@wildo-ai/zod-decorators 1.1.7 → 1.1.9

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 (55) hide show
  1. package/dist/esm/commons.d.ts.map +1 -1
  2. package/dist/esm/commons.js.map +1 -1
  3. package/dist/esm/currencies.shared.schemas.d.ts.map +1 -1
  4. package/dist/esm/currencies.shared.schemas.js.map +1 -1
  5. package/dist/esm/files/agent-file-formats.d.ts.map +1 -1
  6. package/dist/esm/files/agent-file-formats.js.map +1 -1
  7. package/dist/esm/files/extension-nature-map.d.ts.map +1 -1
  8. package/dist/esm/files/extension-nature-map.js.map +1 -1
  9. package/dist/esm/files/file-extensions.enum.d.ts.map +1 -1
  10. package/dist/esm/files/file-extensions.enum.js.map +1 -1
  11. package/dist/esm/files/mime-registry.d.ts.map +1 -1
  12. package/dist/esm/files/mime-registry.js.map +1 -1
  13. package/dist/esm/files/unified-registry.d.ts.map +1 -1
  14. package/dist/esm/files/unified-registry.js.map +1 -1
  15. package/dist/esm/index.d.ts.map +1 -1
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/install-bigint-json-encoding.d.ts.map +1 -1
  18. package/dist/esm/install-bigint-json-encoding.js.map +1 -1
  19. package/dist/esm/testing/decorated-test-schemas.d.ts.map +1 -1
  20. package/dist/esm/testing/decorated-test-schemas.js.map +1 -1
  21. package/dist/esm/testing.d.ts.map +1 -1
  22. package/dist/esm/testing.js.map +1 -1
  23. package/dist/esm/zod-address.d.ts.map +1 -1
  24. package/dist/esm/zod-address.js.map +1 -1
  25. package/dist/esm/zod-bigdecimal.d.ts.map +1 -1
  26. package/dist/esm/zod-bigdecimal.js.map +1 -1
  27. package/dist/esm/zod-code.d.ts.map +1 -1
  28. package/dist/esm/zod-code.js.map +1 -1
  29. package/dist/esm/zod-color.d.ts.map +1 -1
  30. package/dist/esm/zod-color.js.map +1 -1
  31. package/dist/esm/zod-decorators.types.d.ts.map +1 -1
  32. package/dist/esm/zod-decorators.types.js.map +1 -1
  33. package/dist/esm/zod-duration.d.ts.map +1 -1
  34. package/dist/esm/zod-duration.js.map +1 -1
  35. package/dist/esm/zod-file.d.ts.map +1 -1
  36. package/dist/esm/zod-file.js.map +1 -1
  37. package/dist/esm/zod-money.d.ts.map +1 -1
  38. package/dist/esm/zod-money.js.map +1 -1
  39. package/dist/esm/zod-phone.d.ts.map +1 -1
  40. package/dist/esm/zod-phone.js.map +1 -1
  41. package/dist/esm/zod-range.d.ts.map +1 -1
  42. package/dist/esm/zod-range.js.map +1 -1
  43. package/dist/esm/zod-utils.shared.d.ts.map +1 -1
  44. package/dist/esm/zod-utils.shared.js.map +1 -1
  45. package/dist/esm/zod-versioned.d.ts.map +1 -1
  46. package/dist/esm/zod-versioned.js.map +1 -1
  47. package/dist/esm/zod.module-override.d.ts.map +1 -1
  48. package/dist/esm/zod.module-override.js.map +1 -1
  49. package/package.json +1 -1
  50. package/dist/esm/.native.tsbuildinfo +0 -1
  51. package/dist/esm/__mocks__/mime.d.ts +0 -12
  52. package/dist/esm/__mocks__/mime.d.ts.map +0 -1
  53. package/dist/esm/__mocks__/mime.js +0 -75
  54. package/dist/esm/__mocks__/mime.js.map +0 -1
  55. package/dist/tsconfig.build.tsbuildinfo +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"zod-duration.d.ts","sourceRoot":"","sources":["../../src/zod-duration.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,cAAc,EAId,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,uBAAuB,EACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB;IACnB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,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AAS,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC3C,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;KAC5C,CAAC;IAEF,MAAM,gBAAgB,GAAyB,cAAsB,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IAC5F,cAAsB,CAAC,eAAe,CAAC,GAAG;QACzC,GAAG,gBAAgB;QACnB,cAAc,EAAE,gBAAgB;KACjC,CAAC;IAEF,mBAAmB,CAAC,cAAc,CAAC,CAAC;IAEpC,OAAO,cAAoD,CAAC;AAC9D,CAAC;AAsBD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU,CAAC,OAA+B;IACxD,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC;AACD,oDAAoD;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAU,CAAC;IAChD,QAAQ,EAAE,CAAC;IACX,YAAY,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;CAC5E,CAAC,CAAC","sourcesContent":["\n// ============================================================================\n// DURATION SCHEMA HELPER\n// ============================================================================\n\nimport {\n DecoratorInput,\n SCHEMA_METADATA,\n CustomFieldMetadata,\n DurationSchemaMetadata,\n DurationUnit,\n SummaryFieldParams,\n ZodDecorator,\n ZodDecorator_ParamsType,\n} from './zod-decorators.types';\nimport { z } from 'zod';\nimport { addChainableMethods } from './zod.module-override';\n\n/**\n * @wildo_source:part:start zod.factories.duration facet:layer:shared facet:family:schema-factory\n *\n * Duration value type — represents a time span with value and unit.\n *\n * Stored as { value: number, unit: DurationUnit } for clarity and flexibility.\n * Use durationToSeconds() for canonical conversion when needed (e.g., TTL, expiry).\n *\n * @example\n * { value: 5, unit: DurationUnit.MINUTES } // 5 minutes\n * { value: 1, unit: DurationUnit.HOURS } // 1 hour\n */\nexport interface DurationValue {\n /** Numeric quantity (must be non-negative for typical use) */\n value: number;\n /** Unit of time */\n unit: DurationUnit;\n}\n\n/**\n * Options for creating a duration schema via z_duration().\n * Uses the DurationUnit enum for type-safe configuration.\n */\nexport interface DurationSchemaOptions {\n /** Allowed units (if empty/undefined, all units are allowed) */\n allowedUnits?: DurationUnit[];\n /** Minimum value (for the numeric part) */\n minValue?: number;\n /** Maximum value (for the numeric part) */\n maxValue?: number;\n}\n\n/** Seconds multiplier for each duration unit */\nconst DURATION_MULTIPLIERS: Record<DurationUnit, number> = {\n [DurationUnit.MILLISECONDS]: 0.001,\n [DurationUnit.SECONDS]: 1,\n [DurationUnit.MINUTES]: 60,\n [DurationUnit.HOURS]: 3600,\n [DurationUnit.DAYS]: 86400,\n [DurationUnit.WEEKS]: 604800,\n [DurationUnit.MONTHS]: 30 * 86400,\n [DurationUnit.YEARS]: 365.25 * 86400,\n [DurationUnit.CENTURIES]: 100 * 365.25 * 86400,\n};\n\n/** Canonical Zod schema for DurationUnit. Clone via `z_clone()` for independent metadata. */\nexport const DurationUnitSchema = z.enum(DurationUnit).systemEnum('DurationUnit');\n\n/**\n * Zod schema for DurationValue.\n */\nexport const DurationValueSchema = z.object({\n value: z.number().int().min(0).describe(\"How many `unit`s the duration lasts.\"),\n unit: DurationUnitSchema.describe(\"The unit `value` is counted in.\"),\n});\n\n/**\n * Convert a duration to total seconds for canonical storage/comparison.\n * Use when setting TTL, expiry, or comparing durations.\n *\n * @param d - Duration value\n * @returns Total seconds\n */\nexport function durationToSeconds(d: DurationValue): number {\n return d.value * DURATION_MULTIPLIERS[d.unit];\n}\n\n/**\n * Create a duration from total seconds, using the most appropriate unit.\n * Prefers larger units when the value divides evenly.\n *\n * @param totalSeconds - Total seconds\n * @returns DurationValue\n */\nexport function secondsToDuration(totalSeconds: number): DurationValue {\n if (totalSeconds <= 0) {\n return { value: 0, unit: DurationUnit.SECONDS };\n }\n const units: DurationUnit[] = [\n DurationUnit.CENTURIES,\n DurationUnit.YEARS,\n DurationUnit.MONTHS,\n DurationUnit.WEEKS,\n DurationUnit.DAYS,\n DurationUnit.HOURS,\n DurationUnit.MINUTES,\n DurationUnit.SECONDS,\n DurationUnit.MILLISECONDS,\n ];\n for (const unit of units) {\n const m = DURATION_MULTIPLIERS[unit];\n if (totalSeconds % m === 0 && totalSeconds >= m) {\n return { value: totalSeconds / m, unit };\n }\n }\n return { value: totalSeconds, unit: DurationUnit.SECONDS };\n}\n\n/** Singular form for each duration unit (when value is 1) */\nconst DURATION_UNIT_SINGULAR: Record<DurationUnit, string> = {\n [DurationUnit.MILLISECONDS]: 'millisecond',\n [DurationUnit.SECONDS]: 'second',\n [DurationUnit.MINUTES]: 'minute',\n [DurationUnit.HOURS]: 'hour',\n [DurationUnit.DAYS]: 'day',\n [DurationUnit.WEEKS]: 'week',\n [DurationUnit.MONTHS]: 'month',\n [DurationUnit.YEARS]: 'year',\n [DurationUnit.CENTURIES]: 'century',\n};\n\n/**\n * Format a duration for display.\n *\n * @param d - Duration value\n * @param options - Format options\n * @returns Formatted string (e.g., \"5 minutes\", \"1 hour\")\n */\nexport function formatDuration(\n d: DurationValue,\n options: { pluralize?: boolean } = {}\n): string {\n const { pluralize = true } = options;\n const label =\n pluralize && d.value === 1\n ? DURATION_UNIT_SINGULAR[d.unit] ?? d.unit\n : d.unit;\n return `${d.value} ${label}`;\n}\n\n/**\n * z_duration() - Creates duration schemas for time spans.\n *\n * Duration values are stored as { value, unit }.\n * Use durationToSeconds() when you need canonical seconds (e.g., TTL).\n *\n * @example\n * ```typescript\n * import { z_duration, DurationUnit } from '@wildo-ai/zod-decorators';\n *\n * const sessionTtl = z_duration();\n * const allowedUnits = z_duration({ allowedUnits: [DurationUnit.MINUTES, DurationUnit.HOURS] });\n *\n * // UI props via .durationUI()\n * z_duration().durationUI({ edit: { defaultUnit: DurationUnit.MINUTES } })\n * z_duration({ allowedUnits: [DurationUnit.HOURS, DurationUnit.DAYS] }).durationUI({ edit: { defaultUnit: DurationUnit.HOURS } })\n * ```\n */\n\n/**\n * Creates a duration schema with metadata for detection and form component rendering.\n *\n * @param options - Configuration options for duration field\n * @returns A Zod object schema with metadata for duration detection\n */\nexport function createDurationSchema(\n options: DurationSchemaOptions = {}\n): DecoratedDurationSchema {\n const {\n allowedUnits,\n minValue,\n maxValue,\n } = options;\n\n let valueSchema = z.number().int().min(0);\n if (minValue !== undefined) {\n valueSchema = valueSchema.min(minValue);\n }\n if (maxValue !== undefined) {\n valueSchema = valueSchema.max(maxValue);\n }\n\n const unitSchema =\n allowedUnits && allowedUnits.length > 0\n ? z.enum([allowedUnits[0], ...allowedUnits.slice(1)] as [string, ...string[]])\n : DurationUnitSchema;\n\n const durationSchema = z.object({\n value: valueSchema.describe(\"How many `unit`s the duration lasts.\"),\n unit: unitSchema.describe(\"The unit `value` is counted in.\"),\n });\n\n const durationMetadata: DurationSchemaMetadata = {\n isDuration: true,\n ...(allowedUnits && allowedUnits.length > 0 && { allowedUnits }),\n ...(minValue !== undefined && { minValue }),\n ...(maxValue !== undefined && { maxValue }),\n };\n\n const existingMetadata: CustomFieldMetadata = (durationSchema as any)[SCHEMA_METADATA] || {};\n (durationSchema as any)[SCHEMA_METADATA] = {\n ...existingMetadata,\n durationConfig: durationMetadata,\n };\n\n addChainableMethods(durationSchema);\n\n return durationSchema as unknown as DecoratedDurationSchema;\n}\n\n/**\n * Return type for duration schemas - includes decorator methods.\n */\nexport type DecoratedDurationSchema = z.ZodObject<{\n value: z.ZodNumber;\n unit: z.ZodTypeAny;\n}> & {\n [ZodDecorator.IS_DB_INDEXED](): DecoratedDurationSchema;\n /** Installed at runtime with the other chainable methods; declared here so an authored `.durationUI(…)` typechecks. */\n [ZodDecorator.DURATION_UI](params?: ZodDecorator_ParamsType[ZodDecorator.DURATION_UI]): DecoratedDurationSchema;\n [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): DecoratedDurationSchema;\n [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): DecoratedDurationSchema;\n [ZodDecorator.IS_SUMMARY_FIELD](params?: SummaryFieldParams): DecoratedDurationSchema;\n [ZodDecorator.IS_BACKEND_ONLY](params?: ZodDecorator_ParamsType[ZodDecorator.IS_BACKEND_ONLY]): DecoratedDurationSchema;\n [ZodDecorator.IS_WRITE_ONLY_SECRET](params?: ZodDecorator_ParamsType[ZodDecorator.IS_WRITE_ONLY_SECRET]): DecoratedDurationSchema;\n [ZodDecorator.EXCLUDE_FROM_CREATE](): DecoratedDurationSchema;\n [ZodDecorator.EXCLUDE_FROM_UPDATE](): DecoratedDurationSchema;\n addDecorators(decorators: DecoratorInput[]): DecoratedDurationSchema;\n};\n\n/**\n * Creates a duration schema for time spans.\n *\n * @example\n * ```typescript\n * import { z_duration, DurationUnit } from '@wildo-ai/zod-decorators';\n *\n * z_duration()\n * z_duration({ allowedUnits: [DurationUnit.MINUTES, DurationUnit.HOURS, DurationUnit.DAYS] })\n * z_duration({ minValue: 1, maxValue: 1440 }) // 1–1440 minutes\n *\n * // UI props via .durationUI()\n * z_duration().durationUI({ edit: { defaultUnit: DurationUnit.HOURS } })\n * ```\n */\nexport function z_duration(options?: DurationSchemaOptions): DecoratedDurationSchema {\n return createDurationSchema(options);\n}\n/** @wildo_source:part:end zod.factories.duration */\n\n/**\n * Schema for token expiry duration — minutes, hours, or days only, value ≥ 1.\n * Use for expiresIn in consumable tokens, sharableDefaults, and share API.\n */\nexport const ExpiresInDurationSchema = z_duration({\n minValue: 1,\n allowedUnits: [DurationUnit.MINUTES, DurationUnit.HOURS, DurationUnit.DAYS],\n});\n"]}
