@tailor-platform/sdk 1.66.0 → 1.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/application-Djeezk3m.mjs +4 -0
  3. package/dist/{client-F0a4cWUM.mjs → application-WpWwTyk9.mjs} +5734 -20
  4. package/dist/application-WpWwTyk9.mjs.map +1 -0
  5. package/dist/{authconnection-D8SJGMpj.mjs → authconnection-Ds2Ahpum.mjs} +2 -2
  6. package/dist/{authconnection-D8SJGMpj.mjs.map → authconnection-Ds2Ahpum.mjs.map} +1 -1
  7. package/dist/cli/index.mjs +18 -64
  8. package/dist/cli/index.mjs.map +1 -1
  9. package/dist/cli/lib.d.mts +7 -7
  10. package/dist/cli/lib.mjs +3 -4
  11. package/dist/cli/lib.mjs.map +1 -1
  12. package/dist/completion/zsh-worker.zsh +1 -1
  13. package/dist/configure/index.d.mts +5 -5
  14. package/dist/configure/index.mjs +2 -2
  15. package/dist/configure/index.mjs.map +1 -1
  16. package/dist/{context-s0lxhu8_.mjs → context-CDQqIv4u.mjs} +2 -2
  17. package/dist/{context-s0lxhu8_.mjs.map → context-CDQqIv4u.mjs.map} +1 -1
  18. package/dist/{crashreport-Bf6uT6mf.mjs → crashreport-6jpCceOF.mjs} +1 -1
  19. package/dist/{crashreport-0EHy-ayY.mjs → crashreport-u9y2npiy.mjs} +5 -7
  20. package/dist/{crashreport-0EHy-ayY.mjs.map → crashreport-u9y2npiy.mjs.map} +1 -1
  21. package/dist/enum-constants-C7DaWeQo.mjs.map +1 -1
  22. package/dist/field-C4zdJLW5.mjs.map +1 -1
  23. package/dist/{file-B58Dm-2P.mjs → file-BkxupbYP.mjs} +2 -2
  24. package/dist/{file-B58Dm-2P.mjs.map → file-BkxupbYP.mjs.map} +1 -1
  25. package/dist/file-utils-BHPxPXmn.mjs.map +1 -1
  26. package/dist/{iconv-DreIffeM.mjs → iconv-D1zmPjvi.mjs} +2 -2
  27. package/dist/{iconv-DreIffeM.mjs.map → iconv-D1zmPjvi.mjs.map} +1 -1
  28. package/dist/{idp-Ch95ag8h.mjs → idp-BZPqpcYY.mjs} +2 -2
  29. package/dist/{idp-Ch95ag8h.mjs.map → idp-BZPqpcYY.mjs.map} +1 -1
  30. package/dist/{index-Db2RvnEH.d.mts → index-CklcVeMG.d.mts} +2 -2
  31. package/dist/{index-CZ2r3qiO.d.mts → index-DYhnxXYR.d.mts} +2 -2
  32. package/dist/{index-QpC0TNbH.d.mts → index-DlDRSzFZ.d.mts} +2 -2
  33. package/dist/{index-BdLqzJDu.d.mts → index-DvEUb3pX.d.mts} +15 -9
  34. package/dist/{index-Bhjep8cS.d.mts → index-hXoO-AOC.d.mts} +2 -2
  35. package/dist/job-BpsFXPbi.mjs.map +1 -1
  36. package/dist/kysely-type-D1e0Vwkd.mjs.map +1 -1
  37. package/dist/mock-DMgIygjE.mjs.map +1 -1
  38. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  39. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  40. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  41. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  42. package/dist/plugin/builtin/seed/index.mjs +1 -1
  43. package/dist/plugin/index.d.mts +2 -3
  44. package/dist/plugin/index.mjs.map +1 -1
  45. package/dist/registry-D0uB0OrK.mjs.map +1 -1
  46. package/dist/runtime/authconnection.mjs +1 -1
  47. package/dist/runtime/context.mjs +1 -1
  48. package/dist/runtime/file.mjs +1 -1
  49. package/dist/runtime/iconv.mjs +1 -1
  50. package/dist/runtime/idp.mjs +1 -1
  51. package/dist/runtime/index.mjs +7 -7
  52. package/dist/runtime/secretmanager.mjs +1 -1
  53. package/dist/runtime/workflow.mjs +1 -1
  54. package/dist/{runtime-2nzOZCUb.mjs → runtime-BU6KtCvk.mjs} +9 -35
  55. package/dist/runtime-BU6KtCvk.mjs.map +1 -0
  56. package/dist/schema-1msIhXwA.mjs.map +1 -1
  57. package/dist/{secret-file-CWzF8rry.mjs → secret-file-eB3R3Fil.mjs} +27 -2
  58. package/dist/{secret-file-CWzF8rry.mjs.map → secret-file-eB3R3Fil.mjs.map} +1 -1
  59. package/dist/{secretmanager-B9h-U_8U.mjs → secretmanager-h3tBJV8f.mjs} +2 -2
  60. package/dist/{secretmanager-B9h-U_8U.mjs.map → secretmanager-h3tBJV8f.mjs.map} +1 -1
  61. package/dist/{seed-BH2FbrPV.mjs → seed-YAbtMy65.mjs} +2 -2
  62. package/dist/seed-YAbtMy65.mjs.map +1 -0
  63. package/dist/{service-DMohAx8a2.mjs → service-DMohAx8a.mjs} +1 -1
  64. package/dist/service-DMohAx8a.mjs.map +1 -0
  65. package/dist/service-wI3Hvrgx.mjs.map +1 -1
  66. package/dist/{plugin-DylAsA4Z.d.mts → types-Bzr0RQME.d.mts} +342 -36
  67. package/dist/types-CmzfQP_m.mjs.map +1 -1
  68. package/dist/types-DTcZ2Yax.d.mts +74 -0
  69. package/dist/{tailordb-C-ar4XCX.d.mts → types-DZrtN6-H.d.mts} +89 -239
  70. package/dist/utils/test/index.d.mts +3 -3
  71. package/dist/utils/test/index.mjs.map +1 -1
  72. package/dist/vitest/index.d.mts +1 -1
  73. package/dist/{workflow--aPbA8Uq.mjs → workflow-C8I7shjM.mjs} +2 -2
  74. package/dist/{workflow--aPbA8Uq.mjs.map → workflow-C8I7shjM.mjs.map} +1 -1
  75. package/dist/{workflow.generated--1Qc15Et.d.mts → workflow.generated-1S50BhEb.d.mts} +17 -241
  76. package/docs/cli-reference.md +18 -17
  77. package/docs/github-actions.md +2 -2
  78. package/package.json +13 -11
  79. package/dist/actor-D_2aJjYO.d.mts +0 -24
  80. package/dist/application-DGDmL8i_.mjs +0 -5620
  81. package/dist/application-DGDmL8i_.mjs.map +0 -1
  82. package/dist/application-nTydHJm8.mjs +0 -4
  83. package/dist/client-F0a4cWUM.mjs.map +0 -1
  84. package/dist/client-boxXYevx.mjs +0 -4
  85. package/dist/env-B-g-qgE4.d.mts +0 -7
  86. package/dist/runtime-2nzOZCUb.mjs.map +0 -1
  87. package/dist/seed-BH2FbrPV.mjs.map +0 -1
  88. package/dist/service-DMohAx8a2.mjs.map +0 -1
  89. /package/dist/{chunk-BkoGK1jX.mjs → rolldown-runtime-BkoGK1jX.mjs} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"types-CmzfQP_m.mjs","names":[],"sources":["../src/configure/types/type.ts"],"sourcesContent":["import { type AllowedValues, type AllowedValuesOutput, mapAllowedValues } from \"./field\";\nimport type {\n DefinedFieldMetadata,\n TailorFieldType,\n TailorToTs,\n FieldMetadata,\n FieldOptions,\n FieldOutput,\n} from \"@/types/field-types\";\nimport type { InferFieldsOutput, Prettify } from \"@/types/helpers\";\nimport type { TailorField as TailorFieldBase } from \"@/types/tailor-field\";\nimport type { TailorUser } from \"@/types/user\";\nimport type { FieldValidateInput } from \"@/types/validation\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\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\n/**\n * Full TailorField interface with builder methods.\n * Extends the minimal structural interface from types/ with fluent API methods.\n */\nexport interface TailorField<\n 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 Output = any,\n M extends FieldMetadata = FieldMetadata,\n T extends TailorFieldType = TailorFieldType,\n> extends TailorFieldBase<Defined, Output, M, T> {\n readonly fields: Record<string, TailorAnyField>;\n _metadata: M;\n\n /**\n * Set a description for the field\n * @param description - The description text\n * @returns The field with updated metadata\n */\n description<CurrentDefined extends Defined>(\n this: CurrentDefined extends { description: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n description: string,\n ): TailorField<Prettify<CurrentDefined & { description: true }>, Output>;\n\n /**\n * Set a custom type name for enum or nested types\n * @param typeName - The custom type name\n * @returns The field with updated metadata\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 ): TailorField<Prettify<CurrentDefined & { typeName: true }>, Output>;\n\n /**\n * Add validation functions to the field\n * @param validate - One or more validation functions\n * @returns The field with updated metadata\n */\n validate<CurrentDefined extends Defined>(\n this: CurrentDefined extends { validate: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n ...validate: FieldValidateInput<Output>[]\n ): TailorField<Prettify<CurrentDefined & { validate: true }>, Output>;\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 args - Value, context data, and user\n * @returns Validation result\n */\n parse(args: FieldParseArgs): StandardSchemaV1.Result<Output>;\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @private\n * @param args - Parse arguments\n * @returns Validation result\n */\n _parseInternal(args: FieldParseInternalArgs): StandardSchemaV1.Result<Output>;\n}\n\n/**\n * Internal shape carried by every runtime field for clone-on-write support.\n *\n * `clone()` is intentionally kept off the public {@link TailorField} interface:\n * adding it there would force `TailorDBField` (which has a differently-typed\n * `clone`) to stop being assignable to `TailorField`, breaking the supported\n * `t.object({ field: db.string() })` usage. Every `t.*` and `db.*` field carries\n * a `clone()` at runtime, so the internal cast in `clone()` is safe.\n */\ntype CloneableField = { clone(): TailorAnyField };\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 decimal: /^-?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?$/,\n} as const;\n\ntype FieldParseArgs = {\n value: unknown;\n data: unknown;\n user: TailorUser;\n};\n\ntype FieldValidateValueArgs<T extends TailorFieldType> = {\n value: TailorToTs[T];\n data: unknown;\n user: TailorUser;\n pathArray: string[];\n};\n\ntype FieldParseInternalArgs = {\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};\n\n/**\n * Creates a new TailorField instance.\n * @param type - Field type\n * @param options - Field options\n * @param fields - Nested fields for object-like types\n * @param values - Allowed values for enum-like fields\n * @param metadata - Pre-built metadata to clone from (used by `clone()`); when\n * given, the mutable containers are deep-copied here and `options`/`values` are\n * ignored for metadata construction\n * @returns A new TailorField\n */\nfunction createTailorField<\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, TailorAnyField>,\n values?: AllowedValues,\n metadata?: FieldMetadata,\n): TailorField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n> {\n // When cloning, take ownership of the source metadata and deep-copy its mutable\n // containers (enum value objects and `[fn, message]` validator tuples; validator\n // functions are kept by reference) so no two instances share mutable state.\n const _metadata: FieldMetadata = metadata\n ? {\n ...metadata,\n ...(metadata.allowedValues && {\n allowedValues: metadata.allowedValues.map((v) => ({ ...v })),\n }),\n ...(metadata.validate && {\n validate: metadata.validate.map((v) => (Array.isArray(v) ? ([...v] as typeof v) : v)),\n }),\n }\n : { required: true };\n\n if (!metadata) {\n if (options) {\n if (options.optional === true) {\n _metadata.required = false;\n }\n if (options.array === true) {\n _metadata.array = true;\n }\n }\n if (values) {\n _metadata.allowedValues = mapAllowedValues(values);\n }\n }\n\n /**\n * Validate a single value (not an array element)\n * Used internally for array element validation\n * @param args - Value, context data, and user\n * @returns Array of validation issues\n */\n function validateValue(args: FieldValidateValueArgs<T>): StandardSchemaV1.Issue[] {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n const path = pathArray.length > 0 ? pathArray : undefined;\n\n // Type-specific validation\n switch (type) {\n case \"string\":\n if (typeof value !== \"string\") {\n issues.push({\n message: `Expected a string: received ${String(value)}`,\n path,\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,\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,\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,\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,\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,\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,\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,\n });\n }\n break;\n case \"decimal\":\n if (typeof value !== \"string\" || !regex.decimal.test(value)) {\n issues.push({\n message: `Expected a decimal string: received ${String(value)}`,\n path,\n });\n }\n break;\n\n case \"enum\":\n if (field._metadata.allowedValues) {\n const allowedValues = field._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,\n });\n }\n }\n break;\n\n case \"nested\":\n // Validate nested object fields\n // runtime value may not match the declared type\n // oxlint-disable typescript/no-unnecessary-condition\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n value instanceof Date\n ) {\n // oxlint-enable typescript/no-unnecessary-condition\n issues.push({\n message: `Expected an object: received ${String(value)}`,\n path,\n });\n } else if (Object.keys(field.fields).length > 0) {\n for (const [fieldName, nestedField] of Object.entries(field.fields)) {\n const fieldValue = (value as Record<string, unknown>)[fieldName];\n const result = nestedField._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 = field._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,\n });\n }\n }\n }\n\n return issues;\n }\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @param args - Parse arguments\n * @returns Parse result with value or issues\n */\n function parseInternal(\n args: FieldParseInternalArgs,\n ): StandardSchemaV1.Result<FieldOutput<OutputBase, TOptions>> {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n const path = pathArray.length > 0 ? pathArray : undefined;\n\n // 1. Check required/optional\n const isNullOrUndefined = value === null || value === undefined;\n if (field._metadata.required && isNullOrUndefined) {\n issues.push({\n message: \"Required field is missing\",\n path,\n });\n return { issues };\n }\n\n // If optional and null/undefined, skip further validation and normalize to null\n if (!field._metadata.required && isNullOrUndefined) {\n return { value: value ?? null };\n }\n\n // 2. Check array type\n if (field._metadata.array) {\n if (!Array.isArray(value)) {\n issues.push({\n message: \"Expected an array\",\n path,\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 = 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 FieldOutput<OutputBase, TOptions> };\n }\n\n // 3. Type-specific validation and custom validation\n const valueIssues = 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 /**\n * Clone the field and apply metadata updates to the clone.\n * The original instance is never mutated, so a field shared across places\n * cannot leak metadata between them.\n * @param metadataUpdates - Metadata properties to overwrite on the clone\n * @returns A new field with the updated metadata\n */\n function cloneWith(metadataUpdates: Partial<FieldMetadata>) {\n const cloned = field.clone();\n Object.assign(cloned._metadata, metadataUpdates);\n return cloned;\n }\n\n const field: TailorField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n > &\n CloneableField = {\n type,\n fields: fields ?? {},\n _defined: undefined as unknown as {\n type: T;\n array: TOptions extends { array: true } ? true : false;\n },\n _output: undefined as FieldOutput<OutputBase, TOptions>,\n _metadata,\n\n get metadata() {\n return { ...this._metadata };\n },\n\n description(description: string) {\n // Clone-on-write so a shared field instance never leaks metadata.\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ description }) as any;\n },\n\n typeName(typeName: string) {\n // Clone-on-write so a shared field instance never leaks metadata.\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ typeName }) as any;\n },\n\n validate(...validateInputs: FieldValidateInput<FieldOutput<OutputBase, TOptions>>[]) {\n // Clone-on-write so a shared field instance never leaks metadata.\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ validate: validateInputs }) as any;\n },\n\n parse(args: FieldParseArgs): StandardSchemaV1.Result<FieldOutput<OutputBase, TOptions>> {\n return parseInternal({\n value: args.value,\n data: args.data,\n user: args.user,\n pathArray: [],\n });\n },\n\n _parseInternal: parseInternal,\n\n clone() {\n // Deep clone nested object fields so the new instance shares no mutable state.\n let clonedFields = fields;\n if (fields) {\n const cloned: Record<string, TailorAnyField> = {};\n for (const [key, nestedField] of Object.entries(fields)) {\n // Both t.* and db.* fields carry clone() at runtime (see CloneableField).\n cloned[key] = (nestedField as TailorAnyField & CloneableField).clone();\n }\n clonedFields = cloned;\n }\n\n // Rebuild via the factory, handing it this field's metadata so the new\n // parseInternal/validateValue closures rebind to the clone and the factory\n // owns the metadata deep-copy.\n // oxlint-disable-next-line no-explicit-any\n return createTailorField(type, options, clonedFields, values, this._metadata) as any;\n },\n };\n\n return field;\n}\n\n/**\n * Create a UUID field for resolver input/output.\n * @param options - Field configuration options\n * @returns A UUID field\n * @example t.uuid()\n */\nfunction uuid<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"uuid\", options);\n}\n\n/**\n * Create a string field for resolver input/output.\n * @param options - Field configuration options\n * @returns A string field\n * @example t.string()\n * @example t.string({ optional: true })\n * @example t.string({ array: true })\n */\nfunction string<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"string\", options);\n}\n\n/**\n * Create a boolean field for resolver input/output.\n * @param options - Field configuration options\n * @returns A boolean field\n * @example t.bool()\n */\nfunction bool<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"boolean\", options);\n}\n\n/**\n * Create an integer field for resolver input/output.\n * @param options - Field configuration options\n * @returns An integer field\n * @example t.int()\n */\nfunction int<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"integer\", options);\n}\n\n/**\n * Create a float field for resolver input/output.\n * @param options - Field configuration options\n * @returns A float field\n * @example t.float()\n */\nfunction float<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"float\", options);\n}\n\n/**\n * Create a decimal field for resolver input/output (stored as string for precision).\n * @param options - Field configuration options\n * @returns A decimal field\n * @example t.decimal()\n * @example t.decimal({ optional: true })\n */\nfunction decimal<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"decimal\", options);\n}\n\n/**\n * Create a date field for resolver input/output.\n * @param options - Field configuration options\n * @returns A date field\n * @example t.date()\n */\nfunction date<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"date\", options);\n}\n\n/**\n * Create a datetime field for resolver input/output.\n * @param options - Field configuration options\n * @returns A datetime field\n * @example t.datetime()\n */\nfunction datetime<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"datetime\", options);\n}\n\n/**\n * Create a time field for resolver input/output.\n * @param options - Field configuration options\n * @returns A time field\n * @example t.time()\n */\nfunction time<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"time\", options);\n}\n\n/**\n * Create an enum field for resolver input/output.\n * @param values - Array of allowed string values\n * @param options - Field configuration options\n * @returns An enum field\n * @example t.enum([\"active\", \"inactive\"])\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 createTailorField<\"enum\", Opt, AllowedValuesOutput<V>>(\"enum\", options, undefined, values);\n}\n\n/**\n * Create a nested object field for resolver input/output.\n * @param fields - Record of field definitions\n * @param options - Field options (optional, array)\n * @returns A nested object field\n * @example\n * // Single object:\n * output: t.object({ name: t.string(), email: t.string() })\n * @example\n * // Array of objects:\n * items: t.object({ name: t.string() }, { array: true })\n */\nfunction object<const F extends Record<string, TailorAnyField>, const Opt extends FieldOptions>(\n fields: F,\n options?: Opt,\n) {\n const objectField = createTailorField(\"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 decimal,\n date,\n datetime,\n time,\n enum: _enum,\n object,\n};\n"],"mappings":";;;;AAoGA,MAAM,QAAQ;CACZ,MAAM;CACN,MAAM;CACN,MAAM;C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Q,OAAO;AAC1C;;;;;;;;;AAUA,SAAS,OAAuC,SAAe;CAC7D,OAAO,kBAAkB,UAAU,OAAO;AAC5C;;;;;;;AAQA,SAAS,KAAqC,SAAe;CAC3D,OAAO,kBAAkB,WAAW,OAAO;AAC7C;;;;;;;AAQA,SAAS,IAAoC,SAAe;CAC1D,OAAO,kBAAkB,WAAW,OAAO;AAC7C;;;;;;;AAQA,SAAS,MAAsC,SAAe;CAC5D,OAAO,kBAAkB,SAAS,OAAO;AAC3C;;;;;;;;AASA,SAAS,QAAwC,SAAe;CAC9D,OAAO,kBAAkB,WAAW,OAAO;AAC7C;;;;;;;AAQA,SAAS,KAAqC,SAAe;CAC3D,OAAO,kBAAkB,QAAQ,OAAO;AAC1C;;;;;;;AAQA,SAAS,SAAyC,SAAe;CAC/D,OAAO,kBAAkB,YAAY,OAAO;AAC9C;;;;;;;AAQA,SAAS,KAAqC,SAAe;CAC3D,OAAO,kBAAkB,QAAQ,OAAO;AAC1C;;;;;;;;AASA,SAAS,MACP,QACA,SAIA;CACA,OAAO,kBAAuD,QAAQ,SAAS,QAAW,MAAM;AAClG;;;;;;;;;;;;;AAcA,SAAS,OACP,QACA,SACA;CAKA,OAJoB,kBAAkB,UAAU,SAAS,MAIxC;AACnB;AAEA,MAAa,IAAI;CACf;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,MAAM;CACN;AACF"}
