facturas 0.16.0 → 0.17.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 +17 -17
- package/dist/{chunk-5O2FESHA.mjs → chunk-BNZECHTS.mjs} +3 -7
- package/dist/chunk-BNZECHTS.mjs.map +1 -0
- package/dist/{chunk-VJ2ICMSA.mjs → chunk-KD2WT535.mjs} +11 -11
- package/dist/chunk-KD2WT535.mjs.map +1 -0
- package/dist/{chunk-WN62NMUJ.mjs → chunk-MS4SSSYU.mjs} +2 -2
- package/dist/chunk-MS4SSSYU.mjs.map +1 -0
- package/dist/cli.d.ts +2 -2
- package/dist/cli.mjs +12 -12
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-C7lhfLGY.d.ts → client-DFRttmTZ.d.ts} +2 -4
- package/dist/errors.d.ts +1 -1
- package/dist/{fiscal-evidence-DaCyGd5o.d.ts → fiscal-evidence-Cecw1s05.d.ts} +7 -7
- package/dist/index.d.ts +5 -7
- package/dist/index.mjs +3 -5
- package/dist/index.mjs.map +1 -1
- package/dist/wsfe.d.ts +15 -15
- package/dist/wsfe.mjs +1 -1
- package/dist/wsmtxca.d.ts +6 -6
- package/dist/wsmtxca.mjs +1 -1
- package/package.json +9 -4
- package/dist/chunk-5O2FESHA.mjs.map +0 -1
- package/dist/chunk-VJ2ICMSA.mjs.map +0 -1
- package/dist/chunk-WN62NMUJ.mjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { h as ArcaEnvironment, A as ArcaClientOptions } from './types-Su7QwloQ.js';
|
|
2
2
|
import { PadronService } from './padron.js';
|
|
3
|
+
import { e as ArcaAuthorizationOutcome, I as IssuanceService, h as ArcaFiscalIssue, o as ArcaSafeErrorMetadata } from './fiscal-evidence-Cecw1s05.js';
|
|
3
4
|
import { WsfeVoucherInput, WsfeVoucherInfo, WsfeDateInput, WsfeService } from './wsfe.js';
|
|
4
5
|
import { VoucherClass, ReceiverCondition, IssuerCondition } from './constants.js';
|
|
5
|
-
import { e as ArcaAuthorizationOutcome, h as ArcaFiscalIssue, p as ArcaSafeErrorMetadata } from './fiscal-evidence-DaCyGd5o.js';
|
|
6
6
|
import { WsmtxcaService } from './wsmtxca.js';
|
|
7
7
|
|
|
8
8
|
type VoucherCoordinates = {
|
|
@@ -275,8 +275,6 @@ type IssuedVoucher = VoucherCoordinates & {
|
|
|
275
275
|
*/
|
|
276
276
|
qr?: string;
|
|
277
277
|
};
|
|
278
|
-
/** The provider a call targets. It is chosen explicitly, never switched. */
|
|
279
|
-
type IssuanceService = "wsfe" | "wsmtxca";
|
|
280
278
|
type ServiceFor<O extends IssueOptions> = "service" extends keyof O ? "wsmtxca" extends O["service"] ? O extends {
|
|
281
279
|
service: "wsmtxca";
|
|
282
280
|
} ? "wsmtxca" : IssuanceService : "wsfe" : "wsfe";
|
|
@@ -619,4 +617,4 @@ type ArcaClient = {
|
|
|
619
617
|
*/
|
|
620
618
|
declare function createArcaClient(config?: ArcaClientOptions): ArcaClient;
|
|
621
619
|
|
|
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
|
|
620
|
+
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 IssueAmounts as e, type IssueCommon as f, type IssueInput as g, type IssueOptions as h, type IssueOutcome as i, type IssuePreview as j, type IssueRequest as k, type IssuedVoucher as l, type ItemLine as m, type PreviewOptions as n, type RecoveryOptions as o, type VatRate as p, type VoucherAmounts as q, type VoucherCoordinates as r, type VoucherSummary as s, type VouchersService as t, type WsmtxcaIssueRequest as u, type WsmtxcaLine as v, createArcaClient as w, matchWsfeVoucherIdentity as x };
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './types-Su7QwloQ.js';
|
|
2
|
-
export { A as ArcaAuthenticationError, a as ArcaAuthenticationErrorOptions, c as ArcaAuthenticationReason, f as ArcaConfigurationError, g as ArcaError,
|
|
2
|
+
export { A as ArcaAuthenticationError, a as ArcaAuthenticationErrorOptions, c as ArcaAuthenticationReason, f as ArcaConfigurationError, g as ArcaError, k as ArcaInputError, l as ArcaInputErrorCode, m as ArcaInputErrorOptions, n as ArcaInvalidSoapResponseError, o as ArcaSafeErrorMetadata, p as ArcaServiceError, q as ArcaSoapFaultError, r as ArcaTransportError, t as isArcaAuthenticationError, u as toArcaSafeErrorMetadata } from './fiscal-evidence-Cecw1s05.js';
|
|
@@ -119,8 +119,8 @@ type ArcaSafeErrorMetadata = {
|
|
|
119
119
|
};
|
|
120
120
|
declare function toArcaSafeErrorMetadata(error: unknown): ArcaSafeErrorMetadata;
|
|
121
121
|
|
|
122
|
-
/** ARCA
|
|
123
|
-
type
|
|
122
|
+
/** The ARCA service a call targets. It is chosen explicitly, never switched. */
|
|
123
|
+
type IssuanceService = "wsfe" | "wsmtxca";
|
|
124
124
|
/** Location of a structured authorization result in the service response. */
|
|
125
125
|
type ArcaFiscalResultLevel = "header" | "detail" | "operation";
|
|
126
126
|
/** Every structured result field exposed by one provider response. */
|
|
@@ -131,7 +131,7 @@ type ArcaFiscalResults = {
|
|
|
131
131
|
};
|
|
132
132
|
/** Source and meaning of one provider issue. */
|
|
133
133
|
type ArcaFiscalIssue = {
|
|
134
|
-
service:
|
|
134
|
+
service: IssuanceService;
|
|
135
135
|
operation: string;
|
|
136
136
|
source: "error" | "observation";
|
|
137
137
|
category: "business" | "infrastructure" | "observation" | "unknown";
|
|
@@ -147,7 +147,7 @@ type ArcaAuthenticationEvidence = {
|
|
|
147
147
|
reason: ArcaAuthenticationReason;
|
|
148
148
|
providerCode?: string | number;
|
|
149
149
|
};
|
|
150
|
-
type ArcaAuthorizationEvidenceBase<TService extends
|
|
150
|
+
type ArcaAuthorizationEvidenceBase<TService extends IssuanceService = IssuanceService> = {
|
|
151
151
|
service: TService;
|
|
152
152
|
operation: string;
|
|
153
153
|
results: ArcaFiscalResults;
|
|
@@ -156,7 +156,7 @@ type ArcaAuthorizationEvidenceBase<TService extends ArcaFiscalService = ArcaFisc
|
|
|
156
156
|
raw?: Record<string, unknown>;
|
|
157
157
|
};
|
|
158
158
|
/** Structured evidence returned by one exact voucher authorization attempt. */
|
|
159
|
-
type ArcaAuthorizationOutcome<TService extends
|
|
159
|
+
type ArcaAuthorizationOutcome<TService extends IssuanceService = IssuanceService> = (ArcaAuthorizationEvidenceBase<TService> & {
|
|
160
160
|
kind: "authorized";
|
|
161
161
|
result: "A" | "O";
|
|
162
162
|
resultLevel: ArcaFiscalResultLevel;
|
|
@@ -178,7 +178,7 @@ type ArcaAuthorizationOutcome<TService extends ArcaFiscalService = ArcaFiscalSer
|
|
|
178
178
|
voucherNumber?: number;
|
|
179
179
|
});
|
|
180
180
|
/** Structured result of consulting one exact voucher number. */
|
|
181
|
-
type ArcaVoucherLookupResult<TVoucher, TService extends
|
|
181
|
+
type ArcaVoucherLookupResult<TVoucher, TService extends IssuanceService = IssuanceService> = {
|
|
182
182
|
kind: "found";
|
|
183
183
|
service: TService;
|
|
184
184
|
operation: string;
|
|
@@ -194,4 +194,4 @@ type ArcaVoucherLookupResult<TVoucher, TService extends ArcaFiscalService = Arca
|
|
|
194
194
|
raw: Record<string, unknown>;
|
|
195
195
|
};
|
|
196
196
|
|
|
197
|
-
export { ArcaAuthenticationError as A, type ArcaAuthenticationErrorOptions as a, type ArcaAuthenticationEvidence as b, type ArcaAuthenticationReason as c, type ArcaAuthorizationIndeterminateReason as d, type ArcaAuthorizationOutcome as e, ArcaConfigurationError as f, ArcaError as g, type ArcaFiscalIssue as h, type ArcaFiscalResultLevel as i, type ArcaFiscalResults as j,
|
|
197
|
+
export { ArcaAuthenticationError as A, type IssuanceService as I, type ArcaAuthenticationErrorOptions as a, type ArcaAuthenticationEvidence as b, type ArcaAuthenticationReason as c, type ArcaAuthorizationIndeterminateReason as d, type ArcaAuthorizationOutcome as e, ArcaConfigurationError as f, ArcaError as g, type ArcaFiscalIssue as h, type ArcaFiscalResultLevel as i, type ArcaFiscalResults as j, ArcaInputError as k, type ArcaInputErrorCode as l, type ArcaInputErrorOptions as m, ArcaInvalidSoapResponseError as n, type ArcaSafeErrorMetadata as o, ArcaServiceError as p, ArcaSoapFaultError as q, ArcaTransportError as r, type ArcaVoucherLookupResult as s, isArcaAuthenticationError as t, toArcaSafeErrorMetadata as u };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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
|
|
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 IssueAmounts, f as IssueCommon, g as IssueInput, h as IssueOptions, i as IssueOutcome, j as IssuePreview, k as IssueRequest, l as IssuedVoucher, m as ItemLine, N as NotePreview, P as PeriodNoteInput, n as PreviewOptions, R as Receiver, o as RecoveryOptions, T as Tribute, V as VatItem, p as VatRate, q as VoucherAmounts, r as VoucherCoordinates, s as VoucherSummary, t as VouchersService, W as WsfeIdentityMatch, u as WsmtxcaIssueRequest, v as WsmtxcaLine, w as createArcaClient, x as matchWsfeVoucherIdentity } from './client-DFRttmTZ.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
|
-
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
|
|
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 ArcaInputError, l as ArcaInputErrorCode, m as ArcaInputErrorOptions, n as ArcaInvalidSoapResponseError, o as ArcaSafeErrorMetadata, p as ArcaServiceError, q as ArcaSoapFaultError, r as ArcaTransportError, s as ArcaVoucherLookupResult, I as IssuanceService, t as isArcaAuthenticationError, u as toArcaSafeErrorMetadata } from './fiscal-evidence-Cecw1s05.js';
|
|
6
6
|
export { CreatePadronServiceOptions, PadronService, PadronTax, PadronTaxIdLookupResult, PadronTaxpayerResult, createPadronService } from './padron.js';
|
|
7
|
-
export { CreateWsfeServiceOptions, WsfeActivity, WsfeActivityType, WsfeAssociatedPeriod, WsfeAssociatedVoucher, WsfeAuthorizationOutcome,
|
|
8
|
-
export { CreateWsmtxcaServiceOptions, WsmtxcaAuthorizationOutcome,
|
|
7
|
+
export { CreateWsfeServiceOptions, WsfeActivity, WsfeActivityType, WsfeAssociatedPeriod, WsfeAssociatedVoucher, WsfeAuthorizationOutcome, WsfeBuyer, WsfeCatalogEntry, WsfeCurrencyType, WsfeDateInput, WsfeIssueInput, WsfeOptionalField, WsfeQuotation, WsfeReceiverVatCondition, WsfeSalesPoint, WsfeServerStatus, WsfeService, WsfeTax, WsfeVatRate, WsfeVoucherInfo, WsfeVoucherInput, WsfeVoucherLookupResult, createWsfeService } from './wsfe.js';
|
|
8
|
+
export { CreateWsmtxcaServiceOptions, WsmtxcaAuthorizationOutcome, WsmtxcaIssueInput, WsmtxcaLastAuthorizedVoucherResult, WsmtxcaSalesPoint, WsmtxcaSalesPointsResult, WsmtxcaService, WsmtxcaVoucherInfo, WsmtxcaVoucherLookupOutcome, WsmtxcaVoucherLookupResult, createWsmtxcaService } from './wsmtxca.js';
|
|
9
9
|
import './index-DAC3edtw.js';
|
|
10
10
|
|
|
11
11
|
/** Valid ARCA environment names. */
|
|
@@ -24,8 +24,6 @@ type CreateArcaClientConfigFromEnvOptions = {
|
|
|
24
24
|
defaultEnvironment?: ArcaEnvironment;
|
|
25
25
|
variableNames?: Partial<typeof ARCA_ENV_VARIABLES>;
|
|
26
26
|
};
|
|
27
|
-
/** Returns `"production"` or `"test"` based on the boolean flag. */
|
|
28
|
-
declare function resolveArcaEnvironment(production: boolean): ArcaEnvironment;
|
|
29
27
|
/**
|
|
30
28
|
* Builds an {@link ArcaClientConfig} from environment variables.
|
|
31
29
|
* Reads `process.env` by default; override with `options.env`.
|
|
@@ -117,4 +115,4 @@ declare function createRedisStore(client: RedisClient, options?: {
|
|
|
117
115
|
|
|
118
116
|
declare function createMemoryWsaaSessionStore(): ArcaWsaaSessionStore;
|
|
119
117
|
|
|
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
|
|
118
|
+
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -11,10 +11,9 @@ import {
|
|
|
11
11
|
createFileStore,
|
|
12
12
|
createMemoryWsaaSessionStore,
|
|
13
13
|
matchWsfeVoucherIdentity,
|
|
14
|
-
resolveArcaEnvironment,
|
|
15
14
|
storeCall,
|
|
16
15
|
withLease
|
|
17
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-BNZECHTS.mjs";
|
|
18
17
|
import {
|
|
19
18
|
ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS,
|
|
20
19
|
ARCA_INVOICE_CLASS_BY_ISSUER,
|
|
@@ -26,10 +25,10 @@ import {
|
|
|
26
25
|
} from "./chunk-EXECWJEC.mjs";
|
|
27
26
|
import {
|
|
28
27
|
createWsfeService
|
|
29
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-KD2WT535.mjs";
|
|
30
29
|
import {
|
|
31
30
|
createWsmtxcaService
|
|
32
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-MS4SSSYU.mjs";
|
|
33
32
|
import "./chunk-PHXH34L6.mjs";
|
|
34
33
|
import {
|
|
35
34
|
ArcaAuthenticationError,
|
|
@@ -250,7 +249,6 @@ export {
|
|
|
250
249
|
createWsmtxcaService,
|
|
251
250
|
isArcaAuthenticationError,
|
|
252
251
|
matchWsfeVoucherIdentity,
|
|
253
|
-
resolveArcaEnvironment,
|
|
254
252
|
toArcaSafeErrorMetadata
|
|
255
253
|
};
|
|
256
254
|
//# sourceMappingURL=index.mjs.map
|
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 ),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KAAK,OAAO,IAAI,IAC3C,MAAM,WAAW,KAAK,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,UA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;","names":[]}
|
package/dist/wsfe.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as ArcaClientConfig } from './types-Su7QwloQ.js';
|
|
2
2
|
import { W as WsaaAuthModule, S as SoapTransport } from './index-DAC3edtw.js';
|
|
3
|
-
import { e as ArcaAuthorizationOutcome,
|
|
3
|
+
import { e as ArcaAuthorizationOutcome, s as ArcaVoucherLookupResult } from './fiscal-evidence-Cecw1s05.js';
|
|
4
4
|
|
|
5
5
|
/** Accepted public date inputs for WSFE request fields. */
|
|
6
6
|
type WsfeDateInput = `${number}${number}${number}${number}-${number}${number}-${number}${number}` | `${number}${number}${number}${number}${number}${number}${number}${number}`;
|
|
@@ -75,8 +75,8 @@ type WsfeVoucherInput = {
|
|
|
75
75
|
buyers?: WsfeBuyer[];
|
|
76
76
|
activities?: WsfeActivity[];
|
|
77
77
|
};
|
|
78
|
-
/** Input for
|
|
79
|
-
type
|
|
78
|
+
/** Input for {@link WsfeService.issue}: one voucher with an explicit number. */
|
|
79
|
+
type WsfeIssueInput = {
|
|
80
80
|
representedTaxId?: number | string;
|
|
81
81
|
data: WsfeVoucherInput;
|
|
82
82
|
voucherNumber: number;
|
|
@@ -162,7 +162,7 @@ type WsfeService = {
|
|
|
162
162
|
* `voucherNumber`, without transport retries, returning structured evidence
|
|
163
163
|
* (`authorized`, `rejected` or `indeterminate`) instead of throwing.
|
|
164
164
|
*/
|
|
165
|
-
issue(input:
|
|
165
|
+
issue(input: WsfeIssueInput): Promise<WsfeAuthorizationOutcome>;
|
|
166
166
|
/** Returns the next available voucher number for the given sales point and type. */
|
|
167
167
|
getNextVoucherNumber(input: {
|
|
168
168
|
representedTaxId?: number | string;
|
|
@@ -172,52 +172,52 @@ type WsfeService = {
|
|
|
172
172
|
abortSignal?: AbortSignal;
|
|
173
173
|
}): Promise<number>;
|
|
174
174
|
/** Lists all configured points of sale for the taxpayer. */
|
|
175
|
-
getSalesPoints(input
|
|
175
|
+
getSalesPoints(input?: {
|
|
176
176
|
representedTaxId?: number | string;
|
|
177
177
|
forceRefresh?: boolean;
|
|
178
178
|
}): Promise<WsfeSalesPoint[]>;
|
|
179
179
|
/** Lists voucher types accepted by WSFE. */
|
|
180
|
-
getVoucherTypes(input
|
|
180
|
+
getVoucherTypes(input?: {
|
|
181
181
|
representedTaxId?: number | string;
|
|
182
182
|
forceRefresh?: boolean;
|
|
183
183
|
}): Promise<WsfeCatalogEntry[]>;
|
|
184
184
|
/** Lists document types accepted by WSFE. */
|
|
185
|
-
getDocumentTypes(input
|
|
185
|
+
getDocumentTypes(input?: {
|
|
186
186
|
representedTaxId?: number | string;
|
|
187
187
|
forceRefresh?: boolean;
|
|
188
188
|
}): Promise<WsfeCatalogEntry[]>;
|
|
189
189
|
/** Lists concept types accepted by WSFE. */
|
|
190
|
-
getConceptTypes(input
|
|
190
|
+
getConceptTypes(input?: {
|
|
191
191
|
representedTaxId?: number | string;
|
|
192
192
|
forceRefresh?: boolean;
|
|
193
193
|
}): Promise<WsfeCatalogEntry[]>;
|
|
194
194
|
/** Lists live ARCA currency identifiers such as PES and DOL, not ISO codes. */
|
|
195
|
-
getCurrencyTypes(input
|
|
195
|
+
getCurrencyTypes(input?: {
|
|
196
196
|
representedTaxId?: number | string;
|
|
197
197
|
forceRefresh?: boolean;
|
|
198
198
|
}): Promise<WsfeCurrencyType[]>;
|
|
199
199
|
/** Lists VAT rates accepted by WSFE. */
|
|
200
|
-
getVatRates(input
|
|
200
|
+
getVatRates(input?: {
|
|
201
201
|
representedTaxId?: number | string;
|
|
202
202
|
forceRefresh?: boolean;
|
|
203
203
|
}): Promise<WsfeCatalogEntry[]>;
|
|
204
204
|
/** Lists tax types accepted by WSFE. */
|
|
205
|
-
getTaxTypes(input
|
|
205
|
+
getTaxTypes(input?: {
|
|
206
206
|
representedTaxId?: number | string;
|
|
207
207
|
forceRefresh?: boolean;
|
|
208
208
|
}): Promise<WsfeCatalogEntry[]>;
|
|
209
209
|
/** Lists optional field types accepted by WSFE. */
|
|
210
|
-
getOptionalTypes(input
|
|
210
|
+
getOptionalTypes(input?: {
|
|
211
211
|
representedTaxId?: number | string;
|
|
212
212
|
forceRefresh?: boolean;
|
|
213
213
|
}): Promise<WsfeCatalogEntry[]>;
|
|
214
214
|
/** Lists activities enabled for the taxpayer. */
|
|
215
|
-
getActivities(input
|
|
215
|
+
getActivities(input?: {
|
|
216
216
|
representedTaxId?: number | string;
|
|
217
217
|
forceRefresh?: boolean;
|
|
218
218
|
}): Promise<WsfeActivityType[]>;
|
|
219
219
|
/** Lists receiver VAT condition values accepted by WSFE. */
|
|
220
|
-
getReceiverVatConditions(input
|
|
220
|
+
getReceiverVatConditions(input?: {
|
|
221
221
|
representedTaxId?: number | string;
|
|
222
222
|
voucherClass?: string;
|
|
223
223
|
forceRefresh?: boolean;
|
|
@@ -256,4 +256,4 @@ type CreateWsfeServiceOptions = {
|
|
|
256
256
|
/** Creates a WSFE service instance wired with authentication and SOAP transport. */
|
|
257
257
|
declare function createWsfeService(options: CreateWsfeServiceOptions): WsfeService;
|
|
258
258
|
|
|
259
|
-
export { type CreateWsfeServiceOptions, type WsfeActivity, type WsfeActivityType, type WsfeAssociatedPeriod, type WsfeAssociatedVoucher, type WsfeAuthorizationOutcome, type
|
|
259
|
+
export { type CreateWsfeServiceOptions, type WsfeActivity, type WsfeActivityType, type WsfeAssociatedPeriod, type WsfeAssociatedVoucher, type WsfeAuthorizationOutcome, type WsfeBuyer, type WsfeCatalogEntry, type WsfeCurrencyType, type WsfeDateInput, type WsfeIssueInput, type WsfeOptionalField, type WsfeQuotation, type WsfeReceiverVatCondition, type WsfeSalesPoint, type WsfeServerStatus, type WsfeService, type WsfeTax, type WsfeVatRate, type WsfeVoucherInfo, type WsfeVoucherInput, type WsfeVoucherLookupResult, createWsfeService };
|
package/dist/wsfe.mjs
CHANGED
package/dist/wsmtxca.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as ArcaRepresentedTaxId, a as ArcaClientConfig } from './types-Su7QwloQ.js';
|
|
2
2
|
import { W as WsaaAuthModule, S as SoapTransport } from './index-DAC3edtw.js';
|
|
3
|
-
import { e as ArcaAuthorizationOutcome,
|
|
3
|
+
import { e as ArcaAuthorizationOutcome, s as ArcaVoucherLookupResult } from './fiscal-evidence-Cecw1s05.js';
|
|
4
4
|
|
|
5
|
-
/** Input
|
|
6
|
-
type
|
|
5
|
+
/** Input for {@link WsmtxcaService.issue}: one WSMTXCA voucher request. */
|
|
6
|
+
type WsmtxcaIssueInput = {
|
|
7
7
|
representedTaxId?: ArcaRepresentedTaxId;
|
|
8
8
|
data: Record<string, unknown>;
|
|
9
9
|
forceRefresh?: boolean;
|
|
@@ -66,7 +66,7 @@ type WsmtxcaService = {
|
|
|
66
66
|
* Issues one exact voucher: a single autorizarComprobante without transport
|
|
67
67
|
* retries, returning structured evidence instead of throwing.
|
|
68
68
|
*/
|
|
69
|
-
issue(input:
|
|
69
|
+
issue(input: WsmtxcaIssueInput): Promise<WsmtxcaAuthorizationOutcome>;
|
|
70
70
|
/** Returns the last authorized voucher number for the given sales point and type. */
|
|
71
71
|
getLastAuthorizedVoucher(input: {
|
|
72
72
|
representedTaxId?: ArcaRepresentedTaxId;
|
|
@@ -76,7 +76,7 @@ type WsmtxcaService = {
|
|
|
76
76
|
abortSignal?: AbortSignal;
|
|
77
77
|
}): Promise<WsmtxcaLastAuthorizedVoucherResult>;
|
|
78
78
|
/** Returns the points of sale enabled for WSMTXCA. */
|
|
79
|
-
getSalesPoints(input
|
|
79
|
+
getSalesPoints(input?: {
|
|
80
80
|
representedTaxId?: ArcaRepresentedTaxId;
|
|
81
81
|
forceRefresh?: boolean;
|
|
82
82
|
}): Promise<WsmtxcaSalesPointsResult>;
|
|
@@ -106,4 +106,4 @@ type CreateWsmtxcaServiceOptions = {
|
|
|
106
106
|
/** Creates a WSMTXCA service instance wired with authentication and SOAP transport. */
|
|
107
107
|
declare function createWsmtxcaService(options: CreateWsmtxcaServiceOptions): WsmtxcaService;
|
|
108
108
|
|
|
109
|
-
export { type CreateWsmtxcaServiceOptions, type WsmtxcaAuthorizationOutcome, type
|
|
109
|
+
export { type CreateWsmtxcaServiceOptions, type WsmtxcaAuthorizationOutcome, type WsmtxcaIssueInput, type WsmtxcaLastAuthorizedVoucherResult, type WsmtxcaSalesPoint, type WsmtxcaSalesPointsResult, type WsmtxcaService, type WsmtxcaVoucherInfo, type WsmtxcaVoucherLookupOutcome, type WsmtxcaVoucherLookupResult, createWsmtxcaService };
|
package/dist/wsmtxca.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "facturas",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
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
|
-
"author": "
|
|
8
|
-
"homepage": "https://
|
|
7
|
+
"author": "LaPyme",
|
|
8
|
+
"homepage": "https://facturas-sdk.dev",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/LaPyme/facturas.git"
|
|
@@ -21,7 +21,12 @@
|
|
|
21
21
|
"wsfe",
|
|
22
22
|
"wsmtxca",
|
|
23
23
|
"padron",
|
|
24
|
-
"facturacion-electronica"
|
|
24
|
+
"facturacion-electronica",
|
|
25
|
+
"factura",
|
|
26
|
+
"facturacion",
|
|
27
|
+
"cae",
|
|
28
|
+
"typescript",
|
|
29
|
+
"sdk"
|
|
25
30
|
],
|
|
26
31
|
"engines": {
|
|
27
32
|
"node": ">=22"
|