@flusys/nestjs-shared 7.0.2 → 8.0.0-beta.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/classes/api-controller.class.d.ts +4 -4
- package/classes/api-service.class.d.ts +7 -7
- package/classes/disabled-event-bus.class.d.ts +1 -1
- package/classes/domain-event.publisher.d.ts +1 -1
- package/classes/event-bus.registry.d.ts +1 -1
- package/classes/event-transports/event-transport.registry.d.ts +1 -1
- package/classes/event-transports/index.d.ts +2 -2
- package/classes/event-transports/kafka-transport.optional.d.ts +1 -1
- package/classes/event-transports/memory-transport.d.ts +1 -1
- package/classes/event-transports/rabbitmq-transport.optional.d.ts +1 -1
- package/classes/hybrid-event-bus.class.d.ts +1 -1
- package/classes/index.d.ts +11 -11
- package/constants/index.d.ts +2 -2
- package/constants/permissions.d.ts +12 -0
- package/decorators/api-response.decorator.d.ts +1 -1
- package/decorators/current-user.decorator.d.ts +1 -1
- package/decorators/index.d.ts +6 -6
- package/decorators/require-permission.decorator.d.ts +1 -1
- package/dtos/filter-and-pagination.dto.d.ts +1 -1
- package/dtos/index.d.ts +6 -6
- package/entities/index.d.ts +3 -3
- package/enums/index.d.ts +3 -3
- package/exceptions/index.d.ts +2 -2
- package/fesm/470.js +2713 -0
- package/fesm/509.js +793 -0
- package/fesm/667.js +606 -0
- package/fesm/67.js +808 -0
- package/fesm/720.js +914 -0
- package/{cjs/classes/event-transports/rabbitmq-transport.optional.js → fesm/chunks/123.js} +78 -55
- package/fesm/{classes/event-transports/kafka-transport.optional.js → chunks/37.js} +74 -41
- package/fesm/classes/index.js +62 -12
- package/fesm/constants/index.js +445 -17
- package/fesm/decorators/index.js +341 -6
- package/fesm/dtos/index.js +23 -6
- package/fesm/entities/index.js +336 -3
- package/fesm/enums/index.js +57 -3
- package/fesm/exceptions/index.js +280 -2
- package/fesm/guards/index.js +1003 -3
- package/fesm/index.js +1524 -14
- package/fesm/interceptors/index.js +924 -5
- package/fesm/interfaces/index.js +57 -11
- package/fesm/middlewares/index.js +33 -1
- package/fesm/modules/index.js +432 -9
- package/fesm/runtime.js +134 -0
- package/fesm/utils/index.js +1045 -8
- package/filters/global-exception.filter.d.ts +1 -1
- package/filters/index.d.ts +1 -1
- package/guards/index.d.ts +3 -3
- package/guards/jwt-auth.guard.d.ts +1 -1
- package/guards/optional-jwt-auth.guard.d.ts +1 -1
- package/guards/permission.guard.d.ts +2 -2
- package/index.d.ts +14 -14
- package/interceptors/delete-empty-id-from-body.interceptor.d.ts +1 -1
- package/interceptors/idempotency.interceptor.d.ts +2 -2
- package/interceptors/index.d.ts +5 -5
- package/interceptors/response-meta.interceptor.d.ts +1 -1
- package/interceptors/set-user-field-on-body.interceptor.d.ts +1 -1
- package/interceptors/slug.interceptor.d.ts +2 -2
- package/interfaces/ai-assistant-adapter.interface.d.ts +1 -1
- package/interfaces/api.interface.d.ts +2 -2
- package/interfaces/datasource.interface.d.ts +1 -1
- package/interfaces/event-manager-adapter.interface.d.ts +2 -2
- package/interfaces/index.d.ts +11 -11
- package/interfaces/module-config.interface.d.ts +1 -1
- package/interfaces/notification-adapter.interface.d.ts +1 -1
- package/middlewares/index.d.ts +1 -1
- package/middlewares/logger.middleware.d.ts +2 -2
- package/modules/cache/cache.module.d.ts +1 -1
- package/modules/datasource/index.d.ts +1 -1
- package/modules/datasource/multi-tenant-datasource.service.d.ts +4 -4
- package/modules/event-bus/event-bus.explorer.d.ts +2 -2
- package/modules/event-bus/event-bus.module.d.ts +2 -2
- package/modules/event-bus/module-events.provider.d.ts +1 -1
- package/modules/index.d.ts +9 -9
- package/modules/shared-permission-cache/shared-permission-cache.service.d.ts +3 -3
- package/modules/utils/utils.service.d.ts +1 -1
- package/package.json +30 -44
- package/utils/index.d.ts +8 -8
- package/utils/permission-cache-key.util.d.ts +1 -1
- package/utils/query-helpers.util.d.ts +2 -2
- package/utils/request.util.d.ts +1 -1
- package/cjs/classes/api-controller.class.js +0 -728
- package/cjs/classes/api-controller.class.spec.js +0 -684
- package/cjs/classes/api-service.class.js +0 -631
- package/cjs/classes/api-service.class.spec.js +0 -1137
- package/cjs/classes/disabled-event-bus.class.js +0 -15
- package/cjs/classes/disabled-event-bus.class.spec.js +0 -40
- package/cjs/classes/domain-event.publisher.js +0 -76
- package/cjs/classes/domain-event.publisher.spec.js +0 -234
- package/cjs/classes/event-bus.registry.js +0 -68
- package/cjs/classes/event-bus.registry.spec.js +0 -141
- package/cjs/classes/event-transports/event-transport.registry.js +0 -41
- package/cjs/classes/event-transports/event-transport.registry.spec.js +0 -31
- package/cjs/classes/event-transports/index.js +0 -23
- package/cjs/classes/event-transports/kafka-transport.optional.js +0 -151
- package/cjs/classes/event-transports/kafka-transport.optional.spec.js +0 -198
- package/cjs/classes/event-transports/memory-transport.js +0 -53
- package/cjs/classes/event-transports/memory-transport.spec.js +0 -57
- package/cjs/classes/event-transports/rabbitmq-transport.optional.spec.js +0 -255
- package/cjs/classes/handle-custome-db.js +0 -37
- package/cjs/classes/handle-custome-db.spec.js +0 -82
- package/cjs/classes/hybrid-cache.class.js +0 -96
- package/cjs/classes/hybrid-cache.class.spec.js +0 -168
- package/cjs/classes/hybrid-event-bus.class.js +0 -281
- package/cjs/classes/hybrid-event-bus.class.spec.js +0 -218
- package/cjs/classes/index.js +0 -28
- package/cjs/classes/winston.logger.class.js +0 -274
- package/cjs/classes/winston.logger.class.spec.js +0 -330
- package/cjs/constants/index.js +0 -88
- package/cjs/constants/message-keys.js +0 -68
- package/cjs/constants/permissions.js +0 -297
- package/cjs/decorators/api-response.decorator.js +0 -52
- package/cjs/decorators/api-response.decorator.spec.js +0 -126
- package/cjs/decorators/current-user.decorator.js +0 -16
- package/cjs/decorators/current-user.decorator.spec.js +0 -74
- package/cjs/decorators/index.js +0 -23
- package/cjs/decorators/log-action.decorator.js +0 -149
- package/cjs/decorators/log-action.decorator.spec.js +0 -353
- package/cjs/decorators/on-domain-event.decorator.js +0 -13
- package/cjs/decorators/on-domain-event.decorator.spec.js +0 -50
- package/cjs/decorators/public.decorator.js +0 -13
- package/cjs/decorators/public.decorator.spec.js +0 -50
- package/cjs/decorators/require-permission.decorator.js +0 -32
- package/cjs/decorators/require-permission.decorator.spec.js +0 -147
- package/cjs/dtos/delete.dto.js +0 -92
- package/cjs/dtos/filter-and-pagination.dto.js +0 -164
- package/cjs/dtos/get-by-ids.dto.js +0 -65
- package/cjs/dtos/identity-response.dto.js +0 -108
- package/cjs/dtos/index.js +0 -23
- package/cjs/dtos/pagination.dto.js +0 -67
- package/cjs/dtos/response-payload.dto.js +0 -369
- package/cjs/entities/identity.js +0 -100
- package/cjs/entities/index.js +0 -20
- package/cjs/entities/raw-type.js +0 -4
- package/cjs/entities/user-root.js +0 -189
- package/cjs/enums/index.js +0 -20
- package/cjs/enums/notification-type.enum.js +0 -17
- package/cjs/enums/participant-status.enum.js +0 -17
- package/cjs/enums/recurrence-type.enum.js +0 -18
- package/cjs/exceptions/base-app.exception.js +0 -151
- package/cjs/exceptions/base-app.exception.spec.js +0 -157
- package/cjs/exceptions/index.js +0 -19
- package/cjs/exceptions/permission.exception.js +0 -56
- package/cjs/exceptions/permission.exception.spec.js +0 -82
- package/cjs/filters/global-exception.filter.js +0 -279
- package/cjs/filters/global-exception.filter.spec.js +0 -440
- package/cjs/filters/index.js +0 -18
- package/cjs/guards/index.js +0 -20
- package/cjs/guards/jwt-auth.guard.js +0 -75
- package/cjs/guards/jwt-auth.guard.spec.js +0 -75
- package/cjs/guards/optional-jwt-auth.guard.js +0 -67
- package/cjs/guards/optional-jwt-auth.guard.spec.js +0 -55
- package/cjs/guards/permission.guard.js +0 -179
- package/cjs/guards/permission.guard.spec.js +0 -373
- package/cjs/index.js +0 -31
- package/cjs/interceptors/delete-empty-id-from-body.interceptor.js +0 -40
- package/cjs/interceptors/delete-empty-id-from-body.interceptor.spec.js +0 -107
- package/cjs/interceptors/idempotency.interceptor.js +0 -96
- package/cjs/interceptors/idempotency.interceptor.spec.js +0 -116
- package/cjs/interceptors/index.js +0 -22
- package/cjs/interceptors/response-meta.interceptor.js +0 -47
- package/cjs/interceptors/response-meta.interceptor.spec.js +0 -89
- package/cjs/interceptors/set-user-field-on-body.interceptor.js +0 -60
- package/cjs/interceptors/set-user-field-on-body.interceptor.spec.js +0 -128
- package/cjs/interceptors/slug.interceptor.js +0 -75
- package/cjs/interceptors/slug.interceptor.spec.js +0 -110
- package/cjs/interfaces/ai-assistant-adapter.interface.js +0 -24
- package/cjs/interfaces/api.interface.js +0 -4
- package/cjs/interfaces/datasource.interface.js +0 -4
- package/cjs/interfaces/event-bus.interface.js +0 -4
- package/cjs/interfaces/event-manager-adapter.interface.js +0 -11
- package/cjs/interfaces/identity.interface.js +0 -4
- package/cjs/interfaces/index.js +0 -28
- package/cjs/interfaces/logged-user-info.interface.js +0 -6
- package/cjs/interfaces/module-config.interface.js +0 -4
- package/cjs/interfaces/notification-adapter.interface.js +0 -11
- package/cjs/interfaces/permission-sync-adapter.interface.js +0 -11
- package/cjs/interfaces/permission.interface.js +0 -4
- package/cjs/middlewares/index.js +0 -18
- package/cjs/middlewares/logger.middleware.js +0 -264
- package/cjs/middlewares/logger.middleware.spec.js +0 -462
- package/cjs/modules/cache/cache.module.js +0 -39
- package/cjs/modules/cache/cache.module.spec.js +0 -48
- package/cjs/modules/datasource/index.js +0 -18
- package/cjs/modules/datasource/multi-tenant-datasource.service.js +0 -222
- package/cjs/modules/datasource/multi-tenant-datasource.service.spec.js +0 -381
- package/cjs/modules/event-bus/event-bus.explorer.js +0 -124
- package/cjs/modules/event-bus/event-bus.explorer.spec.js +0 -189
- package/cjs/modules/event-bus/event-bus.integration.spec.js +0 -253
- package/cjs/modules/event-bus/event-bus.module.js +0 -94
- package/cjs/modules/event-bus/event-bus.module.spec.js +0 -149
- package/cjs/modules/event-bus/module-events.provider.js +0 -39
- package/cjs/modules/event-bus/module-events.provider.spec.js +0 -56
- package/cjs/modules/index.js +0 -26
- package/cjs/modules/shared-permission-cache/shared-permission-cache.module.js +0 -32
- package/cjs/modules/shared-permission-cache/shared-permission-cache.service.js +0 -101
- package/cjs/modules/shared-permission-cache/shared-permission-cache.service.spec.js +0 -165
- package/cjs/modules/utils/utils.module.js +0 -32
- package/cjs/modules/utils/utils.service.js +0 -76
- package/cjs/modules/utils/utils.service.spec.js +0 -169
- package/cjs/utils/date-time.util.js +0 -94
- package/cjs/utils/date-time.util.spec.js +0 -84
- package/cjs/utils/event-pattern.util.js +0 -103
- package/cjs/utils/event-pattern.util.spec.js +0 -251
- package/cjs/utils/html-sanitizer.util.js +0 -64
- package/cjs/utils/html-sanitizer.util.spec.js +0 -76
- package/cjs/utils/index.js +0 -25
- package/cjs/utils/optional-module.util.js +0 -35
- package/cjs/utils/optional-module.util.spec.js +0 -14
- package/cjs/utils/permission-cache-key.util.js +0 -31
- package/cjs/utils/permission-cache-key.util.spec.js +0 -88
- package/cjs/utils/query-helpers.util.js +0 -60
- package/cjs/utils/query-helpers.util.spec.js +0 -209
- package/cjs/utils/request.util.js +0 -96
- package/cjs/utils/request.util.spec.js +0 -249
- package/cjs/utils/string.util.js +0 -63
- package/cjs/utils/string.util.spec.js +0 -63
- package/fesm/classes/api-controller.class.js +0 -718
- package/fesm/classes/api-controller.class.spec.js +0 -680
- package/fesm/classes/api-service.class.js +0 -621
- package/fesm/classes/api-service.class.spec.js +0 -1133
- package/fesm/classes/disabled-event-bus.class.js +0 -11
- package/fesm/classes/disabled-event-bus.class.spec.js +0 -36
- package/fesm/classes/domain-event.publisher.js +0 -63
- package/fesm/classes/domain-event.publisher.spec.js +0 -230
- package/fesm/classes/event-bus.registry.js +0 -64
- package/fesm/classes/event-bus.registry.spec.js +0 -137
- package/fesm/classes/event-transports/event-transport.registry.js +0 -35
- package/fesm/classes/event-transports/event-transport.registry.spec.js +0 -27
- package/fesm/classes/event-transports/index.js +0 -6
- package/fesm/classes/event-transports/kafka-transport.optional.spec.js +0 -194
- package/fesm/classes/event-transports/memory-transport.js +0 -49
- package/fesm/classes/event-transports/memory-transport.spec.js +0 -53
- package/fesm/classes/event-transports/rabbitmq-transport.optional.js +0 -174
- package/fesm/classes/event-transports/rabbitmq-transport.optional.spec.js +0 -251
- package/fesm/classes/handle-custome-db.js +0 -19
- package/fesm/classes/handle-custome-db.spec.js +0 -78
- package/fesm/classes/hybrid-cache.class.js +0 -81
- package/fesm/classes/hybrid-cache.class.spec.js +0 -164
- package/fesm/classes/hybrid-event-bus.class.js +0 -237
- package/fesm/classes/hybrid-event-bus.class.spec.js +0 -214
- package/fesm/classes/winston.logger.class.js +0 -228
- package/fesm/classes/winston.logger.class.spec.js +0 -327
- package/fesm/constants/message-keys.js +0 -49
- package/fesm/constants/permissions.js +0 -208
- package/fesm/decorators/api-response.decorator.js +0 -42
- package/fesm/decorators/api-response.decorator.spec.js +0 -122
- package/fesm/decorators/current-user.decorator.js +0 -18
- package/fesm/decorators/current-user.decorator.spec.js +0 -73
- package/fesm/decorators/log-action.decorator.js +0 -139
- package/fesm/decorators/log-action.decorator.spec.js +0 -349
- package/fesm/decorators/on-domain-event.decorator.js +0 -10
- package/fesm/decorators/on-domain-event.decorator.spec.js +0 -46
- package/fesm/decorators/public.decorator.js +0 -20
- package/fesm/decorators/public.decorator.spec.js +0 -46
- package/fesm/decorators/require-permission.decorator.js +0 -27
- package/fesm/decorators/require-permission.decorator.spec.js +0 -143
- package/fesm/dtos/delete.dto.js +0 -82
- package/fesm/dtos/filter-and-pagination.dto.js +0 -148
- package/fesm/dtos/get-by-ids.dto.js +0 -55
- package/fesm/dtos/identity-response.dto.js +0 -98
- package/fesm/dtos/pagination.dto.js +0 -57
- package/fesm/dtos/response-payload.dto.js +0 -336
- package/fesm/entities/identity.js +0 -90
- package/fesm/entities/raw-type.js +0 -1
- package/fesm/entities/user-root.js +0 -179
- package/fesm/enums/notification-type.enum.js +0 -7
- package/fesm/enums/participant-status.enum.js +0 -7
- package/fesm/enums/recurrence-type.enum.js +0 -8
- package/fesm/exceptions/base-app.exception.js +0 -115
- package/fesm/exceptions/base-app.exception.spec.js +0 -153
- package/fesm/exceptions/permission.exception.js +0 -35
- package/fesm/exceptions/permission.exception.spec.js +0 -78
- package/fesm/filters/global-exception.filter.js +0 -269
- package/fesm/filters/global-exception.filter.spec.js +0 -436
- package/fesm/filters/index.js +0 -1
- package/fesm/guards/jwt-auth.guard.js +0 -65
- package/fesm/guards/jwt-auth.guard.spec.js +0 -71
- package/fesm/guards/optional-jwt-auth.guard.js +0 -57
- package/fesm/guards/optional-jwt-auth.guard.spec.js +0 -51
- package/fesm/guards/permission.guard.js +0 -169
- package/fesm/guards/permission.guard.spec.js +0 -369
- package/fesm/interceptors/delete-empty-id-from-body.interceptor.js +0 -30
- package/fesm/interceptors/delete-empty-id-from-body.interceptor.spec.js +0 -103
- package/fesm/interceptors/idempotency.interceptor.js +0 -86
- package/fesm/interceptors/idempotency.interceptor.spec.js +0 -112
- package/fesm/interceptors/response-meta.interceptor.js +0 -37
- package/fesm/interceptors/response-meta.interceptor.spec.js +0 -85
- package/fesm/interceptors/set-user-field-on-body.interceptor.js +0 -39
- package/fesm/interceptors/set-user-field-on-body.interceptor.spec.js +0 -124
- package/fesm/interceptors/slug.interceptor.js +0 -65
- package/fesm/interceptors/slug.interceptor.spec.js +0 -106
- package/fesm/interfaces/ai-assistant-adapter.interface.js +0 -3
- package/fesm/interfaces/api.interface.js +0 -1
- package/fesm/interfaces/datasource.interface.js +0 -1
- package/fesm/interfaces/event-bus.interface.js +0 -1
- package/fesm/interfaces/event-manager-adapter.interface.js +0 -1
- package/fesm/interfaces/identity.interface.js +0 -1
- package/fesm/interfaces/logged-user-info.interface.js +0 -3
- package/fesm/interfaces/module-config.interface.js +0 -5
- package/fesm/interfaces/notification-adapter.interface.js +0 -1
- package/fesm/interfaces/permission-sync-adapter.interface.js +0 -1
- package/fesm/interfaces/permission.interface.js +0 -1
- package/fesm/middlewares/logger.middleware.js +0 -235
- package/fesm/middlewares/logger.middleware.spec.js +0 -459
- package/fesm/modules/cache/cache.module.js +0 -29
- package/fesm/modules/cache/cache.module.spec.js +0 -44
- package/fesm/modules/datasource/index.js +0 -1
- package/fesm/modules/datasource/multi-tenant-datasource.service.js +0 -212
- package/fesm/modules/datasource/multi-tenant-datasource.service.spec.js +0 -377
- package/fesm/modules/event-bus/event-bus.explorer.js +0 -114
- package/fesm/modules/event-bus/event-bus.explorer.spec.js +0 -185
- package/fesm/modules/event-bus/event-bus.integration.spec.js +0 -249
- package/fesm/modules/event-bus/event-bus.module.js +0 -84
- package/fesm/modules/event-bus/event-bus.module.spec.js +0 -145
- package/fesm/modules/event-bus/module-events.provider.js +0 -26
- package/fesm/modules/event-bus/module-events.provider.spec.js +0 -52
- package/fesm/modules/shared-permission-cache/shared-permission-cache.module.js +0 -22
- package/fesm/modules/shared-permission-cache/shared-permission-cache.service.js +0 -91
- package/fesm/modules/shared-permission-cache/shared-permission-cache.service.spec.js +0 -161
- package/fesm/modules/utils/utils.module.js +0 -22
- package/fesm/modules/utils/utils.service.js +0 -66
- package/fesm/modules/utils/utils.service.spec.js +0 -165
- package/fesm/utils/date-time.util.js +0 -70
- package/fesm/utils/date-time.util.spec.js +0 -80
- package/fesm/utils/event-pattern.util.js +0 -91
- package/fesm/utils/event-pattern.util.spec.js +0 -247
- package/fesm/utils/html-sanitizer.util.js +0 -69
- package/fesm/utils/html-sanitizer.util.spec.js +0 -72
- package/fesm/utils/optional-module.util.js +0 -25
- package/fesm/utils/optional-module.util.spec.js +0 -10
- package/fesm/utils/permission-cache-key.util.js +0 -10
- package/fesm/utils/permission-cache-key.util.spec.js +0 -84
- package/fesm/utils/query-helpers.util.js +0 -85
- package/fesm/utils/query-helpers.util.spec.js +0 -205
- package/fesm/utils/request.util.js +0 -81
- package/fesm/utils/request.util.spec.js +0 -245
- package/fesm/utils/string.util.js +0 -71
- package/fesm/utils/string.util.spec.js +0 -59
package/fesm/720.js
ADDED
|
@@ -0,0 +1,914 @@
|
|
|
1
|
+
import * as __rspack_external_winston_daily_rotate_file_d74f2d27 from "winston-daily-rotate-file";
|
|
2
|
+
import * as __rspack_external_winston_transport_f7e85261 from "winston-transport";
|
|
3
|
+
import * as __rspack_external__flusys_nestjs_core_config_197fa0a9 from "@flusys/nestjs-core/config";
|
|
4
|
+
import * as __rspack_external__nestjs_common_a04939da from "@nestjs/common";
|
|
5
|
+
import * as __rspack_external_fs from "fs";
|
|
6
|
+
import * as __rspack_external_path from "path";
|
|
7
|
+
import * as __rspack_external_winston from "winston";
|
|
8
|
+
import * as __rspack_external_async_hooks from "async_hooks";
|
|
9
|
+
import * as __rspack_external_uuid from "uuid";
|
|
10
|
+
export const __rspack_esm_id = 720;
|
|
11
|
+
export const __rspack_esm_ids = [720];
|
|
12
|
+
export const __webpack_modules__ = {
|
|
13
|
+
245(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
14
|
+
|
|
15
|
+
// EXPORTS
|
|
16
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
17
|
+
X: () => (/* binding */ createModuleLogger),
|
|
18
|
+
K: () => (/* binding */ instance)
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-core/config"
|
|
22
|
+
var config_ = __webpack_require__(307);
|
|
23
|
+
;// CONCATENATED MODULE: external "fs"
|
|
24
|
+
|
|
25
|
+
;// CONCATENATED MODULE: external "path"
|
|
26
|
+
|
|
27
|
+
;// CONCATENATED MODULE: external "winston"
|
|
28
|
+
|
|
29
|
+
;// CONCATENATED MODULE: external "winston-daily-rotate-file"
|
|
30
|
+
|
|
31
|
+
;// CONCATENATED MODULE: external "winston-transport"
|
|
32
|
+
|
|
33
|
+
;// CONCATENATED MODULE: ./projects/nestjs-shared/src/classes/winston.logger.class.ts
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// Handle both webpack (no default export) and esbuild (default export)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const Transport = __rspack_external_winston_transport_f7e85261["default"] || __rspack_external_winston_transport_f7e85261;
|
|
42
|
+
const DailyRotateFile = __rspack_external_winston_daily_rotate_file_d74f2d27["default"] || __rspack_external_winston_daily_rotate_file_d74f2d27;
|
|
43
|
+
// Configuration
|
|
44
|
+
const logConfig = config_.envConfig.getLogConfig();
|
|
45
|
+
const LOG_DIR = logConfig.dir;
|
|
46
|
+
const LOG_LEVEL = logConfig.level;
|
|
47
|
+
const LOG_MAX_SIZE = logConfig.maxSize;
|
|
48
|
+
const LOG_MAX_FILES = logConfig.maxFiles;
|
|
49
|
+
const USE_TENANT_MODE = config_.envConfig.useTenantMode();
|
|
50
|
+
// Ensure logs directory exists
|
|
51
|
+
if (!(0,__rspack_external_fs.existsSync)(LOG_DIR)) {
|
|
52
|
+
(0,__rspack_external_fs.mkdirSync)(LOG_DIR, {
|
|
53
|
+
recursive: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// Custom Formats
|
|
57
|
+
/**
|
|
58
|
+
* Custom format for structured logging (production)
|
|
59
|
+
* Multi-line format:
|
|
60
|
+
* - Line 1: Timestamp
|
|
61
|
+
* - Line 2: Log Level
|
|
62
|
+
* - Line 3: [RequestId]
|
|
63
|
+
* - Line 4: Empty
|
|
64
|
+
* - Line 5+: Message with context
|
|
65
|
+
*/ const LEVEL_MAP = {
|
|
66
|
+
error: 'Error',
|
|
67
|
+
warn: 'Warning',
|
|
68
|
+
info: 'Information',
|
|
69
|
+
debug: 'Debug',
|
|
70
|
+
verbose: 'Verbose'
|
|
71
|
+
};
|
|
72
|
+
const LOG_SEPARATOR = '─'.repeat(80);
|
|
73
|
+
const structuredFormat = __rspack_external_winston.format.printf(({ timestamp, level, message, context, requestId, userId, tenantId, companyId, method, url, path, statusCode, duration, stack, ...metadata })=>{
|
|
74
|
+
const reqId = requestId || 'no-request-id';
|
|
75
|
+
const levelFormatted = LEVEL_MAP[level] || level.charAt(0).toUpperCase() + level.slice(1);
|
|
76
|
+
const contextParts = [];
|
|
77
|
+
if (context) contextParts.push(`Context: ${context}`);
|
|
78
|
+
if (method && (path || url)) contextParts.push(`Endpoint: ${method} ${path || url}`);
|
|
79
|
+
if (statusCode) contextParts.push(`Status: ${statusCode}`);
|
|
80
|
+
if (duration) contextParts.push(`Duration: ${duration}`);
|
|
81
|
+
if (userId) contextParts.push(`UserId: ${userId}`);
|
|
82
|
+
if (tenantId) contextParts.push(`TenantId: ${tenantId}`);
|
|
83
|
+
if (companyId) contextParts.push(`CompanyId: ${companyId}`);
|
|
84
|
+
let content = message;
|
|
85
|
+
if (contextParts.length > 0) {
|
|
86
|
+
content = `${contextParts.join(' | ')}\n${message}`;
|
|
87
|
+
}
|
|
88
|
+
const metaKeys = Object.keys(metadata).filter((k)=>k !== 'splat');
|
|
89
|
+
if (metaKeys.length > 0) {
|
|
90
|
+
const metaStr = JSON.stringify(metaKeys.reduce((acc, k)=>({
|
|
91
|
+
...acc,
|
|
92
|
+
[k]: metadata[k]
|
|
93
|
+
}), {}));
|
|
94
|
+
content += `\nMetadata: ${metaStr}`;
|
|
95
|
+
}
|
|
96
|
+
if (stack) {
|
|
97
|
+
content += `\nStack: ${stack}`;
|
|
98
|
+
}
|
|
99
|
+
return `${LOG_SEPARATOR}\n${timestamp} | ${levelFormatted} | [${reqId}]\n${content}`;
|
|
100
|
+
});
|
|
101
|
+
// Transports
|
|
102
|
+
/**
|
|
103
|
+
* Daily rotating file transport for all logs
|
|
104
|
+
*/ const combinedRotateTransport = new DailyRotateFile({
|
|
105
|
+
filename: `${LOG_DIR}/combined-%DATE%.log`,
|
|
106
|
+
datePattern: 'YYYY-MM-DD',
|
|
107
|
+
zippedArchive: true,
|
|
108
|
+
maxSize: LOG_MAX_SIZE,
|
|
109
|
+
maxFiles: LOG_MAX_FILES,
|
|
110
|
+
level: LOG_LEVEL
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* Daily rotating file transport for error logs only
|
|
114
|
+
*/ const errorRotateTransport = new DailyRotateFile({
|
|
115
|
+
filename: `${LOG_DIR}/error-%DATE%.log`,
|
|
116
|
+
datePattern: 'YYYY-MM-DD',
|
|
117
|
+
zippedArchive: true,
|
|
118
|
+
maxSize: LOG_MAX_SIZE,
|
|
119
|
+
maxFiles: LOG_MAX_FILES,
|
|
120
|
+
level: 'error'
|
|
121
|
+
});
|
|
122
|
+
// Transport Caches
|
|
123
|
+
const moduleTransportCache = new Map();
|
|
124
|
+
const tenantTransportCache = new Map();
|
|
125
|
+
function getCachedTransport(cache, name) {
|
|
126
|
+
const cached = cache.get(name);
|
|
127
|
+
if (cached) return cached;
|
|
128
|
+
const logDir = (0,__rspack_external_path.join)(LOG_DIR, name);
|
|
129
|
+
if (!(0,__rspack_external_fs.existsSync)(logDir)) {
|
|
130
|
+
(0,__rspack_external_fs.mkdirSync)(logDir, {
|
|
131
|
+
recursive: true
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const transport = new DailyRotateFile({
|
|
135
|
+
filename: `${logDir}/combined-%DATE%.log`,
|
|
136
|
+
datePattern: 'YYYY-MM-DD',
|
|
137
|
+
zippedArchive: true,
|
|
138
|
+
maxSize: LOG_MAX_SIZE,
|
|
139
|
+
maxFiles: LOG_MAX_FILES,
|
|
140
|
+
level: LOG_LEVEL
|
|
141
|
+
});
|
|
142
|
+
cache.set(name, transport);
|
|
143
|
+
return transport;
|
|
144
|
+
}
|
|
145
|
+
const getModuleTransport = (name)=>getCachedTransport(moduleTransportCache, name);
|
|
146
|
+
const getTenantTransport = (name)=>getCachedTransport(tenantTransportCache, name);
|
|
147
|
+
let winston_logger_class_TenantAwareTransport = class TenantAwareTransport extends Transport {
|
|
148
|
+
defaultTransport;
|
|
149
|
+
constructor(defaultTransport){
|
|
150
|
+
super(), this.defaultTransport = defaultTransport;
|
|
151
|
+
}
|
|
152
|
+
log(info, callback) {
|
|
153
|
+
setImmediate(()=>this.emit('logged', info));
|
|
154
|
+
const tenantId = info.tenantId || info.metadata?.tenantId;
|
|
155
|
+
const transport = USE_TENANT_MODE && tenantId ? getTenantTransport(tenantId) : this.defaultTransport;
|
|
156
|
+
transport.log(info, callback);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const tenantAwareCombinedTransport = new winston_logger_class_TenantAwareTransport(combinedRotateTransport);
|
|
160
|
+
const consoleTransport = new __rspack_external_winston.transports.Console({
|
|
161
|
+
level: LOG_LEVEL,
|
|
162
|
+
format: __rspack_external_winston.format.combine(__rspack_external_winston.format.colorize({
|
|
163
|
+
all: true
|
|
164
|
+
}), __rspack_external_winston.format.timestamp({
|
|
165
|
+
format: 'YYYY-MM-DD HH:mm:ss'
|
|
166
|
+
}), __rspack_external_winston.format.errors({
|
|
167
|
+
stack: true
|
|
168
|
+
}), structuredFormat)
|
|
169
|
+
});
|
|
170
|
+
// Logger Instances
|
|
171
|
+
/**
|
|
172
|
+
* Development logger configuration
|
|
173
|
+
* - Console output with colors
|
|
174
|
+
* - Human-readable format
|
|
175
|
+
* - Debug level by default
|
|
176
|
+
*/ const devLogger = (0,__rspack_external_winston.createLogger)({
|
|
177
|
+
level: LOG_LEVEL,
|
|
178
|
+
format: __rspack_external_winston.format.combine(__rspack_external_winston.format.timestamp({
|
|
179
|
+
format: 'YYYY-MM-DD HH:mm:ss'
|
|
180
|
+
}), __rspack_external_winston.format.errors({
|
|
181
|
+
stack: true
|
|
182
|
+
})),
|
|
183
|
+
transports: [
|
|
184
|
+
consoleTransport
|
|
185
|
+
],
|
|
186
|
+
exitOnError: false
|
|
187
|
+
});
|
|
188
|
+
/**
|
|
189
|
+
* Production logger configuration
|
|
190
|
+
* - File-based logging with rotation
|
|
191
|
+
* - JSON structured format
|
|
192
|
+
* - Separate error log file
|
|
193
|
+
* - Compressed old logs
|
|
194
|
+
* - Tenant-aware routing (when USE_TENANT_MODE=true)
|
|
195
|
+
*/ const prodLogger = (0,__rspack_external_winston.createLogger)({
|
|
196
|
+
level: LOG_LEVEL,
|
|
197
|
+
format: __rspack_external_winston.format.combine(__rspack_external_winston.format.timestamp({
|
|
198
|
+
format: 'YYYY-MM-DD HH:mm:ss.SSS'
|
|
199
|
+
}), __rspack_external_winston.format.errors({
|
|
200
|
+
stack: true
|
|
201
|
+
}), structuredFormat),
|
|
202
|
+
transports: [
|
|
203
|
+
tenantAwareCombinedTransport,
|
|
204
|
+
errorRotateTransport
|
|
205
|
+
],
|
|
206
|
+
exitOnError: false
|
|
207
|
+
});
|
|
208
|
+
// Exports
|
|
209
|
+
/**
|
|
210
|
+
* Winston logger instance (global)
|
|
211
|
+
* - DEV: Console output with colors
|
|
212
|
+
* - PROD: File-based with daily rotation, tenant-aware routing
|
|
213
|
+
*/ const instance = config_.envConfig.isProduction() ? prodLogger : devLogger;
|
|
214
|
+
/**
|
|
215
|
+
* Module logger cache to avoid creating multiple loggers for the same module
|
|
216
|
+
*/ const moduleLoggerCache = new Map();
|
|
217
|
+
/**
|
|
218
|
+
* Create a module-specific logger instance
|
|
219
|
+
* - DEV: Console output (same as global)
|
|
220
|
+
* - PROD: File-based with module-specific folder + shared error log
|
|
221
|
+
*
|
|
222
|
+
* @param moduleName - The module name (e.g., 'auth', 'iam', 'storage')
|
|
223
|
+
* @returns Logger instance for the module
|
|
224
|
+
*/ function createModuleLogger(moduleName) {
|
|
225
|
+
// In dev mode, use global console logger
|
|
226
|
+
if (!config_.envConfig.isProduction()) {
|
|
227
|
+
return devLogger;
|
|
228
|
+
}
|
|
229
|
+
// Check cache first
|
|
230
|
+
if (moduleLoggerCache.has(moduleName)) {
|
|
231
|
+
return moduleLoggerCache.get(moduleName);
|
|
232
|
+
}
|
|
233
|
+
// Create module-specific logger for production
|
|
234
|
+
const moduleLogger = (0,__rspack_external_winston.createLogger)({
|
|
235
|
+
level: LOG_LEVEL,
|
|
236
|
+
format: __rspack_external_winston.format.combine(__rspack_external_winston.format.timestamp({
|
|
237
|
+
format: 'YYYY-MM-DD HH:mm:ss.SSS'
|
|
238
|
+
}), __rspack_external_winston.format.errors({
|
|
239
|
+
stack: true
|
|
240
|
+
}), structuredFormat),
|
|
241
|
+
transports: [
|
|
242
|
+
getModuleTransport(moduleName),
|
|
243
|
+
errorRotateTransport
|
|
244
|
+
],
|
|
245
|
+
exitOnError: false
|
|
246
|
+
});
|
|
247
|
+
moduleLoggerCache.set(moduleName, moduleLogger);
|
|
248
|
+
return moduleLogger;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
},
|
|
253
|
+
43(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
254
|
+
/* import */ var _permissions_js__rspack_import_0 = __webpack_require__(975);
|
|
255
|
+
/* import */ var _message_keys_js__rspack_import_1 = __webpack_require__(389);
|
|
256
|
+
// Metadata keys
|
|
257
|
+
const IS_PUBLIC_KEY = 'isPublic';
|
|
258
|
+
const PERMISSIONS_KEY = 'permissions';
|
|
259
|
+
const DOMAIN_EVENT_HANDLER_KEY = 'domainEventHandler';
|
|
260
|
+
// Injection tokens
|
|
261
|
+
const CACHE_INSTANCE = 'CACHE_INSTANCE';
|
|
262
|
+
const PERMISSION_GUARD_CONFIG = 'PERMISSION_GUARD_CONFIG';
|
|
263
|
+
const EVENT_BUS_INSTANCE = 'EVENT_BUS_INSTANCE';
|
|
264
|
+
const EVENT_BUS_MODULE_OPTIONS = 'EVENT_BUS_MODULE_OPTIONS';
|
|
265
|
+
// Header names
|
|
266
|
+
const IDEMPOTENCY_KEY_HEADER = 'x-idempotency-key';
|
|
267
|
+
const REQUEST_ID_HEADER = 'x-request-id';
|
|
268
|
+
const CLIENT_TYPE_HEADER = 'x-client-type';
|
|
269
|
+
// Cache key prefixes
|
|
270
|
+
const PERMISSIONS_CACHE_PREFIX = 'my-permissions';
|
|
271
|
+
const IDEMPOTENCY_CACHE_PREFIX = 'idempotency';
|
|
272
|
+
// Event bus defaults
|
|
273
|
+
const DEFAULT_EVENT_EXCHANGE = 'flusys.events';
|
|
274
|
+
const DEFAULT_EVENT_TOPIC = 'flusys.domain-events';
|
|
275
|
+
const DEFAULT_EVENT_SERVICE_NAME = 'flusys';
|
|
276
|
+
// Permission codes
|
|
277
|
+
|
|
278
|
+
// Message keys for localization
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
282
|
+
BC: () => (/* reexport safe */ _permissions_js__rspack_import_0.BC),
|
|
283
|
+
Bz: () => (/* reexport safe */ _permissions_js__rspack_import_0.Bz),
|
|
284
|
+
Em: () => (/* reexport safe */ _permissions_js__rspack_import_0.Em),
|
|
285
|
+
GT: () => (/* reexport safe */ _permissions_js__rspack_import_0.GT),
|
|
286
|
+
Jj: () => (/* reexport safe */ _permissions_js__rspack_import_0.Jj),
|
|
287
|
+
N3: () => (/* reexport safe */ _permissions_js__rspack_import_0.N3),
|
|
288
|
+
ON: () => (/* reexport safe */ _permissions_js__rspack_import_0.ON),
|
|
289
|
+
P0: () => (/* reexport safe */ _permissions_js__rspack_import_0.P0),
|
|
290
|
+
Q5: () => (/* reexport safe */ _permissions_js__rspack_import_0.Q5),
|
|
291
|
+
S6: () => (/* reexport safe */ _permissions_js__rspack_import_0.S6),
|
|
292
|
+
T: () => (/* reexport safe */ _permissions_js__rspack_import_0.T),
|
|
293
|
+
UB: () => (/* reexport safe */ _permissions_js__rspack_import_0.UB),
|
|
294
|
+
UG: () => (/* reexport safe */ _permissions_js__rspack_import_0.UG),
|
|
295
|
+
UU: () => (/* reexport safe */ _message_keys_js__rspack_import_1.UU),
|
|
296
|
+
Ub: () => (/* reexport safe */ _permissions_js__rspack_import_0.Ub),
|
|
297
|
+
V0: () => (/* reexport safe */ _permissions_js__rspack_import_0.V0),
|
|
298
|
+
Wc: () => (/* reexport safe */ _permissions_js__rspack_import_0.Wc),
|
|
299
|
+
Y3: () => (/* reexport safe */ _permissions_js__rspack_import_0.Y3),
|
|
300
|
+
Y7: () => (/* reexport safe */ _permissions_js__rspack_import_0.Y7),
|
|
301
|
+
_X: () => (/* reexport safe */ _permissions_js__rspack_import_0._X),
|
|
302
|
+
aO: () => (/* reexport safe */ _permissions_js__rspack_import_0.aO),
|
|
303
|
+
fS: () => (/* reexport safe */ _permissions_js__rspack_import_0.fS),
|
|
304
|
+
hg: () => (/* reexport safe */ _message_keys_js__rspack_import_1.hg),
|
|
305
|
+
l3: () => (/* reexport safe */ _permissions_js__rspack_import_0.l3),
|
|
306
|
+
mK: () => (/* reexport safe */ _message_keys_js__rspack_import_1.mK),
|
|
307
|
+
mV: () => (/* reexport safe */ _permissions_js__rspack_import_0.mV),
|
|
308
|
+
rH: () => (/* reexport safe */ _permissions_js__rspack_import_0.rH),
|
|
309
|
+
t$: () => (/* reexport safe */ _permissions_js__rspack_import_0.t$),
|
|
310
|
+
w7: () => (/* reexport safe */ _permissions_js__rspack_import_0.w7),
|
|
311
|
+
wA: () => (/* reexport safe */ _permissions_js__rspack_import_0.wA),
|
|
312
|
+
wM: () => (/* reexport safe */ _permissions_js__rspack_import_0.wM),
|
|
313
|
+
z$: () => (/* reexport safe */ _permissions_js__rspack_import_0.z$),
|
|
314
|
+
zd: () => (/* reexport safe */ _permissions_js__rspack_import_0.zd)
|
|
315
|
+
}, {
|
|
316
|
+
Hq: DEFAULT_EVENT_EXCHANGE,
|
|
317
|
+
Lw: PERMISSION_GUARD_CONFIG,
|
|
318
|
+
N7: PERMISSIONS_KEY,
|
|
319
|
+
PT: DOMAIN_EVENT_HANDLER_KEY,
|
|
320
|
+
Qj: EVENT_BUS_INSTANCE,
|
|
321
|
+
SL: EVENT_BUS_MODULE_OPTIONS,
|
|
322
|
+
fG: PERMISSIONS_CACHE_PREFIX,
|
|
323
|
+
iH: IDEMPOTENCY_KEY_HEADER,
|
|
324
|
+
jA: IS_PUBLIC_KEY,
|
|
325
|
+
kC: REQUEST_ID_HEADER,
|
|
326
|
+
mg: IDEMPOTENCY_CACHE_PREFIX,
|
|
327
|
+
nx: DEFAULT_EVENT_TOPIC,
|
|
328
|
+
xw: CLIENT_TYPE_HEADER,
|
|
329
|
+
zl: CACHE_INSTANCE
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
},
|
|
334
|
+
389(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
335
|
+
// ==================== AUTH (Shared across guards/interceptors) ====================
|
|
336
|
+
// These are duplicated in nestjs-auth but needed here to avoid circular dependencies
|
|
337
|
+
const AUTH_MESSAGES = {
|
|
338
|
+
TOKEN_REQUIRED: 'auth.token.required',
|
|
339
|
+
TOKEN_INVALID: 'auth.token.invalid',
|
|
340
|
+
ENTITY_BELOG_ANOTHER_COMPANY: 'entity.belongs.another.company',
|
|
341
|
+
COMPANY_NO_ACCESS: 'auth.company.no.access'
|
|
342
|
+
};
|
|
343
|
+
// ==================== ERROR (HTTP Exceptions) ====================
|
|
344
|
+
const ERROR_MESSAGES = {
|
|
345
|
+
NOT_FOUND: 'error.not.found',
|
|
346
|
+
VALIDATION: 'error.validation',
|
|
347
|
+
UNAUTHORIZED: 'error.unauthorized',
|
|
348
|
+
FORBIDDEN: 'error.forbidden',
|
|
349
|
+
CONFLICT: 'error.conflict',
|
|
350
|
+
DB_FOREIGN_KEY: 'error.db.foreign.key',
|
|
351
|
+
DB_NOT_NULL: 'error.db.not.null',
|
|
352
|
+
DB_INVALID_INPUT: 'error.db.invalid.input',
|
|
353
|
+
DB_VALUE_TOO_LONG: 'error.db.value.too.long',
|
|
354
|
+
DB_CHECK_CONSTRAINT: 'error.db.check.constraint',
|
|
355
|
+
DB_DEADLOCK: 'error.db.deadlock',
|
|
356
|
+
INTERNAL: 'error.internal',
|
|
357
|
+
SERVICE_UNAVAILABLE: 'error.service.unavailable',
|
|
358
|
+
UNKNOWN: 'error.unknown',
|
|
359
|
+
HTTP: 'error.http',
|
|
360
|
+
GENERIC: 'error.generic',
|
|
361
|
+
PERMISSION_SYSTEM_UNAVAILABLE: 'error.permission.system.unavailable',
|
|
362
|
+
INSUFFICIENT_PERMISSIONS: 'error.insufficient.permissions',
|
|
363
|
+
INSUFFICIENT_PERMISSIONS_OR: 'error.insufficient.permissions.or',
|
|
364
|
+
NO_PERMISSIONS_FOUND: 'error.no.permissions.found',
|
|
365
|
+
ENDPOINT_DISABLED: 'error.endpoint.disabled'
|
|
366
|
+
};
|
|
367
|
+
// ==================== SYSTEM (Infrastructure) ====================
|
|
368
|
+
const SYSTEM_MESSAGES = {
|
|
369
|
+
REPOSITORY_NOT_AVAILABLE: 'system.repository.not.available',
|
|
370
|
+
DATASOURCE_NOT_AVAILABLE: 'system.datasource.not.available',
|
|
371
|
+
DATABASE_CONFIG_NOT_AVAILABLE: 'system.database.config.not.available',
|
|
372
|
+
SERVICE_NOT_AVAILABLE: 'system.service.not.available',
|
|
373
|
+
CONFIG_REQUIRED: 'system.config.required',
|
|
374
|
+
INTERNAL_ERROR: 'system.internal.error',
|
|
375
|
+
DUPLICATE_REQUEST: 'system.duplicate.request',
|
|
376
|
+
INVALID_TENANT_ID: 'system.invalid.tenant.id',
|
|
377
|
+
TENANT_NOT_FOUND: 'system.tenant.not.found',
|
|
378
|
+
TENANT_HEADER_REQUIRED: 'system.tenant.header.required',
|
|
379
|
+
MISSING_PARAMETER: 'system.missing.parameter',
|
|
380
|
+
SDK_NOT_INSTALLED: 'system.sdk.not.installed',
|
|
381
|
+
PATH_TRAVERSAL_DETECTED: 'system.path.traversal.detected',
|
|
382
|
+
INVALID_FILE_KEY: 'system.invalid.file.key'
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
386
|
+
}, {
|
|
387
|
+
UU: ERROR_MESSAGES,
|
|
388
|
+
hg: SYSTEM_MESSAGES,
|
|
389
|
+
mK: AUTH_MESSAGES
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
},
|
|
394
|
+
975(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
395
|
+
// ==================== AUTH MODULE ====================
|
|
396
|
+
const USER_PERMISSIONS = {
|
|
397
|
+
CREATE: 'user.create',
|
|
398
|
+
READ: 'user.read',
|
|
399
|
+
UPDATE: 'user.update',
|
|
400
|
+
DELETE: 'user.delete',
|
|
401
|
+
LOOKUP: 'user.lookup'
|
|
402
|
+
};
|
|
403
|
+
const COMPANY_PERMISSIONS = {
|
|
404
|
+
CREATE: 'company.create',
|
|
405
|
+
READ: 'company.read',
|
|
406
|
+
UPDATE: 'company.update',
|
|
407
|
+
DELETE: 'company.delete'
|
|
408
|
+
};
|
|
409
|
+
const BRANCH_PERMISSIONS = {
|
|
410
|
+
CREATE: 'branch.create',
|
|
411
|
+
READ: 'branch.read',
|
|
412
|
+
UPDATE: 'branch.update',
|
|
413
|
+
DELETE: 'branch.delete'
|
|
414
|
+
};
|
|
415
|
+
const SOCIAL_AUTH_CONFIG_PERMISSIONS = {
|
|
416
|
+
CREATE: 'social-config.create',
|
|
417
|
+
READ: 'social-config.read',
|
|
418
|
+
UPDATE: 'social-config.update',
|
|
419
|
+
DELETE: 'social-config.delete'
|
|
420
|
+
};
|
|
421
|
+
// ==================== IAM MODULE ====================
|
|
422
|
+
const ACTION_PERMISSIONS = {
|
|
423
|
+
CREATE: 'action.create',
|
|
424
|
+
READ: 'action.read',
|
|
425
|
+
UPDATE: 'action.update',
|
|
426
|
+
DELETE: 'action.delete'
|
|
427
|
+
};
|
|
428
|
+
const ROLE_PERMISSIONS = {
|
|
429
|
+
CREATE: 'role.create',
|
|
430
|
+
READ: 'role.read',
|
|
431
|
+
UPDATE: 'role.update',
|
|
432
|
+
DELETE: 'role.delete'
|
|
433
|
+
};
|
|
434
|
+
const ROLE_ACTION_PERMISSIONS = {
|
|
435
|
+
READ: 'role-action.read',
|
|
436
|
+
ASSIGN: 'role-action.assign'
|
|
437
|
+
};
|
|
438
|
+
const USER_ROLE_PERMISSIONS = {
|
|
439
|
+
READ: 'user-role.read',
|
|
440
|
+
ASSIGN: 'user-role.assign'
|
|
441
|
+
};
|
|
442
|
+
const USER_ACTION_PERMISSIONS = {
|
|
443
|
+
READ: 'user-action.read',
|
|
444
|
+
ASSIGN: 'user-action.assign'
|
|
445
|
+
};
|
|
446
|
+
const COMPANY_ACTION_PERMISSIONS = {
|
|
447
|
+
READ: 'company-action.read',
|
|
448
|
+
ASSIGN: 'company-action.assign'
|
|
449
|
+
};
|
|
450
|
+
// ==================== STORAGE MODULE ====================
|
|
451
|
+
const FILE_PERMISSIONS = {
|
|
452
|
+
CREATE: 'file.create',
|
|
453
|
+
READ: 'file.read',
|
|
454
|
+
UPDATE: 'file.update',
|
|
455
|
+
DELETE: 'file.delete',
|
|
456
|
+
VIEW_PRIVATE_ACTION: 'file.view.private'
|
|
457
|
+
};
|
|
458
|
+
const FOLDER_PERMISSIONS = {
|
|
459
|
+
CREATE: 'folder.create',
|
|
460
|
+
READ: 'folder.read',
|
|
461
|
+
UPDATE: 'folder.update',
|
|
462
|
+
DELETE: 'folder.delete'
|
|
463
|
+
};
|
|
464
|
+
const STORAGE_CONFIG_PERMISSIONS = {
|
|
465
|
+
CREATE: 'storage-config.create',
|
|
466
|
+
READ: 'storage-config.read',
|
|
467
|
+
UPDATE: 'storage-config.update',
|
|
468
|
+
DELETE: 'storage-config.delete'
|
|
469
|
+
};
|
|
470
|
+
const UPLOAD_CONFIG_PERMISSIONS = {
|
|
471
|
+
DELETE: 'upload-config.delete'
|
|
472
|
+
};
|
|
473
|
+
// ==================== EMAIL MODULE ====================
|
|
474
|
+
const EMAIL_CONFIG_PERMISSIONS = {
|
|
475
|
+
CREATE: 'email-config.create',
|
|
476
|
+
READ: 'email-config.read',
|
|
477
|
+
UPDATE: 'email-config.update',
|
|
478
|
+
DELETE: 'email-config.delete'
|
|
479
|
+
};
|
|
480
|
+
const EMAIL_TEMPLATE_PERMISSIONS = {
|
|
481
|
+
CREATE: 'email-template.create',
|
|
482
|
+
READ: 'email-template.read',
|
|
483
|
+
UPDATE: 'email-template.update',
|
|
484
|
+
DELETE: 'email-template.delete'
|
|
485
|
+
};
|
|
486
|
+
// ==================== FORM BUILDER MODULE ====================
|
|
487
|
+
const FORM_PERMISSIONS = {
|
|
488
|
+
CREATE: 'form.create',
|
|
489
|
+
READ: 'form.read',
|
|
490
|
+
UPDATE: 'form.update',
|
|
491
|
+
DELETE: 'form.delete'
|
|
492
|
+
};
|
|
493
|
+
const FORM_RESULT_PERMISSIONS = {
|
|
494
|
+
CREATE: 'form-result.create',
|
|
495
|
+
READ: 'form-result.read',
|
|
496
|
+
UPDATE: 'form-result.update',
|
|
497
|
+
DELETE: 'form-result.delete'
|
|
498
|
+
};
|
|
499
|
+
// ==================== EVENT MANAGER MODULE ====================
|
|
500
|
+
const EVENT_PERMISSIONS = {
|
|
501
|
+
CREATE: 'event.create',
|
|
502
|
+
READ: 'event.read',
|
|
503
|
+
UPDATE: 'event.update',
|
|
504
|
+
DELETE: 'event.delete'
|
|
505
|
+
};
|
|
506
|
+
// ==================== NOTIFICATION MODULE ====================
|
|
507
|
+
const NOTIFICATION_PERMISSIONS = {
|
|
508
|
+
CREATE: 'notification.create',
|
|
509
|
+
READ: 'notification.read',
|
|
510
|
+
UPDATE: 'notification.update',
|
|
511
|
+
DELETE: 'notification.delete'
|
|
512
|
+
};
|
|
513
|
+
// ==================== LOCALIZATION MODULE ====================
|
|
514
|
+
const LANGUAGE_PERMISSIONS = {
|
|
515
|
+
CREATE: 'language.create',
|
|
516
|
+
READ: 'language.read',
|
|
517
|
+
UPDATE: 'language.update',
|
|
518
|
+
DELETE: 'language.delete'
|
|
519
|
+
};
|
|
520
|
+
const TRANSLATION_KEY_PERMISSIONS = {
|
|
521
|
+
CREATE: 'translation-key.create',
|
|
522
|
+
READ: 'translation-key.read',
|
|
523
|
+
UPDATE: 'translation-key.update',
|
|
524
|
+
DELETE: 'translation-key.delete'
|
|
525
|
+
};
|
|
526
|
+
const TRANSLATION_PERMISSIONS = {
|
|
527
|
+
CREATE: 'translation.create',
|
|
528
|
+
READ: 'translation.read',
|
|
529
|
+
UPDATE: 'translation.update',
|
|
530
|
+
DELETE: 'translation.delete'
|
|
531
|
+
};
|
|
532
|
+
// ==================== TASK MANAGER MODULE ====================
|
|
533
|
+
const TASK_BOARD_PERMISSIONS = {
|
|
534
|
+
CREATE: 'task-board.create',
|
|
535
|
+
READ: 'task-board.read',
|
|
536
|
+
UPDATE: 'task-board.update',
|
|
537
|
+
DELETE: 'task-board.delete',
|
|
538
|
+
MANAGE_MEMBERS: 'task-board.manage-members'
|
|
539
|
+
};
|
|
540
|
+
const TASK_LIST_PERMISSIONS = {
|
|
541
|
+
CREATE: 'task-list.create',
|
|
542
|
+
READ: 'task-list.read',
|
|
543
|
+
UPDATE: 'task-list.update',
|
|
544
|
+
DELETE: 'task-list.delete'
|
|
545
|
+
};
|
|
546
|
+
const TASK_PERMISSIONS = {
|
|
547
|
+
CREATE: 'task.create',
|
|
548
|
+
READ: 'task.read',
|
|
549
|
+
UPDATE: 'task.update',
|
|
550
|
+
DELETE: 'task.delete',
|
|
551
|
+
MOVE: 'task.move',
|
|
552
|
+
ASSIGN: 'task.assign'
|
|
553
|
+
};
|
|
554
|
+
const TASK_LABEL_PERMISSIONS = {
|
|
555
|
+
CREATE: 'task-label.create',
|
|
556
|
+
READ: 'task-label.read',
|
|
557
|
+
UPDATE: 'task-label.update',
|
|
558
|
+
DELETE: 'task-label.delete'
|
|
559
|
+
};
|
|
560
|
+
const TASK_COMMENT_PERMISSIONS = {
|
|
561
|
+
CREATE: 'task-comment.create',
|
|
562
|
+
READ: 'task-comment.read',
|
|
563
|
+
DELETE: 'task-comment.delete'
|
|
564
|
+
};
|
|
565
|
+
// ==================== AI ASSISTANT MODULE ====================
|
|
566
|
+
const AI_ASSISTANT_PERMISSIONS = {
|
|
567
|
+
VIEW_ALL_HISTORY: 'ai-assistant.view-all-history'
|
|
568
|
+
};
|
|
569
|
+
// ==================== AGGREGATED EXPORTS ====================
|
|
570
|
+
const PERMISSIONS = {
|
|
571
|
+
// Auth
|
|
572
|
+
USER: USER_PERMISSIONS,
|
|
573
|
+
COMPANY: COMPANY_PERMISSIONS,
|
|
574
|
+
BRANCH: BRANCH_PERMISSIONS,
|
|
575
|
+
SOCIAL_AUTH_CONFIG: SOCIAL_AUTH_CONFIG_PERMISSIONS,
|
|
576
|
+
// IAM
|
|
577
|
+
ACTION: ACTION_PERMISSIONS,
|
|
578
|
+
ROLE: ROLE_PERMISSIONS,
|
|
579
|
+
ROLE_ACTION: ROLE_ACTION_PERMISSIONS,
|
|
580
|
+
USER_ROLE: USER_ROLE_PERMISSIONS,
|
|
581
|
+
USER_ACTION: USER_ACTION_PERMISSIONS,
|
|
582
|
+
COMPANY_ACTION: COMPANY_ACTION_PERMISSIONS,
|
|
583
|
+
// Storage
|
|
584
|
+
FILE: FILE_PERMISSIONS,
|
|
585
|
+
FOLDER: FOLDER_PERMISSIONS,
|
|
586
|
+
STORAGE_CONFIG: STORAGE_CONFIG_PERMISSIONS,
|
|
587
|
+
// Email
|
|
588
|
+
EMAIL_CONFIG: EMAIL_CONFIG_PERMISSIONS,
|
|
589
|
+
EMAIL_TEMPLATE: EMAIL_TEMPLATE_PERMISSIONS,
|
|
590
|
+
// Form Builder
|
|
591
|
+
FORM: FORM_PERMISSIONS,
|
|
592
|
+
FORM_RESULT: FORM_RESULT_PERMISSIONS,
|
|
593
|
+
// Event Manager
|
|
594
|
+
EVENT: EVENT_PERMISSIONS,
|
|
595
|
+
// Notification
|
|
596
|
+
NOTIFICATION: NOTIFICATION_PERMISSIONS,
|
|
597
|
+
// Localization
|
|
598
|
+
LANGUAGE: LANGUAGE_PERMISSIONS,
|
|
599
|
+
TRANSLATION_KEY: TRANSLATION_KEY_PERMISSIONS,
|
|
600
|
+
TRANSLATION: TRANSLATION_PERMISSIONS,
|
|
601
|
+
// Task Manager
|
|
602
|
+
TASK_BOARD: TASK_BOARD_PERMISSIONS,
|
|
603
|
+
TASK_LIST: TASK_LIST_PERMISSIONS,
|
|
604
|
+
TASK: TASK_PERMISSIONS,
|
|
605
|
+
TASK_LABEL: TASK_LABEL_PERMISSIONS,
|
|
606
|
+
TASK_COMMENT: TASK_COMMENT_PERMISSIONS,
|
|
607
|
+
// AI Assistant
|
|
608
|
+
AI_ASSISTANT: AI_ASSISTANT_PERMISSIONS
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
612
|
+
}, {
|
|
613
|
+
BC: USER_PERMISSIONS,
|
|
614
|
+
Bz: AI_ASSISTANT_PERMISSIONS,
|
|
615
|
+
Em: STORAGE_CONFIG_PERMISSIONS,
|
|
616
|
+
GT: FORM_RESULT_PERMISSIONS,
|
|
617
|
+
Jj: PERMISSIONS,
|
|
618
|
+
N3: TRANSLATION_KEY_PERMISSIONS,
|
|
619
|
+
ON: TASK_LIST_PERMISSIONS,
|
|
620
|
+
P0: ROLE_ACTION_PERMISSIONS,
|
|
621
|
+
Q5: LANGUAGE_PERMISSIONS,
|
|
622
|
+
S6: FILE_PERMISSIONS,
|
|
623
|
+
T: TASK_PERMISSIONS,
|
|
624
|
+
UB: UPLOAD_CONFIG_PERMISSIONS,
|
|
625
|
+
UG: TASK_LABEL_PERMISSIONS,
|
|
626
|
+
Ub: EVENT_PERMISSIONS,
|
|
627
|
+
V0: EMAIL_CONFIG_PERMISSIONS,
|
|
628
|
+
Wc: FORM_PERMISSIONS,
|
|
629
|
+
Y3: TASK_BOARD_PERMISSIONS,
|
|
630
|
+
Y7: ACTION_PERMISSIONS,
|
|
631
|
+
_X: USER_ACTION_PERMISSIONS,
|
|
632
|
+
aO: COMPANY_ACTION_PERMISSIONS,
|
|
633
|
+
fS: TRANSLATION_PERMISSIONS,
|
|
634
|
+
l3: SOCIAL_AUTH_CONFIG_PERMISSIONS,
|
|
635
|
+
mV: ROLE_PERMISSIONS,
|
|
636
|
+
rH: NOTIFICATION_PERMISSIONS,
|
|
637
|
+
t$: COMPANY_PERMISSIONS,
|
|
638
|
+
w7: USER_ROLE_PERMISSIONS,
|
|
639
|
+
wA: BRANCH_PERMISSIONS,
|
|
640
|
+
wM: FOLDER_PERMISSIONS,
|
|
641
|
+
z$: EMAIL_TEMPLATE_PERMISSIONS,
|
|
642
|
+
zd: TASK_COMMENT_PERMISSIONS
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
},
|
|
647
|
+
419(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
648
|
+
|
|
649
|
+
// EXPORTS
|
|
650
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
651
|
+
pq: () => (/* binding */ LoggerMiddleware),
|
|
652
|
+
xR: () => (/* binding */ getCompanyId),
|
|
653
|
+
RE: () => (/* binding */ getRequestId),
|
|
654
|
+
EO: () => (/* binding */ getTenantId),
|
|
655
|
+
F6: () => (/* binding */ getUserId),
|
|
656
|
+
V8: () => (/* binding */ requestContext)
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-core/config"
|
|
660
|
+
var config_ = __webpack_require__(307);
|
|
661
|
+
// EXTERNAL MODULE: external "@nestjs/common"
|
|
662
|
+
var common_ = __webpack_require__(157);
|
|
663
|
+
;// CONCATENATED MODULE: external "async_hooks"
|
|
664
|
+
|
|
665
|
+
;// CONCATENATED MODULE: external "uuid"
|
|
666
|
+
|
|
667
|
+
// EXTERNAL MODULE: ./projects/nestjs-shared/src/classes/winston.logger.class.ts + 5 modules
|
|
668
|
+
var winston_logger_class = __webpack_require__(245);
|
|
669
|
+
// EXTERNAL MODULE: ./projects/nestjs-shared/src/constants/index.ts
|
|
670
|
+
var constants = __webpack_require__(43);
|
|
671
|
+
;// CONCATENATED MODULE: ./projects/nestjs-shared/src/middlewares/logger.middleware.ts
|
|
672
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
673
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
674
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
675
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
676
|
+
} else {
|
|
677
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
678
|
+
if (d = decorators[i]) {
|
|
679
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
// Configuration
|
|
692
|
+
const logConfig = config_.envConfig.getLogConfig();
|
|
693
|
+
const IS_DEBUG = logConfig.level === 'debug';
|
|
694
|
+
const DISABLE_HTTP_LOGGING = logConfig.disableHttpLogging;
|
|
695
|
+
const TENANT_ID_HEADER = 'x-tenant-id';
|
|
696
|
+
const EXCLUDED_PATHS = [
|
|
697
|
+
'/health',
|
|
698
|
+
'/metrics',
|
|
699
|
+
'/favicon.ico'
|
|
700
|
+
];
|
|
701
|
+
const MAX_BODY_LOG_SIZE = 1000;
|
|
702
|
+
const requestContext = new __rspack_external_async_hooks.AsyncLocalStorage();
|
|
703
|
+
// Context accessors
|
|
704
|
+
const getRequestId = ()=>requestContext.getStore()?.requestId;
|
|
705
|
+
const getTenantId = ()=>requestContext.getStore()?.tenantId;
|
|
706
|
+
const getUserId = ()=>requestContext.getStore()?.userId;
|
|
707
|
+
const getCompanyId = ()=>requestContext.getStore()?.companyId;
|
|
708
|
+
// Helper Functions
|
|
709
|
+
function summarizeRequestBody(body) {
|
|
710
|
+
if (!body) return undefined;
|
|
711
|
+
const parsed = typeof body === 'string' ? tryParseJson(body) : body;
|
|
712
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
713
|
+
const str = String(body);
|
|
714
|
+
return str.length > MAX_BODY_LOG_SIZE ? str.substring(0, MAX_BODY_LOG_SIZE) + '...' : str;
|
|
715
|
+
}
|
|
716
|
+
// For API request bodies, provide a concise summary
|
|
717
|
+
const summary = {};
|
|
718
|
+
// Pagination info
|
|
719
|
+
if (parsed.pagination) {
|
|
720
|
+
summary.page = parsed.pagination.currentPage;
|
|
721
|
+
summary.pageSize = parsed.pagination.pageSize;
|
|
722
|
+
}
|
|
723
|
+
// Filter keys only (not values - may contain sensitive data)
|
|
724
|
+
if (parsed.filter && typeof parsed.filter === 'object') {
|
|
725
|
+
const filterKeys = Object.keys(parsed.filter);
|
|
726
|
+
if (filterKeys.length > 0) summary.filterKeys = filterKeys;
|
|
727
|
+
}
|
|
728
|
+
// Select fields count
|
|
729
|
+
if (Array.isArray(parsed.select) && parsed.select.length > 0) {
|
|
730
|
+
summary.selectCount = parsed.select.length;
|
|
731
|
+
}
|
|
732
|
+
// Sort keys
|
|
733
|
+
if (parsed.sort && typeof parsed.sort === 'object') {
|
|
734
|
+
const sortKeys = Object.keys(parsed.sort);
|
|
735
|
+
if (sortKeys.length > 0) summary.sortKeys = sortKeys;
|
|
736
|
+
}
|
|
737
|
+
// ID for single item operations
|
|
738
|
+
if (parsed.id) summary.id = parsed.id;
|
|
739
|
+
// IDs for bulk operations
|
|
740
|
+
if (Array.isArray(parsed.ids)) summary.idsCount = parsed.ids.length;
|
|
741
|
+
return Object.keys(summary).length > 0 ? JSON.stringify(summary) : '{}';
|
|
742
|
+
}
|
|
743
|
+
function summarizeResponseBody(body) {
|
|
744
|
+
if (!body) return undefined;
|
|
745
|
+
const parsed = typeof body === 'string' ? tryParseJson(body) : body;
|
|
746
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
747
|
+
const str = String(body);
|
|
748
|
+
return str.length > MAX_BODY_LOG_SIZE ? str.substring(0, MAX_BODY_LOG_SIZE) + '...' : str;
|
|
749
|
+
}
|
|
750
|
+
const summary = {};
|
|
751
|
+
if ('success' in parsed) summary.success = parsed.success;
|
|
752
|
+
if ('message' in parsed) summary.message = parsed.message;
|
|
753
|
+
if ('code' in parsed) summary.code = parsed.code;
|
|
754
|
+
if (Array.isArray(parsed.data)) {
|
|
755
|
+
summary.dataCount = parsed.data.length;
|
|
756
|
+
} else if (parsed.data && typeof parsed.data === 'object') {
|
|
757
|
+
summary.hasData = true;
|
|
758
|
+
}
|
|
759
|
+
if (parsed.meta) {
|
|
760
|
+
summary.total = parsed.meta.total;
|
|
761
|
+
summary.page = parsed.meta.page;
|
|
762
|
+
}
|
|
763
|
+
if (parsed.errors) {
|
|
764
|
+
summary.errorsCount = Array.isArray(parsed.errors) ? parsed.errors.length : 1;
|
|
765
|
+
}
|
|
766
|
+
return JSON.stringify(summary);
|
|
767
|
+
}
|
|
768
|
+
function tryParseJson(str) {
|
|
769
|
+
try {
|
|
770
|
+
return JSON.parse(str);
|
|
771
|
+
} catch {
|
|
772
|
+
return null;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
function getClientIp(req) {
|
|
776
|
+
return req.headers['x-forwarded-for']?.split(',')[0] || req.socket?.remoteAddress || 'unknown';
|
|
777
|
+
}
|
|
778
|
+
class LoggerMiddleware {
|
|
779
|
+
logger = winston_logger_class/* .instance */.K;
|
|
780
|
+
use(req, res, next) {
|
|
781
|
+
const requestId = req.headers[constants/* .REQUEST_ID_HEADER */.kC] || (0,__rspack_external_uuid.v4)();
|
|
782
|
+
const tenantId = req.headers[TENANT_ID_HEADER];
|
|
783
|
+
const startTime = Date.now();
|
|
784
|
+
res.setHeader(constants/* .REQUEST_ID_HEADER */.kC, requestId);
|
|
785
|
+
const context = {
|
|
786
|
+
requestId,
|
|
787
|
+
tenantId,
|
|
788
|
+
startTime
|
|
789
|
+
};
|
|
790
|
+
requestContext.run(context, ()=>{
|
|
791
|
+
const shouldSkipLogging = DISABLE_HTTP_LOGGING || EXCLUDED_PATHS.some((path)=>req.originalUrl.startsWith(path));
|
|
792
|
+
if (!shouldSkipLogging) {
|
|
793
|
+
this.logRequest(req, requestId, tenantId);
|
|
794
|
+
this.setupResponseLogging(req, res, startTime, requestId, tenantId);
|
|
795
|
+
}
|
|
796
|
+
next();
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
setupResponseLogging(req, res, startTime, requestId, tenantId) {
|
|
800
|
+
let responseLogged = false;
|
|
801
|
+
const originalSend = res.send;
|
|
802
|
+
const originalJson = res.json;
|
|
803
|
+
const originalEnd = res.end;
|
|
804
|
+
const logOnce = (body)=>{
|
|
805
|
+
if (!responseLogged) {
|
|
806
|
+
responseLogged = true;
|
|
807
|
+
this.logResponse(req, res, startTime, body, requestId, tenantId);
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
res.send = function(body) {
|
|
811
|
+
logOnce(body);
|
|
812
|
+
return originalSend.call(this, body);
|
|
813
|
+
};
|
|
814
|
+
res.json = function(body) {
|
|
815
|
+
logOnce(body);
|
|
816
|
+
return originalJson.call(this, body);
|
|
817
|
+
};
|
|
818
|
+
res.end = function(...args) {
|
|
819
|
+
logOnce(args[0]);
|
|
820
|
+
return originalEnd.apply(this, args);
|
|
821
|
+
};
|
|
822
|
+
res.on('error', (error)=>{
|
|
823
|
+
this.logger.error('Response error', {
|
|
824
|
+
...this.buildBaseLogData(req, requestId, tenantId),
|
|
825
|
+
error: error.message,
|
|
826
|
+
stack: error.stack
|
|
827
|
+
});
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
logRequest(req, requestId, tenantId) {
|
|
831
|
+
const ip = getClientIp(req);
|
|
832
|
+
const contentType = req.headers['content-type'] || 'none';
|
|
833
|
+
// Build descriptive message like: Started processing request "POST" "/api/users" from "192.168.1.1"
|
|
834
|
+
const message = `Started processing request "${req.method}" "${req.originalUrl}" from "${ip}"`;
|
|
835
|
+
const logData = {
|
|
836
|
+
...this.buildBaseLogData(req, requestId, tenantId),
|
|
837
|
+
query: Object.keys(req.query).length > 0 ? req.query : undefined,
|
|
838
|
+
ip,
|
|
839
|
+
userAgent: req.headers['user-agent'],
|
|
840
|
+
contentType,
|
|
841
|
+
contentLength: req.headers['content-length']
|
|
842
|
+
};
|
|
843
|
+
if (IS_DEBUG) {
|
|
844
|
+
logData.body = summarizeRequestBody(req.body);
|
|
845
|
+
}
|
|
846
|
+
this.logger.info(message, logData);
|
|
847
|
+
}
|
|
848
|
+
logResponse(req, res, startTime, body, requestId, tenantId) {
|
|
849
|
+
const duration = Date.now() - startTime;
|
|
850
|
+
const statusCode = res.statusCode;
|
|
851
|
+
const level = statusCode >= 500 ? 'error' : statusCode >= 400 ? 'warn' : 'info';
|
|
852
|
+
const userId = getUserId();
|
|
853
|
+
const companyId = getCompanyId();
|
|
854
|
+
const contentType = res.getHeader('content-type') || 'none';
|
|
855
|
+
const contentLength = res.getHeader('content-length') || 'null';
|
|
856
|
+
// Build descriptive message like: Request finished "HTTP/1.1" "POST" "/api/users" - 200 "application/json" 534.29ms
|
|
857
|
+
const message = `Request finished "HTTP/1.1" "${req.method}" "${req.originalUrl}" - ${statusCode} ${contentLength} "${contentType}" ${duration.toFixed(2)}ms`;
|
|
858
|
+
const logData = {
|
|
859
|
+
...this.buildBaseLogData(req, requestId, tenantId),
|
|
860
|
+
userId,
|
|
861
|
+
companyId,
|
|
862
|
+
statusCode,
|
|
863
|
+
statusMessage: res.statusMessage,
|
|
864
|
+
duration: `${duration}ms`,
|
|
865
|
+
durationMs: duration,
|
|
866
|
+
contentType,
|
|
867
|
+
contentLength
|
|
868
|
+
};
|
|
869
|
+
if (statusCode >= 400 || IS_DEBUG) {
|
|
870
|
+
logData.responseBody = summarizeResponseBody(body);
|
|
871
|
+
}
|
|
872
|
+
this.logger.log(level, message, logData);
|
|
873
|
+
if (duration > 3000 && statusCode < 400) {
|
|
874
|
+
this.logger.warn(`Slow request detected: "${req.method}" "${req.originalUrl}" took ${duration}ms (threshold: 3000ms)`, {
|
|
875
|
+
...this.buildBaseLogData(req, requestId, tenantId),
|
|
876
|
+
userId,
|
|
877
|
+
companyId,
|
|
878
|
+
duration: `${duration}ms`,
|
|
879
|
+
durationMs: duration,
|
|
880
|
+
threshold: '3000ms'
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
buildBaseLogData(req, requestId, tenantId) {
|
|
885
|
+
return {
|
|
886
|
+
context: 'HTTP',
|
|
887
|
+
requestId,
|
|
888
|
+
tenantId,
|
|
889
|
+
method: req.method,
|
|
890
|
+
url: req.originalUrl,
|
|
891
|
+
path: req.path
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
LoggerMiddleware = _ts_decorate([
|
|
896
|
+
(0,common_.Injectable)()
|
|
897
|
+
], LoggerMiddleware);
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
},
|
|
901
|
+
307(module) {
|
|
902
|
+
|
|
903
|
+
module.exports = __rspack_external__flusys_nestjs_core_config_197fa0a9;
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
},
|
|
907
|
+
157(module) {
|
|
908
|
+
|
|
909
|
+
module.exports = __rspack_external__nestjs_common_a04939da;
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
},
|
|
913
|
+
|
|
914
|
+
};
|