@seamapi/cli 0.18.1 → 0.19.0
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/README.md +55 -1
- package/bin/cli.js +73 -249
- package/bin/cli.js.map +1 -1
- package/lib/args/coerce.d.ts +28 -0
- package/lib/args/coerce.js +131 -0
- package/lib/args/coerce.js.map +1 -0
- package/lib/{util/cli-args.d.ts → args/parse.d.ts} +12 -15
- package/lib/{util/cli-args.js → args/parse.js} +21 -24
- package/lib/args/parse.js.map +1 -0
- package/lib/args/validate.d.ts +23 -0
- package/lib/args/validate.js +42 -0
- package/lib/args/validate.js.map +1 -0
- package/lib/auth/operations.d.ts +54 -0
- package/lib/auth/operations.js +115 -0
- package/lib/auth/operations.js.map +1 -0
- package/lib/{validate-token.js → auth/validate-token.js} +2 -2
- package/lib/auth/validate-token.js.map +1 -0
- package/lib/blueprint/cache.d.ts +16 -0
- package/lib/blueprint/cache.js +73 -0
- package/lib/blueprint/cache.js.map +1 -0
- package/lib/blueprint/endpoint.d.ts +14 -0
- package/lib/{get-response-key.js → blueprint/endpoint.js} +11 -2
- package/lib/blueprint/endpoint.js.map +1 -0
- package/lib/blueprint/index.d.ts +12 -0
- package/lib/blueprint/index.js +10 -0
- package/lib/blueprint/index.js.map +1 -0
- package/lib/blueprint/source-npm.d.ts +10 -0
- package/lib/{blueprint.js → blueprint/source-npm.js} +20 -74
- package/lib/blueprint/source-npm.js.map +1 -0
- package/lib/blueprint/source-remote.d.ts +6 -0
- package/lib/blueprint/source-remote.js +14 -0
- package/lib/blueprint/source-remote.js.map +1 -0
- package/lib/commands/api-command.d.ts +8 -0
- package/lib/commands/api-command.js +71 -0
- package/lib/commands/api-command.js.map +1 -0
- package/lib/commands/local/completion.d.ts +18 -0
- package/lib/commands/local/completion.js +35 -0
- package/lib/commands/local/completion.js.map +1 -0
- package/lib/commands/local/config-reveal-location.d.ts +2 -0
- package/lib/commands/local/config-reveal-location.js +15 -0
- package/lib/commands/local/config-reveal-location.js.map +1 -0
- package/lib/commands/local/config-set-fake-server.d.ts +3 -0
- package/lib/commands/local/config-set-fake-server.js +20 -0
- package/lib/commands/local/config-set-fake-server.js.map +1 -0
- package/lib/commands/local/config-use-remote-api-defs.d.ts +2 -0
- package/lib/commands/local/config-use-remote-api-defs.js +20 -0
- package/lib/commands/local/config-use-remote-api-defs.js.map +1 -0
- package/lib/commands/local/health.d.ts +2 -0
- package/lib/commands/local/health.js +18 -0
- package/lib/commands/local/health.js.map +1 -0
- package/lib/commands/local/login.d.ts +2 -0
- package/lib/commands/local/login.js +35 -0
- package/lib/commands/local/login.js.map +1 -0
- package/lib/commands/local/logout.d.ts +2 -0
- package/lib/commands/local/logout.js +17 -0
- package/lib/commands/local/logout.js.map +1 -0
- package/lib/commands/local/select-server.d.ts +2 -0
- package/lib/commands/local/select-server.js +27 -0
- package/lib/commands/local/select-server.js.map +1 -0
- package/lib/commands/local/select-workspace.d.ts +2 -0
- package/lib/commands/local/select-workspace.js +22 -0
- package/lib/commands/local/select-workspace.js.map +1 -0
- package/lib/commands/local/wizard.d.ts +9 -0
- package/lib/commands/local/wizard.js +28 -0
- package/lib/commands/local/wizard.js.map +1 -0
- package/lib/commands/registry.d.ts +54 -0
- package/lib/commands/registry.js +64 -0
- package/lib/commands/registry.js.map +1 -0
- package/lib/{command-spec.d.ts → commands/spec.d.ts} +8 -12
- package/lib/{command-spec.js → commands/spec.js} +27 -120
- package/lib/commands/spec.js.map +1 -0
- package/lib/config/config-store.d.ts +23 -8
- package/lib/config/config-store.js +16 -42
- package/lib/config/config-store.js.map +1 -1
- package/lib/config/index.d.ts +2 -1
- package/lib/config/index.js +2 -1
- package/lib/config/index.js.map +1 -1
- package/lib/config/memory-config-store.d.ts +21 -0
- package/lib/config/memory-config-store.js +48 -0
- package/lib/config/memory-config-store.js.map +1 -0
- package/lib/config/migrate.js +1 -1
- package/lib/config/migrate.js.map +1 -1
- package/lib/config/values.d.ts +12 -0
- package/lib/config/values.js +50 -0
- package/lib/config/values.js.map +1 -0
- package/lib/context.d.ts +37 -0
- package/lib/context.js +31 -0
- package/lib/context.js.map +1 -0
- package/lib/env.d.ts +5 -0
- package/lib/env.js +5 -0
- package/lib/env.js.map +1 -1
- package/lib/errors.d.ts +31 -0
- package/lib/errors.js +58 -0
- package/lib/errors.js.map +1 -0
- package/lib/http/api.d.ts +37 -0
- package/lib/http/api.js +20 -0
- package/lib/http/api.js.map +1 -0
- package/lib/http/client.d.ts +4 -0
- package/lib/{get-seam.js → http/client.js} +16 -17
- package/lib/http/client.js.map +1 -0
- package/lib/http/follow-ups.d.ts +6 -0
- package/lib/http/follow-ups.js +30 -0
- package/lib/http/follow-ups.js.map +1 -0
- package/lib/http/memory-seam-api.d.ts +22 -0
- package/lib/http/memory-seam-api.js +41 -0
- package/lib/http/memory-seam-api.js.map +1 -0
- package/lib/http/request.d.ts +19 -0
- package/lib/http/request.js +39 -0
- package/lib/http/request.js.map +1 -0
- package/lib/{interact-for-access-code.js → interactions/access-code.js} +4 -4
- package/lib/interactions/access-code.js.map +1 -0
- package/lib/{interact-for-acs-entrance.js → interactions/acs-entrance.js} +3 -3
- package/lib/interactions/acs-entrance.js.map +1 -0
- package/lib/{interact-for-acs-system.js → interactions/acs-system.js} +3 -3
- package/lib/interactions/acs-system.js.map +1 -0
- package/lib/{interact-for-acs-user.js → interactions/acs-user.js} +4 -4
- package/lib/interactions/acs-user.js.map +1 -0
- package/lib/{interact-for-action-attempt-poll.js → interactions/action-attempt-poll.js} +5 -5
- package/lib/interactions/action-attempt-poll.js.map +1 -0
- package/lib/{interact-for-array.js → interactions/array.js} +4 -3
- package/lib/interactions/array.js.map +1 -0
- package/lib/{interact-for-blueprint-object.d.ts → interactions/blueprint-object.d.ts} +3 -2
- package/lib/{interact-for-blueprint-object.js → interactions/blueprint-object.js} +49 -20
- package/lib/interactions/blueprint-object.js.map +1 -0
- package/lib/{interact-for-command-params.d.ts → interactions/command-params.d.ts} +2 -2
- package/lib/{interact-for-command-params.js → interactions/command-params.js} +4 -3
- package/lib/interactions/command-params.js.map +1 -0
- package/lib/interactions/command-selection.d.ts +10 -0
- package/lib/{interact-for-command-selection.js → interactions/command-selection.js} +9 -15
- package/lib/interactions/command-selection.js.map +1 -0
- package/lib/{interact-for-connected-account.js → interactions/connected-account.js} +3 -3
- package/lib/interactions/connected-account.js.map +1 -0
- package/lib/{interact-for-custom-metadata.js → interactions/custom-metadata.js} +4 -3
- package/lib/interactions/custom-metadata.js.map +1 -0
- package/lib/{interact-for-device.js → interactions/device.js} +3 -3
- package/lib/interactions/device.js.map +1 -0
- package/lib/interactions/index.d.ts +19 -0
- package/lib/interactions/index.js +20 -0
- package/lib/interactions/index.js.map +1 -0
- package/lib/{interact-for-login.js → interactions/login.js} +16 -14
- package/lib/interactions/login.js.map +1 -0
- package/lib/{interact-for-resource.js → interactions/resource.js} +3 -3
- package/lib/interactions/resource.js.map +1 -0
- package/lib/{interact-for-server-selection.js → interactions/server-selection.js} +10 -13
- package/lib/interactions/server-selection.js.map +1 -0
- package/lib/{interact-for-timestamp.js → interactions/timestamp.js} +2 -2
- package/lib/interactions/timestamp.js.map +1 -0
- package/lib/{interact-for-use-remote-api-defs.js → interactions/use-remote-api-defs.js} +5 -6
- package/lib/interactions/use-remote-api-defs.js.map +1 -0
- package/lib/{interact-for-user-identity.js → interactions/user-identity.js} +3 -3
- package/lib/interactions/user-identity.js.map +1 -0
- package/lib/{interact-for-workspace-id.js → interactions/workspace-id.js} +11 -10
- package/lib/interactions/workspace-id.js.map +1 -0
- package/lib/memory-prompt.d.ts +32 -0
- package/lib/memory-prompt.js +41 -0
- package/lib/memory-prompt.js.map +1 -0
- package/lib/output/get-output.d.ts +1 -1
- package/lib/output/get-output.js +1 -1
- package/lib/output/get-output.js.map +1 -1
- package/lib/output/{create-memory-output.d.ts → memory-output.d.ts} +1 -1
- package/lib/output/{create-memory-output.js → memory-output.js} +2 -2
- package/lib/output/memory-output.js.map +1 -0
- package/lib/output/{create-output.d.ts → output.d.ts} +18 -1
- package/lib/output/output.js +46 -0
- package/lib/output/output.js.map +1 -0
- package/lib/output/read-stdin-json.js.map +1 -0
- package/lib/output/resolve-output-format.d.ts +1 -1
- package/lib/{util → output}/with-loading.js +1 -1
- package/lib/output/with-loading.js.map +1 -0
- package/lib/prompt.d.ts +101 -0
- package/lib/{util/prompt.js → prompt.js} +83 -56
- package/lib/prompt.js.map +1 -0
- package/lib/{completion → render/completion}/describe.js +1 -2
- package/lib/render/completion/describe.js.map +1 -0
- package/lib/{completion → render/completion}/index.d.ts +2 -2
- package/lib/{completion → render/completion}/index.js +1 -2
- package/lib/render/completion/index.js.map +1 -0
- package/lib/{completion → render/completion}/render-bash.d.ts +1 -1
- package/lib/{completion → render/completion}/render-bash.js +1 -1
- package/lib/render/completion/render-bash.js.map +1 -0
- package/lib/{completion → render/completion}/render-fish.d.ts +1 -1
- package/lib/render/completion/render-fish.js.map +1 -0
- package/lib/{completion → render/completion}/render-zsh.d.ts +1 -1
- package/lib/{completion → render/completion}/render-zsh.js +1 -1
- package/lib/render/completion/render-zsh.js.map +1 -0
- package/lib/{render-help.d.ts → render/help.d.ts} +1 -1
- package/lib/{render-help.js → render/help.js} +2 -2
- package/lib/render/help.js.map +1 -0
- package/lib/render/text.d.ts +4 -0
- package/lib/render/text.js +16 -0
- package/lib/render/text.js.map +1 -0
- package/lib/version.d.ts +2 -2
- package/lib/version.js +2 -2
- package/package.json +4 -3
- package/src/bin/cli.ts +91 -332
- package/src/lib/args/coerce.ts +164 -0
- package/src/lib/{util/cli-args.ts → args/parse.ts} +30 -25
- package/src/lib/args/validate.ts +73 -0
- package/src/lib/auth/operations.ts +169 -0
- package/src/lib/{validate-token.ts → auth/validate-token.ts} +2 -2
- package/src/lib/blueprint/cache.ts +97 -0
- package/src/lib/{get-response-key.ts → blueprint/endpoint.ts} +17 -3
- package/src/lib/blueprint/index.ts +27 -0
- package/src/lib/{blueprint.ts → blueprint/source-npm.ts} +27 -99
- package/src/lib/blueprint/source-remote.ts +17 -0
- package/src/lib/commands/api-command.ts +109 -0
- package/src/lib/commands/local/completion.ts +51 -0
- package/src/lib/commands/local/config-reveal-location.ts +16 -0
- package/src/lib/commands/local/config-set-fake-server.ts +21 -0
- package/src/lib/commands/local/config-use-remote-api-defs.ts +23 -0
- package/src/lib/commands/local/health.ts +22 -0
- package/src/lib/commands/local/login.ts +42 -0
- package/src/lib/commands/local/logout.ts +18 -0
- package/src/lib/commands/local/select-server.ts +30 -0
- package/src/lib/commands/local/select-workspace.ts +25 -0
- package/src/lib/commands/local/wizard.ts +31 -0
- package/src/lib/commands/registry.ts +127 -0
- package/src/lib/{command-spec.ts → commands/spec.ts} +30 -131
- package/src/lib/config/config-store.ts +39 -64
- package/src/lib/config/index.ts +8 -1
- package/src/lib/config/memory-config-store.ts +62 -0
- package/src/lib/config/migrate.ts +1 -1
- package/src/lib/config/values.ts +72 -0
- package/src/lib/context.ts +84 -0
- package/src/lib/env.ts +9 -2
- package/src/lib/errors.ts +67 -0
- package/src/lib/http/api.ts +61 -0
- package/src/lib/{get-seam.ts → http/client.ts} +19 -18
- package/src/lib/http/follow-ups.ts +42 -0
- package/src/lib/http/memory-seam-api.ts +57 -0
- package/src/lib/http/request.ts +69 -0
- package/src/lib/{interact-for-access-code.ts → interactions/access-code.ts} +4 -3
- package/src/lib/{interact-for-acs-entrance.ts → interactions/acs-entrance.ts} +3 -2
- package/src/lib/{interact-for-acs-system.ts → interactions/acs-system.ts} +3 -2
- package/src/lib/{interact-for-acs-user.ts → interactions/acs-user.ts} +4 -3
- package/src/lib/{interact-for-action-attempt-poll.ts → interactions/action-attempt-poll.ts} +4 -4
- package/src/lib/{interact-for-array.ts → interactions/array.ts} +3 -3
- package/src/lib/{interact-for-blueprint-object.ts → interactions/blueprint-object.ts} +57 -24
- package/src/lib/{interact-for-command-params.ts → interactions/command-params.ts} +6 -4
- package/src/lib/{interact-for-command-selection.ts → interactions/command-selection.ts} +11 -23
- package/src/lib/{interact-for-connected-account.ts → interactions/connected-account.ts} +3 -2
- package/src/lib/{interact-for-custom-metadata.ts → interactions/custom-metadata.ts} +3 -7
- package/src/lib/{interact-for-device.ts → interactions/device.ts} +3 -2
- package/src/lib/interactions/index.ts +19 -0
- package/src/lib/{interact-for-login.ts → interactions/login.ts} +16 -13
- package/src/lib/{interact-for-resource.ts → interactions/resource.ts} +2 -2
- package/src/lib/{interact-for-server-selection.ts → interactions/server-selection.ts} +12 -17
- package/src/lib/{interact-for-timestamp.ts → interactions/timestamp.ts} +1 -1
- package/src/lib/{interact-for-use-remote-api-defs.ts → interactions/use-remote-api-defs.ts} +4 -5
- package/src/lib/{interact-for-user-identity.ts → interactions/user-identity.ts} +3 -2
- package/src/lib/{interact-for-workspace-id.ts → interactions/workspace-id.ts} +10 -17
- package/src/lib/memory-prompt.ts +89 -0
- package/src/lib/output/get-output.ts +1 -1
- package/src/lib/output/{create-memory-output.ts → memory-output.ts} +1 -1
- package/src/lib/output/{create-output.ts → output.ts} +47 -32
- package/src/lib/output/resolve-output-format.ts +1 -1
- package/src/lib/{util → output}/with-loading.ts +1 -1
- package/src/lib/prompt.ts +306 -0
- package/src/lib/{completion → render/completion}/describe.ts +1 -2
- package/src/lib/{completion → render/completion}/index.ts +3 -4
- package/src/lib/{completion → render/completion}/render-bash.ts +1 -1
- package/src/lib/{completion → render/completion}/render-fish.ts +2 -1
- package/src/lib/{completion → render/completion}/render-zsh.ts +2 -1
- package/src/lib/{render-help.ts → render/help.ts} +1 -1
- package/src/lib/render/text.ts +17 -0
- package/src/lib/version.ts +2 -2
- package/lib/blueprint.d.ts +0 -7
- package/lib/blueprint.js.map +0 -1
- package/lib/command-spec.js.map +0 -1
- package/lib/completion/describe.js.map +0 -1
- package/lib/completion/index.js.map +0 -1
- package/lib/completion/render-bash.js.map +0 -1
- package/lib/completion/render-fish.js.map +0 -1
- package/lib/completion/render-zsh.js.map +0 -1
- package/lib/get-api-blueprint.d.ts +0 -6
- package/lib/get-api-blueprint.js +0 -18
- package/lib/get-api-blueprint.js.map +0 -1
- package/lib/get-command-blueprint-def.d.ts +0 -2
- package/lib/get-command-blueprint-def.js +0 -11
- package/lib/get-command-blueprint-def.js.map +0 -1
- package/lib/get-credentials.d.ts +0 -15
- package/lib/get-credentials.js +0 -35
- package/lib/get-credentials.js.map +0 -1
- package/lib/get-current-workspace-id.d.ts +0 -1
- package/lib/get-current-workspace-id.js +0 -9
- package/lib/get-current-workspace-id.js.map +0 -1
- package/lib/get-response-key.d.ts +0 -9
- package/lib/get-response-key.js.map +0 -1
- package/lib/get-seam.d.ts +0 -3
- package/lib/get-seam.js.map +0 -1
- package/lib/get-server.d.ts +0 -6
- package/lib/get-server.js +0 -17
- package/lib/get-server.js.map +0 -1
- package/lib/interact-for-access-code.js.map +0 -1
- package/lib/interact-for-acs-entrance.js.map +0 -1
- package/lib/interact-for-acs-system.js.map +0 -1
- package/lib/interact-for-acs-user.js.map +0 -1
- package/lib/interact-for-action-attempt-poll.js.map +0 -1
- package/lib/interact-for-array.js.map +0 -1
- package/lib/interact-for-blueprint-object.js.map +0 -1
- package/lib/interact-for-command-params.js.map +0 -1
- package/lib/interact-for-command-selection.d.ts +0 -2
- package/lib/interact-for-command-selection.js.map +0 -1
- package/lib/interact-for-connected-account.js.map +0 -1
- package/lib/interact-for-custom-metadata.js.map +0 -1
- package/lib/interact-for-device.js.map +0 -1
- package/lib/interact-for-login.js.map +0 -1
- package/lib/interact-for-resource.js.map +0 -1
- package/lib/interact-for-server-selection.js.map +0 -1
- package/lib/interact-for-timestamp.js.map +0 -1
- package/lib/interact-for-use-remote-api-defs.js.map +0 -1
- package/lib/interact-for-user-identity.js.map +0 -1
- package/lib/interact-for-workspace-id.js.map +0 -1
- package/lib/output/create-memory-output.js.map +0 -1
- package/lib/output/create-output.js +0 -34
- package/lib/output/create-output.js.map +0 -1
- package/lib/render-help.js.map +0 -1
- package/lib/types.d.ts +0 -6
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
- package/lib/util/cli-args.js.map +0 -1
- package/lib/util/ellipsis.d.ts +0 -1
- package/lib/util/ellipsis.js +0 -6
- package/lib/util/ellipsis.js.map +0 -1
- package/lib/util/prompt.d.ts +0 -80
- package/lib/util/prompt.js.map +0 -1
- package/lib/util/read-stdin-json.js.map +0 -1
- package/lib/util/request-seam-api.d.ts +0 -7
- package/lib/util/request-seam-api.js +0 -26
- package/lib/util/request-seam-api.js.map +0 -1
- package/lib/util/with-loading.js.map +0 -1
- package/lib/validate-token.js.map +0 -1
- package/src/lib/get-api-blueprint.ts +0 -31
- package/src/lib/get-command-blueprint-def.ts +0 -15
- package/src/lib/get-credentials.ts +0 -38
- package/src/lib/get-current-workspace-id.ts +0 -9
- package/src/lib/get-server.ts +0 -20
- package/src/lib/types.ts +0 -7
- package/src/lib/util/ellipsis.ts +0 -4
- package/src/lib/util/prompt.ts +0 -229
- package/src/lib/util/request-seam-api.ts +0 -47
- /package/lib/{validate-token.d.ts → auth/validate-token.d.ts} +0 -0
- /package/lib/{interact-for-access-code.d.ts → interactions/access-code.d.ts} +0 -0
- /package/lib/{interact-for-acs-entrance.d.ts → interactions/acs-entrance.d.ts} +0 -0
- /package/lib/{interact-for-acs-system.d.ts → interactions/acs-system.d.ts} +0 -0
- /package/lib/{interact-for-acs-user.d.ts → interactions/acs-user.d.ts} +0 -0
- /package/lib/{interact-for-action-attempt-poll.d.ts → interactions/action-attempt-poll.d.ts} +0 -0
- /package/lib/{interact-for-array.d.ts → interactions/array.d.ts} +0 -0
- /package/lib/{interact-for-connected-account.d.ts → interactions/connected-account.d.ts} +0 -0
- /package/lib/{interact-for-custom-metadata.d.ts → interactions/custom-metadata.d.ts} +0 -0
- /package/lib/{interact-for-device.d.ts → interactions/device.d.ts} +0 -0
- /package/lib/{interact-for-login.d.ts → interactions/login.d.ts} +0 -0
- /package/lib/{interact-for-resource.d.ts → interactions/resource.d.ts} +0 -0
- /package/lib/{interact-for-server-selection.d.ts → interactions/server-selection.d.ts} +0 -0
- /package/lib/{interact-for-timestamp.d.ts → interactions/timestamp.d.ts} +0 -0
- /package/lib/{interact-for-use-remote-api-defs.d.ts → interactions/use-remote-api-defs.d.ts} +0 -0
- /package/lib/{interact-for-user-identity.d.ts → interactions/user-identity.d.ts} +0 -0
- /package/lib/{interact-for-workspace-id.d.ts → interactions/workspace-id.d.ts} +0 -0
- /package/lib/{util → output}/read-stdin-json.d.ts +0 -0
- /package/lib/{util → output}/read-stdin-json.js +0 -0
- /package/lib/{util → output}/with-loading.d.ts +0 -0
- /package/lib/{completion → render/completion}/describe.d.ts +0 -0
- /package/lib/{completion → render/completion}/render-fish.js +0 -0
- /package/src/lib/{util → output}/read-stdin-json.ts +0 -0
|
@@ -1,52 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
readFile,
|
|
5
|
-
rename,
|
|
6
|
-
rm,
|
|
7
|
-
writeFile,
|
|
8
|
-
} from 'node:fs/promises'
|
|
9
|
-
import { dirname, join } from 'node:path'
|
|
10
|
-
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
1
|
+
import { access, mkdir, rm, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
import { pathToFileURL } from 'node:url'
|
|
11
4
|
|
|
12
5
|
import type { Blueprint, TypesModuleInput } from '@seamapi/blueprint'
|
|
13
6
|
import envPaths from 'env-paths'
|
|
14
7
|
import { extract } from 'tar'
|
|
15
8
|
|
|
16
|
-
import { withLoading } from '
|
|
17
|
-
|
|
9
|
+
import { withLoading } from 'lib/output/with-loading.js'
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
getBlueprintVersion,
|
|
13
|
+
getCacheFile,
|
|
14
|
+
isUpdateCheckDue,
|
|
15
|
+
readCache,
|
|
16
|
+
writeCache,
|
|
17
|
+
} from './cache.js'
|
|
18
18
|
|
|
19
19
|
const typesPackageName = '@seamapi/types'
|
|
20
20
|
const openapiTarEntryName = 'package/lib/seam/connect/openapi.js'
|
|
21
21
|
const registryUrl = 'https://registry.npmjs.org'
|
|
22
|
-
const updateCheckInterval = 24 * 60 * 60 * 1000
|
|
23
|
-
|
|
24
|
-
const cacheFileName = 'blueprint.json'
|
|
25
|
-
|
|
26
|
-
interface BlueprintCache {
|
|
27
|
-
blueprintVersion: string
|
|
28
|
-
typesVersion: string
|
|
29
|
-
checkedAt: string
|
|
30
|
-
blueprint: Blueprint
|
|
31
|
-
}
|
|
32
22
|
|
|
33
23
|
interface TypesPackageManifest {
|
|
34
24
|
version: string
|
|
35
25
|
dist: { tarball: string }
|
|
36
26
|
}
|
|
37
27
|
|
|
38
|
-
interface GetBlueprintOptions {
|
|
28
|
+
export interface GetBlueprintOptions {
|
|
39
29
|
update?: boolean
|
|
40
30
|
cacheDirectory?: string
|
|
41
31
|
}
|
|
42
32
|
|
|
43
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Build a blueprint from the latest published Seam API types on npm,
|
|
35
|
+
* using the on-disk cache unless it is stale or an update is forced.
|
|
36
|
+
*/
|
|
37
|
+
export const getBlueprint = async (
|
|
44
38
|
options: GetBlueprintOptions = {},
|
|
45
39
|
): Promise<Blueprint> => {
|
|
46
40
|
const update = options.update ?? false
|
|
47
41
|
const cacheDirectory =
|
|
48
42
|
options.cacheDirectory ?? envPaths('seam', { suffix: '' }).cache
|
|
49
|
-
const cacheFile =
|
|
43
|
+
const cacheFile = getCacheFile(cacheDirectory)
|
|
50
44
|
const blueprintVersion = await getBlueprintVersion()
|
|
51
45
|
|
|
52
46
|
const cache = await readCache(cacheFile)
|
|
@@ -100,41 +94,6 @@ const getBlueprint = async (
|
|
|
100
94
|
return blueprint
|
|
101
95
|
}
|
|
102
96
|
|
|
103
|
-
const getBlueprintVersion = async (): Promise<string> => {
|
|
104
|
-
if (seamapiBlueprintVersion !== '0.0.0') return seamapiBlueprintVersion
|
|
105
|
-
|
|
106
|
-
// The version is only injected when the package is packed, so a
|
|
107
|
-
// development checkout reads the pinned version from package.json
|
|
108
|
-
// to keep invalidating the cache on version changes as expected.
|
|
109
|
-
const pkg = await findOwnPackageJson()
|
|
110
|
-
return pkg?.dependencies?.['@seamapi/blueprint'] ?? seamapiBlueprintVersion
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const findOwnPackageJson = async (): Promise<{
|
|
114
|
-
dependencies?: Record<string, string>
|
|
115
|
-
} | null> => {
|
|
116
|
-
let directory = dirname(fileURLToPath(import.meta.url))
|
|
117
|
-
while (true) {
|
|
118
|
-
try {
|
|
119
|
-
const pkg = JSON.parse(
|
|
120
|
-
await readFile(join(directory, 'package.json'), 'utf8'),
|
|
121
|
-
) as { name?: string; dependencies?: Record<string, string> }
|
|
122
|
-
if (pkg.name === '@seamapi/cli') return pkg
|
|
123
|
-
} catch {
|
|
124
|
-
// Keep walking up until a package.json for this package is found.
|
|
125
|
-
}
|
|
126
|
-
const parent = dirname(directory)
|
|
127
|
-
if (parent === directory) return null
|
|
128
|
-
directory = parent
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const isUpdateCheckDue = (checkedAt: string): boolean => {
|
|
133
|
-
const checkedAtTime = Date.parse(checkedAt)
|
|
134
|
-
if (Number.isNaN(checkedAtTime)) return true
|
|
135
|
-
return Date.now() - checkedAtTime > updateCheckInterval
|
|
136
|
-
}
|
|
137
|
-
|
|
138
97
|
const fetchLatestTypesPackageManifest =
|
|
139
98
|
async (): Promise<TypesPackageManifest> => {
|
|
140
99
|
const res = await fetch(`${registryUrl}/${typesPackageName}/latest`, {
|
|
@@ -144,7 +103,8 @@ const fetchLatestTypesPackageManifest =
|
|
|
144
103
|
if (!res.ok) {
|
|
145
104
|
throw new Error(`npm registry responded with status ${res.status}`)
|
|
146
105
|
}
|
|
147
|
-
const
|
|
106
|
+
const body = await res.json()
|
|
107
|
+
const manifest = body as Partial<TypesPackageManifest>
|
|
148
108
|
if (
|
|
149
109
|
typeof manifest.version !== 'string' ||
|
|
150
110
|
typeof manifest.dist?.tarball !== 'string'
|
|
@@ -181,21 +141,24 @@ const downloadOpenapi = async (
|
|
|
181
141
|
await rm(extractDirectory, { recursive: true, force: true })
|
|
182
142
|
await mkdir(extractDirectory, { recursive: true })
|
|
183
143
|
try {
|
|
184
|
-
|
|
144
|
+
const tarball = await res.arrayBuffer()
|
|
145
|
+
await writeFile(tarballFile, Buffer.from(tarball))
|
|
185
146
|
await extract({ file: tarballFile, cwd: extractDirectory }, [
|
|
186
147
|
openapiTarEntryName,
|
|
187
148
|
])
|
|
188
149
|
|
|
189
150
|
const moduleFile = join(extractDirectory, openapiTarEntryName)
|
|
190
|
-
|
|
151
|
+
const moduleFileExists = await exists(moduleFile)
|
|
152
|
+
if (!moduleFileExists) {
|
|
191
153
|
throw new Error(`Missing ${openapiTarEntryName} in package tarball`)
|
|
192
154
|
}
|
|
193
155
|
|
|
194
156
|
// The OpenAPI document is published as a JavaScript module, so import it.
|
|
195
157
|
const openapiModuleUrl = pathToFileURL(moduleFile).href
|
|
196
|
-
const
|
|
158
|
+
const openapiModule = (await import(openapiModuleUrl)) as {
|
|
197
159
|
default: unknown
|
|
198
160
|
}
|
|
161
|
+
const { default: openapi } = openapiModule
|
|
199
162
|
if (openapi == null) {
|
|
200
163
|
throw new Error(`Missing default export in ${openapiTarEntryName}`)
|
|
201
164
|
}
|
|
@@ -214,40 +177,5 @@ const exists = async (file: string): Promise<boolean> => {
|
|
|
214
177
|
}
|
|
215
178
|
}
|
|
216
179
|
|
|
217
|
-
const readCache = async (file: string): Promise<BlueprintCache | null> => {
|
|
218
|
-
try {
|
|
219
|
-
const cache = JSON.parse(await readFile(file, 'utf8')) as unknown
|
|
220
|
-
if (!isBlueprintCache(cache)) return null
|
|
221
|
-
return cache
|
|
222
|
-
} catch {
|
|
223
|
-
return null
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const writeCache = async (
|
|
228
|
-
file: string,
|
|
229
|
-
cache: BlueprintCache,
|
|
230
|
-
): Promise<void> => {
|
|
231
|
-
const temporaryFile = `${file}.tmp`
|
|
232
|
-
await mkdir(dirname(file), { recursive: true })
|
|
233
|
-
await writeFile(temporaryFile, `${JSON.stringify(cache)}\n`, 'utf8')
|
|
234
|
-
await rename(temporaryFile, file)
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const isBlueprintCache = (cache: unknown): cache is BlueprintCache => {
|
|
238
|
-
if (cache == null || typeof cache !== 'object') return false
|
|
239
|
-
const { blueprintVersion, typesVersion, checkedAt, blueprint } =
|
|
240
|
-
cache as Record<string, unknown>
|
|
241
|
-
return (
|
|
242
|
-
typeof blueprintVersion === 'string' &&
|
|
243
|
-
typeof typesVersion === 'string' &&
|
|
244
|
-
typeof checkedAt === 'string' &&
|
|
245
|
-
blueprint != null &&
|
|
246
|
-
typeof blueprint === 'object'
|
|
247
|
-
)
|
|
248
|
-
}
|
|
249
|
-
|
|
250
180
|
const toErrorMessage = (error: unknown): string =>
|
|
251
181
|
error instanceof Error ? error.message : String(error)
|
|
252
|
-
|
|
253
|
-
export default getBlueprint
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Blueprint } from '@seamapi/blueprint'
|
|
2
|
+
|
|
3
|
+
import { resolveAuth } from 'lib/context.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Build a blueprint from the OpenAPI document the current server is running,
|
|
7
|
+
* describing exactly what that server accepts rather than what is published.
|
|
8
|
+
*/
|
|
9
|
+
export const createRemoteBlueprint = async (): Promise<Blueprint> => {
|
|
10
|
+
const [{ createBlueprint }, { getOpenapiSchema }] = await Promise.all([
|
|
11
|
+
import('@seamapi/blueprint'),
|
|
12
|
+
import('@seamapi/http/connect'),
|
|
13
|
+
])
|
|
14
|
+
const openapi = await getOpenapiSchema(resolveAuth().server)
|
|
15
|
+
|
|
16
|
+
return await createBlueprint({ openapi }, { omitUndocumented: true })
|
|
17
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { isDeepStrictEqual as isEqual } from 'node:util'
|
|
2
|
+
|
|
3
|
+
import { coerceArgParams } from 'lib/args/coerce.js'
|
|
4
|
+
import { parseCliArgs, toArgName, toArgParams } from 'lib/args/parse.js'
|
|
5
|
+
import { assertRequiredParams } from 'lib/args/validate.js'
|
|
6
|
+
import {
|
|
7
|
+
getCommandBlueprintDef,
|
|
8
|
+
getResponseKey,
|
|
9
|
+
} from 'lib/blueprint/endpoint.js'
|
|
10
|
+
import type { CliContext } from 'lib/context.js'
|
|
11
|
+
import { UsageError } from 'lib/errors.js'
|
|
12
|
+
import { runResponseFollowUps } from 'lib/http/follow-ups.js'
|
|
13
|
+
import { requestSeamApi } from 'lib/http/request.js'
|
|
14
|
+
import { interactForCommandParams } from 'lib/interactions/index.js'
|
|
15
|
+
|
|
16
|
+
import type { CommandResult, Invocation } from './registry.js'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Run a command that calls a Seam API endpoint: assemble the params,
|
|
20
|
+
* prompt for what is missing, make the request, and run any follow-ups
|
|
21
|
+
* the response calls for.
|
|
22
|
+
*/
|
|
23
|
+
export const executeApiCommand = async (
|
|
24
|
+
invocation: Invocation,
|
|
25
|
+
ctx: CliContext,
|
|
26
|
+
): Promise<CommandResult> => {
|
|
27
|
+
const { path } = invocation
|
|
28
|
+
const isNonInteractive = ctx.interactivity === 'non-interactive'
|
|
29
|
+
const apiPath = `/${path.join('/').replace(/-/g, '_')}`
|
|
30
|
+
|
|
31
|
+
const parameters = getCommandBlueprintDef(path, ctx).request.parameters
|
|
32
|
+
|
|
33
|
+
// Re-read the arguments knowing the endpoint's own parameter types — the
|
|
34
|
+
// generic first parse guessed, mangling opaque values like access codes —
|
|
35
|
+
// then coerce each value to the JSON type its parameter documents.
|
|
36
|
+
const stringKeys = parameters
|
|
37
|
+
.filter(({ format }) => format !== 'boolean' && format !== 'number')
|
|
38
|
+
.flatMap(({ name }) => [name, name.replace(/_/g, '-')])
|
|
39
|
+
const { params: argParams, issues } = coerceArgParams(
|
|
40
|
+
parameters,
|
|
41
|
+
toArgParams(parseCliArgs(invocation.argv, { stringKeys })),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
if (issues.length > 0) {
|
|
45
|
+
throw new UsageError(
|
|
46
|
+
`Invalid ${
|
|
47
|
+
issues.length === 1 ? 'value' : 'values'
|
|
48
|
+
} for ${apiPath}: ${issues
|
|
49
|
+
.map(({ name, expected }) => `${toArgName(name)} expects ${expected}`)
|
|
50
|
+
.join('; ')}`,
|
|
51
|
+
{
|
|
52
|
+
hint: `Run 'seam ${path.join(' ')} --help' to see what it accepts.`,
|
|
53
|
+
},
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Params given as arguments win over params piped in.
|
|
58
|
+
const commandParams: Record<string, any> = { ...invocation.stdinParams }
|
|
59
|
+
Object.assign(commandParams, argParams)
|
|
60
|
+
|
|
61
|
+
applyEndpointDefaults(path, commandParams)
|
|
62
|
+
|
|
63
|
+
// Non-interactive runs never prompt: validate and send what was given.
|
|
64
|
+
let params: Record<string, any>
|
|
65
|
+
if (isNonInteractive) {
|
|
66
|
+
assertRequiredParams(parameters, commandParams, apiPath)
|
|
67
|
+
params = commandParams
|
|
68
|
+
} else {
|
|
69
|
+
const edited = await interactForCommandParams(
|
|
70
|
+
{ command: path, params: commandParams },
|
|
71
|
+
ctx,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
if (edited === '[Back]') {
|
|
75
|
+
return { kind: 'back', toPath: path.slice(0, -1) }
|
|
76
|
+
}
|
|
77
|
+
params = edited
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (apiPath.includes('/events/list') && params['between']) {
|
|
81
|
+
delete params['since']
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const api = await ctx.api()
|
|
85
|
+
const body = await requestSeamApi(
|
|
86
|
+
{ path: apiPath, params, responseKey: getResponseKey(path, ctx) },
|
|
87
|
+
{ api, output: ctx.output },
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
await runResponseFollowUps(body, ctx)
|
|
91
|
+
|
|
92
|
+
return { kind: 'done' }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Per-endpoint request policy that is not derivable from the API
|
|
97
|
+
* definitions. Keep this table small and explicit.
|
|
98
|
+
*/
|
|
99
|
+
const applyEndpointDefaults = (
|
|
100
|
+
path: string[],
|
|
101
|
+
params: Record<string, any>,
|
|
102
|
+
): void => {
|
|
103
|
+
// Unbounded event lists are never wanted, so default to the last month.
|
|
104
|
+
if (isEqual(path, ['events', 'list']) && !params['since']) {
|
|
105
|
+
const date = new Date()
|
|
106
|
+
date.setMonth(date.getMonth() - 1)
|
|
107
|
+
params['since'] = date.toISOString()
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ApiBlueprint } from 'lib/blueprint/index.js'
|
|
2
|
+
import type { Command } from 'lib/commands/registry.js'
|
|
3
|
+
import type { CommandSpec } from 'lib/commands/spec.js'
|
|
4
|
+
import { getOutput } from 'lib/output/get-output.js'
|
|
5
|
+
import {
|
|
6
|
+
type CompletionShell,
|
|
7
|
+
renderCompletion,
|
|
8
|
+
} from 'lib/render/completion/index.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Print the completion script for a shell.
|
|
12
|
+
*
|
|
13
|
+
* Completions always come from the cached API definitions so that they can
|
|
14
|
+
* be generated without logging in. They may lag the definitions served by
|
|
15
|
+
* Seam when config use-remote-api-defs is enabled.
|
|
16
|
+
*
|
|
17
|
+
* Called by the entry before any auth or blueprint context exists, and by
|
|
18
|
+
* the registered command's executor — one implementation for both.
|
|
19
|
+
*/
|
|
20
|
+
export const printCompletion = (
|
|
21
|
+
shell: CompletionShell,
|
|
22
|
+
spec: CommandSpec,
|
|
23
|
+
): void => {
|
|
24
|
+
getOutput().text(renderCompletion(shell, spec))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type BuildSpec = (blueprint: ApiBlueprint) => CommandSpec
|
|
28
|
+
|
|
29
|
+
const completionCommand = (
|
|
30
|
+
shell: CompletionShell,
|
|
31
|
+
buildSpec: BuildSpec,
|
|
32
|
+
): Command => ({
|
|
33
|
+
definition: {
|
|
34
|
+
path: ['completion', shell],
|
|
35
|
+
kind: 'cli',
|
|
36
|
+
title: `Print the ${shell} completion script.`,
|
|
37
|
+
description: '',
|
|
38
|
+
flags: [],
|
|
39
|
+
},
|
|
40
|
+
requiresAuth: false,
|
|
41
|
+
execute: async (_invocation, ctx) => {
|
|
42
|
+
printCompletion(shell, buildSpec(ctx.blueprint))
|
|
43
|
+
return { kind: 'done' }
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
export const createCompletionCommands = (buildSpec: BuildSpec): Command[] => [
|
|
48
|
+
completionCommand('bash', buildSpec),
|
|
49
|
+
completionCommand('fish', buildSpec),
|
|
50
|
+
completionCommand('zsh', buildSpec),
|
|
51
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Command } from 'lib/commands/registry.js'
|
|
2
|
+
|
|
3
|
+
export const configRevealLocationCommand: Command = {
|
|
4
|
+
definition: {
|
|
5
|
+
path: ['config', 'reveal-location'],
|
|
6
|
+
kind: 'cli',
|
|
7
|
+
title: 'Print the path to the CLI configuration file.',
|
|
8
|
+
description: '',
|
|
9
|
+
flags: [],
|
|
10
|
+
},
|
|
11
|
+
requiresAuth: true,
|
|
12
|
+
execute: async (_invocation, ctx) => {
|
|
13
|
+
ctx.output.text(ctx.config.path)
|
|
14
|
+
return { kind: 'done' }
|
|
15
|
+
},
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { selectFakeServer } from 'lib/auth/operations.js'
|
|
2
|
+
import type { Command } from 'lib/commands/registry.js'
|
|
3
|
+
|
|
4
|
+
/** Hidden: a development shortcut, kept out of help and completion. */
|
|
5
|
+
export const configSetFakeServerCommand: Command = {
|
|
6
|
+
definition: {
|
|
7
|
+
path: ['config', 'set', 'fake-server'],
|
|
8
|
+
kind: 'cli',
|
|
9
|
+
title: 'Point the CLI at a fake Seam Connect server.',
|
|
10
|
+
description: '',
|
|
11
|
+
flags: [],
|
|
12
|
+
},
|
|
13
|
+
requiresAuth: false,
|
|
14
|
+
hidden: true,
|
|
15
|
+
execute: async (_invocation, ctx) => {
|
|
16
|
+
const { server } = selectFakeServer({ config: ctx.config })
|
|
17
|
+
ctx.output.info(`Server URL set to ${server}`)
|
|
18
|
+
ctx.output.info(`PAT set to use fakeseamconnect with "seam_apikey1_token"`)
|
|
19
|
+
return { kind: 'done' }
|
|
20
|
+
},
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Command } from 'lib/commands/registry.js'
|
|
2
|
+
import { NonInteractiveError } from 'lib/errors.js'
|
|
3
|
+
import { interactForUseRemoteApiDefs } from 'lib/interactions/index.js'
|
|
4
|
+
|
|
5
|
+
export const configUseRemoteApiDefsCommand: Command = {
|
|
6
|
+
definition: {
|
|
7
|
+
path: ['config', 'use-remote-api-defs'],
|
|
8
|
+
kind: 'cli',
|
|
9
|
+
title: 'Choose whether to use the API definitions served by Seam.',
|
|
10
|
+
description: '',
|
|
11
|
+
flags: [],
|
|
12
|
+
},
|
|
13
|
+
requiresAuth: true,
|
|
14
|
+
execute: async (_invocation, ctx) => {
|
|
15
|
+
if (ctx.interactivity === 'non-interactive') {
|
|
16
|
+
throw new NonInteractiveError(
|
|
17
|
+
'Cannot select whether to use remote API definitions in non-interactive mode',
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
await interactForUseRemoteApiDefs()
|
|
21
|
+
return { kind: 'done' }
|
|
22
|
+
},
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Command } from 'lib/commands/registry.js'
|
|
2
|
+
import { requestSeamApi } from 'lib/http/request.js'
|
|
3
|
+
|
|
4
|
+
export const healthCommand: Command = {
|
|
5
|
+
definition: {
|
|
6
|
+
path: ['health', 'get-health'],
|
|
7
|
+
// Handled by the CLI itself, but calls the Seam API.
|
|
8
|
+
kind: 'api',
|
|
9
|
+
title: 'Report the health of the Seam API.',
|
|
10
|
+
description: '',
|
|
11
|
+
flags: [],
|
|
12
|
+
},
|
|
13
|
+
requiresAuth: true,
|
|
14
|
+
execute: async (_invocation, ctx) => {
|
|
15
|
+
const api = await ctx.api()
|
|
16
|
+
await requestSeamApi(
|
|
17
|
+
{ path: '/health/get_health', params: {} },
|
|
18
|
+
{ api, output: ctx.output },
|
|
19
|
+
)
|
|
20
|
+
return { kind: 'done' }
|
|
21
|
+
},
|
|
22
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { assertMutable, login } from 'lib/auth/operations.js'
|
|
2
|
+
import type { Command } from 'lib/commands/registry.js'
|
|
3
|
+
import { stringFlag } from 'lib/commands/spec.js'
|
|
4
|
+
import { NonInteractiveError } from 'lib/errors.js'
|
|
5
|
+
import { interactForLogin } from 'lib/interactions/index.js'
|
|
6
|
+
|
|
7
|
+
export const loginCommand: Command = {
|
|
8
|
+
definition: {
|
|
9
|
+
path: ['login'],
|
|
10
|
+
kind: 'cli',
|
|
11
|
+
title: 'Log in to Seam.',
|
|
12
|
+
description:
|
|
13
|
+
'Prompts for a personal access token unless one is passed with --token.',
|
|
14
|
+
flags: [
|
|
15
|
+
stringFlag('server', 'Seam API server to log in to.'),
|
|
16
|
+
stringFlag('token', 'Personal access token to log in with.'),
|
|
17
|
+
stringFlag('workspace-id', 'Workspace to select after logging in.'),
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
requiresAuth: false,
|
|
21
|
+
execute: async ({ args }, ctx) => {
|
|
22
|
+
if (args['token'] || args['workspace_id'] || args['server']) {
|
|
23
|
+
await login(
|
|
24
|
+
{
|
|
25
|
+
server: args['server'] ? args['server'] : undefined,
|
|
26
|
+
token: args['token'] ? String(args['token']).trim() : undefined,
|
|
27
|
+
workspaceId: args['workspace_id'] ? args['workspace_id'] : undefined,
|
|
28
|
+
},
|
|
29
|
+
ctx.config,
|
|
30
|
+
)
|
|
31
|
+
return { kind: 'done' }
|
|
32
|
+
}
|
|
33
|
+
assertMutable(ctx.auth, 'token', 'log in')
|
|
34
|
+
if (ctx.interactivity === 'non-interactive') {
|
|
35
|
+
throw new NonInteractiveError(
|
|
36
|
+
'Missing required parameter for login: --token',
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
await interactForLogin()
|
|
40
|
+
return { kind: 'done' }
|
|
41
|
+
},
|
|
42
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { logout } from 'lib/auth/operations.js'
|
|
2
|
+
import type { Command } from 'lib/commands/registry.js'
|
|
3
|
+
|
|
4
|
+
export const logoutCommand: Command = {
|
|
5
|
+
definition: {
|
|
6
|
+
path: ['logout'],
|
|
7
|
+
kind: 'cli',
|
|
8
|
+
title: 'Log out of Seam.',
|
|
9
|
+
description: '',
|
|
10
|
+
flags: [],
|
|
11
|
+
},
|
|
12
|
+
requiresAuth: true,
|
|
13
|
+
execute: async (_invocation, ctx) => {
|
|
14
|
+
logout(ctx.config)
|
|
15
|
+
ctx.output.info('Logged out!')
|
|
16
|
+
return { kind: 'done' }
|
|
17
|
+
},
|
|
18
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { assertMutable, selectServer } from 'lib/auth/operations.js'
|
|
2
|
+
import type { Command } from 'lib/commands/registry.js'
|
|
3
|
+
import { stringFlag } from 'lib/commands/spec.js'
|
|
4
|
+
import { NonInteractiveError } from 'lib/errors.js'
|
|
5
|
+
import { interactForServerSelection } from 'lib/interactions/index.js'
|
|
6
|
+
|
|
7
|
+
export const selectServerCommand: Command = {
|
|
8
|
+
definition: {
|
|
9
|
+
path: ['select', 'server'],
|
|
10
|
+
kind: 'cli',
|
|
11
|
+
title: 'Select the Seam API server.',
|
|
12
|
+
description: '',
|
|
13
|
+
flags: [stringFlag('server', 'Seam API server to select.')],
|
|
14
|
+
},
|
|
15
|
+
requiresAuth: false,
|
|
16
|
+
execute: async ({ args }, ctx) => {
|
|
17
|
+
assertMutable(ctx.auth, 'server', 'select a server')
|
|
18
|
+
if (args['server']) {
|
|
19
|
+
selectServer(args['server'], ctx.config)
|
|
20
|
+
return { kind: 'done' }
|
|
21
|
+
}
|
|
22
|
+
if (ctx.interactivity === 'non-interactive') {
|
|
23
|
+
throw new NonInteractiveError(
|
|
24
|
+
'Missing required parameter for select server: --server',
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
await interactForServerSelection()
|
|
28
|
+
return { kind: 'done' }
|
|
29
|
+
},
|
|
30
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { assertMutable } from 'lib/auth/operations.js'
|
|
2
|
+
import type { Command } from 'lib/commands/registry.js'
|
|
3
|
+
import { NonInteractiveError } from 'lib/errors.js'
|
|
4
|
+
import { interactForWorkspaceId } from 'lib/interactions/index.js'
|
|
5
|
+
|
|
6
|
+
export const selectWorkspaceCommand: Command = {
|
|
7
|
+
definition: {
|
|
8
|
+
path: ['select', 'workspace'],
|
|
9
|
+
kind: 'cli',
|
|
10
|
+
title: 'Select the current workspace.',
|
|
11
|
+
description: '',
|
|
12
|
+
flags: [],
|
|
13
|
+
},
|
|
14
|
+
requiresAuth: true,
|
|
15
|
+
execute: async (_invocation, ctx) => {
|
|
16
|
+
assertMutable(ctx.auth, 'workspaceId', 'select a workspace')
|
|
17
|
+
if (ctx.interactivity === 'non-interactive') {
|
|
18
|
+
throw new NonInteractiveError(
|
|
19
|
+
'Cannot select a workspace in non-interactive mode: pass --workspace-id to "seam login"',
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
await interactForWorkspaceId()
|
|
23
|
+
return { kind: 'done' }
|
|
24
|
+
},
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Command } from 'lib/commands/registry.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Run the Seam setup wizard.
|
|
5
|
+
*
|
|
6
|
+
* Intercepted by the entry before argument parsing so the wizard owns its
|
|
7
|
+
* own argv; the registered executor covers selecting it interactively.
|
|
8
|
+
*/
|
|
9
|
+
export const runWizard = async (argv: string[]): Promise<void> => {
|
|
10
|
+
const { default: wizard } = await import('@seamapi/wizard')
|
|
11
|
+
await wizard({
|
|
12
|
+
argv,
|
|
13
|
+
commandName: 'seam wizard',
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const wizardCommand: Command = {
|
|
18
|
+
definition: {
|
|
19
|
+
path: ['wizard'],
|
|
20
|
+
kind: 'cli',
|
|
21
|
+
title: 'Set up Seam in the current project.',
|
|
22
|
+
description:
|
|
23
|
+
'Takes a project from zero to a working Seam integration. Run seam wizard --help for its own options.',
|
|
24
|
+
flags: [],
|
|
25
|
+
},
|
|
26
|
+
requiresAuth: false,
|
|
27
|
+
execute: async () => {
|
|
28
|
+
await runWizard([])
|
|
29
|
+
return { kind: 'done' }
|
|
30
|
+
},
|
|
31
|
+
}
|