@tailor-platform/sdk 1.11.0 → 1.12.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/application-DM4zTgXU.mjs +4 -0
  3. package/dist/{application-BKBo5tGD.mjs → application-DnWZVbDO.mjs} +164 -26
  4. package/dist/application-DnWZVbDO.mjs.map +1 -0
  5. package/dist/cli/index.mjs +13 -19
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.d.mts +149 -17
  8. package/dist/cli/lib.mjs +132 -4
  9. package/dist/cli/lib.mjs.map +1 -1
  10. package/dist/configure/index.d.mts +4 -3
  11. package/dist/configure/index.mjs +16 -757
  12. package/dist/configure/index.mjs.map +1 -1
  13. package/dist/env-4RO7szrH.d.mts +66 -0
  14. package/dist/{index-D8zIUsWi.d.mts → index-BBr_q3vB.d.mts} +20 -11
  15. package/dist/{index-DcOTucF6.d.mts → index-Bid18Opo.d.mts} +473 -84
  16. package/dist/{jiti-ygK9KoRA.mjs → jiti-DuCiUfMj.mjs} +2 -2
  17. package/dist/{jiti-ygK9KoRA.mjs.map → jiti-DuCiUfMj.mjs.map} +1 -1
  18. package/dist/{job-l-pIR9IY.mjs → job-zGAXCidt.mjs} +1 -1
  19. package/dist/{job-l-pIR9IY.mjs.map → job-zGAXCidt.mjs.map} +1 -1
  20. package/dist/kysely/index.d.mts +25 -0
  21. package/dist/kysely/index.mjs +27 -0
  22. package/dist/kysely/index.mjs.map +1 -0
  23. package/dist/plugin/index.d.mts +105 -0
  24. package/dist/plugin/index.mjs +45 -0
  25. package/dist/plugin/index.mjs.map +1 -0
  26. package/dist/schema-BmKdDzr1.mjs +784 -0
  27. package/dist/schema-BmKdDzr1.mjs.map +1 -0
  28. package/dist/{src-CG8kJBI9.mjs → src-QNTCsO6J.mjs} +2 -2
  29. package/dist/{src-CG8kJBI9.mjs.map → src-QNTCsO6J.mjs.map} +1 -1
  30. package/dist/types-r-ZratAg.mjs +13 -0
  31. package/dist/types-r-ZratAg.mjs.map +1 -0
  32. package/dist/{update-D0muqqOP.mjs → update-B_W-UQnS.mjs} +1626 -390
  33. package/dist/update-B_W-UQnS.mjs.map +1 -0
  34. package/dist/utils/test/index.d.mts +2 -2
  35. package/dist/utils/test/index.mjs +1 -1
  36. package/docs/cli/tailordb.md +0 -12
  37. package/docs/generator/builtin.md +2 -2
  38. package/docs/plugin/custom.md +389 -0
  39. package/docs/plugin/index.md +112 -0
  40. package/docs/services/workflow.md +28 -0
  41. package/package.json +16 -23
  42. package/dist/application-BKBo5tGD.mjs.map +0 -1
  43. package/dist/application-a12-7TT3.mjs +0 -4
  44. package/dist/update-D0muqqOP.mjs.map +0 -1
  45. /package/dist/{chunk-CIV_ash9.mjs → chunk-C3Kl5s5P.mjs} +0 -0
@@ -1,276 +1,6 @@
1
- import { n as createWorkflowJob, t as WORKFLOW_TEST_ENV_KEY } from "../job-l-pIR9IY.mjs";
1
+ import { i as t$1, n as unsafeAllowAllGqlPermission, r as unsafeAllowAllTypePermission, t as db } from "../schema-BmKdDzr1.mjs";
2
+ import { n as createWorkflowJob, t as WORKFLOW_TEST_ENV_KEY } from "../job-zGAXCidt.mjs";
2
3
 
