@ramiidv/arca-fecred 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/LICENSE +21 -0
- package/README.md +351 -0
- package/dist/arca-fecred.d.ts +129 -0
- package/dist/arca-fecred.d.ts.map +1 -0
- package/dist/arca-fecred.js +365 -0
- package/dist/arca-fecred.js.map +1 -0
- package/dist/constants.d.ts +83 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +108 -0
- package/dist/constants.js.map +1 -0
- package/dist/fecred-client.d.ts +100 -0
- package/dist/fecred-client.d.ts.map +1 -0
- package/dist/fecred-client.js +194 -0
- package/dist/fecred-client.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +208 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +26 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +161 -0
- package/dist/validation.js.map +1 -0
- package/llms.txt +173 -0
- package/package.json +65 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { ArcaValidationError } from '@ramiidv/arca-common';
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// CUIT validation
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
/**
|
|
6
|
+
* Validates a CUIT value. Must be a positive number or a non-empty numeric string.
|
|
7
|
+
* @param cuit - Value to validate
|
|
8
|
+
* @param fieldName - Field name for error messages (default: "cuit")
|
|
9
|
+
* @returns The CUIT as a string
|
|
10
|
+
* @throws ArcaValidationError if the CUIT is invalid
|
|
11
|
+
*/
|
|
12
|
+
export function validateCuit(cuit, fieldName = 'cuit') {
|
|
13
|
+
if (typeof cuit === 'number') {
|
|
14
|
+
if (!Number.isFinite(cuit) || cuit <= 0 || !Number.isInteger(cuit)) {
|
|
15
|
+
throw new ArcaValidationError(`${fieldName} debe ser un numero entero positivo.`, [{ field: fieldName, message: 'Debe ser un numero entero positivo', value: cuit }], fieldName);
|
|
16
|
+
}
|
|
17
|
+
return String(cuit);
|
|
18
|
+
}
|
|
19
|
+
if (typeof cuit === 'string') {
|
|
20
|
+
const trimmed = cuit.trim();
|
|
21
|
+
if (trimmed.length === 0) {
|
|
22
|
+
throw new ArcaValidationError(`${fieldName} no puede estar vacio.`, [{ field: fieldName, message: 'No puede estar vacio', value: cuit }], fieldName);
|
|
23
|
+
}
|
|
24
|
+
// Allow formats: 20123456789 or 20-12345678-9
|
|
25
|
+
const normalized = trimmed.replace(/-/g, '');
|
|
26
|
+
if (!/^\d+$/.test(normalized)) {
|
|
27
|
+
throw new ArcaValidationError(`${fieldName} debe contener solo digitos (opcionalmente separados por guiones).`, [{ field: fieldName, message: 'Debe contener solo digitos', value: cuit }], fieldName);
|
|
28
|
+
}
|
|
29
|
+
return trimmed;
|
|
30
|
+
}
|
|
31
|
+
throw new ArcaValidationError(`${fieldName} debe ser un numero o string.`, [{ field: fieldName, message: 'Debe ser un numero o string', value: cuit }], fieldName);
|
|
32
|
+
}
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// CodCtaCte validation
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
/**
|
|
37
|
+
* Validates a CodCtaCte (current account code).
|
|
38
|
+
* Must be a non-empty string or a positive number.
|
|
39
|
+
* @param cod - Value to validate
|
|
40
|
+
* @returns The code as a number
|
|
41
|
+
* @throws ArcaValidationError if the code is invalid
|
|
42
|
+
*/
|
|
43
|
+
export function validateCodCtaCte(cod) {
|
|
44
|
+
if (typeof cod === 'number') {
|
|
45
|
+
if (!Number.isFinite(cod) || cod <= 0 || !Number.isInteger(cod)) {
|
|
46
|
+
throw new ArcaValidationError('codCtaCte debe ser un numero entero positivo.', [{ field: 'codCtaCte', message: 'Debe ser un numero entero positivo', value: cod }], 'codCtaCte');
|
|
47
|
+
}
|
|
48
|
+
return cod;
|
|
49
|
+
}
|
|
50
|
+
if (typeof cod === 'string') {
|
|
51
|
+
const trimmed = cod.trim();
|
|
52
|
+
if (trimmed.length === 0) {
|
|
53
|
+
throw new ArcaValidationError('codCtaCte no puede estar vacio.', [{ field: 'codCtaCte', message: 'No puede estar vacio', value: cod }], 'codCtaCte');
|
|
54
|
+
}
|
|
55
|
+
const num = Number(trimmed);
|
|
56
|
+
if (!Number.isFinite(num) || num <= 0 || !Number.isInteger(num)) {
|
|
57
|
+
throw new ArcaValidationError('codCtaCte debe ser un numero entero positivo.', [{ field: 'codCtaCte', message: 'Debe ser un numero entero positivo', value: cod }], 'codCtaCte');
|
|
58
|
+
}
|
|
59
|
+
return num;
|
|
60
|
+
}
|
|
61
|
+
throw new ArcaValidationError('codCtaCte es requerido.', [{ field: 'codCtaCte', message: 'Es requerido', value: cod }], 'codCtaCte');
|
|
62
|
+
}
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
// ConsultarCtasCtes params validation
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
/**
|
|
67
|
+
* Validates parameters for consultarCtasCtes.
|
|
68
|
+
* Requires rol, fechaDesde, fechaHasta, and at least one of CUITEmisor or CUITReceptor
|
|
69
|
+
* (depending on the role).
|
|
70
|
+
* @param params - Parameters to validate
|
|
71
|
+
* @throws ArcaValidationError if required fields are missing or invalid
|
|
72
|
+
*/
|
|
73
|
+
export function validateConsultaCtasCtes(params) {
|
|
74
|
+
const errors = [];
|
|
75
|
+
// Validate rol
|
|
76
|
+
if (!params.rol || typeof params.rol !== 'string' || params.rol.trim().length === 0) {
|
|
77
|
+
errors.push({
|
|
78
|
+
field: 'rol',
|
|
79
|
+
message: 'rol es requerido (debe ser "Emisor" o "Receptor")',
|
|
80
|
+
value: params.rol,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const rolNorm = params.rol.trim();
|
|
85
|
+
if (rolNorm !== 'Emisor' && rolNorm !== 'Receptor') {
|
|
86
|
+
errors.push({
|
|
87
|
+
field: 'rol',
|
|
88
|
+
message: 'rol debe ser "Emisor" o "Receptor"',
|
|
89
|
+
value: params.rol,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Validate fechaDesde
|
|
94
|
+
if (!params.fechaDesde || typeof params.fechaDesde !== 'string' || params.fechaDesde.trim().length === 0) {
|
|
95
|
+
errors.push({
|
|
96
|
+
field: 'fechaDesde',
|
|
97
|
+
message: 'fechaDesde es requerido',
|
|
98
|
+
value: params.fechaDesde,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
else if (!isValidDateString(params.fechaDesde)) {
|
|
102
|
+
errors.push({
|
|
103
|
+
field: 'fechaDesde',
|
|
104
|
+
message: 'fechaDesde debe ser una fecha valida (YYYY-MM-DD)',
|
|
105
|
+
value: params.fechaDesde,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
// Validate fechaHasta
|
|
109
|
+
if (!params.fechaHasta || typeof params.fechaHasta !== 'string' || params.fechaHasta.trim().length === 0) {
|
|
110
|
+
errors.push({
|
|
111
|
+
field: 'fechaHasta',
|
|
112
|
+
message: 'fechaHasta es requerido',
|
|
113
|
+
value: params.fechaHasta,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
else if (!isValidDateString(params.fechaHasta)) {
|
|
117
|
+
errors.push({
|
|
118
|
+
field: 'fechaHasta',
|
|
119
|
+
message: 'fechaHasta debe ser una fecha valida (YYYY-MM-DD)',
|
|
120
|
+
value: params.fechaHasta,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// Validate date range
|
|
124
|
+
if (params.fechaDesde && params.fechaHasta && isValidDateString(params.fechaDesde) && isValidDateString(params.fechaHasta)) {
|
|
125
|
+
if (params.fechaDesde > params.fechaHasta) {
|
|
126
|
+
errors.push({
|
|
127
|
+
field: 'fechaHasta',
|
|
128
|
+
message: 'fechaHasta debe ser igual o posterior a fechaDesde',
|
|
129
|
+
value: { fechaDesde: params.fechaDesde, fechaHasta: params.fechaHasta },
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Validate that at least one CUIT is present
|
|
134
|
+
const hasCuitEmisor = params.cuitEmisor != null && String(params.cuitEmisor).trim().length > 0;
|
|
135
|
+
const hasCuitReceptor = params.cuitReceptor != null && String(params.cuitReceptor).trim().length > 0;
|
|
136
|
+
if (!hasCuitEmisor && !hasCuitReceptor) {
|
|
137
|
+
// While the WS may accept queries without CUITs in some cases,
|
|
138
|
+
// at least one is typically needed depending on the role
|
|
139
|
+
// We allow it but do not error - the service will return its own error if needed
|
|
140
|
+
}
|
|
141
|
+
if (errors.length > 0) {
|
|
142
|
+
throw new ArcaValidationError(`Parametros de consultarCtasCtes invalidos: ${errors.map((e) => e.message).join('; ')}`, errors);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// ---------------------------------------------------------------------------
|
|
146
|
+
// Helpers
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
/**
|
|
149
|
+
* Checks if a string is a valid YYYY-MM-DD date.
|
|
150
|
+
*/
|
|
151
|
+
function isValidDateString(dateStr) {
|
|
152
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(dateStr))
|
|
153
|
+
return false;
|
|
154
|
+
const date = new Date(dateStr + 'T00:00:00Z');
|
|
155
|
+
if (isNaN(date.getTime()))
|
|
156
|
+
return false;
|
|
157
|
+
// Verify the parsed date matches input (catches e.g. 2026-02-30)
|
|
158
|
+
const [y, m, d] = dateStr.split('-').map(Number);
|
|
159
|
+
return date.getUTCFullYear() === y && date.getUTCMonth() + 1 === m && date.getUTCDate() === d;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,iEAAiE;IACjE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AAChG,CAAC"}
|
package/llms.txt
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# @ramiidv/arca-fecred
|
|
2
|
+
|
|
3
|
+
> TypeScript SDK para el web service WSFECRED de ARCA (ex AFIP) - Factura de Credito Electronica MiPyME (Ley 27440)
|
|
4
|
+
|
|
5
|
+
## Instalacion
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ramiidv/arca-fecred
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requisitos: Node.js >= 18 (fetch nativo). ESM only.
|
|
12
|
+
|
|
13
|
+
## Configuracion
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { ArcaFecred } from '@ramiidv/arca-fecred';
|
|
17
|
+
|
|
18
|
+
const fecred = new ArcaFecred({
|
|
19
|
+
cert: string, // PEM X.509 certificate
|
|
20
|
+
key: string, // PEM RSA private key
|
|
21
|
+
cuit: string, // CUIT representada (ej: "20123456789")
|
|
22
|
+
production?: boolean, // default: false (homologacion)
|
|
23
|
+
timeout?: number, // default: 30000
|
|
24
|
+
retries?: number, // default: 1
|
|
25
|
+
retryDelayMs?: number, // default: 1000
|
|
26
|
+
onEvent?: (event: ArcaEvent) => void,
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Metodos principales
|
|
31
|
+
|
|
32
|
+
### consultarMontoObligadoRecepcion(cuit: string): Promise<MontoObligadoResult>
|
|
33
|
+
Verifica si una CUIT esta obligada a recibir FCE. Retorna: { cuitConsultada, obligado: boolean, montoDesde?: number, raw }.
|
|
34
|
+
|
|
35
|
+
### consultarCtasCtes(params: ConsultarCtasCtesParams): Promise<CtaCte[]>
|
|
36
|
+
Consulta cuentas corrientes de actividad FCE. Params: { rol: "Emisor"|"Receptor", cuitEmisor?, cuitReceptor?, fechaDesde, fechaHasta }. Retorna array de CtaCte.
|
|
37
|
+
|
|
38
|
+
### consultarComprobantes(params: ConsultarComprobantesParams): Promise<ComprobanteFecred[]>
|
|
39
|
+
Busca comprobantes FCE. Params: { cuitEmisor?, cuitReceptor?, codCtaCte?, fechaDesde?, fechaHasta? }. Retorna array de ComprobanteFecred.
|
|
40
|
+
|
|
41
|
+
### aceptarFECred(codCtaCte: number): Promise<AceptarFecredResult>
|
|
42
|
+
Acepta una FCE. Retorna: { codCtaCte, resultado, raw }.
|
|
43
|
+
|
|
44
|
+
### rechazarFECred(codCtaCte: number, codMotivoRechazo: number): Promise<RechazarFecredResult>
|
|
45
|
+
Rechaza una FCE. Usar MotivoRechazo enum para codMotivoRechazo. Retorna: { codCtaCte, resultado, raw }.
|
|
46
|
+
|
|
47
|
+
### informarFacturaAceptadaCancelada(params: InformarCanceladaParams): Promise<InformarCanceladaResult>
|
|
48
|
+
Informa que una FCE aceptada fue pagada. Params: { codCtaCte, codFormaCancelacion, observaciones? }. Usar FormaCancelacion enum.
|
|
49
|
+
|
|
50
|
+
### consultarTiposRetenciones(): Promise<TipoRetencionItem[]>
|
|
51
|
+
Tipos de retenciones disponibles. Retorna: { codTipoRetencion, descTipoRetencion }[].
|
|
52
|
+
|
|
53
|
+
### consultarTiposFormasCancelacion(): Promise<TipoFormaCancelacionItem[]>
|
|
54
|
+
Formas de cancelacion disponibles. Retorna: { codFormaCancelacion, descFormaCancelacion }[].
|
|
55
|
+
|
|
56
|
+
### consultarTiposAjustesOperacion(): Promise<TipoAjusteOperacionItem[]>
|
|
57
|
+
Tipos de ajustes de operacion. Retorna: { codTipoAjuste, descTipoAjuste }[].
|
|
58
|
+
|
|
59
|
+
### consultarTiposMotivoRechazo(): Promise<TipoMotivoRechazoItem[]>
|
|
60
|
+
Motivos de rechazo disponibles. Retorna: { codMotivoRechazo, descMotivoRechazo }[].
|
|
61
|
+
|
|
62
|
+
### status(): Promise<ServerStatus>
|
|
63
|
+
Health check. No requiere autenticacion. Retorna: { appserver, dbserver, authserver }.
|
|
64
|
+
|
|
65
|
+
### clearAuthCache(): void
|
|
66
|
+
Invalida el ticket de acceso cacheado para WSFECRED.
|
|
67
|
+
|
|
68
|
+
## Tipos principales
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
interface CtaCte {
|
|
72
|
+
codCtaCte: number;
|
|
73
|
+
cuitEmisor: string;
|
|
74
|
+
denominacionEmisor?: string;
|
|
75
|
+
cuitReceptor: string;
|
|
76
|
+
denominacionReceptor?: string;
|
|
77
|
+
tipoComprobante?: number;
|
|
78
|
+
puntoVenta?: number;
|
|
79
|
+
nroComprobante?: number;
|
|
80
|
+
codMoneda?: string;
|
|
81
|
+
importeTotal?: number;
|
|
82
|
+
saldo?: number;
|
|
83
|
+
estado?: string;
|
|
84
|
+
fechaEmision?: string;
|
|
85
|
+
fechaVencimientoPago?: string;
|
|
86
|
+
fechaVencimientoAceptacion?: string;
|
|
87
|
+
cae?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface ComprobanteFecred {
|
|
91
|
+
codCtaCte: number;
|
|
92
|
+
tipoComprobante?: number;
|
|
93
|
+
puntoVenta?: number;
|
|
94
|
+
nroComprobante?: number;
|
|
95
|
+
cuitEmisor: string;
|
|
96
|
+
cuitReceptor: string;
|
|
97
|
+
codMoneda?: string;
|
|
98
|
+
importeTotal?: number;
|
|
99
|
+
importeNeto?: number;
|
|
100
|
+
saldo?: number;
|
|
101
|
+
estado?: string;
|
|
102
|
+
fechaEmision?: string;
|
|
103
|
+
fechaVencimientoPago?: string;
|
|
104
|
+
cae?: string;
|
|
105
|
+
retenciones?: RetencionFecred[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface MontoObligadoResult {
|
|
109
|
+
cuitConsultada: string;
|
|
110
|
+
obligado: boolean;
|
|
111
|
+
montoDesde?: number;
|
|
112
|
+
raw: Record<string, unknown>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
interface ServerStatus {
|
|
116
|
+
appserver: string;
|
|
117
|
+
dbserver: string;
|
|
118
|
+
authserver: string;
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Errores
|
|
123
|
+
|
|
124
|
+
3-class hierarchy from @ramiidv/arca-common:
|
|
125
|
+
- ArcaError: base class
|
|
126
|
+
- ArcaAuthError: WSAA authentication failures
|
|
127
|
+
- ArcaServiceError: business errors from WSFECRED (has errors: {code: number, msg: string}[])
|
|
128
|
+
- ArcaSoapError: HTTP/transport errors (has statusCode?: number)
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { ArcaAuthError, ArcaServiceError, ArcaSoapError } from '@ramiidv/arca-fecred';
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
await fecred.aceptarFECred(codCtaCte);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
if (error instanceof ArcaAuthError) { /* auth failure */ }
|
|
137
|
+
if (error instanceof ArcaServiceError) { /* business error, check error.errors */ }
|
|
138
|
+
if (error instanceof ArcaSoapError) { /* HTTP/network error, check error.statusCode */ }
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Eventos
|
|
143
|
+
|
|
144
|
+
Discriminated union types: auth:login, auth:cache-hit, request:start, request:end, request:retry, request:error.
|
|
145
|
+
|
|
146
|
+
## Enums
|
|
147
|
+
|
|
148
|
+
- RolCtaCte (EMISOR="Emisor", RECEPTOR="Receptor")
|
|
149
|
+
- EstadoCtaCte (PENDIENTE_ACEPTACION, ACEPTADA, RECHAZADA, CANCELADA, ANULADA)
|
|
150
|
+
- MotivoRechazo (NOTA_CREDITO_DEBITO=1, CUIT_INCORRECTO=2, FECHA_INCORRECTA=3, CBU_INCORRECTO=4, OTROS=5)
|
|
151
|
+
- FormaCancelacion (ACREDITACION_CUENTA=1, TRANSFERENCIA=2, CHEQUE=3, PAGO_ELECTRONICO=4, COMPENSACION=5, ENDOSO=6, OTRO=99)
|
|
152
|
+
- TipoAjusteOperacion (NOTA_CREDITO=1, NOTA_DEBITO=2)
|
|
153
|
+
- TipoRetencion (GANANCIAS=1, IVA=2, SUSS=3, INGRESOS_BRUTOS=4, OTRAS=99)
|
|
154
|
+
|
|
155
|
+
## Clientes de bajo nivel
|
|
156
|
+
|
|
157
|
+
Accesibles como propiedades publicas: fecred.wsaa, fecred.fecred.
|
|
158
|
+
|
|
159
|
+
## SOAP details
|
|
160
|
+
|
|
161
|
+
- WSAA service ID: "wsfecred"
|
|
162
|
+
- Production endpoint: https://serviciosjava.afip.gob.ar/wsfecred/FECredService
|
|
163
|
+
- Homologation endpoint: https://fwshomo.afip.gob.ar/wsfecred/FECredService
|
|
164
|
+
- Namespace: https://serviciosjava.afip.gob.ar/wsfecred/FECredService?wsdl
|
|
165
|
+
- Uses ser: prefix (Java-based, like padron services)
|
|
166
|
+
- Auth passed as authRequest: { Token, Sign, Cuit }
|
|
167
|
+
|
|
168
|
+
## Utilidades re-exportadas de arca-common
|
|
169
|
+
|
|
170
|
+
- ensureArray<T>(value): T[] - normaliza single/array SOAP responses
|
|
171
|
+
- parseXml(xml): Record<string, unknown> - parse XML
|
|
172
|
+
- buildXml(obj): string - build XML from object
|
|
173
|
+
- checkServiceErrors(result, serviceName): void - throws ArcaServiceError if errors found
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ramiidv/arca-fecred",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK para el web service WSFECRED de ARCA (ex AFIP) - Factura de Credito Electronica MiPyME",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"llms.txt",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"clean": "rm -rf dist",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"test:watch": "vitest",
|
|
27
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"arca",
|
|
31
|
+
"afip",
|
|
32
|
+
"wsfecred",
|
|
33
|
+
"fce",
|
|
34
|
+
"factura-credito-electronica",
|
|
35
|
+
"mipyme",
|
|
36
|
+
"argentina",
|
|
37
|
+
"sdk",
|
|
38
|
+
"typescript",
|
|
39
|
+
"soap"
|
|
40
|
+
],
|
|
41
|
+
"author": "ramiidv",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/ramiidv/arca-fecred.git"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/ramiidv/arca-fecred#readme",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/ramiidv/arca-fecred/issues"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=18"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@ramiidv/arca-common": "^0.1.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@types/node": "^22.0.0",
|
|
62
|
+
"typescript": "^5.7.0",
|
|
63
|
+
"vitest": "^3.2.4"
|
|
64
|
+
}
|
|
65
|
+
}
|