@miguelmorales13/nestkit 0.16.0 → 0.19.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.
Files changed (91) hide show
  1. package/README.md +212 -61
  2. package/dist/audit/index.cjs +12 -12
  3. package/dist/audit/index.js +2 -2
  4. package/dist/auth/index.cjs +12 -11
  5. package/dist/auth/index.js +5 -4
  6. package/dist/auth/oauth/http.d.ts +10 -3
  7. package/dist/auth/oauth/index.cjs +189 -30
  8. package/dist/auth/oauth/index.d.ts +6 -4
  9. package/dist/auth/oauth/index.js +169 -10
  10. package/dist/auth/oauth/magic-link.dto.d.ts +6 -0
  11. package/dist/auth/oauth/memory-magic-link.store.d.ts +19 -0
  12. package/dist/auth/oauth/oauth-auth.service.d.ts +46 -5
  13. package/dist/auth/oauth/oauth.controller.d.ts +5 -1
  14. package/dist/auth/oauth/oauth.options.d.ts +34 -1
  15. package/dist/auth/oauth/oauth.ports.d.ts +38 -0
  16. package/dist/bootstrap/index.cjs +8 -6
  17. package/dist/bootstrap/index.js +7 -5
  18. package/dist/{chunk-UWDHAZVE.cjs → chunk-3AUOOEQO.cjs} +2 -2
  19. package/dist/{chunk-JV4EAOF2.js → chunk-4PFAKLT3.js} +1 -1
  20. package/dist/{chunk-47FXU74G.cjs → chunk-52IOOHNX.cjs} +2 -2
  21. package/dist/chunk-6RAPVLJM.js +212 -0
  22. package/dist/{chunk-KRC47OX6.js → chunk-A2DGK4ZL.js} +26 -3
  23. package/dist/chunk-APUFKA4K.cjs +212 -0
  24. package/dist/chunk-AXMW5JF7.cjs +83 -0
  25. package/dist/{chunk-DABTRWA6.js → chunk-DYHSOULW.js} +1 -1
  26. package/dist/{chunk-KP2ZHJSR.js → chunk-ETRUVZTJ.js} +8 -0
  27. package/dist/{chunk-C5DV4RAX.cjs → chunk-FH5UNWWW.cjs} +6 -6
  28. package/dist/{chunk-4GT66KQS.cjs → chunk-FNUZGYUF.cjs} +4 -4
  29. package/dist/{chunk-FDNGAYTZ.cjs → chunk-HDFPSA2V.cjs} +6 -6
  30. package/dist/{chunk-U7QK24HL.cjs → chunk-HVHYZXBB.cjs} +2 -2
  31. package/dist/{chunk-LK3OINS7.js → chunk-IFNYRZP2.js} +1 -1
  32. package/dist/{chunk-YFYHLYHN.js → chunk-M3GQDRWR.js} +7 -1
  33. package/dist/{chunk-67B7IYAV.cjs → chunk-MSTXS3MU.cjs} +28 -5
  34. package/dist/chunk-PNK5WMPP.cjs +30 -0
  35. package/dist/chunk-Q5Y33L7B.cjs +19 -0
  36. package/dist/{chunk-EBPEMVZU.cjs → chunk-SDWHKPXI.cjs} +8 -0
  37. package/dist/{chunk-MLOQDUBN.js → chunk-TUNDBBQF.js} +4 -4
  38. package/dist/{chunk-UIVBPNH4.js → chunk-UNEVXCFW.js} +4 -4
  39. package/dist/chunk-VVMRZEIW.js +30 -0
  40. package/dist/{chunk-XX5ROVSC.cjs → chunk-W2T2VFLC.cjs} +3 -3
  41. package/dist/chunk-X4PQJZ4G.js +83 -0
  42. package/dist/{chunk-ORWJ7LES.js → chunk-ZFIDAX7K.js} +1 -1
  43. package/dist/{chunk-XHW4CTBS.js → chunk-ZJMLEP5H.js} +1 -1
  44. package/dist/crud/index.cjs +4 -4
  45. package/dist/crud/index.js +3 -3
  46. package/dist/email/adapters/brevo.email.d.ts +22 -0
  47. package/dist/email/adapters/memory.email.d.ts +14 -0
  48. package/dist/email/adapters/message.d.ts +13 -0
  49. package/dist/email/adapters/resend.email.d.ts +28 -0
  50. package/dist/email/adapters/smtp.email.d.ts +22 -0
  51. package/dist/email/address.d.ts +15 -0
  52. package/dist/email/email.module.d.ts +37 -0
  53. package/dist/email/email.options.d.ts +39 -0
  54. package/dist/email/email.port.d.ts +62 -0
  55. package/dist/email/index.cjs +314 -0
  56. package/dist/email/index.d.ts +12 -0
  57. package/dist/email/index.js +314 -0
  58. package/dist/errors/app.exception.d.ts +9 -1
  59. package/dist/errors/common.exceptions.d.ts +6 -5
  60. package/dist/errors/global-exception.filter.d.ts +9 -0
  61. package/dist/errors/index.cjs +8 -5
  62. package/dist/errors/index.js +9 -6
  63. package/dist/i18n/i18n.interceptor.d.ts +16 -0
  64. package/dist/i18n/i18n.module.d.ts +49 -3
  65. package/dist/i18n/index.cjs +26 -2
  66. package/dist/i18n/index.d.ts +8 -0
  67. package/dist/i18n/index.js +25 -1
  68. package/dist/i18n/locale.d.ts +53 -0
  69. package/dist/i18n/message.d.ts +36 -0
  70. package/dist/i18n/nestjs-i18n.translator.d.ts +9 -0
  71. package/dist/i18n/runtime.d.ts +55 -0
  72. package/dist/i18n/translator.port.d.ts +29 -0
  73. package/dist/idempotency/index.cjs +6 -5
  74. package/dist/idempotency/index.js +3 -2
  75. package/dist/index.cjs +38 -16
  76. package/dist/index.js +47 -25
  77. package/dist/invoicing/index.cjs +14 -13
  78. package/dist/invoicing/index.js +3 -2
  79. package/dist/payments/index.cjs +15 -14
  80. package/dist/payments/index.js +3 -2
  81. package/dist/response/index.cjs +3 -3
  82. package/dist/response/index.js +2 -2
  83. package/dist/stripe/index.cjs +4 -3
  84. package/dist/stripe/index.js +3 -2
  85. package/dist/tracking/index.cjs +3 -3
  86. package/dist/tracking/index.js +2 -2
  87. package/dist/tracking/request-context.d.ts +10 -0
  88. package/package.json +6 -1
  89. package/dist/chunk-IYUUYCP5.js +0 -36
  90. package/dist/chunk-M3EL5O6T.cjs +0 -36
  91. package/dist/chunk-R7BVS6CI.cjs +0 -13
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Brand shared by every copy of the package in a dependency tree — see the
3
+ * note on `Symbol.for` in `response/paginated.ts`.
4
+ */
5
+ declare const I18N_MESSAGE: unique symbol;
6
+ /**
7
+ * A message that has not been translated yet: a key, its interpolation
8
+ * arguments, and what to say if no translation exists.
9
+ *
10
+ * It is deliberately lazy. The place that knows the message (a service
11
+ * throwing, a controller returning) rarely knows the language; the place that
12
+ * knows the language (the edge: `I18nInterceptor`, `GlobalExceptionFilter`)
13
+ * has no idea which messages are inside the payload. So the message travels as
14
+ * data and is resolved once, at the edge, in the request's language.
15
+ *
16
+ * Serialises to the fallback (or the key) when it reaches `JSON.stringify`
17
+ * untranslated — an app that never imported `I18nModule` still answers with a
18
+ * readable string rather than `{ "key": ... }`.
19
+ */
20
+ export declare class I18nMessage {
21
+ readonly key: string;
22
+ readonly args?: Record<string, unknown> | undefined;
23
+ readonly fallback?: string | undefined;
24
+ readonly [I18N_MESSAGE] = true;
25
+ constructor(key: string, args?: Record<string, unknown> | undefined, fallback?: string | undefined);
26
+ toJSON(): string;
27
+ toString(): string;
28
+ }
29
+ /**
30
+ * Builds a lazy message. `t('widgets.not_found', { id }, 'Widget not found')`
31
+ * reads the way every i18n library reads, but it does not translate here —
32
+ * see {@link I18nMessage}.
33
+ */
34
+ export declare function t(key: string, args?: Record<string, unknown>, fallback?: string): I18nMessage;
35
+ export declare function isI18nMessage(value: unknown): value is I18nMessage;
36
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { I18nService } from 'nestjs-i18n';
2
+ import type { TranslateOptions, TranslatorPort } from './translator.port.js';
3
+ /** {@link TranslatorPort} over `nestjs-i18n`: JSON files per language and namespace, held in memory. */
4
+ export declare class NestI18nTranslator implements TranslatorPort {
5
+ private readonly service;
6
+ constructor(service: I18nService);
7
+ translate(key: string, options?: TranslateOptions): string | undefined;
8
+ supportedLanguages(): string[];
9
+ }
@@ -0,0 +1,55 @@
1
+ import { I18nMessage } from './message.js';
2
+ import type { LocaleResolver } from './locale.js';
3
+ import type { TranslatorPort } from './translator.port.js';
4
+ /**
5
+ * What `I18nModule` leaves behind once it is wired, for the pieces that are
6
+ * not created through DI (`GlobalExceptionFilter` and `ResponseInterceptor`
7
+ * are `new`-ed in `applyNestKitDefaults`) and for code with no injector at
8
+ * all (a queue worker building an email).
9
+ *
10
+ * A module-level singleton for the same reason `RequestContext` is one — and
11
+ * the reason `splitting: true` is non-negotiable in `tsup.config.ts`: without
12
+ * it the `errors` bundle would hold a different copy of this variable than
13
+ * the `i18n` bundle that sets it.
14
+ */
15
+ export interface I18nRuntime {
16
+ translator: TranslatorPort;
17
+ fallbackLanguage: string;
18
+ resolveLocale: LocaleResolver;
19
+ /**
20
+ * Namespace under which an `AppException`'s `code` is looked up when it
21
+ * carries no explicit message key (`errors.NOT_FOUND`). `false` disables it.
22
+ */
23
+ errorCodes: string | false;
24
+ }
25
+ export declare function setI18nRuntime(next: I18nRuntime | undefined): void;
26
+ export declare function getI18nRuntime(): I18nRuntime | undefined;
27
+ export interface TranslateCallOptions {
28
+ /** Overrides the request's language — for an email in the recipient's language, say. */
29
+ lang?: string;
30
+ args?: Record<string, unknown>;
31
+ /** What to return when the key is missing; a message's own `fallback` wins over it. */
32
+ defaultValue?: string;
33
+ }
34
+ /** The language the current request speaks, or the configured fallback, or nothing. */
35
+ export declare function currentLanguage(): string | undefined;
36
+ /**
37
+ * Translates a key or an {@link I18nMessage} right now, in the current
38
+ * request's language unless `lang` says otherwise. Never throws: a missing
39
+ * key or a broken backend yields the fallback, then the key — a translation
40
+ * problem must not become the error a client sees.
41
+ */
42
+ export declare function translate(input: string | I18nMessage, options?: TranslateCallOptions): string;
43
+ /**
44
+ * Walks a value and replaces every {@link I18nMessage} inside it with its
45
+ * translation. This is what makes the interceptor generic: it does not care
46
+ * whether the controller returned an entity, a list, a page or `{ message }`.
47
+ *
48
+ * Only plain objects and arrays are entered. A class instance (a Date, a
49
+ * Buffer, a stream, an ORM entity with lazy relations) is passed through
50
+ * untouched — walking it would be unsafe, and serialising it is the
51
+ * consumer's business anyway. A page keeps its brand, so `ResponseInterceptor`
52
+ * still recognises it afterwards. Nothing is copied unless something under it
53
+ * actually changed.
54
+ */
55
+ export declare function translateDeep<T>(value: T, lang?: string): T;
@@ -0,0 +1,29 @@
1
+ export interface TranslateOptions {
2
+ /** Language to translate into. The adapter decides what happens when it is unknown. */
3
+ lang?: string;
4
+ /** Interpolation arguments — `{id}` placeholders, in the default adapter. */
5
+ args?: Record<string, unknown>;
6
+ }
7
+ /**
8
+ * What the rest of the package needs from a translation backend, and nothing
9
+ * more. `nestjs-i18n` with JSON files is the adapter that ships
10
+ * (`NestI18nTranslator`); a consumer with translations in a database, in
11
+ * `i18next`, or in memory implements these two methods and passes the object
12
+ * to `I18nModule.forRoot({ translator })`.
13
+ */
14
+ export interface TranslatorPort {
15
+ /**
16
+ * Returns the translated string, or `undefined` when the key does not exist
17
+ * in that language (after whatever fallback chain the backend applies). The
18
+ * callers decide what to show then — the message's fallback, or the key.
19
+ * Must not throw for a missing key.
20
+ */
21
+ translate(key: string, options?: TranslateOptions): string | undefined;
22
+ /**
23
+ * Languages the backend can actually answer in. Used to validate whatever
24
+ * the request asked for (`?lang=xx`) before it reaches the backend — an
25
+ * arbitrary tag from a query string must never turn into a lookup, a file
26
+ * path or an `Intl` call.
27
+ */
28
+ supportedLanguages(): string[];
29
+ }
@@ -1,8 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
3
 
