@tailor-platform/sdk 1.2.2 → 1.2.4

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.
@@ -6,6 +6,17 @@ import { IsAny, NonEmptyObject } from "type-fest";
6
6
  import { StandardSchemaV1 } from "@standard-schema/spec";
7
7
  import * as zod_v4_core33 from "zod/v4/core";
8
8
 
9
+ //#region src/parser/service/tailordb/relation.d.ts
10
+ declare const relationTypes: {
11
+ readonly "1-1": "1-1";
12
+ readonly oneToOne: "1-1";
13
+ readonly "n-1": "n-1";
14
+ readonly manyToOne: "n-1";
15
+ readonly "N-1": "n-1";
16
+ readonly keyOnly: "keyOnly";
17
+ };
18
+ type RelationType = keyof typeof relationTypes;
19
+ //#endregion
9
20
  //#region src/configure/types/helpers.d.ts
10
21
  type Prettify<T$1> = { [K in keyof T$1 as string extends K ? never : K]: T$1[K] } & {};
11
22
  type DeepWritable<T$1> = T$1 extends Date | RegExp | Function ? T$1 : T$1 extends object ? { -readonly [P in keyof T$1]: DeepWritable<T$1[P]> } & {} : T$1;
@@ -252,6 +263,11 @@ declare class TailorField<const Defined extends DefinedFieldMetadata = DefinedFi
252
263
  /**
253
264
  * Parse and validate a value against this field's validation rules
254
265
  * Returns StandardSchema Result type with success or failure
266
+ * @param {{ value: unknown; data: unknown; user: TailorUser }} args - Value, context data, and user
267
+ * @param {unknown} args.value - Value to validate
268
+ * @param {unknown} args.data - Context data
269
+ * @param {TailorUser} args.user - Tailor user information
270
+ * @returns {StandardSchemaV1.Result<Output>} Validation result
255
271
  */
