@miguelmorales13/nestkit 0.25.0 → 0.28.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 +5 -0
- package/dist/alerts/alert-on-failure.decorator.d.ts +5 -0
- package/dist/alerts/alert-sinks.d.ts +29 -0
- package/dist/alerts/alerts.module.d.ts +19 -0
- package/dist/alerts/alerts.options.d.ts +1 -0
- package/dist/alerts/alerts.service.d.ts +28 -0
- package/dist/alerts/alerts.types.d.ts +66 -0
- package/dist/alerts/index.cjs +276 -0
- package/dist/alerts/index.d.ts +10 -0
- package/dist/alerts/index.js +276 -0
- package/dist/alerts/logger-with-alerts.d.ts +18 -0
- package/dist/alerts/process-guards.d.ts +21 -0
- package/dist/alerts/runtime.d.ts +4 -0
- package/dist/audit/index.cjs +13 -13
- package/dist/audit/index.js +2 -2
- package/dist/auth/index.cjs +21 -21
- package/dist/auth/index.js +3 -3
- package/dist/auth/oauth/index.cjs +123 -115
- package/dist/auth/oauth/index.js +25 -17
- package/dist/auth/oauth/oauth-provider.d.ts +9 -0
- package/dist/auth/oauth/providers/apple.d.ts +3 -1
- package/dist/bootstrap/apply-defaults.d.ts +9 -0
- package/dist/bootstrap/index.cjs +6 -5
- package/dist/bootstrap/index.js +5 -4
- package/dist/chunk-3TUMVLPJ.js +14 -0
- package/dist/{chunk-PA24P76K.js → chunk-45SW7FBE.js} +1 -1
- package/dist/{chunk-RF75KC63.cjs → chunk-47IYXZHW.cjs} +2 -2
- package/dist/{chunk-TUNDBBQF.js → chunk-4WWOKZIO.js} +4 -4
- package/dist/{chunk-A2DGK4ZL.js → chunk-5LVGCTJ3.js} +1 -1
- package/dist/chunk-A6YGIZCQ.cjs +14 -0
- package/dist/chunk-A7FI6HXV.js +40 -0
- package/dist/chunk-CU4FUIVJ.cjs +8 -0
- package/dist/{chunk-FH5UNWWW.cjs → chunk-D35TBVRO.cjs} +4 -4
- package/dist/{chunk-4MGIQFAJ.js → chunk-D3DDJWUD.js} +5 -0
- package/dist/chunk-DVGPEBUL.js +8 -0
- package/dist/{chunk-VKOPDDCC.js → chunk-ENZ7LQRE.js} +1 -1
- package/dist/{chunk-3AUOOEQO.cjs → chunk-F77X4QUN.cjs} +2 -2
- package/dist/chunk-FBNV5X6C.js +61 -0
- package/dist/{chunk-APUFKA4K.cjs → chunk-FDZQCLLK.cjs} +6 -6
- package/dist/{chunk-DYHSOULW.js → chunk-IGSNB5BX.js} +1 -1
- package/dist/chunk-IVWPA6QH.cjs +90 -0
- package/dist/{chunk-MSTXS3MU.cjs → chunk-JJKGQNGD.cjs} +2 -2
- package/dist/{chunk-FNUZGYUF.cjs → chunk-JRFE7NSO.cjs} +12 -4
- package/dist/{chunk-HVHYZXBB.cjs → chunk-KNU5RN3O.cjs} +3 -3
- package/dist/{chunk-52IOOHNX.cjs → chunk-KQPJCVN3.cjs} +26 -26
- package/dist/chunk-LGFHLAY3.cjs +61 -0
- package/dist/{chunk-2REOCMUD.cjs → chunk-LRX7AMSS.cjs} +6 -1
- package/dist/{chunk-4PFAKLT3.js → chunk-MUWHGBIB.js} +1 -1
- package/dist/{chunk-ZJMLEP5H.js → chunk-NJYLQDB3.js} +1 -1
- package/dist/{chunk-IFNYRZP2.js → chunk-OSRH6KYZ.js} +4 -4
- package/dist/{chunk-6RAPVLJM.js → chunk-OTE77ONL.js} +1 -1
- package/dist/chunk-UDACUMLO.cjs +40 -0
- package/dist/{chunk-UNEVXCFW.js → chunk-UGAAJRPO.js} +10 -2
- package/dist/{chunk-SPTDXUED.cjs → chunk-URLDTS2Q.cjs} +2 -2
- package/dist/{chunk-W2T2VFLC.cjs → chunk-VALDHJOO.cjs} +5 -5
- package/dist/chunk-WFCQDOSN.js +90 -0
- package/dist/consent/consent.interceptor.d.ts +20 -0
- package/dist/consent/consent.module.d.ts +25 -0
- package/dist/consent/consent.options.d.ts +30 -0
- package/dist/consent/consent.port.d.ts +17 -0
- package/dist/consent/consent.service.d.ts +44 -0
- package/dist/consent/guard/index.cjs +13 -0
- package/dist/consent/guard/index.d.ts +31 -0
- package/dist/consent/guard/index.js +13 -0
- package/dist/consent/index.cjs +271 -0
- package/dist/consent/index.d.ts +13 -0
- package/dist/consent/index.js +271 -0
- package/dist/consent/memory.store.d.ts +7 -0
- package/dist/consent/shared/index.cjs +11 -0
- package/dist/consent/shared/index.d.ts +19 -0
- package/dist/consent/shared/index.js +11 -0
- package/dist/consent/typeorm.store.d.ts +22 -0
- package/dist/crud/index.cjs +4 -4
- package/dist/crud/index.js +3 -3
- package/dist/database/postgres/index.cjs +3 -3
- package/dist/database/postgres/index.js +2 -2
- package/dist/database/supabase/index.cjs +3 -3
- package/dist/database/supabase/index.js +2 -2
- package/dist/database/typeorm/index.cjs +2 -2
- package/dist/database/typeorm/index.js +1 -1
- package/dist/devices/device-check.interceptor.d.ts +20 -0
- package/dist/devices/devices.module.d.ts +28 -0
- package/dist/devices/devices.options.d.ts +53 -0
- package/dist/devices/devices.port.d.ts +62 -0
- package/dist/devices/devices.service.d.ts +58 -0
- package/dist/devices/index.cjs +327 -0
- package/dist/devices/index.d.ts +8 -0
- package/dist/devices/index.js +327 -0
- package/dist/devices/memory.store.d.ts +12 -0
- package/dist/email/index.cjs +2 -2
- package/dist/email/index.js +1 -1
- package/dist/email/nodemailer/index.cjs +2 -2
- package/dist/email/nodemailer/index.js +1 -1
- package/dist/email/resend/index.cjs +2 -2
- package/dist/email/resend/index.js +1 -1
- package/dist/entities/index.cjs +1 -1
- package/dist/entities/index.js +1 -1
- package/dist/errors/index.cjs +7 -7
- package/dist/errors/index.js +7 -7
- package/dist/events/buses.d.ts +27 -0
- package/dist/events/events.controller.d.ts +15 -0
- package/dist/events/events.module.d.ts +29 -0
- package/dist/events/events.options.d.ts +50 -0
- package/dist/events/events.service.d.ts +49 -0
- package/dist/events/events.types.d.ts +77 -0
- package/dist/events/index.cjs +557 -0
- package/dist/events/index.d.ts +10 -0
- package/dist/events/index.js +557 -0
- package/dist/events/memory-ticket.store.d.ts +9 -0
- package/dist/google-business/google-business-http.d.ts +41 -0
- package/dist/google-business/google-business.errors.d.ts +75 -0
- package/dist/google-business/google-business.mappers.d.ts +52 -0
- package/dist/google-business/google-business.module.d.ts +26 -0
- package/dist/google-business/google-business.options.d.ts +40 -0
- package/dist/google-business/google-business.ports.d.ts +18 -0
- package/dist/google-business/google-business.service.d.ts +120 -0
- package/dist/google-business/google-business.types.d.ts +155 -0
- package/dist/google-business/index.cjs +1025 -0
- package/dist/google-business/index.d.ts +15 -0
- package/dist/google-business/index.js +1025 -0
- package/dist/google-business/testing/google-simulator.d.ts +61 -0
- package/dist/hardening/body-limits.d.ts +24 -0
- package/dist/hardening/http.types.d.ts +26 -0
- package/dist/hardening/index.cjs +179 -0
- package/dist/hardening/index.d.ts +19 -0
- package/dist/hardening/index.js +179 -0
- package/dist/hardening/memory-rate-limit.store.d.ts +10 -0
- package/dist/hardening/origin-secret.d.ts +29 -0
- package/dist/hardening/rate-limit.decorator.d.ts +8 -0
- package/dist/hardening/rate-limit.guard.d.ts +18 -0
- package/dist/hardening/rate-limit.module.d.ts +23 -0
- package/dist/hardening/rate-limit.options.d.ts +35 -0
- package/dist/hardening/rate-limit.port.d.ts +11 -0
- package/dist/hardening/redis-rate-limit.store.d.ts +23 -0
- package/dist/hardening/trust-proxy.d.ts +22 -0
- package/dist/health/health.controller.d.ts +32 -0
- package/dist/health/health.module.d.ts +15 -0
- package/dist/health/health.options.d.ts +24 -0
- package/dist/health/index.cjs +103 -0
- package/dist/health/index.d.ts +5 -0
- package/dist/health/index.js +103 -0
- package/dist/i18n/index.cjs +3 -3
- package/dist/i18n/index.js +2 -2
- package/dist/idempotency/idempotency.interceptor.d.ts +1 -0
- package/dist/idempotency/idempotency.options.d.ts +15 -0
- package/dist/idempotency/index.cjs +214 -7
- package/dist/idempotency/index.d.ts +5 -0
- package/dist/idempotency/index.js +210 -3
- package/dist/idempotency/no-idempotency.decorator.d.ts +8 -0
- package/dist/idempotency/postgres.store.d.ts +49 -0
- package/dist/idempotency/redis.store.d.ts +59 -0
- package/dist/index.cjs +21 -20
- package/dist/index.js +31 -30
- package/dist/invoicing/index.cjs +2 -2
- package/dist/invoicing/index.js +1 -1
- package/dist/jobs/defer-job.d.ts +10 -0
- package/dist/jobs/index.cjs +318 -0
- package/dist/jobs/index.d.ts +8 -0
- package/dist/jobs/index.js +318 -0
- package/dist/jobs/jobs-admin.controller.d.ts +18 -0
- package/dist/jobs/jobs.module.d.ts +33 -0
- package/dist/jobs/jobs.options.d.ts +62 -0
- package/dist/jobs/jobs.service.d.ts +53 -0
- package/dist/jobs/jobs.sql.d.ts +11 -0
- package/dist/media/index.cjs +14 -14
- package/dist/media/index.js +1 -1
- package/dist/meta/index.cjs +3 -3
- package/dist/meta/index.js +1 -1
- package/dist/notifications/index.cjs +375 -0
- package/dist/notifications/index.d.ts +8 -0
- package/dist/notifications/index.js +375 -0
- package/dist/notifications/memory.stores.d.ts +23 -0
- package/dist/notifications/notifications.controller.d.ts +11 -0
- package/dist/notifications/notifications.module.d.ts +31 -0
- package/dist/notifications/notifications.options.d.ts +33 -0
- package/dist/notifications/notifications.port.d.ts +97 -0
- package/dist/notifications/notifier.service.d.ts +31 -0
- package/dist/payments/index.cjs +7 -7
- package/dist/payments/index.js +1 -1
- package/dist/pinterest/index.cjs +3 -3
- package/dist/pinterest/index.js +1 -1
- package/dist/privacy/anonymizer.d.ts +14 -0
- package/dist/privacy/index.cjs +768 -0
- package/dist/privacy/index.d.ts +13 -0
- package/dist/privacy/index.js +768 -0
- package/dist/privacy/memory.store.d.ts +15 -0
- package/dist/privacy/privacy.module.d.ts +30 -0
- package/dist/privacy/privacy.options.d.ts +43 -0
- package/dist/privacy/privacy.port.d.ts +25 -0
- package/dist/privacy/privacy.service.d.ts +69 -0
- package/dist/privacy/privacy.types.d.ts +125 -0
- package/dist/privacy/sql.d.ts +7 -0
- package/dist/privacy/sql.store.d.ts +21 -0
- package/dist/privacy/zip.d.ts +23 -0
- package/dist/push/index.cjs +13 -13
- package/dist/push/index.js +5 -5
- package/dist/resilience/alert-channels.d.ts +39 -0
- package/dist/resilience/alert-errors.interceptor.d.ts +10 -0
- package/dist/resilience/alert-on-failure.decorator.d.ts +10 -0
- package/dist/resilience/alert.service.d.ts +77 -0
- package/dist/resilience/index.cjs +863 -0
- package/dist/resilience/index.d.ts +18 -0
- package/dist/resilience/index.js +863 -0
- package/dist/resilience/memory-alert-store.d.ts +26 -0
- package/dist/resilience/provider-health.controller.d.ts +14 -0
- package/dist/resilience/provider-unavailable.exception.d.ts +11 -0
- package/dist/resilience/resilience.module.d.ts +34 -0
- package/dist/resilience/resilience.options.d.ts +28 -0
- package/dist/resilience/resilience.types.d.ts +167 -0
- package/dist/resilience/resilient-fetch.d.ts +38 -0
- package/dist/resilience/runtime.d.ts +24 -0
- package/dist/resilience/typeorm/alert.entity.d.ts +21 -0
- package/dist/resilience/typeorm/index.cjs +102 -0
- package/dist/resilience/typeorm/index.d.ts +3 -0
- package/dist/resilience/typeorm/index.js +102 -0
- package/dist/resilience/typeorm/typeorm-alert-store.d.ts +39 -0
- package/dist/resilience/validate-destination.d.ts +63 -0
- package/dist/response/index.cjs +3 -3
- package/dist/response/index.js +2 -2
- package/dist/scheduling/cron-lock.service.d.ts +36 -0
- package/dist/scheduling/cron-unico.decorator.d.ts +27 -0
- package/dist/scheduling/fallback.store.d.ts +34 -0
- package/dist/scheduling/index.cjs +392 -0
- package/dist/scheduling/index.d.ts +18 -0
- package/dist/scheduling/index.js +392 -0
- package/dist/scheduling/lock-store.port.d.ts +19 -0
- package/dist/scheduling/memory.store.d.ts +15 -0
- package/dist/scheduling/redis.module.d.ts +31 -0
- package/dist/scheduling/redis.store.d.ts +24 -0
- package/dist/scheduling/scheduling.module.d.ts +24 -0
- package/dist/scheduling/scheduling.options.d.ts +27 -0
- package/dist/scheduling/sql.store.d.ts +26 -0
- package/dist/secrets/index.cjs +274 -0
- package/dist/secrets/index.d.ts +8 -0
- package/dist/secrets/index.js +274 -0
- package/dist/secrets/secrets.errors.d.ts +6 -0
- package/dist/secrets/secrets.module.d.ts +21 -0
- package/dist/secrets/secrets.options.d.ts +32 -0
- package/dist/secrets/secrets.service.d.ts +54 -0
- package/dist/secrets/secrets.transformer.d.ts +33 -0
- package/dist/security/hash.d.ts +8 -0
- package/dist/security/index.cjs +119 -2
- package/dist/security/index.d.ts +5 -0
- package/dist/security/index.js +119 -2
- package/dist/security/mask.d.ts +22 -0
- package/dist/security/signed-grant.d.ts +30 -0
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.js +1 -1
- package/dist/stripe/index.cjs +7 -7
- package/dist/stripe/index.js +1 -1
- package/dist/telegram/index.cjs +2 -2
- package/dist/telegram/index.js +1 -1
- package/dist/tenancy/app-role.d.ts +24 -0
- package/dist/tenancy/db-helpers.d.ts +12 -0
- package/dist/tenancy/index.cjs +205 -0
- package/dist/tenancy/index.d.ts +14 -0
- package/dist/tenancy/index.js +205 -0
- package/dist/tenancy/pg/index.cjs +34 -0
- package/dist/tenancy/pg/index.d.ts +2 -0
- package/dist/tenancy/pg/index.js +34 -0
- package/dist/tenancy/pg/with-tenant.d.ts +23 -0
- package/dist/tenancy/request-context.d.ts +18 -0
- package/dist/tenancy/rls-guardrail.d.ts +38 -0
- package/dist/tenancy/scope.d.ts +5 -0
- package/dist/tenancy/tenancy.errors.d.ts +5 -0
- package/dist/tenancy/tenancy.middleware.d.ts +8 -0
- package/dist/tenancy/tenancy.module.d.ts +37 -0
- package/dist/tenancy/tenancy.options.d.ts +34 -0
- package/dist/tenancy/typeorm/index.cjs +41 -0
- package/dist/tenancy/typeorm/index.d.ts +2 -0
- package/dist/tenancy/typeorm/index.js +41 -0
- package/dist/tenancy/typeorm/with-tenant.d.ts +23 -0
- package/dist/tiktok/index.cjs +3 -3
- package/dist/tiktok/index.js +1 -1
- package/dist/tracking/index.cjs +3 -3
- package/dist/tracking/index.js +2 -2
- package/dist/umami/index.cjs +4 -4
- package/dist/umami/index.js +1 -1
- package/dist/whatsapp/index.cjs +2 -2
- package/dist/whatsapp/index.js +1 -1
- package/package.json +107 -2
|
@@ -7,7 +7,7 @@ import "../chunk-VVMRZEIW.js";
|
|
|
7
7
|
import {
|
|
8
8
|
__decorateClass,
|
|
9
9
|
__decorateParam
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-D3DDJWUD.js";
|
|
11
11
|
|
|
12
12
|
// src/idempotency/idempotency.port.ts
|
|
13
13
|
var IDEMPOTENCY_STORE = /* @__PURE__ */ Symbol("IDEMPOTENCY_STORE");
|
|
@@ -60,6 +60,13 @@ import {
|
|
|
60
60
|
} from "@nestjs/common";
|
|
61
61
|
import { from, of } from "rxjs";
|
|
62
62
|
import { catchError, concatMap, switchMap } from "rxjs/operators";
|
|
63
|
+
|
|
64
|
+
// src/idempotency/no-idempotency.decorator.ts
|
|
65
|
+
import { SetMetadata } from "@nestjs/common";
|
|
66
|
+
var NO_IDEMPOTENCY_KEY = "nestkit:no-idempotency";
|
|
67
|
+
var NoIdempotency = () => SetMetadata(NO_IDEMPOTENCY_KEY, true);
|
|
68
|
+
|
|
69
|
+
// src/idempotency/idempotency.interceptor.ts
|
|
63
70
|
var DEFAULT_METHODS = ["POST", "PUT", "PATCH", "DELETE"];
|
|
64
71
|
var DEFAULT_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
65
72
|
function headerOf(request, name) {
|
|
@@ -85,6 +92,7 @@ var IdempotencyInterceptor = class {
|
|
|
85
92
|
const http = context.switchToHttp();
|
|
86
93
|
const request = http.getRequest();
|
|
87
94
|
const response = http.getResponse();
|
|
95
|
+
if (this.isExcluded(context, request)) return next.handle();
|
|
88
96
|
const methods = this.options.methods ?? DEFAULT_METHODS;
|
|
89
97
|
const method = String(request?.method ?? "GET").toUpperCase();
|
|
90
98
|
if (!methods.includes(method)) return next.handle();
|
|
@@ -101,7 +109,8 @@ var IdempotencyInterceptor = class {
|
|
|
101
109
|
return next.handle();
|
|
102
110
|
}
|
|
103
111
|
const ttlMs = this.options.ttlMs ?? DEFAULT_TTL_MS;
|
|
104
|
-
const
|
|
112
|
+
const scopeFn = this.options.scopeBy ?? this.options.scope;
|
|
113
|
+
const scope = scopeFn ? scopeFn(request) : request?.user?.sub;
|
|
105
114
|
const storeKey = `${scope ?? "anonymous"}:${key}`;
|
|
106
115
|
const path = request?.originalUrl ?? request?.url ?? "";
|
|
107
116
|
const fingerprint = createHash("sha256").update(`${method} ${path} ${stableStringify(request?.body ?? null)}`).digest("hex");
|
|
@@ -126,6 +135,11 @@ var IdempotencyInterceptor = class {
|
|
|
126
135
|
// yet is not replayable, and the retry this protects against is
|
|
127
136
|
// exactly the one that arrives immediately.
|
|
128
137
|
concatMap(async (body) => {
|
|
138
|
+
const max = this.options.maxResponseBytes;
|
|
139
|
+
if (max !== void 0 && Buffer.byteLength(JSON.stringify(body ?? null), "utf8") > max) {
|
|
140
|
+
await this.store.release(storeKey);
|
|
141
|
+
return body;
|
|
142
|
+
}
|
|
129
143
|
await this.store.complete(
|
|
130
144
|
storeKey,
|
|
131
145
|
{ status: Number(response?.statusCode ?? 200), body, fingerprint, completedAt: /* @__PURE__ */ new Date() },
|
|
@@ -144,6 +158,19 @@ var IdempotencyInterceptor = class {
|
|
|
144
158
|
})
|
|
145
159
|
);
|
|
146
160
|
}
|
|
161
|
+
isExcluded(context, request) {
|
|
162
|
+
const handler = typeof context.getHandler === "function" ? context.getHandler() : void 0;
|
|
163
|
+
const klass = typeof context.getClass === "function" ? context.getClass() : void 0;
|
|
164
|
+
if (handler && Reflect.getMetadata(NO_IDEMPOTENCY_KEY, handler)) return true;
|
|
165
|
+
if (klass && Reflect.getMetadata(NO_IDEMPOTENCY_KEY, klass)) return true;
|
|
166
|
+
const patterns = this.options.excludeRoutes;
|
|
167
|
+
if (!patterns?.length) return false;
|
|
168
|
+
const path = String(request?.originalUrl ?? request?.url ?? "").split("?")[0];
|
|
169
|
+
return patterns.some((re) => {
|
|
170
|
+
re.lastIndex = 0;
|
|
171
|
+
return re.test(path);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
147
174
|
mismatch(headerName) {
|
|
148
175
|
return new ValidationAppException(
|
|
149
176
|
`This ${headerName} was already used for a different request`,
|
|
@@ -198,10 +225,190 @@ IdempotencyModule = __decorateClass([
|
|
|
198
225
|
Global(),
|
|
199
226
|
Module({})
|
|
200
227
|
], IdempotencyModule);
|
|
228
|
+
|
|
229
|
+
// src/idempotency/postgres.store.ts
|
|
230
|
+
var IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?$/;
|
|
231
|
+
function checkTable(table) {
|
|
232
|
+
if (!IDENTIFIER.test(table)) throw new Error(`PostgresIdempotencyStore: invalid table name "${table}"`);
|
|
233
|
+
return table;
|
|
234
|
+
}
|
|
235
|
+
function rowsOf(result) {
|
|
236
|
+
if (Array.isArray(result)) return result.length === 2 && Array.isArray(result[0]) ? result[0] : result;
|
|
237
|
+
const rows = result?.rows;
|
|
238
|
+
return Array.isArray(rows) ? rows : [];
|
|
239
|
+
}
|
|
240
|
+
var PostgresIdempotencyStore = class _PostgresIdempotencyStore {
|
|
241
|
+
constructor(options) {
|
|
242
|
+
this.calls = 0;
|
|
243
|
+
this.table = checkTable(options.table ?? "idempotency_key");
|
|
244
|
+
const { pool } = options;
|
|
245
|
+
if (options.query) this.query = options.query;
|
|
246
|
+
else if (pool) this.query = (sql, params) => pool.query(sql, params);
|
|
247
|
+
else throw new Error("PostgresIdempotencyStore: pass `pool` or `query`");
|
|
248
|
+
this.maxBytes = options.maxBytes;
|
|
249
|
+
this.cleanupEvery = options.cleanupEvery ?? 100;
|
|
250
|
+
}
|
|
251
|
+
static createTableSql(table = "idempotency_key") {
|
|
252
|
+
const t = checkTable(table);
|
|
253
|
+
const idx = `${t.replace(".", "_")}_expires_idx`;
|
|
254
|
+
return `CREATE TABLE IF NOT EXISTS ${t} (
|
|
255
|
+
key text PRIMARY KEY,
|
|
256
|
+
fingerprint text NOT NULL,
|
|
257
|
+
status integer,
|
|
258
|
+
body jsonb,
|
|
259
|
+
completed_at timestamptz,
|
|
260
|
+
expires_at timestamptz NOT NULL
|
|
261
|
+
);
|
|
262
|
+
CREATE INDEX IF NOT EXISTS ${idx} ON ${t} (expires_at)`;
|
|
263
|
+
}
|
|
264
|
+
async ensureTable() {
|
|
265
|
+
for (const statement of _PostgresIdempotencyStore.createTableSql(this.table).split(";\n")) {
|
|
266
|
+
await this.query(statement, []);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
async begin(key, fingerprint, ttlMs) {
|
|
270
|
+
await this.maybeCleanup();
|
|
271
|
+
const claimed = rowsOf(
|
|
272
|
+
await this.query(
|
|
273
|
+
`INSERT INTO ${this.table} (key, fingerprint, expires_at)
|
|
274
|
+
VALUES ($1, $2, now() + make_interval(secs => $3::double precision / 1000))
|
|
275
|
+
ON CONFLICT (key) DO UPDATE
|
|
276
|
+
SET fingerprint = EXCLUDED.fingerprint, status = NULL, body = NULL,
|
|
277
|
+
completed_at = NULL, expires_at = EXCLUDED.expires_at
|
|
278
|
+
WHERE ${this.table}.expires_at <= now()
|
|
279
|
+
RETURNING key`,
|
|
280
|
+
[key, fingerprint, ttlMs]
|
|
281
|
+
)
|
|
282
|
+
);
|
|
283
|
+
if (claimed.length > 0) return { state: "claimed" };
|
|
284
|
+
const found = rowsOf(
|
|
285
|
+
await this.query(
|
|
286
|
+
`SELECT fingerprint, status, body, completed_at FROM ${this.table} WHERE key = $1`,
|
|
287
|
+
[key]
|
|
288
|
+
)
|
|
289
|
+
)[0];
|
|
290
|
+
if (!found) return this.begin(key, fingerprint, ttlMs);
|
|
291
|
+
if (found.status === null || found.status === void 0) {
|
|
292
|
+
return { state: "in_progress", fingerprint: found.fingerprint };
|
|
293
|
+
}
|
|
294
|
+
return {
|
|
295
|
+
state: "completed",
|
|
296
|
+
record: {
|
|
297
|
+
status: Number(found.status),
|
|
298
|
+
body: found.body,
|
|
299
|
+
fingerprint: found.fingerprint,
|
|
300
|
+
completedAt: new Date(found.completed_at)
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
async complete(key, record, ttlMs) {
|
|
305
|
+
const body = JSON.stringify(record.body ?? null);
|
|
306
|
+
if (this.maxBytes !== void 0 && Buffer.byteLength(body, "utf8") > this.maxBytes) {
|
|
307
|
+
await this.release(key);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
await this.query(
|
|
311
|
+
`UPDATE ${this.table}
|
|
312
|
+
SET status = $2, body = $3::jsonb, fingerprint = $4, completed_at = $5,
|
|
313
|
+
expires_at = now() + make_interval(secs => $6::double precision / 1000)
|
|
314
|
+
WHERE key = $1`,
|
|
315
|
+
[key, record.status, body, record.fingerprint, record.completedAt, ttlMs]
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
async release(key) {
|
|
319
|
+
await this.query(`DELETE FROM ${this.table} WHERE key = $1`, [key]);
|
|
320
|
+
}
|
|
321
|
+
/** Deletes every expired row now. Returns nothing; also runs on its own every `cleanupEvery` calls. */
|
|
322
|
+
async purgeExpired() {
|
|
323
|
+
await this.query(`DELETE FROM ${this.table} WHERE expires_at <= now()`, []);
|
|
324
|
+
}
|
|
325
|
+
async maybeCleanup() {
|
|
326
|
+
if (this.cleanupEvery <= 0) return;
|
|
327
|
+
this.calls += 1;
|
|
328
|
+
if (this.calls % this.cleanupEvery !== 0) return;
|
|
329
|
+
try {
|
|
330
|
+
await this.purgeExpired();
|
|
331
|
+
} catch {
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// src/idempotency/redis.store.ts
|
|
337
|
+
var REDIS_IDEMPOTENCY_DEFAULT_MAX_BYTES = 256 * 1024;
|
|
338
|
+
var RedisIdempotencyStore = class {
|
|
339
|
+
constructor(options) {
|
|
340
|
+
this.inFallback = /* @__PURE__ */ new Set();
|
|
341
|
+
this.client = options.client;
|
|
342
|
+
this.prefix = options.prefix ?? "idem:";
|
|
343
|
+
this.maxBytes = options.maxBytes ?? REDIS_IDEMPOTENCY_DEFAULT_MAX_BYTES;
|
|
344
|
+
this.onError = options.onError;
|
|
345
|
+
this.fallback = options.fallback;
|
|
346
|
+
}
|
|
347
|
+
async begin(key, fingerprint, ttlMs) {
|
|
348
|
+
try {
|
|
349
|
+
const raw = await this.client.reclamarOLeer(
|
|
350
|
+
this.prefix + key,
|
|
351
|
+
JSON.stringify({ f: fingerprint }),
|
|
352
|
+
ttlMs
|
|
353
|
+
);
|
|
354
|
+
if (raw === null || raw === void 0) return { state: "claimed" };
|
|
355
|
+
const entry = JSON.parse(raw);
|
|
356
|
+
if (entry.r) {
|
|
357
|
+
return {
|
|
358
|
+
state: "completed",
|
|
359
|
+
record: {
|
|
360
|
+
status: entry.r.status,
|
|
361
|
+
body: entry.r.body,
|
|
362
|
+
fingerprint: entry.f,
|
|
363
|
+
completedAt: new Date(entry.r.completedAt)
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
return { state: "in_progress", fingerprint: entry.f };
|
|
368
|
+
} catch (error) {
|
|
369
|
+
if (!this.fallback) throw error;
|
|
370
|
+
this.onError?.(error);
|
|
371
|
+
const result = await this.fallback.begin(key, fingerprint, ttlMs);
|
|
372
|
+
if (result.state === "claimed") this.inFallback.add(key);
|
|
373
|
+
return result;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
async complete(key, record, ttlMs) {
|
|
377
|
+
if (this.fallback && this.inFallback.delete(key)) return this.fallback.complete(key, record, ttlMs);
|
|
378
|
+
const text = JSON.stringify({
|
|
379
|
+
f: record.fingerprint,
|
|
380
|
+
r: { status: record.status, body: record.body, completedAt: record.completedAt.toISOString() }
|
|
381
|
+
});
|
|
382
|
+
try {
|
|
383
|
+
if (Buffer.byteLength(text, "utf8") > this.maxBytes) {
|
|
384
|
+
await this.client.borrar(this.prefix + key);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
await this.client.fijar(this.prefix + key, text, ttlMs);
|
|
388
|
+
} catch (error) {
|
|
389
|
+
if (!this.fallback) throw error;
|
|
390
|
+
this.onError?.(error);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
async release(key) {
|
|
394
|
+
if (this.fallback && this.inFallback.delete(key)) return this.fallback.release(key);
|
|
395
|
+
try {
|
|
396
|
+
await this.client.borrar(this.prefix + key);
|
|
397
|
+
} catch (error) {
|
|
398
|
+
if (!this.fallback) throw error;
|
|
399
|
+
this.onError?.(error);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
};
|
|
201
403
|
export {
|
|
202
404
|
IDEMPOTENCY_OPTIONS,
|
|
203
405
|
IDEMPOTENCY_STORE,
|
|
204
406
|
IdempotencyInterceptor,
|
|
205
407
|
IdempotencyModule,
|
|
206
|
-
MemoryIdempotencyStore
|
|
408
|
+
MemoryIdempotencyStore,
|
|
409
|
+
NO_IDEMPOTENCY_KEY,
|
|
410
|
+
NoIdempotency,
|
|
411
|
+
PostgresIdempotencyStore,
|
|
412
|
+
REDIS_IDEMPOTENCY_DEFAULT_MAX_BYTES,
|
|
413
|
+
RedisIdempotencyStore
|
|
207
414
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Metadata key read by the interceptor. */
|
|
2
|
+
export declare const NO_IDEMPOTENCY_KEY = "nestkit:no-idempotency";
|
|
3
|
+
/**
|
|
4
|
+
* Opts a handler (or a whole controller) out of idempotency, whatever the
|
|
5
|
+
* client sends. For endpoints whose answer is a credential — a session, a
|
|
6
|
+
* device token — which must never be parked in a store for the TTL.
|
|
7
|
+
*/
|
|
8
|
+
export declare const NoIdempotency: () => MethodDecorator & ClassDecorator;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { BeginResult, IdempotencyRecord, IdempotencyStorePort } from './idempotency.port.js';
|
|
2
|
+
/** Minimal SQL runner: `(sql, params) => rows` — a `pg` Pool/Client adapter, TypeORM's `DataSource.query`, etc. Postgres syntax, `$n` params. */
|
|
3
|
+
export type IdempotencyQuery = (sql: string, params: unknown[]) => Promise<unknown>;
|
|
4
|
+
/** Structural `pg` Pool/Client: only `query` is used, so `pg` is never imported. */
|
|
5
|
+
export interface IdempotencyPgPool {
|
|
6
|
+
query(sql: string, params?: unknown[]): Promise<{
|
|
7
|
+
rows: any[];
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export interface PostgresIdempotencyStoreOptions {
|
|
11
|
+
/** Table name (optionally `schema.table`). Defaults to `idempotency_key`. */
|
|
12
|
+
table?: string;
|
|
13
|
+
/** A `pg` Pool or Client. */
|
|
14
|
+
pool?: IdempotencyPgPool;
|
|
15
|
+
/** Alternative to `pool`. One of the two is required. */
|
|
16
|
+
query?: IdempotencyQuery;
|
|
17
|
+
/** Largest answer kept, in bytes of its JSON; a bigger one is released instead. Unlimited by default. */
|
|
18
|
+
maxBytes?: number;
|
|
19
|
+
/** Every N-th `begin` deletes expired rows (best effort). Defaults to 100; 0 turns it off. */
|
|
20
|
+
cleanupEvery?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Idempotency keys in Postgres, shared by every instance.
|
|
24
|
+
*
|
|
25
|
+
* `begin` is one atomic `INSERT … ON CONFLICT DO UPDATE … WHERE expires_at <= now()`:
|
|
26
|
+
* the row is ours if it is new or expired; otherwise nothing is returned and a
|
|
27
|
+
* second `SELECT` reads what is there. Expired rows are also swept every
|
|
28
|
+
* `cleanupEvery` calls so the table does not grow forever (an index on
|
|
29
|
+
* `expires_at` keeps the sweep cheap).
|
|
30
|
+
*
|
|
31
|
+
* Create the table with `PostgresIdempotencyStore.createTableSql()` in a
|
|
32
|
+
* migration, or call `ensureTable()` once at boot.
|
|
33
|
+
*/
|
|
34
|
+
export declare class PostgresIdempotencyStore implements IdempotencyStorePort {
|
|
35
|
+
private readonly table;
|
|
36
|
+
private readonly query;
|
|
37
|
+
private readonly maxBytes?;
|
|
38
|
+
private readonly cleanupEvery;
|
|
39
|
+
private calls;
|
|
40
|
+
constructor(options: PostgresIdempotencyStoreOptions);
|
|
41
|
+
static createTableSql(table?: string): string;
|
|
42
|
+
ensureTable(): Promise<void>;
|
|
43
|
+
begin(key: string, fingerprint: string, ttlMs: number): Promise<BeginResult>;
|
|
44
|
+
complete(key: string, record: IdempotencyRecord, ttlMs: number): Promise<void>;
|
|
45
|
+
release(key: string): Promise<void>;
|
|
46
|
+
/** Deletes every expired row now. Returns nothing; also runs on its own every `cleanupEvery` calls. */
|
|
47
|
+
purgeExpired(): Promise<void>;
|
|
48
|
+
private maybeCleanup;
|
|
49
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { BeginResult, IdempotencyRecord, IdempotencyStorePort } from './idempotency.port.js';
|
|
2
|
+
/**
|
|
3
|
+
* Structural Redis client: the three atomic operations this store needs, so
|
|
4
|
+
* neither `ioredis` nor `redis` is imported. Adapt your client to it:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const client: RedisIdempotencyClient = {
|
|
8
|
+
* reclamarOLeer: (key, value, ttlMs) => redis.set(key, value, 'PX', ttlMs, 'NX', 'GET'),
|
|
9
|
+
* fijar: (key, value, ttlMs) => redis.set(key, value, 'PX', ttlMs).then(() => undefined),
|
|
10
|
+
* borrar: (key) => redis.del(key).then(() => undefined),
|
|
11
|
+
* };
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export interface RedisIdempotencyClient {
|
|
15
|
+
/**
|
|
16
|
+
* `SET key value NX PX ttl GET` in ONE command (Redis 7+): claims the key if
|
|
17
|
+
* absent and returns `null`, otherwise returns what was stored and leaves it
|
|
18
|
+
* untouched. A separate GET + SET would lose the race this module exists for.
|
|
19
|
+
*/
|
|
20
|
+
reclamarOLeer(key: string, value: string, ttlMs: number): Promise<string | null>;
|
|
21
|
+
/** `SET key value PX ttl` (overwrite). */
|
|
22
|
+
fijar(key: string, value: string, ttlMs: number): Promise<void>;
|
|
23
|
+
/** `DEL key`. */
|
|
24
|
+
borrar(key: string): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export interface RedisIdempotencyStoreOptions {
|
|
27
|
+
client: RedisIdempotencyClient;
|
|
28
|
+
/** Key prefix. Defaults to `idem:`. */
|
|
29
|
+
prefix?: string;
|
|
30
|
+
/** Largest answer kept, in bytes; a bigger one is released instead. Defaults to 256 KB. */
|
|
31
|
+
maxBytes?: number;
|
|
32
|
+
/** Called when Redis throws; the request is then served from `fallback` and never rejected. */
|
|
33
|
+
onError?: (error: unknown) => void;
|
|
34
|
+
/** Used while Redis is down. Defaults to none: a Redis failure then propagates. */
|
|
35
|
+
fallback?: IdempotencyStorePort;
|
|
36
|
+
}
|
|
37
|
+
export declare const REDIS_IDEMPOTENCY_DEFAULT_MAX_BYTES: number;
|
|
38
|
+
/**
|
|
39
|
+
* Idempotency keys in Redis, shared between instances.
|
|
40
|
+
*
|
|
41
|
+
* Commands per request (Upstash bills per command): first time = 2 (claim +
|
|
42
|
+
* store answer); replay = 1; handler error = 2 (claim + delete).
|
|
43
|
+
*
|
|
44
|
+
* With a `fallback`, a Redis outage degrades to that store instead of
|
|
45
|
+
* rejecting the request (a sale is never blocked by Redis); keys claimed there
|
|
46
|
+
* are completed and released there too.
|
|
47
|
+
*/
|
|
48
|
+
export declare class RedisIdempotencyStore implements IdempotencyStorePort {
|
|
49
|
+
private readonly client;
|
|
50
|
+
private readonly prefix;
|
|
51
|
+
private readonly maxBytes;
|
|
52
|
+
private readonly onError?;
|
|
53
|
+
private readonly fallback?;
|
|
54
|
+
private readonly inFallback;
|
|
55
|
+
constructor(options: RedisIdempotencyStoreOptions);
|
|
56
|
+
begin(key: string, fingerprint: string, ttlMs: number): Promise<BeginResult>;
|
|
57
|
+
complete(key: string, record: IdempotencyRecord, ttlMs: number): Promise<void>;
|
|
58
|
+
release(key: string): Promise<void>;
|
|
59
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,66 +1,67 @@
|
|
|
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
|
-
var _chunkSPTDXUEDcjs = require('./chunk-SPTDXUED.cjs');
|
|
6
|
-
require('./chunk-KVBQBT3D.cjs');
|
|
7
5
|
|
|
6
|
+
var _chunk47IYXZHWcjs = require('./chunk-47IYXZHW.cjs');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
11
|
-
var _chunkRF75KC63cjs = require('./chunk-RF75KC63.cjs');
|
|
12
10
|
|
|
11
|
+
var _chunkURLDTS2Qcjs = require('./chunk-URLDTS2Q.cjs');
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
|
|
16
|
-
var _chunkHVHYZXBBcjs = require('./chunk-HVHYZXBB.cjs');
|
|
17
15
|
|
|
16
|
+
var _chunkKNU5RN3Ocjs = require('./chunk-KNU5RN3O.cjs');
|
|
17
|
+
require('./chunk-H2EHN366.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
var _chunkQS2W5XCQcjs = require('./chunk-QS2W5XCQ.cjs');
|
|
21
|
+
require('./chunk-7SOM7EZP.cjs');
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
|
|
23
|
-
var _chunkAPUFKA4Kcjs = require('./chunk-APUFKA4K.cjs');
|
|
24
|
-
require('./chunk-H2EHN366.cjs');
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
+
var _chunkFDZQCLLKcjs = require('./chunk-FDZQCLLK.cjs');
|
|
28
29
|
|
|
29
|
-
var _chunk52IOOHNXcjs = require('./chunk-52IOOHNX.cjs');
|
|
30
|
-
require('./chunk-W2T2VFLC.cjs');
|
|
31
30
|
|
|
31
|
+
var _chunkJRFE7NSOcjs = require('./chunk-JRFE7NSO.cjs');
|
|
32
32
|
|
|
33
|
-
var _chunkFNUZGYUFcjs = require('./chunk-FNUZGYUF.cjs');
|
|
34
33
|
|
|
34
|
+
var _chunkF77X4QUNcjs = require('./chunk-F77X4QUN.cjs');
|
|
35
35
|
|
|
36
|
-
var _chunk3AUOOEQOcjs = require('./chunk-3AUOOEQO.cjs');
|
|
37
36
|
|
|
37
|
+
var _chunkJJKGQNGDcjs = require('./chunk-JJKGQNGD.cjs');
|
|
38
|
+
require('./chunk-IVWPA6QH.cjs');
|
|
38
39
|
|
|
39
|
-
var _chunkQS2W5XCQcjs = require('./chunk-QS2W5XCQ.cjs');
|
|
40
|
-
require('./chunk-7SOM7EZP.cjs');
|
|
41
40
|
|
|
42
41
|
|
|
43
42
|
|
|
43
|
+
var _chunkAXMW5JF7cjs = require('./chunk-AXMW5JF7.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
var _chunkHDFPSA2Vcjs = require('./chunk-HDFPSA2V.cjs');
|
|
48
47
|
|
|
48
|
+
var _chunkKQPJCVN3cjs = require('./chunk-KQPJCVN3.cjs');
|
|
49
49
|
|
|
50
|
-
var _chunkMSTXS3MUcjs = require('./chunk-MSTXS3MU.cjs');
|
|
51
50
|
|
|
52
51
|
|
|
53
52
|
|
|
53
|
+
var _chunkY72D5L6Icjs = require('./chunk-Y72D5L6I.cjs');
|
|
54
|
+
require('./chunk-VALDHJOO.cjs');
|
|
54
55
|
|
|
55
|
-
var _chunkAXMW5JF7cjs = require('./chunk-AXMW5JF7.cjs');
|
|
56
56
|
|
|
57
|
+
var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
|
|
57
58
|
|
|
58
59
|
|
|
59
60
|
|
|
60
|
-
var _chunkY72D5L6Icjs = require('./chunk-Y72D5L6I.cjs');
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
|
|
64
|
+
var _chunkHDFPSA2Vcjs = require('./chunk-HDFPSA2V.cjs');
|
|
64
65
|
|
|
65
66
|
|
|
66
67
|
var _chunkQ5Y33L7Bcjs = require('./chunk-Q5Y33L7B.cjs');
|
|
@@ -69,7 +70,7 @@ var _chunkQ5Y33L7Bcjs = require('./chunk-Q5Y33L7B.cjs');
|
|
|
69
70
|
|
|
70
71
|
|
|
71
72
|
var _chunkPNK5WMPPcjs = require('./chunk-PNK5WMPP.cjs');
|
|
72
|
-
require('./chunk-
|
|
73
|
+
require('./chunk-LRX7AMSS.cjs');
|
|
73
74
|
|
|
74
75
|
|
|
75
76
|
|
|
@@ -108,4 +109,4 @@ require('./chunk-2REOCMUD.cjs');
|
|
|
108
109
|
|
|
109
110
|
|
|
110
111
|
|
|
111
|
-
exports.AppException = _chunkQ5Y33L7Bcjs.AppException; exports.BaseCrudService =
|
|
112
|
+
exports.AppException = _chunkQ5Y33L7Bcjs.AppException; exports.BaseCrudService = _chunkKQPJCVN3cjs.BaseCrudService; exports.BaseResponseDto = _chunkQS2W5XCQcjs.BaseResponseDto; exports.ConflictAppException = _chunkHDFPSA2Vcjs.ConflictAppException; exports.ForbiddenAppException = _chunkHDFPSA2Vcjs.ForbiddenAppException; exports.GlobalExceptionFilter = _chunkJJKGQNGDcjs.GlobalExceptionFilter; exports.I18nInterceptor = _chunkFDZQCLLKcjs.I18nInterceptor; exports.I18nMessage = _chunkPNK5WMPPcjs.I18nMessage; exports.I18nModule = _chunkFDZQCLLKcjs.I18nModule; exports.ListQuery = _chunkKQPJCVN3cjs.ListQuery; exports.NestI18nTranslator = _chunkFDZQCLLKcjs.NestI18nTranslator; exports.NotFoundAppException = _chunkHDFPSA2Vcjs.NotFoundAppException; exports.PG_POOL = _chunk47IYXZHWcjs.PG_POOL; exports.PgModule = _chunk47IYXZHWcjs.PgModule; exports.REQUEST_ID_HEADER = _chunkKNU5RN3Ocjs.REQUEST_ID_HEADER; exports.RequestContext = _chunkSDWHKPXIcjs.RequestContext; exports.RequestIdMiddleware = _chunkKNU5RN3Ocjs.RequestIdMiddleware; exports.ResponseInterceptor = _chunkF77X4QUNcjs.ResponseInterceptor; exports.SUPABASE_ANON_CLIENT = _chunkURLDTS2Qcjs.SUPABASE_ANON_CLIENT; exports.SUPABASE_SERVICE_ROLE_CLIENT = _chunkURLDTS2Qcjs.SUPABASE_SERVICE_ROLE_CLIENT; exports.SupabaseModule = _chunkURLDTS2Qcjs.SupabaseModule; exports.TrackingModule = _chunkKNU5RN3Ocjs.TrackingModule; exports.UnauthorizedAppException = _chunkHDFPSA2Vcjs.UnauthorizedAppException; exports.ValidationAppException = _chunkHDFPSA2Vcjs.ValidationAppException; exports.applyNestKitDefaults = _chunkJRFE7NSOcjs.applyNestKitDefaults; exports.buildPageMeta = _chunkY72D5L6Icjs.buildPageMeta; exports.createCrudController = _chunkKQPJCVN3cjs.createCrudController; exports.currentLanguage = _chunkAXMW5JF7cjs.currentLanguage; exports.isI18nMessage = _chunkPNK5WMPPcjs.isI18nMessage; exports.isPaginated = _chunkY72D5L6Icjs.isPaginated; exports.matchLanguage = _chunkFDZQCLLKcjs.matchLanguage; exports.paginated = _chunkY72D5L6Icjs.paginated; exports.t = _chunkPNK5WMPPcjs.t; exports.translate = _chunkAXMW5JF7cjs.translate; exports.translateDeep = _chunkAXMW5JF7cjs.translateDeep; exports.translateOr = _chunkFDZQCLLKcjs.translateOr; exports.withTenantScope = _chunk47IYXZHWcjs.withTenantScope;
|
package/dist/index.js
CHANGED
|
@@ -1,66 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SUPABASE_ANON_CLIENT,
|
|
3
|
-
SUPABASE_SERVICE_ROLE_CLIENT,
|
|
4
|
-
SupabaseModule
|
|
5
|
-
} from "./chunk-PA24P76K.js";
|
|
6
1
|
import "./chunk-EPVKCBPT.js";
|
|
7
2
|
import {
|
|
8
3
|
PG_POOL,
|
|
9
4
|
PgModule,
|
|
10
5
|
withTenantScope
|
|
11
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ENZ7LQRE.js";
|
|
7
|
+
import {
|
|
8
|
+
SUPABASE_ANON_CLIENT,
|
|
9
|
+
SUPABASE_SERVICE_ROLE_CLIENT,
|
|
10
|
+
SupabaseModule
|
|
11
|
+
} from "./chunk-45SW7FBE.js";
|
|
12
12
|
import {
|
|
13
13
|
REQUEST_ID_HEADER,
|
|
14
14
|
RequestIdMiddleware,
|
|
15
15
|
TrackingModule
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-MUWHGBIB.js";
|
|
17
|
+
import "./chunk-ODPSIFOB.js";
|
|
18
|
+
import {
|
|
19
|
+
BaseResponseDto
|
|
20
|
+
} from "./chunk-XX2HPTRU.js";
|
|
21
|
+
import "./chunk-DQYAIQQ5.js";
|
|
17
22
|
import {
|
|
18
23
|
I18nInterceptor,
|
|
19
24
|
I18nModule,
|
|
20
25
|
NestI18nTranslator,
|
|
21
26
|
matchLanguage,
|
|
22
27
|
translateOr
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-ODPSIFOB.js";
|
|
25
|
-
import {
|
|
26
|
-
BaseCrudService,
|
|
27
|
-
ListQuery,
|
|
28
|
-
createCrudController
|
|
29
|
-
} from "./chunk-IFNYRZP2.js";
|
|
30
|
-
import "./chunk-ZJMLEP5H.js";
|
|
28
|
+
} from "./chunk-OTE77ONL.js";
|
|
31
29
|
import {
|
|
32
30
|
applyNestKitDefaults
|
|
33
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-UGAAJRPO.js";
|
|
34
32
|
import {
|
|
35
33
|
ResponseInterceptor
|
|
36
|
-
} from "./chunk-
|
|
37
|
-
import {
|
|
38
|
-
BaseResponseDto
|
|
39
|
-
} 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";
|
|
34
|
+
} from "./chunk-IGSNB5BX.js";
|
|
48
35
|
import {
|
|
49
36
|
GlobalExceptionFilter
|
|
50
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-5LVGCTJ3.js";
|
|
38
|
+
import "./chunk-WFCQDOSN.js";
|
|
51
39
|
import {
|
|
52
40
|
currentLanguage,
|
|
53
41
|
translate,
|
|
54
42
|
translateDeep
|
|
55
43
|
} from "./chunk-X4PQJZ4G.js";
|
|
44
|
+
import {
|
|
45
|
+
BaseCrudService,
|
|
46
|
+
ListQuery,
|
|
47
|
+
createCrudController
|
|
48
|
+
} from "./chunk-OSRH6KYZ.js";
|
|
56
49
|
import {
|
|
57
50
|
buildPageMeta,
|
|
58
51
|
isPaginated,
|
|
59
52
|
paginated
|
|
60
53
|
} from "./chunk-TCAMLNUZ.js";
|
|
54
|
+
import "./chunk-NJYLQDB3.js";
|
|
61
55
|
import {
|
|
62
56
|
RequestContext
|
|
63
57
|
} from "./chunk-ETRUVZTJ.js";
|
|
58
|
+
import {
|
|
59
|
+
ConflictAppException,
|
|
60
|
+
ForbiddenAppException,
|
|
61
|
+
NotFoundAppException,
|
|
62
|
+
UnauthorizedAppException,
|
|
63
|
+
ValidationAppException
|
|
64
|
+
} from "./chunk-ZFIDAX7K.js";
|
|
64
65
|
import {
|
|
65
66
|
AppException
|
|
66
67
|
} from "./chunk-M3GQDRWR.js";
|
|
@@ -69,7 +70,7 @@ import {
|
|
|
69
70
|
isI18nMessage,
|
|
70
71
|
t
|
|
71
72
|
} from "./chunk-VVMRZEIW.js";
|
|
72
|
-
import "./chunk-
|
|
73
|
+
import "./chunk-D3DDJWUD.js";
|
|
73
74
|
export {
|
|
74
75
|
AppException,
|
|
75
76
|
BaseCrudService,
|
package/dist/invoicing/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var _chunkQ5Y33L7Bcjs = require('../chunk-Q5Y33L7B.cjs');
|
|
|
7
7
|
require('../chunk-PNK5WMPP.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkLRX7AMSScjs = require('../chunk-LRX7AMSS.cjs');
|
|
11
11
|
|
|
12
12
|
// src/invoicing/invoicing.port.ts
|
|
13
13
|
var INVOICING = /* @__PURE__ */ Symbol("INVOICING");
|
|
@@ -561,7 +561,7 @@ var InvoicingModule = class {
|
|
|
561
561
|
};
|
|
562
562
|
}
|
|
563
563
|
};
|
|
564
|
-
InvoicingModule = exports.InvoicingModule =
|
|
564
|
+
InvoicingModule = exports.InvoicingModule = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
565
565
|
_common.Global.call(void 0, ),
|
|
566
566
|
_common.Module.call(void 0, {})
|
|
567
567
|
], InvoicingModule);
|
package/dist/invoicing/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A handler throws this when a third party asked to wait (HTTP 429 with
|
|
3
|
+
* `Retry-After`): the job goes back to the queue for after that wait WITHOUT
|
|
4
|
+
* spending an attempt, up to `maxDeferrals`. A `null` wait means the provider
|
|
5
|
+
* did not say how long: the queue uses its own growing wait.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DeferJob extends Error {
|
|
8
|
+
readonly retryAfterMs: number | null;
|
|
9
|
+
constructor(retryAfterMs?: number | null, message?: string);
|
|
10
|
+
}
|