@saltsquareio/nestjs-backend-platform 0.0.1
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/LICENSE +21 -0
- package/README.md +72 -0
- package/dist/cli/migrate.d.ts +2 -0
- package/dist/cli/migrate.js +34 -0
- package/dist/cli/migrate.js.map +1 -0
- package/dist/core/ai/ai.module.d.ts +5 -0
- package/dist/core/ai/ai.module.js +53 -0
- package/dist/core/ai/ai.module.js.map +1 -0
- package/dist/core/ai/ai.options.d.ts +33 -0
- package/dist/core/ai/ai.options.js +14 -0
- package/dist/core/ai/ai.options.js.map +1 -0
- package/dist/core/ai/ai.service.d.ts +49 -0
- package/dist/core/ai/ai.service.js +381 -0
- package/dist/core/ai/ai.service.js.map +1 -0
- package/dist/core/ai/ai.types.d.ts +133 -0
- package/dist/core/ai/ai.types.js +3 -0
- package/dist/core/ai/ai.types.js.map +1 -0
- package/dist/core/ai/context/context-formatter.service.d.ts +9 -0
- package/dist/core/ai/context/context-formatter.service.js +66 -0
- package/dist/core/ai/context/context-formatter.service.js.map +1 -0
- package/dist/core/ai/cost/cost-tracking.service.d.ts +12 -0
- package/dist/core/ai/cost/cost-tracking.service.js +65 -0
- package/dist/core/ai/cost/cost-tracking.service.js.map +1 -0
- package/dist/core/ai/entities/ai-invocation-log.entity.d.ts +19 -0
- package/dist/core/ai/entities/ai-invocation-log.entity.js +116 -0
- package/dist/core/ai/entities/ai-invocation-log.entity.js.map +1 -0
- package/dist/core/ai/entities/prompt-template.entity.d.ts +13 -0
- package/dist/core/ai/entities/prompt-template.entity.js +75 -0
- package/dist/core/ai/entities/prompt-template.entity.js.map +1 -0
- package/dist/core/ai/index.d.ts +18 -0
- package/dist/core/ai/index.js +36 -0
- package/dist/core/ai/index.js.map +1 -0
- package/dist/core/ai/llm/dummy-llm-model.d.ts +9 -0
- package/dist/core/ai/llm/dummy-llm-model.js +18 -0
- package/dist/core/ai/llm/dummy-llm-model.js.map +1 -0
- package/dist/core/ai/llm/index.d.ts +2 -0
- package/dist/core/ai/llm/index.js +19 -0
- package/dist/core/ai/llm/index.js.map +1 -0
- package/dist/core/ai/llm/openai-llm-model.d.ts +10 -0
- package/dist/core/ai/llm/openai-llm-model.js +46 -0
- package/dist/core/ai/llm/openai-llm-model.js.map +1 -0
- package/dist/core/ai/llm-model.d.ts +17 -0
- package/dist/core/ai/llm-model.js +3 -0
- package/dist/core/ai/llm-model.js.map +1 -0
- package/dist/core/ai/memory/memory.service.d.ts +18 -0
- package/dist/core/ai/memory/memory.service.js +157 -0
- package/dist/core/ai/memory/memory.service.js.map +1 -0
- package/dist/core/ai/memory/memory.types.d.ts +6 -0
- package/dist/core/ai/memory/memory.types.js +3 -0
- package/dist/core/ai/memory/memory.types.js.map +1 -0
- package/dist/core/ai/memory/memory.utils.d.ts +1 -0
- package/dist/core/ai/memory/memory.utils.js +17 -0
- package/dist/core/ai/memory/memory.utils.js.map +1 -0
- package/dist/core/ai/model-registry.service.d.ts +19 -0
- package/dist/core/ai/model-registry.service.js +60 -0
- package/dist/core/ai/model-registry.service.js.map +1 -0
- package/dist/core/ai/model-resolver.service.d.ts +6 -0
- package/dist/core/ai/model-resolver.service.js +28 -0
- package/dist/core/ai/model-resolver.service.js.map +1 -0
- package/dist/core/ai/prompt-builder.service.d.ts +16 -0
- package/dist/core/ai/prompt-builder.service.js +34 -0
- package/dist/core/ai/prompt-builder.service.js.map +1 -0
- package/dist/core/ai/provider/provider-factory.service.d.ts +18 -0
- package/dist/core/ai/provider/provider-factory.service.js +60 -0
- package/dist/core/ai/provider/provider-factory.service.js.map +1 -0
- package/dist/core/ai/safety/safety-guardrail.service.d.ts +9 -0
- package/dist/core/ai/safety/safety-guardrail.service.js +65 -0
- package/dist/core/ai/safety/safety-guardrail.service.js.map +1 -0
- package/dist/core/ai/summarization/summarization.service.d.ts +24 -0
- package/dist/core/ai/summarization/summarization.service.js +66 -0
- package/dist/core/ai/summarization/summarization.service.js.map +1 -0
- package/dist/core/ai/template/template.service.d.ts +14 -0
- package/dist/core/ai/template/template.service.js +88 -0
- package/dist/core/ai/template/template.service.js.map +1 -0
- package/dist/core/audit-log/audit-log.entity.d.ts +13 -0
- package/dist/core/audit-log/audit-log.entity.js +72 -0
- package/dist/core/audit-log/audit-log.entity.js.map +1 -0
- package/dist/core/audit-log/audit-log.module.d.ts +2 -0
- package/dist/core/audit-log/audit-log.module.js +25 -0
- package/dist/core/audit-log/audit-log.module.js.map +1 -0
- package/dist/core/audit-log/audit-log.service.d.ts +20 -0
- package/dist/core/audit-log/audit-log.service.js +59 -0
- package/dist/core/audit-log/audit-log.service.js.map +1 -0
- package/dist/core/audit-log/index.d.ts +6 -0
- package/dist/core/audit-log/index.js +11 -0
- package/dist/core/audit-log/index.js.map +1 -0
- package/dist/core/auth/auth.provider.d.ts +4 -0
- package/dist/core/auth/auth.provider.js +3 -0
- package/dist/core/auth/auth.provider.js.map +1 -0
- package/dist/core/auth/decorators.d.ts +4 -0
- package/dist/core/auth/decorators.js +11 -0
- package/dist/core/auth/decorators.js.map +1 -0
- package/dist/core/auth/index.d.ts +6 -0
- package/dist/core/auth/index.js +23 -0
- package/dist/core/auth/index.js.map +1 -0
- package/dist/core/auth/params.d.ts +2 -0
- package/dist/core/auth/params.js +23 -0
- package/dist/core/auth/params.js.map +1 -0
- package/dist/core/auth/role.can-activate.d.ts +10 -0
- package/dist/core/auth/role.can-activate.js +42 -0
- package/dist/core/auth/role.can-activate.js.map +1 -0
- package/dist/core/auth/types.d.ts +6 -0
- package/dist/core/auth/types.js +3 -0
- package/dist/core/auth/types.js.map +1 -0
- package/dist/core/auth/utils.d.ts +4 -0
- package/dist/core/auth/utils.js +22 -0
- package/dist/core/auth/utils.js.map +1 -0
- package/dist/core/configuration/coerce.d.ts +2 -0
- package/dist/core/configuration/coerce.js +8 -0
- package/dist/core/configuration/coerce.js.map +1 -0
- package/dist/core/configuration/configuration.module.d.ts +9 -0
- package/dist/core/configuration/configuration.module.js +38 -0
- package/dist/core/configuration/configuration.module.js.map +1 -0
- package/dist/core/configuration/define-config.d.ts +2 -0
- package/dist/core/configuration/define-config.js +20 -0
- package/dist/core/configuration/define-config.js.map +1 -0
- package/dist/core/configuration/env-files.d.ts +1 -0
- package/dist/core/configuration/env-files.js +7 -0
- package/dist/core/configuration/env-files.js.map +1 -0
- package/dist/core/configuration/index.d.ts +5 -0
- package/dist/core/configuration/index.js +22 -0
- package/dist/core/configuration/index.js.map +1 -0
- package/dist/core/configuration/schemas/app.schema.d.ts +16 -0
- package/dist/core/configuration/schemas/app.schema.js +23 -0
- package/dist/core/configuration/schemas/app.schema.js.map +1 -0
- package/dist/core/database/common.d.ts +12 -0
- package/dist/core/database/common.js +15 -0
- package/dist/core/database/common.js.map +1 -0
- package/dist/core/database/custom-snake-case-naming-strategy.d.ts +9 -0
- package/dist/core/database/custom-snake-case-naming-strategy.js +28 -0
- package/dist/core/database/custom-snake-case-naming-strategy.js.map +1 -0
- package/dist/core/database/database.config.d.ts +4 -0
- package/dist/core/database/database.config.js +39 -0
- package/dist/core/database/database.config.js.map +1 -0
- package/dist/core/database/database.module.d.ts +7 -0
- package/dist/core/database/database.module.js +58 -0
- package/dist/core/database/database.module.js.map +1 -0
- package/dist/core/database/database.schema.d.ts +41 -0
- package/dist/core/database/database.schema.js +33 -0
- package/dist/core/database/database.schema.js.map +1 -0
- package/dist/core/database/index.d.ts +5 -0
- package/dist/core/database/index.js +22 -0
- package/dist/core/database/index.js.map +1 -0
- package/dist/core/database/ssl-config.d.ts +3 -0
- package/dist/core/database/ssl-config.js +8 -0
- package/dist/core/database/ssl-config.js.map +1 -0
- package/dist/core/exception/all-exceptions.filter.d.ts +8 -0
- package/dist/core/exception/all-exceptions.filter.js +56 -0
- package/dist/core/exception/all-exceptions.filter.js.map +1 -0
- package/dist/core/exception/index.d.ts +1 -0
- package/dist/core/exception/index.js +18 -0
- package/dist/core/exception/index.js.map +1 -0
- package/dist/core/exception/utils.d.ts +6 -0
- package/dist/core/exception/utils.js +15 -0
- package/dist/core/exception/utils.js.map +1 -0
- package/dist/core/health/health.controller.d.ts +9 -0
- package/dist/core/health/health.controller.js +52 -0
- package/dist/core/health/health.controller.js.map +1 -0
- package/dist/core/health/health.module.d.ts +2 -0
- package/dist/core/health/health.module.js +24 -0
- package/dist/core/health/health.module.js.map +1 -0
- package/dist/core/health/index.d.ts +1 -0
- package/dist/core/health/index.js +18 -0
- package/dist/core/health/index.js.map +1 -0
- package/dist/core/health/shutdown-handler.d.ts +2 -0
- package/dist/core/health/shutdown-handler.js +20 -0
- package/dist/core/health/shutdown-handler.js.map +1 -0
- package/dist/core/health/shutdown.service.d.ts +11 -0
- package/dist/core/health/shutdown.service.js +54 -0
- package/dist/core/health/shutdown.service.js.map +1 -0
- package/dist/core/http/http.circuit-breaker.d.ts +4 -0
- package/dist/core/http/http.circuit-breaker.js +25 -0
- package/dist/core/http/http.circuit-breaker.js.map +1 -0
- package/dist/core/http/http.client.factory.d.ts +3 -0
- package/dist/core/http/http.client.factory.js +32 -0
- package/dist/core/http/http.client.factory.js.map +1 -0
- package/dist/core/http/http.module.d.ts +2 -0
- package/dist/core/http/http.module.js +19 -0
- package/dist/core/http/http.module.js.map +1 -0
- package/dist/core/http/http.open-api.d.ts +8 -0
- package/dist/core/http/http.open-api.js +22 -0
- package/dist/core/http/http.open-api.js.map +1 -0
- package/dist/core/http/http.types.d.ts +6 -0
- package/dist/core/http/http.types.js +3 -0
- package/dist/core/http/http.types.js.map +1 -0
- package/dist/core/http/index.d.ts +4 -0
- package/dist/core/http/index.js +21 -0
- package/dist/core/http/index.js.map +1 -0
- package/dist/core/info/index.d.ts +1 -0
- package/dist/core/info/index.js +18 -0
- package/dist/core/info/index.js.map +1 -0
- package/dist/core/info/info.controller.d.ts +3 -0
- package/dist/core/info/info.controller.js +33 -0
- package/dist/core/info/info.controller.js.map +1 -0
- package/dist/core/info/info.module.d.ts +6 -0
- package/dist/core/info/info.module.js +27 -0
- package/dist/core/info/info.module.js.map +1 -0
- package/dist/core/info/info.utils.d.ts +13 -0
- package/dist/core/info/info.utils.js +32 -0
- package/dist/core/info/info.utils.js.map +1 -0
- package/dist/core/logger/hash-pii.d.ts +1 -0
- package/dist/core/logger/hash-pii.js +13 -0
- package/dist/core/logger/hash-pii.js.map +1 -0
- package/dist/core/logger/index.d.ts +4 -0
- package/dist/core/logger/index.js +21 -0
- package/dist/core/logger/index.js.map +1 -0
- package/dist/core/logger/logger.module.d.ts +2 -0
- package/dist/core/logger/logger.module.js +30 -0
- package/dist/core/logger/logger.module.js.map +1 -0
- package/dist/core/logger/logging.interceptor.d.ts +8 -0
- package/dist/core/logger/logging.interceptor.js +51 -0
- package/dist/core/logger/logging.interceptor.js.map +1 -0
- package/dist/core/logger/pino.config.d.ts +9 -0
- package/dist/core/logger/pino.config.js +47 -0
- package/dist/core/logger/pino.config.js.map +1 -0
- package/dist/core/migrations/create-migration-data-source.d.ts +8 -0
- package/dist/core/migrations/create-migration-data-source.js +18 -0
- package/dist/core/migrations/create-migration-data-source.js.map +1 -0
- package/dist/core/migrations/index.d.ts +3 -0
- package/dist/core/migrations/index.js +20 -0
- package/dist/core/migrations/index.js.map +1 -0
- package/dist/core/migrations/platform-entities.d.ts +2 -0
- package/dist/core/migrations/platform-entities.js +10 -0
- package/dist/core/migrations/platform-entities.js.map +1 -0
- package/dist/core/migrations/run-migrations.d.ts +3 -0
- package/dist/core/migrations/run-migrations.js +80 -0
- package/dist/core/migrations/run-migrations.js.map +1 -0
- package/dist/core/newrelic/index.d.ts +1 -0
- package/dist/core/newrelic/index.js +18 -0
- package/dist/core/newrelic/index.js.map +1 -0
- package/dist/core/newrelic/newrelic.utils.d.ts +2 -0
- package/dist/core/newrelic/newrelic.utils.js +31 -0
- package/dist/core/newrelic/newrelic.utils.js.map +1 -0
- package/dist/core/scheduler/index.d.ts +3 -0
- package/dist/core/scheduler/index.js +20 -0
- package/dist/core/scheduler/index.js.map +1 -0
- package/dist/core/scheduler/scheduled-cron.decorator.d.ts +6 -0
- package/dist/core/scheduler/scheduled-cron.decorator.js +31 -0
- package/dist/core/scheduler/scheduled-cron.decorator.js.map +1 -0
- package/dist/core/scheduler/scheduler-control.service.d.ts +14 -0
- package/dist/core/scheduler/scheduler-control.service.js +42 -0
- package/dist/core/scheduler/scheduler-control.service.js.map +1 -0
- package/dist/core/scheduler/scheduler.module.d.ts +4 -0
- package/dist/core/scheduler/scheduler.module.js +27 -0
- package/dist/core/scheduler/scheduler.module.js.map +1 -0
- package/dist/core/throttler/index.d.ts +7 -0
- package/dist/core/throttler/index.js +25 -0
- package/dist/core/throttler/index.js.map +1 -0
- package/dist/core/throttler/pg-throttler.storage.d.ts +10 -0
- package/dist/core/throttler/pg-throttler.storage.js +58 -0
- package/dist/core/throttler/pg-throttler.storage.js.map +1 -0
- package/dist/core/throttler/rate-limit-hit.entity.d.ts +6 -0
- package/dist/core/throttler/rate-limit-hit.entity.js +36 -0
- package/dist/core/throttler/rate-limit-hit.entity.js.map +1 -0
- package/dist/core/throttler/throttler-cleanup.service.d.ts +7 -0
- package/dist/core/throttler/throttler-cleanup.service.js +41 -0
- package/dist/core/throttler/throttler-cleanup.service.js.map +1 -0
- package/dist/core/throttler/throttler-tracker.d.ts +2 -0
- package/dist/core/throttler/throttler-tracker.js +29 -0
- package/dist/core/throttler/throttler-tracker.js.map +1 -0
- package/dist/core/throttler/throttler.module.d.ts +2 -0
- package/dist/core/throttler/throttler.module.js +41 -0
- package/dist/core/throttler/throttler.module.js.map +1 -0
- package/dist/core/utils/app-initializer.d.ts +5 -0
- package/dist/core/utils/app-initializer.js +37 -0
- package/dist/core/utils/app-initializer.js.map +1 -0
- package/dist/core/utils/feature-flag.d.ts +1 -0
- package/dist/core/utils/feature-flag.js +10 -0
- package/dist/core/utils/feature-flag.js.map +1 -0
- package/dist/core/utils/index.d.ts +5 -0
- package/dist/core/utils/index.js +22 -0
- package/dist/core/utils/index.js.map +1 -0
- package/dist/core/utils/parse-allowed-origins.d.ts +1 -0
- package/dist/core/utils/parse-allowed-origins.js +21 -0
- package/dist/core/utils/parse-allowed-origins.js.map +1 -0
- package/dist/core/utils/security-middleware.d.ts +2 -0
- package/dist/core/utils/security-middleware.js +19 -0
- package/dist/core/utils/security-middleware.js.map +1 -0
- package/dist/core/utils/with-timeout.d.ts +4 -0
- package/dist/core/utils/with-timeout.js +23 -0
- package/dist/core/utils/with-timeout.js.map +1 -0
- package/dist/core/ws/index.d.ts +4 -0
- package/dist/core/ws/index.js +23 -0
- package/dist/core/ws/index.js.map +1 -0
- package/dist/core/ws/validate-ws-dto.d.ts +1 -0
- package/dist/core/ws/validate-ws-dto.js +14 -0
- package/dist/core/ws/validate-ws-dto.js.map +1 -0
- package/dist/core/ws/ws-token.module.d.ts +2 -0
- package/dist/core/ws/ws-token.module.js +21 -0
- package/dist/core/ws/ws-token.module.js.map +1 -0
- package/dist/core/ws/ws-token.service.d.ts +8 -0
- package/dist/core/ws/ws-token.service.js +57 -0
- package/dist/core/ws/ws-token.service.js.map +1 -0
- package/dist/core/ws/ws.constants.d.ts +7 -0
- package/dist/core/ws/ws.constants.js +11 -0
- package/dist/core/ws/ws.constants.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/package.json +167 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppInfoSingleton = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
class AppInfoSingleton {
|
|
7
|
+
constructor(info) {
|
|
8
|
+
this.info = info;
|
|
9
|
+
}
|
|
10
|
+
static getInfo() {
|
|
11
|
+
return AppInfoSingleton.getInstance().info;
|
|
12
|
+
}
|
|
13
|
+
static getInstance() {
|
|
14
|
+
if (!AppInfoSingleton.instance) {
|
|
15
|
+
const info = AppInfoSingleton.resolveInfo();
|
|
16
|
+
AppInfoSingleton.instance = new AppInfoSingleton(info);
|
|
17
|
+
}
|
|
18
|
+
return AppInfoSingleton.instance;
|
|
19
|
+
}
|
|
20
|
+
static resolveInfo() {
|
|
21
|
+
const path = (0, path_1.join)(process.cwd(), 'package.json');
|
|
22
|
+
const rawContent = (0, fs_1.readFileSync)(path, 'utf-8');
|
|
23
|
+
const content = JSON.parse(rawContent);
|
|
24
|
+
return {
|
|
25
|
+
name: content.name,
|
|
26
|
+
description: content.description,
|
|
27
|
+
version: content.version,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.AppInfoSingleton = AppInfoSingleton;
|
|
32
|
+
//# sourceMappingURL=info.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.utils.js","sourceRoot":"","sources":["../../../src/core/info/info.utils.ts"],"names":[],"mappings":";;;AAAA,2BAAkC;AAClC,+BAA4B;AAQ5B,MAAa,gBAAgB;IAG3B,YAAqC,IAAc;QAAd,SAAI,GAAJ,IAAI,CAAU;IAAG,CAAC;IAEhD,MAAM,CAAC,OAAO;QACnB,OAAO,gBAAgB,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC;IAC7C,CAAC;IAEO,MAAM,CAAC,WAAW;QACxB,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;YAC/B,MAAM,IAAI,GAAG,gBAAgB,CAAC,WAAW,EAAE,CAAC;YAC5C,gBAAgB,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,gBAAgB,CAAC,QAAQ,CAAC;IACnC,CAAC;IAEO,MAAM,CAAC,WAAW;QACxB,MAAM,IAAI,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QACjD,MAAM,UAAU,GAAG,IAAA,iBAAY,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAa,CAAC;QACnD,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC;IACJ,CAAC;CACF;AA3BD,4CA2BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hashEmail(email: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hashEmail = hashEmail;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const HASH_LENGTH = 12;
|
|
6
|
+
function hashEmail(email) {
|
|
7
|
+
const normalized = email.trim().toLowerCase();
|
|
8
|
+
return (0, node_crypto_1.createHash)('sha256')
|
|
9
|
+
.update(normalized)
|
|
10
|
+
.digest('hex')
|
|
11
|
+
.slice(0, HASH_LENGTH);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=hash-pii.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-pii.js","sourceRoot":"","sources":["../../../src/core/logger/hash-pii.ts"],"names":[],"mappings":";;AASA,8BAMC;AAfD,6CAAyC;AAEzC,MAAM,WAAW,GAAG,EAAE,CAAC;AAOvB,SAAgB,SAAS,CAAC,KAAa;IACrC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC;SACxB,MAAM,CAAC,UAAU,CAAC;SAClB,MAAM,CAAC,KAAK,CAAC;SACb,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./logger.module"), exports);
|
|
18
|
+
__exportStar(require("./logging.interceptor"), exports);
|
|
19
|
+
__exportStar(require("./pino.config"), exports);
|
|
20
|
+
__exportStar(require("./hash-pii"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/logger/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,wDAAsC;AACtC,gDAA8B;AAC9B,6CAA2B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LoggerModule = void 0;
|
|
10
|
+
const nestjs_pino_1 = require("nestjs-pino");
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const core_1 = require("@nestjs/core");
|
|
13
|
+
const config_1 = require("@nestjs/config");
|
|
14
|
+
const pino_config_1 = require("./pino.config");
|
|
15
|
+
const logging_interceptor_1 = require("./logging.interceptor");
|
|
16
|
+
let LoggerModule = class LoggerModule {
|
|
17
|
+
};
|
|
18
|
+
exports.LoggerModule = LoggerModule;
|
|
19
|
+
exports.LoggerModule = LoggerModule = __decorate([
|
|
20
|
+
(0, common_1.Module)({
|
|
21
|
+
imports: [
|
|
22
|
+
nestjs_pino_1.LoggerModule.forRootAsync({
|
|
23
|
+
inject: [config_1.ConfigService],
|
|
24
|
+
useFactory: (configService) => (0, pino_config_1.pinoConfig)(configService),
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
providers: [{ provide: core_1.APP_INTERCEPTOR, useClass: logging_interceptor_1.LoggingInterceptor }],
|
|
28
|
+
})
|
|
29
|
+
], LoggerModule);
|
|
30
|
+
//# sourceMappingURL=logger.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../../../src/core/logger/logger.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6CAA+D;AAC/D,2CAAwC;AACxC,uCAA+C;AAC/C,2CAA+C;AAC/C,+CAAiE;AACjE,+DAA2D;AAYpD,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IAVxB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,0BAAgB,CAAC,YAAY,CAAC;gBAC5B,MAAM,EAAE,CAAC,sBAAa,CAAC;gBACvB,UAAU,EAAE,CAAC,aAAkD,EAAE,EAAE,CACjE,IAAA,wBAAU,EAAC,aAAa,CAAC;aAC5B,CAAC;SACH;QACD,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,sBAAe,EAAE,QAAQ,EAAE,wCAAkB,EAAE,CAAC;KACxE,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { PinoLogger } from 'nestjs-pino';
|
|
4
|
+
export declare class LoggingInterceptor implements NestInterceptor {
|
|
5
|
+
private readonly pinoLogger;
|
|
6
|
+
constructor(pinoLogger: PinoLogger);
|
|
7
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LoggingInterceptor = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const rxjs_1 = require("rxjs");
|
|
15
|
+
const nestjs_pino_1 = require("nestjs-pino");
|
|
16
|
+
const newrelic_utils_1 = require("../newrelic/newrelic.utils");
|
|
17
|
+
let LoggingInterceptor = class LoggingInterceptor {
|
|
18
|
+
constructor(pinoLogger) {
|
|
19
|
+
this.pinoLogger = pinoLogger;
|
|
20
|
+
}
|
|
21
|
+
intercept(context, next) {
|
|
22
|
+
const request = context.switchToHttp().getRequest();
|
|
23
|
+
const traceId = request.id;
|
|
24
|
+
const userId = request.user?.sub ?? 'anonymous';
|
|
25
|
+
const { method, url } = request;
|
|
26
|
+
this.pinoLogger.assign({ ...(traceId && { traceId }), userId });
|
|
27
|
+
(0, newrelic_utils_1.addCustomAttributes)({ ...(traceId && { traceId }), userId });
|
|
28
|
+
this.pinoLogger.info({ method, url }, 'Request started');
|
|
29
|
+
const startTime = Date.now();
|
|
30
|
+
return next.handle().pipe((0, rxjs_1.tap)({
|
|
31
|
+
next: () => {
|
|
32
|
+
const response = context
|
|
33
|
+
.switchToHttp()
|
|
34
|
+
.getResponse();
|
|
35
|
+
const durationMs = Date.now() - startTime;
|
|
36
|
+
this.pinoLogger.info({ method, url, statusCode: response.statusCode, durationMs }, 'Request completed');
|
|
37
|
+
},
|
|
38
|
+
error: (error) => {
|
|
39
|
+
const durationMs = Date.now() - startTime;
|
|
40
|
+
const statusCode = error instanceof common_1.HttpException ? error.getStatus() : 500;
|
|
41
|
+
this.pinoLogger.error({ method, url, statusCode, durationMs }, 'Request failed');
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.LoggingInterceptor = LoggingInterceptor;
|
|
47
|
+
exports.LoggingInterceptor = LoggingInterceptor = __decorate([
|
|
48
|
+
(0, common_1.Injectable)(),
|
|
49
|
+
__metadata("design:paramtypes", [nestjs_pino_1.PinoLogger])
|
|
50
|
+
], LoggingInterceptor);
|
|
51
|
+
//# sourceMappingURL=logging.interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.interceptor.js","sourceRoot":"","sources":["../../../src/core/logger/logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAMwB;AACxB,+BAAuC;AACvC,6CAAyC;AACzC,+DAAiE;AAc1D,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD,SAAS,CAAC,OAAyB,EAAE,IAAiB;QACpD,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAkB,CAAC;QACpE,MAAM,OAAO,GAAG,OAAO,CAAC,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,IAAI,WAAW,CAAC;QAChD,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QAEhC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAChE,IAAA,oCAAmB,EAAC,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAC7D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAC;QAEzD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,UAAG,EAAC;YACF,IAAI,EAAE,GAAG,EAAE;gBACT,MAAM,QAAQ,GAAG,OAAO;qBACrB,YAAY,EAAE;qBACd,WAAW,EAAsB,CAAC;gBACrC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;gBAC1C,IAAI,CAAC,UAAU,CAAC,IAAI,CAClB,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,EAC5D,mBAAmB,CACpB,CAAC;YACJ,CAAC;YACD,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE;gBACxB,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;gBAC1C,MAAM,UAAU,GACd,KAAK,YAAY,sBAAa,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;gBAC3D,IAAI,CAAC,UAAU,CAAC,KAAK,CACnB,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,EACvC,gBAAgB,CACjB,CAAC;YACJ,CAAC;SACF,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAA;AAvCY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;qCAE8B,wBAAU;GADxC,kBAAkB,CAuC9B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Params } from 'nestjs-pino';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
export interface EnvironmentVariables {
|
|
4
|
+
NODE_ENV: string;
|
|
5
|
+
LOG_LEVEL: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const REDACT_PATHS: string[];
|
|
8
|
+
export declare const REDACT_CENSOR = "[REDACTED]";
|
|
9
|
+
export declare const pinoConfig: (configService: ConfigService<EnvironmentVariables>) => Params;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pinoConfig = exports.REDACT_CENSOR = exports.REDACT_PATHS = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
exports.REDACT_PATHS = [
|
|
6
|
+
'password',
|
|
7
|
+
'token',
|
|
8
|
+
'accessToken',
|
|
9
|
+
'refreshToken',
|
|
10
|
+
'apiKey',
|
|
11
|
+
'authorization',
|
|
12
|
+
'Authorization',
|
|
13
|
+
'headers.authorization',
|
|
14
|
+
'headers.cookie',
|
|
15
|
+
'req.headers.authorization',
|
|
16
|
+
'req.headers.cookie',
|
|
17
|
+
'body.password',
|
|
18
|
+
'body.refreshToken',
|
|
19
|
+
];
|
|
20
|
+
exports.REDACT_CENSOR = '[REDACTED]';
|
|
21
|
+
const pinoConfig = (configService) => {
|
|
22
|
+
const nodeEnv = configService.get('NODE_ENV');
|
|
23
|
+
const isDev = nodeEnv === 'development';
|
|
24
|
+
const isTest = nodeEnv === 'test';
|
|
25
|
+
return {
|
|
26
|
+
pinoHttp: {
|
|
27
|
+
enabled: !isTest,
|
|
28
|
+
level: configService.get('LOG_LEVEL', 'info'),
|
|
29
|
+
autoLogging: false,
|
|
30
|
+
genReqId: (req) => req.headers['x-trace-id'] ?? (0, node_crypto_1.randomUUID)(),
|
|
31
|
+
redact: { paths: exports.REDACT_PATHS, censor: exports.REDACT_CENSOR },
|
|
32
|
+
transport: isDev
|
|
33
|
+
? {
|
|
34
|
+
target: 'pino-pretty',
|
|
35
|
+
options: {
|
|
36
|
+
colorize: true,
|
|
37
|
+
translateTime: 'SYS:standard',
|
|
38
|
+
ignore: 'pid,hostname,req',
|
|
39
|
+
singleLine: true,
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
: undefined,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.pinoConfig = pinoConfig;
|
|
47
|
+
//# sourceMappingURL=pino.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pino.config.js","sourceRoot":"","sources":["../../../src/core/logger/pino.config.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAU5B,QAAA,YAAY,GAAG;IAC1B,UAAU;IACV,OAAO;IACP,aAAa;IACb,cAAc;IACd,QAAQ;IACR,eAAe;IACf,eAAe;IACf,uBAAuB;IACvB,gBAAgB;IAChB,2BAA2B;IAC3B,oBAAoB;IACpB,eAAe;IACf,mBAAmB;CACpB,CAAC;AAEW,QAAA,aAAa,GAAG,YAAY,CAAC;AAEnC,MAAM,UAAU,GAAG,CACxB,aAAkD,EAC1C,EAAE;IACV,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,CAAS,UAAU,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,OAAO,KAAK,aAAa,CAAC;IACxC,MAAM,MAAM,GAAG,OAAO,KAAK,MAAM,CAAC;IAClC,OAAO;QACL,QAAQ,EAAE;YACR,OAAO,EAAE,CAAC,MAAM;YAChB,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC;YAC7C,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE,CAAC,GAAoB,EAAE,EAAE,CAChC,GAAG,CAAC,OAAO,CAAC,YAAY,CAAY,IAAI,IAAA,wBAAU,GAAE;YACvD,MAAM,EAAE,EAAE,KAAK,EAAE,oBAAY,EAAE,MAAM,EAAE,qBAAa,EAAE;YACtD,SAAS,EAAE,KAAK;gBACd,CAAC,CAAC;oBACE,MAAM,EAAE,aAAa;oBACrB,OAAO,EAAE;wBACP,QAAQ,EAAE,IAAI;wBACd,aAAa,EAAE,cAAc;wBAC7B,MAAM,EAAE,kBAAkB;wBAC1B,UAAU,EAAE,IAAI;qBACjB;iBACF;gBACH,CAAC,CAAC,SAAS;SACd;KACF,CAAC;AACJ,CAAC,CAAC;AA3BW,QAAA,UAAU,cA2BrB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DataSource } from 'typeorm';
|
|
2
|
+
import { EntityClassOrSchema } from '@nestjs/typeorm/dist/interfaces/entity-class-or-schema.type';
|
|
3
|
+
export interface MigrationDataSourceOptions {
|
|
4
|
+
entities?: (EntityClassOrSchema | string)[];
|
|
5
|
+
migrations?: string[];
|
|
6
|
+
appEnv?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function createMigrationDataSource(options?: MigrationDataSourceOptions): DataSource;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMigrationDataSource = createMigrationDataSource;
|
|
4
|
+
const dotenv_1 = require("dotenv");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const env_files_1 = require("../configuration/env-files");
|
|
7
|
+
const database_config_1 = require("../database/database.config");
|
|
8
|
+
const database_schema_1 = require("../database/database.schema");
|
|
9
|
+
const platform_entities_1 = require("./platform-entities");
|
|
10
|
+
function createMigrationDataSource(options = {}) {
|
|
11
|
+
const appEnv = options.appEnv ?? process.env.APP_ENV ?? 'local';
|
|
12
|
+
(0, dotenv_1.config)({ path: (0, env_files_1.buildEnvFilePath)(appEnv) });
|
|
13
|
+
return new typeorm_1.DataSource((0, database_config_1.getDatabaseConfig)((0, database_schema_1.databaseConfig)(), {
|
|
14
|
+
entities: [...platform_entities_1.PLATFORM_ENTITIES, ...(options.entities ?? [])],
|
|
15
|
+
migrations: options.migrations,
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=create-migration-data-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-migration-data-source.js","sourceRoot":"","sources":["../../../src/core/migrations/create-migration-data-source.ts"],"names":[],"mappings":";;AAuBA,8DAYC;AAnCD,mCAA2C;AAC3C,qCAAqC;AAErC,0DAA8D;AAC9D,iEAAgE;AAChE,iEAA6D;AAC7D,2DAAwD;AAiBxD,SAAgB,yBAAyB,CACvC,UAAsC,EAAE;IAExC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC;IAChE,IAAA,eAAO,EAAC,EAAE,IAAI,EAAE,IAAA,4BAAgB,EAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAE5C,OAAO,IAAI,oBAAU,CACnB,IAAA,mCAAiB,EAAC,IAAA,gCAAc,GAAE,EAAE;QAClC,QAAQ,EAAE,CAAC,GAAG,qCAAiB,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;QAC7D,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./create-migration-data-source"), exports);
|
|
18
|
+
__exportStar(require("./platform-entities"), exports);
|
|
19
|
+
__exportStar(require("./run-migrations"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/migrations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C;AAC/C,sDAAoC;AACpC,mDAAiC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PLATFORM_ENTITIES = void 0;
|
|
4
|
+
const audit_log_1 = require("../audit-log");
|
|
5
|
+
const throttler_1 = require("../throttler");
|
|
6
|
+
exports.PLATFORM_ENTITIES = [
|
|
7
|
+
...audit_log_1.AUDIT_LOG_ENTITIES,
|
|
8
|
+
...throttler_1.THROTTLER_ENTITIES,
|
|
9
|
+
];
|
|
10
|
+
//# sourceMappingURL=platform-entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-entities.js","sourceRoot":"","sources":["../../../src/core/migrations/platform-entities.ts"],"names":[],"mappings":";;;AACA,4CAAkD;AAClD,4CAAkD;AAMrC,QAAA,iBAAiB,GAA0B;IACtD,GAAG,8BAAkB;IACrB,GAAG,8BAAkB;CACtB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runMigrations = runMigrations;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
function log(message) {
|
|
6
|
+
console.log(`[migrations] ${message}`);
|
|
7
|
+
}
|
|
8
|
+
function migrationsTable(dataSource) {
|
|
9
|
+
return dataSource.options.migrationsTableName ?? 'migrations';
|
|
10
|
+
}
|
|
11
|
+
async function head(dataSource) {
|
|
12
|
+
try {
|
|
13
|
+
const rows = await dataSource.query(`SELECT name FROM "${migrationsTable(dataSource)}" ORDER BY id DESC LIMIT 1`);
|
|
14
|
+
return rows[0]?.name ?? '(none)';
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
const message = err instanceof Error ? err.message : '';
|
|
18
|
+
if (message.includes('does not exist')) {
|
|
19
|
+
return '(none — table created on first run)';
|
|
20
|
+
}
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function runUp(dataSource) {
|
|
25
|
+
log(`previous head: ${await head(dataSource)}`);
|
|
26
|
+
const applied = await dataSource.runMigrations();
|
|
27
|
+
if (applied.length === 0) {
|
|
28
|
+
log('no pending migrations');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
for (const migration of applied) {
|
|
32
|
+
log(`applied: ${migration.name}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
log(`new head: ${await head(dataSource)}`);
|
|
36
|
+
}
|
|
37
|
+
async function show(dataSource) {
|
|
38
|
+
const executor = new typeorm_1.MigrationExecutor(dataSource);
|
|
39
|
+
const all = await executor.getAllMigrations();
|
|
40
|
+
const executed = await executor.getExecutedMigrations();
|
|
41
|
+
const executedNames = new Set(executed.map((m) => m.name));
|
|
42
|
+
log(`current head: ${await head(dataSource)}`);
|
|
43
|
+
log(`applied: ${executed.length} / total: ${all.length}`);
|
|
44
|
+
for (const migration of all) {
|
|
45
|
+
log(`${executedNames.has(migration.name) ? '[x]' : '[ ]'} ${migration.name}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function revert(dataSource, steps) {
|
|
49
|
+
if (!Number.isInteger(steps) || steps < 1) {
|
|
50
|
+
throw new Error(`revert: steps must be a positive integer (got ${steps})`);
|
|
51
|
+
}
|
|
52
|
+
for (let i = 1; i <= steps; i++) {
|
|
53
|
+
log(`step ${i}/${steps} reverting from: ${await head(dataSource)}`);
|
|
54
|
+
await dataSource.undoLastMigration();
|
|
55
|
+
log(`step ${i}/${steps} new head: ${await head(dataSource)}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function runMigrations(dataSource, command = 'run', steps = 1) {
|
|
59
|
+
const owned = !dataSource.isInitialized;
|
|
60
|
+
if (owned) {
|
|
61
|
+
await dataSource.initialize();
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
if (command === 'run') {
|
|
65
|
+
await runUp(dataSource);
|
|
66
|
+
}
|
|
67
|
+
else if (command === 'show') {
|
|
68
|
+
await show(dataSource);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
await revert(dataSource, steps);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
if (owned) {
|
|
76
|
+
await dataSource.destroy();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=run-migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-migrations.js","sourceRoot":"","sources":["../../../src/core/migrations/run-migrations.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './newrelic.utils';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./newrelic.utils"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/newrelic/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addCustomAttributes = addCustomAttributes;
|
|
4
|
+
exports.noticeError = noticeError;
|
|
5
|
+
let cached;
|
|
6
|
+
function agent() {
|
|
7
|
+
if (cached === undefined) {
|
|
8
|
+
try {
|
|
9
|
+
cached = require('newrelic');
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
cached = null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return cached;
|
|
16
|
+
}
|
|
17
|
+
function addCustomAttributes(attributes) {
|
|
18
|
+
try {
|
|
19
|
+
agent()?.addCustomAttributes(attributes);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function noticeError(error, attributes) {
|
|
25
|
+
try {
|
|
26
|
+
agent()?.noticeError(error, attributes);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=newrelic.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"newrelic.utils.js","sourceRoot":"","sources":["../../../src/core/newrelic/newrelic.utils.ts"],"names":[],"mappings":";;AAoBA,kDAMC;AAED,kCASC;AAhCD,IAAI,MAAwC,CAAC;AAE7C,SAAS,KAAK;IACZ,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,IAAI,CAAC;YAGH,MAAM,GAAG,OAAO,CAAC,UAAU,CAAkB,CAAC;QAChD,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,mBAAmB,CAAC,UAAkC;IACpE,IAAI,CAAC;QACH,KAAK,EAAE,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;AACH,CAAC;AAED,SAAgB,WAAW,CACzB,KAAc,EACd,UAAmC;IAEnC,IAAI,CAAC;QACH,KAAK,EAAE,EAAE,WAAW,CAAC,KAAc,EAAE,UAAU,CAAC,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./scheduled-cron.decorator"), exports);
|
|
18
|
+
__exportStar(require("./scheduler-control.service"), exports);
|
|
19
|
+
__exportStar(require("./scheduler.module"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/scheduler/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,8DAA4C;AAC5C,qDAAmC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CronExpression } from '@nestjs/schedule';
|
|
2
|
+
export type ScheduledCronExpression = CronExpression;
|
|
3
|
+
export declare const ScheduledCronExpression: typeof CronExpression;
|
|
4
|
+
export declare function ScheduledCron(cronExpression: ScheduledCronExpression | string, options?: {
|
|
5
|
+
timeZone?: string;
|
|
6
|
+
}): MethodDecorator;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScheduledCronExpression = void 0;
|
|
4
|
+
exports.ScheduledCron = ScheduledCron;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const schedule_1 = require("@nestjs/schedule");
|
|
7
|
+
const nestjs_pino_1 = require("nestjs-pino");
|
|
8
|
+
const storage_1 = require("nestjs-pino/storage");
|
|
9
|
+
exports.ScheduledCronExpression = schedule_1.CronExpression;
|
|
10
|
+
function ScheduledCron(cronExpression, options) {
|
|
11
|
+
return (target, propertyKey, descriptor) => {
|
|
12
|
+
const name = `${target.constructor.name}.${String(propertyKey)}`;
|
|
13
|
+
const originalMethod = descriptor.value;
|
|
14
|
+
descriptor.value = function (...args) {
|
|
15
|
+
const childLogger = nestjs_pino_1.PinoLogger.root.child({
|
|
16
|
+
traceId: (0, node_crypto_1.randomUUID)(),
|
|
17
|
+
userId: 'system',
|
|
18
|
+
cronJob: name,
|
|
19
|
+
});
|
|
20
|
+
return storage_1.storage.run(new storage_1.Store(childLogger), () => originalMethod.apply(this, args));
|
|
21
|
+
};
|
|
22
|
+
(0, schedule_1.Cron)(cronExpression, {
|
|
23
|
+
name,
|
|
24
|
+
disabled: true,
|
|
25
|
+
waitForCompletion: true,
|
|
26
|
+
...options,
|
|
27
|
+
})(target, propertyKey, descriptor);
|
|
28
|
+
return descriptor;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=scheduled-cron.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduled-cron.decorator.js","sourceRoot":"","sources":["../../../src/core/scheduler/scheduled-cron.decorator.ts"],"names":[],"mappings":";;;AAQA,sCAuCC;AA/CD,6CAAyC;AACzC,+CAAwD;AACxD,6CAAyC;AACzC,iDAAqD;AAGxC,QAAA,uBAAuB,GAAG,yBAAc,CAAC;AAEtD,SAAgB,aAAa,CAC3B,cAAgD,EAChD,OAA+B;IAE/B,OAAO,CACL,MAAc,EACd,WAA4B,EAC5B,UAA8B,EAC9B,EAAE;QACF,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;QACjE,MAAM,cAAc,GAAG,UAAU,CAAC,KAEb,CAAC;QAEtB,UAAU,CAAC,KAAK,GAAG,UAEjB,GAAG,IAAe;YAElB,MAAM,WAAW,GAAG,wBAAU,CAAC,IAAI,CAAC,KAAK,CAAC;gBACxC,OAAO,EAAE,IAAA,wBAAU,GAAE;gBACrB,MAAM,EAAE,QAAQ;gBAChB,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;YAEH,OAAO,iBAAO,CAAC,GAAG,CAChB,IAAI,eAAK,CAAC,WAAW,CAAC,EACtB,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAqB,CAC3D,CAAC;QACJ,CAAC,CAAC;QAEF,IAAA,eAAI,EAAC,cAAc,EAAE;YACnB,IAAI;YACJ,QAAQ,EAAE,IAAI;YACd,iBAAiB,EAAE,IAAI;YACvB,GAAG,OAAO;SACX,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAEpC,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OnApplicationBootstrap } from '@nestjs/common';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
import { SchedulerRegistry } from '@nestjs/schedule';
|
|
4
|
+
interface EnvironmentVariables {
|
|
5
|
+
SCHEDULER_ENABLED?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class SchedulerControlService implements OnApplicationBootstrap {
|
|
8
|
+
private readonly schedulerRegistry;
|
|
9
|
+
private readonly configService;
|
|
10
|
+
private readonly logger;
|
|
11
|
+
constructor(schedulerRegistry: SchedulerRegistry, configService: ConfigService<EnvironmentVariables>);
|
|
12
|
+
onApplicationBootstrap(): void;
|
|
13
|
+
}
|
|
14
|
+
export {};
|