256
272
  parse(args: {
257
273
  value: unknown;
@@ -262,11 +278,23 @@ declare class TailorField<const Defined extends DefinedFieldMetadata = DefinedFi
262
278
  * Validate a single value (not an array element)
263
279
  * Used internally for array element validation
264
280
  * @private
281
+ * @param {{ value: TailorToTs[T]; data: unknown; user: TailorUser; pathArray: string[] }} args - Validation arguments
282
+ * @param {TailorToTs[T]} args.value - Value to validate
283
+ * @param {unknown} args.data - Context data
284
+ * @param {TailorUser} args.user - Tailor user information
285
+ * @param {string[]} args.pathArray - Field path array for nested validation
286
+ * @returns {StandardSchemaV1.Issue[]} Validation issues
265
287
  */
266
288
  private _validateValue;
267
289
  /**
268
290
  * Internal parse method that tracks field path for nested validation
269
291
  * @private
292
+ * @param {{ value: unknown; data: unknown; user: TailorUser; pathArray: string[] }} args - Parse arguments
293
+ * @param {unknown} args.value - Value to parse
294
+ * @param {unknown} args.data - Context data
295
+ * @param {TailorUser} args.user - Tailor user information
296
+ * @param {string[]} args.pathArray - Field path array for nested validation
297
+ * @returns {StandardSchemaV1.Result<Output>} Validation result
270
298
  */
271
299
  private _parseInternal;
272
300
  }
@@ -306,10 +334,166 @@ type TailorUser = {
306
334
  /** Represents an unauthenticated user in the Tailor platform. */
307
335
  declare const unauthenticatedTailorUser: TailorUser;
308
336
  //#endregion
309
- //#region src/configure/types/env.d.ts
310
- interface Env {}
311
- /** Represents environment variables in the Tailor platform. */
312
- type TailorEnv = keyof Env extends never ? Record<string, string> : Env;
337
+ //#region src/configure/services/tailordb/permission.d.ts
338
+ type TailorTypePermission<User extends object = InferredAttributeMap, Type extends object = object> = {
339
+ create: readonly ActionPermission<"record", User, Type, false>[];
340
+ read: readonly ActionPermission<"record", User, Type, false>[];
341
+ update: readonly ActionPermission<"record", User, Type, true>[];
342
+ delete: readonly ActionPermission<"record", User, Type, false>[];
343
+ };
344
+ type ActionPermission<Level extends "record" | "gql" = "record" | "gql", User extends object = InferredAttributeMap, Type extends object = object, Update extends boolean = boolean> = {
345
+ conditions: PermissionCondition<Level, User, Update, Type> | readonly PermissionCondition<Level, User, Update, Type>[];
346
+ description?: string | undefined;
347
+ permit?: boolean;
348
+ } | readonly [...PermissionCondition<Level, User, Update, Type>, ...([] | [boolean])] | readonly [...PermissionCondition<Level, User, Update, Type>[], ...([] | [boolean])];
349
+ type TailorTypeGqlPermission<User extends object = InferredAttributeMap, Type extends object = object> = readonly GqlPermissionPolicy<User, Type>[];
350
+ type GqlPermissionPolicy<User extends object = InferredAttributeMap, Type extends object = object> = {
351
+ conditions: readonly PermissionCondition<"gql", User, boolean, Type>[];
352
+ actions: "all" | readonly GqlPermissionAction$1[];
353
+ permit?: boolean;
354
+ description?: string;
355
+ };
356
+ type GqlPermissionAction$1 = "read" | "create" | "update" | "delete" | "aggregate" | "bulkUpsert";
357
+ type EqualityOperator = "=" | "!=";
358
+ type ContainsOperator = "in" | "not in";
359
+ type StringFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string ? K : never }[keyof User];
360
+ type StringArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string[] ? K : never }[keyof User];
361
+ type BooleanFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean ? K : never }[keyof User];
362
+ type BooleanArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean[] ? K : never }[keyof User];
363
+ type UserStringOperand<User extends object = InferredAttributeMap> = {
364
+ user: StringFieldKeys<User> | "id";
365
+ };
366
+ type UserStringArrayOperand<User extends object = InferredAttributeMap> = {
367
+ user: StringArrayFieldKeys<User>;
368
+ };
369
+ type UserBooleanOperand<User extends object = InferredAttributeMap> = {
370
+ user: BooleanFieldKeys<User> | "_loggedIn";
371
+ };
372
+ type UserBooleanArrayOperand<User extends object = InferredAttributeMap> = {
373
+ user: BooleanArrayFieldKeys<User>;
374
+ };
375
+ type RecordOperand$1<Type extends object, Update extends boolean = false> = Update extends true ? {
376
+ oldRecord: (keyof Type & string) | "id";
377
+ } | {
378
+ newRecord: (keyof Type & string) | "id";
379
+ } : {
380
+ record: (keyof Type & string) | "id";
381
+ };
382
+ 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);
383
+ 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);
384
+ 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>;
385
+ 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);
386
+ 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);
387
+ 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>;
388
+ /**
389
+ * Type representing a permission condition that combines user attributes, record fields, and literal values using comparison operators.
390
+ *
391
+ * The User type is extended by `user-defined.d.ts`, which is automatically generated when running `tailor-sdk generate`.
392
+ * Attributes enabled in the config file's `auth.userProfile.attributes` become available as types.
393
+ * @example
394
+ * ```ts
395
+ * // tailor.config.ts
396
+ * export const auth = defineAuth("my-auth", {
397
+ * userProfile: {
398
+ * type: user,
399
+ * attributes: {
400
+ * isAdmin: true,
401
+ * roles: true,
402
+ * }
403
+ * }
404
+ * });
405
+ * ```
406
+ */
407
+ 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>;
408
+ /**
409
+ * Grants full record-level access without any conditions.
410
+ *
411
+ * Unsafe and intended only for local development, prototyping, or tests.
412
+ * Do not use this in production environments, as it effectively disables
413
+ * authorization checks.
414
+ */
415
+ declare const unsafeAllowAllTypePermission: TailorTypePermission;
416
+ /**
417
+ * Grants full GraphQL access (all actions) without any conditions.
418
+ *
419
+ * Unsafe and intended only for local development, prototyping, or tests.
420
+ * Do not use this in production environments, as it effectively disables
421
+ * authorization checks.
422
+ */
423
+ declare const unsafeAllowAllGqlPermission: TailorTypeGqlPermission;
424
+ //#endregion
425
+ //#region src/configure/services/tailordb/types.d.ts
426
+ type SerialConfig<T$1 extends "string" | "integer" = "string" | "integer"> = Prettify<{
427
+ start: number;
428
+ maxValue?: number;
429
+ } & (T$1 extends "string" ? {
430
+ format?: string;
431
+ } : object)>;
432
+ interface DBFieldMetadata extends FieldMetadata {
433
+ index?: boolean;
434
+ unique?: boolean;
435
+ vector?: boolean;
436
+ foreignKey?: boolean;
437
+ foreignKeyType?: string;
438
+ foreignKeyField?: string;
439
+ hooks?: Hook<any, any>;
440
+ serial?: SerialConfig;
441
+ relation?: boolean;
442
+ }
443
+ interface DefinedDBFieldMetadata extends DefinedFieldMetadata {
444
+ index?: boolean;
445
+ unique?: boolean;
446
+ vector?: boolean;
447
+ foreignKey?: boolean;
448
+ foreignKeyType?: boolean;
449
+ validate?: boolean;
450
+ hooks?: {
451
+ create: boolean;
452
+ update: boolean;
453
+ };
454
+ serial?: boolean;
455
+ relation?: boolean;
456
+ }
457
+ type ExcludeNestedDBFields<T$1 extends Record<string, TailorAnyDBField>> = { [K in keyof T$1]: T$1[K] extends TailorDBField<{
458
+ type: "nested";
459
+ array: boolean;
460
+ }, any> ? never : T$1[K] };
461
+ type HookFn<TValue, TData, TReturn> = (args: {
462
+ value: TValue;
463
+ data: TData extends Record<string, unknown> ? { readonly [K in keyof TData]?: TData[K] | null | undefined } : unknown;
464
+ user: TailorUser;
465
+ }) => TReturn;
466
+ type Hook<TData, TReturn> = {
467
+ create?: HookFn<TReturn | null, TData, TReturn>;
468
+ update?: HookFn<TReturn | null, TData, TReturn>;
469
+ };
470
+ 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 {
471
+ hooks: unknown;
472
+ } ? never : F[K]["_defined"] extends {
473
+ type: "nested";
474
+ } ? never : K]?: Hook<TData, output<F[K]>> }>;
475
+ type TailorDBServiceConfig = {
476
+ files: string[];
477
+ ignores?: string[];
478
+ };
479
+ type TailorDBExternalConfig = {
480
+ external: true;
481
+ };
482
+ type TailorDBServiceInput = {
483
+ [namespace: string]: TailorDBServiceConfig | TailorDBExternalConfig;
484
+ };
485
+ type IndexDef<T$1 extends {
486
+ fields: Record<PropertyKey, unknown>;
487
+ }> = {
488
+ fields: [keyof T$1["fields"], keyof T$1["fields"], ...(keyof T$1["fields"])[]];
489
+ unique?: boolean;
490
+ name?: string;
491
+ };
492
+ interface TypeFeatures {
493
+ pluralForm?: string;
494
+ aggregation?: true;
495
+ bulkUpsert?: true;
496
+ }
313
497
  //#endregion
