How to use getDesc method in wpt

Best JavaScript code snippet using wpt

server_small.js

Source:server_small.js Github

copy

Full Screen

...34 GraphQLNonNull35} = require('graphql');36/**37 * Get descriptions from json file. 38 * NOTE: getDesc(this.name) not possible because this.name refers to keyname of object, and not the key 'name' IN the object (this 'name' is reserved)39 */40const descriptions = JSON.parse(fs.readFileSync('descriptions.json', 'utf8'));41function getDesc(name) {42 return descriptions[name]43}44/**45 * START - ALL RELATED TO INTERNAL FUNCTION46 */47/**48 * Create enum for filter operators49 */50var WhereOperators = new GraphQLEnumType({51 name: "WhereOperatorEnum",52 description: function() {53 return getDesc("WhereOperatorEnum")},54 values: {55 "And": {56 value: "And"57 }, 58 "Or": {59 value: "Or"60 }, 61 "Equal": {62 value: "Equal"63 }, 64 "Not": {65 value: "NotEqual"66 }, 67 "NotEqual": {68 value: "NotEqual"69 }, 70 "GreaterThan": {71 value: "GreaterThan"72 }, 73 "GreaterThanEqual": {74 value: "GreaterThanEqual"75 }, 76 "LessThan": {77 value: "LessThan"78 },79 "LessThanEqual": {80 value: "LessThanEqual"81 },82 }83})84/**85 * Create filter fields for queries86 */87var whereFields = {88 operator: {89 name: "WhereOperator",90 description: function() {91 return getDesc("WhereOperator")},92 type: WhereOperators93 },94 operands: {95 name: "WhereOperands",96 description: function() {97 return getDesc("WhereOperands")},98 type: new GraphQLList(new GraphQLInputObjectType({99 name: "WhereOperandsInpObj",100 description: function() {101 return getDesc("WhereOperandsInpObj")},102 fields: function () {return whereFields}103 }))104 },105 path: { 106 name: "WherePath",107 description: function() {108 return getDesc("WherePath")},109 type: new GraphQLList(GraphQLString) 110 },111 valueInt: { 112 name: "WhereValueInt",113 description: function() {114 return getDesc("WhereValueInt")},115 type: GraphQLInt 116 },117 valueNumber: { 118 name: "WhereValueNumber",119 description: function() {120 return getDesc("WhereValueNumber")},121 type: GraphQLFloat122 },123 valueBoolean: { 124 name: "WhereValueBoolean",125 description: function() {126 return getDesc("WhereValueBoolean")},127 type: GraphQLBoolean128 },129 valueString: { 130 name: "WhereValueString",131 description: function() {132 return getDesc("WhereValueString")},133 type: GraphQLString 134 }135}136/**137 * Create class enum for filter options138 */139var fuzzyFetchEnum = new GraphQLEnumType({140 name: "fuzzyFetchPropertiesValueTypeEnum",141 description: function() {142 return getDesc("fuzzyFetchPropertiesValueTypeEnum")},143 values: {144 "EQ": {145 value: "EQ"146 }, 147 "NEQ": {148 value: "NEQ"149 }, 150 "PREFIX": {151 value: "PREFIX"152 }, 153 "REGEX": {154 value: "REGEX"155 }, 156 "FUZZY": {157 value: "FUZZY"158 }159 }160})161/**162 * Create class enum for filter options163 */164function createClassEnum(ontologyThings) {165 var enumValues = {}166 var count = 0167 // loop through classes168 ontologyThings.classes.forEach(singleClass => {169 // create enum item170 enumValues[singleClass.class] = {"value": singleClass.class}171 count += 1172 })173 174 var classEnum = new GraphQLEnumType({175 name: 'classEnum',176 description: function() {177 return getDesc("classEnum")},178 values: enumValues,179 });180 return classEnum181}182 183/**184 * Create arguments for the network function185 */186var argsKeywords = new GraphQLInputObjectType({187 name: "argsKeywords",188 description: function() {189 return getDesc("argsKeywords")},190 fields: {191 keyword: {192 name: "WeaviateNetworkKeywordsKeyword",193 description: function() {194 return getDesc("WeaviateNetworkKeywordsKeyword")},195 type: GraphQLString196 },197 weight: {198 name: "WeaviateNetworkKeywordsWeight",199 description: function() {200 return getDesc("WeaviateNetworkKeywordsWeight")},201 type: GraphQLFloat202 }203 }204})205/**206 * create arguments for a search207 */208var propsForArgs = {} //global209function createArgs(item){210 // check if argument name is defined, if not, create it211 if(propsForArgs[item.class] == undefined){212 // empty argument213 propsForArgs[item.class] = {}214 // always return first215 propsForArgs[item.class]["first"] = {216 name: "firstFilter",217 type: GraphQLInt,218 description: function() {219 return getDesc("firstFilter")},220 }221 // always return after222 propsForArgs[item.class]["after"] = {223 name: "afterFilter",224 type: GraphQLInt,225 description: function() {226 return getDesc("afterFilter")},227 }228 }229 230 return propsForArgs[item.class] // return the prop with the argument231}232/**233 * Create the subclasses of a Thing or Action in the Local function234 */235function createMetaSubClasses(ontologyThings){236 console.log("------START METASUBCLASSES--------")237 var subClasses = {};238 // loop through classes239 ontologyThings.classes.forEach(singleClass => {240 //console.log(singleClass.class)241 // create recursive sub classes242 subClasses[singleClass.class] = new GraphQLObjectType({243 name: "Meta" + singleClass.class,244 description: singleClass.description,245 fields: function(){246 // declare props that should be returned247 var returnProps = {}248 returnProps["meta"] = {249 name: "Meta"+ singleClass.class + "Meta",250 description: function() {251 return getDesc("MetaClassMeta")},252 type: new GraphQLObjectType({253 name: "Meta" + singleClass.class + "MetaObj",254 description: function() {255 return getDesc("MetaClassMetaObj")},256 fields: {257 count: {258 name: "Meta" + singleClass.class + "MetaCount",259 description: function() {260 return getDesc("MetaClassMetaCount")},261 type: GraphQLInt262 }263 }264 })265 }266 267 // loop over properties268 singleClass.properties.forEach(singleClassProperty => {269 returntypes = []270 standard_fields = {271 type: {272 name: "Meta" + singleClass.class + singleClassProperty.name + "Type",273 description: function() {274 return getDesc("MetaClassPropertyType")},275 type: GraphQLString,276 },277 count: {278 name: "Meta" + singleClass.class + singleClassProperty.name + "Count",279 description: function() {280 return getDesc("MetaClassPropertyCount")},281 type: GraphQLInt,282 }283 }284 singleClassProperty["@dataType"].forEach(singleClassPropertyDatatype => {285 // if class (start with capital, return Class)286 if(singleClassPropertyDatatype[0] === singleClassPropertyDatatype[0].toUpperCase()){287 returnProps[singleClassProperty.name] = {288 name: "Meta" + singleClass.class + singleClassProperty.name,289 description: "Meta information about the property \"" + singleClassProperty.name + "\"",290 type: new GraphQLObjectType({291 name: "Meta" + singleClass.class + singleClassProperty.name + "Obj",292 description: function() {293 return getDesc("MetaClassPropertyObj")},294 fields: Object.assign(standard_fields, {295 pointingTo: {296 name: "Meta" + singleClass.class + singleClassProperty.name + "PointingTo",297 description: function() {298 return getDesc("MetaClassPropertyPointingTo")},299 type: new GraphQLList(GraphQLString)300 }301 })302 })303 }304 } else if(singleClassPropertyDatatype === "string" || singleClassPropertyDatatype === "date") {305 topOccurrencesType = new GraphQLObjectType({306 name: "Meta" + singleClass.class + singleClassProperty.name + "TopOccurrencesObj",307 description: function() {308 return getDesc("MetaClassPropertyTopOccurrencesObj")},309 fields: {310 value: {311 name: "Meta" + singleClass.class + singleClassProperty.name + "TopOccurrencesValue",312 description: function() {313 return getDesc("MetaClassPropertyTopOccurrencesValue")},314 type: GraphQLString315 },316 occurs: {317 name: "Meta" + singleClass.class + singleClassProperty.name + "TopOccurrencesOccurs",318 description: function() {319 return getDesc("MetaClassPropertyTopOccurrencesOccurs")},320 type: GraphQLInt321 }322 }323 })324 returnProps[singleClassProperty.name] = {325 name: "Meta" + singleClass.class + singleClassProperty.name,326 description: "Meta information about the property \"" + singleClassProperty.name + "\"",327 type: new GraphQLObjectType({328 name: "Meta" + singleClass.class + singleClassProperty.name + "Obj",329 description: function() {330 return getDesc("MetaClassPropertyObj")},331 fields: Object.assign(standard_fields, {332 topOccurrences: {333 name: "Meta" + singleClass.class + singleClassProperty.name + "TopOccurrences",334 description: function() {335 return getDesc("MetaClassPropertyTopOccurrences")},336 type: new GraphQLList( topOccurrencesType ),337 args: {338 first: { 339 name: "firstFilter",340 description: function() {341 return getDesc("firstFilter")},342 type: GraphQLInt 343 },344 after: { 345 name: "afterFilter",346 description: function() {347 return getDesc("afterFilter")},348 type: GraphQLInt 349 }350 },351 resolve(parentValue, args) {352 data = parentValue.topOccurrences353 if (args.after) {354 data = data.splice(args.after)355 }356 if (args.first) {357 data = data.splice(0, args.first)358 }359 return data360 }361 }362 })363 })364 }365 } else if(singleClassPropertyDatatype === "int" || singleClassPropertyDatatype === "number") {366 returnProps[singleClassProperty.name] = {367 name: "Meta" + singleClass.class + singleClassProperty.name,368 description: "Meta information about the property \"" + singleClassProperty.name + "\"",369 type: new GraphQLObjectType({370 name: "Meta" + singleClass.class + singleClassProperty.name + "Obj",371 description: function() {372 return getDesc("MetaClassPropertyObj")},373 fields: Object.assign(standard_fields, {374 lowest: {375 name: "Meta" + singleClass.class + singleClassProperty.name + "Lowest",376 description: function() {377 return getDesc("MetaClassPropertyLowest")},378 type: GraphQLFloat,379 },380 highest: {381 name: "Meta" + singleClass.class + singleClassProperty.name + "Highest",382 description: function() {383 return getDesc("MetaClassPropertyHighest")},384 type: GraphQLFloat,385 },386 average: {387 name: "Meta" + singleClass.class + singleClassProperty.name + "Average",388 description: function() {389 return getDesc("MetaClassPropertyAverage")},390 type: GraphQLFloat,391 },392 sum: {393 name: "Meta" + singleClass.class + singleClassProperty.name + "Sum",394 description: function() {395 return getDesc("MetaClassPropertySum")},396 type: GraphQLFloat,397 }398 })399 })400 }401 } else if(singleClassPropertyDatatype === "boolean") {402 returnProps[singleClassProperty.name] = {403 name: "Meta" + singleClass.class + singleClassProperty.name,404 description: "Meta information about the property \"" + singleClassProperty.name + "\"",405 type: new GraphQLObjectType({406 name: "Meta" + singleClass.class + singleClassProperty.name + "Obj",407 description: function() {408 return getDesc("MetaClassPropertyObj")},409 fields: Object.assign(standard_fields, {410 totalTrue: {411 name: "Meta" + singleClass.class + singleClassProperty.name + "TotalTrue",412 description: function() {413 return getDesc("MetaClassPropertyTotalTrue")},414 type: GraphQLInt,415 },416 percentageTrue: {417 name: "Meta" + singleClass.class + singleClassProperty.name + "PercentageTrue",418 description: function() {419 return getDesc("MetaClassPropertyPerentageTrue")},420 type: GraphQLFloat,421 }422 })423 })424 }425 // TO DO: CREATE META INFORMATION FOR DATE, NOW THIS IS SAME AS STRING DATATYPE426 // } else if(singleClassPropertyDatatype === "date") {427 // returnProps[singleClassProperty.name] = {428 // name: "Meta" + singleClass.class + singleClassProperty.name,429 // description: singleClassProperty.description,430 // type: GraphQLString // string since no GraphQL date type exists431 // }432 } else {433 console.error("I DONT KNOW THIS VALUE! " + singleClassProperty["@dataType"][0])434 returnProps[singleClassProperty.name] = {435 name: "Meta" + singleClass.class + singleClassProperty.name,436 description: singleClassProperty.description,437 type: GraphQLString438 }439 }440 })441 });442 return returnProps443 }444 });445 });446 console.log("------DONE METASUBCLASSES--------")447 return subClasses;448}449/**450 * Create the rootclasses of a Thing or Action in the Local function451 */452function createMetaRootClasses(ontologyThings, metaSubClasses){453 console.log("------START METAROOTCLASSES--------")454 var rootClassesFields = {}455 // loop through classes456 ontologyThings.classes.forEach(singleClass => {457 // create root sub classes458 rootClassesFields[singleClass.class] = {459 name: "Meta" + singleClass.class,460 type: metaSubClasses[singleClass.class],461 description: singleClass.description,462 args: createArgs(singleClass),463 resolve(parentValue, args) {464 return demoResolver.metaRootClassResolver(parentValue, singleClass.class, args)465 }466 }467 })468 console.log("------STOP METAROOTCLASSES--------")469 return rootClassesFields470}471/**472 * Create the subclasses of a Thing or Action in the Local function473 */474function createSubClasses(ontologyThings, weaviate){475 console.log("------START SUBCLASSES--------")476 var subClasses = {};477 // loop through classes478 ontologyThings.classes.forEach(singleClass => {479 //console.log(singleClass.class)480 // create recursive sub classes481 subClasses[singleClass.class] = new GraphQLObjectType({482 name: weaviate + singleClass.class,483 description: singleClass.description,484 fields: function(){485 // declare props that should be returned486 var returnProps = {}487 // add uuid to props488 returnProps["uuid"] = {489 name: "SubClassUuid",490 description: function() {491 return getDesc("SubClassUuid")},492 type: GraphQLString493 }494 // loop over properties495 singleClass.properties.forEach(singleClassProperty => {496 returntypes = []497 singleClassProperty["@dataType"].forEach(singleClassPropertyDatatype => {498 // if class (start with capital, return Class)499 if(singleClassPropertyDatatype[0] === singleClassPropertyDatatype[0].toUpperCase()){500 returntypes.push(subClasses[singleClassPropertyDatatype])501 } else if(singleClassPropertyDatatype === "string") {502 returnProps[singleClassProperty.name] = {503 name: weaviate + singleClass.class + singleClassProperty.name,504 description: singleClassProperty.description,505 type: GraphQLString506 }507 } else if(singleClassPropertyDatatype === "int") {508 returnProps[singleClassProperty.name] = {509 name: weaviate + singleClass.class + singleClassProperty.name,510 description: singleClassProperty.description,511 type: GraphQLInt512 }513 } else if(singleClassPropertyDatatype === "number") {514 returnProps[singleClassProperty.name] = {515 name: weaviate + singleClass.class + singleClassProperty.name,516 description: singleClassProperty.description,517 type: GraphQLFloat518 }519 } else if(singleClassPropertyDatatype === "boolean") {520 returnProps[singleClassProperty.name] = {521 name: weaviate + singleClass.class + singleClassProperty.name,522 description: singleClassProperty.description,523 type: GraphQLBoolean524 }525 } else if(singleClassPropertyDatatype === "date") {526 returnProps[singleClassProperty.name] = {527 name: weaviate + singleClass.class + singleClassProperty.name,528 description: singleClassProperty.description,529 type: GraphQLString // string since no GraphQL date type exists530 }} else {531 console.error("I DONT KNOW THIS VALUE! " + singleClassProperty["@dataType"][0])532 returnProps[singleClassProperty.name] = {533 name: weaviate + singleClass.class + singleClassProperty.name,534 description: singleClassProperty.description,535 type: GraphQLString536 }537 }538 })539 if (returntypes.length > 0) {540 returnProps[singleClassProperty.name[0].toUpperCase() + singleClassProperty.name.substring(1)] = {541 name: weaviate + singleClass.class + singleClassProperty.name[0].toUpperCase() + singleClassProperty.name.substring(1),542 description: singleClassProperty.description,543 type: new GraphQLUnionType({544 name: weaviate + singleClass.class + singleClassProperty.name[0].toUpperCase() + singleClassProperty.name.substring(1) + 'Obj', 545 description: singleClassProperty.description,546 types: returntypes,547 resolveType(obj, context, info) {548 // get returntypes here to return right class types549 return subClasses[obj.class]550 },551 }),552 //args: createArgs(thing, false),553 resolve(parentValue, obj) {554 console.log("resolve ROOT CLASS " + singleClassProperty.name[0].toUpperCase() + singleClassProperty.name.substring(1))555 if (typeof parentValue[singleClassProperty.name] === "object") {556 return parentValue[singleClassProperty.name]557 }558 return 559 }560 }561 }562 });563 return returnProps564 }565 });566 });567 console.log("------DONE SUBCLASSES--------")568 return subClasses;569}570 571/**572 * Create the rootclasses of a Thing or Action in the Local function573 */574function createRootClasses(ontologyThings, subClasses){575 console.log("------START ROOTCLASSES--------")576 var rootClassesFields = {}577 // loop through classes578 ontologyThings.classes.forEach(singleClass => {579 // create root sub classes580 rootClassesFields[singleClass.class] = {581 name: singleClass.class,582 type: new GraphQLList(subClasses[singleClass.class]),583 description: singleClass.description,584 args: createArgs(singleClass),585 resolve(parentValue, args) {586 return demoResolver.rootClassResolver(parentValue, singleClass.class, args)587 }588 }589 })590 console.log("------STOP ROOTCLASSES--------")591 return rootClassesFields592}593/**594 * Merge ontologies because both actions and things can refer to eachother595 */596function mergeOntologies(a, b){597 var classCount = [];598 599 var classes = {}600 classes["classes"] = []601 a.classes.forEach(singleClassA => {602 classCount.push(singleClassA.class)603 classes["classes"].push(singleClassA)604 })605 b.classes.forEach(singleClassB => {606 classes["classes"].push(singleClassB)607 })608 console.log("------MERGED ONTOLOGIES--------")609 return classes610}611var NetworkFetchWherePropertyFilterFields = {612 name: {613 name: "NetworkFetchWherePropertyWhereName",614 description: function() {615 return getDesc("NetworkFetchWherePropertyWhereName")},616 type: GraphQLString,617 }, 618 keywords: {619 name: "NetworkFetchWherePropertyWhereKeywords",620 description: function() {621 return getDesc("NetworkFetchWherePropertyWhereKeywords")},622 type: new GraphQLList(new GraphQLInputObjectType({623 name: "NetworkFetchWherePropertyWhereKeywordsInpObj",624 description: function() {625 return getDesc("NetworkFetchWherePropertyWhereKeywordsInpObj")},626 fields: {627 value: {628 name: "NetworkFetchWherePropertyWhereKeywordsValue",629 description: function() {630 return getDesc("NetworkFetchWherePropertyWhereKeywordsValue")},631 type: GraphQLString,632 },633 weight: {634 name: "NetworkFetchWherePropertyWhereKeywordsWeight",635 description: function() {636 return getDesc("NetworkFetchWherePropertyWhereKeywordsWeight")},637 type: GraphQLFloat,638 }639 }640 }))641 }, 642 certainty: {643 name: "NetworkFetchWherePropertyWhereCertainty",644 description: function() {645 return getDesc("NetworkFetchWherePropertyWhereCertainty")},646 type: GraphQLFloat,647 },648 operator: {649 name: "NetworkFetchWherePropertyWhereOperator",650 description: function() {651 return getDesc("NetworkFetchWherePropertyWhereOperator")},652 type: WhereOperators653 },654 valueInt: { 655 name: "NetworkFetchWherePropertyWhereValueInt",656 description: function() {657 return getDesc("WhereValueInt")},658 type: GraphQLInt 659 },660 valueNumber: { 661 name: "NetworkFetchWherePropertyWhereValueNumber",662 description: function() {663 return getDesc("WhereValueNumber")},664 type: GraphQLFloat665 },666 valueBoolean: { 667 name: "NetworkFetchWherePropertyWhereValueBoolean",668 description: function() {669 return getDesc("WhereValueBoolean")},670 type: GraphQLBoolean671 },672 valueString: { 673 name: "NetworkFetchWherePropertyWhereValueString",674 description: function() {675 return getDesc("WhereValueString")},676 type: GraphQLString 677 }678}679/**680 * Create class and property filter options for network fetch 681 */682var NetworkIntrospectWhereClassAndPropertyFilterFields = {683 name: {684 name: "WeaviateNetworkWhereName",685 description: function() {686 return getDesc("WeaviateNetworkWhereName")},687 type: GraphQLString,688 }, 689 keywords: {690 name: "WeaviateNetworkWhereNameKeywords",691 description: function() {692 return getDesc("WeaviateNetworkWhereNameKeywords")},693 type: new GraphQLList(new GraphQLInputObjectType({694 name: "WeaviateNetworkWhereNameKeywordsInpObj",695 description: function() {696 return getDesc("WeaviateNetworkWhereNameKeywordsInpObj")},697 fields: {698 value: {699 name: "WeaviateNetworkWhereNameKeywordsValue",700 description: function() {701 return getDesc("WeaviateNetworkWhereNameKeywordsValue")},702 type: GraphQLString,703 },704 weight: {705 name: "WeaviateNetworkWhereNameKeywordsWeight",706 description: function() {707 return getDesc("WeaviateNetworkWhereNameKeywordsWeight")},708 type: GraphQLFloat,709 }710 }711 }))712 }, 713 certainty: {714 name: "WeaviateNetworkWhereCertainty",715 description: function() {716 return getDesc("WeaviateNetworkWhereCertainty")},717 type: GraphQLFloat,718 }, 719 first: {720 name: "WeaviateNetworkWhereFirst",721 description: function() {722 return getDesc("WeaviateNetworkWhereFirst")},723 type: GraphQLInt,724 }725}726/**727 * Create filter options for network fetch 728 */729var NetworkIntrospectWhereFilterFields = {730 where: { 731 name: "WeaviateNetworkIntrospectWhere",732 description: function() {733 return getDesc("WeaviateNetworkIntrospectWhere")},734 type: new GraphQLList(new GraphQLInputObjectType({735 name: "WeaviateNetworkIntrospectWhereInpObj",736 description: function() {737 return getDesc("WeaviateNetworkIntrospectWhereInpObj")},738 fields: {739 class: {740 name: "WeaviateNetworkIntrospectWhereClass",741 description: function() {742 return getDesc("WeaviateNetworkIntrospectWhereClass")},743 type: new GraphQLList(new GraphQLInputObjectType({744 name: "WeaviateNetworkIntrospectWhereClassObj",745 description: function() {746 return getDesc("WeaviateNetworkIntrospectWhereClassObj")},747 fields: NetworkIntrospectWhereClassAndPropertyFilterFields748 }))749 },750 properties: {751 name: "WeaviateNetworkIntrospectWhereProperties",752 description: function() {753 return getDesc("WeaviateNetworkIntrospectWhereProperties")},754 type: new GraphQLList(new GraphQLInputObjectType({755 name: "WeaviateNetworkIntrospectWherePropertiesObj",756 description: function() {757 return getDesc("WeaviateNetworkIntrospectWherePropertiesObj")},758 fields: NetworkIntrospectWhereClassAndPropertyFilterFields759 }))760 }761 }762 })) //Needs to be in contextionary, weight = always 1.0763 }764}765var NetworkFetchFilterFields = {766 where: { 767 name: "NetworkFetchWhere",768 description: function() {769 return getDesc("NetworkFetchWhere")},770 type: new GraphQLInputObjectType({771 name: "NetworkFetchWhereInpObj",772 description: function() {773 return getDesc("NetworkFetchWhereInpObj")},774 fields: {775 class: {776 name: "NetworkFetchWhereInpObjClass",777 description: function() {778 return getDesc("NetworkFetchWhereInpObjClass")},779 type: new GraphQLList(new GraphQLInputObjectType({780 name: "NetworkFetchWhereInpObjClassInpObj",781 description: function() {782 return getDesc("NetworkFetchWhereInpObjClassInpObj")},783 fields: NetworkIntrospectWhereClassAndPropertyFilterFields784 }))785 },786 properties: {787 name: "NetworkFetchWhereInpObjProperties",788 description: function() {789 return getDesc("NetworkFetchWhereInpObjProperties")},790 type: new GraphQLList(new GraphQLInputObjectType({791 name: "NetworkFetchWhereInpObjProperties",792 description: function() {793 return getDesc("NetworkFetchWhereInpObjProperties")},794 fields: NetworkFetchWherePropertyFilterFields795 }))796 },797 first: {798 name: "NetworkFetchWhereInpObjFirst",799 description: function() {800 return getDesc("NetworkFetchWhereInpObjFirst")},801 type: GraphQLInt,802 }803 }804 }) //Needs to be in contextionary, weight = always 1.0805 }806}807/**808 * END - ALL RELATED TO INTERNAL809 */810/**811 * START - ALL RELATED TO NETWORK812 */813function getWeaviateNetworkGetWeaviateFields(weaviate) {814 var thingsFile = './network/' + weaviate + '/things_schema.json';815 var actionsFile = './network/' + weaviate + '/things_schema.json';816 //let ontologyThings = require(thingsFile);817 //let ontologyActions = require(actionsFile);818 let ontologyThings = fs.readFileSync(thingsFile, {encoding:'utf8'});819 let ontologyActions = fs.readFileSync(actionsFile, {encoding:'utf8'});820 // merge821 classes = mergeOntologies(JSON.parse(ontologyThings), JSON.parse(ontologyActions))822 var localSubClasses = createSubClasses(classes, weaviate);823 var rootClassesNetworkThingsFields = createRootClasses(JSON.parse(ontologyThings), localSubClasses);824 var rootClassesNetworkActionsFields = createRootClasses(JSON.parse(ontologyActions), localSubClasses);825 fields = {826 Things: {827 name: "WeaviateNetworkGet" + weaviate[0].toUpperCase() + weaviate.substring(1) + "Things",828 description: function() {829 return getDesc("WeaviateNetworkGetThings")},830 type: new GraphQLObjectType({831 name: "WeaviateNetworkGet" + weaviate[0].toUpperCase() + weaviate.substring(1) + "ThingsObj",832 description: function() {833 return getDesc("WeaviateNetworkGetThingsObj")},834 fields: rootClassesNetworkThingsFields835 }),836 resolve(parentValue) {837 console.log("resolve WeaviateNetworkGet" + weaviate[0].toUpperCase() + weaviate.substring(1) + "Things")838 return parentValue.Things // resolve with empty array839 },840 },841 Actions: {842 name: "WeaviateNetworkGet" + weaviate[0].toUpperCase() + weaviate.substring(1) + "Actions",843 description: function() {844 return getDesc("WeaviateNetworkGetActions")},845 type: new GraphQLObjectType({846 name: "WeaviateNetworkGet" + weaviate[0].toUpperCase() + weaviate.substring(1) + "ActionsObj",847 description: function() {848 return getDesc("WeaviateNetworkGetActionsObj")},849 fields: rootClassesNetworkActionsFields850 }),851 resolve(parentValue) {852 console.log("resolve WeaviateNetworkGet" + weaviate[0].toUpperCase() + weaviate.substring(1) + "Actions")853 return parentValue.Actions // resolve with empty array854 }855 }856 }857return fields858}859function createNetworkWeaviateFields() {860 console.log("------START NETWORKWEAVIATEFIELDS--------")861 var networkFields = {}862 function getDirectories(path) {863 return fs.readdirSync(path).filter(function (file) {864 return fs.statSync(path+'/'+file).isDirectory();865 });866 }867 var weaviates = getDirectories("./network");868 weaviates.forEach(weaviate => {869 networkFields[weaviate] = {870 name: "WeaviateNetworkGet" + weaviate[0].toUpperCase() + weaviate.substring(1),871 description: "Object field for weaviate " + weaviate + " in the network.",872 type: new GraphQLObjectType({873 name: "WeaviateNetworkGet" + weaviate[0].toUpperCase() + weaviate.substring(1) + "Obj",874 description: "Objects for the what to Get from the weaviate " + weaviate + " in the network.",875 fields: getWeaviateNetworkGetWeaviateFields(weaviate)876 }),877 resolve(parentValue){878 console.log("resolve WeaviateNetworkGet" + weaviate[0].toUpperCase() + weaviate.substring(1))879 return parentValue[weaviate] // resolve with empty array880 }881 }882 })883 console.log("------STOP NETWORKWEAVIATEFIELDS--------")884 return networkFields885}886var NetworkIntrospectThingsActionsFields = {887 weaviate: {888 name: "WeaviateNetworkIntrospectWeaviate",889 description: function() {890 return getDesc("WeaviateNetworkIntrospectWeaviate")},891 type: GraphQLString892 },893 className: {894 name: "WeaviateNetworkIntrospectClassName",895 description: function() {896 return getDesc("WeaviateNetworkIntrospectClassName")},897 type: GraphQLString898 },899 certainty: {900 name: "WeaviateNetworkIntrospectCertainty",901 description: function() {902 return getDesc("WeaviateNetworkIntrospectCertainty")},903 type: GraphQLFloat904 },905 properties: {906 name: "WeaviateNetworkIntrospectProperties",907 description: function() {908 return getDesc("WeaviateNetworkIntrospectProperties")},909 type: new GraphQLList(new GraphQLObjectType({910 name: "WeaviateNetworkIntrospectPropertiesObj",911 description: function() {912 return getDesc("WeaviateNetworkIntrospectPropertiesObj")},913 fields: {914 propertyName: {915 name: "WeaviateNetworkIntrospectPropertiesPropertyName",916 description: function() {917 return getDesc("WeaviateNetworkIntrospectPropertiesPropertyName")},918 type: GraphQLString919 },920 certainty: {921 name: "WeaviateNetworkIntrospectPropertiesCertainty",922 description: function() {923 return getDesc("WeaviateNetworkIntrospectPropertiesCertainty")},924 type: GraphQLFloat925 }926 }927 }))928 }929}930var NetworkIntrospectBeaconFields = {931 weaviate: {932 name: "WeaviateNetworkIntrospectBeaconWeaviate",933 description: function() {934 return getDesc("WeaviateNetworkIntrospectWeaviate")},935 type: GraphQLString936 },937 className: {938 name: "WeaviateNetworkIntrospectBeaconClassName",939 description: function() {940 return getDesc("WeaviateNetworkIntrospectClassName")},941 type: GraphQLString942 },943 properties: {944 name: "WeaviateNetworkIntrospectBeaconProperties",945 description: function() {946 return getDesc("WeaviateNetworkIntrospectProperties")},947 type: new GraphQLList(new GraphQLObjectType({948 name: "WeaviateNetworkIntrospectBeaconPropertiesObj",949 description: function() {950 return getDesc("WeaviateNetworkIntrospectBeaconPropertiesObj")},951 fields: {952 propertyName: {953 name: "WeaviateNetworkIntrospectPropertiesBeaconPropertyName",954 description: function() {955 return getDesc("WeaviateNetworkIntrospectPropertiesPropertyName")},956 type: GraphQLString957 }958 }959 }))960 }961}962/**963 * END - ALL RELATED TO NETWORK964 */965/**966 * START CONSTRUCTING THE SERVICE967 */968fs.readFile('demo_schemas/things_schema.json', 'utf8', function(err, ontologyThings) { // read things ontology969 fs.readFile('demo_schemas/actions_schema.json', 'utf8', function(err, ontologyActions) { // read actions ontology970 // merge971 classes = mergeOntologies(JSON.parse(ontologyThings), JSON.parse(ontologyActions))972 // create GraphQL fields for words in contextionary973 // var contextionaryWords = createContextionaryFields(nouns);974 975 // create the root and sub classes based on the Weaviate schemas976 var localSubClasses = createSubClasses(classes, "");977 var rootClassesThingsFields = createRootClasses(JSON.parse(ontologyThings), localSubClasses);978 var rootClassesActionsFields = createRootClasses(JSON.parse(ontologyActions), localSubClasses);979 var classesEnum = createClassEnum(classes);980 // var PinPointField = createPinPointField(classes);981 var metaSubClasses = createMetaSubClasses(classes)982 var metaRootClassesThingsFields = createMetaRootClasses(JSON.parse(ontologyThings), metaSubClasses);983 var metaRootClassesActionsFields = createMetaRootClasses(JSON.parse(ontologyActions), metaSubClasses);984 var networkWeaviateFields = createNetworkWeaviateFields()985 // This is the root 986 var Weaviate = new GraphQLObjectType({987 name: 'WeaviateObj',988 description: function() {989 return getDesc("WeaviateObj")},990 fields: {991 Local: {992 name: "WeaviateLocal",993 description: function() {994 return getDesc("WeaviateLocal")},995 resolve() {996 console.log("resolve WeaviateLocal")997 return [{}] // resolve with empty array998 },999 type: new GraphQLObjectType({1000 name: "WeaviateLocalObj",1001 description: function() {1002 return getDesc("WeaviateLocalObj")},1003 resolve() {1004 console.log("resolve WeaviateLocalObj")1005 return [{}] // resolve with empty array1006 },1007 fields: {1008 Get: {1009 name: "WeaviateLocalGet",1010 description: function() {1011 return getDesc("WeaviateLocalGet")},1012 args: {1013 where: { 1014 name: "WeaviateLocalGetWhere",1015 description: function() {1016 return getDesc("WeaviateLocalGetWhere")},1017 type: new GraphQLInputObjectType({1018 name: "WeaviateLocalGetWhereInpObj",1019 description: function() {1020 return getDesc("WeaviateLocalGetWhereInpObj")},1021 fields: whereFields1022 }) 1023 }1024 },1025 type: new GraphQLObjectType({1026 name: "WeaviateLocalGetObj",1027 description: function() {1028 return getDesc("WeaviateLocalGetObj")},1029 fields: {1030 Things: {1031 name: "WeaviateLocalGetThings",1032 description: function() {1033 return getDesc("WeaviateLocalGetThings")},1034 type: new GraphQLObjectType({1035 name: "WeaviateLocalGetThingsObj",1036 description: function() {1037 return getDesc("WeaviateLocalGetThingsObj")},1038 fields: rootClassesThingsFields1039 }),1040 resolve(parentValue) {1041 console.log("resolve WeaviateLocalGetThings")1042 return parentValue.Things // resolve with empty array1043 },1044 },1045 Actions: {1046 name: "WeaviateLocalGetActions",1047 description: function() {1048 return getDesc("WeaviateLocalGetActions")},1049 type: new GraphQLObjectType({1050 name: "WeaviateLocalGetActionsObj",1051 description: function() {1052 return getDesc("WeaviateLocalGetActionsObj")},1053 fields: rootClassesActionsFields1054 }),1055 resolve(parentValue) {1056 console.log("resolve WeaviateLocalGetActions")1057 return parentValue.Actions // resolve with empty array1058 }1059 }1060 }1061 }),1062 resolve(parentValue, args) {1063 console.log("resolve WeaviateLocalGet")1064 return demoResolver.resolveGet(args.where) // resolve with empty array1065 },1066 },1067 GetMeta: {1068 name: "WeaviateLocalGetMeta",1069 description: function() {1070 return getDesc("WeaviateLocalGetMeta")},1071 args: {1072 where: { 1073 name: "WeaviateLocalGetMetaWhere",1074 description: function() {1075 return getDesc("WeaviateLocalGetMetaWhere")},1076 type: new GraphQLInputObjectType({1077 name: "WeaviateLocalGetMetaWhereInpObj",1078 description: function() {1079 return getDesc("WeaviateLocalGetMetaWhereInpObj")},1080 fields: whereFields1081 }) 1082 }1083 },1084 type: new GraphQLObjectType({1085 name: "WeaviateLocalGetMetaObj",1086 description: function() {1087 return getDesc("WeaviateLocalGetMetaObj")},1088 fields: {1089 Things: {1090 name: "WeaviateLocalGetMetaThings",1091 description: function() {1092 return getDesc("WeaviateLocalGetMetaThings")},1093 type: new GraphQLObjectType({1094 name: "WeaviateLocalGetMetaThingsObj",1095 description: function() {1096 return getDesc("WeaviateLocalGetMetaThingsObj")},1097 fields: metaRootClassesThingsFields1098 }),1099 resolve(parentValue, args) {1100 console.log("resolve WeaviateLocalGetMetaThings")1101 return parentValue.Things // resolve with empty array1102 }1103 }, 1104 Actions: {1105 name: "WeaviateLocalGetMetaActions",1106 description: function() {1107 return getDesc("WeaviateLocalGetMetaActions")},1108 type: new GraphQLObjectType({1109 name: "WeaviateLocalGetMetaActionsObj",1110 description: function() {1111 return getDesc("WeaviateLocalGetMetaActionsObj")},1112 fields: metaRootClassesActionsFields1113 }),1114 resolve(parentValue, args) {1115 console.log("resolve WeaviateLocalGetMetaActions")1116 return parentValue.Actions // resolve with empty array1117 }1118 }1119 },1120 }),1121 resolve(parentValue, args) {1122 console.log("resolve WeaviateLocalGetMeta")1123 return demoResolver.resolveGet(args.where) // resolve with empty array1124 },1125 },1126 }1127 })1128 },1129 Network: {1130 name: "WeaviateNetwork",1131 description: function() {1132 return getDesc("WeaviateNetwork")},1133 args: {1134 networkTimeout: { 1135 name: "WeaviateNetworkNetworkTimeout",1136 description: function() {1137 return getDesc("WeaviateNetworkNetworkTimeout")},1138 type: GraphQLInt1139 },1140 // network: {1141 // name: "WeaviateNetworkNetworkNetwork",1142 // description: function() {1143 // return getDesc("WeaviateNetworkNetworkNetwork")},1144 // type: GraphQLString1145 // }1146 },1147 resolve() {1148 console.log("resolve WeaviateNetwork")1149 return [{}] // resolve with empty array1150 },1151 type: new GraphQLObjectType({1152 name: "WeaviateNetworkObj",1153 description: function() {1154 return getDesc("WeaviateNetworkObj")},1155 fields: {1156 Get: {1157 name: "WeaviateNetworkGet",1158 description: function() {1159 return getDesc("WeaviateNetworkGet")},1160 args: {1161 where: { 1162 name: "WeaviateNetworkGetWhere",1163 description: function() {1164 return getDesc("WeaviateNetworkGetWhere")},1165 type: new GraphQLInputObjectType({1166 name: "WeaviateNetworkGetWhereInpObj",1167 description: function() {1168 return getDesc("WeaviateNetworkGetWhereInpObj")},1169 fields: whereFields1170 }) 1171 }1172 },1173 type: new GraphQLObjectType({1174 name: "WeaviateNetworkGetObj",1175 description: function() {1176 return getDesc("WeaviateNetworkGetObj")},1177 fields: networkWeaviateFields1178 }),1179 resolve(parentValue, args) {1180 console.log("resolve WeaviateNetworkGet")1181 return demoResolver.resolveNetworkGet(args.where) // resolve with empty array1182 },1183 },1184 Fetch: {1185 name: "WeaviateNetworkFetch",1186 description: function() {1187 return getDesc("WeaviateNetworkFetch")},1188 type: new GraphQLObjectType({1189 name: "WeaviateNetworkFetchObj",1190 description: function() {1191 return getDesc("WeaviateNetworkFetchObj")},1192 fields: {1193 Fuzzy: {1194 name: "WeaviateNetworkFetchFuzzy",1195 description: function() {1196 return getDesc("WeaviateNetworkFetchFuzzy")},1197 args: {1198 value: { 1199 name: "WeaviateNetworkFetchFuzzyArgValue",1200 description: function() {1201 return getDesc("WeaviateNetworkFetchFuzzyArgValue")},1202 type: new GraphQLNonNull(GraphQLString)1203 },1204 certainty: { 1205 name: "WeaviateNetworkFetchFuzzyArgCertainty",1206 description: function() {1207 return getDesc("WeaviateNetworkFetchFuzzyArgCertainty")},1208 type: new GraphQLNonNull(GraphQLFloat)1209 }1210 },1211 type: new GraphQLList(new GraphQLObjectType({1212 name: "WeaviateNetworkFetchFuzzyObj",1213 description: function() {1214 return getDesc("WeaviateNetworkFetchFuzzyObj")},1215 fields: {1216 beacon: { // The beacon to do a convertedfetch1217 name: "WeaviateNetworkFetchFuzzyBeacon",1218 description: function() {1219 return getDesc("WeaviateNetworkFetchFuzzyBeacon")},1220 type: GraphQLString1221 }, 1222 certainty: { // What is the certainty to the original request?1223 name: "WeaviateNetworkFetchFuzzyCertainty",1224 description: function() {1225 return getDesc("WeaviateNetworkFetchFuzzyCertainty")},1226 type: GraphQLFloat1227 }1228 }1229 })),1230 resolve(parentValue, args) {1231 console.log("resolve WeaviateNetworkFetchFuzzy")1232 return [{}]1233 }1234 },1235 Things: {1236 name: "WeaviateNetworkFetchThings",1237 description: function() {1238 return getDesc("WeaviateNetworkFetchThings")},1239 args: NetworkFetchFilterFields,1240 type: new GraphQLList(new GraphQLObjectType({1241 name: "WeaviateNetworkFetchThingsObj",1242 description: function() {1243 return getDesc("WeaviateNetworkFetchThingsObj")},1244 fields: {1245 beacon: { // The beacon to do a convertedfetch1246 name: "WeaviateNetworkFetchThingsBeacon",1247 description: function() {1248 return getDesc("WeaviateNetworkFetchThingsBeacon")},1249 type: GraphQLString1250 }, 1251 certainty: { // What is the certainty to the original request?1252 name: "WeaviateNetworkFetchThingsCertainty",1253 description: function() {1254 return getDesc("WeaviateNetworkFetchThingsCertainty")},1255 type: GraphQLFloat1256 }1257 }1258 })),1259 resolve(parentValue, args) {1260 console.log("resolve WeaviateNetworkFetchThings")1261 return demoResolver.resolveNetworkFetch(args)1262 }1263 },1264 Actions: {1265 name: "WeaviateNetworkFetchActions",1266 description: function() {1267 return getDesc("WeaviateNetworkFetchActions")},1268 args: NetworkFetchFilterFields,1269 type: new GraphQLList(new GraphQLObjectType({1270 name: "WeaviateNetworkFetchActionsObj",1271 description: function() {1272 return getDesc("WeaviateNetworkFetchActionsObj")},1273 fields: {1274 beacon: {1275 name: "WeaviateNetworkFetchActionsBeacon",1276 description: function() {1277 return getDesc("WeaviateNetworkFetchActionsBeacon")},1278 type: GraphQLString,1279 resolve(parentValue, args) {1280 console.log("resolve WeaviateNetworkFetchActionsBeacon")1281 return [{}] // resolve with empty array1282 }1283 }, 1284 certainty: {1285 name: "WeaviateNetworkFetchActionsCertainty",1286 description: function() {1287 return getDesc("WeaviateNetworkFetchActionsCertainty")},1288 type: GraphQLFloat, // should be enum of type (id est, string, int, cref etc)1289 resolve(parentValue, args) {1290 console.log("resolve WeaviateNetworkFetchActionsCertainty")1291 return [{}] // resolve with empty array1292 }1293 }1294 }1295 })),1296 resolve(parentValue, args) {1297 console.log("resolve WeaviateNetworkFetchActions")1298 return demoResolver.resolveNetworkFetch(args)1299 }1300 },1301 }1302 }),1303 resolve() {1304 console.log("resolve WeaviateNetworkFetch")1305 return [{}] // resolve with empty array1306 },1307 },1308 Introspect: {1309 name: "WeaviateNetworkIntrospect",1310 description: function() {1311 return getDesc("WeaviateNetworkIntrospect")},1312 type: new GraphQLObjectType({1313 name: "WeaviateNetworkIntrospectObj",1314 description: function() {1315 return getDesc("WeaviateNetworkIntrospectObj")},1316 fields: {1317 Things: {1318 name: "WeaviateNetworkIntrospectThings",1319 description: function() {1320 return getDesc("WeaviateNetworkIntrospectThings")},1321 args: NetworkIntrospectWhereFilterFields,1322 type: new GraphQLList(new GraphQLObjectType({1323 name: "WeaviateNetworkIntrospectThingsObj",1324 description: function() {1325 return getDesc("WeaviateNetworkIntrospectThingsObj")},1326 fields: NetworkIntrospectThingsActionsFields1327 })),1328 resolve(parentValue, args) {1329 console.log("resolve WeaviateNetworkIntrospectThings")1330 return demoResolver.resolveNetworkIntrospect(args) // resolve with empty array1331 }1332 },1333 Actions: {1334 name: "WeaviateNetworkIntrospectActions",1335 description: function() {1336 return getDesc("WeaviateNetworkIntrospectActions")},1337 args: NetworkIntrospectWhereFilterFields,1338 type: new GraphQLList(new GraphQLObjectType({1339 name: "WeaviateNetworkIntrospectActionsObj",1340 description: function() {1341 return getDesc("WeaviateNetworkIntrospectActionsObj")},1342 fields: NetworkIntrospectThingsActionsFields1343 })),1344 resolve(parentValue, args) {1345 console.log("resolve WeaviateNetworkIntrospectActions")1346 return demoResolver.resolveNetworkIntrospect(args) // resolve with empty array1347 }1348 },1349 Beacon: {1350 name: "WeaviateNetworkIntrospectBeacon",1351 description: function() {1352 return getDesc("WeaviateNetworkIntrospectBeacon")},1353 args: {1354 id: { // The id of the beacon like: weaviate://foo-bar-baz/UUID1355 name: "WeaviateNetworkIntrospectBeaconId",1356 description: function() {1357 return getDesc("WeaviateNetworkIntrospectBeaconId")},1358 type: new GraphQLNonNull(GraphQLString)1359 }1360 },1361 type: new GraphQLObjectType({1362 name: "WeaviateNetworkIntrospectBeaconObj",1363 description: function() {1364 return getDesc("WeaviateNetworkIntrospectBeaconObj")},1365 fields: NetworkIntrospectBeaconFields1366 }),1367 resolve(parentValue, args) {1368 console.log("resolve WeaviateNetworkIntrospectBeacon")1369 return demoResolver.resolveNetworkIntrospectBeacon(args) // resolve with empty array1370 }1371 }1372 }1373 }),1374 resolve() {1375 console.log("resolve WeaviateNetworkIntrospect")1376 return [{}] // resolve with empty array1377 }1378 }...

Full Screen

Full Screen

Theory.js

Source:Theory.js Github

copy

Full Screen

...17 // a118 {19 let getDesc = (level) => "a_1=" + getA1(level).toString(0);20 a1 = theory.createUpgrade(0, currency, new FirstFreeCost(new ExponentialCost(10, Math.log2(1.5))));21 a1.getDescription = (_) => Utils.getMath(getDesc(a1.level));22 a1.getInfo = (amount) => Utils.getMathTo(getDesc(a1.level), getDesc(a1.level + amount));23 }24 // a225 {26 let getDesc = (level) => "a_2=" + getA2(level).toString(0);27 a2 = theory.createUpgrade(1, currency, new ExponentialCost(110, Math.log2(1.5)));28 a2.getDescription = (_) => Utils.getMath(getDesc(a2.level));29 a2.getInfo = (amount) => Utils.getMathTo(getDesc(a2.level), getDesc(a2.level + amount));30 }31 // a332 {33 let getDesc = (level) => "a_3=" + getA3(level).toString(0);34 a3 = theory.createUpgrade(2, currency, new ExponentialCost(1400, Math.log2(1.5)));35 a3.getDescription = (_) => Utils.getMath(getDesc(a3.level));36 a3.getInfo = (amount) => Utils.getMathTo(getDesc(a3.level), getDesc(a3.level + amount));37 }38 // a439 {40 let getDesc = (level) => "a_4=" + getA4(level).toString(0);41 a4 = theory.createUpgrade(3, currency, new ExponentialCost(15000, Math.log2(1.5)));42 a4.getDescription = (_) => Utils.getMath(getDesc(a4.level));43 a4.getInfo = (amount) => Utils.getMathTo(getDesc(a4.level), getDesc(a4.level + amount));44 }45 // a546 {47 let getDesc = (level) => "a_5=" + getA5(level).toString(0);48 a5 = theory.createUpgrade(4, currency, new ExponentialCost(1.7e6, Math.log2(1.5)));49 a5.getDescription = (_) => Utils.getMath(getDesc(a5.level));50 a5.getInfo = (amount) => Utils.getMathTo(getDesc(a5.level), getDesc(a5.level + amount));51 }52 // a653 {54 let getDesc = (level) => "a_6=" + getA6(level).toString(0);55 a6 = theory.createUpgrade(5, currency, new ExponentialCost(1.8e7, Math.log2(1.5)));56 a6.getDescription = (_) => Utils.getMath(getDesc(a6.level));57 a6.getInfo = (amount) => Utils.getMathTo(getDesc(a6.level), getDesc(a6.level + amount));58 }59 // a760 {61 let getDesc = (level) => "a_7=" + getA7(level).toString(0);62 a7 = theory.createUpgrade(6, currency, new ExponentialCost(1.8e7, Math.log2(1.5)));63 a7.getDescription = (_) => Utils.getMath(getDesc(a7.level));64 a7.getInfo = (amount) => Utils.getMathTo(getDesc(a7.level), getDesc(a7.level + amount));65 }66 // a867 {68 let getDesc = (level) => "a_8=" + getA8(level).toString(0);69 a8 = theory.createUpgrade(7, currency, new ExponentialCost(1.8e9, Math.log2(1.5)));70 a8.getDescription = (_) => Utils.getMath(getDesc(a8.level));71 a8.getInfo = (amount) => Utils.getMathTo(getDesc(a8.level), getDesc(a8.level + amount));72 }73 // a974 {75 let getDesc = (level) => "a_9=" + getA9(level).toString(0);76 a9 = theory.createUpgrade(8, currency, new ExponentialCost(2e10, Math.log2(1.5)));77 a9.getDescription = (_) => Utils.getMath(getDesc(a9.level));78 a9.getInfo = (amount) => Utils.getMathTo(getDesc(a9.level), getDesc(a9.level + amount));79 }80 /////////////////////81 // Permanent Upgrades82 theory.createPublicationUpgrade(0, currency, 1e10);83 theory.createBuyAllUpgrade(1, currency, 1e13);84 theory.createAutoBuyerUpgrade(2, currency, 1e30);85 ///////////////////////86 //// Milestone Upgrades87 theory.setMilestoneCost(new LinearCost(25, 25));88 /////////////////89 //// Achievements90 ///////////////////91 //// Story chapters92}...

Full Screen

Full Screen

help.ts

Source:help.ts Github

copy

Full Screen

...36 * Gets the description of a command37 * @param {string} commandName38 * @return {string}39 */40 function getDesc(commandName:string) {41 logger.debug(`[${PREFIX}] getDesc: ${commandName}`);42 const desc = globalCommands?.filter((command) => command.name === commandName).at(0)?.description ??43 guildCommands?.filter((command) => command.name === commandName).at(0)?.description;44 logger.debug(`[${PREFIX}] getDesc: ${desc}`);45 return desc;46 }47 const hrEmbed = embedTemplate()48 .setTitle('Harm Reduction Modules')49 .addFields(50 {name: 'Drug', value: getDesc('drug'), inline: true},51 {name: 'Combo', value: getDesc('drug'), inline: true},52 {name: 'iDose', value: getDesc('idose'), inline: true},53 {name: 'ComboChart', value: getDesc('drug'), inline: true},54 {name: 'Reagents', value: getDesc('drug'), inline: true},55 {name: 'Calc Psychedelics', value: getDesc('psychedelic_calc'), inline: true},56 {name: 'Calc DXM', value: getDesc('dxm_calc'), inline: true},57 {name: 'Calc Benzos', value: getDesc('benzo_calc'), inline: true},58 {name: 'Calc Ketamine', value: getDesc('ketamine_calc'), inline: true},59 {name: 'Recovery', value: getDesc('recovery'), inline: true},60 {name: 'Breathe', value: getDesc('breathe'), inline: true},61 {name: 'Warmline', value: getDesc('warmline'), inline: true},62 {name: 'KIPP', value: getDesc('kipp'), inline: true},63 {name: 'Hydrate', value: getDesc('hydrate'), inline: true},64 {name: 'EMS', value: getDesc('ems'), inline: true},65 );66 const funEmbed = embedTemplate()67 .setTitle('Other Modules')68 .addFields(69 {name: 'About', value: getDesc('about'), inline: true},70 {name: 'Contact', value: getDesc('contact'), inline: true},71 {name: 'Bug', value: getDesc('bug'), inline: true},72 {name: 'Triptoys', value: getDesc('triptoys'), inline: true},73 {name: 'Imgur', value: getDesc('imgur'), inline: true},74 {name: 'Magick8Ball', value: getDesc('magick8ball'), inline: true},75 {name: 'Urban Define', value: getDesc('urban_define'), inline: true},76 {name: 'Topic', value: getDesc('topic'), inline: true},77 {name: 'Joke', value: getDesc('joke'), inline: true},78 {name: 'Youtube', value: getDesc('youtube'), inline: true},79 {name: 'Coinflip', value: getDesc('coinflip'), inline: true},80 {name: 'Lovebomb', value: getDesc('lovebomb'), inline: true},81 {name: 'Remindme', value: getDesc('remindme'), inline: true},82 {name: 'Convert', value: getDesc('convert'), inline: true},83 {name: 'Poll', value: getDesc('poll'), inline: true},84 );85 const tripsitEmbed = embedTemplate()86 .setTitle('Tripsit-Only Modules')87 .addFields(88 {name: 'TripSit', value: getDesc('tripsit'), inline: true},89 {name: 'Clearchat', value: getDesc('clear-chat'), inline: true},90 {name: 'Bridge', value: getDesc('bridge'), inline: true},91 {name: 'Birthday', value: getDesc('birthday'), inline: true},92 {name: 'Time', value: getDesc('time'), inline: true},93 {name: 'Profile', value: getDesc('profile'), inline: true},94 {name: 'Moderate', value: getDesc('mod'), inline: true},95 {name: 'Report', value: getDesc('report'), inline: true},96 );97 const book = [98 hrEmbed,99 funEmbed,100 tripsitEmbed,101 ];102 paginationEmbed(interaction, book, buttonList, 120000);103 logger.debug(`[${PREFIX}] finished!`);104 },...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getDesc(function(err, data) {4 if (err) {5 console.error('Error: ' + err);6 }7 else {8 console.log(data);9 }10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getDesc(url, function(err, data) {4 console.log(data);5});6var wpt = require('wpt');7var wpt = new WebPageTest('www.webpagetest.org');8wpt.getLocations(function(err, data) {9 console.log(data);10});11var wpt = require('wpt');12var wpt = new WebPageTest('www.webpagetest.org');13wpt.getLocations(function(err, data) {14 console.log(data);15});16var wpt = require('wpt');17var wpt = new WebPageTest('www.webpagetest.org');18wpt.getTesters(function(err, data) {19 console.log(data);20});21var wpt = require('wpt');22var wpt = new WebPageTest('www.webpagetest.org');23wpt.getTestResults('131210_1J_1', function(err, data) {24 console.log(data);25});26var wpt = require('wpt');27var wpt = new WebPageTest('www.webpagetest.org');28wpt.getTestStatus('131210_1J_1', function(err, data) {29 console.log(data);30});31var wpt = require('wpt');32var wpt = new WebPageTest('www.webpagetest.org');33wpt.runTest(url, function(err, data) {34 console.log(data);35});36var wpt = require('wpt');37var wpt = new WebPageTest('www.webpagetest.org');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt.js');2var wpt = new wpt('your wpt api key');3wpt.getDesc('your test id', function(err, data) {4 if(err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var wpt = require('wpt.js');11var wpt = new wpt('your wpt api key');12wpt.getDesc('your test id', function(err, data) {13 if(err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19var request = require('request');20var wpt = function(apiKey) {21 this.apiKey = apiKey;22};23wpt.prototype.getDesc = function(testId, callback) {24 if(err) {25 callback(err, null);26 } else {27 callback(null, body);28 }29 });30};31module.exports = wpt;32var wpt = require('wpt.js');33var wpt = new wpt('your wpt api key');34wpt.getDesc('your test id', function(err, data) {35 if(err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var request = require('request');42var wpt = function(apiKey) {43 this.apiKey = apiKey;44};45wpt.prototype.getDesc = function(testId, callback) {46 if(err) {47 callback(err, null);48 } else {49 callback(null, body);50 }51 });52};53module.exports = wpt;54var wpt = require('wpt.js');55var wpt = new wpt('your wpt api key');56wpt.getDesc('your test id', function(err, data) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var getDesc = function (name) {2 var desc = this.desc[name];3 return desc;4};5var getDesc = function (name) {6 var desc = this.desc[name];7 return desc;8};9var getDesc = function (name) {10 var desc = this.desc[name];11 return desc;12};13var getDesc = function (name) {14 var desc = this.desc[name];15 return desc;16};17var getDesc = function (name) {18 var desc = this.desc[name];19 return desc;20};21var getDesc = function (name) {22 var desc = this.desc[name];23 return desc;24};25var getDesc = function (name) {26 var desc = this.desc[name];27 return desc;28};29var getDesc = function (name) {30 var desc = this.desc[name];31 return desc;32};33var getDesc = function (name) {34 var desc = this.desc[name];35 return desc;36};

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful