@stepzen/sdk 0.44.0 → 0.45.0-experimental.32a4304

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 (109) hide show
  1. package/lib/client-v2.d.ts +6 -6
  2. package/lib/client-v2.d.ts.map +1 -1
  3. package/lib/client-v2.js +16 -21
  4. package/lib/client-v2.js.map +1 -1
  5. package/lib/client.d.ts +10 -10
  6. package/lib/client.d.ts.map +1 -1
  7. package/lib/client.js +18 -24
  8. package/lib/client.js.map +1 -1
  9. package/lib/commands/account.d.ts +1 -1
  10. package/lib/commands/account.d.ts.map +1 -1
  11. package/lib/commands/account.js +8 -10
  12. package/lib/commands/account.js.map +1 -1
  13. package/lib/commands/authenticate.d.ts +1 -1
  14. package/lib/commands/authenticate.d.ts.map +1 -1
  15. package/lib/commands/authenticate.js +8 -10
  16. package/lib/commands/authenticate.js.map +1 -1
  17. package/lib/commands/deploy.d.ts +1 -1
  18. package/lib/commands/deploy.d.ts.map +1 -1
  19. package/lib/commands/deploy.js +7 -9
  20. package/lib/commands/deploy.js.map +1 -1
  21. package/lib/commands/getPublicAccount.d.ts +1 -1
  22. package/lib/commands/getPublicAccount.d.ts.map +1 -1
  23. package/lib/commands/getPublicAccount.js +6 -8
  24. package/lib/commands/getPublicAccount.js.map +1 -1
  25. package/lib/commands/list.d.ts +1 -1
  26. package/lib/commands/list.d.ts.map +1 -1
  27. package/lib/commands/list.js +7 -9
  28. package/lib/commands/list.js.map +1 -1
  29. package/lib/commands/upload.d.ts +1 -1
  30. package/lib/commands/upload.d.ts.map +1 -1
  31. package/lib/commands/upload.js +18 -20
  32. package/lib/commands/upload.js.map +1 -1
  33. package/lib/commands-v2/account.d.ts +1 -1
  34. package/lib/commands-v2/account.d.ts.map +1 -1
  35. package/lib/commands-v2/account.js +3 -5
  36. package/lib/commands-v2/account.js.map +1 -1
  37. package/lib/commands-v2/delete.d.ts +1 -1
  38. package/lib/commands-v2/delete.d.ts.map +1 -1
  39. package/lib/commands-v2/delete.js +4 -6
  40. package/lib/commands-v2/delete.js.map +1 -1
  41. package/lib/commands-v2/deploy.d.ts +1 -1
  42. package/lib/commands-v2/deploy.d.ts.map +1 -1
  43. package/lib/commands-v2/deploy.js +3 -5
  44. package/lib/commands-v2/deploy.js.map +1 -1
  45. package/lib/commands-v2/getPublicAccount.d.ts +1 -1
  46. package/lib/commands-v2/getPublicAccount.d.ts.map +1 -1
  47. package/lib/commands-v2/getPublicAccount.js +3 -5
  48. package/lib/commands-v2/getPublicAccount.js.map +1 -1
  49. package/lib/commands-v2/list.d.ts +1 -1
  50. package/lib/commands-v2/list.d.ts.map +1 -1
  51. package/lib/commands-v2/list.js +3 -5
  52. package/lib/commands-v2/list.js.map +1 -1
  53. package/lib/index.d.ts +4 -13
  54. package/lib/index.d.ts.map +1 -1
  55. package/lib/index.js +4 -28
  56. package/lib/index.js.map +1 -1
  57. package/lib/init-v2.d.ts +5 -5
  58. package/lib/init-v2.d.ts.map +1 -1
  59. package/lib/init-v2.js +7 -11
  60. package/lib/init-v2.js.map +1 -1
  61. package/lib/init.d.ts +8 -8
  62. package/lib/init.d.ts.map +1 -1
  63. package/lib/init.js +7 -11
  64. package/lib/init.js.map +1 -1
  65. package/lib/shared/constants.js +6 -9
  66. package/lib/shared/constants.js.map +1 -1
  67. package/lib/shared/graphql-client.d.ts +5 -4
  68. package/lib/shared/graphql-client.d.ts.map +1 -1
  69. package/lib/shared/graphql-client.js +11 -17
  70. package/lib/shared/graphql-client.js.map +1 -1
  71. package/lib/shared/payloads.d.ts +2 -2
  72. package/lib/shared/payloads.d.ts.map +1 -1
  73. package/lib/shared/payloads.js +18 -25
  74. package/lib/shared/payloads.js.map +1 -1
  75. package/lib/shared/request.d.ts +1 -1
  76. package/lib/shared/request.d.ts.map +1 -1
  77. package/lib/shared/request.js +7 -11
  78. package/lib/shared/request.js.map +1 -1
  79. package/lib/shared/rmtemp.js +6 -10
  80. package/lib/shared/rmtemp.js.map +1 -1
  81. package/lib/shared/transpiling.js +10 -14
  82. package/lib/shared/transpiling.js.map +1 -1
  83. package/lib/shared/types.js +1 -2
  84. package/lib/shared/types.js.map +1 -1
  85. package/lib/shared/validation.js +6 -11
  86. package/lib/shared/validation.js.map +1 -1
  87. package/package.json +8 -6
  88. package/src/client-v2.ts +7 -7
  89. package/src/client.ts +7 -7
  90. package/src/commands/account.ts +4 -4
  91. package/src/commands/authenticate.ts +4 -4
  92. package/src/commands/deploy.ts +4 -4
  93. package/src/commands/getPublicAccount.ts +3 -3
  94. package/src/commands/list.ts +4 -4
  95. package/src/commands/upload.ts +9 -9
  96. package/src/commands-v2/account.ts +2 -2
  97. package/src/commands-v2/delete.ts +3 -3
  98. package/src/commands-v2/deploy.ts +2 -2
  99. package/src/commands-v2/getPublicAccount.ts +2 -2
  100. package/src/commands-v2/list.ts +2 -2
  101. package/src/index.ts +4 -27
  102. package/src/init-v2.ts +4 -4
  103. package/src/init.ts +4 -4
  104. package/src/shared/graphql-client.ts +8 -7
  105. package/src/shared/payloads.ts +12 -12
  106. package/src/shared/request.ts +8 -3
  107. package/src/shared/rmtemp.ts +4 -4
  108. package/src/shared/transpiling.ts +6 -6
  109. package/src/shared/validation.ts +4 -4
@@ -1,21 +1,21 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as debug from 'debug'
4
- import * as path from 'path'
3
+ import debug from 'debug'
4
+ import path from 'node:path'
5
5
  import fetch from '@stepzen/fetch'
6
6
 
7
- import {ADMIN_UPLOAD_URL} from '../shared/constants'
8
- import {generateYamlPayload, generateZipPayload} from '../shared/payloads'
9
- import {getRequestHeaders} from '../shared/request'
7
+ import {ADMIN_UPLOAD_URL} from '../shared/constants.js'
8
+ import {generateYamlPayload, generateZipPayload} from '../shared/payloads.js'
9
+ import {getRequestHeaders} from '../shared/request.js'
10
10
  import {
11
11
  SDKConfiguration,
12
12
  StepZenAccount,
13
13
  StepZenUpload,
14
14
  ZenCtlResponse,
15
- } from '../shared/types'
16
- import {transpileConfigurationset} from '../shared/transpiling'
17
- import {validateConfigurationset, validateSchema} from '../shared/validation'
18
- import {rmtemp} from '../shared/rmtemp'
15
+ } from '../shared/types.js'
16
+ import {transpileConfigurationset} from '../shared/transpiling.js'
17
+ import {validateConfigurationset, validateSchema} from '../shared/validation.js'
18
+ import {rmtemp} from '../shared/rmtemp.js'
19
19
 
20
20
  export default async (
21
21
  details: StepZenUpload,
@@ -4,8 +4,8 @@ import {
4
4
  SDKConfigurationV2,
5
5
  StepZenAccountV2,
6
6
  ZenCtlResponseV2,
7
- } from '../shared/types'
8
- import {fetchZenCtlGraphQLQuery} from '../shared/graphql-client'
7
+ } from '../shared/types.js'
8
+ import {fetchZenCtlGraphQLQuery} from '../shared/graphql-client.js'
9
9
 
