@miguelmorales13/nestkit 0.26.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/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 +101 -101
- package/dist/auth/oauth/index.js +3 -3
- package/dist/bootstrap/apply-defaults.d.ts +9 -0
- package/dist/bootstrap/index.cjs +7 -6
- package/dist/bootstrap/index.js +6 -5
- 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-2DUEQKOI.js → chunk-5LVGCTJ3.js} +4 -4
- 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-LSDY6ETG.cjs → chunk-JJKGQNGD.cjs} +5 -5
- package/dist/{chunk-ALIKVFOV.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-PFHHLB7B.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 +19 -18
- package/dist/index.js +32 -31
- 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
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
+
};
|
|
3
7
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
8
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
9
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -11,6 +15,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
11
15
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
12
16
|
|
|
13
17
|
export {
|
|
18
|
+
__export,
|
|
14
19
|
__decorateClass,
|
|
15
20
|
__decorateParam
|
|
16
21
|
};
|
|
@@ -6,7 +6,7 @@ var _chunkY72D5L6Icjs = require('./chunk-Y72D5L6I.cjs');
|
|
|
6
6
|
var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkLRX7AMSScjs = require('./chunk-LRX7AMSS.cjs');
|
|
10
10
|
|
|
11
11
|
// src/response/response.interceptor.ts
|
|
12
12
|
var _common = require('@nestjs/common');
|
|
@@ -25,7 +25,7 @@ var ResponseInterceptor = class {
|
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
ResponseInterceptor = exports.ResponseInterceptor =
|
|
28
|
+
ResponseInterceptor = exports.ResponseInterceptor = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
29
29
|
_common.Injectable.call(void 0, )
|
|
30
30
|
], ResponseInterceptor);
|
|
31
31
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// src/tenancy/tenancy.options.ts
|
|
2
|
+
var TENANCY_OPTIONS = /* @__PURE__ */ Symbol("TENANCY_OPTIONS");
|
|
3
|
+
var DEFAULT_GUCS = { tenant: "app.tenant_id", actor: "app.actor_id" };
|
|
4
|
+
|
|
5
|
+
// src/tenancy/request-context.ts
|
|
6
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
7
|
+
var storage = new AsyncLocalStorage();
|
|
8
|
+
var TenancyContext = {
|
|
9
|
+
run(fn, initial = {}) {
|
|
10
|
+
return storage.run({ ...initial }, fn);
|
|
11
|
+
},
|
|
12
|
+
setTenant(tenantId) {
|
|
13
|
+
const s = storage.getStore();
|
|
14
|
+
if (s) s.tenantId = tenantId;
|
|
15
|
+
},
|
|
16
|
+
setActor(actorId) {
|
|
17
|
+
const s = storage.getStore();
|
|
18
|
+
if (s) s.actorId = actorId;
|
|
19
|
+
},
|
|
20
|
+
tenantId() {
|
|
21
|
+
return storage.getStore()?.tenantId;
|
|
22
|
+
},
|
|
23
|
+
actorId() {
|
|
24
|
+
return storage.getStore()?.actorId;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/tenancy/tenancy.errors.ts
|
|
29
|
+
var TenantRequiredError = class extends Error {
|
|
30
|
+
constructor(message = "No tenant in scope: refusing to run a tenant query without one.") {
|
|
31
|
+
super(message);
|
|
32
|
+
this.code = "TENANT_REQUIRED";
|
|
33
|
+
this.name = "TenantRequiredError";
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/tenancy/scope.ts
|
|
38
|
+
var GUC_NAME = /^[a-zA-Z_][\w]*(\.[\w-]+)+$/;
|
|
39
|
+
async function applyScope(query, scope, options = {}) {
|
|
40
|
+
const gucs = options.gucs ?? DEFAULT_GUCS;
|
|
41
|
+
const tenantId = scope.tenantId ?? TenancyContext.tenantId();
|
|
42
|
+
const actorId = scope.actorId ?? TenancyContext.actorId();
|
|
43
|
+
if (!tenantId && options.failClosed !== false) throw new TenantRequiredError();
|
|
44
|
+
const pairs = [];
|
|
45
|
+
if (tenantId) pairs.push([gucs.tenant, tenantId]);
|
|
46
|
+
if (gucs.actor && actorId) pairs.push([gucs.actor, actorId]);
|
|
47
|
+
for (const [name] of pairs) {
|
|
48
|
+
if (!GUC_NAME.test(name)) throw new Error(`Invalid GUC name: ${name}`);
|
|
49
|
+
}
|
|
50
|
+
for (const [name, value] of pairs) {
|
|
51
|
+
await query("SELECT set_config($1, $2, true)", [name, value]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
TENANCY_OPTIONS,
|
|
57
|
+
DEFAULT_GUCS,
|
|
58
|
+
TenancyContext,
|
|
59
|
+
TenantRequiredError,
|
|
60
|
+
applyScope
|
|
61
|
+
};
|
|
@@ -9,7 +9,7 @@ var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkLRX7AMSScjs = require('./chunk-LRX7AMSS.cjs');
|
|
13
13
|
|
|
14
14
|
// src/i18n/i18n.module.ts
|
|
15
15
|
|
|
@@ -36,7 +36,7 @@ var I18nInterceptor = class {
|
|
|
36
36
|
return next.handle().pipe(_operators.map.call(void 0, (data) => _chunkAXMW5JF7cjs.translateDeep.call(void 0, data, lang)));
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
I18nInterceptor = exports.I18nInterceptor =
|
|
39
|
+
I18nInterceptor = exports.I18nInterceptor = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
40
40
|
_common.Injectable.call(void 0, )
|
|
41
41
|
], I18nInterceptor);
|
|
42
42
|
|
|
@@ -181,11 +181,11 @@ var I18nModule = class {
|
|
|
181
181
|
return this.i18n;
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
|
-
I18nModule = exports.I18nModule =
|
|
184
|
+
I18nModule = exports.I18nModule = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
185
185
|
_common.Module.call(void 0, {}),
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Inject.call(void 0, NESTKIT_I18N_OPTIONS)),
|
|
187
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Optional.call(void 0, )),
|
|
188
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Inject.call(void 0, _nestjsi18n.I18nService))
|
|
189
189
|
], I18nModule);
|
|
190
190
|
var RuntimeResolver = class {
|
|
191
191
|
resolve(context) {
|
|
@@ -0,0 +1,90 @@
|
|
|
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; }// src/hardening/http.types.ts
|
|
2
|
+
function pathOf(req) {
|
|
3
|
+
const raw = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(req.path, () => ( req.originalUrl)), () => ( req.url)), () => ( ""));
|
|
4
|
+
const q = raw.indexOf("?");
|
|
5
|
+
return q === -1 ? raw : raw.slice(0, q);
|
|
6
|
+
}
|
|
7
|
+
function headerOf(req, name) {
|
|
8
|
+
const v = _optionalChain([req, 'access', _ => _.headers, 'optionalAccess', _2 => _2[name.toLowerCase()]]);
|
|
9
|
+
return Array.isArray(v) ? v[0] : v;
|
|
10
|
+
}
|
|
11
|
+
function matchesPath(rule, path) {
|
|
12
|
+
if (rule instanceof RegExp) return rule.test(path);
|
|
13
|
+
if (rule.endsWith("*")) return path.startsWith(rule.slice(0, -1));
|
|
14
|
+
return path === rule;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/hardening/body-limits.ts
|
|
18
|
+
var _module = require('module');
|
|
19
|
+
var _path = require('path');
|
|
20
|
+
var DEFAULT_BODY_LIMIT = "1mb";
|
|
21
|
+
var expressJson = (limit) => {
|
|
22
|
+
const req = _module.createRequire.call(void 0, _path.join.call(void 0, process.cwd(), "noop.js"));
|
|
23
|
+
return req("express").json({ limit });
|
|
24
|
+
};
|
|
25
|
+
function applyBodyLimits(app, options, factory = expressJson) {
|
|
26
|
+
const routes = _nullishCoalesce(options.routes, () => ( []));
|
|
27
|
+
if (routes.length) {
|
|
28
|
+
const parsers = /* @__PURE__ */ new Map();
|
|
29
|
+
const parserFor = (limit) => {
|
|
30
|
+
let p = parsers.get(limit);
|
|
31
|
+
if (!p) parsers.set(limit, p = factory(limit));
|
|
32
|
+
return p;
|
|
33
|
+
};
|
|
34
|
+
app.use((req, res, next) => {
|
|
35
|
+
const path = pathOf(req);
|
|
36
|
+
const rule = routes.find((r) => matchesPath(r.match, path));
|
|
37
|
+
return rule ? parserFor(rule.limit)(req, res, next) : next();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
_optionalChain([app, 'access', _3 => _3.useBodyParser, 'optionalCall', _4 => _4("json", { limit: _nullishCoalesce(options.default, () => ( DEFAULT_BODY_LIMIT)) })]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/hardening/origin-secret.ts
|
|
44
|
+
var _crypto = require('crypto');
|
|
45
|
+
var digest = (v) => _crypto.createHash.call(void 0, "sha256").update(v).digest();
|
|
46
|
+
function sameSecret(received, expected) {
|
|
47
|
+
return typeof received === "string" && _crypto.timingSafeEqual.call(void 0, digest(received), expected);
|
|
48
|
+
}
|
|
49
|
+
function originSecretMiddleware(options) {
|
|
50
|
+
const expected = options.value ? digest(options.value) : null;
|
|
51
|
+
const scoped = (_nullishCoalesce(options.scoped, () => ( []))).filter((s) => s.value).map((s) => ({ header: s.header, paths: s.paths, expected: digest(s.value) }));
|
|
52
|
+
const exclude = _nullishCoalesce(options.exclude, () => ( []));
|
|
53
|
+
return (req, res, next) => {
|
|
54
|
+
if (!expected) return next();
|
|
55
|
+
const path = pathOf(req);
|
|
56
|
+
if (exclude.some((r) => matchesPath(r, path))) return next();
|
|
57
|
+
if (sameSecret(headerOf(req, options.header), expected)) return next();
|
|
58
|
+
if (scoped.some(
|
|
59
|
+
(s) => s.paths.some((r) => matchesPath(r, path)) && sameSecret(headerOf(req, s.header), s.expected)
|
|
60
|
+
))
|
|
61
|
+
return next();
|
|
62
|
+
res.status(_nullishCoalesce(options.status, () => ( 403))).json({
|
|
63
|
+
success: false,
|
|
64
|
+
error: { code: _nullishCoalesce(options.code, () => ( "UNTRUSTED_ORIGIN")), message: _nullishCoalesce(options.message, () => ( "Access not allowed.")) }
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/hardening/trust-proxy.ts
|
|
70
|
+
function trustedIp(req, options = {}) {
|
|
71
|
+
for (const name of _nullishCoalesce(options.trustedHeaders, () => ( []))) {
|
|
72
|
+
const v = headerOf(req, name);
|
|
73
|
+
if (v) return v;
|
|
74
|
+
}
|
|
75
|
+
return _optionalChain([req, 'access', _5 => _5.ips, 'optionalAccess', _6 => _6.length]) ? req.ips[0] : _nullishCoalesce(req.ip, () => ( ""));
|
|
76
|
+
}
|
|
77
|
+
function applyTrustProxy(app, value) {
|
|
78
|
+
const instance = app.getHttpAdapter().getInstance();
|
|
79
|
+
_optionalChain([instance, 'access', _7 => _7.set, 'optionalCall', _8 => _8("trust proxy", value)]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
exports.pathOf = pathOf; exports.matchesPath = matchesPath; exports.DEFAULT_BODY_LIMIT = DEFAULT_BODY_LIMIT; exports.applyBodyLimits = applyBodyLimits; exports.originSecretMiddleware = originSecretMiddleware; exports.trustedIp = trustedIp; exports.applyTrustProxy = applyTrustProxy;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var _chunkQ5Y33L7Bcjs = require('./chunk-Q5Y33L7B.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
3
|
|
|
7
4
|
|
|
8
5
|
var _chunkAXMW5JF7cjs = require('./chunk-AXMW5JF7.cjs');
|
|
@@ -11,7 +8,10 @@ var _chunkAXMW5JF7cjs = require('./chunk-AXMW5JF7.cjs');
|
|
|
11
8
|
var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
|
|
12
9
|
|
|
13
10
|
|
|
14
|
-
var
|
|
11
|
+
var _chunkQ5Y33L7Bcjs = require('./chunk-Q5Y33L7B.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunkLRX7AMSScjs = require('./chunk-LRX7AMSS.cjs');
|
|
15
15
|
|
|
16
16
|
// src/errors/global-exception.filter.ts
|
|
17
17
|
|
|
@@ -87,7 +87,7 @@ var GlobalExceptionFilter = class {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
-
GlobalExceptionFilter = exports.GlobalExceptionFilter =
|
|
90
|
+
GlobalExceptionFilter = exports.GlobalExceptionFilter = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
91
91
|
_common.Catch.call(void 0, )
|
|
92
92
|
], GlobalExceptionFilter);
|
|
93
93
|
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkF77X4QUNcjs = require('./chunk-F77X4QUN.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkJJKGQNGDcjs = require('./chunk-JJKGQNGD.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunkIVWPA6QHcjs = require('./chunk-IVWPA6QH.cjs');
|
|
7
12
|
|
|
8
13
|
// src/bootstrap/apply-defaults.ts
|
|
9
14
|
|
|
@@ -12,13 +17,16 @@ var _common = require('@nestjs/common');
|
|
|
12
17
|
var _swagger = require('@nestjs/swagger');
|
|
13
18
|
var _helmet = require('helmet'); var _helmet2 = _interopRequireDefault(_helmet);
|
|
14
19
|
function applyNestKitDefaults(app, options = {}) {
|
|
20
|
+
if (options.trustProxy !== void 0) _chunkIVWPA6QHcjs.applyTrustProxy.call(void 0, app, options.trustProxy);
|
|
21
|
+
if (options.originSecret) app.use(_chunkIVWPA6QHcjs.originSecretMiddleware.call(void 0, options.originSecret));
|
|
22
|
+
if (options.bodyLimits) _chunkIVWPA6QHcjs.applyBodyLimits.call(void 0, app, options.bodyLimits);
|
|
15
23
|
app.use(_helmet2.default.call(void 0, ));
|
|
16
24
|
app.enableCors(_nullishCoalesce(options.cors, () => ( { origin: _nullishCoalesce(_optionalChain([process, 'access', _ => _.env, 'access', _2 => _2.CORS_ORIGIN, 'optionalAccess', _3 => _3.split, 'call', _4 => _4(",")]), () => ( true)) })));
|
|
17
25
|
app.useGlobalPipes(
|
|
18
26
|
new (0, _common.ValidationPipe)({ whitelist: true, transform: true, ...options.validation })
|
|
19
27
|
);
|
|
20
|
-
app.useGlobalFilters(new (0,
|
|
21
|
-
app.useGlobalInterceptors(new (0,
|
|
28
|
+
app.useGlobalFilters(new (0, _chunkJJKGQNGDcjs.GlobalExceptionFilter)());
|
|
29
|
+
app.useGlobalInterceptors(new (0, _chunkF77X4QUNcjs.ResponseInterceptor)());
|
|
22
30
|
if (options.swagger !== false) {
|
|
23
31
|
const swaggerOptions = _nullishCoalesce(options.swagger, () => ( { title: "API" }));
|
|
24
32
|
const config = new (0, _swagger.DocumentBuilder)().setTitle(swaggerOptions.title).build();
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkLRX7AMSScjs = require('./chunk-LRX7AMSS.cjs');
|
|
7
7
|
|
|
8
8
|
// src/tracking/request-id.middleware.ts
|
|
9
9
|
var _crypto = require('crypto');
|
|
@@ -18,7 +18,7 @@ var RequestIdMiddleware = class {
|
|
|
18
18
|
_chunkSDWHKPXIcjs.RequestContext.run({ requestId }, () => next());
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
RequestIdMiddleware = exports.RequestIdMiddleware =
|
|
21
|
+
RequestIdMiddleware = exports.RequestIdMiddleware = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
22
22
|
_common.Injectable.call(void 0, )
|
|
23
23
|
], RequestIdMiddleware);
|
|
24
24
|
|
|
@@ -29,7 +29,7 @@ var TrackingModule = class {
|
|
|
29
29
|
consumer.apply(RequestIdMiddleware).forRoutes("*");
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
TrackingModule = exports.TrackingModule =
|
|
32
|
+
TrackingModule = exports.TrackingModule = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
33
33
|
_common.Module.call(void 0, {})
|
|
34
34
|
], TrackingModule);
|
|
35
35
|
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await 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 _chunkW2T2VFLCcjs = require('./chunk-W2T2VFLC.cjs');
|
|
4
3
|
|
|
4
|
+
var _chunkY72D5L6Icjs = require('./chunk-Y72D5L6I.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkVALDHJOOcjs = require('./chunk-VALDHJOO.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkLRX7AMSScjs = require('./chunk-LRX7AMSS.cjs');
|
|
12
12
|
|
|
13
13
|
// src/crud/list-query.dto.ts
|
|
14
14
|
var _classtransformer = require('class-transformer');
|
|
15
15
|
var _classvalidator = require('class-validator');
|
|
16
16
|
var ListQuery = class {
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
_chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
19
19
|
_classvalidator.IsOptional.call(void 0, ),
|
|
20
20
|
_classtransformer.Type.call(void 0, () => Number),
|
|
21
21
|
_classvalidator.IsInt.call(void 0, ),
|
|
22
22
|
_classvalidator.Min.call(void 0, 1)
|
|
23
23
|
], ListQuery.prototype, "page", 2);
|
|
24
|
-
|
|
24
|
+
_chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
25
25
|
_classvalidator.IsOptional.call(void 0, ),
|
|
26
26
|
_classtransformer.Type.call(void 0, () => Number),
|
|
27
27
|
_classvalidator.IsInt.call(void 0, ),
|
|
28
28
|
_classvalidator.Min.call(void 0, 1),
|
|
29
29
|
_classvalidator.Max.call(void 0, 200)
|
|
30
30
|
], ListQuery.prototype, "limit", 2);
|
|
31
|
-
|
|
31
|
+
_chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
32
32
|
_classvalidator.IsOptional.call(void 0, ),
|
|
33
33
|
_classvalidator.IsString.call(void 0, )
|
|
34
34
|
], ListQuery.prototype, "sortBy", 2);
|
|
35
|
-
|
|
35
|
+
_chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
36
36
|
_classvalidator.IsOptional.call(void 0, ),
|
|
37
37
|
_classvalidator.IsIn.call(void 0, ["asc", "desc"])
|
|
38
38
|
], ListQuery.prototype, "sortOrder", 2);
|
|
@@ -117,7 +117,7 @@ var BaseCrudService = class {
|
|
|
117
117
|
const audit = this.options.audit;
|
|
118
118
|
if (!audit) return;
|
|
119
119
|
await audit.recorder.record(
|
|
120
|
-
|
|
120
|
+
_chunkVALDHJOOcjs.withRequestContext.call(void 0, {
|
|
121
121
|
action,
|
|
122
122
|
resource: audit.resource,
|
|
123
123
|
resourceId,
|
|
@@ -165,35 +165,35 @@ function createCrudController(serviceToken, options = {}) {
|
|
|
165
165
|
return this.service.delete(id, tenantIdOf(req));
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
|
-
|
|
168
|
+
_chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
169
169
|
_common.Get.call(void 0, ),
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Query.call(void 0, )),
|
|
171
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Req.call(void 0, ))
|
|
172
172
|
], CrudControllerHost.prototype, "findAll", 1);
|
|
173
|
-
|
|
173
|
+
_chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
174
174
|
_common.Get.call(void 0, ":id"),
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Param.call(void 0, "id")),
|
|
176
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Req.call(void 0, ))
|
|
177
177
|
], CrudControllerHost.prototype, "findById", 1);
|
|
178
|
-
|
|
178
|
+
_chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
179
179
|
_common.Post.call(void 0, ),
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Body.call(void 0, )),
|
|
181
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Req.call(void 0, ))
|
|
182
182
|
], CrudControllerHost.prototype, "create", 1);
|
|
183
|
-
|
|
183
|
+
_chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
184
184
|
_common.Patch.call(void 0, ":id"),
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Param.call(void 0, "id")),
|
|
186
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Body.call(void 0, )),
|
|
187
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 2, _common.Req.call(void 0, ))
|
|
188
188
|
], CrudControllerHost.prototype, "update", 1);
|
|
189
|
-
|
|
189
|
+
_chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
190
190
|
_common.Delete.call(void 0, ":id"),
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Param.call(void 0, "id")),
|
|
192
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Req.call(void 0, ))
|
|
193
193
|
], CrudControllerHost.prototype, "remove", 1);
|
|
194
|
-
CrudControllerHost =
|
|
194
|
+
CrudControllerHost = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
|
|
195
195
|
_common.Controller.call(void 0, _nullishCoalesce(options.path, () => ( ""))),
|
|
196
|
-
|
|
196
|
+
_chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Inject.call(void 0, serviceToken))
|
|
197
197
|
], CrudControllerHost);
|
|
198
198
|
return CrudControllerHost;
|
|
199
199
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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; }// src/tenancy/tenancy.options.ts
|
|
2
|
+
var TENANCY_OPTIONS = /* @__PURE__ */ Symbol("TENANCY_OPTIONS");
|
|
3
|
+
var DEFAULT_GUCS = { tenant: "app.tenant_id", actor: "app.actor_id" };
|
|
4
|
+
|
|
5
|
+
// src/tenancy/request-context.ts
|
|
6
|
+
var _async_hooks = require('async_hooks');
|
|
7
|
+
var storage = new (0, _async_hooks.AsyncLocalStorage)();
|
|
8
|
+
var TenancyContext = {
|
|
9
|
+
run(fn, initial = {}) {
|
|
10
|
+
return storage.run({ ...initial }, fn);
|
|
11
|
+
},
|
|
12
|
+
setTenant(tenantId) {
|
|
13
|
+
const s = storage.getStore();
|
|
14
|
+
if (s) s.tenantId = tenantId;
|
|
15
|
+
},
|
|
16
|
+
setActor(actorId) {
|
|
17
|
+
const s = storage.getStore();
|
|
18
|
+
if (s) s.actorId = actorId;
|
|
19
|
+
},
|
|
20
|
+
tenantId() {
|
|
21
|
+
return _optionalChain([storage, 'access', _ => _.getStore, 'call', _2 => _2(), 'optionalAccess', _3 => _3.tenantId]);
|
|
22
|
+
},
|
|
23
|
+
actorId() {
|
|
24
|
+
return _optionalChain([storage, 'access', _4 => _4.getStore, 'call', _5 => _5(), 'optionalAccess', _6 => _6.actorId]);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/tenancy/tenancy.errors.ts
|
|
29
|
+
var TenantRequiredError = class extends Error {
|
|
30
|
+
constructor(message = "No tenant in scope: refusing to run a tenant query without one.") {
|
|
31
|
+
super(message);
|
|
32
|
+
this.code = "TENANT_REQUIRED";
|
|
33
|
+
this.name = "TenantRequiredError";
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/tenancy/scope.ts
|
|
38
|
+
var GUC_NAME = /^[a-zA-Z_][\w]*(\.[\w-]+)+$/;
|
|
39
|
+
async function applyScope(query, scope, options = {}) {
|
|
40
|
+
const gucs = _nullishCoalesce(options.gucs, () => ( DEFAULT_GUCS));
|
|
41
|
+
const tenantId = _nullishCoalesce(scope.tenantId, () => ( TenancyContext.tenantId()));
|
|
42
|
+
const actorId = _nullishCoalesce(scope.actorId, () => ( TenancyContext.actorId()));
|
|
43
|
+
if (!tenantId && options.failClosed !== false) throw new TenantRequiredError();
|
|
44
|
+
const pairs = [];
|
|
45
|
+
if (tenantId) pairs.push([gucs.tenant, tenantId]);
|
|
46
|
+
if (gucs.actor && actorId) pairs.push([gucs.actor, actorId]);
|
|
47
|
+
for (const [name] of pairs) {
|
|
48
|
+
if (!GUC_NAME.test(name)) throw new Error(`Invalid GUC name: ${name}`);
|
|
49
|
+
}
|
|
50
|
+
for (const [name, value] of pairs) {
|
|
51
|
+
await query("SELECT set_config($1, $2, true)", [name, value]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
exports.TENANCY_OPTIONS = TENANCY_OPTIONS; exports.DEFAULT_GUCS = DEFAULT_GUCS; exports.TenancyContext = TenancyContext; exports.TenantRequiredError = TenantRequiredError; exports.applyScope = applyScope;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
+
};
|
|
3
7
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
8
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
9
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -13,4 +17,5 @@ var __decorateParam = (index, decorator) => (target, key) => decorator(target, k
|
|
|
13
17
|
|
|
14
18
|
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
|
|
21
|
+
exports.__export = __export; exports.__decorateClass = __decorateClass; exports.__decorateParam = __decorateParam;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
withRequestContext
|
|
3
|
-
} from "./chunk-ZJMLEP5H.js";
|
|
4
1
|
import {
|
|
5
2
|
buildPageMeta,
|
|
6
3
|
paginated
|
|
7
4
|
} from "./chunk-TCAMLNUZ.js";
|
|
5
|
+
import {
|
|
6
|
+
withRequestContext
|
|
7
|
+
} from "./chunk-NJYLQDB3.js";
|
|
8
8
|
import {
|
|
9
9
|
__decorateClass,
|
|
10
10
|
__decorateParam
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-D3DDJWUD.js";
|
|
12
12
|
|
|
13
13
|
// src/crud/list-query.dto.ts
|
|
14
14
|
import { Type } from "class-transformer";
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
|
|
3
|
+
var _chunkLRX7AMSScjs = require('./chunk-LRX7AMSS.cjs');
|
|
4
|
+
|
|
5
|
+
// src/consent/guard/index.ts
|
|
6
|
+
var guard_exports = {};
|
|
7
|
+
_chunkLRX7AMSScjs.__export.call(void 0, guard_exports, {
|
|
8
|
+
bundleContains: () => bundleContains,
|
|
9
|
+
checkParity: () => checkParity,
|
|
10
|
+
extractVersion: () => extractVersion,
|
|
11
|
+
verifyRelease: () => verifyRelease
|
|
12
|
+
});
|
|
13
|
+
function extractVersion(source, pattern) {
|
|
14
|
+
return _nullishCoalesce(_optionalChain([pattern, 'access', _ => _.exec, 'call', _2 => _2(source), 'optionalAccess', _3 => _3[1]]), () => ( null));
|
|
15
|
+
}
|
|
16
|
+
function checkParity(mobile, server) {
|
|
17
|
+
if (!mobile || !server) return { ok: false, message: "No se pudo leer la versi\xF3n m\xEDnima (m\xF3vil o servidor)." };
|
|
18
|
+
return mobile === server ? { ok: true, message: `Paridad correcta: ${server}.` } : { ok: false, message: `La m\xEDnima del m\xF3vil (${mobile}) no coincide con la del servidor (${server}).` };
|
|
19
|
+
}
|
|
20
|
+
function bundleContains(bundleText, minimum) {
|
|
21
|
+
return bundleText.includes(minimum) ? { ok: true, message: `El bundle web trae ${minimum}.` } : { ok: false, message: `El bundle web publicado NO trae ${minimum}: publ\xEDcalo antes de desplegar la API.` };
|
|
22
|
+
}
|
|
23
|
+
function verifyRelease(input) {
|
|
24
|
+
const results = [checkParity(input.mobile, input.server)];
|
|
25
|
+
if (input.webBundle !== void 0 && input.server)
|
|
26
|
+
results.push(bundleContains(input.webBundle, input.server));
|
|
27
|
+
if (input.mobilePublished !== void 0)
|
|
28
|
+
results.push(
|
|
29
|
+
input.mobilePublished === input.server ? { ok: true, message: "M\xF3vil publicado confirmado." } : { ok: false, message: `M\xF3vil publicado (${input.mobilePublished}) distinto de la m\xEDnima (${input.server}).` }
|
|
30
|
+
);
|
|
31
|
+
return { ok: results.every((r) => r.ok), results };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
exports.extractVersion = extractVersion; exports.checkParity = checkParity; exports.bundleContains = bundleContains; exports.verifyRelease = verifyRelease; exports.guard_exports = guard_exports;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ResponseInterceptor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IGSNB5BX.js";
|
|
4
4
|
import {
|
|
5
5
|
GlobalExceptionFilter
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5LVGCTJ3.js";
|
|
7
|
+
import {
|
|
8
|
+
applyBodyLimits,
|
|
9
|
+
applyTrustProxy,
|
|
10
|
+
originSecretMiddleware
|
|
11
|
+
} from "./chunk-WFCQDOSN.js";
|
|
7
12
|
|
|
8
13
|
// src/bootstrap/apply-defaults.ts
|
|
9
14
|
import {
|
|
@@ -12,6 +17,9 @@ import {
|
|
|
12
17
|
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
|
|
13
18
|
import helmet from "helmet";
|
|
14
19
|
function applyNestKitDefaults(app, options = {}) {
|
|
20
|
+
if (options.trustProxy !== void 0) applyTrustProxy(app, options.trustProxy);
|
|
21
|
+
if (options.originSecret) app.use(originSecretMiddleware(options.originSecret));
|
|
22
|
+
if (options.bodyLimits) applyBodyLimits(app, options.bodyLimits);
|
|
15
23
|
app.use(helmet());
|
|
16
24
|
app.enableCors(options.cors ?? { origin: process.env.CORS_ORIGIN?.split(",") ?? true });
|
|
17
25
|
app.useGlobalPipes(
|