UNPKG

42.6 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../es6/LatticeFactory.js"],"names":["getChecklist","setChecklist","hasChecklist","newChecklist","_i","args","colors","depth","CHECKLIST","CHECK_SCHEMA","CHECK_RESOLVERS","CHECK_API_DOCS","Class","META_KEY","item","value","checklist","items","length","keys","complete","reduce","p","c","i","a","Error","dropLowest","ValidationResults","constructor","errors","valid","name","LatticeFactory","validateTemplate","template","hide","results","indent","string","count","space","split","map","s","trim","replace","repeat","join","push","String","schema","resolvers","Object","docs","dr","br","b1","b0","bb","dg","bg","a0","gr","bgr","errorStrings","error","message","stack","splice","generateClass","baseClass","GQLBase","fn","eval","brandClass","injectSchema","defineProperty","get","injectResolvers","tree","SyntaxTree","from","SCHEMA","outline","fields","fieldResolver","LL","warn","prop","info","prototype","type","decorator","resolver","mutator","subscriptor","fnName","injectDocs","copyProp","o","to","as","descriptor","result","TYPE","DOC_CLASS","DOC_FIELDS","DOC_QUERY","DOC_MUTATION","DOC_SUBSCRIPTION","DOC_QUERIES","DOC_MUTATIONS","DOC_SUBSCRIPTIONS","Type","TopLevelConstant","FieldConstants","entries","build","validationResults","_schema","_resolvers","_apiDocs","FACTORY_CLASS","isFactoryClass","removeClassBrand"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAkEgBA,Y,GAAAA,Y;QAcAC,Y,GAAAA,Y;QAyBAC,Y,GAAAA,Y;QAsBAC,Y,GAAAA,Y;;AA7HhB;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,MAAMC,KAAK,CAAC,GAAGC,IAAJ,KAAa,mBAAQ,GAAGA,IAAX,EAAiB,EAACC,QAAQ,IAAT,EAAeC,OAAO,CAAtB,EAAjB,CAAxB;;AAGA;;;;;;;;;AAZA;;;AAoBO,MAAMC,gCAAY,mBAAW,WAAX,CAAlB;;AAEP;;;;;;;AAOO,MAAMC,sCAAe,mBAAW,kBAAX,CAArB;;AAE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;AAED;;;;;;;;;AASA;AACA,uCAAkC;AAAE,WAAO,KAAKoB,IAAZ;AAAkB;;AAEtD;;;;;;;;AAQA,aAAWyE,IAAX,GAA0B;AAAE,WAAO,mBAAW,wBAAX,CAAP;AAA6C;;AAEzE;;;;;;;;AAQA,aAAWkB,aAAX,GAAmC;AAAE,WAAO,mBAAW,eAAX,CAAP;AAAoC;AAvnB/C,C;AA0nBrB,MAAMC,0CAAiB3F,eAAe2F,cAAtC;;AAEP;AACA","file":"LatticeFactory.js","sourceRoot":"es6","sourcesContent":["// @flow\n\nimport { GQLBase, META_KEY } from './GQLBase'\nimport { GQLEnum } from './GQLEnum'\nimport { GQLInterface } from './GQLInterface'\nimport { GQLScalar } from './GQLScalar'\n// import { GQLUnion } from './GQLUnion'\nimport { SyntaxTree } from './SyntaxTree'\nimport { customDedent } from 'ne-tag-fns'\nimport { typeOf, extendsFrom } from 'ne-types'\nimport { inspect } from 'util'\nimport { resolver, mutator, subscriptor } from './decorators/Resolvers'\nimport { Properties } from './decorators/ModelProperties'\nimport { LatticeLogs as LL } from './utils'\n\nconst _i = (...args) => inspect(...args, {colors: true, depth: 3})\n\n\n/**\n * The CHECKLIST Symbol is used as a storage key in the metadata staging\n * area for each of the GQLBase extended classes. In the LatticeFactory\n * it is used to determine where in the flow of construction the class\n * currently is.\n *\n * @type {Symbol}\n */\nexport const CHECKLIST = Symbol.for('checklist')\n\n/**\n * The CHECK_SCHEMA Symbol is part of the CHECKLIST for a constructed\n * GQLBase extended class. It denotes that the class has had its SCHEMA\n * getter defined.\n *\n * @type {Symbol}\n */\nexport const CHECK_SCHEMA = Symbol.for('checklist-schema')\n\n/**\n * The CHECK_RESOLVERS Symbol is part of the CHECKLIST for a constructed\n * GQLBase extended class. It denotes that the class has had its instance\n * field resolvers as well as its static Query, Mutation and Subscription\n * resolvers injected and defined.\n *\n * @type {Symbol}\n */\nexport const CHECK_RESOLVERS = Symbol.for('checklist-resolvers')\n\n/**\n * The CHECK_API_DOCS Symbol is part of the CHECKLIST for a constructed\n * GQLBase extended class. It denotes that the class has had its api docs\n * defined, processed and setup on the class in a way that it will be\n * picked up in the build lifecycle.\n *\n * @type {Symbol}\n */\nexport const CHECK_API_DOCS = Symbol.for('checklist-api-docs')\n\n/**\n * Peeks into the metadata storage area of a given GQLBase extended\n * class and fetches the factory checklist if one exists.\n *\n * @param {Function} Class a reference to the GQLBase class to peek in\n * @return {Object} an object setup with at least three booleans keyed by\n * the constants CHECK_SCHEMA, CHECK_RESOLVERS, and CHECK_API_DOCS or null\n * if none exists\n */\nexport function getChecklist(Class: Function) {\n return (Class && Class[META_KEY] && Class[META_KEY][CHECKLIST]) || null\n}\n\n/**\n * Obtains the checklist from the supplied GQLBase extended class. If the\n * class has a checklist, its checklist item is set to true or the boolean\n * value specified.\n *\n * @param {Function} Class a reference to the GQLBase class to set\n * @param {Symbol} item one of CHECK_SCHEMA, CHECK_RESOLVERS, or\n * CHECK_API_DOCS\n * @param {Boolean} value the value for the checklist item to set\n */\nexport function setChecklist(\n Class: Function,\n item: Symbol,\n value: boolean = true\n) {\n let checklist = getChecklist(Class)\n\n if (checklist) {\n // $FlowFixMe\n checklist[item] = value\n }\n}\n\n/**\n * This function, when invoked with only a class will return true if the\n * Class has a defined checklist. If one ore more CHECKLIST symbols are\n * passed, the function will only return true if all the supplied symbols\n * are set to truthy values.\n *\n * @param {Function} Class a reference to the GQLBase class to set\n * @param {Array<Symbol>} items any of CHECK_SCHEMA, CHECK_RESOLVERS, or\n * CHECK_API_DOCS\n * @return {Boolean} true if the checklist and/or all items are true and\n * present.\n */\nexport function hasChecklist(Class: Function, ...items: Array<Symbol>) {\n let checklist = getChecklist(Class)\n\n if (checklist && items.length) {\n for (let item of items) {\n if (!checklist[item]) {\n return false\n }\n }\n\n return true\n }\n\n return checklist\n}\n\n/**\n * Injects and creates a new CHECKLIST object on the supplied GQLBase\n * extended class. All items are installed and set to false.\n *\n * @param {Function} Class a reference to the GQLBase class to set\n */\nexport function newChecklist(Class: Function) {\n if (Class) {\n // $FlowFixMe\n Class[META_KEY][CHECKLIST] = {\n [CHECK_SCHEMA]: false,\n [CHECK_RESOLVERS]: false,\n [CHECK_API_DOCS]: false,\n\n get keys() {\n return [\n CHECK_SCHEMA, CHECK_RESOLVERS, CHECK_API_DOCS\n ]\n },\n\n get complete() {\n return this.keys.reduce((p,c,i,a) => {\n if (!p || !this[c]) { return false }\n }, true)\n }\n }\n }\n else {\n throw new Error(customDedent({dropLowest:true})`\n Cannot create new checklist metadata on a non-existent class\n `)\n }\n}\n\nexport class ValidationResults {\n errors: Array<Error>\n\n constructor(errors: Array<Error> = []) {\n this.errors = errors\n }\n\n get valid(): boolean { return this.errors.length === 0 }\n\n // $FlowFixMe\n get [Symbol.toStringTag](): string { return this.constructor.name }\n\n // $FlowFixMe\n static get [Symbol.toStringTag](): string { return this.name }\n}\n\nexport class LatticeFactory {\n\n /**\n * Walks through a supplied template object and collects errors with its\n * format before bubbling up an exception if any part of it fails to\n * pass muster. The exception can be prevented from throwing if hide is set\n * to true\n *\n * @param {Object} template an object to be parsed for construction via the\n * Lattice Factory\n * @param {boolean} hide if true, an invalid template will NOT throw errors\n * @return {ValidationResults} a `ValidationResults` object containing the\n * collected errors and a `valid` that is dynamically calculated.\n */\n static validateTemplate(\n template: Object,\n hide: boolean = false\n ): ValidationResults {\n let results = new ValidationResults()\n let indent = (string: string, count: number = 4, space: string = ' ') => (\n string\n .split('\\n')\n .map(s => s.trim().replace(/(^)/gm, `$1${space.repeat(count)}`))\n .join('\\n')\n )\n\n if (typeof template.name === 'undefined') {\n results.errors.push(new Error(customDedent({dropLowest:true})`\n The \\`template.name\\` field must exist or the creation for the Lattice\n factory class generation to succeed.\n\n Please read the documentation for more information on the format of\n a LatticeFactory template.\n `))\n }\n\n if (!extendsFrom(template.name, String)) {\n results.errors.push(new Error(customDedent({dropLowest:true})`\n The \\`template.name\\` field must be a string.\n\n Please read the documentation for more information on the format of\n a LatticeFactory template.\n `))\n }\n\n if (typeof template.schema === 'undefined') {\n results.errors.push(new Error(customDedent({dropLowest:true})`\n The \\`template.schema\\` field must exist or the creation for the\n Lattice factory class generation to succeed.\n\n Please read the documentation for more information on the format of\n a LatticeFactory template.\n `))\n }\n\n if (!extendsFrom(template.schema, String)) {\n results.errors.push(new Error(customDedent({dropLowest:true})`\n The \\`template.schema\\` field must be a string of GraphQL SDL/IDL\n\n Please read the documentation for more information on the format of\n a LatticeFactory template.\n `))\n }\n\n if (\n !extendsFrom(template.resolvers, Object) // Supports 95% of objects\n || typeof template.resolvers !== 'object' // Supports Object.create(null)\n ) {\n results.errors.push(new Error(customDedent({dropLowest:true})`\\x1b[91;1m\n The \\`template.resolvers\\` field must be an Object containing the\n resolver functions. Query, Mutation and Subscription resolvers will\n take the following signature. Additionally, the keys for these special\n resolvers must be Query, Mutation or Subscription; respectively\n \\x1b[37;22m\n Query: { [resolver]: (requestData, resolverParameters) => {} }\n Mutation: { [resolver]: (requestData, resolverParameters) => {} }\n Subscription: { [resolver]: (requestData, resolverParameters) => {} }\n\n where:\n \\`requestData\\` is an object with { req, res, gql|next } depending\n on the graphql server implementation (FB Reference, Apollo, etc)\n \\`resovlerParameters\\` is an object with keys matching those\n parameters defined in the SCHEMA for the resolver in question.\n \\x1b[91;1m\n Field resolvers should be found under the key name of the type\n or interface in question and must correspond to the following signature\n \\x1b[37;22m\n [Type]: { [resolver]: (resolverParameters) => {} }\n\n where:\n \\`Type\\` is the name of the GQL type defined in the schema\n \\`resovlerParameters\\` is an object with keys matching those\n parameters defined in the SCHEMA for the resolver in question.\n\n * it is worth noting that the field resolvers are not static and\n can access the \\`requestData\\` object via \\`this.requestData\\`\n \\x1b[91;1m\n Please read the documentation for more information on the format of\n a LatticeFactory template.\\x1b[0m\n `))\n }\n\n if (typeof template.docs === 'undefined') {\n results.errors.push(new Error(customDedent({dropLowest:true})`\n The \\`template.docs\\` field must exist for the creation of the\n Lattice factory class generation to succeed.\n\n Please read the documentation for more information on the format of\n a LatticeFactory template.\n `))\n }\n\n if (\n !extendsFrom(template.docs, Object) // Supports 95% of objects\n || typeof template.docs !== 'object' // Supports Object.create(null)\n ) {\n let dr = '\\x1b[31m', br = '\\x1b[91m'\n let b1 = '\\x1b[1m', b0 = '\\x1b[22m'\n let bb = '\\x1b[90m'\n let dg = '\\x1b[37m', bg = '\\x1b[97m'\n let a0 = '\\x1b[0m'\n let gr = '\\x1b[32m', bgr = '\\x1b[92m'\n\n results.errors.push(new Error(customDedent({dropLowest:true})`\\x1b[1;91m\n The \\`template.docs\\` field must be an object containing keys and\n value pairs matching the types, enums, unions and interfaces defined\n in your schema.\n\n The special Symbol object TYPE can be used to reference the docs for\n the named or keyed field describing the documentation to be processed\n Comments for the \\`Query\\`, \\`Mutation\\`, and \\`Subscription\\` [TYPE]\n entries will replace any previous one that comes before it. Typically\n this field is best left undescribed since there will ever only be\n one of each at most.\n\n \\x1b[22;31mExamples should look something like this:\\x1b[22;37m\n import { TYPE, joinLines } from 'graphql-lattice'\n\n export default {\n ${bb}/* other fields */${dg}\n\n ${b1}schema:${b0} joinLines${gr}\\`\n type Person { id: ID name: String }\n type Query { findPerson(id: ID): Person }\n type Mutation { setPersonName(id: ID, name: String): Person }\n \\`${dg},\n\n ${b1}docs:${b0} {\n ${b1}Person:${b0} {\n [TYPE]: ${gr}'A contrived person type'${dg},\n id: ${gr}'A unique identifier for a person'${dg},\n name: ${gr}'A string denoting the name of a person'${dg}\n },\n ${b1}Query:${b0} {\n findPerson: ${gr}'A query taking an ID, returns a Person'${dg},\n },\n ${b1}Mutation:${b0} {\n setPersonName: joinLines${gr}\\`\n A mutation that sets the name of the user identified by an\n ID to the new name value supplied\n \\`${dg}\n }\n }\n }\n \\x1b[22;31m\n Note the usage of \\`Person\\`, \\`Query\\` and \\`Mutation\\` explicitly\n as keys to the supplied \\`docs\\` object.\\x1b[0m\n `))\n }\n\n if (!results.valid) {\n let errorStrings = []\n\n for (let error of results.errors) {\n let { message, stack } = error\n\n stack = stack\n .trim()\n .split('\\n')\n .splice(message.split('\\n').length)\n .map(s => s.trim())\n .join('\\n')\n message = message.replace(/(Error:\\s)/, '$1\\n').trim()\n\n errorStrings.push(\n `\\x1b[31;1m${message}\\x1b[0m\\n` + indent(stack)\n )\n }\n\n let error = new Error(customDedent({dropLowest:true})`\n OOPS!\n\n An error occurred validating your factory template. The object\n in question is as follows:\n\n @template\n\n The individual errors that occurred are:\n \\n@errors`\n .replace(/@template/, indent(_i(template)))\n .replace(/@errors/, errorStrings.join('\\n\\n'))\n )\n\n error.stack = error.message\n error.message = ''\n\n if (!hide) throw error\n }\n\n return results\n }\n\n /**\n * The starting point of a LatticeFactory object -> class creation. The name\n * of the class and baseClass to use are provided and are created from there.\n * At this point, the generated class is still incomplete. It must complete\n * the entire checklist before being deemed valid.\n *\n * @param {string} name name of the class to create\n * @param {Function} baseClass the Lattice class your new class should extend;\n * while this can be anything, it should be GQLBase, GQLInterface, GQLEnum or\n * GQLUnion. This defaults to GQLBase should nothing be supplied\n * @return {Function} actually this returns the generated class\n */\n static generateClass(name: string, baseClass: Function = GQLBase) {\n if (!name) {\n throw new Error('LatticeFactory.generateClass needs a name!!')\n }\n\n // Alright ladies and gentlemen, hold onto your hats; we're entering the\n // meta zone!!! The way the following works is to make sure that our\n // passed in base class `baseClass` is actually in scope as the name of\n // the value it represents. We use the `new Function()` syntax to do that\n // but we do it via eval since we don't know the name of the function\n // at the time we write the code\n //\n // So given a class name of \"Car\" and baseName equalling GQLBase, the Class\n // instance, fn would look something like the results of calling this\n //\n // let fn = new Function(\n // \"GQLBase\",\n // \"class Car extends GQLBase {}; return Car;\"\n // )\n //\n // Which in turn sets fn to something that would be the same as\n //\n // function fn(GQLBase) { class Car extends GQLBase {}; return Car }\n //\n // Which means that when we invoke fn(baseClass), which is fn(GQLBase),\n // we get the results we intend; even if GQLBase is not necessarily in\n // the scope of the function at the time of call. Neat. Scary. OMG Thanks\n // for code comments. You're welcome future me.\n let fn = eval(`(new Function(\n \"${baseClass.name}\",\n \"class ${name} extends ${baseClass.name} {}; return ${name};\"\n ))`);\n\n let Class = fn(baseClass)\n\n this.brandClass(Class)\n newChecklist(Class)\n\n return Class;\n }\n\n /**\n * Injects the SCHEMA property into the newly defined class. The supplied\n * `schema` string becomes what the new class returns when `.SCHEMA` is\n * gotten.\n *\n * @param {Function} Class this will throw an error if the class is not one\n * generated by the LatticeFactory or if the class itself is null or undefined\n * @param {string} schema the string that the new class should return\n * @return {Function} returns the modified Class with the `CHECK_SCHEMA`\n * portion ticked off internally.\n */\n static injectSchema(Class: Function, schema: string) {\n if (!Class || !hasChecklist(Class)) {\n throw new Error(customDedent({dropLowest:true})`\n Either the supplied schema string is invalid\n SCHEMA: \\`\n ${schema}\n \\`\n\n Or your supplied class ${(Class && Class.name) || 'undefined'} is\n non-existent. Please check your code and try the LatticeFactory\n again.\n `)\n }\n\n // $FlowFixMe\n Object.defineProperty(Class, 'SCHEMA', {\n get() { return schema }\n })\n\n setChecklist(Class, CHECK_SCHEMA)\n\n return Class\n }\n\n /**\n * Injects the resolvers into appropriate areas. Resolvers keyed by `Query`,\n * `Mutation`, or `Subscription` will be placed into the appropriate area\n * in `Class[META_KEY]` which acts as a staging area originally designed for\n * use with the @resolver, @mutator and @subscriptor decorators. These will\n * be bound in a typical fashion as is done with the decorators making the\n * first parameter becoming the requestData of the object instance and the\n * second being the object containing the parameters for the resolver as\n * passed in by GraphQL. Subsequent parameters will be supplied as is the\n * fashion of the system you're using; Facebook's reference implementation or\n * Apollo or something else.\n *\n * Resolvers keyed by type name are considered to be field resolvers and\n * have a different signature. They can be properties of the key, in\n * which case they will simply be installed as getters. Or they can be\n * functions; synchronous or asynchronous. Function field resolvers are\n * instance methods and can make use of `this.getModel()` or\n * `this.requestData` internally.\n *\n * @param {Function} Class the class, generated by generateClass() lest an\n * error be thrown, to which to add the resolvers from a template\n * @param {Object} resolverObj an object containing the resolvers as dictated\n * by the new format.\n * @return {Function} returns the modified Class with the `CHECK_RESOLVERS`\n * portion ticked off internally.\n */\n static injectResolvers(Class: Function, resolvers: Object): Function {\n if (!hasChecklist(Class, CHECK_SCHEMA)) {\n throw new Error(customDedent({dropLowest:true})`\n \\`injectResolvers\\` cannot be called on a class without a SCHEMA.\n Please verify your progress in the process and try again.\n `)\n }\n\n let tree = SyntaxTree.from(Class.SCHEMA)\n let outline = tree ? tree.outline : {}\n\n if (Class.name in outline && Class.name in resolvers) {\n let fields = Object.keys(outline[Class.name])\n\n for (let fieldResolver of fields) {\n if (!fieldResolver in resolvers[Class.name]) {\n LL.warn(customDedent({dropLowest: true})`\n ${fieldResolver} not supplied in resolvers for ${Class.name}\n `)\n continue;\n }\n\n let prop = resolvers[Class.name][fieldResolver]\n\n if (prop && typeof prop === 'function') {\n LL.info('Injecting [fn] %s', fieldResolver)\n Object.defineProperty(Class.prototype, fieldResolver, {\n value: prop\n })\n }\n else {\n LL.info('Injecting [prop] %s', fieldResolver)\n Properties(fieldResolver)(Class, ['factory-props'])\n }\n }\n }\n\n for (let [type: string, decorator: Function] of [\n ['Query', resolver],\n ['Mutation', mutator],\n ['Subscription', subscriptor]\n ]) {\n let keys = Object.keys(outline[type] || {})\n\n // $FlowFixMe\n if (!type in outline || !keys.length) { continue; }\n\n for (let fnName of keys) {\n let fn = resolvers[fnName]\n decorator(Class, fnName, {value: fn})\n LL.info('Adding %s resolver [%s]', type, fnName)\n }\n }\n\n setChecklist(Class, CHECK_RESOLVERS)\n\n return Class\n }\n\n static injectDocs(Class: Function, docs: Object): Function {\n if (!hasChecklist(Class, CHECK_SCHEMA, CHECK_RESOLVERS)) {\n throw new Error(customDedent({dropLowest:true})`\n \\`injectDocs\\` cannot be called on a class without a SCHEMA or\n RESOLVERS defined. Please verify your progress in the process and try\n again.\n `)\n }\n\n let copyProp = (\n o: mixed,\n prop: string | Symbol,\n to: mixed,\n as: ?(string | Symbol)\n ): mixed => {\n // $FlowFixMe\n let prototype = o.prototype || Object.getPrototypeOf(o)\n let descriptor = Object.getOwnPropertyDescriptor(prototype, prop)\n\n if (!as) {\n as = prop\n }\n\n if (descriptor) {\n Object.defineProperty(to, as, descriptor)\n }\n else {\n // $FlowFixMe\n to[as] = o[prop]\n }\n }\n\n // Create an object our future `static apiDocs()` method of our factory\n // generated class will return\n let result = {}\n\n // Setup the constants we will need in this conversion\n const { TYPE } = this;\n const {\n DOC_CLASS, DOC_FIELDS, DOC_QUERY, DOC_MUTATION, DOC_SUBSCRIPTION,\n DOC_QUERIES, DOC_MUTATIONS, DOC_SUBSCRIPTIONS\n } = GQLBase\n\n // This part might get a little meta, so I have provided comments. You are\n // welcome future me. I hope it helps. This gnarly block should cover all\n // the descriptions for Query, Mutation, Subscription and the Class we\n // are creating. Other superfluous\n for (let [Type, TopLevelConstant, FieldConstants] of [\n ['Query', DOC_QUERY, DOC_QUERIES],\n ['Mutation', DOC_MUTATION, DOC_MUTATIONS],\n ['Subscription', DOC_SUBSCRIPTION, DOC_SUBSCRIPTIONS],\n [Class.name, DOC_CLASS, DOC_FIELDS]\n ]) {\n // One of 'Query', 'Mutation', or 'Subscription'\n if (docs[Type]) {\n // If a top level description is present (i.e. Query, Mutation or\n // Subscription description)\n if (docs[Type][TYPE]) {\n copyProp(docs[Type], TYPE, result, TopLevelConstant)\n }\n\n // Fetch the properties from the supplied docs object; TYPE Symbols\n // do not show up in a call to entries which is why it is handled above\n // $FlowFixMe\n let entries = Object.entries(docs[Type])\n\n // If we have entries to document, create an object to hold those\n // values; i.e. if we have `{ Query: { getPeople: 'desc' } }`, we need\n // to make sure we have `{ [DOC_QUERIES]: { getPeople: 'desc' } }` in\n // our result. The object holding getPeople in the end there is defined\n // below when we have something to copy.\n if (entries.length) {\n result[FieldConstants] = {}\n }\n\n // For each name value pair defined above, copy its descriptor or base\n // value if a descriptor isn't available\n for (let [prop, value] of entries) {\n copyProp(docs[Type], prop, result[FieldConstants])\n }\n }\n }\n\n Object.defineProperty(Class, 'apiDocs', {\n value: function() { return result }\n })\n\n setChecklist(Class, CHECK_API_DOCS)\n\n return Class\n }\n\n static build(template: Object): Function {\n let validationResults = this.validateTemplate(template)\n let Class = this.generateClass(template.name, template.type || GQLBase)\n\n if (!Class) {\n throw new Error(customDedent({dropLowest: true})`\n LatticeFactory was unable to build your Class from the name and types\n supplied in your template. You provided the following template. Please\n look it over and correct any errors before trying again.\n\n \\x1b[1mTemplate\\x1b[0m\n ${_i(template)}\n `)\n }\n\n this.injectSchema(Class, template.schema)\n this.injectResolvers(Class, template.resolvers || {})\n this.injectDocs(Class, template.docs || {})\n\n // Need to fix how auto-props work; for now create one instance...\n new Class({})\n\n if (!hasChecklist(Class, CHECK_SCHEMA, CHECK_RESOLVERS, CHECK_API_DOCS)) {\n let _schema = hasChecklist(Class, CHECK_SCHEMA) ? '✅' : '❌'\n let _resolvers = hasChecklist(Class, CHECK_RESOLVERS) ? '✅' : '❌'\n let _apiDocs = hasChecklist(Class, CHECK_API_DOCS) ? '✅' : '❌'\n\n throw new Error(customDedent({dropLowest: true})`\n Something went wrong in the process of building the class called\n ${Class && Class.name || template && template.name || 'Unknown!'},\n please check the supplied template for errors.\n\n [ ${_schema} ] Has a SCHEMA defined\n [ ${_resolvers} ] Has defined RESOLVERS matching the SCHEMA\n [ ${_apiDocs} ] Has defined API Docs matching the SCHEMA\n\n \\x1b[1mTemplate\\x1b[0m\n ${_i(template)}\n\n \\x1b[1mClass\\x1b[0m\n ${_i(Class)}\n `)\n }\n\n return Class\n }\n\n /**\n * A static helper method to consistently tag, or brand, classes with a\n * symbol that denotes they were created using the LatticeFactory process.\n * This is done by setting a `Symbol` on the root of the class or in the\n * `[META_KEY]` object for classes extending `GQLBase`.\n *\n * @method ⌾⠀brandClass\n * @memberof LatticeFactory\n * @static\n *\n * @param {Function} Class the class to brand with the `FACTORY_CLASS` symbol\n * @return {Function} returns the Class value passed in\n */\n static brandClass(Class: ?Function): ?Function {\n if (Class) {\n if (extendsFrom(Class, GQLBase)) {\n Class[META_KEY][this.FACTORY_CLASS] = true\n }\n else {\n Class[this.FACTORY_CLASS] = true\n }\n }\n\n return Class\n }\n\n /**\n * A static helper to check and see if the supplied class or function was\n * branded with the `brandClass()` function. This amounts to storing the\n * boolean true under the property `Class[LatticeFactory.FACTORY_CLASS]` or\n * `Class[META_KEY][LatticeFacatory.FACTORY_CLASS]` for `GQLBase` extended\n * classes.\n *\n * @method ⌾⠀isFactoryClass\n * @memberof LatticeFactory\n * @static\n *\n * @param {Function} Class the class to check for `FACTORY_CLASS` branding\n * @return {boolean} true if the brand exists, false otherwise\n */\n static isFactoryClass(Class: Function): boolean {\n if (Class) {\n return (extendsFrom(Class, GQLBase)\n ? !!Class[META_KEY][this.FACTORY_CLASS]\n : !!Class[this.FACTORY_CLASS]\n )\n }\n\n return false\n }\n\n /**\n * A static helper method to consistently remove any previous tag or brand\n * applied with `brandClass`, this is done by removing a previously set\n * `Symbol` on the root of the class or in the `[META_KEY]` object for\n * classes extending `GQLBase`.\n *\n * @method ⌾⠀removeClassBrand\n * @memberof LatticeFactory\n * @static\n *\n * @param {Function} Class the class to brand with the `FACTORY_CLASS` symbol\n * @return {Function} returns the Class value passed in\n */\n static removeClassBrand(Class: Function): Function {\n if (Class) {\n if (extendsFrom(Class, GQLBase)) {\n delete Class[META_KEY][this.FACTORY_CLASS]\n }\n else {\n delete Class[this.FACTORY_CLASS]\n }\n }\n\n return Class\n }\n\n /**\n * A constant that reports that this class is `'[object LatticeFactory]'`\n * rather than `'[object Object]'` when introspected with tools such as\n * `Object.prototype.toString.apply(class)`.\n *\n * @memberof LatticeFactory\n * @type {Symbol}\n * @static\n */\n // $FlowFixMe\n static get [Symbol.toStringTag]() { return this.name }\n\n /**\n * A constant exported as part of LatticeFactory that can be used for\n * defining documentation for the type itself.\n *\n * @memberof LatticeFactory\n * @type {Symbol}\n * @static\n */\n static get TYPE(): Symbol { return Symbol.for('API Docs Type Constant') }\n\n /**\n * A constant exported as part of LatticeFactory that can be used for\n * identifying classes that were generated with LatticeFactory.\n *\n * @memberof LatticeFactory\n * @type {Symbol}\n * @static\n */\n static get FACTORY_CLASS(): Symbol { return Symbol.for('Factory Class') }\n}\n\nexport const isFactoryClass = LatticeFactory.isFactoryClass\n\n// TESTING REPL\n/**\nvar { LatticeFactory, getChecklist, hasChecklist, CHECKLIST, CHECK_SCHEMA, CHECK_RESOLVERS } = require('./dist/LatticeFactory'); var { GQLBase, META_KEY, joinLines, SyntaxTree, typeOf } = require('./dist/lattice'); var gql = joinLines, LF = LatticeFactory, TYPE = LF.TYPE;\nvar PersonDef = { name: 'Person', schema: gql` enum StatType { PHYSICAL, MENTAL } type Person { name: String stats(type:StatType): Stat } type Query { findPerson(id: ID): Person } `, resolvers: { Query: { findPerson({req, res, next}, {id}) { console.log('find person') } }, Person: { stats({type}) { let { req, res, next} = this.requestData } } }, docs: { StatType: { [TYPE]: `A type of statistic associated with people`, PHYSICAL: `Physical attributes`, MENTAL: `Mental attributes` }, Person: { [TYPE]: `Represents a person`, personId: `Unique id of the person in question`, name: `The name of the person`, stats: `Allows you to query the stats of a person based on type` }, Query: { [TYPE]: 'Top level query desc.', findPerson: `Searches the system for the specified user` } } };\nvar Person = LF.build(PersonDef), p = new Person({name: 'Brielle'})\nPerson.getProp('stats',true,{requestData:{req:1,res:2,next:3}})\nvar Broke = LF.build({name: 'Broke', schema: gql`type Broke {name: String}`, resolvers:{}, docs:{}})\nvar t = LF.validateTemplate({name: '', type: GQLBase, resolvers: {}, docs: {}, schema: ''});\n*/\n"]}
\No newline at end of file