1
+ {"version":3,"file":"types-CmzfQP_m.mjs","names":[],"sources":["../src/configure/types/type.ts"],"sourcesContent":["import { type AllowedValues, type AllowedValuesOutput, mapAllowedValues } from \"./field\";\nimport type {\n DefinedFieldMetadata,\n TailorFieldType,\n TailorToTs,\n FieldMetadata,\n FieldOptions,\n FieldOutput,\n TailorField as TailorFieldBase,\n FieldValidateInput,\n} from \"@/configure/types/field.types\";\nimport type { TailorUser } from \"@/runtime/types\";\nimport type { InferFieldsOutput, Prettify } from \"@/types/helpers\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\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\n/**\n * Full TailorField interface with builder methods.\n * Extends the minimal structural interface from types/ with fluent API methods.\n */\nexport interface TailorField<\n 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 Output = any,\n M extends FieldMetadata = FieldMetadata,\n T extends TailorFieldType = TailorFieldType,\n> extends TailorFieldBase<Defined, Output, M, T> {\n readonly fields: Record<string, TailorAnyField>;\n _metadata: M;\n\n /**\n * Set a description for the field\n * @param description - The description text\n * @returns The field with updated metadata\n */\n description<CurrentDefined extends Defined>(\n this: CurrentDefined extends { description: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n description: string,\n ): TailorField<Prettify<CurrentDefined & { description: true }>, Output>;\n\n /**\n * Set a custom type name for enum or nested types\n * @param typeName - The custom type name\n * @returns The field with updated metadata\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 ): TailorField<Prettify<CurrentDefined & { typeName: true }>, Output>;\n\n /**\n * Add validation functions to the field\n * @param validate - One or more validation functions\n * @returns The field with updated metadata\n */\n validate<CurrentDefined extends Defined>(\n this: CurrentDefined extends { validate: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n ...validate: FieldValidateInput<Output>[]\n ): TailorField<Prettify<CurrentDefined & { validate: true }>, Output>;\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 args - Value, context data, and user\n * @returns Validation result\n */\n parse(args: FieldParseArgs): StandardSchemaV1.Result<Output>;\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @private\n * @param args - Parse arguments\n * @returns Validation result\n */\n _parseInternal(args: FieldParseInternalArgs): StandardSchemaV1.Result<Output>;\n}\n\n/**\n * Internal shape carried by every runtime field for clone-on-write support.\n *\n * `clone()` is intentionally kept off the public {@link TailorField} interface:\n * adding it there would force `TailorDBField` (which has a differently-typed\n * `clone`) to stop being assignable to `TailorField`, breaking the supported\n * `t.object({ field: db.string() })` usage. Every `t.*` and `db.*` field carries\n * a `clone()` at runtime, so the internal cast in `clone()` is safe.\n */\ntype CloneableField = { clone(): TailorAnyField };\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 decimal: /^-?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?$/,\n} as const;\n\ntype FieldParseArgs = {\n value: unknown;\n data: unknown;\n user: TailorUser;\n};\n\ntype FieldValidateValueArgs<T extends TailorFieldType> = {\n value: TailorToTs[T];\n data: unknown;\n user: TailorUser;\n pathArray: string[];\n};\n\ntype FieldParseInternalArgs = {\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};\n\n/**\n * Creates a new TailorField instance.\n * @param type - Field type\n * @param options - Field options\n * @param fields - Nested fields for object-like types\n * @param values - Allowed values for enum-like fields\n * @param metadata - Pre-built metadata to clone from (used by `clone()`); when\n * given, the mutable containers are deep-copied here and `options`/`values` are\n * ignored for metadata construction\n * @returns A new TailorField\n */\nfunction createTailorField<\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, TailorAnyField>,\n values?: AllowedValues,\n metadata?: FieldMetadata,\n): TailorField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n> {\n // When cloning, take ownership of the source metadata and deep-copy its mutable\n // containers (enum value objects and `[fn, message]` validator tuples; validator\n // functions are kept by reference) so no two instances share mutable state.\n const _metadata: FieldMetadata = metadata\n ? {\n ...metadata,\n ...(metadata.allowedValues && {\n allowedValues: metadata.allowedValues.map((v) => ({ ...v })),\n }),\n ...(metadata.validate && {\n validate: metadata.validate.map((v) => (Array.isArray(v) ? ([...v] as typeof v) : v)),\n }),\n }\n : { required: true };\n\n if (!metadata) {\n if (options) {\n if (options.optional === true) {\n _metadata.required = false;\n }\n if (options.array === true) {\n _metadata.array = true;\n }\n }\n if (values) {\n _metadata.allowedValues = mapAllowedValues(values);\n }\n }\n\n /**\n * Validate a single value (not an array element)\n * Used internally for array element validation\n * @param args - Value, context data, and user\n * @returns Array of validation issues\n */\n function validateValue(args: FieldValidateValueArgs<T>): StandardSchemaV1.Issue[] {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n const path = pathArray.length > 0 ? pathArray : undefined;\n\n // Type-specific validation\n switch (type) {\n case \"string\":\n if (typeof value !== \"string\") {\n issues.push({\n message: `Expected a string: received ${String(value)}`,\n path,\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,\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,\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,\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,\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,\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,\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,\n });\n }\n break;\n case \"decimal\":\n if (typeof value !== \"string\" || !regex.decimal.test(value)) {\n issues.push({\n message: `Expected a decimal string: received ${String(value)}`,\n path,\n });\n }\n break;\n\n case \"enum\":\n if (field._metadata.allowedValues) {\n const allowedValues = field._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,\n });\n }\n }\n break;\n\n case \"nested\":\n // Validate nested object fields\n // runtime value may not match the declared type\n // oxlint-disable typescript/no-unnecessary-condition\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n value instanceof Date\n ) {\n // oxlint-enable typescript/no-unnecessary-condition\n issues.push({\n message: `Expected an object: received ${String(value)}`,\n path,\n });\n } else if (Object.keys(field.fields).length > 0) {\n for (const [fieldName, nestedField] of Object.entries(field.fields)) {\n const fieldValue = (value as Record<string, unknown>)[fieldName];\n const result = nestedField._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 = field._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,\n });\n }\n }\n }\n\n return issues;\n }\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @param args - Parse arguments\n * @returns Parse result with value or issues\n */\n function parseInternal(\n args: FieldParseInternalArgs,\n ): StandardSchemaV1.Result<FieldOutput<OutputBase, TOptions>> {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n const path = pathArray.length > 0 ? pathArray : undefined;\n\n // 1. Check required/optional\n const isNullOrUndefined = value === null || value === undefined;\n if (field._metadata.required && isNullOrUndefined) {\n issues.push({\n message: \"Required field is missing\",\n path,\n });\n return { issues };\n }\n\n // If optional and null/undefined, skip further validation and normalize to null\n if (!field._metadata.required && isNullOrUndefined) {\n return { value: value ?? null };\n }\n\n // 2. Check array type\n if (field._metadata.array) {\n if (!Array.isArray(value)) {\n issues.push({\n message: \"Expected an array\",\n path,\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 = 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 FieldOutput<OutputBase, TOptions> };\n }\n\n // 3. Type-specific validation and custom validation\n const valueIssues = 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 /**\n * Clone the field and apply metadata updates to the clone.\n * The original instance is never mutated, so a field shared across places\n * cannot leak metadata between them.\n * @param metadataUpdates - Metadata properties to overwrite on the clone\n * @returns A new field with the updated metadata\n */\n function cloneWith(metadataUpdates: Partial<FieldMetadata>) {\n const cloned = field.clone();\n Object.assign(cloned._metadata, metadataUpdates);\n return cloned;\n }\n\n const field: TailorField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n > &\n CloneableField = {\n type,\n fields: fields ?? {},\n _defined: undefined as unknown as {\n type: T;\n array: TOptions extends { array: true } ? true : false;\n },\n _output: undefined as FieldOutput<OutputBase, TOptions>,\n _metadata,\n\n get metadata() {\n return { ...this._metadata };\n },\n\n description(description: string) {\n // Clone-on-write so a shared field instance never leaks metadata.\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ description }) as any;\n },\n\n typeName(typeName: string) {\n // Clone-on-write so a shared field instance never leaks metadata.\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ typeName }) as any;\n },\n\n validate(...validateInputs: FieldValidateInput<FieldOutput<OutputBase, TOptions>>[]) {\n // Clone-on-write so a shared field instance never leaks metadata.\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ validate: validateInputs }) as any;\n },\n\n parse(args: FieldParseArgs): StandardSchemaV1.Result<FieldOutput<OutputBase, TOptions>> {\n return parseInternal({\n value: args.value,\n data: args.data,\n user: args.user,\n pathArray: [],\n });\n },\n\n _parseInternal: parseInternal,\n\n clone() {\n // Deep clone nested object fields so the new instance shares no mutable state.\n let clonedFields = fields;\n if (fields) {\n const cloned: Record<string, TailorAnyField> = {};\n for (const [key, nestedField] of Object.entries(fields)) {\n // Both t.* and db.* fields carry clone() at runtime (see CloneableField).\n cloned[key] = (nestedField as TailorAnyField & CloneableField).clone();\n }\n clonedFields = cloned;\n }\n\n // Rebuild via the factory, handing it this field's metadata so the new\n // parseInternal/validateValue closures rebind to the clone and the factory\n // owns the metadata deep-copy.\n // oxlint-disable-next-line no-explicit-any\n return createTailorField(type, options, clonedFields, values, this._metadata) as any;\n },\n };\n\n return field;\n}\n\n/**\n * Create a UUID field for resolver input/output.\n * @param options - Field configuration options\n * @returns A UUID field\n * @example t.uuid()\n */\nfunction uuid<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"uuid\", options);\n}\n\n/**\n * Create a string field for resolver input/output.\n * @param options - Field configuration options\n * @returns A string field\n * @example t.string()\n * @example t.string({ optional: true })\n * @example t.string({ array: true })\n */\nfunction string<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"string\", options);\n}\n\n/**\n * Create a boolean field for resolver input/output.\n * @param options - Field configuration options\n * @returns A boolean field\n * @example t.bool()\n */\nfunction bool<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"boolean\", options);\n}\n\n/**\n * Create an integer field for resolver input/output.\n * @param options - Field configuration options\n * @returns An integer field\n * @example t.int()\n */\nfunction int<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"integer\", options);\n}\n\n/**\n * Create a float field for resolver input/output.\n * @param options - Field configuration options\n * @returns A float field\n * @example t.float()\n */\nfunction float<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"float\", options);\n}\n\n/**\n * Create a decimal field for resolver input/output (stored as string for precision).\n * @param options - Field configuration options\n * @returns A decimal field\n * @example t.decimal()\n * @example t.decimal({ optional: true })\n */\nfunction decimal<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"decimal\", options);\n}\n\n/**\n * Create a date field for resolver input/output.\n * @param options - Field configuration options\n * @returns A date field\n * @example t.date()\n */\nfunction date<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"date\", options);\n}\n\n/**\n * Create a datetime field for resolver input/output.\n * @param options - Field configuration options\n * @returns A datetime field\n * @example t.datetime()\n */\nfunction datetime<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"datetime\", options);\n}\n\n/**\n * Create a time field for resolver input/output.\n * @param options - Field configuration options\n * @returns A time field\n * @example t.time()\n */\nfunction time<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"time\", options);\n}\n\n/**\n * Create an enum field for resolver input/output.\n * @param values - Array of allowed string values\n * @param options - Field configuration options\n * @returns An enum field\n * @example t.enum([\"active\", \"inactive\"])\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 createTailorField<\"enum\", Opt, AllowedValuesOutput<V>>(\"enum\", options, undefined, values);\n}\n\n/**\n * Create a nested object field for resolver input/output.\n * @param fields - Record of field definitions\n * @param options - Field options (optional, array)\n * @returns A nested object field\n * @example\n * // Single object:\n * output: t.object({ name: t.string(), email: t.string() })\n * @example\n * // Array of objects:\n * items: t.object({ name: t.string() }, { array: true })\n */\nfunction object<const F extends Record<string, TailorAnyField>, const Opt extends FieldOptions>(\n fields: F,\n options?: Opt,\n) {\n const objectField = createTailorField(\"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 decimal,\n date,\n datetime,\n time,\n enum: _enum,\n object,\n};\n"],"mappings":";;;;AAoGA,MAAM,QAAQ;CACZ,MAAM;CACN,MAAM;CACN,MAAM;CACN,UACE;CACF,SAAS;AACX;;;;;;;;;;;;AAmCA,SAAS,kBAKP,MACA,SACA,QACA,QACA,UAIA;CAIA,MAAM,YAA2B,WAC7B;EACE,GAAG;EACH,GAAI,SAAS,iBAAiB,EAC5B,eAAe,SAAS,cAAc,KAAK,OAAO,EAAE,GAAG,EAAE,EAAE,EAC7D;EACA,GAAI,SAAS,YAAY,EACvB,UAAU,SAAS,SAAS,KAAK,MAAO,MAAM,QAAQ,CAAC,IAAK,CAAC,GAAG,CAAC,IAAiB,CAAE,EACtF;CACF,IACA,EAAE,UAAU,KAAK;CAErB,IAAI,CAAC,UAAU;EACb,IAAI,SAAS;GACX,IAAI,QAAQ,aAAa,MACvB,UAAU,WAAW;GAEvB,IAAI,QAAQ,UAAU,MACpB,UAAU,QAAQ;EAEtB;EACA,IAAI,QACF,UAAU,gBAAgB,iBAAiB,MAAM;CAErD;;;;;;;CAQA,SAAS,cAAc,MAA2D;EAChF,MAAM,EAAE,OAAO,MAAM,MAAM,cAAc;EACzC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ACP,QACA,SAIA;CACA,OAAO,kBAAuD,QAAQ,SAAS,QAAW,MAAM;AAClG;;;;;;;;;;;;;AAcA,SAAS,OACP,QACA,SACA;CAKA,OAJoB,kBAAkB,UAAU,SAAS,MAIxC;AACnB;AAEA,MAAa,IAAI;CACf;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,MAAM;CACN;AACF"}
@@ -0,0 +1,74 @@
1
+ //#region src/runtime/types.d.ts
2
+ interface AttributeMap {}
3
+ interface AttributeList {
4
+ __tuple?: [];
5
+ }
6
+ type InferredAttributeMap = keyof AttributeMap extends never ? Record<string, string | string[] | boolean | boolean[] | undefined> : AttributeMap;
7
+ type InferredAttributeList = AttributeList["__tuple"] extends [] ? string[] : AttributeList["__tuple"];
8
+ /** Represents a user in the Tailor platform. */
9
+ type TailorUser = {
10
+ /**
11
+ * The ID of the user.
12
+ * For unauthenticated users, this will be a nil UUID.
13
+ */
14
+ id: string;
15
+ /**
16
+ * The type of the user.
17
+ * For unauthenticated users, this will be an empty string.
18
+ */
19
+ type: "user" | "machine_user" | ""; /** The ID of the workspace the user belongs to. */
20
+ workspaceId: string;
21
+ /**
22
+ * A map of the user's attributes.
23
+ * For unauthenticated users, this will be null.
24
+ */
25
+ attributes: InferredAttributeMap | null;
26
+ /**
27
+ * A list of the user's attributes.
28
+ * For unauthenticated users, this will be an empty array.
29
+ */
30
+ attributeList: InferredAttributeList;
31
+ };
32
+ /**
33
+ * The invoker of the current function execution.
34
+ *
35
+ * Reflects `authInvoker` delegation: when `authInvoker` is specified, this is
36
+ * the machine user; otherwise it is the calling user.
37
+ * Distinct from resolver's `user` (the authenticated caller) and executor's
38
+ * `actor` (the subject of the event).
39
+ *
40
+ * `null` for anonymous requests.
41
+ *
42
+ * TODO(v2): unify with `TailorUser` — same underlying principal shape.
43
+ */
44
+ type TailorInvoker = {
45
+ /** The ID of the invoker (user ID or machine user ID). */id: string; /** The type of the invoker. */
46
+ type: "user" | "machine_user"; /** The ID of the workspace the invoker belongs to. */
47
+ workspaceId: string; /** A map of the invoker's attributes. */
48
+ attributes: InferredAttributeMap; /** A list of the invoker's attribute IDs. */
49
+ attributeList: InferredAttributeList;
50
+ } | null;
51
+ /** User type enum values from the Tailor Platform server. */
52
+ type TailorActorType = "USER_TYPE_USER" | "USER_TYPE_MACHINE_USER" | "USER_TYPE_UNSPECIFIED";
53
+ /** Represents an actor in event triggers. */
54
+ type TailorActor = {
55
+ /** The ID of the workspace the user belongs to. */workspaceId: string; /** The ID of the user. */
56
+ userId: string;
57
+ /**
58
+ * A map of the user's attributes.
59
+ * Maps from server's `attributeMap` field.
60
+ */
61
+ attributes: InferredAttributeMap | null;
62
+ /**
63
+ * A list of the user's attributes.
64
+ * Maps from server's `attributes` field.
65
+ */
66
+ attributeList: InferredAttributeList; /** The type of the user. */
67
+ userType: TailorActorType;
68
+ };
69
+ interface Env {}
70
+ /** Represents environment variables in the Tailor platform. */
71
+ type TailorEnv = keyof Env extends never ? Record<string, string | number | boolean> : Env;
72
+ //#endregion
73
+ export { TailorActor as a, TailorUser as c, InferredAttributeMap as i, AttributeMap as n, TailorEnv as o, Env as r, TailorInvoker as s, AttributeList as t };
74
+ //# sourceMappingURL=types-DTcZ2Yax.d.mts.map
@@ -1,3 +1,4 @@
1
+ import { c as TailorUser, i as InferredAttributeMap } from "./types-DTcZ2Yax.mjs";
1
2
  import { NonEmptyObject } from "type-fest";