10
10
  export default async ({
11
11
  account,
@@ -1,12 +1,12 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as debug from 'debug'
3
+ import debug from 'debug'
4
4
  import {
5
5
  SDKConfigurationV2,
6
6
  StepZenDeleteV2,
7
7
  ZenCtlResponseV2,
8
- } from '../shared/types'
9
- import {fetchZenCtlGraphQLQuery} from '../shared/graphql-client'
8
+ } from '../shared/types.js'
9
+ import {fetchZenCtlGraphQLQuery} from '../shared/graphql-client.js'
10
10
 
11
11
  export default async ({
12
12
  account,
@@ -6,8 +6,8 @@ import {
6
6
  SDKConfigurationV2,
7
7
  StepZenEndpointV2,
8
8
  ZenCtlResponseV2,
9
- } from '../shared/types'
10
- import {fetchZenCtlGraphQLQuery} from '../shared/graphql-client'
9
+ } from '../shared/types.js'
10
+ import {fetchZenCtlGraphQLQuery} from '../shared/graphql-client.js'
11
11
 
12
12
  export default async ({
13
13
  account,
@@ -4,8 +4,8 @@ import {
4
4
  SDKConfigurationV2,
5
5
  StepZenCredentialsV2,
6
6
  ZenCtlResponseV2,
7
- } from '../shared/types'
8
- import {fetchPublicAccountGraphQLQuery} from '../shared/graphql-client'
7
+ } from '../shared/types.js'
8
+ import {fetchPublicAccountGraphQLQuery} from '../shared/graphql-client.js'
9
9
 
10
10
  export default async ({
11
11
  token,
@@ -4,8 +4,8 @@ import type {
4
4
  SDKConfigurationV2,
5
5
  ZenCtlResponseV2,
6
6
  StepZenEndpointV2,
7
- } from '../shared/types'
8
- import {fetchZenCtlGraphQLQuery} from '../shared/graphql-client'
7
+ } from '../shared/types.js'
8
+ import {fetchZenCtlGraphQLQuery} from '../shared/graphql-client.js'
9
9
 
10
10
  export default async ({
11
11
  account,
package/src/index.ts CHANGED
@@ -1,29 +1,6 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as path from 'path'
4
- import {init, SDK} from './init'
5
-
6
- export * from './init'
7
- export * from './init-v2'
8
- export * from './shared/types'
9
- export {fetchGraphQLQuery} from './shared/graphql-client'
10
-
11
- /**
12
- * The default SDK instance that does not know the name of the app using the SDK.
13
- * It tries to guess the app name from `process.argv`
14
- *
15
- * @deprecated use the init({appName: 'my-app/1.2.3'}) method to initialis an SDK instance
16
- */
17
- const stepzen: SDK = init({
18
- // For legacy apps use the script name (e.g. `index.js` as the app name)
19
- // Fallback to `node` if this file is imported into an interactive node shell
20
- appName: path.basename(process.argv[1] || process.argv[0]),
21
- })
22
-
23
- export default stepzen
24
-
25
- // Hack: support both ESM-style imports: `import stepzen from '@stepzen/sdk'`
26
- // and keep the backwards-compat with CJS-style imports: `const stepzen = require('@stepzen/sdk')`
27
- // NOTE: if at any point in the future there is a name collision between `stepzen` and ES exports
28
- // this hack will break
29
- module.exports = {...module.exports, ...stepzen}
3
+ export * from './init.js'
4
+ export * from './init-v2.js'
5
+ export * from './shared/types.js'
6
+ export {fetchGraphQLQuery} from './shared/graphql-client.js'
package/src/init-v2.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import accountCommand from './commands-v2/account'
4
- import {createSdkClient} from './client-v2'
5
- import {getUserAgent} from './shared/request'
6
- import {SDKConfigurationV2} from './shared/types'
3
+ import accountCommand from './commands-v2/account.js'
4
+ import {createSdkClient} from './client-v2.js'
5
+ import {getUserAgent} from './shared/request.js'
6
+ import {SDKConfigurationV2} from './shared/types.js'
7
7
 
8
8
  export const initV2 = (sdkConfig: SDKConfigurationV2) => {
9
9
  return {
package/src/init.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import authenticate from './commands/authenticate'
4
- import {createSdkClient} from './client'
5
- import {getUserAgent} from './shared/request'
3
+ import authenticate from './commands/authenticate.js'
4
+ import {createSdkClient} from './client.js'
5
+ import {getUserAgent} from './shared/request.js'
6
6
  import {
7
7
  AnonymousClientOptions,
8
8
  SDKConfiguration,
9
9
  UserCredentialsClientOptions,
10
- } from './shared/types'
10
+ } from './shared/types.js'
11
11
 
12
12
  export const init = (sdkConfig: SDKConfiguration) => {
13
13
  const defaults = {
@@ -1,11 +1,12 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as debug from 'debug'
3
+ import debug from 'debug'
4
4
  import fetch from '@stepzen/fetch'
5
5
  import type {ExecutionResult} from 'graphql'
6
+ import type {ObjMap} from 'graphql/jsutils/ObjMap.js'
6
7
 
7
- import {SDKConfigurationV2} from './types'
8
- import {getUserAgent} from './request'
8
+ import {SDKConfigurationV2} from './types.js'
9
+ import {getUserAgent} from './request.js'
9
10
 
10
11
  // The StepZen's ZenCtl GraphQL API offers stronger guarantees than defined in
11
12
  // the GraphQL standard:
@@ -14,14 +15,14 @@ export type GraphQLResponse<TData = Record<string, any>> =
14
15
  | GraphQLErrorResponse<TData>
15
16
 
16
17
  // 1. a successful response would always have a non-null `data` property and no `errors`.
17
- type GraphQLSuccessResponse<TData> = ExecutionResult<TData> & {
18
+ type GraphQLSuccessResponse<TData> = ExecutionResult<TData, ObjMap<unknown>> & {
18
19
  data: TData
19
20
  errors: undefined
20
21
  }
21
22
 
22
23
  // 2. an error response would always have a non-null `errors` property.
23
- type GraphQLErrorResponse<TData> = ExecutionResult<TData> &
24
- Required<Pick<ExecutionResult<TData>, 'errors'>>
24
+ type GraphQLErrorResponse<TData> = ExecutionResult<TData, ObjMap<unknown>> &
25
+ Required<Pick<ExecutionResult<TData, ObjMap<unknown>>, 'errors'>>
25
26
 
26
27
  export const fetchGraphQLQuery = async <T = Record<string, any>>({
27
28
  url,
@@ -35,7 +36,7 @@ export const fetchGraphQLQuery = async <T = Record<string, any>>({
35
36
  variables?: Record<string, any>
36
37
  operationName?: string
37
38
  headers?: Record<string, any>
38
- }): Promise<ExecutionResult<T>> => {
39
+ }): Promise<ExecutionResult<T, ObjMap<unknown>>> => {
39
40
  debug('stepzen:sdk:url')(url)
40
41
  debug('stepzen:sdk:headers')(headers)
41
42
  debug('stepzen:sdk:query')(query)
@@ -2,18 +2,18 @@
2
2
 
3
3
  // This file contains helpers that zip a file or directory
4
4
 
5
- import * as archiver from 'archiver'
6
- import * as debug from 'debug'
7
- import * as FormData from 'form-data'
8
- import * as fs from 'fs'
9
- import * as glob from 'glob'
10
- import * as os from 'os'
11
- import * as path from 'path'
12
- import * as yaml from 'yaml'
13
- import {transpileConfigurationset} from './transpiling'
14
- import {validateConfigurationset} from './validation'
15
- import {Configuration, SchemaFiles} from './types'
16
- import {rmtemp} from './rmtemp'
5
+ import archiver from 'archiver'
6
+ import debug from 'debug'
7
+ import FormData from 'form-data'
8
+ import fs from 'node:fs'
9
+ import glob from 'glob'
10
+ import os from 'node:os'
11
+ import path from 'node:path'
12
+ import yaml from 'yaml'
13
+ import {transpileConfigurationset} from './transpiling.js'
14
+ import {validateConfigurationset} from './validation.js'
15
+ import {Configuration, SchemaFiles} from './types.js'
16
+ import {rmtemp} from './rmtemp.js'
17
17
 
18
18
  type YamlPayload = FormData
19
19
  type ZipPayload = FormData
@@ -1,10 +1,15 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as os from 'os'
3
+ import os from 'node:os'
4
4
  import * as isWsl from 'is-wsl'
5
- import {SDKConfiguration, StepZenAccount, ZenCtlRequestHeaders} from './types'
5
+ import {createRequire} from 'node:module'
6
+ import {
7
+ SDKConfiguration,
8
+ StepZenAccount,
9
+ ZenCtlRequestHeaders,
10
+ } from './types.js'
6
11
 
7
- const {version} = require('../../package.json')
12
+ const {version} = createRequire(import.meta.url)('../../package.json')
8
13
 
9
14
  // mimics the logic from @oclif/config
10
15
  // https://github.com/oclif/core/blob/d7067d13c7d80c9e0064455c27ac1ebb6ee53fd2/src/config/config.ts#L128
@@ -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,12 +1,12 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as dotenv from 'dotenv'
4
- import * as debug from 'debug'
5
- import * as fsx from 'fs-extra'
6
- import * as os from 'os'
7
- import * as path from 'path'
3
+ import dotenv from 'dotenv'
4
+ import debug from 'debug'
5
+ import fsx from 'fs-extra'
6
+ import os from 'node:os'
7
+ import path from 'node:path'
8
8
  import {transpile} from '@stepzen/transpiler'
9
- import {rmtemp} from './rmtemp'
9
+ import {rmtemp} from './rmtemp.js'
10
10
 
11
11
  /**
12
12
  * @returns `undefined` when called without arguments
@@ -1,9 +1,9 @@
1
1
  // Copyright IBM Corp. 2020, 2024
2
2
 
3
- import * as debug from 'debug'
4
- import * as fs from 'fs'
5
- import * as glob from 'glob'
6
- import * as yaml from 'yaml'
3
+ import debug from 'debug'
4
+ import fs from 'node:fs'
5
+ import glob from 'glob'
6
+ import yaml from 'yaml'
7
7
 
8
8
  // Validate the Configurationset file
9
9
  export const validateConfigurationset = async (file: string | undefined) => {