@wildo-ai/zod-decorators 1.1.4 → 1.1.6

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 (68) hide show
  1. package/dist/esm/currencies.shared.schemas.d.ts.map +1 -1
  2. package/dist/esm/currencies.shared.schemas.js.map +1 -1
  3. package/dist/esm/files/agent-file-formats.d.ts +51 -37
  4. package/dist/esm/files/agent-file-formats.d.ts.map +1 -1
  5. package/dist/esm/files/agent-file-formats.js +54 -47
  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/mime-registry.d.ts.map +1 -1
  9. package/dist/esm/files/unified-registry.d.ts +2 -2
  10. package/dist/esm/files/unified-registry.d.ts.map +1 -1
  11. package/dist/esm/files/unified-registry.js +1 -1
  12. package/dist/esm/files/unified-registry.js.map +1 -1
  13. package/dist/esm/index.d.ts +1 -0
  14. package/dist/esm/index.d.ts.map +1 -1
  15. package/dist/esm/index.js +1 -0
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/testing/decorated-test-schemas.d.ts.map +1 -1
  18. package/dist/esm/testing.d.ts +11 -0
  19. package/dist/esm/testing.d.ts.map +1 -1
  20. package/dist/esm/testing.js +11 -0
  21. package/dist/esm/testing.js.map +1 -1
  22. package/dist/esm/zod-address.d.ts +146 -0
  23. package/dist/esm/zod-address.d.ts.map +1 -0
  24. package/dist/esm/zod-address.js +176 -0
  25. package/dist/esm/zod-address.js.map +1 -0
  26. package/dist/esm/zod-bigdecimal.d.ts.map +1 -1
  27. package/dist/esm/zod-code.d.ts +2 -0
  28. package/dist/esm/zod-code.d.ts.map +1 -1
  29. package/dist/esm/zod-code.js +4 -4
  30. package/dist/esm/zod-code.js.map +1 -1
  31. package/dist/esm/zod-color.d.ts.map +1 -1
  32. package/dist/esm/zod-decorators.types.d.ts +311 -29
  33. package/dist/esm/zod-decorators.types.d.ts.map +1 -1
  34. package/dist/esm/zod-decorators.types.js +177 -8
  35. package/dist/esm/zod-decorators.types.js.map +1 -1
  36. package/dist/esm/zod-duration.d.ts +2 -0
  37. package/dist/esm/zod-duration.d.ts.map +1 -1
  38. package/dist/esm/zod-duration.js +4 -4
  39. package/dist/esm/zod-duration.js.map +1 -1
  40. package/dist/esm/zod-file.d.ts +70 -4
  41. package/dist/esm/zod-file.d.ts.map +1 -1
  42. package/dist/esm/zod-file.js +92 -75
  43. package/dist/esm/zod-file.js.map +1 -1
  44. package/dist/esm/zod-money.d.ts +2 -0
  45. package/dist/esm/zod-money.d.ts.map +1 -1
  46. package/dist/esm/zod-money.js +6 -6
  47. package/dist/esm/zod-money.js.map +1 -1
  48. package/dist/esm/zod-phone.d.ts +8 -0
  49. package/dist/esm/zod-phone.d.ts.map +1 -1
  50. package/dist/esm/zod-phone.js +6 -1
  51. package/dist/esm/zod-phone.js.map +1 -1
  52. package/dist/esm/zod-range.d.ts.map +1 -1
  53. package/dist/esm/zod-utils.shared.d.ts +343 -12
  54. package/dist/esm/zod-utils.shared.d.ts.map +1 -1
  55. package/dist/esm/zod-utils.shared.js +1004 -90
  56. package/dist/esm/zod-utils.shared.js.map +1 -1
  57. package/dist/esm/zod-versioned.d.ts.map +1 -1
  58. package/dist/esm/zod-versioned.js.map +1 -1
  59. package/dist/esm/zod.module-override.d.ts +29 -1
  60. package/dist/esm/zod.module-override.d.ts.map +1 -1
  61. package/dist/esm/zod.module-override.js +67 -8
  62. package/dist/esm/zod.module-override.js.map +1 -1
  63. package/dist/tsconfig.build.tsbuildinfo +1 -1
  64. package/package.json +2 -7
  65. package/dist/esm/companion-exports.d.ts +0 -8
  66. package/dist/esm/companion-exports.d.ts.map +0 -1
  67. package/dist/esm/companion-exports.js +0 -8
  68. package/dist/esm/companion-exports.js.map +0 -1
