@stepzen/transpiler 0.44.0 → 0.45.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actions/configure.js +7 -9
- package/lib/actions/configure.js.map +1 -1
- package/lib/actions/lint.js +12 -14
- package/lib/actions/lint.js.map +1 -1
- package/lib/actions/merge.d.ts +1 -1
- package/lib/actions/merge.d.ts.map +1 -1
- package/lib/actions/merge.js +43 -45
- package/lib/actions/merge.js.map +1 -1
- package/lib/actions/print.js +4 -6
- package/lib/actions/print.js.map +1 -1
- package/lib/actions/stitch.js +23 -25
- package/lib/actions/stitch.js.map +1 -1
- package/lib/actions/transpile.js +18 -20
- package/lib/actions/transpile.js.map +1 -1
- package/lib/actions/validate.js +13 -15
- package/lib/actions/validate.js.map +1 -1
- package/lib/index.d.ts +7 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -17
- package/lib/index.js.map +1 -1
- package/lib/mutations/config/envvars.js +2 -4
- package/lib/mutations/config/envvars.js.map +1 -1
- package/lib/mutations/config/index.js +2 -4
- package/lib/mutations/config/index.js.map +1 -1
- package/lib/utils/constants.js +5 -8
- package/lib/utils/constants.js.map +1 -1
- package/lib/utils/copy-workspace-content.js +9 -13
- package/lib/utils/copy-workspace-content.js.map +1 -1
- package/lib/utils/dedupe-query-and-mutation-types.js +8 -10
- package/lib/utils/dedupe-query-and-mutation-types.js.map +1 -1
- package/lib/utils/ensure-query-and-mutation-types.js +6 -8
- package/lib/utils/ensure-query-and-mutation-types.js.map +1 -1
- package/lib/utils/graphql-helpers.d.ts +1 -1
- package/lib/utils/graphql-helpers.d.ts.map +1 -1
- package/lib/utils/graphql-helpers.js +1 -5
- package/lib/utils/graphql-helpers.js.map +1 -1
- package/lib/utils/merge-helpers.js +47 -61
- package/lib/utils/merge-helpers.js.map +1 -1
- package/lib/utils/rmtemp.js +6 -10
- package/lib/utils/rmtemp.js.map +1 -1
- package/lib/utils/set-files-in-sdl.d.ts +2 -3
- package/lib/utils/set-files-in-sdl.d.ts.map +1 -1
- package/lib/utils/set-files-in-sdl.js +39 -42
- package/lib/utils/set-files-in-sdl.js.map +1 -1
- package/lib/utils/strip-empty-queries-and-mutations.js +7 -9
- package/lib/utils/strip-empty-queries-and-mutations.js.map +1 -1
- package/lib/validators/config-exists/index.js +9 -11
- package/lib/validators/config-exists/index.js.map +1 -1
- package/lib/validators/index.js +2 -4
- package/lib/validators/index.js.map +1 -1
- package/package.json +16 -12
- package/src/actions/configure.ts +6 -6
- package/src/actions/lint.ts +8 -8
- package/src/actions/merge.ts +12 -12
- package/src/actions/print.ts +1 -1
- package/src/actions/stitch.ts +11 -11
- package/src/actions/transpile.ts +11 -11
- package/src/actions/validate.ts +6 -6
- package/src/index.ts +7 -7
- package/src/mutations/config/envvars.ts +1 -1
- package/src/mutations/config/index.ts +1 -1
- package/src/utils/constants.ts +2 -2
- package/src/utils/copy-workspace-content.ts +5 -5
- package/src/utils/dedupe-query-and-mutation-types.ts +1 -1
- package/src/utils/ensure-query-and-mutation-types.ts +1 -1
- package/src/utils/graphql-helpers.ts +3 -1
- package/src/utils/merge-helpers.ts +14 -14
- package/src/utils/rmtemp.ts +4 -4
- package/src/utils/set-files-in-sdl.ts +27 -21
- package/src/utils/strip-empty-queries-and-mutations.ts +1 -1
- package/src/validators/config-exists/index.ts +4 -4
- package/src/validators/index.ts +1 -1
package/lib/actions/validate.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.default = (source, options = {
|
|
2
|
+
import { buildASTSchema, parse, print } from 'graphql';
|
|
3
|
+
import fsx from 'fs-extra';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import ensureQueryAndMutationTypes from '../utils/ensure-query-and-mutation-types.js';
|
|
7
|
+
import { EXPERIMENTAL_EXTENSIONS } from '../utils/constants.js';
|
|
8
|
+
import validators from '../validators/index.js';
|
|
9
|
+
export default (source, options = {
|
|
12
10
|
extensions: '',
|
|
13
11
|
}) => {
|
|
14
12
|
// Ensure source and output directories exist
|
|
@@ -23,16 +21,16 @@ exports.default = (source, options = {
|
|
|
23
21
|
const file = path.join(source, 'index.graphql');
|
|
24
22
|
const index = fsx.readFileSync(file, 'utf8');
|
|
25
23
|
// Parse
|
|
26
|
-
let ast =
|
|
24
|
+
let ast = parse(`${EXPERIMENTAL_EXTENSIONS}${os.EOL}${options.extensions}${os.EOL}${index}`, {
|
|
27
25
|
noLocation: true,
|
|
28
26
|
});
|
|
29
27
|
// We make an exception for 'no type Query' or 'no type Mutation'
|
|
30
|
-
ast = (
|
|
28
|
+
ast = ensureQueryAndMutationTypes(ast);
|
|
31
29
|
// Build and print, to validate
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
buildASTSchema(ast);
|
|
31
|
+
print(ast);
|
|
34
32
|
// Custom validators
|
|
35
|
-
for (const validator of
|
|
33
|
+
for (const validator of validators) {
|
|
36
34
|
validator(ast, source);
|
|
37
35
|
}
|
|
38
36
|
// Return true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/actions/validate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/actions/validate.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,EAAC,cAAc,EAAgB,KAAK,EAAE,KAAK,EAAC,MAAM,SAAS,CAAA;AAClE,OAAO,GAAG,MAAM,UAAU,CAAA;AAC1B,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,2BAA2B,MAAM,6CAA6C,CAAA;AACrF,OAAO,EAAC,uBAAuB,E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export { default as configure } from './actions/configure';
|
|
2
|
-
export { default as lint } from './actions/lint';
|
|
3
|
-
export { default as merge } from './actions/merge';
|
|
4
|
-
export { default as print } from './actions/print';
|
|
5
|
-
export { default as stitch } from './actions/stitch';
|
|
6
|
-
export { default as transpile } from './actions/transpile';
|
|
7
|
-
export { default as validate } from './actions/validate';
|
|
1
|
+
export { default as configure } from './actions/configure.js';
|
|
2
|
+
export { default as lint } from './actions/lint.js';
|
|
3
|
+
export { default as merge } from './actions/merge.js';
|
|
4
|
+
export { default as print } from './actions/print.js';
|
|
5
|
+
export { default as stitch } from './actions/stitch.js';
|
|
6
|
+
export { default as transpile } from './actions/transpile.js';
|
|
7
|
+
export { default as validate } from './actions/validate.js';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,uBAAuB,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, "merge", { enumerable: true, get: function () { return merge_1.default; } });
|
|
11
|
-
var print_1 = require("./actions/print");
|
|
12
|
-
Object.defineProperty(exports, "print", { enumerable: true, get: function () { return print_1.default; } });
|
|
13
|
-
var stitch_1 = require("./actions/stitch");
|
|
14
|
-
Object.defineProperty(exports, "stitch", { enumerable: true, get: function () { return stitch_1.default; } });
|
|
15
|
-
var transpile_1 = require("./actions/transpile");
|
|
16
|
-
Object.defineProperty(exports, "transpile", { enumerable: true, get: function () { return transpile_1.default; } });
|
|
17
|
-
var validate_1 = require("./actions/validate");
|
|
18
|
-
Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return validate_1.default; } });
|
|
2
|
+
export { default as configure } from './actions/configure.js';
|
|
3
|
+
export { default as lint } from './actions/lint.js';
|
|
4
|
+
export { default as merge } from './actions/merge.js';
|
|
5
|
+
export { default as print } from './actions/print.js';
|
|
6
|
+
export { default as stitch } from './actions/stitch.js';
|
|
7
|
+
export { default as transpile } from './actions/transpile.js';
|
|
8
|
+
export { default as validate } from './actions/validate.js';
|
|
19
9
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,uBAAuB,CAAA"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
|
|
4
|
-
const debug = require("debug");
|
|
2
|
+
import debug from 'debug';
|
|
5
3
|
function replaceVars(value, envvars, path = '') {
|
|
6
4
|
if (!value) {
|
|
7
5
|
return [value, 0];
|
|
@@ -34,7 +32,7 @@ function replaceVars(value, envvars, path = '') {
|
|
|
34
32
|
return [value, 0];
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
|
-
|
|
35
|
+
export default async (config) => {
|
|
38
36
|
const envvars = Object.keys(process.env)
|
|
39
37
|
.filter(key => {
|
|
40
38
|
return key.startsWith(`STEPZEN_`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envvars.js","sourceRoot":"","sources":["../../../src/mutations/config/envvars.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"envvars.js","sourceRoot":"","sources":["../../../src/mutations/config/envvars.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,SAAS,WAAW,CAClB,KAAQ,EACR,OAA+B,EAC/B,IAAI,GAAG,EAAE;IAET,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACnB,CAAC;IAED,IAAI,YAAY,GAAG,CAAC,CAAA;IACpB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,OAA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C;QAED;YACE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACrB,CAAC;AACH,CAAC;AAED,eAAe,KAAK,EAClB,MAA2B,EACG,EAAE;IAChC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;SACrC,MAAM,CAAC,GAAG,CAAC,EAAE;QACZ,OAAO,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;IACnC,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,GAAQ,EAAE,GAAG,EAAE,EAAE;QACxB,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC3B,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,CAAC,CAAA;IAER,KAAK,CAAC,2BAA2B,CAAC,CAChC,+CAA+C;QAC7C,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAC3D,CAAA;IAED,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzC,KAAK,CAAC,2BAA2B,CAAC,CAChC,oDAAoD,CACrD,CAAA;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAED,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5D,KAAK,CAAC,2BAA2B,CAAC,CAAC,4BAA4B,YAAY,EAAE,CAAC,CAAA;IAE9E,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.default = [envvars_1.default];
|
|
2
|
+
import envvars from './envvars.js';
|
|
3
|
+
export default [envvars];
|
|
6
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mutations/config/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mutations/config/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,OAAO,MAAM,cAAc,CAAA;AAElC,eAAe,CAAC,OAAO,CAAC,CAAA"}
|
package/lib/utils/constants.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const dotenv = require("dotenv");
|
|
6
|
-
const debug = require("debug");
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
import debug from 'debug';
|
|
7
4
|
debug('stepzen:dotenv')(`loading .env from ${process.cwd()}, at transpiler/src/utils/constants.ts`);
|
|
8
5
|
dotenv.config();
|
|
9
6
|
const { STEPZEN_SERVER_URL: ENV_VAR_STEPZEN_SERVER_URL } = process.env;
|
|
10
|
-
|
|
7
|
+
export const EXPERIMENTAL_EXTENSIONS = `
|
|
11
8
|
directive @experimental(
|
|
12
9
|
debug: Boolean
|
|
13
10
|
function: String
|
|
@@ -15,6 +12,6 @@ directive @experimental(
|
|
|
15
12
|
setter: String
|
|
16
13
|
) on OBJECT | FIELD_DEFINITION
|
|
17
14
|
`;
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
export const STEPZEN_SERVER_URL = ENV_VAR_STEPZEN_SERVER_URL || 'https://{account}.stepzen.io';
|
|
16
|
+
export const ALL_GRAPHQL_FILES = '**/*.graphql';
|
|
20
17
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,KAAK,CAAC,gBAAgB,CAAC,CACrB,qBAAqB,OAAO,CAAC,GAAG,EAAE,wCAAwC,CAC3E,CAAA;AACD,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,EAAC,kBAAkB,EAAE,0BAA0B,EAAC,GAAG,OAAO,CAAC,GAAG,CAAA;AAEpE,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;CAOtC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAC7B,0BAA0B,IAAI,8BAA8B,CAAA;AAE9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAA"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const lodash_1 = require("lodash");
|
|
9
|
-
const constants_1 = require("./constants");
|
|
2
|
+
import fsx from 'fs-extra';
|
|
3
|
+
import glob from 'glob';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { flatMap } from 'lodash-es';
|
|
6
|
+
import { ALL_GRAPHQL_FILES } from './constants.js';
|
|
10
7
|
const WORKSPACE_FILE_PATTERNS = [
|
|
11
8
|
'**/*.graphql',
|
|
12
9
|
'stepzen.config.json',
|
|
@@ -24,11 +21,11 @@ const IGNORED_PATTERNS = ['node_modules/**'];
|
|
|
24
21
|
* Exclude all other files.
|
|
25
22
|
* Exclude special folders, e.g. node_modules
|
|
26
23
|
*/
|
|
27
|
-
|
|
24
|
+
export default (srcPath, dstPath) => {
|
|
28
25
|
if (!fsx.existsSync(srcPath)) {
|
|
29
26
|
throw new Error(`Cannot find source directory ${srcPath}`);
|
|
30
27
|
}
|
|
31
|
-
|
|
28
|
+
flatMap(WORKSPACE_FILE_PATTERNS, pattern => glob.sync(pattern, {
|
|
32
29
|
cwd: srcPath,
|
|
33
30
|
ignore: IGNORED_PATTERNS,
|
|
34
31
|
})).forEach(relativePath => {
|
|
@@ -38,10 +35,9 @@ exports.default = (srcPath, dstPath) => {
|
|
|
38
35
|
fsx.copyFileSync(srcFileFullPath, dstFileFullPath);
|
|
39
36
|
});
|
|
40
37
|
};
|
|
41
|
-
const getAllGraphQLFiles = (srcPath) => {
|
|
38
|
+
export const getAllGraphQLFiles = (srcPath) => {
|
|
42
39
|
return glob
|
|
43
|
-
.sync(
|
|
40
|
+
.sync(ALL_GRAPHQL_FILES, { cwd: srcPath })
|
|
44
41
|
.filter(file => file !== 'index.graphql');
|
|
45
42
|
};
|
|
46
|
-
exports.getAllGraphQLFiles = getAllGraphQLFiles;
|
|
47
43
|
//# sourceMappingURL=copy-workspace-content.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-workspace-content.js","sourceRoot":"","sources":["../../src/utils/copy-workspace-content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"copy-workspace-content.js","sourceRoot":"","sources":["../../src/utils/copy-workspace-content.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,GAAG,MAAM,UAAU,CAAA;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAA;AAEhD,MAAM,uBAAuB,GAAG;IAC9B,cAAc;IACd,qBAAqB;IACrB,aAAa;CACd,CAAA;AAED,MAAM,gBAAgB,GAAG,CAAC,iBAAiB,CAAC,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,eAAe,CAAC,OAAe,EAAE,OAAe,EAAE,EAAE;IAClD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,gCAAgC,OAAO,EAAE,CAAC,CAAA;IAC5D,CAAC;IAED,OAAO,CAAC,uBAAuB,EAAE,OAAO,CAAC,EAAE,CACzC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QACjB,GAAG,EAAE,OAAO;QACZ,MAAM,EAAE,gBAAgB;KACzB,CAAC,CACH,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;QACvB,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;QACxD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;QACxD,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAA;QAChD,GAAG,CAAC,YAAY,CAAC,eAAe,EAAE,eAAe,CAAC,CAAA;IACpD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAE,EAAE;IACpD,OAAO,IAAI;SACR,IAAI,CAAC,iBAAiB,EAAE,EAAC,GAAG,EAAE,OAAO,EAAC,CAAC;SACvC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,eAAe,CAAC,CAAA;AAC7C,CAAC,CAAA"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let ast = (0, graphql_1.parse)(schema);
|
|
2
|
+
import { parse, print, visit } from 'graphql';
|
|
3
|
+
import { cloneDeep } from '../utils/graphql-helpers.js';
|
|
4
|
+
export default (schema) => {
|
|
5
|
+
let ast = parse(schema);
|
|
8
6
|
let queries = [];
|
|
9
7
|
let mutations = [];
|
|
10
8
|
// Loop through the AST and find Query and Mutation types.
|
|
11
9
|
// Store their fields.
|
|
12
10
|
// Return null to remove it from the tree
|
|
13
|
-
ast =
|
|
11
|
+
ast = visit(ast, {
|
|
14
12
|
ObjectTypeDefinition: {
|
|
15
13
|
enter(node) {
|
|
16
14
|
if (node.name.kind === 'Name' && node.name.value === 'Query') {
|
|
@@ -45,7 +43,7 @@ exports.default = (schema) => {
|
|
|
45
43
|
// If there are queries, add a single Query type
|
|
46
44
|
// with all the concatenated queries
|
|
47
45
|
if (queries.length > 0) {
|
|
48
|
-
const mutated =
|
|
46
|
+
const mutated = cloneDeep(ast);
|
|
49
47
|
const query = {
|
|
50
48
|
...queryTemplate,
|
|
51
49
|
fields: queries,
|
|
@@ -56,7 +54,7 @@ exports.default = (schema) => {
|
|
|
56
54
|
// If there are mutations, add a single Query type
|
|
57
55
|
// with all the concatenated mutations
|
|
58
56
|
if (mutations.length > 0) {
|
|
59
|
-
const mutated =
|
|
57
|
+
const mutated = cloneDeep(ast);
|
|
60
58
|
const query = {
|
|
61
59
|
...mutationTemplate,
|
|
62
60
|
fields: mutations,
|
|
@@ -64,6 +62,6 @@ exports.default = (schema) => {
|
|
|
64
62
|
mutated.definitions.push(query);
|
|
65
63
|
ast = mutated;
|
|
66
64
|
}
|
|
67
|
-
return
|
|
65
|
+
return print(ast);
|
|
68
66
|
};
|
|
69
67
|
//# sourceMappingURL=dedupe-query-and-mutation-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dedupe-query-and-mutation-types.js","sourceRoot":"","sources":["../../src/utils/dedupe-query-and-mutation-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dedupe-query-and-mutation-types.js","sourceRoot":"","sources":["../../src/utils/dedupe-query-and-mutation-types.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,EAAe,KAAK,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,SAAS,CAAA;AAEzD,OAAO,EAAC,SAAS,E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EAAE;QACd,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,EAAE;KACX,CAAA;IAED,gDAAgD;IAChD,oCAAoC;IACpC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,OAAO,GAAQ,SAAS,CAAC,GAAG,CAAC,CAAA;QACnC,MAAM,KAAK,GAAG;YACZ,GAAG,aAAa;YAChB,MAAM,EAAE,OAAO;SAChB,CAAA;QACD,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC/B,GAAG,GAAG,OAAO,CAAA;IACf,CAAC;IAED,kDAAkD;IAClD,sCAAsC;IACtC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,OAAO,GAAQ,SAAS,CAAC,GAAG,CAAC,CAAA;QACnC,MAAM,KAAK,GAAG;YACZ,GAAG,gBAAgB;YACnB,MAAM,EAAE,SAAS;SAClB,CAAA;QACD,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC/B,GAAG,GAAG,OAAO,CAAA;IACf,CAAC;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,CAAA;AACnB,CAAC,CAAA"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.default = (ast) => {
|
|
2
|
+
import { visit } from 'graphql';
|
|
3
|
+
import { cloneDeep } from '../utils/graphql-helpers.js';
|
|
4
|
+
export default (ast) => {
|
|
7
5
|
let queries = [];
|
|
8
6
|
let mutations = [];
|
|
9
7
|
// Loop through the AST and find Query and Mutation types.
|
|
10
|
-
ast =
|
|
8
|
+
ast = visit(ast, {
|
|
11
9
|
ObjectTypeDefinition: {
|
|
12
10
|
enter(node) {
|
|
13
11
|
if (node.name.kind === 'Name' && node.name.value === 'Query') {
|
|
@@ -21,7 +19,7 @@ exports.default = (ast) => {
|
|
|
21
19
|
});
|
|
22
20
|
// If there are no queries, add a single empty Query type
|
|
23
21
|
if (queries.length === 0) {
|
|
24
|
-
const mutated =
|
|
22
|
+
const mutated = cloneDeep(ast);
|
|
25
23
|
mutated.definitions.push({
|
|
26
24
|
kind: 'ObjectTypeDefinition',
|
|
27
25
|
description: undefined,
|
|
@@ -34,7 +32,7 @@ exports.default = (ast) => {
|
|
|
34
32
|
}
|
|
35
33
|
// If there are mutations, add a single empty Mutation type
|
|
36
34
|
if (mutations.length === 0) {
|
|
37
|
-
const mutated =
|
|
35
|
+
const mutated = cloneDeep(ast);
|
|
38
36
|
mutated.definitions.push({
|
|
39
37
|
kind: 'ObjectTypeDefinition',
|
|
40
38
|
description: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-query-and-mutation-types.js","sourceRoot":"","sources":["../../src/utils/ensure-query-and-mutation-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ensure-query-and-mutation-types.js","sourceRoot":"","sources":["../../src/utils/ensure-query-and-mutation-types.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,EAAe,KAAK,EAAC,MAAM,SAAS,CAAA;AAE3C,OAAO,EAAC,SAAS,EAAC,MAAM,6BAA6B,CAAA;AAErD,eAAe,CAAC,GAAiB,EAAgB,EAAE;IACjD,IAAI,OAAO,GAAQ,EAAE,CAAA;IACrB,IAAI,SAAS,GAAQ,EAAE,CAAA;IAEvB,0DAA0D;IAC1D,GAAG,GAAG,KAAK,CAAC,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,CAAC;oBAC7D,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;gBACvC,CAAC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
|
|
1
|
+
{"version":3,"file":"graphql-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/graphql-helpers.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,GAC7C,CAAC,GACD;IAAC,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAC,CAAA;AACnD,eAAO,MAAM,SAAS,iCACW,CAAA"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
|
|
4
|
-
exports.cloneDeep = void 0;
|
|
5
|
-
const cloneDeep = (obj) => JSON.parse(JSON.stringify(obj));
|
|
6
|
-
exports.cloneDeep = cloneDeep;
|
|
2
|
+
export const cloneDeep = (obj) => JSON.parse(JSON.stringify(obj));
|
|
7
3
|
//# sourceMappingURL=graphql-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-helpers.js","sourceRoot":"","sources":["../../src/utils/graphql-helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graphql-helpers.js","sourceRoot":"","sources":["../../src/utils/graphql-helpers.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAKjC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,GAAM,EAAoB,EAAE,CACvD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA"}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const rmtemp_1 = require("./rmtemp");
|
|
19
|
-
const dedupeTempFolder = (dirpath) => {
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import { BREAK, Kind, visit } from 'graphql';
|
|
4
|
+
import { buildSchema } from 'graphql/utilities/index.js';
|
|
5
|
+
import fetch from '@stepzen/fetch';
|
|
6
|
+
import fsx from 'fs-extra';
|
|
7
|
+
import glob from 'glob';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { replace } from 'lodash-es';
|
|
11
|
+
import { cloneDeep } from '../utils/graphql-helpers.js';
|
|
12
|
+
import { STEPZEN_SERVER_URL } from './constants.js';
|
|
13
|
+
import configure from '../actions/configure.js';
|
|
14
|
+
import transpile from '../actions/transpile.js';
|
|
15
|
+
import { rmtemp } from './rmtemp.js';
|
|
16
|
+
export const dedupeTempFolder = (dirpath) => {
|
|
20
17
|
do {
|
|
21
|
-
dirpath =
|
|
18
|
+
dirpath = replace(dirpath, os.tmpdir(), '');
|
|
22
19
|
} while (dirpath.includes(os.tmpdir()));
|
|
23
20
|
dirpath = path.join(os.tmpdir(), dirpath);
|
|
24
21
|
return dirpath;
|
|
25
22
|
};
|
|
26
|
-
|
|
27
|
-
const findNextAvailableSubfolder = (folder, name) => {
|
|
23
|
+
export const findNextAvailableSubfolder = (folder, name) => {
|
|
28
24
|
let subfolder = name;
|
|
29
25
|
let counter = 1;
|
|
30
26
|
while (fsx.existsSync(path.join(folder, subfolder))) {
|
|
@@ -33,24 +29,23 @@ const findNextAvailableSubfolder = (folder, name) => {
|
|
|
33
29
|
}
|
|
34
30
|
return subfolder;
|
|
35
31
|
};
|
|
36
|
-
exports.findNextAvailableSubfolder = findNextAvailableSubfolder;
|
|
37
32
|
const isQueryMutationSubscription = (ancestors) => {
|
|
38
33
|
if (Array.isArray(ancestors[ancestors.length - 1])) {
|
|
39
34
|
return false;
|
|
40
35
|
}
|
|
41
36
|
const ancestor = ancestors[ancestors.length - 1];
|
|
42
|
-
return (ancestor.kind ===
|
|
37
|
+
return (ancestor.kind === Kind.OBJECT_TYPE_DEFINITION &&
|
|
43
38
|
['Query', 'Mutation', 'Subscription'].includes(ancestor.name.value));
|
|
44
39
|
};
|
|
45
|
-
const findQueryMutationInSchema = (name, files) => {
|
|
40
|
+
export const findQueryMutationInSchema = (name, files) => {
|
|
46
41
|
for (const file of files) {
|
|
47
42
|
let found = false;
|
|
48
|
-
|
|
43
|
+
visit(file.ast, {
|
|
49
44
|
FieldDefinition(node, _key, _parent, _path, ancestors) {
|
|
50
45
|
if (isQueryMutationSubscription(ancestors) &&
|
|
51
46
|
node.name.value === name) {
|
|
52
47
|
found = true;
|
|
53
|
-
return
|
|
48
|
+
return BREAK;
|
|
54
49
|
}
|
|
55
50
|
},
|
|
56
51
|
});
|
|
@@ -59,15 +54,14 @@ const findQueryMutationInSchema = (name, files) => {
|
|
|
59
54
|
}
|
|
60
55
|
return false;
|
|
61
56
|
};
|
|
62
|
-
|
|
63
|
-
const findTypeInSchema = (name, files) => {
|
|
57
|
+
export const findTypeInSchema = (name, files) => {
|
|
64
58
|
for (const file of files) {
|
|
65
59
|
let found = false;
|
|
66
|
-
|
|
60
|
+
visit(file.ast, {
|
|
67
61
|
ObjectTypeDefinition(node) {
|
|
68
62
|
if (node.name.value === name) {
|
|
69
63
|
found = true;
|
|
70
|
-
return
|
|
64
|
+
return BREAK;
|
|
71
65
|
}
|
|
72
66
|
},
|
|
73
67
|
});
|
|
@@ -76,8 +70,7 @@ const findTypeInSchema = (name, files) => {
|
|
|
76
70
|
}
|
|
77
71
|
return false;
|
|
78
72
|
};
|
|
79
|
-
|
|
80
|
-
const getConfiguration = async (directories, silent = false, answers = {}) => {
|
|
73
|
+
export const getConfiguration = async (directories, silent = false, answers = {}) => {
|
|
81
74
|
const tmp = path.join(os.tmpdir(), `stepzen-tmp-config-${Date.now()}`);
|
|
82
75
|
fsx.ensureDirSync(tmp);
|
|
83
76
|
try {
|
|
@@ -89,47 +82,44 @@ const getConfiguration = async (directories, silent = false, answers = {}) => {
|
|
|
89
82
|
for (const config of configs) {
|
|
90
83
|
const configFolder = path.join(directory, config);
|
|
91
84
|
let writeFolder = path.join(tmp, directory, config);
|
|
92
|
-
writeFolder =
|
|
85
|
+
writeFolder = dedupeTempFolder(writeFolder);
|
|
93
86
|
const content = fsx.readFileSync(configFolder, 'utf8');
|
|
94
87
|
fsx.ensureFileSync(writeFolder);
|
|
95
88
|
fsx.writeFileSync(writeFolder, content, { mode: 0o600 });
|
|
96
89
|
}
|
|
97
90
|
}
|
|
98
|
-
const configuration = await (
|
|
91
|
+
const configuration = await configure(tmp, silent, answers);
|
|
99
92
|
return configuration;
|
|
100
93
|
}
|
|
101
94
|
finally {
|
|
102
|
-
|
|
95
|
+
rmtemp(tmp);
|
|
103
96
|
}
|
|
104
97
|
};
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
const baseurl = constants_1.STEPZEN_SERVER_URL.replace('.io', '.net').replace('{account}', 'stepzen');
|
|
98
|
+
export const getExtensions = async () => {
|
|
99
|
+
const baseurl = STEPZEN_SERVER_URL.replace('.io', '.net').replace('{account}', 'stepzen');
|
|
108
100
|
const url = `${baseurl}/directives.graphql`;
|
|
109
101
|
const startedAt = new Date().getTime();
|
|
110
102
|
debug('stepzen:extensions')(`[transpiler] fetching StepZen extensions from ${url}`);
|
|
111
|
-
const response = await (
|
|
103
|
+
const response = await fetch(url);
|
|
112
104
|
const text = await response.text();
|
|
113
105
|
const doneAt = new Date().getTime();
|
|
114
106
|
debug('stepzen:extensions')(`[transpiler] fetched extensions (${text.length} bytes, ${doneAt - startedAt} ms)`);
|
|
115
107
|
return text;
|
|
116
108
|
};
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
return (0, utilities_1.buildSchema)(`${extensions}${os.EOL}${transpiled.schema}`);
|
|
109
|
+
export const getSchema = async (directory, extensions) => {
|
|
110
|
+
const transpiled = await transpile(directory);
|
|
111
|
+
return buildSchema(`${extensions}${os.EOL}${transpiled.schema}`);
|
|
121
112
|
};
|
|
122
|
-
|
|
123
|
-
const mergeQueryMutationIntoSchema = (type, files) => {
|
|
113
|
+
export const mergeQueryMutationIntoSchema = (type, files) => {
|
|
124
114
|
files = files.map((file) => {
|
|
125
115
|
return {
|
|
126
116
|
...file,
|
|
127
|
-
ast:
|
|
117
|
+
ast: visit(file.ast, {
|
|
128
118
|
FieldDefinition(node, _key, _parent, _path, ancestors) {
|
|
129
119
|
if (isQueryMutationSubscription(ancestors) &&
|
|
130
120
|
node.name.value === type.name.value) {
|
|
131
|
-
const directives =
|
|
132
|
-
const mutated =
|
|
121
|
+
const directives = cloneDeep(type.directives);
|
|
122
|
+
const mutated = cloneDeep(node);
|
|
133
123
|
mutated.directives = directives;
|
|
134
124
|
return mutated;
|
|
135
125
|
}
|
|
@@ -139,17 +129,16 @@ const mergeQueryMutationIntoSchema = (type, files) => {
|
|
|
139
129
|
});
|
|
140
130
|
return files;
|
|
141
131
|
};
|
|
142
|
-
|
|
143
|
-
const mergeTypeIntoSchema = (type, files) => {
|
|
132
|
+
export const mergeTypeIntoSchema = (type, files) => {
|
|
144
133
|
files = files.map((file) => {
|
|
145
134
|
return {
|
|
146
135
|
...file,
|
|
147
|
-
ast:
|
|
136
|
+
ast: visit(file.ast, {
|
|
148
137
|
ObjectTypeDefinition(node) {
|
|
149
138
|
if (node.name.value === type.name.value) {
|
|
150
|
-
const directives =
|
|
151
|
-
const fields =
|
|
152
|
-
const mutated =
|
|
139
|
+
const directives = cloneDeep(type.directives);
|
|
140
|
+
const fields = cloneDeep(type.fields);
|
|
141
|
+
const mutated = cloneDeep(node);
|
|
153
142
|
mutated.directives = directives;
|
|
154
143
|
mutated.fields = fields;
|
|
155
144
|
return mutated;
|
|
@@ -160,12 +149,11 @@ const mergeTypeIntoSchema = (type, files) => {
|
|
|
160
149
|
});
|
|
161
150
|
return files;
|
|
162
151
|
};
|
|
163
|
-
|
|
164
|
-
const removeQueryMutationFromSchema = (name, files) => {
|
|
152
|
+
export const removeQueryMutationFromSchema = (name, files) => {
|
|
165
153
|
files = files.map((file) => {
|
|
166
154
|
return {
|
|
167
155
|
...file,
|
|
168
|
-
ast:
|
|
156
|
+
ast: visit(file.ast, {
|
|
169
157
|
FieldDefinition(node, _key, _parent, _path, ancestors) {
|
|
170
158
|
if (isQueryMutationSubscription(ancestors) &&
|
|
171
159
|
node.name.value === name) {
|
|
@@ -177,12 +165,11 @@ const removeQueryMutationFromSchema = (name, files) => {
|
|
|
177
165
|
});
|
|
178
166
|
return files;
|
|
179
167
|
};
|
|
180
|
-
|
|
181
|
-
const removeTypeFromSchema = (name, files) => {
|
|
168
|
+
export const removeTypeFromSchema = (name, files) => {
|
|
182
169
|
files = files.map((file) => {
|
|
183
170
|
return {
|
|
184
171
|
...file,
|
|
185
|
-
ast:
|
|
172
|
+
ast: visit(file.ast, {
|
|
186
173
|
ObjectTypeDefinition(node) {
|
|
187
174
|
if (node.name.value === name) {
|
|
188
175
|
return null;
|
|
@@ -193,5 +180,4 @@ const removeTypeFromSchema = (name, files) => {
|
|
|
193
180
|
});
|
|
194
181
|
return files;
|
|
195
182
|
};
|
|
196
|
-
exports.removeTypeFromSchema = removeTypeFromSchema;
|
|
197
183
|
//# sourceMappingURL=merge-helpers.js.map
|