3
- //#region src/configure/types/field.ts
4
- /**
5
- * Normalize allowed values into EnumValue objects with descriptions.
6
- * @param values - Allowed values as strings or EnumValue objects
7
- * @returns Normalized allowed values
8
- */
9
- function mapAllowedValues(values) {
10
- return values.map((value) => {
11
- if (typeof value === "string") return {
12
- value,
13
- description: ""
14
- };
15
- return {
16
- ...value,
17
- description: value.description ?? ""
18
- };
19
- });
20
- }
21
-
22
- //#endregion
23
- //#region src/configure/types/type.ts
24
- const regex$1 = {
25
- uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
26
- date: /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/,
27
- time: /^(?<hour>\d{2}):(?<minute>\d{2})$/,
28
- datetime: /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})T(?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2})(.(?<millisec>\d{3}))?Z$/
29
- };
30
- /**
31
- * Creates a new TailorField instance.
32
- * @param type - Field type
33
- * @param options - Field options
34
- * @param fields - Nested fields for object-like types
35
- * @param values - Allowed values for enum-like fields
36
- * @returns A new TailorField
37
- */
38
- function createTailorField(type, options, fields, values) {
39
- const _metadata = { required: true };
40
- if (options) {
41
- if (options.optional === true) _metadata.required = false;
42
- if (options.array === true) _metadata.array = true;
43
- }
44
- if (values) _metadata.allowedValues = mapAllowedValues(values);
45
- /**
46
- * Validate a single value (not an array element)
47
- * Used internally for array element validation
48
- * @param args - Value, context data, and user
49
- * @returns Array of validation issues
50
- */
51
- function validateValue(args) {
52
- const { value, data, user, pathArray } = args;
53
- const issues = [];
54
- switch (type) {
55
- case "string":
56
- if (typeof value !== "string") issues.push({
57
- message: `Expected a string: received ${String(value)}`,
58
- path: pathArray.length > 0 ? pathArray : void 0
59
- });
60
- break;
61
- case "integer":
62
- if (typeof value !== "number" || !Number.isInteger(value)) issues.push({
63
- message: `Expected an integer: received ${String(value)}`,
64
- path: pathArray.length > 0 ? pathArray : void 0
65
- });
66
- break;
67
- case "float":
68
- if (typeof value !== "number" || !Number.isFinite(value)) issues.push({
69
- message: `Expected a number: received ${String(value)}`,
70
- path: pathArray.length > 0 ? pathArray : void 0
71
- });
72
- break;
73
- case "boolean":
74
- if (typeof value !== "boolean") issues.push({
75
- message: `Expected a boolean: received ${String(value)}`,
76
- path: pathArray.length > 0 ? pathArray : void 0
77
- });
78
- break;
79
- case "uuid":
80
- if (typeof value !== "string" || !regex$1.uuid.test(value)) issues.push({
81
- message: `Expected a valid UUID: received ${String(value)}`,
82
- path: pathArray.length > 0 ? pathArray : void 0
83
- });
84
- break;
85
- case "date":
86
- if (typeof value !== "string" || !regex$1.date.test(value)) issues.push({
87
- message: `Expected to match "yyyy-MM-dd" format: received ${String(value)}`,
88
- path: pathArray.length > 0 ? pathArray : void 0
89
- });
90
- break;
91
- case "datetime":
92
- if (typeof value !== "string" || !regex$1.datetime.test(value)) issues.push({
93
- message: `Expected to match ISO format: received ${String(value)}`,
94
- path: pathArray.length > 0 ? pathArray : void 0
95
- });
96
- break;
97
- case "time":
98
- if (typeof value !== "string" || !regex$1.time.test(value)) issues.push({
99
- message: `Expected to match "HH:mm" format: received ${String(value)}`,
100
- path: pathArray.length > 0 ? pathArray : void 0
101
- });
102
- break;
103
- case "enum":
104
- if (field._metadata.allowedValues) {
105
- const allowedValues = field._metadata.allowedValues.map((v) => v.value);
106
- if (typeof value !== "string" || !allowedValues.includes(value)) issues.push({
107
- message: `Must be one of [${allowedValues.join(", ")}]: received ${String(value)}`,
108
- path: pathArray.length > 0 ? pathArray : void 0
109
- });
110
- }
111
- break;
112
- case "nested":
113
- if (typeof value !== "object" || value === null || Array.isArray(value) || value instanceof Date) issues.push({
114
- message: `Expected an object: received ${String(value)}`,
115
- path: pathArray.length > 0 ? pathArray : void 0
116
- });
117
- else if (field.fields && Object.keys(field.fields).length > 0) for (const [fieldName, nestedField] of Object.entries(field.fields)) {
118
- const fieldValue = value?.[fieldName];
119
- const result = nestedField._parseInternal({
120
- value: fieldValue,
121
- data,
122
- user,
123
- pathArray: pathArray.concat(fieldName)
124
- });
125
- if (result.issues) issues.push(...result.issues);
126
- }
127
- break;
128
- }
129
- const validateFns = field._metadata.validate;
130
- if (validateFns && validateFns.length > 0) for (const validateInput of validateFns) {
131
- const { fn, message } = typeof validateInput === "function" ? {
132
- fn: validateInput,
133
- message: "Validation failed"
134
- } : {
135
- fn: validateInput[0],
136
- message: validateInput[1]
137
- };
138
- if (!fn({
139
- value,
140
- data,
141
- user
142
- })) issues.push({
143
- message,
144
- path: pathArray.length > 0 ? pathArray : void 0
145
- });
146
- }
147
- return issues;
148
- }
149
- /**
150
- * Internal parse method that tracks field path for nested validation
151
- * @param args - Parse arguments
152
- * @returns Parse result with value or issues
153
- */
154
- function parseInternal(args) {
155
- const { value, data, user, pathArray } = args;
156
- const issues = [];
157
- const isNullOrUndefined = value === null || value === void 0;
158
- if (field._metadata.required && isNullOrUndefined) {
159
- issues.push({
160
- message: "Required field is missing",
161
- path: pathArray.length > 0 ? pathArray : void 0
162
- });
163
- return { issues };
164
- }
165
- if (!field._metadata.required && isNullOrUndefined) return { value: value ?? null };
166
- if (field._metadata.array) {
167
- if (!Array.isArray(value)) {
168
- issues.push({
169
- message: "Expected an array",
170
- path: pathArray.length > 0 ? pathArray : void 0
171
- });
172
- return { issues };
173
- }
174
- for (let i = 0; i < value.length; i++) {
175
- const elementValue = value[i];
176
- const elementIssues = validateValue({
177
- value: elementValue,
178
- data,
179
- user,
180
- pathArray: pathArray.concat(`[${i}]`)
181
- });
182
- if (elementIssues.length > 0) issues.push(...elementIssues);
183
- }
184
- if (issues.length > 0) return { issues };
185
- return { value };
186
- }
187
- const valueIssues = validateValue({
188
- value,
189
- data,
190
- user,
191
- pathArray
192
- });
193
- issues.push(...valueIssues);
194
- if (issues.length > 0) return { issues };
195
- return { value };
196
- }
197
- const field = {
198
- type,
199
- fields: fields ?? {},
200
- _defined: void 0,
201
- _output: void 0,
202
- _metadata,
203
- get metadata() {
204
- return { ...this._metadata };
205
- },
206
- description(description) {
207
- this._metadata.description = description;
208
- return this;
209
- },
210
- typeName(typeName) {
211
- this._metadata.typeName = typeName;
212
- return this;
213
- },
214
- validate(...validateInputs) {
215
- this._metadata.validate = validateInputs;
216
- return this;
217
- },
218
- parse(args) {
219
- return parseInternal({
220
- value: args.value,
221
- data: args.data,
222
- user: args.user,
223
- pathArray: []
224
- });
225
- },
226
- _parseInternal: parseInternal
227
- };
228
- return field;
229
- }
230
- function uuid$1(options) {
231
- return createTailorField("uuid", options);
232
- }
233
- function string$1(options) {
234
- return createTailorField("string", options);
235
- }
236
- function bool$1(options) {
237
- return createTailorField("boolean", options);
238
- }
239
- function int$1(options) {
240
- return createTailorField("integer", options);
241
- }
242
- function float$1(options) {
243
- return createTailorField("float", options);
244
- }
245
- function date$1(options) {
246
- return createTailorField("date", options);
247
- }
248
- function datetime$1(options) {
249
- return createTailorField("datetime", options);
250
- }
251
- function time$1(options) {
252
- return createTailorField("time", options);
253
- }
254
- function _enum$1(values, options) {
255
- return createTailorField("enum", options, void 0, values);
256
- }
257
- function object$1(fields, options) {
258
- return createTailorField("nested", options, fields);
259
- }
260
- const t$1 = {
261
- uuid: uuid$1,
262
- string: string$1,
263
- bool: bool$1,
264
- int: int$1,
265
- float: float$1,
266
- date: date$1,
267
- datetime: datetime$1,
268
- time: time$1,
269
- enum: _enum$1,
270
- object: object$1
271
- };
272
-
273
- //#endregion
274
4
  //#region src/configure/types/user.ts