@@ -98,6 +98,8 @@ export type DecoratedDurationSchema = z.ZodObject<{
98
98
  unit: z.ZodTypeAny;
99
99
  }> & {
100
100
  [ZodDecorator.IS_DB_INDEXED](): DecoratedDurationSchema;
101
+ /** Installed at runtime with the other chainable methods; declared here so an authored `.durationUI(…)` typechecks. */
102
+ [ZodDecorator.DURATION_UI](params?: ZodDecorator_ParamsType[ZodDecorator.DURATION_UI]): DecoratedDurationSchema;
101
103
  [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): DecoratedDurationSchema;
102
104
  [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): DecoratedDurationSchema;
103
105
  [ZodDecorator.IS_SUMMARY_FIELD](params?: SummaryFieldParams): DecoratedDurationSchema;
@@ -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,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;IAC9B,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAeD,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,2FAAkD,CAAC;AAElF;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;iBAG9B,CAAC;AAEH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAA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uB,CAAC;CACtE,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,uBAAuB,CAEnF;AACD,oDAAoD;AAEpD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,yBAGlC,CAAC"}
@@ -22,8 +22,8 @@ export const DurationUnitSchema = z.enum(DurationUnit).systemEnum('DurationUnit'
22
22
  * Zod schema for DurationValue.
23
23
  */
24
24
  export const DurationValueSchema = z.object({
25
- value: z.number().int().min(0),
26
- unit: DurationUnitSchema,
25
+ value: z.number().int().min(0).describe("How many `unit`s the duration lasts."),
26
+ unit: DurationUnitSchema.describe("The unit `value` is counted in."),
27
27
  });
28
28
  /**
29
29
  * Convert a duration to total seconds for canonical storage/comparison.
@@ -128,8 +128,8 @@ export function createDurationSchema(options = {}) {
128
128
  ? z.enum([allowedUnits[0], ...allowedUnits.slice(1)])
129
129
  : DurationUnitSchema;
130
130
  const durationSchema = z.object({
131
- value: valueSchema,
132
- unit: unitSchema,
131
+ value: valueSchema.describe("How many `unit`s the duration lasts."),
132
+ unit: unitSchema.describe("The unit `value` is counted in."),
133
133
  });
134
134
  const durationMetadata = {
135
135
  isDuration: true,
@@ -1 +1 @@
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,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAkC5D,gDAAgD;AAChD,MAAM,oBAAoB,GAAiC;IACzD,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK;IAClC,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,CAAC,YAAY,CAAC,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AAE,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;AAoBD;;;;;;;;;;;;;;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),\n unit: DurationUnitSchema,\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,\n unit: unitSchema,\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 [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,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAkC5D,gDAAgD;AAChD,MAAM,oBAAoB,GAAiC;IACzD,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK;IAClC,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,EAAE;IAC1B,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,IAAI;IA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,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,5 +1,6 @@
1
- import { FileSchemaOptions, FileMimeTypeGroup, FileNature, FileDisplayNature, FileDisplayPresentation, type FileActivationConfig, type FileUIDisplayParams, FileStorageAccepted, FileNatureConstraints_Image, FileNatureConstraints_Video, FileNatureConstraints_Audio, FileNatureConstraints_Document } from "./zod-decorators.types";
1
+ import { FileSchemaOptions, FileMimeTypeGroup, FileNature, FileDisplayNature, FileDisplayPresentation, type FileActivationConfig, type FileUIDisplayParams, FileStorageAccepted, FileNatureConstraints_Image, FileNatureConstraints_Video, FileNatureConstraints_Audio, FileNatureConstraints_Document, ZodDecorator, ZodDecorator_ParamsType } from "./zod-decorators.types";
2
2
  import { z } from "zod";
3
+ import { AgentFileFormat } from "./files/agent-file-formats";
3
4
  /**
4
5
  * Single file value type - represents a single file reference stored in the database.
5
6
  * The actual file is stored in a file storage system, this object references it.
@@ -128,6 +129,19 @@ export interface DecoratedFileSchema extends z.ZodObject<{
128
129
  fileId: z.ZodString;
129
130
  updatedAt: z.ZodDate;
130
131
  }> {
132
+ /**
133
+ * Declared here, as the sibling factories declare theirs (`DecoratedMoneySchema.moneyUI`,
134
+ * `DecoratedPhoneSchema.phoneUI`, …), because a file's display and edit policy is authored on
135
+ * the factory's output and nowhere else. The applyable-type map admits `fileUI` on `ZodObject`,
136
+ * but a bare `z.object({...})` is not a file, so the base prototype deliberately does not carry
137
+ * it — the per-instance install `createFileSchema` performs is what makes it reachable.
138
+ *
139
+ * Not a RE-declaration: `fileUI` is absent from the `ZodObject` module augmentation, so this adds
140
+ * a member rather than conflicting with one. That distinction is what the TS2320 note above is
141
+ * about — re-declaring a member the augmentation already carries is what broke here before.
142
+ */
143
+ [ZodDecorator.FILE_UI](params?: ZodDecorator_ParamsType[ZodDecorator.FILE_UI]): DecoratedFileSchema;
144
+ [ZodDecorator.FILE_SPEC](params?: ZodDecorator_ParamsType[ZodDecorator.FILE_SPEC]): DecoratedFileSchema;
131
145
  }
132
146
  /**
133
147
  * Return type for multiple file schemas - includes decorator methods.
@@ -139,6 +153,19 @@ export interface DecoratedMultipleFileSchema extends z.ZodObject<{
139
153
  fileIds: z.ZodArray<z.ZodString>;
140
154
  updatedAt: z.ZodDate;
141
155
  }> {
156
+ /**
157
+ * Declared here, as the sibling factories declare theirs (`DecoratedMoneySchema.moneyUI`,
158
+ * `DecoratedPhoneSchema.phoneUI`, …), because a file's display and edit policy is authored on
159
+ * the factory's output and nowhere else. The applyable-type map admits `fileUI` on `ZodObject`,
160
+ * but a bare `z.object({...})` is not a file, so the base prototype deliberately does not carry
161
+ * it — the per-instance install `createFileSchema` performs is what makes it reachable. Mirrors the single-file interface above.
162
+ *
163
+ * Not a RE-declaration: `fileUI` is absent from the `ZodObject` module augmentation, so this adds
164
+ * a member rather than conflicting with one. That distinction is what the TS2320 note above is
165
+ * about — re-declaring a member the augmentation already carries is what broke here before.
166
+ */
167
+ [ZodDecorator.FILE_UI](params?: ZodDecorator_ParamsType[ZodDecorator.FILE_UI]): DecoratedMultipleFileSchema;
168
+ [ZodDecorator.FILE_SPEC](params?: ZodDecorator_ParamsType[ZodDecorator.FILE_SPEC]): DecoratedMultipleFileSchema;
142
169
  }
