@miguelmorales13/nestkit 0.16.0 → 0.18.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 (79) hide show
  1. package/README.md +152 -28
  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-C5DV4RAX.cjs → chunk-4HHZFOVC.cjs} +6 -6
  20. package/dist/{chunk-JV4EAOF2.js → chunk-4PFAKLT3.js} +1 -1
  21. package/dist/{chunk-47FXU74G.cjs → chunk-52IOOHNX.cjs} +2 -2
  22. package/dist/chunk-6RAPVLJM.js +212 -0
  23. package/dist/{chunk-KRC47OX6.js → chunk-A2DGK4ZL.js} +26 -3
  24. package/dist/chunk-APUFKA4K.cjs +212 -0
  25. package/dist/chunk-AXMW5JF7.cjs +83 -0
  26. package/dist/{chunk-DABTRWA6.js → chunk-DYHSOULW.js} +1 -1
  27. package/dist/{chunk-KP2ZHJSR.js → chunk-ETRUVZTJ.js} +8 -0
  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-MLOQDUBN.js → chunk-IKXSVEJ7.js} +2 -2
  33. package/dist/{chunk-YFYHLYHN.js → chunk-M3GQDRWR.js} +7 -1
  34. package/dist/{chunk-67B7IYAV.cjs → chunk-MSTXS3MU.cjs} +28 -5
  35. package/dist/chunk-PNK5WMPP.cjs +30 -0
  36. package/dist/chunk-Q5Y33L7B.cjs +19 -0
  37. package/dist/{chunk-EBPEMVZU.cjs → chunk-SDWHKPXI.cjs} +8 -0
  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/errors/app.exception.d.ts +9 -1
  47. package/dist/errors/common.exceptions.d.ts +6 -5
  48. package/dist/errors/global-exception.filter.d.ts +9 -0
  49. package/dist/errors/index.cjs +8 -5
  50. package/dist/errors/index.js +7 -4
  51. package/dist/i18n/i18n.interceptor.d.ts +16 -0
  52. package/dist/i18n/i18n.module.d.ts +49 -3
  53. package/dist/i18n/index.cjs +26 -2
  54. package/dist/i18n/index.d.ts +8 -0
  55. package/dist/i18n/index.js +25 -1
  56. package/dist/i18n/locale.d.ts +53 -0
  57. package/dist/i18n/message.d.ts +36 -0
  58. package/dist/i18n/nestjs-i18n.translator.d.ts +9 -0
  59. package/dist/i18n/runtime.d.ts +55 -0
  60. package/dist/i18n/translator.port.d.ts +29 -0
  61. package/dist/idempotency/index.cjs +6 -5
  62. package/dist/idempotency/index.js +3 -2
  63. package/dist/index.cjs +36 -14
  64. package/dist/index.js +41 -19
  65. package/dist/invoicing/index.cjs +14 -13
  66. package/dist/invoicing/index.js +3 -2
  67. package/dist/payments/index.cjs +15 -14
  68. package/dist/payments/index.js +3 -2
  69. package/dist/response/index.cjs +3 -3
  70. package/dist/response/index.js +2 -2
  71. package/dist/stripe/index.cjs +4 -3
  72. package/dist/stripe/index.js +3 -2
  73. package/dist/tracking/index.cjs +3 -3
  74. package/dist/tracking/index.js +2 -2
  75. package/dist/tracking/request-context.d.ts +10 -0
  76. package/package.json +1 -1
  77. package/dist/chunk-IYUUYCP5.js +0 -36
  78. package/dist/chunk-M3EL5O6T.cjs +0 -36
  79. package/dist/chunk-R7BVS6CI.cjs +0 -13
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Structural request shape, so locale resolution works on Express and
3
+ * Fastify alike (Fastify exposes the raw headers on `raw`; both expose
4
+ * `headers` and `query` directly).
5
+ */
6
+ export interface LocaleRequest {
7
+ headers?: Record<string, string | string[] | undefined>;
8
+ query?: Record<string, unknown>;
9
+ cookies?: Record<string, string | undefined>;
10
+ }
11
+ /**
12
+ * Where the language comes from. Listed in order of precedence: the first
13
+ * source that yields a supported language wins.
14
+ *
15
+ * - `query` — `?lang=en`; the name comes from `LocaleOptions.query`.
16
+ * - `header` — a custom header such as `x-lang`; `LocaleOptions.header`.
17
+ * - `cookie` — `LocaleOptions.cookie`; read from the `Cookie` header
18
+ * directly, so it works without `cookie-parser`.
19
+ * - `accept-language` — the browser's header, with `q` weights and region
20
+ * fallback (`es-MX` matches `es`).
21
+ * - a function — anything else: the tenant's default language, a
22
+ * user preference read by a guard, a path prefix.
23
+ */
24
+ export type LocaleSource = 'query' | 'header' | 'cookie' | 'accept-language' | ((req: LocaleRequest) => string | undefined);
25
+ export interface LocaleOptions {
26
+ /** Defaults to `['query', 'header', 'cookie', 'accept-language']`. */
27
+ from?: LocaleSource[];
28
+ /** Query parameter name. Defaults to `lang`. */
29
+ query?: string;
30
+ /** Header name, case-insensitive. Defaults to `x-lang`. */
31
+ header?: string;
32
+ /** Cookie name. Defaults to `lang`. */
33
+ cookie?: string;
34
+ }
35
+ export type LocaleResolver = (req: LocaleRequest) => string | undefined;
36
+ /**
37
+ * Compiles the options into one function the interceptor and the filter can
38
+ * call per request. Every candidate goes through {@link matchLanguage}, so a
39
+ * value the backend cannot answer in is skipped rather than passed along —
40
+ * the next source gets its turn, and the fallback language is what remains.
41
+ */
42
+ export declare function buildLocaleResolver(options: LocaleOptions, supportedLanguages: () => string[]): LocaleResolver;
43
+ /**
44
+ * Picks the best supported language out of a raw value, which may be a single
45
+ * tag (`en`, `es-MX`) or a full `Accept-Language` header
46
+ * (`es-MX,es;q=0.9,en;q=0.8`). Exact match first, then the base language of a
47
+ * regional tag, in the order the client stated its preferences.
48
+ *
49
+ * With no supported list (a backend that cannot enumerate its languages) the
50
+ * first tag is returned as-is, but only if it looks like a language tag —
51
+ * that is the last line between a query string and an `Intl` constructor.
52
+ */
53
+ export declare function matchLanguage(raw: string, supported: string[]): string | undefined;
@@ -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
@@ -8,54 +8,67 @@ var _chunkRF75KC63cjs = require('./chunk-RF75KC63.cjs');
8
8
 
