@flusys/nestjs-shared 1.1.0 → 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 +139 -1103
- package/cjs/classes/api-controller.class.js +320 -29
- package/cjs/classes/api-service.class.js +219 -64
- package/cjs/classes/handle-custome-db.js +37 -0
- package/cjs/classes/index.js +1 -2
- package/cjs/classes/winston.logger.class.js +103 -70
- package/cjs/constants/index.js +1 -4
- package/cjs/constants/message-keys.js +68 -0
- package/cjs/constants/permissions.js +114 -11
- package/cjs/decorators/api-response.decorator.js +1 -2
- package/cjs/decorators/index.js +1 -1
- package/cjs/decorators/log-action.decorator.js +149 -0
- package/cjs/decorators/require-permission.decorator.js +5 -5
- 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/response-payload.dto.js +72 -0
- package/cjs/entities/identity.js +8 -2
- package/cjs/entities/index.js +1 -0
- package/cjs/entities/raw-type.js +4 -0
- package/cjs/entities/user-root.js +2 -1
- 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 +71 -77
- package/cjs/index.js +2 -0
- package/cjs/interceptors/idempotency.interceptor.js +1 -1
- package/cjs/interceptors/index.js +0 -1
- package/cjs/interfaces/event-manager-adapter.interface.js +11 -0
- package/cjs/interfaces/index.js +2 -1
- package/cjs/interfaces/notification-adapter.interface.js +11 -0
- package/cjs/interfaces/permission.interface.js +1 -1
- package/cjs/middlewares/logger.middleware.js +83 -26
- package/cjs/modules/datasource/index.js +0 -1
- package/cjs/modules/datasource/multi-tenant-datasource.service.js +46 -85
- package/cjs/modules/utils/utils.service.js +4 -20
- package/cjs/utils/date-time.util.js +94 -0
- package/cjs/utils/index.js +1 -1
- package/cjs/utils/query-helpers.util.js +8 -1
- package/cjs/utils/request.util.js +25 -0
- package/classes/api-controller.class.d.ts +14 -6
- package/classes/api-service.class.d.ts +25 -22
- package/classes/handle-custome-db.d.ts +3 -0
- package/classes/index.d.ts +1 -2
- package/classes/winston.logger.class.d.ts +1 -0
- package/constants/index.d.ts +1 -1
- package/constants/message-keys.d.ts +45 -0
- package/constants/permissions.d.ts +127 -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 -1
- package/decorators/log-action.decorator.d.ts +8 -0
- package/decorators/require-permission.decorator.d.ts +2 -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 -0
- 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 +321 -30
- package/fesm/classes/api-service.class.js +222 -67
- package/fesm/classes/handle-custome-db.js +19 -0
- package/fesm/classes/index.js +1 -2
- package/fesm/classes/winston.logger.class.js +100 -68
- package/fesm/constants/index.js +2 -1
- package/fesm/constants/message-keys.js +49 -0
- package/fesm/constants/permissions.js +86 -14
- package/fesm/decorators/api-response.decorator.js +2 -20
- package/fesm/decorators/index.js +1 -1
- package/fesm/decorators/log-action.decorator.js +139 -0
- package/fesm/decorators/require-permission.decorator.js +17 -65
- 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/response-payload.dto.js +72 -0
- package/fesm/entities/identity.js +8 -2
- package/fesm/entities/index.js +1 -0
- package/fesm/entities/raw-type.js +1 -0
- package/fesm/entities/user-root.js +2 -1
- 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 +73 -79
- package/fesm/index.js +2 -0
- package/fesm/interceptors/idempotency.interceptor.js +2 -2
- package/fesm/interceptors/index.js +0 -1
- package/fesm/interfaces/datasource.interface.js +1 -20
- package/fesm/interfaces/event-manager-adapter.interface.js +1 -0
- package/fesm/interfaces/index.js +2 -1
- package/fesm/interfaces/notification-adapter.interface.js +1 -0
- package/fesm/interfaces/permission.interface.js +1 -3
- package/fesm/middlewares/logger.middleware.js +83 -26
- package/fesm/modules/datasource/index.js +0 -1
- package/fesm/modules/datasource/multi-tenant-datasource.service.js +47 -86
- package/fesm/modules/utils/utils.service.js +5 -21
- package/fesm/utils/date-time.util.js +70 -0
- package/fesm/utils/index.js +1 -1
- package/fesm/utils/query-helpers.util.js +8 -1
- package/fesm/utils/request.util.js +22 -0
- package/filters/global-exception.filter.d.ts +9 -0
- package/filters/index.d.ts +1 -0
- package/guards/permission.guard.d.ts +3 -7
- package/index.d.ts +2 -0
- package/interceptors/idempotency.interceptor.d.ts +1 -1
- package/interceptors/index.d.ts +0 -1
- package/interfaces/api.interface.d.ts +2 -0
- package/interfaces/event-manager-adapter.interface.d.ts +43 -0
- package/interfaces/index.d.ts +2 -1
- package/interfaces/notification-adapter.interface.d.ts +21 -0
- package/interfaces/permission.interface.d.ts +13 -8
- package/modules/datasource/index.d.ts +0 -1
- package/modules/datasource/multi-tenant-datasource.service.d.ts +5 -15
- package/modules/utils/utils.service.d.ts +0 -1
- package/package.json +21 -14
- package/utils/date-time.util.d.ts +8 -0
- package/utils/index.d.ts +1 -1
- package/utils/request.util.d.ts +2 -0
- package/cjs/classes/request-scoped-api.service.js +0 -61
- package/cjs/classes/winston-logger-adapter.class.js +0 -104
- package/cjs/decorators/sanitize-html.decorator.js +0 -36
- package/cjs/interceptors/query-performance.interceptor.js +0 -66
- package/cjs/interfaces/logger.interface.js +0 -7
- package/cjs/modules/datasource/datasource.module.js +0 -117
- package/cjs/utils/error-handler.util.js +0 -90
- package/classes/request-scoped-api.service.d.ts +0 -14
- package/classes/winston-logger-adapter.class.d.ts +0 -22
- package/decorators/sanitize-html.decorator.d.ts +0 -2
- package/fesm/classes/request-scoped-api.service.js +0 -51
- package/fesm/classes/winston-logger-adapter.class.js +0 -107
- package/fesm/decorators/sanitize-html.decorator.js +0 -45
- package/fesm/interceptors/query-performance.interceptor.js +0 -56
- package/fesm/interfaces/logger.interface.js +0 -4
- package/fesm/modules/datasource/datasource.module.js +0 -107
- package/fesm/utils/error-handler.util.js +0 -82
- package/interceptors/query-performance.interceptor.d.ts +0 -8
- package/interfaces/logger.interface.d.ts +0 -7
- package/modules/datasource/datasource.module.d.ts +0 -19
- package/utils/error-handler.util.d.ts +0 -19
|
@@ -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);
|
|
@@ -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
|
@@ -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
|
}
|
|
@@ -253,6 +309,22 @@ _ts_decorate([
|
|
|
253
309
|
}),
|
|
254
310
|
_ts_metadata("design:type", String)
|
|
255
311
|
], MessageResponseDto.prototype, "message", void 0);
|
|
312
|
+
_ts_decorate([
|
|
313
|
+
ApiPropertyOptional({
|
|
314
|
+
example: 'user.delete.success',
|
|
315
|
+
description: 'Translation key for localization'
|
|
316
|
+
}),
|
|
317
|
+
_ts_metadata("design:type", String)
|
|
318
|
+
], MessageResponseDto.prototype, "messageKey", void 0);
|
|
319
|
+
_ts_decorate([
|
|
320
|
+
ApiPropertyOptional({
|
|
321
|
+
example: {
|
|
322
|
+
count: 3
|
|
323
|
+
},
|
|
324
|
+
description: 'Variables for message interpolation'
|
|
325
|
+
}),
|
|
326
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
327
|
+
], MessageResponseDto.prototype, "messageVariables", void 0);
|
|
256
328
|
_ts_decorate([
|
|
257
329
|
ApiPropertyOptional({
|
|
258
330
|
type: RequestMetaDto
|
|
@@ -39,14 +39,16 @@ _ts_decorate([
|
|
|
39
39
|
_ts_decorate([
|
|
40
40
|
CreateDateColumn({
|
|
41
41
|
name: 'created_at',
|
|
42
|
-
type: 'timestamp'
|
|
42
|
+
type: 'timestamp',
|
|
43
|
+
select: false
|
|
43
44
|
}),
|
|
44
45
|
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
45
46
|
], Identity.prototype, "createdAt", void 0);
|
|
46
47
|
_ts_decorate([
|
|
47
48
|
UpdateDateColumn({
|
|
48
49
|
name: 'updated_at',
|
|
49
|
-
type: 'timestamp'
|
|
50
|
+
type: 'timestamp',
|
|
51
|
+
select: false
|
|
50
52
|
}),
|
|
51
53
|
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
52
54
|
], Identity.prototype, "updatedAt", void 0);
|
|
@@ -54,6 +56,7 @@ _ts_decorate([
|
|
|
54
56
|
DeleteDateColumn({
|
|
55
57
|
name: 'deleted_at',
|
|
56
58
|
type: 'timestamp',
|
|
59
|
+
select: false,
|
|
57
60
|
nullable: true
|
|
58
61
|
}),
|
|
59
62
|
_ts_metadata("design:type", Object)
|
|
@@ -62,6 +65,7 @@ _ts_decorate([
|
|
|
62
65
|
Column({
|
|
63
66
|
name: 'created_by_id',
|
|
64
67
|
type: 'uuid',
|
|
68
|
+
select: false,
|
|
65
69
|
nullable: true
|
|
66
70
|
}),
|
|
67
71
|
_ts_metadata("design:type", Object)
|
|
@@ -70,6 +74,7 @@ _ts_decorate([
|
|
|
70
74
|
Column({
|
|
71
75
|
name: 'updated_by_id',
|
|
72
76
|
type: 'uuid',
|
|
77
|
+
select: false,
|
|
73
78
|
nullable: true
|
|
74
79
|
}),
|
|
75
80
|
_ts_metadata("design:type", Object)
|
|
@@ -78,6 +83,7 @@ _ts_decorate([
|
|
|
78
83
|
Column({
|
|
79
84
|
name: 'deleted_by_id',
|
|
80
85
|
type: 'uuid',
|
|
86
|
+
select: false,
|
|
81
87
|
nullable: true
|
|
82
88
|
}),
|
|
83
89
|
_ts_metadata("design:type", Object)
|
package/fesm/entities/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -20,6 +20,7 @@ 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 { getJsonColumnType } from '@flusys/nestjs-shared';
|
|
23
24
|
import { Column, CreateDateColumn, DeleteDateColumn, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
|
|
24
25
|
export class UserRoot {
|
|
25
26
|
constructor(){
|
|
@@ -124,7 +125,7 @@ _ts_decorate([
|
|
|
124
125
|
], UserRoot.prototype, "lastLoginAt", void 0);
|
|
125
126
|
_ts_decorate([
|
|
126
127
|
Column({
|
|
127
|
-
type:
|
|
128
|
+
type: getJsonColumnType(),
|
|
128
129
|
nullable: true,
|
|
129
130
|
name: 'additional_fields'
|
|
130
131
|
}),
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var NotificationType = /*#__PURE__*/ function(NotificationType) {
|
|
2
|
+
NotificationType["INFO"] = "info";
|
|
3
|
+
NotificationType["WARNING"] = "warning";
|
|
4
|
+
NotificationType["SUCCESS"] = "success";
|
|
5
|
+
NotificationType["ERROR"] = "error";
|
|
6
|
+
return NotificationType;
|
|
7
|
+
}({});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var ParticipantStatus = /*#__PURE__*/ function(ParticipantStatus) {
|
|
2
|
+
ParticipantStatus["PENDING"] = "pending";
|
|
3
|
+
ParticipantStatus["ACCEPTED"] = "accepted";
|
|
4
|
+
ParticipantStatus["DECLINED"] = "declined";
|
|
5
|
+
ParticipantStatus["TENTATIVE"] = "tentative";
|
|
6
|
+
return ParticipantStatus;
|
|
7
|
+
}({});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var RecurrenceType = /*#__PURE__*/ function(RecurrenceType) {
|
|
2
|
+
RecurrenceType["NONE"] = "none";
|
|
3
|
+
RecurrenceType["DAILY"] = "daily";
|
|
4
|
+
RecurrenceType["WEEKLY"] = "weekly";
|
|
5
|
+
RecurrenceType["BIWEEKLY"] = "biweekly";
|
|
6
|
+
RecurrenceType["MONTHLY"] = "monthly";
|
|
7
|
+
return RecurrenceType;
|
|
8
|
+
}({});
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
import { HttpException, HttpStatus } from '@nestjs/common';
|
|
15
|
+
import { ERROR_MESSAGES } from '../constants/message-keys';
|
|
16
|
+
export class BaseAppException extends HttpException {
|
|
17
|
+
constructor(options){
|
|
18
|
+
const status = options.status || HttpStatus.BAD_REQUEST;
|
|
19
|
+
super({
|
|
20
|
+
success: false,
|
|
21
|
+
message: options.message,
|
|
22
|
+
messageKey: options.messageKey || ERROR_MESSAGES.GENERIC,
|
|
23
|
+
messageVariables: options.messageVariables,
|
|
24
|
+
errors: options.errors
|
|
25
|
+
}, status), _define_property(this, "messageKey", void 0), _define_property(this, "messageVariables", void 0), _define_property(this, "errors", void 0), _define_property(this, "metadata", void 0);
|
|
26
|
+
this.messageKey = options.messageKey || ERROR_MESSAGES.GENERIC;
|
|
27
|
+
this.messageVariables = options.messageVariables;
|
|
28
|
+
this.errors = options.errors;
|
|
29
|
+
this.metadata = options.metadata;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class NotFoundException extends BaseAppException {
|
|
33
|
+
constructor(entity, id){
|
|
34
|
+
super({
|
|
35
|
+
message: id ? `${entity} with id "${id}" not found` : `${entity} not found`,
|
|
36
|
+
messageKey: ERROR_MESSAGES.NOT_FOUND,
|
|
37
|
+
status: HttpStatus.NOT_FOUND,
|
|
38
|
+
metadata: {
|
|
39
|
+
entity,
|
|
40
|
+
id
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class ValidationException extends BaseAppException {
|
|
46
|
+
constructor(errors){
|
|
47
|
+
super({
|
|
48
|
+
message: 'Validation failed',
|
|
49
|
+
messageKey: ERROR_MESSAGES.VALIDATION,
|
|
50
|
+
status: HttpStatus.BAD_REQUEST,
|
|
51
|
+
errors
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export class UnauthorizedException extends BaseAppException {
|
|
56
|
+
constructor(message = 'Unauthorized access'){
|
|
57
|
+
super({
|
|
58
|
+
message,
|
|
59
|
+
messageKey: ERROR_MESSAGES.UNAUTHORIZED,
|
|
60
|
+
status: HttpStatus.UNAUTHORIZED
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export class ForbiddenException extends BaseAppException {
|
|
65
|
+
constructor(message = 'Access forbidden'){
|
|
66
|
+
super({
|
|
67
|
+
message,
|
|
68
|
+
messageKey: ERROR_MESSAGES.FORBIDDEN,
|
|
69
|
+
status: HttpStatus.FORBIDDEN
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export class ConflictException extends BaseAppException {
|
|
74
|
+
constructor(entity, field){
|
|
75
|
+
super({
|
|
76
|
+
message: field ? `${entity} with this ${field} already exists` : `${entity} already exists`,
|
|
77
|
+
messageKey: ERROR_MESSAGES.CONFLICT,
|
|
78
|
+
messageVariables: {
|
|
79
|
+
entity,
|
|
80
|
+
...field !== undefined && {
|
|
81
|
+
field
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
status: HttpStatus.CONFLICT,
|
|
85
|
+
metadata: {
|
|
86
|
+
entity,
|
|
87
|
+
field
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export class InternalServerException extends BaseAppException {
|
|
93
|
+
constructor(message = 'Internal server error'){
|
|
94
|
+
super({
|
|
95
|
+
message,
|
|
96
|
+
messageKey: ERROR_MESSAGES.INTERNAL,
|
|
97
|
+
status: HttpStatus.INTERNAL_SERVER_ERROR
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export class ServiceUnavailableException extends BaseAppException {
|
|
102
|
+
constructor(service){
|
|
103
|
+
super({
|
|
104
|
+
message: `${service} is temporarily unavailable`,
|
|
105
|
+
messageKey: ERROR_MESSAGES.SERVICE_UNAVAILABLE,
|
|
106
|
+
messageVariables: {
|
|
107
|
+
service
|
|
108
|
+
},
|
|
109
|
+
status: HttpStatus.SERVICE_UNAVAILABLE,
|
|
110
|
+
metadata: {
|
|
111
|
+
service
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
package/fesm/exceptions/index.js
CHANGED
|
@@ -1,37 +1,35 @@
|
|
|
1
1
|
import { ForbiddenException, InternalServerErrorException } from '@nestjs/common';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(message = 'Permission system temporarily unavailable. Please try again later.'){
|
|
2
|
+
import { ERROR_MESSAGES } from '../constants/message-keys';
|
|
3
|
+
export class PermissionSystemUnavailableException extends InternalServerErrorException {
|
|
4
|
+
constructor(){
|
|
6
5
|
super({
|
|
7
6
|
success: false,
|
|
8
|
-
message,
|
|
9
|
-
|
|
7
|
+
message: 'Permission system temporarily unavailable',
|
|
8
|
+
messageKey: ERROR_MESSAGES.PERMISSION_SYSTEM_UNAVAILABLE
|
|
10
9
|
});
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
constructor(missingPermissions, operator = 'and'){
|
|
17
|
-
const message = operator === 'or' ? `Requires at least one of: ${missingPermissions.join(', ')}` : `Missing required permissions: ${missingPermissions.join(', ')}`;
|
|
12
|
+
export class InsufficientPermissionsException extends ForbiddenException {
|
|
13
|
+
constructor(missingPermissions, operator = 'AND'){
|
|
14
|
+
const messageKey = operator === 'OR' ? ERROR_MESSAGES.INSUFFICIENT_PERMISSIONS_OR : ERROR_MESSAGES.INSUFFICIENT_PERMISSIONS;
|
|
18
15
|
super({
|
|
19
16
|
success: false,
|
|
20
|
-
message,
|
|
21
|
-
|
|
17
|
+
message: 'Insufficient permissions',
|
|
18
|
+
messageKey,
|
|
19
|
+
messageVariables: {
|
|
20
|
+
permissions: missingPermissions.join(', ')
|
|
21
|
+
},
|
|
22
22
|
missingPermissions,
|
|
23
23
|
operator
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
* Exception thrown when no permissions found for user
|
|
29
|
-
*/ export class NoPermissionsFoundException extends ForbiddenException {
|
|
27
|
+
export class NoPermissionsFoundException extends ForbiddenException {
|
|
30
28
|
constructor(){
|
|
31
29
|
super({
|
|
32
30
|
success: false,
|
|
33
|
-
message: 'No permissions found
|
|
34
|
-
|
|
31
|
+
message: 'No permissions found',
|
|
32
|
+
messageKey: ERROR_MESSAGES.NO_PERMISSIONS_FOUND
|
|
35
33
|
});
|
|
36
34
|
}
|
|
37
35
|
}
|