@anysoftinc/anydb-sdk 0.6.0 → 0.7.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/dist/client.d.ts +63 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +83 -6
- package/dist/nextauth-adapter.js +1 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -20,6 +20,27 @@ export interface SymbolicQuery {
|
|
|
20
20
|
where: QueryClause[];
|
|
21
21
|
in?: QueryValue[];
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Temporal query options following Datomic REST API.
|
|
25
|
+
* These options control which point-in-time view of the database to query.
|
|
26
|
+
*/
|
|
27
|
+
export interface TemporalOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Query the database as of a specific transaction time (t value).
|
|
30
|
+
* Returns the database as it existed at that point in time.
|
|
31
|
+
*/
|
|
32
|
+
"as-of"?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Query only facts added since a specific transaction time (t value).
|
|
35
|
+
* Returns only datoms that were added after that point in time.
|
|
36
|
+
*/
|
|
37
|
+
since?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Query the entire history of the database.
|
|
40
|
+
* When true, returns all historical facts including retractions.
|
|
41
|
+
*/
|
|
42
|
+
history?: boolean;
|
|
43
|
+
}
|
|
23
44
|
export type EntityId = number | string;
|
|
24
45
|
export type BasisT = number | "-";
|
|
25
46
|
export interface Datom {
|
|
@@ -95,11 +116,52 @@ export declare class AnyDBClient {
|
|
|
95
116
|
getStorageAlias(): string;
|
|
96
117
|
info(): Promise<DatabaseInfo>;
|
|
97
118
|
transact(txData: any[]): Promise<Transaction>;
|
|
98
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Execute a query against the database with optional temporal options.
|
|
121
|
+
*
|
|
122
|
+
* @param q - The symbolic query to execute
|
|
123
|
+
* @param options - Optional temporal options (as-of, since, history) or additional query args
|
|
124
|
+
* @param args - Additional arguments to pass to the query
|
|
125
|
+
* @returns Query results as an array of tuples
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* // Query current state
|
|
129
|
+
* const results = await db.query({ find: [sym('?e')], where: [[sym('?e'), kw('person/name'), sym('?name')]] });
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* // Query as of a specific transaction time
|
|
133
|
+
* const results = await db.query(
|
|
134
|
+
* { find: [sym('?e')], where: [[sym('?e'), kw('person/name'), sym('?name')]] },
|
|
135
|
+
* { "as-of": 1000 }
|
|
136
|
+
* );
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* // Query entire history
|
|
140
|
+
* const results = await db.query(
|
|
141
|
+
* { find: [sym('?e'), sym('?name')], where: [[sym('?e'), kw('person/name'), sym('?name')]] },
|
|
142
|
+
* { history: true }
|
|
143
|
+
* );
|
|
144
|
+
*/
|
|
145
|
+
query(q: SymbolicQuery, options?: TemporalOptions | any, ...args: any[]): Promise<QueryResult>;
|
|
146
|
+
/**
|
|
147
|
+
* Retrieve an entity by ID with all its attributes.
|
|
148
|
+
*
|
|
149
|
+
* @param entityId - The entity ID to retrieve
|
|
150
|
+
* @param basisT - The basis-t value (currently unused, kept for API compatibility)
|
|
151
|
+
* @param options - Optional temporal options (as-of, since)
|
|
152
|
+
* @returns The entity with all its attributes
|
|
153
|
+
*/
|
|
99
154
|
entity(entityId: EntityId, basisT?: BasisT, options?: {
|
|
100
155
|
"as-of"?: number;
|
|
101
156
|
since?: number;
|
|
102
157
|
}): Promise<Entity>;
|
|
158
|
+
/**
|
|
159
|
+
* Retrieve datoms from an index with optional temporal options.
|
|
160
|
+
*
|
|
161
|
+
* @param index - The index to use (eavt, aevt, avet, vaet)
|
|
162
|
+
* @param options - Options including entity/attribute/value filters and temporal options
|
|
163
|
+
* @returns Array of datoms matching the criteria
|
|
164
|
+
*/
|
|
103
165
|
datoms(index: "eavt" | "aevt" | "avet" | "vaet", options?: {
|
|
104
166
|
e?: EntityId;
|
|
105
167
|
a?: string;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,QAAQ,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,GAAG,GAAI,MAAM,MAAM,KAAG,MAA4C,CAAC;AAChF,eAAO,MAAM,IAAI,GAAI,IAAI,MAAM,KAAG,IAAsC,CAAC;AACzE,eAAO,MAAM,EAAE,GAAI,MAAM,MAAM,KAAG,OAajC,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,GAAG,EAAE,CAAC;AACV,MAAM,MAAM,WAAW,GAAG,UAAU,EAAE,CAAC;AAEvC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC;CACnB;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AACvC,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;AAElC,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,QAAQ,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,GAAG,CAAC;IACP,EAAE,EAAE,QAAQ,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,MAAM;IACrB,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AE,GAAG,CAAC,CAAC,EAAO,GACzC,WAAW,CAEb;AAGD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,CAGrD;AAED,eAAe,aAAa,CAAC"}
|
package/dist/client.js
CHANGED
|
@@ -317,24 +317,93 @@ export class AnyDBClient {
|
|
|
317
317
|
await this.ensureInitialized();
|
|
318
318
|
return this.client.transact(this.storageAlias, this.dbName, txData);
|
|
319
319
|
}
|
|
320
|
-
|
|
320
|
+
/**
|
|
321
|
+
* Execute a query against the database with optional temporal options.
|
|
322
|
+
*
|
|
323
|
+
* @param q - The symbolic query to execute
|
|
324
|
+
* @param options - Optional temporal options (as-of, since, history) or additional query args
|
|
325
|
+
* @param args - Additional arguments to pass to the query
|
|
326
|
+
* @returns Query results as an array of tuples
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* // Query current state
|
|
330
|
+
* const results = await db.query({ find: [sym('?e')], where: [[sym('?e'), kw('person/name'), sym('?name')]] });
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* // Query as of a specific transaction time
|
|
334
|
+
* const results = await db.query(
|
|
335
|
+
* { find: [sym('?e')], where: [[sym('?e'), kw('person/name'), sym('?name')]] },
|
|
336
|
+
* { "as-of": 1000 }
|
|
337
|
+
* );
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* // Query entire history
|
|
341
|
+
* const results = await db.query(
|
|
342
|
+
* { find: [sym('?e'), sym('?name')], where: [[sym('?e'), kw('person/name'), sym('?name')]] },
|
|
343
|
+
* { history: true }
|
|
344
|
+
* );
|
|
345
|
+
*/
|
|
346
|
+
async query(q, options, ...args) {
|
|
321
347
|
await this.ensureInitialized();
|
|
322
348
|
// Server path: use /api/query with db descriptor as first arg
|
|
349
|
+
// Following Datomic REST API, temporal options are included in the db descriptor
|
|
323
350
|
const dbDescriptor = {
|
|
324
351
|
"db/alias": `${this.storageAlias}/${this.dbName}`,
|
|
325
352
|
};
|
|
326
|
-
|
|
353
|
+
// Check if options is a TemporalOptions object (has as-of, since, or history keys)
|
|
354
|
+
const isTemporalOptions = options && typeof options === 'object' &&
|
|
355
|
+
('as-of' in options || 'since' in options || 'history' in options);
|
|
356
|
+
if (isTemporalOptions) {
|
|
357
|
+
const temporalOpts = options;
|
|
358
|
+
if (temporalOpts["as-of"] !== undefined) {
|
|
359
|
+
dbDescriptor["as-of"] = temporalOpts["as-of"];
|
|
360
|
+
}
|
|
361
|
+
if (temporalOpts.since !== undefined) {
|
|
362
|
+
dbDescriptor["since"] = temporalOpts.since;
|
|
363
|
+
}
|
|
364
|
+
if (temporalOpts.history !== undefined) {
|
|
365
|
+
dbDescriptor["history"] = temporalOpts.history;
|
|
366
|
+
}
|
|
367
|
+
return this.client.querySymbolic(q, [dbDescriptor, ...args]);
|
|
368
|
+
}
|
|
369
|
+
else if (options !== undefined) {
|
|
370
|
+
// options is actually a query arg, not temporal options
|
|
371
|
+
return this.client.querySymbolic(q, [dbDescriptor, options, ...args]);
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
return this.client.querySymbolic(q, [dbDescriptor, ...args]);
|
|
375
|
+
}
|
|
327
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* Retrieve an entity by ID with all its attributes.
|
|
379
|
+
*
|
|
380
|
+
* @param entityId - The entity ID to retrieve
|
|
381
|
+
* @param basisT - The basis-t value (currently unused, kept for API compatibility)
|
|
382
|
+
* @param options - Optional temporal options (as-of, since)
|
|
383
|
+
* @returns The entity with all its attributes
|
|
384
|
+
*/
|
|
328
385
|
async entity(entityId, basisT = "-", options) {
|
|
329
|
-
// Use the query API to retrieve entity via pull
|
|
386
|
+
// Use the query API to retrieve entity via pull with wildcard to get all attributes
|
|
330
387
|
const q = {
|
|
331
|
-
find: [[sym("pull"), sym("?e"), [
|
|
388
|
+
find: [[sym("pull"), sym("?e"), [sym("*")]]],
|
|
332
389
|
where: [[sym("?e"), kw("db/id"), entityId]],
|
|
333
390
|
};
|
|
334
|
-
|
|
391
|
+
// Pass temporal options to query if provided
|
|
392
|
+
const temporalOpts = options ? {
|
|
393
|
+
"as-of": options["as-of"],
|
|
394
|
+
since: options.since,
|
|
395
|
+
} : undefined;
|
|
396
|
+
const rows = await this.query(q, temporalOpts);
|
|
335
397
|
const first = Array.isArray(rows) ? rows[0]?.[0] : null;
|
|
336
398
|
return first || { "db/id": entityId };
|
|
337
399
|
}
|
|
400
|
+
/**
|
|
401
|
+
* Retrieve datoms from an index with optional temporal options.
|
|
402
|
+
*
|
|
403
|
+
* @param index - The index to use (eavt, aevt, avet, vaet)
|
|
404
|
+
* @param options - Options including entity/attribute/value filters and temporal options
|
|
405
|
+
* @returns Array of datoms matching the criteria
|
|
406
|
+
*/
|
|
338
407
|
async datoms(index, options = {}) {
|
|
339
408
|
// Server exposes datoms via query; implement minimal AVET example
|
|
340
409
|
const clauses = [];
|
|
@@ -343,7 +412,15 @@ export class AnyDBClient {
|
|
|
343
412
|
const v = options.v !== undefined ? options.v : sym("?v");
|
|
344
413
|
clauses.push([e, a, v]);
|
|
345
414
|
const q = { find: [e, a, v], where: clauses };
|
|
346
|
-
|
|
415
|
+
// Build temporal options from the options parameter
|
|
416
|
+
const temporalOpts = (options["as-of"] !== undefined || options.since !== undefined || options.history !== undefined)
|
|
417
|
+
? {
|
|
418
|
+
"as-of": options["as-of"],
|
|
419
|
+
since: options.since,
|
|
420
|
+
history: options.history,
|
|
421
|
+
}
|
|
422
|
+
: undefined;
|
|
423
|
+
const rows = await this.query(q, temporalOpts);
|
|
347
424
|
return rows.map((r) => ({ e: r[0], a: r[1], v: r[2], tx: 0, added: true }));
|
|
348
425
|
}
|
|
349
426
|
subscribeToEvents(onEvent, onError) {
|
package/dist/nextauth-adapter.js
CHANGED