@miguelmorales13/nestkit 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1186,6 +1186,27 @@ misma URL o valida un borrador o emite un documento con efectos fiscales. `isTes
1186
1186
  para que puedas negarte a arrancar en el ambiente equivocado. Del lado de Facturama, el default es el
1187
1187
  sandbox a propósito: una configuración olvidada no puede timbrar de verdad.
1188
1188
 
1189
+ #### Reintentar un timbrado sin duplicarlo
1190
+
1191
+ `issue()` es la única operación de este módulo con un efecto irreversible caro de repetir por
1192
+ accidente: un timeout o una conexión caída *después* de que el PAC ya timbró no te dice si el
1193
+ documento existe. `idempotencyKey` en `InvoiceDraft` resuelve eso — **solo en Facturapi**, que lo
1194
+ soporta con `idempotency_key` en el body (y, además, como header, para que un wrapper de resiliencia
1195
+ genérico que solo sabe reconocer un header `*idempotency*` —sin parsear el body— sepa que este POST
1196
+ es seguro de reintentar). Facturama no tiene equivalente y el adaptador simplemente lo ignora.
1197
+
1198
+ La clave es de la **llamada**, no de la venta: generá una nueva en cada intento real de facturar
1199
+ (`crypto.randomUUID()` alcanza), y reusala solo entre los reintentos automáticos de esa misma
1200
+ llamada. Repetirla en un reintento **deliberado** — por ejemplo, volver a facturar tras cancelar — le
1201
+ devuelve el documento viejo (cancelado) en vez de timbrar uno nuevo.
1202
+
1203
+ ```ts
1204
+ await facturacion.issue({
1205
+ /* … */
1206
+ idempotencyKey: crypto.randomUUID(),
1207
+ });
1208
+ ```
1209
+
1189
1210
  #### Lo que este módulo no hace
1190
1211
 
1191
1212
  - **No genera ni sella XML.** Los PAC que solo timbran un CFDI que vos sellaste con tu propio CSD
@@ -8,8 +8,8 @@ var _chunkFH5UNWWWcjs = require('../chunk-FH5UNWWW.cjs');
8
8
 
9
9
 
10
10
  var _chunkHDFPSA2Vcjs = require('../chunk-HDFPSA2V.cjs');
11
- require('../chunk-SDWHKPXI.cjs');
12
11
  require('../chunk-Q5Y33L7B.cjs');
12
+ require('../chunk-SDWHKPXI.cjs');
13
13
  require('../chunk-PNK5WMPP.cjs');
14
14
 
15
15
 
@@ -8,8 +8,8 @@ import {
8
8
  ForbiddenAppException,
9
9
  UnauthorizedAppException
10
10
  } from "../chunk-ZFIDAX7K.js";
11
- import "../chunk-ETRUVZTJ.js";
12
11
  import "../chunk-M3GQDRWR.js";
12
+ import "../chunk-ETRUVZTJ.js";
13
13
  import "../chunk-VVMRZEIW.js";
14
14
  import {
15
15
  __decorateClass,
@@ -6,8 +6,8 @@ var _chunkFH5UNWWWcjs = require('../../chunk-FH5UNWWW.cjs');
6
6
 
7
7
 
8
8
  var _chunkHDFPSA2Vcjs = require('../../chunk-HDFPSA2V.cjs');
9
- require('../../chunk-SDWHKPXI.cjs');
10
9
  require('../../chunk-Q5Y33L7B.cjs');
10
+ require('../../chunk-SDWHKPXI.cjs');
11
11
  require('../../chunk-PNK5WMPP.cjs');
12
12
 
13
13
 
@@ -6,8 +6,8 @@ import {
6
6
  UnauthorizedAppException,
7
7
  ValidationAppException
8
8
  } from "../../chunk-ZFIDAX7K.js";
9
- import "../../chunk-ETRUVZTJ.js";
10
9
  import "../../chunk-M3GQDRWR.js";
10
+ import "../../chunk-ETRUVZTJ.js";
11
11
  import "../../chunk-VVMRZEIW.js";
12
12
  import {
13
13
  __decorateClass,
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkFNUZGYUFcjs = require('../chunk-FNUZGYUF.cjs');
3
+ var _chunkFQRF37NGcjs = require('../chunk-FQRF37NG.cjs');
4
+ require('../chunk-LSDY6ETG.cjs');
4
5
  require('../chunk-3AUOOEQO.cjs');
5
- require('../chunk-MSTXS3MU.cjs');
6
+ require('../chunk-Q5Y33L7B.cjs');
6
7
  require('../chunk-AXMW5JF7.cjs');
7
8
  require('../chunk-Y72D5L6I.cjs');
8
9
  require('../chunk-SDWHKPXI.cjs');
9
- require('../chunk-Q5Y33L7B.cjs');
10
10
  require('../chunk-PNK5WMPP.cjs');
11
11
  require('../chunk-2REOCMUD.cjs');
12
12
 
13
13
 
14
- exports.applyNestKitDefaults = _chunkFNUZGYUFcjs.applyNestKitDefaults;
14
+ exports.applyNestKitDefaults = _chunkFQRF37NGcjs.applyNestKitDefaults;
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  applyNestKitDefaults
3
- } from "../chunk-UNEVXCFW.js";
3
+ } from "../chunk-PLEY5EZT.js";
4
+ import "../chunk-2DUEQKOI.js";
4
5
  import "../chunk-DYHSOULW.js";
5
- import "../chunk-A2DGK4ZL.js";
6
+ import "../chunk-M3GQDRWR.js";
6
7
  import "../chunk-X4PQJZ4G.js";
7
8
  import "../chunk-TCAMLNUZ.js";
8
9
  import "../chunk-ETRUVZTJ.js";
9
- import "../chunk-M3GQDRWR.js";
10
10
  import "../chunk-VVMRZEIW.js";
11
11
  import "../chunk-4MGIQFAJ.js";
12
12
  export {
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunk3AUOOEQOcjs = require('./chunk-3AUOOEQO.cjs');
3
+ var _chunkLSDY6ETGcjs = require('./chunk-LSDY6ETG.cjs');
4
4
 
5
5
 
6
- var _chunkMSTXS3MUcjs = require('./chunk-MSTXS3MU.cjs');
6
+ var _chunk3AUOOEQOcjs = require('./chunk-3AUOOEQO.cjs');
7
7
 
8
8
  // src/bootstrap/apply-defaults.ts
9
9
 
@@ -17,7 +17,7 @@ function applyNestKitDefaults(app, options = {}) {
17
17
  app.useGlobalPipes(
18
18
  new (0, _common.ValidationPipe)({ whitelist: true, transform: true, ...options.validation })
19
19
  );
20
- app.useGlobalFilters(new (0, _chunkMSTXS3MUcjs.GlobalExceptionFilter)());
20
+ app.useGlobalFilters(new (0, _chunkLSDY6ETGcjs.GlobalExceptionFilter)());
21
21
  app.useGlobalInterceptors(new (0, _chunk3AUOOEQOcjs.ResponseInterceptor)());
22
22
  if (options.swagger !== false) {
23
23
  const swaggerOptions = _nullishCoalesce(options.swagger, () => ( { title: "API" }));
@@ -1,9 +1,9 @@
1
+ import {
2
+ GlobalExceptionFilter
3
+ } from "./chunk-2DUEQKOI.js";
1
4
  import {
2
5
  ResponseInterceptor
3
6
  } from "./chunk-DYHSOULW.js";
4
- import {
5
- GlobalExceptionFilter
6
- } from "./chunk-A2DGK4ZL.js";
7
7
 
8
8
  // src/bootstrap/apply-defaults.ts
9
9
  import {
@@ -8,13 +8,13 @@
8
8
  var _chunkHDFPSA2Vcjs = require('../chunk-HDFPSA2V.cjs');
9
9
 
10
10
 
11
- var _chunkMSTXS3MUcjs = require('../chunk-MSTXS3MU.cjs');
12
- require('../chunk-AXMW5JF7.cjs');
13
- require('../chunk-Y72D5L6I.cjs');
14
- require('../chunk-SDWHKPXI.cjs');
11
+ var _chunkLSDY6ETGcjs = require('../chunk-LSDY6ETG.cjs');
15
12
 
16
13
 
17
14
  var _chunkQ5Y33L7Bcjs = require('../chunk-Q5Y33L7B.cjs');
15
+ require('../chunk-AXMW5JF7.cjs');
16
+ require('../chunk-Y72D5L6I.cjs');
17
+ require('../chunk-SDWHKPXI.cjs');
18
18
  require('../chunk-PNK5WMPP.cjs');
19
19
  require('../chunk-2REOCMUD.cjs');
20
20
 
@@ -25,4 +25,4 @@ require('../chunk-2REOCMUD.cjs');
25
25
 
26
26
 
27
27
 
28
- exports.AppException = _chunkQ5Y33L7Bcjs.AppException; exports.ConflictAppException = _chunkHDFPSA2Vcjs.ConflictAppException; exports.ForbiddenAppException = _chunkHDFPSA2Vcjs.ForbiddenAppException; exports.GlobalExceptionFilter = _chunkMSTXS3MUcjs.GlobalExceptionFilter; exports.NotFoundAppException = _chunkHDFPSA2Vcjs.NotFoundAppException; exports.UnauthorizedAppException = _chunkHDFPSA2Vcjs.UnauthorizedAppException; exports.ValidationAppException = _chunkHDFPSA2Vcjs.ValidationAppException;
28
+ exports.AppException = _chunkQ5Y33L7Bcjs.AppException; exports.ConflictAppException = _chunkHDFPSA2Vcjs.ConflictAppException; exports.ForbiddenAppException = _chunkHDFPSA2Vcjs.ForbiddenAppException; exports.GlobalExceptionFilter = _chunkLSDY6ETGcjs.GlobalExceptionFilter; exports.NotFoundAppException = _chunkHDFPSA2Vcjs.NotFoundAppException; exports.UnauthorizedAppException = _chunkHDFPSA2Vcjs.UnauthorizedAppException; exports.ValidationAppException = _chunkHDFPSA2Vcjs.ValidationAppException;
@@ -8,13 +8,13 @@ import {
8
8
  } from "../chunk-ZFIDAX7K.js";
9
9
  import {
10
10
  GlobalExceptionFilter
11
- } from "../chunk-A2DGK4ZL.js";
12
- import "../chunk-X4PQJZ4G.js";
13
- import "../chunk-TCAMLNUZ.js";
14
- import "../chunk-ETRUVZTJ.js";
11
+ } from "../chunk-2DUEQKOI.js";
15
12
  import {
16
13
  AppException
17
14
  } from "../chunk-M3GQDRWR.js";
15
+ import "../chunk-X4PQJZ4G.js";
16
+ import "../chunk-TCAMLNUZ.js";
17
+ import "../chunk-ETRUVZTJ.js";
18
18
  import "../chunk-VVMRZEIW.js";
19
19
  import "../chunk-4MGIQFAJ.js";
20
20
  export {
package/dist/index.cjs CHANGED
@@ -1,30 +1,34 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-KVBQBT3D.cjs');
2
-
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
3
2
 
4
3
 
5
4
 
6
5
  var _chunkRF75KC63cjs = require('./chunk-RF75KC63.cjs');
6
+ require('./chunk-KVBQBT3D.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
11
  var _chunkSPTDXUEDcjs = require('./chunk-SPTDXUED.cjs');
12
- require('./chunk-H2EHN366.cjs');
13
12
 
14
13
 
15
14
 
16
15
 
17
16
  var _chunkHVHYZXBBcjs = require('./chunk-HVHYZXBB.cjs');
17
+ require('./chunk-7SOM7EZP.cjs');
18
+ require('./chunk-H2EHN366.cjs');
18
19
 
19
20
 
20
21
 
21
22
 
22
23
 
23
24
 
24
- var _chunkAPUFKA4Kcjs = require('./chunk-APUFKA4K.cjs');
25
+ var _chunkHDFPSA2Vcjs = require('./chunk-HDFPSA2V.cjs');
26
+
25
27
 
28
+ var _chunkFQRF37NGcjs = require('./chunk-FQRF37NG.cjs');
26
29
 
27
- var _chunkFNUZGYUFcjs = require('./chunk-FNUZGYUF.cjs');
30
+
31
+ var _chunkLSDY6ETGcjs = require('./chunk-LSDY6ETG.cjs');
28
32
 
29
33
 
30
34
  var _chunk3AUOOEQOcjs = require('./chunk-3AUOOEQO.cjs');
@@ -36,18 +40,17 @@ var _chunk52IOOHNXcjs = require('./chunk-52IOOHNX.cjs');
36
40
  require('./chunk-W2T2VFLC.cjs');
37
41
 
38
42
 
39
- var _chunkQS2W5XCQcjs = require('./chunk-QS2W5XCQ.cjs');
40
- require('./chunk-7SOM7EZP.cjs');
43
+ var _chunkQ5Y33L7Bcjs = require('./chunk-Q5Y33L7B.cjs');
41
44
 
42
45
 
46
+ var _chunkQS2W5XCQcjs = require('./chunk-QS2W5XCQ.cjs');
43
47
 
44
48
 
45
49
 
46
50
 
47
- var _chunkHDFPSA2Vcjs = require('./chunk-HDFPSA2V.cjs');
48
51
 
49
52
 
50
- var _chunkMSTXS3MUcjs = require('./chunk-MSTXS3MU.cjs');
53
+ var _chunkAPUFKA4Kcjs = require('./chunk-APUFKA4K.cjs');
51
54
 
52
55
 
53
56
 
@@ -63,9 +66,6 @@ var _chunkY72D5L6Icjs = require('./chunk-Y72D5L6I.cjs');
63
66
  var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
64
67
 
65
68
 
66
- var _chunkQ5Y33L7Bcjs = require('./chunk-Q5Y33L7B.cjs');
67
-
68
-
69
69
 
70
70
 
71
71
  var _chunkPNK5WMPPcjs = require('./chunk-PNK5WMPP.cjs');
@@ -108,4 +108,4 @@ require('./chunk-2REOCMUD.cjs');
108
108
 
109
109
 
110
110
 
111
- exports.AppException = _chunkQ5Y33L7Bcjs.AppException; exports.BaseCrudService = _chunk52IOOHNXcjs.BaseCrudService; exports.BaseResponseDto = _chunkQS2W5XCQcjs.BaseResponseDto; exports.ConflictAppException = _chunkHDFPSA2Vcjs.ConflictAppException; exports.ForbiddenAppException = _chunkHDFPSA2Vcjs.ForbiddenAppException; exports.GlobalExceptionFilter = _chunkMSTXS3MUcjs.GlobalExceptionFilter; exports.I18nInterceptor = _chunkAPUFKA4Kcjs.I18nInterceptor; exports.I18nMessage = _chunkPNK5WMPPcjs.I18nMessage; exports.I18nModule = _chunkAPUFKA4Kcjs.I18nModule; exports.ListQuery = _chunk52IOOHNXcjs.ListQuery; exports.NestI18nTranslator = _chunkAPUFKA4Kcjs.NestI18nTranslator; exports.NotFoundAppException = _chunkHDFPSA2Vcjs.NotFoundAppException; exports.PG_POOL = _chunkRF75KC63cjs.PG_POOL; exports.PgModule = _chunkRF75KC63cjs.PgModule; exports.REQUEST_ID_HEADER = _chunkHVHYZXBBcjs.REQUEST_ID_HEADER; exports.RequestContext = _chunkSDWHKPXIcjs.RequestContext; exports.RequestIdMiddleware = _chunkHVHYZXBBcjs.RequestIdMiddleware; exports.ResponseInterceptor = _chunk3AUOOEQOcjs.ResponseInterceptor; exports.SUPABASE_ANON_CLIENT = _chunkSPTDXUEDcjs.SUPABASE_ANON_CLIENT; exports.SUPABASE_SERVICE_ROLE_CLIENT = _chunkSPTDXUEDcjs.SUPABASE_SERVICE_ROLE_CLIENT; exports.SupabaseModule = _chunkSPTDXUEDcjs.SupabaseModule; exports.TrackingModule = _chunkHVHYZXBBcjs.TrackingModule; exports.UnauthorizedAppException = _chunkHDFPSA2Vcjs.UnauthorizedAppException; exports.ValidationAppException = _chunkHDFPSA2Vcjs.ValidationAppException; exports.applyNestKitDefaults = _chunkFNUZGYUFcjs.applyNestKitDefaults; exports.buildPageMeta = _chunkY72D5L6Icjs.buildPageMeta; exports.createCrudController = _chunk52IOOHNXcjs.createCrudController; exports.currentLanguage = _chunkAXMW5JF7cjs.currentLanguage; exports.isI18nMessage = _chunkPNK5WMPPcjs.isI18nMessage; exports.isPaginated = _chunkY72D5L6Icjs.isPaginated; exports.matchLanguage = _chunkAPUFKA4Kcjs.matchLanguage; exports.paginated = _chunkY72D5L6Icjs.paginated; exports.t = _chunkPNK5WMPPcjs.t; exports.translate = _chunkAXMW5JF7cjs.translate; exports.translateDeep = _chunkAXMW5JF7cjs.translateDeep; exports.translateOr = _chunkAPUFKA4Kcjs.translateOr; exports.withTenantScope = _chunkRF75KC63cjs.withTenantScope;
111
+ exports.AppException = _chunkQ5Y33L7Bcjs.AppException; exports.BaseCrudService = _chunk52IOOHNXcjs.BaseCrudService; exports.BaseResponseDto = _chunkQS2W5XCQcjs.BaseResponseDto; exports.ConflictAppException = _chunkHDFPSA2Vcjs.ConflictAppException; exports.ForbiddenAppException = _chunkHDFPSA2Vcjs.ForbiddenAppException; exports.GlobalExceptionFilter = _chunkLSDY6ETGcjs.GlobalExceptionFilter; exports.I18nInterceptor = _chunkAPUFKA4Kcjs.I18nInterceptor; exports.I18nMessage = _chunkPNK5WMPPcjs.I18nMessage; exports.I18nModule = _chunkAPUFKA4Kcjs.I18nModule; exports.ListQuery = _chunk52IOOHNXcjs.ListQuery; exports.NestI18nTranslator = _chunkAPUFKA4Kcjs.NestI18nTranslator; exports.NotFoundAppException = _chunkHDFPSA2Vcjs.NotFoundAppException; exports.PG_POOL = _chunkRF75KC63cjs.PG_POOL; exports.PgModule = _chunkRF75KC63cjs.PgModule; exports.REQUEST_ID_HEADER = _chunkHVHYZXBBcjs.REQUEST_ID_HEADER; exports.RequestContext = _chunkSDWHKPXIcjs.RequestContext; exports.RequestIdMiddleware = _chunkHVHYZXBBcjs.RequestIdMiddleware; exports.ResponseInterceptor = _chunk3AUOOEQOcjs.ResponseInterceptor; exports.SUPABASE_ANON_CLIENT = _chunkSPTDXUEDcjs.SUPABASE_ANON_CLIENT; exports.SUPABASE_SERVICE_ROLE_CLIENT = _chunkSPTDXUEDcjs.SUPABASE_SERVICE_ROLE_CLIENT; exports.SupabaseModule = _chunkSPTDXUEDcjs.SupabaseModule; exports.TrackingModule = _chunkHVHYZXBBcjs.TrackingModule; exports.UnauthorizedAppException = _chunkHDFPSA2Vcjs.UnauthorizedAppException; exports.ValidationAppException = _chunkHDFPSA2Vcjs.ValidationAppException; exports.applyNestKitDefaults = _chunkFQRF37NGcjs.applyNestKitDefaults; exports.buildPageMeta = _chunkY72D5L6Icjs.buildPageMeta; exports.createCrudController = _chunk52IOOHNXcjs.createCrudController; exports.currentLanguage = _chunkAXMW5JF7cjs.currentLanguage; exports.isI18nMessage = _chunkPNK5WMPPcjs.isI18nMessage; exports.isPaginated = _chunkY72D5L6Icjs.isPaginated; exports.matchLanguage = _chunkAPUFKA4Kcjs.matchLanguage; exports.paginated = _chunkY72D5L6Icjs.paginated; exports.t = _chunkPNK5WMPPcjs.t; exports.translate = _chunkAXMW5JF7cjs.translate; exports.translateDeep = _chunkAXMW5JF7cjs.translateDeep; exports.translateOr = _chunkAPUFKA4Kcjs.translateOr; exports.withTenantScope = _chunkRF75KC63cjs.withTenantScope;
package/dist/index.js CHANGED
@@ -1,30 +1,34 @@
1
- import "./chunk-EPVKCBPT.js";
2
1
  import {
3
2
  PG_POOL,
4
3
  PgModule,
5
4
  withTenantScope
6
5
  } from "./chunk-VKOPDDCC.js";
6
+ import "./chunk-EPVKCBPT.js";
7
7
  import {
8
8
  SUPABASE_ANON_CLIENT,
9
9
  SUPABASE_SERVICE_ROLE_CLIENT,
10
10
  SupabaseModule
11
11
  } from "./chunk-PA24P76K.js";
12
- import "./chunk-ODPSIFOB.js";
13
12
  import {
14
13
  REQUEST_ID_HEADER,
15
14
  RequestIdMiddleware,
16
15
  TrackingModule
17
16
  } from "./chunk-4PFAKLT3.js";
17
+ import "./chunk-DQYAIQQ5.js";
18
+ import "./chunk-ODPSIFOB.js";
18
19
  import {
19
- I18nInterceptor,
20
- I18nModule,
21
- NestI18nTranslator,
22
- matchLanguage,
23
- translateOr
24
- } from "./chunk-6RAPVLJM.js";
20
+ ConflictAppException,
21
+ ForbiddenAppException,
22
+ NotFoundAppException,
23
+ UnauthorizedAppException,
24
+ ValidationAppException
25
+ } from "./chunk-ZFIDAX7K.js";
25
26
  import {
26
27
  applyNestKitDefaults
27
- } from "./chunk-UNEVXCFW.js";
28
+ } from "./chunk-PLEY5EZT.js";
29
+ import {
30
+ GlobalExceptionFilter
31
+ } from "./chunk-2DUEQKOI.js";
28
32
  import {
29
33
  ResponseInterceptor
30
34
  } from "./chunk-DYHSOULW.js";
@@ -34,20 +38,19 @@ import {
34
38
  createCrudController
35
39
  } from "./chunk-IFNYRZP2.js";
36
40
  import "./chunk-ZJMLEP5H.js";
41
+ import {
42
+ AppException
43
+ } from "./chunk-M3GQDRWR.js";
37
44
  import {
38
45
  BaseResponseDto
39
46
  } from "./chunk-XX2HPTRU.js";
40
- import "./chunk-DQYAIQQ5.js";
41
- import {
42
- ConflictAppException,
43
- ForbiddenAppException,
44
- NotFoundAppException,
45
- UnauthorizedAppException,
46
- ValidationAppException
47
- } from "./chunk-ZFIDAX7K.js";
48
47
  import {
49
- GlobalExceptionFilter
50
- } from "./chunk-A2DGK4ZL.js";
48
+ I18nInterceptor,
49
+ I18nModule,
50
+ NestI18nTranslator,
51
+ matchLanguage,
52
+ translateOr
53
+ } from "./chunk-6RAPVLJM.js";
51
54
  import {
52
55
  currentLanguage,
53
56
  translate,
@@ -61,9 +64,6 @@ import {
61
64
  import {
62
65
  RequestContext
63
66
  } from "./chunk-ETRUVZTJ.js";
64
- import {
65
- AppException
66
- } from "./chunk-M3GQDRWR.js";
67
67
  import {
68
68
  I18nMessage,
69
69
  isI18nMessage,
@@ -24,6 +24,7 @@ export declare class FacturamaInvoicing implements InvoicingPort {
24
24
  /** True while this adapter points at the sandbox host. */
25
25
  get isSandbox(): boolean;
26
26
  private headers;
27
+ /** `draft.idempotencyKey` is intentionally unused: Facturama's API has no equivalent. */
27
28
  issue(draft: InvoiceDraft): Promise<Invoice>;
28
29
  get(id: string): Promise<Invoice>;
29
30
  /**
@@ -215,7 +215,10 @@ var FacturapiInvoicing = class {
215
215
  const lines = computeLines(draft.items);
216
216
  const invoice = await requestJson(PROVIDER, this.fetchImpl, `${this.baseUrl}/invoices`, {
217
217
  method: "POST",
218
- headers: this.headers(),
218
+ // The header is redundant with `idempotency_key` in the body — Facturapi only reads the
219
+ // body field — but it lets a generic resilience wrapper that sniffs for an
220
+ // `*idempotency*` header (rather than parsing the body) know this POST is safe to retry.
221
+ headers: draft.idempotencyKey ? { ...this.headers(), "idempotency-key": draft.idempotencyKey } : this.headers(),
219
222
  body: JSON.stringify({
220
223
  customer: typeof draft.customer === "string" ? draft.customer : {
221
224
  legal_name: draft.customer.legalName,
@@ -251,7 +254,8 @@ var FacturapiInvoicing = class {
251
254
  exchange: draft.exchangeRate,
252
255
  series: draft.series,
253
256
  folio_number: draft.folioNumber,
254
- external_id: draft.externalId
257
+ external_id: draft.externalId,
258
+ idempotency_key: draft.idempotencyKey
255
259
  })
256
260
  });
257
261
  return this.toInvoice(invoice);
@@ -357,6 +361,7 @@ var FacturamaInvoicing = class {
357
361
  headers() {
358
362
  return { authorization: `Basic ${this.token}`, "content-type": "application/json" };
359
363
  }
364
+ /** `draft.idempotencyKey` is intentionally unused: Facturama's API has no equivalent. */
360
365
  async issue(draft) {
361
366
  if (typeof draft.customer === "string") {
362
367
  throw new UnsupportedByProviderException(
@@ -215,7 +215,10 @@ var FacturapiInvoicing = class {
215
215
  const lines = computeLines(draft.items);
216
216
  const invoice = await requestJson(PROVIDER, this.fetchImpl, `${this.baseUrl}/invoices`, {
217
217
  method: "POST",
218
- headers: this.headers(),
218
+ // The header is redundant with `idempotency_key` in the body — Facturapi only reads the
219
+ // body field — but it lets a generic resilience wrapper that sniffs for an
220
+ // `*idempotency*` header (rather than parsing the body) know this POST is safe to retry.
221
+ headers: draft.idempotencyKey ? { ...this.headers(), "idempotency-key": draft.idempotencyKey } : this.headers(),
219
222
  body: JSON.stringify({
220
223
  customer: typeof draft.customer === "string" ? draft.customer : {
221
224
  legal_name: draft.customer.legalName,
@@ -251,7 +254,8 @@ var FacturapiInvoicing = class {
251
254
  exchange: draft.exchangeRate,
252
255
  series: draft.series,
253
256
  folio_number: draft.folioNumber,
254
- external_id: draft.externalId
257
+ external_id: draft.externalId,
258
+ idempotency_key: draft.idempotencyKey
255
259
  })
256
260
  });
257
261
  return this.toInvoice(invoice);
@@ -357,6 +361,7 @@ var FacturamaInvoicing = class {
357
361
  headers() {
358
362
  return { authorization: `Basic ${this.token}`, "content-type": "application/json" };
359
363
  }
364
+ /** `draft.idempotencyKey` is intentionally unused: Facturama's API has no equivalent. */
360
365
  async issue(draft) {
361
366
  if (typeof draft.customer === "string") {
362
367
  throw new UnsupportedByProviderException(
@@ -99,6 +99,16 @@ export interface InvoiceDraft {
99
99
  folioNumber?: number;
100
100
  /** Your own id for this invoice, echoed back by the provider. */
101
101
  externalId?: string;
102
+ /**
103
+ * A key unique to this **attempt** to issue the invoice — not to the sale.
104
+ * When set, Facturapi returns the same invoice instead of stamping a second
105
+ * one if the request is sent twice (a timeout or a dropped connection after
106
+ * it already stamped). Generate a fresh one per call to `issue()`; reusing
107
+ * the same key across a deliberate re-issue (e.g. after cancelling) makes
108
+ * the provider hand back the old, cancelled document instead of a new one.
109
+ * Facturapi only — Facturama has no equivalent and ignores this field.
110
+ */
111
+ idempotencyKey?: string;
102
112
  }
103
113
  export interface Invoice {
104
114
  /** The provider's id — what every other method here takes. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miguelmorales13/nestkit",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,3 +1,6 @@
1
+ import {
2
+ AppException
3
+ } from "./chunk-M3GQDRWR.js";
1
4
  import {
2
5
  getI18nRuntime,
3
6
  translate,
@@ -6,9 +9,6 @@ import {
6
9
  import {
7
10
  RequestContext
8
11
  } from "./chunk-ETRUVZTJ.js";
9
- import {
10
- AppException
11
- } from "./chunk-M3GQDRWR.js";
12
12
  import {
13
13
  __decorateClass
14
14
  } from "./chunk-4MGIQFAJ.js";
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
+ var _chunkQ5Y33L7Bcjs = require('./chunk-Q5Y33L7B.cjs');
3
4
 
4
5
 
5
- var _chunkAXMW5JF7cjs = require('./chunk-AXMW5JF7.cjs');
6
6
 
7
7
 
8
- var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
8
+ var _chunkAXMW5JF7cjs = require('./chunk-AXMW5JF7.cjs');
9
9
 
10
10
 
11
- var _chunkQ5Y33L7Bcjs = require('./chunk-Q5Y33L7B.cjs');
11
+ var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
12
12
 
13
13
 
14
14
  var _chunk2REOCMUDcjs = require('./chunk-2REOCMUD.cjs');