@synteq/cli 0.2.0 → 1.1.2
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 +17 -0
- package/dist/commands/apps/list.js +56 -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 +616 -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 +48 -0
- package/dist/commands/function/init.js +277 -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 +82 -0
- package/dist/commands/link.js +532 -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,99 @@
|
|
|
1
|
+
/** The five fields and their ranges — the backend's `_CRON_RANGES`
|
|
2
|
+
* (routers/functions.py), in the same order. Day-of-week allows 0-7. */
|
|
3
|
+
const CRON_FIELDS = [
|
|
4
|
+
{ name: "minute", lo: 0, hi: 59 },
|
|
5
|
+
{ name: "hour", lo: 0, hi: 23 },
|
|
6
|
+
{ name: "day-of-month", lo: 1, hi: 31 },
|
|
7
|
+
{ name: "month", lo: 1, hi: 12 },
|
|
8
|
+
{ name: "day-of-week", lo: 0, hi: 7 },
|
|
9
|
+
];
|
|
10
|
+
/** The backend's `_CRON_FIELD_RE`: digits, `*`, `,`, `-` and `/` only — no
|
|
11
|
+
* names (MON, JAN) and no `?`/`L`/`#`. */
|
|
12
|
+
const CRON_FIELD_RE = /^[0-9*,/-]+$/;
|
|
13
|
+
const DIGITS_RE = /^[0-9]+$/;
|
|
14
|
+
/** A port of the backend's `_valid_cron_field`: comma-separated parts, each
|
|
15
|
+
* `*`, `N` or `A-B` (A <= B, both in range), optionally `/STEP` (STEP >= 1). */
|
|
16
|
+
export function validCronField(field, lo, hi) {
|
|
17
|
+
if (!field || !CRON_FIELD_RE.test(field))
|
|
18
|
+
return false;
|
|
19
|
+
for (const part of field.split(",")) {
|
|
20
|
+
if (!part)
|
|
21
|
+
return false;
|
|
22
|
+
const slash = part.indexOf("/");
|
|
23
|
+
const expr = slash === -1 ? part : part.slice(0, slash);
|
|
24
|
+
const step = slash === -1 ? "" : part.slice(slash + 1);
|
|
25
|
+
// A "/" always needs a number after it ("*/" is refused by the server
|
|
26
|
+
// and by the orchestrator's scheduler, where it never fires).
|
|
27
|
+
if (slash !== -1) {
|
|
28
|
+
if (!DIGITS_RE.test(step) || Number(step) < 1)
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (expr === "*")
|
|
32
|
+
continue;
|
|
33
|
+
const dash = expr.indexOf("-");
|
|
34
|
+
if (dash !== -1) {
|
|
35
|
+
const a = expr.slice(0, dash);
|
|
36
|
+
const b = expr.slice(dash + 1);
|
|
37
|
+
if (!DIGITS_RE.test(a) || !DIGITS_RE.test(b))
|
|
38
|
+
return false;
|
|
39
|
+
if (!(lo <= Number(a) && Number(a) <= Number(b) && Number(b) <= hi))
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
else if (!DIGITS_RE.test(expr) || Number(expr) < lo || Number(expr) > hi) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
/** A 5-field cron expression, evaluated in UTC by the dispatcher, checked
|
|
49
|
+
* with the backend's own grammar (`_valid_cron`) so a schedule the server
|
|
50
|
+
* would 422 is refused here, before any call — and first of all the mistake
|
|
51
|
+
* a shell makes for you: an unquoted `*` expanding to filenames, or a
|
|
52
|
+
* schedule split across arguments. Returns the whitespace-collapsed form. */
|
|
53
|
+
export function normalizeSchedule(raw) {
|
|
54
|
+
const schedule = raw.trim().replace(/\s+/g, " ");
|
|
55
|
+
const fields = schedule.split(" ");
|
|
56
|
+
if (fields.length !== 5) {
|
|
57
|
+
throw new Error(`A schedule is 5 cron fields (minute hour day-of-month month day-of-week), got ${fields.length}: "${schedule}". ` +
|
|
58
|
+
`Quote it so the shell leaves the stars alone, e.g. "*/15 * * * *".`);
|
|
59
|
+
}
|
|
60
|
+
fields.forEach((f, i) => {
|
|
61
|
+
const { name, lo, hi } = CRON_FIELDS[i];
|
|
62
|
+
if (!validCronField(f, lo, hi)) {
|
|
63
|
+
throw new Error(`"${f}" isn't a valid ${name} field in "${schedule}": use ${lo}-${hi}, with digits, *, ",", "-" and "/" only (no names like MON or JAN).`);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return schedule;
|
|
67
|
+
}
|
|
68
|
+
/** Resolve a trigger by full id or a unique id prefix (the short id the list
|
|
69
|
+
* prints). Throws a plain Error — user error, not an API fault. */
|
|
70
|
+
export function resolveTrigger(triggers, ref) {
|
|
71
|
+
const needle = ref.trim().toLowerCase();
|
|
72
|
+
if (!needle)
|
|
73
|
+
throw new Error("Give a trigger id (see `synteq function cron list`).");
|
|
74
|
+
const exact = triggers.find((t) => t.id.toLowerCase() === needle);
|
|
75
|
+
if (exact)
|
|
76
|
+
return exact;
|
|
77
|
+
const matches = triggers.filter((t) => t.id.toLowerCase().startsWith(needle));
|
|
78
|
+
if (matches.length === 1)
|
|
79
|
+
return matches[0];
|
|
80
|
+
if (matches.length === 0) {
|
|
81
|
+
// UUIDv7 ids share a long time-ordered prefix, so the list prints the
|
|
82
|
+
// TAIL of the id; accept that too.
|
|
83
|
+
const tail = triggers.filter((t) => t.id.toLowerCase().endsWith(needle));
|
|
84
|
+
if (tail.length === 1)
|
|
85
|
+
return tail[0];
|
|
86
|
+
if (tail.length > 1) {
|
|
87
|
+
throw new Error(`"${ref}" matches ${tail.length} triggers — use more of the id.`);
|
|
88
|
+
}
|
|
89
|
+
throw new Error(`No cron trigger "${ref}" on this function (see \`synteq function cron list\`).`);
|
|
90
|
+
}
|
|
91
|
+
throw new Error(`"${ref}" matches ${matches.length} triggers — use more of the id.`);
|
|
92
|
+
}
|
|
93
|
+
/** The short id the list shows. UUIDv7 puts the timestamp first, so triggers
|
|
94
|
+
* made minutes apart share their leading characters — the tail is what tells
|
|
95
|
+
* them apart. */
|
|
96
|
+
export function shortTriggerId(id) {
|
|
97
|
+
return id.slice(-8);
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=cron.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron.js","sourceRoot":"","sources":["../../src/functions-support/cron.ts"],"names":[],"mappings":"AAEA;yEACyE;AACzE,MAAM,WAAW,GAA4D;IAC3E,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;IACjC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;IAC/B,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EA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C,CAAC;QACzE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC,CAAC,CAAE,CAAC;QACvC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,IAAI,GAAG,aAAa,IAAI,CAAC,MAAM,iCAAiC,CAAC,CAAC;QACpF,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,yDAAyD,CAAC,CAAC;IACpG,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,IAAI,GAAG,aAAa,OAAO,CAAC,MAAM,iCAAiC,CAAC,CAAC;AACvF,CAAC;AAED;;kBAEkB;AAClB,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** A function env var key: what the backend accepts (`FnEnvVarSetIn.key`,
|
|
2
|
+
* 1..255 characters) minus what can't survive the CLI's KEY=VALUE form —
|
|
3
|
+
* whitespace and `=`. The ONE rule: `function env set` and
|
|
4
|
+
* `function deploy --env/--secret` (and its prompt) all check keys with it. */
|
|
5
|
+
export declare const FN_ENV_KEY_RE: RegExp;
|
|
6
|
+
/** Why `key` isn't a valid function env var name, or null when it is. */
|
|
7
|
+
export declare function envKeyProblem(key: string): string | null;
|
|
8
|
+
export type FnEnvKind = "config" | "secret";
|
|
9
|
+
/** One env var to set on a function: what `function env set` sends. */
|
|
10
|
+
export interface FnEnvAssignment {
|
|
11
|
+
key: string;
|
|
12
|
+
value: string;
|
|
13
|
+
kind: FnEnvKind;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse `KEY=VALUE` into an assignment. A leading `!` on the key marks a
|
|
17
|
+
* secret (`!API_KEY=sk-…`) — the first-run prompt's shorthand only. The
|
|
18
|
+
* scripted flags say the kind instead (`--env` config, `--secret` secret) and
|
|
19
|
+
* pass it as `kind`; a `!` there is refused rather than silently becoming
|
|
20
|
+
* part of the key. Throws a plain Error (a user error) on a malformed pair,
|
|
21
|
+
* with a message fit for a prompt validator or `this.error`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseEnvAssignment(raw: string, kind?: FnEnvKind): FnEnvAssignment;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** A function env var key: what the backend accepts (`FnEnvVarSetIn.key`,
|
|
2
|
+
* 1..255 characters) minus what can't survive the CLI's KEY=VALUE form —
|
|
3
|
+
* whitespace and `=`. The ONE rule: `function env set` and
|
|
4
|
+
* `function deploy --env/--secret` (and its prompt) all check keys with it. */
|
|
5
|
+
export const FN_ENV_KEY_RE = /^[^\s=]{1,255}$/;
|
|
6
|
+
/** Why `key` isn't a valid function env var name, or null when it is. */
|
|
7
|
+
export function envKeyProblem(key) {
|
|
8
|
+
if (!key)
|
|
9
|
+
return "Empty key. Provide KEY=VALUE.";
|
|
10
|
+
if (key.length > 255)
|
|
11
|
+
return `"${key.slice(0, 20)}…" is longer than 255 characters.`;
|
|
12
|
+
if (!FN_ENV_KEY_RE.test(key))
|
|
13
|
+
return `"${key}" isn't a valid name: no spaces or "=".`;
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse `KEY=VALUE` into an assignment. A leading `!` on the key marks a
|
|
18
|
+
* secret (`!API_KEY=sk-…`) — the first-run prompt's shorthand only. The
|
|
19
|
+
* scripted flags say the kind instead (`--env` config, `--secret` secret) and
|
|
20
|
+
* pass it as `kind`; a `!` there is refused rather than silently becoming
|
|
21
|
+
* part of the key. Throws a plain Error (a user error) on a malformed pair,
|
|
22
|
+
* with a message fit for a prompt validator or `this.error`.
|
|
23
|
+
*/
|
|
24
|
+
export function parseEnvAssignment(raw, kind) {
|
|
25
|
+
let text = raw.trimStart();
|
|
26
|
+
let resolved = kind ?? "config";
|
|
27
|
+
if (text.startsWith("!")) {
|
|
28
|
+
if (kind !== undefined) {
|
|
29
|
+
throw new Error(`"${raw.trim()}": the ! secret prefix is only for the interactive prompt — pass --secret KEY=VALUE instead.`);
|
|
30
|
+
}
|
|
31
|
+
resolved = "secret";
|
|
32
|
+
text = text.slice(1);
|
|
33
|
+
}
|
|
34
|
+
const eq = text.indexOf("=");
|
|
35
|
+
if (eq <= 0) {
|
|
36
|
+
throw new Error(`"${raw.trim()}" isn't KEY=VALUE.`);
|
|
37
|
+
}
|
|
38
|
+
const key = text.slice(0, eq).trim();
|
|
39
|
+
const problem = envKeyProblem(key);
|
|
40
|
+
if (problem)
|
|
41
|
+
throw new Error(problem);
|
|
42
|
+
return { key, value: text.slice(eq + 1), kind: resolved };
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/functions-support/env.ts"],"names":[],"mappings":"AAAA;;;gFAGgF;AAChF,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAE/C,yEAAyE;AACzE,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,IAAI,CAAC,GAAG;QAAE,OAAO,+BAA+B,CAAC;IACjD,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG;QAAE,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,mCAAmC,CAAC;IACrF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,GAAG,yCAAyC,CAAC;IACtF,OAAO,IAAI,CAAC;AACd,CAAC;AAWD;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,IAAgB;IAC9D,IAAI,IAAI,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC;IAC3B,IAAI,QAAQ,GAAc,IAAI,IAAI,QAAQ,CAAC;IAC3C,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,IAAI,GAAG,CAAC,IAAI,EAAE,8FAA8F,CAC7G,CAAC;QACJ,CAAC;QACD,QAAQ,GAAG,QAAQ,CAAC;QACpB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IACD,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Clients } from "../api/factory.js";
|
|
2
|
+
import { type AppLink } from "../config/store.js";
|
|
3
|
+
import type { Fn } from "../api/types.js";
|
|
4
|
+
/** Guidance when a command needs a function but the cwd isn't linked to one. */
|
|
5
|
+
export declare function notLinkedFunctionError(hint: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* The function a command should act on: `--name` when given, else the
|
|
8
|
+
* directory's link (which must be a FUNCTION link — an app link is refused
|
|
9
|
+
* with a pointer at `synteq …` app commands rather than silently 404ing).
|
|
10
|
+
*
|
|
11
|
+
* Returns the resolved row plus the (possibly rescoped) clients, mirroring
|
|
12
|
+
* BaseCommand.resolveLinkedApp's side effect without reaching into the
|
|
13
|
+
* command. Callers assign `this.clients = clients`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveLinkedFunction(clients: Clients, flags: {
|
|
16
|
+
name?: string;
|
|
17
|
+
team?: string;
|
|
18
|
+
insecure?: boolean;
|
|
19
|
+
}, cwd?: string): Promise<{
|
|
20
|
+
fn: Fn;
|
|
21
|
+
clients: Clients;
|
|
22
|
+
link?: AppLink;
|
|
23
|
+
}>;
|
|
24
|
+
/** Build the link record `synteq function init` writes for a directory. */
|
|
25
|
+
export declare function functionLink(fn: Fn, teamId: string, projectId: string): AppLink;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { clientsForLinkTeam } from "../apps-support/link.js";
|
|
2
|
+
import { linkKind } from "../config/store.js";
|
|
3
|
+
import { resolveFunction } from "./resolve.js";
|
|
4
|
+
/** Guidance when a command needs a function but the cwd isn't linked to one. */
|
|
5
|
+
export function notLinkedFunctionError(hint) {
|
|
6
|
+
return [
|
|
7
|
+
"No function given and this directory isn't linked to one.",
|
|
8
|
+
`Run \`synteq function init <name>\` here for a one-time setup, or pass ${hint}.`,
|
|
9
|
+
].join("\n");
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The function a command should act on: `--name` when given, else the
|
|
13
|
+
* directory's link (which must be a FUNCTION link — an app link is refused
|
|
14
|
+
* with a pointer at `synteq …` app commands rather than silently 404ing).
|
|
15
|
+
*
|
|
16
|
+
* Returns the resolved row plus the (possibly rescoped) clients, mirroring
|
|
17
|
+
* BaseCommand.resolveLinkedApp's side effect without reaching into the
|
|
18
|
+
* command. Callers assign `this.clients = clients`.
|
|
19
|
+
*/
|
|
20
|
+
export async function resolveLinkedFunction(clients, flags, cwd = process.cwd()) {
|
|
21
|
+
let ref = flags.name;
|
|
22
|
+
let projectId;
|
|
23
|
+
let link;
|
|
24
|
+
let scoped = clients;
|
|
25
|
+
if (!ref) {
|
|
26
|
+
link = clients.config.linkFor(cwd);
|
|
27
|
+
if (!link)
|
|
28
|
+
throw new Error(notLinkedFunctionError("--name <slug>"));
|
|
29
|
+
if (linkKind(link) !== "function") {
|
|
30
|
+
throw new Error(`This directory is linked to the app "${link.app_slug}", not a function. ` +
|
|
31
|
+
"Use `synteq deploy` / `synteq app …` here, or pass --name <slug>.");
|
|
32
|
+
}
|
|
33
|
+
ref = link.app_id;
|
|
34
|
+
projectId = link.project_id;
|
|
35
|
+
scoped = clientsForLinkTeam(clients, link, flags);
|
|
36
|
+
}
|
|
37
|
+
const fn = await resolveFunction(scoped.api, ref, projectId);
|
|
38
|
+
return { fn, clients: scoped, link };
|
|
39
|
+
}
|
|
40
|
+
/** Build the link record `synteq function init` writes for a directory. */
|
|
41
|
+
export function functionLink(fn, teamId, projectId) {
|
|
42
|
+
return {
|
|
43
|
+
kind: "function",
|
|
44
|
+
team_id: teamId,
|
|
45
|
+
project_id: projectId,
|
|
46
|
+
app_id: fn.id,
|
|
47
|
+
app_slug: fn.slug,
|
|
48
|
+
linked_at: new Date().toISOString(),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../src/functions-support/link.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAgB,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,gFAAgF;AAChF,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,OAAO;QACL,2DAA2D;QAC3D,0EAA0E,IAAI,GAAG;KAClF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAgB,EAChB,KAA2D,EAC3D,GAAG,GAAG,OAAO,CAA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api/client.js";
|
|
2
|
+
import type { FnBuild, FnRelease } from "../api/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Follow a function deploy to its end. Two phases, because the backend
|
|
5
|
+
* splits them: the BUILD row reaches succeeded/failed, then the status cron
|
|
6
|
+
* mints a RELEASE and flips it current once the orchestrator reports Live.
|
|
7
|
+
*
|
|
8
|
+
* CONTRACT:
|
|
9
|
+
* - `waitForBuild` polls GET /functions/{id}/builds/{buildId} every
|
|
10
|
+
* `intervalMs` (min 2000) until status ∈ {succeeded, failed} or
|
|
11
|
+
* `timeoutMs` elapses (→ throws DeployTimeoutError). `onStatus` fires
|
|
12
|
+
* once per status CHANGE (never per poll) so the command can print
|
|
13
|
+
* transitions without spam.
|
|
14
|
+
* - `waitForRelease` polls GET /functions/{id}/releases until a release
|
|
15
|
+
* whose buildId === build.id exists AND isCurrent, or one exists with a
|
|
16
|
+
* failed-looking status (→ returns it; the command decides), or timeout.
|
|
17
|
+
* - Both honour an AbortSignal for Ctrl-C.
|
|
18
|
+
*/
|
|
19
|
+
export declare const BUILD_TERMINAL: Set<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Release statuses that end the wait WITHOUT the release ever going current.
|
|
22
|
+
* `waitForRelease` RETURNS these rather than throwing — the command reports
|
|
23
|
+
* the outcome (and, for `failed`/`*_failed`, points at the build logs).
|
|
24
|
+
*/
|
|
25
|
+
export declare const RELEASE_TERMINAL_BAD: Set<string>;
|
|
26
|
+
/** Floor on the poll interval, so a caller can't hammer the API. */
|
|
27
|
+
export declare const MIN_INTERVAL_MS = 2000;
|
|
28
|
+
export declare class DeployTimeoutError extends Error {
|
|
29
|
+
constructor(phase: "build" | "release", after: number);
|
|
30
|
+
}
|
|
31
|
+
export interface PollOpts {
|
|
32
|
+
intervalMs?: number;
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
onStatus?: (status: string, build: FnBuild) => void;
|
|
36
|
+
}
|
|
37
|
+
export declare function waitForBuild(api: ApiClient, fnId: string, buildId: string, opts?: PollOpts): Promise<FnBuild>;
|
|
38
|
+
export declare function waitForRelease(api: ApiClient, fnId: string, buildId: string, opts?: Omit<PollOpts, "onStatus"> & {
|
|
39
|
+
onStatus?: (status: string, rel: FnRelease) => void;
|
|
40
|
+
}): Promise<FnRelease>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Follow a function deploy to its end. Two phases, because the backend
|
|
3
|
+
* splits them: the BUILD row reaches succeeded/failed, then the status cron
|
|
4
|
+
* mints a RELEASE and flips it current once the orchestrator reports Live.
|
|
5
|
+
*
|
|
6
|
+
* CONTRACT:
|
|
7
|
+
* - `waitForBuild` polls GET /functions/{id}/builds/{buildId} every
|
|
8
|
+
* `intervalMs` (min 2000) until status ∈ {succeeded, failed} or
|
|
9
|
+
* `timeoutMs` elapses (→ throws DeployTimeoutError). `onStatus` fires
|
|
10
|
+
* once per status CHANGE (never per poll) so the command can print
|
|
11
|
+
* transitions without spam.
|
|
12
|
+
* - `waitForRelease` polls GET /functions/{id}/releases until a release
|
|
13
|
+
* whose buildId === build.id exists AND isCurrent, or one exists with a
|
|
14
|
+
* failed-looking status (→ returns it; the command decides), or timeout.
|
|
15
|
+
* - Both honour an AbortSignal for Ctrl-C.
|
|
16
|
+
*/
|
|
17
|
+
export const BUILD_TERMINAL = new Set(["succeeded", "failed"]);
|
|
18
|
+
/**
|
|
19
|
+
* Release statuses that end the wait WITHOUT the release ever going current.
|
|
20
|
+
* `waitForRelease` RETURNS these rather than throwing — the command reports
|
|
21
|
+
* the outcome (and, for `failed`/`*_failed`, points at the build logs).
|
|
22
|
+
*/
|
|
23
|
+
export const RELEASE_TERMINAL_BAD = new Set([
|
|
24
|
+
"failed",
|
|
25
|
+
"health_failed",
|
|
26
|
+
"start_failed",
|
|
27
|
+
"superseded",
|
|
28
|
+
]);
|
|
29
|
+
/** Floor on the poll interval, so a caller can't hammer the API. */
|
|
30
|
+
export const MIN_INTERVAL_MS = 2000;
|
|
31
|
+
const DEFAULT_INTERVAL_MS = 3000;
|
|
32
|
+
const DEFAULT_TIMEOUT_MS = 600_000;
|
|
33
|
+
export class DeployTimeoutError extends Error {
|
|
34
|
+
constructor(phase, after) {
|
|
35
|
+
super(`Timed out after ${Math.round(after / 1000)}s waiting for the ${phase}.`);
|
|
36
|
+
this.name = "DeployTimeoutError";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** The reason an aborted wait rejects with — the signal's, or a plain Error. */
|
|
40
|
+
function abortReason(signal) {
|
|
41
|
+
return signal.reason ?? new Error("aborted");
|
|
42
|
+
}
|
|
43
|
+
/** Sleep `ms`, rejecting early (and clearing the timer) if `signal` aborts. */
|
|
44
|
+
function sleep(ms, signal) {
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
if (signal?.aborted) {
|
|
47
|
+
reject(abortReason(signal));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const timer = setTimeout(() => {
|
|
51
|
+
signal?.removeEventListener("abort", onAbort);
|
|
52
|
+
resolve();
|
|
53
|
+
}, ms);
|
|
54
|
+
const onAbort = () => {
|
|
55
|
+
clearTimeout(timer);
|
|
56
|
+
reject(abortReason(signal));
|
|
57
|
+
};
|
|
58
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export async function waitForBuild(api, fnId, buildId, opts = {}) {
|
|
62
|
+
const interval = Math.max(MIN_INTERVAL_MS, opts.intervalMs ?? DEFAULT_INTERVAL_MS);
|
|
63
|
+
const timeout = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
64
|
+
const started = Date.now();
|
|
65
|
+
let last;
|
|
66
|
+
for (;;) {
|
|
67
|
+
if (opts.signal?.aborted)
|
|
68
|
+
throw abortReason(opts.signal);
|
|
69
|
+
const build = await api.functions.build(fnId, buildId);
|
|
70
|
+
if (build.status !== last) {
|
|
71
|
+
last = build.status;
|
|
72
|
+
opts.onStatus?.(build.status, build);
|
|
73
|
+
}
|
|
74
|
+
if (BUILD_TERMINAL.has(build.status))
|
|
75
|
+
return build;
|
|
76
|
+
const elapsed = Date.now() - started;
|
|
77
|
+
if (elapsed >= timeout)
|
|
78
|
+
throw new DeployTimeoutError("build", elapsed);
|
|
79
|
+
await sleep(interval, opts.signal);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export async function waitForRelease(api, fnId, buildId, opts = {}) {
|
|
83
|
+
const interval = Math.max(MIN_INTERVAL_MS, opts.intervalMs ?? DEFAULT_INTERVAL_MS);
|
|
84
|
+
const timeout = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
85
|
+
const started = Date.now();
|
|
86
|
+
let last;
|
|
87
|
+
for (;;) {
|
|
88
|
+
if (opts.signal?.aborted)
|
|
89
|
+
throw abortReason(opts.signal);
|
|
90
|
+
const releases = await api.functions.releases(fnId);
|
|
91
|
+
const mine = releases.filter((r) => r.buildId === buildId);
|
|
92
|
+
// Newest first, so a rebuild that minted two rows reports the latest.
|
|
93
|
+
mine.sort((a, b) => b.number - a.number);
|
|
94
|
+
const current = mine.find((r) => r.isCurrent);
|
|
95
|
+
const bad = mine.find((r) => RELEASE_TERMINAL_BAD.has(r.status));
|
|
96
|
+
const decided = current ?? bad;
|
|
97
|
+
if (mine.length > 0 && mine[0].status !== last) {
|
|
98
|
+
last = mine[0].status;
|
|
99
|
+
opts.onStatus?.(mine[0].status, mine[0]);
|
|
100
|
+
}
|
|
101
|
+
if (decided)
|
|
102
|
+
return decided;
|
|
103
|
+
const elapsed = Date.now() - started;
|
|
104
|
+
if (elapsed >= timeout)
|
|
105
|
+
throw new DeployTimeoutError("release", elapsed);
|
|
106
|
+
await sleep(interval, opts.signal);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=poll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poll.js","sourceRoot":"","sources":["../../src/functions-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AAM,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YAC/C,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACtB,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,OAAO;YAAE,OAAO,OAAO,CAAC;QAE5B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;QACrC,IAAI,OAAO,IAAI,OAAO;YAAE,MAAM,IAAI,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAEzE,MAAM,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { pageThrough } from "../api/client.js";
|
|
2
|
+
import { idPrefixMatches, isIdPrefix } from "../apps-support/resolve.js";
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a function reference (slug OR uuid) to a full Fn row — the
|
|
5
|
+
* functions twin of apps-support/resolve.ts. A uuid goes straight to
|
|
6
|
+
* GET /functions/{id}; anything else is a slug asked of the server with
|
|
7
|
+
* `q=<slug>` (name / slug / hostname search, portal #419) and exact-matched
|
|
8
|
+
* here. An id prefix is not something `q` searches, so that walks every
|
|
9
|
+
* page of the project's list.
|
|
10
|
+
*
|
|
11
|
+
* Throws a plain Error (a user error the command surfaces as exit 1); an
|
|
12
|
+
* API fault is an ApiError and propagates to `this.fail`.
|
|
13
|
+
*/
|
|
14
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
15
|
+
export async function resolveFunction(api, ref, projectId) {
|
|
16
|
+
if (UUID_RE.test(ref))
|
|
17
|
+
return api.functions.get(ref);
|
|
18
|
+
const bySlug = await pageThrough((page) => api.functions.listPage(projectId, { q: ref, page }), (page) => page.items.some((f) => f.slug === ref));
|
|
19
|
+
let matches = bySlug.filter((f) => f.slug === ref);
|
|
20
|
+
if (matches.length === 0 && isIdPrefix(ref)) {
|
|
21
|
+
const all = await pageThrough((page) => api.functions.listPage(projectId, { page }));
|
|
22
|
+
matches = idPrefixMatches(all, ref, "function");
|
|
23
|
+
}
|
|
24
|
+
if (matches.length === 0) {
|
|
25
|
+
throw new Error(`No function named "${ref}" in the active project. Run \`synteq function list\` to see available functions.`);
|
|
26
|
+
}
|
|
27
|
+
if (matches.length > 1)
|
|
28
|
+
matches.sort((a, b) => b.id.localeCompare(a.id));
|
|
29
|
+
return matches[0];
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/functions-support/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAEzE;;;;;;;;;;GAUG;AACH,MAAM,OAAO,GAAG,iEAAiE,CAAC;AAElF,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAc,EAAE,GAAW,EAAE,SAAkB;IACnF,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,MAAM,WAAW,CAC9B,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAC7D,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CACjD,CAAC;IACF,IAAI,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;IACnD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5C,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACrF,OAAO,GAAG,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,sBAAsB,GAAG,mFAAmF,CAC7G,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACzE,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime knowledge the CLI needs offline: which handler filenames belong to
|
|
3
|
+
* which runtime, and the starter each `synteq function init` scaffolds.
|
|
4
|
+
*
|
|
5
|
+
* HANDLER_ENTRIES mirrors the BACKEND's table verbatim
|
|
6
|
+
* (portal/backend/app/services/functions/source_shape.py::HANDLER_ENTRIES),
|
|
7
|
+
* in the same order, so what the CLI infers from a directory is what the
|
|
8
|
+
* build's shaping step will conclude from the same files. The two sets are
|
|
9
|
+
* disjoint by extension, which is what makes inference sound.
|
|
10
|
+
*/
|
|
11
|
+
export declare const RUNTIMES: readonly ["node22", "python312"];
|
|
12
|
+
export type Runtime = (typeof RUNTIMES)[number];
|
|
13
|
+
export declare const RUNTIME_LABELS: Record<Runtime, string>;
|
|
14
|
+
export declare const HANDLER_ENTRIES: Record<Runtime, readonly string[]>;
|
|
15
|
+
/**
|
|
16
|
+
* The runtime a set of ROOT-relative paths is written against, or null when
|
|
17
|
+
* they do not say: no recognised entry, a Dockerfile (that build path never
|
|
18
|
+
* consults the runtime), or entries for both runtimes at once.
|
|
19
|
+
*/
|
|
20
|
+
export declare function inferRuntime(paths: string[]): Runtime | null;
|
|
21
|
+
/** The first entry filename per runtime — what `init` writes. */
|
|
22
|
+
export declare function entryFor(runtime: Runtime): string;
|
|
23
|
+
/**
|
|
24
|
+
* Starter handlers. The node one is byte-identical to the portal editor's
|
|
25
|
+
* seed (frontend/lib/functions/files.ts STARTER) so a function scaffolded
|
|
26
|
+
* from the terminal and one pasted in the browser start from the same file.
|
|
27
|
+
* Both are HANDLERS, not servers: the platform's shim owns the listener and
|
|
28
|
+
* imports this file expecting a default export (node) or `handler` (python).
|
|
29
|
+
*/
|
|
30
|
+
export declare const STARTERS: Record<Runtime, string>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime knowledge the CLI needs offline: which handler filenames belong to
|
|
3
|
+
* which runtime, and the starter each `synteq function init` scaffolds.
|
|
4
|
+
*
|
|
5
|
+
* HANDLER_ENTRIES mirrors the BACKEND's table verbatim
|
|
6
|
+
* (portal/backend/app/services/functions/source_shape.py::HANDLER_ENTRIES),
|
|
7
|
+
* in the same order, so what the CLI infers from a directory is what the
|
|
8
|
+
* build's shaping step will conclude from the same files. The two sets are
|
|
9
|
+
* disjoint by extension, which is what makes inference sound.
|
|
10
|
+
*/
|
|
11
|
+
export const RUNTIMES = ["node22", "python312"];
|
|
12
|
+
export const RUNTIME_LABELS = {
|
|
13
|
+
node22: "Node.js 22",
|
|
14
|
+
python312: "Python 3.12",
|
|
15
|
+
};
|
|
16
|
+
export const HANDLER_ENTRIES = {
|
|
17
|
+
node22: ["index.mjs", "index.js", "handler.mjs", "handler.js", "main.mjs", "main.js"],
|
|
18
|
+
python312: ["handler.py", "main.py", "index.py", "app.py"],
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The runtime a set of ROOT-relative paths is written against, or null when
|
|
22
|
+
* they do not say: no recognised entry, a Dockerfile (that build path never
|
|
23
|
+
* consults the runtime), or entries for both runtimes at once.
|
|
24
|
+
*/
|
|
25
|
+
export function inferRuntime(paths) {
|
|
26
|
+
const names = new Set(paths.map((p) => p.replace(/^\.\//, "").trim()).filter(Boolean));
|
|
27
|
+
if (names.has("Dockerfile"))
|
|
28
|
+
return null;
|
|
29
|
+
const hits = RUNTIMES.filter((rt) => HANDLER_ENTRIES[rt].some((e) => names.has(e)));
|
|
30
|
+
return hits.length === 1 ? hits[0] : null;
|
|
31
|
+
}
|
|
32
|
+
/** The first entry filename per runtime — what `init` writes. */
|
|
33
|
+
export function entryFor(runtime) {
|
|
34
|
+
return HANDLER_ENTRIES[runtime][0];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Starter handlers. The node one is byte-identical to the portal editor's
|
|
38
|
+
* seed (frontend/lib/functions/files.ts STARTER) so a function scaffolded
|
|
39
|
+
* from the terminal and one pasted in the browser start from the same file.
|
|
40
|
+
* Both are HANDLERS, not servers: the platform's shim owns the listener and
|
|
41
|
+
* imports this file expecting a default export (node) or `handler` (python).
|
|
42
|
+
*/
|
|
43
|
+
export const STARTERS = {
|
|
44
|
+
node22: `export default async function handler(event, context) {
|
|
45
|
+
return { hello: "world", path: event.path };
|
|
46
|
+
}
|
|
47
|
+
`,
|
|
48
|
+
python312: `def handler(event, context):
|
|
49
|
+
return {"hello": "world", "path": event["path"]}
|
|
50
|
+
`,
|
|
51
|
+
};
|
|
52
|
+
//#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AAU,QAAQ,CAAC,OAAgB;IACvC,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA4B;IAC/C,MAAM,EAAE;;;CAGT;IACC,SAAS,EAAE;;CAEZ;CACA,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { FnSourceFile } from "../api/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Collect a directory into the `files` shape POST /functions/{id}/deploys/source
|
|
4
|
+
* takes: plain UTF-8 text files, root-relative slash paths, sorted.
|
|
5
|
+
*
|
|
6
|
+
* CONTRACT (the deploy command depends on every line of this):
|
|
7
|
+
* - Walks `dir` recursively. Skips, at any depth: node_modules, .git,
|
|
8
|
+
* .synteq (reserved for the platform shim — the backend refuses it),
|
|
9
|
+
* __pycache__, .venv, venv, dist, build, target, .DS_Store, *.log,
|
|
10
|
+
* dotenv files (`.env`, `.env.*` except `.env.example` / `.env.sample` /
|
|
11
|
+
* `.env.template`; reason "dotenv", no opt-in), and anything matched by
|
|
12
|
+
* a `.synteqignore` in `dir` (gitignore-style globs, one per line, `#`
|
|
13
|
+
* comments) when one exists.
|
|
14
|
+
* - Skips binary files (a NUL byte in the first 8 KiB) and any single file
|
|
15
|
+
* larger than the whole source cap — each skip is reported in `skipped`
|
|
16
|
+
* with a reason so the command can print them, never silently dropped.
|
|
17
|
+
* - Refuses paths longer than 255 chars or containing `..` (backend limits).
|
|
18
|
+
* - Enforces `maxFiles` on the number of collected files (the backend's
|
|
19
|
+
* bundle member ceiling, `Fn.maxSourceFiles`; MAX_SOURCE_FILES without
|
|
20
|
+
* one). Over it throws SourceTooManyFilesError naming the limit.
|
|
21
|
+
* - Enforces `maxTotalBytes` on the sum of UTF-8 content. The caller passes
|
|
22
|
+
* the backend's LIVE cap (`Fn.maxSourceBytes`, admin-editable); without
|
|
23
|
+
* one, MAX_TOTAL_BYTES is the backend's own default. Over it throws
|
|
24
|
+
* SourceTooLargeError naming the total and the largest offenders so the
|
|
25
|
+
* user knows what to exclude.
|
|
26
|
+
* - Never follows symlinks.
|
|
27
|
+
* - Returns files sorted by path so a re-run of an unchanged tree produces
|
|
28
|
+
* an identical payload.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Fallback source ceiling, used only when the API row carries no
|
|
32
|
+
* `maxSourceBytes` (an older backend). Mirrors the backend's
|
|
33
|
+
* `DEFAULT_MAX_FUNCTION_SOURCE_MB` (5 MB); the live number is what an admin
|
|
34
|
+
* set in portal settings and rides on every GET /functions row.
|
|
35
|
+
*/
|
|
36
|
+
export declare const MAX_TOTAL_BYTES = 5000000;
|
|
37
|
+
/**
|
|
38
|
+
* Fallback file-count ceiling, used only when the API row carries no
|
|
39
|
+
* `maxSourceFiles` (an older backend). Mirrors the backend's
|
|
40
|
+
* `source_shape.MAX_TARBALL_MEMBERS`.
|
|
41
|
+
*/
|
|
42
|
+
export declare const MAX_SOURCE_FILES = 4096;
|
|
43
|
+
/**
|
|
44
|
+
* The editor's inline `files` shape takes at most this many files
|
|
45
|
+
* (`functions_deploys._MAX_SOURCE_FILES`). A tree that fits is sent that way
|
|
46
|
+
* so the deployed source stays re-openable in the portal editor; a larger one
|
|
47
|
+
* goes up as a tarball (`sourceB64`), which only the caps above bound.
|
|
48
|
+
*/
|
|
49
|
+
export declare const EDITOR_MAX_FILES = 32;
|
|
50
|
+
export interface CollectOptions {
|
|
51
|
+
/** The backend's source cap for this function, in bytes. */
|
|
52
|
+
maxTotalBytes?: number;
|
|
53
|
+
/** The backend's file-count cap for this function. */
|
|
54
|
+
maxFiles?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface SkippedFile {
|
|
57
|
+
path: string;
|
|
58
|
+
reason: "binary" | "too-large" | "ignored" | "dotenv" | "symlink" | "bad-path";
|
|
59
|
+
}
|
|
60
|
+
export interface CollectedSource {
|
|
61
|
+
files: FnSourceFile[];
|
|
62
|
+
skipped: SkippedFile[];
|
|
63
|
+
totalBytes: number;
|
|
64
|
+
}
|
|
65
|
+
export declare class SourceTooLargeError extends Error {
|
|
66
|
+
readonly totalBytes: number;
|
|
67
|
+
readonly largest: {
|
|
68
|
+
path: string;
|
|
69
|
+
bytes: number;
|
|
70
|
+
}[];
|
|
71
|
+
readonly limitBytes: number;
|
|
72
|
+
constructor(totalBytes: number, largest: {
|
|
73
|
+
path: string;
|
|
74
|
+
bytes: number;
|
|
75
|
+
}[], limitBytes?: number);
|
|
76
|
+
}
|
|
77
|
+
export declare class SourceTooManyFilesError extends Error {
|
|
78
|
+
readonly fileCount: number;
|
|
79
|
+
readonly limitFiles: number;
|
|
80
|
+
constructor(fileCount: number, limitFiles?: number);
|
|
81
|
+
}
|
|
82
|
+
interface IgnoreRule {
|
|
83
|
+
re: RegExp;
|
|
84
|
+
/** Trailing "/" — only matches directories. */
|
|
85
|
+
dirOnly: boolean;
|
|
86
|
+
/** Leading "/" or an interior "/" — matched against the full root-relative path. */
|
|
87
|
+
anchored: boolean;
|
|
88
|
+
}
|
|
89
|
+
export declare function parseIgnoreFile(text: string): IgnoreRule[];
|
|
90
|
+
export declare function collectSourceFiles(dir: string, opts?: CollectOptions): Promise<CollectedSource>;
|
|
91
|
+
export declare function tarballFromFiles(files: FnSourceFile[]): Buffer;
|
|
92
|
+
export {};
|