fiscalapi 4.0.439 → 4.0.462
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 +66 -0
- package/dist/cjs/abstractions/invoice-service.interface.d.ts +10 -0
- package/dist/cjs/abstractions/invoice-service.interface.d.ts.map +1 -1
- package/dist/cjs/abstractions/stamp-service.interface.d.ts +6 -2
- package/dist/cjs/abstractions/stamp-service.interface.d.ts.map +1 -1
- package/dist/cjs/abstractions/ticket-service.interface.d.ts +6 -4
- package/dist/cjs/abstractions/ticket-service.interface.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/models/ticket.d.ts +2 -2
- package/dist/cjs/models/webhook-event.d.ts +78 -0
- package/dist/cjs/models/webhook-event.d.ts.map +1 -0
- package/dist/cjs/models/webhook-event.js +31 -0
- package/dist/cjs/models/webhook-event.js.map +1 -0
- package/dist/cjs/services/invoice-service.d.ts +7 -0
- package/dist/cjs/services/invoice-service.d.ts.map +1 -1
- package/dist/cjs/services/invoice-service.js +16 -0
- package/dist/cjs/services/invoice-service.js.map +1 -1
- package/dist/cjs/services/stamp-service.d.ts +2 -1
- package/dist/cjs/services/stamp-service.d.ts.map +1 -1
- package/dist/cjs/services/stamp-service.js +6 -2
- package/dist/cjs/services/stamp-service.js.map +1 -1
- package/dist/cjs/webhooks/webhook-verification-error.d.ts +11 -0
- package/dist/cjs/webhooks/webhook-verification-error.d.ts.map +1 -0
- package/dist/cjs/webhooks/webhook-verification-error.js +20 -0
- package/dist/cjs/webhooks/webhook-verification-error.js.map +1 -0
- package/dist/cjs/webhooks/webhook.d.ts +48 -0
- package/dist/cjs/webhooks/webhook.d.ts.map +1 -0
- package/dist/cjs/webhooks/webhook.js +252 -0
- package/dist/cjs/webhooks/webhook.js.map +1 -0
- package/dist/esm/abstractions/invoice-service.interface.d.ts +10 -0
- package/dist/esm/abstractions/invoice-service.interface.d.ts.map +1 -1
- package/dist/esm/abstractions/stamp-service.interface.d.ts +6 -2
- package/dist/esm/abstractions/stamp-service.interface.d.ts.map +1 -1
- package/dist/esm/abstractions/ticket-service.interface.d.ts +6 -4
- package/dist/esm/abstractions/ticket-service.interface.d.ts.map +1 -1
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/models/ticket.d.ts +2 -2
- package/dist/esm/models/webhook-event.d.ts +78 -0
- package/dist/esm/models/webhook-event.d.ts.map +1 -0
- package/dist/esm/models/webhook-event.js +28 -0
- package/dist/esm/models/webhook-event.js.map +1 -0
- package/dist/esm/services/invoice-service.d.ts +7 -0
- package/dist/esm/services/invoice-service.d.ts.map +1 -1
- package/dist/esm/services/invoice-service.js +16 -0
- package/dist/esm/services/invoice-service.js.map +1 -1
- package/dist/esm/services/stamp-service.d.ts +2 -1
- package/dist/esm/services/stamp-service.d.ts.map +1 -1
- package/dist/esm/services/stamp-service.js +6 -2
- package/dist/esm/services/stamp-service.js.map +1 -1
- package/dist/esm/webhooks/webhook-verification-error.d.ts +11 -0
- package/dist/esm/webhooks/webhook-verification-error.d.ts.map +1 -0
- package/dist/esm/webhooks/webhook-verification-error.js +16 -0
- package/dist/esm/webhooks/webhook-verification-error.js.map +1 -0
- package/dist/esm/webhooks/webhook.d.ts +48 -0
- package/dist/esm/webhooks/webhook.d.ts.map +1 -0
- package/dist/esm/webhooks/webhook.js +248 -0
- package/dist/esm/webhooks/webhook.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -310,6 +310,12 @@ try {
|
|
|
310
310
|
}
|
|
311
311
|
```
|
|
312
312
|
|
|
313
|
+
Si la creación puede repetirse (por ejemplo, tras un corte de red), pasa una llave de idempotencia como segundo argumento, de hasta 64 caracteres. Repetir la misma petición con la misma llave de idempotencia devuelve la factura original sin crear otra; con otra petición distinta, la API responde 422.
|
|
314
|
+
|
|
315
|
+
```javascript
|
|
316
|
+
const apiResponse = await fiscalApi.invoices.create(invoice, "pedido-1001-intento-1");
|
|
317
|
+
```
|
|
318
|
+
|
|
313
319
|
### 6. Crear la Misma Factura de Ingreso (Por Valores)
|
|
314
320
|
|
|
315
321
|
```javascript
|
|
@@ -476,6 +482,66 @@ try {
|
|
|
476
482
|
|
|
477
483
|
Tras una firma exitosa, todas las personas del tenant con el RFC del certificado quedan con `manifestStatusId` en `Signed`; `fiscalApi.persons.getById(...)` lo refleja.
|
|
478
484
|
|
|
485
|
+
### 10. Recibir webhooks
|
|
486
|
+
|
|
487
|
+
FiscalAPI firma cada entrega con [Standard Webhooks](https://www.standardwebhooks.com) y el secreto `whsec_…` de tu webhook. `Webhook.verify` comprueba la firma (en tiempo constante) y que `webhook-timestamp` no difiera más de 5 minutos del reloj del receptor, y devuelve el `WebhookEvent`. La firma es la única prueba de que la entrega viene de FiscalAPI.
|
|
488
|
+
|
|
489
|
+
**Verifica el cuerpo crudo**: en Express, recíbelo con `express.raw({ type: 'application/json' })` y pasa el `Buffer` tal cual. Un cuerpo deserializado y vuelto a serializar (`JSON.stringify(req.body)` después de `express.json()`) cambia sus bytes y la firma deja de coincidir. Registra la ruta antes de un `app.use(express.json())` global: si ese parser corre primero, `req.body` ya no es el cuerpo crudo.
|
|
490
|
+
|
|
491
|
+
```javascript
|
|
492
|
+
const express = require('express');
|
|
493
|
+
const { FiscalapiClient, Webhook, WebhookEventTypes, WebhookVerificationError } = require('fiscalapi');
|
|
494
|
+
|
|
495
|
+
const app = express();
|
|
496
|
+
const fiscalApi = FiscalapiClient.create(settings);
|
|
497
|
+
const webhookSecret = process.env.FISCALAPI_WEBHOOK_SECRET; // whsec_… del webhook, desde tu configuración segura
|
|
498
|
+
|
|
499
|
+
app.post('/webhooks/fiscalapi', express.raw({ type: 'application/json' }), (req, res) => {
|
|
500
|
+
// Sin cuerpo o con otro Content-Type, express.raw no deja un Buffer: no es una entrega de FiscalAPI.
|
|
501
|
+
if (!Buffer.isBuffer(req.body)) return res.sendStatus(400);
|
|
502
|
+
|
|
503
|
+
let webhookEvent;
|
|
504
|
+
try {
|
|
505
|
+
webhookEvent = Webhook.verify(req.headers, req.body, webhookSecret);
|
|
506
|
+
} catch (error) {
|
|
507
|
+
if (error instanceof WebhookVerificationError) {
|
|
508
|
+
return res.sendStatus(400); // firma inválida, header faltante o timestamp fuera de tolerancia
|
|
509
|
+
}
|
|
510
|
+
throw error; // secreto mal configurado: error del receptor, no de la entrega
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// Responde 2xx rápido y procesa después: FiscalAPI corta cada intento a los 15 s y lo reintenta.
|
|
514
|
+
res.sendStatus(200);
|
|
515
|
+
// Procesa fuera de la petición. setImmediate es ilustrativo: en producción usa una cola durable.
|
|
516
|
+
setImmediate(() => processEvent(webhookEvent).catch(console.error));
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
async function processEvent(webhookEvent) {
|
|
520
|
+
// La entrega es al menos una vez: webhookEvent.id (el header webhook-id) se repite en cada reintento;
|
|
521
|
+
// descarta los ya procesados. El orden de llegada no está garantizado: el estado autoritativo se lee del recurso.
|
|
522
|
+
switch (webhookEvent.type) {
|
|
523
|
+
case WebhookEventTypes.InvoiceCanceled: {
|
|
524
|
+
const invoice = await fiscalApi.invoices.getById(webhookEvent.data.relatedObject.id);
|
|
525
|
+
break;
|
|
526
|
+
}
|
|
527
|
+
case WebhookEventTypes.DownloadRequestCompleted: {
|
|
528
|
+
const request = await fiscalApi.downloadRequests.getById(webhookEvent.data.relatedObject.id);
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
default:
|
|
532
|
+
break; // un tipo que no conoces se ignora: el catálogo puede crecer
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
- `WebhookEvent` es el mismo sobre para todo evento: `id`, `type` (texto; compáralo con las constantes de `WebhookEventTypes`), `createdAt` (un `Date`; el sobre lo trae en UTC), `personId` (`null` si el recurso no tiene persona) y `data` con `relatedObject` (`id`, `type`, `url`), `status` y `previousStatus`.
|
|
538
|
+
- `relatedObject.url` es la ruta relativa del GET v4 del recurso (`/api/v4/invoices/{id}`); para leerlo, usa el servicio de su tipo con `relatedObject.id`.
|
|
539
|
+
- El botón "Enviar prueba" del webhook (`POST /api/v4/webhooks/{id}/test`) envía `WebhookEventTypes.WebhookTest` (`webhook.test`), cuyo `relatedObject` es el webhook mismo (`type` `webhook`, `url` `/api/v4/webhooks/{id}`), sin persona ni estados; no se suscribe.
|
|
540
|
+
- `headers` acepta el objeto `req.headers` de Node/Express o un `Headers` de fetch; los nombres no distinguen mayúsculas. `body` acepta el `Buffer` crudo o ese mismo cuerpo como texto; un cuerpo que no es UTF-8 válido se rechaza.
|
|
541
|
+
- Durante una rotación del secreto, FiscalAPI firma con el nuevo y con el anterior por 24 h: pasa ambos, `Webhook.verify(req.headers, req.body, [secretoNuevo, secretoAnterior])`.
|
|
542
|
+
- La tolerancia es configurable en segundos (`Webhook.verify(req.headers, req.body, secreto, 120)`); el valor por omisión es `Webhook.DEFAULT_TOLERANCE_SECONDS` (300).
|
|
543
|
+
- Un secreto mal copiado (no es base64) o una lista de secretos vacía lanza `TypeError` con la posición del secreto (nunca su valor), y una tolerancia negativa `RangeError`: son errores de configuración, no de la entrega.
|
|
544
|
+
|
|
479
545
|
## 📂 Más Ejemplos
|
|
480
546
|
|
|
481
547
|
- [Gestión de Timbres](examples/ejemplo-timbres.ts)
|
|
@@ -6,6 +6,16 @@ import { IFiscalapiService } from './fiscalapi-service.interface';
|
|
|
6
6
|
* Interfaz para el servicio de facturas
|
|
7
7
|
*/
|
|
8
8
|
export interface IInvoiceService extends IFiscalapiService<Invoice> {
|
|
9
|
+
/**
|
|
10
|
+
* POST /api/v4/invoices
|
|
11
|
+
* Crea una factura. Con `idempotencyKey` (hasta 64 caracteres) se envía el header `Idempotency-Key`: repetir la llave de idempotencia
|
|
12
|
+
* con la misma petición devuelve la factura original sin timbrar otra vez; con otra petición, 422. Sin ella, el
|
|
13
|
+
* header no se envía.
|
|
14
|
+
* @param {Invoice} model - Datos de la factura
|
|
15
|
+
* @param {string} [idempotencyKey] - Valor del header Idempotency-Key
|
|
16
|
+
* @returns {Promise<ApiResponse<Invoice>>} Factura creada
|
|
17
|
+
*/
|
|
18
|
+
create(model: Invoice, idempotencyKey?: string): Promise<ApiResponse<Invoice>>;
|
|
9
19
|
/**
|
|
10
20
|
* Cancela una factura
|
|
11
21
|
* @param {CancelInvoiceRequest} request - Solicitud para cancelar factura
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoice-service.interface.d.ts","sourceRoot":"","sources":["../../../src/abstractions/invoice-service.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,iBAAiB,CAAC,OAAO,CAAC;IACjE;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAEnF;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IAEtE;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IAEvD;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IAEjE;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,CAAC;CACvF"}
|
|
1
|
+
{"version":3,"file":"invoice-service.interface.d.ts","sourceRoot":"","sources":["../../../src/abstractions/invoice-service.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,iBAAiB,CAAC,OAAO,CAAC;IACjE;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IAE/E;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAEnF;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IAEtE;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IAEvD;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IAEjE;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,CAAC;CACvF"}
|
|
@@ -6,11 +6,15 @@ import { IFiscalapiService } from './fiscalapi-service.interface';
|
|
|
6
6
|
*/
|
|
7
7
|
export interface IStampService extends IFiscalapiService<StampTransaction> {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* POST /api/v4/stamps
|
|
10
|
+
* Transfiere timbres de una persona a otra. Con `idempotencyKey` (hasta 64 caracteres) se envía el header
|
|
11
|
+
* `Idempotency-Key`: repetir la llave de idempotencia con la misma petición devuelve el resultado original sin transferir otra vez;
|
|
12
|
+
* con otra petición, 422. Sin ella, el header no se envía.
|
|
10
13
|
* @param {StampTransactionParams} request - Parámetros de la transferencia
|
|
14
|
+
* @param {string} [idempotencyKey] - Valor del header Idempotency-Key
|
|
11
15
|
* @returns {Promise<ApiResponse<boolean>>} Resultado de la operación
|
|
12
16
|
*/
|
|
13
|
-
transferStamps(request: StampTransactionParams): Promise<ApiResponse<boolean>>;
|
|
17
|
+
transferStamps(request: StampTransactionParams, idempotencyKey?: string): Promise<ApiResponse<boolean>>;
|
|
14
18
|
/**
|
|
15
19
|
* Retira timbres de una persona
|
|
16
20
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stamp-service.interface.d.ts","sourceRoot":"","sources":["../../../src/abstractions/stamp-service.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,iBAAiB,CAAC,gBAAgB,CAAC;IACxE
|
|
1
|
+
{"version":3,"file":"stamp-service.interface.d.ts","sourceRoot":"","sources":["../../../src/abstractions/stamp-service.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,iBAAiB,CAAC,gBAAgB,CAAC;IACxE;;;;;;;;OAQG;IACH,cAAc,CAAC,OAAO,EAAE,sBAAsB,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IAExG;;;;;;;;;OASG;IACH,cAAc,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;CAChF"}
|
|
@@ -9,11 +9,13 @@ import { Ticket, TicketCodeResult, TicketIngestionResult, TicketListFilters } fr
|
|
|
9
9
|
export interface ITicketService {
|
|
10
10
|
/**
|
|
11
11
|
* POST /api/v4/tickets
|
|
12
|
-
* Ingiere un ticket y cobra 1 crédito de ticket. Con `idempotencyKey` (
|
|
13
|
-
* `Idempotency-Key`: repetir la
|
|
14
|
-
*
|
|
12
|
+
* Ingiere un ticket y cobra 1 crédito de ticket. Con `idempotencyKey` (de 1 a 64 caracteres ASCII visibles, sin
|
|
13
|
+
* espacios) se envía el header `Idempotency-Key`: repetir la misma llave de idempotencia con el mismo cuerpo, dentro de
|
|
14
|
+
* 24 h, devuelve la respuesta original (201, con el header `Idempotent-Replayed: true`) sin registrar otro ticket ni
|
|
15
|
+
* cobrar otra vez; con otro cuerpo, 422; con la original aún en proceso, 409 con Retry-After. Sin ella, el header no se
|
|
16
|
+
* envía. Un folio y serie ya activos del emisor responden 409.
|
|
15
17
|
* @param {Ticket} ticket - Ticket a ingerir
|
|
16
|
-
* @param {string} [idempotencyKey] -
|
|
18
|
+
* @param {string} [idempotencyKey] - Llave de idempotencia (idempotency key), valor del header Idempotency-Key
|
|
17
19
|
* @returns {Promise<ApiResponse<TicketIngestionResult>>} Ticket ingerido con su código y QR
|
|
18
20
|
*/
|
|
19
21
|
create(ticket: Ticket, idempotencyKey?: string): Promise<ApiResponse<TicketIngestionResult>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ticket-service.interface.d.ts","sourceRoot":"","sources":["../../../src/abstractions/ticket-service.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEtG;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B
|
|
1
|
+
{"version":3,"file":"ticket-service.interface.d.ts","sourceRoot":"","sources":["../../../src/abstractions/ticket-service.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEtG;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAE7F;;;;;OAKG;IACH,OAAO,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE9E;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAErE;;;;;OAKG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAE5D;;;;;OAKG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;CACnD"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -32,6 +32,11 @@ export type { SatValidationType, SatValidationTypeStatus, SatValidationStatus, S
|
|
|
32
32
|
export { SatValidationTypeIds, SatValidationStatusIds } from './models/sat-validation';
|
|
33
33
|
export type { Ticket, TicketIssuer, TicketItem, TicketItemTax, TicketEvent, TicketIngestionResult, TicketCodeResult, TicketListFilters } from './models/ticket';
|
|
34
34
|
export { TicketStatus, TicketEventType, TicketActorType } from './models/ticket';
|
|
35
|
+
export type { WebhookEvent, WebhookEventData, WebhookRelatedObject } from './models/webhook-event';
|
|
36
|
+
export { WebhookEventTypes } from './models/webhook-event';
|
|
37
|
+
export type { WebhookHeaders, WebhookHeadersGetter } from './webhooks/webhook';
|
|
38
|
+
export { Webhook } from './webhooks/webhook';
|
|
39
|
+
export { WebhookVerificationError } from './webhooks/webhook-verification-error';
|
|
35
40
|
export type { FiscalapiSettings } from './common/fiscalapi-settings';
|
|
36
41
|
export type { ApiResponse, ValidationFailure, ProblemDetails } from './common/api-response';
|
|
37
42
|
export type { FileResponse } from './common/file-response';
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,YAAY,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAElF,YAAY,EAAE,iBAAiB,EAAE,0BAA0B,EAA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C"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
//Export public API
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.isObjectEmpty = exports.isArrayNullOrEmpty = exports.isNullOrEmpty = exports.isNullOrUndefined = exports.decodeFromBase64 = exports.encodeToBase64 = exports.SAT_DATE_FORMAT = exports.parseSatDate = exports.formatSatDate = exports.CatalogDto = exports.SerializableDto = exports.AuditableDto = exports.BaseDto = exports.PagedList = exports.TicketActorType = exports.TicketEventType = exports.TicketStatus = exports.SatValidationStatusIds = exports.SatValidationTypeIds = exports.CreditType = exports.StampTransactionStatus = exports.StampTransactionType = exports.FiscalapiClient = void 0;
|
|
4
|
+
exports.isObjectEmpty = exports.isArrayNullOrEmpty = exports.isNullOrEmpty = exports.isNullOrUndefined = exports.decodeFromBase64 = exports.encodeToBase64 = exports.SAT_DATE_FORMAT = exports.parseSatDate = exports.formatSatDate = exports.CatalogDto = exports.SerializableDto = exports.AuditableDto = exports.BaseDto = exports.PagedList = exports.WebhookVerificationError = exports.Webhook = exports.WebhookEventTypes = exports.TicketActorType = exports.TicketEventType = exports.TicketStatus = exports.SatValidationStatusIds = exports.SatValidationTypeIds = exports.CreditType = exports.StampTransactionStatus = exports.StampTransactionType = exports.FiscalapiClient = void 0;
|
|
5
5
|
var fiscalapi_client_1 = require("./services/fiscalapi-client");
|
|
6
6
|
Object.defineProperty(exports, "FiscalapiClient", { enumerable: true, get: function () { return fiscalapi_client_1.FiscalapiClient; } });
|
|
7
7
|
var stamp_1 = require("./models/stamp");
|
|
@@ -15,6 +15,12 @@ var ticket_1 = require("./models/ticket");
|
|
|
15
15
|
Object.defineProperty(exports, "TicketStatus", { enumerable: true, get: function () { return ticket_1.TicketStatus; } });
|
|
16
16
|
Object.defineProperty(exports, "TicketEventType", { enumerable: true, get: function () { return ticket_1.TicketEventType; } });
|
|
17
17
|
Object.defineProperty(exports, "TicketActorType", { enumerable: true, get: function () { return ticket_1.TicketActorType; } });
|
|
18
|
+
var webhook_event_1 = require("./models/webhook-event");
|
|
19
|
+
Object.defineProperty(exports, "WebhookEventTypes", { enumerable: true, get: function () { return webhook_event_1.WebhookEventTypes; } });
|
|
20
|
+
var webhook_1 = require("./webhooks/webhook");
|
|
21
|
+
Object.defineProperty(exports, "Webhook", { enumerable: true, get: function () { return webhook_1.Webhook; } });
|
|
22
|
+
var webhook_verification_error_1 = require("./webhooks/webhook-verification-error");
|
|
23
|
+
Object.defineProperty(exports, "WebhookVerificationError", { enumerable: true, get: function () { return webhook_verification_error_1.WebhookVerificationError; } });
|
|
18
24
|
//Values
|
|
19
25
|
var paged_list_1 = require("./common/paged-list");
|
|
20
26
|
Object.defineProperty(exports, "PagedList", { enumerable: true, get: function () { return paged_list_1.PagedList; } });
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,mBAAmB;;;AAEnB,gEAA8D;AAArD,mHAAA,eAAe,OAAA;AAsIxB,wCAIwB;AAHtB,6GAAA,oBAAoB,OAAA;AACpB,+GAAA,sBAAsB,OAAA;AACtB,mGAAA,UAAU,OAAA;AAWZ,0DAGiC;AAF/B,sHAAA,oBAAoB,OAAA;AACpB,wHAAA,sBAAsB,OAAA;AAcxB,0CAIyB;AAHvB,sGAAA,YAAY,OAAA;AACZ,yGAAA,eAAe,OAAA;AACf,yGAAA,eAAe,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,mBAAmB;;;AAEnB,gEAA8D;AAArD,mHAAA,eAAe,OAAA;AAsIxB,wCAIwB;AAHtB,6GAAA,oBAAoB,OAAA;AACpB,+GAAA,sBAAsB,OAAA;AACtB,mGAAA,UAAU,OAAA;AAWZ,0DAGiC;AAF/B,sHAAA,oBAAoB,OAAA;AACpB,wHAAA,sBAAsB,OAAA;AAcxB,0CAIyB;AAHvB,sGAAA,YAAY,OAAA;AACZ,yGAAA,eAAe,OAAA;AACf,yGAAA,eAAe,OAAA;AAKjB,wDAA2D;AAAlD,kHAAA,iBAAiB,OAAA;AAE1B,8CAA6C;AAApC,kGAAA,OAAO,OAAA;AAChB,oFAAiF;AAAxE,sIAAA,wBAAwB,OAAA;AASjC,QAAQ;AACR,kDAAiD;AAAvC,uGAAA,SAAS,OAAA;AACnB,8CAA6C;AAAnC,mGAAA,OAAO,OAAA;AACjB,wDAAsD;AAA7C,6GAAA,YAAY,OAAA;AACrB,8DAA4D;AAAnD,mHAAA,eAAe,OAAA;AACxB,oDAAkD;AAAzC,yGAAA,UAAU,OAAA;AACnB,iDAAkF;AAAzE,2GAAA,aAAa,OAAA;AAAE,0GAAA,YAAY,OAAA;AAAE,6GAAA,eAAe,OAAA;AACrD,yDAA0E;AAAjE,gHAAA,cAAc,OAAA;AAAE,kHAAA,gBAAgB,OAAA;AACzC,6DAA+G;AAAtG,qHAAA,iBAAiB,OAAA;AAAE,iHAAA,aAAa,OAAA;AAAE,sHAAA,kBAAkB,OAAA;AAAE,iHAAA,aAAa,OAAA"}
|
|
@@ -139,8 +139,8 @@ export interface Ticket {
|
|
|
139
139
|
events?: TicketEvent[];
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
* Respuesta de `tickets.create`:
|
|
143
|
-
*
|
|
142
|
+
* Respuesta de `tickets.create`: un ticket nuevo (201) y la repetición con la misma llave de idempotencia y el mismo
|
|
143
|
+
* cuerpo devuelven la misma respuesta original.
|
|
144
144
|
*/
|
|
145
145
|
export interface TicketIngestionResult {
|
|
146
146
|
id: string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Un evento de webhook de FiscalAPI: el mismo sobre para todo tipo de evento. Lo devuelve `Webhook.verify` después de
|
|
3
|
+
* validar la firma. Es una notificación ligera: para el estado autoritativo del recurso (el orden de llegada no está
|
|
4
|
+
* garantizado), consulte `data.relatedObject` con el servicio de su tipo (por ejemplo `client.invoices.getById(id)`).
|
|
5
|
+
*/
|
|
6
|
+
export interface WebhookEvent {
|
|
7
|
+
/**
|
|
8
|
+
* Id del evento; es también el header `webhook-id` y no cambia entre reintentos: úselo para descartar entregas
|
|
9
|
+
* repetidas.
|
|
10
|
+
*/
|
|
11
|
+
id: string;
|
|
12
|
+
/**
|
|
13
|
+
* Tipo de evento (ver `WebhookEventTypes`). Es texto y no un enum: un tipo que esta versión del SDK no conoce llega
|
|
14
|
+
* tal cual, sin error, y se ignora.
|
|
15
|
+
*/
|
|
16
|
+
type: string;
|
|
17
|
+
/** Momento del cambio de estado, al segundo. El sobre lo trae en UTC (`2026-10-12T18:47:53Z`). */
|
|
18
|
+
createdAt: Date;
|
|
19
|
+
/** Persona del tenant dueña del recurso; null si el recurso no tiene una (factura emitida por valores). */
|
|
20
|
+
personId: string | null;
|
|
21
|
+
/** El recurso que cambió y sus estados. */
|
|
22
|
+
data: WebhookEventData;
|
|
23
|
+
}
|
|
24
|
+
/** Datos de un `WebhookEvent`. */
|
|
25
|
+
export interface WebhookEventData {
|
|
26
|
+
/** El recurso que cambió de estado. */
|
|
27
|
+
relatedObject: WebhookRelatedObject;
|
|
28
|
+
/**
|
|
29
|
+
* Estado al que llegó el recurso, con los códigos públicos de la API v4 (factura `V`, `C`, `X`; solicitud de descarga
|
|
30
|
+
* `1`, `2`, `3`, `-1`; regla de descarga `1`..`4`, `-1`); null si el tipo de evento no lo lleva.
|
|
31
|
+
*/
|
|
32
|
+
status: string | null;
|
|
33
|
+
/** Estado del que salió el recurso, con los mismos códigos que `status`; null si no aplica. */
|
|
34
|
+
previousStatus: string | null;
|
|
35
|
+
}
|
|
36
|
+
/** El recurso al que se refiere un `WebhookEvent`. */
|
|
37
|
+
export interface WebhookRelatedObject {
|
|
38
|
+
/** Id del recurso: el que reciben los `getById` de los servicios del SDK. */
|
|
39
|
+
id: string;
|
|
40
|
+
/**
|
|
41
|
+
* Tipo de recurso: `invoice`, `download_request`, `download_rule` o `webhook` (el de
|
|
42
|
+
* `WebhookEventTypes.WebhookTest`); el conjunto puede crecer.
|
|
43
|
+
*/
|
|
44
|
+
type: string;
|
|
45
|
+
/**
|
|
46
|
+
* Ruta relativa del GET v4 del recurso (por ejemplo `/api/v4/invoices/{id}`), sin host: el mismo evento es idéntico
|
|
47
|
+
* en pruebas y en producción. Para leer el recurso use su servicio con `id`.
|
|
48
|
+
*/
|
|
49
|
+
url: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Tipos de evento de webhook, como llegan en `WebhookEvent.type`. Los de un cambio de estado nombran el estado al que
|
|
53
|
+
* llegó el recurso. Son una ayuda para comparar: el catálogo puede crecer y un tipo desconocido se ignora.
|
|
54
|
+
*/
|
|
55
|
+
export declare const WebhookEventTypes: {
|
|
56
|
+
/** La factura pasó de vigente a cancelación en proceso (`V` → `C`). */
|
|
57
|
+
readonly InvoiceCancellationRequested: "invoice.cancellation_requested";
|
|
58
|
+
/** La cancelación en proceso terminó y la factura quedó cancelada (`C` → `X`). */
|
|
59
|
+
readonly InvoiceCanceled: "invoice.canceled";
|
|
60
|
+
/** La cancelación en proceso se rechazó y la factura volvió a vigente (`C` → `V`). */
|
|
61
|
+
readonly InvoiceCancellationRejected: "invoice.cancellation_rejected";
|
|
62
|
+
/** La solicitud de descarga masiva terminó con éxito (→ `3`). */
|
|
63
|
+
readonly DownloadRequestCompleted: "download_request.completed";
|
|
64
|
+
/**
|
|
65
|
+
* La solicitud de descarga masiva se abandonó (→ `-1`). No implica un error: el motivo está en la solicitud
|
|
66
|
+
* (`client.downloadRequests.getById(id)`).
|
|
67
|
+
*/
|
|
68
|
+
readonly DownloadRequestAbandoned: "download_request.abandoned";
|
|
69
|
+
/** La regla de descarga masiva quedó suspendida (`2` → `4`). */
|
|
70
|
+
readonly DownloadRuleSuspended: "download_rule.suspended";
|
|
71
|
+
/**
|
|
72
|
+
* Prueba de un webhook: no se suscribe; llega solo al pulsar "Enviar prueba" (`POST /api/v4/webhooks/{id}/test`), y
|
|
73
|
+
* solo a ese webhook. Su `data.relatedObject` es el webhook mismo (`type` `webhook`, `url` `/api/v4/webhooks/{id}`),
|
|
74
|
+
* sin persona ni estados.
|
|
75
|
+
*/
|
|
76
|
+
readonly WebhookTest: "webhook.test";
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=webhook-event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-event.d.ts","sourceRoot":"","sources":["../../../src/models/webhook-event.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb,kGAAkG;IAClG,SAAS,EAAE,IAAI,CAAC;IAEhB,2GAA2G;IAC3G,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB,2CAA2C;IAC3C,IAAI,EAAE,gBAAgB,CAAC;CACxB;AAED,kCAAkC;AAClC,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,aAAa,EAAE,oBAAoB,CAAC;IAEpC;;;OAGG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtB,+FAA+F;IAC/F,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,sDAAsD;AACtD,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB;IAC5B,uEAAuE;;IAEvE,kFAAkF;;IAElF,sFAAsF;;IAEtF,iEAAiE;;IAEjE;;;OAGG;;IAEH,gEAAgE;;IAEhE;;;;OAIG;;CAEK,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhookEventTypes = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Tipos de evento de webhook, como llegan en `WebhookEvent.type`. Los de un cambio de estado nombran el estado al que
|
|
6
|
+
* llegó el recurso. Son una ayuda para comparar: el catálogo puede crecer y un tipo desconocido se ignora.
|
|
7
|
+
*/
|
|
8
|
+
exports.WebhookEventTypes = {
|
|
9
|
+
/** La factura pasó de vigente a cancelación en proceso (`V` → `C`). */
|
|
10
|
+
InvoiceCancellationRequested: 'invoice.cancellation_requested',
|
|
11
|
+
/** La cancelación en proceso terminó y la factura quedó cancelada (`C` → `X`). */
|
|
12
|
+
InvoiceCanceled: 'invoice.canceled',
|
|
13
|
+
/** La cancelación en proceso se rechazó y la factura volvió a vigente (`C` → `V`). */
|
|
14
|
+
InvoiceCancellationRejected: 'invoice.cancellation_rejected',
|
|
15
|
+
/** La solicitud de descarga masiva terminó con éxito (→ `3`). */
|
|
16
|
+
DownloadRequestCompleted: 'download_request.completed',
|
|
17
|
+
/**
|
|
18
|
+
* La solicitud de descarga masiva se abandonó (→ `-1`). No implica un error: el motivo está en la solicitud
|
|
19
|
+
* (`client.downloadRequests.getById(id)`).
|
|
20
|
+
*/
|
|
21
|
+
DownloadRequestAbandoned: 'download_request.abandoned',
|
|
22
|
+
/** La regla de descarga masiva quedó suspendida (`2` → `4`). */
|
|
23
|
+
DownloadRuleSuspended: 'download_rule.suspended',
|
|
24
|
+
/**
|
|
25
|
+
* Prueba de un webhook: no se suscribe; llega solo al pulsar "Enviar prueba" (`POST /api/v4/webhooks/{id}/test`), y
|
|
26
|
+
* solo a ese webhook. Su `data.relatedObject` es el webhook mismo (`type` `webhook`, `url` `/api/v4/webhooks/{id}`),
|
|
27
|
+
* sin persona ni estados.
|
|
28
|
+
*/
|
|
29
|
+
WebhookTest: 'webhook.test',
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=webhook-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-event.js","sourceRoot":"","sources":["../../../src/models/webhook-event.ts"],"names":[],"mappings":";;;AA6DA;;;GAGG;AACU,QAAA,iBAAiB,GAAG;IAC/B,uEAAuE;IACvE,4BAA4B,EAAE,gCAAgC;IAC9D,kFAAkF;IAClF,eAAe,EAAE,kBAAkB;IACnC,sFAAsF;IACtF,2BAA2B,EAAE,+BAA+B;IAC5D,iEAAiE;IACjE,wBAAwB,EAAE,4BAA4B;IACtD;;;OAGG;IACH,wBAAwB,EAAE,4BAA4B;IACtD,gEAAgE;IAChE,qBAAqB,EAAE,yBAAyB;IAChD;;;;OAIG;IACH,WAAW,EAAE,cAAc;CACnB,CAAC"}
|
|
@@ -14,6 +14,13 @@ export declare class InvoiceService extends BaseFiscalapiService<Invoice> implem
|
|
|
14
14
|
* @param {string} apiVersion - Versión de la API
|
|
15
15
|
*/
|
|
16
16
|
constructor(httpClient: IFiscalapiHttpClient, apiVersion: string);
|
|
17
|
+
/**
|
|
18
|
+
* Crea una factura
|
|
19
|
+
* @param {Invoice} model - Datos de la factura
|
|
20
|
+
* @param {string} [idempotencyKey] - Valor del header Idempotency-Key
|
|
21
|
+
* @returns {Promise<ApiResponse<Invoice>>} Factura creada
|
|
22
|
+
*/
|
|
23
|
+
create(model: Invoice, idempotencyKey?: string): Promise<ApiResponse<Invoice>>;
|
|
17
24
|
/**
|
|
18
25
|
* Cancela una factura
|
|
19
26
|
* @param {CancelInvoiceRequest} request - Solicitud para cancelar factura
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoice-service.d.ts","sourceRoot":"","sources":["../../../src/services/invoice-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,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AAC;IAW3E;;;;OAIG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAa5D;;;;OAIG;IACG,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAQtE;;;;OAIG;IACG,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;CAO5F"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InvoiceService = void 0;
|
|
4
4
|
const base_fiscalapi_service_1 = require("./base-fiscalapi-service");
|
|
5
|
+
/** Header de la llave de idempotencia; el mismo que usa el servicio de tickets. */
|
|
6
|
+
const IDEMPOTENCY_KEY_HEADER = 'Idempotency-Key';
|
|
5
7
|
/**
|
|
6
8
|
* Implementación del servicio de facturas
|
|
7
9
|
*/
|
|
@@ -14,6 +16,20 @@ class InvoiceService extends base_fiscalapi_service_1.BaseFiscalapiService {
|
|
|
14
16
|
constructor(httpClient, apiVersion) {
|
|
15
17
|
super(httpClient, 'invoices', apiVersion);
|
|
16
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Crea una factura
|
|
21
|
+
* @param {Invoice} model - Datos de la factura
|
|
22
|
+
* @param {string} [idempotencyKey] - Valor del header Idempotency-Key
|
|
23
|
+
* @returns {Promise<ApiResponse<Invoice>>} Factura creada
|
|
24
|
+
*/
|
|
25
|
+
async create(model, idempotencyKey) {
|
|
26
|
+
// POST /api/v4/invoices, con el header Idempotency-Key solo si se pasa
|
|
27
|
+
return await this.executeRequest({
|
|
28
|
+
data: model,
|
|
29
|
+
method: 'POST',
|
|
30
|
+
config: idempotencyKey === undefined ? undefined : { headers: { [IDEMPOTENCY_KEY_HEADER]: idempotencyKey } },
|
|
31
|
+
});
|
|
32
|
+
}
|
|
17
33
|
/**
|
|
18
34
|
* Cancela una factura
|
|
19
35
|
* @param {CancelInvoiceRequest} request - Solicitud para cancelar factura
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoice-service.js","sourceRoot":"","sources":["../../../src/services/invoice-service.ts"],"names":[],"mappings":";;;AAGA,qEAAgE;AAYhE;;GAEG;AACH,MAAa,cAAe,SAAQ,6CAA6B;IAE/D;;;;OAIG;IACH,YAAY,UAAgC,EAAE,UAAkB;QAC9D,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAA6B;QACxC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,MAAM,IAAI,CAAC,cAAc,CAA8C;YAC5E,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAAyB;QACpC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,MAAM,IAAI,CAAC,cAAc,CAAiC;YAC/D,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QAErB,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,MAAM,IAAI,CAAC,cAAc,CAAuB;YACrD,IAAI,EAAC,GAAG,EAAE,MAAM;YAChB,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IAEL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,OAA2B;QACpC,OAAO,MAAM,IAAI,CAAC,cAAc,CAA8B;YAC5D,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,OAA6B;QAC3C,OAAO,MAAM,IAAI,CAAC,cAAc,CAA8C;YAC5E,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"invoice-service.js","sourceRoot":"","sources":["../../../src/services/invoice-service.ts"],"names":[],"mappings":";;;AAGA,qEAAgE;AAYhE,mFAAmF;AACnF,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAEjD;;GAEG;AACH,MAAa,cAAe,SAAQ,6CAA6B;IAE/D;;;;OAIG;IACH,YAAY,UAAgC,EAAE,UAAkB;QAC9D,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,KAAc,EAAE,cAAuB;QAClD,uEAAuE;QACvE,OAAO,MAAM,IAAI,CAAC,cAAc,CAAmB;YACjD,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,sBAAsB,CAAC,EAAE,cAAc,EAAE,EAAE;SAC7G,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAA6B;QACxC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,MAAM,IAAI,CAAC,cAAc,CAA8C;YAC5E,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAAyB;QACpC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,MAAM,IAAI,CAAC,cAAc,CAAiC;YAC/D,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QAErB,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,MAAM,IAAI,CAAC,cAAc,CAAuB;YACrD,IAAI,EAAC,GAAG,EAAE,MAAM;YAChB,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IAEL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,OAA2B;QACpC,OAAO,MAAM,IAAI,CAAC,cAAc,CAA8B;YAC5D,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,OAA6B;QAC3C,OAAO,MAAM,IAAI,CAAC,cAAc,CAA8C;YAC5E,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;CACF;AArGD,wCAqGC"}
|
|
@@ -17,9 +17,10 @@ export declare class StampService extends BaseFiscalapiService<StampTransaction>
|
|
|
17
17
|
* Transfiere timbres, créditos de validación o créditos de ticket de una persona a otra.
|
|
18
18
|
* El tipo de crédito se elige con `creditType`; si se omite, se transfieren timbres.
|
|
19
19
|
* @param {StampTransactionParams} request - Parámetros de la transferencia
|
|
20
|
+
* @param {string} [idempotencyKey] - Valor del header Idempotency-Key
|
|
20
21
|
* @returns {Promise<ApiResponse<boolean>>} Resultado de la operación
|
|
21
22
|
*/
|
|
22
|
-
transferStamps(request: StampTransactionParams): Promise<ApiResponse<boolean>>;
|
|
23
|
+
transferStamps(request: StampTransactionParams, idempotencyKey?: string): Promise<ApiResponse<boolean>>;
|
|
23
24
|
/**
|
|
24
25
|
* Retira timbres de una persona
|
|
25
26
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stamp-service.d.ts","sourceRoot":"","sources":["../../../src/services/stamp-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"stamp-service.d.ts","sourceRoot":"","sources":["../../../src/services/stamp-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAK3E;;GAEG;AACH,qBAAa,YAAa,SAAQ,oBAAoB,CAAC,gBAAgB,CAAE,YAAW,aAAa;IAC/F;;;;OAIG;gBACS,UAAU,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM;IAIhE;;;;;;OAMG;IACG,cAAc,CAAC,OAAO,EAAE,sBAAsB,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAa7G;;;;;;;;;OASG;IACG,cAAc,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;CAGrF"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StampService = void 0;
|
|
4
4
|
const base_fiscalapi_service_1 = require("./base-fiscalapi-service");
|
|
5
|
+
/** Header de la llave de idempotencia; el mismo que usa el servicio de tickets. */
|
|
6
|
+
const IDEMPOTENCY_KEY_HEADER = 'Idempotency-Key';
|
|
5
7
|
/**
|
|
6
8
|
* Implementación del servicio de timbres fiscales
|
|
7
9
|
*/
|
|
@@ -18,16 +20,18 @@ class StampService extends base_fiscalapi_service_1.BaseFiscalapiService {
|
|
|
18
20
|
* Transfiere timbres, créditos de validación o créditos de ticket de una persona a otra.
|
|
19
21
|
* El tipo de crédito se elige con `creditType`; si se omite, se transfieren timbres.
|
|
20
22
|
* @param {StampTransactionParams} request - Parámetros de la transferencia
|
|
23
|
+
* @param {string} [idempotencyKey] - Valor del header Idempotency-Key
|
|
21
24
|
* @returns {Promise<ApiResponse<boolean>>} Resultado de la operación
|
|
22
25
|
*/
|
|
23
|
-
async transferStamps(request) {
|
|
26
|
+
async transferStamps(request, idempotencyKey) {
|
|
24
27
|
if (!request) {
|
|
25
28
|
throw new Error('request cannot be null');
|
|
26
29
|
}
|
|
27
|
-
// POST /api/v4/stamps
|
|
30
|
+
// POST /api/v4/stamps, con el header Idempotency-Key solo si se pasa
|
|
28
31
|
return await this.executeRequest({
|
|
29
32
|
data: request,
|
|
30
33
|
method: 'POST',
|
|
34
|
+
config: idempotencyKey === undefined ? undefined : { headers: { [IDEMPOTENCY_KEY_HEADER]: idempotencyKey } },
|
|
31
35
|
});
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stamp-service.js","sourceRoot":"","sources":["../../../src/services/stamp-service.ts"],"names":[],"mappings":";;;AAEA,qEAAgE;AAIhE;;GAEG;AACH,MAAa,YAAa,SAAQ,6CAAsC;IACtE;;;;OAIG;IACH,YAAY,UAAgC,EAAE,UAAkB;QAC9D,KAAK,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC1C,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"stamp-service.js","sourceRoot":"","sources":["../../../src/services/stamp-service.ts"],"names":[],"mappings":";;;AAEA,qEAAgE;AAIhE,mFAAmF;AACnF,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAEjD;;GAEG;AACH,MAAa,YAAa,SAAQ,6CAAsC;IACtE;;;;OAIG;IACH,YAAY,UAAgC,EAAE,UAAkB;QAC9D,KAAK,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,cAAc,CAAC,OAA+B,EAAE,cAAuB;QAC3E,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,qEAAqE;QACrE,OAAO,MAAM,IAAI,CAAC,cAAc,CAAkC;YAChE,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,sBAAsB,CAAC,EAAE,cAAc,EAAE,EAAE;SAC7G,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,cAAc,CAAC,OAA+B;QAClD,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;CACF;AA3CD,oCA2CC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* La entrega no se puede tratar como auténtica: falta un header de Standard Webhooks, ninguna firma coincide, el
|
|
3
|
+
* timestamp está fuera de la tolerancia, el cuerpo no es texto UTF-8 válido o el cuerpo firmado no es un evento. El
|
|
4
|
+
* receptor la rechaza (por ejemplo con un 400) y no la procesa.
|
|
5
|
+
*/
|
|
6
|
+
export declare class WebhookVerificationError extends Error {
|
|
7
|
+
/** El error original cuando la causa es otra excepción (por ejemplo el `SyntaxError` de un JSON inválido). */
|
|
8
|
+
readonly cause?: unknown;
|
|
9
|
+
constructor(message: string, cause?: unknown);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=webhook-verification-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-verification-error.d.ts","sourceRoot":"","sources":["../../../src/webhooks/webhook-verification-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,8GAA8G;IAC9G,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;gBAEb,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAQ7C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhookVerificationError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* La entrega no se puede tratar como auténtica: falta un header de Standard Webhooks, ninguna firma coincide, el
|
|
6
|
+
* timestamp está fuera de la tolerancia, el cuerpo no es texto UTF-8 válido o el cuerpo firmado no es un evento. El
|
|
7
|
+
* receptor la rechaza (por ejemplo con un 400) y no la procesa.
|
|
8
|
+
*/
|
|
9
|
+
class WebhookVerificationError extends Error {
|
|
10
|
+
constructor(message, cause) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'WebhookVerificationError';
|
|
13
|
+
// `cause` como propiedad propia: la opción `{ cause }` de Error no existe en todas las versiones de Node que soporta el SDK.
|
|
14
|
+
if (cause !== undefined) {
|
|
15
|
+
this.cause = cause;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.WebhookVerificationError = WebhookVerificationError;
|
|
20
|
+
//# sourceMappingURL=webhook-verification-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-verification-error.js","sourceRoot":"","sources":["../../../src/webhooks/webhook-verification-error.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,wBAAyB,SAAQ,KAAK;IAIjD,YAAY,OAAe,EAAE,KAAe;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,6HAA6H;QAC7H,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAZD,4DAYC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { WebhookEvent } from '../models/webhook-event';
|
|
2
|
+
/** Un `Headers` de fetch (o cualquier objeto con `get` que no distinga mayúsculas). */
|
|
3
|
+
export interface WebhookHeadersGetter {
|
|
4
|
+
get(name: string): string | null;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Los headers de la petición recibida: el objeto `req.headers` de Node/Express (valores `string` o `string[]`; de un
|
|
8
|
+
* arreglo se usa el primer valor) o un `Headers` de fetch. Los nombres se comparan sin distinguir mayúsculas.
|
|
9
|
+
*/
|
|
10
|
+
export type WebhookHeaders = WebhookHeadersGetter | Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
11
|
+
/**
|
|
12
|
+
* Verificación de las entregas de webhooks de FiscalAPI, que se firman con Standard Webhooks
|
|
13
|
+
* (https://www.standardwebhooks.com): HMAC-SHA256 sobre `webhook-id.webhook-timestamp.cuerpo` con el secreto `whsec_…`
|
|
14
|
+
* del webhook, en el header `webhook-signature` como `v1,<base64>`. La firma es la única prueba de que una entrega viene
|
|
15
|
+
* de FiscalAPI.
|
|
16
|
+
*/
|
|
17
|
+
export declare class Webhook {
|
|
18
|
+
/**
|
|
19
|
+
* Diferencia máxima, en segundos, entre `webhook-timestamp` y el reloj del receptor, hacia atrás o hacia adelante: una
|
|
20
|
+
* entrega capturada no se puede repetir después. 5 minutos.
|
|
21
|
+
*/
|
|
22
|
+
static readonly DEFAULT_TOLERANCE_SECONDS: number;
|
|
23
|
+
private constructor();
|
|
24
|
+
/**
|
|
25
|
+
* Verifica una entrega y devuelve su evento. Con varios secretos basta que una firma `v1` del header coincida con uno
|
|
26
|
+
* de ellos: sirve durante una rotación, mientras el receptor despliega el secreto nuevo y conserva el anterior
|
|
27
|
+
* (FiscalAPI firma con ambos durante 24 h).
|
|
28
|
+
*
|
|
29
|
+
* Responda 2xx rápido y procese el evento después, fuera de la petición: FiscalAPI corta cada intento a los 15 s y lo
|
|
30
|
+
* reintenta.
|
|
31
|
+
*
|
|
32
|
+
* @param headers Los headers de la petición recibida: `req.headers` de Node/Express o un `Headers` de fetch.
|
|
33
|
+
* @param body El cuerpo **crudo** tal como llegó (en Express, el `Buffer` de `express.raw({ type: 'application/json' })`),
|
|
34
|
+
* o ese mismo cuerpo como texto. Nunca uno deserializado y vuelto a serializar (`JSON.stringify(req.body)`): cambian
|
|
35
|
+
* sus bytes (espacios, orden, escapes) y la firma deja de coincidir.
|
|
36
|
+
* @param secret El secreto del webhook (`whsec_…`; se acepta también sin el prefijo), o varios.
|
|
37
|
+
* @param toleranceSeconds Tolerancia del timestamp en segundos; por omisión `Webhook.DEFAULT_TOLERANCE_SECONDS`.
|
|
38
|
+
* @returns El evento del cuerpo verificado.
|
|
39
|
+
* @throws {WebhookVerificationError} Falta un header, el timestamp está fuera de la tolerancia, ninguna firma `v1`
|
|
40
|
+
* coincide, el cuerpo no es texto UTF-8 válido o el cuerpo firmado no es un evento: rechace la entrega sin procesarla.
|
|
41
|
+
* @throws {TypeError} Un argumento falta o no es del tipo esperado, no hay secretos o uno no es base64: es un error de
|
|
42
|
+
* configuración del receptor, no de la entrega. En una lista indica la posición del secreto, nunca su valor.
|
|
43
|
+
* @throws {RangeError} La tolerancia es negativa o infinita.
|
|
44
|
+
*/
|
|
45
|
+
static verify(headers: WebhookHeaders, body: string | Uint8Array, secret: string, toleranceSeconds?: number): WebhookEvent;
|
|
46
|
+
static verify(headers: WebhookHeaders, body: string | Uint8Array, secrets: readonly string[], toleranceSeconds?: number): WebhookEvent;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=webhook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../src/webhooks/webhook.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,uFAAuF;AACvF,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;AA8BrH;;;;;GAKG;AACH,qBAAa,OAAO;IAClB;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,yBAAyB,SAAU;IAEnD,OAAO;IAEP;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,YAAY;IAC1H,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,YAAY;CAyBvI"}
|