@kedem/okdb 2.3.5 → 2.5.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +427 -0
  2. package/algorithm-worker-thread.js +1 -1
  3. package/bin/okdb.js +1 -1
  4. package/docs/auth-and-sync.md +30 -5
  5. package/docs/auth-permissions.md +19 -6
  6. package/docs/change-log.md +79 -59
  7. package/docs/data-model.md +20 -18
  8. package/docs/deployment.md +25 -0
  9. package/docs/diagnostics.md +59 -17
  10. package/docs/embeddings.md +57 -6
  11. package/docs/fts.md +50 -5
  12. package/docs/functions.md +21 -8
  13. package/docs/http-api.md +139 -98
  14. package/docs/http-cluster.md +30 -8
  15. package/docs/indexes.md +5 -4
  16. package/docs/licensing.md +6 -1
  17. package/docs/logging.md +18 -0
  18. package/docs/migration.md +153 -2
  19. package/docs/pipelines.md +6 -1
  20. package/docs/plugins.md +12 -18
  21. package/docs/process-registry.md +50 -39
  22. package/docs/processors.md +40 -22
  23. package/docs/querying.md +50 -36
  24. package/docs/queue.md +110 -14
  25. package/docs/subscriptions.md +37 -24
  26. package/docs/sync.md +96 -37
  27. package/docs/time-machine.md +23 -17
  28. package/docs/transactions.md +11 -19
  29. package/docs/ttl.md +118 -67
  30. package/docs/upgrade-2.0.md +2 -2
  31. package/docs/views.md +75 -52
  32. package/okdb-functions-sandbox-worker.js +1 -1
  33. package/okdb-http-worker-child.js +1 -1
  34. package/okdb-views-bootstrap-worker.js +1 -1
  35. package/okdb.js +1 -1
  36. package/package.json +1 -1
  37. package/public/sections/db/parts/type-viewer.ok.js +1 -1
  38. package/public/sections/embeddings/parts/engines-overview.ok.js +1 -1
  39. package/public/sections/queue/parts/queue-jobs.ok.js +1 -1
  40. package/public/sections/system/modals/data-ops-modal.ok.js +1 -1
  41. package/types/environment.d.ts +320 -52
  42. package/types/features/admin.d.ts +8 -2
  43. package/types/features/api.d.ts +10 -16
  44. package/types/features/auth.d.ts +135 -16
  45. package/types/features/embeddings.d.ts +639 -31
  46. package/types/features/engines.d.ts +368 -14
  47. package/types/features/files.d.ts +0 -3
  48. package/types/features/fts.d.ts +98 -26
  49. package/types/features/functions.d.ts +175 -15
  50. package/types/features/mcp.d.ts +23 -10
  51. package/types/features/pipelines.d.ts +268 -9
  52. package/types/features/queue.d.ts +230 -34
  53. package/types/features/sync.d.ts +177 -14
  54. package/types/features/time-machine.d.ts +117 -16
  55. package/types/features/views.d.ts +230 -39
  56. package/types/index.d.ts +357 -254
  57. package/types/okdb.d.ts +397 -0
  58. package/types/options.d.ts +309 -48
  59. package/public/test-cron-input.html +0 -60
  60. package/public/test-json-input.html +0 -280
@@ -1,11 +1,26 @@
1
1
  // Core option types and data shapes
2
2
 
3
3
  export type OKDBPrimaryKey = string | number;
4
- export type OKDBIndexKey = Array<string | number | null | Buffer>;
4
+ export type OKDBIndexKey = Array<string | number | boolean | null | Buffer>;
5
+ /** A sift/MongoDB-style filter. Code-evaluating operators (`$where`) are rejected with
6
+ * `QUERY_OPERATOR_FORBIDDEN` everywhere a filter is accepted. */
5
7
  export type OKDBFilter = Record<string, unknown>;
8
+ /** An index is named by its field list (`['customerId', 'createdAt']`) or the `~`-joined
9
+ * string form (`'customerId~createdAt'`). */
10
+ export type OKDBIndexSpec = string | string[];
6
11
 
7
12
  // ── Constructor options ───────────────────────────────────────────────────────
8
13
 
