@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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface OKDBPipelineDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
sourceType: string;
|
|
4
|
+
steps: OKDBPipelineStep[];
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface OKDBPipelineStep {
|
|
9
|
+
type: string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare class OKDBPipelines {
|
|
14
|
+
register(definition: OKDBPipelineDefinition): Promise<void>;
|
|
15
|
+
unregister(name: string): Promise<void>;
|
|
16
|
+
get(name: string): OKDBPipelineDefinition | null;
|
|
17
|
+
list(): OKDBPipelineDefinition[];
|
|
18
|
+
bootSyncedPipelines(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { OKDBIndexKey } from '../options';
|
|
2
|
+
import type { EventEmitter } from 'events';
|
|
3
|
+
|
|
4
|
+
export type OKDBJobStatus = 'pending' | 'running' | 'done' | 'failed';
|
|
5
|
+
|
|
6
|
+
export interface OKDBJobBucket {
|
|
7
|
+
id: string;
|
|
8
|
+
tokens: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface OKDBJob {
|
|
12
|
+
id: string;
|
|
13
|
+
type: string;
|
|
14
|
+
idempotency_key: string | null;
|
|
15
|
+
status: OKDBJobStatus;
|
|
16
|
+
status_code: string | null;
|
|
17
|
+
status_message: string | null;
|
|
18
|
+
error_stack: string | null;
|
|
19
|
+
progress: string | null;
|
|
20
|
+
when: number;
|
|
21
|
+
priority: number;
|
|
22
|
+
tags: string[];
|
|
23
|
+
tag: string | null;
|
|
24
|
+
bucket: string | null;
|
|
25
|
+
bucket_tokens: number | null;
|
|
26
|
+
buckets: OKDBJobBucket[] | null;
|
|
27
|
+
cron: string | null;
|
|
28
|
+
created: number;
|
|
29
|
+
updated: number;
|
|
30
|
+
finished: number | null;
|
|
31
|
+
tries: number;
|
|
32
|
+
max_tries: number | null;
|
|
33
|
+
retry_delay: number;
|
|
34
|
+
backoff_multiplier: number;
|
|
35
|
+
claim_id: string | null;
|
|
36
|
+
claim_expires: number | null;
|
|
37
|
+
done_ttl: number | null;
|
|
38
|
+
failed_ttl: number | null;
|
|
39
|
+
payload?: unknown;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface OKDBJobBucketRecord {
|
|
43
|
+
id: string;
|
|
44
|
+
tokens: number;
|
|
45
|
+
capacity: number;
|
|
46
|
+
refill_amount: number;
|
|
47
|
+
refill_every: number;
|
|
48
|
+
updated: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type OKDBJobTypeStatus = 'active' | 'paused' | 'draining';
|
|
52
|
+
|
|
53
|
+
export interface OKDBJobType {
|
|
54
|
+
id: string;
|
|
55
|
+
status: OKDBJobTypeStatus;
|
|
56
|
+
max_concurrency: number | null;
|
|
57
|
+
defaults: Partial<OKDBJobDefaults>;
|
|
58
|
+
payload_schema: { definition: unknown; enforce: boolean } | null;
|
|
59
|
+
created_at: number;
|
|
60
|
+
updated_at: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface OKDBJobDefaults {
|
|
64
|
+
max_tries: number | null;
|
|
65
|
+
retry_delay: number;
|
|
66
|
+
backoff_multiplier: number;
|
|
67
|
+
priority: number;
|
|
68
|
+
ttl: number | null;
|
|
69
|
+
done_ttl: number | null;
|
|
70
|
+
failed_ttl: number | null;
|
|
71
|
+
buckets: OKDBJobBucket[] | null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface OKDBEnqueueOptions {
|
|
75
|
+
when?: number;
|
|
76
|
+
priority?: number;
|
|
77
|
+
tags?: string[];
|
|
78
|
+
bucket?: string;
|
|
79
|
+
bucket_tokens?: number;
|
|
80
|
+
buckets?: OKDBJobBucket[];
|
|
81
|
+
cron?: string;
|
|
82
|
+
max_tries?: number | null;
|
|
83
|
+
retry_delay?: number;
|
|
84
|
+
backoff_multiplier?: number;
|
|
85
|
+
done_ttl?: number | null;
|
|
86
|
+
failed_ttl?: number | null;
|
|
87
|
+
idempotency_key?: string | number;
|
|
88
|
+
txn?: OKDBQueueTransaction;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface OKDBClaimOptions {
|
|
92
|
+
ttl?: number;
|
|
93
|
+
tags?: string[];
|
|
94
|
+
bucket?: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface OKDBListJobsOptions {
|
|
98
|
+
type?: string | null;
|
|
99
|
+
status?: OKDBJobStatus | null;
|
|
100
|
+
bucket?: string | null;
|
|
101
|
+
tag?: string | null;
|
|
102
|
+
sort?: 'when' | 'priority';
|
|
103
|
+
direction?: 'asc' | 'desc';
|
|
104
|
+
limit?: number;
|
|
105
|
+
cursor?: OKDBIndexKey | null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface OKDBAddBucketOptions {
|
|
109
|
+
capacity?: number;
|
|
110
|
+
tokens?: number;
|
|
111
|
+
refill_amount?: number;
|
|
112
|
+
refill_every?: number;
|
|
113
|
+
txn?: OKDBQueueTransaction;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface OKDBAddJobTypeOptions {
|
|
117
|
+
status?: OKDBJobTypeStatus;
|
|
118
|
+
max_concurrency?: number | null;
|
|
119
|
+
defaults?: Partial<OKDBJobDefaults>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface OKDBQueueTransaction {
|
|
123
|
+
put(type: string, key: string | number, value: unknown): void;
|
|
124
|
+
remove(type: string, key: string | number): void;
|
|
125
|
+
update(type: string, key: string | number, value: unknown, opts?: unknown): void;
|
|
126
|
+
commit(): Promise<void>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface OKDBQueueWorker {
|
|
130
|
+
stop(timeout?: number): Promise<void>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface OKDBQueueSpawnedWorker {
|
|
134
|
+
stop(timeout?: number): Promise<void>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export declare class OKDBQueue {
|
|
138
|
+
events: EventEmitter;
|
|
139
|
+
|
|
140
|
+
// ── Core job lifecycle ────────────────────────────────────────────────────
|
|
141
|
+
enqueue(type: string, payload: unknown, options?: OKDBEnqueueOptions): Promise<string>;
|
|
142
|
+
claim(type: string, options?: OKDBClaimOptions): Promise<OKDBJob | null>;
|
|
143
|
+
worker(type: string, handler: (job: OKDBJob) => Promise<unknown> | unknown, options?: Record<string, unknown>): OKDBQueueWorker;
|
|
144
|
+
spawn(type: string, modulePath: string, options?: Record<string, unknown>): Promise<OKDBQueueSpawnedWorker>;
|
|
145
|
+
stopAll(timeout?: number): Promise<void>;
|
|
146
|
+
|
|
147
|
+
// ── Job retrieval / management ────────────────────────────────────────────
|
|
148
|
+
getJob(id: string): Promise<OKDBJob | null>;
|
|
149
|
+
updateJob(id: string, patch: Partial<OKDBJob & { payload: unknown }>, options?: { txn?: OKDBQueueTransaction }): Promise<OKDBJob>;
|
|
150
|
+
removeJob(id: string, options?: { txn?: OKDBQueueTransaction }): Promise<boolean>;
|
|
151
|
+
retryJob(id: string): Promise<OKDBJob>;
|
|
152
|
+
cancelJob(id: string): Promise<OKDBJob>;
|
|
153
|
+
list(options?: OKDBListJobsOptions): Promise<{ items: OKDBJob[]; cursor: OKDBIndexKey | null }>;
|
|
154
|
+
|
|
155
|
+
// ── Worker callbacks ──────────────────────────────────────────────────────
|
|
156
|
+
heartbeat(jobId: string, claimId: string, ttl?: number | null): Promise<OKDBJob>;
|
|
157
|
+
markJobHeartbeat(jobId: string, claimId: string, ttl?: number | null): Promise<OKDBJob>;
|
|
158
|
+
markJobProgress(jobId: string, claimId: string, message: string): Promise<OKDBJob>;
|
|
159
|
+
markJobComplete(jobId: string, claimId: string, result?: unknown): Promise<OKDBJob>;
|
|
160
|
+
completeJob(jobId: string, claimId: string, result?: unknown): Promise<OKDBJob>;
|
|
161
|
+
markJobFail(jobId: string, claimId: string, err: Error | unknown, code?: string): Promise<{ permanentlyFailed: boolean; job: OKDBJob }>;
|
|
162
|
+
failJob(jobId: string, claimId: string, err: Error | unknown, code?: string): Promise<{ permanentlyFailed: boolean; job: OKDBJob }>;
|
|
163
|
+
releaseClaim(jobId: string, claimId: string, options?: { when?: number; statusCode?: string; keepTry?: boolean }): Promise<boolean>;
|
|
164
|
+
|
|
165
|
+
// ── Bulk operations ───────────────────────────────────────────────────────
|
|
166
|
+
clearDone(type?: string | null, limit?: number): Promise<number>;
|
|
167
|
+
clearFailed(type?: string | null, limit?: number): Promise<number>;
|
|
168
|
+
clearStuck(type?: string | null, limit?: number): Promise<number>;
|
|
169
|
+
retryFailed(type?: string | null, limit?: number): Promise<number>;
|
|
170
|
+
|
|
171
|
+
// ── Token buckets ─────────────────────────────────────────────────────────
|
|
172
|
+
addBucket(id: string, options?: OKDBAddBucketOptions): Promise<void>;
|
|
173
|
+
updateBucket(id: string, patch: Partial<OKDBJobBucketRecord>): Promise<void>;
|
|
174
|
+
removeBucket(id: string): Promise<void>;
|
|
175
|
+
getBucket(id: string): OKDBJobBucketRecord | null;
|
|
176
|
+
tryClaimTokens(bucketId: string, tokens?: number): Promise<boolean>;
|
|
177
|
+
|
|
178
|
+
// ── Job types ─────────────────────────────────────────────────────────────
|
|
179
|
+
addJobType(id: string, options?: OKDBAddJobTypeOptions): Promise<OKDBJobType>;
|
|
180
|
+
getJobType(id: string): Promise<OKDBJobType | null>;
|
|
181
|
+
listJobTypes(): Promise<OKDBJobType[]>;
|
|
182
|
+
removeJobType(id: string): Promise<boolean>;
|
|
183
|
+
pauseJobType(id: string): Promise<OKDBJobType>;
|
|
184
|
+
resumeJobType(id: string): Promise<OKDBJobType>;
|
|
185
|
+
drainJobType(id: string): Promise<OKDBJobType>;
|
|
186
|
+
setJobTypeSchema(id: string, definition: unknown, enforce?: boolean): Promise<OKDBJobType>;
|
|
187
|
+
removeJobTypeSchema(id: string): Promise<OKDBJobType>;
|
|
188
|
+
samplePayloads(type: string, limit?: number): Promise<unknown[]>;
|
|
189
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface OKDBSyncNode {
|
|
2
|
+
id: string;
|
|
3
|
+
address: string | null;
|
|
4
|
+
meta: Record<string, unknown>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
updated: number;
|
|
7
|
+
publicKey?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface OKDBSyncLink {
|
|
11
|
+
id: string;
|
|
12
|
+
nodeA: string;
|
|
13
|
+
nodeB: string;
|
|
14
|
+
createdAt: number;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface OKDBSyncInfo {
|
|
19
|
+
node_id: string;
|
|
20
|
+
clock: number;
|
|
21
|
+
auto_reconcile: boolean;
|
|
22
|
+
peers: number;
|
|
23
|
+
reconciling: string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export declare class OKDBSync {
|
|
27
|
+
info(): OKDBSyncInfo;
|
|
28
|
+
getSelfNode(): OKDBSyncNode;
|
|
29
|
+
addPeer(address: string, options?: Record<string, unknown>): Promise<void>;
|
|
30
|
+
removePeer(nodeId: string): Promise<void>;
|
|
31
|
+
listPeers(): OKDBSyncNode[];
|
|
32
|
+
reconcile(nodeId?: string): Promise<void>;
|
|
33
|
+
stop(): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { OKDBPrimaryKey } from '../options';
|
|
2
|
+
|
|
3
|
+
export interface OKDBTimeMachineSnapshot {
|
|
4
|
+
clock: number;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface OKDBTimeMachineDiff {
|
|
10
|
+
key: OKDBPrimaryKey;
|
|
11
|
+
type: string;
|
|
12
|
+
action: 'put' | 'remove';
|
|
13
|
+
oldValue?: unknown;
|
|
14
|
+
newValue?: unknown;
|
|
15
|
+
clock: number;
|
|
16
|
+
timestamp: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface OKDBTimeMachineQueryOptions {
|
|
20
|
+
from?: number;
|
|
21
|
+
to?: number;
|
|
22
|
+
limit?: number;
|
|
23
|
+
types?: string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export declare class OKDBTimeMachine {
|
|
27
|
+
start(): void;
|
|
28
|
+
stop(): Promise<void>;
|
|
29
|
+
getAt(type: string, key: OKDBPrimaryKey, clock: number): unknown;
|
|
30
|
+
getDiff(options?: OKDBTimeMachineQueryOptions): Iterable<OKDBTimeMachineDiff>;
|
|
31
|
+
listSnapshots(options?: { limit?: number }): OKDBTimeMachineSnapshot[];
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface OKDBViewDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
sourceType: string;
|
|
4
|
+
targetType: string;
|
|
5
|
+
map?: string;
|
|
6
|
+
reduce?: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export declare class OKDBViews {
|
|
11
|
+
register(definition: OKDBViewDefinition): Promise<void>;
|
|
12
|
+
unregister(name: string): Promise<void>;
|
|
13
|
+
get(name: string): OKDBViewDefinition | null;
|
|
14
|
+
list(): OKDBViewDefinition[];
|
|
15
|
+
bootSyncedViews(): Promise<void>;
|
|
16
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// ── Re-export all public types ────────────────────────────────────────────────
|
|
2
|
+
export type * from './options';
|
|
3
|
+
export type * from './errors';
|
|
4
|
+
export type { OKDBTransaction, OKDBEnvironment } from './environment';
|
|
5
|
+
|
|
6
|
+
// Features
|
|
7
|
+
export type { OKDBQueue, OKDBJob, OKDBJobStatus, OKDBJobType, OKDBJobBucket, OKDBJobBucketRecord, OKDBEnqueueOptions, OKDBClaimOptions, OKDBListJobsOptions } from './features/queue';
|
|
8
|
+
export type { OKDBFiles, OKDBFileRecord, OKDBUploadOptions } from './features/files';
|
|
9
|
+
export type { OKDBSync, OKDBSyncNode, OKDBSyncInfo } from './features/sync';
|
|
10
|
+
export type { OKDBAuth, OKDBToken, OKDBAuthContext, OKDBLoginResult } from './features/auth';
|
|
11
|
+
export type { OKDBEmbeddings, OKDBEmbeddingsPipeline, OKDBEmbeddingsSearchResult } from './features/embeddings';
|
|
12
|
+
export type { OKDBFts, OKDBFtsIndex, OKDBFtsQueryResult } from './features/fts';
|
|
13
|
+
export type { OKDBEngines, OKDBEngineDefinition } from './features/engines';
|
|
14
|
+
export type { OKDBFunctions, OKDBFunctionDefinition } from './features/functions';
|
|
15
|
+
export type { OKDBPipelines, OKDBPipelineDefinition } from './features/pipelines';
|
|
16
|
+
export type { OKDBViews, OKDBViewDefinition } from './features/views';
|
|
17
|
+
export type { OKDBMcp, OKDBMcpTool } from './features/mcp';
|
|
18
|
+
export type { OKDBTimeMachine, OKDBTimeMachineDiff, OKDBTimeMachineSnapshot } from './features/time-machine';
|
|
19
|
+
export type { OKDBAdmin } from './features/admin';
|
|
20
|
+
export type { OKDBApi } from './features/api';
|
|
21
|
+
|
|
22
|
+
// ── Main OKDB class ───────────────────────────────────────────────────────────
|
|
23
|
+
import type { OKDBOptions, OKDBEnvironmentConfig, OKDBPrimaryKey, OKDBIndexKey, OKDBFilter, OKDBRangeOptions, OKDBQueryOptions, OKDBGeoQueryOptions, OKDBFtsQueryOptions, OKDBWriteOptions, OKDBEntry, OKDBIndexEntry, OKDBChangeEntry, OKDBIndexDefinition, OKDBRemoveEnvironmentResult, OKDBTtlListOptions, OKDBInfoResult } from './options';
|
|
24
|
+
import type { OKDBEnvironment, OKDBTransaction } from './environment';
|
|
25
|
+
import type { OKDBQueue } from './features/queue';
|
|
26
|
+
import type { OKDBFiles } from './features/files';
|
|
27
|
+
import type { OKDBSync } from './features/sync';
|
|
28
|
+
import type { OKDBAuth } from './features/auth';
|
|
29
|
+
import type { OKDBEmbeddings } from './features/embeddings';
|
|
30
|
+
import type { OKDBFts } from './features/fts';
|
|
31
|
+
import type { OKDBEngines } from './features/engines';
|
|
32
|
+
import type { OKDBFunctions } from './features/functions';
|
|
33
|
+
import type { OKDBPipelines } from './features/pipelines';
|
|
34
|
+
import type { OKDBMcp } from './features/mcp';
|
|
35
|
+
import type { OKDBAdmin } from './features/admin';
|
|
36
|
+
import type { OKDBApi } from './features/api';
|
|
37
|
+
import type { EventEmitter } from 'events';
|
|
38
|
+
|
|
39
|
+
export declare class OKDB {
|
|
40
|
+
static defaults: OKDBOptions;
|
|
41
|
+
static HIGH_SENTINEL: Buffer;
|
|
42
|
+
|
|
43
|
+
readonly path: string;
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly options: OKDBOptions;
|
|
46
|
+
readonly events: EventEmitter;
|
|
47
|
+
|
|
48
|
+
// ── Subsystems ────────────────────────────────────────────────────────────
|
|
49
|
+
readonly http: unknown;
|
|
50
|
+
readonly auth: OKDBAuth;
|
|
51
|
+
readonly log: unknown;
|
|
52
|
+
readonly bus: unknown;
|
|
53
|
+
readonly admin: OKDBAdmin;
|
|
54
|
+
readonly api: OKDBApi;
|
|
55
|
+
readonly sync: OKDBSync;
|
|
56
|
+
readonly embeddings: OKDBEmbeddings;
|
|
57
|
+
readonly fts: OKDBFts;
|
|
58
|
+
readonly engines: OKDBEngines;
|
|
59
|
+
readonly pipelines: OKDBPipelines;
|
|
60
|
+
readonly functions: OKDBFunctions;
|
|
61
|
+
readonly mcp: OKDBMcp;
|
|
62
|
+
readonly meta: unknown;
|
|
63
|
+
readonly migrate: unknown;
|
|
64
|
+
readonly plugins: unknown;
|
|
65
|
+
|
|
66
|
+
// ── Queue and files are shortcuts to default env ──────────────────────────
|
|
67
|
+
readonly queue: OKDBQueue;
|
|
68
|
+
readonly files: OKDBFiles;
|
|
69
|
+
|
|
70
|
+
constructor(dbPath: string, options?: OKDBOptions);
|
|
71
|
+
|
|
72
|
+
// ── Lifecycle ─────────────────────────────────────────────────────────────
|
|
73
|
+
open(): Promise<void>;
|
|
74
|
+
close(): Promise<void>;
|
|
75
|
+
|
|
76
|
+
// ── Environment management ────────────────────────────────────────────────
|
|
77
|
+
readonly default: OKDBEnvironment;
|
|
78
|
+
env(name?: string): OKDBEnvironment;
|
|
79
|
+
createEnvironment(name: string, config?: OKDBEnvironmentConfig): Promise<OKDBEnvironment>;
|
|
80
|
+
removeEnvironment(name: string, options?: { keepSubEnvs?: string[] }): Promise<OKDBRemoveEnvironmentResult>;
|
|
81
|
+
|
|
82
|
+
// ── Info ──────────────────────────────────────────────────────────────────
|
|
83
|
+
readonly info: OKDBInfoResult;
|
|
84
|
+
|
|
85
|
+
// ── Transactions ──────────────────────────────────────────────────────────
|
|
86
|
+
transaction(options?: Record<string, unknown>): OKDBTransaction;
|
|
87
|
+
txn<T = void>(work: (txn: OKDBTransaction) => T | Promise<T>, options?: Record<string, unknown>): Promise<T>;
|
|
88
|
+
|
|
89
|
+
// ── CRUD (delegates to default env) ───────────────────────────────────────
|
|
90
|
+
put(type: string, key: OKDBPrimaryKey, value: unknown, options?: OKDBWriteOptions): Promise<void>;
|
|
91
|
+
update(type: string, key: OKDBPrimaryKey, value: unknown, options?: OKDBWriteOptions): Promise<void>;
|
|
92
|
+
patch(type: string, key: OKDBPrimaryKey, patch: Record<string, unknown>, options?: OKDBWriteOptions): Promise<void>;
|
|
93
|
+
create(type: string, key: OKDBPrimaryKey, value: unknown, options?: OKDBWriteOptions): Promise<void>;
|
|
94
|
+
remove(type: string, key: OKDBPrimaryKey, options?: Pick<OKDBWriteOptions, 'ifVersion'>): Promise<void>;
|
|
95
|
+
|
|
96
|
+
// ── Read ──────────────────────────────────────────────────────────────────
|
|
97
|
+
get<T = unknown>(type: string, key: OKDBPrimaryKey, options?: Record<string, unknown>): T | undefined;
|
|
98
|
+
getMany<T = unknown>(type: string, keys: OKDBPrimaryKey[], options?: Record<string, unknown>): (T | undefined)[];
|
|
99
|
+
getEntry<T = unknown>(type: string, key: OKDBPrimaryKey, options?: Record<string, unknown>): OKDBEntry<T> | undefined;
|
|
100
|
+
getRange<T = unknown>(type: string, options?: OKDBRangeOptions): Iterable<OKDBEntry<T>>;
|
|
101
|
+
getValues<T = unknown>(type: string, options?: OKDBRangeOptions): Iterable<T>;
|
|
102
|
+
getKeys(type: string, options?: OKDBRangeOptions): Iterable<OKDBPrimaryKey>;
|
|
103
|
+
getCount(type: string, options?: OKDBRangeOptions): number;
|
|
104
|
+
getByPrefix<T = unknown>(type: string, prefix: OKDBPrimaryKey, options?: OKDBRangeOptions): Iterable<OKDBEntry<T>>;
|
|
105
|
+
|
|
106
|
+
// ── Index queries ─────────────────────────────────────────────────────────
|
|
107
|
+
getIndex<T = unknown>(type: string, index: string[], options?: OKDBQueryOptions): Iterable<OKDBIndexEntry<T>>;
|
|
108
|
+
byIndex<T = unknown>(type: string, index: string[], options?: OKDBQueryOptions): Iterable<OKDBIndexEntry<T>>;
|
|
109
|
+
query<T = unknown>(type: string, filter: OKDBFilter, options?: OKDBQueryOptions): Iterable<OKDBIndexEntry<T>>;
|
|
110
|
+
geoQuery<T = unknown>(type: string, field: string, options: OKDBGeoQueryOptions): Iterable<OKDBEntry<T>>;
|
|
111
|
+
ftsQuery<T = unknown>(type: string, name: string, text: string, filter?: OKDBFilter, options?: OKDBFtsQueryOptions): Iterable<OKDBEntry<T>>;
|
|
112
|
+
|
|
113
|
+
// ── Type management ───────────────────────────────────────────────────────
|
|
114
|
+
registerType(type: string, timestamp?: number): Promise<void>;
|
|
115
|
+
ensureType(type: string, options?: { timestamp?: number; indexes?: Array<string[] | OKDBIndexDefinition> }): Promise<void>;
|
|
116
|
+
hasType(type: string): boolean;
|
|
117
|
+
dropType(type: string, timestamp?: number): Promise<void>;
|
|
118
|
+
|
|
119
|
+
// ── Index management ──────────────────────────────────────────────────────
|
|
120
|
+
registerIndex(type: string, index: string[], options?: { type?: 'geo'; precision?: number; unique?: boolean; timestamp?: number }): Promise<void>;
|
|
121
|
+
hasIndex(type: string, index: string[]): boolean;
|
|
122
|
+
dropIndex(type: string, index: string[], timestamp?: number): Promise<void>;
|
|
123
|
+
resetIndex(type: string, index: string[], clear?: boolean): Promise<void>;
|
|
124
|
+
indexReady(type: string, index: string[]): Promise<boolean>;
|
|
125
|
+
getIndexStatus(type: string, index: string[]): string;
|
|
126
|
+
getUniqueViolations(type: string, index: string[]): unknown[];
|
|
127
|
+
hasUniqueViolations(type: string, index: string[]): boolean;
|
|
128
|
+
getUniqueViolation(type: string, index: string[], key: OKDBPrimaryKey): unknown;
|
|
129
|
+
|
|
130
|
+
// ── Change tracking ───────────────────────────────────────────────────────
|
|
131
|
+
getClock(type?: string, options?: Record<string, unknown>): number;
|
|
132
|
+
getChanges(type?: string, from?: number, to?: number, options?: Record<string, unknown>): Iterable<OKDBChangeEntry>;
|
|
133
|
+
|
|
134
|
+
// ── TTL ───────────────────────────────────────────────────────────────────
|
|
135
|
+
setTTL(type: string, key: OKDBPrimaryKey, ttlMs: number): Promise<void>;
|
|
136
|
+
getTTL(type: string, key: OKDBPrimaryKey): number | null;
|
|
137
|
+
clearTTL(type: string, key: OKDBPrimaryKey): Promise<void>;
|
|
138
|
+
sweepExpiredTTL(batchSize?: number): Promise<number>;
|
|
139
|
+
listTTL(options?: OKDBTtlListOptions): Iterable<{ type: string; key: OKDBPrimaryKey; expiresAt: number }>;
|
|
140
|
+
ttlStats(type?: string): unknown;
|
|
141
|
+
setDefaultTTL(type: string, ttlMs: number): Promise<void>;
|
|
142
|
+
getDefaultTTL(type: string): number | null;
|
|
143
|
+
clearDefaultTTL(type: string): Promise<void>;
|
|
144
|
+
|
|
145
|
+
// ── Utilities ─────────────────────────────────────────────────────────────
|
|
146
|
+
count(iterable: Iterable<unknown>): number;
|
|
147
|
+
range(iterable: Iterable<unknown>): Generator<unknown>;
|
|
148
|
+
now(): number;
|
|
149
|
+
equal(a: unknown, b: unknown): boolean;
|
|
150
|
+
getResolvedOptions(): { durability: string; lmdbOptions: unknown; warnings: string[] };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default OKDB;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// Core option types and data shapes
|
|
2
|
+
|
|
3
|
+
export type OKDBPrimaryKey = string | number;
|
|
4
|
+
export type OKDBIndexKey = Array<string | number | null | Buffer>;
|
|
5
|
+
export type OKDBFilter = Record<string, unknown>;
|
|
6
|
+
|
|
7
|
+
// ── Constructor options ───────────────────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
export interface OKDBOptions {
|
|
10
|
+
maxDbs?: number;
|
|
11
|
+
pageSize?: number;
|
|
12
|
+
compression?: boolean;
|
|
13
|
+
encryptionKey?: string | Buffer;
|
|
14
|
+
mapSize?: number;
|
|
15
|
+
durability?: 'strict' | 'balanced' | 'fast' | 'custom';
|
|
16
|
+
allowUnsafe?: boolean;
|
|
17
|
+
lmdb?: Record<string, unknown>;
|
|
18
|
+
auth?: OKDBAuthOptions;
|
|
19
|
+
sync?: OKDBSyncOptions;
|
|
20
|
+
queue?: OKDBQueueOptions;
|
|
21
|
+
bus?: boolean | Record<string, unknown>;
|
|
22
|
+
functions?: Record<string, unknown>;
|
|
23
|
+
timeMachine?: OKDBTimeMachineOptions;
|
|
24
|
+
runtimeDeclarations?: boolean;
|
|
25
|
+
log?: { retainDays?: number };
|
|
26
|
+
shutdownTimeout?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface OKDBAuthOptions {
|
|
30
|
+
open?: boolean | string | string[];
|
|
31
|
+
session?: { secure?: boolean; sameSite?: 'Lax' | 'Strict' | 'None' };
|
|
32
|
+
token?: { secret?: string; ttl?: number };
|
|
33
|
+
oauth?: OKDBOAuthConfig;
|
|
34
|
+
providers?: Record<string, OKDBOAuthProviderConfig>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface OKDBOAuthConfig {
|
|
38
|
+
providerLabel?: string;
|
|
39
|
+
issuer?: string;
|
|
40
|
+
clientId?: string;
|
|
41
|
+
scopes?: string[];
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface OKDBOAuthProviderConfig {
|
|
46
|
+
issuer: string;
|
|
47
|
+
clientId: string;
|
|
48
|
+
scopes?: string[];
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface OKDBSyncOptions {
|
|
53
|
+
address?: string;
|
|
54
|
+
delta_limit?: number;
|
|
55
|
+
reconcile_concurrency?: number;
|
|
56
|
+
auto_reconcile?: boolean;
|
|
57
|
+
gcPeerStalenessLimitDays?: number;
|
|
58
|
+
gcIntervalMs?: number;
|
|
59
|
+
[key: string]: unknown;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface OKDBQueueOptions {
|
|
63
|
+
default_ttl?: number;
|
|
64
|
+
claim_batch_limit?: number;
|
|
65
|
+
reconcile_batch_limit?: number;
|
|
66
|
+
default_bucket_tokens?: number;
|
|
67
|
+
default_max_tries?: number | null;
|
|
68
|
+
default_retry_delay?: number;
|
|
69
|
+
default_backoff_multiplier?: number;
|
|
70
|
+
cron_next?: ((cronExpr: string, fromTimestamp: number) => number) | null;
|
|
71
|
+
done_ttl?: number | null;
|
|
72
|
+
failed_ttl?: number | null;
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface OKDBTimeMachineOptions {
|
|
77
|
+
[key: string]: unknown;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface OKDBEnvironmentConfig {
|
|
81
|
+
sync?: boolean;
|
|
82
|
+
durability?: 'strict' | 'balanced' | 'fast' | 'custom';
|
|
83
|
+
lmdb?: Record<string, unknown>;
|
|
84
|
+
compression?: boolean;
|
|
85
|
+
encryptionKey?: string | Buffer;
|
|
86
|
+
parentEnv?: string;
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ── Query and range options ───────────────────────────────────────────────────
|
|
91
|
+
|
|
92
|
+
export interface OKDBRangeOptions {
|
|
93
|
+
start?: OKDBPrimaryKey;
|
|
94
|
+
end?: OKDBPrimaryKey;
|
|
95
|
+
limit?: number;
|
|
96
|
+
reverse?: boolean;
|
|
97
|
+
offset?: number;
|
|
98
|
+
snapshot?: boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface OKDBQueryOptions {
|
|
102
|
+
index?: string[];
|
|
103
|
+
prefix?: OKDBIndexKey;
|
|
104
|
+
start?: OKDBIndexKey;
|
|
105
|
+
end?: OKDBIndexKey;
|
|
106
|
+
startIndex?: OKDBIndexKey;
|
|
107
|
+
limit?: number;
|
|
108
|
+
reverse?: boolean;
|
|
109
|
+
offset?: number;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface OKDBGeoQueryOptions {
|
|
113
|
+
lat: number;
|
|
114
|
+
lon: number;
|
|
115
|
+
radius?: number;
|
|
116
|
+
limit?: number;
|
|
117
|
+
reverse?: boolean;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface OKDBFtsQueryOptions {
|
|
121
|
+
limit?: number;
|
|
122
|
+
offset?: number;
|
|
123
|
+
[key: string]: unknown;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface OKDBWriteOptions {
|
|
127
|
+
ifVersion?: number;
|
|
128
|
+
timestamp?: number;
|
|
129
|
+
ttl?: number;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ── Result shapes ─────────────────────────────────────────────────────────────
|
|
133
|
+
|
|
134
|
+
export interface OKDBEntry<T = unknown> {
|
|
135
|
+
key: OKDBPrimaryKey;
|
|
136
|
+
value: T;
|
|
137
|
+
version: number;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface OKDBIndexEntry<T = unknown> extends OKDBEntry<T> {
|
|
141
|
+
indexKey: OKDBIndexKey;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface OKDBChangeEntry {
|
|
145
|
+
clock: number;
|
|
146
|
+
origin: string;
|
|
147
|
+
type: string;
|
|
148
|
+
key: OKDBPrimaryKey;
|
|
149
|
+
action: string;
|
|
150
|
+
version?: number;
|
|
151
|
+
timestamp: number;
|
|
152
|
+
newValue?: unknown;
|
|
153
|
+
oldValue?: unknown;
|
|
154
|
+
txnId?: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface OKDBIndexDefinition {
|
|
158
|
+
fields: string[];
|
|
159
|
+
type?: 'geo';
|
|
160
|
+
precision?: number;
|
|
161
|
+
unique?: boolean;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface OKDBTypeSchema {
|
|
165
|
+
definition: Record<string, unknown>;
|
|
166
|
+
enforce?: boolean;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface OKDBCompactResult {
|
|
170
|
+
ok: boolean;
|
|
171
|
+
sizeBefore: number;
|
|
172
|
+
sizeAfter: number;
|
|
173
|
+
saved: number;
|
|
174
|
+
savedPct: number;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface OKDBRemoveEnvironmentResult {
|
|
178
|
+
ok: boolean;
|
|
179
|
+
name: string;
|
|
180
|
+
filesRemoved: string[];
|
|
181
|
+
filesLocked: string[];
|
|
182
|
+
keptSubEnvs?: string[];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface OKDBTtlListOptions {
|
|
186
|
+
limit?: number;
|
|
187
|
+
reverse?: boolean;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface OKDBInfoResult {
|
|
191
|
+
id: string;
|
|
192
|
+
pageSize: number;
|
|
193
|
+
lastPageNumber: number;
|
|
194
|
+
mapSize: number;
|
|
195
|
+
clock: number;
|
|
196
|
+
plugins: string[];
|
|
197
|
+
versions: { okdb: string; lmdb: string | null; lmdbNative: string };
|
|
198
|
+
version: string;
|
|
199
|
+
ttl: unknown;
|
|
200
|
+
types: Record<string, unknown>;
|
|
201
|
+
config: unknown;
|
|
202
|
+
}
|