@blitznocode/blitz-orm 0.0.42 → 0.0.44

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.
@@ -0,0 +1,255 @@
1
+ import { TypeDBClient, TypeDBSession } from 'typedb-client';
2
+
3
+ type BormConfig = {
4
+ server: {
5
+ provider: 'blitz-orm-js';
6
+ };
7
+ query?: {
8
+ noMetadata?: boolean;
9
+ simplifiedLinks?: boolean;
10
+ };
11
+ mutation?: {
12
+ noMetadata?: boolean;
13
+ };
14
+ dbConnectors: [ProviderObject, ...ProviderObject[]];
15
+ };
16
+ type ProviderObject = {
17
+ id: string;
18
+ provider: 'typeDB';
19
+ dbName: string;
20
+ url: string;
21
+ };
22
+ type DBConnector = {
23
+ id: string;
24
+ subs?: string;
25
+ path?: string;
26
+ as?: string;
27
+ };
28
+ type TypeDBHandles = Map<string, {
29
+ client: TypeDBClient;
30
+ session: TypeDBSession;
31
+ }>;
32
+ type DBHandles = {
33
+ typeDB: TypeDBHandles;
34
+ };
35
+ type BormSchema = {
36
+ entities: {
37
+ [s: string]: BormEntity;
38
+ };
39
+ relations: {
40
+ [s: string]: BormRelation;
41
+ };
42
+ };
43
+ type EnrichedBormSchema = {
44
+ entities: {
45
+ [s: string]: EnrichedBormEntity;
46
+ };
47
+ relations: {
48
+ [s: string]: EnrichedBormRelation;
49
+ };
50
+ };
51
+ type BormEntity = {
52
+ extends: string;
53
+ idFields?: string[];
54
+ defaultDBConnector: DBConnector;
55
+ dataFields?: DataField[];
56
+ linkFields?: LinkField[];
57
+ } | {
58
+ extends?: string;
59
+ idFields: string[];
60
+ defaultDBConnector: DBConnector;
61
+ dataFields?: DataField[];
62
+ linkFields?: LinkField[];
63
+ };
64
+ type BormRelation = BormEntity & {
65
+ roles?: {
66
+ [key: string]: RoleField;
67
+ };
68
+ };
69
+ type EnrichedBormEntity = Omit<BormEntity, 'linkFields' | 'idFields' | 'dataFields'> & {
70
+ extends?: string;
71
+ idFields: string[];
72
+ thingType: 'entity';
73
+ name: string;
74
+ computedFields: string[];
75
+ linkFields?: EnrichedLinkField[];
76
+ dataFields?: EnrichedDataField[];
77
+ };
78
+ type EnrichedBormRelation = Omit<BormRelation, 'linkFields' | 'dataFields'> & {
79
+ thingType: 'relation';
80
+ name: string;
81
+ computedFields: string[];
82
+ linkFields?: EnrichedLinkField[];
83
+ dataFields?: EnrichedDataField[];
84
+ roles: {
85
+ [key: string]: EnrichedRoleField;
86
+ };
87
+ };
88
+ type LinkField = BormField & {
89
+ relation: string;
90
+ plays: string;
91
+ } & ({
92
+ target: 'role';
93
+ filter?: Filter | Filter[];
94
+ } | {
95
+ target: 'relation';
96
+ });
97
+ type LinkedFieldWithThing = LinkField & {
98
+ thing: string;
99
+ thingType: ThingType;
100
+ };
101
+ type RequireAtLeastOne<T> = {
102
+ [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
103
+ }[keyof T];
104
+ type LinkFilter = {
105
+ $thing?: string;
106
+ $thingType?: string;
107
+ $role?: string;
108
+ [key: string]: string | number | Filter | undefined;
109
+ };
110
+ type Filter = DataFilter | LinkFilter | MiddleFilter;
111
+ type MiddleFilter = {
112
+ $and?: Filter[];
113
+ $or?: Filter[];
114
+ };
115
+ type DataFilter = RequireAtLeastOne<{
116
+ $eq?: any;
117
+ $ge?: number | string;
118
+ }>;
119
+ type EnrichedLinkField = BormField & {
120
+ name: string;
121
+ relation: string;
122
+ plays: string;
123
+ } & ({
124
+ target: 'role';
125
+ filter?: Filter | Filter[];
126
+ oppositeLinkFieldsPlayedBy: LinkedFieldWithThing[];
127
+ } | {
128
+ target: 'relation';
129
+ oppositeLinkFieldsPlayedBy: Pick<LinkedFieldWithThing, 'thing' | 'thingType' | 'plays'>[];
130
+ });
131
+ type BormField = {
132
+ path: string;
133
+ cardinality: CardinalityType;
134
+ ordered?: boolean;
135
+ embedded?: boolean;
136
+ rights?: RightType[];
137
+ };
138
+ type RoleField = {
139
+ cardinality: CardinalityType;
140
+ dbConnector?: DBConnector;
141
+ };
142
+ type EnrichedRoleField = RoleField & {
143
+ playedBy?: LinkedFieldWithThing[];
144
+ };
145
+ type DataField = BormField & {
146
+ shared?: boolean;
147
+ default?: any;
148
+ contentType: ContentType;
149
+ validations?: any;
150
+ dbConnectors?: [DBConnector, ...DBConnector[]];
151
+ };
152
+ type EnrichedDataField = DataField & {
153
+ dbPath: string;
154
+ };
155
+ type ThingType = 'entity' | 'relation' | 'attribute';
156
+ type RightType = 'CREATE' | 'DELETE' | 'UPDATE' | 'LINK' | 'UNLINK';
157
+ type ContentType = 'ID' | 'JSON' | 'COLOR' | 'BOOLEAN' | 'POINT' | 'FILE' | 'EMAIL' | 'PHONE' | 'WEEK_DAY' | 'DURATION' | 'HOUR' | 'TIME' | 'DATE' | 'RATING' | 'CURRENCY' | 'PERCENTAGE' | 'NUMBER_DECIMAL' | 'NUMBER' | 'URL' | 'PASSWORD' | 'LANGUAGE_TEXT' | 'RICH_TEXT' | 'TEXT';
158
+ type CardinalityType = 'ONE' | 'MANY' | 'INTERVAL';
159
+ type RelationClassType = 'SYMMETRICAL' | 'OWNED';
160
+ type RequiredKey<T, K extends keyof T> = T & {
161
+ [P in K]-?: T[P];
162
+ };
163
+ type WithRequired<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> & RequiredKey<T, K>;
164
+ type BQLMutationBlock = {
165
+ [key: string]: any;
166
+ $id?: string | string[];
167
+ $filter?: Filter | Filter[];
168
+ $tempId?: string;
169
+ $op?: string;
170
+ } & ({
171
+ $entity: string;
172
+ } | {
173
+ $relation: string;
174
+ });
175
+ type FilledBQLMutationBlock = WithRequired<BQLMutationBlock, '$tempId' | '$op'>;
176
+ type BQLFieldObj = {
177
+ $path: string;
178
+ } & Omit<RawBQLQuery, '$entity' | '$relation'>;
179
+ type BQLField = string | BQLFieldObj;
180
+ type RawBQLQuery = {
181
+ $id?: string | string[];
182
+ $filter?: Record<string, any>;
183
+ $fields?: BQLField[];
184
+ } & ({
185
+ $entity: string;
186
+ } | {
187
+ $relation: string;
188
+ });
189
+ type RawBQLMutation = ({
190
+ $entity: string;
191
+ } | {
192
+ $relation: string;
193
+ }) & Record<string, any>;
194
+ type ParsedBQLQuery = Omit<RawBQLQuery, '$entity' | '$relation'> & {
195
+ $localFilters?: Record<string, any>;
196
+ $nestedFilters?: Record<string, any>;
197
+ } & ({
198
+ $entity: EnrichedBormEntity;
199
+ } | {
200
+ $relation: EnrichedBormRelation;
201
+ });
202
+ type ParsedBQLMutation = {
203
+ things: BQLMutationBlock[];
204
+ edges: BQLMutationBlock[];
205
+ };
206
+ type TQLRequest = {
207
+ entity?: string;
208
+ roles?: {
209
+ path: string;
210
+ request: string;
211
+ owner: string;
212
+ }[];
213
+ relations?: {
214
+ relation: string;
215
+ entity: string;
216
+ request: string;
217
+ }[];
218
+ insertionMatches?: string;
219
+ deletionMatches?: string;
220
+ insertions?: string;
221
+ deletions?: string;
222
+ };
223
+ type TQLEntityMutation = {
224
+ entity: string;
225
+ relations?: {
226
+ relation: string;
227
+ entity: string;
228
+ request: string;
229
+ }[];
230
+ };
231
+ type BQLResponseSingle = (({
232
+ $entity: string;
233
+ $id: string;
234
+ } | undefined) & Record<string, any>) | string | null;
235
+ type BQLResponseMulti = BQLResponseSingle[];
236
+ type BQLResponse = BQLResponseSingle | BQLResponseMulti;
237
+
238
+ type BormProps = {
239
+ schema: BormSchema;
240
+ config: BormConfig;
241
+ };
242
+ declare class BormClient {
243
+ #private;
244
+ private schema;
245
+ private config;
246
+ private dbHandles?;
247
+ constructor({ schema, config }: BormProps);
248
+ init: () => Promise<void>;
249
+ introspect: () => Promise<BormSchema>;
250
+ query: (query: RawBQLQuery, queryConfig?: any) => Promise<void | BQLResponse>;
251
+ mutate: (mutation: RawBQLMutation | RawBQLMutation[], mutationConfig?: any) => Promise<void | BQLResponse>;
252
+ close: () => Promise<void>;
253
+ }
254
+
255
+ export { BQLField, BQLFieldObj, BQLMutationBlock, BQLResponse, BQLResponseMulti, BQLResponseSingle, BormConfig, BormEntity, BormField, BormRelation, BormSchema, CardinalityType, ContentType, DBConnector, DBHandles, DataField, DataFilter, EnrichedBormEntity, EnrichedBormRelation, EnrichedBormSchema, EnrichedDataField, EnrichedLinkField, EnrichedRoleField, FilledBQLMutationBlock, Filter, LinkField, LinkFilter, LinkedFieldWithThing, MiddleFilter, ParsedBQLMutation, ParsedBQLQuery, ProviderObject, RawBQLMutation, RawBQLQuery, RelationClassType, RightType, RoleField, TQLEntityMutation, TQLRequest, ThingType, BormClient as default };