@tailor-platform/sdk 1.2.3 → 1.2.5

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.
@@ -1,10 +1,10 @@
1
1
  /// <reference path="./user-defined.d.ts" />
2
- import * as zod38 from "zod";
2
+ import * as zod0 from "zod";
3
3
  import { z } from "zod";
4
4
  import * as type_fest0 from "type-fest";
5
5
  import { IsAny, NonEmptyObject } from "type-fest";
6
6
  import { StandardSchemaV1 } from "@standard-schema/spec";
7
- import * as zod_v4_core33 from "zod/v4/core";
7
+ import * as zod_v4_core0 from "zod/v4/core";
8
8
 
9
9
  //#region src/parser/service/tailordb/relation.d.ts
10
10
  declare const relationTypes: {
@@ -263,6 +263,11 @@ declare class TailorField<const Defined extends DefinedFieldMetadata = DefinedFi
263
263
  /**
264
264
  * Parse and validate a value against this field's validation rules
265
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
266
271
  */
267
272
  parse(args: {
268
273
  value: unknown;
@@ -273,11 +278,23 @@ declare class TailorField<const Defined extends DefinedFieldMetadata = DefinedFi
273
278
  * Validate a single value (not an array element)
274
279
  * Used internally for array element validation
275
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
276
287
  */
277
288
  private _validateValue;
278
289
  /**
279
290
  * Internal parse method that tracks field path for nested validation
280
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
281
298
  */
282
299
  private _parseInternal;
283
300
  }
@@ -317,6 +334,167 @@ type TailorUser = {
317
334
  /** Represents an unauthenticated user in the Tailor platform. */
318
335
  declare const unauthenticatedTailorUser: TailorUser;
319
336
  //#endregion
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
+ }
497
+ //#endregion
320
498
  //#region src/parser/service/auth/schema.d.ts
321
499
  declare const AuthInvokerSchema: z.ZodObject<{
322
500
  namespace: z.ZodString;
@@ -561,191 +739,6 @@ type AuthServiceInput<User extends TailorDBInstance, AttributeMap$1 extends User
561
739
  tenantProvider?: TenantProviderConfig;
562
740
  };
563
741
  //#endregion
564
- //#region src/configure/services/auth/index.d.ts
565
- declare const authDefinitionBrand: unique symbol;
566
- type AuthDefinitionBrand = {
567
- readonly [authDefinitionBrand]: true;
568
- };
569
- /**
570
- * Invoker type compatible with tailor.v1.AuthInvoker
571
- * - namespace: auth service name
572
- * - machineUserName: machine user name
573
- */
574
- type AuthInvoker<M extends string> = Omit<AuthInvoker$1, "machineUserName"> & {
575
- machineUserName: M;
576
- };
577
- /**
578
- * Define an auth service for the Tailor SDK.
579
- * @template Name
580
- * @template User
581
- * @template AttributeMap
582
- * @template AttributeList
583
- * @template MachineUserNames
584
- * @template M
585
- * @param {Name} name - Auth service name
586
- * @param {AuthServiceInput<User, AttributeMap, AttributeList, MachineUserNames>} config - Auth service configuration
587
- * @returns {AuthDefinitionBrand & AuthServiceInput<User, AttributeMap, AttributeList, MachineUserNames> & { name: string; invoker<M extends MachineUserNames>(machineUser: M): AuthInvoker<M> }} Defined auth service
588
- */
589
- 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>): {
590
- readonly name: Name;
591
- readonly invoker: <M extends MachineUserNames>(machineUser: M) => {
592
- readonly namespace: Name;
593
- readonly machineUserName: M;
594
- };
595
- readonly userProfile?: {
596
- namespace?: string;
597
- type: User;
598
- usernameField: UsernameFieldKey<User>;
599
- attributes?: (AttributeMap$1 & { [K in Exclude<keyof AttributeMap$1, UserAttributeKey<User>>]: never }) | undefined;
600
- attributeList?: AttributeList$1 | undefined;
601
- } | undefined;
602
- readonly machineUsers?: Record<MachineUserNames, type_fest0.IsAny<User> extends true ? {
603
- attributes: Record<string, AuthAttributeValue>;
604
- attributeList?: string[];
605
- } : (Extract<{ [K_1 in keyof AttributeMap$1]-?: undefined extends AttributeMap$1[K_1] ? never : K_1 }[keyof AttributeMap$1], UserAttributeKey<User>> extends never ? {
606
- attributes?: never;
607
- } : {
608
- 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 };
609
- }) & ([] extends AttributeList$1 ? {
610
- attributeList?: never;
611
- } : {
612
- 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 };
613
- })> | undefined;
614
- readonly oauth2Clients?: Record<string, OAuth2ClientInput>;
615
- readonly idProvider?: IdProviderConfig;
616
- readonly scim?: SCIMConfig;
617
- readonly tenantProvider?: TenantProviderConfig;
618
- } & AuthDefinitionBrand;
619
- type AuthExternalConfig = {
620
- name: string;
621
- external: true;
622
- };
623
- type AuthOwnConfig = ReturnType<typeof defineAuth<string, any, any, any, string>>;
624
- type AuthConfig = AuthOwnConfig | AuthExternalConfig;
625
- //#endregion
626
- //#region src/configure/services/tailordb/permission.d.ts
627
- type TailorTypePermission<User extends object = InferredAttributeMap, Type extends object = object> = {
628
- create: readonly ActionPermission<"record", User, Type, false>[];
629
- read: readonly ActionPermission<"record", User, Type, false>[];
630
- update: readonly ActionPermission<"record", User, Type, true>[];
631
- delete: readonly ActionPermission<"record", User, Type, false>[];
632
- };
633
- type ActionPermission<Level extends "record" | "gql" = "record" | "gql", User extends object = InferredAttributeMap, Type extends object = object, Update extends boolean = boolean> = {
634
- conditions: PermissionCondition<Level, User, Update, Type> | readonly PermissionCondition<Level, User, Update, Type>[];
635
- description?: string | undefined;
636
- permit?: boolean;
637
- } | readonly [...PermissionCondition<Level, User, Update, Type>, ...([] | [boolean])] | readonly [...PermissionCondition<Level, User, Update, Type>[], ...([] | [boolean])];
638
- type TailorTypeGqlPermission<User extends object = InferredAttributeMap, Type extends object = object> = readonly GqlPermissionPolicy<User, Type>[];
639
- type GqlPermissionPolicy<User extends object = InferredAttributeMap, Type extends object = object> = {
640
- conditions: readonly PermissionCondition<"gql", User, boolean, Type>[];
641
- actions: "all" | readonly GqlPermissionAction$1[];
642
- permit?: boolean;
643
- description?: string;
644
- };
645
- type GqlPermissionAction$1 = "read" | "create" | "update" | "delete" | "aggregate" | "bulkUpsert";
646
- 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>];
647
- type UserOperand$1<User extends object = InferredAttributeMap> = {
648
- user: { [K in keyof User]: User[K] extends string | string[] | boolean | boolean[] ? K : never }[keyof User] | "id" | "_loggedIn";
649
- };
650
- type RecordOperand$1<Type extends object, Update extends boolean = false> = Update extends true ? {
651
- oldRecord: (keyof Type & string) | "id";
652
- } | {
653
- newRecord: (keyof Type & string) | "id";
654
- } : {
655
- record: (keyof Type & string) | "id";
656
- };
657
- 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);
658
- type PermissionOperator = "=" | "!=" | "in" | "not in";
659
- /**
660
- * Grants full record-level access without any conditions.
661
- *
662
- * Unsafe and intended only for local development, prototyping, or tests.
663
- * Do not use this in production environments, as it effectively disables
664
- * authorization checks.
665
- */
666
- declare const unsafeAllowAllTypePermission: TailorTypePermission;
667
- /**
668
- * Grants full GraphQL access (all actions) without any conditions.
669
- *
670
- * Unsafe and intended only for local development, prototyping, or tests.
671
- * Do not use this in production environments, as it effectively disables
672
- * authorization checks.
673
- */
674
- declare const unsafeAllowAllGqlPermission: TailorTypeGqlPermission;
675
- //#endregion
676
- //#region src/configure/services/tailordb/types.d.ts
677
- type SerialConfig<T$1 extends "string" | "integer" = "string" | "integer"> = Prettify<{
678
- start: number;
679
- maxValue?: number;
680
- } & (T$1 extends "string" ? {
681
- format?: string;
682
- } : object)>;
683
- interface DBFieldMetadata extends FieldMetadata {
684
- index?: boolean;
685
- unique?: boolean;
686
- vector?: boolean;
687
- foreignKey?: boolean;
688
- foreignKeyType?: string;
689
- foreignKeyField?: string;
690
- hooks?: Hook<any, any>;
691
- serial?: SerialConfig;
692
- relation?: boolean;
693
- }
694
- interface DefinedDBFieldMetadata extends DefinedFieldMetadata {
695
- index?: boolean;
696
- unique?: boolean;
697
- vector?: boolean;
698
- foreignKey?: boolean;
699
- foreignKeyType?: boolean;
700
- validate?: boolean;
701
- hooks?: {
702
- create: boolean;
703
- update: boolean;
704
- };
705
- serial?: boolean;
706
- relation?: boolean;
707
- }
708
- type ExcludeNestedDBFields<T$1 extends Record<string, TailorAnyDBField>> = { [K in keyof T$1]: T$1[K] extends TailorDBField<{
709
- type: "nested";
710
- array: boolean;
711
- }, any> ? never : T$1[K] };
712
- type HookFn<TValue, TData, TReturn> = (args: {
713
- value: TValue;
714
- data: TData extends Record<string, unknown> ? { readonly [K in keyof TData]?: TData[K] | null | undefined } : unknown;
715
- user: TailorUser;
716
- }) => TReturn;
717
- type Hook<TData, TReturn> = {
718
- create?: HookFn<TReturn | null, TData, TReturn>;
719
- update?: HookFn<TReturn | null, TData, TReturn>;
720
- };
721
- 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 {
722
- hooks: unknown;
723
- } ? never : F[K]["_defined"] extends {
724
- type: "nested";
725
- } ? never : K]?: Hook<TData, output<F[K]>> }>;
726
- type TailorDBServiceConfig = {
727
- files: string[];
728
- ignores?: string[];
729
- };
730
- type TailorDBExternalConfig = {
731
- external: true;
732
- };
733
- type TailorDBServiceInput = {
734
- [namespace: string]: TailorDBServiceConfig | TailorDBExternalConfig;
735
- };
736
- type IndexDef<T$1 extends {
737
- fields: Record<PropertyKey, unknown>;
738
- }> = {
739
- fields: [keyof T$1["fields"], keyof T$1["fields"], ...(keyof T$1["fields"])[]];
740
- unique?: boolean;
741
- name?: string;
742
- };
743
- interface TypeFeatures {
744
- pluralForm?: string;
745
- aggregation?: true;
746
- bulkUpsert?: true;
747
- }
748
- //#endregion
749
742
  //#region src/parser/service/tailordb/types.d.ts
