@remkoj/optimizely-graph-functions 6.0.0-pre13 → 6.0.0-pre15

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 (38) hide show
  1. package/README.md +4 -0
  2. package/dist/_transform/injectComponentDocuments.d.ts +3 -0
  3. package/dist/_transform/injectComponentDocuments.js +72 -24
  4. package/dist/_transform/injectComponentDocuments.js.map +1 -1
  5. package/dist/_transform/injectPageQueries.d.ts +1 -0
  6. package/dist/_transform/injectPageQueries.js +40 -7
  7. package/dist/_transform/injectPageQueries.js.map +1 -1
  8. package/dist/_transform/injectSectionQueries.d.ts +1 -0
  9. package/dist/_transform/injectSectionQueries.js +27 -7
  10. package/dist/_transform/injectSectionQueries.js.map +1 -1
  11. package/dist/_transform/performInjections.js +2 -35
  12. package/dist/_transform/performInjections.js.map +1 -1
  13. package/dist/cms/index.d.ts +4 -10
  14. package/dist/cms/index.js +57 -24
  15. package/dist/cms/index.js.map +1 -1
  16. package/dist/contenttype-loader.d.ts +1 -48
  17. package/dist/contenttype-loader.js +21 -281
  18. package/dist/contenttype-loader.js.map +1 -1
  19. package/dist/generator/collision-tracker.d.ts +22 -0
  20. package/dist/generator/collision-tracker.js +103 -0
  21. package/dist/generator/collision-tracker.js.map +1 -0
  22. package/dist/generator/generator.d.ts +77 -0
  23. package/dist/generator/generator.js +267 -0
  24. package/dist/generator/generator.js.map +1 -0
  25. package/dist/generator/index.d.ts +3 -0
  26. package/dist/generator/index.js +42 -0
  27. package/dist/generator/index.js.map +1 -0
  28. package/dist/generator/virtual-location.d.ts +41 -0
  29. package/dist/generator/virtual-location.js +139 -0
  30. package/dist/generator/virtual-location.js.map +1 -0
  31. package/dist/index.js +4 -1
  32. package/dist/index.js.map +1 -1
  33. package/dist/preset.js +61 -36
  34. package/dist/preset.js.map +1 -1
  35. package/dist/transform.d.ts +3 -3
  36. package/dist/transform.js +6 -1
  37. package/dist/transform.js.map +1 -1
  38. package/package.json +20 -16
@@ -1,58 +1,11 @@
1
1
  import { type Types } from '@graphql-codegen/plugin-helpers';
2
- import type { IntegrationApi } from '@remkoj/optimizely-cms-api';
3
2
  export * as Tools from './tools';
4
3
  type LoaderConfig = {
4
+ cwd: string;
5
5
  pluginContext?: {
6
6
  [key: string]: any;
7
7
  };
8
8
  };
9
9
  type LoaderFunction = (documentUri: string, config: LoaderConfig) => Promise<Types.DocumentFile | undefined | void>;
10
10
  declare const ContentTypeLoader: LoaderFunction;
