@campxdev/server-shared 1.6.28 → 1.6.30

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.
Files changed (59) hide show
  1. package/dist/domain/index.d.ts +1 -0
  2. package/dist/domain/index.d.ts.map +1 -1
  3. package/dist/domain/index.js +1 -0
  4. package/dist/domain/index.js.map +1 -1
  5. package/dist/domain/modules/shared-domain.module.d.ts.map +1 -1
  6. package/dist/domain/modules/shared-domain.module.js +3 -2
  7. package/dist/domain/modules/shared-domain.module.js.map +1 -1
  8. package/dist/domain/mongodb-repositories/mongodb-global-user.repository.d.ts +1 -0
  9. package/dist/domain/mongodb-repositories/mongodb-global-user.repository.d.ts.map +1 -1
  10. package/dist/domain/mongodb-repositories/mongodb-global-user.repository.js +9 -0
  11. package/dist/domain/mongodb-repositories/mongodb-global-user.repository.js.map +1 -1
  12. package/dist/domain/other-schemas/sub-schemas.schema.d.ts +2 -0
  13. package/dist/domain/other-schemas/sub-schemas.schema.d.ts.map +1 -1
  14. package/dist/domain/other-schemas/sub-schemas.schema.js +9 -0
  15. package/dist/domain/other-schemas/sub-schemas.schema.js.map +1 -1
  16. package/dist/domain/repositories/global-user.repository.d.ts +1 -0
  17. package/dist/domain/repositories/global-user.repository.d.ts.map +1 -1
  18. package/dist/domain/repositories/global-user.repository.js.map +1 -1
  19. package/dist/domain/schemas/global-users.schema.d.ts +3 -0
  20. package/dist/domain/schemas/global-users.schema.d.ts.map +1 -1
  21. package/dist/domain/schemas/global-users.schema.js +12 -0
  22. package/dist/domain/schemas/global-users.schema.js.map +1 -1
  23. package/dist/domain/schemas/tenant.schema.d.ts +7 -0
  24. package/dist/domain/schemas/tenant.schema.d.ts.map +1 -1
  25. package/dist/domain/schemas/tenant.schema.js +28 -1
  26. package/dist/domain/schemas/tenant.schema.js.map +1 -1
  27. package/dist/domain/services/shared-domain.service.d.ts +34 -0
  28. package/dist/domain/services/shared-domain.service.d.ts.map +1 -0
  29. package/dist/domain/services/shared-domain.service.js +57 -0
  30. package/dist/domain/services/shared-domain.service.js.map +1 -0
  31. package/dist/frappe/frappe.module.d.ts +3 -0
  32. package/dist/frappe/frappe.module.d.ts.map +1 -0
  33. package/dist/frappe/frappe.module.js +23 -0
  34. package/dist/frappe/frappe.module.js.map +1 -0
  35. package/dist/frappe/index.d.ts +5 -0
  36. package/dist/frappe/index.d.ts.map +1 -0
  37. package/dist/frappe/index.js +21 -0
  38. package/dist/frappe/index.js.map +1 -0
  39. package/dist/frappe/services/department.service.d.ts +25 -0
  40. package/dist/frappe/services/department.service.d.ts.map +1 -0
  41. package/dist/frappe/services/department.service.js +83 -0
  42. package/dist/frappe/services/department.service.js.map +1 -0
  43. package/dist/frappe/services/designation.service.d.ts +25 -0
  44. package/dist/frappe/services/designation.service.d.ts.map +1 -0
  45. package/dist/frappe/services/designation.service.js +80 -0
  46. package/dist/frappe/services/designation.service.js.map +1 -0
  47. package/dist/frappe/services/user.service.d.ts +46 -0
  48. package/dist/frappe/services/user.service.d.ts.map +1 -0
  49. package/dist/frappe/services/user.service.js +172 -0
  50. package/dist/frappe/services/user.service.js.map +1 -0
  51. package/dist/index.d.ts +1 -0
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +1 -0
  54. package/dist/index.js.map +1 -1
  55. package/dist/request-store/request-store.d.ts +29 -1
  56. package/dist/request-store/request-store.d.ts.map +1 -1
  57. package/dist/request-store/request-store.js +20 -2
  58. package/dist/request-store/request-store.js.map +1 -1
  59. package/package.json +1 -1
