@ramiidv/arca-agro 0.3.0 → 0.4.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/CHANGELOG.md +119 -0
- package/README.md +60 -36
- package/dist/arca-agro.d.ts +11 -12
- package/dist/arca-agro.d.ts.map +1 -1
- package/dist/arca-agro.js +16 -70
- package/dist/arca-agro.js.map +1 -1
- package/dist/context.d.ts +5 -2
- package/dist/context.d.ts.map +1 -1
- package/dist/cpe-client.d.ts +2 -1
- package/dist/cpe-client.d.ts.map +1 -1
- package/dist/cpe-client.js +9 -8
- package/dist/cpe-client.js.map +1 -1
- package/dist/cpe-schemas.d.ts +0 -2
- package/dist/cpe-schemas.d.ts.map +1 -1
- package/dist/cpe-schemas.js +0 -2
- package/dist/cpe-schemas.js.map +1 -1
- package/dist/errors.d.ts +2 -7
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +3 -9
- package/dist/errors.js.map +1 -1
- package/dist/lpg-client.d.ts +2 -1
- package/dist/lpg-client.d.ts.map +1 -1
- package/dist/lpg-client.js +7 -7
- package/dist/lpg-client.js.map +1 -1
- package/dist/lpg-schemas.d.ts +0 -2
- package/dist/lpg-schemas.d.ts.map +1 -1
- package/dist/lpg-schemas.js +1 -2
- package/dist/lpg-schemas.js.map +1 -1
- package/dist/schema.d.ts +4 -88
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +7 -293
- package/dist/schema.js.map +1 -1
- package/dist/types.d.ts +4 -9
- package/dist/types.d.ts.map +1 -1
- package/llms.txt +1 -1
- package/package.json +15 -18
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8c02c30: API uniforme entre los SDKs (los nombres anteriores siguen funcionando,
|
|
8
|
+
marcados `@deprecated`, hasta la próxima major):
|
|
9
|
+
|
|
10
|
+
- arca-facturacion: la clase principal es `ArcaFacturacion` (`Arca` queda como
|
|
11
|
+
alias). Nuevo `status()` → `{ wsfe, wsfex }` con `ServiceStatus` y el
|
|
12
|
+
`ServerStatus` de arca-common (`appserver`/`dbserver`/`authserver`);
|
|
13
|
+
`serverStatus()`/`serverStatusExpo()` y su `ServerStatus` en mayúsculas
|
|
14
|
+
quedan deprecados.
|
|
15
|
+
- arca-agro: `status()` (antes `serverStatus()`).
|
|
16
|
+
- arca-fecred: el cliente de bajo nivel es `client` (antes `fecred`).
|
|
17
|
+
- arca-common: `ServiceStatus` y `statusOf()` para el estado de varios servicios.
|
|
18
|
+
- bed68e8: Paquetes solo ESM y Node >= 20.19. `arca-common`, `arca-facturacion` y
|
|
19
|
+
`arca-padron` dejan de publicar un build CommonJS: desde CommonJS se cargan con
|
|
20
|
+
`require()` (require(esm), Node >= 20.19 / 22.12). Todos los paquetes pasan a
|
|
21
|
+
requerir Node >= 20.19.0 (Node 18 y 20 sin soporte). El código vive ahora en el
|
|
22
|
+
monorepo `arca-sdks`.
|
|
23
|
+
- f8bd053: Las clases principales extienden `ArcaSdkBase` de arca-common, así que todos
|
|
24
|
+
los SDKs tienen la misma base: `wsaa`, `cuit`, `production`, `on()`/`off()`,
|
|
25
|
+
`clearAuthCache()`, `config.wsaa` (WsaaClient compartido) y `config.signal`
|
|
26
|
+
(signal global). arca-mtxca acepta `endpoints: { mtxca, wsaa }` (`endpoint` y
|
|
27
|
+
`wsaaEndpoint` quedan deprecados). Los `dummy`/`status` validan la respuesta con
|
|
28
|
+
`parseServerStatus`: si falta un campo lanzan `ArcaSoapError`.
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- 20ecf7d: DSL de schemas, segunda versión:
|
|
33
|
+
|
|
34
|
+
- Corrección: `dec()` redondea sobre el valor decimal escrito (`8.575` →
|
|
35
|
+
`8.58`; antes daba `8.57` por la representación binaria). Afecta los importes
|
|
36
|
+
que los SDKs envían redondeados.
|
|
37
|
+
- `must()` rechaza también el valor vacío; los elementos `xsi:nil` cuentan
|
|
38
|
+
como ausentes (en una lista, como lista vacía); `must()` en listas exige el
|
|
39
|
+
elemento; un objeto opcional vacío se omite y uno obligatorio valida sus hijos.
|
|
40
|
+
- Al decodificar se validan enteros (`int()`) y valores permitidos
|
|
41
|
+
(`str({ values })`).
|
|
42
|
+
- Nuevos: `siNo()` (S/N ↔ boolean), `double()`, `xml(nombre, campo)` (nombre
|
|
43
|
+
distinto en el XML), `custom(encode, decode)`, `roundHalfUp()` y
|
|
44
|
+
`decodeResponse(..., { emptyLists: 'omit' })`.
|
|
45
|
+
- b86db00: Nuevo subpath `@ramiidv/arca-common/schema`: el DSL para describir los tipos
|
|
46
|
+
del XSD de un servicio y, con la misma descripción, validar y serializar
|
|
47
|
+
requests en el orden del XSD (`encodeRequest`) y decodificar respuestas con
|
|
48
|
+
tipos (`decodeResponse`). Nuevo error `ArcaResponseError` (respuesta con forma
|
|
49
|
+
inválida, con `uncertain`).
|
|
50
|
+
|
|
51
|
+
arca-agro usa el DSL de common (`ArcaAgroResponseError` extiende
|
|
52
|
+
`ArcaResponseError`) y parsea las respuestas sin conversión numérica: los
|
|
53
|
+
`xs:string` con contenido numérico (ej: `"0012"`, `"10.50"`) ya no pierden ceros
|
|
54
|
+
ni decimales.
|
|
55
|
+
- Updated dependencies [8c02c30]
|
|
56
|
+
- Updated dependencies [f8bd053]
|
|
57
|
+
- Updated dependencies [242fb5f]
|
|
58
|
+
- Updated dependencies [fd438bc]
|
|
59
|
+
- Updated dependencies [bed68e8]
|
|
60
|
+
- Updated dependencies [20ecf7d]
|
|
61
|
+
- Updated dependencies [b86db00]
|
|
62
|
+
- @ramiidv/arca-common@0.5.0
|
|
63
|
+
|
|
64
|
+
## 0.3.0 (2026-11-01)
|
|
65
|
+
|
|
66
|
+
Reescritura de los clientes contra los WSDL/XSD oficiales. La versión anterior no funcionaba contra ARCA en ningún servicio (endpoints, namespaces, elementos y campos incorrectos).
|
|
67
|
+
|
|
68
|
+
### Breaking
|
|
69
|
+
|
|
70
|
+
- **Se elimina WSCTG** (cliente `CtgClient`, `agro.ctg`, tipos, constantes `CTG_*`, `validateCTG`, servicio en `serverStatus`): el CTG fue derogado el 1/11/2021 (RG 5017/2021, reemplazado por la Carta de Porte Electrónica) y sus endpoints responden 404.
|
|
71
|
+
- WSCPE: los requests ahora siguen el XSD (`cabecera`, `origen`, `datosCarga`, `destino`, `destinatario`, `transporte`, ...). Se renombran/reemplazan métodos: `confirmadoArriboCPE` → `confirmarArriboCPE`, `editarCPE` → `editarCPEAutomotor`, `consultarCPE` → `consultarCPEAutomotor`, `consultarConstanciaCPEPDF` eliminado (el PDF viene en `pdf` de las respuestas). `consultarUltNroOrden`/`siguienteNroOrden` reciben `(sucursal, tipoCPE)`.
|
|
72
|
+
- WSLPG: `liquidacionAutorizar` recibe `{ liquidacion, deducciones?, retenciones?, percepciones? }` según `LpgLiquidacionBaseType`; `liquidacionConsultar` se reemplaza por `liquidacionXCoeConsultar` y `liquidacionXNroOrdenConsultar`; `liquidacionAnular(coe)`; `liquidacionAjustarUnificado({ ajusteBase, ajusteCredito?, ajusteDebito? })`; `certificacionAutorizar`/`certificacionAnular` → `cgAutorizar`, `cgSolicitarAnulacion`, `cgConfirmarAnulacion`; `consultarParametros(nombre)` → un método por paramétrica (`tipoGranoConsultar`, `puertoConsultar`, ...).
|
|
73
|
+
- Respuestas tipadas según el XSD: `nroCTG` y `coe` son `string`; los `xs:string` (ej: `codigo` de paramétricas) son `string`. Se eliminan `AgroAuth`, `AgroError`, `raw` y las index signatures `[key: string]: unknown`.
|
|
74
|
+
- Los errores de negocio se lanzan como `ArcaAgroServiceError` (extiende `ArcaServiceError`) en lugar de devolverse en `errores`.
|
|
75
|
+
- `ArcaAgroConfig` extiende `ArcaBaseConfig`: `requestTimeoutMs` → `timeout`; `cuit` acepta `number | string` y se valida el dígito verificador.
|
|
76
|
+
- `CpeClient`/`LpgClient` solo se obtienen desde `ArcaAgro` (se exportan como tipos); sus métodos reciben `opts?: { signal }` en lugar de `auth`.
|
|
77
|
+
- `serverStatus()` devuelve `{ cpe, lpg }` con `{ ok: true, status } | { ok: false, error }`; `clearAuthCache()` es async.
|
|
78
|
+
- `validateCPE`/`validateCTG` → `validateAutorizarCPEAutomotor`, `validateAutorizarCPEFerroviaria`, `validateLiquidacion`, `validateAjusteUnificado`.
|
|
79
|
+
- Requiere `@ramiidv/arca-common` ^0.4.0.
|
|
80
|
+
|
|
81
|
+
### Features
|
|
82
|
+
|
|
83
|
+
- WSCPE, circuito automotor completo: `autorizarCPEAutomotor` (tipos 74 y 274), `consultarCPEAutomotor`, `editarCPEAutomotor`, `editarCPEConfirmadaAutomotor`, `confirmarArriboCPE`, `confirmacionDefinitivaCPEAutomotor`, `descargadoDestinoCPE`, `rechazoCPE`, `anularCPE`, `nuevoDestinoDestinatarioCPEAutomotor`, `regresoOrigenCPEAutomotor`, `desvioCPEAutomotor`, `informarContingencia`, `cerrarContingenciaCPE`.
|
|
84
|
+
- WSCPE, circuito ferroviario: `autorizarCPEFerroviaria`, `consultarCPEFerroviaria`, `editarCPEFerroviaria`, `editarCPEConfirmadaFerroviaria`, `confirmacionDefinitivaCPEFerroviaria`, `nuevoDestinoDestinatarioCPEFerroviaria`, `regresoOrigenCPEFerroviaria`, `desvioCPEFerroviaria`, `consultaCPEFerroviariaPorNroOperativo`.
|
|
85
|
+
- WSCPE, consultas y paramétricas: `consultarCPEPorDestino`, `consultarCPEPPendientesDeResolucion`, `consultarProvincias`, `consultarLocalidadesPorProvincia`, `consultarTiposGrano`, `consultarPlantas`, `consultarLocalidadesProductor`, `consultarCategoriasSemillas`, `consultarVariedadesSemillas`.
|
|
86
|
+
- WSLPG: `liquidacionUltimoNroOrdenConsultar`, `cgConsultarUltimoNroOrden` y paramétricas (`provinciasConsultar`, `localidadXProvinciaConsultar`, `tipoOperacionXActividadConsultar`, `puertoConsultar`, `tipoActividadConsultar`, `tipoActividadRepresentadoConsultar`, `tipoCertificadoDepositoConsultar`, `tipoRetencionConsultar`, `tipoDeduccionConsultar`, `tipoGranoConsultar`, `codigoGradoReferenciaConsultar`, `codigoGradoEntregadoXTipoGranoConsultar`, `campaniasConsultar`).
|
|
87
|
+
- Validación local completa contra el XSD (obligatorios, campos desconocidos, rangos, largos, CUIT con dígito verificador, números finitos, redondeo según `fractionDigits`, fechas) reportando todos los errores juntos.
|
|
88
|
+
- Constantes `TIPO_CPE` y `ESTADOS_CPE`. Endpoints configurables (`endpoints: { cpe, lpg, wsaa }`).
|
|
89
|
+
- Configuración de WSAA: `ticketStorage`, `clockOffsetMs`, `autoClockSkew`, `loginErrorCooldownMs`, `fetch`, `legacyTls`.
|
|
90
|
+
- Todos los métodos aceptan `{ signal }`.
|
|
91
|
+
|
|
92
|
+
### Fixes
|
|
93
|
+
|
|
94
|
+
- WSCPE: endpoints de homologación (`cpea-ws-qaext.afip.gob.ar`) y producción (`cpea-ws.afip.gob.ar`), elementos `<Op>Req`/`<Op>Resp`, SOAPAction y auth `{ token, sign, cuitRepresentada }`.
|
|
95
|
+
- WSLPG: namespace `http://serviciosjava.afip.gob.ar/wslpg/` (era `https`), elementos del WSDL (`liquidacionReq`, `liqConsXCoeReq`, ...) y auth `{ token, sign, cuit }`.
|
|
96
|
+
- Los errores de negocio (`errores.error[]`, `erroresFormato.error[]`) ya no se pierden: siempre se lanzan.
|
|
97
|
+
- Las consultas sin resultados devuelven `[]` (antes devolvían `[respuestaCompleta]`).
|
|
98
|
+
- `consultarUltNroOrden` lanza si ARCA no devuelve `nroOrden` (antes devolvía 0 y `siguienteNroOrden` daba 1, un número ya usado).
|
|
99
|
+
- Las emisiones (autorizar, anular, rechazar, confirmar, editar, contingencias, desvíos, liquidar, ajustar, certificar) nunca se reintentan y conservan `uncertain`.
|
|
100
|
+
- `serverStatus()` usa `Promise.allSettled`; `clearAuthCache()` espera el borrado de los tickets.
|
|
101
|
+
- Validación: `NaN` ya no pasa como número positivo; el CUIT se valida con dígito verificador.
|
|
102
|
+
- Los ejemplos usaban `codTipoCartaPorte: 1` (inválido); ahora usan el tipo 74.
|
|
103
|
+
|
|
104
|
+
## 0.2.0 (2026-06-03)
|
|
105
|
+
|
|
106
|
+
### Chore
|
|
107
|
+
- Build standalone para CI y workflow de release en GitHub Actions.
|
|
108
|
+
- `homepage` apunta a arca-sdk.dev.
|
|
109
|
+
|
|
110
|
+
## 0.1.0 (2026-03-31)
|
|
111
|
+
|
|
112
|
+
### Features
|
|
113
|
+
- Initial release
|
|
114
|
+
- WSCPE (Carta de Porte Electronica) - Electronic bill of lading for grain transport
|
|
115
|
+
- WSCTG (Codigo de Trazabilidad de Granos) - Grain traceability codes
|
|
116
|
+
- WSLPG (Liquidacion Primaria de Granos) - Primary grain settlement/liquidation
|
|
117
|
+
- Auto-handles WSAA authentication for all 3 services
|
|
118
|
+
- Retry with exponential backoff on transient errors
|
|
119
|
+
- Event system for logging/debugging
|
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ const cpe = await agro.cpe.autorizarCPEAutomotor({
|
|
|
72
72
|
|
|
73
73
|
cpe.cabecera.nroCTG; // '010100012345' (string)
|
|
74
74
|
cpe.cabecera.estado; // 'AC'
|
|
75
|
-
cpe.pdf;
|
|
75
|
+
cpe.pdf; // constancia en base64
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
> **`siguienteNroOrden` no es atómico.** Hace `consultarUltNroOrden + 1`: dos procesos que lo llamen a la vez obtienen el mismo número y ARCA rechaza la segunda autorización. Si emitís en paralelo para la misma sucursal y tipo, serializá las emisiones o llevá tu propio contador.
|
|
@@ -83,16 +83,36 @@ cpe.pdf; // constancia en base64
|
|
|
83
83
|
const cartaPorte = { tipoCPE: TIPO_CPE.AUTOMOTOR, sucursal: 1, nroOrden: 15 };
|
|
84
84
|
|
|
85
85
|
await agro.cpe.confirmarArriboCPE({ cuitSolicitante, cartaPorte });
|
|
86
|
-
await agro.cpe.confirmacionDefinitivaCPEAutomotor({
|
|
86
|
+
await agro.cpe.confirmacionDefinitivaCPEAutomotor({
|
|
87
|
+
cuitSolicitante,
|
|
88
|
+
cartaPorte,
|
|
89
|
+
pesoBrutoDescarga: 41900,
|
|
90
|
+
pesoTaraDescarga: 12000,
|
|
91
|
+
});
|
|
87
92
|
await agro.cpe.descargadoDestinoCPE({ cuitSolicitante, cartaPorte });
|
|
88
93
|
await agro.cpe.rechazoCPE({ cuitSolicitante, cartaPorte, rechazoMotivo: 2, rechazoObservaciones: 'Humedad' });
|
|
89
94
|
await agro.cpe.anularCPE({ cartaPorte, anulacionMotivo: 3, anulacionObservaciones: 'Error de carga' });
|
|
90
|
-
await agro.cpe.editarCPEAutomotor({
|
|
95
|
+
await agro.cpe.editarCPEAutomotor({
|
|
96
|
+
nroCTG,
|
|
97
|
+
cuitDestinatario,
|
|
98
|
+
cuitChofer,
|
|
99
|
+
cuitTransportista,
|
|
100
|
+
destino,
|
|
101
|
+
pesoBruto,
|
|
102
|
+
codGrano,
|
|
103
|
+
});
|
|
91
104
|
await agro.cpe.editarCPEConfirmadaAutomotor({ nroCTG, intervinientes: { cuitCorredorVentaPrimaria } });
|
|
92
|
-
await agro.cpe.nuevoDestinoDestinatarioCPEAutomotor({
|
|
105
|
+
await agro.cpe.nuevoDestinoDestinatarioCPEAutomotor({
|
|
106
|
+
cartaPorte,
|
|
107
|
+
destino,
|
|
108
|
+
transporte: { fechaHoraPartida, kmRecorrer },
|
|
109
|
+
});
|
|
93
110
|
await agro.cpe.regresoOrigenCPEAutomotor({ cartaPorte, transporte: { fechaHoraPartida, kmRecorrer } });
|
|
94
111
|
await agro.cpe.desvioCPEAutomotor({ cuitSolicitante, cartaPorte, destino, transporte });
|
|
95
|
-
await agro.cpe.informarContingencia({
|
|
112
|
+
await agro.cpe.informarContingencia({
|
|
113
|
+
cartaPorte,
|
|
114
|
+
contingencia: { concepto: 'C', descripcion: 'Desperfecto mecánico' },
|
|
115
|
+
});
|
|
96
116
|
await agro.cpe.cerrarContingenciaCPE({ cartaPorte, concepto: 'A' });
|
|
97
117
|
|
|
98
118
|
const detalle = await agro.cpe.consultarCPEAutomotor({ nroCTG: '010100012345' }); // o { cartaPorte }
|
|
@@ -107,8 +127,12 @@ Las operaciones que modifican una CPE devuelven `CPEResultado` (`{ cabecera?, pd
|
|
|
107
127
|
### Consultas y paramétricas
|
|
108
128
|
|
|
109
129
|
```ts
|
|
110
|
-
await agro.cpe.consultarUltNroOrden(1, TIPO_CPE.AUTOMOTOR);
|
|
111
|
-
await agro.cpe.consultarCPEPorDestino({
|
|
130
|
+
await agro.cpe.consultarUltNroOrden(1, TIPO_CPE.AUTOMOTOR); // número; si ARCA no lo devuelve, lanza
|
|
131
|
+
await agro.cpe.consultarCPEPorDestino({
|
|
132
|
+
planta: 1938,
|
|
133
|
+
fechaPartidaDesde: '2026-11-01',
|
|
134
|
+
fechaPartidaHasta: '2026-11-07',
|
|
135
|
+
});
|
|
112
136
|
await agro.cpe.consultarCPEPPendientesDeResolucion({ perfil: 'D', planta: 1938 });
|
|
113
137
|
await agro.cpe.consultarProvincias();
|
|
114
138
|
await agro.cpe.consultarLocalidadesPorProvincia(12);
|
|
@@ -159,7 +183,7 @@ const { autorizacion, eventos } = await agro.lpg.liquidacionAutorizar({
|
|
|
159
183
|
retenciones: [{ codigoConcepto: 'RG', baseCalculo: 7500000, alicuota: 2 }],
|
|
160
184
|
});
|
|
161
185
|
|
|
162
|
-
autorizacion.coe;
|
|
186
|
+
autorizacion.coe; // '330100012345' (string)
|
|
163
187
|
autorizacion.totalNetoAPagar; // number
|
|
164
188
|
```
|
|
165
189
|
|
|
@@ -203,13 +227,13 @@ Liquidación secundaria (`lsg*`), anticipos (`lpgAutorizarAnticipo`, `lpgCancela
|
|
|
203
227
|
|
|
204
228
|
## Errores
|
|
205
229
|
|
|
206
|
-
| Error
|
|
207
|
-
|
|
208
|
-
| `ArcaValidationError`
|
|
209
|
-
| `ArcaAgroServiceError` (extiende `ArcaServiceError`) | ARCA rechazó la operación: `errores.error[]` (y en WSLPG también `erroresFormato.error[]`). `errors[]`, `service`, `method` y `response` (el nodo completo devuelto).
|
|
210
|
-
| `ArcaSoapError`
|
|
211
|
-
| `ArcaAgroResponseError`
|
|
212
|
-
| `ArcaAuthError` / `ArcaTicketVigenteError`
|
|
230
|
+
| Error | Cuándo |
|
|
231
|
+
| ---------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
232
|
+
| `ArcaValidationError` | Datos inválidos, antes de llamar a ARCA: campo obligatorio faltante, campo desconocido, CUIT con dígito verificador incorrecto, `NaN`/`Infinity`, rangos y largos del XSD, fechas. `details[]` trae cada campo con su ruta (ej: `transporte.dominio[0]`). |
|
|
233
|
+
| `ArcaAgroServiceError` (extiende `ArcaServiceError`) | ARCA rechazó la operación: `errores.error[]` (y en WSLPG también `erroresFormato.error[]`). `errors[]`, `service`, `method` y `response` (el nodo completo devuelto). |
|
|
234
|
+
| `ArcaSoapError` | Red, timeout, HTTP o SOAP Fault. `uncertain` indica si ARCA pudo haber procesado el request. |
|
|
235
|
+
| `ArcaAgroResponseError` | La respuesta no trae un dato imprescindible (ej: `nroCTG` al autorizar, `coe` al liquidar, `nroOrden` al consultar el último). `uncertain` es `true` en emisiones. |
|
|
236
|
+
| `ArcaAuthError` / `ArcaTicketVigenteError` | Errores de WSAA. |
|
|
213
237
|
|
|
214
238
|
Los montos se redondean a los decimales del XSD (`fractionDigits`). Las fechas `xsd:date` aceptan `Date` o `AAAAMMDD`/`AAAA-MM-DD`; las `xsd:dateTime` aceptan `Date` (se envía en hora de Argentina, `-03:00`) o un string ISO-8601.
|
|
215
239
|
|
|
@@ -248,7 +272,7 @@ try {
|
|
|
248
272
|
## Estado de los servicios
|
|
249
273
|
|
|
250
274
|
```ts
|
|
251
|
-
const estado = await agro.
|
|
275
|
+
const estado = await agro.status();
|
|
252
276
|
// { cpe: { ok: true, status: { appserver, dbserver, authserver } }, lpg: { ok: false, error } }
|
|
253
277
|
```
|
|
254
278
|
|
|
@@ -269,31 +293,31 @@ También se puede pasar `onEvent` en la configuración. Los errores de los handl
|
|
|
269
293
|
|
|
270
294
|
`ArcaAgroConfig` extiende `ArcaBaseConfig` de `@ramiidv/arca-common`.
|
|
271
295
|
|
|
272
|
-
| Opción
|
|
273
|
-
|
|
274
|
-
| `cuit`
|
|
275
|
-
| `cert` / `key`
|
|
276
|
-
| `production`
|
|
277
|
-
| `timeout`
|
|
278
|
-
| `retries`
|
|
279
|
-
| `retryDelayMs`
|
|
280
|
-
| `tokenTTLMinutes`
|
|
281
|
-
| `ticketStorage`
|
|
282
|
-
| `clockOffsetMs` / `autoClockSkew` |
|
|
283
|
-
| `loginErrorCooldownMs`
|
|
284
|
-
| `fetch`
|
|
285
|
-
| `legacyTls`
|
|
286
|
-
| `endpoints`
|
|
287
|
-
| `onEvent`
|
|
296
|
+
| Opción | Tipo | Default | Descripción |
|
|
297
|
+
| --------------------------------- | ------------------------------- | ------------- | ----------------------------------------------------------- |
|
|
298
|
+
| `cuit` | `number \| string` | **requerido** | CUIT representada (con o sin guiones) |
|
|
299
|
+
| `cert` / `key` | `string` | **requerido** | Certificado y clave privada PEM |
|
|
300
|
+
| `production` | `boolean` | `false` | Entorno de producción |
|
|
301
|
+
| `timeout` | `number` | `30000` | Timeout HTTP (ms) |
|
|
302
|
+
| `retries` | `number` | `1` | Reintentos de consultas (las emisiones nunca se reintentan) |
|
|
303
|
+
| `retryDelayMs` | `number` | `1000` | Delay base entre reintentos (ms) |
|
|
304
|
+
| `tokenTTLMinutes` | `number` | `720` | Vida del ticket WSAA |
|
|
305
|
+
| `ticketStorage` | `TicketStorage` | memoria | Persistencia del ticket WSAA (recomendado en producción) |
|
|
306
|
+
| `clockOffsetMs` / `autoClockSkew` | | `0` / `true` | Desfase de reloj con ARCA |
|
|
307
|
+
| `loginErrorCooldownMs` | `number` | `60000` | Espera tras un login WSAA fallido |
|
|
308
|
+
| `fetch` | `typeof fetch` | global | `fetch` propio (proxy, tests) |
|
|
309
|
+
| `legacyTls` | `'auto' \| 'never' \| 'always'` | `'auto'` | Transporte TLS legacy |
|
|
310
|
+
| `endpoints` | `{ cpe?, lpg?, wsaa? }` | oficiales | Endpoints propios |
|
|
311
|
+
| `onEvent` | `function` | | Callback de eventos |
|
|
288
312
|
|
|
289
313
|
`clearAuthCache()` (async) invalida los tickets de WSCPE y WSLPG.
|
|
290
314
|
|
|
291
315
|
## Endpoints
|
|
292
316
|
|
|
293
|
-
| Servicio | Homologación
|
|
294
|
-
|
|
295
|
-
| WSCPE
|
|
296
|
-
| WSLPG
|
|
317
|
+
| Servicio | Homologación | Producción |
|
|
318
|
+
| -------- | ------------------------------------------------------- | ---------------------------------------------------- |
|
|
319
|
+
| WSCPE | `https://cpea-ws-qaext.afip.gob.ar/wscpe/services/soap` | `https://cpea-ws.afip.gob.ar/wscpe/services/soap` |
|
|
320
|
+
| WSLPG | `https://fwshomo.afip.gov.ar/wslpg/LpgService` | `https://serviciosjava.afip.gob.ar/wslpg/LpgService` |
|
|
297
321
|
|
|
298
322
|
Namespaces: WSCPE `https://serviciosjava.afip.gob.ar/wscpe/`, WSLPG `http://serviciosjava.afip.gob.ar/wslpg/`.
|
|
299
323
|
|
package/dist/arca-agro.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ArcaSdkBase } from '@ramiidv/arca-common';
|
|
2
|
+
import type { CallOptions } from '@ramiidv/arca-common';
|
|
2
3
|
import { CpeClient } from './cpe-client.js';
|
|
3
4
|
import { LpgClient } from './lpg-client.js';
|
|
5
|
+
import { WSAA_SERVICES } from './constants.js';
|
|
4
6
|
import type { AgroServiceStatus, ArcaAgroConfig } from './types.js';
|
|
7
|
+
type AgroService = keyof typeof WSAA_SERVICES;
|
|
5
8
|
/**
|
|
6
9
|
* Cliente de los servicios agropecuarios de ARCA: WSCPE (Carta de Porte
|
|
7
10
|
* Electrónica) y WSLPG (Liquidación Primaria de Granos), con autenticación
|
|
@@ -19,30 +22,26 @@ import type { AgroServiceStatus, ArcaAgroConfig } from './types.js';
|
|
|
19
22
|
* const liq = await agro.lpg.liquidacionAutorizar({ liquidacion: { ... } });
|
|
20
23
|
* ```
|
|
21
24
|
*/
|
|
22
|
-
export declare class ArcaAgro {
|
|
23
|
-
#private;
|
|
25
|
+
export declare class ArcaAgro extends ArcaSdkBase<AgroService> {
|
|
24
26
|
/** WSCPE: Carta de Porte Electrónica (automotor y ferroviaria). */
|
|
25
27
|
readonly cpe: CpeClient;
|
|
26
28
|
/** WSLPG: Liquidación Primaria de Granos y certificaciones. */
|
|
27
29
|
readonly lpg: LpgClient;
|
|
28
30
|
/** @throws ArcaValidationError si el CUIT es inválido. */
|
|
29
31
|
constructor(config: ArcaAgroConfig);
|
|
30
|
-
/**
|
|
31
|
-
* Suscribirse a eventos del SDK (`auth:*`, `request:*`).
|
|
32
|
-
* Los errores de los handlers se ignoran.
|
|
33
|
-
*/
|
|
34
|
-
on(event: ArcaEvent['type'], handler: (event: ArcaEvent) => void): this;
|
|
35
|
-
/** Desuscribirse de un evento. */
|
|
36
|
-
off(event: ArcaEvent['type'], handler: (event: ArcaEvent) => void): this;
|
|
37
32
|
/**
|
|
38
33
|
* Estado de los servidores de WSCPE y WSLPG (`dummy`, sin autenticación).
|
|
39
34
|
* Una falla de un servicio no impide conocer el estado del otro.
|
|
40
35
|
*/
|
|
36
|
+
status(opts?: CallOptions): Promise<{
|
|
37
|
+
cpe: AgroServiceStatus;
|
|
38
|
+
lpg: AgroServiceStatus;
|
|
39
|
+
}>;
|
|
40
|
+
/** @deprecated Usá `status()` (mismo resultado). */
|
|
41
41
|
serverStatus(opts?: CallOptions): Promise<{
|
|
42
42
|
cpe: AgroServiceStatus;
|
|
43
43
|
lpg: AgroServiceStatus;
|
|
44
44
|
}>;
|
|
45
|
-
/** Invalida los tickets de acceso (memoria y `ticketStorage`) de WSCPE y WSLPG. */
|
|
46
|
-
clearAuthCache(): Promise<void>;
|
|
47
45
|
}
|
|
46
|
+
export {};
|
|
48
47
|
//# sourceMappingURL=arca-agro.d.ts.map
|
package/dist/arca-agro.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arca-agro.d.ts","sourceRoot":"","sources":["../src/arca-agro.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"arca-agro.d.ts","sourceRoot":"","sources":["../src/arca-agro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAgC,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEpE,KAAK,WAAW,GAAG,MAAM,OAAO,aAAa,CAAC;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,QAAS,SAAQ,WAAW,CAAC,WAAW,CAAC;IACpD,mEAAmE;IACnE,SAAgB,GAAG,EAAE,SAAS,CAAC;IAC/B,+DAA+D;IAC/D,SAAgB,GAAG,EAAE,SAAS,CAAC;IAE/B,0DAA0D;gBAC9C,MAAM,EAAE,cAAc;IAalC;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,iBAAiB,CAAC;QAAC,GAAG,EAAE,iBAAiB,CAAA;KAAE,CAAC;IAIvF,oDAAoD;IACpD,YAAY,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,iBAAiB,CAAC;QAAC,GAAG,EAAE,iBAAiB,CAAA;KAAE,CAAC;CAG9F"}
|
package/dist/arca-agro.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { WsaaClient, safeEmit, validateCuit } from '@ramiidv/arca-common';
|
|
1
|
+
import { ArcaSdkBase, statusOf } from '@ramiidv/arca-common';
|
|
3
2
|
import { CpeClient } from './cpe-client.js';
|
|
4
3
|
import { LpgClient } from './lpg-client.js';
|
|
5
4
|
import { CPE_ENDPOINTS, LPG_ENDPOINTS, WSAA_SERVICES } from './constants.js';
|
|
@@ -20,87 +19,34 @@ import { CPE_ENDPOINTS, LPG_ENDPOINTS, WSAA_SERVICES } from './constants.js';
|
|
|
20
19
|
* const liq = await agro.lpg.liquidacionAutorizar({ liquidacion: { ... } });
|
|
21
20
|
* ```
|
|
22
21
|
*/
|
|
23
|
-
export class ArcaAgro {
|
|
22
|
+
export class ArcaAgro extends ArcaSdkBase {
|
|
24
23
|
/** WSCPE: Carta de Porte Electrónica (automotor y ferroviaria). */
|
|
25
24
|
cpe;
|
|
26
25
|
/** WSLPG: Liquidación Primaria de Granos y certificaciones. */
|
|
27
26
|
lpg;
|
|
28
|
-
#wsaa;
|
|
29
|
-
#emitter = new EventEmitter();
|
|
30
27
|
/** @throws ArcaValidationError si el CUIT es inválido. */
|
|
31
28
|
constructor(config) {
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
cert: config.cert,
|
|
40
|
-
key: config.key,
|
|
41
|
-
production,
|
|
42
|
-
endpoint: config.endpoints?.wsaa,
|
|
43
|
-
tokenTTLMinutes: config.tokenTTLMinutes,
|
|
44
|
-
timeout: config.timeout,
|
|
45
|
-
retries: config.retries,
|
|
46
|
-
retryDelayMs: config.retryDelayMs,
|
|
47
|
-
onEvent: emit,
|
|
48
|
-
ticketStorage: config.ticketStorage,
|
|
49
|
-
clockOffsetMs: config.clockOffsetMs,
|
|
50
|
-
autoClockSkew: config.autoClockSkew,
|
|
51
|
-
loginErrorCooldownMs: config.loginErrorCooldownMs,
|
|
52
|
-
fetch: config.fetch,
|
|
53
|
-
legacyTls: config.legacyTls,
|
|
29
|
+
super(config, WSAA_SERVICES);
|
|
30
|
+
const context = (service, endpoint) => ({
|
|
31
|
+
endpoint,
|
|
32
|
+
cuit: this.cuit,
|
|
33
|
+
transport: this.transport,
|
|
34
|
+
getTicket: (opts) => this.ticket(service, opts),
|
|
35
|
+
callOptions: (opts) => this.callOptions(opts),
|
|
54
36
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
retries: config.retries,
|
|
58
|
-
retryDelayMs: config.retryDelayMs,
|
|
59
|
-
onEvent: emit,
|
|
60
|
-
fetch: config.fetch,
|
|
61
|
-
legacyTls: config.legacyTls,
|
|
62
|
-
};
|
|
63
|
-
const env = production ? 'production' : 'testing';
|
|
64
|
-
this.cpe = new CpeClient({
|
|
65
|
-
endpoint: config.endpoints?.cpe ?? CPE_ENDPOINTS[env],
|
|
66
|
-
cuit,
|
|
67
|
-
soap,
|
|
68
|
-
getTicket: (opts) => this.#wsaa.getAccessTicket(WSAA_SERVICES.cpe, opts),
|
|
69
|
-
});
|
|
70
|
-
this.lpg = new LpgClient({
|
|
71
|
-
endpoint: config.endpoints?.lpg ?? LPG_ENDPOINTS[env],
|
|
72
|
-
cuit,
|
|
73
|
-
soap,
|
|
74
|
-
getTicket: (opts) => this.#wsaa.getAccessTicket(WSAA_SERVICES.lpg, opts),
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Suscribirse a eventos del SDK (`auth:*`, `request:*`).
|
|
79
|
-
* Los errores de los handlers se ignoran.
|
|
80
|
-
*/
|
|
81
|
-
on(event, handler) {
|
|
82
|
-
this.#emitter.on(event, handler);
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
/** Desuscribirse de un evento. */
|
|
86
|
-
off(event, handler) {
|
|
87
|
-
this.#emitter.off(event, handler);
|
|
88
|
-
return this;
|
|
37
|
+
this.cpe = new CpeClient(context('cpe', this.endpoint(CPE_ENDPOINTS, config.endpoints?.cpe)));
|
|
38
|
+
this.lpg = new LpgClient(context('lpg', this.endpoint(LPG_ENDPOINTS, config.endpoints?.lpg)));
|
|
89
39
|
}
|
|
90
40
|
/**
|
|
91
41
|
* Estado de los servidores de WSCPE y WSLPG (`dummy`, sin autenticación).
|
|
92
42
|
* Una falla de un servicio no impide conocer el estado del otro.
|
|
93
43
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const toStatus = (r) => r.status === 'fulfilled'
|
|
97
|
-
? { ok: true, status: r.value }
|
|
98
|
-
: { ok: false, error: r.reason instanceof Error ? r.reason : new Error(String(r.reason)) };
|
|
99
|
-
return { cpe: toStatus(cpe), lpg: toStatus(lpg) };
|
|
44
|
+
status(opts) {
|
|
45
|
+
return statusOf({ cpe: () => this.cpe.dummy(opts), lpg: () => this.lpg.dummy(opts) });
|
|
100
46
|
}
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
|
|
47
|
+
/** @deprecated Usá `status()` (mismo resultado). */
|
|
48
|
+
serverStatus(opts) {
|
|
49
|
+
return this.status(opts);
|
|
104
50
|
}
|
|
105
51
|
}
|
|
106
52
|
//# sourceMappingURL=arca-agro.js.map
|
package/dist/arca-agro.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arca-agro.js","sourceRoot":"","sources":["../src/arca-agro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"arca-agro.js","sourceRoot":"","sources":["../src/arca-agro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAA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QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACF"}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AccessTicket, CallOptions,
|
|
1
|
+
import type { AccessTicket, CallOptions, ServiceTransport } from '@ramiidv/arca-common';
|
|
2
2
|
/**
|
|
3
3
|
* Contexto que `ArcaAgro` le pasa a cada sub-cliente.
|
|
4
4
|
* @internal
|
|
@@ -7,7 +7,10 @@ export interface ServiceContext {
|
|
|
7
7
|
readonly endpoint: string;
|
|
8
8
|
/** CUIT representada, normalizada a 11 dígitos. */
|
|
9
9
|
readonly cuit: string;
|
|
10
|
+
readonly transport: ServiceTransport;
|
|
11
|
+
/** Ticket de acceso del servicio (ya combina el `signal` global). */
|
|
10
12
|
readonly getTicket: (opts?: CallOptions) => Promise<AccessTicket>;
|
|
11
|
-
|
|
13
|
+
/** Combina el `signal` global de `ArcaAgro` con el de la llamada. */
|
|
14
|
+
readonly callOptions: (opts?: CallOptions) => CallOptions;
|
|
12
15
|
}
|
|
13
16
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExF;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,qEAAqE;IACrE,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAClE,qEAAqE;IACrE,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,WAAW,CAAC;CAC3D"}
|
package/dist/cpe-client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SoapServiceClient } from '@ramiidv/arca-common';
|
|
1
2
|
import type { CallOptions, ServerStatus } from '@ramiidv/arca-common';
|
|
2
3
|
import type { ServiceContext } from './context.js';
|
|
3
4
|
import type { CodigoDescripcion } from './types.js';
|
|
@@ -13,7 +14,7 @@ import type { CuitInput } from './types.js';
|
|
|
13
14
|
* reintentan y, si la respuesta se pierde, el `ArcaSoapError` tiene
|
|
14
15
|
* `uncertain: true` (ver README, "Recuperar una emisión incierta").
|
|
15
16
|
*/
|
|
16
|
-
export declare class CpeClient {
|
|
17
|
+
export declare class CpeClient extends SoapServiceClient {
|
|
17
18
|
#private;
|
|
18
19
|
/** @internal Se construye desde `ArcaAgro`. */
|
|
19
20
|
constructor(ctx: ServiceContext);
|
package/dist/cpe-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpe-client.d.ts","sourceRoot":"","sources":["../src/cpe-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cpe-client.d.ts","sourceRoot":"","sources":["../src/cpe-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAqB,MAAM,sBAAsB,CAAC;AAEzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAKnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EACV,eAAe,EACf,2BAA2B,EAC3B,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AAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ/F,kBAAkB;IACZ,mBAAmB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAI3E,oCAAoC;IAC9B,gCAAgC,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAK9G,sBAAsB;IAChB,mBAAmB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAI3E,sCAAsC;IAChC,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAKjF,4CAA4C;IACtC,6BAA6B,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAK1G,8BAA8B;IACxB,2BAA2B,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAInF,iEAAiE;IAC3D,2BAA2B,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAKvG,qEAAqE;IAC/D,KAAK,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;CAGvD"}
|
package/dist/cpe-client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SoapServiceClient, parseServerStatus } from '@ramiidv/arca-common';
|
|
2
2
|
import { CPE_NAMESPACE } from './constants.js';
|
|
3
3
|
import { ArcaAgroResponseError, throwOnServiceErrors } from './errors.js';
|
|
4
4
|
import { decodeResponse, encodeRequest, int, list, must, obj } from './schema.js';
|
|
@@ -16,10 +16,11 @@ const listOf = (name, item) => ({ [name]: list(obj(item), 0) });
|
|
|
16
16
|
* reintentan y, si la respuesta se pierde, el `ArcaSoapError` tiene
|
|
17
17
|
* `uncertain: true` (ver README, "Recuperar una emisión incierta").
|
|
18
18
|
*/
|
|
19
|
-
export class CpeClient {
|
|
19
|
+
export class CpeClient extends SoapServiceClient {
|
|
20
20
|
#ctx;
|
|
21
21
|
/** @internal Se construye desde `ArcaAgro`. */
|
|
22
22
|
constructor(ctx) {
|
|
23
|
+
super({ endpoint: ctx.endpoint, namespace: CPE_NAMESPACE, transport: ctx.transport });
|
|
23
24
|
this.#ctx = ctx;
|
|
24
25
|
}
|
|
25
26
|
// ============================================================
|
|
@@ -37,13 +38,13 @@ export class CpeClient {
|
|
|
37
38
|
async #call(method, body, kind, opts) {
|
|
38
39
|
const element = method.charAt(0).toUpperCase() + method.slice(1);
|
|
39
40
|
const params = body === null ? {} : { auth: await this.#auth(opts), ...body };
|
|
40
|
-
const result = await
|
|
41
|
-
...this.#ctx.soap,
|
|
41
|
+
const result = await this.soapCall(method, params, {
|
|
42
42
|
kind,
|
|
43
|
-
signal: opts
|
|
43
|
+
signal: this.#ctx.callOptions(opts).signal,
|
|
44
44
|
requestElement: body === null ? null : `${element}Req`,
|
|
45
45
|
responseElement: `${element}Resp`,
|
|
46
46
|
soapActionFromMethod: true,
|
|
47
|
+
parseNumbers: false,
|
|
47
48
|
});
|
|
48
49
|
// `<respuesta/>` vacía (ej: una lista sin resultados) se parsea como ''.
|
|
49
50
|
const respuesta = result['respuesta'] === '' ? {} : result['respuesta'];
|
|
@@ -218,7 +219,8 @@ export class CpeClient {
|
|
|
218
219
|
async consultarUltNroOrden(sucursal, tipoCPE, opts) {
|
|
219
220
|
const solicitud = encodeRequest({ sucursal, tipoCPE }, S.CONSULTAR_ULT_NRO_ORDEN, 'consultarUltNroOrden');
|
|
220
221
|
const r = await this.#call('consultarUltNroOrden', { solicitud }, 'consulta', opts);
|
|
221
|
-
return this.#decode(r, { nroOrden: must(int()) }, 'consultarUltNroOrden', 'consulta')
|
|
222
|
+
return this.#decode(r, { nroOrden: must(int()) }, 'consultarUltNroOrden', 'consulta')
|
|
223
|
+
.nroOrden;
|
|
222
224
|
}
|
|
223
225
|
/**
|
|
224
226
|
* Número de orden siguiente al último autorizado (`consultarUltNroOrden + 1`).
|
|
@@ -268,8 +270,7 @@ export class CpeClient {
|
|
|
268
270
|
}
|
|
269
271
|
/** Estado de los servidores de WSCPE (no requiere autenticación). */
|
|
270
272
|
async dummy(opts) {
|
|
271
|
-
|
|
272
|
-
return this.#decode(r, S.R_DUMMY, 'dummy', 'consulta');
|
|
273
|
+
return parseServerStatus(await this.#call('dummy', null, 'consulta', opts));
|
|
273
274
|
}
|
|
274
275
|
}
|
|
275
276
|
//# sourceMappingURL=cpe-client.js.map
|