@exabugs/dynamodb-client 1.8.0 → 1.10.0

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 (89) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +1 -0
  3. package/dist/client/FindCursor.d.ts +11 -6
  4. package/dist/client/FindCursor.d.ts.map +1 -1
  5. package/dist/client/FindCursor.js +30 -11
  6. package/dist/client/FindCursor.js.map +1 -1
  7. package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyField.d.ts.map +1 -1
  8. package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyField.js +5 -4
  9. package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyField.js.map +1 -1
  10. package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyInput.d.ts.map +1 -1
  11. package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyInput.js +5 -4
  12. package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyInput.js.map +1 -1
  13. package/dist/integrations/react-admin/components/ReferenceManyToMany/useGetListAll.d.ts +19 -0
  14. package/dist/integrations/react-admin/components/ReferenceManyToMany/useGetListAll.d.ts.map +1 -0
  15. package/dist/integrations/react-admin/components/ReferenceManyToMany/useGetListAll.js +36 -0
  16. package/dist/integrations/react-admin/components/ReferenceManyToMany/useGetListAll.js.map +1 -0
  17. package/dist/integrations/react-admin/dataProvider.d.ts +15 -1
  18. package/dist/integrations/react-admin/dataProvider.d.ts.map +1 -1
  19. package/dist/integrations/react-admin/dataProvider.js +61 -4
  20. package/dist/integrations/react-admin/dataProvider.js.map +1 -1
  21. package/dist/integrations/react-admin/index.d.ts +1 -0
  22. package/dist/integrations/react-admin/index.d.ts.map +1 -1
  23. package/dist/integrations/react-admin/index.js.map +1 -1
  24. package/dist/server/handler.cjs +683 -499
  25. package/dist/server/handler.cjs.map +4 -4
  26. package/dist/server/media-handler.cjs +2 -2
  27. package/dist/server/media-process-handler-dlq.cjs +544 -344
  28. package/dist/server/media-process-handler-dlq.cjs.map +4 -4
  29. package/dist/server/media-process-handler.cjs +543 -343
  30. package/dist/server/media-process-handler.cjs.map +4 -4
  31. package/dist/server/operations/deleteMany.d.ts.map +1 -1
  32. package/dist/server/operations/deleteMany.js +15 -30
  33. package/dist/server/operations/deleteMany.js.map +1 -1
  34. package/dist/server/operations/deleteOne.d.ts.map +1 -1
  35. package/dist/server/operations/deleteOne.js +7 -4
  36. package/dist/server/operations/deleteOne.js.map +1 -1
  37. package/dist/server/operations/find/idQuery.d.ts.map +1 -1
  38. package/dist/server/operations/find/idQuery.js +23 -9
  39. package/dist/server/operations/find/idQuery.js.map +1 -1
  40. package/dist/server/operations/find/nearQuery.d.ts.map +1 -1
  41. package/dist/server/operations/find/nearQuery.js +41 -40
  42. package/dist/server/operations/find/nearQuery.js.map +1 -1
  43. package/dist/server/operations/find/shadowQuery.d.ts +7 -0
  44. package/dist/server/operations/find/shadowQuery.d.ts.map +1 -1
  45. package/dist/server/operations/find/shadowQuery.js +34 -42
  46. package/dist/server/operations/find/shadowQuery.js.map +1 -1
  47. package/dist/server/operations/findAll.d.ts +8 -0
  48. package/dist/server/operations/findAll.d.ts.map +1 -0
  49. package/dist/server/operations/findAll.js +46 -0
  50. package/dist/server/operations/findAll.js.map +1 -0
  51. package/dist/server/operations/findMany.d.ts.map +1 -1
  52. package/dist/server/operations/findMany.js +9 -26
  53. package/dist/server/operations/findMany.js.map +1 -1
  54. package/dist/server/operations/findManyReference.d.ts.map +1 -1
  55. package/dist/server/operations/findManyReference.js +4 -14
  56. package/dist/server/operations/findManyReference.js.map +1 -1
  57. package/dist/server/operations/parameterConverter.d.ts.map +1 -1
  58. package/dist/server/operations/parameterConverter.js +16 -8
  59. package/dist/server/operations/parameterConverter.js.map +1 -1
  60. package/dist/server/operations/updateMany.d.ts.map +1 -1
  61. package/dist/server/operations/updateMany.js +15 -30
  62. package/dist/server/operations/updateMany.js.map +1 -1
  63. package/dist/server/operations/updateOne.d.ts.map +1 -1
  64. package/dist/server/operations/updateOne.js +8 -6
  65. package/dist/server/operations/updateOne.js.map +1 -1
  66. package/dist/server/utils/batchGet.d.ts +21 -0
  67. package/dist/server/utils/batchGet.d.ts.map +1 -0
  68. package/dist/server/utils/batchGet.js +73 -0
  69. package/dist/server/utils/batchGet.js.map +1 -0
  70. package/dist/server/utils/scanWarning.d.ts +30 -0
  71. package/dist/server/utils/scanWarning.d.ts.map +1 -0
  72. package/dist/server/utils/scanWarning.js +63 -0
  73. package/dist/server/utils/scanWarning.js.map +1 -0
  74. package/dist/shared/utils/index.d.ts +1 -0
  75. package/dist/shared/utils/index.d.ts.map +1 -1
  76. package/dist/shared/utils/index.js +1 -0
  77. package/dist/shared/utils/index.js.map +1 -1
  78. package/dist/shared/utils/scanSort.d.ts +16 -0
  79. package/dist/shared/utils/scanSort.d.ts.map +1 -0
  80. package/dist/shared/utils/scanSort.js +33 -0
  81. package/dist/shared/utils/scanSort.js.map +1 -0
  82. package/dist/sharp-layer.zip +0 -0
  83. package/docs/README.md +286 -0
  84. package/docs/SCAN_WARNING.md +81 -0
  85. package/package.json +2 -1
  86. package/terraform/README.md +8 -6
  87. package/terraform/main.tf +40 -1
  88. package/terraform/outputs.tf +13 -0
  89. package/terraform/variables.tf +17 -0
@@ -1,5 +1,5 @@
1
- // @exabugs/dynamodb-client v1.8.0
2
- // Built: 2026-10-11T23:03:45.636Z
1
+ // @exabugs/dynamodb-client v1.10.0
2
+ // Built: 2026-10-11T23:48:57.909Z
3
3
  "use strict";
4
4
  var __create = Object.create;
5
5
  var __defProp = Object.defineProperty;