9
9
 
10
10
  var _chunkSPTDXUEDcjs = require('./chunk-SPTDXUED.cjs');
11
+ require('./chunk-H2EHN366.cjs');
11
12
 
12
13
 
13
14
 
14
15
 
15
- var _chunkU7QK24HLcjs = require('./chunk-U7QK24HL.cjs');
16
+ var _chunkHVHYZXBBcjs = require('./chunk-HVHYZXBB.cjs');
16
17
  require('./chunk-KVBQBT3D.cjs');
17
18
  require('./chunk-7SOM7EZP.cjs');
18
- require('./chunk-H2EHN366.cjs');
19
19
 
20
20
 
21
- var _chunk4GT66KQScjs = require('./chunk-4GT66KQS.cjs');
21
+ var _chunkFNUZGYUFcjs = require('./chunk-FNUZGYUF.cjs');
22
22
 
23
23
 
24
- var _chunk67B7IYAVcjs = require('./chunk-67B7IYAV.cjs');
24
+ var _chunk3AUOOEQOcjs = require('./chunk-3AUOOEQO.cjs');
25
25
 
26
26
 
27
- var _chunkUWDHAZVEcjs = require('./chunk-UWDHAZVE.cjs');
27
+ var _chunkMSTXS3MUcjs = require('./chunk-MSTXS3MU.cjs');
28
28
 
29
29
 
30
30
 
31
31
 
32
- var _chunk47FXU74Gcjs = require('./chunk-47FXU74G.cjs');
33
- require('./chunk-XX5ROVSC.cjs');
32
+ var _chunk52IOOHNXcjs = require('./chunk-52IOOHNX.cjs');
33
+ require('./chunk-W2T2VFLC.cjs');
34
34
 
35
35
 
36
+ var _chunkQS2W5XCQcjs = require('./chunk-QS2W5XCQ.cjs');
36
37
 
37
38
 
38
- var _chunkY72D5L6Icjs = require('./chunk-Y72D5L6I.cjs');
39
39
 
40
40
 
41
- var _chunkEBPEMVZUcjs = require('./chunk-EBPEMVZU.cjs');
42
41
 
43
42
 
