@exabugs/dynamodb-client 1.5.3 → 1.6.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/dist/server/handler.cjs +3 -3
- package/dist/server/media/magicBytes.d.ts.map +1 -1
- package/dist/server/media/magicBytes.js +17 -14
- package/dist/server/media/magicBytes.js.map +1 -1
- package/dist/server/media/media-handler.d.ts.map +1 -1
- package/dist/server/media/media-handler.js +38 -4
- package/dist/server/media/media-handler.js.map +1 -1
- package/dist/server/media/metadata.d.ts +29 -0
- package/dist/server/media/metadata.d.ts.map +1 -0
- package/dist/server/media/metadata.js +57 -0
- package/dist/server/media/metadata.js.map +1 -0
- package/dist/server/media/presign.d.ts.map +1 -1
- package/dist/server/media/presign.js +18 -1
- package/dist/server/media/presign.js.map +1 -1
- package/dist/server/media/process-handler-dlq.d.ts +0 -13
- package/dist/server/media/process-handler-dlq.d.ts.map +1 -1
- package/dist/server/media/process-handler-dlq.js +49 -7
- package/dist/server/media/process-handler-dlq.js.map +1 -1
- package/dist/server/media/process-handler.d.ts.map +1 -1
- package/dist/server/media/process-handler.js +40 -25
- package/dist/server/media/process-handler.js.map +1 -1
- package/dist/server/media/types.d.ts +1 -1
- package/dist/server/media/types.d.ts.map +1 -1
- package/dist/server/media/upload-handler.d.ts +50 -0
- package/dist/server/media/upload-handler.d.ts.map +1 -0
- package/dist/server/media/upload-handler.js +115 -0
- package/dist/server/media/upload-handler.js.map +1 -0
- package/dist/server/media-handler.cjs +27 -3
- package/dist/server/media-handler.cjs.map +2 -2
- package/dist/server/media-process-handler-dlq.cjs +25496 -13553
- package/dist/server/media-process-handler-dlq.cjs.map +4 -4
- package/dist/server/media-process-handler.cjs +648 -536
- package/dist/server/media-process-handler.cjs.map +4 -4
- package/dist/sharp-layer.zip +0 -0
- package/package.json +5 -1
- package/terraform/media/README.md +4 -1
- package/terraform/media/main.tf +86 -13
- package/terraform/media/variables.tf +33 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// @exabugs/dynamodb-client v1.
|
|
2
|
-
// Built: 2026-10-
|
|
1
|
+
// @exabugs/dynamodb-client v1.6.0
|
|
2
|
+
// Built: 2026-10-04T23:59:48.659Z
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -2041,19 +2041,19 @@ var init_ProviderError = __esm({
|
|
|
2041
2041
|
name = "ProviderError";
|
|
2042
2042
|
tryNextLink;
|
|
2043
2043
|
constructor(message, options = true) {
|
|
2044
|
-
let
|
|
2044
|
+
let logger14;
|
|
2045
2045
|
let tryNextLink = true;
|
|
2046
2046
|
if (typeof options === "boolean") {
|
|
2047
|
-
|
|
2047
|
+
logger14 = void 0;
|
|
2048
2048
|
tryNextLink = options;
|
|
2049
2049
|
} else if (options != null && typeof options === "object") {
|
|
2050
|
-
|
|
2050
|
+
logger14 = options.logger;
|
|
2051
2051
|
tryNextLink = options.tryNextLink ?? true;
|
|
2052
2052
|
}
|
|
2053
2053
|
super(message);
|
|
2054
2054
|
this.tryNextLink = tryNextLink;
|
|
2055
2055
|
Object.setPrototypeOf(this, _ProviderError.prototype);
|
|
2056
|
-
|
|
2056
|
+
logger14?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
|
|
2057
2057
|
}
|
|
2058
2058
|
static from(error2, options = true) {
|
|
2059
2059
|
return Object.assign(new this(error2.message, options), error2);
|
|
@@ -2486,8 +2486,8 @@ var init_configLoader = __esm({
|
|
|
2486
2486
|
init_fromSharedConfigFiles();
|
|
2487
2487
|
init_fromStatic();
|
|
2488
2488
|
loadConfig = /* @__PURE__ */ __name(({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => {
|
|
2489
|
-
const { signingName, logger:
|
|
2490
|
-
const envOptions = { signingName, logger:
|
|
2489
|
+
const { signingName, logger: logger14 } = configuration;
|
|
2490
|
+
const envOptions = { signingName, logger: logger14 };
|
|
2491
2491
|
return memoize(chain(fromEnv(environmentVariableSelector, envOptions), fromSharedConfigFiles(configFileSelector, configuration), fromStatic(defaultValue)));
|
|
2492
2492
|
}, "loadConfig");
|
|
2493
2493
|
}
|
|
@@ -4106,7 +4106,7 @@ var init_ByteArrayCollector = __esm({
|
|
|
4106
4106
|
});
|
|
4107
4107
|
|
|
4108
4108
|
// node_modules/@smithy/core/dist-es/submodules/serde/util-stream/createBufferedReadable.browser.js
|
|
4109
|
-
function createBufferedReadableStream(upstream, size,
|
|
4109
|
+
function createBufferedReadableStream(upstream, size, logger14) {
|
|
4110
4110
|
const reader = upstream.getReader();
|
|
4111
4111
|
let streamBufferingLoggedWarning = false;
|
|
4112
4112
|
let bytesSeen = 0;
|
|
@@ -4144,7 +4144,7 @@ function createBufferedReadableStream(upstream, size, logger13) {
|
|
|
4144
4144
|
const newSize = merge(buffers, mode, chunk);
|
|
4145
4145
|
if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
|
|
4146
4146
|
streamBufferingLoggedWarning = true;
|
|
4147
|
-
|
|
4147
|
+
logger14?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
|
|
4148
4148
|
}
|
|
4149
4149
|
if (newSize >= size) {
|
|
4150
4150
|
controller.enqueue(flush(buffers, mode));
|
|
@@ -4208,9 +4208,9 @@ var init_createBufferedReadable_browser = __esm({
|
|
|
4208
4208
|
});
|
|
4209
4209
|
|
|
4210
4210
|
// node_modules/@smithy/core/dist-es/submodules/serde/util-stream/createBufferedReadable.js
|
|
4211
|
-
function createBufferedReadable(upstream, size,
|
|
4211
|
+
function createBufferedReadable(upstream, size, logger14) {
|
|
4212
4212
|
if (isReadableStream(upstream)) {
|
|
4213
|
-
return createBufferedReadableStream(upstream, size,
|
|
4213
|
+
return createBufferedReadableStream(upstream, size, logger14);
|
|
4214
4214
|
}
|
|
4215
4215
|
const downstream = new import_node_stream2.Readable({ read() {
|
|
4216
4216
|
} });
|
|
@@ -4243,7 +4243,7 @@ function createBufferedReadable(upstream, size, logger13) {
|
|
|
4243
4243
|
const newSize = merge(buffers, mode, chunk);
|
|
4244
4244
|
if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
|
|
4245
4245
|
streamBufferingLoggedWarning = true;
|
|
4246
|
-
|
|
4246
|
+
logger14?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
|
|
4247
4247
|
}
|
|
4248
4248
|
if (newSize >= size) {
|
|
4249
4249
|
downstream.push(flush(buffers, mode));
|
|
@@ -8281,19 +8281,19 @@ var require_dist_cjs4 = __commonJS({
|
|
|
8281
8281
|
name = "ProviderError";
|
|
8282
8282
|
tryNextLink;
|
|
8283
8283
|
constructor(message, options = true) {
|
|
8284
|
-
let
|
|
8284
|
+
let logger14;
|
|
8285
8285
|
let tryNextLink = true;
|
|
8286
8286
|
if (typeof options === "boolean") {
|
|
8287
|
-
|
|
8287
|
+
logger14 = void 0;
|
|
8288
8288
|
tryNextLink = options;
|
|
8289
8289
|
} else if (options != null && typeof options === "object") {
|
|
8290
|
-
|
|
8290
|
+
logger14 = options.logger;
|
|
8291
8291
|
tryNextLink = options.tryNextLink ?? true;
|
|
8292
8292
|
}
|
|
8293
8293
|
super(message);
|
|
8294
8294
|
this.tryNextLink = tryNextLink;
|
|
8295
8295
|
Object.setPrototypeOf(this, _ProviderError.prototype);
|
|
8296
|
-
|
|
8296
|
+
logger14?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
|
|
8297
8297
|
}
|
|
8298
8298
|
static from(error2, options = true) {
|
|
8299
8299
|
return Object.assign(new this(error2.message, options), error2);
|
|
@@ -11106,9 +11106,9 @@ var require_dist_cjs13 = __commonJS({
|
|
|
11106
11106
|
this.middlewareStack.use(mw);
|
|
11107
11107
|
}
|
|
11108
11108
|
const stack = clientStack.concat(this.middlewareStack);
|
|
11109
|
-
const { logger:
|
|
11109
|
+
const { logger: logger14 } = configuration;
|
|
11110
11110
|
const handlerExecutionContext = {
|
|
11111
|
-
logger:
|
|
11111
|
+
logger: logger14,
|
|
11112
11112
|
clientName,
|
|
11113
11113
|
commandName,
|
|
11114
11114
|
inputFilterSensitiveLog,
|
|
@@ -14922,7 +14922,7 @@ var require_createBufferedReadableStream = __commonJS({
|
|
|
14922
14922
|
exports2.sizeOf = sizeOf2;
|
|
14923
14923
|
exports2.modeOf = modeOf2;
|
|
14924
14924
|
var ByteArrayCollector_1 = require_ByteArrayCollector();
|
|
14925
|
-
function createBufferedReadableStream2(upstream, size,
|
|
14925
|
+
function createBufferedReadableStream2(upstream, size, logger14) {
|
|
14926
14926
|
const reader = upstream.getReader();
|
|
14927
14927
|
let streamBufferingLoggedWarning = false;
|
|
14928
14928
|
let bytesSeen = 0;
|
|
@@ -14960,7 +14960,7 @@ var require_createBufferedReadableStream = __commonJS({
|
|
|
14960
14960
|
const newSize = merge2(buffers, mode, chunk);
|
|
14961
14961
|
if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
|
|
14962
14962
|
streamBufferingLoggedWarning = true;
|
|
14963
|
-
|
|
14963
|
+
logger14?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
|
|
14964
14964
|
}
|
|
14965
14965
|
if (newSize >= size) {
|
|
14966
14966
|
controller.enqueue(flush2(buffers, mode));
|
|
@@ -15031,9 +15031,9 @@ var require_createBufferedReadable = __commonJS({
|
|
|
15031
15031
|
var ByteArrayCollector_1 = require_ByteArrayCollector();
|
|
15032
15032
|
var createBufferedReadableStream_1 = require_createBufferedReadableStream();
|
|
15033
15033
|
var stream_type_check_1 = require_stream_type_check();
|
|
15034
|
-
function createBufferedReadable2(upstream, size,
|
|
15034
|
+
function createBufferedReadable2(upstream, size, logger14) {
|
|
15035
15035
|
if ((0, stream_type_check_1.isReadableStream)(upstream)) {
|
|
15036
|
-
return (0, createBufferedReadableStream_1.createBufferedReadableStream)(upstream, size,
|
|
15036
|
+
return (0, createBufferedReadableStream_1.createBufferedReadableStream)(upstream, size, logger14);
|
|
15037
15037
|
}
|
|
15038
15038
|
const downstream = new node_stream_1.Readable({ read() {
|
|
15039
15039
|
} });
|
|
@@ -15066,7 +15066,7 @@ var require_createBufferedReadable = __commonJS({
|
|
|
15066
15066
|
const newSize = (0, createBufferedReadableStream_1.merge)(buffers, mode, chunk);
|
|
15067
15067
|
if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
|
|
15068
15068
|
streamBufferingLoggedWarning = true;
|
|
15069
|
-
|
|
15069
|
+
logger14?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
|
|
15070
15070
|
}
|
|
15071
15071
|
if (newSize >= size) {
|
|
15072
15072
|
downstream.push((0, createBufferedReadableStream_1.flush)(buffers, mode));
|
|
@@ -15474,7 +15474,7 @@ var require_dist_cjs18 = __commonJS({
|
|
|
15474
15474
|
}
|
|
15475
15475
|
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME$2), DEFER_EVENT_LISTENER_TIME$2);
|
|
15476
15476
|
}, "setConnectionTimeout");
|
|
15477
|
-
var setRequestTimeout = /* @__PURE__ */ __name((req, reject, timeoutInMs = 0, throwOnRequestTimeout,
|
|
15477
|
+
var setRequestTimeout = /* @__PURE__ */ __name((req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger14) => {
|
|
15478
15478
|
if (timeoutInMs) {
|
|
15479
15479
|
return timing.setTimeout(() => {
|
|
15480
15480
|
let msg = `@smithy/node-http-handler - [${throwOnRequestTimeout ? "ERROR" : "WARN"}] a request has exceeded the configured ${timeoutInMs} ms requestTimeout.`;
|
|
@@ -15487,7 +15487,7 @@ var require_dist_cjs18 = __commonJS({
|
|
|
15487
15487
|
reject(error2);
|
|
15488
15488
|
} else {
|
|
15489
15489
|
msg += ` Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.`;
|
|
15490
|
-
|
|
15490
|
+
logger14?.warn?.(msg);
|
|
15491
15491
|
}
|
|
15492
15492
|
}, timeoutInMs);
|
|
15493
15493
|
}
|
|
@@ -15603,7 +15603,7 @@ var require_dist_cjs18 = __commonJS({
|
|
|
15603
15603
|
}
|
|
15604
15604
|
return new _NodeHttpHandler(instanceOrOptions);
|
|
15605
15605
|
}
|
|
15606
|
-
static checkSocketUsage(agent, socketWarningTimestamp,
|
|
15606
|
+
static checkSocketUsage(agent, socketWarningTimestamp, logger14 = console) {
|
|
15607
15607
|
const { sockets, requests, maxSockets } = agent;
|
|
15608
15608
|
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
15609
15609
|
return socketWarningTimestamp;
|
|
@@ -15617,7 +15617,7 @@ var require_dist_cjs18 = __commonJS({
|
|
|
15617
15617
|
const socketsInUse = sockets[origin]?.length ?? 0;
|
|
15618
15618
|
const requestsEnqueued = requests[origin]?.length ?? 0;
|
|
15619
15619
|
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
15620
|
-
|
|
15620
|
+
logger14?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
|
|
15621
15621
|
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
15622
15622
|
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
|
|
15623
15623
|
return Date.now();
|
|
@@ -18642,7 +18642,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
18642
18642
|
return false;
|
|
18643
18643
|
}, "isChecksumWithPartNumber");
|
|
18644
18644
|
var getChecksum = /* @__PURE__ */ __name(async (body, { checksumAlgorithmFn, base64Encoder }) => base64Encoder(await stringHasher(checksumAlgorithmFn, body)), "getChecksum");
|
|
18645
|
-
var validateChecksumFromResponse = /* @__PURE__ */ __name(async (response, { config, responseAlgorithms, logger:
|
|
18645
|
+
var validateChecksumFromResponse = /* @__PURE__ */ __name(async (response, { config, responseAlgorithms, logger: logger14 }) => {
|
|
18646
18646
|
const checksumAlgorithms = getChecksumAlgorithmListForResponse(responseAlgorithms);
|
|
18647
18647
|
const { body: responseBody, headers: responseHeaders } = response;
|
|
18648
18648
|
for (const algorithm of checksumAlgorithms) {
|
|
@@ -18654,7 +18654,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
18654
18654
|
checksumAlgorithmFn = selectChecksumAlgorithmFunction(algorithm, config);
|
|
18655
18655
|
} catch (error2) {
|
|
18656
18656
|
if (algorithm === exports2.ChecksumAlgorithm.CRC64NVME) {
|
|
18657
|
-
|
|
18657
|
+
logger14?.warn(`Skipping ${exports2.ChecksumAlgorithm.CRC64NVME} checksum validation: ${error2.message}`);
|
|
18658
18658
|
continue;
|
|
18659
18659
|
}
|
|
18660
18660
|
throw error2;
|
|
@@ -18796,12 +18796,12 @@ var require_dist_cjs27 = __commonJS({
|
|
|
18796
18796
|
var loggerMiddleware = /* @__PURE__ */ __name(() => (next, context) => async (args) => {
|
|
18797
18797
|
try {
|
|
18798
18798
|
const response = await next(args);
|
|
18799
|
-
const { clientName, commandName, logger:
|
|
18799
|
+
const { clientName, commandName, logger: logger14, dynamoDbDocumentClientOptions = {} } = context;
|
|
18800
18800
|
const { overrideInputFilterSensitiveLog, overrideOutputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
|
|
18801
18801
|
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
|
|
18802
18802
|
const outputFilterSensitiveLog = overrideOutputFilterSensitiveLog ?? context.outputFilterSensitiveLog;
|
|
18803
18803
|
const { $metadata, ...outputWithoutMetadata } = response.output;
|
|
18804
|
-
|
|
18804
|
+
logger14?.info?.({
|
|
18805
18805
|
clientName,
|
|
18806
18806
|
commandName,
|
|
18807
18807
|
input: inputFilterSensitiveLog(args.input),
|
|
@@ -18810,10 +18810,10 @@ var require_dist_cjs27 = __commonJS({
|
|
|
18810
18810
|
});
|
|
18811
18811
|
return response;
|
|
18812
18812
|
} catch (error2) {
|
|
18813
|
-
const { clientName, commandName, logger:
|
|
18813
|
+
const { clientName, commandName, logger: logger14, dynamoDbDocumentClientOptions = {} } = context;
|
|
18814
18814
|
const { overrideInputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
|
|
18815
18815
|
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
|
|
18816
|
-
|
|
18816
|
+
logger14?.error?.({
|
|
18817
18817
|
clientName,
|
|
18818
18818
|
commandName,
|
|
18819
18819
|
input: inputFilterSensitiveLog(args.input),
|
|
@@ -20104,7 +20104,7 @@ var require_dist_cjs32 = __commonJS({
|
|
|
20104
20104
|
evaluateTreeRule
|
|
20105
20105
|
};
|
|
20106
20106
|
var resolveEndpoint4 = /* @__PURE__ */ __name((ruleSetObject, options) => {
|
|
20107
|
-
const { endpointParams, logger:
|
|
20107
|
+
const { endpointParams, logger: logger14 } = options;
|
|
20108
20108
|
const { parameters, rules } = ruleSetObject;
|
|
20109
20109
|
options.logger?.debug?.(`${debugId} Initial EndpointParams: ${toDebugString(endpointParams)}`);
|
|
20110
20110
|
const paramsWithDefault = Object.entries(parameters).filter(([, v5]) => v5.default != null).map(([k4, v5]) => [k4, v5.default]);
|
|
@@ -20119,7 +20119,7 @@ var require_dist_cjs32 = __commonJS({
|
|
|
20119
20119
|
throw new EndpointError(`Missing required parameter: '${requiredParam}'`);
|
|
20120
20120
|
}
|
|
20121
20121
|
}
|
|
20122
|
-
const endpoint = evaluateRules(rules, { endpointParams, logger:
|
|
20122
|
+
const endpoint = evaluateRules(rules, { endpointParams, logger: logger14, referenceRecord: {} });
|
|
20123
20123
|
options.logger?.debug?.(`${debugId} Resolved endpoint: ${toDebugString(endpoint)}`);
|
|
20124
20124
|
return endpoint;
|
|
20125
20125
|
}, "resolveEndpoint");
|
|
@@ -20628,11 +20628,11 @@ var require_dist_cjs36 = __commonJS({
|
|
|
20628
20628
|
userAgentAppId: /* @__PURE__ */ __name(async () => {
|
|
20629
20629
|
const appId = await normalizedAppIdProvider();
|
|
20630
20630
|
if (!isValidUserAgentAppId(appId)) {
|
|
20631
|
-
const
|
|
20631
|
+
const logger14 = input.logger?.constructor?.name === "NoOpLogger" || !input.logger ? console : input.logger;
|
|
20632
20632
|
if (typeof appId !== "string") {
|
|
20633
|
-
|
|
20633
|
+
logger14?.warn("userAgentAppId must be a string or undefined.");
|
|
20634
20634
|
} else if (appId.length > 50) {
|
|
20635
|
-
|
|
20635
|
+
logger14?.warn("The provided userAgentAppId exceeds the maximum length of 50 characters.");
|
|
20636
20636
|
}
|
|
20637
20637
|
}
|
|
20638
20638
|
return appId;
|
|
@@ -21500,8 +21500,8 @@ var require_dist_cjs42 = __commonJS({
|
|
|
21500
21500
|
var isFunction2 = /* @__PURE__ */ __name((func) => typeof func === "function", "isFunction");
|
|
21501
21501
|
var fromStatic2 = /* @__PURE__ */ __name((defaultValue) => isFunction2(defaultValue) ? async () => await defaultValue() : propertyProvider.fromStatic(defaultValue), "fromStatic");
|
|
21502
21502
|
var loadConfig2 = /* @__PURE__ */ __name(({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => {
|
|
21503
|
-
const { signingName, logger:
|
|
21504
|
-
const envOptions = { signingName, logger:
|
|
21503
|
+
const { signingName, logger: logger14 } = configuration;
|
|
21504
|
+
const envOptions = { signingName, logger: logger14 };
|
|
21505
21505
|
return propertyProvider.memoize(propertyProvider.chain(fromEnv2(environmentVariableSelector, envOptions), fromSharedConfigFiles2(configFileSelector, configuration), fromStatic2(defaultValue)));
|
|
21506
21506
|
}, "loadConfig");
|
|
21507
21507
|
exports2.loadConfig = loadConfig2;
|
|
@@ -23737,7 +23737,7 @@ var require_dist_cjs53 = __commonJS({
|
|
|
23737
23737
|
"http:": true,
|
|
23738
23738
|
"https:": true
|
|
23739
23739
|
};
|
|
23740
|
-
var getCmdsUri = /* @__PURE__ */ __name(async ({ logger:
|
|
23740
|
+
var getCmdsUri = /* @__PURE__ */ __name(async ({ logger: logger14 }) => {
|
|
23741
23741
|
if (process.env[ENV_CMDS_RELATIVE_URI]) {
|
|
23742
23742
|
return {
|
|
23743
23743
|
hostname: CMDS_IP,
|
|
@@ -23749,13 +23749,13 @@ var require_dist_cjs53 = __commonJS({
|
|
|
23749
23749
|
if (!parsed.hostname || !(parsed.hostname in GREENGRASS_HOSTS)) {
|
|
23750
23750
|
throw new propertyProvider.CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {
|
|
23751
23751
|
tryNextLink: false,
|
|
23752
|
-
logger:
|
|
23752
|
+
logger: logger14
|
|
23753
23753
|
});
|
|
23754
23754
|
}
|
|
23755
23755
|
if (!parsed.protocol || !(parsed.protocol in GREENGRASS_PROTOCOLS)) {
|
|
23756
23756
|
throw new propertyProvider.CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {
|
|
23757
23757
|
tryNextLink: false,
|
|
23758
|
-
logger:
|
|
23758
|
+
logger: logger14
|
|
23759
23759
|
});
|
|
23760
23760
|
}
|
|
23761
23761
|
return {
|
|
@@ -23765,7 +23765,7 @@ var require_dist_cjs53 = __commonJS({
|
|
|
23765
23765
|
}
|
|
23766
23766
|
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`, {
|
|
23767
23767
|
tryNextLink: false,
|
|
23768
|
-
logger:
|
|
23768
|
+
logger: logger14
|
|
23769
23769
|
});
|
|
23770
23770
|
}, "getCmdsUri");
|
|
23771
23771
|
var InstanceMetadataV1FallbackError = class _InstanceMetadataV1FallbackError extends propertyProvider.CredentialsProviderError {
|
|
@@ -23820,10 +23820,10 @@ var require_dist_cjs53 = __commonJS({
|
|
|
23820
23820
|
var STATIC_STABILITY_REFRESH_INTERVAL_SECONDS = 5 * 60;
|
|
23821
23821
|
var STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS = 5 * 60;
|
|
23822
23822
|
var STATIC_STABILITY_DOC_URL = "https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html";
|
|
23823
|
-
var getExtendedInstanceMetadataCredentials = /* @__PURE__ */ __name((credentials,
|
|
23823
|
+
var getExtendedInstanceMetadataCredentials = /* @__PURE__ */ __name((credentials, logger14) => {
|
|
23824
23824
|
const refreshInterval = STATIC_STABILITY_REFRESH_INTERVAL_SECONDS + Math.floor(Math.random() * STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS);
|
|
23825
23825
|
const newExpiration = new Date(Date.now() + refreshInterval * 1e3);
|
|
23826
|
-
|
|
23826
|
+
logger14.warn(`Attempting credential expiration extension due to a credential service availability issue. A refresh of these credentials will be attempted after ${new Date(newExpiration)}.
|
|
23827
23827
|
For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
23828
23828
|
const originalExpiration = credentials.originalExpiration ?? credentials.expiration;
|
|
23829
23829
|
return {
|
|
@@ -23833,19 +23833,19 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
|
23833
23833
|
};
|
|
23834
23834
|
}, "getExtendedInstanceMetadataCredentials");
|
|
23835
23835
|
var staticStabilityProvider = /* @__PURE__ */ __name((provider, options = {}) => {
|
|
23836
|
-
const
|
|
23836
|
+
const logger14 = options?.logger || console;
|
|
23837
23837
|
let pastCredentials;
|
|
23838
23838
|
return async () => {
|
|
23839
23839
|
let credentials;
|
|
23840
23840
|
try {
|
|
23841
23841
|
credentials = await provider();
|
|
23842
23842
|
if (credentials.expiration && credentials.expiration.getTime() < Date.now()) {
|
|
23843
|
-
credentials = getExtendedInstanceMetadataCredentials(credentials,
|
|
23843
|
+
credentials = getExtendedInstanceMetadataCredentials(credentials, logger14);
|
|
23844
23844
|
}
|
|
23845
23845
|
} catch (e4) {
|
|
23846
23846
|
if (pastCredentials) {
|
|
23847
|
-
|
|
23848
|
-
credentials = getExtendedInstanceMetadataCredentials(pastCredentials,
|
|
23847
|
+
logger14.warn("Credential renew failed: ", e4);
|
|
23848
|
+
credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger14);
|
|
23849
23849
|
} else {
|
|
23850
23850
|
throw e4;
|
|
23851
23851
|
}
|
|
@@ -23862,7 +23862,7 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
|
23862
23862
|
var fromInstanceMetadata = /* @__PURE__ */ __name((init = {}) => staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger }), "fromInstanceMetadata");
|
|
23863
23863
|
var getInstanceMetadataProvider = /* @__PURE__ */ __name((init = {}) => {
|
|
23864
23864
|
let disableFetchToken = false;
|
|
23865
|
-
const { logger:
|
|
23865
|
+
const { logger: logger14, profile } = init;
|
|
23866
23866
|
const { timeout, maxRetries } = providerConfigFromInit(init);
|
|
23867
23867
|
const getCredentials = /* @__PURE__ */ __name(async (maxRetries2, options) => {
|
|
23868
23868
|
const isImdsV1Fallback = disableFetchToken || options.headers?.[X_AWS_EC2_METADATA_TOKEN] == null;
|
|
@@ -23926,7 +23926,7 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
|
23926
23926
|
return async () => {
|
|
23927
23927
|
const endpoint = await getInstanceMetadataEndpoint();
|
|
23928
23928
|
if (disableFetchToken) {
|
|
23929
|
-
|
|
23929
|
+
logger14?.debug("AWS SDK Instance Metadata", "using v1 fallback (no token fetch)");
|
|
23930
23930
|
return getCredentials(maxRetries, { ...endpoint, timeout });
|
|
23931
23931
|
} else {
|
|
23932
23932
|
let token;
|
|
@@ -23940,7 +23940,7 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
|
23940
23940
|
} else if (error2.message === "TimeoutError" || [403, 404, 405].includes(error2.statusCode)) {
|
|
23941
23941
|
disableFetchToken = true;
|
|
23942
23942
|
}
|
|
23943
|
-
|
|
23943
|
+
logger14?.debug("AWS SDK Instance Metadata", "using v1 fallback (initial)");
|
|
23944
23944
|
return getCredentials(maxRetries, { ...endpoint, timeout });
|
|
23945
23945
|
}
|
|
23946
23946
|
return getCredentials(maxRetries, {
|
|
@@ -23997,7 +23997,7 @@ var require_checkUrl = __commonJS({
|
|
|
23997
23997
|
var ECS_CONTAINER_HOST = "169.254.170.2";
|
|
23998
23998
|
var EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
|
|
23999
23999
|
var EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
|
|
24000
|
-
var checkUrl = /* @__PURE__ */ __name((url,
|
|
24000
|
+
var checkUrl = /* @__PURE__ */ __name((url, logger14) => {
|
|
24001
24001
|
if (url.protocol === "https:") {
|
|
24002
24002
|
return;
|
|
24003
24003
|
}
|
|
@@ -24024,7 +24024,7 @@ var require_checkUrl = __commonJS({
|
|
|
24024
24024
|
throw new property_provider_1.CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
|
|
24025
24025
|
- loopback CIDR 127.0.0.0/8 or [::1/128]
|
|
24026
24026
|
- ECS container host 169.254.170.2
|
|
24027
|
-
- EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger:
|
|
24027
|
+
- EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger: logger14 });
|
|
24028
24028
|
}, "checkUrl");
|
|
24029
24029
|
exports2.checkUrl = checkUrl;
|
|
24030
24030
|
}
|
|
@@ -24055,13 +24055,13 @@ var require_requestHelpers = __commonJS({
|
|
|
24055
24055
|
});
|
|
24056
24056
|
}
|
|
24057
24057
|
__name(createGetRequest, "createGetRequest");
|
|
24058
|
-
async function getCredentials(response,
|
|
24058
|
+
async function getCredentials(response, logger14) {
|
|
24059
24059
|
const stream = (0, util_stream_1.sdkStreamMixin)(response.body);
|
|
24060
24060
|
const str = await stream.transformToString();
|
|
24061
24061
|
if (response.statusCode === 200) {
|
|
24062
24062
|
const parsed = JSON.parse(str);
|
|
24063
24063
|
if (typeof parsed.AccessKeyId !== "string" || typeof parsed.SecretAccessKey !== "string" || typeof parsed.Token !== "string" || typeof parsed.Expiration !== "string") {
|
|
24064
|
-
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:
|
|
24064
|
+
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: logger14 });
|
|
24065
24065
|
}
|
|
24066
24066
|
return {
|
|
24067
24067
|
accessKeyId: parsed.AccessKeyId,
|
|
@@ -24076,12 +24076,12 @@ var require_requestHelpers = __commonJS({
|
|
|
24076
24076
|
parsedBody = JSON.parse(str);
|
|
24077
24077
|
} catch (e4) {
|
|
24078
24078
|
}
|
|
24079
|
-
throw Object.assign(new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger:
|
|
24079
|
+
throw Object.assign(new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger: logger14 }), {
|
|
24080
24080
|
Code: parsedBody.Code,
|
|
24081
24081
|
Message: parsedBody.Message
|
|
24082
24082
|
});
|
|
24083
24083
|
}
|
|
24084
|
-
throw new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger:
|
|
24084
|
+
throw new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger: logger14 });
|
|
24085
24085
|
}
|
|
24086
24086
|
__name(getCredentials, "getCredentials");
|
|
24087
24087
|
}
|
|
@@ -25445,14 +25445,14 @@ var require_dist_cjs60 = __commonJS({
|
|
|
25445
25445
|
var propertyProvider = require_dist_cjs4();
|
|
25446
25446
|
var sharedIniFileLoader = require_dist_cjs41();
|
|
25447
25447
|
var fs = require("fs");
|
|
25448
|
-
var fromEnvSigningName = /* @__PURE__ */ __name(({ logger:
|
|
25449
|
-
|
|
25448
|
+
var fromEnvSigningName = /* @__PURE__ */ __name(({ logger: logger14, signingName } = {}) => async () => {
|
|
25449
|
+
logger14?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
|
|
25450
25450
|
if (!signingName) {
|
|
25451
|
-
throw new propertyProvider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger:
|
|
25451
|
+
throw new propertyProvider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger: logger14 });
|
|
25452
25452
|
}
|
|
25453
25453
|
const bearerTokenKey = httpAuthSchemes.getBearerTokenEnvKey(signingName);
|
|
25454
25454
|
if (!(bearerTokenKey in process.env)) {
|
|
25455
|
-
throw new propertyProvider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger:
|
|
25455
|
+
throw new propertyProvider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger: logger14 });
|
|
25456
25456
|
}
|
|
25457
25457
|
const token = { token: process.env[bearerTokenKey] };
|
|
25458
25458
|
client.setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
|
|
@@ -25573,8 +25573,8 @@ var require_dist_cjs60 = __commonJS({
|
|
|
25573
25573
|
return existingToken;
|
|
25574
25574
|
}
|
|
25575
25575
|
}, "fromSso");
|
|
25576
|
-
var fromStatic2 = /* @__PURE__ */ __name(({ token, logger:
|
|
25577
|
-
|
|
25576
|
+
var fromStatic2 = /* @__PURE__ */ __name(({ token, logger: logger14 }) => async () => {
|
|
25577
|
+
logger14?.debug("@aws-sdk/token-providers - fromStatic");
|
|
25578
25578
|
if (!token || !token.token) {
|
|
25579
25579
|
throw new propertyProvider.TokenProviderError(`Please pass a valid token to fromStatic`, false);
|
|
25580
25580
|
}
|
|
@@ -26363,7 +26363,7 @@ var require_dist_cjs62 = __commonJS({
|
|
|
26363
26363
|
var tokenProviders = require_dist_cjs60();
|
|
26364
26364
|
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");
|
|
26365
26365
|
var SHOULD_FAIL_CREDENTIAL_CHAIN = false;
|
|
26366
|
-
var resolveSSOCredentials = /* @__PURE__ */ __name(async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, profile, filepath, configFilepath, ignoreCache, logger:
|
|
26366
|
+
var resolveSSOCredentials = /* @__PURE__ */ __name(async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, profile, filepath, configFilepath, ignoreCache, logger: logger14 }) => {
|
|
26367
26367
|
let token;
|
|
26368
26368
|
const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
|
|
26369
26369
|
if (ssoSession) {
|
|
@@ -26381,7 +26381,7 @@ var require_dist_cjs62 = __commonJS({
|
|
|
26381
26381
|
} catch (e4) {
|
|
26382
26382
|
throw new propertyProvider.CredentialsProviderError(e4.message, {
|
|
26383
26383
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
26384
|
-
logger:
|
|
26384
|
+
logger: logger14
|
|
26385
26385
|
});
|
|
26386
26386
|
}
|
|
26387
26387
|
} else {
|
|
@@ -26390,14 +26390,14 @@ var require_dist_cjs62 = __commonJS({
|
|
|
26390
26390
|
} catch (e4) {
|
|
26391
26391
|
throw new propertyProvider.CredentialsProviderError(`The SSO session associated with this profile is invalid. ${refreshMessage}`, {
|
|
26392
26392
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
26393
|
-
logger:
|
|
26393
|
+
logger: logger14
|
|
26394
26394
|
});
|
|
26395
26395
|
}
|
|
26396
26396
|
}
|
|
26397
26397
|
if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
|
|
26398
26398
|
throw new propertyProvider.CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`, {
|
|
26399
26399
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
26400
|
-
logger:
|
|
26400
|
+
logger: logger14
|
|
26401
26401
|
});
|
|
26402
26402
|
}
|
|
26403
26403
|
const { accessToken } = token;
|
|
@@ -26419,14 +26419,14 @@ var require_dist_cjs62 = __commonJS({
|
|
|
26419
26419
|
} catch (e4) {
|
|
26420
26420
|
throw new propertyProvider.CredentialsProviderError(e4, {
|
|
26421
26421
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
26422
|
-
logger:
|
|
26422
|
+
logger: logger14
|
|
26423
26423
|
});
|
|
26424
26424
|
}
|
|
26425
26425
|
const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope, accountId } = {} } = ssoResp;
|
|
26426
26426
|
if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
|
|
26427
26427
|
throw new propertyProvider.CredentialsProviderError("SSO returns an invalid temporary credential.", {
|
|
26428
26428
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
26429
|
-
logger:
|
|
26429
|
+
logger: logger14
|
|
26430
26430
|
});
|
|
26431
26431
|
}
|
|
26432
26432
|
const credentials = {
|
|
@@ -26444,11 +26444,11 @@ var require_dist_cjs62 = __commonJS({
|
|
|
26444
26444
|
}
|
|
26445
26445
|
return credentials;
|
|
26446
26446
|
}, "resolveSSOCredentials");
|
|
26447
|
-
var validateSsoProfile = /* @__PURE__ */ __name((profile,
|
|
26447
|
+
var validateSsoProfile = /* @__PURE__ */ __name((profile, logger14) => {
|
|
26448
26448
|
const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
|
|
26449
26449
|
if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
|
|
26450
26450
|
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(", ")}
|
|
26451
|
-
Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger:
|
|
26451
|
+
Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger: logger14 });
|
|
26452
26452
|
}
|
|
26453
26453
|
return profile;
|
|
26454
26454
|
}, "validateSsoProfile");
|
|
@@ -27231,7 +27231,7 @@ var require_dist_cjs63 = __commonJS({
|
|
|
27231
27231
|
}
|
|
27232
27232
|
async refresh(token) {
|
|
27233
27233
|
const { SigninClient: SigninClient2, CreateOAuth2TokenCommand: CreateOAuth2TokenCommand2 } = await Promise.resolve().then(() => (init_signin(), signin_exports));
|
|
27234
|
-
const { logger:
|
|
27234
|
+
const { logger: logger14, userAgentAppId } = this.callerClientConfig ?? {};
|
|
27235
27235
|
const isH22 = /* @__PURE__ */ __name((requestHandler2) => {
|
|
27236
27236
|
return requestHandler2?.metadata?.handlerProtocol === "h2";
|
|
27237
27237
|
}, "isH2");
|
|
@@ -27244,7 +27244,7 @@ var require_dist_cjs63 = __commonJS({
|
|
|
27244
27244
|
},
|
|
27245
27245
|
region,
|
|
27246
27246
|
requestHandler,
|
|
27247
|
-
logger:
|
|
27247
|
+
logger: logger14,
|
|
27248
27248
|
userAgentAppId,
|
|
27249
27249
|
...this.init?.clientConfig
|
|
27250
27250
|
});
|
|
@@ -28262,9 +28262,9 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
28262
28262
|
return async (sourceCreds, params) => {
|
|
28263
28263
|
closureSourceCreds = sourceCreds;
|
|
28264
28264
|
if (!stsClient) {
|
|
28265
|
-
const { logger:
|
|
28265
|
+
const { logger: logger14 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
|
|
28266
28266
|
const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
|
|
28267
|
-
logger:
|
|
28267
|
+
logger: logger14,
|
|
28268
28268
|
profile
|
|
28269
28269
|
});
|
|
28270
28270
|
const isCompatibleRequestHandler = !isH2(requestHandler);
|
|
@@ -28275,7 +28275,7 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
28275
28275
|
credentialDefaultProvider: /* @__PURE__ */ __name(() => async () => closureSourceCreds, "credentialDefaultProvider"),
|
|
28276
28276
|
region: resolvedRegion,
|
|
28277
28277
|
requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
|
|
28278
|
-
logger:
|
|
28278
|
+
logger: logger14
|
|
28279
28279
|
});
|
|
28280
28280
|
}
|
|
28281
28281
|
const { Credentials: Credentials2, AssumedRoleUser: AssumedRoleUser2 } = await stsClient.send(new AssumeRoleCommand(params));
|
|
@@ -28299,9 +28299,9 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
28299
28299
|
let stsClient;
|
|
28300
28300
|
return async (params) => {
|
|
28301
28301
|
if (!stsClient) {
|
|
28302
|
-
const { logger:
|
|
28302
|
+
const { logger: logger14 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
|
|
28303
28303
|
const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
|
|
28304
|
-
logger:
|
|
28304
|
+
logger: logger14,
|
|
28305
28305
|
profile
|
|
28306
28306
|
});
|
|
28307
28307
|
const isCompatibleRequestHandler = !isH2(requestHandler);
|
|
@@ -28311,7 +28311,7 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
28311
28311
|
profile,
|
|
28312
28312
|
region: resolvedRegion,
|
|
28313
28313
|
requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
|
|
28314
|
-
logger:
|
|
28314
|
+
logger: logger14
|
|
28315
28315
|
});
|
|
28316
28316
|
}
|
|
28317
28317
|
const { Credentials: Credentials2, AssumedRoleUser: AssumedRoleUser2 } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
|
|
@@ -28441,7 +28441,7 @@ var require_dist_cjs64 = __commonJS({
|
|
|
28441
28441
|
client.setCredentialFeature(credentials, "CREDENTIALS_PROCESS", "w");
|
|
28442
28442
|
return credentials;
|
|
28443
28443
|
}, "getValidatedProcessCredentials");
|
|
28444
|
-
var resolveProcessCredentials = /* @__PURE__ */ __name(async (profileName, profiles,
|
|
28444
|
+
var resolveProcessCredentials = /* @__PURE__ */ __name(async (profileName, profiles, logger14) => {
|
|
28445
28445
|
const profile = profiles[profileName];
|
|
28446
28446
|
if (profiles[profileName]) {
|
|
28447
28447
|
const credentialProcess = profile["credential_process"];
|
|
@@ -28457,14 +28457,14 @@ var require_dist_cjs64 = __commonJS({
|
|
|
28457
28457
|
}
|
|
28458
28458
|
return getValidatedProcessCredentials(profileName, data, profiles);
|
|
28459
28459
|
} catch (error2) {
|
|
28460
|
-
throw new propertyProvider.CredentialsProviderError(error2.message, { logger:
|
|
28460
|
+
throw new propertyProvider.CredentialsProviderError(error2.message, { logger: logger14 });
|
|
28461
28461
|
}
|
|
28462
28462
|
} else {
|
|
28463
|
-
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger:
|
|
28463
|
+
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger: logger14 });
|
|
28464
28464
|
}
|
|
28465
28465
|
} else {
|
|
28466
28466
|
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`, {
|
|
28467
|
-
logger:
|
|
28467
|
+
logger: logger14
|
|
28468
28468
|
});
|
|
28469
28469
|
}
|
|
28470
28470
|
}, "resolveProcessCredentials");
|
|
@@ -28623,21 +28623,21 @@ var require_dist_cjs66 = __commonJS({
|
|
|
28623
28623
|
var propertyProvider = require_dist_cjs4();
|
|
28624
28624
|
var client = (init_client(), __toCommonJS(client_exports));
|
|
28625
28625
|
var credentialProviderLogin = require_dist_cjs63();
|
|
28626
|
-
var resolveCredentialSource = /* @__PURE__ */ __name((credentialSource, profileName,
|
|
28626
|
+
var resolveCredentialSource = /* @__PURE__ */ __name((credentialSource, profileName, logger14) => {
|
|
28627
28627
|
const sourceProvidersMap = {
|
|
28628
28628
|
EcsContainer: /* @__PURE__ */ __name(async (options) => {
|
|
28629
28629
|
const { fromHttp } = await Promise.resolve().then(() => __toESM(require_dist_cjs54()));
|
|
28630
28630
|
const { fromContainerMetadata } = await Promise.resolve().then(() => __toESM(require_dist_cjs53()));
|
|
28631
|
-
|
|
28631
|
+
logger14?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
|
|
28632
28632
|
return async () => propertyProvider.chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
|
|
28633
28633
|
}, "EcsContainer"),
|
|
28634
28634
|
Ec2InstanceMetadata: /* @__PURE__ */ __name(async (options) => {
|
|
28635
|
-
|
|
28635
|
+
logger14?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
|
|
28636
28636
|
const { fromInstanceMetadata } = await Promise.resolve().then(() => __toESM(require_dist_cjs53()));
|
|
28637
28637
|
return async () => fromInstanceMetadata(options)().then(setNamedProvider);
|
|
28638
28638
|
}, "Ec2InstanceMetadata"),
|
|
28639
28639
|
Environment: /* @__PURE__ */ __name(async (options) => {
|
|
28640
|
-
|
|
28640
|
+
logger14?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
|
|
28641
28641
|
const { fromEnv: fromEnv2 } = await Promise.resolve().then(() => __toESM(require_dist_cjs52()));
|
|
28642
28642
|
return async () => fromEnv2(options)().then(setNamedProvider);
|
|
28643
28643
|
}, "Environment")
|
|
@@ -28645,24 +28645,24 @@ var require_dist_cjs66 = __commonJS({
|
|
|
28645
28645
|
if (credentialSource in sourceProvidersMap) {
|
|
28646
28646
|
return sourceProvidersMap[credentialSource];
|
|
28647
28647
|
} else {
|
|
28648
|
-
throw new propertyProvider.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger:
|
|
28648
|
+
throw new propertyProvider.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger: logger14 });
|
|
28649
28649
|
}
|
|
28650
28650
|
}, "resolveCredentialSource");
|
|
28651
28651
|
var setNamedProvider = /* @__PURE__ */ __name((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p"), "setNamedProvider");
|
|
28652
|
-
var isAssumeRoleProfile = /* @__PURE__ */ __name((arg, { profile = "default", logger:
|
|
28653
|
-
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:
|
|
28652
|
+
var isAssumeRoleProfile = /* @__PURE__ */ __name((arg, { profile = "default", logger: logger14 } = {}) => {
|
|
28653
|
+
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: logger14 }) || isCredentialSourceProfile(arg, { profile, logger: logger14 }));
|
|
28654
28654
|
}, "isAssumeRoleProfile");
|
|
28655
|
-
var isAssumeRoleWithSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger:
|
|
28655
|
+
var isAssumeRoleWithSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger: logger14 }) => {
|
|
28656
28656
|
const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
|
28657
28657
|
if (withSourceProfile) {
|
|
28658
|
-
|
|
28658
|
+
logger14?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
|
|
28659
28659
|
}
|
|
28660
28660
|
return withSourceProfile;
|
|
28661
28661
|
}, "isAssumeRoleWithSourceProfile");
|
|
28662
|
-
var isCredentialSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger:
|
|
28662
|
+
var isCredentialSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger: logger14 }) => {
|
|
28663
28663
|
const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
|
28664
28664
|
if (withProviderProfile) {
|
|
28665
|
-
|
|
28665
|
+
logger14?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
|
|
28666
28666
|
}
|
|
28667
28667
|
return withProviderProfile;
|
|
28668
28668
|
}, "isCredentialSourceProfile");
|
|
@@ -56443,7 +56443,7 @@ var require_dist_cjs81 = __commonJS({
|
|
|
56443
56443
|
return async () => handler2(this.clientCommand);
|
|
56444
56444
|
}
|
|
56445
56445
|
};
|
|
56446
|
-
var
|
|
56446
|
+
var BatchGetCommand5 = class extends DynamoDBDocumentClientCommand {
|
|
56447
56447
|
static {
|
|
56448
56448
|
__name(this, "BatchGetCommand");
|
|
56449
56449
|
}
|
|
@@ -56946,7 +56946,7 @@ var require_dist_cjs81 = __commonJS({
|
|
|
56946
56946
|
}
|
|
56947
56947
|
}
|
|
56948
56948
|
batchGet(args, optionsOrCb, cb) {
|
|
56949
|
-
const command = new
|
|
56949
|
+
const command = new BatchGetCommand5(args);
|
|
56950
56950
|
if (typeof optionsOrCb === "function") {
|
|
56951
56951
|
this.send(command, optionsOrCb);
|
|
56952
56952
|
} else if (typeof cb === "function") {
|
|
@@ -57123,7 +57123,7 @@ var require_dist_cjs81 = __commonJS({
|
|
|
57123
57123
|
}, "get")
|
|
57124
57124
|
});
|
|
57125
57125
|
exports2.BatchExecuteStatementCommand = BatchExecuteStatementCommand;
|
|
57126
|
-
exports2.BatchGetCommand =
|
|
57126
|
+
exports2.BatchGetCommand = BatchGetCommand5;
|
|
57127
57127
|
exports2.BatchWriteCommand = BatchWriteCommand;
|
|
57128
57128
|
exports2.DeleteCommand = DeleteCommand;
|
|
57129
57129
|
exports2.DynamoDBDocument = DynamoDBDocument;
|
|
@@ -57955,235 +57955,86 @@ var init_shadow = __esm({
|
|
|
57955
57955
|
}
|
|
57956
57956
|
});
|
|
57957
57957
|
|
|
57958
|
-
// src/server/utils/
|
|
57959
|
-
function
|
|
57960
|
-
if (
|
|
57961
|
-
|
|
57962
|
-
|
|
57963
|
-
resource,
|
|
57964
|
-
recordCount,
|
|
57965
|
-
warningThreshold: LARGE_BATCH_WARNING_THRESHOLD,
|
|
57966
|
-
estimatedTimeoutRisk: "high",
|
|
57967
|
-
recommendation: "Consider splitting the batch into smaller requests to avoid Lambda timeout (15 min limit)"
|
|
57958
|
+
// src/server/utils/dynamodb.ts
|
|
57959
|
+
function getDBClient() {
|
|
57960
|
+
if (!dbClient) {
|
|
57961
|
+
dbClient = createDynamoDBClient({
|
|
57962
|
+
region: process.env.AWS_REGION || process.env.REGION
|
|
57968
57963
|
});
|
|
57969
57964
|
}
|
|
57965
|
+
return dbClient;
|
|
57970
57966
|
}
|
|
57971
|
-
function
|
|
57972
|
-
const
|
|
57973
|
-
|
|
57974
|
-
|
|
57975
|
-
const risk = remainingMs < LAMBDA_TIMEOUT_MS * TIMEOUT_RISK_THRESHOLD ? "high" : "low";
|
|
57976
|
-
return {
|
|
57977
|
-
elapsedMs,
|
|
57978
|
-
remainingMs,
|
|
57979
|
-
risk,
|
|
57980
|
-
utilizationPercent
|
|
57981
|
-
};
|
|
57982
|
-
}
|
|
57983
|
-
function logPreparationTimeoutRisk(requestId, resource, totalRecords, chunkCount, riskInfo) {
|
|
57984
|
-
logger2.info("Records prepared for chunk execution", {
|
|
57985
|
-
requestId,
|
|
57986
|
-
resource,
|
|
57987
|
-
totalRecords,
|
|
57988
|
-
chunkCount,
|
|
57989
|
-
preparationTimeMs: riskInfo.elapsedMs,
|
|
57990
|
-
remainingTimeMs: riskInfo.remainingMs,
|
|
57991
|
-
timeoutRisk: riskInfo.risk
|
|
57992
|
-
});
|
|
57993
|
-
if (riskInfo.risk === "high") {
|
|
57994
|
-
logger2.warn("High timeout risk detected during preparation phase", {
|
|
57995
|
-
requestId,
|
|
57996
|
-
resource,
|
|
57997
|
-
preparationElapsedMs: riskInfo.elapsedMs,
|
|
57998
|
-
remainingTimeMs: riskInfo.remainingMs,
|
|
57999
|
-
lambdaTimeoutMs: LAMBDA_TIMEOUT_MS,
|
|
58000
|
-
recommendation: "Consider reducing batch size or optimizing preparation logic"
|
|
58001
|
-
});
|
|
57967
|
+
function getTableName() {
|
|
57968
|
+
const tableName = process.env.TABLE_NAME;
|
|
57969
|
+
if (!tableName) {
|
|
57970
|
+
throw new ConfigError("TABLE_NAME environment variable is not set");
|
|
58002
57971
|
}
|
|
57972
|
+
return tableName;
|
|
58003
57973
|
}
|
|
58004
|
-
function
|
|
58005
|
-
const
|
|
58006
|
-
|
|
58007
|
-
requestId,
|
|
58008
|
-
resource,
|
|
58009
|
-
requested,
|
|
58010
|
-
succeeded,
|
|
58011
|
-
totalFailed: failed,
|
|
58012
|
-
totalExecutionTimeMs: riskInfo.elapsedMs,
|
|
58013
|
-
totalExecutionTimeSeconds: totalElapsedSeconds,
|
|
58014
|
-
lambdaTimeoutMs: LAMBDA_TIMEOUT_MS,
|
|
58015
|
-
timeoutUtilization: `${riskInfo.utilizationPercent}%`,
|
|
58016
|
-
...additionalInfo
|
|
58017
|
-
});
|
|
57974
|
+
function removeShadowKeys(record) {
|
|
57975
|
+
const { __shadowKeys, ...rest } = record;
|
|
57976
|
+
return rest;
|
|
58018
57977
|
}
|
|
58019
|
-
function
|
|
58020
|
-
const
|
|
58021
|
-
|
|
58022
|
-
requestId,
|
|
58023
|
-
resource,
|
|
58024
|
-
totalRequested: requested,
|
|
58025
|
-
successCount: succeeded,
|
|
58026
|
-
failedCount: failed,
|
|
58027
|
-
failureRate: `${failureRate}%`,
|
|
58028
|
-
errorCodes: [...new Set(errorCodes)],
|
|
58029
|
-
...additionalInfo
|
|
58030
|
-
});
|
|
57978
|
+
function extractCleanRecord(item) {
|
|
57979
|
+
const data = item.data || item;
|
|
57980
|
+
return removeShadowKeys(data);
|
|
58031
57981
|
}
|
|
58032
|
-
|
|
58033
|
-
|
|
58034
|
-
|
|
57982
|
+
async function executeDynamoDBOperation(operation2, operationName) {
|
|
57983
|
+
try {
|
|
57984
|
+
return await operation2();
|
|
57985
|
+
} catch (error2) {
|
|
57986
|
+
if (error2 instanceof Error && error2.name === "AccessDeniedException") {
|
|
57987
|
+
logger2.error("DynamoDB access denied", {
|
|
57988
|
+
errorName: error2.name,
|
|
57989
|
+
errorMessage: error2.message,
|
|
57990
|
+
operation: operationName,
|
|
57991
|
+
tableName: process.env.TABLE_NAME,
|
|
57992
|
+
region: process.env.AWS_REGION || process.env.REGION
|
|
57993
|
+
});
|
|
57994
|
+
throw new Error(`Insufficient permissions to access DynamoDB: ${operationName}`);
|
|
57995
|
+
}
|
|
57996
|
+
throw error2;
|
|
57997
|
+
}
|
|
57998
|
+
}
|
|
57999
|
+
var logger2, dbClient;
|
|
58000
|
+
var init_dynamodb3 = __esm({
|
|
58001
|
+
"src/server/utils/dynamodb.ts"() {
|
|
58035
58002
|
"use strict";
|
|
58036
58003
|
init_shared();
|
|
58037
58004
|
logger2 = createLogger({ service: "records-lambda" });
|
|
58038
|
-
|
|
58039
|
-
__name(
|
|
58040
|
-
__name(
|
|
58041
|
-
__name(
|
|
58042
|
-
__name(
|
|
58005
|
+
dbClient = null;
|
|
58006
|
+
__name(getDBClient, "getDBClient");
|
|
58007
|
+
__name(getTableName, "getTableName");
|
|
58008
|
+
__name(removeShadowKeys, "removeShadowKeys");
|
|
58009
|
+
__name(extractCleanRecord, "extractCleanRecord");
|
|
58010
|
+
__name(executeDynamoDBOperation, "executeDynamoDBOperation");
|
|
58043
58011
|
}
|
|
58044
58012
|
});
|
|
58045
58013
|
|
|
58046
|
-
// src/server/utils/
|
|
58047
|
-
function
|
|
58048
|
-
|
|
58049
|
-
const itemCounts = [];
|
|
58050
|
-
let currentChunk = [];
|
|
58051
|
-
let currentItemCount = 0;
|
|
58052
|
-
for (const record of records) {
|
|
58053
|
-
const itemCount = getItemCount(record);
|
|
58054
|
-
if (itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS) {
|
|
58055
|
-
const errorMsg = `Single record exceeds ${DYNAMODB_TRANSACT_WRITE_MAX_ITEMS} items limit: ${itemCount} items`;
|
|
58056
|
-
logger3.error("Chunk validation failed", {
|
|
58057
|
-
itemCount,
|
|
58058
|
-
limit: DYNAMODB_TRANSACT_WRITE_MAX_ITEMS
|
|
58059
|
-
});
|
|
58060
|
-
throw new Error(errorMsg);
|
|
58061
|
-
}
|
|
58062
|
-
if (currentItemCount + itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS) {
|
|
58063
|
-
if (currentChunk.length > 0) {
|
|
58064
|
-
chunks.push(currentChunk);
|
|
58065
|
-
itemCounts.push(currentItemCount);
|
|
58066
|
-
}
|
|
58067
|
-
currentChunk = [record];
|
|
58068
|
-
currentItemCount = itemCount;
|
|
58069
|
-
} else {
|
|
58070
|
-
currentChunk.push(record);
|
|
58071
|
-
currentItemCount += itemCount;
|
|
58072
|
-
}
|
|
58073
|
-
}
|
|
58074
|
-
if (currentChunk.length > 0) {
|
|
58075
|
-
chunks.push(currentChunk);
|
|
58076
|
-
itemCounts.push(currentItemCount);
|
|
58077
|
-
}
|
|
58078
|
-
logger3.info("Chunk calculation completed", {
|
|
58079
|
-
totalRecords: records.length,
|
|
58080
|
-
chunkCount: chunks.length,
|
|
58081
|
-
itemCounts,
|
|
58082
|
-
minItemsPerChunk: itemCounts.length > 0 ? Math.min(...itemCounts) : 0,
|
|
58083
|
-
maxItemsPerChunk: itemCounts.length > 0 ? Math.max(...itemCounts) : 0,
|
|
58084
|
-
avgItemsPerChunk: itemCounts.length > 0 ? Math.round(itemCounts.reduce((sum, count) => sum + count, 0) / itemCounts.length) : 0
|
|
58085
|
-
});
|
|
58086
|
-
return { chunks, itemCounts };
|
|
58014
|
+
// src/server/utils/validation.ts
|
|
58015
|
+
function validateSortField(_config, _resource, _sort) {
|
|
58016
|
+
return;
|
|
58087
58017
|
}
|
|
58088
|
-
|
|
58089
|
-
const
|
|
58090
|
-
const
|
|
58091
|
-
|
|
58092
|
-
|
|
58093
|
-
|
|
58094
|
-
|
|
58095
|
-
|
|
58096
|
-
totalRecords
|
|
58097
|
-
});
|
|
58098
|
-
for (let i4 = 0; i4 < chunks.length; i4++) {
|
|
58099
|
-
const chunk = chunks[i4];
|
|
58100
|
-
const chunkStartTime = Date.now();
|
|
58101
|
-
try {
|
|
58102
|
-
logger3.debug(`Executing chunk ${i4 + 1}/${chunks.length}`, {
|
|
58103
|
-
chunkIndex: i4,
|
|
58104
|
-
recordCount: chunk.length
|
|
58105
|
-
});
|
|
58106
|
-
const successfulRecords = await executeChunk(chunk);
|
|
58107
|
-
successRecords.push(...successfulRecords);
|
|
58108
|
-
const chunkDuration = Date.now() - chunkStartTime;
|
|
58109
|
-
logger3.info(`Chunk ${i4 + 1}/${chunks.length} succeeded`, {
|
|
58110
|
-
chunkIndex: i4,
|
|
58111
|
-
recordCount: chunk.length,
|
|
58112
|
-
durationMs: chunkDuration
|
|
58113
|
-
});
|
|
58114
|
-
} catch (error2) {
|
|
58115
|
-
const chunkDuration = Date.now() - chunkStartTime;
|
|
58116
|
-
const errorMessage = error2 instanceof Error ? error2.message : "Unknown error";
|
|
58117
|
-
const errorCode = getErrorCode(error2);
|
|
58118
|
-
logger3.error(`Chunk ${i4 + 1}/${chunks.length} failed`, {
|
|
58119
|
-
chunkIndex: i4,
|
|
58120
|
-
recordCount: chunk.length,
|
|
58121
|
-
durationMs: chunkDuration,
|
|
58122
|
-
error: errorMessage,
|
|
58123
|
-
errorCode
|
|
58124
|
-
});
|
|
58125
|
-
for (const record of chunk) {
|
|
58126
|
-
const recordId = getRecordId(record);
|
|
58127
|
-
failedIds.push(recordId);
|
|
58128
|
-
errors.push({
|
|
58129
|
-
id: recordId,
|
|
58130
|
-
code: errorCode,
|
|
58131
|
-
message: errorMessage
|
|
58132
|
-
});
|
|
58133
|
-
}
|
|
58134
|
-
}
|
|
58135
|
-
}
|
|
58136
|
-
const totalExecutionTime = Date.now() - executionStartTime;
|
|
58137
|
-
logger3.info("Chunk execution completed", {
|
|
58138
|
-
totalChunks: chunks.length,
|
|
58139
|
-
totalRecords,
|
|
58140
|
-
successCount: successRecords.length,
|
|
58141
|
-
failedCount: failedIds.length,
|
|
58142
|
-
totalExecutionTimeMs: totalExecutionTime,
|
|
58143
|
-
avgTimePerChunkMs: chunks.length > 0 ? Math.round(totalExecutionTime / chunks.length) : 0
|
|
58144
|
-
});
|
|
58145
|
-
if (failedIds.length > 0) {
|
|
58146
|
-
logger3.warn("Partial failure detected in chunk execution", {
|
|
58147
|
-
totalRecords,
|
|
58148
|
-
successCount: successRecords.length,
|
|
58149
|
-
failedCount: failedIds.length,
|
|
58150
|
-
failureRate: `${Math.round(failedIds.length / totalRecords * 100)}%`,
|
|
58151
|
-
failedIds: failedIds.slice(0, 10),
|
|
58152
|
-
// 最初の10件のみログ出力
|
|
58153
|
-
errorSummary: errors.slice(0, 5).map((e4) => ({
|
|
58154
|
-
id: e4.id,
|
|
58155
|
-
code: e4.code,
|
|
58156
|
-
message: e4.message.substring(0, 100)
|
|
58157
|
-
// メッセージを100文字に制限
|
|
58158
|
-
}))
|
|
58159
|
-
});
|
|
58018
|
+
function normalizePagination(pagination) {
|
|
58019
|
+
const perPage = Math.min(pagination?.perPage || 50, 50);
|
|
58020
|
+
const nextToken = pagination?.nextToken;
|
|
58021
|
+
return { perPage, nextToken };
|
|
58022
|
+
}
|
|
58023
|
+
function normalizeSort(config, _resource, sort) {
|
|
58024
|
+
if (sort) {
|
|
58025
|
+
return sort;
|
|
58160
58026
|
}
|
|
58161
58027
|
return {
|
|
58162
|
-
|
|
58163
|
-
|
|
58164
|
-
errors
|
|
58028
|
+
field: config.updatedAtField,
|
|
58029
|
+
order: "DESC"
|
|
58165
58030
|
};
|
|
58166
58031
|
}
|
|
58167
|
-
|
|
58168
|
-
|
|
58169
|
-
if ("name" in error2 && typeof error2.name === "string") {
|
|
58170
|
-
return error2.name;
|
|
58171
|
-
}
|
|
58172
|
-
if ("code" in error2 && typeof error2.code === "string") {
|
|
58173
|
-
return error2.code;
|
|
58174
|
-
}
|
|
58175
|
-
}
|
|
58176
|
-
return "TRANSACTION_FAILED";
|
|
58177
|
-
}
|
|
58178
|
-
var logger3;
|
|
58179
|
-
var init_chunking = __esm({
|
|
58180
|
-
"src/server/utils/chunking.ts"() {
|
|
58032
|
+
var init_validation2 = __esm({
|
|
58033
|
+
"src/server/utils/validation.ts"() {
|
|
58181
58034
|
"use strict";
|
|
58182
|
-
|
|
58183
|
-
|
|
58184
|
-
__name(
|
|
58185
|
-
__name(executeChunks, "executeChunks");
|
|
58186
|
-
__name(getErrorCode, "getErrorCode");
|
|
58035
|
+
__name(validateSortField, "validateSortField");
|
|
58036
|
+
__name(normalizePagination, "normalizePagination");
|
|
58037
|
+
__name(normalizeSort, "normalizeSort");
|
|
58187
58038
|
}
|
|
58188
58039
|
});
|
|
58189
58040
|
|
|
@@ -58253,62 +58104,6 @@ var init_cost_tracker = __esm({
|
|
|
58253
58104
|
}
|
|
58254
58105
|
});
|
|
58255
58106
|
|
|
58256
|
-
// src/server/utils/dynamodb.ts
|
|
58257
|
-
function getDBClient() {
|
|
58258
|
-
if (!dbClient) {
|
|
58259
|
-
dbClient = createDynamoDBClient({
|
|
58260
|
-
region: process.env.AWS_REGION || process.env.REGION
|
|
58261
|
-
});
|
|
58262
|
-
}
|
|
58263
|
-
return dbClient;
|
|
58264
|
-
}
|
|
58265
|
-
function getTableName() {
|
|
58266
|
-
const tableName = process.env.TABLE_NAME;
|
|
58267
|
-
if (!tableName) {
|
|
58268
|
-
throw new ConfigError("TABLE_NAME environment variable is not set");
|
|
58269
|
-
}
|
|
58270
|
-
return tableName;
|
|
58271
|
-
}
|
|
58272
|
-
function removeShadowKeys(record) {
|
|
58273
|
-
const { __shadowKeys, ...rest } = record;
|
|
58274
|
-
return rest;
|
|
58275
|
-
}
|
|
58276
|
-
function extractCleanRecord(item) {
|
|
58277
|
-
const data = item.data || item;
|
|
58278
|
-
return removeShadowKeys(data);
|
|
58279
|
-
}
|
|
58280
|
-
async function executeDynamoDBOperation(operation2, operationName) {
|
|
58281
|
-
try {
|
|
58282
|
-
return await operation2();
|
|
58283
|
-
} catch (error2) {
|
|
58284
|
-
if (error2 instanceof Error && error2.name === "AccessDeniedException") {
|
|
58285
|
-
logger4.error("DynamoDB access denied", {
|
|
58286
|
-
errorName: error2.name,
|
|
58287
|
-
errorMessage: error2.message,
|
|
58288
|
-
operation: operationName,
|
|
58289
|
-
tableName: process.env.TABLE_NAME,
|
|
58290
|
-
region: process.env.AWS_REGION || process.env.REGION
|
|
58291
|
-
});
|
|
58292
|
-
throw new Error(`Insufficient permissions to access DynamoDB: ${operationName}`);
|
|
58293
|
-
}
|
|
58294
|
-
throw error2;
|
|
58295
|
-
}
|
|
58296
|
-
}
|
|
58297
|
-
var logger4, dbClient;
|
|
58298
|
-
var init_dynamodb3 = __esm({
|
|
58299
|
-
"src/server/utils/dynamodb.ts"() {
|
|
58300
|
-
"use strict";
|
|
58301
|
-
init_shared();
|
|
58302
|
-
logger4 = createLogger({ service: "records-lambda" });
|
|
58303
|
-
dbClient = null;
|
|
58304
|
-
__name(getDBClient, "getDBClient");
|
|
58305
|
-
__name(getTableName, "getTableName");
|
|
58306
|
-
__name(removeShadowKeys, "removeShadowKeys");
|
|
58307
|
-
__name(extractCleanRecord, "extractCleanRecord");
|
|
58308
|
-
__name(executeDynamoDBOperation, "executeDynamoDBOperation");
|
|
58309
|
-
}
|
|
58310
|
-
});
|
|
58311
|
-
|
|
58312
58107
|
// src/client/FindCursor.ts
|
|
58313
58108
|
var init_FindCursor = __esm({
|
|
58314
58109
|
"src/client/FindCursor.ts"() {
|
|
@@ -58517,80 +58312,6 @@ var init_index2 = __esm({
|
|
|
58517
58312
|
}
|
|
58518
58313
|
});
|
|
58519
58314
|
|
|
58520
|
-
// src/server/utils/timestamps.ts
|
|
58521
|
-
var timestamps_exports = {};
|
|
58522
|
-
__export(timestamps_exports, {
|
|
58523
|
-
addCreateTimestamps: () => addCreateTimestamps,
|
|
58524
|
-
addUpdateTimestamp: () => addUpdateTimestamp,
|
|
58525
|
-
getTimestampFields: () => getTimestampFields
|
|
58526
|
-
});
|
|
58527
|
-
function getTimestampFields() {
|
|
58528
|
-
const shadowConfig = getShadowConfig();
|
|
58529
|
-
return {
|
|
58530
|
-
createdAt: shadowConfig.createdAtField,
|
|
58531
|
-
updatedAt: shadowConfig.updatedAtField
|
|
58532
|
-
};
|
|
58533
|
-
}
|
|
58534
|
-
function addCreateTimestamps(data) {
|
|
58535
|
-
const timestampFields = getTimestampFields();
|
|
58536
|
-
if (!timestampFields) {
|
|
58537
|
-
return data;
|
|
58538
|
-
}
|
|
58539
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
58540
|
-
return {
|
|
58541
|
-
[timestampFields.createdAt]: now,
|
|
58542
|
-
[timestampFields.updatedAt]: now,
|
|
58543
|
-
...data
|
|
58544
|
-
};
|
|
58545
|
-
}
|
|
58546
|
-
function addUpdateTimestamp(data) {
|
|
58547
|
-
const timestampFields = getTimestampFields();
|
|
58548
|
-
if (!timestampFields) {
|
|
58549
|
-
return data;
|
|
58550
|
-
}
|
|
58551
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
58552
|
-
return {
|
|
58553
|
-
[timestampFields.updatedAt]: now,
|
|
58554
|
-
...data
|
|
58555
|
-
};
|
|
58556
|
-
}
|
|
58557
|
-
var init_timestamps = __esm({
|
|
58558
|
-
"src/server/utils/timestamps.ts"() {
|
|
58559
|
-
"use strict";
|
|
58560
|
-
init_index2();
|
|
58561
|
-
__name(getTimestampFields, "getTimestampFields");
|
|
58562
|
-
__name(addCreateTimestamps, "addCreateTimestamps");
|
|
58563
|
-
__name(addUpdateTimestamp, "addUpdateTimestamp");
|
|
58564
|
-
}
|
|
58565
|
-
});
|
|
58566
|
-
|
|
58567
|
-
// src/server/utils/validation.ts
|
|
58568
|
-
function validateSortField(_config, _resource, _sort) {
|
|
58569
|
-
return;
|
|
58570
|
-
}
|
|
58571
|
-
function normalizePagination(pagination) {
|
|
58572
|
-
const perPage = Math.min(pagination?.perPage || 50, 50);
|
|
58573
|
-
const nextToken = pagination?.nextToken;
|
|
58574
|
-
return { perPage, nextToken };
|
|
58575
|
-
}
|
|
58576
|
-
function normalizeSort(config, _resource, sort) {
|
|
58577
|
-
if (sort) {
|
|
58578
|
-
return sort;
|
|
58579
|
-
}
|
|
58580
|
-
return {
|
|
58581
|
-
field: config.updatedAtField,
|
|
58582
|
-
order: "DESC"
|
|
58583
|
-
};
|
|
58584
|
-
}
|
|
58585
|
-
var init_validation2 = __esm({
|
|
58586
|
-
"src/server/utils/validation.ts"() {
|
|
58587
|
-
"use strict";
|
|
58588
|
-
__name(validateSortField, "validateSortField");
|
|
58589
|
-
__name(normalizePagination, "normalizePagination");
|
|
58590
|
-
__name(normalizeSort, "normalizeSort");
|
|
58591
|
-
}
|
|
58592
|
-
});
|
|
58593
|
-
|
|
58594
58315
|
// src/shared/constants/validation.ts
|
|
58595
58316
|
var VALIDATION_ERROR_MESSAGES;
|
|
58596
58317
|
var init_validation3 = __esm({
|
|
@@ -58753,7 +58474,7 @@ function parseFilters(filter) {
|
|
|
58753
58474
|
parsedFilters.push({ parsed, value });
|
|
58754
58475
|
}
|
|
58755
58476
|
} catch (error2) {
|
|
58756
|
-
|
|
58477
|
+
logger3.error("Invalid filter field syntax", {
|
|
58757
58478
|
fieldKey,
|
|
58758
58479
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
58759
58480
|
});
|
|
@@ -58822,7 +58543,7 @@ function detectNearQuery(filter) {
|
|
|
58822
58543
|
}
|
|
58823
58544
|
return null;
|
|
58824
58545
|
}
|
|
58825
|
-
var
|
|
58546
|
+
var logger3;
|
|
58826
58547
|
var init_utils5 = __esm({
|
|
58827
58548
|
"src/server/operations/find/utils.ts"() {
|
|
58828
58549
|
"use strict";
|
|
@@ -58831,7 +58552,7 @@ var init_utils5 = __esm({
|
|
|
58831
58552
|
init_shadow();
|
|
58832
58553
|
init_filter();
|
|
58833
58554
|
init_validation2();
|
|
58834
|
-
|
|
58555
|
+
logger3 = createLogger({
|
|
58835
58556
|
service: "find-utils",
|
|
58836
58557
|
level: process.env.LOG_LEVEL || "info"
|
|
58837
58558
|
});
|
|
@@ -58848,7 +58569,7 @@ var init_utils5 = __esm({
|
|
|
58848
58569
|
async function executeIdQuery(resource, normalizedParams, requestId) {
|
|
58849
58570
|
const { sort, pagination, parsedFilters } = normalizedParams;
|
|
58850
58571
|
const { perPage, nextToken } = pagination;
|
|
58851
|
-
|
|
58572
|
+
logger4.debug("Executing ID optimized query", {
|
|
58852
58573
|
requestId,
|
|
58853
58574
|
resource,
|
|
58854
58575
|
sort,
|
|
@@ -58885,7 +58606,7 @@ async function executeSpecificIdQuery(resource, targetId, requestId) {
|
|
|
58885
58606
|
costTracker.add(queryResult.ConsumedCapacity);
|
|
58886
58607
|
const mainRecords = queryResult.Items || [];
|
|
58887
58608
|
const items = mainRecords.map((item) => extractCleanRecord(item));
|
|
58888
|
-
|
|
58609
|
+
logger4.info("ID specific query succeeded", {
|
|
58889
58610
|
requestId,
|
|
58890
58611
|
resource,
|
|
58891
58612
|
targetId,
|
|
@@ -58932,7 +58653,7 @@ async function executeInQuery(resource, targetIds, sort, requestId) {
|
|
|
58932
58653
|
const bVal = String(b4.id ?? "");
|
|
58933
58654
|
return sort.order === "ASC" ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal);
|
|
58934
58655
|
});
|
|
58935
|
-
|
|
58656
|
+
logger4.info("ID $in query succeeded", {
|
|
58936
58657
|
requestId,
|
|
58937
58658
|
resource,
|
|
58938
58659
|
requestedCount: targetIds.length,
|
|
@@ -59001,7 +58722,7 @@ async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsed
|
|
|
59001
58722
|
queryResult.LastEvaluatedKey.PK,
|
|
59002
58723
|
queryResult.LastEvaluatedKey.SK
|
|
59003
58724
|
) : void 0;
|
|
59004
|
-
|
|
58725
|
+
logger4.info("ID all records query succeeded", {
|
|
59005
58726
|
requestId,
|
|
59006
58727
|
resource,
|
|
59007
58728
|
count: items.length,
|
|
@@ -59022,7 +58743,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
59022
58743
|
const tableName = getTableName();
|
|
59023
58744
|
const costTracker = new CostTracker();
|
|
59024
58745
|
const offset = nextToken ? decodeOffsetToken(nextToken) ?? 0 : 0;
|
|
59025
|
-
|
|
58746
|
+
logger4.debug("Executing full scan query (ID sort)", {
|
|
59026
58747
|
requestId,
|
|
59027
58748
|
resource,
|
|
59028
58749
|
offset
|
|
@@ -59034,7 +58755,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
59034
58755
|
let iterations = 0;
|
|
59035
58756
|
do {
|
|
59036
58757
|
if (++iterations > MAX_ITERATIONS) {
|
|
59037
|
-
|
|
58758
|
+
logger4.error("executeAllRecordsQueryFullScan: \u6700\u5927\u53CD\u5FA9\u56DE\u6570\u3092\u8D85\u904E\u3057\u305F\u305F\u3081\u4E2D\u65AD", {
|
|
59038
58759
|
requestId,
|
|
59039
58760
|
resource,
|
|
59040
58761
|
iterations
|
|
@@ -59065,7 +58786,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
59065
58786
|
const nextKey = queryResult.LastEvaluatedKey;
|
|
59066
58787
|
const nextKeySignature = nextKey ? `${nextKey.PK}#${nextKey.SK}` : void 0;
|
|
59067
58788
|
if (nextKeySignature && nextKeySignature === previousKeySignature) {
|
|
59068
|
-
|
|
58789
|
+
logger4.error("executeAllRecordsQueryFullScan: \u540C\u4E00\u306ELastEvaluatedKey\u304C\u8FD4\u5374\u3055\u308C\u305F\u305F\u3081\u4E2D\u65AD", {
|
|
59069
58790
|
requestId,
|
|
59070
58791
|
resource,
|
|
59071
58792
|
iterations
|
|
@@ -59080,7 +58801,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
59080
58801
|
const page = items.slice(offset, offset + perPage);
|
|
59081
58802
|
const hasNextPage = offset + perPage < items.length;
|
|
59082
58803
|
const nextTokenValue = hasNextPage ? encodeOffsetToken(offset + perPage) : void 0;
|
|
59083
|
-
|
|
58804
|
+
logger4.info("ID full scan query succeeded", {
|
|
59084
58805
|
requestId,
|
|
59085
58806
|
resource,
|
|
59086
58807
|
totalMatched: items.length,
|
|
@@ -59095,7 +58816,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
59095
58816
|
consumedCapacity: costTracker.getAggregated()
|
|
59096
58817
|
};
|
|
59097
58818
|
}
|
|
59098
|
-
var import_lib_dynamodb2,
|
|
58819
|
+
var import_lib_dynamodb2, logger4;
|
|
59099
58820
|
var init_idQuery = __esm({
|
|
59100
58821
|
"src/server/operations/find/idQuery.ts"() {
|
|
59101
58822
|
"use strict";
|
|
@@ -59105,7 +58826,7 @@ var init_idQuery = __esm({
|
|
|
59105
58826
|
init_dynamodb3();
|
|
59106
58827
|
init_pagination();
|
|
59107
58828
|
init_utils5();
|
|
59108
|
-
|
|
58829
|
+
logger4 = createLogger({
|
|
59109
58830
|
service: "id-query",
|
|
59110
58831
|
level: process.env.LOG_LEVEL || "info"
|
|
59111
58832
|
});
|
|
@@ -59119,7 +58840,7 @@ var init_idQuery = __esm({
|
|
|
59119
58840
|
|
|
59120
58841
|
// src/server/operations/find/nearQuery.ts
|
|
59121
58842
|
async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId) {
|
|
59122
|
-
|
|
58843
|
+
logger5.debug("Executing $near query", {
|
|
59123
58844
|
requestId,
|
|
59124
58845
|
resource,
|
|
59125
58846
|
fieldName,
|
|
@@ -59130,7 +58851,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
59130
58851
|
const searchFunction = /* @__PURE__ */ __name(async (geohashPrefix) => {
|
|
59131
58852
|
const dbClient2 = getDBClient();
|
|
59132
58853
|
const tableName = getTableName();
|
|
59133
|
-
|
|
58854
|
+
logger5.debug("Searching shadow records", {
|
|
59134
58855
|
requestId,
|
|
59135
58856
|
resource,
|
|
59136
58857
|
fieldName,
|
|
@@ -59155,7 +58876,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
59155
58876
|
);
|
|
59156
58877
|
costTracker.add(queryResult.ConsumedCapacity);
|
|
59157
58878
|
const shadowRecords = queryResult.Items || [];
|
|
59158
|
-
|
|
58879
|
+
logger5.debug("Shadow records found", {
|
|
59159
58880
|
requestId,
|
|
59160
58881
|
resource,
|
|
59161
58882
|
geohashPrefix,
|
|
@@ -59166,7 +58887,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
59166
58887
|
const parts = sk.split("#id#");
|
|
59167
58888
|
return parts.length === 2 ? parts[1] : null;
|
|
59168
58889
|
}).filter((id) => id !== null);
|
|
59169
|
-
|
|
58890
|
+
logger5.debug("Main record IDs extracted", {
|
|
59170
58891
|
requestId,
|
|
59171
58892
|
resource,
|
|
59172
58893
|
geohashPrefix,
|
|
@@ -59200,14 +58921,14 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
59200
58921
|
}
|
|
59201
58922
|
validRecords.push(...batchGetResult.Responses?.[tableName] || []);
|
|
59202
58923
|
}
|
|
59203
|
-
|
|
58924
|
+
logger5.debug("Main records retrieved", {
|
|
59204
58925
|
requestId,
|
|
59205
58926
|
resource,
|
|
59206
58927
|
geohashPrefix,
|
|
59207
58928
|
count: validRecords.length
|
|
59208
58929
|
});
|
|
59209
58930
|
const cleanRecords = validRecords.map((record) => extractCleanRecord(record));
|
|
59210
|
-
|
|
58931
|
+
logger5.debug("Clean records extracted", {
|
|
59211
58932
|
requestId,
|
|
59212
58933
|
resource,
|
|
59213
58934
|
geohashPrefix,
|
|
@@ -59226,7 +58947,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
59226
58947
|
config
|
|
59227
58948
|
);
|
|
59228
58949
|
const items = result.documents;
|
|
59229
|
-
|
|
58950
|
+
logger5.info("$near query succeeded", {
|
|
59230
58951
|
requestId,
|
|
59231
58952
|
resource,
|
|
59232
58953
|
fieldName,
|
|
@@ -59244,7 +58965,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
59244
58965
|
consumedCapacity: costTracker.getAggregated()
|
|
59245
58966
|
};
|
|
59246
58967
|
}
|
|
59247
|
-
var import_lib_dynamodb3,
|
|
58968
|
+
var import_lib_dynamodb3, logger5;
|
|
59248
58969
|
var init_nearQuery = __esm({
|
|
59249
58970
|
"src/server/operations/find/nearQuery.ts"() {
|
|
59250
58971
|
"use strict";
|
|
@@ -59254,7 +58975,7 @@ var init_nearQuery = __esm({
|
|
|
59254
58975
|
init_nearSearch();
|
|
59255
58976
|
init_cost_tracker();
|
|
59256
58977
|
init_dynamodb3();
|
|
59257
|
-
|
|
58978
|
+
logger5 = createLogger({
|
|
59258
58979
|
service: "near-query",
|
|
59259
58980
|
level: process.env.LOG_LEVEL || "info"
|
|
59260
58981
|
});
|
|
@@ -59284,7 +59005,7 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
59284
59005
|
(f4) => !(isKeyConditionOptimized && f4 === optimizableFilter)
|
|
59285
59006
|
);
|
|
59286
59007
|
if (residualFilters.length > 0) {
|
|
59287
|
-
|
|
59008
|
+
logger6.debug("Residual filters detected, falling back to full scan", {
|
|
59288
59009
|
requestId,
|
|
59289
59010
|
resource,
|
|
59290
59011
|
sortField: sort.field,
|
|
@@ -59292,7 +59013,7 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
59292
59013
|
});
|
|
59293
59014
|
return executeFullScanQuery(resource, normalizedParams, costTracker, requestId);
|
|
59294
59015
|
}
|
|
59295
|
-
|
|
59016
|
+
logger6.debug("Executing shadow query", {
|
|
59296
59017
|
requestId,
|
|
59297
59018
|
resource,
|
|
59298
59019
|
sortField: sort.field,
|
|
@@ -59340,7 +59061,7 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
59340
59061
|
shadowRecords.LastEvaluatedKey.PK,
|
|
59341
59062
|
shadowRecords.LastEvaluatedKey.SK
|
|
59342
59063
|
) : void 0;
|
|
59343
|
-
|
|
59064
|
+
logger6.info("Shadow query succeeded", {
|
|
59344
59065
|
requestId,
|
|
59345
59066
|
resource,
|
|
59346
59067
|
sortField: sort.field,
|
|
@@ -59365,7 +59086,7 @@ async function executeFilterFirstQuery(resource, normalizedParams, filterCandida
|
|
|
59365
59086
|
const offset = nextToken ? decodeOffsetToken(nextToken) ?? 0 : 0;
|
|
59366
59087
|
const filterSort = { field: filterCandidate.parsed.field, order: "ASC" };
|
|
59367
59088
|
const remainingFilters = parsedFilters.filter((f4) => f4 !== filterCandidate);
|
|
59368
|
-
|
|
59089
|
+
logger6.debug("Executing filter-first query", {
|
|
59369
59090
|
requestId,
|
|
59370
59091
|
resource,
|
|
59371
59092
|
filterField: filterCandidate.parsed.field,
|
|
@@ -59386,7 +59107,7 @@ async function executeFilterFirstQuery(resource, normalizedParams, filterCandida
|
|
|
59386
59107
|
const page = items.slice(offset, offset + perPage);
|
|
59387
59108
|
const hasNextPage = offset + perPage < items.length;
|
|
59388
59109
|
const nextTokenValue = hasNextPage ? encodeOffsetToken(offset + perPage) : void 0;
|
|
59389
|
-
|
|
59110
|
+
logger6.info("Filter-first query succeeded", {
|
|
59390
59111
|
requestId,
|
|
59391
59112
|
resource,
|
|
59392
59113
|
filterField: filterCandidate.parsed.field,
|
|
@@ -59407,7 +59128,7 @@ async function executeFullScanQuery(resource, normalizedParams, costTracker, req
|
|
|
59407
59128
|
const { sort, pagination, parsedFilters } = normalizedParams;
|
|
59408
59129
|
const { perPage, nextToken } = pagination;
|
|
59409
59130
|
const offset = nextToken ? decodeOffsetToken(nextToken) ?? 0 : 0;
|
|
59410
|
-
|
|
59131
|
+
logger6.debug("Executing full scan query", {
|
|
59411
59132
|
requestId,
|
|
59412
59133
|
resource,
|
|
59413
59134
|
sortField: sort.field,
|
|
@@ -59420,7 +59141,7 @@ async function executeFullScanQuery(resource, normalizedParams, costTracker, req
|
|
|
59420
59141
|
const page = items.slice(offset, offset + perPage);
|
|
59421
59142
|
const hasNextPage = offset + perPage < items.length;
|
|
59422
59143
|
const nextTokenValue = hasNextPage ? encodeOffsetToken(offset + perPage) : void 0;
|
|
59423
|
-
|
|
59144
|
+
logger6.info("Full scan query succeeded", {
|
|
59424
59145
|
requestId,
|
|
59425
59146
|
resource,
|
|
59426
59147
|
sortField: sort.field,
|
|
@@ -59444,7 +59165,7 @@ async function fetchAllRecordsViaShadowIndex(resource, indexSort, indexFilter, c
|
|
|
59444
59165
|
let iterations = 0;
|
|
59445
59166
|
do {
|
|
59446
59167
|
if (++iterations > MAX_ITERATIONS) {
|
|
59447
|
-
|
|
59168
|
+
logger6.error("fetchAllRecordsViaShadowIndex: \u6700\u5927\u53CD\u5FA9\u56DE\u6570\u3092\u8D85\u904E\u3057\u305F\u305F\u3081\u4E2D\u65AD", {
|
|
59448
59169
|
requestId,
|
|
59449
59170
|
resource,
|
|
59450
59171
|
iterations
|
|
@@ -59465,7 +59186,7 @@ async function fetchAllRecordsViaShadowIndex(resource, indexSort, indexFilter, c
|
|
|
59465
59186
|
const nextKey = result.LastEvaluatedKey;
|
|
59466
59187
|
const nextKeySignature = nextKey ? `${nextKey.PK}#${nextKey.SK}` : void 0;
|
|
59467
59188
|
if (nextKeySignature && nextKeySignature === previousKeySignature) {
|
|
59468
|
-
|
|
59189
|
+
logger6.error("fetchAllRecordsViaShadowIndex: \u540C\u4E00\u306ELastEvaluatedKey\u304C\u8FD4\u5374\u3055\u308C\u305F\u305F\u3081\u4E2D\u65AD", {
|
|
59469
59190
|
requestId,
|
|
59470
59191
|
resource,
|
|
59471
59192
|
iterations
|
|
@@ -59676,7 +59397,7 @@ async function fetchMainRecords(resource, recordIds, costTracker, requestId) {
|
|
|
59676
59397
|
}
|
|
59677
59398
|
allRecords.push(...batchGetResult.Responses?.[tableName] || []);
|
|
59678
59399
|
}
|
|
59679
|
-
|
|
59400
|
+
logger6.debug("Main records fetched", {
|
|
59680
59401
|
requestId,
|
|
59681
59402
|
resource,
|
|
59682
59403
|
requestedCount: uniqueRecordIds.length,
|
|
@@ -59684,7 +59405,7 @@ async function fetchMainRecords(resource, recordIds, costTracker, requestId) {
|
|
|
59684
59405
|
});
|
|
59685
59406
|
return allRecords;
|
|
59686
59407
|
}
|
|
59687
|
-
var import_lib_dynamodb4,
|
|
59408
|
+
var import_lib_dynamodb4, logger6, KEY_CONDITION_OPERATORS;
|
|
59688
59409
|
var init_shadowQuery = __esm({
|
|
59689
59410
|
"src/server/operations/find/shadowQuery.ts"() {
|
|
59690
59411
|
"use strict";
|
|
@@ -59695,7 +59416,7 @@ var init_shadowQuery = __esm({
|
|
|
59695
59416
|
init_dynamodb3();
|
|
59696
59417
|
init_pagination();
|
|
59697
59418
|
init_utils5();
|
|
59698
|
-
|
|
59419
|
+
logger6 = createLogger({
|
|
59699
59420
|
service: "shadow-query",
|
|
59700
59421
|
level: process.env.LOG_LEVEL || "info"
|
|
59701
59422
|
});
|
|
@@ -59716,14 +59437,14 @@ var init_shadowQuery = __esm({
|
|
|
59716
59437
|
|
|
59717
59438
|
// src/server/operations/find/handler.ts
|
|
59718
59439
|
async function handleFind(resource, params, requestId) {
|
|
59719
|
-
|
|
59440
|
+
logger7.debug("Executing find", {
|
|
59720
59441
|
requestId,
|
|
59721
59442
|
resource,
|
|
59722
59443
|
params
|
|
59723
59444
|
});
|
|
59724
59445
|
const nearDetection = detectNearQuery(params.filter);
|
|
59725
59446
|
if (nearDetection) {
|
|
59726
|
-
|
|
59447
|
+
logger7.debug("$near operator detected, executing near search", {
|
|
59727
59448
|
requestId,
|
|
59728
59449
|
resource,
|
|
59729
59450
|
fieldName: nearDetection.fieldName
|
|
@@ -59740,7 +59461,7 @@ async function handleFind(resource, params, requestId) {
|
|
|
59740
59461
|
const config = initializeFindConfig();
|
|
59741
59462
|
const normalizedParams = normalizeFindParams(config, resource, params);
|
|
59742
59463
|
validateSortField(config, resource, normalizedParams.sort);
|
|
59743
|
-
|
|
59464
|
+
logger7.debug("Find parameters normalized", {
|
|
59744
59465
|
requestId,
|
|
59745
59466
|
resource,
|
|
59746
59467
|
sort: normalizedParams.sort,
|
|
@@ -59755,7 +59476,7 @@ async function handleFind(resource, params, requestId) {
|
|
|
59755
59476
|
}
|
|
59756
59477
|
return executeShadowQuery(resource, normalizedParams, requestId);
|
|
59757
59478
|
}
|
|
59758
|
-
var
|
|
59479
|
+
var logger7;
|
|
59759
59480
|
var init_handler = __esm({
|
|
59760
59481
|
"src/server/operations/find/handler.ts"() {
|
|
59761
59482
|
"use strict";
|
|
@@ -59765,7 +59486,7 @@ var init_handler = __esm({
|
|
|
59765
59486
|
init_nearQuery();
|
|
59766
59487
|
init_shadowQuery();
|
|
59767
59488
|
init_utils5();
|
|
59768
|
-
|
|
59489
|
+
logger7 = createLogger({
|
|
59769
59490
|
service: "find-handler",
|
|
59770
59491
|
level: process.env.LOG_LEVEL || "info"
|
|
59771
59492
|
});
|
|
@@ -59785,6 +59506,285 @@ var init_find = __esm({
|
|
|
59785
59506
|
}
|
|
59786
59507
|
});
|
|
59787
59508
|
|
|
59509
|
+
// src/server/utils/bulkOperations.ts
|
|
59510
|
+
function logLargeBatchWarning(operation2, recordCount, requestId, resource) {
|
|
59511
|
+
if (recordCount > LARGE_BATCH_WARNING_THRESHOLD) {
|
|
59512
|
+
logger9.warn(`Large batch ${operation2} operation detected`, {
|
|
59513
|
+
requestId,
|
|
59514
|
+
resource,
|
|
59515
|
+
recordCount,
|
|
59516
|
+
warningThreshold: LARGE_BATCH_WARNING_THRESHOLD,
|
|
59517
|
+
estimatedTimeoutRisk: "high",
|
|
59518
|
+
recommendation: "Consider splitting the batch into smaller requests to avoid Lambda timeout (15 min limit)"
|
|
59519
|
+
});
|
|
59520
|
+
}
|
|
59521
|
+
}
|
|
59522
|
+
function calculateTimeoutRisk(startTime) {
|
|
59523
|
+
const elapsedMs = Date.now() - startTime;
|
|
59524
|
+
const remainingMs = LAMBDA_TIMEOUT_MS - elapsedMs;
|
|
59525
|
+
const utilizationPercent = Math.round(elapsedMs / LAMBDA_TIMEOUT_MS * 100);
|
|
59526
|
+
const risk = remainingMs < LAMBDA_TIMEOUT_MS * TIMEOUT_RISK_THRESHOLD ? "high" : "low";
|
|
59527
|
+
return {
|
|
59528
|
+
elapsedMs,
|
|
59529
|
+
remainingMs,
|
|
59530
|
+
risk,
|
|
59531
|
+
utilizationPercent
|
|
59532
|
+
};
|
|
59533
|
+
}
|
|
59534
|
+
function logPreparationTimeoutRisk(requestId, resource, totalRecords, chunkCount, riskInfo) {
|
|
59535
|
+
logger9.info("Records prepared for chunk execution", {
|
|
59536
|
+
requestId,
|
|
59537
|
+
resource,
|
|
59538
|
+
totalRecords,
|
|
59539
|
+
chunkCount,
|
|
59540
|
+
preparationTimeMs: riskInfo.elapsedMs,
|
|
59541
|
+
remainingTimeMs: riskInfo.remainingMs,
|
|
59542
|
+
timeoutRisk: riskInfo.risk
|
|
59543
|
+
});
|
|
59544
|
+
if (riskInfo.risk === "high") {
|
|
59545
|
+
logger9.warn("High timeout risk detected during preparation phase", {
|
|
59546
|
+
requestId,
|
|
59547
|
+
resource,
|
|
59548
|
+
preparationElapsedMs: riskInfo.elapsedMs,
|
|
59549
|
+
remainingTimeMs: riskInfo.remainingMs,
|
|
59550
|
+
lambdaTimeoutMs: LAMBDA_TIMEOUT_MS,
|
|
59551
|
+
recommendation: "Consider reducing batch size or optimizing preparation logic"
|
|
59552
|
+
});
|
|
59553
|
+
}
|
|
59554
|
+
}
|
|
59555
|
+
function logBulkOperationComplete(operation2, requestId, resource, requested, succeeded, failed, riskInfo, additionalInfo) {
|
|
59556
|
+
const totalElapsedSeconds = Math.round(riskInfo.elapsedMs / 1e3);
|
|
59557
|
+
logger9.info(`${operation2} completed`, {
|
|
59558
|
+
requestId,
|
|
59559
|
+
resource,
|
|
59560
|
+
requested,
|
|
59561
|
+
succeeded,
|
|
59562
|
+
totalFailed: failed,
|
|
59563
|
+
totalExecutionTimeMs: riskInfo.elapsedMs,
|
|
59564
|
+
totalExecutionTimeSeconds: totalElapsedSeconds,
|
|
59565
|
+
lambdaTimeoutMs: LAMBDA_TIMEOUT_MS,
|
|
59566
|
+
timeoutUtilization: `${riskInfo.utilizationPercent}%`,
|
|
59567
|
+
...additionalInfo
|
|
59568
|
+
});
|
|
59569
|
+
}
|
|
59570
|
+
function logPartialFailure(operation2, requestId, resource, requested, succeeded, failed, errorCodes, additionalInfo) {
|
|
59571
|
+
const failureRate = Math.round(failed / requested * 100);
|
|
59572
|
+
logger9.warn(`Partial failure in ${operation2} operation`, {
|
|
59573
|
+
requestId,
|
|
59574
|
+
resource,
|
|
59575
|
+
totalRequested: requested,
|
|
59576
|
+
successCount: succeeded,
|
|
59577
|
+
failedCount: failed,
|
|
59578
|
+
failureRate: `${failureRate}%`,
|
|
59579
|
+
errorCodes: [...new Set(errorCodes)],
|
|
59580
|
+
...additionalInfo
|
|
59581
|
+
});
|
|
59582
|
+
}
|
|
59583
|
+
var logger9;
|
|
59584
|
+
var init_bulkOperations = __esm({
|
|
59585
|
+
"src/server/utils/bulkOperations.ts"() {
|
|
59586
|
+
"use strict";
|
|
59587
|
+
init_shared();
|
|
59588
|
+
logger9 = createLogger({ service: "records-lambda" });
|
|
59589
|
+
__name(logLargeBatchWarning, "logLargeBatchWarning");
|
|
59590
|
+
__name(calculateTimeoutRisk, "calculateTimeoutRisk");
|
|
59591
|
+
__name(logPreparationTimeoutRisk, "logPreparationTimeoutRisk");
|
|
59592
|
+
__name(logBulkOperationComplete, "logBulkOperationComplete");
|
|
59593
|
+
__name(logPartialFailure, "logPartialFailure");
|
|
59594
|
+
}
|
|
59595
|
+
});
|
|
59596
|
+
|
|
59597
|
+
// src/server/utils/chunking.ts
|
|
59598
|
+
function calculateChunks(records, getItemCount) {
|
|
59599
|
+
const chunks = [];
|
|
59600
|
+
const itemCounts = [];
|
|
59601
|
+
let currentChunk = [];
|
|
59602
|
+
let currentItemCount = 0;
|
|
59603
|
+
for (const record of records) {
|
|
59604
|
+
const itemCount = getItemCount(record);
|
|
59605
|
+
if (itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS) {
|
|
59606
|
+
const errorMsg = `Single record exceeds ${DYNAMODB_TRANSACT_WRITE_MAX_ITEMS} items limit: ${itemCount} items`;
|
|
59607
|
+
logger10.error("Chunk validation failed", {
|
|
59608
|
+
itemCount,
|
|
59609
|
+
limit: DYNAMODB_TRANSACT_WRITE_MAX_ITEMS
|
|
59610
|
+
});
|
|
59611
|
+
throw new Error(errorMsg);
|
|
59612
|
+
}
|
|
59613
|
+
if (currentItemCount + itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS) {
|
|
59614
|
+
if (currentChunk.length > 0) {
|
|
59615
|
+
chunks.push(currentChunk);
|
|
59616
|
+
itemCounts.push(currentItemCount);
|
|
59617
|
+
}
|
|
59618
|
+
currentChunk = [record];
|
|
59619
|
+
currentItemCount = itemCount;
|
|
59620
|
+
} else {
|
|
59621
|
+
currentChunk.push(record);
|
|
59622
|
+
currentItemCount += itemCount;
|
|
59623
|
+
}
|
|
59624
|
+
}
|
|
59625
|
+
if (currentChunk.length > 0) {
|
|
59626
|
+
chunks.push(currentChunk);
|
|
59627
|
+
itemCounts.push(currentItemCount);
|
|
59628
|
+
}
|
|
59629
|
+
logger10.info("Chunk calculation completed", {
|
|
59630
|
+
totalRecords: records.length,
|
|
59631
|
+
chunkCount: chunks.length,
|
|
59632
|
+
itemCounts,
|
|
59633
|
+
minItemsPerChunk: itemCounts.length > 0 ? Math.min(...itemCounts) : 0,
|
|
59634
|
+
maxItemsPerChunk: itemCounts.length > 0 ? Math.max(...itemCounts) : 0,
|
|
59635
|
+
avgItemsPerChunk: itemCounts.length > 0 ? Math.round(itemCounts.reduce((sum, count) => sum + count, 0) / itemCounts.length) : 0
|
|
59636
|
+
});
|
|
59637
|
+
return { chunks, itemCounts };
|
|
59638
|
+
}
|
|
59639
|
+
async function executeChunks(chunks, executeChunk, getRecordId) {
|
|
59640
|
+
const successRecords = [];
|
|
59641
|
+
const failedIds = [];
|
|
59642
|
+
const errors = [];
|
|
59643
|
+
const totalRecords = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
59644
|
+
const executionStartTime = Date.now();
|
|
59645
|
+
logger10.info("Starting chunk execution", {
|
|
59646
|
+
totalChunks: chunks.length,
|
|
59647
|
+
totalRecords
|
|
59648
|
+
});
|
|
59649
|
+
for (let i4 = 0; i4 < chunks.length; i4++) {
|
|
59650
|
+
const chunk = chunks[i4];
|
|
59651
|
+
const chunkStartTime = Date.now();
|
|
59652
|
+
try {
|
|
59653
|
+
logger10.debug(`Executing chunk ${i4 + 1}/${chunks.length}`, {
|
|
59654
|
+
chunkIndex: i4,
|
|
59655
|
+
recordCount: chunk.length
|
|
59656
|
+
});
|
|
59657
|
+
const successfulRecords = await executeChunk(chunk);
|
|
59658
|
+
successRecords.push(...successfulRecords);
|
|
59659
|
+
const chunkDuration = Date.now() - chunkStartTime;
|
|
59660
|
+
logger10.info(`Chunk ${i4 + 1}/${chunks.length} succeeded`, {
|
|
59661
|
+
chunkIndex: i4,
|
|
59662
|
+
recordCount: chunk.length,
|
|
59663
|
+
durationMs: chunkDuration
|
|
59664
|
+
});
|
|
59665
|
+
} catch (error2) {
|
|
59666
|
+
const chunkDuration = Date.now() - chunkStartTime;
|
|
59667
|
+
const errorMessage = error2 instanceof Error ? error2.message : "Unknown error";
|
|
59668
|
+
const errorCode = getErrorCode(error2);
|
|
59669
|
+
logger10.error(`Chunk ${i4 + 1}/${chunks.length} failed`, {
|
|
59670
|
+
chunkIndex: i4,
|
|
59671
|
+
recordCount: chunk.length,
|
|
59672
|
+
durationMs: chunkDuration,
|
|
59673
|
+
error: errorMessage,
|
|
59674
|
+
errorCode
|
|
59675
|
+
});
|
|
59676
|
+
for (const record of chunk) {
|
|
59677
|
+
const recordId = getRecordId(record);
|
|
59678
|
+
failedIds.push(recordId);
|
|
59679
|
+
errors.push({
|
|
59680
|
+
id: recordId,
|
|
59681
|
+
code: errorCode,
|
|
59682
|
+
message: errorMessage
|
|
59683
|
+
});
|
|
59684
|
+
}
|
|
59685
|
+
}
|
|
59686
|
+
}
|
|
59687
|
+
const totalExecutionTime = Date.now() - executionStartTime;
|
|
59688
|
+
logger10.info("Chunk execution completed", {
|
|
59689
|
+
totalChunks: chunks.length,
|
|
59690
|
+
totalRecords,
|
|
59691
|
+
successCount: successRecords.length,
|
|
59692
|
+
failedCount: failedIds.length,
|
|
59693
|
+
totalExecutionTimeMs: totalExecutionTime,
|
|
59694
|
+
avgTimePerChunkMs: chunks.length > 0 ? Math.round(totalExecutionTime / chunks.length) : 0
|
|
59695
|
+
});
|
|
59696
|
+
if (failedIds.length > 0) {
|
|
59697
|
+
logger10.warn("Partial failure detected in chunk execution", {
|
|
59698
|
+
totalRecords,
|
|
59699
|
+
successCount: successRecords.length,
|
|
59700
|
+
failedCount: failedIds.length,
|
|
59701
|
+
failureRate: `${Math.round(failedIds.length / totalRecords * 100)}%`,
|
|
59702
|
+
failedIds: failedIds.slice(0, 10),
|
|
59703
|
+
// 最初の10件のみログ出力
|
|
59704
|
+
errorSummary: errors.slice(0, 5).map((e4) => ({
|
|
59705
|
+
id: e4.id,
|
|
59706
|
+
code: e4.code,
|
|
59707
|
+
message: e4.message.substring(0, 100)
|
|
59708
|
+
// メッセージを100文字に制限
|
|
59709
|
+
}))
|
|
59710
|
+
});
|
|
59711
|
+
}
|
|
59712
|
+
return {
|
|
59713
|
+
successRecords,
|
|
59714
|
+
failedIds,
|
|
59715
|
+
errors
|
|
59716
|
+
};
|
|
59717
|
+
}
|
|
59718
|
+
function getErrorCode(error2) {
|
|
59719
|
+
if (error2 && typeof error2 === "object") {
|
|
59720
|
+
if ("name" in error2 && typeof error2.name === "string") {
|
|
59721
|
+
return error2.name;
|
|
59722
|
+
}
|
|
59723
|
+
if ("code" in error2 && typeof error2.code === "string") {
|
|
59724
|
+
return error2.code;
|
|
59725
|
+
}
|
|
59726
|
+
}
|
|
59727
|
+
return "TRANSACTION_FAILED";
|
|
59728
|
+
}
|
|
59729
|
+
var logger10;
|
|
59730
|
+
var init_chunking = __esm({
|
|
59731
|
+
"src/server/utils/chunking.ts"() {
|
|
59732
|
+
"use strict";
|
|
59733
|
+
init_shared();
|
|
59734
|
+
logger10 = createLogger({ service: "records-lambda" });
|
|
59735
|
+
__name(calculateChunks, "calculateChunks");
|
|
59736
|
+
__name(executeChunks, "executeChunks");
|
|
59737
|
+
__name(getErrorCode, "getErrorCode");
|
|
59738
|
+
}
|
|
59739
|
+
});
|
|
59740
|
+
|
|
59741
|
+
// src/server/utils/timestamps.ts
|
|
59742
|
+
var timestamps_exports = {};
|
|
59743
|
+
__export(timestamps_exports, {
|
|
59744
|
+
addCreateTimestamps: () => addCreateTimestamps,
|
|
59745
|
+
addUpdateTimestamp: () => addUpdateTimestamp,
|
|
59746
|
+
getTimestampFields: () => getTimestampFields
|
|
59747
|
+
});
|
|
59748
|
+
function getTimestampFields() {
|
|
59749
|
+
const shadowConfig = getShadowConfig();
|
|
59750
|
+
return {
|
|
59751
|
+
createdAt: shadowConfig.createdAtField,
|
|
59752
|
+
updatedAt: shadowConfig.updatedAtField
|
|
59753
|
+
};
|
|
59754
|
+
}
|
|
59755
|
+
function addCreateTimestamps(data) {
|
|
59756
|
+
const timestampFields = getTimestampFields();
|
|
59757
|
+
if (!timestampFields) {
|
|
59758
|
+
return data;
|
|
59759
|
+
}
|
|
59760
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
59761
|
+
return {
|
|
59762
|
+
[timestampFields.createdAt]: now,
|
|
59763
|
+
[timestampFields.updatedAt]: now,
|
|
59764
|
+
...data
|
|
59765
|
+
};
|
|
59766
|
+
}
|
|
59767
|
+
function addUpdateTimestamp(data) {
|
|
59768
|
+
const timestampFields = getTimestampFields();
|
|
59769
|
+
if (!timestampFields) {
|
|
59770
|
+
return data;
|
|
59771
|
+
}
|
|
59772
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
59773
|
+
return {
|
|
59774
|
+
[timestampFields.updatedAt]: now,
|
|
59775
|
+
...data
|
|
59776
|
+
};
|
|
59777
|
+
}
|
|
59778
|
+
var init_timestamps = __esm({
|
|
59779
|
+
"src/server/utils/timestamps.ts"() {
|
|
59780
|
+
"use strict";
|
|
59781
|
+
init_index2();
|
|
59782
|
+
__name(getTimestampFields, "getTimestampFields");
|
|
59783
|
+
__name(addCreateTimestamps, "addCreateTimestamps");
|
|
59784
|
+
__name(addUpdateTimestamp, "addUpdateTimestamp");
|
|
59785
|
+
}
|
|
59786
|
+
});
|
|
59787
|
+
|
|
59788
59788
|
// src/server/operations/updateMany.ts
|
|
59789
59789
|
var updateMany_exports = {};
|
|
59790
59790
|
__export(updateMany_exports, {
|
|
@@ -59835,7 +59835,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
59835
59835
|
const upsert = options?.upsert ?? false;
|
|
59836
59836
|
const startTime = Date.now();
|
|
59837
59837
|
const costTracker = new CostTracker();
|
|
59838
|
-
|
|
59838
|
+
logger11.debug("Executing updateMany", {
|
|
59839
59839
|
requestId,
|
|
59840
59840
|
resource,
|
|
59841
59841
|
upsert
|
|
@@ -59843,13 +59843,13 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
59843
59843
|
let ids;
|
|
59844
59844
|
if ("ids" in params) {
|
|
59845
59845
|
ids = params.ids;
|
|
59846
|
-
|
|
59846
|
+
logger11.debug("Executing updateMany with ids", {
|
|
59847
59847
|
requestId,
|
|
59848
59848
|
resource,
|
|
59849
59849
|
count: ids.length
|
|
59850
59850
|
});
|
|
59851
59851
|
} else {
|
|
59852
|
-
|
|
59852
|
+
logger11.debug("Executing updateMany with filter", {
|
|
59853
59853
|
requestId,
|
|
59854
59854
|
resource,
|
|
59855
59855
|
filter: params.filter
|
|
@@ -59857,7 +59857,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
59857
59857
|
const { handleFind: handleFind2 } = await Promise.resolve().then(() => (init_find(), find_exports));
|
|
59858
59858
|
const findResult = await handleFind2(resource, { filter: params.filter }, requestId);
|
|
59859
59859
|
ids = findResult.items.map((item) => item.id);
|
|
59860
|
-
|
|
59860
|
+
logger11.debug("Found records with filter", {
|
|
59861
59861
|
requestId,
|
|
59862
59862
|
resource,
|
|
59863
59863
|
count: ids.length
|
|
@@ -59866,7 +59866,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
59866
59866
|
if (upsert) {
|
|
59867
59867
|
const newId = ulid2();
|
|
59868
59868
|
ids = [newId];
|
|
59869
|
-
|
|
59869
|
+
logger11.info("Creating new record with filter (upsert: true)", {
|
|
59870
59870
|
requestId,
|
|
59871
59871
|
resource,
|
|
59872
59872
|
newId,
|
|
@@ -59902,7 +59902,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
59902
59902
|
}));
|
|
59903
59903
|
const batchGetResult = await executeDynamoDBOperation(
|
|
59904
59904
|
() => dbClient2.send(
|
|
59905
|
-
new
|
|
59905
|
+
new import_lib_dynamodb6.BatchGetCommand({
|
|
59906
59906
|
RequestItems: {
|
|
59907
59907
|
[tableName]: {
|
|
59908
59908
|
Keys: keys,
|
|
@@ -59930,7 +59930,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
59930
59930
|
);
|
|
59931
59931
|
const notFoundIds = ids.filter((id) => !existingIds.has(id));
|
|
59932
59932
|
if (!upsert && notFoundIds.length > 0) {
|
|
59933
|
-
|
|
59933
|
+
logger11.warn("Records not found (upsert: false)", {
|
|
59934
59934
|
requestId,
|
|
59935
59935
|
resource,
|
|
59936
59936
|
notFoundCount: notFoundIds.length,
|
|
@@ -59939,7 +59939,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
59939
59939
|
});
|
|
59940
59940
|
}
|
|
59941
59941
|
if (upsert && notFoundIds.length > 0) {
|
|
59942
|
-
|
|
59942
|
+
logger11.info("Creating new records (upsert: true)", {
|
|
59943
59943
|
requestId,
|
|
59944
59944
|
resource,
|
|
59945
59945
|
notFoundCount: notFoundIds.length,
|
|
@@ -59977,7 +59977,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
59977
59977
|
const failedId = existingData.id || "unknown-id";
|
|
59978
59978
|
const errorMessage = error2 instanceof Error ? error2.message : "Unknown preparation error";
|
|
59979
59979
|
const errorCode = getPreparationErrorCode(error2);
|
|
59980
|
-
|
|
59980
|
+
logger11.error("Failed to prepare record for update", {
|
|
59981
59981
|
requestId,
|
|
59982
59982
|
recordId: failedId,
|
|
59983
59983
|
error: errorMessage,
|
|
@@ -60017,7 +60017,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
60017
60017
|
} catch (error2) {
|
|
60018
60018
|
const errorMessage = error2 instanceof Error ? error2.message : "Unknown preparation error";
|
|
60019
60019
|
const errorCode = getPreparationErrorCode(error2);
|
|
60020
|
-
|
|
60020
|
+
logger11.error("Failed to prepare new record for upsert", {
|
|
60021
60021
|
requestId,
|
|
60022
60022
|
recordId: id,
|
|
60023
60023
|
error: errorMessage,
|
|
@@ -60088,7 +60088,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
60088
60088
|
}
|
|
60089
60089
|
const result = await executeDynamoDBOperation(
|
|
60090
60090
|
() => dbClient2.send(
|
|
60091
|
-
new
|
|
60091
|
+
new import_lib_dynamodb6.TransactWriteCommand({
|
|
60092
60092
|
TransactItems: transactItems,
|
|
60093
60093
|
ReturnConsumedCapacity: "TOTAL"
|
|
60094
60094
|
})
|
|
@@ -60230,11 +60230,11 @@ function getPreparationErrorCode(error2) {
|
|
|
60230
60230
|
}
|
|
60231
60231
|
return "VALIDATION_ERROR" /* VALIDATION_ERROR */;
|
|
60232
60232
|
}
|
|
60233
|
-
var
|
|
60233
|
+
var import_lib_dynamodb6, logger11;
|
|
60234
60234
|
var init_updateMany = __esm({
|
|
60235
60235
|
"src/server/operations/updateMany.ts"() {
|
|
60236
60236
|
"use strict";
|
|
60237
|
-
|
|
60237
|
+
import_lib_dynamodb6 = __toESM(require_dist_cjs81(), 1);
|
|
60238
60238
|
init_shared();
|
|
60239
60239
|
init_shadow();
|
|
60240
60240
|
init_shadow();
|
|
@@ -60243,7 +60243,7 @@ var init_updateMany = __esm({
|
|
|
60243
60243
|
init_cost_tracker();
|
|
60244
60244
|
init_dynamodb3();
|
|
60245
60245
|
init_timestamps();
|
|
60246
|
-
|
|
60246
|
+
logger11 = createLogger({ service: "records-lambda" });
|
|
60247
60247
|
__name(expandDotNotation, "expandDotNotation");
|
|
60248
60248
|
__name(applyJsonMergePatch, "applyJsonMergePatch");
|
|
60249
60249
|
__name(handleUpdateMany, "handleUpdateMany");
|
|
@@ -60262,15 +60262,88 @@ var import_client_s3 = __toESM(require_dist_cjs74(), 1);
|
|
|
60262
60262
|
var import_client_ssm2 = __toESM(require_dist_cjs75(), 1);
|
|
60263
60263
|
init_shared();
|
|
60264
60264
|
|
|
60265
|
+
// src/server/operations/findMany.ts
|
|
60266
|
+
var import_lib_dynamodb5 = __toESM(require_dist_cjs81(), 1);
|
|
60267
|
+
init_shared();
|
|
60268
|
+
init_shadow();
|
|
60269
|
+
init_dynamodb3();
|
|
60270
|
+
init_find();
|
|
60271
|
+
var logger8 = createLogger({ service: "records-lambda" });
|
|
60272
|
+
async function handleFindMany(resource, params, requestId) {
|
|
60273
|
+
if ("ids" in params) {
|
|
60274
|
+
const { ids } = params;
|
|
60275
|
+
logger8.debug("Executing findMany by ids", {
|
|
60276
|
+
requestId,
|
|
60277
|
+
resource,
|
|
60278
|
+
count: ids.length
|
|
60279
|
+
});
|
|
60280
|
+
if (ids.length === 0) {
|
|
60281
|
+
return [];
|
|
60282
|
+
}
|
|
60283
|
+
const dbClient2 = getDBClient();
|
|
60284
|
+
const tableName = getTableName();
|
|
60285
|
+
const keys = ids.map((id) => ({
|
|
60286
|
+
PK: resource,
|
|
60287
|
+
SK: generateMainRecordSK2(id)
|
|
60288
|
+
}));
|
|
60289
|
+
const result = await executeDynamoDBOperation(
|
|
60290
|
+
() => dbClient2.send(
|
|
60291
|
+
new import_lib_dynamodb5.BatchGetCommand({
|
|
60292
|
+
RequestItems: {
|
|
60293
|
+
[tableName]: {
|
|
60294
|
+
Keys: keys,
|
|
60295
|
+
ConsistentRead: true
|
|
60296
|
+
}
|
|
60297
|
+
}
|
|
60298
|
+
})
|
|
60299
|
+
),
|
|
60300
|
+
"BatchGetItem"
|
|
60301
|
+
);
|
|
60302
|
+
const items = result.Responses?.[tableName] || [];
|
|
60303
|
+
const records = items.map((item) => extractCleanRecord(item));
|
|
60304
|
+
logger8.info("findMany by ids succeeded", {
|
|
60305
|
+
requestId,
|
|
60306
|
+
resource,
|
|
60307
|
+
requested: ids.length,
|
|
60308
|
+
found: records.length
|
|
60309
|
+
});
|
|
60310
|
+
return records;
|
|
60311
|
+
}
|
|
60312
|
+
if ("filter" in params) {
|
|
60313
|
+
const { filter } = params;
|
|
60314
|
+
logger8.debug("Executing findMany by filter", {
|
|
60315
|
+
requestId,
|
|
60316
|
+
resource,
|
|
60317
|
+
filter
|
|
60318
|
+
});
|
|
60319
|
+
const findResult = await handleFind(
|
|
60320
|
+
resource,
|
|
60321
|
+
{
|
|
60322
|
+
filter
|
|
60323
|
+
},
|
|
60324
|
+
requestId
|
|
60325
|
+
);
|
|
60326
|
+
logger8.info("findMany by filter succeeded", {
|
|
60327
|
+
requestId,
|
|
60328
|
+
resource,
|
|
60329
|
+
filter,
|
|
60330
|
+
found: findResult.items.length
|
|
60331
|
+
});
|
|
60332
|
+
return findResult.items;
|
|
60333
|
+
}
|
|
60334
|
+
throw new Error("findMany requires either ids or filter");
|
|
60335
|
+
}
|
|
60336
|
+
__name(handleFindMany, "handleFindMany");
|
|
60337
|
+
|
|
60265
60338
|
// src/server/operations/updateOne.ts
|
|
60266
60339
|
init_shared();
|
|
60267
|
-
var
|
|
60340
|
+
var logger12 = createLogger({ service: "records-lambda" });
|
|
60268
60341
|
async function handleUpdateOne(resource, params, requestId) {
|
|
60269
60342
|
const { data: patchData, options } = params;
|
|
60270
60343
|
const { handleUpdateMany: handleUpdateMany2 } = await Promise.resolve().then(() => (init_updateMany(), updateMany_exports));
|
|
60271
60344
|
if ("id" in params) {
|
|
60272
60345
|
const targetId = params.id;
|
|
60273
|
-
|
|
60346
|
+
logger12.debug("Executing updateOne with id", {
|
|
60274
60347
|
requestId,
|
|
60275
60348
|
resource,
|
|
60276
60349
|
id: targetId,
|
|
@@ -60309,7 +60382,7 @@ async function handleUpdateOne(resource, params, requestId) {
|
|
|
60309
60382
|
consumedCapacity: updateManyResult.consumedCapacity
|
|
60310
60383
|
};
|
|
60311
60384
|
} else {
|
|
60312
|
-
|
|
60385
|
+
logger12.debug("Executing updateOne with filter", {
|
|
60313
60386
|
requestId,
|
|
60314
60387
|
resource,
|
|
60315
60388
|
filter: params.filter,
|
|
@@ -60357,29 +60430,35 @@ __name(handleUpdateOne, "handleUpdateOne");
|
|
|
60357
60430
|
|
|
60358
60431
|
// src/server/media/magicBytes.ts
|
|
60359
60432
|
var SIGNATURES = {
|
|
60360
|
-
"image/jpeg": [{ bytes: [255, 216, 255] }],
|
|
60361
|
-
"image/png": [{ bytes: [137, 80, 78, 71, 13, 10, 26, 10] }],
|
|
60433
|
+
"image/jpeg": [[{ bytes: [255, 216, 255] }]],
|
|
60434
|
+
"image/png": [[{ bytes: [137, 80, 78, 71, 13, 10, 26, 10] }]],
|
|
60362
60435
|
"image/gif": [
|
|
60363
|
-
{ bytes: [71, 73, 70, 56, 55, 97] },
|
|
60364
|
-
|
|
60436
|
+
[{ bytes: [71, 73, 70, 56, 55, 97] }],
|
|
60437
|
+
// GIF87a
|
|
60438
|
+
[{ bytes: [71, 73, 70, 56, 57, 97] }]
|
|
60439
|
+
// GIF89a
|
|
60365
60440
|
],
|
|
60366
60441
|
"image/webp": [
|
|
60367
|
-
|
|
60368
|
-
|
|
60369
|
-
|
|
60370
|
-
|
|
60442
|
+
[
|
|
60443
|
+
{ bytes: [82, 73, 70, 70] },
|
|
60444
|
+
// "RIFF"
|
|
60445
|
+
{ bytes: [87, 69, 66, 80], offset: 8 }
|
|
60446
|
+
// "WEBP"
|
|
60447
|
+
]
|
|
60371
60448
|
]
|
|
60372
60449
|
};
|
|
60450
|
+
function matchesCondition(sig, buffer) {
|
|
60451
|
+
const offset = sig.offset ?? 0;
|
|
60452
|
+
if (buffer.length < offset + sig.bytes.length) return false;
|
|
60453
|
+
return sig.bytes.every((byte, i4) => buffer[offset + i4] === byte);
|
|
60454
|
+
}
|
|
60455
|
+
__name(matchesCondition, "matchesCondition");
|
|
60373
60456
|
function verifyMagicBytes(contentType, buffer) {
|
|
60374
|
-
const
|
|
60375
|
-
if (!
|
|
60457
|
+
const candidates = SIGNATURES[contentType];
|
|
60458
|
+
if (!candidates) {
|
|
60376
60459
|
return true;
|
|
60377
60460
|
}
|
|
60378
|
-
return
|
|
60379
|
-
const offset = sig.offset ?? 0;
|
|
60380
|
-
if (buffer.length < offset + sig.bytes.length) return false;
|
|
60381
|
-
return sig.bytes.every((byte, i4) => buffer[offset + i4] === byte);
|
|
60382
|
-
});
|
|
60461
|
+
return candidates.some((conditions) => conditions.every((sig) => matchesCondition(sig, buffer)));
|
|
60383
60462
|
}
|
|
60384
60463
|
__name(verifyMagicBytes, "verifyMagicBytes");
|
|
60385
60464
|
function isProcessableImage(contentType) {
|
|
@@ -60387,6 +60466,36 @@ function isProcessableImage(contentType) {
|
|
|
60387
60466
|
}
|
|
60388
60467
|
__name(isProcessableImage, "isProcessableImage");
|
|
60389
60468
|
|
|
60469
|
+
// src/server/media/metadata.ts
|
|
60470
|
+
var RESERVED_METADATA_KEYS = /* @__PURE__ */ new Set(["original-filename"]);
|
|
60471
|
+
function extractAppMetadata(metadata) {
|
|
60472
|
+
const result = {};
|
|
60473
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
60474
|
+
if (!RESERVED_METADATA_KEYS.has(key)) {
|
|
60475
|
+
result[key] = value;
|
|
60476
|
+
}
|
|
60477
|
+
}
|
|
60478
|
+
return result;
|
|
60479
|
+
}
|
|
60480
|
+
__name(extractAppMetadata, "extractAppMetadata");
|
|
60481
|
+
function decodeOriginalFilename(raw) {
|
|
60482
|
+
if (!raw) return void 0;
|
|
60483
|
+
try {
|
|
60484
|
+
return decodeURIComponent(raw);
|
|
60485
|
+
} catch {
|
|
60486
|
+
return raw;
|
|
60487
|
+
}
|
|
60488
|
+
}
|
|
60489
|
+
__name(decodeOriginalFilename, "decodeOriginalFilename");
|
|
60490
|
+
function buildContentDisposition(decodedFilename) {
|
|
60491
|
+
if (!decodedFilename) return "attachment";
|
|
60492
|
+
const sanitized = decodedFilename.replace(/["\r\n]/g, "");
|
|
60493
|
+
const asciiFallback = sanitized.replace(/[^\x20-\x7e]/g, "").trim() || "download";
|
|
60494
|
+
const encoded = encodeURIComponent(sanitized);
|
|
60495
|
+
return `attachment; filename="${asciiFallback}"; filename*=UTF-8''${encoded}`;
|
|
60496
|
+
}
|
|
60497
|
+
__name(buildContentDisposition, "buildContentDisposition");
|
|
60498
|
+
|
|
60390
60499
|
// src/server/media/ssmParams.ts
|
|
60391
60500
|
var import_client_ssm = __toESM(require_dist_cjs75(), 1);
|
|
60392
60501
|
var cachedImagePolicy;
|
|
@@ -60418,30 +60527,23 @@ async function getImagePolicy(ssmClient2, paramName) {
|
|
|
60418
60527
|
__name(getImagePolicy, "getImagePolicy");
|
|
60419
60528
|
|
|
60420
60529
|
// src/server/media/process-handler.ts
|
|
60421
|
-
var
|
|
60530
|
+
var logger13 = createLogger({ service: "media-process-handler" });
|
|
60422
60531
|
var s3Client = new import_client_s3.S3Client({ region: process.env.AWS_REGION });
|
|
60423
60532
|
var ssmClient = new import_client_ssm2.SSMClient({ region: process.env.AWS_REGION });
|
|
60424
60533
|
var MAX_INPUT_PIXELS = 1e8;
|
|
60425
|
-
var
|
|
60426
|
-
function extractAppMetadata(metadata) {
|
|
60427
|
-
const result = {};
|
|
60428
|
-
for (const [key, value] of Object.entries(metadata)) {
|
|
60429
|
-
if (!RESERVED_METADATA_KEYS.has(key)) {
|
|
60430
|
-
result[key] = value;
|
|
60431
|
-
}
|
|
60432
|
-
}
|
|
60433
|
-
return result;
|
|
60434
|
-
}
|
|
60435
|
-
__name(extractAppMetadata, "extractAppMetadata");
|
|
60436
|
-
function sanitizeFilenameForHeader(filename) {
|
|
60437
|
-
return filename.replace(/["\r\n]/g, "");
|
|
60438
|
-
}
|
|
60439
|
-
__name(sanitizeFilenameForHeader, "sanitizeFilenameForHeader");
|
|
60534
|
+
var MAGIC_BYTES_CHECK_RANGE = 255;
|
|
60440
60535
|
async function streamToBuffer(body) {
|
|
60441
60536
|
const bytes = await body.transformToByteArray();
|
|
60442
60537
|
return Buffer.from(bytes);
|
|
60443
60538
|
}
|
|
60444
60539
|
__name(streamToBuffer, "streamToBuffer");
|
|
60540
|
+
async function getHeadBytes(bucket, key) {
|
|
60541
|
+
const result = await s3Client.send(
|
|
60542
|
+
new import_client_s3.GetObjectCommand({ Bucket: bucket, Key: key, Range: `bytes=0-${MAGIC_BYTES_CHECK_RANGE}` })
|
|
60543
|
+
);
|
|
60544
|
+
return streamToBuffer(result.Body);
|
|
60545
|
+
}
|
|
60546
|
+
__name(getHeadBytes, "getHeadBytes");
|
|
60445
60547
|
async function writeMediaRecord(fileId, fields, requestId) {
|
|
60446
60548
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
60447
60549
|
await handleUpdateOne(
|
|
@@ -60462,14 +60564,22 @@ async function processRecord(bucket, rawKey) {
|
|
|
60462
60564
|
const key = decodeURIComponent(rawKey.replace(/\+/g, " "));
|
|
60463
60565
|
const fileId = key.replace(/^raw\//, "");
|
|
60464
60566
|
const requestId = `s3-event-${fileId}`;
|
|
60567
|
+
const existing = await handleFindMany("media", { ids: [fileId] }, requestId);
|
|
60568
|
+
const existingRecord = existing[0];
|
|
60569
|
+
if (existingRecord?.status === "completed") {
|
|
60570
|
+
logger13.warn("Media already completed, ignoring re-upload to the same fileId", {
|
|
60571
|
+
requestId,
|
|
60572
|
+
fileId
|
|
60573
|
+
});
|
|
60574
|
+
return;
|
|
60575
|
+
}
|
|
60465
60576
|
const head = await s3Client.send(new import_client_s3.HeadObjectCommand({ Bucket: bucket, Key: key }));
|
|
60466
60577
|
const contentType = head.ContentType || "application/octet-stream";
|
|
60467
60578
|
const metadata = head.Metadata || {};
|
|
60468
|
-
const originalFilename = metadata["original-filename"];
|
|
60469
|
-
const
|
|
60470
|
-
|
|
60471
|
-
|
|
60472
|
-
logger12.warn("Content type does not match file signature", { requestId, fileId, contentType });
|
|
60579
|
+
const originalFilename = decodeOriginalFilename(metadata["original-filename"]);
|
|
60580
|
+
const headBytes = await getHeadBytes(bucket, key);
|
|
60581
|
+
if (!verifyMagicBytes(contentType, headBytes)) {
|
|
60582
|
+
logger13.warn("Content type does not match file signature", { requestId, fileId, contentType });
|
|
60473
60583
|
await writeMediaRecord(
|
|
60474
60584
|
fileId,
|
|
60475
60585
|
{
|
|
@@ -60489,6 +60599,8 @@ async function processRecord(bucket, rawKey) {
|
|
|
60489
60599
|
throw new Error("IMAGE_POLICY_PARAM environment variable is not set");
|
|
60490
60600
|
}
|
|
60491
60601
|
const imagePolicy = await getImagePolicy(ssmClient, imagePolicyParam);
|
|
60602
|
+
const getResult = await s3Client.send(new import_client_s3.GetObjectCommand({ Bucket: bucket, Key: key }));
|
|
60603
|
+
const buffer = await streamToBuffer(getResult.Body);
|
|
60492
60604
|
const image = (0, import_sharp.default)(buffer, { limitInputPixels: MAX_INPUT_PIXELS }).rotate();
|
|
60493
60605
|
const inputMeta = await image.metadata();
|
|
60494
60606
|
const maxDim = imagePolicy.masterMaxDimension;
|
|
@@ -60526,7 +60638,7 @@ async function processRecord(bucket, rawKey) {
|
|
|
60526
60638
|
CopySource: `${bucket}/${key}`,
|
|
60527
60639
|
MetadataDirective: "REPLACE",
|
|
60528
60640
|
ContentType: contentType,
|
|
60529
|
-
ContentDisposition:
|
|
60641
|
+
ContentDisposition: buildContentDisposition(originalFilename)
|
|
60530
60642
|
})
|
|
60531
60643
|
);
|
|
60532
60644
|
await writeMediaRecord(
|
|
@@ -60535,14 +60647,14 @@ async function processRecord(bucket, rawKey) {
|
|
|
60535
60647
|
status: "completed",
|
|
60536
60648
|
contentType,
|
|
60537
60649
|
outputContentType: contentType,
|
|
60538
|
-
size: head.ContentLength ??
|
|
60650
|
+
size: head.ContentLength ?? 0,
|
|
60539
60651
|
...originalFilename ? { originalFilename } : {},
|
|
60540
60652
|
...appMetadata
|
|
60541
60653
|
},
|
|
60542
60654
|
requestId
|
|
60543
60655
|
);
|
|
60544
60656
|
}
|
|
60545
|
-
|
|
60657
|
+
logger13.info("Media processed", { requestId, fileId, contentType });
|
|
60546
60658
|
}
|
|
60547
60659
|
__name(processRecord, "processRecord");
|
|
60548
60660
|
var handler = /* @__PURE__ */ __name(async (event) => {
|
|
@@ -60552,7 +60664,7 @@ var handler = /* @__PURE__ */ __name(async (event) => {
|
|
|
60552
60664
|
try {
|
|
60553
60665
|
await processRecord(bucket, key);
|
|
60554
60666
|
} catch (error2) {
|
|
60555
|
-
|
|
60667
|
+
logger13.error("Failed to process media", {
|
|
60556
60668
|
bucket,
|
|
60557
60669
|
key,
|
|
60558
60670
|
error: error2 instanceof Error ? error2.message : String(error2)
|