@stepzen/transpiler 0.0.0-experimental-20221114-610843f6
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 +21 -0
- package/README.md +1 -0
- package/lib/actions/configure.d.ts +12 -0
- package/lib/actions/configure.d.ts.map +1 -0
- package/lib/actions/configure.js +134 -0
- package/lib/actions/configure.js.map +1 -0
- package/lib/actions/lint.d.ts +5 -0
- package/lib/actions/lint.d.ts.map +1 -0
- package/lib/actions/lint.js +31 -0
- package/lib/actions/lint.js.map +1 -0
- package/lib/actions/merge.d.ts +15 -0
- package/lib/actions/merge.d.ts.map +1 -0
- package/lib/actions/merge.js +177 -0
- package/lib/actions/merge.js.map +1 -0
- package/lib/actions/print.d.ts +4 -0
- package/lib/actions/print.d.ts.map +1 -0
- package/lib/actions/print.js +10 -0
- package/lib/actions/print.js.map +1 -0
- package/lib/actions/stitch.d.ts +3 -0
- package/lib/actions/stitch.d.ts.map +1 -0
- package/lib/actions/stitch.js +96 -0
- package/lib/actions/stitch.js.map +1 -0
- package/lib/actions/transpile.d.ts +17 -0
- package/lib/actions/transpile.d.ts.map +1 -0
- package/lib/actions/transpile.js +62 -0
- package/lib/actions/transpile.js.map +1 -0
- package/lib/actions/validate.d.ts +5 -0
- package/lib/actions/validate.d.ts.map +1 -0
- package/lib/actions/validate.js +40 -0
- package/lib/actions/validate.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/lib/mutations/config/envvars.d.ts +3 -0
- package/lib/mutations/config/envvars.d.ts.map +1 -0
- package/lib/mutations/config/envvars.js +27 -0
- package/lib/mutations/config/envvars.js.map +1 -0
- package/lib/mutations/config/index.d.ts +3 -0
- package/lib/mutations/config/index.d.ts.map +1 -0
- package/lib/mutations/config/index.js +5 -0
- package/lib/mutations/config/index.js.map +1 -0
- package/lib/utils/constants.d.ts +4 -0
- package/lib/utils/constants.d.ts.map +1 -0
- package/lib/utils/constants.js +19 -0
- package/lib/utils/constants.js.map +1 -0
- package/lib/utils/copy-workspace-content.d.ts +15 -0
- package/lib/utils/copy-workspace-content.d.ts.map +1 -0
- package/lib/utils/copy-workspace-content.js +46 -0
- package/lib/utils/copy-workspace-content.js.map +1 -0
- package/lib/utils/dedupe-query-and-mutation-types.d.ts +3 -0
- package/lib/utils/dedupe-query-and-mutation-types.d.ts.map +1 -0
- package/lib/utils/dedupe-query-and-mutation-types.js +68 -0
- package/lib/utils/dedupe-query-and-mutation-types.js.map +1 -0
- package/lib/utils/ensure-query-and-mutation-types.d.ts +4 -0
- package/lib/utils/ensure-query-and-mutation-types.d.ts.map +1 -0
- package/lib/utils/ensure-query-and-mutation-types.js +49 -0
- package/lib/utils/ensure-query-and-mutation-types.js.map +1 -0
- package/lib/utils/graphql-helpers.d.ts +5 -0
- package/lib/utils/graphql-helpers.d.ts.map +1 -0
- package/lib/utils/graphql-helpers.js +6 -0
- package/lib/utils/graphql-helpers.js.map +1 -0
- package/lib/utils/merge-helpers.d.ts +13 -0
- package/lib/utils/merge-helpers.d.ts.map +1 -0
- package/lib/utils/merge-helpers.js +180 -0
- package/lib/utils/merge-helpers.js.map +1 -0
- package/lib/utils/set-files-in-sdl.d.ts +7 -0
- package/lib/utils/set-files-in-sdl.d.ts.map +1 -0
- package/lib/utils/set-files-in-sdl.js +122 -0
- package/lib/utils/set-files-in-sdl.js.map +1 -0
- package/lib/utils/strip-empty-queries-and-mutations.d.ts +4 -0
- package/lib/utils/strip-empty-queries-and-mutations.d.ts.map +1 -0
- package/lib/utils/strip-empty-queries-and-mutations.js +44 -0
- package/lib/utils/strip-empty-queries-and-mutations.js.map +1 -0
- package/lib/validators/config-exists/index.d.ts +4 -0
- package/lib/validators/config-exists/index.d.ts.map +1 -0
- package/lib/validators/config-exists/index.js +46 -0
- package/lib/validators/config-exists/index.js.map +1 -0
- package/lib/validators/index.d.ts +3 -0
- package/lib/validators/index.d.ts.map +1 -0
- package/lib/validators/index.js +5 -0
- package/lib/validators/index.js.map +1 -0
- package/package.json +57 -0
- package/src/actions/configure.ts +176 -0
- package/src/actions/lint.ts +44 -0
- package/src/actions/merge.ts +243 -0
- package/src/actions/print.ts +8 -0
- package/src/actions/stitch.ts +113 -0
- package/src/actions/transpile.ts +74 -0
- package/src/actions/validate.ts +54 -0
- package/src/index.ts +7 -0
- package/src/mutations/config/envvars.ts +33 -0
- package/src/mutations/config/index.ts +3 -0
- package/src/utils/constants.ts +22 -0
- package/src/utils/copy-workspace-content.ts +48 -0
- package/src/utils/dedupe-query-and-mutation-types.ts +74 -0
- package/src/utils/ensure-query-and-mutation-types.ts +52 -0
- package/src/utils/graphql-helpers.ts +3 -0
- package/src/utils/merge-helpers.ts +205 -0
- package/src/utils/set-files-in-sdl.ts +156 -0
- package/src/utils/strip-empty-queries-and-mutations.ts +43 -0
- package/src/validators/config-exists/index.ts +54 -0
- package/src/validators/index.ts +3 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeTypeFromSchema = exports.removeQueryMutationFromSchema = exports.mergeTypeIntoSchema = exports.mergeQueryMutationIntoSchema = exports.getSchema = exports.getExtensions = exports.getConfiguration = exports.findTypeInSchema = exports.findQueryMutationInSchema = exports.findNextAvailableSubfolder = exports.dedupeTempFolder = void 0;
|
|
4
|
+
const debug = require("debug");
|
|
5
|
+
const graphql_1 = require("graphql");
|
|
6
|
+
const utilities_1 = require("graphql/utilities");
|
|
7
|
+
const fetch_1 = require("@stepzen/fetch");
|
|
8
|
+
const fs = require("fs-extra");
|
|
9
|
+
const glob = require("glob");
|
|
10
|
+
const os = require("os");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
const lodash_1 = require("lodash");
|
|
13
|
+
const graphql_helpers_1 = require("../utils/graphql-helpers");
|
|
14
|
+
const constants_1 = require("./constants");
|
|
15
|
+
const configure_1 = require("../actions/configure");
|
|
16
|
+
const transpile_1 = require("../actions/transpile");
|
|
17
|
+
const dedupeTempFolder = (dirpath) => {
|
|
18
|
+
do {
|
|
19
|
+
dirpath = (0, lodash_1.replace)(dirpath, os.tmpdir(), '');
|
|
20
|
+
} while (dirpath.includes(os.tmpdir()));
|
|
21
|
+
dirpath = path.join(os.tmpdir(), dirpath);
|
|
22
|
+
return dirpath;
|
|
23
|
+
};
|
|
24
|
+
exports.dedupeTempFolder = dedupeTempFolder;
|
|
25
|
+
const findNextAvailableSubfolder = (folder, name) => {
|
|
26
|
+
let subfolder = name;
|
|
27
|
+
let counter = 1;
|
|
28
|
+
while (fs.existsSync(path.join(folder, subfolder))) {
|
|
29
|
+
const suffix = `${counter++}`.padStart(2, '0');
|
|
30
|
+
subfolder = `${name}-${suffix}`;
|
|
31
|
+
}
|
|
32
|
+
return subfolder;
|
|
33
|
+
};
|
|
34
|
+
exports.findNextAvailableSubfolder = findNextAvailableSubfolder;
|
|
35
|
+
const findQueryMutationInSchema = (name, files) => {
|
|
36
|
+
for (const file of files) {
|
|
37
|
+
let found = false;
|
|
38
|
+
(0, graphql_1.visit)(file.ast, {
|
|
39
|
+
FieldDefinition(node) {
|
|
40
|
+
if (node.name.value === name) {
|
|
41
|
+
found = true;
|
|
42
|
+
return graphql_1.BREAK;
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
if (found)
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
};
|
|
51
|
+
exports.findQueryMutationInSchema = findQueryMutationInSchema;
|
|
52
|
+
const findTypeInSchema = (name, files) => {
|
|
53
|
+
for (const file of files) {
|
|
54
|
+
let found = false;
|
|
55
|
+
(0, graphql_1.visit)(file.ast, {
|
|
56
|
+
ObjectTypeDefinition(node) {
|
|
57
|
+
if (node.name.value === name) {
|
|
58
|
+
found = true;
|
|
59
|
+
return graphql_1.BREAK;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
if (found)
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
};
|
|
68
|
+
exports.findTypeInSchema = findTypeInSchema;
|
|
69
|
+
const getConfiguration = async (directories, silent = false, answers = {}) => {
|
|
70
|
+
const tmp = path.join(os.tmpdir(), `stepzen-tmp-config-${Date.now()}`);
|
|
71
|
+
fs.ensureDirSync(tmp);
|
|
72
|
+
for (const directory of directories) {
|
|
73
|
+
const configs = [
|
|
74
|
+
...glob.sync('**/config.yaml', { cwd: directory }),
|
|
75
|
+
...glob.sync('**/stepzen.config.json', { cwd: directory }),
|
|
76
|
+
];
|
|
77
|
+
for (const config of configs) {
|
|
78
|
+
const configFolder = path.join(directory, config);
|
|
79
|
+
let writeFolder = path.join(tmp, directory, config);
|
|
80
|
+
writeFolder = (0, exports.dedupeTempFolder)(writeFolder);
|
|
81
|
+
const content = fs.readFileSync(configFolder, 'utf8');
|
|
82
|
+
fs.ensureFileSync(writeFolder);
|
|
83
|
+
fs.writeFileSync(writeFolder, content);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const configuration = await (0, configure_1.default)(tmp, silent, answers);
|
|
87
|
+
fs.removeSync(tmp);
|
|
88
|
+
return configuration;
|
|
89
|
+
};
|
|
90
|
+
exports.getConfiguration = getConfiguration;
|
|
91
|
+
const getExtensions = async () => {
|
|
92
|
+
const domain = constants_1.STEPZEN_DOMAIN.replace('.io', '.net');
|
|
93
|
+
const url = `https://stepzen.${domain}/directives.graphql`;
|
|
94
|
+
const startedAt = new Date().getTime();
|
|
95
|
+
debug('stepzen:extensions')(`[transpiler] fetching StepZen extensions from ${url}`);
|
|
96
|
+
const response = await (0, fetch_1.default)(url);
|
|
97
|
+
const text = await response.text();
|
|
98
|
+
const doneAt = new Date().getTime();
|
|
99
|
+
debug('stepzen:extensions')(`[transpiler] fetched extensions (${text.length} bytes, ${doneAt - startedAt} ms)`);
|
|
100
|
+
return text;
|
|
101
|
+
};
|
|
102
|
+
exports.getExtensions = getExtensions;
|
|
103
|
+
const getSchema = async (directory, extensions) => {
|
|
104
|
+
const transpiled = await (0, transpile_1.default)(directory);
|
|
105
|
+
return (0, utilities_1.buildSchema)(`${extensions}${os.EOL}${transpiled.schema}`);
|
|
106
|
+
};
|
|
107
|
+
exports.getSchema = getSchema;
|
|
108
|
+
const mergeQueryMutationIntoSchema = (type, files) => {
|
|
109
|
+
files = files.map((file) => {
|
|
110
|
+
return {
|
|
111
|
+
...file,
|
|
112
|
+
ast: (0, graphql_1.visit)(file.ast, {
|
|
113
|
+
FieldDefinition(node) {
|
|
114
|
+
if (node.name.value === type.name.value) {
|
|
115
|
+
const directives = (0, graphql_helpers_1.cloneDeep)(type.directives);
|
|
116
|
+
const mutated = (0, graphql_helpers_1.cloneDeep)(node);
|
|
117
|
+
mutated.directives = directives;
|
|
118
|
+
return mutated;
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
return files;
|
|
125
|
+
};
|
|
126
|
+
exports.mergeQueryMutationIntoSchema = mergeQueryMutationIntoSchema;
|
|
127
|
+
const mergeTypeIntoSchema = (type, files) => {
|
|
128
|
+
files = files.map((file) => {
|
|
129
|
+
return {
|
|
130
|
+
...file,
|
|
131
|
+
ast: (0, graphql_1.visit)(file.ast, {
|
|
132
|
+
ObjectTypeDefinition(node) {
|
|
133
|
+
if (node.name.value === type.name.value) {
|
|
134
|
+
const directives = (0, graphql_helpers_1.cloneDeep)(type.directives);
|
|
135
|
+
const fields = (0, graphql_helpers_1.cloneDeep)(type.fields);
|
|
136
|
+
const mutated = (0, graphql_helpers_1.cloneDeep)(node);
|
|
137
|
+
mutated.directives = directives;
|
|
138
|
+
mutated.fields = fields;
|
|
139
|
+
return mutated;
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
}),
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
return files;
|
|
146
|
+
};
|
|
147
|
+
exports.mergeTypeIntoSchema = mergeTypeIntoSchema;
|
|
148
|
+
const removeQueryMutationFromSchema = (name, files) => {
|
|
149
|
+
files = files.map((file) => {
|
|
150
|
+
return {
|
|
151
|
+
...file,
|
|
152
|
+
ast: (0, graphql_1.visit)(file.ast, {
|
|
153
|
+
FieldDefinition(node) {
|
|
154
|
+
if (node.name.value === name) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
}),
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
return files;
|
|
162
|
+
};
|
|
163
|
+
exports.removeQueryMutationFromSchema = removeQueryMutationFromSchema;
|
|
164
|
+
const removeTypeFromSchema = (name, files) => {
|
|
165
|
+
files = files.map((file) => {
|
|
166
|
+
return {
|
|
167
|
+
...file,
|
|
168
|
+
ast: (0, graphql_1.visit)(file.ast, {
|
|
169
|
+
ObjectTypeDefinition(node) {
|
|
170
|
+
if (node.name.value === name) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
}),
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
return files;
|
|
178
|
+
};
|
|
179
|
+
exports.removeTypeFromSchema = removeTypeFromSchema;
|
|
180
|
+
//# sourceMappingURL=merge-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-helpers.js","sourceRoot":"","sources":["../../src/utils/merge-helpers.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAC9B,qCAAmD;AACnD,iDAA6C;AAC7C,0CAAkC;AAClC,+BAA8B;AAC9B,6BAA4B;AAC5B,yBAAwB;AACxB,6BAA4B;AAC5B,mCAA8B;AAE9B,8DAAkD;AAClD,2CAA0C;AAE1C,oDAA4C;AAC5C,oDAA4C;AAErC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,EAAE;IAClD,GAAG;QACD,OAAO,GAAG,IAAA,gBAAO,EAAC,OAAO,EAAE,E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ACF,CAAC;SACH,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAdY,QAAA,oBAAoB,wBAchC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DirectiveNode, SchemaDefinitionNode } from 'graphql';
|
|
2
|
+
import { DeepWriteable } from './graphql-helpers';
|
|
3
|
+
export declare const createOrUpdateSdlDirective: (importedGraphQLFiles: readonly string[], allGraphQLFiles: readonly string[], origSdlDirective?: DeepWriteable<DirectiveNode>) => DeepWriteable<DirectiveNode>;
|
|
4
|
+
export declare const createSchemaElement: (importedGraphQLFiles: readonly string[], allGraphQLFiles: readonly string[]) => DeepWriteable<SchemaDefinitionNode>;
|
|
5
|
+
declare const _default: (source: string, importedGraphQLFiles: readonly string[]) => void;
|
|
6
|
+
export default _default;
|
|
7
|
+
//# sourceMappingURL=set-files-in-sdl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-files-in-sdl.d.ts","sourceRoot":"","sources":["../../src/utils/set-files-in-sdl.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EAGb,oBAAoB,EAGrB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAY,aAAa,EAAC,MAAM,mBAAmB,CAAA;AAQ1D,eAAO,MAAM,0BAA0B,yBACf,SAAS,MAAM,EAAE,mBACtB,SAAS,MAAM,EAAE,qBACf,cAAc,aAAa,CAAC,iCA2DhD,CAAA;AAED,eAAO,MAAM,mBAAmB,yBACR,SAAS,MAAM,EAAE,mBACtB,SAAS,MAAM,EAAE,wCAuBnC,CAAA;iCAEuB,MAAM,wBAAwB,SAAS,MAAM,EAAE;AAAvE,wBA4CC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSchemaElement = exports.createOrUpdateSdlDirective = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const graphql_1 = require("graphql");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const graphql_helpers_1 = require("./graphql-helpers");
|
|
8
|
+
const print_1 = require("../actions/print");
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
const copy_workspace_content_1 = require("./copy-workspace-content");
|
|
11
|
+
const normalizePathSep = (pathlike) => pathlike.replace(path.sep, path.posix.sep);
|
|
12
|
+
const createOrUpdateSdlDirective = (importedGraphQLFiles, allGraphQLFiles, origSdlDirective) => {
|
|
13
|
+
let sdlDirective;
|
|
14
|
+
if (origSdlDirective) {
|
|
15
|
+
sdlDirective = (0, graphql_helpers_1.cloneDeep)(origSdlDirective);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
sdlDirective = {
|
|
19
|
+
kind: 'Directive',
|
|
20
|
+
name: {
|
|
21
|
+
kind: 'Name',
|
|
22
|
+
value: 'sdl',
|
|
23
|
+
},
|
|
24
|
+
arguments: [
|
|
25
|
+
{
|
|
26
|
+
kind: 'Argument',
|
|
27
|
+
name: {
|
|
28
|
+
kind: 'Name',
|
|
29
|
+
value: 'files',
|
|
30
|
+
},
|
|
31
|
+
value: {
|
|
32
|
+
kind: 'ListValue',
|
|
33
|
+
values: [
|
|
34
|
+
{
|
|
35
|
+
kind: 'StringValue',
|
|
36
|
+
value: constants_1.ALL_GRAPHQL_FILES,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
sdlDirective.arguments = sdlDirective.arguments?.map(arg => {
|
|
45
|
+
if (arg.name.value === 'files') {
|
|
46
|
+
const filesValueNodes = arg.value;
|
|
47
|
+
const fileset = new Set([
|
|
48
|
+
...filesValueNodes.values.map(value => value.value),
|
|
49
|
+
...importedGraphQLFiles,
|
|
50
|
+
// Make sure paths in the `@sdl()` directive use the `/` separator
|
|
51
|
+
// even on Windows.
|
|
52
|
+
].map(normalizePathSep));
|
|
53
|
+
if (fileset.has(constants_1.ALL_GRAPHQL_FILES)) {
|
|
54
|
+
fileset.delete(constants_1.ALL_GRAPHQL_FILES);
|
|
55
|
+
allGraphQLFiles.forEach(file => fileset.add(normalizePathSep(file)));
|
|
56
|
+
}
|
|
57
|
+
filesValueNodes.values = [...fileset].map(file => ({
|
|
58
|
+
kind: 'StringValue',
|
|
59
|
+
value: file,
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
return arg;
|
|
63
|
+
});
|
|
64
|
+
return sdlDirective;
|
|
65
|
+
};
|
|
66
|
+
exports.createOrUpdateSdlDirective = createOrUpdateSdlDirective;
|
|
67
|
+
const createSchemaElement = (importedGraphQLFiles, allGraphQLFiles) => {
|
|
68
|
+
const schemaElement = {
|
|
69
|
+
kind: 'SchemaDefinition',
|
|
70
|
+
directives: [
|
|
71
|
+
(0, exports.createOrUpdateSdlDirective)(importedGraphQLFiles, allGraphQLFiles),
|
|
72
|
+
],
|
|
73
|
+
operationTypes: [
|
|
74
|
+
{
|
|
75
|
+
kind: 'OperationTypeDefinition',
|
|
76
|
+
operation: 'query',
|
|
77
|
+
type: {
|
|
78
|
+
kind: 'NamedType',
|
|
79
|
+
name: {
|
|
80
|
+
kind: 'Name',
|
|
81
|
+
value: 'Query',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
return schemaElement;
|
|
88
|
+
};
|
|
89
|
+
exports.createSchemaElement = createSchemaElement;
|
|
90
|
+
exports.default = (source, importedGraphQLFiles) => {
|
|
91
|
+
const allGraphQLFiles = (0, copy_workspace_content_1.getAllGraphQLFiles)(source);
|
|
92
|
+
const output = path.join(source, 'index.graphql');
|
|
93
|
+
const index = fs.readFileSync(output, 'utf8');
|
|
94
|
+
let hasSchemaElement;
|
|
95
|
+
let ast = (0, graphql_1.parse)(index);
|
|
96
|
+
ast = (0, graphql_1.visit)(ast, {
|
|
97
|
+
SchemaDefinition(node) {
|
|
98
|
+
hasSchemaElement = true;
|
|
99
|
+
const mutated = (0, graphql_helpers_1.cloneDeep)(node);
|
|
100
|
+
const idx = mutated.directives?.findIndex(directive => directive.name.value === 'sdl');
|
|
101
|
+
if (mutated.directives && idx !== undefined && idx > -1) {
|
|
102
|
+
mutated.directives[idx] = (0, exports.createOrUpdateSdlDirective)(importedGraphQLFiles, allGraphQLFiles, mutated.directives[idx]);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
mutated.directives = mutated.directives || [];
|
|
106
|
+
mutated.directives.push((0, exports.createOrUpdateSdlDirective)(importedGraphQLFiles, allGraphQLFiles));
|
|
107
|
+
}
|
|
108
|
+
return mutated;
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
if (!hasSchemaElement) {
|
|
112
|
+
ast = (0, graphql_1.visit)(ast, {
|
|
113
|
+
Document(node) {
|
|
114
|
+
const mutated = (0, graphql_helpers_1.cloneDeep)(node);
|
|
115
|
+
mutated.definitions.push((0, exports.createSchemaElement)(importedGraphQLFiles, allGraphQLFiles));
|
|
116
|
+
return mutated;
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
fs.writeFileSync(output, (0, print_1.default)(ast));
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=set-files-in-sdl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-files-in-sdl.js","sourceRoot":"","sources":["../../src/utils/set-files-in-sdl.ts"],"names":[],"mappings":";;;AAAA,yBAAwB;AAExB,qCAOgB;AAChB,6BAA4B;AAE5B,uDAA0D;AAC1D,4CAAoC;AACpC,2CAA6C;AAC7C,qEAA2D;AAE3D,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAC5C,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAErC,MAAM,0BAA0B,GA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sources":["../../src/utils/strip-empty-queries-and-mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAQ,MAAM,SAAS,CAAA;8BAItB,YAAY,KAAG,YAAY;AAAhD,wBAsCC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const graphql_1 = require("graphql");
|
|
4
|
+
const graphql_helpers_1 = require("./graphql-helpers");
|
|
5
|
+
exports.default = (ast) => {
|
|
6
|
+
// Loop through the AST and nuke `__query` and `__mutation` stubs
|
|
7
|
+
ast = (0, graphql_1.visit)(ast, {
|
|
8
|
+
ObjectTypeDefinition: {
|
|
9
|
+
enter(node) {
|
|
10
|
+
if (node.name.kind === 'Name' && node.name.value === 'Query') {
|
|
11
|
+
const mutated = (0, graphql_helpers_1.cloneDeep)(node);
|
|
12
|
+
mutated.fields = mutated.fields.filter((field) => {
|
|
13
|
+
return field.name.value !== '__query';
|
|
14
|
+
});
|
|
15
|
+
return mutated;
|
|
16
|
+
}
|
|
17
|
+
if (node.name.kind === 'Name' && node.name.value === 'Mutation') {
|
|
18
|
+
const mutated = (0, graphql_helpers_1.cloneDeep)(node);
|
|
19
|
+
mutated.fields = mutated.fields.filter((field) => {
|
|
20
|
+
return field.name.value !== '__mutated';
|
|
21
|
+
});
|
|
22
|
+
return mutated;
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
// Strip empty Queries and Mutations definitions
|
|
28
|
+
ast = (0, graphql_1.visit)(ast, {
|
|
29
|
+
ObjectTypeDefinition: {
|
|
30
|
+
enter(node) {
|
|
31
|
+
if (node.name.kind === 'Name' && node.name.value === 'Query') {
|
|
32
|
+
if (node.fields?.length === 0)
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if (node.name.kind === 'Name' && node.name.value === 'Mutation') {
|
|
36
|
+
if (node.fields?.length === 0)
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
return ast;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=strip-empty-queries-and-mutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-empty-queries-and-mutations.js","sourceRoot":"","sources":["../../src/utils/strip-empty-queries-and-mutations.ts"],"names":[],"mappings":";;AAAA,qCAA2C;AAE3C,uDAA2C;AAE3C,kBAAe,CAAC,GAAiB,EAAgB,EAAE;IACjD,iEAAiE;IACjE,GAAG,GAAG,IAAA,eAAK,EAAC,GAAG,EAAE;QACf,oBAAoB,EAAE;YACpB,KAAK,CAAC,IAAI;gBACR,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO,EAAE;oBAC5D,MAAM,OAAO,GAAQ,IAAA,2BAAS,EAAC,IAAI,CAAC,CAAA;oBACpC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE;wBACpD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAA;oBACvC,CAAC,CAAC,CAAA;oBACF,OAAO,OAAO,CAAA;iBACf;gBACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,UAAU,EAAE;oBAC/D,MAAM,OAAO,GAAQ,IAAA,2BAAS,EAAC,IAAI,CAAC,CAAA;oBACpC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE;wBACpD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,WAAW,CAAA;oBACzC,CAAC,CAAC,CAAA;oBACF,OAAO,OAAO,CAAA;iBACf;YACH,CAAC;SACF;KACF,CAAC,CAAA;IAEF,gDAAgD;IAChD,GAAG,GAAG,IAAA,eAAK,EAAC,GAAG,EAAE;QACf,oBAAoB,EAAE;YACpB,KAAK,CAAC,IAAI;gBACR,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO,EAAE;oBAC5D,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC;wBAAE,OAAO,IAAI,CAAA;iBAC3C;gBACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,UAAU,EAAE;oBAC/D,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC;wBAAE,OAAO,IAAI,CAAA;iBAC3C;YACH,CAAC;SACF;KACF,CAAC,CAAA;IAEF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/validators/config-exists/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAQ,MAAM,SAAS,CAAA;8BActB,YAAY,UAAU,MAAM;AAAjD,wBAuCC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const graphql_1 = require("graphql");
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const yaml = require("yaml");
|
|
8
|
+
const STEPZEN_DEFAULTS = [
|
|
9
|
+
'fedex_default',
|
|
10
|
+
'holidayapi_default',
|
|
11
|
+
'ipapi_default',
|
|
12
|
+
'owm_default',
|
|
13
|
+
'ups_default',
|
|
14
|
+
];
|
|
15
|
+
exports.default = (ast, source) => {
|
|
16
|
+
let configs = [];
|
|
17
|
+
(0, graphql_1.visit)(ast, {
|
|
18
|
+
Argument(node) {
|
|
19
|
+
const name = node.name?.value;
|
|
20
|
+
const value = node.value?.value;
|
|
21
|
+
if (name === 'configuration') {
|
|
22
|
+
configs = configs.concat(value);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
configs = (0, lodash_1.uniq)(configs);
|
|
27
|
+
configs = (0, lodash_1.filter)(configs, config => !STEPZEN_DEFAULTS.includes(config));
|
|
28
|
+
if (configs.length > 0) {
|
|
29
|
+
const sourceConfig = path.join(source, 'config.yaml');
|
|
30
|
+
if (!fs.existsSync(sourceConfig)) {
|
|
31
|
+
throw new Error('No config.yaml found');
|
|
32
|
+
}
|
|
33
|
+
const content = fs.readFileSync(sourceConfig, 'utf8');
|
|
34
|
+
const asYaml = yaml.parse(content);
|
|
35
|
+
for (const config of configs) {
|
|
36
|
+
const found = asYaml?.configurationset?.find((c) => {
|
|
37
|
+
return c?.configuration?.name === config;
|
|
38
|
+
});
|
|
39
|
+
if (!found) {
|
|
40
|
+
throw new Error(`Could not find configuration item for "${config}"`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validators/config-exists/index.ts"],"names":[],"mappings":";;AAAA,qCAA2C;AAC3C,mCAAmC;AACnC,yBAAwB;AACxB,6BAA4B;AAC5B,6BAA4B;AAE5B,MAAM,gBAAgB,GAAG;IACvB,eAAe;IACf,oBAAoB;IACpB,eAAe;IACf,aAAa;IACb,aAAa;CACd,CAAA;AAED,kBAAe,CAAC,GAAiB,EAAE,MAAc,EAAE,EAAE;IACnD,IAAI,OAAO,GAAQ,EAAE,CAAA;IAErB,IAAA,eAAK,EAAC,GAAG,EAAE;QACT,QAAQ,CAAC,IAAS;YAChB,MAAM,IAAI,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sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":";AAEA,wBAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":";;AAAA,mDAA0C;AAE1C,kBAAe,CAAC,uBAAY,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stepzen/transpiler",
|
|
3
|
+
"description": "The StepZen transpiler",
|
|
4
|
+
"version": "0.0.0-experimental-20221114-610843f6",
|
|
5
|
+
"author": "Darren Waddell <darren@stepzen.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/**/*",
|
|
9
|
+
"src/**/*"
|
|
10
|
+
],
|
|
11
|
+
"main": "lib/index.js",
|
|
12
|
+
"types": "lib/index.d.ts",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=14.0.1",
|
|
15
|
+
"npm": ">=6.14"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"clean": "rm -rf lib tsconfig.tsbuildinfo",
|
|
19
|
+
"build": "../../node_modules/.bin/tsc -b",
|
|
20
|
+
"test": "npm run build && nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
21
|
+
"test:single": "npm run build && mocha",
|
|
22
|
+
"posttest": "prettier . --check"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@graphql-tools/merge": "^6.2.17",
|
|
26
|
+
"@stepzen/fetch": "^0.0.0-experimental-20221114-610843f6",
|
|
27
|
+
"debug": "^4.3.4",
|
|
28
|
+
"dotenv": "^10.0.0",
|
|
29
|
+
"fs-extra": "^9.1.0",
|
|
30
|
+
"glob": "^7.2.3",
|
|
31
|
+
"graphql": "^15.8.0",
|
|
32
|
+
"inquirer": "^8.2.4",
|
|
33
|
+
"lodash": "^4.17.21",
|
|
34
|
+
"prettier": "^2.7.1",
|
|
35
|
+
"shelljs": "^0.8.5",
|
|
36
|
+
"yaml": "^1.10.2"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/debug": "^4.1.7",
|
|
40
|
+
"@types/fs-extra": "^9.0.11",
|
|
41
|
+
"@types/glob": "^7.2.0",
|
|
42
|
+
"@types/inquirer": "^7.3.1",
|
|
43
|
+
"@types/lodash": "^4.14.168",
|
|
44
|
+
"@types/mocha": "^8.2.2",
|
|
45
|
+
"@types/mock-fs": "^4.13.0",
|
|
46
|
+
"@types/prettier": "^2.4.4",
|
|
47
|
+
"@types/shelljs": "^0.8.9",
|
|
48
|
+
"chai": "^4.3.4",
|
|
49
|
+
"fancy-test": "^1.4.10",
|
|
50
|
+
"mocha": "^9.0.1",
|
|
51
|
+
"mock-fs": "^4.13.0",
|
|
52
|
+
"node-ts": "^5.1.1",
|
|
53
|
+
"nyc": "^14.1.1",
|
|
54
|
+
"ts-node": "^10.8.2"
|
|
55
|
+
},
|
|
56
|
+
"gitHead": "956064c78cdc0cdcfa085a34ab3d9267bd08e649"
|
|
57
|
+
}
|