facturas 0.14.0 → 0.16.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 +4 -2
- package/dist/{chunk-65C5ZQOB.mjs → chunk-5O2FESHA.mjs} +493 -103
- package/dist/chunk-5O2FESHA.mjs.map +1 -0
- package/dist/{chunk-LQMNKQ2V.mjs → chunk-DHN6OQJP.mjs} +1 -6
- package/dist/chunk-DHN6OQJP.mjs.map +1 -0
- package/dist/{chunk-WVKVJTFG.mjs → chunk-EXECWJEC.mjs} +80 -3
- package/dist/chunk-EXECWJEC.mjs.map +1 -0
- package/dist/{chunk-BPBTQDCO.mjs → chunk-VJ2ICMSA.mjs} +1 -4
- package/dist/chunk-VJ2ICMSA.mjs.map +1 -0
- package/dist/cli.d.ts +2 -2
- package/dist/cli.mjs +7 -7
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-bblLZeUb.d.ts → client-C7lhfLGY.d.ts} +42 -4
- package/dist/constants.d.ts +1 -9
- package/dist/constants.mjs +1 -3
- package/dist/index.d.ts +49 -3
- package/dist/index.mjs +10 -4
- package/dist/index.mjs.map +1 -1
- package/dist/padron.d.ts +19 -1
- package/dist/padron.mjs +1 -1
- package/dist/wsfe.d.ts +0 -10
- package/dist/wsfe.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-65C5ZQOB.mjs.map +0 -1
- package/dist/chunk-BPBTQDCO.mjs.map +0 -1
- package/dist/chunk-LQMNKQ2V.mjs.map +0 -1
- package/dist/chunk-WVKVJTFG.mjs.map +0 -1
|
@@ -10,7 +10,10 @@ type VoucherCoordinates = {
|
|
|
10
10
|
voucherType: number;
|
|
11
11
|
number: number;
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Raw-free consultation evidence in the facade's units: money in minor units,
|
|
15
|
+
* dates in `YYYY-MM-DD`. A field ARCA omits or reports unparseably is absent.
|
|
16
|
+
*/
|
|
14
17
|
type VoucherSummary = {
|
|
15
18
|
number: number;
|
|
16
19
|
salesPoint?: number;
|
|
@@ -79,7 +82,7 @@ type LegacyWsmtxcaLine = Omit<WsmtxcaLine, "discount"> & {
|
|
|
79
82
|
discount?: number;
|
|
80
83
|
};
|
|
81
84
|
type WsmtxcaIssueRequest = ReturnType<typeof wsmtxcaRequest>;
|
|
82
|
-
type FiscalHeader = WsfeVoucherInput & {
|
|
85
|
+
type FiscalHeader$1 = WsfeVoucherInput & {
|
|
83
86
|
/** Derived provider lines. WSFE never reads them; WSMTXCA sends them. */
|
|
84
87
|
lines?: readonly WsmtxcaLine[];
|
|
85
88
|
/** @internal Lines mirrored from an authorized WSMTXCA consultation. */
|
|
@@ -87,7 +90,7 @@ type FiscalHeader = WsfeVoucherInput & {
|
|
|
87
90
|
/** @internal Durable v2 reservation evidence written before `lines`. */
|
|
88
91
|
details?: readonly LegacyWsmtxcaLine[];
|
|
89
92
|
};
|
|
90
|
-
declare function wsmtxcaRequest(data: FiscalHeader, number?: number): {
|
|
93
|
+
declare function wsmtxcaRequest(data: FiscalHeader$1, number?: number): {
|
|
91
94
|
comprobanteCAERequest: {
|
|
92
95
|
arrayItems: {
|
|
93
96
|
item: {
|
|
@@ -220,6 +223,24 @@ type IssueAmounts = {
|
|
|
220
223
|
vatAdjustment: number;
|
|
221
224
|
};
|
|
222
225
|
|
|
226
|
+
/**
|
|
227
|
+
* The normalized fiscal fields shared by previews and authorized vouchers.
|
|
228
|
+
* Dates are `YYYY-MM-DD`; `exchangeRate` is an exact decimal string. Service
|
|
229
|
+
* dates are absent for product-only documents. `paymentDueDate` is absent when
|
|
230
|
+
* the fiscal document has no due date.
|
|
231
|
+
*/
|
|
232
|
+
type FiscalHeader = {
|
|
233
|
+
/** ARCA concept: products (1), services (2), or both (3). */
|
|
234
|
+
concept: 1 | 2 | 3;
|
|
235
|
+
documentType: number;
|
|
236
|
+
documentNumber: string;
|
|
237
|
+
receiverVatConditionId: number;
|
|
238
|
+
currencyId: string;
|
|
239
|
+
exchangeRate?: string;
|
|
240
|
+
serviceStartDate?: string;
|
|
241
|
+
serviceEndDate?: string;
|
|
242
|
+
paymentDueDate?: string;
|
|
243
|
+
};
|
|
223
244
|
type IssueOptions = {
|
|
224
245
|
service?: "wsfe" | "wsmtxca";
|
|
225
246
|
/** An externally reserved number. Never reads the next number when supplied. */
|
|
@@ -239,12 +260,20 @@ type IssueOptions = {
|
|
|
239
260
|
*/
|
|
240
261
|
abortSignal?: AbortSignal;
|
|
241
262
|
};
|
|
263
|
+
/** Dates are `YYYY-MM-DD` and money is in minor units, like the input. */
|
|
242
264
|
type IssuedVoucher = VoucherCoordinates & {
|
|
243
265
|
voucherClass: VoucherClass;
|
|
244
266
|
date: string;
|
|
267
|
+
header: FiscalHeader;
|
|
245
268
|
cae: string;
|
|
246
269
|
caeExpiry: string;
|
|
247
270
|
amounts: IssueAmounts;
|
|
271
|
+
/**
|
|
272
|
+
* The URL the printed voucher's QR must encode, per ARCA's specification.
|
|
273
|
+
* Absent only if ARCA answered a CAE the specification cannot encode: an
|
|
274
|
+
* authorization is never lost over its QR.
|
|
275
|
+
*/
|
|
276
|
+
qr?: string;
|
|
248
277
|
};
|
|
249
278
|
/** The provider a call targets. It is chosen explicitly, never switched. */
|
|
250
279
|
type IssuanceService = "wsfe" | "wsmtxca";
|
|
@@ -259,6 +288,7 @@ type IssueRequest<S extends IssuanceService = "wsfe"> = S extends "wsmtxca" ? Ws
|
|
|
259
288
|
type IssuePreview<S extends IssuanceService = "wsfe"> = {
|
|
260
289
|
voucherClass: VoucherClass;
|
|
261
290
|
voucherType: number;
|
|
291
|
+
header: FiscalHeader;
|
|
262
292
|
amounts: IssueAmounts;
|
|
263
293
|
request: IssueRequest<S>;
|
|
264
294
|
service?: S;
|
|
@@ -438,6 +468,14 @@ type CreditNoteInput = Pick<IssuanceFields, "taxes" | "optionalFields" | "fce">
|
|
|
438
468
|
for: VoucherCoordinates | readonly VoucherCoordinates[];
|
|
439
469
|
salesPoint?: number;
|
|
440
470
|
date?: WsfeDateInput;
|
|
471
|
+
/**
|
|
472
|
+
* The receiver's IVA condition, used only when the consulted original does
|
|
473
|
+
* not report one. ARCA omits it on vouchers authorized before the field
|
|
474
|
+
* existed. When the original reports it, the two must agree.
|
|
475
|
+
*/
|
|
476
|
+
to?: {
|
|
477
|
+
condition: ReceiverCondition | number;
|
|
478
|
+
};
|
|
441
479
|
} & ({
|
|
442
480
|
items: NonNullable<IssueInput["items"]>;
|
|
443
481
|
total?: number;
|
|
@@ -581,4 +619,4 @@ type ArcaClient = {
|
|
|
581
619
|
*/
|
|
582
620
|
declare function createArcaClient(config?: ArcaClientOptions): ArcaClient;
|
|
583
621
|
|
|
584
|
-
export { type ArcaClient as A, type CreditNoteInput as C, type DebitNoteInput as D, type FceOptions as F, type InvoiceFamily as I, type NotePreview as N, type PeriodNoteInput as P, type Receiver as R, type Tribute as T, type VatItem as V, type WsfeIdentityMatch as W, type AmountItem as a, type ArcaClientConfigView as b, type
|
|
622
|
+
export { type ArcaClient as A, type CreditNoteInput as C, type DebitNoteInput as D, type FceOptions as F, type InvoiceFamily as I, type NotePreview as N, type PeriodNoteInput as P, type Receiver as R, type Tribute as T, type VatItem as V, type WsfeIdentityMatch as W, type AmountItem as a, type ArcaClientConfigView as b, type FiscalHeader as c, type IssuanceFields as d, type IssuanceService as e, type IssueAmounts as f, type IssueCommon as g, type IssueInput as h, type IssueOptions as i, type IssueOutcome as j, type IssuePreview as k, type IssueRequest as l, type IssuedVoucher as m, type ItemLine as n, type PreviewOptions as o, type RecoveryOptions as p, type VatRate as q, type VoucherAmounts as r, type VoucherCoordinates as s, type VoucherSummary as t, type VouchersService as u, type WsmtxcaIssueRequest as v, type WsmtxcaLine as w, createArcaClient as x, matchWsfeVoucherIdentity as y };
|
package/dist/constants.d.ts
CHANGED
|
@@ -52,14 +52,6 @@ declare const ARCA_CURRENCY_IDS: {
|
|
|
52
52
|
readonly ARS: "PES";
|
|
53
53
|
readonly USD: "DOL";
|
|
54
54
|
};
|
|
55
|
-
/**
|
|
56
|
-
* Common ARCA currency identifiers.
|
|
57
|
-
* @deprecated Use ISO_CURRENCIES, or ARCA_CURRENCY_IDS at the provider boundary.
|
|
58
|
-
*/
|
|
59
|
-
declare const ARCA_CURRENCIES: {
|
|
60
|
-
readonly PES: "PES";
|
|
61
|
-
readonly DOL: "DOL";
|
|
62
|
-
};
|
|
63
55
|
/** Legal assertions supported by the invoice high-level API; never inferred from Padrón. */
|
|
64
56
|
type IssuerCondition = "responsable_inscripto" | "monotributo" | "exento" | "no_alcanzado";
|
|
65
57
|
type ReceiverCondition = IssuerCondition | "consumidor_final";
|
|
@@ -109,4 +101,4 @@ declare const ARCA_INVOICE_CLASS_BY_ISSUER: {
|
|
|
109
101
|
};
|
|
110
102
|
};
|
|
111
103
|
|
|
112
|
-
export { ARCA_CONCEPT_TYPES,
|
|
104
|
+
export { ARCA_CONCEPT_TYPES, ARCA_CURRENCY_IDS, ARCA_DOCUMENT_TYPES, ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS, ARCA_INVOICE_CLASS_BY_ISSUER, ARCA_ISSUER_CONDITION_IDS, ARCA_RECEIVER_CONDITION_IDS, ARCA_RECEIVER_VAT_CONDITIONS, ARCA_VAT_RATES, ARCA_VOUCHER_TYPES, ISO_CURRENCIES, type IssuerCondition, type ReceiverCondition, type VoucherClass };
|
package/dist/constants.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARCA_CONCEPT_TYPES,
|
|
3
|
-
ARCA_CURRENCIES,
|
|
4
3
|
ARCA_CURRENCY_IDS,
|
|
5
4
|
ARCA_DOCUMENT_TYPES,
|
|
6
5
|
ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS,
|
|
@@ -11,10 +10,9 @@ import {
|
|
|
11
10
|
ARCA_VAT_RATES,
|
|
12
11
|
ARCA_VOUCHER_TYPES,
|
|
13
12
|
ISO_CURRENCIES
|
|
14
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-DHN6OQJP.mjs";
|
|
15
14
|
export {
|
|
16
15
|
ARCA_CONCEPT_TYPES,
|
|
17
|
-
ARCA_CURRENCIES,
|
|
18
16
|
ARCA_CURRENCY_IDS,
|
|
19
17
|
ARCA_DOCUMENT_TYPES,
|
|
20
18
|
ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { a as AmountItem, A as ArcaClient, b as ArcaClientConfigView, C as CreditNoteInput, D as DebitNoteInput, F as FceOptions, I as InvoiceFamily,
|
|
1
|
+
export { a as AmountItem, A as ArcaClient, b as ArcaClientConfigView, C as CreditNoteInput, D as DebitNoteInput, F as FceOptions, c as FiscalHeader, I as InvoiceFamily, d as IssuanceFields, e as IssuanceService, f as IssueAmounts, g as IssueCommon, h as IssueInput, i as IssueOptions, j as IssueOutcome, k as IssuePreview, l as IssueRequest, m as IssuedVoucher, n as ItemLine, N as NotePreview, P as PeriodNoteInput, o as PreviewOptions, R as Receiver, p as RecoveryOptions, T as Tribute, V as VatItem, q as VatRate, r as VoucherAmounts, s as VoucherCoordinates, t as VoucherSummary, u as VouchersService, W as WsfeIdentityMatch, v as WsmtxcaIssueRequest, w as WsmtxcaLine, x as createArcaClient, y as matchWsfeVoucherIdentity } from './client-C7lhfLGY.js';
|
|
2
2
|
import { h as ArcaEnvironment, a as ArcaClientConfig, i as ArcaStore, j as ArcaWsaaSessionStore } from './types-Su7QwloQ.js';
|
|
3
3
|
export { g as ArcaAuthCredentials, f as ArcaAuthOptions, A as ArcaClientConfig, k as ArcaLogLevel, l as ArcaLoggerConfig, m as ArcaPadronServiceName, n as ArcaRepresentedTaxId, b as ArcaServiceName, o as ArcaServiceTarget, e as ArcaWsaaServiceId, p as ArcaWsaaSessionKey } from './types-Su7QwloQ.js';
|
|
4
4
|
export { ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS, ARCA_INVOICE_CLASS_BY_ISSUER, ARCA_ISSUER_CONDITION_IDS, ARCA_RECEIVER_CONDITION_IDS, IssuerCondition, ReceiverCondition, VoucherClass } from './constants.js';
|
|
5
5
|
export { A as ArcaAuthenticationError, a as ArcaAuthenticationErrorOptions, b as ArcaAuthenticationEvidence, c as ArcaAuthenticationReason, d as ArcaAuthorizationIndeterminateReason, e as ArcaAuthorizationOutcome, f as ArcaConfigurationError, g as ArcaError, h as ArcaFiscalIssue, i as ArcaFiscalResultLevel, j as ArcaFiscalResults, k as ArcaFiscalService, l as ArcaInputError, m as ArcaInputErrorCode, n as ArcaInputErrorOptions, o as ArcaInvalidSoapResponseError, p as ArcaSafeErrorMetadata, q as ArcaServiceError, r as ArcaSoapFaultError, s as ArcaTransportError, t as ArcaVoucherLookupResult, u as isArcaAuthenticationError, v as toArcaSafeErrorMetadata } from './fiscal-evidence-DaCyGd5o.js';
|
|
6
|
-
export { CreatePadronServiceOptions, PadronService, PadronTaxIdLookupResult, PadronTaxpayerResult, createPadronService } from './padron.js';
|
|
6
|
+
export { CreatePadronServiceOptions, PadronService, PadronTax, PadronTaxIdLookupResult, PadronTaxpayerResult, createPadronService } from './padron.js';
|
|
7
7
|
export { CreateWsfeServiceOptions, WsfeActivity, WsfeActivityType, WsfeAssociatedPeriod, WsfeAssociatedVoucher, WsfeAuthorizationOutcome, WsfeAuthorizeVoucherInput, WsfeBuyer, WsfeCatalogEntry, WsfeCurrencyType, WsfeDateInput, WsfeOptionalField, WsfeQuotation, WsfeReceiverVatCondition, WsfeSalesPoint, WsfeServerStatus, WsfeService, WsfeTax, WsfeVatRate, WsfeVoucherInfo, WsfeVoucherInput, WsfeVoucherLookupResult, createWsfeService } from './wsfe.js';
|
|
8
8
|
export { CreateWsmtxcaServiceOptions, WsmtxcaAuthorizationOutcome, WsmtxcaAuthorizeVoucherInput, WsmtxcaLastAuthorizedVoucherResult, WsmtxcaSalesPoint, WsmtxcaSalesPointsResult, WsmtxcaService, WsmtxcaVoucherInfo, WsmtxcaVoucherLookupOutcome, WsmtxcaVoucherLookupResult, createWsmtxcaService } from './wsmtxca.js';
|
|
9
9
|
import './index-DAC3edtw.js';
|
|
@@ -40,6 +40,52 @@ declare function createArcaClientConfigFromEnv(options?: CreateArcaClientConfigF
|
|
|
40
40
|
*/
|
|
41
41
|
declare function assertArcaClientConfig(config: ArcaClientConfig): void;
|
|
42
42
|
|
|
43
|
+
/** Where every printed voucher's QR points, per ARCA's QR specification v1. */
|
|
44
|
+
declare const ARCA_QR_URL = "https://www.arca.gob.ar/fe/qr/";
|
|
45
|
+
/** What the QR of a printed voucher encodes. Amounts are minor units. */
|
|
46
|
+
type ArcaQrInput = {
|
|
47
|
+
/** The issuer's CUIT. */
|
|
48
|
+
taxId: number | string;
|
|
49
|
+
salesPoint: number;
|
|
50
|
+
voucherType: number;
|
|
51
|
+
number: number;
|
|
52
|
+
/** `YYYY-MM-DD` or `YYYYMMDD`. */
|
|
53
|
+
date: string;
|
|
54
|
+
/** The total in the voucher's currency, in minor units. */
|
|
55
|
+
total: number;
|
|
56
|
+
/** ARCA currency id; `PES` when omitted. */
|
|
57
|
+
currency?: string;
|
|
58
|
+
/** Pesos per unit of `currency`; 1 for pesos. */
|
|
59
|
+
exchangeRate?: number | string;
|
|
60
|
+
/** The CAE, or the CAEA when `authorization` is `"CAEA"`. */
|
|
61
|
+
cae: string;
|
|
62
|
+
authorization?: "CAE" | "CAEA";
|
|
63
|
+
/** The receiver's document. Omitted, or type 99, means an unidentified consumidor final. */
|
|
64
|
+
document?: {
|
|
65
|
+
type: number;
|
|
66
|
+
number: number | string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
/** The JSON the QR carries, in the field order of ARCA's specification. */
|
|
70
|
+
type ArcaQrPayload = {
|
|
71
|
+
ver: 1;
|
|
72
|
+
fecha: string;
|
|
73
|
+
cuit: number;
|
|
74
|
+
ptoVta: number;
|
|
75
|
+
tipoCmp: number;
|
|
76
|
+
nroCmp: number;
|
|
77
|
+
importe: number;
|
|
78
|
+
moneda: string;
|
|
79
|
+
ctz: number;
|
|
80
|
+
tipoDocRec?: number;
|
|
81
|
+
nroDocRec?: number;
|
|
82
|
+
tipoCodAut: "E" | "A";
|
|
83
|
+
codAut: number;
|
|
84
|
+
};
|
|
85
|
+
/** Builds the URL a printed voucher's QR must encode. Pure, no I/O. */
|
|
86
|
+
declare function arcaQrUrl(input: ArcaQrInput): string;
|
|
87
|
+
declare function arcaQrPayload(input: ArcaQrInput): ArcaQrPayload;
|
|
88
|
+
|
|
43
89
|
/** Persistent store for a single server with a private durable volume. */
|
|
44
90
|
declare function createFileStore(directory: string): ArcaStore;
|
|
45
91
|
|
|
@@ -71,4 +117,4 @@ declare function createRedisStore(client: RedisClient, options?: {
|
|
|
71
117
|
|
|
72
118
|
declare function createMemoryWsaaSessionStore(): ArcaWsaaSessionStore;
|
|
73
119
|
|
|
74
|
-
export { ARCA_ENVIRONMENTS, ARCA_ENV_VARIABLES, ArcaEnvironment, ArcaStore, ArcaWsaaSessionStore, type CreateArcaClientConfigFromEnvOptions, assertArcaClientConfig, createArcaClientConfigFromEnv, createFileStore, createMemoryStore, createMemoryWsaaSessionStore, createPostgresStore, createRedisStore, resolveArcaEnvironment };
|
|
120
|
+
export { ARCA_ENVIRONMENTS, ARCA_ENV_VARIABLES, ARCA_QR_URL, ArcaEnvironment, type ArcaQrInput, type ArcaQrPayload, ArcaStore, ArcaWsaaSessionStore, type CreateArcaClientConfigFromEnvOptions, arcaQrPayload, arcaQrUrl, assertArcaClientConfig, createArcaClientConfigFromEnv, createFileStore, createMemoryStore, createMemoryWsaaSessionStore, createPostgresStore, createRedisStore, resolveArcaEnvironment };
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,9 @@ import {
|
|
|
2
2
|
ARCA_ENVIRONMENTS,
|
|
3
3
|
ARCA_ENV_VARIABLES,
|
|
4
4
|
ARCA_LEASE_MS,
|
|
5
|
+
ARCA_QR_URL,
|
|
6
|
+
arcaQrPayload,
|
|
7
|
+
arcaQrUrl,
|
|
5
8
|
assertArcaClientConfig,
|
|
6
9
|
createArcaClient,
|
|
7
10
|
createArcaClientConfigFromEnv,
|
|
@@ -11,19 +14,19 @@ import {
|
|
|
11
14
|
resolveArcaEnvironment,
|
|
12
15
|
storeCall,
|
|
13
16
|
withLease
|
|
14
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-5O2FESHA.mjs";
|
|
15
18
|
import {
|
|
16
19
|
ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS,
|
|
17
20
|
ARCA_INVOICE_CLASS_BY_ISSUER,
|
|
18
21
|
ARCA_ISSUER_CONDITION_IDS,
|
|
19
22
|
ARCA_RECEIVER_CONDITION_IDS
|
|
20
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-DHN6OQJP.mjs";
|
|
21
24
|
import {
|
|
22
25
|
createPadronService
|
|
23
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-EXECWJEC.mjs";
|
|
24
27
|
import {
|
|
25
28
|
createWsfeService
|
|
26
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-VJ2ICMSA.mjs";
|
|
27
30
|
import {
|
|
28
31
|
createWsmtxcaService
|
|
29
32
|
} from "./chunk-WN62NMUJ.mjs";
|
|
@@ -222,6 +225,7 @@ export {
|
|
|
222
225
|
ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS,
|
|
223
226
|
ARCA_INVOICE_CLASS_BY_ISSUER,
|
|
224
227
|
ARCA_ISSUER_CONDITION_IDS,
|
|
228
|
+
ARCA_QR_URL,
|
|
225
229
|
ARCA_RECEIVER_CONDITION_IDS,
|
|
226
230
|
ArcaAuthenticationError,
|
|
227
231
|
ArcaConfigurationError,
|
|
@@ -231,6 +235,8 @@ export {
|
|
|
231
235
|
ArcaServiceError,
|
|
232
236
|
ArcaSoapFaultError,
|
|
233
237
|
ArcaTransportError,
|
|
238
|
+
arcaQrPayload,
|
|
239
|
+
arcaQrUrl,
|
|
234
240
|
assertArcaClientConfig,
|
|
235
241
|
createArcaClient,
|
|
236
242
|
createArcaClientConfigFromEnv,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/store/memory.ts","../src/store/postgres.ts","../src/store/redis.ts"],"sourcesContent":["import type { ArcaStore } from \"./types\";\n\n/** In-process store for tests; reservations do not survive a restart. */\nexport function createMemoryStore(): ArcaStore {\n const values = new Map<string, string>();\n const locks = new Map<string, Promise<void>>();\n return {\n get: (key) => Promise.resolve(values.get(key) ?? null),\n set(key, value) {\n values.set(key, value);\n return Promise.resolve();\n },\n add(key, value) {\n if (values.has(key)) {\n return Promise.resolve(false);\n }\n values.set(key, value);\n return Promise.resolve(true);\n },\n delete(key) {\n values.delete(key);\n return Promise.resolve();\n },\n async withLock(key, fn) {\n const previous = locks.get(key) ?? Promise.resolve();\n let release: () => void = () => undefined;\n const current = new Promise<void>((resolve) => {\n release = resolve;\n });\n const queued = previous.catch(() => undefined).then(() => current);\n locks.set(key, queued);\n await previous.catch(() => undefined);\n try {\n return await fn();\n } finally {\n release();\n if (locks.get(key) === queued) {\n locks.delete(key);\n }\n }\n },\n };\n}\n","import { ArcaConfigurationError } from \"../errors\";\nimport { ARCA_LEASE_MS, withLease } from \"./lock\";\nimport { type ArcaStore, storeCall } from \"./types\";\n\ntype Row = { key?: string; value?: string };\n/** Uses the caller's SQL client; provision the table before use. */\nexport function createPostgresStore({\n query,\n table = \"arca_store\",\n}: {\n query: (text: string, params: string[]) => Promise<Row[] | { rows: Row[] }>;\n table?: string;\n}): ArcaStore {\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(table)) {\n throw new ArcaConfigurationError(\"Invalid ARCA store table identifier.\");\n }\n const name = `\"${table}\"`;\n const lease = Math.round(ARCA_LEASE_MS / 1000);\n const run = (text: string, params: string[]) =>\n storeCall(async () => {\n const result = await query(text, params);\n return Array.isArray(result) ? result : result.rows;\n });\n return {\n async get(key) {\n return (\n (await run(`SELECT value FROM ${name} WHERE key = $1`, [key]))[0]\n ?.value ?? null\n );\n },\n async set(key, value) {\n await run(\n `INSERT INTO ${name} (key, value) VALUES ($1, $2) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_at = now()`,\n [key, value]\n );\n },\n async add(key, value) {\n return (\n (\n await run(\n `INSERT INTO ${name} (key, value) VALUES ($1, $2) ON CONFLICT DO NOTHING RETURNING key`,\n [key, value]\n )\n ).length > 0\n );\n },\n async delete(key) {\n await run(`DELETE FROM ${name} WHERE key = $1`, [key]);\n },\n withLock(key, fn) {\n // A lease row, not an advisory lock: it survives a transaction-mode\n // pooler, where a session-scoped lock would be taken on another backend.\n return withLease(\n key,\n {\n async acquire(owner) {\n const taken = await run(\n `INSERT INTO ${name} (key, value) VALUES ($1, $2) ON CONFLICT DO NOTHING RETURNING key`,\n [key, owner]\n );\n if (taken.length > 0) {\n return true;\n }\n const expired = await run(\n `UPDATE ${name} SET value = $2, updated_at = now() WHERE key = $1 AND updated_at < now() - interval '${lease} seconds' RETURNING key`,\n [key, owner]\n );\n return expired.length > 0;\n },\n async renew(owner) {\n await run(\n `UPDATE ${name} SET updated_at = now() WHERE key = $1 AND value = $2`,\n [key, owner]\n );\n },\n async release(owner) {\n await run(`DELETE FROM ${name} WHERE key = $1 AND value = $2`, [\n key,\n owner,\n ]);\n },\n },\n fn\n );\n },\n };\n}\n","import { ArcaConfigurationError } from \"../errors\";\nimport { ARCA_LEASE_MS, withLease } from \"./lock\";\nimport { type ArcaStore, storeCall } from \"./types\";\n\ntype RedisClient = {\n get(key: string): Promise<unknown>;\n set(key: string, value: string): Promise<unknown>;\n call?(...args: string[]): Promise<unknown>;\n del?(key: string): Promise<unknown>;\n};\n/** Uses ioredis or Upstash without importing either driver. */\nexport function createRedisStore(\n client: RedisClient,\n options: { flavor?: \"ioredis\" | \"upstash\" } = {}\n): ArcaStore {\n const flavor =\n options.flavor ??\n (typeof client.call === \"function\" ? \"ioredis\" : \"upstash\");\n if (flavor === \"ioredis\" && !client.call) {\n throw new ArcaConfigurationError(\n \"ARCA Redis ioredis flavor requires client.call.\"\n );\n }\n // The public structural type accepts ioredis's overloaded set method.\n // Only the Upstash flavor invokes its options-object overload.\n const upstashSet = client.set as (\n key: string,\n value: string,\n options: { nx?: true; xx?: true; px?: number }\n ) => Promise<unknown>;\n const read = async (key: string) => {\n const value = await client.get(key);\n if (value === null || value === undefined) {\n return null;\n }\n // Upstash can deserialize stored JSON automatically.\n return typeof value === \"string\" ? value : JSON.stringify(value);\n };\n // A lease, so a crashed holder frees the key; a renewal keeps a live one.\n const lease = (key: string, owner: string, mode: \"nx\" | \"xx\") =>\n storeCall(\n async () =>\n (flavor === \"ioredis\"\n ? await client.call?.(\n \"SET\",\n key,\n owner,\n mode.toUpperCase(),\n \"PX\",\n String(ARCA_LEASE_MS)\n )\n : await upstashSet.call(client, key, owner, {\n [mode]: true,\n px: ARCA_LEASE_MS,\n })) === \"OK\"\n );\n return {\n get: (key) => storeCall(() => read(key)),\n set: (key, value) =>\n storeCall(async () => {\n await client.set(key, value);\n }),\n add: (key, value) =>\n storeCall(\n async () =>\n (flavor === \"ioredis\"\n ? await client.call?.(\"SET\", key, value, \"NX\")\n : await upstashSet.call(client, key, value, { nx: true })) === \"OK\"\n ),\n ...(client.del\n ? {\n delete: (key: string) =>\n storeCall(async () => {\n await client.del?.(key);\n }),\n withLock: <T>(key: string, fn: () => Promise<T>) =>\n withLease(\n key,\n {\n acquire: (owner) => lease(key, owner, \"nx\"),\n renew: async (owner) => {\n // Check and set: only the holder extends its own lease.\n if ((await storeCall(() => read(key))) === owner) {\n await lease(key, owner, \"xx\");\n }\n },\n release: async (owner) => {\n await storeCall(async () => {\n if ((await read(key)) === owner) {\n await client.del?.(key);\n }\n });\n },\n },\n fn\n ),\n }\n : {}),\n };\n}\n"],"mappings":";;;;;;;;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,QAAQ,KAAK,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO;AAAA,IACrE;AAAA,IACF,GAAI,OAAO,MACP;AAAA,MACE,QAAQ,CAAC,QACP,UAAU,YAAY;AACpB,cAAM,OAAO,MAAM,GAAG;AAAA,MACxB,CAAC;AAAA,MACH,UAAU,CAAI,KAAa,OACzB;AAAA,QACE;AAAA,QACA;AAAA,UACE,SAAS,CAAC,UAAU,MAAM,KAAK,OAAO,IAAI;AAAA,UAC1C,OAAO,OAAO,UAAU;AAEtB,gBAAK,MAAM,UAAU,MAAM,KAAK,GAAG,CAAC,MAAO,OAAO;AAChD,oBAAM,MAAM,KAAK,OAAO,IAAI;AAAA,YAC9B;AAAA,UACF;AAAA,UACA,SAAS,OAAO,UAAU;AACxB,kBAAM,UAAU,YAAY;AAC1B,kBAAK,MAAM,KAAK,GAAG,MAAO,OAAO;AAC/B,sBAAM,OAAO,MAAM,GAAG;AAAA,cACxB;AAAA,YACF,CAAC;AAAA,UACH;AAAA,QACF;AAAA,QACA;AAAA,MACF;AAAA,IACJ,IACA,CAAC;AAAA,EACP;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/store/memory.ts","../src/store/postgres.ts","../src/store/redis.ts"],"sourcesContent":["import type { ArcaStore } from \"./types\";\n\n/** In-process store for tests; reservations do not survive a restart. */\nexport function createMemoryStore(): ArcaStore {\n const values = new Map<string, string>();\n const locks = new Map<string, Promise<void>>();\n return {\n get: (key) => Promise.resolve(values.get(key) ?? null),\n set(key, value) {\n values.set(key, value);\n return Promise.resolve();\n },\n add(key, value) {\n if (values.has(key)) {\n return Promise.resolve(false);\n }\n values.set(key, value);\n return Promise.resolve(true);\n },\n delete(key) {\n values.delete(key);\n return Promise.resolve();\n },\n async withLock(key, fn) {\n const previous = locks.get(key) ?? Promise.resolve();\n let release: () => void = () => undefined;\n const current = new Promise<void>((resolve) => {\n release = resolve;\n });\n const queued = previous.catch(() => undefined).then(() => current);\n locks.set(key, queued);\n await previous.catch(() => undefined);\n try {\n return await fn();\n } finally {\n release();\n if (locks.get(key) === queued) {\n locks.delete(key);\n }\n }\n },\n };\n}\n","import { ArcaConfigurationError } from \"../errors\";\nimport { ARCA_LEASE_MS, withLease } from \"./lock\";\nimport { type ArcaStore, storeCall } from \"./types\";\n\ntype Row = { key?: string; value?: string };\n/** Uses the caller's SQL client; provision the table before use. */\nexport function createPostgresStore({\n query,\n table = \"arca_store\",\n}: {\n query: (text: string, params: string[]) => Promise<Row[] | { rows: Row[] }>;\n table?: string;\n}): ArcaStore {\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(table)) {\n throw new ArcaConfigurationError(\"Invalid ARCA store table identifier.\");\n }\n const name = `\"${table}\"`;\n const lease = Math.round(ARCA_LEASE_MS / 1000);\n const run = (text: string, params: string[]) =>\n storeCall(async () => {\n const result = await query(text, params);\n return Array.isArray(result) ? result : result.rows;\n });\n return {\n async get(key) {\n return (\n (await run(`SELECT value FROM ${name} WHERE key = $1`, [key]))[0]\n ?.value ?? null\n );\n },\n async set(key, value) {\n await run(\n `INSERT INTO ${name} (key, value) VALUES ($1, $2) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_at = now()`,\n [key, value]\n );\n },\n async add(key, value) {\n return (\n (\n await run(\n `INSERT INTO ${name} (key, value) VALUES ($1, $2) ON CONFLICT DO NOTHING RETURNING key`,\n [key, value]\n )\n ).length > 0\n );\n },\n async delete(key) {\n await run(`DELETE FROM ${name} WHERE key = $1`, [key]);\n },\n withLock(key, fn) {\n // A lease row, not an advisory lock: it survives a transaction-mode\n // pooler, where a session-scoped lock would be taken on another backend.\n return withLease(\n key,\n {\n async acquire(owner) {\n const taken = await run(\n `INSERT INTO ${name} (key, value) VALUES ($1, $2) ON CONFLICT DO NOTHING RETURNING key`,\n [key, owner]\n );\n if (taken.length > 0) {\n return true;\n }\n const expired = await run(\n `UPDATE ${name} SET value = $2, updated_at = now() WHERE key = $1 AND updated_at < now() - interval '${lease} seconds' RETURNING key`,\n [key, owner]\n );\n return expired.length > 0;\n },\n async renew(owner) {\n await run(\n `UPDATE ${name} SET updated_at = now() WHERE key = $1 AND value = $2`,\n [key, owner]\n );\n },\n async release(owner) {\n await run(`DELETE FROM ${name} WHERE key = $1 AND value = $2`, [\n key,\n owner,\n ]);\n },\n },\n fn\n );\n },\n };\n}\n","import { ArcaConfigurationError } from \"../errors\";\nimport { ARCA_LEASE_MS, withLease } from \"./lock\";\nimport { type ArcaStore, storeCall } from \"./types\";\n\ntype RedisClient = {\n get(key: string): Promise<unknown>;\n set(key: string, value: string): Promise<unknown>;\n call?(...args: string[]): Promise<unknown>;\n del?(key: string): Promise<unknown>;\n};\n/** Uses ioredis or Upstash without importing either driver. */\nexport function createRedisStore(\n client: RedisClient,\n options: { flavor?: \"ioredis\" | \"upstash\" } = {}\n): ArcaStore {\n const flavor =\n options.flavor ??\n (typeof client.call === \"function\" ? \"ioredis\" : \"upstash\");\n if (flavor === \"ioredis\" && !client.call) {\n throw new ArcaConfigurationError(\n \"ARCA Redis ioredis flavor requires client.call.\"\n );\n }\n // The public structural type accepts ioredis's overloaded set method.\n // Only the Upstash flavor invokes its options-object overload.\n const upstashSet = client.set as (\n key: string,\n value: string,\n options: { nx?: true; xx?: true; px?: number }\n ) => Promise<unknown>;\n const read = async (key: string) => {\n const value = await client.get(key);\n if (value === null || value === undefined) {\n return null;\n }\n // Upstash can deserialize stored JSON automatically.\n return typeof value === \"string\" ? value : JSON.stringify(value);\n };\n // A lease, so a crashed holder frees the key; a renewal keeps a live one.\n const lease = (key: string, owner: string, mode: \"nx\" | \"xx\") =>\n storeCall(\n async () =>\n (flavor === \"ioredis\"\n ? await client.call?.(\n \"SET\",\n key,\n owner,\n mode.toUpperCase(),\n \"PX\",\n String(ARCA_LEASE_MS)\n )\n : await upstashSet.call(client, key, owner, {\n [mode]: true,\n px: ARCA_LEASE_MS,\n })) === \"OK\"\n );\n return {\n get: (key) => storeCall(() => read(key)),\n set: (key, value) =>\n storeCall(async () => {\n await client.set(key, value);\n }),\n add: (key, value) =>\n storeCall(\n async () =>\n (flavor === \"ioredis\"\n ? await client.call?.(\"SET\", key, value, \"NX\")\n : await upstashSet.call(client, key, value, { nx: true })) === \"OK\"\n ),\n ...(client.del\n ? {\n delete: (key: string) =>\n storeCall(async () => {\n await client.del?.(key);\n }),\n withLock: <T>(key: string, fn: () => Promise<T>) =>\n withLease(\n key,\n {\n acquire: (owner) => lease(key, owner, \"nx\"),\n renew: async (owner) => {\n // Check and set: only the holder extends its own lease.\n if ((await storeCall(() => read(key))) === owner) {\n await lease(key, owner, \"xx\");\n }\n },\n release: async (owner) => {\n await storeCall(async () => {\n if ((await read(key)) === owner) {\n await client.del?.(key);\n }\n });\n },\n },\n fn\n ),\n }\n : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,oBAA+B;AAC7C,QAAM,SAAS,oBAAI,IAAoB;AACvC,QAAM,QAAQ,oBAAI,IAA2B;AAC7C,SAAO;AAAA,IACL,KAAK,CAAC,QAAQ,QAAQ,QAAQ,OAAO,IAAI,GAAG,KAAK,IAAI;AAAA,IACrD,IAAI,KAAK,OAAO;AACd,aAAO,IAAI,KAAK,KAAK;AACrB,aAAO,QAAQ,QAAQ;AAAA,IACzB;AAAA,IACA,IAAI,KAAK,OAAO;AACd,UAAI,OAAO,IAAI,GAAG,GAAG;AACnB,eAAO,QAAQ,QAAQ,KAAK;AAAA,MAC9B;AACA,aAAO,IAAI,KAAK,KAAK;AACrB,aAAO,QAAQ,QAAQ,IAAI;AAAA,IAC7B;AAAA,IACA,OAAO,KAAK;AACV,aAAO,OAAO,GAAG;AACjB,aAAO,QAAQ,QAAQ;AAAA,IACzB;AAAA,IACA,MAAM,SAAS,KAAK,IAAI;AACtB,YAAM,WAAW,MAAM,IAAI,GAAG,KAAK,QAAQ,QAAQ;AACnD,UAAI,UAAsB,MAAM;AAChC,YAAM,UAAU,IAAI,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-1,11 +1,29 @@
|
|
|
1
|
+
import { ReceiverCondition } from './constants.js';
|
|
1
2
|
import { a as ArcaClientConfig } from './types-Su7QwloQ.js';
|
|
2
3
|
import { W as WsaaAuthModule, S as SoapTransport } from './index-DAC3edtw.js';
|
|
3
4
|
|
|
5
|
+
/** One tax registration reported by the constancia de inscripción. */
|
|
6
|
+
type PadronTax = {
|
|
7
|
+
id: number;
|
|
8
|
+
description?: string;
|
|
9
|
+
/** ARCA's state code; `AC` is active. Absent when ARCA omits it. */
|
|
10
|
+
state?: string;
|
|
11
|
+
regime: "general" | "monotributo";
|
|
12
|
+
};
|
|
4
13
|
/** Result of a taxpayer lookup via Padron A5. */
|
|
5
14
|
type PadronTaxpayerResult = {
|
|
6
15
|
taxId: string;
|
|
7
16
|
personType?: string;
|
|
8
17
|
name?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The receiver condition to invoice this taxpayer under, derived from its
|
|
20
|
+
* active IVA registrations: 30 is responsable inscripto, 20 monotributo, 32
|
|
21
|
+
* exento and 34 no alcanzado. A taxpayer with none of them is a consumidor
|
|
22
|
+
* final. Absent when the registrations contradict each other or when the
|
|
23
|
+
* constancia reports an error, because then they may be missing.
|
|
24
|
+
*/
|
|
25
|
+
condition?: ReceiverCondition;
|
|
26
|
+
taxes: PadronTax[];
|
|
9
27
|
raw: Record<string, unknown>;
|
|
10
28
|
};
|
|
11
29
|
/** Result of a tax ID lookup by document number via Padron A13. */
|
|
@@ -28,4 +46,4 @@ type CreatePadronServiceOptions = {
|
|
|
28
46
|
/** Creates a Padron service instance wired with authentication and SOAP transport. */
|
|
29
47
|
declare function createPadronService(options: CreatePadronServiceOptions): PadronService;
|
|
30
48
|
|
|
31
|
-
export { type CreatePadronServiceOptions, type PadronService, type PadronTaxIdLookupResult, type PadronTaxpayerResult, createPadronService };
|
|
49
|
+
export { type CreatePadronServiceOptions, type PadronService, type PadronTax, type PadronTaxIdLookupResult, type PadronTaxpayerResult, createPadronService };
|
package/dist/padron.mjs
CHANGED
package/dist/wsfe.d.ts
CHANGED
|
@@ -171,16 +171,6 @@ type WsfeService = {
|
|
|
171
171
|
forceRefresh?: boolean;
|
|
172
172
|
abortSignal?: AbortSignal;
|
|
173
173
|
}): Promise<number>;
|
|
174
|
-
/**
|
|
175
|
-
* @deprecated Use `getNextVoucherNumber()` instead.
|
|
176
|
-
* Returns the next available voucher number, not the last authorized one.
|
|
177
|
-
*/
|
|
178
|
-
getLastVoucher(input: {
|
|
179
|
-
representedTaxId?: number | string;
|
|
180
|
-
salesPoint: number;
|
|
181
|
-
voucherType: number;
|
|
182
|
-
forceRefresh?: boolean;
|
|
183
|
-
}): Promise<number>;
|
|
184
174
|
/** Lists all configured points of sale for the taxpayer. */
|
|
185
175
|
getSalesPoints(input: {
|
|
186
176
|
representedTaxId?: number | string;
|
package/dist/wsfe.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "facturas",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Node.js
|
|
3
|
+
"version": "0.16.0",
|
|
4
|
+
"description": "SDK de facturación electrónica con ARCA / AFIP para Node.js: facturas, notas de crédito y débito, y Padrón con una sola API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": "Lapyme",
|