@blitznocode/blitz-orm 0.9.19 → 0.10.4
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 +184 -60
- package/dist/index.d.ts +184 -60
- package/dist/index.js +38 -52
- package/dist/index.mjs +40 -54
- package/dist/magic-string.es-3CTDYLTI.mjs +15 -0
- package/package.json +20 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { TypeDBCredential, TypeDBDriver, TypeDBSession } from 'typedb-driver';
|
|
2
|
+
import { Surreal } from 'surrealdb.node';
|
|
2
3
|
|
|
3
|
-
interface
|
|
4
|
+
interface TypeDBProvider extends CommonProvider {
|
|
4
5
|
provider: 'typeDB';
|
|
5
6
|
url: string;
|
|
6
7
|
}
|
|
7
|
-
interface
|
|
8
|
+
interface TypeDBClusterProvider extends CommonProvider {
|
|
8
9
|
provider: 'typeDBCluster';
|
|
9
10
|
addresses: string[];
|
|
10
11
|
credentials: TypeDBCredential;
|
|
@@ -14,6 +15,17 @@ type TypeDBHandles = Map<string, {
|
|
|
14
15
|
session: TypeDBSession;
|
|
15
16
|
}>;
|
|
16
17
|
|
|
18
|
+
interface SurrealDBProviderObject extends CommonProvider {
|
|
19
|
+
provider: 'surrealDB';
|
|
20
|
+
url: string;
|
|
21
|
+
namespace: string;
|
|
22
|
+
username: string;
|
|
23
|
+
password: string;
|
|
24
|
+
}
|
|
25
|
+
type SurrealDBHandles = Map<string, {
|
|
26
|
+
client: Surreal;
|
|
27
|
+
}>;
|
|
28
|
+
|
|
17
29
|
type QueryConfig = {
|
|
18
30
|
noMetadata?: boolean;
|
|
19
31
|
returnNulls?: boolean;
|
|
@@ -32,14 +44,13 @@ type BormConfig = {
|
|
|
32
44
|
};
|
|
33
45
|
query?: QueryConfig;
|
|
34
46
|
mutation?: MutationConfig;
|
|
35
|
-
dbConnectors: [
|
|
47
|
+
dbConnectors: [Provider, ...Provider[]];
|
|
36
48
|
};
|
|
37
|
-
type
|
|
38
|
-
interface
|
|
49
|
+
type Provider = TypeDBProvider | TypeDBClusterProvider | SurrealDBProviderObject;
|
|
50
|
+
interface CommonProvider {
|
|
39
51
|
id: string;
|
|
40
52
|
dbName: string;
|
|
41
53
|
}
|
|
42
|
-
type Provider = 'typeDB' | 'typeDBCluster';
|
|
43
54
|
type DBConnector = {
|
|
44
55
|
id: string;
|
|
45
56
|
subs?: string;
|
|
@@ -48,7 +59,7 @@ type DBConnector = {
|
|
|
48
59
|
};
|
|
49
60
|
type AllDbHandles = {
|
|
50
61
|
typeDB: TypeDBHandles;
|
|
51
|
-
surrealDB:
|
|
62
|
+
surrealDB: SurrealDBHandles;
|
|
52
63
|
};
|
|
53
64
|
type AtLeastOne<T, U = {
|
|
54
65
|
[K in keyof T]: Pick<T, K>;
|
|
@@ -68,29 +79,10 @@ type WithBormMetadata<T> = T extends any[] ? T[number] extends object ? Array<Wi
|
|
|
68
79
|
type WithBormMetadataObject<T> = {
|
|
69
80
|
[K in keyof T]: WithBormMetadata<T[K]>;
|
|
70
81
|
} & BormMetadata;
|
|
71
|
-
type BQLResponseSingle = Record<string, any>;
|
|
82
|
+
type BQLResponseSingle = Record<string | symbol, any>;
|
|
72
83
|
type BQLResponseMulti = BQLResponseSingle[];
|
|
73
84
|
type BQLResponse = BQLResponseSingle | BQLResponseMulti;
|
|
74
85
|
|
|
75
|
-
type LinkFilter = {
|
|
76
|
-
$thing?: string;
|
|
77
|
-
$thingType?: string;
|
|
78
|
-
$role?: string;
|
|
79
|
-
[key: string]: string | number | Filter | undefined;
|
|
80
|
-
};
|
|
81
|
-
type Filter = DataFilter | LinkFilter | MiddleFilter;
|
|
82
|
-
type MiddleFilter = {
|
|
83
|
-
$and?: Filter[];
|
|
84
|
-
$or?: Filter[];
|
|
85
|
-
};
|
|
86
|
-
type RequireAtLeastOne<T> = {
|
|
87
|
-
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
|
|
88
|
-
}[keyof T];
|
|
89
|
-
type DataFilter = RequireAtLeastOne<{
|
|
90
|
-
$eq?: any;
|
|
91
|
-
$ge?: number | string;
|
|
92
|
-
}>;
|
|
93
|
-
|
|
94
86
|
type BormSchema = {
|
|
95
87
|
entities: {
|
|
96
88
|
[s: string]: BormEntity;
|
|
@@ -139,7 +131,8 @@ type Action = {
|
|
|
139
131
|
type NodeFunctionParams = [
|
|
140
132
|
currentNode: EnrichedBQLMutationBlock,
|
|
141
133
|
parentNode: EnrichedBQLMutationBlock,
|
|
142
|
-
context: Record<string, any
|
|
134
|
+
context: Record<string, any>,
|
|
135
|
+
dbNode: EnrichedBQLMutationBlock | Record<string, never>
|
|
143
136
|
];
|
|
144
137
|
type TransFormAction = {
|
|
145
138
|
type: 'transform';
|
|
@@ -161,18 +154,18 @@ type AdapterContext = {
|
|
|
161
154
|
|
|
162
155
|
type BormField = {
|
|
163
156
|
path: string;
|
|
164
|
-
cardinality?:
|
|
157
|
+
cardinality?: DiscreteCardinality;
|
|
165
158
|
ordered?: boolean;
|
|
166
159
|
embedded?: boolean;
|
|
167
160
|
rights?: readonly RightType[];
|
|
168
161
|
};
|
|
169
162
|
type RoleField = {
|
|
170
|
-
cardinality:
|
|
163
|
+
cardinality: DiscreteCardinality;
|
|
171
164
|
dbConnector?: DBConnector;
|
|
172
165
|
};
|
|
173
166
|
type LinkField = BormField & {
|
|
174
167
|
relation: string;
|
|
175
|
-
cardinality:
|
|
168
|
+
cardinality: DiscreteCardinality;
|
|
176
169
|
plays: string;
|
|
177
170
|
} & ({
|
|
178
171
|
target: 'role';
|
|
@@ -244,6 +237,7 @@ type BooleanField = BormField & {
|
|
|
244
237
|
};
|
|
245
238
|
type AllDataField = StringField | NumberField | DateField | BooleanField;
|
|
246
239
|
type DataField = BormField & {
|
|
240
|
+
cardinality?: Cardinality;
|
|
247
241
|
shared?: boolean;
|
|
248
242
|
validations?: {
|
|
249
243
|
required?: boolean;
|
|
@@ -281,7 +275,8 @@ type ContentTypeMapping = {
|
|
|
281
275
|
RICH_TEXT: string;
|
|
282
276
|
TEXT: string;
|
|
283
277
|
};
|
|
284
|
-
type
|
|
278
|
+
type DiscreteCardinality = 'ONE' | 'MANY';
|
|
279
|
+
type Cardinality = DiscreteCardinality | 'INTERVAL';
|
|
285
280
|
type RightType = 'CREATE' | 'DELETE' | 'UPDATE' | 'LINK' | 'UNLINK';
|
|
286
281
|
type BQLFieldObj = {
|
|
287
282
|
$path: string;
|
|
@@ -329,7 +324,7 @@ type EnrichedRoleField = RoleField & {
|
|
|
329
324
|
type EnrichedDataField = DataField & {
|
|
330
325
|
dbPath: string;
|
|
331
326
|
};
|
|
332
|
-
type EnrichedLinkField =
|
|
327
|
+
type EnrichedLinkField = LinkField & {
|
|
333
328
|
name: string;
|
|
334
329
|
relation: string;
|
|
335
330
|
plays: string;
|
|
@@ -344,8 +339,133 @@ type EnrichedLinkField = BormField & {
|
|
|
344
339
|
});
|
|
345
340
|
|
|
346
341
|
declare const Schema: unique symbol;
|
|
342
|
+
declare const QueryPath: unique symbol;
|
|
347
343
|
declare const EdgeType: unique symbol;
|
|
348
344
|
declare const EdgeSchema: unique symbol;
|
|
345
|
+
declare const DBNode: unique symbol;
|
|
346
|
+
|
|
347
|
+
type Sorter = {
|
|
348
|
+
field: string;
|
|
349
|
+
desc?: boolean;
|
|
350
|
+
} | string;
|
|
351
|
+
type FilterValue = string | number | boolean | string[] | number[] | boolean[];
|
|
352
|
+
type PositiveFilter = {
|
|
353
|
+
[field: string]: FilterValue;
|
|
354
|
+
};
|
|
355
|
+
type NegativeFilter = {
|
|
356
|
+
$not?: PositiveFilter;
|
|
357
|
+
};
|
|
358
|
+
type Filter = PositiveFilter | NegativeFilter;
|
|
359
|
+
type RawBQLQuery = {
|
|
360
|
+
$id?: string | string[];
|
|
361
|
+
$filter?: Filter;
|
|
362
|
+
$fields?: BQLField[];
|
|
363
|
+
$excludedFields?: BQLField[];
|
|
364
|
+
$sort?: Sorter[];
|
|
365
|
+
$offset?: number;
|
|
366
|
+
$limit?: number;
|
|
367
|
+
} & ({
|
|
368
|
+
$entity: string;
|
|
369
|
+
} | {
|
|
370
|
+
$relation: string;
|
|
371
|
+
} | {
|
|
372
|
+
$thing: string;
|
|
373
|
+
$thingType: 'entity' | 'relation';
|
|
374
|
+
});
|
|
375
|
+
type EnrichedAttributeQuery = {
|
|
376
|
+
$fieldType: 'data';
|
|
377
|
+
$thingType: 'attribute';
|
|
378
|
+
$path: string;
|
|
379
|
+
$dbPath: string;
|
|
380
|
+
$as: string;
|
|
381
|
+
$var: string;
|
|
382
|
+
$justId: boolean;
|
|
383
|
+
$id: string;
|
|
384
|
+
$isVirtual?: boolean;
|
|
385
|
+
};
|
|
386
|
+
type PlayedBy = {
|
|
387
|
+
path: string;
|
|
388
|
+
cardinality: 'ONE' | 'MANY';
|
|
389
|
+
relation: string;
|
|
390
|
+
plays: string;
|
|
391
|
+
target: 'role' | 'relation';
|
|
392
|
+
thing: string;
|
|
393
|
+
thingType: 'entity' | 'relation';
|
|
394
|
+
};
|
|
395
|
+
type EnrichedLinkQuery = {
|
|
396
|
+
$fieldType: 'link';
|
|
397
|
+
$thingType: 'entity' | 'relation';
|
|
398
|
+
$thing: string;
|
|
399
|
+
$plays: string;
|
|
400
|
+
$playedBy: PlayedBy;
|
|
401
|
+
$path: string;
|
|
402
|
+
$dbPath: string;
|
|
403
|
+
$as: string;
|
|
404
|
+
$var: string;
|
|
405
|
+
$fields: EnrichedFieldQuery[];
|
|
406
|
+
$target: 'relation' | 'role';
|
|
407
|
+
$intermediary?: string;
|
|
408
|
+
$justId: boolean;
|
|
409
|
+
$id: string;
|
|
410
|
+
$idNotIncluded?: boolean;
|
|
411
|
+
$filter?: Filter;
|
|
412
|
+
$filterByUnique: boolean;
|
|
413
|
+
$filterProcessed: boolean;
|
|
414
|
+
$sort?: Sorter[];
|
|
415
|
+
$offset?: number;
|
|
416
|
+
$limit?: number;
|
|
417
|
+
[QueryPath]: string;
|
|
418
|
+
};
|
|
419
|
+
type EnrichedRoleQuery = {
|
|
420
|
+
$fieldType: 'role';
|
|
421
|
+
$thingType: 'relation';
|
|
422
|
+
$thing: string;
|
|
423
|
+
$path: string;
|
|
424
|
+
$dbPath: string;
|
|
425
|
+
$as: string;
|
|
426
|
+
$var: string;
|
|
427
|
+
$fields: EnrichedFieldQuery[];
|
|
428
|
+
$intermediary: string;
|
|
429
|
+
$justId: string;
|
|
430
|
+
$id: string;
|
|
431
|
+
$idNotIncluded?: boolean;
|
|
432
|
+
$filter?: Filter;
|
|
433
|
+
$filterByUnique: boolean;
|
|
434
|
+
$playedBy: PlayedBy;
|
|
435
|
+
$filterProcessed: boolean;
|
|
436
|
+
$sort?: Sorter[];
|
|
437
|
+
$offset?: number;
|
|
438
|
+
$limit?: number;
|
|
439
|
+
[QueryPath]: string;
|
|
440
|
+
};
|
|
441
|
+
type EnrichedFieldQuery = EnrichedAttributeQuery | EnrichedLinkQuery | EnrichedRoleQuery;
|
|
442
|
+
type EnrichedEntityQuery = {
|
|
443
|
+
$thingType: 'entity';
|
|
444
|
+
$thing: string;
|
|
445
|
+
$path: string;
|
|
446
|
+
$fields: (EnrichedAttributeQuery | EnrichedLinkQuery)[];
|
|
447
|
+
$idNotIncluded?: boolean;
|
|
448
|
+
$filter?: Filter;
|
|
449
|
+
$filterByUnique: boolean;
|
|
450
|
+
$sort?: Sorter[];
|
|
451
|
+
$offset?: number;
|
|
452
|
+
$limit?: number;
|
|
453
|
+
[QueryPath]: string;
|
|
454
|
+
};
|
|
455
|
+
type EnrichedRelationQuery = {
|
|
456
|
+
$thingType: 'relation';
|
|
457
|
+
$thing: string;
|
|
458
|
+
$path: string;
|
|
459
|
+
$fields: EnrichedFieldQuery[];
|
|
460
|
+
$idNotIncluded?: boolean;
|
|
461
|
+
$filter?: Filter;
|
|
462
|
+
$filterByUnique: boolean;
|
|
463
|
+
$sort?: Sorter[];
|
|
464
|
+
$offset?: number;
|
|
465
|
+
$limit?: number;
|
|
466
|
+
[QueryPath]: string;
|
|
467
|
+
};
|
|
468
|
+
type EnrichedBQLQuery = EnrichedEntityQuery | EnrichedRelationQuery;
|
|
349
469
|
|
|
350
470
|
type RequiredKey<T, K extends keyof T> = T & {
|
|
351
471
|
[P in K]-?: T[P];
|
|
@@ -355,7 +475,7 @@ type BQLMutation = RootBQLMutationBlock | RootBQLMutationBlock[];
|
|
|
355
475
|
type RootBQLMutationBlock = {
|
|
356
476
|
[key: string]: any;
|
|
357
477
|
$id?: string | string[];
|
|
358
|
-
$filter?: Filter
|
|
478
|
+
$filter?: Filter;
|
|
359
479
|
$tempId?: string;
|
|
360
480
|
$op?: string;
|
|
361
481
|
} & ({
|
|
@@ -369,7 +489,7 @@ type RootBQLMutationBlock = {
|
|
|
369
489
|
type BQLMutationBlock = {
|
|
370
490
|
[key: string]: any;
|
|
371
491
|
$id?: string | string[];
|
|
372
|
-
$filter?: Filter
|
|
492
|
+
$filter?: Filter;
|
|
373
493
|
$tempId?: string;
|
|
374
494
|
$op?: string;
|
|
375
495
|
$entity?: string;
|
|
@@ -386,13 +506,15 @@ type FilledBQLMutationBlock = WithRequired<BQLMutationBlock, '$op'> & {
|
|
|
386
506
|
type EnrichedBQLMutationBlock = {
|
|
387
507
|
[key: string]: any;
|
|
388
508
|
$id?: string | string[];
|
|
389
|
-
$filter?: Filter
|
|
509
|
+
$filter?: Filter;
|
|
510
|
+
$fields?: any[];
|
|
390
511
|
$tempId?: string;
|
|
391
512
|
$op: BormOperation;
|
|
392
513
|
$thing: string;
|
|
393
514
|
$thingType: 'entity' | 'relation';
|
|
394
515
|
[EdgeSchema]?: EnrichedDataField | EnrichedLinkField | EnrichedRoleField;
|
|
395
516
|
[EdgeType]?: 'linkField' | 'roleField';
|
|
517
|
+
[DBNode]?: EnrichedBQLMutationBlock | Record<string, never>;
|
|
396
518
|
};
|
|
397
519
|
type RawBQLMutation<T extends Record<string, any> = Record<string, any>> = ({
|
|
398
520
|
$id?: string;
|
|
@@ -408,28 +530,6 @@ type ParsedBQLMutation = {
|
|
|
408
530
|
edges: BQLMutationBlock[];
|
|
409
531
|
};
|
|
410
532
|
|
|
411
|
-
type RawBQLQuery = {
|
|
412
|
-
$id?: string | string[];
|
|
413
|
-
$filter?: Record<string, any>;
|
|
414
|
-
$fields?: BQLField[];
|
|
415
|
-
$excludedFields?: BQLField[];
|
|
416
|
-
} & ({
|
|
417
|
-
$entity: string;
|
|
418
|
-
} | {
|
|
419
|
-
$relation: string;
|
|
420
|
-
} | {
|
|
421
|
-
$thing: string;
|
|
422
|
-
$thingType: 'entity' | 'relation';
|
|
423
|
-
});
|
|
424
|
-
type ParsedBQLQuery = Omit<RawBQLQuery, '$entity' | '$relation' | '$thing' | '$thingType'> & {
|
|
425
|
-
$localFilters?: Record<string, any>;
|
|
426
|
-
$nestedFilters?: Record<string, any>;
|
|
427
|
-
} & ({
|
|
428
|
-
$entity: EnrichedBormEntity;
|
|
429
|
-
} | {
|
|
430
|
-
$relation: EnrichedBormRelation;
|
|
431
|
-
});
|
|
432
|
-
|
|
433
533
|
type TQLRequest = {
|
|
434
534
|
entity?: string;
|
|
435
535
|
roles?: {
|
|
@@ -504,6 +604,30 @@ type ExtractRoles<S> = 'roles' extends keyof S ? {
|
|
|
504
604
|
} : {};
|
|
505
605
|
type TypeGen<S extends BaseSchema> = ExtractDataFields<S> & ExtractLinkFields<S> & ExtractRoles<S>;
|
|
506
606
|
|
|
607
|
+
type Request = {
|
|
608
|
+
rawBqlRequest: RawBQLQuery;
|
|
609
|
+
filledBqlRequest?: FilledBQLMutationBlock[] | FilledBQLMutationBlock;
|
|
610
|
+
bqlRequest?: {
|
|
611
|
+
query?: EnrichedBQLQuery;
|
|
612
|
+
mutation?: ParsedBQLMutation;
|
|
613
|
+
};
|
|
614
|
+
schema: EnrichedBormSchema;
|
|
615
|
+
config: BormConfig;
|
|
616
|
+
tqlRequest?: TQLRequest;
|
|
617
|
+
dbHandles: DBHandles;
|
|
618
|
+
enrichedBqlQuery?: any;
|
|
619
|
+
};
|
|
620
|
+
type BaseResponse = {
|
|
621
|
+
bqlRes?: BQLResponse | null;
|
|
622
|
+
};
|
|
623
|
+
type NextPipeline<Res extends BaseResponse> = {
|
|
624
|
+
req: Request;
|
|
625
|
+
res: Res;
|
|
626
|
+
pipeline: Pipeline<Res>;
|
|
627
|
+
};
|
|
628
|
+
type PipelineOperation<Res extends BaseResponse> = (req: Request, res: Res) => Promise<void | NextPipeline<Res>[]>;
|
|
629
|
+
type Pipeline<Res extends BaseResponse> = PipelineOperation<Res>[];
|
|
630
|
+
|
|
507
631
|
type BormProps = {
|
|
508
632
|
schema: BormSchema;
|
|
509
633
|
config: BormConfig;
|
|
@@ -518,9 +642,9 @@ declare class BormClient {
|
|
|
518
642
|
init: () => Promise<void>;
|
|
519
643
|
introspect: () => Promise<BormSchema>;
|
|
520
644
|
define: () => Promise<void>;
|
|
521
|
-
query: (query: RawBQLQuery | RawBQLQuery[], queryConfig?: QueryConfig) => Promise<BQLResponse>;
|
|
645
|
+
query: (query: RawBQLQuery | RawBQLQuery[], queryConfig?: QueryConfig) => Promise<BQLResponseSingle | BQLResponse[]>;
|
|
522
646
|
mutate: (mutation: BQLMutation, mutationConfig?: MutationConfig) => Promise<BQLResponseMulti>;
|
|
523
647
|
close: () => Promise<void>;
|
|
524
648
|
}
|
|
525
649
|
|
|
526
|
-
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
|
|
650
|
+
export { type Action, type BQLField, type BQLFieldObj, type BQLMutation, type BQLMutationBlock, type BQLResponse, type BQLResponseMulti, type BQLResponseSingle, type BaseResponse, type BormConfig, type BormEntity, type BormField, type BormMetadata, type BormOperation, type BormRelation, type BormSchema, type BormTrigger, type Cardinality, type CommonProvider, type ContentType, type ContentTypeMapping, type DBConnector, type DBHandleKey, type DBHandles, type DataField, type DiscreteCardinality, type EnrichedAttributeQuery, type EnrichedBQLMutationBlock, type EnrichedBQLQuery, type EnrichedBormEntity, type EnrichedBormRelation, type EnrichedBormSchema, type EnrichedDataField, type EnrichedEntityQuery, type EnrichedFieldQuery, type EnrichedLinkField, type EnrichedLinkQuery, type EnrichedRelationQuery, type EnrichedRoleField, type EnrichedRoleQuery, type FilledBQLMutationBlock, type Filter, type FilterValue, type Hooks, type LinkField, type LinkedFieldWithThing, type MutationConfig, type NegativeFilter, type NodeFunctionParams, type ParsedBQLMutation, type Pipeline, type PipelineOperation, type PlayedBy, type PositiveFilter, type PreHook, type Provider, type QueryConfig, type RawBQLMutation, type RawBQLQuery, type Request, type RightType, type RoleField, type RootBQLMutationBlock, type Sorter, type TQLEntityMutation, type TQLRequest, type ThingType, type TransFormAction, type TypeDBClusterProvider, type TypeDBHandles, type TypeDBProvider, type TypeGen, type ValidateAction, type WithBormMetadata, BormClient as default };
|