@tailor-platform/sdk 1.38.0 → 1.39.1

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 (78) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/actor-Bb4OVq1j.d.mts +30 -0
  3. package/dist/{application-DhQrXEld.mjs → application-BHu8YE-g.mjs} +148 -148
  4. package/dist/application-BHu8YE-g.mjs.map +1 -0
  5. package/dist/application-C8Lr37AM.mjs +4 -0
  6. package/dist/{brand-D-d15jx3.mjs → brand-Ll48SMXe.mjs} +1 -1
  7. package/dist/{brand-D-d15jx3.mjs.map → brand-Ll48SMXe.mjs.map} +1 -1
  8. package/dist/cli/index.mjs +15 -15
  9. package/dist/cli/lib.d.mts +9 -9
  10. package/dist/cli/lib.mjs +4 -4
  11. package/dist/{client-xzPXtc_e.mjs → client-B2K45RvK.mjs} +77 -47
  12. package/dist/client-B2K45RvK.mjs.map +1 -0
  13. package/dist/{client-BWAbbA1C.mjs → client-CEVmv94H.mjs} +1 -1
  14. package/dist/configure/index.d.mts +4 -3
  15. package/dist/configure/index.mjs +55 -4
  16. package/dist/configure/index.mjs.map +1 -1
  17. package/dist/{crash-report-DXhPL8Ue.mjs → crash-report-CACiemAr.mjs} +4 -4
  18. package/dist/{crash-report-DXhPL8Ue.mjs.map → crash-report-CACiemAr.mjs.map} +1 -1
  19. package/dist/{crash-report-BEAiCSCl.mjs → crash-report-CPUF3T5d.mjs} +1 -1
  20. package/dist/{errors-D9f2UJpT.mjs → errors-ChWX5ZG8.mjs} +1 -1
  21. package/dist/{errors-D9f2UJpT.mjs.map → errors-ChWX5ZG8.mjs.map} +1 -1
  22. package/dist/field-BY2vbJ8f.mjs +23 -0
  23. package/dist/field-BY2vbJ8f.mjs.map +1 -0
  24. package/dist/{index-Cs3fwmLu.d.mts → index-BYmdVno1.d.mts} +144 -29
  25. package/dist/{index-Cln_TTZn.d.mts → index-CeFwhUkX.d.mts} +2 -2
  26. package/dist/{index-CIIXsk3E.d.mts → index-Ch8Em3nz.d.mts} +2 -2
  27. package/dist/{index-D_W9-Lvk.d.mts → index-Cx1RYDbu.d.mts} +2 -2
  28. package/dist/{index-CHo73Aat.d.mts → index-DLO_XvLi.d.mts} +2 -2
  29. package/dist/{interceptor-CzaH2Ur6.mjs → interceptor-B5bKVwgq.mjs} +1 -1
  30. package/dist/{interceptor-CzaH2Ur6.mjs.map → interceptor-B5bKVwgq.mjs.map} +1 -1
  31. package/dist/{job-DkAklmE4.mjs → job-p6zf8Qpg.mjs} +2 -2
  32. package/dist/job-p6zf8Qpg.mjs.map +1 -0
  33. package/dist/{logger-5_JMzHmw.mjs → logger-DTNAMYGy.mjs} +1 -1
  34. package/dist/{logger-5_JMzHmw.mjs.map → logger-DTNAMYGy.mjs.map} +1 -1
  35. package/dist/package-json-CPR7s5hf.mjs +4 -0
  36. package/dist/{package-json-BHViVisJ.mjs → package-json-CWp8s9dE.mjs} +1 -1
  37. package/dist/{package-json-BHViVisJ.mjs.map → package-json-CWp8s9dE.mjs.map} +1 -1
  38. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  39. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  40. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  41. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  42. package/dist/plugin/builtin/seed/index.mjs +1 -1
  43. package/dist/plugin/index.d.mts +2 -1
  44. package/dist/{runtime-ChpwtPut.mjs → runtime-2xqzvkQv.mjs} +92 -15
  45. package/dist/runtime-2xqzvkQv.mjs.map +1 -0
  46. package/dist/{schema-CnwUqPyM.mjs → schema-CEcfEyPN.mjs} +4 -44
  47. package/dist/schema-CEcfEyPN.mjs.map +1 -0
  48. package/dist/{seed-DrbB1VXd.mjs → seed-CyYPhvNL.mjs} +12 -12
  49. package/dist/seed-CyYPhvNL.mjs.map +1 -0
  50. package/dist/{service-Bcp6JB3w.mjs → service-SrG26B9T.mjs} +3 -3
  51. package/dist/{service-Bcp6JB3w.mjs.map → service-SrG26B9T.mjs.map} +1 -1
  52. package/dist/{plugin-D84blivd.d.mts → tailor-db-field-B99RnR2N.d.mts} +683 -1211
  53. package/dist/{telemetry-DwHuiNiR.mjs → telemetry-BuDto_2q.mjs} +2 -2
  54. package/dist/{telemetry-DwHuiNiR.mjs.map → telemetry-BuDto_2q.mjs.map} +1 -1
  55. package/dist/telemetry-C1hzFaiV.mjs +4 -0
  56. package/dist/types-BnphjkIJ.mjs +5 -0
  57. package/dist/{types-B9ZMosul.mjs → types-Duhhsx3R.mjs} +3 -32
  58. package/dist/types-Duhhsx3R.mjs.map +1 -0
  59. package/dist/utils/test/index.d.mts +2 -2
  60. package/dist/utils/test/index.mjs +1 -1
  61. package/dist/workflow.generated-DSwr-k57.d.mts +1207 -0
  62. package/docs/cli/application.md +21 -5
  63. package/docs/cli-reference.md +1 -0
  64. package/docs/generator/index.md +10 -0
  65. package/docs/services/idp.md +4 -4
  66. package/package.json +2 -2
  67. package/dist/application-C1ipG5Q6.mjs +0 -4
  68. package/dist/application-DhQrXEld.mjs.map +0 -1
  69. package/dist/client-xzPXtc_e.mjs.map +0 -1
  70. package/dist/job-DkAklmE4.mjs.map +0 -1
  71. package/dist/package-json--6dmp6-h.mjs +0 -4
  72. package/dist/runtime-ChpwtPut.mjs.map +0 -1
  73. package/dist/schema-CnwUqPyM.mjs.map +0 -1
  74. package/dist/seed-DrbB1VXd.mjs.map +0 -1
  75. package/dist/telemetry-4IOPW6wE.mjs +0 -4
  76. package/dist/types-B9ZMosul.mjs.map +0 -1
  77. package/dist/types-C45jRrCM.mjs +0 -4
  78. package/dist/workflow.generated-BRdcCWfC.d.mts +0 -414
@@ -1,33 +1,155 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { z } from "zod";
3
- import { StandardSchemaV1 } from "@standard-schema/spec";
4
2
  import { IsAny, JsonObject, NonEmptyObject } from "type-fest";
5
3
 
6
- //#region src/parser/generator-config/index.d.ts
7
- declare const BaseGeneratorConfigSchema: z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"@tailor-platform/kysely-type">, z.ZodObject<{
8
- distPath: z.ZodString;
9
- }, z.core.$strip>], null>, z.ZodTuple<[z.ZodLiteral<"@tailor-platform/seed">, z.ZodObject<{
10
- distPath: z.ZodString;
11
- machineUserName: z.ZodOptional<z.ZodString>;
12
- }, z.core.$strip>], null>, z.ZodTuple<[z.ZodLiteral<"@tailor-platform/enum-constants">, z.ZodObject<{
13
- distPath: z.ZodString;
14
- }, z.core.$strip>], null>, z.ZodTuple<[z.ZodLiteral<"@tailor-platform/file-utils">, z.ZodObject<{
15
- distPath: z.ZodString;
16
- }, z.core.$strip>], null>, z.ZodObject<{
17
- id: z.ZodString;
18
- description: z.ZodString;
19
- dependencies: z.ZodArray<z.ZodEnum<{
20
- executor: "executor";
21
- tailordb: "tailordb";
22
- resolver: "resolver";
23
- }>>;
24
- processType: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
25
- processResolver: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
26
- processExecutor: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
27
- processTailorDBNamespace: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
28
- processResolverNamespace: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
29
- aggregate: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodAny>;
30
- }, z.core.$strip>]>;
4
+ //#region src/types/helpers.d.ts
5
+ type Prettify<T> = { [K in keyof T as string extends K ? never : K]: T[K] } & {};
6
+ type DeepWritable<T> = T extends Date | RegExp | Function ? T : T extends object ? { -readonly [P in keyof T]: DeepWritable<T[P]> } & {} : T;
7
+ type output<T> = T extends {
8
+ _output: infer U;
9
+ } ? DeepWritable<U> : never;
10
+ type NullableToOptional<T> = { [K in keyof T as null extends T[K] ? never : K]: T[K] } & { [K in keyof T as null extends T[K] ? K : never]?: T[K] };
11
+ type InferFieldsOutput<F extends Record<string, {
12
+ _output: any;
13
+ [key: string]: any;
14
+ }>> = DeepWritable<Prettify<NullableToOptional<{ [K in keyof F]: output<F[K]> }>>>;
15
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
16
+ [key: string]: JsonValue;
17
+ };
18
+ /**
19
+ * A looser version of JsonValue that accepts interfaces.
20
+ * TypeScript interfaces don't have index signatures by default,
21
+ * so they can't be assigned to JsonValue's {[Key in string]: JsonValue}.
22
+ * This type uses a recursive check instead.
23
+ */
24
+ type JsonCompatible<T> = T extends string | number | boolean | null | undefined ? T : T extends readonly (infer U)[] ? JsonCompatible<U>[] : T extends object ? T extends {
25
+ toJSON: () => unknown;
26
+ } ? never : { [K in keyof T]: JsonCompatible<T[K]> } : never;
27
+ //#endregion
28
+ //#region src/types/user.d.ts
29
+ interface AttributeMap {}
30
+ interface AttributeList {
31
+ __tuple?: [];
32
+ }
33
+ type InferredAttributeMap = keyof AttributeMap extends never ? Record<string, string | string[] | boolean | boolean[] | undefined> : AttributeMap;
34
+ type InferredAttributeList = AttributeList["__tuple"] extends [] ? string[] : AttributeList["__tuple"];
35
+ /** Represents a user in the Tailor platform. */
36
+ type TailorUser = {
37
+ /**
38
+ * The ID of the user.
39
+ * For unauthenticated users, this will be a nil UUID.
40
+ */
41
+ id: string;
42
+ /**
43
+ * The type of the user.
44
+ * For unauthenticated users, this will be an empty string.
45
+ */
46
+ type: "user" | "machine_user" | ""; /** The ID of the workspace the user belongs to. */
47
+ workspaceId: string;
48
+ /**
49
+ * A map of the user's attributes.
50
+ * For unauthenticated users, this will be null.
51
+ */
52
+ attributes: InferredAttributeMap | null;
53
+ /**
54
+ * A list of the user's attributes.
55
+ * For unauthenticated users, this will be an empty array.
56
+ */
57
+ attributeList: InferredAttributeList;
58
+ };
59
+ /** Represents an unauthenticated user in the Tailor platform. */
60
+ declare const unauthenticatedTailorUser: TailorUser;
61
+ //#endregion
62
+ //#region src/types/validation.d.ts
63
+ /**
64
+ * Validation function type
65
+ */
66
+ type ValidateFn<O, D = unknown> = (args: {
67
+ value: O;
68
+ data: D;
69
+ user: TailorUser;
70
+ }) => boolean;
71
+ /**
72
+ * Validation configuration with custom error message
73
+ */
74
+ type ValidateConfig<O, D = unknown> = [ValidateFn<O, D>, string];
75
+ /**
76
+ * Field-level validation function
77
+ */
78
+ type FieldValidateFn<O> = ValidateFn<O>;
79
+ /**
80
+ * Field-level validation configuration
81
+ */
82
+ type FieldValidateConfig<O> = ValidateConfig<O>;
83
+ /**
84
+ * Input type for field validation - can be either a function or a tuple of [function, errorMessage]
85
+ */
86
+ type FieldValidateInput<O> = FieldValidateFn<O> | FieldValidateConfig<O>;
87
+ /**
88
+ * Base validators type for field collections
89
+ * @template F - Record of fields
90
+ * @template ExcludeKeys - Keys to exclude from validation (default: "id" for TailorDB)
91
+ */
92
+ type ValidatorsBase<F extends Record<string, {
93
+ _defined: any;
94
+ _output: any;
95
+ [key: string]: any;
96
+ }>, ExcludeKeys extends string = "id"> = NonEmptyObject<{ [K in Exclude<keyof F, ExcludeKeys> as F[K]["_defined"] extends {
97
+ validate: unknown;
98
+ } ? never : K]?: ValidateFn<output<F[K]>, InferFieldsOutput<F>> | ValidateConfig<output<F[K]>, InferFieldsOutput<F>> | (ValidateFn<output<F[K]>, InferFieldsOutput<F>> | ValidateConfig<output<F[K]>, InferFieldsOutput<F>>)[] }>;
99
+ /**
100
+ * Validators type (by default excludes "id" field for TailorDB compatibility)
101
+ * Can be used with both TailorField and TailorDBField
102
+ */
103
+ type Validators<F extends Record<string, {
104
+ _defined: any;
105
+ _output: any;
106
+ [key: string]: any;
107
+ }>> = ValidatorsBase<F, "id">;
108
+ //#endregion
109
+ //#region src/types/field-types.d.ts
110
+ interface EnumValue {
111
+ value: string;
112
+ description?: string;
113
+ }
114
+ type TailorFieldType = "uuid" | "string" | "boolean" | "integer" | "float" | "decimal" | "enum" | "date" | "datetime" | "time" | "nested";
115
+ type TailorToTs = {
116
+ string: string;
117
+ integer: number;
118
+ float: number;
119
+ decimal: string;
120
+ boolean: boolean;
121
+ uuid: string;
122
+ date: string;
123
+ datetime: string | Date;
124
+ time: string;
125
+ enum: string;
126
+ object: Record<string, unknown>;
127
+ nested: Record<string, unknown>;
128
+ } & Record<TailorFieldType, unknown>;
129
+ interface FieldMetadata {
130
+ description?: string;
131
+ required?: boolean;
132
+ array?: boolean;
133
+ allowedValues?: EnumValue[];
134
+ validate?: FieldValidateInput<any>[];
135
+ typeName?: string;
136
+ }
137
+ interface DefinedFieldMetadata {
138
+ type: TailorFieldType;
139
+ array: boolean;
140
+ description?: boolean;
141
+ validate?: boolean;
142
+ typeName?: boolean;
143
+ }
144
+ type FieldOptions = {
145
+ optional?: boolean;
146
+ array?: boolean;
147
+ };
148
+ type FieldOutput$1<T, O extends FieldOptions> = OptionalFieldOutput<ArrayFieldOutput<T, O>, O>;
149
+ type OptionalFieldOutput<T, O extends FieldOptions> = O["optional"] extends true ? T | null : T;
150
+ type ArrayFieldOutput<T, O extends FieldOptions> = [O] extends [{
151
+ array: true;
152
+ }] ? T[] : T;
31
153
  //#endregion
