@anysoftinc/anydb-sdk 0.1.1
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/README.md +336 -0
- package/dist/client.d.ts +167 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +397 -0
- package/dist/nextauth-adapter.d.ts +23 -0
- package/dist/nextauth-adapter.d.ts.map +1 -0
- package/dist/nextauth-adapter.js +340 -0
- package/dist/query-builder.d.ts +126 -0
- package/dist/query-builder.d.ts.map +1 -0
- package/dist/query-builder.js +207 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
# AnyDB TypeScript SDK
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for querying and transacting with Datomic databases via the AnyDB server.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @anysoftinc/anydb-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { DatomicClient, createDatomicDatabase } from '@anysoftinc/anydb-sdk';
|
|
15
|
+
|
|
16
|
+
// Create a client
|
|
17
|
+
const client = new DatomicClient({
|
|
18
|
+
baseUrl: 'http://localhost:4000'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Create a database wrapper for convenience
|
|
22
|
+
const db = createDatomicDatabase(client, 'storage-alias', 'db-name');
|
|
23
|
+
|
|
24
|
+
// Query the database
|
|
25
|
+
const results = await db.query([
|
|
26
|
+
':find', '?e', '?name',
|
|
27
|
+
':where', ['?e', ':db/ident', '?name']
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
// Execute a transaction
|
|
31
|
+
const txResult = await db.transact([
|
|
32
|
+
{
|
|
33
|
+
'db/id': 'tempid',
|
|
34
|
+
':person/name': 'John Doe',
|
|
35
|
+
':person/email': 'john@example.com'
|
|
36
|
+
}
|
|
37
|
+
]);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Core Features
|
|
41
|
+
|
|
42
|
+
### Database Operations
|
|
43
|
+
- **Database Management** - Create, list, and delete databases
|
|
44
|
+
- **Transactions** - Execute database transactions
|
|
45
|
+
- **Queries** - Execute Datalog queries with full EDN support
|
|
46
|
+
- **Entity Lookup** - Retrieve individual entities
|
|
47
|
+
- **Datom Access** - Raw datom queries with indexing
|
|
48
|
+
|
|
49
|
+
### Query Types
|
|
50
|
+
|
|
51
|
+
#### Traditional Array-based Queries
|
|
52
|
+
```typescript
|
|
53
|
+
const query = [
|
|
54
|
+
':find', '?e', '?name',
|
|
55
|
+
':where', ['?e', ':person/name', '?name']
|
|
56
|
+
];
|
|
57
|
+
const results = await db.query(query);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### Symbolic Queries (Type-safe)
|
|
61
|
+
```typescript
|
|
62
|
+
import { sym, kw } from '@anysoftinc/anydb-sdk';
|
|
63
|
+
|
|
64
|
+
const query = {
|
|
65
|
+
find: [sym('?e'), sym('?name')],
|
|
66
|
+
where: [
|
|
67
|
+
[sym('?e'), kw(':person/name'), sym('?name')]
|
|
68
|
+
]
|
|
69
|
+
};
|
|
70
|
+
const results = await db.querySymbolic(query);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### Enhanced Query Builder
|
|
74
|
+
|
|
75
|
+
The QueryBuilder provides a type-safe, fluent API for constructing Datalog queries:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { QueryBuilder, kw } from '@anysoftinc/anydb-sdk';
|
|
79
|
+
|
|
80
|
+
// Basic entity-attribute-value query
|
|
81
|
+
const basicQuery = new QueryBuilder()
|
|
82
|
+
.find('?e', '?name')
|
|
83
|
+
.where({ entity: '?e', attribute: kw(':person/name'), value: '?name' })
|
|
84
|
+
.build();
|
|
85
|
+
|
|
86
|
+
// Fluent entity-based building
|
|
87
|
+
const fluentQuery = new QueryBuilder()
|
|
88
|
+
.find('?e', '?name')
|
|
89
|
+
.entity('?e').hasAttribute(kw(':person/name')).withValue('?name')
|
|
90
|
+
.build();
|
|
91
|
+
|
|
92
|
+
// Helper methods for common patterns
|
|
93
|
+
const entitiesWithName = new QueryBuilder()
|
|
94
|
+
.findEntitiesWith(kw(':person/name'))
|
|
95
|
+
.build();
|
|
96
|
+
|
|
97
|
+
// Aggregation queries
|
|
98
|
+
const personCount = new QueryBuilder()
|
|
99
|
+
.count('?e')
|
|
100
|
+
.where({ entity: '?e', attribute: kw(':person/name'), value: '?name' })
|
|
101
|
+
.build();
|
|
102
|
+
|
|
103
|
+
// Multiple aggregations
|
|
104
|
+
const stats = new QueryBuilder()
|
|
105
|
+
.count('?e')
|
|
106
|
+
.avg('?age')
|
|
107
|
+
.where({ entity: '?e', attribute: kw(':person/name'), value: '?name' })
|
|
108
|
+
.where({ entity: '?e', attribute: kw(':person/age'), value: '?age' })
|
|
109
|
+
.build();
|
|
110
|
+
|
|
111
|
+
// Input parameters and with clauses
|
|
112
|
+
const parameterizedQuery = new QueryBuilder()
|
|
113
|
+
.find('?e')
|
|
114
|
+
.in('$', '?minAge')
|
|
115
|
+
.with('?tx')
|
|
116
|
+
.where({ entity: '?e', attribute: kw(':person/age'), value: '?age' })
|
|
117
|
+
.build();
|
|
118
|
+
|
|
119
|
+
// Direct execution
|
|
120
|
+
const results = await new QueryBuilder()
|
|
121
|
+
.find('?e', '?name')
|
|
122
|
+
.entity('?e').hasAttribute(kw(':person/name')).withValue('?name')
|
|
123
|
+
.execute(db);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**QueryBuilder Benefits:**
|
|
127
|
+
- **Type Safety**: All attributes use proper `Keyword` objects with `kw()`
|
|
128
|
+
- **IntelliSense**: Full autocomplete for methods and parameters
|
|
129
|
+
- **Structured Queries**: No string concatenation or EDN parsing errors
|
|
130
|
+
- **Fluent API**: Chain methods for readable query construction
|
|
131
|
+
- **Aggregations**: Built-in support for count, sum, avg, min, max
|
|
132
|
+
- **Direct Execution**: Execute queries directly from the builder
|
|
133
|
+
|
|
134
|
+
### Temporal Queries
|
|
135
|
+
```typescript
|
|
136
|
+
// As-of queries
|
|
137
|
+
const pastResults = await client.query(query, [{
|
|
138
|
+
'db/alias': 'storage/db',
|
|
139
|
+
'as-of': 1000
|
|
140
|
+
}]);
|
|
141
|
+
|
|
142
|
+
// Since queries
|
|
143
|
+
const recentResults = await client.query(query, [{
|
|
144
|
+
'db/alias': 'storage/db',
|
|
145
|
+
since: 1000
|
|
146
|
+
}]);
|
|
147
|
+
|
|
148
|
+
// History queries
|
|
149
|
+
const allHistory = await client.query(query, [{
|
|
150
|
+
'db/alias': 'storage/db',
|
|
151
|
+
history: true
|
|
152
|
+
}]);
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Schema Definition
|
|
156
|
+
```typescript
|
|
157
|
+
import { SchemaBuilder, DatomicUtils } from '@anysoftinc/anydb-sdk';
|
|
158
|
+
|
|
159
|
+
// Define attributes
|
|
160
|
+
const personNameAttr = SchemaBuilder.attribute({
|
|
161
|
+
':db/ident': ':person/name',
|
|
162
|
+
':db/valueType': ':db.type/string',
|
|
163
|
+
':db/cardinality': ':db.cardinality/one',
|
|
164
|
+
':db/index': true,
|
|
165
|
+
':db/doc': 'Person name'
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Define enums
|
|
169
|
+
const genderEnum = SchemaBuilder.enum(':person.gender/male');
|
|
170
|
+
|
|
171
|
+
// Install schema
|
|
172
|
+
await db.transact([personNameAttr, genderEnum]);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Utility Functions
|
|
176
|
+
```typescript
|
|
177
|
+
import { DatomicUtils } from '@anysoftinc/anydb-sdk';
|
|
178
|
+
|
|
179
|
+
// Generate temp IDs
|
|
180
|
+
const tempId = DatomicUtils.tempId();
|
|
181
|
+
|
|
182
|
+
// Create entities
|
|
183
|
+
const personEntity = DatomicUtils.createEntity({
|
|
184
|
+
':person/name': 'Jane Doe',
|
|
185
|
+
':person/email': 'jane@example.com'
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// Retract data
|
|
189
|
+
const retraction = DatomicUtils.retractEntity(12345);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Advanced Features
|
|
193
|
+
|
|
194
|
+
### EDN Data Types
|
|
195
|
+
The SDK provides full support for Datomic's EDN data types:
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
import { sym, kw, uuid } from '@anysoftinc/anydb-sdk';
|
|
199
|
+
|
|
200
|
+
// Symbols for query variables
|
|
201
|
+
const entityVar = sym('?e');
|
|
202
|
+
|
|
203
|
+
// Keywords for attributes
|
|
204
|
+
const nameAttr = kw(':person/name');
|
|
205
|
+
|
|
206
|
+
// UUIDs
|
|
207
|
+
const entityId = uuid('550e8400-e29b-41d4-a716-446655440000');
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Event Streaming
|
|
211
|
+
Subscribe to transaction reports via Server-Sent Events:
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
const eventSource = db.subscribeToEvents(
|
|
215
|
+
(event) => {
|
|
216
|
+
const txData = JSON.parse(event.data);
|
|
217
|
+
console.log('Transaction:', txData);
|
|
218
|
+
},
|
|
219
|
+
(error) => {
|
|
220
|
+
console.error('Connection error:', error);
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
// Close the connection when done
|
|
225
|
+
eventSource.close();
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Raw Datom Queries
|
|
229
|
+
Access the raw datom index for high-performance queries:
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
// Query EAVT index
|
|
233
|
+
const datoms = await db.datoms('eavt', '-', {
|
|
234
|
+
e: 12345,
|
|
235
|
+
limit: 100
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// Query AVET index for attribute values
|
|
239
|
+
const attributeValues = await db.datoms('avet', '-', {
|
|
240
|
+
a: ':person/name',
|
|
241
|
+
start: 'A',
|
|
242
|
+
end: 'B'
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Custom HTTP Configuration
|
|
247
|
+
```typescript
|
|
248
|
+
const client = new DatomicClient({
|
|
249
|
+
baseUrl: 'https://api.example.com',
|
|
250
|
+
timeout: 30000,
|
|
251
|
+
headers: {
|
|
252
|
+
'Authorization': 'Bearer token',
|
|
253
|
+
'X-Custom-Header': 'value'
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### NextAuth.js Integration
|
|
259
|
+
The SDK includes a NextAuth.js adapter for authentication:
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
import { AnyDBAdapter } from '@anysoftinc/anydb-sdk/nextauth-adapter';
|
|
263
|
+
import NextAuth from 'next-auth';
|
|
264
|
+
|
|
265
|
+
export default NextAuth({
|
|
266
|
+
adapter: AnyDBAdapter(db),
|
|
267
|
+
providers: [
|
|
268
|
+
// Your providers
|
|
269
|
+
],
|
|
270
|
+
});
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Error Handling
|
|
274
|
+
|
|
275
|
+
The SDK provides detailed error information:
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
try {
|
|
279
|
+
const results = await db.query(invalidQuery);
|
|
280
|
+
} catch (error) {
|
|
281
|
+
if (error.message.includes('Datomic API error')) {
|
|
282
|
+
console.error('Server error:', error.message);
|
|
283
|
+
} else {
|
|
284
|
+
console.error('Client error:', error);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## TypeScript Support
|
|
290
|
+
|
|
291
|
+
Full TypeScript definitions are included:
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
import type {
|
|
295
|
+
QueryResult,
|
|
296
|
+
Transaction,
|
|
297
|
+
Entity,
|
|
298
|
+
Datom,
|
|
299
|
+
DatabaseDescriptor
|
|
300
|
+
} from '@anysoftinc/anydb-sdk';
|
|
301
|
+
|
|
302
|
+
const processResults = (results: QueryResult): void => {
|
|
303
|
+
results.forEach(row => {
|
|
304
|
+
console.log('Row:', row);
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Examples
|
|
310
|
+
|
|
311
|
+
See the [examples directory](./examples/) for complete working examples:
|
|
312
|
+
|
|
313
|
+
- **[Console Example](./examples/console/)** - Web-based query interface with Monaco Editor
|
|
314
|
+
- **[NextAuth.js Example](./examples/nextauth-example.md)** - Authentication adapter for NextAuth.js
|
|
315
|
+
|
|
316
|
+
## API Reference
|
|
317
|
+
|
|
318
|
+
### DatomicClient
|
|
319
|
+
The main client class for interacting with the AnyDB server.
|
|
320
|
+
|
|
321
|
+
### DatomicDatabase
|
|
322
|
+
Convenience wrapper for working with a specific database.
|
|
323
|
+
|
|
324
|
+
### DatomicUtils
|
|
325
|
+
Static utility methods for common Datomic operations.
|
|
326
|
+
|
|
327
|
+
### SchemaBuilder
|
|
328
|
+
Helper for building schema definitions.
|
|
329
|
+
|
|
330
|
+
### QueryBuilder
|
|
331
|
+
Fluent API for constructing queries programmatically.
|
|
332
|
+
|
|
333
|
+
## Related
|
|
334
|
+
|
|
335
|
+
- [AnyDB Server](../../..) - Backend Clojure implementation
|
|
336
|
+
- [Datomic Documentation](https://docs.datomic.com/) - Official Datomic docs
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export interface Symbol {
|
|
2
|
+
_type: 'symbol';
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
export interface UUID {
|
|
6
|
+
_type: 'uuid';
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Keyword {
|
|
10
|
+
_type: 'keyword';
|
|
11
|
+
value: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const sym: (name: string) => Symbol;
|
|
14
|
+
export declare const uuid: (id: string) => UUID;
|
|
15
|
+
export declare const kw: (name: string) => Keyword;
|
|
16
|
+
export type QueryValue = Symbol | UUID | Keyword | string | number | boolean | Date | null;
|
|
17
|
+
export type QueryClause = QueryValue[];
|
|
18
|
+
export interface SymbolicQuery {
|
|
19
|
+
find: QueryValue[];
|
|
20
|
+
where: QueryClause[];
|
|
21
|
+
in?: QueryValue[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Enhanced EDN stringifier with support for symbolic types
|
|
25
|
+
*/
|
|
26
|
+
export declare function stringifyEdn(obj: unknown): string;
|
|
27
|
+
export type EntityId = number | string;
|
|
28
|
+
export type KeywordString = string;
|
|
29
|
+
export type Instant = Date | string;
|
|
30
|
+
export type BasisT = number | "-";
|
|
31
|
+
export interface Datom {
|
|
32
|
+
e: EntityId;
|
|
33
|
+
a: KeywordString;
|
|
34
|
+
v: any;
|
|
35
|
+
tx: EntityId;
|
|
36
|
+
added: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface Entity {
|
|
39
|
+
[attribute: string]: any;
|
|
40
|
+
"db/id": EntityId;
|
|
41
|
+
}
|
|
42
|
+
export interface Transaction {
|
|
43
|
+
"db-before": DatabaseInfo;
|
|
44
|
+
"db-after": DatabaseInfo;
|
|
45
|
+
"tx-data": Datom[];
|
|
46
|
+
tempids: Record<string, EntityId>;
|
|
47
|
+
}
|
|
48
|
+
export interface DatabaseInfo {
|
|
49
|
+
"basis-t": number;
|
|
50
|
+
"db/alias": string;
|
|
51
|
+
}
|
|
52
|
+
export type QueryInput = any[];
|
|
53
|
+
export type QueryResult = any[][];
|
|
54
|
+
export interface DatabaseDescriptor {
|
|
55
|
+
"db/alias": string;
|
|
56
|
+
"basis-t"?: BasisT;
|
|
57
|
+
"as-of"?: number;
|
|
58
|
+
since?: number;
|
|
59
|
+
history?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface DatomicConfig {
|
|
62
|
+
baseUrl: string;
|
|
63
|
+
timeout?: number;
|
|
64
|
+
headers?: Record<string, string>;
|
|
65
|
+
}
|
|
66
|
+
export declare class DatomicClient {
|
|
67
|
+
private config;
|
|
68
|
+
private baseUrl;
|
|
69
|
+
constructor(config: DatomicConfig);
|
|
70
|
+
private normalizeEdn;
|
|
71
|
+
private request;
|
|
72
|
+
listDatabases(storageAlias: string): Promise<string[]>;
|
|
73
|
+
createDatabase(storageAlias: string, dbName: string): Promise<{
|
|
74
|
+
"db-created": string;
|
|
75
|
+
}>;
|
|
76
|
+
deleteDatabase(storageAlias: string, dbName: string): Promise<{
|
|
77
|
+
"db-deleted": string;
|
|
78
|
+
}>;
|
|
79
|
+
transact(storageAlias: string, dbName: string, txData: any[]): Promise<Transaction>;
|
|
80
|
+
databaseInfo(storageAlias: string, dbName: string, basisT?: BasisT): Promise<DatabaseInfo>;
|
|
81
|
+
datoms(storageAlias: string, dbName: string, basisT: BasisT, options: {
|
|
82
|
+
index: "eavt" | "aevt" | "avet" | "vaet";
|
|
83
|
+
e?: EntityId;
|
|
84
|
+
a?: KeywordString;
|
|
85
|
+
v?: any;
|
|
86
|
+
start?: any;
|
|
87
|
+
end?: any;
|
|
88
|
+
limit?: number;
|
|
89
|
+
offset?: number;
|
|
90
|
+
"as-of"?: number;
|
|
91
|
+
since?: number;
|
|
92
|
+
history?: boolean;
|
|
93
|
+
}): Promise<Datom[]>;
|
|
94
|
+
entity(storageAlias: string, dbName: string, basisT: BasisT, entityId: EntityId, options?: {
|
|
95
|
+
"as-of"?: number;
|
|
96
|
+
since?: number;
|
|
97
|
+
}): Promise<Entity>;
|
|
98
|
+
queryGet(query: QueryInput, args: DatabaseDescriptor[], options?: {
|
|
99
|
+
limit?: number;
|
|
100
|
+
offset?: number;
|
|
101
|
+
}): Promise<QueryResult>;
|
|
102
|
+
query(query: QueryInput, args: any[], options?: {
|
|
103
|
+
limit?: number;
|
|
104
|
+
offset?: number;
|
|
105
|
+
}): Promise<QueryResult>;
|
|
106
|
+
querySymbolic(query: SymbolicQuery, args?: any[], options?: {
|
|
107
|
+
limit?: number;
|
|
108
|
+
offset?: number;
|
|
109
|
+
}): Promise<QueryResult>;
|
|
110
|
+
subscribeToEvents(storageAlias: string, dbName: string, onEvent: (event: MessageEvent) => void, onError?: (error: Event) => void): EventSource;
|
|
111
|
+
}
|
|
112
|
+
export declare class DatomicUtils {
|
|
113
|
+
static tempId(partition?: string): string;
|
|
114
|
+
static keyword(namespace: string, name: string): KeywordString;
|
|
115
|
+
static createEntity(attributes: Record<string, any>, tempId?: string): any[];
|
|
116
|
+
static retractEntity(entityId: EntityId): any[];
|
|
117
|
+
static retractAttribute(entityId: EntityId, attribute: KeywordString, value?: any): any[];
|
|
118
|
+
static addAttribute(entityId: EntityId, attribute: KeywordString, value: any): any[];
|
|
119
|
+
}
|
|
120
|
+
export interface AttributeDefinition {
|
|
121
|
+
":db/ident": KeywordString;
|
|
122
|
+
":db/valueType": KeywordString;
|
|
123
|
+
":db/cardinality": ":db.cardinality/one" | ":db.cardinality/many";
|
|
124
|
+
":db/unique"?: ":db.unique/value" | ":db.unique/identity";
|
|
125
|
+
":db/index"?: boolean;
|
|
126
|
+
":db/fulltext"?: boolean;
|
|
127
|
+
":db/isComponent"?: boolean;
|
|
128
|
+
":db/noHistory"?: boolean;
|
|
129
|
+
":db/doc"?: string;
|
|
130
|
+
}
|
|
131
|
+
export declare class SchemaBuilder {
|
|
132
|
+
static attribute(def: AttributeDefinition): any;
|
|
133
|
+
static enum(ident: KeywordString, doc?: string): any;
|
|
134
|
+
}
|
|
135
|
+
export declare function edn(strings: TemplateStringsArray, ...values: any[]): QueryInput;
|
|
136
|
+
export declare class DatomicDatabase {
|
|
137
|
+
private client;
|
|
138
|
+
private storageAlias;
|
|
139
|
+
private dbName;
|
|
140
|
+
constructor(client: DatomicClient, storageAlias: string, dbName: string);
|
|
141
|
+
transact(txData: any[]): Promise<Transaction>;
|
|
142
|
+
info(basisT?: BasisT): Promise<DatabaseInfo>;
|
|
143
|
+
datoms(index: "eavt" | "aevt" | "avet" | "vaet", basisT?: BasisT, options?: {
|
|
144
|
+
e?: EntityId;
|
|
145
|
+
a?: KeywordString;
|
|
146
|
+
v?: any;
|
|
147
|
+
start?: any;
|
|
148
|
+
end?: any;
|
|
149
|
+
limit?: number;
|
|
150
|
+
offset?: number;
|
|
151
|
+
"as-of"?: number;
|
|
152
|
+
since?: number;
|
|
153
|
+
history?: boolean;
|
|
154
|
+
}): Promise<Datom[]>;
|
|
155
|
+
entity(entityId: EntityId, basisT?: BasisT, options?: {
|
|
156
|
+
"as-of"?: number;
|
|
157
|
+
since?: number;
|
|
158
|
+
}): Promise<Entity>;
|
|
159
|
+
query(query: QueryInput, ...args: any[]): Promise<QueryResult>;
|
|
160
|
+
querySymbolic(query: SymbolicQuery, ...args: any[]): Promise<QueryResult>;
|
|
161
|
+
subscribeToEvents(onEvent: (event: MessageEvent) => void, onError?: (error: Event) => void): EventSource;
|
|
162
|
+
}
|
|
163
|
+
export declare function createDatomicClient(config: DatomicConfig): DatomicClient;
|
|
164
|
+
export declare function createDatomicDatabase(client: DatomicClient, storageAlias: string, dbName: string): DatomicDatabase;
|
|
165
|
+
export declare function pluckFirstColumn(rows: any[][]): any[];
|
|
166
|
+
export default DatomicClient;
|
|
167
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,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,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