143
170
  /**
144
171
  * Creates a file schema for file uploads with reference storage.
@@ -206,10 +233,40 @@ export declare function getFileExtension(filename: string): string;
206
233
  */
207
234
  export declare function isMimeTypeAllowed(mimeType: string, allowedMimeTypes?: string[]): boolean;
208
235
  /**
209
- * Get a human-readable description of allowed file types.
210
- * Uses UnifiedFileFormatRegistry for better format detection.
236
+ * How an accepted file type is identified — the discriminator of {@link AcceptedFileKind}.
211
237
  */
212
- export declare function getAcceptDescription(allowedMimeTypes?: string[]): string;
238
+ export declare enum AcceptedFileKindCategory {
239
+ /** A broad nature (images, PDF, office documents, …) — one {@link FileNature} member. */
240
+ NATURE = "nature",
241
+ /** A text format an agent can produce — one {@link AgentFileFormat} member. */
242
+ AGENT_FORMAT = "agent_format",
243
+ /** Neither: the MIME subtype itself (`csv` for `text/csv`), shown as the value it is. */
244
+ MIME_SUBTYPE = "mime_subtype"
245
+ }
246
+ /** One kind of file a field accepts, as a FACT a renderer names — never as words. */
247
+ export type AcceptedFileKind = {
248
+ category: AcceptedFileKindCategory.NATURE;
249
+ nature: FileNature;
250
+ } | {
251
+ category: AcceptedFileKindCategory.AGENT_FORMAT;
252
+ format: AgentFileFormat;
253
+ } | {
254
+ category: AcceptedFileKindCategory.MIME_SUBTYPE;
255
+ subtype: string;
256
+ };
257
+ /**
258
+ * The kinds of file a field's `allowedMimeTypes` admit, deduplicated, in first-seen order. An empty
259
+ * result means every file is accepted.
260
+ *
261
+ * This answers FACTS and the renderer names them from its label tree. It used to answer an English
262
+ * sentence ("Images, PDF, Text files") from two hand-kept maps plus a humanizing fallback — words
263
+ * produced by code in a package with no i18n at all, which no locale could translate (#1283,
264
+ * `.claude/rules/display-text-comes-from-i18n.md`).
265
+ *
266
+ * Resolution per MIME type: the unified format registry first (a nature, or an agent format), then
267
+ * the broad MIME families the registry does not classify, then the subtype as a value.
268
+ */
269
+ export declare function getAcceptedFileKinds(allowedMimeTypes?: string[]): AcceptedFileKind[];
213
270
  /**
214
271
  * Get file nature from schema metadata.
215
272
  * @param schema - Zod schema (must be a file schema)
@@ -241,6 +298,15 @@ export declare function getFileConstraints(schema: z.ZodTypeAny): {
241
298
  * 2. `mimeType` (from file metadata or browser File object) → detected via MIME prefix matching
242
299
  * 3. `FileDisplayNature.GENERIC` (fallback)
243
300
  *
301
+ * `FileNature.ALL` is not a nature, it is the ABSENCE of a declaration: a field that accepts anything
302
+ * says nothing about the file in front of it. So it does not decide at step 1 — the file's own MIME
303
+ * type does, exactly as for a field with no declared nature. Until 2026-09-24 it mapped to GENERIC and
304
+ * won, so every file in an open field, a PNG and a PDF included, resolved to GENERIC: no preview, and
305
+ * an authored `OVERLAY` activation always degraded to a download. `resolveFileDisplayPolicy` already
306
+ * describes the intended behaviour ("the file's ACTUAL nature has no displayer — which is only
307
+ * reachable when the schema declared an open nature"); this is what makes that sentence true.
308
+ * `FileNature.ARCHIVE` stays GENERIC at step 1, because that IS a declaration.
309
+ *
244
310
  * @param schemaNature - The `FileNature` declared in schema metadata (from `getFileMetadata(schema)?.nature`)
245
311
  * @param mimeType - The MIME type of the actual file
246
312
  * @returns The `FileDisplayNature` to use for rendering
@@ -1 +1 @@
1
- {"version":3,"file":"zod-file.d.ts","sourceRoot":"","sources":["../../src/zod-file.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eTypeGroups, FileNature, FileDisplayNature, Fil
5
5
  import { z } from "zod";
6
6
  import { addChainableMethods, addDecorators } from "./zod.module-override.js";
7
7
  import { UnifiedFileFormatRegistry } from "./files/unified-registry.js";
8
+ import { AgentFileFormat } from "./files/agent-file-formats.js";
8
9
  /**
9
10
  * Deduplicated warning tracker for unsupported storage providers.
10
11
  * Prevents console spam when the same schema is created multiple times (e.g., in tests or HMR).
11
12
  */
