@remkoj/optimizely-graph-functions 6.0.0-pre8 → 6.0.0-rc.1

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.
Files changed (73) hide show
  1. package/LICENSE +12 -12
  2. package/README.md +60 -14
  3. package/dist/_transform/cleanFragments.d.ts +10 -0
  4. package/dist/_transform/cleanFragments.js +39 -0
  5. package/dist/_transform/cleanFragments.js.map +1 -0
  6. package/dist/_transform/cleanSpreads.d.ts +10 -0
  7. package/dist/_transform/cleanSpreads.js +36 -0
  8. package/dist/_transform/cleanSpreads.js.map +1 -0
  9. package/dist/_transform/handleDependDirective.d.ts +11 -0
  10. package/dist/_transform/handleDependDirective.js +128 -0
  11. package/dist/_transform/handleDependDirective.js.map +1 -0
  12. package/dist/_transform/injectComponentDocuments.d.ts +16 -0
  13. package/dist/_transform/injectComponentDocuments.js +177 -0
  14. package/dist/_transform/injectComponentDocuments.js.map +1 -0
  15. package/dist/_transform/injectPageQueries.d.ts +5 -0
  16. package/dist/_transform/injectPageQueries.js +114 -0
  17. package/dist/_transform/injectPageQueries.js.map +1 -0
  18. package/dist/_transform/injectSectionQueries.d.ts +5 -0
  19. package/dist/_transform/injectSectionQueries.js +128 -0
  20. package/dist/_transform/injectSectionQueries.js.map +1 -0
  21. package/dist/_transform/normalizeFragmentNames.d.ts +12 -0
  22. package/dist/_transform/normalizeFragmentNames.js +77 -0
  23. package/dist/_transform/normalizeFragmentNames.js.map +1 -0
  24. package/dist/_transform/normalizeQueryNames.d.ts +12 -0
  25. package/dist/_transform/normalizeQueryNames.js +83 -0
  26. package/dist/_transform/normalizeQueryNames.js.map +1 -0
  27. package/dist/_transform/options.d.ts +3 -0
  28. package/dist/_transform/options.js +21 -0
  29. package/dist/_transform/options.js.map +1 -0
  30. package/dist/_transform/performInjections.d.ts +24 -0
  31. package/dist/_transform/performInjections.js +192 -0
  32. package/dist/_transform/performInjections.js.map +1 -0
  33. package/dist/_transform/tools.d.ts +34 -0
  34. package/dist/_transform/tools.js +103 -0
  35. package/dist/_transform/tools.js.map +1 -0
  36. package/dist/cms/index.d.ts +11 -0
  37. package/dist/cms/index.js +121 -0
  38. package/dist/cms/index.js.map +1 -0
  39. package/dist/contenttype-loader.d.ts +11 -0
  40. package/dist/contenttype-loader.js +72 -0
  41. package/dist/contenttype-loader.js.map +1 -0
  42. package/dist/documents/fragments.cms13.js +147 -39
  43. package/dist/documents/fragments.cms13.js.map +1 -1
  44. package/dist/documents/queries.cms13.js +9 -3
  45. package/dist/documents/queries.cms13.js.map +1 -1
  46. package/dist/embedded-loader.js +31 -16
  47. package/dist/embedded-loader.js.map +1 -1
  48. package/dist/generator/collision-tracker.d.ts +22 -0
  49. package/dist/generator/collision-tracker.js +103 -0
  50. package/dist/generator/collision-tracker.js.map +1 -0
  51. package/dist/generator/generator.d.ts +77 -0
  52. package/dist/generator/generator.js +272 -0
  53. package/dist/generator/generator.js.map +1 -0
  54. package/dist/generator/index.d.ts +3 -0
  55. package/dist/generator/index.js +42 -0
  56. package/dist/generator/index.js.map +1 -0
  57. package/dist/generator/virtual-location.d.ts +41 -0
  58. package/dist/generator/virtual-location.js +139 -0
  59. package/dist/generator/virtual-location.js.map +1 -0
  60. package/dist/index.d.ts +2 -5
  61. package/dist/index.js +4 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/preset.d.ts +2 -4
  64. package/dist/preset.js +112 -73
  65. package/dist/preset.js.map +1 -1
  66. package/dist/tools.d.ts +4 -0
  67. package/dist/tools.js +20 -0
  68. package/dist/tools.js.map +1 -0
  69. package/dist/transform.d.ts +12 -1
  70. package/dist/transform.js +48 -58
  71. package/dist/transform.js.map +1 -1
  72. package/dist/types.d.ts +23 -0
  73. package/package.json +27 -21
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getPageDocuments = getPageDocuments;
37
+ exports.injectPageQueries = injectPageQueries;
38
+ const graphql_1 = require("graphql");
39
+ const OptiCMS = __importStar(require("../cms"));
40
+ const tools_1 = require("./tools");
41
+ const utils_1 = require("../utils");
42
+ const generator_1 = require("../generator");
43
+ async function getPageDocuments(loader = '@remkoj/optimizely-graph-functions/contenttype-loader') {
44
+ const pageTypes = OptiCMS.getContentTypesList(undefined, (ct) => {
45
+ if (ct.source == "graph")
46
+ return false;
47
+ return ["_page", "_experience"].includes((ct.baseType || "").toLowerCase());
48
+ });
49
+ const documents = [];
50
+ for (const pageType of await pageTypes) {
51
+ const vLoc = generator_1.VirtualLocation.build(pageType, { type: 'query' });
52
+ if (vLoc) {
53
+ const def = {};
54
+ def[vLoc] = { loader };
55
+ documents.push(def);
56
+ }
57
+ // Get properties
58
+ const propertyComponentTypeNames = generator_1.DocumentGenerator.getReferencedPropertyComponents(pageType);
59
+ const propertyComponentTypes = (await Promise.all(propertyComponentTypeNames.map(componentTypeName => OptiCMS.getContentType(componentTypeName)))).filter(utils_1.isNotNullOrUndefined);
60
+ for (const propertyComponentType of propertyComponentTypes) {
61
+ const propVLoc = generator_1.VirtualLocation.build(propertyComponentType, { type: 'fragment', forProperty: true });
62
+ if (propVLoc && !documents.some(x => typeof x === 'object' && x[propVLoc])) {
63
+ // Inject virtual location
64
+ const def = {};
65
+ def[propVLoc] = { loader };
66
+ documents.push(def);
67
+ }
68
+ }
69
+ }
70
+ return documents;
71
+ }
72
+ async function injectPageQueries(files, options) {
73
+ if (options.presetConfig.verbose)
74
+ console.log(`✨ [Optimizely] Generating page queries that have not been defined by the implementation`);
75
+ const existingQueries = (0, tools_1.getAllQueries)(files);
76
+ const existingTypes = (0, tools_1.getAllTypeNames)(options.schema);
77
+ const allTypes = OptiCMS.getContentTypes(undefined);
78
+ const pageLevelTypes = OptiCMS.getContentTypesList(undefined, (ct) => {
79
+ if (ct.source == "graph")
80
+ return false;
81
+ return ["_page", "_experience"].includes((ct.baseType || "").toLowerCase());
82
+ });
83
+ const queryGen = new generator_1.DocumentGenerator(await allTypes);
84
+ const newFiles = [];
85
+ for (const pageContentType of await pageLevelTypes) {
86
+ const graphDataType = queryGen.getGraphType(pageContentType);
87
+ const queryName = queryGen.getDefaultQueryName(pageContentType);
88
+ // Check if the type exists in the Schema, if not skip it
89
+ if (!existingTypes.includes(graphDataType)) {
90
+ if (options.presetConfig.verbose)
91
+ console.log(` - Skipping query generation for ${pageContentType.key}, the schema does not contain the type ${graphDataType}`);
92
+ continue;
93
+ }
94
+ // Check if the query has already been defined, if so skip it
95
+ if (existingQueries.has(queryName)) {
96
+ if (options.presetConfig.verbose)
97
+ console.log(` - Skipping query generation for ${pageContentType.key}, the project already includes a definition for ${queryName}`);
98
+ continue;
99
+ }
100
+ const rawSDL = queryGen.buildGetQuery(pageContentType, queryName);
101
+ const vLoc = generator_1.VirtualLocation.build(pageContentType, { type: 'query' });
102
+ if (options.presetConfig.verbose)
103
+ console.log(` - Generated query for ${pageContentType.key} at ${vLoc}`);
104
+ newFiles.push({
105
+ rawSDL,
106
+ document: (0, graphql_1.parse)(rawSDL),
107
+ location: vLoc,
108
+ hash: vLoc
109
+ });
110
+ }
111
+ return [...files, ...newFiles];
112
+ }
113
+ exports.default = injectPageQueries;
114
+ //# sourceMappingURL=injectPageQueries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injectPageQueries.js","sourceRoot":"","sources":["../../src/_transform/injectPageQueries.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,4CA+BC;AAED,8CAgDC;AAzFD,qCAA+B;AAE/B,gDAAiC;AAEjC,mCAAwD;AACxD,oCAA+C;AAC/C,4CAAiE;AAE1D,KAAK,UAAU,gBAAgB,CAAC,SAAiB,uDAAuD;IAE7G,MAAM,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE;QAC9D,IAAI,EAAE,CAAC,MAAM,IAAI,OAAO;YACtB,OAAO,KAAK,CAAC;QACf,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAiC,EAAE,CAAC;IACnD,KAAK,MAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,2BAAe,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;QAC/D,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,GAAG,GAA+B,EAAE,CAAA;YAC1C,GAAG,CAAC,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AAC,eAAe,EAAE,SAAS,CAAC,CAAA;QACjE,MAAM,IAAI,GAAG,2BAAe,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;QACtE,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;YAC9B,OAAO,CAAC,GAAG,CAAC,6BAA6B,eAAe,CAAC,GAAG,OAAO,IAAI,EAAE,CAAC,CAAA;QAE5E,QAAQ,CAAC,IAAI,CAAC;YACZ,MAAM;YACN,QAAQ,EAAE,IAAA,eAAK,EAAC,MAAM,CAAC;YACvB,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,IAAI;SACX,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,CAAC,GAAG,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAA;AAChC,CAAC;AAED,kBAAe,iBAAiB,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { Types } from '@graphql-codegen/plugin-helpers';
2
+ import type { PresetOptions } from '../types';
3
+ export declare function getSectionDocuments(loader?: string): Promise<Types.CustomDocumentLoader[]>;
4
+ export declare function injectSectionQueries(files: Types.DocumentFile[], options: Types.PresetFnArgs<PresetOptions>): Promise<Types.DocumentFile[]>;
5
+ export default injectSectionQueries;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getSectionDocuments = getSectionDocuments;
37
+ exports.injectSectionQueries = injectSectionQueries;
38
+ const graphql_1 = require("graphql");
39
+ const OptiCMS = __importStar(require("../cms"));
40
+ const tools_1 = require("./tools");
41
+ const generator_1 = require("../generator");
42
+ async function getSectionDocuments(loader = '@remkoj/optimizely-graph-functions/contenttype-loader') {
43
+ const sectionTypes = OptiCMS.getContentTypesList(undefined, (ct) => {
44
+ if (ct.source == "graph")
45
+ return false;
46
+ return ["_section"].includes((ct.baseType || "").toLowerCase());
47
+ });
48
+ const documents = [];
49
+ for (const sectionType of await sectionTypes) {
50
+ const vLoc = generator_1.VirtualLocation.build(sectionType, { type: 'query' });
51
+ if (vLoc) {
52
+ const def = {};
53
+ def[vLoc] = { loader };
54
+ documents.push(def);
55
+ }
56
+ const fragmentVLoc = generator_1.VirtualLocation.build(sectionType, { type: 'fragment' });
57
+ if (fragmentVLoc) {
58
+ const def = {};
59
+ def[fragmentVLoc] = { loader };
60
+ documents.push(def);
61
+ }
62
+ }
63
+ return documents;
64
+ }
65
+ async function injectSectionQueries(files, options) {
66
+ if (options.presetConfig.verbose)
67
+ console.log(`✨ [Optimizely] Generating section queries that have not been defined by the implementation`);
68
+ const existingQueries = (0, tools_1.getAllQueries)(files);
69
+ const existingFragments = (0, tools_1.getAllFragments)(files);
70
+ const existingTypes = (0, tools_1.getAllTypeNames)(options.schema);
71
+ const allTypes = OptiCMS.getContentTypes(undefined);
72
+ const sectionTypes = OptiCMS.getContentTypesList(undefined, (ct) => {
73
+ if (ct.source == "graph")
74
+ return false;
75
+ return ["_section"].includes((ct.baseType || "").toLowerCase());
76
+ });
77
+ const newFiles = [];
78
+ const queryGen = new generator_1.DocumentGenerator(await allTypes);
79
+ for (const sectionContentType of await sectionTypes) {
80
+ const graphDataType = queryGen.getGraphType(sectionContentType);
81
+ const queryName = queryGen.getDefaultQueryName(sectionContentType);
82
+ const fragmentName = queryGen.getDefaultFragmentName(sectionContentType);
83
+ // Check if the type exists in the Schema, if not skip it
84
+ if (!existingTypes.includes(graphDataType)) {
85
+ if (options.presetConfig.verbose)
86
+ console.log(` - Skipping query generation for ${sectionContentType.key}, the schema does not contain the type ${graphDataType}`);
87
+ continue;
88
+ }
89
+ // Check if the query has already been defined, if so skip it
90
+ if (existingQueries.has(queryName)) {
91
+ if (options.presetConfig.verbose)
92
+ console.log(` - Skipping query generation for ${sectionContentType.key}, the project already includes a definition for ${queryName}`);
93
+ // Add Query
94
+ }
95
+ else {
96
+ const rawSDL = queryGen.buildGetQuery(sectionContentType, queryName);
97
+ const vLoc = generator_1.VirtualLocation.build(sectionContentType, { type: 'query' });
98
+ if (options.presetConfig.verbose)
99
+ console.log(` - Generated query for ${sectionContentType.key} at ${vLoc}`);
100
+ newFiles.push({
101
+ rawSDL,
102
+ document: (0, graphql_1.parse)(rawSDL),
103
+ location: vLoc,
104
+ hash: vLoc
105
+ });
106
+ }
107
+ if (existingFragments.has(fragmentName)) {
108
+ if (options.presetConfig.verbose)
109
+ console.log(` - Skipping fragment generation for ${sectionContentType.key}, the project already includes a definition for ${fragmentName}`);
110
+ // Add Fragment
111
+ }
112
+ else {
113
+ const rawSDL = queryGen.buildFragment(sectionContentType);
114
+ const vLoc = generator_1.VirtualLocation.build(sectionContentType, { type: 'fragment' });
115
+ if (options.presetConfig.verbose)
116
+ console.log(` - Generated fragment for ${sectionContentType.key} at ${vLoc}`);
117
+ newFiles.push({
118
+ rawSDL,
119
+ document: (0, graphql_1.parse)(rawSDL),
120
+ location: vLoc,
121
+ hash: vLoc
122
+ });
123
+ }
124
+ }
125
+ return [...files, ...newFiles];
126
+ }
127
+ exports.default = injectSectionQueries;
128
+ //# sourceMappingURL=injectSectionQueries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injectSectionQueries.js","sourceRoot":"","sources":["../../src/_transform/injectSectionQueries.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,kDAwBC;AAED,oDAsEC;AAvGD,qCAA+B;AAE/B,gDAAiC;AAEjC,mCAAyE;AACzE,4CAAiE;AAE1D,KAAK,UAAU,mBAAmB,CAAC,SAAiB,uDAAuD;IAEhH,MAAM,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE;QACjE,IAAI,EAAE,CAAC,MAAM,IAAI,OAAO;YACtB,OAAO,KAAK,CAAC;QACf,OAAO,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAiC,EAAE,CAAC;IACnD,KAAK,MAAM,WAAW,IAAI,MAAM,YAAY,EAAE,CAAC;QAC7C,MAAM,IAAI,GAAG,2BAAe,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;QAClE,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,GAAG,GAA+B,EAAE,CAAA;YAC1C,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,CAAA;YACtB,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;QACD,MAAM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E,CAAC;YACxC,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;gBAC9B,OAAO,CAAC,GAAG,CAAC,0CAA0C,kBAAkB,CAAC,GAAG,mDAAmD,YAAY,EAAE,CAAC,CAAA;YAElJ,eAAe;QACf,CAAC;aAAK,CAAC;YACL,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAA;YACzD,MAAM,IAAI,GAAG,2BAAe,CAAC,KAAK,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;YAC5E,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;gBAC9B,OAAO,CAAC,GAAG,CAAC,gCAAgC,kBAAkB,CAAC,GAAG,OAAO,IAAI,EAAE,CAAC,CAAA;YAElF,QAAQ,CAAC,IAAI,CAAC;gBACZ,MAAM;gBACN,QAAQ,EAAE,IAAA,eAAK,EAAC,MAAM,CAAC;gBACvB,QAAQ,EAAE,IAAI;gBACd,IAAI,EAAE,IAAI;aACX,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAA;AAChC,CAAC;AAED,kBAAe,oBAAoB,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { Types } from '@graphql-codegen/plugin-helpers';
2
+ import type { PresetOptions } from '../types';
3
+ /**
4
+ * Allows the SDK to define fragments starting with an "_", for which:
5
+ * - If a fragment with the same name, without an "_" exists, will be removed
6
+ * - If such a fragment does not exist, it will be renamed to without a "_"
7
+ *
8
+ * @param files
9
+ * @param options
10
+ * @returns
11
+ */
12
+ export declare function normalizeFragmentNames(files: Types.DocumentFile[], options: Types.PresetFnArgs<PresetOptions>): Types.DocumentFile[];
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeFragmentNames = normalizeFragmentNames;
4
+ const graphql_1 = require("graphql");
5
+ /**
6
+ * Allows the SDK to define fragments starting with an "_", for which:
7
+ * - If a fragment with the same name, without an "_" exists, will be removed
8
+ * - If such a fragment does not exist, it will be renamed to without a "_"
9
+ *
10
+ * @param files
11
+ * @param options
12
+ * @returns
13
+ */
14
+ function normalizeFragmentNames(files, options) {
15
+ if (options.presetConfig.verbose)
16
+ console.log(`✨ [Optimizely] Making all internal fragments available, which have not be overridden by the project`);
17
+ // Filter & rename fragments
18
+ const allFragmentNames = files.reduce((list, file) => {
19
+ if (file.document)
20
+ (0, graphql_1.visit)(file.document, {
21
+ FragmentDefinition: {
22
+ enter(node) {
23
+ list.push(node.name.value);
24
+ }
25
+ }
26
+ });
27
+ return list;
28
+ }, []);
29
+ const operations = allFragmentNames.reduce((prev, fragmentName) => {
30
+ if (fragmentName.startsWith('_')) {
31
+ if (allFragmentNames.includes(fragmentName.substring(1))) {
32
+ prev.toRemove.push(fragmentName);
33
+ }
34
+ else {
35
+ prev.toRename.push(fragmentName);
36
+ }
37
+ }
38
+ return prev;
39
+ }, { toRename: [], toRemove: [] });
40
+ if (options.presetConfig.verbose)
41
+ console.log(`✨ [Optimizely] Identified ${operations.toRemove.length} fragments to remove (${operations.toRemove.join(", ")}) and ${operations.toRename.length} fragments to rename`);
42
+ const filteredFiles = files.map(file => {
43
+ let isModified = false;
44
+ const newDocument = file.document ? (0, graphql_1.visit)(file.document, {
45
+ FragmentDefinition: {
46
+ enter(node) {
47
+ const nodeName = node.name.value;
48
+ if (operations.toRemove.includes(nodeName)) {
49
+ if (options.presetConfig.verbose)
50
+ console.log(` ⚠ Removing default fragment ${node.name.value.substring(1)} from the documents as it has been overridden.`);
51
+ isModified = true;
52
+ return null;
53
+ }
54
+ if (operations.toRename.includes(nodeName)) {
55
+ if (options.presetConfig.verbose)
56
+ console.log(` ⚠ Making default fragment ${node.name.value.substring(1)} available as it has not been overridden.`);
57
+ isModified = true;
58
+ return {
59
+ ...node,
60
+ name: {
61
+ ...node.name,
62
+ value: nodeName.substring(1)
63
+ }
64
+ };
65
+ }
66
+ }
67
+ }
68
+ }) : undefined;
69
+ return isModified ? {
70
+ ...file,
71
+ rawSDL: newDocument ? (0, graphql_1.print)(newDocument) : undefined,
72
+ document: newDocument
73
+ } : file;
74
+ });
75
+ return filteredFiles;
76
+ }
77
+ //# sourceMappingURL=normalizeFragmentNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeFragmentNames.js","sourceRoot":"","sources":["../../src/_transform/normalizeFragmentNames.ts"],"names":[],"mappings":";;AAcA,wDA4DC;AAxED,qCAAsC;AAGtC;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CAAC,KAA2B,EAAE,OAA0C;IAC5G,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;QAC9B,OAAO,CAAC,GAAG,CAAC,qGAAqG,CAAC,CAAA;IACpH,4BAA4B;IAC5B,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAW,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QAC7D,IAAI,IAAI,CAAC,QAAQ;YAAE,IAAA,eAAK,EAAC,IAAI,CAAC,QAAQ,EAAE;gBACtC,kBAAkB,EAAE;oBAClB,KAAK,CAAC,IAAI;wBACR,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;oBAC5B,CAAC;iBACF;aACF,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,MAAM,UAAU,GAAG,gBAAgB,CAAC,MAAM,CAA6C,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE;QAC5G,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YAClC,CAAC;iBAAM,CAAC;gB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C,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,2CAA2C,CAAC,CAAA;wBACrH,UAAU,GAAG,IAAI,CAAA;wBACjB,OAAO;4BACL,GAAG,IAAI;4BACP,IAAI,EAAE;gCACJ,GAAG,IAAI,CAAC,IAAI;gCACZ,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;6BAC7B;yBACwB,CAAA;oBAC7B,CAAC;gBACH,CAAC;aACF;SACF,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACd,OAAO,UAAU,CAAC,CAAC,CAAC;YAClB,GAAG,IAAI;YACP,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,IAAA,eAAK,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;YACpD,QAAQ,EAAE,WAAW;SACA,CAAC,CAAC,CAAC,IAAI,CAAA;IAChC,CAAC,CAAC,CAAA;IACF,OAAO,aAAa,CAAA;AACtB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Types } from '@graphql-codegen/plugin-helpers';
2
+ import type { PresetOptions } from '../types';
3
+ /**
4
+ * Allows the SDK to define fragments starting with an "_", for which:
5
+ * - If a fragment with the same name, without an "_" exists, will be removed
6
+ * - If such a fragment does not exist, it will be renamed to without a "_"
7
+ *
8
+ * @param files
9
+ * @param options
10
+ * @returns
11
+ */
12
+ export declare function normalizeQueryNames(files: Types.DocumentFile[], options: Types.PresetFnArgs<PresetOptions>): Types.DocumentFile[];
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeQueryNames = normalizeQueryNames;
4
+ const graphql_1 = require("graphql");
5
+ /**
6
+ * Allows the SDK to define fragments starting with an "_", for which:
7
+ * - If a fragment with the same name, without an "_" exists, will be removed
8
+ * - If such a fragment does not exist, it will be renamed to without a "_"
9
+ *
10
+ * @param files
11
+ * @param options
12
+ * @returns
13
+ */
14
+ function normalizeQueryNames(files, options) {
15
+ if (options.presetConfig.verbose)
16
+ console.log(`✨ [Optimizely] Making all internal queries available, which have not be overridden by the project`);
17
+ // List all queries
18
+ const allQueryNames = files.reduce((list, file) => {
19
+ if (file.document)
20
+ (0, graphql_1.visit)(file.document, {
21
+ OperationDefinition: {
22
+ enter(node) {
23
+ if (node.operation == graphql_1.OperationTypeNode.QUERY && typeof (node.name?.value) == 'string' && node.name.value.length > 0)
24
+ list.push(node.name.value);
25
+ }
26
+ }
27
+ });
28
+ return list;
29
+ }, []);
30
+ // Determine the operations for the internal queries
31
+ const operations = allQueryNames.reduce((prev, queryName) => {
32
+ if (queryName.startsWith('_')) {
33
+ if (allQueryNames.includes(queryName.substring(1))) {
34
+ prev.toRemove.push(queryName);
35
+ }
36
+ else {
37
+ prev.toRename.push(queryName);
38
+ }
39
+ }
40
+ return prev;
41
+ }, { toRename: [], toRemove: [] });
42
+ // Update documents
43
+ const filteredFiles = files.map(file => {
44
+ let isModified = false;
45
+ const newDocument = file.document ? (0, graphql_1.visit)(file.document, {
46
+ OperationDefinition: {
47
+ enter(node) {
48
+ // Only process queries with a name and of operation type Query
49
+ if (node.name && node.operation === graphql_1.OperationTypeNode.QUERY) {
50
+ const nodeName = node.name.value;
51
+ // Remove query
52
+ if (operations.toRemove.includes(nodeName)) {
53
+ if (options.presetConfig.verbose)
54
+ console.log(` ⚠ Removing default query ${node.name.value.substring(1)} from the documents as it has been overridden.`);
55
+ isModified = true;
56
+ return null;
57
+ }
58
+ // Rename query
59
+ if (operations.toRename.includes(nodeName)) {
60
+ if (options.presetConfig.verbose)
61
+ console.log(` ⚠ Making default fragment ${node.name.value.substring(1)} available as it has not been overridden.`);
62
+ isModified = true;
63
+ return {
64
+ ...node,
65
+ name: {
66
+ ...node.name,
67
+ value: nodeName.substring(1)
68
+ }
69
+ };
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }) : undefined;
75
+ return isModified ? {
76
+ ...file,
77
+ rawSDL: newDocument ? (0, graphql_1.print)(newDocument) : undefined,
78
+ document: newDocument
79
+ } : file;
80
+ });
81
+ return filteredFiles;
82
+ }
83
+ //# sourceMappingURL=normalizeQueryNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeQueryNames.js","sourceRoot":"","sources":["../../src/_transform/normalizeQueryNames.ts"],"names":[],"mappings":";;AAcA,kDAuEC;AAnFD,qCAAyD;AAGzD;;;;;;;;GAQG;AACH,SAAgB,mBAAmB,CAAC,KAA2B,EAAE,OAA0C;IACzG,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;QAC9B,OAAO,CAAC,GAAG,CAAC,mGAAmG,CAAC,CAAA;IAElH,mBAAmB;IACnB,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAW,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QAC1D,IAAI,IAAI,CAAC,QAAQ;YAAE,IAAA,eAAK,EAAC,IAAI,CAAC,QAAQ,EAAE;gBACtC,mBAAmB,EAAE;oBACnB,KAAK,CAAC,IAAI;wBACR,IAAI,IAAI,CAAC,SAAS,IAAI,2BAAiB,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;4BAClH,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;oBAC9B,CAAC;iBACF;aACF,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,oDAAoD;IACpD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAA6C,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;QACtG,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,IAAI,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnD,IAAI,CAAC,QAAQ,C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SAAS,CAAC,CAAC,CAAC,2CAA2C,CAAC,CAAA;4BACrH,UAAU,GAAG,IAAI,CAAA;4BACjB,OAAO;gCACL,GAAG,IAAI;gCACP,IAAI,EAAE;oCACJ,GAAG,IAAI,CAAC,IAAI;oCACZ,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;iCAC7B;6BACyB,CAAA;wBAC9B,CAAC;oBACH,CAAC;gBACH,CAAC;aACF;SACF,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACd,OAAO,UAAU,CAAC,CAAC,CAAC;YAClB,GAAG,IAAI;YACP,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,IAAA,eAAK,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;YACpD,QAAQ,EAAE,WAAW;SACA,CAAC,CAAC,CAAC,IAAI,CAAA;IAChC,CAAC,CAAC,CAAA;IACF,OAAO,aAAa,CAAA;AACtB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { TransformOptions } from "../types";
2
+ export declare const defaultOptions: Readonly<Required<TransformOptions>>;
3
+ export declare function pickTransformOptions(options: Record<string, any>): Readonly<Required<TransformOptions>>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultOptions = void 0;
4
+ exports.pickTransformOptions = pickTransformOptions;
5
+ exports.defaultOptions = {
6
+ injections: [],
7
+ verbose: false,
8
+ recursion: true,
9
+ cleanup: true,
10
+ cmsClient: {}
11
+ };
12
+ function pickTransformOptions(options) {
13
+ return {
14
+ cleanup: options.cleanup ?? true,
15
+ injections: options.injections ?? [],
16
+ verbose: options.verbose ?? false,
17
+ recursion: options.recursion ?? true,
18
+ cmsClient: options.cmsClient ?? undefined
19
+ };
20
+ }
21
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/_transform/options.ts"],"names":[],"mappings":";;;AAUA,oDAQC;AAhBY,QAAA,cAAc,GAAyC;IAClE,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,EAAE;CACd,CAAA;AAED,SAAgB,oBAAoB,CAAC,OAA4B;IAC/D,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK;QACjC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI;QACpC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,SAAS;KAC1C,CAAA;AACH,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { Types } from '@graphql-codegen/plugin-helpers';
2
+ import { type FragmentDefinitionNode } from 'graphql';
3
+ import type { PresetOptions, Injection, TransformOptions } from '../types';
4
+ /**
5
+ * Check all fragments within the project and ensure that there's at least a fragment for every
6
+ * content type defined in Optimizely CMS. This assumes that when overriding the fragments the
7
+ * project will ensure that the injections are correct.
8
+ *
9
+ * @param files
10
+ * @param options
11
+ * @returns
12
+ */
13
+ export declare function performInjections(files: Types.DocumentFile[], options: Types.PresetFnArgs<PresetOptions>): Promise<Types.DocumentFile[]>;
14
+ export default performInjections;
15
+ type TargetedFragementInfo = {
16
+ name: string;
17
+ contentType: string;
18
+ definition: FragmentDefinitionNode;
19
+ location?: string;
20
+ };
21
+ type TargetedFragments = Map<string, Array<TargetedFragementInfo>>;
22
+ export declare function getInjectionsByFile(file: Types.DocumentFile, injections: Injection[]): Array<Injection>;
23
+ export declare function getInjectionsByFragmentName(fragmentName: string, injections: Injection[]): Array<Injection>;
24
+ export declare function getComponentFragments(files: Types.DocumentFile[], { injections, verbose }: Readonly<Required<TransformOptions>>): Promise<TargetedFragments>;