@remkoj/optimizely-graph-functions 6.0.0-pre9 → 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.
- package/README.md +60 -14
- package/dist/_transform/handleDependDirective.d.ts +11 -0
- package/dist/_transform/handleDependDirective.js +128 -0
- package/dist/_transform/handleDependDirective.js.map +1 -0
- package/dist/_transform/injectComponentDocuments.d.ts +3 -0
- package/dist/_transform/injectComponentDocuments.js +79 -24
- package/dist/_transform/injectComponentDocuments.js.map +1 -1
- package/dist/_transform/injectPageQueries.d.ts +1 -0
- package/dist/_transform/injectPageQueries.js +40 -7
- package/dist/_transform/injectPageQueries.js.map +1 -1
- package/dist/_transform/injectSectionQueries.d.ts +1 -0
- package/dist/_transform/injectSectionQueries.js +64 -17
- package/dist/_transform/injectSectionQueries.js.map +1 -1
- package/dist/_transform/normalizeFragmentNames.js +2 -0
- package/dist/_transform/normalizeFragmentNames.js.map +1 -1
- package/dist/_transform/performInjections.js +2 -35
- package/dist/_transform/performInjections.js.map +1 -1
- package/dist/cms/index.d.ts +4 -10
- package/dist/cms/index.js +57 -24
- package/dist/cms/index.js.map +1 -1
- package/dist/contenttype-loader.d.ts +1 -48
- package/dist/contenttype-loader.js +21 -286
- package/dist/contenttype-loader.js.map +1 -1
- package/dist/documents/fragments.cms13.js +77 -13
- package/dist/documents/fragments.cms13.js.map +1 -1
- package/dist/generator/collision-tracker.d.ts +22 -0
- package/dist/generator/collision-tracker.js +103 -0
- package/dist/generator/collision-tracker.js.map +1 -0
- package/dist/generator/generator.d.ts +77 -0
- package/dist/generator/generator.js +272 -0
- package/dist/generator/generator.js.map +1 -0
- package/dist/generator/index.d.ts +3 -0
- package/dist/generator/index.js +42 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/virtual-location.d.ts +41 -0
- package/dist/generator/virtual-location.js +139 -0
- package/dist/generator/virtual-location.js.map +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/preset.js +103 -38
- package/dist/preset.js.map +1 -1
- package/dist/transform.d.ts +4 -3
- package/dist/transform.js +8 -1
- package/dist/transform.js.map +1 -1
- package/package.json +20 -16
|
@@ -33,36 +33,34 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
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
|
|
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
|
-
|
|
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
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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,268 +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
|
-
const pick = (propertyItemConfig?.allowedTypes ?? []).filter(x => !x.startsWith('_'));
|
|
314
|
-
const hide = (propertyItemConfig?.restrictedTypes ?? []).filter(x => !x.startsWith('_'));
|
|
315
|
-
const pickAll = pick.length == 0 || (pick.length == 1 && pick.at(0) === '*');
|
|
316
|
-
if (hide.length > 0)
|
|
317
|
-
console.log("Negative filtering isn't reflected in the Graph Queries");
|
|
318
|
-
//const fragments = pick.map(x => "..." + x + "Data")
|
|
319
|
-
/*
|
|
320
|
-
item {
|
|
321
|
-
...IContentData${pickAll ? '\n ...BlockData' : '\n ' + fragments.join('\n ')}
|
|
322
|
-
}*/
|
|
323
|
-
return outputPropertyName + ` {
|
|
324
|
-
key
|
|
325
|
-
url {
|
|
326
|
-
type
|
|
327
|
-
base
|
|
328
|
-
default
|
|
329
|
-
}
|
|
330
|
-
}`;
|
|
331
|
-
}
|
|
332
|
-
default:
|
|
333
|
-
return outputPropertyName;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
71
|
exports.default = ContentTypeLoader;
|
|
337
72
|
//# sourceMappingURL=contenttype-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contenttype-loader.js","sourceRoot":"","sources":["../src/contenttype-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"contenttype-loader.js","sourceRoot":"","sources":["../src/contenttype-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAA+B;AAC/B,+CAAgC;AAEhC,2CAA0F;AAE1F,iDAAgC;AAWhC,MAAM,gBAAgB,GAA6B,IAAI,oCAAwB,EAAE,CAAA;AAEjF,MAAM,iBAAiB,GAAmB,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE;IACtE,gBAAgB,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;IAElC,MAAM,UAAU,GAAG,2BAAe,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;IACrD,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,CAAC;IAC/G,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;IACxD,MAAM,SAAS,GAAG,IAAI,6BAAiB,CAAC,eAAe,CAAC,CAAC;IAEzD,IAAI,MAAwB,CAAC;IAC7B,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,GAAG,SAAS,CAAC,oBAAoB,CAAC,IAAK,cAAe,EAAE,CAAC,CAAA;IACjE,CAAC;SAAM,CAAC;QACN,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QACjE,IAAI,CAAC,WAAW;YACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,cAAc,4BAA4B,QAAQ,GAAG,CAAC,CAAA;QAEhG,IAAI,WAAW,CAAC,QAAQ,KAAK,QAAQ;YACnC,MAAM,IAAI,KAAK,CAAC,gDAAgD,QAAQ,iBAAiB,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAA;QAElH,MAAM,GAAG,UAAU,KAAK,UAAU,CAAC,CAAC;YAClC,SAAS,CAAC,aAAa,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"}
|
|
@@ -76,10 +76,37 @@ exports.default = [
|
|
|
76
76
|
... on CompositionStructureNode {
|
|
77
77
|
nodes {
|
|
78
78
|
...CompositionNodeData
|
|
79
|
-
...CompositionStructureNode
|
|
80
|
-
|
|
79
|
+
... on CompositionStructureNode {
|
|
80
|
+
nodes {
|
|
81
|
+
...CompositionNodeData
|
|
82
|
+
... on CompositionStructureNode {
|
|
83
|
+
nodes {
|
|
84
|
+
...CompositionNodeData
|
|
85
|
+
... on CompositionComponentNode {
|
|
86
|
+
component {
|
|
87
|
+
...IContentData
|
|
88
|
+
...BlockData
|
|
89
|
+
...ElementData
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
... on CompositionStructureNode {
|
|
93
|
+
nodes {
|
|
94
|
+
...CompositionNodeData
|
|
95
|
+
... on CompositionComponentNode {
|
|
96
|
+
component {
|
|
97
|
+
...IContentData
|
|
98
|
+
...FormElementData
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
81
107
|
}
|
|
82
108
|
component {
|
|
109
|
+
...IContentData
|
|
83
110
|
...SectionData
|
|
84
111
|
}
|
|
85
112
|
}
|
|
@@ -91,20 +118,32 @@ exports.default = [
|
|
|
91
118
|
...CompositionNodeData
|
|
92
119
|
nodes {
|
|
93
120
|
...CompositionNodeData
|
|
94
|
-
... on CompositionComponentNode {
|
|
95
|
-
component {
|
|
96
|
-
...IContentData
|
|
97
|
-
...SectionElementData
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
121
|
... on CompositionStructureNode {
|
|
101
122
|
nodes {
|
|
102
123
|
...CompositionNodeData
|
|
103
|
-
...CompositionStructureNode
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
124
|
+
... on CompositionStructureNode {
|
|
125
|
+
nodes {
|
|
126
|
+
...CompositionNodeData
|
|
127
|
+
... on CompositionComponentNode {
|
|
128
|
+
component {
|
|
129
|
+
...IContentData
|
|
130
|
+
...BlockData
|
|
131
|
+
...ElementData
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
... on CompositionStructureNode {
|
|
135
|
+
nodes {
|
|
136
|
+
...CompositionNodeData
|
|
137
|
+
... on CompositionComponentNode {
|
|
138
|
+
component {
|
|
139
|
+
...IContentData
|
|
140
|
+
...FormElementData
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
108
147
|
}
|
|
109
148
|
}
|
|
110
149
|
}
|
|
@@ -145,6 +184,31 @@ exports.default = [
|
|
|
145
184
|
base
|
|
146
185
|
default
|
|
147
186
|
}
|
|
187
|
+
}`,
|
|
188
|
+
`fragment _CmpImageAssetInfo on cmp_PublicImageAsset {
|
|
189
|
+
__typename
|
|
190
|
+
Title
|
|
191
|
+
AltText
|
|
192
|
+
Width
|
|
193
|
+
Height
|
|
194
|
+
Url
|
|
195
|
+
Renditions {
|
|
196
|
+
Name
|
|
197
|
+
Width
|
|
198
|
+
Height
|
|
199
|
+
Url
|
|
200
|
+
}
|
|
201
|
+
}`,
|
|
202
|
+
`fragment _CmpVideoAssetInfo on cmp_PublicVideoAsset {
|
|
203
|
+
Title
|
|
204
|
+
AltText
|
|
205
|
+
Url
|
|
206
|
+
Renditions {
|
|
207
|
+
Name
|
|
208
|
+
Width
|
|
209
|
+
Height
|
|
210
|
+
Url
|
|
211
|
+
}
|
|
148
212
|
}`
|
|
149
213
|
];
|
|
150
214
|
//# sourceMappingURL=fragments.cms13.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fragments.cms13.js","sourceRoot":"","sources":["../../src/documents/fragments.cms13.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb;;;;;;;;;;;;;;;;;EAiBA;IACA;;;;;;;;;;;;;;EAcA;IACA;;;;EAIA;IACA;;;;;;;EAOA;IACA;;;;;;;;;;;EAWA;IACA;;EAEA;IACA
|
|
1
|
+
{"version":3,"file":"fragments.cms13.js","sourceRoot":"","sources":["../../src/documents/fragments.cms13.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb;;;;;;;;;;;;;;;;;EAiBA;IACA;;;;;;;;;;;;;;EAcA;IACA;;;;EAIA;IACA;;;;;;;EAOA;IACA;;;;;;;;;;;EAWA;IACA;;EAEA;IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkDA;IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCA;IACA;;;;;;EAMA;IACA;;;;;;;EAOA;IACA;;;;;;;;;;EAUA;IACA;;;;;;;;;EASA;IACF;;;;;;;;;;;;;EAaE;IACF;;;;;;;;;;EAUE;CACD,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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