@kedem/okdb 2.4.0 → 2.6.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/CHANGELOG.md +160 -0
- package/algorithm-worker-thread.js +1 -1
- package/bin/okdb.js +1 -1
- package/docs/auth-and-sync.md +2 -1
- package/docs/auth-permissions.md +31 -5
- package/docs/change-log.md +6 -6
- package/docs/licensing.md +6 -1
- package/docs/migration.md +60 -1
- package/docs/plugins.md +1 -1
- package/docs/processors.md +1 -1
- package/docs/subscriptions.md +6 -4
- package/docs/views.md +4 -0
- package/okdb-functions-sandbox-worker.js +1 -1
- package/okdb-http-worker-child.js +1 -1
- package/okdb-views-bootstrap-worker.js +1 -1
- package/okdb.js +1 -1
- package/package.json +1 -1
- package/public/admin-app.js +1 -1
- package/public/components/schema-edit-modal.ok.js +1 -0
- package/public/core/db/db-section.ok.html +1 -0
- package/public/core/db/modals/add-item-modal.ok.js +1 -0
- package/public/core/db/modals/create-fts-modal.ok.js +1 -0
- package/public/core/db/modals/create-index-modal.ok.js +1 -0
- package/public/core/db/parts/db-overview.ok.js +1 -0
- package/public/core/db/parts/edit-row.ok.js +1 -0
- package/public/core/db/parts/type-changelog.ok.js +1 -0
- package/public/core/db/parts/type-data-tab.ok.js +1 -0
- package/public/core/db/parts/type-list.ok.js +1 -0
- package/public/core/db/parts/type-manage-tab.ok.js +1 -0
- package/public/core/db/parts/type-schema-tab.ok.js +1 -0
- package/public/core/db/parts/type-viewer.ok.js +1 -0
- package/public/core/db/type-ops.js +1 -0
- package/public/core/docs/docs-page.ok.html +1 -0
- package/public/core/license/license-panel.ok.js +1 -0
- package/public/core/system/parts/system-log.ok.js +1 -0
- package/public/core/system/parts/system-processing-panel.ok.js +1 -0
- package/public/core/system/parts/system-storage-panel.ok.js +1 -0
- package/public/core/system/system-events-page.ok.js +1 -0
- package/public/core/system/system-logs-page.ok.js +1 -0
- package/public/core/system/system-overview-page.ok.html +1 -0
- package/public/core/system/system-runtime-page.ok.js +1 -0
- package/public/core/system/system-section.ok.html +1 -0
- package/public/features/api/api-panel.ok.js +1 -0
- package/public/features/api/index.js +1 -0
- package/public/features/auth/auth-panel.ok.js +1 -0
- package/public/features/auth/index.js +1 -0
- package/public/features/files/files-section.ok.html +1 -0
- package/public/features/files/index.js +1 -0
- package/public/features/files/parts/files-file-list.ok.js +1 -0
- package/public/features/files/parts/files-path-browser.ok.js +1 -0
- package/public/features/files/parts/files-preview.ok.js +1 -0
- package/public/features/files/parts/files-upload-panel.ok.js +1 -0
- package/public/features/functions/exports.js +1 -0
- package/public/features/functions/functions-section.ok.html +1 -0
- package/public/features/functions/functions-store.js +1 -0
- package/public/features/functions/index.js +1 -0
- package/public/features/functions/modals/function-modal.ok.js +1 -0
- package/public/features/functions/parts/function-detail.ok.js +1 -0
- package/public/features/functions/parts/function-logs.ok.js +1 -0
- package/public/features/functions/parts/function-runner.ok.js +1 -0
- package/public/features/pipelines/engine-ui-utils.js +1 -0
- package/public/features/pipelines/exports.js +1 -0
- package/public/features/pipelines/index.js +1 -0
- package/public/features/pipelines/modals/create-pipeline-modal.ok.js +1 -0
- package/public/features/pipelines/modals/edit-pipeline-modal.ok.js +1 -0
- package/public/features/pipelines/modals/engine-modal.ok.js +1 -0
- package/public/features/pipelines/parts/embed-create-panel.ok.js +1 -0
- package/public/features/pipelines/parts/embed-embedder-panel.ok.js +1 -0
- package/public/features/pipelines/parts/embed-indexer-panel.ok.js +1 -0
- package/public/features/pipelines/parts/embed-search-panel.ok.js +1 -0
- package/public/features/pipelines/parts/embed-worker-panel.ok.js +1 -0
- package/public/features/pipelines/parts/embeddings-engine-panel.ok.js +1 -0
- package/public/features/pipelines/parts/engine-declaration-editor.ok.js +1 -0
- package/public/features/pipelines/parts/engines-overview.ok.js +1 -0
- package/public/features/pipelines/parts/generic-engine-panel.ok.js +1 -0
- package/public/features/pipelines/parts/pipeline-create-panel.ok.js +1 -0
- package/public/features/pipelines/parts/pipeline-flow-strip.ok.js +1 -0
- package/public/features/pipelines/parts/type-pipelines-tab.ok.js +1 -0
- package/public/features/pipelines/pipelines-section.ok.html +1 -0
- package/public/features/queue/index.js +1 -0
- package/public/features/queue/modals/create-bucket-modal.ok.js +1 -0
- package/public/features/queue/modals/edit-bucket-modal.ok.js +1 -0
- package/public/features/queue/modals/edit-job-modal.ok.js +1 -0
- package/public/features/queue/modals/enqueue-job-modal.ok.js +1 -0
- package/public/features/queue/modals/job-type-modal.ok.js +1 -0
- package/public/features/queue/parts/job-log-panel.ok.js +1 -0
- package/public/features/queue/parts/queue-buckets.ok.js +1 -0
- package/public/features/queue/parts/queue-job-types.ok.js +1 -0
- package/public/features/queue/parts/queue-jobs.ok.js +1 -0
- package/public/features/queue/parts/queue-types.ok.js +1 -0
- package/public/features/queue/parts/queue-workers.ok.js +1 -0
- package/public/features/queue/queue-section.ok.html +1 -0
- package/public/features/sync/index.js +1 -0
- package/public/features/sync/sync-panel.ok.js +1 -0
- package/public/features/views/index.js +1 -0
- package/public/features/views/modals/create-view-modal.ok.js +1 -0
- package/public/features/views/parts/views-list.ok.js +1 -0
- package/public/features/views/parts/views-overview.ok.js +1 -0
- package/public/features/views/views-section.ok.html +1 -0
- package/public/features/views/views-store.js +1 -0
- package/public/index.html +9 -3
- package/public/modules/ok.js +1 -1
- package/public/shell/admin-shell.ok.html +3 -0
- package/public/shell/core-manifest.js +1 -0
- package/public/shell/shell-piece.ok.js +1 -0
- package/public/shell/shell-section-host.ok.js +1 -0
- package/public/shell/shell-section.ok.js +1 -0
- package/public/shell/shell-store.js +1 -0
- package/public/stores/auth-store.js +1 -1
- package/public/stores/okdb-store.js +1 -1
- package/public/stores/storage-store.js +1 -0
- package/public/styles.css +1 -1
- package/public/vendor/okjs/ok.esm.min.js +1 -1
- package/public/vendor/okjs/toolkit/components/ok-chart.ok.js +1 -1
- package/public/vendor/okjs/toolkit/components/ok-doc-viewer.ok.js +1 -1
- package/public/vendor/okjs/toolkit/components/ok-marked.ok.js +1 -1
- package/public/vendor/okjs/toolkit/components/ok-monaco.ok.js +1 -1
- package/types/okdb.d.ts +20 -0
- package/public/components/admin-route-host.ok.js +0 -1
- package/public/components/field.html +0 -158
- package/public/layouts/_default.ok.html +0 -3
- package/public/sections/api/index.ok.html +0 -1
- package/public/sections/auth/index.ok.html +0 -1
- package/public/sections/auth/modals/perm-info-popover.ok.js +0 -1
- package/public/sections/db/index.ok.html +0 -1
- package/public/sections/db/modals/add-item-modal.ok.js +0 -1
- package/public/sections/db/modals/create-fts-modal.ok.js +0 -1
- package/public/sections/db/modals/create-index-modal.ok.js +0 -1
- package/public/sections/db/modals/create-pipeline-modal.ok.js +0 -1
- package/public/sections/db/modals/schema-edit-modal.ok.js +0 -1
- package/public/sections/db/parts/db-overview.ok.js +0 -1
- package/public/sections/db/parts/edit-row.ok.js +0 -1
- package/public/sections/db/parts/type-changelog.ok.js +0 -1
- package/public/sections/db/parts/type-list.ok.js +0 -1
- package/public/sections/db/parts/type-pipelines-tab.ok.js +0 -1
- package/public/sections/db/parts/type-schema-tab.ok.js +0 -1
- package/public/sections/db/parts/type-viewer.ok.js +0 -1
- package/public/sections/db/parts/type-violations-tab.ok.js +0 -1
- package/public/sections/docs/index.ok.html +0 -1
- package/public/sections/embeddings/index.ok.html +0 -1
- package/public/sections/embeddings/modals/edit-pipeline-modal.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-create-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-embedder-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-engine-declaration-editor.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-engine-list.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-indexer-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-lifecycle-bar.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-overview.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-search-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-worker-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/embeddings-engine-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/engines-overview.ok.js +0 -1
- package/public/sections/embeddings/parts/pipeline-create-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/pipeline-flow-strip.ok.js +0 -1
- package/public/sections/engines/engine-ui-utils.js +0 -1
- package/public/sections/engines/index.ok.html +0 -1
- package/public/sections/engines/modals/engine-modal.ok.js +0 -1
- package/public/sections/engines/parts/engine-declaration-editor.ok.js +0 -1
- package/public/sections/engines/parts/generic-engine-panel.ok.js +0 -1
- package/public/sections/files/index.ok.html +0 -1
- package/public/sections/files/parts/files-collection-list.ok.js +0 -1
- package/public/sections/files/parts/files-collection-panel.ok.js +0 -1
- package/public/sections/files/parts/files-file-list.ok.js +0 -1
- package/public/sections/files/parts/files-path-browser.ok.js +0 -1
- package/public/sections/files/parts/files-preview.ok.js +0 -1
- package/public/sections/files/parts/files-upload-panel.ok.js +0 -1
- package/public/sections/functions/index.ok.html +0 -1
- package/public/sections/functions/modals/function-modal.ok.js +0 -1
- package/public/sections/functions/parts/function-detail.ok.js +0 -1
- package/public/sections/functions/parts/function-logs.ok.js +0 -1
- package/public/sections/functions/parts/function-runner.ok.js +0 -1
- package/public/sections/license/index.ok.html +0 -1
- package/public/sections/license/parts/license-panel.ok.js +0 -1
- package/public/sections/queue/index.ok.html +0 -1
- package/public/sections/queue/modals/create-bucket-modal.ok.js +0 -1
- package/public/sections/queue/modals/edit-bucket-modal.ok.js +0 -1
- package/public/sections/queue/modals/edit-job-modal.ok.js +0 -1
- package/public/sections/queue/modals/enqueue-job-modal.ok.js +0 -1
- package/public/sections/queue/modals/job-type-modal.ok.js +0 -1
- package/public/sections/queue/parts/job-log-panel.ok.js +0 -1
- package/public/sections/queue/parts/ok-job-form.ok.js +0 -1
- package/public/sections/queue/parts/queue-buckets.ok.js +0 -1
- package/public/sections/queue/parts/queue-job-types.ok.js +0 -1
- package/public/sections/queue/parts/queue-jobs.ok.js +0 -1
- package/public/sections/queue/parts/queue-types.ok.js +0 -1
- package/public/sections/queue/parts/queue-workers.ok.js +0 -1
- package/public/sections/sync/index.ok.html +0 -5
- package/public/sections/sync/parts/sync-node-detail.ok.js +0 -1
- package/public/sections/system/index.ok.html +0 -1
- package/public/sections/system/parts/system-api-panel.ok.js +0 -1
- package/public/sections/system/parts/system-auth-panel.ok.js +0 -1
- package/public/sections/system/parts/system-log.ok.js +0 -1
- package/public/sections/system/parts/system-processing-panel.ok.js +0 -1
- package/public/sections/system/parts/system-status.ok.js +0 -1
- package/public/sections/system/parts/system-storage-panel.ok.js +0 -1
- package/public/sections/system/parts/system-sync-panel.ok.js +0 -1
- package/public/sections/views/index.ok.html +0 -1
- package/public/sections/views/modals/create-view-modal.ok.js +0 -1
- package/public/sections/views/parts/views-list.ok.js +0 -1
- package/public/sections/views/parts/views-overview.ok.js +0 -1
- package/public/stores/functions-store.js +0 -1
- /package/public/{sections → core}/db/parts/tm-timeline.ok.js +0 -0
- /package/public/{util → core/db}/sift-schema.js +0 -0
- /package/public/{view-models → core/db}/type-query-vm.js +0 -0
- /package/public/{sections → core}/system/modals/data-ops-modal.ok.js +0 -0
- /package/public/{sections → core}/system/parts/system-locks-panel.ok.js +0 -0
- /package/public/{sections → core}/system/parts/system-log-history.ok.js +0 -0
- /package/public/{sections → core}/system/parts/system-process-panel.ok.js +0 -0
- /package/public/{sections → core}/system/parts/system-runtime-overview.ok.js +0 -0
- /package/public/{sections → features}/api/parts/api-endpoint.ok.js +0 -0
- /package/public/{sections → features}/auth/modals/create-token-modal.ok.js +0 -0
- /package/public/{sections → features}/auth/modals/edit-token-modal.ok.js +0 -0
- /package/public/{sections → features}/auth/parts/token-detail.ok.js +0 -0
- /package/public/{sections → features}/auth/parts/token-list.ok.js +0 -0
- /package/public/{sections → features}/files/parts/files-blob-status.ok.js +0 -0
- /package/public/{sections → features}/files/parts/files-overview.ok.js +0 -0
- /package/public/{sections → features}/functions/parts/functions-list.ok.js +0 -0
- /package/public/{sections/engines → features/pipelines}/engine-panel-shared-style.js +0 -0
- /package/public/{sections/embeddings → features/pipelines}/modals/register-model-modal.ok.js +0 -0
- /package/public/{sections/embeddings → features/pipelines}/modals/replace-embedder-modal.ok.js +0 -0
- /package/public/{sections/embeddings → features/pipelines}/parts/embed-model-catalog.ok.js +0 -0
- /package/public/{sections/engines → features/pipelines}/parts/engine-lifecycle-actions.ok.js +0 -0
- /package/public/{sections/engines → features/pipelines}/parts/engine-panel-shell.ok.js +0 -0
- /package/public/{sections/engines → features/pipelines}/parts/engine-resource-card.ok.js +0 -0
- /package/public/{sections/engines → features/pipelines}/parts/engine-row-item.ok.js +0 -0
- /package/public/{sections/embeddings → features/pipelines}/parts/pipeline-try-search.ok.js +0 -0
- /package/public/{sections → features}/queue/parts/code-panel.ok.js +0 -0
- /package/public/{sections → features}/sync/modals/connect-peer-modal.ok.js +0 -0
- /package/public/{sections → features}/sync/parts/sync-retention.ok.js +0 -0
- /package/public/{sections → features}/sync/parts/sync-topology.ok.js +0 -0
- /package/public/{sections → features}/views/parts/view-detail.ok.js +0 -0
- /package/public/{sections/db → shell}/modals/create-env-modal.ok.js +0 -0
- /package/public/{sections/db → shell}/modals/demo-env-modal.ok.js +0 -0
- /package/public/{sections/db → shell}/modals/remove-env-modal.ok.js +0 -0
package/docs/auth-and-sync.md
CHANGED
|
@@ -146,7 +146,8 @@ Pull-based, last-write-wins replication over HTTP; no coordinator, no consensus.
|
|
|
146
146
|
```
|
|
147
147
|
|
|
148
148
|
Each node has a persistent `nodeId` (`__identity`) and an Ed25519 keypair (`__nodePrivateKey` /
|
|
149
|
-
`__nodePublicKey`), generated on first
|
|
149
|
+
`__nodePublicKey`), generated on first use (the first sync operation that needs it — a join, a
|
|
150
|
+
signed request, the node's own `~sync_nodes` record) and never replicated. Peers are recorded in the
|
|
150
151
|
`~sync_nodes` type in `~system` — with their address and **public key** — which itself replicates,
|
|
151
152
|
so the mesh forms from one join.
|
|
152
153
|
|
package/docs/auth-permissions.md
CHANGED
|
@@ -40,9 +40,14 @@ These are global only (per-env grants cannot hold them).
|
|
|
40
40
|
| Namespace | Operations | What it covers |
|
|
41
41
|
| --------- | ----------------------- | ----------------------------------------------------------------------- |
|
|
42
42
|
| `auth` | `read`, `write` | API tokens and users |
|
|
43
|
-
| `system` | `read`, `write` | Server info, logs, events, processor status, backups, engines
|
|
43
|
+
| `system` | `read`, `write` | Server info, logs, events, processor status, backups, engines, licence |
|
|
44
44
|
| `sync` | `read`, `write`, `peer` | Cluster replication — `peer` is for machine-to-machine only (see below) |
|
|
45
45
|
|
|
46
|
+
The `/api/env/:env/engines…` routes are `system:*` (so a grant must be global — see above) but
|
|
47
|
+
still declare `scope: 'env'`: a token needs `system:write` to manage engines anywhere, and
|
|
48
|
+
additionally `protected:write` to manage them in a `~`-prefixed env such as `~system` (see
|
|
49
|
+
[The `protected` gate](#the-protected-gate)). `ttl` routes follow the same pattern.
|
|
50
|
+
|
|
46
51
|
### Gate
|
|
47
52
|
|
|
48
53
|
| Namespace | Operations | What it covers |
|
|
@@ -86,10 +91,13 @@ Shape of a token with per-env grants:
|
|
|
86
91
|
The token can list tokens globally, read records in `production`, and do anything data-related in `staging`.
|
|
87
92
|
|
|
88
93
|
:::note
|
|
89
|
-
Per-env grants are only consulted on routes that resolve their env from the path
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
Per-env grants are only consulted on routes that resolve their env from the path (the route
|
|
95
|
+
declares `access.scope: 'env'` or `{ env: 'params.env' }`). That covers every env-scoped
|
|
96
|
+
feature — records, types/indexes/TTL/FTS/vector, views, subscriptions, env admin, files, queue,
|
|
97
|
+
functions, pipelines and time machine — so e.g. a per-env `files:read` or `queue:work` grant
|
|
98
|
+
works exactly like a per-env `data:read` grant. `tests/auth-routes-have-permissions.test.js`
|
|
99
|
+
fails the build for any `:env` route whose permission is missing that declaration, so this list
|
|
100
|
+
stays accurate.
|
|
93
101
|
:::
|
|
94
102
|
|
|
95
103
|
## The `protected` gate
|
|
@@ -110,6 +118,24 @@ is only applied on routes that resolve their env from the path (see the note abo
|
|
|
110
118
|
|
|
111
119
|
`sync:peer` gates the cluster replication endpoints. A node holding this token can receive replicated data for any namespace. **Do not grant it to human users.**
|
|
112
120
|
|
|
121
|
+
## Time machine, licence, and setup permissions
|
|
122
|
+
|
|
123
|
+
- **Time machine** (`/api/env/:env/time-machine…`) is env-scoped (`scope: 'env'`), so per-env
|
|
124
|
+
grants and the protected `~` env gate both apply:
|
|
125
|
+
- Status/config reads (`GET …/time-machine`, `…/types`, `…/types/:type`, the deprecated
|
|
126
|
+
`…/status`) need `schema:read` — the same permission as index/FTS status.
|
|
127
|
+
- Document history, point-in-time state, and diffs (`…/:type/:key/history`, `…/:type/:key/at/:clock`,
|
|
128
|
+
`…/changes`) are document contents, so they need `data:read`.
|
|
129
|
+
- Enabling/disabling/dropping/flushing tracking (`…/types/:type/enable|disable|drop|flush`,
|
|
130
|
+
`…/enable-all`, `…/disable-all`, incl. the deprecated per-env `…/enable`/`…/disable`) needs
|
|
131
|
+
`schema:write` — the same permission as registering or dropping an index.
|
|
132
|
+
- **Licence** (`/admin/license…`) is a `system:*` namespace, so it is global only:
|
|
133
|
+
`GET /admin/license/status` needs `system:read`; `POST /admin/license`,
|
|
134
|
+
`POST /admin/license/:id/activate` and `DELETE /admin/license/:id` need `system:write`.
|
|
135
|
+
- **Setup join** (`POST /admin/setup/join`) needs `sync:write` — joining starts replicating this
|
|
136
|
+
node's data to the remote, so it is cluster configuration like `PUT /api/sync/links`. First-run
|
|
137
|
+
setup in open/bootstrap mode bypasses the permission check (there is no token yet).
|
|
138
|
+
|
|
113
139
|
## Cookbook: common token recipes
|
|
114
140
|
|
|
115
141
|
### Read-only browser client
|
package/docs/change-log.md
CHANGED
|
@@ -171,13 +171,13 @@ Async (`single`/`fanout`) handlers receive change-log records:
|
|
|
171
171
|
|
|
172
172
|
### originMode
|
|
173
173
|
|
|
174
|
-
`origin` is the
|
|
174
|
+
`origin` is the identity of the store that made the write — every process on the same path shares it, so `'remote'` means writes synced in from other stores. A cloned store counts its history from before the copy as its own. The filter applies to inline and async processors alike (live drains, log replay, and the snapshot bootstrap); a drain chunk that is filtered out entirely still advances the cursor.
|
|
175
175
|
|
|
176
|
-
| Value | Fires when
|
|
177
|
-
| ---------- |
|
|
178
|
-
| `'self'` | **Default.** Only writes made by this
|
|
179
|
-
| `'remote'` | Only writes made by other
|
|
180
|
-
| `'all'` | Any write
|
|
176
|
+
| Value | Fires when |
|
|
177
|
+
| ---------- | --------------------------------------------- |
|
|
178
|
+
| `'self'` | **Default.** Only writes made by this store |
|
|
179
|
+
| `'remote'` | Only writes made by other stores (sync peers) |
|
|
180
|
+
| `'all'` | Any write |
|
|
181
181
|
|
|
182
182
|
This is useful for reacting differently to local vs. replicated changes — e.g., sending a notification only when your own node creates a record, not when it receives one from a peer.
|
|
183
183
|
|
package/docs/licensing.md
CHANGED
|
@@ -180,13 +180,18 @@ A missing or invalid file is a warning naming the error code — never the file'
|
|
|
180
180
|
## Node identity, reset, and moving a database
|
|
181
181
|
|
|
182
182
|
The activation is bound to the node identity created when the database was first initialized.
|
|
183
|
-
|
|
183
|
+
Consequences:
|
|
184
184
|
|
|
185
185
|
- **`okdb reset` preserves your license.** The reset command deliberately carries the node
|
|
186
186
|
identity and all stored licenses into the fresh database, so activation survives.
|
|
187
187
|
- **Deleting the data directory by hand does not.** A new directory means a new node identity;
|
|
188
188
|
previously activated licenses show `wrong_node` and need a re-activation from your vendor
|
|
189
189
|
(add the license again, send the new PIN).
|
|
190
|
+
- **A clone is a new node.** `OKDB.clone()`, `OKDB.reidentify()` and
|
|
191
|
+
`okdb restore --new-identity` give the copy its own identity: its licence records come along,
|
|
192
|
+
but a node-bound activation shows `wrong_node` there until the copy is activated with its own
|
|
193
|
+
PIN. The source keeps its activation. See
|
|
194
|
+
[Cloning a store](migration.md#cloning-a-store-new-identity).
|
|
190
195
|
|
|
191
196
|
The same applies to copying a license between machines: the blob can be added anywhere, but
|
|
192
197
|
each node needs its own activation.
|
package/docs/migration.md
CHANGED
|
@@ -5,6 +5,7 @@ OKDB's migration feature handles export/import of all types and records as JSON
|
|
|
5
5
|
| You want | Use |
|
|
6
6
|
| ----------------------------------------- | --------------------------------------------------------------------------------- |
|
|
7
7
|
| a restorable copy of the whole store | [`migrate.backup(dir)`](#hot-backup-and-restore) / `okdb backup` + `okdb restore` |
|
|
8
|
+
| a copy that is a store of its own | [`OKDB.clone(src, dst)`](#cloning-a-store-new-identity) / `OKDB.reidentify(dir)` |
|
|
8
9
|
| portable, version-independent data | [`migrate.exportToFile()`](#streaming-export-ndjson) / `okdb export` |
|
|
9
10
|
| a small in-memory snapshot (tests, demos) | `migrate.export()` / `exportJSON()` |
|
|
10
11
|
|
|
@@ -196,7 +197,9 @@ overwrites. The result directory **is a store**: open OKDB on it (or on a copy o
|
|
|
196
197
|
`okdb restore <backup> --path <target>` copies it into a new/empty target. Things to know:
|
|
197
198
|
|
|
198
199
|
- The restored store has the **same node identity** as the source. Do not run it as a sync
|
|
199
|
-
peer alongside the original — restore replaces a node, it does not clone one.
|
|
200
|
+
peer alongside the original — restore replaces a node, it does not clone one. To bring the
|
|
201
|
+
copy up as a **new** node instead, use `okdb restore <backup> --path <target> --new-identity`
|
|
202
|
+
(or `OKDB.reidentify(target)`) — see [Cloning a store](#cloning-a-store-new-identity).
|
|
200
203
|
- An env registered with an absolute path _outside_ the store (legacy / hand-edited records
|
|
201
204
|
only; `createEnvironment` always places envs under the root) is copied to its default
|
|
202
205
|
placement and flagged `outOfTree` in the manifest; while its original path still exists,
|
|
@@ -216,6 +219,62 @@ new OKDB('/data/okdb', { backup: { root: '/mnt/backups/okdb' } });
|
|
|
216
219
|
|
|
217
220
|
---
|
|
218
221
|
|
|
222
|
+
## Cloning a store (new identity)
|
|
223
|
+
|
|
224
|
+
Every store has a node identity (`db.id`), created on its first open. A byte copy keeps it, so
|
|
225
|
+
two copies of one store behave as one node: they join the same bus group (and receive each
|
|
226
|
+
other's change and compaction signals), share the sync node id, keypair and token secret, and
|
|
227
|
+
match the same licence activation. Use `OKDB.clone()` whenever a copy must be a store of its
|
|
228
|
+
own — test templates, a staging copy, a backup brought up next to the original.
|
|
229
|
+
|
|
230
|
+
```javascript
|
|
231
|
+
await OKDB.clone('/data/template', '/tmp/test-42'); // → { path, files, bytes, ms }
|
|
232
|
+
const db = new OKDB('/tmp/test-42');
|
|
233
|
+
await db.open(); // the first open gives the copy its own identity
|
|
234
|
+
db.id; // new UUID
|
|
235
|
+
db.formerIds; // [ '<template id>' ]
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
- **The source must be closed** by every process. A copy of a running store is not consistent
|
|
239
|
+
across its LMDB files, so `clone()` refuses with `STORE_IN_USE` when a process has the store
|
|
240
|
+
open (detected on Linux from the LMDB file locks; on other platforms this is your
|
|
241
|
+
responsibility). For a store that must stay up, take a [hot backup](#hot-backup-and-restore)
|
|
242
|
+
and re-identify it: `await db.migrate.backup(dir); OKDB.reidentify(dir)`.
|
|
243
|
+
- `dstPath` must not exist or be empty (`CLONE_DEST_NOT_EMPTY`), and must not overlap the source.
|
|
244
|
+
- **Everything is copied** — every env, `~fts`, time-machine history, `~vectors`, `~blobs`, views,
|
|
245
|
+
indexes and processor cursors — **except** LMDB `lock.mdb` files, the disposable `~processes`
|
|
246
|
+
env, upload staging (`~blobs/tmp`) and compaction leftovers. The copy is fast (a file copy,
|
|
247
|
+
reflinked where the filesystem supports it: a small store clones in a few milliseconds) and
|
|
248
|
+
opens with every index, view and search index ready — nothing is rebuilt or reprocessed.
|
|
249
|
+
- Envs are expected to live under the store directory (the default). If an env was registered at
|
|
250
|
+
an absolute path outside it and that directory exists, the copy's first open refuses with
|
|
251
|
+
`REIDENTIFY_OUT_OF_TREE_ENV` instead of opening the source's files.
|
|
252
|
+
|
|
253
|
+
**`OKDB.reidentify(path)`** marks a closed copy you made yourself (`cp -r`, a restored backup) to
|
|
254
|
+
take a new identity on its next open — the same step `clone()` ends with. It only writes a small
|
|
255
|
+
marker file (`okdb-reidentify.json`) at the store root; the store's **first open** applies it,
|
|
256
|
+
exactly once, even when several processes open the copy at the same time. Marking is idempotent,
|
|
257
|
+
and a marked copy that is copied again before it is opened still gives each copy its own identity.
|
|
258
|
+
A store that has already been opened under its new identity is an ordinary store: copying it
|
|
259
|
+
again needs another `clone()` / `reidentify()`.
|
|
260
|
+
|
|
261
|
+
**What the first open changes** — and what it keeps:
|
|
262
|
+
|
|
263
|
+
| Area | On the copy |
|
|
264
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
265
|
+
| Identity | a new `db.id`; the old one is kept in `db.formerIds`. The bus group (`okdb-<id>`) follows the id, so the copy and the source never hear each other. |
|
|
266
|
+
| Secrets | a new token secret (sessions signed by the source stop validating, unless you set `auth.token.secret` yourself) and a new sync keypair (minted on first sync use). Stored users and API tokens are data and are copied. |
|
|
267
|
+
| Sync | not a member of anything: no `~sync_nodes` / `~sync_links` rows, no peer cursors. They are removed from the copy's changelog too, so nothing it later sends can delete them in the source's cluster. `db.sync.join(...)` makes it a new node, which pulls the topology back. |
|
|
268
|
+
| Licences | records are kept. A node-bound (standard) activation shows `wrong_node` on the copy; activate it again with the copy's own PIN. Open and internal licences, and `OKDB_LICENSE_FILE` installs of them, keep working. |
|
|
269
|
+
| Processes | leases, want-markers, the migration lock and process-keyed control rows are dropped — they belonged to the source's processes. |
|
|
270
|
+
| Changelog | kept as-is, origins included. Changes stamped with a former identity up to the point the copy was made count as the copy's own (`originMode: 'self'`); a former identity's later changes — the source's, synced in — are remote. |
|
|
271
|
+
| Data and derived | untouched: documents, indexes, views, FTS, time machine, vectors, files, queue jobs and every processor cursor. |
|
|
272
|
+
|
|
273
|
+
Queue jobs that were claimed when the source closed are recovered by the normal claim-timeout
|
|
274
|
+
path, as after a restart.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
219
278
|
## Logical backup workflow
|
|
220
279
|
|
|
221
280
|
A version-independent alternative to the hot backup (slower; re-derives indexes on import):
|
package/docs/plugins.md
CHANGED
|
@@ -75,7 +75,7 @@ Plugin name must not conflict with existing OKDB properties (`env`, `put`, `get`
|
|
|
75
75
|
| `instance.start(okdb)` | async | **yes** | Start servers, timers, workers |
|
|
76
76
|
| `instance.stop(okdb)` | async | **yes** | Stop everything started in `start()` |
|
|
77
77
|
|
|
78
|
-
`start`/`stop` are optional. Plugins start in registration order at the end of `open()` and stop in reverse order during `close()`. If any plugin's `start()` throws, all already-started plugins are stopped in reverse order
|
|
78
|
+
`start`/`stop` are optional. Plugins start in registration order at the end of `open()` and stop in reverse order during `close()`. If any plugin's `start()` throws, all already-started plugins are stopped in reverse order (the throwing plugin's `stop()` is not called), then `open()` releases everything else it had opened and rethrows the error; the instance is left stopped, so `close()` is a no-op.
|
|
79
79
|
|
|
80
80
|
---
|
|
81
81
|
|
package/docs/processors.md
CHANGED
|
@@ -82,7 +82,7 @@ Both are called as `fn(ctx, changes, info)`. A bare closure (`handler: async (ch
|
|
|
82
82
|
|
|
83
83
|
`changes` are change-log records (`{ type, key, action, clock, origin, ... }`). With the default `hydrateValues: true`, `put` records also carry `.value` (the current document); otherwise read the document via `ctx.env.get(c.type, c.key)`.
|
|
84
84
|
|
|
85
|
-
`originMode` filters by who wrote the change (compared to the change's `origin`, the writing
|
|
85
|
+
`originMode` filters by who wrote the change (compared to the change's `origin`, the writing store's identity — shared by every process on the same path): `self` (default — this store's writes, including a cloned store's history from before the copy), `remote` (writes synced in from other stores), or `all`. It applies on every delivery path — inline, async live drains, log replay and the snapshot bootstrap (which judges each doc by its latest change). A drain chunk whose changes are all filtered out is not delivered, and the cursor still moves past it. A `quantum` module receives the mode as `payload.originMode` and applies it itself with `filterByOrigin` (`src/runtime/okdb-processor-origin.js`), as the built-in quanta do. Async processors with `remote`/`all` also wake on cross-process writes via the bus.
|
|
86
86
|
|
|
87
87
|
**`rebuild` (snapshot-bootstrap processors).** With `bootstrap: 'snapshot'` you may pass `rebuild: async () => { ... }` — a feature-owned **full rebuild** (scan the actual docs, then reposition the cursor via `setCursor` + `markSnapshotComplete`). It runs whenever the processor bootstraps with an **un-positioned cursor**: after a cursor reset (the admin ⟲ "full reprocess"), or when a build handoff was interrupted by a crash. Without it, the framework's only option is replaying the changelog from 0 — which is **not** a rebuild: sync-GC prunes the changelog (its horizon ignores processor cursors), so replay-from-0 can silently yield a partial derived store. FTS registers one (re-scans all docs of the type into every index, clearing first).
|
|
88
88
|
|
package/docs/subscriptions.md
CHANGED
|
@@ -230,10 +230,12 @@ Subscription state lives in a dedicated environment named `~sub`, opened `sync:f
|
|
|
230
230
|
`onDelete: cascade`, and a reverse index on `[dataEnv, type, key]` for O(interested
|
|
231
231
|
sessions) routing.
|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
233
|
+
Everything is lazy. The `~sub` store and the signal router are built on a process's first
|
|
234
|
+
subscription use (its first SSE connection or control call), never at `open()` — a store that
|
|
235
|
+
never had a subscriber has no `~sub` env at all. Routing is lazy too: a process routes changes
|
|
236
|
+
only while it holds at least one open subscription connection (signals are only ever delivered
|
|
237
|
+
to connections on the process that holds them). An embedded instance that never serves
|
|
238
|
+
subscriptions does no per-change subscription work, and no change-feed is started on its behalf.
|
|
237
239
|
|
|
238
240
|
The `~sub` _env_ name starts with `~` so its writes stay out of the data change-feed, while
|
|
239
241
|
the non-`~` type names keep FK cascade and TTL working. `sync:false` keeps machine-bound
|
package/docs/views.md
CHANGED
|
@@ -694,6 +694,10 @@ See [pipelines.md](./pipelines.md) for materializer documentation.
|
|
|
694
694
|
|
|
695
695
|
View definitions are stored in the `~views` system type within their environment and sync to connected peers like any other document. On startup and after each sync reconcile pass, OKDB activates any view definitions that arrived from remote peers but are not yet live locally.
|
|
696
696
|
|
|
697
|
+
A view counts every document of its source types, whoever wrote it: documents synced in from a peer are maintained live exactly like local writes — by sync and async views, `$ref` sections and live map `$ref`s alike — so a view's live result always equals what a rebuild of the same data gives. Up to okdb 2.4.0 the sync-mode handlers (sync views, and every view's `$ref` / live map `$ref` sections) skipped remote-origin writes. View storage version 7 repairs that once, on first open: on a store that has or had a sync peer (a peer in `~sync_nodes`, a peer sync cursor, a sync link, or a cloned / re-identified store) those views rebuild; everywhere else — pure async views, and every view on a store that never synced — the version is restamped without a rebuild, since nothing can be missing. One info line (`views storage v7: …`) logs the decision and its reason.
|
|
698
|
+
|
|
699
|
+
The one case the upgrade cannot see: writes stamped with an explicit foreign `origin` (`put(..., { origin })`) on a store that never synced. If a sync-mode view was fed such writes before the upgrade, repair it with `await env.views.rebuild(name)`.
|
|
700
|
+
|
|
697
701
|
---
|
|
698
702
|
|
|
699
703
|
## Error codes
|