11
- export type VirtualLocationOptions = {
12
- forProperty: boolean;
13
- type: 'fragment' | 'query';
14
- };
15
- export type VirtualLocationData = {
16
- contentTypeBase: string;
17
- contentTypeKey: string;
18
- injectionTargets: Array<string>;
19
- } & VirtualLocationOptions;
20
- export declare function parseVirtualLocation(virtualPath: string): VirtualLocationData | undefined;
21
- export declare function buildVirtualLocation(contentType: IntegrationApi.ContentType, options?: Partial<VirtualLocationOptions>): string | undefined;
22
- /**
23
- * Get the Graph Type for the Content Type
24
- * @param contentType
25
- * @returns
26
- */
27
- export declare function getGraphType(contentType: IntegrationApi.ContentType): string;
28
- export declare function getGraphPropertyType(contentType: IntegrationApi.ContentType): string;
29
- export declare function parseBaseType(storedBaseType: string): string;
30
- export declare function extractBaseType(contentType: IntegrationApi.ContentType, fallback?: string): string;
31
- export declare enum ContentTypeTarget {
32
- 'SectionData' = "SectionData",
33
- 'PageData' = "PageData",
34
- 'MediaData' = "MediaData",
35
- 'ComponentData' = "ComponentData",
36
- 'ElementData' = "ElementData",
37
- 'SectionElementData' = "SectionElementData",
38
- 'FormElementData' = "FormElementData",
39
- 'BlockData' = "BlockData"
40
- }
41
- export declare function getContentTypeTargets(contentType: IntegrationApi.ContentType): ContentTypeTarget[];
42
- export declare function buildGetQuery(contentType: IntegrationApi.ContentType, queryName?: string | ((defaultName: string) => string), propertyTracker?: PropertyCollisionTracker): string;
43
- /**
44
- * Retrieve a list of component keys that are referenced as property by this type
45
- *
46
- * @param contentType
47
- * @returns
48
- */
49
- export declare function getReferencedPropertyComponents(contentType: IntegrationApi.ContentType): string[];
50
- export declare function getSlugFromKey(key: string): string;
51
- /**
52
- * Tracker for all properties, indexed by property name, then type
53
- * for a list of all ContentTypes.
54
- */
55
- export type PropertyCollisionTracker = Map<string, string>;
56
- export declare function buildFragment(contentType: IntegrationApi.ContentType, fragmentName?: string | ((defaultName: string) => string), forProperty?: boolean, propertyTracker?: PropertyCollisionTracker): string;
57
- export declare function buildProperty(propertyName: string, propertyConfig?: IntegrationApi.ContentTypeProperty, propertyTracker?: PropertyCollisionTracker): string | null;
58
11
  export default ContentTypeLoader;
@@ -33,36 +33,34 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ContentTypeTarget = exports.Tools = void 0;
37
- exports.parseVirtualLocation = parseVirtualLocation;
38
- exports.buildVirtualLocation = buildVirtualLocation;
39
- exports.getGraphType = getGraphType;
40
- exports.getGraphPropertyType = getGraphPropertyType;
41
- exports.parseBaseType = parseBaseType;
42
- exports.extractBaseType = extractBaseType;
43
- exports.getContentTypeTargets = getContentTypeTargets;
44
- exports.buildGetQuery = buildGetQuery;
45
- exports.getReferencedPropertyComponents = getReferencedPropertyComponents;
46
- exports.getSlugFromKey = getSlugFromKey;
47
- exports.buildFragment = buildFragment;
48
- exports.buildProperty = buildProperty;
36
+ exports.Tools = void 0;
49
37
  const graphql_1 = require("graphql");
50
38
  const OptiCMS = __importStar(require("./cms"));
51
- const tools_1 = require("./tools");
39
+ const generator_1 = require("./generator");
52
40
  exports.Tools = __importStar(require("./tools"));
