@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,623 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dreamlake notes find | select | replace | insert | delete | toc`
|
|
3
|
+
*
|
|
4
|
+
* The shape follows the CLI's existing convention rather than the SDK's: the
|
|
5
|
+
* thing you are looking FOR is the first positional argument, and the thing
|
|
6
|
+
* you are replacing it WITH is `--text`. That is the opposite order from
|
|
7
|
+
* Python, where the replacement comes first — a deliberate difference, because
|
|
8
|
+
* `notes replace "Draft" --text "Published"` reads the way the other search
|
|
9
|
+
* commands here already read, and reversing it to match the SDK would make
|
|
10
|
+
* every existing muscle memory wrong.
|
|
11
|
+
*
|
|
12
|
+
* Legacy mutations use one conditional replacement; modern insert uses an
|
|
13
|
+
* original-revision insertion. Legacy writes:
|
|
14
|
+
*
|
|
15
|
+
* 1. read the body and its revision
|
|
16
|
+
* 2. compute the whole edit locally
|
|
17
|
+
* 3. send the result with `If-Match`
|
|
18
|
+
*
|
|
19
|
+
* So a concurrent edit is refused rather than clobbered, and `--dry-run` can
|
|
20
|
+
* show exactly what would be written without a second code path — it stops
|
|
21
|
+
* after step 2.
|
|
22
|
+
*/
|
|
23
|
+
import { AmbiguousMatch, EditError, NoMatch, find, insert, insertPlacement, replacementPlan, removalPlan, applyEditPlan, remove, replace, } from "./editing.js";
|
|
24
|
+
import { readDocumentSnapshot, documentInsertion, documentEdits, submitDocumentPatch, printPatchReceipt, documentWriteError } from "./document.js";
|
|
25
|
+
import { markdownToc, htmlToc } from "./toc.js";
|
|
26
|
+
// The connection plumbing lives in the main notes module; importing it keeps
|
|
27
|
+
// one definition of "how do I reach the server".
|
|
28
|
+
import { ctx, report, resolveNote, seg } from "./index.js";
|
|
29
|
+
import { AmbiguousElement, NoElement, SelectorError, parse, select, textPieces, } from "./html.js";
|
|
30
|
+
import { emitJson, fail } from "../helpers.js";
|
|
31
|
+
import { requestJson } from "../client.js";
|
|
32
|
+
/** Exit code for an edit that could not be located; distinct from a transport
|
|
33
|
+
* failure so a script can tell "your query was wrong" from "the server is
|
|
34
|
+
* down". */
|
|
35
|
+
export const EXIT_NO_MATCH = 6;
|
|
36
|
+
/** Read the body and the revision the edit will be written against. */
|
|
37
|
+
async function readBody(c, id) {
|
|
38
|
+
return requestJson(c.remote, `/namespaces/${seg(c.ns)}/notes/${seg(id)}/body`, { token: c.token });
|
|
39
|
+
}
|
|
40
|
+
/** Send the finished document as one conditional write. */
|
|
41
|
+
async function writeBody(c, id, text, headers) {
|
|
42
|
+
return requestJson(c.remote, `/namespaces/${seg(c.ns)}/notes/${seg(id)}/body`, {
|
|
43
|
+
method: "PUT",
|
|
44
|
+
token: c.token,
|
|
45
|
+
json: { text },
|
|
46
|
+
headers,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** Turn the flags into the single target the editing engine accepts. */
|
|
50
|
+
function whereFrom(query, opts) {
|
|
51
|
+
const w = {};
|
|
52
|
+
if (query !== undefined)
|
|
53
|
+
w.query = query;
|
|
54
|
+
if (opts.regex !== undefined)
|
|
55
|
+
w.regex = opts.regex;
|
|
56
|
+
if (opts.flags)
|
|
57
|
+
w.flags = opts.flags;
|
|
58
|
+
if (opts.line !== undefined)
|
|
59
|
+
w.line = parseRange(opts.line, "--line");
|
|
60
|
+
if (opts.ind !== undefined)
|
|
61
|
+
w.ind = parseRange(opts.ind, "--ind");
|
|
62
|
+
if (opts.count !== undefined)
|
|
63
|
+
w.count = Number(opts.count);
|
|
64
|
+
if (opts.all)
|
|
65
|
+
w.all = true;
|
|
66
|
+
return w;
|
|
67
|
+
}
|
|
68
|
+
/** `10` or `10:15` — a single position or an inclusive/half-open range. */
|
|
69
|
+
function parseRange(raw, flag) {
|
|
70
|
+
const parts = raw.split(":");
|
|
71
|
+
const nums = parts.map((p) => {
|
|
72
|
+
const n = Number(p);
|
|
73
|
+
if (!Number.isInteger(n)) {
|
|
74
|
+
throw new EditError(`${flag} takes integers, got ${raw}`);
|
|
75
|
+
}
|
|
76
|
+
return n;
|
|
77
|
+
});
|
|
78
|
+
if (nums.length === 1)
|
|
79
|
+
return nums[0];
|
|
80
|
+
if (nums.length === 2)
|
|
81
|
+
return [nums[0], nums[1]];
|
|
82
|
+
throw new EditError(`${flag} takes N or N:M, got ${raw}`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Replace inside ONE element's text nodes, landing on raw source.
|
|
86
|
+
*
|
|
87
|
+
* The query runs over decoded text — so an entity reads as the character it
|
|
88
|
+
* stands for — and each match is mapped back to the source range it came from.
|
|
89
|
+
* Markup outside the matched characters is untouched, which is why the
|
|
90
|
+
* document keeps its entity spelling and attribute quoting.
|
|
91
|
+
*/
|
|
92
|
+
export function elementReplacementPlan(source, css, text, w) {
|
|
93
|
+
const doc = parse(source);
|
|
94
|
+
const el = select(doc, css);
|
|
95
|
+
const pieces = textPieces(doc, el);
|
|
96
|
+
const hits = [];
|
|
97
|
+
for (const piece of pieces) {
|
|
98
|
+
for (const m of find(piece.decoded, w.query, { regex: w.regex, flags: w.flags })) {
|
|
99
|
+
const start = piece.spans[m.ind[0]][0];
|
|
100
|
+
const end = m.ind[1] > m.ind[0] ? piece.spans[m.ind[1] - 1][1] : start;
|
|
101
|
+
hits.push([start, end]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (hits.length === 0)
|
|
105
|
+
throw new NoMatch(`${w.query !== undefined ? "query" : "regex"} matched nothing in ${css}`);
|
|
106
|
+
if (!w.all) {
|
|
107
|
+
const wanted = w.count ?? 1;
|
|
108
|
+
if (hits.length !== wanted) {
|
|
109
|
+
throw new AmbiguousMatch(`expected ${wanted} match${wanted === 1 ? "" : "es"} in ${css}, found ${hits.length} — ` +
|
|
110
|
+
"narrow the query, or pass --all");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Escaped, because it is going into markup as text.
|
|
114
|
+
const escaped = text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
115
|
+
return hits.sort((a, b) => a[0] - b[0]).map(([start, end]) => [start, end, escaped]);
|
|
116
|
+
}
|
|
117
|
+
function replaceInElement(source, css, text, w) {
|
|
118
|
+
return applyEditPlan(source, elementReplacementPlan(source, css, text, w));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Insert markup relative to one element.
|
|
122
|
+
*
|
|
123
|
+
* Inserted as MARKUP, not escaped — this is how you add an `<li>`, and
|
|
124
|
+
* escaping would put the tags on the page as visible text. No newline is
|
|
125
|
+
* added: HTML is not line-oriented, and one inside a `<pre>` changes what it
|
|
126
|
+
* renders.
|
|
127
|
+
*/
|
|
128
|
+
export function elementInsertionPosition(source, css, position) {
|
|
129
|
+
const doc = parse(source);
|
|
130
|
+
const el = select(doc, css);
|
|
131
|
+
let at;
|
|
132
|
+
if (position === "before")
|
|
133
|
+
at = el.outer[0];
|
|
134
|
+
else if (position === "after")
|
|
135
|
+
at = el.outer[1];
|
|
136
|
+
else if (position === "prepend")
|
|
137
|
+
at = el.inner[0];
|
|
138
|
+
else if (position === "append")
|
|
139
|
+
at = el.inner[1];
|
|
140
|
+
else {
|
|
141
|
+
throw new EditError(`unknown position '${position}'; use before, after, prepend or append`);
|
|
142
|
+
}
|
|
143
|
+
if ((position === "prepend" || position === "append") &&
|
|
144
|
+
el.inner[0] === el.inner[1] &&
|
|
145
|
+
el.outer[1] === el.inner[1]) {
|
|
146
|
+
// A void element has no inside. Appending "into" one silently lands AFTER
|
|
147
|
+
// it, which renders as though it worked.
|
|
148
|
+
throw new EditError(`<${el.tag}> cannot have children; use --position before or after`);
|
|
149
|
+
}
|
|
150
|
+
return at;
|
|
151
|
+
}
|
|
152
|
+
export function insertAtElement(source, css, text, position) {
|
|
153
|
+
const at = elementInsertionPosition(source, css, position);
|
|
154
|
+
const chars = Array.from(source);
|
|
155
|
+
return chars.slice(0, at).join("") + text + chars.slice(at).join("");
|
|
156
|
+
}
|
|
157
|
+
/** The note to act on. `--note` per the documented CLI shape. */
|
|
158
|
+
function requireNote(opts) {
|
|
159
|
+
if (!opts.note) {
|
|
160
|
+
fail("say which note: --note <id-or-slug>");
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
return opts.note;
|
|
164
|
+
}
|
|
165
|
+
/** One place that maps an editing refusal onto an exit code. */
|
|
166
|
+
function reportEdit(err) {
|
|
167
|
+
if (err instanceof NoElement || err instanceof AmbiguousElement || err instanceof SelectorError) {
|
|
168
|
+
fail(err.message);
|
|
169
|
+
return EXIT_NO_MATCH;
|
|
170
|
+
}
|
|
171
|
+
if (err instanceof EditError) {
|
|
172
|
+
fail(err.message);
|
|
173
|
+
return EXIT_NO_MATCH;
|
|
174
|
+
}
|
|
175
|
+
return report(err);
|
|
176
|
+
}
|
|
177
|
+
// ── Commands ─────────────────────────────────────────────────────────────────
|
|
178
|
+
export async function runNotesFind(query, opts) {
|
|
179
|
+
const ref = requireNote(opts);
|
|
180
|
+
if (!ref)
|
|
181
|
+
return 1;
|
|
182
|
+
const c = await ctx(opts);
|
|
183
|
+
if (!c)
|
|
184
|
+
return 1;
|
|
185
|
+
try {
|
|
186
|
+
const id = await resolveNote(c, ref);
|
|
187
|
+
if (!id)
|
|
188
|
+
return 1;
|
|
189
|
+
const body = await readBody(c, id);
|
|
190
|
+
const matches = find(body.text, query, {
|
|
191
|
+
regex: opts.regex,
|
|
192
|
+
flags: opts.flags,
|
|
193
|
+
limit: opts.limit ? Number(opts.limit) : undefined,
|
|
194
|
+
});
|
|
195
|
+
if (opts.json) {
|
|
196
|
+
// The revision travels with the result: a caller that acts on a match
|
|
197
|
+
// needs the revision those offsets were computed against.
|
|
198
|
+
emitJson({ etag: body.etag, matches });
|
|
199
|
+
return 0;
|
|
200
|
+
}
|
|
201
|
+
for (const m of matches) {
|
|
202
|
+
process.stdout.write(`${m.line[0]}:${m.ind[0]} ${JSON.stringify(m.text)}\n`);
|
|
203
|
+
}
|
|
204
|
+
if (matches.length === 0)
|
|
205
|
+
process.stderr.write("no matches\n");
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
208
|
+
catch (e) {
|
|
209
|
+
return reportEdit(e);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
export async function runNotesToc(opts) {
|
|
213
|
+
const ref = requireNote(opts);
|
|
214
|
+
if (!ref)
|
|
215
|
+
return 1;
|
|
216
|
+
const c = await ctx(opts);
|
|
217
|
+
if (!c)
|
|
218
|
+
return 1;
|
|
219
|
+
try {
|
|
220
|
+
const id = await resolveNote(c, ref);
|
|
221
|
+
if (!id)
|
|
222
|
+
return 1;
|
|
223
|
+
const body = await readBody(c, id);
|
|
224
|
+
const entries = opts.html ? htmlToc(body.text) : markdownToc(body.text);
|
|
225
|
+
if (opts.json) {
|
|
226
|
+
emitJson({ etag: body.etag, entries });
|
|
227
|
+
return 0;
|
|
228
|
+
}
|
|
229
|
+
for (const e of entries) {
|
|
230
|
+
const indent = " ".repeat(Math.max(0, e.level - 1));
|
|
231
|
+
process.stdout.write(`${indent}${e.anchor} L${e.line[0]}-${e.line[1]} [${e.ind[0]},${e.ind[1]}) ${e.title}\n`);
|
|
232
|
+
}
|
|
233
|
+
return 0;
|
|
234
|
+
}
|
|
235
|
+
catch (e) {
|
|
236
|
+
return reportEdit(e);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/** The one write path: read, edit locally, send with a precondition. */
|
|
240
|
+
async function mutate(opts, apply) {
|
|
241
|
+
const ref = requireNote(opts);
|
|
242
|
+
if (!ref)
|
|
243
|
+
return 1;
|
|
244
|
+
if (opts.ifMatch?.replace(/^W\//, '').replace(/^"|"$/g, '').startsWith('rtc:')) {
|
|
245
|
+
fail('This legacy edit requires the quoted ETag from notes read --legacy --json, not an rtc: revision. Preserve the draft and read the legacy baseline, or use notes patch --base-revision for a modern merge edit.');
|
|
246
|
+
return 1;
|
|
247
|
+
}
|
|
248
|
+
const c = await ctx(opts);
|
|
249
|
+
if (!c)
|
|
250
|
+
return 1;
|
|
251
|
+
try {
|
|
252
|
+
const id = await resolveNote(c, ref);
|
|
253
|
+
if (!id)
|
|
254
|
+
return 1;
|
|
255
|
+
const body = await readBody(c, id);
|
|
256
|
+
const updated = apply(body.text);
|
|
257
|
+
if (opts.dryRun) {
|
|
258
|
+
// Everything except the write, so what is shown is what would be sent —
|
|
259
|
+
// not a separate preview code path that could disagree with it.
|
|
260
|
+
if (opts.json)
|
|
261
|
+
emitJson({ etag: body.etag, text: updated, wouldWrite: true });
|
|
262
|
+
else
|
|
263
|
+
process.stdout.write(updated);
|
|
264
|
+
return 0;
|
|
265
|
+
}
|
|
266
|
+
// `--if-match` wins if given; otherwise the revision just read is the
|
|
267
|
+
// precondition. `--force` sends none, which is the only way to overwrite
|
|
268
|
+
// a concurrent edit and has to be asked for.
|
|
269
|
+
const headers = opts.force
|
|
270
|
+
? {}
|
|
271
|
+
: { "If-Match": opts.ifMatch ?? body.etag };
|
|
272
|
+
const res = await writeBody(c, id, updated, headers);
|
|
273
|
+
if (opts.json)
|
|
274
|
+
emitJson(res);
|
|
275
|
+
else
|
|
276
|
+
process.stdout.write(`${res.etag}\n`);
|
|
277
|
+
return 0;
|
|
278
|
+
}
|
|
279
|
+
catch (e) {
|
|
280
|
+
return reportEdit(e);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/** Modern editors submit plans computed against one immutable source snapshot. */
|
|
284
|
+
async function mutateDocument(opts, plan) {
|
|
285
|
+
if (opts.baseRevision !== undefined && (!opts.baseRevision.trim() || opts.baseRevision === "*" || /[\r\n]/.test(opts.baseRevision))) {
|
|
286
|
+
fail("--base-revision requires the original retained revision");
|
|
287
|
+
return 1;
|
|
288
|
+
}
|
|
289
|
+
const ref = requireNote(opts);
|
|
290
|
+
if (!ref)
|
|
291
|
+
return 1;
|
|
292
|
+
const c = await ctx(opts);
|
|
293
|
+
if (!c)
|
|
294
|
+
return 1;
|
|
295
|
+
try {
|
|
296
|
+
const id = await resolveNote(c, ref);
|
|
297
|
+
if (!id)
|
|
298
|
+
return 1;
|
|
299
|
+
const source = await readDocumentSnapshot(c, id, opts.baseRevision);
|
|
300
|
+
const edits = plan(source.content);
|
|
301
|
+
const payload = documentEdits(source, edits.map(([start, end, text]) => ({ start, end, text })), opts.exact);
|
|
302
|
+
if (opts.dryRun) {
|
|
303
|
+
const text = applyEditPlan(source.content, edits);
|
|
304
|
+
if (opts.json)
|
|
305
|
+
emitJson({ dryRun: true, method: "PATCH", path: `/namespaces/${seg(c.ns)}/notes/${seg(id)}/body`, headers: {}, payload, text, ...(!payload.patch ? { noChange: true } : {}) });
|
|
306
|
+
else
|
|
307
|
+
process.stdout.write(text);
|
|
308
|
+
return 0;
|
|
309
|
+
}
|
|
310
|
+
if (!payload.patch) {
|
|
311
|
+
if (opts.json)
|
|
312
|
+
emitJson({ note: id, hash: source.hash, revision: source.revision, noChange: true });
|
|
313
|
+
else
|
|
314
|
+
process.stdout.write(`note: ${id}\nhash: ${source.hash}\nrevision: ${source.revision}\nno change\n`);
|
|
315
|
+
return 0;
|
|
316
|
+
}
|
|
317
|
+
printPatchReceipt(await submitDocumentPatch(c, id, payload), opts.json);
|
|
318
|
+
return 0;
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
if (error instanceof EditError || error instanceof NoElement || error instanceof AmbiguousElement || error instanceof SelectorError)
|
|
322
|
+
return reportEdit(error);
|
|
323
|
+
return documentWriteError(error);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function modernFlagsCompatible(opts) {
|
|
327
|
+
if ((opts.legacy || opts.force || opts.ifMatch !== undefined) && (opts.baseRevision !== undefined || opts.exact)) {
|
|
328
|
+
fail("--legacy/--force/--if-match cannot combine with --base-revision or --exact");
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
export async function runNotesReplace(query, opts) {
|
|
334
|
+
if (!modernFlagsCompatible(opts))
|
|
335
|
+
return 1;
|
|
336
|
+
if (opts.legacy || opts.force || opts.ifMatch !== undefined)
|
|
337
|
+
return runLegacyNotesReplace(query, opts);
|
|
338
|
+
if (opts.text !== undefined && opts.html !== undefined) {
|
|
339
|
+
fail("--text is escaped and --html is not; give one");
|
|
340
|
+
return 1;
|
|
341
|
+
}
|
|
342
|
+
if (opts.html !== undefined) {
|
|
343
|
+
if (!opts.selector) {
|
|
344
|
+
fail("--html replaces an element's contents; say which with --selector");
|
|
345
|
+
return 1;
|
|
346
|
+
}
|
|
347
|
+
if (query !== undefined || opts.regex !== undefined) {
|
|
348
|
+
fail("--html replaces the whole element's contents; it cannot be combined with a query");
|
|
349
|
+
return 1;
|
|
350
|
+
}
|
|
351
|
+
return mutateDocument(opts, source => elementHtmlPlan(source, opts.selector, opts.html));
|
|
352
|
+
}
|
|
353
|
+
if (opts.text === undefined) {
|
|
354
|
+
fail("--text is the replacement; say what to put there");
|
|
355
|
+
return 1;
|
|
356
|
+
}
|
|
357
|
+
return mutateDocument(opts, source => opts.selector
|
|
358
|
+
? elementReplacementPlan(source, opts.selector, opts.text, whereFrom(query, opts))
|
|
359
|
+
: replacementPlan(source, opts.text, whereFrom(query, opts)));
|
|
360
|
+
}
|
|
361
|
+
export async function runNotesDelete(query, opts) {
|
|
362
|
+
if (!modernFlagsCompatible(opts))
|
|
363
|
+
return 1;
|
|
364
|
+
if (opts.legacy || opts.force || opts.ifMatch !== undefined)
|
|
365
|
+
return runLegacyNotesDelete(query, opts);
|
|
366
|
+
return mutateDocument(opts, source => opts.selector
|
|
367
|
+
? elementReplacementPlan(source, opts.selector, "", whereFrom(query, opts))
|
|
368
|
+
: removalPlan(source, whereFrom(query, opts)));
|
|
369
|
+
}
|
|
370
|
+
async function runLegacyNotesReplace(query, opts) {
|
|
371
|
+
if (opts.text !== undefined && opts.html !== undefined) {
|
|
372
|
+
fail("--text is escaped and --html is not; give one");
|
|
373
|
+
return 1;
|
|
374
|
+
}
|
|
375
|
+
if (opts.html !== undefined) {
|
|
376
|
+
if (!opts.selector) {
|
|
377
|
+
fail("--html replaces an element's contents; say which with --selector");
|
|
378
|
+
return 1;
|
|
379
|
+
}
|
|
380
|
+
if (query !== undefined || opts.regex !== undefined) {
|
|
381
|
+
// A query matches DECODED text and maps back to a source span; splicing
|
|
382
|
+
// markup into one of those can land inside a tag.
|
|
383
|
+
fail("--html replaces the whole element's contents; it cannot be combined with a query");
|
|
384
|
+
return 1;
|
|
385
|
+
}
|
|
386
|
+
return mutate(opts, (src) => setElementHtml(src, opts.selector, opts.html));
|
|
387
|
+
}
|
|
388
|
+
if (opts.text === undefined) {
|
|
389
|
+
fail("--text is the replacement; say what to put there");
|
|
390
|
+
return 1;
|
|
391
|
+
}
|
|
392
|
+
return mutate(opts, (src) => opts.selector
|
|
393
|
+
? replaceInElement(src, opts.selector, opts.text, whereFrom(query, opts))
|
|
394
|
+
: replace(src, opts.text, whereFrom(query, opts)));
|
|
395
|
+
}
|
|
396
|
+
/** Set an element's inner source verbatim. Markup, not escaped. */
|
|
397
|
+
export function elementHtmlPlan(source, css, html) {
|
|
398
|
+
const el = select(parse(source), css);
|
|
399
|
+
return [[el.inner[0], el.inner[1], html]];
|
|
400
|
+
}
|
|
401
|
+
export function setElementHtml(source, css, html) {
|
|
402
|
+
return applyEditPlan(source, elementHtmlPlan(source, css, html));
|
|
403
|
+
}
|
|
404
|
+
export async function runNotesInsert(opts) {
|
|
405
|
+
const compatibility = opts.legacy || opts.force || opts.ifMatch !== undefined;
|
|
406
|
+
if (compatibility) {
|
|
407
|
+
if (opts.baseRevision !== undefined || opts.exact) {
|
|
408
|
+
fail("--legacy/--force/--if-match cannot combine with --base-revision or --exact");
|
|
409
|
+
return 1;
|
|
410
|
+
}
|
|
411
|
+
return runLegacyNotesInsert(opts);
|
|
412
|
+
}
|
|
413
|
+
if (opts.text === undefined) {
|
|
414
|
+
fail("--text is what to insert");
|
|
415
|
+
return 1;
|
|
416
|
+
}
|
|
417
|
+
if (opts.selector && (opts.line !== undefined || opts.ind !== undefined)) {
|
|
418
|
+
fail("--selector and --line/--ind name different places; give one");
|
|
419
|
+
return 1;
|
|
420
|
+
}
|
|
421
|
+
if (!opts.selector && (opts.line === undefined) === (opts.ind === undefined)) {
|
|
422
|
+
fail("give exactly one of --line, --ind, or --selector");
|
|
423
|
+
return 1;
|
|
424
|
+
}
|
|
425
|
+
if (opts.baseRevision !== undefined && (!opts.baseRevision.trim() || opts.baseRevision === "*" || /[\r\n]/.test(opts.baseRevision))) {
|
|
426
|
+
fail("--base-revision requires the original retained revision");
|
|
427
|
+
return 1;
|
|
428
|
+
}
|
|
429
|
+
const ref = requireNote(opts);
|
|
430
|
+
if (!ref)
|
|
431
|
+
return 1;
|
|
432
|
+
const c = await ctx(opts);
|
|
433
|
+
if (!c)
|
|
434
|
+
return 1;
|
|
435
|
+
try {
|
|
436
|
+
const id = await resolveNote(c, ref);
|
|
437
|
+
if (!id)
|
|
438
|
+
return 1;
|
|
439
|
+
const source = await readDocumentSnapshot(c, id, opts.baseRevision);
|
|
440
|
+
const placement = opts.selector
|
|
441
|
+
? { at: elementInsertionPosition(source.content, opts.selector, opts.position ?? "append"), text: opts.text }
|
|
442
|
+
: insertPlacement(source.content, opts.text, {
|
|
443
|
+
line: opts.line === undefined ? undefined : singlePosition(opts.line, "--line"),
|
|
444
|
+
ind: opts.ind === undefined ? undefined : singlePosition(opts.ind, "--ind"),
|
|
445
|
+
});
|
|
446
|
+
const payload = documentInsertion(source, placement.at, placement.text, opts.exact);
|
|
447
|
+
if (opts.dryRun) {
|
|
448
|
+
const chars = Array.from(source.content);
|
|
449
|
+
const text = chars.slice(0, placement.at).join("") + placement.text + chars.slice(placement.at).join("");
|
|
450
|
+
if (opts.json)
|
|
451
|
+
emitJson({ dryRun: true, method: "PATCH", path: `/namespaces/${seg(c.ns)}/notes/${seg(id)}/body`, headers: {}, payload, text, ...(placement.text ? {} : { noChange: true }) });
|
|
452
|
+
else
|
|
453
|
+
process.stdout.write(text);
|
|
454
|
+
return 0;
|
|
455
|
+
}
|
|
456
|
+
if (!placement.text) {
|
|
457
|
+
if (opts.json)
|
|
458
|
+
emitJson({ note: id, hash: source.hash, revision: source.revision, noChange: true });
|
|
459
|
+
else
|
|
460
|
+
process.stdout.write(`note: ${id}\nhash: ${source.hash}\nrevision: ${source.revision}\nno change\n`);
|
|
461
|
+
return 0;
|
|
462
|
+
}
|
|
463
|
+
printPatchReceipt(await submitDocumentPatch(c, id, payload), opts.json);
|
|
464
|
+
return 0;
|
|
465
|
+
}
|
|
466
|
+
catch (error) {
|
|
467
|
+
if (error instanceof EditError || error instanceof NoElement || error instanceof AmbiguousElement || error instanceof SelectorError)
|
|
468
|
+
return reportEdit(error);
|
|
469
|
+
return documentWriteError(error);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
function singlePosition(raw, flag) {
|
|
473
|
+
if (!/^-?\d+$/.test(raw) || !Number.isSafeInteger(Number(raw)))
|
|
474
|
+
throw new EditError(`${flag} takes one safe integer position`);
|
|
475
|
+
return Number(raw);
|
|
476
|
+
}
|
|
477
|
+
async function runLegacyNotesInsert(opts) {
|
|
478
|
+
if (opts.text === undefined) {
|
|
479
|
+
fail("--text is what to insert");
|
|
480
|
+
return 1;
|
|
481
|
+
}
|
|
482
|
+
if (opts.selector) {
|
|
483
|
+
if (opts.line !== undefined || opts.ind !== undefined) {
|
|
484
|
+
// A selector and a line are two different places. Honouring either would
|
|
485
|
+
// insert somewhere the caller did not name.
|
|
486
|
+
fail("--selector and --line/--ind name different places; give one");
|
|
487
|
+
return 1;
|
|
488
|
+
}
|
|
489
|
+
return mutate(opts, (src) => insertAtElement(src, opts.selector, opts.text, opts.position ?? "append"));
|
|
490
|
+
}
|
|
491
|
+
if (opts.line === undefined && opts.ind === undefined) {
|
|
492
|
+
fail("say where: --line N, --ind N, or --selector CSS");
|
|
493
|
+
return 1;
|
|
494
|
+
}
|
|
495
|
+
return mutate(opts, (src) => insert(src, opts.text, {
|
|
496
|
+
line: opts.line !== undefined ? parseRange(opts.line, "--line") : undefined,
|
|
497
|
+
ind: opts.ind !== undefined ? parseRange(opts.ind, "--ind") : undefined,
|
|
498
|
+
}));
|
|
499
|
+
}
|
|
500
|
+
async function runLegacyNotesDelete(query, opts) {
|
|
501
|
+
return mutate(opts, (src) => opts.selector
|
|
502
|
+
? replaceInElement(src, opts.selector, "", whereFrom(query, opts))
|
|
503
|
+
: remove(src, whereFrom(query, opts)));
|
|
504
|
+
}
|
|
505
|
+
/** `dreamlake notes select "#contact" --note NOTE` */
|
|
506
|
+
export async function runNotesSelect(css, opts) {
|
|
507
|
+
const ref = requireNote(opts);
|
|
508
|
+
if (!ref)
|
|
509
|
+
return 1;
|
|
510
|
+
const c = await ctx(opts);
|
|
511
|
+
if (!c)
|
|
512
|
+
return 1;
|
|
513
|
+
try {
|
|
514
|
+
const id = await resolveNote(c, ref);
|
|
515
|
+
if (!id)
|
|
516
|
+
return 1;
|
|
517
|
+
const body = await readBody(c, id);
|
|
518
|
+
const doc = parse(body.text);
|
|
519
|
+
const el = select(doc, css);
|
|
520
|
+
const text = textPieces(doc, el).map((p) => p.decoded).join("");
|
|
521
|
+
if (opts.json) {
|
|
522
|
+
emitJson({
|
|
523
|
+
etag: body.etag,
|
|
524
|
+
tag: el.tag,
|
|
525
|
+
attrs: el.attrs,
|
|
526
|
+
outer: el.outer,
|
|
527
|
+
inner: el.inner,
|
|
528
|
+
text,
|
|
529
|
+
});
|
|
530
|
+
return 0;
|
|
531
|
+
}
|
|
532
|
+
process.stdout.write(`<${el.tag}> [${el.inner[0]},${el.inner[1]})\n${text}\n`);
|
|
533
|
+
return 0;
|
|
534
|
+
}
|
|
535
|
+
catch (e) {
|
|
536
|
+
return reportEdit(e);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
export async function runNotesGrep(query, opts) {
|
|
540
|
+
const c = await ctx(opts);
|
|
541
|
+
if (!c)
|
|
542
|
+
return 1;
|
|
543
|
+
try {
|
|
544
|
+
const limit = Math.max(1, Number(opts.limit ?? 50));
|
|
545
|
+
const base = new URLSearchParams();
|
|
546
|
+
if (query !== undefined)
|
|
547
|
+
base.set("q", query);
|
|
548
|
+
if (opts.regex !== undefined)
|
|
549
|
+
base.set("regex", opts.regex);
|
|
550
|
+
if (opts.flags)
|
|
551
|
+
base.set("flags", opts.flags);
|
|
552
|
+
if (opts.caseSensitive !== undefined)
|
|
553
|
+
base.set("caseSensitive", String(opts.caseSensitive));
|
|
554
|
+
if (opts.glob)
|
|
555
|
+
base.set("glob", opts.glob);
|
|
556
|
+
if (opts.note)
|
|
557
|
+
base.set("note", opts.note);
|
|
558
|
+
if (opts.context)
|
|
559
|
+
base.set("context", opts.context);
|
|
560
|
+
const hits = [];
|
|
561
|
+
let cursor = null;
|
|
562
|
+
let truncated = false;
|
|
563
|
+
let notesSearched = 0;
|
|
564
|
+
const partial = new Set();
|
|
565
|
+
let stale = 0;
|
|
566
|
+
// Pages are followed so `--limit` counts HITS. Where the server ended a
|
|
567
|
+
// page is invisible from here, so it must not decide how much you get.
|
|
568
|
+
for (;;) {
|
|
569
|
+
const qs = new URLSearchParams(base);
|
|
570
|
+
qs.set("limit", String(Math.min(limit - hits.length, 200)));
|
|
571
|
+
if (cursor)
|
|
572
|
+
qs.set("cursor", cursor);
|
|
573
|
+
const page = await requestJson(c.remote, `/namespaces/${seg(c.ns)}/notes/search?${qs.toString()}`, { token: c.token });
|
|
574
|
+
hits.push(...page.hits);
|
|
575
|
+
truncated = truncated || page.truncated;
|
|
576
|
+
notesSearched += page.notesSearched ?? 0;
|
|
577
|
+
for (const id of page.partialNotes ?? [])
|
|
578
|
+
partial.add(id);
|
|
579
|
+
stale = Math.max(stale, page.staleNotes ?? 0);
|
|
580
|
+
cursor = page.nextCursor;
|
|
581
|
+
if (!cursor || hits.length >= limit)
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
584
|
+
if (opts.json) {
|
|
585
|
+
emitJson({
|
|
586
|
+
hits,
|
|
587
|
+
truncated,
|
|
588
|
+
notesSearched,
|
|
589
|
+
partialNotes: [...partial],
|
|
590
|
+
staleNotes: stale,
|
|
591
|
+
nextCursor: cursor,
|
|
592
|
+
});
|
|
593
|
+
return 0;
|
|
594
|
+
}
|
|
595
|
+
// `slug:line:column: text`, which is `rg`'s shape — so the same eyes and
|
|
596
|
+
// the same editor jump-to-line plumbing work without translation.
|
|
597
|
+
for (const h of hits) {
|
|
598
|
+
for (const b of h.before)
|
|
599
|
+
process.stdout.write(`${h.noteSlug}-${b}\n`);
|
|
600
|
+
process.stdout.write(`${h.noteSlug}:${h.line}:${h.column}: ${h.text}\n`);
|
|
601
|
+
for (const a of h.after)
|
|
602
|
+
process.stdout.write(`${h.noteSlug}-${a}\n`);
|
|
603
|
+
}
|
|
604
|
+
// On stderr, where it cannot be mistaken for a result — and said at all
|
|
605
|
+
// because a bounded answer that looks complete is how "replace them all"
|
|
606
|
+
// quietly replaces some of them.
|
|
607
|
+
if (!hits.length)
|
|
608
|
+
process.stderr.write(`no matches in ${notesSearched} notes\n`);
|
|
609
|
+
if (truncated) {
|
|
610
|
+
process.stderr.write("note: a note held more matches than were returned — narrow the query\n");
|
|
611
|
+
}
|
|
612
|
+
if (partial.size) {
|
|
613
|
+
process.stderr.write(`note: ${partial.size} note(s) too large to index in full; their tails were not searched\n`);
|
|
614
|
+
}
|
|
615
|
+
if (stale) {
|
|
616
|
+
process.stderr.write(`note: ${stale} open note(s) could not be flushed first; their newest edits are missing\n`);
|
|
617
|
+
}
|
|
618
|
+
return 0;
|
|
619
|
+
}
|
|
620
|
+
catch (e) {
|
|
621
|
+
return reportEdit(e);
|
|
622
|
+
}
|
|
623
|
+
}
|