44
- var _chunkQS2W5XCQcjs = require('./chunk-QS2W5XCQ.cjs');
43
+ var _chunkAPUFKA4Kcjs = require('./chunk-APUFKA4K.cjs');
44
+
45
+
46
+
47
+
48
+ var _chunkAXMW5JF7cjs = require('./chunk-AXMW5JF7.cjs');
49
+
50
+
51
+
52
+
53
+ var _chunkY72D5L6Icjs = require('./chunk-Y72D5L6I.cjs');
54
+
55
+
56
+ var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
57
+
45
58
 
46
59
 
47
60
 
48
- var _chunkM3EL5O6Tcjs = require('./chunk-M3EL5O6T.cjs');
49
61
 
50
62
 
63
+ var _chunkHDFPSA2Vcjs = require('./chunk-HDFPSA2V.cjs');
51
64
 
52
65
 
66
+ var _chunkQ5Y33L7Bcjs = require('./chunk-Q5Y33L7B.cjs');
53
67
 
54
68
 
55
- var _chunkFDNGAYTZcjs = require('./chunk-FDNGAYTZ.cjs');
56
69
 
57
70
 
58
- var _chunkR7BVS6CIcjs = require('./chunk-R7BVS6CI.cjs');
71
+ var _chunkPNK5WMPPcjs = require('./chunk-PNK5WMPP.cjs');
59
72
  require('./chunk-2REOCMUD.cjs');
60
73
 
61
74
 
@@ -86,4 +99,13 @@ require('./chunk-2REOCMUD.cjs');
86
99
 
87
100
 
88
101
 
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;
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
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;
package/dist/index.js CHANGED
@@ -8,29 +8,44 @@ import {
8
8
  SUPABASE_SERVICE_ROLE_CLIENT,
9
9
  SupabaseModule
10
10
  } from "./chunk-PA24P76K.js";
11
+ import "./chunk-ODPSIFOB.js";
11
12
  import {
12
13
  REQUEST_ID_HEADER,
13
14
  RequestIdMiddleware,
14
15
  TrackingModule
15
- } from "./chunk-JV4EAOF2.js";
16
+ } from "./chunk-4PFAKLT3.js";
16
17
  import "./chunk-EPVKCBPT.js";
17
18
  import "./chunk-DQYAIQQ5.js";
18
- import "./chunk-ODPSIFOB.js";
19
19
  import {
20
20
  applyNestKitDefaults
21
- } from "./chunk-UIVBPNH4.js";
22
- import {
23
- GlobalExceptionFilter
24
- } from "./chunk-KRC47OX6.js";
21
+ } from "./chunk-UNEVXCFW.js";
25
22
  import {
26
23
  ResponseInterceptor
27
- } from "./chunk-DABTRWA6.js";
24
+ } from "./chunk-DYHSOULW.js";
25
+ import {
26
+ GlobalExceptionFilter
27
+ } from "./chunk-A2DGK4ZL.js";
28
28
  import {
29
29
  BaseCrudService,
30
30
  ListQuery,
31
31
  createCrudController
32
- } from "./chunk-LK3OINS7.js";
33
- import "./chunk-XHW4CTBS.js";
32
+ } from "./chunk-IFNYRZP2.js";
33
+ import "./chunk-ZJMLEP5H.js";
34
+ import {
35
+ BaseResponseDto
36
+ } from "./chunk-XX2HPTRU.js";
37
+ import {
38
+ I18nInterceptor,
39
+ I18nModule,
40
+ NestI18nTranslator,
41
+ matchLanguage,
42
+ translateOr
43
+ } from "./chunk-6RAPVLJM.js";
44
+ import {
45
+ currentLanguage,
46
+ translate,
47
+ translateDeep
48
+ } from "./chunk-X4PQJZ4G.js";
34
49
  import {
35
50
  buildPageMeta,
36
51
  isPaginated,
@@ -38,24 +53,22 @@ import {
38
53
  } from "./chunk-TCAMLNUZ.js";
39
54
  import {
40
55
  RequestContext
41
- } from "./chunk-KP2ZHJSR.js";
42
- import {
43
- BaseResponseDto
44
- } from "./chunk-XX2HPTRU.js";
45
- import {
46
- I18nModule,
47
- translateOr
48
- } from "./chunk-IYUUYCP5.js";
56
+ } from "./chunk-ETRUVZTJ.js";
49
57
  import {
50
58
  ConflictAppException,
51
59
  ForbiddenAppException,
52
60
  NotFoundAppException,
53
61
  UnauthorizedAppException,
54
62
  ValidationAppException
55
- } from "./chunk-ORWJ7LES.js";
63
+ } from "./chunk-ZFIDAX7K.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";