datahike 0.8.1872 → 0.8.1877

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 (149) hide show
  1. package/README.md +16 -0
  2. package/boring.core.js +2 -2
  3. package/boring.data.js +7 -7
  4. package/boring.options.js +16 -16
  5. package/boring.reader.js +4 -4
  6. package/boring.writer.js +2 -2
  7. package/browser/datahike.js +3883 -3858
  8. package/browser/index.mjs +2 -0
  9. package/cljs.cache.js +10 -10
  10. package/cljs.cache.wrapped.js +7 -7
  11. package/cljs.core.async.impl.channels.js +9 -9
  12. package/cljs.core.async.impl.dispatch.js +3 -3
  13. package/cljs.core.async.impl.ioc_helpers.js +2 -2
  14. package/cljs.core.async.impl.timers.js +6 -6
  15. package/cljs.core.async.js +16 -15
  16. package/cljs.core.js +570 -569
  17. package/cljs.nodejs.js +1 -1
  18. package/cljs.reader.js +12 -12
  19. package/cljs.spec.alpha.js +74 -74
  20. package/cljs.tools.reader.edn.js +26 -26
  21. package/cljs.tools.reader.impl.commons.js +7 -7
  22. package/cljs.tools.reader.impl.errors.js +10 -10
  23. package/cljs.tools.reader.impl.inspect.js +4 -4
  24. package/cljs.tools.reader.impl.utils.js +3 -3
  25. package/cljs.tools.reader.js +2 -2
  26. package/cljs.tools.reader.reader_types.js +1 -1
  27. package/cljs_env.js +9 -9
  28. package/cljs_node_io.core.js +11 -11
  29. package/cljs_node_io.file.js +27 -27
  30. package/cljs_node_io.fs.js +1 -1
  31. package/clojure.data.js +14 -14
  32. package/clojure.set.js +2 -2
  33. package/clojure.string.js +13 -13
  34. package/clojure.walk.js +3 -3
  35. package/datahike.api.impl.js +34 -34
  36. package/datahike.api.js +5 -5
  37. package/datahike.array.js +9 -9
  38. package/datahike.attr_preds.js +1 -1
  39. package/datahike.bitemporal.predicate.js +1 -1
  40. package/datahike.config.js +49 -49
  41. package/datahike.connections.js +4 -4
  42. package/datahike.connector.js +77 -77
  43. package/datahike.constants.js +20 -21
  44. package/datahike.core.js +1 -1
  45. package/datahike.datom.js +23 -22
  46. package/datahike.db.interface.js +12 -12
  47. package/datahike.db.js +99 -98
  48. package/datahike.db.search.js +49 -49
  49. package/datahike.db.transaction.js +11 -11
  50. package/datahike.db.utils.js +48 -48
  51. package/datahike.env.js +4 -4
  52. package/datahike.gc.js +12 -12
  53. package/datahike.gc_roots.js +2 -2
  54. package/datahike.impl.entity.js +16 -16
  55. package/datahike.index.interface.js +12 -12
  56. package/datahike.index.js +1 -1
  57. package/datahike.index.persistent_set.js +175 -175
  58. package/datahike.index.persistent_set.warm.js +1 -1
  59. package/datahike.index.secondary.js +5 -5
  60. package/datahike.js.api.js +263 -243
  61. package/datahike.js.convert.js +2 -0
  62. package/datahike.lru.js +8 -8
  63. package/datahike.metrics.js +10 -10
  64. package/datahike.migrate.ids.js +1 -1
  65. package/datahike.online_gc.js +2 -2
  66. package/datahike.optimistic.js +12 -12
  67. package/datahike.pull_api.js +7 -7
  68. package/datahike.query.analyze.js +4 -4
  69. package/datahike.query.estimate.js +2 -2
  70. package/datahike.query.execute.js +7 -7
  71. package/datahike.query.ir.js +6 -6
  72. package/datahike.query.js +1411 -1410
  73. package/datahike.query.logical.js +2 -2
  74. package/datahike.query.lower.js +2 -2
  75. package/datahike.query.plan.js +12 -12
  76. package/datahike.query.relation.js +1 -1
  77. package/datahike.query.resolve.js +1 -1
  78. package/datahike.query_stats.js +1 -1
  79. package/datahike.readers.js +10 -11
  80. package/datahike.remote.js +2 -0
  81. package/datahike.schema.js +48 -48
  82. package/datahike.schema_cache.js +3 -3
  83. package/datahike.store.js +62 -62
  84. package/datahike.tools.js +5 -5
  85. package/datahike.tx_preds.js +1 -1
  86. package/datahike.versioning.js +4 -4
  87. package/datahike.writer.js +813 -804
  88. package/datahike.writing.js +53 -53
  89. package/datalog.parser.impl.js +4 -4
  90. package/datalog.parser.impl.proto.js +1 -1
  91. package/datalog.parser.impl.util.js +1 -1
  92. package/datalog.parser.js +1 -1
  93. package/datalog.parser.pull.js +3 -3
  94. package/datalog.parser.type.js +32 -32
  95. package/fress.api.js +1 -1
  96. package/fress.impl.adler32.js +4 -4
  97. package/fress.impl.bigdec.js +2 -2
  98. package/fress.impl.buffer.js +4 -4
  99. package/fress.impl.raw_input.js +1 -1
  100. package/fress.impl.raw_output.js +4 -4
  101. package/fress.impl.table.js +1 -1
  102. package/fress.reader.js +15 -15
  103. package/fress.util.js +11 -11
  104. package/fress.writer.js +24 -24
  105. package/geheimnis.aes.js +1 -1
  106. package/hasch.benc.js +3 -3
  107. package/hasch.core.js +11 -11
  108. package/hasch.platform.js +18 -18
  109. package/index.d.ts +32 -0
  110. package/is.simm.partial_cps.sequence.js +5 -5
  111. package/kabel/datahike.js +5329 -5303
  112. package/kabel/index.mjs +2 -0
  113. package/konserve.compressor.js +16 -16
  114. package/konserve.core.js +53 -53
  115. package/konserve.encryptor.js +11 -11
  116. package/konserve.gc.js +1 -1
  117. package/konserve.gc_guard.js +1 -1
  118. package/konserve.impl.defaults.js +15 -15
  119. package/konserve.impl.storage_layout.js +3 -3
  120. package/konserve.memory.js +1 -1
  121. package/konserve.metrics.js +6 -6
  122. package/konserve.node_filestore.js +620 -620
  123. package/konserve.protocols.js +7 -7
  124. package/konserve.serializers.js +20 -20
  125. package/konserve.store.js +98 -98
  126. package/konserve.tiered.js +10 -10
  127. package/konserve.utils.js +6 -6
  128. package/org.replikativ.persistent_sorted_set.branch.js +3 -3
  129. package/org.replikativ.persistent_sorted_set.btset.js +366 -366
  130. package/org.replikativ.persistent_sorted_set.fressian.js +5 -5
  131. package/org.replikativ.persistent_sorted_set.impl.boundary.js +1 -1
  132. package/org.replikativ.persistent_sorted_set.impl.nodes.js +2 -2
  133. package/org.replikativ.persistent_sorted_set.js +1 -1
  134. package/org.replikativ.persistent_sorted_set.leaf.js +1 -1
  135. package/org.replikativ.persistent_sorted_set.util.js +1 -1
  136. package/org.replikativ.persistent_sorted_set.warm.js +1 -1
  137. package/package.json +13 -3
  138. package/remote/datahike.js +679 -0
  139. package/remote/index.js +3 -0
  140. package/remote/index.mjs +50 -0
  141. package/remote.d.ts +709 -0
  142. package/replikativ.logging.js +1 -1
  143. package/replikativ.metrics.js +1 -1
  144. package/s3/datahike.js +4555 -4529
  145. package/s3/index.mjs +2 -0
  146. package/superv.async.js +26 -26
  147. package/tailrecursion.priority_map.js +16 -16
  148. package/taoensso.trove.console.js +4 -4
  149. package/taoensso.trove.js +1 -1
