@valentine-efagene/qshelter-common 1.0.1 → 1.0.3
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/dist/OpenApiHelper.d.ts +9 -0
- package/dist/OpenApiHelper.js +118 -0
- package/dist/OpenApiHelper.js.map +1 -0
- package/dist/decorator/index.d.ts +2 -0
- package/dist/decorator/index.js +19 -0
- package/dist/decorator/index.js.map +1 -0
- package/dist/decorator/permission.decorator.d.ts +2 -0
- package/dist/decorator/permission.decorator.js +6 -0
- package/dist/decorator/permission.decorator.js.map +1 -0
- package/dist/decorator/tenant.decorator.d.ts +2 -0
- package/dist/decorator/tenant.decorator.js +13 -0
- package/dist/decorator/tenant.decorator.js.map +1 -0
- package/dist/entities/common.entity.js +1 -1
- package/dist/entities/common.entity.js.map +1 -1
- package/dist/entities/common.pure.entity.js +3 -2
- package/dist/entities/common.pure.entity.js.map +1 -1
- package/dist/entities/mortgage.entity.js +13 -13
- package/dist/entities/mortgage.entity.js.map +1 -1
- package/dist/entities/property.entity.d.ts +1 -2
- package/dist/entities/property.entity.js +6 -12
- package/dist/entities/property.entity.js.map +1 -1
- package/dist/entities/tenant.entity.d.ts +1 -1
- package/dist/entities/tenant.entity.js +3 -3
- package/dist/entities/tenant.entity.js.map +1 -1
- package/dist/entities/user.entity.d.ts +1 -1
- package/dist/entities/user.entity.js +7 -7
- package/dist/entities/user.entity.js.map +1 -1
- package/dist/entities/wallet.entity.js +9 -9
- package/dist/entities/wallet.entity.js.map +1 -1
- package/dist/guard/index.d.ts +2 -0
- package/dist/guard/index.js +19 -0
- package/dist/guard/index.js.map +1 -0
- package/dist/guard/permission.guard.d.ts +10 -0
- package/dist/guard/permission.guard.js +47 -0
- package/dist/guard/permission.guard.js.map +1 -0
- package/dist/guard/swagger-auth.guard.d.ts +1 -0
- package/dist/guard/swagger-auth.guard.js +9 -0
- package/dist/guard/swagger-auth.guard.js.map +1 -0
- package/dist/helpers/ArrayHelper.d.ts +2 -0
- package/dist/helpers/ArrayHelper.js +6 -0
- package/dist/helpers/ArrayHelper.js.map +1 -0
- package/dist/helpers/ConstantHelper.d.ts +36 -0
- package/{helpers/ConstantHelper.ts → dist/helpers/ConstantHelper.js} +36 -47
- package/dist/helpers/ConstantHelper.js.map +1 -0
- package/dist/helpers/CustomNamingStrategy.d.ts +7 -0
- package/dist/helpers/CustomNamingStrategy.js +22 -0
- package/dist/helpers/CustomNamingStrategy.js.map +1 -0
- package/dist/helpers/DateHelper.d.ts +3 -0
- package/dist/helpers/DateHelper.js +20 -0
- package/dist/helpers/DateHelper.js.map +1 -0
- package/dist/helpers/EmailHelper.d.ts +4 -0
- package/dist/helpers/EmailHelper.js +65 -0
- package/dist/helpers/EmailHelper.js.map +1 -0
- package/dist/helpers/FileSystemHelper.d.ts +15 -0
- package/dist/helpers/FileSystemHelper.js +112 -0
- package/dist/helpers/FileSystemHelper.js.map +1 -0
- package/dist/helpers/index.d.ts +5 -0
- package/dist/helpers/index.js +22 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/middleware/AccessLoggerMiddleware.d.ts +6 -0
- package/dist/middleware/AccessLoggerMiddleware.js +64 -0
- package/dist/middleware/AccessLoggerMiddleware.js.map +1 -0
- package/dist/middleware/AuthenticationMiddleware.d.ts +5 -0
- package/dist/middleware/AuthenticationMiddleware.js +19 -0
- package/dist/middleware/AuthenticationMiddleware.js.map +1 -0
- package/dist/middleware/TenantMiddleware.d.ts +14 -0
- package/dist/middleware/TenantMiddleware.js +49 -0
- package/dist/middleware/TenantMiddleware.js.map +1 -0
- package/dist/middleware/index.d.ts +3 -0
- package/dist/middleware/index.js +20 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/common.type.d.ts +15 -0
- package/dist/types/common.type.js +18 -1
- package/dist/types/common.type.js.map +1 -1
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.js +25 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mortgage-fsm.type.d.ts +180 -0
- package/dist/types/mortgage-fsm.type.js +130 -0
- package/dist/types/mortgage-fsm.type.js.map +1 -0
- package/dist/types/permission.enums.d.ts +42 -0
- package/dist/types/permission.enums.js +47 -0
- package/dist/types/permission.enums.js.map +1 -0
- package/dist/types/permission.type.d.ts +42 -0
- package/dist/types/permission.type.js +47 -0
- package/dist/types/permission.type.js.map +1 -0
- package/{types/policy.types.ts → dist/types/policy.type.d.ts} +0 -3
- package/dist/types/policy.type.js +3 -0
- package/dist/types/policy.type.js.map +1 -0
- package/dist/types/tenant.type.d.ts +13 -0
- package/dist/types/tenant.type.js +19 -0
- package/dist/types/tenant.type.js.map +1 -0
- package/dist/types/user.type.d.ts +10 -0
- package/dist/types/user.type.js +16 -0
- package/dist/types/user.type.js.map +1 -0
- package/package.json +51 -3
- package/OpenApiHelper.ts +0 -121
- package/decorator/permission.decorator.ts +0 -4
- package/decorator/tenant.decorator.ts +0 -16
- package/entities/BaseEntity.ts +0 -34
- package/entities/TenantAwareEntity.ts +0 -34
- package/entities/TenantAwareRepository.ts +0 -100
- package/entities/amenity.entity.ts +0 -10
- package/entities/common.entity.ts +0 -46
- package/entities/common.pure.entity.ts +0 -36
- package/entities/index.ts +0 -27
- package/entities/mortgage-document.entity.ts +0 -37
- package/entities/mortgage-downpayment-installment.entity.ts +0 -40
- package/entities/mortgage-downpayment-payment.entity.ts +0 -61
- package/entities/mortgage-downpayment.entity.ts +0 -43
- package/entities/mortgage-step.entity.ts +0 -33
- package/entities/mortgage-type.entity.ts +0 -31
- package/entities/mortgage.entity.ts +0 -89
- package/entities/password_reset_tokens.entity.ts +0 -25
- package/entities/permission.entity.ts +0 -12
- package/entities/property-document.entity.ts +0 -21
- package/entities/property-media.entity.ts +0 -23
- package/entities/property.entity.ts +0 -147
- package/entities/refresh_token.entity.ts +0 -16
- package/entities/role.entity.ts +0 -20
- package/entities/settings.entity.ts +0 -56
- package/entities/social.entity.ts +0 -27
- package/entities/tenant.entity.ts +0 -65
- package/entities/transaction.entity.ts +0 -56
- package/entities/user.entity.ts +0 -89
- package/entities/user_suspensions.entity.ts +0 -24
- package/entities/wallet.entity.ts +0 -54
- package/guard/permission.guard.ts +0 -42
- package/guard/swagger-auth.guard.ts +0 -9
- package/helpers/ArrayHelper.ts +0 -1
- package/helpers/CustomNamingStrategy.ts +0 -27
- package/helpers/DateHelper.ts +0 -21
- package/helpers/EmailHelper.ts +0 -38
- package/helpers/FileSystemHelper.ts +0 -101
- package/index.ts +0 -9
- package/middleware/AccessLoggerMiddleware.ts +0 -58
- package/middleware/AuthenticationMiddleware.ts +0 -13
- package/middleware/TenantMiddleware.ts +0 -52
- package/pagination/index.ts +0 -2
- package/pagination/pagination.helper.ts +0 -57
- package/pagination/pagination.types.ts +0 -21
- package/standard-response.ts +0 -16
- package/tsconfig.json +0 -33
- package/types/common.type.ts +0 -32
- package/types/mortgage-fsm.types.ts +0 -279
- package/types/property.type.ts +0 -10
- package/types/social.enums.ts +0 -17
- package/types/tenant.enums.ts +0 -14
- package/types/transaction.type.ts +0 -9
- package/types/user.enums.ts +0 -11
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TenantPlan = exports.TenantStatus = void 0;
|
|
4
|
+
var TenantStatus;
|
|
5
|
+
(function (TenantStatus) {
|
|
6
|
+
TenantStatus["ACTIVE"] = "active";
|
|
7
|
+
TenantStatus["SUSPENDED"] = "suspended";
|
|
8
|
+
TenantStatus["PENDING"] = "pending";
|
|
9
|
+
TenantStatus["TRIAL"] = "trial";
|
|
10
|
+
TenantStatus["CANCELLED"] = "cancelled";
|
|
11
|
+
})(TenantStatus || (exports.TenantStatus = TenantStatus = {}));
|
|
12
|
+
var TenantPlan;
|
|
13
|
+
(function (TenantPlan) {
|
|
14
|
+
TenantPlan["FREE"] = "free";
|
|
15
|
+
TenantPlan["BASIC"] = "basic";
|
|
16
|
+
TenantPlan["PREMIUM"] = "premium";
|
|
17
|
+
TenantPlan["ENTERPRISE"] = "enterprise";
|
|
18
|
+
})(TenantPlan || (exports.TenantPlan = TenantPlan = {}));
|
|
19
|
+
//# sourceMappingURL=tenant.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant.type.js","sourceRoot":"","sources":["../../types/tenant.type.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAMX;AAND,WAAY,YAAY;IACpB,iCAAiB,CAAA;IACjB,uCAAuB,CAAA;IACvB,mCAAmB,CAAA;IACnB,+BAAe,CAAA;IACf,uCAAuB,CAAA;AAC3B,CAAC,EANW,YAAY,4BAAZ,YAAY,QAMvB;AAED,IAAY,UAKX;AALD,WAAY,UAAU;IAClB,2BAAa,CAAA;IACb,6BAAe,CAAA;IACf,iCAAmB,CAAA;IACnB,uCAAyB,CAAA;AAC7B,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserStatus = exports.UserRole = void 0;
|
|
4
|
+
var UserRole;
|
|
5
|
+
(function (UserRole) {
|
|
6
|
+
UserRole["ADMIN"] = "admin";
|
|
7
|
+
UserRole["VENDOR"] = "vendor";
|
|
8
|
+
UserRole["USER"] = "user";
|
|
9
|
+
})(UserRole || (exports.UserRole = UserRole = {}));
|
|
10
|
+
var UserStatus;
|
|
11
|
+
(function (UserStatus) {
|
|
12
|
+
UserStatus["ACTIVE"] = "ACTIVE";
|
|
13
|
+
UserStatus["SUSPENDED"] = "SUSPENDED";
|
|
14
|
+
UserStatus["PENDING"] = "PENDING";
|
|
15
|
+
})(UserStatus || (exports.UserStatus = UserStatus = {}));
|
|
16
|
+
//# sourceMappingURL=user.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.type.js","sourceRoot":"","sources":["../../types/user.type.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,2BAAe,CAAA;IACf,6BAAiB,CAAA;IACjB,yBAAa,CAAA;AACf,CAAC,EAJW,QAAQ,wBAAR,QAAQ,QAInB;AAED,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,qCAAuB,CAAA;IACvB,iCAAmB,CAAA;AACrB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valentine-efagene/qshelter-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Shared common utilities, DTOs, entities, guards, middleware, decorators, and pagination for QShelter",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,6 +22,51 @@
|
|
|
22
22
|
],
|
|
23
23
|
"author": "Valentine Efagene",
|
|
24
24
|
"license": "MIT",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"require": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./*": {
|
|
34
|
+
"import": "./dist/*",
|
|
35
|
+
"require": "./dist/*"
|
|
36
|
+
},
|
|
37
|
+
"./middleware/*": {
|
|
38
|
+
"import": "./dist/middleware/*",
|
|
39
|
+
"require": "./dist/middleware/*"
|
|
40
|
+
},
|
|
41
|
+
"./guard/*": {
|
|
42
|
+
"import": "./dist/guard/*",
|
|
43
|
+
"require": "./dist/guard/*"
|
|
44
|
+
},
|
|
45
|
+
"./helpers/*": {
|
|
46
|
+
"import": "./dist/helpers/*",
|
|
47
|
+
"require": "./dist/helpers/*"
|
|
48
|
+
},
|
|
49
|
+
"./decorator/*": {
|
|
50
|
+
"import": "./dist/decorator/*",
|
|
51
|
+
"require": "./dist/decorator/*"
|
|
52
|
+
},
|
|
53
|
+
"./entities/*": {
|
|
54
|
+
"import": "./dist/entities/*",
|
|
55
|
+
"require": "./dist/entities/*"
|
|
56
|
+
},
|
|
57
|
+
"./types/*": {
|
|
58
|
+
"import": "./dist/types/*",
|
|
59
|
+
"require": "./dist/types/*"
|
|
60
|
+
},
|
|
61
|
+
"./OpenApiHelper": {
|
|
62
|
+
"import": "./dist/OpenApiHelper.js",
|
|
63
|
+
"require": "./dist/OpenApiHelper.js"
|
|
64
|
+
},
|
|
65
|
+
"./standard-response": {
|
|
66
|
+
"import": "./dist/standard-response.js",
|
|
67
|
+
"require": "./dist/standard-response.js"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
25
70
|
"peerDependencies": {
|
|
26
71
|
"typeorm": "^0.3.0",
|
|
27
72
|
"@nestjs/common": "^10.0.0",
|
|
@@ -31,7 +76,9 @@
|
|
|
31
76
|
"class-validator": "^0.14.0",
|
|
32
77
|
"class-transformer": "^0.5.0"
|
|
33
78
|
},
|
|
34
|
-
"dependencies": {
|
|
79
|
+
"dependencies": {
|
|
80
|
+
"handlebars": "^4.7.8"
|
|
81
|
+
},
|
|
35
82
|
"devDependencies": {
|
|
36
83
|
"@nestjs/swagger": "^7.4.0",
|
|
37
84
|
"typeorm": "^0.3.20",
|
|
@@ -41,6 +88,7 @@
|
|
|
41
88
|
"class-validator": "^0.14.0",
|
|
42
89
|
"class-transformer": "^0.5.1",
|
|
43
90
|
"typescript": "^5.0.0",
|
|
44
|
-
"@types/node": "^20.0.0"
|
|
91
|
+
"@types/node": "^20.0.0",
|
|
92
|
+
"@types/handlebars": "^4.1.0"
|
|
45
93
|
}
|
|
46
94
|
}
|
package/OpenApiHelper.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { ApiHeaderOptions, ApiResponseOptions } from '@nestjs/swagger';
|
|
2
|
-
|
|
3
|
-
export default class OpenApiHelper {
|
|
4
|
-
public static userIdHeader: ApiHeaderOptions = {
|
|
5
|
-
name: 'user_id',
|
|
6
|
-
description: "Requesting user's ID",
|
|
7
|
-
required: true,
|
|
8
|
-
example: '1',
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
public static responseDoc: ApiResponseOptions = {
|
|
12
|
-
status: 200,
|
|
13
|
-
description: 'Successful response',
|
|
14
|
-
schema: {
|
|
15
|
-
type: 'object',
|
|
16
|
-
properties: {
|
|
17
|
-
statusCode: { type: 'number' },
|
|
18
|
-
message: { type: 'string' },
|
|
19
|
-
data: { type: 'object' },
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
public static paginatedResponseDoc: ApiResponseOptions = {
|
|
25
|
-
status: 200,
|
|
26
|
-
description: 'Successful response',
|
|
27
|
-
schema: {
|
|
28
|
-
type: 'object',
|
|
29
|
-
properties: {
|
|
30
|
-
statusCode: { type: 'number' },
|
|
31
|
-
message: { type: 'string' },
|
|
32
|
-
data: {
|
|
33
|
-
type: 'object',
|
|
34
|
-
properties: {
|
|
35
|
-
data: { type: 'array', items: { type: 'object' } }, // Adjust the type based on your actual item type
|
|
36
|
-
meta: {
|
|
37
|
-
type: 'object',
|
|
38
|
-
properties: {
|
|
39
|
-
itemsPerPage: { type: 'number' },
|
|
40
|
-
totalItems: { type: 'number' },
|
|
41
|
-
currentPage: { type: 'number' },
|
|
42
|
-
totalPages: { type: 'number' },
|
|
43
|
-
sortBy: { type: 'array' },
|
|
44
|
-
search: { type: 'string' },
|
|
45
|
-
filter: {
|
|
46
|
-
type: 'object',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
link: {
|
|
51
|
-
type: 'object',
|
|
52
|
-
properties: {
|
|
53
|
-
first: { type: 'string' },
|
|
54
|
-
previous: { type: 'string' },
|
|
55
|
-
current: { type: 'string' },
|
|
56
|
-
next: { type: 'string' },
|
|
57
|
-
last: { type: 'string' },
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
public static arrayResponseDoc: ApiResponseOptions = {
|
|
67
|
-
status: 200,
|
|
68
|
-
description: 'Successful response',
|
|
69
|
-
schema: {
|
|
70
|
-
type: 'object',
|
|
71
|
-
properties: {
|
|
72
|
-
statusCode: { type: 'number' },
|
|
73
|
-
message: { type: 'string' },
|
|
74
|
-
data: {
|
|
75
|
-
type: 'array',
|
|
76
|
-
items: { type: 'object' },
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
public static nullResponseDoc: ApiResponseOptions = {
|
|
83
|
-
status: 200,
|
|
84
|
-
description: 'Successful response',
|
|
85
|
-
schema: {
|
|
86
|
-
oneOf: [
|
|
87
|
-
{
|
|
88
|
-
type: 'object',
|
|
89
|
-
properties: {
|
|
90
|
-
statusCode: { type: 'number' },
|
|
91
|
-
message: { type: 'string' },
|
|
92
|
-
data: {
|
|
93
|
-
type: 'string',
|
|
94
|
-
nullable: true,
|
|
95
|
-
description: 'Nothing is returned',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
public static errorResponseDoc: ApiResponseOptions = {
|
|
104
|
-
status: 200,
|
|
105
|
-
description: 'Successful response',
|
|
106
|
-
schema: {
|
|
107
|
-
oneOf: [
|
|
108
|
-
{
|
|
109
|
-
type: 'object',
|
|
110
|
-
properties: {
|
|
111
|
-
statusCode: { type: 'number' },
|
|
112
|
-
message: { type: 'string' },
|
|
113
|
-
error: {
|
|
114
|
-
type: 'object',
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
|
|
2
|
-
import { Tenant } from '../../tenant/tenant.entity';
|
|
3
|
-
|
|
4
|
-
export const CurrentTenant = createParamDecorator(
|
|
5
|
-
(data: unknown, ctx: ExecutionContext): Tenant | undefined => {
|
|
6
|
-
const request = ctx.switchToHttp().getRequest();
|
|
7
|
-
return request.tenant;
|
|
8
|
-
},
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
export const CurrentTenantId = createParamDecorator(
|
|
12
|
-
(data: unknown, ctx: ExecutionContext): number | undefined => {
|
|
13
|
-
const request = ctx.switchToHttp().getRequest();
|
|
14
|
-
return request.tenantId;
|
|
15
|
-
},
|
|
16
|
-
);
|
package/entities/BaseEntity.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import Tenant from './tenant.entity';
|
|
2
|
-
import { CreateDateColumn, DeleteDateColumn, PrimaryGeneratedColumn, UpdateDateColumn, Column, Index, ManyToOne, JoinColumn } from 'typeorm';
|
|
3
|
-
|
|
4
|
-
export class BaseEntity {
|
|
5
|
-
@PrimaryGeneratedColumn()
|
|
6
|
-
id: number;
|
|
7
|
-
|
|
8
|
-
@CreateDateColumn({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
9
|
-
createdAt: Date;
|
|
10
|
-
|
|
11
|
-
@UpdateDateColumn({
|
|
12
|
-
type: 'timestamp',
|
|
13
|
-
default: () => 'CURRENT_TIMESTAMP',
|
|
14
|
-
onUpdate: 'CURRENT_TIMESTAMP',
|
|
15
|
-
})
|
|
16
|
-
updatedAt: Date;
|
|
17
|
-
|
|
18
|
-
@DeleteDateColumn({ nullable: true, default: null })
|
|
19
|
-
deletedAt: Date;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Tenant-aware version of BaseEntity
|
|
24
|
-
* Use this for entities that need tenant isolation
|
|
25
|
-
*/
|
|
26
|
-
export class TenantAwareBaseEntity extends BaseEntity {
|
|
27
|
-
@ManyToOne(() => Tenant, { onDelete: 'CASCADE' })
|
|
28
|
-
@JoinColumn({ name: 'tenant_id' })
|
|
29
|
-
tenant: Tenant;
|
|
30
|
-
|
|
31
|
-
@Column({ name: 'tenant_id' })
|
|
32
|
-
@Index()
|
|
33
|
-
tenantId: number;
|
|
34
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import Tenant from './tenant.entity';
|
|
2
|
-
import { CreateDateColumn, DeleteDateColumn, PrimaryGeneratedColumn, UpdateDateColumn, Column, Index, ManyToOne, JoinColumn } from 'typeorm';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Base entity with tenant support
|
|
6
|
-
* All entities that need to be isolated by tenant should extend this
|
|
7
|
-
*/
|
|
8
|
-
export class TenantAwareEntity {
|
|
9
|
-
@PrimaryGeneratedColumn()
|
|
10
|
-
id: number;
|
|
11
|
-
|
|
12
|
-
@ManyToOne(() => Tenant, { onDelete: 'CASCADE' })
|
|
13
|
-
@JoinColumn({ name: 'tenant_id' })
|
|
14
|
-
tenant: Tenant;
|
|
15
|
-
|
|
16
|
-
@Column({ name: 'tenant_id' })
|
|
17
|
-
@Index()
|
|
18
|
-
tenantId: number;
|
|
19
|
-
|
|
20
|
-
@CreateDateColumn({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
21
|
-
createdAt: Date;
|
|
22
|
-
|
|
23
|
-
@UpdateDateColumn({
|
|
24
|
-
type: 'timestamp',
|
|
25
|
-
default: () => 'CURRENT_TIMESTAMP',
|
|
26
|
-
onUpdate: 'CURRENT_TIMESTAMP',
|
|
27
|
-
})
|
|
28
|
-
updatedAt: Date;
|
|
29
|
-
|
|
30
|
-
@DeleteDateColumn({ nullable: true, default: null })
|
|
31
|
-
deletedAt: Date;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default TenantAwareEntity;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { Repository, FindManyOptions, FindOneOptions, FindOptionsWhere, DeepPartial } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Base repository with automatic tenant scoping
|
|
5
|
-
* All queries automatically filter by tenantId
|
|
6
|
-
*/
|
|
7
|
-
export class TenantAwareRepository<Entity extends { tenantId: number }> extends Repository<Entity> {
|
|
8
|
-
/**
|
|
9
|
-
* Find entities with automatic tenant filtering
|
|
10
|
-
*/
|
|
11
|
-
async findByTenant(tenantId: number, options?: FindManyOptions<Entity>): Promise<Entity[]> {
|
|
12
|
-
return this.find({
|
|
13
|
-
...options,
|
|
14
|
-
where: {
|
|
15
|
-
...options?.where,
|
|
16
|
-
tenantId,
|
|
17
|
-
} as FindOptionsWhere<Entity>,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Find one entity with automatic tenant filtering
|
|
23
|
-
*/
|
|
24
|
-
async findOneByTenant(
|
|
25
|
-
tenantId: number,
|
|
26
|
-
options?: FindOneOptions<Entity>
|
|
27
|
-
): Promise<Entity | null> {
|
|
28
|
-
return this.findOne({
|
|
29
|
-
...options,
|
|
30
|
-
where: {
|
|
31
|
-
...options?.where,
|
|
32
|
-
tenantId,
|
|
33
|
-
} as FindOptionsWhere<Entity>,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Count entities with automatic tenant filtering
|
|
39
|
-
*/
|
|
40
|
-
async countByTenant(tenantId: number, options?: FindManyOptions<Entity>): Promise<number> {
|
|
41
|
-
return this.count({
|
|
42
|
-
...options,
|
|
43
|
-
where: {
|
|
44
|
-
...options?.where,
|
|
45
|
-
tenantId,
|
|
46
|
-
} as FindOptionsWhere<Entity>,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Create and save entity with automatic tenantId
|
|
52
|
-
*/
|
|
53
|
-
async createForTenant(tenantId: number, entityData: DeepPartial<Entity>): Promise<Entity> {
|
|
54
|
-
const entity = this.create({
|
|
55
|
-
...entityData,
|
|
56
|
-
tenantId,
|
|
57
|
-
} as DeepPartial<Entity>);
|
|
58
|
-
return this.save(entity);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Update entity with tenant validation
|
|
63
|
-
*/
|
|
64
|
-
async updateForTenant(
|
|
65
|
-
tenantId: number,
|
|
66
|
-
id: number,
|
|
67
|
-
entityData: DeepPartial<Entity>
|
|
68
|
-
): Promise<Entity> {
|
|
69
|
-
const entity = await this.findOneByTenant(tenantId, { where: { id } as any });
|
|
70
|
-
if (!entity) {
|
|
71
|
-
throw new Error(`Entity with ID ${id} not found for tenant ${tenantId}`);
|
|
72
|
-
}
|
|
73
|
-
Object.assign(entity, entityData);
|
|
74
|
-
return this.save(entity);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Delete entity with tenant validation
|
|
79
|
-
*/
|
|
80
|
-
async deleteForTenant(tenantId: number, id: number): Promise<void> {
|
|
81
|
-
const entity = await this.findOneByTenant(tenantId, { where: { id } as any });
|
|
82
|
-
if (!entity) {
|
|
83
|
-
throw new Error(`Entity with ID ${id} not found for tenant ${tenantId}`);
|
|
84
|
-
}
|
|
85
|
-
await this.remove(entity);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Soft delete entity with tenant validation
|
|
90
|
-
*/
|
|
91
|
-
async softDeleteForTenant(tenantId: number, id: number): Promise<void> {
|
|
92
|
-
const entity = await this.findOneByTenant(tenantId, { where: { id } as any });
|
|
93
|
-
if (!entity) {
|
|
94
|
-
throw new Error(`Entity with ID ${id} not found for tenant ${tenantId}`);
|
|
95
|
-
}
|
|
96
|
-
await this.softRemove(entity);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export default TenantAwareRepository;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { User } from './user.entity';
|
|
2
|
-
import {
|
|
3
|
-
ManyToOne,
|
|
4
|
-
JoinColumn,
|
|
5
|
-
Column,
|
|
6
|
-
} from 'typeorm';
|
|
7
|
-
import { DocumentStatus } from '../types/common.type';
|
|
8
|
-
import { AbstractTenantAwareEntity } from './common.pure.entity';
|
|
9
|
-
|
|
10
|
-
export abstract class AbstractBaseReviewableEntity extends AbstractTenantAwareEntity {
|
|
11
|
-
@ManyToOne(() => User, { eager: true })
|
|
12
|
-
@JoinColumn({ name: 'reviewed_by' })
|
|
13
|
-
reviewer: User;
|
|
14
|
-
|
|
15
|
-
@Column({ type: 'timestamp', nullable: true })
|
|
16
|
-
reviewedAt: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export abstract class AbstractBaseDocumentEntity extends AbstractBaseReviewableEntity {
|
|
20
|
-
@Column({
|
|
21
|
-
type: 'enum',
|
|
22
|
-
enum: DocumentStatus,
|
|
23
|
-
default: DocumentStatus.PENDING,
|
|
24
|
-
})
|
|
25
|
-
status: DocumentStatus;
|
|
26
|
-
|
|
27
|
-
@Column({ nullable: true })
|
|
28
|
-
comment: string;
|
|
29
|
-
|
|
30
|
-
@Column({ type: 'text', nullable: false })
|
|
31
|
-
url: string;
|
|
32
|
-
|
|
33
|
-
@Column({ nullable: true })
|
|
34
|
-
description: string;
|
|
35
|
-
|
|
36
|
-
@Column({ nullable: true })
|
|
37
|
-
name: string;
|
|
38
|
-
|
|
39
|
-
@Column({ nullable: false, comment: "In bytes" })
|
|
40
|
-
size: number
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export abstract class AbstractBaseMediaEntity extends AbstractBaseDocumentEntity {
|
|
44
|
-
// @Column()
|
|
45
|
-
// mimeType: string;
|
|
46
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { CreateDateColumn, DeleteDateColumn, PrimaryGeneratedColumn, UpdateDateColumn, Column, Index, ManyToOne, JoinColumn } from "typeorm";
|
|
3
|
-
import { Tenant } from "./tenant.entity";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export abstract class AbstractBaseEntity {
|
|
7
|
-
@PrimaryGeneratedColumn()
|
|
8
|
-
id: number;
|
|
9
|
-
|
|
10
|
-
@CreateDateColumn({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
11
|
-
createdAt: Date;
|
|
12
|
-
|
|
13
|
-
@UpdateDateColumn({
|
|
14
|
-
type: 'timestamp',
|
|
15
|
-
default: () => 'CURRENT_TIMESTAMP',
|
|
16
|
-
onUpdate: 'CURRENT_TIMESTAMP',
|
|
17
|
-
})
|
|
18
|
-
updatedAt: Date;
|
|
19
|
-
|
|
20
|
-
@DeleteDateColumn({ nullable: true, default: null })
|
|
21
|
-
deletedAt: Date;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Tenant-aware base entity
|
|
26
|
-
* All entities that need tenant isolation should extend this
|
|
27
|
-
*/
|
|
28
|
-
export abstract class AbstractTenantAwareEntity extends AbstractBaseEntity {
|
|
29
|
-
@ManyToOne(() => Tenant, { onDelete: 'CASCADE' })
|
|
30
|
-
@JoinColumn({ name: 'tenant_id' })
|
|
31
|
-
tenant: Tenant;
|
|
32
|
-
|
|
33
|
-
@Column({ name: 'tenant_id' })
|
|
34
|
-
@Index()
|
|
35
|
-
tenantId: number;
|
|
36
|
-
}
|
package/entities/index.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export * from './BaseEntity';
|
|
2
|
-
export * from './TenantAwareEntity';
|
|
3
|
-
export * from './TenantAwareRepository';
|
|
4
|
-
export * from './amenity.entity';
|
|
5
|
-
export * from './common.entity';
|
|
6
|
-
export * from './common.pure.entity';
|
|
7
|
-
export * from './mortgage-document.entity';
|
|
8
|
-
export * from './mortgage-downpayment-installment.entity';
|
|
9
|
-
export * from './mortgage-downpayment-payment.entity';
|
|
10
|
-
export * from './mortgage-downpayment.entity';
|
|
11
|
-
export * from './mortgage-step.entity';
|
|
12
|
-
export * from './mortgage-type.entity';
|
|
13
|
-
export * from './mortgage.entity';
|
|
14
|
-
export * from './password_reset_tokens.entity';
|
|
15
|
-
export * from './permission.entity';
|
|
16
|
-
export * from './property-document.entity';
|
|
17
|
-
export * from './property-media.entity';
|
|
18
|
-
export * from './property.entity';
|
|
19
|
-
export * from './refresh_token.entity';
|
|
20
|
-
export * from './role.entity';
|
|
21
|
-
export * from './settings.entity';
|
|
22
|
-
export * from './social.entity';
|
|
23
|
-
export * from './tenant.entity';
|
|
24
|
-
export * from './transaction.entity';
|
|
25
|
-
export * from './user.entity';
|
|
26
|
-
export * from './user_suspensions.entity';
|
|
27
|
-
export * from './wallet.entity';
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
|
|
2
|
-
import { AbstractBaseReviewableEntity } from './common.entity';
|
|
3
|
-
import { Mortgage } from './mortgage.entity';
|
|
4
|
-
import { User } from './user.entity';
|
|
5
|
-
|
|
6
|
-
@Entity({ name: 'mortgage_document' })
|
|
7
|
-
export class MortgageDocument extends AbstractBaseReviewableEntity {
|
|
8
|
-
@ManyToOne(() => Mortgage, (mortgage) => mortgage.documents, { onDelete: 'CASCADE' })
|
|
9
|
-
@JoinColumn({ name: 'mortgage_id' })
|
|
10
|
-
mortgage: Mortgage;
|
|
11
|
-
|
|
12
|
-
@Column({ nullable: true })
|
|
13
|
-
mortgageId: number;
|
|
14
|
-
|
|
15
|
-
@Column()
|
|
16
|
-
fileName: string;
|
|
17
|
-
|
|
18
|
-
// Allow null URLs for template/placeholder documents created from mortgage type templates.
|
|
19
|
-
@Column({ nullable: true })
|
|
20
|
-
url: string;
|
|
21
|
-
|
|
22
|
-
// Flag to mark this document as a template/placeholder (not yet uploaded). Template docs typically have a name but no URL.
|
|
23
|
-
@Column({ default: false })
|
|
24
|
-
isTemplate: boolean;
|
|
25
|
-
|
|
26
|
-
@Column({ nullable: true })
|
|
27
|
-
mimeType: string;
|
|
28
|
-
|
|
29
|
-
@ManyToOne(() => User, { nullable: true })
|
|
30
|
-
@JoinColumn({ name: 'uploaded_by' })
|
|
31
|
-
uploadedBy: User;
|
|
32
|
-
|
|
33
|
-
@Column({ nullable: true })
|
|
34
|
-
uploadedById: number;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default MortgageDocument;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
|
|
2
|
-
import { AbstractBaseEntity } from './common.pure.entity';
|
|
3
|
-
import { MortgageDownpaymentPlan } from './mortgage-downpayment.entity';
|
|
4
|
-
|
|
5
|
-
export enum InstallmentStatus {
|
|
6
|
-
PENDING = 'PENDING',
|
|
7
|
-
PARTIAL = 'PARTIAL',
|
|
8
|
-
PAID = 'PAID',
|
|
9
|
-
LATE = 'LATE',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@Entity({ name: 'mortgage_downpayment_installment' })
|
|
13
|
-
export class MortgageDownpaymentInstallment extends AbstractBaseEntity {
|
|
14
|
-
@ManyToOne(() => MortgageDownpaymentPlan, (p) => p.installments, { onDelete: 'CASCADE' })
|
|
15
|
-
@JoinColumn({ name: 'plan_id' })
|
|
16
|
-
plan: MortgageDownpaymentPlan;
|
|
17
|
-
|
|
18
|
-
@Column({ nullable: true })
|
|
19
|
-
planId: number;
|
|
20
|
-
|
|
21
|
-
@Column({ type: 'int' })
|
|
22
|
-
sequence: number;
|
|
23
|
-
|
|
24
|
-
@Column({ type: 'date' })
|
|
25
|
-
dueDate: Date;
|
|
26
|
-
|
|
27
|
-
@Column({ type: 'double precision' })
|
|
28
|
-
amountDue: number;
|
|
29
|
-
|
|
30
|
-
@Column({ type: 'double precision', default: 0 })
|
|
31
|
-
amountPaid: number;
|
|
32
|
-
|
|
33
|
-
@Column({ type: 'timestamp', nullable: true })
|
|
34
|
-
paidAt: Date;
|
|
35
|
-
|
|
36
|
-
@Column({ type: 'enum', enum: InstallmentStatus, default: InstallmentStatus.PENDING })
|
|
37
|
-
status: InstallmentStatus;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default MortgageDownpaymentInstallment;
|