@blitznocode/blitz-orm 0.13.10 → 0.14.0

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 CHANGED
@@ -56,6 +56,7 @@ type QueryConfig = {
56
56
  returnNulls?: boolean;
57
57
  simplifiedLinks?: boolean;
58
58
  debugger?: boolean;
59
+ legacySurrealDBAdapter?: boolean;
59
60
  };
60
61
  type MutationConfig = {
61
62
  noMetadata?: boolean;
@@ -159,90 +160,6 @@ type TQLEntityMutation = {
159
160
  }[];
160
161
  };
161
162
 
162
- type BormSchema = {
163
- entities: {
164
- [s: string]: BormEntity;
165
- };
166
- relations: {
167
- [s: string]: BormRelation;
168
- };
169
- };
170
- type BormEntity = {
171
- extends: string;
172
- idFields?: readonly string[];
173
- defaultDBConnector: DBConnector;
174
- dataFields?: readonly DataField[];
175
- linkFields?: readonly LinkField[];
176
- refFields?: {
177
- [key: string]: RefField;
178
- };
179
- hooks?: Hooks;
180
- } | {
181
- idFields: readonly string[];
182
- defaultDBConnector: DBConnector;
183
- dataFields?: readonly DataField[];
184
- linkFields?: readonly LinkField[];
185
- refFields?: {
186
- [key: string]: RefField;
187
- };
188
- hooks?: Hooks;
189
- };
190
- type BormRelation = BormEntity & {
191
- defaultDBConnector: DBConnector & {
192
- path: string;
193
- };
194
- roles?: {
195
- [key: string]: RoleField;
196
- };
197
- };
198
- type BormOperation = 'create' | 'update' | 'delete' | 'link' | 'unlink' | 'replace' | 'match';
199
- type BormTrigger = 'onCreate' | 'onUpdate' | 'onDelete' | 'onLink' | 'onUnlink' | 'onReplace' | 'onMatch';
200
- type Hooks = {
201
- pre?: readonly PreHook[];
202
- };
203
- type PreHook = {
204
- triggers?: {
205
- [K in BormTrigger]?: () => boolean;
206
- };
207
- actions: readonly Action[];
208
- };
209
- type Action = {
210
- name?: string;
211
- description?: string;
212
- } & (TransFormAction | ValidateAction);
213
- type NodeFunctionParams = [
214
- currentNode: EnrichedBQLMutationBlock,
215
- parentNode: EnrichedBQLMutationBlock,
216
- context: Record<string, any>,
217
- dbNode: EnrichedBQLMutationBlock | Record<string, never>
218
- ];
219
- type TransFormAction = {
220
- type: 'transform';
221
- fn: (...args: NodeFunctionParams) => Partial<EnrichedBQLMutationBlock>;
222
- };
223
- type ValidateAction = {
224
- type: 'validate';
225
- fn: (...args: NodeFunctionParams) => boolean;
226
- severity: 'error' | 'warning' | 'info';
227
- message: string;
228
- };
229
-
230
- type AdapterContext = {
231
- mutation: {
232
- splitArray$Ids: boolean;
233
- requiresParseBQL: boolean;
234
- };
235
- };
236
-
237
- declare const Schema: unique symbol;
238
- declare const QueryPath: unique symbol;
239
- declare const EdgeType: unique symbol;
240
- declare const EdgeSchema: unique symbol;
241
- declare const DBNode: unique symbol;
242
- declare const FieldSchema: unique symbol;
243
- declare const SharedMetadata: unique symbol;
244
- declare const SuqlMetadata: unique symbol;
245
-
246
163
  type BormField = {
247
164
  path: string;
248
165
  cardinality?: DiscreteCardinality;
@@ -272,6 +189,7 @@ type LinkField = BormField & {
272
189
  } & ({
273
190
  target: 'role';
274
191
  filter?: Filter | Filter[];
192
+ targetRole: string;
275
193
  } | {
276
194
  target: 'relation';
277
195
  });
@@ -409,6 +327,107 @@ type BQLFieldObj = {
409
327
  } & Omit<RawBQLQuery, '$entity' | '$relation' | '$thing' | '$thingType'>;
410
328
  type BQLField = string | BQLFieldObj;
411
329
 
330
+ /**
331
+ * These types are design for SurrealDB query in mind. For other DBs or for mutation, they may be missing some fields.
332
+ */
333
+
334
+ type Index = SingleIndex | CompositeIndex;
335
+ interface SingleIndex {
336
+ type: 'single';
337
+ field: string;
338
+ }
339
+ interface CompositeIndex {
340
+ type: 'composite';
341
+ fields: [string, ...string[]];
342
+ }
343
+
344
+ type BormSchema = {
345
+ entities: {
346
+ [s: string]: BormEntity;
347
+ };
348
+ relations: {
349
+ [s: string]: BormRelation;
350
+ };
351
+ };
352
+ type BormEntity = {
353
+ extends: string;
354
+ idFields?: readonly string[];
355
+ defaultDBConnector: DBConnector;
356
+ dataFields?: readonly DataField[];
357
+ linkFields?: readonly LinkField[];
358
+ refFields?: {
359
+ [key: string]: RefField;
360
+ };
361
+ hooks?: Hooks;
362
+ indexes?: Index[];
363
+ } | {
364
+ idFields: readonly string[];
365
+ defaultDBConnector: DBConnector;
366
+ dataFields?: readonly DataField[];
367
+ linkFields?: readonly LinkField[];
368
+ refFields?: {
369
+ [key: string]: RefField;
370
+ };
371
+ hooks?: Hooks;
372
+ indexes?: Index[];
373
+ };
374
+ type BormRelation = BormEntity & {
375
+ defaultDBConnector: DBConnector & {
376
+ path: string;
377
+ };
378
+ roles?: {
379
+ [key: string]: RoleField;
380
+ };
381
+ indexes?: Index[];
382
+ };
383
+ type BormOperation = 'create' | 'update' | 'delete' | 'link' | 'unlink' | 'replace' | 'match';
384
+ type BormTrigger = 'onCreate' | 'onUpdate' | 'onDelete' | 'onLink' | 'onUnlink' | 'onReplace' | 'onMatch';
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
+ name?: string;
396
+ description?: string;
397
+ } & (TransFormAction | ValidateAction);
398
+ type NodeFunctionParams = [
399
+ currentNode: EnrichedBQLMutationBlock,
400
+ parentNode: EnrichedBQLMutationBlock,
401
+ context: Record<string, any>,
402
+ dbNode: EnrichedBQLMutationBlock | Record<string, never>
403
+ ];
404
+ type TransFormAction = {
405
+ type: 'transform';
406
+ fn: (...args: NodeFunctionParams) => Partial<EnrichedBQLMutationBlock>;
407
+ };
408
+ type ValidateAction = {
409
+ type: 'validate';
410
+ fn: (...args: NodeFunctionParams) => boolean;
411
+ severity: 'error' | 'warning' | 'info';
412
+ message: string;
413
+ };
414
+
415
+ type AdapterContext = {
416
+ mutation: {
417
+ splitArray$Ids: boolean;
418
+ requiresParseBQL: boolean;
419
+ };
420
+ };
421
+
422
+ declare const Schema: unique symbol;
423
+ declare const QueryPath: unique symbol;
424
+ declare const EdgeType: unique symbol;
425
+ declare const EdgeSchema: unique symbol;
426
+ declare const DBNode: unique symbol;
427
+ declare const FieldSchema: unique symbol;
428
+ declare const SharedMetadata: unique symbol;
429
+ declare const SuqlMetadata: unique symbol;
430
+
412
431
  type EnrichedBormSchema = {
413
432
  entities: {
414
433
  [s: string]: EnrichedBormEntity;