aws-service-stack 0.18.439 → 0.18.441

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.
@@ -1 +1 @@
1
- {"version":3,"file":"controller-request.d.ts","sourceRoot":"","sources":["../../src/controller/controller-request.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,kBAAkB,EAKnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAkB,MAAM,iBAAiB,CAAC;AAGjE,8BAAsB,iBAAiB,CAAC,CAAC,GAAG,GAAG;IAC7C,SAAS,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAC;IACrC,SAAS,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACtC,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAEtC,QAAQ,EAAE,cAAc,EAAE;IAIhC,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IAUxE,qBAAqB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC;IAUhF,SAAS,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;IAEnF,SAAS,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,GAAG,CAAC;YAEvE,aAAa;IAsC3B,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,cAAc;CAYvB"}
1
+ {"version":3,"file":"controller-request.d.ts","sourceRoot":"","sources":["../../src/controller/controller-request.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,kBAAkB,EAKnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,cAAc,EAA8B,MAAM,iBAAiB,CAAC;AAG7E,8BAAsB,iBAAiB,CAAC,CAAC,GAAG,GAAG;IAC7C,SAAS,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAC;IACrC,SAAS,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACtC,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAEtC,QAAQ,EAAE,cAAc,EAAE;IAIhC,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IAUxE,qBAAqB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC;IAUhF,SAAS,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;IAEnF,SAAS,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,GAAG,CAAC;YAEvE,aAAa;IAuC3B,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,cAAc;CAYvB"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ControllerRequest = void 0;
4
4
  const index_1 = require("../index");
5
5
  const exception_1 = require("../exception");
6
+ const types_1 = require("../model/index.js");
6
7
  const string_util_1 = require("../utils/string.util");
7
8
  class ControllerRequest {
8
9
  policies;
@@ -21,7 +22,7 @@ class ControllerRequest {
21
22
  try {
22
23
  if (!Array.isArray(this.policies) || this.policies.length === 0)
23
24
  throw new exception_1.ErrorHttp(exception_1.HTTP.INTERNAL_SERVER_ERROR, "No policies defined for this controller");
24
- const policy = this.policies.find((p) => p.method === method && (0, string_util_1.trimSpecialChar)(p.path) === (0, string_util_1.trimSpecialChar)(path));
25
+ const policy = this.policies.find((p) => (p.method === method || p.method === types_1.HttpMethod.ANY) && (0, string_util_1.trimSpecialChar)(p.path) === (0, string_util_1.trimSpecialChar)(path));
25
26
  if (!policy) {
26
27
  throw new exception_1.ErrorHttp(exception_1.HTTP.NOT_FOUND, "No matching policy found for this endpoint");
27
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"controller-request.js","sourceRoot":"","sources":["../../src/controller/controller-request.ts"],"names":[],"mappings":";;;AAAA,oCAOkB;AAElB,4CAAgE;AAEhE,sDAAuD;AAEvD,MAAsB,iBAAiB;IAC3B,QAAQ,CAAmB;IAC3B,OAAO,CAAqB;IAC5B,eAAe,CAAyB;IAElD,YAAY,QAA0B;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,KAA2B;QACrD,OAAO,IAAI,CAAC,aAAa,CACvB,KAAK,EACL,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,QAAQ,EACd,KAAK,CAAC,IAAI,EACV,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CACtC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,KAA6B;QACvD,OAAO,IAAI,CAAC,aAAa,CACvB,KAAK,EACL,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAChC,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,IAAI,EACV,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CACtC,CAAC;IACJ,CAAC;IAMO,KAAK,CAAC,aAAa,CACzB,KAAU,EACV,MAAc,EACd,IAAY,EACZ,gBAAqB,EACrB,SAAuC;QAEvC,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;gBAC7D,MAAM,IAAI,qBAAS,CAAC,gBAAI,CAAC,qBAAqB,EAAE,yCAAyC,CAAC,CAAC;YAE7F,MAAM,MAAM,GA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AC;IAEO,eAAe,CAAC,IAAS,EAAE,MAAsB;QACvD,IAAI,CAAC;YACH,IAAA,0BAAkB,EAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,eAAe,GAAG,IAAA,oBAAY,EAAC,KAAK,CAAC,CAAC;YAC5C,MAAM,IAAI,qBAAS,CAAC,gBAAI,CAAC,WAAW,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IAEO,cAAc,CAAC,QAAa,EAAE,cAA8B;QAClE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAA,oBAAY,EAAC,QAAQ,EAAE,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;QAChF,CAAC;QAED,IAAI,QAAQ,EAAE,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACrD,QAAQ,CAAC,KAAK,GAAG,IAAA,oBAAY,EAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;YAC9F,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,OAAO,IAAA,oBAAY,EAAC,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACrF,CAAC;CACF;AA5FD,8CA4FC","sourcesContent":["import {\n APIResponse,\n APIResponseOptions,\n createApiResponse,\n formatErrors,\n removeFields,\n validateWithSchema,\n} from \"../index\";\nimport { APIGatewayProxyEvent, APIGatewayProxyEventV2 } from \"aws-lambda\";\nimport { ErrorHttp, HTTP, refineHttpError } from \"../exception\";\nimport { EndpointPolicy, ResponseFields } from \"@chinggis/types\";\nimport { trimSpecialChar } from \"../utils/string.util\";\n\nexport abstract class ControllerRequest<R = any> {\n protected policies: EndpointPolicy[];\n protected options: APIResponseOptions;\n protected responseHeaders: Record<string, string>;\n\n constructor(policies: EndpointPolicy[]) {\n this.policies = policies;\n }\n\n async resolveRequestRestApi(event: APIGatewayProxyEvent): Promise<APIResponse> {\n return this.handleRequest(\n event,\n event.httpMethod,\n event.resource,\n event.body,\n this.processRequestRestApi.bind(this),\n );\n }\n\n async resolveRequestHttpApi(event: APIGatewayProxyEventV2): Promise<APIResponse> {\n return this.handleRequest(\n event,\n event.requestContext.http.method,\n event.rawPath,\n event.body,\n this.processRequestHttpApi.bind(this),\n );\n }\n\n protected abstract processRequestRestApi(event: APIGatewayProxyEvent): Promise<any>;\n\n protected abstract processRequestHttpApi(event: APIGatewayProxyEventV2): Promise<any>;\n\n private async handleRequest(\n event: any,\n method: string,\n path: string,\n validationTarget: any,\n processor: (event: any) => Promise<any>,\n ): Promise<APIResponse> {\n try {\n if (!Array.isArray(this.policies) || this.policies.length === 0)\n throw new ErrorHttp(HTTP.INTERNAL_SERVER_ERROR, \"No policies defined for this controller\");\n\n const policy = this.policies.find(\n (p) => p.method === method && trimSpecialChar(p.path) === trimSpecialChar(path),\n );\n\n if (!policy) {\n throw new ErrorHttp(HTTP.NOT_FOUND, \"No matching policy found for this endpoint\");\n }\n\n validationTarget = validationTarget ? JSON.parse(validationTarget) : {};\n\n this.validateRequest(validationTarget, policy);\n\n const response = await processor(event);\n\n const filteredResponse = policy.response ? this.filterResponse(response, policy.response) : response;\n\n return createApiResponse(200, filteredResponse, this.options, this.responseHeaders);\n } catch (err) {\n const error = refineHttpError(err);\n\n if (error.statusCode >= 500) log.error(error);\n else if (error.statusCode >= 400) log.warn(error);\n\n return createApiResponse(error.statusCode, error.content);\n }\n }\n\n private validateRequest(body: any, policy: EndpointPolicy): void {\n try {\n validateWithSchema(policy.validator, body);\n } catch (error) {\n const formattedErrors = formatErrors(error);\n throw new ErrorHttp(HTTP.BAD_REQUEST, undefined, formattedErrors);\n }\n }\n\n private filterResponse(response: any, responsePolicy: ResponseFields): any {\n if (Array.isArray(response)) {\n return removeFields(response, responsePolicy.include, responsePolicy.exclude);\n }\n\n if (response?.items && Array.isArray(response.items)) {\n response.items = removeFields(response.items, responsePolicy.include, responsePolicy.exclude);\n return response;\n }\n\n return removeFields([response], responsePolicy.include, responsePolicy.exclude)[0];\n }\n}\n"]}
1
+ {"version":3,"file":"controller-request.js","sourceRoot":"","sources":["../../src/controller/controller-request.ts"],"names":[],"mappings":";;;AAAA,oCAOkB;AAElB,4CAAgE;AAChE,2CAA6E;AAC7E,sDAAuD;AAEvD,MAAsB,iBAAiB;IAC3B,QAAQ,CAAmB;IAC3B,OAAO,CAAqB;IAC5B,eAAe,CAAyB;IAElD,YAAY,QAA0B;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,KAA2B;QACrD,OAAO,IAAI,CAAC,aAAa,CACvB,KAAK,EACL,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,QAAQ,EACd,KAAK,CAAC,IAAI,EACV,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CACtC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,KAA6B;QACvD,OAAO,IAAI,CAAC,aAAa,CACvB,KAAK,EACL,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAChC,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,IAAI,EACV,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CACtC,CAAC;IACJ,CAAC;IAMO,KAAK,CAAC,aAAa,CACzB,KAAU,EACV,MAAc,EACd,IAAY,EACZ,gBAAqB,EACrB,SAAuC;QAEvC,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK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"../index\";\nimport { APIGatewayProxyEvent, APIGatewayProxyEventV2 } from \"aws-lambda\";\nimport { ErrorHttp, HTTP, refineHttpError } from \"../exception\";\nimport { EndpointPolicy, HttpMethod, ResponseFields } from \"@chinggis/types\";\nimport { trimSpecialChar } from \"../utils/string.util\";\n\nexport abstract class ControllerRequest<R = any> {\n protected policies: EndpointPolicy[];\n protected options: APIResponseOptions;\n protected responseHeaders: Record<string, string>;\n\n constructor(policies: EndpointPolicy[]) {\n this.policies = policies;\n }\n\n async resolveRequestRestApi(event: APIGatewayProxyEvent): Promise<APIResponse> {\n return this.handleRequest(\n event,\n event.httpMethod,\n event.resource,\n event.body,\n this.processRequestRestApi.bind(this),\n );\n }\n\n async resolveRequestHttpApi(event: APIGatewayProxyEventV2): Promise<APIResponse> {\n return this.handleRequest(\n event,\n event.requestContext.http.method,\n event.rawPath,\n event.body,\n this.processRequestHttpApi.bind(this),\n );\n }\n\n protected abstract processRequestRestApi(event: APIGatewayProxyEvent): Promise<any>;\n\n protected abstract processRequestHttpApi(event: APIGatewayProxyEventV2): Promise<any>;\n\n private async handleRequest(\n event: any,\n method: string,\n path: string,\n validationTarget: any,\n processor: (event: any) => Promise<any>,\n ): Promise<APIResponse> {\n try {\n if (!Array.isArray(this.policies) || this.policies.length === 0)\n throw new ErrorHttp(HTTP.INTERNAL_SERVER_ERROR, \"No policies defined for this controller\");\n\n const policy = this.policies.find(\n (p) =>\n (p.method === method || p.method === HttpMethod.ANY) && trimSpecialChar(p.path) === trimSpecialChar(path),\n );\n\n if (!policy) {\n throw new ErrorHttp(HTTP.NOT_FOUND, \"No matching policy found for this endpoint\");\n }\n\n validationTarget = validationTarget ? JSON.parse(validationTarget) : {};\n\n this.validateRequest(validationTarget, policy);\n\n const response = await processor(event);\n\n const filteredResponse = policy.response ? this.filterResponse(response, policy.response) : response;\n\n return createApiResponse(200, filteredResponse, this.options, this.responseHeaders);\n } catch (err) {\n const error = refineHttpError(err);\n\n if (error.statusCode >= 500) log.error(error);\n else if (error.statusCode >= 400) log.warn(error);\n\n return createApiResponse(error.statusCode, error.content);\n }\n }\n\n private validateRequest(body: any, policy: EndpointPolicy): void {\n try {\n validateWithSchema(policy.validator, body);\n } catch (error) {\n const formattedErrors = formatErrors(error);\n throw new ErrorHttp(HTTP.BAD_REQUEST, undefined, formattedErrors);\n }\n }\n\n private filterResponse(response: any, responsePolicy: ResponseFields): any {\n if (Array.isArray(response)) {\n return removeFields(response, responsePolicy.include, responsePolicy.exclude);\n }\n\n if (response?.items && Array.isArray(response.items)) {\n response.items = removeFields(response.items, responsePolicy.include, responsePolicy.exclude);\n return response;\n }\n\n return removeFields([response], responsePolicy.include, responsePolicy.exclude)[0];\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"base-db.repo.d.ts","sourceRoot":"","sources":["../../src/repositories/base-db.repo.ts"],"names":[],"mappings":"AAqBA,OAAO,EAEL,UAAU,EAQV,cAAc,EAGd,IAAI,EAML,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAIrD,qBAAa,cAAc,CAAC,CAAC,SAAS,UAAU,CAAE,YAAW,UAAU,CAAC,CAAC,CAAC;IACxE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuD;IAChF,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAc;IAE3C,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAwCzE,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAI3E,qBAAqB,CACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,E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BAAE,EAAE,EAAE,MAAM,CAAA;aAAE,CAAC;YACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SACjC,EAAE,CAAC;QACJ,MAAM,CAAC,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE;gBAAE,EAAE,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,EAAE,CAAC;KACvD,GAAG,OAAO,CAAC,OAAO,CAAC;IA8DpB,YAAY;IAIZ,WAAW,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO;IAK9C,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAKpC,WAAW,IAAI,cAAc;YAIf,gBAAgB;YAIhB,uBAAuB;YAgDvB,cAAc;YAwBd,qBAAqB;YAgCrB,8BAA8B;IA+C5C;;;OAGG;YACW,eAAe;IAsF7B;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAWnC;;OAEG;YACW,eAAe;IAiB7B;;OAEG;YACW,WAAW;CA4B1B"}
@@ -475,12 +475,6 @@ class BaseRepoDBImpl {
475
475
  async incrementOrDecrementFieldValue(entityId, fieldPath, delta) {
476
476
  const partitionKey = this._indexMap.partitionKey;
477
477
  const pathSegments = fieldPath.split(".");
478
- const leafField = pathSegments[pathSegments.length - 1];
479
- const fullFieldPath = fieldPath;
480
- const numberFields = this._indexMap?.numberFields;
481
- if (numberFields?.length && !numberFields.some((field) => field === leafField || field === fullFieldPath)) {
482
- throw new Error(`${fullFieldPath} field not found in indexMap.numberFields`);
483
- }
484
478
  const expressionAttributeNames = {};
485
479
  pathSegments.forEach((segment, i) => {
486
480
  expressionAttributeNames[`#f${i}`] = segment;
@@ -497,8 +491,21 @@ class BaseRepoDBImpl {
497
491
  },
498
492
  ReturnValues: client_dynamodb_1.ReturnValue.ALL_NEW,
499
493
  };
500
- const result = await this.dynamoDb.send(new client_dynamodb_1.UpdateItemCommand(params));
501
- return (0, util_dynamodb_1.unmarshall)(result.Attributes);
494
+ try {
495
+ const result = await this.dynamoDb.send(new client_dynamodb_1.UpdateItemCommand(params));
496
+ return (0, util_dynamodb_1.unmarshall)(result.Attributes);
497
+ }
498
+ catch (error) {
499
+ if (error.name === "ValidationException" && error.message.includes("incorrect data type")) {
500
+ throw new Error(`Database Type Error: Cannot increment '${fieldPath}'. The existing field in the database is not a Number type.`);
501
+ }
502
+ if (error.name === "ValidationException" &&
503
+ error.message.includes("document path provided in the update expression is invalid")) {
504
+ throw new Error(`Path Error: Cannot increment '${fieldPath}' because one of the parent maps/objects does not exist in the document.`);
505
+ }
506
+ console.error("incrementOrDecrementFieldValue unexpected error: ", error);
507
+ throw error;
508
+ }
502
509
  }
503
510
  /**
504
511
  * Runs repeated Scan requests until enough filtered items are collected, the
@@ -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,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,KAAK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CAAC,kBAAkB,CAAC;QAC/C,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,8BAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,6BAAW,CAAC,YAAY,CAAC,CAAC;QAEzF,IAAI,KAAK;YAAE,GAAG,CAAC,KAAK,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC;QAEvD,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,sBAAa,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE,iCAAiC,CAAC,CAAC;QAE9G,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,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;AA7uBD,wCA6uBC","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 fieldNames.forEach((fieldPath, index) => {\n const parts = fieldPath.split(\".\");\n const pathPlaceholders: string[] = [];\n\n parts.forEach((part, partIndex) => {\n const namePlaceholder = `#field${index}_${partIndex}`;\n pathPlaceholders.push(namePlaceholder);\n expressionAttributeNames[namePlaceholder] = part;\n });\n\n removeExpressions.push(pathPlaceholders.join(\".\"));\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(\n entityId: string,\n fieldName: string,\n value?: number,\n nestedFieldSeparator?: string,\n ): Promise<T> {\n if (value < 0) {\n throw new Error(\"Increment operation only supports positive values\");\n }\n const fieldPath = nestedFieldSeparator ? fieldName.split(nestedFieldSeparator).join(\".\") : fieldName;\n return this.incrementOrDecrementFieldValue(entityId, fieldPath, value ?? 1);\n }\n\n decrementValueByField(\n entityId: string,\n fieldName: string,\n value?: number,\n nestedFieldSeparator?: string,\n ): 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).join(\".\") : 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(entity: Partial<T>, fields: string[]): Promise<Partial<T>> {\n if (!entity || !fields?.length) return entity;\n\n const partitionKey = this._indexMap?.partitionKey;\n if (!partitionKey) return entity;\n\n const entityId = entity[partitionKey as keyof T] as unknown as string;\n if (!entityId) return entity;\n\n const updateExpressions: string[] = [];\n const expressionAttributeNames: Record<string, string> = {};\n const expressionAttributeValues: Record<string, any> = {}; // Typ je nach deinem SDK Import\n\n fields.forEach((fieldPath, index) => {\n if (fieldPath === partitionKey) return;\n\n const rawValue = fieldPath.split(\".\").reduce((acc: any, part) => acc?.[part], entity);\n\n if (rawValue === undefined) return;\n const parts = fieldPath.split(\".\");\n const pathPlaceholders: string[] = [];\n\n parts.forEach((part, partIndex) => {\n const namePlaceholder = `#field${index}_${partIndex}`;\n pathPlaceholders.push(namePlaceholder);\n expressionAttributeNames[namePlaceholder] = part; // Mappt z.B. \"#field0_0\" auf \"loyalty\"\n });\n\n const fullPath = pathPlaceholders.join(\".\");\n const valuePlaceholder = `:val${index}`;\n\n updateExpressions.push(`${fullPath} = ${valuePlaceholder}`);\n\n const marshalledWrapper = marshall({ temp: rawValue }, { removeUndefinedValues: true });\n expressionAttributeValues[valuePlaceholder] = marshalledWrapper.temp;\n });\n\n if (updateExpressions.length === 0) return entity;\n\n const response = await this.dynamoDb.send(\n new UpdateItemCommand({\n TableName: this._tableName,\n Key: marshall({ [partitionKey]: entityId }),\n UpdateExpression: `SET ${updateExpressions.join(\", \")}`,\n ExpressionAttributeNames: expressionAttributeNames,\n ExpressionAttributeValues: expressionAttributeValues,\n ReturnValues: ReturnValue.ALL_NEW,\n }),\n );\n\n return response.Attributes ? (unmarshall(response.Attributes) as Partial<T>) : entity;\n }\n\n async updateMany(entityList: Partial<T>[], fields: string[], isTransactional: boolean): Promise<boolean> {\n if (isTransactional === undefined || isTransactional === false || isTransactional === null)\n return this.updateManyNormal(entityList, fields);\n\n return 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, debug?: boolean): 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.sendCommandPage<T>(dbQuery, filter?.lastKey, debug);\n const fieldsRemoved = removeFields(response?.items, filter.fieldsInclude, filter.fieldsExclude);\n return { items: fieldsRemoved, lastKey: response?.lastKey };\n }\n\n async scan(filter: Filter, debug?: boolean): Promise<List<Partial<T>>> {\n if (!filter) filter = { size: this.DYNAMO_QUERY_LIMIT };\n const queryCountLimit = this.validateScanQueryCountLimit(filter);\n const expression = buildDynamoDBFilterConditions(filter, this._indexMap);\n const scanInput = buildDynamoDBScanCommand({ tableName: this._tableName, filter, expression });\n const response = await this.sendCommandDeep<T>(\n scanInput,\n filter?.lastKey,\n queryCountLimit,\n filter?.size ?? this.DYNAMO_QUERY_LIMIT,\n debug,\n );\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(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 pathSegments = fieldPath.split(\".\");\n const leafField = pathSegments[pathSegments.length - 1];\n const fullFieldPath = fieldPath;\n const numberFields = this._indexMap?.numberFields;\n\n if (numberFields?.length && !numberFields.some((field) => field === leafField || field === fullFieldPath)) {\n throw new Error(`${fullFieldPath} field not found in indexMap.numberFields`);\n }\n\n const expressionAttributeNames: Record<string, string> = {};\n pathSegments.forEach((segment, i) => {\n expressionAttributeNames[`#f${i}`] = segment;\n });\n\n const pathExpr = pathSegments.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 * Runs repeated Scan requests until enough filtered items are collected, the\n * table ends, or the caller's scan-request limit is reached.\n */\n private async sendCommandDeep<T>(\n queryInput: QueryCommandInput | ScanCommandInput,\n startKey?: string | Record<string, any>,\n queryCountLimit?: number,\n size = this.DYNAMO_QUERY_LIMIT,\n debug?: boolean,\n ): Promise<List<T>> {\n const result: List<T> = { items: [] };\n\n let scannedCount = 0;\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 remainingQueryCount = queryCountLimit === undefined ? undefined : queryCountLimit - scannedCount;\n if (remainingQueryCount !== undefined && remainingQueryCount <= 0) {\n result.lastKey = lastEvaluatedKey ? toBase64(JSON.stringify(lastEvaluatedKey)) : undefined;\n return result;\n }\n\n const response: QueryCommandOutput = await this.sendCommand(\n {\n ...queryInput,\n ExclusiveStartKey: lastEvaluatedKey,\n },\n debug,\n );\n const responseItems = response.Items ?? [];\n scannedCount++;\n\n if (result.items.length + responseItems.length > size) {\n const takeCount = size - result.items.length;\n const lastIncludedIndex = takeCount - 1;\n\n result.items.push(...unMarshall<T>(responseItems.slice(0, takeCount)));\n\n const index = this._indexMap.get(queryInput.IndexName);\n result.lastKey = generateLastEvaluatedKey(\n responseItems[lastIncludedIndex],\n index?.field ?? this._indexMap.partitionKey,\n index?.sortKeyField,\n );\n return result;\n }\n\n // no more items to fetch\n if (response.LastEvaluatedKey == undefined) {\n result?.items.push(...unMarshall<T>(responseItems));\n result.lastKey = undefined;\n return result;\n }\n\n if (responseItems.length === 0 && response.LastEvaluatedKey) {\n lastEvaluatedKey = response.LastEvaluatedKey;\n if (queryCountLimit !== undefined && scannedCount >= queryCountLimit) {\n result.lastKey = toBase64(JSON.stringify(response.LastEvaluatedKey));\n return result;\n }\n continue;\n }\n\n if (result?.items.length + responseItems.length <= size) {\n result?.items.push(...unMarshall<T>(responseItems));\n lastEvaluatedKey = response.LastEvaluatedKey;\n if (result?.items.length === size) {\n result.lastKey = toBase64(JSON.stringify(response.LastEvaluatedKey));\n return result;\n }\n if (queryCountLimit !== undefined && scannedCount >= queryCountLimit) {\n result.lastKey = toBase64(JSON.stringify(response.LastEvaluatedKey));\n return result;\n }\n continue;\n }\n } while (lastEvaluatedKey);\n\n return result;\n }\n\n /**\n * Enforces the per-call safety limit for scan pagination.\n */\n private validateScanQueryCountLimit(filter: Filter): number {\n const value = Number(filter.queryCountLimit);\n if (!Number.isInteger(value) || value <= 0) {\n throw new ErrorDynamoDB(this._tableName, \"scan\", \"scan requires queryCountLimit\");\n }\n if (value > 500) {\n throw new ErrorDynamoDB(this._tableName, \"scan\", \"scan queryCountLimit must not be greater than 500\");\n }\n return value;\n }\n\n /**\n * Executes one DynamoDB Query/Scan page and returns DynamoDB's pagination key.\n */\n private async sendCommandPage<T>(\n queryInput: QueryCommandInput | ScanCommandInput,\n startKey?: string | Record<string, any>,\n debug?: boolean,\n ): Promise<List<T>> {\n if (startKey) {\n queryInput.ExclusiveStartKey =\n typeof startKey === \"string\" ? parseLastEvaluatedKey<Record<string, AttributeValue>>(startKey) : startKey;\n }\n\n const response = await this.sendCommand(queryInput, debug);\n return {\n items: unMarshall<T>(response.Items),\n lastKey: response.LastEvaluatedKey ? toBase64(JSON.stringify(response.LastEvaluatedKey)) : undefined,\n };\n }\n\n /**\n * Sends one QueryCommand or ScanCommand after applying table/default limit.\n */\n private async sendCommand(\n commandInput: QueryCommandInput | ScanCommandInput,\n debug?: boolean,\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 const isQuery = \"KeyConditionExpression\" in commandInput;\n\n if (isQuery && !commandInput.Limit) {\n commandInput.Limit = this.DYNAMO_QUERY_LIMIT;\n }\n\n const command = isQuery ? new QueryCommand(commandInput) : new ScanCommand(commandInput);\n\n if (debug) 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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,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;QAEzC,kBAAkB;QAClB,gHAAgH;QAChH,IAAI;QAEJ,MAAM,OAAO,GAAG,wBAAwB,IAAI,YAAY,CAAC;QAEzD,IAAI,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YACnC,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC;QAC/C,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,8BAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,6BAAW,CAAC,YAAY,CAAC,CAAC;QAEzF,IAAI,KAAK;YAAE,GAAG,CAAC,KAAK,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC;QAEvD,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,sBAAa,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE,iCAAiC,CAAC,CAAC;QAE9G,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,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;AAzvBD,wCAyvBC","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 fieldNames.forEach((fieldPath, index) => {\n const parts = fieldPath.split(\".\");\n const pathPlaceholders: string[] = [];\n\n parts.forEach((part, partIndex) => {\n const namePlaceholder = `#field${index}_${partIndex}`;\n pathPlaceholders.push(namePlaceholder);\n expressionAttributeNames[namePlaceholder] = part;\n });\n\n removeExpressions.push(pathPlaceholders.join(\".\"));\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(\n entityId: string,\n fieldName: string,\n value?: number,\n nestedFieldSeparator?: string,\n ): Promise<T> {\n if (value < 0) {\n throw new Error(\"Increment operation only supports positive values\");\n }\n const fieldPath = nestedFieldSeparator ? fieldName.split(nestedFieldSeparator).join(\".\") : fieldName;\n return this.incrementOrDecrementFieldValue(entityId, fieldPath, value ?? 1);\n }\n\n decrementValueByField(\n entityId: string,\n fieldName: string,\n value?: number,\n nestedFieldSeparator?: string,\n ): 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).join(\".\") : 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(entity: Partial<T>, fields: string[]): Promise<Partial<T>> {\n if (!entity || !fields?.length) return entity;\n\n const partitionKey = this._indexMap?.partitionKey;\n if (!partitionKey) return entity;\n\n const entityId = entity[partitionKey as keyof T] as unknown as string;\n if (!entityId) return entity;\n\n const updateExpressions: string[] = [];\n const expressionAttributeNames: Record<string, string> = {};\n const expressionAttributeValues: Record<string, any> = {}; // Typ je nach deinem SDK Import\n\n fields.forEach((fieldPath, index) => {\n if (fieldPath === partitionKey) return;\n\n const rawValue = fieldPath.split(\".\").reduce((acc: any, part) => acc?.[part], entity);\n\n if (rawValue === undefined) return;\n const parts = fieldPath.split(\".\");\n const pathPlaceholders: string[] = [];\n\n parts.forEach((part, partIndex) => {\n const namePlaceholder = `#field${index}_${partIndex}`;\n pathPlaceholders.push(namePlaceholder);\n expressionAttributeNames[namePlaceholder] = part; // Mappt z.B. \"#field0_0\" auf \"loyalty\"\n });\n\n const fullPath = pathPlaceholders.join(\".\");\n const valuePlaceholder = `:val${index}`;\n\n updateExpressions.push(`${fullPath} = ${valuePlaceholder}`);\n\n const marshalledWrapper = marshall({ temp: rawValue }, { removeUndefinedValues: true });\n expressionAttributeValues[valuePlaceholder] = marshalledWrapper.temp;\n });\n\n if (updateExpressions.length === 0) return entity;\n\n const response = await this.dynamoDb.send(\n new UpdateItemCommand({\n TableName: this._tableName,\n Key: marshall({ [partitionKey]: entityId }),\n UpdateExpression: `SET ${updateExpressions.join(\", \")}`,\n ExpressionAttributeNames: expressionAttributeNames,\n ExpressionAttributeValues: expressionAttributeValues,\n ReturnValues: ReturnValue.ALL_NEW,\n }),\n );\n\n return response.Attributes ? (unmarshall(response.Attributes) as Partial<T>) : entity;\n }\n\n async updateMany(entityList: Partial<T>[], fields: string[], isTransactional: boolean): Promise<boolean> {\n if (isTransactional === undefined || isTransactional === false || isTransactional === null)\n return this.updateManyNormal(entityList, fields);\n\n return 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, debug?: boolean): 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.sendCommandPage<T>(dbQuery, filter?.lastKey, debug);\n const fieldsRemoved = removeFields(response?.items, filter.fieldsInclude, filter.fieldsExclude);\n return { items: fieldsRemoved, lastKey: response?.lastKey };\n }\n\n async scan(filter: Filter, debug?: boolean): Promise<List<Partial<T>>> {\n if (!filter) filter = { size: this.DYNAMO_QUERY_LIMIT };\n const queryCountLimit = this.validateScanQueryCountLimit(filter);\n const expression = buildDynamoDBFilterConditions(filter, this._indexMap);\n const scanInput = buildDynamoDBScanCommand({ tableName: this._tableName, filter, expression });\n const response = await this.sendCommandDeep<T>(\n scanInput,\n filter?.lastKey,\n queryCountLimit,\n filter?.size ?? this.DYNAMO_QUERY_LIMIT,\n debug,\n );\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(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 pathSegments = fieldPath.split(\".\");\n\n const expressionAttributeNames: Record<string, string> = {};\n pathSegments.forEach((segment, i) => {\n expressionAttributeNames[`#f${i}`] = segment;\n });\n\n const pathExpr = pathSegments.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 try {\n const result = await this.dynamoDb.send(new UpdateItemCommand(params));\n return unmarshall(result.Attributes) as T;\n } catch (error) {\n if (error.name === \"ValidationException\" && error.message.includes(\"incorrect data type\")) {\n throw new Error(\n `Database Type Error: Cannot increment '${fieldPath}'. The existing field in the database is not a Number type.`,\n );\n }\n\n if (\n error.name === \"ValidationException\" &&\n error.message.includes(\"document path provided in the update expression is invalid\")\n ) {\n throw new Error(\n `Path Error: Cannot increment '${fieldPath}' because one of the parent maps/objects does not exist in the document.`,\n );\n }\n\n console.error(\"incrementOrDecrementFieldValue unexpected error: \", error);\n throw error;\n }\n }\n\n /**\n * Runs repeated Scan requests until enough filtered items are collected, the\n * table ends, or the caller's scan-request limit is reached.\n */\n private async sendCommandDeep<T>(\n queryInput: QueryCommandInput | ScanCommandInput,\n startKey?: string | Record<string, any>,\n queryCountLimit?: number,\n size = this.DYNAMO_QUERY_LIMIT,\n debug?: boolean,\n ): Promise<List<T>> {\n const result: List<T> = { items: [] };\n\n let scannedCount = 0;\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 remainingQueryCount = queryCountLimit === undefined ? undefined : queryCountLimit - scannedCount;\n if (remainingQueryCount !== undefined && remainingQueryCount <= 0) {\n result.lastKey = lastEvaluatedKey ? toBase64(JSON.stringify(lastEvaluatedKey)) : undefined;\n return result;\n }\n\n const response: QueryCommandOutput = await this.sendCommand(\n {\n ...queryInput,\n ExclusiveStartKey: lastEvaluatedKey,\n },\n debug,\n );\n const responseItems = response.Items ?? [];\n scannedCount++;\n\n if (result.items.length + responseItems.length > size) {\n const takeCount = size - result.items.length;\n const lastIncludedIndex = takeCount - 1;\n\n result.items.push(...unMarshall<T>(responseItems.slice(0, takeCount)));\n\n const index = this._indexMap.get(queryInput.IndexName);\n result.lastKey = generateLastEvaluatedKey(\n responseItems[lastIncludedIndex],\n index?.field ?? this._indexMap.partitionKey,\n index?.sortKeyField,\n );\n return result;\n }\n\n // no more items to fetch\n if (response.LastEvaluatedKey == undefined) {\n result?.items.push(...unMarshall<T>(responseItems));\n result.lastKey = undefined;\n return result;\n }\n\n if (responseItems.length === 0 && response.LastEvaluatedKey) {\n lastEvaluatedKey = response.LastEvaluatedKey;\n if (queryCountLimit !== undefined && scannedCount >= queryCountLimit) {\n result.lastKey = toBase64(JSON.stringify(response.LastEvaluatedKey));\n return result;\n }\n continue;\n }\n\n if (result?.items.length + responseItems.length <= size) {\n result?.items.push(...unMarshall<T>(responseItems));\n lastEvaluatedKey = response.LastEvaluatedKey;\n if (result?.items.length === size) {\n result.lastKey = toBase64(JSON.stringify(response.LastEvaluatedKey));\n return result;\n }\n if (queryCountLimit !== undefined && scannedCount >= queryCountLimit) {\n result.lastKey = toBase64(JSON.stringify(response.LastEvaluatedKey));\n return result;\n }\n continue;\n }\n } while (lastEvaluatedKey);\n\n return result;\n }\n\n /**\n * Enforces the per-call safety limit for scan pagination.\n */\n private validateScanQueryCountLimit(filter: Filter): number {\n const value = Number(filter.queryCountLimit);\n if (!Number.isInteger(value) || value <= 0) {\n throw new ErrorDynamoDB(this._tableName, \"scan\", \"scan requires queryCountLimit\");\n }\n if (value > 500) {\n throw new ErrorDynamoDB(this._tableName, \"scan\", \"scan queryCountLimit must not be greater than 500\");\n }\n return value;\n }\n\n /**\n * Executes one DynamoDB Query/Scan page and returns DynamoDB's pagination key.\n */\n private async sendCommandPage<T>(\n queryInput: QueryCommandInput | ScanCommandInput,\n startKey?: string | Record<string, any>,\n debug?: boolean,\n ): Promise<List<T>> {\n if (startKey) {\n queryInput.ExclusiveStartKey =\n typeof startKey === \"string\" ? parseLastEvaluatedKey<Record<string, AttributeValue>>(startKey) : startKey;\n }\n\n const response = await this.sendCommand(queryInput, debug);\n return {\n items: unMarshall<T>(response.Items),\n lastKey: response.LastEvaluatedKey ? toBase64(JSON.stringify(response.LastEvaluatedKey)) : undefined,\n };\n }\n\n /**\n * Sends one QueryCommand or ScanCommand after applying table/default limit.\n */\n private async sendCommand(\n commandInput: QueryCommandInput | ScanCommandInput,\n debug?: boolean,\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 const isQuery = \"KeyConditionExpression\" in commandInput;\n\n if (isQuery && !commandInput.Limit) {\n commandInput.Limit = this.DYNAMO_QUERY_LIMIT;\n }\n\n const command = isQuery ? new QueryCommand(commandInput) : new ScanCommand(commandInput);\n\n if (debug) 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-service-stack",
3
- "version": "0.18.439",
3
+ "version": "0.18.441",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "chinggis.systems",