facturas 0.4.2 → 0.5.1

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/padron.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as ArcaClientConfig } from './types-SloiIQkT.js';
2
- import { W as WsaaAuthModule, S as SoapTransport } from './index-BLq3d6xg.js';
1
+ import { f as ArcaClientConfig } from './types-CKKe1Oo4.js';
2
+ import { W as WsaaAuthModule, S as SoapTransport } from './index-CqXVyU0E.js';
3
3
 
4
4
  /** Result of a taxpayer lookup via Padron A5. */
5
5
  type PadronTaxpayerResult = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/services/padron.ts"],"sourcesContent":["/** Base error class for all ARCA-related errors. */\nexport class ArcaError extends Error {\n readonly code: string;\n override readonly name: string = \"ArcaError\";\n\n constructor(message: string, code = \"ARCA_ERROR\", options?: ErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/** Thrown when the ARCA client configuration is missing or invalid. */\nexport class ArcaConfigurationError extends ArcaError {\n override readonly name: string = \"ArcaConfigurationError\";\n\n constructor(message: string, options?: ErrorOptions) {\n super(message, \"ARCA_CONFIGURATION_ERROR\", options);\n }\n}\n\n/** Thrown when caller-provided input data is missing or invalid. */\nexport class ArcaInputError extends ArcaError {\n override readonly name: string = \"ArcaInputError\";\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_INPUT_ERROR\", options);\n this.detail = options?.detail;\n }\n}\n\n/** Thrown when an HTTP request to an ARCA endpoint fails at the transport level. */\nexport class ArcaTransportError extends ArcaError {\n override readonly name: string = \"ArcaTransportError\";\n readonly statusCode?: number;\n readonly responseBody?: string;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n statusCode?: number;\n responseBody?: string;\n }\n ) {\n super(message, \"ARCA_TRANSPORT_ERROR\", options);\n this.statusCode = options?.statusCode;\n this.responseBody = options?.responseBody;\n }\n}\n\n/** Thrown when the SOAP response contains a Fault element. */\nexport class ArcaSoapFaultError extends ArcaError {\n override readonly name: string = \"ArcaSoapFaultError\";\n readonly faultCode?: string;\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n faultCode?: string;\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_SOAP_FAULT\", options);\n this.faultCode = options?.faultCode;\n this.detail = options?.detail;\n }\n}\n\n/** Thrown when an ARCA service (WSFE, WSMTXCA, Padron) returns a domain-level error. */\nexport class ArcaServiceError extends ArcaError {\n override readonly name: string = \"ArcaServiceError\";\n readonly serviceCode?: string | number;\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n serviceCode?: string | number;\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_SERVICE_ERROR\", options);\n this.serviceCode = options?.serviceCode;\n this.detail = options?.detail;\n }\n}\n","import { ArcaSoapFaultError } from \"../errors\";\nimport type {\n ArcaClientConfig,\n ArcaPadronServiceName,\n} from \"../internal/types\";\nimport type { SoapTransport } from \"../soap\";\nimport type { WsaaAuthModule } from \"../wsaa\";\n\n/** Result of a taxpayer lookup via Padron A5. */\nexport type PadronTaxpayerResult = {\n taxId: string;\n personType?: string;\n name?: string;\n raw: Record<string, unknown>;\n};\n\n/** Result of a tax ID lookup by document number via Padron A13. */\nexport type PadronTaxIdLookupResult = {\n taxIds: string[];\n raw: Record<string, unknown>;\n};\n\n/** Padron taxpayer registry service. */\nexport type PadronService = {\n /** Looks up taxpayer details by CUIT. Returns `null` if the taxpayer does not exist. */\n getTaxpayerDetails(\n taxId: number | string\n ): Promise<PadronTaxpayerResult | null>;\n /** Looks up CUITs associated with a document number. Returns `null` if not found. */\n getTaxIdByDocument(\n documentNumber: number | string\n ): Promise<PadronTaxIdLookupResult | null>;\n};\n\nexport type CreatePadronServiceOptions = {\n config: ArcaClientConfig;\n auth: WsaaAuthModule;\n soap: SoapTransport;\n};\n\n/** Creates a Padron service instance wired with authentication and SOAP transport. */\nexport function createPadronService(\n options: CreatePadronServiceOptions\n): PadronService {\n return {\n async getTaxpayerDetails(taxId) {\n const raw = await executePadronOperation(\n options,\n \"padron-a5\",\n \"getPersona_v2\",\n {\n idPersona: Number.parseInt(String(taxId), 10),\n }\n );\n if (!raw) {\n return null;\n }\n const record = raw as Record<string, unknown>;\n const datosGenerales = record.datosGenerales as\n | Record<string, unknown>\n | undefined;\n return {\n taxId: String(record.idPersona ?? \"\"),\n ...(record.tipoPersona === undefined\n ? {}\n : { personType: String(record.tipoPersona) }),\n ...(datosGenerales ? { name: extractPadronName(datosGenerales) } : {}),\n raw: record,\n };\n },\n async getTaxIdByDocument(documentNumber) {\n const raw = await executePadronOperation(\n options,\n \"padron-a13\",\n \"getIdPersonaListByDocumento\",\n {\n documento: String(documentNumber),\n }\n );\n if (!raw) {\n return null;\n }\n const record = raw as Record<string, unknown>;\n const idPersona = record.idPersona;\n const taxIds = Array.isArray(idPersona)\n ? idPersona.map(String)\n : idPersona === undefined\n ? []\n : [String(idPersona)];\n return {\n taxIds,\n raw: record,\n };\n },\n };\n}\n\nfunction extractPadronName(\n datosGenerales: Record<string, unknown>\n): string | undefined {\n if (typeof datosGenerales.razonSocial === \"string\") {\n return datosGenerales.razonSocial;\n }\n const nombre = datosGenerales.nombre;\n const apellido = datosGenerales.apellido;\n if (typeof apellido === \"string\" && typeof nombre === \"string\") {\n return `${apellido} ${nombre}`.trim();\n }\n if (typeof apellido === \"string\") {\n return apellido;\n }\n if (typeof nombre === \"string\") {\n return nombre;\n }\n return undefined;\n}\n\nasync function executePadronOperation(\n options: CreatePadronServiceOptions,\n service: ArcaPadronServiceName,\n operation: string,\n body: Record<string, unknown>\n) {\n const auth = await options.auth.login(\n service === \"padron-a5\"\n ? \"ws_sr_constancia_inscripcion\"\n : \"ws_sr_padron_a13\"\n );\n\n try {\n const response = await options.soap.execute<\n Record<string, unknown>,\n Record<string, unknown>\n >({\n service,\n operation,\n bodyElementNamespaceMode: \"prefix\",\n body: {\n token: auth.token,\n sign: auth.sign,\n cuitRepresentada: Number.parseInt(options.config.taxId, 10),\n ...body,\n },\n });\n\n const operationResponse = response.result as Record<string, unknown>;\n\n if (operation === \"getPersona_v2\") {\n return operationResponse.personaReturn ?? null;\n }\n\n if (operation === \"getIdPersonaListByDocumento\") {\n return operationResponse.idPersonaListReturn ?? null;\n }\n\n return operationResponse.return ?? null;\n } catch (error) {\n if (\n error instanceof ArcaSoapFaultError &&\n // Public Padron A5/A13 WSDLs expose only a generic validation fault, so\n // there is no documented not-found-specific fault code to match here.\n // Keep the current message fallback, but treat it as fragile.\n error.message.toLowerCase().includes(\"no existe\")\n ) {\n return null;\n }\n\n throw error;\n }\n}\n"],"mappings":";AACO,IAAM,YAAN,cAAwB,MAAM;AAAA,EAC1B;AAAA,EACS,OAAe;AAAA,EAEjC,YAAY,SAAiB,OAAO,cAAc,SAAwB;AACxE,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AA+CO,IAAM,qBAAN,cAAiC,UAAU;AAAA,EAC9B,OAAe;AAAA,EACxB;AAAA,EACA;AAAA,EAET,YACE,SACA,SAIA;AACA,UAAM,SAAS,mBAAmB,OAAO;AACzC,SAAK,YAAY,SAAS;AAC1B,SAAK,SAAS,SAAS;AAAA,EACzB;AACF;;;AC/BO,SAAS,oBACd,SACe;AACf,SAAO;AAAA,IACL,MAAM,mBAAmB,OAAO;AAC9B,YAAM,MAAM,MAAM;AAAA,QAChB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,UACE,WAAW,OAAO,SAAS,OAAO,KAAK,GAAG,EAAE;AAAA,QAC9C;AAAA,MACF;AACA,UAAI,CAAC,KAAK;AACR,eAAO;AAAA,MACT;AACA,YAAM,SAAS;AACf,YAAM,iBAAiB,OAAO;AAG9B,aAAO;AAAA,QACL,OAAO,OAAO,OAAO,aAAa,EAAE;AAAA,QACpC,GAAI,OAAO,gBAAgB,SACvB,CAAC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K;AAAA,QACX,kBAAkB,OAAO,SAAS,QAAQ,OAAO,OAAO,EAAE;AAAA,QAC1D,GAAG;AAAA,MACL;AAAA,IACF,CAAC;AAED,UAAM,oBAAoB,SAAS;AAEnC,QAAI,cAAc,iBAAiB;AACjC,aAAO,kBAAkB,iBAAiB;AAAA,IAC5C;AAEA,QAAI,cAAc,+BAA+B;AAC/C,aAAO,kBAAkB,uBAAuB;AAAA,IAClD;AAEA,WAAO,kBAAkB,UAAU;AAAA,EACrC,SAAS,OAAO;AACd,QACE,iBAAiB;AAAA;AAAA;AAAA,IAIjB,MAAM,QAAQ,YAAY,EAAE,SAAS,WAAW,GAChD;AACA,aAAO;AAAA,IACT;AAEA,UAAM;AAAA,EACR;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/services/padron.ts"],"sourcesContent":["import type { ArcaServiceName } from \"./internal/types\";\n\n/** Base error class for all ARCA-related errors. */\nexport class ArcaError extends Error {\n readonly code: string;\n override readonly name: string = \"ArcaError\";\n\n constructor(message: string, code = \"ARCA_ERROR\", options?: ErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/** Thrown when the ARCA client configuration is missing or invalid. */\nexport class ArcaConfigurationError extends ArcaError {\n override readonly name: string = \"ArcaConfigurationError\";\n\n constructor(message: string, options?: ErrorOptions) {\n super(message, \"ARCA_CONFIGURATION_ERROR\", options);\n }\n}\n\n/** Thrown when caller-provided input data is missing or invalid. */\nexport class ArcaInputError extends ArcaError {\n override readonly name: string = \"ArcaInputError\";\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_INPUT_ERROR\", options);\n this.detail = options?.detail;\n }\n}\n\n/** Thrown when an HTTP request to an ARCA endpoint fails at the transport level. */\nexport class ArcaTransportError extends ArcaError {\n override readonly name: string = \"ArcaTransportError\";\n readonly statusCode?: number;\n readonly contentType?: string;\n readonly responseBody?: string;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n statusCode?: number;\n contentType?: string;\n responseBody?: string;\n }\n ) {\n super(message, \"ARCA_TRANSPORT_ERROR\", options);\n this.statusCode = options?.statusCode;\n this.contentType = options?.contentType;\n this.responseBody = options?.responseBody;\n }\n}\n\n/** Thrown when the SOAP response contains a Fault element. */\nexport class ArcaSoapFaultError extends ArcaError {\n override readonly name: string = \"ArcaSoapFaultError\";\n readonly faultCode?: string;\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n faultCode?: string;\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_SOAP_FAULT\", options);\n this.faultCode = options?.faultCode;\n this.detail = options?.detail;\n }\n}\n\n/** Thrown when a response cannot be parsed as a valid SOAP envelope. */\nexport class ArcaInvalidSoapResponseError extends ArcaError {\n override readonly name: string = \"ArcaInvalidSoapResponseError\";\n readonly service?: ArcaServiceName;\n readonly operation?: string;\n readonly endpointUrl?: string;\n readonly statusCode?: number;\n readonly contentType?: string;\n readonly responseBodyLength?: number;\n readonly responseBodyPreview?: string;\n readonly parsedDetail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n service?: ArcaServiceName;\n operation?: string;\n endpointUrl?: string;\n statusCode?: number;\n contentType?: string;\n responseBodyLength?: number;\n responseBodyPreview?: string;\n parsedDetail?: unknown;\n }\n ) {\n super(message, \"ARCA_INVALID_SOAP_RESPONSE\", options);\n this.service = options?.service;\n this.operation = options?.operation;\n this.endpointUrl = options?.endpointUrl;\n this.statusCode = options?.statusCode;\n this.contentType = options?.contentType;\n this.responseBodyLength = options?.responseBodyLength;\n this.responseBodyPreview = options?.responseBodyPreview;\n this.parsedDetail = options?.parsedDetail;\n }\n}\n\n/** Thrown when an ARCA service (WSFE, WSMTXCA, Padron) returns a domain-level error. */\nexport class ArcaServiceError extends ArcaError {\n override readonly name: string = \"ArcaServiceError\";\n readonly serviceCode?: string | number;\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n serviceCode?: string | number;\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_SERVICE_ERROR\", options);\n this.serviceCode = options?.serviceCode;\n this.detail = options?.detail;\n }\n}\n","import { ArcaSoapFaultError } from \"../errors\";\nimport type {\n ArcaClientConfig,\n ArcaPadronServiceName,\n} from \"../internal/types\";\nimport type { SoapTransport } from \"../soap\";\nimport type { WsaaAuthModule } from \"../wsaa\";\n\n/** Result of a taxpayer lookup via Padron A5. */\nexport type PadronTaxpayerResult = {\n taxId: string;\n personType?: string;\n name?: string;\n raw: Record<string, unknown>;\n};\n\n/** Result of a tax ID lookup by document number via Padron A13. */\nexport type PadronTaxIdLookupResult = {\n taxIds: string[];\n raw: Record<string, unknown>;\n};\n\n/** Padron taxpayer registry service. */\nexport type PadronService = {\n /** Looks up taxpayer details by CUIT. Returns `null` if the taxpayer does not exist. */\n getTaxpayerDetails(\n taxId: number | string\n ): Promise<PadronTaxpayerResult | null>;\n /** Looks up CUITs associated with a document number. Returns `null` if not found. */\n getTaxIdByDocument(\n documentNumber: number | string\n ): Promise<PadronTaxIdLookupResult | null>;\n};\n\nexport type CreatePadronServiceOptions = {\n config: ArcaClientConfig;\n auth: WsaaAuthModule;\n soap: SoapTransport;\n};\n\n/** Creates a Padron service instance wired with authentication and SOAP transport. */\nexport function createPadronService(\n options: CreatePadronServiceOptions\n): PadronService {\n return {\n async getTaxpayerDetails(taxId) {\n const raw = await executePadronOperation(\n options,\n \"padron-a5\",\n \"getPersona_v2\",\n {\n idPersona: Number.parseInt(String(taxId), 10),\n }\n );\n if (!raw) {\n return null;\n }\n const record = raw as Record<string, unknown>;\n const datosGenerales = record.datosGenerales as\n | Record<string, unknown>\n | undefined;\n return {\n taxId: String(record.idPersona ?? \"\"),\n ...(record.tipoPersona === undefined\n ? {}\n : { personType: String(record.tipoPersona) }),\n ...(datosGenerales ? { name: extractPadronName(datosGenerales) } : {}),\n raw: record,\n };\n },\n async getTaxIdByDocument(documentNumber) {\n const raw = await executePadronOperation(\n options,\n \"padron-a13\",\n \"getIdPersonaListByDocumento\",\n {\n documento: String(documentNumber),\n }\n );\n if (!raw) {\n return null;\n }\n const record = raw as Record<string, unknown>;\n const idPersona = record.idPersona;\n const taxIds = Array.isArray(idPersona)\n ? idPersona.map(String)\n : idPersona === undefined\n ? []\n : [String(idPersona)];\n return {\n taxIds,\n raw: record,\n };\n },\n };\n}\n\nfunction extractPadronName(\n datosGenerales: Record<string, unknown>\n): string | undefined {\n if (typeof datosGenerales.razonSocial === \"string\") {\n return datosGenerales.razonSocial;\n }\n const nombre = datosGenerales.nombre;\n const apellido = datosGenerales.apellido;\n if (typeof apellido === \"string\" && typeof nombre === \"string\") {\n return `${apellido} ${nombre}`.trim();\n }\n if (typeof apellido === \"string\") {\n return apellido;\n }\n if (typeof nombre === \"string\") {\n return nombre;\n }\n return undefined;\n}\n\nasync function executePadronOperation(\n options: CreatePadronServiceOptions,\n service: ArcaPadronServiceName,\n operation: string,\n body: Record<string, unknown>\n) {\n const auth = await options.auth.login(\n service === \"padron-a5\"\n ? \"ws_sr_constancia_inscripcion\"\n : \"ws_sr_padron_a13\"\n );\n\n try {\n const response = await options.soap.execute<\n Record<string, unknown>,\n Record<string, unknown>\n >({\n service,\n operation,\n bodyElementNamespaceMode: \"prefix\",\n body: {\n token: auth.token,\n sign: auth.sign,\n cuitRepresentada: Number.parseInt(options.config.taxId, 10),\n ...body,\n },\n });\n\n const operationResponse = response.result as Record<string, unknown>;\n\n if (operation === \"getPersona_v2\") {\n return operationResponse.personaReturn ?? null;\n }\n\n if (operation === \"getIdPersonaListByDocumento\") {\n return operationResponse.idPersonaListReturn ?? null;\n }\n\n return operationResponse.return ?? null;\n } catch (error) {\n if (\n error instanceof ArcaSoapFaultError &&\n // Public Padron A5/A13 WSDLs expose only a generic validation fault, so\n // there is no documented not-found-specific fault code to match here.\n // Keep the current message fallback, but treat it as fragile.\n error.message.toLowerCase().includes(\"no existe\")\n ) {\n return null;\n }\n\n throw error;\n }\n}\n"],"mappings":";A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14,6 +14,17 @@ type ArcaLoggerConfig = {
