aws-service-stack 0.17.261 → 0.17.267
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/_examples/controller/profile/profile.controller.d.ts +1 -1
- package/dist/_examples/controller/profile/profile.controller.js +1 -1
- package/dist/_examples/controller/profile/profile.controller.js.map +1 -1
- package/dist/_examples/controller/rorder/order-config.d.ts +6 -0
- package/dist/_examples/controller/rorder/order-config.js +50 -0
- package/dist/_examples/controller/rorder/order-config.js.map +1 -0
- package/dist/_examples/controller/rorder/order-controller.d.ts +9 -0
- package/dist/_examples/controller/rorder/order-controller.js +66 -0
- package/dist/_examples/controller/rorder/order-controller.js.map +1 -0
- package/dist/_examples/controller/rorder/order-crud.d.ts +4 -0
- package/dist/_examples/controller/rorder/order-crud.js +57 -0
- package/dist/_examples/controller/rorder/order-crud.js.map +1 -0
- package/dist/_examples/repositories/rorder/rorder-db.repo.d.ts +5 -0
- package/dist/_examples/repositories/rorder/rorder-db.repo.interface.d.ts +4 -0
- package/dist/_examples/repositories/rorder/rorder-db.repo.interface.js +3 -0
- package/dist/_examples/repositories/rorder/rorder-db.repo.interface.js.map +1 -0
- package/dist/_examples/repositories/rorder/rorder-db.repo.js +18 -0
- package/dist/_examples/repositories/rorder/rorder-db.repo.js.map +1 -0
- package/dist/_examples/repositories/rorder/rorder-es.repo.d.ts +7 -0
- package/dist/_examples/repositories/rorder/rorder-es.repo.interface.d.ts +5 -0
- package/dist/_examples/repositories/rorder/rorder-es.repo.interface.js +3 -0
- package/dist/_examples/repositories/rorder/rorder-es.repo.interface.js.map +1 -0
- package/dist/_examples/repositories/rorder/rorder-es.repo.js +22 -0
- package/dist/_examples/repositories/rorder/rorder-es.repo.js.map +1 -0
- package/dist/_examples/service/profile-service.d.ts +2 -4
- package/dist/_examples/service/profile-service.interface.d.ts +2 -2
- package/dist/_examples/service/profile-service.interface.js.map +1 -1
- package/dist/_examples/service/profile-service.js +2 -5
- package/dist/_examples/service/profile-service.js.map +1 -1
- package/dist/_examples/service/rorder/rorder-service.d.ts +11 -0
- package/dist/_examples/service/rorder/rorder-service.interface.d.ts +9 -0
- package/dist/_examples/service/rorder/rorder-service.interface.js +3 -0
- package/dist/_examples/service/rorder/rorder-service.interface.js.map +1 -0
- package/dist/_examples/service/rorder/rorder-service.js +65 -0
- package/dist/_examples/service/rorder/rorder-service.js.map +1 -0
- package/dist/controller/controller-api.js +2 -2
- package/dist/controller/controller-api.js.map +1 -1
- package/dist/model/base.config.d.ts +3 -2
- package/dist/model/base.config.js +5 -3
- package/dist/model/base.config.js.map +1 -1
- package/dist/model/base.model.d.ts +1 -1
- package/dist/model/base.model.js.map +1 -1
- package/dist/model/dynamodb.model.d.ts +2 -0
- package/dist/model/dynamodb.model.js +2 -0
- package/dist/model/dynamodb.model.js.map +1 -1
- package/dist/service/crud.service.d.ts +3 -1
- package/dist/service/crud.service.interface.d.ts +4 -1
- package/dist/service/crud.service.interface.js.map +1 -1
- package/dist/service/crud.service.js +31 -7
- package/dist/service/crud.service.js.map +1 -1
- package/dist/utils/http/http.util.js +6 -2
- package/dist/utils/http/http.util.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,5 +9,5 @@ import { Profile } from "src/_examples/model-shared/example.model";
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class ProfileController extends ControllerApi<Profile, ProfileService> {
|
|
11
11
|
constructor();
|
|
12
|
-
protected processCrudRequest(
|
|
12
|
+
protected processCrudRequest(req: HttpRequest): Promise<any>;
|
|
13
13
|
}
|
|
@@ -56,7 +56,7 @@ let ProfileController = class ProfileController extends controller_api_1.Control
|
|
|
56
56
|
const service = typedi_1.default.get("ProfileService");
|
|
57
57
|
super(service, profile_config_1.CONFIG_PROFILE.toObject());
|
|
58
58
|
}
|
|
59
|
-
async processCrudRequest(
|
|
59
|
+
async processCrudRequest(req) {
|
|
60
60
|
return undefined;
|
|
61
61
|
}
|
|
62
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.controller.js","sourceRoot":"","sources":["../../../../src/_examples/controller/profile/profile.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,yCAAuC;AACvC,qDAAkD;AAClD,uEAAmE;AAInE;;;GAGG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,8BAAsC;IAC3E;QACE,MAAM,OAAO,GAAmB,gBAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAChE,KAAK,CAAC,OAAO,EAAE,+BAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5C,CAAC;IAES,KAAK,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"profile.controller.js","sourceRoot":"","sources":["../../../../src/_examples/controller/profile/profile.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,yCAAuC;AACvC,qDAAkD;AAClD,uEAAmE;AAInE;;;GAGG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,8BAAsC;IAC3E;QACE,MAAM,OAAO,GAAmB,gBAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAChE,KAAK,CAAC,OAAO,EAAE,+BAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5C,CAAC;IAES,KAAK,CAAC,kBAAkB,CAAC,GAAgB;QACjD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAA;AATY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,gBAAO,EAAC,mBAAmB,CAAC;;GAChB,iBAAiB,CAS7B","sourcesContent":["import Container, { Service } from \"typedi\";\nimport { ProfileService } from \"../../service/profile-service.interface\";\nimport \"../../service/profile-service\";\nimport { CONFIG_PROFILE } from \"./profile.config\";\nimport { ControllerApi } from \"../../../controller/controller-api\";\nimport { HttpRequest } from \"@chinggis/core\";\nimport { Profile } from \"src/_examples/model-shared/example.model\";\n\n/**\n * Example Controller for Profile: Validator (Zod) is set centrally.\n * This automatically validates POST/PUT/PATCH requests.\n */\n@Service(\"ProfileController\")\nexport class ProfileController extends ControllerApi<Profile, ProfileService> {\n constructor() {\n const service: ProfileService = Container.get(\"ProfileService\");\n super(service, CONFIG_PROFILE.toObject());\n }\n\n protected async processCrudRequest(req: HttpRequest): Promise<any> {\n return undefined;\n }\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONFIG_ORDER = exports.OrderConfig = exports.path = void 0;
|
|
4
|
+
const core_1 = require("../../../index.js");
|
|
5
|
+
exports.path = "/retailer/orders"; // url path base
|
|
6
|
+
// Retailer Order configuration
|
|
7
|
+
class OrderConfig extends core_1.EntityConfigImpl {
|
|
8
|
+
constructor() {
|
|
9
|
+
// DYNAMODB
|
|
10
|
+
const tableName = "ROrder-4xixumh73vbs7azfxjds2l3ijq-staging";
|
|
11
|
+
const indexMap = new core_1.DynamoIndexMap()
|
|
12
|
+
.set("byAccount", { field: "accountId", rFields: ["accountId"] })
|
|
13
|
+
.set("byBranch", { field: "branchId", rFields: ["branchId"] })
|
|
14
|
+
.set("byStatus", { field: "status", rFields: ["status"] })
|
|
15
|
+
.set("byCompletedDate", { field: "completedDate", rFields: ["completedDate"] })
|
|
16
|
+
.set("byCompletedYearMonth", {
|
|
17
|
+
field: "completedYearMonth",
|
|
18
|
+
rFields: ["completedYearMonth"],
|
|
19
|
+
});
|
|
20
|
+
// OPENSEARCH
|
|
21
|
+
const openSearch = {
|
|
22
|
+
domain: "https://search-amplify-opense-u395qzlqz9h6-i4pks35uvl6djkxq5ikogrmh2i.ap-southeast-1.es.amazonaws.com",
|
|
23
|
+
index: "rorder",
|
|
24
|
+
};
|
|
25
|
+
// PERMISSIONS
|
|
26
|
+
const parentFieldName = "accountId";
|
|
27
|
+
const ownerFieldName = "branchId";
|
|
28
|
+
const adminGroupName = ["adminUsers"];
|
|
29
|
+
const policies = [
|
|
30
|
+
{ method: core_1.HttpMethod.GET, path: `${exports.path}`, access: [core_1.Access.OWNER, core_1.Access.ADMIN] },
|
|
31
|
+
{ method: core_1.HttpMethod.GET, path: `${exports.path}/search`, access: [core_1.Access.OWNER, core_1.Access.ADMIN] },
|
|
32
|
+
{ method: core_1.HttpMethod.GET, path: `${exports.path}/{id}`, access: [core_1.Access.OWNER, core_1.Access.ADMIN] },
|
|
33
|
+
{ method: core_1.HttpMethod.POST, path: `${exports.path}`, access: [core_1.Access.USER, core_1.Access.ADMIN] },
|
|
34
|
+
{ method: core_1.HttpMethod.PUT, path: `${exports.path}/{id}`, access: [core_1.Access.ADMIN] },
|
|
35
|
+
{ method: core_1.HttpMethod.PATCH, path: `${exports.path}/{id}`, access: [core_1.Access.ADMIN] },
|
|
36
|
+
{ method: core_1.HttpMethod.DELETE, path: `${exports.path}/{id}`, access: [core_1.Access.ADMIN] },
|
|
37
|
+
];
|
|
38
|
+
// INIT
|
|
39
|
+
super(exports.path, adminGroupName);
|
|
40
|
+
this.setDynamoDB(tableName, ownerFieldName, indexMap, parentFieldName)
|
|
41
|
+
.setOpenSearch(openSearch.domain, openSearch.index)
|
|
42
|
+
.setPolicies(policies);
|
|
43
|
+
this.PARENT_ID_FIELD_NAME = parentFieldName;
|
|
44
|
+
this.OWNER_ID_FIELD_NAME = ownerFieldName;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.OrderConfig = OrderConfig;
|
|
48
|
+
// Export default Retailer Order configuration
|
|
49
|
+
exports.CONFIG_ORDER = new OrderConfig();
|
|
50
|
+
//# sourceMappingURL=order-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-config.js","sourceRoot":"","sources":["../../../../src/_examples/controller/rorder/order-config.ts"],"names":[],"mappings":";;;AAAA,yCAAgH;AAEnG,QAA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sourcesContent":["import { Access as a, DynamoIndexMap, EndpointPolicy, EntityConfigImpl, HttpMethod as m } from \"@chinggis/core\";\n\nexport const path = \"/retailer/orders\"; // url path base\n\n// Retailer Order configuration\nexport class OrderConfig extends EntityConfigImpl {\n constructor() {\n // DYNAMODB\n const tableName = \"ROrder-4xixumh73vbs7azfxjds2l3ijq-staging\";\n const indexMap = new DynamoIndexMap()\n .set(\"byAccount\", { field: \"accountId\", rFields: [\"accountId\"] })\n .set(\"byBranch\", { field: \"branchId\", rFields: [\"branchId\"] })\n .set(\"byStatus\", { field: \"status\", rFields: [\"status\"] })\n .set(\"byCompletedDate\", { field: \"completedDate\", rFields: [\"completedDate\"] })\n .set(\"byCompletedYearMonth\", {\n field: \"completedYearMonth\",\n rFields: [\"completedYearMonth\"],\n });\n\n // OPENSEARCH\n const openSearch = {\n domain: \"https://search-amplify-opense-u395qzlqz9h6-i4pks35uvl6djkxq5ikogrmh2i.ap-southeast-1.es.amazonaws.com\",\n index: \"rorder\",\n };\n\n // PERMISSIONS\n const parentFieldName = \"accountId\";\n const ownerFieldName = \"branchId\";\n const adminGroupName = [\"adminUsers\"];\n const policies: EndpointPolicy[] = [\n { method: m.GET, path: `${path}`, access: [a.OWNER, a.ADMIN] },\n { method: m.GET, path: `${path}/search`, access: [a.OWNER, a.ADMIN] },\n { method: m.GET, path: `${path}/{id}`, access: [a.OWNER, a.ADMIN] },\n { method: m.POST, path: `${path}`, access: [a.USER, a.ADMIN] },\n { method: m.PUT, path: `${path}/{id}`, access: [a.ADMIN] },\n { method: m.PATCH, path: `${path}/{id}`, access: [a.ADMIN] },\n { method: m.DELETE, path: `${path}/{id}`, access: [a.ADMIN] },\n ];\n\n // INIT\n super(path, adminGroupName);\n this.setDynamoDB(tableName, ownerFieldName, indexMap, parentFieldName)\n .setOpenSearch(openSearch.domain, openSearch.index)\n .setPolicies(policies);\n\n this.PARENT_ID_FIELD_NAME = parentFieldName;\n this.OWNER_ID_FIELD_NAME = ownerFieldName;\n }\n}\n\n// Export default Retailer Order configuration\nexport const CONFIG_ORDER = new OrderConfig();\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ControllerApi } from "src/controller";
|
|
2
|
+
import { HttpRequest } from "src/utils";
|
|
3
|
+
import { ROrder } from "src/_examples/model-shared/supplier-portal.model";
|
|
4
|
+
import { ROrderService } from "src/_examples/service/rorder/rorder-service.interface";
|
|
5
|
+
import "src/_examples/service/rorder/rorder-service";
|
|
6
|
+
export declare class ROrderController extends ControllerApi<ROrder, ROrderService> {
|
|
7
|
+
constructor();
|
|
8
|
+
protected processCrudRequest(req: HttpRequest): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.ROrderController = void 0;
|
|
46
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
47
|
+
const controller_1 = require("src/controller");
|
|
48
|
+
const order_config_1 = require("./order-config");
|
|
49
|
+
require("src/_examples/service/rorder/rorder-service");
|
|
50
|
+
let ROrderController = class ROrderController extends controller_1.ControllerApi {
|
|
51
|
+
constructor() {
|
|
52
|
+
super(typedi_1.default.get("ROrderService"), order_config_1.CONFIG_ORDER.toObject());
|
|
53
|
+
}
|
|
54
|
+
async processCrudRequest(req) {
|
|
55
|
+
if (req.resourcePath === `PUT ${order_config_1.path}/cancel/{id}`) {
|
|
56
|
+
const { id } = req.pathParameters;
|
|
57
|
+
return "cancelled";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.ROrderController = ROrderController;
|
|
62
|
+
exports.ROrderController = ROrderController = __decorate([
|
|
63
|
+
(0, typedi_1.Service)("ROrderController"),
|
|
64
|
+
__metadata("design:paramtypes", [])
|
|
65
|
+
], ROrderController);
|
|
66
|
+
//# sourceMappingURL=order-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-controller.js","sourceRoot":"","sources":["../../../../src/_examples/controller/rorder/order-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,+CAA+C;AAE/C,iDAAoD;AAMpD,uDAAqD;AAG9C,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,0BAAoC;IACxE;QACE,KAAK,CAAC,gBAAS,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,2BAAY,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjE,CAAC;IAES,KAAK,CAAC,kBAAkB,CAAC,GAAgB;QACjD,IAAI,GAAG,CAAC,YAAY,KAAK,OAAO,mBAAI,cAAc,EAAE,CAAC;YACnD,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,CAAC,cAAc,CAAC;YAClC,OAAO,WAAW,CAAC;QACrB,CAAC;IACH,CAAC;CACF,CAAA;AAXY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,gBAAO,EAAC,kBAAkB,CAAC;;GACf,gBAAgB,CAW5B","sourcesContent":["import Container, { Service } from \"typedi\";\nimport { ControllerApi } from \"src/controller\";\nimport { HttpRequest } from \"src/utils\";\nimport { CONFIG_ORDER, path } from \"./order-config\";\n\nimport { ROrder } from \"src/_examples/model-shared/supplier-portal.model\";\n\n// import { ROrderService } from \"@retailer/services/order/rorder-service.interface\";\nimport { ROrderService } from \"src/_examples/service/rorder/rorder-service.interface\";\nimport \"src/_examples/service/rorder/rorder-service\";\n\n@Service(\"ROrderController\")\nexport class ROrderController extends ControllerApi<ROrder, ROrderService> {\n constructor() {\n super(Container.get(\"ROrderService\"), CONFIG_ORDER.toObject());\n }\n\n protected async processCrudRequest(req: HttpRequest): Promise<any> {\n if (req.resourcePath === `PUT ${path}/cancel/{id}`) {\n const { id } = req.pathParameters;\n return \"cancelled\";\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.handler = void 0;
|
|
43
|
+
require("reflect-metadata");
|
|
44
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
45
|
+
require("./order-controller");
|
|
46
|
+
const handler = (event) => typedi_1.default.get(HelperCDI).process(event);
|
|
47
|
+
exports.handler = handler;
|
|
48
|
+
let HelperCDI = class HelperCDI {
|
|
49
|
+
controller = typedi_1.default.get("ROrderController");
|
|
50
|
+
async process(event) {
|
|
51
|
+
return this.controller.resolveCrudRequest(event);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
HelperCDI = __decorate([
|
|
55
|
+
(0, typedi_1.Service)()
|
|
56
|
+
], HelperCDI);
|
|
57
|
+
//# sourceMappingURL=order-crud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-crud.js","sourceRoot":"","sources":["../../../../src/_examples/controller/rorder/order-crud.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,iDAA4C;AAK5C,8BAA4B;AAErB,MAAM,OAAO,GAAG,CAAC,KAA2B,EAAE,EAAE,CAAC,gBAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAAnF,QAAA,OAAO,WAA4E;AAGhG,IAAM,SAAS,GAAf,MAAM,SAAS;IACI,UAAU,GAAqB,gBAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAElF,KAAK,CAAC,OAAO,CAAC,KAA2B;QACvC,OAAO,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AANK,SAAS;IADd,IAAA,gBAAO,GAAE;GACJ,SAAS,CAMd","sourcesContent":["import \"reflect-metadata\";\nimport Container, { Service } from \"typedi\";\nimport { APIGatewayProxyEvent } from \"aws-lambda\";\n\n// Controller\nimport { ROrderController } from \"./order-controller\";\nimport \"./order-controller\";\n\nexport const handler = (event: APIGatewayProxyEvent) => Container.get(HelperCDI).process(event);\n\n@Service()\nclass HelperCDI {\n private readonly controller: ROrderController = Container.get(\"ROrderController\");\n\n async process(event: APIGatewayProxyEvent) {\n return this.controller.resolveCrudRequest(event);\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ROrderRepoDB } from "./rorder-db.repo.interface";
|
|
2
|
+
import { ROrder } from "src/_examples/model-shared/supplier-portal.model";
|
|
3
|
+
import { BaseRepoDBImpl } from "src/repositories";
|
|
4
|
+
export declare class ROrderRepoDBImpl extends BaseRepoDBImpl<ROrder> implements ROrderRepoDB {
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rorder-db.repo.interface.js","sourceRoot":"","sources":["../../../../src/_examples/repositories/rorder/rorder-db.repo.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { ROrder } from \"src/_examples/model-shared/supplier-portal.model\";\nimport { BaseRepoDB } from \"src/repositories\";\n\nexport interface ROrderRepoDB extends BaseRepoDB<ROrder> {}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
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.ROrderRepoDBImpl = void 0;
|
|
10
|
+
const typedi_1 = require("typedi");
|
|
11
|
+
const repositories_1 = require("src/repositories");
|
|
12
|
+
let ROrderRepoDBImpl = class ROrderRepoDBImpl extends repositories_1.BaseRepoDBImpl {
|
|
13
|
+
};
|
|
14
|
+
exports.ROrderRepoDBImpl = ROrderRepoDBImpl;
|
|
15
|
+
exports.ROrderRepoDBImpl = ROrderRepoDBImpl = __decorate([
|
|
16
|
+
(0, typedi_1.Service)("ROrderRepoDB")
|
|
17
|
+
], ROrderRepoDBImpl);
|
|
18
|
+
//# sourceMappingURL=rorder-db.repo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rorder-db.repo.js","sourceRoot":"","sources":["../../../../src/_examples/repositories/rorder/rorder-db.repo.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mCAAiC;AAGjC,mDAAkD;AAG3C,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,6BAAsB;CAA2B,CAAA;AAA1E,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,gBAAO,EAAC,cAAc,CAAC;GACX,gBAAgB,CAA0D","sourcesContent":["import { Service } from \"typedi\";\nimport { ROrderRepoDB } from \"./rorder-db.repo.interface\";\nimport { ROrder } from \"src/_examples/model-shared/supplier-portal.model\";\nimport { BaseRepoDBImpl } from \"src/repositories\";\n\n@Service(\"ROrderRepoDB\")\nexport class ROrderRepoDBImpl extends BaseRepoDBImpl<ROrder> implements ROrderRepoDB {}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseRepoESImpl } from "src/repositories";
|
|
2
|
+
import { ROrder } from "src/_examples/model-shared/supplier-portal.model";
|
|
3
|
+
import { ROrderRepoES } from "./rorder-es.repo.interface";
|
|
4
|
+
import "./rorder-es.repo";
|
|
5
|
+
export declare class ROrderRepoESImpl extends BaseRepoESImpl<ROrder> implements ROrderRepoES {
|
|
6
|
+
demoSearch(): Promise<ROrder[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rorder-es.repo.interface.js","sourceRoot":"","sources":["../../../../src/_examples/repositories/rorder/rorder-es.repo.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { ROrder } from \"src/_examples/model-shared/supplier-portal.model\";\nimport { BaseRepoES } from \"src/repositories\";\n\nexport interface ROrderRepoES extends BaseRepoES<ROrder> {\n demoSearch(): Promise<ROrder[]>;\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
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.ROrderRepoESImpl = void 0;
|
|
10
|
+
const typedi_1 = require("typedi");
|
|
11
|
+
const repositories_1 = require("src/repositories");
|
|
12
|
+
require("./rorder-es.repo");
|
|
13
|
+
let ROrderRepoESImpl = class ROrderRepoESImpl extends repositories_1.BaseRepoESImpl {
|
|
14
|
+
demoSearch() {
|
|
15
|
+
throw new Error("Method not implemented.");
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.ROrderRepoESImpl = ROrderRepoESImpl;
|
|
19
|
+
exports.ROrderRepoESImpl = ROrderRepoESImpl = __decorate([
|
|
20
|
+
(0, typedi_1.Service)("ROrderRepoES")
|
|
21
|
+
], ROrderRepoESImpl);
|
|
22
|
+
//# sourceMappingURL=rorder-es.repo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rorder-es.repo.js","sourceRoot":"","sources":["../../../../src/_examples/repositories/rorder/rorder-es.repo.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mCAAiC;AACjC,mDAAkD;AAIlD,4BAA0B;AAGnB,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,6BAAsB;IAC1D,UAAU;QACR,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF,CAAA;AAJY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,gBAAO,EAAC,cAAc,CAAC;GACX,gBAAgB,CAI5B","sourcesContent":["import { Service } from \"typedi\";\nimport { BaseRepoESImpl } from \"src/repositories\";\nimport { ROrder } from \"src/_examples/model-shared/supplier-portal.model\";\n\nimport { ROrderRepoES } from \"./rorder-es.repo.interface\";\nimport \"./rorder-es.repo\";\n\n@Service(\"ROrderRepoES\")\nexport class ROrderRepoESImpl extends BaseRepoESImpl<ROrder> implements ROrderRepoES {\n demoSearch(): Promise<ROrder[]> {\n throw new Error(\"Method not implemented.\");\n }\n}\n"]}
|
|
@@ -2,12 +2,10 @@ import { ProfileService } from "./profile-service.interface";
|
|
|
2
2
|
import "./profile-service";
|
|
3
3
|
import { ProfileRepoDB } from "../repositories/profile/profile-repo-db.interface";
|
|
4
4
|
import "../repositories/profile/profile-repo-db";
|
|
5
|
-
import {
|
|
6
|
-
import { ActionDynamoDB } from "../../index.js";
|
|
5
|
+
import { CrudServiceImpl } from "../../index.js";
|
|
7
6
|
import { Profile } from "../model-shared/example.model";
|
|
8
|
-
export declare class ProfileServiceImpl extends
|
|
7
|
+
export declare class ProfileServiceImpl extends CrudServiceImpl<Profile, ProfileRepoDB, any> implements ProfileService {
|
|
9
8
|
constructor();
|
|
10
|
-
processChanges(itemOld: Profile, itemNew: Profile, action: ActionDynamoDB, tableName: string): Promise<any>;
|
|
11
9
|
deletePhone(profileId: string): Promise<Profile>;
|
|
12
10
|
mergeById(profileIdSource: string, profileIdTarget: string): Promise<Profile>;
|
|
13
11
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseService } from "../../service/base.service.interface";
|
|
2
1
|
import { Profile } from "../model-shared/example.model";
|
|
3
|
-
|
|
2
|
+
import { CrudService } from "../../index.js";
|
|
3
|
+
export interface ProfileService extends CrudService<Profile> {
|
|
4
4
|
deletePhone(profileId: string): Promise<Profile>;
|
|
5
5
|
mergeById(profileIdSource: string, profileIdTarget: string): Promise<Profile>;
|
|
6
6
|
updateProfileFields(profileId: string, fieldsToUpdate: Partial<Profile>): Promise<Profile>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-service.interface.js","sourceRoot":"","sources":["../../../src/_examples/service/profile-service.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"profile-service.interface.js","sourceRoot":"","sources":["../../../src/_examples/service/profile-service.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { Profile } from \"../model-shared/example.model\";\nimport { CrudService } from \"@chinggis/core\";\n\nexport interface ProfileService extends CrudService<Profile> {\n deletePhone(profileId: string): Promise<Profile>;\n mergeById(profileIdSource: string, profileIdTarget: string): Promise<Profile>;\n updateProfileFields(profileId: string, fieldsToUpdate: Partial<Profile>): Promise<Profile>;\n findAll(): Promise<Profile[]>;\n}\n"]}
|
|
@@ -14,14 +14,11 @@ const typedi_1 = require("typedi");
|
|
|
14
14
|
require("./profile-service");
|
|
15
15
|
require("../repositories/profile/profile-repo-db");
|
|
16
16
|
const errors_1 = require("../../exception/errors");
|
|
17
|
-
const
|
|
18
|
-
let ProfileServiceImpl = class ProfileServiceImpl extends
|
|
17
|
+
const core_1 = require("../../index.js");
|
|
18
|
+
let ProfileServiceImpl = class ProfileServiceImpl extends core_1.CrudServiceImpl {
|
|
19
19
|
constructor() {
|
|
20
20
|
super(typedi_1.Container.get("ProfileRepoDB"), null);
|
|
21
21
|
}
|
|
22
|
-
processChanges(itemOld, itemNew, action, tableName) {
|
|
23
|
-
throw new Error("Method not implemented.");
|
|
24
|
-
}
|
|
25
22
|
async deletePhone(profileId) {
|
|
26
23
|
try {
|
|
27
24
|
const profile = await this.findById("system", profileId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-service.js","sourceRoot":"","sources":["../../../src/_examples/service/profile-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAA4C;AAE5C,6BAA2B;AAE3B,mDAAiD;AAEjD,mDAAmD;AACnD,6DAA6D;AAKtD,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,8BAA4C;IAClF;QACE,KAAK,CAAC,kBAAS,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,cAAc,CAAC,OAAgB,EAAE,OAAgB,EAAE,MAAsB,EAAE,SAAiB;QAC1F,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,SAAiB;QACjC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC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AAE,CAAC;QACvE,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1D,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAEO,WAAW,CAAC,MAAa,EAAE,MAAa;QAC9C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;QACrB,CAAC;QACD,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;CACF,CAAA;AA7IY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,gBAAO,EAAC,gBAAgB,CAAC;;GACb,kBAAkB,CA6I9B","sourcesContent":["import { Container, Service } from \"typedi\";\nimport { ProfileService } from \"./profile-service.interface\";\nimport \"./profile-service\";\nimport { ProfileRepoDB } from \"../repositories/profile/profile-repo-db.interface\";\nimport \"../repositories/profile/profile-repo-db\";\n\nimport { ErrorHttp } from \"../../exception/errors\";\nimport { BaseServiceImpl } from \"../../service/base.service\";\nimport { ActionDynamoDB } from \"@chinggis/core\";\nimport { Profile } from \"../model-shared/example.model\";\n\n@Service(\"ProfileService\")\nexport class ProfileServiceImpl extends BaseServiceImpl<Profile, ProfileRepoDB, any> implements ProfileService {\n constructor() {\n super(Container.get(\"ProfileRepoDB\"), null);\n }\n\n processChanges(itemOld: Profile, itemNew: Profile, action: ActionDynamoDB, tableName: string): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n\n async deletePhone(profileId: string): Promise<Profile> {\n try {\n const profile = await this.findById(\"system\", profileId);\n if (!profile.phone) {\n throw new ErrorHttp({ code: 400, error: \"Уг хаяг дээр утасны дугаар байхгүй байна!\" });\n }\n\n if (profile.oldPhoneNumbers) {\n profile.oldPhoneNumbers.push(profile.phone);\n } else {\n profile.oldPhoneNumbers = [profile.phone];\n }\n\n delete profile.phone;\n delete profile.phoneVerified;\n delete profile.phoneVerificationCode;\n\n return this.save(profile, \"system\");\n } catch (error) {\n throw new ErrorHttp({ code: 500, error: `Error deleting phone: ${error}` });\n }\n }\n\n async mergeById(profileIdSource: string, profileIdTarget: string): Promise<Profile> {\n const profileSource = await this.findById(profileIdSource);\n const profileTarget = await this.findById(profileIdTarget);\n\n if (!profileSource || !profileTarget) {\n throw new ErrorHttp({\n code: 400,\n error: `Тухайн ID дээр профайл олдсонгүй: ${!profileSource ? profileIdSource : profileIdTarget}`,\n });\n }\n try {\n await this.mergeProfile(profileSource, profileTarget);\n return profileTarget;\n } catch (error) {\n throw new ErrorHttp({ code: 500, error: `Error merging profiles by ID: ${error}` });\n }\n }\n\n /**\n * Example method showing PATCH validation (only specific fields)\n */\n async updateProfileFields(profileId: string, fieldsToUpdate: Partial<Profile>): Promise<Profile> {\n const profile = await this.findById(profileId);\n if (!profile) {\n throw new ErrorHttp({ code: 404, error: `Profile not found: ${profileId}` });\n }\n try {\n // Update only the specified fields\n Object.assign(profile, fieldsToUpdate);\n\n return this.save(profile, profileId);\n } catch (error) {\n throw new ErrorHttp({ code: 500, error: `Error updating profile fields: ${error}` });\n }\n }\n\n // Override findAll to return all profiles\n async findAll(): Promise<Profile[]> {\n try {\n const result = await this.scan({});\n return (result.items as Profile[]) || [];\n } catch (error) {\n throw new ErrorHttp({ code: 500, error: `Error fetching all profiles: ${error}` });\n }\n }\n\n private async mergeProfile(from: Partial<Profile>, to: Partial<Profile>): Promise<void> {\n // Merge logic - simplified version of the original\n if (from.cardNumber && to.cardNumber && from.cardNumber !== to.cardNumber) {\n throw new ErrorHttp({ code: 400, error: \"Profiles cannot merge with different card numbers\" });\n }\n\n if (from.cardNumber) to.cardNumber = from.cardNumber;\n if (from.availablePoint) {\n to.availablePoint = to.availablePoint ? to.availablePoint + from.availablePoint : from.availablePoint;\n }\n if (from.providerIds) to.providerIds = this.mergeArrays(to.providerIds || [], from.providerIds);\n if (from.boughtEntityIds) to.boughtEntityIds = this.mergeArrays(to.boughtEntityIds || [], from.boughtEntityIds);\n if (from.loyaltyPercentage && from.loyaltyPercentage > (to.loyaltyPercentage || 0)) {\n to.loyaltyPercentage = from.loyaltyPercentage;\n }\n if (from.email && !to.email) to.email = from.email;\n if (from.firstName && !to.firstName) to.firstName = from.firstName;\n if (from.lastName && !to.lastName) to.lastName = from.lastName;\n if (from.birthDate && !to.birthDate) to.birthDate = from.birthDate;\n if (from.gender && !to.gender) to.gender = from.gender;\n if (from.facebook && !to.facebook) to.facebook = from.facebook;\n if (from.google && !to.google) to.google = from.google;\n if (from.apple && !to.apple) to.apple = from.apple;\n if (from.phone && !to.phone) to.phone = from.phone;\n if (from.cardPin && !to.cardPin) to.cardPin = from.cardPin;\n if (from.emailVerified) to.emailVerified = from.emailVerified;\n if (from.phoneVerified) {\n to.phoneVerified = true;\n delete to.toVerifyPhone;\n }\n\n if (from.oldPhoneNumbers) {\n to.oldPhoneNumbers = this.mergeArrays(to.oldPhoneNumbers || [], from.oldPhoneNumbers);\n if (from.phone) to.oldPhoneNumbers.push(from.phone);\n }\n\n this.addNote(to, `${from.id} id-тай бүртгэлийг энэ бүртгэлтэй нэгтгэв. date: ${new Date().toISOString()}`);\n this.markAsRemoved(from);\n\n await this.saveAll([from, to], \"system\", \"services\");\n }\n\n private addNote(profile: Partial<Profile>, note: string): void {\n if (!profile.note) profile.note = \"\";\n profile.note = profile.note ? `${profile.note}\\n${note}` : note;\n }\n\n private markAsRemoved(profile: Partial<Profile>): void {\n if (profile.phone) profile.phone = `removed_${profile.phone}`;\n if (profile.email) profile.email = `removed_${profile.email}`;\n if (profile.firstName) profile.firstName = `removed_${profile.firstName}`;\n if (profile.lastName) profile.lastName = `removed_${profile.lastName}`;\n if (profile.providerIds && profile.providerIds.length > 0) {\n profile.providerIds = profile.providerIds.map((id) => \"removed_\" + id);\n }\n }\n\n private mergeArrays(target: any[], source: any[]): any[] {\n if (!Array.isArray(target)) {\n return [...source];\n }\n return [...target, ...source.filter((item) => !target.includes(item))];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"profile-service.js","sourceRoot":"","sources":["../../../src/_examples/service/profile-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAA4C;AAE5C,6BAA2B;AAE3B,mDAAiD;AAEjD,mDAAmD;AACnD,yCAAiD;AAI1C,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,sBAA4C;IAClF;QACE,KAAK,CAAC,kBAAS,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,SAAiB;QACjC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YACzD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;gBACnB,MAAM,IAAI,kBAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,2CAA2C,EAAE,CAAC,CAAC;YACzF,CAAC;YAED,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;gBAC5B,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,eAAe,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC5C,CAAC;YAED,OAAO,OAAO,CAAC,KAAK,CAAC;YACrB,OAAO,OAAO,CAAC,aAAa,CAAC;YAC7B,OAAO,OAAO,CAAC,qBAAqB,CAAC;YAErC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,Q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AC;CACF,CAAA;AAzIY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,gBAAO,EAAC,gBAAgB,CAAC;;GACb,kBAAkB,CAyI9B","sourcesContent":["import { Container, Service } from \"typedi\";\nimport { ProfileService } from \"./profile-service.interface\";\nimport \"./profile-service\";\nimport { ProfileRepoDB } from \"../repositories/profile/profile-repo-db.interface\";\nimport \"../repositories/profile/profile-repo-db\";\n\nimport { ErrorHttp } from \"../../exception/errors\";\nimport { CrudServiceImpl } from \"@chinggis/core\";\nimport { Profile } from \"../model-shared/example.model\";\n\n@Service(\"ProfileService\")\nexport class ProfileServiceImpl extends CrudServiceImpl<Profile, ProfileRepoDB, any> implements ProfileService {\n constructor() {\n super(Container.get(\"ProfileRepoDB\"), null);\n }\n\n async deletePhone(profileId: string): Promise<Profile> {\n try {\n const profile = await this.findById(\"system\", profileId);\n if (!profile.phone) {\n throw new ErrorHttp({ code: 400, error: \"Уг хаяг дээр утасны дугаар байхгүй байна!\" });\n }\n\n if (profile.oldPhoneNumbers) {\n profile.oldPhoneNumbers.push(profile.phone);\n } else {\n profile.oldPhoneNumbers = [profile.phone];\n }\n\n delete profile.phone;\n delete profile.phoneVerified;\n delete profile.phoneVerificationCode;\n\n return this.save(profile, \"system\");\n } catch (error) {\n throw new ErrorHttp({ code: 500, error: `Error deleting phone: ${error}` });\n }\n }\n\n async mergeById(profileIdSource: string, profileIdTarget: string): Promise<Profile> {\n const profileSource = await this.findById(profileIdSource);\n const profileTarget = await this.findById(profileIdTarget);\n\n if (!profileSource || !profileTarget) {\n throw new ErrorHttp({\n code: 400,\n error: `Тухайн ID дээр профайл олдсонгүй: ${!profileSource ? profileIdSource : profileIdTarget}`,\n });\n }\n try {\n await this.mergeProfile(profileSource, profileTarget);\n return profileTarget;\n } catch (error) {\n throw new ErrorHttp({ code: 500, error: `Error merging profiles by ID: ${error}` });\n }\n }\n\n /**\n * Example method showing PATCH validation (only specific fields)\n */\n async updateProfileFields(profileId: string, fieldsToUpdate: Partial<Profile>): Promise<Profile> {\n const profile = await this.findById(profileId);\n if (!profile) {\n throw new ErrorHttp({ code: 404, error: `Profile not found: ${profileId}` });\n }\n try {\n // Update only the specified fields\n Object.assign(profile, fieldsToUpdate);\n\n return this.save(profile, profileId);\n } catch (error) {\n throw new ErrorHttp({ code: 500, error: `Error updating profile fields: ${error}` });\n }\n }\n\n // Override findAll to return all profiles\n async findAll(): Promise<Profile[]> {\n try {\n const result = await this.scan({});\n return (result.items as Profile[]) || [];\n } catch (error) {\n throw new ErrorHttp({ code: 500, error: `Error fetching all profiles: ${error}` });\n }\n }\n\n private async mergeProfile(from: Partial<Profile>, to: Partial<Profile>): Promise<void> {\n // Merge logic - simplified version of the original\n if (from.cardNumber && to.cardNumber && from.cardNumber !== to.cardNumber) {\n throw new ErrorHttp({ code: 400, error: \"Profiles cannot merge with different card numbers\" });\n }\n\n if (from.cardNumber) to.cardNumber = from.cardNumber;\n if (from.availablePoint) {\n to.availablePoint = to.availablePoint ? to.availablePoint + from.availablePoint : from.availablePoint;\n }\n if (from.providerIds) to.providerIds = this.mergeArrays(to.providerIds || [], from.providerIds);\n if (from.boughtEntityIds) to.boughtEntityIds = this.mergeArrays(to.boughtEntityIds || [], from.boughtEntityIds);\n if (from.loyaltyPercentage && from.loyaltyPercentage > (to.loyaltyPercentage || 0)) {\n to.loyaltyPercentage = from.loyaltyPercentage;\n }\n if (from.email && !to.email) to.email = from.email;\n if (from.firstName && !to.firstName) to.firstName = from.firstName;\n if (from.lastName && !to.lastName) to.lastName = from.lastName;\n if (from.birthDate && !to.birthDate) to.birthDate = from.birthDate;\n if (from.gender && !to.gender) to.gender = from.gender;\n if (from.facebook && !to.facebook) to.facebook = from.facebook;\n if (from.google && !to.google) to.google = from.google;\n if (from.apple && !to.apple) to.apple = from.apple;\n if (from.phone && !to.phone) to.phone = from.phone;\n if (from.cardPin && !to.cardPin) to.cardPin = from.cardPin;\n if (from.emailVerified) to.emailVerified = from.emailVerified;\n if (from.phoneVerified) {\n to.phoneVerified = true;\n delete to.toVerifyPhone;\n }\n\n if (from.oldPhoneNumbers) {\n to.oldPhoneNumbers = this.mergeArrays(to.oldPhoneNumbers || [], from.oldPhoneNumbers);\n if (from.phone) to.oldPhoneNumbers.push(from.phone);\n }\n\n this.addNote(to, `${from.id} id-тай бүртгэлийг энэ бүртгэлтэй нэгтгэв. date: ${new Date().toISOString()}`);\n this.markAsRemoved(from);\n\n await this.saveAll([from, to], \"system\", \"services\");\n }\n\n private addNote(profile: Partial<Profile>, note: string): void {\n if (!profile.note) profile.note = \"\";\n profile.note = profile.note ? `${profile.note}\\n${note}` : note;\n }\n\n private markAsRemoved(profile: Partial<Profile>): void {\n if (profile.phone) profile.phone = `removed_${profile.phone}`;\n if (profile.email) profile.email = `removed_${profile.email}`;\n if (profile.firstName) profile.firstName = `removed_${profile.firstName}`;\n if (profile.lastName) profile.lastName = `removed_${profile.lastName}`;\n if (profile.providerIds && profile.providerIds.length > 0) {\n profile.providerIds = profile.providerIds.map((id) => \"removed_\" + id);\n }\n }\n\n private mergeArrays(target: any[], source: any[]): any[] {\n if (!Array.isArray(target)) {\n return [...source];\n }\n return [...target, ...source.filter((item) => !target.includes(item))];\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CrudServiceImpl } from "src/service";
|
|
2
|
+
import { ROrder } from "src/_examples/model-shared/supplier-portal.model";
|
|
3
|
+
import { ROrderService } from "./rorder-service.interface";
|
|
4
|
+
import "./rorder-service";
|
|
5
|
+
import { ROrderRepoDB } from "src/_examples/repositories/rorder/rorder-db.repo.interface";
|
|
6
|
+
import "src/_examples/repositories/rorder/rorder-db.repo";
|
|
7
|
+
import { ROrderRepoES } from "src/_examples/repositories/rorder/rorder-es.repo.interface";
|
|
8
|
+
import "src/_examples/repositories/rorder/rorder-es.repo";
|
|
9
|
+
export declare class ROrderServiceImpl extends CrudServiceImpl<ROrder, ROrderRepoDB, ROrderRepoES> implements ROrderService {
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CrudService } from "src/service";
|
|
2
|
+
import { Retailer, ROrder, ROrderItem, Supplier } from "src/_examples/model-shared/supplier-portal.model";
|
|
3
|
+
export type ReportData = {
|
|
4
|
+
supplierToItemsMap: Map<Supplier, Partial<ROrderItem>[]>;
|
|
5
|
+
retailer: Retailer;
|
|
6
|
+
retailerOrder: ROrder;
|
|
7
|
+
};
|
|
8
|
+
export interface ROrderService extends CrudService<ROrder> {
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rorder-service.interface.js","sourceRoot":"","sources":["../../../../src/_examples/service/rorder/rorder-service.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { CrudService } from \"src/service\";\nimport { Retailer, ROrder, ROrderItem, Supplier } from \"src/_examples/model-shared/supplier-portal.model\";\n\nexport type ReportData = {\n supplierToItemsMap: Map<Supplier, Partial<ROrderItem>[]>;\n retailer: Retailer;\n retailerOrder: ROrder;\n};\n\nexport interface ROrderService extends CrudService<ROrder> {}\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.ROrderServiceImpl = void 0;
|
|
46
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
47
|
+
const service_1 = require("src/service");
|
|
48
|
+
const order_config_1 = require("src/_examples/controller/rorder/order-config");
|
|
49
|
+
require("./rorder-service");
|
|
50
|
+
require("src/_examples/repositories/rorder/rorder-db.repo");
|
|
51
|
+
require("src/_examples/repositories/rorder/rorder-es.repo");
|
|
52
|
+
let ROrderServiceImpl = class ROrderServiceImpl extends service_1.CrudServiceImpl {
|
|
53
|
+
constructor() {
|
|
54
|
+
const repoDB = typedi_1.default.get("ROrderRepoDB");
|
|
55
|
+
const repoES = typedi_1.default.get("ROrderRepoES");
|
|
56
|
+
super(repoDB, repoES);
|
|
57
|
+
this.setConfig(order_config_1.CONFIG_ORDER.toObject());
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
exports.ROrderServiceImpl = ROrderServiceImpl;
|
|
61
|
+
exports.ROrderServiceImpl = ROrderServiceImpl = __decorate([
|
|
62
|
+
(0, typedi_1.Service)("ROrderService"),
|
|
63
|
+
__metadata("design:paramtypes", [])
|
|
64
|
+
], ROrderServiceImpl);
|
|
65
|
+
//# sourceMappingURL=rorder-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rorder-service.js","sourceRoot":"","sources":["../../../../src/_examples/service/rorder/rorder-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,yCAA8C;AAE9C,+EAA4E;AAG5E,4BAA0B;AAG1B,4DAA0D;AAG1D,4DAA0D;AAGnD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,yBAAmD;IACxF;QACE,MAAM,MAAM,GAAiB,gBAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC3D,MAAM,MAAM,GAAiB,gBAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC3D,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,2BAAY,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF,CAAA;AAPY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,gBAAO,EAAC,eAAe,CAAC;;GACZ,iBAAiB,CAO7B","sourcesContent":["import Container, { Service } from \"typedi\";\n\nimport { CrudServiceImpl } from \"src/service\";\nimport { ROrder } from \"src/_examples/model-shared/supplier-portal.model\";\nimport { CONFIG_ORDER } from \"src/_examples/controller/rorder/order-config\";\n\nimport { ROrderService } from \"./rorder-service.interface\";\nimport \"./rorder-service\";\n\nimport { ROrderRepoDB } from \"src/_examples/repositories/rorder/rorder-db.repo.interface\";\nimport \"src/_examples/repositories/rorder/rorder-db.repo\";\n\nimport { ROrderRepoES } from \"src/_examples/repositories/rorder/rorder-es.repo.interface\";\nimport \"src/_examples/repositories/rorder/rorder-es.repo\";\n\n@Service(\"ROrderService\")\nexport class ROrderServiceImpl extends CrudServiceImpl<ROrder, ROrderRepoDB, ROrderRepoES> implements ROrderService {\n constructor() {\n const repoDB: ROrderRepoDB = Container.get(\"ROrderRepoDB\");\n const repoES: ROrderRepoES = Container.get(\"ROrderRepoES\");\n super(repoDB, repoES);\n this.setConfig(CONFIG_ORDER.toObject());\n }\n}\n"]}
|
|
@@ -117,7 +117,7 @@ class ControllerApi {
|
|
|
117
117
|
throw new exception_1.ErrorHttp({ code: 400, error: "BadRequest" }, "[CORE] No ownerId provided");
|
|
118
118
|
}
|
|
119
119
|
// Initialize IDs
|
|
120
|
-
const { ownerId,
|
|
120
|
+
const { ownerId, ownerParentId: inputParentId } = entity;
|
|
121
121
|
let profileId = ownerId;
|
|
122
122
|
let parentId;
|
|
123
123
|
// Determine parentId and profileId
|
|
@@ -135,7 +135,7 @@ class ControllerApi {
|
|
|
135
135
|
profileId = cognitoUser.profile;
|
|
136
136
|
}
|
|
137
137
|
// Remove fields that shouldn't be saved directly
|
|
138
|
-
delete entity.
|
|
138
|
+
delete entity.ownerParentId;
|
|
139
139
|
delete entity.ownerId;
|
|
140
140
|
// Save entity
|
|
141
141
|
return this.service.save(entity, profileId, parentId);
|