@asteby/storefront-react 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account.cjs.map +1 -1
- package/dist/account.js +1 -1
- package/dist/{chunk-Q7UTJIKY.js → chunk-D5L7UZIA.js} +25 -4
- package/dist/chunk-D5L7UZIA.js.map +1 -0
- package/dist/{chunk-PPQEUTXJ.js → chunk-VE7WQPMY.js} +48 -6
- package/dist/chunk-VE7WQPMY.js.map +1 -0
- package/dist/fiscal-server.cjs.map +1 -1
- package/dist/fiscal-server.d.cts +2 -2
- package/dist/fiscal-server.d.ts +2 -2
- package/dist/fiscal-server.js +1 -1
- package/dist/fiscal.cjs +418 -17
- package/dist/fiscal.cjs.map +1 -1
- package/dist/fiscal.css +103 -0
- package/dist/fiscal.d.cts +91 -7
- package/dist/fiscal.d.ts +91 -7
- package/dist/fiscal.js +296 -18
- package/dist/fiscal.js.map +1 -1
- package/dist/{types-BnvSbV6t.d.cts → types-CZ3PleG6.d.cts} +1 -1
- package/dist/{types-BnvSbV6t.d.ts → types-CZ3PleG6.d.ts} +1 -1
- package/package.json +2 -2
- package/dist/chunk-PPQEUTXJ.js.map +0 -1
- package/dist/chunk-Q7UTJIKY.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asteby/storefront-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "React bindings for @asteby/storefront — SSR-safe provider, optimistic cart, Money, responsive Image, prices, variant selection, SEO meta and JSON-LD, section registry and server-rendered theme CSS.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
"react": "^19.0.0"
|
|
164
164
|
},
|
|
165
165
|
"dependencies": {
|
|
166
|
-
"@asteby/storefront": "0.
|
|
166
|
+
"@asteby/storefront": "0.16.0"
|
|
167
167
|
},
|
|
168
168
|
"devDependencies": {
|
|
169
169
|
"@testing-library/react": "^16.3.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fiscal/messages.ts"],"names":[],"mappings":";AAyGA,IAAM,EAAA,GAAqB;AAAA,EACzB,MAAA,EAAQ;AAAA,IACN,MAAA,EAAQ,gBAAA;AAAA,IACR,KAAA,EAAO,KAAA;AAAA,IACP,SAAA,EAAW,6CAAA;AAAA,IACX,SAAA,EAAW,0BAAA;AAAA,IACX,aAAA,EAAe,sDAAA;AAAA,IACf,UAAA,EAAY,yBAAA;AAAA,IACZ,cAAA,EAAgB,kEAAA;AAAA,IAChB,MAAA,EAAQ,mBAAA;AAAA,IACR,UAAA,EAAY,sDAAA;AAAA,IACZ,YAAA,EAAc,qBAAA;AAAA,IACd,kBAAA,EAAoB,0FAAA;AAAA,IACpB,GAAA,EAAK,mBAAA;AAAA,IACL,OAAA,EAAS,mDAAA;AAAA,IACT,SAAA,EAAW,cAAA;AAAA,IACX,YAAA,EAAc,kBAAA;AAAA,IACd,MAAA,EAAQ;AAAA,MACN,QAAA,EAAU,sBAAA;AAAA,MACV,WAAA,EAAa,yCAAA;AAAA,MACb,YAAA,EAAc,+DAAA;AAAA,MACd,OAAA,EAAS,kCAAA;AAAA,MACT,UAAA,EAAY,sDAAA;AAAA,MACZ,aAAA,EAAe;AAAA;AACjB,GACF;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,KAAA,EAAO,oBAAA;AAAA,IACP,QAAA,EAAU,8CAAA;AAAA,IACV,UAAA,EAAY,+BAAA;AAAA,IACZ,MAAA,EAAQ,gBAAA;AAAA,IACR,MAAA,EAAQ,uBAAA;AAAA,IACR,cAAA,EAAgB,qFAAA;AAAA,IAChB,aAAA,EAAe,qFAAA;AAAA,IACf,YAAA,EAAc,iBAAA;AAAA,IACd,MAAA,EAAQ,0BAAA;AAAA,IACR,OAAA,EAAS,6BAAA;AAAA,IACT,MAAA,EA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AAA,IAAQ,CAAC,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,IAAK,OAAO,MAAM,QAAA,IAAY,CAAA,KAAM,OAAO,KAAA,CAAM,CAAA,EAA8B,CAAyC,CAAA,GAAI,CAAA;AAAA,EAC9L;AACA,EAAA,OAAO,GAAA;AACT,CAAA;AAGO,SAAS,cAAA,CAAe,QAAwB,SAAA,EAAgE;AACrH,EAAA,MAAM,IAAA,GAAA,CAAQ,UAAU,OAAA,EAAS,WAAA,GAAc,UAAA,CAAW,IAAI,IAAI,EAAA,GAAK,EAAA;AACvE,EAAA,OAAO,SAAA,GAAY,KAAA,CAAM,IAAA,EAAM,SAAS,CAAA,GAAI,IAAA;AAC9C;AAGO,SAAS,IAAA,CAAK,UAAkB,IAAA,EAA+C;AACpF,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,YAAA,EAAc,CAAC,CAAA,EAAG,CAAA,KAAe,CAAA,IAAK,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,CAAC,CAAC,IAAI,CAAE,CAAA;AAC3F","file":"chunk-PPQEUTXJ.js","sourcesContent":["/** Texts of the fiscal components. Spanish (es-MX) by default, English with `en*`, any locale with `messages`. */\nimport type { FiscalReadError } from './types.js'\n\nexport type DeepPartial<T> = { [K in keyof T]?: T[K] extends Record<string, unknown> ? DeepPartial<T[K]> : T[K] }\n\nexport type FiscalMessages = {\n fields: {\n legend: string\n taxId: string\n taxIdHint: string\n legalName: string\n /** Used when the region publishes no help for the legal name. */\n legalNameHint: string\n postalCode: string\n postalCodeHint: string\n regime: string\n regimeHint: string\n regimeChoose: string\n regimeFromDocument: string\n use: string\n useHint: string\n useChoose: string\n /** `{document}` = the document's name. */\n fromDocument: string\n errors: {\n required: string\n taxIdFormat: string\n postalFormat: string\n unknown: string\n personType: string\n useNotAllowed: string\n }\n }\n reader: {\n /** `{document}`. */\n title: string\n dropHint: string\n dropActive: string\n choose: string\n obtain: string\n privacyBrowser: string\n privacyServer: string\n uploadServer: string\n manual: string\n reading: string\n cancel: string\n done: string\n reviewTitle: string\n reviewHint: string\n confirm: string\n changeFile: string\n saveToAccount: string\n saveConsent: string\n warnings: { qrMismatch: string; stale: string; regimeMissing: string; fieldsMissing: string }\n errors: Record<FiscalReadError, string>\n summaryTitleOne: string\n summaryTitleMany: string\n }\n toggle: {\n label: string\n payDefault: string\n payAndInvoice: string\n profileTitle: string\n change: string\n useOther: string\n useSaved: string\n manualTitle: string\n unavailable: string\n privacy: string\n fieldsOf: { taxId: string; legalName: string; postalCode: string; regime: string; use: string }\n }\n status: {\n title: string\n request: string\n requestHelp: string\n awaitingTitle: string\n awaitingBody: string\n processingTitle: string\n processingBody: string\n processingSlow: string\n refresh: string\n issuedTitle: string\n issuedBody: string\n folio: string\n pdf: string\n xml: string\n needsDataTitle: string\n needsDataBody: string\n correct: string\n reviewTitle: string\n reviewBody: string\n contact: string\n contactBy: string\n windowTitle: string\n windowBody: string\n unavailableTitle: string\n unavailableBody: string\n cancelledTitle: string\n cancelledBody: string\n /** `reason_code` -> cause for the buyer. `default` when unknown. */\n reasons: Record<string, string>\n }\n server: { errors: Record<string, string> }\n}\n\nconst ES: FiscalMessages = {\n fields: {\n legend: 'Datos fiscales',\n taxId: 'RFC',\n taxIdHint: 'Se escribe en mayúsculas y sin espacios.',\n legalName: 'Nombre o razón social',\n legalNameHint: 'Escríbelo tal como aparece en tu registro fiscal.',\n postalCode: 'Código postal fiscal',\n postalCodeHint: 'El de tu domicilio fiscal, que puede ser distinto al de entrega.',\n regime: 'Régimen fiscal',\n regimeHint: 'Solo mostramos los que aplican a tu tipo de persona.',\n regimeChoose: 'Elige tu régimen',\n regimeFromDocument: 'Tu documento menciona más de un régimen. Elige el que usarás para esta factura.',\n use: 'Uso de la factura',\n useHint: 'Solo mostramos los usos que admite tu régimen.',\n useChoose: 'Elige el uso',\n fromDocument: 'De tu {document}',\n errors: {\n required: 'Completa este campo.',\n taxIdFormat: 'Revisa el formato: {kind} no válido.',\n postalFormat: 'Escribe un código postal válido, por ejemplo {example}.',\n unknown: 'Elige una opción de la lista.',\n personType: 'Este régimen no corresponde a tu tipo de persona.',\n useNotAllowed: 'Este uso no está disponible con el régimen elegido.',\n },\n },\n reader: {\n title: 'Sube tu {document}',\n dropHint: 'Arrastra el PDF aquí o toca para elegirlo',\n dropActive: 'Suelta el archivo para leerlo',\n choose: 'Elegir archivo',\n obtain: 'Descárgala aquí',\n privacyBrowser: 'La leemos en tu dispositivo. No guardamos el archivo, solo los datos que confirmes.',\n privacyServer: 'La procesamos y la descartamos al terminar. Solo guardamos los datos que confirmes.',\n uploadServer: 'Leer mi archivo',\n manual: 'Captura tus datos a mano',\n reading: 'Leyendo tu {document}…',\n cancel: 'Cancelar',\n done: 'Listo. Revisa tus datos.',\n reviewTitle: 'Revisa tus datos',\n reviewHint: 'Puedes corregir cualquier campo antes de continuar.',\n confirm: 'Usar estos datos',\n changeFile: 'Subir otro archivo',\n saveToAccount: 'Guardar en mi cuenta para la próxima',\n saveConsent: 'Guardaremos estos datos en tu cuenta para facturar más rápido. Puedes borrarlos cuando quieras.',\n warnings: {\n qrMismatch: 'El código QR de tu documento no coincide con los datos leídos. Revisa con calma tu RFC y tu nombre.',\n stale: 'Tu documento tiene {days} días de emitido. Si algo cambió en tu registro, descarga uno nuevo.',\n regimeMissing: 'No pudimos detectar tu régimen. Elígelo de la lista.',\n fieldsMissing: 'No encontramos algunos datos en el documento. Complétalos para continuar.',\n },\n errors: {\n not_pdf: 'Ese archivo no es un PDF. Sube el PDF que descargaste o captura tus datos a mano.',\n too_large: 'El archivo pesa más de {size}. Sube el PDF original o captura tus datos a mano.',\n no_text: 'Este PDF parece una imagen escaneada y no podemos leerlo. Captura tus datos a mano.',\n password: 'Este PDF tiene contraseña y no podemos abrirlo. Descárgalo de nuevo sin contraseña o captura tus datos a mano.',\n unreadable: 'No pudimos leer este archivo. Inténtalo con otro o captura tus datos a mano.',\n },\n summaryTitleOne: 'Revisa 1 campo para continuar',\n summaryTitleMany: 'Revisa {n} campos para continuar',\n },\n toggle: {\n label: 'Necesito factura (CFDI)',\n payDefault: 'Pagar',\n payAndInvoice: 'Pagar y facturar',\n profileTitle: 'Facturaremos con estos datos',\n change: 'Cambiar',\n useOther: 'Usar otros datos',\n useSaved: 'Usar mis datos guardados',\n manualTitle: 'Datos de facturación',\n unavailable: 'Esta tienda todavía no factura en línea.',\n privacy: 'Usamos estos datos solo para emitir tu factura.',\n fieldsOf: { taxId: 'RFC', legalName: 'Nombre o razón social', postalCode: 'Código postal fiscal', regime: 'Régimen', use: 'Uso' },\n },\n status: {\n title: 'Factura',\n request: 'Solicitar factura',\n requestHelp: '¿Necesitas factura de este pedido?',\n awaitingTitle: 'Esperando tu pago',\n awaitingBody: 'Cuando se acredite tu pago emitimos la factura. Con OXXO o transferencia puede tardar un poco.',\n processingTitle: 'Estamos generando tu factura',\n processingBody: 'Suele tardar menos de un minuto. Esta página se actualiza sola.',\n processingSlow: 'Sigue en proceso. Puedes cerrar esta página: tu factura aparecerá aquí cuando esté lista.',\n refresh: 'Actualizar',\n issuedTitle: 'Tu factura está lista',\n issuedBody: 'Descárgala cuando la necesites. Los enlaces vencen en 15 minutos; vuelve a abrir esta página para generar nuevos.',\n folio: 'Folio fiscal',\n pdf: 'Descargar PDF',\n xml: 'Descargar XML',\n needsDataTitle: 'Faltan datos para tu factura',\n needsDataBody: 'No pudimos emitirla con los datos que nos diste.',\n correct: 'Corregir y reintentar',\n reviewTitle: 'La tienda está revisando tu factura',\n reviewBody: 'Necesita una revisión del negocio. No tienes que hacer nada más; si tarda, escríbenos.',\n contact: 'Contactar a la tienda',\n contactBy: 'Escríbenos a {contact} con tu número de pedido.',\n windowTitle: 'Ya pasó el plazo para facturar',\n windowBody: 'Este pedido está fuera del plazo para pedir factura. Si necesitas ayuda, contacta a la tienda.',\n unavailableTitle: 'Factura no disponible',\n unavailableBody: 'Esta tienda no emite factura de este pedido. Si la necesitas, contáctala.',\n cancelledTitle: 'Factura cancelada',\n cancelledBody: 'Esta factura fue cancelada. Si necesitas una nueva, contacta a la tienda.',\n reasons: {\n 'invoice.tax_id': 'El RFC no es válido.',\n 'invoice.legal_name': 'El nombre o la razón social no coincide con tu registro.',\n 'invoice.tax_regime': 'El régimen fiscal no es válido para tus datos.',\n 'invoice.postal_code': 'El código postal fiscal no es válido.',\n 'invoice.use': 'El uso de la factura no es válido con tu régimen.',\n default: 'Revisa tus datos fiscales y vuelve a intentarlo.',\n },\n },\n server: {\n errors: {\n validation: 'Revisa este campo.',\n required: 'Completa este campo.',\n invalid: 'El valor no es válido.',\n },\n },\n}\n\nconst EN: FiscalMessages = {\n fields: {\n legend: 'Tax details',\n taxId: 'Tax ID',\n taxIdHint: 'Uppercase, without spaces.',\n legalName: 'Legal name',\n legalNameHint: 'Write it as it appears in your tax registration.',\n postalCode: 'Tax postal code',\n postalCodeHint: 'The one of your tax address, which can differ from the delivery address.',\n regime: 'Tax regime',\n regimeHint: 'We only list the ones that apply to your kind of taxpayer.',\n regimeChoose: 'Choose your regime',\n regimeFromDocument: 'Your document lists more than one regime. Choose the one for this invoice.',\n use: 'Invoice use',\n useHint: 'We only list the uses your regime admits.',\n useChoose: 'Choose the use',\n fromDocument: 'From your {document}',\n errors: {\n required: 'Fill in this field.',\n taxIdFormat: 'Check the format: not a valid {kind}.',\n postalFormat: 'Enter a valid postal code, like {example}.',\n unknown: 'Choose an option from the list.',\n personType: 'This regime does not match your kind of taxpayer.',\n useNotAllowed: 'This use is not available with the chosen regime.',\n },\n },\n reader: {\n title: 'Upload your {document}',\n dropHint: 'Drag the PDF here or tap to choose it',\n dropActive: 'Drop the file to read it',\n choose: 'Choose file',\n obtain: 'Get it here',\n privacyBrowser: 'We read it on your device. We do not keep the file, only the details you confirm.',\n privacyServer: 'We process it and discard it when done. We only keep the details you confirm.',\n uploadServer: 'Read my file',\n manual: 'Enter your details by hand',\n reading: 'Reading your {document}…',\n cancel: 'Cancel',\n done: 'Done. Review your details.',\n reviewTitle: 'Review your details',\n reviewHint: 'You can fix any field before continuing.',\n confirm: 'Use these details',\n changeFile: 'Upload another file',\n saveToAccount: 'Save to my account for next time',\n saveConsent: 'We will save these details to your account to invoice faster. You can delete them any time.',\n warnings: {\n qrMismatch: 'The QR code of your document does not match what we read. Check your tax ID and name carefully.',\n stale: 'Your document was issued {days} days ago. If something changed in your registration, download a new one.',\n regimeMissing: 'We could not detect your regime. Choose it from the list.',\n fieldsMissing: 'We did not find some details in the document. Fill them in to continue.',\n },\n errors: {\n not_pdf: 'That file is not a PDF. Upload the PDF you downloaded or enter your details by hand.',\n too_large: 'The file is larger than {size}. Upload the original PDF or enter your details by hand.',\n no_text: 'This PDF looks like a scanned image and we cannot read it. Enter your details by hand.',\n password: 'This PDF is password protected and we cannot open it. Download it again without a password or enter your details by hand.',\n unreadable: 'We could not read this file. Try another one or enter your details by hand.',\n },\n summaryTitleOne: 'Check 1 field to continue',\n summaryTitleMany: 'Check {n} fields to continue',\n },\n toggle: {\n label: 'I need an invoice',\n payDefault: 'Pay',\n payAndInvoice: 'Pay and invoice',\n profileTitle: 'We will invoice with these details',\n change: 'Change',\n useOther: 'Use other details',\n useSaved: 'Use my saved details',\n manualTitle: 'Invoice details',\n unavailable: 'This store does not invoice online yet.',\n privacy: 'We only use these details to issue your invoice.',\n fieldsOf: { taxId: 'Tax ID', legalName: 'Legal name', postalCode: 'Tax postal code', regime: 'Regime', use: 'Use' },\n },\n status: {\n title: 'Invoice',\n request: 'Request invoice',\n requestHelp: 'Do you need an invoice for this order?',\n awaitingTitle: 'Waiting for your payment',\n awaitingBody: 'We issue the invoice once your payment clears. Cash and bank transfers can take a while.',\n processingTitle: 'We are generating your invoice',\n processingBody: 'It usually takes under a minute. This page updates by itself.',\n processingSlow: 'Still in progress. You can close this page: your invoice will show up here when it is ready.',\n refresh: 'Refresh',\n issuedTitle: 'Your invoice is ready',\n issuedBody: 'Download it whenever you need. The links expire in 15 minutes; reopen this page for new ones.',\n folio: 'Tax folio',\n pdf: 'Download PDF',\n xml: 'Download XML',\n needsDataTitle: 'Your invoice needs more details',\n needsDataBody: 'We could not issue it with the details you gave us.',\n correct: 'Fix and retry',\n reviewTitle: 'The store is reviewing your invoice',\n reviewBody: 'It needs a review by the business. You do not need to do anything else; if it takes long, write to us.',\n contact: 'Contact the store',\n contactBy: 'Write to {contact} with your order number.',\n windowTitle: 'The invoicing period has ended',\n windowBody: 'This order is outside the period to request an invoice. If you need help, contact the store.',\n unavailableTitle: 'Invoice not available',\n unavailableBody: 'This store does not issue an invoice for this order. If you need one, contact them.',\n cancelledTitle: 'Invoice cancelled',\n cancelledBody: 'This invoice was cancelled. If you need a new one, contact the store.',\n reasons: {\n 'invoice.tax_id': 'The tax ID is not valid.',\n 'invoice.legal_name': 'The legal name does not match your registration.',\n 'invoice.tax_regime': 'The tax regime is not valid for your details.',\n 'invoice.postal_code': 'The tax postal code is not valid.',\n 'invoice.use': 'The invoice use is not valid with your regime.',\n default: 'Check your tax details and try again.',\n },\n },\n server: {\n errors: {\n validation: 'Check this field.',\n required: 'Fill in this field.',\n invalid: 'The value is not valid.',\n },\n },\n}\n\nconst merge = <T extends Record<string, unknown>>(base: T, over: DeepPartial<T> | undefined): T => {\n if (!over) return base\n const out: Record<string, unknown> = { ...base }\n for (const [k, v] of Object.entries(over)) {\n if (v === undefined) continue\n const b = base[k]\n out[k] = typeof v === 'object' && v !== null && !Array.isArray(v) && typeof b === 'object' && b !== null ? merge(b as Record<string, unknown>, v as DeepPartial<Record<string, unknown>>) : v\n }\n return out as T\n}\n\n/** Messages for a locale (`es*` default, `en*`), with optional overrides (merged level by level). */\nexport function fiscalMessages(locale?: string | null, overrides?: DeepPartial<FiscalMessages> | null): FiscalMessages {\n const base = (locale ?? 'es-MX').toLowerCase().startsWith('en') ? EN : ES\n return overrides ? merge(base, overrides) : base\n}\n\n/** `{name}` placeholders. */\nexport function fill(template: string, vars: Record<string, string | number>): string {\n return template.replace(/\\{(\\w+)\\}/g, (m, k: string) => (k in vars ? String(vars[k]) : m))\n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AAW,CAAA,CAAE,MAAM,CAAA;AAC9C,EAAA,IAAI,WAAW,MAAA,KAAW,CAAA,MAAO,YAAA,EAAc,UAAA,CAAW,CAAC,CAAE,CAAA;AAAA,OAAA,IACpD,UAAA,CAAW,MAAA,GAAS,CAAA,EAAG,IAAA,CAAK,KAAK,YAAY,CAAA;AACtD,EAAA,OAAO;AAAA,IACL,MAAM,CAAA,CAAE,IAAA;AAAA,IACR,MAAA;AAAA,IACA,iBAAA,EAAmB,UAAA;AAAA,IACnB,aAAA,EAAe,IAAA;AAAA,IACf,QAAA,EAAU,EAAE,EAAA,CAAG,KAAA;AAAA,IACf,OAAO,CAAA,CAAE,KAAA;AAAA,IACT,UAAU,CAAA,CAAE,QAAA;AAAA,IACZ,OAAA,EAAS,CAAC,GAAG,CAAA,CAAE,OAAO,CAAA;AAAA,IACtB;AAAA,GACF;AACF","file":"chunk-Q7UTJIKY.js","sourcesContent":["/**\n * Pure helpers over the region's fiscal catalog (`Region.fiscal_id`). They know no country: the tax id format, the\n * regimes, the invoice uses and the postal code format are all data.\n */\nimport type { InvoiceRequest, Region, RegionFiscalEntry, RegionFiscalId } from '@asteby/storefront'\nimport type { FiscalFieldName, FiscalFieldValues } from './types.js'\n\nexport type FiscalRegion = Pick<Region, 'address'> & { fiscal_id?: RegionFiscalId }\n\n/** Uppercase, no spaces, hyphens or dots: how a tax id is compared and sent. */\nexport function normalizeTaxId(raw: string): string {\n return raw.replace(/[\\s\\-.]/g, '').toUpperCase()\n}\n\n/** Masks a tax id for display and logs: first 2 and last 3 characters stay (`PE********ABC`). */\nexport function maskTaxId(taxId: string): string {\n const v = taxId.trim()\n return v.length <= 5 ? '*'.repeat(v.length) : `${v.slice(0, 2)}${'*'.repeat(v.length - 5)}${v.slice(-3)}`\n}\n\nconst compile = (pattern: string | undefined): RegExp | null => {\n if (!pattern) return null\n try {\n return new RegExp(pattern)\n } catch {\n return null\n }\n}\n\n/** `null` when the tax id is valid for the region (its pattern or one of its generic ids); otherwise why not. */\nexport function taxIdProblem(fid: RegionFiscalId | undefined, raw: string): 'required' | 'format' | null {\n const v = normalizeTaxId(raw)\n if (!v) return 'required'\n if (!fid) return null\n if (fid.generic_ids.includes(v)) return null\n const re = compile(fid.pattern)\n return re && !re.test(v) ? 'format' : null\n}\n\nexport function postalCodeProblem(region: FiscalRegion, raw: string): 'required' | 'format' | null {\n const v = raw.trim()\n if (!v) return 'required'\n const re = compile(region.address?.postal_code?.pattern)\n return re && !re.test(v) ? 'format' : null\n}\n\n/**\n * Builds the function that tells a person type from a tax id when the region does not publish one. Pass the length\n * of the tax id per type, e.g. `personTypeByLength({ individual: 13, company: 12 })`. Without a function the regimes\n * are not narrowed by person type (the server still checks the combination).\n */\nexport function personTypeByLength(lengths: Record<string, number>): (taxId: string) => string | null {\n return (taxId) => {\n const n = normalizeTaxId(taxId).length\n return Object.keys(lengths).find((t) => lengths[t] === n) ?? null\n }\n}\n\n/** Regimes that fit a person type (all when the type is unknown). */\nexport function regimesFor(fid: RegionFiscalId | undefined, personType: string | null): RegionFiscalEntry[] {\n const all = fid?.regimes ?? []\n if (!personType) return all\n return all.filter((r) => r.person_types.length === 0 || r.person_types.includes(personType))\n}\n\n/** Invoice uses a regime admits (all when no regime is chosen yet). */\nexport function usesFor(fid: RegionFiscalId | undefined, regime: string | null | undefined): RegionFiscalEntry[] {\n const all = fid?.invoice_uses ?? []\n if (!regime) return all\n return all.filter((u) => !u.allowed_regimes || u.allowed_regimes.length === 0 || u.allowed_regimes.includes(regime))\n}\n\nexport type FiscalProblem = 'required' | 'format' | 'unknown' | 'person_type' | 'use_not_allowed'\n\n/** Client-side check of the whole form against the region; the server stays the authority. */\nexport function validateFiscalValues(\n region: FiscalRegion,\n v: Partial<FiscalFieldValues>,\n personTypeOf?: (taxId: string) => string | null,\n): Partial<Record<FiscalFieldName, FiscalProblem>> {\n const fid = region.fiscal_id\n const out: Partial<Record<FiscalFieldName, FiscalProblem>> = {}\n const tax = taxIdProblem(fid, v.tax_id ?? '')\n if (tax) out.tax_id = tax\n if (!(v.legal_name ?? '').trim()) out.legal_name = 'required'\n if (postalCodeProblem(region, v.postal_code ?? '')) out.postal_code = postalCodeProblem(region, v.postal_code ?? '')!\n const regime = v.tax_regime ?? ''\n if (!regime) out.tax_regime = 'required'\n else if (fid) {\n const entry = fid.regimes.find((r) => r.code === regime)\n if (!entry) out.tax_regime = 'unknown'\n else if (!tax && !fid.generic_ids.includes(normalizeTaxId(v.tax_id ?? ''))) {\n const person = personTypeOf?.(v.tax_id ?? '') ?? null\n if (person && entry.person_types.length > 0 && !entry.person_types.includes(person)) out.tax_regime = 'person_type'\n }\n }\n const use = v.use ?? ''\n if (!use) out.use = 'required'\n else if (fid) {\n const entry = fid.invoice_uses.find((u) => u.code === use)\n if (!entry) out.use = 'unknown'\n else if (regime && entry.allowed_regimes && entry.allowed_regimes.length > 0 && !entry.allowed_regimes.includes(regime)) out.use = 'use_not_allowed'\n }\n return out\n}\n\n/** Form values -> the API's `InvoiceRequest` (without `document`). */\nexport function toInvoiceRequest(v: Partial<FiscalFieldValues>, countryCode?: string): InvoiceRequest {\n return {\n requested: true,\n tax_id: normalizeTaxId(v.tax_id ?? ''),\n legal_name: (v.legal_name ?? '').trim(),\n tax_regime: v.tax_regime ?? '',\n use: v.use ?? '',\n postal_code: (v.postal_code ?? '').trim(),\n ...(countryCode ? { country_code: countryCode } : {}),\n }\n}\n\n/** `label_en` for English locales when the region has it. */\nexport function entryLabel(e: RegionFiscalEntry, locale?: string | null): string {\n return (locale ?? 'es-MX').toLowerCase().startsWith('en') && e.label_en ? e.label_en : e.label\n}\n","/** Turns what the engine read into what the UI shows. Shared by the browser reader and the server upload. */\nimport type { FiscalDocumentEvidence } from '@asteby/storefront'\nimport type { IdentityExtraction } from '@asteby/storefront/fiscal-document'\nimport { normalizeTaxId } from './format.js'\nimport type { FiscalExtractionSummary, FiscalFieldName } from './types.js'\n\nconst first = (v: string | string[] | undefined): string => (Array.isArray(v) ? (v[0] ?? '') : (v ?? ''))\n\n/** `evidence` comes from `buildDocumentEvidence`. Only the conventional fields are kept: nothing else can leak. */\nexport function summarizeExtraction(x: IdentityExtraction, evidence: FiscalDocumentEvidence, validRegimes?: Iterable<string>): FiscalExtractionSummary {\n const f = x.fields\n const valid = validRegimes ? new Set(validRegimes) : null\n const raw = f.tax_regime\n const candidates = (Array.isArray(raw) ? raw : raw ? [raw] : []).filter((c) => !valid || valid.has(c))\n const values: FiscalExtractionSummary['values'] = {}\n const from: FiscalFieldName[] = []\n const put = (name: FiscalFieldName, v: string) => {\n if (!v) return\n values[name] = v\n from.push(name)\n }\n put('tax_id', normalizeTaxId(first(f.tax_id)))\n put('legal_name', first(f.legal_name).trim())\n put('postal_code', first(f.postal_code).trim())\n if (candidates.length === 1) put('tax_regime', candidates[0]!)\n else if (candidates.length > 1) from.push('tax_regime')\n return {\n kind: x.kind,\n values,\n regime_candidates: candidates,\n from_document: from,\n qr_match: x.qr.match,\n stale: x.stale,\n age_days: x.age_days,\n missing: [...x.missing],\n evidence,\n }\n}\n"]}
|