14
14
  level?: ArcaLogLevel;
15
15
  log?: (level: ArcaLogLevel, message: string, ...args: unknown[]) => void;
16
16
  };
17
+ type ArcaWsaaSessionKey = {
18
+ environment: ArcaEnvironment;
19
+ service: ArcaWsaaServiceId;
20
+ certificateFingerprint: string;
21
+ };
22
+ type ArcaWsaaSessionStore = {
23
+ get(key: ArcaWsaaSessionKey): Promise<ArcaAuthCredentials | null>;
24
+ set(key: ArcaWsaaSessionKey, credentials: ArcaAuthCredentials): Promise<void>;
25
+ delete?(key: ArcaWsaaSessionKey): Promise<void>;
26
+ withLock?<T>(key: ArcaWsaaSessionKey, fn: () => Promise<T>): Promise<T>;
27
+ };
17
28
  /** Configuration required to create an ARCA client. */
18
29
  type ArcaClientConfig = {
19
30
  taxId: string;
@@ -24,6 +35,7 @@ type ArcaClientConfig = {
24
35
  retries?: number;
25
36
  retryDelay?: number;
26
37
  logger?: ArcaLoggerConfig;
38
+ wsaaSessionStore?: ArcaWsaaSessionStore;
27
39
  };
28
40
  /** Credentials returned by a WSAA login. */
29
41
  type ArcaAuthCredentials = {
@@ -50,4 +62,4 @@ type ArcaSoapExecutionOptions<TBody> = {
50
62
  body: TBody;
51
63
  };
52
64
 
53
- export type { ArcaClientConfig as A, ArcaEnvironment as a, ArcaAuthCredentials as b, ArcaAuthOptions as c, ArcaLogLevel as d, ArcaLoggerConfig as e, ArcaPadronServiceName as f, ArcaRepresentedTaxId as g, ArcaServiceName as h, ArcaServiceTarget as i, ArcaWsaaServiceId as j, ArcaSoapExecutionOptions as k, ArcaSoapResponse as l };
65
+ export type { ArcaServiceName as A, ArcaSoapExecutionOptions as a, ArcaSoapResponse as b, ArcaWsaaServiceId as c, ArcaAuthOptions as d, ArcaAuthCredentials as e, ArcaClientConfig as f, ArcaEnvironment as g, ArcaWsaaSessionStore as h, ArcaLogLevel as i, ArcaLoggerConfig as j, ArcaPadronServiceName as k, ArcaRepresentedTaxId as l, ArcaServiceTarget as m, ArcaWsaaSessionKey as n };
package/dist/types.d.ts CHANGED
@@ -1 +1 @@
1
- export { b as ArcaAuthCredentials, c as ArcaAuthOptions, A as ArcaClientConfig, a as ArcaEnvironment, d as ArcaLogLevel, e as ArcaLoggerConfig, f as ArcaPadronServiceName, g as ArcaRepresentedTaxId, h as ArcaServiceName, i as ArcaServiceTarget, j as ArcaWsaaServiceId } from './types-SloiIQkT.js';
1
+ export { e as ArcaAuthCredentials, d as ArcaAuthOptions, f as ArcaClientConfig, g as ArcaEnvironment, i as ArcaLogLevel, j as ArcaLoggerConfig, k as ArcaPadronServiceName, l as ArcaRepresentedTaxId, A as ArcaServiceName, m as ArcaServiceTarget, c as ArcaWsaaServiceId, n as ArcaWsaaSessionKey, h as ArcaWsaaSessionStore } from './types-CKKe1Oo4.js';
package/dist/wsfe.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as ArcaClientConfig } from './types-SloiIQkT.js';
2
- import { W as WsaaAuthModule, S as SoapTransport } from './index-BLq3d6xg.js';
1
+ import { f as ArcaClientConfig } from './types-CKKe1Oo4.js';
2
+ import { W as WsaaAuthModule, S as SoapTransport } from './index-CqXVyU0E.js';
3
3
 
4
4
  /** Accepted public date inputs for WSFE request fields. */
5
5
  type WsfeDateInput = `${number}${number}${number}${number}-${number}${number}-${number}${number}` | `${number}${number}${number}${number}${number}${number}${number}${number}`;
@@ -79,6 +79,7 @@ type WsfeAuthorizeVoucherInput = {
79
79
  representedTaxId?: number | string;
80
80
  data: WsfeVoucherInput;
81
81
  voucherNumber: number;
82
+ forceRefresh?: boolean;
82
83
  };
83
84
  /** Result of a successful WSFE voucher authorization. */
84
85
  type WsfeAuthorizationResult = {
@@ -140,13 +141,14 @@ type WsfeService = {
140
141
  createNextVoucher(input: {
141
142
  representedTaxId?: number | string;
142
143
  data: WsfeVoucherInput;
144
+ forceRefresh?: boolean;
143
145
  }): Promise<WsfeAuthorizationResult>;
144
146
  /** Returns the next available voucher number for the given sales point and type. */
145
147
  getNextVoucherNumber(input: {
146
148
  representedTaxId?: number | string;
147
149
  salesPoint: number;
148
150
  voucherType: number;
149
- forceAuthRefresh?: boolean;
151
+ forceRefresh?: boolean;
150
152
  }): Promise<number>;
151
153
  /**
152
154
  * @deprecated Use `getNextVoucherNumber()` instead.
@@ -156,58 +158,58 @@ type WsfeService = {
156
158
  representedTaxId?: number | string;
157
159
  salesPoint: number;
158
160
  voucherType: number;
159
- forceAuthRefresh?: boolean;
161
+ forceRefresh?: boolean;
160
162
  }): Promise<number>;
161
163
  /** Lists all configured points of sale for the taxpayer. */
162
164
  getSalesPoints(input: {
163
165
  representedTaxId?: number | string;
164
- forceAuthRefresh?: boolean;
166
+ forceRefresh?: boolean;
165
167
  }): Promise<WsfeSalesPoint[]>;
166
168
  /** Lists voucher types accepted by WSFE. */
167
169
  getVoucherTypes(input: {
168
170
  representedTaxId?: number | string;
169
- forceAuthRefresh?: boolean;
171
+ forceRefresh?: boolean;
170
172
  }): Promise<WsfeCatalogEntry[]>;
171
173
  /** Lists document types accepted by WSFE. */
172
174
  getDocumentTypes(input: {
173
175
  representedTaxId?: number | string;
174
- forceAuthRefresh?: boolean;
176
+ forceRefresh?: boolean;
175
177
  }): Promise<WsfeCatalogEntry[]>;
176
178
  /** Lists concept types accepted by WSFE. */
177
179
  getConceptTypes(input: {
178
180
  representedTaxId?: number | string;
179
- forceAuthRefresh?: boolean;
181
+ forceRefresh?: boolean;
180
182
  }): Promise<WsfeCatalogEntry[]>;
181
183
  /** Lists supported currency types. */
182
184
  getCurrencyTypes(input: {
183
185
  representedTaxId?: number | string;
184
- forceAuthRefresh?: boolean;
186
+ forceRefresh?: boolean;
185
187
  }): Promise<WsfeCurrencyType[]>;
186
188
  /** Lists VAT rates accepted by WSFE. */
187
189
  getVatRates(input: {
188
190
  representedTaxId?: number | string;
189
- forceAuthRefresh?: boolean;
191
+ forceRefresh?: boolean;
190
192
  }): Promise<WsfeCatalogEntry[]>;
191
193
  /** Lists tax types accepted by WSFE. */
192
194
  getTaxTypes(input: {
193
195
  representedTaxId?: number | string;
194
- forceAuthRefresh?: boolean;
196
+ forceRefresh?: boolean;
195
197
  }): Promise<WsfeCatalogEntry[]>;
196
198
  /** Lists optional field types accepted by WSFE. */
197
199
  getOptionalTypes(input: {
198
200
  representedTaxId?: number | string;
199
- forceAuthRefresh?: boolean;
201
+ forceRefresh?: boolean;
200
202
  }): Promise<WsfeCatalogEntry[]>;
201
203
  /** Lists activities enabled for the taxpayer. */
202
204
  getActivities(input: {
203
205
  representedTaxId?: number | string;
204
- forceAuthRefresh?: boolean;
206
+ forceRefresh?: boolean;
205
207
  }): Promise<WsfeActivityType[]>;
206
208
  /** Lists receiver VAT condition values accepted by WSFE. */
207
209
  getReceiverVatConditions(input: {
208
210
  representedTaxId?: number | string;
209
211
  voucherClass?: string;
210
- forceAuthRefresh?: boolean;
212
+ forceRefresh?: boolean;
211
213
  }): Promise<WsfeReceiverVatCondition[]>;
212
214
  /** Reports WSFE backend status without requiring taxpayer authorization. */
213
215
  getServerStatus(): Promise<WsfeServerStatus>;
@@ -215,7 +217,7 @@ type WsfeService = {
215
217
  getQuotation(input: {
216
218
  currencyId: string;
217
219
  representedTaxId?: number | string;
218
- forceAuthRefresh?: boolean;
220
+ forceRefresh?: boolean;
219
221
  }): Promise<WsfeQuotation>;
220
222
  /** Retrieves details for a specific voucher. Returns `null` if not found. */
221
223
  getVoucherInfo(input: {
@@ -223,6 +225,7 @@ type WsfeService = {
223
225
  number: number;
224
226
  salesPoint: number;
225
227
  voucherType: number;
228
+ forceRefresh?: boolean;
226
229
  }): Promise<WsfeVoucherInfo | null>;
227
230
  };
228
231
  type CreateWsfeServiceOptions = {
package/dist/wsfe.js CHANGED
@@ -31,7 +31,7 @@ function createWsfeService(options) {
31
31
  async function executeWsfeAuthenticatedOperation(operation, input, body = {}) {
32
32
  const auth = await options.auth.login("wsfe", {
33
33
  representedTaxId: input.representedTaxId,
34
- forceRefresh: input.forceAuthRefresh
34
+ forceRefresh: input.forceRefresh
35
35
  });
36
36
  const response = await options.soap.execute({
37
37
  service: "wsfe",
@@ -59,13 +59,13 @@ function createWsfeService(options) {
59
59
  representedTaxId,
60
60
  salesPoint,
61
61
  voucherType,
62
- forceAuthRefresh
62
+ forceRefresh
63
63
  }) {
64
64
  const result = await executeWsfeAuthenticatedOperation(
65
65
  "FECompUltimoAutorizado",
66
66
  {
67
67
  representedTaxId,
68
- forceAuthRefresh
68
+ forceRefresh
69
69
  },
70
70
  {
71
71
  PtoVta: salesPoint,
@@ -77,29 +77,35 @@ function createWsfeService(options) {
77
77
  async function getWsfeCatalog(operation, resultKey, input) {
78
78
  const result = await executeWsfeAuthenticatedOperation(operation, {
79
79
  representedTaxId: input.representedTaxId,
80
- forceAuthRefresh: input.forceAuthRefresh
80
+ forceRefresh: input.forceRefresh
81
81
  });
82
82
  return getWsfeResultEntries(result, resultKey).map(mapWsfeCatalogEntry);
83
83
  }
84
84
  function authorizeVoucher({
85
85
  representedTaxId,
86
86
  data,
87
- voucherNumber
87
+ voucherNumber,
88
+ forceRefresh
88
89
  }) {
89
90
  const normalizedInput = normalizeWsfeVoucherInput(data);
90
91
  return authorizeNormalizedVoucher({
91
92
  representedTaxId,
92
93
  data: normalizedInput,
93
- voucherNumber
94
+ voucherNumber,
95
+ forceRefresh
94
96
  });
95
97
  }
96
98
  async function authorizeNormalizedVoucher({
97
99
  representedTaxId,
98
100
  data: normalizedInput,
99
- voucherNumber
101
+ voucherNumber,
102
+ forceRefresh
100
103
  }) {
101
104
  const requestData = mapWsfeVoucherInput(normalizedInput, voucherNumber);
102
- const auth = await options.auth.login("wsfe", { representedTaxId });
105
+ const auth = await options.auth.login("wsfe", {
106
+ representedTaxId,
107
+ forceRefresh
108
+ });
103
109
  const response = await options.soap.execute({
104
110
  service: "wsfe",
105
111
  operation: "FECAESolicitar",
@@ -139,12 +145,13 @@ function createWsfeService(options) {
139
145
  }
140
146
  return {
141
147
  authorizeVoucher,
142
- async createNextVoucher({ representedTaxId, data }) {
148
+ async createNextVoucher({ representedTaxId, data, forceRefresh }) {
143
149
  const normalizedInput = normalizeWsfeVoucherInput(data);
144
150
  const voucherNumber = await getNextVoucherNumber({
145
151
  representedTaxId,
146
152
  salesPoint: normalizedInput.salesPoint,
147
- voucherType: normalizedInput.voucherType
153
+ voucherType: normalizedInput.voucherType,
154
+ forceRefresh
148
155
  });
149
156
  return authorizeNormalizedVoucher({
150
157
  representedTaxId,
@@ -156,12 +163,12 @@ function createWsfeService(options) {
156
163
  getLastVoucher(input) {
157
164
  return getNextVoucherNumber(input);
158
165
  },
159
- async getSalesPoints({ representedTaxId, forceAuthRefresh }) {
166
+ async getSalesPoints({ representedTaxId, forceRefresh }) {
160
167
  const result = await executeWsfeAuthenticatedOperation(
161
168
  "FEParamGetPtosVenta",
162
169
  {
163
170
  representedTaxId,
164
- forceAuthRefresh
171
+ forceRefresh
165
172
  }
166
173
  );
167
174
  const rawPoints = result.ResultGet?.PtoVenta;
@@ -180,12 +187,12 @@ function createWsfeService(options) {
180
187
  getConceptTypes(input) {
181
188
  return getWsfeCatalog("FEParamGetTiposConcepto", "ConceptoTipo", input);
182
189
  },
183
- async getCurrencyTypes({ representedTaxId, forceAuthRefresh }) {
190
+ async getCurrencyTypes({ representedTaxId, forceRefresh }) {
184
191
  const result = await executeWsfeAuthenticatedOperation(
185
192
  "FEParamGetTiposMonedas",
186
193
  {
187
194
  representedTaxId,
188
- forceAuthRefresh
195
+ forceRefresh
189
196
  }
190
197
  );
191
198
  return getWsfeResultEntries(result, "Moneda").map(mapWsfeCurrencyType);
@@ -199,12 +206,12 @@ function createWsfeService(options) {
199
206
  getOptionalTypes(input) {
200
207
  return getWsfeCatalog("FEParamGetTiposOpcional", "OpcionalTipo", input);
201
208
  },
202
- async getActivities({ representedTaxId, forceAuthRefresh }) {
209
+ async getActivities({ representedTaxId, forceRefresh }) {
203
210
  const result = await executeWsfeAuthenticatedOperation(
204
211
  "FEParamGetActividades",
205
212
  {
206
213
  representedTaxId,
207
- forceAuthRefresh
214
+ forceRefresh
208
215
  }
209
216
  );
210
217
  return getWsfeResultEntries(result, "ActividadesTipo").map(
@@ -214,13 +221,13 @@ function createWsfeService(options) {
214
221
  async getReceiverVatConditions({
215
222
  representedTaxId,
216
223
  voucherClass,
217
- forceAuthRefresh
224
+ forceRefresh
218
225
  }) {
219
226
  const result = await executeWsfeAuthenticatedOperation(
220
227
  "FEParamGetCondicionIvaReceptor",
221
228
  {
222
229
  representedTaxId,
223
- forceAuthRefresh
230
+ forceRefresh
224
231
  },
225
232
  {
226
233
  ...voucherClass === void 0 ? {} : { ClaseCmp: voucherClass }
@@ -234,12 +241,12 @@ function createWsfeService(options) {
234
241
  const result = await executeWsfeOperation("FEDummy");
235
242
  return mapWsfeServerStatus(result);
236
243
  },
237
- async getQuotation({ currencyId, representedTaxId, forceAuthRefresh }) {
244
+ async getQuotation({ currencyId, representedTaxId, forceRefresh }) {
238
245
  const result = await executeWsfeAuthenticatedOperation(
239
246
  "FEParamGetCotizacion",
240
247
  {
241
248
  representedTaxId,
242
- forceAuthRefresh
249
+ forceRefresh
243
250
  },
244
251
  {
245
252
  MonId: currencyId
@@ -252,12 +259,14 @@ function createWsfeService(options) {
252
259
  representedTaxId,
253
260
  number,
254
261
  salesPoint,
255
- voucherType
262
+ voucherType,
263
+ forceRefresh
256
264
  }) {
257
265
  const result = await executeWsfeAuthenticatedOperation(
258
266
  "FECompConsultar",
259
267
  {
260
- representedTaxId
268
+ representedTaxId,
269
+ forceRefresh
261
270
  },
262
271
  {
263
272
  FeCompConsReq: {
package/dist/wsfe.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/services/wsfe.ts"],"sourcesContent":["/** Base error class for all ARCA-related errors. */\nexport class ArcaError extends Error {\n readonly code: string;\n override readonly name: string = \"ArcaError\";\n\n constructor(message: string, code = \"ARCA_ERROR\", options?: ErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/** Thrown when the ARCA client configuration is missing or invalid. */\nexport class ArcaConfigurationError extends ArcaError {\n override readonly name: string = \"ArcaConfigurationError\";\n\n constructor(message: string, options?: ErrorOptions) {\n super(message, \"ARCA_CONFIGURATION_ERROR\", options);\n }\n}\n\n/** Thrown when caller-provided input data is missing or invalid. */\nexport class ArcaInputError extends ArcaError {\n override readonly name: string = \"ArcaInputError\";\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_INPUT_ERROR\", options);\n this.detail = options?.detail;\n }\n}\n\n/** Thrown when an HTTP request to an ARCA endpoint fails at the transport level. */\nexport class ArcaTransportError extends ArcaError {\n override readonly name: string = \"ArcaTransportError\";\n readonly statusCode?: number;\n readonly responseBody?: string;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n statusCode?: number;\n responseBody?: string;\n }\n ) {\n super(message, \"ARCA_TRANSPORT_ERROR\", options);\n this.statusCode = options?.statusCode;\n this.responseBody = options?.responseBody;\n }\n}\n\n/** Thrown when the SOAP response contains a Fault element. */\nexport class ArcaSoapFaultError extends ArcaError {\n override readonly name: string = \"ArcaSoapFaultError\";\n readonly faultCode?: string;\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n faultCode?: string;\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_SOAP_FAULT\", options);\n this.faultCode = options?.faultCode;\n this.detail = options?.detail;\n }\n}\n\n/** Thrown when an ARCA service (WSFE, WSMTXCA, Padron) returns a domain-level error. */\nexport class ArcaServiceError extends ArcaError {\n override readonly name: string = \"ArcaServiceError\";\n readonly serviceCode?: string | number;\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n serviceCode?: string | number;\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_SERVICE_ERROR\", options);\n this.serviceCode = options?.serviceCode;\n this.detail = options?.detail;\n }\n}\n","import { ArcaInputError, ArcaServiceError } from \"../errors\";\nimport type { ArcaClientConfig, ArcaRepresentedTaxId } from \"../internal/types\";\nimport type { SoapTransport } from \"../soap\";\nimport type { WsaaAuthModule } from \"../wsaa\";\n\n/** Accepted public date inputs for WSFE request fields. */\nexport type WsfeDateInput =\n | `${number}${number}${number}${number}-${number}${number}-${number}${number}`\n | `${number}${number}${number}${number}${number}${number}${number}${number}`;\n\n/** An associated voucher referenced by a WSFE invoice request. */\nexport type WsfeAssociatedVoucher = {\n type: number;\n salesPoint: number;\n number: number;\n taxId?: string;\n voucherDate?: WsfeDateInput;\n};\n\n/** An associated period used by WSFE credit/debit notes without associated vouchers. */\nexport type WsfeAssociatedPeriod = {\n startDate: WsfeDateInput;\n endDate: WsfeDateInput;\n};\n\n/** A tax (tributo) item in a WSFE invoice request. */\nexport type WsfeTax = {\n id: number;\n description?: string;\n baseAmount: number;\n rate: number;\n amount: number;\n};\n\n/** A VAT rate (alícuota IVA) item in a WSFE invoice request. */\nexport type WsfeVatRate = {\n id: number;\n baseAmount: number;\n amount: number;\n};\n\n/** An optional field (campo opcional) in a WSFE invoice request. */\nexport type WsfeOptionalField = {\n id: string;\n value: string;\n};\n\n/** A buyer (comprador) in a WSFE invoice request. */\nexport type WsfeBuyer = {\n documentType: number;\n documentNumber: number;\n percentage: number;\n};\n\n/** An activity associated with a WSFE invoice request. */\nexport type WsfeActivity = {\n id: number;\n};\n\n/** Input data for authorizing a WSFE voucher. */\nexport type WsfeVoucherInput = {\n salesPoint: number;\n voucherType: number;\n concept: number;\n documentType: number;\n documentNumber: number;\n receiverVatConditionId?: number;\n voucherDate: WsfeDateInput;\n totalAmount: number;\n nonTaxableAmount: number;\n netAmount: number;\n exemptAmount: number;\n taxAmount: number;\n vatAmount: number;\n currencyId: string;\n exchangeRate?: number;\n sameCurrencyForeignCancellation?: \"S\" | \"N\";\n serviceStartDate?: WsfeDateInput;\n serviceEndDate?: WsfeDateInput;\n paymentDueDate?: WsfeDateInput;\n associatedVouchers?: WsfeAssociatedVoucher[];\n associatedPeriod?: WsfeAssociatedPeriod;\n taxes?: WsfeTax[];\n vatRates?: WsfeVatRate[];\n optionalFields?: WsfeOptionalField[];\n buyers?: WsfeBuyer[];\n activities?: WsfeActivity[];\n};\n\n/** Input for authorizing a WSFE voucher with an explicit voucher number. */\nexport type WsfeAuthorizeVoucherInput = {\n representedTaxId?: number | string;\n data: WsfeVoucherInput;\n voucherNumber: number;\n};\n\n/** Result of a successful WSFE voucher authorization. */\nexport type WsfeAuthorizationResult = {\n cae: string;\n caeExpiry: string;\n voucherNumber: number;\n raw: Record<string, unknown>;\n};\n\n/** A point-of-sale entry returned by {@link WsfeService.getSalesPoints}. */\nexport type WsfeSalesPoint = {\n number: number;\n emissionType?: string;\n blocked?: string;\n deletedSince?: string;\n};\n\n/** Voucher details returned by {@link WsfeService.getVoucherInfo}. */\nexport type WsfeVoucherInfo = {\n voucherNumber: number;\n voucherDate?: string;\n salesPoint?: number;\n voucherType?: number;\n totalAmount?: number;\n result?: string;\n cae?: string;\n caeExpiry?: string;\n raw: Record<string, unknown>;\n};\n\nexport type WsfeCatalogEntry = {\n id: number;\n description: string;\n};\n\nexport type WsfeActivityType = WsfeCatalogEntry & {\n order: number;\n};\n\nexport type WsfeReceiverVatCondition = WsfeCatalogEntry & {\n voucherClass: string;\n};\n\nexport type WsfeCurrencyType = {\n id: string;\n description: string;\n validFrom: string;\n validTo: string;\n};\n\nexport type WsfeServerStatus = {\n appServer: string;\n dbServer: string;\n authServer: string;\n};\n\nexport type WsfeQuotation = {\n currencyId: string;\n rate: number;\n date: string;\n};\n\n/** WSFE electronic invoicing service. */\nexport type WsfeService = {\n /** Authorizes a voucher with the explicit number sent as `CbteDesde` and `CbteHasta`. */\n authorizeVoucher(\n input: WsfeAuthorizeVoucherInput\n ): Promise<WsfeAuthorizationResult>;\n /** Authorizes a new voucher by fetching the next number and requesting a CAE. */\n createNextVoucher(input: {\n representedTaxId?: number | string;\n data: WsfeVoucherInput;\n }): Promise<WsfeAuthorizationResult>;\n /** Returns the next available voucher number for the given sales point and type. */\n getNextVoucherNumber(input: {\n representedTaxId?: number | string;\n salesPoint: number;\n voucherType: number;\n forceAuthRefresh?: boolean;\n }): Promise<number>;\n /**\n * @deprecated Use `getNextVoucherNumber()` instead.\n * Returns the next available voucher number, not the last authorized one.\n */\n getLastVoucher(input: {\n representedTaxId?: number | string;\n salesPoint: number;\n voucherType: number;\n forceAuthRefresh?: boolean;\n }): Promise<number>;\n /** Lists all configured points of sale for the taxpayer. */\n getSalesPoints(input: {\n representedTaxId?: number | string;\n forceAuthRefresh?: boolean;\n }): Promise<WsfeSalesPoint[]>;\n /** Lists voucher types accepted by WSFE. */\n getVoucherTypes(input: {\n representedTaxId?: number | string;\n forceAuthRefresh?: boolean;\n }): Promise<WsfeCatalogEntry[]>;\n /** Lists document types accepted by WSFE. */\n getDocumentTypes(input: {\n representedTaxId?: number | string;\n forceAuthRefresh?: boolean;\n }): Promise<WsfeCatalogEntry[]>;\n /** Lists concept types accepted by WSFE. */\n getConceptTypes(input: {\n representedTaxId?: number | string;\n forceAuthRefresh?: boolean;\n }): Promise<WsfeCatalogEntry[]>;\n /** Lists supported currency types. */\n getCurrencyTypes(input: {\n representedTaxId?: number | string;\n forceAuthRefresh?: boolean;\n }): Promise<WsfeCurrencyType[]>;\n /** Lists VAT rates accepted by WSFE. */\n getVatRates(input: {\n representedTaxId?: number | string;\n forceAuthRefresh?: boolean;\n }): Promise<WsfeCatalogEntry[]>;\n /** Lists tax types accepted by WSFE. */\n getTaxTypes(input: {\n representedTaxId?: number | string;\n forceAuthRefresh?: boolean;\n }): Promise<WsfeCatalogEntry[]>;\n /** Lists optional field types accepted by WSFE. */\n getOptionalTypes(input: {\n representedTaxId?: number | string;\n forceAuthRefresh?: boolean;\n }): Promise<WsfeCatalogEntry[]>;\n /** Lists activities enabled for the taxpayer. */\n getActivities(input: {\n representedTaxId?: number | string;\n forceAuthRefresh?: boolean;\n }): Promise<WsfeActivityType[]>;\n /** Lists receiver VAT condition values accepted by WSFE. */\n getReceiverVatConditions(input: {\n representedTaxId?: number | string;\n voucherClass?: string;\n forceAuthRefresh?: boolean;\n }): Promise<WsfeReceiverVatCondition[]>;\n /** Reports WSFE backend status without requiring taxpayer authorization. */\n getServerStatus(): Promise<WsfeServerStatus>;\n /** Returns the exchange rate for a given currency. */\n getQuotation(input: {\n currencyId: string;\n representedTaxId?: number | string;\n forceAuthRefresh?: boolean;\n }): Promise<WsfeQuotation>;\n /** Retrieves details for a specific voucher. Returns `null` if not found. */\n getVoucherInfo(input: {\n representedTaxId?: number | string;\n number: number;\n salesPoint: number;\n voucherType: number;\n }): Promise<WsfeVoucherInfo | null>;\n};\n\nexport type CreateWsfeServiceOptions = {\n config: ArcaClientConfig;\n auth: WsaaAuthModule;\n soap: SoapTransport;\n};\n\ntype NormalizedWsfeAssociatedVoucher = Omit<\n WsfeAssociatedVoucher,\n \"voucherDate\"\n> & {\n voucherDate?: string;\n};\n\ntype NormalizedWsfeAssociatedPeriod = {\n startDate: string;\n endDate: string;\n};\n\ntype NormalizedWsfeVoucherInput = Omit<\n WsfeVoucherInput,\n | \"voucherDate\"\n | \"serviceStartDate\"\n | \"serviceEndDate\"\n | \"paymentDueDate\"\n | \"associatedVouchers\"\n | \"associatedPeriod\"\n> & {\n voucherDate: string;\n serviceStartDate?: string;\n serviceEndDate?: string;\n paymentDueDate?: string;\n associatedVouchers?: NormalizedWsfeAssociatedVoucher[];\n associatedPeriod?: NormalizedWsfeAssociatedPeriod;\n};\n\n/** Creates a WSFE service instance wired with authentication and SOAP transport. */\nexport function createWsfeService(\n options: CreateWsfeServiceOptions\n): WsfeService {\n async function executeWsfeAuthenticatedOperation(\n operation: string,\n input: {\n representedTaxId?: ArcaRepresentedTaxId;\n forceAuthRefresh?: boolean;\n },\n body: Record<string, unknown> = {}\n ) {\n const auth = await options.auth.login(\"wsfe\", {\n representedTaxId: input.representedTaxId,\n forceRefresh: input.forceAuthRefresh,\n });\n const response = await options.soap.execute<\n Record<string, unknown>,\n Record<string, unknown>\n >({\n service: \"wsfe\",\n operation,\n body: {\n Auth: createWsfeAuth(\n input.representedTaxId ?? options.config.taxId,\n auth.token,\n auth.sign\n ),\n ...body,\n },\n });\n\n return unwrapWsfeOperationResult(operation, response.result);\n }\n\n async function executeWsfeOperation(\n operation: string,\n body: Record<string, unknown> = {}\n ) {\n const response = await options.soap.execute<\n Record<string, unknown>,\n Record<string, unknown>\n >({\n service: \"wsfe\",\n operation,\n body,\n });\n\n return unwrapWsfeOperationResult(operation, response.result);\n }\n\n async function getNextVoucherNumber({\n representedTaxId,\n salesPoint,\n voucherType,\n forceAuthRefresh,\n }: {\n representedTaxId?: number | string;\n salesPoint: number;\n voucherType: number;\n forceAuthRefresh?: boolean;\n }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FECompUltimoAutorizado\",\n {\n representedTaxId,\n forceAuthRefresh,\n },\n {\n PtoVta: salesPoint,\n CbteTipo: voucherType,\n }\n );\n return Number(result.CbteNro ?? 0) + 1;\n }\n\n async function getWsfeCatalog(\n operation: string,\n resultKey: string,\n input: {\n representedTaxId?: ArcaRepresentedTaxId;\n forceAuthRefresh?: boolean;\n }\n ): Promise<WsfeCatalogEntry[]> {\n const result = await executeWsfeAuthenticatedOperation(operation, {\n representedTaxId: input.representedTaxId,\n forceAuthRefresh: input.forceAuthRefresh,\n });\n return getWsfeResultEntries(result, resultKey).map(mapWsfeCatalogEntry);\n }\n\n function authorizeVoucher({\n representedTaxId,\n data,\n voucherNumber,\n }: WsfeAuthorizeVoucherInput): Promise<WsfeAuthorizationResult> {\n const normalizedInput = normalizeWsfeVoucherInput(data);\n return authorizeNormalizedVoucher({\n representedTaxId,\n data: normalizedInput,\n voucherNumber,\n });\n }\n\n async function authorizeNormalizedVoucher({\n representedTaxId,\n data: normalizedInput,\n voucherNumber,\n }: {\n representedTaxId?: number | string;\n data: NormalizedWsfeVoucherInput;\n voucherNumber: number;\n }): Promise<WsfeAuthorizationResult> {\n const requestData = mapWsfeVoucherInput(normalizedInput, voucherNumber);\n\n const auth = await options.auth.login(\"wsfe\", { representedTaxId });\n const response = await options.soap.execute<\n Record<string, unknown>,\n Record<string, unknown>\n >({\n service: \"wsfe\",\n operation: \"FECAESolicitar\",\n body: {\n Auth: createWsfeAuth(\n representedTaxId ?? options.config.taxId,\n auth.token,\n auth.sign\n ),\n FeCAEReq: {\n FeCabReq: {\n CantReg: 1,\n PtoVta: normalizedInput.salesPoint,\n CbteTipo: normalizedInput.voucherType,\n },\n FeDetReq: {\n FECAEDetRequest: requestData,\n },\n },\n },\n });\n\n const result = unwrapWsfeOperationResult(\"FECAESolicitar\", response.result);\n const detailResponse = normalizeWsfeDetailResponse(result);\n const cae = detailResponse.CAE;\n const caeExpiry = detailResponse.CAEFchVto;\n\n if (typeof cae !== \"string\" || typeof caeExpiry !== \"string\") {\n throw new ArcaServiceError(\"WSFE did not return CAE authorization data\", {\n detail: result,\n });\n }\n\n return {\n cae,\n caeExpiry: String(caeExpiry),\n voucherNumber,\n raw: result,\n };\n }\n\n return {\n authorizeVoucher,\n async createNextVoucher({ representedTaxId, data }) {\n const normalizedInput = normalizeWsfeVoucherInput(data);\n\n const voucherNumber = await getNextVoucherNumber({\n representedTaxId,\n salesPoint: normalizedInput.salesPoint,\n voucherType: normalizedInput.voucherType,\n });\n\n return authorizeNormalizedVoucher({\n representedTaxId,\n data: normalizedInput,\n voucherNumber,\n });\n },\n getNextVoucherNumber,\n getLastVoucher(input) {\n return getNextVoucherNumber(input);\n },\n async getSalesPoints({ representedTaxId, forceAuthRefresh }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FEParamGetPtosVenta\",\n {\n representedTaxId,\n forceAuthRefresh,\n }\n );\n const rawPoints = (\n result.ResultGet as Record<string, unknown> | undefined\n )?.PtoVenta;\n if (!rawPoints) {\n return [];\n }\n const entries = Array.isArray(rawPoints) ? rawPoints : [rawPoints];\n return entries.map(mapWsfeSalesPoint);\n },\n getVoucherTypes(input) {\n return getWsfeCatalog(\"FEParamGetTiposCbte\", \"CbteTipo\", input);\n },\n getDocumentTypes(input) {\n return getWsfeCatalog(\"FEParamGetTiposDoc\", \"DocTipo\", input);\n },\n getConceptTypes(input) {\n return getWsfeCatalog(\"FEParamGetTiposConcepto\", \"ConceptoTipo\", input);\n },\n async getCurrencyTypes({ representedTaxId, forceAuthRefresh }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FEParamGetTiposMonedas\",\n {\n representedTaxId,\n forceAuthRefresh,\n }\n );\n return getWsfeResultEntries(result, \"Moneda\").map(mapWsfeCurrencyType);\n },\n getVatRates(input) {\n return getWsfeCatalog(\"FEParamGetTiposIva\", \"IvaTipo\", input);\n },\n getTaxTypes(input) {\n return getWsfeCatalog(\"FEParamGetTiposTributos\", \"TributoTipo\", input);\n },\n getOptionalTypes(input) {\n return getWsfeCatalog(\"FEParamGetTiposOpcional\", \"OpcionalTipo\", input);\n },\n async getActivities({ representedTaxId, forceAuthRefresh }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FEParamGetActividades\",\n {\n representedTaxId,\n forceAuthRefresh,\n }\n );\n return getWsfeResultEntries(result, \"ActividadesTipo\").map(\n mapWsfeActivityType\n );\n },\n async getReceiverVatConditions({\n representedTaxId,\n voucherClass,\n forceAuthRefresh,\n }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FEParamGetCondicionIvaReceptor\",\n {\n representedTaxId,\n forceAuthRefresh,\n },\n {\n ...(voucherClass === undefined ? {} : { ClaseCmp: voucherClass }),\n }\n );\n return getWsfeResultEntries(result, \"CondicionIvaReceptor\").map(\n mapWsfeReceiverVatCondition\n );\n },\n async getServerStatus() {\n const result = await executeWsfeOperation(\"FEDummy\");\n return mapWsfeServerStatus(result);\n },\n async getQuotation({ currencyId, representedTaxId, forceAuthRefresh }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FEParamGetCotizacion\",\n {\n representedTaxId,\n forceAuthRefresh,\n },\n {\n MonId: currencyId,\n }\n );\n const raw =\n (result.ResultGet as Record<string, unknown> | undefined) ?? {};\n return mapWsfeQuotation(raw);\n },\n async getVoucherInfo({\n representedTaxId,\n number,\n salesPoint,\n voucherType,\n }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FECompConsultar\",\n {\n representedTaxId,\n },\n {\n FeCompConsReq: {\n CbteNro: number,\n PtoVta: salesPoint,\n CbteTipo: voucherType,\n },\n }\n );\n const raw = (result.ResultGet as Record<string, unknown> | null) ?? null;\n if (!raw) {\n return null;\n }\n return mapWsfeVoucherInfo(raw);\n },\n };\n}\n\nfunction mapWsfeVoucherInput(\n input: NormalizedWsfeVoucherInput,\n voucherNumber: number\n): Record<string, unknown> {\n const sendsSameForeignCurrencyCancellation =\n input.currencyId !== \"PES\" && input.sameCurrencyForeignCancellation === \"S\";\n\n if (\n input.exchangeRate === undefined &&\n !sendsSameForeignCurrencyCancellation\n ) {\n throw new ArcaInputError(\n \"exchangeRate is required unless sameCurrencyForeignCancellation is S for a foreign-currency voucher.\"\n );\n }\n\n const data: Record<string, unknown> = {\n Concepto: input.concept,\n DocTipo: input.documentType,\n DocNro: input.documentNumber,\n CbteDesde: voucherNumber,\n CbteHasta: voucherNumber,\n CbteFch: input.voucherDate,\n ImpTotal: input.totalAmount,\n ImpTotConc: input.nonTaxableAmount,\n ImpNeto: input.netAmount,\n ImpOpEx: input.exemptAmount,\n ImpTrib: input.taxAmount,\n ImpIVA: input.vatAmount,\n MonId: input.currencyId,\n PtoVta: input.salesPoint,\n CbteTipo: input.voucherType,\n };\n\n if (!sendsSameForeignCurrencyCancellation) {\n data.MonCotiz = input.exchangeRate;\n }\n\n if (input.receiverVatConditionId !== undefined) {\n data.CondicionIVAReceptorId = input.receiverVatConditionId;\n }\n\n if (\n input.currencyId !== \"PES\" &&\n input.sameCurrencyForeignCancellation !== undefined\n ) {\n data.CanMisMonExt = input.sameCurrencyForeignCancellation;\n }\n\n if (input.serviceStartDate !== undefined) {\n data.FchServDesde = input.serviceStartDate;\n }\n if (input.serviceEndDate !== undefined) {\n data.FchServHasta = input.serviceEndDate;\n }\n if (input.paymentDueDate !== undefined) {\n data.FchVtoPago = input.paymentDueDate;\n }\n\n if (input.associatedVouchers) {\n data.CbtesAsoc = {\n CbteAsoc: input.associatedVouchers.map((v) => ({\n Tipo: v.type,\n PtoVta: v.salesPoint,\n Nro: v.number,\n ...(v.taxId === undefined ? {} : { Cuit: v.taxId }),\n ...(v.voucherDate === undefined ? {} : { CbteFch: v.voucherDate }),\n })),\n };\n }\n\n if (input.associatedPeriod) {\n data.PeriodoAsoc = {\n FchDesde: input.associatedPeriod.startDate,\n FchHasta: input.associatedPeriod.endDate,\n };\n }\n\n if (input.taxes) {\n data.Tributos = {\n Tributo: input.taxes.map((t) => ({\n Id: t.id,\n ...(t.description === undefined ? {} : { Desc: t.description }),\n BaseImp: t.baseAmount,\n Alic: t.rate,\n Importe: t.amount,\n })),\n };\n }\n\n if (input.vatRates) {\n data.Iva = {\n AlicIva: input.vatRates.map((v) => ({\n Id: v.id,\n BaseImp: v.baseAmount,\n Importe: v.amount,\n })),\n };\n }\n\n if (input.optionalFields) {\n data.Opcionales = {\n Opcional: input.optionalFields.map((o) => ({\n Id: o.id,\n Valor: o.value,\n })),\n };\n }\n\n if (input.buyers) {\n data.Compradores = {\n Comprador: input.buyers.map((b) => ({\n DocTipo: b.documentType,\n DocNro: b.documentNumber,\n Porcentaje: b.percentage,\n })),\n };\n }\n\n if (input.activities) {\n data.Actividades = {\n Actividad: input.activities.map((a) => ({\n Id: a.id,\n })),\n };\n }\n\n return data;\n}\n\nfunction normalizeWsfeVoucherInput(\n input: WsfeVoucherInput\n): NormalizedWsfeVoucherInput {\n const {\n voucherDate,\n serviceStartDate,\n serviceEndDate,\n paymentDueDate,\n associatedVouchers,\n associatedPeriod,\n ...rest\n } = input;\n\n return {\n ...rest,\n voucherDate: normalizeWsfeDateInput(voucherDate, \"voucherDate\"),\n ...(serviceStartDate === undefined\n ? {}\n : {\n serviceStartDate: normalizeWsfeDateInput(\n serviceStartDate,\n \"serviceStartDate\"\n ),\n }),\n ...(serviceEndDate === undefined\n ? {}\n : {\n serviceEndDate: normalizeWsfeDateInput(\n serviceEndDate,\n \"serviceEndDate\"\n ),\n }),\n ...(paymentDueDate === undefined\n ? {}\n : {\n paymentDueDate: normalizeWsfeDateInput(\n paymentDueDate,\n \"paymentDueDate\"\n ),\n }),\n ...(associatedVouchers === undefined\n ? {}\n : {\n associatedVouchers: associatedVouchers.map((voucher, index) => {\n const { voucherDate: associatedVoucherDate, ...associatedRest } =\n voucher;\n\n return {\n ...associatedRest,\n ...(associatedVoucherDate === undefined\n ? {}\n : {\n voucherDate: normalizeWsfeDateInput(\n associatedVoucherDate,\n `associatedVouchers[${index}].voucherDate`\n ),\n }),\n };\n }),\n }),\n ...(associatedPeriod === undefined\n ? {}\n : {\n associatedPeriod: {\n startDate: normalizeWsfeDateInput(\n associatedPeriod.startDate,\n \"associatedPeriod.startDate\"\n ),\n endDate: normalizeWsfeDateInput(\n associatedPeriod.endDate,\n \"associatedPeriod.endDate\"\n ),\n },\n }),\n };\n}\n\nfunction normalizeWsfeDateInput(\n value: WsfeDateInput,\n fieldName: string\n): string {\n if (typeof value !== \"string\") {\n throw new ArcaInputError(\n `Invalid WSFE ${fieldName}: expected a YYYY-MM-DD or YYYYMMDD string`,\n {\n detail: { field: fieldName, value },\n }\n );\n }\n\n const normalizedValue = value.trim();\n const afipMatch = normalizedValue.match(/^(\\d{4})(\\d{2})(\\d{2})$/);\n if (afipMatch) {\n const [, year, month, day] = afipMatch;\n assertValidCalendarDate(year, month, day, fieldName, normalizedValue);\n return normalizedValue;\n }\n\n const isoMatch = normalizedValue.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/);\n if (isoMatch) {\n const [, year, month, day] = isoMatch;\n assertValidCalendarDate(year, month, day, fieldName, normalizedValue);\n return `${year}${month}${day}`;\n }\n\n throw new ArcaInputError(\n `Invalid WSFE ${fieldName}: expected a YYYY-MM-DD or YYYYMMDD string`,\n {\n detail: { field: fieldName, value: normalizedValue },\n }\n );\n}\n\nfunction assertValidCalendarDate(\n yearInput: string,\n monthInput: string,\n dayInput: string,\n fieldName: string,\n value: string\n) {\n const year = Number(yearInput);\n const month = Number(monthInput);\n const day = Number(dayInput);\n const candidate = new Date(Date.UTC(year, month - 1, day));\n\n if (\n candidate.getUTCFullYear() !== year ||\n candidate.getUTCMonth() !== month - 1 ||\n candidate.getUTCDate() !== day\n ) {\n throw new ArcaInputError(\n `Invalid WSFE ${fieldName}: received a non-existent calendar date`,\n {\n detail: { field: fieldName, value },\n }\n );\n }\n}\n\nfunction mapWsfeSalesPoint(raw: unknown): WsfeSalesPoint {\n const record = raw as Record<string, unknown>;\n return {\n number: Number(record.Nro ?? 0),\n ...(record.EmisionTipo === undefined\n ? {}\n : { emissionType: String(record.EmisionTipo) }),\n ...(record.Bloqueado === undefined\n ? {}\n : { blocked: String(record.Bloqueado) }),\n ...(record.FchBaja === undefined\n ? {}\n : { deletedSince: String(record.FchBaja) }),\n };\n}\n\nfunction mapWsfeCatalogEntry(raw: unknown): WsfeCatalogEntry {\n const record = raw as Record<string, unknown>;\n return {\n id: Number(record.Id ?? 0),\n description: String(record.Desc ?? \"\"),\n };\n}\n\nfunction mapWsfeActivityType(raw: unknown): WsfeActivityType {\n const record = raw as Record<string, unknown>;\n return {\n id: Number(record.Id ?? 0),\n description: String(record.Desc ?? \"\"),\n order: Number(record.Orden ?? 0),\n };\n}\n\nfunction mapWsfeReceiverVatCondition(raw: unknown): WsfeReceiverVatCondition {\n const record = raw as Record<string, unknown>;\n return {\n id: Number(record.Id ?? 0),\n description: String(record.Desc ?? \"\"),\n voucherClass: String(record.Cmp_Clase ?? \"\"),\n };\n}\n\nfunction mapWsfeCurrencyType(raw: unknown): WsfeCurrencyType {\n const record = raw as Record<string, unknown>;\n return {\n id: String(record.Id ?? \"\"),\n description: String(record.Desc ?? \"\"),\n validFrom: String(record.FchDesde ?? \"\"),\n validTo: String(record.FchHasta ?? \"\"),\n };\n}\n\nfunction mapWsfeServerStatus(raw: Record<string, unknown>): WsfeServerStatus {\n return {\n appServer: String(raw.AppServer ?? \"\"),\n dbServer: String(raw.DbServer ?? \"\"),\n authServer: String(raw.AuthServer ?? \"\"),\n };\n}\n\nfunction mapWsfeQuotation(raw: Record<string, unknown>): WsfeQuotation {\n return {\n currencyId: String(raw.MonId ?? \"\"),\n rate: Number(raw.MonCotiz ?? 0),\n date: String(raw.FchCotiz ?? \"\"),\n };\n}\n\nfunction mapWsfeVoucherInfo(raw: Record<string, unknown>): WsfeVoucherInfo {\n return {\n voucherNumber: Number(raw.CbteDesde ?? raw.CbteHasta ?? 0),\n ...(raw.CbteFch === undefined ? {} : { voucherDate: String(raw.CbteFch) }),\n ...(raw.PtoVta === undefined ? {} : { salesPoint: Number(raw.PtoVta) }),\n ...(raw.CbteTipo === undefined\n ? {}\n : { voucherType: Number(raw.CbteTipo) }),\n ...(raw.ImpTotal === undefined\n ? {}\n : { totalAmount: Number(raw.ImpTotal) }),\n ...(raw.Resultado === undefined ? {} : { result: String(raw.Resultado) }),\n ...(raw.CAE === undefined ? {} : { cae: String(raw.CAE) }),\n ...(raw.CAEFchVto === undefined\n ? {}\n : { caeExpiry: String(raw.CAEFchVto) }),\n raw,\n };\n}\n\nfunction createWsfeAuth(\n representedTaxId: number | string,\n token: string,\n sign: string\n) {\n return {\n Token: token,\n Sign: sign,\n Cuit: Number.parseInt(String(representedTaxId), 10),\n };\n}\n\nfunction unwrapWsfeOperationResult(\n operation: string,\n response: Record<string, unknown>\n) {\n const operationResponse = response[`${operation}Response`] as\n | Record<string, unknown>\n | undefined;\n const result = (operationResponse?.[`${operation}Result`] ??\n response[`${operation}Result`] ??\n response) as Record<string, unknown>;\n\n if (operation === \"FECAESolicitar\") {\n const detailResponse = normalizeWsfeDetailResponse(result);\n const resultCode = detailResponse.Resultado;\n if (resultCode && resultCode !== \"A\") {\n const observationsContainer = detailResponse.Observaciones as\n | Record<string, unknown>\n | undefined;\n const observations = normalizeWsfeErrors(observationsContainer?.Obs);\n if (observations.length > 0) {\n const firstObservation = observations[0];\n if (!firstObservation) {\n throw new ArcaServiceError(\n \"WSFE returned an empty observation list\",\n {\n detail: result,\n }\n );\n }\n throw new ArcaServiceError(firstObservation.message, {\n serviceCode: firstObservation.code,\n detail: result,\n });\n }\n }\n }\n\n const errorsContainer = result.Errors as Record<string, unknown> | undefined;\n const errors = normalizeWsfeErrors(errorsContainer?.Err);\n if (errors.length > 0) {\n const firstError = errors[0];\n if (!firstError) {\n throw new ArcaServiceError(\"WSFE returned an empty error list\", {\n detail: result,\n });\n }\n throw new ArcaServiceError(firstError.message, {\n serviceCode: firstError.code,\n detail: result,\n });\n }\n\n return result;\n}\n\nfunction normalizeWsfeDetailResponse(result: Record<string, unknown>) {\n const detailResponse = result.FeDetResp as\n | Record<string, unknown>\n | undefined;\n const rawDetail = detailResponse?.FECAEDetResponse;\n\n if (Array.isArray(rawDetail)) {\n return (rawDetail[0] as Record<string, unknown>) ?? {};\n }\n\n return (rawDetail as Record<string, unknown> | undefined) ?? {};\n}\n\nfunction normalizeWsfeErrors(rawErrors: unknown) {\n const entries = Array.isArray(rawErrors)\n ? rawErrors\n : rawErrors\n ? [rawErrors]\n : [];\n\n return entries\n .map((entry) => entry as Record<string, unknown>)\n .map((entry) => {\n const code = entry.Code ?? entry.code ?? \"N/A\";\n const message = entry.Msg ?? entry.msg ?? \"Unknown WSFE error\";\n return {\n code: String(code),\n message: `(${String(code)}) ${String(message)}`,\n };\n });\n}\n\nfunction getWsfeResultEntries(\n result: Record<string, unknown>,\n key: string\n): Record<string, unknown>[] {\n const rawEntries = (\n result.ResultGet as Record<string, unknown> | undefined\n )?.[key];\n if (!rawEntries) {\n return [];\n }\n\n return (Array.isArray(rawEntries) ? rawEntries : [rawEntries]).map(\n (entry) => entry as Record<string, unknown>\n );\n}\n"],"mappings":";AACO,IAAM,YAAN,cAAwB,MAAM;AAAA,EAC1B;AAAA,EACS,OAAe;AAAA,EAEjC,YAAY,SAAiB,OAAO,cAAc,SAAwB;AAC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a,WAAW;AAAA,MACxB,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAEA,SAAS,4BAA4B,QAAiC;AACpE,QAAM,iBAAiB,OAAO;AAG9B,QAAM,YAAY,gBAAgB;AAElC,MAAI,MAAM,QAAQ,SAAS,GAAG;AAC5B,WAAQ,UAAU,CAAC,KAAiC,CAAC;AAAA,EACvD;AAEA,SAAQ,aAAqD,CAAC;AAChE;AAEA,SAAS,oBAAoB,WAAoB;AAC/C,QAAM,UAAU,MAAM,QAAQ,SAAS,IACnC,YACA,YACE,CAAC,SAAS,IACV,CAAC;AAEP,SAAO,QACJ,IAAI,CAAC,UAAU,KAAgC,EAC/C,IAAI,CAAC,UAAU;AACd,UAAM,OAAO,MAAM,QAAQ,MAAM,QAAQ;AACzC,UAAM,UAAU,MAAM,OAAO,MAAM,OAAO;AAC1C,WAAO;AAAA,MACL,MAAM,OAAO,IAAI;AAAA,MACjB,SAAS,IAAI,OAAO,IAAI,CAAC,KAAK,OAAO,OAAO,CAAC;AAAA,IAC/C;AAAA,EACF,CAAC;AACL;AAEA,SAAS,qBACP,QACA,KAC2B;AAC3B,QAAM,aACJ,OAAO,YACL,GAAG;AACP,MAAI,CAAC,YAAY;AACf,WAAO,CAAC;AAAA,EACV;AAEA,UAAQ,MAAM,QAAQ,UAAU,IAAI,aAAa,CAAC,UAAU,GAAG;AAAA,IAC7D,CAAC,UAAU;AAAA,EACb;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/services/wsfe.ts"],"sourcesContent":["import type { ArcaServiceName } from \"./internal/types\";\n\n/** Base error class for all ARCA-related errors. */\nexport class ArcaError extends Error {\n readonly code: string;\n override readonly name: string = \"ArcaError\";\n\n constructor(message: string, code = \"ARCA_ERROR\", options?: ErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/** Thrown when the ARCA client configuration is missing or invalid. */\nexport class ArcaConfigurationError extends ArcaError {\n override readonly name: string = \"ArcaConfigurationError\";\n\n constructor(message: string, options?: ErrorOptions) {\n super(message, \"ARCA_CONFIGURATION_ERROR\", options);\n }\n}\n\n/** Thrown when caller-provided input data is missing or invalid. */\nexport class ArcaInputError extends ArcaError {\n override readonly name: string = \"ArcaInputError\";\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_INPUT_ERROR\", options);\n this.detail = options?.detail;\n }\n}\n\n/** Thrown when an HTTP request to an ARCA endpoint fails at the transport level. */\nexport class ArcaTransportError extends ArcaError {\n override readonly name: string = \"ArcaTransportError\";\n readonly statusCode?: number;\n readonly contentType?: string;\n readonly responseBody?: string;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n statusCode?: number;\n contentType?: string;\n responseBody?: string;\n }\n ) {\n super(message, \"ARCA_TRANSPORT_ERROR\", options);\n this.statusCode = options?.statusCode;\n this.contentType = options?.contentType;\n this.responseBody = options?.responseBody;\n }\n}\n\n/** Thrown when the SOAP response contains a Fault element. */\nexport class ArcaSoapFaultError extends ArcaError {\n override readonly name: string = \"ArcaSoapFaultError\";\n readonly faultCode?: string;\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n faultCode?: string;\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_SOAP_FAULT\", options);\n this.faultCode = options?.faultCode;\n this.detail = options?.detail;\n }\n}\n\n/** Thrown when a response cannot be parsed as a valid SOAP envelope. */\nexport class ArcaInvalidSoapResponseError extends ArcaError {\n override readonly name: string = \"ArcaInvalidSoapResponseError\";\n readonly service?: ArcaServiceName;\n readonly operation?: string;\n readonly endpointUrl?: string;\n readonly statusCode?: number;\n readonly contentType?: string;\n readonly responseBodyLength?: number;\n readonly responseBodyPreview?: string;\n readonly parsedDetail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n service?: ArcaServiceName;\n operation?: string;\n endpointUrl?: string;\n statusCode?: number;\n contentType?: string;\n responseBodyLength?: number;\n responseBodyPreview?: string;\n parsedDetail?: unknown;\n }\n ) {\n super(message, \"ARCA_INVALID_SOAP_RESPONSE\", options);\n this.service = options?.service;\n this.operation = options?.operation;\n this.endpointUrl = options?.endpointUrl;\n this.statusCode = options?.statusCode;\n this.contentType = options?.contentType;\n this.responseBodyLength = options?.responseBodyLength;\n this.responseBodyPreview = options?.responseBodyPreview;\n this.parsedDetail = options?.parsedDetail;\n }\n}\n\n/** Thrown when an ARCA service (WSFE, WSMTXCA, Padron) returns a domain-level error. */\nexport class ArcaServiceError extends ArcaError {\n override readonly name: string = \"ArcaServiceError\";\n readonly serviceCode?: string | number;\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n serviceCode?: string | number;\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_SERVICE_ERROR\", options);\n this.serviceCode = options?.serviceCode;\n this.detail = options?.detail;\n }\n}\n","import { ArcaInputError, ArcaServiceError } from \"../errors\";\nimport type { ArcaClientConfig, ArcaRepresentedTaxId } from \"../internal/types\";\nimport type { SoapTransport } from \"../soap\";\nimport type { WsaaAuthModule } from \"../wsaa\";\n\n/** Accepted public date inputs for WSFE request fields. */\nexport type WsfeDateInput =\n | `${number}${number}${number}${number}-${number}${number}-${number}${number}`\n | `${number}${number}${number}${number}${number}${number}${number}${number}`;\n\n/** An associated voucher referenced by a WSFE invoice request. */\nexport type WsfeAssociatedVoucher = {\n type: number;\n salesPoint: number;\n number: number;\n taxId?: string;\n voucherDate?: WsfeDateInput;\n};\n\n/** An associated period used by WSFE credit/debit notes without associated vouchers. */\nexport type WsfeAssociatedPeriod = {\n startDate: WsfeDateInput;\n endDate: WsfeDateInput;\n};\n\n/** A tax (tributo) item in a WSFE invoice request. */\nexport type WsfeTax = {\n id: number;\n description?: string;\n baseAmount: number;\n rate: number;\n amount: number;\n};\n\n/** A VAT rate (alícuota IVA) item in a WSFE invoice request. */\nexport type WsfeVatRate = {\n id: number;\n baseAmount: number;\n amount: number;\n};\n\n/** An optional field (campo opcional) in a WSFE invoice request. */\nexport type WsfeOptionalField = {\n id: string;\n value: string;\n};\n\n/** A buyer (comprador) in a WSFE invoice request. */\nexport type WsfeBuyer = {\n documentType: number;\n documentNumber: number;\n percentage: number;\n};\n\n/** An activity associated with a WSFE invoice request. */\nexport type WsfeActivity = {\n id: number;\n};\n\n/** Input data for authorizing a WSFE voucher. */\nexport type WsfeVoucherInput = {\n salesPoint: number;\n voucherType: number;\n concept: number;\n documentType: number;\n documentNumber: number;\n receiverVatConditionId?: number;\n voucherDate: WsfeDateInput;\n totalAmount: number;\n nonTaxableAmount: number;\n netAmount: number;\n exemptAmount: number;\n taxAmount: number;\n vatAmount: number;\n currencyId: string;\n exchangeRate?: number;\n sameCurrencyForeignCancellation?: \"S\" | \"N\";\n serviceStartDate?: WsfeDateInput;\n serviceEndDate?: WsfeDateInput;\n paymentDueDate?: WsfeDateInput;\n associatedVouchers?: WsfeAssociatedVoucher[];\n associatedPeriod?: WsfeAssociatedPeriod;\n taxes?: WsfeTax[];\n vatRates?: WsfeVatRate[];\n optionalFields?: WsfeOptionalField[];\n buyers?: WsfeBuyer[];\n activities?: WsfeActivity[];\n};\n\n/** Input for authorizing a WSFE voucher with an explicit voucher number. */\nexport type WsfeAuthorizeVoucherInput = {\n representedTaxId?: number | string;\n data: WsfeVoucherInput;\n voucherNumber: number;\n forceRefresh?: boolean;\n};\n\n/** Result of a successful WSFE voucher authorization. */\nexport type WsfeAuthorizationResult = {\n cae: string;\n caeExpiry: string;\n voucherNumber: number;\n raw: Record<string, unknown>;\n};\n\n/** A point-of-sale entry returned by {@link WsfeService.getSalesPoints}. */\nexport type WsfeSalesPoint = {\n number: number;\n emissionType?: string;\n blocked?: string;\n deletedSince?: string;\n};\n\n/** Voucher details returned by {@link WsfeService.getVoucherInfo}. */\nexport type WsfeVoucherInfo = {\n voucherNumber: number;\n voucherDate?: string;\n salesPoint?: number;\n voucherType?: number;\n totalAmount?: number;\n result?: string;\n cae?: string;\n caeExpiry?: string;\n raw: Record<string, unknown>;\n};\n\nexport type WsfeCatalogEntry = {\n id: number;\n description: string;\n};\n\nexport type WsfeActivityType = WsfeCatalogEntry & {\n order: number;\n};\n\nexport type WsfeReceiverVatCondition = WsfeCatalogEntry & {\n voucherClass: string;\n};\n\nexport type WsfeCurrencyType = {\n id: string;\n description: string;\n validFrom: string;\n validTo: string;\n};\n\nexport type WsfeServerStatus = {\n appServer: string;\n dbServer: string;\n authServer: string;\n};\n\nexport type WsfeQuotation = {\n currencyId: string;\n rate: number;\n date: string;\n};\n\n/** WSFE electronic invoicing service. */\nexport type WsfeService = {\n /** Authorizes a voucher with the explicit number sent as `CbteDesde` and `CbteHasta`. */\n authorizeVoucher(\n input: WsfeAuthorizeVoucherInput\n ): Promise<WsfeAuthorizationResult>;\n /** Authorizes a new voucher by fetching the next number and requesting a CAE. */\n createNextVoucher(input: {\n representedTaxId?: number | string;\n data: WsfeVoucherInput;\n forceRefresh?: boolean;\n }): Promise<WsfeAuthorizationResult>;\n /** Returns the next available voucher number for the given sales point and type. */\n getNextVoucherNumber(input: {\n representedTaxId?: number | string;\n salesPoint: number;\n voucherType: number;\n forceRefresh?: boolean;\n }): Promise<number>;\n /**\n * @deprecated Use `getNextVoucherNumber()` instead.\n * Returns the next available voucher number, not the last authorized one.\n */\n getLastVoucher(input: {\n representedTaxId?: number | string;\n salesPoint: number;\n voucherType: number;\n forceRefresh?: boolean;\n }): Promise<number>;\n /** Lists all configured points of sale for the taxpayer. */\n getSalesPoints(input: {\n representedTaxId?: number | string;\n forceRefresh?: boolean;\n }): Promise<WsfeSalesPoint[]>;\n /** Lists voucher types accepted by WSFE. */\n getVoucherTypes(input: {\n representedTaxId?: number | string;\n forceRefresh?: boolean;\n }): Promise<WsfeCatalogEntry[]>;\n /** Lists document types accepted by WSFE. */\n getDocumentTypes(input: {\n representedTaxId?: number | string;\n forceRefresh?: boolean;\n }): Promise<WsfeCatalogEntry[]>;\n /** Lists concept types accepted by WSFE. */\n getConceptTypes(input: {\n representedTaxId?: number | string;\n forceRefresh?: boolean;\n }): Promise<WsfeCatalogEntry[]>;\n /** Lists supported currency types. */\n getCurrencyTypes(input: {\n representedTaxId?: number | string;\n forceRefresh?: boolean;\n }): Promise<WsfeCurrencyType[]>;\n /** Lists VAT rates accepted by WSFE. */\n getVatRates(input: {\n representedTaxId?: number | string;\n forceRefresh?: boolean;\n }): Promise<WsfeCatalogEntry[]>;\n /** Lists tax types accepted by WSFE. */\n getTaxTypes(input: {\n representedTaxId?: number | string;\n forceRefresh?: boolean;\n }): Promise<WsfeCatalogEntry[]>;\n /** Lists optional field types accepted by WSFE. */\n getOptionalTypes(input: {\n representedTaxId?: number | string;\n forceRefresh?: boolean;\n }): Promise<WsfeCatalogEntry[]>;\n /** Lists activities enabled for the taxpayer. */\n getActivities(input: {\n representedTaxId?: number | string;\n forceRefresh?: boolean;\n }): Promise<WsfeActivityType[]>;\n /** Lists receiver VAT condition values accepted by WSFE. */\n getReceiverVatConditions(input: {\n representedTaxId?: number | string;\n voucherClass?: string;\n forceRefresh?: boolean;\n }): Promise<WsfeReceiverVatCondition[]>;\n /** Reports WSFE backend status without requiring taxpayer authorization. */\n getServerStatus(): Promise<WsfeServerStatus>;\n /** Returns the exchange rate for a given currency. */\n getQuotation(input: {\n currencyId: string;\n representedTaxId?: number | string;\n forceRefresh?: boolean;\n }): Promise<WsfeQuotation>;\n /** Retrieves details for a specific voucher. Returns `null` if not found. */\n getVoucherInfo(input: {\n representedTaxId?: number | string;\n number: number;\n salesPoint: number;\n voucherType: number;\n forceRefresh?: boolean;\n }): Promise<WsfeVoucherInfo | null>;\n};\n\nexport type CreateWsfeServiceOptions = {\n config: ArcaClientConfig;\n auth: WsaaAuthModule;\n soap: SoapTransport;\n};\n\ntype NormalizedWsfeAssociatedVoucher = Omit<\n WsfeAssociatedVoucher,\n \"voucherDate\"\n> & {\n voucherDate?: string;\n};\n\ntype NormalizedWsfeAssociatedPeriod = {\n startDate: string;\n endDate: string;\n};\n\ntype NormalizedWsfeVoucherInput = Omit<\n WsfeVoucherInput,\n | \"voucherDate\"\n | \"serviceStartDate\"\n | \"serviceEndDate\"\n | \"paymentDueDate\"\n | \"associatedVouchers\"\n | \"associatedPeriod\"\n> & {\n voucherDate: string;\n serviceStartDate?: string;\n serviceEndDate?: string;\n paymentDueDate?: string;\n associatedVouchers?: NormalizedWsfeAssociatedVoucher[];\n associatedPeriod?: NormalizedWsfeAssociatedPeriod;\n};\n\n/** Creates a WSFE service instance wired with authentication and SOAP transport. */\nexport function createWsfeService(\n options: CreateWsfeServiceOptions\n): WsfeService {\n async function executeWsfeAuthenticatedOperation(\n operation: string,\n input: {\n representedTaxId?: ArcaRepresentedTaxId;\n forceRefresh?: boolean;\n },\n body: Record<string, unknown> = {}\n ) {\n const auth = await options.auth.login(\"wsfe\", {\n representedTaxId: input.representedTaxId,\n forceRefresh: input.forceRefresh,\n });\n const response = await options.soap.execute<\n Record<string, unknown>,\n Record<string, unknown>\n >({\n service: \"wsfe\",\n operation,\n body: {\n Auth: createWsfeAuth(\n input.representedTaxId ?? options.config.taxId,\n auth.token,\n auth.sign\n ),\n ...body,\n },\n });\n\n return unwrapWsfeOperationResult(operation, response.result);\n }\n\n async function executeWsfeOperation(\n operation: string,\n body: Record<string, unknown> = {}\n ) {\n const response = await options.soap.execute<\n Record<string, unknown>,\n Record<string, unknown>\n >({\n service: \"wsfe\",\n operation,\n body,\n });\n\n return unwrapWsfeOperationResult(operation, response.result);\n }\n\n async function getNextVoucherNumber({\n representedTaxId,\n salesPoint,\n voucherType,\n forceRefresh,\n }: {\n representedTaxId?: number | string;\n salesPoint: number;\n voucherType: number;\n forceRefresh?: boolean;\n }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FECompUltimoAutorizado\",\n {\n representedTaxId,\n forceRefresh,\n },\n {\n PtoVta: salesPoint,\n CbteTipo: voucherType,\n }\n );\n return Number(result.CbteNro ?? 0) + 1;\n }\n\n async function getWsfeCatalog(\n operation: string,\n resultKey: string,\n input: {\n representedTaxId?: ArcaRepresentedTaxId;\n forceRefresh?: boolean;\n }\n ): Promise<WsfeCatalogEntry[]> {\n const result = await executeWsfeAuthenticatedOperation(operation, {\n representedTaxId: input.representedTaxId,\n forceRefresh: input.forceRefresh,\n });\n return getWsfeResultEntries(result, resultKey).map(mapWsfeCatalogEntry);\n }\n\n function authorizeVoucher({\n representedTaxId,\n data,\n voucherNumber,\n forceRefresh,\n }: WsfeAuthorizeVoucherInput): Promise<WsfeAuthorizationResult> {\n const normalizedInput = normalizeWsfeVoucherInput(data);\n return authorizeNormalizedVoucher({\n representedTaxId,\n data: normalizedInput,\n voucherNumber,\n forceRefresh,\n });\n }\n\n async function authorizeNormalizedVoucher({\n representedTaxId,\n data: normalizedInput,\n voucherNumber,\n forceRefresh,\n }: {\n representedTaxId?: number | string;\n data: NormalizedWsfeVoucherInput;\n voucherNumber: number;\n forceRefresh?: boolean;\n }): Promise<WsfeAuthorizationResult> {\n const requestData = mapWsfeVoucherInput(normalizedInput, voucherNumber);\n\n const auth = await options.auth.login(\"wsfe\", {\n representedTaxId,\n forceRefresh,\n });\n const response = await options.soap.execute<\n Record<string, unknown>,\n Record<string, unknown>\n >({\n service: \"wsfe\",\n operation: \"FECAESolicitar\",\n body: {\n Auth: createWsfeAuth(\n representedTaxId ?? options.config.taxId,\n auth.token,\n auth.sign\n ),\n FeCAEReq: {\n FeCabReq: {\n CantReg: 1,\n PtoVta: normalizedInput.salesPoint,\n CbteTipo: normalizedInput.voucherType,\n },\n FeDetReq: {\n FECAEDetRequest: requestData,\n },\n },\n },\n });\n\n const result = unwrapWsfeOperationResult(\"FECAESolicitar\", response.result);\n const detailResponse = normalizeWsfeDetailResponse(result);\n const cae = detailResponse.CAE;\n const caeExpiry = detailResponse.CAEFchVto;\n\n if (typeof cae !== \"string\" || typeof caeExpiry !== \"string\") {\n throw new ArcaServiceError(\"WSFE did not return CAE authorization data\", {\n detail: result,\n });\n }\n\n return {\n cae,\n caeExpiry: String(caeExpiry),\n voucherNumber,\n raw: result,\n };\n }\n\n return {\n authorizeVoucher,\n async createNextVoucher({ representedTaxId, data, forceRefresh }) {\n const normalizedInput = normalizeWsfeVoucherInput(data);\n\n const voucherNumber = await getNextVoucherNumber({\n representedTaxId,\n salesPoint: normalizedInput.salesPoint,\n voucherType: normalizedInput.voucherType,\n forceRefresh,\n });\n\n return authorizeNormalizedVoucher({\n representedTaxId,\n data: normalizedInput,\n voucherNumber,\n });\n },\n getNextVoucherNumber,\n getLastVoucher(input) {\n return getNextVoucherNumber(input);\n },\n async getSalesPoints({ representedTaxId, forceRefresh }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FEParamGetPtosVenta\",\n {\n representedTaxId,\n forceRefresh,\n }\n );\n const rawPoints = (\n result.ResultGet as Record<string, unknown> | undefined\n )?.PtoVenta;\n if (!rawPoints) {\n return [];\n }\n const entries = Array.isArray(rawPoints) ? rawPoints : [rawPoints];\n return entries.map(mapWsfeSalesPoint);\n },\n getVoucherTypes(input) {\n return getWsfeCatalog(\"FEParamGetTiposCbte\", \"CbteTipo\", input);\n },\n getDocumentTypes(input) {\n return getWsfeCatalog(\"FEParamGetTiposDoc\", \"DocTipo\", input);\n },\n getConceptTypes(input) {\n return getWsfeCatalog(\"FEParamGetTiposConcepto\", \"ConceptoTipo\", input);\n },\n async getCurrencyTypes({ representedTaxId, forceRefresh }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FEParamGetTiposMonedas\",\n {\n representedTaxId,\n forceRefresh,\n }\n );\n return getWsfeResultEntries(result, \"Moneda\").map(mapWsfeCurrencyType);\n },\n getVatRates(input) {\n return getWsfeCatalog(\"FEParamGetTiposIva\", \"IvaTipo\", input);\n },\n getTaxTypes(input) {\n return getWsfeCatalog(\"FEParamGetTiposTributos\", \"TributoTipo\", input);\n },\n getOptionalTypes(input) {\n return getWsfeCatalog(\"FEParamGetTiposOpcional\", \"OpcionalTipo\", input);\n },\n async getActivities({ representedTaxId, forceRefresh }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FEParamGetActividades\",\n {\n representedTaxId,\n forceRefresh,\n }\n );\n return getWsfeResultEntries(result, \"ActividadesTipo\").map(\n mapWsfeActivityType\n );\n },\n async getReceiverVatConditions({\n representedTaxId,\n voucherClass,\n forceRefresh,\n }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FEParamGetCondicionIvaReceptor\",\n {\n representedTaxId,\n forceRefresh,\n },\n {\n ...(voucherClass === undefined ? {} : { ClaseCmp: voucherClass }),\n }\n );\n return getWsfeResultEntries(result, \"CondicionIvaReceptor\").map(\n mapWsfeReceiverVatCondition\n );\n },\n async getServerStatus() {\n const result = await executeWsfeOperation(\"FEDummy\");\n return mapWsfeServerStatus(result);\n },\n async getQuotation({ currencyId, representedTaxId, forceRefresh }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FEParamGetCotizacion\",\n {\n representedTaxId,\n forceRefresh,\n },\n {\n MonId: currencyId,\n }\n );\n const raw =\n (result.ResultGet as Record<string, unknown> | undefined) ?? {};\n return mapWsfeQuotation(raw);\n },\n async getVoucherInfo({\n representedTaxId,\n number,\n salesPoint,\n voucherType,\n forceRefresh,\n }) {\n const result = await executeWsfeAuthenticatedOperation(\n \"FECompConsultar\",\n {\n representedTaxId,\n forceRefresh,\n },\n {\n FeCompConsReq: {\n CbteNro: number,\n PtoVta: salesPoint,\n CbteTipo: voucherType,\n },\n }\n );\n const raw = (result.ResultGet as Record<string, unknown> | null) ?? null;\n if (!raw) {\n return null;\n }\n return mapWsfeVoucherInfo(raw);\n },\n };\n}\n\nfunction mapWsfeVoucherInput(\n input: NormalizedWsfeVoucherInput,\n voucherNumber: number\n): Record<string, unknown> {\n const sendsSameForeignCurrencyCancellation =\n input.currencyId !== \"PES\" && input.sameCurrencyForeignCancellation === \"S\";\n\n if (\n input.exchangeRate === undefined &&\n !sendsSameForeignCurrencyCancellation\n ) {\n throw new ArcaInputError(\n \"exchangeRate is required unless sameCurrencyForeignCancellation is S for a foreign-currency voucher.\"\n );\n }\n\n const data: Record<string, unknown> = {\n Concepto: input.concept,\n DocTipo: input.documentType,\n DocNro: input.documentNumber,\n CbteDesde: voucherNumber,\n CbteHasta: voucherNumber,\n CbteFch: input.voucherDate,\n ImpTotal: input.totalAmount,\n ImpTotConc: input.nonTaxableAmount,\n ImpNeto: input.netAmount,\n ImpOpEx: input.exemptAmount,\n ImpTrib: input.taxAmount,\n ImpIVA: input.vatAmount,\n MonId: input.currencyId,\n PtoVta: input.salesPoint,\n CbteTipo: input.voucherType,\n };\n\n if (!sendsSameForeignCurrencyCancellation) {\n data.MonCotiz = input.exchangeRate;\n }\n\n if (input.receiverVatConditionId !== undefined) {\n data.CondicionIVAReceptorId = input.receiverVatConditionId;\n }\n\n if (\n input.currencyId !== \"PES\" &&\n input.sameCurrencyForeignCancellation !== undefined\n ) {\n data.CanMisMonExt = input.sameCurrencyForeignCancellation;\n }\n\n if (input.serviceStartDate !== undefined) {\n data.FchServDesde = input.serviceStartDate;\n }\n if (input.serviceEndDate !== undefined) {\n data.FchServHasta = input.serviceEndDate;\n }\n if (input.paymentDueDate !== undefined) {\n data.FchVtoPago = input.paymentDueDate;\n }\n\n if (input.associatedVouchers) {\n data.CbtesAsoc = {\n CbteAsoc: input.associatedVouchers.map((v) => ({\n Tipo: v.type,\n PtoVta: v.salesPoint,\n Nro: v.number,\n ...(v.taxId === undefined ? {} : { Cuit: v.taxId }),\n ...(v.voucherDate === undefined ? {} : { CbteFch: v.voucherDate }),\n })),\n };\n }\n\n if (input.associatedPeriod) {\n data.PeriodoAsoc = {\n FchDesde: input.associatedPeriod.startDate,\n FchHasta: input.associatedPeriod.endDate,\n };\n }\n\n if (input.taxes) {\n data.Tributos = {\n Tributo: input.taxes.map((t) => ({\n Id: t.id,\n ...(t.description === undefined ? {} : { Desc: t.description }),\n BaseImp: t.baseAmount,\n Alic: t.rate,\n Importe: t.amount,\n })),\n };\n }\n\n if (input.vatRates) {\n data.Iva = {\n AlicIva: input.vatRates.map((v) => ({\n Id: v.id,\n BaseImp: v.baseAmount,\n Importe: v.amount,\n })),\n };\n }\n\n if (input.optionalFields) {\n data.Opcionales = {\n Opcional: input.optionalFields.map((o) => ({\n Id: o.id,\n Valor: o.value,\n })),\n };\n }\n\n if (input.buyers) {\n data.Compradores = {\n Comprador: input.buyers.map((b) => ({\n DocTipo: b.documentType,\n DocNro: b.documentNumber,\n Porcentaje: b.percentage,\n })),\n };\n }\n\n if (input.activities) {\n data.Actividades = {\n Actividad: input.activities.map((a) => ({\n Id: a.id,\n })),\n };\n }\n\n return data;\n}\n\nfunction normalizeWsfeVoucherInput(\n input: WsfeVoucherInput\n): NormalizedWsfeVoucherInput {\n const {\n voucherDate,\n serviceStartDate,\n serviceEndDate,\n paymentDueDate,\n associatedVouchers,\n associatedPeriod,\n ...rest\n } = input;\n\n return {\n ...rest,\n voucherDate: normalizeWsfeDateInput(voucherDate, \"voucherDate\"),\n ...(serviceStartDate === undefined\n ? {}\n : {\n serviceStartDate: normalizeWsfeDateInput(\n serviceStartDate,\n \"serviceStartDate\"\n ),\n }),\n ...(serviceEndDate === undefined\n ? {}\n : {\n serviceEndDate: normalizeWsfeDateInput(\n serviceEndDate,\n \"serviceEndDate\"\n ),\n }),\n ...(paymentDueDate === undefined\n ? {}\n : {\n paymentDueDate: normalizeWsfeDateInput(\n paymentDueDate,\n \"paymentDueDate\"\n ),\n }),\n ...(associatedVouchers === undefined\n ? {}\n : {\n associatedVouchers: associatedVouchers.map((voucher, index) => {\n const { voucherDate: associatedVoucherDate, ...associatedRest } =\n voucher;\n\n return {\n ...associatedRest,\n ...(associatedVoucherDate === undefined\n ? {}\n : {\n voucherDate: normalizeWsfeDateInput(\n associatedVoucherDate,\n `associatedVouchers[${index}].voucherDate`\n ),\n }),\n };\n }),\n }),\n ...(associatedPeriod === undefined\n ? {}\n : {\n associatedPeriod: {\n startDate: normalizeWsfeDateInput(\n associatedPeriod.startDate,\n \"associatedPeriod.startDate\"\n ),\n endDate: normalizeWsfeDateInput(\n associatedPeriod.endDate,\n \"associatedPeriod.endDate\"\n ),\n },\n }),\n };\n}\n\nfunction normalizeWsfeDateInput(\n value: WsfeDateInput,\n fieldName: string\n): string {\n if (typeof value !== \"string\") {\n throw new ArcaInputError(\n `Invalid WSFE ${fieldName}: expected a YYYY-MM-DD or YYYYMMDD string`,\n {\n detail: { field: fieldName, value },\n }\n );\n }\n\n const normalizedValue = value.trim();\n const afipMatch = normalizedValue.match(/^(\\d{4})(\\d{2})(\\d{2})$/);\n if (afipMatch) {\n const [, year, month, day] = afipMatch;\n assertValidCalendarDate(year, month, day, fieldName, normalizedValue);\n return normalizedValue;\n }\n\n const isoMatch = normalizedValue.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/);\n if (isoMatch) {\n const [, year, month, day] = isoMatch;\n assertValidCalendarDate(year, month, day, fieldName, normalizedValue);\n return `${year}${month}${day}`;\n }\n\n throw new ArcaInputError(\n `Invalid WSFE ${fieldName}: expected a YYYY-MM-DD or YYYYMMDD string`,\n {\n detail: { field: fieldName, value: normalizedValue },\n }\n );\n}\n\nfunction assertValidCalendarDate(\n yearInput: string,\n monthInput: string,\n dayInput: string,\n fieldName: string,\n value: string\n) {\n const year = Number(yearInput);\n const month = Number(monthInput);\n const day = Number(dayInput);\n const candidate = new Date(Date.UTC(year, month - 1, day));\n\n if (\n candidate.getUTCFullYear() !== year ||\n candidate.getUTCMonth() !== month - 1 ||\n candidate.getUTCDate() !== day\n ) {\n throw new ArcaInputError(\n `Invalid WSFE ${fieldName}: received a non-existent calendar date`,\n {\n detail: { field: fieldName, value },\n }\n );\n }\n}\n\nfunction mapWsfeSalesPoint(raw: unknown): WsfeSalesPoint {\n const record = raw as Record<string, unknown>;\n return {\n number: Number(record.Nro ?? 0),\n ...(record.EmisionTipo === undefined\n ? {}\n : { emissionType: String(record.EmisionTipo) }),\n ...(record.Bloqueado === undefined\n ? {}\n : { blocked: String(record.Bloqueado) }),\n ...(record.FchBaja === undefined\n ? {}\n : { deletedSince: String(record.FchBaja) }),\n };\n}\n\nfunction mapWsfeCatalogEntry(raw: unknown): WsfeCatalogEntry {\n const record = raw as Record<string, unknown>;\n return {\n id: Number(record.Id ?? 0),\n description: String(record.Desc ?? \"\"),\n };\n}\n\nfunction mapWsfeActivityType(raw: unknown): WsfeActivityType {\n const record = raw as Record<string, unknown>;\n return {\n id: Number(record.Id ?? 0),\n description: String(record.Desc ?? \"\"),\n order: Number(record.Orden ?? 0),\n };\n}\n\nfunction mapWsfeReceiverVatCondition(raw: unknown): WsfeReceiverVatCondition {\n const record = raw as Record<string, unknown>;\n return {\n id: Number(record.Id ?? 0),\n description: String(record.Desc ?? \"\"),\n voucherClass: String(record.Cmp_Clase ?? \"\"),\n };\n}\n\nfunction mapWsfeCurrencyType(raw: unknown): WsfeCurrencyType {\n const record = raw as Record<string, unknown>;\n return {\n id: String(record.Id ?? \"\"),\n description: String(record.Desc ?? \"\"),\n validFrom: String(record.FchDesde ?? \"\"),\n validTo: String(record.FchHasta ?? \"\"),\n };\n}\n\nfunction mapWsfeServerStatus(raw: Record<string, unknown>): WsfeServerStatus {\n return {\n appServer: String(raw.AppServer ?? \"\"),\n dbServer: String(raw.DbServer ?? \"\"),\n authServer: String(raw.AuthServer ?? \"\"),\n };\n}\n\nfunction mapWsfeQuotation(raw: Record<string, unknown>): WsfeQuotation {\n return {\n currencyId: String(raw.MonId ?? \"\"),\n rate: Number(raw.MonCotiz ?? 0),\n date: String(raw.FchCotiz ?? \"\"),\n };\n}\n\nfunction mapWsfeVoucherInfo(raw: Record<string, unknown>): WsfeVoucherInfo {\n return {\n voucherNumber: Number(raw.CbteDesde ?? raw.CbteHasta ?? 0),\n ...(raw.CbteFch === undefined ? {} : { voucherDate: String(raw.CbteFch) }),\n ...(raw.PtoVta === undefined ? {} : { salesPoint: Number(raw.PtoVta) }),\n ...(raw.CbteTipo === undefined\n ? {}\n : { voucherType: Number(raw.CbteTipo) }),\n ...(raw.ImpTotal === undefined\n ? {}\n : { totalAmount: Number(raw.ImpTotal) }),\n ...(raw.Resultado === undefined ? {} : { result: String(raw.Resultado) }),\n ...(raw.CAE === undefined ? {} : { cae: String(raw.CAE) }),\n ...(raw.CAEFchVto === undefined\n ? {}\n : { caeExpiry: String(raw.CAEFchVto) }),\n raw,\n };\n}\n\nfunction createWsfeAuth(\n representedTaxId: number | string,\n token: string,\n sign: string\n) {\n return {\n Token: token,\n Sign: sign,\n Cuit: Number.parseInt(String(representedTaxId), 10),\n };\n}\n\nfunction unwrapWsfeOperationResult(\n operation: string,\n response: Record<string, unknown>\n) {\n const operationResponse = response[`${operation}Response`] as\n | Record<string, unknown>\n | undefined;\n const result = (operationResponse?.[`${operation}Result`] ??\n response[`${operation}Result`] ??\n response) as Record<string, unknown>;\n\n if (operation === \"FECAESolicitar\") {\n const detailResponse = normalizeWsfeDetailResponse(result);\n const resultCode = detailResponse.Resultado;\n if (resultCode && resultCode !== \"A\") {\n const observationsContainer = detailResponse.Observaciones as\n | Record<string, unknown>\n | undefined;\n const observations = normalizeWsfeErrors(observationsContainer?.Obs);\n if (observations.length > 0) {\n const firstObservation = observations[0];\n if (!firstObservation) {\n throw new ArcaServiceError(\n \"WSFE returned an empty observation list\",\n {\n detail: result,\n }\n );\n }\n throw new ArcaServiceError(firstObservation.message, {\n serviceCode: firstObservation.code,\n detail: result,\n });\n }\n }\n }\n\n const errorsContainer = result.Errors as Record<string, unknown> | undefined;\n const errors = normalizeWsfeErrors(errorsContainer?.Err);\n if (errors.length > 0) {\n const firstError = errors[0];\n if (!firstError) {\n throw new ArcaServiceError(\"WSFE returned an empty error list\", {\n detail: result,\n });\n }\n throw new ArcaServiceError(firstError.message, {\n serviceCode: firstError.code,\n detail: result,\n });\n }\n\n return result;\n}\n\nfunction normalizeWsfeDetailResponse(result: Record<string, unknown>) {\n const detailResponse = result.FeDetResp as\n | Record<string, unknown>\n | undefined;\n const rawDetail = detailResponse?.FECAEDetResponse;\n\n if (Array.isArray(rawDetail)) {\n return (rawDetail[0] as Record<string, unknown>) ?? {};\n }\n\n return (rawDetail as Record<string, unknown> | undefined) ?? {};\n}\n\nfunction normalizeWsfeErrors(rawErrors: unknown) {\n const entries = Array.isArray(rawErrors)\n ? rawErrors\n : rawErrors\n ? [rawErrors]\n : [];\n\n return entries\n .map((entry) => entry as Record<string, unknown>)\n .map((entry) => {\n const code = entry.Code ?? entry.code ?? \"N/A\";\n const message = entry.Msg ?? entry.msg ?? \"Unknown WSFE error\";\n return {\n code: String(code),\n message: `(${String(code)}) ${String(message)}`,\n };\n });\n}\n\nfunction getWsfeResultEntries(\n result: Record<string, unknown>,\n key: string\n): Record<string, unknown>[] {\n const rawEntries = (\n result.ResultGet as Record<string, unknown> | undefined\n )?.[key];\n if (!rawEntries) {\n return [];\n }\n\n return (Array.isArray(rawEntries) ? rawEntries : [rawEntries]).map(\n (entry) => entry as Record<string, unknown>\n );\n}\n"],"mappings":";AAGO,IAAM,YAAN,cAAwB,MAAM;AAAA,EAC1B;AAAA,EACS,OAAe;AAAA,EAEjC,YAAY,SAAiB,OAAO,cAAc,SAAwB;AACxE,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAYO,IAAM,iBAAN,cAA6B,UAAU;AAAA,EAC1B,OAAe;AAAA,EACxB;AAAA,EAET,YACE,SACA,SAGA;AACA,UAAM,SAAS,oBAAoB,OAAO;AAC1C,SAAK,SAAS,SAAS;AAAA,EACzB;AACF;AAiFO,IAAM,mBAAN,cAA+B,UAAU;AAAA,EAC5B,OAAe;AAAA,EACxB;AAAA,EACA;AAAA,EAET,YACE,SACA,SAIA;AACA,UAAM,SAAS,sBAAsB,OAAO;AAC5C,SAAK,cAAc,SAAS;AAC5B,SAAK,SAAS,SAAS;AAAA,EACzB;AACF;;;AC+JO,SAAS,kBACd,SACa;AACb,iBAAe,kCACb,WACA,OAIA,OAAgC,CAAC,GACjC;AACA,UAAM,OAAO,MAAM,QAAQ,KAAK,MAAM,QAAQ;AAAA,MAC5C,kBAAkB,MAAM;AAA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