@ramiidv/arca-agro 0.1.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/llms.txt ADDED
@@ -0,0 +1,187 @@
1
+ # @ramiidv/arca-agro - Technical Reference
2
+
3
+ ## Overview
4
+
5
+ TypeScript SDK for ARCA (Argentina's tax authority, formerly AFIP) agricultural web services. Bundles three SOAP services into a single package with automatic WSAA authentication.
6
+
7
+ - **WSCPE** - Carta de Porte Electrónica: electronic bill of lading for grain transport
8
+ - **WSCTG** - Código de Trazabilidad de Granos: grain traceability codes
9
+ - **WSLPG** - Liquidación Primaria de Granos: primary grain settlement and certification
10
+
11
+ ## Architecture
12
+
13
+ ```
14
+ ArcaAgro (orchestrator)
15
+ ├── .cpe → CpeClient (WSCPE) → WSAA service: "wscpe"
16
+ ├── .ctg → CtgClient (WSCTG) → WSAA service: "wsctg"
17
+ └── .lpg → LpgClient (WSLPG) → WSAA service: "wslpg"
18
+ ```
19
+
20
+ All shared utilities (WsaaClient, afipSoapCall, errors, types) come from `@ramiidv/arca-common`. No duplication.
21
+
22
+ ## WSAA Service Identifiers
23
+
24
+ | Service | WSAA ID |
25
+ |---------|---------|
26
+ | WSCPE | `wscpe` |
27
+ | WSCTG | `wsctg` |
28
+ | WSLPG | `wslpg` |
29
+
30
+ ## Endpoints
31
+
32
+ ### WSCPE
33
+ - Testing: `https://fwshomo.afip.gov.ar/wscpe/services/soap`
34
+ - Production: `https://serviciosjava.afip.gob.ar/wscpe/services/soap`
35
+
36
+ ### WSCTG
37
+ - Testing: `https://fwshomo.afip.gov.ar/wsctg/services/CTGService_v4.0`
38
+ - Production: `https://serviciosjava.afip.gob.ar/wsctg/services/CTGService_v4.0`
39
+
40
+ ### WSLPG
41
+ - Testing: `https://fwshomo.afip.gov.ar/wslpg/LpgService`
42
+ - Production: `https://serviciosjava.afip.gob.ar/wslpg/LpgService`
43
+
44
+ ## API Methods
45
+
46
+ ### agro.cpe.* (WSCPE)
47
+
48
+ | Method | Description |
49
+ |--------|-------------|
50
+ | `autorizarCPEAutomotor(cpe)` | Authorize electronic bill of lading for road transport |
51
+ | `confirmadoArriboCPE(params)` | Confirm arrival at destination |
52
+ | `rechazoCPE(params)` | Reject a CPE |
53
+ | `anularCPE(params)` | Cancel a CPE |
54
+ | `editarCPE(params)` | Edit fields of an authorized CPE |
55
+ | `informarContingencia(params)` | Report a contingency on a CPE |
56
+ | `consultarCPE(params)` | Query CPEs by search criteria |
57
+ | `consultarCPEPorDestino(params)` | Query CPEs by destination |
58
+ | `consultarUltNroOrden(sucursal)` | Get last order number for a branch |
59
+ | `siguienteNroOrden(sucursal)` | Get next order number (last + 1) |
60
+ | `consultarConstanciaCPEPDF(nroCTG)` | Get CPE certificate as base64 PDF |
61
+ | `dummy()` | Check WSCPE server status |
62
+
63
+ ### agro.ctg.* (WSCTG)
64
+
65
+ | Method | Description |
66
+ |--------|-------------|
67
+ | `solicitarCTGInicial(solicitud)` | Request initial CTG for grain transport |
68
+ | `confirmarArribo(params)` | Confirm CTG arrival at destination |
69
+ | `rechazarCTG(params)` | Reject a CTG |
70
+ | `anularCTG(params)` | Cancel a CTG |
71
+ | `consultarCTG(params)` | Query CTGs by search criteria |
72
+ | `consultarCTGExcel(params)` | Query CTGs and get Excel export (base64) |
73
+ | `consultarConstanciaCTGPDF(nroCTG)` | Get CTG certificate as base64 PDF |
74
+ | `obtenerCTGActivos()` | Get active (pending) CTGs |
75
+ | `dummy()` | Check WSCTG server status |
76
+
77
+ ### agro.lpg.* (WSLPG)
78
+
79
+ | Method | Description |
80
+ |--------|-------------|
81
+ | `liquidacionAutorizar(liquidacion)` | Authorize a primary grain settlement |
82
+ | `liquidacionConsultar(params)` | Query authorized settlements |
83
+ | `liquidacionAnular(ptoEmision, nroOrden)` | Cancel a settlement |
84
+ | `liquidacionAjustarUnificado(params)` | Unified adjustment (debit/credit) |
85
+ | `certificacionAutorizar(certificacion)` | Authorize a grain certification |
86
+ | `certificacionAnular(tipo, nro)` | Cancel a certification |
87
+ | `consultarParametros(tipo, params?)` | Query WSLPG parameters (grain types, grades, ports, etc.) |
88
+ | `dummy()` | Check WSLPG server status |
89
+
90
+ ### Global
91
+
92
+ | Method | Description |
93
+ |--------|-------------|
94
+ | `serverStatus()` | Check all 3 services at once |
95
+ | `clearAuthCache()` | Invalidate all cached WSAA tokens |
96
+ | `on(event, handler)` | Subscribe to SDK events |
97
+ | `off(event, handler)` | Unsubscribe from events |
98
+
99
+ ## Key Types
100
+
101
+ ### Configuration
102
+
103
+ ```ts
104
+ interface ArcaAgroConfig {
105
+ cuit: number;
106
+ cert: string; // PEM certificate
107
+ key: string; // PEM private key
108
+ production?: boolean; // default: false
109
+ tokenTTLMinutes?: number; // default: 720
110
+ requestTimeoutMs?: number; // default: 30000
111
+ retries?: number; // default: 1
112
+ retryDelayMs?: number; // default: 1000
113
+ onEvent?: (event: ArcaEvent) => void;
114
+ }
115
+ ```
116
+
117
+ ### CPE Types
118
+
119
+ - `CartaPorteAutomotor` - Input for CPE authorization
120
+ - `CartaPorteResult` - CPE operation result (nroCTG, nroCartaPorte, estado, errores, raw)
121
+ - `ConsultaCPEParams` - CPE query parameters
122
+ - `ConfirmadoArriboCPEParams` - Arrival confirmation input
123
+ - `RechazoAnulacionCPEParams` - Rejection/cancellation input
124
+ - `EditarCPEParams` - Edit input
125
+ - `ContingenciaCPEParams` - Contingency report input
126
+
127
+ ### CTG Types
128
+
129
+ - `SolicitudCTG` - Input for CTG request
130
+ - `CTGResult` - CTG operation result (nroCTG, estado, vigencia, errores, raw)
131
+ - `ConsultaCTGParams` - CTG query parameters
132
+ - `ConfirmarArriboCTGParams` - Arrival confirmation input
133
+ - `RechazoCTGParams` - Rejection input
134
+ - `AnulacionCTGParams` - Cancellation input
135
+ - `CTGActivosResult` - Active CTGs result
136
+
137
+ ### LPG Types
138
+
139
+ - `Liquidacion` - Input for settlement authorization
140
+ - `LiquidacionResult` - Settlement result (codOperacion, nroOrden, totalPagar, errores, raw)
141
+ - `ConsultaLiquidacionParams` - Settlement query parameters
142
+ - `AjusteUnificadoParams` - Unified adjustment input
143
+ - `Certificacion` - Certification input
144
+ - `CertificacionResult` - Certification result
145
+
146
+ ## Error Hierarchy
147
+
148
+ All errors extend from `ArcaError` (from `@ramiidv/arca-common`):
149
+
150
+ - `ArcaAuthError` - WSAA authentication failures
151
+ - `ArcaSoapError` - HTTP/SOAP transport errors (includes `statusCode`)
152
+ - `ArcaServiceError` - Business logic errors from ARCA (includes `errors[]` with code + msg)
153
+ - `ArcaValidationError` - Input validation errors
154
+
155
+ ## Low-Level Clients
156
+
157
+ For direct control over auth, use the individual clients:
158
+
159
+ ```ts
160
+ import { CpeClient, CtgClient, LpgClient } from '@ramiidv/arca-agro';
161
+ import { WsaaClient } from '@ramiidv/arca-common';
162
+
163
+ const cpe = new CpeClient(production, { timeoutMs, retries, retryDelayMs, onEvent });
164
+ const ctg = new CtgClient(production, { ... });
165
+ const lpg = new LpgClient(production, { ... });
166
+ ```
167
+
168
+ Each client method takes `auth: AgroAuth` as first parameter:
169
+ ```ts
170
+ interface AgroAuth { Token: string; Sign: string; Cuit: number; }
171
+ ```
172
+
173
+ ## Source Files
174
+
175
+ | File | Purpose |
176
+ |------|---------|
177
+ | `src/constants.ts` | Endpoints, namespaces, WSAA service IDs |
178
+ | `src/types.ts` | All TypeScript interfaces for the 3 services |
179
+ | `src/cpe-client.ts` | Low-level WSCPE SOAP client |
180
+ | `src/ctg-client.ts` | Low-level WSCTG SOAP client |
181
+ | `src/lpg-client.ts` | Low-level WSLPG SOAP client |
182
+ | `src/arca-agro.ts` | Main orchestrator with auto-auth and namespaced API |
183
+ | `src/index.ts` | Public exports |
184
+
185
+ ## Dependencies
186
+
187
+ - `@ramiidv/arca-common` (^0.1.0) - WsaaClient, afipSoapCall, errors, types, validators
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@ramiidv/arca-agro",
3
+ "version": "0.1.0",
4
+ "description": "SDK para servicios agropecuarios de ARCA (ex AFIP) - WSCPE, WSCTG, WSLPG",
5
+ "author": "ramiidv",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "sideEffects": false,
18
+ "files": [
19
+ "dist",
20
+ "README.md",
21
+ "LICENSE",
22
+ "llms.txt"
23
+ ],
24
+ "scripts": {
25
+ "build": "tsc",
26
+ "clean": "rm -rf dist",
27
+ "dev": "tsc --watch",
28
+ "typecheck": "tsc --noEmit",
29
+ "test": "vitest run",
30
+ "test:watch": "vitest",
31
+ "prepublishOnly": "npm run clean && npm run build"
32
+ },
33
+ "keywords": [
34
+ "arca",
35
+ "afip",
36
+ "agro",
37
+ "granos",
38
+ "carta-de-porte",
39
+ "ctg",
40
+ "liquidacion",
41
+ "argentina",
42
+ "wscpe",
43
+ "wsctg",
44
+ "wslpg",
45
+ "soap",
46
+ "sdk",
47
+ "typescript"
48
+ ],
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/ramiidv/arca-agro.git"
52
+ },
53
+ "homepage": "https://github.com/ramiidv/arca-agro#readme",
54
+ "bugs": {
55
+ "url": "https://github.com/ramiidv/arca-agro/issues"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public"
59
+ },
60
+ "engines": {
61
+ "node": ">=18.0.0"
62
+ },
63
+ "dependencies": {
64
+ "@ramiidv/arca-common": "^0.1.0"
65
+ },
66
+ "devDependencies": {
67
+ "@types/node": "^22.0.0",
68
+ "typescript": "^5.7.0",
69
+ "vitest": "^3.1.0"
70
+ }
71
+ }