@synteq/cli 0.2.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.d.ts +362 -5
- package/dist/api/client.js +559 -44
- package/dist/api/client.js.map +1 -1
- package/dist/api/factory.js +5 -2
- package/dist/api/factory.js.map +1 -1
- package/dist/api/types.d.ts +892 -3
- package/dist/apps-support/deploy.d.ts +197 -0
- package/dist/apps-support/deploy.js +639 -0
- package/dist/apps-support/deploy.js.map +1 -0
- package/dist/apps-support/dotenv.d.ts +67 -0
- package/dist/apps-support/dotenv.js +136 -0
- package/dist/apps-support/dotenv.js.map +1 -0
- package/dist/apps-support/env-rollout.d.ts +18 -0
- package/dist/apps-support/env-rollout.js +52 -0
- package/dist/apps-support/env-rollout.js.map +1 -0
- package/dist/apps-support/git.d.ts +14 -0
- package/dist/apps-support/git.js +25 -0
- package/dist/apps-support/git.js.map +1 -0
- package/dist/apps-support/link.d.ts +25 -0
- package/dist/apps-support/link.js +39 -0
- package/dist/apps-support/link.js.map +1 -0
- package/dist/apps-support/log-stream.d.ts +25 -0
- package/dist/apps-support/log-stream.js +85 -0
- package/dist/apps-support/log-stream.js.map +1 -0
- package/dist/apps-support/paid-app.d.ts +64 -0
- package/dist/apps-support/paid-app.js +195 -0
- package/dist/apps-support/paid-app.js.map +1 -0
- package/dist/apps-support/plans.d.ts +44 -0
- package/dist/apps-support/plans.js +43 -0
- package/dist/apps-support/plans.js.map +1 -0
- package/dist/apps-support/resolve.d.ts +10 -0
- package/dist/apps-support/resolve.js +53 -0
- package/dist/apps-support/resolve.js.map +1 -0
- package/dist/apps-support/time.d.ts +20 -0
- package/dist/apps-support/time.js +82 -0
- package/dist/apps-support/time.js.map +1 -0
- package/dist/auth/scope.js +4 -0
- package/dist/auth/scope.js.map +1 -1
- package/dist/auth/tokens.d.ts +3 -0
- package/dist/auth/tokens.js +6 -4
- package/dist/auth/tokens.js.map +1 -1
- package/dist/base/command.d.ts +35 -0
- package/dist/base/command.js +87 -4
- package/dist/base/command.js.map +1 -1
- package/dist/commands/agents.d.ts +10 -0
- package/dist/commands/agents.js +53 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/api.d.ts +0 -1
- package/dist/commands/api.js +6 -5
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/app/deployment/list.d.ts +14 -0
- package/dist/commands/app/deployment/list.js +45 -0
- package/dist/commands/app/deployment/list.js.map +1 -0
- package/dist/commands/app/deployment/rollback.d.ts +18 -0
- package/dist/commands/app/deployment/rollback.js +57 -0
- package/dist/commands/app/deployment/rollback.js.map +1 -0
- package/dist/commands/app/deployment/show.d.ts +26 -0
- package/dist/commands/app/deployment/show.js +98 -0
- package/dist/commands/app/deployment/show.js.map +1 -0
- package/dist/commands/app/domain/add.d.ts +17 -0
- package/dist/commands/app/domain/add.js +59 -0
- package/dist/commands/app/domain/add.js.map +1 -0
- package/dist/commands/app/domain/list.d.ts +14 -0
- package/dist/commands/app/domain/list.js +42 -0
- package/dist/commands/app/domain/list.js.map +1 -0
- package/dist/commands/app/domain/remove.d.ts +16 -0
- package/dist/commands/app/domain/remove.js +51 -0
- package/dist/commands/app/domain/remove.js.map +1 -0
- package/dist/commands/app/domain/verify.d.ts +15 -0
- package/dist/commands/app/domain/verify.js +39 -0
- package/dist/commands/app/domain/verify.js.map +1 -0
- package/dist/commands/app/env/add.d.ts +22 -0
- package/dist/commands/app/env/add.js +103 -0
- package/dist/commands/app/env/add.js.map +1 -0
- package/dist/commands/app/env/list.d.ts +17 -0
- package/dist/commands/app/env/list.js +40 -0
- package/dist/commands/app/env/list.js.map +1 -0
- package/dist/commands/app/env/reveal.d.ts +17 -0
- package/dist/commands/app/env/reveal.js +40 -0
- package/dist/commands/app/env/reveal.js.map +1 -0
- package/dist/commands/app/env/rm.d.ts +16 -0
- package/dist/commands/app/env/rm.js +48 -0
- package/dist/commands/app/env/rm.js.map +1 -0
- package/dist/commands/app/health.d.ts +14 -0
- package/dist/commands/app/health.js +40 -0
- package/dist/commands/app/health.js.map +1 -0
- package/dist/commands/app/index.d.ts +6 -0
- package/dist/commands/app/index.js +7 -0
- package/dist/commands/app/index.js.map +1 -0
- package/dist/commands/app/link.d.ts +22 -0
- package/dist/commands/app/link.js +31 -0
- package/dist/commands/app/link.js.map +1 -0
- package/dist/commands/app/logs.d.ts +25 -0
- package/dist/commands/app/logs.js +121 -0
- package/dist/commands/app/logs.js.map +1 -0
- package/dist/commands/app/metrics.d.ts +21 -0
- package/dist/commands/app/metrics.js +123 -0
- package/dist/commands/app/metrics.js.map +1 -0
- package/dist/commands/app/plan/change.d.ts +18 -0
- package/dist/commands/app/plan/change.js +79 -0
- package/dist/commands/app/plan/change.js.map +1 -0
- package/dist/commands/app/plan/show.d.ts +14 -0
- package/dist/commands/app/plan/show.js +40 -0
- package/dist/commands/app/plan/show.js.map +1 -0
- package/dist/commands/app/settings/set.d.ts +25 -0
- package/dist/commands/app/settings/set.js +96 -0
- package/dist/commands/app/settings/set.js.map +1 -0
- package/dist/commands/app/settings/show.d.ts +14 -0
- package/dist/commands/app/settings/show.js +48 -0
- package/dist/commands/app/settings/show.js.map +1 -0
- package/dist/commands/app/unlink.d.ts +8 -0
- package/dist/commands/app/unlink.js +25 -0
- package/dist/commands/app/unlink.js.map +1 -0
- package/dist/commands/apps/create.d.ts +26 -0
- package/dist/commands/apps/create.js +91 -0
- package/dist/commands/apps/create.js.map +1 -0
- package/dist/commands/apps/list.d.ts +16 -0
- package/dist/commands/apps/list.js +54 -0
- package/dist/commands/apps/list.js.map +1 -0
- package/dist/commands/baremetal/activity.d.ts +14 -0
- package/dist/commands/baremetal/activity.js +53 -0
- package/dist/commands/baremetal/activity.js.map +1 -0
- package/dist/commands/baremetal/bandwidth.d.ts +10 -0
- package/dist/commands/baremetal/bandwidth.js +86 -0
- package/dist/commands/baremetal/bandwidth.js.map +1 -0
- package/dist/commands/baremetal/console.d.ts +20 -0
- package/dist/commands/baremetal/console.js +72 -0
- package/dist/commands/baremetal/console.js.map +1 -0
- package/dist/commands/baremetal/details.d.ts +11 -0
- package/dist/commands/baremetal/details.js +116 -0
- package/dist/commands/baremetal/details.js.map +1 -0
- package/dist/commands/baremetal/index.d.ts +5 -0
- package/dist/commands/baremetal/index.js +6 -0
- package/dist/commands/baremetal/index.js.map +1 -0
- package/dist/commands/baremetal/install-password.d.ts +14 -0
- package/dist/commands/baremetal/install-password.js +80 -0
- package/dist/commands/baremetal/install-password.js.map +1 -0
- package/dist/commands/baremetal/list.d.ts +11 -0
- package/dist/commands/baremetal/list.js +59 -0
- package/dist/commands/baremetal/list.js.map +1 -0
- package/dist/commands/baremetal/order.d.ts +34 -0
- package/dist/commands/baremetal/order.js +394 -0
- package/dist/commands/baremetal/order.js.map +1 -0
- package/dist/commands/baremetal/power.d.ts +18 -0
- package/dist/commands/baremetal/power.js +168 -0
- package/dist/commands/baremetal/power.js.map +1 -0
- package/dist/commands/baremetal/reinstall.d.ts +21 -0
- package/dist/commands/baremetal/reinstall.js +168 -0
- package/dist/commands/baremetal/reinstall.js.map +1 -0
- package/dist/commands/config/profile/add.d.ts +11 -0
- package/dist/commands/config/profile/add.js +51 -0
- package/dist/commands/config/profile/add.js.map +1 -0
- package/dist/commands/config/profile/list.d.ts +7 -0
- package/dist/commands/config/profile/list.js +29 -0
- package/dist/commands/config/profile/list.js.map +1 -0
- package/dist/commands/config/profile/remove.d.ts +11 -0
- package/dist/commands/config/profile/remove.js +35 -0
- package/dist/commands/config/profile/remove.js.map +1 -0
- package/dist/commands/config/profile/use.d.ts +10 -0
- package/dist/commands/config/profile/use.js +44 -0
- package/dist/commands/config/profile/use.js.map +1 -0
- package/dist/commands/config/show.js +4 -1
- package/dist/commands/config/show.js.map +1 -1
- package/dist/commands/credits/add.js +2 -2
- package/dist/commands/credits/add.js.map +1 -1
- package/dist/commands/credits/index.js +5 -1
- package/dist/commands/credits/index.js.map +1 -1
- package/dist/commands/deploy.d.ts +51 -0
- package/dist/commands/deploy.js +515 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/function/create.d.ts +29 -0
- package/dist/commands/function/create.js +113 -0
- package/dist/commands/function/create.js.map +1 -0
- package/dist/commands/function/credits/add.d.ts +29 -0
- package/dist/commands/function/credits/add.js +209 -0
- package/dist/commands/function/credits/add.js.map +1 -0
- package/dist/commands/function/credits/auto-reload.d.ts +27 -0
- package/dist/commands/function/credits/auto-reload.js +107 -0
- package/dist/commands/function/credits/auto-reload.js.map +1 -0
- package/dist/commands/function/credits/index.d.ts +22 -0
- package/dist/commands/function/credits/index.js +80 -0
- package/dist/commands/function/credits/index.js.map +1 -0
- package/dist/commands/function/cron/add.d.ts +19 -0
- package/dist/commands/function/cron/add.js +74 -0
- package/dist/commands/function/cron/add.js.map +1 -0
- package/dist/commands/function/cron/list.d.ts +12 -0
- package/dist/commands/function/cron/list.js +55 -0
- package/dist/commands/function/cron/list.js.map +1 -0
- package/dist/commands/function/cron/rm.d.ts +17 -0
- package/dist/commands/function/cron/rm.js +73 -0
- package/dist/commands/function/cron/rm.js.map +1 -0
- package/dist/commands/function/cron/run.d.ts +16 -0
- package/dist/commands/function/cron/run.js +59 -0
- package/dist/commands/function/cron/run.js.map +1 -0
- package/dist/commands/function/cron/update.d.ts +21 -0
- package/dist/commands/function/cron/update.js +87 -0
- package/dist/commands/function/cron/update.js.map +1 -0
- package/dist/commands/function/delete.d.ts +23 -0
- package/dist/commands/function/delete.js +90 -0
- package/dist/commands/function/delete.js.map +1 -0
- package/dist/commands/function/deploy.d.ts +64 -0
- package/dist/commands/function/deploy.js +608 -0
- package/dist/commands/function/deploy.js.map +1 -0
- package/dist/commands/function/env/list.d.ts +12 -0
- package/dist/commands/function/env/list.js +46 -0
- package/dist/commands/function/env/list.js.map +1 -0
- package/dist/commands/function/env/reveal.d.ts +21 -0
- package/dist/commands/function/env/reveal.js +54 -0
- package/dist/commands/function/env/reveal.js.map +1 -0
- package/dist/commands/function/env/rm.d.ts +17 -0
- package/dist/commands/function/env/rm.js +62 -0
- package/dist/commands/function/env/rm.js.map +1 -0
- package/dist/commands/function/env/set.d.ts +28 -0
- package/dist/commands/function/env/set.js +124 -0
- package/dist/commands/function/env/set.js.map +1 -0
- package/dist/commands/function/index.d.ts +14 -0
- package/dist/commands/function/index.js +11 -0
- package/dist/commands/function/index.js.map +1 -0
- package/dist/commands/function/init.d.ts +47 -0
- package/dist/commands/function/init.js +269 -0
- package/dist/commands/function/init.js.map +1 -0
- package/dist/commands/function/invoke.d.ts +29 -0
- package/dist/commands/function/invoke.js +138 -0
- package/dist/commands/function/invoke.js.map +1 -0
- package/dist/commands/function/link.d.ts +23 -0
- package/dist/commands/function/link.js +80 -0
- package/dist/commands/function/link.js.map +1 -0
- package/dist/commands/function/list.d.ts +16 -0
- package/dist/commands/function/list.js +55 -0
- package/dist/commands/function/list.js.map +1 -0
- package/dist/commands/function/logs.d.ts +29 -0
- package/dist/commands/function/logs.js +171 -0
- package/dist/commands/function/logs.js.map +1 -0
- package/dist/commands/function/pause.d.ts +19 -0
- package/dist/commands/function/pause.js +50 -0
- package/dist/commands/function/pause.js.map +1 -0
- package/dist/commands/function/releases.d.ts +15 -0
- package/dist/commands/function/releases.js +62 -0
- package/dist/commands/function/releases.js.map +1 -0
- package/dist/commands/function/resume.d.ts +16 -0
- package/dist/commands/function/resume.js +47 -0
- package/dist/commands/function/resume.js.map +1 -0
- package/dist/commands/function/rollback.d.ts +18 -0
- package/dist/commands/function/rollback.js +69 -0
- package/dist/commands/function/rollback.js.map +1 -0
- package/dist/commands/function/settings/set.d.ts +23 -0
- package/dist/commands/function/settings/set.js +119 -0
- package/dist/commands/function/settings/set.js.map +1 -0
- package/dist/commands/function/show.d.ts +15 -0
- package/dist/commands/function/show.js +80 -0
- package/dist/commands/function/show.js.map +1 -0
- package/dist/commands/function/unlink.d.ts +9 -0
- package/dist/commands/function/unlink.js +34 -0
- package/dist/commands/function/unlink.js.map +1 -0
- package/dist/commands/link.d.ts +77 -0
- package/dist/commands/link.js +530 -0
- package/dist/commands/link.js.map +1 -0
- package/dist/commands/login.js +9 -0
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/order.js +3 -1
- package/dist/commands/order.js.map +1 -1
- package/dist/commands/payments/methods/delete.js +2 -2
- package/dist/commands/payments/methods/delete.js.map +1 -1
- package/dist/commands/resources.js +50 -7
- package/dist/commands/resources.js.map +1 -1
- package/dist/commands/status.d.ts +12 -0
- package/dist/commands/status.js +71 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/storage/detach.js +1 -1
- package/dist/commands/storage/detach.js.map +1 -1
- package/dist/commands/storage/list.js +6 -2
- package/dist/commands/storage/list.js.map +1 -1
- package/dist/commands/storage/order.d.ts +2 -0
- package/dist/commands/storage/order.js +100 -18
- package/dist/commands/storage/order.js.map +1 -1
- package/dist/commands/storage/resize.js +19 -6
- package/dist/commands/storage/resize.js.map +1 -1
- package/dist/commands/tickets/create.d.ts +2 -0
- package/dist/commands/tickets/create.js +40 -1
- package/dist/commands/tickets/create.js.map +1 -1
- package/dist/commands/tickets/download.d.ts +18 -0
- package/dist/commands/tickets/download.js +138 -0
- package/dist/commands/tickets/download.js.map +1 -0
- package/dist/commands/tickets/list.js +13 -7
- package/dist/commands/tickets/list.js.map +1 -1
- package/dist/commands/tickets/reply.d.ts +2 -0
- package/dist/commands/tickets/reply.js +33 -4
- package/dist/commands/tickets/reply.js.map +1 -1
- package/dist/commands/vds/order.js +72 -7
- package/dist/commands/vds/order.js.map +1 -1
- package/dist/commands/vps/console.js +14 -6
- package/dist/commands/vps/console.js.map +1 -1
- package/dist/commands/vps/details.js +7 -1
- package/dist/commands/vps/details.js.map +1 -1
- package/dist/commands/vps/ip/add.js +76 -9
- package/dist/commands/vps/ip/add.js.map +1 -1
- package/dist/commands/vps/list.js +13 -4
- package/dist/commands/vps/list.js.map +1 -1
- package/dist/commands/vps/order.d.ts +19 -0
- package/dist/commands/vps/order.js +179 -23
- package/dist/commands/vps/order.js.map +1 -1
- package/dist/commands/vps/power.js +2 -2
- package/dist/commands/vps/power.js.map +1 -1
- package/dist/commands/vps/reinstall.js +2 -2
- package/dist/commands/vps/reinstall.js.map +1 -1
- package/dist/commands/vps/resize.js +36 -13
- package/dist/commands/vps/resize.js.map +1 -1
- package/dist/commands/whoami.d.ts +5 -0
- package/dist/commands/whoami.js +8 -3
- package/dist/commands/whoami.js.map +1 -1
- package/dist/config/paths.d.ts +1 -1
- package/dist/config/paths.js +6 -1
- package/dist/config/paths.js.map +1 -1
- package/dist/config/store.d.ts +58 -0
- package/dist/config/store.js +84 -2
- package/dist/config/store.js.map +1 -1
- package/dist/functions-support/credits.d.ts +64 -0
- package/dist/functions-support/credits.js +181 -0
- package/dist/functions-support/credits.js.map +1 -0
- package/dist/functions-support/cron.d.ts +17 -0
- package/dist/functions-support/cron.js +99 -0
- package/dist/functions-support/cron.js.map +1 -0
- package/dist/functions-support/env.d.ts +23 -0
- package/dist/functions-support/env.js +44 -0
- package/dist/functions-support/env.js.map +1 -0
- package/dist/functions-support/link.d.ts +25 -0
- package/dist/functions-support/link.js +51 -0
- package/dist/functions-support/link.js.map +1 -0
- package/dist/functions-support/poll.d.ts +40 -0
- package/dist/functions-support/poll.js +109 -0
- package/dist/functions-support/poll.js.map +1 -0
- package/dist/functions-support/resolve.d.ts +3 -0
- package/dist/functions-support/resolve.js +31 -0
- package/dist/functions-support/resolve.js.map +1 -0
- package/dist/functions-support/runtime.d.ts +30 -0
- package/dist/functions-support/runtime.js +52 -0
- package/dist/functions-support/runtime.js.map +1 -0
- package/dist/functions-support/source.d.ts +92 -0
- package/dist/functions-support/source.js +343 -0
- package/dist/functions-support/source.js.map +1 -0
- package/dist/help/scope-aware-help.js +10 -1
- package/dist/help/scope-aware-help.js.map +1 -1
- package/dist/tui/App.js +10 -25
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/components/Menu.d.ts +3 -1
- package/dist/tui/components/Menu.js +7 -3
- package/dist/tui/components/Menu.js.map +1 -1
- package/dist/tui/router.d.ts +1 -1
- package/dist/tui/router.js.map +1 -1
- package/dist/tui/screens/Billing.js +56 -4
- package/dist/tui/screens/Billing.js.map +1 -1
- package/dist/tui/screens/Dashboard.js +8 -7
- package/dist/tui/screens/Dashboard.js.map +1 -1
- package/dist/tui/screens/Deploy.d.ts +2 -0
- package/dist/tui/screens/Deploy.js +912 -0
- package/dist/tui/screens/Deploy.js.map +1 -0
- package/dist/tui/screens/Order.js +359 -26
- package/dist/tui/screens/Order.js.map +1 -1
- package/dist/tui/screens/Resources.js +273 -31
- package/dist/tui/screens/Resources.js.map +1 -1
- package/dist/tui/screens/Tickets.js +18 -6
- package/dist/tui/screens/Tickets.js.map +1 -1
- package/dist/tui/screens/deployPreset.d.ts +20 -0
- package/dist/tui/screens/deployPreset.js +11 -0
- package/dist/tui/screens/deployPreset.js.map +1 -0
- package/dist/tui/screens/resources/AppDetail.d.ts +7 -0
- package/dist/tui/screens/resources/AppDetail.js +810 -0
- package/dist/tui/screens/resources/AppDetail.js.map +1 -0
- package/dist/tui/screens/resources/FunctionDetail.d.ts +7 -0
- package/dist/tui/screens/resources/FunctionDetail.js +751 -0
- package/dist/tui/screens/resources/FunctionDetail.js.map +1 -0
- package/dist/ui/attach.d.ts +15 -0
- package/dist/ui/attach.js +63 -0
- package/dist/ui/attach.js.map +1 -0
- package/dist/ui/baremetal-resolve.d.ts +10 -0
- package/dist/ui/baremetal-resolve.js +50 -0
- package/dist/ui/baremetal-resolve.js.map +1 -0
- package/dist/ui/confirm.js +1 -1
- package/dist/ui/confirm.js.map +1 -1
- package/dist/ui/cycle.d.ts +66 -0
- package/dist/ui/cycle.js +96 -0
- package/dist/ui/cycle.js.map +1 -0
- package/dist/ui/deploy-ui.d.ts +75 -0
- package/dist/ui/deploy-ui.js +243 -0
- package/dist/ui/deploy-ui.js.map +1 -0
- package/dist/ui/order-result.d.ts +4 -0
- package/dist/ui/order-result.js +32 -0
- package/dist/ui/order-result.js.map +1 -0
- package/dist/ui/payment-gate.d.ts +26 -0
- package/dist/ui/payment-gate.js +70 -0
- package/dist/ui/payment-gate.js.map +1 -0
- package/dist/ui/payment.js +10 -3
- package/dist/ui/payment.js.map +1 -1
- package/dist/ui/portal.d.ts +1 -1
- package/dist/ui/portal.js +7 -2
- package/dist/ui/portal.js.map +1 -1
- package/dist/ui/project-resolve.d.ts +25 -0
- package/dist/ui/project-resolve.js +31 -0
- package/dist/ui/project-resolve.js.map +1 -0
- package/dist/ui/render-mode.d.ts +5 -0
- package/dist/ui/render-mode.js +1 -1
- package/dist/ui/render-mode.js.map +1 -1
- package/dist/ui/resource-detail.js +0 -3
- package/dist/ui/resource-detail.js.map +1 -1
- package/dist/ui/resource-resolve.d.ts +9 -2
- package/dist/ui/resource-resolve.js +11 -4
- package/dist/ui/resource-resolve.js.map +1 -1
- package/dist/ui/spinner.d.ts +10 -1
- package/dist/ui/spinner.js +12 -3
- package/dist/ui/spinner.js.map +1 -1
- package/dist/ui/table.d.ts +7 -0
- package/dist/ui/table.js +11 -0
- package/dist/ui/table.js.map +1 -1
- package/dist/ui/tax.d.ts +10 -0
- package/dist/ui/tax.js +31 -0
- package/dist/ui/tax.js.map +1 -0
- package/dist/ui/ticket-resolve.d.ts +9 -1
- package/dist/ui/ticket-resolve.js +13 -2
- package/dist/ui/ticket-resolve.js.map +1 -1
- package/dist/ui/volume-resolve.js +4 -1
- package/dist/ui/volume-resolve.js.map +1 -1
- package/dist/ui/wait.d.ts +4 -0
- package/dist/ui/wait.js +7 -2
- package/dist/ui/wait.js.map +1 -1
- package/dist/ui/wizard.d.ts +2 -1
- package/dist/ui/wizard.js +1 -1
- package/dist/ui/wizard.js.map +1 -1
- package/dist/version-check-bin.js +2 -2
- package/dist/version-check-bin.js.map +1 -1
- package/dist/version-check.d.ts +5 -0
- package/dist/version-check.js +6 -1
- package/dist/version-check.js.map +1 -1
- package/package.json +53 -6
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { ApiError } from "../api/errors.js";
|
|
2
|
+
import { planCapReason } from "./plans.js";
|
|
3
|
+
import { waitFor } from "../ui/wait.js";
|
|
4
|
+
import { withSpinner } from "../ui/spinner.js";
|
|
5
|
+
import { confirmAction, describePaymentMethod, pickFromCatalog, readBalance } from "../ui/wizard.js";
|
|
6
|
+
import { ensurePaymentMethod } from "../ui/payment-gate.js";
|
|
7
|
+
import { dim, ok } from "../ui/glyphs.js";
|
|
8
|
+
/**
|
|
9
|
+
* Creating a PAID app is an order: the first month is quoted (tax
|
|
10
|
+
* included), a card is chosen, the charge is confirmed, and provisioning runs
|
|
11
|
+
* off the settled order. This mirrors the web's NewAppPayModal step for
|
|
12
|
+
* step; POST /apps only ever creates free-tier apps (the backend refuses a
|
|
13
|
+
* paid tier there with 402).
|
|
14
|
+
*/
|
|
15
|
+
/** The tiers a team can still create an app on — a tier at its per-team
|
|
16
|
+
* cap is not offered at all (not greyed out: there is nothing to do with
|
|
17
|
+
* it). Empty means every tier is full for this team. */
|
|
18
|
+
export function pickablePlans(plans) {
|
|
19
|
+
return plans.filter((p) => planCapReason(p) === undefined);
|
|
20
|
+
}
|
|
21
|
+
/** The price, shown BEFORE any question about credits or cards (owner,
|
|
22
|
+
* 2026-09-23): the customer sees what the first month costs, then decides
|
|
23
|
+
* how to pay it. `degraded` = the tax engine did not answer, so the total
|
|
24
|
+
* is the plan's anchor and tax lands on the invoice. */
|
|
25
|
+
export function priceLine(q) {
|
|
26
|
+
const money = (n) => `$${n.toFixed(2)}${q.currency && q.currency !== "USD" ? ` ${q.currency}` : ""}`;
|
|
27
|
+
const tax = q.degraded
|
|
28
|
+
? " + tax (estimate unavailable; the final total is on the invoice)"
|
|
29
|
+
: q.taxTotal > 0
|
|
30
|
+
? ` (incl. ${money(q.taxTotal)} ${q.taxLabel})`
|
|
31
|
+
: "";
|
|
32
|
+
return `First month of ${q.slug} on ${q.planName}: ${money(q.total)}${tax}`;
|
|
33
|
+
}
|
|
34
|
+
/** The one line the customer confirms before being charged: the price first,
|
|
35
|
+
* then exactly where the money comes from. "Charge $0.00 … from your credit
|
|
36
|
+
* balance" read as nonsense (Ben, 2026-10-06), so a credit-covered month
|
|
37
|
+
* says what is used and that no card is touched. */
|
|
38
|
+
export function chargeLine(q) {
|
|
39
|
+
const money = (n) => `$${n.toFixed(2)}${q.currency && q.currency !== "USD" ? ` ${q.currency}` : ""}`;
|
|
40
|
+
const tax = q.taxTotal > 0 ? ` (incl. ${money(q.taxTotal)} ${q.taxLabel})` : "";
|
|
41
|
+
const price = `First month of ${q.slug} on ${q.planName}: ${money(q.total)}${tax}.`;
|
|
42
|
+
const credit = Math.min(Math.max(0, q.creditsApplied), q.total);
|
|
43
|
+
const due = q.total - credit;
|
|
44
|
+
const card = q.method ? describePaymentMethod(q.method) : "your payment method";
|
|
45
|
+
if (due <= 0)
|
|
46
|
+
return `${price} Use ${money(credit)} of your credit balance — nothing is charged to a card?`;
|
|
47
|
+
if (credit > 0)
|
|
48
|
+
return `${price} Use ${money(credit)} credit and charge the remaining ${money(due)} to ${card}?`;
|
|
49
|
+
return `${price} Charge ${money(due)} to ${card}?`;
|
|
50
|
+
}
|
|
51
|
+
export class PaidAppOrderError extends Error {
|
|
52
|
+
}
|
|
53
|
+
export async function orderPaidApp(clients, input, opts) {
|
|
54
|
+
const { api } = clients;
|
|
55
|
+
const spec = { slug: input.slug, plan_tier: input.plan.name, region: input.region, project_id: input.projectId };
|
|
56
|
+
// 1. The first-month quote, tax included. A preview failure (tax engine
|
|
57
|
+
// down, rate limit) must not block ordering: fall back to the tier's
|
|
58
|
+
// anchor price and say the tax is not in it. A preview the API REFUSED
|
|
59
|
+
// (4xx with a reason — the plan can't be ordered, the slug is taken,
|
|
60
|
+
// the location is full) is not a degraded quote: surface it and stop,
|
|
61
|
+
// or the customer is walked to a charge prompt for an order that will
|
|
62
|
+
// be refused the same way (staging, 2026-09-23: a dedicated tier's 422
|
|
63
|
+
// read as "Tax estimate unavailable" and the flow went on).
|
|
64
|
+
let total = Number(input.plan.monthlyAnchorUsd ?? 0);
|
|
65
|
+
let taxTotal = 0;
|
|
66
|
+
let taxLabel = "tax";
|
|
67
|
+
let currency = "USD";
|
|
68
|
+
let degraded = false;
|
|
69
|
+
try {
|
|
70
|
+
const q = await withSpinner("Pricing the first month", () => api.orders.preview({ kind: "app", spec }));
|
|
71
|
+
total = Number(q.total);
|
|
72
|
+
taxTotal = Number(q.tax_total ?? 0);
|
|
73
|
+
taxLabel = q.tax_label ?? "tax";
|
|
74
|
+
currency = q.currency ?? currency;
|
|
75
|
+
degraded = Boolean(q.estimate_degraded);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
if (e instanceof ApiError && e.status >= 400 && e.status < 500 && e.status !== 429) {
|
|
79
|
+
throw new Error(`Can't order ${input.plan.displayName ?? input.plan.name}: ${e.detail}`);
|
|
80
|
+
}
|
|
81
|
+
degraded = true;
|
|
82
|
+
}
|
|
83
|
+
// The price comes first, on its own line, before the credit and card
|
|
84
|
+
// questions — the questions are about how to pay an amount the customer
|
|
85
|
+
// has already seen, not the other way round.
|
|
86
|
+
opts.log(priceLine({
|
|
87
|
+
total, taxTotal, taxLabel, currency, degraded,
|
|
88
|
+
slug: input.slug, planName: input.plan.displayName ?? input.plan.name,
|
|
89
|
+
}));
|
|
90
|
+
// 2. Credits first, when the team has some and asked (or is asked).
|
|
91
|
+
const balance = await api.billing.balance().catch(() => ({}));
|
|
92
|
+
const credit = readBalance(balance.credit);
|
|
93
|
+
let applyCredits = Boolean(opts.applyCredits);
|
|
94
|
+
if (!applyCredits && credit > 0 && opts.interactive && !opts.yes) {
|
|
95
|
+
applyCredits = await confirmAction(`Apply your credit balance ($${credit.toFixed(2)}) first?`, true);
|
|
96
|
+
}
|
|
97
|
+
const creditsApplied = applyCredits ? Math.min(credit, total) : 0;
|
|
98
|
+
const coveredByCredit = applyCredits && credit >= total && total > 0;
|
|
99
|
+
// 3. A card the app_order touchpoint may charge — unless credit covers it.
|
|
100
|
+
let method;
|
|
101
|
+
if (!coveredByCredit) {
|
|
102
|
+
let rows = await api.payments.methodsForTouchpoint("app_order").catch(() => []);
|
|
103
|
+
let eligible = rows.filter((m) => m.eligible);
|
|
104
|
+
if (eligible.length === 0) {
|
|
105
|
+
// Same hand-off as the free tier: open the portal, wait, re-check.
|
|
106
|
+
await ensurePaymentMethod({
|
|
107
|
+
api,
|
|
108
|
+
apiBaseUrl: clients.config.get().api_base_url,
|
|
109
|
+
interactive: opts.interactive,
|
|
110
|
+
log: opts.log,
|
|
111
|
+
action: `charge the first month of ${input.slug}`,
|
|
112
|
+
});
|
|
113
|
+
rows = await api.payments.methodsForTouchpoint("app_order").catch(() => []);
|
|
114
|
+
eligible = rows.filter((m) => m.eligible);
|
|
115
|
+
if (eligible.length === 0) {
|
|
116
|
+
const why = rows.map((m) => m.ineligible_reason).filter(Boolean)[0];
|
|
117
|
+
throw new PaidAppOrderError(`No saved payment method can be charged for an app${why ? ` (${why})` : ""}. Add a card in the portal, then try again.`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (opts.paymentMethodId) {
|
|
121
|
+
method = rows.find((m) => m.id === opts.paymentMethodId);
|
|
122
|
+
if (!method)
|
|
123
|
+
throw new PaidAppOrderError(`Payment method ${opts.paymentMethodId} is not on this team.`);
|
|
124
|
+
if (!method.eligible) {
|
|
125
|
+
throw new PaidAppOrderError(`Payment method ${opts.paymentMethodId} can't be charged for an app${method.ineligible_reason ? `: ${method.ineligible_reason}` : "."}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else if (!opts.interactive || opts.yes) {
|
|
129
|
+
method = eligible.find((m) => m.is_default) ?? eligible[0];
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const id = await pickFromCatalog("Charge which payment method?", rows.map((m) => ({
|
|
133
|
+
value: m.id,
|
|
134
|
+
name: describePaymentMethod(m),
|
|
135
|
+
disabled: m.eligible ? undefined : (m.ineligible_reason ?? "not allowed for apps"),
|
|
136
|
+
})), { defaultValue: (eligible.find((m) => m.is_default) ?? eligible[0]).id });
|
|
137
|
+
method = rows.find((m) => m.id === id);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// 4. Confirm the charge. Scripts pass --yes; a non-interactive run
|
|
141
|
+
// without it must not charge silently.
|
|
142
|
+
const line = chargeLine({
|
|
143
|
+
total,
|
|
144
|
+
taxTotal,
|
|
145
|
+
taxLabel,
|
|
146
|
+
currency,
|
|
147
|
+
slug: input.slug,
|
|
148
|
+
planName: input.plan.displayName ?? input.plan.name,
|
|
149
|
+
method,
|
|
150
|
+
creditsApplied,
|
|
151
|
+
});
|
|
152
|
+
if (!opts.yes) {
|
|
153
|
+
if (!opts.interactive) {
|
|
154
|
+
throw new PaidAppOrderError(`${line.replace(/\?$/, ".")}\nRe-run with --yes to confirm the charge.`);
|
|
155
|
+
}
|
|
156
|
+
if (!(await confirmAction(line, true)))
|
|
157
|
+
throw new PaidAppOrderError("Not charged; no app created.");
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
opts.log(dim(line.replace(/\?$/, ".")));
|
|
161
|
+
}
|
|
162
|
+
// 5. Order → settle → provision. The app row lands off the settled order.
|
|
163
|
+
const payment = coveredByCredit
|
|
164
|
+
? { method: "credit_only" }
|
|
165
|
+
: { method: "saved", payment_method_id: method.id, apply_credits: applyCredits && credit > 0 };
|
|
166
|
+
const result = await withSpinner(`Charging and creating ${input.slug}`, () => api.orders.createApp(spec, payment));
|
|
167
|
+
if (result.checkout_url) {
|
|
168
|
+
throw new PaidAppOrderError(`This order needs hosted checkout: ${result.checkout_url}`);
|
|
169
|
+
}
|
|
170
|
+
if (result.status === "failed")
|
|
171
|
+
throw new PaidAppOrderError("The charge did not go through; no app created.");
|
|
172
|
+
const wait = await waitFor({
|
|
173
|
+
timeoutSeconds: opts.timeoutSeconds ?? 120,
|
|
174
|
+
poll: () => api.orders.status(result.order_id),
|
|
175
|
+
classify: (o) => {
|
|
176
|
+
const s = (o.status ?? "").toLowerCase();
|
|
177
|
+
if ((s === "complete" || s === "provisioned") && o.resource_id)
|
|
178
|
+
return { state: "success", label: `order ${s}` };
|
|
179
|
+
if (s === "failed" || s === "cancelled") {
|
|
180
|
+
return { state: "failure", label: `order ${s}`, reason: `Order ${s}: ${o.error_detail ?? "no detail from server"}` };
|
|
181
|
+
}
|
|
182
|
+
return { state: "pending", label: `order ${s || "pending"}` };
|
|
183
|
+
},
|
|
184
|
+
onStatus: (l) => opts.log(dim(` ${l}`)),
|
|
185
|
+
});
|
|
186
|
+
if (wait.outcome === "timeout") {
|
|
187
|
+
throw new PaidAppOrderError(`Charged, but the app is still being created (order ${result.order_id}). It will appear in \`synteq app list\` shortly.`);
|
|
188
|
+
}
|
|
189
|
+
if (wait.outcome === "failure")
|
|
190
|
+
throw new PaidAppOrderError(wait.reason);
|
|
191
|
+
const app = await api.apps.get(wait.value.resource_id);
|
|
192
|
+
opts.log(ok(`Charged ${creditsApplied >= total && total > 0 ? "credit" : describePaymentMethod(method)} for the first month.`));
|
|
193
|
+
return app;
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=paid-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paid-app.js","sourceRoot":"","sources":["../../src/apps-support/paid-app.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACrG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAE1C;;;;;;GAMG;AAEH;;yDAEyD;AACzD,MAAM,UAAU,a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M,IAAI,iBAAiB,CACzB,sDAAsD,MAAM,CAAC,QAAQ,mDAAmD,CACzH,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;QAAE,MAAM,IAAI,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzE,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,WAAY,CAAC,CAAC;IACxD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW,cAAc,IAAI,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC,MAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC;IACjI,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AppLocation } from "../api/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Plan and location helpers shared by the one-shot commands (`link`,
|
|
4
|
+
* `deploy`, `apps create`) and the TUI Deploy walkthrough — the TUI must
|
|
5
|
+
* not import from `commands/`.
|
|
6
|
+
*/
|
|
7
|
+
/** One-line plan description for the picker: resources + price (or "free")
|
|
8
|
+
* + how much of the per-team cap is used. */
|
|
9
|
+
export declare function planLine(p: {
|
|
10
|
+
isFree?: boolean;
|
|
11
|
+
cpuMillicores?: number;
|
|
12
|
+
memoryMib?: number;
|
|
13
|
+
monthlyAnchorUsd?: string | number;
|
|
14
|
+
maxAppsPerTeam?: number | null;
|
|
15
|
+
teamAppsOnTier?: number;
|
|
16
|
+
}): string;
|
|
17
|
+
/** A tier is unpickable when the team is at its per-team cap on it. Returns
|
|
18
|
+
* the reason the picker shows in parens, or undefined when it can be chosen. */
|
|
19
|
+
export declare function planCapReason(p: {
|
|
20
|
+
name?: string;
|
|
21
|
+
isFree?: boolean;
|
|
22
|
+
maxAppsPerTeam?: number | null;
|
|
23
|
+
teamAppsOnTier?: number;
|
|
24
|
+
/** Pro boxes (2026-09-23): a dedicated tier with no capacity right now. */
|
|
25
|
+
available?: boolean;
|
|
26
|
+
unavailableReason?: string | null;
|
|
27
|
+
}): string | undefined;
|
|
28
|
+
/** A paid tier is an ORDER (quote, card, charge); only a free tier is a bare
|
|
29
|
+
* POST /apps. */
|
|
30
|
+
export declare function isPaidPlan(p: {
|
|
31
|
+
name?: string;
|
|
32
|
+
isFree?: boolean;
|
|
33
|
+
}): boolean;
|
|
34
|
+
/** A location the picker offers; `region` is the value POSTed as the app's
|
|
35
|
+
* region. Built from GET /apps/locations — the placeable clusters of THIS
|
|
36
|
+
* environment — exactly like the web onboarding (NewAppSlideOver's
|
|
37
|
+
* toLocationOptions): several clusters can share a datacenter, so dedupe on
|
|
38
|
+
* the Location code; a cluster with no linked Location is not offerable. */
|
|
39
|
+
export interface LocationOption {
|
|
40
|
+
code: string;
|
|
41
|
+
city: string;
|
|
42
|
+
region: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function toLocationOptions(rows: AppLocation[]): LocationOption[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan and location helpers shared by the one-shot commands (`link`,
|
|
3
|
+
* `deploy`, `apps create`) and the TUI Deploy walkthrough — the TUI must
|
|
4
|
+
* not import from `commands/`.
|
|
5
|
+
*/
|
|
6
|
+
/** One-line plan description for the picker: resources + price (or "free")
|
|
7
|
+
* + how much of the per-team cap is used. */
|
|
8
|
+
export function planLine(p) {
|
|
9
|
+
const cpu = p.cpuMillicores ? `${(p.cpuMillicores / 1000).toFixed(p.cpuMillicores % 1000 ? 1 : 0)} vCPU` : "";
|
|
10
|
+
const mem = p.memoryMib ? `${Math.round(p.memoryMib / 1024 * 10) / 10} GB` : "";
|
|
11
|
+
const price = p.isFree ? "free" : p.monthlyAnchorUsd != null ? `$${p.monthlyAnchorUsd}/mo` : "";
|
|
12
|
+
const cap = p.maxAppsPerTeam != null ? `${p.teamAppsOnTier ?? 0}/${p.maxAppsPerTeam} used` : "";
|
|
13
|
+
return [cpu, mem, price, cap].filter(Boolean).join(" · ");
|
|
14
|
+
}
|
|
15
|
+
/** A tier is unpickable when the team is at its per-team cap on it. Returns
|
|
16
|
+
* the reason the picker shows in parens, or undefined when it can be chosen. */
|
|
17
|
+
export function planCapReason(p) {
|
|
18
|
+
if (p.available === false)
|
|
19
|
+
return p.unavailableReason ?? "No capacity right now";
|
|
20
|
+
if (p.maxAppsPerTeam == null)
|
|
21
|
+
return undefined;
|
|
22
|
+
if ((p.teamAppsOnTier ?? 0) < p.maxAppsPerTeam)
|
|
23
|
+
return undefined;
|
|
24
|
+
return p.isFree || p.name === "free" ? "max free" : "max used";
|
|
25
|
+
}
|
|
26
|
+
/** A paid tier is an ORDER (quote, card, charge); only a free tier is a bare
|
|
27
|
+
* POST /apps. */
|
|
28
|
+
export function isPaidPlan(p) {
|
|
29
|
+
return !p.isFree && p.name !== "free";
|
|
30
|
+
}
|
|
31
|
+
export function toLocationOptions(rows) {
|
|
32
|
+
const out = [];
|
|
33
|
+
const seen = new Set();
|
|
34
|
+
for (const r of rows) {
|
|
35
|
+
const code = (r.code ?? "").trim();
|
|
36
|
+
if (!code || seen.has(code))
|
|
37
|
+
continue;
|
|
38
|
+
seen.add(code);
|
|
39
|
+
out.push({ code, city: (r.city ?? "").trim() || r.name, region: r.region });
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=plans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plans.js","sourceRoot":"","sources":["../../src/apps-support/plans.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH;8CAC8C;AAC9C,MAAM,UAAU,QAAQ,CAAC,CAOxB;IACC,MAAM,GAAG,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CA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UAAU,CAAC;AACjE,CAAC;AAED;kBACkB;AAClB,MAAM,UAAU,UAAU,CAAC,CAAsC;IAC/D,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;AACxC,CAAC;AAaD,MAAM,UAAU,iBAAiB,CAAC,IAAmB;IACnD,MAAM,GAAG,GAAqB,EAAE,CAAC;IACjC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QACtC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACf,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ApiClient } from "../api/client.js";
|
|
2
|
+
import type { App } from "../api/types.js";
|
|
3
|
+
export declare function resolveApp(api: ApiClient, ref: string, projectId?: string): Promise<App>;
|
|
4
|
+
/** The lists print the first 8 characters of an id; accept that (or any
|
|
5
|
+
* unambiguous hex prefix of the id, dashes ignored) as a target. */
|
|
6
|
+
export declare function isIdPrefix(ref: string): boolean;
|
|
7
|
+
export declare function idPrefixMatches<T extends {
|
|
8
|
+
id: string;
|
|
9
|
+
slug: string;
|
|
10
|
+
}>(rows: T[], ref: string, kind: string): T[];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { pageThrough } from "../api/client.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve an app reference (slug OR uuid) to a full App row for the active
|
|
4
|
+
* project. Commands take a friendly `<app>` slug; the API keys everything by
|
|
5
|
+
* uuid.
|
|
6
|
+
*
|
|
7
|
+
* A raw uuid is looked up directly via GET /apps/{id} (cheaper, and works for
|
|
8
|
+
* an app the active-project list wouldn't include). Anything else is asked
|
|
9
|
+
* of the server as `q=<slug>` (name / slug / hostname search, portal #419)
|
|
10
|
+
* and exact-matched here — GET /apps is paged (50 by default, 200 at most),
|
|
11
|
+
* so scanning one page read the 201st app as "not found". An id prefix is
|
|
12
|
+
* not something `q` searches, so that walks every page.
|
|
13
|
+
*
|
|
14
|
+
* Throws a plain Error whose message the command surfaces via `this.error`
|
|
15
|
+
* (exit 1) — resolution failure is a user error, not a network fault.
|
|
16
|
+
*/
|
|
17
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
18
|
+
export async function resolveApp(api, ref, projectId) {
|
|
19
|
+
if (UUID_RE.test(ref)) {
|
|
20
|
+
// Direct lookup — the API 404s (→ ApiError) if it isn't ours.
|
|
21
|
+
return api.apps.get(ref);
|
|
22
|
+
}
|
|
23
|
+
const bySlug = await pageThrough((page) => api.apps.listPage(projectId, { q: ref, page }), (page) => page.items.some((a) => a.slug === ref));
|
|
24
|
+
let matches = bySlug.filter((a) => a.slug === ref);
|
|
25
|
+
if (matches.length === 0 && isIdPrefix(ref)) {
|
|
26
|
+
const all = await pageThrough((page) => api.apps.listPage(projectId, { page }));
|
|
27
|
+
matches = idPrefixMatches(all, ref, "app");
|
|
28
|
+
}
|
|
29
|
+
if (matches.length === 0) {
|
|
30
|
+
throw new Error(`No app named "${ref}" in the active project. Run \`synteq apps list\` to see available apps.`);
|
|
31
|
+
}
|
|
32
|
+
if (matches.length > 1) {
|
|
33
|
+
// Slugs are unique per active project so this is defensive; prefer newest.
|
|
34
|
+
matches.sort((a, b) => b.id.localeCompare(a.id));
|
|
35
|
+
}
|
|
36
|
+
return matches[0];
|
|
37
|
+
}
|
|
38
|
+
/** The lists print the first 8 characters of an id; accept that (or any
|
|
39
|
+
* unambiguous hex prefix of the id, dashes ignored) as a target. */
|
|
40
|
+
export function isIdPrefix(ref) {
|
|
41
|
+
return /^[0-9a-f]{6,31}$/i.test(ref);
|
|
42
|
+
}
|
|
43
|
+
export function idPrefixMatches(rows, ref, kind) {
|
|
44
|
+
if (!isIdPrefix(ref))
|
|
45
|
+
return [];
|
|
46
|
+
const want = ref.toLowerCase();
|
|
47
|
+
const hits = rows.filter((r) => r.id.replace(/-/g, "").toLowerCase().startsWith(want));
|
|
48
|
+
if (hits.length > 1) {
|
|
49
|
+
throw new Error(`"${ref}" matches ${hits.length} ${kind}s (${hits.map((r) => r.slug).join(", ")}); use the slug or a longer id.`);
|
|
50
|
+
}
|
|
51
|
+
return hits;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/apps-support/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAC;AAG/D;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,GACX,iEAAiE,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAc,EACd,GAAW,EACX,SAAkB;IAElB,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACtB,8DAA8D;QAC9D,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,WAAW,CAC9B,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,GAAG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,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IAChC,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACvF,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,IAAI,GAAG,aAAa,IAAI,CAAC,MAAM,IAAI,IAAI,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,iCAAiC,CACjH,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time bounds for `--from` / `--until` (and the TUI's log timeframe filter).
|
|
3
|
+
*
|
|
4
|
+
* A bound is either an ISO-8601 instant ("2026-09-12T16:00:00Z",
|
|
5
|
+
* "2026-09-12 16:00", a date alone = midnight UTC) or a relative age
|
|
6
|
+
* ("90m", "2h", "3d", "1w") meaning that long before now. Relative ages
|
|
7
|
+
* are what people actually type at a prompt; ISO is what scripts pass.
|
|
8
|
+
*/
|
|
9
|
+
/** Parse one bound. Returns null when the text is neither shape. */
|
|
10
|
+
export declare function parseTimeBound(raw: string, now?: Date): Date | null;
|
|
11
|
+
/** Both bounds at once, validated: from < until. Throws a plain Error with
|
|
12
|
+
* the message a CLI or a prompt can show verbatim. */
|
|
13
|
+
export declare function parseTimeframe(from: string | undefined, until: string | undefined, now?: Date): {
|
|
14
|
+
from?: string;
|
|
15
|
+
until?: string;
|
|
16
|
+
};
|
|
17
|
+
/** "16:04:09" in the viewer's zone, for a log line. */
|
|
18
|
+
export declare function fmtClock(iso: string | undefined): string;
|
|
19
|
+
/** "Sep 12 16:04" in the viewer's zone, for a release row. */
|
|
20
|
+
export declare function fmtWhen(iso: string | undefined | null): string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time bounds for `--from` / `--until` (and the TUI's log timeframe filter).
|
|
3
|
+
*
|
|
4
|
+
* A bound is either an ISO-8601 instant ("2026-09-12T16:00:00Z",
|
|
5
|
+
* "2026-09-12 16:00", a date alone = midnight UTC) or a relative age
|
|
6
|
+
* ("90m", "2h", "3d", "1w") meaning that long before now. Relative ages
|
|
7
|
+
* are what people actually type at a prompt; ISO is what scripts pass.
|
|
8
|
+
*/
|
|
9
|
+
const RELATIVE = /^(\d+(?:\.\d+)?)\s*([smhdw])$/i;
|
|
10
|
+
const UNIT_MS = {
|
|
11
|
+
s: 1_000,
|
|
12
|
+
m: 60_000,
|
|
13
|
+
h: 3_600_000,
|
|
14
|
+
d: 86_400_000,
|
|
15
|
+
w: 604_800_000,
|
|
16
|
+
};
|
|
17
|
+
/** Parse one bound. Returns null when the text is neither shape. */
|
|
18
|
+
export function parseTimeBound(raw, now = new Date()) {
|
|
19
|
+
const text = raw.trim();
|
|
20
|
+
if (!text)
|
|
21
|
+
return null;
|
|
22
|
+
const rel = RELATIVE.exec(text);
|
|
23
|
+
if (rel) {
|
|
24
|
+
const n = Number(rel[1]);
|
|
25
|
+
const unit = rel[2].toLowerCase();
|
|
26
|
+
if (!Number.isFinite(n) || n < 0)
|
|
27
|
+
return null;
|
|
28
|
+
return new Date(now.getTime() - n * UNIT_MS[unit]);
|
|
29
|
+
}
|
|
30
|
+
// "2026-09-12 16:00" → ISO's "T"; a bare date is midnight UTC, and a
|
|
31
|
+
// timestamp with no zone is read as UTC (the API's own rule for naive
|
|
32
|
+
// values), so what the user typed and what the server filtered on agree.
|
|
33
|
+
let iso = text.replace(" ", "T");
|
|
34
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(iso))
|
|
35
|
+
iso += "T00:00:00Z";
|
|
36
|
+
else if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/.test(iso))
|
|
37
|
+
iso += "Z";
|
|
38
|
+
const d = new Date(iso);
|
|
39
|
+
return Number.isNaN(d.getTime()) ? null : d;
|
|
40
|
+
}
|
|
41
|
+
/** Both bounds at once, validated: from < until. Throws a plain Error with
|
|
42
|
+
* the message a CLI or a prompt can show verbatim. */
|
|
43
|
+
export function parseTimeframe(from, until, now = new Date()) {
|
|
44
|
+
const out = {};
|
|
45
|
+
let fromDate = null;
|
|
46
|
+
let untilDate = null;
|
|
47
|
+
if (from !== undefined) {
|
|
48
|
+
fromDate = parseTimeBound(from, now);
|
|
49
|
+
if (!fromDate)
|
|
50
|
+
throw new Error(`--from: "${from}" is not a timestamp (2026-09-12T16:00:00Z) or an age (90m, 2h, 3d).`);
|
|
51
|
+
out.from = fromDate.toISOString();
|
|
52
|
+
}
|
|
53
|
+
if (until !== undefined) {
|
|
54
|
+
untilDate = parseTimeBound(until, now);
|
|
55
|
+
if (!untilDate)
|
|
56
|
+
throw new Error(`--until: "${until}" is not a timestamp (2026-09-12T17:00:00Z) or an age (30m, 1h).`);
|
|
57
|
+
out.until = untilDate.toISOString();
|
|
58
|
+
}
|
|
59
|
+
if (fromDate && untilDate && untilDate <= fromDate) {
|
|
60
|
+
throw new Error("--until must be after --from.");
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
/** "16:04:09" in the viewer's zone, for a log line. */
|
|
65
|
+
export function fmtClock(iso) {
|
|
66
|
+
if (!iso)
|
|
67
|
+
return "";
|
|
68
|
+
const d = new Date(iso);
|
|
69
|
+
if (Number.isNaN(d.getTime()))
|
|
70
|
+
return iso;
|
|
71
|
+
return d.toLocaleTimeString(undefined, { hour12: false });
|
|
72
|
+
}
|
|
73
|
+
/** "Sep 12 16:04" in the viewer's zone, for a release row. */
|
|
74
|
+
export function fmtWhen(iso) {
|
|
75
|
+
if (!iso)
|
|
76
|
+
return "";
|
|
77
|
+
const d = new Date(iso);
|
|
78
|
+
if (Number.isNaN(d.getTime()))
|
|
79
|
+
return iso;
|
|
80
|
+
return d.toLocaleString(undefined, { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", hour12: false });
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../src/apps-support/time.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AAClD,MAAM,OAAO,GAA2B;IACtC,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,WAAW;CACf,CAAC;AAEF,oEAAoE;AACpE,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,MAAY,IAAI,IAAI,EAAE;IAChE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACxB,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAC9C,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC;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SAAS,IAAI,SAAS,IAAI,QAAQ,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,QAAQ,CAAC,GAAuB;IAC9C,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAAE,OAAO,GAAG,CAAC;IAC1C,OAAO,CAAC,CAAC,kBAAkB,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,OAAO,CAAC,GAA8B;IACpD,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAAE,OAAO,GAAG,CAAC;IAC1C,OAAO,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AAC5H,CAAC"}
|
package/dist/auth/scope.js
CHANGED
|
@@ -30,6 +30,10 @@ export function scopeAllowsCommand(cmdScope, granted) {
|
|
|
30
30
|
// Fail-closed: no label ⇒ treat as session-only.
|
|
31
31
|
if (cmdScope === undefined || cmdScope === "none")
|
|
32
32
|
return "deny-session-only";
|
|
33
|
+
// "any": the command has no scope of its own (`synteq api`, `synteq agents`)
|
|
34
|
+
// — any key may run it and the backend enforces scope per endpoint.
|
|
35
|
+
if (cmdScope === "any")
|
|
36
|
+
return "allow";
|
|
33
37
|
if (granted === null)
|
|
34
38
|
return "allow-unknown";
|
|
35
39
|
return granted.has(cmdScope) ? "allow" : "deny-missing-scope";
|
package/dist/auth/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/auth/scope.ts"],"names":[],"mappings":"AAKA;8EAC8E;AAC9E,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAkB;IACrD,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7D,IAAI,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACnC,IAAI,CAAC,MAAM;QAAE,OAAO,WAAW,CAAC;IAChC,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAChD,OAAO,SAAS,CAAC;AACnB,CAAC;AAQD;;;;;;;qEAOqE;AACrE,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEjF,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,OAAO,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED;;+EAE+E;AAC/E,MAAM,UAAU,kBAAkB,CAChC,QAA4B,EAC5B,OAAiB;IAEjB,iDAAiD;IACjD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,MAAM;QAAE,OAAO,mBAAmB,CAAC;IAC9E,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,eAAe,CAAC;IAC7C,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC;AACh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OAAO,8BAA8B,OAAO,6CAA6C,CAClG,CAAC;AACJ,CAAC"}
|
package/dist/auth/tokens.d.ts
CHANGED
|
@@ -8,10 +8,13 @@ export interface Tokens {
|
|
|
8
8
|
export interface TokenStoreOpts {
|
|
9
9
|
filePath?: string;
|
|
10
10
|
useKeychain?: boolean;
|
|
11
|
+
/** Named profile these credentials belong to; scopes the file + keychain slot. */
|
|
12
|
+
profile?: string;
|
|
11
13
|
}
|
|
12
14
|
export declare class TokenStore {
|
|
13
15
|
private filePath;
|
|
14
16
|
private useKeychain;
|
|
17
|
+
private account;
|
|
15
18
|
constructor(opts?: TokenStoreOpts);
|
|
16
19
|
read(): Promise<Tokens | null>;
|
|
17
20
|
write(tokens: Tokens): Promise<void>;
|
package/dist/auth/tokens.js
CHANGED
|
@@ -6,14 +6,16 @@ const KEYCHAIN_ACCOUNT = "tokens";
|
|
|
6
6
|
export class TokenStore {
|
|
7
7
|
filePath;
|
|
8
8
|
useKeychain;
|
|
9
|
+
account;
|
|
9
10
|
constructor(opts = {}) {
|
|
10
|
-
this.filePath = opts.filePath ?? tokensFile();
|
|
11
|
+
this.filePath = opts.filePath ?? tokensFile(opts.profile);
|
|
12
|
+
this.account = opts.profile ? `${KEYCHAIN_ACCOUNT}-${opts.profile}` : KEYCHAIN_ACCOUNT;
|
|
11
13
|
const envOptOut = process.env.SYNTEQ_NO_KEYCHAIN === "1";
|
|
12
14
|
this.useKeychain = opts.useKeychain ?? !envOptOut;
|
|
13
15
|
}
|
|
14
16
|
async read() {
|
|
15
17
|
if (this.useKeychain) {
|
|
16
|
-
const raw = await keychainGet(
|
|
18
|
+
const raw = await keychainGet(this.account);
|
|
17
19
|
if (raw) {
|
|
18
20
|
try {
|
|
19
21
|
return JSON.parse(raw);
|
|
@@ -33,7 +35,7 @@ export class TokenStore {
|
|
|
33
35
|
}
|
|
34
36
|
async write(tokens) {
|
|
35
37
|
const payload = JSON.stringify(tokens);
|
|
36
|
-
if (this.useKeychain && (await keychainSet(
|
|
38
|
+
if (this.useKeychain && (await keychainSet(this.account, payload))) {
|
|
37
39
|
rmSync(this.filePath, { force: true });
|
|
38
40
|
return;
|
|
39
41
|
}
|
|
@@ -44,7 +46,7 @@ export class TokenStore {
|
|
|
44
46
|
async clear() {
|
|
45
47
|
if (this.useKeychain) {
|
|
46
48
|
try {
|
|
47
|
-
await keychainDelete(
|
|
49
|
+
await keychainDelete(this.account);
|
|
48
50
|
}
|
|
49
51
|
catch {
|
|
50
52
|
}
|
package/dist/auth/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/auth/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEzE,MAAM,gBAAgB,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/auth/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEzE,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAiBlC,MAAM,OAAO,UAAU;IACb,QAAQ,CAAS;IACjB,WAAW,CAAU;IACrB,OAAO,CAAS;IAEx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AAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACvC,OAAO;QACT,CAAC;QACD,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACvD,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC;gBACH,MAAM,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrC,CAAC;YAAC,MAAM,CAAC;YACT,CAAC;QACH,CAAC;QACD,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;CACF"}
|
package/dist/base/command.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
2
|
import { type Clients } from "../api/factory.js";
|
|
3
|
+
/** Positional app target shared by the `app …` commands that act on one app. */
|
|
4
|
+
export declare const appTargetArg: {
|
|
5
|
+
target: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
import type { App } from "../api/types.js";
|
|
3
8
|
export declare abstract class BaseCommand extends Command {
|
|
4
9
|
static baseFlags: {
|
|
5
10
|
output: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -9,9 +14,39 @@ export declare abstract class BaseCommand extends Command {
|
|
|
9
14
|
protected outputFormat: "table" | "json";
|
|
10
15
|
protected initClients(): Promise<void>;
|
|
11
16
|
protected emit(data: unknown, renderTable: () => void): void;
|
|
17
|
+
/** An informational line. stdout in table mode; stderr in JSON mode, where
|
|
18
|
+
* stdout carries the JSON document only (piped / `-o json` output must
|
|
19
|
+
* parse). */
|
|
20
|
+
protected info(line: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* The app-resolution dance every `app *` command shares: take an explicit
|
|
23
|
+
* `--app <slug|uuid>` or fall back to this directory's `synteq link`,
|
|
24
|
+
* rescope the client to the linked team, and resolve to a full App.
|
|
25
|
+
* Rescopes `this.clients` as a side effect (same as the inline blocks it
|
|
26
|
+
* replaces). A bad slug is a user error (exit 1); an API fault propagates
|
|
27
|
+
* to `this.fail`.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Commands with one required positional (a release ref, an env key, a
|
|
31
|
+
* hostname, a tier) also take the app as an optional LEADING positional:
|
|
32
|
+
* `app deployment show rackmap 1` and `app deployment show 1` both work.
|
|
33
|
+
* Returns [target, value]; errors when the value is missing.
|
|
34
|
+
*/
|
|
35
|
+
protected positional(first: string | undefined, second: string | undefined, name: string): [string | undefined, string];
|
|
36
|
+
protected resolveLinkedApp(flags: {
|
|
37
|
+
app?: string;
|
|
38
|
+
team?: string;
|
|
39
|
+
insecure?: boolean;
|
|
40
|
+
}, target?: string): Promise<App>;
|
|
12
41
|
protected failWith(detail: string, exit: number, status?: number, requestId?: string): never;
|
|
13
42
|
protected catch(err: Error & {
|
|
14
43
|
exitCode?: number;
|
|
15
44
|
}): Promise<unknown>;
|
|
45
|
+
/** A finished command gives the shell back. Interactive prompts (inquirer,
|
|
46
|
+
* clack) attach to stdin, and a TTY stdin that is left flowing or ref'd
|
|
47
|
+
* keeps Node's event loop — and so the process — alive after the last line
|
|
48
|
+
* of output, which reads as the CLI hanging. `run()` has resolved or thrown
|
|
49
|
+
* by the time oclif calls this, so nothing still needs the keyboard. */
|
|
50
|
+
protected finally(err: Error | undefined): Promise<unknown>;
|
|
16
51
|
protected fail(err: unknown): never;
|
|
17
52
|
}
|