@dreamlake/dreamlake-cli 0.88.1 → 0.89.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/dist/api/access.d.ts +83 -0
- package/dist/api/access.js +77 -0
- package/dist/api/agent.d.ts +156 -0
- package/dist/api/agent.js +111 -0
- package/dist/api/browser.d.ts +90 -0
- package/dist/api/browser.js +102 -0
- package/dist/api/client.d.ts +53 -0
- package/dist/api/client.js +102 -0
- package/dist/api/common.d.ts +28 -0
- package/dist/api/common.js +16 -0
- package/dist/api/content.d.ts +195 -0
- package/dist/api/content.js +147 -0
- package/dist/api/execution.d.ts +84 -0
- package/dist/api/execution.js +73 -0
- package/dist/api/http.d.ts +19 -0
- package/dist/api/http.js +66 -0
- package/dist/api/index.d.ts +2330 -0
- package/dist/api/index.js +114 -0
- package/dist/api/infra.d.ts +2 -0
- package/dist/api/infra.js +2 -0
- package/dist/api/jobs.d.ts +2 -0
- package/dist/api/jobs.js +2 -0
- package/dist/api/layout.d.ts +2 -0
- package/dist/api/layout.js +2 -0
- package/dist/api/library-edit.d.ts +3 -0
- package/dist/api/library-edit.js +3 -0
- package/dist/api/library-manifest.d.ts +2 -0
- package/dist/api/library-manifest.js +2 -0
- package/dist/api/note-character-plan.d.ts +2 -0
- package/dist/api/note-character-plan.js +2 -0
- package/dist/api/note-editing.d.ts +2 -0
- package/dist/api/note-editing.js +2 -0
- package/dist/api/note-edits.d.ts +21 -0
- package/dist/api/note-edits.js +10 -0
- package/dist/api/note-events.d.ts +5 -0
- package/dist/api/note-events.js +11 -0
- package/dist/api/note-files.d.ts +75 -0
- package/dist/api/note-files.js +65 -0
- package/dist/api/note-html-read.d.ts +2 -0
- package/dist/api/note-html-read.js +2 -0
- package/dist/api/note-html.d.ts +2 -0
- package/dist/api/note-html.js +2 -0
- package/dist/api/note-toc.d.ts +2 -0
- package/dist/api/note-toc.js +2 -0
- package/dist/api/notes.d.ts +304 -0
- package/dist/api/notes.js +181 -0
- package/dist/api/open-resources.d.ts +27 -0
- package/dist/api/open-resources.js +102 -0
- package/dist/api/ownership.d.ts +12 -0
- package/dist/api/ownership.js +24 -0
- package/dist/api/platform.d.ts +83 -0
- package/dist/api/platform.js +56 -0
- package/dist/api/presigned-transfer.d.ts +2 -0
- package/dist/api/presigned-transfer.js +2 -0
- package/dist/api/registered-runs.d.ts +48 -0
- package/dist/api/registered-runs.js +33 -0
- package/dist/api/sessions.d.ts +299 -0
- package/dist/api/sessions.js +105 -0
- package/dist/api/storage.d.ts +46 -0
- package/dist/api/storage.js +34 -0
- package/dist/api/streams.d.ts +18 -0
- package/dist/api/streams.js +70 -0
- package/dist/api/vault.d.ts +93 -0
- package/dist/api/vault.js +79 -0
- package/dist/api/workspace.d.ts +180 -0
- package/dist/api/workspace.js +146 -0
- package/dist/cli/agent-identity.d.ts +4 -0
- package/dist/cli/agent-identity.js +21 -0
- package/dist/cli/agents/identity.d.ts +50 -0
- package/dist/cli/agents/identity.js +105 -0
- package/dist/cli/agents/index.d.ts +31 -0
- package/dist/cli/agents/index.js +580 -0
- package/dist/cli/agents/manage.d.ts +43 -0
- package/dist/cli/agents/manage.js +376 -0
- package/dist/cli/agents/spec.d.ts +104 -0
- package/dist/cli/agents/spec.js +280 -0
- package/dist/cli/agents/web.d.ts +7 -0
- package/dist/cli/agents/web.js +109 -0
- package/dist/cli/artifact/incremental.d.ts +21 -0
- package/dist/cli/artifact/incremental.js +80 -0
- package/dist/cli/artifact/index.d.ts +52 -0
- package/dist/cli/artifact/index.js +405 -0
- package/dist/cli/artifact/meta.d.ts +69 -0
- package/dist/cli/artifact/meta.js +189 -0
- package/dist/cli/auth/commands.d.ts +29 -0
- package/dist/cli/auth/commands.js +327 -0
- package/dist/cli/auth/constants.d.ts +13 -0
- package/dist/cli/auth/constants.js +18 -0
- package/dist/cli/auth/credentials.d.ts +37 -0
- package/dist/cli/auth/credentials.js +155 -0
- package/dist/cli/auth/device-flow.d.ts +32 -0
- package/dist/cli/auth/device-flow.js +154 -0
- package/dist/cli/auth/device-secret.d.ts +6 -0
- package/dist/cli/auth/device-secret.js +26 -0
- package/dist/cli/auth/machine.d.ts +15 -0
- package/dist/cli/auth/machine.js +126 -0
- package/dist/cli/auth/materialized.d.ts +32 -0
- package/dist/cli/auth/materialized.js +102 -0
- package/dist/cli/auth/migrate.d.ts +10 -0
- package/dist/cli/auth/migrate.js +75 -0
- package/dist/cli/client.d.ts +102 -0
- package/dist/cli/client.js +206 -0
- package/dist/cli/collection-list.d.ts +3 -0
- package/dist/cli/collection-list.js +25 -0
- package/dist/cli/compat/ctx.d.ts +26 -0
- package/dist/cli/compat/ctx.js +76 -0
- package/dist/cli/compat/dreamdb-wasm-embedded.d.ts +2 -0
- package/dist/cli/compat/dreamdb-wasm-embedded.js +8 -0
- package/dist/cli/compat/dreamdb-wasm.d.ts +1 -0
- package/dist/cli/compat/dreamdb-wasm.js +26 -0
- package/dist/cli/compat/dreamdb.d.ts +112 -0
- package/dist/cli/compat/dreamdb.js +219 -0
- package/dist/cli/compat/flags.d.ts +2 -0
- package/dist/cli/compat/flags.js +13 -0
- package/dist/cli/compat/http.d.ts +23 -0
- package/dist/cli/compat/http.js +137 -0
- package/dist/cli/compat/presignedTransfer.d.ts +139 -0
- package/dist/cli/compat/presignedTransfer.js +580 -0
- package/dist/cli/compat/s3-backend.d.ts +73 -0
- package/dist/cli/compat/s3-backend.js +132 -0
- package/dist/cli/config.d.ts +22 -0
- package/dist/cli/config.js +96 -0
- package/dist/cli/connection/dto.d.ts +159 -0
- package/dist/cli/connection/dto.js +497 -0
- package/dist/cli/connection/index.d.ts +50 -0
- package/dist/cli/connection/index.js +413 -0
- package/dist/cli/connection/oauth.d.ts +23 -0
- package/dist/cli/connection/oauth.js +290 -0
- package/dist/cli/connection/write.d.ts +47 -0
- package/dist/cli/connection/write.js +573 -0
- package/dist/cli/create/index.d.ts +19 -0
- package/dist/cli/create/index.js +209 -0
- package/dist/cli/declare/index.d.ts +29 -0
- package/dist/cli/declare/index.js +304 -0
- package/dist/cli/delete/index.d.ts +18 -0
- package/dist/cli/delete/index.js +232 -0
- package/dist/cli/download/index.d.ts +9 -0
- package/dist/cli/download/index.js +128 -0
- package/dist/cli/env/compose.d.ts +88 -0
- package/dist/cli/env/compose.js +402 -0
- package/dist/cli/env/index.d.ts +176 -0
- package/dist/cli/env/index.js +1011 -0
- package/dist/cli/experiments/index.d.ts +11 -0
- package/dist/cli/experiments/index.js +168 -0
- package/dist/cli/glob.d.ts +1 -0
- package/dist/cli/glob.js +45 -0
- package/dist/cli/graphql-helpers.d.ts +23 -0
- package/dist/cli/graphql-helpers.js +42 -0
- package/dist/cli/graphql.d.ts +10 -0
- package/dist/cli/graphql.js +47 -0
- package/dist/cli/help-examples.generated.d.ts +1 -0
- package/dist/cli/help-examples.generated.js +192 -0
- package/dist/cli/helpers.d.ts +8 -0
- package/dist/cli/helpers.js +106 -0
- package/dist/cli/hosts/api.d.ts +29 -0
- package/dist/cli/hosts/api.js +54 -0
- package/dist/cli/hosts/bootstrap-source.d.ts +1 -0
- package/dist/cli/hosts/bootstrap-source.js +2 -0
- package/dist/cli/hosts/catalog.d.ts +26 -0
- package/dist/cli/hosts/catalog.js +55 -0
- package/dist/cli/hosts/config.d.ts +45 -0
- package/dist/cli/hosts/config.js +179 -0
- package/dist/cli/hosts/credentials.d.ts +19 -0
- package/dist/cli/hosts/credentials.js +173 -0
- package/dist/cli/hosts/enroll.d.ts +17 -0
- package/dist/cli/hosts/enroll.js +109 -0
- package/dist/cli/hosts/enrollments.d.ts +25 -0
- package/dist/cli/hosts/enrollments.js +54 -0
- package/dist/cli/hosts/index.d.ts +6 -0
- package/dist/cli/hosts/index.js +279 -0
- package/dist/cli/hosts/inventory.d.ts +40 -0
- package/dist/cli/hosts/inventory.js +91 -0
- package/dist/cli/hosts/lifecycle.d.ts +15 -0
- package/dist/cli/hosts/lifecycle.js +108 -0
- package/dist/cli/hosts/metrics-source.d.ts +12 -0
- package/dist/cli/hosts/metrics-source.js +89 -0
- package/dist/cli/hosts/observations.d.ts +39 -0
- package/dist/cli/hosts/observations.js +102 -0
- package/dist/cli/hosts/remote.d.ts +5 -0
- package/dist/cli/hosts/remote.js +66 -0
- package/dist/cli/hosts/ssh.d.ts +63 -0
- package/dist/cli/hosts/ssh.js +276 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +288 -0
- package/dist/cli/infra/api.d.ts +95 -0
- package/dist/cli/infra/api.js +291 -0
- package/dist/cli/infra/index.d.ts +5 -0
- package/dist/cli/infra/index.js +102 -0
- package/dist/cli/infra/move.d.ts +15 -0
- package/dist/cli/infra/move.js +123 -0
- package/dist/cli/infra/transfer.d.ts +15 -0
- package/dist/cli/infra/transfer.js +280 -0
- package/dist/cli/jobs/api.d.ts +69 -0
- package/dist/cli/jobs/api.js +121 -0
- package/dist/cli/jobs/index.d.ts +5 -0
- package/dist/cli/jobs/index.js +140 -0
- package/dist/cli/lakeshore/index.d.ts +98 -0
- package/dist/cli/lakeshore/index.js +502 -0
- package/dist/cli/launch/index.d.ts +43 -0
- package/dist/cli/launch/index.js +270 -0
- package/dist/cli/layout/index.d.ts +2 -0
- package/dist/cli/layout/index.js +44 -0
- package/dist/cli/layout/transport.d.ts +12 -0
- package/dist/cli/layout/transport.js +70 -0
- package/dist/cli/library/add.d.ts +60 -0
- package/dist/cli/library/add.js +348 -0
- package/dist/cli/library/cache.d.ts +26 -0
- package/dist/cli/library/cache.js +88 -0
- package/dist/cli/library/config.d.ts +75 -0
- package/dist/cli/library/config.js +198 -0
- package/dist/cli/library/digest.d.ts +5 -0
- package/dist/cli/library/digest.js +19 -0
- package/dist/cli/library/discover.d.ts +87 -0
- package/dist/cli/library/discover.js +534 -0
- package/dist/cli/library/freshness.d.ts +35 -0
- package/dist/cli/library/freshness.js +109 -0
- package/dist/cli/library/generation.d.ts +35 -0
- package/dist/cli/library/generation.js +211 -0
- package/dist/cli/library/index.d.ts +2 -0
- package/dist/cli/library/index.js +36 -0
- package/dist/cli/library/info.d.ts +69 -0
- package/dist/cli/library/info.js +311 -0
- package/dist/cli/library/list.d.ts +33 -0
- package/dist/cli/library/list.js +86 -0
- package/dist/cli/library/manifest.d.ts +81 -0
- package/dist/cli/library/manifest.js +200 -0
- package/dist/cli/library/manifestCache.d.ts +45 -0
- package/dist/cli/library/manifestCache.js +169 -0
- package/dist/cli/library/pull.d.ts +30 -0
- package/dist/cli/library/pull.js +438 -0
- package/dist/cli/library/push.d.ts +72 -0
- package/dist/cli/library/push.js +642 -0
- package/dist/cli/library/rm.d.ts +31 -0
- package/dist/cli/library/rm.js +200 -0
- package/dist/cli/library/search.d.ts +18 -0
- package/dist/cli/library/search.js +181 -0
- package/dist/cli/library/stat.d.ts +15 -0
- package/dist/cli/library/stat.js +127 -0
- package/dist/cli/library/tools.d.ts +104 -0
- package/dist/cli/library/tools.js +163 -0
- package/dist/cli/library/wire.d.ts +47 -0
- package/dist/cli/library/wire.js +120 -0
- package/dist/cli/list/index.d.ts +26 -0
- package/dist/cli/list/index.js +256 -0
- package/dist/cli/notes/character-plan.d.ts +22 -0
- package/dist/cli/notes/character-plan.js +232 -0
- package/dist/cli/notes/document.d.ts +73 -0
- package/dist/cli/notes/document.js +306 -0
- package/dist/cli/notes/edit-commands.d.ts +106 -0
- package/dist/cli/notes/edit-commands.js +623 -0
- package/dist/cli/notes/editing.d.ts +81 -0
- package/dist/cli/notes/editing.js +305 -0
- package/dist/cli/notes/events.d.ts +36 -0
- package/dist/cli/notes/events.js +54 -0
- package/dist/cli/notes/files-commands.d.ts +120 -0
- package/dist/cli/notes/files-commands.js +554 -0
- package/dist/cli/notes/html-read.d.ts +9 -0
- package/dist/cli/notes/html-read.js +90 -0
- package/dist/cli/notes/html.d.ts +73 -0
- package/dist/cli/notes/html.js +381 -0
- package/dist/cli/notes/index.d.ts +123 -0
- package/dist/cli/notes/index.js +1303 -0
- package/dist/cli/notes/linger.d.ts +59 -0
- package/dist/cli/notes/linger.js +339 -0
- package/dist/cli/notes/media-commands.d.ts +5 -0
- package/dist/cli/notes/media-commands.js +51 -0
- package/dist/cli/notes/move-command.d.ts +83 -0
- package/dist/cli/notes/move-command.js +259 -0
- package/dist/cli/notes/rm-command.d.ts +22 -0
- package/dist/cli/notes/rm-command.js +110 -0
- package/dist/cli/notes/select-command.d.ts +12 -0
- package/dist/cli/notes/select-command.js +84 -0
- package/dist/cli/notes/suggest-diff.d.ts +56 -0
- package/dist/cli/notes/suggest-diff.js +311 -0
- package/dist/cli/notes/toc.d.ts +38 -0
- package/dist/cli/notes/toc.js +144 -0
- package/dist/cli/notes/transfer-command.d.ts +6 -0
- package/dist/cli/notes/transfer-command.js +9 -0
- package/dist/cli/notes/version-commands.d.ts +19 -0
- package/dist/cli/notes/version-commands.js +178 -0
- package/dist/cli/nymph/index.d.ts +74 -0
- package/dist/cli/nymph/index.js +349 -0
- package/dist/cli/org/index.d.ts +34 -0
- package/dist/cli/org/index.js +341 -0
- package/dist/cli/ownership/index.d.ts +12 -0
- package/dist/cli/ownership/index.js +122 -0
- package/dist/cli/ownership/metadata-transfer.d.ts +20 -0
- package/dist/cli/ownership/metadata-transfer.js +159 -0
- package/dist/cli/page/index.d.ts +58 -0
- package/dist/cli/page/index.js +387 -0
- package/dist/cli/pipeline/index.d.ts +69 -0
- package/dist/cli/pipeline/index.js +604 -0
- package/dist/cli/progress.d.ts +60 -0
- package/dist/cli/progress.js +276 -0
- package/dist/cli/project/attachments.d.ts +10 -0
- package/dist/cli/project/attachments.js +39 -0
- package/dist/cli/project/grants.d.ts +10 -0
- package/dist/cli/project/grants.js +39 -0
- package/dist/cli/project/index.d.ts +8 -0
- package/dist/cli/project/index.js +92 -0
- package/dist/cli/project/move.d.ts +57 -0
- package/dist/cli/project/move.js +242 -0
- package/dist/cli/project/output.d.ts +2 -0
- package/dist/cli/project/output.js +29 -0
- package/dist/cli/project/stream.d.ts +55 -0
- package/dist/cli/project/stream.js +207 -0
- package/dist/cli/project/transfer-preview.d.ts +8 -0
- package/dist/cli/project/transfer-preview.js +10 -0
- package/dist/cli/prompt.d.ts +1 -0
- package/dist/cli/prompt.js +17 -0
- package/dist/cli/provider/dreamdir.d.ts +52 -0
- package/dist/cli/provider/dreamdir.js +138 -0
- package/dist/cli/provider/index.d.ts +4 -0
- package/dist/cli/provider/index.js +419 -0
- package/dist/cli/provider/jump-worker.d.ts +9 -0
- package/dist/cli/provider/jump-worker.js +141 -0
- package/dist/cli/provider/lifecycle.d.ts +149 -0
- package/dist/cli/provider/lifecycle.js +1390 -0
- package/dist/cli/provider/machine.d.ts +17 -0
- package/dist/cli/provider/machine.js +116 -0
- package/dist/cli/provider/ssh.d.ts +105 -0
- package/dist/cli/provider/ssh.js +305 -0
- package/dist/cli/provider/terraform.d.ts +140 -0
- package/dist/cli/provider/terraform.js +288 -0
- package/dist/cli/providers/index.d.ts +18 -0
- package/dist/cli/providers/index.js +422 -0
- package/dist/cli/python.d.ts +61 -0
- package/dist/cli/python.js +255 -0
- package/dist/cli/queues/index.d.ts +33 -0
- package/dist/cli/queues/index.js +248 -0
- package/dist/cli/queues/slurm.d.ts +10 -0
- package/dist/cli/queues/slurm.js +134 -0
- package/dist/cli/resources.d.ts +72 -0
- package/dist/cli/resources.js +137 -0
- package/dist/cli/run/index.d.ts +15 -0
- package/dist/cli/run/index.js +163 -0
- package/dist/cli/run/input.d.ts +34 -0
- package/dist/cli/run/input.js +135 -0
- package/dist/cli/run/recovery.d.ts +2 -0
- package/dist/cli/run/recovery.js +18 -0
- package/dist/cli/run/setup.d.ts +3 -0
- package/dist/cli/run/setup.js +62 -0
- package/dist/cli/runconfig/index.d.ts +12 -0
- package/dist/cli/runconfig/index.js +130 -0
- package/dist/cli/runnable/index.d.ts +35 -0
- package/dist/cli/runnable/index.js +575 -0
- package/dist/cli/runnable/path.d.ts +115 -0
- package/dist/cli/runnable/path.js +288 -0
- package/dist/cli/runnable/run.d.ts +91 -0
- package/dist/cli/runnable/run.js +239 -0
- package/dist/cli/runnable/upload.d.ts +43 -0
- package/dist/cli/runnable/upload.js +342 -0
- package/dist/cli/runnable/worker.d.ts +1 -0
- package/dist/cli/runnable/worker.js +44 -0
- package/dist/cli/schemas/workflow-spec.schema.json +335 -0
- package/dist/cli/self-update/index.d.ts +5 -0
- package/dist/cli/self-update/index.js +107 -0
- package/dist/cli/self-update/install.d.ts +60 -0
- package/dist/cli/self-update/install.js +428 -0
- package/dist/cli/self-update/paths.d.ts +40 -0
- package/dist/cli/self-update/paths.js +87 -0
- package/dist/cli/self-update/releases.d.ts +41 -0
- package/dist/cli/self-update/releases.js +153 -0
- package/dist/cli/self-update/settings.d.ts +16 -0
- package/dist/cli/self-update/settings.js +68 -0
- package/dist/cli/self-update/update.d.ts +18 -0
- package/dist/cli/self-update/update.js +241 -0
- package/dist/cli/service-accounts/index.d.ts +3 -0
- package/dist/cli/service-accounts/index.js +149 -0
- package/dist/cli/session-affiliation.d.ts +26 -0
- package/dist/cli/session-affiliation.js +135 -0
- package/dist/cli/sessions/affiliation.d.ts +8 -0
- package/dist/cli/sessions/affiliation.js +66 -0
- package/dist/cli/sessions/api.d.ts +55 -0
- package/dist/cli/sessions/api.js +88 -0
- package/dist/cli/sessions/control.d.ts +6 -0
- package/dist/cli/sessions/control.js +159 -0
- package/dist/cli/sessions/conversation.d.ts +15 -0
- package/dist/cli/sessions/conversation.js +118 -0
- package/dist/cli/sessions/index.d.ts +2 -0
- package/dist/cli/sessions/index.js +209 -0
- package/dist/cli/sessions/managed.d.ts +39 -0
- package/dist/cli/sessions/managed.js +63 -0
- package/dist/cli/sessions/redaction.d.ts +2 -0
- package/dist/cli/sessions/redaction.js +11 -0
- package/dist/cli/sessions/runner/exec.d.ts +108 -0
- package/dist/cli/sessions/runner/exec.js +335 -0
- package/dist/cli/sessions/runner/journal.d.ts +26 -0
- package/dist/cli/sessions/runner/journal.js +49 -0
- package/dist/cli/sessions/runner/native.d.ts +48 -0
- package/dist/cli/sessions/runner/native.js +170 -0
- package/dist/cli/sessions/runner/pod.d.ts +30 -0
- package/dist/cli/sessions/runner/pod.js +129 -0
- package/dist/cli/sessions/runner/serve.d.ts +85 -0
- package/dist/cli/sessions/runner/serve.js +558 -0
- package/dist/cli/sessions/sync.d.ts +47 -0
- package/dist/cli/sessions/sync.js +80 -0
- package/dist/cli/sessions/transport.d.ts +14 -0
- package/dist/cli/sessions/transport.js +116 -0
- package/dist/cli/share.d.ts +15 -0
- package/dist/cli/share.js +139 -0
- package/dist/cli/skill/catalog.d.ts +141 -0
- package/dist/cli/skill/catalog.js +442 -0
- package/dist/cli/skill/files.d.ts +89 -0
- package/dist/cli/skill/files.js +264 -0
- package/dist/cli/skill/index.d.ts +268 -0
- package/dist/cli/skill/index.js +1216 -0
- package/dist/cli/skill/manifest.d.ts +30 -0
- package/dist/cli/skill/manifest.js +101 -0
- package/dist/cli/skill/prefs.d.ts +9 -0
- package/dist/cli/skill/prefs.js +32 -0
- package/dist/cli/skill/reminders.d.ts +15 -0
- package/dist/cli/skill/reminders.js +105 -0
- package/dist/cli/skill/tar.d.ts +17 -0
- package/dist/cli/skill/tar.js +195 -0
- package/dist/cli/snapshot/index.d.ts +24 -0
- package/dist/cli/snapshot/index.js +146 -0
- package/dist/cli/source/access.d.ts +45 -0
- package/dist/cli/source/access.js +563 -0
- package/dist/cli/source/control.d.ts +103 -0
- package/dist/cli/source/control.js +546 -0
- package/dist/cli/source/delete.d.ts +89 -0
- package/dist/cli/source/delete.js +463 -0
- package/dist/cli/source/index.d.ts +288 -0
- package/dist/cli/source/index.js +1348 -0
- package/dist/cli/source/share.d.ts +65 -0
- package/dist/cli/source/share.js +530 -0
- package/dist/cli/source/upload.d.ts +62 -0
- package/dist/cli/source/upload.js +258 -0
- package/dist/cli/source/write.d.ts +77 -0
- package/dist/cli/source/write.js +335 -0
- package/dist/cli/spawn.d.ts +28 -0
- package/dist/cli/spawn.js +81 -0
- package/dist/cli/target.d.ts +22 -0
- package/dist/cli/target.js +85 -0
- package/dist/cli/tasks/index.d.ts +38 -0
- package/dist/cli/tasks/index.js +365 -0
- package/dist/cli/team/index.d.ts +37 -0
- package/dist/cli/team/index.js +407 -0
- package/dist/cli/telemetry.d.ts +23 -0
- package/dist/cli/telemetry.js +262 -0
- package/dist/cli/telemetryJournal.d.ts +26 -0
- package/dist/cli/telemetryJournal.js +104 -0
- package/dist/cli/update/index.d.ts +21 -0
- package/dist/cli/update/index.js +284 -0
- package/dist/cli/upload/index.d.ts +11 -0
- package/dist/cli/upload/index.js +261 -0
- package/dist/cli/upload/kinds.d.ts +10 -0
- package/dist/cli/upload/kinds.js +85 -0
- package/dist/cli/upload/multipart.d.ts +21 -0
- package/dist/cli/upload/multipart.js +248 -0
- package/dist/cli/vault/affected-preview.d.ts +15 -0
- package/dist/cli/vault/affected-preview.js +38 -0
- package/dist/cli/vault/cloud.d.ts +55 -0
- package/dist/cli/vault/cloud.js +287 -0
- package/dist/cli/vault/format.d.ts +18 -0
- package/dist/cli/vault/format.js +104 -0
- package/dist/cli/vault/hostCredentials.d.ts +21 -0
- package/dist/cli/vault/hostCredentials.js +71 -0
- package/dist/cli/vault/hostSupersessions.d.ts +18 -0
- package/dist/cli/vault/hostSupersessions.js +68 -0
- package/dist/cli/vault/import.d.ts +3 -0
- package/dist/cli/vault/import.js +79 -0
- package/dist/cli/vault/index.d.ts +14 -0
- package/dist/cli/vault/index.js +225 -0
- package/dist/cli/vault/keys.d.ts +5 -0
- package/dist/cli/vault/keys.js +165 -0
- package/dist/cli/vault/kms.d.ts +6 -0
- package/dist/cli/vault/kms.js +169 -0
- package/dist/cli/vault/list.d.ts +13 -0
- package/dist/cli/vault/list.js +60 -0
- package/dist/cli/vault/listView.d.ts +21 -0
- package/dist/cli/vault/listView.js +123 -0
- package/dist/cli/vault/managementMetadata.d.ts +2 -0
- package/dist/cli/vault/managementMetadata.js +23 -0
- package/dist/cli/vault/mutations.d.ts +8 -0
- package/dist/cli/vault/mutations.js +151 -0
- package/dist/cli/vault/otp.d.ts +6 -0
- package/dist/cli/vault/otp.js +62 -0
- package/dist/cli/vault/otpIntent.d.ts +23 -0
- package/dist/cli/vault/otpIntent.js +76 -0
- package/dist/cli/vault/passImport.d.ts +25 -0
- package/dist/cli/vault/passImport.js +129 -0
- package/dist/cli/vault/passOtp.d.ts +51 -0
- package/dist/cli/vault/passOtp.js +101 -0
- package/dist/cli/vault/passStore.d.ts +26 -0
- package/dist/cli/vault/passStore.js +134 -0
- package/dist/cli/vault/passwordCommand.d.ts +39 -0
- package/dist/cli/vault/passwordCommand.js +101 -0
- package/dist/cli/vault/passwordProbe.d.ts +27 -0
- package/dist/cli/vault/passwordProbe.js +282 -0
- package/dist/cli/vault/passwordRotation.d.ts +9 -0
- package/dist/cli/vault/passwordRotation.js +273 -0
- package/dist/cli/vault/rotationApi.d.ts +13 -0
- package/dist/cli/vault/rotationApi.js +58 -0
- package/dist/cli/vault/rotationCommand.d.ts +2 -0
- package/dist/cli/vault/rotationCommand.js +75 -0
- package/dist/cli/vault/rotationEngine.d.ts +19 -0
- package/dist/cli/vault/rotationEngine.js +65 -0
- package/dist/cli/vault/rotationHelperSource.d.ts +2 -0
- package/dist/cli/vault/rotationHelperSource.js +3 -0
- package/dist/cli/vault/rotationInput.d.ts +11 -0
- package/dist/cli/vault/rotationInput.js +48 -0
- package/dist/cli/vault/rotationJournal.d.ts +16 -0
- package/dist/cli/vault/rotationJournal.js +183 -0
- package/dist/cli/vault/rotationKeys.d.ts +4 -0
- package/dist/cli/vault/rotationKeys.js +48 -0
- package/dist/cli/vault/rotationPrepare.d.ts +17 -0
- package/dist/cli/vault/rotationPrepare.js +108 -0
- package/dist/cli/vault/rotationRemote.d.ts +33 -0
- package/dist/cli/vault/rotationRemote.js +156 -0
- package/dist/cli/vault/rotationState.d.ts +42 -0
- package/dist/cli/vault/rotationState.js +115 -0
- package/dist/cli/vault/rotationTransport.d.ts +18 -0
- package/dist/cli/vault/rotationTransport.js +71 -0
- package/dist/cli/vault/sshSource.d.ts +18 -0
- package/dist/cli/vault/sshSource.js +196 -0
- package/dist/cli/vault/sshSync.d.ts +17 -0
- package/dist/cli/vault/sshSync.js +224 -0
- package/dist/cli/vault/sshTransfer.d.ts +22 -0
- package/dist/cli/vault/sshTransfer.js +140 -0
- package/dist/cli/vault/terraformState.d.ts +66 -0
- package/dist/cli/vault/terraformState.js +252 -0
- package/dist/cli/vault/terraformStateCommand.d.ts +2 -0
- package/dist/cli/vault/terraformStateCommand.js +61 -0
- package/dist/cli/vault/tree.d.ts +43 -0
- package/dist/cli/vault/tree.js +292 -0
- package/dist/cli/version.d.ts +1 -0
- package/dist/cli/version.js +9 -0
- package/dist/cli/workflow/index.d.ts +76 -0
- package/dist/cli/workflow/index.js +826 -0
- package/dist/cli/workflow/validate.d.ts +19 -0
- package/dist/cli/workflow/validate.js +353 -0
- package/dist/package.json +1 -0
- package/package.json +28 -10
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { runProjectStreamMove } from './stream.js';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { performance } from 'node:perf_hooks';
|
|
5
|
+
import { requestJson } from '../client.js';
|
|
6
|
+
import { resolveCtx } from '../compat/ctx.js';
|
|
7
|
+
import { emitProjectResult } from './output.js';
|
|
8
|
+
import { fail } from '../helpers.js';
|
|
9
|
+
const segment = encodeURIComponent;
|
|
10
|
+
const nonempty = (s) => typeof s === 'string' && !!s.trim();
|
|
11
|
+
const validId = (s) => typeof s === 'string' && /^[a-f0-9]{24}$/i.test(s);
|
|
12
|
+
const equal = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
13
|
+
const quoted = (s) => "'" + s.replace(/'/g, "'\"'\"'") + "'";
|
|
14
|
+
const states = ['pending', 'preparing', 'committing', 'completed', 'rejected', 'cancelled', 'expired', 'aborting', 'aborted', 'recovery-required'];
|
|
15
|
+
const resourceKey = (ref) => `${ref.type}:${ref.id.toLowerCase()}`;
|
|
16
|
+
const transferTypes = new Set(['project', 'note', 'artifact', 'env']);
|
|
17
|
+
const validRef = (ref) => !!ref && typeof ref === 'object' && !Array.isArray(ref) &&
|
|
18
|
+
Object.keys(ref).length === 2 && validId(ref.id) && transferTypes.has(ref.type);
|
|
19
|
+
export function validateProjectTransferPlan(plan, id) {
|
|
20
|
+
const invalid = () => { throw new Error('Invalid whole-Project transfer plan; no partial transfer is permitted'); };
|
|
21
|
+
if (!plan || plan.apiVersion !== 1 || !validRef(plan.resource) || plan.resource.type !== 'project' || plan.resource.id !== id ||
|
|
22
|
+
!nonempty(plan.ownerNamespaceId) || !nonempty(plan.version) || !nonempty(plan.projectName) ||
|
|
23
|
+
typeof plan.executable !== 'boolean' || !Array.isArray(plan.manifest) || !Array.isArray(plan.noteNames) ||
|
|
24
|
+
!Number.isSafeInteger(plan.limits?.maxNotes) || plan.limits.maxNotes < 0 ||
|
|
25
|
+
!Number.isSafeInteger(plan.limits.maxTreeNodes) || plan.limits.maxTreeNodes < 1)
|
|
26
|
+
return invalid();
|
|
27
|
+
if (Object.hasOwn(plan.limits, 'maxResources') && (!Number.isSafeInteger(plan.limits.maxResources) || plan.limits.maxResources < 1))
|
|
28
|
+
return invalid();
|
|
29
|
+
const maxResources = plan.limits.maxResources ?? plan.limits.maxNotes + 1;
|
|
30
|
+
if (!Number.isSafeInteger(maxResources) || maxResources < 1 || plan.manifest.length < 1 || plan.manifest.length > maxResources ||
|
|
31
|
+
!equal(plan.manifest[0], plan.resource) || plan.manifest.some((ref, index) => !validRef(ref) || (index > 0 && ref.type === 'project')) ||
|
|
32
|
+
new Set(plan.manifest.map(resourceKey)).size !== plan.manifest.length)
|
|
33
|
+
return invalid();
|
|
34
|
+
const notes = plan.manifest.filter(ref => ref.type === 'note');
|
|
35
|
+
if (notes.length > plan.limits.maxNotes || plan.noteNames.length !== notes.length ||
|
|
36
|
+
plan.noteNames.some(note => !note || !validId(note.id) || !nonempty(note.name) || !notes.some(ref => ref.id === note.id)) ||
|
|
37
|
+
new Set(plan.noteNames.map(note => note.id.toLowerCase())).size !== notes.length)
|
|
38
|
+
return invalid();
|
|
39
|
+
const members = plan.manifest.slice(1);
|
|
40
|
+
if (!Object.hasOwn(plan, 'resourceNames')) {
|
|
41
|
+
// A legacy Note-only plan still carries every non-root name in noteNames.
|
|
42
|
+
if (members.some(ref => ref.type !== 'note'))
|
|
43
|
+
return invalid();
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const names = plan.resourceNames;
|
|
47
|
+
if (!Array.isArray(names) || names.length !== members.length ||
|
|
48
|
+
names.some(row => !row || !validId(row.id) || !nonempty(row.name) ||
|
|
49
|
+
!members.some(ref => ref.type === row.type && ref.id === row.id)) ||
|
|
50
|
+
new Set(names.map(resourceKey)).size !== members.length ||
|
|
51
|
+
plan.noteNames.some(note => !names.some(row => row.type === 'note' && row.id === note.id && row.name === note.name)) ||
|
|
52
|
+
(members.some(ref => ref.type !== 'note') && plan.limits.maxResources === undefined))
|
|
53
|
+
return invalid();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function resourceCounts(plan) {
|
|
57
|
+
return Object.fromEntries(['project', 'note', 'artifact', 'env'].map(type => [type, plan.manifest.filter(ref => ref.type === type).length]));
|
|
58
|
+
}
|
|
59
|
+
function validateRequest(request, plan, destinationId) {
|
|
60
|
+
if (request?.apiVersion !== 1 || !equal(request.resource, plan.resource) ||
|
|
61
|
+
request.expectedOwner !== plan.ownerNamespaceId || request.expectedVersion !== plan.version ||
|
|
62
|
+
request.destinationNamespaceId !== destinationId || !equal(request.manifest, plan.manifest) ||
|
|
63
|
+
!nonempty(request.destinationName) || request.destinationName.length > 200 ||
|
|
64
|
+
!nonempty(request.idempotencyKey) || request.idempotencyKey.length > 200 ||
|
|
65
|
+
request.policy?.visibility !== 'private' || !Array.isArray(request.policy.retainedGrantIds) || request.policy.retainedGrantIds.length !== 0 ||
|
|
66
|
+
typeof request.policy.preserveAccess !== 'boolean' || typeof request.policy.preserveExternalFilings !== 'boolean' ||
|
|
67
|
+
(request.destinationNames !== undefined && (!Array.isArray(request.destinationNames) ||
|
|
68
|
+
new Set(request.destinationNames.map(row => row.resource?.id)).size !== request.destinationNames.length ||
|
|
69
|
+
request.destinationNames.some(row => row.resource?.type !== 'note' || !plan.manifest.some(ref => equal(ref, row.resource)) || !nonempty(row.name) || row.name.length > 200)))) {
|
|
70
|
+
throw new Error('Transfer request must match the complete Project plan, valid names and private policy; review corrected inputs');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function validatePreview(preview, request, modernPlan) {
|
|
74
|
+
if (preview?.apiVersion !== 1 || !equal(preview.resource, request.resource) ||
|
|
75
|
+
preview.sourceNamespaceId !== request.expectedOwner || preview.destinationNamespaceId !== request.destinationNamespaceId ||
|
|
76
|
+
preview.expectedVersion !== request.expectedVersion || !equal(preview.manifest, request.manifest) || !nonempty(preview.previewHash) ||
|
|
77
|
+
!Array.isArray(preview.blockers) || preview.blockers.some(b => !nonempty(b.code) || !nonempty(b.action)) ||
|
|
78
|
+
!preview.summary || preview.summary.includedCount !== request.manifest.length ||
|
|
79
|
+
[preview.summary.includedCount, preview.summary.retainedFilings, preview.summary.detachedFilings].some(n => !Number.isSafeInteger(n) || n < 0) ||
|
|
80
|
+
preview.summary.becomesPrivate !== true ||
|
|
81
|
+
((modernPlan || preview.summary.detachedOtherFilings !== undefined) && (!Number.isSafeInteger(preview.summary.detachedOtherFilings) ||
|
|
82
|
+
preview.summary.detachedOtherFilings < 0 || preview.summary.detachedOtherFilings > preview.summary.detachedFilings)))
|
|
83
|
+
throw new Error('Invalid transfer preview; nothing submitted');
|
|
84
|
+
}
|
|
85
|
+
function validateOperation(op, request) {
|
|
86
|
+
if (op?.apiVersion !== 1 || !validId(op.id) || !states.includes(op.state) ||
|
|
87
|
+
op.sourceNamespaceId !== request.expectedOwner || op.destinationNamespaceId !== request.destinationNamespaceId ||
|
|
88
|
+
!equal(op.resource, request.resource) || op.previewHash !== request.previewHash) {
|
|
89
|
+
throw new Error('Invalid operation response; submission outcome is unknown. Reuse the exact saved request and idempotency key');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** New Project moves always use the server's streaming coordinator. */
|
|
93
|
+
export async function runProjectMove(project, opts) {
|
|
94
|
+
opts = { ...opts, acceptIfOwner: opts.acceptIfOwner === true || opts.acceptIfAuthorized === true };
|
|
95
|
+
if (opts.requestFile && !opts.stream) {
|
|
96
|
+
let saved;
|
|
97
|
+
try {
|
|
98
|
+
saved = JSON.parse(readFileSync(opts.requestFile, 'utf8'));
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
fail('Cannot read saved Project transfer review; reuse the exact reviewed file');
|
|
102
|
+
return 1;
|
|
103
|
+
}
|
|
104
|
+
if (saved?.mode !== 'stream')
|
|
105
|
+
return runLegacyProjectMove(project, opts);
|
|
106
|
+
}
|
|
107
|
+
return runProjectStreamMove(project, opts.requestFile ? opts : { ...opts,
|
|
108
|
+
preserveAccess: opts.preserveAccess ?? true, preserveExternalFilings: opts.preserveExternalFilings ?? true });
|
|
109
|
+
}
|
|
110
|
+
/** Compatibility for exact saved legacy reviews. The command never selects this
|
|
111
|
+
* for new moves; the API remains authoritative about existing-request replay. */
|
|
112
|
+
export async function runLegacyProjectMove(project, opts) {
|
|
113
|
+
opts = { ...opts, acceptIfOwner: opts.acceptIfOwner === true || opts.acceptIfAuthorized === true };
|
|
114
|
+
try {
|
|
115
|
+
const source = (opts.namespace ?? '').trim().replace(/^@/, ''), destination = (opts.to ?? '').trim().replace(/^@/, '');
|
|
116
|
+
if (!source || !destination || !project.trim() || source === destination)
|
|
117
|
+
throw new Error('Choose an explicit source namespace, Project, and different destination namespace');
|
|
118
|
+
if (opts.dryRun && opts.confirm)
|
|
119
|
+
throw new Error('--dry-run cannot submit a transfer');
|
|
120
|
+
if (opts.wait && !opts.acceptIfOwner)
|
|
121
|
+
throw new Error('--wait requires --accept-if-authorized; another recipient must accept their own request');
|
|
122
|
+
const timeout = opts.waitTimeout ?? 30;
|
|
123
|
+
if (!Number.isSafeInteger(timeout) || timeout < 0 || timeout > 60)
|
|
124
|
+
throw new Error('--wait-timeout must be an integer from 0 to 60 seconds');
|
|
125
|
+
if (opts.confirm && !opts.requestFile && (!nonempty(opts.previewHash) || (!nonempty(opts.idempotencyKey) && !opts.out))) {
|
|
126
|
+
throw new Error('Submit only with --confirm and a reviewed --request-file, or --preview-hash plus a stable --idempotency-key/--out file');
|
|
127
|
+
}
|
|
128
|
+
if (opts.requestFile && (opts.out || opts.name || opts.renameNote?.length || opts.idempotencyKey))
|
|
129
|
+
throw new Error('Replay the saved request unchanged; do not combine --request-file with request overrides');
|
|
130
|
+
const c = resolveCtx(opts);
|
|
131
|
+
if (!c.token)
|
|
132
|
+
throw new Error("Not authenticated — run 'dreamlake login' first");
|
|
133
|
+
const get = (path, timeoutMs) => requestJson(c.remote, path, { token: c.token, redirect: 'error', timeoutMs });
|
|
134
|
+
const post = (path, json) => requestJson(c.remote, path, { token: c.token, method: 'POST', json, redirect: 'error' });
|
|
135
|
+
const base = `/namespaces/${segment(source)}/ownership`;
|
|
136
|
+
const target = await get(`/namespaces/${segment(destination)}/ownership/capabilities`);
|
|
137
|
+
if (target?.apiVersion !== 1 || !nonempty(target.namespaceId))
|
|
138
|
+
throw new Error('Destination namespace identity could not be verified');
|
|
139
|
+
const saved = opts.requestFile ? JSON.parse(readFileSync(opts.requestFile, 'utf8')) : undefined;
|
|
140
|
+
let plan;
|
|
141
|
+
if (saved) {
|
|
142
|
+
if (!opts.confirm || opts.dryRun || saved.source !== source || saved.destination !== destination ||
|
|
143
|
+
saved.plan?.projectName !== project.trim() || saved.ready !== true || !validId(saved.plan?.resource?.id)) {
|
|
144
|
+
throw new Error('Replay requires --confirm and the matching complete review bundle produced by project move --dry-run');
|
|
145
|
+
}
|
|
146
|
+
plan = saved.plan;
|
|
147
|
+
validateProjectTransferPlan(plan, plan.resource.id);
|
|
148
|
+
const authority = await get(`${base}/capabilities`);
|
|
149
|
+
if (authority?.apiVersion !== 1 || authority.namespaceId !== plan.ownerNamespaceId)
|
|
150
|
+
throw new Error('Saved source namespace identity could not be verified');
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const resource = await get(`/namespaces/${segment(source)}/projects/${segment(project.trim())}`);
|
|
154
|
+
if (!validId(resource?.id))
|
|
155
|
+
throw new Error('Invalid Project identity');
|
|
156
|
+
plan = await get(`${base}/resources/project/${segment(resource.id)}/transfer-plan`);
|
|
157
|
+
validateProjectTransferPlan(plan, resource.id);
|
|
158
|
+
}
|
|
159
|
+
if (target.namespaceId === plan.ownerNamespaceId)
|
|
160
|
+
throw new Error('Destination is the current owner');
|
|
161
|
+
const request = saved?.request ?? {
|
|
162
|
+
apiVersion: 1, resource: plan.resource, expectedOwner: plan.ownerNamespaceId, expectedVersion: plan.version,
|
|
163
|
+
destinationNamespaceId: target.namespaceId, destinationName: opts.name ?? plan.projectName,
|
|
164
|
+
manifest: plan.manifest, idempotencyKey: opts.idempotencyKey ?? randomUUID(),
|
|
165
|
+
policy: { visibility: 'private', retainedGrantIds: [], preserveAccess: opts.preserveAccess === true, preserveExternalFilings: opts.preserveExternalFilings === true },
|
|
166
|
+
...(opts.renameNote?.length ? { destinationNames: opts.renameNote.map(value => {
|
|
167
|
+
const at = value.indexOf('=');
|
|
168
|
+
if (at < 1 || !validId(value.slice(0, at)) || !nonempty(value.slice(at + 1)))
|
|
169
|
+
throw new Error('--rename-note requires NOTE_ID=NAME from this complete Project plan');
|
|
170
|
+
return { resource: { type: 'note', id: value.slice(0, at) }, name: value.slice(at + 1) };
|
|
171
|
+
}) } : {}),
|
|
172
|
+
};
|
|
173
|
+
validateRequest(request, plan, target.namespaceId);
|
|
174
|
+
if (saved && ((opts.preserveAccess && !request.policy.preserveAccess) || (opts.preserveExternalFilings && !request.policy.preserveExternalFilings))) {
|
|
175
|
+
throw new Error('Policy flags differ from the saved reviewed request');
|
|
176
|
+
}
|
|
177
|
+
const reviewedHash = opts.previewHash ?? request.previewHash;
|
|
178
|
+
const previewRequest = { ...request };
|
|
179
|
+
delete previewRequest.previewHash;
|
|
180
|
+
// A replay must reach the journal even if the original Project has already moved.
|
|
181
|
+
const preview = saved?.preview ?? await post(`${base}/transfers/preview`, previewRequest);
|
|
182
|
+
validatePreview(preview, request, Object.hasOwn(plan, 'resourceNames'));
|
|
183
|
+
request.previewHash = preview.previewHash;
|
|
184
|
+
const ready = plan.executable && preview.blockers.length === 0;
|
|
185
|
+
const counts = resourceCounts(plan);
|
|
186
|
+
const review = { source, destination, ready, plan, request, preview, resourceCounts: counts };
|
|
187
|
+
if (opts.out)
|
|
188
|
+
writeFileSync(opts.out, JSON.stringify(review, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
|
|
189
|
+
if (!opts.confirm || opts.dryRun || !ready) {
|
|
190
|
+
emitProjectResult(review, () => [
|
|
191
|
+
`${source}/${project} → ${destination}/${request.destinationName}: ${ready ? 'ready for review' : 'transfer unavailable'}`,
|
|
192
|
+
`Whole Project + ${counts.note} Notes + ${counts.artifact} Artifacts + ${counts.env} Envs; all become private.`,
|
|
193
|
+
`External filings: ${preview.summary.retainedFilings} retained, ${preview.summary.detachedFilings} detached.`,
|
|
194
|
+
`Only external Note filings can be retained; Artifact/Env attachments in other Projects always detach${preview.summary.detachedOtherFilings === undefined ? '.' : ` (${preview.summary.detachedOtherFilings} detached).`}`,
|
|
195
|
+
`Preserve existing access: ${request.policy.preserveAccess ? 'requested; inspect exact server inventory in --json' : 'no'}.`,
|
|
196
|
+
`Preview hash: ${preview.previewHash}; idempotency key: ${request.idempotencyKey}.`,
|
|
197
|
+
...preview.blockers.map(b => `${b.code}: ${b.action}`),
|
|
198
|
+
...(plan.executable ? [] : ['Server execution gate is disabled.']),
|
|
199
|
+
'Nothing moved. Save --json output (or --out) and review its full inventory before --confirm --request-file.',
|
|
200
|
+
].join('\n'), opts.json);
|
|
201
|
+
return ready ? 0 : 3;
|
|
202
|
+
}
|
|
203
|
+
if (!nonempty(reviewedHash) || reviewedHash !== preview.previewHash)
|
|
204
|
+
throw new Error('STALE_PREVIEW: exact reviewed preview hash required; nothing submitted');
|
|
205
|
+
if (opts.acceptIfOwner && (preview.destinationAuthority?.allowed !== true || preview.destinationAuthority.namespaceId !== target.namespaceId || preview.destinationAuthority.action !== 'ownership.accept' ||
|
|
206
|
+
(saved && target.capabilities?.['ownership.accept']?.allowed !== true))) {
|
|
207
|
+
throw new Error('Destination ownership acceptance authority was not verified; omit --accept-if-authorized to request recipient acceptance');
|
|
208
|
+
}
|
|
209
|
+
let operation = await post(`${base}/transfers`, request);
|
|
210
|
+
validateOperation(operation, request);
|
|
211
|
+
const targetBase = `/namespaces/${segment(destination)}/ownership/transfers/${segment(operation.id)}`;
|
|
212
|
+
// No mutation is retried. A saved request/key survives uncertain create outcomes.
|
|
213
|
+
if (opts.acceptIfOwner && operation.state === 'pending') {
|
|
214
|
+
operation = await post(`${targetBase}/accept`);
|
|
215
|
+
validateOperation(operation, request);
|
|
216
|
+
}
|
|
217
|
+
const deadline = performance.now() + timeout * 1000;
|
|
218
|
+
while (opts.wait && ['preparing', 'committing', 'aborting'].includes(operation.state) && performance.now() < deadline) {
|
|
219
|
+
try {
|
|
220
|
+
operation = await get(targetBase, Math.max(1, Math.min(30000, Math.ceil(deadline - performance.now()))));
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (['TimeoutError', 'AbortError'].includes(error.name))
|
|
224
|
+
break;
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
validateOperation(operation, request);
|
|
228
|
+
if (!['preparing', 'committing', 'aborting'].includes(operation.state) || performance.now() >= deadline)
|
|
229
|
+
break;
|
|
230
|
+
await new Promise(resolve => setTimeout(resolve, Math.min(1000, Math.max(0, deadline - performance.now()))));
|
|
231
|
+
}
|
|
232
|
+
const nextAction = operation.state === 'pending'
|
|
233
|
+
? `dreamlake ownership accept ${operation.id} --namespace ${quoted(destination)}`
|
|
234
|
+
: `dreamlake ownership status ${operation.id} --namespace ${quoted(source)}`;
|
|
235
|
+
emitProjectResult({ ...review, operation, nextAction, timedOut: !!opts.wait && ['preparing', 'committing', 'aborting'].includes(operation.state) }, () => `Transfer ${operation.id}: ${operation.state}.\n${nextAction}`, opts.json);
|
|
236
|
+
return ['rejected', 'cancelled', 'expired', 'aborted', 'recovery-required'].includes(operation.state) ? 3 : 0;
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
fail(error.message);
|
|
240
|
+
return 1;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { emitJson, renderTable } from '../helpers.js';
|
|
2
|
+
// Terminal summaries are presentation only. Piped output keeps the existing JSON contract.
|
|
3
|
+
export function emitProjectResult(result, summary, json) {
|
|
4
|
+
if (json || !process.stdout.isTTY)
|
|
5
|
+
emitJson(result);
|
|
6
|
+
else
|
|
7
|
+
process.stdout.write(summary() + '\n');
|
|
8
|
+
}
|
|
9
|
+
const cell = (value) => typeof value === 'string'
|
|
10
|
+
? value.replace(/[\x00-\x1f\x7f-\x9f]/g, ' ') : 'unknown';
|
|
11
|
+
export function projectSummary(action, namespace, project, result) {
|
|
12
|
+
const heading = `${cell(namespace)}/${cell(project)}`;
|
|
13
|
+
if (action === 'inspect') {
|
|
14
|
+
const access = result.permissions;
|
|
15
|
+
const canManage = access.project?.manageGrants;
|
|
16
|
+
return `${heading}\nYour access: ${cell(access.role)}\nManage grants: ${canManage === true ? 'yes' : canManage === false ? 'no' : 'unknown'}`;
|
|
17
|
+
}
|
|
18
|
+
const rows = result.grants.map((grant) => ({
|
|
19
|
+
ID: cell(grant.id),
|
|
20
|
+
Recipient: grant.teamId ? `team:${cell(grant.team?.slug ?? grant.teamId)}` : cell(grant.grantee?.slug ?? grant.granteeId),
|
|
21
|
+
Role: cell(grant.role),
|
|
22
|
+
Effective: grant.teamId ? 'per member' : cell(grant.effectiveRole),
|
|
23
|
+
}));
|
|
24
|
+
const baseline = result.baseline;
|
|
25
|
+
const inherited = baseline
|
|
26
|
+
? `Inherited access: org members ${baseline.orgMembers == null ? 'none' : cell(baseline.orgMembers)}; namespace owners ${cell(baseline.namespaceOwners)}; public ${baseline.public == null ? 'none' : cell(baseline.public)}`
|
|
27
|
+
: 'Inherited access: unavailable from this server';
|
|
28
|
+
return `${heading}\n${renderTable(rows, ['ID', 'Recipient', 'Role', 'Effective']).trimEnd()}\n${inherited}`;
|
|
29
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ProjectMoveOptions } from './move.js';
|
|
2
|
+
type Root = {
|
|
3
|
+
type: 'project';
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
6
|
+
export type StreamOperation = {
|
|
7
|
+
apiVersion: 1;
|
|
8
|
+
mode: 'stream';
|
|
9
|
+
streamVersion: 1 | 2;
|
|
10
|
+
id: string;
|
|
11
|
+
resource: Root;
|
|
12
|
+
sourceNamespaceId: string;
|
|
13
|
+
destinationNamespaceId: string;
|
|
14
|
+
previewHash: string;
|
|
15
|
+
state: string;
|
|
16
|
+
};
|
|
17
|
+
export type StreamProgress = {
|
|
18
|
+
apiVersion: 1;
|
|
19
|
+
mode: 'stream';
|
|
20
|
+
streamVersion: 1 | 2;
|
|
21
|
+
operationId: string;
|
|
22
|
+
state: string;
|
|
23
|
+
phase: string;
|
|
24
|
+
cursor: string | null;
|
|
25
|
+
counters: {
|
|
26
|
+
discovered: number;
|
|
27
|
+
prepared: number;
|
|
28
|
+
committed: number;
|
|
29
|
+
pending: number;
|
|
30
|
+
};
|
|
31
|
+
finalWatermark: string | null;
|
|
32
|
+
};
|
|
33
|
+
type Capability = {
|
|
34
|
+
apiVersion: 1;
|
|
35
|
+
namespaceId: string;
|
|
36
|
+
projectTransferStream?: {
|
|
37
|
+
apiVersion: 1;
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
resumeEnabled?: boolean;
|
|
40
|
+
streamVersions?: number[];
|
|
41
|
+
defaultStreamVersion?: number;
|
|
42
|
+
};
|
|
43
|
+
capabilities?: Record<string, {
|
|
44
|
+
allowed: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
export declare function requireStreamCapability(c: Capability, action?: 'admit' | 'resume'): void;
|
|
48
|
+
export declare function selectProjectStreamVersion(c: Capability): 1 | 2;
|
|
49
|
+
export declare function validateStreamOperation(op: StreamOperation, expected: Partial<StreamOperation> & {
|
|
50
|
+
id?: string;
|
|
51
|
+
}): void;
|
|
52
|
+
export declare function validateStreamProgress(p: StreamProgress, operationId: string, streamVersion?: 1 | 2): void;
|
|
53
|
+
/** An explicit, separately gated protocol. The server owns dynamic closure/cursors. */
|
|
54
|
+
export declare function runProjectStreamMove(project: string, opts: ProjectMoveOptions): Promise<number>;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { performance } from 'node:perf_hooks';
|
|
4
|
+
import { requestJson } from '../client.js';
|
|
5
|
+
import { resolveCtx } from '../compat/ctx.js';
|
|
6
|
+
import { fail } from '../helpers.js';
|
|
7
|
+
import { emitProjectResult } from './output.js';
|
|
8
|
+
const states = new Set(['pending', 'preparing', 'committing', 'completed', 'rejected', 'cancelled', 'expired', 'aborting', 'aborted', 'recovery-required']);
|
|
9
|
+
const busy = new Set(['preparing', 'committing', 'aborting']);
|
|
10
|
+
const failed = new Set(['rejected', 'cancelled', 'expired', 'aborted', 'recovery-required']);
|
|
11
|
+
const id = (v) => typeof v === 'string' && /^[a-f0-9]{24}$/i.test(v);
|
|
12
|
+
const text = (v) => typeof v === 'string' && !!v.trim();
|
|
13
|
+
const equal = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
14
|
+
const versioned = (v) => v?.apiVersion === 1 && v.mode === 'stream' && (v.streamVersion === 1 || v.streamVersion === 2);
|
|
15
|
+
const root = (v) => v?.type === 'project' && id(v.id) && Object.keys(v).length === 2;
|
|
16
|
+
const count = (v) => Number.isSafeInteger(v) && v >= 0;
|
|
17
|
+
export function requireStreamCapability(c, action = 'admit') {
|
|
18
|
+
if (c?.apiVersion !== 1 || !text(c.namespaceId) || c.projectTransferStream?.apiVersion !== 1 || (action === 'resume' ? c.projectTransferStream.resumeEnabled !== true : c.projectTransferStream.enabled !== true)) {
|
|
19
|
+
throw new Error('STREAM_UNAVAILABLE: explicit compatible server streaming capability is required; no fixed-manifest fallback');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function selectProjectStreamVersion(c) {
|
|
23
|
+
const capability = c.projectTransferStream;
|
|
24
|
+
if (capability?.defaultStreamVersion === 2) {
|
|
25
|
+
if (!Array.isArray(capability.streamVersions) || !capability.streamVersions.includes(2))
|
|
26
|
+
throw new Error('Incompatible Project streamv2 capability; no downgrade');
|
|
27
|
+
return 2;
|
|
28
|
+
}
|
|
29
|
+
if (capability?.defaultStreamVersion !== undefined && capability.defaultStreamVersion !== 1)
|
|
30
|
+
throw new Error('Unsupported Project stream default; no downgrade');
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
export function validateStreamOperation(op, expected) {
|
|
34
|
+
if (!versioned(op) || !id(op.id) || !root(op.resource) || !text(op.sourceNamespaceId) || !text(op.destinationNamespaceId) ||
|
|
35
|
+
op.sourceNamespaceId === op.destinationNamespaceId || !text(op.previewHash) || !states.has(op.state) ||
|
|
36
|
+
Object.entries(expected).some(([k, v]) => !equal(op[k], v))) {
|
|
37
|
+
throw new Error('Invalid streaming operation identity; outcome unknown. Reconcile the same saved request/operation; do not recreate or accept another operation');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function validateStreamProgress(p, operationId, streamVersion) {
|
|
41
|
+
if (!versioned(p) || streamVersion !== undefined && p.streamVersion !== streamVersion || p.operationId !== operationId || !id(p.operationId) || !states.has(p.state) || !text(p.phase) ||
|
|
42
|
+
!(p.cursor === null || text(p.cursor)) || !(p.finalWatermark === null || text(p.finalWatermark)) ||
|
|
43
|
+
(p.state === 'completed' && (!text(p.finalWatermark) || p.counters?.pending !== 0)) ||
|
|
44
|
+
!p.counters || ['discovered', 'prepared', 'committed', 'pending'].some(k => !count(p.counters[k]))) {
|
|
45
|
+
throw new Error('Invalid operation-bound streaming progress; cursor and ownership outcome remain unknown');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function validatePlan(p) {
|
|
49
|
+
if (!versioned(p) || !root(p.resource) || !text(p.ownerNamespaceId) || !text(p.version) || !text(p.projectName) || typeof p.executable !== 'boolean') {
|
|
50
|
+
throw new Error('Invalid streaming Project plan; nothing submitted');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function validateRequest(r, p, destination) {
|
|
54
|
+
const allowed = new Set(['apiVersion', 'mode', 'streamVersion', 'resource', 'expectedOwner', 'expectedVersion', 'destinationNamespaceId', 'destinationName', 'destinationNames', 'idempotencyKey', 'previewHash', 'policy']);
|
|
55
|
+
if (!versioned(r) || r.streamVersion !== p.streamVersion || Object.keys(r).some(k => !allowed.has(k)) || !equal(r.resource, p.resource) || r.expectedOwner !== p.ownerNamespaceId ||
|
|
56
|
+
r.expectedVersion !== p.version || r.destinationNamespaceId !== destination || r.destinationName !== p.projectName ||
|
|
57
|
+
(r.destinationNames !== undefined && (!Array.isArray(r.destinationNames) || r.destinationNames.length > 1000 ||
|
|
58
|
+
new Set(r.destinationNames.map(row => row?.resource?.id?.toLowerCase())).size !== r.destinationNames.length ||
|
|
59
|
+
r.destinationNames.some(row => !row || Object.keys(row).length !== 2 || !row.resource || Object.keys(row.resource).length !== 2 ||
|
|
60
|
+
row.resource.type !== 'note' || !id(row.resource.id) || !text(row.name) || row.name.length > 200))) ||
|
|
61
|
+
!text(r.idempotencyKey) || r.idempotencyKey.length > 200 || r.policy?.visibility !== 'private' ||
|
|
62
|
+
!Array.isArray(r.policy.retainedGrantIds) || r.policy.retainedGrantIds.length !== 0 ||
|
|
63
|
+
typeof r.policy.preserveAccess !== 'boolean' || typeof r.policy.preserveExternalFilings !== 'boolean' ||
|
|
64
|
+
Object.keys(r.policy).some(k => !['visibility', 'retainedGrantIds', 'preserveAccess', 'preserveExternalFilings'].includes(k))) {
|
|
65
|
+
throw new Error('Streaming request must bind the unchanged Project name, owner/version, destination, key and exact private policy; no client manifest or unreviewed rename overrides');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function validatePreview(p, r) {
|
|
69
|
+
if (!versioned(p) || p.streamVersion !== r.streamVersion || !equal(p.resource, r.resource) || p.sourceNamespaceId !== r.expectedOwner || p.destinationNamespaceId !== r.destinationNamespaceId ||
|
|
70
|
+
p.expectedVersion !== r.expectedVersion || !text(p.previewHash) || !Array.isArray(p.blockers) || p.blockers.some(b => !text(b.code) || !text(b.action)) ||
|
|
71
|
+
!p.summary || p.summary.becomesPrivate !== true || ['includedCount', 'retainedFilings', 'detachedFilings', 'detachedOtherFilings'].some(k => !count(p.summary[k]))) {
|
|
72
|
+
throw new Error('Invalid streaming preview; nothing submitted');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** An explicit, separately gated protocol. The server owns dynamic closure/cursors. */
|
|
76
|
+
export async function runProjectStreamMove(project, opts) {
|
|
77
|
+
opts = { ...opts, acceptIfOwner: opts.acceptIfOwner === true || opts.acceptIfAuthorized === true };
|
|
78
|
+
try {
|
|
79
|
+
const source = (opts.namespace ?? '').trim().replace(/^@/, ''), destination = (opts.to ?? '').trim().replace(/^@/, '');
|
|
80
|
+
if (!source || !destination || !project.trim() || source === destination)
|
|
81
|
+
throw new Error('Choose explicit different source/destination namespaces and a Project');
|
|
82
|
+
if (opts.dryRun && opts.confirm)
|
|
83
|
+
throw new Error('--dry-run cannot submit');
|
|
84
|
+
if (opts.name)
|
|
85
|
+
throw new Error('Streaming requires the unchanged root Project name');
|
|
86
|
+
if ((opts.renameNote?.length ?? 0) > 1000)
|
|
87
|
+
throw new Error('At most 1000 explicit Note ID/name mappings are supported');
|
|
88
|
+
if (opts.wait && !opts.acceptIfOwner)
|
|
89
|
+
throw new Error('--wait requires explicit --accept-if-authorized');
|
|
90
|
+
const timeout = opts.waitTimeout ?? 30;
|
|
91
|
+
if (!Number.isSafeInteger(timeout) || timeout < 0 || timeout > 60)
|
|
92
|
+
throw new Error('--wait-timeout must be an integer from 0 to 60 seconds');
|
|
93
|
+
if (opts.confirm && !opts.requestFile)
|
|
94
|
+
throw new Error('Streaming confirmation requires the exact saved --request-file from --stream --dry-run --out');
|
|
95
|
+
if (opts.requestFile && (opts.out || opts.idempotencyKey || opts.previewHash || opts.renameNote?.length))
|
|
96
|
+
throw new Error('Replay streaming review unchanged; no request overrides');
|
|
97
|
+
const c = resolveCtx(opts);
|
|
98
|
+
if (!c.token)
|
|
99
|
+
throw new Error("Not authenticated — run 'dreamlake login' first");
|
|
100
|
+
const get = (path, timeoutMs) => requestJson(c.remote, path, { token: c.token, redirect: 'error', timeoutMs });
|
|
101
|
+
const post = (path, json) => requestJson(c.remote, path, { token: c.token, method: 'POST', json, redirect: 'error' });
|
|
102
|
+
const base = `/namespaces/${encodeURIComponent(source)}/ownership`;
|
|
103
|
+
const sourceCaps = await get(`${base}/capabilities`);
|
|
104
|
+
if (!opts.requestFile)
|
|
105
|
+
requireStreamCapability(sourceCaps);
|
|
106
|
+
else if (sourceCaps?.apiVersion !== 1 || !text(sourceCaps.namespaceId) || sourceCaps.projectTransferStream?.apiVersion !== 1)
|
|
107
|
+
throw new Error('Saved streaming source capability identity is unknown');
|
|
108
|
+
const target = await get(`/namespaces/${encodeURIComponent(destination)}/ownership/capabilities`);
|
|
109
|
+
if (target?.apiVersion !== 1 || !text(target.namespaceId) || target.namespaceId === sourceCaps.namespaceId)
|
|
110
|
+
throw new Error('Destination namespace identity could not be verified');
|
|
111
|
+
const saved = opts.requestFile ? JSON.parse(readFileSync(opts.requestFile, 'utf8')) : undefined;
|
|
112
|
+
let plan;
|
|
113
|
+
if (saved) {
|
|
114
|
+
if (!opts.confirm || opts.dryRun || saved.mode !== 'stream' || ![1, 2].includes(saved.streamVersion) || saved.streamVersion !== saved.plan?.streamVersion || saved.source !== source || saved.destination !== destination || saved.ready !== true || saved.plan?.projectName !== project.trim())
|
|
115
|
+
throw new Error('Replay requires matching complete streaming review bundle and --confirm');
|
|
116
|
+
plan = saved.plan;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
const resource = await get(`/namespaces/${encodeURIComponent(source)}/projects/${encodeURIComponent(project.trim())}`);
|
|
120
|
+
if (!id(resource?.id))
|
|
121
|
+
throw new Error('Invalid Project identity');
|
|
122
|
+
const streamVersion = selectProjectStreamVersion(sourceCaps);
|
|
123
|
+
plan = await get(`${base}/resources/project/${resource.id}/transfer-plan?mode=stream&streamVersion=${streamVersion}`);
|
|
124
|
+
if (plan?.streamVersion !== streamVersion)
|
|
125
|
+
throw new Error('Project stream version changed; no downgrade');
|
|
126
|
+
if (plan?.resource?.id !== resource.id)
|
|
127
|
+
throw new Error('Streaming plan changed Project identity');
|
|
128
|
+
}
|
|
129
|
+
validatePlan(plan);
|
|
130
|
+
if (plan.ownerNamespaceId !== sourceCaps.namespaceId)
|
|
131
|
+
throw new Error('Streaming source owner identity changed');
|
|
132
|
+
const request = saved?.request ?? { apiVersion: 1, mode: 'stream', streamVersion: plan.streamVersion, resource: plan.resource,
|
|
133
|
+
expectedOwner: plan.ownerNamespaceId, expectedVersion: plan.version, destinationNamespaceId: target.namespaceId, destinationName: plan.projectName,
|
|
134
|
+
...(opts.renameNote?.length ? { destinationNames: opts.renameNote.map(value => {
|
|
135
|
+
const at = value.indexOf('=');
|
|
136
|
+
if (at < 1 || !id(value.slice(0, at)) || !text(value.slice(at + 1)))
|
|
137
|
+
throw new Error('--rename-note requires NOTE_ID=NAME; server must verify membership in the captured Project closure');
|
|
138
|
+
return { resource: { type: 'note', id: value.slice(0, at) }, name: value.slice(at + 1) };
|
|
139
|
+
}) } : {}),
|
|
140
|
+
idempotencyKey: opts.idempotencyKey ?? randomUUID(), policy: { visibility: 'private', retainedGrantIds: [], preserveAccess: opts.preserveAccess === true, preserveExternalFilings: opts.preserveExternalFilings === true } };
|
|
141
|
+
validateRequest(request, plan, target.namespaceId);
|
|
142
|
+
if (saved && ((opts.preserveAccess !== undefined && opts.preserveAccess !== request.policy.preserveAccess) ||
|
|
143
|
+
(opts.preserveExternalFilings !== undefined && opts.preserveExternalFilings !== request.policy.preserveExternalFilings)))
|
|
144
|
+
throw new Error('Preserve flags differ from saved streaming policy');
|
|
145
|
+
const reviewedHash = request.previewHash;
|
|
146
|
+
const previewRequest = { ...request };
|
|
147
|
+
delete previewRequest.previewHash;
|
|
148
|
+
const preview = saved?.preview ?? await post(`${base}/transfers/preview`, previewRequest);
|
|
149
|
+
validatePreview(preview, request);
|
|
150
|
+
if (saved && reviewedHash !== preview.previewHash)
|
|
151
|
+
throw new Error('Saved streaming preview hash mismatch');
|
|
152
|
+
request.previewHash = preview.previewHash;
|
|
153
|
+
const preservationSafe = !request.policy.preserveExternalFilings || (preview.summary.detachedFilings === 0 && preview.summary.detachedOtherFilings === 0);
|
|
154
|
+
const ready = plan.executable && preview.blockers.length === 0 && preservationSafe;
|
|
155
|
+
const review = { mode: 'stream', streamVersion: plan.streamVersion, source, destination, ready, plan, request, preview };
|
|
156
|
+
if (opts.out)
|
|
157
|
+
writeFileSync(opts.out, JSON.stringify(review, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
|
|
158
|
+
if (!opts.confirm || opts.dryRun || !ready) {
|
|
159
|
+
emitProjectResult(review, () => `Streaming v${request.streamVersion} Project ${source}/${project} → ${destination}: ${ready ? 'ready for review' : 'unavailable'}.\nServer captures membership by resource ID; no content/blob copying. Inspect the full policy/access preview before confirming.\nExternal detachments: ${preview.summary.detachedFilings} total, ${preview.summary.detachedOtherFilings} other; preserve external filings ${request.policy.preserveExternalFilings ? 'required' : 'not requested'}.\n${preview.blockers.map((b) => `${b.code}: ${b.action}`).join('\n')}\nNothing moved.`, opts.json);
|
|
160
|
+
return ready ? 0 : 3;
|
|
161
|
+
}
|
|
162
|
+
if (opts.acceptIfOwner && (target.capabilities?.['ownership.accept']?.allowed !== true || preview.destinationAuthority?.allowed !== true ||
|
|
163
|
+
preview.destinationAuthority.namespaceId !== target.namespaceId || preview.destinationAuthority.action !== 'ownership.accept'))
|
|
164
|
+
throw new Error('Destination acceptance authority was not verified; nothing submitted');
|
|
165
|
+
const expected = { streamVersion: request.streamVersion, resource: request.resource, sourceNamespaceId: request.expectedOwner, destinationNamespaceId: request.destinationNamespaceId, previewHash: request.previewHash };
|
|
166
|
+
let operation = await post(`${base}/transfers`, request);
|
|
167
|
+
validateStreamOperation(operation, expected);
|
|
168
|
+
const operationId = operation.id;
|
|
169
|
+
const targetBase = `/namespaces/${encodeURIComponent(destination)}/ownership/transfers/${operationId}`;
|
|
170
|
+
if (opts.acceptIfOwner && operation.state === 'pending') {
|
|
171
|
+
operation = await post(`${targetBase}/accept`);
|
|
172
|
+
validateStreamOperation(operation, { ...expected, id: operationId });
|
|
173
|
+
}
|
|
174
|
+
let progress;
|
|
175
|
+
const deadline = performance.now() + timeout * 1000;
|
|
176
|
+
while (opts.wait && busy.has(operation.state) && performance.now() < deadline) {
|
|
177
|
+
try {
|
|
178
|
+
progress = await get(`${base}/transfers/${operationId}/progress`, Math.max(1, Math.min(30000, Math.ceil(deadline - performance.now()))));
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
if (['TimeoutError', 'AbortError'].includes(error.name))
|
|
182
|
+
break;
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
validateStreamProgress(progress, operationId, request.streamVersion);
|
|
186
|
+
if (!opts.json && process.stderr.isTTY)
|
|
187
|
+
process.stderr.write(`${progress.phase}: discovered ${progress.counters.discovered}, prepared ${progress.counters.prepared}, committed ${progress.counters.committed}, pending ${progress.counters.pending}\n`);
|
|
188
|
+
operation = { ...operation, state: progress.state };
|
|
189
|
+
if (!busy.has(operation.state) || performance.now() >= deadline)
|
|
190
|
+
break;
|
|
191
|
+
await new Promise(resolve => setTimeout(resolve, Math.min(1000, Math.max(0, deadline - performance.now()))));
|
|
192
|
+
}
|
|
193
|
+
if (operation.state === 'completed' && progress?.state !== 'completed') {
|
|
194
|
+
progress = await get(`${base}/transfers/${operationId}/progress`);
|
|
195
|
+
validateStreamProgress(progress, operationId, request.streamVersion);
|
|
196
|
+
if (progress.state !== 'completed')
|
|
197
|
+
throw new Error('Streaming completion is not confirmed by the operation-bound final watermark; inspect the same operation');
|
|
198
|
+
}
|
|
199
|
+
const nextAction = `dreamlake ownership progress ${operationId} --namespace '${source.replace(/'/g, "'\"'\"'")}'`;
|
|
200
|
+
emitProjectResult({ ...review, operation, progress, nextAction, timedOut: !!opts.wait && busy.has(operation.state) }, () => `Streaming transfer ${operationId}: ${operation.state}.\n${nextAction}`, opts.json);
|
|
201
|
+
return failed.has(operation.state) ? 3 : 0;
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
fail(error.message);
|
|
205
|
+
return 1;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type DreamlakeOpts } from '../compat/ctx.js';
|
|
2
|
+
/** Compatibility alias for whole-Project streaming review; never submits. */
|
|
3
|
+
export declare function runProjectTransferPreview(project: string, opts: DreamlakeOpts & {
|
|
4
|
+
namespace: string;
|
|
5
|
+
toNamespace: string;
|
|
6
|
+
includeNote?: string[];
|
|
7
|
+
json?: boolean;
|
|
8
|
+
}): Promise<number>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { runProjectMove } from './move.js';
|
|
2
|
+
import { fail } from '../helpers.js';
|
|
3
|
+
/** Compatibility alias for whole-Project streaming review; never submits. */
|
|
4
|
+
export async function runProjectTransferPreview(project, opts) {
|
|
5
|
+
if (opts.includeNote?.length) {
|
|
6
|
+
fail('--include-note selected manifests are retired. Review the whole Project with project move --dry-run; streaming discovers all resources.');
|
|
7
|
+
return 1;
|
|
8
|
+
}
|
|
9
|
+
return runProjectMove(project, { ...opts, to: opts.toNamespace, dryRun: true });
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function confirm(message: string, defaultValue?: boolean): Promise<boolean>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Interactive confirmation, replacing dreamlake-py's `input()` /
|
|
2
|
+
// `rich.Confirm.ask`. Uses @inquirer/prompts (already a lakeshore dep).
|
|
3
|
+
// Non-TTY stdin returns the default without prompting so scripted runs
|
|
4
|
+
// don't hang.
|
|
5
|
+
import { confirm as inquirerConfirm } from "@inquirer/prompts";
|
|
6
|
+
export async function confirm(message, defaultValue = false) {
|
|
7
|
+
if (!process.stdin.isTTY) {
|
|
8
|
+
return defaultValue;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
return await inquirerConfirm({ message, default: defaultValue });
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
// Ctrl-C / closed stream → treat as "no".
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface DreamRoot {
|
|
2
|
+
/** The project directory. Printed as `root:`. */
|
|
3
|
+
root: string;
|
|
4
|
+
/** Absolute path of the `.dream` directory itself. */
|
|
5
|
+
dir: string;
|
|
6
|
+
/** How it was decided — printed in parentheses after the root. */
|
|
7
|
+
source: "flag" | "dreamrc" | "cwd";
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveDreamRoot(flag?: string): DreamRoot;
|
|
10
|
+
/** How the root was found, for the `root:` line. */
|
|
11
|
+
export declare function rootNote(dream: DreamRoot): string;
|
|
12
|
+
export declare function providerDir(dream: DreamRoot, name: string): string;
|
|
13
|
+
/** `<abs>` relative to the root, for the short forms in prose. */
|
|
14
|
+
export declare function relative(dream: DreamRoot, abs: string): string;
|
|
15
|
+
export declare function invalidNameMessage(name: string): string | null;
|
|
16
|
+
export declare const DREAM_GITIGNORE: string;
|
|
17
|
+
export interface ProviderRecord {
|
|
18
|
+
name: string;
|
|
19
|
+
/** The `LakeshoreProvider.kind` this vendor maps to — k8s, aws-ec2, … */
|
|
20
|
+
kind: string;
|
|
21
|
+
/** The template directory this came from — kube, ec2, docker, ssh, slurm. */
|
|
22
|
+
vendor: string;
|
|
23
|
+
/** `<vendor>` again, spelled out, plus its version — e.g. "kube v1". */
|
|
24
|
+
template: string;
|
|
25
|
+
templateVersion: number;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function readProviderRecord(dir: string): ProviderRecord | null;
|
|
29
|
+
export interface FileWrite {
|
|
30
|
+
/** Absolute destination path. */
|
|
31
|
+
path: string;
|
|
32
|
+
content: string;
|
|
33
|
+
}
|
|
34
|
+
export type WriteOutcome = {
|
|
35
|
+
ok: true;
|
|
36
|
+
files: string[];
|
|
37
|
+
} | {
|
|
38
|
+
ok: false;
|
|
39
|
+
message: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The whole scaffold, as ONE try/catch whose failure is a sentence —
|
|
43
|
+
* `cannot write to <dir>: <message>`, the shape runnable/index.ts:536-542 uses.
|
|
44
|
+
* A half-written provider directory is worse than none, so the caller treats
|
|
45
|
+
* this as all-or-nothing even though the filesystem cannot.
|
|
46
|
+
*/
|
|
47
|
+
export declare function writeFiles(dir: string, writes: FileWrite[]): WriteOutcome;
|
|
48
|
+
/**
|
|
49
|
+
* `.dream/.gitignore`, written on first scaffold only. Never rewritten: an
|
|
50
|
+
* operator who edited it did so on purpose.
|
|
51
|
+
*/
|
|
52
|
+
export declare function gitignoreWrite(dream: DreamRoot): FileWrite | null;
|