@tailor-platform/sdk 1.15.2 → 1.17.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/CHANGELOG.md +46 -0
- package/dist/application-D5ZEr4zk.mjs +4 -0
- package/dist/{application-DLUgR1gv.mjs → application-DYfVZVPT.mjs} +4812 -69
- package/dist/application-DYfVZVPT.mjs.map +1 -0
- package/dist/cli/index.mjs +3 -3
- package/dist/cli/lib.d.mts +164 -30
- package/dist/cli/lib.mjs +3 -3
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/configure/index.d.mts +3 -3
- package/dist/configure/index.mjs +46 -2
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{index-Bg_UJxhL.d.mts → index-qQXpN674.d.mts} +136 -11
- package/dist/job-CULA2Pvf.mjs +51 -0
- package/dist/job-CULA2Pvf.mjs.map +1 -0
- package/dist/plugin/index.d.mts +1 -1
- package/dist/{schema-DRYB-nzA.mjs → schema-R5TxC5Pn.mjs} +143 -1
- package/dist/schema-R5TxC5Pn.mjs.map +1 -0
- package/dist/{index-pQbghcVa.d.mts → types-BeNtD-fA.d.mts} +88 -115
- package/dist/{types-BZRw-Iys.d.mts → types-DzvazVmg.d.mts} +220 -18
- package/dist/types-b-ig8nW_.mjs.map +1 -1
- package/dist/update-DQKCUNmr.mjs +10701 -0
- package/dist/update-DQKCUNmr.mjs.map +1 -0
- package/dist/utils/test/index.d.mts +3 -3
- package/dist/utils/test/index.mjs +1 -1
- package/package.json +1 -1
- package/postinstall.mjs +2 -2
- package/dist/application-DLUgR1gv.mjs.map +0 -1
- package/dist/application-DhvHS3pX.mjs +0 -4
- package/dist/job-XiwGyFJt.mjs +0 -21
- package/dist/job-XiwGyFJt.mjs.map +0 -1
- package/dist/schema-DRYB-nzA.mjs.map +0 -1
- package/dist/update-70uX2TDG.mjs +0 -15424
- package/dist/update-70uX2TDG.mjs.map +0 -1
|
@@ -52,6 +52,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
52
52
|
"=": "=";
|
|
53
53
|
"!=": "!=";
|
|
54
54
|
"not in": "not in";
|
|
55
|
+
hasAny: "hasAny";
|
|
56
|
+
"not hasAny": "not hasAny";
|
|
55
57
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
56
58
|
user: z.ZodString;
|
|
57
59
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -73,6 +75,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
73
75
|
"=": "=";
|
|
74
76
|
"!=": "!=";
|
|
75
77
|
"not in": "not in";
|
|
78
|
+
hasAny: "hasAny";
|
|
79
|
+
"not hasAny": "not hasAny";
|
|
76
80
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
77
81
|
user: z.ZodString;
|
|
78
82
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -97,6 +101,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
97
101
|
"=": "=";
|
|
98
102
|
"!=": "!=";
|
|
99
103
|
"not in": "not in";
|
|
104
|
+
hasAny: "hasAny";
|
|
105
|
+
"not hasAny": "not hasAny";
|
|
100
106
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
101
107
|
user: z.ZodString;
|
|
102
108
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -118,6 +124,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
118
124
|
"=": "=";
|
|
119
125
|
"!=": "!=";
|
|
120
126
|
"not in": "not in";
|
|
127
|
+
hasAny: "hasAny";
|
|
128
|
+
"not hasAny": "not hasAny";
|
|
121
129
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
122
130
|
user: z.ZodString;
|
|
123
131
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -139,6 +147,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
139
147
|
"=": "=";
|
|
140
148
|
"!=": "!=";
|
|
141
149
|
"not in": "not in";
|
|
150
|
+
hasAny: "hasAny";
|
|
151
|
+
"not hasAny": "not hasAny";
|
|
142
152
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
143
153
|
user: z.ZodString;
|
|
144
154
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -162,6 +172,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
162
172
|
"=": "=";
|
|
163
173
|
"!=": "!=";
|
|
164
174
|
"not in": "not in";
|
|
175
|
+
hasAny: "hasAny";
|
|
176
|
+
"not hasAny": "not hasAny";
|
|
165
177
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
166
178
|
user: z.ZodString;
|
|
167
179
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -183,6 +195,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
183
195
|
"=": "=";
|
|
184
196
|
"!=": "!=";
|
|
185
197
|
"not in": "not in";
|
|
198
|
+
hasAny: "hasAny";
|
|
199
|
+
"not hasAny": "not hasAny";
|
|
186
200
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
187
201
|
user: z.ZodString;
|
|
188
202
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -207,6 +221,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
207
221
|
"=": "=";
|
|
208
222
|
"!=": "!=";
|
|
209
223
|
"not in": "not in";
|
|
224
|
+
hasAny: "hasAny";
|
|
225
|
+
"not hasAny": "not hasAny";
|
|
210
226
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
211
227
|
user: z.ZodString;
|
|
212
228
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -228,6 +244,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
228
244
|
"=": "=";
|
|
229
245
|
"!=": "!=";
|
|
230
246
|
"not in": "not in";
|
|
247
|
+
hasAny: "hasAny";
|
|
248
|
+
"not hasAny": "not hasAny";
|
|
231
249
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
232
250
|
user: z.ZodString;
|
|
233
251
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -249,6 +267,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
249
267
|
"=": "=";
|
|
250
268
|
"!=": "!=";
|
|
251
269
|
"not in": "not in";
|
|
270
|
+
hasAny: "hasAny";
|
|
271
|
+
"not hasAny": "not hasAny";
|
|
252
272
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
253
273
|
user: z.ZodString;
|
|
254
274
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -272,6 +292,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
272
292
|
"=": "=";
|
|
273
293
|
"!=": "!=";
|
|
274
294
|
"not in": "not in";
|
|
295
|
+
hasAny: "hasAny";
|
|
296
|
+
"not hasAny": "not hasAny";
|
|
275
297
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
276
298
|
user: z.ZodString;
|
|
277
299
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -293,6 +315,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
293
315
|
"=": "=";
|
|
294
316
|
"!=": "!=";
|
|
295
317
|
"not in": "not in";
|
|
318
|
+
hasAny: "hasAny";
|
|
319
|
+
"not hasAny": "not hasAny";
|
|
296
320
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
297
321
|
user: z.ZodString;
|
|
298
322
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -317,6 +341,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
317
341
|
"=": "=";
|
|
318
342
|
"!=": "!=";
|
|
319
343
|
"not in": "not in";
|
|
344
|
+
hasAny: "hasAny";
|
|
345
|
+
"not hasAny": "not hasAny";
|
|
320
346
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
321
347
|
user: z.ZodString;
|
|
322
348
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -338,6 +364,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
338
364
|
"=": "=";
|
|
339
365
|
"!=": "!=";
|
|
340
366
|
"not in": "not in";
|
|
367
|
+
hasAny: "hasAny";
|
|
368
|
+
"not hasAny": "not hasAny";
|
|
341
369
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
342
370
|
user: z.ZodString;
|
|
343
371
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -359,6 +387,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
359
387
|
"=": "=";
|
|
360
388
|
"!=": "!=";
|
|
361
389
|
"not in": "not in";
|
|
390
|
+
hasAny: "hasAny";
|
|
391
|
+
"not hasAny": "not hasAny";
|
|
362
392
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
363
393
|
user: z.ZodString;
|
|
364
394
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -382,6 +412,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
382
412
|
"=": "=";
|
|
383
413
|
"!=": "!=";
|
|
384
414
|
"not in": "not in";
|
|
415
|
+
hasAny: "hasAny";
|
|
416
|
+
"not hasAny": "not hasAny";
|
|
385
417
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
386
418
|
user: z.ZodString;
|
|
387
419
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -403,6 +435,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
403
435
|
"=": "=";
|
|
404
436
|
"!=": "!=";
|
|
405
437
|
"not in": "not in";
|
|
438
|
+
hasAny: "hasAny";
|
|
439
|
+
"not hasAny": "not hasAny";
|
|
406
440
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
407
441
|
user: z.ZodString;
|
|
408
442
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -427,6 +461,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
427
461
|
"=": "=";
|
|
428
462
|
"!=": "!=";
|
|
429
463
|
"not in": "not in";
|
|
464
|
+
hasAny: "hasAny";
|
|
465
|
+
"not hasAny": "not hasAny";
|
|
430
466
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
431
467
|
user: z.ZodString;
|
|
432
468
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -448,6 +484,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
448
484
|
"=": "=";
|
|
449
485
|
"!=": "!=";
|
|
450
486
|
"not in": "not in";
|
|
487
|
+
hasAny: "hasAny";
|
|
488
|
+
"not hasAny": "not hasAny";
|
|
451
489
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
452
490
|
user: z.ZodString;
|
|
453
491
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -469,6 +507,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
469
507
|
"=": "=";
|
|
470
508
|
"!=": "!=";
|
|
471
509
|
"not in": "not in";
|
|
510
|
+
hasAny: "hasAny";
|
|
511
|
+
"not hasAny": "not hasAny";
|
|
472
512
|
}>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
473
513
|
user: z.ZodString;
|
|
474
514
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>, z.ZodObject<{
|
|
@@ -487,6 +527,8 @@ declare const RawPermissionsSchema: z.ZodObject<{
|
|
|
487
527
|
"=": "=";
|
|
488
528
|
"!=": "!=";
|
|
489
529
|
"not in": "not in";
|
|
530
|
+
hasAny: "hasAny";
|
|
531
|
+
"not hasAny": "not hasAny";
|
|
490
532
|
}>, z.ZodUnion<readonly [z.ZodObject<{
|
|
491
533
|
user: z.ZodString;
|
|
492
534
|
}, z.core.$strict>, z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodBoolean>]>], null>>>>;
|
|
@@ -635,11 +677,11 @@ declare const TailorFieldSchema: z.ZodObject<{
|
|
|
635
677
|
type: z.ZodEnum<{
|
|
636
678
|
string: "string";
|
|
637
679
|
boolean: "boolean";
|
|
638
|
-
date: "date";
|
|
639
|
-
enum: "enum";
|
|
640
680
|
uuid: "uuid";
|
|
641
681
|
integer: "integer";
|
|
642
682
|
float: "float";
|
|
683
|
+
enum: "enum";
|
|
684
|
+
date: "date";
|
|
643
685
|
datetime: "datetime";
|
|
644
686
|
time: "time";
|
|
645
687
|
nested: "nested";
|
|
@@ -668,11 +710,11 @@ declare const ResolverSchema: z.ZodObject<{
|
|
|
668
710
|
type: z.ZodEnum<{
|
|
669
711
|
string: "string";
|
|
670
712
|
boolean: "boolean";
|
|
671
|
-
date: "date";
|
|
672
|
-
enum: "enum";
|
|
673
713
|
uuid: "uuid";
|
|
674
714
|
integer: "integer";
|
|
675
715
|
float: "float";
|
|
716
|
+
enum: "enum";
|
|
717
|
+
date: "date";
|
|
676
718
|
datetime: "datetime";
|
|
677
719
|
time: "time";
|
|
678
720
|
nested: "nested";
|
|
@@ -698,11 +740,11 @@ declare const ResolverSchema: z.ZodObject<{
|
|
|
698
740
|
type: z.ZodEnum<{
|
|
699
741
|
string: "string";
|
|
700
742
|
boolean: "boolean";
|
|
701
|
-
date: "date";
|
|
702
|
-
enum: "enum";
|
|
703
743
|
uuid: "uuid";
|
|
704
744
|
integer: "integer";
|
|
705
745
|
float: "float";
|
|
746
|
+
enum: "enum";
|
|
747
|
+
date: "date";
|
|
706
748
|
datetime: "datetime";
|
|
707
749
|
time: "time";
|
|
708
750
|
nested: "nested";
|
|
@@ -909,6 +951,22 @@ type ArrayFieldOutput<T, O extends FieldOptions> = [O] extends [{
|
|
|
909
951
|
}] ? T[] : T;
|
|
910
952
|
//#endregion
|
|
911
953
|
//#region src/configure/services/tailordb/permission.d.ts
|
|
954
|
+
/**
|
|
955
|
+
* Record-level permission configuration for a TailorDB type.
|
|
956
|
+
* Defines create, read, update, and delete permissions.
|
|
957
|
+
*
|
|
958
|
+
* Prefer object format with explicit `conditions` and `permit` for readability.
|
|
959
|
+
* Shorthand array format is supported for compatibility, but less readable.
|
|
960
|
+
*
|
|
961
|
+
* For update operations, use `newRecord`/`oldRecord` operands instead of `record`.
|
|
962
|
+
* @example
|
|
963
|
+
* const permission: TailorTypePermission = {
|
|
964
|
+
* create: [{ conditions: [[{ user: "_loggedIn" }, "=", true]], permit: true }],
|
|
965
|
+
* read: [{ conditions: [[{ record: "isPublic" }, "=", true]], permit: true }],
|
|
966
|
+
* update: [{ conditions: [[{ newRecord: "ownerId" }, "=", { user: "id" }]], permit: true }],
|
|
967
|
+
* delete: [{ conditions: [[{ record: "ownerId" }, "=", { user: "id" }]], permit: true }],
|
|
968
|
+
* };
|
|
969
|
+
*/
|
|
912
970
|
type TailorTypePermission<User extends object = InferredAttributeMap, Type extends object = object> = {
|
|
913
971
|
create: readonly ActionPermission<"record", User, Type, false>[];
|
|
914
972
|
read: readonly ActionPermission<"record", User, Type, false>[];
|
|
@@ -930,6 +988,7 @@ type GqlPermissionPolicy<User extends object = InferredAttributeMap, Type extend
|
|
|
930
988
|
type GqlPermissionAction$1 = "read" | "create" | "update" | "delete" | "aggregate" | "bulkUpsert";
|
|
931
989
|
type EqualityOperator = "=" | "!=";
|
|
932
990
|
type ContainsOperator = "in" | "not in";
|
|
991
|
+
type HasAnyOperator = "hasAny" | "not hasAny";
|
|
933
992
|
type StringFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string ? K : never }[keyof User];
|
|
934
993
|
type StringArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string[] ? K : never }[keyof User];
|
|
935
994
|
type BooleanFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean ? K : never }[keyof User];
|
|
@@ -959,6 +1018,7 @@ type EqualityCondition<Level extends "record" | "gql" = "record", User extends o
|
|
|
959
1018
|
type StringContainsCondition<Level extends "record" | "gql", User extends object, Update extends boolean, Type extends object> = readonly [string, ContainsOperator, string[]] | readonly [UserStringOperand<User>, ContainsOperator, string[]] | readonly [string, ContainsOperator, UserStringArrayOperand<User>] | (Level extends "record" ? readonly [RecordOperand$1<Type, Update>, ContainsOperator, string[] | UserStringArrayOperand<User>] | readonly [string | UserStringOperand<User>, ContainsOperator, RecordOperand$1<Type, Update>] : never);
|
|
960
1019
|
type BooleanContainsCondition<Level extends "record" | "gql", User extends object, Update extends boolean, Type extends object> = (Level extends "gql" ? readonly [string, ContainsOperator, boolean[]] : never) | readonly [boolean, ContainsOperator, boolean[]] | readonly [UserBooleanOperand<User>, ContainsOperator, boolean[]] | readonly [boolean, ContainsOperator, UserBooleanArrayOperand<User>] | (Level extends "record" ? readonly [RecordOperand$1<Type, Update>, ContainsOperator, boolean[] | UserBooleanArrayOperand<User>] | readonly [boolean | UserBooleanOperand<User>, ContainsOperator, RecordOperand$1<Type, Update>] : never);
|
|
961
1020
|
type ContainsCondition<Level extends "record" | "gql" = "record", User extends object = InferredAttributeMap, Update extends boolean = boolean, Type extends object = object> = StringContainsCondition<Level, User, Update, Type> | BooleanContainsCondition<Level, User, Update, Type>;
|
|
1021
|
+
type HasAnyCondition<Level extends "record" | "gql", User extends object, Update extends boolean, Type extends object> = readonly [string[] | UserStringArrayOperand<User>, HasAnyOperator, string[] | UserStringArrayOperand<User>] | (Level extends "record" ? readonly [RecordOperand$1<Type, Update>, HasAnyOperator, string[] | UserStringArrayOperand<User>] | readonly [string[] | UserStringArrayOperand<User>, HasAnyOperator, RecordOperand$1<Type, Update>] : never);
|
|
962
1022
|
/**
|
|
963
1023
|
* Type representing a permission condition that combines user attributes, record fields, and literal values using comparison operators.
|
|
964
1024
|
*
|
|
@@ -979,7 +1039,7 @@ type ContainsCondition<Level extends "record" | "gql" = "record", User extends o
|
|
|
979
1039
|
* });
|
|
980
1040
|
* ```
|
|
981
1041
|
*/
|
|
982
|
-
type PermissionCondition<Level extends "record" | "gql" = "record", User extends object = InferredAttributeMap, Update extends boolean = boolean, Type extends object = object> = EqualityCondition<Level, User, Update, Type> | ContainsCondition<Level, User, Update, Type>;
|
|
1042
|
+
type PermissionCondition<Level extends "record" | "gql" = "record", User extends object = InferredAttributeMap, Update extends boolean = boolean, Type extends object = object> = EqualityCondition<Level, User, Update, Type> | ContainsCondition<Level, User, Update, Type> | HasAnyCondition<Level, User, Update, Type>;
|
|
983
1043
|
/**
|
|
984
1044
|
* Grants full record-level access without any conditions.
|
|
985
1045
|
*
|
|
@@ -1457,7 +1517,11 @@ interface TailorDBField<Defined extends DefinedDBFieldMetadata, Output> extends
|
|
|
1457
1517
|
description: true;
|
|
1458
1518
|
}>, Output>;
|
|
1459
1519
|
/**
|
|
1460
|
-
* Define a relation to another type
|
|
1520
|
+
* Define a relation to another type.
|
|
1521
|
+
* Relation types: "n-1" (many-to-one), "1-1" (one-to-one), "keyOnly" (key only).
|
|
1522
|
+
* Aliases "manyToOne", "oneToOne", and "N-1" are also accepted.
|
|
1523
|
+
* @example db.uuid().relation({ type: "n-1", toward: { type: otherModel } })
|
|
1524
|
+
* @example db.uuid().relation({ type: "1-1", toward: { type: profile } })
|
|
1461
1525
|
*/
|
|
1462
1526
|
relation<S extends RelationType, T extends TailorAnyDBType, CurrentDefined extends Defined>(this: CurrentDefined extends {
|
|
1463
1527
|
relation: unknown;
|
|
@@ -1515,7 +1579,10 @@ interface TailorDBField<Defined extends DefinedDBFieldMetadata, Output> extends
|
|
|
1515
1579
|
vector: true;
|
|
1516
1580
|
}>, Output>;
|
|
1517
1581
|
/**
|
|
1518
|
-
* Add hooks for create/update operations
|
|
1582
|
+
* Add hooks for create/update operations on this field.
|
|
1583
|
+
* The hook function receives `{ value, data, user }` and returns the computed value.
|
|
1584
|
+
* @example db.string().hooks({ create: ({ data }) => data.firstName + " " + data.lastName })
|
|
1585
|
+
* @example db.datetime().hooks({ create: () => new Date(), update: () => new Date() })
|
|
1519
1586
|
*/
|
|
1520
1587
|
hooks<CurrentDefined extends Defined, const H extends Hook<unknown, Output>>(this: CurrentDefined extends {
|
|
1521
1588
|
hooks: unknown;
|
|
@@ -1533,7 +1600,15 @@ interface TailorDBField<Defined extends DefinedDBFieldMetadata, Output> extends
|
|
|
1533
1600
|
serial: false;
|
|
1534
1601
|
}>, Output>;
|
|
1535
1602
|
/**
|
|
1536
|
-
* Add validation functions to the field
|
|
1603
|
+
* Add validation functions to the field.
|
|
1604
|
+
* Accepts a function or a tuple of [function, errorMessage].
|
|
1605
|
+
* Prefer the tuple form for diagnosable errors.
|
|
1606
|
+
* @example
|
|
1607
|
+
* // Function form (default error message):
|
|
1608
|
+
* db.int().validate(({ value }) => value >= 0)
|
|
1609
|
+
* @example
|
|
1610
|
+
* // Tuple form with custom error message (recommended):
|
|
1611
|
+
* db.string().validate([({ value }) => value.length >= 8, "Must be at least 8 characters"])
|
|
1537
1612
|
*/
|
|
1538
1613
|
validate<CurrentDefined extends Defined>(this: CurrentDefined extends {
|
|
1539
1614
|
validate: unknown;
|
|
@@ -1566,60 +1641,133 @@ interface TailorDBField<Defined extends DefinedDBFieldMetadata, Output> extends
|
|
|
1566
1641
|
} ? true : Defined["array"];
|
|
1567
1642
|
}>, FieldOutput$1<TailorToTs[Defined["type"]], NewOpt>>;
|
|
1568
1643
|
}
|
|
1644
|
+
/**
|
|
1645
|
+
* Create a UUID field.
|
|
1646
|
+
* @param options - Field configuration options
|
|
1647
|
+
* @returns A UUID field
|
|
1648
|
+
* @example db.uuid()
|
|
1649
|
+
* @example db.uuid({ optional: true })
|
|
1650
|
+
*/
|
|
1569
1651
|
declare function uuid<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
|
|
1570
1652
|
type: "uuid";
|
|
1571
1653
|
array: Opt extends {
|
|
1572
1654
|
array: true;
|
|
1573
1655
|
} ? true : false;
|
|
1574
1656
|
}, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
|
|
1657
|
+
/**
|
|
1658
|
+
* Create a string field.
|
|
1659
|
+
* @param options - Field configuration options
|
|
1660
|
+
* @returns A string field
|
|
1661
|
+
* @example db.string()
|
|
1662
|
+
* @example db.string({ optional: true })
|
|
1663
|
+
*/
|
|
1575
1664
|
declare function string<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
|
|
1576
1665
|
type: "string";
|
|
1577
1666
|
array: Opt extends {
|
|
1578
1667
|
array: true;
|
|
1579
1668
|
} ? true : false;
|
|
1580
1669
|
}, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
|
|
1670
|
+
/**
|
|
1671
|
+
* Create a boolean field.
|
|
1672
|
+
* Note: The method name is `bool` but creates a `boolean` type field.
|
|
1673
|
+
* @param options - Field configuration options
|
|
1674
|
+
* @returns A boolean field
|
|
1675
|
+
* @example db.bool()
|
|
1676
|
+
* @example db.bool({ optional: true })
|
|
1677
|
+
*/
|
|
1581
1678
|
declare function bool<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
|
|
1582
1679
|
type: "boolean";
|
|
1583
1680
|
array: Opt extends {
|
|
1584
1681
|
array: true;
|
|
1585
1682
|
} ? true : false;
|
|
1586
1683
|
}, Opt["optional"] extends true ? ArrayFieldOutput<boolean, Opt> | null : ArrayFieldOutput<boolean, Opt>>;
|
|
1684
|
+
/**
|
|
1685
|
+
* Create an integer field.
|
|
1686
|
+
* @param options - Field configuration options
|
|
1687
|
+
* @returns An integer field
|
|
1688
|
+
* @example db.int()
|
|
1689
|
+
* @example db.int({ optional: true })
|
|
1690
|
+
*/
|
|
1587
1691
|
declare function int<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
|
|
1588
1692
|
type: "integer";
|
|
1589
1693
|
array: Opt extends {
|
|
1590
1694
|
array: true;
|
|
1591
1695
|
} ? true : false;
|
|
1592
1696
|
}, Opt["optional"] extends true ? ArrayFieldOutput<number, Opt> | null : ArrayFieldOutput<number, Opt>>;
|
|
1697
|
+
/**
|
|
1698
|
+
* Create a float (decimal number) field.
|
|
1699
|
+
* @param options - Field configuration options
|
|
1700
|
+
* @returns A float field
|
|
1701
|
+
* @example db.float()
|
|
1702
|
+
* @example db.float({ optional: true })
|
|
1703
|
+
*/
|
|
1593
1704
|
declare function float<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
|
|
1594
1705
|
type: "float";
|
|
1595
1706
|
array: Opt extends {
|
|
1596
1707
|
array: true;
|
|
1597
1708
|
} ? true : false;
|
|
1598
1709
|
}, Opt["optional"] extends true ? ArrayFieldOutput<number, Opt> | null : ArrayFieldOutput<number, Opt>>;
|
|
1710
|
+
/**
|
|
1711
|
+
* Create a date field (date only, no time component).
|
|
1712
|
+
* Format: "yyyy-MM-dd"
|
|
1713
|
+
* @param options - Field configuration options
|
|
1714
|
+
* @returns A date field
|
|
1715
|
+
* @example db.date()
|
|
1716
|
+
*/
|
|
1599
1717
|
declare function date<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
|
|
1600
1718
|
type: "date";
|
|
1601
1719
|
array: Opt extends {
|
|
1602
1720
|
array: true;
|
|
1603
1721
|
} ? true : false;
|
|
1604
1722
|
}, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
|
|
1723
|
+
/**
|
|
1724
|
+
* Create a datetime field (date and time).
|
|
1725
|
+
* Format: ISO 8601 "yyyy-MM-ddTHH:mm:ssZ"
|
|
1726
|
+
* @param options - Field configuration options
|
|
1727
|
+
* @returns A datetime field
|
|
1728
|
+
* @example db.datetime()
|
|
1729
|
+
*/
|
|
1605
1730
|
declare function datetime<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
|
|
1606
1731
|
type: "datetime";
|
|
1607
1732
|
array: Opt extends {
|
|
1608
1733
|
array: true;
|
|
1609
1734
|
} ? true : false;
|
|
1610
1735
|
}, Opt["optional"] extends true ? ArrayFieldOutput<string | Date, Opt> | null : ArrayFieldOutput<string | Date, Opt>>;
|
|
1736
|
+
/**
|
|
1737
|
+
* Create a time field (time only, no date component).
|
|
1738
|
+
* Format: "HH:mm"
|
|
1739
|
+
* @param options - Field configuration options
|
|
1740
|
+
* @returns A time field
|
|
1741
|
+
* @example db.time()
|
|
1742
|
+
*/
|
|
1611
1743
|
declare function time<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
|
|
1612
1744
|
type: "time";
|
|
1613
1745
|
array: Opt extends {
|
|
1614
1746
|
array: true;
|
|
1615
1747
|
} ? true : false;
|
|
1616
1748
|
}, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
|
|
1749
|
+
/**
|
|
1750
|
+
* Create an enum field with a fixed set of allowed string values.
|
|
1751
|
+
* @param values - Array of allowed string values, or array of `{ value, description }` objects
|
|
1752
|
+
* @param options - Field configuration options
|
|
1753
|
+
* @returns An enum field
|
|
1754
|
+
* @example db.enum(["active", "inactive", "suspended"])
|
|
1755
|
+
* @example db.enum(["small", "medium", "large"], { optional: true })
|
|
1756
|
+
*/
|
|
1617
1757
|
declare function _enum<const V extends AllowedValues, const Opt extends FieldOptions>(values: V, options?: Opt): TailorDBField<{
|
|
1618
1758
|
type: "enum";
|
|
1619
1759
|
array: Opt extends {
|
|
1620
1760
|
array: true;
|
|
1621
1761
|
} ? true : false;
|
|
1622
1762
|
}, FieldOutput$1<AllowedValuesOutput<V>, Opt>>;
|
|
1763
|
+
/**
|
|
1764
|
+
* Create a nested object field with sub-fields.
|
|
1765
|
+
* @param fields - Record of nested field definitions
|
|
1766
|
+
* @param options - Field configuration options
|
|
1767
|
+
* @returns A nested object field
|
|
1768
|
+
* @example db.object({ street: db.string(), city: db.string(), zip: db.string() })
|
|
1769
|
+
* @example db.object({ name: db.string() }, { optional: true })
|
|
1770
|
+
*/
|
|
1623
1771
|
declare function object<const F extends Record<string, TailorAnyDBField> & ExcludeNestedDBFields<F>, const Opt extends FieldOptions>(fields: F, options?: Opt): TailorDBField<{
|
|
1624
1772
|
type: "nested";
|
|
1625
1773
|
array: Opt extends {
|
|
@@ -1637,11 +1785,26 @@ interface TailorDBType$1<Fields extends Record<string, TailorAnyDBField> = any,
|
|
|
1637
1785
|
/** Returns metadata for the type */
|
|
1638
1786
|
readonly metadata: TailorDBTypeMetadata;
|
|
1639
1787
|
/**
|
|
1640
|
-
* Add hooks for fields
|
|
1788
|
+
* Add hooks for fields at the type level.
|
|
1789
|
+
* Each key is a field name, and the value defines create/update hooks.
|
|
1790
|
+
* @example
|
|
1791
|
+
* db.type("Order", {
|
|
1792
|
+
* total: db.float(),
|
|
1793
|
+
* tax: db.float(),
|
|
1794
|
+
* ...db.fields.timestamps(),
|
|
1795
|
+
* }).hooks({
|
|
1796
|
+
* tax: { create: ({ data }) => data.total * 0.1, update: ({ data }) => data.total * 0.1 },
|
|
1797
|
+
* })
|
|
1641
1798
|
*/
|
|
1642
1799
|
hooks(hooks: Hooks<Fields>): TailorDBType$1<Fields, User>;
|
|
1643
1800
|
/**
|
|
1644
|
-
* Add validators for fields
|
|
1801
|
+
* Add validators for fields at the type level.
|
|
1802
|
+
* Each key is a field name, and the value is a validator or array of validators.
|
|
1803
|
+
* Prefer the tuple form [function, message] for diagnosable errors.
|
|
1804
|
+
* @example
|
|
1805
|
+
* db.type("User", { email: db.string() }).validate({
|
|
1806
|
+
* email: [({ value }) => value.includes("@"), "Email must contain @"],
|
|
1807
|
+
* })
|
|
1645
1808
|
*/
|
|
1646
1809
|
validate(validators: Validators<Fields>): TailorDBType$1<Fields, User>;
|
|
1647
1810
|
/**
|
|
@@ -1657,11 +1820,28 @@ interface TailorDBType$1<Fields extends Record<string, TailorAnyDBField> = any,
|
|
|
1657
1820
|
*/
|
|
1658
1821
|
files<const F extends string>(files: Record<F, string> & Partial<Record<keyof output<TailorDBType$1<Fields, User>>, never>>): TailorDBType$1<Fields, User>;
|
|
1659
1822
|
/**
|
|
1660
|
-
* Set record-level permissions
|
|
1823
|
+
* Set record-level permissions for create, read, update, and delete operations.
|
|
1824
|
+
* Prefer object format with explicit `conditions` and `permit` for readability.
|
|
1825
|
+
* For update operations, use `newRecord` and `oldRecord` operands.
|
|
1826
|
+
* @example
|
|
1827
|
+
* .permission({
|
|
1828
|
+
* create: [{ conditions: [[{ user: "_loggedIn" }, "=", true]], permit: true }],
|
|
1829
|
+
* read: [{ conditions: [[{ record: "isPublic" }, "=", true]], permit: true }],
|
|
1830
|
+
* update: [{ conditions: [[{ newRecord: "ownerId" }, "=", { user: "id" }]], permit: true }],
|
|
1831
|
+
* delete: [{ conditions: [[{ record: "ownerId" }, "=", { user: "id" }]], permit: true }],
|
|
1832
|
+
* })
|
|
1661
1833
|
*/
|
|
1662
1834
|
permission<U$1 extends object = User, P$1 extends TailorTypePermission<U$1, output<TailorDBType$1<Fields, User>>> = TailorTypePermission<U$1, output<TailorDBType$1<Fields, User>>>>(permission: P$1): TailorDBType$1<Fields, U$1>;
|
|
1663
1835
|
/**
|
|
1664
|
-
* Set GraphQL-level permissions
|
|
1836
|
+
* Set GraphQL-level permissions controlling access to GraphQL operations.
|
|
1837
|
+
* @example
|
|
1838
|
+
* .gqlPermission([
|
|
1839
|
+
* {
|
|
1840
|
+
* conditions: [[{ user: "_loggedIn" }, "=", true]],
|
|
1841
|
+
* actions: "all",
|
|
1842
|
+
* permit: true,
|
|
1843
|
+
* },
|
|
1844
|
+
* ])
|
|
1665
1845
|
*/
|
|
1666
1846
|
gqlPermission<U$1 extends object = User, P$1 extends TailorTypeGqlPermission<U$1> = TailorTypeGqlPermission<U$1>>(permission: P$1): TailorDBType$1<Fields, U$1>;
|
|
1667
1847
|
/**
|
|
@@ -1703,16 +1883,28 @@ type DBType<F extends {
|
|
|
1703
1883
|
id: idField;
|
|
1704
1884
|
} & F>;
|
|
1705
1885
|
/**
|
|
1706
|
-
* Creates a new database type with the specified fields
|
|
1886
|
+
* Creates a new database type with the specified fields.
|
|
1887
|
+
* An `id` field (UUID) is automatically added to every type.
|
|
1707
1888
|
* @param name - The name of the type, or a tuple of [name, pluralForm]
|
|
1708
1889
|
* @param fields - The field definitions for the type
|
|
1709
1890
|
* @returns A new TailorDBType instance
|
|
1891
|
+
* @example
|
|
1892
|
+
* export const user = db.type("User", {
|
|
1893
|
+
* name: db.string(),
|
|
1894
|
+
* email: db.string(),
|
|
1895
|
+
* age: db.int({ optional: true }),
|
|
1896
|
+
* role: db.enum(["admin", "member"]),
|
|
1897
|
+
* ...db.fields.timestamps(),
|
|
1898
|
+
* });
|
|
1899
|
+
* // Always export both the value and type:
|
|
1900
|
+
* export type user = typeof user;
|
|
1710
1901
|
*/
|
|
1711
1902
|
declare function dbType<const F extends {
|
|
1712
1903
|
id?: never;
|
|
1713
1904
|
} & Record<string, TailorAnyDBField>>(name: string | [string, string], fields: F): DBType<F>;
|
|
1714
1905
|
/**
|
|
1715
|
-
* Creates a new database type with the specified fields and description
|
|
1906
|
+
* Creates a new database type with the specified fields and description.
|
|
1907
|
+
* An `id` field (UUID) is automatically added to every type.
|
|
1716
1908
|
* @param name - The name of the type, or a tuple of [name, pluralForm]
|
|
1717
1909
|
* @param description - A description of the type
|
|
1718
1910
|
* @param fields - The field definitions for the type
|
|
@@ -1734,6 +1926,16 @@ declare const db: {
|
|
|
1734
1926
|
enum: typeof _enum;
|
|
1735
1927
|
object: typeof object;
|
|
1736
1928
|
fields: {
|
|
1929
|
+
/**
|
|
1930
|
+
* Creates standard timestamp fields (createdAt, updatedAt) with auto-hooks.
|
|
1931
|
+
* createdAt is set on create, updatedAt is set on update.
|
|
1932
|
+
* @returns An object with createdAt and updatedAt fields
|
|
1933
|
+
* @example
|
|
1934
|
+
* const model = db.type("Model", {
|
|
1935
|
+
* name: db.string(),
|
|
1936
|
+
* ...db.fields.timestamps(),
|
|
1937
|
+
* });
|
|
1938
|
+
*/
|
|
1737
1939
|
timestamps: () => {
|
|
1738
1940
|
createdAt: TailorDBField<{
|
|
1739
1941
|
type: "datetime";
|
|
@@ -2144,7 +2346,7 @@ interface OperatorFieldConfig {
|
|
|
2144
2346
|
fields?: Record<string, OperatorFieldConfig>;
|
|
2145
2347
|
}
|
|
2146
2348
|
type GqlPermissionAction = "read" | "create" | "update" | "delete" | "aggregate" | "bulkUpsert";
|
|
2147
|
-
type StandardPermissionOperator = "eq" | "ne" | "in" | "nin";
|
|
2349
|
+
type StandardPermissionOperator = "eq" | "ne" | "in" | "nin" | "hasAny" | "nhasAny";
|
|
2148
2350
|
type UserOperand = {
|
|
2149
2351
|
user: string;
|
|
2150
2352
|
};
|
|
@@ -2237,4 +2439,4 @@ interface TailorDBType {
|
|
|
2237
2439
|
}
|
|
2238
2440
|
//#endregion
|
|
2239
2441
|
export { unsafeAllowAllTypePermission as $, TailorDBField as A, PluginGeneratedExecutor as B, UserAttributeKey as C, unauthenticatedTailorUser as Ct, ValueOperand as D, UsernameFieldKey as E, TailorDBServiceInput as Et, Plugin as F, PluginOutput as G, PluginGeneratedResolver as H, PluginAttachment as I, TypePluginOutput as J, PluginProcessContext as K, PluginConfigs as L, TailorDBType$1 as M, db as N, TailorAnyDBField as O, NamespacePluginOutput as P, unsafeAllowAllGqlPermission as Q, PluginExecutorContext as R, TenantProviderConfig as S, TailorUser as St, UserAttributeMap as T, AllowedValuesOutput as Tt, PluginGeneratedType as U, PluginGeneratedExecutorWithFile as V, PluginNamespaceProcessContext as W, TailorTypeGqlPermission as X, PermissionCondition as Y, TailorTypePermission as Z, SCIMAttributeMapping as _, Env as _t, AuthInvoker as a, TailorFieldType as at, SCIMConfig as b, AttributeList as bt, BuiltinIdP as c, QueryType as ct, IdProviderConfig as d, ResolverInput as dt, ArrayFieldOutput as et, OAuth2ClientGrantType as f, ResolverServiceConfig as ft, SCIMAttribute as g, output as gt, SAML as h, JsonCompatible as ht, AuthExternalConfig as i, FieldOutput$1 as it, TailorDBInstance as j, TailorAnyDBType as k, DefinedAuth as l, Resolver as lt, OIDC as m, InferFieldsOutput as mt, TypeSourceInfoEntry as n, FieldMetadata as nt, AuthOwnConfig as o, TailorAnyField as ot, OAuth2ClientInput as p, ResolverServiceInput as pt, TailorDBTypeForPlugin as q, AuthConfig as r, FieldOptions as rt, AuthServiceInput as s, TailorField as st, TailorDBType as t, DefinedFieldMetadata as tt, IDToken as u, ResolverExternalConfig as ut, SCIMAttributeType as v, TailorEnv as vt, UserAttributeListKey as w, AllowedValues as wt, SCIMResource as x, AttributeMap as xt, SCIMAuthorization as y, TailorActor as yt, PluginExecutorContextBase as z };
|
|
2240
|
-
//# sourceMappingURL=types-
|
|
2442
|
+
//# sourceMappingURL=types-DzvazVmg.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-b-ig8nW_.mjs","names":[],"sources":["../src/parser/service/tailordb/types.ts"],"sourcesContent":["import type { RelationType } from \"./relation\";\nimport type {\n DBFieldMetadataSchema,\n RawRelationConfigSchema,\n RawPermissionsSchema,\n TailorDBTypeSchema,\n TailorDBServiceConfig as TailorDBServiceConfigType,\n TailorDBTypeSettingsSchema,\n} from \"./schema\";\nimport type { GqlOperationsConfig } from \"@/configure/services/tailordb\";\nimport type { ValueOperand } from \"@/parser/service/auth/types\";\nimport type { z } from \"zod\";\n\nexport type { RelationType } from \"./relation\";\nexport type { TypeSourceInfo } from \"./type-parser\";\n\n// ========================================\n// Source info type for TailorDB types\n// ========================================\n\n/**\n * Source information for a user-defined TailorDB type.\n */\nexport interface UserDefinedTypeSource {\n /** File path to import from */\n filePath: string;\n /** Export name in the source file */\n exportName: string;\n /** Not present for user-defined types */\n pluginId?: never;\n}\n\n/**\n * Source information for a plugin-generated TailorDB type.\n */\nexport interface PluginGeneratedTypeSource {\n /** Not present for plugin-generated types */\n filePath?: never;\n /** Export name of the generated type */\n exportName: string;\n /** Plugin ID that generated this type */\n pluginId: string;\n /** Plugin import path for code generators */\n pluginImportPath: string;\n /** Original type's file path */\n originalFilePath: string;\n /** Original type's export name */\n originalExportName: string;\n /** Generated type kind for getGeneratedType() API (e.g., \"request\", \"step\") */\n generatedTypeKind?: string;\n /** Plugin config used to generate this type */\n pluginConfig?: unknown;\n /** Namespace where this type was generated */\n namespace?: string;\n}\n\n/**\n * Source information for a TailorDB type.\n * Discriminated union: use `pluginId` to distinguish between user-defined and plugin-generated types.\n */\nexport type TypeSourceInfoEntry = UserDefinedTypeSource | PluginGeneratedTypeSource;\n\n/**\n * Type guard to check if source is plugin-generated\n * @param source - Type source info to check\n * @returns True if source is plugin-generated\n */\nexport function isPluginGeneratedType(\n source: TypeSourceInfoEntry,\n): source is PluginGeneratedTypeSource {\n return source.pluginId !== undefined;\n}\n\nexport type {\n TailorAnyDBField,\n TailorAnyDBType,\n TailorDBField,\n DBFieldMetadata,\n Hook,\n TailorTypePermission,\n TailorTypeGqlPermission,\n GqlOperationsConfig,\n GqlOperations,\n} from \"@/configure/services/tailordb\";\nexport type {\n TailorDBServiceConfigInput,\n TailorDBServiceConfig,\n TailorDBExternalConfig,\n TailorDBServiceInput,\n} from \"./schema\";\n\n/**\n * Parsed and normalized settings for TailorDB type.\n * gqlOperations is normalized from alias to object format.\n * @public\n */\nexport type TailorDBTypeParsedSettings = z.output<typeof TailorDBTypeSettingsSchema>;\n\n/**\n * Migration configuration for TailorDB\n * @public\n */\nexport type TailorDBMigrationConfig = NonNullable<TailorDBServiceConfigType[\"migration\"]>;\n\nexport type TailorDBTypeSchemaOutput = z.output<typeof TailorDBTypeSchema>;\n\nexport type DBFieldMetadataOutput = z.output<typeof DBFieldMetadataSchema>;\nexport type RawRelationConfigOutput = z.output<typeof RawRelationConfigSchema>;\n\nexport type RawPermissions = z.output<typeof RawPermissionsSchema>;\n\nexport type TailorDBFieldOutput = {\n type: string;\n fields?: Record<string, TailorDBFieldOutput>;\n metadata: DBFieldMetadataOutput;\n rawRelation?: RawRelationConfigOutput;\n};\n\nexport interface Script {\n expr: string;\n}\n\nexport interface EnumValue {\n value: string;\n description?: string;\n}\n\ninterface OperatorValidateConfig {\n script: Script;\n errorMessage: string;\n}\n\ninterface OperatorFieldHook {\n create?: Script;\n update?: Script;\n}\n\n/**\n * Raw relation config stored in configure layer, processed in parser layer.\n * This is the serialized form of RelationConfig from schema.ts where\n * the TailorDBType reference is replaced with the type name string.\n */\nexport interface RawRelationConfig {\n type: RelationType;\n toward: {\n type: string;\n as?: string;\n key?: string;\n };\n backward?: string;\n}\n\nexport interface OperatorFieldConfig {\n type: string;\n required?: boolean;\n description?: string;\n allowedValues?: EnumValue[];\n array?: boolean;\n index?: boolean;\n unique?: boolean;\n vector?: boolean;\n foreignKey?: boolean;\n foreignKeyType?: string;\n foreignKeyField?: string;\n rawRelation?: RawRelationConfig;\n validate?: OperatorValidateConfig[];\n hooks?: OperatorFieldHook;\n serial?: {\n start: number;\n maxValue?: number;\n format?: string;\n };\n fields?: Record<string, OperatorFieldConfig>;\n}\n\ntype GqlPermissionAction = \"read\" | \"create\" | \"update\" | \"delete\" | \"aggregate\" | \"bulkUpsert\";\n\ntype StandardPermissionOperator = \"eq\" | \"ne\" | \"in\" | \"nin\";\n\ntype UserOperand = {\n user: string;\n};\n\ntype RecordOperand<Update extends boolean = false> = Update extends true\n ? { oldRecord: string } | { newRecord: string }\n : { record: string };\n\nexport type PermissionOperand<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = UserOperand | ValueOperand | (Level extends \"record\" ? RecordOperand<Update> : never);\n\nexport type StandardPermissionCondition<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = readonly [\n PermissionOperand<Level, Update>,\n StandardPermissionOperator,\n PermissionOperand<Level, Update>,\n];\n\nexport type StandardActionPermission<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = {\n conditions: readonly StandardPermissionCondition<Level, Update>[];\n description?: string;\n permit: \"allow\" | \"deny\";\n};\n\nexport type StandardTailorTypePermission = {\n create: readonly StandardActionPermission<\"record\", false>[];\n read: readonly StandardActionPermission<\"record\", false>[];\n update: readonly StandardActionPermission<\"record\", true>[];\n delete: readonly StandardActionPermission<\"record\", false>[];\n};\n\nexport type StandardGqlPermissionPolicy = {\n conditions: readonly StandardPermissionCondition<\"gql\">[];\n actions: readonly [\"all\"] | readonly GqlPermissionAction[];\n permit: \"allow\" | \"deny\";\n description?: string;\n};\n\nexport type StandardTailorTypeGqlPermission = readonly StandardGqlPermissionPolicy[];\n\nexport interface Permissions {\n record?: StandardTailorTypePermission;\n gql?: StandardTailorTypeGqlPermission;\n}\n\nexport interface TailorDBTypeMetadata {\n name: string;\n description?: string;\n settings?: {\n pluralForm?: string;\n aggregation?: boolean;\n bulkUpsert?: boolean;\n gqlOperations?: GqlOperationsConfig;\n };\n permissions: RawPermissions;\n files: Record<string, string>;\n indexes?: Record<\n string,\n {\n fields: string[];\n unique?: boolean;\n }\n >;\n}\n\n/**\n * Parsed and normalized TailorDB field information\n */\nexport interface ParsedField {\n name: string;\n config: OperatorFieldConfig;\n relation?: {\n targetType: string;\n forwardName: string;\n backwardName: string;\n key: string;\n unique: boolean;\n };\n}\n\n/**\n * Parsed and normalized TailorDB relationship information\n */\nexport interface ParsedRelationship {\n name: string;\n targetType: string;\n targetField: string;\n sourceField: string;\n isArray: boolean;\n description: string;\n}\n\n/**\n * Parsed and normalized TailorDB type information\n */\nexport interface TailorDBType {\n name: string;\n pluralForm: string;\n description?: string;\n fields: Record<string, ParsedField>;\n forwardRelationships: Record<string, ParsedRelationship>;\n backwardRelationships: Record<string, ParsedRelationship>;\n settings: TailorDBTypeParsedSettings;\n permissions: Permissions;\n indexes?: TailorDBTypeMetadata[\"indexes\"];\n files?: TailorDBTypeMetadata[\"files\"];\n}\n"],"mappings":";;;;;;AAmEA,SAAgB,sBACd,QACqC;AACrC,QAAO,OAAO,aAAa"}
|
|
1
|
+
{"version":3,"file":"types-b-ig8nW_.mjs","names":[],"sources":["../src/parser/service/tailordb/types.ts"],"sourcesContent":["import type { RelationType } from \"./relation\";\nimport type {\n DBFieldMetadataSchema,\n RawRelationConfigSchema,\n RawPermissionsSchema,\n TailorDBTypeSchema,\n TailorDBServiceConfig as TailorDBServiceConfigType,\n TailorDBTypeSettingsSchema,\n} from \"./schema\";\nimport type { GqlOperationsConfig } from \"@/configure/services/tailordb\";\nimport type { ValueOperand } from \"@/parser/service/auth/types\";\nimport type { z } from \"zod\";\n\nexport type { RelationType } from \"./relation\";\nexport type { TypeSourceInfo } from \"./type-parser\";\n\n// ========================================\n// Source info type for TailorDB types\n// ========================================\n\n/**\n * Source information for a user-defined TailorDB type.\n */\nexport interface UserDefinedTypeSource {\n /** File path to import from */\n filePath: string;\n /** Export name in the source file */\n exportName: string;\n /** Not present for user-defined types */\n pluginId?: never;\n}\n\n/**\n * Source information for a plugin-generated TailorDB type.\n */\nexport interface PluginGeneratedTypeSource {\n /** Not present for plugin-generated types */\n filePath?: never;\n /** Export name of the generated type */\n exportName: string;\n /** Plugin ID that generated this type */\n pluginId: string;\n /** Plugin import path for code generators */\n pluginImportPath: string;\n /** Original type's file path */\n originalFilePath: string;\n /** Original type's export name */\n originalExportName: string;\n /** Generated type kind for getGeneratedType() API (e.g., \"request\", \"step\") */\n generatedTypeKind?: string;\n /** Plugin config used to generate this type */\n pluginConfig?: unknown;\n /** Namespace where this type was generated */\n namespace?: string;\n}\n\n/**\n * Source information for a TailorDB type.\n * Discriminated union: use `pluginId` to distinguish between user-defined and plugin-generated types.\n */\nexport type TypeSourceInfoEntry = UserDefinedTypeSource | PluginGeneratedTypeSource;\n\n/**\n * Type guard to check if source is plugin-generated\n * @param source - Type source info to check\n * @returns True if source is plugin-generated\n */\nexport function isPluginGeneratedType(\n source: TypeSourceInfoEntry,\n): source is PluginGeneratedTypeSource {\n return source.pluginId !== undefined;\n}\n\nexport type {\n TailorAnyDBField,\n TailorAnyDBType,\n TailorDBField,\n DBFieldMetadata,\n Hook,\n TailorTypePermission,\n TailorTypeGqlPermission,\n GqlOperationsConfig,\n GqlOperations,\n} from \"@/configure/services/tailordb\";\nexport type {\n TailorDBServiceConfigInput,\n TailorDBServiceConfig,\n TailorDBExternalConfig,\n TailorDBServiceInput,\n} from \"./schema\";\n\n/**\n * Parsed and normalized settings for TailorDB type.\n * gqlOperations is normalized from alias to object format.\n * @public\n */\nexport type TailorDBTypeParsedSettings = z.output<typeof TailorDBTypeSettingsSchema>;\n\n/**\n * Migration configuration for TailorDB\n * @public\n */\nexport type TailorDBMigrationConfig = NonNullable<TailorDBServiceConfigType[\"migration\"]>;\n\nexport type TailorDBTypeSchemaOutput = z.output<typeof TailorDBTypeSchema>;\n\nexport type DBFieldMetadataOutput = z.output<typeof DBFieldMetadataSchema>;\nexport type RawRelationConfigOutput = z.output<typeof RawRelationConfigSchema>;\n\nexport type RawPermissions = z.output<typeof RawPermissionsSchema>;\n\nexport type TailorDBFieldOutput = {\n type: string;\n fields?: Record<string, TailorDBFieldOutput>;\n metadata: DBFieldMetadataOutput;\n rawRelation?: RawRelationConfigOutput;\n};\n\nexport interface Script {\n expr: string;\n}\n\nexport interface EnumValue {\n value: string;\n description?: string;\n}\n\ninterface OperatorValidateConfig {\n script: Script;\n errorMessage: string;\n}\n\ninterface OperatorFieldHook {\n create?: Script;\n update?: Script;\n}\n\n/**\n * Raw relation config stored in configure layer, processed in parser layer.\n * This is the serialized form of RelationConfig from schema.ts where\n * the TailorDBType reference is replaced with the type name string.\n */\nexport interface RawRelationConfig {\n type: RelationType;\n toward: {\n type: string;\n as?: string;\n key?: string;\n };\n backward?: string;\n}\n\nexport interface OperatorFieldConfig {\n type: string;\n required?: boolean;\n description?: string;\n allowedValues?: EnumValue[];\n array?: boolean;\n index?: boolean;\n unique?: boolean;\n vector?: boolean;\n foreignKey?: boolean;\n foreignKeyType?: string;\n foreignKeyField?: string;\n rawRelation?: RawRelationConfig;\n validate?: OperatorValidateConfig[];\n hooks?: OperatorFieldHook;\n serial?: {\n start: number;\n maxValue?: number;\n format?: string;\n };\n fields?: Record<string, OperatorFieldConfig>;\n}\n\ntype GqlPermissionAction = \"read\" | \"create\" | \"update\" | \"delete\" | \"aggregate\" | \"bulkUpsert\";\n\ntype StandardPermissionOperator = \"eq\" | \"ne\" | \"in\" | \"nin\" | \"hasAny\" | \"nhasAny\";\n\ntype UserOperand = {\n user: string;\n};\n\ntype RecordOperand<Update extends boolean = false> = Update extends true\n ? { oldRecord: string } | { newRecord: string }\n : { record: string };\n\nexport type PermissionOperand<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = UserOperand | ValueOperand | (Level extends \"record\" ? RecordOperand<Update> : never);\n\nexport type StandardPermissionCondition<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = readonly [\n PermissionOperand<Level, Update>,\n StandardPermissionOperator,\n PermissionOperand<Level, Update>,\n];\n\nexport type StandardActionPermission<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = {\n conditions: readonly StandardPermissionCondition<Level, Update>[];\n description?: string;\n permit: \"allow\" | \"deny\";\n};\n\nexport type StandardTailorTypePermission = {\n create: readonly StandardActionPermission<\"record\", false>[];\n read: readonly StandardActionPermission<\"record\", false>[];\n update: readonly StandardActionPermission<\"record\", true>[];\n delete: readonly StandardActionPermission<\"record\", false>[];\n};\n\nexport type StandardGqlPermissionPolicy = {\n conditions: readonly StandardPermissionCondition<\"gql\">[];\n actions: readonly [\"all\"] | readonly GqlPermissionAction[];\n permit: \"allow\" | \"deny\";\n description?: string;\n};\n\nexport type StandardTailorTypeGqlPermission = readonly StandardGqlPermissionPolicy[];\n\nexport interface Permissions {\n record?: StandardTailorTypePermission;\n gql?: StandardTailorTypeGqlPermission;\n}\n\nexport interface TailorDBTypeMetadata {\n name: string;\n description?: string;\n settings?: {\n pluralForm?: string;\n aggregation?: boolean;\n bulkUpsert?: boolean;\n gqlOperations?: GqlOperationsConfig;\n };\n permissions: RawPermissions;\n files: Record<string, string>;\n indexes?: Record<\n string,\n {\n fields: string[];\n unique?: boolean;\n }\n >;\n}\n\n/**\n * Parsed and normalized TailorDB field information\n */\nexport interface ParsedField {\n name: string;\n config: OperatorFieldConfig;\n relation?: {\n targetType: string;\n forwardName: string;\n backwardName: string;\n key: string;\n unique: boolean;\n };\n}\n\n/**\n * Parsed and normalized TailorDB relationship information\n */\nexport interface ParsedRelationship {\n name: string;\n targetType: string;\n targetField: string;\n sourceField: string;\n isArray: boolean;\n description: string;\n}\n\n/**\n * Parsed and normalized TailorDB type information\n */\nexport interface TailorDBType {\n name: string;\n pluralForm: string;\n description?: string;\n fields: Record<string, ParsedField>;\n forwardRelationships: Record<string, ParsedRelationship>;\n backwardRelationships: Record<string, ParsedRelationship>;\n settings: TailorDBTypeParsedSettings;\n permissions: Permissions;\n indexes?: TailorDBTypeMetadata[\"indexes\"];\n files?: TailorDBTypeMetadata[\"files\"];\n}\n"],"mappings":";;;;;;AAmEA,SAAgB,sBACd,QACqC;AACrC,QAAO,OAAO,aAAa"}
|