14
+ /**
15
+ * `new OKDB(path, options)`.
16
+ *
17
+ * Removed options throw at construction (see docs/upgrade-2.0.md): `asyncProcessors`
18
+ * (ASYNC_PROCESSORS_REMOVED), `processing` (PROCESSING_REMOVED), `bus` (BUS_OPTION_REMOVED),
19
+ * `envs` (ENVS_REMOVED), `deferProcessing` (DEFER_PROCESSING_REMOVED), `workers` (WORKERS_REMOVED),
20
+ * `sync: true | false` (SYNC_OPTION_REMOVED — `sync` is only the settings object now),
21
+ * `compaction: 'active' | 'passive'` (COMPACTION_ALIAS_REMOVED), `processors: '<filter>'`.
22
+ * Any other key not listed here is ignored with one logged warning (did-you-mean for near-misses).
23
+ */
9
24
  export interface OKDBOptions {
10
25
  maxDbs?: number;
11
26
  pageSize?: number;
@@ -14,38 +29,76 @@ export interface OKDBOptions {
14
29
  mapSize?: number;
15
30
  durability?: 'strict' | 'balanced' | 'fast' | 'custom';
16
31
  allowUnsafe?: boolean;
32
+ /** Raw lmdb-js options (advanced; validated against `durability`). */
17
33
  lmdb?: Record<string, unknown>;
18
34
  auth?: OKDBAuthOptions;
35
+ /** Sync (replication) settings for `db.sync`. */
19
36
  sync?: OKDBSyncOptions;
37
+ /** Queue defaults applied to every env's queue. */
20
38
  queue?: OKDBQueueOptions;
39
+ /** Function-runtime defaults. */
21
40
  functions?: Record<string, unknown>;
22
- timeMachine?: OKDBTimeMachineOptions;
41
+ /** Time machine: attached to user envs (`env.timeMachine`) only when truthy (and licensed). */
42
+ timeMachine?: boolean | OKDBTimeMachineOptions;
43
+ /** MCP endpoint options. */
44
+ mcp?: { allowedOrigins?: string[] | '*' | null; [key: string]: unknown };
45
+ /** false skips booting runtime-declared views/processors at open(). Default true. */
23
46
  runtimeDeclarations?: boolean;
24
- log?: { retainDays?: number };
47
+ log?: { retainDays?: number; [key: string]: unknown };
48
+ /** close() grace period in ms (default 30000). */
25
49
  shutdownTimeout?: number;
26
- /** Lifecycle role flags — gate which background work this instance runs.
27
- * Defaults preserve full-role behavior; passive instances serve reads/writes
28
- * but skip engines / async processors / compaction scheduling. */
50
+ /** Reader-table check interval in ms (default 60000, min 1000). */
51
+ readerCheckIntervalMs?: number;
52
+ /** Lifecycle role flag: run queue/pipeline/embeddings engines on this instance. Default true. */
29
53
  engines?: boolean;
30
- /** okdb 2.0: INITIAL processing participation (claim every unclaimed `single` lease
31
- * and drain derived work — FTS, views, time-machine, embeddings). Default true.
32
- * false = not participating: claim nothing; reads/writes + inline processors still
33
- * run. Participation is dynamic — db.processors.start()/stop() flip it at runtime
34
- * (open with false + start() later = fast startup). Pass false for ephemeral
35
- * short-lived processes. */
54
+ /** INITIAL processing participation (claim every unclaimed `single` lease and drain derived
55
+ * work — FTS, views, time-machine, embeddings). Default true. false = not participating:
56
+ * claim nothing; reads/writes + inline processors still run. Participation is dynamic —
57
+ * `db.processors.start()/stop()` flip it at runtime (open with false + start() later =
58
+ * fast startup). */
36
59
  processors?: boolean;
37
- /** okdb 2.0: true = eligible to claim the per-env compaction lease,
38
- * false = passive (explicit env.compact() still works). */
60
+ /** true = eligible to claim the per-env compaction lease, false = passive
61
+ * (explicit `env.compact()` still works). Default true. */
39
62
  compaction?: boolean;
40
63
  /** Process-registry participation. false = invisible non-participant;
41
- * { name } labels this process in the admin's process list. */
42
- processes?: boolean | { name?: string; kind?: string; register?: boolean; listenAddr?: string | null };
43
- /** Auto-compaction thresholds; { enabled: false } (or OKDB_AUTO_COMPACT=0) disables. */
44
- autoCompact?: { enabled?: boolean; [key: string]: unknown };
64
+ * an object labels this process / forces reader-only (`register: false`). */
65
+ processes?:
66
+ | boolean
67
+ | {
68
+ name?: string;
69
+ kind?: string;
70
+ register?: boolean;
71
+ listenAddr?: string | null;
72
+ supervisorKey?: string | null;
73
+ };
74
+ /** Auto-compaction thresholds; `{ enabled: false }` (or OKDB_AUTO_COMPACT=0) disables. */
75
+ autoCompact?: OKDBAutoCompactOptions;
45
76
  /** HTTP API options (e.g. defaultEnv for routes that omit :env). */
46
77
  api?: { defaultEnv?: string; [key: string]: unknown };
47
- /** Admin UI feature; false disables it entirely. */
78
+ /** `false` disables the admin UI entirely (`db.admin` is then null). Only `false` is
79
+ * read — an object form is currently ignored. */
48
80
  admin?: boolean | Record<string, unknown>;
81
+ /** HTTP/MCP backups (`POST /api/system/backup`) may only write under `root`
82
+ * (default `<store>-backups`, next to the store). `db.migrate.backup(dir)` is unrestricted. */
83
+ backup?: { root?: string };
84
+ /** Live subscriptions (SSE) tuning. */
85
+ subscriptions?: { beatMs?: number; [key: string]: unknown };
86
+ /** Debug switches (e.g. `{ logRequests: true }`). */
87
+ debug?: { logRequests?: boolean; [key: string]: unknown };
88
+ /** Action when a license expires at runtime. */
89
+ onLicenseExpired?: string;
90
+ }
91
+
92
+ export interface OKDBAutoCompactOptions {
93
+ enabled?: boolean;
94
+ checkEveryWrites?: number;
95
+ checkEveryMs?: number;
96
+ minFileBytes?: number;
97
+ wastedRatioThreshold?: number;
98
+ cooldownMs?: number;
99
+ quietPeriodMs?: number;
100
+ maxHotDeferMs?: number;
101
+ [key: string]: unknown;
49
102
  }
50
103
 
51
104
  export interface OKDBAuthOptions {
@@ -54,6 +107,7 @@ export interface OKDBAuthOptions {
54
107
  token?: { secret?: string; ttl?: number };
55
108
  oauth?: OKDBOAuthConfig;
56
109
  providers?: Record<string, OKDBOAuthProviderConfig>;
110
+ [key: string]: unknown;
57
111
  }
58
112
 
59
113
  export interface OKDBOAuthConfig {
@@ -73,6 +127,8 @@ export interface OKDBOAuthProviderConfig {
73
127
 
74
128
  export interface OKDBSyncOptions {
75
129
  address?: string;
130
+ /** Bearer token presented to peers. */
131
+ token?: string;
76
132
  delta_limit?: number;
77
133
  reconcile_concurrency?: number;
78
134
  auto_reconcile?: boolean;
@@ -96,105 +152,248 @@ export interface OKDBQueueOptions {
96
152
  }
97
153
 
98
154
  export interface OKDBTimeMachineOptions {
99
- [key: string]: unknown;
155
+ /** Diff-flush debounce in ms (default 1000). */
156
+ flushDelayMs?: number;
100
157
  }
101
158
 
159
+ /** `createEnvironment(name, config)`. `sync: false` throws SYNC_OPTION_REMOVED for user envs —
160
+ * the changelog auto-enables with its first consumer. */
102
161
  export interface OKDBEnvironmentConfig {
103
162
  durability?: 'strict' | 'balanced' | 'fast' | 'custom';
104
163
  lmdb?: Record<string, unknown>;
105
164
  compression?: boolean;
106
165
  encryptionKey?: string | Buffer;
107
166
  parentEnv?: string;
167
+ /** Per-env role overrides (same meaning as the constructor flags). */
168
+ engines?: boolean;
169
+ processors?: boolean;
170
+ compaction?: boolean;
171
+ autoCompact?: OKDBAutoCompactOptions;
108
172
  [key: string]: unknown;
109
173
  }
110
174
 
111
175
  // ── Query and range options ───────────────────────────────────────────────────
112
176
 
177
+ /**
178
+ * Pinned-snapshot mode for range reads.
179
+ * - omitted / `false` (default for getRange/getKeys/getValues/getByPrefix): renewable read —
180
+ * safe to hold across `await`, consistency is per-row.
181
+ * - `true`: frozen whole-scan view, STRICT — consume synchronously; iterating after an
182
+ * `await` throws `READER_HELD_ACROSS_AWAIT`.
183
+ * - `'tolerant'`: frozen view that parks at a suspension and resumes iff no commit landed
184
+ * meanwhile (otherwise throws) — the error becomes load-dependent.
185
+ */
186
+ export type OKDBSnapshotMode = boolean | 'tolerant';
187
+
188
+ /** Options for getRange/getKeys/getValues/getCount/getByPrefix. Unknown keys throw. */
113
189
  export interface OKDBRangeOptions {
114
190
  start?: OKDBPrimaryKey;
115
191
  end?: OKDBPrimaryKey;
192
+ inclusiveEnd?: boolean;
193
+ exclusiveStart?: boolean;
116
194
  limit?: number;
117
195
  reverse?: boolean;
118
196
  offset?: number;
119
- snapshot?: boolean;
197
+ versions?: boolean;
198
+ snapshot?: OKDBSnapshotMode;
199
+ /** A caller-managed lmdb read transaction (advanced). */
200
+ transaction?: unknown;
201
+ }
202
+
203
+ /** FTS signal for hybrid `query()` (makes query() async). */
204
+ export interface OKDBQueryFtsSignal {
205
+ /** FTS index name on this type. */
206
+ name: string;
207
+ query?: string;
208
+ mode?: 'and' | 'or';
209
+ prefix?: boolean;
210
+ /** Cap on raw FTS candidates considered (default: all matches; 200 when query() has no limit). */
211
+ limit?: number;
212
+ /** RRF weight of the FTS signal when fused with `vector` (default 1). */
213
+ weight?: number;
120
214
  }
121
215
 
216
+ /** Vector signal for hybrid `query()` (makes query() async). */
217
+ export interface OKDBQueryVectorSignal {
218
+ /** Embeddings / vector-search engine name (`<env>:` prefix optional). */
219
+ engine: string;
220
+ query?: string;
221
+ limit?: number;
222
+ /** RRF weight of the vector signal when fused with `fts` (default 1). */
223
+ weight?: number;
224
+ }
225
+
226
+ export interface OKDBQueryNear {
227
+ field: string;
228
+ lat?: number;
229
+ lon?: number;
230
+ /** Max distance in meters. */
231
+ radius?: number;
232
+ /** [minLat, minLon, maxLat, maxLon] */
233
+ bbox?: number[];
234
+ }
235
+
236
+ /**
237
+ * query() options — a fixed vocabulary; unknown keys (including `start`/`end`) throw.
238
+ */
122
239
  export interface OKDBQueryOptions {
123
- index?: string[] | { fields: string[]; prefix?: OKDBIndexKey; start?: OKDBIndexKey; end?: OKDBIndexKey };
124
- prefix?: OKDBIndexKey;
240
+ index?:
241
+ | OKDBIndexSpec
242
+ | {
243
+ fields: string[];
244
+ prefix?: unknown;
245
+ start?: OKDBIndexKey;
246
+ end?: OKDBIndexKey;
247
+ startKey?: OKDBPrimaryKey;
248
+ endKey?: OKDBPrimaryKey;
249
+ };
250
+ /** Index prefix (a single value or an array of leading values). Requires `index`. */
251
+ prefix?: unknown;
125
252
  /** Inclusive index-key lower/upper bound. NOT `start`/`end` — those are byIndex/getRange
126
253
  * names and are not implemented by query(); passing them throws. */
127
254
  startIndex?: OKDBIndexKey;
128
255
  endIndex?: OKDBIndexKey;
129
- /** Primary-key page-boundary hint (cursor-style pagination), as an alternative to startIndex/endIndex. */
256
+ /** Primary-key page-boundary hint (cursor-style pagination). */
130
257
  startKey?: OKDBPrimaryKey;
131
258
  endKey?: OKDBPrimaryKey;
132
259
  limit?: number;
133
260
  reverse?: boolean;
134
261
  offset?: number;
262
+ /** Map each result row before it is returned. */
263
+ select?: (entry: OKDBQueryEntry<any>) => any;
264
+ /** Geo filter (alternatively `$near` / `$within` inside the filter). Rows carry `distance`. */
265
+ near?: OKDBQueryNear;
266
+ /** FTS signal — makes query() return a Promise. */
267
+ fts?: OKDBQueryFtsSignal;
268
+ /** Vector signal — makes query() return a Promise. */
269
+ vector?: OKDBQueryVectorSignal;
270
+ transaction?: unknown;
135
271
  }
136
272
 
273
+ /** query() options carrying an fts or vector signal — query() then resolves asynchronously. */
274
+ export type OKDBHybridQueryOptions = OKDBQueryOptions &
275
+ ({ fts: OKDBQueryFtsSignal } | { vector: OKDBQueryVectorSignal });
276
+
137
277
  /**
138
- * Options for byIndex/getIndex/countByIndex. Distinct from OKDBQueryOptions: these forward
139
- * directly to lmdb-js's own range scan, so `start`/`end` ARE the real (direction-independent)
140
- * index-key bounds here — unlike query(), which uses startIndex/endIndex instead.
278
+ * Options for byIndex/getIndex/countByIndex. Distinct from OKDBQueryOptions: `start`/`end`
279
+ * ARE the (direction-independent, inclusive) index-key bounds here — unlike query(), which
280
+ * uses startIndex/endIndex instead. Index scans are always pinned + guarded: consume them
281
+ * synchronously (see OKDBSnapshotMode).
141
282
  */
142
283
  export interface OKDBIndexRangeOptions {
143
- prefix?: OKDBIndexKey;
284
+ /** Shorthand for start: [...prefix], end: [...prefix, HIGH_SENTINEL]. */
285
+ prefix?: unknown;
144
286
  start?: OKDBIndexKey;
145
287
  end?: OKDBIndexKey;
288
+ inclusiveEnd?: boolean;
289
+ exclusiveStart?: boolean;
146
290
  reverse?: boolean;
147
291
  limit?: number;
148
292
  offset?: number;
149
- snapshot?: boolean;
293
+ versions?: boolean;
294
+ snapshot?: OKDBSnapshotMode;
150
295
  transaction?: unknown;
151
296
  /** byIndex only: include all entries violating a unique index instead of just the winner. */
152
297
  includeViolations?: boolean;
153
298
  }
154
299
 
155
300
  export interface OKDBGeoQueryOptions {
156
- lat: number;
157
- lon: number;
301
+ lat?: number;
302
+ lon?: number;
303
+ /** Max distance in meters. */
158
304
  radius?: number;
305
+ /** [minLat, minLon, maxLat, maxLon] bounding box (alternative to lat/lon). */
306
+ bbox?: number[];
307
+ /** Sift filter applied to documents. */
308
+ filter?: OKDBFilter;
159
309
  limit?: number;
160
- reverse?: boolean;
310
+ offset?: number;
311
+ select?: (entry: OKDBQueryEntry<any>) => any;
161
312
  }
162
313
 
314
+ /** Options forwarded to `fts.searchDocs` by ftsQuery(). */
163
315
  export interface OKDBFtsQueryOptions {
164
316
  limit?: number;
165
- offset?: number;
317
+ mode?: 'and' | 'or';
318
+ prefix?: boolean;
166
319
  [key: string]: unknown;
167
320
  }
168
321
 
169
322
  export interface OKDBWriteOptions {
170
- ifVersion?: number;
323
+ /** Optimistic concurrency: fail with VERSION_MISMATCH unless the stored version matches. */
324
+ ifVersion?: number | null;
325
+ /** put/create only: explicit version to store. */
326
+ version?: number | null;
171
327
  timestamp?: number;
172
- ttl?: number;
328
+ /** Origin id stamped on the change (defaults to this instance). */
329
+ origin?: string | null;
330
+ /** Per-document TTL in ms. */
331
+ ttl?: number | null;
332
+ }
333
+
334
+ export interface OKDBRemoveOptions {
335
+ ifVersion?: number | null;
336
+ timestamp?: number;
337
+ origin?: string | null;
338
+ }
339
+
340
+ export interface OKDBTransactionOptions {
341
+ /** Pin a consistent read view for the transaction's creation turn (true), or park/resume it
342
+ * across awaits while no commit lands ('tolerant'). Default false. */
343
+ useReadTransaction?: boolean | 'tolerant';
173
344
  }
174
345
 
175
346
  // ── Result shapes ─────────────────────────────────────────────────────────────
176
347
 
348
+ /**
349
+ * Lazy range result (lmdb-js RangeIterable or okdb's guarded equivalent). Iterate it or chain
350
+ * `map`/`filter`; materialize with `Array.from(...)`.
351
+ */
352
+ export interface OKDBRangeIterable<T> extends Iterable<T> {
353
+ map<U>(fn: (entry: T) => U): OKDBRangeIterable<U>;
354
+ filter(fn: (entry: T) => unknown): OKDBRangeIterable<T>;
355
+ forEach(fn: (entry: T) => unknown): void;
356
+ }
357
+
177
358
  export interface OKDBEntry<T = unknown> {
178
359
  key: OKDBPrimaryKey;
179
360
  value: T;
180
- version: number;
361
+ version?: number;
181
362
  }
182
363
 
183
364
  export interface OKDBIndexEntry<T = unknown> extends OKDBEntry<T> {
184
365
  indexKey: OKDBIndexKey;
366
+ indexVersion?: number;
367
+ }
368
+
369
+ /** A query() row: an entry, plus index/geo/hybrid-search fields depending on the path taken. */
370
+ export interface OKDBQueryEntry<T = unknown> extends OKDBEntry<T> {
371
+ indexKey?: OKDBIndexKey;
372
+ /** Geo queries: distance in meters. */
373
+ distance?: number;
374
+ /** Hybrid queries: combined / per-signal scores. */
375
+ score?: number;
376
+ ftsScore?: number;
377
+ numTerms?: number;
378
+ maxScore?: number;
379
+ vectorScore?: number;
380
+ chunkHash?: string;
381
+ chunk?: unknown;
185
382
  }
186
383
 
384
+ /** A change-log record (`getChanges()`; processor handlers receive the same shape). */
187
385
  export interface OKDBChangeEntry {
188
386
  clock: number;
189
- origin: string;
387
+ id?: string;
190
388
  type: string;
191
- key: OKDBPrimaryKey;
389
+ key?: OKDBPrimaryKey;
390
+ /** 'put' | 'remove' | schema actions ('registerType', …). */
192
391
  action: string;
193
- version?: number;
392
+ /** HLC timestamp. */
194
393
  timestamp: number;
195
- newValue?: unknown;
196
- oldValue?: unknown;
394
+ origin?: string | null;
197
395
  txnId?: string;
396
+ [key: string]: unknown;
198
397
  }
199
398
 
200
399
  export interface OKDBIndexDefinition {
@@ -204,17 +403,41 @@ export interface OKDBIndexDefinition {
204
403
  unique?: boolean;
205
404
  }
206
405
 
406
+ export interface OKDBRegisterIndexOptions {
407
+ type?: 'geo';
408
+ /** Geohash precision (default 7). */
409
+ precision?: number;
410
+ unique?: boolean;
411
+ timestamp?: number;
412
+ }
413
+
207
414
  export interface OKDBTypeSchema {
208
415
  definition: Record<string, unknown>;
209
416
  enforce?: boolean;
210
417
  }
211
418
 
419
+ /** `ensure(definition)` — idempotent type + indexes + FTS + views + schema declaration. */
420
+ export interface OKDBEnsureDefinition {
421
+ type: string;
422
+ indexes?: Array<string[] | OKDBIndexDefinition>;
423
+ fts?: Array<{ name: string; fields: string[]; [key: string]: unknown }>;
424
+ views?: Array<{ name: string; definition: Record<string, unknown> }>;
425
+ schema?: OKDBTypeSchema | null;
426
+ }
427
+
212
428
  export interface OKDBCompactResult {
213
429
  ok: boolean;
214
- sizeBefore: number;
215
- sizeAfter: number;
216
- saved: number;
217
- savedPct: number;
430
+ /** Another process held the compaction lease, or the env was closing. */
431
+ skipped?: boolean;
432
+ reason?: string;
433
+ /** Writers did not quiesce; auto-compaction retries later. */
434
+ deferred?: boolean;
435
+ sizeBefore?: number;
436
+ sizeAfter?: number;
437
+ saved?: number;
438
+ savedPct?: number;
439
+ usedLogicalRebuild?: boolean;
440
+ [key: string]: unknown;
218
441
  }
219
442
 
220
443
  export interface OKDBRemoveEnvironmentResult {
@@ -226,8 +449,45 @@ export interface OKDBRemoveEnvironmentResult {
226
449
  }
227
450
 
228
451
  export interface OKDBTtlListOptions {
452
+ /** Filter to a single type. */
453
+ type?: string | null;
454
+ /** Max entries (default 100). */
229
455
  limit?: number;
230
- reverse?: boolean;
456
+ }
457
+
458
+ export interface OKDBTtlInfo {
459
+ expiresAt: number;
460
+ remainingMs: number;
461
+ }
462
+
463
+ export interface OKDBTtlListResult {
464
+ items: Array<{ type: string; key: OKDBPrimaryKey; expiresAt: number; remainingMs: number; expired: boolean }>;
465
+ total: number;
466
+ }
467
+
468
+ export interface OKDBTtlStats {
469
+ enabled: boolean;
470
+ totalEntries: number;
471
+ expiredEntries: number;
472
+ nextExpiry: number | null;
473
+ byType: Record<string, number>;
474
+ }
475
+
476
+ export interface OKDBTtlSweepResult {
477
+ removed: number;
478
+ types: Record<string, number>;
479
+ }
480
+
481
+ export interface OKDBResolvedOptions {
482
+ durability?: string;
483
+ lmdbOptions?: unknown;
484
+ warnings?: string[];
485
+ }
486
+
487
+ export interface OKDBRoleFlags {
488
+ readonly processors: boolean;
489
+ readonly engines: boolean;
490
+ readonly compaction: boolean;
231
491
  }
232
492
 
233
493
  export interface OKDBInfoResult {
@@ -239,7 +499,8 @@ export interface OKDBInfoResult {
239
499
  plugins: string[];
240
500
  versions: { okdb: string; lmdb: string | null; lmdbNative: string };
241
501
  version: string;
242
- ttl: unknown;
502
+ ttl: OKDBTtlStats;
243
503
  types: Record<string, unknown>;
244
- config: unknown;
504
+ config: OKDBResolvedOptions;
505
+ [key: string]: unknown;
245
506
  }
@@ -1,60 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <base href="./">
5
- <meta charset="UTF-8">
6
- <title>ok-cron-input test</title>
7
- <link rel="stylesheet" href="styles.css">
8
- <script type="importmap">
9
- {
10
- "imports": {
11
- "@toolkit/": "./vendor/okjs/toolkit/",
12
- "@okjs": "./vendor/okjs/ok.esm.min.js"
13
- }
14
- }
15
- </script>
16
- <style>
17
- body { padding: 40px; display:block; height:auto; }
18
- .demo { max-width:500px; margin:0 auto; display:flex; flex-direction:column; gap:32px; }
19
- h1 { color:#4FC1FF; font-size:18px; margin:0 0 8px; }
20
- .row { display:flex; flex-direction:column; gap:6px; }
21
- label { font-size:12px; color:#6b8a9e; }
22
- .val { font-family:monospace; font-size:12px; color:#8bb4cc; background:#12171a; padding:4px 8px; border-radius:4px; border:1px solid #2a3035; min-height:22px; }
23
- </style>
24
- </head>
25
- <body>
26
- <div class="demo">
27
- <div>
28
- <h1>ok-cron-input</h1>
29
- <p style="color:#8899aa;font-size:12px;margin:0">Click the ✏ button to open the cron editor panel.</p>
30
- </div>
31
-
32
- <div class="row">
33
- <label>Cron expression (empty start)</label>
34
- <ok-cron-input id="c1" @change="document.getElementById('v1').textContent = $event.detail"></ok-cron-input>
35
- <div class="val" id="v1"></div>
36
- </div>
37
-
38
- <div class="row">
39
- <label>Cron expression (pre-populated)</label>
40
- <ok-cron-input id="c2" value="*/15 9-17 * * 1-5" @change="document.getElementById('v2').textContent = $event.detail"></ok-cron-input>
41
- <div class="val" id="v2">*/15 9-17 * * 1-5</div>
42
- </div>
43
-
44
- <div class="row">
45
- <label>Cron expression (disabled)</label>
46
- <ok-cron-input value="0 12 * * *" disabled></ok-cron-input>
47
- </div>
48
- </div>
49
-
50
- <script type="module">
51
- import OK from '@okjs';
52
- import okCronInput from './components/ok-cron-input.ok.js';
53
- const ok = OK({ env: 'dev' });
54
- ok.register(okCronInput);
55
- await ok.init(document.body);
56
- </script>
57
- </body>
58
- </html>
59
-
60
-