@marinoscar/platform-cli 0.1.0-next.3 → 0.1.0-next.5
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/CHANGELOG.md +88 -0
- package/README.md +126 -31
- package/dist/android/build.d.ts +30 -0
- package/dist/android/build.d.ts.map +1 -0
- package/dist/android/build.js +126 -0
- package/dist/android/build.js.map +1 -0
- package/dist/android/command.d.ts +21 -0
- package/dist/android/command.d.ts.map +1 -0
- package/dist/android/command.js +355 -0
- package/dist/android/command.js.map +1 -0
- package/dist/android/deploy-step.d.ts +85 -0
- package/dist/android/deploy-step.d.ts.map +1 -0
- package/dist/android/deploy-step.js +268 -0
- package/dist/android/deploy-step.js.map +1 -0
- package/dist/android/doctor.d.ts +47 -0
- package/dist/android/doctor.d.ts.map +1 -0
- package/dist/android/doctor.js +219 -0
- package/dist/android/doctor.js.map +1 -0
- package/dist/android/exec.d.ts +42 -0
- package/dist/android/exec.d.ts.map +1 -0
- package/dist/android/exec.js +103 -0
- package/dist/android/exec.js.map +1 -0
- package/dist/android/fix-plan.d.ts +44 -0
- package/dist/android/fix-plan.d.ts.map +1 -0
- package/dist/android/fix-plan.js +86 -0
- package/dist/android/fix-plan.js.map +1 -0
- package/dist/android/git-freshness.d.ts +34 -0
- package/dist/android/git-freshness.d.ts.map +1 -0
- package/dist/android/git-freshness.js +120 -0
- package/dist/android/git-freshness.js.map +1 -0
- package/dist/android/gradle.d.ts +32 -0
- package/dist/android/gradle.d.ts.map +1 -0
- package/dist/android/gradle.js +55 -0
- package/dist/android/gradle.js.map +1 -0
- package/dist/android/identity.d.ts +27 -0
- package/dist/android/identity.d.ts.map +1 -0
- package/dist/android/identity.js +60 -0
- package/dist/android/identity.js.map +1 -0
- package/dist/android/index.d.ts +7 -0
- package/dist/android/index.d.ts.map +1 -0
- package/dist/android/index.js +8 -0
- package/dist/android/index.js.map +1 -0
- package/dist/android/installer.d.ts +28 -0
- package/dist/android/installer.d.ts.map +1 -0
- package/dist/android/installer.js +96 -0
- package/dist/android/installer.js.map +1 -0
- package/dist/android/java.d.ts +26 -0
- package/dist/android/java.d.ts.map +1 -0
- package/dist/android/java.js +65 -0
- package/dist/android/java.js.map +1 -0
- package/dist/android/keystore.d.ts +54 -0
- package/dist/android/keystore.d.ts.map +1 -0
- package/dist/android/keystore.js +159 -0
- package/dist/android/keystore.js.map +1 -0
- package/dist/android/metadata.d.ts +39 -0
- package/dist/android/metadata.d.ts.map +1 -0
- package/dist/android/metadata.js +61 -0
- package/dist/android/metadata.js.map +1 -0
- package/dist/android/operations.d.ts +42 -0
- package/dist/android/operations.d.ts.map +1 -0
- package/dist/android/operations.js +59 -0
- package/dist/android/operations.js.map +1 -0
- package/dist/android/paths.d.ts +29 -0
- package/dist/android/paths.d.ts.map +1 -0
- package/dist/android/paths.js +97 -0
- package/dist/android/paths.js.map +1 -0
- package/dist/android/publish.d.ts +37 -0
- package/dist/android/publish.d.ts.map +1 -0
- package/dist/android/publish.js +119 -0
- package/dist/android/publish.js.map +1 -0
- package/dist/android/registrations.d.ts +92 -0
- package/dist/android/registrations.d.ts.map +1 -0
- package/dist/android/registrations.js +112 -0
- package/dist/android/registrations.js.map +1 -0
- package/dist/android/release-status.d.ts +73 -0
- package/dist/android/release-status.d.ts.map +1 -0
- package/dist/android/release-status.js +161 -0
- package/dist/android/release-status.js.map +1 -0
- package/dist/android/release.d.ts +33 -0
- package/dist/android/release.d.ts.map +1 -0
- package/dist/android/release.js +59 -0
- package/dist/android/release.js.map +1 -0
- package/dist/android/screen-layout.d.ts +26 -0
- package/dist/android/screen-layout.d.ts.map +1 -0
- package/dist/android/screen-layout.js +24 -0
- package/dist/android/screen-layout.js.map +1 -0
- package/dist/android/screen-model.d.ts +56 -0
- package/dist/android/screen-model.d.ts.map +1 -0
- package/dist/android/screen-model.js +207 -0
- package/dist/android/screen-model.js.map +1 -0
- package/dist/android/screen.d.ts +8 -0
- package/dist/android/screen.d.ts.map +1 -0
- package/dist/android/screen.js +395 -0
- package/dist/android/screen.js.map +1 -0
- package/dist/android/sdk.d.ts +48 -0
- package/dist/android/sdk.d.ts.map +1 -0
- package/dist/android/sdk.js +82 -0
- package/dist/android/sdk.js.map +1 -0
- package/dist/android/server-url.d.ts +19 -0
- package/dist/android/server-url.d.ts.map +1 -0
- package/dist/android/server-url.js +36 -0
- package/dist/android/server-url.js.map +1 -0
- package/dist/android/upload-progress.d.ts +3 -0
- package/dist/android/upload-progress.d.ts.map +1 -0
- package/dist/android/upload-progress.js +47 -0
- package/dist/android/upload-progress.js.map +1 -0
- package/dist/android/version.d.ts +47 -0
- package/dist/android/version.d.ts.map +1 -0
- package/dist/android/version.js +136 -0
- package/dist/android/version.js.map +1 -0
- package/dist/api-client/index.d.ts +3 -0
- package/dist/api-client/index.d.ts.map +1 -0
- package/dist/api-client/index.js +5 -0
- package/dist/api-client/index.js.map +1 -0
- package/dist/commands/index.d.ts +52 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +63 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/core/cli-registry.d.ts +41 -0
- package/dist/core/cli-registry.d.ts.map +1 -0
- package/dist/core/cli-registry.js +49 -0
- package/dist/core/cli-registry.js.map +1 -0
- package/dist/core/command-registry.d.ts +10 -0
- package/dist/core/command-registry.d.ts.map +1 -1
- package/dist/core/command-registry.js +17 -0
- package/dist/core/command-registry.js.map +1 -1
- package/dist/core/env-annotation-registry.d.ts +58 -0
- package/dist/core/env-annotation-registry.d.ts.map +1 -0
- package/dist/core/env-annotation-registry.js +80 -0
- package/dist/core/env-annotation-registry.js.map +1 -0
- package/dist/core/env-generator-registry.d.ts +59 -0
- package/dist/core/env-generator-registry.d.ts.map +1 -0
- package/dist/core/env-generator-registry.js +102 -0
- package/dist/core/env-generator-registry.js.map +1 -0
- package/dist/core/env-group-registry.d.ts +65 -0
- package/dist/core/env-group-registry.d.ts.map +1 -0
- package/dist/core/env-group-registry.js +77 -0
- package/dist/core/env-group-registry.js.map +1 -0
- package/dist/core/env-spec-registry.d.ts +16 -2
- package/dist/core/env-spec-registry.d.ts.map +1 -1
- package/dist/core/env-spec-registry.js +15 -0
- package/dist/core/env-spec-registry.js.map +1 -1
- package/dist/core/env-values.d.ts +3 -2
- package/dist/core/env-values.d.ts.map +1 -1
- package/dist/core/env-values.js +5 -3
- package/dist/core/env-values.js.map +1 -1
- package/dist/core/index.d.ts +10 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -2
- package/dist/core/index.js.map +1 -1
- package/dist/deploy/index.d.ts +3 -0
- package/dist/deploy/index.d.ts.map +1 -0
- package/dist/deploy/index.js +5 -0
- package/dist/deploy/index.js.map +1 -0
- package/dist/engine/api-client.d.ts +211 -0
- package/dist/engine/api-client.d.ts.map +1 -0
- package/dist/engine/api-client.js +350 -0
- package/dist/engine/api-client.js.map +1 -0
- package/dist/engine/browser.d.ts +18 -0
- package/dist/engine/browser.d.ts.map +1 -0
- package/dist/engine/browser.js +115 -0
- package/dist/engine/browser.js.map +1 -0
- package/dist/engine/builtin-registrations.d.ts +20 -0
- package/dist/engine/builtin-registrations.d.ts.map +1 -0
- package/dist/engine/builtin-registrations.js +86 -0
- package/dist/engine/builtin-registrations.js.map +1 -0
- package/dist/engine/commands/api.d.ts +88 -0
- package/dist/engine/commands/api.d.ts.map +1 -0
- package/dist/engine/commands/api.js +398 -0
- package/dist/engine/commands/api.js.map +1 -0
- package/dist/engine/commands/config.d.ts +5 -0
- package/dist/engine/commands/config.d.ts.map +1 -0
- package/dist/engine/commands/config.js +83 -0
- package/dist/engine/commands/config.js.map +1 -0
- package/dist/engine/commands/deploy.d.ts +243 -0
- package/dist/engine/commands/deploy.d.ts.map +1 -0
- package/dist/engine/commands/deploy.js +1159 -0
- package/dist/engine/commands/deploy.js.map +1 -0
- package/dist/engine/commands/init.d.ts +18 -0
- package/dist/engine/commands/init.d.ts.map +1 -0
- package/dist/engine/commands/init.js +50 -0
- package/dist/engine/commands/init.js.map +1 -0
- package/dist/engine/commands/login.d.ts +4 -0
- package/dist/engine/commands/login.d.ts.map +1 -0
- package/dist/engine/commands/login.js +205 -0
- package/dist/engine/commands/login.js.map +1 -0
- package/dist/engine/commands/node.d.ts +21 -0
- package/dist/engine/commands/node.d.ts.map +1 -0
- package/dist/engine/commands/node.js +436 -0
- package/dist/engine/commands/node.js.map +1 -0
- package/dist/engine/config.d.ts +246 -0
- package/dist/engine/config.d.ts.map +1 -0
- package/dist/engine/config.js +414 -0
- package/dist/engine/config.js.map +1 -0
- package/dist/engine/conformance.d.ts +187 -0
- package/dist/engine/conformance.d.ts.map +1 -0
- package/dist/engine/conformance.js +227 -0
- package/dist/engine/conformance.js.map +1 -0
- package/dist/engine/create-cli.d.ts +94 -0
- package/dist/engine/create-cli.d.ts.map +1 -0
- package/dist/engine/create-cli.js +60 -0
- package/dist/engine/create-cli.js.map +1 -0
- package/dist/engine/deploy/about.d.ts +12 -0
- package/dist/engine/deploy/about.d.ts.map +1 -0
- package/dist/engine/deploy/about.js +110 -0
- package/dist/engine/deploy/about.js.map +1 -0
- package/dist/engine/deploy/adopt.d.ts +21 -0
- package/dist/engine/deploy/adopt.d.ts.map +1 -0
- package/dist/engine/deploy/adopt.js +78 -0
- package/dist/engine/deploy/adopt.js.map +1 -0
- package/dist/engine/deploy/answers-file.d.ts +7 -0
- package/dist/engine/deploy/answers-file.d.ts.map +1 -0
- package/dist/engine/deploy/answers-file.js +49 -0
- package/dist/engine/deploy/answers-file.js.map +1 -0
- package/dist/engine/deploy/app-role.d.ts +278 -0
- package/dist/engine/deploy/app-role.d.ts.map +1 -0
- package/dist/engine/deploy/app-role.js +826 -0
- package/dist/engine/deploy/app-role.js.map +1 -0
- package/dist/engine/deploy/app-version.d.ts +47 -0
- package/dist/engine/deploy/app-version.d.ts.map +1 -0
- package/dist/engine/deploy/app-version.js +232 -0
- package/dist/engine/deploy/app-version.js.map +1 -0
- package/dist/engine/deploy/checks/database.d.ts +83 -0
- package/dist/engine/deploy/checks/database.d.ts.map +1 -0
- package/dist/engine/deploy/checks/database.js +455 -0
- package/dist/engine/deploy/checks/database.js.map +1 -0
- package/dist/engine/deploy/checks/dns.d.ts +3 -0
- package/dist/engine/deploy/checks/dns.d.ts.map +1 -0
- package/dist/engine/deploy/checks/dns.js +85 -0
- package/dist/engine/deploy/checks/dns.js.map +1 -0
- package/dist/engine/deploy/checks/host.d.ts +19 -0
- package/dist/engine/deploy/checks/host.d.ts.map +1 -0
- package/dist/engine/deploy/checks/host.js +530 -0
- package/dist/engine/deploy/checks/host.js.map +1 -0
- package/dist/engine/deploy/checks/index.d.ts +33 -0
- package/dist/engine/deploy/checks/index.d.ts.map +1 -0
- package/dist/engine/deploy/checks/index.js +67 -0
- package/dist/engine/deploy/checks/index.js.map +1 -0
- package/dist/engine/deploy/checks/registry.d.ts +102 -0
- package/dist/engine/deploy/checks/registry.d.ts.map +1 -0
- package/dist/engine/deploy/checks/registry.js +103 -0
- package/dist/engine/deploy/checks/registry.js.map +1 -0
- package/dist/engine/deploy/checks/source.d.ts +45 -0
- package/dist/engine/deploy/checks/source.d.ts.map +1 -0
- package/dist/engine/deploy/checks/source.js +175 -0
- package/dist/engine/deploy/checks/source.js.map +1 -0
- package/dist/engine/deploy/checks/tls.d.ts +87 -0
- package/dist/engine/deploy/checks/tls.d.ts.map +1 -0
- package/dist/engine/deploy/checks/tls.js +552 -0
- package/dist/engine/deploy/checks/tls.js.map +1 -0
- package/dist/engine/deploy/checks/types.d.ts +178 -0
- package/dist/engine/deploy/checks/types.d.ts.map +1 -0
- package/dist/engine/deploy/checks/types.js +199 -0
- package/dist/engine/deploy/checks/types.js.map +1 -0
- package/dist/engine/deploy/compose-files.d.ts +29 -0
- package/dist/engine/deploy/compose-files.d.ts.map +1 -0
- package/dist/engine/deploy/compose-files.js +118 -0
- package/dist/engine/deploy/compose-files.js.map +1 -0
- package/dist/engine/deploy/consent.d.ts +29 -0
- package/dist/engine/deploy/consent.d.ts.map +1 -0
- package/dist/engine/deploy/consent.js +35 -0
- package/dist/engine/deploy/consent.js.map +1 -0
- package/dist/engine/deploy/database-drop.d.ts +22 -0
- package/dist/engine/deploy/database-drop.d.ts.map +1 -0
- package/dist/engine/deploy/database-drop.js +135 -0
- package/dist/engine/deploy/database-drop.js.map +1 -0
- package/dist/engine/deploy/database.d.ts +116 -0
- package/dist/engine/deploy/database.d.ts.map +1 -0
- package/dist/engine/deploy/database.js +252 -0
- package/dist/engine/deploy/database.js.map +1 -0
- package/dist/engine/deploy/deploy-info.d.ts +48 -0
- package/dist/engine/deploy/deploy-info.d.ts.map +1 -0
- package/dist/engine/deploy/deploy-info.js +163 -0
- package/dist/engine/deploy/deploy-info.js.map +1 -0
- package/dist/engine/deploy/deployment-evidence.d.ts +38 -0
- package/dist/engine/deploy/deployment-evidence.d.ts.map +1 -0
- package/dist/engine/deploy/deployment-evidence.js +92 -0
- package/dist/engine/deploy/deployment-evidence.js.map +1 -0
- package/dist/engine/deploy/edge-config.d.ts +103 -0
- package/dist/engine/deploy/edge-config.d.ts.map +1 -0
- package/dist/engine/deploy/edge-config.js +170 -0
- package/dist/engine/deploy/edge-config.js.map +1 -0
- package/dist/engine/deploy/env-absence.d.ts +61 -0
- package/dist/engine/deploy/env-absence.d.ts.map +1 -0
- package/dist/engine/deploy/env-absence.js +33 -0
- package/dist/engine/deploy/env-absence.js.map +1 -0
- package/dist/engine/deploy/env-file.d.ts +14 -0
- package/dist/engine/deploy/env-file.d.ts.map +1 -0
- package/dist/engine/deploy/env-file.js +58 -0
- package/dist/engine/deploy/env-file.js.map +1 -0
- package/dist/engine/deploy/env-fragments.d.ts +29 -0
- package/dist/engine/deploy/env-fragments.d.ts.map +1 -0
- package/dist/engine/deploy/env-fragments.js +73 -0
- package/dist/engine/deploy/env-fragments.js.map +1 -0
- package/dist/engine/deploy/env-metadata.d.ts +73 -0
- package/dist/engine/deploy/env-metadata.d.ts.map +1 -0
- package/dist/engine/deploy/env-metadata.js +227 -0
- package/dist/engine/deploy/env-metadata.js.map +1 -0
- package/dist/engine/deploy/env-spec.d.ts +75 -0
- package/dist/engine/deploy/env-spec.d.ts.map +1 -0
- package/dist/engine/deploy/env-spec.js +239 -0
- package/dist/engine/deploy/env-spec.js.map +1 -0
- package/dist/engine/deploy/env-wizard.d.ts +56 -0
- package/dist/engine/deploy/env-wizard.d.ts.map +1 -0
- package/dist/engine/deploy/env-wizard.js +235 -0
- package/dist/engine/deploy/env-wizard.js.map +1 -0
- package/dist/engine/deploy/executor.d.ts +81 -0
- package/dist/engine/deploy/executor.d.ts.map +1 -0
- package/dist/engine/deploy/executor.js +247 -0
- package/dist/engine/deploy/executor.js.map +1 -0
- package/dist/engine/deploy/health.d.ts +146 -0
- package/dist/engine/deploy/health.d.ts.map +1 -0
- package/dist/engine/deploy/health.js +323 -0
- package/dist/engine/deploy/health.js.map +1 -0
- package/dist/engine/deploy/hooks.d.ts +66 -0
- package/dist/engine/deploy/hooks.d.ts.map +1 -0
- package/dist/engine/deploy/hooks.js +19 -0
- package/dist/engine/deploy/hooks.js.map +1 -0
- package/dist/engine/deploy/host-facts.d.ts +23 -0
- package/dist/engine/deploy/host-facts.d.ts.map +1 -0
- package/dist/engine/deploy/host-facts.js +67 -0
- package/dist/engine/deploy/host-facts.js.map +1 -0
- package/dist/engine/deploy/install.d.ts +233 -0
- package/dist/engine/deploy/install.d.ts.map +1 -0
- package/dist/engine/deploy/install.js +1304 -0
- package/dist/engine/deploy/install.js.map +1 -0
- package/dist/engine/deploy/inventory.d.ts +30 -0
- package/dist/engine/deploy/inventory.d.ts.map +1 -0
- package/dist/engine/deploy/inventory.js +122 -0
- package/dist/engine/deploy/inventory.js.map +1 -0
- package/dist/engine/deploy/journal.d.ts +77 -0
- package/dist/engine/deploy/journal.d.ts.map +1 -0
- package/dist/engine/deploy/journal.js +221 -0
- package/dist/engine/deploy/journal.js.map +1 -0
- package/dist/engine/deploy/layout.d.ts +77 -0
- package/dist/engine/deploy/layout.d.ts.map +1 -0
- package/dist/engine/deploy/layout.js +191 -0
- package/dist/engine/deploy/layout.js.map +1 -0
- package/dist/engine/deploy/oauth-check.d.ts +58 -0
- package/dist/engine/deploy/oauth-check.d.ts.map +1 -0
- package/dist/engine/deploy/oauth-check.js +213 -0
- package/dist/engine/deploy/oauth-check.js.map +1 -0
- package/dist/engine/deploy/proxy-bootstrap.d.ts +149 -0
- package/dist/engine/deploy/proxy-bootstrap.d.ts.map +1 -0
- package/dist/engine/deploy/proxy-bootstrap.js +416 -0
- package/dist/engine/deploy/proxy-bootstrap.js.map +1 -0
- package/dist/engine/deploy/proxy-streams.d.ts +110 -0
- package/dist/engine/deploy/proxy-streams.d.ts.map +1 -0
- package/dist/engine/deploy/proxy-streams.js +208 -0
- package/dist/engine/deploy/proxy-streams.js.map +1 -0
- package/dist/engine/deploy/proxy.d.ts +375 -0
- package/dist/engine/deploy/proxy.d.ts.map +1 -0
- package/dist/engine/deploy/proxy.js +758 -0
- package/dist/engine/deploy/proxy.js.map +1 -0
- package/dist/engine/deploy/renewal.d.ts +54 -0
- package/dist/engine/deploy/renewal.d.ts.map +1 -0
- package/dist/engine/deploy/renewal.js +169 -0
- package/dist/engine/deploy/renewal.js.map +1 -0
- package/dist/engine/deploy/repo.d.ts +101 -0
- package/dist/engine/deploy/repo.d.ts.map +1 -0
- package/dist/engine/deploy/repo.js +250 -0
- package/dist/engine/deploy/repo.js.map +1 -0
- package/dist/engine/deploy/run-record.d.ts +28 -0
- package/dist/engine/deploy/run-record.d.ts.map +1 -0
- package/dist/engine/deploy/run-record.js +44 -0
- package/dist/engine/deploy/run-record.js.map +1 -0
- package/dist/engine/deploy/state.d.ts +262 -0
- package/dist/engine/deploy/state.d.ts.map +1 -0
- package/dist/engine/deploy/state.js +163 -0
- package/dist/engine/deploy/state.js.map +1 -0
- package/dist/engine/deploy/steps/app-step-context.d.ts +24 -0
- package/dist/engine/deploy/steps/app-step-context.d.ts.map +1 -0
- package/dist/engine/deploy/steps/app-step-context.js +45 -0
- package/dist/engine/deploy/steps/app-step-context.js.map +1 -0
- package/dist/engine/deploy/steps/pipeline.d.ts +46 -0
- package/dist/engine/deploy/steps/pipeline.d.ts.map +1 -0
- package/dist/engine/deploy/steps/pipeline.js +73 -0
- package/dist/engine/deploy/steps/pipeline.js.map +1 -0
- package/dist/engine/deploy/steps/plan.d.ts +28 -0
- package/dist/engine/deploy/steps/plan.d.ts.map +1 -0
- package/dist/engine/deploy/steps/plan.js +32 -0
- package/dist/engine/deploy/steps/plan.js.map +1 -0
- package/dist/engine/deploy/steps/registry.d.ts +182 -0
- package/dist/engine/deploy/steps/registry.d.ts.map +1 -0
- package/dist/engine/deploy/steps/registry.js +212 -0
- package/dist/engine/deploy/steps/registry.js.map +1 -0
- package/dist/engine/deploy/steps/step-values.d.ts +28 -0
- package/dist/engine/deploy/steps/step-values.d.ts.map +1 -0
- package/dist/engine/deploy/steps/step-values.js +33 -0
- package/dist/engine/deploy/steps/step-values.js.map +1 -0
- package/dist/engine/deploy/testing/fake-postgres.d.ts +88 -0
- package/dist/engine/deploy/testing/fake-postgres.d.ts.map +1 -0
- package/dist/engine/deploy/testing/fake-postgres.js +236 -0
- package/dist/engine/deploy/testing/fake-postgres.js.map +1 -0
- package/dist/engine/deploy/testing/fake-vps.d.ts +147 -0
- package/dist/engine/deploy/testing/fake-vps.d.ts.map +1 -0
- package/dist/engine/deploy/testing/fake-vps.js +365 -0
- package/dist/engine/deploy/testing/fake-vps.js.map +1 -0
- package/dist/engine/deploy/uninstall.d.ts +87 -0
- package/dist/engine/deploy/uninstall.d.ts.map +1 -0
- package/dist/engine/deploy/uninstall.js +320 -0
- package/dist/engine/deploy/uninstall.js.map +1 -0
- package/dist/engine/deploy/update.d.ts +111 -0
- package/dist/engine/deploy/update.d.ts.map +1 -0
- package/dist/engine/deploy/update.js +1228 -0
- package/dist/engine/deploy/update.js.map +1 -0
- package/dist/engine/deploy/version-step.d.ts +65 -0
- package/dist/engine/deploy/version-step.d.ts.map +1 -0
- package/dist/engine/deploy/version-step.js +176 -0
- package/dist/engine/deploy/version-step.js.map +1 -0
- package/dist/engine/device-auth.d.ts +240 -0
- package/dist/engine/device-auth.d.ts.map +1 -0
- package/dist/engine/device-auth.js +442 -0
- package/dist/engine/device-auth.js.map +1 -0
- package/dist/engine/device-login.d.ts +126 -0
- package/dist/engine/device-login.d.ts.map +1 -0
- package/dist/engine/device-login.js +164 -0
- package/dist/engine/device-login.js.map +1 -0
- package/dist/engine/errors.d.ts +314 -0
- package/dist/engine/errors.d.ts.map +1 -0
- package/dist/engine/errors.js +561 -0
- package/dist/engine/errors.js.map +1 -0
- package/dist/engine/identity.d.ts +169 -0
- package/dist/engine/identity.d.ts.map +1 -0
- package/dist/engine/identity.js +227 -0
- package/dist/engine/identity.js.map +1 -0
- package/dist/engine/index.d.ts +104 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +126 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/init/local-profile.d.ts +93 -0
- package/dist/engine/init/local-profile.d.ts.map +1 -0
- package/dist/engine/init/local-profile.js +295 -0
- package/dist/engine/init/local-profile.js.map +1 -0
- package/dist/engine/init/run-init.d.ts +41 -0
- package/dist/engine/init/run-init.d.ts.map +1 -0
- package/dist/engine/init/run-init.js +297 -0
- package/dist/engine/init/run-init.js.map +1 -0
- package/dist/engine/node/capabilities.d.ts +238 -0
- package/dist/engine/node/capabilities.d.ts.map +1 -0
- package/dist/engine/node/capabilities.js +316 -0
- package/dist/engine/node/capabilities.js.map +1 -0
- package/dist/engine/node/daemon.d.ts +63 -0
- package/dist/engine/node/daemon.d.ts.map +1 -0
- package/dist/engine/node/daemon.js +227 -0
- package/dist/engine/node/daemon.js.map +1 -0
- package/dist/engine/node/doctor.d.ts +58 -0
- package/dist/engine/node/doctor.d.ts.map +1 -0
- package/dist/engine/node/doctor.js +394 -0
- package/dist/engine/node/doctor.js.map +1 -0
- package/dist/engine/node/enrollment.d.ts +98 -0
- package/dist/engine/node/enrollment.d.ts.map +1 -0
- package/dist/engine/node/enrollment.js +189 -0
- package/dist/engine/node/enrollment.js.map +1 -0
- package/dist/engine/node/env-flags.d.ts +5 -0
- package/dist/engine/node/env-flags.d.ts.map +1 -0
- package/dist/engine/node/env-flags.js +22 -0
- package/dist/engine/node/env-flags.js.map +1 -0
- package/dist/engine/node/executors/credential-hygiene.d.ts +63 -0
- package/dist/engine/node/executors/credential-hygiene.d.ts.map +1 -0
- package/dist/engine/node/executors/credential-hygiene.js +189 -0
- package/dist/engine/node/executors/credential-hygiene.js.map +1 -0
- package/dist/engine/node/executors/db-backup-run.d.ts +73 -0
- package/dist/engine/node/executors/db-backup-run.d.ts.map +1 -0
- package/dist/engine/node/executors/db-backup-run.js +362 -0
- package/dist/engine/node/executors/db-backup-run.js.map +1 -0
- package/dist/engine/node/executors/example-checksum.d.ts +30 -0
- package/dist/engine/node/executors/example-checksum.d.ts.map +1 -0
- package/dist/engine/node/executors/example-checksum.js +56 -0
- package/dist/engine/node/executors/example-checksum.js.map +1 -0
- package/dist/engine/node/executors/index.d.ts +168 -0
- package/dist/engine/node/executors/index.d.ts.map +1 -0
- package/dist/engine/node/executors/index.js +44 -0
- package/dist/engine/node/executors/index.js.map +1 -0
- package/dist/engine/node/executors/registry.d.ts +38 -0
- package/dist/engine/node/executors/registry.d.ts.map +1 -0
- package/dist/engine/node/executors/registry.js +92 -0
- package/dist/engine/node/executors/registry.js.map +1 -0
- package/dist/engine/node/heap-snapshot.d.ts +37 -0
- package/dist/engine/node/heap-snapshot.d.ts.map +1 -0
- package/dist/engine/node/heap-snapshot.js +160 -0
- package/dist/engine/node/heap-snapshot.js.map +1 -0
- package/dist/engine/node/install-deps.d.ts +73 -0
- package/dist/engine/node/install-deps.d.ts.map +1 -0
- package/dist/engine/node/install-deps.js +150 -0
- package/dist/engine/node/install-deps.js.map +1 -0
- package/dist/engine/node/ipc-protocol.d.ts +67 -0
- package/dist/engine/node/ipc-protocol.d.ts.map +1 -0
- package/dist/engine/node/ipc-protocol.js +83 -0
- package/dist/engine/node/ipc-protocol.js.map +1 -0
- package/dist/engine/node/lifecycle.d.ts +103 -0
- package/dist/engine/node/lifecycle.d.ts.map +1 -0
- package/dist/engine/node/lifecycle.js +259 -0
- package/dist/engine/node/lifecycle.js.map +1 -0
- package/dist/engine/node/logger.d.ts +82 -0
- package/dist/engine/node/logger.d.ts.map +1 -0
- package/dist/engine/node/logger.js +241 -0
- package/dist/engine/node/logger.js.map +1 -0
- package/dist/engine/node/memory-watchdog.d.ts +78 -0
- package/dist/engine/node/memory-watchdog.d.ts.map +1 -0
- package/dist/engine/node/memory-watchdog.js +224 -0
- package/dist/engine/node/memory-watchdog.js.map +1 -0
- package/dist/engine/node/node-api.d.ts +391 -0
- package/dist/engine/node/node-api.d.ts.map +1 -0
- package/dist/engine/node/node-api.js +123 -0
- package/dist/engine/node/node-api.js.map +1 -0
- package/dist/engine/node/node-config.d.ts +128 -0
- package/dist/engine/node/node-config.d.ts.map +1 -0
- package/dist/engine/node/node-config.js +237 -0
- package/dist/engine/node/node-config.js.map +1 -0
- package/dist/engine/node/node-dashboard-source.d.ts +56 -0
- package/dist/engine/node/node-dashboard-source.d.ts.map +1 -0
- package/dist/engine/node/node-dashboard-source.js +213 -0
- package/dist/engine/node/node-dashboard-source.js.map +1 -0
- package/dist/engine/node/node-engine.d.ts +229 -0
- package/dist/engine/node/node-engine.d.ts.map +1 -0
- package/dist/engine/node/node-engine.js +723 -0
- package/dist/engine/node/node-engine.js.map +1 -0
- package/dist/engine/node/node-errors.d.ts +54 -0
- package/dist/engine/node/node-errors.d.ts.map +1 -0
- package/dist/engine/node/node-errors.js +71 -0
- package/dist/engine/node/node-errors.js.map +1 -0
- package/dist/engine/node/node-events.d.ts +132 -0
- package/dist/engine/node/node-events.d.ts.map +1 -0
- package/dist/engine/node/node-events.js +2 -0
- package/dist/engine/node/node-events.js.map +1 -0
- package/dist/engine/node/node-vitals.d.ts +123 -0
- package/dist/engine/node/node-vitals.d.ts.map +1 -0
- package/dist/engine/node/node-vitals.js +266 -0
- package/dist/engine/node/node-vitals.js.map +1 -0
- package/dist/engine/node/paths.d.ts +39 -0
- package/dist/engine/node/paths.d.ts.map +1 -0
- package/dist/engine/node/paths.js +60 -0
- package/dist/engine/node/paths.js.map +1 -0
- package/dist/engine/node/pg-dump.d.ts +126 -0
- package/dist/engine/node/pg-dump.d.ts.map +1 -0
- package/dist/engine/node/pg-dump.js +223 -0
- package/dist/engine/node/pg-dump.js.map +1 -0
- package/dist/engine/node/pidfile.d.ts +38 -0
- package/dist/engine/node/pidfile.d.ts.map +1 -0
- package/dist/engine/node/pidfile.js +156 -0
- package/dist/engine/node/pidfile.js.map +1 -0
- package/dist/engine/node/runtime-tuning.d.ts +65 -0
- package/dist/engine/node/runtime-tuning.d.ts.map +1 -0
- package/dist/engine/node/runtime-tuning.js +198 -0
- package/dist/engine/node/runtime-tuning.js.map +1 -0
- package/dist/engine/node/service.d.ts +39 -0
- package/dist/engine/node/service.d.ts.map +1 -0
- package/dist/engine/node/service.js +211 -0
- package/dist/engine/node/service.js.map +1 -0
- package/dist/engine/node/start.d.ts +62 -0
- package/dist/engine/node/start.d.ts.map +1 -0
- package/dist/engine/node/start.js +245 -0
- package/dist/engine/node/start.js.map +1 -0
- package/dist/engine/node/worker-env-table.d.ts +15 -0
- package/dist/engine/node/worker-env-table.d.ts.map +1 -0
- package/dist/engine/node/worker-env-table.js +97 -0
- package/dist/engine/node/worker-env-table.js.map +1 -0
- package/dist/engine/node/worker-env.d.ts +50 -0
- package/dist/engine/node/worker-env.d.ts.map +1 -0
- package/dist/engine/node/worker-env.js +101 -0
- package/dist/engine/node/worker-env.js.map +1 -0
- package/dist/engine/output.d.ts +97 -0
- package/dist/engine/output.d.ts.map +1 -0
- package/dist/engine/output.js +274 -0
- package/dist/engine/output.js.map +1 -0
- package/dist/engine/package-info.d.ts +7 -0
- package/dist/engine/package-info.d.ts.map +1 -0
- package/dist/engine/package-info.js +38 -0
- package/dist/engine/package-info.js.map +1 -0
- package/dist/engine/program.d.ts +50 -0
- package/dist/engine/program.d.ts.map +1 -0
- package/dist/engine/program.js +197 -0
- package/dist/engine/program.js.map +1 -0
- package/dist/engine/prompt.d.ts +69 -0
- package/dist/engine/prompt.d.ts.map +1 -0
- package/dist/engine/prompt.js +205 -0
- package/dist/engine/prompt.js.map +1 -0
- package/dist/engine/registries.d.ts +5 -0
- package/dist/engine/registries.d.ts.map +1 -0
- package/dist/engine/registries.js +52 -0
- package/dist/engine/registries.js.map +1 -0
- package/dist/engine/request-body.d.ts +31 -0
- package/dist/engine/request-body.d.ts.map +1 -0
- package/dist/engine/request-body.js +156 -0
- package/dist/engine/request-body.js.map +1 -0
- package/dist/engine/test-support.d.ts +50 -0
- package/dist/engine/test-support.d.ts.map +1 -0
- package/dist/engine/test-support.js +86 -0
- package/dist/engine/test-support.js.map +1 -0
- package/dist/engine/tui/app.d.ts +3 -0
- package/dist/engine/tui/app.d.ts.map +1 -0
- package/dist/engine/tui/app.js +100 -0
- package/dist/engine/tui/app.js.map +1 -0
- package/dist/engine/tui/builtin-screens.d.ts +6 -0
- package/dist/engine/tui/builtin-screens.d.ts.map +1 -0
- package/dist/engine/tui/builtin-screens.js +54 -0
- package/dist/engine/tui/builtin-screens.js.map +1 -0
- package/dist/engine/tui/index.d.ts +23 -0
- package/dist/engine/tui/index.d.ts.map +1 -0
- package/dist/engine/tui/index.js +71 -0
- package/dist/engine/tui/index.js.map +1 -0
- package/dist/engine/tui/layout.d.ts +132 -0
- package/dist/engine/tui/layout.d.ts.map +1 -0
- package/dist/engine/tui/layout.js +200 -0
- package/dist/engine/tui/layout.js.map +1 -0
- package/dist/engine/tui/routes.d.ts +5 -0
- package/dist/engine/tui/routes.d.ts.map +1 -0
- package/dist/engine/tui/routes.js +16 -0
- package/dist/engine/tui/routes.js.map +1 -0
- package/dist/engine/tui/screen-registry.d.ts +100 -0
- package/dist/engine/tui/screen-registry.d.ts.map +1 -0
- package/dist/engine/tui/screen-registry.js +96 -0
- package/dist/engine/tui/screen-registry.js.map +1 -0
- package/dist/engine/tui/screen-sections.d.ts +9 -0
- package/dist/engine/tui/screen-sections.d.ts.map +1 -0
- package/dist/engine/tui/screen-sections.js +45 -0
- package/dist/engine/tui/screen-sections.js.map +1 -0
- package/dist/engine/tui/screens/deploy/advanced-model.d.ts +69 -0
- package/dist/engine/tui/screens/deploy/advanced-model.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/advanced-model.js +228 -0
- package/dist/engine/tui/screens/deploy/advanced-model.js.map +1 -0
- package/dist/engine/tui/screens/deploy/doctor-model.d.ts +37 -0
- package/dist/engine/tui/screens/deploy/doctor-model.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/doctor-model.js +89 -0
- package/dist/engine/tui/screens/deploy/doctor-model.js.map +1 -0
- package/dist/engine/tui/screens/deploy/doctor.d.ts +8 -0
- package/dist/engine/tui/screens/deploy/doctor.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/doctor.js +153 -0
- package/dist/engine/tui/screens/deploy/doctor.js.map +1 -0
- package/dist/engine/tui/screens/deploy/fields.d.ts +123 -0
- package/dist/engine/tui/screens/deploy/fields.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/fields.js +202 -0
- package/dist/engine/tui/screens/deploy/fields.js.map +1 -0
- package/dist/engine/tui/screens/deploy/flags-model.d.ts +67 -0
- package/dist/engine/tui/screens/deploy/flags-model.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/flags-model.js +302 -0
- package/dist/engine/tui/screens/deploy/flags-model.js.map +1 -0
- package/dist/engine/tui/screens/deploy/index.d.ts +6 -0
- package/dist/engine/tui/screens/deploy/index.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/index.js +83 -0
- package/dist/engine/tui/screens/deploy/index.js.map +1 -0
- package/dist/engine/tui/screens/deploy/install-model.d.ts +159 -0
- package/dist/engine/tui/screens/deploy/install-model.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/install-model.js +319 -0
- package/dist/engine/tui/screens/deploy/install-model.js.map +1 -0
- package/dist/engine/tui/screens/deploy/install.d.ts +8 -0
- package/dist/engine/tui/screens/deploy/install.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/install.js +361 -0
- package/dist/engine/tui/screens/deploy/install.js.map +1 -0
- package/dist/engine/tui/screens/deploy/model.d.ts +49 -0
- package/dist/engine/tui/screens/deploy/model.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/model.js +59 -0
- package/dist/engine/tui/screens/deploy/model.js.map +1 -0
- package/dist/engine/tui/screens/deploy/run-model.d.ts +58 -0
- package/dist/engine/tui/screens/deploy/run-model.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/run-model.js +117 -0
- package/dist/engine/tui/screens/deploy/run-model.js.map +1 -0
- package/dist/engine/tui/screens/deploy/run.d.ts +75 -0
- package/dist/engine/tui/screens/deploy/run.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/run.js +201 -0
- package/dist/engine/tui/screens/deploy/run.js.map +1 -0
- package/dist/engine/tui/screens/deploy/status.d.ts +17 -0
- package/dist/engine/tui/screens/deploy/status.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/status.js +107 -0
- package/dist/engine/tui/screens/deploy/status.js.map +1 -0
- package/dist/engine/tui/screens/deploy/update.d.ts +41 -0
- package/dist/engine/tui/screens/deploy/update.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy/update.js +175 -0
- package/dist/engine/tui/screens/deploy/update.js.map +1 -0
- package/dist/engine/tui/screens/deploy.d.ts +12 -0
- package/dist/engine/tui/screens/deploy.d.ts.map +1 -0
- package/dist/engine/tui/screens/deploy.js +23 -0
- package/dist/engine/tui/screens/deploy.js.map +1 -0
- package/dist/engine/tui/screens/invoke.d.ts +6 -0
- package/dist/engine/tui/screens/invoke.d.ts.map +1 -0
- package/dist/engine/tui/screens/invoke.js +193 -0
- package/dist/engine/tui/screens/invoke.js.map +1 -0
- package/dist/engine/tui/screens/login.d.ts +6 -0
- package/dist/engine/tui/screens/login.d.ts.map +1 -0
- package/dist/engine/tui/screens/login.js +255 -0
- package/dist/engine/tui/screens/login.js.map +1 -0
- package/dist/engine/tui/screens/logout.d.ts +6 -0
- package/dist/engine/tui/screens/logout.d.ts.map +1 -0
- package/dist/engine/tui/screens/logout.js +142 -0
- package/dist/engine/tui/screens/logout.js.map +1 -0
- package/dist/engine/tui/screens/menu.d.ts +22 -0
- package/dist/engine/tui/screens/menu.d.ts.map +1 -0
- package/dist/engine/tui/screens/menu.js +84 -0
- package/dist/engine/tui/screens/menu.js.map +1 -0
- package/dist/engine/tui/screens/node.d.ts +6 -0
- package/dist/engine/tui/screens/node.d.ts.map +1 -0
- package/dist/engine/tui/screens/node.js +228 -0
- package/dist/engine/tui/screens/node.js.map +1 -0
- package/dist/engine/tui/screens/status.d.ts +6 -0
- package/dist/engine/tui/screens/status.d.ts.map +1 -0
- package/dist/engine/tui/screens/status.js +134 -0
- package/dist/engine/tui/screens/status.js.map +1 -0
- package/dist/engine/tui/scroll-box.d.ts +27 -0
- package/dist/engine/tui/scroll-box.d.ts.map +1 -0
- package/dist/engine/tui/scroll-box.js +52 -0
- package/dist/engine/tui/scroll-box.js.map +1 -0
- package/dist/engine/tui/section-registry.d.ts +65 -0
- package/dist/engine/tui/section-registry.d.ts.map +1 -0
- package/dist/engine/tui/section-registry.js +90 -0
- package/dist/engine/tui/section-registry.js.map +1 -0
- package/dist/engine/tui/terminal.d.ts +31 -0
- package/dist/engine/tui/terminal.d.ts.map +1 -0
- package/dist/engine/tui/terminal.js +142 -0
- package/dist/engine/tui/terminal.js.map +1 -0
- package/dist/engine/tui/tty.d.ts +49 -0
- package/dist/engine/tui/tty.d.ts.map +1 -0
- package/dist/engine/tui/tty.js +139 -0
- package/dist/engine/tui/tty.js.map +1 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +5 -0
- package/dist/node/index.js.map +1 -0
- package/dist/telemetry/index.d.ts +2 -1
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +1 -0
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/node-span-relay.d.ts +1 -1
- package/dist/telemetry/node-span-relay.d.ts.map +1 -1
- package/dist/telemetry/node-span-relay.js +39 -6
- package/dist/telemetry/node-span-relay.js.map +1 -1
- package/dist/telemetry/node-span.d.ts +39 -7
- package/dist/telemetry/node-span.d.ts.map +1 -1
- package/dist/telemetry/node-span.js +19 -1
- package/dist/telemetry/node-span.js.map +1 -1
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +4 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/tui/index.d.ts +3 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +5 -0
- package/dist/tui/index.js.map +1 -0
- package/package.json +43 -5
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { type ConfigContext } from '../config.js';
|
|
3
|
+
import { type BodyResolutionContext } from '../request-body.js';
|
|
4
|
+
/**
|
|
5
|
+
* Methods this command will send.
|
|
6
|
+
*
|
|
7
|
+
* AN ALLOW-LIST, not a passthrough, because #144 asks for a typo to be a clear
|
|
8
|
+
* local error rather than a confusing remote one. `appctl api GTE /api/users`
|
|
9
|
+
* sent verbatim gets a 404 or a 405 from the server, and a 404 reads as "that
|
|
10
|
+
* endpoint does not exist" — sending the user to check the path, which was
|
|
11
|
+
* correct all along. Rejecting it here names the actual mistake.
|
|
12
|
+
*
|
|
13
|
+
* The set is HTTP's own, not this API's: HEAD and OPTIONS are here because
|
|
14
|
+
* probing an endpoint's existence and its allowed methods is a legitimate
|
|
15
|
+
* thing to do with a generic client, and excluding them would push someone to
|
|
16
|
+
* curl. TRACE and CONNECT are excluded — no application server should honour
|
|
17
|
+
* them and both are proxy-level operations.
|
|
18
|
+
*
|
|
19
|
+
* EXPORTED FOR THE INK TUI (#145), which offers these as a pick-list on its
|
|
20
|
+
* endpoint-invoker screen rather than making the user type one. A second
|
|
21
|
+
* hard-coded list there would be the classic way for the two interfaces to
|
|
22
|
+
* drift — the TUI would keep offering a method the command had stopped
|
|
23
|
+
* accepting, and the mismatch would only ever be noticed by a user.
|
|
24
|
+
*/
|
|
25
|
+
export declare const ALLOWED_METHODS: readonly ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"];
|
|
26
|
+
export type AllowedMethod = (typeof ALLOWED_METHODS)[number];
|
|
27
|
+
/**
|
|
28
|
+
* Methods for which a request body is not merely unusual but IMPOSSIBLE.
|
|
29
|
+
*
|
|
30
|
+
* The WHATWG fetch specification forbids a body on GET and HEAD, so Node's
|
|
31
|
+
* fetch throws `TypeError: Request with GET/HEAD method cannot have body`
|
|
32
|
+
* before a socket is opened. That throw lands in `ApiClient.send`'s catch
|
|
33
|
+
* around `fetchImpl`, which classifies everything it catches as a transport
|
|
34
|
+
* failure — so the user would be told "Could not reach https://host", which is
|
|
35
|
+
* a lie with a completely misleading fix attached (check your VPN, is the
|
|
36
|
+
* server up) for what is actually a two-word mistake in their command.
|
|
37
|
+
*
|
|
38
|
+
* Checked HERE, before the client is ever called, so the diagnosis is the real
|
|
39
|
+
* one. DELETE is deliberately absent: a DELETE with a body is legal, some APIs
|
|
40
|
+
* use it, and fetch permits it.
|
|
41
|
+
*
|
|
42
|
+
* Exported for the TUI, which uses it to decide whether to ask for a body at
|
|
43
|
+
* all rather than offering a field that could only produce this error.
|
|
44
|
+
*/
|
|
45
|
+
export declare const BODYLESS_METHODS: ReadonlySet<AllowedMethod>;
|
|
46
|
+
export declare function registerApiCommand(program: Command, ctx?: ConfigContext & BodyResolutionContext): Command;
|
|
47
|
+
export declare function parseMethod(raw: string): AllowedMethod;
|
|
48
|
+
/**
|
|
49
|
+
* Validate the path and split any inline query string off it.
|
|
50
|
+
*
|
|
51
|
+
* The leading-slash requirement is #144's, and it earns its place: without it
|
|
52
|
+
* `appctl api GET api/users` produces `https://host/apiapi/users` or a 404
|
|
53
|
+
* depending on how the join lands, and the user is left staring at a path that
|
|
54
|
+
* looks right.
|
|
55
|
+
*
|
|
56
|
+
* THE `/api` PREFIX IS OPTIONAL AND STRIPPED WHEN PRESENT. This is the subtle
|
|
57
|
+
* one. `ApiClient`'s base URL ALREADY ends in `/api` (`resolveApiBaseUrl`
|
|
58
|
+
* appends it, because the API sets it as a global prefix in main.ts), so
|
|
59
|
+
* passing `/api/auth/me` through unchanged would request
|
|
60
|
+
* `https://host/api/api/auth/me`. Fastify answers 404, and a 404 is read by
|
|
61
|
+
* every human being as "that endpoint does not exist" — sending them to check
|
|
62
|
+
* the endpoint, the docs, and their permissions, none of which are the
|
|
63
|
+
* problem. Since #144's own examples all write the prefix, and the docs and
|
|
64
|
+
* Swagger show it too, both forms must work. The match requires a segment
|
|
65
|
+
* boundary, so a real endpoint at `/apikeys` is untouched.
|
|
66
|
+
*
|
|
67
|
+
* The inline query string is SPLIT AND MERGED rather than left in the path,
|
|
68
|
+
* because `buildUrl` would otherwise append `?page=2` to a path that already
|
|
69
|
+
* contained a `?` and produce a URL with two of them — which is not an error
|
|
70
|
+
* anywhere, just silently wrong parsing on the server.
|
|
71
|
+
*/
|
|
72
|
+
export declare function parseRequestPath(raw: string): {
|
|
73
|
+
path: string;
|
|
74
|
+
query: URLSearchParams;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* `key=value` → a pair.
|
|
78
|
+
*
|
|
79
|
+
* Split on the FIRST `=` only, so a value containing one (a base64 cursor, an
|
|
80
|
+
* ISO timestamp, a filter expression) survives intact. Encoding is left to
|
|
81
|
+
* `URLSearchParams`, which is the only thing that gets percent-encoding right
|
|
82
|
+
* for every character without a hand-rolled table.
|
|
83
|
+
*/
|
|
84
|
+
export declare function parseQueryPair(pair: string): {
|
|
85
|
+
key: string;
|
|
86
|
+
value: string;
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/engine/commands/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAGtE,OAAO,EAAsB,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAyCpF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,eAAe,uEAQlB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,aAAa,CAGtD,CAAC;AAaH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,GAAG,CAAC,EAAE,aAAa,GAAG,qBAAqB,GAC1C,OAAO,CAsCT;AA8LD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAUtD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE,CA0CtF;AAQD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAkB3E"}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { ApiClient, resolveApiBaseUrl } from '../api-client.js';
|
|
2
|
+
import { API_PATH_PREFIX, cliName } from '../identity.js';
|
|
3
|
+
import { requireCredentials } from '../config.js';
|
|
4
|
+
import { UsageError } from '../errors.js';
|
|
5
|
+
import { createSpinner, formatJson, formatStatusLine, shouldUseColour } from '../output.js';
|
|
6
|
+
import { resolveRequestBody } from '../request-body.js';
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// `appctl api <method> <path>` (issue #144, epic #110)
|
|
9
|
+
// =============================================================================
|
|
10
|
+
//
|
|
11
|
+
// ONE COMMAND FOR THE WHOLE API, and the reason is architectural rather than
|
|
12
|
+
// lazy. This repository is a BASELINE: downstream applications delete
|
|
13
|
+
// `/api/allowlist`, add `/api/invoices`, and rename half of what is left. A
|
|
14
|
+
// CLI with a hand-written subcommand per resource would be obsolete in every
|
|
15
|
+
// fork on the day it was forked, and every new endpoint would need matching
|
|
16
|
+
// CLI work forever. A generic invoker is the only shape that stays correct
|
|
17
|
+
// through that — it works against endpoints that do not exist yet.
|
|
18
|
+
//
|
|
19
|
+
// #110 records the two alternatives and why they lost: typed subcommands
|
|
20
|
+
// (friendlier, and wrong for a template) and generating commands from the
|
|
21
|
+
// published OpenAPI document (genuinely attractive, and a code-generation
|
|
22
|
+
// pipeline plus a schema-drift problem — a project of its own). The generic
|
|
23
|
+
// command is the foundation under either of them.
|
|
24
|
+
//
|
|
25
|
+
// -----------------------------------------------------------------------------
|
|
26
|
+
// THE CONTRACT THIS COMMAND MAKES WITH A SHELL
|
|
27
|
+
// -----------------------------------------------------------------------------
|
|
28
|
+
// stdout : the response body. Nothing else. Ever.
|
|
29
|
+
// stderr : status line, spinner, warnings, errors.
|
|
30
|
+
// exit 0 : if and only if the server answered 2xx.
|
|
31
|
+
//
|
|
32
|
+
// All three are load-bearing and all three fail silently when broken. A status
|
|
33
|
+
// line on stdout breaks `--raw | jq` for every consumer at once. An exit 0 on
|
|
34
|
+
// a 403 turns a broken deploy into a green pipeline, and nobody finds out
|
|
35
|
+
// until much later.
|
|
36
|
+
//
|
|
37
|
+
// The exit codes are not computed here: the command THROWS, `program.ts`
|
|
38
|
+
// catches, and `exitCodeFor` (errors.ts) maps ApiError → 3 (or 5 for a 401),
|
|
39
|
+
// NetworkError → 4, UsageError → 2. The message printed is `err.message`,
|
|
40
|
+
// which ApiError has already built as `<status>: <the server's own sentence>`
|
|
41
|
+
// — so a missing permission arrives as `403: Missing permission users:read`
|
|
42
|
+
// and not as `Request failed`. That is the entire point of errors.ts, and this
|
|
43
|
+
// command's job is to not get in its way.
|
|
44
|
+
// =============================================================================
|
|
45
|
+
/**
|
|
46
|
+
* Methods this command will send.
|
|
47
|
+
*
|
|
48
|
+
* AN ALLOW-LIST, not a passthrough, because #144 asks for a typo to be a clear
|
|
49
|
+
* local error rather than a confusing remote one. `appctl api GTE /api/users`
|
|
50
|
+
* sent verbatim gets a 404 or a 405 from the server, and a 404 reads as "that
|
|
51
|
+
* endpoint does not exist" — sending the user to check the path, which was
|
|
52
|
+
* correct all along. Rejecting it here names the actual mistake.
|
|
53
|
+
*
|
|
54
|
+
* The set is HTTP's own, not this API's: HEAD and OPTIONS are here because
|
|
55
|
+
* probing an endpoint's existence and its allowed methods is a legitimate
|
|
56
|
+
* thing to do with a generic client, and excluding them would push someone to
|
|
57
|
+
* curl. TRACE and CONNECT are excluded — no application server should honour
|
|
58
|
+
* them and both are proxy-level operations.
|
|
59
|
+
*
|
|
60
|
+
* EXPORTED FOR THE INK TUI (#145), which offers these as a pick-list on its
|
|
61
|
+
* endpoint-invoker screen rather than making the user type one. A second
|
|
62
|
+
* hard-coded list there would be the classic way for the two interfaces to
|
|
63
|
+
* drift — the TUI would keep offering a method the command had stopped
|
|
64
|
+
* accepting, and the mismatch would only ever be noticed by a user.
|
|
65
|
+
*/
|
|
66
|
+
export const ALLOWED_METHODS = [
|
|
67
|
+
'GET',
|
|
68
|
+
'HEAD',
|
|
69
|
+
'POST',
|
|
70
|
+
'PUT',
|
|
71
|
+
'PATCH',
|
|
72
|
+
'DELETE',
|
|
73
|
+
'OPTIONS',
|
|
74
|
+
];
|
|
75
|
+
/**
|
|
76
|
+
* Methods for which a request body is not merely unusual but IMPOSSIBLE.
|
|
77
|
+
*
|
|
78
|
+
* The WHATWG fetch specification forbids a body on GET and HEAD, so Node's
|
|
79
|
+
* fetch throws `TypeError: Request with GET/HEAD method cannot have body`
|
|
80
|
+
* before a socket is opened. That throw lands in `ApiClient.send`'s catch
|
|
81
|
+
* around `fetchImpl`, which classifies everything it catches as a transport
|
|
82
|
+
* failure — so the user would be told "Could not reach https://host", which is
|
|
83
|
+
* a lie with a completely misleading fix attached (check your VPN, is the
|
|
84
|
+
* server up) for what is actually a two-word mistake in their command.
|
|
85
|
+
*
|
|
86
|
+
* Checked HERE, before the client is ever called, so the diagnosis is the real
|
|
87
|
+
* one. DELETE is deliberately absent: a DELETE with a body is legal, some APIs
|
|
88
|
+
* use it, and fetch permits it.
|
|
89
|
+
*
|
|
90
|
+
* Exported for the TUI, which uses it to decide whether to ask for a body at
|
|
91
|
+
* all rather than offering a field that could only produce this error.
|
|
92
|
+
*/
|
|
93
|
+
export const BODYLESS_METHODS = new Set([
|
|
94
|
+
'GET',
|
|
95
|
+
'HEAD',
|
|
96
|
+
]);
|
|
97
|
+
export function registerApiCommand(program, ctx) {
|
|
98
|
+
return program
|
|
99
|
+
.command('api')
|
|
100
|
+
.description('Call any API endpoint and print the response')
|
|
101
|
+
.argument('<method>', `HTTP method (${ALLOWED_METHODS.join(', ')})`)
|
|
102
|
+
.argument('<path>', 'Request path, e.g. /api/auth/me')
|
|
103
|
+
// No default value is passed to commander here on purpose: supplying `[]`
|
|
104
|
+
// makes it advertise `(default: [])` in `--help`, which is noise that
|
|
105
|
+
// means nothing to a reader. The absent case is handled at the use site.
|
|
106
|
+
.option('--query <key=value>', 'Query parameter; repeat for more than one', collectQuery)
|
|
107
|
+
.option('--data <json>', "Request body: inline JSON, @file.json, or - for stdin")
|
|
108
|
+
.option('--raw', 'Print unformatted JSON on stdout and nothing else')
|
|
109
|
+
.option('-q, --quiet', 'Suppress the status line and spinner on stderr')
|
|
110
|
+
.option('--no-color', 'Disable colour even on a terminal')
|
|
111
|
+
.option('--timeout <ms>', 'Per-request timeout in milliseconds')
|
|
112
|
+
.addHelpText('after', [
|
|
113
|
+
'',
|
|
114
|
+
'Examples:',
|
|
115
|
+
` ${cliName()} api GET /api/auth/me`,
|
|
116
|
+
` ${cliName()} api GET /api/users --query page=2 --query pageSize=50`,
|
|
117
|
+
` ${cliName()} api POST /api/allowlist --data '{"email":"a@b.com"}'`,
|
|
118
|
+
` ${cliName()} api POST /api/allowlist --data @entry.json`,
|
|
119
|
+
` cat entry.json | ${cliName()} api POST /api/allowlist --data -`,
|
|
120
|
+
` ${cliName()} api GET /api/users --raw | jq '.data[].email'`,
|
|
121
|
+
'',
|
|
122
|
+
'Output:',
|
|
123
|
+
' The response body goes to stdout; everything else goes to stderr, so',
|
|
124
|
+
' `--raw | jq` and `--raw > file.json` both stay clean. The exit code is 0',
|
|
125
|
+
' only for a 2xx; a non-2xx exits non-zero with the server’s own message.',
|
|
126
|
+
'',
|
|
127
|
+
` The \`${API_PATH_PREFIX}\` prefix is optional: /api/auth/me and /auth/me are the same.`,
|
|
128
|
+
].join('\n'))
|
|
129
|
+
.action(async (method, path, options) => {
|
|
130
|
+
await runApiCommand(method, path, options, ctx);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async function runApiCommand(rawMethod, rawPath, options, ctx) {
|
|
134
|
+
const method = parseMethod(rawMethod);
|
|
135
|
+
const { path, query } = parseRequestPath(rawPath);
|
|
136
|
+
const timeoutMs = parseTimeout(options.timeout);
|
|
137
|
+
for (const pair of options.query ?? []) {
|
|
138
|
+
const { key, value } = parseQueryPair(pair);
|
|
139
|
+
// `append`, not `set`: repeated keys are how a REST API expresses a
|
|
140
|
+
// multi-valued filter (`?role=Admin&role=Viewer`), and collapsing them
|
|
141
|
+
// would silently drop all but the last. This is also why the query string
|
|
142
|
+
// is assembled here instead of being handed to `ApiClient` as the
|
|
143
|
+
// `Record<string, QueryValue>` its `query` option takes — a Record cannot
|
|
144
|
+
// represent a repeated key at all.
|
|
145
|
+
query.append(key, value);
|
|
146
|
+
}
|
|
147
|
+
const body = await resolveRequestBody(options.data, ctx);
|
|
148
|
+
if (body !== undefined && BODYLESS_METHODS.has(method)) {
|
|
149
|
+
throw new UsageError(`${method} requests cannot carry a body. Use --query for parameters, or a method that takes one (POST, PUT, PATCH).`);
|
|
150
|
+
}
|
|
151
|
+
// Credentials are resolved BEFORE the request, and their absence throws
|
|
152
|
+
// AuthRequiredError with "run login" rather than sending `Authorization:
|
|
153
|
+
// Bearer undefined` and relaying a 401 that blames the user's credentials
|
|
154
|
+
// for not existing. See requireCredentials() in config.ts.
|
|
155
|
+
//
|
|
156
|
+
// There is deliberately NO `--server` or `--token` flag on this command.
|
|
157
|
+
// The server and the credential are a PAIR — a PAT minted for one host is
|
|
158
|
+
// worthless on another and must never be sent to it — and a flag that let
|
|
159
|
+
// them be set independently would make leaking a token to the wrong host a
|
|
160
|
+
// single typo away. Pointing at a different server is `login`, or the
|
|
161
|
+
// APPCTL_SERVER_URL / APPCTL_TOKEN pair, which #143 resolves together.
|
|
162
|
+
const credentials = requireCredentials(ctx);
|
|
163
|
+
const client = new ApiClient({
|
|
164
|
+
baseUrl: resolveApiBaseUrl(credentials.serverUrl),
|
|
165
|
+
token: credentials.token,
|
|
166
|
+
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
167
|
+
});
|
|
168
|
+
const queryString = query.toString();
|
|
169
|
+
const requestPath = queryString.length > 0 ? `${path}?${queryString}` : path;
|
|
170
|
+
// What the status line and the spinner say. `path` has had the `/api`
|
|
171
|
+
// prefix stripped so it can be joined onto a base URL that already carries
|
|
172
|
+
// one — an internal detail — and echoing THAT back would show the user a
|
|
173
|
+
// path they did not type and that does not exist on the server. This puts
|
|
174
|
+
// the prefix back, so what is reported is the real path on the wire.
|
|
175
|
+
const displayPath = `${API_PATH_PREFIX}${path === '/' ? '' : path}${queryString.length > 0 ? `?${queryString}` : ''}`;
|
|
176
|
+
const quiet = options.quiet === true;
|
|
177
|
+
const raw = options.raw === true;
|
|
178
|
+
// Progress belongs on stderr and only on a terminal — `createSpinner`
|
|
179
|
+
// enforces the second half itself. Suppressed under `--quiet` for the case
|
|
180
|
+
// where a caller merges the two streams (`2>&1`) and wants only the body.
|
|
181
|
+
const stopSpinner = createSpinner(`${method} ${displayPath}`, { enabled: !quiet });
|
|
182
|
+
const startedAt = Date.now();
|
|
183
|
+
let response;
|
|
184
|
+
try {
|
|
185
|
+
// The body is spread in only when `--data` was actually given. This is not
|
|
186
|
+
// cosmetic: `ApiClient.send` decides whether to send a payload AND whether
|
|
187
|
+
// to set `Content-Type: application/json` on `options.body !== undefined`,
|
|
188
|
+
// and Fastify 5 answers 400 to a request that declares a JSON content type
|
|
189
|
+
// and then carries no body. So `{ body: undefined }` and no `body` key are
|
|
190
|
+
// very different things here, and `exactOptionalPropertyTypes` is what
|
|
191
|
+
// makes the compiler agree.
|
|
192
|
+
//
|
|
193
|
+
// A body of literal `null` (`--data null`) still counts as present and is
|
|
194
|
+
// sent as the four bytes `null`, which is what the user asked for.
|
|
195
|
+
response = await client.send(method, requestPath, {
|
|
196
|
+
...(body === undefined ? {} : { body: body.value }),
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
// In a `finally` so a thrown ApiError cannot leave a half-drawn spinner
|
|
201
|
+
// frame sitting in front of the error message program.ts is about to
|
|
202
|
+
// print. This runs on the failure path far more often than on the success
|
|
203
|
+
// one, which is exactly why it cannot live after the await.
|
|
204
|
+
stopSpinner();
|
|
205
|
+
}
|
|
206
|
+
const durationMs = Date.now() - startedAt;
|
|
207
|
+
if (!quiet) {
|
|
208
|
+
process.stderr.write(formatStatusLine({ method, path: displayPath, status: response.status, durationMs }));
|
|
209
|
+
}
|
|
210
|
+
writeBody(response.body, { raw, quiet, colourRequested: options.color });
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Write the response body to stdout.
|
|
214
|
+
*
|
|
215
|
+
* ---------------------------------------------------------------------------
|
|
216
|
+
* WHAT GETS PRINTED: `response.body`, IN BOTH MODES. THE UNWRAPPED
|
|
217
|
+
* `response.data` IS NEVER PRINTED. This is the one decision in #144 with a
|
|
218
|
+
* real argument on both sides, so here is the whole of it.
|
|
219
|
+
*
|
|
220
|
+
* The API's TransformInterceptor wraps a handler's return value as
|
|
221
|
+
* `{ data, meta: { timestamp } }` — but it PASSES THROUGH anything that
|
|
222
|
+
* already carries a `data` key. A paginated endpoint returns
|
|
223
|
+
* `{ data: [...], pagination: { total, page, pageSize } }` and is therefore
|
|
224
|
+
* NEVER WRAPPED. `unwrapEnvelope` cannot tell those two cases apart (nothing
|
|
225
|
+
* can, from the outside — they are the same shape), so unwrapping
|
|
226
|
+
* `GET /api/users` yields the bare array and SILENTLY DISCARDS THE PAGE COUNT.
|
|
227
|
+
*
|
|
228
|
+
* THE CASE FOR PRINTING `data`: it is what a human wants. One less level of
|
|
229
|
+
* nesting, no `meta.timestamp` noise on every single call.
|
|
230
|
+
*
|
|
231
|
+
* THE CASE FOR PRINTING `body`, which wins, on two grounds:
|
|
232
|
+
*
|
|
233
|
+
* 1. THE TWO MODES MUST AGREE. `--raw` must emit the server's own bytes —
|
|
234
|
+
* a script piping into `jq` wants the truth, not a client-side
|
|
235
|
+
* interpretation, and `ApiResponse.body` exists to carry exactly that.
|
|
236
|
+
* If the default mode unwrapped and `--raw` did not, then a user who
|
|
237
|
+
* explored an endpoint interactively and then wrote a `jq` filter against
|
|
238
|
+
* what they saw would have written it against a shape that does not
|
|
239
|
+
* exist in the pipe. They would debug the filter. The CLI would have lied
|
|
240
|
+
* to them, in the one mode where being trustworthy is the whole feature.
|
|
241
|
+
*
|
|
242
|
+
* 2. UNWRAPPING IS LOSSY AND INCONSISTENT — see the pagination case above.
|
|
243
|
+
* A generic API command that cannot show the total on `GET /api/users` is
|
|
244
|
+
* broken for the endpoint from #144's own examples. The envelope is cheap
|
|
245
|
+
* noise; the dropped page count is expensive silence. Between a mode that
|
|
246
|
+
* is slightly verbose and a mode that is quietly wrong, take verbose.
|
|
247
|
+
*
|
|
248
|
+
* `unwrapEnvelope` and `ApiResponse.data` remain right for TYPED callers —
|
|
249
|
+
* `device-login.ts` asks for a `CurrentUser` and means it. They are wrong for
|
|
250
|
+
* a passthrough, which is what this command is.
|
|
251
|
+
* ---------------------------------------------------------------------------
|
|
252
|
+
*/
|
|
253
|
+
function writeBody(body, options) {
|
|
254
|
+
if (body === undefined) {
|
|
255
|
+
// A 204, or any 2xx with an empty body — `DELETE /api/allowlist/{id}` and
|
|
256
|
+
// `POST /api/auth/logout` both do this. NOTHING goes to stdout: the server
|
|
257
|
+
// sent no bytes, so printing `null` would invent a value it never sent,
|
|
258
|
+
// and `--raw > file.json` would produce a file whose content is a fiction.
|
|
259
|
+
// An empty stdout is also correct for `jq`, which reads it as no input.
|
|
260
|
+
if (!options.quiet)
|
|
261
|
+
process.stderr.write(' (no response body)\n');
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (options.raw) {
|
|
265
|
+
// Compact, one line, and NEVER coloured — `shouldUseColour` is not even
|
|
266
|
+
// consulted here, so no FORCE_COLOR on any machine can inject escape
|
|
267
|
+
// sequences into a pipeline (see the note in output.ts).
|
|
268
|
+
//
|
|
269
|
+
// The trailing newline is a LINE TERMINATOR, not extra output: a POSIX
|
|
270
|
+
// text line ends with one, `jq` and every line-oriented tool expect it,
|
|
271
|
+
// and omitting it leaves a shell prompt glued to the last brace. It is
|
|
272
|
+
// also what makes `--raw` usable inside `while read`.
|
|
273
|
+
process.stdout.write(`${JSON.stringify(body)}\n`);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const colour = shouldUseColour({
|
|
277
|
+
requested: options.colourRequested,
|
|
278
|
+
isTTY: process.stdout.isTTY === true,
|
|
279
|
+
env: process.env,
|
|
280
|
+
});
|
|
281
|
+
process.stdout.write(`${formatJson(body, { colour })}\n`);
|
|
282
|
+
}
|
|
283
|
+
// -----------------------------------------------------------------------------
|
|
284
|
+
// Argument parsing and validation
|
|
285
|
+
// -----------------------------------------------------------------------------
|
|
286
|
+
/** commander's repeatable-option collector. */
|
|
287
|
+
function collectQuery(value, previous) {
|
|
288
|
+
return [...(previous ?? []), value];
|
|
289
|
+
}
|
|
290
|
+
export function parseMethod(raw) {
|
|
291
|
+
const method = raw.trim().toUpperCase();
|
|
292
|
+
if (ALLOWED_METHODS.includes(method)) {
|
|
293
|
+
return method;
|
|
294
|
+
}
|
|
295
|
+
throw new UsageError(`"${raw}" is not an HTTP method. Use one of: ${ALLOWED_METHODS.join(', ')}.`);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Validate the path and split any inline query string off it.
|
|
299
|
+
*
|
|
300
|
+
* The leading-slash requirement is #144's, and it earns its place: without it
|
|
301
|
+
* `appctl api GET api/users` produces `https://host/apiapi/users` or a 404
|
|
302
|
+
* depending on how the join lands, and the user is left staring at a path that
|
|
303
|
+
* looks right.
|
|
304
|
+
*
|
|
305
|
+
* THE `/api` PREFIX IS OPTIONAL AND STRIPPED WHEN PRESENT. This is the subtle
|
|
306
|
+
* one. `ApiClient`'s base URL ALREADY ends in `/api` (`resolveApiBaseUrl`
|
|
307
|
+
* appends it, because the API sets it as a global prefix in main.ts), so
|
|
308
|
+
* passing `/api/auth/me` through unchanged would request
|
|
309
|
+
* `https://host/api/api/auth/me`. Fastify answers 404, and a 404 is read by
|
|
310
|
+
* every human being as "that endpoint does not exist" — sending them to check
|
|
311
|
+
* the endpoint, the docs, and their permissions, none of which are the
|
|
312
|
+
* problem. Since #144's own examples all write the prefix, and the docs and
|
|
313
|
+
* Swagger show it too, both forms must work. The match requires a segment
|
|
314
|
+
* boundary, so a real endpoint at `/apikeys` is untouched.
|
|
315
|
+
*
|
|
316
|
+
* The inline query string is SPLIT AND MERGED rather than left in the path,
|
|
317
|
+
* because `buildUrl` would otherwise append `?page=2` to a path that already
|
|
318
|
+
* contained a `?` and produce a URL with two of them — which is not an error
|
|
319
|
+
* anywhere, just silently wrong parsing on the server.
|
|
320
|
+
*/
|
|
321
|
+
export function parseRequestPath(raw) {
|
|
322
|
+
const trimmed = raw.trim();
|
|
323
|
+
if (trimmed.length === 0) {
|
|
324
|
+
throw new UsageError('A request path is required, for example /api/auth/me.');
|
|
325
|
+
}
|
|
326
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed)) {
|
|
327
|
+
// A full URL is a reasonable thing to try, and accepting it would be
|
|
328
|
+
// actively dangerous: the stored bearer token would be sent to whatever
|
|
329
|
+
// host was typed. The server comes from the login that minted the token,
|
|
330
|
+
// and only from there.
|
|
331
|
+
throw new UsageError(`Pass a path, not a full URL: ${trimmed}. The server comes from your login (\`${cliName()} config\` shows it).`);
|
|
332
|
+
}
|
|
333
|
+
if (!trimmed.startsWith('/')) {
|
|
334
|
+
throw new UsageError(`Path must start with "/": try /${trimmed.replace(/^\/+/, '')}`);
|
|
335
|
+
}
|
|
336
|
+
if (trimmed.includes('#')) {
|
|
337
|
+
// A fragment is never transmitted to a server, so silently dropping it
|
|
338
|
+
// would mean requesting something other than what was typed. In a shell it
|
|
339
|
+
// is nearly always an unquoted `#` starting a comment instead.
|
|
340
|
+
throw new UsageError(`Path contains "#", which is never sent to a server. Quote the argument if the character is part of the path.`);
|
|
341
|
+
}
|
|
342
|
+
const questionMark = trimmed.indexOf('?');
|
|
343
|
+
const rawPathPart = questionMark === -1 ? trimmed : trimmed.slice(0, questionMark);
|
|
344
|
+
const rawQueryPart = questionMark === -1 ? '' : trimmed.slice(questionMark + 1);
|
|
345
|
+
// `//users` collapses to `/users`: a doubled slash is a distinct path to
|
|
346
|
+
// Fastify and answers 404, and it is what you get from naive string joining
|
|
347
|
+
// upstream of this command.
|
|
348
|
+
const normalisedSlashes = rawPathPart.replace(/^\/+/, '/');
|
|
349
|
+
const path = stripApiPrefix(normalisedSlashes);
|
|
350
|
+
return { path, query: new URLSearchParams(rawQueryPart) };
|
|
351
|
+
}
|
|
352
|
+
function stripApiPrefix(path) {
|
|
353
|
+
if (path === API_PATH_PREFIX)
|
|
354
|
+
return '/';
|
|
355
|
+
if (path.startsWith(`${API_PATH_PREFIX}/`))
|
|
356
|
+
return path.slice(API_PATH_PREFIX.length);
|
|
357
|
+
return path;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* `key=value` → a pair.
|
|
361
|
+
*
|
|
362
|
+
* Split on the FIRST `=` only, so a value containing one (a base64 cursor, an
|
|
363
|
+
* ISO timestamp, a filter expression) survives intact. Encoding is left to
|
|
364
|
+
* `URLSearchParams`, which is the only thing that gets percent-encoding right
|
|
365
|
+
* for every character without a hand-rolled table.
|
|
366
|
+
*/
|
|
367
|
+
export function parseQueryPair(pair) {
|
|
368
|
+
const separator = pair.indexOf('=');
|
|
369
|
+
if (separator === -1) {
|
|
370
|
+
throw new UsageError(`--query expects key=value, got "${pair}". For an empty value write ${pair}=.`);
|
|
371
|
+
}
|
|
372
|
+
const key = pair.slice(0, separator);
|
|
373
|
+
if (key.trim().length === 0) {
|
|
374
|
+
throw new UsageError(`--query "${pair}" has an empty parameter name.`);
|
|
375
|
+
}
|
|
376
|
+
// The value is NOT trimmed: a trailing space can be meaningful in a search
|
|
377
|
+
// term, and silently editing a user's query value is worse than passing it
|
|
378
|
+
// through. The key is only trimmed for the emptiness check above.
|
|
379
|
+
return { key, value: pair.slice(separator + 1) };
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* `--timeout` in milliseconds.
|
|
383
|
+
*
|
|
384
|
+
* Validated rather than passed through as `Number(...)`, because `Number('30s')`
|
|
385
|
+
* is `NaN`, and a `NaN` timeout reaches `AbortSignal.timeout` as an immediate
|
|
386
|
+
* abort — the request would fail instantly with a timeout message for a value
|
|
387
|
+
* the user believed was thirty seconds.
|
|
388
|
+
*/
|
|
389
|
+
function parseTimeout(raw) {
|
|
390
|
+
if (raw === undefined)
|
|
391
|
+
return undefined;
|
|
392
|
+
const value = Number(raw);
|
|
393
|
+
if (!Number.isFinite(value) || !Number.isInteger(value) || value <= 0) {
|
|
394
|
+
throw new UsageError(`--timeout must be a positive whole number of milliseconds, got "${raw}".`);
|
|
395
|
+
}
|
|
396
|
+
return value;
|
|
397
|
+
}
|
|
398
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/engine/commands/api.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAsB,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAA8B,MAAM,oBAAoB,CAAC;AAEpF,gFAAgF;AAChF,wDAAwD;AACxD,gFAAgF;AAChF,EAAE;AACF,6EAA6E;AAC7E,sEAAsE;AACtE,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,mEAAmE;AACnE,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,0EAA0E;AAC1E,4EAA4E;AAC5E,kDAAkD;AAClD,EAAE;AACF,gFAAgF;AAChF,+CAA+C;AAC/C,gFAAgF;AAChF,oDAAoD;AACpD,qDAAqD;AACrD,qDAAqD;AACrD,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,0EAA0E;AAC1E,oBAAoB;AACpB,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,0EAA0E;AAC1E,8EAA8E;AAC9E,4EAA4E;AAC5E,+EAA+E;AAC/E,0CAA0C;AAC1C,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,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AU,CAAC,mEAAmE,GAAG,IAAI,CAAC,CAAC;IACnG,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { type ConfigContext, type ConfigSummary } from '../config.js';
|
|
3
|
+
export declare function registerConfigCommand(program: Command, ctx?: ConfigContext): Command;
|
|
4
|
+
export declare function formatSummary(summary: ConfigSummary): string;
|
|
5
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/engine/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAIL,KAAK,aAAa,EAElB,KAAK,aAAa,EACnB,MAAM,cAAc,CAAC;AAkBtB,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,aAAa,GAAG,OAAO,CAWpF;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CA6C5D"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { cliName } from '../identity.js';
|
|
2
|
+
import { serverUrlEnvVar, tokenEnvVar, describeConfig, } from '../config.js';
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// `appctl config` (issue #143, epic #110)
|
|
5
|
+
// =============================================================================
|
|
6
|
+
//
|
|
7
|
+
// "Where is my token, which server am I pointed at, and is it still valid?" is
|
|
8
|
+
// the first question asked whenever anything is wrong, and without this
|
|
9
|
+
// command the only way to answer it is to `cat` the config file — which prints
|
|
10
|
+
// the token to the terminal, into scrollback, and usually into a pasted bug
|
|
11
|
+
// report. Giving people a safe way to look is the point.
|
|
12
|
+
//
|
|
13
|
+
// THE TOKEN CANNOT BE PRINTED FROM HERE. Not because this file is careful, but
|
|
14
|
+
// because `describeConfig()` returns a ConfigSummary, and ConfigSummary has no
|
|
15
|
+
// field capable of holding it — `tokenHint` is already masked by the time it
|
|
16
|
+
// arrives. A future edit that tried to print the token would not compile.
|
|
17
|
+
// =============================================================================
|
|
18
|
+
export function registerConfigCommand(program, ctx) {
|
|
19
|
+
return program
|
|
20
|
+
.command('config')
|
|
21
|
+
.description('Show the stored server URL and a masked token hint')
|
|
22
|
+
.action(() => {
|
|
23
|
+
// stderr, like every other human-readable line in this CLI: stdout stays
|
|
24
|
+
// reserved for #144's pipeable output. `--json` on stdout would be a
|
|
25
|
+
// reasonable future addition and would go through the SAME
|
|
26
|
+
// ConfigSummary, so it inherits the no-token guarantee for free.
|
|
27
|
+
process.stderr.write(formatSummary(describeConfig(ctx)));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function formatSummary(summary) {
|
|
31
|
+
const lines = [''];
|
|
32
|
+
if (summary.serverUrl === undefined && summary.tokenSource === undefined) {
|
|
33
|
+
return ([
|
|
34
|
+
'',
|
|
35
|
+
` Not logged in.`,
|
|
36
|
+
'',
|
|
37
|
+
` Run \`${cliName()} login\`, or set ${serverUrlEnvVar()} and ${tokenEnvVar()}.`,
|
|
38
|
+
` Config file: ${summary.path} (does not exist)`,
|
|
39
|
+
'',
|
|
40
|
+
].join('\n') + '\n');
|
|
41
|
+
}
|
|
42
|
+
lines.push(` Server: ${summary.serverUrl ?? '(not set)'}${source(summary.serverUrlSource)}`);
|
|
43
|
+
lines.push(` Token: ${summary.tokenHint}${source(summary.tokenSource)}`);
|
|
44
|
+
if (summary.tokenName !== undefined) {
|
|
45
|
+
// The name and id are what let a user find the exact row to revoke in the
|
|
46
|
+
// web UI's Access Tokens page — the property that makes a long-lived
|
|
47
|
+
// credential acceptable (epic #110). Neither is a secret: `GET /api/pat`
|
|
48
|
+
// already returns both to the same user.
|
|
49
|
+
lines.push(` Name: ${summary.tokenName}`);
|
|
50
|
+
}
|
|
51
|
+
if (summary.tokenId !== undefined) {
|
|
52
|
+
lines.push(` ID: ${summary.tokenId}`);
|
|
53
|
+
}
|
|
54
|
+
if (summary.expiresAt !== undefined) {
|
|
55
|
+
const state = summary.expired === true ? ' (EXPIRED — run login again)' : '';
|
|
56
|
+
lines.push(` Expires: ${summary.expiresAt}${state}`);
|
|
57
|
+
}
|
|
58
|
+
if (summary.updatedAt !== undefined) {
|
|
59
|
+
lines.push(` Updated: ${summary.updatedAt}`);
|
|
60
|
+
}
|
|
61
|
+
lines.push(` File: ${summary.path}${summary.fileExists ? '' : ' (does not exist)'}`);
|
|
62
|
+
lines.push('');
|
|
63
|
+
return lines.join('\n') + '\n';
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Says which layer won.
|
|
67
|
+
*
|
|
68
|
+
* Worth a column of its own: the single most confusing state this CLI can be
|
|
69
|
+
* in is an exported `APPCTL_TOKEN` left over in a shell, quietly overriding
|
|
70
|
+
* the config file so that `login` appears to have had no effect. Naming the
|
|
71
|
+
* winning source turns a mystery into a one-word answer.
|
|
72
|
+
*/
|
|
73
|
+
function source(from) {
|
|
74
|
+
switch (from) {
|
|
75
|
+
case 'env':
|
|
76
|
+
return ' (from the environment)';
|
|
77
|
+
case 'file':
|
|
78
|
+
return ' (from the config file)';
|
|
79
|
+
default:
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/engine/commands/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EACL,eAAe,EACf,WAAW,EACX,cAAc,GAIf,MAAM,cAAc,CAAC;AAEtB,gFAAgF;AAChF,2CAA2C;AAC3C,gFAAgF;AAChF,EAAE;AACF,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAC/E,4EAA4E;AAC5E,yDAAyD;AACzD,EAAE;AACF,+EAA+E;AAC/E,+EAA+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