@@ -0,0 +1,5 @@
1
+ export * from './frappe.module';
2
+ export * from './services/user.service';
3
+ export * from './services/designation.service';
4
+ export * from './services/department.service';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/frappe/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC"}
@@ -0,0 +1,21 @@
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("./frappe.module"), exports);
18
+ __exportStar(require("./services/user.service"), exports);
19
+ __exportStar(require("./services/designation.service"), exports);
20
+ __exportStar(require("./services/department.service"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/frappe/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,0DAAwC;AACxC,iEAA+C;AAC/C,gEAA8C"}
@@ -0,0 +1,25 @@
1
+ export declare class FrappeDepartmentService {
2
+ private getAxiosConfig;
3
+ getDepartments(props: {
4
+ baseUrl: string;
5
+ token: string;
6
+ secret: string;
7
+ }): Promise<any>;
8
+ createDepartment(props: {
9
+ baseUrl: string;
10
+ token: string;
11
+ secret: string;
12
+ departmentData: {
13
+ department_name: string;
14
+ };
15
+ }): Promise<any>;
16
+ reNameDepartment(props: {
17
+ baseUrl: string;
18
+ token: string;
19
+ secret: string;
20
+ oldDepartmentName: string;
21
+ newDepartmentName: string;
22
+ merge?: boolean;
23
+ }): Promise<any>;
24
+ }
25
+ //# sourceMappingURL=department.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"department.service.d.ts","sourceRoot":"","sources":["../../../src/frappe/services/department.service.ts"],"names":[],"mappings":"AAGA,qBACa,uBAAuB;IAClC,OAAO,CAAC,cAAc;IAUhB,cAAc,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAqBvF,gBAAgB,CAAC,KAAK,EAAE;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,EAAE;YAAE,eAAe,EAAE,MAAM,CAAA;SAAE,CAAC;KAC7C,GAAG,OAAO,CAAC,GAAG,CAAC;IAqBV,gBAAgB,CAAC,KAAK,EAAE;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,iBAAiB,EAAE,MAAM,CAAC;QAC1B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GAAG,OAAO,CAAC,GAAG,CAAC;CA0BjB"}
@@ -0,0 +1,83 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FrappeDepartmentService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const axios_1 = __importDefault(require("axios"));
15
+ let FrappeDepartmentService = class FrappeDepartmentService {
16
+ getAxiosConfig(token, secret) {
17
+ return {
18
+ headers: {
19
+ Authorization: `token ${token}:${secret}`,
20
+ 'Content-Type': 'application/json',
21
+ },
22
+ };
23
+ }
24
+ // Get Departments in ERPNext
25
+ async getDepartments(props) {
26
+ const { baseUrl, token, secret } = props;
27
+ const url = `${baseUrl}/api/resource/Department`;
28
+ const config = this.getAxiosConfig(token, secret);
29
+ try {
30
+ const response = await axios_1.default.get(url, config);
31
+ return response.data;
32
+ }
33
+ catch (error) {
34
+ if (axios_1.default.isAxiosError(error)) {
35
+ throw new common_1.UnprocessableEntityException('Error fetching departments from Frappe', error.response?.data || error.message);
36
+ }
37
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
38
+ }
39
+ }
40
+ // Create Department in ERPNext
41
+ async createDepartment(props) {
42
+ const { baseUrl, token, secret, departmentData } = props;
43
+ const url = `${baseUrl}/api/resource/Department`;
44
+ const config = this.getAxiosConfig(token, secret);
45
+ try {
46
+ const response = await axios_1.default.post(url, departmentData, config);
47
+ return response.data;
48
+ }
49
+ catch (error) {
50
+ if (axios_1.default.isAxiosError(error)) {
51
+ throw new common_1.UnprocessableEntityException('Error creating department in Frappe', error.response?.data || error.message);
52
+ }
53
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
54
+ }
55
+ }
56
+ // Rename Department in ERPNext
57
+ async reNameDepartment(props) {
58
+ const { baseUrl, token, secret, oldDepartmentName, newDepartmentName, merge = false } = props;
59
+ const url = `${baseUrl}/api/method/frappe.rename_doc`;
60
+ const config = this.getAxiosConfig(token, secret);
61
+ const renamePayload = {
62
+ doctype: 'Department',
63
+ old: oldDepartmentName,
64
+ new: newDepartmentName,
65
+ merge: merge ? 1 : 0, // Set merge option (0 = No, 1 = Yes)
66
+ };
67
+ try {
68
+ const response = await axios_1.default.post(url, renamePayload, config);
69
+ return response.data;
70
+ }
71
+ catch (error) {
72
+ if (axios_1.default.isAxiosError(error)) {
73
+ throw new common_1.UnprocessableEntityException('Error renaming department in Frappe', error.response?.data || error.message);
74
+ }
75
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
76
+ }
77
+ }
78
+ };
79
+ exports.FrappeDepartmentService = FrappeDepartmentService;
80
+ exports.FrappeDepartmentService = FrappeDepartmentService = __decorate([
81
+ (0, common_1.Injectable)()
82
+ ], FrappeDepartmentService);
83
+ //# sourceMappingURL=department.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"department.service.js","sourceRoot":"","sources":["../../../src/frappe/services/department.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA0E;AAC1E,kDAAkD;AAG3C,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAC1B,cAAc,CAAC,KAAa,EAAE,MAAc;QAClD,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,KAAK,IAAI,MAAM,EAAE;gBACzC,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC;IACJ,CAAC;IAED,6BAA6B;IAC7B,KAAK,CAAC,cAAc,CAAC,KAAyD;QAC5E,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAEzC,MAAM,GAAG,GAAG,GAAG,OAAO,0BAA0B,CAAC;QACjD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAElD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC9C,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,MA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AAM,CAAC,CAAC;QAElD,MAAM,aAAa,GAAG;YACpB,OAAO,EAAE,YAAY;YACrB,GAAG,EAAE,iBAAiB;YACtB,GAAG,EAAE,iBAAiB;YACtB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,qCAAqC;SAC5D,CAAC;QAEF,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;YAC9D,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,qCAA4B,CACpC,qCAAqC,EACrC,KAAK,CAAC,QAAQ,EAAE,IAAI,IAAI,KAAK,CAAC,OAAO,CACtC,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,qCAA4B,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;CACF,CAAA;AA3FY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;GACA,uBAAuB,CA2FnC"}
@@ -0,0 +1,25 @@
1
+ export declare class FrappeDesignationService {
2
+ private getAxiosConfig;
3
+ getDesignations(props: {
4
+ baseUrl: string;
5
+ token: string;
6
+ secret: string;
7
+ }): Promise<any>;
8
+ createDesignation(props: {
9
+ baseUrl: string;
10
+ token: string;
11
+ secret: string;
12
+ designationData: {
13
+ designation_name: string;
14
+ };
15
+ }): Promise<any>;
16
+ reNameDesignation(props: {
17
+ baseUrl: string;
18
+ token: string;
19
+ secret: string;
20
+ oldDesignationName: string;
21
+ newDesignationName: string;
22
+ merge?: boolean;
23
+ }): Promise<any>;
24
+ }
25
+ //# sourceMappingURL=designation.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"designation.service.d.ts","sourceRoot":"","sources":["../../../src/frappe/services/designation.service.ts"],"names":[],"mappings":"AAGA,qBACa,wBAAwB;IACnC,OAAO,CAAC,cAAc;IAShB,eAAe,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAoBxF,iBAAiB,CAAC,KAAK,EAAE;QAC7B,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,eAAe,EAAE;YAAE,gBAAgB,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/C,GAAG,OAAO,CAAC,GAAG,CAAC;IAoBV,iBAAiB,CAAC,KAAK,EAAE;QAC7B,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,kBAAkB,EAAE,MAAM,CAAC;QAC3B,kBAAkB,EAAE,MAAM,CAAC;QAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GAAG,OAAO,CAAC,GAAG,CAAC;CA0BjB"}
@@ -0,0 +1,80 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FrappeDesignationService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const axios_1 = __importDefault(require("axios"));
15
+ let FrappeDesignationService = class FrappeDesignationService {
16
+ getAxiosConfig(token, secret) {
17
+ return {
18
+ headers: {
19
+ Authorization: `token ${token}:${secret}`,
20
+ 'Content-Type': 'application/json',
21
+ },
22
+ };
23
+ }
24
+ async getDesignations(props) {
25
+ const { baseUrl, token, secret } = props;
26
+ const url = `${baseUrl}/api/method/Designation`;
27
+ const config = this.getAxiosConfig(token, secret);
28
+ try {
29
+ const response = await axios_1.default.get(url, config);
30
+ return response.data;
31
+ }
32
+ catch (error) {
33
+ if (axios_1.default.isAxiosError(error)) {
34
+ throw new common_1.UnprocessableEntityException('Error fetching designations from Frappe', error.response?.data || error.message);
35
+ }
36
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
37
+ }
38
+ }
39
+ async createDesignation(props) {
40
+ const { baseUrl, token, secret, designationData } = props;
41
+ const url = `${baseUrl}/api/resource/Designation`;
42
+ const config = this.getAxiosConfig(token, secret);
43
+ try {
44
+ const response = await axios_1.default.post(url, designationData, config);
45
+ return response.data;
46
+ }
47
+ catch (error) {
48
+ if (axios_1.default.isAxiosError(error)) {
49
+ throw new common_1.UnprocessableEntityException('Error creating designation in Frappe', error.response?.data || error.message);
50
+ }
51
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
52
+ }
53
+ }
54
+ async reNameDesignation(props) {
55
+ const { baseUrl, token, secret, oldDesignationName, newDesignationName, merge = false } = props;
56
+ const url = `${baseUrl}/api/method/frappe.rename_doc`;
57
+ const config = this.getAxiosConfig(token, secret);
58
+ const renamePayload = {
59
+ doctype: 'Designation',
60
+ old: oldDesignationName,
61
+ new: newDesignationName,
62
+ merge: merge ? 1 : 0, // Set merge option (0 = No, 1 = Yes)
63
+ };
64
+ try {
65
+ const response = await axios_1.default.post(url, renamePayload, config);
66
+ return response.data;
67
+ }
68
+ catch (error) {
69
+ if (axios_1.default.isAxiosError(error)) {
70
+ throw new common_1.UnprocessableEntityException('Error renaming designation in Frappe', error.response?.data || error.message);
71
+ }
72
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
73
+ }
74
+ }
75
+ };
76
+ exports.FrappeDesignationService = FrappeDesignationService;
77
+ exports.FrappeDesignationService = FrappeDesignationService = __decorate([
78
+ (0, common_1.Injectable)()
79
+ ], FrappeDesignationService);
80
+ //# sourceMappingURL=designation.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"designation.service.js","sourceRoot":"","sources":["../../../src/frappe/services/designation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA0E;AAC1E,kDAAkD;AAG3C,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAC3B,cAAc,CAAC,KAAa,EAAE,MAAc;QAClD,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,KAAK,IAAI,MAAM,EAAE;gBACzC,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,KAAyD;QAC7E,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAEzC,MAAM,GAAG,GAAG,GAAG,OAAO,yBAAyB,CAAC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAElD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC9C,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,qCAA4B,CACpC,yCAAyC,EACzC,KAAK,CAAC,QAAQ,EAAE,IAAI,IAAI,KAAK,CAAC,OAAO,CACtC,CAAC;YACJ,CAAC;YACD,MAAM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CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,qCAAqC;SAC5D,CAAC;QAEF,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;YAC9D,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,qCAA4B,CACpC,sCAAsC,EACtC,KAAK,CAAC,QAAQ,EAAE,IAAI,IAAI,KAAK,CAAC,OAAO,CACtC,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,qCAA4B,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;CACF,CAAA;AAxFY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;GACA,wBAAwB,CAwFpC"}
@@ -0,0 +1,46 @@
1
+ export declare class FrappeUserService {
2
+ private getAxiosConfig;
3
+ getLoggedInUser(props: {
4
+ baseUrl: string;
5
+ token: string;
6
+ secret: string;
7
+ }): Promise<any>;
8
+ getUsers(props: {
9
+ baseUrl: string;
10
+ token: string;
11
+ secret: string;
12
+ }): Promise<any>;
13
+ createUser(props: {
14
+ baseUrl: string;
15
+ token: string;
16
+ secret: string;
17
+ userData: any;
18
+ }): Promise<any>;
19
+ updateUser(props: {
20
+ baseUrl: string;
21
+ token: string;
22
+ secret: string;
23
+ userId: string;
24
+ userData: any;
25
+ }): Promise<any>;
26
+ deleteUser(props: {
27
+ baseUrl: string;
28
+ token: string;
29
+ secret: string;
30
+ userId: string;
31
+ }): Promise<any>;
32
+ createUserAndEmployee(props: {
33
+ baseUrl: string;
34
+ token: string;
35
+ secret: string;
36
+ userData: any;
37
+ }): Promise<any>;
38
+ createEmployee(props: {
39
+ baseUrl: string;
40
+ token: string;
41
+ secret: string;
42
+ employeeData: any;
43
+ userId: string;
44
+ }): Promise<any>;
45
+ }
46
+ //# sourceMappingURL=user.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../../src/frappe/services/user.service.ts"],"names":[],"mappings":"AAGA,qBACa,iBAAiB;IAC5B,OAAO,CAAC,cAAc;IAShB,eAAe,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAoBxF,QAAQ,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAuBjF,UAAU,CAAC,KAAK,EAAE;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,GAAG,CAAC;KACf,GAAG,OAAO,CAAC,GAAG,CAAC;IAqBV,UAAU,CAAC,KAAK,EAAE;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,GAAG,CAAC;KACf,GAAG,OAAO,CAAC,GAAG,CAAC;IAqBV,UAAU,CAAC,KAAK,EAAE;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,GAAG,CAAC;IAqBV,qBAAqB,CAAC,KAAK,EAAE;QACjC,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,GAAG,CAAC;KACf,GAAG,OAAO,CAAC,GAAG,CAAC;IA8CV,cAAc,CAAC,KAAK,EAAE;QAC1B,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE,GAAG,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,GAAG,CAAC;CA2BjB"}
@@ -0,0 +1,172 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FrappeUserService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const axios_1 = __importDefault(require("axios"));
15
+ let FrappeUserService = class FrappeUserService {
16
+ getAxiosConfig(token, secret) {
17
+ return {
18
+ headers: {
19
+ Authorization: `token ${token}:${secret}`,
20
+ 'Content-Type': 'application/json',
21
+ },
22
+ };
23
+ }
24
+ async getLoggedInUser(props) {
25
+ const { baseUrl, token, secret } = props;
26
+ const url = `${baseUrl}/api/method/frappe.auth.get_logged_user`;
27
+ const config = this.getAxiosConfig(token, secret);
28
+ try {
29
+ const response = await axios_1.default.get(url, config);
30
+ return response.data;
31
+ }
32
+ catch (error) {
33
+ if (axios_1.default.isAxiosError(error)) {
34
+ throw new common_1.UnprocessableEntityException('Error fetching logged-in user from Frappe', error.response?.data || error.message);
35
+ }
36
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
37
+ }
38
+ }
39
+ async getUsers(props) {
40
+ const { baseUrl, token, secret } = props;
41
+ // Specify the fields you want to retrieve
42
+ const fields = ['email', 'first_name', 'last_name', 'gender'];
43
+ const url = `${baseUrl}/api/resource/User?fields=${JSON.stringify(fields)}`;
44
+ const config = this.getAxiosConfig(token, secret);
45
+ try {
46
+ const response = await axios_1.default.get(url, config);
47
+ return response.data;
48
+ }
49
+ catch (error) {
50
+ if (axios_1.default.isAxiosError(error)) {
51
+ console.log('Error fetching users from Frappe', error.response?.data || error.message);
52
+ throw new common_1.UnprocessableEntityException('Error fetching users from Frappe', error.response?.data || error.message);
53
+ }
54
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
55
+ }
56
+ }
57
+ // Create User in ERPNext
58
+ async createUser(props) {
59
+ const { baseUrl, token, secret, userData } = props;
60
+ const url = `${baseUrl}/api/resource/User`;
61
+ const config = this.getAxiosConfig(token, secret);
62
+ try {
63
+ const response = await axios_1.default.post(url, userData, config);
64
+ return response.data;
65
+ }
66
+ catch (error) {
67
+ if (axios_1.default.isAxiosError(error)) {
68
+ throw new common_1.UnprocessableEntityException('Error creating user in Frappe', error.response?.data || error.message);
69
+ }
70
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
71
+ }
72
+ }
73
+ // Update User in ERPNext
74
+ async updateUser(props) {
75
+ const { baseUrl, token, secret, userId, userData } = props;
76
+ const url = `${baseUrl}/api/resource/User/${userId}`;
77
+ const config = this.getAxiosConfig(token, secret);
78
+ try {
79
+ const response = await axios_1.default.put(url, userData, config);
80
+ return response.data;
81
+ }
82
+ catch (error) {
83
+ if (axios_1.default.isAxiosError(error)) {
84
+ throw new common_1.UnprocessableEntityException('Error updating user in Frappe', error.response?.data || error.message);
85
+ }
86
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
87
+ }
88
+ }
89
+ // Delete User in ERPNext
90
+ async deleteUser(props) {
91
+ const { baseUrl, token, secret, userId } = props;
92
+ const url = `${baseUrl}/api/resource/User/${userId}`;
93
+ const config = this.getAxiosConfig(token, secret);
94
+ try {
95
+ const response = await axios_1.default.delete(url, config);
96
+ return response.data;
97
+ }
98
+ catch (error) {
99
+ if (axios_1.default.isAxiosError(error)) {
100
+ throw new common_1.UnprocessableEntityException('Error deleting user in Frappe', error.response?.data || error.message);
101
+ }
102
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
103
+ }
104
+ }
105
+ // Create User and Employee in Frappe
106
+ async createUserAndEmployee(props) {
107
+ const { baseUrl, token, secret, userData } = props;
108
+ const createUserPayload = {
109
+ email: userData.email,
110
+ first_name: userData.first_name,
111
+ send_welcome_email: 0,
112
+ roles: [{ role: 'Employee' }], // Assign Employee role
113
+ };
114
+ try {
115
+ // Step 1: Create the user first
116
+ const createdUser = await this.createUser({
117
+ baseUrl,
118
+ token,
119
+ secret,
120
+ userData: createUserPayload,
121
+ });
122
+ // Step 2: Create the employee using the new function
123
+ const createdEmployee = await this.createEmployee({
124
+ baseUrl,
125
+ token,
126
+ secret,
127
+ employeeData: userData,
128
+ userId: createdUser.data.email,
129
+ });
130
+ // Return both user and employee details
131
+ return {
132
+ message: 'User and Employee created and linked successfully',
133
+ user: createdUser,
134
+ employee: createdEmployee,
135
+ };
136
+ }
137
+ catch (error) {
138
+ if (axios_1.default.isAxiosError(error)) {
139
+ throw new common_1.UnprocessableEntityException('Error creating user and employee in Frappe', error.response?.data || error.message);
140
+ }
141
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
142
+ }
143
+ }
144
+ // Separate function for creating Employee
145
+ async createEmployee(props) {
146
+ const { baseUrl, token, secret, employeeData, userId } = props;
147
+ const createEmployeePayload = {
148
+ first_name: employeeData.first_name,
149
+ gender: employeeData.gender,
150
+ date_of_birth: employeeData.date_of_birth,
151
+ date_of_joining: employeeData.date_of_joining,
152
+ user_id: userId, // Link the employee with the created user
153
+ };
154
+ const employeeUrl = `${baseUrl}/api/resource/Employee`;
155
+ const config = this.getAxiosConfig(token, secret);
156
+ try {
157
+ const employeeResponse = await axios_1.default.post(employeeUrl, createEmployeePayload, config);
158
+ return employeeResponse.data.data;
159
+ }
160
+ catch (error) {
161
+ if (axios_1.default.isAxiosError(error)) {
162
+ throw new common_1.UnprocessableEntityException('Error creating employee in Frappe', error.response?.data || error.message);
163
+ }
164
+ throw new common_1.UnprocessableEntityException('Unexpected error', error);
165
+ }
166
+ }
167
+ };
168
+ exports.FrappeUserService = FrappeUserService;
169
+ exports.FrappeUserService = FrappeUserService = __decorate([
170
+ (0, common_1.Injectable)()
171
+ ], FrappeUserService);
172
+ //# sourceMappingURL=user.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../../src/frappe/services/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA0E;AAC1E,kDAAkD;AAG3C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IACpB,cAAc,CAAC,KAAa,EAAE,MAAc;QAClD,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,KAAK,IAAI,MAAM,EAAE;gBACzC,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,KAAyD;QAC7E,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAEzC,MAAM,GAAG,GAAG,GAAG,OAAO,yCAAyC,CAAC;QAChE,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAElD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC9C,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAA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e;YAC7C,OAAO,EAAE,MAAM,EAAE,0CAA0C;SAC5D,CAAC;QAEF,MAAM,WAAW,GAAG,GAAG,OAAO,wBAAwB,CAAC;QACvD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAElD,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,WAAW,EAAE,qBAAqB,EAAE,MAAM,CAAC,CAAC;YACtF,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,qCAA4B,CACpC,mCAAmC,EACnC,KAAK,CAAC,QAAQ,EAAE,IAAI,IAAI,KAAK,CAAC,OAAO,CACtC,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,qCAA4B,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;CACF,CAAA;AAxNY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAwN7B"}
package/dist/index.d.ts CHANGED
@@ -11,4 +11,5 @@ export * from './request-store';
11
11
  export * from './shared-module';
12
12
  export * from './task-queue';
13
13
  export * from './utils';
14
+ export * from './frappe';
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -27,4 +27,5 @@ __exportStar(require("./request-store"), exports);
27
27
  __exportStar(require("./shared-module"), exports);
28
28
  __exportStar(require("./task-queue"), exports);
29
29
  __exportStar(require("./utils"), exports);
30
+ __exportStar(require("./frappe"), exports);
30
31
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,2CAAyB;AACzB,+DAA6C;AAC7C,yDAAuC;AACvC,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,oDAAkC;AAClC,gDAA8B;AAC9B,kDAAgC;AAChC,kDAAgC;AAChC,+CAA6B;AAC7B,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,2CAAyB;AACzB,+DAA6C;AAC7C,yDAAuC;AACvC,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,oDAAkC;AAClC,gDAA8B;AAC9B,kDAAgC;AAChC,kDAAgC;AAChC,+CAA6B;AAC7B,0CAAwB;AACxB,2CAAyB"}
@@ -1,4 +1,29 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
1
25
  import { NextFunction, Request, Response } from 'express';
26
+ import { ClientSession } from 'mongoose';
2
27
  import { DataSource, EntityManager } from 'typeorm';
3
28
  import { IRequest, UserData } from '../common/interfaces/context.interface';
4
29
  import { Tenant } from '../domain';
@@ -6,9 +31,12 @@ import { EvaluatorType, InstitutionType } from '../modules-handler';
6
31
  type IStoreSession<T> = {
7
32
  setParams?: () => void;
8
33
  session: () => T | Promise<T>;
34
+ inheritParent?: boolean;
9
35
  };
10
36
  export declare const storeMiddleWare: (req: Request, _res: Response, next: NextFunction) => void;
11
- export declare const storeSession: <T>({ session, setParams }: IStoreSession<T>) => Promise<T>;
37
+ export declare const storeSession: <T>({ session, setParams, inheritParent }: IStoreSession<T>) => Promise<T>;
38
+ export declare function setMongoSession(session: ClientSession): void;
39
+ export declare function getMongoSession(strict?: boolean): ClientSession;
12
40
  export declare function setExpressRequest(req: Request): void;
13
41
  export declare function getExpressRequest(): Request;
14
42
  export declare function setRequest(req: IRequest): void;
@@ -1 +1 @@
1
- {"version":3,"file":"request-store.d.ts","sourceRoot":"","sources":["../../src/request-store/request-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAcpE,KAAK,aAAa,CAAC,CAAC,IAAI;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,eAAe,QAAS,OAAO,QAAQ,QAAQ,QAAQ,YAAY,SAK/E,CAAC;AAEF,eAAO,MAAM,YAAY,8BAAqC,cAAc,CAAC,CAAC,eAY7E,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAEpD;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAE9C;AAED,wBAAgB,UAAU,IAAI,QAAQ,CAErC;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAErD;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAEjD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC;AAED,wBAAgB,mBAAmB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AAE,GAAG,GAAG,IAAI,CAE3C;AAED,wBAAgB,WAAW,IAAI,GAAG,CAEjC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAOlC;AAED,wBAAgB,qBAAqB,IAAI,UAAU,CAMlD;AAED,wBAAgB,kBAAkB,IAAI,aAAa,CAGlD;AAGD,wBAAgB,UAAU;;;;;;;;EAUzB;AAED,wBAAgB,eAAe,WAE9B;AAED,wBAAgB,YAAY,WAE3B;AAGD,wBAAgB,mBAAmB;;;;;EAOlC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMySQLCredentials = exports.getS3BaseUrl = exports.getS3BucketName = exports.getAWSKeys = exports.getEasyWDMSManager = exports.getEasyWDMSDataSource = exports.getLeadId = exports.getLeadData = exports.setLeadData = exports.getEvaluatorId = exports.getEvaluatorData = exports.setEvaluatorData = exports.getUserData = exports.setUserData = exports.getInstitutionUniqueIdForFilter = exports.getInstitutionIdForFilter = exports.hasAllInstitutionsAccess = exports.isMasterGlobalInstitution = exports.isMasterInstitution = exports.getInstitutionLegacy = exports.getUserInstitutions = exports.setUserInstitutions = exports.getInstitution = exports.getInstitutionOrFail = exports.setInstitution = exports.getManager = exports.getDataSource = exports.setTenantDataSource = exports.getTenantDetails = exports.getTenantDetailsIfExists = exports.setTenantDetails = exports.getRequest = exports.setRequest = exports.getExpressRequest = exports.setExpressRequest = exports.storeSession = exports.storeMiddleWare = void 0;
3
+ exports.getMySQLCredentials = exports.getS3BaseUrl = exports.getS3BucketName = exports.getAWSKeys = exports.getEasyWDMSManager = exports.getEasyWDMSDataSource = exports.getLeadId = exports.getLeadData = exports.setLeadData = exports.getEvaluatorId = exports.getEvaluatorData = exports.setEvaluatorData = exports.getUserData = exports.setUserData = exports.getInstitutionUniqueIdForFilter = exports.getInstitutionIdForFilter = exports.hasAllInstitutionsAccess = exports.isMasterGlobalInstitution = exports.isMasterInstitution = exports.getInstitutionLegacy = exports.getUserInstitutions = exports.setUserInstitutions = exports.getInstitution = exports.getInstitutionOrFail = exports.setInstitution = exports.getManager = exports.getDataSource = exports.setTenantDataSource = exports.getTenantDetails = exports.getTenantDetailsIfExists = exports.setTenantDetails = exports.getRequest = exports.setRequest = exports.getExpressRequest = exports.setExpressRequest = exports.getMongoSession = exports.setMongoSession = exports.storeSession = exports.storeMiddleWare = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const utils_1 = require("../utils");
6
6
  const store_config_1 = require("./store-config");
@@ -20,9 +20,15 @@ const storeMiddleWare = (req, _res, next) => {
20
20
  });
21
21
  };
22
22
  exports.storeMiddleWare = storeMiddleWare;
23
- const storeSession = async ({ session, setParams }) => {
23
+ const storeSession = async ({ session, setParams, inheritParent }) => {
24
24
  return new Promise((resolve, reject) => {
25
+ const previousStore = store_config_1.store.getStore();
25
26
  store_config_1.store.run(new Map(), async () => {
27
+ if (inheritParent && previousStore) {
28
+ for (const [key, value] of previousStore.entries()) {
29
+ (0, store_config_1.set)(key, value);
30
+ }
31
+ }
26
32
  try {
27
33
  if (setParams)
28
34
  setParams();
@@ -36,6 +42,18 @@ const storeSession = async ({ session, setParams }) => {
36
42
  });
37
43
  };
38
44
  exports.storeSession = storeSession;
45
+ function setMongoSession(session) {
46
+ (0, store_config_1.set)('MONGO_SESSION', session);
47
+ }
48
+ exports.setMongoSession = setMongoSession;
49
+ function getMongoSession(strict) {
50
+ const session = (0, store_config_1.get)('MONGO_SESSION');
51
+ if (!session && strict) {
52
+ throw new common_1.UnprocessableEntityException('Unable to get database session');
53
+ }
54
+ return session;
55
+ }
56
+ exports.getMongoSession = getMongoSession;
39
57
  function setExpressRequest(req) {
40
58
  (0, store_config_1.set)(EXPRESS_REQUEST, req);
41
59
  }