@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
package/LICENSE CHANGED
@@ -1,13 +1,13 @@
1
- Copyright 2024 Remko Jantzen
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
1
+ Copyright 2024 Remko Jantzen
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
13
  limitations under the License.
package/README.md CHANGED
@@ -1,4 +1,8 @@
1
- # Optimizely GraphQL Codegen Plugin
1
+ # Optimizely GraphQL Codegen Plugin <!-- omit in toc -->
2
+
3
+ > [!WARNING]
4
+ > There'll be an update of Optimizely SaaS CMS that is incompatible with all SDK versions prior to 5.1.6. If you don't upgrade, you will see empty pages (main website) and "Component not found" messages (preview).
5
+
2
6
  GraphQL Codegen plugin and preset which generate both the GraphQL type definitions and a few convenienece methods for useage with [Optimizely Graph Client](../optimizely-graph-client/README.md).
3
7
 
4
8
  [Release notes](https://github.com/remkoj/optimizely-dxp-clients/releases)
@@ -6,7 +10,22 @@ GraphQL Codegen plugin and preset which generate both the GraphQL type definitio
6
10
  > [!WARNING]
7
11
  > The GraphQL Codegen preset requires a patch to enable it to work with recursive queries. Make sure to run this command after every update to ensure you're using the latest patches: `yarn opti-graph patches:apply`. Adjust when used in a mono-repo to patch the correct package.json, for example: `yarn workspace frontend opti-graph patches:apply -p ../../`
8
12
 
9
- ## Install package
13
+ ## Contents <!-- omit in toc -->
14
+ - [1. Install package](#1-install-package)
15
+ - [2. Configure package](#2-configure-package)
16
+ - [3. GraphQL Document Processing](#3-graphql-document-processing)
17
+ - [3.1. Allow overwriting of built-in fragments \& queries](#31-allow-overwriting-of-built-in-fragments--queries)
18
+ - [3.2. Injection of fragments \& queries for ContentTypes](#32-injection-of-fragments--queries-for-contenttypes)
19
+ - [3.3. Auto inject fragments](#33-auto-inject-fragments)
20
+ - [3.4. Remove fragments and spreads that target non-existing types](#34-remove-fragments-and-spreads-that-target-non-existing-types)
21
+ - [3.5. Dedicated Queries \& Fragments](#35-dedicated-queries--fragments)
22
+ - [Compiler field directive `@depend`](#compiler-field-directive-depend)
23
+ - [4. Usage](#4-usage)
24
+ - [4.1. Option 1: Direct methods](#41-option-1-direct-methods)
25
+ - [4.2. Option 2: Enhanced Client](#42-option-2-enhanced-client)
26
+
27
+
28
+ ## 1. Install package
10
29
  To install using Yarn, use the following command:
11
30
 
12
31
  ```bash
@@ -19,7 +38,7 @@ yarn add --dev @remkoj/optimizely-graph-cli
19
38
  yarn opti-graph patches:apply
20
39
  ```
21
40
 
22
- ## Configure package
41
+ ## 2. Configure package
23
42
  Create a codegen.ts within your application root folder (e.g. apps/frontend/codegen.ts within the example site). Within the codegen.ts create the following configuration:
24
43
 
25
44
  ```typescript
@@ -104,11 +123,46 @@ The presetConfig of the `OptimizelyGraphPreset` is an extension of the configura
104
123
  | functions | The list of GraphQL Functions that should be made available in the `functions.ts` file. When specified, this overrides the default list.<br/>*Default value: `['getContentType','getContentByPath','getContentById']`*
105
124
  | verbose | Set to `true` to enable debugging output of the preset, loader, plugin and transform |
106
125
 
126
+ ## 3. GraphQL Document Processing
127
+ ### 3.1. Allow overwriting of built-in fragments & queries
128
+ All fragment and query names injected / generated by this package start with an underscore (for example: `_getContentById`). During the document pre-processing, all these fragments and queries will be processed with this logic:
129
+ - If there's no query or fragment with the name without the leading underscore, it will be renamed. (i.e. `_getContentById` becomes `getContentById`)
130
+ - If a query or fragment with the name without leading underscore does exist, the built-in version with underscore will be removed from the document set.
131
+
132
+ This allows a project to overwrite built-in fragments and queries, while still ensuring type-safety.
133
+
134
+ ### 3.2. Injection of fragments & queries for ContentTypes
135
+ For each content type the appropriate fragments and queries will be auto generated an injected into the document set.
136
+
137
+ ### 3.3. Auto inject fragments
138
+ Dynamically build queries & fragments based upon the `injections` configuration, and the default injections from the auto-generated fragments & queries.
139
+
140
+ This allows you to tell wich group of fragments you want at a given location and then during GraphQL compilation generate the full queries based upon the current content schema in Optimizely CMS and your project configuration.
141
+
142
+ ### 3.4. Remove fragments and spreads that target non-existing types
143
+ Depending on the features you have enabled in your CMS, not all types might actually be present in Optimizely Graph. This logic removes these fragments and spreads from the documents.
144
+
145
+ This approach assumes you're using TypeScript, as missing, but required types or fields should cause an error in the TypeScript compilation step of you application. Hence it moves the error from GraphQL Codegen to TypeScript, allowing some of the changes to be handled in the code.
146
+
147
+ ### 3.5. Dedicated Queries & Fragments
148
+ The preset automatically injects a number of fragments and documents into the generated code. These can be found in their respective document:
149
+
150
+ - [`opti-cms:/queries/13`](./src/documents/queries.cms13.ts)
151
+ - [`opti-cms:/queries/12`](./src/documents/queries.cms12.ts)
152
+ - [`opti-cms:/fragments/13`](./src/documents/fragments.cms13.ts)
153
+ - [`opti-cms:/fragments/12`](./src/documents/fragments.cms12.ts)
154
+
155
+ ### Compiler field directive `@depend`
156
+ A compile time directive `@depend` is processed, allowing you to make selections depend on a field to present in the schema.
107
157
 
108
- ## Usage
158
+ For example: `componentData: item @depend(on: "ContentReference.item") {}` will remove the field selection `componentData` from the document if there's no type with the name `ContentReference` that has a field named `item`.
159
+
160
+ This allows to write generic queries that can cope with differen configurations within the CMS.
161
+
162
+ ## 4. Usage
109
163
  After running the code generation, you can use the following API's (assuming the folder where the generated files are stored is available at `@/gql`):
110
164
 
111
- ### Option 1: Direct methods
165
+ ### 4.1. Option 1: Direct methods
112
166
  Only the methods specified by the `functions` preset configuration are available using this method.
113
167
 
114
168
  ```typescript
@@ -123,7 +177,7 @@ const contentFromId = await getContentById(client, { guidValue: '00000000-0000-0
123
177
  const contentFromPath = await getContentByPath(client, { path: '/en' })
124
178
  ```
125
179
 
126
- ### Option 2: Enhanced Client
180
+ ### 4.2. Option 2: Enhanced Client
127
181
  All GraphQL operations (e.g. Queries, Mutations, ...) defined within the documents are available using this method.
128
182
 
129
183
  ```typescript
@@ -138,11 +192,3 @@ const locale = Schema.Locales.En
138
192
 
139
193
  const contentItem = await client.getContentById({ guidValue: contentId, locale })
140
194
  ```
141
-
142
- ## Query Fragments
143
- The preset automatically injects a number of fragments and documents into the generated code. These can be found in their respective document:
144
-
145
- - [`opti-cms:/queries/13`](./src/documents/queries.cms13.ts)
146
- - [`opti-cms:/queries/12`](./src/documents/queries.cms12.ts)
147
- - [`opti-cms:/fragments/13`](./src/documents/fragments.cms13.ts)
148
- - [`opti-cms:/fragments/12`](./src/documents/fragments.cms12.ts)
@@ -0,0 +1,10 @@
1
+ import { type Types } from '@graphql-codegen/plugin-helpers';
2
+ import type { PresetOptions } from '../types';
3
+ /**
4
+ * Remove all fragments that target a type that is not present in the Schema
5
+ *
6
+ * @param files
7
+ * @param options
8
+ * @returns
9
+ */
10
+ export declare function cleanFragments(files: Types.DocumentFile[], options: Types.PresetFnArgs<PresetOptions>): Types.DocumentFile[];
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cleanFragments = cleanFragments;
4
+ const graphql_1 = require("graphql");
5
+ /**
6
+ * Remove all fragments that target a type that is not present in the Schema
7
+ *
8
+ * @param files
9
+ * @param options
10
+ * @returns
11
+ */
12
+ function cleanFragments(files, options) {
13
+ if (options.presetConfig.verbose)
14
+ console.log(`✨ [Optimizely] Removing fragments that target non-existing types from the documents`);
15
+ return files.map(doc => {
16
+ if (doc.document) {
17
+ let isModified = false;
18
+ const newDocument = (0, graphql_1.visit)(doc.document, {
19
+ FragmentDefinition: {
20
+ enter: (node) => {
21
+ if (!options.schema.definitions.some(x => (x.kind == graphql_1.Kind.OBJECT_TYPE_DEFINITION || x.kind == graphql_1.Kind.INTERFACE_TYPE_DEFINITION) && x.name.value == node.typeCondition.name.value)) {
22
+ if (options.presetConfig.verbose)
23
+ console.log(`⚠ Removing fragment ${node.name.value} from the documents, as its target ${node.typeCondition.name.value} is not available in the schema`);
24
+ isModified = true;
25
+ return null;
26
+ }
27
+ }
28
+ }
29
+ });
30
+ return isModified ? {
31
+ ...doc,
32
+ rawSDL: (0, graphql_1.print)(newDocument),
33
+ document: newDocument
34
+ } : doc;
35
+ }
36
+ return doc;
37
+ });
38
+ }
39
+ //# sourceMappingURL=cleanFragments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanFragments.js","sourceRoot":"","sources":["../../src/_transform/cleanFragments.ts"],"names":[],"mappings":";;AAWA,wCA0BC;AApCD,qCAAmD;AAGnD;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,KAA2B,EAAE,OAA0C;IACpG,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;QAC9B,OAAO,CAAC,GAAG,CAAC,qFAAqF,CAAC,CAAA;IACpG,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACrB,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;YACjB,IAAI,UAAU,GAAG,KAAK,CAAA;YACtB,MAAM,WAAW,GAAG,IAAA,eAAK,EAAC,GAAG,CAAC,QAAQ,EAAE;gBACtC,kBAAkB,EAAE;oBAClB,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;wBACd,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,cAAI,CAAC,sBAAsB,IAAI,CAAC,CAAC,IAAI,IAAI,cAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;4BAChL,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;gCAC9B,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,CAAC,IAAI,CAAC,KAAK,sCAAsC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,iCAAiC,CAAC,CAAA;4BACzJ,UAAU,GAAG,IAAI,CAAA;4BACjB,OAAO,IAAI,CAAA;wBACb,CAAC;oBACH,CAAC;iBACF;aACF,CAAC,CAAA;YACF,OAAO,UAAU,CAAC,CAAC,CAAC;gBAClB,GAAG,GAAG;gBACN,MAAM,EAAE,IAAA,eAAK,EAAC,WAAW,CAAC;gBAC1B,QAAQ,EAAE,WAAW;aACtB,CAAC,CAAC,CAAC,GAAG,CAAA;QACT,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type Types } from '@graphql-codegen/plugin-helpers';
2
+ import type { PresetOptions } from '../types';
3
+ /**
4
+ * Remove all fragment spreads that target non-existing fragments from the documents.
5
+ *
6
+ * @param files
7
+ * @param options
8
+ * @returns
9
+ */
10
+ export declare function cleanFragmentSpreads(files: Types.DocumentFile[], options: Types.PresetFnArgs<PresetOptions>): Types.DocumentFile[];
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cleanFragmentSpreads = cleanFragmentSpreads;
4
+ const graphql_1 = require("graphql");
5
+ const tools_1 = require("./tools");
6
+ /**
7
+ * Remove all fragment spreads that target non-existing fragments from the documents.
8
+ *
9
+ * @param files
10
+ * @param options
11
+ * @returns
12
+ */
13
+ function cleanFragmentSpreads(files, options) {
14
+ const allFragments = (0, tools_1.getAllFragments)(files);
15
+ return files.map(file => {
16
+ if (!file.document)
17
+ return file;
18
+ let isModified = false;
19
+ const newDocument = (0, graphql_1.visit)(file.document, {
20
+ FragmentSpread: {
21
+ enter: (node) => {
22
+ if (!allFragments.some(x => x.fragmentName === node.name.value)) {
23
+ isModified = true;
24
+ return null;
25
+ }
26
+ }
27
+ }
28
+ });
29
+ return isModified ? {
30
+ ...file,
31
+ rawSDL: (0, graphql_1.print)(newDocument),
32
+ document: newDocument
33
+ } : file;
34
+ });
35
+ }
36
+ //# sourceMappingURL=cleanSpreads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanSpreads.js","sourceRoot":"","sources":["../../src/_transform/cleanSpreads.ts"],"names":[],"mappings":";;AAYA,oDAwBC;AAnCD,qCAAmD;AAEnD,mCAAyC;AAEzC;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,KAA2B,EAAE,OAA0C;IAC1G,MAAM,YAAY,GAAG,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAA;IAC3C,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACtB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAChB,OAAO,IAAI,CAAC;QAEd,IAAI,UAAU,GAAY,KAAK,CAAC;QAChC,MAAM,WAAW,GAAG,IAAA,eAAK,EAAC,IAAI,CAAC,QAAQ,EAAE;YACvC,cAAc,EAAE;gBACd,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;oBACd,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;wBAChE,UAAU,GAAG,IAAI,CAAC;wBAClB,OAAO,IAAI,CAAC;oBACd,CAAC;gBACH,CAAC;aACF;SACF,CAAC,CAAC;QAEH,OAAO,UAAU,CAAC,CAAC,CAAC;YAClB,GAAG,IAAI;YACP,MAAM,EAAE,IAAA,eAAK,EAAC,WAAW,CAAC;YAC1B,QAAQ,EAAE,WAAW;SACtB,CAAC,CAAC,CAAC,IAAI,CAAA;IACV,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Types } from '@graphql-codegen/plugin-helpers';
2
+ import type { PresetOptions } from '../types';
3
+ /**
4
+ * Remove the "item" field in queries and fragments from the "ContentReference" type if it's not in the schema
5
+ *
6
+ * @param files
7
+ * @param options
8
+ * @returns
9
+ */
10
+ export declare function handleDependDirective(files: Types.DocumentFile[], options: Types.PresetFnArgs<PresetOptions>): Promise<Types.DocumentFile[]>;
11
+ export default handleDependDirective;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleDependDirective = handleDependDirective;
4
+ const graphql_1 = require("graphql");
5
+ /**
6
+ * Remove the "item" field in queries and fragments from the "ContentReference" type if it's not in the schema
7
+ *
8
+ * @param files
9
+ * @param options
10
+ * @returns
11
+ */
12
+ async function handleDependDirective(files, options) {
13
+ // Debug output
14
+ if (options.presetConfig.verbose)
15
+ console.log(`✨ [Optimizely] Checking ContentReference to determine if it has an "item" field`);
16
+ // Ouch, this is an old SaaS CMS instance, so we're going to clean this field
17
+ if (options.presetConfig.verbose)
18
+ console.log(`✨ [Optimizely] Nope it hasn't removing any reference to it`);
19
+ const filteredFiles = files.map((file) => {
20
+ let isModified = false;
21
+ const newDocument = file.document ? (0, graphql_1.visit)(file.document, {
22
+ Field: {
23
+ enter(node) {
24
+ // Check if the field has the `depend` directive
25
+ const dependDirective = node.directives?.find(x => x.name.value === 'depend');
26
+ if (dependDirective) {
27
+ // If so read the arguments and validate if the required "on" argument is there
28
+ const args = parseArgs(dependDirective.arguments);
29
+ const dependency = args.get('on');
30
+ if (typeof dependency !== 'string' || dependency.length === 0)
31
+ throw new Error(`The "@depend" directive requires the parameter "on" to be a non-empty string ${buildLocString(dependDirective)}`);
32
+ // Parse & validate the argument
33
+ const [typeName, fieldName, ...remaining] = dependency.split('.');
34
+ if (remaining.length > 0)
35
+ throw new Error(`The "on" parameter of the "@depend" directive must have the form "typeName.fieldName" ${buildLocString(dependDirective)}`);
36
+ // Retrieve the type fields
37
+ const fields = getObjectFieldNames(options.schema, typeName);
38
+ isModified = true;
39
+ if (!(fields?.includes(fieldName) ?? false)) {
40
+ return null; // Remove the item
41
+ }
42
+ else {
43
+ const newNode = {
44
+ ...node,
45
+ directives: node.directives?.filter(x => x.name.value !== 'depend')
46
+ };
47
+ return newNode;
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }) : undefined;
53
+ return isModified
54
+ ? {
55
+ ...file,
56
+ rawSDL: newDocument ? (0, graphql_1.print)(newDocument) : undefined,
57
+ document: newDocument,
58
+ }
59
+ : file;
60
+ });
61
+ return filteredFiles;
62
+ }
63
+ exports.default = handleDependDirective;
64
+ function buildLocString(node) {
65
+ if (!node.loc)
66
+ return "";
67
+ const sourceName = node.loc.source.name;
68
+ const startLine = node.loc.startToken.line;
69
+ const startChar = node.loc.startToken.column;
70
+ return `in ${sourceName} at line ${startLine}, position ${startChar}`;
71
+ }
72
+ function parseArgs(args) {
73
+ return args?.reduce((out, arg) => {
74
+ const argName = arg.name.value;
75
+ switch (arg.value.kind) {
76
+ case graphql_1.Kind.INT:
77
+ out.set(argName, parseInt(arg.value.value));
78
+ break;
79
+ case graphql_1.Kind.BOOLEAN:
80
+ out.set(argName, new Boolean(arg.value.value));
81
+ break;
82
+ case graphql_1.Kind.STRING:
83
+ out.set(argName, arg.value.value);
84
+ break;
85
+ default:
86
+ throw new Error(`Error parsing directive arguments, encountered unsupported argument kind ${arg.value.kind} for ${argName} ${buildLocString(arg)}`);
87
+ }
88
+ return out;
89
+ }, new Map()) ?? new Map();
90
+ }
91
+ function getObjectFieldNames(schema, objectName) {
92
+ let currentObjectName;
93
+ let objectFields = [];
94
+ let hasType = false;
95
+ (0, graphql_1.visit)(schema, {
96
+ ObjectTypeDefinition: {
97
+ enter(node) {
98
+ if (node.name.value === objectName)
99
+ hasType = true;
100
+ currentObjectName = node.name.value;
101
+ },
102
+ leave(node) {
103
+ if (currentObjectName === node.name.value)
104
+ currentObjectName = undefined;
105
+ },
106
+ },
107
+ FieldDefinition: {
108
+ enter(node) {
109
+ if (currentObjectName === objectName)
110
+ objectFields.push(node.name.value);
111
+ },
112
+ },
113
+ });
114
+ return objectFields;
115
+ }
116
+ function isASTNode(node) {
117
+ return !Array.isArray(node);
118
+ }
119
+ function isNotNullOrUndefined(toTest) {
120
+ return toTest !== null && toTest !== undefined;
121
+ }
122
+ function isFragmentOrOperation(x) {
123
+ if (Array.isArray(x) || x == undefined || x == null)
124
+ return false;
125
+ return (x.kind == graphql_1.Kind.FRAGMENT_DEFINITION ||
126
+ x.kind == graphql_1.Kind.OPERATION_DEFINITION);
127
+ }
128
+ //# sourceMappingURL=handleDependDirective.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleDependDirective.js","sourceRoot":"","sources":["../../src/_transform/handleDependDirective.ts"],"names":[],"mappings":";;AAsBA,sDA0DC;AA/ED,qCAWgB;AAGhB;;;;;;GAMG;AACI,KAAK,UAAU,qBAAqB,CACzC,KAA2B,EAC3B,OAA0C;IAE1C,eAAe;IACf,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;QAC9B,OAAO,CAAC,GAAG,CACT,iFAAiF,CAClF,CAAA;IAEH,6EAA6E;IAC7E,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;QAC9B,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAA;IAE3E,MAAM,aAAa,GAAyB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7D,IAAI,UAAU,GAAG,KAAK,CAAA;QACtB,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,eAAK,EAAC,IAAI,CAAC,QAAQ,EAAE;YACvD,KAAK,EAAE;gBACL,KAAK,CAAC,IAAI;oBACR,gDAAgD;oBAChD,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAA;oBAC7E,IAAI,eAAe,EAAE,CAAC;wBACpB,+EAA+E;wBAC/E,MAAM,IAAI,GAAG,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;wBACj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IAAI,IAAI;QAAE,OAAO,KAAK,CAAA;IACjE,OAAO,CACJ,CAAa,CAAC,IAAI,IAAI,cAAI,CAAC,mBAAmB;QAC9C,CAAa,CAAC,IAAI,IAAI,cAAI,CAAC,oBAAoB,CACjD,CAAA;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Types } from '@graphql-codegen/plugin-helpers';
2
+ import type { PresetOptions } from '../types';
3
+ export declare function getComponentDocuments(loader?: string): Promise<Types.CustomDocumentLoader[]>;
4
+ export declare function getInjectionTargetDocuments(loader?: string): Promise<Types.CustomDocumentLoader[]>;
5
+ export declare function injectInjectionTargets(files: Types.DocumentFile[], options: Types.PresetFnArgs<PresetOptions>): Promise<Types.DocumentFile[]>;
6
+ /**
7
+ * Check all fragments within the project and ensure that there's at least a fragment for every
8
+ * content type defined in Optimizely CMS. This assumes that when overriding the fragments the
9
+ * project will ensure that the injections are correct.
10
+ *
11
+ * @param files
12
+ * @param options
13
+ * @returns
14
+ */
15
+ export declare function injectComponentDocuments(files: Types.DocumentFile[], options: Types.PresetFnArgs<PresetOptions>): Promise<Types.DocumentFile[]>;
16
+ export default injectComponentDocuments;
@@ -0,0 +1,177 @@
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.getComponentDocuments = getComponentDocuments;
37
+ exports.getInjectionTargetDocuments = getInjectionTargetDocuments;
38
+ exports.injectInjectionTargets = injectInjectionTargets;
39
+ exports.injectComponentDocuments = injectComponentDocuments;
40
+ const graphql_1 = require("graphql");
41
+ const generator_1 = require("../generator");
42
+ const OptiCMS = __importStar(require("../cms"));
43
+ const tools_1 = require("./tools");
44
+ const utils_1 = require("../utils");
45
+ async function getComponentDocuments(loader = '@remkoj/optimizely-graph-functions/contenttype-loader') {
46
+ const componentTypes = await OptiCMS.getContentTypesList(undefined, (ct) => {
47
+ if (!ct.key) // The key is required
48
+ return false;
49
+ if (ct.source === 'graph' || ct.source === 'globalcontract' || ct.source === '_system') // Only CMS managed types are allowed
50
+ return false;
51
+ //@ts-expect-error
52
+ if (ct.isContract) // Contracts must be ignored
53
+ return false;
54
+ return true;
55
+ });
56
+ const documents = [];
57
+ for (const componentType of componentTypes) {
58
+ const vLoc = generator_1.VirtualLocation.build(componentType, { type: 'fragment', forProperty: false });
59
+ if (vLoc) {
60
+ // Inject virtual location
61
+ const def = {};
62
+ def[vLoc] = { loader };
63
+ documents.push(def);
64
+ // Get properties
65
+ const propertyComponentTypeNames = generator_1.DocumentGenerator.getReferencedPropertyComponents(componentType);
66
+ const propertyComponentTypes = (await Promise.all(propertyComponentTypeNames.map(componentTypeName => OptiCMS.getContentType(componentTypeName)))).filter(utils_1.isNotNullOrUndefined);
67
+ for (const propertyComponentType of propertyComponentTypes) {
68
+ const propVLoc = generator_1.VirtualLocation.build(propertyComponentType, { type: 'fragment', forProperty: true });
69
+ if (propVLoc && !documents.some(x => typeof x === 'object' && x[propVLoc])) {
70
+ // Inject virtual location
71
+ const def = {};
72
+ def[propVLoc] = { loader };
73
+ documents.push(def);
74
+ }
75
+ }
76
+ }
77
+ }
78
+ return documents;
79
+ }
80
+ async function getInjectionTargetDocuments(loader = '@remkoj/optimizely-graph-functions/contenttype-loader') {
81
+ const documents = [];
82
+ for (const injectionTarget of generator_1.VirtualLocation.getInjectionTargets()) {
83
+ const vLoc = generator_1.VirtualLocation.build(injectionTarget);
84
+ const def = {};
85
+ def[vLoc] = { loader };
86
+ documents.push(def);
87
+ }
88
+ return documents;
89
+ }
90
+ async function injectInjectionTargets(files, options) {
91
+ const allFragments = (0, tools_1.getAllFragments)(files);
92
+ const addedFiles = [];
93
+ if (options.presetConfig.verbose)
94
+ console.log(`✨ [Optimizely] Generating injection target fragments`);
95
+ for (const injectionTarget of generator_1.VirtualLocation.getInjectionTargets()) {
96
+ if (!allFragments.some(x => x.fragmentName === injectionTarget)) {
97
+ const vLoc = `opti-cms:/injectiontarget/${injectionTarget}`;
98
+ const rawSDL = `fragment ${injectionTarget} on _IContent { ...IContentData }`;
99
+ if (options.presetConfig.verbose)
100
+ console.log(` - Generated fragment ${injectionTarget} at ${vLoc}`);
101
+ addedFiles.push({
102
+ rawSDL,
103
+ document: (0, graphql_1.parse)(rawSDL),
104
+ location: vLoc,
105
+ hash: vLoc
106
+ });
107
+ }
108
+ }
109
+ return [...files, ...addedFiles];
110
+ }
111
+ /**
112
+ * Check all fragments within the project and ensure that there's at least a fragment for every
113
+ * content type defined in Optimizely CMS. This assumes that when overriding the fragments the
114
+ * project will ensure that the injections are correct.
115
+ *
116
+ * @param files
117
+ * @param options
118
+ * @returns
119
+ */
120
+ async function injectComponentDocuments(files, options) {
121
+ const allFragments = (0, tools_1.getAllFragments)(files);
122
+ const allGraphTypes = (0, tools_1.getAllTypeNames)(options.schema);
123
+ const addedFiles = [];
124
+ if (options.presetConfig.verbose)
125
+ console.log(`✨ [Optimizely] Generating component fragments that have not been defined by the implementation`);
126
+ const allContentTypes = await OptiCMS.getContentTypes(options.presetConfig.cmsClient, (ct) => {
127
+ return ct.key && ct.source !== 'graph' ? true : false;
128
+ });
129
+ const queryGen = new generator_1.DocumentGenerator(allContentTypes);
130
+ const propTracker = new Map();
131
+ for (const [_, contentType] of allContentTypes) {
132
+ // Skip over content types without a key
133
+ if (!contentType.key)
134
+ continue;
135
+ // Construct the type names expected to be in Graph
136
+ const graphType = queryGen.getGraphType(contentType);
137
+ const graphPropertyType = queryGen.getGraphPropertyType(contentType);
138
+ const fragmentName = queryGen.getDefaultFragmentName(contentType);
139
+ const propertyFragmentName = queryGen.getDefaultPropertyFragmentName(contentType);
140
+ // Check if the types exist
141
+ const graphTypeExists = allGraphTypes.includes(graphType);
142
+ const graphPropertyTypeExists = allGraphTypes.includes(graphPropertyType);
143
+ // Add Component Data Fragment
144
+ if (graphTypeExists && !allFragments.has(fragmentName)) {
145
+ const rawSDL = queryGen.buildFragment(contentType, fragmentName, false, propTracker);
146
+ const vLoc = generator_1.VirtualLocation.build(contentType);
147
+ if (rawSDL) {
148
+ if (options.presetConfig.verbose)
149
+ console.log(` - Generated fragment ${fragmentName} for ${contentType.key} at ${vLoc}`);
150
+ addedFiles.push({
151
+ rawSDL,
152
+ document: (0, graphql_1.parse)(rawSDL),
153
+ location: vLoc,
154
+ hash: vLoc
155
+ });
156
+ }
157
+ }
158
+ // Add Component Property Data Fragment
159
+ if (graphPropertyTypeExists && contentType.baseType === '_component' && !allFragments.has(propertyFragmentName)) {
160
+ const rawSDL = queryGen.buildFragment(contentType, propertyFragmentName, true, propTracker);
161
+ const vLoc = generator_1.VirtualLocation.build(contentType, { forProperty: true });
162
+ if (rawSDL) {
163
+ if (options.presetConfig.verbose)
164
+ console.log(` - Generated property fragment ${propertyFragmentName} for ${contentType.key} at ${vLoc}`);
165
+ addedFiles.push({
166
+ rawSDL,
167
+ document: (0, graphql_1.parse)(rawSDL),
168
+ location: vLoc,
169
+ hash: vLoc
170
+ });
171
+ }
172
+ }
173
+ }
174
+ return [...files, ...addedFiles];
175
+ }
176
+ exports.default = injectComponentDocuments;
177
+ //# sourceMappingURL=injectComponentDocuments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injectComponentDocuments.js","sourceRoot":"","sources":["../../src/_transform/injectComponentDocuments.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,sDAqCC;AAED,kEAUC;AAED,wDAuBC;AAWD,4DAgEC;AA5JD,qCAA+B;AAC/B,4CAAiE;AACjE,gDAAiC;AAEjC,mCAA0D;AAC1D,oCAA+C;AAExC,KAAK,UAAU,qBAAqB,CAAC,SAAiB,uDAAuD;IAElH,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE;QACzE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,sBAAsB;YACjC,OAAO,KAAK,CAAC;QACf,IAAI,EAAE,CAAC,MAAM,KAAK,OAAO,IAAI,EAAE,CAAC,MAAM,KAAK,gBAAgB,IAAI,EAAE,CAAC,MAAM,KAAK,SAAS,EAAE,qCAAqC;YAC3H,OAAO,KAAK,CAAC;QACf,kBAAkB;QAClB,IAAI,EAAE,CAAC,UAAU,EAAE,4BAA4B;YAC7C,OAAO,KAAK,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAiC,EAAE,CAAC;IACnD,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,2BAAe,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,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,IAAA,eAAK,EAAC,MAAM,CAAC;oBACvB,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,IAAI;iBACX,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,KAAK,EAAE,GAAG,UAAU,CAAC,CAAA;AAClC,CAAC;AAED,kBAAe,wBAAwB,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { Types } from '@graphql-codegen/plugin-helpers';
2
+ import type { PresetOptions } from '../types';
3
+ export declare function getPageDocuments(loader?: string): Promise<Types.CustomDocumentLoader[]>;
4
+ export declare function injectPageQueries(files: Types.DocumentFile[], options: Types.PresetFnArgs<PresetOptions>): Promise<Types.DocumentFile[]>;
5
+ export default injectPageQueries;