aws-service-stack 0.18.403 → 0.18.405

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/_examples/controller/local-task-controller.d.ts +2 -0
  2. package/dist/_examples/controller/local-task-controller.js +23 -0
  3. package/dist/_examples/controller/local-task-controller.js.map +1 -0
  4. package/dist/_examples/model/user.model.d.ts +1 -0
  5. package/dist/_examples/model/user.model.js +3 -0
  6. package/dist/_examples/model/user.model.js.map +1 -0
  7. package/dist/_examples/service/profile-service.js +8 -9
  8. package/dist/_examples/service/profile-service.js.map +1 -1
  9. package/dist/exception/errors.js +1 -1
  10. package/dist/exception/errors.js.map +1 -1
  11. package/dist/model/dynamodb.model.js.map +1 -1
  12. package/dist/repositories/base-db.repo.d.ts +1 -0
  13. package/dist/repositories/base-db.repo.interface.d.ts +12 -0
  14. package/dist/repositories/base-db.repo.interface.js.map +1 -1
  15. package/dist/repositories/base-db.repo.js +27 -6
  16. package/dist/repositories/base-db.repo.js.map +1 -1
  17. package/dist/repositories/base-es.repo.d.ts +2 -2
  18. package/dist/repositories/base-es.repo.interface.d.ts +2 -2
  19. package/dist/repositories/base-es.repo.interface.js.map +1 -1
  20. package/dist/repositories/base-es.repo.js.map +1 -1
  21. package/dist/service/crud.service.d.ts +1 -0
  22. package/dist/service/crud.service.interface.d.ts +5 -1
  23. package/dist/service/crud.service.interface.js.map +1 -1
  24. package/dist/service/crud.service.js +7 -0
  25. package/dist/service/crud.service.js.map +1 -1
  26. package/dist/utils/dynamodb.utils.d.ts +1 -1
  27. package/dist/utils/dynamodb.utils.js +54 -9
  28. package/dist/utils/dynamodb.utils.js.map +1 -1
  29. package/package.json +10 -6
@@ -0,0 +1,2 @@
1
+ import "reflect-metadata";
2
+ import "../service/profile-service";
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ // handler.ts
7
+ require("reflect-metadata");
8
+ const typedi_1 = __importDefault(require("typedi"));
9
+ require("../service/profile-service");
10
+ class HelperCDI {
11
+ profileService = typedi_1.default.get("ProfileService");
12
+ async run() {
13
+ console.log("running");
14
+ await this.entityChanged();
15
+ console.log("done");
16
+ }
17
+ async entityChanged() {
18
+ const profile = await this.profileService.findById("0f761530-9b92-4706-86ab-8bacf311439f");
19
+ log.info(`profile: ${profile.firstName}`);
20
+ }
21
+ }
22
+ new HelperCDI().run().then((r) => { });
23
+ //# sourceMappingURL=local-task-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-task-controller.js","sourceRoot":"","sources":["../../../src/_examples/controller/local-task-controller.ts"],"names":[],"mappings":";;;;;AAAA,aAAa;AACb,4BAA0B;AAE1B,oDAA+B;AAE/B,sCAAoC;AAEpC,MAAM,SAAS;IACI,cAAc,GAAmB,gBAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAElF,KAAK,CAAC,GAAG;QACP,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAEvB,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAEO,KAAK,CAAC,aAAa;QACzB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,sCAAsC,CAAC,CAAC;QAC3F,GAAG,CAAC,IAAI,CAAC,YAAY,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF;AAED,IAAI,SAAS,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC","sourcesContent":["// handler.ts\nimport \"reflect-metadata\";\n\nimport Container from \"typedi\";\nimport { ProfileService } from \"../service/profile-service.interface\";\nimport \"../service/profile-service\";\n\nclass HelperCDI {\n private readonly profileService: ProfileService = Container.get(\"ProfileService\");\n\n async run() {\n console.log(\"running\");\n\n await this.entityChanged();\n console.log(\"done\");\n }\n\n private async entityChanged() {\n const profile = await this.profileService.findById(\"0f761530-9b92-4706-86ab-8bacf311439f\");\n log.info(`profile: ${profile.firstName}`);\n }\n}\n\nnew HelperCDI().run().then((r) => {});\n"]}
@@ -0,0 +1 @@
1
+ export { User } from "../model-shared/example.model";
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=user.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.model.js","sourceRoot":"","sources":["../../../src/_examples/model/user.model.ts"],"names":[],"mappings":"","sourcesContent":["export { User } from \"../model-shared/example.model\";\n\n"]}
@@ -13,7 +13,6 @@ exports.ProfileServiceImpl = void 0;
13
13
  const typedi_1 = require("typedi");
14
14
  require("./profile-service");
15
15
  require("../repositories/profile/profile-repo-db");
16
- const errors_1 = require("../../exception/errors");
17
16
  const core_1 = require("../../index.js");
