@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,19 +1,21 @@
|
|
|
1
|
-
import { access, mkdir,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { access, mkdir, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
4
|
import envPaths from 'env-paths';
|
|
5
5
|
import { extract } from 'tar';
|
|
6
|
-
import { withLoading } from '
|
|
7
|
-
import {
|
|
6
|
+
import { withLoading } from '../output/with-loading.js';
|
|
7
|
+
import { getBlueprintVersion, getCacheFile, isUpdateCheckDue, readCache, writeCache, } from './cache.js';
|
|
8
8
|
const typesPackageName = '@seamapi/types';
|
|
9
9
|
const openapiTarEntryName = 'package/lib/seam/connect/openapi.js';
|
|
10
10
|
const registryUrl = 'https://registry.npmjs.org';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Build a blueprint from the latest published Seam API types on npm,
|
|
13
|
+
* using the on-disk cache unless it is stale or an update is forced.
|
|
14
|
+
*/
|
|
15
|
+
export const getBlueprint = async (options = {}) => {
|
|
14
16
|
const update = options.update ?? false;
|
|
15
17
|
const cacheDirectory = options.cacheDirectory ?? envPaths('seam', { suffix: '' }).cache;
|
|
16
|
-
const cacheFile =
|
|
18
|
+
const cacheFile = getCacheFile(cacheDirectory);
|
|
17
19
|
const blueprintVersion = await getBlueprintVersion();
|
|
18
20
|
const cache = await readCache(cacheFile);
|
|
19
21
|
const isCacheUsable = cache != null && cache.blueprintVersion === blueprintVersion;
|
|
@@ -55,38 +57,6 @@ const getBlueprint = async (options = {}) => {
|
|
|
55
57
|
});
|
|
56
58
|
return blueprint;
|
|
57
59
|
};
|
|
58
|
-
const getBlueprintVersion = async () => {
|
|
59
|
-
if (seamapiBlueprintVersion !== '0.0.0')
|
|
60
|
-
return seamapiBlueprintVersion;
|
|
61
|
-
// The version is only injected when the package is packed, so a
|
|
62
|
-
// development checkout reads the pinned version from package.json
|
|
63
|
-
// to keep invalidating the cache on version changes as expected.
|
|
64
|
-
const pkg = await findOwnPackageJson();
|
|
65
|
-
return pkg?.dependencies?.['@seamapi/blueprint'] ?? seamapiBlueprintVersion;
|
|
66
|
-
};
|
|
67
|
-
const findOwnPackageJson = async () => {
|
|
68
|
-
let directory = dirname(fileURLToPath(import.meta.url));
|
|
69
|
-
while (true) {
|
|
70
|
-
try {
|
|
71
|
-
const pkg = JSON.parse(await readFile(join(directory, 'package.json'), 'utf8'));
|
|
72
|
-
if (pkg.name === '@seamapi/cli')
|
|
73
|
-
return pkg;
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
// Keep walking up until a package.json for this package is found.
|
|
77
|
-
}
|
|
78
|
-
const parent = dirname(directory);
|
|
79
|
-
if (parent === directory)
|
|
80
|
-
return null;
|
|
81
|
-
directory = parent;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const isUpdateCheckDue = (checkedAt) => {
|
|
85
|
-
const checkedAtTime = Date.parse(checkedAt);
|
|
86
|
-
if (Number.isNaN(checkedAtTime))
|
|
87
|
-
return true;
|
|
88
|
-
return Date.now() - checkedAtTime > updateCheckInterval;
|
|
89
|
-
};
|
|
90
60
|
const fetchLatestTypesPackageManifest = async () => {
|
|
91
61
|
const res = await fetch(`${registryUrl}/${typesPackageName}/latest`, {
|
|
92
62
|
headers: { accept: 'application/json' },
|
|
@@ -95,7 +65,8 @@ const fetchLatestTypesPackageManifest = async () => {
|
|
|
95
65
|
if (!res.ok) {
|
|
96
66
|
throw new Error(`npm registry responded with status ${res.status}`);
|
|
97
67
|
}
|
|
98
|
-
const
|
|
68
|
+
const body = await res.json();
|
|
69
|
+
const manifest = body;
|
|
99
70
|
if (typeof manifest.version !== 'string' ||
|
|
100
71
|
typeof manifest.dist?.tarball !== 'string') {
|
|
101
72
|
throw new Error('npm registry returned an unexpected package manifest');
|
|
@@ -121,17 +92,20 @@ const downloadOpenapi = async (manifest, cacheDirectory) => {
|
|
|
121
92
|
await rm(extractDirectory, { recursive: true, force: true });
|
|
122
93
|
await mkdir(extractDirectory, { recursive: true });
|
|
123
94
|
try {
|
|
124
|
-
|
|
95
|
+
const tarball = await res.arrayBuffer();
|
|
96
|
+
await writeFile(tarballFile, Buffer.from(tarball));
|
|
125
97
|
await extract({ file: tarballFile, cwd: extractDirectory }, [
|
|
126
98
|
openapiTarEntryName,
|
|
127
99
|
]);
|
|
128
100
|
const moduleFile = join(extractDirectory, openapiTarEntryName);
|
|
129
|
-
|
|
101
|
+
const moduleFileExists = await exists(moduleFile);
|
|
102
|
+
if (!moduleFileExists) {
|
|
130
103
|
throw new Error(`Missing ${openapiTarEntryName} in package tarball`);
|
|
131
104
|
}
|
|
132
105
|
// The OpenAPI document is published as a JavaScript module, so import it.
|
|
133
106
|
const openapiModuleUrl = pathToFileURL(moduleFile).href;
|
|
134
|
-
const
|
|
107
|
+
const openapiModule = (await import(openapiModuleUrl));
|
|
108
|
+
const { default: openapi } = openapiModule;
|
|
135
109
|
if (openapi == null) {
|
|
136
110
|
throw new Error(`Missing default export in ${openapiTarEntryName}`);
|
|
137
111
|
}
|
|
@@ -150,33 +124,5 @@ const exists = async (file) => {
|
|
|
150
124
|
return false;
|
|
151
125
|
}
|
|
152
126
|
};
|
|
153
|
-
const readCache = async (file) => {
|
|
154
|
-
try {
|
|
155
|
-
const cache = JSON.parse(await readFile(file, 'utf8'));
|
|
156
|
-
if (!isBlueprintCache(cache))
|
|
157
|
-
return null;
|
|
158
|
-
return cache;
|
|
159
|
-
}
|
|
160
|
-
catch {
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
const writeCache = async (file, cache) => {
|
|
165
|
-
const temporaryFile = `${file}.tmp`;
|
|
166
|
-
await mkdir(dirname(file), { recursive: true });
|
|
167
|
-
await writeFile(temporaryFile, `${JSON.stringify(cache)}\n`, 'utf8');
|
|
168
|
-
await rename(temporaryFile, file);
|
|
169
|
-
};
|
|
170
|
-
const isBlueprintCache = (cache) => {
|
|
171
|
-
if (cache == null || typeof cache !== 'object')
|
|
172
|
-
return false;
|
|
173
|
-
const { blueprintVersion, typesVersion, checkedAt, blueprint } = cache;
|
|
174
|
-
return (typeof blueprintVersion === 'string' &&
|
|
175
|
-
typeof typesVersion === 'string' &&
|
|
176
|
-
typeof checkedAt === 'string' &&
|
|
177
|
-
blueprint != null &&
|
|
178
|
-
typeof blueprint === 'object');
|
|
179
|
-
};
|
|
180
127
|
const toErrorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
181
|
-
|
|
182
|
-
//# sourceMappingURL=blueprint.js.map
|
|
128
|
+
//# sourceMappingURL=source-npm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-npm.js","sourceRoot":"","sources":["../../src/lib/blueprint/source-npm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAGxC,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAE7B,OAAO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;QACT,MAAM,EAAE,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAC9D,CAAC;AACH,CAAC,CAAA;AAED,MAAM,MAAM,GAAG,KAAK,EAAE,IAAY,EAAoB,EAAE;IACtD,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CAAC,CAAA;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,KAAc,EAAU,EAAE,CAChD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Blueprint } from '@seamapi/blueprint';
|
|
2
|
+
/**
|
|
3
|
+
* Build a blueprint from the OpenAPI document the current server is running,
|
|
4
|
+
* describing exactly what that server accepts rather than what is published.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createRemoteBlueprint: () => Promise<Blueprint>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resolveAuth } from '../context.js';
|
|
2
|
+
/**
|
|
3
|
+
* Build a blueprint from the OpenAPI document the current server is running,
|
|
4
|
+
* describing exactly what that server accepts rather than what is published.
|
|
5
|
+
*/
|
|
6
|
+
export const createRemoteBlueprint = async () => {
|
|
7
|
+
const [{ createBlueprint }, { getOpenapiSchema }] = await Promise.all([
|
|
8
|
+
import('@seamapi/blueprint'),
|
|
9
|
+
import('@seamapi/http/connect'),
|
|
10
|
+
]);
|
|
11
|
+
const openapi = await getOpenapiSchema(resolveAuth().server);
|
|
12
|
+
return await createBlueprint({ openapi }, { omitUndocumented: true });
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=source-remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-remote.js","sourceRoot":"","sources":["../../src/lib/blueprint/source-remote.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,IAAwB,EAAE;IAClE,MAAM,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACpE,MAAM,CAAC,oBAAoB,CAAC;QAC5B,MAAM,CAAC,uBAAuB,CAAC;KAChC,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,CAAA;IAE5D,OAAO,MAAM,eAAe,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAA;AACvE,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CliContext } from '../context.js';
|
|
2
|
+
import type { CommandResult, Invocation } from './registry.js';
|
|
3
|
+
/**
|
|
4
|
+
* Run a command that calls a Seam API endpoint: assemble the params,
|
|
5
|
+
* prompt for what is missing, make the request, and run any follow-ups
|
|
6
|
+
* the response calls for.
|
|
7
|
+
*/
|
|
8
|
+
export declare const executeApiCommand: (invocation: Invocation, ctx: CliContext) => Promise<CommandResult>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { isDeepStrictEqual as isEqual } from 'node:util';
|
|
2
|
+
import { coerceArgParams } from '../args/coerce.js';
|
|
3
|
+
import { parseCliArgs, toArgName, toArgParams } from '../args/parse.js';
|
|
4
|
+
import { assertRequiredParams } from '../args/validate.js';
|
|
5
|
+
import { getCommandBlueprintDef, getResponseKey, } from '../blueprint/endpoint.js';
|
|
6
|
+
import { UsageError } from '../errors.js';
|
|
7
|
+
import { runResponseFollowUps } from '../http/follow-ups.js';
|
|
8
|
+
import { requestSeamApi } from '../http/request.js';
|
|
9
|
+
import { interactForCommandParams } from '../interactions/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Run a command that calls a Seam API endpoint: assemble the params,
|
|
12
|
+
* prompt for what is missing, make the request, and run any follow-ups
|
|
13
|
+
* the response calls for.
|
|
14
|
+
*/
|
|
15
|
+
export const executeApiCommand = async (invocation, ctx) => {
|
|
16
|
+
const { path } = invocation;
|
|
17
|
+
const isNonInteractive = ctx.interactivity === 'non-interactive';
|
|
18
|
+
const apiPath = `/${path.join('/').replace(/-/g, '_')}`;
|
|
19
|
+
const parameters = getCommandBlueprintDef(path, ctx).request.parameters;
|
|
20
|
+
// Re-read the arguments knowing the endpoint's own parameter types — the
|
|
21
|
+
// generic first parse guessed, mangling opaque values like access codes —
|
|
22
|
+
// then coerce each value to the JSON type its parameter documents.
|
|
23
|
+
const stringKeys = parameters
|
|
24
|
+
.filter(({ format }) => format !== 'boolean' && format !== 'number')
|
|
25
|
+
.flatMap(({ name }) => [name, name.replace(/_/g, '-')]);
|
|
26
|
+
const { params: argParams, issues } = coerceArgParams(parameters, toArgParams(parseCliArgs(invocation.argv, { stringKeys })));
|
|
27
|
+
if (issues.length > 0) {
|
|
28
|
+
throw new UsageError(`Invalid ${issues.length === 1 ? 'value' : 'values'} for ${apiPath}: ${issues
|
|
29
|
+
.map(({ name, expected }) => `${toArgName(name)} expects ${expected}`)
|
|
30
|
+
.join('; ')}`, {
|
|
31
|
+
hint: `Run 'seam ${path.join(' ')} --help' to see what it accepts.`,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
// Params given as arguments win over params piped in.
|
|
35
|
+
const commandParams = { ...invocation.stdinParams };
|
|
36
|
+
Object.assign(commandParams, argParams);
|
|
37
|
+
applyEndpointDefaults(path, commandParams);
|
|
38
|
+
// Non-interactive runs never prompt: validate and send what was given.
|
|
39
|
+
let params;
|
|
40
|
+
if (isNonInteractive) {
|
|
41
|
+
assertRequiredParams(parameters, commandParams, apiPath);
|
|
42
|
+
params = commandParams;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const edited = await interactForCommandParams({ command: path, params: commandParams }, ctx);
|
|
46
|
+
if (edited === '[Back]') {
|
|
47
|
+
return { kind: 'back', toPath: path.slice(0, -1) };
|
|
48
|
+
}
|
|
49
|
+
params = edited;
|
|
50
|
+
}
|
|
51
|
+
if (apiPath.includes('/events/list') && params['between']) {
|
|
52
|
+
delete params['since'];
|
|
53
|
+
}
|
|
54
|
+
const api = await ctx.api();
|
|
55
|
+
const body = await requestSeamApi({ path: apiPath, params, responseKey: getResponseKey(path, ctx) }, { api, output: ctx.output });
|
|
56
|
+
await runResponseFollowUps(body, ctx);
|
|
57
|
+
return { kind: 'done' };
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Per-endpoint request policy that is not derivable from the API
|
|
61
|
+
* definitions. Keep this table small and explicit.
|
|
62
|
+
*/
|
|
63
|
+
const applyEndpointDefaults = (path, params) => {
|
|
64
|
+
// Unbounded event lists are never wanted, so default to the last month.
|
|
65
|
+
if (isEqual(path, ['events', 'list']) && !params['since']) {
|
|
66
|
+
const date = new Date();
|
|
67
|
+
date.setMonth(date.getMonth() - 1);
|
|
68
|
+
params['since'] = date.toISOString();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=api-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-command.js","sourceRoot":"","sources":["../../src/lib/commands/api-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EACL,sBAAsB,EACtB,cAAc,GACf,MAAM,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IACxB,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,CAAA;IAC3B,MAAM,IAAI,GAAG,MAAM,cAAc,CAC/B,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EACjE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAC5B,CAAA;IAED,MAAM,oBAAoB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAErC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;AACzB,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,qBAAqB,GAAG,CAC5B,IAAc,EACd,MAA2B,EACrB,EAAE;IACR,wEAAwE;IACxE,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAA;QACvB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAA;QAClC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;IACtC,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ApiBlueprint } from '../../blueprint/index.js';
|
|
2
|
+
import type { Command } from '../../commands/registry.js';
|
|
3
|
+
import type { CommandSpec } from '../../commands/spec.js';
|
|
4
|
+
import { type CompletionShell } from '../../render/completion/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Print the completion script for a shell.
|
|
7
|
+
*
|
|
8
|
+
* Completions always come from the cached API definitions so that they can
|
|
9
|
+
* be generated without logging in. They may lag the definitions served by
|
|
10
|
+
* Seam when config use-remote-api-defs is enabled.
|
|
11
|
+
*
|
|
12
|
+
* Called by the entry before any auth or blueprint context exists, and by
|
|
13
|
+
* the registered command's executor — one implementation for both.
|
|
14
|
+
*/
|
|
15
|
+
export declare const printCompletion: (shell: CompletionShell, spec: CommandSpec) => void;
|
|
16
|
+
type BuildSpec = (blueprint: ApiBlueprint) => CommandSpec;
|
|
17
|
+
export declare const createCompletionCommands: (buildSpec: BuildSpec) => Command[];
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getOutput } from '../../output/get-output.js';
|
|
2
|
+
import { renderCompletion, } from '../../render/completion/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Print the completion script for a shell.
|
|
5
|
+
*
|
|
6
|
+
* Completions always come from the cached API definitions so that they can
|
|
7
|
+
* be generated without logging in. They may lag the definitions served by
|
|
8
|
+
* Seam when config use-remote-api-defs is enabled.
|
|
9
|
+
*
|
|
10
|
+
* Called by the entry before any auth or blueprint context exists, and by
|
|
11
|
+
* the registered command's executor — one implementation for both.
|
|
12
|
+
*/
|
|
13
|
+
export const printCompletion = (shell, spec) => {
|
|
14
|
+
getOutput().text(renderCompletion(shell, spec));
|
|
15
|
+
};
|
|
16
|
+
const completionCommand = (shell, buildSpec) => ({
|
|
17
|
+
definition: {
|
|
18
|
+
path: ['completion', shell],
|
|
19
|
+
kind: 'cli',
|
|
20
|
+
title: `Print the ${shell} completion script.`,
|
|
21
|
+
description: '',
|
|
22
|
+
flags: [],
|
|
23
|
+
},
|
|
24
|
+
requiresAuth: false,
|
|
25
|
+
execute: async (_invocation, ctx) => {
|
|
26
|
+
printCompletion(shell, buildSpec(ctx.blueprint));
|
|
27
|
+
return { kind: 'done' };
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
export const createCompletionCommands = (buildSpec) => [
|
|
31
|
+
completionCommand('bash', buildSpec),
|
|
32
|
+
completionCommand('fish', buildSpec),
|
|
33
|
+
completionCommand('zsh', buildSpec),
|
|
34
|
+
];
|
|
35
|
+
//# sourceMappingURL=completion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.js","sourceRoot":"","sources":["../../../src/lib/commands/local/completion.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAEL,gBAAgB,GACjB,MAAM,gCAAgC,CAAA;AAEvC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAsB,EACtB,IAAiB,EACX,EAAE;IACR,SAAS,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;AACjD,CAAC,CAAA;AAID,MAAM,iBAAiB,GAAG,CACxB,KAAsB,EACtB,SAAoB,EACX,EAAE,CAAC,CAAC;IACb,UAAU,EAAE;QACV,IAAI,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC;QAC3B,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,aAAa,KAAK,qBAAqB;QAC9C,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,EAAE;KACV;IACD,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE;QAClC,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAA;QAChD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,SAAoB,EAAa,EAAE,CAAC;IAC3E,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC;IACpC,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC;IACpC,iBAAiB,CAAC,KAAK,EAAE,SAAS,CAAC;CACpC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const configRevealLocationCommand = {
|
|
2
|
+
definition: {
|
|
3
|
+
path: ['config', 'reveal-location'],
|
|
4
|
+
kind: 'cli',
|
|
5
|
+
title: 'Print the path to the CLI configuration file.',
|
|
6
|
+
description: '',
|
|
7
|
+
flags: [],
|
|
8
|
+
},
|
|
9
|
+
requiresAuth: true,
|
|
10
|
+
execute: async (_invocation, ctx) => {
|
|
11
|
+
ctx.output.text(ctx.config.path);
|
|
12
|
+
return { kind: 'done' };
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=config-reveal-location.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-reveal-location.js","sourceRoot":"","sources":["../../../src/lib/commands/local/config-reveal-location.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,2BAA2B,GAAY;IAClD,UAAU,EAAE;QACV,IAAI,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC;QACnC,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,+CAA+C;QACtD,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,EAAE;KACV;IACD,YAAY,EAAE,IAAI;IAClB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE;QAClC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAChC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { selectFakeServer } from '../../auth/operations.js';
|
|
2
|
+
/** Hidden: a development shortcut, kept out of help and completion. */
|
|
3
|
+
export const configSetFakeServerCommand = {
|
|
4
|
+
definition: {
|
|
5
|
+
path: ['config', 'set', 'fake-server'],
|
|
6
|
+
kind: 'cli',
|
|
7
|
+
title: 'Point the CLI at a fake Seam Connect server.',
|
|
8
|
+
description: '',
|
|
9
|
+
flags: [],
|
|
10
|
+
},
|
|
11
|
+
requiresAuth: false,
|
|
12
|
+
hidden: true,
|
|
13
|
+
execute: async (_invocation, ctx) => {
|
|
14
|
+
const { server } = selectFakeServer({ config: ctx.config });
|
|
15
|
+
ctx.output.info(`Server URL set to ${server}`);
|
|
16
|
+
ctx.output.info(`PAT set to use fakeseamconnect with "seam_apikey1_token"`);
|
|
17
|
+
return { kind: 'done' };
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=config-set-fake-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-set-fake-server.js","sourceRoot":"","sources":["../../../src/lib/commands/local/config-set-fake-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,uEAAuE;AACvE,MAAM,CAAC,MAAM,0BAA0B,GAAY;IACjD,UAAU,EAAE;QACV,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC;QACtC,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,8CAA8C;QACrD,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,EAAE;KACV;IACD,YAAY,EAAE,KAAK;IACnB,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE;QAClC,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAA;QAC3D,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,MAAM,EAAE,CAAC,CAAA;QAC9C,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAA;QAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NonInteractiveError } from '../../errors.js';
|
|
2
|
+
import { interactForUseRemoteApiDefs } from '../../interactions/index.js';
|
|
3
|
+
export const configUseRemoteApiDefsCommand = {
|
|
4
|
+
definition: {
|
|
5
|
+
path: ['config', 'use-remote-api-defs'],
|
|
6
|
+
kind: 'cli',
|
|
7
|
+
title: 'Choose whether to use the API definitions served by Seam.',
|
|
8
|
+
description: '',
|
|
9
|
+
flags: [],
|
|
10
|
+
},
|
|
11
|
+
requiresAuth: true,
|
|
12
|
+
execute: async (_invocation, ctx) => {
|
|
13
|
+
if (ctx.interactivity === 'non-interactive') {
|
|
14
|
+
throw new NonInteractiveError('Cannot select whether to use remote API definitions in non-interactive mode');
|
|
15
|
+
}
|
|
16
|
+
await interactForUseRemoteApiDefs();
|
|
17
|
+
return { kind: 'done' };
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=config-use-remote-api-defs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-use-remote-api-defs.js","sourceRoot":"","sources":["../../../src/lib/commands/local/config-use-remote-api-defs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAEvE,MAAM,CAAC,MAAM,6BAA6B,GAAY;IACpD,UAAU,EAAE;QACV,IAAI,EAAE,CAAC,QAAQ,EAAE,qBAAqB,CAAC;QACvC,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,2DAA2D;QAClE,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,EAAE;KACV;IACD,YAAY,EAAE,IAAI;IAClB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE;QAClC,IAAI,GAAG,CAAC,aAAa,KAAK,iBAAiB,EAAE,CAAC;YAC5C,MAAM,IAAI,mBAAmB,CAC3B,6EAA6E,CAC9E,CAAA;QACH,CAAC;QACD,MAAM,2BAA2B,EAAE,CAAA;QACnC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { requestSeamApi } from '../../http/request.js';
|
|
2
|
+
export const healthCommand = {
|
|
3
|
+
definition: {
|
|
4
|
+
path: ['health', 'get-health'],
|
|
5
|
+
// Handled by the CLI itself, but calls the Seam API.
|
|
6
|
+
kind: 'api',
|
|
7
|
+
title: 'Report the health of the Seam API.',
|
|
8
|
+
description: '',
|
|
9
|
+
flags: [],
|
|
10
|
+
},
|
|
11
|
+
requiresAuth: true,
|
|
12
|
+
execute: async (_invocation, ctx) => {
|
|
13
|
+
const api = await ctx.api();
|
|
14
|
+
await requestSeamApi({ path: '/health/get_health', params: {} }, { api, output: ctx.output });
|
|
15
|
+
return { kind: 'done' };
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../../src/lib/commands/local/health.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,MAAM,CAAC,MAAM,aAAa,GAAY;IACpC,UAAU,EAAE;QACV,IAAI,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC;QAC9B,qDAAqD;QACrD,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,oCAAoC;QAC3C,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,EAAE;KACV;IACD,YAAY,EAAE,IAAI;IAClB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE;QAClC,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,CAAA;QAC3B,MAAM,cAAc,CAClB,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,EAAE,EAAE,EAAE,EAC1C,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAC5B,CAAA;QACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { assertMutable, login } from '../../auth/operations.js';
|
|
2
|
+
import { stringFlag } from '../../commands/spec.js';
|
|
3
|
+
import { NonInteractiveError } from '../../errors.js';
|
|
4
|
+
import { interactForLogin } from '../../interactions/index.js';
|
|
5
|
+
export const loginCommand = {
|
|
6
|
+
definition: {
|
|
7
|
+
path: ['login'],
|
|
8
|
+
kind: 'cli',
|
|
9
|
+
title: 'Log in to Seam.',
|
|
10
|
+
description: 'Prompts for a personal access token unless one is passed with --token.',
|
|
11
|
+
flags: [
|
|
12
|
+
stringFlag('server', 'Seam API server to log in to.'),
|
|
13
|
+
stringFlag('token', 'Personal access token to log in with.'),
|
|
14
|
+
stringFlag('workspace-id', 'Workspace to select after logging in.'),
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
requiresAuth: false,
|
|
18
|
+
execute: async ({ args }, ctx) => {
|
|
19
|
+
if (args['token'] || args['workspace_id'] || args['server']) {
|
|
20
|
+
await login({
|
|
21
|
+
server: args['server'] ? args['server'] : undefined,
|
|
22
|
+
token: args['token'] ? String(args['token']).trim() : undefined,
|
|
23
|
+
workspaceId: args['workspace_id'] ? args['workspace_id'] : undefined,
|
|
24
|
+
}, ctx.config);
|
|
25
|
+
return { kind: 'done' };
|
|
26
|
+
}
|
|
27
|
+
assertMutable(ctx.auth, 'token', 'log in');
|
|
28
|
+
if (ctx.interactivity === 'non-interactive') {
|
|
29
|
+
throw new NonInteractiveError('Missing required parameter for login: --token');
|
|
30
|
+
}
|
|
31
|
+
await interactForLogin();
|
|
32
|
+
return { kind: 'done' };
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/lib/commands/local/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAE7D,OAAO,EAAE,UA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C1C,IAAI,GAAG,CAAC,aAAa,KAAK,iBAAiB,EAAE,CAAC;YAC5C,MAAM,IAAI,mBAAmB,CAC3B,+CAA+C,CAChD,CAAA;QACH,CAAC;QACD,MAAM,gBAAgB,EAAE,CAAA;QACxB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { logout } from '../../auth/operations.js';
|
|
2
|
+
export const logoutCommand = {
|
|
3
|
+
definition: {
|
|
4
|
+
path: ['logout'],
|
|
5
|
+
kind: 'cli',
|
|
6
|
+
title: 'Log out of Seam.',
|
|
7
|
+
description: '',
|
|
8
|
+
flags: [],
|
|
9
|
+
},
|
|
10
|
+
requiresAuth: true,
|
|
11
|
+
execute: async (_invocation, ctx) => {
|
|
12
|
+
logout(ctx.config);
|
|
13
|
+
ctx.output.info('Logged out!');
|
|
14
|
+
return { kind: 'done' };
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/lib/commands/local/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAG/C,MAAM,CAAC,MAAM,aAAa,GAAY;IACpC,UAAU,EAAE;QACV,IAAI,EAAE,CAAC,QAAQ,CAAC;QAChB,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,EAAE;KACV;IACD,YAAY,EAAE,IAAI;IAClB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE;QAClC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAClB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { assertMutable, selectServer } from '../../auth/operations.js';
|
|
2
|
+
import { stringFlag } from '../../commands/spec.js';
|
|
3
|
+
import { NonInteractiveError } from '../../errors.js';
|
|
4
|
+
import { interactForServerSelection } from '../../interactions/index.js';
|
|
5
|
+
export const selectServerCommand = {
|
|
6
|
+
definition: {
|
|
7
|
+
path: ['select', 'server'],
|
|
8
|
+
kind: 'cli',
|
|
9
|
+
title: 'Select the Seam API server.',
|
|
10
|
+
description: '',
|
|
11
|
+
flags: [stringFlag('server', 'Seam API server to select.')],
|
|
12
|
+
},
|
|
13
|
+
requiresAuth: false,
|
|
14
|
+
execute: async ({ args }, ctx) => {
|
|
15
|
+
assertMutable(ctx.auth, 'server', 'select a server');
|
|
16
|
+
if (args['server']) {
|
|
17
|
+
selectServer(args['server'], ctx.config);
|
|
18
|
+
return { kind: 'done' };
|
|
19
|
+
}
|
|
20
|
+
if (ctx.interactivity === 'non-interactive') {
|
|
21
|
+
throw new NonInteractiveError('Missing required parameter for select server: --server');
|
|
22
|
+
}
|
|
23
|
+
await interactForServerSelection();
|
|
24
|
+
return { kind: 'done' };
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=select-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-server.js","sourceRoot":"","sources":["../../../src/lib/commands/local/select-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAA;AAEtE,MAAM,CAAC,MAAM,mBAAmB,GAAY;IAC1C,UAAU,EAAE;QACV,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;QAC1B,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAC;KAC5D;IACD,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE;QAC/B,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAA;QACpD,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnB,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;YACxC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;QACzB,CAAC;QACD,IAAI,GAAG,CAAC,aAAa,KAAK,iBAAiB,EAAE,CAAC;YAC5C,MAAM,IAAI,mBAAmB,CAC3B,wDAAwD,CACzD,CAAA;QACH,CAAC;QACD,MAAM,0BAA0B,EAAE,CAAA;QAClC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { assertMutable } from '../../auth/operations.js';
|
|
2
|
+
import { NonInteractiveError } from '../../errors.js';
|
|
3
|
+
import { interactForWorkspaceId } from '../../interactions/index.js';
|
|
4
|
+
export const selectWorkspaceCommand = {
|
|
5
|
+
definition: {
|
|
6
|
+
path: ['select', 'workspace'],
|
|
7
|
+
kind: 'cli',
|
|
8
|
+
title: 'Select the current workspace.',
|
|
9
|
+
description: '',
|
|
10
|
+
flags: [],
|
|
11
|
+
},
|
|
12
|
+
requiresAuth: true,
|
|
13
|
+
execute: async (_invocation, ctx) => {
|
|
14
|
+
assertMutable(ctx.auth, 'workspaceId', 'select a workspace');
|
|
15
|
+
if (ctx.interactivity === 'non-interactive') {
|
|
16
|
+
throw new NonInteractiveError('Cannot select a workspace in non-interactive mode: pass --workspace-id to "seam login"');
|
|
17
|
+
}
|
|
18
|
+
await interactForWorkspaceId();
|
|
19
|
+
return { kind: 'done' };
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=select-workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-workspace.js","sourceRoot":"","sources":["../../../src/lib/commands/local/select-workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAElE,MAAM,CAAC,MAAM,sBAAsB,GAAY;IAC7C,UAAU,EAAE;QACV,IAAI,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;QAC7B,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,+BAA+B;QACtC,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,EAAE;KACV;IACD,YAAY,EAAE,IAAI;IAClB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE;QAClC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAA;QAC5D,IAAI,GAAG,CAAC,aAAa,KAAK,iBAAiB,EAAE,CAAC;YAC5C,MAAM,IAAI,mBAAmB,CAC3B,wFAAwF,CACzF,CAAA;QACH,CAAC;QACD,MAAM,sBAAsB,EAAE,CAAA;QAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Command } from '../../commands/registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* Run the Seam setup wizard.
|
|
4
|
+
*
|
|
5
|
+
* Intercepted by the entry before argument parsing so the wizard owns its
|
|
6
|
+
* own argv; the registered executor covers selecting it interactively.
|
|
7
|
+
*/
|
|
8
|
+
export declare const runWizard: (argv: string[]) => Promise<void>;
|
|
9
|
+
export declare const wizardCommand: Command;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run the Seam setup wizard.
|
|
3
|
+
*
|
|
4
|
+
* Intercepted by the entry before argument parsing so the wizard owns its
|
|
5
|
+
* own argv; the registered executor covers selecting it interactively.
|
|
6
|
+
*/
|
|
7
|
+
export const runWizard = async (argv) => {
|
|
8
|
+
const { default: wizard } = await import('@seamapi/wizard');
|
|
9
|
+
await wizard({
|
|
10
|
+
argv,
|
|
11
|
+
commandName: 'seam wizard',
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
export const wizardCommand = {
|
|
15
|
+
definition: {
|
|
16
|
+
path: ['wizard'],
|
|
17
|
+
kind: 'cli',
|
|
18
|
+
title: 'Set up Seam in the current project.',
|
|
19
|
+
description: 'Takes a project from zero to a working Seam integration. Run seam wizard --help for its own options.',
|
|
20
|
+
flags: [],
|
|
21
|
+
},
|
|
22
|
+
requiresAuth: false,
|
|
23
|
+
execute: async () => {
|
|
24
|
+
await runWizard([]);
|
|
25
|
+
return { kind: 'done' };
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=wizard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wizard.js","sourceRoot":"","sources":["../../../src/lib/commands/local/wizard.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,IAAc,EAAiB,EAAE;IAC/D,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAA;IAC3D,MAAM,MAAM,CAAC;QACX,IAAI;QACJ,WAAW,EAAE,aAAa;KAC3B,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAY;IACpC,UAAU,EAAE;QACV,IAAI,EAAE,CAAC,QAAQ,CAAC;QAChB,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,qCAAqC;QAC5C,WAAW,EACT,sGAAsG;QACxG,KAAK,EAAE,EAAE;KACV;IACD,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,MAAM,SAAS,CAAC,EAAE,CAAC,CAAA;QACnB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
|