12
13
  const _warnedStorageProviders = new Set();
13
14
  /**
14
- * The storages an `IFileStorageProvider` exists for. `GOOGLE_DRIVE` joined on
15
- * 2026-09-09 (#394 P5): its bytes stay in Drive, read and written through the
16
- * connected account of the person who linked or uploaded them. `ONEDRIVE` and
17
- * `DROPBOX` remain declared-but-unserved until each gets a provider.
15
+ * The storages the ENGINE serves itself. `GOOGLE_DRIVE` joined on 2026-09-09 (#394 P5): its bytes stay
16
+ * in Drive, read and written through the connected account of the person who linked or uploaded them.
17
+ * Any other member is served only when a loaded provider contributes an adapter (#1674) —
18
+ * `ONEDRIVE` by the engine's `microsoft-onedrive` once scoped — which this decorator package cannot see, so it
19
+ * warns about those members rather than refusing them.
18
20
  */
19
21
  const _supportedProviders = new Set([FileStorageAccepted.WILDO_MANAGED, FileStorageAccepted.LOCAL_DIRECTORY, FileStorageAccepted.GOOGLE_DRIVE]);
20
22
  const GENERATED_PDF_MIME_TYPES = ['application/pdf'];
@@ -23,15 +25,15 @@ const GENERATION_METADATA_KEYS = new Set(['source', 'templateId']);
23
25
  * Zod schema for SingleFileValue.
