@remkoj/optimizely-graph-functions 1.0.4 → 2.0.0-pre2
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/dist/documents.d.ts +0 -5
- package/dist/documents.js +110 -146
- package/dist/documents.js.map +1 -1
- package/dist/index.js +4 -27
- package/dist/index.js.map +1 -1
- package/dist/preset.d.ts +1 -1
- package/dist/preset.js +57 -8
- package/dist/preset.js.map +1 -1
- package/dist/transform.d.ts +3 -1
- package/dist/transform.js +32 -24
- package/dist/transform.js.map +1 -1
- package/package.json +17 -8
package/dist/documents.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type { Types } from '@graphql-codegen/plugin-helpers';
|
|
2
|
-
type DocumentsConfigNode = NonNullable<Types.Config['documents']>;
|
|
3
1
|
export declare const IContentDataProps: string[];
|
|
4
2
|
export declare const fragments: string[];
|
|
5
3
|
export declare const queries: string[];
|
|
6
4
|
export declare const DefaultFunctions: string[];
|
|
7
|
-
export declare const documents: string[];
|
|
8
|
-
export declare const injectFragments: (base: DocumentsConfigNode) => DocumentsConfigNode;
|
|
9
|
-
export {};
|
package/dist/documents.js
CHANGED
|
@@ -1,173 +1,137 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DefaultFunctions = exports.queries = exports.fragments = exports.IContentDataProps = void 0;
|
|
4
4
|
exports.IContentDataProps = ["contentType", "id", "locale", "path", "__typename"];
|
|
5
5
|
exports.fragments = [
|
|
6
|
-
`fragment
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
locale: Language {
|
|
22
|
-
name: Name
|
|
23
|
-
}
|
|
24
|
-
path:RelativePath
|
|
25
|
-
}`,
|
|
26
|
-
`fragment ContentAreaItemData on ContentAreaItemModelSearch {
|
|
27
|
-
item: ContentLink {
|
|
28
|
-
...ContentLinkSearch
|
|
29
|
-
data: Expanded {
|
|
30
|
-
...BlockData
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
displayOption:DisplayOption
|
|
34
|
-
}`,
|
|
35
|
-
`fragment BlockContentAreaItemSearchData on ContentAreaItemModelSearch {
|
|
36
|
-
item: ContentLink {
|
|
37
|
-
...ContentLinkSearch
|
|
38
|
-
data: Expanded {
|
|
39
|
-
...IContentData
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
displayOption:DisplayOption
|
|
43
|
-
}`,
|
|
44
|
-
`fragment BlockContentAreaItemData on ContentAreaItemModel {
|
|
45
|
-
item: ContentLink {
|
|
46
|
-
...ContentLink
|
|
47
|
-
data: Expanded {
|
|
48
|
-
...IContentData
|
|
49
|
-
}
|
|
6
|
+
`fragment IContentData on IContent
|
|
7
|
+
{
|
|
8
|
+
_metadata {
|
|
9
|
+
...IContentInfo
|
|
10
|
+
}
|
|
11
|
+
_type: __typename
|
|
12
|
+
}`,
|
|
13
|
+
`fragment CompositionData on ICompositionNode {
|
|
14
|
+
name: displayName
|
|
15
|
+
layoutType
|
|
16
|
+
type
|
|
17
|
+
key
|
|
18
|
+
... on ICompositionStructureNode {
|
|
19
|
+
nodes @recursive(depth: 5) {
|
|
20
|
+
name: displayName
|
|
50
21
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
title: Title
|
|
56
|
-
href: Href
|
|
57
|
-
target: Target
|
|
58
|
-
content: ContentLink {
|
|
59
|
-
href: Url
|
|
60
|
-
data: Expanded {
|
|
61
|
-
path: RelativePath
|
|
22
|
+
}
|
|
23
|
+
... on ICompositionElementNode {
|
|
24
|
+
element {
|
|
25
|
+
...ElementData
|
|
62
26
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
`fragment
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}`,
|
|
75
|
-
`fragment ImageDataSearch on ContentModelReferenceSearch {
|
|
76
|
-
...ContentLinkSearch
|
|
77
|
-
url: Url
|
|
78
|
-
data: Expanded {
|
|
79
|
-
...IContentData
|
|
80
|
-
url: Url
|
|
81
|
-
alt: Name
|
|
82
|
-
path: RelativePath
|
|
83
|
-
}
|
|
84
|
-
}`,
|
|
27
|
+
}
|
|
28
|
+
}`,
|
|
29
|
+
`fragment IElementData on IElement {
|
|
30
|
+
_metadata {
|
|
31
|
+
...IContentInfo
|
|
32
|
+
}
|
|
33
|
+
_type: __typename
|
|
34
|
+
}`,
|
|
35
|
+
`fragment ElementData on IElement {
|
|
36
|
+
...IElementData
|
|
37
|
+
}`,
|
|
85
38
|
`fragment BlockData on IContent {
|
|
86
|
-
|
|
87
|
-
|
|
39
|
+
...IContentData
|
|
40
|
+
}`,
|
|
88
41
|
`fragment PageData on IContent {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
`fragment
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
42
|
+
...IContentData
|
|
43
|
+
}`,
|
|
44
|
+
`fragment LinkData on ContentUrl {
|
|
45
|
+
base
|
|
46
|
+
hierarchical
|
|
47
|
+
default
|
|
48
|
+
}`,
|
|
49
|
+
`fragment ReferenceData on ContentReference {
|
|
50
|
+
key
|
|
51
|
+
url {
|
|
52
|
+
...LinkData
|
|
53
|
+
}
|
|
54
|
+
}`,
|
|
55
|
+
`fragment IContentInfo on IContentMetadata {
|
|
56
|
+
key
|
|
57
|
+
locale
|
|
58
|
+
types
|
|
59
|
+
displayName
|
|
60
|
+
version
|
|
61
|
+
url {
|
|
62
|
+
...LinkData
|
|
63
|
+
}
|
|
64
|
+
}`,
|
|
65
|
+
`fragment IContentListItem on IContent {
|
|
66
|
+
...IContentData
|
|
67
|
+
}`,
|
|
68
|
+
`fragment ExperienceData on IExperience {
|
|
69
|
+
experience: _metadata {
|
|
70
|
+
... on CompositionMetadata {
|
|
71
|
+
composition {
|
|
72
|
+
key
|
|
73
|
+
layoutType
|
|
74
|
+
type
|
|
75
|
+
nodes {
|
|
76
|
+
...CompositionData
|
|
77
|
+
}
|
|
99
78
|
}
|
|
100
79
|
}
|
|
101
|
-
|
|
102
|
-
|
|
80
|
+
}
|
|
81
|
+
}`
|
|
103
82
|
];
|
|
104
|
-
exports.queries = [
|
|
105
|
-
|
|
83
|
+
exports.queries = [
|
|
84
|
+
`query getContentById($key: String!, $version: String, $locale: [Locales!], $path: String, $domain: String) {
|
|
85
|
+
content: Content(
|
|
106
86
|
where: {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
IsCommonDraft: { eq: $isCommonDraft }
|
|
87
|
+
_or: [
|
|
88
|
+
{ _metadata: { key: { eq: $key }, version: { eq: $version } } }
|
|
89
|
+
{ _metadata: { url: { hierarchical: { eq: $path }, base: { eq: $domain } }, version: { eq: $version } } }
|
|
90
|
+
]
|
|
113
91
|
}
|
|
114
92
|
locale: $locale
|
|
115
93
|
) {
|
|
116
94
|
total
|
|
117
95
|
items {
|
|
118
96
|
...IContentData
|
|
119
|
-
...PageData
|
|
120
97
|
...BlockData
|
|
98
|
+
...PageData
|
|
121
99
|
}
|
|
122
100
|
}
|
|
123
101
|
}`,
|
|
124
|
-
`query getContentByPath($path: String!, $locale: [Locales], $
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
items {
|
|
138
|
-
...PageData
|
|
102
|
+
`query getContentByPath($path: String!, $version: String, $locale: [Locales!], $domain: String) {
|
|
103
|
+
content: Content(
|
|
104
|
+
where: {
|
|
105
|
+
_metadata: { url: { default: { eq: $path }, base: { eq: $domain } }, version: { eq: $version }}
|
|
106
|
+
}
|
|
107
|
+
locale: $locale
|
|
108
|
+
) {
|
|
109
|
+
total
|
|
110
|
+
items {
|
|
111
|
+
...IContentData
|
|
112
|
+
...BlockData
|
|
113
|
+
...PageData
|
|
114
|
+
}
|
|
139
115
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
116
|
+
}`,
|
|
117
|
+
`query getContentType($key: String!, $version: String, $locale: [Locales!], $path: String, $domain: String) {
|
|
118
|
+
content: Content(
|
|
119
|
+
where: {
|
|
120
|
+
_or: [
|
|
121
|
+
{ _metadata: { key: { eq: $key }, version: { eq: $version } } }
|
|
122
|
+
{ _metadata: { url: { hierarchical: { eq: $path }, base: { eq: $domain } }, version: { eq: $version } } }
|
|
123
|
+
]
|
|
148
124
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
125
|
+
locale: $locale
|
|
126
|
+
) {
|
|
127
|
+
total
|
|
128
|
+
items {
|
|
129
|
+
_metadata {
|
|
130
|
+
types
|
|
131
|
+
}
|
|
154
132
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
limit: 1
|
|
159
|
-
) {
|
|
160
|
-
items {
|
|
161
|
-
ContentType
|
|
162
|
-
},
|
|
163
|
-
total
|
|
164
|
-
}
|
|
165
|
-
}`];
|
|
133
|
+
}
|
|
134
|
+
}`
|
|
135
|
+
];
|
|
166
136
|
exports.DefaultFunctions = ['getContentType', 'getContentByPath', 'getContentById'];
|
|
167
|
-
exports.documents = [...exports.queries, ...exports.fragments];
|
|
168
|
-
const injectFragments = (base) => {
|
|
169
|
-
const baseIsArray = Array.isArray(base);
|
|
170
|
-
return baseIsArray ? [...exports.fragments, ...base] : [...exports.fragments, base];
|
|
171
|
-
};
|
|
172
|
-
exports.injectFragments = injectFragments;
|
|
173
137
|
//# sourceMappingURL=documents.js.map
|
package/dist/documents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,CAAC,aAAa,EAAC,IAAI,EAAC,QAAQ,EAAC,MAAM,EAAC,YAAY,CAAC,CAAA;AAErE,QAAA,SAAS,GAAG;IACzB;;;;;;EAME;IACF;;;;;;;;;;;;;;;EAeE;IACF;;;;;EAKE;IACF;;EAEE;IACF;;EAEE;IACF;;EAEE;IACF;;;;EAIE;IACF;;;;;EAKE;IACF;;;;;;;;;EASE;IACF;;EAEE;IACF;;;;;;;;;;;;;EAaE;CACD,CAAA;AACY,QAAA,OAAO,GAAG;IACvB;;;;;;;;;;;;;;;;;EAiBE;IACF;;;;;;;;;;;;;;EAcE;IACF;;;;;;;;;;;;;;;;;EAiBE;CACD,CAAA;AAEY,QAAA,gBAAgB,GAAG,CAAC,gBAAgB,EAAC,kBAAkB,EAAC,gBAAgB,CAAC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.plugin = exports.validate = exports.pickPluginOptions = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
|
+
const documents_1 = require("./documents");
|
|
6
7
|
function pickPluginOptions(options) {
|
|
7
8
|
return {
|
|
8
|
-
functions: options.functions ??
|
|
9
|
+
functions: options.functions ?? documents_1.DefaultFunctions,
|
|
9
10
|
prettyPrintQuery: options.prettyPrintQuery ?? false,
|
|
10
11
|
clientPath: options.clientPath ?? "./graphql"
|
|
11
12
|
};
|
|
@@ -52,7 +53,7 @@ const plugin = async (schema, documents, config, info) => {
|
|
|
52
53
|
if (!(queryNode && queryNode.operation == graphql_1.OperationTypeNode.QUERY))
|
|
53
54
|
return [`export async function ${fn}() { throw new Error('No query named ${fn} defined')}`];
|
|
54
55
|
const fragments = resolveSpreads(queryNode, docs);
|
|
55
|
-
const fnTypeName = fn
|
|
56
|
+
const fnTypeName = fn; //.charAt(0).toUpperCase() + fn.slice(1)
|
|
56
57
|
const varsType = `Types.${fnTypeName}QueryVariables`;
|
|
57
58
|
const returnType = `Types.${fnTypeName}Query`;
|
|
58
59
|
const query = [queryNode, ...fragments].map(node => (0, graphql_1.print)(node)).join("\n\n");
|
|
@@ -71,11 +72,9 @@ const plugin = async (schema, documents, config, info) => {
|
|
|
71
72
|
const prepend = [];
|
|
72
73
|
const append = [];
|
|
73
74
|
prepend.push('import { gql, type GraphQLClient } from \'graphql-request\'');
|
|
74
|
-
prepend.push('import { ContentGraphClient as BaseGraphClient } from \'@remkoj/optimizely-graph-client\'');
|
|
75
75
|
prepend.push(`import type * as Types from './graphql'`);
|
|
76
76
|
prepend.push("\n");
|
|
77
|
-
append.push("\n
|
|
78
|
-
append.push(generateClientClass(functions));
|
|
77
|
+
append.push("\n");
|
|
79
78
|
return { prepend, content: output.join("\n"), append };
|
|
80
79
|
};
|
|
81
80
|
exports.plugin = plugin;
|
|
@@ -112,27 +111,5 @@ function resolveSpreads(definition, document, availableFragments = []) {
|
|
|
112
111
|
});
|
|
113
112
|
return [...fragments, ...dependencies];
|
|
114
113
|
}
|
|
115
|
-
function generateClientClass(functions) {
|
|
116
|
-
return `/**
|
|
117
|
-
* Function client for Optimizely Graph, exposing both the raw request method,
|
|
118
|
-
* as well as the high level convenience methods to read content from
|
|
119
|
-
* Optimizely Graph. The actual format for each of the Content Items returned
|
|
120
|
-
* by these convenience methods is defined by the GraphQL Fragments within the
|
|
121
|
-
* application codebase.
|
|
122
|
-
*/
|
|
123
|
-
export class OptimizelyGraphClient extends BaseGraphClient {
|
|
124
|
-
|
|
125
|
-
${functions.map(fn => {
|
|
126
|
-
const fnTypeName = fn.charAt(0).toUpperCase() + fn.slice(1);
|
|
127
|
-
const fnNamespace = "Types";
|
|
128
|
-
const varsType = `${fnNamespace}.${fnTypeName}QueryVariables`;
|
|
129
|
-
const returnType = `${fnNamespace}.${fnTypeName}Query`;
|
|
130
|
-
return ` public ${fn}(variables: ${varsType}) : Promise<${returnType}>
|
|
131
|
-
{
|
|
132
|
-
return ${fn}(this, variables)
|
|
133
|
-
}`;
|
|
134
|
-
}).join('\n\n')}
|
|
135
|
-
}`;
|
|
136
|
-
}
|
|
137
114
|
exports.default = { validate: exports.validate, plugin: exports.plugin };
|
|
138
115
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,qCAA0J;AAC1J,mCAA8C;AAC9C,2CAA8C;AAQ9C,SAAgB,iBAAiB,CAAC,OAA2B;IAEzD,OAAO;QACH,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,4BAAgB;QAChD,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,KAAK;QACnD,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,WAAW;KAChD,CAAA;AACL,CAAC;AAPD,8CAOC;AAED;;;;;;;;;GASG;AACI,MAAM,QAAQ,GAAoC,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE;IAEzH,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACnB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,wCAAw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,CAAA;QAChF,YAAY,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;IACF,OAAO,CAAE,GAAG,SAAS,EAAE,GAAG,YAAY,CAAC,CAAA;AAC3C,CAAC;AAED,kBAAe,EAAE,QAAQ,EAAR,gBAAQ,EAAE,MAAM,EAAN,cAAM,EAAkC,CAAA"}
|
package/dist/preset.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Types } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import { type ClientPresetConfig as ClientPresetOptions } from '@graphql-codegen/client-preset';
|
|
3
3
|
import { type PluginOptions } from './index';
|
|
4
4
|
import { type TransformOptions } from './transform';
|
package/dist/preset.js
CHANGED
|
@@ -27,27 +27,72 @@ exports.preset = void 0;
|
|
|
27
27
|
const documents_1 = require("./documents");
|
|
28
28
|
// Import base preset
|
|
29
29
|
const client_preset_1 = require("@graphql-codegen/client-preset");
|
|
30
|
+
const GraphQLRequestPlugin = __importStar(require("@graphql-codegen/typescript-graphql-request"));
|
|
31
|
+
const AddPlugin = __importStar(require("@graphql-codegen/add"));
|
|
30
32
|
// Import injected parts
|
|
31
33
|
const index_1 = __importStar(require("./index"));
|
|
32
34
|
const transform_1 = __importStar(require("./transform"));
|
|
33
35
|
exports.preset = {
|
|
36
|
+
/**
|
|
37
|
+
* Prepare the documents to be parsed by this preset, without modifying the original array
|
|
38
|
+
*
|
|
39
|
+
* @param outputFilePath The path where the output of this preset will be stored
|
|
40
|
+
* @param outputSpecificDocuments The currently selected documents
|
|
41
|
+
* @returns An awaitable with the modified list of documents.
|
|
42
|
+
*/
|
|
34
43
|
prepareDocuments: async (outputFilePath, outputSpecificDocuments) => {
|
|
35
44
|
// Get the base documents
|
|
36
|
-
const documents = client_preset_1.preset.prepareDocuments ?
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
return documents;
|
|
45
|
+
const documents = client_preset_1.preset.prepareDocuments ?
|
|
46
|
+
await client_preset_1.preset.prepareDocuments(outputFilePath, outputSpecificDocuments) :
|
|
47
|
+
[...outputSpecificDocuments, `!${outputFilePath}`];
|
|
48
|
+
// Create a new, extended, array
|
|
49
|
+
return [...documents, ...documents_1.fragments, ...documents_1.queries];
|
|
41
50
|
},
|
|
42
51
|
buildGeneratesSection: async (options) => {
|
|
52
|
+
// Extend the document transforms
|
|
53
|
+
options.config = {
|
|
54
|
+
...options.config,
|
|
55
|
+
namingConvention: "keep", // Keep casing "as-is" from Optimizely Graph
|
|
56
|
+
};
|
|
43
57
|
options.documentTransforms = [
|
|
58
|
+
...(options.documentTransforms || []),
|
|
44
59
|
{
|
|
45
60
|
name: 'optly-transform',
|
|
46
61
|
transformObject: transform_1.default,
|
|
47
62
|
config: (0, transform_1.pickTransformOptions)(options.presetConfig)
|
|
48
63
|
}
|
|
49
64
|
];
|
|
65
|
+
// Build the preset files
|
|
50
66
|
const section = await client_preset_1.preset.buildGeneratesSection(options);
|
|
67
|
+
// Add GraphQL Request Client
|
|
68
|
+
section.push({
|
|
69
|
+
filename: `${options.baseOutputDir}client.ts`,
|
|
70
|
+
pluginMap: {
|
|
71
|
+
"add": AddPlugin,
|
|
72
|
+
"typescript-graphql-request": GraphQLRequestPlugin
|
|
73
|
+
},
|
|
74
|
+
plugins: [
|
|
75
|
+
{
|
|
76
|
+
add: {
|
|
77
|
+
content: ["import type * as Schema from \"./graphql\";"]
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
'typescript-graphql-request': {
|
|
82
|
+
pureMagicComment: true,
|
|
83
|
+
useTypeImports: true,
|
|
84
|
+
dedupeFragments: true,
|
|
85
|
+
importOperationTypesFrom: "Schema"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
schema: options.schema,
|
|
90
|
+
schemaAst: options.schemaAst,
|
|
91
|
+
config: options.config,
|
|
92
|
+
profiler: options.profiler,
|
|
93
|
+
documents: options.documents,
|
|
94
|
+
documentTransforms: options.documentTransforms
|
|
95
|
+
});
|
|
51
96
|
// Add the functions file
|
|
52
97
|
section.push({
|
|
53
98
|
filename: `${options.baseOutputDir}functions.ts`,
|
|
@@ -60,6 +105,8 @@ exports.preset = {
|
|
|
60
105
|
}
|
|
61
106
|
],
|
|
62
107
|
schema: options.schema,
|
|
108
|
+
schemaAst: options.schemaAst,
|
|
109
|
+
profiler: options.profiler,
|
|
63
110
|
config: (0, index_1.pickPluginOptions)(options.presetConfig),
|
|
64
111
|
documents: options.documents,
|
|
65
112
|
documentTransforms: options.documentTransforms
|
|
@@ -67,9 +114,11 @@ exports.preset = {
|
|
|
67
114
|
// Add functions to index plugin
|
|
68
115
|
section.forEach((fileConfig, idx) => {
|
|
69
116
|
if (fileConfig.filename.endsWith("index.ts")) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
117
|
+
section[idx].plugins.unshift({
|
|
118
|
+
add: {
|
|
119
|
+
content: ['export * as Schema from "./graphql";', 'export * from "./functions";', 'export { getSdk, type Sdk } from "./client";']
|
|
120
|
+
}
|
|
121
|
+
});
|
|
73
122
|
}
|
|
74
123
|
});
|
|
75
124
|
return section;
|
package/dist/preset.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset.js","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAAgD;AAEhD,qBAAqB;AACrB,kEAAuH;
|
|
1
|
+
{"version":3,"file":"preset.js","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAAgD;AAEhD,qBAAqB;AACrB,kEAAuH;AACvH,kGAAmF;AACnF,gEAAiD;AAEjD,wBAAwB;AACxB,iDAAuE;AACvE,yDAAoF;AAKvE,QAAA,MAAM,GACnB;IACI;;;;;;OAMG;IACH,gBAAgB,EAAE,KAAK,EAAE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
|
package/dist/transform.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Types } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import type { Injection } from './types';
|
|
3
3
|
export type TransformOptions = {
|
|
4
4
|
injections?: Injection[];
|
|
5
|
+
verbose?: boolean;
|
|
6
|
+
recursion?: boolean;
|
|
5
7
|
};
|
|
6
8
|
export declare function pickTransformOptions(options: Record<string, any>): TransformOptions;
|
|
7
9
|
export declare const transform: Types.DocumentTransformFunction<TransformOptions>;
|
package/dist/transform.js
CHANGED
|
@@ -8,13 +8,14 @@ const graphql_1 = require("graphql");
|
|
|
8
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
9
|
function pickTransformOptions(options) {
|
|
10
10
|
return {
|
|
11
|
-
injections: options.injections ?? []
|
|
11
|
+
injections: options.injections ?? [],
|
|
12
|
+
verbose: options.verbose ?? false,
|
|
13
|
+
recursion: options.recursion ?? true
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
16
|
exports.pickTransformOptions = pickTransformOptions;
|
|
15
17
|
function isArray(toTest) { return Array.isArray(toTest); }
|
|
16
|
-
const transform =
|
|
17
|
-
//console.log("[STARTED] Optimizely document transformation")
|
|
18
|
+
const transform = ({ documents: files, config, schema, pluginContext }) => {
|
|
18
19
|
const injections = config.injections ?? [];
|
|
19
20
|
// Retrieve component fragments
|
|
20
21
|
const componentFragments = {};
|
|
@@ -27,12 +28,12 @@ const transform = async ({ documents: files, config, schema }) => {
|
|
|
27
28
|
(0, graphql_1.visit)(file.document, {
|
|
28
29
|
FragmentDefinition: {
|
|
29
30
|
enter(node) {
|
|
30
|
-
console.log("[ DEBUG ] Visiting fragment:", node.name.value, node.typeCondition.name.value);
|
|
31
31
|
const matchingInjections = applicableInjections.filter(injection => !injection.nameRegex || (new RegExp(injection.nameRegex)).test(node.name.value));
|
|
32
32
|
if (!matchingInjections || matchingInjections.length == 0)
|
|
33
33
|
return false;
|
|
34
34
|
matchingInjections.forEach(injection => {
|
|
35
|
-
|
|
35
|
+
if (config.verbose)
|
|
36
|
+
console.debug(`[ OPTIMIZELY ] Found ${node.name.value} for ${injection.into} in file ${node.loc?.source?.name}`);
|
|
36
37
|
if (!componentFragments[injection.into])
|
|
37
38
|
componentFragments[injection.into] = [];
|
|
38
39
|
if (!componentFragments[injection.into].some(f => f.name.value == node.name.value))
|
|
@@ -45,19 +46,19 @@ const transform = async ({ documents: files, config, schema }) => {
|
|
|
45
46
|
});
|
|
46
47
|
// Get the names we actually need to inject into, and return when none are present
|
|
47
48
|
const intoNames = Object.getOwnPropertyNames(componentFragments);
|
|
49
|
+
// Process recursion
|
|
48
50
|
const componentSpreads = {};
|
|
49
|
-
if (intoNames.length > 0) {
|
|
51
|
+
if (config.recursion && intoNames.length > 0) {
|
|
50
52
|
// Process the fragments, add matching spreads if need be
|
|
51
|
-
const recursiveFragments = ["
|
|
53
|
+
const recursiveFragments = ["IContentListItem"];
|
|
52
54
|
intoNames.forEach(intoName => {
|
|
53
|
-
//console.log(`[ DEBUG ] Preparing mutations for ${ intoName }`)
|
|
54
55
|
componentFragments[intoName].forEach(fragment => {
|
|
55
|
-
//console.log(`[ DEBUG ] Preparing mutations for fragment ${ fragment.name.value } within ${ intoName }`)
|
|
56
56
|
(0, graphql_1.visit)(fragment, {
|
|
57
57
|
FragmentSpread: {
|
|
58
58
|
leave(node, key, parent, path, ancestors) {
|
|
59
59
|
if (recursiveFragments.includes(node.name.value) && !isArray(ancestors[0]) && ancestors[0].kind == graphql_1.Kind.FRAGMENT_DEFINITION) {
|
|
60
|
-
|
|
60
|
+
if (config.verbose)
|
|
61
|
+
console.debug(`[ OPTIMIZELY ] Found ${node.name.value} within ${fragment.name.value} for ${intoName}, creating recursive fragment`);
|
|
61
62
|
const fields = ancestors.filter(a => !isArray(a) && a.kind != graphql_1.Kind.FRAGMENT_DEFINITION && a.kind != graphql_1.Kind.SELECTION_SET);
|
|
62
63
|
if (fields.length < 1)
|
|
63
64
|
return undefined;
|
|
@@ -72,6 +73,15 @@ const transform = async ({ documents: files, config, schema }) => {
|
|
|
72
73
|
kind: graphql_1.Kind.FIELD,
|
|
73
74
|
name: fields[0].name,
|
|
74
75
|
alias: fields[0].alias,
|
|
76
|
+
directives: [{
|
|
77
|
+
kind: graphql_1.Kind.DIRECTIVE,
|
|
78
|
+
name: { kind: graphql_1.Kind.NAME, value: "recursive" },
|
|
79
|
+
arguments: [{
|
|
80
|
+
kind: graphql_1.Kind.ARGUMENT,
|
|
81
|
+
name: { kind: graphql_1.Kind.NAME, value: "depth" },
|
|
82
|
+
value: { kind: graphql_1.Kind.INT, value: "5" }
|
|
83
|
+
}]
|
|
84
|
+
}],
|
|
75
85
|
selectionSet: {
|
|
76
86
|
kind: graphql_1.Kind.SELECTION_SET,
|
|
77
87
|
selections: recursiveSelections
|
|
@@ -89,26 +99,29 @@ const transform = async ({ documents: files, config, schema }) => {
|
|
|
89
99
|
});
|
|
90
100
|
});
|
|
91
101
|
}
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
//console.log(`[ DEBUG ] Entering file ${ file.location } }`)
|
|
102
|
+
// Update the documents
|
|
103
|
+
return files.map(file => {
|
|
95
104
|
const document = file.document ? (0, graphql_1.visit)(file.document, {
|
|
105
|
+
// Remove fragments from the preset, for which the target type does not exist
|
|
96
106
|
FragmentDefinition: {
|
|
97
107
|
enter(node) {
|
|
98
108
|
if (file.location && !node_fs_1.default.existsSync(file.location)) {
|
|
99
109
|
const typePresent = schema.definitions.some(definition => (definition.kind == graphql_1.Kind.OBJECT_TYPE_DEFINITION || definition.kind == graphql_1.Kind.INTERFACE_TYPE_DEFINITION) && definition.name.value == node.typeCondition.name.value);
|
|
100
|
-
//console.log(`[ DEBUG ] Entering fragment ${ node.name.value } on ${ node.typeCondition.name.value }; ${ node.typeCondition.name.value } present in schema: ${ typePresent ? 'yes' : 'no'}`)
|
|
101
110
|
if (!typePresent) {
|
|
102
|
-
|
|
111
|
+
if (config.verbose)
|
|
112
|
+
console.debug(`[OPTIMIZELY] Type ${node.typeCondition.name.value} not found, dropping fragment ${node.name.value}`);
|
|
103
113
|
return null;
|
|
104
114
|
}
|
|
105
115
|
}
|
|
106
116
|
}
|
|
107
117
|
},
|
|
118
|
+
// Add items to the selection sets
|
|
108
119
|
SelectionSet: {
|
|
109
120
|
enter(node, key, parent) {
|
|
110
121
|
if (!isArray(parent) && parent?.kind == graphql_1.Kind.FRAGMENT_DEFINITION && intoNames.includes(parent.name.value)) {
|
|
111
122
|
const addedSelections = componentFragments[parent.name.value].map(fragment => {
|
|
123
|
+
if (config.verbose)
|
|
124
|
+
console.debug(`[ OPTIMIZELY ] Adding fragment ${fragment.name.value} to ${parent.name.value}`);
|
|
112
125
|
return {
|
|
113
126
|
kind: graphql_1.Kind.FRAGMENT_SPREAD,
|
|
114
127
|
directives: [],
|
|
@@ -119,7 +132,8 @@ const transform = async ({ documents: files, config, schema }) => {
|
|
|
119
132
|
};
|
|
120
133
|
});
|
|
121
134
|
componentSpreads[parent.name.value]?.forEach(spread => {
|
|
122
|
-
|
|
135
|
+
if (config.verbose)
|
|
136
|
+
console.debug(`[ OPTIMIZELY ] Adding inline fragment for ${spread.typeCondition?.name.value ?? "Untyped"} to ${parent.name.value}`);
|
|
123
137
|
addedSelections.push(spread);
|
|
124
138
|
});
|
|
125
139
|
return {
|
|
@@ -139,17 +153,11 @@ const transform = async ({ documents: files, config, schema }) => {
|
|
|
139
153
|
document: document,
|
|
140
154
|
};
|
|
141
155
|
});
|
|
142
|
-
//console.log("[SUCCESS] Optimizely document transformation")
|
|
143
|
-
return newFiles;
|
|
144
156
|
};
|
|
145
157
|
exports.transform = transform;
|
|
146
158
|
exports.default = { transform: exports.transform };
|
|
147
159
|
// The recursive sections to add
|
|
148
|
-
const recursiveSelections = (0, graphql_1.parse)(`fragment
|
|
149
|
-
|
|
150
|
-
data: Expanded @recursive(depth: 3) {
|
|
151
|
-
__typename
|
|
152
|
-
}
|
|
153
|
-
}
|
|
160
|
+
const recursiveSelections = (0, graphql_1.parse)(`fragment IContentListItem on IContent {
|
|
161
|
+
...IContentData
|
|
154
162
|
}`).definitions[0]?.selectionSet.selections || [];
|
|
155
163
|
//# sourceMappingURL=transform.js.map
|
package/dist/transform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":";;;;;;AAGA,qCAA4C;AAC5C,sDAAwB;
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":";;;;;;AAGA,qCAA4C;AAC5C,sDAAwB;AAQxB,SAAgB,oBAAoB,CAAC,OAA2B;IAE5D,OAAO;QACH,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK;QACjC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI;KACvC,CAAA;AACL,CAAC;AAPD,oDAOC;AAED,SAAS,OAAO,CAAI,MAAyB,IAA6B,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA,CAAC,CAAC;AAEjG,MAAM,SAAS,GAAuD,CAAC,EAAC,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE;IAEhI,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAA;IAE1C,+BAA+B;IAC/B,MAAM,kBAAkB,GAAmD,EAAE,CAAA;IAC7E,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACjB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAM;QAC1B,MAAM,oBAAoB,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,SAAS,IAAI,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC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AAgC;AAChC,MAAM,mBAAmB,GAAI,IAAA,eAAK,EAAC;;EAEjC,CAAC,CAAC,WAAW,CAAC,CAAC,CAA4B,EAAE,YAAY,CAAC,UAAU,IAAI,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remkoj/optimizely-graph-functions",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0-pre2",
|
|
5
5
|
"packageManager": "yarn@4.1.1",
|
|
6
6
|
"repository": "https://github.com/remkoj/optimizely-dxp-clients.git",
|
|
7
7
|
"author": "Remko Jantzen <693172+remkoj@users.noreply.github.com>",
|
|
@@ -35,26 +35,35 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@types/node": "^20.12.6",
|
|
38
|
+
"@types/node": "^20.12.10",
|
|
40
39
|
"graphql": "^16.8.1",
|
|
41
|
-
"
|
|
40
|
+
"graphql-request": "^6.1.0",
|
|
41
|
+
"graphql-tag": "^2.12.6",
|
|
42
|
+
"typescript": "^5.4.5"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
45
|
"@graphql-codegen/add": "^5.0.2",
|
|
45
46
|
"@graphql-codegen/client-preset": "^4.2.5",
|
|
47
|
+
"@graphql-codegen/plugin-helpers": "^5.0.3",
|
|
48
|
+
"@graphql-codegen/typescript": "^4.0.6",
|
|
49
|
+
"@graphql-codegen/typescript-graphql-request": "^6.2.0",
|
|
50
|
+
"@graphql-codegen/typescript-operations": "^4.2.0",
|
|
46
51
|
"tslib": "^2.6.2"
|
|
47
52
|
},
|
|
48
53
|
"scripts": {
|
|
49
54
|
"clean": "tsc --clean",
|
|
50
55
|
"prepare": "tsc --build",
|
|
51
56
|
"recompile": "tsc --build --clean && tsc --build --force",
|
|
52
|
-
"watch": "tsc --watch"
|
|
57
|
+
"watch": "yarn tsc --watch"
|
|
53
58
|
},
|
|
54
59
|
"peerDependencies": {
|
|
55
|
-
"graphql": "*"
|
|
60
|
+
"@graphql-typed-document-node/core": "*",
|
|
61
|
+
"graphql": "*",
|
|
62
|
+
"graphql-request": "*",
|
|
63
|
+
"graphql-tag": "*"
|
|
56
64
|
},
|
|
57
65
|
"optionalDependencies": {
|
|
58
|
-
"@remkoj/optimizely-graph-client": "
|
|
59
|
-
}
|
|
66
|
+
"@remkoj/optimizely-graph-client": "2.0.0-pre2"
|
|
67
|
+
},
|
|
68
|
+
"stableVersion": "1.0.4"
|
|
60
69
|
}
|