2
3
 
3
4
  //#region src/types/helpers.d.ts
@@ -35,60 +36,50 @@ type JsonCompatible<T> = T extends string | number | boolean | null | undefined
35
36
  toJSON: () => unknown;
36
37
  } ? never : { [K in keyof T]: JsonCompatible<T[K]> } : never;
37
38
  //#endregion
38
- //#region src/types/user.d.ts
39
- interface AttributeMap {}
40
- interface AttributeList {
41
- __tuple?: [];
39
+ //#region src/configure/types/field.types.d.ts
40
+ interface EnumValue {
41
+ value: string;
42
+ description?: string;
42
43
  }
43
- type InferredAttributeMap = keyof AttributeMap extends never ? Record<string, string | string[] | boolean | boolean[] | undefined> : AttributeMap;
44
- type InferredAttributeList = AttributeList["__tuple"] extends [] ? string[] : AttributeList["__tuple"];
45
- /** Represents a user in the Tailor platform. */
46
- type TailorUser = {
47
- /**
48
- * The ID of the user.
49
- * For unauthenticated users, this will be a nil UUID.
50
- */
51
- id: string;
52
- /**
53
- * The type of the user.
54
- * For unauthenticated users, this will be an empty string.
55
- */
56
- type: "user" | "machine_user" | ""; /** The ID of the workspace the user belongs to. */
57
- workspaceId: string;
58
- /**
59
- * A map of the user's attributes.
60
- * For unauthenticated users, this will be null.
61
- */
62
- attributes: InferredAttributeMap | null;
63
- /**
64
- * A list of the user's attributes.
65
- * For unauthenticated users, this will be an empty array.
66
- */
67
- attributeList: InferredAttributeList;
44
+ type TailorFieldType = "uuid" | "string" | "boolean" | "integer" | "float" | "decimal" | "enum" | "date" | "datetime" | "time" | "nested";
45
+ type TailorToTs = {
46
+ string: string;
47
+ integer: number;
48
+ float: number;
49
+ decimal: string;
50
+ boolean: boolean;
51
+ uuid: string;
52
+ date: string;
53
+ datetime: string | Date;
54
+ time: string;
55
+ enum: string;
56
+ object: Record<string, unknown>;
57
+ nested: Record<string, unknown>;
58
+ } & Record<TailorFieldType, unknown>;
59
+ interface FieldMetadata {
60
+ description?: string;
61
+ required?: boolean;
62
+ array?: boolean;
63
+ allowedValues?: EnumValue[];
64
+ validate?: FieldValidateInput<any>[];
65
+ typeName?: string;
66
+ }
67
+ interface DefinedFieldMetadata {
68
+ type: TailorFieldType;
69
+ array: boolean;
70
+ description?: boolean;
71
+ validate?: boolean;
72
+ typeName?: boolean;
73
+ }
74
+ type FieldOptions = {
75
+ optional?: boolean;
76
+ array?: boolean;
68
77
  };
69
- /** Represents an unauthenticated user in the Tailor platform. */
70
- declare const unauthenticatedTailorUser: TailorUser;
71
- /**
72
- * The invoker of the current function execution.
73
- *
74
- * Reflects `authInvoker` delegation: when `authInvoker` is specified, this is
75
- * the machine user; otherwise it is the calling user.
76
- * Distinct from resolver's `user` (the authenticated caller) and executor's
77
- * `actor` (the subject of the event).
78
- *
79
- * `null` for anonymous requests.
80
- *
81
- * TODO(v2): unify with `TailorUser` — same underlying principal shape.
82
- */
83
- type TailorInvoker = {
84
- /** The ID of the invoker (user ID or machine user ID). */id: string; /** The type of the invoker. */
85
- type: "user" | "machine_user"; /** The ID of the workspace the invoker belongs to. */
86
- workspaceId: string; /** A map of the invoker's attributes. */
87
- attributes: InferredAttributeMap; /** A list of the invoker's attribute IDs. */
88
- attributeList: InferredAttributeList;
89
- } | null;
90
- //#endregion
91
- //#region src/types/validation.d.ts
78
+ type FieldOutput<T, O extends FieldOptions> = OptionalFieldOutput<ArrayFieldOutput<T, O>, O>;
79
+ type OptionalFieldOutput<T, O extends FieldOptions> = O["optional"] extends true ? T | null : T;
80
+ type ArrayFieldOutput<T, O extends FieldOptions> = [O] extends [{
81
+ array: true;
82
+ }] ? T[] : T;
92
83
  /**
93
84
  * Validation function type
94
85
  */
@@ -134,62 +125,6 @@ type Validators<F extends Record<string, {
134
125
  _output: any;
135
126
  [key: string]: any;
136
127
  }>> = ValidatorsBase<F, "id">;
137
- //#endregion
138
- //#region src/types/field-types.d.ts
139
- interface EnumValue {
140
- value: string;
141
- description?: string;
142
- }
143
- type TailorFieldType = "uuid" | "string" | "boolean" | "integer" | "float" | "decimal" | "enum" | "date" | "datetime" | "time" | "nested";
144
- type TailorToTs = {
145
- string: string;
146
- integer: number;
147
- float: number;
148
- decimal: string;
149
- boolean: boolean;
150
- uuid: string;
151
- date: string;
152
- datetime: string | Date;
153
- time: string;
154
- enum: string;
155
- object: Record<string, unknown>;
156
- nested: Record<string, unknown>;
157
- } & Record<TailorFieldType, unknown>;
158
- interface FieldMetadata {
159
- description?: string;
160
- required?: boolean;
161
- array?: boolean;
162
- allowedValues?: EnumValue[];
163
- validate?: FieldValidateInput<any>[];
164
- typeName?: string;
165
- }
166
- interface DefinedFieldMetadata {
167
- type: TailorFieldType;
168
- array: boolean;
169
- description?: boolean;
170
- validate?: boolean;
171
- typeName?: boolean;
172
- }
173
- type FieldOptions = {
174
- optional?: boolean;
175
- array?: boolean;
176
- };
177
- type FieldOutput<T, O extends FieldOptions> = OptionalFieldOutput<ArrayFieldOutput<T, O>, O>;
178
- type OptionalFieldOutput<T, O extends FieldOptions> = O["optional"] extends true ? T | null : T;
179
- type ArrayFieldOutput<T, O extends FieldOptions> = [O] extends [{
180
- array: true;
181
- }] ? T[] : T;
182
- //#endregion
183
- //#region src/types/plugin-attachment.d.ts
184
- /**
185
- * Plugin attachment stored on TailorAnyDBType instances.
186
- */
187
- interface PluginAttachment {
188
- pluginId: string;
189
- config: unknown;
190
- }
191
- //#endregion
192
- //#region src/types/tailor-field.d.ts
193
128
  /**
194
129
  * Minimal structural interface for TailorField.
195
130
  * Defines only the properties needed by parser, plugin, cli, and types layers.
@@ -632,7 +567,7 @@ type TailorDBServiceConfigInput = {
632
567
  } | undefined;
633
568
  };
634
569
  //#endregion
635
- //#region src/types/tailordb-metadata.d.ts
570
+ //#region src/configure/services/tailordb/types.d.ts
636
571
  type SerialConfig<T extends "string" | "integer" = "string" | "integer"> = Prettify<{
637
572
  start: number;
638
573
  maxValue?: number;
@@ -693,8 +628,6 @@ interface TailorDBTypeMetadata {
693
628
  unique?: boolean;
694
629
  }>;
695
630
  }
696
- //#endregion
697
- //#region src/types/tailor-db-field.d.ts
698
631
  /**
699
632
  * Minimal structural interface for TailorDBField.
700
633
  * Defines only the properties needed by parser, plugin, cli, and types layers.
@@ -712,20 +645,55 @@ type TailorAnyDBField = TailorDBField<any, any>;
712
645
  * The full interface with builder methods (hooks, validate, features, permission, etc.)
713
646
  * is defined in configure/services/tailordb/schema.ts.
714
647
  */
715
- interface TailorDBType$1<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributeMap> {
648
+ interface TailorDBType<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributeMap> {
716
649
  readonly name: string;
717
650
  readonly fields: Fields;
718
651
  readonly _output: InferFieldsOutput<Fields>;
719
652
  readonly metadata: TailorDBTypeMetadata;
720
653
  readonly plugins: PluginAttachment[];
721
654
  }
722
- type TailorAnyDBType = TailorDBType$1<any, any>;
723
- type TailorDBInstance<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributeMap> = TailorDBType$1<Fields, User>;
724
- //#endregion
725
- //#region src/types/auth-value.d.ts
726
- type ValueOperand = string | boolean | string[] | boolean[];
727
- //#endregion
728
- //#region src/types/tailordb.d.ts
655
+ type TailorAnyDBType = TailorDBType<any, any>;
656
+ type TailorDBInstance<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributeMap> = TailorDBType<Fields, User>;
657
+ type HookFn<TValue, TData, TReturn> = (args: {
658
+ value: TValue;
659
+ data: TData extends Record<string, unknown> ? { readonly [K in keyof TData]?: TData[K] | null | undefined } : unknown;
660
+ user: TailorUser;
661
+ }) => TReturn;
662
+ type Hook<TData, TReturn> = {
663
+ create?: HookFn<TReturn | null, TData, TReturn>;
664
+ update?: HookFn<TReturn | null, TData, TReturn>;
665
+ };
666
+ 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 {
667
+ hooks: unknown;
668
+ } ? never : F[K]["_defined"] extends {
669
+ type: "nested";
670
+ } ? never : K]?: Hook<TData, output<F[K]>> }>;
671
+ type ExcludeNestedDBFields<T extends Record<string, TailorAnyDBField>> = { [K in keyof T]: T[K] extends TailorDBField<{
672
+ type: "nested";
673
+ array: boolean;
674
+ }, any> ? never : T[K] };
675
+ interface TypeFeatures {
676
+ pluralForm?: string;
677
+ aggregation?: true;
678
+ bulkUpsert?: true;
679
+ /** Configure GraphQL operations for this type. Use "query" for read-only mode, or an object for granular control. */
680
+ gqlOperations?: GqlOperationsConfig;
681
+ /**
682
+ * Enable publishing events for this type.
683
+ * When enabled, record creation/update/deletion events are published.
684
+ * If not specified, this is automatically set to true when an executor uses this type
685
+ * with recordCreated/recordUpdated/recordDeleted triggers. If explicitly set to false
686
+ * while an executor uses this type, an error will be thrown during apply.
687
+ */
688
+ publishEvents?: boolean;
689
+ }
690
+ /**
691
+ * Plugin attachment stored on TailorAnyDBType instances.
692
+ */
693
+ interface PluginAttachment {
694
+ pluginId: string;
695
+ config: unknown;
696
+ }
729
697
  type IndexDef<T extends {
730
698
  fields: Record<PropertyKey, unknown>;
731
699
  }> = {
@@ -740,124 +708,6 @@ type TailorDBExternalConfig = {
740
708
  type TailorDBServiceInput = {
741
709
  [namespace: string]: TailorDBServiceConfigInput | TailorDBExternalConfig;
742
710
  };
743
- interface UserDefinedTypeSource {
744
- filePath: string;
745
- exportName: string;
746
- pluginId?: never;
747
- }
748
- interface PluginGeneratedTypeSource {
749
- filePath?: never;
750
- exportName: string;
751
- pluginId: string;
752
- pluginImportPath: string;
753
- originalFilePath: string;
754
- originalExportName: string;
755
- generatedTypeKind?: string;
756
- pluginConfig?: unknown;
757
- namespace?: string;
758
- }
759
- type TypeSourceInfoEntry = UserDefinedTypeSource | PluginGeneratedTypeSource;
760
- interface Script {
761
- expr: string;
762
- }
763
- interface OperatorValidateConfig {
764
- script: Script;
765
- errorMessage: string;
766
- }
767
- interface OperatorFieldHook {
768
- create?: Script;
769
- update?: Script;
770
- }
771
- interface OperatorFieldConfig {
772
- type: string;
773
- required?: boolean;
774
- description?: string;
775
- allowedValues?: EnumValue[];
776
- array?: boolean;
777
- index?: boolean;
778
- unique?: boolean;
779
- vector?: boolean;
780
- foreignKey?: boolean;
781
- foreignKeyType?: string;
782
- foreignKeyField?: string;
783
- rawRelation?: RawRelationConfig;
784
- validate?: OperatorValidateConfig[];
785
- hooks?: OperatorFieldHook;
786
- serial?: {
787
- start: number;
788
- maxValue?: number;
789
- format?: string;
790
- };
791
- scale?: number;
792
- fields?: Record<string, OperatorFieldConfig>;
793
- }
794
- type GqlPermissionAction = "read" | "create" | "update" | "delete" | "aggregate" | "bulkUpsert";
795
- type StandardPermissionOperator = "eq" | "ne" | "in" | "nin" | "hasAny" | "nhasAny";
796
- type UserOperand = {
797
- user: string;
798
- };
799
- type StandardRecordOperand<Update extends boolean = false> = Update extends true ? {
800
- oldRecord: string;
801
- } | {
802
- newRecord: string;
803
- } : {
804
- record: string;
805
- };
806
- type PermissionOperand<Level extends "record" | "gql" = "record" | "gql", Update extends boolean = boolean> = UserOperand | ValueOperand | (Level extends "record" ? StandardRecordOperand<Update> : never);
807
- type StandardPermissionCondition<Level extends "record" | "gql" = "record" | "gql", Update extends boolean = boolean> = readonly [PermissionOperand<Level, Update>, StandardPermissionOperator, PermissionOperand<Level, Update>];
808
- type StandardActionPermission<Level extends "record" | "gql" = "record" | "gql", Update extends boolean = boolean> = {
809
- conditions: readonly StandardPermissionCondition<Level, Update>[];
810
- description?: string;
811
- permit: "allow" | "deny";
812
- };
813
- type StandardTailorTypePermission = {
814
- create: readonly StandardActionPermission<"record", false>[];
815
- read: readonly StandardActionPermission<"record", false>[];
816
- update: readonly StandardActionPermission<"record", true>[];
817
- delete: readonly StandardActionPermission<"record", false>[];
818
- };
819
- type StandardGqlPermissionPolicy = {
820
- conditions: readonly StandardPermissionCondition<"gql">[];
821
- actions: readonly ["all"] | readonly GqlPermissionAction[];
822
- permit: "allow" | "deny";
823
- description?: string;
824
- };
825
- type StandardTailorTypeGqlPermission = readonly StandardGqlPermissionPolicy[];
826
- interface Permissions {
827
- record?: StandardTailorTypePermission;
828
- gql?: StandardTailorTypeGqlPermission;
829
- }
830
- interface ParsedField {
831
- name: string;
832
- config: OperatorFieldConfig;
833
- relation?: {
834
- targetType: string;
835
- forwardName: string;
836
- backwardName: string;
837
- key: string;
838
- unique: boolean;
839
- };
840
- }
841
- interface ParsedRelationship {
842
- name: string;
843
- targetType: string;
844
- targetField: string;
845
- sourceField: string;
846
- isArray: boolean;
847
- description: string;
848
- }
849
- interface TailorDBType {
850
- name: string;
851
- pluralForm: string;
852
- description?: string;
853
- fields: Record<string, ParsedField>;
854
- forwardRelationships: Record<string, ParsedRelationship>;
855
- backwardRelationships: Record<string, ParsedRelationship>;
856
- settings: TailorDBTypeParsedSettings;
857
- permissions: Permissions;
858
- indexes?: TailorDBTypeMetadata["indexes"];
859
- files?: TailorDBTypeMetadata["files"];
860
- }
861
711
  //#endregion
862
- export { InferredAttributeList as A, FieldOutput as C, Validators as D, FieldValidateInput as E, InferFieldsOutput as F, JsonCompatible as I, JsonValue$1 as L, TailorInvoker as M, TailorUser as N, AttributeList as O, unauthenticatedTailorUser as P, Prettify as R, FieldOptions as S, TailorToTs as T, PluginAttachment as _, TypeSourceInfoEntry as a, EnumValue as b, TailorAnyDBType as c, TailorDBType$1 as d, DBFieldMetadata as f, TailorField as g, SerialConfig as h, TailorDBType as i, InferredAttributeMap as j, AttributeMap as k, TailorDBField as l, GqlOperationsConfig as m, RelationType as n, ValueOperand as o, DefinedDBFieldMetadata as p, TailorDBServiceInput as r, TailorAnyDBField as s, IndexDef as t, TailorDBInstance as u, ArrayFieldOutput as v, TailorFieldType as w, FieldMetadata as x, DefinedFieldMetadata as y, output as z };
863
- //# sourceMappingURL=tailordb-C-ar4XCX.d.mts.map
712
+ export { Validators as A, FieldMetadata as C, TailorField as D, FieldValidateInput as E, output as F, JsonCompatible as M, JsonValue$1 as N, TailorFieldType as O, Prettify as P, EnumValue as S, FieldOutput as T, TailorDBTypeMetadata as _, Hooks as a, ArrayFieldOutput as b, RawRelationConfig as c, TailorAnyDBField as d, TailorAnyDBType as f, TailorDBType as g, TailorDBServiceInput as h, Hook as i, InferFieldsOutput as j, TailorToTs as k, RelationType as l, TailorDBInstance as m, DefinedDBFieldMetadata as n, IndexDef as o, TailorDBField as p, ExcludeNestedDBFields as r, PluginAttachment as s, DBFieldMetadata as t, SerialConfig as u, TypeFeatures as v, FieldOptions as w, DefinedFieldMetadata as x, TailorDBTypeParsedSettings as y };
713
+ //# sourceMappingURL=types-DZrtN6-H.d.mts.map
@@ -1,6 +1,6 @@
1
- import { M as TailorInvoker } from "../../tailordb-C-ar4XCX.mjs";
2
- import { Z as TailorDBType } from "../../workflow.generated--1Qc15Et.mjs";
3
- import { jt as TailorField, n as output, wt as WORKFLOW_TEST_ENV_KEY } from "../../index-BdLqzJDu.mjs";
1
+ import { s as TailorInvoker } from "../../types-DTcZ2Yax.mjs";
2
+ import { j as TailorDBType } from "../../workflow.generated-1S50BhEb.mjs";
3
+ import { Mt as TailorField, n as output, wt as WORKFLOW_TEST_ENV_KEY } from "../../index-DvEUb3pX.mjs";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
5
 
6
6
  //#region src/utils/test/mock.d.ts