@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.
Files changed (72) hide show
  1. package/lib/actions/configure.js +7 -9
  2. package/lib/actions/configure.js.map +1 -1
  3. package/lib/actions/lint.js +12 -14
  4. package/lib/actions/lint.js.map +1 -1
  5. package/lib/actions/merge.d.ts +1 -1
  6. package/lib/actions/merge.d.ts.map +1 -1
  7. package/lib/actions/merge.js +43 -45
  8. package/lib/actions/merge.js.map +1 -1
  9. package/lib/actions/print.js +4 -6
  10. package/lib/actions/print.js.map +1 -1
  11. package/lib/actions/stitch.js +23 -25
  12. package/lib/actions/stitch.js.map +1 -1
  13. package/lib/actions/transpile.js +18 -20
  14. package/lib/actions/transpile.js.map +1 -1
  15. package/lib/actions/validate.js +13 -15
  16. package/lib/actions/validate.js.map +1 -1
  17. package/lib/index.d.ts +7 -7
  18. package/lib/index.d.ts.map +1 -1
  19. package/lib/index.js +7 -17
  20. package/lib/index.js.map +1 -1
  21. package/lib/mutations/config/envvars.js +2 -4
  22. package/lib/mutations/config/envvars.js.map +1 -1
  23. package/lib/mutations/config/index.js +2 -4
  24. package/lib/mutations/config/index.js.map +1 -1
  25. package/lib/utils/constants.js +5 -8
  26. package/lib/utils/constants.js.map +1 -1
  27. package/lib/utils/copy-workspace-content.js +9 -13
  28. package/lib/utils/copy-workspace-content.js.map +1 -1
  29. package/lib/utils/dedupe-query-and-mutation-types.js +8 -10
  30. package/lib/utils/dedupe-query-and-mutation-types.js.map +1 -1
  31. package/lib/utils/ensure-query-and-mutation-types.js +6 -8
  32. package/lib/utils/ensure-query-and-mutation-types.js.map +1 -1
  33. package/lib/utils/graphql-helpers.d.ts +1 -1
  34. package/lib/utils/graphql-helpers.d.ts.map +1 -1
  35. package/lib/utils/graphql-helpers.js +1 -5
  36. package/lib/utils/graphql-helpers.js.map +1 -1
  37. package/lib/utils/merge-helpers.js +47 -61
  38. package/lib/utils/merge-helpers.js.map +1 -1
  39. package/lib/utils/rmtemp.js +6 -10
  40. package/lib/utils/rmtemp.js.map +1 -1
  41. package/lib/utils/set-files-in-sdl.d.ts +2 -3
  42. package/lib/utils/set-files-in-sdl.d.ts.map +1 -1
  43. package/lib/utils/set-files-in-sdl.js +39 -42
  44. package/lib/utils/set-files-in-sdl.js.map +1 -1
  45. package/lib/utils/strip-empty-queries-and-mutations.js +7 -9
  46. package/lib/utils/strip-empty-queries-and-mutations.js.map +1 -1
  47. package/lib/validators/config-exists/index.js +9 -11
  48. package/lib/validators/config-exists/index.js.map +1 -1
  49. package/lib/validators/index.js +2 -4
  50. package/lib/validators/index.js.map +1 -1
  51. package/package.json +16 -12
  52. package/src/actions/configure.ts +6 -6
  53. package/src/actions/lint.ts +8 -8
  54. package/src/actions/merge.ts +12 -12
  55. package/src/actions/print.ts +1 -1
  56. package/src/actions/stitch.ts +11 -11
  57. package/src/actions/transpile.ts +11 -11
  58. package/src/actions/validate.ts +6 -6
  59. package/src/index.ts +7 -7
  60. package/src/mutations/config/envvars.ts +1 -1
  61. package/src/mutations/config/index.ts +1 -1
  62. package/src/utils/constants.ts +2 -2
  63. package/src/utils/copy-workspace-content.ts +5 -5
  64. package/src/utils/dedupe-query-and-mutation-types.ts +1 -1
  65. package/src/utils/ensure-query-and-mutation-types.ts +1 -1
  66. package/src/utils/graphql-helpers.ts +3 -1
  67. package/src/utils/merge-helpers.ts +14 -14
  68. package/src/utils/rmtemp.ts +4 -4
  69. package/src/utils/set-files-in-sdl.ts +27 -21
  70. package/src/utils/strip-empty-queries-and-mutations.ts +1 -1
  71. package/src/validators/config-exists/index.ts +4 -4
  72. package/src/validators/index.ts +1 -1