@@ -1548,12 +1548,12 @@ var require_dist_cjs7 = __commonJS({
1548
1548
  var loggerMiddleware = /* @__PURE__ */ __name(() => (next, context) => async (args) => {
1549
1549
  try {
1550
1550
  const response = await next(args);
1551
- const { clientName, commandName, logger: logger26, dynamoDbDocumentClientOptions = {} } = context;
1551
+ const { clientName, commandName, logger: logger28, dynamoDbDocumentClientOptions = {} } = context;
1552
1552
  const { overrideInputFilterSensitiveLog, overrideOutputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
1553
1553
  const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
1554
1554
  const outputFilterSensitiveLog = overrideOutputFilterSensitiveLog ?? context.outputFilterSensitiveLog;
1555
1555
  const { $metadata, ...outputWithoutMetadata } = response.output;
1556
- logger26?.info?.({
1556
+ logger28?.info?.({
1557
1557
  clientName,
1558
1558
  commandName,
1559
1559
  input: inputFilterSensitiveLog(args.input),
@@ -1562,10 +1562,10 @@ var require_dist_cjs7 = __commonJS({
1562
1562
  });
1563
1563
  return response;
1564
1564
  } catch (error2) {
1565
- const { clientName, commandName, logger: logger26, dynamoDbDocumentClientOptions = {} } = context;
1565
+ const { clientName, commandName, logger: logger28, dynamoDbDocumentClientOptions = {} } = context;
1566
1566
  const { overrideInputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
1567
1567
  const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
1568
- logger26?.error?.({
1568
+ logger28?.error?.({
1569
1569
  clientName,
1570
1570
  commandName,
1571
1571
  input: inputFilterSensitiveLog(args.input),
@@ -3191,19 +3191,19 @@ var init_ProviderError = __esm({
3191
3191
  name = "ProviderError";
3192
3192
  tryNextLink;
3193
3193
  constructor(message, options = true) {
3194
- let logger26;
3194
+ let logger28;
3195
3195
  let tryNextLink = true;
3196
3196
  if (typeof options === "boolean") {
3197
- logger26 = void 0;
3197
+ logger28 = void 0;
3198
3198
  tryNextLink = options;
3199
3199
  } else if (options != null && typeof options === "object") {
3200
- logger26 = options.logger;
3200
+ logger28 = options.logger;
3201
3201
  tryNextLink = options.tryNextLink ?? true;
3202
3202
  }
3203
3203
  super(message);
3204
3204
  this.tryNextLink = tryNextLink;
3205
3205
  Object.setPrototypeOf(this, _ProviderError.prototype);
3206
- logger26?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
3206
+ logger28?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
3207
3207
  }
3208
3208
  static from(error2, options = true) {
3209
3209
  return Object.assign(new this(error2.message, options), error2);
@@ -3636,8 +3636,8 @@ var init_configLoader = __esm({
3636
3636
  init_fromSharedConfigFiles();
3637
3637
  init_fromStatic();
3638
3638
  loadConfig = /* @__PURE__ */ __name(({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => {
3639
- const { signingName, logger: logger26 } = configuration;
3640
- const envOptions = { signingName, logger: logger26 };
3639
+ const { signingName, logger: logger28 } = configuration;
3640
+ const envOptions = { signingName, logger: logger28 };
3641
3641
  return memoize(chain(fromEnv(environmentVariableSelector, envOptions), fromSharedConfigFiles(configFileSelector, configuration), fromStatic(defaultValue)));
3642
3642
  }, "loadConfig");
3643
3643
  }
@@ -5256,7 +5256,7 @@ var init_ByteArrayCollector = __esm({
5256
5256
  });
5257
5257
 
5258
5258
  // node_modules/@smithy/core/dist-es/submodules/serde/util-stream/createBufferedReadable.browser.js
5259
- function createBufferedReadableStream(upstream, size, logger26) {
5259
+ function createBufferedReadableStream(upstream, size, logger28) {
5260
5260
  const reader = upstream.getReader();
5261
5261
  let streamBufferingLoggedWarning = false;
5262
5262
  let bytesSeen = 0;
@@ -5294,7 +5294,7 @@ function createBufferedReadableStream(upstream, size, logger26) {
5294
5294
  const newSize = merge(buffers, mode, chunk);
5295
5295
  if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
5296
5296
  streamBufferingLoggedWarning = true;
5297
- logger26?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
5297
+ logger28?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
5298
5298
  }
5299
5299
  if (newSize >= size) {
5300
5300
  controller.enqueue(flush(buffers, mode));
@@ -5358,9 +5358,9 @@ var init_createBufferedReadable_browser = __esm({
5358
5358
  });
5359
5359
 
5360
5360
  // node_modules/@smithy/core/dist-es/submodules/serde/util-stream/createBufferedReadable.js
5361
- function createBufferedReadable(upstream, size, logger26) {
5361
+ function createBufferedReadable(upstream, size, logger28) {
5362
5362
  if (isReadableStream(upstream)) {
5363
- return createBufferedReadableStream(upstream, size, logger26);
5363
+ return createBufferedReadableStream(upstream, size, logger28);
5364
5364
  }
5365
5365
  const downstream = new import_node_stream2.Readable({ read() {
5366
5366
  } });
@@ -5393,7 +5393,7 @@ function createBufferedReadable(upstream, size, logger26) {
5393
5393
  const newSize = merge(buffers, mode, chunk);
5394
5394
  if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
5395
5395
  streamBufferingLoggedWarning = true;
5396
- logger26?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
5396
+ logger28?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
5397
5397
  }
5398
5398
  if (newSize >= size) {
5399
5399
  downstream.push(flush(buffers, mode));
@@ -9159,7 +9159,7 @@ var require_dist_cjs9 = __commonJS({
9159
9159
  evaluateTreeRule
9160
9160
  };
9161
9161
  var resolveEndpoint4 = /* @__PURE__ */ __name((ruleSetObject, options) => {
9162
- const { endpointParams, logger: logger26 } = options;
9162
+ const { endpointParams, logger: logger28 } = options;
9163
9163
  const { parameters, rules } = ruleSetObject;
9164
9164
  options.logger?.debug?.(`${debugId} Initial EndpointParams: ${toDebugString(endpointParams)}`);
9165
9165
  const paramsWithDefault = Object.entries(parameters).filter(([, v5]) => v5.default != null).map(([k4, v5]) => [k4, v5.default]);
@@ -9174,7 +9174,7 @@ var require_dist_cjs9 = __commonJS({
9174
9174
  throw new EndpointError(`Missing required parameter: '${requiredParam}'`);
9175
9175
  }
9176
9176
  }
9177
- const endpoint = evaluateRules(rules, { endpointParams, logger: logger26, referenceRecord: {} });
9177
+ const endpoint = evaluateRules(rules, { endpointParams, logger: logger28, referenceRecord: {} });
9178
9178
  options.logger?.debug?.(`${debugId} Resolved endpoint: ${toDebugString(endpoint)}`);
9179
9179
  return endpoint;
9180
9180
  }, "resolveEndpoint");
@@ -9961,19 +9961,19 @@ var require_dist_cjs13 = __commonJS({
9961
9961
  name = "ProviderError";
9962
9962
  tryNextLink;
9963
9963
  constructor(message, options = true) {
9964
- let logger26;
9964
+ let logger28;
9965
9965
  let tryNextLink = true;
9966
9966
  if (typeof options === "boolean") {
9967
- logger26 = void 0;
9967
+ logger28 = void 0;
9968
9968
  tryNextLink = options;
9969
9969
  } else if (options != null && typeof options === "object") {
9970
- logger26 = options.logger;
9970
+ logger28 = options.logger;
9971
9971
  tryNextLink = options.tryNextLink ?? true;
9972
9972
  }
9973
9973
  super(message);
9974
9974
  this.tryNextLink = tryNextLink;
9975
9975
  Object.setPrototypeOf(this, _ProviderError.prototype);
9976
- logger26?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
9976
+ logger28?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
9977
9977
  }
9978
9978
  static from(error2, options = true) {
9979
9979
  return Object.assign(new this(error2.message, options), error2);
@@ -12769,9 +12769,9 @@ var require_dist_cjs21 = __commonJS({
12769
12769
  this.middlewareStack.use(mw);
12770
12770
  }
12771
12771
  const stack = clientStack.concat(this.middlewareStack);
12772
- const { logger: logger26 } = configuration;
12772
+ const { logger: logger28 } = configuration;
12773
12773
  const handlerExecutionContext = {
12774
- logger: logger26,
12774
+ logger: logger28,
12775
12775
  clientName,
12776
12776
  commandName,
12777
12777
  inputFilterSensitiveLog,
@@ -16398,11 +16398,11 @@ var require_dist_cjs24 = __commonJS({
16398
16398
  userAgentAppId: /* @__PURE__ */ __name(async () => {
16399
16399
  const appId = await normalizedAppIdProvider();
16400
16400
  if (!isValidUserAgentAppId(appId)) {
16401
- const logger26 = input.logger?.constructor?.name === "NoOpLogger" || !input.logger ? console : input.logger;
16401
+ const logger28 = input.logger?.constructor?.name === "NoOpLogger" || !input.logger ? console : input.logger;
16402
16402
  if (typeof appId !== "string") {
16403
- logger26?.warn("userAgentAppId must be a string or undefined.");
16403
+ logger28?.warn("userAgentAppId must be a string or undefined.");
16404
16404
  } else if (appId.length > 50) {
16405
- logger26?.warn("The provided userAgentAppId exceeds the maximum length of 50 characters.");
16405
+ logger28?.warn("The provided userAgentAppId exceeds the maximum length of 50 characters.");
16406
16406
  }
16407
16407
  }
16408
16408
  return appId;
@@ -17289,8 +17289,8 @@ var require_dist_cjs30 = __commonJS({
17289
17289
  var isFunction2 = /* @__PURE__ */ __name((func) => typeof func === "function", "isFunction");
17290
17290
  var fromStatic2 = /* @__PURE__ */ __name((defaultValue) => isFunction2(defaultValue) ? async () => await defaultValue() : propertyProvider.fromStatic(defaultValue), "fromStatic");
17291
17291
  var loadConfig2 = /* @__PURE__ */ __name(({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => {
17292
- const { signingName, logger: logger26 } = configuration;
17293
- const envOptions = { signingName, logger: logger26 };
17292
+ const { signingName, logger: logger28 } = configuration;
17293
+ const envOptions = { signingName, logger: logger28 };
17294
17294
  return propertyProvider.memoize(propertyProvider.chain(fromEnv2(environmentVariableSelector, envOptions), fromSharedConfigFiles2(configFileSelector, configuration), fromStatic2(defaultValue)));
17295
17295
  }, "loadConfig");
17296
17296
  exports2.loadConfig = loadConfig2;
@@ -19661,7 +19661,7 @@ var require_dist_cjs40 = __commonJS({
19661
19661
  "http:": true,
19662
19662
  "https:": true
19663
19663
  };
19664
- var getCmdsUri = /* @__PURE__ */ __name(async ({ logger: logger26 }) => {
19664
+ var getCmdsUri = /* @__PURE__ */ __name(async ({ logger: logger28 }) => {
19665
19665
  if (process.env[ENV_CMDS_RELATIVE_URI]) {
19666
19666
  return {
19667
19667
  hostname: CMDS_IP,
@@ -19673,13 +19673,13 @@ var require_dist_cjs40 = __commonJS({
19673
19673
  if (!parsed.hostname || !(parsed.hostname in GREENGRASS_HOSTS)) {
19674
19674
  throw new propertyProvider.CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {
19675
19675
  tryNextLink: false,
19676
- logger: logger26
19676
+ logger: logger28
19677
19677
  });
19678
19678
  }
19679
19679
  if (!parsed.protocol || !(parsed.protocol in GREENGRASS_PROTOCOLS)) {
19680
19680
  throw new propertyProvider.CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {
19681
19681
  tryNextLink: false,
19682
- logger: logger26
19682
+ logger: logger28
19683
19683
  });
19684
19684
  }
19685
19685
  return {
@@ -19689,7 +19689,7 @@ var require_dist_cjs40 = __commonJS({
19689
19689
  }
19690
19690
  throw new propertyProvider.CredentialsProviderError(`The container metadata credential provider cannot be used unless the ${ENV_CMDS_RELATIVE_URI} or ${ENV_CMDS_FULL_URI} environment variable is set`, {
19691
19691
  tryNextLink: false,
19692
- logger: logger26
19692
+ logger: logger28
19693
19693
  });
19694
19694
  }, "getCmdsUri");
19695
19695
  var InstanceMetadataV1FallbackError = class _InstanceMetadataV1FallbackError extends propertyProvider.CredentialsProviderError {
@@ -19744,10 +19744,10 @@ var require_dist_cjs40 = __commonJS({
19744
19744
  var STATIC_STABILITY_REFRESH_INTERVAL_SECONDS = 5 * 60;
19745
19745
  var STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS = 5 * 60;
19746
19746
  var STATIC_STABILITY_DOC_URL = "https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html";
19747
- var getExtendedInstanceMetadataCredentials = /* @__PURE__ */ __name((credentials, logger26) => {
19747
+ var getExtendedInstanceMetadataCredentials = /* @__PURE__ */ __name((credentials, logger28) => {
19748
19748
  const refreshInterval = STATIC_STABILITY_REFRESH_INTERVAL_SECONDS + Math.floor(Math.random() * STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS);
19749
19749
  const newExpiration = new Date(Date.now() + refreshInterval * 1e3);
19750
- logger26.warn(`Attempting credential expiration extension due to a credential service availability issue. A refresh of these credentials will be attempted after ${new Date(newExpiration)}.
19750
+ logger28.warn(`Attempting credential expiration extension due to a credential service availability issue. A refresh of these credentials will be attempted after ${new Date(newExpiration)}.
19751
19751
  For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
19752
19752
  const originalExpiration = credentials.originalExpiration ?? credentials.expiration;
19753
19753
  return {
@@ -19757,19 +19757,19 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
19757
19757
  };
19758
19758
  }, "getExtendedInstanceMetadataCredentials");
19759
19759
  var staticStabilityProvider = /* @__PURE__ */ __name((provider, options = {}) => {
19760
- const logger26 = options?.logger || console;
19760
+ const logger28 = options?.logger || console;
19761
19761
  let pastCredentials;
19762
19762
  return async () => {
19763
19763
  let credentials;
19764
19764
  try {
19765
19765
  credentials = await provider();
19766
19766
  if (credentials.expiration && credentials.expiration.getTime() < Date.now()) {
19767
- credentials = getExtendedInstanceMetadataCredentials(credentials, logger26);
19767
+ credentials = getExtendedInstanceMetadataCredentials(credentials, logger28);
19768
19768
  }
19769
19769
  } catch (e4) {
19770
19770
  if (pastCredentials) {
19771
- logger26.warn("Credential renew failed: ", e4);
19772
- credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger26);
19771
+ logger28.warn("Credential renew failed: ", e4);
19772
+ credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger28);
19773
19773
  } else {
19774
19774
  throw e4;
19775
19775
  }
@@ -19786,7 +19786,7 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
19786
19786
  var fromInstanceMetadata = /* @__PURE__ */ __name((init = {}) => staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger }), "fromInstanceMetadata");
19787
19787
  var getInstanceMetadataProvider = /* @__PURE__ */ __name((init = {}) => {
19788
19788
  let disableFetchToken = false;
19789
- const { logger: logger26, profile } = init;
19789
+ const { logger: logger28, profile } = init;
19790
19790
  const { timeout, maxRetries } = providerConfigFromInit(init);
19791
19791
  const getCredentials = /* @__PURE__ */ __name(async (maxRetries2, options) => {
19792
19792
  const isImdsV1Fallback = disableFetchToken || options.headers?.[X_AWS_EC2_METADATA_TOKEN] == null;
@@ -19850,7 +19850,7 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
19850
19850
  return async () => {
19851
19851
  const endpoint = await getInstanceMetadataEndpoint();
19852
19852
  if (disableFetchToken) {
19853
- logger26?.debug("AWS SDK Instance Metadata", "using v1 fallback (no token fetch)");
19853
+ logger28?.debug("AWS SDK Instance Metadata", "using v1 fallback (no token fetch)");
19854
19854
  return getCredentials(maxRetries, { ...endpoint, timeout });
19855
19855
  } else {
19856
19856
  let token;
@@ -19864,7 +19864,7 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
19864
19864
  } else if (error2.message === "TimeoutError" || [403, 404, 405].includes(error2.statusCode)) {
19865
19865
  disableFetchToken = true;
19866
19866
  }
19867
- logger26?.debug("AWS SDK Instance Metadata", "using v1 fallback (initial)");
19867
+ logger28?.debug("AWS SDK Instance Metadata", "using v1 fallback (initial)");
19868
19868
  return getCredentials(maxRetries, { ...endpoint, timeout });
19869
19869
  }
19870
19870
  return getCredentials(maxRetries, {
@@ -20168,7 +20168,7 @@ var require_dist_cjs43 = __commonJS({
20168
20168
  }
20169
20169
  return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME$2), DEFER_EVENT_LISTENER_TIME$2);
20170
20170
  }, "setConnectionTimeout");
20171
- var setRequestTimeout = /* @__PURE__ */ __name((req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger26) => {
20171
+ var setRequestTimeout = /* @__PURE__ */ __name((req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger28) => {
20172
20172
  if (timeoutInMs) {
20173
20173
  return timing.setTimeout(() => {
20174
20174
  let msg = `@smithy/node-http-handler - [${throwOnRequestTimeout ? "ERROR" : "WARN"}] a request has exceeded the configured ${timeoutInMs} ms requestTimeout.`;
@@ -20181,7 +20181,7 @@ var require_dist_cjs43 = __commonJS({
20181
20181
  reject(error2);
20182
20182
  } else {
20183
20183
  msg += ` Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.`;
20184
- logger26?.warn?.(msg);
20184
+ logger28?.warn?.(msg);
20185
20185
  }
20186
20186
  }, timeoutInMs);
20187
20187
  }
@@ -20297,7 +20297,7 @@ var require_dist_cjs43 = __commonJS({
20297
20297
  }
20298
20298
  return new _NodeHttpHandler(instanceOrOptions);
20299
20299
  }
20300
- static checkSocketUsage(agent, socketWarningTimestamp, logger26 = console) {
20300
+ static checkSocketUsage(agent, socketWarningTimestamp, logger28 = console) {
20301
20301
  const { sockets, requests, maxSockets } = agent;
20302
20302
  if (typeof maxSockets !== "number" || maxSockets === Infinity) {
20303
20303
  return socketWarningTimestamp;
@@ -20311,7 +20311,7 @@ var require_dist_cjs43 = __commonJS({
20311
20311
  const socketsInUse = sockets[origin]?.length ?? 0;
20312
20312
  const requestsEnqueued = requests[origin]?.length ?? 0;
20313
20313
  if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
20314
- logger26?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
20314
+ logger28?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
20315
20315
  See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
20316
20316
  or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
20317
20317
  return Date.now();
@@ -20841,7 +20841,7 @@ var require_checkUrl = __commonJS({
20841
20841
  var ECS_CONTAINER_HOST = "169.254.170.2";
20842
20842
  var EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
20843
20843
  var EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
20844
- var checkUrl = /* @__PURE__ */ __name((url, logger26) => {
20844
+ var checkUrl = /* @__PURE__ */ __name((url, logger28) => {
20845
20845
  if (url.protocol === "https:") {
20846
20846
  return;
20847
20847
  }
@@ -20868,7 +20868,7 @@ var require_checkUrl = __commonJS({
20868
20868
  throw new property_provider_1.CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
20869
20869
  - loopback CIDR 127.0.0.0/8 or [::1/128]
20870
20870
  - ECS container host 169.254.170.2
20871
- - EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger: logger26 });
20871
+ - EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger: logger28 });
20872
20872
  }, "checkUrl");
20873
20873
  exports2.checkUrl = checkUrl;
20874
20874
  }
@@ -21085,7 +21085,7 @@ var require_createBufferedReadableStream = __commonJS({
21085
21085
  exports2.sizeOf = sizeOf2;
21086
21086
  exports2.modeOf = modeOf2;
21087
21087
  var ByteArrayCollector_1 = require_ByteArrayCollector();
21088
- function createBufferedReadableStream2(upstream, size, logger26) {
21088
+ function createBufferedReadableStream2(upstream, size, logger28) {
21089
21089
  const reader = upstream.getReader();
21090
21090
  let streamBufferingLoggedWarning = false;
21091
21091
  let bytesSeen = 0;
@@ -21123,7 +21123,7 @@ var require_createBufferedReadableStream = __commonJS({
21123
21123
  const newSize = merge2(buffers, mode, chunk);
21124
21124
  if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
21125
21125
  streamBufferingLoggedWarning = true;
21126
- logger26?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
21126
+ logger28?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
21127
21127
  }
21128
21128
  if (newSize >= size) {
21129
21129
  controller.enqueue(flush2(buffers, mode));
@@ -21194,9 +21194,9 @@ var require_createBufferedReadable = __commonJS({
21194
21194
  var ByteArrayCollector_1 = require_ByteArrayCollector();
21195
21195
  var createBufferedReadableStream_1 = require_createBufferedReadableStream();
21196
21196
  var stream_type_check_1 = require_stream_type_check();
21197
- function createBufferedReadable2(upstream, size, logger26) {
21197
+ function createBufferedReadable2(upstream, size, logger28) {
21198
21198
  if ((0, stream_type_check_1.isReadableStream)(upstream)) {
21199
- return (0, createBufferedReadableStream_1.createBufferedReadableStream)(upstream, size, logger26);
21199
+ return (0, createBufferedReadableStream_1.createBufferedReadableStream)(upstream, size, logger28);
21200
21200
  }
21201
21201
  const downstream = new node_stream_1.Readable({ read() {
21202
21202
  } });
@@ -21229,7 +21229,7 @@ var require_createBufferedReadable = __commonJS({
21229
21229
  const newSize = (0, createBufferedReadableStream_1.merge)(buffers, mode, chunk);
21230
21230
  if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
21231
21231
  streamBufferingLoggedWarning = true;
21232
- logger26?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
21232
+ logger28?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
21233
21233
  }
21234
21234
  if (newSize >= size) {
21235
21235
  downstream.push((0, createBufferedReadableStream_1.flush)(buffers, mode));
@@ -22071,13 +22071,13 @@ var require_requestHelpers = __commonJS({
22071
22071
  });
22072
22072
  }
22073
22073
  __name(createGetRequest, "createGetRequest");
22074
- async function getCredentials(response, logger26) {
22074
+ async function getCredentials(response, logger28) {
22075
22075
  const stream = (0, util_stream_1.sdkStreamMixin)(response.body);
22076
22076
  const str = await stream.transformToString();
22077
22077
  if (response.statusCode === 200) {
22078
22078
  const parsed = JSON.parse(str);
22079
22079
  if (typeof parsed.AccessKeyId !== "string" || typeof parsed.SecretAccessKey !== "string" || typeof parsed.Token !== "string" || typeof parsed.Expiration !== "string") {
22080
- throw new property_provider_1.CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: { AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger: logger26 });
22080
+ throw new property_provider_1.CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: { AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger: logger28 });
22081
22081
  }
22082
22082
  return {
22083
22083
  accessKeyId: parsed.AccessKeyId,
@@ -22092,12 +22092,12 @@ var require_requestHelpers = __commonJS({
22092
22092
  parsedBody = JSON.parse(str);
22093
22093
  } catch (e4) {
22094
22094
  }
22095
- throw Object.assign(new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger: logger26 }), {
22095
+ throw Object.assign(new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger: logger28 }), {
22096
22096
  Code: parsedBody.Code,
22097
22097
  Message: parsedBody.Message
22098
22098
  });
22099
22099
  }
22100
- throw new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger: logger26 });
22100
+ throw new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger: logger28 });
22101
22101
  }
22102
22102
  __name(getCredentials, "getCredentials");
22103
22103
  }
@@ -23461,14 +23461,14 @@ var require_dist_cjs53 = __commonJS({
23461
23461
  var propertyProvider = require_dist_cjs13();
23462
23462
  var sharedIniFileLoader = require_dist_cjs29();
23463
23463
  var fs = require("fs");
23464
- var fromEnvSigningName = /* @__PURE__ */ __name(({ logger: logger26, signingName } = {}) => async () => {
23465
- logger26?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
23464
+ var fromEnvSigningName = /* @__PURE__ */ __name(({ logger: logger28, signingName } = {}) => async () => {
23465
+ logger28?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
23466
23466
  if (!signingName) {
23467
- throw new propertyProvider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger: logger26 });
23467
+ throw new propertyProvider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger: logger28 });
23468
23468
  }
23469
23469
  const bearerTokenKey = httpAuthSchemes.getBearerTokenEnvKey(signingName);
23470
23470
  if (!(bearerTokenKey in process.env)) {
23471
- throw new propertyProvider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger: logger26 });
23471
+ throw new propertyProvider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger: logger28 });
23472
23472
  }
23473
23473
  const token = { token: process.env[bearerTokenKey] };
23474
23474
  client.setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
@@ -23589,8 +23589,8 @@ var require_dist_cjs53 = __commonJS({
23589
23589
  return existingToken;
23590
23590
  }
23591
23591
  }, "fromSso");
23592
- var fromStatic2 = /* @__PURE__ */ __name(({ token, logger: logger26 }) => async () => {
23593
- logger26?.debug("@aws-sdk/token-providers - fromStatic");
23592
+ var fromStatic2 = /* @__PURE__ */ __name(({ token, logger: logger28 }) => async () => {
23593
+ logger28?.debug("@aws-sdk/token-providers - fromStatic");
23594
23594
  if (!token || !token.token) {
23595
23595
  throw new propertyProvider.TokenProviderError(`Please pass a valid token to fromStatic`, false);
23596
23596
  }
@@ -24379,7 +24379,7 @@ var require_dist_cjs55 = __commonJS({
24379
24379
  var tokenProviders = require_dist_cjs53();
24380
24380
  var isSsoProfile = /* @__PURE__ */ __name((arg) => arg && (typeof arg.sso_start_url === "string" || typeof arg.sso_account_id === "string" || typeof arg.sso_session === "string" || typeof arg.sso_region === "string" || typeof arg.sso_role_name === "string"), "isSsoProfile");
24381
24381
  var SHOULD_FAIL_CREDENTIAL_CHAIN = false;
24382
- var resolveSSOCredentials = /* @__PURE__ */ __name(async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, profile, filepath, configFilepath, ignoreCache, logger: logger26 }) => {
24382
+ var resolveSSOCredentials = /* @__PURE__ */ __name(async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, profile, filepath, configFilepath, ignoreCache, logger: logger28 }) => {
24383
24383
  let token;
24384
24384
  const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
24385
24385
  if (ssoSession) {
@@ -24397,7 +24397,7 @@ var require_dist_cjs55 = __commonJS({
24397
24397
  } catch (e4) {
24398
24398
  throw new propertyProvider.CredentialsProviderError(e4.message, {
24399
24399
  tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
24400
- logger: logger26
24400
+ logger: logger28
24401
24401
  });
24402
24402
  }
24403
24403
  } else {
@@ -24406,14 +24406,14 @@ var require_dist_cjs55 = __commonJS({
24406
24406
  } catch (e4) {
24407
24407
  throw new propertyProvider.CredentialsProviderError(`The SSO session associated with this profile is invalid. ${refreshMessage}`, {
24408
24408
  tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
24409
- logger: logger26
24409
+ logger: logger28
24410
24410
  });
24411
24411
  }
24412
24412
  }
24413
24413
  if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
24414
24414
  throw new propertyProvider.CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`, {
24415
24415
  tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
24416
- logger: logger26
24416
+ logger: logger28
24417
24417
  });
24418
24418
  }
24419
24419
  const { accessToken } = token;
@@ -24435,14 +24435,14 @@ var require_dist_cjs55 = __commonJS({
24435
24435
  } catch (e4) {
24436
24436
  throw new propertyProvider.CredentialsProviderError(e4, {
24437
24437
  tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
24438
- logger: logger26
24438
+ logger: logger28
24439
24439
  });
24440
24440
  }
24441
24441
  const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope, accountId } = {} } = ssoResp;
24442
24442
  if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
24443
24443
  throw new propertyProvider.CredentialsProviderError("SSO returns an invalid temporary credential.", {
24444
24444
  tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
24445
- logger: logger26
24445
+ logger: logger28
24446
24446
  });
24447
24447
  }
24448
24448
  const credentials = {
@@ -24460,11 +24460,11 @@ var require_dist_cjs55 = __commonJS({
24460
24460
  }
24461
24461
  return credentials;
24462
24462
  }, "resolveSSOCredentials");
24463
- var validateSsoProfile = /* @__PURE__ */ __name((profile, logger26) => {
24463
+ var validateSsoProfile = /* @__PURE__ */ __name((profile, logger28) => {
24464
24464
  const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
24465
24465
  if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
24466
24466
  throw new propertyProvider.CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", "sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(profile).join(", ")}
24467
- Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger: logger26 });
24467
+ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger: logger28 });
24468
24468
  }
24469
24469
  return profile;
24470
24470
  }, "validateSsoProfile");
@@ -25247,7 +25247,7 @@ var require_dist_cjs56 = __commonJS({
25247
25247
  }
25248
25248
  async refresh(token) {
25249
25249
  const { SigninClient: SigninClient2, CreateOAuth2TokenCommand: CreateOAuth2TokenCommand2 } = await Promise.resolve().then(() => (init_signin(), signin_exports));
25250
- const { logger: logger26, userAgentAppId } = this.callerClientConfig ?? {};
25250
+ const { logger: logger28, userAgentAppId } = this.callerClientConfig ?? {};
25251
25251
  const isH22 = /* @__PURE__ */ __name((requestHandler2) => {
25252
25252
  return requestHandler2?.metadata?.handlerProtocol === "h2";
25253
25253
  }, "isH2");
@@ -25260,7 +25260,7 @@ var require_dist_cjs56 = __commonJS({
25260
25260
  },
25261
25261
  region,
25262
25262
  requestHandler,
25263
- logger: logger26,
25263
+ logger: logger28,
25264
25264
  userAgentAppId,
25265
25265
  ...this.init?.clientConfig
25266
25266
  });
@@ -26278,9 +26278,9 @@ var init_defaultStsRoleAssumers = __esm({
26278
26278
  return async (sourceCreds, params) => {
26279
26279
  closureSourceCreds = sourceCreds;
26280
26280
  if (!stsClient) {
26281
- const { logger: logger26 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
26281
+ const { logger: logger28 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
26282
26282
  const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
26283
- logger: logger26,
26283
+ logger: logger28,
26284
26284
  profile
26285
26285
  });
26286
26286
  const isCompatibleRequestHandler = !isH2(requestHandler);
@@ -26291,7 +26291,7 @@ var init_defaultStsRoleAssumers = __esm({
26291
26291
  credentialDefaultProvider: /* @__PURE__ */ __name(() => async () => closureSourceCreds, "credentialDefaultProvider"),
26292
26292
  region: resolvedRegion,
26293
26293
  requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
26294
- logger: logger26
26294
+ logger: logger28
26295
26295
  });
26296
26296
  }
26297
26297
  const { Credentials: Credentials2, AssumedRoleUser: AssumedRoleUser2 } = await stsClient.send(new AssumeRoleCommand(params));
@@ -26315,9 +26315,9 @@ var init_defaultStsRoleAssumers = __esm({
26315
26315
  let stsClient;
26316
26316
  return async (params) => {
26317
26317
  if (!stsClient) {
26318
- const { logger: logger26 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
26318
+ const { logger: logger28 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
26319
26319
  const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
26320
- logger: logger26,
26320
+ logger: logger28,
26321
26321
  profile
26322
26322
  });
26323
26323
  const isCompatibleRequestHandler = !isH2(requestHandler);
@@ -26327,7 +26327,7 @@ var init_defaultStsRoleAssumers = __esm({
26327
26327
  profile,
26328
26328
  region: resolvedRegion,
26329
26329
  requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
26330
- logger: logger26
26330
+ logger: logger28
26331
26331
  });
26332
26332
  }
26333
26333
  const { Credentials: Credentials2, AssumedRoleUser: AssumedRoleUser2 } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
@@ -26457,7 +26457,7 @@ var require_dist_cjs57 = __commonJS({
26457
26457
  client.setCredentialFeature(credentials, "CREDENTIALS_PROCESS", "w");
26458
26458
  return credentials;
26459
26459
  }, "getValidatedProcessCredentials");
26460
- var resolveProcessCredentials = /* @__PURE__ */ __name(async (profileName, profiles, logger26) => {
26460
+ var resolveProcessCredentials = /* @__PURE__ */ __name(async (profileName, profiles, logger28) => {
26461
26461
  const profile = profiles[profileName];
26462
26462
  if (profiles[profileName]) {
26463
26463
  const credentialProcess = profile["credential_process"];
@@ -26473,14 +26473,14 @@ var require_dist_cjs57 = __commonJS({
26473
26473
  }
26474
26474
  return getValidatedProcessCredentials(profileName, data, profiles);
26475
26475
  } catch (error2) {
26476
- throw new propertyProvider.CredentialsProviderError(error2.message, { logger: logger26 });
26476
+ throw new propertyProvider.CredentialsProviderError(error2.message, { logger: logger28 });
26477
26477
  }
26478
26478
  } else {
26479
- throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger: logger26 });
26479
+ throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger: logger28 });
26480
26480
  }
26481
26481
  } else {
26482
26482
  throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`, {
26483
- logger: logger26
26483
+ logger: logger28
26484
26484
  });
26485
26485
  }
26486
26486
  }, "resolveProcessCredentials");
@@ -26639,21 +26639,21 @@ var require_dist_cjs59 = __commonJS({
26639
26639
  var propertyProvider = require_dist_cjs13();
26640
26640
  var client = (init_client(), __toCommonJS(client_exports));
26641
26641
  var credentialProviderLogin = require_dist_cjs56();
26642
- var resolveCredentialSource = /* @__PURE__ */ __name((credentialSource, profileName, logger26) => {
26642
+ var resolveCredentialSource = /* @__PURE__ */ __name((credentialSource, profileName, logger28) => {
26643
26643
  const sourceProvidersMap = {
26644
26644
  EcsContainer: /* @__PURE__ */ __name(async (options) => {
26645
26645
  const { fromHttp } = await Promise.resolve().then(() => __toESM(require_dist_cjs47()));
26646
26646
  const { fromContainerMetadata } = await Promise.resolve().then(() => __toESM(require_dist_cjs40()));
26647
- logger26?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
26647
+ logger28?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
26648
26648
  return async () => propertyProvider.chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
26649
26649
  }, "EcsContainer"),
26650
26650
  Ec2InstanceMetadata: /* @__PURE__ */ __name(async (options) => {
26651
- logger26?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
26651
+ logger28?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
26652
26652
  const { fromInstanceMetadata } = await Promise.resolve().then(() => __toESM(require_dist_cjs40()));
26653
26653
  return async () => fromInstanceMetadata(options)().then(setNamedProvider);
26654
26654
  }, "Ec2InstanceMetadata"),
26655
26655
  Environment: /* @__PURE__ */ __name(async (options) => {
26656
- logger26?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
26656
+ logger28?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
26657
26657
  const { fromEnv: fromEnv2 } = await Promise.resolve().then(() => __toESM(require_dist_cjs39()));
26658
26658
  return async () => fromEnv2(options)().then(setNamedProvider);
26659
26659
  }, "Environment")
@@ -26661,24 +26661,24 @@ var require_dist_cjs59 = __commonJS({
26661
26661
  if (credentialSource in sourceProvidersMap) {
26662
26662
  return sourceProvidersMap[credentialSource];
26663
26663
  } else {
26664
- throw new propertyProvider.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger: logger26 });
26664
+ throw new propertyProvider.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger: logger28 });
26665
26665
  }
26666
26666
  }, "resolveCredentialSource");
26667
26667
  var setNamedProvider = /* @__PURE__ */ __name((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p"), "setNamedProvider");
26668
- var isAssumeRoleProfile = /* @__PURE__ */ __name((arg, { profile = "default", logger: logger26 } = {}) => {
26669
- return Boolean(arg) && typeof arg === "object" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 && ["undefined", "string"].indexOf(typeof arg.external_id) > -1 && ["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 && (isAssumeRoleWithSourceProfile(arg, { profile, logger: logger26 }) || isCredentialSourceProfile(arg, { profile, logger: logger26 }));
26668
+ var isAssumeRoleProfile = /* @__PURE__ */ __name((arg, { profile = "default", logger: logger28 } = {}) => {
26669
+ return Boolean(arg) && typeof arg === "object" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 && ["undefined", "string"].indexOf(typeof arg.external_id) > -1 && ["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 && (isAssumeRoleWithSourceProfile(arg, { profile, logger: logger28 }) || isCredentialSourceProfile(arg, { profile, logger: logger28 }));
26670
26670
  }, "isAssumeRoleProfile");
26671
- var isAssumeRoleWithSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger: logger26 }) => {
26671
+ var isAssumeRoleWithSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger: logger28 }) => {
26672
26672
  const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
26673
26673
  if (withSourceProfile) {
26674
- logger26?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
26674
+ logger28?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
26675
26675
  }
26676
26676
  return withSourceProfile;
26677
26677
  }, "isAssumeRoleWithSourceProfile");
26678
- var isCredentialSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger: logger26 }) => {
26678
+ var isCredentialSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger: logger28 }) => {
26679
26679
  const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
26680
26680
  if (withProviderProfile) {
26681
- logger26?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
26681
+ logger28?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
26682
26682
  }
26683
26683
  return withProviderProfile;
26684
26684
  }, "isCredentialSourceProfile");
@@ -27292,7 +27292,7 @@ var require_dist_cjs62 = __commonJS({
27292
27292
  return value;
27293
27293
  };
27294
27294
  }, "getCircularReplacer");
27295
- var sleep = /* @__PURE__ */ __name((seconds) => {
27295
+ var sleep2 = /* @__PURE__ */ __name((seconds) => {
27296
27296
  return new Promise((resolve) => setTimeout(resolve, seconds * 1e3));
27297
27297
  }, "sleep");
27298
27298
  var waiterServiceDefaults = {
@@ -27359,7 +27359,7 @@ var require_dist_cjs62 = __commonJS({
27359
27359
  if (Date.now() + delay * 1e3 > waitUntil) {
27360
27360
  return { state: exports2.WaiterState.TIMEOUT, observedResponses };
27361
27361
  }
27362
- await sleep(delay);
27362
+ await sleep2(delay);
27363
27363
  const { state: state3, reason: reason2 } = await acceptorChecks(client, input);
27364
27364
  if (reason2) {
27365
27365
  const message = createMessageFromResponse(reason2);
@@ -32199,7 +32199,7 @@ var require_dist_cjs65 = __commonJS({
32199
32199
  return async () => handler2(this.clientCommand);
32200
32200
  }
32201
32201
  };
32202
- var BatchGetCommand7 = class extends DynamoDBDocumentClientCommand {
32202
+ var BatchGetCommand2 = class extends DynamoDBDocumentClientCommand {
32203
32203
  static {
32204
32204
  __name(this, "BatchGetCommand");
32205
32205
  }
@@ -32702,7 +32702,7 @@ var require_dist_cjs65 = __commonJS({
32702
32702
  }
32703
32703
  }
32704
32704
  batchGet(args, optionsOrCb, cb) {
32705
- const command = new BatchGetCommand7(args);
32705
+ const command = new BatchGetCommand2(args);
32706
32706
  if (typeof optionsOrCb === "function") {
32707
32707
  this.send(command, optionsOrCb);
32708
32708
  } else if (typeof cb === "function") {
@@ -32879,7 +32879,7 @@ var require_dist_cjs65 = __commonJS({
32879
32879
  }, "get")
32880
32880
  });
32881
32881
  exports2.BatchExecuteStatementCommand = BatchExecuteStatementCommand;
32882
- exports2.BatchGetCommand = BatchGetCommand7;
32882
+ exports2.BatchGetCommand = BatchGetCommand2;
32883
32883
  exports2.BatchWriteCommand = BatchWriteCommand;
32884
32884
  exports2.DeleteCommand = DeleteCommand;
32885
32885
  exports2.DynamoDBDocument = DynamoDBDocument;
@@ -32927,6 +32927,27 @@ var init_dynamodb = __esm({
32927
32927
  }
32928
32928
  });
32929
32929
 
32930
+ // src/shared/utils/scanSort.ts
32931
+ function chooseScanSortField(filter) {
32932
+ const keys = Object.keys(filter);
32933
+ if (keys.length !== 1) {
32934
+ return "id";
32935
+ }
32936
+ const [key] = keys;
32937
+ const value = filter[key];
32938
+ const isPlainField = !key.includes(":") && !key.includes(".") && key !== "id";
32939
+ const isSafeString = typeof value === "string" && value.length > 0 && new TextEncoder().encode(value).length <= 64 && // 空白や '#' はシャドーの SK でエスケープされ、'id' を含む値は SK の区切りと紛らわしくなる
32940
+ // (extractRecordIds は最後の '#id#' で分けるが、念のため避ける)
32941
+ !/[\s#]/.test(value) && value !== "id" && !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(value);
32942
+ return isPlainField && isSafeString ? key : "id";
32943
+ }
32944
+ var init_scanSort = __esm({
32945
+ "src/shared/utils/scanSort.ts"() {
32946
+ "use strict";
32947
+ __name(chooseScanSortField, "chooseScanSortField");
32948
+ }
32949
+ });
32950
+
32930
32951
  // src/shared/utils/index.ts
32931
32952
  var init_utils3 = __esm({
32932
32953
  "src/shared/utils/index.ts"() {
@@ -32935,6 +32956,7 @@ var init_utils3 = __esm({
32935
32956
  init_ulid();
32936
32957
  init_validation();
32937
32958
  init_dynamodb();
32959
+ init_scanSort();
32938
32960
  }
32939
32961
  });
32940
32962
 
@@ -33704,10 +33726,144 @@ var init_shadow = __esm({
33704
33726
  }
33705
33727
  });
33706
33728
 
33729
+ // src/server/utils/dynamodb.ts
33730
+ function getDBClient() {
33731
+ if (!dbClient) {
33732
+ dbClient = createDynamoDBClient({
33733
+ region: process.env.AWS_REGION || process.env.REGION
33734
+ });
33735
+ }
33736
+ return dbClient;
33737
+ }
33738
+ function getTableName() {
33739
+ const tableName = process.env.TABLE_NAME;
33740
+ if (!tableName) {
33741
+ throw new ConfigError("TABLE_NAME environment variable is not set");
33742
+ }
33743
+ return tableName;
33744
+ }
33745
+ function removeShadowKeys(record) {
33746
+ const { __shadowKeys, ...rest } = record;
33747
+ return rest;
33748
+ }
33749
+ function extractCleanRecord(item) {
33750
+ const data = item.data || item;
33751
+ return removeShadowKeys(data);
33752
+ }
33753
+ async function executeDynamoDBOperation(operation2, operationName) {
33754
+ try {
33755
+ return await operation2();
33756
+ } catch (error2) {
33757
+ if (error2 instanceof Error && error2.name === "AccessDeniedException") {
33758
+ logger2.error("DynamoDB access denied", {
33759
+ errorName: error2.name,
33760
+ errorMessage: error2.message,
33761
+ operation: operationName,
33762
+ tableName: process.env.TABLE_NAME,
33763
+ region: process.env.AWS_REGION || process.env.REGION
33764
+ });
33765
+ throw new Error(`Insufficient permissions to access DynamoDB: ${operationName}`);
33766
+ }
33767
+ throw error2;
33768
+ }
33769
+ }
33770
+ var logger2, dbClient;
33771
+ var init_dynamodb3 = __esm({
33772
+ "src/server/utils/dynamodb.ts"() {
33773
+ "use strict";
33774
+ init_shared();
33775
+ logger2 = createLogger({ service: "records-lambda" });
33776
+ dbClient = null;
33777
+ __name(getDBClient, "getDBClient");
33778
+ __name(getTableName, "getTableName");
33779
+ __name(removeShadowKeys, "removeShadowKeys");
33780
+ __name(extractCleanRecord, "extractCleanRecord");
33781
+ __name(executeDynamoDBOperation, "executeDynamoDBOperation");
33782
+ }
33783
+ });
33784
+
33785
+ // src/server/utils/batchGet.ts
33786
+ function sleep(ms) {
33787
+ return new Promise((resolve) => setTimeout(resolve, ms));
33788
+ }
33789
+ async function batchGetAll(keys, { consistentRead, costTracker, requestId, baseDelayMs = 50 }) {
33790
+ const unique = Array.from(new Map(keys.map((k4) => [`${k4.PK}\0${k4.SK}`, k4])).values());
33791
+ if (unique.length === 0) {
33792
+ return [];
33793
+ }
33794
+ const dbClient2 = getDBClient();
33795
+ const tableName = getTableName();
33796
+ const records = [];
33797
+ for (let i4 = 0; i4 < unique.length; i4 += BATCH_GET_MAX_KEYS) {
33798
+ let pending = unique.slice(i4, i4 + BATCH_GET_MAX_KEYS);
33799
+ for (let attempt = 0; pending.length > 0; attempt++) {
33800
+ if (attempt > BATCH_GET_MAX_RETRIES) {
33801
+ logger3.error("BatchGetItem \u306E UnprocessedKeys \u304C\u89E3\u6D88\u3057\u306A\u304B\u3063\u305F", {
33802
+ requestId,
33803
+ unprocessed: pending.length,
33804
+ attempts: attempt
33805
+ });
33806
+ throw new AppError(
33807
+ "INTERNAL_ERROR" /* INTERNAL_ERROR */,
33808
+ "BatchGetItem still has unprocessed keys after retries",
33809
+ 503,
33810
+ { unprocessed: pending.length }
33811
+ );
33812
+ }
33813
+ if (attempt > 0) {
33814
+ await sleep(baseDelayMs * 2 ** (attempt - 1) * (0.5 + Math.random() / 2));
33815
+ }
33816
+ const keysToGet = pending;
33817
+ const result = await executeDynamoDBOperation(
33818
+ () => dbClient2.send(
33819
+ new import_lib_dynamodb2.BatchGetCommand({
33820
+ RequestItems: {
33821
+ [tableName]: {
33822
+ Keys: keysToGet,
33823
+ ConsistentRead: consistentRead
33824
+ }
33825
+ },
33826
+ ReturnConsumedCapacity: "TOTAL"
33827
+ })
33828
+ ),
33829
+ "BatchGetItem"
33830
+ );
33831
+ if (costTracker) {
33832
+ const capacity = result.ConsumedCapacity;
33833
+ if (Array.isArray(capacity)) {
33834
+ capacity.forEach((c4) => costTracker.add(c4));
33835
+ } else {
33836
+ costTracker.add(capacity);
33837
+ }
33838
+ }
33839
+ records.push(...result.Responses?.[tableName] ?? []);
33840
+ pending = result.UnprocessedKeys?.[tableName]?.Keys ?? [];
33841
+ }
33842
+ }
33843
+ return records;
33844
+ }
33845
+ var import_lib_dynamodb2, logger3, BATCH_GET_MAX_KEYS, BATCH_GET_MAX_RETRIES;
33846
+ var init_batchGet = __esm({
33847
+ "src/server/utils/batchGet.ts"() {
33848
+ "use strict";
33849
+ import_lib_dynamodb2 = __toESM(require_dist_cjs65(), 1);
33850
+ init_shared();
33851
+ init_dynamodb3();
33852
+ logger3 = createLogger({
33853
+ service: "batch-get",
33854
+ level: process.env.LOG_LEVEL || "info"
33855
+ });
33856
+ BATCH_GET_MAX_KEYS = 100;
33857
+ BATCH_GET_MAX_RETRIES = 8;
33858
+ __name(sleep, "sleep");
33859
+ __name(batchGetAll, "batchGetAll");
33860
+ }
33861
+ });
33862
+
33707
33863
  // src/server/utils/bulkOperations.ts
33708
33864
  function logLargeBatchWarning(operation2, recordCount, requestId, resource) {
33709
33865
  if (recordCount > LARGE_BATCH_WARNING_THRESHOLD) {
33710
- logger2.warn(`Large batch ${operation2} operation detected`, {
33866
+ logger4.warn(`Large batch ${operation2} operation detected`, {
33711
33867
  requestId,
33712
33868
  resource,
33713
33869
  recordCount,
@@ -33730,7 +33886,7 @@ function calculateTimeoutRisk(startTime) {
33730
33886
  };
33731
33887
  }
33732
33888
  function logPreparationTimeoutRisk(requestId, resource, totalRecords, chunkCount, riskInfo) {
33733
- logger2.info("Records prepared for chunk execution", {
33889
+ logger4.info("Records prepared for chunk execution", {
33734
33890
  requestId,
33735
33891
  resource,
33736
33892
  totalRecords,
@@ -33740,7 +33896,7 @@ function logPreparationTimeoutRisk(requestId, resource, totalRecords, chunkCount
33740
33896
  timeoutRisk: riskInfo.risk
33741
33897
  });
33742
33898
  if (riskInfo.risk === "high") {
33743
- logger2.warn("High timeout risk detected during preparation phase", {
33899
+ logger4.warn("High timeout risk detected during preparation phase", {
33744
33900
  requestId,
33745
33901
  resource,
33746
33902
  preparationElapsedMs: riskInfo.elapsedMs,
@@ -33752,7 +33908,7 @@ function logPreparationTimeoutRisk(requestId, resource, totalRecords, chunkCount
33752
33908
  }
33753
33909
  function logBulkOperationComplete(operation2, requestId, resource, requested, succeeded, failed, riskInfo, additionalInfo) {
33754
33910
  const totalElapsedSeconds = Math.round(riskInfo.elapsedMs / 1e3);
33755
- logger2.info(`${operation2} completed`, {
33911
+ logger4.info(`${operation2} completed`, {
33756
33912
  requestId,
33757
33913
  resource,
33758
33914
  requested,
@@ -33767,7 +33923,7 @@ function logBulkOperationComplete(operation2, requestId, resource, requested, su
33767
33923
  }
33768
33924
  function logPartialFailure(operation2, requestId, resource, requested, succeeded, failed, errorCodes, additionalInfo) {
33769
33925
  const failureRate = Math.round(failed / requested * 100);
33770
- logger2.warn(`Partial failure in ${operation2} operation`, {
33926
+ logger4.warn(`Partial failure in ${operation2} operation`, {
33771
33927
  requestId,
33772
33928
  resource,
33773
33929
  totalRequested: requested,
@@ -33778,12 +33934,12 @@ function logPartialFailure(operation2, requestId, resource, requested, succeeded
33778
33934
  ...additionalInfo
33779
33935
  });
33780
33936
  }
33781
- var logger2;
33937
+ var logger4;
33782
33938
  var init_bulkOperations = __esm({
33783
33939
  "src/server/utils/bulkOperations.ts"() {
33784
33940
  "use strict";
33785
33941
  init_shared();
33786
- logger2 = createLogger({ service: "records-lambda" });
33942
+ logger4 = createLogger({ service: "records-lambda" });
33787
33943
  __name(logLargeBatchWarning, "logLargeBatchWarning");
33788
33944
  __name(calculateTimeoutRisk, "calculateTimeoutRisk");
33789
33945
  __name(logPreparationTimeoutRisk, "logPreparationTimeoutRisk");
@@ -33802,7 +33958,7 @@ function calculateChunks(records, getItemCount) {
33802
33958
  const itemCount = getItemCount(record);
33803
33959
  if (itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS) {
33804
33960
  const errorMsg = `Single record exceeds ${DYNAMODB_TRANSACT_WRITE_MAX_ITEMS} items limit: ${itemCount} items`;
33805
- logger3.error("Chunk validation failed", {
33961
+ logger5.error("Chunk validation failed", {
33806
33962
  itemCount,
33807
33963
  limit: DYNAMODB_TRANSACT_WRITE_MAX_ITEMS
33808
33964
  });
@@ -33824,7 +33980,7 @@ function calculateChunks(records, getItemCount) {
33824
33980
  chunks.push(currentChunk);
33825
33981
  itemCounts.push(currentItemCount);
33826
33982
  }
33827
- logger3.info("Chunk calculation completed", {
33983
+ logger5.info("Chunk calculation completed", {
33828
33984
  totalRecords: records.length,
33829
33985
  chunkCount: chunks.length,
33830
33986
  itemCounts,
@@ -33840,7 +33996,7 @@ async function executeChunks(chunks, executeChunk, getRecordId) {
33840
33996
  const errors = [];
33841
33997
  const totalRecords = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
33842
33998
  const executionStartTime = Date.now();
33843
- logger3.info("Starting chunk execution", {
33999
+ logger5.info("Starting chunk execution", {
33844
34000
  totalChunks: chunks.length,
33845
34001
  totalRecords
33846
34002
  });
@@ -33848,14 +34004,14 @@ async function executeChunks(chunks, executeChunk, getRecordId) {
33848
34004
  const chunk = chunks[i4];
33849
34005
  const chunkStartTime = Date.now();
33850
34006
  try {
33851
- logger3.debug(`Executing chunk ${i4 + 1}/${chunks.length}`, {
34007
+ logger5.debug(`Executing chunk ${i4 + 1}/${chunks.length}`, {
33852
34008
  chunkIndex: i4,
33853
34009
  recordCount: chunk.length
33854
34010
  });
33855
34011
  const successfulRecords = await executeChunk(chunk);
33856
34012
  successRecords.push(...successfulRecords);
33857
34013
  const chunkDuration = Date.now() - chunkStartTime;
33858
- logger3.info(`Chunk ${i4 + 1}/${chunks.length} succeeded`, {
34014
+ logger5.info(`Chunk ${i4 + 1}/${chunks.length} succeeded`, {
33859
34015
  chunkIndex: i4,
33860
34016
  recordCount: chunk.length,
33861
34017
  durationMs: chunkDuration
@@ -33864,7 +34020,7 @@ async function executeChunks(chunks, executeChunk, getRecordId) {
33864
34020
  const chunkDuration = Date.now() - chunkStartTime;
33865
34021
  const errorMessage = error2 instanceof Error ? error2.message : "Unknown error";
33866
34022
  const errorCode = getErrorCode(error2);
33867
- logger3.error(`Chunk ${i4 + 1}/${chunks.length} failed`, {
34023
+ logger5.error(`Chunk ${i4 + 1}/${chunks.length} failed`, {
33868
34024
  chunkIndex: i4,
33869
34025
  recordCount: chunk.length,
33870
34026
  durationMs: chunkDuration,
@@ -33883,7 +34039,7 @@ async function executeChunks(chunks, executeChunk, getRecordId) {
33883
34039
  }
33884
34040
  }
33885
34041
  const totalExecutionTime = Date.now() - executionStartTime;
33886
- logger3.info("Chunk execution completed", {
34042
+ logger5.info("Chunk execution completed", {
33887
34043
  totalChunks: chunks.length,
33888
34044
  totalRecords,
33889
34045
  successCount: successRecords.length,
@@ -33892,7 +34048,7 @@ async function executeChunks(chunks, executeChunk, getRecordId) {
33892
34048
  avgTimePerChunkMs: chunks.length > 0 ? Math.round(totalExecutionTime / chunks.length) : 0
33893
34049
  });
33894
34050
  if (failedIds.length > 0) {
33895
- logger3.warn("Partial failure detected in chunk execution", {
34051
+ logger5.warn("Partial failure detected in chunk execution", {
33896
34052
  totalRecords,
33897
34053
  successCount: successRecords.length,
33898
34054
  failedCount: failedIds.length,
@@ -33924,12 +34080,12 @@ function getErrorCode(error2) {
33924
34080
  }
33925
34081
  return "TRANSACTION_FAILED";
33926
34082
  }
33927
- var logger3;
34083
+ var logger5;
33928
34084
  var init_chunking = __esm({
33929
34085
  "src/server/utils/chunking.ts"() {
33930
34086
  "use strict";
33931
34087
  init_shared();
33932
- logger3 = createLogger({ service: "records-lambda" });
34088
+ logger5 = createLogger({ service: "records-lambda" });
33933
34089
  __name(calculateChunks, "calculateChunks");
33934
34090
  __name(executeChunks, "executeChunks");
33935
34091
  __name(getErrorCode, "getErrorCode");
@@ -34002,62 +34158,6 @@ var init_cost_tracker = __esm({
34002
34158
  }
34003
34159
  });
34004
34160
 
34005
- // src/server/utils/dynamodb.ts
34006
- function getDBClient() {
34007
- if (!dbClient) {
34008
- dbClient = createDynamoDBClient({
34009
- region: process.env.AWS_REGION || process.env.REGION
34010
- });
34011
- }
34012
- return dbClient;
34013
- }
34014
- function getTableName() {
34015
- const tableName = process.env.TABLE_NAME;
34016
- if (!tableName) {
34017
- throw new ConfigError("TABLE_NAME environment variable is not set");
34018
- }
34019
- return tableName;
34020
- }
34021
- function removeShadowKeys(record) {
34022
- const { __shadowKeys, ...rest } = record;
34023
- return rest;
34024
- }
34025
- function extractCleanRecord(item) {
34026
- const data = item.data || item;
34027
- return removeShadowKeys(data);
34028
- }
34029
- async function executeDynamoDBOperation(operation2, operationName) {
34030
- try {
34031
- return await operation2();
34032
- } catch (error2) {
34033
- if (error2 instanceof Error && error2.name === "AccessDeniedException") {
34034
- logger4.error("DynamoDB access denied", {
34035
- errorName: error2.name,
34036
- errorMessage: error2.message,
34037
- operation: operationName,
34038
- tableName: process.env.TABLE_NAME,
34039
- region: process.env.AWS_REGION || process.env.REGION
34040
- });
34041
- throw new Error(`Insufficient permissions to access DynamoDB: ${operationName}`);
34042
- }
34043
- throw error2;
34044
- }
34045
- }
34046
- var logger4, dbClient;
34047
- var init_dynamodb3 = __esm({
34048
- "src/server/utils/dynamodb.ts"() {
34049
- "use strict";
34050
- init_shared();
34051
- logger4 = createLogger({ service: "records-lambda" });
34052
- dbClient = null;
34053
- __name(getDBClient, "getDBClient");
34054
- __name(getTableName, "getTableName");
34055
- __name(removeShadowKeys, "removeShadowKeys");
34056
- __name(extractCleanRecord, "extractCleanRecord");
34057
- __name(executeDynamoDBOperation, "executeDynamoDBOperation");
34058
- }
34059
- });
34060
-
34061
34161
  // src/server/utils/validation.ts
34062
34162
  function validateSortField(_config, _resource, _sort) {
34063
34163
  return;
@@ -34375,6 +34475,59 @@ var init_pagination = __esm({
34375
34475
  }
34376
34476
  });
34377
34477
 
34478
+ // src/server/utils/scanWarning.ts
34479
+ function getScanWarnThreshold() {
34480
+ const raw = process.env.SCAN_WARN_THRESHOLD;
34481
+ if (raw === void 0 || raw === "") {
34482
+ return DEFAULT_SCAN_WARN_THRESHOLD;
34483
+ }
34484
+ const value = Number(raw);
34485
+ return Number.isInteger(value) && value >= 1 ? value : DEFAULT_SCAN_WARN_THRESHOLD;
34486
+ }
34487
+ var logger6, SPARSE_SCAN_EVENT, DEFAULT_SCAN_WARN_THRESHOLD, ScanWatcher;
34488
+ var init_scanWarning = __esm({
34489
+ "src/server/utils/scanWarning.ts"() {
34490
+ "use strict";
34491
+ init_shared();
34492
+ logger6 = createLogger({ service: "scan-warning", level: "warn" });
34493
+ SPARSE_SCAN_EVENT = "SPARSE_SCAN";
34494
+ DEFAULT_SCAN_WARN_THRESHOLD = 5e3;
34495
+ __name(getScanWarnThreshold, "getScanWarnThreshold");
34496
+ ScanWatcher = class {
34497
+ constructor(context) {
34498
+ this.context = context;
34499
+ }
34500
+ static {
34501
+ __name(this, "ScanWatcher");
34502
+ }
34503
+ scanned = 0;
34504
+ warned = false;
34505
+ threshold = getScanWarnThreshold();
34506
+ /** 読んだ件数を加える */
34507
+ add(count) {
34508
+ this.scanned += count;
34509
+ if (!this.warned && this.scanned >= this.threshold) {
34510
+ this.warned = true;
34511
+ logger6.warn(
34512
+ `${SPARSE_SCAN_EVENT}: 1\u30EA\u30AF\u30A8\u30B9\u30C8\u3067 ${this.scanned} \u4EF6\u4EE5\u4E0A\u3092\u8AAD\u307F\u307E\u3057\u305F\u3002\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u30FB\u30B9\u30AD\u30FC\u30DE\u30FB\u30ED\u30B8\u30C3\u30AF\u306E\u898B\u76F4\u3057\u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044\uFF08docs/SCAN_WARNING.md\uFF09`,
34513
+ {
34514
+ event: SPARSE_SCAN_EVENT,
34515
+ ...this.context,
34516
+ scanned: this.scanned,
34517
+ threshold: this.threshold,
34518
+ actions: [
34519
+ "\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9: \u7D5E\u308A\u8FBC\u307F\u306B\u4F7F\u3046\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u30B7\u30E3\u30C9\u30FC\u8A2D\u5B9A\u306B\u8FFD\u52A0\u3057\u3001$eq \u306A\u3069\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u3067\u89E3\u6C7A\u3067\u304D\u308B\u6761\u4EF6\u306B\u3059\u308B",
34520
+ "\u30B9\u30AD\u30FC\u30DE: \u7D5E\u308A\u8FBC\u307F\u6761\u4EF6\u3092\u30AD\u30FC\u306B\u3067\u304D\u308B\u3088\u3046\u3001\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u5206\u5272\u30FB\u975E\u6B63\u898F\u5316\u3092\u691C\u8A0E\u3059\u308B",
34521
+ "\u30ED\u30B8\u30C3\u30AF: \u7D5E\u308A\u8FBC\u307F\u3092\u6BCE\u56DE\u884C\u3046\u5FC5\u8981\u304C\u3042\u308B\u304B\u3001\u6761\u4EF6\u3092\u5909\u3048\u3089\u308C\u306A\u3044\u304B\u3001\u7D50\u679C\u3092\u30AD\u30E3\u30C3\u30B7\u30E5\u3067\u304D\u306A\u3044\u304B\u3092\u898B\u76F4\u3059"
34522
+ ]
34523
+ }
34524
+ );
34525
+ }
34526
+ }
34527
+ };
34528
+ }
34529
+ });
34530
+
34378
34531
  // src/server/utils/filter.ts
34379
34532
  function parseFilterField(fieldKey) {
34380
34533
  const parts = fieldKey.split(":");
@@ -34463,7 +34616,7 @@ function parseFilters(filter) {
34463
34616
  parsedFilters.push({ parsed, value });
34464
34617
  }
34465
34618
  } catch (error2) {
34466
- logger5.error("Invalid filter field syntax", {
34619
+ logger7.error("Invalid filter field syntax", {
34467
34620
  fieldKey,
34468
34621
  error: error2 instanceof Error ? error2.message : String(error2)
34469
34622
  });
@@ -34532,7 +34685,7 @@ function detectNearQuery(filter) {
34532
34685
  }
34533
34686
  return null;
34534
34687
  }
34535
- var logger5;
34688
+ var logger7;
34536
34689
  var init_utils5 = __esm({
34537
34690
  "src/server/operations/find/utils.ts"() {
34538
34691
  "use strict";
@@ -34541,7 +34694,7 @@ var init_utils5 = __esm({
34541
34694
  init_shadow();
34542
34695
  init_filter();
34543
34696
  init_validation2();
34544
- logger5 = createLogger({
34697
+ logger7 = createLogger({
34545
34698
  service: "find-utils",
34546
34699
  level: process.env.LOG_LEVEL || "info"
34547
34700
  });
@@ -34558,7 +34711,7 @@ var init_utils5 = __esm({
34558
34711
  async function executeIdQuery(resource, normalizedParams, requestId) {
34559
34712
  const { sort, pagination, parsedFilters } = normalizedParams;
34560
34713
  const { perPage, nextToken } = pagination;
34561
- logger6.debug("Executing ID optimized query", {
34714
+ logger8.debug("Executing ID optimized query", {
34562
34715
  requestId,
34563
34716
  resource,
34564
34717
  sort,
@@ -34579,7 +34732,7 @@ async function executeSpecificIdQuery(resource, targetId, requestId) {
34579
34732
  const costTracker = new CostTracker();
34580
34733
  const queryResult = await executeDynamoDBOperation(
34581
34734
  () => dbClient2.send(
34582
- new import_lib_dynamodb2.QueryCommand({
34735
+ new import_lib_dynamodb3.QueryCommand({
34583
34736
  TableName: tableName,
34584
34737
  KeyConditionExpression: "PK = :pk AND SK = :sk",
34585
34738
  ExpressionAttributeValues: {
@@ -34595,7 +34748,7 @@ async function executeSpecificIdQuery(resource, targetId, requestId) {
34595
34748
  costTracker.add(queryResult.ConsumedCapacity);
34596
34749
  const mainRecords = queryResult.Items || [];
34597
34750
  const items = mainRecords.map((item) => extractCleanRecord(item));
34598
- logger6.info("ID specific query succeeded", {
34751
+ logger8.info("ID specific query succeeded", {
34599
34752
  requestId,
34600
34753
  resource,
34601
34754
  targetId,
@@ -34618,7 +34771,7 @@ async function executeInQuery(resource, targetIds, sort, requestId) {
34618
34771
  targetIds.map(
34619
34772
  (id) => executeDynamoDBOperation(
34620
34773
  () => dbClient2.send(
34621
- new import_lib_dynamodb2.QueryCommand({
34774
+ new import_lib_dynamodb3.QueryCommand({
34622
34775
  TableName: tableName,
34623
34776
  KeyConditionExpression: "PK = :pk AND SK = :sk",
34624
34777
  ExpressionAttributeValues: {
@@ -34642,7 +34795,7 @@ async function executeInQuery(resource, targetIds, sort, requestId) {
34642
34795
  const bVal = String(b4.id ?? "");
34643
34796
  return sort.order === "ASC" ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal);
34644
34797
  });
34645
- logger6.info("ID $in query succeeded", {
34798
+ logger8.info("ID $in query succeeded", {
34646
34799
  requestId,
34647
34800
  resource,
34648
34801
  requestedCount: targetIds.length,
@@ -34681,7 +34834,7 @@ async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsed
34681
34834
  }
34682
34835
  const queryResult = await executeDynamoDBOperation(
34683
34836
  () => dbClient2.send(
34684
- new import_lib_dynamodb2.QueryCommand({
34837
+ new import_lib_dynamodb3.QueryCommand({
34685
34838
  TableName: tableName,
34686
34839
  KeyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
34687
34840
  ExpressionAttributeValues: {
@@ -34718,7 +34871,7 @@ async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsed
34718
34871
  queryResult.LastEvaluatedKey.PK,
34719
34872
  queryResult.LastEvaluatedKey.SK
34720
34873
  ) : void 0;
34721
- logger6.info("ID all records query succeeded", {
34874
+ logger8.info("ID all records query succeeded", {
34722
34875
  requestId,
34723
34876
  resource,
34724
34877
  count: items.length,
@@ -34750,18 +34903,28 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
34750
34903
  let iterations = 0;
34751
34904
  let previousKeySignature;
34752
34905
  let chunkSize = SCAN_CHUNK_INITIAL;
34906
+ const watcher = new ScanWatcher({
34907
+ requestId,
34908
+ resource,
34909
+ path: "id-filtered-scan",
34910
+ sortField: sort.field,
34911
+ filters: parsedFilters.map((f4) => `${f4.parsed.field}:${f4.parsed.operator}`)
34912
+ });
34753
34913
  scan: while (true) {
34754
34914
  if (++iterations > SCAN_MAX_ITERATIONS) {
34755
- logger6.error("executeAllRecordsQueryFullScan: \u6700\u5927\u53CD\u5FA9\u56DE\u6570\u3092\u8D85\u904E\u3057\u305F\u305F\u3081\u4E2D\u65AD", {
34915
+ logger8.error("executeAllRecordsQueryFullScan: \u6700\u5927\u53CD\u5FA9\u56DE\u6570\u3092\u8D85\u904E", {
34756
34916
  requestId,
34757
34917
  resource,
34758
34918
  iterations
34759
34919
  });
34760
- break;
34920
+ throw new AppError("INTERNAL_ERROR" /* INTERNAL_ERROR */, "ID scan exceeded the iteration limit", 500, {
34921
+ resource,
34922
+ iterations
34923
+ });
34761
34924
  }
34762
34925
  const queryResult = await executeDynamoDBOperation(
34763
34926
  () => dbClient2.send(
34764
- new import_lib_dynamodb2.QueryCommand({
34927
+ new import_lib_dynamodb3.QueryCommand({
34765
34928
  TableName: tableName,
34766
34929
  KeyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
34767
34930
  ExpressionAttributeValues: {
@@ -34778,6 +34941,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
34778
34941
  "Query"
34779
34942
  );
34780
34943
  costTracker.add(queryResult.ConsumedCapacity);
34944
+ watcher.add((queryResult.Items || []).length);
34781
34945
  for (const row of queryResult.Items || []) {
34782
34946
  scanned++;
34783
34947
  if (!matchesAllFilters(extractCleanRecord(row), parsedFilters)) {
@@ -34796,19 +34960,24 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
34796
34960
  }
34797
34961
  const nextKeySignature = `${nextKey.PK}#${nextKey.SK}`;
34798
34962
  if (nextKeySignature === previousKeySignature) {
34799
- logger6.error("executeAllRecordsQueryFullScan: \u540C\u4E00\u306ELastEvaluatedKey\u304C\u8FD4\u5374\u3055\u308C\u305F\u305F\u3081\u4E2D\u65AD", {
34963
+ logger8.error("executeAllRecordsQueryFullScan: \u540C\u4E00\u306ELastEvaluatedKey\u304C\u8FD4\u5374\u3055\u308C\u305F", {
34800
34964
  requestId,
34801
34965
  resource,
34802
34966
  iterations
34803
34967
  });
34804
- break;
34968
+ throw new AppError(
34969
+ "INTERNAL_ERROR" /* INTERNAL_ERROR */,
34970
+ "ID scan received the same LastEvaluatedKey repeatedly",
34971
+ 500,
34972
+ { resource, iterations }
34973
+ );
34805
34974
  }
34806
34975
  previousKeySignature = nextKeySignature;
34807
34976
  exclusiveStartKey = nextKey;
34808
34977
  chunkSize = Math.min(chunkSize * 2, SCAN_CHUNK_MAX);
34809
34978
  }
34810
34979
  const nextTokenValue = hasNextPage && lastReturned ? encodeNextToken(lastReturned.PK, lastReturned.SK) : void 0;
34811
- logger6.info("ID filtered scan query succeeded", {
34980
+ logger8.info("ID filtered scan query succeeded", {
34812
34981
  requestId,
34813
34982
  resource,
34814
34983
  scanned,
@@ -34822,17 +34991,18 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
34822
34991
  consumedCapacity: costTracker.getAggregated()
34823
34992
  };
34824
34993
  }
34825
- var import_lib_dynamodb2, logger6, SCAN_CHUNK_INITIAL, SCAN_CHUNK_MAX, SCAN_MAX_ITERATIONS;
34994
+ var import_lib_dynamodb3, logger8, SCAN_CHUNK_INITIAL, SCAN_CHUNK_MAX, SCAN_MAX_ITERATIONS;
34826
34995
  var init_idQuery = __esm({
34827
34996
  "src/server/operations/find/idQuery.ts"() {
34828
34997
  "use strict";
34829
- import_lib_dynamodb2 = __toESM(require_dist_cjs65(), 1);
34998
+ import_lib_dynamodb3 = __toESM(require_dist_cjs65(), 1);
34830
34999
  init_shared();
34831
35000
  init_cost_tracker();
34832
35001
  init_dynamodb3();
34833
35002
  init_pagination();
35003
+ init_scanWarning();
34834
35004
  init_utils5();
34835
- logger6 = createLogger({
35005
+ logger8 = createLogger({
34836
35006
  service: "id-query",
34837
35007
  level: process.env.LOG_LEVEL || "info"
34838
35008
  });
@@ -34849,7 +35019,7 @@ var init_idQuery = __esm({
34849
35019
 
34850
35020
  // src/server/operations/find/nearQuery.ts
34851
35021
  async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId) {
34852
- logger7.debug("Executing $near query", {
35022
+ logger9.debug("Executing $near query", {
34853
35023
  requestId,
34854
35024
  resource,
34855
35025
  fieldName,
@@ -34860,32 +35030,58 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
34860
35030
  const searchFunction = /* @__PURE__ */ __name(async (geohashPrefix) => {
34861
35031
  const dbClient2 = getDBClient();
34862
35032
  const tableName = getTableName();
34863
- logger7.debug("Searching shadow records", {
35033
+ logger9.debug("Searching shadow records", {
34864
35034
  requestId,
34865
35035
  resource,
34866
35036
  fieldName,
34867
35037
  geohashPrefix,
34868
35038
  skPrefix: `${fieldName}#${geohashPrefix}`
34869
35039
  });
34870
- const queryResult = await executeDynamoDBOperation(
34871
- () => dbClient2.send(
34872
- new import_lib_dynamodb3.QueryCommand({
34873
- TableName: tableName,
34874
- KeyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
34875
- ExpressionAttributeValues: {
34876
- ":pk": resource,
34877
- ":skPrefix": `${fieldName}#${geohashPrefix}`
34878
- },
34879
- ConsistentRead: false,
34880
- // シャドウレコードは結果整合性で十分
34881
- ReturnConsumedCapacity: "TOTAL"
34882
- })
34883
- ),
34884
- "Query"
34885
- );
34886
- costTracker.add(queryResult.ConsumedCapacity);
34887
- const shadowRecords = queryResult.Items || [];
34888
- logger7.debug("Shadow records found", {
35040
+ const shadowRecords = [];
35041
+ const watcher = new ScanWatcher({
35042
+ requestId,
35043
+ resource,
35044
+ path: "near-search",
35045
+ sortField: fieldName,
35046
+ filters: ["$near"]
35047
+ });
35048
+ let exclusiveStartKey;
35049
+ let previousKeySignature;
35050
+ do {
35051
+ const queryResult = await executeDynamoDBOperation(
35052
+ () => dbClient2.send(
35053
+ new import_lib_dynamodb4.QueryCommand({
35054
+ TableName: tableName,
35055
+ KeyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
35056
+ ExpressionAttributeValues: {
35057
+ ":pk": resource,
35058
+ ":skPrefix": `${fieldName}#${geohashPrefix}`
35059
+ },
35060
+ ExclusiveStartKey: exclusiveStartKey,
35061
+ ConsistentRead: false,
35062
+ // シャドウレコードは結果整合性で十分
35063
+ ReturnConsumedCapacity: "TOTAL"
35064
+ })
35065
+ ),
35066
+ "Query"
35067
+ );
35068
+ costTracker.add(queryResult.ConsumedCapacity);
35069
+ shadowRecords.push(...queryResult.Items || []);
35070
+ watcher.add((queryResult.Items || []).length);
35071
+ const nextKey = queryResult.LastEvaluatedKey;
35072
+ const nextKeySignature = nextKey ? `${nextKey.PK}#${nextKey.SK}` : void 0;
35073
+ if (nextKeySignature && nextKeySignature === previousKeySignature) {
35074
+ throw new AppError(
35075
+ "INTERNAL_ERROR" /* INTERNAL_ERROR */,
35076
+ "Near search received the same LastEvaluatedKey repeatedly",
35077
+ 500,
35078
+ { resource, geohashPrefix }
35079
+ );
35080
+ }
35081
+ previousKeySignature = nextKeySignature;
35082
+ exclusiveStartKey = nextKey;
35083
+ } while (exclusiveStartKey);
35084
+ logger9.debug("Shadow records found", {
34889
35085
  requestId,
34890
35086
  resource,
34891
35087
  geohashPrefix,
@@ -34896,48 +35092,24 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
34896
35092
  const parts = sk.split("#id#");
34897
35093
  return parts.length === 2 ? parts[1] : null;
34898
35094
  }).filter((id) => id !== null);
34899
- logger7.debug("Main record IDs extracted", {
35095
+ logger9.debug("Main record IDs extracted", {
34900
35096
  requestId,
34901
35097
  resource,
34902
35098
  geohashPrefix,
34903
35099
  ids: mainRecordIds
34904
35100
  });
34905
- const BATCH_SIZE = 100;
34906
- const validRecords = [];
34907
- for (let i4 = 0; i4 < mainRecordIds.length; i4 += BATCH_SIZE) {
34908
- const chunk = mainRecordIds.slice(i4, i4 + BATCH_SIZE);
34909
- const batchGetResult = await executeDynamoDBOperation(
34910
- () => dbClient2.send(
34911
- new import_lib_dynamodb3.BatchGetCommand({
34912
- RequestItems: {
34913
- [tableName]: {
34914
- Keys: chunk.map((id) => ({
34915
- PK: resource,
34916
- SK: `id#${id}`
34917
- })),
34918
- ConsistentRead: false
34919
- }
34920
- },
34921
- ReturnConsumedCapacity: "TOTAL"
34922
- })
34923
- ),
34924
- "BatchGetItem"
34925
- );
34926
- if (batchGetResult.ConsumedCapacity) {
34927
- for (const capacity of batchGetResult.ConsumedCapacity) {
34928
- costTracker.add(capacity);
34929
- }
34930
- }
34931
- validRecords.push(...batchGetResult.Responses?.[tableName] || []);
34932
- }
34933
- logger7.debug("Main records retrieved", {
35101
+ const validRecords = await batchGetAll(
35102
+ mainRecordIds.map((id) => ({ PK: resource, SK: `id#${id}` })),
35103
+ { consistentRead: false, costTracker, requestId }
35104
+ );
35105
+ logger9.debug("Main records retrieved", {
34934
35106
  requestId,
34935
35107
  resource,
34936
35108
  geohashPrefix,
34937
35109
  count: validRecords.length
34938
35110
  });
34939
35111
  const cleanRecords = validRecords.map((record) => extractCleanRecord(record));
34940
- logger7.debug("Clean records extracted", {
35112
+ logger9.debug("Clean records extracted", {
34941
35113
  requestId,
34942
35114
  resource,
34943
35115
  geohashPrefix,
@@ -34956,7 +35128,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
34956
35128
  config
34957
35129
  );
34958
35130
  const items = result.documents;
34959
- logger7.info("$near query succeeded", {
35131
+ logger9.info("$near query succeeded", {
34960
35132
  requestId,
34961
35133
  resource,
34962
35134
  fieldName,
@@ -34974,17 +35146,19 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
34974
35146
  consumedCapacity: costTracker.getAggregated()
34975
35147
  };
34976
35148
  }
34977
- var import_lib_dynamodb3, logger7;
35149
+ var import_lib_dynamodb4, logger9;
34978
35150
  var init_nearQuery = __esm({
34979
35151
  "src/server/operations/find/nearQuery.ts"() {
34980
35152
  "use strict";
34981
- import_lib_dynamodb3 = __toESM(require_dist_cjs65(), 1);
35153
+ import_lib_dynamodb4 = __toESM(require_dist_cjs65(), 1);
34982
35154
  init_geohash();
34983
35155
  init_shared();
34984
35156
  init_nearSearch();
35157
+ init_batchGet();
34985
35158
  init_cost_tracker();
34986
35159
  init_dynamodb3();
34987
- logger7 = createLogger({
35160
+ init_scanWarning();
35161
+ logger9 = createLogger({
34988
35162
  service: "near-query",
34989
35163
  level: process.env.LOG_LEVEL || "info"
34990
35164
  });
@@ -35014,7 +35188,7 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
35014
35188
  (f4) => !(isKeyConditionOptimized && f4 === optimizableFilter)
35015
35189
  );
35016
35190
  if (residualFilters.length > 0) {
35017
- logger8.debug("Residual filters detected, falling back to full scan", {
35191
+ logger10.debug("Residual filters detected, falling back to full scan", {
35018
35192
  requestId,
35019
35193
  resource,
35020
35194
  sortField: sort.field,
@@ -35022,7 +35196,7 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
35022
35196
  });
35023
35197
  return executeFullScanQuery(resource, normalizedParams, costTracker, requestId);
35024
35198
  }
35025
- logger8.debug("Executing shadow query", {
35199
+ logger10.debug("Executing shadow query", {
35026
35200
  requestId,
35027
35201
  resource,
35028
35202
  sortField: sort.field,
@@ -35070,7 +35244,7 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
35070
35244
  shadowRecords.LastEvaluatedKey.PK,
35071
35245
  shadowRecords.LastEvaluatedKey.SK
35072
35246
  ) : void 0;
35073
- logger8.info("Shadow query succeeded", {
35247
+ logger10.info("Shadow query succeeded", {
35074
35248
  requestId,
35075
35249
  resource,
35076
35250
  sortField: sort.field,
@@ -35095,7 +35269,7 @@ async function executeFilterFirstQuery(resource, normalizedParams, filterCandida
35095
35269
  const offset = nextToken ? decodeOffsetToken(nextToken) ?? 0 : 0;
35096
35270
  const filterSort = { field: filterCandidate.parsed.field, order: "ASC" };
35097
35271
  const remainingFilters = parsedFilters.filter((f4) => f4 !== filterCandidate);
35098
- logger8.debug("Executing filter-first query", {
35272
+ logger10.debug("Executing filter-first query", {
35099
35273
  requestId,
35100
35274
  resource,
35101
35275
  filterField: filterCandidate.parsed.field,
@@ -35107,7 +35281,9 @@ async function executeFilterFirstQuery(resource, normalizedParams, filterCandida
35107
35281
  filterSort,
35108
35282
  filterCandidate,
35109
35283
  costTracker,
35110
- requestId
35284
+ requestId,
35285
+ "shadow-filter-first",
35286
+ parsedFilters
35111
35287
  );
35112
35288
  if (remainingFilters.length > 0) {
35113
35289
  items = items.filter((r4) => matchesAllFilters(r4, remainingFilters));
@@ -35116,7 +35292,7 @@ async function executeFilterFirstQuery(resource, normalizedParams, filterCandida
35116
35292
  const page = items.slice(offset, offset + perPage);
35117
35293
  const hasNextPage = offset + perPage < items.length;
35118
35294
  const nextTokenValue = hasNextPage ? encodeOffsetToken(offset + perPage) : void 0;
35119
- logger8.info("Filter-first query succeeded", {
35295
+ logger10.info("Filter-first query succeeded", {
35120
35296
  requestId,
35121
35297
  resource,
35122
35298
  filterField: filterCandidate.parsed.field,
@@ -35137,20 +35313,28 @@ async function executeFullScanQuery(resource, normalizedParams, costTracker, req
35137
35313
  const { sort, pagination, parsedFilters } = normalizedParams;
35138
35314
  const { perPage, nextToken } = pagination;
35139
35315
  const offset = nextToken ? decodeOffsetToken(nextToken) ?? 0 : 0;
35140
- logger8.debug("Executing full scan query", {
35316
+ logger10.debug("Executing full scan query", {
35141
35317
  requestId,
35142
35318
  resource,
35143
35319
  sortField: sort.field,
35144
35320
  offset
35145
35321
  });
35146
- let items = await fetchAllRecordsViaShadowIndex(resource, sort, void 0, costTracker, requestId);
35322
+ let items = await fetchAllRecordsViaShadowIndex(
35323
+ resource,
35324
+ sort,
35325
+ void 0,
35326
+ costTracker,
35327
+ requestId,
35328
+ "shadow-full-scan",
35329
+ parsedFilters
35330
+ );
35147
35331
  if (parsedFilters.length > 0) {
35148
35332
  items = items.filter((r4) => matchesAllFilters(r4, parsedFilters));
35149
35333
  }
35150
35334
  const page = items.slice(offset, offset + perPage);
35151
35335
  const hasNextPage = offset + perPage < items.length;
35152
35336
  const nextTokenValue = hasNextPage ? encodeOffsetToken(offset + perPage) : void 0;
35153
- logger8.info("Full scan query succeeded", {
35337
+ logger10.info("Full scan query succeeded", {
35154
35338
  requestId,
35155
35339
  resource,
35156
35340
  sortField: sort.field,
@@ -35166,20 +35350,35 @@ async function executeFullScanQuery(resource, normalizedParams, costTracker, req
35166
35350
  consumedCapacity: costTracker.getAggregated()
35167
35351
  };
35168
35352
  }
35169
- async function fetchAllRecordsViaShadowIndex(resource, indexSort, indexFilter, costTracker, requestId) {
35353
+ async function fetchAllRecordsViaShadowIndex(resource, indexSort, indexFilter, costTracker, requestId, scanPath, parsedFilters) {
35170
35354
  const allShadowItems = [];
35355
+ const watcher = new ScanWatcher({
35356
+ requestId,
35357
+ resource,
35358
+ path: scanPath,
35359
+ sortField: indexSort.field,
35360
+ filters: parsedFilters.map((f4) => `${f4.parsed.field}:${f4.parsed.operator}`)
35361
+ });
35171
35362
  let lastKey;
35172
35363
  let previousKeySignature;
35173
35364
  const MAX_ITERATIONS = 1e4;
35174
35365
  let iterations = 0;
35175
35366
  do {
35176
35367
  if (++iterations > MAX_ITERATIONS) {
35177
- logger8.error("fetchAllRecordsViaShadowIndex: \u6700\u5927\u53CD\u5FA9\u56DE\u6570\u3092\u8D85\u904E\u3057\u305F\u305F\u3081\u4E2D\u65AD", {
35368
+ logger10.error("fetchAllRecordsViaShadowIndex: \u6700\u5927\u53CD\u5FA9\u56DE\u6570\u3092\u8D85\u904E", {
35178
35369
  requestId,
35179
35370
  resource,
35180
35371
  iterations
35181
35372
  });
35182
- break;
35373
+ throw new AppError(
35374
+ "INTERNAL_ERROR" /* INTERNAL_ERROR */,
35375
+ "Shadow index scan exceeded the iteration limit",
35376
+ 500,
35377
+ {
35378
+ resource,
35379
+ iterations
35380
+ }
35381
+ );
35183
35382
  }
35184
35383
  const result = await executeShadowRecordQuery(
35185
35384
  resource,
@@ -35192,15 +35391,21 @@ async function fetchAllRecordsViaShadowIndex(resource, indexSort, indexFilter, c
35192
35391
  requestId
35193
35392
  );
35194
35393
  allShadowItems.push(...result.Items || []);
35394
+ watcher.add((result.Items || []).length);
35195
35395
  const nextKey = result.LastEvaluatedKey;
35196
35396
  const nextKeySignature = nextKey ? `${nextKey.PK}#${nextKey.SK}` : void 0;
35197
35397
  if (nextKeySignature && nextKeySignature === previousKeySignature) {
35198
- logger8.error("fetchAllRecordsViaShadowIndex: \u540C\u4E00\u306ELastEvaluatedKey\u304C\u8FD4\u5374\u3055\u308C\u305F\u305F\u3081\u4E2D\u65AD", {
35398
+ logger10.error("fetchAllRecordsViaShadowIndex: \u540C\u4E00\u306ELastEvaluatedKey\u304C\u8FD4\u5374\u3055\u308C\u305F", {
35199
35399
  requestId,
35200
35400
  resource,
35201
35401
  iterations
35202
35402
  });
35203
- break;
35403
+ throw new AppError(
35404
+ "INTERNAL_ERROR" /* INTERNAL_ERROR */,
35405
+ "Shadow index scan received the same LastEvaluatedKey repeatedly",
35406
+ 500,
35407
+ { resource, iterations }
35408
+ );
35204
35409
  }
35205
35410
  previousKeySignature = nextKeySignature;
35206
35411
  lastKey = nextKey;
@@ -35262,7 +35467,7 @@ async function executeShadowRecordQuery(resource, sort, perPage, nextToken, opti
35262
35467
  );
35263
35468
  const result = await executeDynamoDBOperation(
35264
35469
  () => dbClient2.send(
35265
- new import_lib_dynamodb4.QueryCommand({
35470
+ new import_lib_dynamodb5.QueryCommand({
35266
35471
  TableName: tableName,
35267
35472
  KeyConditionExpression: keyConditionExpression,
35268
35473
  ExpressionAttributeValues: expressionAttributeValues,
@@ -35370,62 +35575,37 @@ function encodeValueForShadowSK(value, type) {
35370
35575
  function extractRecordIds(shadowRecords) {
35371
35576
  return shadowRecords.map((record) => {
35372
35577
  const sk = record.SK;
35373
- const parts = sk.split("#id#");
35374
- return parts.length > 1 ? parts[1] : null;
35578
+ const index = sk.lastIndexOf("#id#");
35579
+ return index >= 0 ? sk.slice(index + "#id#".length) : null;
35375
35580
  }).filter((id) => id !== null);
35376
35581
  }
35377
35582
  async function fetchMainRecords(resource, recordIds, costTracker, requestId) {
35378
- const dbClient2 = getDBClient();
35379
- const tableName = getTableName();
35380
- const uniqueRecordIds = Array.from(new Set(recordIds));
35381
- const BATCH_SIZE = 100;
35382
- const allRecords = [];
35383
- for (let i4 = 0; i4 < uniqueRecordIds.length; i4 += BATCH_SIZE) {
35384
- const chunk = uniqueRecordIds.slice(i4, i4 + BATCH_SIZE);
35385
- const batchGetResult = await executeDynamoDBOperation(
35386
- () => dbClient2.send(
35387
- new import_lib_dynamodb4.BatchGetCommand({
35388
- RequestItems: {
35389
- [tableName]: {
35390
- Keys: chunk.map((id) => ({
35391
- PK: resource,
35392
- SK: `id#${id}`
35393
- })),
35394
- ConsistentRead: true
35395
- }
35396
- },
35397
- ReturnConsumedCapacity: "TOTAL"
35398
- })
35399
- ),
35400
- "BatchGetItem"
35401
- );
35402
- if (batchGetResult.ConsumedCapacity) {
35403
- for (const capacity of batchGetResult.ConsumedCapacity) {
35404
- costTracker.add(capacity);
35405
- }
35406
- }
35407
- allRecords.push(...batchGetResult.Responses?.[tableName] || []);
35408
- }
35409
- logger8.debug("Main records fetched", {
35583
+ const allRecords = await batchGetAll(
35584
+ recordIds.map((id) => ({ PK: resource, SK: `id#${id}` })),
35585
+ { consistentRead: true, costTracker, requestId }
35586
+ );
35587
+ logger10.debug("Main records fetched", {
35410
35588
  requestId,
35411
35589
  resource,
35412
- requestedCount: uniqueRecordIds.length,
35590
+ requestedCount: new Set(recordIds).size,
35413
35591
  fetchedCount: allRecords.length
35414
35592
  });
35415
35593
  return allRecords;
35416
35594
  }
35417
- var import_lib_dynamodb4, logger8, KEY_CONDITION_OPERATORS;
35595
+ var import_lib_dynamodb5, logger10, KEY_CONDITION_OPERATORS;
35418
35596
  var init_shadowQuery = __esm({
35419
35597
  "src/server/operations/find/shadowQuery.ts"() {
35420
35598
  "use strict";
35421
- import_lib_dynamodb4 = __toESM(require_dist_cjs65(), 1);
35599
+ import_lib_dynamodb5 = __toESM(require_dist_cjs65(), 1);
35422
35600
  init_formatting();
35423
35601
  init_shared();
35602
+ init_batchGet();
35424
35603
  init_cost_tracker();
35425
35604
  init_dynamodb3();
35426
35605
  init_pagination();
35606
+ init_scanWarning();
35427
35607
  init_utils5();
35428
- logger8 = createLogger({
35608
+ logger10 = createLogger({
35429
35609
  service: "shadow-query",
35430
35610
  level: process.env.LOG_LEVEL || "info"
35431
35611
  });
@@ -35446,14 +35626,14 @@ var init_shadowQuery = __esm({
35446
35626
 
35447
35627
  // src/server/operations/find/handler.ts
35448
35628
  async function handleFind(resource, params, requestId) {
35449
- logger9.debug("Executing find", {
35629
+ logger11.debug("Executing find", {
35450
35630
  requestId,
35451
35631
  resource,
35452
35632
  params
35453
35633
  });
35454
35634
  const nearDetection = detectNearQuery(params.filter);
35455
35635
  if (nearDetection) {
35456
- logger9.debug("$near operator detected, executing near search", {
35636
+ logger11.debug("$near operator detected, executing near search", {
35457
35637
  requestId,
35458
35638
  resource,
35459
35639
  fieldName: nearDetection.fieldName
@@ -35470,7 +35650,7 @@ async function handleFind(resource, params, requestId) {
35470
35650
  const config = initializeFindConfig();
35471
35651
  const normalizedParams = normalizeFindParams(config, resource, params);
35472
35652
  validateSortField(config, resource, normalizedParams.sort);
35473
- logger9.debug("Find parameters normalized", {
35653
+ logger11.debug("Find parameters normalized", {
35474
35654
  requestId,
35475
35655
  resource,
35476
35656
  sort: normalizedParams.sort,
@@ -35485,7 +35665,7 @@ async function handleFind(resource, params, requestId) {
35485
35665
  }
35486
35666
  return executeShadowQuery(resource, normalizedParams, requestId);
35487
35667
  }
35488
- var logger9;
35668
+ var logger11;
35489
35669
  var init_handler = __esm({
35490
35670
  "src/server/operations/find/handler.ts"() {
35491
35671
  "use strict";
@@ -35495,7 +35675,7 @@ var init_handler = __esm({
35495
35675
  init_nearQuery();
35496
35676
  init_shadowQuery();
35497
35677
  init_utils5();
35498
- logger9 = createLogger({
35678
+ logger11 = createLogger({
35499
35679
  service: "find-handler",
35500
35680
  level: process.env.LOG_LEVEL || "info"
35501
35681
  });
@@ -35504,10 +35684,6 @@ var init_handler = __esm({
35504
35684
  });
35505
35685
 
35506
35686
  // src/server/operations/find.ts
35507
- var find_exports = {};
35508
- __export(find_exports, {
35509
- handleFind: () => handleFind
35510
- });
35511
35687
  var init_find = __esm({
35512
35688
  "src/server/operations/find.ts"() {
35513
35689
  "use strict";
@@ -35515,6 +35691,60 @@ var init_find = __esm({
35515
35691
  }
35516
35692
  });
35517
35693
 
35694
+ // src/server/operations/findAll.ts
35695
+ async function findAllByFilter(resource, filter, requestId) {
35696
+ const sortField = chooseScanSortField(filter);
35697
+ const items = [];
35698
+ let nextToken;
35699
+ let previousToken;
35700
+ for (; ; ) {
35701
+ const result = await handleFind(
35702
+ resource,
35703
+ {
35704
+ filter,
35705
+ sort: { field: sortField, order: "ASC" },
35706
+ pagination: { perPage: 50, nextToken }
35707
+ },
35708
+ requestId
35709
+ );
35710
+ items.push(...result.items);
35711
+ nextToken = result.pageInfo?.hasNextPage ? result.nextToken : void 0;
35712
+ if (!nextToken) {
35713
+ return items;
35714
+ }
35715
+ if (nextToken === previousToken) {
35716
+ throw new AppError(
35717
+ "INTERNAL_ERROR" /* INTERNAL_ERROR */,
35718
+ "findAllByFilter received the same nextToken repeatedly",
35719
+ 500,
35720
+ { resource }
35721
+ );
35722
+ }
35723
+ previousToken = nextToken;
35724
+ }
35725
+ }
35726
+ async function findOneByFilter(resource, filter, requestId) {
35727
+ const result = await handleFind(
35728
+ resource,
35729
+ {
35730
+ filter,
35731
+ sort: { field: chooseScanSortField(filter), order: "ASC" },
35732
+ pagination: { perPage: 1 }
35733
+ },
35734
+ requestId
35735
+ );
35736
+ return result.items[0];
35737
+ }
35738
+ var init_findAll = __esm({
35739
+ "src/server/operations/findAll.ts"() {
35740
+ "use strict";
35741
+ init_shared();
35742
+ init_find();
35743
+ __name(findAllByFilter, "findAllByFilter");
35744
+ __name(findOneByFilter, "findOneByFilter");
35745
+ }
35746
+ });
35747
+
35518
35748
  // src/server/operations/deleteMany.ts
35519
35749
  var deleteMany_exports = {};
35520
35750
  __export(deleteMany_exports, {
@@ -35526,21 +35756,31 @@ async function handleDeleteMany(resource, params, requestId) {
35526
35756
  let ids;
35527
35757
  if ("ids" in params) {
35528
35758
  ids = params.ids;
35529
- logger10.debug("Executing deleteMany with ids", {
35759
+ logger12.debug("Executing deleteMany with ids", {
35530
35760
  requestId,
35531
35761
  resource,
35532
35762
  count: ids.length
35533
35763
  });
35534
35764
  } else {
35535
- logger10.debug("Executing deleteMany with filter", {
35765
+ logger12.debug("Executing deleteMany with filter", {
35536
35766
  requestId,
35537
35767
  resource,
35538
35768
  filter: params.filter
35539
35769
  });
35540
- const { handleFind: handleFind2 } = await Promise.resolve().then(() => (init_find(), find_exports));
35541
- const findResult = await handleFind2(resource, { filter: params.filter }, requestId);
35542
- ids = findResult.items.map((item) => item.id);
35543
- logger10.debug("Found records with filter", {
35770
+ if (Object.keys(params.filter).length === 0) {
35771
+ throw new AppError(
35772
+ "VALIDATION_ERROR" /* VALIDATION_ERROR */,
35773
+ "deleteMany requires a non-empty filter or ids",
35774
+ 400
35775
+ );
35776
+ }
35777
+ const matched = await findAllByFilter(
35778
+ resource,
35779
+ params.filter,
35780
+ requestId
35781
+ );
35782
+ ids = matched.map((item) => item.id);
35783
+ logger12.debug("Found records with filter", {
35544
35784
  requestId,
35545
35785
  resource,
35546
35786
  count: ids.length
@@ -35558,32 +35798,10 @@ async function handleDeleteMany(resource, params, requestId) {
35558
35798
  logLargeBatchWarning("deleteMany", ids.length, requestId, resource);
35559
35799
  const dbClient2 = getDBClient();
35560
35800
  const tableName = getTableName();
35561
- const keys = ids.map((id) => ({
35562
- PK: resource,
35563
- SK: generateMainRecordSK2(id)
35564
- }));
35565
- const batchGetResult = await executeDynamoDBOperation(
35566
- () => dbClient2.send(
35567
- new import_lib_dynamodb5.BatchGetCommand({
35568
- RequestItems: {
35569
- [tableName]: {
35570
- Keys: keys,
35571
- ConsistentRead: true
35572
- }
35573
- },
35574
- ReturnConsumedCapacity: "TOTAL"
35575
- })
35576
- ),
35577
- "BatchGetItem"
35801
+ const existingItems = await batchGetAll(
35802
+ ids.map((id) => ({ PK: resource, SK: generateMainRecordSK2(id) })),
35803
+ { consistentRead: true, costTracker, requestId }
35578
35804
  );
35579
- if (Array.isArray(batchGetResult.ConsumedCapacity)) {
35580
- for (const capacity of batchGetResult.ConsumedCapacity) {
35581
- costTracker.add(capacity);
35582
- }
35583
- } else {
35584
- costTracker.add(batchGetResult.ConsumedCapacity);
35585
- }
35586
- const existingItems = batchGetResult.Responses?.[tableName] || [];
35587
35805
  const existingIds = /* @__PURE__ */ new Set();
35588
35806
  const preparedRecords = [];
35589
35807
  for (const item of existingItems) {
@@ -35604,7 +35822,7 @@ async function handleDeleteMany(resource, params, requestId) {
35604
35822
  message: `Record not found: ${id}`
35605
35823
  }));
35606
35824
  if (preparedRecords.length === 0) {
35607
- logger10.info("deleteMany completed - no records found", {
35825
+ logger12.info("deleteMany completed - no records found", {
35608
35826
  requestId,
35609
35827
  resource,
35610
35828
  requested: ids.length,
@@ -35668,7 +35886,7 @@ async function handleDeleteMany(resource, params, requestId) {
35668
35886
  }
35669
35887
  const result = await executeDynamoDBOperation(
35670
35888
  () => dbClient2.send(
35671
- new import_lib_dynamodb5.TransactWriteCommand({
35889
+ new import_lib_dynamodb6.TransactWriteCommand({
35672
35890
  TransactItems: transactItems,
35673
35891
  ReturnConsumedCapacity: "TOTAL"
35674
35892
  })
@@ -35763,18 +35981,20 @@ async function handleDeleteMany(resource, params, requestId) {
35763
35981
  consumedCapacity: costTracker.getAggregated()
35764
35982
  };
35765
35983
  }
35766
- var import_lib_dynamodb5, logger10;
35984
+ var import_lib_dynamodb6, logger12;
35767
35985
  var init_deleteMany = __esm({
35768
35986
  "src/server/operations/deleteMany.ts"() {
35769
35987
  "use strict";
35770
- import_lib_dynamodb5 = __toESM(require_dist_cjs65(), 1);
35988
+ import_lib_dynamodb6 = __toESM(require_dist_cjs65(), 1);
35771
35989
  init_shared();
35772
35990
  init_shadow();
35991
+ init_batchGet();
35773
35992
  init_bulkOperations();
35774
35993
  init_chunking();
35775
35994
  init_cost_tracker();
35776
35995
  init_dynamodb3();
35777
- logger10 = createLogger({ service: "records-lambda" });
35996
+ init_findAll();
35997
+ logger12 = createLogger({ service: "records-lambda" });
35778
35998
  __name(handleDeleteMany, "handleDeleteMany");
35779
35999
  }
35780
36000
  });
@@ -35783,7 +36003,7 @@ var init_deleteMany = __esm({
35783
36003
  async function handleFindMany(resource, params, requestId) {
35784
36004
  if ("ids" in params) {
35785
36005
  const { ids } = params;
35786
- logger12.debug("Executing findMany by ids", {
36006
+ logger14.debug("Executing findMany by ids", {
35787
36007
  requestId,
35788
36008
  resource,
35789
36009
  count: ids.length
@@ -35791,28 +36011,12 @@ async function handleFindMany(resource, params, requestId) {
35791
36011
  if (ids.length === 0) {
35792
36012
  return [];
35793
36013
  }
35794
- const dbClient2 = getDBClient();
35795
- const tableName = getTableName();
35796
- const keys = ids.map((id) => ({
35797
- PK: resource,
35798
- SK: generateMainRecordSK2(id)
35799
- }));
35800
- const result = await executeDynamoDBOperation(
35801
- () => dbClient2.send(
35802
- new import_lib_dynamodb6.BatchGetCommand({
35803
- RequestItems: {
35804
- [tableName]: {
35805
- Keys: keys,
35806
- ConsistentRead: true
35807
- }
35808
- }
35809
- })
35810
- ),
35811
- "BatchGetItem"
36014
+ const items = await batchGetAll(
36015
+ ids.map((id) => ({ PK: resource, SK: generateMainRecordSK2(id) })),
36016
+ { consistentRead: true, requestId }
35812
36017
  );
35813
- const items = result.Responses?.[tableName] || [];
35814
36018
  const records = items.map((item) => extractCleanRecord(item));
35815
- logger12.info("findMany by ids succeeded", {
36019
+ logger14.info("findMany by ids succeeded", {
35816
36020
  requestId,
35817
36021
  resource,
35818
36022
  requested: ids.length,
@@ -35822,38 +36026,32 @@ async function handleFindMany(resource, params, requestId) {
35822
36026
  }
35823
36027
  if ("filter" in params) {
35824
36028
  const { filter } = params;
35825
- logger12.debug("Executing findMany by filter", {
36029
+ logger14.debug("Executing findMany by filter", {
35826
36030
  requestId,
35827
36031
  resource,
35828
36032
  filter
35829
36033
  });
35830
- const findResult = await handleFind(
35831
- resource,
35832
- {
35833
- filter
35834
- },
35835
- requestId
35836
- );
35837
- logger12.info("findMany by filter succeeded", {
36034
+ const items = await findAllByFilter(resource, filter, requestId);
36035
+ logger14.info("findMany by filter succeeded", {
35838
36036
  requestId,
35839
36037
  resource,
35840
36038
  filter,
35841
- found: findResult.items.length
36039
+ found: items.length
35842
36040
  });
35843
- return findResult.items;
36041
+ return items;
35844
36042
  }
35845
36043
  throw new Error("findMany requires either ids or filter");
35846
36044
  }
35847
- var import_lib_dynamodb6, logger12;
36045
+ var logger14;
35848
36046
  var init_findMany = __esm({
35849
36047
  "src/server/operations/findMany.ts"() {
35850
36048
  "use strict";
35851
- import_lib_dynamodb6 = __toESM(require_dist_cjs65(), 1);
35852
36049
  init_shared();
35853
36050
  init_shadow();
36051
+ init_batchGet();
35854
36052
  init_dynamodb3();
35855
- init_find();
35856
- logger12 = createLogger({ service: "records-lambda" });
36053
+ init_findAll();
36054
+ logger14 = createLogger({ service: "records-lambda" });
35857
36055
  __name(handleFindMany, "handleFindMany");
35858
36056
  }
35859
36057
  });
@@ -35866,7 +36064,7 @@ __export(findOne_exports, {
35866
36064
  async function handleFindOne(resource, params, requestId) {
35867
36065
  if ("id" in params) {
35868
36066
  const { id } = params;
35869
- logger14.debug("Executing findOne by id (using findMany)", {
36067
+ logger16.debug("Executing findOne by id (using findMany)", {
35870
36068
  requestId,
35871
36069
  resource,
35872
36070
  id
@@ -35875,7 +36073,7 @@ async function handleFindOne(resource, params, requestId) {
35875
36073
  if (results.length === 0) {
35876
36074
  throw new ItemNotFoundError(`Record not found: ${id}`, { resource, id });
35877
36075
  }
35878
- logger14.info("findOne by id succeeded", {
36076
+ logger16.info("findOne by id succeeded", {
35879
36077
  requestId,
35880
36078
  resource,
35881
36079
  id
@@ -35884,7 +36082,7 @@ async function handleFindOne(resource, params, requestId) {
35884
36082
  }
35885
36083
  if ("filter" in params) {
35886
36084
  const { filter } = params;
35887
- logger14.debug("Executing findOne by filter (using findMany)", {
36085
+ logger16.debug("Executing findOne by filter (using findMany)", {
35888
36086
  requestId,
35889
36087
  resource,
35890
36088
  filter
@@ -35893,7 +36091,7 @@ async function handleFindOne(resource, params, requestId) {
35893
36091
  if (results.length === 0) {
35894
36092
  throw new ItemNotFoundError(`Record not found with filter`, { resource, filter });
35895
36093
  }
35896
- logger14.info("findOne by filter succeeded", {
36094
+ logger16.info("findOne by filter succeeded", {
35897
36095
  requestId,
35898
36096
  resource,
35899
36097
  filter
@@ -35902,13 +36100,13 @@ async function handleFindOne(resource, params, requestId) {
35902
36100
  }
35903
36101
  throw new Error("findOne requires either id or filter");
35904
36102
  }
35905
- var logger14;
36103
+ var logger16;
35906
36104
  var init_findOne = __esm({
35907
36105
  "src/server/operations/findOne.ts"() {
35908
36106
  "use strict";
35909
36107
  init_shared();
35910
36108
  init_findMany();
35911
- logger14 = createLogger({ service: "records-lambda" });
36109
+ logger16 = createLogger({ service: "records-lambda" });
35912
36110
  __name(handleFindOne, "handleFindOne");
35913
36111
  }
35914
36112
  });
@@ -35969,13 +36167,13 @@ function calculateTTL(resource, createdAt) {
35969
36167
  }
35970
36168
  const ttlDays = parseInt(ttlDaysStr, 10);
35971
36169
  if (isNaN(ttlDays) || ttlDays <= 0) {
35972
- logger15.warn("Invalid TTL_DAYS value", { resource, envKey, value: ttlDaysStr });
36170
+ logger17.warn("Invalid TTL_DAYS value", { resource, envKey, value: ttlDaysStr });
35973
36171
  return void 0;
35974
36172
  }
35975
36173
  const createdAtMs = new Date(createdAt).getTime();
35976
36174
  const ttlMs = createdAtMs + ttlDays * 24 * 60 * 60 * 1e3;
35977
36175
  const ttl = Math.floor(ttlMs / 1e3);
35978
- logger15.debug("TTL calculated", {
36176
+ logger17.debug("TTL calculated", {
35979
36177
  resource,
35980
36178
  ttlDays,
35981
36179
  createdAt,
@@ -35987,7 +36185,7 @@ function calculateTTL(resource, createdAt) {
35987
36185
  function addTTL(resource, recordData) {
35988
36186
  const createdAt = recordData.createdAt;
35989
36187
  if (!createdAt) {
35990
- logger15.warn("createdAt not found, skipping TTL calculation", { resource });
36188
+ logger17.warn("createdAt not found, skipping TTL calculation", { resource });
35991
36189
  return recordData;
35992
36190
  }
35993
36191
  const ttl = calculateTTL(resource, createdAt);
@@ -35999,12 +36197,12 @@ function addTTL(resource, recordData) {
35999
36197
  ttl
36000
36198
  };
36001
36199
  }
36002
- var logger15;
36200
+ var logger17;
36003
36201
  var init_ttl = __esm({
36004
36202
  "src/server/utils/ttl.ts"() {
36005
36203
  "use strict";
36006
36204
  init_index2();
36007
- logger15 = createLogger({ service: "records-lambda" });
36205
+ logger17 = createLogger({ service: "records-lambda" });
36008
36206
  __name(calculateTTL, "calculateTTL");
36009
36207
  __name(addTTL, "addTTL");
36010
36208
  }
@@ -36019,7 +36217,7 @@ async function handleInsertMany(resource, params, requestId) {
36019
36217
  const { data: recordsData } = params;
36020
36218
  const startTime = Date.now();
36021
36219
  const costTracker = new CostTracker();
36022
- logger16.debug("Executing insertMany", {
36220
+ logger18.debug("Executing insertMany", {
36023
36221
  requestId,
36024
36222
  resource,
36025
36223
  count: recordsData.length
@@ -36062,7 +36260,7 @@ async function handleInsertMany(resource, params, requestId) {
36062
36260
  const failedId = recordData.id || `temp-id-${i4}`;
36063
36261
  const errorMessage = error2 instanceof Error ? error2.message : "Unknown preparation error";
36064
36262
  const errorCode = getPreparationErrorCode(error2);
36065
- logger16.error("Failed to prepare record for creation", {
36263
+ logger18.error("Failed to prepare record for creation", {
36066
36264
  requestId,
36067
36265
  recordId: failedId,
36068
36266
  error: errorMessage,
@@ -36227,7 +36425,7 @@ function getPreparationErrorCode(error2) {
36227
36425
  }
36228
36426
  return "VALIDATION_ERROR" /* VALIDATION_ERROR */;
36229
36427
  }
36230
- var import_lib_dynamodb8, logger16;
36428
+ var import_lib_dynamodb8, logger18;
36231
36429
  var init_insertMany = __esm({
36232
36430
  "src/server/operations/insertMany.ts"() {
36233
36431
  "use strict";
@@ -36241,7 +36439,7 @@ var init_insertMany = __esm({
36241
36439
  init_dynamodb3();
36242
36440
  init_timestamps();
36243
36441
  init_ttl();
36244
- logger16 = createLogger({ service: "records-lambda" });
36442
+ logger18 = createLogger({ service: "records-lambda" });
36245
36443
  __name(handleInsertMany, "handleInsertMany");
36246
36444
  __name(getPreparationErrorCode, "getPreparationErrorCode");
36247
36445
  }
@@ -36364,7 +36562,7 @@ async function handleUpdateMany(resource, params, requestId) {
36364
36562
  const upsert = options?.upsert ?? false;
36365
36563
  const startTime = Date.now();
36366
36564
  const costTracker = new CostTracker();
36367
- logger18.debug("Executing updateMany", {
36565
+ logger20.debug("Executing updateMany", {
36368
36566
  requestId,
36369
36567
  resource,
36370
36568
  upsert
@@ -36372,21 +36570,31 @@ async function handleUpdateMany(resource, params, requestId) {
36372
36570
  let ids;
36373
36571
  if ("ids" in params) {
36374
36572
  ids = params.ids;
36375
- logger18.debug("Executing updateMany with ids", {
36573
+ logger20.debug("Executing updateMany with ids", {
36376
36574
  requestId,
36377
36575
  resource,
36378
36576
  count: ids.length
36379
36577
  });
36380
36578
  } else {
36381
- logger18.debug("Executing updateMany with filter", {
36579
+ logger20.debug("Executing updateMany with filter", {
36382
36580
  requestId,
36383
36581
  resource,
36384
36582
  filter: params.filter
36385
36583
  });
36386
- const { handleFind: handleFind2 } = await Promise.resolve().then(() => (init_find(), find_exports));
36387
- const findResult = await handleFind2(resource, { filter: params.filter }, requestId);
36388
- ids = findResult.items.map((item) => item.id);
36389
- logger18.debug("Found records with filter", {
36584
+ if (Object.keys(params.filter).length === 0) {
36585
+ throw new AppError(
36586
+ "VALIDATION_ERROR" /* VALIDATION_ERROR */,
36587
+ "updateMany requires a non-empty filter or ids",
36588
+ 400
36589
+ );
36590
+ }
36591
+ const matched = await findAllByFilter(
36592
+ resource,
36593
+ params.filter,
36594
+ requestId
36595
+ );
36596
+ ids = matched.map((item) => item.id);
36597
+ logger20.debug("Found records with filter", {
36390
36598
  requestId,
36391
36599
  resource,
36392
36600
  count: ids.length
@@ -36395,7 +36603,7 @@ async function handleUpdateMany(resource, params, requestId) {
36395
36603
  if (upsert) {
36396
36604
  const newId = ulid2();
36397
36605
  ids = [newId];
36398
- logger18.info("Creating new record with filter (upsert: true)", {
36606
+ logger20.info("Creating new record with filter (upsert: true)", {
36399
36607
  requestId,
36400
36608
  resource,
36401
36609
  newId,
@@ -36425,32 +36633,10 @@ async function handleUpdateMany(resource, params, requestId) {
36425
36633
  logLargeBatchWarning("updateMany", ids.length, requestId, resource);
36426
36634
  const dbClient2 = getDBClient();
36427
36635
  const tableName = getTableName();
36428
- const keys = ids.map((id) => ({
36429
- PK: resource,
36430
- SK: generateMainRecordSK2(id)
36431
- }));
36432
- const batchGetResult = await executeDynamoDBOperation(
36433
- () => dbClient2.send(
36434
- new import_lib_dynamodb9.BatchGetCommand({
36435
- RequestItems: {
36436
- [tableName]: {
36437
- Keys: keys,
36438
- ConsistentRead: true
36439
- }
36440
- },
36441
- ReturnConsumedCapacity: "TOTAL"
36442
- })
36443
- ),
36444
- "BatchGetItem"
36636
+ const existingItems = await batchGetAll(
36637
+ ids.map((id) => ({ PK: resource, SK: generateMainRecordSK2(id) })),
36638
+ { consistentRead: true, costTracker, requestId }
36445
36639
  );
36446
- if (Array.isArray(batchGetResult.ConsumedCapacity)) {
36447
- for (const capacity of batchGetResult.ConsumedCapacity) {
36448
- costTracker.add(capacity);
36449
- }
36450
- } else {
36451
- costTracker.add(batchGetResult.ConsumedCapacity);
36452
- }
36453
- const existingItems = batchGetResult.Responses?.[tableName] || [];
36454
36640
  const existingIds = new Set(
36455
36641
  existingItems.map((item) => {
36456
36642
  const data = item.data;
@@ -36459,7 +36645,7 @@ async function handleUpdateMany(resource, params, requestId) {
36459
36645
  );
36460
36646
  const notFoundIds = ids.filter((id) => !existingIds.has(id));
36461
36647
  if (!upsert && notFoundIds.length > 0) {
36462
- logger18.warn("Records not found (upsert: false)", {
36648
+ logger20.warn("Records not found (upsert: false)", {
36463
36649
  requestId,
36464
36650
  resource,
36465
36651
  notFoundCount: notFoundIds.length,
@@ -36468,7 +36654,7 @@ async function handleUpdateMany(resource, params, requestId) {
36468
36654
  });
36469
36655
  }
36470
36656
  if (upsert && notFoundIds.length > 0) {
36471
- logger18.info("Creating new records (upsert: true)", {
36657
+ logger20.info("Creating new records (upsert: true)", {
36472
36658
  requestId,
36473
36659
  resource,
36474
36660
  notFoundCount: notFoundIds.length,
@@ -36504,7 +36690,7 @@ async function handleUpdateMany(resource, params, requestId) {
36504
36690
  const failedId = existingData.id || "unknown-id";
36505
36691
  const errorMessage = error2 instanceof Error ? error2.message : "Unknown preparation error";
36506
36692
  const errorCode = getPreparationErrorCode2(error2);
36507
- logger18.error("Failed to prepare record for update", {
36693
+ logger20.error("Failed to prepare record for update", {
36508
36694
  requestId,
36509
36695
  recordId: failedId,
36510
36696
  error: errorMessage,
@@ -36544,7 +36730,7 @@ async function handleUpdateMany(resource, params, requestId) {
36544
36730
  } catch (error2) {
36545
36731
  const errorMessage = error2 instanceof Error ? error2.message : "Unknown preparation error";
36546
36732
  const errorCode = getPreparationErrorCode2(error2);
36547
- logger18.error("Failed to prepare new record for upsert", {
36733
+ logger20.error("Failed to prepare new record for upsert", {
36548
36734
  requestId,
36549
36735
  recordId: id,
36550
36736
  error: errorMessage,
@@ -36757,7 +36943,7 @@ function getPreparationErrorCode2(error2) {
36757
36943
  }
36758
36944
  return "VALIDATION_ERROR" /* VALIDATION_ERROR */;
36759
36945
  }
36760
- var import_lib_dynamodb9, logger18;
36946
+ var import_lib_dynamodb9, logger20;
36761
36947
  var init_updateMany = __esm({
36762
36948
  "src/server/operations/updateMany.ts"() {
36763
36949
  "use strict";
@@ -36765,13 +36951,15 @@ var init_updateMany = __esm({
36765
36951
  init_shared();
36766
36952
  init_shadow();
36767
36953
  init_shadow();
36954
+ init_batchGet();
36768
36955
  init_bulkOperations();
36769
36956
  init_chunking();
36770
36957
  init_cost_tracker();
36771
36958
  init_dynamodb3();
36772
36959
  init_mergePatch();
36773
36960
  init_timestamps();
36774
- logger18 = createLogger({ service: "records-lambda" });
36961
+ init_findAll();
36962
+ logger20 = createLogger({ service: "records-lambda" });
36775
36963
  __name(handleUpdateMany, "handleUpdateMany");
36776
36964
  __name(getPreparationErrorCode2, "getPreparationErrorCode");
36777
36965
  }
@@ -36792,13 +36980,14 @@ init_deleteMany();
36792
36980
 
36793
36981
  // src/server/operations/deleteOne.ts
36794
36982
  init_shared();
36795
- var logger11 = createLogger({ service: "records-lambda" });
36983
+ init_findAll();
36984
+ var logger13 = createLogger({ service: "records-lambda" });
36796
36985
  async function handleDeleteOne(resource, params, requestId) {
36797
36986
  const { handleDeleteMany: handleDeleteMany2 } = await Promise.resolve().then(() => (init_deleteMany(), deleteMany_exports));
36798
36987
  let targetId;
36799
36988
  if ("id" in params) {
36800
36989
  targetId = params.id;
36801
- logger11.debug("Executing deleteOne with id", {
36990
+ logger13.debug("Executing deleteOne with id", {
36802
36991
  requestId,
36803
36992
  resource,
36804
36993
  id: targetId
@@ -36825,18 +37014,17 @@ async function handleDeleteOne(resource, params, requestId) {
36825
37014
  consumedCapacity: deleteManyResult.consumedCapacity
36826
37015
  };
36827
37016
  } else {
36828
- logger11.debug("Executing deleteOne with filter", {
37017
+ logger13.debug("Executing deleteOne with filter", {
36829
37018
  requestId,
36830
37019
  resource,
36831
37020
  filter: params.filter
36832
37021
  });
36833
- const deleteManyResult = await handleDeleteMany2(
37022
+ const target = await findOneByFilter(
36834
37023
  resource,
36835
- {
36836
- filter: params.filter
36837
- },
37024
+ params.filter,
36838
37025
  requestId
36839
37026
  );
37027
+ const deleteManyResult = target ? await handleDeleteMany2(resource, { ids: [target.id] }, requestId) : await handleDeleteMany2(resource, { ids: [] }, requestId);
36840
37028
  if (deleteManyResult.count === 0) {
36841
37029
  const error2 = Object.values(deleteManyResult.errors || {})[0];
36842
37030
  if (error2) {
@@ -36849,7 +37037,7 @@ async function handleDeleteOne(resource, params, requestId) {
36849
37037
  if (!deletedId) {
36850
37038
  throw new Error("Failed to get deleted record ID");
36851
37039
  }
36852
- logger11.info("deleteOne succeeded", {
37040
+ logger13.info("deleteOne succeeded", {
36853
37041
  requestId,
36854
37042
  resource,
36855
37043
  id: deletedId
@@ -36872,13 +37060,14 @@ init_findMany();
36872
37060
  var import_lib_dynamodb7 = __toESM(require_dist_cjs65(), 1);
36873
37061
  init_shared();
36874
37062
  init_shadow();
37063
+ init_batchGet();
36875
37064
  init_dynamodb3();
36876
37065
  init_pagination();
36877
37066
  init_validation2();
36878
- var logger13 = createLogger({ service: "records-lambda" });
37067
+ var logger15 = createLogger({ service: "records-lambda" });
36879
37068
  async function handleFindManyReference(resource, params, requestId) {
36880
37069
  const { target, id, filter, sort: sortParam, pagination } = params;
36881
- logger13.debug("Executing findManyReference", {
37070
+ logger15.debug("Executing findManyReference", {
36882
37071
  requestId,
36883
37072
  resource,
36884
37073
  target,
@@ -36931,23 +37120,10 @@ async function handleFindManyReference(resource, params, requestId) {
36931
37120
  const parts = sk.split("#id#");
36932
37121
  return parts[parts.length - 1];
36933
37122
  });
36934
- const batchGetResult = await executeDynamoDBOperation(
36935
- () => dbClient2.send(
36936
- new import_lib_dynamodb7.BatchGetCommand({
36937
- RequestItems: {
36938
- [tableName]: {
36939
- Keys: recordIds.map((recordId) => ({
36940
- PK: resource,
36941
- SK: `id#${recordId}`
36942
- })),
36943
- ConsistentRead: true
36944
- }
36945
- }
36946
- })
36947
- ),
36948
- "BatchGetItem"
37123
+ const mainRecords = await batchGetAll(
37124
+ recordIds.map((recordId) => ({ PK: resource, SK: `id#${recordId}` })),
37125
+ { consistentRead: true, requestId }
36949
37126
  );
36950
- const mainRecords = batchGetResult.Responses?.[tableName] || [];
36951
37127
  const recordMap = new Map(
36952
37128
  mainRecords.map((item) => {
36953
37129
  const data = item.data;
@@ -36968,7 +37144,7 @@ async function handleFindManyReference(resource, params, requestId) {
36968
37144
  queryResult.LastEvaluatedKey.PK,
36969
37145
  queryResult.LastEvaluatedKey.SK
36970
37146
  ) : void 0;
36971
- logger13.info("findManyReference succeeded", {
37147
+ logger15.info("findManyReference succeeded", {
36972
37148
  requestId,
36973
37149
  resource,
36974
37150
  target,
@@ -36993,9 +37169,9 @@ init_insertMany();
36993
37169
 
36994
37170
  // src/server/operations/insertOne.ts
36995
37171
  init_shared();
36996
- var logger17 = createLogger({ service: "records-lambda" });
37172
+ var logger19 = createLogger({ service: "records-lambda" });
36997
37173
  async function handleInsertOne(resource, params, requestId) {
36998
- logger17.debug("Executing insertOne", {
37174
+ logger19.debug("Executing insertOne", {
36999
37175
  requestId,
37000
37176
  resource
37001
37177
  });
@@ -37021,7 +37197,7 @@ async function handleInsertOne(resource, params, requestId) {
37021
37197
  }
37022
37198
  const { handleFindOne: handleFindOne2 } = await Promise.resolve().then(() => (init_findOne(), findOne_exports));
37023
37199
  const createdRecord = await handleFindOne2(resource, { id: createdId }, requestId);
37024
- logger17.info("insertOne succeeded", {
37200
+ logger19.info("insertOne succeeded", {
37025
37201
  requestId,
37026
37202
  resource,
37027
37203
  id: createdId
@@ -37139,10 +37315,11 @@ function convertUpdateOneParams(mongoParams) {
37139
37315
  __name(convertUpdateOneParams, "convertUpdateOneParams");
37140
37316
  function convertUpdateManyParams(mongoParams) {
37141
37317
  const idFilter = mongoParams.filter?.id;
37142
- const ids = typeof idFilter === "object" && idFilter !== null && "$in" in idFilter ? idFilter.$in || [] : [];
37318
+ const hasIdIn = typeof idFilter === "object" && idFilter !== null && "$in" in idFilter;
37319
+ const target = hasIdIn ? { ids: idFilter.$in || [] } : mongoParams.filter ? { filter: mongoParams.filter } : { ids: [] };
37143
37320
  const updateData = mongoParams.update && typeof mongoParams.update === "object" ? "$set" in mongoParams.update ? mongoParams.update.$set || {} : mongoParams.update : {};
37144
37321
  return {
37145
- ids,
37322
+ ...target,
37146
37323
  data: updateData,
37147
37324
  ...mongoParams.options?.upsert !== void 0 && {
37148
37325
  options: { upsert: mongoParams.options.upsert }
@@ -37164,8 +37341,13 @@ function convertDeleteOneParams(mongoParams) {
37164
37341
  __name(convertDeleteOneParams, "convertDeleteOneParams");
37165
37342
  function convertDeleteManyParams(mongoParams) {
37166
37343
  const idFilter = mongoParams.filter?.id;
37167
- const ids = typeof idFilter === "object" && idFilter !== null && "$in" in idFilter ? idFilter.$in || [] : [];
37168
- return { ids };
37344
+ if (typeof idFilter === "object" && idFilter !== null && "$in" in idFilter) {
37345
+ return { ids: idFilter.$in || [] };
37346
+ }
37347
+ if (mongoParams.filter) {
37348
+ return { filter: mongoParams.filter };
37349
+ }
37350
+ return { ids: [] };
37169
37351
  }
37170
37352
  __name(convertDeleteManyParams, "convertDeleteManyParams");
37171
37353
  function convertInsertManyParams(mongoParams) {
@@ -37183,13 +37365,14 @@ init_updateMany();
37183
37365
 
37184
37366
  // src/server/operations/updateOne.ts
37185
37367
  init_shared();
37186
- var logger19 = createLogger({ service: "records-lambda" });
37368
+ init_findAll();
37369
+ var logger21 = createLogger({ service: "records-lambda" });
37187
37370
  async function handleUpdateOne(resource, params, requestId) {
37188
37371
  const { data: patchData, options } = params;
37189
37372
  const { handleUpdateMany: handleUpdateMany2 } = await Promise.resolve().then(() => (init_updateMany(), updateMany_exports));
37190
37373
  if ("id" in params) {
37191
37374
  const targetId = params.id;
37192
- logger19.debug("Executing updateOne with id", {
37375
+ logger21.debug("Executing updateOne with id", {
37193
37376
  requestId,
37194
37377
  resource,
37195
37378
  id: targetId,
@@ -37231,19 +37414,20 @@ async function handleUpdateOne(resource, params, requestId) {
37231
37414
  consumedCapacity: updateManyResult.consumedCapacity
37232
37415
  };
37233
37416
  } else {
37234
- logger19.debug("Executing updateOne with filter", {
37417
+ logger21.debug("Executing updateOne with filter", {
37235
37418
  requestId,
37236
37419
  resource,
37237
37420
  filter: params.filter,
37238
37421
  upsert: options?.upsert
37239
37422
  });
37423
+ const target = await findOneByFilter(
37424
+ resource,
37425
+ params.filter,
37426
+ requestId
37427
+ );
37240
37428
  const updateManyResult = await handleUpdateMany2(
37241
37429
  resource,
37242
- {
37243
- filter: params.filter,
37244
- data: patchData,
37245
- options
37246
- },
37430
+ target ? { ids: [target.id], data: patchData, options } : { filter: params.filter, data: patchData, options },
37247
37431
  requestId
37248
37432
  );
37249
37433
  if (updateManyResult.count === 0) {
@@ -37281,13 +37465,13 @@ async function handleUpdateOne(resource, params, requestId) {
37281
37465
  __name(handleUpdateOne, "handleUpdateOne");
37282
37466
 
37283
37467
  // src/server/operations/operationDispatcher.ts
37284
- var logger20 = createLogger({
37468
+ var logger22 = createLogger({
37285
37469
  service: "operation-dispatcher",
37286
37470
  level: process.env.LOG_LEVEL || "info"
37287
37471
  });
37288
37472
  async function executeOperation(request2, requestId) {
37289
37473
  const { op: op2, resource } = request2;
37290
- logger20.debug("Executing operation", {
37474
+ logger22.debug("Executing operation", {
37291
37475
  requestId,
37292
37476
  operation: op2,
37293
37477
  resource
@@ -38510,13 +38694,13 @@ CognitoJwtVerifier.USER_POOL_ID_REGEX = /^(?<region>[a-z]{2}-(gov-)?[a-z]+-\d)_[
38510
38694
 
38511
38695
  // src/server/utils/auth.ts
38512
38696
  init_index2();
38513
- var logger21 = createLogger({ service: "records-lambda" });
38697
+ var logger23 = createLogger({ service: "records-lambda" });
38514
38698
  var verifierInstance = null;
38515
38699
  function getVerifier(userPoolId, clientId) {
38516
38700
  if (!verifierInstance) {
38517
- logger21.debug("Creating JWT verifier instance", { userPoolId, clientId });
38701
+ logger23.debug("Creating JWT verifier instance", { userPoolId, clientId });
38518
38702
  if (!clientId) {
38519
- logger21.warn(
38703
+ logger23.warn(
38520
38704
  "COGNITO_CLIENT_ID is not set: JWT audience (aud) verification is DISABLED. Tokens issued to ANY app client of this user pool are accepted. Set cognito_client_id (Terraform) / COGNITO_CLIENT_ID in production. See docs/AUTHORIZATION.md",
38521
38705
  { userPoolId }
38522
38706
  );
@@ -38533,18 +38717,18 @@ function getVerifier(userPoolId, clientId) {
38533
38717
  }
38534
38718
  __name(getVerifier, "getVerifier");
38535
38719
  async function verifyJwt(token, userPoolId, clientId) {
38536
- logger21.debug("Verifying JWT token with signature validation");
38720
+ logger23.debug("Verifying JWT token with signature validation");
38537
38721
  try {
38538
38722
  const verifier = getVerifier(userPoolId, clientId);
38539
38723
  const payload2 = await verifier.verify(token);
38540
- logger21.debug("JWT token verified successfully", {
38724
+ logger23.debug("JWT token verified successfully", {
38541
38725
  sub: payload2.sub,
38542
38726
  email: payload2.email,
38543
38727
  tokenUse: payload2.token_use
38544
38728
  });
38545
38729
  return payload2;
38546
38730
  } catch (error2) {
38547
- logger21.error("JWT verification failed", {
38731
+ logger23.error("JWT verification failed", {
38548
38732
  error: error2 instanceof Error ? error2.message : String(error2)
38549
38733
  });
38550
38734
  let message = "JWT verification failed";
@@ -38585,7 +38769,7 @@ async function verifyAuthHeader(authHeader, userPoolId, clientId) {
38585
38769
  __name(verifyAuthHeader, "verifyAuthHeader");
38586
38770
 
38587
38771
  // src/server/utils/authHandler.ts
38588
- var logger22 = createLogger({
38772
+ var logger24 = createLogger({
38589
38773
  service: "auth-handler",
38590
38774
  level: process.env.LOG_LEVEL || "info"
38591
38775
  });
@@ -38600,7 +38784,7 @@ async function handleAuthentication(event, requestId) {
38600
38784
  }
38601
38785
  __name(handleAuthentication, "handleAuthentication");
38602
38786
  function handleIAMAuthentication(iam, requestId) {
38603
- logger22.info("IAM authenticated request", {
38787
+ logger24.info("IAM authenticated request", {
38604
38788
  requestId,
38605
38789
  userArn: iam.userArn,
38606
38790
  accountId: iam.accountId,
@@ -38615,7 +38799,7 @@ async function handleCognitoAuthentication(authHeader, requestId) {
38615
38799
  throw new Error("COGNITO_USER_POOL_ID environment variable is required");
38616
38800
  }
38617
38801
  const jwtPayload = await verifyAuthHeader(authHeader, userPoolId, clientId);
38618
- logger22.debug("Cognito JWT verified", {
38802
+ logger24.debug("Cognito JWT verified", {
38619
38803
  requestId,
38620
38804
  sub: jwtPayload.sub
38621
38805
  });
@@ -38630,7 +38814,7 @@ init_shared();
38630
38814
  // src/server/utils/responseBuilder.ts
38631
38815
  init_http();
38632
38816
  init_shared();
38633
- var logger23 = createLogger({
38817
+ var logger25 = createLogger({
38634
38818
  service: "response-builder",
38635
38819
  level: process.env.LOG_LEVEL || "info"
38636
38820
  });
@@ -38640,7 +38824,7 @@ function createSuccessResponse(data, requestId) {
38640
38824
  success: true,
38641
38825
  data
38642
38826
  };
38643
- logger23.info("Request succeeded", { requestId });
38827
+ logger25.info("Request succeeded", { requestId });
38644
38828
  return {
38645
38829
  statusCode: HTTP_STATUS.OK,
38646
38830
  headers: {
@@ -38661,7 +38845,7 @@ function createErrorResponse(code, message, statusCode, requestId, details) {
38661
38845
  details
38662
38846
  }
38663
38847
  };
38664
- logger23.error("Request failed", {
38848
+ logger25.error("Request failed", {
38665
38849
  requestId,
38666
38850
  code,
38667
38851
  message,
@@ -38687,7 +38871,7 @@ function createCorsResponse(statusCode) {
38687
38871
  __name(createCorsResponse, "createCorsResponse");
38688
38872
 
38689
38873
  // src/server/utils/errorHandler.ts
38690
- var logger24 = createLogger({
38874
+ var logger26 = createLogger({
38691
38875
  service: "error-handler",
38692
38876
  level: process.env.LOG_LEVEL || "info"
38693
38877
  });
@@ -38702,7 +38886,7 @@ function handleError(error2, requestId) {
38702
38886
  );
38703
38887
  }
38704
38888
  if (error2 instanceof Error) {
38705
- logger24.error("Error stack trace", {
38889
+ logger26.error("Error stack trace", {
38706
38890
  requestId,
38707
38891
  stack: error2.stack,
38708
38892
  message: error2.message
@@ -38787,14 +38971,14 @@ function parseRequestBody(body) {
38787
38971
  __name(parseRequestBody, "parseRequestBody");
38788
38972
 
38789
38973
  // src/server/handler.ts
38790
- var logger25 = createLogger({
38974
+ var logger27 = createLogger({
38791
38975
  service: "records-lambda",
38792
38976
  level: process.env.LOG_LEVEL || "info"
38793
38977
  });
38794
- logger25.info("Records Lambda started with automatic shadow field detection");
38978
+ logger27.info("Records Lambda started with automatic shadow field detection");
38795
38979
  async function handler(event) {
38796
38980
  const requestId = event.requestContext.requestId;
38797
- logger25.info("Received request", {
38981
+ logger27.info("Received request", {
38798
38982
  requestId,
38799
38983
  method: event.requestContext.http.method,
38800
38984
  path: event.requestContext.http.path
@@ -38804,7 +38988,7 @@ async function handler(event) {
38804
38988
  return createCorsResponse(HTTP_STATUS.OK);
38805
38989
  }
38806
38990
  if (event.requestContext.http.method === "GET" && event.requestContext.http.path === "/version") {
38807
- const version = "1.8.0";
38991
+ const version = "1.10.0";
38808
38992
  return createSuccessResponse({ version, timestamp: (/* @__PURE__ */ new Date()).toISOString() }, requestId);
38809
38993
  }
38810
38994
  if (event.requestContext.http.method !== "POST") {
@@ -38812,7 +38996,7 @@ async function handler(event) {
38812
38996
  }
38813
38997
  await handleAuthentication(event, requestId);
38814
38998
  const request2 = parseRequestBody(event.body);
38815
- logger25.info("Parsed request", {
38999
+ logger27.info("Parsed request", {
38816
39000
  requestId,
38817
39001
  operation: request2.op,
38818
39002
  resource: request2.resource