18
17
  let ProfileServiceImpl = class ProfileServiceImpl extends core_1.CrudServiceImpl {
19
18
  constructor() {
@@ -22,7 +21,7 @@ let ProfileServiceImpl = class ProfileServiceImpl extends core_1.CrudServiceImpl
22
21
  async deletePhone(profileId) {
23
22
  const profile = await this.findById(profileId);
24
23
  if (!profile.phone) {
25
- throw new errors_1.ErrorHttp({ code: 400, error: "Уг хаяг дээр утасны дугаар байхгүй байна!" });
24
+ throw new core_1.ErrorHttp({ code: 400, error: "Уг хаяг дээр утасны дугаар байхгүй байна!" });
26
25
  }
27
26
  try {
28
27
  if (profile.oldPhoneNumbers) {
@@ -37,14 +36,14 @@ let ProfileServiceImpl = class ProfileServiceImpl extends core_1.CrudServiceImpl
37
36
  return this.save(profile, undefined);
38
37
  }
39
38
  catch (error) {
40
- throw new errors_1.ErrorHttp({ code: 500, error: `Error deleting phone: ${error}` });
39
+ throw new core_1.ErrorHttp({ code: 500, error: `Error deleting phone: ${error}` });
41
40
  }
42
41
  }
43
42
  async mergeById(profileIdSource, profileIdTarget) {
44
43
  const profileSource = await this.findById(profileIdSource);
45
44
  const profileTarget = await this.findById(profileIdTarget);
46
45
  if (!profileSource || !profileTarget) {
47
- throw new errors_1.ErrorHttp({
46
+ throw new core_1.ErrorHttp({
48
47
  code: 400,
49
48
  error: `Тухайн ID дээр профайл олдсонгүй: ${profileSource ? profileIdTarget : profileIdSource}`,
50
49
  });
@@ -54,7 +53,7 @@ let ProfileServiceImpl = class ProfileServiceImpl extends core_1.CrudServiceImpl
54
53
  return profileTarget;
55
54
  }
56
55
  catch (error) {
57
- throw new errors_1.ErrorHttp({ code: 500, error: `Error merging profiles by ID: ${error}` });
56
+ throw new core_1.ErrorHttp({ code: 500, error: `Error merging profiles by ID: ${error}` });
58
57
  }
59
58
  }
60
59
  /**
@@ -63,7 +62,7 @@ let ProfileServiceImpl = class ProfileServiceImpl extends core_1.CrudServiceImpl
63
62
  async updateProfileFields(profileId, fieldsToUpdate) {
64
63
  const profile = await this.findById(profileId);
65
64
  if (!profile) {
66
- throw new errors_1.ErrorHttp({ code: 404, error: `Profile not found: ${profileId}` });
65
+ throw new core_1.ErrorHttp({ code: 404, error: `Profile not found: ${profileId}` });
67
66
  }
68
67
  try {
69
68
  // Update only the specified fields
@@ -71,7 +70,7 @@ let ProfileServiceImpl = class ProfileServiceImpl extends core_1.CrudServiceImpl
71
70
  return this.save(profile, profileId);
72
71
  }
73
72
  catch (error) {
74
- throw new errors_1.ErrorHttp({ code: 500, error: `Error updating profile fields: ${error}` });
73
+ throw new core_1.ErrorHttp({ code: 500, error: `Error updating profile fields: ${error}` });
75
74
  }
76
75
  }
77
76
  // Override findAll to return all profiles
@@ -81,13 +80,13 @@ let ProfileServiceImpl = class ProfileServiceImpl extends core_1.CrudServiceImpl
81
80
  return result.items || [];
82
81
  }
83
82
  catch (error) {
84
- throw new errors_1.ErrorHttp({ code: 500, error: `Error fetching all profiles: ${error}` });
83
+ throw new core_1.ErrorHttp({ code: 500, error: `Error fetching all profiles: ${error}` });
85
84
  }
86
85
  }
87
86
  async mergeProfile(from, to) {
88
87
  // Merge logic - simplified version of the original
89
88
  if (from.cardNumber && to.cardNumber && from.cardNumber !== to.cardNumber) {
90
- throw new errors_1.ErrorHttp({ code: 400, error: "Profiles cannot merge with different card numbers" });
89
+ throw new core_1.ErrorHttp({ code: 400, error: "Profiles cannot merge with different card numbers" });
91
90
  }
92
91
  if (from.cardNumber)
93
92
  to.cardNumber = from.cardNumber;
@@ -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,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,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,IAAI,kBAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,2CAA2C,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,IAAI,CAAC;YACH,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,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MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;CACF,CAAA;AAxIY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,gBAAO,EAAC,gBAAgB,CAAC;;GACb,kBAAkB,CAwI9B","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 const profile = await this.findById(profileId);\n if (!profile.phone) {\n throw new ErrorHttp({ code: 400, error: \"Уг хаяг дээр утасны дугаар байхгүй байна!\" });\n }\n try {\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, undefined);\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 ? profileIdTarget : profileIdSource}`,\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], \"core.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,yCAA4D;AAIrD,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,MAAM,OAAO,GAAG,MAAM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,OAAO,CAAC,QAAQ,EAAE,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;AAxIY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,gBAAO,EAAC,gBAAgB,CAAC;;GACb,kBAAkB,CAwI9B","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 { CrudServiceImpl, ErrorHttp } 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 const profile = await this.findById(profileId);\n if (!profile.phone) {\n throw new ErrorHttp({ code: 400, error: \"Уг хаяг дээр утасны дугаар байхгүй байна!\" });\n }\n try {\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, undefined);\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 ? profileIdTarget : profileIdSource}`,\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], \"core.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"]}
@@ -30,8 +30,8 @@ class ErrorHttp extends Error {
30
30
  constructor(errorCodeMsg, errorMessage, errorData) {
31
31
  super(errorData);
32
32
  this.statusCode = errorCodeMsg.code;
33
- this.message = typeof errorMessage === "object" ? JSON.stringify(errorMessage) : errorMessage;
34
33
  this.error = errorCodeMsg.error;
34
+ this.message = typeof errorMessage === "object" ? JSON.stringify(errorMessage) : errorMessage;
35
35
  this.data = errorData;
36
36
  }
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/exception/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAU,SAAQ,KAAK;IAClC,IAAI,CAAS;IACb,OAAO,CAAS;IAChB,KAAK,CAAM;IACX,YAAY,IAAY,EAAE,OAAe,EAAE,YAAkB;QAC3D,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AATD,8BASC;AAED,MAAa,aAAc,SAAQ,KAAK;IACtC,SAAS,CAAS;IAClB,OAAO,CAAM;IACb,YAAY,SAAiB,EAAE,OAAY,EAAE,YAAkB;QAC7D,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AARD,sCAQC;AAOD,MAAa,SAAU,SAAQ,KAAK;IAClC,UAAU,CAAS;IACnB,KAAK,CAAS;IACd,OAAO,CAAS;IAChB,IAAI,CAAM;IAEV,YAAY,YAA0B,EAAE,YAAkB,EAAE,SAAe;QACzE,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAC9F,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACxB,CAAC;CACF;AAbD,8BAaC;AAED,MAAa,eAAgB,SAAQ,KAAK;IACxC,UAAU,CAAS;IACnB,UAAU,CAAmB;IAC7B,KAAK,CAAM;IACX,OAAO,CAAM;IAEb,YAAY,UAAkB,EAAE,UAA4B,EAAE,YAAkB;QAC9E,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC;IAC9B,CAAC;CACF;AAZD,0CAYC;AAED,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,SAAiB;QAC3B,KAAK,CAAC,GAAG,SAAS,eAAe,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AALD,sDAKC","sourcesContent":["export class ErrorBase extends Error {\n code: number;\n message: string;\n error: any;\n constructor(code: number, message: string, errorContent?: any) {\n super(errorContent);\n this.code = code;\n this.message = message;\n }\n}\n\nexport class ErrorDynamoDB extends Error {\n tableName: string;\n command: any;\n constructor(tableName: string, command: any, errorContent?: any) {\n super(errorContent);\n this.tableName = tableName;\n this.command = command;\n }\n}\n\nexport interface ErrorCodeMsg {\n code: number;\n error: string;\n}\n\nexport class ErrorHttp extends Error {\n statusCode: number;\n error: string;\n message: string;\n data: any;\n\n constructor(errorCodeMsg: ErrorCodeMsg, errorMessage?: any, errorData?: any) {\n super(errorData);\n this.statusCode = errorCodeMsg.code;\n this.message = typeof errorMessage === \"object\" ? JSON.stringify(errorMessage) : errorMessage;\n this.error = errorCodeMsg.error;\n this.data = errorData;\n }\n}\n\nexport class ErrorValidation extends Error {\n entityName: string;\n validation: Map<string, any>;\n error: any;\n content: any;\n\n constructor(entityName: string, validation: Map<string, any>, errorContent?: any) {\n super(errorContent);\n this.entityName = entityName;\n this.validation = validation;\n this.content = errorContent;\n }\n}\n\nexport class MissingParameterError extends Error {\n constructor(paramName: string) {\n super(`${paramName} is required.`);\n this.name = \"MissingParameterError\";\n }\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/exception/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAU,SAAQ,KAAK;IAClC,IAAI,CAAS;IACb,OAAO,CAAS;IAChB,KAAK,CAAM;IACX,YAAY,IAAY,EAAE,OAAe,EAAE,YAAkB;QAC3D,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AATD,8BASC;AAED,MAAa,aAAc,SAAQ,KAAK;IACtC,SAAS,CAAS;IAClB,OAAO,CAAM;IACb,YAAY,SAAiB,EAAE,OAAY,EAAE,YAAkB;QAC7D,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AARD,sCAQC;AAOD,MAAa,SAAU,SAAQ,KAAK;IAClC,UAAU,CAAS;IACnB,KAAK,CAAS;IACd,OAAO,CAAS;IAChB,IAAI,CAAM;IAEV,YAAY,YAA0B,EAAE,YAAkB,EAAE,SAAe;QACzE,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAC9F,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACxB,CAAC;CACF;AAbD,8BAaC;AAED,MAAa,eAAgB,SAAQ,KAAK;IACxC,UAAU,CAAS;IACnB,UAAU,CAAmB;IAC7B,KAAK,CAAM;IACX,OAAO,CAAM;IAEb,YAAY,UAAkB,EAAE,UAA4B,EAAE,YAAkB;QAC9E,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC;IAC9B,CAAC;CACF;AAZD,0CAYC;AAED,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,SAAiB;QAC3B,KAAK,CAAC,GAAG,SAAS,eAAe,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AALD,sDAKC","sourcesContent":["export class ErrorBase extends Error {\n code: number;\n message: string;\n error: any;\n constructor(code: number, message: string, errorContent?: any) {\n super(errorContent);\n this.code = code;\n this.message = message;\n }\n}\n\nexport class ErrorDynamoDB extends Error {\n tableName: string;\n command: any;\n constructor(tableName: string, command: any, errorContent?: any) {\n super(errorContent);\n this.tableName = tableName;\n this.command = command;\n }\n}\n\nexport interface ErrorCodeMsg {\n code: number;\n error: string;\n}\n\nexport class ErrorHttp extends Error {\n statusCode: number;\n error: string;\n message: string;\n data: any;\n\n constructor(errorCodeMsg: ErrorCodeMsg, errorMessage?: any, errorData?: any) {\n super(errorData);\n this.statusCode = errorCodeMsg.code;\n this.error = errorCodeMsg.error;\n this.message = typeof errorMessage === \"object\" ? JSON.stringify(errorMessage) : errorMessage;\n this.data = errorData;\n }\n}\n\nexport class ErrorValidation extends Error {\n entityName: string;\n validation: Map<string, any>;\n error: any;\n content: any;\n\n constructor(entityName: string, validation: Map<string, any>, errorContent?: any) {\n super(errorContent);\n this.entityName = entityName;\n this.validation = validation;\n this.content = errorContent;\n }\n}\n\nexport class MissingParameterError extends Error {\n constructor(paramName: string) {\n super(`${paramName} is required.`);\n this.name = \"MissingParameterError\";\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"dynamodb.model.js","sourceRoot":"","sources":["../../src/model/dynamodb.model.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;AACnB,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAqBD,oFAAoF;AACpF,MAAa,cAAe,SAAQ,GAQnC;IACC,YAAY,GAAW,IAAI,CAAC;IAC5B,YAAY,CAAY;IACxB,UAAU,CAAY;IACtB,SAAS,CAAY;IACrB,aAAa,CAAY;IAEzB,SAAS,CACP,YAAqB,EACrB,YAAuB,EACvB,WAAsB,EACtB,aAAwB,EACxB,SAAoB;QAEpB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA7BD,wCA6BC","sourcesContent":["export enum ActionDynamoDB {\n INSERT = \"INSERT\",\n MODIFY = \"MODIFY\",\n REMOVE = \"REMOVE\",\n}\n\nexport interface DynamoDbFilter {\n keyConditionExpression?: string;\n filterExpression?: string;\n expressionAttributeNames?: { [key: string]: string };\n expressionAttributeValues?: { [key: string]: any };\n scanIndexForward?: boolean; // false for descending order, true for ascending order\n size?: number;\n startAt?: string;\n getAllItems?: boolean;\n}\n\n/*\n * @deprecated use List\n * **/\nexport interface DynamoDbListResponse<T> {\n items: Array<T>;\n lastKey?: string;\n}\n\n/** the map key is indexName, field: indexField, rField: related field names list */\nexport class DynamoIndexMap extends Map<\n string,\n {\n field: string;\n rFields: string[];\n sortKeyField?: string;\n fieldSeparator?: string;\n }\n> {\n partitionKey: string = \"id\";\n numberFields?: string[];\n listFields?: string[];\n mapFields?: string[];\n booleanFields?: string[];\n\n setFields(\n partitionKey?: string,\n numberFields?: string[],\n arrayFields?: string[],\n booleanFields?: string[],\n mapFields?: string[],\n ): this {\n this.partitionKey = partitionKey;\n this.numberFields = numberFields;\n this.listFields = arrayFields;\n this.booleanFields = booleanFields;\n this.mapFields = mapFields;\n return this;\n }\n}\n"]}
1
+ {"version":3,"file":"dynamodb.model.js","sourceRoot":"","sources":["../../src/model/dynamodb.model.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;AACnB,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAsBD,oFAAoF;AACpF,MAAa,cAAe,SAAQ,GAQnC;IACC,YAAY,GAAW,IAAI,CAAC;IAC5B,YAAY,CAAY;IACxB,UAAU,CAAY;IACtB,SAAS,CAAY;IACrB,aAAa,CAAY;IAEzB,SAAS,CACP,YAAqB,EACrB,YAAuB,EACvB,WAAsB,EACtB,aAAwB,EACxB,SAAoB;QAEpB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA7BD,wCA6BC","sourcesContent":["export enum ActionDynamoDB {\n INSERT = \"INSERT\",\n MODIFY = \"MODIFY\",\n REMOVE = \"REMOVE\",\n}\n\n\nexport interface DynamoDbFilter {\n keyConditionExpression?: string;\n filterExpression?: string;\n expressionAttributeNames?: { [key: string]: string };\n expressionAttributeValues?: { [key: string]: any };\n scanIndexForward?: boolean; // false for descending order, true for ascending order\n size?: number;\n startAt?: string;\n getAllItems?: boolean;\n}\n\n/*\n * @deprecated use List\n * **/\nexport interface DynamoDbListResponse<T> {\n items: Array<T>;\n lastKey?: string;\n}\n\n/** the map key is indexName, field: indexField, rField: related field names list */\nexport class DynamoIndexMap extends Map<\n string,\n {\n field: string;\n rFields: string[];\n sortKeyField?: string;\n fieldSeparator?: string;\n }\n> {\n partitionKey: string = \"id\";\n numberFields?: string[];\n listFields?: string[];\n mapFields?: string[];\n booleanFields?: string[];\n\n setFields(\n partitionKey?: string,\n numberFields?: string[],\n arrayFields?: string[],\n booleanFields?: string[],\n mapFields?: string[],\n ): this {\n this.partitionKey = partitionKey;\n this.numberFields = numberFields;\n this.listFields = arrayFields;\n this.booleanFields = booleanFields;\n this.mapFields = mapFields;\n return this;\n }\n}\n"]}
@@ -11,6 +11,7 @@ export declare class BaseRepoDBImpl<T extends BaseEntity> implements BaseRepoDB<
11
11
  decrementValueByField(entityId: string, fieldName: string, value?: number, nestedFieldSeparator?: string): Promise<T>;
12
12
  transactWrite?(operations: any[]): Promise<boolean>;
13
13
  update(entity: Partial<T>): Promise<T>;
14
+ updateFields(entityId: string, fields: string[]): Promise<boolean>;
14
15
  updateMany(entityList: Partial<T>[], fields: string[], isTransactional: boolean): Promise<boolean>;
15
16
  save(entity: Partial<T>): Promise<T>;
16
17
  saveMany(entities: Partial<T>[], isTransactional?: boolean): Promise<Partial<T>[]>;
@@ -25,6 +25,17 @@ export interface BaseRepoDB<T extends BaseEntity> extends CoreRepo<T> {
25
25
  * @returns The updated entity.
26
26
  */
27
27
  update(entity: Partial<T>): Promise<T>;
28
+ /**
29
+ * Updates only selected fields of one entity identified by its partition key.
30
+ * Supports nested paths using dot notation (e.g. `author.name`).
31
+ *
32
+ * This is a convenience wrapper over `updateMany` for single-item updates.
33
+ *
34
+ * @param entityId - Partition key value of the entity.
35
+ * @param fields - Field names that should be updated.
36
+ * @returns True if the update request is accepted; otherwise, false.
37
+ */
38
+ updateFields(entityId: string, fields: string[]): Promise<boolean>;
28
39
  /**
29
40
  * Updates multiple existing entities.
30
41
  *
@@ -35,6 +46,7 @@ export interface BaseRepoDB<T extends BaseEntity> extends CoreRepo<T> {
35
46
  * If `fieldNames` **is provided**, each entity is updated individually, and only the
36
47
  * specified fields in `fieldNames` will be modified. This approach avoids overwriting
37
48
  * the entire entity and is useful for partial updates.
49
+ * Field names support dot notation for nested updates (e.g. `author.name`).
38
50
  *
39
51
  * Note:
40
52
  * - Entities must already exist in the data store.
@@ -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 /**\n * Atomically increments a numeric field. Supports nested map attributes via `nestedFieldSeparator`.\n * Initializes to `0` if the field does not exist. Leaf field must be in `indexMap.numberFields`.\n *\n * @param entityId - Partition key of the item.\n * @param fieldName - Field name or separator-delimited path (e.g. `\"stats.views\"`).\n * @param value - Amount to increment. Defaults to `1`. Must be positive.\n * @param nestedFieldSeparator - If provided, splits `fieldName` into a nested path.\n *\n * @example\n * repo.incrementValueByField(id, \"views\");\n * repo.incrementValueByField(id, \"stats.monthly.views\", 5, \".\");\n */\n incrementValueByField(entityId: string, fieldName: string, value?: number, nestedFieldSeparator?: string): Promise<T>;\n\n /**\n * Atomically decrements a numeric field. Supports nested map attributes via `nestedFieldSeparator`.\n * Initializes to `0` if the field does not exist. Leaf field must be in `indexMap.numberFields`.\n *\n * @param entityId - Partition key of the item.\n * @param fieldName - Field name or separator-delimited path (e.g. `\"stats.stock\"`).\n * @param value - Amount to decrement. Defaults to `-1`. Must be negative.\n * @param nestedFieldSeparator - If provided, splits `fieldName` into a nested path.\n *\n * @example\n * repo.decrementValueByField(id, \"stock\");\n * repo.decrementValueByField(id, \"stats.monthly.stock\", -3, \".\");\n */\n decrementValueByField(entityId: string, fieldName: string, value?: number, nestedFieldSeparator?: string): Promise<T>;\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 only selected fields of one entity identified by its partition key.\n * Supports nested paths using dot notation (e.g. `author.name`).\n *\n * This is a convenience wrapper over `updateMany` for single-item updates.\n *\n * @param entityId - Partition key value of the entity.\n * @param fields - Field names that should be updated.\n * @returns True if the update request is accepted; otherwise, false.\n */\n updateFields(entityId: string, fields: string[]): Promise<boolean>;\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 * Field names support dot notation for nested updates (e.g. `author.name`).\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 /**\n * Atomically increments a numeric field. Supports nested map attributes via `nestedFieldSeparator`.\n * Initializes to `0` if the field does not exist. Leaf field must be in `indexMap.numberFields`.\n *\n * @param entityId - Partition key of the item.\n * @param fieldName - Field name or separator-delimited path (e.g. `\"stats.views\"`).\n * @param value - Amount to increment. Defaults to `1`. Must be positive.\n * @param nestedFieldSeparator - If provided, splits `fieldName` into a nested path.\n *\n * @example\n * repo.incrementValueByField(id, \"views\");\n * repo.incrementValueByField(id, \"stats.monthly.views\", 5, \".\");\n */\n incrementValueByField(entityId: string, fieldName: string, value?: number, nestedFieldSeparator?: string): Promise<T>;\n\n /**\n * Atomically decrements a numeric field. Supports nested map attributes via `nestedFieldSeparator`.\n * Initializes to `0` if the field does not exist. Leaf field must be in `indexMap.numberFields`.\n *\n * @param entityId - Partition key of the item.\n * @param fieldName - Field name or separator-delimited path (e.g. `\"stats.stock\"`).\n * @param value - Amount to decrement. Defaults to `-1`. Must be negative.\n * @param nestedFieldSeparator - If provided, splits `fieldName` into a nested path.\n *\n * @example\n * repo.decrementValueByField(id, \"stock\");\n * repo.decrementValueByField(id, \"stats.monthly.stock\", -3, \".\");\n */\n decrementValueByField(entityId: string, fieldName: string, value?: number, nestedFieldSeparator?: string): Promise<T>;\n}"]}
@@ -112,6 +112,29 @@ class BaseRepoDBImpl {
112
112
  }
113
113
  return (0, util_dynamodb_1.unmarshall)(result.Attributes);
114
114
  }
115
+ async updateFields(entityId, fields) {
116
+ if (!entityId || !fields?.length)
117
+ return false;
118
+ const partitionKey = this._indexMap?.partitionKey;
119
+ if (!partitionKey)
120
+ return false;
121
+ const existing = await this.findById(entityId);
122
+ if (!existing)
123
+ return false;
124
+ const selectedFields = Array.from(new Set([...fields, partitionKey]));
125
+ const entityToUpdate = (0, index_1.removeFields)([existing], selectedFields)?.[0];
126
+ const indexedItem = (0, index_1.addIndexValue)(entityToUpdate, this._indexMap);
127
+ const { UpdateExpression, ExpressionAttributeNames, ExpressionAttributeValues } = (0, index_1.buildUpdateExpressions)(indexedItem, [partitionKey], selectedFields);
128
+ await this.dynamoDb.send(new client_dynamodb_1.UpdateItemCommand({
129
+ TableName: this._tableName,
130
+ Key: (0, util_dynamodb_1.marshall)({ [partitionKey]: entityId }),
131
+ UpdateExpression,
132
+ ExpressionAttributeNames,
133
+ ExpressionAttributeValues,
134
+ ReturnValues: client_dynamodb_1.ReturnValue.ALL_NEW,
135
+ }));
136
+ return true;
137
+ }
115
138
  async updateMany(entityList, fields, isTransactional) {
116
139
  if (isTransactional === undefined || isTransactional === false || isTransactional === null)
117
140
  return await this.updateManyNormal(entityList, fields);
@@ -349,18 +372,16 @@ class BaseRepoDBImpl {
349
372
  return true;
350
373
  }
351
374
  const partitionKey = this._indexMap.partitionKey;
352
- fieldNames.push(partitionKey);
353
- const entityListCleaned = (0, index_1.removeFields)(entityList, fieldNames);
375
+ const selectedFields = Array.from(new Set([...(fieldNames || []), partitionKey]));
376
+ const entityListCleaned = (0, index_1.removeFields)(entityList, selectedFields);
354
377
  const indexedItems = entityListCleaned.map((entity) => {
355
378
  return (0, index_1.addIndexValue)(entity, this._indexMap);
356
379
  });
357
380
  const transactItems = indexedItems
358
381
  .map((item) => {
359
382
  if (!item[partitionKey])
360
- throw new Error(`Item must have an ${partitionKey} field. Entity: ${JSON.stringify(item, null, 2)}, \nupdateFields: ${JSON.stringify(fieldNames)}`);
361
- const { UpdateExpression, ExpressionAttributeNames, ExpressionAttributeValues } = (0, index_1.buildUpdateExpressions)(item, [
362
- partitionKey,
363
- ]);
383
+ throw new Error(`Item must have an ${partitionKey} field. Entity: ${JSON.stringify(item, null, 2)}, \nupdateFields: ${JSON.stringify(selectedFields)}`);
384
+ const { UpdateExpression, ExpressionAttributeNames, ExpressionAttributeValues } = (0, index_1.buildUpdateExpressions)(item, [partitionKey], selectedFields);
364
385
  return {
365
386
  Update: {
366
387
  TableName: this._tableName,
@@ -1 +1 @@
1
- {"version":3,"file":"base-db.repo.js","sourceRoot":"","sources":["../../src/repositories/base-db.repo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAmBkC;AAClC,0DAA8D;AAC9D,oCAmBkB;AAClB,iDAA4C;AAC5C,gDAAoD;AAGpD,IAAA,gBAAO,EAAC,YAAY,CAAC,CAAC;AAEtB,MAAa,cAAc;IACR,QAAQ,GAAqB,gBAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACxE,UAAU,CAAS;IACnB,SAAS,CAAiB;IACjB,kBAAkB,GAAW,EAAE,CAAC;IAEjD,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,UAAoB;QACjD,IAAI,CAAC,EAAE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;QACjD,MAAM,wBAAwB,GAA2B,EAAE,CAAC;QAC5D,MAAM,iBAAiB,GAAa,EAAE,CAAC;QAEvC,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;YAC/B,MAAM,WAAW,GAAG,IAAI,KAAK,EAAE,CAAC;YAChC,wBAAwB,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;YAC9C,iBAAiB,CAAC,IAAI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AC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,sBAAa,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;CACF;AA/lBD,wCA+lBC","sourcesContent":["import {\n AttributeValue,\n BatchGetItemCommand,\n BatchWriteItemCommand,\n BatchWriteItemCommandInput,\n DeleteItemCommand,\n GetItemCommand,\n PutItemCommand,\n QueryCommand,\n QueryCommandInput,\n QueryCommandOutput,\n ReturnValue,\n ScanCommand,\n ScanCommandInput,\n ScanCommandOutput,\n TransactWriteItemsCommand,\n TransactWriteItemsCommandInput,\n UpdateItemCommand,\n UpdateItemCommandInput,\n} from \"@aws-sdk/client-dynamodb\";\nimport { marshall, unmarshall } from \"@aws-sdk/util-dynamodb\";\nimport {\n addIndexValue,\n BaseRepoDB,\n buildDynamoDBFilterConditions,\n buildDynamoDBQueryCommand,\n buildDynamoDBScanCommand,\n buildQueryDB,\n buildUpdateExpressions,\n chunkArray,\n DBClientDynamoDB,\n DynamoIndexMap,\n generateLastEvaluatedKey,\n generateUUID,\n List,\n parseIndexFilter,\n parseLastEvaluatedKey,\n removeFields,\n toBase64,\n unMarshall,\n} from \"../index\";\nimport Container, { Service } from \"typedi\";\nimport { ErrorDynamoDB } from \"../exception/errors\";\nimport { BaseEntity, Filter } from \"@chinggis/types\";\n\nService(\"BaseRepoDB\");\n\nexport class BaseRepoDBImpl<T extends BaseEntity> implements BaseRepoDB<T> {\n private readonly dynamoDb: DBClientDynamoDB = Container.get(\"DBClientDynamoDB\");\n private _tableName: string;\n private _indexMap: DynamoIndexMap;\n private readonly DYNAMO_QUERY_LIMIT: number = 25;\n\n async deleteFields(id: string, fieldNames: string[]): Promise<Partial<T>> {\n if (!id || fieldNames.length === 0) {\n return undefined;\n }\n\n const partitionKey = this._indexMap.partitionKey;\n const expressionAttributeNames: Record<string, string> = {};\n const removeExpressions: string[] = [];\n\n for (const field of fieldNames) {\n const placeholder = `#${field}`;\n expressionAttributeNames[placeholder] = field;\n removeExpressions.push(placeholder);\n }\n\n const updateExpression = `REMOVE ${removeExpressions.join(\", \")}`;\n\n const params = {\n TableName: this._tableName,\n Key: marshall({ [partitionKey]: id }),\n UpdateExpression: updateExpression,\n ExpressionAttributeNames: expressionAttributeNames,\n ReturnValues: \"ALL_NEW\" as const,\n };\n\n const result = await this.dynamoDb.send(new UpdateItemCommand(params));\n if (!result.Attributes) {\n throw new Error(\"No attributes returned from UpdateItem.\");\n }\n\n return unmarshall(result.Attributes) as Partial<T>;\n }\n\n fieldNotExists(fieldName: string, from: number, size: number): Promise<T[]> {\n throw new Error(\"Method not implemented.\");\n }\n\n incrementValueByField(entityId: string, fieldName: string, value?: number, nestedFieldSeparator?: string): Promise<T> {\n if (value < 0) {\n throw new Error(\"Increment operation only supports positive values\");\n }\n const fieldPath = nestedFieldSeparator ? fieldName.split(nestedFieldSeparator) : [fieldName];\n return this.incrementOrDecrementFieldValue(entityId, fieldPath, value ?? 1);\n }\n\n decrementValueByField(entityId: string, fieldName: string, value?: number, nestedFieldSeparator?: string): Promise<T> {\n if (value > 0) {\n throw new ErrorDynamoDB(\n this._tableName,\n `Decrement operation only supports negative values, inputValue: ${value}, for field: ${fieldName}`,\n );\n }\n const fieldPath = nestedFieldSeparator ? fieldName.split(nestedFieldSeparator) : [fieldName];\n return this.incrementOrDecrementFieldValue(entityId, fieldPath, value ?? -1);\n }\n\n transactWrite?(operations: any[]): Promise<boolean> {\n throw new Error(\"Method not implemented.\");\n }\n\n async update(entity: Partial<T>): Promise<T> {\n const partitionKey = this._indexMap.partitionKey;\n\n if (!entity[partitionKey]) {\n throw new ErrorDynamoDB(this._tableName, `Entity must have value in field ${partitionKey}`);\n }\n\n const indexedItem = addIndexValue(entity, this._indexMap);\n\n const { UpdateExpression, ExpressionAttributeNames, ExpressionAttributeValues } = buildUpdateExpressions(\n indexedItem,\n [partitionKey],\n );\n\n const params = {\n TableName: this._tableName,\n Key: marshall({ [partitionKey]: indexedItem[partitionKey] }),\n UpdateExpression,\n ExpressionAttributeNames,\n ExpressionAttributeValues,\n ReturnValues: ReturnValue.ALL_NEW,\n };\n\n const result = await this.dynamoDb.send(new UpdateItemCommand(params));\n if (!result.Attributes) {\n throw new Error(\"No attributes returned from UpdateItem.\");\n }\n return unmarshall(result.Attributes) as T;\n }\n\n async updateMany(entityList: Partial<T>[], fields: string[], isTransactional: boolean): Promise<boolean> {\n if (isTransactional === undefined || isTransactional === false || isTransactional === null)\n return await this.updateManyNormal(entityList, fields);\n\n return await this.updateManyTransactional(entityList, fields);\n }\n\n async save(entity: Partial<T>): Promise<T> {\n const partitionKey = this._indexMap.partitionKey;\n\n if (!entity[partitionKey]) throw new Error(`Entity must have a ${partitionKey} field.`);\n\n const indexedItem = addIndexValue(entity, this._indexMap);\n\n const params = {\n TableName: this._tableName,\n Item: marshall(indexedItem, { removeUndefinedValues: true }),\n };\n try {\n await this.dynamoDb.send(new PutItemCommand(params));\n\n return entity as T;\n } catch (error) {\n console.error(\"Error saving entity:\", error);\n throw new ErrorDynamoDB(this._tableName, params, error);\n }\n }\n\n async saveMany(entities: Partial<T>[], isTransactional?: boolean): Promise<Partial<T>[]> {\n if (isTransactional === undefined || isTransactional === null || isTransactional === false)\n return await this.saveManyNormal(entities);\n return await this.saveManyTransactional(entities);\n }\n\n async delete(id: string): Promise<boolean> {\n const params = {\n TableName: this._tableName,\n Key: marshall({ [this._indexMap.partitionKey]: id }),\n };\n\n try {\n await this.dynamoDb.send(new DeleteItemCommand(params));\n return true;\n } catch (error) {\n console.error(\"Error deleting item:\", error);\n throw new ErrorDynamoDB(this._tableName, params, error);\n }\n }\n\n async deleteMany(ids: string[]): Promise<boolean> {\n if (ids?.length === 0) return false;\n const chunked = chunkArray(ids, 25);\n for (const chunk of chunked) {\n const deleteRequests = chunk.map((id) => {\n return {\n DeleteRequest: {\n Key: marshall({ [this._indexMap.partitionKey]: id }),\n },\n };\n });\n\n const params = {\n RequestItems: {\n [this._tableName]: deleteRequests,\n },\n };\n\n await this.dynamoDb.send(new BatchWriteItemCommand(params));\n }\n return true;\n }\n\n async findById(id: string): Promise<T> {\n const params = {\n TableName: this._tableName,\n Key: marshall({ [this._indexMap.partitionKey]: id }),\n };\n\n try {\n const result = await this.dynamoDb.send(new GetItemCommand(params));\n if (!result.Item) return null;\n return unmarshall(result.Item) as T;\n } catch (error) {\n console.error(\"Error getting item:\", error);\n throw new ErrorDynamoDB(this._tableName, params, error);\n }\n }\n\n async findByIds(ids: string[]): Promise<T[]> {\n let items: T[] = [];\n if (!ids || ids.length === 0) throw new Error(\"Item must have entityIds\");\n\n const chunked = chunkArray(ids, 100);\n for (const chunk of chunked) {\n const keys = chunk.map((id) => ({ [this._indexMap.partitionKey]: { S: id } }));\n const params = {\n RequestItems: {\n [this._tableName]: { Keys: keys },\n },\n };\n\n const response = await this.dynamoDb.send(new BatchGetItemCommand(params));\n\n items = items.concat(response.Responses?.[this._tableName]?.map((item) => unmarshall(item)) as T[]) ?? [];\n }\n return items;\n }\n\n async find(filter: Filter): Promise<List<Partial<T>>> {\n if (!filter) filter = { size: this.DYNAMO_QUERY_LIMIT };\n\n // Enforce Query-only: require indexName & indexValue; otherwise instruct the caller to use scan\n if (!filter.indexName || filter.indexValue === undefined || filter.indexValue === null) {\n throw new ErrorDynamoDB(\n this._tableName,\n \"find in by index\",\n \"find requires indexName and indexValue; use scan() otherwise\",\n );\n }\n\n const dbQuery = buildDynamoDBQueryCommand({\n tableName: this._tableName,\n filter,\n filterCondition: buildDynamoDBFilterConditions(filter, this._indexMap),\n indexMap: this._indexMap,\n });\n\n const response = await this.sendCommandDeep<T>(dbQuery, filter?.lastKey);\n const fieldsRemoved = removeFields(response?.items, filter.fieldsInclude, filter.fieldsExclude);\n return { items: fieldsRemoved, lastKey: response?.lastKey };\n }\n\n async scan(filter: Filter): Promise<List<Partial<T>>> {\n if (!filter) filter = { size: this.DYNAMO_QUERY_LIMIT };\n const expression = buildDynamoDBFilterConditions(filter, this._indexMap);\n const scanInput = buildDynamoDBScanCommand({ tableName: this._tableName, filter, expression });\n const response = await this.sendCommandDeep<T>(scanInput, filter?.lastKey);\n const fieldsRemoved = removeFields(response?.items, filter.fieldsInclude, filter.fieldsExclude);\n return { items: fieldsRemoved, lastKey: response?.lastKey };\n }\n\n async findOne(filter: Filter): Promise<T> {\n const queryInput = buildQueryDB(this._tableName, filter, this._indexMap);\n queryInput.Limit = 1;\n\n const result = await this.dynamoDb.send(new QueryCommand(queryInput));\n\n if (!result.Items || result.Items.length === 0) return null;\n return unmarshall(result.Items[0]) as T;\n }\n\n findByIndex(indexName: string, value: string): Promise<List<Partial<T>>> {\n return this.find(parseIndexFilter(indexName + \"=\" + value, this._indexMap));\n }\n\n async count(filter: Filter): Promise<number> {\n const queryInput = buildQueryDB(this._tableName, filter, this._indexMap);\n queryInput.Select = \"COUNT\";\n\n const result = await this.dynamoDb.send(new QueryCommand(queryInput));\n return result.Count ?? 0;\n }\n\n async exists(id: string): Promise<boolean> {\n const key = marshall({ [this._indexMap.partitionKey]: id });\n\n const result = await this.dynamoDb.send(\n new GetItemCommand({\n TableName: this._tableName,\n Key: key,\n ProjectionExpression: this._indexMap.partitionKey,\n }),\n );\n\n return !!result.Item;\n }\n\n async getRaw(filter: Filter): Promise<any> {\n const queryInput = buildQueryDB(this._tableName, filter, this._indexMap);\n return this.dynamoDb.send(new QueryCommand(queryInput));\n }\n\n async transactionRead<T>(operations: { id: string; sortKey?: string }[]): Promise<T[]> {\n throw new Error(\"Method not implemented.\");\n }\n\n async transactRead?<TResult = any>(operations: any[]): Promise<TResult[]> {\n throw new Error(\"Method not implemented.\");\n }\n\n async 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 const transactItems: any[] = [];\n\n // Create operations\n if (operations.create) {\n for (const { tableName, item } of operations.create) {\n if (!item?.id) {\n item.id = generateUUID();\n }\n transactItems.push({\n Put: {\n TableName: tableName,\n Item: marshall(item, { removeUndefinedValues: true }),\n },\n });\n }\n }\n\n // Update operations\n if (operations.update) {\n for (const { tableName, key, updateData } of operations.update) {\n const { UpdateExpression, ExpressionAttributeNames, ExpressionAttributeValues } = buildUpdateExpressions(\n updateData,\n [\"id\"],\n );\n\n transactItems.push({\n Update: {\n TableName: tableName,\n Key: marshall(key),\n UpdateExpression,\n ExpressionAttributeNames,\n ExpressionAttributeValues,\n },\n });\n }\n }\n\n // Delete operations\n if (operations.delete) {\n for (const { tableName, key } of operations.delete) {\n transactItems.push({\n Delete: {\n TableName: tableName,\n Key: marshall(key),\n },\n });\n }\n }\n\n if (transactItems.length === 0) return false;\n\n // Execute transaction\n try {\n await this.dynamoDb.send(new TransactWriteItemsCommand({ TransactItems: transactItems }));\n return true;\n } catch (error) {\n console.error(\"Transaction failed:\", error);\n throw new ErrorDynamoDB(this._tableName, transactItems, error);\n }\n }\n\n getTableName() {\n return this._tableName;\n }\n\n setIndexMap(indexMap: DynamoIndexMap): boolean {\n this._indexMap = indexMap;\n return true;\n }\n\n setTable(tableName: string): boolean {\n this._tableName = tableName;\n return true;\n }\n\n getIndexMap(): DynamoIndexMap {\n return this._indexMap;\n }\n\n private async updateManyNormal(entityList: Partial<T>[], fieldNames: string[]): Promise<boolean> {\n return this.updateManyTransactional(entityList, fieldNames); // todo implement normal updateMany\n }\n\n private async updateManyTransactional(entityList: Partial<T>[], fieldNames: string[]): Promise<boolean> {\n if (entityList.length === 0) return false;\n\n if (!fieldNames || fieldNames.length === 0) {\n await this.saveMany(entityList, true);\n return true;\n }\n\n const partitionKey = this._indexMap.partitionKey;\n fieldNames.push(partitionKey);\n const entityListCleaned = removeFields(entityList, fieldNames);\n\n const indexedItems = entityListCleaned.map((entity) => {\n return addIndexValue(entity, this._indexMap);\n });\n\n const transactItems = indexedItems\n .map((item) => {\n if (!item[partitionKey])\n throw new Error(\n `Item must have an ${partitionKey} field. Entity: ${JSON.stringify(item, null, 2)}, \\nupdateFields: ${JSON.stringify(fieldNames)}`,\n );\n\n const { UpdateExpression, ExpressionAttributeNames, ExpressionAttributeValues } = buildUpdateExpressions(item, [\n partitionKey,\n ]);\n\n return {\n Update: {\n TableName: this._tableName,\n Key: { [partitionKey]: { S: item[partitionKey] } }, // id-г шууд key болгож дамжуулах\n UpdateExpression,\n ExpressionAttributeValues,\n ExpressionAttributeNames,\n },\n };\n })\n .filter(Boolean) as any[]; // filter(Boolean) нь хоосон утгуудыг арилгана.\n\n if (transactItems.length < 1) return false;\n\n const chunkedItems = chunkArray(transactItems, 25); // 25-аас дээш бол багцлах\n\n for (const chunk of chunkedItems) await this.dynamoDb.send(new TransactWriteItemsCommand({ TransactItems: chunk }));\n\n return true;\n }\n\n private async saveManyNormal(entities: Partial<T>[]): Promise<Partial<T>[]> {\n if (entities.length === 0) throw new Error(\"Cannot save an empty array of entities.\");\n\n const allSavedEntities: Partial<T>[] = [];\n\n for (const chunk of chunkArray(entities, 25)) {\n chunk.forEach((item) => addIndexValue(item, this._indexMap));\n const putRequests = chunk.map((entity) => ({\n PutRequest: { Item: marshall(entity, { removeUndefinedValues: true }) },\n }));\n\n const params: BatchWriteItemCommandInput = { RequestItems: { [this._tableName]: putRequests } };\n\n const result = await this.dynamoDb.send(new BatchWriteItemCommand(params));\n\n if (result.UnprocessedItems && Object.keys(result.UnprocessedItems).length > 0)\n console.warn(\"⚠️ Some items were unprocessed and need to be retried.\", result.UnprocessedItems);\n\n allSavedEntities.push(...chunk);\n }\n\n return allSavedEntities;\n }\n\n private async saveManyTransactional(entities: Partial<T>[]): Promise<Partial<T>[]> {\n if (entities.length === 0) throw new Error(\"Cannot save an empty array of entities.\");\n\n const allSavedEntities: Partial<T>[] = [];\n\n // DynamoDB TransactWrite limit: 25 actions per request\n for (const chunk of chunkArray(entities, 25)) {\n chunk.forEach((item) => addIndexValue(item, this._indexMap));\n\n const transactItems = chunk.map((entity) => ({\n Put: {\n TableName: this._tableName,\n Item: marshall(entity, { removeUndefinedValues: true }),\n },\n }));\n\n const params: TransactWriteItemsCommandInput = {\n TransactItems: transactItems,\n };\n\n try {\n await this.dynamoDb.send(new TransactWriteItemsCommand(params));\n allSavedEntities.push(...chunk);\n } catch (err) {\n console.error(\"❌ Transaction failed:\", err);\n throw err; // Re-throw so the caller knows it failed\n }\n }\n\n return allSavedEntities;\n }\n\n private async incrementOrDecrementFieldValue(entityId: string, fieldPath: string[], delta: number): Promise<T> {\n const partitionKey = this._indexMap.partitionKey;\n const leafField = fieldPath[fieldPath.length - 1];\n\n if (!this?._indexMap?.numberFields?.includes(leafField)) {\n throw new Error(`${leafField} field not found in indexMap.numberFields`);\n }\n\n const expressionAttributeNames: Record<string, string> = {};\n fieldPath.forEach((segment, i) => {\n expressionAttributeNames[`#f${i}`] = segment;\n });\n\n const pathExpr = fieldPath.map((_, i) => `#f${i}`).join(\".\");\n\n const params: UpdateItemCommandInput = {\n TableName: this._tableName,\n Key: marshall({ [partitionKey]: entityId }),\n UpdateExpression: `SET ${pathExpr} = if_not_exists(${pathExpr}, :start) + :delta`,\n ExpressionAttributeNames: expressionAttributeNames,\n ExpressionAttributeValues: {\n \":delta\": marshall(delta),\n \":start\": marshall(0),\n },\n ReturnValues: ReturnValue.ALL_NEW,\n };\n\n const result = await this.dynamoDb.send(new UpdateItemCommand(params));\n\n return unmarshall(result.Attributes) as T;\n }\n\n /**\n * Executes a DynamoDB Query or Scan and returns up to the desired number of items,\n * respecting DynamoDB's 1MB limit (pagination continuation via LastEvaluatedKey).\n * @param queryInput - QueryCommandInput or ScanCommandInput\n * @param startKey - Optional start key for pagination\n */\n\n private async sendCommandDeep<T>(\n queryInput: QueryCommandInput | ScanCommandInput,\n startKey?: string | Record<string, any>,\n ): Promise<List<T>> {\n const result: List<T> = { items: [] };\n\n const size: number = (queryInput as any)?.Limit ?? 10;\n\n let lastEvaluatedKey: Record<string, AttributeValue>;\n\n if (startKey) {\n lastEvaluatedKey =\n typeof startKey === \"string\"\n ? parseLastEvaluatedKey<Record<string, AttributeValue>>(startKey) // will throw if invalid\n : startKey;\n }\n\n do {\n const response: QueryCommandOutput = await this.sendCommand({\n ...queryInput,\n ExclusiveStartKey: lastEvaluatedKey,\n });\n\n // no more items to fetch\n if (response.LastEvaluatedKey == undefined) {\n result?.items.push(...unMarshall<T>(response.Items));\n result.lastKey = undefined;\n return result;\n }\n\n if (response?.Items.length === 0 && response.LastEvaluatedKey) {\n lastEvaluatedKey = response.LastEvaluatedKey;\n continue;\n }\n\n if (result?.items.length + response?.Items.length <= size) {\n result?.items.push(...unMarshall<T>(response.Items));\n lastEvaluatedKey = response.LastEvaluatedKey;\n if (result?.items.length === size) {\n result.lastKey = toBase64(JSON.stringify(response.LastEvaluatedKey));\n return result;\n }\n continue;\n }\n\n const elementIndex = size - result?.items.length - 1;\n result?.items.push(...unMarshall<T>(response.Items.slice(0, elementIndex)));\n\n const index = this._indexMap.get(queryInput.IndexName);\n result.lastKey = generateLastEvaluatedKey(response.Items[elementIndex], index?.field, index?.sortKeyField);\n break;\n } while (lastEvaluatedKey);\n\n return result;\n }\n\n /**\n * Executes a single Query/Scan and returns the result as-is.\n * Supports pagination via ExclusiveStartKey.\n */\n private async sendCommand(\n commandInput: QueryCommandInput | ScanCommandInput,\n ): Promise<ScanCommandOutput | QueryCommandOutput> {\n commandInput.TableName = this._tableName;\n\n // if (startKey) {\n // commandInput.ExclusiveStartKey = typeof startKey === \"string\" ? parseLastEvaluatedKey(startKey) : startKey;\n // }\n\n if (!commandInput.Limit) {\n commandInput.Limit = this.DYNAMO_QUERY_LIMIT;\n }\n\n const isQuery = \"KeyConditionExpression\" in commandInput;\n const command = isQuery ? new QueryCommand(commandInput) : new ScanCommand(commandInput);\n\n log.debug(\"Sending command:\", commandInput);\n\n if (!this.dynamoDb) throw new ErrorDynamoDB(this._tableName, commandInput, \"dynamoDB client not initialized\");\n\n try {\n return await this.dynamoDb.send(command);\n } catch (error) {\n throw new ErrorDynamoDB(this._tableName, commandInput, error);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"base-db.repo.js","sourceRoot":"","sources":["../../src/repositories/base-db.repo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAmBkC;AAClC,0DAA8D;AAC9D,oCAmBkB;AAClB,iDAA4C;AAC5C,gDAAoD;AAGpD,IAAA,gBAAO,EAAC,YAAY,CAAC,CAAC;AAEtB,MAAa,cAAc;IACR,QAAQ,GAAqB,gBAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACxE,UAAU,CAAS;IACnB,SAAS,CAAiB;IACjB,kBAAkB,GAAW,EAAE,CAAC;IAEjD,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,UAAoB;QACjD,IAAI,CAAC,EAAE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;QACjD,MAAM,wBAAwB,GAA2B,EAAE,CAAC;QAC5D,MAAM,iBAAiB,GAAa,EAAE,CAAC;QAEvC,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;YAC/B,MAAM,WAAW,GAAG,IAAI,KAAK,EAAE,CAAC;YAChC,wBAAwB,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;YAC9C,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,gBAAgB,GAAG,UAAU,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAElE,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,GAAG,EAAE,IAAA,wBAAQ,EAAC,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC;YACrC,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,\n BatchWriteItemCommand,\n BatchWriteItemCommandInput,\n DeleteItemCommand,\n GetItemCommand,\n PutItemCommand,\n QueryCommand,\n QueryCommandInput,\n QueryCommandOutput,\n ReturnValue,\n ScanCommand,\n ScanCommandInput,\n ScanCommandOutput,\n TransactWriteItemsCommand,\n TransactWriteItemsCommandInput,\n UpdateItemCommand,\n UpdateItemCommandInput,\n} from \"@aws-sdk/client-dynamodb\";\nimport { marshall, unmarshall } from \"@aws-sdk/util-dynamodb\";\nimport {\n addIndexValue,\n BaseRepoDB,\n buildDynamoDBFilterConditions,\n buildDynamoDBQueryCommand,\n buildDynamoDBScanCommand,\n buildQueryDB,\n buildUpdateExpressions,\n chunkArray,\n DBClientDynamoDB,\n DynamoIndexMap,\n generateLastEvaluatedKey,\n generateUUID,\n List,\n parseIndexFilter,\n parseLastEvaluatedKey,\n removeFields,\n toBase64,\n unMarshall,\n} from \"../index\";\nimport Container, { Service } from \"typedi\";\nimport { ErrorDynamoDB } from \"../exception/errors\";\nimport { BaseEntity, Filter } from \"@chinggis/types\";\n\nService(\"BaseRepoDB\");\n\nexport class BaseRepoDBImpl<T extends BaseEntity> implements BaseRepoDB<T> {\n private readonly dynamoDb: DBClientDynamoDB = Container.get(\"DBClientDynamoDB\");\n private _tableName: string;\n private _indexMap: DynamoIndexMap;\n private readonly DYNAMO_QUERY_LIMIT: number = 25;\n\n async deleteFields(id: string, fieldNames: string[]): Promise<Partial<T>> {\n if (!id || fieldNames.length === 0) {\n return undefined;\n }\n\n const partitionKey = this._indexMap.partitionKey;\n const expressionAttributeNames: Record<string, string> = {};\n const removeExpressions: string[] = [];\n\n for (const field of fieldNames) {\n const placeholder = `#${field}`;\n expressionAttributeNames[placeholder] = field;\n removeExpressions.push(placeholder);\n }\n\n const updateExpression = `REMOVE ${removeExpressions.join(\", \")}`;\n\n const params = {\n TableName: this._tableName,\n Key: marshall({ [partitionKey]: id }),\n UpdateExpression: updateExpression,\n ExpressionAttributeNames: expressionAttributeNames,\n ReturnValues: \"ALL_NEW\" as const,\n };\n\n const result = await this.dynamoDb.send(new UpdateItemCommand(params));\n if (!result.Attributes) {\n throw new Error(\"No attributes returned from UpdateItem.\");\n }\n\n return unmarshall(result.Attributes) as Partial<T>;\n }\n\n fieldNotExists(fieldName: string, from: number, size: number): Promise<T[]> {\n throw new Error(\"Method not implemented.\");\n }\n\n incrementValueByField(entityId: string, fieldName: string, value?: number, nestedFieldSeparator?: string): Promise<T> {\n if (value < 0) {\n throw new Error(\"Increment operation only supports positive values\");\n }\n const fieldPath = nestedFieldSeparator ? fieldName.split(nestedFieldSeparator) : [fieldName];\n return this.incrementOrDecrementFieldValue(entityId, fieldPath, value ?? 1);\n }\n\n decrementValueByField(entityId: string, fieldName: string, value?: number, nestedFieldSeparator?: string): Promise<T> {\n if (value > 0) {\n throw new ErrorDynamoDB(\n this._tableName,\n `Decrement operation only supports negative values, inputValue: ${value}, for field: ${fieldName}`,\n );\n }\n const fieldPath = nestedFieldSeparator ? fieldName.split(nestedFieldSeparator) : [fieldName];\n return this.incrementOrDecrementFieldValue(entityId, fieldPath, value ?? -1);\n }\n\n transactWrite?(operations: any[]): Promise<boolean> {\n throw new Error(\"Method not implemented.\");\n }\n\n async update(entity: Partial<T>): Promise<T> {\n const partitionKey = this._indexMap.partitionKey;\n\n if (!entity[partitionKey]) {\n throw new ErrorDynamoDB(this._tableName, `Entity must have value in field ${partitionKey}`);\n }\n\n const indexedItem = addIndexValue(entity, this._indexMap);\n\n const { UpdateExpression, ExpressionAttributeNames, ExpressionAttributeValues } = buildUpdateExpressions(\n indexedItem,\n [partitionKey],\n );\n\n const params = {\n TableName: this._tableName,\n Key: marshall({ [partitionKey]: indexedItem[partitionKey] }),\n UpdateExpression,\n ExpressionAttributeNames,\n ExpressionAttributeValues,\n ReturnValues: ReturnValue.ALL_NEW,\n };\n\n const result = await this.dynamoDb.send(new UpdateItemCommand(params));\n if (!result.Attributes) {\n throw new Error(\"No attributes returned from UpdateItem.\");\n }\n return unmarshall(result.Attributes) as T;\n }\n\n async updateFields(entityId: string, fields: string[]): Promise<boolean> {\n if (!entityId || !fields?.length) return false;\n\n const partitionKey = this._indexMap?.partitionKey;\n if (!partitionKey) return false;\n\n const existing = await this.findById(entityId);\n if (!existing) return false;\n\n const selectedFields = Array.from(new Set([...fields, partitionKey]));\n const entityToUpdate = removeFields([existing], selectedFields)?.[0] as Partial<T>;\n\n const indexedItem = addIndexValue(entityToUpdate, this._indexMap);\n const { UpdateExpression, ExpressionAttributeNames, ExpressionAttributeValues } = buildUpdateExpressions(\n indexedItem,\n [partitionKey],\n selectedFields,\n );\n\n await this.dynamoDb.send(\n new UpdateItemCommand({\n TableName: this._tableName,\n Key: marshall({ [partitionKey]: entityId }),\n UpdateExpression,\n ExpressionAttributeNames,\n ExpressionAttributeValues,\n ReturnValues: ReturnValue.ALL_NEW,\n }),\n );\n\n return true;\n }\n\n async updateMany(entityList: Partial<T>[], fields: string[], isTransactional: boolean): Promise<boolean> {\n if (isTransactional === undefined || isTransactional === false || isTransactional === null)\n return await this.updateManyNormal(entityList, fields);\n\n return await this.updateManyTransactional(entityList, fields);\n }\n\n async save(entity: Partial<T>): Promise<T> {\n const partitionKey = this._indexMap.partitionKey;\n\n if (!entity[partitionKey]) throw new Error(`Entity must have a ${partitionKey} field.`);\n\n const indexedItem = addIndexValue(entity, this._indexMap);\n\n const params = {\n TableName: this._tableName,\n Item: marshall(indexedItem, { removeUndefinedValues: true }),\n };\n try {\n await this.dynamoDb.send(new PutItemCommand(params));\n\n return entity as T;\n } catch (error) {\n console.error(\"Error saving entity:\", error);\n throw new ErrorDynamoDB(this._tableName, params, error);\n }\n }\n\n async saveMany(entities: Partial<T>[], isTransactional?: boolean): Promise<Partial<T>[]> {\n if (isTransactional === undefined || isTransactional === null || isTransactional === false)\n return await this.saveManyNormal(entities);\n return await this.saveManyTransactional(entities);\n }\n\n async delete(id: string): Promise<boolean> {\n const params = {\n TableName: this._tableName,\n Key: marshall({ [this._indexMap.partitionKey]: id }),\n };\n\n try {\n await this.dynamoDb.send(new DeleteItemCommand(params));\n return true;\n } catch (error) {\n console.error(\"Error deleting item:\", error);\n throw new ErrorDynamoDB(this._tableName, params, error);\n }\n }\n\n async deleteMany(ids: string[]): Promise<boolean> {\n if (ids?.length === 0) return false;\n const chunked = chunkArray(ids, 25);\n for (const chunk of chunked) {\n const deleteRequests = chunk.map((id) => {\n return {\n DeleteRequest: {\n Key: marshall({ [this._indexMap.partitionKey]: id }),\n },\n };\n });\n\n const params = {\n RequestItems: {\n [this._tableName]: deleteRequests,\n },\n };\n\n await this.dynamoDb.send(new BatchWriteItemCommand(params));\n }\n return true;\n }\n\n async findById(id: string): Promise<T> {\n const params = {\n TableName: this._tableName,\n Key: marshall({ [this._indexMap.partitionKey]: id }),\n };\n\n try {\n const result = await this.dynamoDb.send(new GetItemCommand(params));\n if (!result.Item) return null;\n return unmarshall(result.Item) as T;\n } catch (error) {\n console.error(\"Error getting item:\", error);\n throw new ErrorDynamoDB(this._tableName, params, error);\n }\n }\n\n async findByIds(ids: string[]): Promise<T[]> {\n let items: T[] = [];\n if (!ids || ids.length === 0) throw new Error(\"Item must have entityIds\");\n\n const chunked = chunkArray(ids, 100);\n for (const chunk of chunked) {\n const keys = chunk.map((id) => ({ [this._indexMap.partitionKey]: { S: id } }));\n const params = {\n RequestItems: {\n [this._tableName]: { Keys: keys },\n },\n };\n\n const response = await this.dynamoDb.send(new BatchGetItemCommand(params));\n\n items = items.concat(response.Responses?.[this._tableName]?.map((item) => unmarshall(item)) as T[]) ?? [];\n }\n return items;\n }\n\n async find(filter: Filter): Promise<List<Partial<T>>> {\n if (!filter) filter = { size: this.DYNAMO_QUERY_LIMIT };\n\n // Enforce Query-only: require indexName & indexValue; otherwise instruct the caller to use scan\n if (!filter.indexName || filter.indexValue === undefined || filter.indexValue === null) {\n throw new ErrorDynamoDB(\n this._tableName,\n \"find in by index\",\n \"find requires indexName and indexValue; use scan() otherwise\",\n );\n }\n\n const dbQuery = buildDynamoDBQueryCommand({\n tableName: this._tableName,\n filter,\n filterCondition: buildDynamoDBFilterConditions(filter, this._indexMap),\n indexMap: this._indexMap,\n });\n\n const response = await this.sendCommandDeep<T>(dbQuery, filter?.lastKey);\n const fieldsRemoved = removeFields(response?.items, filter.fieldsInclude, filter.fieldsExclude);\n return { items: fieldsRemoved, lastKey: response?.lastKey };\n }\n\n async scan(filter: Filter): Promise<List<Partial<T>>> {\n if (!filter) filter = { size: this.DYNAMO_QUERY_LIMIT };\n const expression = buildDynamoDBFilterConditions(filter, this._indexMap);\n const scanInput = buildDynamoDBScanCommand({ tableName: this._tableName, filter, expression });\n const response = await this.sendCommandDeep<T>(scanInput, filter?.lastKey);\n const fieldsRemoved = removeFields(response?.items, filter.fieldsInclude, filter.fieldsExclude);\n return { items: fieldsRemoved, lastKey: response?.lastKey };\n }\n\n async findOne(filter: Filter): Promise<T> {\n const queryInput = buildQueryDB(this._tableName, filter, this._indexMap);\n queryInput.Limit = 1;\n\n const result = await this.dynamoDb.send(new QueryCommand(queryInput));\n\n if (!result.Items || result.Items.length === 0) return null;\n return unmarshall(result.Items[0]) as T;\n }\n\n findByIndex(indexName: string, value: string): Promise<List<Partial<T>>> {\n return this.find(parseIndexFilter(indexName + \"=\" + value, this._indexMap));\n }\n\n async count(filter: Filter): Promise<number> {\n const queryInput = buildQueryDB(this._tableName, filter, this._indexMap);\n queryInput.Select = \"COUNT\";\n\n const result = await this.dynamoDb.send(new QueryCommand(queryInput));\n return result.Count ?? 0;\n }\n\n async exists(id: string): Promise<boolean> {\n const key = marshall({ [this._indexMap.partitionKey]: id });\n\n const result = await this.dynamoDb.send(\n new GetItemCommand({\n TableName: this._tableName,\n Key: key,\n ProjectionExpression: this._indexMap.partitionKey,\n }),\n );\n\n return !!result.Item;\n }\n\n async getRaw(filter: Filter): Promise<any> {\n const queryInput = buildQueryDB(this._tableName, filter, this._indexMap);\n return this.dynamoDb.send(new QueryCommand(queryInput));\n }\n\n async transactionRead<T>(operations: { id: string; sortKey?: string }[]): Promise<T[]> {\n throw new Error(\"Method not implemented.\");\n }\n\n async transactRead?<TResult = any>(operations: any[]): Promise<TResult[]> {\n throw new Error(\"Method not implemented.\");\n }\n\n async 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 const transactItems: any[] = [];\n\n // Create operations\n if (operations.create) {\n for (const { tableName, item } of operations.create) {\n if (!item?.id) {\n item.id = generateUUID();\n }\n transactItems.push({\n Put: {\n TableName: tableName,\n Item: marshall(item, { removeUndefinedValues: true }),\n },\n });\n }\n }\n\n // Update operations\n if (operations.update) {\n for (const { tableName, key, updateData } of operations.update) {\n const { UpdateExpression, ExpressionAttributeNames, ExpressionAttributeValues } = buildUpdateExpressions(\n updateData,\n [\"id\"],\n );\n\n transactItems.push({\n Update: {\n TableName: tableName,\n Key: marshall(key),\n UpdateExpression,\n ExpressionAttributeNames,\n ExpressionAttributeValues,\n },\n });\n }\n }\n\n // Delete operations\n if (operations.delete) {\n for (const { tableName, key } of operations.delete) {\n transactItems.push({\n Delete: {\n TableName: tableName,\n Key: marshall(key),\n },\n });\n }\n }\n\n if (transactItems.length === 0) return false;\n\n // Execute transaction\n try {\n await this.dynamoDb.send(new TransactWriteItemsCommand({ TransactItems: transactItems }));\n return true;\n } catch (error) {\n console.error(\"Transaction failed:\", error);\n throw new ErrorDynamoDB(this._tableName, transactItems, error);\n }\n }\n\n getTableName() {\n return this._tableName;\n }\n\n setIndexMap(indexMap: DynamoIndexMap): boolean {\n this._indexMap = indexMap;\n return true;\n }\n\n setTable(tableName: string): boolean {\n this._tableName = tableName;\n return true;\n }\n\n getIndexMap(): DynamoIndexMap {\n return this._indexMap;\n }\n\n private async updateManyNormal(entityList: Partial<T>[], fieldNames: string[]): Promise<boolean> {\n return this.updateManyTransactional(entityList, fieldNames); // todo implement normal updateMany\n }\n\n private async updateManyTransactional(entityList: Partial<T>[], fieldNames: string[]): Promise<boolean> {\n if (entityList.length === 0) return false;\n\n if (!fieldNames || fieldNames.length === 0) {\n await this.saveMany(entityList, true);\n return true;\n }\n\n const partitionKey = this._indexMap.partitionKey;\n const selectedFields = Array.from(new Set([...(fieldNames || []), partitionKey]));\n const entityListCleaned = removeFields(entityList, selectedFields);\n\n const indexedItems = entityListCleaned.map((entity) => {\n return addIndexValue(entity, this._indexMap);\n });\n\n const transactItems = indexedItems\n .map((item) => {\n if (!item[partitionKey])\n throw new Error(\n `Item must have an ${partitionKey} field. Entity: ${JSON.stringify(item, null, 2)}, \\nupdateFields: ${JSON.stringify(selectedFields)}`,\n );\n\n const { UpdateExpression, ExpressionAttributeNames, ExpressionAttributeValues } = buildUpdateExpressions(\n item,\n [partitionKey],\n selectedFields,\n );\n\n return {\n Update: {\n TableName: this._tableName,\n Key: { [partitionKey]: { S: item[partitionKey] } }, // id-г шууд key болгож дамжуулах\n UpdateExpression,\n ExpressionAttributeValues,\n ExpressionAttributeNames,\n },\n };\n })\n .filter(Boolean) as any[]; // filter(Boolean) нь хоосон утгуудыг арилгана.\n\n if (transactItems.length < 1) return false;\n\n const chunkedItems = chunkArray(transactItems, 25); // 25-аас дээш бол багцлах\n\n for (const chunk of chunkedItems) await this.dynamoDb.send(new TransactWriteItemsCommand({ TransactItems: chunk }));\n\n return true;\n }\n\n private async saveManyNormal(entities: Partial<T>[]): Promise<Partial<T>[]> {\n if (entities.length === 0) throw new Error(\"Cannot save an empty array of entities.\");\n\n const allSavedEntities: Partial<T>[] = [];\n\n for (const chunk of chunkArray(entities, 25)) {\n chunk.forEach((item) => addIndexValue(item, this._indexMap));\n const putRequests = chunk.map((entity) => ({\n PutRequest: { Item: marshall(entity, { removeUndefinedValues: true }) },\n }));\n\n const params: BatchWriteItemCommandInput = { RequestItems: { [this._tableName]: putRequests } };\n\n const result = await this.dynamoDb.send(new BatchWriteItemCommand(params));\n\n if (result.UnprocessedItems && Object.keys(result.UnprocessedItems).length > 0)\n console.warn(\"⚠️ Some items were unprocessed and need to be retried.\", result.UnprocessedItems);\n\n allSavedEntities.push(...chunk);\n }\n\n return allSavedEntities;\n }\n\n private async saveManyTransactional(entities: Partial<T>[]): Promise<Partial<T>[]> {\n if (entities.length === 0) throw new Error(\"Cannot save an empty array of entities.\");\n\n const allSavedEntities: Partial<T>[] = [];\n\n // DynamoDB TransactWrite limit: 25 actions per request\n for (const chunk of chunkArray(entities, 25)) {\n chunk.forEach((item) => addIndexValue(item, this._indexMap));\n\n const transactItems = chunk.map((entity) => ({\n Put: {\n TableName: this._tableName,\n Item: marshall(entity, { removeUndefinedValues: true }),\n },\n }));\n\n const params: TransactWriteItemsCommandInput = {\n TransactItems: transactItems,\n };\n\n try {\n await this.dynamoDb.send(new TransactWriteItemsCommand(params));\n allSavedEntities.push(...chunk);\n } catch (err) {\n console.error(\"❌ Transaction failed:\", err);\n throw err; // Re-throw so the caller knows it failed\n }\n }\n\n return allSavedEntities;\n }\n\n private async incrementOrDecrementFieldValue(entityId: string, fieldPath: string[], delta: number): Promise<T> {\n const partitionKey = this._indexMap.partitionKey;\n const leafField = fieldPath[fieldPath.length - 1];\n\n if (!this?._indexMap?.numberFields?.includes(leafField)) {\n throw new Error(`${leafField} field not found in indexMap.numberFields`);\n }\n\n const expressionAttributeNames: Record<string, string> = {};\n fieldPath.forEach((segment, i) => {\n expressionAttributeNames[`#f${i}`] = segment;\n });\n\n const pathExpr = fieldPath.map((_, i) => `#f${i}`).join(\".\");\n\n const params: UpdateItemCommandInput = {\n TableName: this._tableName,\n Key: marshall({ [partitionKey]: entityId }),\n UpdateExpression: `SET ${pathExpr} = if_not_exists(${pathExpr}, :start) + :delta`,\n ExpressionAttributeNames: expressionAttributeNames,\n ExpressionAttributeValues: {\n \":delta\": marshall(delta),\n \":start\": marshall(0),\n },\n ReturnValues: ReturnValue.ALL_NEW,\n };\n\n const result = await this.dynamoDb.send(new UpdateItemCommand(params));\n\n return unmarshall(result.Attributes) as T;\n }\n\n /**\n * Executes a DynamoDB Query or Scan and returns up to the desired number of items,\n * respecting DynamoDB's 1MB limit (pagination continuation via LastEvaluatedKey).\n * @param queryInput - QueryCommandInput or ScanCommandInput\n * @param startKey - Optional start key for pagination\n */\n\n private async sendCommandDeep<T>(\n queryInput: QueryCommandInput | ScanCommandInput,\n startKey?: string | Record<string, any>,\n ): Promise<List<T>> {\n const result: List<T> = { items: [] };\n\n const size: number = (queryInput as any)?.Limit ?? 10;\n\n let lastEvaluatedKey: Record<string, AttributeValue>;\n\n if (startKey) {\n lastEvaluatedKey =\n typeof startKey === \"string\"\n ? parseLastEvaluatedKey<Record<string, AttributeValue>>(startKey) // will throw if invalid\n : startKey;\n }\n\n do {\n const response: QueryCommandOutput = await this.sendCommand({\n ...queryInput,\n ExclusiveStartKey: lastEvaluatedKey,\n });\n\n // no more items to fetch\n if (response.LastEvaluatedKey == undefined) {\n result?.items.push(...unMarshall<T>(response.Items));\n result.lastKey = undefined;\n return result;\n }\n\n if (response?.Items.length === 0 && response.LastEvaluatedKey) {\n lastEvaluatedKey = response.LastEvaluatedKey;\n continue;\n }\n\n if (result?.items.length + response?.Items.length <= size) {\n result?.items.push(...unMarshall<T>(response.Items));\n lastEvaluatedKey = response.LastEvaluatedKey;\n if (result?.items.length === size) {\n result.lastKey = toBase64(JSON.stringify(response.LastEvaluatedKey));\n return result;\n }\n continue;\n }\n\n const elementIndex = size - result?.items.length - 1;\n result?.items.push(...unMarshall<T>(response.Items.slice(0, elementIndex)));\n\n const index = this._indexMap.get(queryInput.IndexName);\n result.lastKey = generateLastEvaluatedKey(response.Items[elementIndex], index?.field, index?.sortKeyField);\n break;\n } while (lastEvaluatedKey);\n\n return result;\n }\n\n /**\n * Executes a single Query/Scan and returns the result as-is.\n * Supports pagination via ExclusiveStartKey.\n */\n private async sendCommand(\n commandInput: QueryCommandInput | ScanCommandInput,\n ): Promise<ScanCommandOutput | QueryCommandOutput> {\n commandInput.TableName = this._tableName;\n\n // if (startKey) {\n // commandInput.ExclusiveStartKey = typeof startKey === \"string\" ? parseLastEvaluatedKey(startKey) : startKey;\n // }\n\n if (!commandInput.Limit) {\n commandInput.Limit = this.DYNAMO_QUERY_LIMIT;\n }\n\n const isQuery = \"KeyConditionExpression\" in commandInput;\n const command = isQuery ? new QueryCommand(commandInput) : new ScanCommand(commandInput);\n\n log.debug(\"Sending command:\", commandInput);\n\n if (!this.dynamoDb) throw new ErrorDynamoDB(this._tableName, commandInput, \"dynamoDB client not initialized\");\n\n try {\n return await this.dynamoDb.send(command);\n } catch (error) {\n throw new ErrorDynamoDB(this._tableName, commandInput, error);\n }\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { BaseRepoES, List } from "../index";
2
2
  import { BaseEntity, Filter } from "../model/index.js";
3
- import { ResponseBody } from "@opensearch-project/opensearch/api/_types/_core.search";
3
+ import { API } from "@opensearch-project/opensearch";
4
4
  export declare abstract class BaseRepoESImpl<T extends BaseEntity> implements BaseRepoES<T> {
5
5
  private searchClient;
6
6
  private indexName;
@@ -10,7 +10,7 @@ export declare abstract class BaseRepoESImpl<T extends BaseEntity> implements Ba
10
10
  find(filter: Filter): Promise<List<T>>;
11
11
  fieldNotExists(fieldName: string, from: number, size: number, includeFields?: string[], excludeFields?: string[]): Promise<T[]>;
12
12
  findOne(filter: Filter): Promise<T>;
13
- nativeQuery(query: any): Promise<ResponseBody>;
13
+ nativeQuery(query: any): Promise<API.Search_ResponseBody>;
14
14
  count(query: any): Promise<number>;
15
15
  getRaw?(filter: Filter): Promise<any>;
16
16
  setIndexName(indexName: string): boolean;
@@ -1,6 +1,6 @@
1
1
  import { CoreRepo } from "./base-core.repo.interface";
2
2
  import { BaseEntity } from "../model/base.model";
3
- import { ResponseBody } from "@opensearch-project/opensearch/api/_types/_core.search";
3
+ import { API } from "@opensearch-project/opensearch";
4
4
  export interface BaseRepoES<T extends BaseEntity> extends CoreRepo<T> {
5
5
  findByIdFieldSelected(id: string, includeFields?: string[], excludeFields?: string[]): Promise<T | undefined>;
6
6
  findBetween<K>(fieldName: string, fromValue: K, toValue: K, includeFields: string[]): Promise<T[]>;
@@ -13,5 +13,5 @@ export interface BaseRepoES<T extends BaseEntity> extends CoreRepo<T> {
13
13
  getIndexName(): string;
14
14
  setEndpoint(value: string): boolean;
15
15
  getEndpoint(): string;
16
- nativeQuery(query: any): Promise<ResponseBody>;
16
+ nativeQuery(query: any): Promise<API.Search_ResponseBody>;
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base-es.repo.interface.js","sourceRoot":"","sources":["../../src/repositories/base-es.repo.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { CoreRepo } from \"./base-core.repo.interface\";\nimport { BaseEntity } from \"../model/base.model\";\nimport { ResponseBody } from \"@opensearch-project/opensearch/api/_types/_core.search\";\n\nexport interface BaseRepoES<T extends BaseEntity> extends CoreRepo<T> {\n findByIdFieldSelected(id: string, includeFields?: string[], excludeFields?: string[]): Promise<T | undefined>;\n\n findBetween<K>(fieldName: string, fromValue: K, toValue: K, includeFields: string[]): Promise<T[]>;\n\n search(searchQuery: any, debug?: boolean): Promise<{ items: T[]; aggs: Record<string, any>; total: number }>;\n\n setIndexName(value: string): boolean;\n\n getIndexName(): string;\n\n setEndpoint(value: string): boolean;\n\n getEndpoint(): string;\n\n nativeQuery(query: any): Promise<ResponseBody>;\n}\n"]}
1
+ {"version":3,"file":"base-es.repo.interface.js","sourceRoot":"","sources":["../../src/repositories/base-es.repo.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { CoreRepo } from \"./base-core.repo.interface\";\nimport { BaseEntity } from \"../model/base.model\";\nimport { API } from \"@opensearch-project/opensearch\";\n\nexport interface BaseRepoES<T extends BaseEntity> extends CoreRepo<T> {\n findByIdFieldSelected(id: string, includeFields?: string[], excludeFields?: string[]): Promise<T | undefined>;\n\n findBetween<K>(fieldName: string, fromValue: K, toValue: K, includeFields: string[]): Promise<T[]>;\n\n search(searchQuery: any, debug?: boolean): Promise<{ items: T[]; aggs: Record<string, any>; total: number }>;\n\n setIndexName(value: string): boolean;\n\n getIndexName(): string;\n\n setEndpoint(value: string): boolean;\n\n getEndpoint(): string;\n\n nativeQuery(query: any): Promise<API.Search_ResponseBody>;\n}\n"]}