@lapyme/arca 0.1.0 → 0.2.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 +5 -31
- package/dist/errors.d.ts +9 -1
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -1
- package/dist/{index-vWZOjFDO.d.ts → index-BLq3d6xg.d.ts} +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.js +507 -213
- package/dist/index.js.map +1 -1
- package/dist/padron.d.ts +2 -2
- package/dist/padron.js +6 -3
- package/dist/padron.js.map +1 -1
- package/dist/{types-DWsYue4B.d.ts → types-SloiIQkT.d.ts} +10 -10
- package/dist/types.d.ts +1 -1
- package/dist/wsfe.d.ts +83 -8
- package/dist/wsfe.js +256 -67
- package/dist/wsfe.js.map +1 -1
- package/dist/wsmtxca.d.ts +2 -2
- package/dist/wsmtxca.js.map +1 -1
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
The package is ESM-first, supports Node.js `>=20`, and defaults to a safe configuration for open-source use:
|
|
6
6
|
|
|
7
7
|
- WSAA credentials stay in memory by default.
|
|
8
|
-
- Disk-backed WSAA caching is opt-in and requires an explicit directory.
|
|
9
8
|
- The documented public surface is intentionally narrow.
|
|
10
9
|
|
|
11
10
|
## Install
|
|
@@ -28,7 +27,7 @@ const client = createArcaClient(
|
|
|
28
27
|
})
|
|
29
28
|
);
|
|
30
29
|
|
|
31
|
-
const nextVoucher = await client.wsfe.
|
|
30
|
+
const nextVoucher = await client.wsfe.getNextVoucherNumber({
|
|
32
31
|
salesPoint: 1,
|
|
33
32
|
voucherType: 6,
|
|
34
33
|
});
|
|
@@ -60,40 +59,16 @@ const client = createArcaClient({
|
|
|
60
59
|
});
|
|
61
60
|
```
|
|
62
61
|
|
|
63
|
-
### Opt-in disk cache for WSAA credentials
|
|
64
|
-
|
|
65
|
-
By default, WSAA login tickets are cached in memory only. To persist them across process restarts, enable disk cache explicitly:
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
import { createArcaClient } from "@lapyme/arca";
|
|
69
|
-
|
|
70
|
-
const client = createArcaClient({
|
|
71
|
-
taxId: "20123456789",
|
|
72
|
-
certificatePem: process.env.ARCA_CERTIFICATE_PEM!,
|
|
73
|
-
privateKeyPem: process.env.ARCA_PRIVATE_KEY_PEM!,
|
|
74
|
-
environment: "production",
|
|
75
|
-
wsaa: {
|
|
76
|
-
cache: {
|
|
77
|
-
mode: "disk",
|
|
78
|
-
directory: ".arca-wsaa-cache",
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Environment-based configuration also supports:
|
|
85
|
-
|
|
86
|
-
- `ARCA_WSAA_CACHE_MODE` with `memory` or `disk`
|
|
87
|
-
- `ARCA_WSAA_CACHE_DIRECTORY` when `ARCA_WSAA_CACHE_MODE=disk`
|
|
88
|
-
|
|
89
62
|
## Supported Modules
|
|
90
63
|
|
|
91
64
|
### `client.wsfe`
|
|
92
65
|
|
|
93
66
|
WSFE electronic invoicing. All inputs and outputs use JS-convention names; the library maps them to AFIP's SOAP schema internally.
|
|
94
67
|
|
|
68
|
+
- WSFE request date fields accept `YYYY-MM-DD` or `YYYYMMDD` strings.
|
|
95
69
|
- `createNextVoucher({ data })` — Authorizes a new voucher. Takes a typed `WsfeVoucherInput` and returns `WsfeAuthorizationResult` with `cae`, `caeExpiry`, `voucherNumber`, and `raw`.
|
|
96
|
-
- `
|
|
70
|
+
- `getNextVoucherNumber({ salesPoint, voucherType })` — Returns the next available voucher number.
|
|
71
|
+
- `getLastVoucher({ salesPoint, voucherType })` — Deprecated alias for `getNextVoucherNumber()`.
|
|
97
72
|
- `getSalesPoints({})` — Lists configured points of sale as `WsfeSalesPoint[]`.
|
|
98
73
|
- `getVoucherInfo({ number, salesPoint, voucherType })` — Retrieves voucher details as `WsfeVoucherInfo | null`.
|
|
99
74
|
|
|
@@ -170,8 +145,7 @@ pnpm pack:check
|
|
|
170
145
|
## Security Notes
|
|
171
146
|
|
|
172
147
|
- Treat your certificate and private key as secrets.
|
|
173
|
-
-
|
|
174
|
-
- If you enable disk cache, point it at a directory with appropriate filesystem permissions for your runtime.
|
|
148
|
+
- WSAA credentials are cached in memory only and are never written to disk by this package.
|
|
175
149
|
|
|
176
150
|
## License
|
|
177
151
|
|
package/dist/errors.d.ts
CHANGED
|
@@ -9,6 +9,14 @@ declare class ArcaConfigurationError extends ArcaError {
|
|
|
9
9
|
readonly name: string;
|
|
10
10
|
constructor(message: string, options?: ErrorOptions);
|
|
11
11
|
}
|
|
12
|
+
/** Thrown when caller-provided input data is missing or invalid. */
|
|
13
|
+
declare class ArcaInputError extends ArcaError {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly detail?: unknown;
|
|
16
|
+
constructor(message: string, options?: ErrorOptions & {
|
|
17
|
+
detail?: unknown;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
12
20
|
/** Thrown when an HTTP request to an ARCA endpoint fails at the transport level. */
|
|
13
21
|
declare class ArcaTransportError extends ArcaError {
|
|
14
22
|
readonly name: string;
|
|
@@ -40,4 +48,4 @@ declare class ArcaServiceError extends ArcaError {
|
|
|
40
48
|
});
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
export { ArcaConfigurationError, ArcaError, ArcaServiceError, ArcaSoapFaultError, ArcaTransportError };
|
|
51
|
+
export { ArcaConfigurationError, ArcaError, ArcaInputError, ArcaServiceError, ArcaSoapFaultError, ArcaTransportError };
|
package/dist/errors.js
CHANGED
|
@@ -13,6 +13,14 @@ var ArcaConfigurationError = class extends ArcaError {
|
|
|
13
13
|
super(message, "ARCA_CONFIGURATION_ERROR", options);
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
+
var ArcaInputError = class extends ArcaError {
|
|
17
|
+
name = "ArcaInputError";
|
|
18
|
+
detail;
|
|
19
|
+
constructor(message, options) {
|
|
20
|
+
super(message, "ARCA_INPUT_ERROR", options);
|
|
21
|
+
this.detail = options?.detail;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
16
24
|
var ArcaTransportError = class extends ArcaError {
|
|
17
25
|
name = "ArcaTransportError";
|
|
18
26
|
statusCode;
|
|
@@ -46,6 +54,7 @@ var ArcaServiceError = class extends ArcaError {
|
|
|
46
54
|
export {
|
|
47
55
|
ArcaConfigurationError,
|
|
48
56
|
ArcaError,
|
|
57
|
+
ArcaInputError,
|
|
49
58
|
ArcaServiceError,
|
|
50
59
|
ArcaSoapFaultError,
|
|
51
60
|
ArcaTransportError
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/** Base error class for all ARCA-related errors. */\nexport class ArcaError extends Error {\n readonly code: string;\n override readonly name: string = \"ArcaError\";\n\n constructor(message: string, code = \"ARCA_ERROR\", options?: ErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/** Thrown when the ARCA client configuration is missing or invalid. */\nexport class ArcaConfigurationError extends ArcaError {\n override readonly name: string = \"ArcaConfigurationError\";\n\n constructor(message: string, options?: ErrorOptions) {\n super(message, \"ARCA_CONFIGURATION_ERROR\", options);\n }\n}\n\
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/** Base error class for all ARCA-related errors. */\nexport class ArcaError extends Error {\n readonly code: string;\n override readonly name: string = \"ArcaError\";\n\n constructor(message: string, code = \"ARCA_ERROR\", options?: ErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/** Thrown when the ARCA client configuration is missing or invalid. */\nexport class ArcaConfigurationError extends ArcaError {\n override readonly name: string = \"ArcaConfigurationError\";\n\n constructor(message: string, options?: ErrorOptions) {\n super(message, \"ARCA_CONFIGURATION_ERROR\", options);\n }\n}\n\n/** Thrown when caller-provided input data is missing or invalid. */\nexport class ArcaInputError extends ArcaError {\n override readonly name: string = \"ArcaInputError\";\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_INPUT_ERROR\", options);\n this.detail = options?.detail;\n }\n}\n\n/** Thrown when an HTTP request to an ARCA endpoint fails at the transport level. */\nexport class ArcaTransportError extends ArcaError {\n override readonly name: string = \"ArcaTransportError\";\n readonly statusCode?: number;\n readonly responseBody?: string;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n statusCode?: number;\n responseBody?: string;\n }\n ) {\n super(message, \"ARCA_TRANSPORT_ERROR\", options);\n this.statusCode = options?.statusCode;\n this.responseBody = options?.responseBody;\n }\n}\n\n/** Thrown when the SOAP response contains a Fault element. */\nexport class ArcaSoapFaultError extends ArcaError {\n override readonly name: string = \"ArcaSoapFaultError\";\n readonly faultCode?: string;\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n faultCode?: string;\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_SOAP_FAULT\", options);\n this.faultCode = options?.faultCode;\n this.detail = options?.detail;\n }\n}\n\n/** Thrown when an ARCA service (WSFE, WSMTXCA, Padron) returns a domain-level error. */\nexport class ArcaServiceError extends ArcaError {\n override readonly name: string = \"ArcaServiceError\";\n readonly serviceCode?: string | number;\n readonly detail?: unknown;\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n serviceCode?: string | number;\n detail?: unknown;\n }\n ) {\n super(message, \"ARCA_SERVICE_ERROR\", options);\n this.serviceCode = options?.serviceCode;\n this.detail = options?.detail;\n }\n}\n"],"mappings":";AACO,IAAM,YAAN,cAAwB,MAAM;AAAA,EAC1B;AAAA,EACS,OAAe;AAAA,EAEjC,YAAY,SAAiB,OAAO,cAAc,SAAwB;AACxE,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAGO,IAAM,yBAAN,cAAqC,UAAU;AAAA,EAClC,OAAe;AAAA,EAEjC,YAAY,SAAiB,SAAwB;AACnD,UAAM,SAAS,4BAA4B,OAAO;AAAA,EACpD;AACF;AAGO,IAAM,iBAAN,cAA6B,UAAU;AAAA,EAC1B,OAAe;AAAA,EACxB;AAAA,EAET,YACE,SACA,SAGA;AACA,UAAM,SAAS,oBAAoB,OAAO;AAC1C,SAAK,SAAS,SAAS;AAAA,EACzB;AACF;AAGO,IAAM,qBAAN,cAAiC,UAAU;AAAA,EAC9B,OAAe;AAAA,EACxB;AAAA,EACA;AAAA,EAET,YACE,SACA,SAIA;AACA,UAAM,SAAS,wBAAwB,OAAO;AAC9C,SAAK,aAAa,SAAS;AAC3B,SAAK,eAAe,SAAS;AAAA,EAC/B;AACF;AAGO,IAAM,qBAAN,cAAiC,UAAU;AAAA,EAC9B,OAAe;AAAA,EACxB;AAAA,EACA;AAAA,EAET,YACE,SACA,SAIA;AACA,UAAM,SAAS,mBAAmB,OAAO;AACzC,SAAK,YAAY,SAAS;AAC1B,SAAK,SAAS,SAAS;AAAA,EACzB;AACF;AAGO,IAAM,mBAAN,cAA+B,UAAU;AAAA,EAC5B,OAAe;AAAA,EACxB;AAAA,EACA;AAAA,EAET,YACE,SACA,SAIA;AACA,UAAM,SAAS,sBAAsB,OAAO;AAC5C,SAAK,cAAc,SAAS;AAC5B,SAAK,SAAS,SAAS;AAAA,EACzB;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as ArcaSoapExecutionOptions, l as ArcaSoapResponse, j as ArcaWsaaServiceId, c as ArcaAuthOptions, b as ArcaAuthCredentials } from './types-SloiIQkT.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,13 +1,13 @@
|
|
|
1
|
-
import { A as ArcaClientConfig, a as ArcaEnvironment } from './types-
|
|
2
|
-
export { b as ArcaAuthCredentials, c as ArcaAuthOptions, d as
|
|
1
|
+
import { A as ArcaClientConfig, a as ArcaEnvironment } from './types-SloiIQkT.js';
|
|
2
|
+
export { b as ArcaAuthCredentials, c as ArcaAuthOptions, d as ArcaLogLevel, e as ArcaLoggerConfig, f as ArcaPadronServiceName, g as ArcaRepresentedTaxId, h as ArcaServiceName, i as ArcaServiceTarget, j as ArcaWsaaServiceId } from './types-SloiIQkT.js';
|
|
3
3
|
import { PadronService } from './padron.js';
|
|
4
4
|
export { CreatePadronServiceOptions, PadronTaxIdLookupResult, PadronTaxpayerResult, createPadronService } from './padron.js';
|
|
5
5
|
import { WsfeService } from './wsfe.js';
|
|
6
|
-
export { CreateWsfeServiceOptions, WsfeAssociatedVoucher, WsfeAuthorizationResult, WsfeBuyer, WsfeOptionalField, WsfeSalesPoint, WsfeTax, WsfeVatRate, WsfeVoucherInfo, WsfeVoucherInput, createWsfeService } from './wsfe.js';
|
|
6
|
+
export { CreateWsfeServiceOptions, WsfeAssociatedVoucher, WsfeAuthorizationResult, WsfeBuyer, WsfeCatalogEntry, WsfeCurrencyType, WsfeDateInput, WsfeOptionalField, WsfeQuotation, WsfeSalesPoint, WsfeServerStatus, WsfeTax, WsfeVatRate, WsfeVoucherInfo, WsfeVoucherInput, createWsfeService } from './wsfe.js';
|
|
7
7
|
import { WsmtxcaService } from './wsmtxca.js';
|
|
8
8
|
export { CreateWsmtxcaServiceOptions, WsmtxcaAuthorizationResult, WsmtxcaLastAuthorizedVoucherResult, WsmtxcaVoucherLookupResult, createWsmtxcaService } from './wsmtxca.js';
|
|
9
|
-
export { ArcaConfigurationError, ArcaError, ArcaServiceError, ArcaSoapFaultError, ArcaTransportError } from './errors.js';
|
|
10
|
-
import './index-
|
|
9
|
+
export { ArcaConfigurationError, ArcaError, ArcaInputError, ArcaServiceError, ArcaSoapFaultError, ArcaTransportError } from './errors.js';
|
|
10
|
+
import './index-BLq3d6xg.js';
|
|
11
11
|
|
|
12
12
|
/** Fully wired ARCA client with access to all service modules. */
|
|
13
13
|
type ArcaClient = {
|
|
@@ -33,8 +33,6 @@ declare const ARCA_ENV_VARIABLES: {
|
|
|
33
33
|
readonly certificatePem: "ARCA_CERTIFICATE_PEM";
|
|
34
34
|
readonly privateKeyPem: "ARCA_PRIVATE_KEY_PEM";
|
|
35
35
|
readonly environment: "ARCA_ENVIRONMENT";
|
|
36
|
-
readonly wsaaCacheMode: "ARCA_WSAA_CACHE_MODE";
|
|
37
|
-
readonly wsaaCacheDirectory: "ARCA_WSAA_CACHE_DIRECTORY";
|
|
38
36
|
};
|
|
39
37
|
type ArcaClientConfigEnvironment = Record<string, string | undefined>;
|
|
40
38
|
/** Options for {@link createArcaClientConfigFromEnv}. */
|