@exabugs/dynamodb-client 1.9.0 → 1.11.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.
- package/CHANGELOG.md +26 -0
- package/README.md +1 -0
- package/dist/integrations/react-admin/dataProvider.d.ts.map +1 -1
- package/dist/integrations/react-admin/dataProvider.js +3 -26
- package/dist/integrations/react-admin/dataProvider.js.map +1 -1
- package/dist/notify/channels/email.d.ts +32 -0
- package/dist/notify/channels/email.d.ts.map +1 -0
- package/dist/notify/channels/email.js +67 -0
- package/dist/notify/channels/email.js.map +1 -0
- package/dist/notify/channels/slack.d.ts +12 -0
- package/dist/notify/channels/slack.d.ts.map +1 -0
- package/dist/notify/channels/slack.js +46 -0
- package/dist/notify/channels/slack.js.map +1 -0
- package/dist/notify/format.d.ts +7 -0
- package/dist/notify/format.d.ts.map +1 -0
- package/dist/notify/format.js +29 -0
- package/dist/notify/format.js.map +1 -0
- package/dist/notify/handler.d.ts +42 -0
- package/dist/notify/handler.d.ts.map +1 -0
- package/dist/notify/handler.js +175 -0
- package/dist/notify/handler.js.map +1 -0
- package/dist/notify/index.d.ts +18 -0
- package/dist/notify/index.d.ts.map +1 -0
- package/dist/notify/index.js +14 -0
- package/dist/notify/index.js.map +1 -0
- package/dist/notify/logger.d.ts +6 -0
- package/dist/notify/logger.d.ts.map +1 -0
- package/dist/notify/logger.js +11 -0
- package/dist/notify/logger.js.map +1 -0
- package/dist/notify/normalize.d.ts +11 -0
- package/dist/notify/normalize.d.ts.map +1 -0
- package/dist/notify/normalize.js +245 -0
- package/dist/notify/normalize.js.map +1 -0
- package/dist/notify/policy.d.ts +15 -0
- package/dist/notify/policy.d.ts.map +1 -0
- package/dist/notify/policy.js +36 -0
- package/dist/notify/policy.js.map +1 -0
- package/dist/notify/store.d.ts +22 -0
- package/dist/notify/store.d.ts.map +1 -0
- package/dist/notify/store.js +119 -0
- package/dist/notify/store.js.map +1 -0
- package/dist/notify/types.d.ts +63 -0
- package/dist/notify/types.d.ts.map +1 -0
- package/dist/notify/types.js +8 -0
- package/dist/notify/types.js.map +1 -0
- package/dist/server/handler.cjs +577 -495
- package/dist/server/handler.cjs.map +4 -4
- package/dist/server/media-handler.cjs +2 -2
- package/dist/server/media-process-handler-dlq.cjs +438 -340
- package/dist/server/media-process-handler-dlq.cjs.map +4 -4
- package/dist/server/media-process-handler.cjs +437 -339
- package/dist/server/media-process-handler.cjs.map +4 -4
- package/dist/server/operations/deleteMany.d.ts.map +1 -1
- package/dist/server/operations/deleteMany.js +15 -30
- package/dist/server/operations/deleteMany.js.map +1 -1
- package/dist/server/operations/deleteOne.d.ts.map +1 -1
- package/dist/server/operations/deleteOne.js +7 -4
- package/dist/server/operations/deleteOne.js.map +1 -1
- package/dist/server/operations/find/nearQuery.d.ts.map +1 -1
- package/dist/server/operations/find/nearQuery.js +41 -40
- package/dist/server/operations/find/nearQuery.js.map +1 -1
- package/dist/server/operations/find/shadowQuery.d.ts +7 -0
- package/dist/server/operations/find/shadowQuery.d.ts.map +1 -1
- package/dist/server/operations/find/shadowQuery.js +10 -34
- package/dist/server/operations/find/shadowQuery.js.map +1 -1
- package/dist/server/operations/findAll.d.ts +8 -0
- package/dist/server/operations/findAll.d.ts.map +1 -0
- package/dist/server/operations/findAll.js +46 -0
- package/dist/server/operations/findAll.js.map +1 -0
- package/dist/server/operations/findMany.d.ts.map +1 -1
- package/dist/server/operations/findMany.js +9 -26
- package/dist/server/operations/findMany.js.map +1 -1
- package/dist/server/operations/findManyReference.d.ts.map +1 -1
- package/dist/server/operations/findManyReference.js +4 -14
- package/dist/server/operations/findManyReference.js.map +1 -1
- package/dist/server/operations/parameterConverter.d.ts.map +1 -1
- package/dist/server/operations/parameterConverter.js +16 -8
- package/dist/server/operations/parameterConverter.js.map +1 -1
- package/dist/server/operations/updateMany.d.ts.map +1 -1
- package/dist/server/operations/updateMany.js +15 -30
- package/dist/server/operations/updateMany.js.map +1 -1
- package/dist/server/operations/updateOne.d.ts.map +1 -1
- package/dist/server/operations/updateOne.js +8 -6
- package/dist/server/operations/updateOne.js.map +1 -1
- package/dist/server/utils/batchGet.d.ts +21 -0
- package/dist/server/utils/batchGet.d.ts.map +1 -0
- package/dist/server/utils/batchGet.js +73 -0
- package/dist/server/utils/batchGet.js.map +1 -0
- package/dist/server/utils/scanWarning.d.ts +1 -1
- package/dist/server/utils/scanWarning.d.ts.map +1 -1
- package/dist/shared/utils/index.d.ts +1 -0
- package/dist/shared/utils/index.d.ts.map +1 -1
- package/dist/shared/utils/index.js +1 -0
- package/dist/shared/utils/index.js.map +1 -1
- package/dist/shared/utils/scanSort.d.ts +16 -0
- package/dist/shared/utils/scanSort.d.ts.map +1 -0
- package/dist/shared/utils/scanSort.js +33 -0
- package/dist/shared/utils/scanSort.js.map +1 -0
- package/dist/sharp-layer.zip +0 -0
- package/docs/NOTIFY.md +103 -0
- package/package.json +8 -3
package/dist/server/handler.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// @exabugs/dynamodb-client v1.
|
|
2
|
-
// Built: 2026-10-
|
|
1
|
+
// @exabugs/dynamodb-client v1.11.0
|
|
2
|
+
// Built: 2026-10-12T06:23:05.041Z
|
|
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:
|
|
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
|
-
|
|
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:
|
|
1565
|
+
const { clientName, commandName, logger: logger28, dynamoDbDocumentClientOptions = {} } = context;
|
|
1566
1566
|
const { overrideInputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
|
|
1567
1567
|
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
|
|
1568
|
-
|
|
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
|
|
3194
|
+
let logger28;
|
|
3195
3195
|
let tryNextLink = true;
|
|
3196
3196
|
if (typeof options === "boolean") {
|
|
3197
|
-
|
|
3197
|
+
logger28 = void 0;
|
|
3198
3198
|
tryNextLink = options;
|
|
3199
3199
|
} else if (options != null && typeof options === "object") {
|
|
3200
|
-
|
|
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
|
-
|
|
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:
|
|
3640
|
-
const envOptions = { signingName, logger:
|
|
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,
|
|
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, logger27) {
|
|
|
5294
5294
|
const newSize = merge(buffers, mode, chunk);
|
|
5295
5295
|
if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
|
|
5296
5296
|
streamBufferingLoggedWarning = true;
|
|
5297
|
-
|
|
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,
|
|
5361
|
+
function createBufferedReadable(upstream, size, logger28) {
|
|
5362
5362
|
if (isReadableStream(upstream)) {
|
|
5363
|
-
return createBufferedReadableStream(upstream, size,
|
|
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, logger27) {
|
|
|
5393
5393
|
const newSize = merge(buffers, mode, chunk);
|
|
5394
5394
|
if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
|
|
5395
5395
|
streamBufferingLoggedWarning = true;
|
|
5396
|
-
|
|
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:
|
|
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:
|
|
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
|
|
9964
|
+
let logger28;
|
|
9965
9965
|
let tryNextLink = true;
|
|
9966
9966
|
if (typeof options === "boolean") {
|
|
9967
|
-
|
|
9967
|
+
logger28 = void 0;
|
|
9968
9968
|
tryNextLink = options;
|
|
9969
9969
|
} else if (options != null && typeof options === "object") {
|
|
9970
|
-
|
|
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
|
-
|
|
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:
|
|
12772
|
+
const { logger: logger28 } = configuration;
|
|
12773
12773
|
const handlerExecutionContext = {
|
|
12774
|
-
logger:
|
|
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
|
|
16401
|
+
const logger28 = input.logger?.constructor?.name === "NoOpLogger" || !input.logger ? console : input.logger;
|
|
16402
16402
|
if (typeof appId !== "string") {
|
|
16403
|
-
|
|
16403
|
+
logger28?.warn("userAgentAppId must be a string or undefined.");
|
|
16404
16404
|
} else if (appId.length > 50) {
|
|
16405
|
-
|
|
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:
|
|
17293
|
-
const envOptions = { signingName, logger:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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,
|
|
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
|
-
|
|
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
|
|
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,
|
|
19767
|
+
credentials = getExtendedInstanceMetadataCredentials(credentials, logger28);
|
|
19768
19768
|
}
|
|
19769
19769
|
} catch (e4) {
|
|
19770
19770
|
if (pastCredentials) {
|
|
19771
|
-
|
|
19772
|
-
credentials = getExtendedInstanceMetadataCredentials(pastCredentials,
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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:
|
|
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,
|
|
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
|
-
|
|
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,
|
|
21197
|
+
function createBufferedReadable2(upstream, size, logger28) {
|
|
21198
21198
|
if ((0, stream_type_check_1.isReadableStream)(upstream)) {
|
|
21199
|
-
return (0, createBufferedReadableStream_1.createBufferedReadableStream)(upstream, size,
|
|
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
|
-
|
|
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,
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
23465
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
23593
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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,
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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,
|
|
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:
|
|
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:
|
|
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:
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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;
|
|
@@ -34384,12 +34484,12 @@ function getScanWarnThreshold() {
|
|
|
34384
34484
|
const value = Number(raw);
|
|
34385
34485
|
return Number.isInteger(value) && value >= 1 ? value : DEFAULT_SCAN_WARN_THRESHOLD;
|
|
34386
34486
|
}
|
|
34387
|
-
var
|
|
34487
|
+
var logger6, SPARSE_SCAN_EVENT, DEFAULT_SCAN_WARN_THRESHOLD, ScanWatcher;
|
|
34388
34488
|
var init_scanWarning = __esm({
|
|
34389
34489
|
"src/server/utils/scanWarning.ts"() {
|
|
34390
34490
|
"use strict";
|
|
34391
34491
|
init_shared();
|
|
34392
|
-
|
|
34492
|
+
logger6 = createLogger({ service: "scan-warning", level: "warn" });
|
|
34393
34493
|
SPARSE_SCAN_EVENT = "SPARSE_SCAN";
|
|
34394
34494
|
DEFAULT_SCAN_WARN_THRESHOLD = 5e3;
|
|
34395
34495
|
__name(getScanWarnThreshold, "getScanWarnThreshold");
|
|
@@ -34408,7 +34508,7 @@ var init_scanWarning = __esm({
|
|
|
34408
34508
|
this.scanned += count;
|
|
34409
34509
|
if (!this.warned && this.scanned >= this.threshold) {
|
|
34410
34510
|
this.warned = true;
|
|
34411
|
-
|
|
34511
|
+
logger6.warn(
|
|
34412
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`,
|
|
34413
34513
|
{
|
|
34414
34514
|
event: SPARSE_SCAN_EVENT,
|
|
@@ -34516,7 +34616,7 @@ function parseFilters(filter) {
|
|
|
34516
34616
|
parsedFilters.push({ parsed, value });
|
|
34517
34617
|
}
|
|
34518
34618
|
} catch (error2) {
|
|
34519
|
-
|
|
34619
|
+
logger7.error("Invalid filter field syntax", {
|
|
34520
34620
|
fieldKey,
|
|
34521
34621
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
34522
34622
|
});
|
|
@@ -34585,7 +34685,7 @@ function detectNearQuery(filter) {
|
|
|
34585
34685
|
}
|
|
34586
34686
|
return null;
|
|
34587
34687
|
}
|
|
34588
|
-
var
|
|
34688
|
+
var logger7;
|
|
34589
34689
|
var init_utils5 = __esm({
|
|
34590
34690
|
"src/server/operations/find/utils.ts"() {
|
|
34591
34691
|
"use strict";
|
|
@@ -34594,7 +34694,7 @@ var init_utils5 = __esm({
|
|
|
34594
34694
|
init_shadow();
|
|
34595
34695
|
init_filter();
|
|
34596
34696
|
init_validation2();
|
|
34597
|
-
|
|
34697
|
+
logger7 = createLogger({
|
|
34598
34698
|
service: "find-utils",
|
|
34599
34699
|
level: process.env.LOG_LEVEL || "info"
|
|
34600
34700
|
});
|
|
@@ -34611,7 +34711,7 @@ var init_utils5 = __esm({
|
|
|
34611
34711
|
async function executeIdQuery(resource, normalizedParams, requestId) {
|
|
34612
34712
|
const { sort, pagination, parsedFilters } = normalizedParams;
|
|
34613
34713
|
const { perPage, nextToken } = pagination;
|
|
34614
|
-
|
|
34714
|
+
logger8.debug("Executing ID optimized query", {
|
|
34615
34715
|
requestId,
|
|
34616
34716
|
resource,
|
|
34617
34717
|
sort,
|
|
@@ -34632,7 +34732,7 @@ async function executeSpecificIdQuery(resource, targetId, requestId) {
|
|
|
34632
34732
|
const costTracker = new CostTracker();
|
|
34633
34733
|
const queryResult = await executeDynamoDBOperation(
|
|
34634
34734
|
() => dbClient2.send(
|
|
34635
|
-
new
|
|
34735
|
+
new import_lib_dynamodb3.QueryCommand({
|
|
34636
34736
|
TableName: tableName,
|
|
34637
34737
|
KeyConditionExpression: "PK = :pk AND SK = :sk",
|
|
34638
34738
|
ExpressionAttributeValues: {
|
|
@@ -34648,7 +34748,7 @@ async function executeSpecificIdQuery(resource, targetId, requestId) {
|
|
|
34648
34748
|
costTracker.add(queryResult.ConsumedCapacity);
|
|
34649
34749
|
const mainRecords = queryResult.Items || [];
|
|
34650
34750
|
const items = mainRecords.map((item) => extractCleanRecord(item));
|
|
34651
|
-
|
|
34751
|
+
logger8.info("ID specific query succeeded", {
|
|
34652
34752
|
requestId,
|
|
34653
34753
|
resource,
|
|
34654
34754
|
targetId,
|
|
@@ -34671,7 +34771,7 @@ async function executeInQuery(resource, targetIds, sort, requestId) {
|
|
|
34671
34771
|
targetIds.map(
|
|
34672
34772
|
(id) => executeDynamoDBOperation(
|
|
34673
34773
|
() => dbClient2.send(
|
|
34674
|
-
new
|
|
34774
|
+
new import_lib_dynamodb3.QueryCommand({
|
|
34675
34775
|
TableName: tableName,
|
|
34676
34776
|
KeyConditionExpression: "PK = :pk AND SK = :sk",
|
|
34677
34777
|
ExpressionAttributeValues: {
|
|
@@ -34695,7 +34795,7 @@ async function executeInQuery(resource, targetIds, sort, requestId) {
|
|
|
34695
34795
|
const bVal = String(b4.id ?? "");
|
|
34696
34796
|
return sort.order === "ASC" ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal);
|
|
34697
34797
|
});
|
|
34698
|
-
|
|
34798
|
+
logger8.info("ID $in query succeeded", {
|
|
34699
34799
|
requestId,
|
|
34700
34800
|
resource,
|
|
34701
34801
|
requestedCount: targetIds.length,
|
|
@@ -34734,7 +34834,7 @@ async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsed
|
|
|
34734
34834
|
}
|
|
34735
34835
|
const queryResult = await executeDynamoDBOperation(
|
|
34736
34836
|
() => dbClient2.send(
|
|
34737
|
-
new
|
|
34837
|
+
new import_lib_dynamodb3.QueryCommand({
|
|
34738
34838
|
TableName: tableName,
|
|
34739
34839
|
KeyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
34740
34840
|
ExpressionAttributeValues: {
|
|
@@ -34771,7 +34871,7 @@ async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsed
|
|
|
34771
34871
|
queryResult.LastEvaluatedKey.PK,
|
|
34772
34872
|
queryResult.LastEvaluatedKey.SK
|
|
34773
34873
|
) : void 0;
|
|
34774
|
-
|
|
34874
|
+
logger8.info("ID all records query succeeded", {
|
|
34775
34875
|
requestId,
|
|
34776
34876
|
resource,
|
|
34777
34877
|
count: items.length,
|
|
@@ -34812,7 +34912,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
34812
34912
|
});
|
|
34813
34913
|
scan: while (true) {
|
|
34814
34914
|
if (++iterations > SCAN_MAX_ITERATIONS) {
|
|
34815
|
-
|
|
34915
|
+
logger8.error("executeAllRecordsQueryFullScan: \u6700\u5927\u53CD\u5FA9\u56DE\u6570\u3092\u8D85\u904E", {
|
|
34816
34916
|
requestId,
|
|
34817
34917
|
resource,
|
|
34818
34918
|
iterations
|
|
@@ -34824,7 +34924,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
34824
34924
|
}
|
|
34825
34925
|
const queryResult = await executeDynamoDBOperation(
|
|
34826
34926
|
() => dbClient2.send(
|
|
34827
|
-
new
|
|
34927
|
+
new import_lib_dynamodb3.QueryCommand({
|
|
34828
34928
|
TableName: tableName,
|
|
34829
34929
|
KeyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
34830
34930
|
ExpressionAttributeValues: {
|
|
@@ -34860,7 +34960,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
34860
34960
|
}
|
|
34861
34961
|
const nextKeySignature = `${nextKey.PK}#${nextKey.SK}`;
|
|
34862
34962
|
if (nextKeySignature === previousKeySignature) {
|
|
34863
|
-
|
|
34963
|
+
logger8.error("executeAllRecordsQueryFullScan: \u540C\u4E00\u306ELastEvaluatedKey\u304C\u8FD4\u5374\u3055\u308C\u305F", {
|
|
34864
34964
|
requestId,
|
|
34865
34965
|
resource,
|
|
34866
34966
|
iterations
|
|
@@ -34877,7 +34977,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
34877
34977
|
chunkSize = Math.min(chunkSize * 2, SCAN_CHUNK_MAX);
|
|
34878
34978
|
}
|
|
34879
34979
|
const nextTokenValue = hasNextPage && lastReturned ? encodeNextToken(lastReturned.PK, lastReturned.SK) : void 0;
|
|
34880
|
-
|
|
34980
|
+
logger8.info("ID filtered scan query succeeded", {
|
|
34881
34981
|
requestId,
|
|
34882
34982
|
resource,
|
|
34883
34983
|
scanned,
|
|
@@ -34891,18 +34991,18 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
34891
34991
|
consumedCapacity: costTracker.getAggregated()
|
|
34892
34992
|
};
|
|
34893
34993
|
}
|
|
34894
|
-
var
|
|
34994
|
+
var import_lib_dynamodb3, logger8, SCAN_CHUNK_INITIAL, SCAN_CHUNK_MAX, SCAN_MAX_ITERATIONS;
|
|
34895
34995
|
var init_idQuery = __esm({
|
|
34896
34996
|
"src/server/operations/find/idQuery.ts"() {
|
|
34897
34997
|
"use strict";
|
|
34898
|
-
|
|
34998
|
+
import_lib_dynamodb3 = __toESM(require_dist_cjs65(), 1);
|
|
34899
34999
|
init_shared();
|
|
34900
35000
|
init_cost_tracker();
|
|
34901
35001
|
init_dynamodb3();
|
|
34902
35002
|
init_pagination();
|
|
34903
35003
|
init_scanWarning();
|
|
34904
35004
|
init_utils5();
|
|
34905
|
-
|
|
35005
|
+
logger8 = createLogger({
|
|
34906
35006
|
service: "id-query",
|
|
34907
35007
|
level: process.env.LOG_LEVEL || "info"
|
|
34908
35008
|
});
|
|
@@ -34919,7 +35019,7 @@ var init_idQuery = __esm({
|
|
|
34919
35019
|
|
|
34920
35020
|
// src/server/operations/find/nearQuery.ts
|
|
34921
35021
|
async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId) {
|
|
34922
|
-
|
|
35022
|
+
logger9.debug("Executing $near query", {
|
|
34923
35023
|
requestId,
|
|
34924
35024
|
resource,
|
|
34925
35025
|
fieldName,
|
|
@@ -34930,32 +35030,58 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
34930
35030
|
const searchFunction = /* @__PURE__ */ __name(async (geohashPrefix) => {
|
|
34931
35031
|
const dbClient2 = getDBClient();
|
|
34932
35032
|
const tableName = getTableName();
|
|
34933
|
-
|
|
35033
|
+
logger9.debug("Searching shadow records", {
|
|
34934
35034
|
requestId,
|
|
34935
35035
|
resource,
|
|
34936
35036
|
fieldName,
|
|
34937
35037
|
geohashPrefix,
|
|
34938
35038
|
skPrefix: `${fieldName}#${geohashPrefix}`
|
|
34939
35039
|
});
|
|
34940
|
-
const
|
|
34941
|
-
|
|
34942
|
-
|
|
34943
|
-
|
|
34944
|
-
|
|
34945
|
-
|
|
34946
|
-
|
|
34947
|
-
|
|
34948
|
-
|
|
34949
|
-
|
|
34950
|
-
|
|
34951
|
-
|
|
34952
|
-
|
|
34953
|
-
|
|
34954
|
-
|
|
34955
|
-
|
|
34956
|
-
|
|
34957
|
-
|
|
34958
|
-
|
|
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", {
|
|
34959
35085
|
requestId,
|
|
34960
35086
|
resource,
|
|
34961
35087
|
geohashPrefix,
|
|
@@ -34966,48 +35092,24 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
34966
35092
|
const parts = sk.split("#id#");
|
|
34967
35093
|
return parts.length === 2 ? parts[1] : null;
|
|
34968
35094
|
}).filter((id) => id !== null);
|
|
34969
|
-
|
|
35095
|
+
logger9.debug("Main record IDs extracted", {
|
|
34970
35096
|
requestId,
|
|
34971
35097
|
resource,
|
|
34972
35098
|
geohashPrefix,
|
|
34973
35099
|
ids: mainRecordIds
|
|
34974
35100
|
});
|
|
34975
|
-
const
|
|
34976
|
-
|
|
34977
|
-
|
|
34978
|
-
|
|
34979
|
-
|
|
34980
|
-
() => dbClient2.send(
|
|
34981
|
-
new import_lib_dynamodb3.BatchGetCommand({
|
|
34982
|
-
RequestItems: {
|
|
34983
|
-
[tableName]: {
|
|
34984
|
-
Keys: chunk.map((id) => ({
|
|
34985
|
-
PK: resource,
|
|
34986
|
-
SK: `id#${id}`
|
|
34987
|
-
})),
|
|
34988
|
-
ConsistentRead: false
|
|
34989
|
-
}
|
|
34990
|
-
},
|
|
34991
|
-
ReturnConsumedCapacity: "TOTAL"
|
|
34992
|
-
})
|
|
34993
|
-
),
|
|
34994
|
-
"BatchGetItem"
|
|
34995
|
-
);
|
|
34996
|
-
if (batchGetResult.ConsumedCapacity) {
|
|
34997
|
-
for (const capacity of batchGetResult.ConsumedCapacity) {
|
|
34998
|
-
costTracker.add(capacity);
|
|
34999
|
-
}
|
|
35000
|
-
}
|
|
35001
|
-
validRecords.push(...batchGetResult.Responses?.[tableName] || []);
|
|
35002
|
-
}
|
|
35003
|
-
logger8.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", {
|
|
35004
35106
|
requestId,
|
|
35005
35107
|
resource,
|
|
35006
35108
|
geohashPrefix,
|
|
35007
35109
|
count: validRecords.length
|
|
35008
35110
|
});
|
|
35009
35111
|
const cleanRecords = validRecords.map((record) => extractCleanRecord(record));
|
|
35010
|
-
|
|
35112
|
+
logger9.debug("Clean records extracted", {
|
|
35011
35113
|
requestId,
|
|
35012
35114
|
resource,
|
|
35013
35115
|
geohashPrefix,
|
|
@@ -35026,7 +35128,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
35026
35128
|
config
|
|
35027
35129
|
);
|
|
35028
35130
|
const items = result.documents;
|
|
35029
|
-
|
|
35131
|
+
logger9.info("$near query succeeded", {
|
|
35030
35132
|
requestId,
|
|
35031
35133
|
resource,
|
|
35032
35134
|
fieldName,
|
|
@@ -35044,17 +35146,19 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
35044
35146
|
consumedCapacity: costTracker.getAggregated()
|
|
35045
35147
|
};
|
|
35046
35148
|
}
|
|
35047
|
-
var
|
|
35149
|
+
var import_lib_dynamodb4, logger9;
|
|
35048
35150
|
var init_nearQuery = __esm({
|
|
35049
35151
|
"src/server/operations/find/nearQuery.ts"() {
|
|
35050
35152
|
"use strict";
|
|
35051
|
-
|
|
35153
|
+
import_lib_dynamodb4 = __toESM(require_dist_cjs65(), 1);
|
|
35052
35154
|
init_geohash();
|
|
35053
35155
|
init_shared();
|
|
35054
35156
|
init_nearSearch();
|
|
35157
|
+
init_batchGet();
|
|
35055
35158
|
init_cost_tracker();
|
|
35056
35159
|
init_dynamodb3();
|
|
35057
|
-
|
|
35160
|
+
init_scanWarning();
|
|
35161
|
+
logger9 = createLogger({
|
|
35058
35162
|
service: "near-query",
|
|
35059
35163
|
level: process.env.LOG_LEVEL || "info"
|
|
35060
35164
|
});
|
|
@@ -35084,7 +35188,7 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
35084
35188
|
(f4) => !(isKeyConditionOptimized && f4 === optimizableFilter)
|
|
35085
35189
|
);
|
|
35086
35190
|
if (residualFilters.length > 0) {
|
|
35087
|
-
|
|
35191
|
+
logger10.debug("Residual filters detected, falling back to full scan", {
|
|
35088
35192
|
requestId,
|
|
35089
35193
|
resource,
|
|
35090
35194
|
sortField: sort.field,
|
|
@@ -35092,7 +35196,7 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
35092
35196
|
});
|
|
35093
35197
|
return executeFullScanQuery(resource, normalizedParams, costTracker, requestId);
|
|
35094
35198
|
}
|
|
35095
|
-
|
|
35199
|
+
logger10.debug("Executing shadow query", {
|
|
35096
35200
|
requestId,
|
|
35097
35201
|
resource,
|
|
35098
35202
|
sortField: sort.field,
|
|
@@ -35140,7 +35244,7 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
35140
35244
|
shadowRecords.LastEvaluatedKey.PK,
|
|
35141
35245
|
shadowRecords.LastEvaluatedKey.SK
|
|
35142
35246
|
) : void 0;
|
|
35143
|
-
|
|
35247
|
+
logger10.info("Shadow query succeeded", {
|
|
35144
35248
|
requestId,
|
|
35145
35249
|
resource,
|
|
35146
35250
|
sortField: sort.field,
|
|
@@ -35165,7 +35269,7 @@ async function executeFilterFirstQuery(resource, normalizedParams, filterCandida
|
|
|
35165
35269
|
const offset = nextToken ? decodeOffsetToken(nextToken) ?? 0 : 0;
|
|
35166
35270
|
const filterSort = { field: filterCandidate.parsed.field, order: "ASC" };
|
|
35167
35271
|
const remainingFilters = parsedFilters.filter((f4) => f4 !== filterCandidate);
|
|
35168
|
-
|
|
35272
|
+
logger10.debug("Executing filter-first query", {
|
|
35169
35273
|
requestId,
|
|
35170
35274
|
resource,
|
|
35171
35275
|
filterField: filterCandidate.parsed.field,
|
|
@@ -35188,7 +35292,7 @@ async function executeFilterFirstQuery(resource, normalizedParams, filterCandida
|
|
|
35188
35292
|
const page = items.slice(offset, offset + perPage);
|
|
35189
35293
|
const hasNextPage = offset + perPage < items.length;
|
|
35190
35294
|
const nextTokenValue = hasNextPage ? encodeOffsetToken(offset + perPage) : void 0;
|
|
35191
|
-
|
|
35295
|
+
logger10.info("Filter-first query succeeded", {
|
|
35192
35296
|
requestId,
|
|
35193
35297
|
resource,
|
|
35194
35298
|
filterField: filterCandidate.parsed.field,
|
|
@@ -35209,7 +35313,7 @@ async function executeFullScanQuery(resource, normalizedParams, costTracker, req
|
|
|
35209
35313
|
const { sort, pagination, parsedFilters } = normalizedParams;
|
|
35210
35314
|
const { perPage, nextToken } = pagination;
|
|
35211
35315
|
const offset = nextToken ? decodeOffsetToken(nextToken) ?? 0 : 0;
|
|
35212
|
-
|
|
35316
|
+
logger10.debug("Executing full scan query", {
|
|
35213
35317
|
requestId,
|
|
35214
35318
|
resource,
|
|
35215
35319
|
sortField: sort.field,
|
|
@@ -35230,7 +35334,7 @@ async function executeFullScanQuery(resource, normalizedParams, costTracker, req
|
|
|
35230
35334
|
const page = items.slice(offset, offset + perPage);
|
|
35231
35335
|
const hasNextPage = offset + perPage < items.length;
|
|
35232
35336
|
const nextTokenValue = hasNextPage ? encodeOffsetToken(offset + perPage) : void 0;
|
|
35233
|
-
|
|
35337
|
+
logger10.info("Full scan query succeeded", {
|
|
35234
35338
|
requestId,
|
|
35235
35339
|
resource,
|
|
35236
35340
|
sortField: sort.field,
|
|
@@ -35261,7 +35365,7 @@ async function fetchAllRecordsViaShadowIndex(resource, indexSort, indexFilter, c
|
|
|
35261
35365
|
let iterations = 0;
|
|
35262
35366
|
do {
|
|
35263
35367
|
if (++iterations > MAX_ITERATIONS) {
|
|
35264
|
-
|
|
35368
|
+
logger10.error("fetchAllRecordsViaShadowIndex: \u6700\u5927\u53CD\u5FA9\u56DE\u6570\u3092\u8D85\u904E", {
|
|
35265
35369
|
requestId,
|
|
35266
35370
|
resource,
|
|
35267
35371
|
iterations
|
|
@@ -35291,7 +35395,7 @@ async function fetchAllRecordsViaShadowIndex(resource, indexSort, indexFilter, c
|
|
|
35291
35395
|
const nextKey = result.LastEvaluatedKey;
|
|
35292
35396
|
const nextKeySignature = nextKey ? `${nextKey.PK}#${nextKey.SK}` : void 0;
|
|
35293
35397
|
if (nextKeySignature && nextKeySignature === previousKeySignature) {
|
|
35294
|
-
|
|
35398
|
+
logger10.error("fetchAllRecordsViaShadowIndex: \u540C\u4E00\u306ELastEvaluatedKey\u304C\u8FD4\u5374\u3055\u308C\u305F", {
|
|
35295
35399
|
requestId,
|
|
35296
35400
|
resource,
|
|
35297
35401
|
iterations
|
|
@@ -35363,7 +35467,7 @@ async function executeShadowRecordQuery(resource, sort, perPage, nextToken, opti
|
|
|
35363
35467
|
);
|
|
35364
35468
|
const result = await executeDynamoDBOperation(
|
|
35365
35469
|
() => dbClient2.send(
|
|
35366
|
-
new
|
|
35470
|
+
new import_lib_dynamodb5.QueryCommand({
|
|
35367
35471
|
TableName: tableName,
|
|
35368
35472
|
KeyConditionExpression: keyConditionExpression,
|
|
35369
35473
|
ExpressionAttributeValues: expressionAttributeValues,
|
|
@@ -35471,63 +35575,37 @@ function encodeValueForShadowSK(value, type) {
|
|
|
35471
35575
|
function extractRecordIds(shadowRecords) {
|
|
35472
35576
|
return shadowRecords.map((record) => {
|
|
35473
35577
|
const sk = record.SK;
|
|
35474
|
-
const
|
|
35475
|
-
return
|
|
35578
|
+
const index = sk.lastIndexOf("#id#");
|
|
35579
|
+
return index >= 0 ? sk.slice(index + "#id#".length) : null;
|
|
35476
35580
|
}).filter((id) => id !== null);
|
|
35477
35581
|
}
|
|
35478
35582
|
async function fetchMainRecords(resource, recordIds, costTracker, requestId) {
|
|
35479
|
-
const
|
|
35480
|
-
|
|
35481
|
-
|
|
35482
|
-
|
|
35483
|
-
|
|
35484
|
-
for (let i4 = 0; i4 < uniqueRecordIds.length; i4 += BATCH_SIZE) {
|
|
35485
|
-
const chunk = uniqueRecordIds.slice(i4, i4 + BATCH_SIZE);
|
|
35486
|
-
const batchGetResult = await executeDynamoDBOperation(
|
|
35487
|
-
() => dbClient2.send(
|
|
35488
|
-
new import_lib_dynamodb4.BatchGetCommand({
|
|
35489
|
-
RequestItems: {
|
|
35490
|
-
[tableName]: {
|
|
35491
|
-
Keys: chunk.map((id) => ({
|
|
35492
|
-
PK: resource,
|
|
35493
|
-
SK: `id#${id}`
|
|
35494
|
-
})),
|
|
35495
|
-
ConsistentRead: true
|
|
35496
|
-
}
|
|
35497
|
-
},
|
|
35498
|
-
ReturnConsumedCapacity: "TOTAL"
|
|
35499
|
-
})
|
|
35500
|
-
),
|
|
35501
|
-
"BatchGetItem"
|
|
35502
|
-
);
|
|
35503
|
-
if (batchGetResult.ConsumedCapacity) {
|
|
35504
|
-
for (const capacity of batchGetResult.ConsumedCapacity) {
|
|
35505
|
-
costTracker.add(capacity);
|
|
35506
|
-
}
|
|
35507
|
-
}
|
|
35508
|
-
allRecords.push(...batchGetResult.Responses?.[tableName] || []);
|
|
35509
|
-
}
|
|
35510
|
-
logger9.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", {
|
|
35511
35588
|
requestId,
|
|
35512
35589
|
resource,
|
|
35513
|
-
requestedCount:
|
|
35590
|
+
requestedCount: new Set(recordIds).size,
|
|
35514
35591
|
fetchedCount: allRecords.length
|
|
35515
35592
|
});
|
|
35516
35593
|
return allRecords;
|
|
35517
35594
|
}
|
|
35518
|
-
var
|
|
35595
|
+
var import_lib_dynamodb5, logger10, KEY_CONDITION_OPERATORS;
|
|
35519
35596
|
var init_shadowQuery = __esm({
|
|
35520
35597
|
"src/server/operations/find/shadowQuery.ts"() {
|
|
35521
35598
|
"use strict";
|
|
35522
|
-
|
|
35599
|
+
import_lib_dynamodb5 = __toESM(require_dist_cjs65(), 1);
|
|
35523
35600
|
init_formatting();
|
|
35524
35601
|
init_shared();
|
|
35602
|
+
init_batchGet();
|
|
35525
35603
|
init_cost_tracker();
|
|
35526
35604
|
init_dynamodb3();
|
|
35527
35605
|
init_pagination();
|
|
35528
35606
|
init_scanWarning();
|
|
35529
35607
|
init_utils5();
|
|
35530
|
-
|
|
35608
|
+
logger10 = createLogger({
|
|
35531
35609
|
service: "shadow-query",
|
|
35532
35610
|
level: process.env.LOG_LEVEL || "info"
|
|
35533
35611
|
});
|
|
@@ -35548,14 +35626,14 @@ var init_shadowQuery = __esm({
|
|
|
35548
35626
|
|
|
35549
35627
|
// src/server/operations/find/handler.ts
|
|
35550
35628
|
async function handleFind(resource, params, requestId) {
|
|
35551
|
-
|
|
35629
|
+
logger11.debug("Executing find", {
|
|
35552
35630
|
requestId,
|
|
35553
35631
|
resource,
|
|
35554
35632
|
params
|
|
35555
35633
|
});
|
|
35556
35634
|
const nearDetection = detectNearQuery(params.filter);
|
|
35557
35635
|
if (nearDetection) {
|
|
35558
|
-
|
|
35636
|
+
logger11.debug("$near operator detected, executing near search", {
|
|
35559
35637
|
requestId,
|
|
35560
35638
|
resource,
|
|
35561
35639
|
fieldName: nearDetection.fieldName
|
|
@@ -35572,7 +35650,7 @@ async function handleFind(resource, params, requestId) {
|
|
|
35572
35650
|
const config = initializeFindConfig();
|
|
35573
35651
|
const normalizedParams = normalizeFindParams(config, resource, params);
|
|
35574
35652
|
validateSortField(config, resource, normalizedParams.sort);
|
|
35575
|
-
|
|
35653
|
+
logger11.debug("Find parameters normalized", {
|
|
35576
35654
|
requestId,
|
|
35577
35655
|
resource,
|
|
35578
35656
|
sort: normalizedParams.sort,
|
|
@@ -35587,7 +35665,7 @@ async function handleFind(resource, params, requestId) {
|
|
|
35587
35665
|
}
|
|
35588
35666
|
return executeShadowQuery(resource, normalizedParams, requestId);
|
|
35589
35667
|
}
|
|
35590
|
-
var
|
|
35668
|
+
var logger11;
|
|
35591
35669
|
var init_handler = __esm({
|
|
35592
35670
|
"src/server/operations/find/handler.ts"() {
|
|
35593
35671
|
"use strict";
|
|
@@ -35597,7 +35675,7 @@ var init_handler = __esm({
|
|
|
35597
35675
|
init_nearQuery();
|
|
35598
35676
|
init_shadowQuery();
|
|
35599
35677
|
init_utils5();
|
|
35600
|
-
|
|
35678
|
+
logger11 = createLogger({
|
|
35601
35679
|
service: "find-handler",
|
|
35602
35680
|
level: process.env.LOG_LEVEL || "info"
|
|
35603
35681
|
});
|
|
@@ -35606,10 +35684,6 @@ var init_handler = __esm({
|
|
|
35606
35684
|
});
|
|
35607
35685
|
|
|
35608
35686
|
// src/server/operations/find.ts
|
|
35609
|
-
var find_exports = {};
|
|
35610
|
-
__export(find_exports, {
|
|
35611
|
-
handleFind: () => handleFind
|
|
35612
|
-
});
|
|
35613
35687
|
var init_find = __esm({
|
|
35614
35688
|
"src/server/operations/find.ts"() {
|
|
35615
35689
|
"use strict";
|
|
@@ -35617,6 +35691,60 @@ var init_find = __esm({
|
|
|
35617
35691
|
}
|
|
35618
35692
|
});
|
|
35619
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
|
+
|
|
35620
35748
|
// src/server/operations/deleteMany.ts
|
|
35621
35749
|
var deleteMany_exports = {};
|
|
35622
35750
|
__export(deleteMany_exports, {
|
|
@@ -35628,21 +35756,31 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
35628
35756
|
let ids;
|
|
35629
35757
|
if ("ids" in params) {
|
|
35630
35758
|
ids = params.ids;
|
|
35631
|
-
|
|
35759
|
+
logger12.debug("Executing deleteMany with ids", {
|
|
35632
35760
|
requestId,
|
|
35633
35761
|
resource,
|
|
35634
35762
|
count: ids.length
|
|
35635
35763
|
});
|
|
35636
35764
|
} else {
|
|
35637
|
-
|
|
35765
|
+
logger12.debug("Executing deleteMany with filter", {
|
|
35638
35766
|
requestId,
|
|
35639
35767
|
resource,
|
|
35640
35768
|
filter: params.filter
|
|
35641
35769
|
});
|
|
35642
|
-
|
|
35643
|
-
|
|
35644
|
-
|
|
35645
|
-
|
|
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", {
|
|
35646
35784
|
requestId,
|
|
35647
35785
|
resource,
|
|
35648
35786
|
count: ids.length
|
|
@@ -35660,32 +35798,10 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
35660
35798
|
logLargeBatchWarning("deleteMany", ids.length, requestId, resource);
|
|
35661
35799
|
const dbClient2 = getDBClient();
|
|
35662
35800
|
const tableName = getTableName();
|
|
35663
|
-
const
|
|
35664
|
-
PK: resource,
|
|
35665
|
-
|
|
35666
|
-
}));
|
|
35667
|
-
const batchGetResult = await executeDynamoDBOperation(
|
|
35668
|
-
() => dbClient2.send(
|
|
35669
|
-
new import_lib_dynamodb5.BatchGetCommand({
|
|
35670
|
-
RequestItems: {
|
|
35671
|
-
[tableName]: {
|
|
35672
|
-
Keys: keys,
|
|
35673
|
-
ConsistentRead: true
|
|
35674
|
-
}
|
|
35675
|
-
},
|
|
35676
|
-
ReturnConsumedCapacity: "TOTAL"
|
|
35677
|
-
})
|
|
35678
|
-
),
|
|
35679
|
-
"BatchGetItem"
|
|
35801
|
+
const existingItems = await batchGetAll(
|
|
35802
|
+
ids.map((id) => ({ PK: resource, SK: generateMainRecordSK2(id) })),
|
|
35803
|
+
{ consistentRead: true, costTracker, requestId }
|
|
35680
35804
|
);
|
|
35681
|
-
if (Array.isArray(batchGetResult.ConsumedCapacity)) {
|
|
35682
|
-
for (const capacity of batchGetResult.ConsumedCapacity) {
|
|
35683
|
-
costTracker.add(capacity);
|
|
35684
|
-
}
|
|
35685
|
-
} else {
|
|
35686
|
-
costTracker.add(batchGetResult.ConsumedCapacity);
|
|
35687
|
-
}
|
|
35688
|
-
const existingItems = batchGetResult.Responses?.[tableName] || [];
|
|
35689
35805
|
const existingIds = /* @__PURE__ */ new Set();
|
|
35690
35806
|
const preparedRecords = [];
|
|
35691
35807
|
for (const item of existingItems) {
|
|
@@ -35706,7 +35822,7 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
35706
35822
|
message: `Record not found: ${id}`
|
|
35707
35823
|
}));
|
|
35708
35824
|
if (preparedRecords.length === 0) {
|
|
35709
|
-
|
|
35825
|
+
logger12.info("deleteMany completed - no records found", {
|
|
35710
35826
|
requestId,
|
|
35711
35827
|
resource,
|
|
35712
35828
|
requested: ids.length,
|
|
@@ -35770,7 +35886,7 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
35770
35886
|
}
|
|
35771
35887
|
const result = await executeDynamoDBOperation(
|
|
35772
35888
|
() => dbClient2.send(
|
|
35773
|
-
new
|
|
35889
|
+
new import_lib_dynamodb6.TransactWriteCommand({
|
|
35774
35890
|
TransactItems: transactItems,
|
|
35775
35891
|
ReturnConsumedCapacity: "TOTAL"
|
|
35776
35892
|
})
|
|
@@ -35865,18 +35981,20 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
35865
35981
|
consumedCapacity: costTracker.getAggregated()
|
|
35866
35982
|
};
|
|
35867
35983
|
}
|
|
35868
|
-
var
|
|
35984
|
+
var import_lib_dynamodb6, logger12;
|
|
35869
35985
|
var init_deleteMany = __esm({
|
|
35870
35986
|
"src/server/operations/deleteMany.ts"() {
|
|
35871
35987
|
"use strict";
|
|
35872
|
-
|
|
35988
|
+
import_lib_dynamodb6 = __toESM(require_dist_cjs65(), 1);
|
|
35873
35989
|
init_shared();
|
|
35874
35990
|
init_shadow();
|
|
35991
|
+
init_batchGet();
|
|
35875
35992
|
init_bulkOperations();
|
|
35876
35993
|
init_chunking();
|
|
35877
35994
|
init_cost_tracker();
|
|
35878
35995
|
init_dynamodb3();
|
|
35879
|
-
|
|
35996
|
+
init_findAll();
|
|
35997
|
+
logger12 = createLogger({ service: "records-lambda" });
|
|
35880
35998
|
__name(handleDeleteMany, "handleDeleteMany");
|
|
35881
35999
|
}
|
|
35882
36000
|
});
|
|
@@ -35885,7 +36003,7 @@ var init_deleteMany = __esm({
|
|
|
35885
36003
|
async function handleFindMany(resource, params, requestId) {
|
|
35886
36004
|
if ("ids" in params) {
|
|
35887
36005
|
const { ids } = params;
|
|
35888
|
-
|
|
36006
|
+
logger14.debug("Executing findMany by ids", {
|
|
35889
36007
|
requestId,
|
|
35890
36008
|
resource,
|
|
35891
36009
|
count: ids.length
|
|
@@ -35893,28 +36011,12 @@ async function handleFindMany(resource, params, requestId) {
|
|
|
35893
36011
|
if (ids.length === 0) {
|
|
35894
36012
|
return [];
|
|
35895
36013
|
}
|
|
35896
|
-
const
|
|
35897
|
-
|
|
35898
|
-
|
|
35899
|
-
PK: resource,
|
|
35900
|
-
SK: generateMainRecordSK2(id)
|
|
35901
|
-
}));
|
|
35902
|
-
const result = await executeDynamoDBOperation(
|
|
35903
|
-
() => dbClient2.send(
|
|
35904
|
-
new import_lib_dynamodb6.BatchGetCommand({
|
|
35905
|
-
RequestItems: {
|
|
35906
|
-
[tableName]: {
|
|
35907
|
-
Keys: keys,
|
|
35908
|
-
ConsistentRead: true
|
|
35909
|
-
}
|
|
35910
|
-
}
|
|
35911
|
-
})
|
|
35912
|
-
),
|
|
35913
|
-
"BatchGetItem"
|
|
36014
|
+
const items = await batchGetAll(
|
|
36015
|
+
ids.map((id) => ({ PK: resource, SK: generateMainRecordSK2(id) })),
|
|
36016
|
+
{ consistentRead: true, requestId }
|
|
35914
36017
|
);
|
|
35915
|
-
const items = result.Responses?.[tableName] || [];
|
|
35916
36018
|
const records = items.map((item) => extractCleanRecord(item));
|
|
35917
|
-
|
|
36019
|
+
logger14.info("findMany by ids succeeded", {
|
|
35918
36020
|
requestId,
|
|
35919
36021
|
resource,
|
|
35920
36022
|
requested: ids.length,
|
|
@@ -35924,38 +36026,32 @@ async function handleFindMany(resource, params, requestId) {
|
|
|
35924
36026
|
}
|
|
35925
36027
|
if ("filter" in params) {
|
|
35926
36028
|
const { filter } = params;
|
|
35927
|
-
|
|
36029
|
+
logger14.debug("Executing findMany by filter", {
|
|
35928
36030
|
requestId,
|
|
35929
36031
|
resource,
|
|
35930
36032
|
filter
|
|
35931
36033
|
});
|
|
35932
|
-
const
|
|
35933
|
-
|
|
35934
|
-
{
|
|
35935
|
-
filter
|
|
35936
|
-
},
|
|
35937
|
-
requestId
|
|
35938
|
-
);
|
|
35939
|
-
logger13.info("findMany by filter succeeded", {
|
|
36034
|
+
const items = await findAllByFilter(resource, filter, requestId);
|
|
36035
|
+
logger14.info("findMany by filter succeeded", {
|
|
35940
36036
|
requestId,
|
|
35941
36037
|
resource,
|
|
35942
36038
|
filter,
|
|
35943
|
-
found:
|
|
36039
|
+
found: items.length
|
|
35944
36040
|
});
|
|
35945
|
-
return
|
|
36041
|
+
return items;
|
|
35946
36042
|
}
|
|
35947
36043
|
throw new Error("findMany requires either ids or filter");
|
|
35948
36044
|
}
|
|
35949
|
-
var
|
|
36045
|
+
var logger14;
|
|
35950
36046
|
var init_findMany = __esm({
|
|
35951
36047
|
"src/server/operations/findMany.ts"() {
|
|
35952
36048
|
"use strict";
|
|
35953
|
-
import_lib_dynamodb6 = __toESM(require_dist_cjs65(), 1);
|
|
35954
36049
|
init_shared();
|
|
35955
36050
|
init_shadow();
|
|
36051
|
+
init_batchGet();
|
|
35956
36052
|
init_dynamodb3();
|
|
35957
|
-
|
|
35958
|
-
|
|
36053
|
+
init_findAll();
|
|
36054
|
+
logger14 = createLogger({ service: "records-lambda" });
|
|
35959
36055
|
__name(handleFindMany, "handleFindMany");
|
|
35960
36056
|
}
|
|
35961
36057
|
});
|
|
@@ -35968,7 +36064,7 @@ __export(findOne_exports, {
|
|
|
35968
36064
|
async function handleFindOne(resource, params, requestId) {
|
|
35969
36065
|
if ("id" in params) {
|
|
35970
36066
|
const { id } = params;
|
|
35971
|
-
|
|
36067
|
+
logger16.debug("Executing findOne by id (using findMany)", {
|
|
35972
36068
|
requestId,
|
|
35973
36069
|
resource,
|
|
35974
36070
|
id
|
|
@@ -35977,7 +36073,7 @@ async function handleFindOne(resource, params, requestId) {
|
|
|
35977
36073
|
if (results.length === 0) {
|
|
35978
36074
|
throw new ItemNotFoundError(`Record not found: ${id}`, { resource, id });
|
|
35979
36075
|
}
|
|
35980
|
-
|
|
36076
|
+
logger16.info("findOne by id succeeded", {
|
|
35981
36077
|
requestId,
|
|
35982
36078
|
resource,
|
|
35983
36079
|
id
|
|
@@ -35986,7 +36082,7 @@ async function handleFindOne(resource, params, requestId) {
|
|
|
35986
36082
|
}
|
|
35987
36083
|
if ("filter" in params) {
|
|
35988
36084
|
const { filter } = params;
|
|
35989
|
-
|
|
36085
|
+
logger16.debug("Executing findOne by filter (using findMany)", {
|
|
35990
36086
|
requestId,
|
|
35991
36087
|
resource,
|
|
35992
36088
|
filter
|
|
@@ -35995,7 +36091,7 @@ async function handleFindOne(resource, params, requestId) {
|
|
|
35995
36091
|
if (results.length === 0) {
|
|
35996
36092
|
throw new ItemNotFoundError(`Record not found with filter`, { resource, filter });
|
|
35997
36093
|
}
|
|
35998
|
-
|
|
36094
|
+
logger16.info("findOne by filter succeeded", {
|
|
35999
36095
|
requestId,
|
|
36000
36096
|
resource,
|
|
36001
36097
|
filter
|
|
@@ -36004,13 +36100,13 @@ async function handleFindOne(resource, params, requestId) {
|
|
|
36004
36100
|
}
|
|
36005
36101
|
throw new Error("findOne requires either id or filter");
|
|
36006
36102
|
}
|
|
36007
|
-
var
|
|
36103
|
+
var logger16;
|
|
36008
36104
|
var init_findOne = __esm({
|
|
36009
36105
|
"src/server/operations/findOne.ts"() {
|
|
36010
36106
|
"use strict";
|
|
36011
36107
|
init_shared();
|
|
36012
36108
|
init_findMany();
|
|
36013
|
-
|
|
36109
|
+
logger16 = createLogger({ service: "records-lambda" });
|
|
36014
36110
|
__name(handleFindOne, "handleFindOne");
|
|
36015
36111
|
}
|
|
36016
36112
|
});
|
|
@@ -36071,13 +36167,13 @@ function calculateTTL(resource, createdAt) {
|
|
|
36071
36167
|
}
|
|
36072
36168
|
const ttlDays = parseInt(ttlDaysStr, 10);
|
|
36073
36169
|
if (isNaN(ttlDays) || ttlDays <= 0) {
|
|
36074
|
-
|
|
36170
|
+
logger17.warn("Invalid TTL_DAYS value", { resource, envKey, value: ttlDaysStr });
|
|
36075
36171
|
return void 0;
|
|
36076
36172
|
}
|
|
36077
36173
|
const createdAtMs = new Date(createdAt).getTime();
|
|
36078
36174
|
const ttlMs = createdAtMs + ttlDays * 24 * 60 * 60 * 1e3;
|
|
36079
36175
|
const ttl = Math.floor(ttlMs / 1e3);
|
|
36080
|
-
|
|
36176
|
+
logger17.debug("TTL calculated", {
|
|
36081
36177
|
resource,
|
|
36082
36178
|
ttlDays,
|
|
36083
36179
|
createdAt,
|
|
@@ -36089,7 +36185,7 @@ function calculateTTL(resource, createdAt) {
|
|
|
36089
36185
|
function addTTL(resource, recordData) {
|
|
36090
36186
|
const createdAt = recordData.createdAt;
|
|
36091
36187
|
if (!createdAt) {
|
|
36092
|
-
|
|
36188
|
+
logger17.warn("createdAt not found, skipping TTL calculation", { resource });
|
|
36093
36189
|
return recordData;
|
|
36094
36190
|
}
|
|
36095
36191
|
const ttl = calculateTTL(resource, createdAt);
|
|
@@ -36101,12 +36197,12 @@ function addTTL(resource, recordData) {
|
|
|
36101
36197
|
ttl
|
|
36102
36198
|
};
|
|
36103
36199
|
}
|
|
36104
|
-
var
|
|
36200
|
+
var logger17;
|
|
36105
36201
|
var init_ttl = __esm({
|
|
36106
36202
|
"src/server/utils/ttl.ts"() {
|
|
36107
36203
|
"use strict";
|
|
36108
36204
|
init_index2();
|
|
36109
|
-
|
|
36205
|
+
logger17 = createLogger({ service: "records-lambda" });
|
|
36110
36206
|
__name(calculateTTL, "calculateTTL");
|
|
36111
36207
|
__name(addTTL, "addTTL");
|
|
36112
36208
|
}
|
|
@@ -36121,7 +36217,7 @@ async function handleInsertMany(resource, params, requestId) {
|
|
|
36121
36217
|
const { data: recordsData } = params;
|
|
36122
36218
|
const startTime = Date.now();
|
|
36123
36219
|
const costTracker = new CostTracker();
|
|
36124
|
-
|
|
36220
|
+
logger18.debug("Executing insertMany", {
|
|
36125
36221
|
requestId,
|
|
36126
36222
|
resource,
|
|
36127
36223
|
count: recordsData.length
|
|
@@ -36164,7 +36260,7 @@ async function handleInsertMany(resource, params, requestId) {
|
|
|
36164
36260
|
const failedId = recordData.id || `temp-id-${i4}`;
|
|
36165
36261
|
const errorMessage = error2 instanceof Error ? error2.message : "Unknown preparation error";
|
|
36166
36262
|
const errorCode = getPreparationErrorCode(error2);
|
|
36167
|
-
|
|
36263
|
+
logger18.error("Failed to prepare record for creation", {
|
|
36168
36264
|
requestId,
|
|
36169
36265
|
recordId: failedId,
|
|
36170
36266
|
error: errorMessage,
|
|
@@ -36329,7 +36425,7 @@ function getPreparationErrorCode(error2) {
|
|
|
36329
36425
|
}
|
|
36330
36426
|
return "VALIDATION_ERROR" /* VALIDATION_ERROR */;
|
|
36331
36427
|
}
|
|
36332
|
-
var import_lib_dynamodb8,
|
|
36428
|
+
var import_lib_dynamodb8, logger18;
|
|
36333
36429
|
var init_insertMany = __esm({
|
|
36334
36430
|
"src/server/operations/insertMany.ts"() {
|
|
36335
36431
|
"use strict";
|
|
@@ -36343,7 +36439,7 @@ var init_insertMany = __esm({
|
|
|
36343
36439
|
init_dynamodb3();
|
|
36344
36440
|
init_timestamps();
|
|
36345
36441
|
init_ttl();
|
|
36346
|
-
|
|
36442
|
+
logger18 = createLogger({ service: "records-lambda" });
|
|
36347
36443
|
__name(handleInsertMany, "handleInsertMany");
|
|
36348
36444
|
__name(getPreparationErrorCode, "getPreparationErrorCode");
|
|
36349
36445
|
}
|
|
@@ -36466,7 +36562,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
36466
36562
|
const upsert = options?.upsert ?? false;
|
|
36467
36563
|
const startTime = Date.now();
|
|
36468
36564
|
const costTracker = new CostTracker();
|
|
36469
|
-
|
|
36565
|
+
logger20.debug("Executing updateMany", {
|
|
36470
36566
|
requestId,
|
|
36471
36567
|
resource,
|
|
36472
36568
|
upsert
|
|
@@ -36474,21 +36570,31 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
36474
36570
|
let ids;
|
|
36475
36571
|
if ("ids" in params) {
|
|
36476
36572
|
ids = params.ids;
|
|
36477
|
-
|
|
36573
|
+
logger20.debug("Executing updateMany with ids", {
|
|
36478
36574
|
requestId,
|
|
36479
36575
|
resource,
|
|
36480
36576
|
count: ids.length
|
|
36481
36577
|
});
|
|
36482
36578
|
} else {
|
|
36483
|
-
|
|
36579
|
+
logger20.debug("Executing updateMany with filter", {
|
|
36484
36580
|
requestId,
|
|
36485
36581
|
resource,
|
|
36486
36582
|
filter: params.filter
|
|
36487
36583
|
});
|
|
36488
|
-
|
|
36489
|
-
|
|
36490
|
-
|
|
36491
|
-
|
|
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", {
|
|
36492
36598
|
requestId,
|
|
36493
36599
|
resource,
|
|
36494
36600
|
count: ids.length
|
|
@@ -36497,7 +36603,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
36497
36603
|
if (upsert) {
|
|
36498
36604
|
const newId = ulid2();
|
|
36499
36605
|
ids = [newId];
|
|
36500
|
-
|
|
36606
|
+
logger20.info("Creating new record with filter (upsert: true)", {
|
|
36501
36607
|
requestId,
|
|
36502
36608
|
resource,
|
|
36503
36609
|
newId,
|
|
@@ -36527,32 +36633,10 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
36527
36633
|
logLargeBatchWarning("updateMany", ids.length, requestId, resource);
|
|
36528
36634
|
const dbClient2 = getDBClient();
|
|
36529
36635
|
const tableName = getTableName();
|
|
36530
|
-
const
|
|
36531
|
-
PK: resource,
|
|
36532
|
-
|
|
36533
|
-
}));
|
|
36534
|
-
const batchGetResult = await executeDynamoDBOperation(
|
|
36535
|
-
() => dbClient2.send(
|
|
36536
|
-
new import_lib_dynamodb9.BatchGetCommand({
|
|
36537
|
-
RequestItems: {
|
|
36538
|
-
[tableName]: {
|
|
36539
|
-
Keys: keys,
|
|
36540
|
-
ConsistentRead: true
|
|
36541
|
-
}
|
|
36542
|
-
},
|
|
36543
|
-
ReturnConsumedCapacity: "TOTAL"
|
|
36544
|
-
})
|
|
36545
|
-
),
|
|
36546
|
-
"BatchGetItem"
|
|
36636
|
+
const existingItems = await batchGetAll(
|
|
36637
|
+
ids.map((id) => ({ PK: resource, SK: generateMainRecordSK2(id) })),
|
|
36638
|
+
{ consistentRead: true, costTracker, requestId }
|
|
36547
36639
|
);
|
|
36548
|
-
if (Array.isArray(batchGetResult.ConsumedCapacity)) {
|
|
36549
|
-
for (const capacity of batchGetResult.ConsumedCapacity) {
|
|
36550
|
-
costTracker.add(capacity);
|
|
36551
|
-
}
|
|
36552
|
-
} else {
|
|
36553
|
-
costTracker.add(batchGetResult.ConsumedCapacity);
|
|
36554
|
-
}
|
|
36555
|
-
const existingItems = batchGetResult.Responses?.[tableName] || [];
|
|
36556
36640
|
const existingIds = new Set(
|
|
36557
36641
|
existingItems.map((item) => {
|
|
36558
36642
|
const data = item.data;
|
|
@@ -36561,7 +36645,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
36561
36645
|
);
|
|
36562
36646
|
const notFoundIds = ids.filter((id) => !existingIds.has(id));
|
|
36563
36647
|
if (!upsert && notFoundIds.length > 0) {
|
|
36564
|
-
|
|
36648
|
+
logger20.warn("Records not found (upsert: false)", {
|
|
36565
36649
|
requestId,
|
|
36566
36650
|
resource,
|
|
36567
36651
|
notFoundCount: notFoundIds.length,
|
|
@@ -36570,7 +36654,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
36570
36654
|
});
|
|
36571
36655
|
}
|
|
36572
36656
|
if (upsert && notFoundIds.length > 0) {
|
|
36573
|
-
|
|
36657
|
+
logger20.info("Creating new records (upsert: true)", {
|
|
36574
36658
|
requestId,
|
|
36575
36659
|
resource,
|
|
36576
36660
|
notFoundCount: notFoundIds.length,
|
|
@@ -36606,7 +36690,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
36606
36690
|
const failedId = existingData.id || "unknown-id";
|
|
36607
36691
|
const errorMessage = error2 instanceof Error ? error2.message : "Unknown preparation error";
|
|
36608
36692
|
const errorCode = getPreparationErrorCode2(error2);
|
|
36609
|
-
|
|
36693
|
+
logger20.error("Failed to prepare record for update", {
|
|
36610
36694
|
requestId,
|
|
36611
36695
|
recordId: failedId,
|
|
36612
36696
|
error: errorMessage,
|
|
@@ -36646,7 +36730,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
36646
36730
|
} catch (error2) {
|
|
36647
36731
|
const errorMessage = error2 instanceof Error ? error2.message : "Unknown preparation error";
|
|
36648
36732
|
const errorCode = getPreparationErrorCode2(error2);
|
|
36649
|
-
|
|
36733
|
+
logger20.error("Failed to prepare new record for upsert", {
|
|
36650
36734
|
requestId,
|
|
36651
36735
|
recordId: id,
|
|
36652
36736
|
error: errorMessage,
|
|
@@ -36859,7 +36943,7 @@ function getPreparationErrorCode2(error2) {
|
|
|
36859
36943
|
}
|
|
36860
36944
|
return "VALIDATION_ERROR" /* VALIDATION_ERROR */;
|
|
36861
36945
|
}
|
|
36862
|
-
var import_lib_dynamodb9,
|
|
36946
|
+
var import_lib_dynamodb9, logger20;
|
|
36863
36947
|
var init_updateMany = __esm({
|
|
36864
36948
|
"src/server/operations/updateMany.ts"() {
|
|
36865
36949
|
"use strict";
|
|
@@ -36867,13 +36951,15 @@ var init_updateMany = __esm({
|
|
|
36867
36951
|
init_shared();
|
|
36868
36952
|
init_shadow();
|
|
36869
36953
|
init_shadow();
|
|
36954
|
+
init_batchGet();
|
|
36870
36955
|
init_bulkOperations();
|
|
36871
36956
|
init_chunking();
|
|
36872
36957
|
init_cost_tracker();
|
|
36873
36958
|
init_dynamodb3();
|
|
36874
36959
|
init_mergePatch();
|
|
36875
36960
|
init_timestamps();
|
|
36876
|
-
|
|
36961
|
+
init_findAll();
|
|
36962
|
+
logger20 = createLogger({ service: "records-lambda" });
|
|
36877
36963
|
__name(handleUpdateMany, "handleUpdateMany");
|
|
36878
36964
|
__name(getPreparationErrorCode2, "getPreparationErrorCode");
|
|
36879
36965
|
}
|
|
@@ -36894,13 +36980,14 @@ init_deleteMany();
|
|
|
36894
36980
|
|
|
36895
36981
|
// src/server/operations/deleteOne.ts
|
|
36896
36982
|
init_shared();
|
|
36897
|
-
|
|
36983
|
+
init_findAll();
|
|
36984
|
+
var logger13 = createLogger({ service: "records-lambda" });
|
|
36898
36985
|
async function handleDeleteOne(resource, params, requestId) {
|
|
36899
36986
|
const { handleDeleteMany: handleDeleteMany2 } = await Promise.resolve().then(() => (init_deleteMany(), deleteMany_exports));
|
|
36900
36987
|
let targetId;
|
|
36901
36988
|
if ("id" in params) {
|
|
36902
36989
|
targetId = params.id;
|
|
36903
|
-
|
|
36990
|
+
logger13.debug("Executing deleteOne with id", {
|
|
36904
36991
|
requestId,
|
|
36905
36992
|
resource,
|
|
36906
36993
|
id: targetId
|
|
@@ -36927,18 +37014,17 @@ async function handleDeleteOne(resource, params, requestId) {
|
|
|
36927
37014
|
consumedCapacity: deleteManyResult.consumedCapacity
|
|
36928
37015
|
};
|
|
36929
37016
|
} else {
|
|
36930
|
-
|
|
37017
|
+
logger13.debug("Executing deleteOne with filter", {
|
|
36931
37018
|
requestId,
|
|
36932
37019
|
resource,
|
|
36933
37020
|
filter: params.filter
|
|
36934
37021
|
});
|
|
36935
|
-
const
|
|
37022
|
+
const target = await findOneByFilter(
|
|
36936
37023
|
resource,
|
|
36937
|
-
|
|
36938
|
-
filter: params.filter
|
|
36939
|
-
},
|
|
37024
|
+
params.filter,
|
|
36940
37025
|
requestId
|
|
36941
37026
|
);
|
|
37027
|
+
const deleteManyResult = target ? await handleDeleteMany2(resource, { ids: [target.id] }, requestId) : await handleDeleteMany2(resource, { ids: [] }, requestId);
|
|
36942
37028
|
if (deleteManyResult.count === 0) {
|
|
36943
37029
|
const error2 = Object.values(deleteManyResult.errors || {})[0];
|
|
36944
37030
|
if (error2) {
|
|
@@ -36951,7 +37037,7 @@ async function handleDeleteOne(resource, params, requestId) {
|
|
|
36951
37037
|
if (!deletedId) {
|
|
36952
37038
|
throw new Error("Failed to get deleted record ID");
|
|
36953
37039
|
}
|
|
36954
|
-
|
|
37040
|
+
logger13.info("deleteOne succeeded", {
|
|
36955
37041
|
requestId,
|
|
36956
37042
|
resource,
|
|
36957
37043
|
id: deletedId
|
|
@@ -36974,13 +37060,14 @@ init_findMany();
|
|
|
36974
37060
|
var import_lib_dynamodb7 = __toESM(require_dist_cjs65(), 1);
|
|
36975
37061
|
init_shared();
|
|
36976
37062
|
init_shadow();
|
|
37063
|
+
init_batchGet();
|
|
36977
37064
|
init_dynamodb3();
|
|
36978
37065
|
init_pagination();
|
|
36979
37066
|
init_validation2();
|
|
36980
|
-
var
|
|
37067
|
+
var logger15 = createLogger({ service: "records-lambda" });
|
|
36981
37068
|
async function handleFindManyReference(resource, params, requestId) {
|
|
36982
37069
|
const { target, id, filter, sort: sortParam, pagination } = params;
|
|
36983
|
-
|
|
37070
|
+
logger15.debug("Executing findManyReference", {
|
|
36984
37071
|
requestId,
|
|
36985
37072
|
resource,
|
|
36986
37073
|
target,
|
|
@@ -37033,23 +37120,10 @@ async function handleFindManyReference(resource, params, requestId) {
|
|
|
37033
37120
|
const parts = sk.split("#id#");
|
|
37034
37121
|
return parts[parts.length - 1];
|
|
37035
37122
|
});
|
|
37036
|
-
const
|
|
37037
|
-
() =>
|
|
37038
|
-
|
|
37039
|
-
RequestItems: {
|
|
37040
|
-
[tableName]: {
|
|
37041
|
-
Keys: recordIds.map((recordId) => ({
|
|
37042
|
-
PK: resource,
|
|
37043
|
-
SK: `id#${recordId}`
|
|
37044
|
-
})),
|
|
37045
|
-
ConsistentRead: true
|
|
37046
|
-
}
|
|
37047
|
-
}
|
|
37048
|
-
})
|
|
37049
|
-
),
|
|
37050
|
-
"BatchGetItem"
|
|
37123
|
+
const mainRecords = await batchGetAll(
|
|
37124
|
+
recordIds.map((recordId) => ({ PK: resource, SK: `id#${recordId}` })),
|
|
37125
|
+
{ consistentRead: true, requestId }
|
|
37051
37126
|
);
|
|
37052
|
-
const mainRecords = batchGetResult.Responses?.[tableName] || [];
|
|
37053
37127
|
const recordMap = new Map(
|
|
37054
37128
|
mainRecords.map((item) => {
|
|
37055
37129
|
const data = item.data;
|
|
@@ -37070,7 +37144,7 @@ async function handleFindManyReference(resource, params, requestId) {
|
|
|
37070
37144
|
queryResult.LastEvaluatedKey.PK,
|
|
37071
37145
|
queryResult.LastEvaluatedKey.SK
|
|
37072
37146
|
) : void 0;
|
|
37073
|
-
|
|
37147
|
+
logger15.info("findManyReference succeeded", {
|
|
37074
37148
|
requestId,
|
|
37075
37149
|
resource,
|
|
37076
37150
|
target,
|
|
@@ -37095,9 +37169,9 @@ init_insertMany();
|
|
|
37095
37169
|
|
|
37096
37170
|
// src/server/operations/insertOne.ts
|
|
37097
37171
|
init_shared();
|
|
37098
|
-
var
|
|
37172
|
+
var logger19 = createLogger({ service: "records-lambda" });
|
|
37099
37173
|
async function handleInsertOne(resource, params, requestId) {
|
|
37100
|
-
|
|
37174
|
+
logger19.debug("Executing insertOne", {
|
|
37101
37175
|
requestId,
|
|
37102
37176
|
resource
|
|
37103
37177
|
});
|
|
@@ -37123,7 +37197,7 @@ async function handleInsertOne(resource, params, requestId) {
|
|
|
37123
37197
|
}
|
|
37124
37198
|
const { handleFindOne: handleFindOne2 } = await Promise.resolve().then(() => (init_findOne(), findOne_exports));
|
|
37125
37199
|
const createdRecord = await handleFindOne2(resource, { id: createdId }, requestId);
|
|
37126
|
-
|
|
37200
|
+
logger19.info("insertOne succeeded", {
|
|
37127
37201
|
requestId,
|
|
37128
37202
|
resource,
|
|
37129
37203
|
id: createdId
|
|
@@ -37241,10 +37315,11 @@ function convertUpdateOneParams(mongoParams) {
|
|
|
37241
37315
|
__name(convertUpdateOneParams, "convertUpdateOneParams");
|
|
37242
37316
|
function convertUpdateManyParams(mongoParams) {
|
|
37243
37317
|
const idFilter = mongoParams.filter?.id;
|
|
37244
|
-
const
|
|
37318
|
+
const hasIdIn = typeof idFilter === "object" && idFilter !== null && "$in" in idFilter;
|
|
37319
|
+
const target = hasIdIn ? { ids: idFilter.$in || [] } : mongoParams.filter ? { filter: mongoParams.filter } : { ids: [] };
|
|
37245
37320
|
const updateData = mongoParams.update && typeof mongoParams.update === "object" ? "$set" in mongoParams.update ? mongoParams.update.$set || {} : mongoParams.update : {};
|
|
37246
37321
|
return {
|
|
37247
|
-
|
|
37322
|
+
...target,
|
|
37248
37323
|
data: updateData,
|
|
37249
37324
|
...mongoParams.options?.upsert !== void 0 && {
|
|
37250
37325
|
options: { upsert: mongoParams.options.upsert }
|
|
@@ -37266,8 +37341,13 @@ function convertDeleteOneParams(mongoParams) {
|
|
|
37266
37341
|
__name(convertDeleteOneParams, "convertDeleteOneParams");
|
|
37267
37342
|
function convertDeleteManyParams(mongoParams) {
|
|
37268
37343
|
const idFilter = mongoParams.filter?.id;
|
|
37269
|
-
|
|
37270
|
-
|
|
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: [] };
|
|
37271
37351
|
}
|
|
37272
37352
|
__name(convertDeleteManyParams, "convertDeleteManyParams");
|
|
37273
37353
|
function convertInsertManyParams(mongoParams) {
|
|
@@ -37285,13 +37365,14 @@ init_updateMany();
|
|
|
37285
37365
|
|
|
37286
37366
|
// src/server/operations/updateOne.ts
|
|
37287
37367
|
init_shared();
|
|
37288
|
-
|
|
37368
|
+
init_findAll();
|
|
37369
|
+
var logger21 = createLogger({ service: "records-lambda" });
|
|
37289
37370
|
async function handleUpdateOne(resource, params, requestId) {
|
|
37290
37371
|
const { data: patchData, options } = params;
|
|
37291
37372
|
const { handleUpdateMany: handleUpdateMany2 } = await Promise.resolve().then(() => (init_updateMany(), updateMany_exports));
|
|
37292
37373
|
if ("id" in params) {
|
|
37293
37374
|
const targetId = params.id;
|
|
37294
|
-
|
|
37375
|
+
logger21.debug("Executing updateOne with id", {
|
|
37295
37376
|
requestId,
|
|
37296
37377
|
resource,
|
|
37297
37378
|
id: targetId,
|
|
@@ -37333,19 +37414,20 @@ async function handleUpdateOne(resource, params, requestId) {
|
|
|
37333
37414
|
consumedCapacity: updateManyResult.consumedCapacity
|
|
37334
37415
|
};
|
|
37335
37416
|
} else {
|
|
37336
|
-
|
|
37417
|
+
logger21.debug("Executing updateOne with filter", {
|
|
37337
37418
|
requestId,
|
|
37338
37419
|
resource,
|
|
37339
37420
|
filter: params.filter,
|
|
37340
37421
|
upsert: options?.upsert
|
|
37341
37422
|
});
|
|
37423
|
+
const target = await findOneByFilter(
|
|
37424
|
+
resource,
|
|
37425
|
+
params.filter,
|
|
37426
|
+
requestId
|
|
37427
|
+
);
|
|
37342
37428
|
const updateManyResult = await handleUpdateMany2(
|
|
37343
37429
|
resource,
|
|
37344
|
-
{
|
|
37345
|
-
filter: params.filter,
|
|
37346
|
-
data: patchData,
|
|
37347
|
-
options
|
|
37348
|
-
},
|
|
37430
|
+
target ? { ids: [target.id], data: patchData, options } : { filter: params.filter, data: patchData, options },
|
|
37349
37431
|
requestId
|
|
37350
37432
|
);
|
|
37351
37433
|
if (updateManyResult.count === 0) {
|
|
@@ -37383,13 +37465,13 @@ async function handleUpdateOne(resource, params, requestId) {
|
|
|
37383
37465
|
__name(handleUpdateOne, "handleUpdateOne");
|
|
37384
37466
|
|
|
37385
37467
|
// src/server/operations/operationDispatcher.ts
|
|
37386
|
-
var
|
|
37468
|
+
var logger22 = createLogger({
|
|
37387
37469
|
service: "operation-dispatcher",
|
|
37388
37470
|
level: process.env.LOG_LEVEL || "info"
|
|
37389
37471
|
});
|
|
37390
37472
|
async function executeOperation(request2, requestId) {
|
|
37391
37473
|
const { op: op2, resource } = request2;
|
|
37392
|
-
|
|
37474
|
+
logger22.debug("Executing operation", {
|
|
37393
37475
|
requestId,
|
|
37394
37476
|
operation: op2,
|
|
37395
37477
|
resource
|
|
@@ -38612,13 +38694,13 @@ CognitoJwtVerifier.USER_POOL_ID_REGEX = /^(?<region>[a-z]{2}-(gov-)?[a-z]+-\d)_[
|
|
|
38612
38694
|
|
|
38613
38695
|
// src/server/utils/auth.ts
|
|
38614
38696
|
init_index2();
|
|
38615
|
-
var
|
|
38697
|
+
var logger23 = createLogger({ service: "records-lambda" });
|
|
38616
38698
|
var verifierInstance = null;
|
|
38617
38699
|
function getVerifier(userPoolId, clientId) {
|
|
38618
38700
|
if (!verifierInstance) {
|
|
38619
|
-
|
|
38701
|
+
logger23.debug("Creating JWT verifier instance", { userPoolId, clientId });
|
|
38620
38702
|
if (!clientId) {
|
|
38621
|
-
|
|
38703
|
+
logger23.warn(
|
|
38622
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",
|
|
38623
38705
|
{ userPoolId }
|
|
38624
38706
|
);
|
|
@@ -38635,18 +38717,18 @@ function getVerifier(userPoolId, clientId) {
|
|
|
38635
38717
|
}
|
|
38636
38718
|
__name(getVerifier, "getVerifier");
|
|
38637
38719
|
async function verifyJwt(token, userPoolId, clientId) {
|
|
38638
|
-
|
|
38720
|
+
logger23.debug("Verifying JWT token with signature validation");
|
|
38639
38721
|
try {
|
|
38640
38722
|
const verifier = getVerifier(userPoolId, clientId);
|
|
38641
38723
|
const payload2 = await verifier.verify(token);
|
|
38642
|
-
|
|
38724
|
+
logger23.debug("JWT token verified successfully", {
|
|
38643
38725
|
sub: payload2.sub,
|
|
38644
38726
|
email: payload2.email,
|
|
38645
38727
|
tokenUse: payload2.token_use
|
|
38646
38728
|
});
|
|
38647
38729
|
return payload2;
|
|
38648
38730
|
} catch (error2) {
|
|
38649
|
-
|
|
38731
|
+
logger23.error("JWT verification failed", {
|
|
38650
38732
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
38651
38733
|
});
|
|
38652
38734
|
let message = "JWT verification failed";
|
|
@@ -38687,7 +38769,7 @@ async function verifyAuthHeader(authHeader, userPoolId, clientId) {
|
|
|
38687
38769
|
__name(verifyAuthHeader, "verifyAuthHeader");
|
|
38688
38770
|
|
|
38689
38771
|
// src/server/utils/authHandler.ts
|
|
38690
|
-
var
|
|
38772
|
+
var logger24 = createLogger({
|
|
38691
38773
|
service: "auth-handler",
|
|
38692
38774
|
level: process.env.LOG_LEVEL || "info"
|
|
38693
38775
|
});
|
|
@@ -38702,7 +38784,7 @@ async function handleAuthentication(event, requestId) {
|
|
|
38702
38784
|
}
|
|
38703
38785
|
__name(handleAuthentication, "handleAuthentication");
|
|
38704
38786
|
function handleIAMAuthentication(iam, requestId) {
|
|
38705
|
-
|
|
38787
|
+
logger24.info("IAM authenticated request", {
|
|
38706
38788
|
requestId,
|
|
38707
38789
|
userArn: iam.userArn,
|
|
38708
38790
|
accountId: iam.accountId,
|
|
@@ -38717,7 +38799,7 @@ async function handleCognitoAuthentication(authHeader, requestId) {
|
|
|
38717
38799
|
throw new Error("COGNITO_USER_POOL_ID environment variable is required");
|
|
38718
38800
|
}
|
|
38719
38801
|
const jwtPayload = await verifyAuthHeader(authHeader, userPoolId, clientId);
|
|
38720
|
-
|
|
38802
|
+
logger24.debug("Cognito JWT verified", {
|
|
38721
38803
|
requestId,
|
|
38722
38804
|
sub: jwtPayload.sub
|
|
38723
38805
|
});
|
|
@@ -38732,7 +38814,7 @@ init_shared();
|
|
|
38732
38814
|
// src/server/utils/responseBuilder.ts
|
|
38733
38815
|
init_http();
|
|
38734
38816
|
init_shared();
|
|
38735
|
-
var
|
|
38817
|
+
var logger25 = createLogger({
|
|
38736
38818
|
service: "response-builder",
|
|
38737
38819
|
level: process.env.LOG_LEVEL || "info"
|
|
38738
38820
|
});
|
|
@@ -38742,7 +38824,7 @@ function createSuccessResponse(data, requestId) {
|
|
|
38742
38824
|
success: true,
|
|
38743
38825
|
data
|
|
38744
38826
|
};
|
|
38745
|
-
|
|
38827
|
+
logger25.info("Request succeeded", { requestId });
|
|
38746
38828
|
return {
|
|
38747
38829
|
statusCode: HTTP_STATUS.OK,
|
|
38748
38830
|
headers: {
|
|
@@ -38763,7 +38845,7 @@ function createErrorResponse(code, message, statusCode, requestId, details) {
|
|
|
38763
38845
|
details
|
|
38764
38846
|
}
|
|
38765
38847
|
};
|
|
38766
|
-
|
|
38848
|
+
logger25.error("Request failed", {
|
|
38767
38849
|
requestId,
|
|
38768
38850
|
code,
|
|
38769
38851
|
message,
|
|
@@ -38789,7 +38871,7 @@ function createCorsResponse(statusCode) {
|
|
|
38789
38871
|
__name(createCorsResponse, "createCorsResponse");
|
|
38790
38872
|
|
|
38791
38873
|
// src/server/utils/errorHandler.ts
|
|
38792
|
-
var
|
|
38874
|
+
var logger26 = createLogger({
|
|
38793
38875
|
service: "error-handler",
|
|
38794
38876
|
level: process.env.LOG_LEVEL || "info"
|
|
38795
38877
|
});
|
|
@@ -38804,7 +38886,7 @@ function handleError(error2, requestId) {
|
|
|
38804
38886
|
);
|
|
38805
38887
|
}
|
|
38806
38888
|
if (error2 instanceof Error) {
|
|
38807
|
-
|
|
38889
|
+
logger26.error("Error stack trace", {
|
|
38808
38890
|
requestId,
|
|
38809
38891
|
stack: error2.stack,
|
|
38810
38892
|
message: error2.message
|
|
@@ -38889,14 +38971,14 @@ function parseRequestBody(body) {
|
|
|
38889
38971
|
__name(parseRequestBody, "parseRequestBody");
|
|
38890
38972
|
|
|
38891
38973
|
// src/server/handler.ts
|
|
38892
|
-
var
|
|
38974
|
+
var logger27 = createLogger({
|
|
38893
38975
|
service: "records-lambda",
|
|
38894
38976
|
level: process.env.LOG_LEVEL || "info"
|
|
38895
38977
|
});
|
|
38896
|
-
|
|
38978
|
+
logger27.info("Records Lambda started with automatic shadow field detection");
|
|
38897
38979
|
async function handler(event) {
|
|
38898
38980
|
const requestId = event.requestContext.requestId;
|
|
38899
|
-
|
|
38981
|
+
logger27.info("Received request", {
|
|
38900
38982
|
requestId,
|
|
38901
38983
|
method: event.requestContext.http.method,
|
|
38902
38984
|
path: event.requestContext.http.path
|
|
@@ -38906,7 +38988,7 @@ async function handler(event) {
|
|
|
38906
38988
|
return createCorsResponse(HTTP_STATUS.OK);
|
|
38907
38989
|
}
|
|
38908
38990
|
if (event.requestContext.http.method === "GET" && event.requestContext.http.path === "/version") {
|
|
38909
|
-
const version = "1.
|
|
38991
|
+
const version = "1.11.0";
|
|
38910
38992
|
return createSuccessResponse({ version, timestamp: (/* @__PURE__ */ new Date()).toISOString() }, requestId);
|
|
38911
38993
|
}
|
|
38912
38994
|
if (event.requestContext.http.method !== "POST") {
|
|
@@ -38914,7 +38996,7 @@ async function handler(event) {
|
|
|
38914
38996
|
}
|
|
38915
38997
|
await handleAuthentication(event, requestId);
|
|
38916
38998
|
const request2 = parseRequestBody(event.body);
|
|
38917
|
-
|
|
38999
|
+
logger27.info("Parsed request", {
|
|
38918
39000
|
requestId,
|
|
38919
39001
|
operation: request2.op,
|
|
38920
39002
|
resource: request2.resource
|