@blitznocode/blitz-orm 0.8.2 → 0.8.3
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/index.d.mts +470 -0
- package/dist/index.d.ts +470 -0
- package/package.json +1 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { TypeDBCredential, TypeDBDriver, TypeDBSession } from 'typedb-driver';
|
|
2
|
+
|
|
3
|
+
interface TypeDBProviderObject {
|
|
4
|
+
provider: 'typeDB';
|
|
5
|
+
url: string;
|
|
6
|
+
}
|
|
7
|
+
interface TypeDBClusterProviderObject {
|
|
8
|
+
provider: 'typeDBCluster';
|
|
9
|
+
addresses: string[];
|
|
10
|
+
credentials: TypeDBCredential;
|
|
11
|
+
}
|
|
12
|
+
type TypeDBHandles = Map<string, {
|
|
13
|
+
client: TypeDBDriver;
|
|
14
|
+
session: TypeDBSession;
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
type QueryConfig = {
|
|
18
|
+
noMetadata?: boolean;
|
|
19
|
+
returnNulls?: boolean;
|
|
20
|
+
simplifiedLinks?: boolean;
|
|
21
|
+
debugger?: boolean;
|
|
22
|
+
};
|
|
23
|
+
type MutateConfig = {
|
|
24
|
+
noMetadata?: boolean;
|
|
25
|
+
preQuery?: boolean;
|
|
26
|
+
ignoreNonexistingThings?: boolean;
|
|
27
|
+
};
|
|
28
|
+
type BormConfig = {
|
|
29
|
+
server: {
|
|
30
|
+
provider: 'blitz-orm-js';
|
|
31
|
+
};
|
|
32
|
+
query?: QueryConfig;
|
|
33
|
+
mutation?: MutateConfig;
|
|
34
|
+
dbConnectors: [ProviderObject, ...ProviderObject[]];
|
|
35
|
+
};
|
|
36
|
+
type ProviderObject = (TypeDBProviderObject & CommonProperties) | (TypeDBClusterProviderObject & CommonProperties);
|
|
37
|
+
interface CommonProperties {
|
|
38
|
+
id: string;
|
|
39
|
+
dbName: string;
|
|
40
|
+
}
|
|
41
|
+
type Provider = 'typeDB' | 'typeDBCluster';
|
|
42
|
+
type DBConnector = {
|
|
43
|
+
id: string;
|
|
44
|
+
subs?: string;
|
|
45
|
+
path?: string;
|
|
46
|
+
as?: string;
|
|
47
|
+
};
|
|
48
|
+
type DBHandles = {
|
|
49
|
+
typeDB: TypeDBHandles;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type ThingType = 'entity' | 'relation' | 'attribute';
|
|
53
|
+
type BormMetadata = {
|
|
54
|
+
$id: string;
|
|
55
|
+
$op?: string;
|
|
56
|
+
$entity?: string;
|
|
57
|
+
$relation?: string;
|
|
58
|
+
$tempId?: string;
|
|
59
|
+
};
|
|
60
|
+
type WithBormMetadata<T> = T extends any[] ? T[number] extends object ? Array<WithBormMetadataObject<T[number]>> : T : T extends object ? WithBormMetadataObject<T> : T;
|
|
61
|
+
type WithBormMetadataObject<T> = {
|
|
62
|
+
[K in keyof T]: WithBormMetadata<T[K]>;
|
|
63
|
+
} & BormMetadata;
|
|
64
|
+
type BQLResponseSingle = Record<string, any>;
|
|
65
|
+
type BQLResponseMulti = BQLResponseSingle[];
|
|
66
|
+
type BQLResponse = BQLResponseSingle | BQLResponseMulti;
|
|
67
|
+
|
|
68
|
+
type LinkFilter = {
|
|
69
|
+
$thing?: string;
|
|
70
|
+
$thingType?: string;
|
|
71
|
+
$role?: string;
|
|
72
|
+
[key: string]: string | number | Filter | undefined;
|
|
73
|
+
};
|
|
74
|
+
type Filter = DataFilter | LinkFilter | MiddleFilter;
|
|
75
|
+
type MiddleFilter = {
|
|
76
|
+
$and?: Filter[];
|
|
77
|
+
$or?: Filter[];
|
|
78
|
+
};
|
|
79
|
+
type RequireAtLeastOne<T> = {
|
|
80
|
+
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
|
|
81
|
+
}[keyof T];
|
|
82
|
+
type DataFilter = RequireAtLeastOne<{
|
|
83
|
+
$eq?: any;
|
|
84
|
+
$ge?: number | string;
|
|
85
|
+
}>;
|
|
86
|
+
|
|
87
|
+
type BormField = {
|
|
88
|
+
path: string;
|
|
89
|
+
cardinality?: CardinalityType;
|
|
90
|
+
ordered?: boolean;
|
|
91
|
+
embedded?: boolean;
|
|
92
|
+
rights?: readonly RightType[];
|
|
93
|
+
};
|
|
94
|
+
type RoleField = {
|
|
95
|
+
cardinality: CardinalityType;
|
|
96
|
+
dbConnector?: DBConnector;
|
|
97
|
+
};
|
|
98
|
+
type LinkField = BormField & {
|
|
99
|
+
relation: string;
|
|
100
|
+
cardinality: CardinalityType;
|
|
101
|
+
plays: string;
|
|
102
|
+
} & ({
|
|
103
|
+
target: 'role';
|
|
104
|
+
filter?: Filter | Filter[];
|
|
105
|
+
} | {
|
|
106
|
+
target: 'relation';
|
|
107
|
+
});
|
|
108
|
+
type LinkedFieldWithThing = LinkField & {
|
|
109
|
+
thing: string;
|
|
110
|
+
thingType: ThingType;
|
|
111
|
+
};
|
|
112
|
+
type StringField = BormField & {
|
|
113
|
+
contentType: 'ID' | 'COLOR' | 'DATE' | 'FILE' | 'EMAIL' | 'PHONE' | 'URL' | 'PASSWORD' | 'LANGUAGE_TEXT' | 'RICH_TEXT' | 'TEXT';
|
|
114
|
+
default?: {
|
|
115
|
+
type: 'fn';
|
|
116
|
+
fn: (currentNode: BQLMutationBlock) => string;
|
|
117
|
+
} | {
|
|
118
|
+
type: 'value';
|
|
119
|
+
value: string;
|
|
120
|
+
};
|
|
121
|
+
validations?: {
|
|
122
|
+
enum?: string[];
|
|
123
|
+
unique?: boolean;
|
|
124
|
+
fn?: (value: string) => boolean;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
type NumberField = BormField & {
|
|
128
|
+
contentType: 'DURATION' | 'HOUR' | 'RATING' | 'CURRENCY' | 'PERCENTAGE' | 'NUMBER_DECIMAL' | 'NUMBER';
|
|
129
|
+
default?: {
|
|
130
|
+
type: 'fn';
|
|
131
|
+
fn: (currentNode: BQLMutationBlock) => number;
|
|
132
|
+
} | {
|
|
133
|
+
type: 'value';
|
|
134
|
+
value: number;
|
|
135
|
+
};
|
|
136
|
+
validations?: {
|
|
137
|
+
enum?: number[];
|
|
138
|
+
unique?: boolean;
|
|
139
|
+
fn?: (value: number) => boolean;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
type DateField = BormField & {
|
|
143
|
+
contentType: 'TIME';
|
|
144
|
+
default?: {
|
|
145
|
+
type: 'fn';
|
|
146
|
+
fn: (currentNode: BQLMutationBlock) => Date;
|
|
147
|
+
} | {
|
|
148
|
+
type: 'value';
|
|
149
|
+
value: Date;
|
|
150
|
+
};
|
|
151
|
+
validations?: {
|
|
152
|
+
enum: Date[];
|
|
153
|
+
fn?: (value: Date) => boolean;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
type BooleanField = BormField & {
|
|
157
|
+
contentType: 'BOOLEAN';
|
|
158
|
+
default?: {
|
|
159
|
+
type: 'fn';
|
|
160
|
+
fn: (currentNode: BQLMutationBlock) => boolean;
|
|
161
|
+
} | {
|
|
162
|
+
type: 'value';
|
|
163
|
+
value: boolean;
|
|
164
|
+
};
|
|
165
|
+
validations?: {
|
|
166
|
+
enum?: boolean[];
|
|
167
|
+
fn?: (value: boolean) => boolean;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
type AllDataField = StringField | NumberField | DateField | BooleanField;
|
|
171
|
+
type DataField = BormField & {
|
|
172
|
+
shared?: boolean;
|
|
173
|
+
validations?: {
|
|
174
|
+
required?: boolean;
|
|
175
|
+
unique?: boolean;
|
|
176
|
+
};
|
|
177
|
+
isVirtual?: boolean;
|
|
178
|
+
dbConnectors?: [DBConnector, ...DBConnector[]];
|
|
179
|
+
} & AllDataField;
|
|
180
|
+
type ContentType = keyof ContentTypeMapping;
|
|
181
|
+
type ContentTypeMapping = {
|
|
182
|
+
ID: string;
|
|
183
|
+
JSON: unknown;
|
|
184
|
+
COLOR: string;
|
|
185
|
+
BOOLEAN: boolean;
|
|
186
|
+
POINT: {
|
|
187
|
+
x: number;
|
|
188
|
+
y: number;
|
|
189
|
+
};
|
|
190
|
+
FILE: string;
|
|
191
|
+
EMAIL: string;
|
|
192
|
+
PHONE: string;
|
|
193
|
+
WEEK_DAY: 'Sunday' | 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday';
|
|
194
|
+
DURATION: number;
|
|
195
|
+
HOUR: number;
|
|
196
|
+
TIME: Date;
|
|
197
|
+
DATE: string;
|
|
198
|
+
RATING: number;
|
|
199
|
+
CURRENCY: number;
|
|
200
|
+
PERCENTAGE: number;
|
|
201
|
+
NUMBER_DECIMAL: number;
|
|
202
|
+
NUMBER: number;
|
|
203
|
+
URL: string;
|
|
204
|
+
PASSWORD: string;
|
|
205
|
+
LANGUAGE_TEXT: string;
|
|
206
|
+
RICH_TEXT: string;
|
|
207
|
+
TEXT: string;
|
|
208
|
+
};
|
|
209
|
+
type CardinalityType = 'ONE' | 'MANY' | 'INTERVAL';
|
|
210
|
+
type RightType = 'CREATE' | 'DELETE' | 'UPDATE' | 'LINK' | 'UNLINK';
|
|
211
|
+
type BQLFieldObj = {
|
|
212
|
+
$path: string;
|
|
213
|
+
$as?: string;
|
|
214
|
+
} & Omit<RawBQLQuery, '$entity' | '$relation' | '$thing' | '$thingType'>;
|
|
215
|
+
type BQLField = string | BQLFieldObj;
|
|
216
|
+
|
|
217
|
+
type EnrichedBormSchema = {
|
|
218
|
+
entities: {
|
|
219
|
+
[s: string]: EnrichedBormEntity;
|
|
220
|
+
};
|
|
221
|
+
relations: {
|
|
222
|
+
[s: string]: EnrichedBormRelation;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
type SharedEnrichedProps = {
|
|
226
|
+
name: string;
|
|
227
|
+
computedFields: string[];
|
|
228
|
+
virtualFields: string[];
|
|
229
|
+
requiredFields: string[];
|
|
230
|
+
enumFields: string[];
|
|
231
|
+
fnValidatedFields: string[];
|
|
232
|
+
linkFields?: EnrichedLinkField[];
|
|
233
|
+
dataFields?: EnrichedDataField[];
|
|
234
|
+
};
|
|
235
|
+
type EnrichedBormEntity = Omit<BormEntity, 'linkFields' | 'idFields' | 'dataFields'> & {
|
|
236
|
+
extends?: string;
|
|
237
|
+
thingType: 'entity';
|
|
238
|
+
allExtends?: string[];
|
|
239
|
+
idFields: string[];
|
|
240
|
+
} & SharedEnrichedProps;
|
|
241
|
+
type EnrichedBormRelation = Omit<BormRelation, 'linkFields' | 'dataFields'> & {
|
|
242
|
+
thingType: 'relation';
|
|
243
|
+
roles: {
|
|
244
|
+
[key: string]: EnrichedRoleField;
|
|
245
|
+
};
|
|
246
|
+
} & SharedEnrichedProps;
|
|
247
|
+
type EnrichedRoleField = RoleField & {
|
|
248
|
+
playedBy?: LinkedFieldWithThing[];
|
|
249
|
+
name: string;
|
|
250
|
+
};
|
|
251
|
+
type EnrichedDataField = DataField & {
|
|
252
|
+
dbPath: string;
|
|
253
|
+
};
|
|
254
|
+
type EnrichedLinkField = BormField & {
|
|
255
|
+
name: string;
|
|
256
|
+
relation: string;
|
|
257
|
+
plays: string;
|
|
258
|
+
} & ({
|
|
259
|
+
target: 'role';
|
|
260
|
+
filter?: Filter | Filter[];
|
|
261
|
+
oppositeLinkFieldsPlayedBy: LinkedFieldWithThing[];
|
|
262
|
+
} | {
|
|
263
|
+
target: 'relation';
|
|
264
|
+
oppositeLinkFieldsPlayedBy: Pick<LinkedFieldWithThing, 'thing' | 'thingType' | 'plays'>[];
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
declare const Schema: unique symbol;
|
|
268
|
+
|
|
269
|
+
type RequiredKey<T, K extends keyof T> = T & {
|
|
270
|
+
[P in K]-?: T[P];
|
|
271
|
+
};
|
|
272
|
+
type WithRequired<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> & RequiredKey<T, K>;
|
|
273
|
+
type BQLMutationBlock = {
|
|
274
|
+
[key: string]: any;
|
|
275
|
+
$id?: string | string[];
|
|
276
|
+
$filter?: Filter | Filter[];
|
|
277
|
+
$tempId?: string;
|
|
278
|
+
$op?: string;
|
|
279
|
+
} & ({
|
|
280
|
+
$entity: string;
|
|
281
|
+
} | {
|
|
282
|
+
$relation: string;
|
|
283
|
+
} | {
|
|
284
|
+
$thing: string;
|
|
285
|
+
$thingType: 'entity' | 'relation';
|
|
286
|
+
});
|
|
287
|
+
type FilledBQLMutationBlock = WithRequired<BQLMutationBlock, '$tempId' | '$op'> & {
|
|
288
|
+
$entity?: string;
|
|
289
|
+
[Schema]: EnrichedBormEntity | EnrichedBormRelation;
|
|
290
|
+
};
|
|
291
|
+
type RawBQLMutation<T extends Record<string, any> = Record<string, any>> = ({
|
|
292
|
+
$id?: string;
|
|
293
|
+
$op?: 'create' | 'delete' | 'update';
|
|
294
|
+
$tempId?: string;
|
|
295
|
+
} | {
|
|
296
|
+
$entity: string;
|
|
297
|
+
} | {
|
|
298
|
+
$relation: string;
|
|
299
|
+
}) & T;
|
|
300
|
+
type ParsedBQLMutation = {
|
|
301
|
+
things: BQLMutationBlock[];
|
|
302
|
+
edges: BQLMutationBlock[];
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
type RawBQLQuery = {
|
|
306
|
+
$id?: string | string[];
|
|
307
|
+
$filter?: Record<string, any>;
|
|
308
|
+
$fields?: BQLField[];
|
|
309
|
+
$excludedFields?: BQLField[];
|
|
310
|
+
} & ({
|
|
311
|
+
$entity: string;
|
|
312
|
+
} | {
|
|
313
|
+
$relation: string;
|
|
314
|
+
} | {
|
|
315
|
+
$thing: string;
|
|
316
|
+
$thingType: 'entity' | 'relation';
|
|
317
|
+
});
|
|
318
|
+
type ParsedBQLQuery = Omit<RawBQLQuery, '$entity' | '$relation' | '$thing' | '$thingType'> & {
|
|
319
|
+
$localFilters?: Record<string, any>;
|
|
320
|
+
$nestedFilters?: Record<string, any>;
|
|
321
|
+
} & ({
|
|
322
|
+
$entity: EnrichedBormEntity;
|
|
323
|
+
} | {
|
|
324
|
+
$relation: EnrichedBormRelation;
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
type TQLRequest = {
|
|
328
|
+
entity?: string;
|
|
329
|
+
roles?: {
|
|
330
|
+
path: string;
|
|
331
|
+
request: string;
|
|
332
|
+
owner: string;
|
|
333
|
+
}[];
|
|
334
|
+
relations?: {
|
|
335
|
+
relation: string;
|
|
336
|
+
entity: string;
|
|
337
|
+
request: string;
|
|
338
|
+
}[];
|
|
339
|
+
insertionMatches?: string;
|
|
340
|
+
deletionMatches?: string;
|
|
341
|
+
insertions?: string;
|
|
342
|
+
deletions?: string;
|
|
343
|
+
};
|
|
344
|
+
type TQLEntityMutation = {
|
|
345
|
+
entity: string;
|
|
346
|
+
relations?: {
|
|
347
|
+
relation: string;
|
|
348
|
+
entity: string;
|
|
349
|
+
request: string;
|
|
350
|
+
}[];
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
type BormSchema = {
|
|
354
|
+
entities: {
|
|
355
|
+
[s: string]: BormEntity;
|
|
356
|
+
};
|
|
357
|
+
relations: {
|
|
358
|
+
[s: string]: BormRelation;
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
type BormEntity = {
|
|
362
|
+
extends: string;
|
|
363
|
+
idFields?: readonly string[];
|
|
364
|
+
defaultDBConnector: DBConnector;
|
|
365
|
+
dataFields?: readonly DataField[];
|
|
366
|
+
linkFields?: readonly LinkField[];
|
|
367
|
+
hooks?: Hooks;
|
|
368
|
+
} | {
|
|
369
|
+
extends?: string;
|
|
370
|
+
idFields: readonly string[];
|
|
371
|
+
defaultDBConnector: DBConnector;
|
|
372
|
+
dataFields?: readonly DataField[];
|
|
373
|
+
linkFields?: readonly LinkField[];
|
|
374
|
+
};
|
|
375
|
+
type BormRelation = BormEntity & {
|
|
376
|
+
defaultDBConnector: DBConnector & {
|
|
377
|
+
path: string;
|
|
378
|
+
};
|
|
379
|
+
roles?: {
|
|
380
|
+
[key: string]: RoleField;
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
type BormOperation = 'create' | 'update' | 'delete' | 'link' | 'unlink';
|
|
384
|
+
type BormTrigger = 'onCreate' | 'onUpdate' | 'onDelete' | 'onLink' | 'onUnlink';
|
|
385
|
+
type Hooks = {
|
|
386
|
+
pre?: readonly PreHook[];
|
|
387
|
+
};
|
|
388
|
+
type PreHook = {
|
|
389
|
+
triggers: {
|
|
390
|
+
[K in BormTrigger]?: () => boolean;
|
|
391
|
+
};
|
|
392
|
+
actions: readonly Action[];
|
|
393
|
+
};
|
|
394
|
+
type Action = {
|
|
395
|
+
type: 'validate';
|
|
396
|
+
fn: (entity: FilledBQLMutationBlock) => boolean;
|
|
397
|
+
severity: 'error' | 'warning' | 'info';
|
|
398
|
+
message: string;
|
|
399
|
+
} | {
|
|
400
|
+
type: 'transform';
|
|
401
|
+
fn: (entity: FilledBQLMutationBlock) => Partial<FilledBQLMutationBlock>;
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
type ContentTypeToType<C extends keyof ContentTypeMapping> = ContentTypeMapping[C];
|
|
405
|
+
type HandleCardinality<T, C extends 'ONE' | 'MANY'> = C extends 'MANY' ? T[] : T;
|
|
406
|
+
type ContentTypeAndCardinality = {
|
|
407
|
+
contentType: keyof ContentTypeMapping;
|
|
408
|
+
cardinality: 'ONE' | 'MANY';
|
|
409
|
+
};
|
|
410
|
+
type ForDataField = {
|
|
411
|
+
path: string;
|
|
412
|
+
contentType: keyof ContentTypeMapping;
|
|
413
|
+
cardinality: 'ONE' | 'MANY';
|
|
414
|
+
};
|
|
415
|
+
type ForLinkField = {
|
|
416
|
+
path: string;
|
|
417
|
+
cardinality: 'ONE' | 'MANY';
|
|
418
|
+
};
|
|
419
|
+
type ForRoleFIeld = {
|
|
420
|
+
cardinality: 'ONE' | 'MANY';
|
|
421
|
+
};
|
|
422
|
+
type BaseSchemaEntity = {
|
|
423
|
+
dataFields: readonly ForDataField[];
|
|
424
|
+
linkFields?: readonly ForLinkField[];
|
|
425
|
+
};
|
|
426
|
+
type BaseSchemaRelation = BaseSchemaEntity & {
|
|
427
|
+
roles?: Record<string, ForRoleFIeld[]>;
|
|
428
|
+
};
|
|
429
|
+
type BaseSchema = BaseSchemaEntity | BaseSchemaRelation;
|
|
430
|
+
type FieldToType<F extends ContentTypeAndCardinality> = HandleCardinality<ContentTypeToType<F['contentType']>, F['cardinality']>;
|
|
431
|
+
type ExtractDataFields<S extends {
|
|
432
|
+
dataFields: readonly ForDataField[];
|
|
433
|
+
}> = {
|
|
434
|
+
[K in S['dataFields'][number]['path']]?: FieldToType<Extract<S['dataFields'][number], {
|
|
435
|
+
path: K;
|
|
436
|
+
}>>;
|
|
437
|
+
};
|
|
438
|
+
type ExtractLinkFields<S> = S extends {
|
|
439
|
+
linkFields?: readonly ForLinkField[];
|
|
440
|
+
} ? S['linkFields'] extends readonly ForLinkField[] ? {
|
|
441
|
+
[K in S['linkFields'][number]['path']]?: HandleCardinality<string, Extract<S['linkFields'][number], {
|
|
442
|
+
path: K;
|
|
443
|
+
}>['cardinality']>;
|
|
444
|
+
} : {} : {};
|
|
445
|
+
type ExtractRoles<S> = 'roles' extends keyof S ? {
|
|
446
|
+
[K in keyof S['roles']]?: S['roles'][K] extends {
|
|
447
|
+
cardinality: 'ONE' | 'MANY';
|
|
448
|
+
} ? HandleCardinality<string, S['roles'][K]['cardinality']> : never;
|
|
449
|
+
} : {};
|
|
450
|
+
type TypeGen<S extends BaseSchema> = ExtractDataFields<S> & ExtractLinkFields<S> & ExtractRoles<S>;
|
|
451
|
+
|
|
452
|
+
type BormProps = {
|
|
453
|
+
schema: BormSchema;
|
|
454
|
+
config: BormConfig;
|
|
455
|
+
};
|
|
456
|
+
declare class BormClient {
|
|
457
|
+
#private;
|
|
458
|
+
private schema;
|
|
459
|
+
private config;
|
|
460
|
+
private dbHandles?;
|
|
461
|
+
constructor({ schema, config }: BormProps);
|
|
462
|
+
init: () => Promise<void>;
|
|
463
|
+
introspect: () => Promise<BormSchema>;
|
|
464
|
+
define: () => Promise<void>;
|
|
465
|
+
query: (query: RawBQLQuery | RawBQLQuery[], queryConfig?: QueryConfig) => Promise<BQLResponse>;
|
|
466
|
+
mutate: (mutation: RawBQLMutation | RawBQLMutation[], mutationConfig?: MutateConfig) => Promise<BQLResponseMulti>;
|
|
467
|
+
close: () => Promise<void>;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export { type Action, type BQLField, type BQLFieldObj, type BQLMutationBlock, type BQLResponse, type BQLResponseMulti, type BQLResponseSingle, type BormConfig, type BormEntity, type BormField, type BormMetadata, type BormOperation, type BormRelation, type BormSchema, type BormTrigger, type CardinalityType, type CommonProperties, type ContentType, type ContentTypeMapping, type DBConnector, type DBHandles, type DataField, type DataFilter, type EnrichedBormEntity, type EnrichedBormRelation, type EnrichedBormSchema, type EnrichedDataField, type EnrichedLinkField, type EnrichedRoleField, type FilledBQLMutationBlock, type Filter, type Hooks, type LinkField, type LinkFilter, type LinkedFieldWithThing, type MiddleFilter, type MutateConfig, type ParsedBQLMutation, type ParsedBQLQuery, type PreHook, type Provider, type ProviderObject, type QueryConfig, type RawBQLMutation, type RawBQLQuery, type RightType, type RoleField, type TQLEntityMutation, type TQLRequest, type ThingType, type TypeDBClusterProviderObject, type TypeDBHandles, type TypeDBProviderObject, type TypeGen, type WithBormMetadata, BormClient as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { TypeDBCredential, TypeDBDriver, TypeDBSession } from 'typedb-driver';
|
|
2
|
+
|
|
3
|
+
interface TypeDBProviderObject {
|
|
4
|
+
provider: 'typeDB';
|
|
5
|
+
url: string;
|
|
6
|
+
}
|
|
7
|
+
interface TypeDBClusterProviderObject {
|
|
8
|
+
provider: 'typeDBCluster';
|
|
9
|
+
addresses: string[];
|
|
10
|
+
credentials: TypeDBCredential;
|
|
11
|
+
}
|
|
12
|
+
type TypeDBHandles = Map<string, {
|
|
13
|
+
client: TypeDBDriver;
|
|
14
|
+
session: TypeDBSession;
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
type QueryConfig = {
|
|
18
|
+
noMetadata?: boolean;
|
|
19
|
+
returnNulls?: boolean;
|
|
20
|
+
simplifiedLinks?: boolean;
|
|
21
|
+
debugger?: boolean;
|
|
22
|
+
};
|
|
23
|
+
type MutateConfig = {
|
|
24
|
+
noMetadata?: boolean;
|
|
25
|
+
preQuery?: boolean;
|
|
26
|
+
ignoreNonexistingThings?: boolean;
|
|
27
|
+
};
|
|
28
|
+
type BormConfig = {
|
|
29
|
+
server: {
|
|
30
|
+
provider: 'blitz-orm-js';
|
|
31
|
+
};
|
|
32
|
+
query?: QueryConfig;
|
|
33
|
+
mutation?: MutateConfig;
|
|
34
|
+
dbConnectors: [ProviderObject, ...ProviderObject[]];
|
|
35
|
+
};
|
|
36
|
+
type ProviderObject = (TypeDBProviderObject & CommonProperties) | (TypeDBClusterProviderObject & CommonProperties);
|
|
37
|
+
interface CommonProperties {
|
|
38
|
+
id: string;
|
|
39
|
+
dbName: string;
|
|
40
|
+
}
|
|
41
|
+
type Provider = 'typeDB' | 'typeDBCluster';
|
|
42
|
+
type DBConnector = {
|
|
43
|
+
id: string;
|
|
44
|
+
subs?: string;
|
|
45
|
+
path?: string;
|
|
46
|
+
as?: string;
|
|
47
|
+
};
|
|
48
|
+
type DBHandles = {
|
|
49
|
+
typeDB: TypeDBHandles;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type ThingType = 'entity' | 'relation' | 'attribute';
|
|
53
|
+
type BormMetadata = {
|
|
54
|
+
$id: string;
|
|
55
|
+
$op?: string;
|
|
56
|
+
$entity?: string;
|
|
57
|
+
$relation?: string;
|
|
58
|
+
$tempId?: string;
|
|
59
|
+
};
|
|
60
|
+
type WithBormMetadata<T> = T extends any[] ? T[number] extends object ? Array<WithBormMetadataObject<T[number]>> : T : T extends object ? WithBormMetadataObject<T> : T;
|
|
61
|
+
type WithBormMetadataObject<T> = {
|
|
62
|
+
[K in keyof T]: WithBormMetadata<T[K]>;
|
|
63
|
+
} & BormMetadata;
|
|
64
|
+
type BQLResponseSingle = Record<string, any>;
|
|
65
|
+
type BQLResponseMulti = BQLResponseSingle[];
|
|
66
|
+
type BQLResponse = BQLResponseSingle | BQLResponseMulti;
|
|
67
|
+
|
|
68
|
+
type LinkFilter = {
|
|
69
|
+
$thing?: string;
|
|
70
|
+
$thingType?: string;
|
|
71
|
+
$role?: string;
|
|
72
|
+
[key: string]: string | number | Filter | undefined;
|
|
73
|
+
};
|
|
74
|
+
type Filter = DataFilter | LinkFilter | MiddleFilter;
|
|
75
|
+
type MiddleFilter = {
|
|
76
|
+
$and?: Filter[];
|
|
77
|
+
$or?: Filter[];
|
|
78
|
+
};
|
|
79
|
+
type RequireAtLeastOne<T> = {
|
|
80
|
+
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
|
|
81
|
+
}[keyof T];
|
|
82
|
+
type DataFilter = RequireAtLeastOne<{
|
|
83
|
+
$eq?: any;
|
|
84
|
+
$ge?: number | string;
|
|
85
|
+
}>;
|
|
86
|
+
|
|
87
|
+
type BormField = {
|
|
88
|
+
path: string;
|
|
89
|
+
cardinality?: CardinalityType;
|
|
90
|
+
ordered?: boolean;
|
|
91
|
+
embedded?: boolean;
|
|
92
|
+
rights?: readonly RightType[];
|
|
93
|
+
};
|
|
94
|
+
type RoleField = {
|
|
95
|
+
cardinality: CardinalityType;
|
|
96
|
+
dbConnector?: DBConnector;
|
|
97
|
+
};
|
|
98
|
+
type LinkField = BormField & {
|
|
99
|
+
relation: string;
|
|
100
|
+
cardinality: CardinalityType;
|
|
101
|
+
plays: string;
|
|
102
|
+
} & ({
|
|
103
|
+
target: 'role';
|
|
104
|
+
filter?: Filter | Filter[];
|
|
105
|
+
} | {
|
|
106
|
+
target: 'relation';
|
|
107
|
+
});
|
|
108
|
+
type LinkedFieldWithThing = LinkField & {
|
|
109
|
+
thing: string;
|
|
110
|
+
thingType: ThingType;
|
|
111
|
+
};
|
|
112
|
+
type StringField = BormField & {
|
|
113
|
+
contentType: 'ID' | 'COLOR' | 'DATE' | 'FILE' | 'EMAIL' | 'PHONE' | 'URL' | 'PASSWORD' | 'LANGUAGE_TEXT' | 'RICH_TEXT' | 'TEXT';
|
|
114
|
+
default?: {
|
|
115
|
+
type: 'fn';
|
|
116
|
+
fn: (currentNode: BQLMutationBlock) => string;
|
|
117
|
+
} | {
|
|
118
|
+
type: 'value';
|
|
119
|
+
value: string;
|
|
120
|
+
};
|
|
121
|
+
validations?: {
|
|
122
|
+
enum?: string[];
|
|
123
|
+
unique?: boolean;
|
|
124
|
+
fn?: (value: string) => boolean;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
type NumberField = BormField & {
|
|
128
|
+
contentType: 'DURATION' | 'HOUR' | 'RATING' | 'CURRENCY' | 'PERCENTAGE' | 'NUMBER_DECIMAL' | 'NUMBER';
|
|
129
|
+
default?: {
|
|
130
|
+
type: 'fn';
|
|
131
|
+
fn: (currentNode: BQLMutationBlock) => number;
|
|
132
|
+
} | {
|
|
133
|
+
type: 'value';
|
|
134
|
+
value: number;
|
|
135
|
+
};
|
|
136
|
+
validations?: {
|
|
137
|
+
enum?: number[];
|
|
138
|
+
unique?: boolean;
|
|
139
|
+
fn?: (value: number) => boolean;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
type DateField = BormField & {
|
|
143
|
+
contentType: 'TIME';
|
|
144
|
+
default?: {
|
|
145
|
+
type: 'fn';
|
|
146
|
+
fn: (currentNode: BQLMutationBlock) => Date;
|
|
147
|
+
} | {
|
|
148
|
+
type: 'value';
|
|
149
|
+
value: Date;
|
|
150
|
+
};
|
|
151
|
+
validations?: {
|
|
152
|
+
enum: Date[];
|
|
153
|
+
fn?: (value: Date) => boolean;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
type BooleanField = BormField & {
|
|
157
|
+
contentType: 'BOOLEAN';
|
|
158
|
+
default?: {
|
|
159
|
+
type: 'fn';
|
|
160
|
+
fn: (currentNode: BQLMutationBlock) => boolean;
|
|
161
|
+
} | {
|
|
162
|
+
type: 'value';
|
|
163
|
+
value: boolean;
|
|
164
|
+
};
|
|
165
|
+
validations?: {
|
|
166
|
+
enum?: boolean[];
|
|
167
|
+
fn?: (value: boolean) => boolean;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
type AllDataField = StringField | NumberField | DateField | BooleanField;
|
|
171
|
+
type DataField = BormField & {
|
|
172
|
+
shared?: boolean;
|
|
173
|
+
validations?: {
|
|
174
|
+
required?: boolean;
|
|
175
|
+
unique?: boolean;
|
|
176
|
+
};
|
|
177
|
+
isVirtual?: boolean;
|
|
178
|
+
dbConnectors?: [DBConnector, ...DBConnector[]];
|
|
179
|
+
} & AllDataField;
|
|
180
|
+
type ContentType = keyof ContentTypeMapping;
|
|
181
|
+
type ContentTypeMapping = {
|
|
182
|
+
ID: string;
|
|
183
|
+
JSON: unknown;
|
|
184
|
+
COLOR: string;
|
|
185
|
+
BOOLEAN: boolean;
|
|
186
|
+
POINT: {
|
|
187
|
+
x: number;
|
|
188
|
+
y: number;
|
|
189
|
+
};
|
|
190
|
+
FILE: string;
|
|
191
|
+
EMAIL: string;
|
|
192
|
+
PHONE: string;
|
|
193
|
+
WEEK_DAY: 'Sunday' | 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday';
|
|
194
|
+
DURATION: number;
|
|
195
|
+
HOUR: number;
|
|
196
|
+
TIME: Date;
|
|
197
|
+
DATE: string;
|
|
198
|
+
RATING: number;
|
|
199
|
+
CURRENCY: number;
|
|
200
|
+
PERCENTAGE: number;
|
|
201
|
+
NUMBER_DECIMAL: number;
|
|
202
|
+
NUMBER: number;
|
|
203
|
+
URL: string;
|
|
204
|
+
PASSWORD: string;
|
|
205
|
+
LANGUAGE_TEXT: string;
|
|
206
|
+
RICH_TEXT: string;
|
|
207
|
+
TEXT: string;
|
|
208
|
+
};
|
|
209
|
+
type CardinalityType = 'ONE' | 'MANY' | 'INTERVAL';
|
|
210
|
+
type RightType = 'CREATE' | 'DELETE' | 'UPDATE' | 'LINK' | 'UNLINK';
|
|
211
|
+
type BQLFieldObj = {
|
|
212
|
+
$path: string;
|
|
213
|
+
$as?: string;
|
|
214
|
+
} & Omit<RawBQLQuery, '$entity' | '$relation' | '$thing' | '$thingType'>;
|
|
215
|
+
type BQLField = string | BQLFieldObj;
|
|
216
|
+
|
|
217
|
+
type EnrichedBormSchema = {
|
|
218
|
+
entities: {
|
|
219
|
+
[s: string]: EnrichedBormEntity;
|
|
220
|
+
};
|
|
221
|
+
relations: {
|
|
222
|
+
[s: string]: EnrichedBormRelation;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
type SharedEnrichedProps = {
|
|
226
|
+
name: string;
|
|
227
|
+
computedFields: string[];
|
|
228
|
+
virtualFields: string[];
|
|
229
|
+
requiredFields: string[];
|
|
230
|
+
enumFields: string[];
|
|
231
|
+
fnValidatedFields: string[];
|
|
232
|
+
linkFields?: EnrichedLinkField[];
|
|
233
|
+
dataFields?: EnrichedDataField[];
|
|
234
|
+
};
|
|
235
|
+
type EnrichedBormEntity = Omit<BormEntity, 'linkFields' | 'idFields' | 'dataFields'> & {
|
|
236
|
+
extends?: string;
|
|
237
|
+
thingType: 'entity';
|
|
238
|
+
allExtends?: string[];
|
|
239
|
+
idFields: string[];
|
|
240
|
+
} & SharedEnrichedProps;
|
|
241
|
+
type EnrichedBormRelation = Omit<BormRelation, 'linkFields' | 'dataFields'> & {
|
|
242
|
+
thingType: 'relation';
|
|
243
|
+
roles: {
|
|
244
|
+
[key: string]: EnrichedRoleField;
|
|
245
|
+
};
|
|
246
|
+
} & SharedEnrichedProps;
|
|
247
|
+
type EnrichedRoleField = RoleField & {
|
|
248
|
+
playedBy?: LinkedFieldWithThing[];
|
|
249
|
+
name: string;
|
|
250
|
+
};
|
|
251
|
+
type EnrichedDataField = DataField & {
|
|
252
|
+
dbPath: string;
|
|
253
|
+
};
|
|
254
|
+
type EnrichedLinkField = BormField & {
|
|
255
|
+
name: string;
|
|
256
|
+
relation: string;
|
|
257
|
+
plays: string;
|
|
258
|
+
} & ({
|
|
259
|
+
target: 'role';
|
|
260
|
+
filter?: Filter | Filter[];
|
|
261
|
+
oppositeLinkFieldsPlayedBy: LinkedFieldWithThing[];
|
|
262
|
+
} | {
|
|
263
|
+
target: 'relation';
|
|
264
|
+
oppositeLinkFieldsPlayedBy: Pick<LinkedFieldWithThing, 'thing' | 'thingType' | 'plays'>[];
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
declare const Schema: unique symbol;
|
|
268
|
+
|
|
269
|
+
type RequiredKey<T, K extends keyof T> = T & {
|
|
270
|
+
[P in K]-?: T[P];
|
|
271
|
+
};
|
|
272
|
+
type WithRequired<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> & RequiredKey<T, K>;
|
|
273
|
+
type BQLMutationBlock = {
|
|
274
|
+
[key: string]: any;
|
|
275
|
+
$id?: string | string[];
|
|
276
|
+
$filter?: Filter | Filter[];
|
|
277
|
+
$tempId?: string;
|
|
278
|
+
$op?: string;
|
|
279
|
+
} & ({
|
|
280
|
+
$entity: string;
|
|
281
|
+
} | {
|
|
282
|
+
$relation: string;
|
|
283
|
+
} | {
|
|
284
|
+
$thing: string;
|
|
285
|
+
$thingType: 'entity' | 'relation';
|
|
286
|
+
});
|
|
287
|
+
type FilledBQLMutationBlock = WithRequired<BQLMutationBlock, '$tempId' | '$op'> & {
|
|
288
|
+
$entity?: string;
|
|
289
|
+
[Schema]: EnrichedBormEntity | EnrichedBormRelation;
|
|
290
|
+
};
|
|
291
|
+
type RawBQLMutation<T extends Record<string, any> = Record<string, any>> = ({
|
|
292
|
+
$id?: string;
|
|
293
|
+
$op?: 'create' | 'delete' | 'update';
|
|
294
|
+
$tempId?: string;
|
|
295
|
+
} | {
|
|
296
|
+
$entity: string;
|
|
297
|
+
} | {
|
|
298
|
+
$relation: string;
|
|
299
|
+
}) & T;
|
|
300
|
+
type ParsedBQLMutation = {
|
|
301
|
+
things: BQLMutationBlock[];
|
|
302
|
+
edges: BQLMutationBlock[];
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
type RawBQLQuery = {
|
|
306
|
+
$id?: string | string[];
|
|
307
|
+
$filter?: Record<string, any>;
|
|
308
|
+
$fields?: BQLField[];
|
|
309
|
+
$excludedFields?: BQLField[];
|
|
310
|
+
} & ({
|
|
311
|
+
$entity: string;
|
|
312
|
+
} | {
|
|
313
|
+
$relation: string;
|
|
314
|
+
} | {
|
|
315
|
+
$thing: string;
|
|
316
|
+
$thingType: 'entity' | 'relation';
|
|
317
|
+
});
|
|
318
|
+
type ParsedBQLQuery = Omit<RawBQLQuery, '$entity' | '$relation' | '$thing' | '$thingType'> & {
|
|
319
|
+
$localFilters?: Record<string, any>;
|
|
320
|
+
$nestedFilters?: Record<string, any>;
|
|
321
|
+
} & ({
|
|
322
|
+
$entity: EnrichedBormEntity;
|
|
323
|
+
} | {
|
|
324
|
+
$relation: EnrichedBormRelation;
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
type TQLRequest = {
|
|
328
|
+
entity?: string;
|
|
329
|
+
roles?: {
|
|
330
|
+
path: string;
|
|
331
|
+
request: string;
|
|
332
|
+
owner: string;
|
|
333
|
+
}[];
|
|
334
|
+
relations?: {
|
|
335
|
+
relation: string;
|
|
336
|
+
entity: string;
|
|
337
|
+
request: string;
|
|
338
|
+
}[];
|
|
339
|
+
insertionMatches?: string;
|
|
340
|
+
deletionMatches?: string;
|
|
341
|
+
insertions?: string;
|
|
342
|
+
deletions?: string;
|
|
343
|
+
};
|
|
344
|
+
type TQLEntityMutation = {
|
|
345
|
+
entity: string;
|
|
346
|
+
relations?: {
|
|
347
|
+
relation: string;
|
|
348
|
+
entity: string;
|
|
349
|
+
request: string;
|
|
350
|
+
}[];
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
type BormSchema = {
|
|
354
|
+
entities: {
|
|
355
|
+
[s: string]: BormEntity;
|
|
356
|
+
};
|
|
357
|
+
relations: {
|
|
358
|
+
[s: string]: BormRelation;
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
type BormEntity = {
|
|
362
|
+
extends: string;
|
|
363
|
+
idFields?: readonly string[];
|
|
364
|
+
defaultDBConnector: DBConnector;
|
|
365
|
+
dataFields?: readonly DataField[];
|
|
366
|
+
linkFields?: readonly LinkField[];
|
|
367
|
+
hooks?: Hooks;
|
|
368
|
+
} | {
|
|
369
|
+
extends?: string;
|
|
370
|
+
idFields: readonly string[];
|
|
371
|
+
defaultDBConnector: DBConnector;
|
|
372
|
+
dataFields?: readonly DataField[];
|
|
373
|
+
linkFields?: readonly LinkField[];
|
|
374
|
+
};
|
|
375
|
+
type BormRelation = BormEntity & {
|
|
376
|
+
defaultDBConnector: DBConnector & {
|
|
377
|
+
path: string;
|
|
378
|
+
};
|
|
379
|
+
roles?: {
|
|
380
|
+
[key: string]: RoleField;
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
type BormOperation = 'create' | 'update' | 'delete' | 'link' | 'unlink';
|
|
384
|
+
type BormTrigger = 'onCreate' | 'onUpdate' | 'onDelete' | 'onLink' | 'onUnlink';
|
|
385
|
+
type Hooks = {
|
|
386
|
+
pre?: readonly PreHook[];
|
|
387
|
+
};
|
|
388
|
+
type PreHook = {
|
|
389
|
+
triggers: {
|
|
390
|
+
[K in BormTrigger]?: () => boolean;
|
|
391
|
+
};
|
|
392
|
+
actions: readonly Action[];
|
|
393
|
+
};
|
|
394
|
+
type Action = {
|
|
395
|
+
type: 'validate';
|
|
396
|
+
fn: (entity: FilledBQLMutationBlock) => boolean;
|
|
397
|
+
severity: 'error' | 'warning' | 'info';
|
|
398
|
+
message: string;
|
|
399
|
+
} | {
|
|
400
|
+
type: 'transform';
|
|
401
|
+
fn: (entity: FilledBQLMutationBlock) => Partial<FilledBQLMutationBlock>;
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
type ContentTypeToType<C extends keyof ContentTypeMapping> = ContentTypeMapping[C];
|
|
405
|
+
type HandleCardinality<T, C extends 'ONE' | 'MANY'> = C extends 'MANY' ? T[] : T;
|
|
406
|
+
type ContentTypeAndCardinality = {
|
|
407
|
+
contentType: keyof ContentTypeMapping;
|
|
408
|
+
cardinality: 'ONE' | 'MANY';
|
|
409
|
+
};
|
|
410
|
+
type ForDataField = {
|
|
411
|
+
path: string;
|
|
412
|
+
contentType: keyof ContentTypeMapping;
|
|
413
|
+
cardinality: 'ONE' | 'MANY';
|
|
414
|
+
};
|
|
415
|
+
type ForLinkField = {
|
|
416
|
+
path: string;
|
|
417
|
+
cardinality: 'ONE' | 'MANY';
|
|
418
|
+
};
|
|
419
|
+
type ForRoleFIeld = {
|
|
420
|
+
cardinality: 'ONE' | 'MANY';
|
|
421
|
+
};
|
|
422
|
+
type BaseSchemaEntity = {
|
|
423
|
+
dataFields: readonly ForDataField[];
|
|
424
|
+
linkFields?: readonly ForLinkField[];
|
|
425
|
+
};
|
|
426
|
+
type BaseSchemaRelation = BaseSchemaEntity & {
|
|
427
|
+
roles?: Record<string, ForRoleFIeld[]>;
|
|
428
|
+
};
|
|
429
|
+
type BaseSchema = BaseSchemaEntity | BaseSchemaRelation;
|
|
430
|
+
type FieldToType<F extends ContentTypeAndCardinality> = HandleCardinality<ContentTypeToType<F['contentType']>, F['cardinality']>;
|
|
431
|
+
type ExtractDataFields<S extends {
|
|
432
|
+
dataFields: readonly ForDataField[];
|
|
433
|
+
}> = {
|
|
434
|
+
[K in S['dataFields'][number]['path']]?: FieldToType<Extract<S['dataFields'][number], {
|
|
435
|
+
path: K;
|
|
436
|
+
}>>;
|
|
437
|
+
};
|
|
438
|
+
type ExtractLinkFields<S> = S extends {
|
|
439
|
+
linkFields?: readonly ForLinkField[];
|
|
440
|
+
} ? S['linkFields'] extends readonly ForLinkField[] ? {
|
|
441
|
+
[K in S['linkFields'][number]['path']]?: HandleCardinality<string, Extract<S['linkFields'][number], {
|
|
442
|
+
path: K;
|
|
443
|
+
}>['cardinality']>;
|
|
444
|
+
} : {} : {};
|
|
445
|
+
type ExtractRoles<S> = 'roles' extends keyof S ? {
|
|
446
|
+
[K in keyof S['roles']]?: S['roles'][K] extends {
|
|
447
|
+
cardinality: 'ONE' | 'MANY';
|
|
448
|
+
} ? HandleCardinality<string, S['roles'][K]['cardinality']> : never;
|
|
449
|
+
} : {};
|
|
450
|
+
type TypeGen<S extends BaseSchema> = ExtractDataFields<S> & ExtractLinkFields<S> & ExtractRoles<S>;
|
|
451
|
+
|
|
452
|
+
type BormProps = {
|
|
453
|
+
schema: BormSchema;
|
|
454
|
+
config: BormConfig;
|
|
455
|
+
};
|
|
456
|
+
declare class BormClient {
|
|
457
|
+
#private;
|
|
458
|
+
private schema;
|
|
459
|
+
private config;
|
|
460
|
+
private dbHandles?;
|
|
461
|
+
constructor({ schema, config }: BormProps);
|
|
462
|
+
init: () => Promise<void>;
|
|
463
|
+
introspect: () => Promise<BormSchema>;
|
|
464
|
+
define: () => Promise<void>;
|
|
465
|
+
query: (query: RawBQLQuery | RawBQLQuery[], queryConfig?: QueryConfig) => Promise<BQLResponse>;
|
|
466
|
+
mutate: (mutation: RawBQLMutation | RawBQLMutation[], mutationConfig?: MutateConfig) => Promise<BQLResponseMulti>;
|
|
467
|
+
close: () => Promise<void>;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export { type Action, type BQLField, type BQLFieldObj, type BQLMutationBlock, type BQLResponse, type BQLResponseMulti, type BQLResponseSingle, type BormConfig, type BormEntity, type BormField, type BormMetadata, type BormOperation, type BormRelation, type BormSchema, type BormTrigger, type CardinalityType, type CommonProperties, type ContentType, type ContentTypeMapping, type DBConnector, type DBHandles, type DataField, type DataFilter, type EnrichedBormEntity, type EnrichedBormRelation, type EnrichedBormSchema, type EnrichedDataField, type EnrichedLinkField, type EnrichedRoleField, type FilledBQLMutationBlock, type Filter, type Hooks, type LinkField, type LinkFilter, type LinkedFieldWithThing, type MiddleFilter, type MutateConfig, type ParsedBQLMutation, type ParsedBQLQuery, type PreHook, type Provider, type ProviderObject, type QueryConfig, type RawBQLMutation, type RawBQLQuery, type RightType, type RoleField, type TQLEntityMutation, type TQLRequest, type ThingType, type TypeDBClusterProviderObject, type TypeDBHandles, type TypeDBProviderObject, type TypeGen, type WithBormMetadata, BormClient as default };
|