@kedem/okdb 1.0.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/LICENSE +57 -0
- package/README.md +344 -0
- package/banner.jpg +0 -0
- package/bin/okdb.js +2 -0
- package/docs/OKDB-ARCHITECTURE.md +1036 -0
- package/docs/auth-and-sync.md +558 -0
- package/docs/auth-permissions.md +143 -0
- package/docs/change-log.md +169 -0
- package/docs/data-model.md +174 -0
- package/docs/embeddings.md +338 -0
- package/docs/files.md +131 -0
- package/docs/fts.md +139 -0
- package/docs/functions.md +514 -0
- package/docs/getting-started.md +233 -0
- package/docs/http-api.md +705 -0
- package/docs/index.md +115 -0
- package/docs/indexes.md +207 -0
- package/docs/logging.md +116 -0
- package/docs/manifest.json +38 -0
- package/docs/migration.md +154 -0
- package/docs/pipelines.md +598 -0
- package/docs/plugins.md +144 -0
- package/docs/querying.md +204 -0
- package/docs/queue.md +637 -0
- package/docs/sync.md +156 -0
- package/docs/transactions.md +140 -0
- package/docs/ttl.md +375 -0
- package/okdb.js +1 -0
- package/package.json +26 -0
- package/public/admin-app.js +1 -0
- package/public/android-chrome-192x192.png +0 -0
- package/public/android-chrome-512x512.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/components/admin-route-host.ok.js +1 -0
- package/public/components/env-picker.ok.js +1 -0
- package/public/components/field-path-input.ok.js +1 -0
- package/public/components/field.html +6 -0
- package/public/components/geo-map.ok.js +1 -0
- package/public/components/ok-cron-input.ok.js +1 -0
- package/public/components/ok-dropzone.ok.js +1 -0
- package/public/components/ok-js-input.ok.js +1 -0
- package/public/components/ok-json-input.ok.js +1 -0
- package/public/components/ok-text-monaco-input.ok.js +1 -0
- package/public/components/theme-toggle.ok.js +1 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/images/logo.png +0 -0
- package/public/images/logo.svg +333 -0
- package/public/index.html +6 -0
- package/public/layouts/_default.ok.html +1 -0
- package/public/layouts/okdb-cube.ok.html +1 -0
- package/public/login-app.js +1 -0
- package/public/login.html +1 -0
- package/public/modules/ok.js +1 -0
- package/public/sections/api/index.ok.html +1 -0
- package/public/sections/api/parts/api-endpoint.ok.js +1 -0
- package/public/sections/auth/index.ok.html +1 -0
- package/public/sections/auth/modals/create-token-modal.ok.js +1 -0
- package/public/sections/auth/modals/edit-token-modal.ok.js +1 -0
- package/public/sections/auth/modals/perm-info-popover.ok.js +1 -0
- package/public/sections/auth/parts/token-detail.ok.js +1 -0
- package/public/sections/auth/parts/token-list.ok.js +1 -0
- package/public/sections/db/index.ok.html +1 -0
- package/public/sections/db/modals/add-item-modal.ok.js +1 -0
- package/public/sections/db/modals/create-env-modal.ok.js +1 -0
- package/public/sections/db/modals/create-fts-modal.ok.js +1 -0
- package/public/sections/db/modals/create-index-modal.ok.js +1 -0
- package/public/sections/db/modals/create-pipeline-modal.ok.js +1 -0
- package/public/sections/db/modals/demo-env-modal.ok.js +1 -0
- package/public/sections/db/modals/remove-env-modal.ok.js +1 -0
- package/public/sections/db/modals/schema-edit-modal.ok.js +1 -0
- package/public/sections/db/parts/db-overview.ok.js +1 -0
- package/public/sections/db/parts/db-pipelines-panel.ok.js +1 -0
- package/public/sections/db/parts/edit-row.ok.js +1 -0
- package/public/sections/db/parts/tm-timeline.ok.js +1 -0
- package/public/sections/db/parts/type-changelog.ok.js +1 -0
- package/public/sections/db/parts/type-list.ok.js +1 -0
- package/public/sections/db/parts/type-pipelines-tab.ok.js +1 -0
- package/public/sections/db/parts/type-schema-tab.ok.js +1 -0
- package/public/sections/db/parts/type-viewer.ok.js +1 -0
- package/public/sections/db/parts/type-violations-tab.ok.js +1 -0
- package/public/sections/docs/index.ok.html +1 -0
- package/public/sections/embeddings/index.ok.html +1 -0
- package/public/sections/embeddings/modals/register-model-modal.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-create-panel.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-embedder-panel.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-engine-declaration-editor.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-engine-list.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-indexer-panel.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-lifecycle-bar.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-model-catalog.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-overview.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-search-panel.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-worker-panel.ok.js +1 -0
- package/public/sections/embeddings/parts/embeddings-engine-panel.ok.js +1 -0
- package/public/sections/embeddings/parts/engines-overview.ok.js +1 -0
- package/public/sections/embeddings/parts/pipeline-create-panel.ok.js +1 -0
- package/public/sections/engines/engine-panel-shared-style.js +1 -0
- package/public/sections/engines/engine-ui-utils.js +1 -0
- package/public/sections/engines/index.ok.html +1 -0
- package/public/sections/engines/modals/engine-modal.ok.js +1 -0
- package/public/sections/engines/parts/engine-declaration-editor.ok.js +1 -0
- package/public/sections/engines/parts/engine-lifecycle-actions.ok.js +1 -0
- package/public/sections/engines/parts/engine-panel-shell.ok.js +1 -0
- package/public/sections/engines/parts/engine-resource-card.ok.js +1 -0
- package/public/sections/engines/parts/engine-row-item.ok.js +1 -0
- package/public/sections/engines/parts/generic-engine-panel.ok.js +1 -0
- package/public/sections/files/index.ok.html +1 -0
- package/public/sections/files/parts/files-blob-status.ok.js +1 -0
- package/public/sections/files/parts/files-collection-list.ok.js +1 -0
- package/public/sections/files/parts/files-collection-panel.ok.js +1 -0
- package/public/sections/files/parts/files-file-list.ok.js +1 -0
- package/public/sections/files/parts/files-overview.ok.js +1 -0
- package/public/sections/files/parts/files-path-browser.ok.js +1 -0
- package/public/sections/files/parts/files-upload-panel.ok.js +1 -0
- package/public/sections/functions/index.ok.html +1 -0
- package/public/sections/functions/modals/function-modal.ok.js +1 -0
- package/public/sections/functions/parts/function-detail.ok.js +1 -0
- package/public/sections/functions/parts/function-logs.ok.js +1 -0
- package/public/sections/functions/parts/function-runner.ok.js +1 -0
- package/public/sections/functions/parts/functions-list.ok.js +1 -0
- package/public/sections/license/index.ok.html +1 -0
- package/public/sections/license/parts/license-panel.ok.js +1 -0
- package/public/sections/processors/index.ok.html +1 -0
- package/public/sections/queue/index.ok.html +1 -0
- package/public/sections/queue/modals/create-bucket-modal.ok.js +1 -0
- package/public/sections/queue/modals/edit-bucket-modal.ok.js +1 -0
- package/public/sections/queue/modals/edit-job-modal.ok.js +1 -0
- package/public/sections/queue/modals/enqueue-job-modal.ok.js +1 -0
- package/public/sections/queue/modals/job-type-modal.ok.js +1 -0
- package/public/sections/queue/parts/ok-job-form.ok.js +1 -0
- package/public/sections/queue/parts/queue-buckets.ok.js +1 -0
- package/public/sections/queue/parts/queue-job-types.ok.js +1 -0
- package/public/sections/queue/parts/queue-jobs.ok.js +1 -0
- package/public/sections/queue/parts/queue-types.ok.js +1 -0
- package/public/sections/queue/parts/queue-workers.ok.js +1 -0
- package/public/sections/sync/index.ok.html +5 -0
- package/public/sections/sync/parts/sync-node-detail.ok.js +1 -0
- package/public/sections/sync/parts/sync-retention.ok.js +1 -0
- package/public/sections/sync/parts/sync-topology.ok.js +1 -0
- package/public/sections/system/index.ok.html +1 -0
- package/public/sections/system/modals/data-ops-modal.ok.js +1 -0
- package/public/sections/system/parts/system-api-panel.ok.js +1 -0
- package/public/sections/system/parts/system-auth-panel.ok.js +1 -0
- package/public/sections/system/parts/system-log-history.ok.js +1 -0
- package/public/sections/system/parts/system-log.ok.js +1 -0
- package/public/sections/system/parts/system-status.ok.js +1 -0
- package/public/sections/system/parts/system-sync-panel.ok.js +1 -0
- package/public/sections/views/index.ok.html +1 -0
- package/public/sections/views/modals/create-view-modal.ok.js +1 -0
- package/public/sections/views/parts/view-detail.ok.js +1 -0
- package/public/sections/views/parts/views-list.ok.js +1 -0
- package/public/sections/views/parts/views-overview.ok.js +1 -0
- package/public/setup-app.js +1 -0
- package/public/setup.html +1 -0
- package/public/site.webmanifest +1 -0
- package/public/stores/auth-store.js +1 -0
- package/public/stores/events-store.js +1 -0
- package/public/stores/functions-store.js +1 -0
- package/public/stores/okdb-store.js +1 -0
- package/public/stores/theme-store.js +1 -0
- package/public/styles.css +1 -0
- package/public/test-cron-input.html +10 -0
- package/public/test-json-input.html +101 -0
- package/public/util/permissions.js +1 -0
- package/public/util/sift-schema.js +1 -0
- package/public/vendor/okjs/ok.esm.min.js +2 -0
- package/public/vendor/okjs/toolkit/behavior/async.ok.js +1 -0
- package/public/vendor/okjs/toolkit/components/ok-chart.ok.js +1 -0
- package/public/vendor/okjs/toolkit/components/ok-doc-viewer.ok.js +1 -0
- package/public/vendor/okjs/toolkit/components/ok-marked.ok.js +1 -0
- package/public/vendor/okjs/toolkit/components/ok-monaco.ok.js +1 -0
- package/public/vendor/okjs/toolkit/core/ok-layer-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/core/ok-layer.ok.js +1 -0
- package/public/vendor/okjs/toolkit/core/ok-overlay.ok.js +1 -0
- package/public/vendor/okjs/toolkit/core/ok-sandbox.ok.js +1 -0
- package/public/vendor/okjs/toolkit/core/transition.ok.js +1 -0
- package/public/vendor/okjs/toolkit/core/virtualized.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-console-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-console.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-fps-monitor-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-fps-monitor.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-inspector-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-inspector.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-js-tree.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-timeline-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-timeline.ok.js +1 -0
- package/public/vendor/okjs/toolkit/docs/doc-viewer.ok.js +1 -0
- package/public/vendor/okjs/toolkit/editor/ok-live-component.ok.js +1 -0
- package/public/vendor/okjs/toolkit/editor/ok-live-example.ok.js +1 -0
- package/public/vendor/okjs/toolkit/editor/ok-live-shell.ok.js +1 -0
- package/public/vendor/okjs/toolkit/elements/ok-dropdown.ok.js +1 -0
- package/public/vendor/okjs/toolkit/elements/ok-icon.ok.js +1 -0
- package/public/vendor/okjs/toolkit/elements/ok-select.ok.js +1 -0
- package/public/vendor/okjs/toolkit/elements/ok-table.ok.js +1 -0
- package/public/vendor/okjs/toolkit/errors/ok-crash-boundary.ok.js +1 -0
- package/public/vendor/okjs/toolkit/errors/ok-crash-info.ok.js +1 -0
- package/public/vendor/okjs/toolkit/i18n/i18n-editor-examples.ok.js +1 -0
- package/public/vendor/okjs/toolkit/i18n/i18n-editor.ok.js +1 -0
- package/public/vendor/okjs/toolkit/i18n/i18n-key-editor-tips.ok.js +1 -0
- package/public/vendor/okjs/toolkit/i18n/i18n-key-editor.ok.js +1 -0
- package/public/vendor/okjs/toolkit/i18n/i18n-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/i18n/ok-i18n.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-contextmenu.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-dismiss-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-draggable.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-flyover-panel.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-flyover.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-highlight-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-highlight.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-hotkeys-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-picker-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-popout-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-popout.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-portal-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-submenu.ok.js +1 -0
- package/public/vendor/okjs/toolkit/layout/ok-resizer.ok.js +1 -0
- package/public/vendor/okjs/toolkit/manifest.js +1 -0
- package/public/vendor/okjs/toolkit/modals/ok-modal-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/modals/ok-modal.ok.js +1 -0
- package/public/vendor/okjs/toolkit/modals/ok-toast-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/modals/ok-window.ok.js +1 -0
- package/public/vendor/okjs/toolkit/navigation/hash-router.ok.js +1 -0
- package/public/vendor/okjs/toolkit/navigation/history-router.ok.js +1 -0
- package/public/vendor/okjs/toolkit/navigation/router.ok.js +1 -0
- package/public/vendor/okjs/toolkit/sync/reactive-sync-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/sync/reactive-sync.js +1 -0
- package/public/vendor/okjs/toolkit/theming/blocks/ok-design-button.css.js +1 -0
- package/public/vendor/okjs/toolkit/theming/blocks/ok-design-input.css.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-design-style.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-design-vars.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-design.ok.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-input.ok.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-style.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-utils.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-variable.ok.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-vm.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor.ok.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme.ok.js +1 -0
- package/public/view-models/type-query-vm.js +1 -0
- package/types/environment.d.ts +130 -0
- package/types/errors.d.ts +98 -0
- package/types/features/admin.d.ts +4 -0
- package/types/features/api.d.ts +18 -0
- package/types/features/auth.d.ts +31 -0
- package/types/features/embeddings.d.ts +39 -0
- package/types/features/engines.d.ts +23 -0
- package/types/features/files.d.ts +29 -0
- package/types/features/fts.d.ts +25 -0
- package/types/features/functions.d.ts +23 -0
- package/types/features/mcp.d.ts +17 -0
- package/types/features/pipelines.d.ts +19 -0
- package/types/features/queue.d.ts +189 -0
- package/types/features/sync.d.ts +34 -0
- package/types/features/time-machine.d.ts +32 -0
- package/types/features/views.d.ts +16 -0
- package/types/index.d.ts +153 -0
- package/types/options.d.ts +202 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
OKDB LICENSE AGREEMENT
|
|
2
|
+
Version 1.0
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2025 Kedem Diamant. All rights reserved.
|
|
5
|
+
|
|
6
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
7
|
+
|
|
8
|
+
1. PERMITTED USE
|
|
9
|
+
|
|
10
|
+
You may use, copy, and integrate this software into your own
|
|
11
|
+
applications free of charge, provided your use is Non-Commercial
|
|
12
|
+
as defined in Section 2.
|
|
13
|
+
|
|
14
|
+
2. NON-COMMERCIAL USE
|
|
15
|
+
|
|
16
|
+
"Non-Commercial" means use that is not primarily intended for or
|
|
17
|
+
directed toward commercial advantage or monetary compensation.
|
|
18
|
+
This includes personal projects, academic research, internal
|
|
19
|
+
evaluation, and open-source software. It excludes any use in or
|
|
20
|
+
as part of a product or service that is sold, licensed, or
|
|
21
|
+
otherwise monetized.
|
|
22
|
+
|
|
23
|
+
3. COMMERCIAL USE
|
|
24
|
+
|
|
25
|
+
Any Commercial use of this software requires a valid commercial
|
|
26
|
+
license obtained from the copyright holder. Commercial licenses
|
|
27
|
+
govern the number of deployments, environments, and features
|
|
28
|
+
available, as enforced by the license activation system embedded
|
|
29
|
+
in the software.
|
|
30
|
+
|
|
31
|
+
To obtain a commercial license, contact: kedem@storita.ai
|
|
32
|
+
|
|
33
|
+
4. RESTRICTIONS
|
|
34
|
+
|
|
35
|
+
Regardless of the nature of your use, you may not:
|
|
36
|
+
|
|
37
|
+
(a) remove, disable, alter, or circumvent any license validation,
|
|
38
|
+
activation, or enforcement mechanism embedded in the software;
|
|
39
|
+
|
|
40
|
+
(b) redistribute this software as a standalone database product,
|
|
41
|
+
managed service, or competitive offering.
|
|
42
|
+
|
|
43
|
+
5. DISCLAIMER OF WARRANTIES
|
|
44
|
+
|
|
45
|
+
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
46
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
|
|
47
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
|
48
|
+
NON-INFRINGEMENT.
|
|
49
|
+
|
|
50
|
+
6. LIMITATION OF LIABILITY
|
|
51
|
+
|
|
52
|
+
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM,
|
|
53
|
+
DAMAGES, OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT, OR
|
|
54
|
+
OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE
|
|
55
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
56
|
+
|
|
57
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
package/README.md
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
<img src="banner.jpg" alt="OKDB — Embedded-First · Sync-Native · AI-Ready" width="100%" />
|
|
2
|
+
|
|
3
|
+
<br/>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="docs/getting-started.md"><strong>Getting Started</strong></a> ·
|
|
7
|
+
<a href="docs/querying.md">Querying</a> ·
|
|
8
|
+
<a href="docs/indexes.md">Indexes</a> ·
|
|
9
|
+
<a href="docs/fts.md">Full-Text Search</a> ·
|
|
10
|
+
<a href="docs/embeddings.md">Embeddings</a> ·
|
|
11
|
+
<a href="docs/sync.md">Sync</a> ·
|
|
12
|
+
<a href="docs/functions.md">Functions</a> ·
|
|
13
|
+
<a href="docs/pipelines.md">Pipelines</a> ·
|
|
14
|
+
<a href="docs/http-api.md">HTTP API</a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
**OKDB** is an embedded, document-centric database for Node.js. No separate server. No network hop. Open a path, write data.
|
|
20
|
+
|
|
21
|
+
It wraps [LMDB](https://www.symas.com/lmdb) — one of the fastest memory-mapped key-value stores ever built — and layers on top: typed collections, composite secondary indexes, full-text search, vector embeddings, multi-node sync, a durable job queue, file storage, point-in-time time-machine queries, reactive materialized views, and a built-in HTTP API. All in one process. All ACID.
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
const OKDB = require('src/okdb');
|
|
25
|
+
|
|
26
|
+
const db = new OKDB('./mydb');
|
|
27
|
+
await db.open();
|
|
28
|
+
|
|
29
|
+
await db.ensureType('users', {
|
|
30
|
+
indexes: [['role'], ['email']],
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
await db.put('users', 'alice', { name: 'Alice', role: 'admin', email: 'alice@example.com' });
|
|
34
|
+
|
|
35
|
+
const alice = db.get('users', 'alice'); // synchronous — instant
|
|
36
|
+
const admins = db.query('users', { role: 'admin' }); // MongoDB-style filter
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Why OKDB?
|
|
42
|
+
|
|
43
|
+
Most Node.js apps reach for a separate database server — Postgres, MongoDB, Redis — even when the workload fits comfortably in a single process. OKDB eliminates that infrastructure layer without sacrificing capability.
|
|
44
|
+
|
|
45
|
+
| | OKDB | SQLite | MongoDB | Redis |
|
|
46
|
+
| ------------------------ | :--: | :----: | :-----: | :---: |
|
|
47
|
+
| Embedded (no server) | ✅ | ✅ | ❌ | ❌ |
|
|
48
|
+
| Document model | ✅ | ❌ | ✅ | ❌ |
|
|
49
|
+
| Composite indexes | ✅ | ✅ | ✅ | ❌ |
|
|
50
|
+
| Full-text search | ✅ | ⚠️ | ✅ | ❌ |
|
|
51
|
+
| Vector / semantic search | ✅ | ⚠️ | ✅ | ❌ |
|
|
52
|
+
| Multi-node sync | ✅ | ❌ | ✅ | ✅ |
|
|
53
|
+
| Durable job queue | ✅ | ❌ | ❌ | ✅ |
|
|
54
|
+
| Synchronous reads | ✅ | ❌ | ❌ | ❌ |
|
|
55
|
+
| ACID transactions | ✅ | ✅ | ✅ | ❌ |
|
|
56
|
+
| Point-in-time queries | ✅ | ❌ | ⚠️ | ❌ |
|
|
57
|
+
| Materialized views | ✅ | ⚠️ | ✅ | ❌ |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Features
|
|
62
|
+
|
|
63
|
+
### ⚡ Synchronous reads
|
|
64
|
+
|
|
65
|
+
LMDB maps the database file directly into process memory. Reads are pointer dereferences — no `await`, no round-trip, no copy.
|
|
66
|
+
|
|
67
|
+
### 🔒 ACID transactions
|
|
68
|
+
|
|
69
|
+
Inherited from LMDB's copy-on-write B+ trees with MVCC. Partial writes are impossible. Crash-safe by default.
|
|
70
|
+
|
|
71
|
+
### 🗂️ Typed collections + composite indexes
|
|
72
|
+
|
|
73
|
+
Organise records into named types (like tables or collections). Declare composite secondary indexes and OKDB maintains them automatically inside every write transaction.
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
await db.ensureType('orders', {
|
|
77
|
+
indexes: [
|
|
78
|
+
['status'],
|
|
79
|
+
['customerId'],
|
|
80
|
+
['customerId', 'createdAt'], // composite — fast filtered range scans
|
|
81
|
+
],
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Range scan by composite index
|
|
85
|
+
for (const { key, value } of db.byIndex('orders', ['customerId', 'createdAt'], {
|
|
86
|
+
start: ['cust-1', 0],
|
|
87
|
+
end: ['cust-1', Date.now()],
|
|
88
|
+
})) {
|
|
89
|
+
console.log(value);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 🔍 Full-text search
|
|
94
|
+
|
|
95
|
+
Built-in inverted-index FTS backed by a dedicated LMDB environment. No Elasticsearch. No external process.
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
await db.fts.register('articles', 'content', { fields: ['title', 'body'] });
|
|
99
|
+
await db.fts.ready('articles', 'content');
|
|
100
|
+
|
|
101
|
+
const results = await db.fts.search('articles', 'content', 'hello world');
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 🤖 Vector embeddings + semantic search
|
|
105
|
+
|
|
106
|
+
First-class embedding pipeline. Point it at a type and a field, connect an embedder (Ollama, OpenAI, or custom), and OKDB handles indexing automatically. Nearest-neighbour search uses an in-process HNSW graph.
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
await db.embeddings.createPipeline('articles', {
|
|
110
|
+
source_type: 'articles',
|
|
111
|
+
field: 'body',
|
|
112
|
+
dims: 1024,
|
|
113
|
+
embedder: { type: 'ollama', model: 'mxbai-embed-large', url: 'http://localhost:11434' },
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const similar = await db.embeddings.search('articles', queryVector, { limit: 10 });
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 🌍 Geo queries
|
|
120
|
+
|
|
121
|
+
Built-in geospatial index for radius and bounding-box queries. See [docs/indexes.md](docs/indexes.md).
|
|
122
|
+
|
|
123
|
+
### 🔄 Multi-node sync
|
|
124
|
+
|
|
125
|
+
Peer-to-peer last-write-wins replication over HTTP. No coordinator. No Raft. Nodes exchange deltas; HLC timestamps resolve conflicts.
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
const db = new OKDB('./node1', {
|
|
129
|
+
sync: { address: 'http://192.168.1.10:8080' },
|
|
130
|
+
});
|
|
131
|
+
await db.open();
|
|
132
|
+
db.http.listen(8080);
|
|
133
|
+
|
|
134
|
+
// Create an admin token first, then join a peer with it
|
|
135
|
+
await db.sync.join('http://192.168.1.11:8080', { token: 'cluster-bearer-token' });
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 📬 Durable job queue
|
|
139
|
+
|
|
140
|
+
Crash-safe job queue stored in LMDB. Workers pull jobs, process them, and acknowledge — all without Redis.
|
|
141
|
+
|
|
142
|
+
### 📁 File / blob storage
|
|
143
|
+
|
|
144
|
+
SHA-256 content-addressable binary blob storage, integrated with the sync system. See [docs/files.md](docs/files.md).
|
|
145
|
+
|
|
146
|
+
### 🧩 Sandboxed custom functions
|
|
147
|
+
|
|
148
|
+
Store JavaScript functions in the database, validate them, and execute them in pooled sandbox runners.
|
|
149
|
+
|
|
150
|
+
- all functions execute with env-local facades: `ctx.env`, `ctx.env.queue`, `ctx.env.files`
|
|
151
|
+
- mark a function `unsafe: true` to additionally receive `ctx.okdb` for cross-env access
|
|
152
|
+
- scripts use the contract `[async] (ctx) => {}`
|
|
153
|
+
- `require`, `import`, and `console` are rejected
|
|
154
|
+
- logging flows through `ctx.log(...)`
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
await db.env('analytics').functions.create({
|
|
158
|
+
name: 'countEvents',
|
|
159
|
+
source: '(ctx) => ({ count: ctx.env.getCount("events") })',
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const run = await db.env('analytics').functions.run('countEvents');
|
|
163
|
+
console.log(run.result.value.count);
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 🔌 Built-in HTTP API + Admin UI
|
|
167
|
+
|
|
168
|
+
Zero-config REST API and a browser-based admin UI for data exploration, index management, and real-time monitoring.
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
db.http.listen(8080);
|
|
172
|
+
// REST API: http://localhost:8080/api/type/users
|
|
173
|
+
// Admin UI: http://localhost:8080/admin/
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 🧠 MCP endpoint (Inspector-ready example)
|
|
177
|
+
|
|
178
|
+
OKDB also exposes an MCP server over SSE + POST:
|
|
179
|
+
|
|
180
|
+
- `GET /mcp/sse`
|
|
181
|
+
- `POST /mcp/messages`
|
|
182
|
+
|
|
183
|
+
For a local working example, run:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
node examples/mcp-inspector.js
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Then in MCP Inspector choose the SSE transport and connect to:
|
|
190
|
+
|
|
191
|
+
- `http://localhost:8787/mcp/sse`
|
|
192
|
+
|
|
193
|
+
The server responds with browser CORS headers for common Inspector origins, accepts preflight `OPTIONS` requests, emits the POST endpoint URL over the SSE `endpoint` event, and exposes the MCP session id via the `mcp-session-id` response header. After connecting, try:
|
|
194
|
+
|
|
195
|
+
- `tools/list`
|
|
196
|
+
- `tools/call` with generated tools such as:
|
|
197
|
+
- `system_info`
|
|
198
|
+
- `system_runtime`
|
|
199
|
+
- `queue_list_jobs`
|
|
200
|
+
- `processor_list`
|
|
201
|
+
|
|
202
|
+
OKDB now derives MCP tools primarily from route operation metadata instead of keeping a separate hand-maintained MCP tool list. Routes marked with canonical metadata and `mcp.include !== false` can participate in MCP generation, while streaming/SSE/raw transport routes stay excluded by default.
|
|
203
|
+
|
|
204
|
+
If you run Inspector from a different origin, allow that origin in `src/features/mcp/okdb-mcp.js`.
|
|
205
|
+
|
|
206
|
+
### ⚙️ Reactive processors
|
|
207
|
+
|
|
208
|
+
Composable change handlers — like database triggers, written in JavaScript. React to writes on any type, in the same transaction or asynchronously.
|
|
209
|
+
|
|
210
|
+
### ⏱️ Time-machine
|
|
211
|
+
|
|
212
|
+
Full edit history for every record. Ask what any document looked like at any point in the past — OKDB stores diffs automatically and reconstructs the state on demand.
|
|
213
|
+
|
|
214
|
+
```js
|
|
215
|
+
// Enable once; tracking starts from current clock
|
|
216
|
+
await db.timeMachine.enable();
|
|
217
|
+
|
|
218
|
+
// Point-in-time read — synchronous, no await
|
|
219
|
+
const snapshot = db.timeMachine.getStateAt('orders', 'ord-42', historicClock);
|
|
220
|
+
|
|
221
|
+
// Full history for a single record
|
|
222
|
+
const { diffs, head } = db.timeMachine.getHistory('orders', 'ord-42');
|
|
223
|
+
|
|
224
|
+
// All changes to a type within a clock range — useful for auditing
|
|
225
|
+
for (const change of db.timeMachine.getChanges('orders', fromClock, toClock)) {
|
|
226
|
+
console.log(change.key, change.diff);
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### 📊 Materialized views
|
|
231
|
+
|
|
232
|
+
Reactive aggregations that update automatically on every write. Declare a view with built-in reducers (`$count`, `$sum`, `$avg`, `$min`, `$max`, `$countBy`) or supply your own, and OKDB keeps the result in sync.
|
|
233
|
+
|
|
234
|
+
```js
|
|
235
|
+
await db.views.create('orderStats', {
|
|
236
|
+
type: 'orders',
|
|
237
|
+
filter: { status: 'completed' },
|
|
238
|
+
reduce: {
|
|
239
|
+
total: { $sum: 'amount' },
|
|
240
|
+
count: { $count: true },
|
|
241
|
+
avgValue: { $avg: 'amount' },
|
|
242
|
+
byRegion: { $countBy: 'region' },
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// Read the live result — synchronous
|
|
247
|
+
const stats = db.views.get('orderStats');
|
|
248
|
+
// → { total: 142500, count: 312, avgValue: 456.7, byRegion: { EU: 140, US: 172 } }
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### 🔑 Authentication & authorization
|
|
252
|
+
|
|
253
|
+
Multi-mode security layer built into the HTTP API. No separate auth service needed.
|
|
254
|
+
|
|
255
|
+
- **Token / session** — bearer tokens with configurable TTL
|
|
256
|
+
- **OIDC / OAuth2** — discovery-based, JWKS validation, email/domain allowlists
|
|
257
|
+
- **IP allowlists** — restrict access by network range
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Installation
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
npm install okdb
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
> **Runtime:** Node.js only. Requires a native LMDB build (handled automatically by the `lmdb` package via node-gyp).
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Quick start
|
|
272
|
+
|
|
273
|
+
```js
|
|
274
|
+
'use strict';
|
|
275
|
+
const OKDB = require('src/okdb');
|
|
276
|
+
|
|
277
|
+
async function main() {
|
|
278
|
+
const db = new OKDB('./demo');
|
|
279
|
+
await db.open();
|
|
280
|
+
|
|
281
|
+
await db.ensureType('products', {
|
|
282
|
+
indexes: [['category'], ['price'], ['category', 'price']],
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
await db.put('products', 'p1', { name: 'Widget', category: 'tools', price: 9.99 });
|
|
286
|
+
await db.put('products', 'p2', { name: 'Gadget', category: 'tools', price: 19.99 });
|
|
287
|
+
await db.put('products', 'p3', { name: 'Doohickey', category: 'misc', price: 4.99 });
|
|
288
|
+
|
|
289
|
+
// MongoDB-style filter
|
|
290
|
+
for (const { key, value } of db.query('products', { category: 'tools' })) {
|
|
291
|
+
console.log(`${key}: ${value.name} — $${value.price}`);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Index range scan
|
|
295
|
+
for (const { key, value } of db.byIndex('products', ['price'], { start: [0], end: [10] })) {
|
|
296
|
+
console.log(`${value.name} costs $${value.price}`);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
await db.close();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
main().catch(console.error);
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Documentation
|
|
308
|
+
|
|
309
|
+
| Topic | |
|
|
310
|
+
| ------------------------------------------ | ------------------------------------------------------------------- |
|
|
311
|
+
| [Getting Started](docs/getting-started.md) | Installation, opening a database, first type, writes & reads |
|
|
312
|
+
| [Querying](docs/querying.md) | Key reads, range scans, index scans, MongoDB filters |
|
|
313
|
+
| [Indexes](docs/indexes.md) | Composite indexes, unique indexes, geo indexes |
|
|
314
|
+
| [Transactions](docs/transactions.md) | Multi-write atomic transactions |
|
|
315
|
+
| [Full-Text Search](docs/fts.md) | Registering FTS indexes, tokenizer config, search |
|
|
316
|
+
| [Embeddings](docs/embeddings.md) | Vector pipeline, embedders, HNSW search |
|
|
317
|
+
| [Sync](docs/sync.md) | Cluster setup, joining peers, conflict resolution |
|
|
318
|
+
| [Queue](docs/queue.md) | Durable job queue, workers, retry |
|
|
319
|
+
| [Files](docs/files.md) | Blob storage, upload, download, sync |
|
|
320
|
+
| [Custom Functions](docs/functions.md) | Stored sandboxed JS functions, env/global execution, HTTP routes |
|
|
321
|
+
| [Pipelines](docs/pipelines.md) | Composable data-flow orchestration with queue and processor drivers |
|
|
322
|
+
| [HTTP API](docs/http-api.md) | REST endpoints, auth, admin UI |
|
|
323
|
+
| [Auth](docs/auth-permissions.md) | Token, OIDC, IP allowlist authentication |
|
|
324
|
+
| [Plugins](docs/plugins.md) | Extending OKDB with custom features |
|
|
325
|
+
| [Migration](docs/migration.md) | Schema evolution, data migration |
|
|
326
|
+
| [Architecture](OKDB-ARCHITECTURE.md) | Deep-dive technical reference |
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Use cases
|
|
331
|
+
|
|
332
|
+
- **Local-first and offline-capable apps** — the database travels with the user
|
|
333
|
+
- **Desktop / Electron apps** — no bundled server process
|
|
334
|
+
- **Edge and IoT services** — minimal footprint, full capability
|
|
335
|
+
- **Data pipelines** — fast ingest, durable queue, automatic vector indexing
|
|
336
|
+
- **AI-powered apps** — embedding storage and semantic search are first-class
|
|
337
|
+
- **Audit trails and compliance** — time-machine records every change; reconstruct any past state on demand
|
|
338
|
+
- **Analytics dashboards** — materialized views keep aggregates live without separate query jobs
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## License
|
|
343
|
+
|
|
344
|
+
See [LICENSE](LICENSE) for details.
|
package/banner.jpg
ADDED
|
Binary file
|