@dojocoding/hacienda-shared
Shared types, constants, enums, and Zod validation schemas for Costa Rica electronic invoicing (Hacienda API v4.4).
This package is used internally by @dojocoding/hacienda-sdk, @dojocoding/hacienda-cli, and @dojocoding/hacienda-mcp. It is not typically imported directly by end users.
Contents
Constants
- Generated catalogs (
shared/src/generated/) -- Code catalogs rendered frompackages/sdk/schemas/codes.jsonbypnpm spec:generate: document type-independent enumerations such asPaymentMethod,SaleCondition,TaxCode,IvaRateCode,IdentificationType,ProvinceCode,CURRENCY_CODES,DISCOUNT_CODES,OTHER_CHARGE_TYPES,EXONERATION_INSTITUTIONS,COMMERCIAL_CODE_TYPESandTRANSACTION_TYPES. Every file starts with aNO EDITARheader: never edit them by hand (the parity-freeze test and thepnpm verifylock detect drift). The pairing registry isscripts/codes-generate/table-map.mjs. - Curated companions -- Human-readable
*_NAMESmaps, derived subsets (REP_*),IVA_RATE_PERCENTAGES,IDENTIFICATION_LENGTHS, currency accessors, and the catalogs without an exactcodes.jsonpairing (ExonerationType,UNITS_OF_MEASURE,DocumentTypeCode,REFERENCE_*) -- hand-written inshared/src/constants/. - XAdES policy -- Policy URI and SHA-1 hash for XAdES-EPES signing
- Environment URLs -- Sandbox and production API/IDP endpoints
Types
FacturaElectronica-- Full invoice typeEmisor/Receptor-- Issuer and receiver typesLineaDetalle-- Invoice line itemImpuesto/Descuento/Exoneracion-- Tax, discount, exonerationSubmissionRequest/SubmissionResponse/StatusResponse-- API request/response typesComprobantesListResponse/ComprobanteDetail-- Document listing and detail types
Schemas (Zod)
FacturaElectronicaSchema-- Validates invoice inputEmisorSchema/ReceptorSchema-- Validates issuer/receiverLineaDetalleSchema-- Validates line itemsIdentificacionSchema-- Validates identification fieldsClaveSchema-- Validates 50-digit clave formatEnvironmentSchema-- Validates environment strings
Installation
npm install @dojocoding/hacienda-shared
Applications can import its public types, enums and validation schemas directly. Internal workspace dependencies are resolved to release versions when packed.
Additive exact ordinary FE schemas
ExactFeInputSchema, ExactFeCalculatedSchema, ExactMoneySchema and
ExactQuantitySchema preserve decimal strings and reject implicit Number
coercion. They belong to the explicit ordinary IVA13/full-payment case, not a
replacement for existing numeric document schemas. See the
exact FE contract.