24
26
  */
25
27
  export const SingleFileValueSchema = z.object({
26
- fileId: z.string().min(1),
27
- updatedAt: z.date(),
28
+ 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."),
29
+ updatedAt: z.date().describe("When this file reference was last set."),
28
30
  });
29
31
  /**
30
32
  * Zod schema for MultipleFileValue.
31
33
  */
32
34
  export const MultipleFileValueSchema = z.object({
33
- fileIds: z.array(z.string().min(1)),
34
- updatedAt: z.date(),
35
+ fileIds: z.array(z.string().min(1)).describe("The stored files' identifiers, in order."),
36
+ updatedAt: z.date().describe("When this file reference was last set."),
35
37
  });
36
38
  /**
37
39
  * Resolve MIME type groups to actual MIME types.
@@ -172,16 +174,24 @@ function assertGeneratedPdfFileOptions(params) {
172
174
  */
173
175
  export function createFileSchema(options = {}) {
174
176
  const { overridable = true, allowedMimeTypes, maxSize, minSize, multiple = false, maxFiles, nature, storageAccepted, filePathBinding, generation, imageConstraints, videoConstraints, audioConstraints, documentConstraints, ragSource, textExtraction, scanPolicy, onParentDelete = 'cascade', sharable, sharableDefaults, } = options;
175
- // Warn at schema creation for a storage no provider serves yet — a declared vocabulary member with no implementation
177
+ // Warn at schema creation for a storage the engine does not serve itself — served only if a provider package contributes it
176
178
  // Uses deduplication to avoid console spam during tests or HMR
177
179
  if (storageAccepted && storageAccepted.some(s => !_supportedProviders.has(s))) {
178
180
  const unsupported = storageAccepted.filter(s => !_supportedProviders.has(s));
179
181
  const warnKey = unsupported.sort().join(',');
180
182
  if (!_warnedStorageProviders.has(warnKey)) {
181
183
  _warnedStorageProviders.add(warnKey);
182
- console.warn(`[z_file] storageAccepted contains unsupported providers: ${unsupported.join(', ')}. ` +
183
- `Implemented: ${[..._supportedProviders].map((s) => `'${s}'`).join(', ')}. ` +
184
- `A declared-but-unserved storage is skipped by the storage router until its provider exists.`);
184
+ // The two cases are NOT the same outcome, and saying only "skipped" understates the second
185
+ // badly enough to be misleading: alongside an implemented storage the declaration really is
186
+ // ignored, but as the ONLY declared storage it stops the application booting. That is the
187
+ // split #460 records, stated here at the moment an author writes the declaration — earlier
188
+ // than the startup validator and the storage router, which draw the same distinction.
189
+ console.warn(`[z_file] storageAccepted names storage(s) the engine does not serve itself: ${unsupported.join(', ')}. ` +
190
+ `The engine serves: ${[..._supportedProviders].map((s) => `'${s}'`).join(', ')}. ` +
191
+ `Another storage is served only when a provider the application scopes contributes an adapter for it ` +
192
+ `('onedrive': the engine's microsoft-onedrive provider). With none, declared ALONGSIDE a served storage it is ` +
193
+ `skipped by the storage router; declared as the ONLY storage the application refuses to boot and every upload ` +
194
+ `to this field is refused, and no environment variable enables it — a storage with no provider cannot be configured into existence.`);
185
195
  }
186
196
  }
187
197
  if (filePathBinding) {
@@ -211,12 +221,12 @@ export function createFileSchema(options = {}) {
211
221
  // Create the file object schema based on single/multiple
212
222
  const fileSchema = multiple
213
223
  ? z.object({
214
- fileIds: z.array(z.string().min(1)),
215
- updatedAt: z.date(),
224
+ fileIds: z.array(z.string().min(1)).describe("The stored files' identifiers, in order."),
225
+ updatedAt: z.date().describe("When this file reference was last set."),
216
226
  })
217
227
  : z.object({
218
- fileId: z.string().min(1),
219
- updatedAt: z.date(),
228
+ 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."),
229
+ updatedAt: z.date().describe("When this file reference was last set."),
220
230
  });
221
231
  // No longer stored in metadata — consumers derive accept from allowedMimeTypes via buildAcceptAttribute()
222
232
  // Store file metadata in SCHEMA_METADATA.fileConfig
@@ -392,72 +402,70 @@ export function isMimeTypeAllowed(mimeType, allowedMimeTypes) {
392
402
  return false;
393
403
  }
394
404
  /**
395
- * Get a human-readable description of allowed file types.
396
- * Uses UnifiedFileFormatRegistry for better format detection.
405
+ * How an accepted file type is identified — the discriminator of {@link AcceptedFileKind}.
397
406
  */
398
- export function getAcceptDescription(allowedMimeTypes) {
407
+ export var AcceptedFileKindCategory;
408
+ (function (AcceptedFileKindCategory) {
409
+ /** A broad nature (images, PDF, office documents, …) — one {@link FileNature} member. */
410
+ AcceptedFileKindCategory["NATURE"] = "nature";
411
+ /** A text format an agent can produce — one {@link AgentFileFormat} member. */
412
+ AcceptedFileKindCategory["AGENT_FORMAT"] = "agent_format";
413
+ /** Neither: the MIME subtype itself (`csv` for `text/csv`), shown as the value it is. */
414
+ AcceptedFileKindCategory["MIME_SUBTYPE"] = "mime_subtype";
415
+ })(AcceptedFileKindCategory || (AcceptedFileKindCategory = {}));
416
+ const AGENT_FILE_FORMAT_VALUES = new Set(Object.values(AgentFileFormat));
417
+ /**
418
+ * The kinds of file a field's `allowedMimeTypes` admit, deduplicated, in first-seen order. An empty
419
+ * result means every file is accepted.
420
+ *
421
+ * This answers FACTS and the renderer names them from its label tree. It used to answer an English
422
+ * sentence ("Images, PDF, Text files") from two hand-kept maps plus a humanizing fallback — words
423
+ * produced by code in a package with no i18n at all, which no locale could translate (#1283,
424
+ * `.claude/rules/display-text-comes-from-i18n.md`).
425
+ *
426
+ * Resolution per MIME type: the unified format registry first (a nature, or an agent format), then
427
+ * the broad MIME families the registry does not classify, then the subtype as a value.
428
+ */
429
+ export function getAcceptedFileKinds(allowedMimeTypes) {
399
430
  if (!allowedMimeTypes || allowedMimeTypes.length === 0)
400
- return 'All files';
401
- const types = new Set();
431
+ return [];
432
+ const kinds = [];
433
+ const seen = new Set();
434
+ const add = (kind, identity) => {
435
+ if (seen.has(identity))
436
+ return;
437
+ seen.add(identity);
438
+ kinds.push(kind);
439
+ };
440
+ const addNature = (nature) => add({ category: AcceptedFileKindCategory.NATURE, nature }, `nature:${nature}`);
402
441
  for (const mime of allowedMimeTypes) {
403
- // Use registry to detect format type
404
442
  const formatType = UnifiedFileFormatRegistry.getFormatTypeFromMimeType(mime);
405
- if (formatType) {
406
- if (formatType.type === 'nature') {
407
- // Map FileNature to human-readable names
408
- const natureNames = {
409
- [FileNature.IMAGE]: 'Images',
410
- [FileNature.VIDEO]: 'Videos',
411
- [FileNature.AUDIO]: 'Audio files',
412
- [FileNature.PDF]: 'PDF',
413
- [FileNature.OFFICE]: 'Office documents',
414
- [FileNature.ARCHIVE]: 'Archives',
415
- };
416
- const name = natureNames[formatType.nature];
417
- if (name) {
418
- types.add(name);
419
- continue;
420
- }
421
- }
422
- else if (formatType.type === 'agent') {
423
- // Map agent formats to human-readable names
424
- const agentNames = {
425
- 'text': 'Text files',
426
- 'markdown': 'Markdown',
427
- 'json': 'JSON',
428
- 'typescript': 'TypeScript',
429
- 'typescript_react': 'TypeScript React',
430
- 'yaml': 'YAML',
431
- };
432
- const name = agentNames[formatType.format] || formatType.format.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
433
- types.add(name);
434
- continue;
435
- }
436
- }
437
- // Fallback: use MIME type patterns
438
- if (mime === 'application/pdf') {
439
- types.add('PDF');
440
- }
441
- else if (mime.startsWith('image/')) {
442
- types.add('Images');
443
+ if (formatType?.type === 'nature') {
444
+ addNature(formatType.nature);
445
+ continue;
443
446
  }
444
- else if (mime.startsWith('video/')) {
445
- types.add('Videos');
446
- }
447
- else if (mime.startsWith('audio/')) {
448
- types.add('Audio');
449
- }
450
- else if (mime.includes('document') || mime.includes('word') || mime.includes('excel') || mime.includes('powerpoint')) {
451
- types.add('Office documents');
447
+ if (formatType?.type === 'agent' && AGENT_FILE_FORMAT_VALUES.has(formatType.format)) {
448
+ const format = formatType.format;
449
+ add({ category: AcceptedFileKindCategory.AGENT_FORMAT, format }, `agent:${format}`);
450
+ continue;
452
451
  }
452
+ if (mime === 'application/pdf')
453
+ addNature(FileNature.PDF);
454
+ else if (mime.startsWith('image/'))
455
+ addNature(FileNature.IMAGE);
456
+ else if (mime.startsWith('video/'))
457
+ addNature(FileNature.VIDEO);
458
+ else if (mime.startsWith('audio/'))
459
+ addNature(FileNature.AUDIO);
460
+ else if (mime.includes('document') || mime.includes('word') || mime.includes('excel') || mime.includes('powerpoint'))
461
+ addNature(FileNature.OFFICE);
453
462
  else {
454
- // Get extension-like description
455
- const ext = mime.split('/').pop()?.toUpperCase();
456
- if (ext)
457
- types.add(ext);
463
+ const subtype = mime.split('/').pop();
464
+ if (subtype)
465
+ add({ category: AcceptedFileKindCategory.MIME_SUBTYPE, subtype }, `subtype:${subtype}`);
458
466
  }
459
467
  }
460
- return Array.from(types).join(', ') || 'Selected file types';
468
+ return kinds;
461
469
  }
462
470
  /**
463
471
  * Get file nature from schema metadata.
@@ -545,6 +553,15 @@ function detectDisplayNatureFromMimeType(mimeType) {
545
553
  * 2. `mimeType` (from file metadata or browser File object) → detected via MIME prefix matching
546
554
  * 3. `FileDisplayNature.GENERIC` (fallback)
547
555
  *
556
+ * `FileNature.ALL` is not a nature, it is the ABSENCE of a declaration: a field that accepts anything
557
+ * says nothing about the file in front of it. So it does not decide at step 1 — the file's own MIME
558
+ * type does, exactly as for a field with no declared nature. Until 2026-09-24 it mapped to GENERIC and
559
+ * won, so every file in an open field, a PNG and a PDF included, resolved to GENERIC: no preview, and
560
+ * an authored `OVERLAY` activation always degraded to a download. `resolveFileDisplayPolicy` already
561
+ * describes the intended behaviour ("the file's ACTUAL nature has no displayer — which is only
562
+ * reachable when the schema declared an open nature"); this is what makes that sentence true.
563
+ * `FileNature.ARCHIVE` stays GENERIC at step 1, because that IS a declaration.
564
+ *
548
565
  * @param schemaNature - The `FileNature` declared in schema metadata (from `getFileMetadata(schema)?.nature`)
549
566
  * @param mimeType - The MIME type of the actual file
550
567
  * @returns The `FileDisplayNature` to use for rendering
@@ -556,8 +573,8 @@ function detectDisplayNatureFromMimeType(mimeType) {
556
573
  * ```
557
574
  */
558
575
  export function resolveFileDisplayNature(schemaNature, mimeType) {
559
- // Priority 1: Schema-declared nature
560
- if (schemaNature) {
576
+ // Priority 1: Schema-declared nature — `ALL` declares nothing, so it falls through to the file itself.
577
+ if (schemaNature && schemaNature !== FileNature.ALL) {
561
578
  return FILE_NATURE_TO_DISPLAY_NATURE[schemaNature] ?? FileDisplayNature.GENERIC;
562
579
  }
563
580
  // Priority 2: MIME type detection