aws-service-stack 0.18.308 → 0.18.310
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/commission/commission.config.d.ts +1 -1
- package/dist/_examples/controller/commission/commission.config.js +3 -3
- package/dist/_examples/controller/commission/commission.config.js.map +1 -1
- package/dist/_examples/controller/supplier/supplier-config.js +0 -1
- package/dist/_examples/controller/supplier/supplier-config.js.map +1 -1
- package/dist/_examples/controller/supplier/supplier-controller-api.d.ts +2 -2
- package/dist/_examples/controller/supplier/supplier-controller-api.js +4 -6
- package/dist/_examples/controller/supplier/supplier-controller-api.js.map +1 -1
- package/dist/_examples/model-shared/supplier-portal.model.d.ts +1 -10
- package/dist/_examples/model-shared/supplier-portal.model.js.map +1 -1
- package/dist/_examples/repositories/supplier/supplier-repo-db.d.ts +2 -2
- package/dist/_examples/repositories/supplier/supplier-repo-db.interface.d.ts +2 -2
- package/dist/_examples/repositories/supplier/supplier-repo-db.interface.js.map +1 -1
- package/dist/_examples/repositories/supplier/supplier-repo-db.js.map +1 -1
- package/dist/_examples/repositories/supplier/supplier-repo-es.d.ts +2 -2
- package/dist/_examples/repositories/supplier/supplier-repo-es.interface.d.ts +2 -2
- package/dist/_examples/repositories/supplier/supplier-repo-es.interface.js.map +1 -1
- package/dist/_examples/repositories/supplier/supplier-repo-es.js.map +1 -1
- package/dist/_examples/service/commission/commission-service.js +2 -0
- package/dist/_examples/service/commission/commission-service.js.map +1 -1
- package/dist/_examples/service/rorder/rorder-service.interface.d.ts +2 -1
- package/dist/_examples/service/rorder/rorder-service.interface.js.map +1 -1
- package/dist/_examples/service/supplier/supplier-service-crud.d.ts +17 -6
- package/dist/_examples/service/supplier/supplier-service-crud.interface.d.ts +12 -5
- package/dist/_examples/service/supplier/supplier-service-crud.interface.js.map +1 -1
- package/dist/_examples/service/supplier/supplier-service-crud.js +61 -76
- package/dist/_examples/service/supplier/supplier-service-crud.js.map +1 -1
- package/dist/_examples/service/supplier/supplier-service-stream.d.ts +5 -5
- package/dist/_examples/service/supplier/supplier-service-stream.interface.d.ts +2 -2
- package/dist/_examples/service/supplier/supplier-service-stream.interface.js.map +1 -1
- package/dist/_examples/service/supplier/supplier-service-stream.js.map +1 -1
- package/dist/model/filter.model.d.ts +1 -0
- package/dist/model/filter.model.js.map +1 -1
- package/dist/repositories/base-db.repo.d.ts +1 -0
- package/dist/repositories/base-db.repo.interface.d.ts +1 -0
- package/dist/repositories/base-db.repo.interface.js.map +1 -1
- package/dist/repositories/base-db.repo.js +17 -0
- package/dist/repositories/base-db.repo.js.map +1 -1
- package/dist/utils/opensearch.utils.d.ts +2 -0
- package/dist/utils/opensearch.utils.js +93 -0
- package/dist/utils/opensearch.utils.js.map +1 -1
- package/dist/utils/reflection.util.js +1 -1
- package/dist/utils/reflection.util.js.map +1 -1
- package/dist/utils/validation.util.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseRepoDBImpl } from "../../../index.js";
|
|
2
|
-
import { SAccount } from "../../model-shared/suppler.model-to-remove";
|
|
3
2
|
import { SupplierRepoDB } from "./supplier-repo-db.interface";
|
|
4
3
|
import "./supplier-repo-db";
|
|
5
|
-
|
|
4
|
+
import { Supplier } from "../../model-shared/supplier.model";
|
|
5
|
+
export declare class SupplierRepoDBImpl extends BaseRepoDBImpl<Supplier> implements SupplierRepoDB {
|
|
6
6
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { BaseRepoDB } from "../../../index.js";
|
|
2
|
-
import {
|
|
3
|
-
export interface SupplierRepoDB extends BaseRepoDB<
|
|
2
|
+
import { Supplier } from "../../model-shared/supplier.model";
|
|
3
|
+
export interface SupplierRepoDB extends BaseRepoDB<Supplier> {
|
|
4
4
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supplier-repo-db.interface.js","sourceRoot":"","sources":["../../../../src/_examples/repositories/supplier/supplier-repo-db.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { BaseRepoDB } from \"@chinggis/core\";\nimport {
|
|
1
|
+
{"version":3,"file":"supplier-repo-db.interface.js","sourceRoot":"","sources":["../../../../src/_examples/repositories/supplier/supplier-repo-db.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { BaseRepoDB } from \"@chinggis/core\";\nimport { Supplier } from \"../../model-shared/supplier.model\";\n\nexport interface SupplierRepoDB extends BaseRepoDB<Supplier> {}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supplier-repo-db.js","sourceRoot":"","sources":["../../../../src/_examples/repositories/supplier/supplier-repo-db.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mCAAiC;AACjC,yCAAgD;
|
|
1
|
+
{"version":3,"file":"supplier-repo-db.js","sourceRoot":"","sources":["../../../../src/_examples/repositories/supplier/supplier-repo-db.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mCAAiC;AACjC,yCAAgD;AAEhD,8BAA4B;AAIrB,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,qBAAwB;CAA6B,CAAA;AAAhF,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,gBAAO,EAAC,gBAAgB,CAAC;GACb,kBAAkB,CAA8D","sourcesContent":["import { Service } from \"typedi\";\nimport { BaseRepoDBImpl } from \"@chinggis/core\";\nimport { SupplierRepoDB } from \"./supplier-repo-db.interface\";\nimport \"./supplier-repo-db\";\nimport { Supplier } from \"../../model-shared/supplier.model\";\n\n@Service(\"SupplierRepoDB\")\nexport class SupplierRepoDBImpl extends BaseRepoDBImpl<Supplier> implements SupplierRepoDB {}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseRepoESImpl } from "../../../index.js";
|
|
2
|
-
import { SAccount } from "../../model-shared/suppler.model-to-remove";
|
|
3
2
|
import { SupplierRepoES } from "./supplier-repo-es.interface";
|
|
4
3
|
import "./supplier-repo-es";
|
|
5
|
-
|
|
4
|
+
import { Supplier } from "src/_examples/model-shared/supplier.model";
|
|
5
|
+
export declare class SupplierRepoESImpl extends BaseRepoESImpl<Supplier> implements SupplierRepoES {
|
|
6
6
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { BaseRepoES } from "../../../index.js";
|
|
2
|
-
import {
|
|
3
|
-
export interface SupplierRepoES extends BaseRepoES<
|
|
2
|
+
import { Supplier } from "../../model-shared/supplier.model";
|
|
3
|
+
export interface SupplierRepoES extends BaseRepoES<Supplier> {
|
|
4
4
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supplier-repo-es.interface.js","sourceRoot":"","sources":["../../../../src/_examples/repositories/supplier/supplier-repo-es.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { BaseRepoES } from \"@chinggis/core\";\nimport {
|
|
1
|
+
{"version":3,"file":"supplier-repo-es.interface.js","sourceRoot":"","sources":["../../../../src/_examples/repositories/supplier/supplier-repo-es.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { BaseRepoES } from \"@chinggis/core\";\nimport { Supplier } from \"../../model-shared/supplier.model\";\n\nexport interface SupplierRepoES extends BaseRepoES<Supplier> {}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supplier-repo-es.js","sourceRoot":"","sources":["../../../../src/_examples/repositories/supplier/supplier-repo-es.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mCAAiC;AACjC,yCAAgD;
|
|
1
|
+
{"version":3,"file":"supplier-repo-es.js","sourceRoot":"","sources":["../../../../src/_examples/repositories/supplier/supplier-repo-es.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mCAAiC;AACjC,yCAAgD;AAEhD,8BAA4B;AAIrB,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,qBAAwB;CAA6B,CAAA;AAAhF,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,gBAAO,EAAC,gBAAgB,CAAC;GACb,kBAAkB,CAA8D","sourcesContent":["import { Service } from \"typedi\";\nimport { BaseRepoESImpl } from \"@chinggis/core\";\nimport { SupplierRepoES } from \"./supplier-repo-es.interface\";\nimport \"./supplier-repo-es\";\nimport { Supplier } from \"src/_examples/model-shared/supplier.model\";\n\n@Service(\"SupplierRepoES\")\nexport class SupplierRepoESImpl extends BaseRepoESImpl<Supplier> implements SupplierRepoES {}\n"]}
|
|
@@ -54,6 +54,7 @@ require("src/_examples/repositories/commission/commission-repo-db");
|
|
|
54
54
|
require("../supplier/supplier-service-crud");
|
|
55
55
|
require("../raccount/raccount-service");
|
|
56
56
|
const raccount_model_1 = require("src/_examples/model-shared/raccount.model");
|
|
57
|
+
const commission_config_1 = require("../../controller/commission/commission.config");
|
|
57
58
|
let CommissionServiceImpl = class CommissionServiceImpl extends service_1.CrudServiceImpl {
|
|
58
59
|
feePool;
|
|
59
60
|
supplierService;
|
|
@@ -64,6 +65,7 @@ let CommissionServiceImpl = class CommissionServiceImpl extends service_1.CrudSe
|
|
|
64
65
|
this.feePool = new Map();
|
|
65
66
|
this.supplierService = typedi_1.default.get("SupplierCrudService");
|
|
66
67
|
this.rAccountService = typedi_1.default.get("RAccountService");
|
|
68
|
+
this.setConfig(commission_config_1.CONFIG_COMMISSION.toObject());
|
|
67
69
|
}
|
|
68
70
|
async create(supplierUsername, retailerUsername, toRetailerPercent) {
|
|
69
71
|
const supplier = (await this.supplierService.find({ username: supplierUsername })).items[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commission-service.js","sourceRoot":"","sources":["../../../../src/_examples/service/commission/commission-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA8C;AAC9C,uEAAuD;AACvD,kDAA0B;AAC1B,iDAA4C;AAG5C,oEAAkE;AAGlE,6CAA2C;AAG3C,wCAAsC;AAGtC,8EAAqF;
|
|
1
|
+
{"version":3,"file":"commission-service.js","sourceRoot":"","sources":["../../../../src/_examples/service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AEzE,MAAM,GAAG,GAAG,WAAW;aACpB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,KAAK,cAAc,CAAC;aAC1D,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5C,OAAO,GAAG,IAAI,CAAC,CAAC;IAClB,CAAC;CACF,CAAA;AA1EY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,gBAAO,EAAC,mBAAmB,CAAC;;GAChB,qBAAqB,CA0EjC","sourcesContent":["import { CrudServiceImpl } from \"src/service\";\nimport { HTTP } from \"src/exception/exception-handler\";\nimport dayjs from \"dayjs\";\nimport Container, { Service } from \"typedi\";\n\nimport { CommissionRepoDB } from \"src/_examples/repositories/commission/commission-repo-db.interface\";\nimport \"src/_examples/repositories/commission/commission-repo-db\";\n\nimport { SupplierService } from \"../supplier/supplier-service-crud.interface\";\nimport \"../supplier/supplier-service-crud\";\n\nimport { RAccountService } from \"../raccount/raccount-service.interface\";\nimport \"../raccount/raccount-service\";\n\nimport { Commission } from \"src/_examples/model-shared/commission.model\";\nimport { ContractStatus, Retailer } from \"src/_examples/model-shared/raccount.model\";\n\nimport { CommissionService } from \"./commission-service.interface\";\nimport { CONFIG_COMMISSION } from \"../../controller/commission/commission.config\";\n\n@Service(\"CommissionService\")\nexport class CommissionServiceImpl\n extends CrudServiceImpl<Commission, CommissionRepoDB, null>\n implements CommissionService\n{\n private readonly feePool: Map<string, number>;\n private readonly supplierService: SupplierService;\n private readonly rAccountService: RAccountService;\n\n constructor() {\n const repoDB: CommissionRepoDB = Container.get(\"CommissionRepoDB\");\n super(repoDB, null);\n this.feePool = new Map<string, number>();\n\n this.supplierService = Container.get(\"SupplierCrudService\");\n this.rAccountService = Container.get(\"RAccountService\");\n\n this.setConfig(CONFIG_COMMISSION.toObject());\n }\n\n async create(supplierUsername: string, retailerUsername: string, toRetailerPercent?: number): Promise<Commission> {\n const supplier = (await this.supplierService.find({ username: supplierUsername })).items[0];\n const retailer = (await this.rAccountService.find({ username: retailerUsername })).items[0];\n\n if (retailer.contractStatus === ContractStatus.EXPIRED) {\n this.throwError(HTTP.BAD_REQUEST.code, \"Уг retailer идэвхжээгүй байна.\");\n }\n\n const existingFee = await this.find({\n supplierUsername,\n retailerUsername,\n });\n\n if (existingFee.items.length > 0) {\n this.throwError(\n HTTP.BAD_REQUEST.code,\n `Fee already exist on supplier: ${supplierUsername} and retailer: ${retailerUsername}`,\n );\n return;\n }\n\n const percentage = retailer.commission1 ?? retailer.commission2;\n\n return this.save(\n {\n supplierUsername: supplierUsername,\n retailerUsername: retailerUsername,\n toRetailerPercent: toRetailerPercent ?? percentage,\n supplier: {\n firstName: supplier.firstName + \" \" + supplier.lastName,\n username: supplier.username,\n taxPayer: supplier.taxPayer,\n },\n retailer: retailer as Retailer,\n isActive: true,\n createdMonth: dayjs(new Date()).format(\"YYYY-MM-DD\"),\n },\n retailerUsername,\n );\n }\n\n async getRetailerCommissionBySupplier(retailerRegNum: string, supplierRegNum: string): Promise<number> {\n if (!retailerRegNum || !supplierRegNum) {\n console.error(\"retailerRegNum or supplierRegNum is missing\");\n return 0;\n }\n\n const percentList = await this.findAllByIndex(\"byOwner\", supplierRegNum);\n\n const fee = percentList\n .filter((item) => item.retailerUsername === retailerRegNum)\n .map((item) => item.toRetailerPercent)[0];\n\n return fee || 0;\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CrudService } from "src/service";
|
|
2
|
-
import { Retailer, ROrder, ROrderItem
|
|
2
|
+
import { Retailer, ROrder, ROrderItem } from "src/_examples/model-shared/supplier-portal.model";
|
|
3
|
+
import { Supplier } from "../../model-shared/supplier.model";
|
|
3
4
|
export type ReportData = {
|
|
4
5
|
supplierToItemsMap: Map<Supplier, Partial<ROrderItem>[]>;
|
|
5
6
|
retailer: Retailer;
|
|
@@ -1 +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
|
|
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 } from \"src/_examples/model-shared/supplier-portal.model\";\nimport { Supplier } from \"../../model-shared/supplier.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"]}
|
|
@@ -3,12 +3,23 @@ import { SupplierRepoDB } from "../../repositories/supplier/supplier-repo-db.int
|
|
|
3
3
|
import "../../repositories/supplier/supplier-repo-db";
|
|
4
4
|
import { SupplierRepoES } from "../../repositories/supplier/supplier-repo-es.interface";
|
|
5
5
|
import "../../repositories/supplier/supplier-repo-es";
|
|
6
|
-
import { ActionDynamoDB,
|
|
7
|
-
import { SAccount } from "../../model-shared/suppler.model-to-remove";
|
|
6
|
+
import { ActionDynamoDB, CognitoUserStatus } from "../../../index.js";
|
|
8
7
|
import { CrudServiceImpl } from "../../../service/crud.service";
|
|
9
|
-
|
|
8
|
+
import "../entity/entity-service";
|
|
9
|
+
import "../commission/commission-service";
|
|
10
|
+
import { Supplier } from "../../model-shared/supplier.model";
|
|
11
|
+
import { Entity, ROrderItem, SOrder } from "../../model-shared/supplier-portal.model";
|
|
12
|
+
export declare class SupplierServiceImpl extends CrudServiceImpl<Supplier, SupplierRepoDB, SupplierRepoES> implements SupplierService {
|
|
13
|
+
private readonly entityService;
|
|
14
|
+
private readonly commissionService;
|
|
10
15
|
constructor();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
calculateItemCounts(entities: Entity[]): Promise<Map<Entity, number>>;
|
|
17
|
+
createDraftSOrder(entities: Map<Entity, number>): SOrder;
|
|
18
|
+
updateCognitoStatus(username: string, status: CognitoUserStatus): Promise<void>;
|
|
19
|
+
listNonPartners(retailerUsername: string, page: number, size: number): Promise<Partial<Supplier>[]>;
|
|
20
|
+
updateItems(supplierListModified: Supplier[], strings: string[]): void;
|
|
21
|
+
sendOrderToSupplier(sOrder: SOrder): Promise<boolean>;
|
|
22
|
+
getSupplierAll(): Promise<Supplier[]>;
|
|
23
|
+
saveSalesReportItems(rOrderItems: ROrderItem[]): Promise<boolean>;
|
|
24
|
+
processChanges(itemOld: Supplier, itemNew: Supplier, action: ActionDynamoDB, tableName: string): Promise<any>;
|
|
14
25
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { Filter, List } from "../../../index.js";
|
|
2
|
-
import { SAccount } from "../../model-shared/suppler.model-to-remove";
|
|
3
1
|
import { CrudService } from "../../../service/crud.service.interface";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { Entity, SOrder } from "../../model-shared/supplier-portal.model";
|
|
3
|
+
import { CognitoUserStatus } from "../../../index.js";
|
|
4
|
+
import { Supplier } from "../../model-shared/supplier.model";
|
|
5
|
+
export interface SupplierService extends CrudService<Supplier> {
|
|
6
|
+
calculateItemCounts(entities: Entity[]): Promise<Map<Entity, number>>;
|
|
7
|
+
createDraftSOrder(entities: Map<Entity, number>): SOrder;
|
|
8
|
+
sendOrderToSupplier(sOrder: SOrder): Promise<boolean>;
|
|
9
|
+
getSupplierAll(): Promise<Supplier[]>;
|
|
10
|
+
updateItems(supplierListModified: Supplier[], strings: string[]): any;
|
|
11
|
+
sendOrderToSupplier(sOrder: SOrder): Promise<boolean>;
|
|
12
|
+
updateCognitoStatus(username: string, status: CognitoUserStatus): Promise<void>;
|
|
13
|
+
listNonPartners(retailerUsername: string, page: number, size: number): Promise<Partial<Supplier>[]>;
|
|
7
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supplier-service-crud.interface.js","sourceRoot":"","sources":["../../../../src/_examples/service/supplier/supplier-service-crud.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"supplier-service-crud.interface.js","sourceRoot":"","sources":["../../../../src/_examples/service/supplier/supplier-service-crud.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { CrudService } from \"../../../service/crud.service.interface\";\nimport { Entity, SOrder } from \"../../model-shared/supplier-portal.model\";\nimport { CognitoUserStatus } from \"@chinggis/core\";\nimport { Supplier } from \"../../model-shared/supplier.model\";\n\nexport interface SupplierService extends CrudService<Supplier> {\n calculateItemCounts(entities: Entity[]): Promise<Map<Entity, number>>;\n\n createDraftSOrder(entities: Map<Entity, number>): SOrder;\n\n sendOrderToSupplier(sOrder: SOrder): Promise<boolean>;\n\n getSupplierAll(): Promise<Supplier[]>;\n\n updateItems(supplierListModified: Supplier[], strings: string[]): any;\n\n sendOrderToSupplier(sOrder: SOrder): Promise<boolean>;\n\n updateCognitoStatus(username: string, status: CognitoUserStatus): Promise<void>;\n\n listNonPartners(retailerUsername: string, page: number, size: number): Promise<Partial<Supplier>[]>;\n}\n"]}
|
|
@@ -42,103 +42,88 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
42
42
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
43
|
};
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.
|
|
45
|
+
exports.SupplierServiceImpl = void 0;
|
|
46
46
|
const typedi_1 = __importStar(require("typedi"));
|
|
47
47
|
require("../../repositories/supplier/supplier-repo-db");
|
|
48
48
|
require("../../repositories/supplier/supplier-repo-es");
|
|
49
49
|
const core_1 = require("../../../index.js");
|
|
50
50
|
const supplier_config_1 = require("../../controller/supplier/supplier-config");
|
|
51
51
|
const crud_service_1 = require("../../../service/crud.service");
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
require("../entity/entity-service");
|
|
53
|
+
require("../commission/commission-service");
|
|
54
|
+
let SupplierServiceImpl = class SupplierServiceImpl extends crud_service_1.CrudServiceImpl {
|
|
55
|
+
// @Inject("EOrderService") private readonly ecomOrderService: EOrderService;
|
|
54
56
|
// @Inject("ROrderService") private readonly rOrderService: ROrderService;
|
|
57
|
+
entityService;
|
|
58
|
+
commissionService;
|
|
55
59
|
//
|
|
56
60
|
constructor() {
|
|
57
61
|
const repoDB = typedi_1.default.get("SupplierRepoDB");
|
|
58
62
|
const repoES = typedi_1.default.get("SupplierRepoES");
|
|
59
63
|
super(repoDB, repoES);
|
|
64
|
+
this.setConfig(supplier_config_1.CONFIG_SUPPLIER.toObject());
|
|
60
65
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!supplier)
|
|
64
|
-
return this.throwError(core_1.HTTP.BAD_REQUEST.code, "supplier not found!");
|
|
65
|
-
if (supplier?.loginStatus === "pending")
|
|
66
|
-
return this.throwError(core_1.HTTP.BAD_REQUEST.code, "already pending user!");
|
|
67
|
-
if (supplier?.loginStatus === "confirmed")
|
|
68
|
-
return this.throwError(core_1.HTTP.BAD_REQUEST.code, "already confirmed user!");
|
|
66
|
+
calculateItemCounts(entities) {
|
|
67
|
+
throw new Error("Method not implemented.");
|
|
69
68
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
query: {
|
|
77
|
-
bool: {
|
|
78
|
-
must_not: [
|
|
79
|
-
{
|
|
80
|
-
term: {
|
|
81
|
-
accountType: "level1",
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
should: [],
|
|
86
|
-
minimum_should_match: 1,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
from: filterAndSort.page * filterAndSort.size,
|
|
90
|
-
size: filterAndSort.size,
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
if (filterAndSort.page && filterAndSort.size) {
|
|
94
|
-
filter.body.from = filterAndSort.page * filterAndSort.size;
|
|
95
|
-
}
|
|
96
|
-
if (filterAndSort.size) {
|
|
97
|
-
filter.body.size = filterAndSort.size;
|
|
98
|
-
}
|
|
99
|
-
if (!filterAndSort.searchKeyword) {
|
|
100
|
-
const result = await this.repoES.search(filter, true);
|
|
101
|
-
return {
|
|
102
|
-
items: result,
|
|
103
|
-
lastKey: null,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
let searchKeyword = filterAndSort.searchKeyword.trim();
|
|
107
|
-
const searchFields = ["username", "firstName", "lastName", "phoneList", "bankAccountNumber", "bankName"];
|
|
108
|
-
searchKeyword = (0, core_1.toCaseInsensitive)(searchKeyword);
|
|
109
|
-
searchFields.forEach((field) => {
|
|
110
|
-
filter.body.query.bool.should.push({
|
|
111
|
-
regexp: {
|
|
112
|
-
[field]: {
|
|
113
|
-
value: `.*${searchKeyword}.*`,
|
|
114
|
-
case_insensitive: true,
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
});
|
|
69
|
+
createDraftSOrder(entities) {
|
|
70
|
+
throw new Error("Method not implemented.");
|
|
71
|
+
}
|
|
72
|
+
async updateCognitoStatus(username, status) {
|
|
73
|
+
const supplierList = await this.find({
|
|
74
|
+
username,
|
|
118
75
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
});
|
|
76
|
+
const supplier = supplierList.items[0];
|
|
77
|
+
supplier.cognitoStatus = status;
|
|
78
|
+
await this.update(supplier);
|
|
79
|
+
}
|
|
80
|
+
async listNonPartners(retailerUsername, page, size) {
|
|
81
|
+
try {
|
|
82
|
+
const partnerCommissions = await this.commissionService.findAllByIndex("byRetailer", retailerUsername);
|
|
83
|
+
const partnerUsernames = new Set(partnerCommissions.map((c) => c.supplierUsername));
|
|
84
|
+
const filter = (0, core_1.parseFilter)(`size=${size}&page=${page}&accountType=level3,level4`);
|
|
85
|
+
const suppliers = await this.search(filter);
|
|
86
|
+
return suppliers.filter((s) => !partnerUsernames.has(s.username));
|
|
128
87
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
88
|
+
catch (error) {
|
|
89
|
+
console.log(error);
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
updateItems(supplierListModified, strings) {
|
|
94
|
+
throw new Error("Method not implemented.");
|
|
95
|
+
}
|
|
96
|
+
sendOrderToSupplier(sOrder) {
|
|
97
|
+
throw new Error("Method not implemented.");
|
|
98
|
+
}
|
|
99
|
+
async getSupplierAll() {
|
|
100
|
+
const supplierList = [];
|
|
101
|
+
// while (true) {
|
|
102
|
+
// const response = await this.repoDB.find(parseIndexFilter("", DYNAMO_DB.SUPPLIER.MAP));
|
|
103
|
+
// if (response.items.length > 0) supplierList.push(...(response.items as unknown as Supplier[]));
|
|
104
|
+
//
|
|
105
|
+
// if (!response.lastKey) break;
|
|
106
|
+
// }
|
|
107
|
+
return supplierList;
|
|
108
|
+
}
|
|
109
|
+
async saveSalesReportItems(rOrderItems) {
|
|
110
|
+
return true;
|
|
134
111
|
}
|
|
135
112
|
async processChanges(itemOld, itemNew, action, tableName) {
|
|
136
113
|
throw new Error("Method not implemented.");
|
|
137
114
|
}
|
|
138
115
|
};
|
|
139
|
-
exports.
|
|
140
|
-
|
|
116
|
+
exports.SupplierServiceImpl = SupplierServiceImpl;
|
|
117
|
+
__decorate([
|
|
118
|
+
(0, typedi_1.Inject)("EntityService"),
|
|
119
|
+
__metadata("design:type", Object)
|
|
120
|
+
], SupplierServiceImpl.prototype, "entityService", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
(0, typedi_1.Inject)("CommissionService"),
|
|
123
|
+
__metadata("design:type", Object)
|
|
124
|
+
], SupplierServiceImpl.prototype, "commissionService", void 0);
|
|
125
|
+
exports.SupplierServiceImpl = SupplierServiceImpl = __decorate([
|
|
141
126
|
(0, typedi_1.Service)("SupplierCrudService"),
|
|
142
127
|
__metadata("design:paramtypes", [])
|
|
143
|
-
],
|
|
128
|
+
], SupplierServiceImpl);
|
|
144
129
|
//# sourceMappingURL=supplier-service-crud.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supplier-service-crud.js","sourceRoot":"","sources":["../../../../src/_examples/service/supplier/supplier-service-crud.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"supplier-service-crud.js","sourceRoot":"","sources":["../../../../src/_examples/service/supplier/supplier-service-crud.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AAKpD,wDAAsD;AAGtD,wDAAsD;AACtD,yCAAgF;AAChF,+EAA4E;AAC5E,gEAAgE;AAGhE,oCAAkC;AAElC,4CAA0C;AAKnC,IAAM,mBAAmB,GAAzB,MAAM,mBACX,SAAQ,8BAAyD;IAGjE,6EAA6E;IAC7E,0EAA0E;IAChC,aAAa,CAAgB;IACzB,iBAAiB,CAAoB;IAEnF,EAAE;IACF;QACE,MAAM,MAAM,GAAmB,gBAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC/D,MAAM,MAAM,GAAmB,gBAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC/D,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,iCAAe,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,mBAAmB,CAAC,QAAkB;QACpC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,iBAAiB,CAAC,QAA6B;QAC7C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,C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IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,YAAY,GAAe,EAAE,CAAC;QACpC,oBAAoB;QACpB,8FAA8F;QAC9F,uGAAuG;QACvG,EAAE;QACF,qCAAqC;QACrC,OAAO;QACP,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,WAAyB;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAiB,EAAE,OAAiB,EAAE,MAAsB,EAAE,SAAiB;QAClG,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF,CAAA;AA5EY,kDAAmB;AAMY;IAAzC,IAAA,eAAM,EAAC,eAAe,CAAC;;0DAA+C;AACzB;IAA7C,IAAA,eAAM,EAAC,mBAAmB,CAAC;;8DAAuD;8BAPxE,mBAAmB;IAD/B,IAAA,gBAAO,EAAC,qBAAqB,CAAC;;GAClB,mBAAmB,CA4E/B","sourcesContent":["import Container, { Inject, Service } from \"typedi\";\n\nimport { SupplierService } from \"./supplier-service-crud.interface\";\n\nimport { SupplierRepoDB } from \"../../repositories/supplier/supplier-repo-db.interface\";\nimport \"../../repositories/supplier/supplier-repo-db\";\n\nimport { SupplierRepoES } from \"../../repositories/supplier/supplier-repo-es.interface\";\nimport \"../../repositories/supplier/supplier-repo-es\";\nimport { ActionDynamoDB, CognitoUserStatus, parseFilter } from \"@chinggis/core\";\nimport { CONFIG_SUPPLIER } from \"../../controller/supplier/supplier-config\";\nimport { CrudServiceImpl } from \"../../../service/crud.service\";\n\nimport { EntityService } from \"../entity/entity-service.interface\";\nimport \"../entity/entity-service\";\nimport { CommissionService } from \"../commission/commission-service.interface\";\nimport \"../commission/commission-service\";\nimport { Supplier } from \"../../model-shared/supplier.model\";\nimport { Entity, ROrderItem, SOrder } from \"../../model-shared/supplier-portal.model\";\n\n@Service(\"SupplierCrudService\")\nexport class SupplierServiceImpl\n extends CrudServiceImpl<Supplier, SupplierRepoDB, SupplierRepoES>\n implements SupplierService\n{\n // @Inject(\"EOrderService\") private readonly ecomOrderService: EOrderService;\n // @Inject(\"ROrderService\") private readonly rOrderService: ROrderService;\n @Inject(\"EntityService\") private readonly entityService: EntityService;\n @Inject(\"CommissionService\") private readonly commissionService: CommissionService;\n\n //\n constructor() {\n const repoDB: SupplierRepoDB = Container.get(\"SupplierRepoDB\");\n const repoES: SupplierRepoES = Container.get(\"SupplierRepoES\");\n super(repoDB, repoES);\n this.setConfig(CONFIG_SUPPLIER.toObject());\n }\n calculateItemCounts(entities: Entity[]): Promise<Map<Entity, number>> {\n throw new Error(\"Method not implemented.\");\n }\n createDraftSOrder(entities: Map<Entity, number>): SOrder {\n throw new Error(\"Method not implemented.\");\n }\n\n async updateCognitoStatus(username: string, status: CognitoUserStatus): Promise<void> {\n const supplierList = await this.find({\n username,\n });\n const supplier = supplierList.items[0];\n supplier.cognitoStatus = status;\n\n await this.update(supplier as Supplier);\n }\n\n async listNonPartners(retailerUsername: string, page: number, size: number): Promise<Partial<Supplier>[]> {\n try {\n const partnerCommissions = await this.commissionService.findAllByIndex(\"byRetailer\", retailerUsername);\n\n const partnerUsernames = new Set(partnerCommissions.map((c) => c.supplierUsername));\n\n const filter = parseFilter(`size=${size}&page=${page}&accountType=level3,level4`);\n const suppliers = await this.search(filter);\n\n return suppliers.filter((s) => !partnerUsernames.has(s.username));\n } catch (error) {\n console.log(error);\n\n throw error;\n }\n }\n\n updateItems(supplierListModified: Supplier[], strings: string[]) {\n throw new Error(\"Method not implemented.\");\n }\n\n sendOrderToSupplier(sOrder: SOrder): Promise<boolean> {\n throw new Error(\"Method not implemented.\");\n }\n\n async getSupplierAll(): Promise<Supplier[]> {\n const supplierList: Supplier[] = [];\n // while (true) {\n // const response = await this.repoDB.find(parseIndexFilter(\"\", DYNAMO_DB.SUPPLIER.MAP));\n // if (response.items.length > 0) supplierList.push(...(response.items as unknown as Supplier[]));\n //\n // if (!response.lastKey) break;\n // }\n return supplierList;\n }\n\n async saveSalesReportItems(rOrderItems: ROrderItem[]): Promise<boolean> {\n return true;\n }\n\n async processChanges(itemOld: Supplier, itemNew: Supplier, action: ActionDynamoDB, tableName: string): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n}\n"]}
|
|
@@ -2,12 +2,12 @@ import { SupplierRepoDB } from "../../repositories/supplier/supplier-repo-db.int
|
|
|
2
2
|
import "../../repositories/supplier/supplier-repo-db";
|
|
3
3
|
import { SupplierRepoES } from "../../repositories/supplier/supplier-repo-es.interface";
|
|
4
4
|
import "../../repositories/supplier/supplier-repo-es";
|
|
5
|
-
import { SAccount } from "../../model-shared/suppler.model-to-remove";
|
|
6
5
|
import { SupplierServiceStream } from "./supplier-service-stream.interface";
|
|
7
6
|
import { StreamServiceImpl } from "../../../service/stream.service";
|
|
8
|
-
|
|
7
|
+
import { Supplier } from "../../model-shared/supplier.model";
|
|
8
|
+
export declare class SupplierServiceStreamImpl extends StreamServiceImpl<Supplier, SupplierRepoDB, SupplierRepoES> implements SupplierServiceStream {
|
|
9
9
|
constructor();
|
|
10
|
-
processDeletion(oldItem:
|
|
11
|
-
processInsertion(newItem:
|
|
12
|
-
processModification(itemOld:
|
|
10
|
+
processDeletion(oldItem: Supplier, newItem: Supplier, tableName?: string): Promise<any>;
|
|
11
|
+
processInsertion(newItem: Supplier, tableName: string): Promise<any>;
|
|
12
|
+
processModification(itemOld: Supplier, itemNew: Supplier, tableName?: string): Promise<any>;
|
|
13
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SAccount } from "../../model-shared/suppler.model-to-remove";
|
|
2
1
|
import { StreamService } from "../../../service/stream.service.interface";
|
|
3
2
|
import "../../../service/stream.service";
|
|
4
|
-
|
|
3
|
+
import { Supplier } from "../../model-shared/supplier.model";
|
|
4
|
+
export interface SupplierServiceStream extends StreamService<Supplier> {
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supplier-service-stream.interface.js","sourceRoot":"","sources":["../../../../src/_examples/service/supplier/supplier-service-stream.interface.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"supplier-service-stream.interface.js","sourceRoot":"","sources":["../../../../src/_examples/service/supplier/supplier-service-stream.interface.ts"],"names":[],"mappings":";;AACA,2CAAyC","sourcesContent":["import { StreamService } from \"../../../service/stream.service.interface\";\nimport \"../../../service/stream.service\";\nimport { Supplier } from \"../../model-shared/supplier.model\";\n\nexport interface SupplierServiceStream extends StreamService<Supplier> {}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supplier-service-stream.js","sourceRoot":"","sources":["../../../../src/_examples/service/supplier/supplier-service-stream.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAG5C,wDAAsD;AAGtD,wDAAsD;
|
|
1
|
+
{"version":3,"file":"supplier-service-stream.js","sourceRoot":"","sources":["../../../../src/_examples/service/supplier/supplier-service-stream.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAG5C,wDAAsD;AAGtD,wDAAsD;AAEtD,oEAAoE;AAI7D,IAAM,yBAAyB,GAA/B,MAAM,yBACX,SAAQ,kCAA2D;IAGnE,EAAE;IACF;QACE,MAAM,MAAM,GAAmB,gBAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC/D,MAAM,MAAM,GAAmB,gBAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC/D,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC;IAED,eAAe,CAAC,OAAiB,EAAE,OAAiB,EAAE,SAAkB;QACtE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,gBAAgB,CAAC,OAAiB,EAAE,SAAiB;QACnD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,mBAAmB,CAAC,OAAiB,EAAE,OAAiB,EAAE,SAAkB;QAC1E,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF,CAAA;AApBY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,gBAAO,EAAC,uBAAuB,CAAC;;GACpB,yBAAyB,CAoBrC","sourcesContent":["import Container, { Service } from \"typedi\";\n\nimport { SupplierRepoDB } from \"../../repositories/supplier/supplier-repo-db.interface\";\nimport \"../../repositories/supplier/supplier-repo-db\";\n\nimport { SupplierRepoES } from \"../../repositories/supplier/supplier-repo-es.interface\";\nimport \"../../repositories/supplier/supplier-repo-es\";\nimport { SupplierServiceStream } from \"./supplier-service-stream.interface\";\nimport { StreamServiceImpl } from \"../../../service/stream.service\";\nimport { Supplier } from \"../../model-shared/supplier.model\";\n\n@Service(\"SupplierStreamService\")\nexport class SupplierServiceStreamImpl\n extends StreamServiceImpl<Supplier, SupplierRepoDB, SupplierRepoES>\n implements SupplierServiceStream\n{\n //\n constructor() {\n const repoDB: SupplierRepoDB = Container.get(\"SupplierRepoDB\");\n const repoES: SupplierRepoES = Container.get(\"SupplierRepoES\");\n super(repoDB, repoES);\n }\n\n processDeletion(oldItem: Supplier, newItem: Supplier, tableName?: string): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n processInsertion(newItem: Supplier, tableName: string): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n processModification(itemOld: Supplier, itemNew: Supplier, tableName?: string): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.model.js","sourceRoot":"","sources":["../../src/model/filter.model.ts"],"names":[],"mappings":"","sourcesContent":["import { SortOrder } from \"@chinggis/core\";\n\nexport interface Filter extends Record<string, any> {\n page?: number; // The page number for pagination\n size?: number; // The size of items per page\n sortBy?: string; // The field to sort by\n sort?: SortOrder; // Sorting order, either ascending or descending\n searchBy?: string[]; // The field to search in\n searchKeyword?: string; // The keyword to search for\n rangeFilters?: RangeFilter[]; // The field to apply range filtering on\n lastKey?: string;\n indexName?: string;\n indexValue?: string;\n fieldsInclude?: string[];\n fieldsExclude?: string[];\n}\n\nexport type RangeFilter = {\n fieldName: string;\n minValue?: number | Date;\n maxValue?: number | Date;\n minExclude?: boolean;\n maxExclude?: boolean;\n};\n\nexport type NumberRange = {\n gte?: number;\n lte?: number;\n};\n\nexport type DateRange = {\n gte?: string;\n lte?: string;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"filter.model.js","sourceRoot":"","sources":["../../src/model/filter.model.ts"],"names":[],"mappings":"","sourcesContent":["import { SortOrder } from \"@chinggis/core\";\n\nexport interface Filter extends Record<string, any> {\n page?: number; // The page number for pagination\n size?: number; // The size of items per page\n sortBy?: string; // The field to sort by\n sort?: SortOrder; // Sorting order, either ascending or descending\n searchBy?: string[]; // The field to search in\n searchKeyword?: string; // The keyword to search for\n rangeFilters?: RangeFilter[]; // The field to apply range filtering on\n lastKey?: string;\n indexName?: string;\n indexValue?: string;\n fieldsInclude?: string[];\n fieldsExclude?: string[];\n urlRaw?: string;\n}\n\nexport type RangeFilter = {\n fieldName: string;\n minValue?: number | Date;\n maxValue?: number | Date;\n minExclude?: boolean;\n maxExclude?: boolean;\n};\n\nexport type NumberRange = {\n gte?: number;\n lte?: number;\n};\n\nexport type DateRange = {\n gte?: string;\n lte?: string;\n};\n"]}
|
|
@@ -19,6 +19,7 @@ export declare class BaseRepoDBImpl<T extends BaseEntity> implements BaseRepoDB<
|
|
|
19
19
|
findById(id: string): Promise<T>;
|
|
20
20
|
findByIds(ids: string[]): Promise<T[]>;
|
|
21
21
|
find(filter: Filter): Promise<List<Partial<T>>>;
|
|
22
|
+
findAll(filter: Filter | string): Promise<Partial<T>[]>;
|
|
22
23
|
scan(filter: Filter): Promise<List<Partial<T>>>;
|
|
23
24
|
findOne(filter: Filter): Promise<T>;
|
|
24
25
|
findByIndex(indexName: string, value: string): Promise<List<Partial<T>>>;
|
|
@@ -132,6 +132,7 @@ export interface BaseRepoDB<T extends BaseEntity> extends CoreRepo<T> {
|
|
|
132
132
|
getTableName(): string;
|
|
133
133
|
/** Executes a DynamoDB Query strictly (requires indexName and indexValue). */
|
|
134
134
|
find(filter: Filter): Promise<List<Partial<T>>>;
|
|
135
|
+
findAll(filter: Filter): Promise<Partial<T>[]>;
|
|
135
136
|
/** Executes a DynamoDB Scan with optional non-index filters. */
|
|
136
137
|
scan(filter: Filter): Promise<List<Partial<T>>>;
|
|
137
138
|
incrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-db.repo.interface.js","sourceRoot":"","sources":["../../src/repositories/base-db.repo.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { DynamoIndexMap, List } from \"../index\";\nimport { CoreRepo } from \"./base-core.repo.interface\";\n\nimport { BaseEntity, Filter } from \"@chinggis/types\";\n\nexport interface BaseRepoDB<T extends BaseEntity> extends CoreRepo<T> {\n /**\n * Saves an entity by either creating it (if it does not exist) or updating it (if it does).\n *\n * @param entity - The entity to save.\n * @returns The saved entity.\n */\n save(entity: Partial<T>): Promise<T>;\n\n /**\n * Saves multiple entities by either creating or updating each one.\n *\n * @param entities - An array of entities to save.\n * @param isTransactional - Optional flag to indicate if the operation should be transactional.\n * @returns An array of saved entities.\n */\n saveMany(entities: Partial<T>[], isTransactional?: boolean): Promise<Partial<T>[]>;\n\n /**\n * Updates an existing entity.\n * Fails if the entity does not exist.\n *\n * @param entity - The entity with updated data.\n * @returns The updated entity.\n */\n update(entity: Partial<T>): Promise<T>;\n\n /**\n * Updates multiple existing entities.\n *\n * If `fieldNames` is **not provided**, the method performs a **batch update**\n * (e.g., using `BatchWriteItem` in DynamoDB, if supported). In this case, entire entities\n * are replaced or merged as a whole.\n *\n * If `fieldNames` **is provided**, each entity is updated individually, and only the\n * specified fields in `fieldNames` will be modified. This approach avoids overwriting\n * the entire entity and is useful for partial updates.\n *\n * Note:\n * - Entities must already exist in the data store.\n * - Batch update is not truly atomic; some partial updates may occur if errors happen mid-way.\n * - If partial field updates are needed, `fieldNames` must be used.\n *\n * @param entities - An array of entities with partial data to update.\n * @param isTransactional - Optional flag to indicate if the operation should be transactional.\n * @param fields - field names to update\n * @returns An array of successfully updated entities.\n */\n updateMany(entities: Partial<T>[], fields: string[], isTransactional?: boolean): Promise<boolean>;\n\n /**\n * Deletes an entity by its unique identifier.\n *\n * @param id - The ID of the entity to delete.\n * @returns True if the entity was successfully deleted; otherwise, false.\n */\n delete(id: string): Promise<boolean>;\n\n /**\n * Deletes multiple entities by their unique identifiers.\n *\n * @param ids - An array of entity IDs to delete.\n * @returns True if all entities were successfully deleted; otherwise, false.\n */\n deleteMany(ids: string[]): Promise<boolean>;\n\n /**\n * Executes a transactional write operation.\n * DynamoDB typically supports this for atomic operations.\n *\n * @param operations - An array of write operations (create, update, delete) to perform atomically.\n * @returns True if the transaction was successful; otherwise, false.\n */\n transactionWrite(operations: {\n create?: { tableName: string; item: Record<string, any> }[];\n update?: {\n tableName: string;\n key: { id: string };\n updateData: Record<string, any>;\n }[];\n delete?: { tableName: string; key: { id: string } }[];\n }): Promise<boolean>;\n\n /**\n * Executes a transactional read operation.\n * DynamoDB typically supports this for atomic read operations.\n *\n * @param operations - An array of read operations to perform atomically.\n * @returns An array of results from the transaction.\n */\n transactionRead<T>(operations: { id: string; sortKey?: string }[]): Promise<T[]>;\n\n /**\n * (Optional) Executes a transactional write operation.\n * DynamoDB typically only supports this.\n *\n * @param operations - An array of write operations to perform atomically.\n * @returns True if the transaction was successful; otherwise, false.\n */\n transactWrite?(operations: any[]): Promise<boolean>;\n\n /**\n * Deletes one or more fields (attributes) from a DynamoDB item by its partition key.\n *\n * This method uses the `REMOVE` operation of the UpdateExpression to remove specific fields\n * from an existing item in the table. It dynamically constructs the expression and returns\n * the updated item (after removal).\n *\n * @param id - The value of the partition key for the item to update.\n * @param fieldNames - An array of attribute names to be removed from the item.\n * @returns The updated item as a partial object, or `undefined` if no update was performed.\n */\n deleteFields(id: string, fieldNames: string[]): Promise<Partial<T>>;\n\n /**\n * (Optional) Executes a transactional read operation.\n * DynamoDB typically only supports this.\n *\n * @param operations - An array of read operations to perform atomically.\n * @returns An array of results from the transaction.\n */\n transactRead?<TResult = any>(operations: any[]): Promise<TResult[]>;\n\n setIndexMap(value: DynamoIndexMap): boolean;\n\n getIndexMap(): DynamoIndexMap;\n\n setTable(name: string): boolean;\n\n getTableName(): string;\n\n /** Executes a DynamoDB Query strictly (requires indexName and indexValue). */\n find(filter: Filter): Promise<List<Partial<T>>>;\n\n /** Executes a DynamoDB Scan with optional non-index filters. */\n scan(filter: Filter): Promise<List<Partial<T>>>;\n\n incrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;\n decrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base-db.repo.interface.js","sourceRoot":"","sources":["../../src/repositories/base-db.repo.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { DynamoIndexMap, List } from \"../index\";\nimport { CoreRepo } from \"./base-core.repo.interface\";\n\nimport { BaseEntity, Filter } from \"@chinggis/types\";\n\nexport interface BaseRepoDB<T extends BaseEntity> extends CoreRepo<T> {\n /**\n * Saves an entity by either creating it (if it does not exist) or updating it (if it does).\n *\n * @param entity - The entity to save.\n * @returns The saved entity.\n */\n save(entity: Partial<T>): Promise<T>;\n\n /**\n * Saves multiple entities by either creating or updating each one.\n *\n * @param entities - An array of entities to save.\n * @param isTransactional - Optional flag to indicate if the operation should be transactional.\n * @returns An array of saved entities.\n */\n saveMany(entities: Partial<T>[], isTransactional?: boolean): Promise<Partial<T>[]>;\n\n /**\n * Updates an existing entity.\n * Fails if the entity does not exist.\n *\n * @param entity - The entity with updated data.\n * @returns The updated entity.\n */\n update(entity: Partial<T>): Promise<T>;\n\n /**\n * Updates multiple existing entities.\n *\n * If `fieldNames` is **not provided**, the method performs a **batch update**\n * (e.g., using `BatchWriteItem` in DynamoDB, if supported). In this case, entire entities\n * are replaced or merged as a whole.\n *\n * If `fieldNames` **is provided**, each entity is updated individually, and only the\n * specified fields in `fieldNames` will be modified. This approach avoids overwriting\n * the entire entity and is useful for partial updates.\n *\n * Note:\n * - Entities must already exist in the data store.\n * - Batch update is not truly atomic; some partial updates may occur if errors happen mid-way.\n * - If partial field updates are needed, `fieldNames` must be used.\n *\n * @param entities - An array of entities with partial data to update.\n * @param isTransactional - Optional flag to indicate if the operation should be transactional.\n * @param fields - field names to update\n * @returns An array of successfully updated entities.\n */\n updateMany(entities: Partial<T>[], fields: string[], isTransactional?: boolean): Promise<boolean>;\n\n /**\n * Deletes an entity by its unique identifier.\n *\n * @param id - The ID of the entity to delete.\n * @returns True if the entity was successfully deleted; otherwise, false.\n */\n delete(id: string): Promise<boolean>;\n\n /**\n * Deletes multiple entities by their unique identifiers.\n *\n * @param ids - An array of entity IDs to delete.\n * @returns True if all entities were successfully deleted; otherwise, false.\n */\n deleteMany(ids: string[]): Promise<boolean>;\n\n /**\n * Executes a transactional write operation.\n * DynamoDB typically supports this for atomic operations.\n *\n * @param operations - An array of write operations (create, update, delete) to perform atomically.\n * @returns True if the transaction was successful; otherwise, false.\n */\n transactionWrite(operations: {\n create?: { tableName: string; item: Record<string, any> }[];\n update?: {\n tableName: string;\n key: { id: string };\n updateData: Record<string, any>;\n }[];\n delete?: { tableName: string; key: { id: string } }[];\n }): Promise<boolean>;\n\n /**\n * Executes a transactional read operation.\n * DynamoDB typically supports this for atomic read operations.\n *\n * @param operations - An array of read operations to perform atomically.\n * @returns An array of results from the transaction.\n */\n transactionRead<T>(operations: { id: string; sortKey?: string }[]): Promise<T[]>;\n\n /**\n * (Optional) Executes a transactional write operation.\n * DynamoDB typically only supports this.\n *\n * @param operations - An array of write operations to perform atomically.\n * @returns True if the transaction was successful; otherwise, false.\n */\n transactWrite?(operations: any[]): Promise<boolean>;\n\n /**\n * Deletes one or more fields (attributes) from a DynamoDB item by its partition key.\n *\n * This method uses the `REMOVE` operation of the UpdateExpression to remove specific fields\n * from an existing item in the table. It dynamically constructs the expression and returns\n * the updated item (after removal).\n *\n * @param id - The value of the partition key for the item to update.\n * @param fieldNames - An array of attribute names to be removed from the item.\n * @returns The updated item as a partial object, or `undefined` if no update was performed.\n */\n deleteFields(id: string, fieldNames: string[]): Promise<Partial<T>>;\n\n /**\n * (Optional) Executes a transactional read operation.\n * DynamoDB typically only supports this.\n *\n * @param operations - An array of read operations to perform atomically.\n * @returns An array of results from the transaction.\n */\n transactRead?<TResult = any>(operations: any[]): Promise<TResult[]>;\n\n setIndexMap(value: DynamoIndexMap): boolean;\n\n getIndexMap(): DynamoIndexMap;\n\n setTable(name: string): boolean;\n\n getTableName(): string;\n\n /** Executes a DynamoDB Query strictly (requires indexName and indexValue). */\n find(filter: Filter): Promise<List<Partial<T>>>;\n\n findAll(filter: Filter): Promise<Partial<T>[]>;\n\n /** Executes a DynamoDB Scan with optional non-index filters. */\n scan(filter: Filter): Promise<List<Partial<T>>>;\n\n incrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;\n decrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;\n}\n"]}
|
|
@@ -223,6 +223,23 @@ class BaseRepoDBImpl {
|
|
|
223
223
|
const fieldsRemoved = (0, index_1.removeFields)(response?.items, filter.fieldsInclude, filter.fieldsExclude);
|
|
224
224
|
return { items: fieldsRemoved, lastKey: response?.lastKey };
|
|
225
225
|
}
|
|
226
|
+
async findAll(filter) {
|
|
227
|
+
if (typeof filter === "string")
|
|
228
|
+
filter = (0, index_1.parseFilter)(filter);
|
|
229
|
+
const result = [];
|
|
230
|
+
let lastKey = filter?.lastKey;
|
|
231
|
+
do {
|
|
232
|
+
const path = `${filter.urlRaw}&lastKey=${lastKey}`;
|
|
233
|
+
const itemList = await this.find((0, index_1.parseFilter)(path));
|
|
234
|
+
result.push(...itemList.items);
|
|
235
|
+
lastKey = itemList.lastKey;
|
|
236
|
+
if (result.length >= 5000) {
|
|
237
|
+
console.warn("too many items returned, breaking loop.");
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
} while (lastKey && lastKey.trim() !== "");
|
|
241
|
+
return result;
|
|
242
|
+
}
|
|
226
243
|
async scan(filter) {
|
|
227
244
|
if (!filter)
|
|
228
245
|
filter = { size: this.DYNAMO_QUERY_LIMIT };
|