@remkoj/optimizely-graph-functions 6.0.0-pre1 → 6.0.0-pre10
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/LICENSE +12 -12
- package/dist/_transform/cleanFragments.d.ts +10 -0
- package/dist/_transform/cleanFragments.js +39 -0
- package/dist/_transform/cleanFragments.js.map +1 -0
- package/dist/_transform/cleanSpreads.d.ts +10 -0
- package/dist/_transform/cleanSpreads.js +36 -0
- package/dist/_transform/cleanSpreads.js.map +1 -0
- package/dist/_transform/injectComponentDocuments.d.ts +13 -0
- package/dist/_transform/injectComponentDocuments.js +122 -0
- package/dist/_transform/injectComponentDocuments.js.map +1 -0
- package/dist/_transform/injectPageQueries.d.ts +4 -0
- package/dist/_transform/injectPageQueries.js +81 -0
- package/dist/_transform/injectPageQueries.js.map +1 -0
- package/dist/_transform/injectSectionQueries.d.ts +4 -0
- package/dist/_transform/injectSectionQueries.js +81 -0
- package/dist/_transform/injectSectionQueries.js.map +1 -0
- package/dist/_transform/normalizeFragmentNames.d.ts +12 -0
- package/dist/_transform/normalizeFragmentNames.js +75 -0
- package/dist/_transform/normalizeFragmentNames.js.map +1 -0
- package/dist/_transform/normalizeQueryNames.d.ts +12 -0
- package/dist/_transform/normalizeQueryNames.js +83 -0
- package/dist/_transform/normalizeQueryNames.js.map +1 -0
- package/dist/_transform/options.d.ts +3 -0
- package/dist/_transform/options.js +21 -0
- package/dist/_transform/options.js.map +1 -0
- package/dist/_transform/performInjections.d.ts +24 -0
- package/dist/_transform/performInjections.js +225 -0
- package/dist/_transform/performInjections.js.map +1 -0
- package/dist/_transform/tools.d.ts +34 -0
- package/dist/_transform/tools.js +103 -0
- package/dist/_transform/tools.js.map +1 -0
- package/dist/cms/index.d.ts +17 -0
- package/dist/cms/index.js +88 -0
- package/dist/cms/index.js.map +1 -0
- package/dist/contenttype-loader.d.ts +58 -0
- package/dist/contenttype-loader.js +332 -0
- package/dist/contenttype-loader.js.map +1 -0
- package/dist/document-ast-plugin.d.ts +1 -0
- package/dist/document-ast-plugin.js +15 -0
- package/dist/document-ast-plugin.js.map +1 -0
- package/dist/documents/fragments.cms13.js +148 -39
- package/dist/documents/fragments.cms13.js.map +1 -1
- package/dist/documents/queries.cms13.js +9 -3
- package/dist/documents/queries.cms13.js.map +1 -1
- package/dist/embedded-loader.js +31 -16
- package/dist/embedded-loader.js.map +1 -1
- package/dist/index.d.ts +2 -5
- package/dist/index.js.map +1 -1
- package/dist/preset.d.ts +2 -4
- package/dist/preset.js +21 -45
- package/dist/preset.js.map +1 -1
- package/dist/tools.d.ts +4 -0
- package/dist/tools.js +20 -0
- package/dist/tools.js.map +1 -0
- package/dist/transform.d.ts +11 -1
- package/dist/transform.js +41 -58
- package/dist/transform.js.map +1 -1
- package/dist/types.d.ts +34 -0
- package/package.json +20 -13
|
@@ -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,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O,IAAI,CAAA;wBACb,CAAC;wBAED,eAAe;wBACf,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;4BAC3C,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;gCAC9B,OAAO,CAAC,GAAG,CAAC,+BAA+B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,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,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>;
|
|
@@ -0,0 +1,225 @@
|
|
|
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.performInjections = performInjections;
|
|
37
|
+
exports.getInjectionsByFile = getInjectionsByFile;
|
|
38
|
+
exports.getInjectionsByFragmentName = getInjectionsByFragmentName;
|
|
39
|
+
exports.getComponentFragments = getComponentFragments;
|
|
40
|
+
const graphql_1 = require("graphql");
|
|
41
|
+
const QueryGen = __importStar(require("../contenttype-loader"));
|
|
42
|
+
const options_1 = require("./options");
|
|
43
|
+
/**
|
|
44
|
+
* Check all fragments within the project and ensure that there's at least a fragment for every
|
|
45
|
+
* content type defined in Optimizely CMS. This assumes that when overriding the fragments the
|
|
46
|
+
* project will ensure that the injections are correct.
|
|
47
|
+
*
|
|
48
|
+
* @param files
|
|
49
|
+
* @param options
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
async function performInjections(files, options) {
|
|
53
|
+
if (options.presetConfig.verbose)
|
|
54
|
+
console.log(`✨ [Optimizely] Running injections into targeted components`);
|
|
55
|
+
// Create context
|
|
56
|
+
const config = { ...options_1.defaultOptions, ...(0, options_1.pickTransformOptions)(options.presetConfig) };
|
|
57
|
+
const componentFragments = await getComponentFragments(files, config);
|
|
58
|
+
// Get the names we actually need to inject into, and return when none are present
|
|
59
|
+
const intoNames = Array.from(componentFragments.keys());
|
|
60
|
+
if (intoNames.length == 0)
|
|
61
|
+
return files;
|
|
62
|
+
if (config.verbose)
|
|
63
|
+
intoNames.forEach(intoName => {
|
|
64
|
+
console.debug(` - Will update queries & fragments using the fragment ${intoName} to also use the fragments:\n - ${(componentFragments.get(intoName) ?? []).map(x => `${x.name} (${x.location})`).join("\n - ")}`);
|
|
65
|
+
});
|
|
66
|
+
function isTargetedSpread(node) {
|
|
67
|
+
return node.kind == graphql_1.Kind.FRAGMENT_SPREAD && intoNames.includes(node.name.value);
|
|
68
|
+
}
|
|
69
|
+
// Run the actual transformation
|
|
70
|
+
const transformedFiles = files.map(file => {
|
|
71
|
+
const document = file.document ? (0, graphql_1.visit)(file.document, {
|
|
72
|
+
// Replace the fragment occurances
|
|
73
|
+
SelectionSet: {
|
|
74
|
+
leave(node, key, parent, path, ancestors) {
|
|
75
|
+
// Get the parent name
|
|
76
|
+
const parentName = [...ancestors].reverse().filter(isFragmentOrOperation).at(0)?.name?.value;
|
|
77
|
+
// Get the sections that need to be added here, return if none found
|
|
78
|
+
const sectionsToAdd = node.selections.filter(isTargetedSpread).map(x => x.name.value);
|
|
79
|
+
if (sectionsToAdd.length == 0)
|
|
80
|
+
return;
|
|
81
|
+
// Debug output
|
|
82
|
+
if (config.verbose)
|
|
83
|
+
console.debug(` - Identified usage of fragment(s) ${sectionsToAdd.join(', ')} in ${parentName} (${file.location}), starting injection procedure`);
|
|
84
|
+
// Create context
|
|
85
|
+
const newSelections = [];
|
|
86
|
+
const existingSpreads = node.selections.filter(x => x.kind === graphql_1.Kind.FRAGMENT_SPREAD).map(x => x.name.value);
|
|
87
|
+
// Loop over the sections that must be processed
|
|
88
|
+
sectionsToAdd.forEach(sectionName => {
|
|
89
|
+
// Loop over the contents of each section
|
|
90
|
+
const addedSelections = (componentFragments.get(sectionName) ?? []).map(fragment => {
|
|
91
|
+
// Check if the spread already exist, and skip if it does exist
|
|
92
|
+
if (existingSpreads.includes(fragment.name))
|
|
93
|
+
return undefined;
|
|
94
|
+
// Add the current fragment to the list to prevent issues, with the same fragment being in multiple sections
|
|
95
|
+
existingSpreads.push(fragment.name);
|
|
96
|
+
return {
|
|
97
|
+
kind: graphql_1.Kind.FRAGMENT_SPREAD,
|
|
98
|
+
directives: [],
|
|
99
|
+
name: {
|
|
100
|
+
kind: graphql_1.Kind.NAME,
|
|
101
|
+
value: fragment.name
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}).filter(isNotNullOrUndefined);
|
|
105
|
+
// Chick the fragments we've added
|
|
106
|
+
if (addedSelections.length > 0) {
|
|
107
|
+
if (config.verbose)
|
|
108
|
+
console.log(` - Added fragments ${addedSelections.map(a => a.name.value).join(', ')} adjacent to ${sectionName}`);
|
|
109
|
+
newSelections.push(...addedSelections);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
// If there're no changes, just return the old fragment
|
|
113
|
+
if (newSelections.length == 0)
|
|
114
|
+
return;
|
|
115
|
+
// Build the new SelectionSet
|
|
116
|
+
const newNode = {
|
|
117
|
+
...node,
|
|
118
|
+
selections: [...node.selections, ...newSelections]
|
|
119
|
+
};
|
|
120
|
+
// If cleanup is disabled just return the new node
|
|
121
|
+
if (!config.cleanup || (Array.isArray(config.cleanup) && config.cleanup.length === 0))
|
|
122
|
+
return newNode;
|
|
123
|
+
// Filter the selections if cleanup is enabled
|
|
124
|
+
newNode.selections = newNode.selections.filter(selection => {
|
|
125
|
+
if (selection.kind !== graphql_1.Kind.FRAGMENT_SPREAD)
|
|
126
|
+
return true; // Allow all non-fragment spreads
|
|
127
|
+
if (config.cleanup && !Array.isArray(config.cleanup) && (sectionsToAdd.includes(selection.name.value) || ['PageData', 'BlockData'].includes(selection.name.value)))
|
|
128
|
+
return false; // Remove matching sections and PageData & BlockData, for any truethy, non-array value for cleanup
|
|
129
|
+
if (Array.isArray(config.cleanup) && config.cleanup.includes(selection.name.value))
|
|
130
|
+
return false; // Remove all explicitly listed fragment spreads
|
|
131
|
+
return true;
|
|
132
|
+
});
|
|
133
|
+
return newNode;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}) : undefined;
|
|
137
|
+
return {
|
|
138
|
+
...file,
|
|
139
|
+
document: document,
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
return transformedFiles;
|
|
143
|
+
}
|
|
144
|
+
exports.default = performInjections;
|
|
145
|
+
function getInjectionsByFile(file, injections) {
|
|
146
|
+
const applicableInjections = injections.filter(injection => !injection.pathRegex || (new RegExp(injection.pathRegex)).test(file.location ?? ""));
|
|
147
|
+
return applicableInjections ?? [];
|
|
148
|
+
}
|
|
149
|
+
function getInjectionsByFragmentName(fragmentName, injections) {
|
|
150
|
+
const matchingInjections = injections.filter(injection => !injection.nameRegex || (new RegExp(injection.nameRegex)).test(fragmentName));
|
|
151
|
+
return matchingInjections ?? [];
|
|
152
|
+
}
|
|
153
|
+
async function getComponentFragments(files, { injections, verbose }) {
|
|
154
|
+
// First process files based upon injection configuration
|
|
155
|
+
const newOutput = files.reduce((componentFragments, file) => {
|
|
156
|
+
if (!file.document)
|
|
157
|
+
return componentFragments; /// Stop if we don't have a document
|
|
158
|
+
// Check if this an internally generated fragment
|
|
159
|
+
const vLocInfo = file.location ? QueryGen.parseVirtualLocation(file.location) : undefined;
|
|
160
|
+
if (vLocInfo) {
|
|
161
|
+
// Only process the Virtual Location if it's for a non-property fragment with at least one injection target
|
|
162
|
+
if (vLocInfo.type !== 'fragment' || vLocInfo.forProperty || vLocInfo.injectionTargets.length == 0)
|
|
163
|
+
return componentFragments;
|
|
164
|
+
// Extract needed properties from the parsed URL
|
|
165
|
+
const { injectionTargets: targets, contentTypeKey } = vLocInfo;
|
|
166
|
+
// Walk the document to process all fragments in it
|
|
167
|
+
(0, graphql_1.visit)(file.document, {
|
|
168
|
+
FragmentDefinition: {
|
|
169
|
+
enter(node) {
|
|
170
|
+
targets.forEach(target => {
|
|
171
|
+
const currentFragments = (componentFragments.get(target) || []);
|
|
172
|
+
if (!currentFragments.some(cf => cf.name == node.name.value)) {
|
|
173
|
+
currentFragments.push({
|
|
174
|
+
name: node.name.value,
|
|
175
|
+
contentType: contentTypeKey,
|
|
176
|
+
definition: node,
|
|
177
|
+
location: file.location
|
|
178
|
+
});
|
|
179
|
+
componentFragments.set(target, currentFragments);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
return componentFragments;
|
|
186
|
+
}
|
|
187
|
+
// Check if this file matches an injection
|
|
188
|
+
const applicableInjections = getInjectionsByFile(file, injections);
|
|
189
|
+
if (applicableInjections.length == 0)
|
|
190
|
+
return componentFragments; // Stop if we don't have a file or no injections for this file
|
|
191
|
+
// Process the document
|
|
192
|
+
(0, graphql_1.visit)(file.document, {
|
|
193
|
+
FragmentDefinition: {
|
|
194
|
+
enter(node) {
|
|
195
|
+
const matchingInjections = getInjectionsByFragmentName(node.name.value, applicableInjections);
|
|
196
|
+
matchingInjections.forEach(injection => {
|
|
197
|
+
const contentTypeKey = node.typeCondition.name.value;
|
|
198
|
+
const target = injection.into;
|
|
199
|
+
const currentFragments = (componentFragments.get(target) || []);
|
|
200
|
+
if (!currentFragments.some(cf => cf.name == node.name.value)) {
|
|
201
|
+
currentFragments.push({
|
|
202
|
+
name: node.name.value,
|
|
203
|
+
contentType: contentTypeKey,
|
|
204
|
+
definition: node,
|
|
205
|
+
location: file.location
|
|
206
|
+
});
|
|
207
|
+
componentFragments.set(target, currentFragments);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return componentFragments;
|
|
214
|
+
}, new Map());
|
|
215
|
+
return newOutput;
|
|
216
|
+
}
|
|
217
|
+
function isNotNullOrUndefined(toTest) {
|
|
218
|
+
return toTest !== null && toTest !== undefined;
|
|
219
|
+
}
|
|
220
|
+
function isFragmentOrOperation(x) {
|
|
221
|
+
if (Array.isArray(x) || x == undefined || x == null)
|
|
222
|
+
return false;
|
|
223
|
+
return x.kind == graphql_1.Kind.FRAGMENT_DEFINITION || x.kind == graphql_1.Kind.OPERATION_DEFINITION;
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=performInjections.js.map
|
|
@@ -0,0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 +1,34 @@
|
|
|
1
|
+
import type { Types } from '@graphql-codegen/plugin-helpers';
|
|
2
|
+
import { type DocumentNode } from 'graphql';
|
|
3
|
+
export type DocumentSet = Types.DocumentFile[];
|
|
4
|
+
export type FragmentMetaData = {
|
|
5
|
+
fragmentName: string;
|
|
6
|
+
targetType: string;
|
|
7
|
+
location?: string;
|
|
8
|
+
};
|
|
9
|
+
export type FragmentMetaDataList = Array<FragmentMetaData> & {
|
|
10
|
+
get(targetType: string): FragmentMetaData | undefined;
|
|
11
|
+
has(targetType: string): boolean;
|
|
12
|
+
hasForType(targetType: string): boolean;
|
|
13
|
+
forType(targetType: string): FragmentMetaDataList;
|
|
14
|
+
};
|
|
15
|
+
export declare function getAllFragments(files: DocumentSet): FragmentMetaDataList;
|
|
16
|
+
export type QueryMetaData = {
|
|
17
|
+
queryName: string;
|
|
18
|
+
targetTypes: Array<string>;
|
|
19
|
+
location?: string;
|
|
20
|
+
};
|
|
21
|
+
export type QueryMetaDataList = Array<QueryMetaData> & {
|
|
22
|
+
get(queryName: string): QueryMetaData | undefined;
|
|
23
|
+
has(queryName: string): boolean;
|
|
24
|
+
hasForType(targetType: string): boolean;
|
|
25
|
+
forType(targetType: string): QueryMetaDataList;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Retrieve the metadata from all queries that are defined in the provided DocumentSet
|
|
29
|
+
*
|
|
30
|
+
* @param files
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export declare function getAllQueries(files: DocumentSet): QueryMetaDataList;
|
|
34
|
+
export declare function getAllTypeNames(schema: DocumentNode): string[];
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllFragments = getAllFragments;
|
|
4
|
+
exports.getAllQueries = getAllQueries;
|
|
5
|
+
exports.getAllTypeNames = getAllTypeNames;
|
|
6
|
+
const graphql_1 = require("graphql");
|
|
7
|
+
function createFragmentMetaDataList(initialItems) {
|
|
8
|
+
const list = [...(initialItems || [])];
|
|
9
|
+
list.hasForType = (function (targetType) {
|
|
10
|
+
return this.some(x => x.targetType === targetType);
|
|
11
|
+
}).bind(list);
|
|
12
|
+
list.forType = (function (targetType) {
|
|
13
|
+
return createFragmentMetaDataList(this.filter(x => x.targetType === targetType));
|
|
14
|
+
}).bind(list);
|
|
15
|
+
list.get = (function (fragmentName) {
|
|
16
|
+
return this.find(x => x.fragmentName === fragmentName);
|
|
17
|
+
}).bind(list);
|
|
18
|
+
list.has = (function (fragmentName) {
|
|
19
|
+
return this.some(x => x.fragmentName === fragmentName);
|
|
20
|
+
}).bind(list);
|
|
21
|
+
return list;
|
|
22
|
+
}
|
|
23
|
+
function getAllFragments(files) {
|
|
24
|
+
const fragmentList = files.reduce((list, file) => {
|
|
25
|
+
if (file.document)
|
|
26
|
+
(0, graphql_1.visit)(file.document, {
|
|
27
|
+
FragmentDefinition: {
|
|
28
|
+
enter(node) {
|
|
29
|
+
list.push({
|
|
30
|
+
fragmentName: node.name.value,
|
|
31
|
+
targetType: node.typeCondition.name.value,
|
|
32
|
+
location: file.location
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return list;
|
|
38
|
+
}, []);
|
|
39
|
+
return createFragmentMetaDataList(fragmentList);
|
|
40
|
+
}
|
|
41
|
+
function createQueryMetaDataList(initialItems) {
|
|
42
|
+
const list = [...(initialItems || [])];
|
|
43
|
+
list.hasForType = (function (targetType) {
|
|
44
|
+
return this.some(x => x.targetTypes.includes(targetType));
|
|
45
|
+
}).bind(list);
|
|
46
|
+
list.forType = (function (targetType) {
|
|
47
|
+
return createQueryMetaDataList(this.filter(x => x.targetTypes.includes(targetType)));
|
|
48
|
+
}).bind(list);
|
|
49
|
+
list.get = (function (queryName) {
|
|
50
|
+
return this.find(x => x.queryName === queryName);
|
|
51
|
+
}).bind(list);
|
|
52
|
+
list.has = (function (queryName) {
|
|
53
|
+
return this.some(x => x.queryName === queryName);
|
|
54
|
+
}).bind(list);
|
|
55
|
+
return list;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Retrieve the metadata from all queries that are defined in the provided DocumentSet
|
|
59
|
+
*
|
|
60
|
+
* @param files
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
function getAllQueries(files) {
|
|
64
|
+
const queryList = files.reduce((list, file) => {
|
|
65
|
+
if (file?.document)
|
|
66
|
+
(0, graphql_1.visit)(file.document, {
|
|
67
|
+
OperationDefinition: {
|
|
68
|
+
enter(node) {
|
|
69
|
+
if (node.operation !== 'query')
|
|
70
|
+
return;
|
|
71
|
+
const queryName = node.name?.value;
|
|
72
|
+
if (!queryName)
|
|
73
|
+
return;
|
|
74
|
+
const metaData = {
|
|
75
|
+
queryName,
|
|
76
|
+
targetTypes: node.selectionSet.selections.filter(x => x.kind == 'Field').map(x => x.name.value),
|
|
77
|
+
location: file.location
|
|
78
|
+
};
|
|
79
|
+
list.push(metaData);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return list;
|
|
84
|
+
}, []);
|
|
85
|
+
return createQueryMetaDataList(queryList);
|
|
86
|
+
}
|
|
87
|
+
function getAllTypeNames(schema) {
|
|
88
|
+
const names = [];
|
|
89
|
+
(0, graphql_1.visit)(schema, {
|
|
90
|
+
ObjectTypeDefinition: {
|
|
91
|
+
enter(node) {
|
|
92
|
+
names.push(node.name.value);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
InterfaceTypeDefinition: {
|
|
96
|
+
enter(node) {
|
|
97
|
+
names.push(node.name.value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return names;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/_transform/tools.ts"],"names":[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AAC,MAAM,EAAE;QACZ,oBAAoB,EAAE;YACpB,KAAK,CAAC,IAAI;gBACR,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAC7B,CAAC;SACF;QACD,uBAAuB,EAAE;YACvB,KAAK,CAAC,IAAI;gBACR,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAC7B,CAAC;SACF;KACF,CAAC,CAAA;IACF,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IntegrationApi, CmsIntegrationApiClient, CmsIntegrationApiOptions } from "@remkoj/optimizely-cms-api";
|
|
2
|
+
export declare function contentTypeToFragmentName(contentType: IntegrationApi.ContentType, forProperty?: boolean): string | undefined;
|
|
3
|
+
export declare function fragmentNameToContentType(fragmentName: string): {
|
|
4
|
+
contentType: string;
|
|
5
|
+
baseType: string;
|
|
6
|
+
forProperty: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function getContentType(contentTypeKey: string, clientOrConfig?: CmsIntegrationApiClient | CmsIntegrationApiOptions): Promise<IntegrationApi.ContentType | undefined>;
|
|
9
|
+
export type ContentTypeFilter = (contentType: IntegrationApi.ContentType) => Promise<boolean> | boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieve all content types as an Async Generator, allowing processing of entries whilest they are being loaded from the CMS instance.
|
|
12
|
+
*
|
|
13
|
+
* @param clientOrConfig
|
|
14
|
+
* @param pageSize
|
|
15
|
+
* @param filter
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAllContentTypes(clientOrConfig?: CmsIntegrationApiClient | CmsIntegrationApiOptions, pageSize?: number, filter?: ContentTypeFilter): AsyncGenerator<IntegrationApi.ContentType>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contentTypeToFragmentName = contentTypeToFragmentName;
|
|
4
|
+
exports.fragmentNameToContentType = fragmentNameToContentType;
|
|
5
|
+
exports.getContentType = getContentType;
|
|
6
|
+
exports.getAllContentTypes = getAllContentTypes;
|
|
7
|
+
const optimizely_cms_api_1 = require("@remkoj/optimizely-cms-api");
|
|
8
|
+
const node_object_hash_1 = require("node-object-hash");
|
|
9
|
+
const tools_1 = require("../tools");
|
|
10
|
+
var hasher = (0, node_object_hash_1.hasher)({ sort: true, coerce: true });
|
|
11
|
+
const clientByHash = new Map();
|
|
12
|
+
function getClient(config) {
|
|
13
|
+
const configHash = hasher.hash(config ?? {});
|
|
14
|
+
let client = clientByHash.get(configHash);
|
|
15
|
+
if (!client) {
|
|
16
|
+
client = new Promise((resolve, reject) => {
|
|
17
|
+
const cms_client = (0, optimizely_cms_api_1.createClient)(config);
|
|
18
|
+
cms_client.getInstanceInfo().then(() => {
|
|
19
|
+
resolve(cms_client);
|
|
20
|
+
}).catch(e => {
|
|
21
|
+
reject(e);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
clientByHash.set(configHash, client);
|
|
25
|
+
}
|
|
26
|
+
return client;
|
|
27
|
+
}
|
|
28
|
+
function contentTypeToFragmentName(contentType, forProperty = false) {
|
|
29
|
+
const contentTypeKey = contentType.key;
|
|
30
|
+
const contentTypeBase = forProperty ? (0, tools_1.ucFirst)((0, tools_1.trimStart)(contentType.baseType ?? '', '_')) : 'Property';
|
|
31
|
+
if (!contentTypeKey)
|
|
32
|
+
return undefined;
|
|
33
|
+
return contentTypeKey + '_' + contentTypeBase + 'Data';
|
|
34
|
+
}
|
|
35
|
+
function fragmentNameToContentType(fragmentName) {
|
|
36
|
+
const result = fragmentName.match(/^([A-Za-z][_0-9A-Za-z]+?)(_([A-Za-z][0-9A-Za-z]+)|_){0,1}Data$/);
|
|
37
|
+
const contentTypeKey = result?.at(1)?.endsWith('Property') ? result.at(1)?.substring(0, Math.max((result.at(1)?.length ?? 0) - 8, 0)) : result?.at(1);
|
|
38
|
+
const contentTypeBase = (result?.at(3) === 'Property' ? 'Component' : result?.at(3)) ?? 'Component';
|
|
39
|
+
if (!contentTypeKey)
|
|
40
|
+
throw new Error("Unable to determine ContentType from fragment: " + fragmentName);
|
|
41
|
+
const forProperty = (result?.at(3) === 'Property' || (!result?.at(3) && result?.at(1)?.endsWith('Property'))) || false;
|
|
42
|
+
return {
|
|
43
|
+
contentType: contentTypeKey,
|
|
44
|
+
baseType: '_' + (0, tools_1.lcFirst)(contentTypeBase),
|
|
45
|
+
forProperty
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async function getContentType(contentTypeKey, clientOrConfig) {
|
|
49
|
+
const client = (0, optimizely_cms_api_1.isClientInstance)(clientOrConfig) ? clientOrConfig : await getClient(clientOrConfig);
|
|
50
|
+
const contentType = await client.contentTypesGet({ path: { key: contentTypeKey } }).catch(() => undefined);
|
|
51
|
+
return contentType;
|
|
52
|
+
}
|
|
53
|
+
const DefaultContentTypeFilter = () => true;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieve all content types as an Async Generator, allowing processing of entries whilest they are being loaded from the CMS instance.
|
|
56
|
+
*
|
|
57
|
+
* @param clientOrConfig
|
|
58
|
+
* @param pageSize
|
|
59
|
+
* @param filter
|
|
60
|
+
*/
|
|
61
|
+
async function* getAllContentTypes(clientOrConfig, pageSize = 25, filter = DefaultContentTypeFilter) {
|
|
62
|
+
const client = (0, optimizely_cms_api_1.isClientInstance)(clientOrConfig) ? clientOrConfig : await getClient(clientOrConfig);
|
|
63
|
+
let requestPageSize = pageSize;
|
|
64
|
+
let requestPageIndex = 0;
|
|
65
|
+
let totalItemCount = 0;
|
|
66
|
+
let totalPages = 0;
|
|
67
|
+
do {
|
|
68
|
+
const resultsPage = await client.contentTypesList({ query: { pageIndex: requestPageIndex, pageSize: requestPageSize } }).catch((_) => {
|
|
69
|
+
return {
|
|
70
|
+
items: [],
|
|
71
|
+
totalItemCount: 0,
|
|
72
|
+
pageIndex: requestPageIndex,
|
|
73
|
+
pageSize: requestPageSize
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
// Calculate fields for next page
|
|
77
|
+
totalItemCount = resultsPage.totalItemCount ?? 0;
|
|
78
|
+
requestPageSize = resultsPage.pageSize ?? 0;
|
|
79
|
+
requestPageIndex = (resultsPage.pageIndex ?? 0) + 1;
|
|
80
|
+
totalPages = resultsPage.totalItemCount && resultsPage.pageSize ? Math.ceil(totalItemCount / requestPageSize) : 0;
|
|
81
|
+
// Yield items
|
|
82
|
+
for (const contentType of (resultsPage.items ?? [])) {
|
|
83
|
+
if (await filter(contentType))
|
|
84
|
+
yield contentType;
|
|
85
|
+
}
|
|
86
|
+
} while (requestPageIndex < totalPages);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cms/index.ts"],"names":[],"mappings":";;AAwBA,8DAMC;AAED,8DAYC;AAED,wCAIC;AAYD,gDA6BC;AA1FD,mEAA4E;AAC5E,uDAA0D;AAC1D,oCAAsD;AAEtD,IAAI,MAAM,GAAG,IAAA,yBAAY,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AACxD,MAAM,YAAY,GAAG,IAAI,GAAG,EAA4C,CAAC;AACzE,SAAS,SAAS,CAAC,MAAiC;IAClD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAA;IAC5C,IAAI,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACvC,MAAM,UAAU,GAAG,IAAA,iCAAY,EAAC,MAAM,CAAC,CAAC;YACxC,UAAU,CAAC,eAAe,EAAE,CAAC,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