@flusys/nestjs-shared 1.1.0-beta → 1.2.0-rc.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/README.md +146 -1330
- package/cjs/classes/api-controller.class.js +325 -49
- package/cjs/classes/api-service.class.js +271 -149
- package/cjs/classes/handle-custome-db.js +37 -0
- package/cjs/classes/index.js +2 -2
- package/cjs/classes/winston.logger.class.js +103 -70
- package/cjs/constants/index.js +15 -4
- package/cjs/constants/message-keys.js +68 -0
- package/cjs/constants/permissions.js +287 -0
- package/cjs/decorators/api-response.decorator.js +2 -3
- package/cjs/decorators/index.js +1 -0
- package/cjs/decorators/log-action.decorator.js +149 -0
- package/cjs/decorators/require-permission.decorator.js +5 -5
- package/cjs/dtos/delete.dto.js +10 -0
- package/cjs/dtos/filter-and-pagination.dto.js +24 -34
- package/cjs/dtos/get-by-ids.dto.js +65 -0
- package/cjs/dtos/identity-response.dto.js +4 -8
- package/cjs/dtos/index.js +1 -0
- package/cjs/dtos/pagination.dto.js +4 -8
- package/cjs/dtos/response-payload.dto.js +68 -112
- package/cjs/entities/identity.js +12 -6
- package/cjs/entities/index.js +1 -0
- package/cjs/entities/raw-type.js +4 -0
- package/cjs/entities/user-root.js +15 -15
- package/cjs/enums/index.js +20 -0
- package/cjs/enums/notification-type.enum.js +17 -0
- package/cjs/enums/participant-status.enum.js +17 -0
- package/cjs/enums/recurrence-type.enum.js +18 -0
- package/cjs/exceptions/base-app.exception.js +151 -0
- package/cjs/exceptions/index.js +1 -0
- package/cjs/exceptions/permission.exception.js +13 -9
- package/cjs/filters/global-exception.filter.js +279 -0
- package/cjs/filters/index.js +18 -0
- package/cjs/guards/jwt-auth.guard.js +4 -1
- package/cjs/guards/permission.guard.js +88 -148
- package/cjs/index.js +2 -0
- package/cjs/interceptors/idempotency.interceptor.js +1 -1
- package/cjs/interceptors/index.js +1 -4
- package/cjs/interceptors/set-user-field-on-body.interceptor.js +60 -0
- package/cjs/interceptors/slug.interceptor.js +30 -9
- package/cjs/interfaces/datasource.interface.js +4 -0
- package/cjs/interfaces/event-manager-adapter.interface.js +11 -0
- package/cjs/interfaces/index.js +4 -2
- package/cjs/interfaces/module-config.interface.js +4 -0
- package/cjs/interfaces/notification-adapter.interface.js +11 -0
- package/cjs/interfaces/permission.interface.js +1 -1
- package/cjs/middlewares/logger.middleware.js +133 -115
- package/cjs/modules/cache/cache.module.js +3 -3
- package/cjs/modules/datasource/index.js +0 -1
- package/cjs/modules/datasource/multi-tenant-datasource.service.js +60 -183
- package/cjs/modules/utils/utils.service.js +27 -206
- package/cjs/utils/date-time.util.js +94 -0
- package/cjs/utils/html-sanitizer.util.js +64 -0
- package/cjs/utils/index.js +5 -1
- package/cjs/utils/query-helpers.util.js +60 -0
- package/cjs/utils/request.util.js +96 -0
- package/cjs/utils/string.util.js +63 -0
- package/classes/api-controller.class.d.ts +16 -8
- package/classes/api-service.class.d.ts +30 -25
- package/classes/handle-custome-db.d.ts +3 -0
- package/classes/index.d.ts +2 -2
- package/classes/winston.logger.class.d.ts +1 -0
- package/constants/index.d.ts +2 -1
- package/constants/message-keys.d.ts +45 -0
- package/constants/permissions.d.ts +306 -0
- package/decorators/api-response.decorator.d.ts +1 -1
- package/decorators/current-user.decorator.d.ts +1 -1
- package/decorators/index.d.ts +1 -0
- package/decorators/log-action.decorator.d.ts +8 -0
- package/decorators/require-permission.decorator.d.ts +2 -2
- package/dtos/delete.dto.d.ts +1 -0
- package/dtos/filter-and-pagination.dto.d.ts +0 -2
- package/dtos/get-by-ids.dto.d.ts +4 -0
- package/dtos/index.d.ts +1 -0
- package/dtos/response-payload.dto.d.ts +8 -20
- package/entities/index.d.ts +1 -0
- package/entities/raw-type.d.ts +1 -0
- package/enums/index.d.ts +3 -0
- package/enums/notification-type.enum.d.ts +6 -0
- package/enums/participant-status.enum.d.ts +6 -0
- package/enums/recurrence-type.enum.d.ts +7 -0
- package/exceptions/base-app.exception.d.ts +41 -0
- package/exceptions/index.d.ts +1 -0
- package/exceptions/permission.exception.d.ts +2 -2
- package/fesm/classes/api-controller.class.js +326 -50
- package/fesm/classes/api-service.class.js +274 -152
- package/fesm/classes/handle-custome-db.js +19 -0
- package/fesm/classes/index.js +3 -2
- package/fesm/classes/winston.logger.class.js +100 -68
- package/fesm/constants/index.js +4 -1
- package/fesm/constants/message-keys.js +49 -0
- package/fesm/constants/permissions.js +200 -0
- package/fesm/decorators/api-response.decorator.js +3 -21
- package/fesm/decorators/index.js +1 -0
- package/fesm/decorators/log-action.decorator.js +139 -0
- package/fesm/decorators/require-permission.decorator.js +17 -65
- package/fesm/dtos/delete.dto.js +12 -2
- package/fesm/dtos/filter-and-pagination.dto.js +26 -47
- package/fesm/dtos/get-by-ids.dto.js +55 -0
- package/fesm/dtos/identity-response.dto.js +4 -8
- package/fesm/dtos/index.js +1 -0
- package/fesm/dtos/pagination.dto.js +4 -8
- package/fesm/dtos/response-payload.dto.js +68 -103
- package/fesm/entities/identity.js +12 -6
- package/fesm/entities/index.js +1 -0
- package/fesm/entities/raw-type.js +1 -0
- package/fesm/entities/user-root.js +15 -15
- package/fesm/enums/index.js +3 -0
- package/fesm/enums/notification-type.enum.js +7 -0
- package/fesm/enums/participant-status.enum.js +7 -0
- package/fesm/enums/recurrence-type.enum.js +8 -0
- package/fesm/exceptions/base-app.exception.js +115 -0
- package/fesm/exceptions/index.js +1 -0
- package/fesm/exceptions/permission.exception.js +16 -18
- package/fesm/filters/global-exception.filter.js +269 -0
- package/fesm/filters/index.js +1 -0
- package/fesm/guards/jwt-auth.guard.js +5 -2
- package/fesm/guards/permission.guard.js +90 -150
- package/fesm/index.js +2 -0
- package/fesm/interceptors/idempotency.interceptor.js +2 -2
- package/fesm/interceptors/index.js +1 -4
- package/fesm/interceptors/set-user-field-on-body.interceptor.js +39 -0
- package/fesm/interceptors/slug.interceptor.js +31 -10
- package/fesm/interfaces/datasource.interface.js +1 -0
- package/fesm/interfaces/event-manager-adapter.interface.js +1 -0
- package/fesm/interfaces/index.js +4 -2
- package/fesm/interfaces/module-config.interface.js +5 -0
- package/fesm/interfaces/notification-adapter.interface.js +1 -0
- package/fesm/interfaces/permission.interface.js +1 -3
- package/fesm/middlewares/logger.middleware.js +133 -109
- package/fesm/modules/cache/cache.module.js +2 -2
- package/fesm/modules/datasource/index.js +0 -1
- package/fesm/modules/datasource/multi-tenant-datasource.service.js +61 -184
- package/fesm/modules/utils/utils.service.js +27 -206
- package/fesm/utils/date-time.util.js +70 -0
- package/fesm/utils/html-sanitizer.util.js +69 -0
- package/fesm/utils/index.js +5 -1
- package/fesm/utils/query-helpers.util.js +85 -0
- package/fesm/utils/request.util.js +81 -0
- package/fesm/utils/string.util.js +71 -0
- package/filters/global-exception.filter.d.ts +9 -0
- package/filters/index.d.ts +1 -0
- package/guards/permission.guard.d.ts +4 -6
- package/index.d.ts +2 -0
- package/interceptors/idempotency.interceptor.d.ts +1 -1
- package/interceptors/index.d.ts +1 -4
- package/interceptors/set-user-field-on-body.interceptor.d.ts +5 -0
- package/interceptors/slug.interceptor.d.ts +2 -1
- package/interfaces/api.interface.d.ts +4 -2
- package/interfaces/datasource.interface.d.ts +5 -0
- package/interfaces/event-manager-adapter.interface.d.ts +43 -0
- package/interfaces/identity.interface.d.ts +4 -4
- package/interfaces/index.d.ts +4 -2
- package/interfaces/logged-user-info.interface.d.ts +0 -2
- package/interfaces/module-config.interface.d.ts +6 -0
- package/interfaces/notification-adapter.interface.d.ts +21 -0
- package/interfaces/permission.interface.d.ts +13 -9
- package/middlewares/logger.middleware.d.ts +2 -2
- package/modules/datasource/index.d.ts +0 -1
- package/modules/datasource/multi-tenant-datasource.service.d.ts +5 -16
- package/modules/utils/utils.service.d.ts +3 -14
- package/package.json +21 -14
- package/utils/date-time.util.d.ts +8 -0
- package/utils/html-sanitizer.util.d.ts +2 -0
- package/utils/index.d.ts +5 -1
- package/utils/query-helpers.util.d.ts +16 -0
- package/utils/request.util.d.ts +6 -0
- package/utils/string.util.d.ts +2 -0
- package/cjs/classes/request-scoped-api.service.js +0 -61
- package/cjs/classes/winston-logger-adapter.class.js +0 -121
- package/cjs/interceptors/query-performance.interceptor.js +0 -66
- package/cjs/interceptors/set-create-by-on-body.interceptor.js +0 -40
- package/cjs/interceptors/set-delete-by-on-body.interceptor.js +0 -40
- package/cjs/interceptors/set-update-by-on-body.interceptor.js +0 -40
- package/cjs/interfaces/base-query.interface.js +0 -6
- package/cjs/interfaces/logger.interface.js +0 -7
- package/cjs/modules/datasource/datasource.module.js +0 -120
- package/cjs/utils/error-handler.util.js +0 -67
- package/classes/request-scoped-api.service.d.ts +0 -13
- package/classes/winston-logger-adapter.class.d.ts +0 -20
- package/fesm/classes/request-scoped-api.service.js +0 -51
- package/fesm/classes/winston-logger-adapter.class.js +0 -124
- package/fesm/interceptors/query-performance.interceptor.js +0 -56
- package/fesm/interceptors/set-create-by-on-body.interceptor.js +0 -30
- package/fesm/interceptors/set-delete-by-on-body.interceptor.js +0 -30
- package/fesm/interceptors/set-update-by-on-body.interceptor.js +0 -30
- package/fesm/interfaces/base-query.interface.js +0 -3
- package/fesm/interfaces/logger.interface.js +0 -4
- package/fesm/modules/datasource/datasource.module.js +0 -110
- package/fesm/utils/error-handler.util.js +0 -59
- package/interceptors/query-performance.interceptor.d.ts +0 -8
- package/interceptors/set-create-by-on-body.interceptor.d.ts +0 -5
- package/interceptors/set-delete-by-on-body.interceptor.d.ts +0 -5
- package/interceptors/set-update-by-on-body.interceptor.d.ts +0 -5
- package/interfaces/base-query.interface.d.ts +0 -7
- package/interfaces/logger.interface.d.ts +0 -7
- package/modules/datasource/datasource.module.d.ts +0 -18
- package/utils/error-handler.util.d.ts +0 -24
|
@@ -1,75 +1,27 @@
|
|
|
1
1
|
import { SetMetadata } from '@nestjs/common';
|
|
2
2
|
import { PERMISSIONS_KEY } from '../constants';
|
|
3
|
-
/**
|
|
4
|
-
* Decorator to require specific permissions for a route
|
|
5
|
-
*
|
|
6
|
-
* By default uses AND logic (user must have ALL permissions).
|
|
7
|
-
* This is the most common and secure pattern.
|
|
8
|
-
*
|
|
9
|
-
* @param permissions - One or more permission keys required (AND logic)
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* // Require single permission
|
|
13
|
-
* @RequirePermission('users.read')
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* // Require ALL permissions (AND)
|
|
17
|
-
* @RequirePermission('users.read', 'users.write')
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* // For OR logic, use RequireAnyPermission instead
|
|
21
|
-
* @RequireAnyPermission('admin.access', 'manager.access')
|
|
22
|
-
*/ export const RequirePermission = (...permissions)=>SetMetadata(PERMISSIONS_KEY, {
|
|
3
|
+
/** Require ALL permissions (AND logic) - most secure pattern */ export const RequirePermission = (...permissions)=>SetMetadata(PERMISSIONS_KEY, {
|
|
23
4
|
permissions,
|
|
24
|
-
operator: '
|
|
5
|
+
operator: 'AND'
|
|
25
6
|
});
|
|
26
|
-
/**
|
|
27
|
-
* Decorator to require ANY of the specified permissions (OR logic)
|
|
28
|
-
*
|
|
29
|
-
* User must have at least ONE of the specified permissions.
|
|
30
|
-
* Less secure than RequirePermission (AND), use carefully.
|
|
31
|
-
*
|
|
32
|
-
* @param permissions - User must have at least ONE of these permissions
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* @RequireAnyPermission('admin.access', 'manager.access')
|
|
36
|
-
*/ export const RequireAnyPermission = (...permissions)=>SetMetadata(PERMISSIONS_KEY, {
|
|
7
|
+
/** Require ANY permission (OR logic) - use carefully */ export const RequireAnyPermission = (...permissions)=>SetMetadata(PERMISSIONS_KEY, {
|
|
37
8
|
permissions,
|
|
38
|
-
operator: '
|
|
9
|
+
operator: 'OR'
|
|
39
10
|
});
|
|
40
11
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* Supports building complex permission trees:
|
|
44
|
-
* - AND/OR operators
|
|
45
|
-
* - Nested children for complex logic
|
|
46
|
-
*
|
|
47
|
-
* @param condition - Complex permission condition
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* // Simple: User needs 'admin' OR 'manager'
|
|
51
|
-
* @RequirePermissionCondition({
|
|
52
|
-
* operator: 'or',
|
|
53
|
-
* permissions: ['admin', 'manager'],
|
|
54
|
-
* })
|
|
55
|
-
*
|
|
12
|
+
* Require complex permission logic using ILogicNode tree
|
|
56
13
|
* @example
|
|
57
|
-
* //
|
|
58
|
-
* @
|
|
59
|
-
* operator: 'and',
|
|
60
|
-
* permissions: ['users.read'],
|
|
61
|
-
* children: [
|
|
62
|
-
* { operator: 'or', permissions: ['admin', 'manager'] }
|
|
63
|
-
* ]
|
|
64
|
-
* })
|
|
65
|
-
*
|
|
14
|
+
* // Single permission
|
|
15
|
+
* @RequirePermissionLogic('users.read')
|
|
66
16
|
* @example
|
|
67
|
-
* //
|
|
68
|
-
* @
|
|
69
|
-
* operator: '
|
|
70
|
-
*
|
|
71
|
-
* {
|
|
72
|
-
*
|
|
73
|
-
*
|
|
17
|
+
* // Complex: users.read AND (admin OR manager)
|
|
18
|
+
* @RequirePermissionLogic({
|
|
19
|
+
* type: 'group', operator: 'AND', children: [
|
|
20
|
+
* { type: 'action', actionId: 'users.read' },
|
|
21
|
+
* { type: 'group', operator: 'OR', children: [
|
|
22
|
+
* { type: 'action', actionId: 'admin' },
|
|
23
|
+
* { type: 'action', actionId: 'manager' },
|
|
24
|
+
* ]},
|
|
25
|
+
* ],
|
|
74
26
|
* })
|
|
75
|
-
*/ export const
|
|
27
|
+
*/ export const RequirePermissionLogic = (logic)=>SetMetadata(PERMISSIONS_KEY, logic);
|
package/fesm/dtos/delete.dto.js
CHANGED
|
@@ -20,12 +20,13 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
20
20
|
function _ts_metadata(k, v) {
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
22
|
}
|
|
23
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
24
|
-
import { IsIn, IsNotEmpty } from 'class-validator';
|
|
23
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
24
|
+
import { IsIn, IsNotEmpty, IsOptional, IsUUID } from 'class-validator';
|
|
25
25
|
export class DeleteDto {
|
|
26
26
|
constructor(){
|
|
27
27
|
_define_property(this, "id", void 0);
|
|
28
28
|
_define_property(this, "type", void 0);
|
|
29
|
+
_define_property(this, "deletedById", void 0);
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
_ts_decorate([
|
|
@@ -70,3 +71,12 @@ _ts_decorate([
|
|
|
70
71
|
]),
|
|
71
72
|
_ts_metadata("design:type", String)
|
|
72
73
|
], DeleteDto.prototype, "type", void 0);
|
|
74
|
+
_ts_decorate([
|
|
75
|
+
ApiPropertyOptional({
|
|
76
|
+
description: 'User ID who initiated the deletion (auto-set by interceptor)',
|
|
77
|
+
example: 'f2e9c8d0-7a2a-11eb-9439-0242ac130002'
|
|
78
|
+
}),
|
|
79
|
+
IsOptional(),
|
|
80
|
+
IsUUID(),
|
|
81
|
+
_ts_metadata("design:type", String)
|
|
82
|
+
], DeleteDto.prototype, "deletedById", void 0);
|
|
@@ -22,27 +22,15 @@ function _ts_metadata(k, v) {
|
|
|
22
22
|
}
|
|
23
23
|
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
24
24
|
import { Type } from 'class-transformer';
|
|
25
|
-
import { IsArray, IsBoolean, IsObject, IsOptional, ValidateNested } from 'class-validator';
|
|
25
|
+
import { IsArray, IsBoolean, IsObject, IsOptional, IsString, Matches, MaxLength, ValidateNested } from 'class-validator';
|
|
26
26
|
import { PaginationDto } from './pagination.dto';
|
|
27
|
-
|
|
28
|
-
* DTO for filtering and pagination in get-all requests
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* {
|
|
32
|
-
* "filter": { "isActive": true, "category": "electronics" },
|
|
33
|
-
* "pagination": { "currentPage": 0, "pageSize": 10 },
|
|
34
|
-
* "sort": { "createdAt": "DESC" },
|
|
35
|
-
* "select": ["id", "name", "price"],
|
|
36
|
-
* "withDeleted": false
|
|
37
|
-
* }
|
|
38
|
-
*/ export class FilterAndPaginationDto {
|
|
27
|
+
export class FilterAndPaginationDto {
|
|
39
28
|
constructor(){
|
|
40
29
|
_define_property(this, "filter", void 0);
|
|
41
30
|
_define_property(this, "pagination", void 0);
|
|
42
31
|
_define_property(this, "sort", void 0);
|
|
43
32
|
_define_property(this, "select", void 0);
|
|
44
33
|
_define_property(this, "withDeleted", void 0);
|
|
45
|
-
_define_property(this, "extraKey", void 0);
|
|
46
34
|
}
|
|
47
35
|
}
|
|
48
36
|
_ts_decorate([
|
|
@@ -90,7 +78,7 @@ _ts_decorate([
|
|
|
90
78
|
type: [
|
|
91
79
|
String
|
|
92
80
|
],
|
|
93
|
-
description: 'Fields to return. If empty, returns all fields.',
|
|
81
|
+
description: 'Fields to return. Must be valid field names (alphanumeric, underscores only). If empty, returns all fields.',
|
|
94
82
|
example: [
|
|
95
83
|
'id',
|
|
96
84
|
'name',
|
|
@@ -100,6 +88,17 @@ _ts_decorate([
|
|
|
100
88
|
}),
|
|
101
89
|
IsOptional(),
|
|
102
90
|
IsArray(),
|
|
91
|
+
IsString({
|
|
92
|
+
each: true
|
|
93
|
+
}),
|
|
94
|
+
Matches(/^[a-zA-Z_][a-zA-Z0-9_]*$/, {
|
|
95
|
+
each: true,
|
|
96
|
+
message: 'Select fields must be valid identifiers (alphanumeric and underscores only)'
|
|
97
|
+
}),
|
|
98
|
+
MaxLength(64, {
|
|
99
|
+
each: true,
|
|
100
|
+
message: 'Field names must be 64 characters or less'
|
|
101
|
+
}),
|
|
103
102
|
_ts_metadata("design:type", Array)
|
|
104
103
|
], FilterAndPaginationDto.prototype, "select", void 0);
|
|
105
104
|
_ts_decorate([
|
|
@@ -112,27 +111,11 @@ _ts_decorate([
|
|
|
112
111
|
IsBoolean(),
|
|
113
112
|
_ts_metadata("design:type", Boolean)
|
|
114
113
|
], FilterAndPaginationDto.prototype, "withDeleted", void 0);
|
|
115
|
-
_ts_decorate([
|
|
116
|
-
ApiPropertyOptional({
|
|
117
|
-
type: [
|
|
118
|
-
String
|
|
119
|
-
],
|
|
120
|
-
description: 'Additional relation keys to include',
|
|
121
|
-
example: [
|
|
122
|
-
'category',
|
|
123
|
-
'createdBy'
|
|
124
|
-
]
|
|
125
|
-
}),
|
|
126
|
-
IsOptional(),
|
|
127
|
-
IsArray(),
|
|
128
|
-
_ts_metadata("design:type", Array)
|
|
129
|
-
], FilterAndPaginationDto.prototype, "extraKey", void 0);
|
|
130
114
|
/**
|
|
131
115
|
* DTO for get-by-id request body
|
|
132
116
|
*/ export class GetByIdBodyDto {
|
|
133
117
|
constructor(){
|
|
134
118
|
_define_property(this, "select", void 0);
|
|
135
|
-
_define_property(this, "extraKey", void 0);
|
|
136
119
|
}
|
|
137
120
|
}
|
|
138
121
|
_ts_decorate([
|
|
@@ -140,7 +123,7 @@ _ts_decorate([
|
|
|
140
123
|
type: [
|
|
141
124
|
String
|
|
142
125
|
],
|
|
143
|
-
description: 'Fields to return. If empty, returns all fields.',
|
|
126
|
+
description: 'Fields to return. Must be valid field names (alphanumeric, underscores only). If empty, returns all fields.',
|
|
144
127
|
example: [
|
|
145
128
|
'id',
|
|
146
129
|
'name',
|
|
@@ -150,20 +133,16 @@ _ts_decorate([
|
|
|
150
133
|
}),
|
|
151
134
|
IsOptional(),
|
|
152
135
|
IsArray(),
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
'createdBy'
|
|
164
|
-
]
|
|
136
|
+
IsString({
|
|
137
|
+
each: true
|
|
138
|
+
}),
|
|
139
|
+
Matches(/^[a-zA-Z_][a-zA-Z0-9_]*$/, {
|
|
140
|
+
each: true,
|
|
141
|
+
message: 'Select fields must be valid identifiers (alphanumeric and underscores only)'
|
|
142
|
+
}),
|
|
143
|
+
MaxLength(64, {
|
|
144
|
+
each: true,
|
|
145
|
+
message: 'Field names must be 64 characters or less'
|
|
165
146
|
}),
|
|
166
|
-
IsOptional(),
|
|
167
|
-
IsArray(),
|
|
168
147
|
_ts_metadata("design:type", Array)
|
|
169
|
-
], GetByIdBodyDto.prototype, "
|
|
148
|
+
], GetByIdBodyDto.prototype, "select", void 0);
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
24
|
+
import { IsArray, IsNotEmpty, IsOptional, IsUUID } from 'class-validator';
|
|
25
|
+
export class GetByIdsDto {
|
|
26
|
+
constructor(){
|
|
27
|
+
_define_property(this, "ids", void 0);
|
|
28
|
+
_define_property(this, "select", void 0);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
_ts_decorate([
|
|
32
|
+
ApiProperty({
|
|
33
|
+
description: 'Array of IDs to retrieve',
|
|
34
|
+
type: [
|
|
35
|
+
String
|
|
36
|
+
],
|
|
37
|
+
example: [
|
|
38
|
+
'uuid-1',
|
|
39
|
+
'uuid-2'
|
|
40
|
+
]
|
|
41
|
+
}),
|
|
42
|
+
IsNotEmpty(),
|
|
43
|
+
IsArray(),
|
|
44
|
+
IsUUID('all', {
|
|
45
|
+
each: true
|
|
46
|
+
}),
|
|
47
|
+
_ts_metadata("design:type", Array)
|
|
48
|
+
], GetByIdsDto.prototype, "ids", void 0);
|
|
49
|
+
_ts_decorate([
|
|
50
|
+
ApiPropertyOptional({
|
|
51
|
+
description: 'Select specific fields to return (comma-separated or array)'
|
|
52
|
+
}),
|
|
53
|
+
IsOptional(),
|
|
54
|
+
_ts_metadata("design:type", Object)
|
|
55
|
+
], GetByIdsDto.prototype, "select", void 0);
|
|
@@ -20,8 +20,8 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
20
20
|
function _ts_metadata(k, v) {
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
22
|
}
|
|
23
|
-
import { Expose, Type } from 'class-transformer';
|
|
24
23
|
import { ApiProperty } from '@nestjs/swagger';
|
|
24
|
+
import { Expose, Type } from 'class-transformer';
|
|
25
25
|
export class IdentityResponseDto {
|
|
26
26
|
constructor(){
|
|
27
27
|
_define_property(this, "id", void 0);
|
|
@@ -34,28 +34,28 @@ export class IdentityResponseDto {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
_ts_decorate([
|
|
37
|
+
Expose(),
|
|
37
38
|
ApiProperty({
|
|
38
39
|
type: String,
|
|
39
40
|
format: 'uuid'
|
|
40
41
|
}),
|
|
41
|
-
Expose(),
|
|
42
42
|
_ts_metadata("design:type", String)
|
|
43
43
|
], IdentityResponseDto.prototype, "id", void 0);
|
|
44
44
|
_ts_decorate([
|
|
45
|
+
Expose(),
|
|
45
46
|
ApiProperty({
|
|
46
47
|
type: String,
|
|
47
48
|
format: 'date-time'
|
|
48
49
|
}),
|
|
49
|
-
Expose(),
|
|
50
50
|
Type(()=>Date),
|
|
51
51
|
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
52
52
|
], IdentityResponseDto.prototype, "createdAt", void 0);
|
|
53
53
|
_ts_decorate([
|
|
54
|
+
Expose(),
|
|
54
55
|
ApiProperty({
|
|
55
56
|
type: String,
|
|
56
57
|
format: 'date-time'
|
|
57
58
|
}),
|
|
58
|
-
Expose(),
|
|
59
59
|
Type(()=>Date),
|
|
60
60
|
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
61
61
|
], IdentityResponseDto.prototype, "updatedAt", void 0);
|
|
@@ -66,7 +66,6 @@ _ts_decorate([
|
|
|
66
66
|
nullable: true,
|
|
67
67
|
required: false
|
|
68
68
|
}),
|
|
69
|
-
Expose(),
|
|
70
69
|
Type(()=>Date),
|
|
71
70
|
_ts_metadata("design:type", Object)
|
|
72
71
|
], IdentityResponseDto.prototype, "deletedAt", void 0);
|
|
@@ -77,7 +76,6 @@ _ts_decorate([
|
|
|
77
76
|
nullable: true,
|
|
78
77
|
required: false
|
|
79
78
|
}),
|
|
80
|
-
Expose(),
|
|
81
79
|
_ts_metadata("design:type", Object)
|
|
82
80
|
], IdentityResponseDto.prototype, "createdById", void 0);
|
|
83
81
|
_ts_decorate([
|
|
@@ -87,7 +85,6 @@ _ts_decorate([
|
|
|
87
85
|
nullable: true,
|
|
88
86
|
required: false
|
|
89
87
|
}),
|
|
90
|
-
Expose(),
|
|
91
88
|
_ts_metadata("design:type", Object)
|
|
92
89
|
], IdentityResponseDto.prototype, "updatedById", void 0);
|
|
93
90
|
_ts_decorate([
|
|
@@ -97,6 +94,5 @@ _ts_decorate([
|
|
|
97
94
|
nullable: true,
|
|
98
95
|
required: false
|
|
99
96
|
}),
|
|
100
|
-
Expose(),
|
|
101
97
|
_ts_metadata("design:type", Object)
|
|
102
98
|
], IdentityResponseDto.prototype, "deletedById", void 0);
|
package/fesm/dtos/index.js
CHANGED
|
@@ -25,17 +25,13 @@ import { Transform } from 'class-transformer';
|
|
|
25
25
|
import { IsNumber, IsOptional } from 'class-validator';
|
|
26
26
|
export class PaginationDto {
|
|
27
27
|
constructor(){
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*/ _define_property(this, "pageSize", 10);
|
|
31
|
-
/**
|
|
32
|
-
* Zero-based page index. Defaults to 0 when not provided or invalid.
|
|
33
|
-
*/ _define_property(this, "currentPage", 0);
|
|
28
|
+
_define_property(this, "pageSize", 10);
|
|
29
|
+
_define_property(this, "currentPage", 0);
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
32
|
_ts_decorate([
|
|
37
33
|
ApiPropertyOptional({
|
|
38
|
-
description: 'Number of items per page
|
|
34
|
+
description: 'Number of items per page (default: 10)',
|
|
39
35
|
example: 10
|
|
40
36
|
}),
|
|
41
37
|
IsOptional(),
|
|
@@ -48,7 +44,7 @@ _ts_decorate([
|
|
|
48
44
|
], PaginationDto.prototype, "pageSize", void 0);
|
|
49
45
|
_ts_decorate([
|
|
50
46
|
ApiPropertyOptional({
|
|
51
|
-
description: 'Zero-based page index
|
|
47
|
+
description: 'Zero-based page index (default: 0)',
|
|
52
48
|
example: 0
|
|
53
49
|
}),
|
|
54
50
|
IsOptional(),
|
|
@@ -50,6 +50,8 @@ export class SingleResponseDto {
|
|
|
50
50
|
constructor(){
|
|
51
51
|
_define_property(this, "success", void 0);
|
|
52
52
|
_define_property(this, "message", void 0);
|
|
53
|
+
_define_property(this, "messageKey", void 0);
|
|
54
|
+
_define_property(this, "messageVariables", void 0);
|
|
53
55
|
_define_property(this, "data", void 0);
|
|
54
56
|
_define_property(this, "_meta", void 0);
|
|
55
57
|
}
|
|
@@ -66,6 +68,22 @@ _ts_decorate([
|
|
|
66
68
|
}),
|
|
67
69
|
_ts_metadata("design:type", String)
|
|
68
70
|
], SingleResponseDto.prototype, "message", void 0);
|
|
71
|
+
_ts_decorate([
|
|
72
|
+
ApiPropertyOptional({
|
|
73
|
+
example: 'user.create.success',
|
|
74
|
+
description: 'Translation key for localization'
|
|
75
|
+
}),
|
|
76
|
+
_ts_metadata("design:type", String)
|
|
77
|
+
], SingleResponseDto.prototype, "messageKey", void 0);
|
|
78
|
+
_ts_decorate([
|
|
79
|
+
ApiPropertyOptional({
|
|
80
|
+
example: {
|
|
81
|
+
name: 'John'
|
|
82
|
+
},
|
|
83
|
+
description: 'Variables for message interpolation'
|
|
84
|
+
}),
|
|
85
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
86
|
+
], SingleResponseDto.prototype, "messageVariables", void 0);
|
|
69
87
|
_ts_decorate([
|
|
70
88
|
ApiPropertyOptional(),
|
|
71
89
|
_ts_metadata("design:type", typeof T === "undefined" ? Object : T)
|
|
@@ -129,6 +147,8 @@ export class ListResponseDto {
|
|
|
129
147
|
constructor(){
|
|
130
148
|
_define_property(this, "success", void 0);
|
|
131
149
|
_define_property(this, "message", void 0);
|
|
150
|
+
_define_property(this, "messageKey", void 0);
|
|
151
|
+
_define_property(this, "messageVariables", void 0);
|
|
132
152
|
_define_property(this, "data", void 0);
|
|
133
153
|
_define_property(this, "meta", void 0);
|
|
134
154
|
_define_property(this, "_meta", void 0);
|
|
@@ -146,6 +166,22 @@ _ts_decorate([
|
|
|
146
166
|
}),
|
|
147
167
|
_ts_metadata("design:type", String)
|
|
148
168
|
], ListResponseDto.prototype, "message", void 0);
|
|
169
|
+
_ts_decorate([
|
|
170
|
+
ApiPropertyOptional({
|
|
171
|
+
example: 'user.list.success',
|
|
172
|
+
description: 'Translation key for localization'
|
|
173
|
+
}),
|
|
174
|
+
_ts_metadata("design:type", String)
|
|
175
|
+
], ListResponseDto.prototype, "messageKey", void 0);
|
|
176
|
+
_ts_decorate([
|
|
177
|
+
ApiPropertyOptional({
|
|
178
|
+
example: {
|
|
179
|
+
count: 10
|
|
180
|
+
},
|
|
181
|
+
description: 'Variables for message interpolation'
|
|
182
|
+
}),
|
|
183
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
184
|
+
], ListResponseDto.prototype, "messageVariables", void 0);
|
|
149
185
|
_ts_decorate([
|
|
150
186
|
ApiPropertyOptional({
|
|
151
187
|
isArray: true
|
|
@@ -196,6 +232,8 @@ export class BulkResponseDto {
|
|
|
196
232
|
constructor(){
|
|
197
233
|
_define_property(this, "success", void 0);
|
|
198
234
|
_define_property(this, "message", void 0);
|
|
235
|
+
_define_property(this, "messageKey", void 0);
|
|
236
|
+
_define_property(this, "messageVariables", void 0);
|
|
199
237
|
_define_property(this, "data", void 0);
|
|
200
238
|
_define_property(this, "meta", void 0);
|
|
201
239
|
_define_property(this, "_meta", void 0);
|
|
@@ -213,6 +251,22 @@ _ts_decorate([
|
|
|
213
251
|
}),
|
|
214
252
|
_ts_metadata("design:type", String)
|
|
215
253
|
], BulkResponseDto.prototype, "message", void 0);
|
|
254
|
+
_ts_decorate([
|
|
255
|
+
ApiPropertyOptional({
|
|
256
|
+
example: 'user.bulk.success',
|
|
257
|
+
description: 'Translation key for localization'
|
|
258
|
+
}),
|
|
259
|
+
_ts_metadata("design:type", String)
|
|
260
|
+
], BulkResponseDto.prototype, "messageKey", void 0);
|
|
261
|
+
_ts_decorate([
|
|
262
|
+
ApiPropertyOptional({
|
|
263
|
+
example: {
|
|
264
|
+
count: 5
|
|
265
|
+
},
|
|
266
|
+
description: 'Variables for message interpolation'
|
|
267
|
+
}),
|
|
268
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
269
|
+
], BulkResponseDto.prototype, "messageVariables", void 0);
|
|
216
270
|
_ts_decorate([
|
|
217
271
|
ApiPropertyOptional({
|
|
218
272
|
isArray: true
|
|
@@ -238,6 +292,8 @@ export class MessageResponseDto {
|
|
|
238
292
|
constructor(){
|
|
239
293
|
_define_property(this, "success", void 0);
|
|
240
294
|
_define_property(this, "message", void 0);
|
|
295
|
+
_define_property(this, "messageKey", void 0);
|
|
296
|
+
_define_property(this, "messageVariables", void 0);
|
|
241
297
|
_define_property(this, "_meta", void 0);
|
|
242
298
|
}
|
|
243
299
|
}
|
|
@@ -255,117 +311,26 @@ _ts_decorate([
|
|
|
255
311
|
], MessageResponseDto.prototype, "message", void 0);
|
|
256
312
|
_ts_decorate([
|
|
257
313
|
ApiPropertyOptional({
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
_ts_metadata("design:type", typeof RequestMetaDto === "undefined" ? Object : RequestMetaDto)
|
|
261
|
-
], MessageResponseDto.prototype, "_meta", void 0);
|
|
262
|
-
MessageResponseDto = _ts_decorate([
|
|
263
|
-
ApiExtraModels()
|
|
264
|
-
], MessageResponseDto);
|
|
265
|
-
export class ValidationErrorDto {
|
|
266
|
-
constructor(){
|
|
267
|
-
_define_property(this, "field", void 0);
|
|
268
|
-
_define_property(this, "message", void 0);
|
|
269
|
-
_define_property(this, "constraint", void 0);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
_ts_decorate([
|
|
273
|
-
ApiProperty({
|
|
274
|
-
example: 'email'
|
|
314
|
+
example: 'user.delete.success',
|
|
315
|
+
description: 'Translation key for localization'
|
|
275
316
|
}),
|
|
276
317
|
_ts_metadata("design:type", String)
|
|
277
|
-
],
|
|
278
|
-
_ts_decorate([
|
|
279
|
-
ApiProperty({
|
|
280
|
-
example: 'Invalid email format'
|
|
281
|
-
}),
|
|
282
|
-
_ts_metadata("design:type", String)
|
|
283
|
-
], ValidationErrorDto.prototype, "message", void 0);
|
|
318
|
+
], MessageResponseDto.prototype, "messageKey", void 0);
|
|
284
319
|
_ts_decorate([
|
|
285
320
|
ApiPropertyOptional({
|
|
286
|
-
example:
|
|
321
|
+
example: {
|
|
322
|
+
count: 3
|
|
323
|
+
},
|
|
324
|
+
description: 'Variables for message interpolation'
|
|
287
325
|
}),
|
|
288
|
-
_ts_metadata("design:type",
|
|
289
|
-
],
|
|
290
|
-
export class ErrorResponseDto {
|
|
291
|
-
constructor(){
|
|
292
|
-
_define_property(this, "success", void 0);
|
|
293
|
-
_define_property(this, "message", void 0);
|
|
294
|
-
_define_property(this, "code", void 0);
|
|
295
|
-
_define_property(this, "errors", void 0);
|
|
296
|
-
_define_property(this, "_meta", void 0);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
_ts_decorate([
|
|
300
|
-
ApiProperty({
|
|
301
|
-
example: false
|
|
302
|
-
}),
|
|
303
|
-
_ts_metadata("design:type", Boolean)
|
|
304
|
-
], ErrorResponseDto.prototype, "success", void 0);
|
|
305
|
-
_ts_decorate([
|
|
306
|
-
ApiProperty({
|
|
307
|
-
example: 'Validation failed'
|
|
308
|
-
}),
|
|
309
|
-
_ts_metadata("design:type", String)
|
|
310
|
-
], ErrorResponseDto.prototype, "message", void 0);
|
|
311
|
-
_ts_decorate([
|
|
312
|
-
ApiPropertyOptional({
|
|
313
|
-
example: 'VALIDATION_ERROR'
|
|
314
|
-
}),
|
|
315
|
-
_ts_metadata("design:type", String)
|
|
316
|
-
], ErrorResponseDto.prototype, "code", void 0);
|
|
317
|
-
_ts_decorate([
|
|
318
|
-
ApiPropertyOptional({
|
|
319
|
-
type: [
|
|
320
|
-
ValidationErrorDto
|
|
321
|
-
]
|
|
322
|
-
}),
|
|
323
|
-
_ts_metadata("design:type", Array)
|
|
324
|
-
], ErrorResponseDto.prototype, "errors", void 0);
|
|
325
|
-
_ts_decorate([
|
|
326
|
-
ApiPropertyOptional({
|
|
327
|
-
type: RequestMetaDto
|
|
328
|
-
}),
|
|
329
|
-
_ts_metadata("design:type", typeof RequestMetaDto === "undefined" ? Object : RequestMetaDto)
|
|
330
|
-
], ErrorResponseDto.prototype, "_meta", void 0);
|
|
331
|
-
ErrorResponseDto = _ts_decorate([
|
|
332
|
-
ApiExtraModels()
|
|
333
|
-
], ErrorResponseDto);
|
|
334
|
-
export class ResponsePayloadDto {
|
|
335
|
-
constructor(){
|
|
336
|
-
_define_property(this, "success", void 0);
|
|
337
|
-
_define_property(this, "message", void 0);
|
|
338
|
-
_define_property(this, "data", void 0);
|
|
339
|
-
_define_property(this, "meta", void 0);
|
|
340
|
-
_define_property(this, "_meta", void 0);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
_ts_decorate([
|
|
344
|
-
ApiProperty({
|
|
345
|
-
example: true
|
|
346
|
-
}),
|
|
347
|
-
_ts_metadata("design:type", Boolean)
|
|
348
|
-
], ResponsePayloadDto.prototype, "success", void 0);
|
|
349
|
-
_ts_decorate([
|
|
350
|
-
ApiProperty({
|
|
351
|
-
example: 'Operation successful'
|
|
352
|
-
}),
|
|
353
|
-
_ts_metadata("design:type", String)
|
|
354
|
-
], ResponsePayloadDto.prototype, "message", void 0);
|
|
355
|
-
_ts_decorate([
|
|
356
|
-
ApiPropertyOptional(),
|
|
357
|
-
_ts_metadata("design:type", typeof T === "undefined" ? Object : T)
|
|
358
|
-
], ResponsePayloadDto.prototype, "data", void 0);
|
|
359
|
-
_ts_decorate([
|
|
360
|
-
ApiPropertyOptional(),
|
|
361
|
-
_ts_metadata("design:type", Object)
|
|
362
|
-
], ResponsePayloadDto.prototype, "meta", void 0);
|
|
326
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
327
|
+
], MessageResponseDto.prototype, "messageVariables", void 0);
|
|
363
328
|
_ts_decorate([
|
|
364
329
|
ApiPropertyOptional({
|
|
365
330
|
type: RequestMetaDto
|
|
366
331
|
}),
|
|
367
332
|
_ts_metadata("design:type", typeof RequestMetaDto === "undefined" ? Object : RequestMetaDto)
|
|
368
|
-
],
|
|
369
|
-
|
|
333
|
+
], MessageResponseDto.prototype, "_meta", void 0);
|
|
334
|
+
MessageResponseDto = _ts_decorate([
|
|
370
335
|
ApiExtraModels()
|
|
371
|
-
],
|
|
336
|
+
], MessageResponseDto);
|