facturas 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +797 -37
- package/dist/{chunk-PPYGVNFA.mjs → chunk-4QVFXT35.mjs} +2 -2
- package/dist/{chunk-NUV5RZPZ.mjs → chunk-7LEKQ4P7.mjs} +2 -2
- package/dist/{chunk-TOVSOJ3G.mjs → chunk-RCM4NAAG.mjs} +25 -6
- package/dist/chunk-RCM4NAAG.mjs.map +1 -0
- package/dist/{chunk-ZX4OOCML.mjs → chunk-XNBD5NVL.mjs} +32 -31
- package/dist/chunk-XNBD5NVL.mjs.map +1 -0
- package/dist/{chunk-HUT3PFKF.mjs → chunk-ZOSNASXB.mjs} +1 -1
- package/dist/chunk-ZOSNASXB.mjs.map +1 -0
- package/dist/errors.d.ts +2 -2
- package/dist/errors.mjs +1 -1
- package/dist/{errors-B0uouRzR.d.ts → fiscal-evidence-DBzakqBE.d.ts} +77 -77
- package/dist/{index-CVpygFb0.d.ts → index-CVGQyyYM.d.ts} +1 -1
- package/dist/index.d.ts +57 -22
- package/dist/index.mjs +672 -61
- package/dist/index.mjs.map +1 -1
- package/dist/padron.d.ts +2 -2
- package/dist/padron.mjs +2 -2
- package/dist/{types-BXq0da71.d.ts → types-BiznC1-X.d.ts} +12 -1
- package/dist/types.d.ts +1 -1
- package/dist/{wsfe-CG_erq7V.d.ts → wsfe-DF0jAE2k.d.ts} +18 -7
- package/dist/wsfe.d.ts +4 -4
- package/dist/wsfe.mjs +3 -3
- package/dist/wsmtxca.d.ts +14 -5
- package/dist/wsmtxca.mjs +3 -3
- package/package.json +1 -1
- package/dist/chunk-HUT3PFKF.mjs.map +0 -1
- package/dist/chunk-TOVSOJ3G.mjs.map +0 -1
- package/dist/chunk-ZX4OOCML.mjs.map +0 -1
- /package/dist/{chunk-PPYGVNFA.mjs.map → chunk-4QVFXT35.mjs.map} +0 -0
- /package/dist/{chunk-NUV5RZPZ.mjs.map → chunk-7LEKQ4P7.mjs.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internal/redaction.ts","../src/errors.ts"],"sourcesContent":["export const MAX_DIAGNOSTIC_PREVIEW_LENGTH = 4096;\n\nconst MAX_DIAGNOSTIC_SCALAR_LENGTH = 512;\nconst SENSITIVE_XML_ELEMENT_NAME = \"((?:[A-Za-z_][\\\\w.-]*:)?(?:Token|Sign))\";\nconst PAIRED_SENSITIVE_XML_ELEMENT = new RegExp(\n `<${SENSITIVE_XML_ELEMENT_NAME}\\\\b[^>]*>[\\\\s\\\\S]*?<\\\\/\\\\1\\\\s*>`,\n \"gi\"\n);\nconst SELF_CLOSING_SENSITIVE_XML_ELEMENT = new RegExp(\n `<${SENSITIVE_XML_ELEMENT_NAME}\\\\b[^>]*\\\\/\\\\s*>`,\n \"gi\"\n);\nconst UNTERMINATED_SENSITIVE_XML_ELEMENT = new RegExp(\n `<${SENSITIVE_XML_ELEMENT_NAME}\\\\b[^>]*>[^<]*`,\n \"gi\"\n);\n\nexport type ResponseBodyDiagnostic = {\n responseBodyLength: number;\n responseBodyPreview: string;\n};\n\nexport type SafeErrorDiagnostic = {\n errorName?: string;\n errorCode?: string;\n statusCode?: number;\n contentType?: string;\n responseBodyLength?: number;\n responseBodyPreview?: string;\n faultCode?: string;\n};\n\n/** Redacts credential-bearing XML elements and applies the global preview bound. */\nexport function redactDiagnosticPreview(\n value: string,\n requestedMaxLength = MAX_DIAGNOSTIC_PREVIEW_LENGTH\n): string {\n const maxLength = normalizePreviewLength(requestedMaxLength);\n\n return value\n .replace(\n PAIRED_SENSITIVE_XML_ELEMENT,\n (_match, tagName: string) => `<${tagName}>[REDACTED]</${tagName}>`\n )\n .replace(\n SELF_CLOSING_SENSITIVE_XML_ELEMENT,\n (_match, tagName: string) => `<${tagName}>[REDACTED]</${tagName}>`\n )\n .replace(\n UNTERMINATED_SENSITIVE_XML_ELEMENT,\n (_match, tagName: string) => `<${tagName}>[REDACTED]`\n )\n .slice(0, maxLength);\n}\n\n/** Produces the only response-body shape allowed in errors and logs. */\nexport function createResponseBodyDiagnostic(\n responseBody: string,\n requestedMaxLength = MAX_DIAGNOSTIC_PREVIEW_LENGTH\n): ResponseBodyDiagnostic {\n return {\n responseBodyLength: responseBody.length,\n responseBodyPreview: redactDiagnosticPreview(\n responseBody,\n requestedMaxLength\n ),\n };\n}\n\n/** Extracts a scalar allowlist from an error without exposing the error or cause. */\nexport function createSafeErrorDiagnostic(error: unknown): SafeErrorDiagnostic {\n if (!(error && typeof error === \"object\")) {\n return {};\n }\n\n const candidate = error as Record<string, unknown>;\n const diagnostic: SafeErrorDiagnostic = {};\n\n assignSafeString(diagnostic, \"errorName\", candidate.name);\n assignSafeString(diagnostic, \"errorCode\", candidate.code);\n assignSafeNumber(diagnostic, \"statusCode\", candidate.statusCode);\n assignSafeString(diagnostic, \"contentType\", candidate.contentType);\n assignSafeNumber(\n diagnostic,\n \"responseBodyLength\",\n candidate.responseBodyLength\n );\n if (typeof candidate.responseBodyPreview === \"string\") {\n diagnostic.responseBodyPreview = redactDiagnosticPreview(\n candidate.responseBodyPreview\n );\n }\n assignSafeString(diagnostic, \"faultCode\", candidate.faultCode);\n\n return diagnostic;\n}\n\nfunction normalizePreviewLength(requestedMaxLength: number): number {\n if (!Number.isFinite(requestedMaxLength)) {\n return MAX_DIAGNOSTIC_PREVIEW_LENGTH;\n }\n\n return Math.max(\n 0,\n Math.min(Math.trunc(requestedMaxLength), MAX_DIAGNOSTIC_PREVIEW_LENGTH)\n );\n}\n\nfunction assignSafeString<\n TKey extends \"errorName\" | \"errorCode\" | \"contentType\" | \"faultCode\",\n>(target: SafeErrorDiagnostic, key: TKey, value: unknown): void {\n if (typeof value === \"string\") {\n target[key] = redactDiagnosticPreview(value, MAX_DIAGNOSTIC_SCALAR_LENGTH);\n }\n}\n\nfunction assignSafeNumber<TKey extends \"statusCode\" | \"responseBodyLength\">(\n target: SafeErrorDiagnostic,\n key: TKey,\n value: unknown\n): void {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n target[key] = value;\n }\n}\n","import { redactDiagnosticPreview } from \"./internal/redaction\";\nimport type { ArcaServiceName } from \"./internal/types\";\nimport type {\n ArcaFiscalIssue,\n ArcaFiscalResultLevel,\n ArcaFiscalResults,\n} from \"./services/fiscal-evidence\";\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/** Stable routing codes for caller-provided input failures. */\nexport type ArcaInputErrorCode =\n | \"ARCA_INPUT_IDEMPOTENCY_MISMATCH\"\n | \"ARCA_INPUT_INVALID_DATE\"\n | \"ARCA_INPUT_INVALID_AMOUNT\"\n | \"ARCA_INPUT_AMOUNT_PRECISION\"\n | \"ARCA_INPUT_AMOUNT_MISMATCH\"\n | \"ARCA_INPUT_INVALID_EXCHANGE_RATE\"\n | \"ARCA_INPUT_INVALID_VALUE\"\n | \"ARCA_INPUT_MISSING_FIELD\"\n | \"ARCA_INPUT_RESERVED_FIELD\";\n\nexport type ArcaInputErrorOptions = ErrorOptions & {\n code: ArcaInputErrorCode;\n field?: string;\n expected?: string;\n};\n\n/** Thrown when caller-provided input data is missing or invalid. */\nexport class ArcaInputError extends ArcaError {\n declare readonly code: ArcaInputErrorCode;\n override readonly name: string = \"ArcaInputError\";\n readonly field?: string;\n readonly expected?: string;\n\n constructor(message: string, options: ArcaInputErrorOptions) {\n super(message, options.code, options);\n this.field = options.field;\n this.expected = options.expected;\n }\n}\n\n/** Stable reasons exposed for explicit ARCA authentication rejections. */\nexport type ArcaAuthenticationReason =\n | \"invalid_token\"\n | \"unauthorized_computer\"\n | \"missing_relationship\"\n | \"authentication_rejected\";\n\nexport type ArcaAuthenticationErrorOptions = ErrorOptions & {\n reason: ArcaAuthenticationReason;\n service: ArcaServiceName;\n operation: string;\n providerCode?: string | number;\n};\n\n/** Thrown when ARCA explicitly rejects credentials before an operation runs. */\nexport class ArcaAuthenticationError extends ArcaError {\n declare readonly code: \"ARCA_AUTHENTICATION_ERROR\";\n override readonly name: string = \"ArcaAuthenticationError\";\n readonly reason: ArcaAuthenticationReason;\n readonly service: ArcaServiceName;\n readonly operation: string;\n readonly providerCode?: string | number;\n\n constructor(message: string, options: ArcaAuthenticationErrorOptions) {\n super(\n redactDiagnosticPreview(message),\n \"ARCA_AUTHENTICATION_ERROR\",\n options\n );\n this.reason = options.reason;\n this.service = options.service;\n this.operation = options.operation;\n this.providerCode = normalizeProviderCode(options.providerCode);\n }\n}\n\n/** Narrows unknown failures to the explicit authentication error contract. */\nexport function isArcaAuthenticationError(\n error: unknown\n): error is ArcaAuthenticationError {\n return error instanceof ArcaAuthenticationError;\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 responseBodyLength?: number;\n readonly responseBodyPreview?: string;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n statusCode?: number;\n contentType?: string;\n responseBodyLength?: number;\n responseBodyPreview?: string;\n }\n ) {\n super(message, \"ARCA_TRANSPORT_ERROR\", options);\n this.statusCode = options?.statusCode;\n this.contentType = options?.contentType;\n this.responseBodyLength = options?.responseBodyLength;\n this.responseBodyPreview =\n options?.responseBodyPreview === undefined\n ? undefined\n : redactDiagnosticPreview(options.responseBodyPreview);\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\n constructor(\n message: string,\n options?: ErrorOptions & {\n faultCode?: string;\n }\n ) {\n super(redactDiagnosticPreview(message), \"ARCA_SOAP_FAULT\", options);\n this.faultCode =\n options?.faultCode === undefined\n ? undefined\n : redactDiagnosticPreview(options.faultCode);\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\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 }\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 =\n options?.responseBodyPreview === undefined\n ? undefined\n : redactDiagnosticPreview(options.responseBodyPreview);\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 service?: ArcaServiceName;\n readonly operation?: string;\n readonly result?: string;\n readonly resultLevel?: ArcaFiscalResultLevel;\n readonly results?: ArcaFiscalResults;\n readonly cae?: string;\n readonly issues?: readonly ArcaFiscalIssue[];\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n serviceCode?: string | number;\n service?: ArcaServiceName;\n operation?: string;\n result?: string;\n resultLevel?: ArcaFiscalResultLevel;\n results?: ArcaFiscalResults;\n cae?: string;\n issues?: readonly ArcaFiscalIssue[];\n }\n ) {\n super(message, \"ARCA_SERVICE_ERROR\", options);\n this.serviceCode = options?.serviceCode;\n this.service = options?.service;\n this.operation = options?.operation;\n this.result = options?.result;\n this.resultLevel = options?.resultLevel;\n this.results = options?.results;\n this.cae = options?.cae;\n this.issues = options?.issues;\n }\n}\n\nfunction normalizeProviderCode(\n providerCode: string | number | undefined\n): string | number | undefined {\n if (typeof providerCode === \"number\") {\n return Number.isFinite(providerCode) ? providerCode : undefined;\n }\n if (typeof providerCode === \"string\") {\n return redactDiagnosticPreview(providerCode, 512);\n }\n return undefined;\n}\n\n/** Narrow error evidence: never includes a cause, raw response or stack. */\nexport type ArcaSafeErrorMetadata = {\n name: string;\n message: string;\n code?: string;\n statusCode?: number;\n};\n\nexport function toArcaSafeErrorMetadata(error: unknown): ArcaSafeErrorMetadata {\n if (!(error instanceof Error)) {\n return { name: \"UnknownError\", message: String(error) };\n }\n return {\n name: error.name,\n message: error.message,\n ...(error instanceof ArcaError ? { code: error.code } : {}),\n ...(error instanceof ArcaTransportError && error.statusCode !== undefined\n ? { statusCode: error.statusCode }\n : {}),\n };\n}\n"],"mappings":";AAAO,IAAM,gCAAgC;AAE7C,IAAM,+BAA+B;AACrC,IAAM,6BAA6B;AACnC,IAAM,+BAA+B,IAAI;AAAA,EACvC,IAAI,0BAA0B;AAAA,EAC9B;AACF;AACA,IAAM,qCAAqC,IAAI;AAAA,EAC7C,IAAI,0BAA0B;AAAA,EAC9B;AACF;AACA,IAAM,qCAAqC,IAAI;AAAA,EAC7C,IAAI,0BAA0B;AAAA,EAC9B;AACF;AAkBO,SAAS,wBACd,OACA,qBAAqB,+BACb;AACR,QAAM,YAAY,uBAAuB,kBAAkB;AAE3D,SAAO,MACJ;AAAA,IACC;AAAA,IACA,CAAC,QAAQ,YAAoB,IAAI,OAAO,gBAAgB,OAAO;AAAA,EACjE,EACC;AAAA,IACC;AAAA,IACA,CAAC,QAAQ,YAAoB,IAAI,OAAO,gBAAgB,OAAO;AAAA,EACjE,EACC;AAAA,IACC;AA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AAC7E,MAAI,EAAE,iBAAiB,QAAQ;AAC7B,WAAO,EAAE,MAAM,gBAAgB,SAAS,OAAO,KAAK,EAAE;AAAA,EACxD;AACA,SAAO;AAAA,IACL,MAAM,MAAM;AAAA,IACZ,SAAS,MAAM;AAAA,IACf,GAAI,iBAAiB,YAAY,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;AAAA,IACzD,GAAI,iBAAiB,sBAAsB,MAAM,eAAe,SAC5D,EAAE,YAAY,MAAM,WAAW,IAC/B,CAAC;AAAA,EACP;AACF;","names":[]}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './types-
|
|
2
|
-
export { c as ArcaAuthenticationError, d as ArcaAuthenticationErrorOptions, f as ArcaAuthenticationReason, h as ArcaConfigurationError, i as ArcaError, m as ArcaInputError, n as ArcaInputErrorCode, o as ArcaInputErrorOptions, p as ArcaInvalidSoapResponseError, b as ArcaSafeErrorMetadata, q as ArcaServiceError, r as ArcaSoapFaultError, s as ArcaTransportError, u as isArcaAuthenticationError, v as toArcaSafeErrorMetadata } from './
|
|
1
|
+
import './types-BiznC1-X.js';
|
|
2
|
+
export { c as ArcaAuthenticationError, d as ArcaAuthenticationErrorOptions, f as ArcaAuthenticationReason, h as ArcaConfigurationError, i as ArcaError, m as ArcaInputError, n as ArcaInputErrorCode, o as ArcaInputErrorOptions, p as ArcaInvalidSoapResponseError, b as ArcaSafeErrorMetadata, q as ArcaServiceError, r as ArcaSoapFaultError, s as ArcaTransportError, u as isArcaAuthenticationError, v as toArcaSafeErrorMetadata } from './fiscal-evidence-DBzakqBE.js';
|
package/dist/errors.mjs
CHANGED
|
@@ -1,79 +1,4 @@
|
|
|
1
|
-
import { A as ArcaServiceName } from './types-
|
|
2
|
-
|
|
3
|
-
/** ARCA services that authorize fiscal vouchers. */
|
|
4
|
-
type ArcaFiscalService = "wsfe" | "wsmtxca";
|
|
5
|
-
/** Location of a structured authorization result in the service response. */
|
|
6
|
-
type ArcaFiscalResultLevel = "header" | "detail" | "operation";
|
|
7
|
-
/** Every structured result field exposed by one provider response. */
|
|
8
|
-
type ArcaFiscalResults = {
|
|
9
|
-
header?: string;
|
|
10
|
-
detail?: string;
|
|
11
|
-
operation?: string;
|
|
12
|
-
};
|
|
13
|
-
/** Source and meaning of one provider issue. */
|
|
14
|
-
type ArcaFiscalIssue = {
|
|
15
|
-
service: ArcaFiscalService;
|
|
16
|
-
operation: string;
|
|
17
|
-
source: "error" | "observation";
|
|
18
|
-
category: "business" | "infrastructure" | "observation" | "unknown";
|
|
19
|
-
code?: string;
|
|
20
|
-
message: string;
|
|
21
|
-
resultLevel?: ArcaFiscalResultLevel;
|
|
22
|
-
};
|
|
23
|
-
/** Why an authorization response cannot prove approval or rejection. */
|
|
24
|
-
type ArcaAuthorizationIndeterminateReason = "authentication_rejected" | "transport_error" | "soap_fault" | "invalid_response" | "incomplete_response" | "contradictory_response" | "unexpected_error";
|
|
25
|
-
/** Safe authentication evidence attached to an exact authorization outcome. */
|
|
26
|
-
type ArcaAuthenticationEvidence = {
|
|
27
|
-
code: "ARCA_AUTHENTICATION_ERROR";
|
|
28
|
-
reason: ArcaAuthenticationReason;
|
|
29
|
-
providerCode?: string | number;
|
|
30
|
-
};
|
|
31
|
-
type ArcaAuthorizationEvidenceBase<TService extends ArcaFiscalService = ArcaFiscalService> = {
|
|
32
|
-
service: TService;
|
|
33
|
-
operation: string;
|
|
34
|
-
results: ArcaFiscalResults;
|
|
35
|
-
errors: ArcaFiscalIssue[];
|
|
36
|
-
observations: ArcaFiscalIssue[];
|
|
37
|
-
raw?: Record<string, unknown>;
|
|
38
|
-
};
|
|
39
|
-
/** Structured evidence returned by one exact voucher authorization attempt. */
|
|
40
|
-
type ArcaAuthorizationOutcome<TService extends ArcaFiscalService = ArcaFiscalService> = (ArcaAuthorizationEvidenceBase<TService> & {
|
|
41
|
-
kind: "authorized";
|
|
42
|
-
result: "A" | "O";
|
|
43
|
-
resultLevel: ArcaFiscalResultLevel;
|
|
44
|
-
cae: string;
|
|
45
|
-
caeExpiry?: string;
|
|
46
|
-
voucherNumber: number;
|
|
47
|
-
}) | (ArcaAuthorizationEvidenceBase<TService> & {
|
|
48
|
-
kind: "rejected";
|
|
49
|
-
result: "R";
|
|
50
|
-
resultLevel: ArcaFiscalResultLevel;
|
|
51
|
-
}) | (ArcaAuthorizationEvidenceBase<TService> & {
|
|
52
|
-
kind: "indeterminate";
|
|
53
|
-
reason: ArcaAuthorizationIndeterminateReason;
|
|
54
|
-
authentication?: ArcaAuthenticationEvidence;
|
|
55
|
-
result?: string;
|
|
56
|
-
resultLevel?: ArcaFiscalResultLevel;
|
|
57
|
-
cae?: string;
|
|
58
|
-
caeExpiry?: string;
|
|
59
|
-
voucherNumber?: number;
|
|
60
|
-
});
|
|
61
|
-
/** Structured result of consulting one exact voucher number. */
|
|
62
|
-
type ArcaVoucherLookupResult<TVoucher, TService extends ArcaFiscalService = ArcaFiscalService> = {
|
|
63
|
-
kind: "found";
|
|
64
|
-
service: TService;
|
|
65
|
-
operation: string;
|
|
66
|
-
voucher: TVoucher;
|
|
67
|
-
observations: ArcaFiscalIssue[];
|
|
68
|
-
raw: Record<string, unknown>;
|
|
69
|
-
} | {
|
|
70
|
-
kind: "not_found";
|
|
71
|
-
service: TService;
|
|
72
|
-
operation: string;
|
|
73
|
-
errors: ArcaFiscalIssue[];
|
|
74
|
-
observations: ArcaFiscalIssue[];
|
|
75
|
-
raw: Record<string, unknown>;
|
|
76
|
-
};
|
|
1
|
+
import { A as ArcaServiceName } from './types-BiznC1-X.js';
|
|
77
2
|
|
|
78
3
|
/** Base error class for all ARCA-related errors. */
|
|
79
4
|
declare class ArcaError extends Error {
|
|
@@ -87,7 +12,7 @@ declare class ArcaConfigurationError extends ArcaError {
|
|
|
87
12
|
constructor(message: string, options?: ErrorOptions);
|
|
88
13
|
}
|
|
89
14
|
/** Stable routing codes for caller-provided input failures. */
|
|
90
|
-
type ArcaInputErrorCode = "ARCA_INPUT_INVALID_DATE" | "ARCA_INPUT_INVALID_AMOUNT" | "ARCA_INPUT_AMOUNT_PRECISION" | "ARCA_INPUT_AMOUNT_MISMATCH" | "ARCA_INPUT_INVALID_EXCHANGE_RATE" | "ARCA_INPUT_INVALID_VALUE" | "ARCA_INPUT_MISSING_FIELD" | "ARCA_INPUT_RESERVED_FIELD";
|
|
15
|
+
type ArcaInputErrorCode = "ARCA_INPUT_IDEMPOTENCY_MISMATCH" | "ARCA_INPUT_INVALID_DATE" | "ARCA_INPUT_INVALID_AMOUNT" | "ARCA_INPUT_AMOUNT_PRECISION" | "ARCA_INPUT_AMOUNT_MISMATCH" | "ARCA_INPUT_INVALID_EXCHANGE_RATE" | "ARCA_INPUT_INVALID_VALUE" | "ARCA_INPUT_MISSING_FIELD" | "ARCA_INPUT_RESERVED_FIELD";
|
|
91
16
|
type ArcaInputErrorOptions = ErrorOptions & {
|
|
92
17
|
code: ArcaInputErrorCode;
|
|
93
18
|
field?: string;
|
|
@@ -194,4 +119,79 @@ type ArcaSafeErrorMetadata = {
|
|
|
194
119
|
};
|
|
195
120
|
declare function toArcaSafeErrorMetadata(error: unknown): ArcaSafeErrorMetadata;
|
|
196
121
|
|
|
122
|
+
/** ARCA services that authorize fiscal vouchers. */
|
|
123
|
+
type ArcaFiscalService = "wsfe" | "wsmtxca";
|
|
124
|
+
/** Location of a structured authorization result in the service response. */
|
|
125
|
+
type ArcaFiscalResultLevel = "header" | "detail" | "operation";
|
|
126
|
+
/** Every structured result field exposed by one provider response. */
|
|
127
|
+
type ArcaFiscalResults = {
|
|
128
|
+
header?: string;
|
|
129
|
+
detail?: string;
|
|
130
|
+
operation?: string;
|
|
131
|
+
};
|
|
132
|
+
/** Source and meaning of one provider issue. */
|
|
133
|
+
type ArcaFiscalIssue = {
|
|
134
|
+
service: ArcaFiscalService;
|
|
135
|
+
operation: string;
|
|
136
|
+
source: "error" | "observation";
|
|
137
|
+
category: "business" | "infrastructure" | "observation" | "unknown";
|
|
138
|
+
code?: string;
|
|
139
|
+
message: string;
|
|
140
|
+
resultLevel?: ArcaFiscalResultLevel;
|
|
141
|
+
};
|
|
142
|
+
/** Why an authorization response cannot prove approval or rejection. */
|
|
143
|
+
type ArcaAuthorizationIndeterminateReason = "authentication_rejected" | "transport_error" | "soap_fault" | "invalid_response" | "incomplete_response" | "contradictory_response" | "unexpected_error";
|
|
144
|
+
/** Safe authentication evidence attached to an exact authorization outcome. */
|
|
145
|
+
type ArcaAuthenticationEvidence = {
|
|
146
|
+
code: "ARCA_AUTHENTICATION_ERROR";
|
|
147
|
+
reason: ArcaAuthenticationReason;
|
|
148
|
+
providerCode?: string | number;
|
|
149
|
+
};
|
|
150
|
+
type ArcaAuthorizationEvidenceBase<TService extends ArcaFiscalService = ArcaFiscalService> = {
|
|
151
|
+
service: TService;
|
|
152
|
+
operation: string;
|
|
153
|
+
results: ArcaFiscalResults;
|
|
154
|
+
errors: ArcaFiscalIssue[];
|
|
155
|
+
observations: ArcaFiscalIssue[];
|
|
156
|
+
raw?: Record<string, unknown>;
|
|
157
|
+
};
|
|
158
|
+
/** Structured evidence returned by one exact voucher authorization attempt. */
|
|
159
|
+
type ArcaAuthorizationOutcome<TService extends ArcaFiscalService = ArcaFiscalService> = (ArcaAuthorizationEvidenceBase<TService> & {
|
|
160
|
+
kind: "authorized";
|
|
161
|
+
result: "A" | "O";
|
|
162
|
+
resultLevel: ArcaFiscalResultLevel;
|
|
163
|
+
cae: string;
|
|
164
|
+
caeExpiry?: string;
|
|
165
|
+
voucherNumber: number;
|
|
166
|
+
}) | (ArcaAuthorizationEvidenceBase<TService> & {
|
|
167
|
+
kind: "rejected";
|
|
168
|
+
result: "R";
|
|
169
|
+
resultLevel: ArcaFiscalResultLevel;
|
|
170
|
+
}) | (ArcaAuthorizationEvidenceBase<TService> & {
|
|
171
|
+
kind: "indeterminate";
|
|
172
|
+
reason: ArcaAuthorizationIndeterminateReason;
|
|
173
|
+
authentication?: ArcaAuthenticationEvidence;
|
|
174
|
+
result?: string;
|
|
175
|
+
resultLevel?: ArcaFiscalResultLevel;
|
|
176
|
+
cae?: string;
|
|
177
|
+
caeExpiry?: string;
|
|
178
|
+
voucherNumber?: number;
|
|
179
|
+
});
|
|
180
|
+
/** Structured result of consulting one exact voucher number. */
|
|
181
|
+
type ArcaVoucherLookupResult<TVoucher, TService extends ArcaFiscalService = ArcaFiscalService> = {
|
|
182
|
+
kind: "found";
|
|
183
|
+
service: TService;
|
|
184
|
+
operation: string;
|
|
185
|
+
voucher: TVoucher;
|
|
186
|
+
observations: ArcaFiscalIssue[];
|
|
187
|
+
raw: Record<string, unknown>;
|
|
188
|
+
} | {
|
|
189
|
+
kind: "not_found";
|
|
190
|
+
service: TService;
|
|
191
|
+
operation: string;
|
|
192
|
+
errors: ArcaFiscalIssue[];
|
|
193
|
+
observations: ArcaFiscalIssue[];
|
|
194
|
+
raw: Record<string, unknown>;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
197
|
export { type ArcaAuthorizationOutcome as A, type ArcaFiscalIssue as a, type ArcaSafeErrorMetadata as b, ArcaAuthenticationError as c, type ArcaAuthenticationErrorOptions as d, type ArcaAuthenticationEvidence as e, type ArcaAuthenticationReason as f, type ArcaAuthorizationIndeterminateReason as g, ArcaConfigurationError as h, ArcaError as i, type ArcaFiscalResultLevel as j, type ArcaFiscalResults as k, type ArcaFiscalService as l, ArcaInputError as m, type ArcaInputErrorCode as n, type ArcaInputErrorOptions as o, ArcaInvalidSoapResponseError as p, ArcaServiceError as q, ArcaSoapFaultError as r, ArcaTransportError as s, type ArcaVoucherLookupResult as t, isArcaAuthenticationError as u, toArcaSafeErrorMetadata as v };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ArcaSoapExecutionOptions, b as ArcaSoapResponse, c as ArcaWsaaServiceId, d as ArcaAuthOptions, e as ArcaAuthCredentials } from './types-
|
|
1
|
+
import { a as ArcaSoapExecutionOptions, b as ArcaSoapResponse, c as ArcaWsaaServiceId, d as ArcaAuthOptions, e as ArcaAuthCredentials } from './types-BiznC1-X.js';
|
|
2
2
|
|
|
3
3
|
type SoapTransport = {
|
|
4
4
|
execute<TBody, TResult>(request: ArcaSoapExecutionOptions<TBody>): Promise<ArcaSoapResponse<TResult>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { f as ArcaEnvironment, g as
|
|
2
|
-
export { e as ArcaAuthCredentials, d as ArcaAuthOptions,
|
|
1
|
+
import { f as ArcaEnvironment, g as ArcaClientOptions, h as ArcaClientConfig, i as ArcaStore, j as ArcaWsaaSessionStore } from './types-BiznC1-X.js';
|
|
2
|
+
export { e as ArcaAuthCredentials, d as ArcaAuthOptions, k as ArcaLogLevel, l as ArcaLoggerConfig, m as ArcaPadronServiceName, n as ArcaRepresentedTaxId, A as ArcaServiceName, o as ArcaServiceTarget, c as ArcaWsaaServiceId, p as ArcaWsaaSessionKey } from './types-BiznC1-X.js';
|
|
3
3
|
import { PadronService } from './padron.js';
|
|
4
4
|
export { CreatePadronServiceOptions, PadronTaxIdLookupResult, PadronTaxpayerResult, createPadronService } from './padron.js';
|
|
5
|
+
import { S as SupportedVatRate, W as WsfeVoucherInput, a as WsfeVoucherInfo, b as WsfeDateInput, c as WsfeService } from './wsfe-DF0jAE2k.js';
|
|
6
|
+
export { B as BuildFacturaBInput, d as BuildFacturaCInput, C as CreateWsfeServiceOptions, e as WsfeActivity, f as WsfeActivityType, g as WsfeAssociatedPeriod, h as WsfeAssociatedVoucher, i as WsfeAuthorizationOutcome, j as WsfeAuthorizationResult, k as WsfeAuthorizeVoucherInput, l as WsfeBuilderCurrencyInput, m as WsfeBuilderVatRate, n as WsfeBuyer, o as WsfeCatalogEntry, p as WsfeCurrencyType, q as WsfeOptionalField, r as WsfeQuotation, s as WsfeReceiverVatCondition, t as WsfeSalesPoint, u as WsfeServerStatus, v as WsfeTax, w as WsfeVatRate, x as WsfeVoucherLookupResult, y as buildFacturaB, z as buildFacturaC, A as createWsfeService } from './wsfe-DF0jAE2k.js';
|
|
5
7
|
import { VoucherClass, ReceiverCondition } from './constants.js';
|
|
6
8
|
export { ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS, ARCA_INVOICE_CLASS_BY_ISSUER, ARCA_ISSUER_CONDITION_IDS, ARCA_RECEIVER_CONDITION_IDS, IssuerCondition } from './constants.js';
|
|
7
|
-
import { A as ArcaAuthorizationOutcome, a as ArcaFiscalIssue, b as ArcaSafeErrorMetadata } from './
|
|
8
|
-
export { c as ArcaAuthenticationError, d as ArcaAuthenticationErrorOptions, e as ArcaAuthenticationEvidence, f as ArcaAuthenticationReason, g as ArcaAuthorizationIndeterminateReason, h as ArcaConfigurationError, i as ArcaError, j as ArcaFiscalResultLevel, k as ArcaFiscalResults, l as ArcaFiscalService, m as ArcaInputError, n as ArcaInputErrorCode, o as ArcaInputErrorOptions, p as ArcaInvalidSoapResponseError, q as ArcaServiceError, r as ArcaSoapFaultError, s as ArcaTransportError, t as ArcaVoucherLookupResult, u as isArcaAuthenticationError, v as toArcaSafeErrorMetadata } from './
|
|
9
|
-
import { S as SupportedVatRate, W as WsfeVoucherInput, a as WsfeVoucherInfo, b as WsfeDateInput, c as WsfeService } from './wsfe-CG_erq7V.js';
|
|
10
|
-
export { B as BuildFacturaBInput, d as BuildFacturaCInput, C as CreateWsfeServiceOptions, e as WsfeActivity, f as WsfeActivityType, g as WsfeAssociatedPeriod, h as WsfeAssociatedVoucher, i as WsfeAuthorizationOutcome, j as WsfeAuthorizationResult, k as WsfeAuthorizeVoucherInput, l as WsfeBuilderCurrencyInput, m as WsfeBuilderVatRate, n as WsfeBuyer, o as WsfeCatalogEntry, p as WsfeCurrencyType, q as WsfeOptionalField, r as WsfeQuotation, s as WsfeReceiverVatCondition, t as WsfeSalesPoint, u as WsfeServerStatus, v as WsfeTax, w as WsfeVatRate, x as WsfeVoucherLookupResult, y as buildFacturaB, z as buildFacturaC, A as createWsfeService } from './wsfe-CG_erq7V.js';
|
|
9
|
+
import { A as ArcaAuthorizationOutcome, a as ArcaFiscalIssue, b as ArcaSafeErrorMetadata } from './fiscal-evidence-DBzakqBE.js';
|
|
10
|
+
export { c as ArcaAuthenticationError, d as ArcaAuthenticationErrorOptions, e as ArcaAuthenticationEvidence, f as ArcaAuthenticationReason, g as ArcaAuthorizationIndeterminateReason, h as ArcaConfigurationError, i as ArcaError, j as ArcaFiscalResultLevel, k as ArcaFiscalResults, l as ArcaFiscalService, m as ArcaInputError, n as ArcaInputErrorCode, o as ArcaInputErrorOptions, p as ArcaInvalidSoapResponseError, q as ArcaServiceError, r as ArcaSoapFaultError, s as ArcaTransportError, t as ArcaVoucherLookupResult, u as isArcaAuthenticationError, v as toArcaSafeErrorMetadata } from './fiscal-evidence-DBzakqBE.js';
|
|
11
11
|
import { WsmtxcaService } from './wsmtxca.js';
|
|
12
12
|
export { CreateWsmtxcaServiceOptions, WsmtxcaAuthorizationOutcome, WsmtxcaAuthorizationResult, WsmtxcaAuthorizeVoucherInput, WsmtxcaLastAuthorizedVoucherResult, WsmtxcaSalesPoint, WsmtxcaSalesPointsResult, WsmtxcaVoucherInfo, WsmtxcaVoucherLookupOutcome, WsmtxcaVoucherLookupResult, createWsmtxcaService } from './wsmtxca.js';
|
|
13
|
-
import './index-
|
|
13
|
+
import './index-CVGQyyYM.js';
|
|
14
14
|
|
|
15
15
|
type VatRate = SupportedVatRate | "exempt" | "untaxed";
|
|
16
16
|
type VatItem = {
|
|
@@ -79,13 +79,14 @@ type WsfeIdentityMatch = {
|
|
|
79
79
|
reason: string;
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
82
|
-
* Compares the invoice subset supported by
|
|
83
|
-
* consistency, not authorship
|
|
84
|
-
*
|
|
82
|
+
* Compares the invoice subset supported by issue(). This proves
|
|
83
|
+
* consistency, not authorship. Configure a store and pass idempotencyKey for retries.
|
|
84
|
+
* Unsupported exact-API extensions are incomplete.
|
|
85
85
|
*/
|
|
86
86
|
declare function matchWsfeVoucherIdentity(sent: WsfeVoucherInput, number: number, found: WsfeVoucherInfo): WsfeIdentityMatch;
|
|
87
87
|
|
|
88
88
|
type IssueOptions = {
|
|
89
|
+
idempotencyKey?: string;
|
|
89
90
|
representedTaxId?: number | string;
|
|
90
91
|
forceRefresh?: boolean;
|
|
91
92
|
include?: {
|
|
@@ -115,7 +116,7 @@ type WithSent<O extends IssueOptions> = O extends {
|
|
|
115
116
|
type Evidence<K extends ArcaAuthorizationOutcome<"wsfe">["kind"], O extends IssueOptions> = WithRaw<Omit<Extract<ArcaAuthorizationOutcome<"wsfe">, {
|
|
116
117
|
kind: K;
|
|
117
118
|
}>, "raw">, O>;
|
|
118
|
-
/** Fiscal outcomes are returned
|
|
119
|
+
/** Fiscal outcomes are returned. Keyed replays authorize only after not_found. */
|
|
119
120
|
type IssueOutcome<O extends IssueOptions = {
|
|
120
121
|
include?: never;
|
|
121
122
|
}> = ({
|
|
@@ -186,15 +187,17 @@ type IssueInput = IssueCommon & ({
|
|
|
186
187
|
});
|
|
187
188
|
|
|
188
189
|
type VouchersService = {
|
|
190
|
+
/** Creates a full credit note associated to an authorized A, B or C invoice. */
|
|
191
|
+
cancel<O extends IssueOptions & {
|
|
192
|
+
date?: WsfeDateInput;
|
|
193
|
+
} = {
|
|
194
|
+
include?: never;
|
|
195
|
+
}>(target: VoucherCoordinates, options?: O): Promise<IssueOutcome<O>>;
|
|
189
196
|
/**
|
|
190
|
-
*
|
|
191
|
-
* voucherType), including concurrent promises in one process. The SDK does not
|
|
192
|
-
* coordinate writers; uncoordinated calls collide on ARCA 10016. Servers and
|
|
193
|
-
* queues must persist attempts and use wsfe.authorizeVoucherOutcome() directly.
|
|
194
|
-
* See the "does not serialize concurrent calls" test in services/vouchers.test.ts.
|
|
197
|
+
* Configure a store and pass idempotencyKey to recover retries after a crash.
|
|
195
198
|
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
199
|
+
* Without a key: one next-number read, one authorization and at most one lookup.
|
|
200
|
+
* Keyed replay consults the reserved number; only not_found permits a write.
|
|
198
201
|
* Local validation and next-number read failures throw before authorization.
|
|
199
202
|
*/
|
|
200
203
|
issue<O extends IssueOptions = {
|
|
@@ -213,19 +216,22 @@ type ArcaClientConfigView = Readonly<{
|
|
|
213
216
|
/** Fully wired ARCA client with access to all service modules. */
|
|
214
217
|
type ArcaClient = {
|
|
215
218
|
readonly config: ArcaClientConfigView;
|
|
219
|
+
/** Issues an invoice from business input. Idempotent with a store and key. */
|
|
220
|
+
issue: VouchersService["issue"];
|
|
221
|
+
/** Issues a full credit note against an authorized invoice. */
|
|
222
|
+
cancel: VouchersService["cancel"];
|
|
216
223
|
wsfe: WsfeService;
|
|
217
|
-
vouchers: VouchersService;
|
|
218
224
|
wsmtxca: WsmtxcaService;
|
|
219
225
|
padron: PadronService;
|
|
220
226
|
};
|
|
221
227
|
/**
|
|
222
228
|
* Creates an ARCA client from the given configuration.
|
|
223
229
|
* Validates the config, wires WSAA authentication and SOAP transport,
|
|
224
|
-
* and returns an object with
|
|
230
|
+
* and returns an object with `issue()`, `cancel()` and the `.wsfe`, `.wsmtxca`, and `.padron` service modules.
|
|
225
231
|
*
|
|
226
232
|
* @throws {ArcaConfigurationError} When the config is missing or invalid.
|
|
227
233
|
*/
|
|
228
|
-
declare function createArcaClient(config
|
|
234
|
+
declare function createArcaClient(config?: ArcaClientOptions): ArcaClient;
|
|
229
235
|
|
|
230
236
|
/** Valid ARCA environment names. */
|
|
231
237
|
declare const ARCA_ENVIRONMENTS: readonly ["production", "test"];
|
|
@@ -259,6 +265,35 @@ declare function createArcaClientConfigFromEnv(options?: CreateArcaClientConfigF
|
|
|
259
265
|
*/
|
|
260
266
|
declare function assertArcaClientConfig(config: ArcaClientConfig): void;
|
|
261
267
|
|
|
268
|
+
/** Persistent store for a single server with a private durable volume. */
|
|
269
|
+
declare function createFileStore(directory: string): ArcaStore;
|
|
270
|
+
|
|
271
|
+
/** In-process store for tests; reservations do not survive a restart. */
|
|
272
|
+
declare function createMemoryStore(): ArcaStore;
|
|
273
|
+
|
|
274
|
+
type Row = {
|
|
275
|
+
key?: string;
|
|
276
|
+
value?: string;
|
|
277
|
+
};
|
|
278
|
+
/** Uses the caller's SQL client; provision the table before use. */
|
|
279
|
+
declare function createPostgresStore({ query, table, }: {
|
|
280
|
+
query: (text: string, params: string[]) => Promise<Row[] | {
|
|
281
|
+
rows: Row[];
|
|
282
|
+
}>;
|
|
283
|
+
table?: string;
|
|
284
|
+
}): ArcaStore;
|
|
285
|
+
|
|
286
|
+
type RedisClient = {
|
|
287
|
+
get(key: string): Promise<unknown>;
|
|
288
|
+
set(key: string, value: string): Promise<unknown>;
|
|
289
|
+
call?(...args: string[]): Promise<unknown>;
|
|
290
|
+
del?(key: string): Promise<unknown>;
|
|
291
|
+
};
|
|
292
|
+
/** Uses ioredis or Upstash without importing either driver. */
|
|
293
|
+
declare function createRedisStore(client: RedisClient, options?: {
|
|
294
|
+
flavor?: "ioredis" | "upstash";
|
|
295
|
+
}): ArcaStore;
|
|
296
|
+
|
|
262
297
|
declare function createMemoryWsaaSessionStore(): ArcaWsaaSessionStore;
|
|
263
298
|
|
|
264
|
-
export { ARCA_ENVIRONMENTS, ARCA_ENV_VARIABLES, type AmountItem, ArcaAuthorizationOutcome, type ArcaClient, ArcaClientConfig, type ArcaClientConfigView, ArcaEnvironment, ArcaFiscalIssue, ArcaSafeErrorMetadata, ArcaWsaaSessionStore, type CreateArcaClientConfigFromEnvOptions, type IssueAmounts, type IssueCommon, type IssueInput, type IssueOptions, type IssueOutcome, type IssuedVoucher, PadronService, type Receiver, ReceiverCondition, type VatItem, type VatRate, VoucherClass, type VoucherCoordinates, type VoucherSummary, type VouchersService, WsfeDateInput, type WsfeIdentityMatch, WsfeService, WsfeVoucherInfo, WsfeVoucherInput, WsmtxcaService, assertArcaClientConfig, createArcaClient, createArcaClientConfigFromEnv, createMemoryWsaaSessionStore, matchWsfeVoucherIdentity, resolveArcaEnvironment };
|
|
299
|
+
export { ARCA_ENVIRONMENTS, ARCA_ENV_VARIABLES, type AmountItem, ArcaAuthorizationOutcome, type ArcaClient, ArcaClientOptions as ArcaClientConfig, type ArcaClientConfigView, ArcaEnvironment, ArcaFiscalIssue, ArcaSafeErrorMetadata, ArcaStore, ArcaWsaaSessionStore, type CreateArcaClientConfigFromEnvOptions, type IssueAmounts, type IssueCommon, type IssueInput, type IssueOptions, type IssueOutcome, type IssuedVoucher, PadronService, type Receiver, ReceiverCondition, type VatItem, type VatRate, VoucherClass, type VoucherCoordinates, type VoucherSummary, type VouchersService, WsfeDateInput, type WsfeIdentityMatch, WsfeService, WsfeVoucherInfo, WsfeVoucherInput, WsmtxcaService, assertArcaClientConfig, createArcaClient, createArcaClientConfigFromEnv, createFileStore, createMemoryStore, createMemoryWsaaSessionStore, createPostgresStore, createRedisStore, matchWsfeVoucherIdentity, resolveArcaEnvironment };
|