750
743
  interface Script {
751
744
  expr: string;
@@ -1209,6 +1202,68 @@ declare const db: {
1209
1202
  };
1210
1203
  };
1211
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
1212
1267
  //#region src/configure/services/executor/types.d.ts
1213
1268
  type ExecutorServiceConfig = {
1214
1269
  files: string[];
@@ -1403,6 +1458,7 @@ declare const BaseGeneratorConfigSchema: z.ZodUnion<readonly [z.ZodTuple<[z.ZodL
1403
1458
  /**
1404
1459
  * Creates a GeneratorConfigSchema with built-in generator support
1405
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
1406
1462
  */
1407
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<{
1408
1464
  distPath: z.ZodString;
@@ -1496,12 +1552,12 @@ declare function defineGenerators(...configs: GeneratorConfig[]): (["@tailor-pla
1496
1552
  id: string;
1497
1553
  description: string;
1498
1554
  dependencies: ("tailordb" | "resolver" | "executor")[];
1499
- aggregate: zod_v4_core33.$InferInnerFunctionType<zod_v4_core33.$ZodFunctionArgs, zod38.ZodAny>;
1500
- processType?: zod_v4_core33.$InferInnerFunctionType<zod_v4_core33.$ZodFunctionArgs, zod_v4_core33.$ZodFunctionOut> | undefined;
1501
- processResolver?: zod_v4_core33.$InferInnerFunctionType<zod_v4_core33.$ZodFunctionArgs, zod_v4_core33.$ZodFunctionOut> | undefined;
1502
- processExecutor?: zod_v4_core33.$InferInnerFunctionType<zod_v4_core33.$ZodFunctionArgs, zod_v4_core33.$ZodFunctionOut> | undefined;
1503
- processTailorDBNamespace?: zod_v4_core33.$InferInnerFunctionType<zod_v4_core33.$ZodFunctionArgs, zod_v4_core33.$ZodFunctionOut> | undefined;
1504
- processResolverNamespace?: zod_v4_core33.$InferInnerFunctionType<zod_v4_core33.$ZodFunctionArgs, zod_v4_core33.$ZodFunctionOut> | undefined;
1555
+ aggregate: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod0.ZodAny>;
1556
+ processType?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
1557
+ processResolver?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
1558
+ processExecutor?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
1559
+ processTailorDBNamespace?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
1560
+ processResolverNamespace?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
1505
1561
  })[];
1506
1562
  //#endregion
1507
1563
  //#region src/parser/service/executor/schema.d.ts
@@ -1639,5 +1695,5 @@ type WorkflowOperation = z.infer<typeof WorkflowOperationSchema>;
1639
1695
  type Executor = z.infer<typeof ExecutorSchema>;
1640
1696
  type ExecutorInput = z.input<typeof ExecutorSchema>;
1641
1697
  //#endregion
1642
- export { SCIMAttributeMapping as $, db as A, AuthExternalConfig as B, ResolverServiceConfig as C, TailorFieldType as Ct, TailorDBField as D, ExecutorServiceInput as E, output 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, PermissionCondition as P, SCIMAttribute as Q, unsafeAllowAllTypePermission as R, ResolverExternalConfig as S, FieldOutput$1 as St, ExecutorServiceConfig as T, JsonCompatible as Tt, defineAuth as U, AuthInvoker as V, AuthServiceInput as W, OIDC as X, OAuth2ClientInput as Y, SAML as Z, StaticWebsiteConfig as _, Resolver as _t, IncomingWebhookTrigger as a, UserAttributeKey as at, IdPExternalConfig as b, FieldMetadata as bt, ScheduleTriggerInput as c, UsernameFieldKey as ct, AppConfig as d, AttributeMap as dt, SCIMAttributeType as et, defineConfig as f, TailorUser as ft, WorkflowServiceInput as g, QueryType as gt, WorkflowServiceConfig as h, TailorField as ht, GqlOperation as i, TenantProviderConfig as it, AllowedValues as j, TailorDBType as k, WebhookOperation as l, ValueOperand as lt, Generator as m, TailorAnyField as mt, ExecutorInput as n, SCIMConfig as nt, RecordTrigger as o, UserAttributeListKey as ot, defineGenerators as p, unauthenticatedTailorUser 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, 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, AuthConfig as z };
1643
- //# sourceMappingURL=types-Dg_zk_OZ.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-DCb7NVBk.d.mts.map
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./../../user-defined.d.ts" />
2
- import { ht as TailorField, k as TailorDBType } from "../../types-Dg_zk_OZ.mjs";
3
- import { n as output } from "../../index-DXZMT4aO.mjs";
2
+ import { P as TailorDBType, ht as TailorField } from "../../types-DCb7NVBk.mjs";
3
+ import { n as output } from "../../index-LqF60FaW.mjs";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
5
 
6
6
  //#region src/utils/test/index.d.ts
@@ -51,10 +51,7 @@ body: async (context) => {
51
51
  // In executors
52
52
  body: async ({ newRecord }) => {
53
53
  const db = getDB("tailordb");
54
- await db
55
- .insertInto("AuditLog")
56
- .values({ userId: newRecord.id, action: "created" })
57
- .execute();
54
+ await db.insertInto("AuditLog").values({ userId: newRecord.id, action: "created" }).execute();
58
55
  };
59
56
 
60
57
  // In workflow jobs
@@ -18,10 +18,7 @@ interface CodeGenerator<T, R, E, Ts, Rs> {
18
18
  source: { filePath: string; exportName: string };
19
19
  }): T | Promise<T>;
20
20
 
21
- processResolver(args: {
22
- resolver: Resolver;
23
- namespace: string;
24
- }): R | Promise<R>;
21
+ processResolver(args: { resolver: Resolver; namespace: string }): R | Promise<R>;
25
22
 
26
23
  processExecutor(executor: Executor): E | Promise<E>;
27
24
 
@@ -297,8 +297,7 @@ export default createExecutor({
297
297
  name: "order-status-changed",
298
298
  trigger: recordUpdatedTrigger({
299
299
  type: order,
300
- condition: ({ oldRecord, newRecord }) =>
301
- oldRecord.status !== newRecord.status,
300
+ condition: ({ oldRecord, newRecord }) => oldRecord.status !== newRecord.status,
302
301
  }),
303
302
  operation: {
304
303
  kind: "function",
@@ -127,10 +127,7 @@ createResolver({
127
127
  .string()
128
128
  .validate(
129
129
  ({ value }) => value.includes("@"),
130
- [
131
- ({ value }) => value.length <= 255,
132
- "Email must be 255 characters or less",
133
- ],
130
+ [({ value }) => value.length <= 255, "Email must be 255 characters or less"],
134
131
  ),
135
132
  age: t.int().validate(({ value }) => value >= 0 && value <= 150),
136
133
  },
@@ -90,12 +90,7 @@ const auth = defineAuth("my-auth", {
90
90
  ## Complete Example
91
91
 
92
92
  ```typescript
93
- import {
94
- defineConfig,
95
- defineAuth,
96
- defineIdp,
97
- defineStaticWebSite,
98
- } from "@tailor-platform/sdk";
93
+ import { defineConfig, defineAuth, defineIdp, defineStaticWebSite } from "@tailor-platform/sdk";
99
94
  import { user } from "./tailordb/user";
100
95
 
101
96
  const website = defineStaticWebSite("my-frontend", {
@@ -206,10 +206,7 @@ Function arguments include: `value` (field value), `data` (entire record value),
206
206
  ```typescript
207
207
  db.string().validate(
208
208
  ({ value }) => value.length > 5,
209
- [
210
- ({ value }) => value.length < 10,
211
- "Value must be shorter than 10 characters",
212
- ],
209
+ [({ value }) => value.length < 10, "Value must be shorter than 10 characters"],
213
210
  );
214
211
  ```
215
212
 
package/docs/testing.md CHANGED
@@ -104,10 +104,7 @@ import { getDB } from "generated/tailordb";
104
104
 
105
105
  export interface DbOperations {
106
106
  transaction: (fn: (ops: DbOperations) => Promise<unknown>) => Promise<void>;
107
- getUser: (
108
- email: string,
109
- forUpdate: boolean,
110
- ) => Promise<{ email: string; age: number }>;
107
+ getUser: (email: string, forUpdate: boolean) => Promise<{ email: string; age: number }>;
111
108
  updateUser: (user: { email: string; age: number }) => Promise<void>;
112
109
  }
113
110
 
@@ -144,32 +141,23 @@ export default createResolver({
144
141
  Then test by mocking the interface:
145
142
 
146
143
  ```typescript
147
- import {
148
- DbOperations,
149
- decrementUserAge,
150
- } from "../src/resolver/decrementUserAge";
144
+ import { DbOperations, decrementUserAge } from "../src/resolver/decrementUserAge";
151
145
 
152
146
  describe("decrementUserAge resolver", () => {
153
147
  test("basic functionality", async () => {
154
148
  // Mock DbOperations implementation
155
149
  const dbOperations = {
156
150
  transaction: vi.fn(
157
- async (fn: (ops: DbOperations) => Promise<unknown>) =>
158
- await fn(dbOperations),
151
+ async (fn: (ops: DbOperations) => Promise<unknown>) => await fn(dbOperations),
159
152
  ),
160
- getUser: vi
161
- .fn()
162
- .mockResolvedValue({ email: "test@example.com", age: 30 }),
153
+ getUser: vi.fn().mockResolvedValue({ email: "test@example.com", age: 30 }),
163
154
  updateUser: vi.fn(),
164
155
  } as DbOperations;
165
156
 
166
157
  const result = await decrementUserAge("test@example.com", dbOperations);
167
158
 
168
159
  expect(result).toEqual({ oldAge: 30, newAge: 29 });
169
- expect(dbOperations.getUser).toHaveBeenCalledExactlyOnceWith(
170
- "test@example.com",
171
- true,
172
- );
160
+ expect(dbOperations.getUser).toHaveBeenCalledExactlyOnceWith("test@example.com", true);
173
161
  expect(dbOperations.updateUser).toHaveBeenCalledExactlyOnceWith(
174
162
  expect.objectContaining({ age: 29 }),
175
163
  );