package/remote.d.ts ADDED
@@ -0,0 +1,709 @@
1
+ // Auto-generated TypeScript definitions for Datahike JavaScript API
2
+ // DO NOT EDIT - Generated from datahike.api.specification
3
+
4
+
5
+ // Core Datahike Types
6
+
7
+ export type Keyword = `:${string}`;
8
+ export type Attribute = Keyword;
9
+
10
+ declare const datahikeUuidBrand: unique symbol;
11
+ /** Opaque UUID input returned by uuid() and randomUuid(). */
12
+ export interface DatahikeUuid {
13
+ readonly [datahikeUuidBrand]: true;
14
+ }
15
+ /** UUID values returned by the JavaScript boundary are ordinary strings. */
16
+ export type UuidValue = string;
17
+
18
+ /** A named branch (for example `':db'` or `':feature'`). */
19
+ export type BranchName = Keyword;
20
+ /** A branch name or an input UUID created with uuid(). */
21
+ export type VersionRef = BranchName | DatahikeUuid;
22
+
23
+ export interface GcOptions {
24
+ /** Keep objects written within this many milliseconds, even if unreachable. */
25
+ 'min-age-ms'?: number;
26
+ }
27
+
28
+ export interface StoreConfig {
29
+ backend: Keyword;
30
+ id?: DatahikeUuid;
31
+ path?: string;
32
+ [key: string]: any;
33
+ }
34
+
35
+ /** S3 backend configuration for the opt-in `datahike/s3` browser entry. */
36
+ export interface S3StoreConfig extends StoreConfig {
37
+ backend: ':s3';
38
+ id: DatahikeUuid;
39
+ endpoint: string;
40
+ bucket: string;
41
+ 'access-key': string;
42
+ secret: string;
43
+ region?: string;
44
+ 'session-token'?: string;
45
+ 'path-style?'?: boolean;
46
+ config?: {
47
+ 'optimistic-locking-retries'?: number;
48
+ [key: string]: any;
49
+ };
50
+ }
51
+
52
+ /**
53
+ * Browser-safe Datahike storage: a complete synchronous memory frontend over
54
+ * an asynchronous, authoritative S3 backend. Bare S3StoreConfig is not a
55
+ * usable Datahike query store in browsers.
56
+ */
57
+ export interface TieredS3StoreConfig extends StoreConfig {
58
+ backend: ':tiered';
59
+ id: DatahikeUuid;
60
+ 'frontend-config': { backend: ':memory'; id: DatahikeUuid };
61
+ 'backend-config': S3StoreConfig;
62
+ 'write-policy'?: ':write-through';
63
+ 'read-policy'?: ':frontend-first';
64
+ }
65
+
66
+ export interface WriterConfig {
67
+ backend: Keyword;
68
+ [key: string]: any;
69
+ }
70
+
71
+ export interface ConnectOptions {
72
+ /**
73
+ * Preserve the ClojureScript API's execution mode. Memory stores can run
74
+ * synchronously; browser and remote stores use false and resolve a Promise.
75
+ */
76
+ 'sync?'?: boolean;
77
+ [key: string]: any;
78
+ }
79
+
80
+ /** Persistent browser backend registered by the `datahike/kabel` entry. */
81
+ export interface IndexedDbStoreConfig extends StoreConfig {
82
+ backend: ':indexeddb';
83
+ id: DatahikeUuid;
84
+ name?: string;
85
+ }
86
+
87
+ /** Synchronous memory frontend over an authoritative IndexedDB cache. */
88
+ export interface TieredIndexedDbStoreConfig extends StoreConfig {
89
+ backend: ':tiered';
90
+ id: DatahikeUuid;
91
+ 'frontend-config': { backend: ':memory'; id: DatahikeUuid };
92
+ 'backend-config': IndexedDbStoreConfig;
93
+ 'write-policy'?: ':write-through';
94
+ 'read-policy'?: ':frontend-first';
95
+ }
96
+
97
+ export interface DatabaseConfig {
98
+ store: StoreConfig;
99
+ writer?: WriterConfig;
100
+ branch?: Keyword;
101
+ 'keep-history?'?: boolean;
102
+ 'schema-flexibility'?: ':read' | ':write';
103
+ 'initial-tx'?: Transaction[];
104
+ name?: string;
105
+ [key: string]: any;
106
+ }
107
+
108
+ declare const connectionBrand: unique symbol;
109
+ export interface Connection {
110
+ readonly [connectionBrand]: true;
111
+ }
112
+
113
+ declare const databaseBrand: unique symbol;
114
+ export interface Database {
115
+ readonly [databaseBrand]: true;
116
+ }
117
+
118
+ export type EntityId = number | string | [Attribute, any];
119
+ export type EntityMap = Record<string, any>;
120
+ export type Transaction =
121
+ | [':db/add', EntityId, Attribute, any]
122
+ | [':db/retract', EntityId, Attribute, any]
123
+ | [Keyword, ...any[]]
124
+ | EntityMap;
125
+
126
+ export interface WithArgs {
127
+ 'tx-data': Transaction[];
128
+ 'tx-meta'?: any;
129
+ }
130
+
131
+ export interface QueryArgs {
132
+ query: string | any[] | Record<string, any>;
133
+ args?: any[];
134
+ limit?: number;
135
+ offset?: number;
136
+ }
137
+
138
+ export interface PullOptions {
139
+ selector: any[];
140
+ eid: EntityId | EntityId[];
141
+ }
142
+
143
+ export type Index = ':eavt' | ':aevt' | ':avet';
144
+ export interface IndexLookupArgs {
145
+ index: Index;
146
+ components?: any[] | null;
147
+ }
148
+
149
+ export interface IndexRangeArgs {
150
+ attrid: Attribute;
151
+ start: any;
152
+ end: any;
153
+ }
154
+
155
+ export interface TransactionReport {
156
+ 'db-before': Database;
157
+ 'db-after': Database;
158
+ 'tx-data': Datom[];
159
+ tempids: { [key: string]: number };
160
+ 'tx-meta'?: any;
161
+ }
162
+
163
+ export interface DurableCommitEvent {
164
+ type: ':datahike/commit';
165
+ 'store-id': UuidValue;
166
+ branch: Keyword;
167
+ 'commit-id': UuidValue;
168
+ 'parent-commit-ids': UuidValue[];
169
+ 'max-tx': number;
170
+ 'tx-count': number;
171
+ 'db-before': Database;
172
+ 'db-after': Database;
173
+ 'tx-reports': TransactionReport[];
174
+ }
175
+
176
+ export interface Datom {
177
+ e: number;
178
+ a: Attribute;
179
+ v: any;
180
+ tx: number;
181
+ added: boolean;
182
+ }
183
+
184
+ export interface Schema {
185
+ [key: string]: {
186
+ 'db/valueType': Keyword;
187
+ 'db/cardinality': Keyword;
188
+ 'db/unique'?: Keyword;
189
+ 'db/index'?: boolean;
190
+ [key: string]: any;
191
+ };
192
+ }
193
+
194
+ export interface Metrics {
195
+ count: number;
196
+ 'avet-count': number;
197
+ 'per-attr-counts': Record<string, number>;
198
+ 'per-entity-counts'?: Record<string, number>;
199
+ 'temporal-count'?: number;
200
+ 'temporal-avet-count'?: number;
201
+ }
202
+
203
+ export interface OptimisticOverlay {
204
+ readonly __optimisticOverlayBrand: never;
205
+ }
206
+
207
+ export interface OptimisticOptions {
208
+ 'max-pending'?: number;
209
+ 'max-queue'?: number;
210
+ 'prediction-timeout-ms'?: number | null;
211
+ 'reconciliation-timeout-ms'?: number | null;
212
+ }
213
+
214
+ export interface OptimisticSubmitOptions {
215
+ branch?: Keyword;
216
+ }
217
+
218
+ export interface OptimisticPredictionOptions extends OptimisticSubmitOptions {
219
+ 'timeout-ms'?: number | null;
220
+ }
221
+
222
+ export type OptimisticTransactionInput =
223
+ | Transaction[]
224
+ | { 'tx-data': Transaction[]; 'tx-meta'?: any };
225
+
226
+ export type OptimisticResultStatus =
227
+ | ':committed'
228
+ | ':accepted'
229
+ | ':reconciled'
230
+ | ':rejected'
231
+ | ':expired'
232
+ | ':abandoned'
233
+ | ':unknown'
234
+ | ':detached';
235
+
236
+ export interface OptimisticResult {
237
+ status: OptimisticResultStatus;
238
+ error?: any;
239
+ receipt?: any;
240
+ 'tx-report'?: TransactionReport;
241
+ outcome?: ':unknown' | ':committed';
242
+ reason?: any;
243
+ 'accepted?'?: boolean;
244
+ }
245
+
246
+ export interface OptimisticHandle {
247
+ ovId: string;
248
+ result: Promise<OptimisticResult>;
249
+ }
250
+
251
+ export interface OptimisticPendingEntry {
252
+ 'ov-id': string;
253
+ kind: ':writer' | ':prediction';
254
+ 'submitted-at': number;
255
+ 'expires-at'?: number | null;
256
+ 'expected-max-tx'?: number | null;
257
+ branch?: string;
258
+ 'acknowledged?': boolean;
259
+ 'conflicting?': boolean;
260
+ 'last-conflict-error'?: any;
261
+ 'reconcile-deadline-at'?: number | null;
262
+ 'reconciliation-stalled?'?: boolean;
263
+ [key: string]: any;
264
+ }
265
+
266
+ export interface OptimisticChanges {
267
+ added: Datom[];
268
+ removed: Datom[];
269
+ }
270
+
271
+ export interface OptimisticTransition {
272
+ revision: number;
273
+ 'db-before': Database;
274
+ 'db-after': Database;
275
+ 'base-max-tx': number | null;
276
+ cause: { type: string; [key: string]: any };
277
+ changes: OptimisticChanges | null;
278
+ }
279
+
280
+ export interface OptimisticStatusEvent {
281
+ revision: number;
282
+ 'ov-id': string;
283
+ kind: ':writer' | ':prediction';
284
+ status:
285
+ | ':visible'
286
+ | ':acknowledged'
287
+ | ':committed'
288
+ | ':reconciled'
289
+ | ':rejected'
290
+ | ':expired'
291
+ | ':abandoned'
292
+ | ':conflicting'
293
+ | ':applicable'
294
+ | ':reconciliation-error'
295
+ | ':reconciliation-stalled'
296
+ | ':unknown'
297
+ | ':detached';
298
+ [key: string]: any;
299
+ }
300
+
301
+
302
+ // API Functions (the thin HTTP client; every call reaches the server)
303
+
304
+ /**
305
+ * Returns database state at given time point (Date or transaction ID)..
306
+ *
307
+ * Examples:
308
+ * - Query as of date
309
+ * (q '[:find ?n :where [_ :name ?n]] (as-of @conn date))
310
+ * - Query as of transaction
311
+ * (as-of @conn 536870913)
312
+ */
313
+ export function asOf(arg0: Database, arg1: number | Date): Promise<Database>;
314
+
315
+ /**
316
+ * Create a new branch from an existing branch or commit.
317
+ *
318
+ * Examples:
319
+ * - Branch from main
320
+ * (branch! conn :db :experiment)
321
+ * - Branch from specific commit
322
+ * (branch! conn #uuid "..." :hotfix)
323
+ */
324
+ export function branch(conn: Connection, from: VersionRef, newBranch: Keyword): Promise<unknown>;
325
+
326
+ /**
327
+ * Load the database at a branch head.
328
+ *
329
+ * Examples:
330
+ * - Load db at branch
331
+ * (branch-as-db conn :experiment)
332
+ */
333
+ export function branchAsDb(source: Connection | Database, branch: Keyword): Promise<Database | null>;
334
+
335
+ /**
336
+ * List all known branch names.
337
+ *
338
+ * Examples:
339
+ * - List branches
340
+ * (branches conn)
341
+ */
342
+ export function branches(conn: Connection): Promise<Array<Keyword>>;
343
+
344
+ /**
345
+ * Load the database at a specific commit.
346
+ *
347
+ * Examples:
348
+ * - Load db at commit
349
+ * (commit-as-db conn #uuid "...")
350
+ */
351
+ export function commitAsDb(source: Connection | Database, commit: DatahikeUuid): Promise<Database | null>;
352
+
353
+ /**
354
+ * Retrieve the commit-id for this database value..
355
+ *
356
+ * Examples:
357
+ * - Get commit id
358
+ * (commit-id @conn)
359
+ */
360
+ export function commitId(db: Database): Promise<UuidValue | null>;
361
+
362
+ /**
363
+ * Connects to a Datahike database via configuration map..
364
+ *
365
+ * Examples:
366
+ * - Connect to default in-memory database
367
+ * (connect)
368
+ * - Connect to file-based database
369
+ * (connect {:store {:backend :file :path "/tmp/example"}})
370
+ */
371
+ export function connect(config: DatabaseConfig): Promise<Connection>;
372
+ export function connect(config: DatabaseConfig, opts: ConnectOptions): Promise<Connection>;
373
+ export function connect(): Promise<Connection>;
374
+
375
+ /**
376
+ * Creates a database via configuration map..
377
+ *
378
+ * Examples:
379
+ * - Create empty database
380
+ * (create-database {:store {:backend :memory :id "example"}})
381
+ * - Create with schema-flexibility :read
382
+ * (create-database {:store {:backend :memory :id "example"} :schema-flexibility :read})
383
+ */
384
+ export function createDatabase(arg0: DatabaseConfig): Promise<DatabaseConfig>;
385
+ export function createDatabase(): Promise<DatabaseConfig>;
386
+
387
+ /**
388
+ * Checks if a database exists via configuration map..
389
+ *
390
+ * Examples:
391
+ * - Check if in-memory database exists
392
+ * (database-exists? {:store {:backend :memory :id "example"}})
393
+ * - Check with default config
394
+ * (database-exists?)
395
+ */
396
+ export function databaseExists(arg0: DatabaseConfig): Promise<boolean>;
397
+ export function databaseExists(): Promise<boolean>;
398
+
399
+ /**
400
+ * Index lookup.
401
+ *
402
+ * Examples:
403
+ * - Find all datoms for entity
404
+ * (datoms db {:index :eavt :components [1]})
405
+ * - Find datoms for entity and attribute
406
+ * (datoms db {:index :eavt :components [1 :likes]})
407
+ */
408
+ export function datoms(db: Database, indexOrOptions: ":eavt" | ":aevt" | ":avet" | IndexLookupArgs): Promise<Datom[] | null>;
409
+ export function datoms(db: Database, indexOrOptions: ":eavt" | ":aevt" | ":avet", ...components: Array<any>): Promise<Datom[] | null>;
410
+
411
+ /**
412
+ * Returns the underlying immutable database value from a connection.
413
+ *
414
+ * Examples:
415
+ * - Get database from connection
416
+ * (db conn)
417
+ * - Prefer direct deref
418
+ * @conn
419
+ */
420
+ export function db(conn: Connection): Promise<Database>;
421
+
422
+ /**
423
+ * Remove a branch.
424
+ *
425
+ * Examples:
426
+ * - Delete branch
427
+ * (delete-branch! conn :experiment)
428
+ */
429
+ export function deleteBranch(conn: Connection, branch: Keyword): Promise<unknown>;
430
+
431
+ /**
432
+ * Deletes a database given via configuration map..
433
+ *
434
+ * Examples:
435
+ * - Delete database
436
+ * (delete-database {:store {:backend :memory :id "example"}})
437
+ */
438
+ export function deleteDatabase(arg0: DatabaseConfig): Promise<any>;
439
+ export function deleteDatabase(): Promise<any>;
440
+
441
+ /**
442
+ * Retrieves an entity by its id.
443
+ *
444
+ * Examples:
445
+ * - Get entity by id
446
+ * (entity db 1)
447
+ * - Get entity by lookup ref
448
+ * (entity db [:email "alice@example.com"])
449
+ */
450
+ export function entity(db: Database, eid: number | [string, any] | string | any): Promise<any>;
451
+
452
+ /**
453
+ * Returns database that entity was created from..
454
+ *
455
+ * Examples:
456
+ * - Get entity's database
457
+ * (entity-db (entity db 1))
458
+ */
459
+ export function entityDb(arg0: any): Promise<Database>;
460
+
461
+ /**
462
+ * Invokes garbage collection on connection's store.
463
+ *
464
+ * Examples:
465
+ * - GC all old snapshots
466
+ * (gc-storage conn)
467
+ * - GC snapshots before date
468
+ * (gc-storage conn (java.util.Date.))
469
+ */
470
+ export function gcStorage(conn: Connection, removeBefore: number | Date, options: GcOptions): Promise<unknown[]>;
471
+ export function gcStorage(conn: Connection, removeBefore: number | Date): Promise<unknown[]>;
472
+ export function gcStorage(conn: Connection): Promise<unknown[]>;
473
+
474
+ /**
475
+ * Returns full historical state of database including all assertions and retractions..
476
+ *
477
+ * Examples:
478
+ * - Query historical data
479
+ * (q '[:find ?n ?a :where [?e :name ?n] [?e :age ?a]] (history @conn))
480
+ */
481
+ export function history(arg0: Database): Promise<Database>;
482
+
483
+ /**
484
+ * Returns part of :avet index between start and end values..
485
+ *
486
+ * Examples:
487
+ * - Find datoms in value range
488
+ * (index-range db {:attrid :likes :start "a" :end "z"})
489
+ * - Find entities with age in range
490
+ * (->> (index-range db {:attrid :age :start 18 :end 60}) (map :e))
491
+ */
492
+ export function indexRange(db: Database, options: IndexRangeArgs): Promise<Datom[]>;
493
+
494
+ /**
495
+ * Load entities directly (bulk load)..
496
+ *
497
+ * Examples:
498
+ * - Bulk load entities
499
+ * (load-entities conn entities)
500
+ */
501
+ export function loadEntities(arg0: Connection, arg1: Transaction[]): Promise<any>;
502
+
503
+ /**
504
+ * Create a merge commit combining the current branch with parent branches/commits.
505
+ *
506
+ * Examples:
507
+ * - Merge feature into main
508
+ * (d/merge-db conn #{:feature} [{:name "merged entity"}])
509
+ * - Merge with metadata
510
+ * (d/merge-db conn #{:feature} [{:name "merged"}] {:source :merge})
511
+ */
512
+ export function mergeDb(arg0: Connection, arg1: Array<any>, arg2: Transaction[]): Promise<TransactionReport>;
513
+ export function mergeDb(arg0: Connection, arg1: Array<any>, arg2: Transaction[], arg3: any): Promise<TransactionReport>;
514
+
515
+ /**
516
+ * Returns database metrics: datom counts overall, per attribute and for the indexed (AVET) attributes, plus the same for history when kept.
517
+ *
518
+ * Examples:
519
+ * - Get metrics
520
+ * (metrics @conn)
521
+ * - With datoms per entity (a full walk)
522
+ * (metrics @conn {:per-entity-counts? true})
523
+ */
524
+ export function metrics(arg0: Database): Promise<Metrics>;
525
+ export function metrics(arg0: Database, arg1: Record<string, any>): Promise<Metrics>;
526
+
527
+ /**
528
+ * Retrieve parent commit ids from this database value..
529
+ *
530
+ * Examples:
531
+ * - Get parent commits
532
+ * (parent-commit-ids @conn)
533
+ */
534
+ export function parentCommitIds(db: Database): Promise<UuidValue[] | null>;
535
+
536
+ /**
537
+ * Fetches data using recursive declarative pull pattern..
538
+ *
539
+ * Examples:
540
+ * - Pull with pattern
541
+ * (pull db [:db/id :name :likes {:friends [:db/id :name]}] 1)
542
+ * - Pull with arg-map
543
+ * (pull db {:selector [:db/id :name] :eid 1})
544
+ */
545
+ export function pull<T extends Record<string, any> = Record<string, any>>(db: Database, patternOrOptions: PullOptions): Promise<T | null>;
546
+ export function pull<T extends Record<string, any> = Record<string, any>>(db: Database, patternOrOptions: Array<any>, eid: number | [string, any] | string): Promise<T | null>;
547
+
548
+ /**
549
+ * Same as pull, but accepts sequence of ids and returns sequence of maps..
550
+ *
551
+ * Examples:
552
+ * - Pull multiple entities
553
+ * (pull-many db [:db/id :name] [1 2 3])
554
+ */
555
+ export function pullMany<T extends Record<string, any> = Record<string, any>>(db: Database, patternOrOptions: PullOptions): Promise<T[]>;
556
+ export function pullMany<T extends Record<string, any> = Record<string, any>>(db: Database, patternOrOptions: Array<any>, eids: Array<number | [string, any] | string>): Promise<T[]>;
557
+
558
+ /**
559
+ * Executes a datalog query..
560
+ *
561
+ * Examples:
562
+ * - Query with vector syntax
563
+ * (q '[:find ?value :where [_ :likes ?value]] db)
564
+ * - Query with map syntax
565
+ * (q '{:find [?value] :where [[_ :likes ?value]]} db)
566
+ */
567
+ export function q<T = unknown>(query: QueryArgs): Promise<T>;
568
+ export function q<T = unknown>(query: Array<any> | Record<string, any> | string, ...inputs: Array<any>): Promise<T>;
569
+
570
+ /**
571
+ * Executes query and returns execution statistics..
572
+ *
573
+ * Examples:
574
+ * - Query with stats
575
+ * (query-stats '[:find ?e :where [?e :name]] db)
576
+ */
577
+ export function queryStats(query: QueryArgs): Promise<Record<string, any>>;
578
+ export function queryStats(query: Array<any> | Record<string, any>, ...inputs: Array<any>): Promise<Record<string, any>>;
579
+
580
+ /**
581
+ * Releases a database connection..
582
+ *
583
+ * Examples:
584
+ * - Release connection
585
+ * (release conn)
586
+ */
587
+ export function release(conn: Connection): Promise<null>;
588
+ export function release(conn: Connection, releaseAll: any): Promise<null>;
589
+
590
+ /**
591
+ * Returns reverse schema definition (attribute id to ident mapping)..
592
+ *
593
+ * Examples:
594
+ * - Get reverse schema
595
+ * (reverse-schema @conn)
596
+ */
597
+ export function reverseSchema(arg0: Database): Promise<Record<string, any>>;
598
+
599
+ /**
600
+ * Like seek-datoms, but iterates BACKWARDS: datoms <= the given components, descending to the beginning of the index.
601
+ *
602
+ * Examples:
603
+ * - Latest room messages, newest first
604
+ * (take 20 (rseek-datoms db {:index :avet :components [:message/room room-eid]}))
605
+ */
606
+ export function rseekDatoms(db: Database, indexOrOptions: ":eavt" | ":aevt" | ":avet" | IndexLookupArgs): Promise<Datom[] | null>;
607
+ export function rseekDatoms(db: Database, indexOrOptions: ":eavt" | ":aevt" | ":avet", ...components: Array<any>): Promise<Datom[] | null>;
608
+
609
+ /**
610
+ * Returns current schema definition..
611
+ *
612
+ * Examples:
613
+ * - Get schema
614
+ * (schema @conn)
615
+ */
616
+ export function schema(arg0: Database): Promise<Schema>;
617
+
618
+ /**
619
+ * Like datoms, but returns datoms starting from specified components through end of index..
620
+ *
621
+ * Examples:
622
+ * - Seek from entity
623
+ * (seek-datoms db {:index :eavt :components [1]})
624
+ */
625
+ export function seekDatoms(db: Database, indexOrOptions: ":eavt" | ":aevt" | ":avet" | IndexLookupArgs): Promise<Datom[] | null>;
626
+ export function seekDatoms(db: Database, indexOrOptions: ":eavt" | ":aevt" | ":avet", ...components: Array<any>): Promise<Datom[] | null>;
627
+
628
+ /**
629
+ * Returns database state since given time point (Date or transaction ID).
630
+ *
631
+ * Examples:
632
+ * - Query since date
633
+ * (since @conn (java.util.Date.))
634
+ * - Query since transaction
635
+ * (since @conn 536870913)
636
+ */
637
+ export function since(arg0: Database, arg1: number | Date): Promise<Database>;
638
+
639
+ /**
640
+ * Applies transaction to the database and updates connection.
641
+ *
642
+ * Examples:
643
+ * - Add single datom
644
+ * (transact conn [[:db/add 1 :name "Ivan"]])
645
+ * - Retract datom
646
+ * (transact conn [[:db/retract 1 :name "Ivan"]])
647
+ */
648
+ export function transact(arg0: Connection, arg1: Transaction[] | WithArgs): Promise<TransactionReport>;
649
+
650
+ /**
651
+ * Strip any valid-time markers from `db` so the full vt-history is
652
+ visible.
653
+ *
654
+ * Examples:
655
+ * - Drop vt-marker for full-history query
656
+ * (q '[:find ?n :where [_ :name ?n]] (valid-all @conn))
657
+ */
658
+ export function validAll(arg0: Database): Promise<Database>;
659
+
660
+ /**
661
+ * Tag `db` with a `:datahike/valid-at` marker so vt-aware secondary
662
+ indices push the filter through `-search-at-vt`.
663
+ *
664
+ * Examples:
665
+ * - Query as of valid-time
666
+ * (q '[:find ?n :where [_ :name ?n]] (valid-at @conn #inst "2024-04-15"))
667
+ */
668
+ export function validAt(arg0: Database, arg1: any): Promise<Database>;
669
+
670
+ /**
671
+ * Filter `db` to datoms whose asserting tx's vt-window overlaps the
672
+ half-open interval `[from, to)`.
673
+ *
674
+ * Examples:
675
+ * - Datoms whose tx vt-window overlaps Q2 2024
676
+ * (q '[:find ?n :where [_ :name ?n]] (valid-between @conn #inst "2024-04-01" #inst "2024-07-01"))
677
+ */
678
+ export function validBetween(arg0: Database, arg1: any, arg2: any): Promise<Database>;
679
+
680
+ /**
681
+ * Filter `db` to datoms whose tx's vt-window is *fully contained*
682
+ in `[from, to)`.
683
+ *
684
+ * Examples:
685
+ * - Corrections whose vt-window was wholly inside Q2
686
+ * (q '[:find ?e :where [?e :name _]] (valid-during @conn #inst "2024-04-01" #inst "2024-07-01"))
687
+ */
688
+ export function validDuring(arg0: Database, arg1: any, arg2: any): Promise<Database>;
689
+
690
+ export interface RemoteReport {
691
+ 'db-after'?: Database;
692
+ 'db-before'?: null;
693
+ 'tx-data'?: Datom[];
694
+ tempids?: { [key: string]: number };
695
+ 'commit-id'?: UuidValue;
696
+ resync?: boolean;
697
+ deleted?: boolean;
698
+ truncated?: boolean;
699
+ error?: any;
700
+ status?: number;
701
+ }
702
+
703
+ export function listen(conn: Connection, callback: (report: RemoteReport) => void): string;
704
+ export function unlisten(conn: Connection, key: string): void;
705
+
706
+ // JavaScript-specific value helpers.
707
+ export function isPromise(value: any): value is Promise<unknown>;
708
+ export function uuid(value: string): DatahikeUuid;
709
+ export function randomUuid(): DatahikeUuid;
@@ -1,2 +1,2 @@
1
1
  var window=global;var $CLJS=require("./cljs_env.js");require("./cljs.core.js");require("./taoensso.trove.js");
2
- 'use strict';$CLJS.yp=new $CLJS.H(null,"ref","ref",1289896967);$CLJS.zp=new $CLJS.H(null,"conn","conn",278309663);$CLJS.Ap=new $CLJS.H(null,"warn","warn",-436710552);
2
+ 'use strict';$CLJS.Cp=new $CLJS.H(null,"ref","ref",1289896967);$CLJS.Dp=new $CLJS.H(null,"conn","conn",278309663);$CLJS.Ep=new $CLJS.H(null,"warn","warn",-436710552);$CLJS.Fp=new $CLJS.H(null,"eavt","eavt",-666437073);