@stepzen/transpiler 0.0.34 → 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.
Files changed (64) hide show
  1. package/lib/actions/configure.js +15 -14
  2. package/lib/actions/configure.js.map +1 -0
  3. package/lib/actions/lint.js +6 -5
  4. package/lib/actions/lint.js.map +1 -0
  5. package/lib/actions/merge.js +14 -15
  6. package/lib/actions/merge.js.map +1 -0
  7. package/lib/actions/print.d.ts +1 -1
  8. package/lib/actions/print.js +2 -1
  9. package/lib/actions/print.js.map +1 -0
  10. package/lib/actions/stitch.js +14 -13
  11. package/lib/actions/stitch.js.map +1 -0
  12. package/lib/actions/transpile.js +7 -6
  13. package/lib/actions/transpile.js.map +1 -0
  14. package/lib/actions/validate.js +4 -3
  15. package/lib/actions/validate.js.map +1 -0
  16. package/lib/index.d.ts +7 -1
  17. package/lib/index.js +16 -16
  18. package/lib/index.js.map +1 -0
  19. package/lib/mutations/config/envvars.js +3 -2
  20. package/lib/mutations/config/envvars.js.map +1 -0
  21. package/lib/mutations/config/index.js +1 -0
  22. package/lib/mutations/config/index.js.map +1 -0
  23. package/lib/utils/constants.js +2 -1
  24. package/lib/utils/constants.js.map +1 -0
  25. package/lib/utils/dedupe-query-and-mutation-types.js +7 -6
  26. package/lib/utils/dedupe-query-and-mutation-types.js.map +1 -0
  27. package/lib/utils/ensure-query-and-mutation-types.d.ts +1 -1
  28. package/lib/utils/ensure-query-and-mutation-types.js +7 -6
  29. package/lib/utils/ensure-query-and-mutation-types.js.map +1 -0
  30. package/lib/utils/graphql-helpers.js +1 -0
  31. package/lib/utils/graphql-helpers.js.map +1 -0
  32. package/lib/utils/merge-helpers.d.ts +1 -1
  33. package/lib/utils/merge-helpers.js +5 -4
  34. package/lib/utils/merge-helpers.js.map +1 -0
  35. package/lib/utils/set-files-in-sdl.js +9 -8
  36. package/lib/utils/set-files-in-sdl.js.map +1 -0
  37. package/lib/utils/strip-empty-queries-and-mutations.d.ts +1 -1
  38. package/lib/utils/strip-empty-queries-and-mutations.js +7 -6
  39. package/lib/utils/strip-empty-queries-and-mutations.js.map +1 -0
  40. package/lib/validators/config-exists/index.d.ts +1 -1
  41. package/lib/validators/config-exists/index.js +11 -10
  42. package/lib/validators/config-exists/index.js.map +1 -0
  43. package/lib/validators/index.js +1 -0
  44. package/lib/validators/index.js.map +1 -0
  45. package/package.json +21 -13
  46. package/src/actions/configure.ts +120 -0
  47. package/src/actions/lint.ts +45 -0
  48. package/src/actions/merge.ts +186 -0
  49. package/src/actions/print.ts +8 -0
  50. package/src/actions/stitch.ts +105 -0
  51. package/src/actions/transpile.ts +70 -0
  52. package/src/actions/validate.ts +54 -0
  53. package/src/index.ts +7 -0
  54. package/src/mutations/config/envvars.ts +17 -0
  55. package/src/mutations/config/index.ts +3 -0
  56. package/src/utils/constants.ts +16 -0
  57. package/src/utils/dedupe-query-and-mutation-types.ts +74 -0
  58. package/src/utils/ensure-query-and-mutation-types.ts +52 -0
  59. package/src/utils/graphql-helpers.ts +3 -0
  60. package/src/utils/merge-helpers.ts +176 -0
  61. package/src/utils/set-files-in-sdl.ts +40 -0
  62. package/src/utils/strip-empty-queries-and-mutations.ts +43 -0
  63. package/src/validators/config-exists/index.ts +54 -0
  64. 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
+ }
@@ -0,0 +1,3 @@
1
+ import configExists from './config-exists'
2
+
3
+ export default [configExists]