@blitznocode/blitz-orm 0.8.11 → 0.9.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/dist/index.d.mts +107 -63
- package/dist/index.d.ts +107 -63
- package/dist/index.js +57 -53
- package/dist/index.mjs +60 -56
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -20,7 +20,7 @@ type QueryConfig = {
|
|
|
20
20
|
simplifiedLinks?: boolean;
|
|
21
21
|
debugger?: boolean;
|
|
22
22
|
};
|
|
23
|
-
type
|
|
23
|
+
type MutationConfig = {
|
|
24
24
|
noMetadata?: boolean;
|
|
25
25
|
preQuery?: boolean;
|
|
26
26
|
ignoreNonexistingThings?: boolean;
|
|
@@ -30,7 +30,7 @@ type BormConfig = {
|
|
|
30
30
|
provider: 'blitz-orm-js';
|
|
31
31
|
};
|
|
32
32
|
query?: QueryConfig;
|
|
33
|
-
mutation?:
|
|
33
|
+
mutation?: MutationConfig;
|
|
34
34
|
dbConnectors: [ProviderObject, ...ProviderObject[]];
|
|
35
35
|
};
|
|
36
36
|
type ProviderObject = (TypeDBProviderObject & CommonProperties) | (TypeDBClusterProviderObject & CommonProperties);
|
|
@@ -45,11 +45,17 @@ type DBConnector = {
|
|
|
45
45
|
path?: string;
|
|
46
46
|
as?: string;
|
|
47
47
|
};
|
|
48
|
-
type
|
|
48
|
+
type AllDbHandles = {
|
|
49
49
|
typeDB: TypeDBHandles;
|
|
50
|
+
surrealDB: any;
|
|
50
51
|
};
|
|
52
|
+
type AtLeastOne<T, U = {
|
|
53
|
+
[K in keyof T]: Pick<T, K>;
|
|
54
|
+
}> = Partial<T> & U[keyof U];
|
|
55
|
+
type DBHandles = AtLeastOne<AllDbHandles>;
|
|
56
|
+
type DBHandleKey = keyof DBHandles;
|
|
51
57
|
|
|
52
|
-
type ThingType = 'entity' | 'relation'
|
|
58
|
+
type ThingType = 'entity' | 'relation';
|
|
53
59
|
type BormMetadata = {
|
|
54
60
|
$id: string;
|
|
55
61
|
$op?: string;
|
|
@@ -84,6 +90,66 @@ type DataFilter = RequireAtLeastOne<{
|
|
|
84
90
|
$ge?: number | string;
|
|
85
91
|
}>;
|
|
86
92
|
|
|
93
|
+
type BormSchema = {
|
|
94
|
+
entities: {
|
|
95
|
+
[s: string]: BormEntity;
|
|
96
|
+
};
|
|
97
|
+
relations: {
|
|
98
|
+
[s: string]: BormRelation;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
type BormEntity = {
|
|
102
|
+
extends: string;
|
|
103
|
+
idFields?: readonly string[];
|
|
104
|
+
defaultDBConnector: DBConnector;
|
|
105
|
+
dataFields?: readonly DataField[];
|
|
106
|
+
linkFields?: readonly LinkField[];
|
|
107
|
+
hooks?: Hooks;
|
|
108
|
+
} | {
|
|
109
|
+
idFields: readonly string[];
|
|
110
|
+
defaultDBConnector: DBConnector;
|
|
111
|
+
dataFields?: readonly DataField[];
|
|
112
|
+
linkFields?: readonly LinkField[];
|
|
113
|
+
hooks?: Hooks;
|
|
114
|
+
};
|
|
115
|
+
type BormRelation = BormEntity & {
|
|
116
|
+
defaultDBConnector: DBConnector & {
|
|
117
|
+
path: string;
|
|
118
|
+
};
|
|
119
|
+
roles?: {
|
|
120
|
+
[key: string]: RoleField;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
type BormOperation = 'create' | 'update' | 'delete' | 'link' | 'unlink' | 'replace' | 'match';
|
|
124
|
+
type BormTrigger = 'onCreate' | 'onUpdate' | 'onDelete' | 'onLink' | 'onUnlink' | 'onReplace' | 'onMatch';
|
|
125
|
+
type Hooks = {
|
|
126
|
+
pre?: readonly PreHook[];
|
|
127
|
+
};
|
|
128
|
+
type PreHook = {
|
|
129
|
+
triggers: {
|
|
130
|
+
[K in BormTrigger]?: () => boolean;
|
|
131
|
+
};
|
|
132
|
+
actions: readonly Action[];
|
|
133
|
+
};
|
|
134
|
+
type Action = TransFormAction | ValidateAction;
|
|
135
|
+
type TransFormAction = {
|
|
136
|
+
type: 'transform';
|
|
137
|
+
fn: (currentNode: FilledBQLMutationBlock, parentNode?: FilledBQLMutationBlock) => Partial<FilledBQLMutationBlock>;
|
|
138
|
+
};
|
|
139
|
+
type ValidateAction = {
|
|
140
|
+
type: 'validate';
|
|
141
|
+
fn: (currentNode: FilledBQLMutationBlock, parentNode: FilledBQLMutationBlock) => boolean;
|
|
142
|
+
severity: 'error' | 'warning' | 'info';
|
|
143
|
+
message: string;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
type AdapterContext = {
|
|
147
|
+
mutation: {
|
|
148
|
+
splitArray$Ids: boolean;
|
|
149
|
+
requiresParseBQL: boolean;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
|
|
87
153
|
type BormField = {
|
|
88
154
|
path: string;
|
|
89
155
|
cardinality?: CardinalityType;
|
|
@@ -231,6 +297,8 @@ type SharedEnrichedProps = {
|
|
|
231
297
|
fnValidatedFields: string[];
|
|
232
298
|
linkFields?: EnrichedLinkField[];
|
|
233
299
|
dataFields?: EnrichedDataField[];
|
|
300
|
+
db: DBHandleKey;
|
|
301
|
+
dbContext: AdapterContext;
|
|
234
302
|
};
|
|
235
303
|
type EnrichedBormEntity = Omit<BormEntity, 'linkFields' | 'idFields' | 'dataFields'> & {
|
|
236
304
|
extends?: string;
|
|
@@ -247,6 +315,7 @@ type EnrichedBormRelation = Omit<BormRelation, 'linkFields' | 'dataFields'> & {
|
|
|
247
315
|
type EnrichedRoleField = RoleField & {
|
|
248
316
|
playedBy?: LinkedFieldWithThing[];
|
|
249
317
|
name: string;
|
|
318
|
+
fieldType: 'roleField';
|
|
250
319
|
};
|
|
251
320
|
type EnrichedDataField = DataField & {
|
|
252
321
|
dbPath: string;
|
|
@@ -255,6 +324,7 @@ type EnrichedLinkField = BormField & {
|
|
|
255
324
|
name: string;
|
|
256
325
|
relation: string;
|
|
257
326
|
plays: string;
|
|
327
|
+
fieldType: 'linkField';
|
|
258
328
|
} & ({
|
|
259
329
|
target: 'role';
|
|
260
330
|
filter?: Filter | Filter[];
|
|
@@ -265,12 +335,15 @@ type EnrichedLinkField = BormField & {
|
|
|
265
335
|
});
|
|
266
336
|
|
|
267
337
|
declare const Schema: unique symbol;
|
|
338
|
+
declare const EdgeType: unique symbol;
|
|
339
|
+
declare const EdgeSchema: unique symbol;
|
|
268
340
|
|
|
269
341
|
type RequiredKey<T, K extends keyof T> = T & {
|
|
270
342
|
[P in K]-?: T[P];
|
|
271
343
|
};
|
|
272
344
|
type WithRequired<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> & RequiredKey<T, K>;
|
|
273
|
-
type
|
|
345
|
+
type BQLMutation = RootBQLMutationBlock | RootBQLMutationBlock[];
|
|
346
|
+
type RootBQLMutationBlock = {
|
|
274
347
|
[key: string]: any;
|
|
275
348
|
$id?: string | string[];
|
|
276
349
|
$filter?: Filter | Filter[];
|
|
@@ -282,11 +355,35 @@ type BQLMutationBlock = {
|
|
|
282
355
|
$relation: string;
|
|
283
356
|
} | {
|
|
284
357
|
$thing: string;
|
|
285
|
-
$thingType
|
|
358
|
+
$thingType?: 'entity' | 'relation';
|
|
286
359
|
});
|
|
287
|
-
type
|
|
360
|
+
type BQLMutationBlock = {
|
|
361
|
+
[key: string]: any;
|
|
362
|
+
$id?: string | string[];
|
|
363
|
+
$filter?: Filter | Filter[];
|
|
364
|
+
$tempId?: string;
|
|
365
|
+
$op?: string;
|
|
288
366
|
$entity?: string;
|
|
289
|
-
|
|
367
|
+
$relation?: string;
|
|
368
|
+
$thing?: string;
|
|
369
|
+
$thingType?: 'entity' | 'relation';
|
|
370
|
+
};
|
|
371
|
+
type FilledBQLMutationBlock = WithRequired<BQLMutationBlock, '$op'> & {
|
|
372
|
+
$entity?: string;
|
|
373
|
+
$relation?: string;
|
|
374
|
+
[Schema]?: EnrichedBormEntity | EnrichedBormRelation;
|
|
375
|
+
[EdgeType]?: 'linkField' | 'roleField';
|
|
376
|
+
};
|
|
377
|
+
type EnrichedBQLMutationBlock = {
|
|
378
|
+
[key: string]: any;
|
|
379
|
+
$id?: string | string[];
|
|
380
|
+
$filter?: Filter | Filter[];
|
|
381
|
+
$tempId?: string;
|
|
382
|
+
$op: BormOperation;
|
|
383
|
+
$thing: string;
|
|
384
|
+
$thingType: 'entity' | 'relation';
|
|
385
|
+
[EdgeSchema]?: EnrichedDataField | EnrichedLinkField | EnrichedRoleField;
|
|
386
|
+
[EdgeType]?: 'linkField' | 'roleField';
|
|
290
387
|
};
|
|
291
388
|
type RawBQLMutation<T extends Record<string, any> = Record<string, any>> = ({
|
|
292
389
|
$id?: string;
|
|
@@ -350,59 +447,6 @@ type TQLEntityMutation = {
|
|
|
350
447
|
}[];
|
|
351
448
|
};
|
|
352
449
|
|
|
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
|
-
idFields: readonly string[];
|
|
370
|
-
defaultDBConnector: DBConnector;
|
|
371
|
-
dataFields?: readonly DataField[];
|
|
372
|
-
linkFields?: readonly LinkField[];
|
|
373
|
-
hooks?: Hooks;
|
|
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 = TransFormAction | ValidateAction;
|
|
395
|
-
type TransFormAction = {
|
|
396
|
-
type: 'transform';
|
|
397
|
-
fn: (currentNode: FilledBQLMutationBlock, parentNode?: FilledBQLMutationBlock) => Partial<FilledBQLMutationBlock>;
|
|
398
|
-
};
|
|
399
|
-
type ValidateAction = {
|
|
400
|
-
type: 'validate';
|
|
401
|
-
fn: (currentNode: FilledBQLMutationBlock, parentNode: FilledBQLMutationBlock) => boolean;
|
|
402
|
-
severity: 'error' | 'warning' | 'info';
|
|
403
|
-
message: string;
|
|
404
|
-
};
|
|
405
|
-
|
|
406
450
|
type ContentTypeToType<C extends keyof ContentTypeMapping> = ContentTypeMapping[C];
|
|
407
451
|
type HandleCardinality<T, C extends 'ONE' | 'MANY'> = C extends 'MANY' ? T[] : T;
|
|
408
452
|
type ContentTypeAndCardinality = {
|
|
@@ -466,8 +510,8 @@ declare class BormClient {
|
|
|
466
510
|
introspect: () => Promise<BormSchema>;
|
|
467
511
|
define: () => Promise<void>;
|
|
468
512
|
query: (query: RawBQLQuery | RawBQLQuery[], queryConfig?: QueryConfig) => Promise<BQLResponse>;
|
|
469
|
-
mutate: (mutation:
|
|
513
|
+
mutate: (mutation: BQLMutation, mutationConfig?: MutationConfig) => Promise<BQLResponseMulti>;
|
|
470
514
|
close: () => Promise<void>;
|
|
471
515
|
}
|
|
472
516
|
|
|
473
|
-
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
|
|
517
|
+
export { type Action, type BQLField, type BQLFieldObj, type BQLMutation, 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 DBHandleKey, type DBHandles, type DataField, type DataFilter, type EnrichedBQLMutationBlock, 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 MutationConfig, type ParsedBQLMutation, type ParsedBQLQuery, type PreHook, type Provider, type ProviderObject, type QueryConfig, type RawBQLMutation, type RawBQLQuery, type RightType, type RoleField, type RootBQLMutationBlock, type TQLEntityMutation, type TQLRequest, type ThingType, type TransFormAction, type TypeDBClusterProviderObject, type TypeDBHandles, type TypeDBProviderObject, type TypeGen, type ValidateAction, type WithBormMetadata, BormClient as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ type QueryConfig = {
|
|
|
20
20
|
simplifiedLinks?: boolean;
|
|
21
21
|
debugger?: boolean;
|
|
22
22
|
};
|
|
23
|
-
type
|
|
23
|
+
type MutationConfig = {
|
|
24
24
|
noMetadata?: boolean;
|
|
25
25
|
preQuery?: boolean;
|
|
26
26
|
ignoreNonexistingThings?: boolean;
|
|
@@ -30,7 +30,7 @@ type BormConfig = {
|
|
|
30
30
|
provider: 'blitz-orm-js';
|
|
31
31
|
};
|
|
32
32
|
query?: QueryConfig;
|
|
33
|
-
mutation?:
|
|
33
|
+
mutation?: MutationConfig;
|
|
34
34
|
dbConnectors: [ProviderObject, ...ProviderObject[]];
|
|
35
35
|
};
|
|
36
36
|
type ProviderObject = (TypeDBProviderObject & CommonProperties) | (TypeDBClusterProviderObject & CommonProperties);
|
|
@@ -45,11 +45,17 @@ type DBConnector = {
|
|
|
45
45
|
path?: string;
|
|
46
46
|
as?: string;
|
|
47
47
|
};
|
|
48
|
-
type
|
|
48
|
+
type AllDbHandles = {
|
|
49
49
|
typeDB: TypeDBHandles;
|
|
50
|
+
surrealDB: any;
|
|
50
51
|
};
|
|
52
|
+
type AtLeastOne<T, U = {
|
|
53
|
+
[K in keyof T]: Pick<T, K>;
|
|
54
|
+
}> = Partial<T> & U[keyof U];
|
|
55
|
+
type DBHandles = AtLeastOne<AllDbHandles>;
|
|
56
|
+
type DBHandleKey = keyof DBHandles;
|
|
51
57
|
|
|
52
|
-
type ThingType = 'entity' | 'relation'
|
|
58
|
+
type ThingType = 'entity' | 'relation';
|
|
53
59
|
type BormMetadata = {
|
|
54
60
|
$id: string;
|
|
55
61
|
$op?: string;
|
|
@@ -84,6 +90,66 @@ type DataFilter = RequireAtLeastOne<{
|
|
|
84
90
|
$ge?: number | string;
|
|
85
91
|
}>;
|
|
86
92
|
|
|
93
|
+
type BormSchema = {
|
|
94
|
+
entities: {
|
|
95
|
+
[s: string]: BormEntity;
|
|
96
|
+
};
|
|
97
|
+
relations: {
|
|
98
|
+
[s: string]: BormRelation;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
type BormEntity = {
|
|
102
|
+
extends: string;
|
|
103
|
+
idFields?: readonly string[];
|
|
104
|
+
defaultDBConnector: DBConnector;
|
|
105
|
+
dataFields?: readonly DataField[];
|
|
106
|
+
linkFields?: readonly LinkField[];
|
|
107
|
+
hooks?: Hooks;
|
|
108
|
+
} | {
|
|
109
|
+
idFields: readonly string[];
|
|
110
|
+
defaultDBConnector: DBConnector;
|
|
111
|
+
dataFields?: readonly DataField[];
|
|
112
|
+
linkFields?: readonly LinkField[];
|
|
113
|
+
hooks?: Hooks;
|
|
114
|
+
};
|
|
115
|
+
type BormRelation = BormEntity & {
|
|
116
|
+
defaultDBConnector: DBConnector & {
|
|
117
|
+
path: string;
|
|
118
|
+
};
|
|
119
|
+
roles?: {
|
|
120
|
+
[key: string]: RoleField;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
type BormOperation = 'create' | 'update' | 'delete' | 'link' | 'unlink' | 'replace' | 'match';
|
|
124
|
+
type BormTrigger = 'onCreate' | 'onUpdate' | 'onDelete' | 'onLink' | 'onUnlink' | 'onReplace' | 'onMatch';
|
|
125
|
+
type Hooks = {
|
|
126
|
+
pre?: readonly PreHook[];
|
|
127
|
+
};
|
|
128
|
+
type PreHook = {
|
|
129
|
+
triggers: {
|
|
130
|
+
[K in BormTrigger]?: () => boolean;
|
|
131
|
+
};
|
|
132
|
+
actions: readonly Action[];
|
|
133
|
+
};
|
|
134
|
+
type Action = TransFormAction | ValidateAction;
|
|
135
|
+
type TransFormAction = {
|
|
136
|
+
type: 'transform';
|
|
137
|
+
fn: (currentNode: FilledBQLMutationBlock, parentNode?: FilledBQLMutationBlock) => Partial<FilledBQLMutationBlock>;
|
|
138
|
+
};
|
|
139
|
+
type ValidateAction = {
|
|
140
|
+
type: 'validate';
|
|
141
|
+
fn: (currentNode: FilledBQLMutationBlock, parentNode: FilledBQLMutationBlock) => boolean;
|
|
142
|
+
severity: 'error' | 'warning' | 'info';
|
|
143
|
+
message: string;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
type AdapterContext = {
|
|
147
|
+
mutation: {
|
|
148
|
+
splitArray$Ids: boolean;
|
|
149
|
+
requiresParseBQL: boolean;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
|
|
87
153
|
type BormField = {
|
|
88
154
|
path: string;
|
|
89
155
|
cardinality?: CardinalityType;
|
|
@@ -231,6 +297,8 @@ type SharedEnrichedProps = {
|
|
|
231
297
|
fnValidatedFields: string[];
|
|
232
298
|
linkFields?: EnrichedLinkField[];
|
|
233
299
|
dataFields?: EnrichedDataField[];
|
|
300
|
+
db: DBHandleKey;
|
|
301
|
+
dbContext: AdapterContext;
|
|
234
302
|
};
|
|
235
303
|
type EnrichedBormEntity = Omit<BormEntity, 'linkFields' | 'idFields' | 'dataFields'> & {
|
|
236
304
|
extends?: string;
|
|
@@ -247,6 +315,7 @@ type EnrichedBormRelation = Omit<BormRelation, 'linkFields' | 'dataFields'> & {
|
|
|
247
315
|
type EnrichedRoleField = RoleField & {
|
|
248
316
|
playedBy?: LinkedFieldWithThing[];
|
|
249
317
|
name: string;
|
|
318
|
+
fieldType: 'roleField';
|
|
250
319
|
};
|
|
251
320
|
type EnrichedDataField = DataField & {
|
|
252
321
|
dbPath: string;
|
|
@@ -255,6 +324,7 @@ type EnrichedLinkField = BormField & {
|
|
|
255
324
|
name: string;
|
|
256
325
|
relation: string;
|
|
257
326
|
plays: string;
|
|
327
|
+
fieldType: 'linkField';
|
|
258
328
|
} & ({
|
|
259
329
|
target: 'role';
|
|
260
330
|
filter?: Filter | Filter[];
|
|
@@ -265,12 +335,15 @@ type EnrichedLinkField = BormField & {
|
|
|
265
335
|
});
|
|
266
336
|
|
|
267
337
|
declare const Schema: unique symbol;
|
|
338
|
+
declare const EdgeType: unique symbol;
|
|
339
|
+
declare const EdgeSchema: unique symbol;
|
|
268
340
|
|
|
269
341
|
type RequiredKey<T, K extends keyof T> = T & {
|
|
270
342
|
[P in K]-?: T[P];
|
|
271
343
|
};
|
|
272
344
|
type WithRequired<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> & RequiredKey<T, K>;
|
|
273
|
-
type
|
|
345
|
+
type BQLMutation = RootBQLMutationBlock | RootBQLMutationBlock[];
|
|
346
|
+
type RootBQLMutationBlock = {
|
|
274
347
|
[key: string]: any;
|
|
275
348
|
$id?: string | string[];
|
|
276
349
|
$filter?: Filter | Filter[];
|
|
@@ -282,11 +355,35 @@ type BQLMutationBlock = {
|
|
|
282
355
|
$relation: string;
|
|
283
356
|
} | {
|
|
284
357
|
$thing: string;
|
|
285
|
-
$thingType
|
|
358
|
+
$thingType?: 'entity' | 'relation';
|
|
286
359
|
});
|
|
287
|
-
type
|
|
360
|
+
type BQLMutationBlock = {
|
|
361
|
+
[key: string]: any;
|
|
362
|
+
$id?: string | string[];
|
|
363
|
+
$filter?: Filter | Filter[];
|
|
364
|
+
$tempId?: string;
|
|
365
|
+
$op?: string;
|
|
288
366
|
$entity?: string;
|
|
289
|
-
|
|
367
|
+
$relation?: string;
|
|
368
|
+
$thing?: string;
|
|
369
|
+
$thingType?: 'entity' | 'relation';
|
|
370
|
+
};
|
|
371
|
+
type FilledBQLMutationBlock = WithRequired<BQLMutationBlock, '$op'> & {
|
|
372
|
+
$entity?: string;
|
|
373
|
+
$relation?: string;
|
|
374
|
+
[Schema]?: EnrichedBormEntity | EnrichedBormRelation;
|
|
375
|
+
[EdgeType]?: 'linkField' | 'roleField';
|
|
376
|
+
};
|
|
377
|
+
type EnrichedBQLMutationBlock = {
|
|
378
|
+
[key: string]: any;
|
|
379
|
+
$id?: string | string[];
|
|
380
|
+
$filter?: Filter | Filter[];
|
|
381
|
+
$tempId?: string;
|
|
382
|
+
$op: BormOperation;
|
|
383
|
+
$thing: string;
|
|
384
|
+
$thingType: 'entity' | 'relation';
|
|
385
|
+
[EdgeSchema]?: EnrichedDataField | EnrichedLinkField | EnrichedRoleField;
|
|
386
|
+
[EdgeType]?: 'linkField' | 'roleField';
|
|
290
387
|
};
|
|
291
388
|
type RawBQLMutation<T extends Record<string, any> = Record<string, any>> = ({
|
|
292
389
|
$id?: string;
|
|
@@ -350,59 +447,6 @@ type TQLEntityMutation = {
|
|
|
350
447
|
}[];
|
|
351
448
|
};
|
|
352
449
|
|
|
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
|
-
idFields: readonly string[];
|
|
370
|
-
defaultDBConnector: DBConnector;
|
|
371
|
-
dataFields?: readonly DataField[];
|
|
372
|
-
linkFields?: readonly LinkField[];
|
|
373
|
-
hooks?: Hooks;
|
|
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 = TransFormAction | ValidateAction;
|
|
395
|
-
type TransFormAction = {
|
|
396
|
-
type: 'transform';
|
|
397
|
-
fn: (currentNode: FilledBQLMutationBlock, parentNode?: FilledBQLMutationBlock) => Partial<FilledBQLMutationBlock>;
|
|
398
|
-
};
|
|
399
|
-
type ValidateAction = {
|
|
400
|
-
type: 'validate';
|
|
401
|
-
fn: (currentNode: FilledBQLMutationBlock, parentNode: FilledBQLMutationBlock) => boolean;
|
|
402
|
-
severity: 'error' | 'warning' | 'info';
|
|
403
|
-
message: string;
|
|
404
|
-
};
|
|
405
|
-
|
|
406
450
|
type ContentTypeToType<C extends keyof ContentTypeMapping> = ContentTypeMapping[C];
|
|
407
451
|
type HandleCardinality<T, C extends 'ONE' | 'MANY'> = C extends 'MANY' ? T[] : T;
|
|
408
452
|
type ContentTypeAndCardinality = {
|
|
@@ -466,8 +510,8 @@ declare class BormClient {
|
|
|
466
510
|
introspect: () => Promise<BormSchema>;
|
|
467
511
|
define: () => Promise<void>;
|
|
468
512
|
query: (query: RawBQLQuery | RawBQLQuery[], queryConfig?: QueryConfig) => Promise<BQLResponse>;
|
|
469
|
-
mutate: (mutation:
|
|
513
|
+
mutate: (mutation: BQLMutation, mutationConfig?: MutationConfig) => Promise<BQLResponseMulti>;
|
|
470
514
|
close: () => Promise<void>;
|
|
471
515
|
}
|
|
472
516
|
|
|
473
|
-
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
|
|
517
|
+
export { type Action, type BQLField, type BQLFieldObj, type BQLMutation, 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 DBHandleKey, type DBHandles, type DataField, type DataFilter, type EnrichedBQLMutationBlock, 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 MutationConfig, type ParsedBQLMutation, type ParsedBQLQuery, type PreHook, type Provider, type ProviderObject, type QueryConfig, type RawBQLMutation, type RawBQLQuery, type RightType, type RoleField, type RootBQLMutationBlock, type TQLEntityMutation, type TQLRequest, type ThingType, type TransFormAction, type TypeDBClusterProviderObject, type TypeDBHandles, type TypeDBProviderObject, type TypeGen, type ValidateAction, type WithBormMetadata, BormClient as default };
|