@miosa/cli 1.3.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -835
- package/bin/miosa.js +75 -0
- package/lib/archive.js +88 -0
- package/lib/checksums.js +29 -0
- package/lib/platforms.js +31 -0
- package/lib/resolve.js +47 -0
- package/package.json +26 -41
- package/scripts/postinstall.js +68 -0
- package/CHANGELOG.md +0 -110
- package/dist/action-authority.d.ts +0 -106
- package/dist/action-authority.d.ts.map +0 -1
- package/dist/action-authority.js +0 -116
- package/dist/action-authority.js.map +0 -1
- package/dist/app-advisor.d.ts +0 -80
- package/dist/app-advisor.d.ts.map +0 -1
- package/dist/app-advisor.js +0 -486
- package/dist/app-advisor.js.map +0 -1
- package/dist/app-contract.d.ts +0 -92
- package/dist/app-contract.d.ts.map +0 -1
- package/dist/app-contract.js +0 -218
- package/dist/app-contract.js.map +0 -1
- package/dist/app-document.d.ts +0 -23
- package/dist/app-document.d.ts.map +0 -1
- package/dist/app-document.js +0 -180
- package/dist/app-document.js.map +0 -1
- package/dist/app-manifest.d.ts +0 -140
- package/dist/app-manifest.d.ts.map +0 -1
- package/dist/app-manifest.js +0 -377
- package/dist/app-manifest.js.map +0 -1
- package/dist/app-operation.d.ts +0 -23
- package/dist/app-operation.d.ts.map +0 -1
- package/dist/app-operation.js +0 -49
- package/dist/app-operation.js.map +0 -1
- package/dist/app-release.d.ts +0 -132
- package/dist/app-release.d.ts.map +0 -1
- package/dist/app-release.js +0 -294
- package/dist/app-release.js.map +0 -1
- package/dist/bin/miosa.d.ts +0 -3
- package/dist/bin/miosa.d.ts.map +0 -1
- package/dist/bin/miosa.js +0 -288
- package/dist/bin/miosa.js.map +0 -1
- package/dist/cli-env.d.ts +0 -12
- package/dist/cli-env.d.ts.map +0 -1
- package/dist/cli-env.js +0 -34
- package/dist/cli-env.js.map +0 -1
- package/dist/client.d.ts +0 -155
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -865
- package/dist/client.js.map +0 -1
- package/dist/commands/actions.d.ts +0 -3
- package/dist/commands/actions.d.ts.map +0 -1
- package/dist/commands/actions.js +0 -222
- package/dist/commands/actions.js.map +0 -1
- package/dist/commands/agent-runtime-profiles.d.ts +0 -3
- package/dist/commands/agent-runtime-profiles.d.ts.map +0 -1
- package/dist/commands/agent-runtime-profiles.js +0 -198
- package/dist/commands/agent-runtime-profiles.js.map +0 -1
- package/dist/commands/agent.d.ts +0 -18
- package/dist/commands/agent.d.ts.map +0 -1
- package/dist/commands/agent.js +0 -737
- package/dist/commands/agent.js.map +0 -1
- package/dist/commands/alerts.d.ts +0 -3
- package/dist/commands/alerts.d.ts.map +0 -1
- package/dist/commands/alerts.js +0 -41
- package/dist/commands/alerts.js.map +0 -1
- package/dist/commands/api-keys.d.ts +0 -3
- package/dist/commands/api-keys.d.ts.map +0 -1
- package/dist/commands/api-keys.js +0 -160
- package/dist/commands/api-keys.js.map +0 -1
- package/dist/commands/api-resource.d.ts +0 -20
- package/dist/commands/api-resource.d.ts.map +0 -1
- package/dist/commands/api-resource.js +0 -120
- package/dist/commands/api-resource.js.map +0 -1
- package/dist/commands/app.d.ts +0 -38
- package/dist/commands/app.d.ts.map +0 -1
- package/dist/commands/app.js +0 -1182
- package/dist/commands/app.js.map +0 -1
- package/dist/commands/apps.d.ts +0 -3
- package/dist/commands/apps.d.ts.map +0 -1
- package/dist/commands/apps.js +0 -218
- package/dist/commands/apps.js.map +0 -1
- package/dist/commands/audit.d.ts +0 -3
- package/dist/commands/audit.d.ts.map +0 -1
- package/dist/commands/audit.js +0 -25
- package/dist/commands/audit.js.map +0 -1
- package/dist/commands/auth.d.ts +0 -3
- package/dist/commands/auth.d.ts.map +0 -1
- package/dist/commands/auth.js +0 -282
- package/dist/commands/auth.js.map +0 -1
- package/dist/commands/backups.d.ts +0 -3
- package/dist/commands/backups.d.ts.map +0 -1
- package/dist/commands/backups.js +0 -23
- package/dist/commands/backups.js.map +0 -1
- package/dist/commands/billing.d.ts +0 -3
- package/dist/commands/billing.d.ts.map +0 -1
- package/dist/commands/billing.js +0 -208
- package/dist/commands/billing.js.map +0 -1
- package/dist/commands/builds.d.ts +0 -3
- package/dist/commands/builds.d.ts.map +0 -1
- package/dist/commands/builds.js +0 -198
- package/dist/commands/builds.js.map +0 -1
- package/dist/commands/capabilities.d.ts +0 -3
- package/dist/commands/capabilities.d.ts.map +0 -1
- package/dist/commands/capabilities.js +0 -1002
- package/dist/commands/capabilities.js.map +0 -1
- package/dist/commands/checkpoints.d.ts +0 -3
- package/dist/commands/checkpoints.d.ts.map +0 -1
- package/dist/commands/checkpoints.js +0 -193
- package/dist/commands/checkpoints.js.map +0 -1
- package/dist/commands/cleanup.d.ts +0 -3
- package/dist/commands/cleanup.d.ts.map +0 -1
- package/dist/commands/cleanup.js +0 -65
- package/dist/commands/cleanup.js.map +0 -1
- package/dist/commands/cloud.d.ts +0 -3
- package/dist/commands/cloud.d.ts.map +0 -1
- package/dist/commands/cloud.js +0 -192
- package/dist/commands/cloud.js.map +0 -1
- package/dist/commands/command-overview.d.ts +0 -13
- package/dist/commands/command-overview.d.ts.map +0 -1
- package/dist/commands/command-overview.js +0 -50
- package/dist/commands/command-overview.js.map +0 -1
- package/dist/commands/completion.d.ts +0 -3
- package/dist/commands/completion.d.ts.map +0 -1
- package/dist/commands/completion.js +0 -183
- package/dist/commands/completion.js.map +0 -1
- package/dist/commands/computers.d.ts +0 -3
- package/dist/commands/computers.d.ts.map +0 -1
- package/dist/commands/computers.js +0 -706
- package/dist/commands/computers.js.map +0 -1
- package/dist/commands/config.d.ts +0 -3
- package/dist/commands/config.d.ts.map +0 -1
- package/dist/commands/config.js +0 -114
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/connect.d.ts +0 -6
- package/dist/commands/connect.d.ts.map +0 -1
- package/dist/commands/connect.js +0 -127
- package/dist/commands/connect.js.map +0 -1
- package/dist/commands/connectors.d.ts +0 -3
- package/dist/commands/connectors.d.ts.map +0 -1
- package/dist/commands/connectors.js +0 -172
- package/dist/commands/connectors.js.map +0 -1
- package/dist/commands/containers.d.ts +0 -3
- package/dist/commands/containers.d.ts.map +0 -1
- package/dist/commands/containers.js +0 -20
- package/dist/commands/containers.js.map +0 -1
- package/dist/commands/context.d.ts +0 -3
- package/dist/commands/context.d.ts.map +0 -1
- package/dist/commands/context.js +0 -233
- package/dist/commands/context.js.map +0 -1
- package/dist/commands/cp.d.ts +0 -3
- package/dist/commands/cp.d.ts.map +0 -1
- package/dist/commands/cp.js +0 -319
- package/dist/commands/cp.js.map +0 -1
- package/dist/commands/cron.d.ts +0 -3
- package/dist/commands/cron.d.ts.map +0 -1
- package/dist/commands/cron.js +0 -65
- package/dist/commands/cron.js.map +0 -1
- package/dist/commands/dashboard.d.ts +0 -13
- package/dist/commands/dashboard.d.ts.map +0 -1
- package/dist/commands/dashboard.js +0 -54
- package/dist/commands/dashboard.js.map +0 -1
- package/dist/commands/databases.d.ts +0 -3
- package/dist/commands/databases.d.ts.map +0 -1
- package/dist/commands/databases.js +0 -714
- package/dist/commands/databases.js.map +0 -1
- package/dist/commands/db.d.ts +0 -3
- package/dist/commands/db.d.ts.map +0 -1
- package/dist/commands/db.js +0 -385
- package/dist/commands/db.js.map +0 -1
- package/dist/commands/deploy.d.ts +0 -3
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js +0 -1234
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/desktop.d.ts +0 -3
- package/dist/commands/desktop.d.ts.map +0 -1
- package/dist/commands/desktop.js +0 -277
- package/dist/commands/desktop.js.map +0 -1
- package/dist/commands/dev.d.ts +0 -3
- package/dist/commands/dev.d.ts.map +0 -1
- package/dist/commands/dev.js +0 -245
- package/dist/commands/dev.js.map +0 -1
- package/dist/commands/devices.d.ts +0 -3
- package/dist/commands/devices.d.ts.map +0 -1
- package/dist/commands/devices.js +0 -279
- package/dist/commands/devices.js.map +0 -1
- package/dist/commands/docker-deploy.d.ts +0 -3
- package/dist/commands/docker-deploy.d.ts.map +0 -1
- package/dist/commands/docker-deploy.js +0 -659
- package/dist/commands/docker-deploy.js.map +0 -1
- package/dist/commands/doctor.d.ts +0 -69
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -596
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/domains.d.ts +0 -3
- package/dist/commands/domains.d.ts.map +0 -1
- package/dist/commands/domains.js +0 -307
- package/dist/commands/domains.js.map +0 -1
- package/dist/commands/enterprise-util.d.ts +0 -39
- package/dist/commands/enterprise-util.d.ts.map +0 -1
- package/dist/commands/enterprise-util.js +0 -217
- package/dist/commands/enterprise-util.js.map +0 -1
- package/dist/commands/env-input.d.ts +0 -26
- package/dist/commands/env-input.d.ts.map +0 -1
- package/dist/commands/env-input.js +0 -68
- package/dist/commands/env-input.js.map +0 -1
- package/dist/commands/env.d.ts +0 -3
- package/dist/commands/env.d.ts.map +0 -1
- package/dist/commands/env.js +0 -189
- package/dist/commands/env.js.map +0 -1
- package/dist/commands/exec.d.ts +0 -3
- package/dist/commands/exec.d.ts.map +0 -1
- package/dist/commands/exec.js +0 -110
- package/dist/commands/exec.js.map +0 -1
- package/dist/commands/forge.d.ts +0 -3
- package/dist/commands/forge.d.ts.map +0 -1
- package/dist/commands/forge.js +0 -254
- package/dist/commands/forge.js.map +0 -1
- package/dist/commands/functions.d.ts +0 -3
- package/dist/commands/functions.d.ts.map +0 -1
- package/dist/commands/functions.js +0 -47
- package/dist/commands/functions.js.map +0 -1
- package/dist/commands/gha-runners.d.ts +0 -3
- package/dist/commands/gha-runners.d.ts.map +0 -1
- package/dist/commands/gha-runners.js +0 -33
- package/dist/commands/gha-runners.js.map +0 -1
- package/dist/commands/groups.d.ts +0 -3
- package/dist/commands/groups.d.ts.map +0 -1
- package/dist/commands/groups.js +0 -38
- package/dist/commands/groups.js.map +0 -1
- package/dist/commands/host.d.ts +0 -3
- package/dist/commands/host.d.ts.map +0 -1
- package/dist/commands/host.js +0 -74
- package/dist/commands/host.js.map +0 -1
- package/dist/commands/hosts.d.ts +0 -7
- package/dist/commands/hosts.d.ts.map +0 -1
- package/dist/commands/hosts.js +0 -91
- package/dist/commands/hosts.js.map +0 -1
- package/dist/commands/link.d.ts +0 -8
- package/dist/commands/link.d.ts.map +0 -1
- package/dist/commands/link.js +0 -124
- package/dist/commands/link.js.map +0 -1
- package/dist/commands/login.d.ts +0 -10
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js +0 -263
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts +0 -3
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js +0 -43
- package/dist/commands/logout.js.map +0 -1
- package/dist/commands/logs.d.ts +0 -3
- package/dist/commands/logs.d.ts.map +0 -1
- package/dist/commands/logs.js +0 -401
- package/dist/commands/logs.js.map +0 -1
- package/dist/commands/ls.d.ts +0 -3
- package/dist/commands/ls.d.ts.map +0 -1
- package/dist/commands/ls.js +0 -121
- package/dist/commands/ls.js.map +0 -1
- package/dist/commands/mcp.d.ts +0 -46
- package/dist/commands/mcp.d.ts.map +0 -1
- package/dist/commands/mcp.js +0 -3413
- package/dist/commands/mcp.js.map +0 -1
- package/dist/commands/menu.d.ts +0 -29
- package/dist/commands/menu.d.ts.map +0 -1
- package/dist/commands/menu.js +0 -147
- package/dist/commands/menu.js.map +0 -1
- package/dist/commands/meshes.d.ts +0 -3
- package/dist/commands/meshes.d.ts.map +0 -1
- package/dist/commands/meshes.js +0 -27
- package/dist/commands/meshes.js.map +0 -1
- package/dist/commands/network-policy.d.ts +0 -3
- package/dist/commands/network-policy.d.ts.map +0 -1
- package/dist/commands/network-policy.js +0 -155
- package/dist/commands/network-policy.js.map +0 -1
- package/dist/commands/new.d.ts +0 -3
- package/dist/commands/new.d.ts.map +0 -1
- package/dist/commands/new.js +0 -296
- package/dist/commands/new.js.map +0 -1
- package/dist/commands/opencomputers.d.ts +0 -10
- package/dist/commands/opencomputers.d.ts.map +0 -1
- package/dist/commands/opencomputers.js +0 -25
- package/dist/commands/opencomputers.js.map +0 -1
- package/dist/commands/operating-contract.d.ts +0 -3
- package/dist/commands/operating-contract.d.ts.map +0 -1
- package/dist/commands/operating-contract.js +0 -651
- package/dist/commands/operating-contract.js.map +0 -1
- package/dist/commands/project.d.ts +0 -4
- package/dist/commands/project.d.ts.map +0 -1
- package/dist/commands/project.js +0 -25
- package/dist/commands/project.js.map +0 -1
- package/dist/commands/pull.d.ts +0 -14
- package/dist/commands/pull.d.ts.map +0 -1
- package/dist/commands/pull.js +0 -156
- package/dist/commands/pull.js.map +0 -1
- package/dist/commands/regions.d.ts +0 -3
- package/dist/commands/regions.d.ts.map +0 -1
- package/dist/commands/regions.js +0 -103
- package/dist/commands/regions.js.map +0 -1
- package/dist/commands/releases.d.ts +0 -3
- package/dist/commands/releases.d.ts.map +0 -1
- package/dist/commands/releases.js +0 -365
- package/dist/commands/releases.js.map +0 -1
- package/dist/commands/rm.d.ts +0 -3
- package/dist/commands/rm.d.ts.map +0 -1
- package/dist/commands/rm.js +0 -42
- package/dist/commands/rm.js.map +0 -1
- package/dist/commands/rollback.d.ts +0 -3
- package/dist/commands/rollback.d.ts.map +0 -1
- package/dist/commands/rollback.js +0 -62
- package/dist/commands/rollback.js.map +0 -1
- package/dist/commands/run-groups.d.ts +0 -3
- package/dist/commands/run-groups.d.ts.map +0 -1
- package/dist/commands/run-groups.js +0 -364
- package/dist/commands/run-groups.js.map +0 -1
- package/dist/commands/run.d.ts +0 -3
- package/dist/commands/run.d.ts.map +0 -1
- package/dist/commands/run.js +0 -130
- package/dist/commands/run.js.map +0 -1
- package/dist/commands/runs.d.ts +0 -3
- package/dist/commands/runs.d.ts.map +0 -1
- package/dist/commands/runs.js +0 -365
- package/dist/commands/runs.js.map +0 -1
- package/dist/commands/runtime-env.d.ts +0 -3
- package/dist/commands/runtime-env.d.ts.map +0 -1
- package/dist/commands/runtime-env.js +0 -114
- package/dist/commands/runtime-env.js.map +0 -1
- package/dist/commands/sandbox-delete-guard.d.ts +0 -4
- package/dist/commands/sandbox-delete-guard.d.ts.map +0 -1
- package/dist/commands/sandbox-delete-guard.js +0 -32
- package/dist/commands/sandbox-delete-guard.js.map +0 -1
- package/dist/commands/sandbox-dev.d.ts +0 -20
- package/dist/commands/sandbox-dev.d.ts.map +0 -1
- package/dist/commands/sandbox-dev.js +0 -583
- package/dist/commands/sandbox-dev.js.map +0 -1
- package/dist/commands/sandbox.d.ts +0 -36
- package/dist/commands/sandbox.d.ts.map +0 -1
- package/dist/commands/sandbox.js +0 -3796
- package/dist/commands/sandbox.js.map +0 -1
- package/dist/commands/scale.d.ts +0 -3
- package/dist/commands/scale.d.ts.map +0 -1
- package/dist/commands/scale.js +0 -61
- package/dist/commands/scale.js.map +0 -1
- package/dist/commands/schedules.d.ts +0 -3
- package/dist/commands/schedules.d.ts.map +0 -1
- package/dist/commands/schedules.js +0 -37
- package/dist/commands/schedules.js.map +0 -1
- package/dist/commands/secrets.d.ts +0 -3
- package/dist/commands/secrets.d.ts.map +0 -1
- package/dist/commands/secrets.js +0 -200
- package/dist/commands/secrets.js.map +0 -1
- package/dist/commands/services.d.ts +0 -3
- package/dist/commands/services.d.ts.map +0 -1
- package/dist/commands/services.js +0 -70
- package/dist/commands/services.js.map +0 -1
- package/dist/commands/shell.d.ts +0 -16
- package/dist/commands/shell.d.ts.map +0 -1
- package/dist/commands/shell.js +0 -555
- package/dist/commands/shell.js.map +0 -1
- package/dist/commands/snapshot.d.ts +0 -10
- package/dist/commands/snapshot.d.ts.map +0 -1
- package/dist/commands/snapshot.js +0 -181
- package/dist/commands/snapshot.js.map +0 -1
- package/dist/commands/ssh.d.ts +0 -3
- package/dist/commands/ssh.d.ts.map +0 -1
- package/dist/commands/ssh.js +0 -93
- package/dist/commands/ssh.js.map +0 -1
- package/dist/commands/status.d.ts +0 -3
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js +0 -302
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/storage.d.ts +0 -3
- package/dist/commands/storage.d.ts.map +0 -1
- package/dist/commands/storage.js +0 -456
- package/dist/commands/storage.js.map +0 -1
- package/dist/commands/teams.d.ts +0 -3
- package/dist/commands/teams.d.ts.map +0 -1
- package/dist/commands/teams.js +0 -169
- package/dist/commands/teams.js.map +0 -1
- package/dist/commands/templates.d.ts +0 -3
- package/dist/commands/templates.d.ts.map +0 -1
- package/dist/commands/templates.js +0 -690
- package/dist/commands/templates.js.map +0 -1
- package/dist/commands/tenant.d.ts +0 -3
- package/dist/commands/tenant.d.ts.map +0 -1
- package/dist/commands/tenant.js +0 -95
- package/dist/commands/tenant.js.map +0 -1
- package/dist/commands/tunnel.d.ts +0 -3
- package/dist/commands/tunnel.d.ts.map +0 -1
- package/dist/commands/tunnel.js +0 -418
- package/dist/commands/tunnel.js.map +0 -1
- package/dist/commands/up.d.ts +0 -14
- package/dist/commands/up.d.ts.map +0 -1
- package/dist/commands/up.js +0 -720
- package/dist/commands/up.js.map +0 -1
- package/dist/commands/update.d.ts +0 -3
- package/dist/commands/update.d.ts.map +0 -1
- package/dist/commands/update.js +0 -166
- package/dist/commands/update.js.map +0 -1
- package/dist/commands/util.d.ts +0 -25
- package/dist/commands/util.d.ts.map +0 -1
- package/dist/commands/util.js +0 -199
- package/dist/commands/util.js.map +0 -1
- package/dist/commands/volumes.d.ts +0 -3
- package/dist/commands/volumes.d.ts.map +0 -1
- package/dist/commands/volumes.js +0 -196
- package/dist/commands/volumes.js.map +0 -1
- package/dist/commands/watch.d.ts +0 -6
- package/dist/commands/watch.d.ts.map +0 -1
- package/dist/commands/watch.js +0 -414
- package/dist/commands/watch.js.map +0 -1
- package/dist/commands/webhooks.d.ts +0 -3
- package/dist/commands/webhooks.d.ts.map +0 -1
- package/dist/commands/webhooks.js +0 -23
- package/dist/commands/webhooks.js.map +0 -1
- package/dist/commands/whoami.d.ts +0 -3
- package/dist/commands/whoami.d.ts.map +0 -1
- package/dist/commands/whoami.js +0 -156
- package/dist/commands/whoami.js.map +0 -1
- package/dist/commands/workspaces.d.ts +0 -3
- package/dist/commands/workspaces.d.ts.map +0 -1
- package/dist/commands/workspaces.js +0 -147
- package/dist/commands/workspaces.js.map +0 -1
- package/dist/config.d.ts +0 -54
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -275
- package/dist/config.js.map +0 -1
- package/dist/errors.d.ts +0 -30
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -92
- package/dist/errors.js.map +0 -1
- package/dist/framework-detector.d.ts +0 -22
- package/dist/framework-detector.d.ts.map +0 -1
- package/dist/framework-detector.js +0 -373
- package/dist/framework-detector.js.map +0 -1
- package/dist/generated/action-capabilities.d.ts +0 -826
- package/dist/generated/action-capabilities.d.ts.map +0 -1
- package/dist/generated/action-capabilities.js +0 -1035
- package/dist/generated/action-capabilities.js.map +0 -1
- package/dist/net-diagnosis.d.ts +0 -87
- package/dist/net-diagnosis.d.ts.map +0 -1
- package/dist/net-diagnosis.js +0 -408
- package/dist/net-diagnosis.js.map +0 -1
- package/dist/pty/raw-mode.d.ts +0 -7
- package/dist/pty/raw-mode.d.ts.map +0 -1
- package/dist/pty/raw-mode.js +0 -22
- package/dist/pty/raw-mode.js.map +0 -1
- package/dist/pty/ws-pty-client.d.ts +0 -13
- package/dist/pty/ws-pty-client.d.ts.map +0 -1
- package/dist/pty/ws-pty-client.js +0 -73
- package/dist/pty/ws-pty-client.js.map +0 -1
- package/dist/tui/dashboard.d.ts +0 -35
- package/dist/tui/dashboard.d.ts.map +0 -1
- package/dist/tui/dashboard.js +0 -191
- package/dist/tui/dashboard.js.map +0 -1
- package/dist/tui/logs.d.ts +0 -26
- package/dist/tui/logs.d.ts.map +0 -1
- package/dist/tui/logs.js +0 -276
- package/dist/tui/logs.js.map +0 -1
- package/dist/types.d.ts +0 -362
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -16
- package/dist/types.js.map +0 -1
- package/dist/ui/picker.d.ts +0 -41
- package/dist/ui/picker.d.ts.map +0 -1
- package/dist/ui/picker.js +0 -77
- package/dist/ui/picker.js.map +0 -1
- package/dist/ui/progress.d.ts +0 -10
- package/dist/ui/progress.d.ts.map +0 -1
- package/dist/ui/progress.js +0 -36
- package/dist/ui/progress.js.map +0 -1
- package/dist/ui/render.d.ts +0 -91
- package/dist/ui/render.d.ts.map +0 -1
- package/dist/ui/render.js +0 -138
- package/dist/ui/render.js.map +0 -1
- package/dist/ui/spinner.d.ts +0 -4
- package/dist/ui/spinner.d.ts.map +0 -1
- package/dist/ui/spinner.js +0 -7
- package/dist/ui/spinner.js.map +0 -1
- package/dist/ui/table.d.ts +0 -8
- package/dist/ui/table.d.ts.map +0 -1
- package/dist/ui/table.js +0 -46
- package/dist/ui/table.js.map +0 -1
- package/dist/update-check.d.ts +0 -13
- package/dist/update-check.d.ts.map +0 -1
- package/dist/update-check.js +0 -94
- package/dist/update-check.js.map +0 -1
- package/dist/version.d.ts +0 -3
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -5
- package/dist/version.js.map +0 -1
|
@@ -1,714 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { loadConfig } from "../config.js";
|
|
3
|
-
import { MiosaClient, parseSse } from "../client.js";
|
|
4
|
-
import { UserError } from "../errors.js";
|
|
5
|
-
import { renderTable } from "../ui/table.js";
|
|
6
|
-
import { spin } from "../ui/spinner.js";
|
|
7
|
-
import { formatBytes } from "../ui/progress.js";
|
|
8
|
-
import { formatDuration } from "../ui/render.js";
|
|
9
|
-
import { handleError, isJsonMode } from "./util.js";
|
|
10
|
-
import { CLI_USER_AGENT } from "../version.js";
|
|
11
|
-
function unwrapDatabases(raw) {
|
|
12
|
-
if (Array.isArray(raw))
|
|
13
|
-
return raw;
|
|
14
|
-
return raw.data ?? raw.databases ?? [];
|
|
15
|
-
}
|
|
16
|
-
function unwrapDatabase(raw) {
|
|
17
|
-
if ("data" in raw && raw.data)
|
|
18
|
-
return raw.data;
|
|
19
|
-
if ("database" in raw && raw.database)
|
|
20
|
-
return raw.database;
|
|
21
|
-
return raw;
|
|
22
|
-
}
|
|
23
|
-
function unwrapCredentials(raw) {
|
|
24
|
-
if ("data" in raw && raw.data)
|
|
25
|
-
return raw.data;
|
|
26
|
-
return raw;
|
|
27
|
-
}
|
|
28
|
-
function fmtState(db) {
|
|
29
|
-
const state = db.state ?? "unknown";
|
|
30
|
-
if (state === "running" || state === "available")
|
|
31
|
-
return chalk.green(state);
|
|
32
|
-
if (state === "creating" || state === "starting" || state === "restarting")
|
|
33
|
-
return chalk.yellow(state);
|
|
34
|
-
if (state === "stopped" || state === "stopping")
|
|
35
|
-
return chalk.dim(state);
|
|
36
|
-
if (state === "error" || state === "failed")
|
|
37
|
-
return chalk.red(state);
|
|
38
|
-
return state;
|
|
39
|
-
}
|
|
40
|
-
function parseIntegerOption(value) {
|
|
41
|
-
const n = Number.parseInt(String(value), 10);
|
|
42
|
-
if (!Number.isInteger(n))
|
|
43
|
-
throw new UserError(`Invalid integer: ${value}`);
|
|
44
|
-
return n;
|
|
45
|
-
}
|
|
46
|
-
function isDatabaseReady(db) {
|
|
47
|
-
const state = String(db.state ?? "").toLowerCase();
|
|
48
|
-
if (state !== "running" && state !== "available")
|
|
49
|
-
return false;
|
|
50
|
-
const connectionStatus = db.connection_test?.status;
|
|
51
|
-
return connectionStatus === undefined || connectionStatus === "ok";
|
|
52
|
-
}
|
|
53
|
-
async function waitForDatabaseReady(client, id, timeoutSec) {
|
|
54
|
-
const deadline = Date.now() + timeoutSec * 1000;
|
|
55
|
-
let last = { id };
|
|
56
|
-
while (Date.now() < deadline) {
|
|
57
|
-
last = unwrapDatabase(await client.apiGet(`/api/v1/databases/${encodeURIComponent(id)}`));
|
|
58
|
-
const state = String(last.state ?? "").toLowerCase();
|
|
59
|
-
if (isDatabaseReady(last))
|
|
60
|
-
return last;
|
|
61
|
-
if (state === "error" || state === "failed") {
|
|
62
|
-
const reason = last.connection_test?.reason;
|
|
63
|
-
throw new UserError(`Database ${id} entered ${state} state.`, reason ? `Connection test: ${reason}` : undefined);
|
|
64
|
-
}
|
|
65
|
-
await new Promise((resolve) => setTimeout(resolve, 2_000));
|
|
66
|
-
}
|
|
67
|
-
throw new UserError(`Database ${id} did not become ready within ${timeoutSec}s.`, `Last state: ${last.state ?? "unknown"}`);
|
|
68
|
-
}
|
|
69
|
-
function unwrapLogs(raw) {
|
|
70
|
-
const root = raw && typeof raw === "object" && "data" in raw
|
|
71
|
-
? raw["data"]
|
|
72
|
-
: raw;
|
|
73
|
-
if (root && typeof root === "object") {
|
|
74
|
-
const r = root;
|
|
75
|
-
const logs = Array.isArray(r["logs"]) ? r["logs"] : [];
|
|
76
|
-
return {
|
|
77
|
-
database_id: typeof r["database_id"] === "string" ? r["database_id"] : undefined,
|
|
78
|
-
logs,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
return { logs: [] };
|
|
82
|
-
}
|
|
83
|
-
function formatLogEntry(entry) {
|
|
84
|
-
const message = entry.line ?? entry.message ?? "";
|
|
85
|
-
if (entry.t)
|
|
86
|
-
return `${entry.t} ${message}`;
|
|
87
|
-
return message;
|
|
88
|
-
}
|
|
89
|
-
function lifecycleVerb(action) {
|
|
90
|
-
if (action === "start")
|
|
91
|
-
return "Starting";
|
|
92
|
-
if (action === "stop")
|
|
93
|
-
return "Stopping";
|
|
94
|
-
return "Restarting";
|
|
95
|
-
}
|
|
96
|
-
function databaseConnectRetryable(state) {
|
|
97
|
-
return ["creating", "provisioning", "starting", "restarting"].includes(state);
|
|
98
|
-
}
|
|
99
|
-
function databaseConnectError(database) {
|
|
100
|
-
const state = database.state ?? "unknown";
|
|
101
|
-
return {
|
|
102
|
-
ok: false,
|
|
103
|
-
error: {
|
|
104
|
-
code: "DATABASE_NOT_RUNNING",
|
|
105
|
-
message: `Database ${database.id} is ${state}; connection credentials are only available once it is running.`,
|
|
106
|
-
retryable: databaseConnectRetryable(state),
|
|
107
|
-
state,
|
|
108
|
-
resource_id: database.id,
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function normalizeEngine(engine) {
|
|
113
|
-
const normalized = engine.trim().toLowerCase();
|
|
114
|
-
return normalized === "postgres" ? "postgresql" : normalized;
|
|
115
|
-
}
|
|
116
|
-
function defaultEngineVersion(engine, version) {
|
|
117
|
-
if (version)
|
|
118
|
-
return version;
|
|
119
|
-
return normalizeEngine(engine) === "postgresql" ? "16" : undefined;
|
|
120
|
-
}
|
|
121
|
-
function buildDatabaseUrl(creds) {
|
|
122
|
-
const direct = creds.recommended_url ??
|
|
123
|
-
creds.proxy_url ??
|
|
124
|
-
creds.url ??
|
|
125
|
-
creds.database_url ??
|
|
126
|
-
creds.connection_url ??
|
|
127
|
-
creds.connection_string ??
|
|
128
|
-
creds.connectionString ??
|
|
129
|
-
creds.uri;
|
|
130
|
-
if (direct)
|
|
131
|
-
return normalizePostgresUrl(direct);
|
|
132
|
-
const host = creds.host;
|
|
133
|
-
const database = creds.database ?? creds.dbname ?? creds.name;
|
|
134
|
-
const username = creds.username ?? creds.user;
|
|
135
|
-
if (!host || !database || !username)
|
|
136
|
-
return null;
|
|
137
|
-
const port = creds.port ?? 5432;
|
|
138
|
-
const password = creds.password ? `:${encodeURIComponent(creds.password)}` : "";
|
|
139
|
-
return `postgresql://${encodeURIComponent(username)}${password}@${host}:${port}/${database}`;
|
|
140
|
-
}
|
|
141
|
-
function normalizePostgresUrl(url) {
|
|
142
|
-
return url.startsWith("postgres://")
|
|
143
|
-
? `postgresql://${url.slice("postgres://".length)}`
|
|
144
|
-
: url;
|
|
145
|
-
}
|
|
146
|
-
function unwrapMetrics(raw) {
|
|
147
|
-
if (raw && typeof raw === "object" && "data" in raw) {
|
|
148
|
-
const data = raw["data"];
|
|
149
|
-
if (data && typeof data === "object")
|
|
150
|
-
return data;
|
|
151
|
-
}
|
|
152
|
-
if (raw && typeof raw === "object")
|
|
153
|
-
return raw;
|
|
154
|
-
return {};
|
|
155
|
-
}
|
|
156
|
-
function renderDatabaseMetrics(raw) {
|
|
157
|
-
const root = unwrapMetrics(raw);
|
|
158
|
-
const current = root["current"] && typeof root["current"] === "object"
|
|
159
|
-
? root["current"]
|
|
160
|
-
: {};
|
|
161
|
-
console.log();
|
|
162
|
-
console.log(chalk.bold("Database metrics"));
|
|
163
|
-
console.log();
|
|
164
|
-
console.log(` ${chalk.bold("database_id")} ${root["database_id"] ?? root["resource_id"] ?? "-"}`);
|
|
165
|
-
console.log(` ${chalk.bold("window")} ${root["window"] ?? "1h"}`);
|
|
166
|
-
console.log(` ${chalk.bold("state")} ${formatMetricState(current["state"])}`);
|
|
167
|
-
console.log(` ${chalk.bold("engine")} ${[current["engine"], current["engine_version"]].filter(Boolean).join(" ") || chalk.dim("-")}`);
|
|
168
|
-
console.log(` ${chalk.bold("cpu")} ${formatMetricValue(current["cpu_count"])}`);
|
|
169
|
-
console.log(` ${chalk.bold("memory")} ${formatMb(current["memory_mb"])}`);
|
|
170
|
-
console.log(` ${chalk.bold("storage")} ${formatMb(current["storage_mb"])}`);
|
|
171
|
-
console.log(` ${chalk.bold("port")} ${formatMetricValue(current["port"])}`);
|
|
172
|
-
console.log(` ${chalk.bold("uptime")} ${formatSeconds(current["uptime_sec"])}`);
|
|
173
|
-
console.log(` ${chalk.bold("node")} ${formatMetricValue(current["node_id"])}`);
|
|
174
|
-
console.log(` ${chalk.bold("ip")} ${formatMetricValue(current["ip_address"])}`);
|
|
175
|
-
console.log();
|
|
176
|
-
}
|
|
177
|
-
function formatMetricState(value) {
|
|
178
|
-
const state = String(value ?? "unknown");
|
|
179
|
-
if (["running", "available", "active", "healthy"].includes(state)) {
|
|
180
|
-
return chalk.green(state);
|
|
181
|
-
}
|
|
182
|
-
if (["creating", "provisioning", "starting", "restarting"].includes(state)) {
|
|
183
|
-
return chalk.yellow(state);
|
|
184
|
-
}
|
|
185
|
-
if (["failed", "error", "unhealthy"].includes(state)) {
|
|
186
|
-
return chalk.red(state);
|
|
187
|
-
}
|
|
188
|
-
return state;
|
|
189
|
-
}
|
|
190
|
-
function formatMetricValue(value) {
|
|
191
|
-
if (value === null || value === undefined || value === "")
|
|
192
|
-
return chalk.dim("-");
|
|
193
|
-
return String(value);
|
|
194
|
-
}
|
|
195
|
-
function formatMb(value) {
|
|
196
|
-
if (typeof value !== "number")
|
|
197
|
-
return formatMetricValue(value);
|
|
198
|
-
return formatBytes(value * 1024 * 1024);
|
|
199
|
-
}
|
|
200
|
-
function formatSeconds(value) {
|
|
201
|
-
if (typeof value !== "number")
|
|
202
|
-
return formatMetricValue(value);
|
|
203
|
-
return formatDuration(value * 1000);
|
|
204
|
-
}
|
|
205
|
-
export function register(program) {
|
|
206
|
-
const databases = program
|
|
207
|
-
.command("databases")
|
|
208
|
-
.description("Manage managed databases");
|
|
209
|
-
// list
|
|
210
|
-
databases
|
|
211
|
-
.command("list")
|
|
212
|
-
.description("List databases")
|
|
213
|
-
.option("--json", "Output raw JSON")
|
|
214
|
-
.action(async (opts) => {
|
|
215
|
-
try {
|
|
216
|
-
const config = loadConfig();
|
|
217
|
-
const client = new MiosaClient(config);
|
|
218
|
-
const spinner = isJsonMode(opts) ? null : spin("Fetching databases...");
|
|
219
|
-
const rows = unwrapDatabases(await client.apiGet("/api/v1/databases"));
|
|
220
|
-
spinner?.stop();
|
|
221
|
-
if (isJsonMode(opts)) {
|
|
222
|
-
console.log(JSON.stringify(rows, null, 2));
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
renderTable(rows, [
|
|
226
|
-
{ header: "ID", key: (d) => d.id.slice(0, 12), width: 14 },
|
|
227
|
-
{ header: "NAME", key: "name", width: 24 },
|
|
228
|
-
{
|
|
229
|
-
header: "ENGINE",
|
|
230
|
-
key: (d) => [d.engine, d.engine_version].filter(Boolean).join(" ") ||
|
|
231
|
-
chalk.dim("unknown"),
|
|
232
|
-
width: 16,
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
header: "REGION",
|
|
236
|
-
key: (d) => d.region ?? chalk.dim("default"),
|
|
237
|
-
width: 14,
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
header: "ENVIRONMENT",
|
|
241
|
-
key: (d) => d.environment_id?.slice(0, 12) ?? chalk.dim("-"),
|
|
242
|
-
width: 14,
|
|
243
|
-
},
|
|
244
|
-
{ header: "STATE", key: fmtState, width: 12 },
|
|
245
|
-
]);
|
|
246
|
-
}
|
|
247
|
-
catch (err) {
|
|
248
|
-
handleError(err);
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
// create
|
|
252
|
-
databases
|
|
253
|
-
.command("create")
|
|
254
|
-
.description("Create a managed database")
|
|
255
|
-
.requiredOption("--name <name>", "Database name")
|
|
256
|
-
.option("--engine <engine>", "Database engine (postgres/postgresql, mysql, redis)", "postgresql")
|
|
257
|
-
.option("--engine-version <version>", "Engine version")
|
|
258
|
-
.option("--db-version <version>", "Alias for --engine-version")
|
|
259
|
-
.option("--region <region>", "Region ID")
|
|
260
|
-
.option("--workspace <workspace-id>", "Workspace ID")
|
|
261
|
-
.option("--environment <environment-id>", "Deployment environment ID")
|
|
262
|
-
.option("--wait", "Wait until the database is ready")
|
|
263
|
-
.option("--timeout <seconds>", "Wait timeout in seconds", parseIntegerOption, 120)
|
|
264
|
-
.option("--json", "Output raw JSON")
|
|
265
|
-
.action(async (opts) => {
|
|
266
|
-
try {
|
|
267
|
-
const config = loadConfig();
|
|
268
|
-
const client = new MiosaClient(config);
|
|
269
|
-
const spinner = isJsonMode(opts) ? null : spin(`Creating database ${opts.name}...`);
|
|
270
|
-
const engine = normalizeEngine(opts.engine);
|
|
271
|
-
const engineVersion = defaultEngineVersion(engine, opts.engineVersion ?? opts.dbVersion);
|
|
272
|
-
const body = {
|
|
273
|
-
name: opts.name,
|
|
274
|
-
engine,
|
|
275
|
-
};
|
|
276
|
-
if (engineVersion)
|
|
277
|
-
body["engine_version"] = engineVersion;
|
|
278
|
-
if (opts.region)
|
|
279
|
-
body["region"] = opts.region;
|
|
280
|
-
if (opts.workspace)
|
|
281
|
-
body["workspace_id"] = opts.workspace;
|
|
282
|
-
if (opts.environment)
|
|
283
|
-
body["environment_id"] = opts.environment;
|
|
284
|
-
let db = unwrapDatabase(await client.apiPost("/api/v1/databases", body));
|
|
285
|
-
spinner?.succeed(`Created database ${db.name ?? db.id}`);
|
|
286
|
-
if (opts.wait) {
|
|
287
|
-
db = await waitForDatabaseReady(client, db.id, opts.timeout);
|
|
288
|
-
}
|
|
289
|
-
if (isJsonMode(opts)) {
|
|
290
|
-
console.log(JSON.stringify(db, null, 2));
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
console.log();
|
|
294
|
-
console.log(` ${chalk.bold("ID")} ${db.id}`);
|
|
295
|
-
console.log(` ${chalk.bold("Name")} ${db.name}`);
|
|
296
|
-
console.log(` ${chalk.bold("Engine")} ${db.engine ?? engine}`);
|
|
297
|
-
console.log(` ${chalk.bold("State")} ${db.state ?? "creating"}`);
|
|
298
|
-
console.log();
|
|
299
|
-
}
|
|
300
|
-
catch (err) {
|
|
301
|
-
handleError(err);
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
// get
|
|
305
|
-
databases
|
|
306
|
-
.command("get <id>")
|
|
307
|
-
.description("Get database details")
|
|
308
|
-
.option("--json", "Output raw JSON")
|
|
309
|
-
.action(async (id, opts) => {
|
|
310
|
-
try {
|
|
311
|
-
const config = loadConfig();
|
|
312
|
-
const client = new MiosaClient(config);
|
|
313
|
-
const db = unwrapDatabase(await client.apiGet(`/api/v1/databases/${encodeURIComponent(id)}`));
|
|
314
|
-
if (isJsonMode(opts)) {
|
|
315
|
-
console.log(JSON.stringify(db, null, 2));
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
console.log();
|
|
319
|
-
console.log(` ${chalk.bold("ID")} ${db.id}`);
|
|
320
|
-
console.log(` ${chalk.bold("Name")} ${db.name}`);
|
|
321
|
-
console.log(` ${chalk.bold("Engine")} ${[db.engine, db.engine_version].filter(Boolean).join(" ") || chalk.dim("unknown")}`);
|
|
322
|
-
console.log(` ${chalk.bold("Region")} ${db.region ?? chalk.dim("default")}`);
|
|
323
|
-
console.log(` ${chalk.bold("State")} ${fmtState(db)}`);
|
|
324
|
-
if (db.created_at)
|
|
325
|
-
console.log(` ${chalk.bold("Created")} ${db.created_at}`);
|
|
326
|
-
console.log();
|
|
327
|
-
console.log(chalk.dim(` Run "miosa databases connect ${id}" to get the connection string.`));
|
|
328
|
-
console.log();
|
|
329
|
-
}
|
|
330
|
-
catch (err) {
|
|
331
|
-
handleError(err);
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
// metrics
|
|
335
|
-
databases
|
|
336
|
-
.command("metrics <id>")
|
|
337
|
-
.description("Show managed database resource, uptime, and endpoint metrics")
|
|
338
|
-
.option("--window <window>", "Metrics window: 1h, 24h, or 7d", "1h")
|
|
339
|
-
.option("--json", "Output raw JSON")
|
|
340
|
-
.action(async (id, opts) => {
|
|
341
|
-
try {
|
|
342
|
-
const config = loadConfig();
|
|
343
|
-
const client = new MiosaClient(config);
|
|
344
|
-
const json = isJsonMode(opts);
|
|
345
|
-
const spinner = json ? null : spin("Fetching database metrics...");
|
|
346
|
-
const metrics = await client.apiGet(`/api/v1/databases/${encodeURIComponent(id)}/metrics?window=${encodeURIComponent(opts.window)}`);
|
|
347
|
-
spinner?.stop();
|
|
348
|
-
if (json) {
|
|
349
|
-
console.log(JSON.stringify(metrics, null, 2));
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
renderDatabaseMetrics(metrics);
|
|
353
|
-
}
|
|
354
|
-
catch (err) {
|
|
355
|
-
handleError(err);
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
const lifecycleAction = (action) => async (id, opts) => {
|
|
359
|
-
try {
|
|
360
|
-
const config = loadConfig();
|
|
361
|
-
const client = new MiosaClient(config);
|
|
362
|
-
const spinner = isJsonMode(opts)
|
|
363
|
-
? null
|
|
364
|
-
: spin(`${lifecycleVerb(action)} database...`);
|
|
365
|
-
const db = unwrapDatabase(await client.apiPost(`/api/v1/databases/${encodeURIComponent(id)}/${action}`, {}));
|
|
366
|
-
spinner?.succeed(`Database ${action} requested`);
|
|
367
|
-
if (isJsonMode(opts)) {
|
|
368
|
-
console.log(JSON.stringify(db, null, 2));
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
console.log();
|
|
372
|
-
console.log(` ${chalk.bold("ID")} ${db.id}`);
|
|
373
|
-
console.log(` ${chalk.bold("State")} ${db.state ?? "unknown"}`);
|
|
374
|
-
console.log();
|
|
375
|
-
}
|
|
376
|
-
catch (err) {
|
|
377
|
-
handleError(err);
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
databases
|
|
381
|
-
.command("start <id>")
|
|
382
|
-
.description("Start a stopped or errored database")
|
|
383
|
-
.option("--json", "Output raw JSON")
|
|
384
|
-
.action(lifecycleAction("start"));
|
|
385
|
-
databases
|
|
386
|
-
.command("stop <id>")
|
|
387
|
-
.description("Stop a running database")
|
|
388
|
-
.option("--json", "Output raw JSON")
|
|
389
|
-
.action(lifecycleAction("stop"));
|
|
390
|
-
databases
|
|
391
|
-
.command("restart <id>")
|
|
392
|
-
.description("Restart a managed database")
|
|
393
|
-
.option("--json", "Output raw JSON")
|
|
394
|
-
.action(lifecycleAction("restart"));
|
|
395
|
-
databases
|
|
396
|
-
.command("wait <id>")
|
|
397
|
-
.description("Wait for a database to become ready")
|
|
398
|
-
.option("--ready", "Wait for running state and successful connection test", true)
|
|
399
|
-
.option("--timeout <seconds>", "Wait timeout in seconds", parseIntegerOption, 120)
|
|
400
|
-
.option("--json", "Output raw JSON")
|
|
401
|
-
.action(async (id, opts) => {
|
|
402
|
-
try {
|
|
403
|
-
void opts.ready;
|
|
404
|
-
const config = loadConfig();
|
|
405
|
-
const client = new MiosaClient(config);
|
|
406
|
-
const spinner = isJsonMode(opts) ? null : spin("Waiting for database...");
|
|
407
|
-
const db = await waitForDatabaseReady(client, id, opts.timeout);
|
|
408
|
-
spinner?.succeed("Database ready");
|
|
409
|
-
if (isJsonMode(opts)) {
|
|
410
|
-
console.log(JSON.stringify(db, null, 2));
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
console.log();
|
|
414
|
-
console.log(` ${chalk.bold("ID")} ${db.id}`);
|
|
415
|
-
console.log(` ${chalk.bold("State")} ${db.state ?? "running"}`);
|
|
416
|
-
if (db.connection_test?.host) {
|
|
417
|
-
console.log(` ${chalk.bold("Endpoint")} ${db.connection_test.host}:${db.connection_test.port ?? ""}`);
|
|
418
|
-
}
|
|
419
|
-
console.log();
|
|
420
|
-
}
|
|
421
|
-
catch (err) {
|
|
422
|
-
handleError(err);
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
// connect — print connection string
|
|
426
|
-
databases
|
|
427
|
-
.command("connect <id>")
|
|
428
|
-
.description("Show connection string for a database")
|
|
429
|
-
.option("--print-url", "Print only the connection URL")
|
|
430
|
-
.option("--json", "Output raw JSON")
|
|
431
|
-
.action(async (id, opts) => {
|
|
432
|
-
try {
|
|
433
|
-
const config = loadConfig();
|
|
434
|
-
const client = new MiosaClient(config);
|
|
435
|
-
const spinner = isJsonMode(opts) || opts.printUrl ? null : spin("Fetching credentials...");
|
|
436
|
-
const database = unwrapDatabase(await client.apiGet(`/api/v1/databases/${encodeURIComponent(id)}`));
|
|
437
|
-
if (database.state !== "running" && database.state !== "available") {
|
|
438
|
-
spinner?.stop();
|
|
439
|
-
const error = databaseConnectError(database);
|
|
440
|
-
if (isJsonMode(opts)) {
|
|
441
|
-
console.log(JSON.stringify(error, null, 2));
|
|
442
|
-
}
|
|
443
|
-
else {
|
|
444
|
-
console.error(chalk.red(error.error.message));
|
|
445
|
-
}
|
|
446
|
-
process.exit(1);
|
|
447
|
-
}
|
|
448
|
-
const creds = unwrapCredentials(await client.apiGet(`/api/v1/databases/${encodeURIComponent(id)}/credentials`));
|
|
449
|
-
spinner?.stop();
|
|
450
|
-
if (isJsonMode(opts)) {
|
|
451
|
-
console.log(JSON.stringify(creds, null, 2));
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
const url = buildDatabaseUrl(creds);
|
|
455
|
-
if (opts.printUrl) {
|
|
456
|
-
if (!url) {
|
|
457
|
-
throw new Error("Could not construct a connection URL from the credentials returned by the API. Use --json to inspect raw credentials.");
|
|
458
|
-
}
|
|
459
|
-
console.log(url);
|
|
460
|
-
return;
|
|
461
|
-
}
|
|
462
|
-
if (url) {
|
|
463
|
-
console.log();
|
|
464
|
-
console.log(` ${chalk.bold("URL")} ${url}`);
|
|
465
|
-
console.log();
|
|
466
|
-
}
|
|
467
|
-
else {
|
|
468
|
-
console.log();
|
|
469
|
-
if (creds.host)
|
|
470
|
-
console.log(` ${chalk.bold("Host")} ${creds.host}`);
|
|
471
|
-
if (creds.port !== undefined)
|
|
472
|
-
console.log(` ${chalk.bold("Port")} ${creds.port}`);
|
|
473
|
-
const database = creds.database ?? creds.dbname ?? creds.name;
|
|
474
|
-
const username = creds.username ?? creds.user;
|
|
475
|
-
if (database)
|
|
476
|
-
console.log(` ${chalk.bold("Database")} ${database}`);
|
|
477
|
-
if (username)
|
|
478
|
-
console.log(` ${chalk.bold("User")} ${username}`);
|
|
479
|
-
if (creds.password)
|
|
480
|
-
console.log(` ${chalk.bold("Password")} ${creds.password}`);
|
|
481
|
-
console.log();
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
catch (err) {
|
|
485
|
-
handleError(err);
|
|
486
|
-
}
|
|
487
|
-
});
|
|
488
|
-
// delete
|
|
489
|
-
databases
|
|
490
|
-
.command("delete <id>")
|
|
491
|
-
.description("Delete a database")
|
|
492
|
-
.option("-f, --force", "Skip confirmation prompt")
|
|
493
|
-
.option("--json", "Output raw JSON")
|
|
494
|
-
.action(async (id, opts) => {
|
|
495
|
-
try {
|
|
496
|
-
if (!opts.force) {
|
|
497
|
-
const { default: inquirer } = await import("inquirer");
|
|
498
|
-
const { ok } = await inquirer.prompt([
|
|
499
|
-
{
|
|
500
|
-
type: "confirm",
|
|
501
|
-
name: "ok",
|
|
502
|
-
message: chalk.red(`Delete database ${id}? This is irreversible.`),
|
|
503
|
-
default: false,
|
|
504
|
-
},
|
|
505
|
-
]);
|
|
506
|
-
if (!ok) {
|
|
507
|
-
console.log(chalk.dim(" Cancelled."));
|
|
508
|
-
process.exit(0);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
const config = loadConfig();
|
|
512
|
-
const client = new MiosaClient(config);
|
|
513
|
-
const spinner = isJsonMode(opts) ? null : spin("Deleting database...");
|
|
514
|
-
const result = await client.apiDelete(`/api/v1/databases/${encodeURIComponent(id)}`);
|
|
515
|
-
spinner?.succeed("Database deleted");
|
|
516
|
-
if (isJsonMode(opts))
|
|
517
|
-
console.log(JSON.stringify(result ?? { ok: true }, null, 2));
|
|
518
|
-
}
|
|
519
|
-
catch (err) {
|
|
520
|
-
handleError(err);
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
// backup
|
|
524
|
-
databases
|
|
525
|
-
.command("backup <id>")
|
|
526
|
-
.description("Trigger a manual backup for a database")
|
|
527
|
-
.option("--json", "Output raw JSON")
|
|
528
|
-
.action(async (id, opts) => {
|
|
529
|
-
try {
|
|
530
|
-
const config = loadConfig();
|
|
531
|
-
const client = new MiosaClient(config);
|
|
532
|
-
const spinner = isJsonMode(opts) ? null : spin("Triggering backup...");
|
|
533
|
-
const result = await client.apiPost(`/api/v1/databases/${encodeURIComponent(id)}/backups`, {});
|
|
534
|
-
spinner?.succeed("Backup started");
|
|
535
|
-
if (isJsonMode(opts)) {
|
|
536
|
-
console.log(JSON.stringify(result, null, 2));
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
const r = result;
|
|
540
|
-
const backupId = typeof r["id"] === "string"
|
|
541
|
-
? r["id"]
|
|
542
|
-
: typeof r["backup_id"] === "string"
|
|
543
|
-
? r["backup_id"]
|
|
544
|
-
: null;
|
|
545
|
-
console.log();
|
|
546
|
-
if (backupId)
|
|
547
|
-
console.log(` ${chalk.bold("Backup ID")} ${backupId}`);
|
|
548
|
-
console.log(` ${chalk.bold("Status")} ${typeof r["status"] === "string" ? r["status"] : "pending"}`);
|
|
549
|
-
console.log();
|
|
550
|
-
if (backupId) {
|
|
551
|
-
console.log(chalk.dim(` Run "miosa databases restore ${id} ${backupId}" to restore from this backup.`));
|
|
552
|
-
console.log();
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
catch (err) {
|
|
556
|
-
handleError(err);
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
// restore
|
|
560
|
-
databases
|
|
561
|
-
.command("restore <id> <backup-id>")
|
|
562
|
-
.description("Restore a database from a backup")
|
|
563
|
-
.option("-f, --force", "Skip confirmation prompt")
|
|
564
|
-
.option("--json", "Output raw JSON")
|
|
565
|
-
.action(async (id, backupId, opts) => {
|
|
566
|
-
try {
|
|
567
|
-
if (!opts.force) {
|
|
568
|
-
const { default: inquirer } = await import("inquirer");
|
|
569
|
-
const { ok } = await inquirer.prompt([
|
|
570
|
-
{
|
|
571
|
-
type: "confirm",
|
|
572
|
-
name: "ok",
|
|
573
|
-
message: chalk.red(`Restore database ${id} from backup ${backupId}? Current data will be overwritten.`),
|
|
574
|
-
default: false,
|
|
575
|
-
},
|
|
576
|
-
]);
|
|
577
|
-
if (!ok) {
|
|
578
|
-
console.log(chalk.dim(" Cancelled."));
|
|
579
|
-
process.exit(0);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
const config = loadConfig();
|
|
583
|
-
const client = new MiosaClient(config);
|
|
584
|
-
const spinner = isJsonMode(opts) ? null : spin("Triggering restore...");
|
|
585
|
-
const result = await client.apiPost(`/api/v1/databases/${encodeURIComponent(id)}/restore`, { backup_id: backupId });
|
|
586
|
-
spinner?.succeed("Restore started");
|
|
587
|
-
if (isJsonMode(opts)) {
|
|
588
|
-
console.log(JSON.stringify(result, null, 2));
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
const r = result;
|
|
592
|
-
console.log();
|
|
593
|
-
console.log(` ${chalk.bold("Database")} ${id}`);
|
|
594
|
-
console.log(` ${chalk.bold("Backup")} ${backupId}`);
|
|
595
|
-
console.log(` ${chalk.bold("Status")} ${typeof r["status"] === "string" ? r["status"] : "restoring"}`);
|
|
596
|
-
console.log();
|
|
597
|
-
console.log(chalk.dim(` Run "miosa databases get ${id}" to monitor restore progress.`));
|
|
598
|
-
console.log();
|
|
599
|
-
}
|
|
600
|
-
catch (err) {
|
|
601
|
-
handleError(err);
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
// logs
|
|
605
|
-
databases
|
|
606
|
-
.command("logs <id>")
|
|
607
|
-
.description("Show recent managed database logs")
|
|
608
|
-
.option("--lines <n>", "Number of lines to fetch", parseIntegerOption, 100)
|
|
609
|
-
.option("--follow", "Follow live logs with SSE")
|
|
610
|
-
.option("--json", "Output raw JSON")
|
|
611
|
-
.action(async (id, opts) => {
|
|
612
|
-
try {
|
|
613
|
-
const config = loadConfig();
|
|
614
|
-
const client = new MiosaClient(config);
|
|
615
|
-
if (!opts.follow) {
|
|
616
|
-
const lines = Math.max(1, Math.min(opts.lines, 500));
|
|
617
|
-
const result = unwrapLogs(await client.apiGet(`/api/v1/databases/${encodeURIComponent(id)}/logs?lines=${lines}`));
|
|
618
|
-
if (isJsonMode(opts)) {
|
|
619
|
-
console.log(JSON.stringify(result, null, 2));
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
if (result.logs.length === 0) {
|
|
623
|
-
console.log(chalk.dim("No database logs."));
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
for (const entry of result.logs) {
|
|
627
|
-
console.log(formatLogEntry(entry));
|
|
628
|
-
}
|
|
629
|
-
return;
|
|
630
|
-
}
|
|
631
|
-
if (!isJsonMode(opts)) {
|
|
632
|
-
console.log(chalk.dim(`Streaming logs for database ${id}...`));
|
|
633
|
-
}
|
|
634
|
-
// Use undici directly to get an SSE response
|
|
635
|
-
const { request } = await import("undici");
|
|
636
|
-
const endpoint = config.endpoint;
|
|
637
|
-
const apiKey = config.api_key ?? "";
|
|
638
|
-
const url = `${endpoint.replace(/\/$/, "")}/api/v1/databases/${encodeURIComponent(id)}/logs/stream`;
|
|
639
|
-
const res = await request(url, {
|
|
640
|
-
method: "GET",
|
|
641
|
-
headers: {
|
|
642
|
-
Authorization: `Bearer ${apiKey}`,
|
|
643
|
-
Accept: "text/event-stream, application/json, */*",
|
|
644
|
-
"User-Agent": CLI_USER_AGENT,
|
|
645
|
-
},
|
|
646
|
-
});
|
|
647
|
-
if (res.statusCode >= 400) {
|
|
648
|
-
const body = await res.body.text();
|
|
649
|
-
if (isJsonMode(opts)) {
|
|
650
|
-
console.log(JSON.stringify({
|
|
651
|
-
ok: false,
|
|
652
|
-
error: {
|
|
653
|
-
code: `HTTP_${res.statusCode}`,
|
|
654
|
-
message: body || `HTTP ${res.statusCode}`,
|
|
655
|
-
retryable: res.statusCode >= 500,
|
|
656
|
-
},
|
|
657
|
-
}, null, 2));
|
|
658
|
-
process.exit(1);
|
|
659
|
-
}
|
|
660
|
-
console.error(chalk.red(`HTTP ${res.statusCode}: ${body}`));
|
|
661
|
-
if (res.statusCode === 406) {
|
|
662
|
-
console.error(chalk.yellow("Database logs endpoint rejected the requested response format. The CLI now accepts SSE, JSON, or text; if this persists, the API route is returning a format negotiation error."));
|
|
663
|
-
}
|
|
664
|
-
process.exit(1);
|
|
665
|
-
}
|
|
666
|
-
for await (const event of parseSse(res.body)) {
|
|
667
|
-
if (isJsonMode(opts)) {
|
|
668
|
-
console.log(JSON.stringify(event));
|
|
669
|
-
continue;
|
|
670
|
-
}
|
|
671
|
-
switch (event.type) {
|
|
672
|
-
case "stdout":
|
|
673
|
-
process.stdout.write(event.data);
|
|
674
|
-
break;
|
|
675
|
-
case "stderr":
|
|
676
|
-
process.stderr.write(chalk.red(event.data));
|
|
677
|
-
break;
|
|
678
|
-
case "error":
|
|
679
|
-
console.error(chalk.red(event.message));
|
|
680
|
-
break;
|
|
681
|
-
case "done":
|
|
682
|
-
return;
|
|
683
|
-
case "unknown":
|
|
684
|
-
try {
|
|
685
|
-
const parsed = JSON.parse(event.raw);
|
|
686
|
-
const line = typeof parsed["line"] === "string"
|
|
687
|
-
? parsed["line"]
|
|
688
|
-
: typeof parsed["message"] === "string"
|
|
689
|
-
? parsed["message"]
|
|
690
|
-
: null;
|
|
691
|
-
if (line) {
|
|
692
|
-
const isErr = parsed["stream"] === "stderr" ||
|
|
693
|
-
parsed["level"] === "error";
|
|
694
|
-
if (isErr)
|
|
695
|
-
process.stderr.write(chalk.red(line) + "\n");
|
|
696
|
-
else
|
|
697
|
-
process.stdout.write(line + "\n");
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
catch {
|
|
701
|
-
// Ignore malformed frames
|
|
702
|
-
}
|
|
703
|
-
break;
|
|
704
|
-
default:
|
|
705
|
-
break;
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
catch (err) {
|
|
710
|
-
handleError(err);
|
|
711
|
-
}
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
//# sourceMappingURL=databases.js.map
|