@trackunit/react-graphql-tools 0.0.69 → 0.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.71](https://github.com/Trackunit/manager/compare/react-graphql-tools/0.0.70...react-graphql-tools/0.0.71) (2024-02-14)
6
+
7
+ ## [0.0.70](https://github.com/Trackunit/manager/compare/react-graphql-tools/0.0.69...react-graphql-tools/0.0.70) (2024-02-07)
8
+
5
9
  ## [0.0.69](https://github.com/Trackunit/manager/compare/react-graphql-tools/0.0.68...react-graphql-tools/0.0.69) (2024-02-05)
6
10
 
7
11
  ## [0.0.68](https://github.com/Trackunit/manager/compare/react-graphql-tools/0.0.67...react-graphql-tools/0.0.68) (2024-02-05)
package/generators.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "generators": {
3
- "add-grapqhl": {
4
- "factory": "./src/generators/add-grapqhl/generator",
5
- "schema": "./src/generators/add-grapqhl/schema.json",
6
- "description": "add-grapqhl generator"
3
+ "add-graphql": {
4
+ "factory": "./src/generators/add-graphql/generator",
5
+ "schema": "./src/generators/add-graphql/schema.json",
6
+ "description": "add-graphql generator"
7
7
  }
8
8
  }
9
- }
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-graphql-tools",
3
- "version": "0.0.69",
3
+ "version": "0.0.71",
4
4
  "main": "./src/index.js",
5
5
  "executors": "./executors.json",
6
6
  "generators": "./generators.json",
@@ -14,11 +14,18 @@ const scrubFile_1 = require("./scrubFile");
14
14
  * @returns {Promise<{ success: number; }>} success when finished
15
15
  */
16
16
  const CreateGraphqlHooks = (_unused, context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
17
+ var _a;
17
18
  const nxRoot = `${context.root}`;
18
19
  if (!context.projectsConfigurations) {
19
20
  throw new Error("context projectsConfigurations is required");
20
21
  }
21
- const libRoot = context.projectsConfigurations.projects[context.projectName].root;
22
+ if (!context.projectName) {
23
+ throw new Error("context projectName is required");
24
+ }
25
+ const libRoot = (_a = context.projectsConfigurations.projects[context.projectName]) === null || _a === void 0 ? void 0 : _a.root;
26
+ if (!libRoot) {
27
+ throw new Error("Missing library root");
28
+ }
22
29
  const fullLibRoot = (0, path_1.join)(nxRoot, libRoot);
23
30
  const tsConfigPath = (0, fs_1.existsSync)((0, path_1.join)(fullLibRoot, "tsconfig.lib.json"))
24
31
  ? (0, path_1.join)(fullLibRoot, "tsconfig.lib.json")
@@ -39,7 +46,12 @@ const config: CodegenConfig = {
39
46
  export default config;
40
47
  `);
41
48
  }
42
- const result = yield (0, generateHooks_1.generateHooks)({ nxRoot: context.root, codeGenFilePath, isVerbose: context.isVerbose, tsConfigPath });
49
+ const result = yield (0, generateHooks_1.generateHooks)({
50
+ nxRoot: context.root,
51
+ codeGenFilePath,
52
+ isVerbose: context.isVerbose,
53
+ tsConfigPath,
54
+ });
43
55
  if (process.env.SKIP_SCRUB !== "true") {
44
56
  const pathToGenerateFile = (0, path_1.join)(fullLibRoot, "src", "generated", "graphql-api", "graphql.ts");
45
57
  if ((0, fs_1.existsSync)(pathToGenerateFile)) {
@@ -1 +1 @@
1
- {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/executor.ts"],"names":[],"mappings":";;;;AACA,2BAAgC;AAChC,+BAA4B;AAC5B,mDAAgD;AAChD,2CAAwC;AAExC;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,CAAO,OAAgB,EAAE,OAAwB,EAAE,EAAE;IACrF,MAAM,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IACjC,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE;QACnC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;KAC/D;IACD,M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AAkB,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;SAChE;KACF;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC,CAAA,CAAC;AA1CW,QAAA,kBAAkB,sBA0C7B;AAEF,kBAAe,0BAAkB,CAAC","sourcesContent":["import { ExecutorContext } from \"@nx/devkit\";\nimport { existsSync } from \"fs\";\nimport { join } from \"path\";\nimport { generateHooks } from \"./generateHooks\";\nimport { scrubFile } from \"./scrubFile\";\n\n/**\n * This executor generates react hooks for all graphql files.\n *\n * @param _unused unused props from nx\n * @param context The execution context for this executor\n * @returns {Promise<{ success: number; }>} success when finished\n */\nexport const CreateGraphqlHooks = async (_unused: unknown, context: ExecutorContext) => {\n const nxRoot = `${context.root}`;\n if (!context.projectsConfigurations) {\n throw new Error(\"context projectsConfigurations is required\");\n }\n const libRoot = context.projectsConfigurations.projects[context.projectName!].root;\n\n const fullLibRoot = join(nxRoot, libRoot);\n const tsConfigPath = existsSync(join(fullLibRoot, \"tsconfig.lib.json\"))\n ? join(fullLibRoot, \"tsconfig.lib.json\")\n : join(fullLibRoot, \"tsconfig.app.json\");\n\n if (!tsConfigPath) {\n throw new Error(\"context projectsConfigurations is required\");\n }\n\n const codeGenFilePath = join(fullLibRoot, \"codegen.ts\");\n if (!existsSync(codeGenFilePath)) {\n throw new Error(`codegen.ts file not found in ${fullLibRoot} please add this file and run again to generate hooks. The content should be\nimport { type CodegenConfig } from \"@graphql-codegen/cli\";\nimport { getGraphqlCodegenConfig } from \"@trackunit/iris-app-build-utilities\";\n\nconst config: CodegenConfig = {\n ...getGraphqlCodegenConfig(__dirname),\n // You can override codegen default config here\n};\nexport default config;\n`);\n }\n\n const result = await generateHooks({ nxRoot: context.root, codeGenFilePath, isVerbose: context.isVerbose, tsConfigPath });\n if (process.env.SKIP_SCRUB !== \"true\") {\n const pathToGenerateFile = join(fullLibRoot, \"src\", \"generated\", \"graphql-api\", \"graphql.ts\");\n if (existsSync(pathToGenerateFile)) {\n if (context.isVerbose) {\n // eslint-disable-next-line no-console\n console.log(\"Scrubbing file: \", pathToGenerateFile);\n }\n await scrubFile(pathToGenerateFile, nxRoot, context.isVerbose);\n }\n }\n return { success: result };\n};\n\nexport default CreateGraphqlHooks;\n"]}
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/executor.ts"],"names":[],"mappings":";;;;AACA,2BAAgC;AAChC,+BAA4B;AAC5B,mDAAgD;AAChD,2CAAwC;AAExC;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,CAAO,OAAgB,EAAE,OAAwB,EAAE,EAAE;;IACrF,MAAM,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IACjC,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE;QACnC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;KAC/D;IACD,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;KACpD;IAED,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,0CAAE,IAAI,CAAC;IAEnF,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;KACzC;IAED,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,IAAA,eAAU,EAAC,IAAA,WAAI,EAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;QACrE,CAAC,CAAC,IAAA,WAAI,EAAC,WAAW,EAAE,mBAAmB,CAAC;QACxC,CAAC,CAAC,IAAA,WAAI,EAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;IAE3C,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;KAC/D;IAED,MAAM,eAAe,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IACxD,IAAI,CAAC,IAAA,eAAU,EAAC,eAAe,CAAC,EAAE;QAChC,MAAM,IAAI,KAAK,CAAC,gCAAgC,WAAW;;;;;;;;;CAS9D,CAAC,CAAC;KACA;IAED,MAAM,MAAM,GAAG,MAAM,IAAA,6BAAa,EAAC;QACjC,MAAM,EAAE,OAAO,CAAC,IAAI;QACpB,eAAe;QACf,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,YAAY;KACb,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,MAAM,EAAE;QACrC,MAAM,kBAAkB,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;QAC9F,IAAI,IAAA,eAAU,EAAC,kBAAkB,CAAC,EAAE;YAClC,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,sCAAsC;gBACtC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;aACrD;YACD,MAAM,IAAA,qBAAS,EAAC,kBAAkB,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;SAChE;KACF;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC,CAAA,CAAC;AAvDW,QAAA,kBAAkB,sBAuD7B;AAEF,kBAAe,0BAAkB,CAAC","sourcesContent":["import { ExecutorContext } from \"@nx/devkit\";\nimport { existsSync } from \"fs\";\nimport { join } from \"path\";\nimport { generateHooks } from \"./generateHooks\";\nimport { scrubFile } from \"./scrubFile\";\n\n/**\n * This executor generates react hooks for all graphql files.\n *\n * @param _unused unused props from nx\n * @param context The execution context for this executor\n * @returns {Promise<{ success: number; }>} success when finished\n */\nexport const CreateGraphqlHooks = async (_unused: unknown, context: ExecutorContext) => {\n const nxRoot = `${context.root}`;\n if (!context.projectsConfigurations) {\n throw new Error(\"context projectsConfigurations is required\");\n }\n if (!context.projectName) {\n throw new Error(\"context projectName is required\");\n }\n\n const libRoot = context.projectsConfigurations.projects[context.projectName]?.root;\n\n if (!libRoot) {\n throw new Error(\"Missing library root\");\n }\n\n const fullLibRoot = join(nxRoot, libRoot);\n const tsConfigPath = existsSync(join(fullLibRoot, \"tsconfig.lib.json\"))\n ? join(fullLibRoot, \"tsconfig.lib.json\")\n : join(fullLibRoot, \"tsconfig.app.json\");\n\n if (!tsConfigPath) {\n throw new Error(\"context projectsConfigurations is required\");\n }\n\n const codeGenFilePath = join(fullLibRoot, \"codegen.ts\");\n if (!existsSync(codeGenFilePath)) {\n throw new Error(`codegen.ts file not found in ${fullLibRoot} please add this file and run again to generate hooks. The content should be\nimport { type CodegenConfig } from \"@graphql-codegen/cli\";\nimport { getGraphqlCodegenConfig } from \"@trackunit/iris-app-build-utilities\";\n\nconst config: CodegenConfig = {\n ...getGraphqlCodegenConfig(__dirname),\n // You can override codegen default config here\n};\nexport default config;\n`);\n }\n\n const result = await generateHooks({\n nxRoot: context.root,\n codeGenFilePath,\n isVerbose: context.isVerbose,\n tsConfigPath,\n });\n if (process.env.SKIP_SCRUB !== \"true\") {\n const pathToGenerateFile = join(fullLibRoot, \"src\", \"generated\", \"graphql-api\", \"graphql.ts\");\n if (existsSync(pathToGenerateFile)) {\n if (context.isVerbose) {\n // eslint-disable-next-line no-console\n console.log(\"Scrubbing file: \", pathToGenerateFile);\n }\n await scrubFile(pathToGenerateFile, nxRoot, context.isVerbose);\n }\n }\n return { success: result };\n};\n\nexport default CreateGraphqlHooks;\n"]}
@@ -131,6 +131,7 @@ const preserveTypes = (node, preservedTypes, sourceFile, isVerbose) => {
131
131
  * Convert an enum to a const object and string literal type
132
132
  */
133
133
  const convertEnumToConstObject = (enumDeclaration) => {
134
+ var _a;
134
135
  const enumName = enumDeclaration.getName();
135
136
  const members = enumDeclaration.getMembers();
136
137
  const properties = members.map(member => {
@@ -138,7 +139,7 @@ const convertEnumToConstObject = (enumDeclaration) => {
138
139
  const value = member.getValue();
139
140
  return `${name}: '${value}'`;
140
141
  });
141
- const lowerCaseFirstLetter = enumName[0].toLowerCase() + enumName.slice(1);
142
+ const lowerCaseFirstLetter = ((_a = enumName[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) + enumName.slice(1);
142
143
  const constObjectText = `export const ${lowerCaseFirstLetter} = {\n ${properties.join(",\n ")},\n} as const;\nexport type ${enumName} = typeof ${lowerCaseFirstLetter}[keyof typeof ${lowerCaseFirstLetter}];`;
143
144
  return constObjectText;
144
145
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/utils.ts"],"names":[],"mappings":";;;AAAA,uCAAwG;AAExG;;GAEG;AACI,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE;IACtC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AAChE,CAAC,CAAC;AAFW,QAAA,OAAO,WAElB;AACF;;GAEG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,EAAE;IAC/C,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEF;;GAEG;AACI,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE;IACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;AACtE,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAEF;;GAEG;AACI,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,EAAE;IAClD,OAAO,IAAI,CAAC,QAAQ,CAAC,mBAAmB,C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AAiB,oBAAoB,IAAI,CAAC;IAEnH,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAhBW,QAAA,wBAAwB,4BAgBnC;AAEF;;GAEG;AACI,MAAM,gBAAgB,GAAG,CAAC,WAAmB,EAAE,EAAE;IACtD,MAAM,OAAO,GAAG,IAAI,kBAAO,CAAC;QAC1B,eAAe,EAAE;YACf,cAAc,EAAE,IAAI;YACpB,kBAAkB,EAAE,IAAI;SACzB;KACF,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC,CAAC;AATW,QAAA,gBAAgB,oBAS3B","sourcesContent":["import { EnumDeclaration, Node, Project, SourceFile, SyntaxKind, TypeAliasDeclaration } from \"ts-morph\";\n\n/**\n * Check if the name is a *Query\n */\nexport const isQuery = (name: string) => {\n return name.endsWith(\"Query\") && name.length > \"Query\".length;\n};\n/**\n * Check if the name is a *QueryVariables\n */\nexport const isQueryVariables = (name: string) => {\n return name.endsWith(\"QueryVariables\");\n};\n\n/**\n * Check if the name is a Mutation\n */\nexport const isMutation = (name: string) => {\n return name.endsWith(\"Mutation\") && name.length > \"Mutation\".length;\n};\n\n/**\n * Check if the name is a *QueryVariables\n */\nexport const isMutationVariables = (name: string) => {\n return name.endsWith(\"MutationVariables\");\n};\n\n/**\n * Check if the name is a *Fragment and not *_Fragment\n */\nexport const isFragment = (name: string) => {\n return name.endsWith(\"Fragment\") && !name.endsWith(\"_Fragment\");\n};\n\n/**\n * Debug where you are in the tree\n */\nconst getFullPathUpOfNode = (node: Node) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let currentNode: any | undefined = node;\n const paths = [];\n\n while (currentNode) {\n // You can customize what details to include for each node (e.g., kind, text)\n let name = currentNode.getName ? currentNode.getName() : currentNode.getKindName();\n if (node.getKind() === SyntaxKind.TypeLiteral) {\n const typeLiteral = node.asKindOrThrow(SyntaxKind.TypeLiteral);\n name = typeLiteral.getText();\n }\n\n paths.unshift(`${name}`);\n currentNode = currentNode.getParent();\n }\n\n return paths.join(\">>\");\n};\n\n/**\n * Get the types that should be preserved\n */\nexport const getPreservedTypes = (\n sourceFile: SourceFile,\n isVerbose?: boolean\n): {\n preservedTypes: string[];\n queryAndMutations: Node[];\n} => {\n const typeAliases = sourceFile.getTypeAliases();\n const queryAndMutations: Node[] = [];\n\n const preservedTypes: string[] = [];\n\n const variablesListToProcess: TypeAliasDeclaration[] = [];\n const queryMutationListToProcess: TypeAliasDeclaration[] = [];\n\n typeAliases.forEach(typeAlias => {\n const name = typeAlias.getName();\n if (isQueryVariables(name) || isMutationVariables(name) || isFragment(name)) {\n variablesListToProcess.push(typeAlias);\n queryAndMutations.push(typeAlias);\n } else if (isQuery(name) || isMutation(name)) {\n queryMutationListToProcess.push(typeAlias);\n queryAndMutations.push(typeAlias);\n }\n });\n\n sourceFile.getVariableStatements().forEach(variableStatement => {\n const variable = variableStatement\n .getFirstChildByKind(SyntaxKind.VariableDeclarationList)\n ?.getFirstChildByKind(SyntaxKind.VariableDeclaration);\n if (variable?.getName().endsWith(\"Document\")) {\n queryAndMutations.push(variableStatement);\n } else if (variable?.getName().endsWith(\"FragmentDoc\")) {\n queryAndMutations.push(variableStatement);\n }\n });\n\n // RUN VARAIABLES FIRST since it will force full props if nessasary\n\n // VARIABLES are input so force include all props\n variablesListToProcess.forEach(typeAlias => {\n preserveTypes(typeAlias, preservedTypes, sourceFile, isVerbose);\n });\n\n // QUERY and MUTATION are dynamic so dont force props\n queryMutationListToProcess.forEach(typeAlias => {\n preserveTypes(typeAlias, preservedTypes, sourceFile, isVerbose);\n });\n\n return { preservedTypes, queryAndMutations };\n};\n\nconst preserveTypes = (node: Node, preservedTypes: string[], sourceFile: SourceFile, isVerbose?: boolean): Node[] => {\n const typeReferences: Node[] = [];\n if (!node.getText().startsWith(\"export type Query\") && !node.getText().startsWith(\"export type Mutation\")) {\n node.forEachDescendant(descendant => {\n if (descendant.getKind() === SyntaxKind.TypeReference) {\n if (\n !descendant.getText().startsWith(\"Scalars\") &&\n !descendant.getText().startsWith(\"Maybe<\") &&\n !descendant.getText().startsWith(\"InputMaybe<\") &&\n !descendant.getText().startsWith(\"Array<\") &&\n !descendant.getText().startsWith(\"Exact<\") &&\n !descendant.getText().includes(\"__typename\")\n ) {\n if (isVerbose) {\n // eslint-disable-next-line no-console\n console.log(\"ADDING\", getFullPathUpOfNode(descendant), \":\", descendant.getText(), descendant.getKindName());\n }\n if (!preservedTypes.includes(descendant.getText())) {\n const foundTypeAlias = sourceFile.getTypeAlias(descendant.getText());\n preservedTypes.push(descendant.getText());\n if (foundTypeAlias) {\n preserveTypes(foundTypeAlias, preservedTypes, sourceFile, isVerbose);\n }\n }\n }\n }\n });\n }\n\n return typeReferences;\n};\n\n/**\n * Convert an enum to a const object and string literal type\n */\nexport const convertEnumToConstObject = (enumDeclaration: EnumDeclaration) => {\n const enumName = enumDeclaration.getName();\n const members = enumDeclaration.getMembers();\n\n const properties = members.map(member => {\n const name = member.getName();\n const value = member.getValue();\n return `${name}: '${value}'`;\n });\n\n const lowerCaseFirstLetter = enumName[0].toLowerCase() + enumName.slice(1);\n const constObjectText = `export const ${lowerCaseFirstLetter} = {\\n ${properties.join(\n \",\\n \"\n )},\\n} as const;\\nexport type ${enumName} = typeof ${lowerCaseFirstLetter}[keyof typeof ${lowerCaseFirstLetter}];`;\n\n return constObjectText;\n};\n\n/**\n * Create a source file from a string\n */\nexport const createSourceFile = (fileContent: string) => {\n const project = new Project({\n compilerOptions: {\n noUnusedLocals: true,\n noUnusedParameters: true,\n },\n });\n\n return project.createSourceFile(\"tmp.ts\", fileContent);\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/utils.ts"],"names":[],"mappings":";;;AAAA,uCAAwG;AAExG;;GAEG;AACI,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE;IACtC,OAAO,IAAI,CAAC,QAA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E;;IAC3E,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAG,eAAe,CAAC,UAAU,EAAE,CAAC;IAE7C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QACtC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAChC,OAAO,GAAG,IAAI,MAAM,KAAK,GAAG,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,MAAM,oBAAoB,GAAG,CAAA,MAAA,QAAQ,CAAC,CAAC,CAAC,0CAAE,WAAW,EAAE,IAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5E,MAAM,eAAe,GAAG,gBAAgB,oBAAoB,WAAW,UAAU,CAAC,IAAI,CACpF,OAAO,CACR,+BAA+B,QAAQ,aAAa,oBAAoB,iBAAiB,oBAAoB,IAAI,CAAC;IAEnH,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAhBW,QAAA,wBAAwB,4BAgBnC;AAEF;;GAEG;AACI,MAAM,gBAAgB,GAAG,CAAC,WAAmB,EAAE,EAAE;IACtD,MAAM,OAAO,GAAG,IAAI,kBAAO,CAAC;QAC1B,eAAe,EAAE;YACf,cAAc,EAAE,IAAI;YACpB,kBAAkB,EAAE,IAAI;SACzB;KACF,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC,CAAC;AATW,QAAA,gBAAgB,oBAS3B","sourcesContent":["import { EnumDeclaration, Node, Project, SourceFile, SyntaxKind, TypeAliasDeclaration } from \"ts-morph\";\n\n/**\n * Check if the name is a *Query\n */\nexport const isQuery = (name: string) => {\n return name.endsWith(\"Query\") && name.length > \"Query\".length;\n};\n/**\n * Check if the name is a *QueryVariables\n */\nexport const isQueryVariables = (name: string) => {\n return name.endsWith(\"QueryVariables\");\n};\n\n/**\n * Check if the name is a Mutation\n */\nexport const isMutation = (name: string) => {\n return name.endsWith(\"Mutation\") && name.length > \"Mutation\".length;\n};\n\n/**\n * Check if the name is a *QueryVariables\n */\nexport const isMutationVariables = (name: string) => {\n return name.endsWith(\"MutationVariables\");\n};\n\n/**\n * Check if the name is a *Fragment and not *_Fragment\n */\nexport const isFragment = (name: string) => {\n return name.endsWith(\"Fragment\") && !name.endsWith(\"_Fragment\");\n};\n\n/**\n * Debug where you are in the tree\n */\nconst getFullPathUpOfNode = (node: Node) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let currentNode: any | undefined = node;\n const paths = [];\n\n while (currentNode) {\n // You can customize what details to include for each node (e.g., kind, text)\n let name = currentNode.getName ? currentNode.getName() : currentNode.getKindName();\n if (node.getKind() === SyntaxKind.TypeLiteral) {\n const typeLiteral = node.asKindOrThrow(SyntaxKind.TypeLiteral);\n name = typeLiteral.getText();\n }\n\n paths.unshift(`${name}`);\n currentNode = currentNode.getParent();\n }\n\n return paths.join(\">>\");\n};\n\n/**\n * Get the types that should be preserved\n */\nexport const getPreservedTypes = (\n sourceFile: SourceFile,\n isVerbose?: boolean\n): {\n preservedTypes: string[];\n queryAndMutations: Node[];\n} => {\n const typeAliases = sourceFile.getTypeAliases();\n const queryAndMutations: Node[] = [];\n\n const preservedTypes: string[] = [];\n\n const variablesListToProcess: TypeAliasDeclaration[] = [];\n const queryMutationListToProcess: TypeAliasDeclaration[] = [];\n\n typeAliases.forEach(typeAlias => {\n const name = typeAlias.getName();\n if (isQueryVariables(name) || isMutationVariables(name) || isFragment(name)) {\n variablesListToProcess.push(typeAlias);\n queryAndMutations.push(typeAlias);\n } else if (isQuery(name) || isMutation(name)) {\n queryMutationListToProcess.push(typeAlias);\n queryAndMutations.push(typeAlias);\n }\n });\n\n sourceFile.getVariableStatements().forEach(variableStatement => {\n const variable = variableStatement\n .getFirstChildByKind(SyntaxKind.VariableDeclarationList)\n ?.getFirstChildByKind(SyntaxKind.VariableDeclaration);\n if (variable?.getName().endsWith(\"Document\")) {\n queryAndMutations.push(variableStatement);\n } else if (variable?.getName().endsWith(\"FragmentDoc\")) {\n queryAndMutations.push(variableStatement);\n }\n });\n\n // RUN VARAIABLES FIRST since it will force full props if nessasary\n\n // VARIABLES are input so force include all props\n variablesListToProcess.forEach(typeAlias => {\n preserveTypes(typeAlias, preservedTypes, sourceFile, isVerbose);\n });\n\n // QUERY and MUTATION are dynamic so dont force props\n queryMutationListToProcess.forEach(typeAlias => {\n preserveTypes(typeAlias, preservedTypes, sourceFile, isVerbose);\n });\n\n return { preservedTypes, queryAndMutations };\n};\n\nconst preserveTypes = (node: Node, preservedTypes: string[], sourceFile: SourceFile, isVerbose?: boolean): Node[] => {\n const typeReferences: Node[] = [];\n if (!node.getText().startsWith(\"export type Query\") && !node.getText().startsWith(\"export type Mutation\")) {\n node.forEachDescendant(descendant => {\n if (descendant.getKind() === SyntaxKind.TypeReference) {\n if (\n !descendant.getText().startsWith(\"Scalars\") &&\n !descendant.getText().startsWith(\"Maybe<\") &&\n !descendant.getText().startsWith(\"InputMaybe<\") &&\n !descendant.getText().startsWith(\"Array<\") &&\n !descendant.getText().startsWith(\"Exact<\") &&\n !descendant.getText().includes(\"__typename\")\n ) {\n if (isVerbose) {\n // eslint-disable-next-line no-console\n console.log(\"ADDING\", getFullPathUpOfNode(descendant), \":\", descendant.getText(), descendant.getKindName());\n }\n if (!preservedTypes.includes(descendant.getText())) {\n const foundTypeAlias = sourceFile.getTypeAlias(descendant.getText());\n preservedTypes.push(descendant.getText());\n if (foundTypeAlias) {\n preserveTypes(foundTypeAlias, preservedTypes, sourceFile, isVerbose);\n }\n }\n }\n }\n });\n }\n\n return typeReferences;\n};\n\n/**\n * Convert an enum to a const object and string literal type\n */\nexport const convertEnumToConstObject = (enumDeclaration: EnumDeclaration) => {\n const enumName = enumDeclaration.getName();\n const members = enumDeclaration.getMembers();\n\n const properties = members.map(member => {\n const name = member.getName();\n const value = member.getValue();\n return `${name}: '${value}'`;\n });\n\n const lowerCaseFirstLetter = enumName[0]?.toLowerCase() + enumName.slice(1);\n const constObjectText = `export const ${lowerCaseFirstLetter} = {\\n ${properties.join(\n \",\\n \"\n )},\\n} as const;\\nexport type ${enumName} = typeof ${lowerCaseFirstLetter}[keyof typeof ${lowerCaseFirstLetter}];`;\n\n return constObjectText;\n};\n\n/**\n * Create a source file from a string\n */\nexport const createSourceFile = (fileContent: string) => {\n const project = new Project({\n compilerOptions: {\n noUnusedLocals: true,\n noUnusedParameters: true,\n },\n });\n\n return project.createSourceFile(\"tmp.ts\", fileContent);\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addGrapqhlGenerator = void 0;
3
+ exports.addGraphqlGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  /* eslint-disable no-console */
6
6
  const devkit_1 = require("@nx/devkit");
@@ -8,7 +8,7 @@ const path = tslib_1.__importStar(require("path"));
8
8
  /**
9
9
  * Setting up Graphql tools for Iris App development
10
10
  */
11
- function addGrapqhlGenerator(tree, options) {
11
+ function addGraphqlGenerator(tree, options) {
12
12
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
13
  const workspaceRoot = "";
14
14
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
@@ -34,6 +34,6 @@ function addGrapqhlGenerator(tree, options) {
34
34
  yield (0, devkit_1.formatFiles)(tree);
35
35
  });
36
36
  }
37
- exports.addGrapqhlGenerator = addGrapqhlGenerator;
38
- exports.default = addGrapqhlGenerator;
37
+ exports.addGraphqlGenerator = addGraphqlGenerator;
38
+ exports.default = addGraphqlGenerator;
39
39
  //# sourceMappingURL=generator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/generators/add-grapqhl/generator.ts"],"names":[],"mappings":";;;;AAAA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,mBAAmB,CAAC","sourcesContent":["/* eslint-disable no-console */\nimport { formatFiles, generateFiles, joinPathFragments, readProjectConfiguration, Tree, updateJson } from \"@nx/devkit\";\nimport * as path from \"path\";\nimport { AddGrapqhlGeneratorSchema } from \"./schema\";\n\n/**\n * Setting up Graphql tools for Iris App development\n */\nexport async function addGrapqhlGenerator(tree: Tree, options: AddGrapqhlGeneratorSchema) {\n const workspaceRoot = \"\";\n const projectConfig = readProjectConfiguration(tree, options.project);\n const libraryRoot = projectConfig.root;\n if (!tree.exists(\"graphql.config.json\") && !tree.exists(\"graphql.config.ts\")) {\n generateFiles(tree, path.join(__dirname, \"files\", \"root\"), workspaceRoot, options);\n } else {\n console.log(\n `\"graphql.config.json\" already exist in your workspace root. \\nPlease ensure that your \"graphql.config.json\" contains \"schema\": \"https://iris.trackunit.com/api/graphql/\".`\n );\n }\n\n if (!tree.exists(`${libraryRoot}/codegen.ts`)) {\n generateFiles(tree, path.join(__dirname, \"files\", \"subDirectory\"), libraryRoot, options);\n } else {\n console.log(`codegen.ts already exists in ${libraryRoot}`);\n }\n\n updateJson(tree, joinPathFragments(libraryRoot, \"project.json\"), projectJSON => {\n projectJSON.targets = {\n ...projectJSON.targets,\n \"graphql-hooks\": {\n executor: \"@trackunit/react-graphql-tools:createHooks\",\n },\n };\n return projectJSON;\n });\n await formatFiles(tree);\n}\n\nexport default addGrapqhlGenerator;\n"]}
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/generators/add-graphql/generator.ts"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,uCAAuH;AACvH,mDAA6B;AAG7B;;GAEG;AACH,SAAsB,mBAAmB,CAAC,IAAU,EAAE,OAAkC;;QACtF,MAAM,aAAa,GAAG,EAAE,CAAC;QACzB,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACtE,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE;YAC5E,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;SACpF;aAAM;YACL,OAAO,CAAC,GAAG,CACT,2KAA2K,CAC5K,CAAC;SACH;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,aAAa,CAAC,EAAE;YAC7C,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;SAC1F;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,gCAAgC,WAAW,EAAE,CAAC,CAAC;SAC5D;QAED,IAAA,mBAAU,EAAC,IAAI,EAAE,IAAA,0BAAiB,EAAC,WAAW,EAAE,cAAc,CAAC,EAAE,WAAW,CAAC,EAAE;YAC7E,WAAW,CAAC,OAAO,mCACd,WAAW,CAAC,OAAO,KACtB,eAAe,EAAE;oBACf,QAAQ,EAAE,4CAA4C;iBACvD,GACF,CAAC;YACF,OAAO,WAAW,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AA5BD,kDA4BC;AAED,kBAAe,mBAAmB,CAAC","sourcesContent":["/* eslint-disable no-console */\nimport { formatFiles, generateFiles, joinPathFragments, readProjectConfiguration, Tree, updateJson } from \"@nx/devkit\";\nimport * as path from \"path\";\nimport { AddGraphqlGeneratorSchema } from \"./schema\";\n\n/**\n * Setting up Graphql tools for Iris App development\n */\nexport async function addGraphqlGenerator(tree: Tree, options: AddGraphqlGeneratorSchema) {\n const workspaceRoot = \"\";\n const projectConfig = readProjectConfiguration(tree, options.project);\n const libraryRoot = projectConfig.root;\n if (!tree.exists(\"graphql.config.json\") && !tree.exists(\"graphql.config.ts\")) {\n generateFiles(tree, path.join(__dirname, \"files\", \"root\"), workspaceRoot, options);\n } else {\n console.log(\n `\"graphql.config.json\" already exist in your workspace root. \\nPlease ensure that your \"graphql.config.json\" contains \"schema\": \"https://iris.trackunit.com/api/graphql/\".`\n );\n }\n\n if (!tree.exists(`${libraryRoot}/codegen.ts`)) {\n generateFiles(tree, path.join(__dirname, \"files\", \"subDirectory\"), libraryRoot, options);\n } else {\n console.log(`codegen.ts already exists in ${libraryRoot}`);\n }\n\n updateJson(tree, joinPathFragments(libraryRoot, \"project.json\"), projectJSON => {\n projectJSON.targets = {\n ...projectJSON.targets,\n \"graphql-hooks\": {\n executor: \"@trackunit/react-graphql-tools:createHooks\",\n },\n };\n return projectJSON;\n });\n await formatFiles(tree);\n}\n\nexport default addGraphqlGenerator;\n"]}
@@ -0,0 +1,3 @@
1
+ export interface AddGraphqlGeneratorSchema {
2
+ project: string;
3
+ }
@@ -1,3 +0,0 @@
1
- export interface AddGrapqhlGeneratorSchema {
2
- project: string;
3
- }