@stepzen/transpiler 0.0.32 → 0.0.35
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 +1 -1
- package/lib/actions/configure.js +15 -14
- package/lib/actions/configure.js.map +1 -0
- package/lib/actions/lint.js +6 -5
- package/lib/actions/lint.js.map +1 -0
- package/lib/actions/merge.js +14 -15
- package/lib/actions/merge.js.map +1 -0
- package/lib/actions/print.d.ts +1 -1
- package/lib/actions/print.js +2 -1
- package/lib/actions/print.js.map +1 -0
- package/lib/actions/stitch.js +14 -13
- package/lib/actions/stitch.js.map +1 -0
- package/lib/actions/transpile.js +7 -6
- package/lib/actions/transpile.js.map +1 -0
- package/lib/actions/validate.js +4 -3
- package/lib/actions/validate.js.map +1 -0
- package/lib/index.d.ts +7 -1
- package/lib/index.js +16 -16
- package/lib/index.js.map +1 -0
- package/lib/mutations/config/envvars.js +3 -2
- package/lib/mutations/config/envvars.js.map +1 -0
- package/lib/mutations/config/index.js +1 -0
- package/lib/mutations/config/index.js.map +1 -0
- package/lib/utils/constants.js +2 -1
- package/lib/utils/constants.js.map +1 -0
- package/lib/utils/dedupe-query-and-mutation-types.js +7 -6
- package/lib/utils/dedupe-query-and-mutation-types.js.map +1 -0
- package/lib/utils/ensure-query-and-mutation-types.d.ts +1 -1
- package/lib/utils/ensure-query-and-mutation-types.js +7 -6
- package/lib/utils/ensure-query-and-mutation-types.js.map +1 -0
- package/lib/utils/graphql-helpers.js +1 -0
- package/lib/utils/graphql-helpers.js.map +1 -0
- package/lib/utils/merge-helpers.d.ts +1 -1
- package/lib/utils/merge-helpers.js +9 -6
- package/lib/utils/merge-helpers.js.map +1 -0
- package/lib/utils/set-files-in-sdl.js +9 -8
- package/lib/utils/set-files-in-sdl.js.map +1 -0
- package/lib/utils/strip-empty-queries-and-mutations.d.ts +1 -1
- package/lib/utils/strip-empty-queries-and-mutations.js +7 -6
- package/lib/utils/strip-empty-queries-and-mutations.js.map +1 -0
- package/lib/validators/config-exists/index.d.ts +1 -1
- package/lib/validators/config-exists/index.js +11 -10
- package/lib/validators/config-exists/index.js.map +1 -0
- package/lib/validators/index.js +1 -0
- package/lib/validators/index.js.map +1 -0
- package/package.json +24 -16
- package/src/actions/configure.ts +120 -0
- package/src/actions/lint.ts +45 -0
- package/src/actions/merge.ts +186 -0
- package/src/actions/print.ts +8 -0
- package/src/actions/stitch.ts +105 -0
- package/src/actions/transpile.ts +70 -0
- package/src/actions/validate.ts +54 -0
- package/src/index.ts +7 -0
- package/src/mutations/config/envvars.ts +17 -0
- package/src/mutations/config/index.ts +3 -0
- package/src/utils/constants.ts +16 -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 +176 -0
- package/src/utils/set-files-in-sdl.ts +40 -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,54 @@
|
|
|
1
|
+
import {DocumentNode, visit} from 'graphql'
|
|
2
|
+
import {filter, uniq} from 'lodash'
|
|
3
|
+
import * as fs from 'fs'
|
|
4
|
+
import * as path from 'path'
|
|
5
|
+
import * as yaml from 'yaml'
|
|
6
|
+
|
|
7
|
+
const STEPZEN_DEFAULTS = [
|
|
8
|
+
'fedex_default',
|
|
9
|
+
'holidayapi_default',
|
|
10
|
+
'ipapi_default',
|
|
11
|
+
'owm_default',
|
|
12
|
+
'ups_default',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
export default (ast: DocumentNode, source: string) => {
|
|
16
|
+
let configs: any = []
|
|
17
|
+
|
|
18
|
+
visit(ast, {
|
|
19
|
+
Argument(node: any) {
|
|
20
|
+
const name = node.name?.value
|
|
21
|
+
const value = node.value?.value
|
|
22
|
+
|
|
23
|
+
if (name === 'configuration') {
|
|
24
|
+
configs = configs.concat(value)
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
configs = uniq(configs)
|
|
30
|
+
configs = filter(configs, config => !STEPZEN_DEFAULTS.includes(config))
|
|
31
|
+
|
|
32
|
+
if (configs.length > 0) {
|
|
33
|
+
const sourceConfig = path.join(source, 'config.yaml')
|
|
34
|
+
|
|
35
|
+
if (!fs.existsSync(sourceConfig)) {
|
|
36
|
+
throw new Error('No config.yaml found')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const content = fs.readFileSync(sourceConfig, 'utf8')
|
|
40
|
+
const asYaml = yaml.parse(content)
|
|
41
|
+
|
|
42
|
+
for (const config of configs) {
|
|
43
|
+
const found = asYaml?.configurationset?.find((c: any) => {
|
|
44
|
+
return c?.configuration?.name === config
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
if (!found) {
|
|
48
|
+
throw new Error(`Could not find configuration item for "${config}"`)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return true
|
|
54
|
+
}
|