4
- var _chunkFDNGAYTZcjs = require('../chunk-FDNGAYTZ.cjs');
5
- require('../chunk-R7BVS6CI.cjs');
4
+ var _chunkHDFPSA2Vcjs = require('../chunk-HDFPSA2V.cjs');
5
+ require('../chunk-Q5Y33L7B.cjs');
6
+ require('../chunk-PNK5WMPP.cjs');
6
7
 
7
8
 
8
9
 
@@ -91,7 +92,7 @@ var IdempotencyInterceptor = class {
91
92
  const key = headerOf(request, headerName);
92
93
  if (!key) {
93
94
  if (this.options.require) {
94
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(
95
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(
95
96
  `This endpoint requires an ${headerName} header`,
96
97
  { header: headerName },
97
98
  "IDEMPOTENCY_KEY_REQUIRED"
@@ -114,7 +115,7 @@ var IdempotencyInterceptor = class {
114
115
  }
115
116
  if (begin.state === "in_progress") {
116
117
  if (begin.fingerprint !== fingerprint) throw this.mismatch(headerName);
117
- throw new (0, _chunkFDNGAYTZcjs.ConflictAppException)(
118
+ throw new (0, _chunkHDFPSA2Vcjs.ConflictAppException)(
118
119
  "A request with this idempotency key is still being processed",
119
120
  { key },
120
121
  "IDEMPOTENCY_IN_PROGRESS"
@@ -144,7 +145,7 @@ var IdempotencyInterceptor = class {
144
145
  );
145
146
  }
146
147
  mismatch(headerName) {
147
- return new (0, _chunkFDNGAYTZcjs.ValidationAppException)(
148
+ return new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(
148
149
  `This ${headerName} was already used for a different request`,
149
150
  void 0,
150
151
  "IDEMPOTENCY_KEY_REUSED"
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  ConflictAppException,
3
3
  ValidationAppException
4
- } from "../chunk-ORWJ7LES.js";
5
- import "../chunk-YFYHLYHN.js";
4
+ } from "../chunk-ZFIDAX7K.js";
5
+ import "../chunk-M3GQDRWR.js";
6
+ import "../chunk-VVMRZEIW.js";
6
7
  import {
7
8
  __decorateClass,
8
9
  __decorateParam
package/dist/index.cjs CHANGED
@@ -1,4 +1,5 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-KVBQBT3D.cjs');
2
+
2
3
 
3
4
 
4
5
 
@@ -8,29 +9,50 @@ var _chunkRF75KC63cjs = require('./chunk-RF75KC63.cjs');
8
9
 
9
10
 
10
11
  var _chunkSPTDXUEDcjs = require('./chunk-SPTDXUED.cjs');
12
+ require('./chunk-H2EHN366.cjs');
13
+
14
+
15
+
16
+
17
+ var _chunkHVHYZXBBcjs = require('./chunk-HVHYZXBB.cjs');
18
+
19
+
20
+
21
+
22
+
23
+
24
+ var _chunkAPUFKA4Kcjs = require('./chunk-APUFKA4K.cjs');
25
+
26
+
27
+ var _chunkFNUZGYUFcjs = require('./chunk-FNUZGYUF.cjs');
11
28
 
12
29
 
30
+ var _chunk3AUOOEQOcjs = require('./chunk-3AUOOEQO.cjs');
13
31
 
14
32
 
15
- var _chunkU7QK24HLcjs = require('./chunk-U7QK24HL.cjs');
16
- require('./chunk-KVBQBT3D.cjs');
33
+
34
+
35
+ var _chunk52IOOHNXcjs = require('./chunk-52IOOHNX.cjs');
36
+ require('./chunk-W2T2VFLC.cjs');
37
+
38
+
39
+ var _chunkQS2W5XCQcjs = require('./chunk-QS2W5XCQ.cjs');
17
40
  require('./chunk-7SOM7EZP.cjs');
18
- require('./chunk-H2EHN366.cjs');
19
41
 
20
42
 
21
- var _chunk4GT66KQScjs = require('./chunk-4GT66KQS.cjs');
22
43
 
23
44
 
24
- var _chunk67B7IYAVcjs = require('./chunk-67B7IYAV.cjs');
25
45
 
26
46
 
27
- var _chunkUWDHAZVEcjs = require('./chunk-UWDHAZVE.cjs');
47
+ var _chunkHDFPSA2Vcjs = require('./chunk-HDFPSA2V.cjs');
48
+
28
49
 
50
+ var _chunkMSTXS3MUcjs = require('./chunk-MSTXS3MU.cjs');
29
51
 
30
52
 
31
53
 
32
- var _chunk47FXU74Gcjs = require('./chunk-47FXU74G.cjs');
33
- require('./chunk-XX5ROVSC.cjs');
54
+
55
+ var _chunkAXMW5JF7cjs = require('./chunk-AXMW5JF7.cjs');
34
56
 
35
57
 
36
58
 
@@ -38,25 +60,25 @@ require('./chunk-XX5ROVSC.cjs');
38
60
  var _chunkY72D5L6Icjs = require('./chunk-Y72D5L6I.cjs');
39
61
 
40
62
 
41
- var _chunkEBPEMVZUcjs = require('./chunk-EBPEMVZU.cjs');
63
+ var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
42
64
 
43
65
 
44
- var _chunkQS2W5XCQcjs = require('./chunk-QS2W5XCQ.cjs');
66
+ var _chunkQ5Y33L7Bcjs = require('./chunk-Q5Y33L7B.cjs');
67
+
45
68
 
46
69
 
47
70
 
48
- var _chunkM3EL5O6Tcjs = require('./chunk-M3EL5O6T.cjs');
71
+ var _chunkPNK5WMPPcjs = require('./chunk-PNK5WMPP.cjs');
72
+ require('./chunk-2REOCMUD.cjs');
73
+
49
74
 
50
75
 
51
76
 
52
77
 
53
78
 
54
79
 
55
- var _chunkFDNGAYTZcjs = require('./chunk-FDNGAYTZ.cjs');
56
80
 
57
81
 
58
- var _chunkR7BVS6CIcjs = require('./chunk-R7BVS6CI.cjs');
59
- require('./chunk-2REOCMUD.cjs');
60
82
 
61
83
 
62
84
 
@@ -86,4 +108,4 @@ require('./chunk-2REOCMUD.cjs');
86
108
 
87
109
 
88
110
 
89
- exports.AppException = _chunkR7BVS6CIcjs.AppException; exports.BaseCrudService = _chunk47FXU74Gcjs.BaseCrudService; exports.BaseResponseDto = _chunkQS2W5XCQcjs.BaseResponseDto; exports.ConflictAppException = _chunkFDNGAYTZcjs.ConflictAppException; exports.ForbiddenAppException = _chunkFDNGAYTZcjs.ForbiddenAppException; exports.GlobalExceptionFilter = _chunk67B7IYAVcjs.GlobalExceptionFilter; exports.I18nModule = _chunkM3EL5O6Tcjs.I18nModule; exports.ListQuery = _chunk47FXU74Gcjs.ListQuery; exports.NotFoundAppException = _chunkFDNGAYTZcjs.NotFoundAppException; exports.PG_POOL = _chunkRF75KC63cjs.PG_POOL; exports.PgModule = _chunkRF75KC63cjs.PgModule; exports.REQUEST_ID_HEADER = _chunkU7QK24HLcjs.REQUEST_ID_HEADER; exports.RequestContext = _chunkEBPEMVZUcjs.RequestContext; exports.RequestIdMiddleware = _chunkU7QK24HLcjs.RequestIdMiddleware; exports.ResponseInterceptor = _chunkUWDHAZVEcjs.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 = _chunkU7QK24HLcjs.TrackingModule; exports.UnauthorizedAppException = _chunkFDNGAYTZcjs.UnauthorizedAppException; exports.ValidationAppException = _chunkFDNGAYTZcjs.ValidationAppException; exports.applyNestKitDefaults = _chunk4GT66KQScjs.applyNestKitDefaults; exports.buildPageMeta = _chunkY72D5L6Icjs.buildPageMeta; exports.createCrudController = _chunk47FXU74Gcjs.createCrudController; exports.isPaginated = _chunkY72D5L6Icjs.isPaginated; exports.paginated = _chunkY72D5L6Icjs.paginated; exports.translateOr = _chunkM3EL5O6Tcjs.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 = _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;
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import "./chunk-EPVKCBPT.js";
1
2
  import {
2
3
  PG_POOL,
3
4
  PgModule,
@@ -8,54 +9,66 @@ import {
8
9
  SUPABASE_SERVICE_ROLE_CLIENT,
9
10
  SupabaseModule
10
11
  } from "./chunk-PA24P76K.js";
12
+ import "./chunk-ODPSIFOB.js";
11
13
  import {
12
14
  REQUEST_ID_HEADER,
13
15
  RequestIdMiddleware,
14
16
  TrackingModule
15
- } from "./chunk-JV4EAOF2.js";
16
- import "./chunk-EPVKCBPT.js";
17
- import "./chunk-DQYAIQQ5.js";
18
- import "./chunk-ODPSIFOB.js";
17
+ } from "./chunk-4PFAKLT3.js";
19
18
  import {
20
- applyNestKitDefaults
21
- } from "./chunk-UIVBPNH4.js";
19
+ I18nInterceptor,
20
+ I18nModule,
21
+ NestI18nTranslator,
22
+ matchLanguage,
23
+ translateOr
24
+ } from "./chunk-6RAPVLJM.js";
22
25
  import {
23
- GlobalExceptionFilter
24
- } from "./chunk-KRC47OX6.js";
26
+ applyNestKitDefaults
27
+ } from "./chunk-UNEVXCFW.js";
25
28
  import {
26
29
  ResponseInterceptor
27
- } from "./chunk-DABTRWA6.js";
30
+ } from "./chunk-DYHSOULW.js";
28
31
  import {
29
32
  BaseCrudService,
30
33
  ListQuery,
31
34
  createCrudController
32
- } from "./chunk-LK3OINS7.js";
33
- import "./chunk-XHW4CTBS.js";
34
- import {
35
- buildPageMeta,
36
- isPaginated,
37
- paginated
38
- } from "./chunk-TCAMLNUZ.js";
39
- import {
40
- RequestContext
41
- } from "./chunk-KP2ZHJSR.js";
35
+ } from "./chunk-IFNYRZP2.js";
36
+ import "./chunk-ZJMLEP5H.js";
42
37
  import {
43
38
  BaseResponseDto
44
39
  } from "./chunk-XX2HPTRU.js";
45
- import {
46
- I18nModule,
47
- translateOr
48
- } from "./chunk-IYUUYCP5.js";
40
+ import "./chunk-DQYAIQQ5.js";
49
41
  import {
50
42
  ConflictAppException,
51
43
  ForbiddenAppException,
52
44
  NotFoundAppException,
53
45
  UnauthorizedAppException,
54
46
  ValidationAppException
55
- } from "./chunk-ORWJ7LES.js";
47
+ } from "./chunk-ZFIDAX7K.js";
48
+ import {
49
+ GlobalExceptionFilter
50
+ } from "./chunk-A2DGK4ZL.js";
51
+ import {
52
+ currentLanguage,
53
+ translate,
54
+ translateDeep
55
+ } from "./chunk-X4PQJZ4G.js";
56
+ import {
57
+ buildPageMeta,
58
+ isPaginated,
59
+ paginated
60
+ } from "./chunk-TCAMLNUZ.js";
61
+ import {
62
+ RequestContext
63
+ } from "./chunk-ETRUVZTJ.js";
56
64
  import {
57
65
  AppException
58
- } from "./chunk-YFYHLYHN.js";
66
+ } from "./chunk-M3GQDRWR.js";
67
+ import {
68
+ I18nMessage,
69
+ isI18nMessage,
70
+ t
71
+ } from "./chunk-VVMRZEIW.js";
59
72
  import "./chunk-4MGIQFAJ.js";
60
73
  export {
61
74
  AppException,
@@ -64,8 +77,11 @@ export {
64
77
  ConflictAppException,
65
78
  ForbiddenAppException,
66
79
  GlobalExceptionFilter,
80
+ I18nInterceptor,
81
+ I18nMessage,
67
82
  I18nModule,
68
83
  ListQuery,
84
+ NestI18nTranslator,
69
85
  NotFoundAppException,
70
86
  PG_POOL,
71
87
  PgModule,
@@ -82,8 +98,14 @@ export {
82
98
  applyNestKitDefaults,
83
99
  buildPageMeta,
84
100
  createCrudController,
101
+ currentLanguage,
102
+ isI18nMessage,
85
103
  isPaginated,
104
+ matchLanguage,
86
105
  paginated,
106
+ t,
107
+ translate,
108
+ translateDeep,
87
109
  translateOr,
88
110
  withTenantScope
89
111
  };
@@ -1,9 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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 _chunkFDNGAYTZcjs = require('../chunk-FDNGAYTZ.cjs');
3
+ var _chunkHDFPSA2Vcjs = require('../chunk-HDFPSA2V.cjs');
4
4
 
5
5
 
6
- var _chunkR7BVS6CIcjs = require('../chunk-R7BVS6CI.cjs');
6
+ var _chunkQ5Y33L7Bcjs = require('../chunk-Q5Y33L7B.cjs');
7
+ require('../chunk-PNK5WMPP.cjs');
7
8
 
8
9
 
9
10
  var _chunk2REOCMUDcjs = require('../chunk-2REOCMUD.cjs');
@@ -23,12 +24,12 @@ function roundHalfUp(value) {
23
24
  }
24
25
  function assertCents(cents, field) {
25
26
  if (!Number.isInteger(cents)) {
26
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(`${field} must be an integer number of cents, got ${cents}`, {
27
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(`${field} must be an integer number of cents, got ${cents}`, {
27
28
  [field]: cents
28
29
  });
29
30
  }
30
31
  if (cents < 0) {
31
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(`${field} must not be negative, got ${cents}`, { [field]: cents });
32
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(`${field} must not be negative, got ${cents}`, { [field]: cents });
32
33
  }
33
34
  }
34
35
  function centsToDecimal(cents) {
@@ -40,7 +41,7 @@ function decimalToCents(value) {
40
41
  const text = typeof value === "number" ? value.toFixed(2) : value.trim();
41
42
  const match = /^(-?)(\d+)(?:\.(\d+))?$/.exec(text);
42
43
  if (!match) {
43
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(`Cannot read "${text}" as a decimal amount`, { value });
44
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(`Cannot read "${text}" as a decimal amount`, { value });
44
45
  }
45
46
  const [, sign, whole, fraction = ""] = match;
46
47
  const cents = Number(whole) * 100 + roundHalfUp(Number(`0.${fraction || "0"}`) * 100);
@@ -48,7 +49,7 @@ function decimalToCents(value) {
48
49
  }
49
50
  function assertDecimalString(value, field) {
50
51
  if (!/^\d+(\.\d{1,6})?$/.test(value.trim())) {
51
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(
52
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(
52
53
  `${field} must be a decimal with at most 6 places, written as a string, got "${value}"`,
53
54
  { [field]: value }
54
55
  );
@@ -59,7 +60,7 @@ function unitPriceToDecimal(price) {
59
60
  }
60
61
  function lineAmountCents(price, quantity) {
61
62
  if (!(quantity > 0) || !Number.isFinite(quantity)) {
62
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(`quantity must be a positive number, got ${quantity}`, { quantity });
63
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(`quantity must be a positive number, got ${quantity}`, { quantity });
63
64
  }
64
65
  const micros = "cents" in price ? price.cents * 1e4 : roundHalfUp(Number(price.decimal) * 1e6);
65
66
  return roundHalfUp(micros * quantity / 1e4);
@@ -74,7 +75,7 @@ function unitPriceOf(item) {
74
75
  const hasCents = item.unitPriceCents !== void 0;
75
76
  const hasDecimal = item.unitPrice !== void 0;
76
77
  if (hasCents === hasDecimal) {
77
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(
78
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(
78
79
  "each item needs exactly one of unitPriceCents (the usual) or unitPrice (an exact decimal string)",
79
80
  { description: item.description }
80
81
  );
@@ -88,10 +89,10 @@ function unitPriceOf(item) {
88
89
  }
89
90
  function computeLine(item) {
90
91
  if (!_optionalChain([item, 'access', _ => _.description, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()])) {
91
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)("each item needs a description", { item });
92
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)("each item needs a description", { item });
92
93
  }
93
94
  if (!_optionalChain([item, 'access', _4 => _4.productKey, 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()])) {
94
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(
95
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(
95
96
  `item "${item.description}" needs a productKey (ClaveProdServ from the SAT catalogue)`,
96
97
  { item }
97
98
  );
@@ -112,7 +113,7 @@ function computeLine(item) {
112
113
  }
113
114
  function computeLines(items) {
114
115
  if (items.length === 0) {
115
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)("an invoice needs at least one item", { items });
116
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)("an invoice needs at least one item", { items });
116
117
  }
117
118
  return items.map(computeLine);
118
119
  }
@@ -123,7 +124,7 @@ var decimal = centsToDecimal;
123
124
 
124
125
  // src/invoicing/provider-http.ts
125
126
 
126
- var InvoicingProviderException = class extends _chunkR7BVS6CIcjs.AppException {
127
+ var InvoicingProviderException = class extends _chunkQ5Y33L7Bcjs.AppException {
127
128
  constructor(provider, status, body, message) {
128
129
  super(
129
130
  "INVOICING_PROVIDER_ERROR",
@@ -133,7 +134,7 @@ var InvoicingProviderException = class extends _chunkR7BVS6CIcjs.AppException {
133
134
  );
134
135
  }
135
136
  };
136
- var UnsupportedByProviderException = class extends _chunkR7BVS6CIcjs.AppException {
137
+ var UnsupportedByProviderException = class extends _chunkQ5Y33L7Bcjs.AppException {
137
138
  constructor(provider, message) {
138
139
  super("INVOICING_UNSUPPORTED", message, _common.HttpStatus.BAD_REQUEST, { provider });
139
140
  }
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  ValidationAppException
3
- } from "../chunk-ORWJ7LES.js";
3
+ } from "../chunk-ZFIDAX7K.js";
4
4
  import {
5
5
  AppException
6
- } from "../chunk-YFYHLYHN.js";
6
+ } from "../chunk-M3GQDRWR.js";
7
+ import "../chunk-VVMRZEIW.js";
7
8
  import {
8
9
  __decorateClass
9
10
  } from "../chunk-4MGIQFAJ.js";
@@ -1,10 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
3
 
4
- var _chunkFDNGAYTZcjs = require('../chunk-FDNGAYTZ.cjs');
4
+ var _chunkHDFPSA2Vcjs = require('../chunk-HDFPSA2V.cjs');
5
5
 
6
6
 
7
- var _chunkR7BVS6CIcjs = require('../chunk-R7BVS6CI.cjs');
7
+ var _chunkQ5Y33L7Bcjs = require('../chunk-Q5Y33L7B.cjs');
8
+ require('../chunk-PNK5WMPP.cjs');
8
9
 
9
10
 
10
11
 
@@ -25,15 +26,15 @@ var _crypto = require('crypto');
25
26
  // src/payments/money.ts
26
27
  function assertCents(cents, field = "amountCents") {
27
28
  if (!Number.isInteger(cents)) {
28
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(`${field} must be an integer number of cents, got ${cents}`, {
29
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(`${field} must be an integer number of cents, got ${cents}`, {
29
30
  [field]: cents
30
31
  });
31
32
  }
32
33
  if (cents < 0) {
33
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(`${field} must not be negative, got ${cents}`, { [field]: cents });
34
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(`${field} must not be negative, got ${cents}`, { [field]: cents });
34
35
  }
35
36
  if (!Number.isSafeInteger(cents)) {
36
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(`${field} is out of safe integer range`, { [field]: cents });
37
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(`${field} is out of safe integer range`, { [field]: cents });
37
38
  }
38
39
  }
39
40
  function centsToDecimalString(cents) {
@@ -45,7 +46,7 @@ function decimalToCents(value) {
45
46
  const text = typeof value === "number" ? value.toFixed(2) : value.trim();
46
47
  const match = /^(-?)(\d+)(?:\.(\d{1,2}))?$/.exec(text);
47
48
  if (!match) {
48
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(`Cannot read "${text}" as a decimal amount`, { value });
49
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(`Cannot read "${text}" as a decimal amount`, { value });
49
50
  }
50
51
  const [, sign, whole, fraction = ""] = match;
51
52
  const cents = Number(whole) * 100 + Number(fraction.padEnd(2, "0"));
@@ -54,7 +55,7 @@ function decimalToCents(value) {
54
55
 
55
56
  // src/payments/provider-http.ts
56
57
 
57
- var TerminalPaymentProviderException = class extends _chunkR7BVS6CIcjs.AppException {
58
+ var TerminalPaymentProviderException = class extends _chunkQ5Y33L7Bcjs.AppException {
58
59
  constructor(provider, status, body, message) {
59
60
  super(
60
61
  "TERMINAL_PAYMENT_PROVIDER_ERROR",
@@ -64,7 +65,7 @@ var TerminalPaymentProviderException = class extends _chunkR7BVS6CIcjs.AppExcept
64
65
  );
65
66
  }
66
67
  };
67
- var UnsupportedByProviderException = class extends _chunkR7BVS6CIcjs.AppException {
68
+ var UnsupportedByProviderException = class extends _chunkQ5Y33L7Bcjs.AppException {
68
69
  constructor(provider, message) {
69
70
  super("TERMINAL_PAYMENT_UNSUPPORTED", message, _common.HttpStatus.BAD_REQUEST, { provider });
70
71
  }
@@ -122,7 +123,7 @@ function toStatus(status) {
122
123
  }
123
124
  function assertReference(reference) {
124
125
  if (!/^[A-Za-z0-9_-]{1,64}$/.test(reference)) {
125
- throw new (0, _chunkFDNGAYTZcjs.ValidationAppException)(
126
+ throw new (0, _chunkHDFPSA2Vcjs.ValidationAppException)(
126
127
  "reference must be 1-64 characters of letters, digits, hyphens or underscores for Mercado Pago",
127
128
  { reference }
128
129
  );
@@ -348,7 +349,7 @@ var MercadoPagoTerminalPayments = class {
348
349
  const signature = header("x-signature");
349
350
  const requestId = header("x-request-id");
350
351
  if (!signature || !requestId) {
351
- throw new (0, _chunkFDNGAYTZcjs.UnauthorizedAppException)("Missing Mercado Pago webhook signature headers", void 0, "INVALID_WEBHOOK_SIGNATURE");
352
+ throw new (0, _chunkHDFPSA2Vcjs.UnauthorizedAppException)("Missing Mercado Pago webhook signature headers", void 0, "INVALID_WEBHOOK_SIGNATURE");
352
353
  }
353
354
  const parts = new Map(
354
355
  signature.split(",").map((part) => {
@@ -361,13 +362,13 @@ var MercadoPagoTerminalPayments = class {
361
362
  const body = request.body;
362
363
  const dataId = String(_nullishCoalesce(_nullishCoalesce(_optionalChain([request, 'access', _10 => _10.query, 'optionalAccess', _11 => _11["data.id"]]), () => ( _optionalChain([body, 'optionalAccess', _12 => _12.data, 'optionalAccess', _13 => _13.id]))), () => ( "")));
363
364
  if (!ts || !received || !dataId) {
364
- throw new (0, _chunkFDNGAYTZcjs.UnauthorizedAppException)("Malformed Mercado Pago webhook signature", void 0, "INVALID_WEBHOOK_SIGNATURE");
365
+ throw new (0, _chunkHDFPSA2Vcjs.UnauthorizedAppException)("Malformed Mercado Pago webhook signature", void 0, "INVALID_WEBHOOK_SIGNATURE");
365
366
  }
366
367
  const manifest = `id:${dataId.toLowerCase()};request-id:${requestId};ts:${ts};`;
367
368
  const expected = _crypto.createHmac.call(void 0, "sha256", secret).update(manifest).digest();
368
369
  const provided = Buffer.from(received, "hex");
369
370
  if (provided.length !== expected.length || !_crypto.timingSafeEqual.call(void 0, provided, expected)) {
370
- throw new (0, _chunkFDNGAYTZcjs.UnauthorizedAppException)("Invalid Mercado Pago webhook signature", void 0, "INVALID_WEBHOOK_SIGNATURE");
371
+ throw new (0, _chunkHDFPSA2Vcjs.UnauthorizedAppException)("Invalid Mercado Pago webhook signature", void 0, "INVALID_WEBHOOK_SIGNATURE");
371
372
  }
372
373
  return { provider: PROVIDER, paymentId: dataId, action: _optionalChain([body, 'optionalAccess', _14 => _14.action]), raw: request.body };
373
374
  }
@@ -669,13 +670,13 @@ var ClipTerminalPayments = class {
669
670
  const a = Buffer.from(provided);
670
671
  const b = Buffer.from(expected);
671
672
  if (a.length !== b.length || !_crypto.timingSafeEqual.call(void 0, a, b)) {
672
- throw new (0, _chunkFDNGAYTZcjs.UnauthorizedAppException)("Invalid Clip webhook token", void 0, "INVALID_WEBHOOK_SIGNATURE");
673
+ throw new (0, _chunkHDFPSA2Vcjs.UnauthorizedAppException)("Invalid Clip webhook token", void 0, "INVALID_WEBHOOK_SIGNATURE");
673
674
  }
674
675
  }
675
676
  const body = request.body;
676
677
  const paymentId = _optionalChain([body, 'optionalAccess', _26 => _26.id]);
677
678
  if (!paymentId) {
678
- throw new (0, _chunkFDNGAYTZcjs.UnauthorizedAppException)("Clip webhook carried no payment id", void 0, "INVALID_WEBHOOK_PAYLOAD");
679
+ throw new (0, _chunkHDFPSA2Vcjs.UnauthorizedAppException)("Clip webhook carried no payment id", void 0, "INVALID_WEBHOOK_PAYLOAD");
679
680
  }
680
681
  return { provider: PROVIDER2, paymentId, action: _optionalChain([body, 'optionalAccess', _27 => _27.event_type]), raw: request.body };
681
682
  }
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  UnauthorizedAppException,
3
3
  ValidationAppException
4
- } from "../chunk-ORWJ7LES.js";
4
+ } from "../chunk-ZFIDAX7K.js";
5
5
  import {
6
6
  AppException
7
- } from "../chunk-YFYHLYHN.js";
7
+ } from "../chunk-M3GQDRWR.js";
8
+ import "../chunk-VVMRZEIW.js";
8
9
  import {
9
10
  __decorateClass,
10
11
  __decorateParam