275
5
  /** Represents an unauthenticated user in the Tailor platform. */
276
6
  const unauthenticatedTailorUser = {
@@ -281,490 +11,6 @@ const unauthenticatedTailorUser = {
281
11
  attributeList: []
282
12
  };
283
13
 
284
- //#endregion
285
- //#region src/configure/services/tailordb/permission.ts
286
- /**
287
- * Grants full record-level access without any conditions.
288
- *
289
- * Unsafe and intended only for local development, prototyping, or tests.
290
- * Do not use this in production environments, as it effectively disables
291
- * authorization checks.
292
- */
293
- const unsafeAllowAllTypePermission = {
294
- create: [{
295
- conditions: [],
296
- permit: true
297
- }],
298
- read: [{
299
- conditions: [],
300
- permit: true
301
- }],
302
- update: [{
303
- conditions: [],
304
- permit: true
305
- }],
306
- delete: [{
307
- conditions: [],
308
- permit: true
309
- }]
310
- };
311
- /**
312
- * Grants full GraphQL access (all actions) without any conditions.
313
- *
314
- * Unsafe and intended only for local development, prototyping, or tests.
315
- * Do not use this in production environments, as it effectively disables
316
- * authorization checks.
317
- */
318
- const unsafeAllowAllGqlPermission = [{
319
- conditions: [],
320
- actions: "all",
321
- permit: true
322
- }];
323
-
324
- //#endregion
325
- //#region src/configure/services/tailordb/schema.ts
326
- function isRelationSelfConfig(config) {
327
- return config.toward.type === "self";
328
- }
329
- const regex = {
330
- uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
331
- date: /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/,
332
- time: /^(?<hour>\d{2}):(?<minute>\d{2})$/,
333
- datetime: /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})T(?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2})(.(?<millisec>\d{3}))?Z$/
334
- };
335
- /**
336
- * Creates a new TailorDBField instance.
337
- * @param type - Field type
338
- * @param options - Field options
339
- * @param fields - Nested fields for object-like types
340
- * @param values - Allowed values for enum-like fields
341
- * @returns A new TailorDBField
342
- */
343
- function createTailorDBField(type, options, fields, values) {
344
- const _metadata = { required: true };
345
- let _rawRelation;
346
- if (options) {
347
- if (options.optional === true) _metadata.required = false;
348
- if (options.array === true) _metadata.array = true;
349
- }
350
- if (values) _metadata.allowedValues = mapAllowedValues(values);
351
- /**
352
- * Validate a single value (not an array element)
353
- * Used internally for array element validation
354
- * @param args - Value, context data, and user
355
- * @returns Array of validation issues
356
- */
357
- function validateValue(args) {
358
- const { value, data, user, pathArray } = args;
359
- const issues = [];
360
- switch (type) {
361
- case "string":
362
- if (typeof value !== "string") issues.push({
363
- message: `Expected a string: received ${String(value)}`,
364
- path: pathArray.length > 0 ? pathArray : void 0
365
- });
366
- break;
367
- case "integer":
368
- if (typeof value !== "number" || !Number.isInteger(value)) issues.push({
369
- message: `Expected an integer: received ${String(value)}`,
370
- path: pathArray.length > 0 ? pathArray : void 0
371
- });
372
- break;
373
- case "float":
374
- if (typeof value !== "number" || !Number.isFinite(value)) issues.push({
375
- message: `Expected a number: received ${String(value)}`,
376
- path: pathArray.length > 0 ? pathArray : void 0
377
- });
378
- break;
379
- case "boolean":
380
- if (typeof value !== "boolean") issues.push({
381
- message: `Expected a boolean: received ${String(value)}`,
382
- path: pathArray.length > 0 ? pathArray : void 0
383
- });
384
- break;
385
- case "uuid":
386
- if (typeof value !== "string" || !regex.uuid.test(value)) issues.push({
387
- message: `Expected a valid UUID: received ${String(value)}`,
388
- path: pathArray.length > 0 ? pathArray : void 0
389
- });
390
- break;
391
- case "date":
392
- if (typeof value !== "string" || !regex.date.test(value)) issues.push({
393
- message: `Expected to match "yyyy-MM-dd" format: received ${String(value)}`,
394
- path: pathArray.length > 0 ? pathArray : void 0
395
- });
396
- break;
397
- case "datetime":
398
- if (typeof value !== "string" || !regex.datetime.test(value)) issues.push({
399
- message: `Expected to match ISO format: received ${String(value)}`,
400
- path: pathArray.length > 0 ? pathArray : void 0
401
- });
402
- break;
403
- case "time":
404
- if (typeof value !== "string" || !regex.time.test(value)) issues.push({
405
- message: `Expected to match "HH:mm" format: received ${String(value)}`,
406
- path: pathArray.length > 0 ? pathArray : void 0
407
- });
408
- break;
409
- case "enum":
410
- if (field._metadata.allowedValues) {
411
- const allowedValues = field._metadata.allowedValues.map((v) => v.value);
412
- if (typeof value !== "string" || !allowedValues.includes(value)) issues.push({
413
- message: `Must be one of [${allowedValues.join(", ")}]: received ${String(value)}`,
414
- path: pathArray.length > 0 ? pathArray : void 0
415
- });
416
- }
417
- break;
418
- case "nested":
419
- if (typeof value !== "object" || value === null || Array.isArray(value) || value instanceof Date) issues.push({
420
- message: `Expected an object: received ${String(value)}`,
421
- path: pathArray.length > 0 ? pathArray : void 0
422
- });
423
- else if (field.fields && Object.keys(field.fields).length > 0) for (const [fieldName, nestedField] of Object.entries(field.fields)) {
424
- const fieldValue = value?.[fieldName];
425
- const result = nestedField._parseInternal({
426
- value: fieldValue,
427
- data,
428
- user,
429
- pathArray: pathArray.concat(fieldName)
430
- });
431
- if (result.issues) issues.push(...result.issues);
432
- }
433
- break;
434
- }
435
- const validateFns = field._metadata.validate;
436
- if (validateFns && validateFns.length > 0) for (const validateInput of validateFns) {
437
- const { fn, message } = typeof validateInput === "function" ? {
438
- fn: validateInput,
439
- message: "Validation failed"
440
- } : {
441
- fn: validateInput[0],
442
- message: validateInput[1]
443
- };
444
- if (!fn({
445
- value,
446
- data,
447
- user
448
- })) issues.push({
449
- message,
450
- path: pathArray.length > 0 ? pathArray : void 0
451
- });
452
- }
453
- return issues;
454
- }
455
- /**
456
- * Internal parse method that tracks field path for nested validation
457
- * @param args - Parse arguments
458
- * @returns Parse result with value or issues
459
- */
460
- function parseInternal(args) {
461
- const { value, data, user, pathArray } = args;
462
- const issues = [];
463
- const isNullOrUndefined = value === null || value === void 0;
464
- if (field._metadata.required && isNullOrUndefined) {
465
- issues.push({
466
- message: "Required field is missing",
467
- path: pathArray.length > 0 ? pathArray : void 0
468
- });
469
- return { issues };
470
- }
471
- if (!field._metadata.required && isNullOrUndefined) return { value: value ?? null };
472
- if (field._metadata.array) {
473
- if (!Array.isArray(value)) {
474
- issues.push({
475
- message: "Expected an array",
476
- path: pathArray.length > 0 ? pathArray : void 0
477
- });
478
- return { issues };
479
- }
480
- for (let i = 0; i < value.length; i++) {
481
- const elementValue = value[i];
482
- const elementIssues = validateValue({
483
- value: elementValue,
484
- data,
485
- user,
486
- pathArray: pathArray.concat(`[${i}]`)
487
- });
488
- if (elementIssues.length > 0) issues.push(...elementIssues);
489
- }
490
- if (issues.length > 0) return { issues };
491
- return { value };
492
- }
493
- const valueIssues = validateValue({
494
- value,
495
- data,
496
- user,
497
- pathArray
498
- });
499
- issues.push(...valueIssues);
500
- if (issues.length > 0) return { issues };
501
- return { value };
502
- }
503
- const field = {
504
- type,
505
- fields: fields ?? {},
506
- _defined: void 0,
507
- _output: void 0,
508
- _metadata,
509
- get metadata() {
510
- return { ...this._metadata };
511
- },
512
- get rawRelation() {
513
- return _rawRelation ? {
514
- ..._rawRelation,
515
- toward: { ..._rawRelation.toward }
516
- } : void 0;
517
- },
518
- description(description) {
519
- this._metadata.description = description;
520
- return this;
521
- },
522
- typeName(typeName) {
523
- this._metadata.typeName = typeName;
524
- return this;
525
- },
526
- validate(...validateInputs) {
527
- this._metadata.validate = validateInputs;
528
- return this;
529
- },
530
- parse(args) {
531
- return parseInternal({
532
- value: args.value,
533
- data: args.data,
534
- user: args.user,
535
- pathArray: []
536
- });
537
- },
538
- _parseInternal: parseInternal,
539
- relation(config) {
540
- const targetType = isRelationSelfConfig(config) ? "self" : config.toward.type.name;
541
- _rawRelation = {
542
- type: config.type,
543
- toward: {
544
- type: targetType,
545
- as: config.toward.as,
546
- key: config.toward.key
547
- },
548
- backward: config.backward
549
- };
550
- return this;
551
- },
552
- index() {
553
- this._metadata.index = true;
554
- return this;
555
- },
556
- unique() {
557
- this._metadata.unique = true;
558
- this._metadata.index = true;
559
- return this;
560
- },
561
- vector() {
562
- this._metadata.vector = true;
563
- return this;
564
- },
565
- hooks(hooks) {
566
- this._metadata.hooks = hooks;
567
- return this;
568
- },
569
- serial(config) {
570
- this._metadata.serial = config;
571
- return this;
572
- },
573
- clone(cloneOptions) {
574
- const clonedField = createTailorDBField(type, options, fields, values);
575
- Object.assign(clonedField._metadata, this._metadata);
576
- if (cloneOptions) {
577
- if (cloneOptions.optional !== void 0) clonedField._metadata.required = !cloneOptions.optional;
578
- if (cloneOptions.array !== void 0) clonedField._metadata.array = cloneOptions.array;
579
- }
580
- if (_rawRelation) {
581
- const clonedRawRelation = {
582
- ..._rawRelation,
583
- toward: { ..._rawRelation.toward }
584
- };
585
- clonedField._setRawRelation(clonedRawRelation);
586
- }
587
- return clonedField;
588
- },
589
- _setRawRelation(relation) {
590
- _rawRelation = relation;
591
- }
592
- };
593
- return field;
594
- }
595
- const createField = createTailorDBField;
596
- function uuid(options) {
597
- return createField("uuid", options);
598
- }
599
- function string(options) {
600
- return createField("string", options);
601
- }
602
- function bool(options) {
603
- return createField("boolean", options);
604
- }
605
- function int(options) {
606
- return createField("integer", options);
607
- }
608
- function float(options) {
609
- return createField("float", options);
610
- }
611
- function date(options) {
612
- return createField("date", options);
613
- }
614
- function datetime(options) {
615
- return createField("datetime", options);
616
- }
617
- function time(options) {
618
- return createField("time", options);
619
- }
620
- function _enum(values, options) {
621
- return createField("enum", options, void 0, values);
622
- }
623
- function object(fields, options) {
624
- return createField("nested", options, fields);
625
- }
626
- /**
627
- * Creates a new TailorDBType instance.
628
- * @param name - Type name
629
- * @param fields - Field definitions
630
- * @param options - Type options
631
- * @param options.pluralForm - Optional plural form
632
- * @param options.description - Optional description
633
- * @returns A new TailorDBType
634
- */
635
- function createTailorDBType(name, fields, options) {
636
- let _description = options.description;
637
- let _settings = {};
638
- let _indexes = [];
639
- const _permissions = {};
640
- let _files = {};
641
- if (options.pluralForm) {
642
- if (name === options.pluralForm) throw new Error(`The name and the plural form must be different. name=${name}`);
643
- _settings.pluralForm = options.pluralForm;
644
- }
645
- return {
646
- name,
647
- fields,
648
- _output: null,
649
- _description,
650
- get metadata() {
651
- const indexes = {};
652
- if (_indexes && _indexes.length > 0) _indexes.forEach((index) => {
653
- const fieldNames = index.fields.map((field) => String(field));
654
- const key = index.name || `idx_${fieldNames.join("_")}`;
655
- indexes[key] = {
656
- fields: fieldNames,
657
- unique: index.unique
658
- };
659
- });
660
- return {
661
- name: this.name,
662
- description: _description,
663
- settings: _settings,
664
- permissions: _permissions,
665
- files: _files,
666
- ...Object.keys(indexes).length > 0 && { indexes }
667
- };
668
- },
669
- hooks(hooks) {
670
- Object.entries(hooks).forEach(([fieldName, fieldHooks]) => {
671
- this.fields[fieldName].hooks(fieldHooks);
672
- });
673
- return this;
674
- },
675
- validate(validators) {
676
- Object.entries(validators).forEach(([fieldName, fieldValidators]) => {
677
- const field = this.fields[fieldName];
678
- const validators$1 = fieldValidators;
679
- const isValidateConfig = (v) => {
680
- return Array.isArray(v) && v.length === 2 && typeof v[1] === "string";
681
- };
682
- if (Array.isArray(validators$1)) if (isValidateConfig(validators$1)) field.validate(validators$1);
683
- else field.validate(...validators$1);
684
- else field.validate(validators$1);
685
- });
686
- return this;
687
- },
688
- features(features) {
689
- _settings = {
690
- ..._settings,
691
- ...features
692
- };
693
- return this;
694
- },
695
- indexes(...indexes) {
696
- _indexes = indexes;
697
- return this;
698
- },
699
- files(files) {
700
- _files = files;
701
- return this;
702
- },
703
- permission(permission) {
704
- const ret = this;
705
- _permissions.record = permission;
706
- return ret;
707
- },
708
- gqlPermission(permission) {
709
- const ret = this;
710
- _permissions.gql = permission;
711
- return ret;
712
- },
713
- description(description) {
714
- _description = description;
715
- this._description = description;
716
- return this;
717
- },
718
- pickFields(keys, options$1) {
719
- const result = {};
720
- for (const key of keys) if (options$1) result[key] = this.fields[key].clone(options$1);
721
- else result[key] = this.fields[key];
722
- return result;
723
- },
724
- omitFields(keys) {
725
- const keysSet = new Set(keys);
726
- const result = {};
727
- for (const key in this.fields) if (Object.hasOwn(this.fields, key) && !keysSet.has(key)) result[key] = this.fields[key];
728
- return result;
729
- }
730
- };
731
- }
732
- const idField = uuid();
733
- function dbType(name, fieldsOrDescription, fields) {
734
- const typeName = Array.isArray(name) ? name[0] : name;
735
- const pluralForm = Array.isArray(name) ? name[1] : void 0;
736
- let description;
737
- let fieldDef;
738
- if (typeof fieldsOrDescription === "string") {
739
- description = fieldsOrDescription;
740
- fieldDef = fields;
741
- } else fieldDef = fieldsOrDescription;
742
- return createTailorDBType(typeName, {
743
- id: idField,
744
- ...fieldDef
745
- }, {
746
- pluralForm,
747
- description
748
- });
749
- }
750
- const db = {
751
- type: dbType,
752
- uuid,
753
- string,
754
- bool,
755
- int,
756
- float,
757
- date,
758
- datetime,
759
- time,
760
- enum: _enum,
761
- object,
762
- fields: { timestamps: () => ({
763
- createdAt: datetime().hooks({ create: () => /* @__PURE__ */ new Date() }).description("Record creation timestamp"),
764
- updatedAt: datetime({ optional: true }).hooks({ update: () => /* @__PURE__ */ new Date() }).description("Record last update timestamp")
765
- }) }
766
- };
767
-
768
14
  //#endregion
