@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
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
function _define_property(obj, key, value) {
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value: value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
|
-
const mockExistsSync = jest.fn();
|
|
15
|
-
const mockMkdirSync = jest.fn();
|
|
16
|
-
jest.mock('fs', ()=>({
|
|
17
|
-
existsSync: (...args)=>mockExistsSync(...args),
|
|
18
|
-
mkdirSync: (...args)=>mockMkdirSync(...args)
|
|
19
|
-
}));
|
|
20
|
-
const mockGetLogConfig = jest.fn();
|
|
21
|
-
const mockUseTenantMode = jest.fn();
|
|
22
|
-
const mockIsProduction = jest.fn();
|
|
23
|
-
jest.mock('@flusys/nestjs-core/config', ()=>({
|
|
24
|
-
envConfig: {
|
|
25
|
-
getLogConfig: (...args)=>mockGetLogConfig(...args),
|
|
26
|
-
useTenantMode: (...args)=>mockUseTenantMode(...args),
|
|
27
|
-
isProduction: (...args)=>mockIsProduction(...args)
|
|
28
|
-
}
|
|
29
|
-
}));
|
|
30
|
-
const { EventEmitter } = require('events');
|
|
31
|
-
let FakeDailyRotateFile = class FakeDailyRotateFile extends EventEmitter {
|
|
32
|
-
constructor(options){
|
|
33
|
-
super(), _define_property(this, "options", void 0), _define_property(this, "log", jest.fn((_info, callback)=>callback?.()));
|
|
34
|
-
this.options = options;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
jest.mock('winston-daily-rotate-file', ()=>({
|
|
38
|
-
__esModule: true,
|
|
39
|
-
default: FakeDailyRotateFile
|
|
40
|
-
}));
|
|
41
|
-
let capturedPrintf;
|
|
42
|
-
jest.mock('winston', ()=>{
|
|
43
|
-
const actual = jest.requireActual('winston');
|
|
44
|
-
// winston's `format` export exposes its sub-formatters (colorize, combine, printf, ...)
|
|
45
|
-
// as non-enumerable getters, so a plain object spread silently drops them. Delegate through
|
|
46
|
-
// the prototype chain instead and only shadow `printf` to capture the formatter callback.
|
|
47
|
-
const realPrintf = actual.format.printf;
|
|
48
|
-
const mockFormat = Object.create(actual.format);
|
|
49
|
-
Object.defineProperty(mockFormat, 'printf', {
|
|
50
|
-
value: (fn)=>{
|
|
51
|
-
capturedPrintf = fn;
|
|
52
|
-
return realPrintf(fn);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return {
|
|
56
|
-
...actual,
|
|
57
|
-
format: mockFormat
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
describe('winston.logger.class', ()=>{
|
|
61
|
-
let consoleErrorSpy;
|
|
62
|
-
beforeEach(()=>{
|
|
63
|
-
jest.resetModules();
|
|
64
|
-
jest.clearAllMocks();
|
|
65
|
-
// FakeDailyRotateFile isn't a real winston-transport instance, so winston logs a
|
|
66
|
-
// harmless "legacy transport" deprecation warning via console.error on each createLogger call.
|
|
67
|
-
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(()=>undefined);
|
|
68
|
-
mockExistsSync.mockReturnValue(true);
|
|
69
|
-
mockGetLogConfig.mockReturnValue({
|
|
70
|
-
dir: 'logs',
|
|
71
|
-
level: 'debug',
|
|
72
|
-
maxSize: '20m',
|
|
73
|
-
maxFiles: '14d',
|
|
74
|
-
disableHttpLogging: false
|
|
75
|
-
});
|
|
76
|
-
mockUseTenantMode.mockReturnValue(false);
|
|
77
|
-
});
|
|
78
|
-
afterEach(()=>{
|
|
79
|
-
consoleErrorSpy.mockRestore();
|
|
80
|
-
});
|
|
81
|
-
it('should create the log directory when it does not exist', ()=>{
|
|
82
|
-
mockExistsSync.mockReturnValue(false);
|
|
83
|
-
mockIsProduction.mockReturnValue(false);
|
|
84
|
-
require('./winston.logger.class');
|
|
85
|
-
expect(mockMkdirSync).toHaveBeenCalledWith('logs', {
|
|
86
|
-
recursive: true
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
it('should not attempt to create the log directory when it already exists', ()=>{
|
|
90
|
-
mockExistsSync.mockReturnValue(true);
|
|
91
|
-
mockIsProduction.mockReturnValue(false);
|
|
92
|
-
require('./winston.logger.class');
|
|
93
|
-
expect(mockMkdirSync).not.toHaveBeenCalledWith('logs', {
|
|
94
|
-
recursive: true
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
it('should export a dev (console-based) instance when not in production', ()=>{
|
|
98
|
-
mockIsProduction.mockReturnValue(false);
|
|
99
|
-
const { instance } = require('./winston.logger.class');
|
|
100
|
-
expect(instance).toBeDefined();
|
|
101
|
-
expect(typeof instance.log).toBe('function');
|
|
102
|
-
});
|
|
103
|
-
it('should export a prod (file-rotation-based) instance when in production', ()=>{
|
|
104
|
-
mockIsProduction.mockReturnValue(true);
|
|
105
|
-
const { instance } = require('./winston.logger.class');
|
|
106
|
-
expect(instance).toBeDefined();
|
|
107
|
-
expect(typeof instance.log).toBe('function');
|
|
108
|
-
});
|
|
109
|
-
describe('createModuleLogger', ()=>{
|
|
110
|
-
it('should return the shared dev logger instance in non-production mode', ()=>{
|
|
111
|
-
mockIsProduction.mockReturnValue(false);
|
|
112
|
-
const { createModuleLogger, instance } = require('./winston.logger.class');
|
|
113
|
-
expect(createModuleLogger('auth')).toBe(instance);
|
|
114
|
-
expect(createModuleLogger('iam')).toBe(instance);
|
|
115
|
-
});
|
|
116
|
-
it('should create a distinct, cached logger per module in production mode', ()=>{
|
|
117
|
-
mockIsProduction.mockReturnValue(true);
|
|
118
|
-
const { createModuleLogger } = require('./winston.logger.class');
|
|
119
|
-
const authLogger1 = createModuleLogger('auth');
|
|
120
|
-
const authLogger2 = createModuleLogger('auth');
|
|
121
|
-
const iamLogger = createModuleLogger('iam');
|
|
122
|
-
expect(authLogger1).toBe(authLogger2);
|
|
123
|
-
expect(authLogger1).not.toBe(iamLogger);
|
|
124
|
-
});
|
|
125
|
-
it('should create the module-specific log directory on first use in production mode', ()=>{
|
|
126
|
-
mockIsProduction.mockReturnValue(true);
|
|
127
|
-
mockExistsSync.mockImplementation((p)=>p === 'logs');
|
|
128
|
-
const { createModuleLogger } = require('./winston.logger.class');
|
|
129
|
-
createModuleLogger('storage');
|
|
130
|
-
expect(mockMkdirSync).toHaveBeenCalledWith(expect.stringContaining('storage'), {
|
|
131
|
-
recursive: true
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
it('should not recreate the module directory or transport on subsequent calls', ()=>{
|
|
135
|
-
mockIsProduction.mockReturnValue(true);
|
|
136
|
-
mockExistsSync.mockReturnValue(true);
|
|
137
|
-
const { createModuleLogger } = require('./winston.logger.class');
|
|
138
|
-
createModuleLogger('storage');
|
|
139
|
-
const mkdirCallsAfterFirst = mockMkdirSync.mock.calls.length;
|
|
140
|
-
createModuleLogger('storage');
|
|
141
|
-
expect(mockMkdirSync.mock.calls.length).toBe(mkdirCallsAfterFirst);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
describe('structuredFormat (captured printf callback)', ()=>{
|
|
145
|
-
beforeEach(()=>{
|
|
146
|
-
mockIsProduction.mockReturnValue(true);
|
|
147
|
-
capturedPrintf = undefined;
|
|
148
|
-
require('./winston.logger.class');
|
|
149
|
-
});
|
|
150
|
-
it('should capture the printf formatter', ()=>{
|
|
151
|
-
expect(capturedPrintf).toBeInstanceOf(Function);
|
|
152
|
-
});
|
|
153
|
-
it('should default the request id when absent and map known levels', ()=>{
|
|
154
|
-
const out = capturedPrintf({
|
|
155
|
-
timestamp: 'T',
|
|
156
|
-
level: 'error',
|
|
157
|
-
message: 'boom'
|
|
158
|
-
});
|
|
159
|
-
expect(out).toContain('[no-request-id]');
|
|
160
|
-
expect(out).toContain('Error');
|
|
161
|
-
});
|
|
162
|
-
it('should use the provided requestId and title-case unknown levels', ()=>{
|
|
163
|
-
const out = capturedPrintf({
|
|
164
|
-
timestamp: 'T',
|
|
165
|
-
level: 'silly',
|
|
166
|
-
message: 'x',
|
|
167
|
-
requestId: 'req-1'
|
|
168
|
-
});
|
|
169
|
-
expect(out).toContain('[req-1]');
|
|
170
|
-
expect(out).toContain('Silly');
|
|
171
|
-
});
|
|
172
|
-
it('should render context, endpoint, status, duration and user/tenant/company parts', ()=>{
|
|
173
|
-
const out = capturedPrintf({
|
|
174
|
-
timestamp: 'T',
|
|
175
|
-
level: 'info',
|
|
176
|
-
message: 'handled',
|
|
177
|
-
context: 'AuthService',
|
|
178
|
-
method: 'POST',
|
|
179
|
-
path: '/login',
|
|
180
|
-
statusCode: 200,
|
|
181
|
-
duration: '12ms',
|
|
182
|
-
userId: 'u1',
|
|
183
|
-
tenantId: 't1',
|
|
184
|
-
companyId: 'c1'
|
|
185
|
-
});
|
|
186
|
-
expect(out).toContain('Context: AuthService');
|
|
187
|
-
expect(out).toContain('Endpoint: POST /login');
|
|
188
|
-
expect(out).toContain('Status: 200');
|
|
189
|
-
expect(out).toContain('Duration: 12ms');
|
|
190
|
-
expect(out).toContain('UserId: u1');
|
|
191
|
-
expect(out).toContain('TenantId: t1');
|
|
192
|
-
expect(out).toContain('CompanyId: c1');
|
|
193
|
-
expect(out).toContain('handled');
|
|
194
|
-
});
|
|
195
|
-
it('should fall back to `url` for the endpoint line when `path` is absent', ()=>{
|
|
196
|
-
const out = capturedPrintf({
|
|
197
|
-
timestamp: 'T',
|
|
198
|
-
level: 'info',
|
|
199
|
-
message: 'm',
|
|
200
|
-
method: 'GET',
|
|
201
|
-
url: '/legacy'
|
|
202
|
-
});
|
|
203
|
-
expect(out).toContain('Endpoint: GET /legacy');
|
|
204
|
-
});
|
|
205
|
-
it('should omit the endpoint line entirely when method has no path or url', ()=>{
|
|
206
|
-
const out = capturedPrintf({
|
|
207
|
-
timestamp: 'T',
|
|
208
|
-
level: 'info',
|
|
209
|
-
message: 'm',
|
|
210
|
-
method: 'GET'
|
|
211
|
-
});
|
|
212
|
-
expect(out).not.toContain('Endpoint:');
|
|
213
|
-
});
|
|
214
|
-
it('should append remaining metadata as JSON, excluding the `splat` key', ()=>{
|
|
215
|
-
const out = capturedPrintf({
|
|
216
|
-
timestamp: 'T',
|
|
217
|
-
level: 'info',
|
|
218
|
-
message: 'm',
|
|
219
|
-
splat: [
|
|
220
|
-
'ignored'
|
|
221
|
-
],
|
|
222
|
-
orderId: 'o1',
|
|
223
|
-
amount: 50
|
|
224
|
-
});
|
|
225
|
-
expect(out).toContain('Metadata: {"orderId":"o1","amount":50}');
|
|
226
|
-
expect(out).not.toContain('ignored');
|
|
227
|
-
});
|
|
228
|
-
it('should omit the Metadata line when no extra metadata remains', ()=>{
|
|
229
|
-
const out = capturedPrintf({
|
|
230
|
-
timestamp: 'T',
|
|
231
|
-
level: 'info',
|
|
232
|
-
message: 'm',
|
|
233
|
-
splat: []
|
|
234
|
-
});
|
|
235
|
-
expect(out).not.toContain('Metadata:');
|
|
236
|
-
});
|
|
237
|
-
it('should append the stack trace when present', ()=>{
|
|
238
|
-
const out = capturedPrintf({
|
|
239
|
-
timestamp: 'T',
|
|
240
|
-
level: 'error',
|
|
241
|
-
message: 'crashed',
|
|
242
|
-
stack: 'Error: crashed\n at foo.ts:1:1'
|
|
243
|
-
});
|
|
244
|
-
expect(out).toContain('Stack: Error: crashed');
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
describe('TenantAwareTransport routing', ()=>{
|
|
248
|
-
it('should route to the default transport when tenant mode is disabled', ()=>{
|
|
249
|
-
mockIsProduction.mockReturnValue(true);
|
|
250
|
-
mockUseTenantMode.mockReturnValue(false);
|
|
251
|
-
const { instance } = require('./winston.logger.class');
|
|
252
|
-
const tenantAwareTransport = instance.transports[0];
|
|
253
|
-
const defaultTransport = tenantAwareTransport.defaultTransport;
|
|
254
|
-
const logSpy = jest.spyOn(defaultTransport, 'log');
|
|
255
|
-
const cb = jest.fn();
|
|
256
|
-
tenantAwareTransport.log({
|
|
257
|
-
level: 'info',
|
|
258
|
-
message: 'x',
|
|
259
|
-
tenantId: 't1'
|
|
260
|
-
}, cb);
|
|
261
|
-
expect(logSpy).toHaveBeenCalled();
|
|
262
|
-
});
|
|
263
|
-
it('should route to the default transport when tenant mode is enabled but no tenantId is present', ()=>{
|
|
264
|
-
mockIsProduction.mockReturnValue(true);
|
|
265
|
-
mockUseTenantMode.mockReturnValue(true);
|
|
266
|
-
const { instance } = require('./winston.logger.class');
|
|
267
|
-
const tenantAwareTransport = instance.transports[0];
|
|
268
|
-
const defaultTransport = tenantAwareTransport.defaultTransport;
|
|
269
|
-
const logSpy = jest.spyOn(defaultTransport, 'log');
|
|
270
|
-
const cb = jest.fn();
|
|
271
|
-
tenantAwareTransport.log({
|
|
272
|
-
level: 'info',
|
|
273
|
-
message: 'x'
|
|
274
|
-
}, cb);
|
|
275
|
-
expect(logSpy).toHaveBeenCalled();
|
|
276
|
-
});
|
|
277
|
-
it('should route to a tenant-specific transport when tenant mode is enabled and tenantId is present', ()=>{
|
|
278
|
-
mockIsProduction.mockReturnValue(true);
|
|
279
|
-
mockUseTenantMode.mockReturnValue(true);
|
|
280
|
-
mockExistsSync.mockReturnValue(true);
|
|
281
|
-
const { instance } = require('./winston.logger.class');
|
|
282
|
-
const tenantAwareTransport = instance.transports[0];
|
|
283
|
-
const defaultTransport = tenantAwareTransport.defaultTransport;
|
|
284
|
-
const defaultLogSpy = jest.spyOn(defaultTransport, 'log');
|
|
285
|
-
const cb = jest.fn();
|
|
286
|
-
tenantAwareTransport.log({
|
|
287
|
-
level: 'info',
|
|
288
|
-
message: 'x',
|
|
289
|
-
tenantId: 'tenant-a'
|
|
290
|
-
}, cb);
|
|
291
|
-
expect(defaultLogSpy).not.toHaveBeenCalled();
|
|
292
|
-
});
|
|
293
|
-
it('should read tenantId from nested `metadata.tenantId` when top-level tenantId is absent', ()=>{
|
|
294
|
-
mockIsProduction.mockReturnValue(true);
|
|
295
|
-
mockUseTenantMode.mockReturnValue(true);
|
|
296
|
-
mockExistsSync.mockReturnValue(true);
|
|
297
|
-
const { instance } = require('./winston.logger.class');
|
|
298
|
-
const tenantAwareTransport = instance.transports[0];
|
|
299
|
-
const defaultTransport = tenantAwareTransport.defaultTransport;
|
|
300
|
-
const defaultLogSpy = jest.spyOn(defaultTransport, 'log');
|
|
301
|
-
const cb = jest.fn();
|
|
302
|
-
tenantAwareTransport.log({
|
|
303
|
-
level: 'info',
|
|
304
|
-
message: 'x',
|
|
305
|
-
metadata: {
|
|
306
|
-
tenantId: 'tenant-b'
|
|
307
|
-
}
|
|
308
|
-
}, cb);
|
|
309
|
-
expect(defaultLogSpy).not.toHaveBeenCalled();
|
|
310
|
-
});
|
|
311
|
-
it('should re-emit "logged" so winston can track transport completion', (done)=>{
|
|
312
|
-
mockIsProduction.mockReturnValue(true);
|
|
313
|
-
mockUseTenantMode.mockReturnValue(false);
|
|
314
|
-
const { instance } = require('./winston.logger.class');
|
|
315
|
-
const tenantAwareTransport = instance.transports[0];
|
|
316
|
-
tenantAwareTransport.once('logged', (info)=>{
|
|
317
|
-
expect(info.message).toBe('done-check');
|
|
318
|
-
done();
|
|
319
|
-
});
|
|
320
|
-
tenantAwareTransport.log({
|
|
321
|
-
level: 'info',
|
|
322
|
-
message: 'done-check'
|
|
323
|
-
}, jest.fn());
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
});
|
|
327
|
-
export { };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// ==================== AUTH (Shared across guards/interceptors) ====================
|
|
2
|
-
// These are duplicated in nestjs-auth but needed here to avoid circular dependencies
|
|
3
|
-
export const AUTH_MESSAGES = {
|
|
4
|
-
TOKEN_REQUIRED: 'auth.token.required',
|
|
5
|
-
TOKEN_INVALID: 'auth.token.invalid',
|
|
6
|
-
ENTITY_BELOG_ANOTHER_COMPANY: 'entity.belongs.another.company',
|
|
7
|
-
COMPANY_NO_ACCESS: 'auth.company.no.access'
|
|
8
|
-
};
|
|
9
|
-
// ==================== ERROR (HTTP Exceptions) ====================
|
|
10
|
-
export const ERROR_MESSAGES = {
|
|
11
|
-
NOT_FOUND: 'error.not.found',
|
|
12
|
-
VALIDATION: 'error.validation',
|
|
13
|
-
UNAUTHORIZED: 'error.unauthorized',
|
|
14
|
-
FORBIDDEN: 'error.forbidden',
|
|
15
|
-
CONFLICT: 'error.conflict',
|
|
16
|
-
DB_FOREIGN_KEY: 'error.db.foreign.key',
|
|
17
|
-
DB_NOT_NULL: 'error.db.not.null',
|
|
18
|
-
DB_INVALID_INPUT: 'error.db.invalid.input',
|
|
19
|
-
DB_VALUE_TOO_LONG: 'error.db.value.too.long',
|
|
20
|
-
DB_CHECK_CONSTRAINT: 'error.db.check.constraint',
|
|
21
|
-
DB_DEADLOCK: 'error.db.deadlock',
|
|
22
|
-
INTERNAL: 'error.internal',
|
|
23
|
-
SERVICE_UNAVAILABLE: 'error.service.unavailable',
|
|
24
|
-
UNKNOWN: 'error.unknown',
|
|
25
|
-
HTTP: 'error.http',
|
|
26
|
-
GENERIC: 'error.generic',
|
|
27
|
-
PERMISSION_SYSTEM_UNAVAILABLE: 'error.permission.system.unavailable',
|
|
28
|
-
INSUFFICIENT_PERMISSIONS: 'error.insufficient.permissions',
|
|
29
|
-
INSUFFICIENT_PERMISSIONS_OR: 'error.insufficient.permissions.or',
|
|
30
|
-
NO_PERMISSIONS_FOUND: 'error.no.permissions.found',
|
|
31
|
-
ENDPOINT_DISABLED: 'error.endpoint.disabled'
|
|
32
|
-
};
|
|
33
|
-
// ==================== SYSTEM (Infrastructure) ====================
|
|
34
|
-
export const SYSTEM_MESSAGES = {
|
|
35
|
-
REPOSITORY_NOT_AVAILABLE: 'system.repository.not.available',
|
|
36
|
-
DATASOURCE_NOT_AVAILABLE: 'system.datasource.not.available',
|
|
37
|
-
DATABASE_CONFIG_NOT_AVAILABLE: 'system.database.config.not.available',
|
|
38
|
-
SERVICE_NOT_AVAILABLE: 'system.service.not.available',
|
|
39
|
-
CONFIG_REQUIRED: 'system.config.required',
|
|
40
|
-
INTERNAL_ERROR: 'system.internal.error',
|
|
41
|
-
DUPLICATE_REQUEST: 'system.duplicate.request',
|
|
42
|
-
INVALID_TENANT_ID: 'system.invalid.tenant.id',
|
|
43
|
-
TENANT_NOT_FOUND: 'system.tenant.not.found',
|
|
44
|
-
TENANT_HEADER_REQUIRED: 'system.tenant.header.required',
|
|
45
|
-
MISSING_PARAMETER: 'system.missing.parameter',
|
|
46
|
-
SDK_NOT_INSTALLED: 'system.sdk.not.installed',
|
|
47
|
-
PATH_TRAVERSAL_DETECTED: 'system.path.traversal.detected',
|
|
48
|
-
INVALID_FILE_KEY: 'system.invalid.file.key'
|
|
49
|
-
};
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
// ==================== AUTH MODULE ====================
|
|
2
|
-
export const USER_PERMISSIONS = {
|
|
3
|
-
CREATE: 'user.create',
|
|
4
|
-
READ: 'user.read',
|
|
5
|
-
UPDATE: 'user.update',
|
|
6
|
-
DELETE: 'user.delete',
|
|
7
|
-
LOOKUP: 'user.lookup'
|
|
8
|
-
};
|
|
9
|
-
export const COMPANY_PERMISSIONS = {
|
|
10
|
-
CREATE: 'company.create',
|
|
11
|
-
READ: 'company.read',
|
|
12
|
-
UPDATE: 'company.update',
|
|
13
|
-
DELETE: 'company.delete'
|
|
14
|
-
};
|
|
15
|
-
export const BRANCH_PERMISSIONS = {
|
|
16
|
-
CREATE: 'branch.create',
|
|
17
|
-
READ: 'branch.read',
|
|
18
|
-
UPDATE: 'branch.update',
|
|
19
|
-
DELETE: 'branch.delete'
|
|
20
|
-
};
|
|
21
|
-
// ==================== IAM MODULE ====================
|
|
22
|
-
export const ACTION_PERMISSIONS = {
|
|
23
|
-
CREATE: 'action.create',
|
|
24
|
-
READ: 'action.read',
|
|
25
|
-
UPDATE: 'action.update',
|
|
26
|
-
DELETE: 'action.delete'
|
|
27
|
-
};
|
|
28
|
-
export const ROLE_PERMISSIONS = {
|
|
29
|
-
CREATE: 'role.create',
|
|
30
|
-
READ: 'role.read',
|
|
31
|
-
UPDATE: 'role.update',
|
|
32
|
-
DELETE: 'role.delete'
|
|
33
|
-
};
|
|
34
|
-
export const ROLE_ACTION_PERMISSIONS = {
|
|
35
|
-
READ: 'role-action.read',
|
|
36
|
-
ASSIGN: 'role-action.assign'
|
|
37
|
-
};
|
|
38
|
-
export const USER_ROLE_PERMISSIONS = {
|
|
39
|
-
READ: 'user-role.read',
|
|
40
|
-
ASSIGN: 'user-role.assign'
|
|
41
|
-
};
|
|
42
|
-
export const USER_ACTION_PERMISSIONS = {
|
|
43
|
-
READ: 'user-action.read',
|
|
44
|
-
ASSIGN: 'user-action.assign'
|
|
45
|
-
};
|
|
46
|
-
export const COMPANY_ACTION_PERMISSIONS = {
|
|
47
|
-
READ: 'company-action.read',
|
|
48
|
-
ASSIGN: 'company-action.assign'
|
|
49
|
-
};
|
|
50
|
-
// ==================== STORAGE MODULE ====================
|
|
51
|
-
export const FILE_PERMISSIONS = {
|
|
52
|
-
CREATE: 'file.create',
|
|
53
|
-
READ: 'file.read',
|
|
54
|
-
UPDATE: 'file.update',
|
|
55
|
-
DELETE: 'file.delete',
|
|
56
|
-
VIEW_PRIVATE_ACTION: 'file.view.private'
|
|
57
|
-
};
|
|
58
|
-
export const FOLDER_PERMISSIONS = {
|
|
59
|
-
CREATE: 'folder.create',
|
|
60
|
-
READ: 'folder.read',
|
|
61
|
-
UPDATE: 'folder.update',
|
|
62
|
-
DELETE: 'folder.delete'
|
|
63
|
-
};
|
|
64
|
-
export const STORAGE_CONFIG_PERMISSIONS = {
|
|
65
|
-
CREATE: 'storage-config.create',
|
|
66
|
-
READ: 'storage-config.read',
|
|
67
|
-
UPDATE: 'storage-config.update',
|
|
68
|
-
DELETE: 'storage-config.delete'
|
|
69
|
-
};
|
|
70
|
-
export const UPLOAD_CONFIG_PERMISSIONS = {
|
|
71
|
-
DELETE: 'upload-config.delete'
|
|
72
|
-
};
|
|
73
|
-
// ==================== EMAIL MODULE ====================
|
|
74
|
-
export const EMAIL_CONFIG_PERMISSIONS = {
|
|
75
|
-
CREATE: 'email-config.create',
|
|
76
|
-
READ: 'email-config.read',
|
|
77
|
-
UPDATE: 'email-config.update',
|
|
78
|
-
DELETE: 'email-config.delete'
|
|
79
|
-
};
|
|
80
|
-
export const EMAIL_TEMPLATE_PERMISSIONS = {
|
|
81
|
-
CREATE: 'email-template.create',
|
|
82
|
-
READ: 'email-template.read',
|
|
83
|
-
UPDATE: 'email-template.update',
|
|
84
|
-
DELETE: 'email-template.delete'
|
|
85
|
-
};
|
|
86
|
-
// ==================== FORM BUILDER MODULE ====================
|
|
87
|
-
export const FORM_PERMISSIONS = {
|
|
88
|
-
CREATE: 'form.create',
|
|
89
|
-
READ: 'form.read',
|
|
90
|
-
UPDATE: 'form.update',
|
|
91
|
-
DELETE: 'form.delete'
|
|
92
|
-
};
|
|
93
|
-
export const FORM_RESULT_PERMISSIONS = {
|
|
94
|
-
CREATE: 'form-result.create',
|
|
95
|
-
READ: 'form-result.read',
|
|
96
|
-
UPDATE: 'form-result.update',
|
|
97
|
-
DELETE: 'form-result.delete'
|
|
98
|
-
};
|
|
99
|
-
// ==================== EVENT MANAGER MODULE ====================
|
|
100
|
-
export const EVENT_PERMISSIONS = {
|
|
101
|
-
CREATE: 'event.create',
|
|
102
|
-
READ: 'event.read',
|
|
103
|
-
UPDATE: 'event.update',
|
|
104
|
-
DELETE: 'event.delete'
|
|
105
|
-
};
|
|
106
|
-
// ==================== NOTIFICATION MODULE ====================
|
|
107
|
-
export const NOTIFICATION_PERMISSIONS = {
|
|
108
|
-
CREATE: 'notification.create',
|
|
109
|
-
READ: 'notification.read',
|
|
110
|
-
UPDATE: 'notification.update',
|
|
111
|
-
DELETE: 'notification.delete'
|
|
112
|
-
};
|
|
113
|
-
// ==================== LOCALIZATION MODULE ====================
|
|
114
|
-
export const LANGUAGE_PERMISSIONS = {
|
|
115
|
-
CREATE: 'language.create',
|
|
116
|
-
READ: 'language.read',
|
|
117
|
-
UPDATE: 'language.update',
|
|
118
|
-
DELETE: 'language.delete'
|
|
119
|
-
};
|
|
120
|
-
export const TRANSLATION_KEY_PERMISSIONS = {
|
|
121
|
-
CREATE: 'translation-key.create',
|
|
122
|
-
READ: 'translation-key.read',
|
|
123
|
-
UPDATE: 'translation-key.update',
|
|
124
|
-
DELETE: 'translation-key.delete'
|
|
125
|
-
};
|
|
126
|
-
export const TRANSLATION_PERMISSIONS = {
|
|
127
|
-
CREATE: 'translation.create',
|
|
128
|
-
READ: 'translation.read',
|
|
129
|
-
UPDATE: 'translation.update',
|
|
130
|
-
DELETE: 'translation.delete'
|
|
131
|
-
};
|
|
132
|
-
// ==================== TASK MANAGER MODULE ====================
|
|
133
|
-
export const TASK_BOARD_PERMISSIONS = {
|
|
134
|
-
CREATE: 'task-board.create',
|
|
135
|
-
READ: 'task-board.read',
|
|
136
|
-
UPDATE: 'task-board.update',
|
|
137
|
-
DELETE: 'task-board.delete',
|
|
138
|
-
MANAGE_MEMBERS: 'task-board.manage-members'
|
|
139
|
-
};
|
|
140
|
-
export const TASK_LIST_PERMISSIONS = {
|
|
141
|
-
CREATE: 'task-list.create',
|
|
142
|
-
READ: 'task-list.read',
|
|
143
|
-
UPDATE: 'task-list.update',
|
|
144
|
-
DELETE: 'task-list.delete'
|
|
145
|
-
};
|
|
146
|
-
export const TASK_PERMISSIONS = {
|
|
147
|
-
CREATE: 'task.create',
|
|
148
|
-
READ: 'task.read',
|
|
149
|
-
UPDATE: 'task.update',
|
|
150
|
-
DELETE: 'task.delete',
|
|
151
|
-
MOVE: 'task.move',
|
|
152
|
-
ASSIGN: 'task.assign'
|
|
153
|
-
};
|
|
154
|
-
export const TASK_LABEL_PERMISSIONS = {
|
|
155
|
-
CREATE: 'task-label.create',
|
|
156
|
-
READ: 'task-label.read',
|
|
157
|
-
UPDATE: 'task-label.update',
|
|
158
|
-
DELETE: 'task-label.delete'
|
|
159
|
-
};
|
|
160
|
-
export const TASK_COMMENT_PERMISSIONS = {
|
|
161
|
-
CREATE: 'task-comment.create',
|
|
162
|
-
READ: 'task-comment.read',
|
|
163
|
-
DELETE: 'task-comment.delete'
|
|
164
|
-
};
|
|
165
|
-
// ==================== AI ASSISTANT MODULE ====================
|
|
166
|
-
export const AI_ASSISTANT_PERMISSIONS = {
|
|
167
|
-
VIEW_ALL_HISTORY: 'ai-assistant.view-all-history'
|
|
168
|
-
};
|
|
169
|
-
// ==================== AGGREGATED EXPORTS ====================
|
|
170
|
-
export const PERMISSIONS = {
|
|
171
|
-
// Auth
|
|
172
|
-
USER: USER_PERMISSIONS,
|
|
173
|
-
COMPANY: COMPANY_PERMISSIONS,
|
|
174
|
-
BRANCH: BRANCH_PERMISSIONS,
|
|
175
|
-
// IAM
|
|
176
|
-
ACTION: ACTION_PERMISSIONS,
|
|
177
|
-
ROLE: ROLE_PERMISSIONS,
|
|
178
|
-
ROLE_ACTION: ROLE_ACTION_PERMISSIONS,
|
|
179
|
-
USER_ROLE: USER_ROLE_PERMISSIONS,
|
|
180
|
-
USER_ACTION: USER_ACTION_PERMISSIONS,
|
|
181
|
-
COMPANY_ACTION: COMPANY_ACTION_PERMISSIONS,
|
|
182
|
-
// Storage
|
|
183
|
-
FILE: FILE_PERMISSIONS,
|
|
184
|
-
FOLDER: FOLDER_PERMISSIONS,
|
|
185
|
-
STORAGE_CONFIG: STORAGE_CONFIG_PERMISSIONS,
|
|
186
|
-
// Email
|
|
187
|
-
EMAIL_CONFIG: EMAIL_CONFIG_PERMISSIONS,
|
|
188
|
-
EMAIL_TEMPLATE: EMAIL_TEMPLATE_PERMISSIONS,
|
|
189
|
-
// Form Builder
|
|
190
|
-
FORM: FORM_PERMISSIONS,
|
|
191
|
-
FORM_RESULT: FORM_RESULT_PERMISSIONS,
|
|
192
|
-
// Event Manager
|
|
193
|
-
EVENT: EVENT_PERMISSIONS,
|
|
194
|
-
// Notification
|
|
195
|
-
NOTIFICATION: NOTIFICATION_PERMISSIONS,
|
|
196
|
-
// Localization
|
|
197
|
-
LANGUAGE: LANGUAGE_PERMISSIONS,
|
|
198
|
-
TRANSLATION_KEY: TRANSLATION_KEY_PERMISSIONS,
|
|
199
|
-
TRANSLATION: TRANSLATION_PERMISSIONS,
|
|
200
|
-
// Task Manager
|
|
201
|
-
TASK_BOARD: TASK_BOARD_PERMISSIONS,
|
|
202
|
-
TASK_LIST: TASK_LIST_PERMISSIONS,
|
|
203
|
-
TASK: TASK_PERMISSIONS,
|
|
204
|
-
TASK_LABEL: TASK_LABEL_PERMISSIONS,
|
|
205
|
-
TASK_COMMENT: TASK_COMMENT_PERMISSIONS,
|
|
206
|
-
// AI Assistant
|
|
207
|
-
AI_ASSISTANT: AI_ASSISTANT_PERMISSIONS
|
|
208
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { BulkMetaDto, BulkResponseDto, ListResponseDto, PaginationMetaDto, SingleResponseDto } from '../dtos';
|
|
2
|
-
import { applyDecorators } from '@nestjs/common';
|
|
3
|
-
import { ApiExtraModels, ApiOkResponse, getSchemaPath } from '@nestjs/swagger';
|
|
4
|
-
export const ApiResponseDto = (dto, isArray = false, arrayType = 'list')=>{
|
|
5
|
-
let wrapperDto;
|
|
6
|
-
let metaDto = null;
|
|
7
|
-
if (!isArray || arrayType === 'single') {
|
|
8
|
-
wrapperDto = SingleResponseDto;
|
|
9
|
-
} else if (arrayType === 'bulk') {
|
|
10
|
-
wrapperDto = BulkResponseDto;
|
|
11
|
-
metaDto = BulkMetaDto;
|
|
12
|
-
} else {
|
|
13
|
-
wrapperDto = ListResponseDto;
|
|
14
|
-
metaDto = PaginationMetaDto;
|
|
15
|
-
}
|
|
16
|
-
return applyDecorators(ApiExtraModels(SingleResponseDto, ListResponseDto, BulkResponseDto, PaginationMetaDto, BulkMetaDto, dto), ApiOkResponse({
|
|
17
|
-
schema: {
|
|
18
|
-
allOf: [
|
|
19
|
-
{
|
|
20
|
-
$ref: getSchemaPath(wrapperDto)
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
properties: {
|
|
24
|
-
data: isArray ? {
|
|
25
|
-
type: 'array',
|
|
26
|
-
items: {
|
|
27
|
-
$ref: getSchemaPath(dto)
|
|
28
|
-
}
|
|
29
|
-
} : {
|
|
30
|
-
$ref: getSchemaPath(dto)
|
|
31
|
-
},
|
|
32
|
-
...metaDto ? {
|
|
33
|
-
meta: {
|
|
34
|
-
$ref: getSchemaPath(metaDto)
|
|
35
|
-
}
|
|
36
|
-
} : {}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
}));
|
|
42
|
-
};
|