@@ -1,13 +1,13 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
3
  import {buildASTSchema, DocumentNode, parse, print} from 'graphql'
4
- import * as fsx from 'fs-extra'
5
- import * as os from 'os'
6
- import * as path from 'path'
4
+ import fsx from 'fs-extra'
5
+ import os from 'node:os'
6
+ import path from 'node:path'
7
7
 
8
- import ensureQueryAndMutationTypes from '../utils/ensure-query-and-mutation-types'
9
- import {EXPERIMENTAL_EXTENSIONS} from '../utils/constants'
10
- import validators from '../validators'
8
+ import ensureQueryAndMutationTypes from '../utils/ensure-query-and-mutation-types.js'
9
+ import {EXPERIMENTAL_EXTENSIONS} from '../utils/constants.js'
10
+ import validators from '../validators/index.js'
11
11
 
12
12
  export default (
13
13
  source: string,
package/src/index.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- export {default as configure} from './actions/configure'
4
- export {default as lint} from './actions/lint'
5
- export {default as merge} from './actions/merge'
6
- export {default as print} from './actions/print'
7
- export {default as stitch} from './actions/stitch'
8
- export {default as transpile} from './actions/transpile'
9
- export {default as validate} from './actions/validate'
3
+ export {default as configure} from './actions/configure.js'
4
+ export {default as lint} from './actions/lint.js'
5
+ export {default as merge} from './actions/merge.js'
6
+ export {default as print} from './actions/print.js'
7
+ export {default as stitch} from './actions/stitch.js'
8
+ export {default as transpile} from './actions/transpile.js'
9
+ export {default as validate} from './actions/validate.js'
@@ -1,6 +1,6 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as debug from 'debug'
3
+ import debug from 'debug'
4
4
 
5
5
  function replaceVars<T>(
6
6
  value: T,
@@ -1,5 +1,5 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import envvars from './envvars'
3
+ import envvars from './envvars.js'
4
4
 
5
5
  export default [envvars]
@@ -1,7 +1,7 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as dotenv from 'dotenv'
4
- import * as debug from 'debug'
3
+ import dotenv from 'dotenv'
4
+ import debug from 'debug'
5
5
 
6
6
  debug('stepzen:dotenv')(
7
7
  `loading .env from ${process.cwd()}, at transpiler/src/utils/constants.ts`,
@@ -1,10 +1,10 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as fsx from 'fs-extra'
4
- import * as glob from 'glob'
5
- import * as path from 'path'
6
- import {flatMap} from 'lodash'
7
- import {ALL_GRAPHQL_FILES} from './constants'
3
+ import fsx from 'fs-extra'
4
+ import glob from 'glob'
5
+ import path from 'node:path'
6
+ import {flatMap} from 'lodash-es'
7
+ import {ALL_GRAPHQL_FILES} from './constants.js'
8
8
 
9
9
  const WORKSPACE_FILE_PATTERNS = [
10
10
  '**/*.graphql',
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {DocumentNode, parse, print, visit} from 'graphql'
4
4
 
5
- import {cloneDeep} from '../utils/graphql-helpers'
5
+ import {cloneDeep} from '../utils/graphql-helpers.js'
6
6
 
7
7
  export default (schema: string): string => {
8
8
  let ast: DocumentNode = parse(schema)
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {DocumentNode, visit} from 'graphql'
4
4
 
5
- import {cloneDeep} from '../utils/graphql-helpers'
5
+ import {cloneDeep} from '../utils/graphql-helpers.js'
6
6
 
7
7
  export default (ast: DocumentNode): DocumentNode => {
8
8
  let queries: any = []
@@ -1,5 +1,7 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- export type DeepWriteable<T> = {-readonly [P in keyof T]: DeepWriteable<T[P]>}
3
+ export type DeepWriteable<T> = T extends Function
4
+ ? T
5
+ : {-readonly [P in keyof T]: DeepWriteable<T[P]>}
4
6
  export const cloneDeep = <T>(obj: T): DeepWriteable<T> =>
5
7
  JSON.parse(JSON.stringify(obj))
@@ -1,21 +1,21 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as debug from 'debug'
3
+ import debug from 'debug'
4
4
  import {ASTNode, BREAK, GraphQLSchema, Kind, visit} from 'graphql'
5
- import {buildSchema} from 'graphql/utilities'
5
+ import {buildSchema} from 'graphql/utilities/index.js'
6
6
  import fetch from '@stepzen/fetch'
7
- import * as fsx from 'fs-extra'
8
- import * as glob from 'glob'
9
- import * as os from 'os'
10
- import * as path from 'path'
11
- import {replace} from 'lodash'
12
-
13
- import {cloneDeep} from '../utils/graphql-helpers'
14
- import {STEPZEN_SERVER_URL} from './constants'
15
-
16
- import configure from '../actions/configure'
17
- import transpile from '../actions/transpile'
18
- import {rmtemp} from './rmtemp'
7
+ import fsx from 'fs-extra'
8
+ import glob from 'glob'
9
+ import os from 'node:os'
10
+ import path from 'node:path'
11
+ import {replace} from 'lodash-es'
12
+
13
+ import {cloneDeep} from '../utils/graphql-helpers.js'
14
+ import {STEPZEN_SERVER_URL} from './constants.js'
15
+
16
+ import configure from '../actions/configure.js'
17
+ import transpile from '../actions/transpile.js'
18
+ import {rmtemp} from './rmtemp.js'
19
19
 
20
20
  export const dedupeTempFolder = (dirpath: string) => {
21
21
  do {
@@ -1,9 +1,9 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as fs from 'fs'
4
- import * as path from 'path'
5
- import * as os from 'os'
6
- import * as debug from 'debug'
3
+ import fs from 'node:fs'
4
+ import path from 'node:path'
5
+ import os from 'node:os'
6
+ import debug from 'debug'
7
7
 
8
8
  // ----------------------------------------------------------------------------
9
9
  // THIS ENTIRE FILE IS COPIED FROM packages/cli/src/shared/rmtemp.ts
@@ -1,7 +1,6 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as fs from 'fs'
4
- import * as glob from 'glob'
3
+ import fs from 'node:fs'
5
4
  import {
6
5
  ConstDirectiveNode,
7
6
  DirectiveNode,
@@ -13,12 +12,12 @@ import {
13
12
  OperationTypeNode,
14
13
  visit,
15
14
  } from 'graphql'
16
- import * as path from 'path'
15
+ import path from 'node:path'
17
16
 
18
- import {cloneDeep, DeepWriteable} from './graphql-helpers'
19
- import print from '../actions/print'
20
- import {ALL_GRAPHQL_FILES} from './constants'
21
- import {getAllGraphQLFiles} from './copy-workspace-content'
17
+ import {cloneDeep, DeepWriteable} from './graphql-helpers.js'
18
+ import print from '../actions/print.js'
19
+ import {ALL_GRAPHQL_FILES} from './constants.js'
20
+ import {getAllGraphQLFiles} from './copy-workspace-content.js'
22
21
 
23
22
  const normalizePathSep = (pathlike: string) =>
24
23
  pathlike.replace(path.sep, path.posix.sep)
@@ -26,9 +25,9 @@ const normalizePathSep = (pathlike: string) =>
26
25
  export const createOrUpdateSdlDirective = (
27
26
  importedGraphQLFiles: readonly string[],
28
27
  allGraphQLFiles: readonly string[],
29
- origSdlDirective?: DeepWriteable<DirectiveNode>,
30
- ) => {
31
- let sdlDirective: DeepWriteable<ConstDirectiveNode>
28
+ origSdlDirective?: DirectiveNode | ConstDirectiveNode,
29
+ ): ConstDirectiveNode => {
30
+ let sdlDirective: DeepWriteable<DirectiveNode>
32
31
  if (origSdlDirective) {
33
32
  sdlDirective = cloneDeep(origSdlDirective)
34
33
  } else {
@@ -84,14 +83,14 @@ export const createOrUpdateSdlDirective = (
84
83
  return arg
85
84
  })
86
85
 
87
- return sdlDirective
86
+ return sdlDirective as ConstDirectiveNode
88
87
  }
89
88
 
90
89
  export const createSchemaElement = (
91
90
  importedGraphQLFiles: readonly string[],
92
91
  allGraphQLFiles: readonly string[],
93
- ) => {
94
- const schemaElement: DeepWriteable<SchemaDefinitionNode> = {
92
+ ): SchemaDefinitionNode => {
93
+ const schemaElement = {
95
94
  kind: Kind.SCHEMA_DEFINITION,
96
95
  directives: [
97
96
  createOrUpdateSdlDirective(importedGraphQLFiles, allGraphQLFiles),
@@ -109,7 +108,7 @@ export const createSchemaElement = (
109
108
  },
110
109
  },
111
110
  ],
112
- }
111
+ } satisfies SchemaDefinitionNode
113
112
 
114
113
  return schemaElement
115
114
  }
@@ -130,15 +129,19 @@ export default (source: string, importedGraphQLFiles: readonly string[]) => {
130
129
  directive => directive.name.value === 'sdl',
131
130
  )
132
131
  if (mutated.directives && idx !== undefined && idx > -1) {
133
- mutated.directives[idx] = createOrUpdateSdlDirective(
134
- importedGraphQLFiles,
135
- allGraphQLFiles,
136
- mutated.directives[idx],
137
- )
132
+ ;(mutated.directives[idx] as DirectiveNode) =
133
+ createOrUpdateSdlDirective(
134
+ importedGraphQLFiles,
135
+ allGraphQLFiles,
136
+ mutated.directives[idx],
137
+ )
138
138
  } else {
139
139
  mutated.directives = mutated.directives || []
140
140
  mutated.directives.push(
141
- createOrUpdateSdlDirective(importedGraphQLFiles, allGraphQLFiles),
141
+ createOrUpdateSdlDirective(
142
+ importedGraphQLFiles,
143
+ allGraphQLFiles,
144
+ ) as DeepWriteable<ConstDirectiveNode>,
142
145
  )
143
146
  }
144
147
  return mutated
@@ -150,7 +153,10 @@ export default (source: string, importedGraphQLFiles: readonly string[]) => {
150
153
  Document(node) {
151
154
  const mutated = cloneDeep(node)
152
155
  mutated.definitions.push(
153
- createSchemaElement(importedGraphQLFiles, allGraphQLFiles),
156
+ createSchemaElement(
157
+ importedGraphQLFiles,
158
+ allGraphQLFiles,
159
+ ) as DeepWriteable<SchemaDefinitionNode>,
154
160
  )
155
161
  return mutated
156
162
  },
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {DocumentNode, visit} from 'graphql'
4
4
 
5
- import {cloneDeep} from './graphql-helpers'
5
+ import {cloneDeep} from './graphql-helpers.js'
6
6
 
7
7
  export default (ast: DocumentNode): DocumentNode => {
8
8
  // Loop through the AST and nuke `__query` and `__mutation` stubs
@@ -1,10 +1,10 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
3
  import {DocumentNode, visit} from 'graphql'
4
- import {filter, uniq} from 'lodash'
5
- import * as fs from 'fs'
6
- import * as path from 'path'
7
- import * as yaml from 'yaml'
4
+ import {filter, uniq} from 'lodash-es'
5
+ import fs from 'node:fs'
6
+ import path from 'node:path'
7
+ import yaml from 'yaml'
8
8
 
9
9
  const STEPZEN_DEFAULTS = [
10
10
  'fedex_default',
@@ -1,5 +1,5 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import configExists from './config-exists'
3
+ import configExists from './config-exists/index.js'
4
4
 
5
5
  export default [configExists]