@campxdev/server-shared 1.0.0
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/.prettierrc +5 -0
- package/.vscode/settings.json +13 -0
- package/dist/common/config/mongo.config.d.ts +4 -0
- package/dist/common/config/mongo.config.d.ts.map +1 -0
- package/dist/common/config/mongo.config.js +17 -0
- package/dist/common/config/mongo.config.js.map +1 -0
- package/dist/common/decorators/message-pattern.decorator.d.ts +9 -0
- package/dist/common/decorators/message-pattern.decorator.d.ts.map +1 -0
- package/dist/common/decorators/message-pattern.decorator.js +17 -0
- package/dist/common/decorators/message-pattern.decorator.js.map +1 -0
- package/dist/common/decorators/request.decorators.d.ts +6 -0
- package/dist/common/decorators/request.decorators.d.ts.map +1 -0
- package/dist/common/decorators/request.decorators.js +37 -0
- package/dist/common/decorators/request.decorators.js.map +1 -0
- package/dist/common/decorators/time-validation.decorator.d.ts +3 -0
- package/dist/common/decorators/time-validation.decorator.d.ts.map +1 -0
- package/dist/common/decorators/time-validation.decorator.js +27 -0
- package/dist/common/decorators/time-validation.decorator.js.map +1 -0
- package/dist/common/filters/unhandled-exception.filter.d.ts +5 -0
- package/dist/common/filters/unhandled-exception.filter.d.ts.map +1 -0
- package/dist/common/filters/unhandled-exception.filter.js +39 -0
- package/dist/common/filters/unhandled-exception.filter.js.map +1 -0
- package/dist/common/guards/guard.d.ts +7 -0
- package/dist/common/guards/guard.d.ts.map +1 -0
- package/dist/common/guards/guard.js +20 -0
- package/dist/common/guards/guard.js.map +1 -0
- package/dist/common/index.d.ts +10 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +26 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/interfaces/context.interface.d.ts +64 -0
- package/dist/common/interfaces/context.interface.d.ts.map +1 -0
- package/dist/common/interfaces/context.interface.js +3 -0
- package/dist/common/interfaces/context.interface.js.map +1 -0
- package/dist/common/store/request-store.d.ts +23 -0
- package/dist/common/store/request-store.d.ts.map +1 -0
- package/dist/common/store/request-store.js +96 -0
- package/dist/common/store/request-store.js.map +1 -0
- package/dist/common/store/store-config.d.ts +9 -0
- package/dist/common/store/store-config.d.ts.map +1 -0
- package/dist/common/store/store-config.js +28 -0
- package/dist/common/store/store-config.js.map +1 -0
- package/dist/domain/db-connection.module.d.ts +4 -0
- package/dist/domain/db-connection.module.d.ts.map +1 -0
- package/dist/domain/db-connection.module.js +30 -0
- package/dist/domain/db-connection.module.js.map +1 -0
- package/dist/domain/index.d.ts +3 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +19 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/schemas/tenant.schema.d.ts +80 -0
- package/dist/domain/schemas/tenant.schema.d.ts.map +1 -0
- package/dist/domain/schemas/tenant.schema.js +193 -0
- package/dist/domain/schemas/tenant.schema.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/permissions/index.d.ts +2 -0
- package/dist/permissions/index.d.ts.map +1 -0
- package/dist/permissions/index.js +18 -0
- package/dist/permissions/index.js.map +1 -0
- package/dist/permissions/permissions.d.ts +1890 -0
- package/dist/permissions/permissions.d.ts.map +1 -0
- package/dist/permissions/permissions.js +1913 -0
- package/dist/permissions/permissions.js.map +1 -0
- package/dist/shared-module/index.d.ts +3 -0
- package/dist/shared-module/index.d.ts.map +1 -0
- package/dist/shared-module/index.js +8 -0
- package/dist/shared-module/index.js.map +1 -0
- package/dist/shared-module/shared.module.d.ts +9 -0
- package/dist/shared-module/shared.module.d.ts.map +1 -0
- package/dist/shared-module/shared.module.js +28 -0
- package/dist/shared-module/shared.module.js.map +1 -0
- package/dist/shared-module/shared.service.d.ts +27 -0
- package/dist/shared-module/shared.service.d.ts.map +1 -0
- package/dist/shared-module/shared.service.js +103 -0
- package/dist/shared-module/shared.service.js.map +1 -0
- package/dist/utils/constants.d.ts +11 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +14 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/utils.d.ts +24 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +225 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +37 -0
- package/src/common/config/mongo.config.ts +13 -0
- package/src/common/decorators/message-pattern.decorator.ts +14 -0
- package/src/common/decorators/request.decorators.ts +32 -0
- package/src/common/decorators/time-validation.decorator.ts +22 -0
- package/src/common/filters/unhandled-exception.filter.ts +29 -0
- package/src/common/guards/guard.ts +19 -0
- package/src/common/index.ts +9 -0
- package/src/common/interfaces/context.interface.ts +68 -0
- package/src/common/store/request-store.ts +96 -0
- package/src/common/store/store-config.ts +25 -0
- package/src/domain/db-connection.module.ts +20 -0
- package/src/domain/index.ts +2 -0
- package/src/domain/schemas/tenant.schema.ts +112 -0
- package/src/index.ts +5 -0
- package/src/permissions/index.ts +1 -0
- package/src/permissions/permissions.ts +1943 -0
- package/src/shared-module/index.ts +2 -0
- package/src/shared-module/shared.module.ts +31 -0
- package/src/shared-module/shared.service.ts +101 -0
- package/src/utils/constants.ts +11 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/utils.ts +191 -0
- package/tsconfig.json +19 -0
package/.prettierrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo.config.d.ts","sourceRoot":"","sources":["../../../src/common/config/mongo.config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;CAYvB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mongoConfig = void 0;
|
|
4
|
+
const mongoConfig = () => {
|
|
5
|
+
const username = encodeURIComponent(process.env.MONGO_DB_USERNAME);
|
|
6
|
+
const password = encodeURIComponent(process.env.MONGO_DB_PASSWORD);
|
|
7
|
+
const DB_NAME = process.env.MONGO_DB_NAME;
|
|
8
|
+
const DB_HOST = process.env.MONGO_DB_HOST;
|
|
9
|
+
const AUTH = `${username}:${password}`;
|
|
10
|
+
const DB = `${DB_HOST}/${DB_NAME}`;
|
|
11
|
+
const MONGO_URI = `mongodb+srv://${AUTH}@${DB}?retryWrites=true&w=majority`;
|
|
12
|
+
return {
|
|
13
|
+
MONGO_URI,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
exports.mongoConfig = mongoConfig;
|
|
17
|
+
//# sourceMappingURL=mongo.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo.config.js","sourceRoot":"","sources":["../../../src/common/config/mongo.config.ts"],"names":[],"mappings":";;;AAAO,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAC1C,MAAM,IAAI,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC;IACvC,MAAM,EAAE,GAAG,GAAG,OAAO,IAAI,OAAO,EAAE,CAAC;IACnC,MAAM,SAAS,GAAG,iBAAiB,IAAI,IAAI,EAAE,8BAA8B,CAAC;IAE5E,OAAO;QACL,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,WAAW,eAYtB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class IMessageProps {
|
|
2
|
+
cmd: string;
|
|
3
|
+
action: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const MessagePatterProps: {
|
|
6
|
+
service: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const MessagePattern: (props: IMessageProps) => MethodDecorator;
|
|
9
|
+
//# sourceMappingURL=message-pattern.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-pattern.decorator.d.ts","sourceRoot":"","sources":["../../../src/common/decorators/message-pattern.decorator.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAa;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,kBAAkB;;CAE9B,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,aAAa,oBAElD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessagePattern = exports.MessagePatterProps = exports.IMessageProps = void 0;
|
|
4
|
+
const microservices_1 = require("@nestjs/microservices");
|
|
5
|
+
class IMessageProps {
|
|
6
|
+
cmd;
|
|
7
|
+
action;
|
|
8
|
+
}
|
|
9
|
+
exports.IMessageProps = IMessageProps;
|
|
10
|
+
exports.MessagePatterProps = {
|
|
11
|
+
service: 'square',
|
|
12
|
+
};
|
|
13
|
+
const MessagePattern = (props) => {
|
|
14
|
+
return (0, microservices_1.MessagePattern)({ service: exports.MessagePatterProps.service, ...props });
|
|
15
|
+
};
|
|
16
|
+
exports.MessagePattern = MessagePattern;
|
|
17
|
+
//# sourceMappingURL=message-pattern.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-pattern.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/message-pattern.decorator.ts"],"names":[],"mappings":";;;AAAA,yDAAkE;AAElE,MAAa,aAAa;IACxB,GAAG,CAAS;IACZ,MAAM,CAAS;CAChB;AAHD,sCAGC;AAEY,QAAA,kBAAkB,GAAG;IAChC,OAAO,EAAE,QAAQ;CAClB,CAAC;AAEK,MAAM,cAAc,GAAG,CAAC,KAAoB,EAAE,EAAE;IACrD,OAAO,IAAA,8BAAO,EAAC,EAAE,OAAO,EAAE,0BAAkB,CAAC,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;AACpE,CAAC,CAAC;AAFW,QAAA,cAAc,kBAEzB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const RPCBody: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
2
|
+
export declare const RPCQuery: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
3
|
+
export declare const RPCParam: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
4
|
+
export declare const RPCUploadedFile: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
5
|
+
export declare const RPCUploadedFiles: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
6
|
+
//# sourceMappingURL=request.decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.decorators.d.ts","sourceRoot":"","sources":["../../../src/common/decorators/request.decorators.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,yLAKlB,CAAC;AAEH,eAAO,MAAM,QAAQ,yLAKnB,CAAC;AAEH,eAAO,MAAM,QAAQ,yLAKnB,CAAC;AAEH,eAAO,MAAM,eAAe,yLAG1B,CAAC;AAEH,eAAO,MAAM,gBAAgB,yLAG3B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RPCUploadedFiles = exports.RPCUploadedFile = exports.RPCParam = exports.RPCQuery = exports.RPCBody = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.RPCBody = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
6
|
+
const request = ctx.switchToRpc().getData();
|
|
7
|
+
if (request.body === undefined || request.body === null)
|
|
8
|
+
return {};
|
|
9
|
+
if (data)
|
|
10
|
+
return request.body[data];
|
|
11
|
+
return request.body;
|
|
12
|
+
});
|
|
13
|
+
exports.RPCQuery = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
14
|
+
const request = ctx.switchToRpc().getData();
|
|
15
|
+
if (request.query === undefined || request.query === null)
|
|
16
|
+
return {};
|
|
17
|
+
if (data)
|
|
18
|
+
return request.query[data];
|
|
19
|
+
return request.query;
|
|
20
|
+
});
|
|
21
|
+
exports.RPCParam = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
22
|
+
const request = ctx.switchToRpc().getData();
|
|
23
|
+
if (request.param === undefined || request.param === null)
|
|
24
|
+
return {};
|
|
25
|
+
if (data)
|
|
26
|
+
return request.param[data];
|
|
27
|
+
return request.param;
|
|
28
|
+
});
|
|
29
|
+
exports.RPCUploadedFile = (0, common_1.createParamDecorator)((_data, ctx) => {
|
|
30
|
+
const request = ctx.switchToRpc().getData();
|
|
31
|
+
return request.file;
|
|
32
|
+
});
|
|
33
|
+
exports.RPCUploadedFiles = (0, common_1.createParamDecorator)((_data, ctx) => {
|
|
34
|
+
const request = ctx.switchToRpc().getData();
|
|
35
|
+
return request.files || [];
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=request.decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.decorators.js","sourceRoot":"","sources":["../../../src/common/decorators/request.decorators.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAE3D,QAAA,OAAO,GAAG,IAAA,6BAAoB,EAAC,CAAC,IAAY,EAAE,GAAqB,EAAE,EAAE;IAClF,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC;IAC5C,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACnE,IAAI,IAAI;QAAE,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC,CAAC,CAAC;AAEU,QAAA,QAAQ,GAAG,IAAA,6BAAoB,EAAC,CAAC,IAAY,EAAE,GAAqB,EAAE,EAAE;IACnF,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC;IAC5C,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACrE,IAAI,IAAI;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,OAAO,CAAC,KAAK,CAAC;AACvB,CAAC,CAAC,CAAC;AAEU,QAAA,QAAQ,GAAG,IAAA,6BAAoB,EAAC,CAAC,IAAY,EAAE,GAAqB,EAAE,EAAE;IACnF,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC;IAC5C,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACrE,IAAI,IAAI;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,OAAO,CAAC,KAAK,CAAC;AACvB,CAAC,CAAC,CAAC;AAEU,QAAA,eAAe,GAAG,IAAA,6BAAoB,EAAC,CAAC,KAAa,EAAE,GAAqB,EAAE,EAAE;IAC3F,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC;IAC5C,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC,CAAC,CAAC;AAEU,QAAA,gBAAgB,GAAG,IAAA,6BAAoB,EAAC,CAAC,KAAa,EAAE,GAAqB,EAAE,EAAE;IAC5F,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC;IAC5C,OAAO,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;AAC7B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-validation.decorator.d.ts","sourceRoot":"","sources":["../../../src/common/decorators/time-validation.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,wBAAgB,MAAM,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,SAC7C,MAAM,gBAAgB,MAAM,UAkB1C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsTime = void 0;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
function IsTime(validationOptions) {
|
|
6
|
+
return (obj, propertyName) => {
|
|
7
|
+
(0, class_validator_1.registerDecorator)({
|
|
8
|
+
propertyName: propertyName,
|
|
9
|
+
target: obj.constructor,
|
|
10
|
+
options: validationOptions,
|
|
11
|
+
name: 'isTime',
|
|
12
|
+
validator: {
|
|
13
|
+
validate(value) {
|
|
14
|
+
if (typeof value !== 'string')
|
|
15
|
+
return false;
|
|
16
|
+
const timeRegex = /^([0-9]|[0-1][0-9]|2[0-3]):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9])$/;
|
|
17
|
+
return timeRegex.test(value);
|
|
18
|
+
},
|
|
19
|
+
defaultMessage() {
|
|
20
|
+
return `${propertyName} must be a valid time in the format HH:mm:ss`;
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.IsTime = IsTime;
|
|
27
|
+
//# sourceMappingURL=time-validation.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-validation.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/time-validation.decorator.ts"],"names":[],"mappings":";;;AAAA,qDAAuE;AAEvE,SAAgB,MAAM,CAAC,iBAAqC;IAC1D,OAAO,CAAC,GAAW,EAAE,YAAoB,EAAE,EAAE;QAC3C,IAAA,mCAAiB,EAAC;YAChB,YAAY,EAAE,YAAY;YAC1B,MAAM,EAAE,GAAG,CAAC,WAAW;YACvB,OAAO,EAAE,iBAAiB;YAC1B,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE;gBACT,QAAQ,CAAC,KAAU;oBACjB,IAAI,OAAO,KAAK,KAAK,QAAQ;wBAAE,OAAO,KAAK,CAAC;oBAC5C,MAAM,SAAS,GAAG,mEAAmE,CAAC;oBACtF,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC/B,CAAC;gBACD,cAAc;oBACZ,OAAO,GAAG,YAAY,8CAA8C,CAAC;gBACvE,CAAC;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAnBD,wBAmBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unhandled-exception.filter.d.ts","sourceRoot":"","sources":["../../../src/common/filters/unhandled-exception.filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGvE,qBACa,wBAAwB,CAAC,CAAC,SAAS,KAAK,CAAE,YAAW,eAAe;IAC/E,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa;CAuBxC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.UnhandledExceptionFilter = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const microservices_1 = require("@nestjs/microservices");
|
|
12
|
+
let UnhandledExceptionFilter = class UnhandledExceptionFilter {
|
|
13
|
+
catch(exception, host) {
|
|
14
|
+
console.log(exception);
|
|
15
|
+
const status = exception['status'];
|
|
16
|
+
const response = exception['response'];
|
|
17
|
+
if (status && response) {
|
|
18
|
+
throw new microservices_1.RpcException({
|
|
19
|
+
statusCode: status,
|
|
20
|
+
response: response,
|
|
21
|
+
message: exception.message,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
throw new microservices_1.RpcException({
|
|
25
|
+
statusCode: 500,
|
|
26
|
+
response: {
|
|
27
|
+
statusCode: 500,
|
|
28
|
+
error: 'Internal Server Error',
|
|
29
|
+
message: exception.message,
|
|
30
|
+
},
|
|
31
|
+
message: exception.message,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
UnhandledExceptionFilter = __decorate([
|
|
36
|
+
(0, common_1.Catch)()
|
|
37
|
+
], UnhandledExceptionFilter);
|
|
38
|
+
exports.UnhandledExceptionFilter = UnhandledExceptionFilter;
|
|
39
|
+
//# sourceMappingURL=unhandled-exception.filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unhandled-exception.filter.js","sourceRoot":"","sources":["../../../src/common/filters/unhandled-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAuE;AACvE,yDAAqD;AAG9C,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACnC,KAAK,CAAC,SAAY,EAAE,IAAmB;QACrC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvB,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QACnC,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;QAEvC,IAAI,MAAM,IAAI,QAAQ,EAAE;YACtB,MAAM,IAAI,4BAAY,CAAC;gBACrB,UAAU,EAAE,MAAM;gBAClB,QAAQ,EAAE,QAAQ;gBAClB,OAAO,EAAE,SAAS,CAAC,OAAO;aAC3B,CAAC,CAAC;SACJ;QAED,MAAM,IAAI,4BAAY,CAAC;YACrB,UAAU,EAAE,GAAG;YACf,QAAQ,EAAE;gBACR,UAAU,EAAE,GAAG;gBACf,KAAK,EAAE,uBAAuB;gBAC9B,OAAO,EAAE,SAAS,CAAC,OAAO;aAC3B;YACD,OAAO,EAAE,SAAS,CAAC,OAAO;SAC3B,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAxBY,wBAAwB;IADpC,IAAA,cAAK,GAAE;GACK,wBAAwB,CAwBpC;AAxBY,4DAAwB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const AUTHENTICATE = "authenticate";
|
|
2
|
+
export declare const JwtAuthGuard: () => import("@nestjs/common").CustomDecorator<string>;
|
|
3
|
+
export declare const CHECK_PERMISSION_KEY = "checkPermissionKey";
|
|
4
|
+
export declare const CheckPermission: (permission: string) => import("@nestjs/common").CustomDecorator<string>;
|
|
5
|
+
export declare const CHECK_EVALUATOR = "checkEvaluator";
|
|
6
|
+
export declare const CheckEvaluator: () => import("@nestjs/common").CustomDecorator<string>;
|
|
7
|
+
//# sourceMappingURL=guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../../src/common/guards/guard.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,eAAO,MAAM,YAAY,wDAExB,CAAC;AAEF,eAAO,MAAM,oBAAoB,uBAAuB,CAAC;AAEzD,eAAO,MAAM,eAAe,eAAgB,MAAM,qDAEjD,CAAC;AAEF,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAEhD,eAAO,MAAM,cAAc,wDAE1B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CheckEvaluator = exports.CHECK_EVALUATOR = exports.CheckPermission = exports.CHECK_PERMISSION_KEY = exports.JwtAuthGuard = exports.AUTHENTICATE = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.AUTHENTICATE = 'authenticate';
|
|
6
|
+
const JwtAuthGuard = () => {
|
|
7
|
+
return (0, common_1.SetMetadata)(exports.AUTHENTICATE, true);
|
|
8
|
+
};
|
|
9
|
+
exports.JwtAuthGuard = JwtAuthGuard;
|
|
10
|
+
exports.CHECK_PERMISSION_KEY = 'checkPermissionKey';
|
|
11
|
+
const CheckPermission = (permission) => {
|
|
12
|
+
return (0, common_1.SetMetadata)(exports.CHECK_PERMISSION_KEY, permission);
|
|
13
|
+
};
|
|
14
|
+
exports.CheckPermission = CheckPermission;
|
|
15
|
+
exports.CHECK_EVALUATOR = 'checkEvaluator';
|
|
16
|
+
const CheckEvaluator = () => {
|
|
17
|
+
return (0, common_1.SetMetadata)(exports.CHECK_EVALUATOR, true);
|
|
18
|
+
};
|
|
19
|
+
exports.CheckEvaluator = CheckEvaluator;
|
|
20
|
+
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../../src/common/guards/guard.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAEhC,QAAA,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,OAAO,IAAA,oBAAW,EAAC,oBAAY,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB;AAEW,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AAElD,MAAM,eAAe,GAAG,CAAC,UAAkB,EAAE,EAAE;IACpD,OAAO,IAAA,oBAAW,EAAC,4BAAoB,EAAE,UAAU,CAAC,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B;AAEW,QAAA,eAAe,GAAG,gBAAgB,CAAC;AAEzC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,OAAO,IAAA,oBAAW,EAAC,uBAAe,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC,CAAC;AAFW,QAAA,cAAc,kBAEzB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './config/mongo.config';
|
|
2
|
+
export * from './decorators/message-pattern.decorator';
|
|
3
|
+
export * from './decorators/request.decorators';
|
|
4
|
+
export * from './decorators/time-validation.decorator';
|
|
5
|
+
export * from './filters/unhandled-exception.filter';
|
|
6
|
+
export * from './guards/guard';
|
|
7
|
+
export * from './interfaces/context.interface';
|
|
8
|
+
export * from './store/request-store';
|
|
9
|
+
export * from './store/store-config';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wCAAwC,CAAC;AACvD,cAAc,iCAAiC,CAAC;AAChD,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./config/mongo.config"), exports);
|
|
18
|
+
__exportStar(require("./decorators/message-pattern.decorator"), exports);
|
|
19
|
+
__exportStar(require("./decorators/request.decorators"), exports);
|
|
20
|
+
__exportStar(require("./decorators/time-validation.decorator"), exports);
|
|
21
|
+
__exportStar(require("./filters/unhandled-exception.filter"), exports);
|
|
22
|
+
__exportStar(require("./guards/guard"), exports);
|
|
23
|
+
__exportStar(require("./interfaces/context.interface"), exports);
|
|
24
|
+
__exportStar(require("./store/request-store"), exports);
|
|
25
|
+
__exportStar(require("./store/store-config"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,yEAAuD;AACvD,kEAAgD;AAChD,yEAAuD;AACvD,uEAAqD;AACrD,iDAA+B;AAC/B,iEAA+C;AAC/C,wDAAsC;AACtC,uDAAqC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as mongoose from 'mongoose';
|
|
2
|
+
export interface IRequest {
|
|
3
|
+
cmd: {
|
|
4
|
+
cmd: string;
|
|
5
|
+
action: string;
|
|
6
|
+
service?: string;
|
|
7
|
+
};
|
|
8
|
+
body?: any;
|
|
9
|
+
param?: any;
|
|
10
|
+
query?: any;
|
|
11
|
+
file?: any;
|
|
12
|
+
files?: any;
|
|
13
|
+
request?: {
|
|
14
|
+
subDomain: string;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
};
|
|
17
|
+
tenantDetails?: TenantDetails;
|
|
18
|
+
userData?: UserData;
|
|
19
|
+
isMicroservice?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface TenantDetails {
|
|
22
|
+
_id: mongoose.Types.ObjectId;
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
subDomain: string;
|
|
26
|
+
host: string;
|
|
27
|
+
port: number;
|
|
28
|
+
username: string;
|
|
29
|
+
password: string;
|
|
30
|
+
database: string;
|
|
31
|
+
env: Env;
|
|
32
|
+
easyWDMSConfig: IEasyWDMSConfig;
|
|
33
|
+
}
|
|
34
|
+
export interface Env {
|
|
35
|
+
s3AccessKeyId: string;
|
|
36
|
+
s3SecretAccessKey: string;
|
|
37
|
+
s3BucketName: string;
|
|
38
|
+
s3Region: string;
|
|
39
|
+
s3Endpoint: string;
|
|
40
|
+
sentryDsn: null;
|
|
41
|
+
razorpayKey: string;
|
|
42
|
+
razorpaySecret: string;
|
|
43
|
+
clientName: string;
|
|
44
|
+
_id: string;
|
|
45
|
+
}
|
|
46
|
+
export interface IEasyWDMSConfig {
|
|
47
|
+
_id: string;
|
|
48
|
+
host: string;
|
|
49
|
+
port: number;
|
|
50
|
+
username: string;
|
|
51
|
+
password: string;
|
|
52
|
+
database: string;
|
|
53
|
+
baseApiUrl: string;
|
|
54
|
+
}
|
|
55
|
+
export interface UserData {
|
|
56
|
+
id?: number;
|
|
57
|
+
userId?: string;
|
|
58
|
+
email?: string;
|
|
59
|
+
isActive: boolean;
|
|
60
|
+
tenantId?: string;
|
|
61
|
+
evaluatorId?: number;
|
|
62
|
+
leadId?: number;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=context.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.interface.d.ts","sourceRoot":"","sources":["../../../src/common/interfaces/context.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE;QACH,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,OAAO,CAAC,EAAE;QACR,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,GAAG,CAAC;IACT,cAAc,EAAE,eAAe,CAAC;CACjC;AAED,MAAM,WAAW,GAAG;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.interface.js","sourceRoot":"","sources":["../../../src/common/interfaces/context.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DataSource, EntityManager } from 'typeorm';
|
|
2
|
+
import { IRequest, TenantDetails, UserData } from '../interfaces/context.interface';
|
|
3
|
+
export declare const EXPRESS_REQUEST = "EXPRESS_REQUEST";
|
|
4
|
+
export declare const TENANT_EASY_WDMS_DATA_SOURCE = "TENANT_EASY_WDMS_DATA_SOURCE";
|
|
5
|
+
export declare const TENANT_DATA_SOURCE = "TENANT_DATA_SOURCE";
|
|
6
|
+
export declare const TENANT_DETAILS = "TENANT_DETAILS";
|
|
7
|
+
export declare const USER_DATA = "USER_DATA";
|
|
8
|
+
export declare function setRequest(req: any): void;
|
|
9
|
+
export declare function getRequest(): IRequest;
|
|
10
|
+
export declare function setTenantDataSource(dataSource: DataSource): void;
|
|
11
|
+
export declare function getDataSource(): DataSource;
|
|
12
|
+
export declare function getManager(): EntityManager;
|
|
13
|
+
export declare function setTenantDetails(tenant: TenantDetails): void;
|
|
14
|
+
export declare function getTenantDetailsIfExists(): TenantDetails;
|
|
15
|
+
export declare function getTenantDetails(): TenantDetails;
|
|
16
|
+
export declare function getS3BaseUrl(): string;
|
|
17
|
+
export declare function setUserData(user: UserData): void;
|
|
18
|
+
export declare function getUserData(): UserData;
|
|
19
|
+
export declare function getEvaluatorId(): number;
|
|
20
|
+
export declare function getLeadId(): number;
|
|
21
|
+
export declare function getEasyWDMSDataSource(): DataSource;
|
|
22
|
+
export declare function getEasyWDMSManager(): EntityManager;
|
|
23
|
+
//# sourceMappingURL=request-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-store.d.ts","sourceRoot":"","sources":["../../../src/common/store/request-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAGpF,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AAC3E,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAEzC;AAED,wBAAgB,UAAU,IAAI,QAAQ,CAErC;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAEhE;AAED,wBAAgB,aAAa,IAAI,UAAU,CAM1C;AAED,wBAAgB,UAAU,IAAI,aAAa,CAG1C;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAE5D;AAED,wBAAgB,wBAAwB,IAAI,aAAa,CAExD;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAOhD;AAED,wBAAgB,YAAY,IAAI,MAAM,CAGrC;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAEhD;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAMvC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAOlC;AAED,wBAAgB,qBAAqB,IAAI,UAAU,CAMlD;AAED,wBAAgB,kBAAkB,IAAI,aAAa,CAGlD"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEasyWDMSManager = exports.getEasyWDMSDataSource = exports.getLeadId = exports.getEvaluatorId = exports.getUserData = exports.setUserData = exports.getS3BaseUrl = exports.getTenantDetails = exports.getTenantDetailsIfExists = exports.setTenantDetails = exports.getManager = exports.getDataSource = exports.setTenantDataSource = exports.getRequest = exports.setRequest = exports.USER_DATA = exports.TENANT_DETAILS = exports.TENANT_DATA_SOURCE = exports.TENANT_EASY_WDMS_DATA_SOURCE = exports.EXPRESS_REQUEST = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const utils_1 = require("../../utils/utils");
|
|
6
|
+
const store_config_1 = require("./store-config");
|
|
7
|
+
exports.EXPRESS_REQUEST = 'EXPRESS_REQUEST';
|
|
8
|
+
exports.TENANT_EASY_WDMS_DATA_SOURCE = 'TENANT_EASY_WDMS_DATA_SOURCE';
|
|
9
|
+
exports.TENANT_DATA_SOURCE = 'TENANT_DATA_SOURCE';
|
|
10
|
+
exports.TENANT_DETAILS = 'TENANT_DETAILS';
|
|
11
|
+
exports.USER_DATA = 'USER_DATA';
|
|
12
|
+
function setRequest(req) {
|
|
13
|
+
(0, store_config_1.set)(exports.EXPRESS_REQUEST, req);
|
|
14
|
+
}
|
|
15
|
+
exports.setRequest = setRequest;
|
|
16
|
+
function getRequest() {
|
|
17
|
+
return (0, store_config_1.get)(exports.EXPRESS_REQUEST);
|
|
18
|
+
}
|
|
19
|
+
exports.getRequest = getRequest;
|
|
20
|
+
function setTenantDataSource(dataSource) {
|
|
21
|
+
(0, store_config_1.set)(exports.TENANT_DATA_SOURCE, dataSource);
|
|
22
|
+
}
|
|
23
|
+
exports.setTenantDataSource = setTenantDataSource;
|
|
24
|
+
function getDataSource() {
|
|
25
|
+
const dataSource = (0, store_config_1.get)(exports.TENANT_DATA_SOURCE);
|
|
26
|
+
if (!dataSource) {
|
|
27
|
+
throw new common_1.UnprocessableEntityException('Unable to connect to data source');
|
|
28
|
+
}
|
|
29
|
+
return dataSource;
|
|
30
|
+
}
|
|
31
|
+
exports.getDataSource = getDataSource;
|
|
32
|
+
function getManager() {
|
|
33
|
+
const dataSource = getDataSource();
|
|
34
|
+
return dataSource.manager;
|
|
35
|
+
}
|
|
36
|
+
exports.getManager = getManager;
|
|
37
|
+
function setTenantDetails(tenant) {
|
|
38
|
+
(0, store_config_1.set)(exports.TENANT_DETAILS, tenant);
|
|
39
|
+
}
|
|
40
|
+
exports.setTenantDetails = setTenantDetails;
|
|
41
|
+
function getTenantDetailsIfExists() {
|
|
42
|
+
return (0, store_config_1.get)(exports.TENANT_DETAILS);
|
|
43
|
+
}
|
|
44
|
+
exports.getTenantDetailsIfExists = getTenantDetailsIfExists;
|
|
45
|
+
function getTenantDetails() {
|
|
46
|
+
const tenant = (0, store_config_1.get)(exports.TENANT_DETAILS);
|
|
47
|
+
if (!tenant) {
|
|
48
|
+
throw new common_1.UnprocessableEntityException('Unable to get tenant details');
|
|
49
|
+
}
|
|
50
|
+
tenant._id = (0, utils_1.getObjectId)(tenant._id);
|
|
51
|
+
return tenant;
|
|
52
|
+
}
|
|
53
|
+
exports.getTenantDetails = getTenantDetails;
|
|
54
|
+
function getS3BaseUrl() {
|
|
55
|
+
const tenant = (0, store_config_1.get)(exports.TENANT_DETAILS);
|
|
56
|
+
return tenant?.env?.s3Endpoint;
|
|
57
|
+
}
|
|
58
|
+
exports.getS3BaseUrl = getS3BaseUrl;
|
|
59
|
+
function setUserData(user) {
|
|
60
|
+
(0, store_config_1.set)(exports.USER_DATA, user);
|
|
61
|
+
}
|
|
62
|
+
exports.setUserData = setUserData;
|
|
63
|
+
function getUserData() {
|
|
64
|
+
return (0, store_config_1.get)(exports.USER_DATA);
|
|
65
|
+
}
|
|
66
|
+
exports.getUserData = getUserData;
|
|
67
|
+
function getEvaluatorId() {
|
|
68
|
+
const userData = getUserData();
|
|
69
|
+
if (!userData?.evaluatorId) {
|
|
70
|
+
throw new common_1.UnprocessableEntityException('You are not an evaluator');
|
|
71
|
+
}
|
|
72
|
+
return userData?.evaluatorId;
|
|
73
|
+
}
|
|
74
|
+
exports.getEvaluatorId = getEvaluatorId;
|
|
75
|
+
function getLeadId() {
|
|
76
|
+
const userData = getUserData();
|
|
77
|
+
if (!userData?.leadId) {
|
|
78
|
+
throw new common_1.UnprocessableEntityException('You are not a lead');
|
|
79
|
+
}
|
|
80
|
+
return userData?.leadId;
|
|
81
|
+
}
|
|
82
|
+
exports.getLeadId = getLeadId;
|
|
83
|
+
function getEasyWDMSDataSource() {
|
|
84
|
+
const dataSource = (0, store_config_1.get)(exports.TENANT_EASY_WDMS_DATA_SOURCE);
|
|
85
|
+
if (!dataSource) {
|
|
86
|
+
throw new common_1.UnprocessableEntityException('EasyWDMS database not configured');
|
|
87
|
+
}
|
|
88
|
+
return dataSource;
|
|
89
|
+
}
|
|
90
|
+
exports.getEasyWDMSDataSource = getEasyWDMSDataSource;
|
|
91
|
+
function getEasyWDMSManager() {
|
|
92
|
+
const dataSource = getEasyWDMSDataSource();
|
|
93
|
+
return dataSource.manager;
|
|
94
|
+
}
|
|
95
|
+
exports.getEasyWDMSManager = getEasyWDMSManager;
|
|
96
|
+
//# sourceMappingURL=request-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-store.js","sourceRoot":"","sources":["../../../src/common/store/request-store.ts"],"names":[],"mappings":";;;AAAA,2CAA8D;AAE9D,6CAAgD;AAEhD,iDAA0C;AAE7B,QAAA,eAAe,GAAG,iBAAiB,CAAC;AACpC,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAC9D,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAC1C,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAClC,QAAA,SAAS,GAAG,WAAW,CAAC;AAErC,SAAgB,UAAU,CAAC,GAAQ;IACjC,IAAA,kBAAG,EAAC,uBAAe,EAAE,GAAG,CAAC,CAAC;AAC5B,CAAC;AAFD,gCAEC;AAED,SAAgB,UAAU;IACxB,OAAO,IAAA,kBAAG,EAAC,uBAAe,CAAC,CAAC;AAC9B,CAAC;AAFD,gCAEC;AAED,SAAgB,mBAAmB,CAAC,UAAsB;IACxD,IAAA,kBAAG,EAAC,0BAAkB,EAAE,UAAU,CAAC,CAAC;AACtC,CAAC;AAFD,kDAEC;AAED,SAAgB,aAAa;IAC3B,MAAM,UAAU,GAAG,IAAA,kBAAG,EAAa,0BAAkB,CAAC,CAAC;IACvD,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,qCAA4B,CAAC,kCAAkC,CAAC,CAAC;KAC5E;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAND,sCAMC;AAED,SAAgB,UAAU;IACxB,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,OAAO,UAAU,CAAC,OAAO,CAAC;AAC5B,CAAC;AAHD,gCAGC;AAED,SAAgB,gBAAgB,CAAC,MAAqB;IACpD,IAAA,kBAAG,EAAC,sBAAc,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAFD,4CAEC;AAED,SAAgB,wBAAwB;IACtC,OAAO,IAAA,kBAAG,EAAgB,sBAAc,CAAC,CAAC;AAC5C,CAAC;AAFD,4DAEC;AAED,SAAgB,gBAAgB;IAC9B,MAAM,MAAM,GAAG,IAAA,kBAAG,EAAgB,sBAAc,CAAC,CAAC;IAClD,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,qCAA4B,CAAC,8BAA8B,CAAC,CAAC;KACxE;IACD,MAAM,CAAC,GAAG,GAAG,IAAA,mBAAW,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACrC,OAAO,MAAM,CAAC;AAChB,CAAC;AAPD,4CAOC;AAED,SAAgB,YAAY;IAC1B,MAAM,MAAM,GAAG,IAAA,kBAAG,EAAC,sBAAc,CAAkB,CAAC;IACpD,OAAO,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC;AACjC,CAAC;AAHD,oCAGC;AAED,SAAgB,WAAW,CAAC,IAAc;IACxC,IAAA,kBAAG,EAAC,iBAAS,EAAE,IAAI,CAAC,CAAC;AACvB,CAAC;AAFD,kCAEC;AAED,SAAgB,WAAW;IACzB,OAAO,IAAA,kBAAG,EAAC,iBAAS,CAAC,CAAC;AACxB,CAAC;AAFD,kCAEC;AAED,SAAgB,cAAc;IAC5B,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE;QAC1B,MAAM,IAAI,qCAA4B,CAAC,0BAA0B,CAAC,CAAC;KACpE;IACD,OAAO,QAAQ,EAAE,WAAW,CAAC;AAC/B,CAAC;AAND,wCAMC;AAED,SAAgB,SAAS;IACvB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE;QACrB,MAAM,IAAI,qCAA4B,CAAC,oBAAoB,CAAC,CAAC;KAC9D;IAED,OAAO,QAAQ,EAAE,MAAM,CAAC;AAC1B,CAAC;AAPD,8BAOC;AAED,SAAgB,qBAAqB;IACnC,MAAM,UAAU,GAAG,IAAA,kBAAG,EAAa,oCAA4B,CAAC,CAAC;IACjE,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,qCAA4B,CAAC,kCAAkC,CAAC,CAAC;KAC5E;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAND,sDAMC;AAED,SAAgB,kBAAkB;IAChC,MAAM,UAAU,GAAG,qBAAqB,EAAE,CAAC;IAC3C,OAAO,UAAU,CAAC,OAAO,CAAC;AAC5B,CAAC;AAHD,gDAGC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { NextFunction, Request, Response } from 'express';
|
|
3
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
4
|
+
export declare const store: AsyncLocalStorage<unknown>;
|
|
5
|
+
export declare const storeMiddleWare: (_req: Request, _res: Response, next: NextFunction) => void;
|
|
6
|
+
export declare const getStore: () => Map<string, any>;
|
|
7
|
+
export declare const set: (key: string, value: any) => Map<string, any>;
|
|
8
|
+
export declare function get<T>(key: string): T;
|
|
9
|
+
//# sourceMappingURL=store-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-config.d.ts","sourceRoot":"","sources":["../../../src/common/store/store-config.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,eAAO,MAAM,KAAK,4BAA0B,CAAC;AAE7C,eAAO,MAAM,eAAe,SAAU,OAAO,QAAQ,QAAQ,QAAQ,YAAY,SAEhF,CAAC;AAEF,eAAO,MAAM,QAAQ,wBAMpB,CAAC;AAEF,eAAO,MAAM,GAAG,QAAS,MAAM,SAAS,GAAG,qBAA+B,CAAC;AAE3E,wBAAgB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAIrC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get = exports.set = exports.getStore = exports.storeMiddleWare = exports.store = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
6
|
+
exports.store = new node_async_hooks_1.AsyncLocalStorage();
|
|
7
|
+
const storeMiddleWare = (_req, _res, next) => {
|
|
8
|
+
exports.store.run(new Map(), () => next());
|
|
9
|
+
};
|
|
10
|
+
exports.storeMiddleWare = storeMiddleWare;
|
|
11
|
+
const getStore = () => {
|
|
12
|
+
const data = exports.store.getStore();
|
|
13
|
+
if (!data) {
|
|
14
|
+
throw new common_1.BadRequestException('Request store is not initialized');
|
|
15
|
+
}
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
exports.getStore = getStore;
|
|
19
|
+
const set = (key, value) => (0, exports.getStore)().set(key, value);
|
|
20
|
+
exports.set = set;
|
|
21
|
+
function get(key) {
|
|
22
|
+
const data = exports.store.getStore();
|
|
23
|
+
if (!data)
|
|
24
|
+
return;
|
|
25
|
+
return data.get(key);
|
|
26
|
+
}
|
|
27
|
+
exports.get = get;
|
|
28
|
+
//# sourceMappingURL=store-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-config.js","sourceRoot":"","sources":["../../../src/common/store/store-config.ts"],"names":[],"mappings":";;;AAAA,2CAAqD;AAErD,uDAAqD;AAExC,QAAA,KAAK,GAAG,IAAI,oCAAiB,EAAE,CAAC;AAEtC,MAAM,eAAe,GAAG,CAAC,IAAa,EAAE,IAAc,EAAE,IAAkB,EAAE,EAAE;IACnF,aAAK,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B;AAEK,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,MAAM,IAAI,GAAG,aAAK,CAAC,QAAQ,EAAE,CAAC;IAC9B,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,4BAAmB,CAAC,kCAAkC,CAAC,CAAC;KACnE;IACD,OAAO,IAAwB,CAAC;AAClC,CAAC,CAAC;AANW,QAAA,QAAQ,YAMnB;AAEK,MAAM,GAAG,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,EAAE,CAAC,IAAA,gBAAQ,GAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAA9D,QAAA,GAAG,OAA2D;AAE3E,SAAgB,GAAG,CAAI,GAAW;IAChC,MAAM,IAAI,GAAG,aAAK,CAAC,QAAQ,EAAsB,CAAC;IAClD,IAAI,CAAC,IAAI;QAAE,OAAO;IAClB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAJD,kBAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-connection.module.d.ts","sourceRoot":"","sources":["../../src/domain/db-connection.module.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAO7D,qBASa,kBAAkB;CAAG"}
|