41
+ const collisionTracker = new generator_1.PropertyCollisionTracker();
53
42
  const ContentTypeLoader = async (documentUri, config) => {
54
- const parsedData = parseVirtualLocation(documentUri);
43
+ collisionTracker.cwd = config.cwd;
44
+ const parsedData = generator_1.VirtualLocation.parse(documentUri);
55
45
  if (!parsedData)
56
46
  return undefined;
57
47
  const { type: loaderType, contentTypeBase: baseType, contentTypeKey, forProperty: isForProperty } = parsedData;
58
- const contentType = await OptiCMS.getContentType(contentTypeKey);
59
- if (!contentType)
60
- throw new Error(`ContentType with key ${baseType} cannot be loaded`);
61
- if (contentType.baseType !== baseType)
62
- throw new Error(`ContentType base types don't match, expected ${baseType} but received ${contentType.baseType}`);
63
- const rawSDL = loaderType === 'fragment' ?
64
- buildFragment(contentType, (name) => '_' + name, isForProperty) :
65
- buildGetQuery(contentType);
48
+ const allContentTypes = await OptiCMS.getContentTypes();
49
+ const generator = new generator_1.DocumentGenerator(allContentTypes);
50
+ let rawSDL;
51
+ if (loaderType === "target") {
52
+ rawSDL = generator.buildInjectionTarget(`_${contentTypeKey}`);
53
+ }
54
+ else {
55
+ const contentType = await OptiCMS.getContentType(contentTypeKey);
56
+ if (!contentType)
57
+ throw new Error(`ContentType with key ${contentTypeKey} cannot be loaded (Base: ${baseType})`);
58
+ if (contentType.baseType !== baseType)
59
+ throw new Error(`ContentType base types don't match, expected ${baseType} but received ${contentType.baseType}`);
60
+ rawSDL = loaderType === 'fragment' ?
61
+ generator.buildFragment(contentType, (name) => '_' + name, isForProperty, collisionTracker) :
62
+ generator.buildGetQuery(contentType, (name) => '_' + name, collisionTracker);
63
+ }
66
64
  return rawSDL ? {
67
65
  document: (0, graphql_1.parse)(rawSDL),
68
66
  location: documentUri,
@@ -70,263 +68,5 @@ const ContentTypeLoader = async (documentUri, config) => {
70
68
  rawSDL
71
69
  } : undefined;
72
70
  };
73
- const DefaultVirtualLocationOptions = { forProperty: false, type: 'fragment' };
74
- function parseVirtualLocation(virtualPath) {
75
- if (!virtualPath.startsWith('opti-cms:/'))
76
- return undefined;
77
- const virtualURL = new URL(virtualPath);
78
- const [basePath, baseType, ctKey, ...targets] = virtualURL.pathname.split('/').filter(tools_1.isNonEmptyString);
79
- // Validate the basepath
80
- if (!['contenttypes', 'contentquery'].includes(basePath))
81
- return undefined;
82
- const type = basePath == "contenttypes" ? 'fragment' : 'query';
83
- const forProperty = baseType.endsWith('.property');
84
- const contentTypeBase = parseBaseType(forProperty ? baseType.substring(0, baseType.length - 9) : baseType);
85
- const contentTypeKey = ctKey;
86
- const injectionTargets = targets;
87
- return { type, contentTypeBase, contentTypeKey, injectionTargets, forProperty };
88
- }
89
- function buildVirtualLocation(contentType, options) {
90
- const { forProperty, type } = { ...DefaultVirtualLocationOptions, ...options };
91
- const basePath = type == 'fragment' ? 'contenttypes' : 'contentquery';
92
- const ctKey = contentType.key;
93
- if (!ctKey || contentType.source === 'graph' || contentType.source === '_system')
94
- return undefined;
95
- const baseType = extractBaseType(contentType);
96
- return forProperty ?
97
- `opti-cms:/${basePath}/${baseType}.property/${ctKey}` :
98
- `opti-cms:/${basePath}/${baseType}/${ctKey}/${getContentTypeTargets(contentType).join('/')}`;
99
- }
100
- /**
101
- * Get the Graph Type for the Content Type
102
- * @param contentType
103
- * @returns
104
- */
105
- function getGraphType(contentType) {
106
- return contentType.key ? contentType.key : "_IContent";
107
- }
108
- function getGraphPropertyType(contentType) {
109
- return (contentType.key ? contentType.key : "_IContent") + "Property";
110
- }
111
- function parseBaseType(storedBaseType) {
112
- switch (storedBaseType.toLowerCase()) {
113
- case 'section':
114
- case 'media':
115
- case 'component':
116
- case 'experience':
117
- case 'page':
118
- return '_' + storedBaseType;
119
- default:
120
- return storedBaseType;
121
- }
122
- }
123
- function extractBaseType(contentType, fallback = 'cms') {
124
- return (contentType.baseType ?? fallback).replace(/^_+/, '');
125
- }
126
- var ContentTypeTarget;
127
- (function (ContentTypeTarget) {
128
- ContentTypeTarget["SectionData"] = "SectionData";
129
- ContentTypeTarget["PageData"] = "PageData";
130
- ContentTypeTarget["MediaData"] = "MediaData";
131
- ContentTypeTarget["ComponentData"] = "ComponentData";
132
- ContentTypeTarget["ElementData"] = "ElementData";
133
- ContentTypeTarget["SectionElementData"] = "SectionElementData";
134
- ContentTypeTarget["FormElementData"] = "FormElementData";
135
- ContentTypeTarget["BlockData"] = "BlockData";
136
- })(ContentTypeTarget || (exports.ContentTypeTarget = ContentTypeTarget = {}));
137
- function getContentTypeTargets(contentType) {
138
- if (!contentType.key || contentType.key.startsWith('graph:'))
139
- return [];
140
- const injections = [];
141
- const baseType = extractBaseType(contentType);
142
- switch (baseType) {
143
- case 'section':
144
- injections.push(ContentTypeTarget.SectionData);
145
- break;
146
- case 'page':
147
- case 'experience':
148
- injections.push(ContentTypeTarget.PageData);
149
- break;
150
- case 'media':
151
- case 'video':
152
- case 'image':
153
- injections.push(ContentTypeTarget.MediaData);
154
- break;
155
- case 'component': {
156
- const usage = contentType.compositionBehaviors ?? [];
157
- const source = contentType.source;
158
- if (!(source === '_server' && usage.length === 1 && usage[0] === 'formsElementEnabled'))
159
- injections.push(ContentTypeTarget.ComponentData);
160
- if (usage.includes('elementEnabled'))
161
- injections.push(ContentTypeTarget.ElementData);
162
- if (usage.includes('sectionEnabled'))
163
- injections.push(ContentTypeTarget.SectionElementData);
164
- if (usage.includes('formsElementEnabled'))
165
- injections.push(ContentTypeTarget.FormElementData);
166
- break;
167
- }
168
- default:
169
- injections.push(ContentTypeTarget.BlockData);
170
- break;
171
- }
172
- return injections;
173
- }
174
- function buildGetQuery(contentType, queryName, propertyTracker = new Map()) {
175
- // Prepare
176
- if (!contentType.key || contentType.source === 'graph')
177
- return '';
178
- const graphType = getGraphType(contentType);
179
- const renderedQueryName = (0, tools_1.isNonEmptyString)(queryName) ? queryName :
180
- (typeof queryName === 'function' ? queryName(`get${(0, tools_1.ucFirst)(graphType)}Data`) :
181
- `get${(0, tools_1.ucFirst)(graphType)}Data`);
182
- // Render properties
183
- const properties = [];
184
- for (const propName of Object.getOwnPropertyNames(contentType.properties ?? {}))
185
- properties.push(buildProperty(propName, (contentType.properties || {})[propName], propertyTracker));
186
- // Inject base type based defaults
187
- if (contentType.baseType === "_experience")
188
- properties.unshift("...ExperienceData");
189
- //Render query
190
- const query = `query ${renderedQueryName}($key: [String!]!, $locale: [Locales], $changeset: String, $variation: VariationInput, $version: String) {
191
- data: ${graphType}(
192
- ids: $key
193
- locale: $locale
194
- variation: $variation
195
- where: { _metadata: { changeset: { eq: $changeset }, version: { eq: $version } } }
196
- ) {
197
- total
198
- item {
199
- _metadata {
200
- key
201
- version
202
- locale
203
- changeset
204
- variation
205
- }
206
- ${properties.filter(tools_1.isNonEmptyString).join("\n ")}
207
- }
208
- }
209
- }`;
210
- return query;
211
- }
212
- /**
213
- * Retrieve a list of component keys that are referenced as property by this type
214
- *
215
- * @param contentType
216
- * @returns
217
- */
218
- function getReferencedPropertyComponents(contentType) {
219
- const properties = contentType.properties;
220
- if (!properties)
221
- return [];
222
- return Object.getOwnPropertyNames(properties).reduce((referencedTypes, propertyKey) => {
223
- if (properties[propertyKey].type == "component" && properties[propertyKey].contentType) {
224
- referencedTypes.push(properties[propertyKey]?.contentType);
225
- }
226
- if (properties[propertyKey].type == "array" && properties[propertyKey].items?.type == "component" && properties[propertyKey].items?.contentType) {
227
- referencedTypes.push(properties[propertyKey]?.items?.contentType);
228
- }
229
- return referencedTypes;
230
- }, []);
231
- }
232
- function getSlugFromKey(key) {
233
- let newKey = key.startsWith('_') ? (0, tools_1.ucFirst)(key.substring(1)) : key;
234
- if (newKey.includes(":"))
235
- newKey = newKey.split(":").map(x => (0, tools_1.ucFirst)(x)).join("");
236
- return newKey;
237
- }
238
- function buildFragment(contentType, fragmentName, forProperty = false, propertyTracker = new Map()) {
239
- if (!contentType.key)
240
- return '';
241
- const graphType = forProperty ? getGraphPropertyType(contentType) : getGraphType(contentType);
242
- const graphFragmentName = (0, tools_1.isNonEmptyString)(fragmentName) ?
243
- fragmentName : (typeof fragmentName === 'function' ? fragmentName((0, tools_1.ucFirst)(graphType) + "Data") : (0, tools_1.ucFirst)(graphType) + "Data");
244
- // Inject all properties
245
- const properties = [];
246
- for (const propName of Object.getOwnPropertyNames(contentType.properties ?? {}))
247
- properties.push(buildProperty(propName, (contentType.properties || {})[propName], propertyTracker));
248
- // Inject base type based defaults
249
- if (contentType.baseType === "_experience")
250
- properties.push("...ExperienceData");
251
- // Ensure that there's at least one property
252
- if (properties.length === 0)
253
- properties.unshift("__typename");
254
- // Construct fragment rawSDL
255
- return `fragment ${graphFragmentName} on ${graphType} {
256
- ${properties.filter(tools_1.isNonEmptyString).join("\n ")}
257
- }`;
258
- }
259
- function buildProperty(propertyName, propertyConfig, propertyTracker = new Map()) {
260
- const propertyItemConfig = propertyConfig?.type === 'array' ? propertyConfig?.items ?? propertyConfig : propertyConfig;
261
- const propertyType = propertyItemConfig?.type ?? 'any';
262
- // Ensure we don't have property naming collisions
263
- let outputPropertyName = propertyName;
264
- if (propertyTracker.has(propertyName)) {
265
- if (propertyTracker.get(propertyName) != propertyType) {
266
- outputPropertyName = `${propertyName}${(0, tools_1.ucFirst)(propertyType)}: ${propertyName}`;
267
- }
268
- }
269
- else {
270
- propertyTracker.set(propertyName, propertyType);
271
- }
272
- switch (propertyType) {
273
- case 'url':
274
- return outputPropertyName + " { type base default }";
275
- case 'content': {
276
- const pick = (propertyItemConfig?.allowedTypes ?? []);
277
- if (pick.length == 0) {
278
- return outputPropertyName + ` {
279
- ...IContentData
280
- ...BlockData
281
- ...ComponentData
282
- }`;
283
- }
284
- else {
285
- return outputPropertyName + ` {
286
- ...IContentData
287
- ${pick.map(x => {
288
- return `...${getSlugFromKey(x)}Data`;
289
- }).join("\n ")}
290
- }`;
291
- }
292
- }
293
- case 'richText':
294
- return outputPropertyName + " { json }";
295
- case 'component': {
296
- const dataType = propertyItemConfig?.contentType;
297
- if (!dataType)
298
- return null; // Skip this property if the contentType isn't set
299
- return outputPropertyName + ` { ...${dataType}PropertyData }`;
300
- }
301
- case 'link':
302
- return outputPropertyName + ` {
303
- title
304
- text
305
- target
306
- url {
307
- type
308
- base
309
- default
310
- }
311
- }`;
312
- case 'contentReference': {
313
- return outputPropertyName + ` {
314
- key
315
- url {
316
- type
317
- base
318
- default
319
- }
320
- item @depend(on: "ContentReference.item") {
321
- __typename
322
- ...CmpImageAssetInfo
323
- ...CmpVideoAssetInfo
324
- }
325
- }`;
326
- }
327
- default:
328
- return outputPropertyName;
329
- }
330
- }
331
71
  exports.default = ContentTypeLoader;
332
72
  //# sourceMappingURL=contenttype-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contenttype-loader.js","sourceRoot":"","sources":["../src/contenttype-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,oDAgBC;AAED,oDAUC;AAOD,oCAEC;AACD,oDAEC;AAED,sCAWC;AAED,0CAEC;AAaD,sDAsCC;AAED,sCAwCC;AAQD,0EAcC;AAED,wCAKC;AAQD,sCAwBC;AAED,sCAuEC;AAzUD,qCAA+B;AAC/B,+CAAgC;AAEhC,mCAAmD;AAEnD,iDAAgC;AAUhC,MAAM,iBAAiB,GAAmB,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE;IACtE,MAAM,UAAU,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAA;IACpD,IAAI,CAAC,UAAU;QACb,OAAO,SAAS,CAAA;IAElB,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,UAAU,CAAA;IAE9G,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,CAAA;IAChE,IAAI,CAAC,WAAW;QACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,mBAAmB,CAAC,CAAA;IAEtE,IAAI,WAAW,CAAC,QAAQ,KAAK,QAAQ;QACnC,MAAM,IAAI,KAAK,CAAC,gDAAgD,QAAQ,iBAAiB,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAA;IAElH,MAAM,MAAM,GAAG,UAAU,KAAK,UAAU,CAAC,CAAC;QACxC,aAAa,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;QACjE,aAAa,CAAC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CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAAC,CAAC;YAC7F,SAAS,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,EAAE,gBAAgB,CAAC,CAAA;IAChF,CAAC;IAED,OAAO,MAAM,CAAC,CAAC,CAAC;QACd,QAAQ,EAAE,IAAA,eAAK,EAAC,MAAM,CAAC;QACvB,QAAQ,EAAE,WAAW;QACrB,IAAI,EAAE,WAAW;QACjB,MAAM;KACP,CAAC,CAAC,CAAC,SAAS,CAAA;AACf,CAAC,CAAA;AAGD,kBAAe,iBAAiB,CAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Tracker for all properties, indexed by property name, then type
3
+ * for a list of all ContentTypes. This uses a lock file to remember
4
+ * any collision resolutions done by the code generation.
5
+ */
6
+ export declare class PropertyCollisionTracker extends Map<string, string> {
7
+ private _cwd;
8
+ private _ready;
9
+ set cwd(newValue: string | undefined);
10
+ get cwd(): string | undefined;
11
+ constructor(cwd?: string);
12
+ private ensureReady;
13
+ private updateLock;
14
+ private readLock;
15
+ private isMapData;
16
+ has(key: string): boolean;
17
+ set(key: string, value: string): this;
18
+ get(key: string): string | undefined;
19
+ delete(key: string): boolean;
20
+ clear(): void;
21
+ }
22
+ export default PropertyCollisionTracker;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PropertyCollisionTracker = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ /**
10
+ * Tracker for all properties, indexed by property name, then type
11
+ * for a list of all ContentTypes. This uses a lock file to remember
12
+ * any collision resolutions done by the code generation.
13
+ */
14
+ class PropertyCollisionTracker extends Map {
15
+ set cwd(newValue) {
16
+ if (newValue !== this._cwd) {
17
+ this._cwd = newValue;
18
+ super.clear();
19
+ if (newValue === undefined) {
20
+ this._ready = false;
21
+ return;
22
+ }
23
+ this.readLock();
24
+ this._ready = true;
25
+ }
26
+ }
27
+ get cwd() {
28
+ return this._cwd;
29
+ }
30
+ constructor(cwd) {
31
+ super();
32
+ this._ready = false;
33
+ this.cwd = cwd;
34
+ }
35
+ ensureReady() {
36
+ if (!this._ready)
37
+ throw new Error("NOT READY");
38
+ }
39
+ updateLock() {
40
+ if (!this._cwd)
41
+ throw new Error("Working directory unknown");
42
+ const file = node_path_1.default.join(this._cwd, '.opti-props.lock');
43
+ const data = [];
44
+ for (const [entryKey, entryValue] of super.entries())
45
+ data.push({ propertyName: entryKey, propertyType: entryValue });
46
+ const raw = JSON.stringify(data, undefined, ' ');
47
+ node_fs_1.default.writeFileSync(file, raw, { encoding: 'utf-8' });
48
+ }
49
+ readLock() {
50
+ try {
51
+ if (!this._cwd)
52
+ throw new Error("Working directory unknown");
53
+ const file = node_path_1.default.join(this._cwd, '.opti-props.lock');
54
+ const raw = node_fs_1.default.readFileSync(file, { encoding: 'utf-8' });
55
+ const data = raw.length > 0 ? JSON.parse(raw) : [];
56
+ if (!Array.isArray(data))
57
+ throw new Error(`Invalid lock file at ${file}`);
58
+ for (const itm of data.filter(this.isMapData))
59
+ super.set(itm.propertyName, itm.propertyType);
60
+ }
61
+ catch (e) {
62
+ if (e.code === 'ENOENT')
63
+ return [];
64
+ throw e;
65
+ }
66
+ }
67
+ isMapData(v) {
68
+ if (typeof (v) !== 'object' || v === null)
69
+ return false;
70
+ return typeof (v.propertyName) === 'string' && typeof (v.propertyType) === 'string';
71
+ }
72
+ has(key) {
73
+ this.ensureReady();
74
+ return super.has(key);
75
+ }
76
+ set(key, value) {
77
+ this.ensureReady();
78
+ const cv = super.get(key);
79
+ if (cv !== value) {
80
+ super.set(key, value);
81
+ this.updateLock();
82
+ }
83
+ return this;
84
+ }
85
+ get(key) {
86
+ this.ensureReady();
87
+ return super.get(key);
88
+ }
89
+ delete(key) {
90
+ this.ensureReady();
91
+ const res = super.delete(key);
92
+ this.updateLock();
93
+ return res;
94
+ }
95
+ clear() {
96
+ this.ensureReady();
97
+ super.clear();
98
+ this.updateLock();
99
+ }
100
+ }
101
+ exports.PropertyCollisionTracker = PropertyCollisionTracker;
102
+ exports.default = PropertyCollisionTracker;
103
+ //# sourceMappingURL=collision-tracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collision-tracker.js","sourceRoot":"","sources":["../../src/generator/collision-tracker.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,sDAAwB;AAExB;;;;GAIG;AACH,MAAa,wBAAyB,SAAQ,GAAkB;IAI9D,IAAW,GAAG,CAAC,QAA4B;QAEzC,IAAI,QAAQ,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YAC3B,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAA;YACpB,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;gBACpB,OAAM;YACR,CAAC;YAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;IAED,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED,YAAmB,GAAY;QAE7B,KAAK,EAAE,CAAA;QAvBD,WAAM,GAAY,KAAK,CAAC;QAwB9B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAEO,WAAW;QAEjB,IAAI,CAAC,IAAI,CAAC,MAAM;YACd,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAA;IAChC,CAAC;IAEO,UAAU;QAEhB,IAAI,CAAC,IAAI,CAAC,IAAI;YACZ,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Z,CAAC;IAED,KAAK;QACH,IAAI,CAAC,WAAW,EAAE,CAAA;QAClB,KAAK,CAAC,KAAK,EAAE,CAAA;QACb,IAAI,CAAC,UAAU,EAAE,CAAA;IACnB,CAAC;CACF;AAzGD,4DAyGC;AAED,kBAAe,wBAAwB,CAAA"}
@@ -0,0 +1,77 @@
1
+ import { type IntegrationApi } from '@remkoj/optimizely-cms-api';
2
+ /**
3
+ * Generate GraphQL fragments and queries for Optimizely Graph,
4
+ * based upon the content type definitions within an Optimizely
5
+ * CMS instance.
6
+ */
7
+ export declare class DocumentGenerator {
8
+ protected _allContentTypes: Map<string, IntegrationApi.ContentType>;
9
+ constructor(allContentTypes?: Map<string, IntegrationApi.ContentType>);
10
+ /**
11
+ * Get the Graph Type for the Content Type, this imitates the logic
12
+ * within Optimizely CMS to transform a ContentType key into a type
13
+ * within Optimizely Graph.
14
+ *
15
+ * @param contentType
16
+ * @returns
17
+ */
18
+ getGraphType(contentType: IntegrationApi.ContentType | string): string;
19
+ /**
20
+ * Get the Graph Type for the Content Type, when it's used as a property,
21
+ * this imitates the logic within Optimizely CMS to transform a ContentType
22
+ * key into a type within Optimizely Graph.
23
+ *
24
+ * @param contentType
25
+ * @returns
26
+ */
27
+ getGraphPropertyType(contentType: IntegrationApi.ContentType | string): string;
28
+ /**
29
+ * Retrieve the default name for the data query for the given content type
30
+ *
31
+ * @param contentType
32
+ * @returns
33
+ */
34
+ getDefaultQueryName(contentType: IntegrationApi.ContentType | string): string;
35
+ /**
36
+ * Retrieve the default name for the data fragment for the given content type
37
+ *
38
+ * @param contentType
39
+ * @returns
40
+ */
41
+ getDefaultFragmentName(contentType: IntegrationApi.ContentType | string): string;
42
+ /**
43
+ * Retrieve the default name for the fragment when the content type is used as
44
+ * property
45
+ *
46
+ * @param contentType
47
+ * @returns
48
+ */
49
+ getDefaultPropertyFragmentName(contentType: IntegrationApi.ContentType | string): string;
50
+ private getSlugFromKey;
51
+ /**
52
+ * Build the GraphQL fragment that is used as injection target
53
+ *
54
+ * @param injectionTarget
55
+ * @returns
56
+ */
57
+ buildInjectionTarget(injectionTarget: string): string;
58
+ /**
59
+ * Build a query to retrieve the data for a specific content type by identifier
60
+ *
61
+ * @param contentType
62
+ * @param queryName
63
+ * @param propertyTracker
64
+ * @returns
65
+ */
66
+ buildGetQuery(contentType: IntegrationApi.ContentType, queryName?: string | ((defaultName: string) => string), propertyTracker?: Map<string, string>): string;
67
+ buildFragment(contentType: IntegrationApi.ContentType, fragmentName?: string | ((defaultName: string) => string), forProperty?: boolean, propertyTracker?: Map<string, string>): string;
68
+ /**
69
+ * Retrieve a list of component keys that are referenced as property by this type
70
+ *
71
+ * @param contentType
72
+ * @returns
73
+ */
74
+ static getReferencedPropertyComponents(contentType: IntegrationApi.ContentType): string[];
75
+ protected buildProperty(propertyName: string, propertyConfig?: IntegrationApi.ContentTypeProperty, propertyTracker?: Map<string, string>): string | null;
76
+ protected getTypeKeysFor(contentTypeRestriction: string): string | string[];
77
+ }