314
498
  //#region src/parser/service/auth/schema.d.ts
315
499
  declare const AuthInvokerSchema: z.ZodObject<{
@@ -555,179 +739,6 @@ type AuthServiceInput<User extends TailorDBInstance, AttributeMap$1 extends User
555
739
  tenantProvider?: TenantProviderConfig;
556
740
  };
557
741
  //#endregion
558
- //#region src/configure/services/auth/index.d.ts
559
- declare const authDefinitionBrand: unique symbol;
560
- type AuthDefinitionBrand = {
561
- readonly [authDefinitionBrand]: true;
562
- };
563
- /**
564
- * Invoker type compatible with tailor.v1.AuthInvoker
565
- * - namespace: auth service name
566
- * - machineUserName: machine user name
567
- */
568
- type AuthInvoker<M extends string> = Omit<AuthInvoker$1, "machineUserName"> & {
569
- machineUserName: M;
570
- };
571
- declare function defineAuth<const Name extends string, const User extends TailorDBInstance, const AttributeMap$1 extends UserAttributeMap<User>, const AttributeList$1 extends UserAttributeListKey<User>[], const MachineUserNames extends string>(name: Name, config: AuthServiceInput<User, AttributeMap$1, AttributeList$1, MachineUserNames>): {
572
- readonly name: Name;
573
- readonly invoker: <M extends MachineUserNames>(machineUser: M) => {
574
- readonly namespace: Name;
575
- readonly machineUserName: M;
576
- };
577
- readonly userProfile?: {
578
- namespace?: string;
579
- type: User;
580
- usernameField: UsernameFieldKey<User>;
581
- attributes?: (AttributeMap$1 & { [K in Exclude<keyof AttributeMap$1, UserAttributeKey<User>>]: never }) | undefined;
582
- attributeList?: AttributeList$1 | undefined;
583
- } | undefined;
584
- readonly machineUsers?: Record<MachineUserNames, type_fest0.IsAny<User> extends true ? {
585
- attributes: Record<string, AuthAttributeValue>;
586
- attributeList?: string[];
587
- } : (Extract<{ [K_1 in keyof AttributeMap$1]-?: undefined extends AttributeMap$1[K_1] ? never : K_1 }[keyof AttributeMap$1], UserAttributeKey<User>> extends never ? {
588
- attributes?: never;
589
- } : {
590
- attributes: { [K_2 in Extract<{ [K_1 in keyof AttributeMap$1]-?: undefined extends AttributeMap$1[K_1] ? never : K_1 }[keyof AttributeMap$1], UserAttributeKey<User>>]: K_2 extends keyof output<User> ? output<User>[K_2] : never } & { [K_3 in Exclude<keyof output<User>, Extract<{ [K_1 in keyof AttributeMap$1]-?: undefined extends AttributeMap$1[K_1] ? never : K_1 }[keyof AttributeMap$1], UserAttributeKey<User>>>]?: undefined };
591
- }) & ([] extends AttributeList$1 ? {
592
- attributeList?: never;
593
- } : {
594
- attributeList: { [Index in keyof AttributeList$1]: AttributeList$1[Index] extends UserAttributeListKey<User> ? AttributeList$1[Index] extends infer T ? T extends AttributeList$1[Index] ? T extends keyof output<User> ? output<User>[T] : never : never : never : never };
595
- })> | undefined;
596
- readonly oauth2Clients?: Record<string, OAuth2ClientInput>;
597
- readonly idProvider?: IdProviderConfig;
598
- readonly scim?: SCIMConfig;
599
- readonly tenantProvider?: TenantProviderConfig;
600
- } & AuthDefinitionBrand;
601
- type AuthExternalConfig = {
602
- name: string;
603
- external: true;
604
- };
605
- type AuthOwnConfig = ReturnType<typeof defineAuth<string, any, any, any, string>>;
606
- type AuthConfig = AuthOwnConfig | AuthExternalConfig;
607
- //#endregion
608
- //#region src/configure/services/tailordb/permission.d.ts
609
- type TailorTypePermission<User extends object = InferredAttributeMap, Type extends object = object> = {
610
- create: readonly ActionPermission<"record", User, Type, false>[];
611
- read: readonly ActionPermission<"record", User, Type, false>[];
612
- update: readonly ActionPermission<"record", User, Type, true>[];
613
- delete: readonly ActionPermission<"record", User, Type, false>[];
614
- };
615
- type ActionPermission<Level extends "record" | "gql" = "record" | "gql", User extends object = InferredAttributeMap, Type extends object = object, Update extends boolean = boolean> = {
616
- conditions: PermissionCondition<Level, User, Update, Type> | readonly PermissionCondition<Level, User, Update, Type>[];
617
- description?: string | undefined;
618
- permit?: boolean;
619
- } | readonly [...PermissionCondition<Level, User, Update, Type>, ...([] | [boolean])] | readonly [...PermissionCondition<Level, User, Update, Type>[], ...([] | [boolean])];
620
- type TailorTypeGqlPermission<User extends object = InferredAttributeMap, Type extends object = object> = readonly GqlPermissionPolicy<User, Type>[];
621
- type GqlPermissionPolicy<User extends object = InferredAttributeMap, Type extends object = object> = {
622
- conditions: readonly PermissionCondition<"gql", User, boolean, Type>[];
623
- actions: "all" | readonly GqlPermissionAction$1[];
624
- permit?: boolean;
625
- description?: string;
626
- };
627
- type GqlPermissionAction$1 = "read" | "create" | "update" | "delete" | "aggregate" | "bulkUpsert";
628
- type PermissionCondition<Level extends "record" | "gql" = "record" | "gql", User extends object = InferredAttributeMap, Update extends boolean = boolean, Type extends object = object> = readonly [PermissionOperand$1<Level, User, Type, Update>, PermissionOperator, PermissionOperand$1<Level, User, Type, Update>];
629
- type UserOperand$1<User extends object = InferredAttributeMap> = {
630
- user: { [K in keyof User]: User[K] extends string | string[] | boolean | boolean[] ? K : never }[keyof User] | "id" | "_loggedIn";
631
- };
632
- type RecordOperand$1<Type extends object, Update extends boolean = false> = Update extends true ? {
633
- oldRecord: (keyof Type & string) | "id";
634
- } | {
635
- newRecord: (keyof Type & string) | "id";
636
- } : {
637
- record: (keyof Type & string) | "id";
638
- };
639
- type PermissionOperand$1<Level extends "record" | "gql" = "record" | "gql", User extends object = InferredAttributeMap, Type extends object = object, Update extends boolean = boolean> = UserOperand$1<User> | ValueOperand | (Level extends "record" ? RecordOperand$1<Type, Update> : never);
640
- type PermissionOperator = "=" | "!=" | "in" | "not in";
641
- /**
642
- * Grants full record-level access without any conditions.
643
- *
644
- * Unsafe and intended only for local development, prototyping, or tests.
645
- * Do not use this in production environments, as it effectively disables
646
- * authorization checks.
647
- */
648
- declare const unsafeAllowAllTypePermission: TailorTypePermission;
649
- /**
650
- * Grants full GraphQL access (all actions) without any conditions.
651
- *
652
- * Unsafe and intended only for local development, prototyping, or tests.
653
- * Do not use this in production environments, as it effectively disables
654
- * authorization checks.
655
- */
656
- declare const unsafeAllowAllGqlPermission: TailorTypeGqlPermission;
657
- //#endregion
658
- //#region src/configure/services/tailordb/types.d.ts
659
- type SerialConfig<T$1 extends "string" | "integer" = "string" | "integer"> = Prettify<{
660
- start: number;
661
- maxValue?: number;
662
- } & (T$1 extends "string" ? {
663
- format?: string;
664
- } : object)>;
665
- interface DBFieldMetadata extends FieldMetadata {
666
- index?: boolean;
667
- unique?: boolean;
668
- vector?: boolean;
669
- foreignKey?: boolean;
670
- foreignKeyType?: string;
671
- foreignKeyField?: string;
672
- hooks?: Hook<any, any>;
673
- serial?: SerialConfig;
674
- relation?: boolean;
675
- }
676
- interface DefinedDBFieldMetadata extends DefinedFieldMetadata {
677
- index?: boolean;
678
- unique?: boolean;
679
- vector?: boolean;
680
- foreignKey?: boolean;
681
- foreignKeyType?: boolean;
682
- validate?: boolean;
683
- hooks?: {
684
- create: boolean;
685
- update: boolean;
686
- };
687
- serial?: boolean;
688
- relation?: boolean;
689
- }
690
- type ExcludeNestedDBFields<T$1 extends Record<string, TailorAnyDBField>> = { [K in keyof T$1]: T$1[K] extends TailorDBField<{
691
- type: "nested";
692
- array: boolean;
693
- }, any> ? never : T$1[K] };
694
- type HookFn<TValue, TData, TReturn> = (args: {
695
- value: TValue;
696
- data: TData extends Record<string, unknown> ? { readonly [K in keyof TData]?: TData[K] | null | undefined } : unknown;
697
- user: TailorUser;
698
- }) => TReturn;
699
- type Hook<TData, TReturn> = {
700
- create?: HookFn<TReturn | null, TData, TReturn>;
701
- update?: HookFn<TReturn | null, TData, TReturn>;
702
- };
703
- 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 {
704
- hooks: unknown;
705
- } ? never : F[K]["_defined"] extends {
706
- type: "nested";
707
- } ? never : K]?: Hook<TData, output<F[K]>> }>;
708
- type TailorDBServiceConfig = {
709
- files: string[];
710
- ignores?: string[];
711
- };
712
- type TailorDBExternalConfig = {
713
- external: true;
714
- };
715
- type TailorDBServiceInput = {
716
- [namespace: string]: TailorDBServiceConfig | TailorDBExternalConfig;
717
- };
718
- type IndexDef<T$1 extends {
719
- fields: Record<PropertyKey, unknown>;
720
- }> = {
721
- fields: [keyof T$1["fields"], keyof T$1["fields"], ...(keyof T$1["fields"])[]];
722
- unique?: boolean;
723
- name?: string;
724
- };
725
- interface TypeFeatures {
726
- pluralForm?: string;
727
- aggregation?: true;
728
- bulkUpsert?: true;
729
- }
730
- //#endregion
731
742
  //#region src/parser/service/tailordb/types.d.ts
