@wildo-ai/zod-decorators 1.1.11 → 1.1.13
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.
- package/dist/esm/commons.d.ts.map +1 -1
- package/dist/esm/commons.js.map +1 -1
- package/dist/esm/currencies.shared.schemas.d.ts.map +1 -1
- package/dist/esm/currencies.shared.schemas.js.map +1 -1
- package/dist/esm/files/agent-file-formats.d.ts.map +1 -1
- package/dist/esm/files/agent-file-formats.js.map +1 -1
- package/dist/esm/files/extension-nature-map.d.ts.map +1 -1
- package/dist/esm/files/extension-nature-map.js.map +1 -1
- package/dist/esm/files/file-extensions.enum.d.ts.map +1 -1
- package/dist/esm/files/file-extensions.enum.js.map +1 -1
- package/dist/esm/files/mime-registry.d.ts.map +1 -1
- package/dist/esm/files/mime-registry.js.map +1 -1
- package/dist/esm/files/unified-registry.d.ts.map +1 -1
- package/dist/esm/files/unified-registry.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/install-bigint-json-encoding.d.ts +1 -1
- package/dist/esm/install-bigint-json-encoding.d.ts.map +1 -1
- package/dist/esm/install-bigint-json-encoding.js +1 -1
- package/dist/esm/install-bigint-json-encoding.js.map +1 -1
- package/dist/esm/testing/decorated-test-schemas.d.ts +7 -7
- package/dist/esm/testing/decorated-test-schemas.d.ts.map +1 -1
- package/dist/esm/testing/decorated-test-schemas.js.map +1 -1
- package/dist/esm/testing.d.ts.map +1 -1
- package/dist/esm/testing.js.map +1 -1
- package/dist/esm/zod-address.d.ts.map +1 -1
- package/dist/esm/zod-address.js.map +1 -1
- package/dist/esm/zod-bigdecimal.d.ts +4 -4
- package/dist/esm/zod-bigdecimal.d.ts.map +1 -1
- package/dist/esm/zod-bigdecimal.js.map +1 -1
- package/dist/esm/zod-code.d.ts +4 -4
- package/dist/esm/zod-code.d.ts.map +1 -1
- package/dist/esm/zod-code.js.map +1 -1
- package/dist/esm/zod-color.d.ts.map +1 -1
- package/dist/esm/zod-color.js.map +1 -1
- package/dist/esm/zod-decorators.types.d.ts +116 -9
- package/dist/esm/zod-decorators.types.d.ts.map +1 -1
- package/dist/esm/zod-decorators.types.js +40 -1
- package/dist/esm/zod-decorators.types.js.map +1 -1
- package/dist/esm/zod-document-sequence.d.ts.map +1 -1
- package/dist/esm/zod-document-sequence.js.map +1 -1
- package/dist/esm/zod-duration.d.ts +6 -6
- package/dist/esm/zod-duration.d.ts.map +1 -1
- package/dist/esm/zod-duration.js.map +1 -1
- package/dist/esm/zod-file.d.ts +5 -4
- package/dist/esm/zod-file.d.ts.map +1 -1
- package/dist/esm/zod-file.js +1 -1
- package/dist/esm/zod-file.js.map +1 -1
- package/dist/esm/zod-money.d.ts +4 -4
- package/dist/esm/zod-money.d.ts.map +1 -1
- package/dist/esm/zod-money.js.map +1 -1
- package/dist/esm/zod-phone.d.ts +4 -4
- package/dist/esm/zod-phone.d.ts.map +1 -1
- package/dist/esm/zod-phone.js.map +1 -1
- package/dist/esm/zod-range.d.ts.map +1 -1
- package/dist/esm/zod-range.js.map +1 -1
- package/dist/esm/zod-utils.shared.d.ts +47 -12
- package/dist/esm/zod-utils.shared.d.ts.map +1 -1
- package/dist/esm/zod-utils.shared.js +143 -40
- package/dist/esm/zod-utils.shared.js.map +1 -1
- package/dist/esm/zod-versioned.d.ts.map +1 -1
- package/dist/esm/zod-versioned.js.map +1 -1
- package/dist/esm/zod-wire-date.d.ts +107 -0
- package/dist/esm/zod-wire-date.d.ts.map +1 -0
- package/dist/esm/zod-wire-date.js +162 -0
- package/dist/esm/zod-wire-date.js.map +1 -0
- package/dist/esm/zod-year-month.d.ts +76 -0
- package/dist/esm/zod-year-month.d.ts.map +1 -0
- package/dist/esm/zod-year-month.js +115 -0
- package/dist/esm/zod-year-month.js.map +1 -0
- package/dist/esm/zod.module-override.d.ts +139 -156
- package/dist/esm/zod.module-override.d.ts.map +1 -1
- package/dist/esm/zod.module-override.js +176 -6
- package/dist/esm/zod.module-override.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-document-sequence.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"zod-document-sequence.d.ts","sourceRoot":"","sources":["../../src/zod-document-sequence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,oBAAY,qBAAqB;IAC/B,2FAA2F;IAC3F,YAAY,iBAAiB;IAC7B,iDAAiD;IACjD,WAAW,gBAAgB;CAC5B;AAED,oCAAoC;AACpC,oBAAY,0BAA0B;IACpC,4CAA4C;IAC5C,MAAM,WAAW;IACjB;;;OAGG;IACH,QAAQ,aAAa;CACtB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,qBAAqB,CAAC;IAC7B,6DAA6D;IAC7D,UAAU,CAAC,EAAE,0BAA0B,CAAC;CACzC;AACD,8DAA8D;AAE9D,iHAAiH;AACjH,oBAAY,sBAAsB;IAChC,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,gDAAgD;AAChD,oBAAY,8BAA8B;IACxC,6BAA6B;IAC7B,OAAO,YAAY;IACnB,0BAA0B;IAC1B,IAAI,SAAS;IACb,cAAc;IACd,KAAK,UAAU;IACf,6BAA6B;IAC7B,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,0BAA0B,GAClC;IAAE,QAAQ,CAAC,IAAI,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChF;IAAE,QAAQ,CAAC,IAAI,EAAE,8BAA8B,CAAC,IAAI,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;CAAE,GACpF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AAK,IAAI;gBAAE,OAAO,SAAS,CAAC;YAC1D,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,8BAA8B,CAAC,KAAK,EAAE,CAAC;YAC9D,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;gBAAE,OAAO,SAAS,CAAC;YAC5D,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;aACI,CAAC;YACJ,uGAAuG;YACvG,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,QAAQ;gBAAE,OAAO,SAAS,CAAC;QAC1H,CAAC;IACH,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;QAAE,OAAO,SAAS,CAAC;IACvE,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,KAAK,sBAAsB,CAAC,KAAK;QAC9D,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IACjH,OAAO,EAAE,KAAK,EAAE,KAAM,EAAE,SAAS,EAAE,CAAC;AACtC,CAAC","sourcesContent":["/**\n * @wildo_source:part:start zod.decorators.document-sequence facet:layer:shared facet:family:decorator facet:audience:app-developer\n *\n * A DOCUMENT NUMBER the server allocates: an invoice, quote or job number such as `INV-2026-00042`.\n *\n * Declared on a string field with `.documentSequence({ format, scope })`. The server assigns the next number of the\n * field's sequence when the row is created (or, with `allocation: EXPLICIT`, when the application's own operation asks\n * for it, such as an \"issue\" transition), inside the same transaction as the write. So two documents created at the same\n * instant in one organization get consecutive numbers, and a failed write consumes none: the sequence has no gaps.\n * EU VAT invoicing requires exactly that, a sequential number that identifies each invoice once.\n *\n * The field is never written by a client: the decorator implies `excludeFromCreate`, `excludeFromUpdate`, and a unique\n * index in the sequence's scope.\n *\n * Import from `@wildo-ai/zod-decorators` (the decorator is installed on every string schema).\n *\n * @example\n * invoiceNumber: z.string().documentSequence({ format: 'INV-{YYYY}-{n:5}', scope: DocumentSequenceScope.ORGANIZATION }),\n * // first invoice of 2026 in an organization: INV-2026-00001; the count restarts at 1 in 2027\n */\nexport enum DocumentSequenceScope {\n /** One sequence per organization: two organizations each have their own INV-2026-00001. */\n ORGANIZATION = 'organization',\n /** One sequence across the whole application. */\n APPLICATION = 'application',\n}\n\n/** WHEN the number is allocated. */\nexport enum DocumentSequenceAllocation {\n /** When the row is created. The default. */\n CREATE = 'create',\n /**\n * When the application's own operation allocates it, through the backend's document-sequence allocator: an invoice\n * drafted without a number and numbered when it is issued. The field stays empty until then, so declare it optional.\n */\n EXPLICIT = 'explicit',\n}\n\n/**\n * The parameters of `.documentSequence(...)`.\n *\n * `format` is literal text with these tokens:\n * - `{n}` or `{n:5}`: the sequence number, zero-padded to the width given (exactly one, required);\n * - `{YYYY}` or `{YY}`: the year, which also RESTARTS the count every year;\n * - `{MM}`: the month (with a year token), which restarts the count every month.\n *\n * The year and month are those of the moment the number is allocated, in the organization's timezone for an\n * ORGANIZATION sequence (its profile's `timezone`) and in UTC for an APPLICATION sequence.\n */\nexport interface DocumentSequenceParams {\n format: string;\n scope: DocumentSequenceScope;\n /** Defaults to {@link DocumentSequenceAllocation.CREATE}. */\n allocation?: DocumentSequenceAllocation;\n}\n/** @wildo_source:part:end zod.decorators.document-sequence */\n\n/** How often a sequence's count restarts, derived from its format: the period is never configured separately. */\nexport enum DocumentSequencePeriod {\n NEVER = 'never',\n YEARLY = 'yearly',\n MONTHLY = 'monthly',\n}\n\n/** What one part of a parsed format renders. */\nexport enum DocumentSequenceFormatPartKind {\n /** Text written as it is. */\n LITERAL = 'literal',\n /** `{YYYY}` or `{YY}`. */\n YEAR = 'year',\n /** `{MM}`. */\n MONTH = 'month',\n /** `{n}` / `{n:<width>}`. */\n NUMBER = 'number',\n}\n\nexport type DocumentSequenceFormatPart =\n | { readonly kind: DocumentSequenceFormatPartKind.LITERAL; readonly text: string }\n | { readonly kind: DocumentSequenceFormatPartKind.YEAR; readonly fourDigits: boolean }\n | { readonly kind: DocumentSequenceFormatPartKind.MONTH }\n | { readonly kind: DocumentSequenceFormatPartKind.NUMBER; readonly width: number };\n\n/** A format split into its literal text and tokens. */\nexport interface ParsedDocumentSequenceFormat {\n readonly parts: readonly DocumentSequenceFormatPart[];\n readonly period: DocumentSequencePeriod;\n}\n\n/** The widest zero padding a format may ask for: wider is a typo, not a document number. */\nconst MAX_NUMBER_WIDTH = 12;\n\n/**\n * Parse a format, or throw naming what is wrong. Called when the decorator is applied, so a bad format fails when the\n * schema loads rather than when the first document is created.\n */\nexport function parseDocumentSequenceFormat(format: string): ParsedDocumentSequenceFormat {\n if (typeof format !== 'string' || format.length === 0) throw new Error('documentSequence: format must be a non-empty string such as \"INV-{YYYY}-{n:5}\".');\n const parts: DocumentSequenceFormatPart[] = [];\n const tokenPattern = /\\{([^{}]*)\\}/gu;\n let cursor = 0;\n let numbers = 0;\n let year = false;\n let month = false;\n for (const match of format.matchAll(tokenPattern)) {\n const literal = format.slice(cursor, match.index);\n if (/[{}]/u.test(literal)) throw new Error(`documentSequence: format \"${format}\" has an unbalanced brace.`);\n if (literal.length > 0) parts.push({ kind: DocumentSequenceFormatPartKind.LITERAL, text: literal });\n const token = match[1]!;\n const numberToken = /^n(?::(\\d+))?$/u.exec(token);\n if (numberToken !== null) {\n const width = numberToken[1] === undefined ? 1 : Number(numberToken[1]);\n if (width < 1 || width > MAX_NUMBER_WIDTH) throw new Error(`documentSequence: format \"${format}\" pads the number to ${width}; use 1 to ${MAX_NUMBER_WIDTH}.`);\n parts.push({ kind: DocumentSequenceFormatPartKind.NUMBER, width });\n numbers += 1;\n } else if (token === 'YYYY' || token === 'YY') {\n parts.push({ kind: DocumentSequenceFormatPartKind.YEAR, fourDigits: token === 'YYYY' });\n year = true;\n } else if (token === 'MM') {\n parts.push({ kind: DocumentSequenceFormatPartKind.MONTH });\n month = true;\n } else {\n throw new Error(`documentSequence: format \"${format}\" has an unknown token \"{${token}}\"; the tokens are {n}, {n:<width>}, {YYYY}, {YY} and {MM}.`);\n }\n cursor = match.index + match[0].length;\n }\n const tail = format.slice(cursor);\n if (/[{}]/u.test(tail)) throw new Error(`documentSequence: format \"${format}\" has an unbalanced brace.`);\n if (tail.length > 0) parts.push({ kind: DocumentSequenceFormatPartKind.LITERAL, text: tail });\n if (numbers !== 1) throw new Error(`documentSequence: format \"${format}\" must contain exactly one {n} token; it has ${numbers}.`);\n if (month && !year) throw new Error(`documentSequence: format \"${format}\" has {MM} without a year, so January would repeat every year's numbers.`);\n return { parts, period: month ? DocumentSequencePeriod.MONTHLY : year ? DocumentSequencePeriod.YEARLY : DocumentSequencePeriod.NEVER };\n}\n\n/** The calendar year and month of `at` in `timeZone` (an IANA zone; UTC when absent or unknown). */\nfunction calendarOf(at: Date, timeZone: string | undefined): { year: number; month: number } {\n try {\n const parts = new Intl.DateTimeFormat('en-US', { timeZone: timeZone ?? 'UTC', year: 'numeric', month: 'numeric' }).formatToParts(at);\n const year = Number(parts.find((part) => part.type === 'year')?.value);\n const month = Number(parts.find((part) => part.type === 'month')?.value);\n if (Number.isFinite(year) && Number.isFinite(month)) return { year, month };\n } catch {\n // An unknown zone falls back to UTC below: a document number must still be allocated.\n }\n return { year: at.getUTCFullYear(), month: at.getUTCMonth() + 1 };\n}\n\n/**\n * The key of the counting period `at` falls in: `''` for a sequence that never restarts, `'2026'` yearly, `'2026-10'`\n * monthly. Two allocations share a counter exactly when they share this key.\n */\nexport function documentSequencePeriodKey(parsed: ParsedDocumentSequenceFormat, at: Date, timeZone?: string): string {\n if (parsed.period === DocumentSequencePeriod.NEVER) return '';\n const { year, month } = calendarOf(at, timeZone);\n return parsed.period === DocumentSequencePeriod.YEARLY ? String(year) : `${year}-${String(month).padStart(2, '0')}`;\n}\n\n/** The document number for count `value`, allocated at `at`. */\nexport function formatDocumentSequenceValue(parsed: ParsedDocumentSequenceFormat, value: number, at: Date, timeZone?: string): string {\n const { year, month } = calendarOf(at, timeZone);\n return parsed.parts.map((part) => {\n switch (part.kind) {\n case DocumentSequenceFormatPartKind.LITERAL: return part.text;\n case DocumentSequenceFormatPartKind.YEAR: return part.fourDigits ? String(year) : String(year % 100).padStart(2, '0');\n case DocumentSequenceFormatPartKind.MONTH: return String(month).padStart(2, '0');\n case DocumentSequenceFormatPartKind.NUMBER: return String(value).padStart(part.width, '0');\n }\n }).join('');\n}\n\n/** What a document number says about the count it carries: the count, and the key of the period it was counted in. */\nexport interface ReadDocumentSequenceValue {\n readonly value: number;\n /** As {@link documentSequencePeriodKey} would compute it: `''`, `'2026'` or `'2026-10'`. */\n readonly periodKey: string;\n}\n\n/** Escape text for use inside a regular expression. */\nfunction escapeForPattern(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/gu, '\\\\$&');\n}\n\n/**\n * Read a document number back: the count it carries and its period, or `undefined` when `text` is not EXACTLY\n * what {@link formatDocumentSequenceValue} renders for some count under this format.\n *\n * Exact on purpose. The question this answers is \"could the counter one day hand out this number?\", which is what\n * makes an existing value collide with a new one on the unique index. `INV-2026-042` under `INV-{YYYY}-{n:5}` is not a\n * number the counter can produce (it pads to 5), so it can never collide, and it is not read. Nor is free text.\n *\n * A two-digit year (`{YY}`) is read as 20YY: the format keeps no century, and a document numbered by this system was\n * numbered in this century.\n */\nexport function readDocumentSequenceValue(parsed: ParsedDocumentSequenceFormat, text: string): ReadDocumentSequenceValue | undefined {\n const pattern = parsed.parts.map((part) => {\n switch (part.kind) {\n case DocumentSequenceFormatPartKind.LITERAL: return escapeForPattern(part.text);\n case DocumentSequenceFormatPartKind.YEAR: return part.fourDigits ? '(\\\\d{4})' : '(\\\\d{2})';\n case DocumentSequenceFormatPartKind.MONTH: return '(\\\\d{2})';\n case DocumentSequenceFormatPartKind.NUMBER: return `(\\\\d{${part.width},})`;\n }\n }).join('');\n const match = new RegExp(`^${pattern}$`, 'u').exec(text);\n if (match === null) return undefined;\n let year: number | undefined;\n let month: number | undefined;\n let value: number | undefined;\n let group = 1;\n for (const part of parsed.parts) {\n if (part.kind === DocumentSequenceFormatPartKind.LITERAL) continue;\n const captured = match[group]!;\n group += 1;\n if (part.kind === DocumentSequenceFormatPartKind.YEAR) {\n // A format may repeat a token (`{YYYY}-{YY}`); text whose repeats disagree is text the formatter never renders.\n const read = part.fourDigits ? Number(captured) : 2000 + Number(captured);\n if (year !== undefined && year !== read) return undefined;\n year = read;\n } else if (part.kind === DocumentSequenceFormatPartKind.MONTH) {\n const read = Number(captured);\n if (month !== undefined && month !== read) return undefined;\n month = read;\n }\n else {\n // Only the canonical rendering: no leading zero beyond the padding, and a count the counter can reach.\n value = Number(captured);\n if (!Number.isSafeInteger(value) || value < 1 || String(value).padStart(part.width, '0') !== captured) return undefined;\n }\n }\n if (month !== undefined && (month < 1 || month > 12)) return undefined;\n const periodKey = parsed.period === DocumentSequencePeriod.NEVER\n ? ''\n : parsed.period === DocumentSequencePeriod.YEARLY ? String(year) : `${year}-${String(month).padStart(2, '0')}`;\n return { value: value!, periodKey };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"zod-document-sequence.js","sourceRoot":"","sources":["../../src/zod-document-sequence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAN,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAC/B,2FAA2F;IAC3F,sDA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,IAAI,IAAI,KAAK,IAAI;gBAAE,OAAO,SAAS,CAAC;YAC1D,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,8BAA8B,CAAC,KAAK,EAAE,CAAC;YAC9D,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;gBAAE,OAAO,SAAS,CAAC;YAC5D,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;aACI,CAAC;YACJ,uGAAuG;YACvG,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,QAAQ;gBAAE,OAAO,SAAS,CAAC;QAC1H,CAAC;IACH,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;QAAE,OAAO,SAAS,CAAC;IACvE,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,KAAK,sBAAsB,CAAC,KAAK;QAC9D,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IACjH,OAAO,EAAE,KAAK,EAAE,KAAM,EAAE,SAAS,EAAE,CAAC;AACtC,CAAC","sourcesContent":["/**\n * @wildo_source:part:start zod.decorators.document-sequence facet:layer:shared facet:family:decorator facet:audience:app-developer\n *\n * A DOCUMENT NUMBER the server allocates: an invoice, quote or job number such as `INV-2026-00042`.\n *\n * Declared on a string field with `.documentSequence({ format, scope })`. The server assigns the next number of the\n * field's sequence when the row is created (or, with `allocation: EXPLICIT`, when the application's own operation asks\n * for it, such as an \"issue\" transition), inside the same transaction as the write. So two documents created at the same\n * instant in one organization get consecutive numbers, and a failed write consumes none: the sequence has no gaps.\n * EU VAT invoicing requires exactly that, a sequential number that identifies each invoice once.\n *\n * The field is never written by a client: the decorator implies `excludeFromCreate`, `excludeFromUpdate`, and a unique\n * index in the sequence's scope.\n *\n * Import from `@wildo-ai/zod-decorators` (the decorator is installed on every string schema).\n *\n * @example\n * invoiceNumber: z.string().documentSequence({ format: 'INV-{YYYY}-{n:5}', scope: DocumentSequenceScope.ORGANIZATION }),\n * // first invoice of 2026 in an organization: INV-2026-00001; the count restarts at 1 in 2027\n */\nexport enum DocumentSequenceScope {\n /** One sequence per organization: two organizations each have their own INV-2026-00001. */\n ORGANIZATION = 'organization',\n /** One sequence across the whole application. */\n APPLICATION = 'application',\n}\n\n/** WHEN the number is allocated. */\nexport enum DocumentSequenceAllocation {\n /** When the row is created. The default. */\n CREATE = 'create',\n /**\n * When the application's own operation allocates it, through the backend's document-sequence allocator: an invoice\n * drafted without a number and numbered when it is issued. The field stays empty until then, so declare it optional.\n */\n EXPLICIT = 'explicit',\n}\n\n/**\n * The parameters of `.documentSequence(...)`.\n *\n * `format` is literal text with these tokens:\n * - `{n}` or `{n:5}`: the sequence number, zero-padded to the width given (exactly one, required);\n * - `{YYYY}` or `{YY}`: the year, which also RESTARTS the count every year;\n * - `{MM}`: the month (with a year token), which restarts the count every month.\n *\n * The year and month are those of the moment the number is allocated, in the organization's timezone for an\n * ORGANIZATION sequence (its profile's `timezone`) and in UTC for an APPLICATION sequence.\n */\nexport interface DocumentSequenceParams {\n format: string;\n scope: DocumentSequenceScope;\n /** Defaults to {@link DocumentSequenceAllocation.CREATE}. */\n allocation?: DocumentSequenceAllocation;\n}\n/** @wildo_source:part:end zod.decorators.document-sequence */\n\n/** How often a sequence's count restarts, derived from its format: the period is never configured separately. */\nexport enum DocumentSequencePeriod {\n NEVER = 'never',\n YEARLY = 'yearly',\n MONTHLY = 'monthly',\n}\n\n/** What one part of a parsed format renders. */\nexport enum DocumentSequenceFormatPartKind {\n /** Text written as it is. */\n LITERAL = 'literal',\n /** `{YYYY}` or `{YY}`. */\n YEAR = 'year',\n /** `{MM}`. */\n MONTH = 'month',\n /** `{n}` / `{n:<width>}`. */\n NUMBER = 'number',\n}\n\nexport type DocumentSequenceFormatPart =\n | { readonly kind: DocumentSequenceFormatPartKind.LITERAL; readonly text: string }\n | { readonly kind: DocumentSequenceFormatPartKind.YEAR; readonly fourDigits: boolean }\n | { readonly kind: DocumentSequenceFormatPartKind.MONTH }\n | { readonly kind: DocumentSequenceFormatPartKind.NUMBER; readonly width: number };\n\n/** A format split into its literal text and tokens. */\nexport interface ParsedDocumentSequenceFormat {\n readonly parts: readonly DocumentSequenceFormatPart[];\n readonly period: DocumentSequencePeriod;\n}\n\n/** The widest zero padding a format may ask for: wider is a typo, not a document number. */\nconst MAX_NUMBER_WIDTH = 12;\n\n/**\n * Parse a format, or throw naming what is wrong. Called when the decorator is applied, so a bad format fails when the\n * schema loads rather than when the first document is created.\n */\nexport function parseDocumentSequenceFormat(format: string): ParsedDocumentSequenceFormat {\n if (typeof format !== 'string' || format.length === 0) throw new Error('documentSequence: format must be a non-empty string such as \"INV-{YYYY}-{n:5}\".');\n const parts: DocumentSequenceFormatPart[] = [];\n const tokenPattern = /\\{([^{}]*)\\}/gu;\n let cursor = 0;\n let numbers = 0;\n let year = false;\n let month = false;\n for (const match of format.matchAll(tokenPattern)) {\n const literal = format.slice(cursor, match.index);\n if (/[{}]/u.test(literal)) throw new Error(`documentSequence: format \"${format}\" has an unbalanced brace.`);\n if (literal.length > 0) parts.push({ kind: DocumentSequenceFormatPartKind.LITERAL, text: literal });\n const token = match[1]!;\n const numberToken = /^n(?::(\\d+))?$/u.exec(token);\n if (numberToken !== null) {\n const width = numberToken[1] === undefined ? 1 : Number(numberToken[1]);\n if (width < 1 || width > MAX_NUMBER_WIDTH) throw new Error(`documentSequence: format \"${format}\" pads the number to ${width}; use 1 to ${MAX_NUMBER_WIDTH}.`);\n parts.push({ kind: DocumentSequenceFormatPartKind.NUMBER, width });\n numbers += 1;\n } else if (token === 'YYYY' || token === 'YY') {\n parts.push({ kind: DocumentSequenceFormatPartKind.YEAR, fourDigits: token === 'YYYY' });\n year = true;\n } else if (token === 'MM') {\n parts.push({ kind: DocumentSequenceFormatPartKind.MONTH });\n month = true;\n } else {\n throw new Error(`documentSequence: format \"${format}\" has an unknown token \"{${token}}\"; the tokens are {n}, {n:<width>}, {YYYY}, {YY} and {MM}.`);\n }\n cursor = match.index + match[0].length;\n }\n const tail = format.slice(cursor);\n if (/[{}]/u.test(tail)) throw new Error(`documentSequence: format \"${format}\" has an unbalanced brace.`);\n if (tail.length > 0) parts.push({ kind: DocumentSequenceFormatPartKind.LITERAL, text: tail });\n if (numbers !== 1) throw new Error(`documentSequence: format \"${format}\" must contain exactly one {n} token; it has ${numbers}.`);\n if (month && !year) throw new Error(`documentSequence: format \"${format}\" has {MM} without a year, so January would repeat every year's numbers.`);\n return { parts, period: month ? DocumentSequencePeriod.MONTHLY : year ? DocumentSequencePeriod.YEARLY : DocumentSequencePeriod.NEVER };\n}\n\n/** The calendar year and month of `at` in `timeZone` (an IANA zone; UTC when absent or unknown). */\nfunction calendarOf(at: Date, timeZone: string | undefined): { year: number; month: number } {\n try {\n const parts = new Intl.DateTimeFormat('en-US', { timeZone: timeZone ?? 'UTC', year: 'numeric', month: 'numeric' }).formatToParts(at);\n const year = Number(parts.find((part) => part.type === 'year')?.value);\n const month = Number(parts.find((part) => part.type === 'month')?.value);\n if (Number.isFinite(year) && Number.isFinite(month)) return { year, month };\n } catch {\n // An unknown zone falls back to UTC below: a document number must still be allocated.\n }\n return { year: at.getUTCFullYear(), month: at.getUTCMonth() + 1 };\n}\n\n/**\n * The key of the counting period `at` falls in: `''` for a sequence that never restarts, `'2026'` yearly, `'2026-10'`\n * monthly. Two allocations share a counter exactly when they share this key.\n */\nexport function documentSequencePeriodKey(parsed: ParsedDocumentSequenceFormat, at: Date, timeZone?: string): string {\n if (parsed.period === DocumentSequencePeriod.NEVER) return '';\n const { year, month } = calendarOf(at, timeZone);\n return parsed.period === DocumentSequencePeriod.YEARLY ? String(year) : `${year}-${String(month).padStart(2, '0')}`;\n}\n\n/** The document number for count `value`, allocated at `at`. */\nexport function formatDocumentSequenceValue(parsed: ParsedDocumentSequenceFormat, value: number, at: Date, timeZone?: string): string {\n const { year, month } = calendarOf(at, timeZone);\n return parsed.parts.map((part) => {\n switch (part.kind) {\n case DocumentSequenceFormatPartKind.LITERAL: return part.text;\n case DocumentSequenceFormatPartKind.YEAR: return part.fourDigits ? String(year) : String(year % 100).padStart(2, '0');\n case DocumentSequenceFormatPartKind.MONTH: return String(month).padStart(2, '0');\n case DocumentSequenceFormatPartKind.NUMBER: return String(value).padStart(part.width, '0');\n }\n }).join('');\n}\n\n/** What a document number says about the count it carries: the count, and the key of the period it was counted in. */\nexport interface ReadDocumentSequenceValue {\n readonly value: number;\n /** As {@link documentSequencePeriodKey} would compute it: `''`, `'2026'` or `'2026-10'`. */\n readonly periodKey: string;\n}\n\n/** Escape text for use inside a regular expression. */\nfunction escapeForPattern(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/gu, '\\\\$&');\n}\n\n/**\n * Read a document number back: the count it carries and its period, or `undefined` when `text` is not EXACTLY\n * what {@link formatDocumentSequenceValue} renders for some count under this format.\n *\n * Exact on purpose. The question this answers is \"could the counter one day hand out this number?\", which is what\n * makes an existing value collide with a new one on the unique index. `INV-2026-042` under `INV-{YYYY}-{n:5}` is not a\n * number the counter can produce (it pads to 5), so it can never collide, and it is not read. Nor is free text.\n *\n * A two-digit year (`{YY}`) is read as 20YY: the format keeps no century, and a document numbered by this system was\n * numbered in this century.\n */\nexport function readDocumentSequenceValue(parsed: ParsedDocumentSequenceFormat, text: string): ReadDocumentSequenceValue | undefined {\n const pattern = parsed.parts.map((part) => {\n switch (part.kind) {\n case DocumentSequenceFormatPartKind.LITERAL: return escapeForPattern(part.text);\n case DocumentSequenceFormatPartKind.YEAR: return part.fourDigits ? '(\\\\d{4})' : '(\\\\d{2})';\n case DocumentSequenceFormatPartKind.MONTH: return '(\\\\d{2})';\n case DocumentSequenceFormatPartKind.NUMBER: return `(\\\\d{${part.width},})`;\n }\n }).join('');\n const match = new RegExp(`^${pattern}$`, 'u').exec(text);\n if (match === null) return undefined;\n let year: number | undefined;\n let month: number | undefined;\n let value: number | undefined;\n let group = 1;\n for (const part of parsed.parts) {\n if (part.kind === DocumentSequenceFormatPartKind.LITERAL) continue;\n const captured = match[group]!;\n group += 1;\n if (part.kind === DocumentSequenceFormatPartKind.YEAR) {\n // A format may repeat a token (`{YYYY}-{YY}`); text whose repeats disagree is text the formatter never renders.\n const read = part.fourDigits ? Number(captured) : 2000 + Number(captured);\n if (year !== undefined && year !== read) return undefined;\n year = read;\n } else if (part.kind === DocumentSequenceFormatPartKind.MONTH) {\n const read = Number(captured);\n if (month !== undefined && month !== read) return undefined;\n month = read;\n }\n else {\n // Only the canonical rendering: no leading zero beyond the padding, and a count the counter can reach.\n value = Number(captured);\n if (!Number.isSafeInteger(value) || value < 1 || String(value).padStart(part.width, '0') !== captured) return undefined;\n }\n }\n if (month !== undefined && (month < 1 || month > 12)) return undefined;\n const periodKey = parsed.period === DocumentSequencePeriod.NEVER\n ? ''\n : parsed.period === DocumentSequencePeriod.YEARLY ? String(year) : `${year}-${String(month).padStart(2, '0')}`;\n return { value: value!, periodKey };\n}\n"]}
|
|
@@ -31,13 +31,13 @@ export interface DurationSchemaOptions {
|
|
|
31
31
|
maxValue?: number;
|
|
32
32
|
}
|
|
33
33
|
/** Canonical Zod schema for DurationUnit. Clone via `z_clone()` for independent metadata. */
|
|
34
|
-
export declare const DurationUnitSchema:
|
|
34
|
+
export declare const DurationUnitSchema: z.ZodEnum<typeof DurationUnit>;
|
|
35
35
|
/**
|
|
36
36
|
* Zod schema for DurationValue.
|
|
37
37
|
*/
|
|
38
38
|
export declare const DurationValueSchema: z.ZodObject<{
|
|
39
39
|
value: z.ZodNumber;
|
|
40
|
-
unit:
|
|
40
|
+
unit: z.ZodEnum<typeof DurationUnit>;
|
|
41
41
|
}, z.core.$strip>;
|
|
42
42
|
/**
|
|
43
43
|
* Convert a duration to total seconds for canonical storage/comparison.
|
|
@@ -92,10 +92,10 @@ export declare function formatDuration(d: DurationValue, options?: {
|
|
|
92
92
|
export declare function createDurationSchema(options?: DurationSchemaOptions): DecoratedDurationSchema;
|
|
93
93
|
/**
|
|
94
94
|
* The chainable methods of `DecoratedDurationSchema`, returning `this` so a chain of several decorations keeps
|
|
95
|
-
* the type it reached
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
95
|
+
* the type it reached, whatever the receiver is (`typeof field` in a resource specification's field map).
|
|
96
|
+
* A method returning the bare `DecoratedDurationSchema` once won the overload inside the intersection, so that
|
|
97
|
+
* field map rejected `schemaShape.x.<factory>Spec(...)` on a field decorated first. Every other decorator
|
|
98
|
+
* returns the receiver's own type too (#3031), so `.isSummaryField()` leaves the field a `DecoratedDurationSchema`.
|
|
99
99
|
*/
|
|
100
100
|
export interface DecoratedDurationSchemaMethods {
|
|
101
101
|
[ZodDecorator.IS_DB_INDEXED](): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-duration.d.ts","sourceRoot":"","sources":["
|
|
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,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AAC,CAAC,kBAAkB,CAAC;IAEzB,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;QAC9B,KAAK,EAAE,WAAW,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;AAgCD;;;;;;;;;;;;;;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 * The chainable methods of `DecoratedDurationSchema`, returning `this` so a chain of several decorations keeps\n * the type it reached: `.isSummaryField()` turns the field into a `DecoratedPrimitiveZodType<DecoratedDurationSchema>`,\n * and a spec or UI method called after it must return that, not the bare factory type. A method\n * returning `DecoratedDurationSchema` itself won that overload inside the intersection, so a resource\n * specification's field map rejected `schemaShape.x.<factory>Spec(...)` on a decorated field.\n */\nexport interface DecoratedDurationSchemaMethods {\n [ZodDecorator.IS_DB_INDEXED](): this;\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]): this;\n [ZodDecorator.DURATION_SPEC](params?: ZodDecorator_ParamsType[ZodDecorator.DURATION_SPEC]): this;\n [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): this;\n [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): this;\n [ZodDecorator.IS_SUMMARY_FIELD](params?: SummaryFieldParams): this;\n [ZodDecorator.IS_BACKEND_ONLY](params?: ZodDecorator_ParamsType[ZodDecorator.IS_BACKEND_ONLY]): this;\n [ZodDecorator.IS_WRITE_ONLY_SECRET](params?: ZodDecorator_ParamsType[ZodDecorator.IS_WRITE_ONLY_SECRET]): this;\n [ZodDecorator.EXCLUDE_FROM_CREATE](): this;\n [ZodDecorator.EXCLUDE_FROM_UPDATE](): this;\n addDecorators(decorators: DecoratorInput[]): this;\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}> & DecoratedDurationSchemaMethods;\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;IAC1B,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK;IAC1B,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM;IAC5B,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,KAAK;IACjC,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK;IACpC,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,GAAG,GAAG,MAAM,GAAG,KA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cAAc,CAAC,CAAC;IAEpC,OAAO,cAAoD,CAAC;AAC9D,CAAC;AAgCD;;;;;;;;;;;;;;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 * The chainable methods of `DecoratedDurationSchema`, returning `this` so a chain of several decorations keeps\n * the type it reached, whatever the receiver is (`typeof field` in a resource specification's field map).\n * A method returning the bare `DecoratedDurationSchema` once won the overload inside the intersection, so that\n * field map rejected `schemaShape.x.<factory>Spec(...)` on a field decorated first. Every other decorator\n * returns the receiver's own type too (#3031), so `.isSummaryField()` leaves the field a `DecoratedDurationSchema`.\n */\nexport interface DecoratedDurationSchemaMethods {\n [ZodDecorator.IS_DB_INDEXED](): this;\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]): this;\n [ZodDecorator.DURATION_SPEC](params?: ZodDecorator_ParamsType[ZodDecorator.DURATION_SPEC]): this;\n [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): this;\n [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): this;\n [ZodDecorator.IS_SUMMARY_FIELD](params?: SummaryFieldParams): this;\n [ZodDecorator.IS_BACKEND_ONLY](params?: ZodDecorator_ParamsType[ZodDecorator.IS_BACKEND_ONLY]): this;\n [ZodDecorator.IS_WRITE_ONLY_SECRET](params?: ZodDecorator_ParamsType[ZodDecorator.IS_WRITE_ONLY_SECRET]): this;\n [ZodDecorator.EXCLUDE_FROM_CREATE](): this;\n [ZodDecorator.EXCLUDE_FROM_UPDATE](): this;\n addDecorators(decorators: DecoratorInput[]): this;\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}> & DecoratedDurationSchemaMethods;\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"]}
|
package/dist/esm/zod-file.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare function resolveMimeTypes(allowedMimeTypes: string[] | FileMimeTy
|
|
|
48
48
|
*
|
|
49
49
|
* File values are stored as: { fileId: string, updatedAt: Date }
|
|
50
50
|
* - fileId: Reference to the file in storage (foreign key, indexed)
|
|
51
|
-
* - updatedAt: When the file was last
|
|
51
|
+
* - updatedAt: When the file reference was last set. A write may omit it, and the server sets it
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
54
54
|
* ```typescript
|
|
@@ -115,9 +115,10 @@ export declare function createFileSchema(options?: FileSchemaOptions): Decorated
|
|
|
115
115
|
* re-declaring them made both interfaces below fail TS2320: an interface may not extend two types
|
|
116
116
|
* whose same-named member differs, and `TSelf` is not `DecoratedPrimitiveZodType<this>`.
|
|
117
117
|
*
|
|
118
|
-
* Removing the mixin costs nothing
|
|
119
|
-
*
|
|
120
|
-
*
|
|
118
|
+
* Removing the mixin costs nothing: every `ZodObject` decorator returns `DecoratedPrimitiveZodType<this>`,
|
|
119
|
+
* which is `this` itself (#3031), and `this` is `DecoratedFileSchema` here. So `z_file().isHidden()`
|
|
120
|
+
* stays a `DecoratedFileSchema`, keeps `fileUI`/`fileSpec`, and offers every decorator the `ZodObject`
|
|
121
|
+
* augmentation declares rather than the four this mixin listed.
|
|
121
122
|
*/
|
|
122
123
|
/**
|
|
123
124
|
* Return type for single file schemas - includes decorator methods.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-file.d.ts","sourceRoot":"","sources":["
|
|
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,IA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AU,GAAG,OAAO,GAAG,SAAS,CAG1F;AAED,mDAAmD;AACnD,MAAM,WAAW,yBAAyB;IACxC,mEAAmE;IACnE,YAAY,EAAE,uBAAuB,CAAC;IACtC,yDAAyD;IACzD,UAAU,EAAE,oBAAoB,CAAC;IACjC,4DAA4D;IAC5D,aAAa,EAAE,iBAAiB,CAAC;IACjC,6EAA6E;IAC7E,QAAQ,EAAE,OAAO,CAAC;IAClB,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAC/C,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC,GAAG,yBAAyB,CA4B5B"}
|
package/dist/esm/zod-file.js
CHANGED
|
@@ -115,7 +115,7 @@ function assertGeneratedPdfFileOptions(params) {
|
|
|
115
115
|
*
|
|
116
116
|
* File values are stored as: { fileId: string, updatedAt: Date }
|
|
117
117
|
* - fileId: Reference to the file in storage (foreign key, indexed)
|
|
118
|
-
* - updatedAt: When the file was last
|
|
118
|
+
* - updatedAt: When the file reference was last set. A write may omit it, and the server sets it
|
|
119
119
|
*
|
|
120
120
|
* @example
|
|
121
121
|
* ```typescript
|
package/dist/esm/zod-file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,EAElB,UAAU,EACV,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EAGpB,mBAAmB,EAMnB,oBAAoB,EAEpB,YAAY,EAEb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;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AAK,oBAAoB,CAAC,OAAO,CAAC;IAE7F,IAAI,YAAY,IAAI,CAAC,CAAC,0BAA0B,IAAI,CAAC,wBAAwB,CAAC,EAAE,CAAC;QAC/E,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,UAAU,EAAE,mBAAmB,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAClH,CAAC;IAED,OAAO;QACL,YAAY,EAAE,0BAA0B,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 // A decorator returns a decorated COPY (#1308), so the copy is what this factory hands back.\n const declaredSchema = ragSource !== undefined\n ? addDecorators(fileSchema, [{ ref: ZodDecorator.RAG_SOURCE, params: ragSource }])\n : fileSchema;\n\n if (multiple) {\n return declaredSchema as unknown as DecoratedMultipleFileSchema;\n }\n return declaredSchema 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// A file SIZE is display text and belongs to the reader's locale, so it is formatted by\n// `useI18n().formatByteSize` (`RegionalFormattingUtils.formatByteSize`), never here: this package has no\n// reader, and the helper that lived here wrote English `KB`/`MB` after browser-locale digits (#2242).\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 + `${activationNeedsD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AAE,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 reference was last set. A write may omit it, and the server sets it\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 // A decorator returns a decorated COPY (#1308), so the copy is what this factory hands back.\n const declaredSchema = ragSource !== undefined\n ? addDecorators(fileSchema, [{ ref: ZodDecorator.RAG_SOURCE, params: ragSource }])\n : fileSchema;\n\n if (multiple) {\n return declaredSchema as unknown as DecoratedMultipleFileSchema;\n }\n return declaredSchema 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: every `ZodObject` decorator returns `DecoratedPrimitiveZodType<this>`,\n * which is `this` itself (#3031), and `this` is `DecoratedFileSchema` here. So `z_file().isHidden()`\n * stays a `DecoratedFileSchema`, keeps `fileUI`/`fileSpec`, and offers every decorator the `ZodObject`\n * augmentation declares 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// A file SIZE is display text and belongs to the reader's locale, so it is formatted by\n// `useI18n().formatByteSize` (`RegionalFormattingUtils.formatByteSize`), never here: this package has no\n// reader, and the helper that lived here wrote English `KB`/`MB` after browser-locale digits (#2242).\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"]}
|
package/dist/esm/zod-money.d.ts
CHANGED
|
@@ -85,10 +85,10 @@ export declare const MoneyValueSchema: z.ZodObject<{
|
|
|
85
85
|
export declare function createMoneySchema(options?: MoneySchemaOptions): DecoratedMoneySchema;
|
|
86
86
|
/**
|
|
87
87
|
* The chainable methods of `DecoratedMoneySchema`, returning `this` so a chain of several decorations keeps
|
|
88
|
-
* the type it reached
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
88
|
+
* the type it reached, whatever the receiver is (`typeof field` in a resource specification's field map).
|
|
89
|
+
* A method returning the bare `DecoratedMoneySchema` once won the overload inside the intersection, so that
|
|
90
|
+
* field map rejected `schemaShape.x.<factory>Spec(...)` on a field decorated first. Every other decorator
|
|
91
|
+
* returns the receiver's own type too (#3031), so `.isSummaryField()` leaves the field a `DecoratedMoneySchema`.
|
|
92
92
|
*/
|
|
93
93
|
export interface DecoratedMoneySchemaMethods {
|
|
94
94
|
[ZodDecorator.IS_DB_INDEXED](): this;
|