1
+ {"version":3,"file":"zod-duration.js","sourceRoot":"","sources":["../../../src/zod-duration.ts"],"names":[],"mappings":"AACA,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E,OAAO,EAEL,eAAe,EAGf,YAAY,EAEZ,YAAY,GAEb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,CAAC,EAAE,M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W,CAAC,QAAQ,CAAC,sCAAsC,CAAC;QACnE,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,iCAAiC,CAAC;KAC7D,CAAC,CAAC;IAEH,MAAM,gBAAgB,GAA2B;QAC/C,UAAU,EAAE,IAAI;QAChB,GAAG,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC;QAChE,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC3C,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;KAC5C,CAAC;IAEF,MAAM,gBAAgB,GAAyB,cAAsB,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IAC5F,cAAsB,CAAC,eAAe,CAAC,GAAG;QACzC,GAAG,gBAAgB;QACnB,cAAc,EAAE,gBAAgB;KACjC,CAAC;IAEF,mBAAmB,CAAC,cAAc,CAAC,CAAC;IAEpC,OAAO,cAAoD,CAAC;AAC9D,CAAC;AAsBD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU,CAAC,OAA+B;IACxD,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC;AACD,oDAAoD;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAU,CAAC;IAChD,QAAQ,EAAE,CAAC;IACX,YAAY,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;CAC5E,CAAC,CAAC","sourcesContent":["\n// ============================================================================\n// DURATION SCHEMA HELPER\n// ============================================================================\n\nimport {\n DecoratorInput,\n SCHEMA_METADATA,\n CustomFieldMetadata,\n DurationSchemaMetadata,\n DurationUnit,\n SummaryFieldParams,\n ZodDecorator,\n ZodDecorator_ParamsType,\n} from './zod-decorators.types';\nimport { z } from 'zod';\nimport { addChainableMethods } from './zod.module-override';\n\n/**\n * @wildo_source:part:start zod.factories.duration facet:layer:shared facet:family:schema-factory\n *\n * Duration value type — represents a time span with value and unit.\n *\n * Stored as { value: number, unit: DurationUnit } for clarity and flexibility.\n * Use durationToSeconds() for canonical conversion when needed (e.g., TTL, expiry).\n *\n * @example\n * { value: 5, unit: DurationUnit.MINUTES } // 5 minutes\n * { value: 1, unit: DurationUnit.HOURS } // 1 hour\n */\nexport interface DurationValue {\n /** Numeric quantity (must be non-negative for typical use) */\n value: number;\n /** Unit of time */\n unit: DurationUnit;\n}\n\n/**\n * Options for creating a duration schema via z_duration().\n * Uses the DurationUnit enum for type-safe configuration.\n */\nexport interface DurationSchemaOptions {\n /** Allowed units (if empty/undefined, all units are allowed) */\n allowedUnits?: DurationUnit[];\n /** Minimum value (for the numeric part) */\n minValue?: number;\n /** Maximum value (for the numeric part) */\n maxValue?: number;\n}\n\n/** Seconds multiplier for each duration unit */\nconst DURATION_MULTIPLIERS: Record<DurationUnit, number> = {\n [DurationUnit.MILLISECONDS]: 0.001,\n [DurationUnit.SECONDS]: 1,\n [DurationUnit.MINUTES]: 60,\n [DurationUnit.HOURS]: 3600,\n [DurationUnit.DAYS]: 86400,\n [DurationUnit.WEEKS]: 604800,\n [DurationUnit.MONTHS]: 30 * 86400,\n [DurationUnit.YEARS]: 365.25 * 86400,\n [DurationUnit.CENTURIES]: 100 * 365.25 * 86400,\n};\n\n/** Canonical Zod schema for DurationUnit. Clone via `z_clone()` for independent metadata. */\nexport const DurationUnitSchema = z.enum(DurationUnit).systemEnum('DurationUnit');\n\n/**\n * Zod schema for DurationValue.\n */\nexport const DurationValueSchema = z.object({\n value: z.number().int().min(0).describe(\"How many `unit`s the duration lasts.\"),\n unit: DurationUnitSchema.describe(\"The unit `value` is counted in.\"),\n});\n\n/**\n * Convert a duration to total seconds for canonical storage/comparison.\n * Use when setting TTL, expiry, or comparing durations.\n *\n * @param d - Duration value\n * @returns Total seconds\n */\nexport function durationToSeconds(d: DurationValue): number {\n return d.value * DURATION_MULTIPLIERS[d.unit];\n}\n\n/**\n * Create a duration from total seconds, using the most appropriate unit.\n * Prefers larger units when the value divides evenly.\n *\n * @param totalSeconds - Total seconds\n * @returns DurationValue\n */\nexport function secondsToDuration(totalSeconds: number): DurationValue {\n if (totalSeconds <= 0) {\n return { value: 0, unit: DurationUnit.SECONDS };\n }\n const units: DurationUnit[] = [\n DurationUnit.CENTURIES,\n DurationUnit.YEARS,\n DurationUnit.MONTHS,\n DurationUnit.WEEKS,\n DurationUnit.DAYS,\n DurationUnit.HOURS,\n DurationUnit.MINUTES,\n DurationUnit.SECONDS,\n DurationUnit.MILLISECONDS,\n ];\n for (const unit of units) {\n const m = DURATION_MULTIPLIERS[unit];\n if (totalSeconds % m === 0 && totalSeconds >= m) {\n return { value: totalSeconds / m, unit };\n }\n }\n return { value: totalSeconds, unit: DurationUnit.SECONDS };\n}\n\n/** Singular form for each duration unit (when value is 1) */\nconst DURATION_UNIT_SINGULAR: Record<DurationUnit, string> = {\n [DurationUnit.MILLISECONDS]: 'millisecond',\n [DurationUnit.SECONDS]: 'second',\n [DurationUnit.MINUTES]: 'minute',\n [DurationUnit.HOURS]: 'hour',\n [DurationUnit.DAYS]: 'day',\n [DurationUnit.WEEKS]: 'week',\n [DurationUnit.MONTHS]: 'month',\n [DurationUnit.YEARS]: 'year',\n [DurationUnit.CENTURIES]: 'century',\n};\n\n/**\n * Format a duration for display.\n *\n * @param d - Duration value\n * @param options - Format options\n * @returns Formatted string (e.g., \"5 minutes\", \"1 hour\")\n */\nexport function formatDuration(\n d: DurationValue,\n options: { pluralize?: boolean } = {}\n): string {\n const { pluralize = true } = options;\n const label =\n pluralize && d.value === 1\n ? DURATION_UNIT_SINGULAR[d.unit] ?? d.unit\n : d.unit;\n return `${d.value} ${label}`;\n}\n\n/**\n * z_duration() - Creates duration schemas for time spans.\n *\n * Duration values are stored as { value, unit }.\n * Use durationToSeconds() when you need canonical seconds (e.g., TTL).\n *\n * @example\n * ```typescript\n * import { z_duration, DurationUnit } from '@wildo-ai/zod-decorators';\n *\n * const sessionTtl = z_duration();\n * const allowedUnits = z_duration({ allowedUnits: [DurationUnit.MINUTES, DurationUnit.HOURS] });\n *\n * // UI props via .durationUI()\n * z_duration().durationUI({ edit: { defaultUnit: DurationUnit.MINUTES } })\n * z_duration({ allowedUnits: [DurationUnit.HOURS, DurationUnit.DAYS] }).durationUI({ edit: { defaultUnit: DurationUnit.HOURS } })\n * ```\n */\n\n/**\n * Creates a duration schema with metadata for detection and form component rendering.\n *\n * @param options - Configuration options for duration field\n * @returns A Zod object schema with metadata for duration detection\n */\nexport function createDurationSchema(\n options: DurationSchemaOptions = {}\n): DecoratedDurationSchema {\n const {\n allowedUnits,\n minValue,\n maxValue,\n } = options;\n\n let valueSchema = z.number().int().min(0);\n if (minValue !== undefined) {\n valueSchema = valueSchema.min(minValue);\n }\n if (maxValue !== undefined) {\n valueSchema = valueSchema.max(maxValue);\n }\n\n const unitSchema =\n allowedUnits && allowedUnits.length > 0\n ? z.enum([allowedUnits[0], ...allowedUnits.slice(1)] as [string, ...string[]])\n : DurationUnitSchema;\n\n const durationSchema = z.object({\n value: valueSchema.describe(\"How many `unit`s the duration lasts.\"),\n unit: unitSchema.describe(\"The unit `value` is counted in.\"),\n });\n\n const durationMetadata: DurationSchemaMetadata = {\n isDuration: true,\n ...(allowedUnits && allowedUnits.length > 0 && { allowedUnits }),\n ...(minValue !== undefined && { minValue }),\n ...(maxValue !== undefined && { maxValue }),\n };\n\n const existingMetadata: CustomFieldMetadata = (durationSchema as any)[SCHEMA_METADATA] || {};\n (durationSchema as any)[SCHEMA_METADATA] = {\n ...existingMetadata,\n durationConfig: durationMetadata,\n };\n\n addChainableMethods(durationSchema);\n\n return durationSchema as unknown as DecoratedDurationSchema;\n}\n\n/**\n * Return type for duration schemas - includes decorator methods.\n */\nexport type DecoratedDurationSchema = z.ZodObject<{\n value: z.ZodNumber;\n unit: z.ZodTypeAny;\n}> & {\n [ZodDecorator.IS_DB_INDEXED](): DecoratedDurationSchema;\n /** Installed at runtime with the other chainable methods; declared here so an authored `.durationUI(…)` typechecks. */\n [ZodDecorator.DURATION_UI](params?: ZodDecorator_ParamsType[ZodDecorator.DURATION_UI]): DecoratedDurationSchema;\n [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): DecoratedDurationSchema;\n [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): DecoratedDurationSchema;\n [ZodDecorator.IS_SUMMARY_FIELD](params?: SummaryFieldParams): DecoratedDurationSchema;\n [ZodDecorator.IS_BACKEND_ONLY](params?: ZodDecorator_ParamsType[ZodDecorator.IS_BACKEND_ONLY]): DecoratedDurationSchema;\n [ZodDecorator.IS_WRITE_ONLY_SECRET](params?: ZodDecorator_ParamsType[ZodDecorator.IS_WRITE_ONLY_SECRET]): DecoratedDurationSchema;\n [ZodDecorator.EXCLUDE_FROM_CREATE](): DecoratedDurationSchema;\n [ZodDecorator.EXCLUDE_FROM_UPDATE](): DecoratedDurationSchema;\n addDecorators(decorators: DecoratorInput[]): DecoratedDurationSchema;\n};\n\n/**\n * Creates a duration schema for time spans.\n *\n * @example\n * ```typescript\n * import { z_duration, DurationUnit } from '@wildo-ai/zod-decorators';\n *\n * z_duration()\n * z_duration({ allowedUnits: [DurationUnit.MINUTES, DurationUnit.HOURS, DurationUnit.DAYS] })\n * z_duration({ minValue: 1, maxValue: 1440 }) // 1–1440 minutes\n *\n * // UI props via .durationUI()\n * z_duration().durationUI({ edit: { defaultUnit: DurationUnit.HOURS } })\n * ```\n */\nexport function z_duration(options?: DurationSchemaOptions): DecoratedDurationSchema {\n return createDurationSchema(options);\n}\n/** @wildo_source:part:end zod.factories.duration */\n\n/**\n * Schema for token expiry duration — minutes, hours, or days only, value ≥ 1.\n * Use for expiresIn in consumable tokens, sharableDefaults, and share API.\n */\nexport const ExpiresInDurationSchema = z_duration({\n minValue: 1,\n allowedUnits: [DurationUnit.MINUTES, DurationUnit.HOURS, DurationUnit.DAYS],\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"zod-file.d.ts","sourceRoot":"","sources":["../../src/zod-file.ts"],"names":[],"mappings":"AAMA,OAAO,EAKL,iBAAiB,EAEjB,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,uBAAuB,EAEvB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,EAC3B,2BAA2B,EAC3B,8BAA8B,EAI9B,YAAY,EACZ,uBAAuB,EACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAqB7D;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,SAAS,EAAE,IAAI,CAAC;CAEjB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,4BAA4B;IAC5B,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,eAAe,GAAG,iBAAiB,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,SAAS,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC;IAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAA;CAAE,CAG3F,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,SAAS,CAAC;IAAE,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAA;CAAE,CAG1G,CAAC;AAGH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AA0B,CAAC,CAAC,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC,qBAAqB;QAC/F,UAAU,EAAE,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,mBAAmB;QACtG,aAAa;QACb,QAAQ,EAAE,IAAI;QACd,iBAAiB,EACf,oBAAoB,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI;cACtE,GAAG,0BAA0B,CAAC,CAAC,CAAC,gBAAgB,qBAAqB,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;cACrF,GAAG,0BAA0B,IAAI,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;cACvE,GAAG,wBAAwB,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,EAAE,EAAE;KACzE,CAAC;AACJ,CAAC","sourcesContent":["\n// ============================================================================\n// FILE SCHEMA HELPER\n// ============================================================================\n\n\nimport {\n DecoratorInput,\n SCHEMA_METADATA,\n CustomFieldMetadata,\n FileSchemaMetadata,\n FileSchemaOptions,\n FileMimeTypeGroups,\n FileMimeTypeGroup,\n FileNature,\n FileDisplayNature,\n FileDisplayPresentation,\n FileActivationPolicy,\n type FileActivationConfig,\n type FileUIDisplayParams,\n FileStorageAccepted,\n FileNatureConstraints_Image,\n FileNatureConstraints_Video,\n FileNatureConstraints_Audio,\n FileNatureConstraints_Document,\n FileGenerationConfig,\n FileGenerationSource,\n RagSourceConfiguration,\n ZodDecorator,\n ZodDecorator_ParamsType\n} from \"./zod-decorators.types\";\nimport { z } from \"zod\";\nimport { addChainableMethods, addDecorators } from \"./zod.module-override\";\nimport { UnifiedFileFormatRegistry } from \"./files/unified-registry\";\nimport { AgentFileFormat } from \"./files/agent-file-formats\";\n\n// Minimal console declaration — avoids pulling in 'dom' or '@types/node' into this shared lib\ndeclare const console: { warn(...args: unknown[]): void };\n\n/**\n * Deduplicated warning tracker for unsupported storage providers.\n * Prevents console spam when the same schema is created multiple times (e.g., in tests or HMR).\n */\nconst _warnedStorageProviders = new Set<string>();\n/**\n * The storages the ENGINE serves itself. `GOOGLE_DRIVE` joined on 2026-09-09 (#394 P5): its bytes stay\n * in Drive, read and written through the connected account of the person who linked or uploaded them.\n * Any other member is served only when a loaded provider contributes an adapter (#1674) —\n * `ONEDRIVE` by the engine's `microsoft-onedrive` once scoped — which this decorator package cannot see, so it\n * warns about those members rather than refusing them.\n */\nconst _supportedProviders = new Set([FileStorageAccepted.WILDO_MANAGED, FileStorageAccepted.LOCAL_DIRECTORY, FileStorageAccepted.GOOGLE_DRIVE]);\nconst GENERATED_PDF_MIME_TYPES = ['application/pdf'] as const;\nconst GENERATION_METADATA_KEYS = new Set(['source', 'templateId']);\n\n/**\n * Single file value type - represents a single file reference stored in the database.\n * The actual file is stored in a file storage system, this object references it.\n */\nexport interface SingleFileValue {\n /** File ID (foreign key to file storage) */\n fileId: string;\n /** Last update timestamp */\n updatedAt: Date;\n\n}\n\n/**\n * Multiple files value type - represents multiple file references stored in the database.\n */\nexport interface MultipleFileValue {\n /** File IDs (foreign keys to file storage) */\n fileIds: string[];\n /** Last update timestamp */\n updatedAt: Date;\n}\n\n/**\n * File value type - can be single or multiple depending on schema configuration.\n */\nexport type FileValue = SingleFileValue | MultipleFileValue;\n\n/**\n * Zod schema for SingleFileValue.\n */\nexport const SingleFileValueSchema: z.ZodObject<{ fileId: z.ZodString; updatedAt: z.ZodDate }> = z.object({\n fileId: z.string().min(1).describe(\"The stored file's identifier. Read the file's details from the file metadata endpoint, or from `file` when the read populates files.\"),\n updatedAt: z.date().describe(\"When this file reference was last set.\"),\n});\n\n/**\n * Zod schema for MultipleFileValue.\n */\nexport const MultipleFileValueSchema: z.ZodObject<{ fileIds: z.ZodArray<z.ZodString>; updatedAt: z.ZodDate }> = z.object({\n fileIds: z.array(z.string().min(1)).describe(\"The stored files' identifiers, in order.\"),\n updatedAt: z.date().describe(\"When this file reference was last set.\"),\n});\n\n\n/**\n * Resolve MIME type groups to actual MIME types.\n * Handles both single group names and arrays of groups/MIME types.\n */\nexport function resolveMimeTypes(\n allowedMimeTypes: string[] | FileMimeTypeGroup | FileMimeTypeGroup[] | undefined\n): string[] | undefined {\n if (!allowedMimeTypes) return undefined;\n\n // If it's a single group name\n if (typeof allowedMimeTypes === 'string') {\n if (allowedMimeTypes in FileMimeTypeGroups) {\n return [...FileMimeTypeGroups[allowedMimeTypes as FileMimeTypeGroup]];\n }\n // Single MIME type\n return [allowedMimeTypes];\n }\n\n // If it's an array\n if (Array.isArray(allowedMimeTypes)) {\n const resolved: string[] = [];\n for (const item of allowedMimeTypes) {\n if (item in FileMimeTypeGroups) {\n // It's a group name\n resolved.push(...FileMimeTypeGroups[item as FileMimeTypeGroup]);\n } else {\n // It's a MIME type\n resolved.push(item);\n }\n }\n // Remove duplicates\n return [...new Set(resolved)];\n }\n\n return undefined;\n}\n\nfunction assertValidFileGenerationConfig(generation: FileGenerationConfig): void {\n const rawGeneration = generation as unknown as Record<string, unknown> | undefined;\n if (!rawGeneration || typeof rawGeneration !== 'object' || Array.isArray(rawGeneration)) {\n throw new Error('[z_file] generation must be an object.');\n }\n\n const extraKeys = Object.keys(rawGeneration).filter((key) => !GENERATION_METADATA_KEYS.has(key));\n if (extraKeys.length > 0) {\n throw new Error(\n `[z_file] generation contains unsupported key(s): ${extraKeys.join(', ')}. ` +\n 'Use only { source: FileGenerationSource.PDF_TEMPLATE, templateId }.'\n );\n }\n\n if (rawGeneration.source !== FileGenerationSource.PDF_TEMPLATE) {\n throw new Error('[z_file] generation.source must be FileGenerationSource.PDF_TEMPLATE.');\n }\n\n if (typeof rawGeneration.templateId !== 'string' || rawGeneration.templateId.trim().length === 0) {\n throw new Error('[z_file] generation.templateId must be a non-empty string.');\n }\n}\n\nfunction assertGeneratedPdfFileOptions(params: {\n generation?: FileGenerationConfig;\n multiple: boolean;\n resolvedMimeTypes?: string[];\n overridable: boolean;\n ragSource?: RagSourceConfiguration;\n scanPolicy?: unknown;\n}): void {\n if (!params.generation) return;\n\n assertValidFileGenerationConfig(params.generation);\n\n if (params.multiple) {\n throw new Error('[z_file] PDF template generation supports single-file fields only.');\n }\n\n if (params.overridable === false) {\n throw new Error('[z_file] PDF template generation requires overridable to remain true so framework REGENERATE can replace the generated file.');\n }\n\n // Re-expression of the pre-Phase-0 `rag` refusal against the shared decorator: a PDF-template\n // output is framework-RENDERED presentation of resource data the corpus can already reach at the\n // source fields — chunking the rendering would index the same facts twice, keyed to a file the\n // next REGENERATE silently replaces.\n if (params.ragSource) {\n throw new Error('[z_file] PDF template generation cannot be combined with RAG ingestion options.');\n }\n\n if (params.scanPolicy) {\n throw new Error('[z_file] PDF template generation cannot be combined with upload scanPolicy options.');\n }\n\n if (\n params.resolvedMimeTypes !== undefined &&\n (params.resolvedMimeTypes.length !== 1 || params.resolvedMimeTypes[0] !== GENERATED_PDF_MIME_TYPES[0])\n ) {\n throw new Error('[z_file] PDF template generation requires allowedMimeTypes to resolve exactly to application/pdf.');\n }\n}\n\n/**\n * z_file() - Creates file schemas for file uploads.\n *\n * File values are stored as: { fileId: string, updatedAt: Date }\n * - fileId: Reference to the file in storage (foreign key, indexed)\n * - updatedAt: When the file was last updated\n *\n * @example\n * ```typescript\n * import { z_file } from '@wildo-ai/zod-decorators';\n *\n * const avatar = z_file();\n * const document = z_file({ allowedMimeTypes: 'Documents' });\n * const images = z_file({\n * allowedMimeTypes: 'Images',\n * maxSize: 5 * 1024 * 1024, // 5MB\n * overridable: true\n * });\n *\n * // With decorators (chainable)\n * z_file().fileUI({ edit: { editMode: FileEditMode.DROPZONE } })\n * z_file({ allowedMimeTypes: ['Images', 'PDF'] }).isHidden({ edit: true })\n * ```\n */\n\n/**\n * @wildo_source:part:start zod.decorators.file-schema\n *\n * Creates a file schema with metadata for detection and form component rendering.\n *\n * ## Where a file field may be declared\n *\n * **The resource's primary scope must be application, organization or user.** A resource scoped to\n * an ANONYMOUS visitor cannot carry a file field — a file's own scope is one of those three, so\n * there is nothing to attribute the bytes to, and the upload refuses that scope by name rather than\n * pretending to support it.\n *\n * **Within the schema, a file field may nest inside objects, arrays and DISCRIMINATED unions.** It\n * may NOT sit inside a record, a map, a set, a tuple, or a plain (non-discriminated) union — the\n * walker that finds file fields refuses those shapes. Where variants are needed, use a discriminated\n * union.\n *\n * **A field carried on several branches of a discriminated union must declare IDENTICAL options on\n * every branch.** Differing options at one path are a conflict the framework refuses rather than\n * choosing between, so a branch that quietly widens `maxSize` or changes `allowedMimeTypes` fails\n * the schema instead of silently winning.\n *\n * ## Uploading is not attaching\n *\n * The generated upload route creates a FILE ROW. Attaching it to a business record is that record's\n * own write, with its own authority. So an uploaded-but-never-submitted file is a real state a\n * caller can produce; the cleanup sweep is what handles it.\n *\n * ## Declaring `imageConstraints.aspectRatio` turns the cropper on\n *\n * That option is the switch for the browser-side crop step — nothing else is wired. It applies to\n * single-file fields only: a `multiple` field keeps the plain upload path. Vector images and\n * formats the browser cannot decode bypass the cropper and upload the original, so the server-side\n * constraint stays the authority.\n *\n * @param options - Configuration options for file field\n * @returns A Zod object schema with metadata for file detection\n */\nexport function createFileSchema(\n options: FileSchemaOptions = {}\n): DecoratedFileSchema | DecoratedMultipleFileSchema {\n const {\n overridable = true,\n allowedMimeTypes,\n maxSize,\n minSize,\n multiple = false,\n maxFiles,\n nature,\n storageAccepted,\n filePathBinding,\n generation,\n imageConstraints,\n videoConstraints,\n audioConstraints,\n documentConstraints,\n ragSource,\n textExtraction,\n scanPolicy,\n onParentDelete = 'cascade',\n sharable,\n sharableDefaults,\n } = options;\n\n // Warn at schema creation for a storage the engine does not serve itself — served only if a provider package contributes it\n // Uses deduplication to avoid console spam during tests or HMR\n if (storageAccepted && storageAccepted.some(s => !_supportedProviders.has(s))) {\n const unsupported = storageAccepted.filter(s => !_supportedProviders.has(s));\n const warnKey = unsupported.sort().join(',');\n if (!_warnedStorageProviders.has(warnKey)) {\n _warnedStorageProviders.add(warnKey);\n // The two cases are NOT the same outcome, and saying only \"skipped\" understates the second\n // badly enough to be misleading: alongside an implemented storage the declaration really is\n // ignored, but as the ONLY declared storage it stops the application booting. That is the\n // split #460 records, stated here at the moment an author writes the declaration — earlier\n // than the startup validator and the storage router, which draw the same distinction.\n console.warn(\n `[z_file] storageAccepted names storage(s) the engine does not serve itself: ${unsupported.join(', ')}. ` +\n `The engine serves: ${[..._supportedProviders].map((s) => `'${s}'`).join(', ')}. ` +\n `Another storage is served only when a provider the application scopes contributes an adapter for it ` +\n `('onedrive': the engine's microsoft-onedrive provider). With none, declared ALONGSIDE a served storage it is ` +\n `skipped by the storage router; declared as the ONLY storage the application refuses to boot and every upload ` +\n `to this field is refused, and no environment variable enables it — a storage with no provider cannot be configured into existence.`\n );\n }\n }\n\n if (filePathBinding) {\n if (filePathBinding.multipleFilePolicy && !multiple) {\n console.warn(\n '[z_file] filePathBinding.multipleFilePolicy is set but multiple is false — multipleFilePolicy will be ignored. ' +\n 'Either set multiple: true or remove multipleFilePolicy.'\n );\n }\n if (filePathBinding.fileName && multiple) {\n console.warn(\n '[z_file] filePathBinding.fileName is set on a multiple file field — fileName is ignored for multiple uploads. ' +\n 'Use filePathBinding.multipleFilePolicy.fileNameTemplate instead.'\n );\n }\n // Warned for EVERY provider, not only WILDO_MANAGED. The condition used to exempt a field that\n // named LOCAL_DIRECTORY, because that provider defaulted to `false` anyway and the warning would\n // have fired on its own default. Both providers now default to `true` and both honour `false`\n // identically, so `false` is an explicit opt-out of the tenant-scoped key shape wherever it is\n // authored — and that is the thing worth saying out loud.\n if (filePathBinding.includeApplicationId === false) {\n console.warn(\n '[z_file] filePathBinding.includeApplicationId is false. Storage keys for this field will carry ' +\n 'NO applications/<appId>/files/<resource>/<scope>/<scopeId>/ prefix, so per-tenant listing, ' +\n 'erasure sweeps and prefix-confined credentials cannot address them — ensure that is intended.'\n );\n }\n }\n\n // Resolve MIME type groups to actual MIME types\n const resolvedMimeTypes = resolveMimeTypes(allowedMimeTypes);\n assertGeneratedPdfFileOptions({ generation, multiple, resolvedMimeTypes, overridable, ragSource, scanPolicy });\n const effectiveMimeTypes = generation ? [...GENERATED_PDF_MIME_TYPES] : resolvedMimeTypes;\n\n // Create the file object schema based on single/multiple\n const fileSchema = multiple\n ? z.object({\n fileIds: z.array(z.string().min(1)).describe(\"The stored files' identifiers, in order.\"),\n updatedAt: z.date().describe(\"When this file reference was last set.\"),\n })\n : z.object({\n fileId: z.string().min(1).describe(\"The stored file's identifier. Read the file's details from the file metadata endpoint, or from `file` when the read populates files.\"),\n updatedAt: z.date().describe(\"When this file reference was last set.\"),\n });\n\n // No longer stored in metadata — consumers derive accept from allowedMimeTypes via buildAcceptAttribute()\n\n // Store file metadata in SCHEMA_METADATA.fileConfig\n const fileMetadata: FileSchemaMetadata = {\n isFile: true,\n overridable,\n ...(effectiveMimeTypes !== undefined && { allowedMimeTypes: effectiveMimeTypes }),\n ...(maxSize !== undefined && { maxSize }),\n ...(minSize !== undefined && { minSize }),\n multiple,\n ...(maxFiles !== undefined && { maxFiles }),\n ...(nature !== undefined && { nature }),\n ...(storageAccepted !== undefined && { storageAccepted }),\n ...(filePathBinding !== undefined && { filePathBinding }),\n ...(generation !== undefined && { generation }),\n ...(imageConstraints !== undefined && { imageConstraints }),\n ...(videoConstraints !== undefined && { videoConstraints }),\n ...(audioConstraints !== undefined && { audioConstraints }),\n ...(documentConstraints !== undefined && { documentConstraints }),\n // Text-provider config only — the RAG declaration itself is NOT stored here (single source of\n // truth is the RAG_SOURCE decorator registered below; read it with `getRagSourceConfig`).\n ...(textExtraction !== undefined && { textExtraction }),\n ...(scanPolicy !== undefined && { scanPolicy }),\n onParentDelete,\n ...(sharable !== undefined && { sharable }),\n ...(sharableDefaults !== undefined && { sharableDefaults }),\n };\n\n // Initialize or extend SCHEMA_METADATA with file config\n const existingMetadata: CustomFieldMetadata = (fileSchema as any)[SCHEMA_METADATA] || {};\n (fileSchema as any)[SCHEMA_METADATA] = {\n ...existingMetadata,\n fileConfig: fileMetadata,\n };\n\n // Add chainable decorator methods to the file schema instance\n addChainableMethods(fileSchema);\n\n // Map the file-side `ragSource` option onto the SHARED RAG_SOURCE decorator — the same one\n // `z.string().ragSource()` registers — so `RagSourceFieldDetection` sees one uniform declaration\n // regardless of text provider. Registered through `addDecorators` (the escape-hatch door) because\n // the fluent `.ragSource()` is deliberately not installed on ZodObject; the shared chokepoint\n // still validates the config and enforces the refused companions identically.\n if (ragSource !== undefined) {\n addDecorators(fileSchema, [{ ref: ZodDecorator.RAG_SOURCE, params: ragSource }]);\n }\n\n if (multiple) {\n return fileSchema as unknown as DecoratedMultipleFileSchema;\n }\n return fileSchema as unknown as DecoratedFileSchema;\n}\n\n/**\n * File schemas declare NO decorator surface of their own.\n *\n * They used to, via a `FileSchemaDecoratorMethods<TSelf>` mixin that re-declared `isDBIndexed`,\n * `isHidden`, `isNotEditable` and `showWhen` with the return narrowed to the file schema — necessary\n * only because the `ZodObject` module augmentation did not carry them. It now does (2026-08-12), and\n * re-declaring them made both interfaces below fail TS2320: an interface may not extend two types\n * whose same-named member differs, and `TSelf` is not `DecoratedPrimitiveZodType<this>`.\n *\n * Removing the mixin costs nothing, because `DecoratedPrimitiveZodType<T>` is `T & { … }` — an\n * INTERSECTION. `z_file().isHidden()` still returns something assignable to `DecoratedFileSchema`,\n * and the full decorator surface is now available rather than the four this mixin listed.\n */\n\n/**\n * Return type for single file schemas - includes decorator methods.\n * IS_DB_INDEXED will index the fileId field for query optimization.\n *\n * Uses `interface` instead of `type` to allow self-referencing without circular alias errors.\n */\nexport interface DecoratedFileSchema extends z.ZodObject<{\n fileId: z.ZodString;\n updatedAt: z.ZodDate;\n}> {\n /**\n * Declared here, as the sibling factories declare theirs (`DecoratedMoneySchema.moneyUI`,\n * `DecoratedPhoneSchema.phoneUI`, …), because a file's display and edit policy is authored on\n * the factory's output and nowhere else. The applyable-type map admits `fileUI` on `ZodObject`,\n * but a bare `z.object({...})` is not a file, so the base prototype deliberately does not carry\n * it — the per-instance install `createFileSchema` performs is what makes it reachable.\n *\n * Not a RE-declaration: `fileUI` is absent from the `ZodObject` module augmentation, so this adds\n * a member rather than conflicting with one. That distinction is what the TS2320 note above is\n * about — re-declaring a member the augmentation already carries is what broke here before.\n */\n [ZodDecorator.FILE_UI](params?: ZodDecorator_ParamsType[ZodDecorator.FILE_UI]): DecoratedFileSchema;\n [ZodDecorator.FILE_SPEC](params?: ZodDecorator_ParamsType[ZodDecorator.FILE_SPEC]): DecoratedFileSchema;\n}\n\n/**\n * Return type for multiple file schemas - includes decorator methods.\n * IS_DB_INDEXED will index the fileIds array for query optimization.\n *\n * Uses `interface` instead of `type` to allow self-referencing without circular alias errors.\n */\nexport interface DecoratedMultipleFileSchema extends z.ZodObject<{\n fileIds: z.ZodArray<z.ZodString>;\n updatedAt: z.ZodDate;\n}> {\n /**\n * Declared here, as the sibling factories declare theirs (`DecoratedMoneySchema.moneyUI`,\n * `DecoratedPhoneSchema.phoneUI`, …), because a file's display and edit policy is authored on\n * the factory's output and nowhere else. The applyable-type map admits `fileUI` on `ZodObject`,\n * but a bare `z.object({...})` is not a file, so the base prototype deliberately does not carry\n * it — the per-instance install `createFileSchema` performs is what makes it reachable. Mirrors the single-file interface above.\n *\n * Not a RE-declaration: `fileUI` is absent from the `ZodObject` module augmentation, so this adds\n * a member rather than conflicting with one. That distinction is what the TS2320 note above is\n * about — re-declaring a member the augmentation already carries is what broke here before.\n */\n [ZodDecorator.FILE_UI](params?: ZodDecorator_ParamsType[ZodDecorator.FILE_UI]): DecoratedMultipleFileSchema;\n [ZodDecorator.FILE_SPEC](params?: ZodDecorator_ParamsType[ZodDecorator.FILE_SPEC]): DecoratedMultipleFileSchema;\n}\n\n/**\n * Creates a file schema for file uploads with reference storage.\n * Named z_file to indicate it's a Zod helper function exported standalone.\n *\n * Single file values are stored as: { fileId: string, updatedAt: Date }\n * Multiple file values are stored as: { fileIds: string[], updatedAt: Date }\n *\n * @example\n * ```typescript\n * import { z_file } from '@wildo-ai/zod-decorators';\n *\n * // Simple usage - single file, any type\n * z_file()\n *\n * // With MIME type groups (shortcuts)\n * z_file({ allowedMimeTypes: 'Images' })\n * z_file({ allowedMimeTypes: 'PDF' })\n * z_file({ allowedMimeTypes: ['Images', 'Video'] })\n * z_file({ allowedMimeTypes: 'Documents' }) // PDF + Office\n *\n * // With specific MIME types\n * z_file({ allowedMimeTypes: ['image/png', 'image/jpeg'] })\n *\n * // With size constraints\n * z_file({ maxSize: 10 * 1024 * 1024 }) // 10MB max\n *\n * // Multiple files (uses fileIds instead of fileId)\n * z_file({ multiple: true, maxFiles: 5 })\n *\n * // Non-overridable (append-only)\n * z_file({ overridable: false })\n *\n * // RAG corpus source — registers the shared RAG_SOURCE decorator on the returned schema\n * // (chunking config), with the file-side text-provider knobs beside it (OCR opt-in).\n * z_file({ allowedMimeTypes: 'Documents', ragSource: {}, textExtraction: { ocr: true } })\n *\n * // With decorators\n * z_file().fileUI({ edit: { editMode: FileEditMode.DROPZONE } })\n * z_file().isHidden({ display: true })\n * ```\n */\nexport function z_file(options?: FileSchemaOptions): DecoratedFileSchema | DecoratedMultipleFileSchema {\n return createFileSchema(options);\n}\n/** @wildo_source:part:end zod.decorators.file-schema */\n\n// ============================================================================\n// UTILITY FUNCTIONS\n// ============================================================================\n\n/**\n * Format file size for display.\n */\nexport function formatFileSize(bytes: number): string {\n if (!Number.isFinite(bytes)) return '—';\n if (bytes === 0) return '0 B';\n if (bytes < 0) return '-' + formatFileSize(Math.abs(bytes));\n\n const units = ['B', 'KB', 'MB', 'GB', 'TB'];\n const k = 1024;\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${units[i]}`;\n}\n\n/**\n * Build enhanced accept attribute string from MIME types.\n * Includes both MIME types and extensions for better browser compatibility.\n * Format: \"image/*,.jpg,.jpeg,.png\" or \"application/pdf,.pdf\"\n *\n * @param mimeTypes - Array of MIME type strings\n * @returns Accept attribute string with MIME types and extensions\n */\nexport function buildAcceptAttribute(mimeTypes: string[]): string {\n if (!mimeTypes || mimeTypes.length === 0) return '';\n\n const parts = new Set<string>();\n const extensions = new Set<string>();\n\n for (const mimeType of mimeTypes) {\n // Add MIME type\n parts.add(mimeType);\n\n // Get extensions for this MIME type\n const mimeExtensions = UnifiedFileFormatRegistry.getExtensions(mimeType);\n for (const ext of mimeExtensions) {\n if (ext) {\n extensions.add(`.${ext}`);\n }\n }\n\n // Also check if it's a wildcard MIME type (e.g., image/*)\n // In that case, get all extensions for that nature\n if (mimeType.endsWith('/*')) {\n const formatType = UnifiedFileFormatRegistry.getFormatTypeFromMimeType(mimeType);\n\n if (formatType && formatType.type === 'nature') {\n const natureExtensions = UnifiedFileFormatRegistry.getExtensionsForNature(formatType.nature);\n for (const ext of natureExtensions) {\n if (ext) {\n extensions.add(`.${ext}`);\n }\n }\n }\n }\n }\n\n // Combine MIME types and extensions\n const allParts = [...parts, ...extensions];\n return allParts.join(',');\n}\n\n/**\n * Get file extension from filename.\n * Uses UnifiedFileFormatRegistry for consistency.\n */\nexport function getFileExtension(filename: string): string {\n return UnifiedFileFormatRegistry.getFileExtension(filename);\n}\n\n/**\n * Check if a MIME type is allowed based on allowed types.\n */\nexport function isMimeTypeAllowed(mimeType: string, allowedMimeTypes?: string[]): boolean {\n if (!allowedMimeTypes || allowedMimeTypes.length === 0) return true;\n\n // Check exact match\n if (allowedMimeTypes.includes(mimeType)) return true;\n\n // Check wildcard match (e.g., \"image/*\")\n const [type] = mimeType.split('/');\n if (allowedMimeTypes.includes(`${type}/*`)) return true;\n\n return false;\n}\n\n/**\n * How an accepted file type is identified — the discriminator of {@link AcceptedFileKind}.\n */\nexport enum AcceptedFileKindCategory {\n /** A broad nature (images, PDF, office documents, …) — one {@link FileNature} member. */\n NATURE = 'nature',\n /** A text format an agent can produce — one {@link AgentFileFormat} member. */\n AGENT_FORMAT = 'agent_format',\n /** Neither: the MIME subtype itself (`csv` for `text/csv`), shown as the value it is. */\n MIME_SUBTYPE = 'mime_subtype',\n}\n\n/** One kind of file a field accepts, as a FACT a renderer names — never as words. */\nexport type AcceptedFileKind =\n | { category: AcceptedFileKindCategory.NATURE; nature: FileNature }\n | { category: AcceptedFileKindCategory.AGENT_FORMAT; format: AgentFileFormat }\n | { category: AcceptedFileKindCategory.MIME_SUBTYPE; subtype: string };\n\nconst AGENT_FILE_FORMAT_VALUES: ReadonlySet<string> = new Set(Object.values(AgentFileFormat));\n\n/**\n * The kinds of file a field's `allowedMimeTypes` admit, deduplicated, in first-seen order. An empty\n * result means every file is accepted.\n *\n * This answers FACTS and the renderer names them from its label tree. It used to answer an English\n * sentence (\"Images, PDF, Text files\") from two hand-kept maps plus a humanizing fallback — words\n * produced by code in a package with no i18n at all, which no locale could translate (#1283,\n * `.claude/rules/display-text-comes-from-i18n.md`).\n *\n * Resolution per MIME type: the unified format registry first (a nature, or an agent format), then\n * the broad MIME families the registry does not classify, then the subtype as a value.\n */\nexport function getAcceptedFileKinds(allowedMimeTypes?: string[]): AcceptedFileKind[] {\n if (!allowedMimeTypes || allowedMimeTypes.length === 0) return [];\n\n const kinds: AcceptedFileKind[] = [];\n const seen = new Set<string>();\n const add = (kind: AcceptedFileKind, identity: string): void => {\n if (seen.has(identity)) return;\n seen.add(identity);\n kinds.push(kind);\n };\n const addNature = (nature: FileNature): void => add({ category: AcceptedFileKindCategory.NATURE, nature }, `nature:${nature}`);\n\n for (const mime of allowedMimeTypes) {\n const formatType = UnifiedFileFormatRegistry.getFormatTypeFromMimeType(mime);\n if (formatType?.type === 'nature') {\n addNature(formatType.nature);\n continue;\n }\n if (formatType?.type === 'agent' && AGENT_FILE_FORMAT_VALUES.has(formatType.format)) {\n const format = formatType.format as AgentFileFormat;\n add({ category: AcceptedFileKindCategory.AGENT_FORMAT, format }, `agent:${format}`);\n continue;\n }\n\n if (mime === 'application/pdf') addNature(FileNature.PDF);\n else if (mime.startsWith('image/')) addNature(FileNature.IMAGE);\n else if (mime.startsWith('video/')) addNature(FileNature.VIDEO);\n else if (mime.startsWith('audio/')) addNature(FileNature.AUDIO);\n else if (mime.includes('document') || mime.includes('word') || mime.includes('excel') || mime.includes('powerpoint')) addNature(FileNature.OFFICE);\n else {\n const subtype = mime.split('/').pop();\n if (subtype) add({ category: AcceptedFileKindCategory.MIME_SUBTYPE, subtype }, `subtype:${subtype}`);\n }\n }\n return kinds;\n}\n\n/**\n * Get file nature from schema metadata.\n * @param schema - Zod schema (must be a file schema)\n * @returns FileNature or undefined if not set\n */\nexport function getFileNature(schema: z.ZodTypeAny): FileNature | undefined {\n const metadata = (schema as any)[SCHEMA_METADATA] as CustomFieldMetadata | undefined;\n return metadata?.fileConfig?.nature;\n}\n\n/**\n * Get storage accepted from schema metadata.\n * @param schema - Zod schema (must be a file schema)\n * @returns Array of FileStorageAccepted or undefined if not set\n */\nexport function getStorageAccepted(schema: z.ZodTypeAny): FileStorageAccepted[] | undefined {\n const metadata = (schema as any)[SCHEMA_METADATA] as CustomFieldMetadata | undefined;\n return metadata?.fileConfig?.storageAccepted;\n}\n\n/**\n * Get file constraints from schema metadata.\n * @param schema - Zod schema (must be a file schema)\n * @returns Object with all constraint properties or undefined if not set\n */\nexport function getFileConstraints(schema: z.ZodTypeAny): {\n imageConstraints?: FileNatureConstraints_Image;\n videoConstraints?: FileNatureConstraints_Video;\n audioConstraints?: FileNatureConstraints_Audio;\n documentConstraints?: FileNatureConstraints_Document;\n} | undefined {\n const metadata = (schema as any)[SCHEMA_METADATA] as CustomFieldMetadata | undefined;\n const fileConfig = metadata?.fileConfig;\n if (!fileConfig) return undefined;\n\n const hasConstraints =\n fileConfig.imageConstraints ||\n fileConfig.videoConstraints ||\n fileConfig.audioConstraints ||\n fileConfig.documentConstraints;\n\n if (!hasConstraints) return undefined;\n\n return {\n ...(fileConfig.imageConstraints && { imageConstraints: fileConfig.imageConstraints }),\n ...(fileConfig.videoConstraints && { videoConstraints: fileConfig.videoConstraints }),\n ...(fileConfig.audioConstraints && { audioConstraints: fileConfig.audioConstraints }),\n ...(fileConfig.documentConstraints && { documentConstraints: fileConfig.documentConstraints }),\n };\n}\n\n// ============================================================================\n// DISPLAY NATURE RESOLUTION\n// ============================================================================\n\n/**\n * Mapping from schema-level `FileNature` to rendering-level `FileDisplayNature`.\n *\n * PDF and OFFICE both render as DOCUMENT.\n * ARCHIVE and ALL are GENERIC (no specialized renderer).\n */\nconst FILE_NATURE_TO_DISPLAY_NATURE: Record<FileNature, FileDisplayNature> = {\n [FileNature.IMAGE]: FileDisplayNature.IMAGE,\n [FileNature.VIDEO]: FileDisplayNature.VIDEO,\n [FileNature.AUDIO]: FileDisplayNature.AUDIO,\n [FileNature.PDF]: FileDisplayNature.DOCUMENT,\n [FileNature.OFFICE]: FileDisplayNature.DOCUMENT,\n [FileNature.ARCHIVE]: FileDisplayNature.GENERIC,\n [FileNature.ALL]: FileDisplayNature.GENERIC,\n};\n\n/**\n * Detect `FileDisplayNature` from a MIME type string.\n *\n * Used as a fallback when no `FileNature` is declared in schema metadata.\n */\nfunction detectDisplayNatureFromMimeType(mimeType: string): FileDisplayNature {\n if (mimeType.startsWith('image/')) return FileDisplayNature.IMAGE;\n if (mimeType.startsWith('video/')) return FileDisplayNature.VIDEO;\n if (mimeType.startsWith('audio/')) return FileDisplayNature.AUDIO;\n if (\n mimeType === 'application/pdf' ||\n mimeType.includes('document') || mimeType.includes('word') ||\n mimeType.includes('spreadsheet') || mimeType.includes('excel') ||\n mimeType.includes('presentation') || mimeType.includes('powerpoint')\n ) return FileDisplayNature.DOCUMENT;\n return FileDisplayNature.GENERIC;\n}\n\n/**\n * Resolve the rendering-level display nature for a file.\n *\n * Resolution priority:\n * 1. `schemaNature` (from `z_file({ nature: ... })` metadata) → mapped via `FILE_NATURE_TO_DISPLAY_NATURE`\n * 2. `mimeType` (from file metadata or browser File object) → detected via MIME prefix matching\n * 3. `FileDisplayNature.GENERIC` (fallback)\n *\n * `FileNature.ALL` is not a nature, it is the ABSENCE of a declaration: a field that accepts anything\n * says nothing about the file in front of it. So it does not decide at step 1 — the file's own MIME\n * type does, exactly as for a field with no declared nature. Until 2026-09-24 it mapped to GENERIC and\n * won, so every file in an open field, a PNG and a PDF included, resolved to GENERIC: no preview, and\n * an authored `OVERLAY` activation always degraded to a download. `resolveFileDisplayPolicy` already\n * describes the intended behaviour (\"the file's ACTUAL nature has no displayer — which is only\n * reachable when the schema declared an open nature\"); this is what makes that sentence true.\n * `FileNature.ARCHIVE` stays GENERIC at step 1, because that IS a declaration.\n *\n * @param schemaNature - The `FileNature` declared in schema metadata (from `getFileMetadata(schema)?.nature`)\n * @param mimeType - The MIME type of the actual file\n * @returns The `FileDisplayNature` to use for rendering\n *\n * @example\n * ```typescript\n * const displayNature = resolveFileDisplayNature(fileSchemaMetadata?.nature, metadata.mimeType)\n * // FileDisplayNature.IMAGE | .VIDEO | .AUDIO | .DOCUMENT | .GENERIC\n * ```\n */\nexport function resolveFileDisplayNature(\n schemaNature?: FileNature,\n mimeType?: string,\n): FileDisplayNature {\n // Priority 1: Schema-declared nature — `ALL` declares nothing, so it falls through to the file itself.\n if (schemaNature && schemaNature !== FileNature.ALL) {\n return FILE_NATURE_TO_DISPLAY_NATURE[schemaNature] ?? FileDisplayNature.GENERIC;\n }\n // Priority 2: MIME type detection\n if (mimeType) {\n return detectDisplayNatureFromMimeType(mimeType);\n }\n // Priority 3: Fallback\n return FileDisplayNature.GENERIC;\n}\n\n// ============================================================================\n// DISPLAY POLICY RESOLUTION (presentation × activation, + the availability guard)\n// ============================================================================\n\n/**\n * Whether the engine can RENDER a file of this nature/MIME (i.e. whether\n * `THUMBNAIL` / `FULL` presentation and `OVERLAY` activation are satisfiable).\n *\n * Nature alone is not always enough: `DOCUMENT` covers PDF *and* Office, and only\n * PDF has a viewer — so the MIME decides when it is known. Extend this (and only\n * this) when a new displayer ships; every guard tier reads it, so availability can\n * never drift between the static and runtime answers.\n */\nexport function fileNatureHasDisplayer(\n displayNature: FileDisplayNature,\n mimeType?: string,\n): boolean {\n switch (displayNature) {\n case FileDisplayNature.IMAGE:\n case FileDisplayNature.VIDEO:\n case FileDisplayNature.AUDIO:\n return true;\n case FileDisplayNature.DOCUMENT:\n // PDF renders (PDF.js); Office documents have no viewer yet. With no MIME\n // known (the static tier on a declared PDF nature) the answer is yes,\n // because `FileNature.PDF` maps here only for PDFs.\n return mimeType === undefined || mimeType === 'application/pdf';\n case FileDisplayNature.GENERIC:\n return false;\n }\n}\n\n/**\n * Whether a DECLARED schema nature can satisfy a display-requiring policy, decided\n * WITHOUT a MIME type. This is the static (registry-build) tier of the guard.\n *\n * Returns `undefined` for `FileNature.ALL` — genuinely undecidable before the file\n * exists, so the static tier must admit it and the runtime tier decides. Any other\n * nature yields a definite answer, which is what lets a misauthored\n * `ARCHIVE` + `FULL` fail at build instead of rendering nothing at runtime.\n */\nexport function declaredFileNatureCanDisplay(schemaNature: FileNature): boolean | undefined {\n if (schemaNature === FileNature.ALL) return undefined;\n return fileNatureHasDisplayer(FILE_NATURE_TO_DISPLAY_NATURE[schemaNature] ?? FileDisplayNature.GENERIC);\n}\n\n/** Outcome of {@link resolveFileDisplayPolicy}. */\nexport interface ResolvedFileDisplayPolicy {\n /** Effective resting presentation after the availability guard. */\n presentation: FileDisplayPresentation;\n /** Effective activation after the availability guard. */\n activation: FileActivationConfig;\n /** The nature the effective policy was resolved against. */\n displayNature: FileDisplayNature;\n /** True when the authored policy could not be satisfied and was degraded. */\n degraded: boolean;\n /** Human-readable cause, for the dev-only warning. Set iff `degraded`. */\n degradationReason?: string;\n}\n\n/**\n * Resolve the effective file display policy — the RUNTIME tier of the guard.\n *\n * Defaults, when nothing is authored: `CARD` presentation, and an activation derived\n * from the nature (`OVERLAY` when a displayer exists, `DOWNLOAD` otherwise) — so a\n * file is always useful without any authoring, and a document does not mount a\n * viewer just by being on the page.\n *\n * Degradation is deterministic, never a crash and never a dead control:\n * `FULL`/`THUMBNAIL` → `CARD`, `OVERLAY` → `DOWNLOAD`. It only fires when the file's\n * actual nature has no displayer — which is only reachable when the schema declared\n * an open nature (`FileNature.ALL`), because a narrow declared nature that cannot\n * display was already refused at registry build.\n *\n * `CUSTOM` is never degraded: it targets an operation, not a displayer, so displayer\n * availability is irrelevant to it.\n */\nexport function resolveFileDisplayPolicy(params: {\n schemaNature?: FileNature;\n mimeType?: string;\n authored?: FileUIDisplayParams;\n}): ResolvedFileDisplayPolicy {\n const { schemaNature, mimeType, authored } = params;\n const displayNature = resolveFileDisplayNature(schemaNature, mimeType);\n const hasDisplayer = fileNatureHasDisplayer(displayNature, mimeType);\n\n const requestedPresentation = authored?.presentation ?? FileDisplayPresentation.CARD;\n const requestedActivation: FileActivationConfig = authored?.activation ?? {\n policy: hasDisplayer ? FileActivationPolicy.OVERLAY : FileActivationPolicy.DOWNLOAD,\n };\n\n const presentationNeedsDisplayer = requestedPresentation !== FileDisplayPresentation.CARD;\n const activationNeedsDisplayer = requestedActivation.policy === FileActivationPolicy.OVERLAY;\n\n if (hasDisplayer || (!presentationNeedsDisplayer && !activationNeedsDisplayer)) {\n return { presentation: requestedPresentation, activation: requestedActivation, displayNature, degraded: false };\n }\n\n return {\n presentation: presentationNeedsDisplayer ? FileDisplayPresentation.CARD : requestedPresentation,\n activation: activationNeedsDisplayer ? { policy: FileActivationPolicy.DOWNLOAD } : requestedActivation,\n displayNature,\n degraded: true,\n degradationReason:\n `no displayer for ${displayNature}${mimeType ? ` (${mimeType})` : ''}: `\n + `${presentationNeedsDisplayer ? `presentation ${requestedPresentation} → card` : ''}`\n + `${presentationNeedsDisplayer && activationNeedsDisplayer ? ', ' : ''}`\n + `${activationNeedsDisplayer ? 'activation overlay → download' : ''}`,\n };\n}\n"]}
1
+ {"version":3,"file":"zod-file.js","sourceRoot":"","sources":["../../../src/zod-file.ts"],"names":[],"mappings":"AACA,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAG/E,OAAO,EAEL,eAAe,EAIf,kBAAkB,EA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,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,mBAAmB;QACtG,aAAa;QACb,QAAQ,EAAE,IAAI;QACd,iBAAiB,EACf,oBAAoB,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI;cACtE,GAAG,0BAA0B,CAAC,CAAC,CAAC,gBAAgB,qBAAqB,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;cACrF,GAAG,0BAA0B,IAAI,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;cACvE,GAAG,wBAAwB,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,EAAE,EAAE;KACzE,CAAC;AACJ,CAAC","sourcesContent":["\n// ============================================================================\n// FILE SCHEMA HELPER\n// ============================================================================\n\n\nimport {\n DecoratorInput,\n SCHEMA_METADATA,\n CustomFieldMetadata,\n FileSchemaMetadata,\n FileSchemaOptions,\n FileMimeTypeGroups,\n FileMimeTypeGroup,\n FileNature,\n FileDisplayNature,\n FileDisplayPresentation,\n FileActivationPolicy,\n type FileActivationConfig,\n type FileUIDisplayParams,\n FileStorageAccepted,\n FileNatureConstraints_Image,\n FileNatureConstraints_Video,\n FileNatureConstraints_Audio,\n FileNatureConstraints_Document,\n FileGenerationConfig,\n FileGenerationSource,\n RagSourceConfiguration,\n ZodDecorator,\n ZodDecorator_ParamsType\n} from \"./zod-decorators.types\";\nimport { z } from \"zod\";\nimport { addChainableMethods, addDecorators } from \"./zod.module-override\";\nimport { UnifiedFileFormatRegistry } from \"./files/unified-registry\";\nimport { AgentFileFormat } from \"./files/agent-file-formats\";\n\n// Minimal console declaration — avoids pulling in 'dom' or '@types/node' into this shared lib\ndeclare const console: { warn(...args: unknown[]): void };\n\n/**\n * Deduplicated warning tracker for unsupported storage providers.\n * Prevents console spam when the same schema is created multiple times (e.g., in tests or HMR).\n */\nconst _warnedStorageProviders = new Set<string>();\n/**\n * The storages the ENGINE serves itself. `GOOGLE_DRIVE` joined on 2026-09-09 (#394 P5): its bytes stay\n * in Drive, read and written through the connected account of the person who linked or uploaded them.\n * Any other member is served only when a loaded provider contributes an adapter (#1674) —\n * `ONEDRIVE` by the engine's `microsoft-onedrive` once scoped — which this decorator package cannot see, so it\n * warns about those members rather than refusing them.\n */\nconst _supportedProviders = new Set([FileStorageAccepted.WILDO_MANAGED, FileStorageAccepted.LOCAL_DIRECTORY, FileStorageAccepted.GOOGLE_DRIVE]);\nconst GENERATED_PDF_MIME_TYPES = ['application/pdf'] as const;\nconst GENERATION_METADATA_KEYS = new Set(['source', 'templateId']);\n\n/**\n * Single file value type - represents a single file reference stored in the database.\n * The actual file is stored in a file storage system, this object references it.\n */\nexport interface SingleFileValue {\n /** File ID (foreign key to file storage) */\n fileId: string;\n /** Last update timestamp */\n updatedAt: Date;\n\n}\n\n/**\n * Multiple files value type - represents multiple file references stored in the database.\n */\nexport interface MultipleFileValue {\n /** File IDs (foreign keys to file storage) */\n fileIds: string[];\n /** Last update timestamp */\n updatedAt: Date;\n}\n\n/**\n * File value type - can be single or multiple depending on schema configuration.\n */\nexport type FileValue = SingleFileValue | MultipleFileValue;\n\n/**\n * Zod schema for SingleFileValue.\n */\nexport const SingleFileValueSchema: z.ZodObject<{ fileId: z.ZodString; updatedAt: z.ZodDate }> = z.object({\n fileId: z.string().min(1).describe(\"The stored file's identifier. Read the file's details from the file metadata endpoint, or from `file` when the read populates files.\"),\n updatedAt: z.date().describe(\"When this file reference was last set.\"),\n});\n\n/**\n * Zod schema for MultipleFileValue.\n */\nexport const MultipleFileValueSchema: z.ZodObject<{ fileIds: z.ZodArray<z.ZodString>; updatedAt: z.ZodDate }> = z.object({\n fileIds: z.array(z.string().min(1)).describe(\"The stored files' identifiers, in order.\"),\n updatedAt: z.date().describe(\"When this file reference was last set.\"),\n});\n\n\n/**\n * Resolve MIME type groups to actual MIME types.\n * Handles both single group names and arrays of groups/MIME types.\n */\nexport function resolveMimeTypes(\n allowedMimeTypes: string[] | FileMimeTypeGroup | FileMimeTypeGroup[] | undefined\n): string[] | undefined {\n if (!allowedMimeTypes) return undefined;\n\n // If it's a single group name\n if (typeof allowedMimeTypes === 'string') {\n if (allowedMimeTypes in FileMimeTypeGroups) {\n return [...FileMimeTypeGroups[allowedMimeTypes as FileMimeTypeGroup]];\n }\n // Single MIME type\n return [allowedMimeTypes];\n }\n\n // If it's an array\n if (Array.isArray(allowedMimeTypes)) {\n const resolved: string[] = [];\n for (const item of allowedMimeTypes) {\n if (item in FileMimeTypeGroups) {\n // It's a group name\n resolved.push(...FileMimeTypeGroups[item as FileMimeTypeGroup]);\n } else {\n // It's a MIME type\n resolved.push(item);\n }\n }\n // Remove duplicates\n return [...new Set(resolved)];\n }\n\n return undefined;\n}\n\nfunction assertValidFileGenerationConfig(generation: FileGenerationConfig): void {\n const rawGeneration = generation as unknown as Record<string, unknown> | undefined;\n if (!rawGeneration || typeof rawGeneration !== 'object' || Array.isArray(rawGeneration)) {\n throw new Error('[z_file] generation must be an object.');\n }\n\n const extraKeys = Object.keys(rawGeneration).filter((key) => !GENERATION_METADATA_KEYS.has(key));\n if (extraKeys.length > 0) {\n throw new Error(\n `[z_file] generation contains unsupported key(s): ${extraKeys.join(', ')}. ` +\n 'Use only { source: FileGenerationSource.PDF_TEMPLATE, templateId }.'\n );\n }\n\n if (rawGeneration.source !== FileGenerationSource.PDF_TEMPLATE) {\n throw new Error('[z_file] generation.source must be FileGenerationSource.PDF_TEMPLATE.');\n }\n\n if (typeof rawGeneration.templateId !== 'string' || rawGeneration.templateId.trim().length === 0) {\n throw new Error('[z_file] generation.templateId must be a non-empty string.');\n }\n}\n\nfunction assertGeneratedPdfFileOptions(params: {\n generation?: FileGenerationConfig;\n multiple: boolean;\n resolvedMimeTypes?: string[];\n overridable: boolean;\n ragSource?: RagSourceConfiguration;\n scanPolicy?: unknown;\n}): void {\n if (!params.generation) return;\n\n assertValidFileGenerationConfig(params.generation);\n\n if (params.multiple) {\n throw new Error('[z_file] PDF template generation supports single-file fields only.');\n }\n\n if (params.overridable === false) {\n throw new Error('[z_file] PDF template generation requires overridable to remain true so framework REGENERATE can replace the generated file.');\n }\n\n // Re-expression of the pre-Phase-0 `rag` refusal against the shared decorator: a PDF-template\n // output is framework-RENDERED presentation of resource data the corpus can already reach at the\n // source fields — chunking the rendering would index the same facts twice, keyed to a file the\n // next REGENERATE silently replaces.\n if (params.ragSource) {\n throw new Error('[z_file] PDF template generation cannot be combined with RAG ingestion options.');\n }\n\n if (params.scanPolicy) {\n throw new Error('[z_file] PDF template generation cannot be combined with upload scanPolicy options.');\n }\n\n if (\n params.resolvedMimeTypes !== undefined &&\n (params.resolvedMimeTypes.length !== 1 || params.resolvedMimeTypes[0] !== GENERATED_PDF_MIME_TYPES[0])\n ) {\n throw new Error('[z_file] PDF template generation requires allowedMimeTypes to resolve exactly to application/pdf.');\n }\n}\n\n/**\n * z_file() - Creates file schemas for file uploads.\n *\n * File values are stored as: { fileId: string, updatedAt: Date }\n * - fileId: Reference to the file in storage (foreign key, indexed)\n * - updatedAt: When the file was last updated\n *\n * @example\n * ```typescript\n * import { z_file } from '@wildo-ai/zod-decorators';\n *\n * const avatar = z_file();\n * const document = z_file({ allowedMimeTypes: 'Documents' });\n * const images = z_file({\n * allowedMimeTypes: 'Images',\n * maxSize: 5 * 1024 * 1024, // 5MB\n * overridable: true\n * });\n *\n * // With decorators (chainable)\n * z_file().fileUI({ edit: { editMode: FileEditMode.DROPZONE } })\n * z_file({ allowedMimeTypes: ['Images', 'PDF'] }).isHidden({ edit: true })\n * ```\n */\n\n/**\n * @wildo_source:part:start zod.decorators.file-schema\n *\n * Creates a file schema with metadata for detection and form component rendering.\n *\n * ## Where a file field may be declared\n *\n * **The resource's primary scope must be application, organization or user.** A resource scoped to\n * an ANONYMOUS visitor cannot carry a file field — a file's own scope is one of those three, so\n * there is nothing to attribute the bytes to, and the upload refuses that scope by name rather than\n * pretending to support it.\n *\n * **Within the schema, a file field may nest inside objects, arrays and DISCRIMINATED unions.** It\n * may NOT sit inside a record, a map, a set, a tuple, or a plain (non-discriminated) union — the\n * walker that finds file fields refuses those shapes. Where variants are needed, use a discriminated\n * union.\n *\n * **A field carried on several branches of a discriminated union must declare IDENTICAL options on\n * every branch.** Differing options at one path are a conflict the framework refuses rather than\n * choosing between, so a branch that quietly widens `maxSize` or changes `allowedMimeTypes` fails\n * the schema instead of silently winning.\n *\n * ## Uploading is not attaching\n *\n * The generated upload route creates a FILE ROW. Attaching it to a business record is that record's\n * own write, with its own authority. So an uploaded-but-never-submitted file is a real state a\n * caller can produce; the cleanup sweep is what handles it.\n *\n * ## Declaring `imageConstraints.aspectRatio` turns the cropper on\n *\n * That option is the switch for the browser-side crop step — nothing else is wired. It applies to\n * single-file fields only: a `multiple` field keeps the plain upload path. Vector images and\n * formats the browser cannot decode bypass the cropper and upload the original, so the server-side\n * constraint stays the authority.\n *\n * @param options - Configuration options for file field\n * @returns A Zod object schema with metadata for file detection\n */\nexport function createFileSchema(\n options: FileSchemaOptions = {}\n): DecoratedFileSchema | DecoratedMultipleFileSchema {\n const {\n overridable = true,\n allowedMimeTypes,\n maxSize,\n minSize,\n multiple = false,\n maxFiles,\n nature,\n storageAccepted,\n filePathBinding,\n generation,\n imageConstraints,\n videoConstraints,\n audioConstraints,\n documentConstraints,\n ragSource,\n textExtraction,\n scanPolicy,\n onParentDelete = 'cascade',\n sharable,\n sharableDefaults,\n } = options;\n\n // Warn at schema creation for a storage the engine does not serve itself — served only if a provider package contributes it\n // Uses deduplication to avoid console spam during tests or HMR\n if (storageAccepted && storageAccepted.some(s => !_supportedProviders.has(s))) {\n const unsupported = storageAccepted.filter(s => !_supportedProviders.has(s));\n const warnKey = unsupported.sort().join(',');\n if (!_warnedStorageProviders.has(warnKey)) {\n _warnedStorageProviders.add(warnKey);\n // The two cases are NOT the same outcome, and saying only \"skipped\" understates the second\n // badly enough to be misleading: alongside an implemented storage the declaration really is\n // ignored, but as the ONLY declared storage it stops the application booting. That is the\n // split #460 records, stated here at the moment an author writes the declaration — earlier\n // than the startup validator and the storage router, which draw the same distinction.\n console.warn(\n `[z_file] storageAccepted names storage(s) the engine does not serve itself: ${unsupported.join(', ')}. ` +\n `The engine serves: ${[..._supportedProviders].map((s) => `'${s}'`).join(', ')}. ` +\n `Another storage is served only when a provider the application scopes contributes an adapter for it ` +\n `('onedrive': the engine's microsoft-onedrive provider). With none, declared ALONGSIDE a served storage it is ` +\n `skipped by the storage router; declared as the ONLY storage the application refuses to boot and every upload ` +\n `to this field is refused, and no environment variable enables it — a storage with no provider cannot be configured into existence.`\n );\n }\n }\n\n if (filePathBinding) {\n if (filePathBinding.multipleFilePolicy && !multiple) {\n console.warn(\n '[z_file] filePathBinding.multipleFilePolicy is set but multiple is false — multipleFilePolicy will be ignored. ' +\n 'Either set multiple: true or remove multipleFilePolicy.'\n );\n }\n if (filePathBinding.fileName && multiple) {\n console.warn(\n '[z_file] filePathBinding.fileName is set on a multiple file field — fileName is ignored for multiple uploads. ' +\n 'Use filePathBinding.multipleFilePolicy.fileNameTemplate instead.'\n );\n }\n // Warned for EVERY provider, not only WILDO_MANAGED. The condition used to exempt a field that\n // named LOCAL_DIRECTORY, because that provider defaulted to `false` anyway and the warning would\n // have fired on its own default. Both providers now default to `true` and both honour `false`\n // identically, so `false` is an explicit opt-out of the tenant-scoped key shape wherever it is\n // authored — and that is the thing worth saying out loud.\n if (filePathBinding.includeApplicationId === false) {\n console.warn(\n '[z_file] filePathBinding.includeApplicationId is false. Storage keys for this field will carry ' +\n 'NO applications/<appId>/files/<resource>/<scope>/<scopeId>/ prefix, so per-tenant listing, ' +\n 'erasure sweeps and prefix-confined credentials cannot address them — ensure that is intended.'\n );\n }\n }\n\n // Resolve MIME type groups to actual MIME types\n const resolvedMimeTypes = resolveMimeTypes(allowedMimeTypes);\n assertGeneratedPdfFileOptions({ generation, multiple, resolvedMimeTypes, overridable, ragSource, scanPolicy });\n const effectiveMimeTypes = generation ? [...GENERATED_PDF_MIME_TYPES] : resolvedMimeTypes;\n\n // Create the file object schema based on single/multiple\n const fileSchema = multiple\n ? z.object({\n fileIds: z.array(z.string().min(1)).describe(\"The stored files' identifiers, in order.\"),\n updatedAt: z.date().describe(\"When this file reference was last set.\"),\n })\n : z.object({\n fileId: z.string().min(1).describe(\"The stored file's identifier. Read the file's details from the file metadata endpoint, or from `file` when the read populates files.\"),\n updatedAt: z.date().describe(\"When this file reference was last set.\"),\n });\n\n // No longer stored in metadata — consumers derive accept from allowedMimeTypes via buildAcceptAttribute()\n\n // Store file metadata in SCHEMA_METADATA.fileConfig\n const fileMetadata: FileSchemaMetadata = {\n isFile: true,\n overridable,\n ...(effectiveMimeTypes !== undefined && { allowedMimeTypes: effectiveMimeTypes }),\n ...(maxSize !== undefined && { maxSize }),\n ...(minSize !== undefined && { minSize }),\n multiple,\n ...(maxFiles !== undefined && { maxFiles }),\n ...(nature !== undefined && { nature }),\n ...(storageAccepted !== undefined && { storageAccepted }),\n ...(filePathBinding !== undefined && { filePathBinding }),\n ...(generation !== undefined && { generation }),\n ...(imageConstraints !== undefined && { imageConstraints }),\n ...(videoConstraints !== undefined && { videoConstraints }),\n ...(audioConstraints !== undefined && { audioConstraints }),\n ...(documentConstraints !== undefined && { documentConstraints }),\n // Text-provider config only — the RAG declaration itself is NOT stored here (single source of\n // truth is the RAG_SOURCE decorator registered below; read it with `getRagSourceConfig`).\n ...(textExtraction !== undefined && { textExtraction }),\n ...(scanPolicy !== undefined && { scanPolicy }),\n onParentDelete,\n ...(sharable !== undefined && { sharable }),\n ...(sharableDefaults !== undefined && { sharableDefaults }),\n };\n\n // Initialize or extend SCHEMA_METADATA with file config\n const existingMetadata: CustomFieldMetadata = (fileSchema as any)[SCHEMA_METADATA] || {};\n (fileSchema as any)[SCHEMA_METADATA] = {\n ...existingMetadata,\n fileConfig: fileMetadata,\n };\n\n // Add chainable decorator methods to the file schema instance\n addChainableMethods(fileSchema);\n\n // Map the file-side `ragSource` option onto the SHARED RAG_SOURCE decorator — the same one\n // `z.string().ragSource()` registers — so `RagSourceFieldDetection` sees one uniform declaration\n // regardless of text provider. Registered through `addDecorators` (the escape-hatch door) because\n // the fluent `.ragSource()` is deliberately not installed on ZodObject; the shared chokepoint\n // still validates the config and enforces the refused companions identically.\n if (ragSource !== undefined) {\n addDecorators(fileSchema, [{ ref: ZodDecorator.RAG_SOURCE, params: ragSource }]);\n }\n\n if (multiple) {\n return fileSchema as unknown as DecoratedMultipleFileSchema;\n }\n return fileSchema as unknown as DecoratedFileSchema;\n}\n\n/**\n * File schemas declare NO decorator surface of their own.\n *\n * They used to, via a `FileSchemaDecoratorMethods<TSelf>` mixin that re-declared `isDBIndexed`,\n * `isHidden`, `isNotEditable` and `showWhen` with the return narrowed to the file schema — necessary\n * only because the `ZodObject` module augmentation did not carry them. It now does (2026-08-12), and\n * re-declaring them made both interfaces below fail TS2320: an interface may not extend two types\n * whose same-named member differs, and `TSelf` is not `DecoratedPrimitiveZodType<this>`.\n *\n * Removing the mixin costs nothing, because `DecoratedPrimitiveZodType<T>` is `T & { … }` — an\n * INTERSECTION. `z_file().isHidden()` still returns something assignable to `DecoratedFileSchema`,\n * and the full decorator surface is now available rather than the four this mixin listed.\n */\n\n/**\n * Return type for single file schemas - includes decorator methods.\n * IS_DB_INDEXED will index the fileId field for query optimization.\n *\n * Uses `interface` instead of `type` to allow self-referencing without circular alias errors.\n */\nexport interface DecoratedFileSchema extends z.ZodObject<{\n fileId: z.ZodString;\n updatedAt: z.ZodDate;\n}> {\n /**\n * Declared here, as the sibling factories declare theirs (`DecoratedMoneySchema.moneyUI`,\n * `DecoratedPhoneSchema.phoneUI`, …), because a file's display and edit policy is authored on\n * the factory's output and nowhere else. The applyable-type map admits `fileUI` on `ZodObject`,\n * but a bare `z.object({...})` is not a file, so the base prototype deliberately does not carry\n * it — the per-instance install `createFileSchema` performs is what makes it reachable.\n *\n * Not a RE-declaration: `fileUI` is absent from the `ZodObject` module augmentation, so this adds\n * a member rather than conflicting with one. That distinction is what the TS2320 note above is\n * about — re-declaring a member the augmentation already carries is what broke here before.\n */\n [ZodDecorator.FILE_UI](params?: ZodDecorator_ParamsType[ZodDecorator.FILE_UI]): DecoratedFileSchema;\n [ZodDecorator.FILE_SPEC](params?: ZodDecorator_ParamsType[ZodDecorator.FILE_SPEC]): DecoratedFileSchema;\n}\n\n/**\n * Return type for multiple file schemas - includes decorator methods.\n * IS_DB_INDEXED will index the fileIds array for query optimization.\n *\n * Uses `interface` instead of `type` to allow self-referencing without circular alias errors.\n */\nexport interface DecoratedMultipleFileSchema extends z.ZodObject<{\n fileIds: z.ZodArray<z.ZodString>;\n updatedAt: z.ZodDate;\n}> {\n /**\n * Declared here, as the sibling factories declare theirs (`DecoratedMoneySchema.moneyUI`,\n * `DecoratedPhoneSchema.phoneUI`, …), because a file's display and edit policy is authored on\n * the factory's output and nowhere else. The applyable-type map admits `fileUI` on `ZodObject`,\n * but a bare `z.object({...})` is not a file, so the base prototype deliberately does not carry\n * it — the per-instance install `createFileSchema` performs is what makes it reachable. Mirrors the single-file interface above.\n *\n * Not a RE-declaration: `fileUI` is absent from the `ZodObject` module augmentation, so this adds\n * a member rather than conflicting with one. That distinction is what the TS2320 note above is\n * about — re-declaring a member the augmentation already carries is what broke here before.\n */\n [ZodDecorator.FILE_UI](params?: ZodDecorator_ParamsType[ZodDecorator.FILE_UI]): DecoratedMultipleFileSchema;\n [ZodDecorator.FILE_SPEC](params?: ZodDecorator_ParamsType[ZodDecorator.FILE_SPEC]): DecoratedMultipleFileSchema;\n}\n\n/**\n * Creates a file schema for file uploads with reference storage.\n * Named z_file to indicate it's a Zod helper function exported standalone.\n *\n * Single file values are stored as: { fileId: string, updatedAt: Date }\n * Multiple file values are stored as: { fileIds: string[], updatedAt: Date }\n *\n * @example\n * ```typescript\n * import { z_file } from '@wildo-ai/zod-decorators';\n *\n * // Simple usage - single file, any type\n * z_file()\n *\n * // With MIME type groups (shortcuts)\n * z_file({ allowedMimeTypes: 'Images' })\n * z_file({ allowedMimeTypes: 'PDF' })\n * z_file({ allowedMimeTypes: ['Images', 'Video'] })\n * z_file({ allowedMimeTypes: 'Documents' }) // PDF + Office\n *\n * // With specific MIME types\n * z_file({ allowedMimeTypes: ['image/png', 'image/jpeg'] })\n *\n * // With size constraints\n * z_file({ maxSize: 10 * 1024 * 1024 }) // 10MB max\n *\n * // Multiple files (uses fileIds instead of fileId)\n * z_file({ multiple: true, maxFiles: 5 })\n *\n * // Non-overridable (append-only)\n * z_file({ overridable: false })\n *\n * // RAG corpus source — registers the shared RAG_SOURCE decorator on the returned schema\n * // (chunking config), with the file-side text-provider knobs beside it (OCR opt-in).\n * z_file({ allowedMimeTypes: 'Documents', ragSource: {}, textExtraction: { ocr: true } })\n *\n * // With decorators\n * z_file().fileUI({ edit: { editMode: FileEditMode.DROPZONE } })\n * z_file().isHidden({ display: true })\n * ```\n */\nexport function z_file(options?: FileSchemaOptions): DecoratedFileSchema | DecoratedMultipleFileSchema {\n return createFileSchema(options);\n}\n/** @wildo_source:part:end zod.decorators.file-schema */\n\n// ============================================================================\n// UTILITY FUNCTIONS\n// ============================================================================\n\n/**\n * Format file size for display.\n */\nexport function formatFileSize(bytes: number): string {\n if (!Number.isFinite(bytes)) return '—';\n if (bytes === 0) return '0 B';\n if (bytes < 0) return '-' + formatFileSize(Math.abs(bytes));\n\n const units = ['B', 'KB', 'MB', 'GB', 'TB'];\n const k = 1024;\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${units[i]}`;\n}\n\n/**\n * Build enhanced accept attribute string from MIME types.\n * Includes both MIME types and extensions for better browser compatibility.\n * Format: \"image/*,.jpg,.jpeg,.png\" or \"application/pdf,.pdf\"\n *\n * @param mimeTypes - Array of MIME type strings\n * @returns Accept attribute string with MIME types and extensions\n */\nexport function buildAcceptAttribute(mimeTypes: string[]): string {\n if (!mimeTypes || mimeTypes.length === 0) return '';\n\n const parts = new Set<string>();\n const extensions = new Set<string>();\n\n for (const mimeType of mimeTypes) {\n // Add MIME type\n parts.add(mimeType);\n\n // Get extensions for this MIME type\n const mimeExtensions = UnifiedFileFormatRegistry.getExtensions(mimeType);\n for (const ext of mimeExtensions) {\n if (ext) {\n extensions.add(`.${ext}`);\n }\n }\n\n // Also check if it's a wildcard MIME type (e.g., image/*)\n // In that case, get all extensions for that nature\n if (mimeType.endsWith('/*')) {\n const formatType = UnifiedFileFormatRegistry.getFormatTypeFromMimeType(mimeType);\n\n if (formatType && formatType.type === 'nature') {\n const natureExtensions = UnifiedFileFormatRegistry.getExtensionsForNature(formatType.nature);\n for (const ext of natureExtensions) {\n if (ext) {\n extensions.add(`.${ext}`);\n }\n }\n }\n }\n }\n\n // Combine MIME types and extensions\n const allParts = [...parts, ...extensions];\n return allParts.join(',');\n}\n\n/**\n * Get file extension from filename.\n * Uses UnifiedFileFormatRegistry for consistency.\n */\nexport function getFileExtension(filename: string): string {\n return UnifiedFileFormatRegistry.getFileExtension(filename);\n}\n\n/**\n * Check if a MIME type is allowed based on allowed types.\n */\nexport function isMimeTypeAllowed(mimeType: string, allowedMimeTypes?: string[]): boolean {\n if (!allowedMimeTypes || allowedMimeTypes.length === 0) return true;\n\n // Check exact match\n if (allowedMimeTypes.includes(mimeType)) return true;\n\n // Check wildcard match (e.g., \"image/*\")\n const [type] = mimeType.split('/');\n if (allowedMimeTypes.includes(`${type}/*`)) return true;\n\n return false;\n}\n\n/**\n * How an accepted file type is identified — the discriminator of {@link AcceptedFileKind}.\n */\nexport enum AcceptedFileKindCategory {\n /** A broad nature (images, PDF, office documents, …) — one {@link FileNature} member. */\n NATURE = 'nature',\n /** A text format an agent can produce — one {@link AgentFileFormat} member. */\n AGENT_FORMAT = 'agent_format',\n /** Neither: the MIME subtype itself (`csv` for `text/csv`), shown as the value it is. */\n MIME_SUBTYPE = 'mime_subtype',\n}\n\n/** One kind of file a field accepts, as a FACT a renderer names — never as words. */\nexport type AcceptedFileKind =\n | { category: AcceptedFileKindCategory.NATURE; nature: FileNature }\n | { category: AcceptedFileKindCategory.AGENT_FORMAT; format: AgentFileFormat }\n | { category: AcceptedFileKindCategory.MIME_SUBTYPE; subtype: string };\n\nconst AGENT_FILE_FORMAT_VALUES: ReadonlySet<string> = new Set(Object.values(AgentFileFormat));\n\n/**\n * The kinds of file a field's `allowedMimeTypes` admit, deduplicated, in first-seen order. An empty\n * result means every file is accepted.\n *\n * This answers FACTS and the renderer names them from its label tree. It used to answer an English\n * sentence (\"Images, PDF, Text files\") from two hand-kept maps plus a humanizing fallback — words\n * produced by code in a package with no i18n at all, which no locale could translate (#1283,\n * `.claude/rules/display-text-comes-from-i18n.md`).\n *\n * Resolution per MIME type: the unified format registry first (a nature, or an agent format), then\n * the broad MIME families the registry does not classify, then the subtype as a value.\n */\nexport function getAcceptedFileKinds(allowedMimeTypes?: string[]): AcceptedFileKind[] {\n if (!allowedMimeTypes || allowedMimeTypes.length === 0) return [];\n\n const kinds: AcceptedFileKind[] = [];\n const seen = new Set<string>();\n const add = (kind: AcceptedFileKind, identity: string): void => {\n if (seen.has(identity)) return;\n seen.add(identity);\n kinds.push(kind);\n };\n const addNature = (nature: FileNature): void => add({ category: AcceptedFileKindCategory.NATURE, nature }, `nature:${nature}`);\n\n for (const mime of allowedMimeTypes) {\n const formatType = UnifiedFileFormatRegistry.getFormatTypeFromMimeType(mime);\n if (formatType?.type === 'nature') {\n addNature(formatType.nature);\n continue;\n }\n if (formatType?.type === 'agent' && AGENT_FILE_FORMAT_VALUES.has(formatType.format)) {\n const format = formatType.format as AgentFileFormat;\n add({ category: AcceptedFileKindCategory.AGENT_FORMAT, format }, `agent:${format}`);\n continue;\n }\n\n if (mime === 'application/pdf') addNature(FileNature.PDF);\n else if (mime.startsWith('image/')) addNature(FileNature.IMAGE);\n else if (mime.startsWith('video/')) addNature(FileNature.VIDEO);\n else if (mime.startsWith('audio/')) addNature(FileNature.AUDIO);\n else if (mime.includes('document') || mime.includes('word') || mime.includes('excel') || mime.includes('powerpoint')) addNature(FileNature.OFFICE);\n else {\n const subtype = mime.split('/').pop();\n if (subtype) add({ category: AcceptedFileKindCategory.MIME_SUBTYPE, subtype }, `subtype:${subtype}`);\n }\n }\n return kinds;\n}\n\n/**\n * Get file nature from schema metadata.\n * @param schema - Zod schema (must be a file schema)\n * @returns FileNature or undefined if not set\n */\nexport function getFileNature(schema: z.ZodTypeAny): FileNature | undefined {\n const metadata = (schema as any)[SCHEMA_METADATA] as CustomFieldMetadata | undefined;\n return metadata?.fileConfig?.nature;\n}\n\n/**\n * Get storage accepted from schema metadata.\n * @param schema - Zod schema (must be a file schema)\n * @returns Array of FileStorageAccepted or undefined if not set\n */\nexport function getStorageAccepted(schema: z.ZodTypeAny): FileStorageAccepted[] | undefined {\n const metadata = (schema as any)[SCHEMA_METADATA] as CustomFieldMetadata | undefined;\n return metadata?.fileConfig?.storageAccepted;\n}\n\n/**\n * Get file constraints from schema metadata.\n * @param schema - Zod schema (must be a file schema)\n * @returns Object with all constraint properties or undefined if not set\n */\nexport function getFileConstraints(schema: z.ZodTypeAny): {\n imageConstraints?: FileNatureConstraints_Image;\n videoConstraints?: FileNatureConstraints_Video;\n audioConstraints?: FileNatureConstraints_Audio;\n documentConstraints?: FileNatureConstraints_Document;\n} | undefined {\n const metadata = (schema as any)[SCHEMA_METADATA] as CustomFieldMetadata | undefined;\n const fileConfig = metadata?.fileConfig;\n if (!fileConfig) return undefined;\n\n const hasConstraints =\n fileConfig.imageConstraints ||\n fileConfig.videoConstraints ||\n fileConfig.audioConstraints ||\n fileConfig.documentConstraints;\n\n if (!hasConstraints) return undefined;\n\n return {\n ...(fileConfig.imageConstraints && { imageConstraints: fileConfig.imageConstraints }),\n ...(fileConfig.videoConstraints && { videoConstraints: fileConfig.videoConstraints }),\n ...(fileConfig.audioConstraints && { audioConstraints: fileConfig.audioConstraints }),\n ...(fileConfig.documentConstraints && { documentConstraints: fileConfig.documentConstraints }),\n };\n}\n\n// ============================================================================\n// DISPLAY NATURE RESOLUTION\n// ============================================================================\n\n/**\n * Mapping from schema-level `FileNature` to rendering-level `FileDisplayNature`.\n *\n * PDF and OFFICE both render as DOCUMENT.\n * ARCHIVE and ALL are GENERIC (no specialized renderer).\n */\nconst FILE_NATURE_TO_DISPLAY_NATURE: Record<FileNature, FileDisplayNature> = {\n [FileNature.IMAGE]: FileDisplayNature.IMAGE,\n [FileNature.VIDEO]: FileDisplayNature.VIDEO,\n [FileNature.AUDIO]: FileDisplayNature.AUDIO,\n [FileNature.PDF]: FileDisplayNature.DOCUMENT,\n [FileNature.OFFICE]: FileDisplayNature.DOCUMENT,\n [FileNature.ARCHIVE]: FileDisplayNature.GENERIC,\n [FileNature.ALL]: FileDisplayNature.GENERIC,\n};\n\n/**\n * Detect `FileDisplayNature` from a MIME type string.\n *\n * Used as a fallback when no `FileNature` is declared in schema metadata.\n */\nfunction detectDisplayNatureFromMimeType(mimeType: string): FileDisplayNature {\n if (mimeType.startsWith('image/')) return FileDisplayNature.IMAGE;\n if (mimeType.startsWith('video/')) return FileDisplayNature.VIDEO;\n if (mimeType.startsWith('audio/')) return FileDisplayNature.AUDIO;\n if (\n mimeType === 'application/pdf' ||\n mimeType.includes('document') || mimeType.includes('word') ||\n mimeType.includes('spreadsheet') || mimeType.includes('excel') ||\n mimeType.includes('presentation') || mimeType.includes('powerpoint')\n ) return FileDisplayNature.DOCUMENT;\n return FileDisplayNature.GENERIC;\n}\n\n/**\n * Resolve the rendering-level display nature for a file.\n *\n * Resolution priority:\n * 1. `schemaNature` (from `z_file({ nature: ... })` metadata) → mapped via `FILE_NATURE_TO_DISPLAY_NATURE`\n * 2. `mimeType` (from file metadata or browser File object) → detected via MIME prefix matching\n * 3. `FileDisplayNature.GENERIC` (fallback)\n *\n * `FileNature.ALL` is not a nature, it is the ABSENCE of a declaration: a field that accepts anything\n * says nothing about the file in front of it. So it does not decide at step 1 — the file's own MIME\n * type does, exactly as for a field with no declared nature. Until 2026-09-24 it mapped to GENERIC and\n * won, so every file in an open field, a PNG and a PDF included, resolved to GENERIC: no preview, and\n * an authored `OVERLAY` activation always degraded to a download. `resolveFileDisplayPolicy` already\n * describes the intended behaviour (\"the file's ACTUAL nature has no displayer — which is only\n * reachable when the schema declared an open nature\"); this is what makes that sentence true.\n * `FileNature.ARCHIVE` stays GENERIC at step 1, because that IS a declaration.\n *\n * @param schemaNature - The `FileNature` declared in schema metadata (from `getFileMetadata(schema)?.nature`)\n * @param mimeType - The MIME type of the actual file\n * @returns The `FileDisplayNature` to use for rendering\n *\n * @example\n * ```typescript\n * const displayNature = resolveFileDisplayNature(fileSchemaMetadata?.nature, metadata.mimeType)\n * // FileDisplayNature.IMAGE | .VIDEO | .AUDIO | .DOCUMENT | .GENERIC\n * ```\n */\nexport function resolveFileDisplayNature(\n schemaNature?: FileNature,\n mimeType?: string,\n): FileDisplayNature {\n // Priority 1: Schema-declared nature — `ALL` declares nothing, so it falls through to the file itself.\n if (schemaNature && schemaNature !== FileNature.ALL) {\n return FILE_NATURE_TO_DISPLAY_NATURE[schemaNature] ?? FileDisplayNature.GENERIC;\n }\n // Priority 2: MIME type detection\n if (mimeType) {\n return detectDisplayNatureFromMimeType(mimeType);\n }\n // Priority 3: Fallback\n return FileDisplayNature.GENERIC;\n}\n\n// ============================================================================\n// DISPLAY POLICY RESOLUTION (presentation × activation, + the availability guard)\n// ============================================================================\n\n/**\n * Whether the engine can RENDER a file of this nature/MIME (i.e. whether\n * `THUMBNAIL` / `FULL` presentation and `OVERLAY` activation are satisfiable).\n *\n * Nature alone is not always enough: `DOCUMENT` covers PDF *and* Office, and only\n * PDF has a viewer — so the MIME decides when it is known. Extend this (and only\n * this) when a new displayer ships; every guard tier reads it, so availability can\n * never drift between the static and runtime answers.\n */\nexport function fileNatureHasDisplayer(\n displayNature: FileDisplayNature,\n mimeType?: string,\n): boolean {\n switch (displayNature) {\n case FileDisplayNature.IMAGE:\n case FileDisplayNature.VIDEO:\n case FileDisplayNature.AUDIO:\n return true;\n case FileDisplayNature.DOCUMENT:\n // PDF renders (PDF.js); Office documents have no viewer yet. With no MIME\n // known (the static tier on a declared PDF nature) the answer is yes,\n // because `FileNature.PDF` maps here only for PDFs.\n return mimeType === undefined || mimeType === 'application/pdf';\n case FileDisplayNature.GENERIC:\n return false;\n }\n}\n\n/**\n * Whether a DECLARED schema nature can satisfy a display-requiring policy, decided\n * WITHOUT a MIME type. This is the static (registry-build) tier of the guard.\n *\n * Returns `undefined` for `FileNature.ALL` — genuinely undecidable before the file\n * exists, so the static tier must admit it and the runtime tier decides. Any other\n * nature yields a definite answer, which is what lets a misauthored\n * `ARCHIVE` + `FULL` fail at build instead of rendering nothing at runtime.\n */\nexport function declaredFileNatureCanDisplay(schemaNature: FileNature): boolean | undefined {\n if (schemaNature === FileNature.ALL) return undefined;\n return fileNatureHasDisplayer(FILE_NATURE_TO_DISPLAY_NATURE[schemaNature] ?? FileDisplayNature.GENERIC);\n}\n\n/** Outcome of {@link resolveFileDisplayPolicy}. */\nexport interface ResolvedFileDisplayPolicy {\n /** Effective resting presentation after the availability guard. */\n presentation: FileDisplayPresentation;\n /** Effective activation after the availability guard. */\n activation: FileActivationConfig;\n /** The nature the effective policy was resolved against. */\n displayNature: FileDisplayNature;\n /** True when the authored policy could not be satisfied and was degraded. */\n degraded: boolean;\n /** Human-readable cause, for the dev-only warning. Set iff `degraded`. */\n degradationReason?: string;\n}\n\n/**\n * Resolve the effective file display policy — the RUNTIME tier of the guard.\n *\n * Defaults, when nothing is authored: `CARD` presentation, and an activation derived\n * from the nature (`OVERLAY` when a displayer exists, `DOWNLOAD` otherwise) — so a\n * file is always useful without any authoring, and a document does not mount a\n * viewer just by being on the page.\n *\n * Degradation is deterministic, never a crash and never a dead control:\n * `FULL`/`THUMBNAIL` → `CARD`, `OVERLAY` → `DOWNLOAD`. It only fires when the file's\n * actual nature has no displayer — which is only reachable when the schema declared\n * an open nature (`FileNature.ALL`), because a narrow declared nature that cannot\n * display was already refused at registry build.\n *\n * `CUSTOM` is never degraded: it targets an operation, not a displayer, so displayer\n * availability is irrelevant to it.\n */\nexport function resolveFileDisplayPolicy(params: {\n schemaNature?: FileNature;\n mimeType?: string;\n authored?: FileUIDisplayParams;\n}): ResolvedFileDisplayPolicy {\n const { schemaNature, mimeType, authored } = params;\n const displayNature = resolveFileDisplayNature(schemaNature, mimeType);\n const hasDisplayer = fileNatureHasDisplayer(displayNature, mimeType);\n\n const requestedPresentation = authored?.presentation ?? FileDisplayPresentation.CARD;\n const requestedActivation: FileActivationConfig = authored?.activation ?? {\n policy: hasDisplayer ? FileActivationPolicy.OVERLAY : FileActivationPolicy.DOWNLOAD,\n };\n\n const presentationNeedsDisplayer = requestedPresentation !== FileDisplayPresentation.CARD;\n const activationNeedsDisplayer = requestedActivation.policy === FileActivationPolicy.OVERLAY;\n\n if (hasDisplayer || (!presentationNeedsDisplayer && !activationNeedsDisplayer)) {\n return { presentation: requestedPresentation, activation: requestedActivation, displayNature, degraded: false };\n }\n\n return {\n presentation: presentationNeedsDisplayer ? FileDisplayPresentation.CARD : requestedPresentation,\n activation: activationNeedsDisplayer ? { policy: FileActivationPolicy.DOWNLOAD } : requestedActivation,\n displayNature,\n degraded: true,\n degradationReason:\n `no displayer for ${displayNature}${mimeType ? ` (${mimeType})` : ''}: `\n + `${presentationNeedsDisplayer ? `presentation ${requestedPresentation} → card` : ''}`\n + `${presentationNeedsDisplayer && activationNeedsDisplayer ? ', ' : ''}`\n + `${activationNeedsDisplayer ? 'activation overlay → download' : ''}`,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"zod-money.d.ts","sourceRoot":"","sources":["../../src/zod-money.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAA6D,kBAAkB,EAAE,kBAAkB,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAClM,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,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ChC,CAAC,CAAC,GAAG,MAAM,IAAI,eAAe,EAAE;QAChC,CAAC,CAAC,GAAG,eAAe,IAAI,MAAM,EAAE,CAAC;AACrC,CAAC","sourcesContent":["\n// ============================================================================\n// MONEY SCHEMA HELPER\n// ============================================================================\n\nimport { DecoratorInput, SCHEMA_METADATA, CustomFieldMetadata, MoneySchemaMetadata, MoneySchemaOptions, SummaryFieldParams, ZodDecorator, ZodDecorator_ParamsType } from \"./zod-decorators.types\";\nimport { z } from \"zod\";\nimport { addChainableMethods } from \"./zod.module-override\";\nimport { CurrencySchema, currencyMinorUnitDecimals } from \"./currencies.shared.schemas\";\n\n/**\n * Money value type - represents a monetary amount with bigint storage.\n *\n * The amount is stored as a bigint in the smallest unit (e.g., cents for USD).\n * Using bigint ensures no precision loss for arbitrarily large amounts.\n * The decimals field indicates how to convert to the display value:\n * - displayValue = Number(amount) / (10 ** decimals)\n *\n * Example: { amount: 1999n, currency: 'USD', decimals: 2 } = $19.99\n */\nexport interface MoneyValue {\n /**\n * Amount in smallest unit (e.g., cents). BigInt to avoid precision issues with\n * large amounts.\n *\n * WIRE CONTRACT: a `bigint` has no JSON form, so on the wire (and at rest in\n * Mongo) this amount is a decimal STRING (e.g. `\"1999\"`). Outbound it is encoded\n * by `BigInt.prototype.toJSON` (`installBigIntJsonEncoding`, same package);\n * inbound it is coerced back to `bigint` by `applyNetworkBoundaryCoercion`\n * (`@wildo-ai/saas-models`) on the shared request/response DTO — so both the\n * frontend and backend hold a real `bigint` at runtime. Full mechanism map:\n * `install-bigint-json-encoding.ts`.\n */\n amount: bigint;\n /** ISO 4217 currency code (e.g., 'USD', 'EUR', 'BTC') */\n currency: string;\n /** Number of decimal places for display (e.g., 2 for USD, 8 for BTC) */\n decimals: number;\n}\n\n/**\n * Zod schema for MoneyValue.\n */\nexport const MoneyValueSchema: z.ZodObject<{ amount: z.ZodBigInt; currency: typeof CurrencySchema; decimals: z.ZodNumber }> = z.object({\n amount: z.bigint().describe(\"The amount in the currency's smallest unit, such as cents, as an integer. Sent as a decimal string (`\\\"1999\\\"`), because it can exceed what a JSON number holds exactly.\"),\n currency: CurrencySchema.describe(\"The ISO 4217 currency code, such as `USD` or `EUR`.\"),\n decimals: z.number().int().min(0).max(18).describe(\"How many decimal places the currency uses, to turn `amount` into a displayed value: `1999` with 2 decimals is 19.99.\"),\n});\n\n/**\n * @wildo_source:part:start zod.factories.money facet:layer:shared facet:family:schema-factory\n *\n * z_money() - Creates money schemas for financial amounts.\n *\n * Money values are stored as integers to avoid floating-point precision issues.\n * The schema creates an object with: { amount, currency, decimals }\n *\n * @example\n * ```typescript\n * import { z_money } from '@wildo-ai/zod-decorators';\n *\n * const price = z_money();\n * const fiatPrice = z_money({ currenciesAllowed: [CurrencyAllowed.FIAT] });\n * const usdPrice = z_money({ allowCurrencyChange: false }).moneyUI({ edit: { defaultCurrency: 'USD' } });\n *\n * // With decorators (chainable)\n * z_money().moneyUI({ edit: { defaultCurrency: 'EUR' } })\n * z_money({ currenciesAllowed: [CurrencyAllowed.FIAT_MAJOR] }).isHidden({ edit: true })\n * ```\n */\n\n/**\n * Creates a money schema with metadata for detection and form component rendering.\n *\n * @param options - Configuration options for money field\n * @returns A Zod object schema with metadata for money detection\n *\n * @example\n * ```typescript\n * // Simple money (all currencies)\n * const price = z_money();\n * // Infers: { amount: bigint, currency: string, decimals: number }\n *\n * // Fiat only (no crypto)\n * const fiatPrice = z_money({ currenciesAllowed: [CurrencyAllowed.FIAT] });\n *\n * // Fixed currency with amount constraints\n * const usdPrice = z_money({\n * allowCurrencyChange: false,\n * minAmount: 0n,\n * maxAmount: 100000000n // $1,000,000.00 in cents\n * }).moneyUI({ edit: { defaultCurrency: 'USD' } });\n * ```\n */\nexport function createMoneySchema(\n options: MoneySchemaOptions = {}\n): DecoratedMoneySchema {\n const {\n currenciesAllowed,\n appEnabledOnly = true,\n allowCurrencyChange = true,\n minAmount,\n maxAmount,\n } = options;\n\n // Create the amount schema with optional min/max constraints\n // Using bigint for amount to avoid precision issues with large financial amounts\n let amountSchema = z.bigint();\n if (minAmount !== undefined) {\n amountSchema = amountSchema.min(minAmount);\n }\n if (maxAmount !== undefined) {\n amountSchema = amountSchema.max(maxAmount);\n }\n\n // Create the money object schema\n const moneySchema = z.object({\n amount: amountSchema.describe(\"The amount in the currency's smallest unit, such as cents, as an integer. Sent as a decimal string (`\\\"1999\\\"`), because it can exceed what a JSON number holds exactly.\"),\n currency: CurrencySchema.describe(\"The ISO 4217 currency code, such as `USD` or `EUR`.\"),\n decimals: z.number().int().min(0).max(18).describe(\"How many decimal places the currency uses, to turn `amount` into a displayed value: `1999` with 2 decimals is 19.99.\"),\n });\n\n const moneyMetadata: MoneySchemaMetadata = {\n isMoney: true,\n ...(currenciesAllowed && currenciesAllowed.length > 0 && { currenciesAllowed }),\n appEnabledOnly,\n allowCurrencyChange,\n ...(minAmount !== undefined && { minAmount }),\n ...(maxAmount !== undefined && { maxAmount }),\n };\n\n // Initialize or extend SCHEMA_METADATA with money config\n const existingMetadata: CustomFieldMetadata = (moneySchema as any)[SCHEMA_METADATA] || {};\n (moneySchema as any)[SCHEMA_METADATA] = {\n ...existingMetadata,\n moneyConfig: moneyMetadata,\n };\n\n // Add chainable decorator methods to the money schema instance\n // This allows: z_money().moneyUI({ edit: { defaultCurrency: 'EUR' } }).isHidden()\n addChainableMethods(moneySchema);\n\n return moneySchema as DecoratedMoneySchema;\n}\n\n/**\n * Return type for money schemas - includes decorator methods.\n * Note: IS_FOREIGN_KEY is not applicable to money objects.\n * IS_DB_INDEXED will index internal fields (amount, currency) for query optimization.\n *\n * This type must list all decorators applicable to ZodObject (per ApplyableTypeAllTypes).\n * Missing entries here cause TS errors when chaining decorators on z_money() fields.\n */\nexport type DecoratedMoneySchema = z.ZodObject<{\n amount: z.ZodBigInt;\n currency: typeof CurrencySchema;\n decimals: z.ZodNumber;\n}> & {\n [ZodDecorator.IS_DB_INDEXED](): DecoratedMoneySchema;\n /** Installed at runtime with the other chainable methods; declared here so an authored `.moneyUI(…)` typechecks. */\n [ZodDecorator.MONEY_UI](params?: ZodDecorator_ParamsType[ZodDecorator.MONEY_UI]): DecoratedMoneySchema;\n [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): DecoratedMoneySchema;\n [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): DecoratedMoneySchema;\n // Resource-level decorators (applicable to all types including ZodObject)\n [ZodDecorator.IS_SUMMARY_FIELD](params?: SummaryFieldParams): DecoratedMoneySchema;\n [ZodDecorator.IS_BACKEND_ONLY](params?: ZodDecorator_ParamsType[ZodDecorator.IS_BACKEND_ONLY]): DecoratedMoneySchema;\n [ZodDecorator.IS_WRITE_ONLY_SECRET](params?: ZodDecorator_ParamsType[ZodDecorator.IS_WRITE_ONLY_SECRET]): DecoratedMoneySchema;\n [ZodDecorator.EXCLUDE_FROM_CREATE](): DecoratedMoneySchema;\n [ZodDecorator.EXCLUDE_FROM_UPDATE](): DecoratedMoneySchema;\n addDecorators(decorators: DecoratorInput[]): DecoratedMoneySchema;\n};\n\n/**\n * Creates a money schema for financial amounts with integer storage.\n * Named z_money to indicate it's a Zod helper function exported standalone.\n *\n * Money values are stored as: { amount: int, currency: string, decimals: int }\n * - amount: Value in smallest unit (e.g., cents for USD, satoshis for BTC)\n * - currency: ISO 4217 code (e.g., 'USD', 'EUR', 'BTC')\n * - decimals: Decimal places for display conversion (e.g., 2 for USD, 8 for BTC)\n *\n * @example\n * ```typescript\n * import { z_money } from '@wildo-ai/zod-decorators';\n *\n * // Simple usage\n * z_money() // All currencies\n *\n * // With options\n * z_money({ currenciesAllowed: [CurrencyAllowed.FIAT] })\n * z_money({ allowCurrencyChange: false }).moneyUI({ edit: { defaultCurrency: 'USD' } })\n * z_money({ currenciesAllowed: [CurrencyAllowed.FIAT_MAJOR], minAmount: 0n })\n *\n * // With decorators (chainable)\n * z_money().moneyUI({ edit: { defaultCurrency: 'USD' } })\n * z_money({ currenciesAllowed: [CurrencyAllowed.FIAT] }).isHidden({ edit: true })\n *\n * // Usage example\n * const price: MoneyValue = { amount: 1999n, currency: 'USD', decimals: 2 };\n * // Represents $19.99\n * ```\n */\nexport function z_money(\n options?: MoneySchemaOptions\n): DecoratedMoneySchema {\n return createMoneySchema(options) as DecoratedMoneySchema;\n}\n/** @wildo_source:part:end zod.factories.money */\n\n// ============================================================================\n// MONEY UTILITY FUNCTIONS\n// ============================================================================\n\n/**\n * Why an amount could not be expressed in its currency's smallest unit.\n *\n * A named vocabulary rather than three bare strings, because each member has a DIFFERENT remedy and\n * an operator reading a sync log needs to know which one they are looking at: an unknown minor unit\n * is a catalogue problem, a precision loss is an authoring problem, and an unsafe magnitude is a\n * limit of the provider's own number type.\n */\nexport enum MoneyMinorUnitConversionFailure {\n /** The currency has no minor unit (`XDR`, `XXX`) or is not one this vocabulary knows. */\n UNKNOWN_MINOR_UNIT = 'unknown_minor_unit',\n /** Converting down would discard a fraction of the provider's smallest unit. */\n PRECISION_LOSS = 'precision_loss',\n /** The converted amount cannot be represented exactly as a JavaScript number. */\n UNSAFE_MAGNITUDE = 'unsafe_magnitude',\n}\n\n/** Thrown by {@link toCurrencyMinorUnitAmountOrThrow}; carries the reason so a caller can branch. */\nexport class MoneyMinorUnitConversionError extends Error {\n constructor(\n public readonly reason: MoneyMinorUnitConversionFailure,\n message: string,\n ) {\n super(message);\n this.name = 'MoneyMinorUnitConversionError';\n }\n}\n\n/**\n * Convert a {@link MoneyValue} to the amount a payment provider expects: an integer in the CURRENCY's\n * smallest unit.\n *\n * Wildo stores money at an AUTHORED scale (`decimals` on the value); a provider reads it at the\n * currency's own scale. Those are two different numbers whenever they disagree, and until 2026-09-08\n * the billing boundary sent the stored amount straight through — so a price authored at any scale\n * other than the currency's was charged at the wrong magnitude, by a factor of 10 per decimal place\n * of disagreement.\n *\n * **All arithmetic is `bigint`.** The stored amount already is one, and the whole reason it is a\n * bigint rather than a number is that money must not round; converting through a float to save a cast\n * would give that back at exactly the boundary where it costs money.\n *\n * **Scaling UP is always exact. Scaling DOWN refuses on a remainder rather than rounding** — a price\n * of 1.005 in a currency whose smallest unit is a cent is not 1.00 and not 1.01, it is a price the\n * provider cannot express, and silently picking one is how a catalogue and an invoice come to\n * disagree by a cent per unit forever.\n *\n * **Throws rather than returning a result union**, and the reason is the compiler rather than taste:\n * this repository compiles with `strict: false` (`engine/tsconfig.common.json`), which disables the\n * discriminant narrowing a `{ ok: true } | { ok: false }` result depends on — so every caller would\n * need a cast to read the failure, at every boundary. A typed error narrows by `instanceof`, which\n * works regardless. Callers that must not throw resolve the scale directly with\n * `currencyMinorUnitDecimals` and decide for themselves.\n *\n * @param subject what the message names (\"price p_1 tier 2 flat amount\"), so an operator reading a\n * sync log knows which amount could not be expressed without opening the catalogue.\n */\nexport function toCurrencyMinorUnitAmountOrThrow(value: MoneyValue, subject: string): number {\n const target = currencyMinorUnitDecimals(value.currency);\n if (target === undefined) {\n throw new MoneyMinorUnitConversionError(\n MoneyMinorUnitConversionFailure.UNKNOWN_MINOR_UNIT,\n `Cannot express ${subject} for a payment provider: currency '${value.currency}' has no minor unit this framework can resolve. Cryptocurrencies are in this position deliberately — their decimals are protocol conventions, not a fiat provider's minor unit.`,\n );\n }\n\n let converted: bigint;\n if (value.decimals === target) {\n converted = value.amount;\n } else if (value.decimals < target) {\n converted = value.amount * 10n ** BigInt(target - value.decimals);\n } else {\n const divisor = 10n ** BigInt(value.decimals - target);\n if (value.amount % divisor !== 0n) {\n throw new MoneyMinorUnitConversionError(\n MoneyMinorUnitConversionFailure.PRECISION_LOSS,\n `Cannot express ${subject} for a payment provider: amount ${value.amount} at scale ${value.decimals} cannot be written in ${value.currency}'s smallest unit (scale ${target}) without discarding a fraction of it. Author the amount at scale ${target}, or at a scale whose extra digits are zero.`,\n );\n }\n converted = value.amount / divisor;\n }\n\n const asNumber = Number(converted);\n if (!Number.isSafeInteger(asNumber)) {\n throw new MoneyMinorUnitConversionError(\n MoneyMinorUnitConversionFailure.UNSAFE_MAGNITUDE,\n `Cannot express ${subject} for a payment provider: amount ${converted} in ${value.currency}'s smallest unit exceeds the range a JavaScript number represents exactly, so handing it over would silently change its value.`,\n );\n }\n\n return asNumber;\n}\n\n/**\n * Convert a decimal amount to bigint representation.\n *\n * **Precision caveat:** This uses floating-point arithmetic internally\n * (`Math.round(decimalAmount * 10^decimals)`), which can produce rounding\n * errors for certain values. Prefer `parseDecimalStringToAmount` when working\n * with user input strings to avoid float precision issues entirely.\n *\n * @param decimalAmount - The decimal amount (e.g., 19.99)\n * @param decimals - Number of decimal places (e.g., 2)\n * @returns BigInt amount (e.g., 1999n)\n */\nexport function toMoneyAmount(decimalAmount: number, decimals: number): bigint {\n return BigInt(Math.round(decimalAmount * Math.pow(10, decimals)));\n}\n\n/**\n * Convert a bigint amount to decimal representation.\n * @param amount - The bigint amount (e.g., 1999n)\n * @param decimals - Number of decimal places (e.g., 2)\n * @returns Decimal amount (e.g., 19.99)\n */\nexport function fromMoneyAmount(amount: bigint, decimals: number): number {\n return Number(amount) / Math.pow(10, decimals);\n}\n\n/**\n * Convert a string or number to bigint safely.\n * Useful for parsing user input or JSON values.\n * @param value - String, number, or bigint to convert\n * @returns BigInt amount\n */\nexport function toBigIntAmount(value: string | number | bigint): bigint {\n if (typeof value === 'bigint') return value;\n if (typeof value === 'number') return BigInt(Math.round(value));\n return BigInt(value);\n}\n\n/**\n * Parse a decimal string directly to a bigint amount, avoiding floating-point\n * precision issues entirely.\n *\n * This is the preferred way to convert user input (e.g., from an HTML input\n * element) to a money amount. It works by splitting the string at the decimal\n * point and manipulating integer/fractional parts as strings, so no float\n * arithmetic is ever involved.\n *\n * - Extra fractional digits beyond `decimals` are **truncated** (not rounded).\n * - Missing fractional digits are **zero-padded**.\n *\n * @param input - A decimal string (e.g., \"19.99\", \"5\", \".50\", \"-12.345\")\n * @param decimals - Number of decimal places for the target currency\n * @returns BigInt amount, or `null` if the input is not a valid decimal string\n *\n * **Note:** Scientific notation strings (e.g., `\"1e+10\"`) are rejected (returns\n * `null`) since they are not valid monetary input. This is correct behavior when\n * reading from `<input type=\"number\">`, which may produce such strings for very\n * large values — those inputs should be constrained via `min`/`max` attributes.\n *\n * @example\n * ```typescript\n * parseDecimalStringToAmount(\"19.99\", 2) // → 1999n\n * parseDecimalStringToAmount(\"19.999\", 2) // → 1999n (truncates, not rounds)\n * parseDecimalStringToAmount(\"19.9\", 2) // → 1990n (pads missing decimals)\n * parseDecimalStringToAmount(\"5\", 2) // → 500n\n * parseDecimalStringToAmount(\".50\", 2) // → 50n\n * parseDecimalStringToAmount(\"-12.34\", 2) // → -1234n\n * parseDecimalStringToAmount(\"abc\", 2) // → null\n * parseDecimalStringToAmount(\"1e+10\", 2) // → null (scientific notation rejected)\n * ```\n */\nexport function parseDecimalStringToAmount(input: string, decimals: number): bigint | null {\n const trimmed = input.trim();\n if (trimmed === '' || trimmed === '.' || trimmed === '-' || trimmed === '-.') return null;\n\n // Handle sign\n const isNegative = trimmed.startsWith('-');\n const unsigned = isNegative ? trimmed.slice(1) : trimmed;\n\n // Validate: only digits and at most one decimal point\n if (!/^\\d*\\.?\\d*$/.test(unsigned)) return null;\n\n const dotIndex = unsigned.indexOf('.');\n const integerPart = dotIndex === -1 ? unsigned : (unsigned.slice(0, dotIndex) || '0');\n const fractionalRaw = dotIndex === -1 ? '' : unsigned.slice(dotIndex + 1);\n\n // Pad or truncate fractional part to exactly `decimals` digits\n const fractionalPart = decimals === 0\n ? ''\n : fractionalRaw.padEnd(decimals, '0').slice(0, decimals);\n\n // Build the combined string and convert to bigint\n const combined = integerPart + fractionalPart;\n // Guard against empty combined (shouldn't happen after validation, but be safe)\n if (combined === '') return 0n;\n\n try {\n const result = BigInt(combined);\n return isNegative ? -result : result;\n } catch {\n return null;\n }\n}\n\n/**\n * Convert a money amount from one decimal precision to another using pure\n * bigint arithmetic (no floating-point involved).\n *\n * Use this when changing a currency (which may have different decimal places)\n * instead of the float roundtrip `fromMoneyAmount` → `toMoneyAmount`.\n *\n * - When increasing decimals (e.g., 2 → 8): multiplies by 10^(diff)\n * - When decreasing decimals (e.g., 8 → 2): divides with half-away-from-zero rounding\n *\n * @param amount - The bigint amount in the source precision\n * @param fromDecimals - Source decimal places\n * @param toDecimals - Target decimal places\n * @returns BigInt amount in the target precision\n *\n * @example\n * ```typescript\n * convertMoneyDecimals(1999n, 2, 2) // → 1999n (same decimals, no-op)\n * convertMoneyDecimals(1999n, 2, 4) // → 199900n (scale up)\n * convertMoneyDecimals(199900n, 4, 2) // → 1999n (scale down)\n * convertMoneyDecimals(12345678n, 8, 2) // → 12n (BTC satoshis to 2-decimal)\n * ```\n */\nexport function convertMoneyDecimals(amount: bigint, fromDecimals: number, toDecimals: number): bigint {\n if (fromDecimals === toDecimals) return amount;\n\n const diff = toDecimals - fromDecimals;\n\n if (diff > 0) {\n // Scale up: multiply\n return amount * (10n ** BigInt(diff));\n }\n\n // Scale down: divide with rounding (half-away-from-zero)\n const divisor = 10n ** BigInt(-diff);\n const isNegative = amount < 0n;\n const absAmount = isNegative ? -amount : amount;\n const rounded = (absAmount + divisor / 2n) / divisor;\n return isNegative ? -rounded : rounded;\n}\n\n/**\n * Format a money value for display.\n * @param money - The money value\n * @param options - Formatting options\n * @returns Formatted string (e.g., \"$19.99\" or \"19.99 USD\")\n */\nexport function formatMoney(\n money: MoneyValue,\n options: {\n showSymbol?: boolean;\n symbolPosition?: 'before' | 'after';\n thousandsSeparator?: string;\n decimalSeparator?: string;\n } = {}\n): string {\n const {\n showSymbol = true,\n symbolPosition = 'before',\n thousandsSeparator = ',',\n decimalSeparator = '.',\n } = options;\n\n const decimalValue = fromMoneyAmount(money.amount, money.decimals);\n\n // Format with proper decimal places\n const [integerPart, decimalPart] = decimalValue.toFixed(money.decimals).split('.');\n\n // Add thousands separator\n const formattedInteger = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, thousandsSeparator);\n\n const formattedNumber = decimalPart\n ? `${formattedInteger}${decimalSeparator}${decimalPart}`\n : formattedInteger;\n\n if (!showSymbol) {\n return formattedNumber;\n }\n\n // For now, use currency code as symbol (can be enhanced with CURRENCY_INFO_MAP)\n const symbol = money.currency;\n\n return symbolPosition === 'before'\n ? `${symbol} ${formattedNumber}`\n : `${formattedNumber} ${symbol}`;\n}\n\n"]}
1
+ {"version":3,"file":"zod-money.js","sourceRoot":"","sources":["../../../src/zod-money.ts"],"names":[],"mappings":"AACA,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,OAAO,EAAkB,eAAe,EAAoF,YAAY,EAA2B,MAAM,wBAAwB,CAAC;AAClM,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAgCxF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAiG,CAAC,CAAC,MAAM,CAAC;IACrI,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0KAA0K,CAAC;IACvM,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC,qDAAqD,CAAC;IACxF,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,sHAAsH,CAAC;CAC3K,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAA8B,EAAE;IAEhC,MAAM,EACJ,iBAAiB,EACjB,cAAc,GAAG,IAAI,EACrB,mBAAmB,GAAG,IAAI,EAC1B,SAAS,EACT,SAAS,GACV,GAAG,OAAO,CAAC;IAEZ,6DAA6D;IAC7D,iFAAiF;IACjF,IAA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D,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AACzC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACzB,KAAiB,EACjB,UAKI,EAAE;IAEN,MAAM,EACJ,UAAU,GAAG,IAAI,EACjB,cAAc,GAAG,QAAQ,EACzB,kBAAkB,GAAG,GAAG,EACxB,gBAAgB,GAAG,GAAG,GACvB,GAAG,OAAO,CAAC;IAEZ,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEnE,oCAAoC;IACpC,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEnF,0BAA0B;IAC1B,MAAM,gBAAgB,GAAG,WAAW,CAAC,OAAO,CAAC,uBAAuB,EAAE,kBAAkB,CAAC,CAAC;IAE1F,MAAM,eAAe,GAAG,WAAW;QACjC,CAAC,CAAC,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,WAAW,EAAE;QACxD,CAAC,CAAC,gBAAgB,CAAC;IAErB,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,gFAAgF;IAChF,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC;IAE9B,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,GAAG,MAAM,IAAI,eAAe,EAAE;QAChC,CAAC,CAAC,GAAG,eAAe,IAAI,MAAM,EAAE,CAAC;AACrC,CAAC","sourcesContent":["\n// ============================================================================\n// MONEY SCHEMA HELPER\n// ============================================================================\n\nimport { DecoratorInput, SCHEMA_METADATA, CustomFieldMetadata, MoneySchemaMetadata, MoneySchemaOptions, SummaryFieldParams, ZodDecorator, ZodDecorator_ParamsType } from \"./zod-decorators.types\";\nimport { z } from \"zod\";\nimport { addChainableMethods } from \"./zod.module-override\";\nimport { CurrencySchema, currencyMinorUnitDecimals } from \"./currencies.shared.schemas\";\n\n/**\n * Money value type - represents a monetary amount with bigint storage.\n *\n * The amount is stored as a bigint in the smallest unit (e.g., cents for USD).\n * Using bigint ensures no precision loss for arbitrarily large amounts.\n * The decimals field indicates how to convert to the display value:\n * - displayValue = Number(amount) / (10 ** decimals)\n *\n * Example: { amount: 1999n, currency: 'USD', decimals: 2 } = $19.99\n */\nexport interface MoneyValue {\n /**\n * Amount in smallest unit (e.g., cents). BigInt to avoid precision issues with\n * large amounts.\n *\n * WIRE CONTRACT: a `bigint` has no JSON form, so on the wire (and at rest in\n * Mongo) this amount is a decimal STRING (e.g. `\"1999\"`). Outbound it is encoded\n * by `BigInt.prototype.toJSON` (`installBigIntJsonEncoding`, same package);\n * inbound it is coerced back to `bigint` by `applyNetworkBoundaryCoercion`\n * (`@wildo-ai/saas-models`) on the shared request/response DTO — so both the\n * frontend and backend hold a real `bigint` at runtime. Full mechanism map:\n * `install-bigint-json-encoding.ts`.\n */\n amount: bigint;\n /** ISO 4217 currency code (e.g., 'USD', 'EUR', 'BTC') */\n currency: string;\n /** Number of decimal places for display (e.g., 2 for USD, 8 for BTC) */\n decimals: number;\n}\n\n/**\n * Zod schema for MoneyValue.\n */\nexport const MoneyValueSchema: z.ZodObject<{ amount: z.ZodBigInt; currency: typeof CurrencySchema; decimals: z.ZodNumber }> = z.object({\n amount: z.bigint().describe(\"The amount in the currency's smallest unit, such as cents, as an integer. Sent as a decimal string (`\\\"1999\\\"`), because it can exceed what a JSON number holds exactly.\"),\n currency: CurrencySchema.describe(\"The ISO 4217 currency code, such as `USD` or `EUR`.\"),\n decimals: z.number().int().min(0).max(18).describe(\"How many decimal places the currency uses, to turn `amount` into a displayed value: `1999` with 2 decimals is 19.99.\"),\n});\n\n/**\n * @wildo_source:part:start zod.factories.money facet:layer:shared facet:family:schema-factory\n *\n * z_money() - Creates money schemas for financial amounts.\n *\n * Money values are stored as integers to avoid floating-point precision issues.\n * The schema creates an object with: { amount, currency, decimals }\n *\n * @example\n * ```typescript\n * import { z_money } from '@wildo-ai/zod-decorators';\n *\n * const price = z_money();\n * const fiatPrice = z_money({ currenciesAllowed: [CurrencyAllowed.FIAT] });\n * const usdPrice = z_money({ allowCurrencyChange: false }).moneyUI({ edit: { defaultCurrency: 'USD' } });\n *\n * // With decorators (chainable)\n * z_money().moneyUI({ edit: { defaultCurrency: 'EUR' } })\n * z_money({ currenciesAllowed: [CurrencyAllowed.FIAT_MAJOR] }).isHidden({ edit: true })\n * ```\n */\n\n/**\n * Creates a money schema with metadata for detection and form component rendering.\n *\n * @param options - Configuration options for money field\n * @returns A Zod object schema with metadata for money detection\n *\n * @example\n * ```typescript\n * // Simple money (all currencies)\n * const price = z_money();\n * // Infers: { amount: bigint, currency: string, decimals: number }\n *\n * // Fiat only (no crypto)\n * const fiatPrice = z_money({ currenciesAllowed: [CurrencyAllowed.FIAT] });\n *\n * // Fixed currency with amount constraints\n * const usdPrice = z_money({\n * allowCurrencyChange: false,\n * minAmount: 0n,\n * maxAmount: 100000000n // $1,000,000.00 in cents\n * }).moneyUI({ edit: { defaultCurrency: 'USD' } });\n * ```\n */\nexport function createMoneySchema(\n options: MoneySchemaOptions = {}\n): DecoratedMoneySchema {\n const {\n currenciesAllowed,\n appEnabledOnly = true,\n allowCurrencyChange = true,\n minAmount,\n maxAmount,\n } = options;\n\n // Create the amount schema with optional min/max constraints\n // Using bigint for amount to avoid precision issues with large financial amounts\n let amountSchema = z.bigint();\n if (minAmount !== undefined) {\n amountSchema = amountSchema.min(minAmount);\n }\n if (maxAmount !== undefined) {\n amountSchema = amountSchema.max(maxAmount);\n }\n\n // Create the money object schema\n const moneySchema = z.object({\n amount: amountSchema.describe(\"The amount in the currency's smallest unit, such as cents, as an integer. Sent as a decimal string (`\\\"1999\\\"`), because it can exceed what a JSON number holds exactly.\"),\n currency: CurrencySchema.describe(\"The ISO 4217 currency code, such as `USD` or `EUR`.\"),\n decimals: z.number().int().min(0).max(18).describe(\"How many decimal places the currency uses, to turn `amount` into a displayed value: `1999` with 2 decimals is 19.99.\"),\n });\n\n const moneyMetadata: MoneySchemaMetadata = {\n isMoney: true,\n ...(currenciesAllowed && currenciesAllowed.length > 0 && { currenciesAllowed }),\n appEnabledOnly,\n allowCurrencyChange,\n ...(minAmount !== undefined && { minAmount }),\n ...(maxAmount !== undefined && { maxAmount }),\n };\n\n // Initialize or extend SCHEMA_METADATA with money config\n const existingMetadata: CustomFieldMetadata = (moneySchema as any)[SCHEMA_METADATA] || {};\n (moneySchema as any)[SCHEMA_METADATA] = {\n ...existingMetadata,\n moneyConfig: moneyMetadata,\n };\n\n // Add chainable decorator methods to the money schema instance\n // This allows: z_money().moneyUI({ edit: { defaultCurrency: 'EUR' } }).isHidden()\n addChainableMethods(moneySchema);\n\n return moneySchema as DecoratedMoneySchema;\n}\n\n/**\n * Return type for money schemas - includes decorator methods.\n * Note: IS_FOREIGN_KEY is not applicable to money objects.\n * IS_DB_INDEXED will index internal fields (amount, currency) for query optimization.\n *\n * This type must list all decorators applicable to ZodObject (per ApplyableTypeAllTypes).\n * Missing entries here cause TS errors when chaining decorators on z_money() fields.\n */\nexport type DecoratedMoneySchema = z.ZodObject<{\n amount: z.ZodBigInt;\n currency: typeof CurrencySchema;\n decimals: z.ZodNumber;\n}> & {\n [ZodDecorator.IS_DB_INDEXED](): DecoratedMoneySchema;\n /** Installed at runtime with the other chainable methods; declared here so an authored `.moneyUI(…)` typechecks. */\n [ZodDecorator.MONEY_UI](params?: ZodDecorator_ParamsType[ZodDecorator.MONEY_UI]): DecoratedMoneySchema;\n [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): DecoratedMoneySchema;\n [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): DecoratedMoneySchema;\n // Resource-level decorators (applicable to all types including ZodObject)\n [ZodDecorator.IS_SUMMARY_FIELD](params?: SummaryFieldParams): DecoratedMoneySchema;\n [ZodDecorator.IS_BACKEND_ONLY](params?: ZodDecorator_ParamsType[ZodDecorator.IS_BACKEND_ONLY]): DecoratedMoneySchema;\n [ZodDecorator.IS_WRITE_ONLY_SECRET](params?: ZodDecorator_ParamsType[ZodDecorator.IS_WRITE_ONLY_SECRET]): DecoratedMoneySchema;\n [ZodDecorator.EXCLUDE_FROM_CREATE](): DecoratedMoneySchema;\n [ZodDecorator.EXCLUDE_FROM_UPDATE](): DecoratedMoneySchema;\n addDecorators(decorators: DecoratorInput[]): DecoratedMoneySchema;\n};\n\n/**\n * Creates a money schema for financial amounts with integer storage.\n * Named z_money to indicate it's a Zod helper function exported standalone.\n *\n * Money values are stored as: { amount: int, currency: string, decimals: int }\n * - amount: Value in smallest unit (e.g., cents for USD, satoshis for BTC)\n * - currency: ISO 4217 code (e.g., 'USD', 'EUR', 'BTC')\n * - decimals: Decimal places for display conversion (e.g., 2 for USD, 8 for BTC)\n *\n * @example\n * ```typescript\n * import { z_money } from '@wildo-ai/zod-decorators';\n *\n * // Simple usage\n * z_money() // All currencies\n *\n * // With options\n * z_money({ currenciesAllowed: [CurrencyAllowed.FIAT] })\n * z_money({ allowCurrencyChange: false }).moneyUI({ edit: { defaultCurrency: 'USD' } })\n * z_money({ currenciesAllowed: [CurrencyAllowed.FIAT_MAJOR], minAmount: 0n })\n *\n * // With decorators (chainable)\n * z_money().moneyUI({ edit: { defaultCurrency: 'USD' } })\n * z_money({ currenciesAllowed: [CurrencyAllowed.FIAT] }).isHidden({ edit: true })\n *\n * // Usage example\n * const price: MoneyValue = { amount: 1999n, currency: 'USD', decimals: 2 };\n * // Represents $19.99\n * ```\n */\nexport function z_money(\n options?: MoneySchemaOptions\n): DecoratedMoneySchema {\n return createMoneySchema(options) as DecoratedMoneySchema;\n}\n/** @wildo_source:part:end zod.factories.money */\n\n// ============================================================================\n// MONEY UTILITY FUNCTIONS\n// ============================================================================\n\n/**\n * Why an amount could not be expressed in its currency's smallest unit.\n *\n * A named vocabulary rather than three bare strings, because each member has a DIFFERENT remedy and\n * an operator reading a sync log needs to know which one they are looking at: an unknown minor unit\n * is a catalogue problem, a precision loss is an authoring problem, and an unsafe magnitude is a\n * limit of the provider's own number type.\n */\nexport enum MoneyMinorUnitConversionFailure {\n /** The currency has no minor unit (`XDR`, `XXX`) or is not one this vocabulary knows. */\n UNKNOWN_MINOR_UNIT = 'unknown_minor_unit',\n /** Converting down would discard a fraction of the provider's smallest unit. */\n PRECISION_LOSS = 'precision_loss',\n /** The converted amount cannot be represented exactly as a JavaScript number. */\n UNSAFE_MAGNITUDE = 'unsafe_magnitude',\n}\n\n/** Thrown by {@link toCurrencyMinorUnitAmountOrThrow}; carries the reason so a caller can branch. */\nexport class MoneyMinorUnitConversionError extends Error {\n constructor(\n public readonly reason: MoneyMinorUnitConversionFailure,\n message: string,\n ) {\n super(message);\n this.name = 'MoneyMinorUnitConversionError';\n }\n}\n\n/**\n * Convert a {@link MoneyValue} to the amount a payment provider expects: an integer in the CURRENCY's\n * smallest unit.\n *\n * Wildo stores money at an AUTHORED scale (`decimals` on the value); a provider reads it at the\n * currency's own scale. Those are two different numbers whenever they disagree, and until 2026-09-08\n * the billing boundary sent the stored amount straight through — so a price authored at any scale\n * other than the currency's was charged at the wrong magnitude, by a factor of 10 per decimal place\n * of disagreement.\n *\n * **All arithmetic is `bigint`.** The stored amount already is one, and the whole reason it is a\n * bigint rather than a number is that money must not round; converting through a float to save a cast\n * would give that back at exactly the boundary where it costs money.\n *\n * **Scaling UP is always exact. Scaling DOWN refuses on a remainder rather than rounding** — a price\n * of 1.005 in a currency whose smallest unit is a cent is not 1.00 and not 1.01, it is a price the\n * provider cannot express, and silently picking one is how a catalogue and an invoice come to\n * disagree by a cent per unit forever.\n *\n * **Throws rather than returning a result union**, and the reason is the compiler rather than taste:\n * this repository compiles with `strict: false` (`engine/tsconfig.common.json`), which disables the\n * discriminant narrowing a `{ ok: true } | { ok: false }` result depends on — so every caller would\n * need a cast to read the failure, at every boundary. A typed error narrows by `instanceof`, which\n * works regardless. Callers that must not throw resolve the scale directly with\n * `currencyMinorUnitDecimals` and decide for themselves.\n *\n * @param subject what the message names (\"price p_1 tier 2 flat amount\"), so an operator reading a\n * sync log knows which amount could not be expressed without opening the catalogue.\n */\nexport function toCurrencyMinorUnitAmountOrThrow(value: MoneyValue, subject: string): number {\n const target = currencyMinorUnitDecimals(value.currency);\n if (target === undefined) {\n throw new MoneyMinorUnitConversionError(\n MoneyMinorUnitConversionFailure.UNKNOWN_MINOR_UNIT,\n `Cannot express ${subject} for a payment provider: currency '${value.currency}' has no minor unit this framework can resolve. Cryptocurrencies are in this position deliberately — their decimals are protocol conventions, not a fiat provider's minor unit.`,\n );\n }\n\n let converted: bigint;\n if (value.decimals === target) {\n converted = value.amount;\n } else if (value.decimals < target) {\n converted = value.amount * 10n ** BigInt(target - value.decimals);\n } else {\n const divisor = 10n ** BigInt(value.decimals - target);\n if (value.amount % divisor !== 0n) {\n throw new MoneyMinorUnitConversionError(\n MoneyMinorUnitConversionFailure.PRECISION_LOSS,\n `Cannot express ${subject} for a payment provider: amount ${value.amount} at scale ${value.decimals} cannot be written in ${value.currency}'s smallest unit (scale ${target}) without discarding a fraction of it. Author the amount at scale ${target}, or at a scale whose extra digits are zero.`,\n );\n }\n converted = value.amount / divisor;\n }\n\n const asNumber = Number(converted);\n if (!Number.isSafeInteger(asNumber)) {\n throw new MoneyMinorUnitConversionError(\n MoneyMinorUnitConversionFailure.UNSAFE_MAGNITUDE,\n `Cannot express ${subject} for a payment provider: amount ${converted} in ${value.currency}'s smallest unit exceeds the range a JavaScript number represents exactly, so handing it over would silently change its value.`,\n );\n }\n\n return asNumber;\n}\n\n/**\n * Convert a decimal amount to bigint representation.\n *\n * **Precision caveat:** This uses floating-point arithmetic internally\n * (`Math.round(decimalAmount * 10^decimals)`), which can produce rounding\n * errors for certain values. Prefer `parseDecimalStringToAmount` when working\n * with user input strings to avoid float precision issues entirely.\n *\n * @param decimalAmount - The decimal amount (e.g., 19.99)\n * @param decimals - Number of decimal places (e.g., 2)\n * @returns BigInt amount (e.g., 1999n)\n */\nexport function toMoneyAmount(decimalAmount: number, decimals: number): bigint {\n return BigInt(Math.round(decimalAmount * Math.pow(10, decimals)));\n}\n\n/**\n * Convert a bigint amount to decimal representation.\n * @param amount - The bigint amount (e.g., 1999n)\n * @param decimals - Number of decimal places (e.g., 2)\n * @returns Decimal amount (e.g., 19.99)\n */\nexport function fromMoneyAmount(amount: bigint, decimals: number): number {\n return Number(amount) / Math.pow(10, decimals);\n}\n\n/**\n * Convert a string or number to bigint safely.\n * Useful for parsing user input or JSON values.\n * @param value - String, number, or bigint to convert\n * @returns BigInt amount\n */\nexport function toBigIntAmount(value: string | number | bigint): bigint {\n if (typeof value === 'bigint') return value;\n if (typeof value === 'number') return BigInt(Math.round(value));\n return BigInt(value);\n}\n\n/**\n * Parse a decimal string directly to a bigint amount, avoiding floating-point\n * precision issues entirely.\n *\n * This is the preferred way to convert user input (e.g., from an HTML input\n * element) to a money amount. It works by splitting the string at the decimal\n * point and manipulating integer/fractional parts as strings, so no float\n * arithmetic is ever involved.\n *\n * - Extra fractional digits beyond `decimals` are **truncated** (not rounded).\n * - Missing fractional digits are **zero-padded**.\n *\n * @param input - A decimal string (e.g., \"19.99\", \"5\", \".50\", \"-12.345\")\n * @param decimals - Number of decimal places for the target currency\n * @returns BigInt amount, or `null` if the input is not a valid decimal string\n *\n * **Note:** Scientific notation strings (e.g., `\"1e+10\"`) are rejected (returns\n * `null`) since they are not valid monetary input. This is correct behavior when\n * reading from `<input type=\"number\">`, which may produce such strings for very\n * large values — those inputs should be constrained via `min`/`max` attributes.\n *\n * @example\n * ```typescript\n * parseDecimalStringToAmount(\"19.99\", 2) // → 1999n\n * parseDecimalStringToAmount(\"19.999\", 2) // → 1999n (truncates, not rounds)\n * parseDecimalStringToAmount(\"19.9\", 2) // → 1990n (pads missing decimals)\n * parseDecimalStringToAmount(\"5\", 2) // → 500n\n * parseDecimalStringToAmount(\".50\", 2) // → 50n\n * parseDecimalStringToAmount(\"-12.34\", 2) // → -1234n\n * parseDecimalStringToAmount(\"abc\", 2) // → null\n * parseDecimalStringToAmount(\"1e+10\", 2) // → null (scientific notation rejected)\n * ```\n */\nexport function parseDecimalStringToAmount(input: string, decimals: number): bigint | null {\n const trimmed = input.trim();\n if (trimmed === '' || trimmed === '.' || trimmed === '-' || trimmed === '-.') return null;\n\n // Handle sign\n const isNegative = trimmed.startsWith('-');\n const unsigned = isNegative ? trimmed.slice(1) : trimmed;\n\n // Validate: only digits and at most one decimal point\n if (!/^\\d*\\.?\\d*$/.test(unsigned)) return null;\n\n const dotIndex = unsigned.indexOf('.');\n const integerPart = dotIndex === -1 ? unsigned : (unsigned.slice(0, dotIndex) || '0');\n const fractionalRaw = dotIndex === -1 ? '' : unsigned.slice(dotIndex + 1);\n\n // Pad or truncate fractional part to exactly `decimals` digits\n const fractionalPart = decimals === 0\n ? ''\n : fractionalRaw.padEnd(decimals, '0').slice(0, decimals);\n\n // Build the combined string and convert to bigint\n const combined = integerPart + fractionalPart;\n // Guard against empty combined (shouldn't happen after validation, but be safe)\n if (combined === '') return 0n;\n\n try {\n const result = BigInt(combined);\n return isNegative ? -result : result;\n } catch {\n return null;\n }\n}\n\n/**\n * Convert a money amount from one decimal precision to another using pure\n * bigint arithmetic (no floating-point involved).\n *\n * Use this when changing a currency (which may have different decimal places)\n * instead of the float roundtrip `fromMoneyAmount` → `toMoneyAmount`.\n *\n * - When increasing decimals (e.g., 2 → 8): multiplies by 10^(diff)\n * - When decreasing decimals (e.g., 8 → 2): divides with half-away-from-zero rounding\n *\n * @param amount - The bigint amount in the source precision\n * @param fromDecimals - Source decimal places\n * @param toDecimals - Target decimal places\n * @returns BigInt amount in the target precision\n *\n * @example\n * ```typescript\n * convertMoneyDecimals(1999n, 2, 2) // → 1999n (same decimals, no-op)\n * convertMoneyDecimals(1999n, 2, 4) // → 199900n (scale up)\n * convertMoneyDecimals(199900n, 4, 2) // → 1999n (scale down)\n * convertMoneyDecimals(12345678n, 8, 2) // → 12n (BTC satoshis to 2-decimal)\n * ```\n */\nexport function convertMoneyDecimals(amount: bigint, fromDecimals: number, toDecimals: number): bigint {\n if (fromDecimals === toDecimals) return amount;\n\n const diff = toDecimals - fromDecimals;\n\n if (diff > 0) {\n // Scale up: multiply\n return amount * (10n ** BigInt(diff));\n }\n\n // Scale down: divide with rounding (half-away-from-zero)\n const divisor = 10n ** BigInt(-diff);\n const isNegative = amount < 0n;\n const absAmount = isNegative ? -amount : amount;\n const rounded = (absAmount + divisor / 2n) / divisor;\n return isNegative ? -rounded : rounded;\n}\n\n/**\n * Format a money value for display.\n * @param money - The money value\n * @param options - Formatting options\n * @returns Formatted string (e.g., \"$19.99\" or \"19.99 USD\")\n */\nexport function formatMoney(\n money: MoneyValue,\n options: {\n showSymbol?: boolean;\n symbolPosition?: 'before' | 'after';\n thousandsSeparator?: string;\n decimalSeparator?: string;\n } = {}\n): string {\n const {\n showSymbol = true,\n symbolPosition = 'before',\n thousandsSeparator = ',',\n decimalSeparator = '.',\n } = options;\n\n const decimalValue = fromMoneyAmount(money.amount, money.decimals);\n\n // Format with proper decimal places\n const [integerPart, decimalPart] = decimalValue.toFixed(money.decimals).split('.');\n\n // Add thousands separator\n const formattedInteger = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, thousandsSeparator);\n\n const formattedNumber = decimalPart\n ? `${formattedInteger}${decimalSeparator}${decimalPart}`\n : formattedInteger;\n\n if (!showSymbol) {\n return formattedNumber;\n }\n\n // For now, use currency code as symbol (can be enhanced with CURRENCY_INFO_MAP)\n const symbol = money.currency;\n\n return symbolPosition === 'before'\n ? `${symbol} ${formattedNumber}`\n : `${formattedNumber} ${symbol}`;\n}\n\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"zod-phone.d.ts","sourceRoot":"","sources":["../../src/zod-phone.ts"],"names":[],"mapp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