769
15
  //#region src/configure/services/auth/index.ts
770
16
  function defineAuth(name, config) {
@@ -1042,6 +288,7 @@ function defineIdp(name, config) {
1042
288
  * @param config - Application configuration
1043
289
  * @returns The same configuration object
1044
290
  */
291
+ /* @__NO_SIDE_EFFECTS__ */
1045
292
  function defineConfig(config) {
1046
293
  return config;
1047
294
  }
@@ -1050,14 +297,26 @@ function defineConfig(config) {
1050
297
  * @param configs - Generator configurations
1051
298
  * @returns Generator configurations as given
1052
299
  */
300
+ /* @__NO_SIDE_EFFECTS__ */
1053
301
  function defineGenerators(...configs) {
1054
302
  return configs;
1055
303
  }
304
+ /**
305
+ * Define plugins to be used with the Tailor SDK.
306
+ * Plugins can generate additional types, resolvers, and executors
307
+ * based on existing TailorDB types.
308
+ * @param configs - Plugin configurations
309
+ * @returns Plugin configurations as given
310
+ */
311
+ /* @__NO_SIDE_EFFECTS__ */
312
+ function definePlugins(...configs) {
313
+ return configs;
314
+ }
1056
315
 
1057
316
  //#endregion
1058
317
  //#region src/configure/index.ts
1059
318
  const t = { ...t$1 };
1060
319
 
1061
320
  //#endregion
1062
- export { WORKFLOW_TEST_ENV_KEY, authAccessTokenIssuedTrigger, authAccessTokenRefreshedTrigger, authAccessTokenRevokedTrigger, createExecutor, createResolver, createWorkflow, createWorkflowJob, db, defineAuth, defineConfig, defineGenerators, defineIdp, defineStaticWebSite, idpUserCreatedTrigger, idpUserDeletedTrigger, idpUserUpdatedTrigger, incomingWebhookTrigger, recordCreatedTrigger, recordDeletedTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, t, unauthenticatedTailorUser, unsafeAllowAllGqlPermission, unsafeAllowAllTypePermission };
321
+ export { WORKFLOW_TEST_ENV_KEY, authAccessTokenIssuedTrigger, authAccessTokenRefreshedTrigger, authAccessTokenRevokedTrigger, createExecutor, createResolver, createWorkflow, createWorkflowJob, db, defineAuth, defineConfig, defineGenerators, defineIdp, definePlugins, defineStaticWebSite, idpUserCreatedTrigger, idpUserDeletedTrigger, idpUserUpdatedTrigger, incomingWebhookTrigger, recordCreatedTrigger, recordDeletedTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, t, unauthenticatedTailorUser, unsafeAllowAllGqlPermission, unsafeAllowAllTypePermission };
1063
322
  //# sourceMappingURL=index.mjs.map