32
154
  //#region src/types/auth.generated.d.ts
33
155
  type AuthInvokerObject = {
@@ -351,8 +473,31 @@ type Executor = {
351
473
  description?: string | undefined;
352
474
  };
353
475
  //#endregion
476
+ //#region src/types/generator-config.generated.d.ts
477
+ type BaseGeneratorConfig = ["@tailor-platform/kysely-type", {
478
+ distPath: string;
479
+ }] | ["@tailor-platform/seed", {
480
+ distPath: string;
481
+ machineUserName?: string | undefined;
482
+ }] | ["@tailor-platform/enum-constants", {
483
+ distPath: string;
484
+ }] | ["@tailor-platform/file-utils", {
485
+ distPath: string;
486
+ }] | {
487
+ id: string;
488
+ description: string;
489
+ dependencies: ("tailordb" | "resolver" | "executor")[];
490
+ aggregate: Function;
491
+ processType?: Function | undefined;
492
+ processResolver?: Function | undefined;
493
+ processExecutor?: Function | undefined;
494
+ processTailorDBNamespace?: Function | undefined;
495
+ processResolverNamespace?: Function | undefined;
496
+ };
497
+ type BaseGeneratorConfigInput = BaseGeneratorConfig;
498
+ //#endregion
354
499
  //#region src/types/generator-config.d.ts
355
- type GeneratorConfig = z.input<typeof BaseGeneratorConfigSchema>;
500
+ type GeneratorConfig = BaseGeneratorConfigInput;
356
501
  //#endregion
357
502
  //#region src/types/resolver.generated.d.ts
358
503
  type Resolver = {
@@ -410,397 +555,153 @@ type AuthConnectionConfig = {
410
555
  tokenUrl?: string | undefined;
411
556
  };
412
557
  //#endregion
413
- //#region src/configure/types/field.d.ts
414
- type AllowedValue = EnumValue;
415
- type AllowedValues = readonly [string | EnumValue, ...(string | EnumValue)[]];
416
- type AllowedValuesOutput<V extends AllowedValues> = V[number] extends infer T ? T extends string ? T : T extends {
417
- value: infer K;
418
- } ? K : never : never;
419
- //#endregion
420
- //#region src/configure/types/user.d.ts
421
- interface AttributeMap {}
422
- interface AttributeList {
423
- __tuple?: [];
424
- }
425
- type InferredAttributeMap = keyof AttributeMap extends never ? Record<string, string | string[] | boolean | boolean[] | undefined> : AttributeMap;
426
- type InferredAttributeList = AttributeList["__tuple"] extends [] ? string[] : AttributeList["__tuple"];
427
- /** Represents a user in the Tailor platform. */
428
- type TailorUser = {
429
- /**
430
- * The ID of the user.
431
- * For unauthenticated users, this will be a nil UUID.
432
- */
433
- id: string;
434
- /**
435
- * The type of the user.
436
- * For unauthenticated users, this will be an empty string.
437
- */
438
- type: "user" | "machine_user" | ""; /** The ID of the workspace the user belongs to. */
439
- workspaceId: string;
440
- /**
441
- * A map of the user's attributes.
442
- * For unauthenticated users, this will be null.
443
- */
444
- attributes: InferredAttributeMap | null;
445
- /**
446
- * A list of the user's attributes.
447
- * For unauthenticated users, this will be an empty array.
448
- */
449
- attributeList: InferredAttributeList;
450
- };
451
- /** Represents an unauthenticated user in the Tailor platform. */
452
- declare const unauthenticatedTailorUser: TailorUser;
453
- //#endregion
454
- //#region src/configure/types/actor.d.ts
455
- /** User type enum values from the Tailor Platform server. */
456
- type TailorActorType = "USER_TYPE_USER" | "USER_TYPE_MACHINE_USER" | "USER_TYPE_UNSPECIFIED";
457
- /** Represents an actor in event triggers. */
458
- type TailorActor = {
459
- /** The ID of the workspace the user belongs to. */workspaceId: string; /** The ID of the user. */
460
- userId: string;
461
- /**
462
- * A map of the user's attributes.
463
- * Maps from server's `attributeMap` field.
464
- */
465
- attributes: InferredAttributeMap | null;
466
- /**
467
- * A list of the user's attributes.
468
- * Maps from server's `attributes` field.
469
- */
470
- attributeList: InferredAttributeList; /** The type of the user. */
471
- userType: TailorActorType;
472
- };
473
- //#endregion
474
- //#region src/configure/types/env.d.ts
475
- interface Env {}
476
- /** Represents environment variables in the Tailor platform. */
477
- type TailorEnv = keyof Env extends never ? Record<string, string> : Env;
478
- //#endregion
479
- //#region src/configure/types/machine-user.d.ts
480
- interface MachineUserNameRegistry {}
481
- /**
482
- * Machine user name.
483
- *
484
- * When `tailor.d.ts` is generated (via `tailor-sdk apply`/`generate`), this is narrowed
485
- * to the union of defined machine user names. When no machine users are registered yet,
486
- * falls back to `string` to avoid blocking editing before the first generate run.
487
- */
488
- type MachineUserName = keyof MachineUserNameRegistry extends never ? string : keyof MachineUserNameRegistry & string;
489
- //#endregion
490
- //#region src/configure/types/helpers.d.ts
491
- type Prettify<T> = { [K in keyof T as string extends K ? never : K]: T[K] } & {};
492
- type DeepWritable<T> = T extends Date | RegExp | Function ? T : T extends object ? { -readonly [P in keyof T]: DeepWritable<T[P]> } & {} : T;
493
- type output<T> = T extends {
494
- _output: infer U;
495
- } ? DeepWritable<U> : never;
496
- type NullableToOptional<T> = { [K in keyof T as null extends T[K] ? never : K]: T[K] } & { [K in keyof T as null extends T[K] ? K : never]?: T[K] };
497
- type InferFieldsOutput<F extends Record<string, {
498
- _output: any;
499
- [key: string]: any;
500
- }>> = DeepWritable<Prettify<NullableToOptional<{ [K in keyof F]: output<F[K]> }>>>;
501
- type JsonValue = string | number | boolean | null | JsonValue[] | {
502
- [key: string]: JsonValue;
503
- };
504
- /**
505
- * A looser version of JsonValue that accepts interfaces.
506
- * TypeScript interfaces don't have index signatures by default,
507
- * so they can't be assigned to JsonValue's {[Key in string]: JsonValue}.
508
- * This type uses a recursive check instead.
509
- */
510
- type JsonCompatible<T> = T extends string | number | boolean | null | undefined ? T : T extends readonly (infer U)[] ? JsonCompatible<U>[] : T extends object ? T extends {
511
- toJSON: () => unknown;
512
- } ? never : { [K in keyof T]: JsonCompatible<T[K]> } : never;
513
- //#endregion
514
- //#region src/types/field.generated.d.ts
515
- type TailorFieldInput = {
516
- /** Field data type */type: "string" | "boolean" | "uuid" | "integer" | "float" | "decimal" | "enum" | "date" | "datetime" | "time" | "nested"; /** Field metadata configuration */
517
- metadata: {
518
- required?: boolean | undefined;
519
- array?: boolean | undefined;
520
- description?: string | undefined;
521
- allowedValues?: {
522
- value: string;
523
- description?: string | undefined;
524
- }[] | undefined;
525
- hooks?: {
526
- create?: Function | undefined;
527
- update?: Function | undefined;
528
- } | undefined;
529
- typeName?: string | undefined;
530
- };
531
- fields: {
532
- [x: string]: TailorFieldInput;
533
- };
534
- };
535
- //#endregion
536
- //#region src/configure/types/type.d.ts
537
- type TailorAnyField = TailorField<any>;
538
- type FieldParseArgs = {
539
- value: unknown;
540
- data: unknown;
541
- user: TailorUser;
542
- };
543
- type FieldParseInternalArgs = {
544
- value: any;
545
- data: unknown;
546
- user: TailorUser;
547
- pathArray: string[];
548
- };
558
+ //#region src/types/tailor-field.d.ts
549
559
  /**
550
- * TailorField interface representing a field with metadata, type information, and optional nested fields.
551
- * This is the base field type used by both resolver types and TailorDB types.
552
- * Using interface to allow self-referencing in the fields property.
560
+ * Minimal structural interface for TailorField.
561
+ * Defines only the properties needed by parser, plugin, cli, and types layers.
562
+ * The full interface with builder methods (description, typeName, validate, parse)
563
+ * is defined in configure/types/type.ts.
553
564
  */
554
- interface TailorField<Defined extends DefinedFieldMetadata = DefinedFieldMetadata, Output = any, M extends FieldMetadata = FieldMetadata, T extends TailorFieldType = TailorFieldType> extends TailorFieldInput {
565
+ interface TailorField<Defined extends DefinedFieldMetadata = DefinedFieldMetadata, Output = any, M extends FieldMetadata = FieldMetadata, T extends TailorFieldType = TailorFieldType> {
555
566
  readonly type: T;
556
567
  readonly fields: Record<string, TailorAnyField>;
557
568
  readonly _defined: Defined;
558
569
  readonly _output: Output;
559
- _metadata: M;
560
- /** Returns a shallow copy of the metadata */
561
570
  readonly metadata: M;
562
- /**
563
- * Set a description for the field
564
- * @param description - The description text
565
- * @returns The field with updated metadata
566
- */
567
- description<CurrentDefined extends Defined>(this: CurrentDefined extends {
568
- description: unknown;
569
- } ? never : TailorField<CurrentDefined, Output>, description: string): TailorField<Prettify<CurrentDefined & {
570
- description: true;
571
- }>, Output>;
572
- /**
573
- * Set a custom type name for enum or nested types
574
- * @param typeName - The custom type name
575
- * @returns The field with updated metadata
576
- */
577
- typeName<CurrentDefined extends Defined>(this: CurrentDefined extends {
578
- typeName: unknown;
579
- } ? never : CurrentDefined extends {
580
- type: "enum" | "nested";
581
- } ? TailorField<CurrentDefined, Output> : never, typeName: string): TailorField<Prettify<CurrentDefined & {
582
- typeName: true;
583
- }>, Output>;
584
- /**
585
- * Add validation functions to the field
586
- * @param validate - One or more validation functions
587
- * @returns The field with updated metadata
588
- */
589
- validate<CurrentDefined extends Defined>(this: CurrentDefined extends {
590
- validate: unknown;
591
- } ? never : TailorField<CurrentDefined, Output>, ...validate: FieldValidateInput<Output>[]): TailorField<Prettify<CurrentDefined & {
592
- validate: true;
593
- }>, Output>;
594
- /**
595
- * Parse and validate a value against this field's validation rules
596
- * Returns StandardSchema Result type with success or failure
597
- * @param args - Value, context data, and user
598
- * @returns Validation result
599
- */
600
- parse(args: FieldParseArgs): StandardSchemaV1.Result<Output>;
601
- /**
602
- * Internal parse method that tracks field path for nested validation
603
- * @private
604
- * @param args - Parse arguments
605
- * @returns Validation result
606
- */
607
- _parseInternal(args: FieldParseInternalArgs): StandardSchemaV1.Result<Output>;
608
571
  }
572
+ type TailorAnyField = TailorField<any>;
609
573
  //#endregion
610
- //#region src/configure/types/validation.d.ts
611
- /**
612
- * Validation function type
613
- */
614
- type ValidateFn<O, D = unknown> = (args: {
615
- value: O;
616
- data: D;
617
- user: TailorUser;
618
- }) => boolean;
619
- /**
620
- * Validation configuration with custom error message
621
- */
622
- type ValidateConfig<O, D = unknown> = [ValidateFn<O, D>, string];
623
- /**
624
- * Field-level validation function
625
- */
626
- type FieldValidateFn<O> = ValidateFn<O>;
627
- /**
628
- * Field-level validation configuration
629
- */
630
- type FieldValidateConfig<O> = ValidateConfig<O>;
631
- /**
632
- * Input type for field validation - can be either a function or a tuple of [function, errorMessage]
633
- */
634
- type FieldValidateInput<O> = FieldValidateFn<O> | FieldValidateConfig<O>;
635
- /**
636
- * Base validators type for field collections
637
- * @template F - Record of fields
638
- * @template ExcludeKeys - Keys to exclude from validation (default: "id" for TailorDB)
639
- */
640
- type ValidatorsBase<F extends Record<string, {
641
- _defined: any;
642
- _output: any;
643
- [key: string]: any;
644
- }>, ExcludeKeys extends string = "id"> = NonEmptyObject<{ [K in Exclude<keyof F, ExcludeKeys> as F[K]["_defined"] extends {
645
- validate: unknown;
646
- } ? never : K]?: ValidateFn<output<F[K]>, InferFieldsOutput<F>> | ValidateConfig<output<F[K]>, InferFieldsOutput<F>> | (ValidateFn<output<F[K]>, InferFieldsOutput<F>> | ValidateConfig<output<F[K]>, InferFieldsOutput<F>>)[] }>;
647
- /**
648
- * Validators type (by default excludes "id" field for TailorDB compatibility)
649
- * Can be used with both TailorField and TailorDBField
650
- */
651
- type Validators<F extends Record<string, {
652
- _defined: any;
653
- _output: any;
654
- [key: string]: any;
655
- }>> = ValidatorsBase<F, "id">;
656
- //#endregion
657
- //#region src/configure/types/types.d.ts
658
- type TailorFieldType = "uuid" | "string" | "boolean" | "integer" | "float" | "decimal" | "enum" | "date" | "datetime" | "time" | "nested";
659
- type TailorToTs = {
660
- string: string;
661
- integer: number;
662
- float: number;
663
- decimal: string;
664
- boolean: boolean;
665
- uuid: string;
666
- date: string;
667
- datetime: string | Date;
668
- time: string;
669
- enum: string;
670
- object: Record<string, unknown>;
671
- nested: Record<string, unknown>;
672
- } & Record<TailorFieldType, unknown>;
673
- interface FieldMetadata {
674
- description?: string;
675
- required?: boolean;
676
- array?: boolean;
677
- allowedValues?: AllowedValue[];
678
- validate?: FieldValidateInput<any>[];
679
- typeName?: string;
680
- }
681
- interface DefinedFieldMetadata {
682
- type: TailorFieldType;
683
- array: boolean;
684
- description?: boolean;
685
- validate?: boolean;
686
- typeName?: boolean;
687
- }
688
- type FieldOptions = {
689
- optional?: boolean;
690
- array?: boolean;
574
+ //#region src/types/auth.d.ts
575
+ type OAuth2ClientGrantType = OAuth2Client["grantTypes"][number];
576
+ type SCIMAttributeType = SCIMAttribute["type"];
577
+ type AuthInvokerWithName<M extends string> = Omit<AuthInvoker, "machineUserName"> & {
578
+ machineUserName: M;
691
579
  };
692
- type FieldOutput$1<T, O extends FieldOptions> = OptionalFieldOutput<ArrayFieldOutput<T, O>, O>;
693
- type OptionalFieldOutput<T, O extends FieldOptions> = O["optional"] extends true ? T | null : T;
694
- type ArrayFieldOutput<T, O extends FieldOptions> = [O] extends [{
580
+ /** Result of retrieving a connection token at runtime. */
581
+ type AuthConnectionTokenResult = {
582
+ access_token: string;
583
+ refresh_token?: string;
584
+ token_type?: string;
585
+ expiry?: string;
586
+ };
587
+ type ValueOperand = string | boolean | string[] | boolean[];
588
+ type AuthAttributeValue = ValueOperand | null | undefined;
589
+ type UserFieldKeys<User extends TailorDBInstance> = keyof output<User> & string;
590
+ type FieldDefined<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = User["fields"][Key] extends {
591
+ _defined: infer Defined;
592
+ } ? Defined : never;
593
+ type FieldOutput<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = output<User>[Key];
594
+ type FieldIsRequired<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = undefined extends FieldOutput<User, Key> ? false : true;
595
+ type FieldIsOfType<User extends TailorDBInstance, Key extends UserFieldKeys<User>, Type extends string> = FieldDefined<User, Key> extends {
596
+ type: Type;
597
+ } ? true : false;
598
+ type FieldIsArray<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldDefined<User, Key> extends {
695
599
  array: true;
696
- }] ? T[] : T;
697
- //#endregion
698
- //#region src/configure/services/tailordb/permission.d.ts
699
- /**
700
- * Record-level permission configuration for a TailorDB type.
701
- * Defines create, read, update, and delete permissions.
702
- *
703
- * Prefer object format with explicit `conditions` and `permit` for readability.
704
- * Shorthand array format is supported for compatibility, but less readable.
705
- *
706
- * For update operations, use `newRecord`/`oldRecord` operands instead of `record`.
707
- * @example
708
- * const permission: TailorTypePermission = {
709
- * create: [{ conditions: [[{ user: "_loggedIn" }, "=", true]], permit: true }],
710
- * read: [{ conditions: [[{ record: "isPublic" }, "=", true]], permit: true }],
711
- * update: [{ conditions: [[{ newRecord: "ownerId" }, "=", { user: "id" }]], permit: true }],
712
- * delete: [{ conditions: [[{ record: "ownerId" }, "=", { user: "id" }]], permit: true }],
713
- * };
714
- */
715
- type TailorTypePermission<User extends object = InferredAttributeMap, Type extends object = object> = {
716
- create: readonly ActionPermission<"record", User, Type, false>[];
717
- read: readonly ActionPermission<"record", User, Type, false>[];
718
- update: readonly ActionPermission<"record", User, Type, true>[];
719
- delete: readonly ActionPermission<"record", User, Type, false>[];
600
+ } ? true : false;
601
+ type FieldIsUnique<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldDefined<User, Key> extends {
602
+ unique: true;
603
+ } ? true : false;
604
+ type FieldSupportsValueOperand<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldOutput<User, Key> extends ValueOperand | null | undefined ? true : false;
605
+ type UsernameFieldKey<User extends TailorDBInstance> = IsAny<User> extends true ? string : { [K in UserFieldKeys<User>]: FieldIsRequired<User, K> extends true ? FieldIsOfType<User, K, "string"> extends true ? FieldIsArray<User, K> extends true ? never : FieldIsUnique<User, K> extends true ? K : never : never : never }[UserFieldKeys<User>];
606
+ type UserAttributeKey<User extends TailorDBInstance> = { [K in UserFieldKeys<User>]: K extends "id" ? never : FieldSupportsValueOperand<User, K> extends true ? FieldIsOfType<User, K, "datetime" | "date" | "time"> extends true ? never : K : never }[UserFieldKeys<User>];
607
+ type UserAttributeListKey<User extends TailorDBInstance> = { [K in UserFieldKeys<User>]: K extends "id" ? never : FieldIsOfType<User, K, "uuid"> extends true ? FieldIsArray<User, K> extends true ? never : K : never }[UserFieldKeys<User>];
608
+ type UserAttributeMap<User extends TailorDBInstance> = { [K in UserAttributeKey<User>]?: true };
609
+ type DisallowExtraKeys<T, Allowed extends PropertyKey> = T & { [K in Exclude<keyof T, Allowed>]: never };
610
+ type AttributeListValue<User extends TailorDBInstance, Key extends UserAttributeListKey<User>> = Key extends keyof output<User> ? output<User>[Key] : never;
611
+ type AttributeListToTuple<User extends TailorDBInstance, AttributeList extends readonly UserAttributeListKey<User>[]> = { [Index in keyof AttributeList]: AttributeList[Index] extends UserAttributeListKey<User> ? AttributeListValue<User, AttributeList[Index]> : never };
612
+ type AttributeMapSelectedKeys<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User>> = Extract<{ [K in keyof AttributeMap]-?: undefined extends AttributeMap[K] ? never : K }[keyof AttributeMap], UserAttributeKey<User>>;
613
+ type UserProfile<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[]> = {
614
+ /**
615
+ * TailorDB namespace where the user type is defined.
616
+ *
617
+ * Usually auto-resolved, so you don't need to specify this.
618
+ * Required only when multiple TailorDBs exist and the type is in an external TailorDB.
619
+ */
620
+ namespace?: string;
621
+ type: User;
622
+ usernameField: UsernameFieldKey<User>;
623
+ attributes?: DisallowExtraKeys<AttributeMap, UserAttributeKey<User>>;
624
+ attributeList?: AttributeList;
720
625
  };
721
- type ActionPermission<Level extends "record" | "gql" = "record" | "gql", User extends object = InferredAttributeMap, Type extends object = object, Update extends boolean = boolean> = {
722
- conditions: PermissionCondition<Level, User, Update, Type> | readonly PermissionCondition<Level, User, Update, Type>[];
723
- description?: string | undefined;
724
- permit?: boolean;
725
- } | readonly [...PermissionCondition<Level, User, Update, Type>, ...([] | [boolean])] | readonly [...PermissionCondition<Level, User, Update, Type>[], ...([] | [boolean])];
726
- type TailorTypeGqlPermission<User extends object = InferredAttributeMap, Type extends object = object> = readonly GqlPermissionPolicy<User, Type>[];
727
- type GqlPermissionPolicy<User extends object = InferredAttributeMap, Type extends object = object> = {
728
- conditions: readonly PermissionCondition<"gql", User, boolean, Type>[];
729
- actions: "all" | readonly GqlPermissionAction$1[];
730
- permit?: boolean;
731
- description?: string;
626
+ type MachineUserAttributeFields = Record<string, TailorField<DefinedFieldMetadata, unknown, FieldMetadata, TailorFieldType>>;
627
+ type TailorFieldOutputValue<Field> = Field extends TailorField<DefinedFieldMetadata, infer Output, FieldMetadata, TailorFieldType> ? Output : never;
628
+ type MachineUserAttributeValues<Fields extends MachineUserAttributeFields> = { [K in keyof Fields]: TailorFieldOutputValue<Fields[K]> extends ValueOperand | null | undefined ? TailorFieldOutputValue<Fields[K]> : never };
629
+ type MachineUserFromAttributes<Fields extends MachineUserAttributeFields> = (keyof Fields extends never ? {
630
+ attributes?: never;
631
+ } : {
632
+ attributes: DisallowExtraKeys<MachineUserAttributeValues<Fields>, keyof Fields>;
633
+ }) & {
634
+ attributeList?: string[];
732
635
  };
733
- type GqlPermissionAction$1 = "read" | "create" | "update" | "delete" | "aggregate" | "bulkUpsert";
734
- type EqualityOperator = "=" | "!=";
735
- type ContainsOperator = "in" | "not in";
736
- type HasAnyOperator = "hasAny" | "not hasAny";
737
- type StringFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string ? K : never }[keyof User];
738
- type StringArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string[] ? K : never }[keyof User];
739
- type BooleanFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean ? K : never }[keyof User];
740
- type BooleanArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean[] ? K : never }[keyof User];
741
- type UserStringOperand<User extends object = InferredAttributeMap> = {
742
- user: StringFieldKeys<User> | "id";
636
+ type MachineUser<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User> = UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[] = [], MachineUserAttributes extends MachineUserAttributeFields | undefined = undefined> = IsAny<MachineUserAttributes> extends true ? IsAny<User> extends true ? {
637
+ attributes: Record<string, AuthAttributeValue>;
638
+ attributeList?: string[];
639
+ } : (AttributeMapSelectedKeys<User, AttributeMap> extends never ? {
640
+ attributes?: never;
641
+ } : {
642
+ attributes: { [K in AttributeMapSelectedKeys<User, AttributeMap>]: K extends keyof output<User> ? output<User>[K] : never } & { [K in Exclude<keyof output<User>, AttributeMapSelectedKeys<User, AttributeMap>>]?: never };
643
+ }) & ([] extends AttributeList ? {
644
+ attributeList?: never;
645
+ } : {
646
+ attributeList: AttributeListToTuple<User, AttributeList>;
647
+ }) : [MachineUserAttributes] extends [MachineUserAttributeFields] ? MachineUserFromAttributes<MachineUserAttributes> : IsAny<User> extends true ? {
648
+ attributes: Record<string, AuthAttributeValue>;
649
+ attributeList?: string[];
650
+ } : (AttributeMapSelectedKeys<User, AttributeMap> extends never ? {
651
+ attributes?: never;
652
+ } : {
653
+ attributes: { [K in AttributeMapSelectedKeys<User, AttributeMap>]: K extends keyof output<User> ? output<User>[K] : never } & { [K in Exclude<keyof output<User>, AttributeMapSelectedKeys<User, AttributeMap>>]?: never };
654
+ }) & ([] extends AttributeList ? {
655
+ attributeList?: never;
656
+ } : {
657
+ attributeList: AttributeListToTuple<User, AttributeList>;
658
+ });
659
+ type BeforeLoginHookArgs = {
660
+ claims: JsonObject;
661
+ idpConfigName: string;
743
662
  };
744
- type UserStringArrayOperand<User extends object = InferredAttributeMap> = {
745
- user: StringArrayFieldKeys<User>;
663
+ type BeforeLoginHook<MachineUserNames extends string> = {
664
+ handler(args: BeforeLoginHookArgs): Promise<void>;
665
+ invoker: NoInfer<MachineUserNames>;
746
666
  };
747
- type UserBooleanOperand<User extends object = InferredAttributeMap> = {
748
- user: BooleanFieldKeys<User> | "_loggedIn";
667
+ type AuthHooks<MachineUserNames extends string> = {
668
+ beforeLogin?: BeforeLoginHook<MachineUserNames>;
749
669
  };
750
- type UserBooleanArrayOperand<User extends object = InferredAttributeMap> = {
751
- user: BooleanArrayFieldKeys<User>;
670
+ type AuthServiceInput<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[], MachineUserNames extends string, MachineUserAttributes extends MachineUserAttributeFields | undefined = MachineUserAttributeFields | undefined, ConnectionNames extends string = string> = {
671
+ hooks?: AuthHooks<MachineUserNames>;
672
+ userProfile?: UserProfile<User, AttributeMap, AttributeList>;
673
+ machineUserAttributes?: MachineUserAttributes;
674
+ machineUsers?: Record<MachineUserNames, MachineUser<User, AttributeMap, AttributeList, MachineUserAttributes>>;
675
+ oauth2Clients?: Record<string, OAuth2ClientInput>;
676
+ idProvider?: IdProvider;
677
+ scim?: SCIMConfig;
678
+ tenantProvider?: TenantProvider;
679
+ connections?: Record<ConnectionNames, AuthConnectionConfig>;
680
+ publishSessionEvents?: boolean;
752
681
  };
753
- type RecordOperand$1<Type extends object, Update extends boolean = false> = Update extends true ? {
754
- oldRecord: (keyof Type & string) | "id";
755
- } | {
756
- newRecord: (keyof Type & string) | "id";
757
- } : {
758
- record: (keyof Type & string) | "id";
682
+ declare const authDefinitionBrand: unique symbol;
683
+ type AuthDefinitionBrand = {
684
+ readonly [authDefinitionBrand]: true;
759
685
  };
760
- type StringEqualityCondition<Level extends "record" | "gql", User extends object, Update extends boolean, Type extends object> = (Level extends "gql" ? readonly [string, EqualityOperator, boolean] : never) | readonly [string, EqualityOperator, string] | readonly [UserStringOperand<User>, EqualityOperator, string] | readonly [string, EqualityOperator, UserStringOperand<User>] | (Level extends "record" ? readonly [RecordOperand$1<Type, Update>, EqualityOperator, string | UserStringOperand<User>] | readonly [string | UserStringOperand<User>, EqualityOperator, RecordOperand$1<Type, Update>] : never);
761
- type BooleanEqualityCondition<Level extends "record" | "gql", User extends object, Update extends boolean, Type extends object> = readonly [boolean, EqualityOperator, boolean] | readonly [UserBooleanOperand<User>, EqualityOperator, boolean] | readonly [boolean, EqualityOperator, UserBooleanOperand<User>] | (Level extends "record" ? readonly [RecordOperand$1<Type, Update>, EqualityOperator, boolean | UserBooleanOperand<User>] | readonly [boolean | UserBooleanOperand<User>, EqualityOperator, RecordOperand$1<Type, Update>] : never);
762
- type EqualityCondition<Level extends "record" | "gql" = "record", User extends object = InferredAttributeMap, Update extends boolean = boolean, Type extends object = object> = StringEqualityCondition<Level, User, Update, Type> | BooleanEqualityCondition<Level, User, Update, Type>;
763
- 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);
764
- 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);
765
- 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>;
766
- 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);
767
- /**
768
- * Type representing a permission condition that combines user attributes, record fields, and literal values using comparison operators.
769
- *
770
- * The User type is extended by `tailor.d.ts`, which is automatically generated when running `tailor-sdk generate`.
771
- * Attributes enabled in the config file's `auth.userProfile.attributes` (or
772
- * `auth.machineUserAttributes` when userProfile is omitted) become available as types.
773
- * @example
774
- * ```ts
775
- * // tailor.config.ts
776
- * export const auth = defineAuth("my-auth", {
777
- * userProfile: {
778
- * type: user,
779
- * attributes: {
780
- * isAdmin: true,
781
- * roles: true,
782
- * }
783
- * }
784
- * });
785
- * ```
786
- */
787
- 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>;
788
- /**
789
- * Grants full record-level access without any conditions.
790
- *
791
- * Unsafe and intended only for local development, prototyping, or tests.
792
- * Do not use this in production environments, as it effectively disables
793
- * authorization checks.
794
- */
795
- declare const unsafeAllowAllTypePermission: TailorTypePermission;
796
- /**
797
- * Grants full GraphQL access (all actions) without any conditions.
798
- *
799
- * Unsafe and intended only for local development, prototyping, or tests.
800
- * Do not use this in production environments, as it effectively disables
801
- * authorization checks.
802
- */
803
- declare const unsafeAllowAllGqlPermission: TailorTypeGqlPermission;
686
+ type ConnectionNames<Config> = Config extends {
687
+ connections?: Record<infer K, unknown>;
688
+ } ? K & string : string;
689
+ type DefinedAuth<Name extends string, Config, MachineUserNames extends string> = Config & {
690
+ name: Name;
691
+ /**
692
+ * @deprecated Pass the machine user name directly as a string instead, e.g. `authInvoker: "machine-user-name"`.
693
+ * Using this function pulls config-layer (Node-only) dependencies into runtime bundles.
694
+ */
695
+ invoker<M extends MachineUserNames>(machineUser: M): AuthInvokerWithName<M>;
696
+ getConnectionToken<C extends ConnectionNames<Config>>(connectionName: C): Promise<AuthConnectionTokenResult>;
697
+ } & AuthDefinitionBrand;
698
+ type AuthExternalConfig = {
699
+ name: string;
700
+ external: true;
701
+ };
702
+ type AuthServiceInputLoose = AuthServiceInput<any, any, any, string, any>;
703
+ type AuthOwnConfig = DefinedAuth<string, AuthServiceInputLoose, string>;
704
+ type AuthConfig = AuthOwnConfig | AuthExternalConfig;
804
705
  //#endregion
805
706
  //#region src/types/tailordb.generated.d.ts
806
707
  /**
@@ -813,6 +714,33 @@ type GqlOperationsInput = "query" | {
813
714
  delete?: boolean | undefined;
814
715
  read?: boolean | undefined;
815
716
  };
717
+ type DBFieldMetadata$1 = {
718
+ /** Whether the field is required */required?: boolean | undefined; /** Whether the field is an array */
719
+ array?: boolean | undefined; /** Field description */
720
+ description?: string | undefined; /** Type name for nested or enum fields */
721
+ typeName?: string | undefined; /** Allowed values for enum fields */
722
+ allowedValues?: {
723
+ value: string; /** Field description */
724
+ description?: string | undefined;
725
+ }[] | undefined; /** Whether the field is indexed for faster queries */
726
+ index?: boolean | undefined; /** Whether the field value must be unique */
727
+ unique?: boolean | undefined; /** Whether the field is a vector field for similarity search */
728
+ vector?: boolean | undefined; /** Whether the field is a foreign key */
729
+ foreignKey?: boolean | undefined; /** Target type name for foreign key relations */
730
+ foreignKeyType?: string | undefined; /** Target field name for foreign key relations */
731
+ foreignKeyField?: string | undefined; /** Lifecycle hooks for the field */
732
+ hooks?: {
733
+ create?: Function | undefined;
734
+ update?: Function | undefined;
735
+ } | undefined; /** Validation functions for the field */
736
+ validate?: (Function | [Function, string])[] | undefined; /** Serial (auto-increment) configuration */
737
+ serial?: {
738
+ start: number;
739
+ maxValue?: number | undefined;
740
+ format?: string | undefined;
741
+ } | undefined; /** Decimal scale (number of digits after decimal point, 0-12) */
742
+ scale?: number | undefined;
743
+ };
816
744
  type TailorDBTypeParsedSettings = {
817
745
  /** Custom plural form of the type name for GraphQL */pluralForm?: string | undefined; /** Enable aggregation queries for this type */
818
746
  aggregation?: boolean | undefined; /** Enable bulk upsert mutation for this type */
@@ -834,7 +762,7 @@ type TailorDBTypeParsedSettings = {
834
762
  };
835
763
  type RawPermissions = {
836
764
  record?: {
837
- create: readonly (readonly (string | boolean | string[] | boolean[] | {
765
+ create: readonly (readonly [(string | boolean | string[] | boolean[] | {
838
766
  user: string;
839
767
  } | {
840
768
  record: string;
@@ -842,7 +770,7 @@ type RawPermissions = {
842
770
  oldRecord: string;
843
771
  } | {
844
772
  newRecord: string;
845
- })[] | readonly (boolean | readonly (string | boolean | string[] | boolean[] | {
773
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
846
774
  user: string;
847
775
  } | {
848
776
  record: string;
@@ -850,28 +778,7 @@ type RawPermissions = {
850
778
  oldRecord: string;
851
779
  } | {
852
780
  newRecord: string;
853
- })[])[] | {
854
- conditions: readonly (string | boolean | string[] | boolean[] | {
855
- user: string;
856
- } | {
857
- record: string;
858
- } | {
859
- oldRecord: string;
860
- } | {
861
- newRecord: string;
862
- })[] | readonly (readonly (string | boolean | string[] | boolean[] | {
863
- user: string;
864
- } | {
865
- record: string;
866
- } | {
867
- oldRecord: string;
868
- } | {
869
- newRecord: string;
870
- })[])[];
871
- description?: string | undefined;
872
- permit?: boolean | undefined;
873
- })[];
874
- read: readonly (readonly (string | boolean | string[] | boolean[] | {
781
+ })] | readonly [(string | boolean | string[] | boolean[] | {
875
782
  user: string;
876
783
  } | {
877
784
  record: string;
@@ -879,7 +786,7 @@ type RawPermissions = {
879
786
  oldRecord: string;
880
787
  } | {
881
788
  newRecord: string;
882
- })[] | readonly (boolean | readonly (string | boolean | string[] | boolean[] | {
789
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
883
790
  user: string;
884
791
  } | {
885
792
  record: string;
@@ -887,28 +794,7 @@ type RawPermissions = {
887
794
  oldRecord: string;
888
795
  } | {
889
796
  newRecord: string;
890
- })[])[] | {
891
- conditions: readonly (string | boolean | string[] | boolean[] | {
892
- user: string;
893
- } | {
894
- record: string;
895
- } | {
896
- oldRecord: string;
897
- } | {
898
- newRecord: string;
899
- })[] | readonly (readonly (string | boolean | string[] | boolean[] | {
900
- user: string;
901
- } | {
902
- record: string;
903
- } | {
904
- oldRecord: string;
905
- } | {
906
- newRecord: string;
907
- })[])[];
908
- description?: string | undefined;
909
- permit?: boolean | undefined;
910
- })[];
911
- update: readonly (readonly (string | boolean | string[] | boolean[] | {
797
+ }), boolean] | readonly (boolean | readonly [(string | boolean | string[] | boolean[] | {
912
798
  user: string;
913
799
  } | {
914
800
  record: string;
@@ -916,7 +802,7 @@ type RawPermissions = {
916
802
  oldRecord: string;
917
803
  } | {
918
804
  newRecord: string;
919
- })[] | readonly (boolean | readonly (string | boolean | string[] | boolean[] | {
805
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
920
806
  user: string;
921
807
  } | {
922
808
  record: string;
@@ -924,8 +810,16 @@ type RawPermissions = {
924
810
  oldRecord: string;
925
811
  } | {
926
812
  newRecord: string;
927
- })[])[] | {
928
- conditions: readonly (string | boolean | string[] | boolean[] | {
813
+ })])[] | {
814
+ conditions: readonly [(string | boolean | string[] | boolean[] | {
815
+ user: string;
816
+ } | {
817
+ record: string;
818
+ } | {
819
+ oldRecord: string;
820
+ } | {
821
+ newRecord: string;
822
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
929
823
  user: string;
930
824
  } | {
931
825
  record: string;
@@ -933,7 +827,7 @@ type RawPermissions = {
933
827
  oldRecord: string;
934
828
  } | {
935
829
  newRecord: string;
936
- })[] | readonly (readonly (string | boolean | string[] | boolean[] | {
830
+ })] | readonly (readonly [(string | boolean | string[] | boolean[] | {
937
831
  user: string;
938
832
  } | {
939
833
  record: string;
@@ -941,11 +835,19 @@ type RawPermissions = {
941
835
  oldRecord: string;
942
836
  } | {
943
837
  newRecord: string;
944
- })[])[];
838
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
839
+ user: string;
840
+ } | {
841
+ record: string;
842
+ } | {
843
+ oldRecord: string;
844
+ } | {
845
+ newRecord: string;
846
+ })])[];
945
847
  description?: string | undefined;
946
848
  permit?: boolean | undefined;
947
849
  })[];
948
- delete: readonly (readonly (string | boolean | string[] | boolean[] | {
850
+ read: readonly (readonly [(string | boolean | string[] | boolean[] | {
949
851
  user: string;
950
852
  } | {
951
853
  record: string;
@@ -953,7 +855,7 @@ type RawPermissions = {
953
855
  oldRecord: string;
954
856
  } | {
955
857
  newRecord: string;
956
- })[] | readonly (boolean | readonly (string | boolean | string[] | boolean[] | {
858
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
957
859
  user: string;
958
860
  } | {
959
861
  record: string;
@@ -961,16 +863,48 @@ type RawPermissions = {
961
863
  oldRecord: string;
962
864
  } | {
963
865
  newRecord: string;
964
- })[])[] | {
965
- conditions: readonly (string | boolean | string[] | boolean[] | {
966
- user: string;
866
+ })] | readonly [(string | boolean | string[] | boolean[] | {
867
+ user: string;
868
+ } | {
869
+ record: string;
870
+ } | {
871
+ oldRecord: string;
872
+ } | {
873
+ newRecord: string;
874
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
875
+ user: string;
876
+ } | {
877
+ record: string;
878
+ } | {
879
+ oldRecord: string;
880
+ } | {
881
+ newRecord: string;
882
+ }), boolean] | readonly (boolean | readonly [(string | boolean | string[] | boolean[] | {
883
+ user: string;
884
+ } | {
885
+ record: string;
886
+ } | {
887
+ oldRecord: string;
888
+ } | {
889
+ newRecord: string;
890
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
891
+ user: string;
892
+ } | {
893
+ record: string;
894
+ } | {
895
+ oldRecord: string;
896
+ } | {
897
+ newRecord: string;
898
+ })])[] | {
899
+ conditions: readonly [(string | boolean | string[] | boolean[] | {
900
+ user: string;
967
901
  } | {
968
902
  record: string;
969
903
  } | {
970
904
  oldRecord: string;
971
905
  } | {
972
906
  newRecord: string;
973
- })[] | readonly (readonly (string | boolean | string[] | boolean[] | {
907
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
974
908
  user: string;
975
909
  } | {
976
910
  record: string;
@@ -978,752 +912,266 @@ type RawPermissions = {
978
912
  oldRecord: string;
979
913
  } | {
980
914
  newRecord: string;
981
- })[])[];
982
- description?: string | undefined;
983
- permit?: boolean | undefined;
984
- })[];
985
- } | undefined;
986
- gql?: readonly {
987
- conditions: readonly (readonly (string | boolean | string[] | boolean[] | {
988
- user: string;
989
- })[])[];
990
- actions: "all" | readonly ("create" | "read" | "update" | "delete" | "aggregate" | "bulkUpsert")[];
991
- permit?: boolean | undefined;
992
- description?: string | undefined;
993
- }[] | undefined;
994
- };
995
- type TailorDBServiceConfigInput = {
996
- /** Glob patterns for TailorDB type definition files */files: string[]; /** Glob patterns to exclude from type discovery */
997
- ignores?: string[] | undefined; /** URL for the ERD (Entity Relationship Diagram) site */
998
- erdSite?: string | undefined; /** Migration configuration */
999
- migration?: {
1000
- directory: string;
1001
- machineUser?: string | undefined;
1002
- } | undefined; /** Default GraphQL operations for all types in this service */
1003
- gqlOperations?: "query" | {
1004
- create?: boolean | undefined;
1005
- update?: boolean | undefined;
1006
- delete?: boolean | undefined;
1007
- read?: boolean | undefined;
1008
- } | undefined;
1009
- };
1010
- //#endregion
1011
- //#region src/configure/services/tailordb/types.d.ts
1012
- type SerialConfig<T extends "string" | "integer" = "string" | "integer"> = Prettify<{
1013
- start: number;
1014
- maxValue?: number;
1015
- } & (T extends "string" ? {
1016
- format?: string;
1017
- } : object)>;
1018
- interface DBFieldMetadata extends FieldMetadata {
1019
- index?: boolean;
1020
- unique?: boolean;
1021
- vector?: boolean;
1022
- foreignKey?: boolean;
1023
- foreignKeyType?: string;
1024
- foreignKeyField?: string;
1025
- hooks?: Hook<any, any>;
1026
- serial?: SerialConfig;
1027
- relation?: boolean;
1028
- scale?: number;
1029
- }
1030
- interface DefinedDBFieldMetadata extends DefinedFieldMetadata {
1031
- index?: boolean;
1032
- unique?: boolean;
1033
- vector?: boolean;
1034
- foreignKey?: boolean;
1035
- foreignKeyType?: boolean;
1036
- validate?: boolean;
1037
- hooks?: {
1038
- create: boolean;
1039
- update: boolean;
1040
- };
1041
- serial?: boolean;
1042
- relation?: boolean;
1043
- }
1044
- type ExcludeNestedDBFields<T extends Record<string, TailorAnyDBField>> = { [K in keyof T]: T[K] extends TailorDBField<{
1045
- type: "nested";
1046
- array: boolean;
1047
- }, any> ? never : T[K] };
1048
- type HookFn<TValue, TData, TReturn> = (args: {
1049
- value: TValue;
1050
- data: TData extends Record<string, unknown> ? { readonly [K in keyof TData]?: TData[K] | null | undefined } : unknown;
1051
- user: TailorUser;
1052
- }) => TReturn;
1053
- type Hook<TData, TReturn> = {
1054
- create?: HookFn<TReturn | null, TData, TReturn>;
1055
- update?: HookFn<TReturn | null, TData, TReturn>;
1056
- };
1057
- type Hooks<F extends Record<string, TailorAnyDBField>, TData = { [K in keyof F]: output<F[K]> }> = NonEmptyObject<{ [K in Exclude<keyof F, "id"> as F[K]["_defined"] extends {
1058
- hooks: unknown;
1059
- } ? never : F[K]["_defined"] extends {
1060
- type: "nested";
1061
- } ? never : K]?: Hook<TData, output<F[K]>> }>;
1062
- type IndexDef<T extends {
1063
- fields: Record<PropertyKey, unknown>;
1064
- }> = {
1065
- fields: [keyof T["fields"], keyof T["fields"], ...(keyof T["fields"])[]];
1066
- unique?: boolean;
1067
- name?: string;
1068
- };
1069
- type GqlOperationsConfig = GqlOperationsInput;
1070
- interface TypeFeatures {
1071
- pluralForm?: string;
1072
- aggregation?: true;
1073
- bulkUpsert?: true;
1074
- /** Configure GraphQL operations for this type. Use "query" for read-only mode, or an object for granular control. */
1075
- gqlOperations?: GqlOperationsConfig;
1076
- /**
1077
- * Enable publishing events for this type.
1078
- * When enabled, record creation/update/deletion events are published.
1079
- * If not specified, this is automatically set to true when an executor uses this type
1080
- * with recordCreated/recordUpdated/recordDeleted triggers. If explicitly set to false
1081
- * while an executor uses this type, an error will be thrown during apply.
1082
- */
1083
- publishEvents?: boolean;
1084
- }
1085
- //#endregion
1086
- //#region src/configure/services/tailordb/schema.d.ts
1087
- interface RelationConfig<S extends RelationType, T extends TailorDBType$1> {
1088
- type: S;
1089
- toward: {
1090
- type: T;
1091
- as?: string;
1092
- key?: keyof T["fields"] & string;
1093
- };
1094
- backward?: string;
1095
- }
1096
- type RelationSelfConfig = {
1097
- type: RelationType;
1098
- toward: {
1099
- type: "self";
1100
- as?: string;
1101
- key?: string;
1102
- };
1103
- backward?: string;
1104
- };
1105
- type TailorAnyDBField = TailorDBField<any, any>;
1106
- type TailorAnyDBType = TailorDBType$1<any, any>;
1107
- /**
1108
- * TailorDBField interface representing a database field with extended metadata.
1109
- * Extends TailorField with database-specific features like relations, indexes, and hooks.
1110
- */
1111
- interface TailorDBField<Defined extends DefinedDBFieldMetadata, Output> extends Omit<TailorField<Defined, Output, DBFieldMetadata, Defined["type"]>, "description" | "validate"> {
1112
- /**
1113
- * typeName is not available on TailorDB fields.
1114
- * Use typeName on pipeline fields (t.enum / t.object) instead.
1115
- */
1116
- typeName(this: never, typeName: string): never;
1117
- /** Returns a shallow copy of the raw relation config if set */
1118
- readonly rawRelation: Readonly<RawRelationConfig> | undefined;
1119
- /**
1120
- * Set a description for the field
1121
- * @param description - The description text
1122
- * @returns The field with updated metadata
1123
- */
1124
- description<CurrentDefined extends Defined>(this: CurrentDefined extends {
1125
- description: unknown;
1126
- } ? never : TailorField<CurrentDefined, Output>, description: string): TailorDBField<Prettify<CurrentDefined & {
1127
- description: true;
1128
- }>, Output>;
1129
- /**
1130
- * Define a relation to another type.
1131
- * Relation types: "n-1" (many-to-one), "1-1" (one-to-one), "keyOnly" (key only).
1132
- * Aliases "manyToOne", "oneToOne", and "N-1" are also accepted.
1133
- * @example db.uuid().relation({ type: "n-1", toward: { type: otherModel } })
1134
- * @example db.uuid().relation({ type: "1-1", toward: { type: profile } })
1135
- */
1136
- relation<S extends RelationType, T extends TailorAnyDBType, CurrentDefined extends Defined>(this: CurrentDefined extends {
1137
- relation: unknown;
1138
- } ? never : TailorDBField<CurrentDefined, Output>, config: RelationConfig<S, T>): TailorDBField<S extends "oneToOne" | "1-1" ? Prettify<CurrentDefined & {
1139
- unique: true;
1140
- index: true;
1141
- relation: true;
1142
- }> : Prettify<CurrentDefined & {
1143
- index: true;
1144
- relation: true;
1145
- }>, Output>;
1146
- /**
1147
- * Define a self-referencing relation
1148
- */
1149
- relation<S extends RelationSelfConfig, CurrentDefined extends Defined>(this: CurrentDefined extends {
1150
- relation: unknown;
1151
- } ? never : TailorDBField<CurrentDefined, Output>, config: S): TailorDBField<S["type"] extends "oneToOne" | "1-1" ? Prettify<CurrentDefined & {
1152
- unique: true;
1153
- index: true;
1154
- relation: true;
1155
- }> : Prettify<CurrentDefined & {
1156
- index: true;
1157
- relation: true;
1158
- }>, Output>;
1159
- /**
1160
- * Add an index to the field
1161
- */
1162
- index<CurrentDefined extends Defined>(this: CurrentDefined extends {
1163
- index: unknown;
1164
- } ? never : CurrentDefined extends {
1165
- array: true;
1166
- } ? never : TailorDBField<CurrentDefined, Output>): TailorDBField<Prettify<CurrentDefined & {
1167
- index: true;
1168
- }>, Output>;
1169
- /**
1170
- * Make the field unique (also adds an index)
1171
- */
1172
- unique<CurrentDefined extends Defined>(this: CurrentDefined extends {
1173
- unique: unknown;
1174
- } ? never : CurrentDefined extends {
1175
- array: true;
1176
- } ? never : TailorDBField<CurrentDefined, Output>): TailorDBField<Prettify<CurrentDefined & {
1177
- unique: true;
1178
- index: true;
1179
- }>, Output>;
1180
- /**
1181
- * Enable vector search on the field (string type only)
1182
- */
1183
- vector<CurrentDefined extends Defined>(this: CurrentDefined extends {
1184
- vector: unknown;
1185
- } ? never : CurrentDefined extends {
1186
- type: "string";
1187
- array: false;
1188
- } ? TailorDBField<CurrentDefined, Output> : never): TailorDBField<Prettify<CurrentDefined & {
1189
- vector: true;
1190
- }>, Output>;
1191
- /**
1192
- * Add hooks for create/update operations on this field.
1193
- * The hook function receives `{ value, data, user }` and returns the computed value.
1194
- * @example db.string().hooks({ create: ({ data }) => data.firstName + " " + data.lastName })
1195
- * @example db.datetime().hooks({ create: () => new Date(), update: () => new Date() })
1196
- */
1197
- hooks<CurrentDefined extends Defined, const H extends Hook<unknown, Output>>(this: CurrentDefined extends {
1198
- hooks: unknown;
1199
- } ? never : CurrentDefined extends {
1200
- type: "nested";
1201
- } ? never : TailorDBField<CurrentDefined, Output>, hooks: H): TailorDBField<Prettify<CurrentDefined & {
1202
- hooks?: {
1203
- create: H extends {
1204
- create: unknown;
1205
- } ? true : false;
1206
- update: H extends {
1207
- update: unknown;
1208
- } ? true : false;
1209
- };
1210
- serial: false;
1211
- }>, Output>;
1212
- /**
1213
- * Add validation functions to the field.
1214
- * Accepts a function or a tuple of [function, errorMessage].
1215
- * Prefer the tuple form for diagnosable errors.
1216
- * @example
1217
- * // Function form (default error message):
1218
- * db.int().validate(({ value }) => value >= 0)
1219
- * @example
1220
- * // Tuple form with custom error message (recommended):
1221
- * db.string().validate([({ value }) => value.length >= 8, "Must be at least 8 characters"])
1222
- */
1223
- validate<CurrentDefined extends Defined>(this: CurrentDefined extends {
1224
- validate: unknown;
1225
- } ? never : TailorDBField<CurrentDefined, Output>, ...validate: FieldValidateInput<Output>[]): TailorDBField<Prettify<CurrentDefined & {
1226
- validate: true;
1227
- }>, Output>;
1228
- /**
1229
- * Configure serial/auto-increment behavior
1230
- */
1231
- serial<CurrentDefined extends Defined>(this: CurrentDefined extends {
1232
- serial: unknown;
1233
- } ? never : Output extends null ? never : CurrentDefined extends {
1234
- type: "integer" | "string";
1235
- array: false;
1236
- } ? TailorDBField<CurrentDefined, Output> : never, config: SerialConfig<CurrentDefined["type"] & ("integer" | "string")>): TailorDBField<Prettify<CurrentDefined & {
1237
- serial: true;
1238
- hooks: {
1239
- create: false;
1240
- update: false;
1241
- };
1242
- }>, Output>;
1243
- /**
1244
- * Clone the field with optional overrides for field options
1245
- * @param options - Optional field options to override
1246
- * @returns A new TailorDBField instance with the same configuration
1247
- */
1248
- clone<const NewOpt extends FieldOptions>(options?: NewOpt): TailorDBField<Prettify<Omit<Defined, "array"> & {
1249
- array: NewOpt extends {
1250
- array: true;
1251
- } ? true : Defined["array"];
1252
- }>, FieldOutput$1<TailorToTs[Defined["type"]], NewOpt>>;
1253
- }
1254
- /**
1255
- * Create a UUID field.
1256
- * @param options - Field configuration options
1257
- * @returns A UUID field
1258
- * @example db.uuid()
1259
- * @example db.uuid({ optional: true })
1260
- */
1261
- declare function uuid<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1262
- type: "uuid";
1263
- array: Opt extends {
1264
- array: true;
1265
- } ? true : false;
1266
- }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
1267
- /**
1268
- * Create a string field.
1269
- * @param options - Field configuration options
1270
- * @returns A string field
1271
- * @example db.string()
1272
- * @example db.string({ optional: true })
1273
- */
1274
- declare function string<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1275
- type: "string";
1276
- array: Opt extends {
1277
- array: true;
1278
- } ? true : false;
1279
- }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
1280
- /**
1281
- * Create a boolean field.
1282
- * Note: The method name is `bool` but creates a `boolean` type field.
1283
- * @param options - Field configuration options
1284
- * @returns A boolean field
1285
- * @example db.bool()
1286
- * @example db.bool({ optional: true })
1287
- */
1288
- declare function bool<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1289
- type: "boolean";
1290
- array: Opt extends {
1291
- array: true;
1292
- } ? true : false;
1293
- }, Opt["optional"] extends true ? ArrayFieldOutput<boolean, Opt> | null : ArrayFieldOutput<boolean, Opt>>;
1294
- /**
1295
- * Create an integer field.
1296
- * @param options - Field configuration options
1297
- * @returns An integer field
1298
- * @example db.int()
1299
- * @example db.int({ optional: true })
1300
- */
1301
- declare function int<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1302
- type: "integer";
1303
- array: Opt extends {
1304
- array: true;
1305
- } ? true : false;
1306
- }, Opt["optional"] extends true ? ArrayFieldOutput<number, Opt> | null : ArrayFieldOutput<number, Opt>>;
1307
- /**
1308
- * Create a float (decimal number) field.
1309
- * @param options - Field configuration options
1310
- * @returns A float field
1311
- * @example db.float()
1312
- * @example db.float({ optional: true })
1313
- */
1314
- declare function float<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1315
- type: "float";
1316
- array: Opt extends {
1317
- array: true;
1318
- } ? true : false;
1319
- }, Opt["optional"] extends true ? ArrayFieldOutput<number, Opt> | null : ArrayFieldOutput<number, Opt>>;
1320
- interface DecimalFieldOptions extends FieldOptions {
1321
- scale?: number;
1322
- }
1323
- /**
1324
- * Create a decimal field (stored as string for precision).
1325
- * @param options - Field configuration options including optional scale (0-12)
1326
- * @returns A decimal field
1327
- * @example db.decimal()
1328
- * @example db.decimal({ scale: 2 })
1329
- * @example db.decimal({ scale: 2, optional: true })
1330
- */
1331
- declare function decimal<const Opt extends DecimalFieldOptions>(options?: Opt): TailorDBField<{
1332
- type: "decimal";
1333
- array: Opt extends {
1334
- array: true;
1335
- } ? true : false;
1336
- }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
1337
- /**
1338
- * Create a date field (date only, no time component).
1339
- * Format: "yyyy-MM-dd"
1340
- * @param options - Field configuration options
1341
- * @returns A date field
1342
- * @example db.date()
1343
- */
1344
- declare function date<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1345
- type: "date";
1346
- array: Opt extends {
1347
- array: true;
1348
- } ? true : false;
1349
- }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
1350
- /**
1351
- * Create a datetime field (date and time).
1352
- * Format: ISO 8601 "yyyy-MM-ddTHH:mm:ssZ"
1353
- * @param options - Field configuration options
1354
- * @returns A datetime field
1355
- * @example db.datetime()
1356
- */
1357
- declare function datetime<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1358
- type: "datetime";
1359
- array: Opt extends {
1360
- array: true;
1361
- } ? true : false;
1362
- }, Opt["optional"] extends true ? ArrayFieldOutput<string | Date, Opt> | null : ArrayFieldOutput<string | Date, Opt>>;
1363
- /**
1364
- * Create a time field (time only, no date component).
1365
- * Format: "HH:mm"
1366
- * @param options - Field configuration options
1367
- * @returns A time field
1368
- * @example db.time()
1369
- */
1370
- declare function time<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1371
- type: "time";
1372
- array: Opt extends {
1373
- array: true;
1374
- } ? true : false;
1375
- }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
1376
- /**
1377
- * Create an enum field with a fixed set of allowed string values.
1378
- * @param values - Array of allowed string values, or array of `{ value, description }` objects
1379
- * @param options - Field configuration options
1380
- * @returns An enum field
1381
- * @example db.enum(["active", "inactive", "suspended"])
1382
- * @example db.enum(["small", "medium", "large"], { optional: true })
1383
- */
1384
- declare function _enum<const V extends AllowedValues, const Opt extends FieldOptions>(values: V, options?: Opt): TailorDBField<{
1385
- type: "enum";
1386
- array: Opt extends {
1387
- array: true;
1388
- } ? true : false;
1389
- }, FieldOutput$1<AllowedValuesOutput<V>, Opt>>;
1390
- /**
1391
- * Create a nested object field with sub-fields.
1392
- * @param fields - Record of nested field definitions
1393
- * @param options - Field configuration options
1394
- * @returns A nested object field
1395
- * @example db.object({ street: db.string(), city: db.string(), zip: db.string() })
1396
- * @example db.object({ name: db.string() }, { optional: true })
1397
- */
1398
- declare function object<const F extends Record<string, TailorAnyDBField> & ExcludeNestedDBFields<F>, const Opt extends FieldOptions>(fields: F, options?: Opt): TailorDBField<{
1399
- type: "nested";
1400
- array: Opt extends {
1401
- array: true;
1402
- } ? true : false;
1403
- }, FieldOutput$1<InferFieldsOutput<F>, Opt>>;
1404
- /**
1405
- * TailorDBType interface representing a database type definition with fields, permissions, and settings.
1406
- */
1407
- interface TailorDBType$1<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributeMap> {
1408
- readonly name: string;
1409
- readonly fields: Fields;
1410
- readonly _output: InferFieldsOutput<Fields>;
1411
- _description?: string;
1412
- /** Returns metadata for the type */
1413
- readonly metadata: TailorDBTypeMetadata;
1414
- /**
1415
- * Add hooks for fields at the type level.
1416
- * Each key is a field name, and the value defines create/update hooks.
1417
- * @example
1418
- * db.type("Order", {
1419
- * total: db.float(),
1420
- * tax: db.float(),
1421
- * ...db.fields.timestamps(),
1422
- * }).hooks({
1423
- * tax: { create: ({ data }) => data.total * 0.1, update: ({ data }) => data.total * 0.1 },
1424
- * })
1425
- */
1426
- hooks(hooks: Hooks<Fields>): TailorDBType$1<Fields, User>;
1427
- /**
1428
- * Add validators for fields at the type level.
1429
- * Each key is a field name, and the value is a validator or array of validators.
1430
- * Prefer the tuple form [function, message] for diagnosable errors.
1431
- * @example
1432
- * db.type("User", { email: db.string() }).validate({
1433
- * email: [({ value }) => value.includes("@"), "Email must contain @"],
1434
- * })
1435
- */
1436
- validate(validators: Validators<Fields>): TailorDBType$1<Fields, User>;
1437
- /**
1438
- * Configure type features
1439
- */
1440
- features(features: Omit<TypeFeatures, "pluralForm">): TailorDBType$1<Fields, User>;
1441
- /**
1442
- * Define composite indexes
1443
- */
1444
- indexes(...indexes: IndexDef<TailorDBType$1<Fields, User>>[]): TailorDBType$1<Fields, User>;
1445
- /**
1446
- * Define file fields
1447
- */
1448
- files<const F extends string>(files: Record<F, string> & Partial<Record<keyof output<TailorDBType$1<Fields, User>>, never>>): TailorDBType$1<Fields, User>;
1449
- /**
1450
- * Set record-level permissions for create, read, update, and delete operations.
1451
- * Prefer object format with explicit `conditions` and `permit` for readability.
1452
- * For update operations, use `newRecord` and `oldRecord` operands.
1453
- * @example
1454
- * .permission({
1455
- * create: [{ conditions: [[{ user: "_loggedIn" }, "=", true]], permit: true }],
1456
- * read: [{ conditions: [[{ record: "isPublic" }, "=", true]], permit: true }],
1457
- * update: [{ conditions: [[{ newRecord: "ownerId" }, "=", { user: "id" }]], permit: true }],
1458
- * delete: [{ conditions: [[{ record: "ownerId" }, "=", { user: "id" }]], permit: true }],
1459
- * })
1460
- */
1461
- permission<U extends object = User, P extends TailorTypePermission<U, output<TailorDBType$1<Fields, User>>> = TailorTypePermission<U, output<TailorDBType$1<Fields, User>>>>(permission: P): TailorDBType$1<Fields, U>;
1462
- /**
1463
- * Set GraphQL-level permissions controlling access to GraphQL operations.
1464
- * @example
1465
- * .gqlPermission([
1466
- * {
1467
- * conditions: [[{ user: "_loggedIn" }, "=", true]],
1468
- * actions: "all",
1469
- * permit: true,
1470
- * },
1471
- * ])
1472
- */
1473
- gqlPermission<U extends object = User, P extends TailorTypeGqlPermission<U> = TailorTypeGqlPermission<U>>(permission: P): TailorDBType$1<Fields, U>;
1474
- /**
1475
- * Set type description
1476
- */
1477
- description(description: string): TailorDBType$1<Fields, User>;
1478
- /**
1479
- * Pick specific fields from the type
1480
- */
1481
- pickFields<K extends keyof Fields>(keys: K[]): Pick<Fields, K>;
1482
- pickFields<K extends keyof Fields, const Opt extends FieldOptions>(keys: K[], options: Opt): { [P in K]: Fields[P] extends TailorDBField<infer D, infer _O> ? TailorDBField<Omit<D, "array"> & {
1483
- array: Opt extends {
1484
- array: true;
1485
- } ? true : D["array"];
1486
- }, FieldOutput$1<TailorToTs[D["type"]], Opt>> : never };
1487
- /**
1488
- * Omit specific fields from the type
1489
- */
1490
- omitFields<K extends keyof Fields>(keys: K[]): Omit<Fields, K>;
1491
- /**
1492
- * Plugin attachments for this type
1493
- */
1494
- readonly plugins: PluginAttachment[];
1495
- /**
1496
- * Attach a plugin to this type
1497
- * @param config - Plugin configuration in the format { pluginId: config }
1498
- * @returns The type with the plugin attached
1499
- */
1500
- plugin<P extends keyof PluginConfigs<keyof Fields & string>>(config: { [K in P]: PluginConfigs<keyof Fields & string>[K] }): TailorDBType$1<Fields, User>;
1501
- }
1502
- type TailorDBInstance<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributeMap> = TailorDBType$1<Fields, User>;
1503
- declare const idField: TailorDBField<{
1504
- type: "uuid";
1505
- array: false;
1506
- }, string>;
1507
- type idField = typeof idField;
1508
- type DBType<F extends {
1509
- id?: never;
1510
- } & Record<string, TailorAnyDBField>> = TailorDBInstance<{
1511
- id: idField;
1512
- } & F>;
1513
- /**
1514
- * Creates a new database type with the specified fields.
1515
- * An `id` field (UUID) is automatically added to every type.
1516
- * @param name - The name of the type, or a tuple of [name, pluralForm]
1517
- * @param fields - The field definitions for the type
1518
- * @returns A new TailorDBType instance
1519
- * @example
1520
- * export const user = db.type("User", {
1521
- * name: db.string(),
1522
- * email: db.string(),
1523
- * age: db.int({ optional: true }),
1524
- * role: db.enum(["admin", "member"]),
1525
- * ...db.fields.timestamps(),
1526
- * });
1527
- * // Always export both the value and type:
1528
- * export type user = typeof user;
1529
- */
1530
- declare function dbType<const F extends {
1531
- id?: never;
1532
- } & Record<string, TailorAnyDBField>>(name: string | [string, string], fields: F): DBType<F>;
1533
- /**
1534
- * Creates a new database type with the specified fields and description.
1535
- * An `id` field (UUID) is automatically added to every type.
1536
- * @param name - The name of the type, or a tuple of [name, pluralForm]
1537
- * @param description - A description of the type
1538
- * @param fields - The field definitions for the type
1539
- * @returns A new TailorDBType instance
1540
- */
1541
- declare function dbType<const F extends {
1542
- id?: never;
1543
- } & Record<string, TailorAnyDBField>>(name: string | [string, string], description: string, fields: F): DBType<F>;
1544
- /** TailorDB schema builder utilities for defining types and fields. */
1545
- declare const db: {
1546
- type: typeof dbType;
1547
- uuid: typeof uuid;
1548
- string: typeof string;
1549
- bool: typeof bool;
1550
- int: typeof int;
1551
- float: typeof float;
1552
- decimal: typeof decimal;
1553
- date: typeof date;
1554
- datetime: typeof datetime;
1555
- time: typeof time;
1556
- enum: typeof _enum;
1557
- object: typeof object;
1558
- fields: {
1559
- /**
1560
- * Creates standard timestamp fields (createdAt, updatedAt) with auto-hooks.
1561
- * createdAt is set on create, updatedAt is set on update.
1562
- * @returns An object with createdAt and updatedAt fields
1563
- * @example
1564
- * const model = db.type("Model", {
1565
- * name: db.string(),
1566
- * ...db.fields.timestamps(),
1567
- * });
1568
- */
1569
- timestamps: () => {
1570
- createdAt: TailorDBField<{
1571
- type: "datetime";
1572
- array: false;
1573
- hooks?: {
1574
- create: true;
1575
- update: false;
1576
- } | undefined;
1577
- serial: false;
1578
- description: true;
1579
- }, string | Date>;
1580
- updatedAt: TailorDBField<{
1581
- type: "datetime";
1582
- array: false;
1583
- hooks?: {
1584
- create: false;
1585
- update: true;
1586
- } | undefined;
1587
- serial: false;
1588
- description: true;
1589
- }, string | Date | null>;
1590
- };
1591
- };
1592
- };
1593
- //#endregion
1594
- //#region src/types/auth.d.ts
1595
- type OAuth2ClientGrantType = OAuth2Client["grantTypes"][number];
1596
- type SCIMAttributeType = SCIMAttribute["type"];
1597
- type AuthInvokerWithName<M extends string> = Omit<AuthInvoker, "machineUserName"> & {
1598
- machineUserName: M;
1599
- };
1600
- /** Result of retrieving a connection token at runtime. */
1601
- type AuthConnectionTokenResult = {
1602
- access_token: string;
1603
- refresh_token?: string;
1604
- token_type?: string;
1605
- expiry?: string;
1606
- };
1607
- type ValueOperand = string | boolean | string[] | boolean[];
1608
- type AuthAttributeValue = ValueOperand | null | undefined;
1609
- type UserFieldKeys<User extends TailorDBInstance> = keyof output<User> & string;
1610
- type FieldDefined<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = User["fields"][Key] extends {
1611
- _defined: infer Defined;
1612
- } ? Defined : never;
1613
- type FieldOutput<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = output<User>[Key];
1614
- type FieldIsRequired<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = undefined extends FieldOutput<User, Key> ? false : true;
1615
- type FieldIsOfType<User extends TailorDBInstance, Key extends UserFieldKeys<User>, Type extends string> = FieldDefined<User, Key> extends {
1616
- type: Type;
1617
- } ? true : false;
1618
- type FieldIsArray<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldDefined<User, Key> extends {
1619
- array: true;
1620
- } ? true : false;
1621
- type FieldIsUnique<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldDefined<User, Key> extends {
1622
- unique: true;
1623
- } ? true : false;
1624
- type FieldSupportsValueOperand<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldOutput<User, Key> extends ValueOperand | null | undefined ? true : false;
1625
- type UsernameFieldKey<User extends TailorDBInstance> = IsAny<User> extends true ? string : { [K in UserFieldKeys<User>]: FieldIsRequired<User, K> extends true ? FieldIsOfType<User, K, "string"> extends true ? FieldIsArray<User, K> extends true ? never : FieldIsUnique<User, K> extends true ? K : never : never : never }[UserFieldKeys<User>];
1626
- type UserAttributeKey<User extends TailorDBInstance> = { [K in UserFieldKeys<User>]: K extends "id" ? never : FieldSupportsValueOperand<User, K> extends true ? FieldIsOfType<User, K, "datetime" | "date" | "time"> extends true ? never : K : never }[UserFieldKeys<User>];
1627
- type UserAttributeListKey<User extends TailorDBInstance> = { [K in UserFieldKeys<User>]: K extends "id" ? never : FieldIsOfType<User, K, "uuid"> extends true ? FieldIsArray<User, K> extends true ? never : K : never }[UserFieldKeys<User>];
1628
- type UserAttributeMap<User extends TailorDBInstance> = { [K in UserAttributeKey<User>]?: true };
1629
- type DisallowExtraKeys<T, Allowed extends PropertyKey> = T & { [K in Exclude<keyof T, Allowed>]: never };
1630
- type AttributeListValue<User extends TailorDBInstance, Key extends UserAttributeListKey<User>> = Key extends keyof output<User> ? output<User>[Key] : never;
1631
- type AttributeListToTuple<User extends TailorDBInstance, AttributeList extends readonly UserAttributeListKey<User>[]> = { [Index in keyof AttributeList]: AttributeList[Index] extends UserAttributeListKey<User> ? AttributeListValue<User, AttributeList[Index]> : never };
1632
- type AttributeMapSelectedKeys<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User>> = Extract<{ [K in keyof AttributeMap]-?: undefined extends AttributeMap[K] ? never : K }[keyof AttributeMap], UserAttributeKey<User>>;
1633
- type UserProfile<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[]> = {
1634
- /**
1635
- * TailorDB namespace where the user type is defined.
1636
- *
1637
- * Usually auto-resolved, so you don't need to specify this.
1638
- * Required only when multiple TailorDBs exist and the type is in an external TailorDB.
1639
- */
1640
- namespace?: string;
1641
- type: User;
1642
- usernameField: UsernameFieldKey<User>;
1643
- attributes?: DisallowExtraKeys<AttributeMap, UserAttributeKey<User>>;
1644
- attributeList?: AttributeList;
1645
- };
1646
- type MachineUserAttributeFields = Record<string, TailorField<DefinedFieldMetadata, unknown, FieldMetadata, TailorFieldType>>;
1647
- type TailorFieldOutputValue<Field> = Field extends TailorField<DefinedFieldMetadata, infer Output, FieldMetadata, TailorFieldType> ? Output : never;
1648
- type MachineUserAttributeValues<Fields extends MachineUserAttributeFields> = { [K in keyof Fields]: TailorFieldOutputValue<Fields[K]> extends ValueOperand | null | undefined ? TailorFieldOutputValue<Fields[K]> : never };
1649
- type MachineUserFromAttributes<Fields extends MachineUserAttributeFields> = (keyof Fields extends never ? {
1650
- attributes?: never;
1651
- } : {
1652
- attributes: DisallowExtraKeys<MachineUserAttributeValues<Fields>, keyof Fields>;
1653
- }) & {
1654
- attributeList?: string[];
1655
- };
1656
- type MachineUser<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User> = UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[] = [], MachineUserAttributes extends MachineUserAttributeFields | undefined = undefined> = IsAny<MachineUserAttributes> extends true ? IsAny<User> extends true ? {
1657
- attributes: Record<string, AuthAttributeValue>;
1658
- attributeList?: string[];
1659
- } : (AttributeMapSelectedKeys<User, AttributeMap> extends never ? {
1660
- attributes?: never;
1661
- } : {
1662
- attributes: { [K in AttributeMapSelectedKeys<User, AttributeMap>]: K extends keyof output<User> ? output<User>[K] : never } & { [K in Exclude<keyof output<User>, AttributeMapSelectedKeys<User, AttributeMap>>]?: never };
1663
- }) & ([] extends AttributeList ? {
1664
- attributeList?: never;
1665
- } : {
1666
- attributeList: AttributeListToTuple<User, AttributeList>;
1667
- }) : [MachineUserAttributes] extends [MachineUserAttributeFields] ? MachineUserFromAttributes<MachineUserAttributes> : IsAny<User> extends true ? {
1668
- attributes: Record<string, AuthAttributeValue>;
1669
- attributeList?: string[];
1670
- } : (AttributeMapSelectedKeys<User, AttributeMap> extends never ? {
1671
- attributes?: never;
1672
- } : {
1673
- attributes: { [K in AttributeMapSelectedKeys<User, AttributeMap>]: K extends keyof output<User> ? output<User>[K] : never } & { [K in Exclude<keyof output<User>, AttributeMapSelectedKeys<User, AttributeMap>>]?: never };
1674
- }) & ([] extends AttributeList ? {
1675
- attributeList?: never;
1676
- } : {
1677
- attributeList: AttributeListToTuple<User, AttributeList>;
1678
- });
1679
- type BeforeLoginHookArgs = {
1680
- claims: JsonObject;
1681
- idpConfigName: string;
1682
- };
1683
- type BeforeLoginHook<MachineUserNames extends string> = {
1684
- handler(args: BeforeLoginHookArgs): Promise<void>;
1685
- invoker: NoInfer<MachineUserNames>;
1686
- };
1687
- type AuthHooks<MachineUserNames extends string> = {
1688
- beforeLogin?: BeforeLoginHook<MachineUserNames>;
1689
- };
1690
- type AuthServiceInput<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[], MachineUserNames extends string, MachineUserAttributes extends MachineUserAttributeFields | undefined = MachineUserAttributeFields | undefined, ConnectionNames extends string = string> = {
1691
- hooks?: AuthHooks<MachineUserNames>;
1692
- userProfile?: UserProfile<User, AttributeMap, AttributeList>;
1693
- machineUserAttributes?: MachineUserAttributes;
1694
- machineUsers?: Record<MachineUserNames, MachineUser<User, AttributeMap, AttributeList, MachineUserAttributes>>;
1695
- oauth2Clients?: Record<string, OAuth2ClientInput>;
1696
- idProvider?: IdProvider;
1697
- scim?: SCIMConfig;
1698
- tenantProvider?: TenantProvider;
1699
- connections?: Record<ConnectionNames, AuthConnectionConfig>;
1700
- publishSessionEvents?: boolean;
1701
- };
1702
- declare const authDefinitionBrand: unique symbol;
1703
- type AuthDefinitionBrand = {
1704
- readonly [authDefinitionBrand]: true;
915
+ })] | readonly (readonly [(string | boolean | string[] | boolean[] | {
916
+ user: string;
917
+ } | {
918
+ record: string;
919
+ } | {
920
+ oldRecord: string;
921
+ } | {
922
+ newRecord: string;
923
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
924
+ user: string;
925
+ } | {
926
+ record: string;
927
+ } | {
928
+ oldRecord: string;
929
+ } | {
930
+ newRecord: string;
931
+ })])[];
932
+ description?: string | undefined;
933
+ permit?: boolean | undefined;
934
+ })[];
935
+ update: readonly (readonly [(string | boolean | string[] | boolean[] | {
936
+ user: string;
937
+ } | {
938
+ record: string;
939
+ } | {
940
+ oldRecord: string;
941
+ } | {
942
+ newRecord: string;
943
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
944
+ user: string;
945
+ } | {
946
+ record: string;
947
+ } | {
948
+ oldRecord: string;
949
+ } | {
950
+ newRecord: string;
951
+ })] | readonly [(string | boolean | string[] | boolean[] | {
952
+ user: string;
953
+ } | {
954
+ record: string;
955
+ } | {
956
+ oldRecord: string;
957
+ } | {
958
+ newRecord: string;
959
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
960
+ user: string;
961
+ } | {
962
+ record: string;
963
+ } | {
964
+ oldRecord: string;
965
+ } | {
966
+ newRecord: string;
967
+ }), boolean] | readonly (boolean | readonly [(string | boolean | string[] | boolean[] | {
968
+ user: string;
969
+ } | {
970
+ record: string;
971
+ } | {
972
+ oldRecord: string;
973
+ } | {
974
+ newRecord: string;
975
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
976
+ user: string;
977
+ } | {
978
+ record: string;
979
+ } | {
980
+ oldRecord: string;
981
+ } | {
982
+ newRecord: string;
983
+ })])[] | {
984
+ conditions: readonly [(string | boolean | string[] | boolean[] | {
985
+ user: string;
986
+ } | {
987
+ record: string;
988
+ } | {
989
+ oldRecord: string;
990
+ } | {
991
+ newRecord: string;
992
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
993
+ user: string;
994
+ } | {
995
+ record: string;
996
+ } | {
997
+ oldRecord: string;
998
+ } | {
999
+ newRecord: string;
1000
+ })] | readonly (readonly [(string | boolean | string[] | boolean[] | {
1001
+ user: string;
1002
+ } | {
1003
+ record: string;
1004
+ } | {
1005
+ oldRecord: string;
1006
+ } | {
1007
+ newRecord: string;
1008
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
1009
+ user: string;
1010
+ } | {
1011
+ record: string;
1012
+ } | {
1013
+ oldRecord: string;
1014
+ } | {
1015
+ newRecord: string;
1016
+ })])[];
1017
+ description?: string | undefined;
1018
+ permit?: boolean | undefined;
1019
+ })[];
1020
+ delete: readonly (readonly [(string | boolean | string[] | boolean[] | {
1021
+ user: string;
1022
+ } | {
1023
+ record: string;
1024
+ } | {
1025
+ oldRecord: string;
1026
+ } | {
1027
+ newRecord: string;
1028
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
1029
+ user: string;
1030
+ } | {
1031
+ record: string;
1032
+ } | {
1033
+ oldRecord: string;
1034
+ } | {
1035
+ newRecord: string;
1036
+ })] | readonly [(string | boolean | string[] | boolean[] | {
1037
+ user: string;
1038
+ } | {
1039
+ record: string;
1040
+ } | {
1041
+ oldRecord: string;
1042
+ } | {
1043
+ newRecord: string;
1044
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
1045
+ user: string;
1046
+ } | {
1047
+ record: string;
1048
+ } | {
1049
+ oldRecord: string;
1050
+ } | {
1051
+ newRecord: string;
1052
+ }), boolean] | readonly (boolean | readonly [(string | boolean | string[] | boolean[] | {
1053
+ user: string;
1054
+ } | {
1055
+ record: string;
1056
+ } | {
1057
+ oldRecord: string;
1058
+ } | {
1059
+ newRecord: string;
1060
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
1061
+ user: string;
1062
+ } | {
1063
+ record: string;
1064
+ } | {
1065
+ oldRecord: string;
1066
+ } | {
1067
+ newRecord: string;
1068
+ })])[] | {
1069
+ conditions: readonly [(string | boolean | string[] | boolean[] | {
1070
+ user: string;
1071
+ } | {
1072
+ record: string;
1073
+ } | {
1074
+ oldRecord: string;
1075
+ } | {
1076
+ newRecord: string;
1077
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
1078
+ user: string;
1079
+ } | {
1080
+ record: string;
1081
+ } | {
1082
+ oldRecord: string;
1083
+ } | {
1084
+ newRecord: string;
1085
+ })] | readonly (readonly [(string | boolean | string[] | boolean[] | {
1086
+ user: string;
1087
+ } | {
1088
+ record: string;
1089
+ } | {
1090
+ oldRecord: string;
1091
+ } | {
1092
+ newRecord: string;
1093
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
1094
+ user: string;
1095
+ } | {
1096
+ record: string;
1097
+ } | {
1098
+ oldRecord: string;
1099
+ } | {
1100
+ newRecord: string;
1101
+ })])[];
1102
+ description?: string | undefined;
1103
+ permit?: boolean | undefined;
1104
+ })[];
1105
+ } | undefined;
1106
+ gql?: readonly {
1107
+ conditions: readonly (readonly [(string | boolean | string[] | boolean[] | {
1108
+ user: string;
1109
+ }), "=" | "!=" | "in" | "not in" | "hasAny" | "not hasAny", (string | boolean | string[] | boolean[] | {
1110
+ user: string;
1111
+ })])[];
1112
+ actions: "all" | readonly ("create" | "read" | "update" | "delete" | "aggregate" | "bulkUpsert")[];
1113
+ permit?: boolean | undefined;
1114
+ description?: string | undefined;
1115
+ }[] | undefined;
1705
1116
  };
1706
- type ConnectionNames<Config> = Config extends {
1707
- connections?: Record<infer K, unknown>;
1708
- } ? K & string : string;
1709
- type DefinedAuth<Name extends string, Config, MachineUserNames extends string> = Config & {
1710
- name: Name;
1711
- /**
1712
- * @deprecated Pass the machine user name directly as a string instead, e.g. `authInvoker: "machine-user-name"`.
1713
- * Using this function pulls config-layer (Node-only) dependencies into runtime bundles.
1714
- */
1715
- invoker<M extends MachineUserNames>(machineUser: M): AuthInvokerWithName<M>;
1716
- getConnectionToken<C extends ConnectionNames<Config>>(connectionName: C): Promise<AuthConnectionTokenResult>;
1717
- } & AuthDefinitionBrand;
1718
- type AuthExternalConfig = {
1719
- name: string;
1720
- external: true;
1117
+ type TailorDBServiceConfigInput = {
1118
+ /** Glob patterns for TailorDB type definition files */files: string[]; /** Glob patterns to exclude from type discovery */
1119
+ ignores?: string[] | undefined; /** URL for the ERD (Entity Relationship Diagram) site */
1120
+ erdSite?: string | undefined; /** Migration configuration */
1121
+ migration?: {
1122
+ directory: string;
1123
+ machineUser?: string | undefined;
1124
+ } | undefined; /** Default GraphQL operations for all types in this service */
1125
+ gqlOperations?: "query" | {
1126
+ create?: boolean | undefined;
1127
+ update?: boolean | undefined;
1128
+ delete?: boolean | undefined;
1129
+ read?: boolean | undefined;
1130
+ } | undefined;
1721
1131
  };
1722
- type AuthServiceInputLoose = AuthServiceInput<any, any, any, string, any>;
1723
- type AuthOwnConfig = DefinedAuth<string, AuthServiceInputLoose, string>;
1724
- type AuthConfig = AuthOwnConfig | AuthExternalConfig;
1725
1132
  //#endregion
1726
1133
  //#region src/types/tailordb.d.ts
1134
+ type SerialConfig<T extends "string" | "integer" = "string" | "integer"> = Prettify<{
1135
+ start: number;
1136
+ maxValue?: number;
1137
+ } & (T extends "string" ? {
1138
+ format?: string;
1139
+ } : object)>;
1140
+ interface DBFieldMetadata extends FieldMetadata {
1141
+ index?: boolean;
1142
+ unique?: boolean;
1143
+ vector?: boolean;
1144
+ foreignKey?: boolean;
1145
+ foreignKeyType?: string;
1146
+ foreignKeyField?: string;
1147
+ /** Lifecycle hooks for the field */
1148
+ hooks?: DBFieldMetadata$1["hooks"];
1149
+ serial?: SerialConfig;
1150
+ relation?: boolean;
1151
+ scale?: number;
1152
+ }
1153
+ interface DefinedDBFieldMetadata extends DefinedFieldMetadata {
1154
+ index?: boolean;
1155
+ unique?: boolean;
1156
+ vector?: boolean;
1157
+ foreignKey?: boolean;
1158
+ foreignKeyType?: boolean;
1159
+ validate?: boolean;
1160
+ hooks?: {
1161
+ create: boolean;
1162
+ update: boolean;
1163
+ };
1164
+ serial?: boolean;
1165
+ relation?: boolean;
1166
+ }
1167
+ type IndexDef<T extends {
1168
+ fields: Record<PropertyKey, unknown>;
1169
+ }> = {
1170
+ fields: [keyof T["fields"], keyof T["fields"], ...(keyof T["fields"])[]];
1171
+ unique?: boolean;
1172
+ name?: string;
1173
+ };
1174
+ type GqlOperationsConfig = GqlOperationsInput;
1727
1175
  type RelationType = "1-1" | "oneToOne" | "n-1" | "manyToOne" | "N-1" | "keyOnly";
1728
1176
  type TailorDBExternalConfig = {
1729
1177
  external: true;
@@ -1751,10 +1199,6 @@ type TypeSourceInfoEntry = UserDefinedTypeSource | PluginGeneratedTypeSource;
1751
1199
  interface Script {
1752
1200
  expr: string;
1753
1201
  }
1754
- interface EnumValue {
1755
- value: string;
1756
- description?: string;
1757
- }
1758
1202
  interface OperatorValidateConfig {
1759
1203
  script: Script;
1760
1204
  errorMessage: string;
@@ -1800,14 +1244,14 @@ type StandardPermissionOperator = "eq" | "ne" | "in" | "nin" | "hasAny" | "nhasA
1800
1244
  type UserOperand = {
1801
1245
  user: string;
1802
1246
  };
1803
- type RecordOperand<Update extends boolean = false> = Update extends true ? {
1247
+ type StandardRecordOperand<Update extends boolean = false> = Update extends true ? {
1804
1248
  oldRecord: string;
1805
1249
  } | {
1806
1250
  newRecord: string;
1807
1251
  } : {
1808
1252
  record: string;
1809
1253
  };
1810
- type PermissionOperand<Level extends "record" | "gql" = "record" | "gql", Update extends boolean = boolean> = UserOperand | ValueOperand | (Level extends "record" ? RecordOperand<Update> : never);
1254
+ type PermissionOperand<Level extends "record" | "gql" = "record" | "gql", Update extends boolean = boolean> = UserOperand | ValueOperand | (Level extends "record" ? StandardRecordOperand<Update> : never);
1811
1255
  type StandardPermissionCondition<Level extends "record" | "gql" = "record" | "gql", Update extends boolean = boolean> = readonly [PermissionOperand<Level, Update>, StandardPermissionOperator, PermissionOperand<Level, Update>];
1812
1256
  type StandardActionPermission<Level extends "record" | "gql" = "record" | "gql", Update extends boolean = boolean> = {
1813
1257
  conditions: readonly StandardPermissionCondition<Level, Update>[];
@@ -1867,7 +1311,7 @@ interface ParsedRelationship {
1867
1311
  isArray: boolean;
1868
1312
  description: string;
1869
1313
  }
1870
- interface TailorDBType {
1314
+ interface TailorDBType$1 {
1871
1315
  name: string;
1872
1316
  pluralForm: string;
1873
1317
  description?: string;
@@ -1920,7 +1364,7 @@ interface TailorDBNamespaceData {
1920
1364
  /** Namespace name */
1921
1365
  namespace: string;
1922
1366
  /** All TailorDB types in this namespace, keyed by type name */
1923
- types: Record<string, TailorDBType>;
1367
+ types: Record<string, TailorDBType$1>;
1924
1368
  /** Source info for each type (file path, export name, plugin info) */
1925
1369
  sourceInfo: ReadonlyMap<string, TypeSourceInfoEntry>;
1926
1370
  /** Plugin attachments configured on each type via .plugin() method */
@@ -2125,5 +1569,33 @@ interface Plugin<TypeConfig = unknown, PluginConfig = unknown> {
2125
1569
  onExecutorReady?(context: ExecutorReadyContext<PluginConfig>): GeneratorResult | Promise<GeneratorResult>;
2126
1570
  }
2127
1571
  //#endregion
2128
- export { FieldOptions as $, BeforeLoginHookArgs as A, IdpUserTrigger as At, TailorAnyDBType as B, IdProvider as Bt, TailorDBType as C, ResolverInput as Ct, AuthExternalConfig as D, ExecutorInput as Dt, AuthConnectionTokenResult as E, Executor as Et, UserAttributeListKey as F, WebhookOperation as Ft, PermissionCondition as G, SCIMAttributeMapping as Gt, TailorDBInstance as H, OIDC as Ht, UserAttributeMap as I, WorkflowOperation as It, unsafeAllowAllGqlPermission as J, SCIMResource as Jt, TailorTypeGqlPermission as K, SCIMAuthorization as Kt, UsernameFieldKey as L, AuthInvoker as Lt, OAuth2ClientGrantType as M, ResolverExecutedTrigger as Mt, SCIMAttributeType as N, ScheduleTriggerInput as Nt, AuthOwnConfig as O, FunctionOperation as Ot, UserAttributeKey as P, TailorDBTrigger as Pt, FieldMetadata as Q, ValueOperand as R, BuiltinIdP as Rt, TailorDBServiceInput as S, Resolver as St, AuthConfig as T, AuthAccessTokenTrigger as Tt, TailorDBType$1 as U, SAML as Ut, TailorDBField as V, OAuth2ClientInput as Vt, db as W, SCIMAttribute as Wt, ArrayFieldOutput as X, unsafeAllowAllTypePermission as Y, TenantProvider as Yt, DefinedFieldMetadata as Z, GeneratorResult as _, unauthenticatedTailorUser as _t, PluginExecutorContext as a, JsonCompatible as at, TailorDBNamespaceData as b, AuthConnectionConfig as bt, PluginGeneratedExecutorWithFile as c, MachineUserName as ct, PluginNamespaceProcessContext as d, TailorEnv as dt, FieldOutput$1 as et, PluginOutput as f, TailorActor as ft, ExecutorReadyContext as g, TailorUser as gt, TypePluginOutput as h, InferredAttributeMap as ht, PluginConfigs as i, InferFieldsOutput as it, DefinedAuth as j, IncomingWebhookTrigger as jt, AuthServiceInput as k, GqlOperation as kt, PluginGeneratedResolver as l, MachineUserNameRegistry as lt, TailorDBTypeForPlugin as m, AttributeMap as mt, Plugin as n, TailorAnyField as nt, PluginExecutorContextBase as o, JsonValue as ot, PluginProcessContext as p, AttributeList as pt, TailorTypePermission as q, SCIMConfig as qt, PluginAttachment as r, TailorField as rt, PluginGeneratedExecutor as s, output as st, NamespacePluginOutput as t, TailorFieldType as tt, PluginGeneratedType as u, Env as ut, ResolverNamespaceData as v, AllowedValues as vt, TypeSourceInfoEntry as w, GeneratorConfig as wt, TailorDBReadyContext as x, AuthConnectionOAuth2Config as xt, ResolverReadyContext as y, AllowedValuesOutput as yt, TailorAnyDBField as z, IDToken as zt };
2129
- //# sourceMappingURL=plugin-D84blivd.d.mts.map
1572
+ //#region src/types/tailor-db-field.d.ts
1573
+ /**
1574
+ * Minimal structural interface for TailorDBField.
1575
+ * Defines only the properties needed by parser, plugin, cli, and types layers.
1576
+ * The full interface with builder methods (relation, index, unique, hooks, validate, etc.)
1577
+ * is defined in configure/services/tailordb/schema.ts.
1578
+ */
1579
+ interface TailorDBField<Defined extends DefinedDBFieldMetadata = DefinedDBFieldMetadata, Output = any> extends Omit<TailorField<Defined, Output, DBFieldMetadata, Defined["type"]>, "fields"> {
1580
+ readonly fields: Record<string, TailorAnyDBField>;
1581
+ readonly rawRelation: Readonly<RawRelationConfig> | undefined;
1582
+ }
1583
+ type TailorAnyDBField = TailorDBField<any, any>;
1584
+ /**
1585
+ * Minimal structural interface for TailorDBType.
1586
+ * Defines only the properties needed by parser, plugin, cli, and types layers.
1587
+ * The full interface with builder methods (hooks, validate, features, permission, etc.)
1588
+ * is defined in configure/services/tailordb/schema.ts.
1589
+ */
1590
+ interface TailorDBType<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributeMap> {
1591
+ readonly name: string;
1592
+ readonly fields: Fields;
1593
+ readonly _output: InferFieldsOutput<Fields>;
1594
+ readonly metadata: TailorDBTypeMetadata;
1595
+ readonly plugins: PluginAttachment[];
1596
+ }
1597
+ type TailorAnyDBType = TailorDBType<any, any>;
1598
+ type TailorDBInstance<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributeMap> = TailorDBType<Fields, User>;
1599
+ //#endregion
1600
+ export { ResolverInput as $, RelationType as A, FieldMetadata as At, BeforeLoginHookArgs as B, InferredAttributeMap as Bt, ResolverReadyContext as C, SCIMAuthorization as Ct, DefinedDBFieldMetadata as D, ArrayFieldOutput as Dt, DBFieldMetadata as E, TenantProvider as Et, AuthConfig as F, FieldValidateInput as Ft, UserAttributeListKey as G, JsonValue as Gt, OAuth2ClientGrantType as H, unauthenticatedTailorUser as Ht, AuthConnectionTokenResult as I, Validators as It, ValueOperand as J, UserAttributeMap as K, Prettify as Kt, AuthExternalConfig as L, AttributeList as Lt, TailorDBServiceInput as M, FieldOutput$1 as Mt, TailorDBType$1 as N, TailorFieldType as Nt, GqlOperationsConfig as O, DefinedFieldMetadata as Ot, TypeSourceInfoEntry as P, TailorToTs as Pt, Resolver as Q, AuthOwnConfig as R, AttributeMap as Rt, ResolverNamespaceData as S, SCIMAttributeMapping as St, TailorDBReadyContext as T, SCIMResource as Tt, SCIMAttributeType as U, InferFieldsOutput as Ut, DefinedAuth as V, TailorUser as Vt, UserAttributeKey as W, JsonCompatible as Wt, AuthConnectionConfig as X, TailorField as Y, AuthConnectionOAuth2Config as Z, PluginProcessContext as _, IdProvider as _t, NamespacePluginOutput as a, FunctionOperation as at, ExecutorReadyContext as b, SAML as bt, PluginConfigs as c, IncomingWebhookTrigger as ct, PluginGeneratedExecutor as d, TailorDBTrigger as dt, GeneratorConfig as et, PluginGeneratedExecutorWithFile as f, WebhookOperation as ft, PluginOutput as g, IDToken as gt, PluginNamespaceProcessContext as h, BuiltinIdP as ht, TailorDBType as i, ExecutorInput as it, SerialConfig as j, FieldOptions as jt, IndexDef as k, EnumValue as kt, PluginExecutorContext as l, ResolverExecutedTrigger as lt, PluginGeneratedType as m, AuthInvoker as mt, TailorAnyDBType as n, AuthAccessTokenTrigger as nt, Plugin as o, GqlOperation as ot, PluginGeneratedResolver as p, WorkflowOperation as pt, UsernameFieldKey as q, output as qt, TailorDBField as r, Executor as rt, PluginAttachment as s, IdpUserTrigger as st, TailorAnyDBField as t, BaseGeneratorConfig as tt, PluginExecutorContextBase as u, ScheduleTriggerInput as ut, TailorDBTypeForPlugin as v, OAuth2ClientInput as vt, TailorDBNamespaceData as w, SCIMConfig as wt, GeneratorResult as x, SCIMAttribute as xt, TypePluginOutput as y, OIDC as yt, AuthServiceInput as z, InferredAttributeList as zt };
1601
+ //# sourceMappingURL=tailor-db-field-B99RnR2N.d.mts.map