732
743
  interface Script {
733
744
  expr: string;
@@ -744,6 +755,20 @@ interface OperatorFieldHook {
744
755
  create?: Script;
745
756
  update?: Script;
746
757
  }
758
+ /**
759
+ * Raw relation config stored in configure layer, processed in parser layer.
760
+ * This is the serialized form of RelationConfig from schema.ts where
761
+ * the TailorDBType reference is replaced with the type name string.
762
+ */
763
+ interface RawRelationConfig {
764
+ type: RelationType;
765
+ toward: {
766
+ type: string;
767
+ as?: string;
768
+ key?: string;
769
+ };
770
+ backward?: string;
771
+ }
747
772
  interface OperatorFieldConfig {
748
773
  type: string;
749
774
  required?: boolean;
@@ -756,6 +781,7 @@ interface OperatorFieldConfig {
756
781
  foreignKey?: boolean;
757
782
  foreignKeyType?: string;
758
783
  foreignKeyField?: string;
784
+ rawRelation?: RawRelationConfig;
759
785
  validate?: OperatorValidateConfig[];
760
786
  hooks?: OperatorFieldHook;
761
787
  serial?: {
@@ -869,7 +895,6 @@ type AllowedValuesOutput<V extends AllowedValues> = V[number] extends infer T ?
869
895
  } ? K : never : never;
870
896
  //#endregion
871
897
  //#region src/configure/services/tailordb/schema.d.ts
872
- type RelationType = "oneToOne" | "1-1" | "manyToOne" | "n-1" | "N-1" | "keyOnly";
873
898
  interface RelationConfig<S extends RelationType, T$1 extends TailorDBType> {
874
899
  type: S;
875
900
  toward: {
@@ -888,16 +913,10 @@ type RelationSelfConfig = {
888
913
  };
889
914
  backward?: string;
890
915
  };
891
- interface ReferenceConfig<T$1 extends TailorAnyDBType> {
892
- type: TailorAnyDBType;
893
- key: keyof T$1["fields"] & string;
894
- nameMap: [string | undefined, string];
895
- }
896
916
  type TailorAnyDBField = TailorDBField<any, any>;
897
917
  declare class TailorDBField<const Defined extends DefinedDBFieldMetadata, const Output> extends TailorField<Defined, Output, DBFieldMetadata> {
898
- private _ref;
899
- private _pendingSelfRelation;
900
- get reference(): Readonly<ReferenceConfig<TailorDBType>> | undefined;
918
+ private _rawRelation;
919
+ get rawRelation(): Readonly<RawRelationConfig> | undefined;
901
920
  get metadata(): {
902
921
  index?: boolean;
903
922
  unique?: boolean;
@@ -1183,6 +1202,68 @@ declare const db: {
1183
1202
  };
1184
1203
  };
1185
1204
  //#endregion
1205
+ //#region src/configure/services/auth/index.d.ts
1206
+ declare const authDefinitionBrand: unique symbol;
1207
+ type AuthDefinitionBrand = {
1208
+ readonly [authDefinitionBrand]: true;
1209
+ };
1210
+ /**
1211
+ * Invoker type compatible with tailor.v1.AuthInvoker
1212
+ * - namespace: auth service name
1213
+ * - machineUserName: machine user name
1214
+ */
1215
+ type AuthInvoker<M extends string> = Omit<AuthInvoker$1, "machineUserName"> & {
1216
+ machineUserName: M;
1217
+ };
1218
+ /**
1219
+ * Define an auth service for the Tailor SDK.
1220
+ * @template Name
1221
+ * @template User
1222
+ * @template AttributeMap
1223
+ * @template AttributeList
1224
+ * @template MachineUserNames
1225
+ * @template M
1226
+ * @param {Name} name - Auth service name
1227
+ * @param {AuthServiceInput<User, AttributeMap, AttributeList, MachineUserNames>} config - Auth service configuration
1228
+ * @returns {AuthDefinitionBrand & AuthServiceInput<User, AttributeMap, AttributeList, MachineUserNames> & { name: string; invoker<M extends MachineUserNames>(machineUser: M): AuthInvoker<M> }} Defined auth service
1229
+ */
1230
+ declare function defineAuth<const Name extends string, const User extends TailorDBInstance, const AttributeMap$1 extends UserAttributeMap<User>, const AttributeList$1 extends UserAttributeListKey<User>[], const MachineUserNames extends string>(name: Name, config: AuthServiceInput<User, AttributeMap$1, AttributeList$1, MachineUserNames>): {
1231
+ readonly name: Name;
1232
+ readonly invoker: <M extends MachineUserNames>(machineUser: M) => {
1233
+ readonly namespace: Name;
1234
+ readonly machineUserName: M;
1235
+ };
1236
+ readonly userProfile?: {
1237
+ namespace?: string;
1238
+ type: User;
1239
+ usernameField: UsernameFieldKey<User>;
1240
+ attributes?: (AttributeMap$1 & { [K in Exclude<keyof AttributeMap$1, UserAttributeKey<User>>]: never }) | undefined;
1241
+ attributeList?: AttributeList$1 | undefined;
1242
+ } | undefined;
1243
+ readonly machineUsers?: Record<MachineUserNames, type_fest0.IsAny<User> extends true ? {
1244
+ attributes: Record<string, AuthAttributeValue>;
1245
+ attributeList?: string[];
1246
+ } : (Extract<{ [K_1 in keyof AttributeMap$1]-?: undefined extends AttributeMap$1[K_1] ? never : K_1 }[keyof AttributeMap$1], UserAttributeKey<User>> extends never ? {
1247
+ attributes?: never;
1248
+ } : {
1249
+ attributes: { [K_2 in Extract<{ [K_1 in keyof AttributeMap$1]-?: undefined extends AttributeMap$1[K_1] ? never : K_1 }[keyof AttributeMap$1], UserAttributeKey<User>>]: K_2 extends keyof output<User> ? output<User>[K_2] : never } & { [K_3 in Exclude<keyof output<User>, Extract<{ [K_1 in keyof AttributeMap$1]-?: undefined extends AttributeMap$1[K_1] ? never : K_1 }[keyof AttributeMap$1], UserAttributeKey<User>>>]?: undefined };
1250
+ }) & ([] extends AttributeList$1 ? {
1251
+ attributeList?: never;
1252
+ } : {
1253
+ attributeList: { [Index in keyof AttributeList$1]: AttributeList$1[Index] extends UserAttributeListKey<User> ? AttributeList$1[Index] extends infer T ? T extends AttributeList$1[Index] ? T extends keyof output<User> ? output<User>[T] : never : never : never : never };
1254
+ })> | undefined;
1255
+ readonly oauth2Clients?: Record<string, OAuth2ClientInput>;
1256
+ readonly idProvider?: IdProviderConfig;
1257
+ readonly scim?: SCIMConfig;
1258
+ readonly tenantProvider?: TenantProviderConfig;
1259
+ } & AuthDefinitionBrand;
1260
+ type AuthExternalConfig = {
1261
+ name: string;
1262
+ external: true;
1263
+ };
1264
+ type AuthOwnConfig = ReturnType<typeof defineAuth<string, any, any, any, string>>;
1265
+ type AuthConfig = AuthOwnConfig | AuthExternalConfig;
1266
+ //#endregion
1186
1267
  //#region src/configure/services/executor/types.d.ts
1187
1268
  type ExecutorServiceConfig = {
1188
1269
  files: string[];
@@ -1251,6 +1332,13 @@ declare const idpDefinitionBrand: unique symbol;
1251
1332
  type IdpDefinitionBrand = {
1252
1333
  readonly [idpDefinitionBrand]: true;
1253
1334
  };
1335
+ /**
1336
+ * Define an IdP service configuration for the Tailor SDK.
1337
+ * @template TClients
1338
+ * @param {string} name - IdP service name
1339
+ * @param {Omit<IdPInput, "name" | "clients"> & { clients: TClients }} config - IdP configuration
1340
+ * @returns {IdpDefinitionBrand & IdPInput} Defined IdP service
1341
+ */
1254
1342
  declare function defineIdp<const TClients extends string[]>(name: string, config: Omit<IdPInput, "name" | "clients"> & {
1255
1343
  clients: TClients;
1256
1344
  }): {
@@ -1298,6 +1386,12 @@ declare const staticWebsiteDefinitionBrand: unique symbol;
1298
1386
  type StaticWebsiteDefinitionBrand = {
1299
1387
  readonly [staticWebsiteDefinitionBrand]: true;
1300
1388
  };
1389
+ /**
1390
+ * Define a static website configuration for the Tailor SDK.
1391
+ * @param {string} name - Static website name
1392
+ * @param {Omit<StaticWebsiteInput, "name">} config - Static website configuration
1393
+ * @returns {StaticWebsiteDefinitionBrand & StaticWebsiteInput & { readonly url: string }} Defined static website
1394
+ */
1301
1395
  declare function defineStaticWebSite(name: string, config: Omit<StaticWebsiteInput, "name">): {
1302
1396
  readonly name: string;
1303
1397
  readonly url: `${string}:url`;
@@ -1364,6 +1458,7 @@ declare const BaseGeneratorConfigSchema: z.ZodUnion<readonly [z.ZodTuple<[z.ZodL
1364
1458
  /**
1365
1459
  * Creates a GeneratorConfigSchema with built-in generator support
1366
1460
  * @param {Map<string, (options: unknown) => CodeGeneratorBase>} builtinGenerators - Map of generator IDs to their constructor functions
1461
+ * @returns {z.ZodEffects<z.ZodUnion<[typeof KyselyTypeConfigSchema, typeof SeedConfigSchema, typeof EnumConstantsConfigSchema, typeof FileUtilsConfigSchema, typeof CodeGeneratorSchema]>, CodeGeneratorBase, unknown> | z.ZodUnion<[typeof KyselyTypeConfigSchema, typeof SeedConfigSchema, typeof EnumConstantsConfigSchema, typeof FileUtilsConfigSchema, typeof CodeGeneratorSchema]>} Generator config schema
1367
1462
  */
1368
1463
  declare function createGeneratorConfigSchema(builtinGenerators: Map<string, (options: any) => CodeGeneratorBase>): z.core.$ZodBranded<z.ZodPipe<z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"@tailor-platform/kysely-type">, z.ZodObject<{
1369
1464
  distPath: z.ZodString;
@@ -1418,9 +1513,9 @@ type CodeGeneratorBase = Omit<z.output<typeof CodeGeneratorSchema>, "dependencie
1418
1513
  };
1419
1514
  //#endregion
1420
1515
  //#region src/configure/config.d.ts
1421
- interface AppConfig<Auth extends AuthConfig = AuthConfig, Idp extends IdPConfig[] = IdPConfig[], StaticWebsites extends StaticWebsiteConfig[] = StaticWebsiteConfig[], Env$1 extends Record<string, string | number | boolean> = Record<string, string | number | boolean>> {
1516
+ interface AppConfig<Auth extends AuthConfig = AuthConfig, Idp extends IdPConfig[] = IdPConfig[], StaticWebsites extends StaticWebsiteConfig[] = StaticWebsiteConfig[], Env extends Record<string, string | number | boolean> = Record<string, string | number | boolean>> {
1422
1517
  name: string;
1423
- env?: Env$1;
1518
+ env?: Env;
1424
1519
  cors?: string[];
1425
1520
  allowedIpAddresses?: string[];
1426
1521
  disableIntrospection?: boolean;
@@ -1432,7 +1527,18 @@ interface AppConfig<Auth extends AuthConfig = AuthConfig, Idp extends IdPConfig[
1432
1527
  workflow?: WorkflowServiceInput;
1433
1528
  staticWebsites?: StaticWebsites;
1434
1529
  }
1530
+ /**
1531
+ * Define a Tailor SDK application configuration with shallow exactness.
1532
+ * @template Config
1533
+ * @param {Config} config - Application configuration
1534
+ * @returns {Config} The same configuration object
1535
+ */
1435
1536
  declare function defineConfig<const Config extends AppConfig & Record<Exclude<keyof Config, keyof AppConfig>, never>>(config: Config): Config;
1537
+ /**
1538
+ * Define generators to be used with the Tailor SDK.
1539
+ * @param {...GeneratorConfig} configs - Generator configurations
1540
+ * @returns {GeneratorConfig[]} Generator configurations as given
1541
+ */
1436
1542
  declare function defineGenerators(...configs: GeneratorConfig[]): (["@tailor-platform/kysely-type", {
1437
1543
  distPath: string;
1438
1544
  }] | ["@tailor-platform/seed", {
@@ -1589,5 +1695,5 @@ type WorkflowOperation = z.infer<typeof WorkflowOperationSchema>;
1589
1695
  type Executor = z.infer<typeof ExecutorSchema>;
1590
1696
  type ExecutorInput = z.input<typeof ExecutorSchema>;
1591
1697
  //#endregion
1592
- export { SCIMAttributeMapping as $, db as A, AuthExternalConfig as B, ResolverServiceConfig as C, FieldOptions as Ct, TailorDBField as D, JsonCompatible as Dt, ExecutorServiceInput as E, InferFieldsOutput as Et, TailorTypeGqlPermission as F, BuiltinIdP as G, AuthOwnConfig as H, TailorTypePermission as I, OAuth2ClientGrantType as J, IDToken as K, unsafeAllowAllGqlPermission as L, AllowedValuesOutput as M, ParsedTailorDBType as N, TailorDBInstance as O, output as Ot, PermissionCondition as P, SCIMAttribute as Q, unsafeAllowAllTypePermission as R, ResolverExternalConfig as S, FieldMetadata as St, ExecutorServiceConfig as T, TailorFieldType as Tt, defineAuth as U, AuthInvoker as V, AuthServiceInput as W, OIDC as X, OAuth2ClientInput as Y, SAML as Z, StaticWebsiteConfig as _, TailorField as _t, IncomingWebhookTrigger as a, UserAttributeKey as at, IdPExternalConfig as b, ResolverInput as bt, ScheduleTriggerInput as c, UsernameFieldKey as ct, AppConfig as d, TailorEnv as dt, SCIMAttributeType as et, defineConfig as f, AttributeList as ft, WorkflowServiceInput as g, TailorAnyField as gt, WorkflowServiceConfig as h, unauthenticatedTailorUser as ht, GqlOperation as i, TenantProviderConfig as it, AllowedValues as j, TailorDBType as k, WebhookOperation as l, ValueOperand as lt, Generator as m, TailorUser as mt, ExecutorInput as n, SCIMConfig as nt, RecordTrigger as o, UserAttributeListKey as ot, defineGenerators as p, AttributeMap as pt, IdProviderConfig as q, FunctionOperation as r, SCIMResource as rt, ResolverExecutedTrigger as s, UserAttributeMap as st, Executor as t, SCIMAuthorization as tt, WorkflowOperation as u, Env as ut, defineStaticWebSite as v, QueryType as vt, ResolverServiceInput as w, FieldOutput$1 as wt, defineIdp as x, ArrayFieldOutput as xt, IdPConfig as y, Resolver as yt, AuthConfig as z };
1593
- //# sourceMappingURL=types-C0n7Syhv.d.mts.map
1698
+ export { TenantProviderConfig as $, AuthOwnConfig as A, BuiltinIdP as B, ResolverServiceConfig as C, TailorFieldType as Ct, AuthConfig as D, ExecutorServiceInput as E, output as Et, db as F, OIDC as G, IdProviderConfig as H, AllowedValues as I, SCIMAttributeMapping as J, SAML as K, AllowedValuesOutput as L, TailorDBField as M, TailorDBInstance as N, AuthExternalConfig as O, TailorDBType as P, SCIMResource as Q, ParsedTailorDBType as R, ResolverExternalConfig as S, FieldOutput$1 as St, ExecutorServiceConfig as T, JsonCompatible as Tt, OAuth2ClientGrantType as U, IDToken as V, OAuth2ClientInput as W, SCIMAuthorization as X, SCIMAttributeType as Y, SCIMConfig as Z, StaticWebsiteConfig as _, Resolver as _t, IncomingWebhookTrigger as a, PermissionCondition as at, IdPExternalConfig as b, FieldMetadata as bt, ScheduleTriggerInput as c, unsafeAllowAllGqlPermission as ct, AppConfig as d, AttributeMap as dt, UserAttributeKey as et, defineConfig as f, TailorUser as ft, WorkflowServiceInput as g, QueryType as gt, WorkflowServiceConfig as h, TailorField as ht, GqlOperation as i, ValueOperand as it, defineAuth as j, AuthInvoker as k, WebhookOperation as l, unsafeAllowAllTypePermission as lt, Generator as m, TailorAnyField as mt, ExecutorInput as n, UserAttributeMap as nt, RecordTrigger as o, TailorTypeGqlPermission as ot, defineGenerators as p, unauthenticatedTailorUser as pt, SCIMAttribute as q, FunctionOperation as r, UsernameFieldKey as rt, ResolverExecutedTrigger as s, TailorTypePermission as st, Executor as t, UserAttributeListKey as tt, WorkflowOperation as u, AttributeList as ut, defineStaticWebSite as v, ResolverInput as vt, ResolverServiceInput as w, InferFieldsOutput as wt, defineIdp as x, FieldOptions as xt, IdPConfig as y, ArrayFieldOutput as yt, AuthServiceInput as z };
1699
+ //# sourceMappingURL=types-BeinUo7W.d.mts.map
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./../../user-defined.d.ts" />
2
- import { _t as TailorField, k as TailorDBType } from "../../types-C0n7Syhv.mjs";
3
- import { n as output } from "../../index-aNF917Ib.mjs";
2
+ import { P as TailorDBType, ht as TailorField } from "../../types-BeinUo7W.mjs";
3
+ import { n as output } from "../../index-Dkyvjk4D.mjs";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
5
 
6
6
  //#region src/utils/test/index.d.ts