@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,718 +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
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
15
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
17
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
18
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
|
-
}
|
|
20
|
-
function _ts_metadata(k, v) {
|
|
21
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
|
-
}
|
|
23
|
-
function _ts_param(paramIndex, decorator) {
|
|
24
|
-
return function(target, key) {
|
|
25
|
-
decorator(target, key, paramIndex);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
import { applyDecorators, Body, HttpCode, HttpStatus, Param, Post, Query, UseGuards, UseInterceptors, Version, VERSION_NEUTRAL } from '@nestjs/common';
|
|
29
|
-
import { ApiBearerAuth, ApiBody, ApiExcludeEndpoint, ApiHeader, ApiOperation, ApiParam, ApiQuery, ApiResponse } from '@nestjs/swagger';
|
|
30
|
-
import { plainToInstance } from 'class-transformer';
|
|
31
|
-
import { ERROR_MESSAGES } from '../constants/message-keys';
|
|
32
|
-
import { CurrentUser, Public, RequireAnyPermission, RequirePermission, RequirePermissionLogic } from '../decorators';
|
|
33
|
-
import { ApiResponseDto } from '../decorators/api-response.decorator';
|
|
34
|
-
import { DeleteDto, FilterAndPaginationDto, GetByIdBodyDto, GetByIdsDto } from '../dtos';
|
|
35
|
-
import { BaseAppException, NotFoundException } from '../exceptions';
|
|
36
|
-
import { JwtAuthGuard, PermissionGuard } from '../guards';
|
|
37
|
-
import { IdempotencyInterceptor, SetCreatedByOnBody, SetDeletedByOnBody, SetUpdateByOnBody, Slug } from '../interceptors';
|
|
38
|
-
/**
|
|
39
|
-
* Helper to normalize security config
|
|
40
|
-
*/ function normalizeSecurity(config) {
|
|
41
|
-
if (!config) return {
|
|
42
|
-
level: 'public'
|
|
43
|
-
};
|
|
44
|
-
if (typeof config === 'string') return {
|
|
45
|
-
level: config
|
|
46
|
-
};
|
|
47
|
-
return config;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Helper to check if endpoint is enabled
|
|
51
|
-
*/ function isEndpointEnabled(endpoint, enabledEndpoints) {
|
|
52
|
-
if (!enabledEndpoints || enabledEndpoints === 'all') return true;
|
|
53
|
-
return enabledEndpoints.includes(endpoint);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Helper to conditionally exclude endpoint from Swagger if disabled
|
|
57
|
-
*/ function createEndpointDecorators(security, endpoint, enabledEndpoints) {
|
|
58
|
-
const decorators = [];
|
|
59
|
-
// Add security decorators
|
|
60
|
-
decorators.push(createSecurityDecorators(security));
|
|
61
|
-
// Exclude from Swagger if endpoint is disabled
|
|
62
|
-
if (!isEndpointEnabled(endpoint, enabledEndpoints)) {
|
|
63
|
-
decorators.push(ApiExcludeEndpoint());
|
|
64
|
-
}
|
|
65
|
-
return applyDecorators(...decorators);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Creates security decorators based on configuration
|
|
69
|
-
*/ function createSecurityDecorators(security) {
|
|
70
|
-
const decorators = [];
|
|
71
|
-
switch(security.level){
|
|
72
|
-
case 'public':
|
|
73
|
-
decorators.push(Public());
|
|
74
|
-
break;
|
|
75
|
-
case 'jwt':
|
|
76
|
-
// Apply JWT authentication guard
|
|
77
|
-
decorators.push(UseGuards(JwtAuthGuard));
|
|
78
|
-
decorators.push(ApiBearerAuth());
|
|
79
|
-
break;
|
|
80
|
-
case 'permission':
|
|
81
|
-
// Apply JWT authentication guard (required for permission checks)
|
|
82
|
-
// Apply PermissionGuard to check permissions from cache
|
|
83
|
-
decorators.push(UseGuards(JwtAuthGuard, PermissionGuard));
|
|
84
|
-
decorators.push(ApiBearerAuth());
|
|
85
|
-
// Check for complex logic first
|
|
86
|
-
if (security.logic) {
|
|
87
|
-
decorators.push(RequirePermissionLogic(security.logic));
|
|
88
|
-
} else if (security.permissions && security.permissions.length > 0) {
|
|
89
|
-
if (security.operator === 'OR') {
|
|
90
|
-
decorators.push(RequireAnyPermission(...security.permissions));
|
|
91
|
-
} else {
|
|
92
|
-
// AND is default and most secure
|
|
93
|
-
decorators.push(RequirePermission(...security.permissions));
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
return applyDecorators(...decorators);
|
|
99
|
-
}
|
|
100
|
-
/** Creates an API Controller with standardized CRUD endpoints (POST-only RPC pattern) */ export function createApiController(createDtoClass, updateDtoClass, responseDtoClass, options = {}) {
|
|
101
|
-
const excludeExtraneousValues = options.excludeExtraneousValues ?? true;
|
|
102
|
-
function toDto(cls, input) {
|
|
103
|
-
return plainToInstance(cls, input, {
|
|
104
|
-
excludeExtraneousValues
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
// Entity name for message keys (defaults to 'item')
|
|
108
|
-
const entityName = options.entityName ?? 'item';
|
|
109
|
-
// Determine if security is global (applies to all) or per-endpoint
|
|
110
|
-
const securityConfig = options.security;
|
|
111
|
-
const endpointKeys = [
|
|
112
|
-
'insert',
|
|
113
|
-
'insertMany',
|
|
114
|
-
'getById',
|
|
115
|
-
'getByIds',
|
|
116
|
-
'getAll',
|
|
117
|
-
'bulkUpsert',
|
|
118
|
-
'getByFilter',
|
|
119
|
-
'update',
|
|
120
|
-
'updateMany',
|
|
121
|
-
'delete'
|
|
122
|
-
];
|
|
123
|
-
// Global security if:
|
|
124
|
-
// 1. It's a string (SecurityLevel)
|
|
125
|
-
// 2. It's an object with 'level' property but no endpoint keys
|
|
126
|
-
const isGlobalSecurity = typeof securityConfig === 'string' || securityConfig && typeof securityConfig === 'object' && 'level' in securityConfig && !endpointKeys.some((key)=>key in securityConfig);
|
|
127
|
-
// Normalize security config for each endpoint
|
|
128
|
-
// IMPORTANT: When per-endpoint security is specified, default to 'jwt' for unconfigured endpoints
|
|
129
|
-
// to prevent accidentally exposing endpoints without authentication
|
|
130
|
-
const defaultSecurity = isGlobalSecurity ? normalizeSecurity(securityConfig) : {
|
|
131
|
-
level: 'jwt'
|
|
132
|
-
};
|
|
133
|
-
const security = {
|
|
134
|
-
insert: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.insert),
|
|
135
|
-
insertMany: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.insertMany),
|
|
136
|
-
getById: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.getById),
|
|
137
|
-
getByIds: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.getByIds),
|
|
138
|
-
getAll: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.getAll),
|
|
139
|
-
getByFilter: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.getByFilter),
|
|
140
|
-
bulkUpsert: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.bulkUpsert),
|
|
141
|
-
update: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.update),
|
|
142
|
-
updateMany: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.updateMany),
|
|
143
|
-
delete: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.delete)
|
|
144
|
-
};
|
|
145
|
-
let ApiController = class ApiController {
|
|
146
|
-
isEnabled(endpoint) {
|
|
147
|
-
if (this.enabledEndpoints === 'all') return true;
|
|
148
|
-
return Array.isArray(this.enabledEndpoints) && this.enabledEndpoints.includes(endpoint);
|
|
149
|
-
}
|
|
150
|
-
async insert(addDto, user) {
|
|
151
|
-
if (!this.isEnabled('insert')) {
|
|
152
|
-
throw new BaseAppException({
|
|
153
|
-
message: `Endpoint 'insert' is disabled`,
|
|
154
|
-
messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
|
|
155
|
-
messageVariables: {
|
|
156
|
-
endpoint: 'insert'
|
|
157
|
-
},
|
|
158
|
-
status: HttpStatus.FORBIDDEN
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
const entity = await this.service.insert(addDto, user);
|
|
162
|
-
const data = toDto(responseDtoClass, entity);
|
|
163
|
-
return {
|
|
164
|
-
success: true,
|
|
165
|
-
message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)} created successfully`,
|
|
166
|
-
messageKey: `${entityName}.create.success`,
|
|
167
|
-
data
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
async insertMany(addDto, user) {
|
|
171
|
-
if (!this.isEnabled('insertMany')) {
|
|
172
|
-
throw new BaseAppException({
|
|
173
|
-
message: `Endpoint 'insertMany' is disabled`,
|
|
174
|
-
messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
|
|
175
|
-
messageVariables: {
|
|
176
|
-
endpoint: 'insertMany'
|
|
177
|
-
},
|
|
178
|
-
status: HttpStatus.FORBIDDEN
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
const entities = await this.service.insertMany(addDto, user);
|
|
182
|
-
const data = entities.map((item)=>toDto(responseDtoClass, item));
|
|
183
|
-
return {
|
|
184
|
-
success: true,
|
|
185
|
-
message: `${data.length} ${entityName}s created successfully`,
|
|
186
|
-
messageKey: `${entityName}.create.many.success`,
|
|
187
|
-
messageVariables: {
|
|
188
|
-
count: data.length
|
|
189
|
-
},
|
|
190
|
-
data,
|
|
191
|
-
meta: {
|
|
192
|
-
count: data.length,
|
|
193
|
-
total: addDto.length,
|
|
194
|
-
failed: addDto.length - data.length
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
async getById(id, body, user) {
|
|
199
|
-
if (!this.isEnabled('getById')) {
|
|
200
|
-
throw new BaseAppException({
|
|
201
|
-
message: `Endpoint 'getById' is disabled`,
|
|
202
|
-
messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
|
|
203
|
-
messageVariables: {
|
|
204
|
-
endpoint: 'getById'
|
|
205
|
-
},
|
|
206
|
-
status: HttpStatus.FORBIDDEN
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
const entity = await this.service.findById(id, user, body?.select);
|
|
210
|
-
const data = toDto(responseDtoClass, entity);
|
|
211
|
-
return {
|
|
212
|
-
success: true,
|
|
213
|
-
message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)} retrieved successfully`,
|
|
214
|
-
messageKey: `${entityName}.get.success`,
|
|
215
|
-
data
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
async getByIds(body, user) {
|
|
219
|
-
if (!this.isEnabled('getByIds')) {
|
|
220
|
-
throw new BaseAppException({
|
|
221
|
-
message: `Endpoint 'getByIds' is disabled`,
|
|
222
|
-
messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
|
|
223
|
-
messageVariables: {
|
|
224
|
-
endpoint: 'getByIds'
|
|
225
|
-
},
|
|
226
|
-
status: HttpStatus.FORBIDDEN
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
const entities = await this.service.findByIds(body.ids, user, body?.select);
|
|
230
|
-
const data = entities.map((item)=>toDto(responseDtoClass, item));
|
|
231
|
-
return {
|
|
232
|
-
success: true,
|
|
233
|
-
message: `${data.length} ${entityName}${data.length !== 1 ? 's' : ''} retrieved successfully`,
|
|
234
|
-
messageKey: `${entityName}.get.by.ids.success`,
|
|
235
|
-
data,
|
|
236
|
-
meta: {
|
|
237
|
-
total: data.length,
|
|
238
|
-
page: 0,
|
|
239
|
-
pageSize: data.length,
|
|
240
|
-
count: data.length,
|
|
241
|
-
totalPages: 1
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
async update(updateDto, user) {
|
|
246
|
-
if (!this.isEnabled('update')) {
|
|
247
|
-
throw new BaseAppException({
|
|
248
|
-
message: `Endpoint 'update' is disabled`,
|
|
249
|
-
messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
|
|
250
|
-
messageVariables: {
|
|
251
|
-
endpoint: 'update'
|
|
252
|
-
},
|
|
253
|
-
status: HttpStatus.FORBIDDEN
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
const entity = await this.service.update(updateDto, user);
|
|
257
|
-
const data = toDto(responseDtoClass, entity);
|
|
258
|
-
return {
|
|
259
|
-
success: true,
|
|
260
|
-
message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)} updated successfully`,
|
|
261
|
-
messageKey: `${entityName}.update.success`,
|
|
262
|
-
data
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
async updateMany(updateDtos, user) {
|
|
266
|
-
if (!this.isEnabled('updateMany')) {
|
|
267
|
-
throw new BaseAppException({
|
|
268
|
-
message: `Endpoint 'updateMany' is disabled`,
|
|
269
|
-
messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
|
|
270
|
-
messageVariables: {
|
|
271
|
-
endpoint: 'updateMany'
|
|
272
|
-
},
|
|
273
|
-
status: HttpStatus.FORBIDDEN
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
const entities = await this.service.updateMany(updateDtos, user);
|
|
277
|
-
const data = entities.map((item)=>toDto(responseDtoClass, item));
|
|
278
|
-
return {
|
|
279
|
-
success: true,
|
|
280
|
-
message: `${data.length} ${entityName}s updated successfully`,
|
|
281
|
-
messageKey: `${entityName}.update.many.success`,
|
|
282
|
-
messageVariables: {
|
|
283
|
-
count: data.length
|
|
284
|
-
},
|
|
285
|
-
data,
|
|
286
|
-
meta: {
|
|
287
|
-
count: data.length,
|
|
288
|
-
total: updateDtos.length,
|
|
289
|
-
failed: updateDtos.length - data.length
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
async bulkUpsert(dtos, user) {
|
|
294
|
-
if (!this.isEnabled('bulkUpsert')) {
|
|
295
|
-
throw new BaseAppException({
|
|
296
|
-
message: `Endpoint 'bulkUpsert' is disabled`,
|
|
297
|
-
messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
|
|
298
|
-
messageVariables: {
|
|
299
|
-
endpoint: 'bulkUpsert'
|
|
300
|
-
},
|
|
301
|
-
status: HttpStatus.FORBIDDEN
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
const toInsert = [];
|
|
305
|
-
const toUpdate = [];
|
|
306
|
-
for (const dto of dtos){
|
|
307
|
-
if ('id' in dto && dto.id) {
|
|
308
|
-
toUpdate.push(dto);
|
|
309
|
-
} else {
|
|
310
|
-
toInsert.push(dto);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
const allEntities = await this.service.bulkUpsert(toInsert, toUpdate, user);
|
|
314
|
-
const data = allEntities.map((item)=>toDto(responseDtoClass, item));
|
|
315
|
-
return {
|
|
316
|
-
success: true,
|
|
317
|
-
message: `${data.length} ${entityName}s upserted successfully`,
|
|
318
|
-
messageKey: `${entityName}.upsert.many.success`,
|
|
319
|
-
messageVariables: {
|
|
320
|
-
count: data.length
|
|
321
|
-
},
|
|
322
|
-
data,
|
|
323
|
-
meta: {
|
|
324
|
-
count: data.length,
|
|
325
|
-
total: dtos.length,
|
|
326
|
-
failed: dtos.length - data.length
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
async getByFilter(filter, user) {
|
|
331
|
-
if (!this.isEnabled('getByFilter')) {
|
|
332
|
-
throw new BaseAppException({
|
|
333
|
-
message: `Endpoint 'getByFilter' is disabled`,
|
|
334
|
-
messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
|
|
335
|
-
messageVariables: {
|
|
336
|
-
endpoint: 'getByFilter'
|
|
337
|
-
},
|
|
338
|
-
status: HttpStatus.FORBIDDEN
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
const result = await this.service.getAll('', {
|
|
342
|
-
filter,
|
|
343
|
-
pagination: {
|
|
344
|
-
currentPage: 0,
|
|
345
|
-
pageSize: 1
|
|
346
|
-
}
|
|
347
|
-
}, user);
|
|
348
|
-
if (!result.data || result.data.length === 0) {
|
|
349
|
-
throw new NotFoundException(entityName);
|
|
350
|
-
}
|
|
351
|
-
const entity = result.data[0];
|
|
352
|
-
const data = toDto(responseDtoClass, entity);
|
|
353
|
-
return {
|
|
354
|
-
success: true,
|
|
355
|
-
message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)} retrieved successfully`,
|
|
356
|
-
messageKey: `${entityName}.get.by.filter.success`,
|
|
357
|
-
data
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
async getAll(filterAndPaginationDto, user, search) {
|
|
361
|
-
if (!this.isEnabled('getAll')) {
|
|
362
|
-
throw new BaseAppException({
|
|
363
|
-
message: `Endpoint 'getAll' is disabled`,
|
|
364
|
-
messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
|
|
365
|
-
messageVariables: {
|
|
366
|
-
endpoint: 'getAll'
|
|
367
|
-
},
|
|
368
|
-
status: HttpStatus.FORBIDDEN
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
const result = await this.service.getAll(search ?? '', filterAndPaginationDto, user);
|
|
372
|
-
const data = result.data.map((item)=>toDto(responseDtoClass, item));
|
|
373
|
-
const page = filterAndPaginationDto.pagination?.currentPage ?? 0;
|
|
374
|
-
const pageSize = filterAndPaginationDto.pagination?.pageSize ?? data.length;
|
|
375
|
-
const totalPages = pageSize > 0 ? Math.ceil(result.total / pageSize) : 1;
|
|
376
|
-
return {
|
|
377
|
-
success: true,
|
|
378
|
-
message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)}s retrieved successfully`,
|
|
379
|
-
messageKey: `${entityName}.get.all.success`,
|
|
380
|
-
data,
|
|
381
|
-
meta: {
|
|
382
|
-
total: result.total,
|
|
383
|
-
page,
|
|
384
|
-
pageSize,
|
|
385
|
-
count: data.length,
|
|
386
|
-
hasMore: page < totalPages - 1,
|
|
387
|
-
totalPages
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
async delete(deleteDto, user) {
|
|
392
|
-
if (!this.isEnabled('delete')) {
|
|
393
|
-
throw new BaseAppException({
|
|
394
|
-
message: `Endpoint 'delete' is disabled`,
|
|
395
|
-
messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
|
|
396
|
-
messageVariables: {
|
|
397
|
-
endpoint: 'delete'
|
|
398
|
-
},
|
|
399
|
-
status: HttpStatus.FORBIDDEN
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
await this.service.delete(deleteDto, user);
|
|
403
|
-
const count = Array.isArray(deleteDto.id) ? deleteDto.id.length : 1;
|
|
404
|
-
const action = deleteDto.type === 'restore' ? 'restore' : 'delete';
|
|
405
|
-
return {
|
|
406
|
-
success: true,
|
|
407
|
-
message: `${count} ${entityName}${count > 1 ? 's' : ''} ${action}d successfully`,
|
|
408
|
-
messageKey: `${entityName}.${action}.success`,
|
|
409
|
-
messageVariables: {
|
|
410
|
-
count
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
constructor(service){
|
|
415
|
-
_define_property(this, "service", void 0);
|
|
416
|
-
_define_property(this, "enabledEndpoints", void 0);
|
|
417
|
-
this.service = service;
|
|
418
|
-
this.enabledEndpoints = options.enabledEndpoints ?? 'all';
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
_ts_decorate([
|
|
422
|
-
createEndpointDecorators(security.insert, 'insert', options.enabledEndpoints),
|
|
423
|
-
Version(VERSION_NEUTRAL),
|
|
424
|
-
Post('insert'),
|
|
425
|
-
HttpCode(HttpStatus.CREATED),
|
|
426
|
-
ApiOperation({
|
|
427
|
-
summary: 'Insert one item',
|
|
428
|
-
description: 'Creates a new item. Supports idempotency via X-Idempotency-Key header.'
|
|
429
|
-
}),
|
|
430
|
-
ApiHeader({
|
|
431
|
-
name: 'X-Idempotency-Key',
|
|
432
|
-
required: false,
|
|
433
|
-
description: 'Unique key to prevent duplicate submissions (recommended for production)'
|
|
434
|
-
}),
|
|
435
|
-
ApiResponseDto(responseDtoClass),
|
|
436
|
-
ApiBody({
|
|
437
|
-
type: createDtoClass
|
|
438
|
-
}),
|
|
439
|
-
UseInterceptors(IdempotencyInterceptor, SetCreatedByOnBody, Slug),
|
|
440
|
-
_ts_param(0, Body()),
|
|
441
|
-
_ts_param(1, CurrentUser()),
|
|
442
|
-
_ts_metadata("design:type", Function),
|
|
443
|
-
_ts_metadata("design:paramtypes", [
|
|
444
|
-
typeof CreateDtoT === "undefined" ? Object : CreateDtoT,
|
|
445
|
-
Object
|
|
446
|
-
]),
|
|
447
|
-
_ts_metadata("design:returntype", Promise)
|
|
448
|
-
], ApiController.prototype, "insert", null);
|
|
449
|
-
_ts_decorate([
|
|
450
|
-
createEndpointDecorators(security.insertMany, 'insertMany', options.enabledEndpoints),
|
|
451
|
-
Version(VERSION_NEUTRAL),
|
|
452
|
-
Post('insert-many'),
|
|
453
|
-
HttpCode(HttpStatus.CREATED),
|
|
454
|
-
ApiOperation({
|
|
455
|
-
summary: 'Insert multiple items',
|
|
456
|
-
description: 'Creates multiple items in a single request. Supports idempotency.'
|
|
457
|
-
}),
|
|
458
|
-
ApiHeader({
|
|
459
|
-
name: 'X-Idempotency-Key',
|
|
460
|
-
required: false,
|
|
461
|
-
description: 'Unique key to prevent duplicate submissions'
|
|
462
|
-
}),
|
|
463
|
-
ApiResponseDto(responseDtoClass, true, 'bulk'),
|
|
464
|
-
ApiBody({
|
|
465
|
-
type: createDtoClass,
|
|
466
|
-
isArray: true
|
|
467
|
-
}),
|
|
468
|
-
UseInterceptors(IdempotencyInterceptor, SetCreatedByOnBody, Slug),
|
|
469
|
-
_ts_param(0, Body()),
|
|
470
|
-
_ts_param(1, CurrentUser()),
|
|
471
|
-
_ts_metadata("design:type", Function),
|
|
472
|
-
_ts_metadata("design:paramtypes", [
|
|
473
|
-
Array,
|
|
474
|
-
Object
|
|
475
|
-
]),
|
|
476
|
-
_ts_metadata("design:returntype", Promise)
|
|
477
|
-
], ApiController.prototype, "insertMany", null);
|
|
478
|
-
_ts_decorate([
|
|
479
|
-
createEndpointDecorators(security.getById, 'getById', options.enabledEndpoints),
|
|
480
|
-
Version(VERSION_NEUTRAL),
|
|
481
|
-
Post('get/:id'),
|
|
482
|
-
HttpCode(HttpStatus.OK),
|
|
483
|
-
ApiOperation({
|
|
484
|
-
summary: 'Get item by ID',
|
|
485
|
-
description: 'Retrieves a single item by ID. Optionally specify fields to select and relations to include.'
|
|
486
|
-
}),
|
|
487
|
-
ApiParam({
|
|
488
|
-
name: 'id',
|
|
489
|
-
type: String,
|
|
490
|
-
description: 'UUID of the item'
|
|
491
|
-
}),
|
|
492
|
-
ApiBody({
|
|
493
|
-
type: GetByIdBodyDto,
|
|
494
|
-
required: false
|
|
495
|
-
}),
|
|
496
|
-
ApiResponseDto(responseDtoClass),
|
|
497
|
-
_ts_param(0, Param('id')),
|
|
498
|
-
_ts_param(1, Body()),
|
|
499
|
-
_ts_param(2, CurrentUser()),
|
|
500
|
-
_ts_metadata("design:type", Function),
|
|
501
|
-
_ts_metadata("design:paramtypes", [
|
|
502
|
-
String,
|
|
503
|
-
typeof GetByIdBodyDto === "undefined" ? Object : GetByIdBodyDto,
|
|
504
|
-
Object
|
|
505
|
-
]),
|
|
506
|
-
_ts_metadata("design:returntype", Promise)
|
|
507
|
-
], ApiController.prototype, "getById", null);
|
|
508
|
-
_ts_decorate([
|
|
509
|
-
createEndpointDecorators(security.getByIds, 'getByIds', options.enabledEndpoints),
|
|
510
|
-
Version(VERSION_NEUTRAL),
|
|
511
|
-
Post('get-by-ids'),
|
|
512
|
-
HttpCode(HttpStatus.OK),
|
|
513
|
-
ApiOperation({
|
|
514
|
-
summary: 'Get items by IDs',
|
|
515
|
-
description: 'Retrieves multiple items by their IDs. Optionally specify fields to select.'
|
|
516
|
-
}),
|
|
517
|
-
ApiBody({
|
|
518
|
-
type: GetByIdsDto
|
|
519
|
-
}),
|
|
520
|
-
ApiResponseDto(responseDtoClass, true, 'list'),
|
|
521
|
-
_ts_param(0, Body()),
|
|
522
|
-
_ts_param(1, CurrentUser()),
|
|
523
|
-
_ts_metadata("design:type", Function),
|
|
524
|
-
_ts_metadata("design:paramtypes", [
|
|
525
|
-
typeof GetByIdsDto === "undefined" ? Object : GetByIdsDto,
|
|
526
|
-
Object
|
|
527
|
-
]),
|
|
528
|
-
_ts_metadata("design:returntype", Promise)
|
|
529
|
-
], ApiController.prototype, "getByIds", null);
|
|
530
|
-
_ts_decorate([
|
|
531
|
-
createEndpointDecorators(security.update, 'update', options.enabledEndpoints),
|
|
532
|
-
Version(VERSION_NEUTRAL),
|
|
533
|
-
Post('update'),
|
|
534
|
-
HttpCode(HttpStatus.OK),
|
|
535
|
-
ApiOperation({
|
|
536
|
-
summary: 'Update one item',
|
|
537
|
-
description: 'Updates an existing item. ID must be included in the body.'
|
|
538
|
-
}),
|
|
539
|
-
ApiResponseDto(responseDtoClass),
|
|
540
|
-
ApiBody({
|
|
541
|
-
type: updateDtoClass
|
|
542
|
-
}),
|
|
543
|
-
UseInterceptors(SetUpdateByOnBody, Slug),
|
|
544
|
-
_ts_param(0, Body()),
|
|
545
|
-
_ts_param(1, CurrentUser()),
|
|
546
|
-
_ts_metadata("design:type", Function),
|
|
547
|
-
_ts_metadata("design:paramtypes", [
|
|
548
|
-
typeof UpdateDtoT === "undefined" ? Object : UpdateDtoT,
|
|
549
|
-
Object
|
|
550
|
-
]),
|
|
551
|
-
_ts_metadata("design:returntype", Promise)
|
|
552
|
-
], ApiController.prototype, "update", null);
|
|
553
|
-
_ts_decorate([
|
|
554
|
-
createEndpointDecorators(security.updateMany, 'updateMany', options.enabledEndpoints),
|
|
555
|
-
Version(VERSION_NEUTRAL),
|
|
556
|
-
Post('update-many'),
|
|
557
|
-
HttpCode(HttpStatus.OK),
|
|
558
|
-
ApiOperation({
|
|
559
|
-
summary: 'Update multiple items',
|
|
560
|
-
description: 'Updates multiple items in a single request. Each item must include an ID.'
|
|
561
|
-
}),
|
|
562
|
-
ApiResponseDto(responseDtoClass, true, 'bulk'),
|
|
563
|
-
ApiBody({
|
|
564
|
-
type: updateDtoClass,
|
|
565
|
-
isArray: true
|
|
566
|
-
}),
|
|
567
|
-
UseInterceptors(SetUpdateByOnBody, Slug),
|
|
568
|
-
_ts_param(0, Body()),
|
|
569
|
-
_ts_param(1, CurrentUser()),
|
|
570
|
-
_ts_metadata("design:type", Function),
|
|
571
|
-
_ts_metadata("design:paramtypes", [
|
|
572
|
-
Array,
|
|
573
|
-
Object
|
|
574
|
-
]),
|
|
575
|
-
_ts_metadata("design:returntype", Promise)
|
|
576
|
-
], ApiController.prototype, "updateMany", null);
|
|
577
|
-
_ts_decorate([
|
|
578
|
-
createEndpointDecorators(security.bulkUpsert, 'bulkUpsert', options.enabledEndpoints),
|
|
579
|
-
Version(VERSION_NEUTRAL),
|
|
580
|
-
Post('bulk-upsert'),
|
|
581
|
-
HttpCode(HttpStatus.OK),
|
|
582
|
-
ApiOperation({
|
|
583
|
-
summary: 'Create or update multiple items',
|
|
584
|
-
description: 'Bulk upsert: items without ID are created, items with ID are updated.'
|
|
585
|
-
}),
|
|
586
|
-
ApiResponseDto(responseDtoClass, true, 'bulk'),
|
|
587
|
-
ApiBody({
|
|
588
|
-
type: createDtoClass,
|
|
589
|
-
isArray: true
|
|
590
|
-
}),
|
|
591
|
-
UseInterceptors(SetCreatedByOnBody, SetUpdateByOnBody, Slug),
|
|
592
|
-
_ts_param(0, Body()),
|
|
593
|
-
_ts_param(1, CurrentUser()),
|
|
594
|
-
_ts_metadata("design:type", Function),
|
|
595
|
-
_ts_metadata("design:paramtypes", [
|
|
596
|
-
Array,
|
|
597
|
-
Object
|
|
598
|
-
]),
|
|
599
|
-
_ts_metadata("design:returntype", Promise)
|
|
600
|
-
], ApiController.prototype, "bulkUpsert", null);
|
|
601
|
-
_ts_decorate([
|
|
602
|
-
createEndpointDecorators(security.getByFilter, 'getByFilter', options.enabledEndpoints),
|
|
603
|
-
Version(VERSION_NEUTRAL),
|
|
604
|
-
Post('get-by-filter'),
|
|
605
|
-
HttpCode(HttpStatus.OK),
|
|
606
|
-
ApiOperation({
|
|
607
|
-
summary: 'Get single item by filter',
|
|
608
|
-
description: 'Retrieves a single item matching the provided filter criteria. Returns first match if multiple exist.'
|
|
609
|
-
}),
|
|
610
|
-
ApiBody({
|
|
611
|
-
schema: {
|
|
612
|
-
type: 'object',
|
|
613
|
-
description: 'Filter criteria'
|
|
614
|
-
}
|
|
615
|
-
}),
|
|
616
|
-
ApiResponseDto(responseDtoClass),
|
|
617
|
-
_ts_param(0, Body()),
|
|
618
|
-
_ts_param(1, CurrentUser()),
|
|
619
|
-
_ts_metadata("design:type", Function),
|
|
620
|
-
_ts_metadata("design:paramtypes", [
|
|
621
|
-
typeof Record === "undefined" ? Object : Record,
|
|
622
|
-
Object
|
|
623
|
-
]),
|
|
624
|
-
_ts_metadata("design:returntype", Promise)
|
|
625
|
-
], ApiController.prototype, "getByFilter", null);
|
|
626
|
-
_ts_decorate([
|
|
627
|
-
createEndpointDecorators(security.getAll, 'getAll', options.enabledEndpoints),
|
|
628
|
-
Version(VERSION_NEUTRAL),
|
|
629
|
-
Post('get-all'),
|
|
630
|
-
HttpCode(HttpStatus.OK),
|
|
631
|
-
ApiOperation({
|
|
632
|
-
summary: 'Get all items with filters and pagination',
|
|
633
|
-
description: 'Supports filter, pagination, sort, select, withDeleted, and q (search) params'
|
|
634
|
-
}),
|
|
635
|
-
ApiQuery({
|
|
636
|
-
name: 'q',
|
|
637
|
-
required: false,
|
|
638
|
-
description: 'Global text search across searchable fields'
|
|
639
|
-
}),
|
|
640
|
-
ApiBody({
|
|
641
|
-
type: FilterAndPaginationDto
|
|
642
|
-
}),
|
|
643
|
-
ApiResponseDto(responseDtoClass, true, 'list'),
|
|
644
|
-
_ts_param(0, Body()),
|
|
645
|
-
_ts_param(1, CurrentUser()),
|
|
646
|
-
_ts_param(2, Query('q')),
|
|
647
|
-
_ts_metadata("design:type", Function),
|
|
648
|
-
_ts_metadata("design:paramtypes", [
|
|
649
|
-
typeof FilterAndPaginationDto === "undefined" ? Object : FilterAndPaginationDto,
|
|
650
|
-
Object,
|
|
651
|
-
String
|
|
652
|
-
]),
|
|
653
|
-
_ts_metadata("design:returntype", Promise)
|
|
654
|
-
], ApiController.prototype, "getAll", null);
|
|
655
|
-
_ts_decorate([
|
|
656
|
-
createEndpointDecorators(security.delete, 'delete', options.enabledEndpoints),
|
|
657
|
-
Version(VERSION_NEUTRAL),
|
|
658
|
-
Post('delete'),
|
|
659
|
-
HttpCode(HttpStatus.OK),
|
|
660
|
-
ApiOperation({
|
|
661
|
-
summary: 'Delete, restore, or permanently remove items',
|
|
662
|
-
description: 'Types: delete (soft), restore, permanent. Supports batch IDs.'
|
|
663
|
-
}),
|
|
664
|
-
ApiResponse({
|
|
665
|
-
status: 200,
|
|
666
|
-
description: 'Operation completed successfully',
|
|
667
|
-
schema: {
|
|
668
|
-
example: {
|
|
669
|
-
success: true,
|
|
670
|
-
message: '3 items deleted successfully'
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}),
|
|
674
|
-
ApiBody({
|
|
675
|
-
type: DeleteDto,
|
|
676
|
-
examples: {
|
|
677
|
-
softDelete: {
|
|
678
|
-
summary: 'Soft delete',
|
|
679
|
-
value: {
|
|
680
|
-
id: [
|
|
681
|
-
'uuid-1',
|
|
682
|
-
'uuid-2'
|
|
683
|
-
],
|
|
684
|
-
type: 'delete'
|
|
685
|
-
}
|
|
686
|
-
},
|
|
687
|
-
restore: {
|
|
688
|
-
summary: 'Restore deleted',
|
|
689
|
-
value: {
|
|
690
|
-
id: [
|
|
691
|
-
'uuid-1'
|
|
692
|
-
],
|
|
693
|
-
type: 'restore'
|
|
694
|
-
}
|
|
695
|
-
},
|
|
696
|
-
permanent: {
|
|
697
|
-
summary: 'Permanent delete',
|
|
698
|
-
value: {
|
|
699
|
-
id: [
|
|
700
|
-
'uuid-1'
|
|
701
|
-
],
|
|
702
|
-
type: 'permanent'
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
}),
|
|
707
|
-
UseInterceptors(SetDeletedByOnBody),
|
|
708
|
-
_ts_param(0, Body()),
|
|
709
|
-
_ts_param(1, CurrentUser()),
|
|
710
|
-
_ts_metadata("design:type", Function),
|
|
711
|
-
_ts_metadata("design:paramtypes", [
|
|
712
|
-
typeof DeleteDto === "undefined" ? Object : DeleteDto,
|
|
713
|
-
Object
|
|
714
|
-
]),
|
|
715
|
-
_ts_metadata("design:returntype", Promise)
|
|
716
|
-
], ApiController.prototype, "delete", null);
|
|
717
|
-
return ApiController;
|
|
718
|
-
}
|