@tailor-platform/sdk 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  /// <reference path="./user-defined.d.ts" />
2
- import * as zod0 from "zod";
2
+ import * as zod38 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_core0 from "zod/v4/core";
7
+ import * as zod_v4_core33 from "zod/v4/core";
8
8
 
9
9
  //#region src/parser/service/tailordb/relation.d.ts
10
10
  declare const relationTypes: {
@@ -229,6 +229,11 @@ type Resolver = z.output<typeof ResolverSchema>;
229
229
  //#endregion
230
230
  //#region src/configure/types/type.d.ts
231
231
  type TailorAnyField = TailorField<any>;
232
+ type FieldParseArgs = {
233
+ value: unknown;
234
+ data: unknown;
235
+ user: TailorUser;
236
+ };
232
237
  declare class TailorField<const Defined extends DefinedFieldMetadata = DefinedFieldMetadata, const Output = any, M extends FieldMetadata = FieldMetadata, T$1 extends TailorFieldType = TailorFieldType> implements TailorFieldInput {
233
238
  readonly type: T$1;
234
239
  readonly fields: Record<string, TailorAnyField>;
@@ -263,38 +268,23 @@ declare class TailorField<const Defined extends DefinedFieldMetadata = DefinedFi
263
268
  /**
264
269
  * Parse and validate a value against this field's validation rules
265
270
  * 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
271
+ * @param args - Value, context data, and user
272
+ * @returns Validation result
271
273
  */
272
- parse(args: {
273
- value: unknown;
274
- data: unknown;
275
- user: TailorUser;
276
- }): StandardSchemaV1.Result<Output>;
274
+ parse(args: FieldParseArgs): StandardSchemaV1.Result<Output>;
277
275
  /**
278
276
  * Validate a single value (not an array element)
279
277
  * Used internally for array element validation
280
278
  * @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
279
+ * @param args - Validation arguments
280
+ * @returns Validation issues
287
281
  */
288
282
  private _validateValue;
289
283
  /**
290
284
  * Internal parse method that tracks field path for nested validation
291
285
  * @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
286
+ * @param args - Parse arguments
287
+ * @returns Validation result
298
288
  */
299
289
  private _parseInternal;
300
290
  }
@@ -334,6 +324,11 @@ type TailorUser = {
334
324
  /** Represents an unauthenticated user in the Tailor platform. */
335
325
  declare const unauthenticatedTailorUser: TailorUser;
336
326
  //#endregion
327
+ //#region src/configure/types/env.d.ts
328
+ interface Env {}
329
+ /** Represents environment variables in the Tailor platform. */
330
+ type TailorEnv = keyof Env extends never ? Record<string, string> : Env;
331
+ //#endregion
337
332
  //#region src/configure/services/tailordb/permission.d.ts
338
333
  type TailorTypePermission<User extends object = InferredAttributeMap, Type extends object = object> = {
339
334
  create: readonly ActionPermission<"record", User, Type, false>[];
@@ -739,6 +734,7 @@ type AuthServiceInput<User extends TailorDBInstance, AttributeMap$1 extends User
739
734
  idProvider?: IdProviderConfig;
740
735
  scim?: SCIMConfig;
741
736
  tenantProvider?: TenantProviderConfig;
737
+ publishSessionEvents?: boolean;
742
738
  };
743
739
  //#endregion
744
740
  //#region src/parser/service/tailordb/types.d.ts
@@ -1025,8 +1021,8 @@ declare class TailorDBField<const Defined extends DefinedDBFieldMetadata, const
1025
1021
  }>, Output>;
1026
1022
  /**
1027
1023
  * Clone the field with optional overrides for field options
1028
- * @param {FieldOptions} [options] - Optional field options to override
1029
- * @returns {TailorDBField<unknown, unknown>} A new TailorDBField instance with the same configuration
1024
+ * @param options - Optional field options to override
1025
+ * @returns A new TailorDBField instance with the same configuration
1030
1026
  */
1031
1027
  clone<const NewOpt extends FieldOptions>(options?: NewOpt): TailorDBField<Prettify<Omit<Defined, "array"> & {
1032
1028
  array: NewOpt extends {
@@ -1119,9 +1115,9 @@ declare class TailorDBType<const Fields extends Record<string, TailorAnyDBField>
1119
1115
  description(description: string): this;
1120
1116
  /**
1121
1117
  * Pick specific fields from the type
1122
- * @param {(keyof Fields)[]} keys - Array of field keys to pick
1123
- * @param {FieldOptions} options - Optional field options to apply to picked fields
1124
- * @returns {Record<string, TailorDBField<unknown, unknown>>} An object containing only the specified fields
1118
+ * @param keys - Array of field keys to pick
1119
+ * @param options - Optional field options to apply to picked fields
1120
+ * @returns An object containing only the specified fields
1125
1121
  */
1126
1122
  pickFields<K$1 extends keyof Fields, const Opt extends FieldOptions>(keys: K$1[], options: Opt): { [P in K$1]: Fields[P$1] extends TailorDBField<infer D, infer _O> ? TailorDBField<Omit<D, "array"> & {
1127
1123
  array: Opt extends {
@@ -1131,8 +1127,8 @@ declare class TailorDBType<const Fields extends Record<string, TailorAnyDBField>
1131
1127
  /**
1132
1128
  * Omit specific fields from the type
1133
1129
  * @template K
1134
- * @param {(keyof Fields)[]} keys - Array of field keys to omit
1135
- * @returns {Omit<Fields, K>} An object containing all fields except the specified ones
1130
+ * @param keys - Array of field keys to omit
1131
+ * @returns An object containing all fields except the specified ones
1136
1132
  */
1137
1133
  omitFields<K$1 extends keyof Fields>(keys: K$1[]): Omit<Fields, K$1>;
1138
1134
  }
@@ -1149,19 +1145,19 @@ type DBType<F extends {
1149
1145
  } & F>;
1150
1146
  /**
1151
1147
  * Creates a new database type with the specified fields
1152
- * @param {string | [string, string]} name - The name of the type, or a tuple of [name, pluralForm]
1153
- * @param {Record<string, TailorDBField<unknown, unknown>>} fields - The field definitions for the type
1154
- * @returns {DBType<F>} A new TailorDBType instance
1148
+ * @param name - The name of the type, or a tuple of [name, pluralForm]
1149
+ * @param fields - The field definitions for the type
1150
+ * @returns A new TailorDBType instance
1155
1151
  */
1156
1152
  declare function dbType<const F extends {
1157
1153
  id?: never;
1158
1154
  } & Record<string, TailorAnyDBField>>(name: string | [string, string], fields: F): DBType<F>;
1159
1155
  /**
1160
1156
  * Creates a new database type with the specified fields and description
1161
- * @param {string | [string, string]} name - The name of the type, or a tuple of [name, pluralForm]
1162
- * @param {string} description - A description of the type
1163
- * @param {Record<string, TailorDBField<unknown, unknown>>} fields - The field definitions for the type
1164
- * @returns {DBType<F>} A new TailorDBType instance
1157
+ * @param name - The name of the type, or a tuple of [name, pluralForm]
1158
+ * @param description - A description of the type
1159
+ * @param fields - The field definitions for the type
1160
+ * @returns A new TailorDBType instance
1165
1161
  */
1166
1162
  declare function dbType<const F extends {
1167
1163
  id?: never;
@@ -1225,9 +1221,9 @@ type AuthInvoker<M extends string> = Omit<AuthInvoker$1, "machineUserName"> & {
1225
1221
  * @template AttributeList
1226
1222
  * @template MachineUserNames
1227
1223
  * @template M
1228
- * @param {Name} name - Auth service name
1229
- * @param {AuthServiceInput<User, AttributeMap, AttributeList, MachineUserNames>} config - Auth service configuration
1230
- * @returns {AuthDefinitionBrand & AuthServiceInput<User, AttributeMap, AttributeList, MachineUserNames> & { name: string; invoker<M extends MachineUserNames>(machineUser: M): AuthInvoker<M> }} Defined auth service
1224
+ * @param name - Auth service name
1225
+ * @param config - Auth service configuration
1226
+ * @returns Defined auth service
1231
1227
  */
1232
1228
  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>): {
1233
1229
  readonly name: Name;
@@ -1258,6 +1254,7 @@ declare function defineAuth<const Name extends string, const User extends Tailor
1258
1254
  readonly idProvider?: IdProviderConfig;
1259
1255
  readonly scim?: SCIMConfig;
1260
1256
  readonly tenantProvider?: TenantProviderConfig;
1257
+ readonly publishSessionEvents?: boolean;
1261
1258
  } & AuthDefinitionBrand;
1262
1259
  type AuthExternalConfig = {
1263
1260
  name: string;
@@ -1337,9 +1334,9 @@ type IdpDefinitionBrand = {
1337
1334
  /**
1338
1335
  * Define an IdP service configuration for the Tailor SDK.
1339
1336
  * @template TClients
1340
- * @param {string} name - IdP service name
1341
- * @param {Omit<IdPInput, "name" | "clients"> & { clients: TClients }} config - IdP configuration
1342
- * @returns {IdpDefinitionBrand & IdPInput} Defined IdP service
1337
+ * @param name - IdP service name
1338
+ * @param config - IdP configuration
1339
+ * @returns Defined IdP service
1343
1340
  */
1344
1341
  declare function defineIdp<const TClients extends string[]>(name: string, config: Omit<IdPInput, "name" | "clients"> & {
1345
1342
  clients: TClients;
@@ -1390,9 +1387,9 @@ type StaticWebsiteDefinitionBrand = {
1390
1387
  };
1391
1388
  /**
1392
1389
  * Define a static website configuration for the Tailor SDK.
1393
- * @param {string} name - Static website name
1394
- * @param {Omit<StaticWebsiteInput, "name">} config - Static website configuration
1395
- * @returns {StaticWebsiteDefinitionBrand & StaticWebsiteInput & { readonly url: string }} Defined static website
1390
+ * @param name - Static website name
1391
+ * @param config - Static website configuration
1392
+ * @returns Defined static website
1396
1393
  */
1397
1394
  declare function defineStaticWebSite(name: string, config: Omit<StaticWebsiteInput, "name">): {
1398
1395
  readonly name: string;
@@ -1459,8 +1456,8 @@ declare const BaseGeneratorConfigSchema: z.ZodUnion<readonly [z.ZodTuple<[z.ZodL
1459
1456
  }, z.core.$strip>]>;
1460
1457
  /**
1461
1458
  * Creates a GeneratorConfigSchema with built-in generator support
1462
- * @param {Map<string, (options: unknown) => CodeGeneratorBase>} builtinGenerators - Map of generator IDs to their constructor functions
1463
- * @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
1459
+ * @param builtinGenerators - Map of generator IDs to their constructor functions
1460
+ * @returns Generator config schema
1464
1461
  */
1465
1462
  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<{
1466
1463
  distPath: z.ZodString;
@@ -1515,9 +1512,9 @@ type CodeGeneratorBase = Omit<z.output<typeof CodeGeneratorSchema>, "dependencie
1515
1512
  };
1516
1513
  //#endregion
1517
1514
  //#region src/configure/config.d.ts
1518
- 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>> {
1515
+ 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>> {
1519
1516
  name: string;
1520
- env?: Env;
1517
+ env?: Env$1;
1521
1518
  cors?: string[];
1522
1519
  allowedIpAddresses?: string[];
1523
1520
  disableIntrospection?: boolean;
@@ -1532,14 +1529,14 @@ interface AppConfig<Auth extends AuthConfig = AuthConfig, Idp extends IdPConfig[
1532
1529
  /**
1533
1530
  * Define a Tailor SDK application configuration with shallow exactness.
1534
1531
  * @template Config
1535
- * @param {Config} config - Application configuration
1536
- * @returns {Config} The same configuration object
1532
+ * @param config - Application configuration
1533
+ * @returns The same configuration object
1537
1534
  */
1538
1535
  declare function defineConfig<const Config extends AppConfig & Record<Exclude<keyof Config, keyof AppConfig>, never>>(config: Config): Config;
1539
1536
  /**
1540
1537
  * Define generators to be used with the Tailor SDK.
1541
- * @param {...GeneratorConfig} configs - Generator configurations
1542
- * @returns {GeneratorConfig[]} Generator configurations as given
1538
+ * @param configs - Generator configurations
1539
+ * @returns Generator configurations as given
1543
1540
  */
1544
1541
  declare function defineGenerators(...configs: GeneratorConfig[]): (["@tailor-platform/kysely-type", {
1545
1542
  distPath: string;
@@ -1554,12 +1551,12 @@ declare function defineGenerators(...configs: GeneratorConfig[]): (["@tailor-pla
1554
1551
  id: string;
1555
1552
  description: string;
1556
1553
  dependencies: ("tailordb" | "resolver" | "executor")[];
1557
- aggregate: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod0.ZodAny>;
1558
- processType?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
1559
- processResolver?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
1560
- processExecutor?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
1561
- processTailorDBNamespace?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
1562
- processResolverNamespace?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
1554
+ aggregate: zod_v4_core33.$InferInnerFunctionType<zod_v4_core33.$ZodFunctionArgs, zod38.ZodAny>;
1555
+ processType?: zod_v4_core33.$InferInnerFunctionType<zod_v4_core33.$ZodFunctionArgs, zod_v4_core33.$ZodFunctionOut> | undefined;
1556
+ processResolver?: zod_v4_core33.$InferInnerFunctionType<zod_v4_core33.$ZodFunctionArgs, zod_v4_core33.$ZodFunctionOut> | undefined;
1557
+ processExecutor?: zod_v4_core33.$InferInnerFunctionType<zod_v4_core33.$ZodFunctionArgs, zod_v4_core33.$ZodFunctionOut> | undefined;
1558
+ processTailorDBNamespace?: zod_v4_core33.$InferInnerFunctionType<zod_v4_core33.$ZodFunctionArgs, zod_v4_core33.$ZodFunctionOut> | undefined;
1559
+ processResolverNamespace?: zod_v4_core33.$InferInnerFunctionType<zod_v4_core33.$ZodFunctionArgs, zod_v4_core33.$ZodFunctionOut> | undefined;
1563
1560
  })[];
1564
1561
  //#endregion
1565
1562
  //#region src/parser/service/executor/schema.d.ts
@@ -1697,5 +1694,5 @@ type WorkflowOperation = z.infer<typeof WorkflowOperationSchema>;
1697
1694
  type Executor = z.infer<typeof ExecutorSchema>;
1698
1695
  type ExecutorInput = z.input<typeof ExecutorSchema>;
1699
1696
  //#endregion
1700
- 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 };
1701
- //# sourceMappingURL=types-22f0o6xW.d.mts.map
1697
+ export { TenantProviderConfig as $, AuthOwnConfig as A, BuiltinIdP as B, ResolverServiceConfig as C, FieldOptions as Ct, AuthConfig as D, JsonCompatible as Dt, ExecutorServiceInput as E, InferFieldsOutput 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, output as Ot, TailorDBType as P, SCIMResource as Q, ParsedTailorDBType as R, ResolverExternalConfig as S, FieldMetadata as St, ExecutorServiceConfig as T, TailorFieldType as Tt, OAuth2ClientGrantType as U, IDToken as V, OAuth2ClientInput as W, SCIMAuthorization as X, SCIMAttributeType as Y, SCIMConfig as Z, StaticWebsiteConfig as _, TailorField as _t, IncomingWebhookTrigger as a, PermissionCondition as at, IdPExternalConfig as b, ResolverInput as bt, ScheduleTriggerInput as c, unsafeAllowAllGqlPermission as ct, AppConfig as d, TailorEnv as dt, UserAttributeKey as et, defineConfig as f, AttributeList as ft, WorkflowServiceInput as g, TailorAnyField as gt, WorkflowServiceConfig as h, unauthenticatedTailorUser as ht, GqlOperation as i, ValueOperand as it, defineAuth as j, AuthInvoker as k, WebhookOperation as l, unsafeAllowAllTypePermission as lt, Generator as m, TailorUser as mt, ExecutorInput as n, UserAttributeMap as nt, RecordTrigger as o, TailorTypeGqlPermission as ot, defineGenerators as p, AttributeMap 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, 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, AuthServiceInput as z };
1698
+ //# sourceMappingURL=types-Yxg4lgU0.d.mts.map
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./../../user-defined.d.ts" />
2
- import { P as TailorDBType, ht as TailorField } from "../../types-22f0o6xW.mjs";
3
- import { n as output } from "../../index-ByDQH56l.mjs";
2
+ import { P as TailorDBType, _t as TailorField } from "../../types-Yxg4lgU0.mjs";
3
+ import { n as output } from "../../index-CTExbeYE.mjs";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
5
 
6
6
  //#region src/utils/test/index.d.ts
@@ -18,17 +18,17 @@ declare const unauthenticatedTailorUser: {
18
18
  * - Recursively processes nested types
19
19
  * - Executes hooks.create for fields with create hooks
20
20
  * @template T - The output type of the hook function
21
- * @param {TailorDBType<unknown, unknown>} type - TailorDB type definition
22
- * @returns {(data: unknown) => Partial<output<T>>} A function that transforms input data according to field hooks
21
+ * @param type - TailorDB type definition
22
+ * @returns A function that transforms input data according to field hooks
23
23
  */
24
24
  declare function createTailorDBHook<T extends TailorDBType<any, any>>(type: T): (data: unknown) => Partial<output<T>>;
25
25
  /**
26
26
  * Creates the standard schema definition for lines-db
27
27
  * This returns the first argument for defineSchema with the ~standard section
28
28
  * @template T - The output type after validation
29
- * @param {TailorField<unknown, T>} schemaType - TailorDB field schema for validation
30
- * @param {(data: unknown) => Partial<T>} hook - Hook function to transform data before validation
31
- * @returns {{ "~standard": StandardSchemaV1<T>["~standard"] }} Schema object with ~standard section for defineSchema
29
+ * @param schemaType - TailorDB field schema for validation
30
+ * @param hook - Hook function to transform data before validation
31
+ * @returns Schema object with ~standard section for defineSchema
32
32
  */
33
33
  declare function createStandardSchema<T = Record<string, unknown>>(schemaType: TailorField<any, T>, hook: (data: unknown) => Partial<T>): {
34
34
  readonly "~standard": {
@@ -13,8 +13,8 @@ const unauthenticatedTailorUser = {
13
13
  * - Recursively processes nested types
14
14
  * - Executes hooks.create for fields with create hooks
15
15
  * @template T - The output type of the hook function
16
- * @param {TailorDBType<unknown, unknown>} type - TailorDB type definition
17
- * @returns {(data: unknown) => Partial<output<T>>} A function that transforms input data according to field hooks
16
+ * @param type - TailorDB type definition
17
+ * @returns A function that transforms input data according to field hooks
18
18
  */
19
19
  function createTailorDBHook(type) {
20
20
  return (data) => {
@@ -38,9 +38,9 @@ function createTailorDBHook(type) {
38
38
  * Creates the standard schema definition for lines-db
39
39
  * This returns the first argument for defineSchema with the ~standard section
40
40
  * @template T - The output type after validation
41
- * @param {TailorField<unknown, T>} schemaType - TailorDB field schema for validation
42
- * @param {(data: unknown) => Partial<T>} hook - Hook function to transform data before validation
43
- * @returns {{ "~standard": StandardSchemaV1<T>["~standard"] }} Schema object with ~standard section for defineSchema
41
+ * @param schemaType - TailorDB field schema for validation
42
+ * @param hook - Hook function to transform data before validation
43
+ * @returns Schema object with ~standard section for defineSchema
44
44
  */
45
45
  function createStandardSchema(schemaType, hook) {
46
46
  return { "~standard": {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/index.ts"],"sourcesContent":["import type { output, TailorUser } from \"@/configure\";\nimport type { TailorDBType } from \"@/configure/services/tailordb/schema\";\nimport type { TailorField } from \"@/configure/types/type\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n} as const satisfies TailorUser;\n\n/**\n * Creates a hook function that processes TailorDB type fields\n * - Uses existing id from data if provided, otherwise generates UUID for id fields\n * - Recursively processes nested types\n * - Executes hooks.create for fields with create hooks\n * @template T - The output type of the hook function\n * @param {TailorDBType<unknown, unknown>} type - TailorDB type definition\n * @returns {(data: unknown) => Partial<output<T>>} A function that transforms input data according to field hooks\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createTailorDBHook<T extends TailorDBType<any, any>>(type: T) {\n return (data: unknown) => {\n return Object.entries(type.fields).reduce(\n (hooked, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const field = value as TailorField<any, any, any>;\n if (key === \"id\") {\n // Use existing id from data if provided, otherwise generate new UUID\n const existingId =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n hooked[key] = existingId ?? crypto.randomUUID();\n } else if (field.type === \"nested\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n hooked[key] = createTailorDBHook({ fields: field.fields } as any)(\n (data as Record<string, unknown>)[key],\n );\n } else if (field.metadata.hooks?.create) {\n hooked[key] = field.metadata.hooks.create({\n value: (data as Record<string, unknown>)[key],\n data: data,\n user: unauthenticatedTailorUser,\n });\n if (hooked[key] instanceof Date) {\n hooked[key] = hooked[key].toISOString();\n }\n } else if (data && typeof data === \"object\") {\n hooked[key] = (data as Record<string, unknown>)[key];\n }\n return hooked;\n },\n {} as Record<string, unknown>,\n ) as Partial<output<T>>;\n };\n}\n\n/**\n * Creates the standard schema definition for lines-db\n * This returns the first argument for defineSchema with the ~standard section\n * @template T - The output type after validation\n * @param {TailorField<unknown, T>} schemaType - TailorDB field schema for validation\n * @param {(data: unknown) => Partial<T>} hook - Hook function to transform data before validation\n * @returns {{ \"~standard\": StandardSchemaV1<T>[\"~standard\"] }} Schema object with ~standard section for defineSchema\n */\nexport function createStandardSchema<T = Record<string, unknown>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schemaType: TailorField<any, T>,\n hook: (data: unknown) => Partial<T>,\n) {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\n const result = schemaType.parse({\n value: hooked,\n data: hooked,\n user: unauthenticatedTailorUser,\n });\n if (result.issues) {\n return result;\n }\n return { value: hooked as T };\n },\n },\n } as const satisfies StandardSchemaV1<T>;\n}\n"],"mappings":";;AAMA,MAAa,4BAA4B;CACvC,IAAI;CACJ,MAAM;CACN,aAAa;CACb,YAAY;CACZ,eAAe,EAAE;CAClB;;;;;;;;;;AAYD,SAAgB,mBAAqD,MAAS;AAC5E,SAAQ,SAAkB;AACxB,SAAO,OAAO,QAAQ,KAAK,OAAO,CAAC,QAChC,QAAQ,CAAC,KAAK,WAAW;GAExB,MAAM,QAAQ;AACd,OAAI,QAAQ,KAIV,QAAO,QADL,QAAQ,OAAO,SAAS,WAAY,KAAiC,OAAO,WAClD,OAAO,YAAY;YACtC,MAAM,SAAS,SAExB,QAAO,OAAO,mBAAmB,EAAE,QAAQ,MAAM,QAAQ,CAAQ,CAC9D,KAAiC,KACnC;YACQ,MAAM,SAAS,OAAO,QAAQ;AACvC,WAAO,OAAO,MAAM,SAAS,MAAM,OAAO;KACxC,OAAQ,KAAiC;KACnC;KACN,MAAM;KACP,CAAC;AACF,QAAI,OAAO,gBAAgB,KACzB,QAAO,OAAO,OAAO,KAAK,aAAa;cAEhC,QAAQ,OAAO,SAAS,SACjC,QAAO,OAAQ,KAAiC;AAElD,UAAO;KAET,EAAE,CACH;;;;;;;;;;;AAYL,SAAgB,qBAEd,YACA,MACA;AACA,QAAO,EACL,aAAa;EACX,SAAS;EACT,QAAQ;EACR,WAAW,UAAmB;GAC5B,MAAM,SAAS,KAAK,MAAM;GAC1B,MAAM,SAAS,WAAW,MAAM;IAC9B,OAAO;IACP,MAAM;IACN,MAAM;IACP,CAAC;AACF,OAAI,OAAO,OACT,QAAO;AAET,UAAO,EAAE,OAAO,QAAa;;EAEhC,EACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/index.ts"],"sourcesContent":["import type { output, TailorUser } from \"@/configure\";\nimport type { TailorDBType } from \"@/configure/services/tailordb/schema\";\nimport type { TailorField } from \"@/configure/types/type\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n} as const satisfies TailorUser;\n\n/**\n * Creates a hook function that processes TailorDB type fields\n * - Uses existing id from data if provided, otherwise generates UUID for id fields\n * - Recursively processes nested types\n * - Executes hooks.create for fields with create hooks\n * @template T - The output type of the hook function\n * @param type - TailorDB type definition\n * @returns A function that transforms input data according to field hooks\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createTailorDBHook<T extends TailorDBType<any, any>>(type: T) {\n return (data: unknown) => {\n return Object.entries(type.fields).reduce(\n (hooked, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const field = value as TailorField<any, any, any>;\n if (key === \"id\") {\n // Use existing id from data if provided, otherwise generate new UUID\n const existingId =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n hooked[key] = existingId ?? crypto.randomUUID();\n } else if (field.type === \"nested\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n hooked[key] = createTailorDBHook({ fields: field.fields } as any)(\n (data as Record<string, unknown>)[key],\n );\n } else if (field.metadata.hooks?.create) {\n hooked[key] = field.metadata.hooks.create({\n value: (data as Record<string, unknown>)[key],\n data: data,\n user: unauthenticatedTailorUser,\n });\n if (hooked[key] instanceof Date) {\n hooked[key] = hooked[key].toISOString();\n }\n } else if (data && typeof data === \"object\") {\n hooked[key] = (data as Record<string, unknown>)[key];\n }\n return hooked;\n },\n {} as Record<string, unknown>,\n ) as Partial<output<T>>;\n };\n}\n\n/**\n * Creates the standard schema definition for lines-db\n * This returns the first argument for defineSchema with the ~standard section\n * @template T - The output type after validation\n * @param schemaType - TailorDB field schema for validation\n * @param hook - Hook function to transform data before validation\n * @returns Schema object with ~standard section for defineSchema\n */\nexport function createStandardSchema<T = Record<string, unknown>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schemaType: TailorField<any, T>,\n hook: (data: unknown) => Partial<T>,\n) {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\n const result = schemaType.parse({\n value: hooked,\n data: hooked,\n user: unauthenticatedTailorUser,\n });\n if (result.issues) {\n return result;\n }\n return { value: hooked as T };\n },\n },\n } as const satisfies StandardSchemaV1<T>;\n}\n"],"mappings":";;AAMA,MAAa,4BAA4B;CACvC,IAAI;CACJ,MAAM;CACN,aAAa;CACb,YAAY;CACZ,eAAe,EAAE;CAClB;;;;;;;;;;AAYD,SAAgB,mBAAqD,MAAS;AAC5E,SAAQ,SAAkB;AACxB,SAAO,OAAO,QAAQ,KAAK,OAAO,CAAC,QAChC,QAAQ,CAAC,KAAK,WAAW;GAExB,MAAM,QAAQ;AACd,OAAI,QAAQ,KAIV,QAAO,QADL,QAAQ,OAAO,SAAS,WAAY,KAAiC,OAAO,WAClD,OAAO,YAAY;YACtC,MAAM,SAAS,SAExB,QAAO,OAAO,mBAAmB,EAAE,QAAQ,MAAM,QAAQ,CAAQ,CAC9D,KAAiC,KACnC;YACQ,MAAM,SAAS,OAAO,QAAQ;AACvC,WAAO,OAAO,MAAM,SAAS,MAAM,OAAO;KACxC,OAAQ,KAAiC;KACnC;KACN,MAAM;KACP,CAAC;AACF,QAAI,OAAO,gBAAgB,KACzB,QAAO,OAAO,OAAO,KAAK,aAAa;cAEhC,QAAQ,OAAO,SAAS,SACjC,QAAO,OAAQ,KAAiC;AAElD,UAAO;KAET,EAAE,CACH;;;;;;;;;;;AAYL,SAAgB,qBAEd,YACA,MACA;AACA,QAAO,EACL,aAAa;EACX,SAAS;EACT,QAAQ;EACR,WAAW,UAAmB;GAC5B,MAAM,SAAS,KAAK,MAAM;GAC1B,MAAM,SAAS,WAAW,MAAM;IAC9B,OAAO;IACP,MAAM;IACN,MAAM;IACP,CAAC;AACF,OAAI,OAAO,OACT,QAAO;AAET,UAAO,EAAE,OAAO,QAAa;;EAEhC,EACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -79,11 +79,11 @@
79
79
  "@types/madge": "5.0.3",
80
80
  "@types/mime-types": "3.0.1",
81
81
  "@types/node": "24.10.9",
82
- "@typescript/native-preview": "7.0.0-dev.20260116.1",
82
+ "@typescript/native-preview": "7.0.0-dev.20260117.1",
83
83
  "@vitest/coverage-v8": "4.0.17",
84
84
  "cross-env": "10.1.0",
85
85
  "eslint": "9.39.2",
86
- "eslint-plugin-jsdoc": "62.0.0",
86
+ "eslint-plugin-jsdoc": "62.1.0",
87
87
  "eslint-plugin-oxlint": "1.39.0",
88
88
  "globals": "17.0.0",
89
89
  "oxlint": "1.39.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-BmQRlW1j.mjs","names":["createField","uuid","string","bool","int","float","date","datetime","time","_enum","object","validators"],"sources":["../src/configure/types/field.ts","../src/configure/types/type.ts","../src/configure/types/user.ts","../src/configure/services/tailordb/permission.ts","../src/configure/services/tailordb/schema.ts","../src/configure/services/auth/index.ts","../src/configure/services/workflow/job.ts","../src/configure/config.ts"],"sourcesContent":["import { type EnumValue } from \"@/parser/service/tailordb/types\";\n\nexport type AllowedValue = EnumValue;\n\nexport type AllowedValues = [string | EnumValue, ...(string | EnumValue)[]];\n\n/**\n * Normalize allowed values into EnumValue objects with descriptions.\n * @param {AllowedValues} values - Allowed values as strings or EnumValue objects\n * @returns {AllowedValue[]} Normalized allowed values\n */\nexport function mapAllowedValues(values: AllowedValues): AllowedValue[] {\n return values.map((value) => {\n if (typeof value === \"string\") {\n return { value, description: \"\" };\n }\n return { ...value, description: value.description ?? \"\" };\n });\n}\n\nexport type AllowedValuesOutput<V extends AllowedValues> = V[number] extends infer T\n ? T extends string\n ? T\n : T extends { value: infer K }\n ? K\n : never\n : never;\n","import { type AllowedValues, type AllowedValuesOutput, mapAllowedValues } from \"./field\";\nimport {\n type TailorFieldType,\n type TailorToTs,\n type FieldMetadata,\n type DefinedFieldMetadata,\n type FieldOptions,\n type FieldOutput,\n} from \"./types\";\nimport type { Prettify, InferFieldsOutput } from \"./helpers\";\nimport type { FieldValidateInput } from \"./validation\";\nimport type { TailorUser } from \"@/configure/types\";\nimport type { TailorFieldInput } from \"@/parser/service/resolver/types\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nconst regex = {\n uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,\n date: /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$/,\n time: /^(?<hour>\\d{2}):(?<minute>\\d{2})$/,\n datetime:\n /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})T(?<hour>\\d{2}):(?<minute>\\d{2}):(?<second>\\d{2})(.(?<millisec>\\d{3}))?Z$/,\n} as const;\n\n// This helper type intentionally uses `any` as a placeholder for unknown field output.\n// oxlint-disable-next-line no-explicit-any\nexport type TailorAnyField = TailorField<any>;\n\nexport class TailorField<\n const Defined extends DefinedFieldMetadata = DefinedFieldMetadata,\n // Generic default output type (kept loose on purpose for library ergonomics).\n // oxlint-disable-next-line no-explicit-any\n const Output = any,\n M extends FieldMetadata = FieldMetadata,\n T extends TailorFieldType = TailorFieldType,\n> implements TailorFieldInput {\n protected _metadata: M;\n public readonly _defined: Defined = undefined as unknown as Defined;\n public readonly _output = undefined as Output;\n\n get metadata() {\n return { ...this._metadata };\n }\n\n protected constructor(\n public readonly type: T,\n options?: FieldOptions,\n public readonly fields: Record<string, TailorAnyField> = {},\n values?: AllowedValues,\n ) {\n this._metadata = { required: true } as M;\n if (options) {\n if (options.optional === true) {\n this._metadata.required = false;\n }\n if (options.array === true) {\n this._metadata.array = true;\n }\n }\n if (values) {\n this._metadata.allowedValues = mapAllowedValues(values);\n }\n }\n\n static create<\n const TType extends TailorFieldType,\n const TOptions extends FieldOptions,\n const OutputBase = TailorToTs[TType],\n >(\n type: TType,\n options?: TOptions,\n fields?: Record<string, TailorAnyField>,\n values?: AllowedValues,\n ) {\n return new TailorField<\n { type: TType; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n >(type, options, fields, values);\n }\n\n description<CurrentDefined extends Defined>(\n this: CurrentDefined extends { description: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n description: string,\n ) {\n this._metadata.description = description;\n return this as TailorField<Prettify<CurrentDefined & { description: true }>, Output>;\n }\n\n typeName<CurrentDefined extends Defined>(\n this: CurrentDefined extends { typeName: unknown }\n ? never\n : CurrentDefined extends { type: \"enum\" | \"nested\" }\n ? TailorField<CurrentDefined, Output>\n : never,\n typeName: string,\n ) {\n this._metadata.typeName = typeName;\n return this as TailorField<Prettify<CurrentDefined & { typeName: true }>, Output>;\n }\n\n validate<CurrentDefined extends Defined>(\n this: CurrentDefined extends { validate: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n ...validate: FieldValidateInput<Output>[]\n ) {\n this._metadata.validate = validate;\n return this as TailorField<Prettify<CurrentDefined & { validate: true }>, Output>;\n }\n\n /**\n * Parse and validate a value against this field's validation rules\n * Returns StandardSchema Result type with success or failure\n * @param {{ value: unknown; data: unknown; user: TailorUser }} args - Value, context data, and user\n * @param {unknown} args.value - Value to validate\n * @param {unknown} args.data - Context data\n * @param {TailorUser} args.user - Tailor user information\n * @returns {StandardSchemaV1.Result<Output>} Validation result\n */\n parse(args: {\n value: unknown;\n data: unknown;\n user: TailorUser;\n }): StandardSchemaV1.Result<Output> {\n return this._parseInternal({\n value: args.value,\n data: args.data,\n user: args.user,\n pathArray: [],\n });\n }\n\n /**\n * Validate a single value (not an array element)\n * Used internally for array element validation\n * @private\n * @param {{ value: TailorToTs[T]; data: unknown; user: TailorUser; pathArray: string[] }} args - Validation arguments\n * @param {TailorToTs[T]} args.value - Value to validate\n * @param {unknown} args.data - Context data\n * @param {TailorUser} args.user - Tailor user information\n * @param {string[]} args.pathArray - Field path array for nested validation\n * @returns {StandardSchemaV1.Issue[]} Validation issues\n */\n private _validateValue(args: {\n value: TailorToTs[T];\n data: unknown;\n user: TailorUser;\n pathArray: string[];\n }): StandardSchemaV1.Issue[] {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n\n // Type-specific validation\n switch (this.type) {\n case \"string\":\n if (typeof value !== \"string\") {\n issues.push({\n message: `Expected a string: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"integer\":\n if (typeof value !== \"number\" || !Number.isInteger(value)) {\n issues.push({\n message: `Expected an integer: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"float\":\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n issues.push({\n message: `Expected a number: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"boolean\":\n if (typeof value !== \"boolean\") {\n issues.push({\n message: `Expected a boolean: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"uuid\":\n if (typeof value !== \"string\" || !regex.uuid.test(value)) {\n issues.push({\n message: `Expected a valid UUID: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"date\":\n if (typeof value !== \"string\" || !regex.date.test(value)) {\n issues.push({\n message: `Expected to match \"yyyy-MM-dd\" format: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"datetime\":\n if (typeof value !== \"string\" || !regex.datetime.test(value)) {\n issues.push({\n message: `Expected to match ISO format: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"time\":\n if (typeof value !== \"string\" || !regex.time.test(value)) {\n issues.push({\n message: `Expected to match \"HH:mm\" format: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"enum\":\n if (this.metadata.allowedValues) {\n const allowedValues = this.metadata.allowedValues.map((v) => v.value);\n if (typeof value !== \"string\" || !allowedValues.includes(value)) {\n issues.push({\n message: `Must be one of [${allowedValues.join(\", \")}]: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n }\n break;\n\n case \"nested\":\n // Validate nested object fields\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n value instanceof Date\n ) {\n issues.push({\n message: `Expected an object: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n } else if (this.fields && Object.keys(this.fields).length > 0) {\n for (const [fieldName, field] of Object.entries(this.fields)) {\n const fieldValue = value?.[fieldName];\n const result = field._parseInternal({\n value: fieldValue,\n data,\n user,\n pathArray: pathArray.concat(fieldName),\n });\n if (result.issues) {\n issues.push(...result.issues);\n }\n }\n }\n break;\n }\n\n // Custom validation functions\n const validateFns = this.metadata.validate;\n if (validateFns && validateFns.length > 0) {\n for (const validateInput of validateFns) {\n const { fn, message } =\n typeof validateInput === \"function\"\n ? { fn: validateInput, message: \"Validation failed\" }\n : { fn: validateInput[0], message: validateInput[1] };\n\n if (!fn({ value, data, user })) {\n issues.push({\n message,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n }\n }\n\n return issues;\n }\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @private\n * @param {{ value: unknown; data: unknown; user: TailorUser; pathArray: string[] }} args - Parse arguments\n * @param {unknown} args.value - Value to parse\n * @param {unknown} args.data - Context data\n * @param {TailorUser} args.user - Tailor user information\n * @param {string[]} args.pathArray - Field path array for nested validation\n * @returns {StandardSchemaV1.Result<Output>} Validation result\n */\n private _parseInternal(args: {\n // Runtime input is unknown/untyped; we validate and narrow it inside the parser.\n // oxlint-disable-next-line no-explicit-any\n value: any;\n data: unknown;\n user: TailorUser;\n pathArray: string[];\n }): StandardSchemaV1.Result<Output> {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n\n // 1. Check required/optional\n const isNullOrUndefined = value === null || value === undefined;\n if (this.metadata.required && isNullOrUndefined) {\n issues.push({\n message: \"Required field is missing\",\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n return { issues };\n }\n\n // If optional and null/undefined, skip further validation\n if (!this.metadata.required && isNullOrUndefined) {\n return { value };\n }\n\n // 2. Check array type\n if (this.metadata.array) {\n if (!Array.isArray(value)) {\n issues.push({\n message: \"Expected an array\",\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n return { issues };\n }\n\n // Validate each array element (without array flag)\n for (let i = 0; i < value.length; i++) {\n const elementValue = value[i];\n const elementPath = pathArray.concat(`[${i}]`);\n\n // Validate element with same type but without array flag\n const elementIssues = this._validateValue({\n value: elementValue,\n data,\n user,\n pathArray: elementPath,\n });\n if (elementIssues.length > 0) {\n issues.push(...elementIssues);\n }\n }\n\n if (issues.length > 0) {\n return { issues };\n }\n return { value: value as Output };\n }\n\n // 3. Type-specific validation and custom validation\n const valueIssues = this._validateValue({ value, data, user, pathArray });\n issues.push(...valueIssues);\n\n if (issues.length > 0) {\n return { issues };\n }\n\n return { value };\n }\n}\n\nconst createField = TailorField.create;\nfunction uuid<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"uuid\", options);\n}\n\nfunction string<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"string\", options);\n}\n\nfunction bool<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"boolean\", options);\n}\n\nfunction int<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"integer\", options);\n}\n\nfunction float<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"float\", options);\n}\n\nfunction date<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"date\", options);\n}\n\nfunction datetime<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"datetime\", options);\n}\n\nfunction time<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"time\", options);\n}\n\nfunction _enum<const V extends AllowedValues, const Opt extends FieldOptions>(\n values: V,\n options?: Opt,\n): TailorField<\n { type: \"enum\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<AllowedValuesOutput<V>, Opt>\n> {\n return createField<\"enum\", Opt, AllowedValuesOutput<V>>(\"enum\", options, undefined, values);\n}\n\nfunction object<const F extends Record<string, TailorAnyField>, const Opt extends FieldOptions>(\n fields: F,\n options?: Opt,\n) {\n const objectField = createField(\"nested\", options, fields) as TailorField<\n { type: \"nested\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<InferFieldsOutput<F>, Opt>\n >;\n return objectField;\n}\n\nexport const t = {\n uuid,\n string,\n bool,\n int,\n float,\n date,\n datetime,\n time,\n enum: _enum,\n object,\n};\n","// Interfaces for module augmentation\n// Users can extend these via: declare module \"@tailor-platform/sdk\" { interface AttributeMap { ... } }\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface AttributeMap {}\nexport interface AttributeList {\n __tuple?: []; // Marker for tuple type\n}\n\nexport type InferredAttributeMap = keyof AttributeMap extends never\n ? Record<string, string | string[] | boolean | boolean[] | undefined>\n : AttributeMap;\n\nexport type InferredAttributeList = AttributeList[\"__tuple\"] extends []\n ? string[]\n : AttributeList[\"__tuple\"];\n\n/** Represents a user in the Tailor platform. */\nexport type TailorUser = {\n /**\n * The ID of the user.\n * For unauthenticated users, this will be a nil UUID.\n */\n id: string;\n /**\n * The type of the user.\n * For unauthenticated users, this will be an empty string.\n */\n type: \"user\" | \"machine_user\" | \"\";\n /** The ID of the workspace the user belongs to. */\n workspaceId: string;\n /**\n * A map of the user's attributes.\n * For unauthenticated users, this will be null.\n */\n attributes: InferredAttributeMap | null;\n /**\n * A list of the user's attributes.\n * For unauthenticated users, this will be an empty array.\n */\n attributeList: InferredAttributeList;\n};\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser: TailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n};\n","import type { InferredAttributeMap } from \"../../types\";\n\nexport type TailorTypePermission<\n User extends object = InferredAttributeMap,\n Type extends object = object,\n> = {\n create: readonly ActionPermission<\"record\", User, Type, false>[];\n read: readonly ActionPermission<\"record\", User, Type, false>[];\n update: readonly ActionPermission<\"record\", User, Type, true>[];\n delete: readonly ActionPermission<\"record\", User, Type, false>[];\n};\n\ntype ActionPermission<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n User extends object = InferredAttributeMap,\n Type extends object = object,\n Update extends boolean = boolean,\n> =\n | {\n conditions:\n | PermissionCondition<Level, User, Update, Type>\n | readonly PermissionCondition<Level, User, Update, Type>[];\n description?: string | undefined;\n permit?: boolean;\n }\n | readonly [...PermissionCondition<Level, User, Update, Type>, ...([] | [boolean])] // single array condition\n | readonly [...PermissionCondition<Level, User, Update, Type>[], ...([] | [boolean])]; // multiple array condition\n\nexport type TailorTypeGqlPermission<\n User extends object = InferredAttributeMap,\n Type extends object = object,\n> = readonly GqlPermissionPolicy<User, Type>[];\n\ntype GqlPermissionPolicy<\n User extends object = InferredAttributeMap,\n Type extends object = object,\n> = {\n conditions: readonly PermissionCondition<\"gql\", User, boolean, Type>[];\n actions: \"all\" | readonly GqlPermissionAction[];\n permit?: boolean;\n description?: string;\n};\n\ntype GqlPermissionAction = \"read\" | \"create\" | \"update\" | \"delete\" | \"aggregate\" | \"bulkUpsert\";\n\ntype EqualityOperator = \"=\" | \"!=\";\ntype ContainsOperator = \"in\" | \"not in\";\n\n// Helper types for User field extraction\ntype StringFieldKeys<User extends object> = {\n [K in keyof User]: User[K] extends string ? K : never;\n}[keyof User];\n\ntype StringArrayFieldKeys<User extends object> = {\n [K in keyof User]: User[K] extends string[] ? K : never;\n}[keyof User];\n\ntype BooleanFieldKeys<User extends object> = {\n [K in keyof User]: User[K] extends boolean ? K : never;\n}[keyof User];\n\ntype BooleanArrayFieldKeys<User extends object> = {\n [K in keyof User]: User[K] extends boolean[] ? K : never;\n}[keyof User];\n\ntype UserStringOperand<User extends object = InferredAttributeMap> = {\n user: StringFieldKeys<User> | \"id\";\n};\n\ntype UserStringArrayOperand<User extends object = InferredAttributeMap> = {\n user: StringArrayFieldKeys<User>;\n};\n\ntype UserBooleanOperand<User extends object = InferredAttributeMap> = {\n user: BooleanFieldKeys<User> | \"_loggedIn\";\n};\n\ntype UserBooleanArrayOperand<User extends object = InferredAttributeMap> = {\n user: BooleanArrayFieldKeys<User>;\n};\n\ntype RecordOperand<Type extends object, Update extends boolean = false> = Update extends true\n ? { oldRecord: (keyof Type & string) | \"id\" } | { newRecord: (keyof Type & string) | \"id\" }\n : { record: (keyof Type & string) | \"id\" };\n\ntype StringEqualityCondition<\n Level extends \"record\" | \"gql\",\n User extends object,\n Update extends boolean,\n Type extends object,\n> =\n | (Level extends \"gql\" ? readonly [string, EqualityOperator, boolean] : never)\n | readonly [string, EqualityOperator, string]\n | readonly [UserStringOperand<User>, EqualityOperator, string]\n | readonly [string, EqualityOperator, UserStringOperand<User>]\n | (Level extends \"record\"\n ?\n | readonly [\n RecordOperand<Type, Update>,\n EqualityOperator,\n string | UserStringOperand<User>,\n ]\n | readonly [\n string | UserStringOperand<User>,\n EqualityOperator,\n RecordOperand<Type, Update>,\n ]\n : never);\n\ntype BooleanEqualityCondition<\n Level extends \"record\" | \"gql\",\n User extends object,\n Update extends boolean,\n Type extends object,\n> =\n | readonly [boolean, EqualityOperator, boolean]\n | readonly [UserBooleanOperand<User>, EqualityOperator, boolean]\n | readonly [boolean, EqualityOperator, UserBooleanOperand<User>]\n | (Level extends \"record\"\n ?\n | readonly [\n RecordOperand<Type, Update>,\n EqualityOperator,\n boolean | UserBooleanOperand<User>,\n ]\n | readonly [\n boolean | UserBooleanOperand<User>,\n EqualityOperator,\n RecordOperand<Type, Update>,\n ]\n : never);\n\ntype EqualityCondition<\n Level extends \"record\" | \"gql\" = \"record\",\n User extends object = InferredAttributeMap,\n Update extends boolean = boolean,\n Type extends object = object,\n> =\n | StringEqualityCondition<Level, User, Update, Type>\n | BooleanEqualityCondition<Level, User, Update, Type>;\n\ntype StringContainsCondition<\n Level extends \"record\" | \"gql\",\n User extends object,\n Update extends boolean,\n Type extends object,\n> =\n | readonly [string, ContainsOperator, string[]]\n | readonly [UserStringOperand<User>, ContainsOperator, string[]]\n | readonly [string, ContainsOperator, UserStringArrayOperand<User>]\n | (Level extends \"record\"\n ?\n | readonly [\n RecordOperand<Type, Update>,\n ContainsOperator,\n string[] | UserStringArrayOperand<User>,\n ]\n | readonly [\n string | UserStringOperand<User>,\n ContainsOperator,\n RecordOperand<Type, Update>,\n ]\n : never);\n\ntype BooleanContainsCondition<\n Level extends \"record\" | \"gql\",\n User extends object,\n Update extends boolean,\n Type extends object,\n> =\n | (Level extends \"gql\" ? readonly [string, ContainsOperator, boolean[]] : never)\n | readonly [boolean, ContainsOperator, boolean[]]\n | readonly [UserBooleanOperand<User>, ContainsOperator, boolean[]]\n | readonly [boolean, ContainsOperator, UserBooleanArrayOperand<User>]\n | (Level extends \"record\"\n ?\n | readonly [\n RecordOperand<Type, Update>,\n ContainsOperator,\n boolean[] | UserBooleanArrayOperand<User>,\n ]\n | readonly [\n boolean | UserBooleanOperand<User>,\n ContainsOperator,\n RecordOperand<Type, Update>,\n ]\n : never);\n\ntype ContainsCondition<\n Level extends \"record\" | \"gql\" = \"record\",\n User extends object = InferredAttributeMap,\n Update extends boolean = boolean,\n Type extends object = object,\n> =\n | StringContainsCondition<Level, User, Update, Type>\n | BooleanContainsCondition<Level, User, Update, Type>;\n\n/**\n * Type representing a permission condition that combines user attributes, record fields, and literal values using comparison operators.\n *\n * The User type is extended by `user-defined.d.ts`, which is automatically generated when running `tailor-sdk generate`.\n * Attributes enabled in the config file's `auth.userProfile.attributes` become available as types.\n * @example\n * ```ts\n * // tailor.config.ts\n * export const auth = defineAuth(\"my-auth\", {\n * userProfile: {\n * type: user,\n * attributes: {\n * isAdmin: true,\n * roles: true,\n * }\n * }\n * });\n * ```\n */\nexport type PermissionCondition<\n Level extends \"record\" | \"gql\" = \"record\",\n User extends object = InferredAttributeMap,\n Update extends boolean = boolean,\n Type extends object = object,\n> = EqualityCondition<Level, User, Update, Type> | ContainsCondition<Level, User, Update, Type>;\n\n/**\n * Grants full record-level access without any conditions.\n *\n * Unsafe and intended only for local development, prototyping, or tests.\n * Do not use this in production environments, as it effectively disables\n * authorization checks.\n */\nexport const unsafeAllowAllTypePermission: TailorTypePermission = {\n create: [{ conditions: [], permit: true }],\n read: [{ conditions: [], permit: true }],\n update: [{ conditions: [], permit: true }],\n delete: [{ conditions: [], permit: true }],\n};\n\n/**\n * Grants full GraphQL access (all actions) without any conditions.\n *\n * Unsafe and intended only for local development, prototyping, or tests.\n * Do not use this in production environments, as it effectively disables\n * authorization checks.\n */\nexport const unsafeAllowAllGqlPermission: TailorTypeGqlPermission = [\n { conditions: [], actions: \"all\", permit: true },\n];\n","import { type AllowedValues, type AllowedValuesOutput } from \"@/configure/types/field\";\nimport { TailorField } from \"@/configure/types/type\";\nimport {\n type FieldOptions,\n type FieldOutput,\n type TailorFieldType,\n type TailorToTs,\n} from \"@/configure/types/types\";\nimport {\n type TailorDBTypeMetadata,\n type RawPermissions,\n type RawRelationConfig,\n type RelationType,\n} from \"@/parser/service/tailordb/types\";\nimport { type TailorTypeGqlPermission, type TailorTypePermission } from \"./permission\";\nimport {\n type DBFieldMetadata,\n type DefinedDBFieldMetadata,\n type Hooks,\n type Hook,\n type SerialConfig,\n type IndexDef,\n type TypeFeatures,\n type ExcludeNestedDBFields,\n} from \"./types\";\nimport type { InferredAttributeMap } from \"@/configure/types\";\nimport type { Prettify, output, InferFieldsOutput } from \"@/configure/types/helpers\";\nimport type { FieldValidateInput, ValidateConfig, Validators } from \"@/configure/types/validation\";\n\ninterface RelationConfig<S extends RelationType, T extends TailorDBType> {\n type: S;\n toward: {\n type: T;\n as?: string;\n key?: keyof T[\"fields\"] & string;\n };\n backward?: string;\n}\n\n// Special config variant for self-referencing relations\ntype RelationSelfConfig = {\n type: RelationType;\n toward: {\n type: \"self\";\n as?: string;\n key?: string;\n };\n backward?: string;\n};\n\nfunction isRelationSelfConfig(\n config: RelationConfig<RelationType, TailorDBType> | RelationSelfConfig,\n): config is RelationSelfConfig {\n return config.toward.type === \"self\";\n}\n\n// Helper alias: DB fields can be arbitrarily nested, so we intentionally keep this loose.\n// oxlint-disable-next-line no-explicit-any\nexport type TailorAnyDBField = TailorDBField<any, any>;\n\nexport class TailorDBField<\n const Defined extends DefinedDBFieldMetadata,\n const Output,\n> extends TailorField<Defined, Output, DBFieldMetadata> {\n private _rawRelation: RawRelationConfig | undefined = undefined;\n\n get rawRelation(): Readonly<RawRelationConfig> | undefined {\n return this._rawRelation\n ? { ...this._rawRelation, toward: { ...this._rawRelation.toward } }\n : undefined;\n }\n\n get metadata() {\n return { ...this._metadata };\n }\n\n private constructor(\n type: TailorFieldType,\n options?: FieldOptions,\n fields?: Record<string, TailorAnyDBField>,\n values?: AllowedValues,\n ) {\n super(type, options, fields, values);\n }\n\n static create<\n const T extends TailorFieldType,\n const TOptions extends FieldOptions,\n const OutputBase = TailorToTs[T],\n >(\n type: T,\n options?: TOptions,\n fields?: Record<string, TailorAnyDBField>,\n values?: AllowedValues,\n ) {\n return new TailorDBField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n >(type, options, fields, values);\n }\n\n description<CurrentDefined extends Defined>(\n this: CurrentDefined extends { description: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n description: string,\n ): TailorDBField<Prettify<CurrentDefined & { description: true }>, Output> {\n // Fluent API: TS can't express the refined return type through the base method.\n // oxlint-disable-next-line no-explicit-any\n return super.description(description) as any;\n }\n\n relation<S extends RelationType, T extends TailorAnyDBType, CurrentDefined extends Defined>(\n this: CurrentDefined extends { relation: unknown }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n config: RelationConfig<S, T>,\n ): TailorDBField<\n S extends \"oneToOne\" | \"1-1\"\n ? Prettify<CurrentDefined & { unique: true; index: true; relation: true }>\n : Prettify<CurrentDefined & { index: true; relation: true }>,\n Output\n >;\n\n // Overload: self-referencing variant\n relation<S extends RelationSelfConfig, CurrentDefined extends Defined>(\n this: CurrentDefined extends { relation: unknown }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n config: S,\n ): TailorDBField<\n S[\"type\"] extends \"oneToOne\" | \"1-1\"\n ? Prettify<CurrentDefined & { unique: true; index: true; relation: true }>\n : Prettify<CurrentDefined & { index: true; relation: true }>,\n Output\n >;\n\n // Implementation\n relation<CurrentDefined extends Defined>(\n this: CurrentDefined extends { relation: unknown }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n config: RelationConfig<RelationType, TailorDBType> | RelationSelfConfig,\n ): TailorDBField<DefinedDBFieldMetadata, Output> {\n // Store raw relation config - all processing happens in parser layer\n const targetType = isRelationSelfConfig(config) ? \"self\" : config.toward.type.name;\n this._rawRelation = {\n type: config.type,\n toward: {\n type: targetType,\n as: config.toward.as,\n key: config.toward.key,\n },\n backward: config.backward,\n };\n return this;\n }\n\n index<CurrentDefined extends Defined>(\n this: CurrentDefined extends { index: unknown }\n ? never\n : CurrentDefined extends { array: true }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n ) {\n this._metadata.index = true;\n return this as TailorDBField<Prettify<CurrentDefined & { index: true }>, Output>;\n }\n\n unique<CurrentDefined extends Defined>(\n this: CurrentDefined extends { unique: unknown }\n ? never\n : CurrentDefined extends { array: true }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n ) {\n this._metadata.unique = true;\n this._metadata.index = true;\n return this as TailorDBField<Prettify<CurrentDefined & { unique: true; index: true }>, Output>;\n }\n\n vector<CurrentDefined extends Defined>(\n this: CurrentDefined extends { vector: unknown }\n ? never\n : CurrentDefined extends { type: \"string\"; array: false }\n ? TailorDBField<CurrentDefined, Output>\n : never,\n ) {\n this._metadata.vector = true;\n return this as TailorDBField<Prettify<CurrentDefined & { vector: true }>, Output>;\n }\n\n hooks<CurrentDefined extends Defined, const H extends Hook<unknown, Output>>(\n this: CurrentDefined extends { hooks: unknown }\n ? never\n : CurrentDefined extends { type: \"nested\" }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n hooks: H,\n ) {\n this._metadata.hooks = hooks;\n return this as TailorDBField<\n Prettify<\n CurrentDefined & {\n hooks?: {\n create: H extends { create: unknown } ? true : false;\n update: H extends { update: unknown } ? true : false;\n };\n serial: false;\n }\n >,\n Output\n >;\n }\n\n validate<CurrentDefined extends Defined>(\n this: CurrentDefined extends { validate: unknown }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n ...validate: FieldValidateInput<Output>[]\n ) {\n this._metadata.validate = validate;\n return this as TailorDBField<Prettify<CurrentDefined & { validate: true }>, Output>;\n }\n\n serial<CurrentDefined extends Defined>(\n this: CurrentDefined extends { serial: unknown }\n ? never\n : Output extends null\n ? never\n : CurrentDefined extends { type: \"integer\" | \"string\"; array: false }\n ? TailorDBField<CurrentDefined, Output>\n : never,\n config: SerialConfig<CurrentDefined[\"type\"] & (\"integer\" | \"string\")>,\n ) {\n (this as TailorDBField<CurrentDefined, Output>)._metadata.serial = config;\n return this as TailorDBField<\n Prettify<\n CurrentDefined & {\n serial: true;\n hooks: { create: false; update: false };\n }\n >,\n Output\n >;\n }\n\n /**\n * Clone the field with optional overrides for field options\n * @param {FieldOptions} [options] - Optional field options to override\n * @returns {TailorDBField<unknown, unknown>} A new TailorDBField instance with the same configuration\n */\n clone<const NewOpt extends FieldOptions>(\n options?: NewOpt,\n ): TailorDBField<\n Prettify<\n Omit<Defined, \"array\"> & {\n array: NewOpt extends { array: true } ? true : Defined[\"array\"];\n }\n >,\n FieldOutput<TailorToTs[Defined[\"type\"]], NewOpt>\n > {\n // Create a clone using Object.create to preserve prototype chain\n const clonedField = Object.create(Object.getPrototypeOf(this)) as TailorDBField<\n Defined,\n Output\n >;\n\n // Copy all properties\n Object.assign(clonedField, {\n type: this.type,\n fields: this.fields,\n _defined: this._defined,\n _output: this._output,\n });\n\n // Clone and merge metadata with new options\n clonedField._metadata = { ...this._metadata };\n if (options) {\n if (options.optional !== undefined) {\n clonedField._metadata.required = !options.optional;\n }\n if (options.array !== undefined) {\n clonedField._metadata.array = options.array;\n }\n }\n\n // Copy internal state\n if (this._rawRelation) {\n clonedField._rawRelation = {\n ...this._rawRelation,\n toward: { ...this._rawRelation.toward },\n };\n }\n\n return clonedField as TailorAnyDBField;\n }\n}\n\nconst createField = TailorDBField.create;\nfunction uuid<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"uuid\", options);\n}\n\nfunction string<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"string\", options);\n}\n\nfunction bool<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"boolean\", options);\n}\n\nfunction int<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"integer\", options);\n}\n\nfunction float<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"float\", options);\n}\n\nfunction date<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"date\", options);\n}\n\nfunction datetime<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"datetime\", options);\n}\n\nfunction time<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"time\", options);\n}\n\nfunction _enum<const V extends AllowedValues, const Opt extends FieldOptions>(\n values: V,\n options?: Opt,\n): TailorDBField<\n { type: \"enum\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<AllowedValuesOutput<V>, Opt>\n> {\n return createField<\"enum\", Opt, AllowedValuesOutput<V>>(\"enum\", options, undefined, values);\n}\n\nfunction object<\n const F extends Record<string, TailorAnyDBField> & ExcludeNestedDBFields<F>,\n const Opt extends FieldOptions,\n>(fields: F, options?: Opt) {\n return createField(\"nested\", options, fields) as unknown as TailorDBField<\n { type: \"nested\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<InferFieldsOutput<F>, Opt>\n >;\n}\n\n// Helper alias\n// oxlint-disable-next-line no-explicit-any\nexport type TailorAnyDBType = TailorDBType<any, any>;\n\nexport class TailorDBType<\n // Default kept loose to avoid forcing callers to supply generics.\n // oxlint-disable-next-line no-explicit-any\n const Fields extends Record<string, TailorAnyDBField> = any,\n User extends object = InferredAttributeMap,\n> {\n public readonly _output = null as unknown as InferFieldsOutput<Fields>;\n public _description?: string;\n private _settings: TypeFeatures = {};\n private _indexes: IndexDef<this>[] = [];\n private _permissions: RawPermissions = {};\n private _files: Record<string, string> = {};\n\n constructor(\n public readonly name: string,\n public readonly fields: Fields,\n options: { pluralForm?: string; description?: string },\n ) {\n this._description = options.description;\n\n if (options.pluralForm) {\n if (name === options.pluralForm) {\n throw new Error(`The name and the plural form must be different. name=${name}`);\n }\n this._settings.pluralForm = options.pluralForm;\n }\n }\n\n get metadata(): TailorDBTypeMetadata {\n // Convert indexes to the format expected by the manifest\n const indexes: Record<string, { fields: string[]; unique?: boolean }> = {};\n if (this._indexes && this._indexes.length > 0) {\n this._indexes.forEach((index) => {\n const fieldNames = index.fields.map((field) => String(field));\n const key = index.name || `idx_${fieldNames.join(\"_\")}`;\n indexes[key] = {\n fields: fieldNames,\n unique: index.unique,\n };\n });\n }\n\n return {\n name: this.name,\n description: this._description,\n settings: this._settings,\n permissions: this._permissions,\n files: this._files,\n ...(Object.keys(indexes).length > 0 && { indexes }),\n };\n }\n\n hooks(hooks: Hooks<Fields>) {\n // `Hooks<Fields>` is strongly typed, but `Object.entries()` loses that information.\n // oxlint-disable-next-line no-explicit-any\n Object.entries(hooks).forEach(([fieldName, fieldHooks]: [string, any]) => {\n this.fields[fieldName].hooks(fieldHooks);\n });\n return this;\n }\n\n validate(validators: Validators<Fields>) {\n Object.entries(validators).forEach(([fieldName, fieldValidators]) => {\n const field = this.fields[fieldName] as TailorAnyDBField;\n\n const validators = fieldValidators as\n | FieldValidateInput<unknown>\n | FieldValidateInput<unknown>[];\n\n const isValidateConfig = (v: unknown): v is ValidateConfig<unknown> => {\n return Array.isArray(v) && v.length === 2 && typeof v[1] === \"string\";\n };\n\n if (Array.isArray(validators)) {\n if (isValidateConfig(validators)) {\n field.validate(validators);\n } else {\n field.validate(...validators);\n }\n } else {\n field.validate(validators);\n }\n });\n return this;\n }\n\n features(features: Omit<TypeFeatures, \"pluralForm\">) {\n this._settings = { ...this._settings, ...features };\n return this;\n }\n\n indexes(...indexes: IndexDef<this>[]) {\n this._indexes = indexes;\n return this;\n }\n\n files<const F extends string>(\n files: Record<F, string> & Partial<Record<keyof output<this>, never>>,\n ) {\n this._files = files;\n return this;\n }\n\n permission<\n U extends object = User,\n P extends TailorTypePermission<U, output<this>> = TailorTypePermission<U, output<this>>,\n >(permission: P) {\n const ret = this as TailorDBType<Fields, U>;\n ret._permissions.record = permission;\n return ret;\n }\n\n gqlPermission<\n U extends object = User,\n P extends TailorTypeGqlPermission<U> = TailorTypeGqlPermission<U>,\n >(permission: P) {\n const ret = this as TailorDBType<Fields, U>;\n ret._permissions.gql = permission;\n return ret;\n }\n\n description(description: string) {\n this._description = description;\n return this;\n }\n\n /**\n * Pick specific fields from the type\n * @param {(keyof Fields)[]} keys - Array of field keys to pick\n * @param {FieldOptions} options - Optional field options to apply to picked fields\n * @returns {Record<string, TailorDBField<unknown, unknown>>} An object containing only the specified fields\n */\n pickFields<K extends keyof Fields, const Opt extends FieldOptions>(keys: K[], options: Opt) {\n const result = {} as Record<K, TailorAnyDBField>;\n for (const key of keys) {\n if (options) {\n result[key] = this.fields[key].clone(options);\n } else {\n result[key] = this.fields[key];\n }\n }\n return result as {\n [P in K]: Fields[P] extends TailorDBField<infer D, infer _O>\n ? TailorDBField<\n Omit<D, \"array\"> & {\n array: Opt extends { array: true } ? true : D[\"array\"];\n },\n FieldOutput<TailorToTs[D[\"type\"]], Opt>\n >\n : never;\n };\n }\n\n /**\n * Omit specific fields from the type\n * @template K\n * @param {(keyof Fields)[]} keys - Array of field keys to omit\n * @returns {Omit<Fields, K>} An object containing all fields except the specified ones\n */\n omitFields<K extends keyof Fields>(keys: K[]): Omit<Fields, K> {\n const keysSet = new Set(keys);\n const result = {} as Record<string, TailorAnyDBField>;\n for (const key in this.fields) {\n if (Object.hasOwn(this.fields, key) && !keysSet.has(key as unknown as K)) {\n result[key] = this.fields[key];\n }\n }\n return result as Omit<Fields, K>;\n }\n}\n\nexport type TailorDBInstance<\n // Default kept loose for convenience; callers still get fully inferred types from `db.type()`.\n // oxlint-disable-next-line no-explicit-any\n Fields extends Record<string, TailorAnyDBField> = any,\n User extends object = InferredAttributeMap,\n> = InstanceType<typeof TailorDBType<Fields, User>>;\n\nconst idField = uuid();\ntype idField = typeof idField;\ntype DBType<F extends { id?: never } & Record<string, TailorAnyDBField>> = TailorDBInstance<\n { id: idField } & F\n>;\n\n/**\n * Creates a new database type with the specified fields\n * @param {string | [string, string]} name - The name of the type, or a tuple of [name, pluralForm]\n * @param {Record<string, TailorDBField<unknown, unknown>>} fields - The field definitions for the type\n * @returns {DBType<F>} A new TailorDBType instance\n */\nfunction dbType<const F extends { id?: never } & Record<string, TailorAnyDBField>>(\n name: string | [string, string],\n fields: F,\n): DBType<F>;\n/**\n * Creates a new database type with the specified fields and description\n * @param {string | [string, string]} name - The name of the type, or a tuple of [name, pluralForm]\n * @param {string} description - A description of the type\n * @param {Record<string, TailorDBField<unknown, unknown>>} fields - The field definitions for the type\n * @returns {DBType<F>} A new TailorDBType instance\n */\nfunction dbType<const F extends { id?: never } & Record<string, TailorAnyDBField>>(\n name: string | [string, string],\n description: string,\n fields: F,\n): DBType<F>;\nfunction dbType<const F extends { id?: never } & Record<string, TailorAnyDBField>>(\n name: string | [string, string],\n fieldsOrDescription: string | F,\n fields?: F,\n): DBType<F> {\n const typeName = Array.isArray(name) ? name[0] : name;\n const pluralForm = Array.isArray(name) ? name[1] : undefined;\n\n let description: string | undefined;\n let fieldDef: F;\n if (typeof fieldsOrDescription === \"string\") {\n description = fieldsOrDescription;\n fieldDef = fields as F;\n } else {\n fieldDef = fieldsOrDescription;\n }\n return new TailorDBType<{ id: idField } & F>(\n typeName,\n {\n id: idField,\n ...fieldDef,\n },\n { pluralForm, description },\n ) as DBType<F>;\n}\n\nexport const db = {\n type: dbType,\n uuid,\n string,\n bool,\n int,\n float,\n date,\n datetime,\n time,\n enum: _enum,\n object,\n fields: {\n timestamps: () => ({\n createdAt: datetime()\n .hooks({ create: () => new Date() })\n .description(\"Record creation timestamp\"),\n updatedAt: datetime({ optional: true })\n .hooks({ update: () => new Date() })\n .description(\"Record last update timestamp\"),\n }),\n },\n};\n","import { type TailorDBInstance } from \"../tailordb/schema\";\nimport type {\n AuthInvoker as ParserAuthInvoker,\n AuthServiceInput,\n UserAttributeListKey,\n UserAttributeMap,\n} from \"@/parser/service/auth/types\";\n\ndeclare const authDefinitionBrand: unique symbol;\ntype AuthDefinitionBrand = { readonly [authDefinitionBrand]: true };\n\nexport type {\n OIDC,\n SAML,\n IDToken,\n BuiltinIdP,\n IdProviderConfig,\n OAuth2ClientGrantType,\n OAuth2ClientInput as OAuth2Client,\n SCIMAuthorization,\n SCIMAttributeType,\n SCIMAttribute,\n SCIMAttributeMapping,\n SCIMResource,\n SCIMConfig,\n TenantProviderConfig,\n ValueOperand,\n UsernameFieldKey,\n UserAttributeKey,\n UserAttributeListKey,\n UserAttributeMap,\n AuthServiceInput,\n} from \"@/parser/service/auth/types\";\n\n/**\n * Invoker type compatible with tailor.v1.AuthInvoker\n * - namespace: auth service name\n * - machineUserName: machine user name\n */\nexport type AuthInvoker<M extends string> = Omit<ParserAuthInvoker, \"machineUserName\"> & {\n machineUserName: M;\n};\n\n/**\n * Define an auth service for the Tailor SDK.\n * @template Name\n * @template User\n * @template AttributeMap\n * @template AttributeList\n * @template MachineUserNames\n * @template M\n * @param {Name} name - Auth service name\n * @param {AuthServiceInput<User, AttributeMap, AttributeList, MachineUserNames>} config - Auth service configuration\n * @returns {AuthDefinitionBrand & AuthServiceInput<User, AttributeMap, AttributeList, MachineUserNames> & { name: string; invoker<M extends MachineUserNames>(machineUser: M): AuthInvoker<M> }} Defined auth service\n */\nexport function defineAuth<\n const Name extends string,\n const User extends TailorDBInstance,\n const AttributeMap extends UserAttributeMap<User>,\n const AttributeList extends UserAttributeListKey<User>[],\n const MachineUserNames extends string,\n>(name: Name, config: AuthServiceInput<User, AttributeMap, AttributeList, MachineUserNames>) {\n const result = {\n ...config,\n name,\n invoker<M extends MachineUserNames>(machineUser: M) {\n return { namespace: name, machineUserName: machineUser } as const;\n },\n } as const satisfies AuthServiceInput<User, AttributeMap, AttributeList, MachineUserNames> & {\n name: string;\n invoker<M extends MachineUserNames>(machineUser: M): AuthInvoker<M>;\n };\n\n return result as typeof result & AuthDefinitionBrand;\n}\n\nexport type AuthExternalConfig = { name: string; external: true };\n\n// We intentionally use `any` placeholders here to avoid re-exporting a large generic surface.\n// oxlint-disable-next-line no-explicit-any\nexport type AuthOwnConfig = ReturnType<typeof defineAuth<string, any, any, any, string>>;\n\nexport type AuthConfig = AuthOwnConfig | AuthExternalConfig;\n","import type { TailorEnv } from \"@/configure/types/env\";\nimport type { JsonCompatible } from \"@/configure/types/helpers\";\nimport type { Jsonifiable, Jsonify, JsonPrimitive } from \"type-fest\";\n\n/**\n * Symbol used to brand WorkflowJob objects created by createWorkflowJob.\n * This enables reliable runtime detection of workflow jobs regardless of\n * how they were imported or assigned (variable reassignment, destructuring, etc.)\n */\nexport const WORKFLOW_JOB_BRAND = Symbol.for(\"tailor:workflow-job\");\n\n/**\n * Context object passed as the second argument to workflow job body functions.\n */\nexport type WorkflowJobContext = {\n env: TailorEnv;\n};\n\n/**\n * Allowed output types for workflow job body functions.\n * Includes Jsonifiable (JSON-serializable values including objects with toJSON like Date),\n * undefined, and void.\n */\nexport type WorkflowJobOutput = Jsonifiable | undefined | void;\n\n/**\n * Convert output type to what trigger returns after JSON serialization.\n * - Jsonifiable values are converted via Jsonify (Date -> string, etc.)\n * - undefined remains undefined\n * - void becomes void\n */\ntype JsonifyOutput<T> = T extends Jsonifiable ? Jsonify<T> : T;\n\n/**\n * Input type constraint for workflow jobs.\n * Accepts any type that is JSON-compatible (primitives, arrays, objects with JSON-compatible values).\n * Excludes objects with toJSON method (like Date) since they won't be serialized in input.\n */\nexport type WorkflowJobInput = undefined | JsonCompatible<unknown>;\n\n/**\n * WorkflowJob represents a job that can be triggered in a workflow.\n *\n * Type constraints:\n * - Input: Must be JSON-compatible (no Date/toJSON objects) or undefined. Interfaces are allowed.\n * - Output: Must be Jsonifiable, undefined, or void\n * - Trigger returns Jsonify<Output> (Date becomes string after JSON.stringify)\n */\nexport interface WorkflowJob<Name extends string = string, Input = undefined, Output = undefined> {\n readonly [WORKFLOW_JOB_BRAND]?: true;\n name: Name;\n /**\n * Trigger this job with the given input.\n * At runtime, this is a placeholder that calls the body function.\n * During bundling, calls to .trigger() are transformed to\n * tailor.workflow.triggerJobFunction(\"<job-name>\", args).\n *\n * Returns Jsonify<Output> because the value passes through JSON.stringify.\n */\n trigger: [Input] extends [undefined]\n ? () => Promise<JsonifyOutput<Awaited<Output>>>\n : (input: Input) => Promise<JsonifyOutput<Awaited<Output>>>;\n body: (input: Input, context: WorkflowJobContext) => Output | Promise<Output>;\n}\n\n/**\n * Helper type to check if all property types are valid.\n * Uses -? to remove optional modifiers so all properties are treated uniformly.\n */\ntype AllPropertiesValid<T> = {\n [K in keyof T]-?: IsValidInput<T[K]> extends true ? true : false;\n}[keyof T] extends true\n ? true\n : false;\n\n/**\n * Check if a type contains any non-JSON-compatible values.\n * Returns `true` if the type is valid for input, `false` otherwise.\n *\n * Accepts:\n * - JSON primitives (string, number, boolean, null)\n * - undefined\n * - Optional primitives (e.g., string | undefined)\n * - Arrays of valid types\n * - Objects with valid field types\n *\n * Rejects:\n * - Objects with toJSON methods (like Date)\n * - Other non-JSON-serializable types\n */\ntype IsValidInput<T> = T extends undefined\n ? true\n : T extends JsonPrimitive\n ? true\n : T extends readonly (infer U)[]\n ? IsValidInput<U>\n : T extends object\n ? T extends { toJSON: () => unknown }\n ? false\n : AllPropertiesValid<T>\n : false;\n\n/**\n * Helper type to check if all property types are valid for output.\n * Uses -? to remove optional modifiers so all properties are treated uniformly.\n */\ntype AllPropertiesValidOutput<T> = {\n [K in keyof T]-?: IsValidOutput<T[K]> extends true ? true : false;\n}[keyof T] extends true\n ? true\n : false;\n\n/**\n * Check if a type is valid for output.\n * Returns `true` if the type is valid, `false` otherwise.\n *\n * Accepts:\n * - JSON primitives (string, number, boolean, null)\n * - undefined and void\n * - Optional primitives (e.g., string | undefined)\n * - Jsonifiable types (Date, objects with toJSON)\n * - Arrays of valid types\n * - Objects with valid field types\n */\ntype IsValidOutput<T> = T extends undefined | void\n ? true\n : T extends JsonPrimitive\n ? true\n : T extends readonly (infer U)[]\n ? IsValidOutput<U>\n : T extends object\n ? AllPropertiesValidOutput<T>\n : false;\n\n/**\n * Body function type with conditional constraint.\n * If input contains invalid types (like Date), the body type becomes `never` to cause an error.\n */\ntype WorkflowJobBody<I, O> =\n IsValidInput<I> extends true\n ? IsValidOutput<O> extends true\n ? (input: I, context: WorkflowJobContext) => O | Promise<O>\n : never\n : never;\n\nexport const createWorkflowJob = <const Name extends string, I = undefined, O = undefined>(config: {\n readonly name: Name;\n readonly body: WorkflowJobBody<I, O>;\n}): WorkflowJob<Name, I, Awaited<O>> => {\n return {\n [WORKFLOW_JOB_BRAND]: true,\n name: config.name,\n // JSON.parse(JSON.stringify(...)) ensures the return value matches Jsonify<Output> type.\n // This converts Date objects to strings, matching actual runtime behavior.\n trigger: async (args?: unknown) => {\n const ret = await tailor.workflow.triggerJobFunction(config.name, args);\n return ret ? JSON.parse(JSON.stringify(ret)) : ret;\n },\n body: config.body,\n } as WorkflowJob<Name, I, Awaited<O>>;\n};\n","import type { AuthConfig } from \"@/configure/services/auth\";\nimport type { ExecutorServiceInput } from \"@/configure/services/executor/types\";\nimport type { IdPConfig } from \"@/configure/services/idp\";\nimport type { ResolverServiceInput } from \"@/configure/services/resolver/types\";\nimport type { StaticWebsiteConfig } from \"@/configure/services/staticwebsite\";\nimport type { TailorDBServiceInput } from \"@/configure/services/tailordb/types\";\nimport type { WorkflowServiceInput } from \"@/configure/services/workflow/types\";\nimport type { GeneratorConfig } from \"@/parser/generator-config/types\";\n\nexport interface AppConfig<\n Auth extends AuthConfig = AuthConfig,\n Idp extends IdPConfig[] = IdPConfig[],\n StaticWebsites extends StaticWebsiteConfig[] = StaticWebsiteConfig[],\n Env extends Record<string, string | number | boolean> = Record<string, string | number | boolean>,\n> {\n name: string;\n env?: Env;\n cors?: string[];\n allowedIpAddresses?: string[];\n disableIntrospection?: boolean;\n db?: TailorDBServiceInput;\n resolver?: ResolverServiceInput;\n idp?: Idp;\n auth?: Auth;\n executor?: ExecutorServiceInput;\n workflow?: WorkflowServiceInput;\n staticWebsites?: StaticWebsites;\n}\n\nlet distPath: string | null = null;\nexport const getDistDir = (): string => {\n const configured = process.env.TAILOR_SDK_OUTPUT_DIR;\n if (configured && configured !== distPath) {\n distPath = configured;\n } else if (distPath === null) {\n distPath = configured || \".tailor-sdk\";\n }\n return distPath;\n};\n\n/**\n * Define a Tailor SDK application configuration with shallow exactness.\n * @template Config\n * @param {Config} config - Application configuration\n * @returns {Config} The same configuration object\n */\nexport function defineConfig<\n const Config extends AppConfig &\n // type-fest's Exact works recursively and causes type errors, so we use a shallow version here.\n Record<Exclude<keyof Config, keyof AppConfig>, never>,\n>(config: Config) {\n return config;\n}\n\n/**\n * Define generators to be used with the Tailor SDK.\n * @param {...GeneratorConfig} configs - Generator configurations\n * @returns {GeneratorConfig[]} Generator configurations as given\n */\nexport function defineGenerators(...configs: GeneratorConfig[]) {\n return configs;\n}\n"],"mappings":";;;;;;AAWA,SAAgB,iBAAiB,QAAuC;AACtE,QAAO,OAAO,KAAK,UAAU;AAC3B,MAAI,OAAO,UAAU,SACnB,QAAO;GAAE;GAAO,aAAa;GAAI;AAEnC,SAAO;GAAE,GAAG;GAAO,aAAa,MAAM,eAAe;GAAI;GACzD;;;;;ACFJ,MAAM,QAAQ;CACZ,MAAM;CACN,MAAM;CACN,MAAM;CACN,UACE;CACH;AAMD,IAAa,cAAb,MAAa,YAOiB;CAC5B,AAAU;CACV,AAAgB,WAAoB;CACpC,AAAgB,UAAU;CAE1B,IAAI,WAAW;AACb,SAAO,EAAE,GAAG,KAAK,WAAW;;CAG9B,AAAU,YACR,AAAgB,MAChB,SACA,AAAgB,SAAyC,EAAE,EAC3D,QACA;EAJgB;EAEA;AAGhB,OAAK,YAAY,EAAE,UAAU,MAAM;AACnC,MAAI,SAAS;AACX,OAAI,QAAQ,aAAa,KACvB,MAAK,UAAU,WAAW;AAE5B,OAAI,QAAQ,UAAU,KACpB,MAAK,UAAU,QAAQ;;AAG3B,MAAI,OACF,MAAK,UAAU,gBAAgB,iBAAiB,OAAO;;CAI3D,OAAO,OAKL,MACA,SACA,QACA,QACA;AACA,SAAO,IAAI,YAGT,MAAM,SAAS,QAAQ,OAAO;;CAGlC,YAIE,aACA;AACA,OAAK,UAAU,cAAc;AAC7B,SAAO;;CAGT,SAME,UACA;AACA,OAAK,UAAU,WAAW;AAC1B,SAAO;;CAGT,SAIE,GAAG,UACH;AACA,OAAK,UAAU,WAAW;AAC1B,SAAO;;;;;;;;;;;CAYT,MAAM,MAI8B;AAClC,SAAO,KAAK,eAAe;GACzB,OAAO,KAAK;GACZ,MAAM,KAAK;GACX,MAAM,KAAK;GACX,WAAW,EAAE;GACd,CAAC;;;;;;;;;;;;;CAcJ,AAAQ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