@exabugs/dynamodb-client 1.26.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/dist/__generated__/models/apiOperation.d.ts +1 -0
- package/dist/__generated__/models/apiOperation.d.ts.map +1 -1
- package/dist/__generated__/models/apiOperation.js +1 -0
- package/dist/__generated__/models/apiOperation.js.map +1 -1
- package/dist/__generated__/models/bulkOperationResult.d.ts +2 -0
- package/dist/__generated__/models/bulkOperationResult.d.ts.map +1 -1
- package/dist/__generated__/models/countParams.d.ts +31 -0
- package/dist/__generated__/models/countParams.d.ts.map +1 -0
- package/dist/__generated__/models/countParams.js +2 -0
- package/dist/__generated__/models/countParams.js.map +1 -0
- package/dist/__generated__/models/countResult.d.ts +37 -0
- package/dist/__generated__/models/countResult.d.ts.map +1 -0
- package/dist/__generated__/models/countResult.js +2 -0
- package/dist/__generated__/models/countResult.js.map +1 -0
- package/dist/__generated__/models/countResultConsumedCapacity.d.ts +35 -0
- package/dist/__generated__/models/countResultConsumedCapacity.d.ts.map +1 -0
- package/dist/__generated__/models/countResultConsumedCapacity.js +25 -0
- package/dist/__generated__/models/countResultConsumedCapacity.js.map +1 -0
- package/dist/__generated__/models/executeOperationBodyOp.d.ts +1 -0
- package/dist/__generated__/models/executeOperationBodyOp.d.ts.map +1 -1
- package/dist/__generated__/models/executeOperationBodyOp.js +1 -0
- package/dist/__generated__/models/executeOperationBodyOp.js.map +1 -1
- package/dist/__generated__/models/index.d.ts +3 -0
- package/dist/__generated__/models/index.d.ts.map +1 -1
- package/dist/__generated__/models/index.js +3 -0
- package/dist/__generated__/models/index.js.map +1 -1
- package/dist/client/Collection.d.ts +7 -0
- package/dist/client/Collection.d.ts.map +1 -1
- package/dist/client/Collection.js +20 -1
- package/dist/client/Collection.js.map +1 -1
- package/dist/scripts/repair-shadows.js +86 -42
- package/dist/scripts/repair-shadows.js.map +1 -1
- package/dist/scripts/utils/cliParser.d.ts +9 -22
- package/dist/scripts/utils/cliParser.d.ts.map +1 -1
- package/dist/scripts/utils/cliParser.js +14 -37
- package/dist/scripts/utils/cliParser.js.map +1 -1
- package/dist/scripts/utils/shadowAudit.d.ts +49 -0
- package/dist/scripts/utils/shadowAudit.d.ts.map +1 -0
- package/dist/scripts/utils/shadowAudit.js +84 -0
- package/dist/scripts/utils/shadowAudit.js.map +1 -0
- package/dist/scripts/utils/shadowRepair.d.ts +42 -0
- package/dist/scripts/utils/shadowRepair.d.ts.map +1 -0
- package/dist/scripts/utils/shadowRepair.js +110 -0
- package/dist/scripts/utils/shadowRepair.js.map +1 -0
- package/dist/server/handler.cjs +1005 -901
- package/dist/server/handler.cjs.map +4 -4
- package/dist/server/handler.js +2 -2
- package/dist/server/handler.js.map +1 -1
- package/dist/server/media-handler.cjs +2 -2
- package/dist/server/media-process-handler-dlq.cjs +19 -3
- package/dist/server/media-process-handler-dlq.cjs.map +2 -2
- package/dist/server/media-process-handler.cjs +19 -3
- package/dist/server/media-process-handler.cjs.map +2 -2
- package/dist/server/operations/count.d.ts +3 -0
- package/dist/server/operations/count.d.ts.map +1 -0
- package/dist/server/operations/count.js +81 -0
- package/dist/server/operations/count.js.map +1 -0
- package/dist/server/operations/deleteMany.d.ts.map +1 -1
- package/dist/server/operations/deleteMany.js +2 -1
- package/dist/server/operations/deleteMany.js.map +1 -1
- package/dist/server/operations/deleteOne.d.ts.map +1 -1
- package/dist/server/operations/deleteOne.js +3 -12
- package/dist/server/operations/deleteOne.js.map +1 -1
- package/dist/server/operations/find/keyCondition.d.ts +38 -0
- package/dist/server/operations/find/keyCondition.d.ts.map +1 -0
- package/dist/server/operations/find/keyCondition.js +184 -0
- package/dist/server/operations/find/keyCondition.js.map +1 -0
- package/dist/server/operations/find/shadowQuery.d.ts.map +1 -1
- package/dist/server/operations/find/shadowQuery.js +16 -143
- package/dist/server/operations/find/shadowQuery.js.map +1 -1
- package/dist/server/operations/find/utils.d.ts.map +1 -1
- package/dist/server/operations/find/utils.js +0 -5
- package/dist/server/operations/find/utils.js.map +1 -1
- package/dist/server/operations/insertMany.d.ts.map +1 -1
- package/dist/server/operations/insertMany.js +1 -4
- package/dist/server/operations/insertMany.js.map +1 -1
- package/dist/server/operations/insertOne.d.ts.map +1 -1
- package/dist/server/operations/insertOne.js +2 -6
- package/dist/server/operations/insertOne.js.map +1 -1
- package/dist/server/operations/operationDispatcher.d.ts.map +1 -1
- package/dist/server/operations/operationDispatcher.js +3 -0
- package/dist/server/operations/operationDispatcher.js.map +1 -1
- package/dist/server/operations/updateMany.d.ts.map +1 -1
- package/dist/server/operations/updateMany.js +6 -2
- package/dist/server/operations/updateMany.js.map +1 -1
- package/dist/server/operations/updateOne.d.ts.map +1 -1
- package/dist/server/operations/updateOne.js +10 -21
- package/dist/server/operations/updateOne.js.map +1 -1
- package/dist/server/types.d.ts +7 -1
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/utils/bulkError.d.ts +12 -0
- package/dist/server/utils/bulkError.d.ts.map +1 -0
- package/dist/server/utils/bulkError.js +21 -0
- package/dist/server/utils/bulkError.js.map +1 -0
- package/dist/server/utils/chunking.d.ts +9 -1
- package/dist/server/utils/chunking.d.ts.map +1 -1
- package/dist/server/utils/chunking.js +20 -3
- package/dist/server/utils/chunking.js.map +1 -1
- package/dist/server/utils/filter.d.ts +3 -105
- package/dist/server/utils/filter.d.ts.map +1 -1
- package/dist/server/utils/filter.js +14 -218
- package/dist/server/utils/filter.js.map +1 -1
- package/docs/README.md +9 -12
- package/package.json +1 -1
- package/dist/scripts/operations/bulkRecordRepair.d.ts +0 -17
- package/dist/scripts/operations/bulkRecordRepair.d.ts.map +0 -1
- package/dist/scripts/operations/bulkRecordRepair.js +0 -76
- package/dist/scripts/operations/bulkRecordRepair.js.map +0 -1
- package/dist/scripts/operations/singleRecordRepair.d.ts +0 -18
- package/dist/scripts/operations/singleRecordRepair.d.ts.map +0 -1
- package/dist/scripts/operations/singleRecordRepair.js +0 -46
- package/dist/scripts/operations/singleRecordRepair.js.map +0 -1
- package/dist/scripts/utils/awsUtils.d.ts +0 -15
- package/dist/scripts/utils/awsUtils.d.ts.map +0 -1
- package/dist/scripts/utils/awsUtils.js +0 -31
- package/dist/scripts/utils/awsUtils.js.map +0 -1
- package/dist/scripts/utils/clientFactory.d.ts +0 -22
- package/dist/scripts/utils/clientFactory.d.ts.map +0 -1
- package/dist/scripts/utils/clientFactory.js +0 -36
- package/dist/scripts/utils/clientFactory.js.map +0 -1
- package/dist/scripts/utils/repairUtils.d.ts +0 -58
- package/dist/scripts/utils/repairUtils.d.ts.map +0 -1
- package/dist/scripts/utils/repairUtils.js +0 -52
- package/dist/scripts/utils/repairUtils.js.map +0 -1
- package/dist/server/utils/ttl.d.ts +0 -17
- package/dist/server/utils/ttl.d.ts.map +0 -1
- package/dist/server/utils/ttl.js +0 -64
- package/dist/server/utils/ttl.js.map +0 -1
package/dist/server/handler.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// @exabugs/dynamodb-client v1.
|
|
2
|
-
// Built: 2026-11-
|
|
1
|
+
// @exabugs/dynamodb-client v1.27.0
|
|
2
|
+
// Built: 2026-11-15T08:17:35.832Z
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -2194,10 +2194,10 @@ var init_command = __esm({
|
|
|
2194
2194
|
this.middlewareStack.use(mw);
|
|
2195
2195
|
}
|
|
2196
2196
|
const stack = clientStack.concat(this.middlewareStack);
|
|
2197
|
-
const { logger:
|
|
2197
|
+
const { logger: logger26 } = configuration;
|
|
2198
2198
|
const additionalSmithyContext = additionalContext[import_types2.SMITHY_CONTEXT_KEY];
|
|
2199
2199
|
const handlerExecutionContext = {
|
|
2200
|
-
logger:
|
|
2200
|
+
logger: logger26,
|
|
2201
2201
|
clientName,
|
|
2202
2202
|
commandName,
|
|
2203
2203
|
inputFilterSensitiveLog,
|
|
@@ -4166,19 +4166,19 @@ var init_ProviderError = __esm({
|
|
|
4166
4166
|
name = "ProviderError";
|
|
4167
4167
|
tryNextLink;
|
|
4168
4168
|
constructor(message, options = true) {
|
|
4169
|
-
let
|
|
4169
|
+
let logger26;
|
|
4170
4170
|
let tryNextLink = true;
|
|
4171
4171
|
if (typeof options === "boolean") {
|
|
4172
|
-
|
|
4172
|
+
logger26 = void 0;
|
|
4173
4173
|
tryNextLink = options;
|
|
4174
4174
|
} else if (options != null && typeof options === "object") {
|
|
4175
|
-
|
|
4175
|
+
logger26 = options.logger;
|
|
4176
4176
|
tryNextLink = options.tryNextLink ?? true;
|
|
4177
4177
|
}
|
|
4178
4178
|
super(message);
|
|
4179
4179
|
this.tryNextLink = tryNextLink;
|
|
4180
4180
|
Object.setPrototypeOf(this, _ProviderError.prototype);
|
|
4181
|
-
|
|
4181
|
+
logger26?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
|
|
4182
4182
|
}
|
|
4183
4183
|
static from(error2, options = true) {
|
|
4184
4184
|
return Object.assign(new this(error2.message, options), error2);
|
|
@@ -4766,8 +4766,8 @@ var init_configLoader = __esm({
|
|
|
4766
4766
|
init_fromSharedConfigFiles();
|
|
4767
4767
|
init_fromStatic();
|
|
4768
4768
|
loadConfig = /* @__PURE__ */ __name(({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => {
|
|
4769
|
-
const { signingName, logger:
|
|
4770
|
-
const envOptions = { signingName, logger:
|
|
4769
|
+
const { signingName, logger: logger26 } = configuration;
|
|
4770
|
+
const envOptions = { signingName, logger: logger26 };
|
|
4771
4771
|
return memoize(chain(fromEnv(environmentVariableSelector, envOptions), fromSharedConfigFiles(configFileSelector, configuration), fromStatic(defaultValue)));
|
|
4772
4772
|
}, "loadConfig");
|
|
4773
4773
|
}
|
|
@@ -6490,7 +6490,7 @@ var init_resolveEndpoint = __esm({
|
|
|
6490
6490
|
init_types3();
|
|
6491
6491
|
init_utils();
|
|
6492
6492
|
resolveEndpoint = /* @__PURE__ */ __name((ruleSetObject, options) => {
|
|
6493
|
-
const { endpointParams, logger:
|
|
6493
|
+
const { endpointParams, logger: logger26 } = options;
|
|
6494
6494
|
const { parameters, rules } = ruleSetObject;
|
|
6495
6495
|
options.logger?.debug?.(`${debugId} Initial EndpointParams: ${toDebugString(endpointParams)}`);
|
|
6496
6496
|
for (const paramKey in parameters) {
|
|
@@ -6507,7 +6507,7 @@ var init_resolveEndpoint = __esm({
|
|
|
6507
6507
|
throw new EndpointError(`Missing required parameter: '${paramKey}'`);
|
|
6508
6508
|
}
|
|
6509
6509
|
}
|
|
6510
|
-
const endpoint = evaluateRules(rules, { endpointParams, logger:
|
|
6510
|
+
const endpoint = evaluateRules(rules, { endpointParams, logger: logger26, referenceRecord: {} });
|
|
6511
6511
|
options.logger?.debug?.(`${debugId} Resolved endpoint: ${toDebugString(endpoint)}`);
|
|
6512
6512
|
return endpoint;
|
|
6513
6513
|
}, "resolveEndpoint");
|
|
@@ -6947,7 +6947,7 @@ var init_ByteArrayCollector = __esm({
|
|
|
6947
6947
|
});
|
|
6948
6948
|
|
|
6949
6949
|
// node_modules/@smithy/core/dist-es/submodules/serde/util-stream/createBufferedReadable.browser.js
|
|
6950
|
-
function createBufferedReadableStream(upstream, size,
|
|
6950
|
+
function createBufferedReadableStream(upstream, size, logger26) {
|
|
6951
6951
|
const reader = upstream.getReader();
|
|
6952
6952
|
let streamBufferingLoggedWarning = false;
|
|
6953
6953
|
let bytesSeen = 0;
|
|
@@ -6985,7 +6985,7 @@ function createBufferedReadableStream(upstream, size, logger27) {
|
|
|
6985
6985
|
const newSize = merge(buffers, mode, chunk);
|
|
6986
6986
|
if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
|
|
6987
6987
|
streamBufferingLoggedWarning = true;
|
|
6988
|
-
|
|
6988
|
+
logger26?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
|
|
6989
6989
|
}
|
|
6990
6990
|
if (newSize >= size) {
|
|
6991
6991
|
controller.enqueue(flush(buffers, mode));
|
|
@@ -7049,9 +7049,9 @@ var init_createBufferedReadable_browser = __esm({
|
|
|
7049
7049
|
});
|
|
7050
7050
|
|
|
7051
7051
|
// node_modules/@smithy/core/dist-es/submodules/serde/util-stream/createBufferedReadable.js
|
|
7052
|
-
function createBufferedReadable(upstream, size,
|
|
7052
|
+
function createBufferedReadable(upstream, size, logger26) {
|
|
7053
7053
|
if (isReadableStream(upstream)) {
|
|
7054
|
-
return createBufferedReadableStream(upstream, size,
|
|
7054
|
+
return createBufferedReadableStream(upstream, size, logger26);
|
|
7055
7055
|
}
|
|
7056
7056
|
const downstream = new import_node_stream3.Readable({ read() {
|
|
7057
7057
|
} });
|
|
@@ -7084,7 +7084,7 @@ function createBufferedReadable(upstream, size, logger27) {
|
|
|
7084
7084
|
const newSize = merge(buffers, mode, chunk);
|
|
7085
7085
|
if (!streamBufferingLoggedWarning && bytesSeen > size * 2) {
|
|
7086
7086
|
streamBufferingLoggedWarning = true;
|
|
7087
|
-
|
|
7087
|
+
logger26?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size}, automatically buffering.`);
|
|
7088
7088
|
}
|
|
7089
7089
|
if (newSize >= size) {
|
|
7090
7090
|
downstream.push(flush(buffers, mode));
|
|
@@ -12769,7 +12769,7 @@ var init_constants5 = __esm({
|
|
|
12769
12769
|
});
|
|
12770
12770
|
|
|
12771
12771
|
// node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/parseRetryAfterHeader.js
|
|
12772
|
-
function parseRetryAfterHeader(response,
|
|
12772
|
+
function parseRetryAfterHeader(response, logger26) {
|
|
12773
12773
|
if (!HttpResponse.isInstance(response)) {
|
|
12774
12774
|
return;
|
|
12775
12775
|
}
|
|
@@ -12786,8 +12786,8 @@ function parseRetryAfterHeader(response, logger27) {
|
|
|
12786
12786
|
const date2 = parseRfc7231DateTime(retryAfter);
|
|
12787
12787
|
retryAfterSeconds = (date2.getTime() - Date.now()) / 1e3;
|
|
12788
12788
|
} catch (e5) {
|
|
12789
|
-
|
|
12790
|
-
|
|
12789
|
+
logger26?.trace?.("Failed to parse retry-after header");
|
|
12790
|
+
logger26?.trace?.(e5);
|
|
12791
12791
|
}
|
|
12792
12792
|
} else if (retryAfter.match(/ GMT, ((\d+)|(\d+\.\d+))$/)) {
|
|
12793
12793
|
retryAfterSeconds = Number(retryAfter.match(/ GMT, ([\d.]+)$/)?.[1]);
|
|
@@ -12804,15 +12804,15 @@ function parseRetryAfterHeader(response, logger27) {
|
|
|
12804
12804
|
const v = response.headers[header];
|
|
12805
12805
|
const backoffMilliseconds = Number(v);
|
|
12806
12806
|
if (isNaN(backoffMilliseconds)) {
|
|
12807
|
-
|
|
12807
|
+
logger26?.trace?.(`Failed to parse x-amz-retry-after=${v}`);
|
|
12808
12808
|
return;
|
|
12809
12809
|
}
|
|
12810
12810
|
return new Date(Date.now() + backoffMilliseconds);
|
|
12811
12811
|
}
|
|
12812
12812
|
}
|
|
12813
12813
|
}
|
|
12814
|
-
function getRetryAfterHint(response,
|
|
12815
|
-
return parseRetryAfterHeader(response,
|
|
12814
|
+
function getRetryAfterHint(response, logger26) {
|
|
12815
|
+
return parseRetryAfterHeader(response, logger26);
|
|
12816
12816
|
}
|
|
12817
12817
|
var init_parseRetryAfterHeader = __esm({
|
|
12818
12818
|
"node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/parseRetryAfterHeader.js"() {
|
|
@@ -12924,12 +12924,12 @@ var init_retryMiddleware = __esm({
|
|
|
12924
12924
|
__name(bindRetryMiddleware, "bindRetryMiddleware");
|
|
12925
12925
|
cooldown = /* @__PURE__ */ __name((ms) => new Promise((resolve) => setTimeout(resolve, ms)), "cooldown");
|
|
12926
12926
|
isRetryStrategyV2 = /* @__PURE__ */ __name((retryStrategy) => typeof retryStrategy.acquireInitialRetryToken !== "undefined" && typeof retryStrategy.refreshRetryTokenForRetry !== "undefined" && typeof retryStrategy.recordSuccess !== "undefined", "isRetryStrategyV2");
|
|
12927
|
-
getRetryErrorInfo = /* @__PURE__ */ __name((error2,
|
|
12927
|
+
getRetryErrorInfo = /* @__PURE__ */ __name((error2, logger26) => {
|
|
12928
12928
|
const errorInfo = {
|
|
12929
12929
|
error: error2,
|
|
12930
12930
|
errorType: getRetryErrorType(error2)
|
|
12931
12931
|
};
|
|
12932
|
-
const retryAfterHint = parseRetryAfterHeader(error2.$response,
|
|
12932
|
+
const retryAfterHint = parseRetryAfterHeader(error2.$response, logger26);
|
|
12933
12933
|
if (retryAfterHint) {
|
|
12934
12934
|
errorInfo.retryAfterHint = retryAfterHint;
|
|
12935
12935
|
}
|
|
@@ -13804,12 +13804,12 @@ var init_loggerMiddleware = __esm({
|
|
|
13804
13804
|
loggerMiddleware = /* @__PURE__ */ __name(() => (next, context) => async (args) => {
|
|
13805
13805
|
try {
|
|
13806
13806
|
const response = await next(args);
|
|
13807
|
-
const { clientName, commandName, logger:
|
|
13807
|
+
const { clientName, commandName, logger: logger26, dynamoDbDocumentClientOptions = {} } = context;
|
|
13808
13808
|
const { overrideInputFilterSensitiveLog, overrideOutputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
|
|
13809
13809
|
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
|
|
13810
13810
|
const outputFilterSensitiveLog = overrideOutputFilterSensitiveLog ?? context.outputFilterSensitiveLog;
|
|
13811
13811
|
const { $metadata, ...outputWithoutMetadata } = response.output;
|
|
13812
|
-
|
|
13812
|
+
logger26?.info?.({
|
|
13813
13813
|
clientName,
|
|
13814
13814
|
commandName,
|
|
13815
13815
|
input: inputFilterSensitiveLog(args.input),
|
|
@@ -13818,10 +13818,10 @@ var init_loggerMiddleware = __esm({
|
|
|
13818
13818
|
});
|
|
13819
13819
|
return response;
|
|
13820
13820
|
} catch (error2) {
|
|
13821
|
-
const { clientName, commandName, logger:
|
|
13821
|
+
const { clientName, commandName, logger: logger26, dynamoDbDocumentClientOptions = {} } = context;
|
|
13822
13822
|
const { overrideInputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
|
|
13823
13823
|
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
|
|
13824
|
-
|
|
13824
|
+
logger26?.error?.({
|
|
13825
13825
|
clientName,
|
|
13826
13826
|
commandName,
|
|
13827
13827
|
input: inputFilterSensitiveLog(args.input),
|
|
@@ -14583,11 +14583,11 @@ function resolveUserAgentConfig(input) {
|
|
|
14583
14583
|
userAgentAppId: /* @__PURE__ */ __name(async () => {
|
|
14584
14584
|
const appId = await normalizedAppIdProvider();
|
|
14585
14585
|
if (!isValidUserAgentAppId(appId)) {
|
|
14586
|
-
const
|
|
14586
|
+
const logger26 = input.logger?.constructor?.name === "NoOpLogger" || !input.logger ? console : input.logger;
|
|
14587
14587
|
if (typeof appId !== "string") {
|
|
14588
|
-
|
|
14588
|
+
logger26?.warn("userAgentAppId must be a string or undefined.");
|
|
14589
14589
|
} else if (appId.length > 50) {
|
|
14590
|
-
|
|
14590
|
+
logger26?.warn("The provided userAgentAppId exceeds the maximum length of 50 characters.");
|
|
14591
14591
|
}
|
|
14592
14592
|
}
|
|
14593
14593
|
return appId;
|
|
@@ -19526,7 +19526,7 @@ var require_dist_cjs6 = __commonJS({
|
|
|
19526
19526
|
var CMDS_IP = "169.254.170.2";
|
|
19527
19527
|
var GREENGRASS_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1"]);
|
|
19528
19528
|
var GREENGRASS_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
19529
|
-
var getCmdsUri = /* @__PURE__ */ __name(async ({ logger:
|
|
19529
|
+
var getCmdsUri = /* @__PURE__ */ __name(async ({ logger: logger26 }) => {
|
|
19530
19530
|
if (process.env[ENV_CMDS_RELATIVE_URI]) {
|
|
19531
19531
|
return {
|
|
19532
19532
|
hostname: CMDS_IP,
|
|
@@ -19538,18 +19538,18 @@ var require_dist_cjs6 = __commonJS({
|
|
|
19538
19538
|
try {
|
|
19539
19539
|
parsed = new URL(process.env[ENV_CMDS_FULL_URI]);
|
|
19540
19540
|
} catch {
|
|
19541
|
-
throw new CredentialsProviderError2(`${process.env[ENV_CMDS_FULL_URI]} is not a valid container metadata service URL`, { tryNextLink: false, logger:
|
|
19541
|
+
throw new CredentialsProviderError2(`${process.env[ENV_CMDS_FULL_URI]} is not a valid container metadata service URL`, { tryNextLink: false, logger: logger26 });
|
|
19542
19542
|
}
|
|
19543
19543
|
if (!parsed.hostname || !GREENGRASS_HOSTS.has(parsed.hostname)) {
|
|
19544
19544
|
throw new CredentialsProviderError2(`${parsed.hostname} is not a valid container metadata service hostname`, {
|
|
19545
19545
|
tryNextLink: false,
|
|
19546
|
-
logger:
|
|
19546
|
+
logger: logger26
|
|
19547
19547
|
});
|
|
19548
19548
|
}
|
|
19549
19549
|
if (!parsed.protocol || !GREENGRASS_PROTOCOLS.has(parsed.protocol)) {
|
|
19550
19550
|
throw new CredentialsProviderError2(`${parsed.protocol} is not a valid container metadata service protocol`, {
|
|
19551
19551
|
tryNextLink: false,
|
|
19552
|
-
logger:
|
|
19552
|
+
logger: logger26
|
|
19553
19553
|
});
|
|
19554
19554
|
}
|
|
19555
19555
|
return {
|
|
@@ -19561,7 +19561,7 @@ var require_dist_cjs6 = __commonJS({
|
|
|
19561
19561
|
}
|
|
19562
19562
|
throw new CredentialsProviderError2(`The container metadata credential provider cannot be used unless the ${ENV_CMDS_RELATIVE_URI} or ${ENV_CMDS_FULL_URI} environment variable is set`, {
|
|
19563
19563
|
tryNextLink: false,
|
|
19564
|
-
logger:
|
|
19564
|
+
logger: logger26
|
|
19565
19565
|
});
|
|
19566
19566
|
}, "getCmdsUri");
|
|
19567
19567
|
var InstanceMetadataV1FallbackError = class _InstanceMetadataV1FallbackError extends CredentialsProviderError2 {
|
|
@@ -19616,10 +19616,10 @@ var require_dist_cjs6 = __commonJS({
|
|
|
19616
19616
|
var STATIC_STABILITY_REFRESH_INTERVAL_SECONDS = 5 * 60;
|
|
19617
19617
|
var STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS = 5 * 60;
|
|
19618
19618
|
var STATIC_STABILITY_DOC_URL = "https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html";
|
|
19619
|
-
var getExtendedInstanceMetadataCredentials = /* @__PURE__ */ __name((credentials,
|
|
19619
|
+
var getExtendedInstanceMetadataCredentials = /* @__PURE__ */ __name((credentials, logger26) => {
|
|
19620
19620
|
const refreshInterval = STATIC_STABILITY_REFRESH_INTERVAL_SECONDS + Math.floor(Math.random() * STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS);
|
|
19621
19621
|
const newExpiration = new Date(Date.now() + refreshInterval * 1e3);
|
|
19622
|
-
|
|
19622
|
+
logger26.warn(`Attempting credential expiration extension due to a credential service availability issue. A refresh of these credentials will be attempted after ${new Date(newExpiration)}.
|
|
19623
19623
|
For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
19624
19624
|
const originalExpiration = credentials.originalExpiration ?? credentials.expiration;
|
|
19625
19625
|
return {
|
|
@@ -19629,19 +19629,19 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
|
19629
19629
|
};
|
|
19630
19630
|
}, "getExtendedInstanceMetadataCredentials");
|
|
19631
19631
|
var staticStabilityProvider = /* @__PURE__ */ __name((provider, options = {}) => {
|
|
19632
|
-
const
|
|
19632
|
+
const logger26 = options?.logger || console;
|
|
19633
19633
|
let pastCredentials;
|
|
19634
19634
|
return async () => {
|
|
19635
19635
|
let credentials;
|
|
19636
19636
|
try {
|
|
19637
19637
|
credentials = await provider();
|
|
19638
19638
|
if (credentials.expiration && credentials.expiration.getTime() < Date.now()) {
|
|
19639
|
-
credentials = getExtendedInstanceMetadataCredentials(credentials,
|
|
19639
|
+
credentials = getExtendedInstanceMetadataCredentials(credentials, logger26);
|
|
19640
19640
|
}
|
|
19641
19641
|
} catch (e5) {
|
|
19642
19642
|
if (pastCredentials) {
|
|
19643
|
-
|
|
19644
|
-
credentials = getExtendedInstanceMetadataCredentials(pastCredentials,
|
|
19643
|
+
logger26.warn("Credential renew failed: ", e5);
|
|
19644
|
+
credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger26);
|
|
19645
19645
|
} else {
|
|
19646
19646
|
throw e5;
|
|
19647
19647
|
}
|
|
@@ -19658,7 +19658,7 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
|
19658
19658
|
var fromInstanceMetadata = /* @__PURE__ */ __name((init = {}) => staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger }), "fromInstanceMetadata");
|
|
19659
19659
|
var getInstanceMetadataProvider = /* @__PURE__ */ __name((init = {}) => {
|
|
19660
19660
|
let disableFetchToken = false;
|
|
19661
|
-
const { logger:
|
|
19661
|
+
const { logger: logger26, profile } = init;
|
|
19662
19662
|
const { timeout, maxRetries } = providerConfigFromInit(init);
|
|
19663
19663
|
const getCredentials = /* @__PURE__ */ __name(async (maxRetries2, options) => {
|
|
19664
19664
|
const isImdsV1Fallback = disableFetchToken || options.headers?.[X_AWS_EC2_METADATA_TOKEN2] == null;
|
|
@@ -19722,7 +19722,7 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
|
19722
19722
|
return async () => {
|
|
19723
19723
|
const endpoint = await getInstanceMetadataEndpoint();
|
|
19724
19724
|
if (disableFetchToken) {
|
|
19725
|
-
|
|
19725
|
+
logger26?.debug("AWS SDK Instance Metadata", "using v1 fallback (no token fetch)");
|
|
19726
19726
|
return getCredentials(maxRetries, { ...endpoint, timeout });
|
|
19727
19727
|
} else {
|
|
19728
19728
|
let token;
|
|
@@ -19736,7 +19736,7 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
|
19736
19736
|
} else if (error2.message === "TimeoutError" || [403, 404, 405].includes(error2.statusCode)) {
|
|
19737
19737
|
disableFetchToken = true;
|
|
19738
19738
|
}
|
|
19739
|
-
|
|
19739
|
+
logger26?.debug("AWS SDK Instance Metadata", "using v1 fallback (initial)");
|
|
19740
19740
|
return getCredentials(maxRetries, { ...endpoint, timeout });
|
|
19741
19741
|
}
|
|
19742
19742
|
return getCredentials(maxRetries, {
|
|
@@ -19861,7 +19861,7 @@ var require_dist_cjs7 = __commonJS({
|
|
|
19861
19861
|
}
|
|
19862
19862
|
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME$2), DEFER_EVENT_LISTENER_TIME$2);
|
|
19863
19863
|
}, "setConnectionTimeout");
|
|
19864
|
-
var setRequestTimeout = /* @__PURE__ */ __name((req, reject, timeoutInMs = 0, throwOnRequestTimeout,
|
|
19864
|
+
var setRequestTimeout = /* @__PURE__ */ __name((req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger26) => {
|
|
19865
19865
|
if (timeoutInMs) {
|
|
19866
19866
|
return timing.setTimeout(() => {
|
|
19867
19867
|
let msg = `@smithy/node-http-handler - [${throwOnRequestTimeout ? "ERROR" : "WARN"}] a request has exceeded the configured ${timeoutInMs} ms requestTimeout.`;
|
|
@@ -19874,7 +19874,7 @@ var require_dist_cjs7 = __commonJS({
|
|
|
19874
19874
|
reject(error2);
|
|
19875
19875
|
} else {
|
|
19876
19876
|
msg += ` Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.`;
|
|
19877
|
-
|
|
19877
|
+
logger26?.warn?.(msg);
|
|
19878
19878
|
}
|
|
19879
19879
|
}, timeoutInMs);
|
|
19880
19880
|
}
|
|
@@ -20015,7 +20015,7 @@ var require_dist_cjs7 = __commonJS({
|
|
|
20015
20015
|
}
|
|
20016
20016
|
return new _NodeHttpHandler(instanceOrOptions);
|
|
20017
20017
|
}
|
|
20018
|
-
static checkSocketUsage(agent, socketWarningTimestamp,
|
|
20018
|
+
static checkSocketUsage(agent, socketWarningTimestamp, logger26 = console) {
|
|
20019
20019
|
const { sockets, requests, maxSockets } = agent;
|
|
20020
20020
|
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
20021
20021
|
return socketWarningTimestamp;
|
|
@@ -20032,7 +20032,7 @@ var require_dist_cjs7 = __commonJS({
|
|
|
20032
20032
|
const socketsInUse = sockets[origin]?.length ?? 0;
|
|
20033
20033
|
const requestsEnqueued = requests[origin]?.length ?? 0;
|
|
20034
20034
|
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
20035
|
-
|
|
20035
|
+
logger26?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
|
|
20036
20036
|
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
20037
20037
|
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
|
|
20038
20038
|
return Date.now();
|
|
@@ -20061,7 +20061,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
20061
20061
|
this.config = await this.configProvider;
|
|
20062
20062
|
}
|
|
20063
20063
|
const config = this.config;
|
|
20064
|
-
const
|
|
20064
|
+
const logger26 = config.logger;
|
|
20065
20065
|
const isSSL = request2.protocol === "https:";
|
|
20066
20066
|
if (!isSSL && !this.config.httpAgent) {
|
|
20067
20067
|
this.config.httpAgent = await this.config.httpAgentProvider();
|
|
@@ -20105,7 +20105,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
20105
20105
|
});
|
|
20106
20106
|
}
|
|
20107
20107
|
socketWarningTimeoutId = timing.setTimeout(() => {
|
|
20108
|
-
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp,
|
|
20108
|
+
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, logger26);
|
|
20109
20109
|
}, config.socketAcquisitionWarningTimeout ?? (config.requestTimeout ?? 2e3) + (config.connectionTimeout ?? 1e3));
|
|
20110
20110
|
const queryString = request2.query ? buildQueryString2(request2.query) : "";
|
|
20111
20111
|
let auth = void 0;
|
|
@@ -20169,7 +20169,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
20169
20169
|
}
|
|
20170
20170
|
const effectiveRequestTimeout = requestTimeout ?? config.requestTimeout;
|
|
20171
20171
|
connectionTimeoutId = setConnectionTimeout(req, reject, config.connectionTimeout);
|
|
20172
|
-
requestTimeoutId = setRequestTimeout(req, reject, effectiveRequestTimeout, config.throwOnRequestTimeout,
|
|
20172
|
+
requestTimeoutId = setRequestTimeout(req, reject, effectiveRequestTimeout, config.throwOnRequestTimeout, logger26 ?? console);
|
|
20173
20173
|
const defaultSocketTimeout = config.socketTimeout === void 0 ? resolveDefaultSocketTimeout(config) : void 0;
|
|
20174
20174
|
if (defaultSocketTimeout) {
|
|
20175
20175
|
socketTimeoutId = setSocketTimeout(req, reject, defaultSocketTimeout, true);
|
|
@@ -20212,7 +20212,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
20212
20212
|
return this.config ?? {};
|
|
20213
20213
|
}
|
|
20214
20214
|
resolveDefaultConfig(options) {
|
|
20215
|
-
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger:
|
|
20215
|
+
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger: logger26 } = options || {};
|
|
20216
20216
|
const keepAlive = true;
|
|
20217
20217
|
const maxSockets = 50;
|
|
20218
20218
|
let httpAgentPromise;
|
|
@@ -20241,7 +20241,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
20241
20241
|
}
|
|
20242
20242
|
return new node_https.Agent({ keepAlive, maxSockets, ...httpsAgent });
|
|
20243
20243
|
})(),
|
|
20244
|
-
logger:
|
|
20244
|
+
logger: logger26
|
|
20245
20245
|
};
|
|
20246
20246
|
}
|
|
20247
20247
|
};
|
|
@@ -20687,7 +20687,7 @@ var require_dist_cjs8 = __commonJS({
|
|
|
20687
20687
|
var ECS_CONTAINER_HOST = "169.254.170.2";
|
|
20688
20688
|
var EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
|
|
20689
20689
|
var EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
|
|
20690
|
-
var checkUrl = /* @__PURE__ */ __name((url,
|
|
20690
|
+
var checkUrl = /* @__PURE__ */ __name((url, logger26) => {
|
|
20691
20691
|
if (url.protocol === "https:") {
|
|
20692
20692
|
return;
|
|
20693
20693
|
}
|
|
@@ -20714,7 +20714,7 @@ var require_dist_cjs8 = __commonJS({
|
|
|
20714
20714
|
throw new CredentialsProviderError2(`URL not accepted. It must either be HTTPS or match one of the following:
|
|
20715
20715
|
- loopback CIDR 127.0.0.0/8 or [::1/128]
|
|
20716
20716
|
- ECS container host 169.254.170.2
|
|
20717
|
-
- EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger:
|
|
20717
|
+
- EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger: logger26 });
|
|
20718
20718
|
}, "checkUrl");
|
|
20719
20719
|
function createGetRequest(url) {
|
|
20720
20720
|
return new HttpRequest2({
|
|
@@ -20730,13 +20730,13 @@ var require_dist_cjs8 = __commonJS({
|
|
|
20730
20730
|
});
|
|
20731
20731
|
}
|
|
20732
20732
|
__name(createGetRequest, "createGetRequest");
|
|
20733
|
-
async function getCredentials(response,
|
|
20733
|
+
async function getCredentials(response, logger26) {
|
|
20734
20734
|
const stream = sdkStreamMixin3(response.body);
|
|
20735
20735
|
const str = await stream.transformToString();
|
|
20736
20736
|
if (response.statusCode === 200) {
|
|
20737
20737
|
const parsed = JSON.parse(str);
|
|
20738
20738
|
if (typeof parsed.AccessKeyId !== "string" || typeof parsed.SecretAccessKey !== "string" || typeof parsed.Token !== "string" || typeof parsed.Expiration !== "string") {
|
|
20739
|
-
throw new CredentialsProviderError2("HTTP credential provider response not of the required format, an object matching: { AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger:
|
|
20739
|
+
throw new CredentialsProviderError2("HTTP credential provider response not of the required format, an object matching: { AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger: logger26 });
|
|
20740
20740
|
}
|
|
20741
20741
|
return {
|
|
20742
20742
|
accessKeyId: parsed.AccessKeyId,
|
|
@@ -20751,12 +20751,12 @@ var require_dist_cjs8 = __commonJS({
|
|
|
20751
20751
|
parsedBody = JSON.parse(str);
|
|
20752
20752
|
} catch (e5) {
|
|
20753
20753
|
}
|
|
20754
|
-
throw Object.assign(new CredentialsProviderError2(`Server responded with status: ${response.statusCode}`, { logger:
|
|
20754
|
+
throw Object.assign(new CredentialsProviderError2(`Server responded with status: ${response.statusCode}`, { logger: logger26 }), {
|
|
20755
20755
|
Code: parsedBody.Code,
|
|
20756
20756
|
Message: parsedBody.Message
|
|
20757
20757
|
});
|
|
20758
20758
|
}
|
|
20759
|
-
throw new CredentialsProviderError2(`Server responded with status: ${response.statusCode}`, { logger:
|
|
20759
|
+
throw new CredentialsProviderError2(`Server responded with status: ${response.statusCode}`, { logger: logger26 });
|
|
20760
20760
|
}
|
|
20761
20761
|
__name(getCredentials, "getCredentials");
|
|
20762
20762
|
var retryWrapper = /* @__PURE__ */ __name((toRetry, maxRetries, delayMs) => {
|
|
@@ -25470,14 +25470,14 @@ var require_dist_cjs10 = __commonJS({
|
|
|
25470
25470
|
var { getBearerTokenEnvKey: getBearerTokenEnvKey2 } = (init_httpAuthSchemes2(), __toCommonJS(httpAuthSchemes_exports));
|
|
25471
25471
|
var { TokenProviderError: TokenProviderError2, getSSOTokenFilepath: getSSOTokenFilepath2, parseKnownFiles: parseKnownFiles2, getProfileName: getProfileName2, loadSsoSessionData: loadSsoSessionData2, getSSOTokenFromFile: getSSOTokenFromFile2, memoize: memoize2, chain: chain2 } = (init_config2(), __toCommonJS(config_exports));
|
|
25472
25472
|
var { promises } = require("node:fs");
|
|
25473
|
-
var fromEnvSigningName = /* @__PURE__ */ __name(({ logger:
|
|
25474
|
-
|
|
25473
|
+
var fromEnvSigningName = /* @__PURE__ */ __name(({ logger: logger26, signingName } = {}) => async () => {
|
|
25474
|
+
logger26?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
|
|
25475
25475
|
if (!signingName) {
|
|
25476
|
-
throw new TokenProviderError2("Please pass 'signingName' to compute environment variable key", { logger:
|
|
25476
|
+
throw new TokenProviderError2("Please pass 'signingName' to compute environment variable key", { logger: logger26 });
|
|
25477
25477
|
}
|
|
25478
25478
|
const bearerTokenKey = getBearerTokenEnvKey2(signingName);
|
|
25479
25479
|
if (!(bearerTokenKey in process.env)) {
|
|
25480
|
-
throw new TokenProviderError2(`Token not present in '${bearerTokenKey}' environment variable`, { logger:
|
|
25480
|
+
throw new TokenProviderError2(`Token not present in '${bearerTokenKey}' environment variable`, { logger: logger26 });
|
|
25481
25481
|
}
|
|
25482
25482
|
const token = { token: process.env[bearerTokenKey] };
|
|
25483
25483
|
setTokenFeature2(token, "BEARER_SERVICE_ENV_VARS", "3");
|
|
@@ -25612,8 +25612,8 @@ var require_dist_cjs10 = __commonJS({
|
|
|
25612
25612
|
inFlightRefreshes.delete(ssoSessionName);
|
|
25613
25613
|
}
|
|
25614
25614
|
}, "fromSso");
|
|
25615
|
-
var fromStatic2 = /* @__PURE__ */ __name(({ token, logger:
|
|
25616
|
-
|
|
25615
|
+
var fromStatic2 = /* @__PURE__ */ __name(({ token, logger: logger26 }) => async () => {
|
|
25616
|
+
logger26?.debug("@aws-sdk/token-providers - fromStatic");
|
|
25617
25617
|
if (!token || !token.token) {
|
|
25618
25618
|
throw new TokenProviderError2(`Please pass a valid token to fromStatic`, false);
|
|
25619
25619
|
}
|
|
@@ -26363,7 +26363,7 @@ var require_dist_cjs11 = __commonJS({
|
|
|
26363
26363
|
var { fromSso } = require_dist_cjs10();
|
|
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, callerClientConfig, profile, filepath, configFilepath, ignoreCache, logger:
|
|
26366
|
+
var resolveSSOCredentials = /* @__PURE__ */ __name(async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, callerClientConfig, profile, filepath, configFilepath, ignoreCache, logger: logger26 }) => {
|
|
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) {
|
|
@@ -26375,7 +26375,7 @@ var require_dist_cjs11 = __commonJS({
|
|
|
26375
26375
|
ignoreCache,
|
|
26376
26376
|
clientConfig,
|
|
26377
26377
|
parentClientConfig,
|
|
26378
|
-
logger:
|
|
26378
|
+
logger: logger26
|
|
26379
26379
|
})({ callerClientConfig });
|
|
26380
26380
|
token = {
|
|
26381
26381
|
accessToken: _token.token,
|
|
@@ -26384,7 +26384,7 @@ var require_dist_cjs11 = __commonJS({
|
|
|
26384
26384
|
} catch (e5) {
|
|
26385
26385
|
throw new CredentialsProviderError2(e5.message, {
|
|
26386
26386
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
26387
|
-
logger:
|
|
26387
|
+
logger: logger26
|
|
26388
26388
|
});
|
|
26389
26389
|
}
|
|
26390
26390
|
} else {
|
|
@@ -26393,14 +26393,14 @@ var require_dist_cjs11 = __commonJS({
|
|
|
26393
26393
|
} catch (e5) {
|
|
26394
26394
|
throw new CredentialsProviderError2(`The SSO session associated with this profile is invalid. ${refreshMessage}`, {
|
|
26395
26395
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
26396
|
-
logger:
|
|
26396
|
+
logger: logger26
|
|
26397
26397
|
});
|
|
26398
26398
|
}
|
|
26399
26399
|
}
|
|
26400
26400
|
if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
|
|
26401
26401
|
throw new CredentialsProviderError2(`The SSO session associated with this profile has expired. ${refreshMessage}`, {
|
|
26402
26402
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
26403
|
-
logger:
|
|
26403
|
+
logger: logger26
|
|
26404
26404
|
});
|
|
26405
26405
|
}
|
|
26406
26406
|
const { accessToken } = token;
|
|
@@ -26420,14 +26420,14 @@ var require_dist_cjs11 = __commonJS({
|
|
|
26420
26420
|
} catch (e5) {
|
|
26421
26421
|
throw new CredentialsProviderError2(e5, {
|
|
26422
26422
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
26423
|
-
logger:
|
|
26423
|
+
logger: logger26
|
|
26424
26424
|
});
|
|
26425
26425
|
}
|
|
26426
26426
|
const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope, accountId } = {} } = ssoResp;
|
|
26427
26427
|
if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
|
|
26428
26428
|
throw new CredentialsProviderError2("SSO returns an invalid temporary credential.", {
|
|
26429
26429
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
26430
|
-
logger:
|
|
26430
|
+
logger: logger26
|
|
26431
26431
|
});
|
|
26432
26432
|
}
|
|
26433
26433
|
const credentials = {
|
|
@@ -26445,11 +26445,11 @@ var require_dist_cjs11 = __commonJS({
|
|
|
26445
26445
|
}
|
|
26446
26446
|
return credentials;
|
|
26447
26447
|
}, "resolveSSOCredentials");
|
|
26448
|
-
var validateSsoProfile = /* @__PURE__ */ __name((profile,
|
|
26448
|
+
var validateSsoProfile = /* @__PURE__ */ __name((profile, logger26) => {
|
|
26449
26449
|
const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
|
|
26450
26450
|
if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
|
|
26451
26451
|
throw new CredentialsProviderError2(`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(", ")}
|
|
26452
|
-
Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger:
|
|
26452
|
+
Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger: logger26 });
|
|
26453
26453
|
}
|
|
26454
26454
|
return profile;
|
|
26455
26455
|
}, "validateSsoProfile");
|
|
@@ -28348,9 +28348,9 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
28348
28348
|
return async (sourceCreds, params) => {
|
|
28349
28349
|
closureSourceCreds = sourceCreds;
|
|
28350
28350
|
if (!stsClient) {
|
|
28351
|
-
const { logger:
|
|
28351
|
+
const { logger: logger26 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
|
|
28352
28352
|
const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
|
|
28353
|
-
logger:
|
|
28353
|
+
logger: logger26,
|
|
28354
28354
|
profile
|
|
28355
28355
|
});
|
|
28356
28356
|
const isCompatibleRequestHandler = !isH2(requestHandler);
|
|
@@ -28361,7 +28361,7 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
28361
28361
|
credentialDefaultProvider: /* @__PURE__ */ __name(() => async () => closureSourceCreds, "credentialDefaultProvider"),
|
|
28362
28362
|
region: resolvedRegion,
|
|
28363
28363
|
requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
|
|
28364
|
-
logger:
|
|
28364
|
+
logger: logger26
|
|
28365
28365
|
});
|
|
28366
28366
|
}
|
|
28367
28367
|
const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleCommand(params));
|
|
@@ -28385,9 +28385,9 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
28385
28385
|
let stsClient;
|
|
28386
28386
|
return async (params) => {
|
|
28387
28387
|
if (!stsClient) {
|
|
28388
|
-
const { logger:
|
|
28388
|
+
const { logger: logger26 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
|
|
28389
28389
|
const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
|
|
28390
|
-
logger:
|
|
28390
|
+
logger: logger26,
|
|
28391
28391
|
profile
|
|
28392
28392
|
});
|
|
28393
28393
|
const isCompatibleRequestHandler = !isH2(requestHandler);
|
|
@@ -28397,7 +28397,7 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
28397
28397
|
profile,
|
|
28398
28398
|
region: resolvedRegion,
|
|
28399
28399
|
requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
|
|
28400
|
-
logger:
|
|
28400
|
+
logger: logger26
|
|
28401
28401
|
});
|
|
28402
28402
|
}
|
|
28403
28403
|
const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
|
|
@@ -29528,7 +29528,7 @@ var require_dist_cjs14 = __commonJS({
|
|
|
29528
29528
|
return this.toCredentials(freshToken.accessToken);
|
|
29529
29529
|
}
|
|
29530
29530
|
const { SigninClient: SigninClient2, CreateOAuth2TokenCommand: CreateOAuth2TokenCommand2 } = (init_signin(), __toCommonJS(signin_exports));
|
|
29531
|
-
const { logger:
|
|
29531
|
+
const { logger: logger26, userAgentAppId } = this.callerClientConfig ?? {};
|
|
29532
29532
|
const isH22 = /* @__PURE__ */ __name((requestHandler2) => {
|
|
29533
29533
|
return requestHandler2?.metadata?.handlerProtocol === "h2";
|
|
29534
29534
|
}, "isH2");
|
|
@@ -29541,7 +29541,7 @@ var require_dist_cjs14 = __commonJS({
|
|
|
29541
29541
|
},
|
|
29542
29542
|
region,
|
|
29543
29543
|
requestHandler,
|
|
29544
|
-
logger:
|
|
29544
|
+
logger: logger26,
|
|
29545
29545
|
userAgentAppId,
|
|
29546
29546
|
...this.init?.clientConfig
|
|
29547
29547
|
});
|
|
@@ -29789,7 +29789,7 @@ var require_dist_cjs15 = __commonJS({
|
|
|
29789
29789
|
setCredentialFeature2(credentials, "CREDENTIALS_PROCESS", "w");
|
|
29790
29790
|
return credentials;
|
|
29791
29791
|
}, "getValidatedProcessCredentials");
|
|
29792
|
-
var resolveProcessCredentials = /* @__PURE__ */ __name(async (profileName, profiles,
|
|
29792
|
+
var resolveProcessCredentials = /* @__PURE__ */ __name(async (profileName, profiles, logger26) => {
|
|
29793
29793
|
const profile = profiles[profileName];
|
|
29794
29794
|
if (profiles[profileName]) {
|
|
29795
29795
|
const credentialProcess = profile["credential_process"];
|
|
@@ -29805,14 +29805,14 @@ var require_dist_cjs15 = __commonJS({
|
|
|
29805
29805
|
}
|
|
29806
29806
|
return getValidatedProcessCredentials(profileName, data, profiles);
|
|
29807
29807
|
} catch (error2) {
|
|
29808
|
-
throw new CredentialsProviderError2(error2.message, { logger:
|
|
29808
|
+
throw new CredentialsProviderError2(error2.message, { logger: logger26 });
|
|
29809
29809
|
}
|
|
29810
29810
|
} else {
|
|
29811
|
-
throw new CredentialsProviderError2(`Profile ${profileName} did not contain credential_process.`, { logger:
|
|
29811
|
+
throw new CredentialsProviderError2(`Profile ${profileName} did not contain credential_process.`, { logger: logger26 });
|
|
29812
29812
|
}
|
|
29813
29813
|
} else {
|
|
29814
29814
|
throw new CredentialsProviderError2(`Profile ${profileName} could not be found in shared credentials file.`, {
|
|
29815
|
-
logger:
|
|
29815
|
+
logger: logger26
|
|
29816
29816
|
});
|
|
29817
29817
|
}
|
|
29818
29818
|
}, "resolveProcessCredentials");
|
|
@@ -29892,21 +29892,21 @@ var require_dist_cjs17 = __commonJS({
|
|
|
29892
29892
|
"node_modules/@aws-sdk/credential-provider-ini/dist-cjs/index.js"(exports2) {
|
|
29893
29893
|
var { CredentialsProviderError: CredentialsProviderError2, chain: chain2, getProfileName: getProfileName2, parseKnownFiles: parseKnownFiles2 } = (init_config2(), __toCommonJS(config_exports));
|
|
29894
29894
|
var { setCredentialFeature: setCredentialFeature2 } = (init_client3(), __toCommonJS(client_exports2));
|
|
29895
|
-
var resolveCredentialSource = /* @__PURE__ */ __name((credentialSource, profileName,
|
|
29895
|
+
var resolveCredentialSource = /* @__PURE__ */ __name((credentialSource, profileName, logger26) => {
|
|
29896
29896
|
const sourceProvidersMap = {
|
|
29897
29897
|
EcsContainer: /* @__PURE__ */ __name(async (options) => {
|
|
29898
29898
|
const { fromHttp } = require_dist_cjs8();
|
|
29899
29899
|
const { fromContainerMetadata } = require_dist_cjs6();
|
|
29900
|
-
|
|
29900
|
+
logger26?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
|
|
29901
29901
|
return async () => chain2(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
|
|
29902
29902
|
}, "EcsContainer"),
|
|
29903
29903
|
Ec2InstanceMetadata: /* @__PURE__ */ __name(async (options) => {
|
|
29904
|
-
|
|
29904
|
+
logger26?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
|
|
29905
29905
|
const { fromInstanceMetadata } = require_dist_cjs6();
|
|
29906
29906
|
return async () => fromInstanceMetadata(options)().then(setNamedProvider);
|
|
29907
29907
|
}, "Ec2InstanceMetadata"),
|
|
29908
29908
|
Environment: /* @__PURE__ */ __name(async (options) => {
|
|
29909
|
-
|
|
29909
|
+
logger26?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
|
|
29910
29910
|
const { fromEnv: fromEnv2 } = require_dist_cjs5();
|
|
29911
29911
|
return async () => fromEnv2(options)().then(setNamedProvider);
|
|
29912
29912
|
}, "Environment")
|
|
@@ -29914,24 +29914,24 @@ var require_dist_cjs17 = __commonJS({
|
|
|
29914
29914
|
if (credentialSource in sourceProvidersMap) {
|
|
29915
29915
|
return sourceProvidersMap[credentialSource];
|
|
29916
29916
|
} else {
|
|
29917
|
-
throw new CredentialsProviderError2(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger:
|
|
29917
|
+
throw new CredentialsProviderError2(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger: logger26 });
|
|
29918
29918
|
}
|
|
29919
29919
|
}, "resolveCredentialSource");
|
|
29920
29920
|
var setNamedProvider = /* @__PURE__ */ __name((creds) => setCredentialFeature2(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p"), "setNamedProvider");
|
|
29921
|
-
var isAssumeRoleProfile = /* @__PURE__ */ __name((arg, { profile = "default", logger:
|
|
29922
|
-
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:
|
|
29921
|
+
var isAssumeRoleProfile = /* @__PURE__ */ __name((arg, { profile = "default", logger: logger26 } = {}) => {
|
|
29922
|
+
return Boolean(arg) && typeof arg === "object" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 && ["undefined", "string"].indexOf(typeof arg.external_id) > -1 && ["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 && (isAssumeRoleWithSourceProfile(arg, { profile, logger: logger26 }) || isCredentialSourceProfile(arg, { profile, logger: logger26 }));
|
|
29923
29923
|
}, "isAssumeRoleProfile");
|
|
29924
|
-
var isAssumeRoleWithSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger:
|
|
29924
|
+
var isAssumeRoleWithSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger: logger26 }) => {
|
|
29925
29925
|
const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
|
29926
29926
|
if (withSourceProfile) {
|
|
29927
|
-
|
|
29927
|
+
logger26?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
|
|
29928
29928
|
}
|
|
29929
29929
|
return withSourceProfile;
|
|
29930
29930
|
}, "isAssumeRoleWithSourceProfile");
|
|
29931
|
-
var isCredentialSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger:
|
|
29931
|
+
var isCredentialSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger: logger26 }) => {
|
|
29932
29932
|
const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
|
29933
29933
|
if (withProviderProfile) {
|
|
29934
|
-
|
|
29934
|
+
logger26?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
|
|
29935
29935
|
}
|
|
29936
29936
|
return withProviderProfile;
|
|
29937
29937
|
}, "isCredentialSourceProfile");
|
|
@@ -36066,7 +36066,7 @@ var require_dist_cjs20 = __commonJS({
|
|
|
36066
36066
|
__name(this, "PutResourcePolicyCommand");
|
|
36067
36067
|
}
|
|
36068
36068
|
};
|
|
36069
|
-
var
|
|
36069
|
+
var QueryCommand6 = class extends command5(_ep2, _mw05, "Query", Query$) {
|
|
36070
36070
|
static {
|
|
36071
36071
|
__name(this, "QueryCommand");
|
|
36072
36072
|
}
|
|
@@ -36160,7 +36160,7 @@ var require_dist_cjs20 = __commonJS({
|
|
|
36160
36160
|
var paginateListExports = createPaginator2(DynamoDBClient2, ListExportsCommand, "NextToken", "NextToken", "MaxResults");
|
|
36161
36161
|
var paginateListImports = createPaginator2(DynamoDBClient2, ListImportsCommand, "NextToken", "NextToken", "PageSize");
|
|
36162
36162
|
var paginateListTables = createPaginator2(DynamoDBClient2, ListTablesCommand, "ExclusiveStartTableName", "LastEvaluatedTableName", "Limit");
|
|
36163
|
-
var paginateQuery = createPaginator2(DynamoDBClient2,
|
|
36163
|
+
var paginateQuery = createPaginator2(DynamoDBClient2, QueryCommand6, "ExclusiveStartKey", "LastEvaluatedKey", "Limit");
|
|
36164
36164
|
var paginateScan = createPaginator2(DynamoDBClient2, ScanCommand, "ExclusiveStartKey", "LastEvaluatedKey", "Limit");
|
|
36165
36165
|
var checkState$5 = /* @__PURE__ */ __name(async (client, input) => {
|
|
36166
36166
|
let reason;
|
|
@@ -36422,7 +36422,7 @@ var require_dist_cjs20 = __commonJS({
|
|
|
36422
36422
|
ListTagsOfResourceCommand,
|
|
36423
36423
|
PutItemCommand,
|
|
36424
36424
|
PutResourcePolicyCommand,
|
|
36425
|
-
QueryCommand:
|
|
36425
|
+
QueryCommand: QueryCommand6,
|
|
36426
36426
|
RestoreTableFromBackupCommand,
|
|
36427
36427
|
RestoreTableToPointInTimeCommand,
|
|
36428
36428
|
ScanCommand,
|
|
@@ -37036,7 +37036,7 @@ var require_dist_cjs20 = __commonJS({
|
|
|
37036
37036
|
exports2.PutResourcePolicyInput$ = PutResourcePolicyInput$;
|
|
37037
37037
|
exports2.PutResourcePolicyOutput$ = PutResourcePolicyOutput$;
|
|
37038
37038
|
exports2.Query$ = Query$;
|
|
37039
|
-
exports2.QueryCommand =
|
|
37039
|
+
exports2.QueryCommand = QueryCommand6;
|
|
37040
37040
|
exports2.QueryInput$ = QueryInput$;
|
|
37041
37041
|
exports2.QueryOutput$ = QueryOutput$;
|
|
37042
37042
|
exports2.Replica$ = Replica$;
|
|
@@ -37964,7 +37964,7 @@ var require_dist_cjs22 = __commonJS({
|
|
|
37964
37964
|
return async () => handler2(this.clientCommand);
|
|
37965
37965
|
}
|
|
37966
37966
|
};
|
|
37967
|
-
var
|
|
37967
|
+
var QueryCommand6 = class extends DynamoDBDocumentClientCommand {
|
|
37968
37968
|
static {
|
|
37969
37969
|
__name(this, "QueryCommand");
|
|
37970
37970
|
}
|
|
@@ -38215,7 +38215,7 @@ var require_dist_cjs22 = __commonJS({
|
|
|
38215
38215
|
const hasSerializer = middlewares.some((m3) => m3.includes?.("serializerMiddleware"));
|
|
38216
38216
|
if (!hasSerializer) {
|
|
38217
38217
|
const configuredLogger = this.config.logger;
|
|
38218
|
-
const
|
|
38218
|
+
const logger26 = configuredLogger && !configuredLogger.constructor?.name.includes("NoOp") ? configuredLogger : console;
|
|
38219
38219
|
const substituteClient = new DynamoDBClient2(Object.assign({}, this.config, {
|
|
38220
38220
|
defaultUserAgentProvider: void 0,
|
|
38221
38221
|
retryStrategy: void 0,
|
|
@@ -38228,7 +38228,7 @@ var require_dist_cjs22 = __commonJS({
|
|
|
38228
38228
|
this.middlewareStack = substituteClient.middlewareStack;
|
|
38229
38229
|
this.config = substituteClient.config;
|
|
38230
38230
|
this.config.translateConfig = translateConfig;
|
|
38231
|
-
|
|
38231
|
+
logger26.warn("@aws-sdk/lib-dynamodb - WARN: incompatible version of DynamoDBClient given to DynamoDBDocumentClient. We have forwarded your client's configuration to a newer version of DynamoDBClient in the dependency closure to instantiate DynamoDBDocumentClient.");
|
|
38232
38232
|
}
|
|
38233
38233
|
}
|
|
38234
38234
|
}
|
|
@@ -38238,7 +38238,7 @@ var require_dist_cjs22 = __commonJS({
|
|
|
38238
38238
|
destroy() {
|
|
38239
38239
|
}
|
|
38240
38240
|
};
|
|
38241
|
-
var paginateQuery = createPaginator2(DynamoDBDocumentClient2,
|
|
38241
|
+
var paginateQuery = createPaginator2(DynamoDBDocumentClient2, QueryCommand6, "ExclusiveStartKey", "LastEvaluatedKey", "Limit");
|
|
38242
38242
|
var paginateScan = createPaginator2(DynamoDBDocumentClient2, ScanCommand, "ExclusiveStartKey", "LastEvaluatedKey", "Limit");
|
|
38243
38243
|
async function* paginatedBatchGet(config, input) {
|
|
38244
38244
|
let requestItems = input.RequestItems;
|
|
@@ -38390,7 +38390,7 @@ var require_dist_cjs22 = __commonJS({
|
|
|
38390
38390
|
}
|
|
38391
38391
|
}
|
|
38392
38392
|
query(args, optionsOrCb, cb) {
|
|
38393
|
-
const command5 = new
|
|
38393
|
+
const command5 = new QueryCommand6(args);
|
|
38394
38394
|
if (typeof optionsOrCb === "function") {
|
|
38395
38395
|
this.send(command5, optionsOrCb);
|
|
38396
38396
|
} else if (typeof cb === "function") {
|
|
@@ -38481,7 +38481,7 @@ var require_dist_cjs22 = __commonJS({
|
|
|
38481
38481
|
exports2.ExportTableToPointInTimeCommand = ExportTableToPointInTimeCommand;
|
|
38482
38482
|
exports2.GetCommand = GetCommand;
|
|
38483
38483
|
exports2.PutCommand = PutCommand;
|
|
38484
|
-
exports2.QueryCommand =
|
|
38484
|
+
exports2.QueryCommand = QueryCommand6;
|
|
38485
38485
|
exports2.ScanCommand = ScanCommand;
|
|
38486
38486
|
exports2.SearchVectorsCommand = SearchVectorsCommand;
|
|
38487
38487
|
exports2.TransactGetCommand = TransactGetCommand;
|
|
@@ -39034,6 +39034,128 @@ var init_shared = __esm({
|
|
|
39034
39034
|
}
|
|
39035
39035
|
});
|
|
39036
39036
|
|
|
39037
|
+
// src/server/utils/cost-tracker.ts
|
|
39038
|
+
var CostTracker;
|
|
39039
|
+
var init_cost_tracker = __esm({
|
|
39040
|
+
"src/server/utils/cost-tracker.ts"() {
|
|
39041
|
+
"use strict";
|
|
39042
|
+
CostTracker = class {
|
|
39043
|
+
static {
|
|
39044
|
+
__name(this, "CostTracker");
|
|
39045
|
+
}
|
|
39046
|
+
totalRCU = 0;
|
|
39047
|
+
totalWCU = 0;
|
|
39048
|
+
operationCount = 0;
|
|
39049
|
+
/**
|
|
39050
|
+
* ConsumedCapacityを追加
|
|
39051
|
+
*
|
|
39052
|
+
* DynamoDB操作のConsumedCapacityを累積します。
|
|
39053
|
+
* undefinedが渡された場合は何もしません(エラーにしない)。
|
|
39054
|
+
*
|
|
39055
|
+
* AWS SDKのConsumedCapacityは以下のフィールドを持ちます:
|
|
39056
|
+
* - CapacityUnits: 総キャパシティユニット(RCU + WCU)
|
|
39057
|
+
* - ReadCapacityUnits: 読み取りキャパシティユニット
|
|
39058
|
+
* - WriteCapacityUnits: 書き込みキャパシティユニット
|
|
39059
|
+
*
|
|
39060
|
+
* このメソッドはReadCapacityUnitsとWriteCapacityUnitsを優先的に使用し、
|
|
39061
|
+
* 存在しない場合はCapacityUnitsを読み取りとして扱います。
|
|
39062
|
+
*
|
|
39063
|
+
* @param consumedCapacity - DynamoDB操作のConsumedCapacity
|
|
39064
|
+
*/
|
|
39065
|
+
add(consumedCapacity) {
|
|
39066
|
+
if (!consumedCapacity) {
|
|
39067
|
+
return;
|
|
39068
|
+
}
|
|
39069
|
+
const rcu = consumedCapacity.ReadCapacityUnits ?? 0;
|
|
39070
|
+
const wcu = consumedCapacity.WriteCapacityUnits ?? 0;
|
|
39071
|
+
this.totalRCU += rcu;
|
|
39072
|
+
this.totalWCU += wcu;
|
|
39073
|
+
this.operationCount += 1;
|
|
39074
|
+
}
|
|
39075
|
+
/**
|
|
39076
|
+
* 集計結果を取得
|
|
39077
|
+
*
|
|
39078
|
+
* これまでに追加されたConsumedCapacityの集計結果を返します。
|
|
39079
|
+
*
|
|
39080
|
+
* @returns 集計されたコスト情報
|
|
39081
|
+
*/
|
|
39082
|
+
getAggregated() {
|
|
39083
|
+
return {
|
|
39084
|
+
totalRCU: this.totalRCU,
|
|
39085
|
+
totalWCU: this.totalWCU,
|
|
39086
|
+
operationCount: this.operationCount
|
|
39087
|
+
};
|
|
39088
|
+
}
|
|
39089
|
+
/**
|
|
39090
|
+
* リセット
|
|
39091
|
+
*
|
|
39092
|
+
* 累積されたコスト情報をクリアします。
|
|
39093
|
+
*/
|
|
39094
|
+
reset() {
|
|
39095
|
+
this.totalRCU = 0;
|
|
39096
|
+
this.totalWCU = 0;
|
|
39097
|
+
this.operationCount = 0;
|
|
39098
|
+
}
|
|
39099
|
+
};
|
|
39100
|
+
}
|
|
39101
|
+
});
|
|
39102
|
+
|
|
39103
|
+
// src/server/utils/dynamodb.ts
|
|
39104
|
+
function getDBClient() {
|
|
39105
|
+
if (!dbClient) {
|
|
39106
|
+
dbClient = createDynamoDBClient({
|
|
39107
|
+
region: process.env.AWS_REGION || process.env.REGION
|
|
39108
|
+
});
|
|
39109
|
+
}
|
|
39110
|
+
return dbClient;
|
|
39111
|
+
}
|
|
39112
|
+
function getTableName() {
|
|
39113
|
+
const tableName = process.env.TABLE_NAME;
|
|
39114
|
+
if (!tableName) {
|
|
39115
|
+
throw new ConfigError("TABLE_NAME environment variable is not set");
|
|
39116
|
+
}
|
|
39117
|
+
return tableName;
|
|
39118
|
+
}
|
|
39119
|
+
function removeShadowKeys(record) {
|
|
39120
|
+
const { __shadowKeys, ...rest } = record;
|
|
39121
|
+
return rest;
|
|
39122
|
+
}
|
|
39123
|
+
function extractCleanRecord(item) {
|
|
39124
|
+
const data = item.data || item;
|
|
39125
|
+
return removeShadowKeys(data);
|
|
39126
|
+
}
|
|
39127
|
+
async function executeDynamoDBOperation(operation2, operationName) {
|
|
39128
|
+
try {
|
|
39129
|
+
return await operation2();
|
|
39130
|
+
} catch (error2) {
|
|
39131
|
+
if (error2 instanceof Error && error2.name === "AccessDeniedException") {
|
|
39132
|
+
logger2.error("DynamoDB access denied", {
|
|
39133
|
+
errorName: error2.name,
|
|
39134
|
+
errorMessage: error2.message,
|
|
39135
|
+
operation: operationName,
|
|
39136
|
+
tableName: process.env.TABLE_NAME,
|
|
39137
|
+
region: process.env.AWS_REGION || process.env.REGION
|
|
39138
|
+
});
|
|
39139
|
+
throw new Error(`Insufficient permissions to access DynamoDB: ${operationName}`);
|
|
39140
|
+
}
|
|
39141
|
+
throw error2;
|
|
39142
|
+
}
|
|
39143
|
+
}
|
|
39144
|
+
var logger2, dbClient;
|
|
39145
|
+
var init_dynamodb3 = __esm({
|
|
39146
|
+
"src/server/utils/dynamodb.ts"() {
|
|
39147
|
+
"use strict";
|
|
39148
|
+
init_shared();
|
|
39149
|
+
logger2 = createLogger({ service: "records-lambda" });
|
|
39150
|
+
dbClient = null;
|
|
39151
|
+
__name(getDBClient, "getDBClient");
|
|
39152
|
+
__name(getTableName, "getTableName");
|
|
39153
|
+
__name(removeShadowKeys, "removeShadowKeys");
|
|
39154
|
+
__name(extractCleanRecord, "extractCleanRecord");
|
|
39155
|
+
__name(executeDynamoDBOperation, "executeDynamoDBOperation");
|
|
39156
|
+
}
|
|
39157
|
+
});
|
|
39158
|
+
|
|
39037
39159
|
// src/shared/constants/formatting.ts
|
|
39038
39160
|
var init_formatting = __esm({
|
|
39039
39161
|
"src/shared/constants/formatting.ts"() {
|
|
@@ -39318,435 +39440,153 @@ var init_shadow = __esm({
|
|
|
39318
39440
|
}
|
|
39319
39441
|
});
|
|
39320
39442
|
|
|
39321
|
-
// src/server/
|
|
39322
|
-
function
|
|
39323
|
-
|
|
39324
|
-
|
|
39325
|
-
|
|
39326
|
-
|
|
39327
|
-
|
|
39328
|
-
|
|
39329
|
-
|
|
39330
|
-
|
|
39331
|
-
|
|
39332
|
-
|
|
39333
|
-
|
|
39443
|
+
// src/server/operations/find/keyCondition.ts
|
|
39444
|
+
function buildKeyCondition(resource, sortField, optimizableFilter, secondFilter) {
|
|
39445
|
+
const expressionAttributeValues = {
|
|
39446
|
+
":pk": resource
|
|
39447
|
+
};
|
|
39448
|
+
if (!optimizableFilter) {
|
|
39449
|
+
return {
|
|
39450
|
+
keyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
39451
|
+
expressionAttributeValues: {
|
|
39452
|
+
...expressionAttributeValues,
|
|
39453
|
+
":skPrefix": `${sortField}#`
|
|
39454
|
+
}
|
|
39455
|
+
};
|
|
39334
39456
|
}
|
|
39335
|
-
|
|
39336
|
-
|
|
39337
|
-
|
|
39338
|
-
|
|
39339
|
-
|
|
39340
|
-
|
|
39341
|
-
|
|
39342
|
-
const data = item.data || item;
|
|
39343
|
-
return removeShadowKeys(data);
|
|
39344
|
-
}
|
|
39345
|
-
async function executeDynamoDBOperation(operation2, operationName) {
|
|
39346
|
-
try {
|
|
39347
|
-
return await operation2();
|
|
39348
|
-
} catch (error2) {
|
|
39349
|
-
if (error2 instanceof Error && error2.name === "AccessDeniedException") {
|
|
39350
|
-
logger2.error("DynamoDB access denied", {
|
|
39351
|
-
errorName: error2.name,
|
|
39352
|
-
errorMessage: error2.message,
|
|
39353
|
-
operation: operationName,
|
|
39354
|
-
tableName: process.env.TABLE_NAME,
|
|
39355
|
-
region: process.env.AWS_REGION || process.env.REGION
|
|
39356
|
-
});
|
|
39357
|
-
throw new Error(`Insufficient permissions to access DynamoDB: ${operationName}`);
|
|
39457
|
+
if (secondFilter) {
|
|
39458
|
+
const first = rangeBounds(sortField, optimizableFilter);
|
|
39459
|
+
const second = rangeBounds(sortField, secondFilter);
|
|
39460
|
+
const low = first.low ?? second.low;
|
|
39461
|
+
const high = first.high ?? second.high;
|
|
39462
|
+
if (low !== void 0 && high !== void 0) {
|
|
39463
|
+
return rangeCondition(expressionAttributeValues, low, high);
|
|
39358
39464
|
}
|
|
39359
|
-
throw error2;
|
|
39360
39465
|
}
|
|
39361
|
-
}
|
|
39362
|
-
|
|
39363
|
-
|
|
39364
|
-
|
|
39365
|
-
|
|
39366
|
-
|
|
39367
|
-
|
|
39368
|
-
|
|
39369
|
-
|
|
39370
|
-
|
|
39371
|
-
|
|
39372
|
-
|
|
39373
|
-
|
|
39374
|
-
|
|
39375
|
-
}
|
|
39376
|
-
|
|
39377
|
-
//
|
|
39378
|
-
|
|
39379
|
-
|
|
39380
|
-
|
|
39381
|
-
|
|
39382
|
-
|
|
39383
|
-
|
|
39384
|
-
|
|
39385
|
-
}
|
|
39386
|
-
const dbClient2 = getDBClient();
|
|
39387
|
-
const tableName = getTableName();
|
|
39388
|
-
const records = [];
|
|
39389
|
-
for (let i5 = 0; i5 < unique.length; i5 += BATCH_GET_MAX_KEYS) {
|
|
39390
|
-
let pending = unique.slice(i5, i5 + BATCH_GET_MAX_KEYS);
|
|
39391
|
-
for (let attempt = 0; pending.length > 0; attempt++) {
|
|
39392
|
-
if (attempt > BATCH_GET_MAX_RETRIES) {
|
|
39393
|
-
logger3.error("BatchGetItem \u306E UnprocessedKeys \u304C\u89E3\u6D88\u3057\u306A\u304B\u3063\u305F", {
|
|
39394
|
-
requestId,
|
|
39395
|
-
unprocessed: pending.length,
|
|
39396
|
-
attempts: attempt
|
|
39397
|
-
});
|
|
39398
|
-
throw new AppError(
|
|
39399
|
-
"INTERNAL_ERROR" /* INTERNAL_ERROR */,
|
|
39400
|
-
"BatchGetItem still has unprocessed keys after retries",
|
|
39401
|
-
503,
|
|
39402
|
-
{ unprocessed: pending.length }
|
|
39403
|
-
);
|
|
39404
|
-
}
|
|
39405
|
-
if (attempt > 0) {
|
|
39406
|
-
await sleep2(baseDelayMs * 2 ** (attempt - 1) * (0.5 + Math.random() / 2));
|
|
39407
|
-
}
|
|
39408
|
-
const keysToGet = pending;
|
|
39409
|
-
const result = await executeDynamoDBOperation(
|
|
39410
|
-
() => dbClient2.send(
|
|
39411
|
-
new import_lib_dynamodb2.BatchGetCommand({
|
|
39412
|
-
RequestItems: {
|
|
39413
|
-
[tableName]: {
|
|
39414
|
-
Keys: keysToGet,
|
|
39415
|
-
ConsistentRead: consistentRead
|
|
39416
|
-
}
|
|
39417
|
-
},
|
|
39418
|
-
ReturnConsumedCapacity: "TOTAL"
|
|
39419
|
-
})
|
|
39420
|
-
),
|
|
39421
|
-
"BatchGetItem"
|
|
39466
|
+
const { operator, type } = optimizableFilter.parsed;
|
|
39467
|
+
const value = optimizableFilter.value;
|
|
39468
|
+
const { encoded, exact } = encodeValueForShadowSK(value, type, operator);
|
|
39469
|
+
const skValue = `${sortField}#${encoded}`;
|
|
39470
|
+
const afterValue = `${skValue}#id#~`;
|
|
39471
|
+
const beforeValue = `${skValue}#id#`;
|
|
39472
|
+
switch (operator) {
|
|
39473
|
+
case "$eq":
|
|
39474
|
+
return {
|
|
39475
|
+
keyConditionExpression: "PK = :pk AND begins_with(SK, :skValue)",
|
|
39476
|
+
expressionAttributeValues: {
|
|
39477
|
+
...expressionAttributeValues,
|
|
39478
|
+
":skValue": beforeValue
|
|
39479
|
+
}
|
|
39480
|
+
};
|
|
39481
|
+
// 範囲検索は SK BETWEEN の 1 条件にする。
|
|
39482
|
+
// - DynamoDB はソートキーに 1 つの条件しか許さない(begins_with と比較を並べると ValidationException)
|
|
39483
|
+
// - 上限・下限を sortField の範囲に閉じないと、他の項目のシャドー(や本体 id#…)まで読む
|
|
39484
|
+
// BETWEEN は両端を含むが、端の値(`…#id#`、`…#id#~`、`{sortField}$`)と一致する SK は実在しない
|
|
39485
|
+
case "$gt":
|
|
39486
|
+
return rangeCondition(
|
|
39487
|
+
expressionAttributeValues,
|
|
39488
|
+
exact ? afterValue : beforeValue,
|
|
39489
|
+
fieldUpperBound(sortField)
|
|
39422
39490
|
);
|
|
39423
|
-
|
|
39424
|
-
|
|
39425
|
-
|
|
39426
|
-
|
|
39427
|
-
|
|
39428
|
-
|
|
39491
|
+
case "$gte":
|
|
39492
|
+
return rangeCondition(expressionAttributeValues, beforeValue, fieldUpperBound(sortField));
|
|
39493
|
+
case "$lt":
|
|
39494
|
+
return rangeCondition(
|
|
39495
|
+
expressionAttributeValues,
|
|
39496
|
+
`${sortField}#`,
|
|
39497
|
+
exact ? beforeValue : afterValue
|
|
39498
|
+
);
|
|
39499
|
+
case "$lte":
|
|
39500
|
+
return rangeCondition(expressionAttributeValues, `${sortField}#`, afterValue);
|
|
39501
|
+
case "$starts":
|
|
39502
|
+
return {
|
|
39503
|
+
keyConditionExpression: "PK = :pk AND begins_with(SK, :skValue)",
|
|
39504
|
+
expressionAttributeValues: {
|
|
39505
|
+
...expressionAttributeValues,
|
|
39506
|
+
":skValue": skValue
|
|
39429
39507
|
}
|
|
39430
|
-
}
|
|
39431
|
-
|
|
39432
|
-
|
|
39433
|
-
|
|
39508
|
+
};
|
|
39509
|
+
default:
|
|
39510
|
+
return {
|
|
39511
|
+
keyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
39512
|
+
expressionAttributeValues: {
|
|
39513
|
+
...expressionAttributeValues,
|
|
39514
|
+
":skPrefix": `${sortField}#`
|
|
39515
|
+
}
|
|
39516
|
+
};
|
|
39434
39517
|
}
|
|
39435
|
-
return records;
|
|
39436
39518
|
}
|
|
39437
|
-
|
|
39438
|
-
|
|
39439
|
-
|
|
39440
|
-
|
|
39441
|
-
|
|
39442
|
-
|
|
39443
|
-
|
|
39444
|
-
|
|
39445
|
-
|
|
39446
|
-
|
|
39447
|
-
|
|
39448
|
-
|
|
39449
|
-
|
|
39450
|
-
|
|
39451
|
-
|
|
39452
|
-
|
|
39453
|
-
}
|
|
39454
|
-
|
|
39455
|
-
// src/server/utils/bulkOperations.ts
|
|
39456
|
-
function logLargeBatchWarning(operation2, recordCount, requestId, resource) {
|
|
39457
|
-
if (recordCount > LARGE_BATCH_WARNING_THRESHOLD) {
|
|
39458
|
-
logger4.warn(`Large batch ${operation2} operation detected`, {
|
|
39459
|
-
requestId,
|
|
39460
|
-
resource,
|
|
39461
|
-
recordCount,
|
|
39462
|
-
warningThreshold: LARGE_BATCH_WARNING_THRESHOLD,
|
|
39463
|
-
estimatedTimeoutRisk: "high",
|
|
39464
|
-
recommendation: "Consider splitting the batch into smaller requests to avoid Lambda timeout (15 min limit)"
|
|
39465
|
-
});
|
|
39519
|
+
function rangeBounds(sortField, filter) {
|
|
39520
|
+
const { operator, type } = filter.parsed;
|
|
39521
|
+
const { encoded, exact } = encodeValueForShadowSK(filter.value, type, operator);
|
|
39522
|
+
const skValue = `${sortField}#${encoded}`;
|
|
39523
|
+
const afterValue = `${skValue}#id#~`;
|
|
39524
|
+
const beforeValue = `${skValue}#id#`;
|
|
39525
|
+
switch (operator) {
|
|
39526
|
+
case "$gt":
|
|
39527
|
+
return { low: exact ? afterValue : beforeValue };
|
|
39528
|
+
case "$gte":
|
|
39529
|
+
return { low: beforeValue };
|
|
39530
|
+
case "$lt":
|
|
39531
|
+
return { high: exact ? beforeValue : afterValue };
|
|
39532
|
+
case "$lte":
|
|
39533
|
+
return { high: afterValue };
|
|
39534
|
+
default:
|
|
39535
|
+
return {};
|
|
39466
39536
|
}
|
|
39467
39537
|
}
|
|
39468
|
-
function
|
|
39469
|
-
const
|
|
39470
|
-
const
|
|
39471
|
-
|
|
39472
|
-
|
|
39473
|
-
|
|
39474
|
-
|
|
39475
|
-
remainingMs,
|
|
39476
|
-
risk,
|
|
39477
|
-
utilizationPercent
|
|
39478
|
-
};
|
|
39479
|
-
}
|
|
39480
|
-
function logPreparationTimeoutRisk(requestId, resource, totalRecords, chunkCount, riskInfo) {
|
|
39481
|
-
logger4.info("Records prepared for chunk execution", {
|
|
39482
|
-
requestId,
|
|
39483
|
-
resource,
|
|
39484
|
-
totalRecords,
|
|
39485
|
-
chunkCount,
|
|
39486
|
-
preparationTimeMs: riskInfo.elapsedMs,
|
|
39487
|
-
remainingTimeMs: riskInfo.remainingMs,
|
|
39488
|
-
timeoutRisk: riskInfo.risk
|
|
39489
|
-
});
|
|
39490
|
-
if (riskInfo.risk === "high") {
|
|
39491
|
-
logger4.warn("High timeout risk detected during preparation phase", {
|
|
39492
|
-
requestId,
|
|
39493
|
-
resource,
|
|
39494
|
-
preparationElapsedMs: riskInfo.elapsedMs,
|
|
39495
|
-
remainingTimeMs: riskInfo.remainingMs,
|
|
39496
|
-
lambdaTimeoutMs: LAMBDA_TIMEOUT_MS,
|
|
39497
|
-
recommendation: "Consider reducing batch size or optimizing preparation logic"
|
|
39498
|
-
});
|
|
39499
|
-
}
|
|
39538
|
+
function findComplementaryBound(primary, parsedFilters) {
|
|
39539
|
+
const op2 = primary.parsed.operator;
|
|
39540
|
+
const wanted = LOWER_BOUND_OPERATORS.has(op2) ? UPPER_BOUND_OPERATORS : UPPER_BOUND_OPERATORS.has(op2) ? LOWER_BOUND_OPERATORS : void 0;
|
|
39541
|
+
if (!wanted) return void 0;
|
|
39542
|
+
return parsedFilters.find(
|
|
39543
|
+
(f5) => f5 !== primary && f5.parsed.field === primary.parsed.field && wanted.has(f5.parsed.operator)
|
|
39544
|
+
);
|
|
39500
39545
|
}
|
|
39501
|
-
function
|
|
39502
|
-
|
|
39503
|
-
logger4.info(`${operation2} completed`, {
|
|
39504
|
-
requestId,
|
|
39505
|
-
resource,
|
|
39506
|
-
requested,
|
|
39507
|
-
succeeded,
|
|
39508
|
-
totalFailed: failed,
|
|
39509
|
-
totalExecutionTimeMs: riskInfo.elapsedMs,
|
|
39510
|
-
totalExecutionTimeSeconds: totalElapsedSeconds,
|
|
39511
|
-
lambdaTimeoutMs: LAMBDA_TIMEOUT_MS,
|
|
39512
|
-
timeoutUtilization: `${riskInfo.utilizationPercent}%`,
|
|
39513
|
-
...additionalInfo
|
|
39514
|
-
});
|
|
39546
|
+
function fieldUpperBound(sortField) {
|
|
39547
|
+
return `${sortField}$`;
|
|
39515
39548
|
}
|
|
39516
|
-
function
|
|
39517
|
-
|
|
39518
|
-
|
|
39519
|
-
|
|
39520
|
-
|
|
39521
|
-
totalRequested: requested,
|
|
39522
|
-
successCount: succeeded,
|
|
39523
|
-
failedCount: failed,
|
|
39524
|
-
failureRate: `${failureRate}%`,
|
|
39525
|
-
errorCodes: [...new Set(errorCodes)],
|
|
39526
|
-
...additionalInfo
|
|
39527
|
-
});
|
|
39549
|
+
function rangeCondition(base, low, high) {
|
|
39550
|
+
return {
|
|
39551
|
+
keyConditionExpression: "PK = :pk AND SK BETWEEN :skLow AND :skHigh",
|
|
39552
|
+
expressionAttributeValues: { ...base, ":skLow": low, ":skHigh": high }
|
|
39553
|
+
};
|
|
39528
39554
|
}
|
|
39529
|
-
|
|
39530
|
-
|
|
39531
|
-
"
|
|
39532
|
-
|
|
39533
|
-
|
|
39534
|
-
logger4 = createLogger({ service: "records-lambda" });
|
|
39535
|
-
__name(logLargeBatchWarning, "logLargeBatchWarning");
|
|
39536
|
-
__name(calculateTimeoutRisk, "calculateTimeoutRisk");
|
|
39537
|
-
__name(logPreparationTimeoutRisk, "logPreparationTimeoutRisk");
|
|
39538
|
-
__name(logBulkOperationComplete, "logBulkOperationComplete");
|
|
39539
|
-
__name(logPartialFailure, "logPartialFailure");
|
|
39540
|
-
}
|
|
39541
|
-
});
|
|
39542
|
-
|
|
39543
|
-
// src/server/utils/chunking.ts
|
|
39544
|
-
function calculateChunks(records, getItemCount) {
|
|
39545
|
-
const chunks = [];
|
|
39546
|
-
const itemCounts = [];
|
|
39547
|
-
let currentChunk = [];
|
|
39548
|
-
let currentItemCount = 0;
|
|
39549
|
-
for (const record of records) {
|
|
39550
|
-
const itemCount = getItemCount(record);
|
|
39551
|
-
if (itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS) {
|
|
39552
|
-
const errorMsg = `Single record exceeds ${DYNAMODB_TRANSACT_WRITE_MAX_ITEMS} items limit: ${itemCount} items`;
|
|
39553
|
-
logger5.error("Chunk validation failed", {
|
|
39554
|
-
itemCount,
|
|
39555
|
-
limit: DYNAMODB_TRANSACT_WRITE_MAX_ITEMS
|
|
39556
|
-
});
|
|
39557
|
-
throw new Error(errorMsg);
|
|
39558
|
-
}
|
|
39559
|
-
if (currentItemCount + itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS) {
|
|
39560
|
-
if (currentChunk.length > 0) {
|
|
39561
|
-
chunks.push(currentChunk);
|
|
39562
|
-
itemCounts.push(currentItemCount);
|
|
39563
|
-
}
|
|
39564
|
-
currentChunk = [record];
|
|
39565
|
-
currentItemCount = itemCount;
|
|
39566
|
-
} else {
|
|
39567
|
-
currentChunk.push(record);
|
|
39568
|
-
currentItemCount += itemCount;
|
|
39569
|
-
}
|
|
39570
|
-
}
|
|
39571
|
-
if (currentChunk.length > 0) {
|
|
39572
|
-
chunks.push(currentChunk);
|
|
39573
|
-
itemCounts.push(currentItemCount);
|
|
39555
|
+
function encodeValueForShadowSK(value, type, operator) {
|
|
39556
|
+
const config = getShadowConfig();
|
|
39557
|
+
if (type === "number" || typeof value === "number") {
|
|
39558
|
+
const num = Number(value);
|
|
39559
|
+
return { encoded: formatFieldValue2("number", num, config), exact: false };
|
|
39574
39560
|
}
|
|
39575
|
-
|
|
39576
|
-
|
|
39577
|
-
|
|
39578
|
-
itemCounts,
|
|
39579
|
-
minItemsPerChunk: itemCounts.length > 0 ? Math.min(...itemCounts) : 0,
|
|
39580
|
-
maxItemsPerChunk: itemCounts.length > 0 ? Math.max(...itemCounts) : 0,
|
|
39581
|
-
avgItemsPerChunk: itemCounts.length > 0 ? Math.round(itemCounts.reduce((sum, count) => sum + count, 0) / itemCounts.length) : 0
|
|
39582
|
-
});
|
|
39583
|
-
return { chunks, itemCounts };
|
|
39584
|
-
}
|
|
39585
|
-
async function executeChunks(chunks, executeChunk, getRecordId) {
|
|
39586
|
-
const successRecords = [];
|
|
39587
|
-
const failedIds = [];
|
|
39588
|
-
const errors = [];
|
|
39589
|
-
const totalRecords = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
39590
|
-
const executionStartTime = Date.now();
|
|
39591
|
-
logger5.info("Starting chunk execution", {
|
|
39592
|
-
totalChunks: chunks.length,
|
|
39593
|
-
totalRecords
|
|
39594
|
-
});
|
|
39595
|
-
for (let i5 = 0; i5 < chunks.length; i5++) {
|
|
39596
|
-
const chunk = chunks[i5];
|
|
39597
|
-
const chunkStartTime = Date.now();
|
|
39598
|
-
try {
|
|
39599
|
-
logger5.debug(`Executing chunk ${i5 + 1}/${chunks.length}`, {
|
|
39600
|
-
chunkIndex: i5,
|
|
39601
|
-
recordCount: chunk.length
|
|
39602
|
-
});
|
|
39603
|
-
const successfulRecords = await executeChunk(chunk);
|
|
39604
|
-
successRecords.push(...successfulRecords);
|
|
39605
|
-
const chunkDuration = Date.now() - chunkStartTime;
|
|
39606
|
-
logger5.info(`Chunk ${i5 + 1}/${chunks.length} succeeded`, {
|
|
39607
|
-
chunkIndex: i5,
|
|
39608
|
-
recordCount: chunk.length,
|
|
39609
|
-
durationMs: chunkDuration
|
|
39610
|
-
});
|
|
39611
|
-
} catch (error2) {
|
|
39612
|
-
const chunkDuration = Date.now() - chunkStartTime;
|
|
39613
|
-
const errorMessage = error2 instanceof Error ? error2.message : "Unknown error";
|
|
39614
|
-
const errorCode = getErrorCode(error2);
|
|
39615
|
-
logger5.error(`Chunk ${i5 + 1}/${chunks.length} failed`, {
|
|
39616
|
-
chunkIndex: i5,
|
|
39617
|
-
recordCount: chunk.length,
|
|
39618
|
-
durationMs: chunkDuration,
|
|
39619
|
-
error: errorMessage,
|
|
39620
|
-
errorCode
|
|
39621
|
-
});
|
|
39622
|
-
for (const record of chunk) {
|
|
39623
|
-
const recordId = getRecordId(record);
|
|
39624
|
-
failedIds.push(recordId);
|
|
39625
|
-
errors.push({
|
|
39626
|
-
id: recordId,
|
|
39627
|
-
code: errorCode,
|
|
39628
|
-
message: errorMessage
|
|
39629
|
-
});
|
|
39630
|
-
}
|
|
39631
|
-
}
|
|
39561
|
+
if (type === "boolean" || typeof value === "boolean") {
|
|
39562
|
+
const bool = typeof value === "boolean" ? value : String(value).toLowerCase() === "true";
|
|
39563
|
+
return { encoded: formatFieldValue2("boolean", bool, config), exact: true };
|
|
39632
39564
|
}
|
|
39633
|
-
const
|
|
39634
|
-
|
|
39635
|
-
|
|
39636
|
-
totalRecords,
|
|
39637
|
-
successCount: successRecords.length,
|
|
39638
|
-
failedCount: failedIds.length,
|
|
39639
|
-
totalExecutionTimeMs: totalExecutionTime,
|
|
39640
|
-
avgTimePerChunkMs: chunks.length > 0 ? Math.round(totalExecutionTime / chunks.length) : 0
|
|
39641
|
-
});
|
|
39642
|
-
if (failedIds.length > 0) {
|
|
39643
|
-
logger5.warn("Partial failure detected in chunk execution", {
|
|
39644
|
-
totalRecords,
|
|
39645
|
-
successCount: successRecords.length,
|
|
39646
|
-
failedCount: failedIds.length,
|
|
39647
|
-
failureRate: `${Math.round(failedIds.length / totalRecords * 100)}%`,
|
|
39648
|
-
failedIds: failedIds.slice(0, 10),
|
|
39649
|
-
// 最初の10件のみログ出力
|
|
39650
|
-
errorSummary: errors.slice(0, 5).map((e5) => ({
|
|
39651
|
-
id: e5.id,
|
|
39652
|
-
code: e5.code,
|
|
39653
|
-
message: e5.message.substring(0, 100)
|
|
39654
|
-
// メッセージを100文字に制限
|
|
39655
|
-
}))
|
|
39656
|
-
});
|
|
39565
|
+
const str = String(value);
|
|
39566
|
+
if (operator !== "$starts" && (type === "date" || inferFieldType(str) === "datetime")) {
|
|
39567
|
+
return { encoded: formatFieldValue2("datetime", str, config), exact: true };
|
|
39657
39568
|
}
|
|
39569
|
+
const encoded = formatFieldValue2("string", str, config);
|
|
39570
|
+
const bytes = new TextEncoder().encode(str).length;
|
|
39658
39571
|
return {
|
|
39659
|
-
|
|
39660
|
-
|
|
39661
|
-
errors
|
|
39572
|
+
encoded,
|
|
39573
|
+
exact: encoded === escapeString2(str) && bytes < config.stringMaxBytes - 3
|
|
39662
39574
|
};
|
|
39663
39575
|
}
|
|
39664
|
-
|
|
39665
|
-
|
|
39666
|
-
|
|
39667
|
-
return error2.name;
|
|
39668
|
-
}
|
|
39669
|
-
if ("code" in error2 && typeof error2.code === "string") {
|
|
39670
|
-
return error2.code;
|
|
39671
|
-
}
|
|
39672
|
-
}
|
|
39673
|
-
return "TRANSACTION_FAILED";
|
|
39674
|
-
}
|
|
39675
|
-
var logger5;
|
|
39676
|
-
var init_chunking = __esm({
|
|
39677
|
-
"src/server/utils/chunking.ts"() {
|
|
39678
|
-
"use strict";
|
|
39679
|
-
init_shared();
|
|
39680
|
-
logger5 = createLogger({ service: "records-lambda" });
|
|
39681
|
-
__name(calculateChunks, "calculateChunks");
|
|
39682
|
-
__name(executeChunks, "executeChunks");
|
|
39683
|
-
__name(getErrorCode, "getErrorCode");
|
|
39684
|
-
}
|
|
39685
|
-
});
|
|
39686
|
-
|
|
39687
|
-
// src/server/utils/cost-tracker.ts
|
|
39688
|
-
var CostTracker;
|
|
39689
|
-
var init_cost_tracker = __esm({
|
|
39690
|
-
"src/server/utils/cost-tracker.ts"() {
|
|
39576
|
+
var KEY_CONDITION_OPERATORS, LOWER_BOUND_OPERATORS, UPPER_BOUND_OPERATORS;
|
|
39577
|
+
var init_keyCondition = __esm({
|
|
39578
|
+
"src/server/operations/find/keyCondition.ts"() {
|
|
39691
39579
|
"use strict";
|
|
39692
|
-
|
|
39693
|
-
|
|
39694
|
-
|
|
39695
|
-
|
|
39696
|
-
|
|
39697
|
-
|
|
39698
|
-
|
|
39699
|
-
|
|
39700
|
-
|
|
39701
|
-
|
|
39702
|
-
* DynamoDB操作のConsumedCapacityを累積します。
|
|
39703
|
-
* undefinedが渡された場合は何もしません(エラーにしない)。
|
|
39704
|
-
*
|
|
39705
|
-
* AWS SDKのConsumedCapacityは以下のフィールドを持ちます:
|
|
39706
|
-
* - CapacityUnits: 総キャパシティユニット(RCU + WCU)
|
|
39707
|
-
* - ReadCapacityUnits: 読み取りキャパシティユニット
|
|
39708
|
-
* - WriteCapacityUnits: 書き込みキャパシティユニット
|
|
39709
|
-
*
|
|
39710
|
-
* このメソッドはReadCapacityUnitsとWriteCapacityUnitsを優先的に使用し、
|
|
39711
|
-
* 存在しない場合はCapacityUnitsを読み取りとして扱います。
|
|
39712
|
-
*
|
|
39713
|
-
* @param consumedCapacity - DynamoDB操作のConsumedCapacity
|
|
39714
|
-
*/
|
|
39715
|
-
add(consumedCapacity) {
|
|
39716
|
-
if (!consumedCapacity) {
|
|
39717
|
-
return;
|
|
39718
|
-
}
|
|
39719
|
-
const rcu = consumedCapacity.ReadCapacityUnits ?? 0;
|
|
39720
|
-
const wcu = consumedCapacity.WriteCapacityUnits ?? 0;
|
|
39721
|
-
this.totalRCU += rcu;
|
|
39722
|
-
this.totalWCU += wcu;
|
|
39723
|
-
this.operationCount += 1;
|
|
39724
|
-
}
|
|
39725
|
-
/**
|
|
39726
|
-
* 集計結果を取得
|
|
39727
|
-
*
|
|
39728
|
-
* これまでに追加されたConsumedCapacityの集計結果を返します。
|
|
39729
|
-
*
|
|
39730
|
-
* @returns 集計されたコスト情報
|
|
39731
|
-
*/
|
|
39732
|
-
getAggregated() {
|
|
39733
|
-
return {
|
|
39734
|
-
totalRCU: this.totalRCU,
|
|
39735
|
-
totalWCU: this.totalWCU,
|
|
39736
|
-
operationCount: this.operationCount
|
|
39737
|
-
};
|
|
39738
|
-
}
|
|
39739
|
-
/**
|
|
39740
|
-
* リセット
|
|
39741
|
-
*
|
|
39742
|
-
* 累積されたコスト情報をクリアします。
|
|
39743
|
-
*/
|
|
39744
|
-
reset() {
|
|
39745
|
-
this.totalRCU = 0;
|
|
39746
|
-
this.totalWCU = 0;
|
|
39747
|
-
this.operationCount = 0;
|
|
39748
|
-
}
|
|
39749
|
-
};
|
|
39580
|
+
init_shadow();
|
|
39581
|
+
KEY_CONDITION_OPERATORS = /* @__PURE__ */ new Set(["$eq", "$gt", "$gte", "$lt", "$lte", "$starts"]);
|
|
39582
|
+
__name(buildKeyCondition, "buildKeyCondition");
|
|
39583
|
+
LOWER_BOUND_OPERATORS = /* @__PURE__ */ new Set(["$gt", "$gte"]);
|
|
39584
|
+
UPPER_BOUND_OPERATORS = /* @__PURE__ */ new Set(["$lt", "$lte"]);
|
|
39585
|
+
__name(rangeBounds, "rangeBounds");
|
|
39586
|
+
__name(findComplementaryBound, "findComplementaryBound");
|
|
39587
|
+
__name(fieldUpperBound, "fieldUpperBound");
|
|
39588
|
+
__name(rangeCondition, "rangeCondition");
|
|
39589
|
+
__name(encodeValueForShadowSK, "encodeValueForShadowSK");
|
|
39750
39590
|
}
|
|
39751
39591
|
});
|
|
39752
39592
|
|
|
@@ -39757,18 +39597,14 @@ function parseFilterField(fieldKey) {
|
|
|
39757
39597
|
return { field: parts[0], operator: "$eq", type: "string" };
|
|
39758
39598
|
}
|
|
39759
39599
|
if (parts.length === 2) {
|
|
39600
|
+
assertSupportedOperator(parts[1]);
|
|
39760
39601
|
const operator = parts[1];
|
|
39761
|
-
if (!isValidOperator(operator)) {
|
|
39762
|
-
throw new Error(`Invalid filter operator: ${parts[1]}`);
|
|
39763
|
-
}
|
|
39764
39602
|
return { field: parts[0], operator, type: "string" };
|
|
39765
39603
|
}
|
|
39766
39604
|
if (parts.length === 3) {
|
|
39605
|
+
assertSupportedOperator(parts[1]);
|
|
39767
39606
|
const operator = parts[1];
|
|
39768
39607
|
const type = parts[2];
|
|
39769
|
-
if (!isValidOperator(operator)) {
|
|
39770
|
-
throw new Error(`Invalid filter operator: ${parts[1]}`);
|
|
39771
|
-
}
|
|
39772
39608
|
if (!isValidType(type)) {
|
|
39773
39609
|
throw new Error(`Invalid filter type: ${parts[2]}`);
|
|
39774
39610
|
}
|
|
@@ -39789,11 +39625,18 @@ function isValidOperator(operator) {
|
|
|
39789
39625
|
"$starts",
|
|
39790
39626
|
"$ends",
|
|
39791
39627
|
"$contains",
|
|
39792
|
-
"$regex",
|
|
39793
39628
|
"$exists",
|
|
39794
39629
|
"$near"
|
|
39795
39630
|
].includes(operator);
|
|
39796
39631
|
}
|
|
39632
|
+
function assertSupportedOperator(operator) {
|
|
39633
|
+
if (operator === "$regex") {
|
|
39634
|
+
throw new Error("Invalid filter operator: $regex is not supported (use $contains or $starts)");
|
|
39635
|
+
}
|
|
39636
|
+
if (!isValidOperator(operator)) {
|
|
39637
|
+
throw new Error(`Invalid filter operator: ${operator}`);
|
|
39638
|
+
}
|
|
39639
|
+
}
|
|
39797
39640
|
function isValidType(type) {
|
|
39798
39641
|
return ["string", "number", "date", "boolean"].includes(type);
|
|
39799
39642
|
}
|
|
@@ -39802,6 +39645,7 @@ var init_filter = __esm({
|
|
|
39802
39645
|
"use strict";
|
|
39803
39646
|
__name(parseFilterField, "parseFilterField");
|
|
39804
39647
|
__name(isValidOperator, "isValidOperator");
|
|
39648
|
+
__name(assertSupportedOperator, "assertSupportedOperator");
|
|
39805
39649
|
__name(isValidType, "isValidType");
|
|
39806
39650
|
}
|
|
39807
39651
|
});
|
|
@@ -39874,7 +39718,7 @@ function parseFilters(filter) {
|
|
|
39874
39718
|
parsedFilters.push({ parsed: withInferredType(parsed, fieldKey, value), value });
|
|
39875
39719
|
}
|
|
39876
39720
|
} catch (error2) {
|
|
39877
|
-
|
|
39721
|
+
logger3.error("Invalid filter field syntax", {
|
|
39878
39722
|
fieldKey,
|
|
39879
39723
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
39880
39724
|
});
|
|
@@ -39917,8 +39761,6 @@ function matchesAllFilters(record, parsedFilters) {
|
|
|
39917
39761
|
return typeof recordValue === "string" && typeof filterValue === "string" && recordValue.endsWith(filterValue);
|
|
39918
39762
|
case "$contains":
|
|
39919
39763
|
return typeof recordValue === "string" && typeof filterValue === "string" && recordValue.includes(filterValue);
|
|
39920
|
-
case "$regex":
|
|
39921
|
-
return typeof recordValue === "string" && typeof filterValue === "string" && recordValue.includes(filterValue);
|
|
39922
39764
|
case "$exists":
|
|
39923
39765
|
return filterValue ? recordValue !== void 0 && recordValue !== null : recordValue === void 0 || recordValue === null;
|
|
39924
39766
|
default:
|
|
@@ -39943,7 +39785,7 @@ function detectNearQuery(filter) {
|
|
|
39943
39785
|
}
|
|
39944
39786
|
return null;
|
|
39945
39787
|
}
|
|
39946
|
-
var
|
|
39788
|
+
var logger3;
|
|
39947
39789
|
var init_utils6 = __esm({
|
|
39948
39790
|
"src/server/operations/find/utils.ts"() {
|
|
39949
39791
|
"use strict";
|
|
@@ -39952,7 +39794,7 @@ var init_utils6 = __esm({
|
|
|
39952
39794
|
init_shadow();
|
|
39953
39795
|
init_filter();
|
|
39954
39796
|
init_validation2();
|
|
39955
|
-
|
|
39797
|
+
logger3 = createLogger({
|
|
39956
39798
|
service: "find-utils",
|
|
39957
39799
|
level: process.env.LOG_LEVEL || "info"
|
|
39958
39800
|
});
|
|
@@ -39966,99 +39808,81 @@ var init_utils6 = __esm({
|
|
|
39966
39808
|
}
|
|
39967
39809
|
});
|
|
39968
39810
|
|
|
39969
|
-
// src/server/utils/
|
|
39970
|
-
function
|
|
39971
|
-
const { id, ...rest } = filter ?? {};
|
|
39972
|
-
if (typeof id === "string") {
|
|
39973
|
-
return { id, rest };
|
|
39974
|
-
}
|
|
39975
|
-
if (typeof id === "object" && id !== null && "$in" in id) {
|
|
39976
|
-
return { ids: (id.$in ?? []).slice(), rest };
|
|
39977
|
-
}
|
|
39978
|
-
return { rest: filter ?? {} };
|
|
39979
|
-
}
|
|
39980
|
-
function conditionOf(rest) {
|
|
39981
|
-
return Object.keys(rest).length > 0 ? rest : void 0;
|
|
39982
|
-
}
|
|
39983
|
-
function conditionMatcher(condition) {
|
|
39984
|
-
if (!condition || Object.keys(condition).length === 0) {
|
|
39985
|
-
return () => true;
|
|
39986
|
-
}
|
|
39987
|
-
const parsed = parseFilters(condition);
|
|
39988
|
-
return (record) => matchesAllFilters(record, parsed);
|
|
39989
|
-
}
|
|
39990
|
-
var init_idFilter = __esm({
|
|
39991
|
-
"src/server/utils/idFilter.ts"() {
|
|
39992
|
-
"use strict";
|
|
39993
|
-
init_utils6();
|
|
39994
|
-
__name(splitIdFilter, "splitIdFilter");
|
|
39995
|
-
__name(conditionOf, "conditionOf");
|
|
39996
|
-
__name(conditionMatcher, "conditionMatcher");
|
|
39997
|
-
}
|
|
39998
|
-
});
|
|
39999
|
-
|
|
40000
|
-
// src/server/utils/revision.ts
|
|
40001
|
-
function revisionOf(item) {
|
|
40002
|
-
const rev = item[REVISION_ATTRIBUTE];
|
|
40003
|
-
return typeof rev === "number" ? rev : void 0;
|
|
40004
|
-
}
|
|
40005
|
-
function nextRevision(current) {
|
|
40006
|
-
return (current ?? 0) + 1;
|
|
40007
|
-
}
|
|
40008
|
-
function notExistsCondition() {
|
|
40009
|
-
return { ConditionExpression: "attribute_not_exists(PK)" };
|
|
40010
|
-
}
|
|
40011
|
-
function unchangedCondition(revision) {
|
|
40012
|
-
const names = { "#rev": REVISION_ATTRIBUTE };
|
|
40013
|
-
if (revision === void 0) {
|
|
40014
|
-
return {
|
|
40015
|
-
ConditionExpression: "attribute_exists(PK) AND attribute_not_exists(#rev)",
|
|
40016
|
-
ExpressionAttributeNames: names
|
|
40017
|
-
};
|
|
40018
|
-
}
|
|
40019
|
-
return {
|
|
40020
|
-
ConditionExpression: "#rev = :rev",
|
|
40021
|
-
ExpressionAttributeNames: names,
|
|
40022
|
-
ExpressionAttributeValues: { ":rev": revision }
|
|
40023
|
-
};
|
|
40024
|
-
}
|
|
40025
|
-
function isWriteConflict(error2) {
|
|
40026
|
-
if (!error2 || typeof error2 !== "object") return false;
|
|
40027
|
-
const { name, CancellationReasons } = error2;
|
|
40028
|
-
if (name === "TransactionConflictException") return true;
|
|
40029
|
-
if (name !== "TransactionCanceledException" || !Array.isArray(CancellationReasons)) return false;
|
|
40030
|
-
const codes = CancellationReasons.map((r5) => r5?.Code).filter((c5) => c5 && c5 !== "None");
|
|
40031
|
-
return codes.length > 0 && codes.every((c5) => c5 === "ConditionalCheckFailed" || c5 === "TransactionConflict");
|
|
40032
|
-
}
|
|
40033
|
-
function sleep3(ms) {
|
|
39811
|
+
// src/server/utils/batchGet.ts
|
|
39812
|
+
function sleep2(ms) {
|
|
40034
39813
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
40035
39814
|
}
|
|
40036
|
-
async function
|
|
40037
|
-
|
|
40038
|
-
|
|
40039
|
-
|
|
40040
|
-
|
|
40041
|
-
|
|
40042
|
-
|
|
40043
|
-
|
|
40044
|
-
|
|
40045
|
-
|
|
39815
|
+
async function batchGetAll(keys, { consistentRead, costTracker, requestId, baseDelayMs = 50 }) {
|
|
39816
|
+
const unique = Array.from(new Map(keys.map((k5) => [`${k5.PK}\0${k5.SK}`, k5])).values());
|
|
39817
|
+
if (unique.length === 0) {
|
|
39818
|
+
return [];
|
|
39819
|
+
}
|
|
39820
|
+
const dbClient2 = getDBClient();
|
|
39821
|
+
const tableName = getTableName();
|
|
39822
|
+
const records = [];
|
|
39823
|
+
for (let i5 = 0; i5 < unique.length; i5 += BATCH_GET_MAX_KEYS) {
|
|
39824
|
+
let pending = unique.slice(i5, i5 + BATCH_GET_MAX_KEYS);
|
|
39825
|
+
for (let attempt = 0; pending.length > 0; attempt++) {
|
|
39826
|
+
if (attempt > BATCH_GET_MAX_RETRIES) {
|
|
39827
|
+
logger4.error("BatchGetItem \u306E UnprocessedKeys \u304C\u89E3\u6D88\u3057\u306A\u304B\u3063\u305F", {
|
|
39828
|
+
requestId,
|
|
39829
|
+
unprocessed: pending.length,
|
|
39830
|
+
attempts: attempt
|
|
39831
|
+
});
|
|
39832
|
+
throw new AppError(
|
|
39833
|
+
"INTERNAL_ERROR" /* INTERNAL_ERROR */,
|
|
39834
|
+
"BatchGetItem still has unprocessed keys after retries",
|
|
39835
|
+
503,
|
|
39836
|
+
{ unprocessed: pending.length }
|
|
39837
|
+
);
|
|
39838
|
+
}
|
|
39839
|
+
if (attempt > 0) {
|
|
39840
|
+
await sleep2(baseDelayMs * 2 ** (attempt - 1) * (0.5 + Math.random() / 2));
|
|
39841
|
+
}
|
|
39842
|
+
const keysToGet = pending;
|
|
39843
|
+
const result = await executeDynamoDBOperation(
|
|
39844
|
+
() => dbClient2.send(
|
|
39845
|
+
new import_lib_dynamodb2.BatchGetCommand({
|
|
39846
|
+
RequestItems: {
|
|
39847
|
+
[tableName]: {
|
|
39848
|
+
Keys: keysToGet,
|
|
39849
|
+
ConsistentRead: consistentRead
|
|
39850
|
+
}
|
|
39851
|
+
},
|
|
39852
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
39853
|
+
})
|
|
39854
|
+
),
|
|
39855
|
+
"BatchGetItem"
|
|
39856
|
+
);
|
|
39857
|
+
if (costTracker) {
|
|
39858
|
+
const capacity = result.ConsumedCapacity;
|
|
39859
|
+
if (Array.isArray(capacity)) {
|
|
39860
|
+
capacity.forEach((c5) => costTracker.add(c5));
|
|
39861
|
+
} else {
|
|
39862
|
+
costTracker.add(capacity);
|
|
39863
|
+
}
|
|
39864
|
+
}
|
|
39865
|
+
records.push(...result.Responses?.[tableName] ?? []);
|
|
39866
|
+
pending = result.UnprocessedKeys?.[tableName]?.Keys ?? [];
|
|
40046
39867
|
}
|
|
40047
39868
|
}
|
|
39869
|
+
return records;
|
|
40048
39870
|
}
|
|
40049
|
-
var
|
|
40050
|
-
var
|
|
40051
|
-
"src/server/utils/
|
|
39871
|
+
var import_lib_dynamodb2, logger4, BATCH_GET_MAX_KEYS, BATCH_GET_MAX_RETRIES;
|
|
39872
|
+
var init_batchGet = __esm({
|
|
39873
|
+
"src/server/utils/batchGet.ts"() {
|
|
40052
39874
|
"use strict";
|
|
40053
|
-
|
|
40054
|
-
|
|
40055
|
-
|
|
40056
|
-
|
|
40057
|
-
|
|
40058
|
-
|
|
40059
|
-
|
|
40060
|
-
|
|
40061
|
-
|
|
39875
|
+
import_lib_dynamodb2 = __toESM(require_dist_cjs22(), 1);
|
|
39876
|
+
init_shared();
|
|
39877
|
+
init_dynamodb3();
|
|
39878
|
+
logger4 = createLogger({
|
|
39879
|
+
service: "batch-get",
|
|
39880
|
+
level: process.env.LOG_LEVEL || "info"
|
|
39881
|
+
});
|
|
39882
|
+
BATCH_GET_MAX_KEYS = 100;
|
|
39883
|
+
BATCH_GET_MAX_RETRIES = 8;
|
|
39884
|
+
__name(sleep2, "sleep");
|
|
39885
|
+
__name(batchGetAll, "batchGetAll");
|
|
40062
39886
|
}
|
|
40063
39887
|
});
|
|
40064
39888
|
|
|
@@ -40361,12 +40185,12 @@ function getScanWarnThreshold() {
|
|
|
40361
40185
|
const value = Number(raw);
|
|
40362
40186
|
return Number.isInteger(value) && value >= 1 ? value : DEFAULT_SCAN_WARN_THRESHOLD;
|
|
40363
40187
|
}
|
|
40364
|
-
var
|
|
40188
|
+
var logger5, SPARSE_SCAN_EVENT, DEFAULT_SCAN_WARN_THRESHOLD, ScanWatcher;
|
|
40365
40189
|
var init_scanWarning = __esm({
|
|
40366
40190
|
"src/server/utils/scanWarning.ts"() {
|
|
40367
40191
|
"use strict";
|
|
40368
40192
|
init_shared();
|
|
40369
|
-
|
|
40193
|
+
logger5 = createLogger({ service: "scan-warning", level: "warn" });
|
|
40370
40194
|
SPARSE_SCAN_EVENT = "SPARSE_SCAN";
|
|
40371
40195
|
DEFAULT_SCAN_WARN_THRESHOLD = 5e3;
|
|
40372
40196
|
__name(getScanWarnThreshold, "getScanWarnThreshold");
|
|
@@ -40386,7 +40210,7 @@ var init_scanWarning = __esm({
|
|
|
40386
40210
|
this.scanned += count;
|
|
40387
40211
|
if (!this.warned && this.scanned >= this.threshold) {
|
|
40388
40212
|
this.warned = true;
|
|
40389
|
-
|
|
40213
|
+
logger5.warn(
|
|
40390
40214
|
`${SPARSE_SCAN_EVENT}: 1\u30EA\u30AF\u30A8\u30B9\u30C8\u3067 ${this.scanned} \u4EF6\u4EE5\u4E0A\u3092\u8AAD\u307F\u307E\u3057\u305F\u3002\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u30FB\u30B9\u30AD\u30FC\u30DE\u30FB\u30ED\u30B8\u30C3\u30AF\u306E\u898B\u76F4\u3057\u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044\uFF08docs/SCAN_WARNING.md\uFF09`,
|
|
40391
40215
|
{
|
|
40392
40216
|
event: SPARSE_SCAN_EVENT,
|
|
@@ -40410,7 +40234,7 @@ var init_scanWarning = __esm({
|
|
|
40410
40234
|
async function executeIdQuery(resource, normalizedParams, requestId) {
|
|
40411
40235
|
const { sort, pagination, parsedFilters } = normalizedParams;
|
|
40412
40236
|
const { perPage, nextToken } = pagination;
|
|
40413
|
-
|
|
40237
|
+
logger6.debug("Executing ID optimized query", {
|
|
40414
40238
|
requestId,
|
|
40415
40239
|
resource,
|
|
40416
40240
|
sort,
|
|
@@ -40463,7 +40287,7 @@ async function executeSpecificIdQuery(resource, targetId, requestId) {
|
|
|
40463
40287
|
costTracker.add(queryResult.ConsumedCapacity);
|
|
40464
40288
|
const mainRecords = queryResult.Items || [];
|
|
40465
40289
|
const items = mainRecords.map((item) => extractCleanRecord(item));
|
|
40466
|
-
|
|
40290
|
+
logger6.info("ID specific query succeeded", {
|
|
40467
40291
|
requestId,
|
|
40468
40292
|
resource,
|
|
40469
40293
|
targetId,
|
|
@@ -40495,7 +40319,7 @@ async function executeInQuery(resource, targetIds, sort, requestId) {
|
|
|
40495
40319
|
if (typeof aVal === "number" && typeof bVal === "number") return (aVal - bVal) * direction;
|
|
40496
40320
|
return String(aVal).localeCompare(String(bVal)) * direction;
|
|
40497
40321
|
});
|
|
40498
|
-
|
|
40322
|
+
logger6.info("ID $in query succeeded", {
|
|
40499
40323
|
requestId,
|
|
40500
40324
|
resource,
|
|
40501
40325
|
requestedCount: targetIds.length,
|
|
@@ -40571,7 +40395,7 @@ async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsed
|
|
|
40571
40395
|
queryResult.LastEvaluatedKey.PK,
|
|
40572
40396
|
queryResult.LastEvaluatedKey.SK
|
|
40573
40397
|
) : void 0;
|
|
40574
|
-
|
|
40398
|
+
logger6.info("ID all records query succeeded", {
|
|
40575
40399
|
requestId,
|
|
40576
40400
|
resource,
|
|
40577
40401
|
count: items.length,
|
|
@@ -40612,7 +40436,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
40612
40436
|
});
|
|
40613
40437
|
scan: while (true) {
|
|
40614
40438
|
if (++iterations > SCAN_MAX_ITERATIONS) {
|
|
40615
|
-
|
|
40439
|
+
logger6.error("executeAllRecordsQueryFullScan: \u6700\u5927\u53CD\u5FA9\u56DE\u6570\u3092\u8D85\u904E", {
|
|
40616
40440
|
requestId,
|
|
40617
40441
|
resource,
|
|
40618
40442
|
iterations
|
|
@@ -40660,7 +40484,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
40660
40484
|
}
|
|
40661
40485
|
const nextKeySignature = `${nextKey.PK}#${nextKey.SK}`;
|
|
40662
40486
|
if (nextKeySignature === previousKeySignature) {
|
|
40663
|
-
|
|
40487
|
+
logger6.error("executeAllRecordsQueryFullScan: \u540C\u4E00\u306ELastEvaluatedKey\u304C\u8FD4\u5374\u3055\u308C\u305F", {
|
|
40664
40488
|
requestId,
|
|
40665
40489
|
resource,
|
|
40666
40490
|
iterations
|
|
@@ -40677,7 +40501,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
40677
40501
|
chunkSize = Math.min(chunkSize * 2, SCAN_CHUNK_MAX);
|
|
40678
40502
|
}
|
|
40679
40503
|
const nextTokenValue = hasNextPage && lastReturned ? encodeNextToken(lastReturned.PK, lastReturned.SK) : void 0;
|
|
40680
|
-
|
|
40504
|
+
logger6.info("ID filtered scan query succeeded", {
|
|
40681
40505
|
requestId,
|
|
40682
40506
|
resource,
|
|
40683
40507
|
scanned,
|
|
@@ -40691,7 +40515,7 @@ async function executeAllRecordsQueryFullScan(resource, sort, perPage, nextToken
|
|
|
40691
40515
|
consumedCapacity: costTracker.getAggregated()
|
|
40692
40516
|
};
|
|
40693
40517
|
}
|
|
40694
|
-
var import_lib_dynamodb3,
|
|
40518
|
+
var import_lib_dynamodb3, logger6, SCAN_CHUNK_INITIAL, SCAN_CHUNK_MAX, SCAN_MAX_ITERATIONS;
|
|
40695
40519
|
var init_idQuery = __esm({
|
|
40696
40520
|
"src/server/operations/find/idQuery.ts"() {
|
|
40697
40521
|
"use strict";
|
|
@@ -40703,7 +40527,7 @@ var init_idQuery = __esm({
|
|
|
40703
40527
|
init_pagination();
|
|
40704
40528
|
init_scanWarning();
|
|
40705
40529
|
init_utils6();
|
|
40706
|
-
|
|
40530
|
+
logger6 = createLogger({
|
|
40707
40531
|
service: "id-query",
|
|
40708
40532
|
level: process.env.LOG_LEVEL || "info"
|
|
40709
40533
|
});
|
|
@@ -40721,7 +40545,7 @@ var init_idQuery = __esm({
|
|
|
40721
40545
|
|
|
40722
40546
|
// src/server/operations/find/nearQuery.ts
|
|
40723
40547
|
async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId) {
|
|
40724
|
-
|
|
40548
|
+
logger7.debug("Executing $near query", {
|
|
40725
40549
|
requestId,
|
|
40726
40550
|
resource,
|
|
40727
40551
|
fieldName,
|
|
@@ -40732,7 +40556,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
40732
40556
|
const searchFunction = /* @__PURE__ */ __name(async (geohashPrefix) => {
|
|
40733
40557
|
const dbClient2 = getDBClient();
|
|
40734
40558
|
const tableName = getTableName();
|
|
40735
|
-
|
|
40559
|
+
logger7.debug("Searching shadow records", {
|
|
40736
40560
|
requestId,
|
|
40737
40561
|
resource,
|
|
40738
40562
|
fieldName,
|
|
@@ -40783,7 +40607,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
40783
40607
|
previousKeySignature = nextKeySignature;
|
|
40784
40608
|
exclusiveStartKey = nextKey;
|
|
40785
40609
|
} while (exclusiveStartKey);
|
|
40786
|
-
|
|
40610
|
+
logger7.debug("Shadow records found", {
|
|
40787
40611
|
requestId,
|
|
40788
40612
|
resource,
|
|
40789
40613
|
geohashPrefix,
|
|
@@ -40794,7 +40618,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
40794
40618
|
const parts = sk.split("#id#");
|
|
40795
40619
|
return parts.length === 2 ? parts[1] : null;
|
|
40796
40620
|
}).filter((id) => id !== null);
|
|
40797
|
-
|
|
40621
|
+
logger7.debug("Main record IDs extracted", {
|
|
40798
40622
|
requestId,
|
|
40799
40623
|
resource,
|
|
40800
40624
|
geohashPrefix,
|
|
@@ -40804,14 +40628,14 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
40804
40628
|
mainRecordIds.map((id) => ({ PK: resource, SK: `id#${id}` })),
|
|
40805
40629
|
{ consistentRead: false, costTracker, requestId }
|
|
40806
40630
|
);
|
|
40807
|
-
|
|
40631
|
+
logger7.debug("Main records retrieved", {
|
|
40808
40632
|
requestId,
|
|
40809
40633
|
resource,
|
|
40810
40634
|
geohashPrefix,
|
|
40811
40635
|
count: validRecords.length
|
|
40812
40636
|
});
|
|
40813
40637
|
const cleanRecords = validRecords.map((record) => extractCleanRecord(record));
|
|
40814
|
-
|
|
40638
|
+
logger7.debug("Clean records extracted", {
|
|
40815
40639
|
requestId,
|
|
40816
40640
|
resource,
|
|
40817
40641
|
geohashPrefix,
|
|
@@ -40824,7 +40648,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
40824
40648
|
const config = minPrecisionOverride !== void 0 ? { ...DEFAULT_GEOHASH_CONFIG, minPrecision: minPrecisionOverride } : DEFAULT_GEOHASH_CONFIG;
|
|
40825
40649
|
const result = await executeNearSearch(nearQuery, fieldName, limit, searchFunction, config);
|
|
40826
40650
|
const items = result.documents;
|
|
40827
|
-
|
|
40651
|
+
logger7.info("$near query succeeded", {
|
|
40828
40652
|
requestId,
|
|
40829
40653
|
resource,
|
|
40830
40654
|
fieldName,
|
|
@@ -40842,7 +40666,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
40842
40666
|
consumedCapacity: costTracker.getAggregated()
|
|
40843
40667
|
};
|
|
40844
40668
|
}
|
|
40845
|
-
var import_lib_dynamodb4,
|
|
40669
|
+
var import_lib_dynamodb4, logger7;
|
|
40846
40670
|
var init_nearQuery = __esm({
|
|
40847
40671
|
"src/server/operations/find/nearQuery.ts"() {
|
|
40848
40672
|
"use strict";
|
|
@@ -40854,7 +40678,7 @@ var init_nearQuery = __esm({
|
|
|
40854
40678
|
init_cost_tracker();
|
|
40855
40679
|
init_dynamodb3();
|
|
40856
40680
|
init_scanWarning();
|
|
40857
|
-
|
|
40681
|
+
logger7 = createLogger({
|
|
40858
40682
|
service: "near-query",
|
|
40859
40683
|
level: process.env.LOG_LEVEL || "info"
|
|
40860
40684
|
});
|
|
@@ -40885,11 +40709,12 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
40885
40709
|
}
|
|
40886
40710
|
const optimizableFilter = findOptimizableFilter(sort.field, parsedFilters);
|
|
40887
40711
|
const isKeyConditionOptimized = optimizableFilter !== void 0 && KEY_CONDITION_OPERATORS.has(optimizableFilter.parsed.operator);
|
|
40712
|
+
const upperFilter = isKeyConditionOptimized ? findComplementaryBound(optimizableFilter, parsedFilters) : void 0;
|
|
40888
40713
|
const residualFilters = parsedFilters.filter(
|
|
40889
|
-
(f5) => !(isKeyConditionOptimized && f5 === optimizableFilter)
|
|
40714
|
+
(f5) => !(isKeyConditionOptimized && (f5 === optimizableFilter || f5 === upperFilter))
|
|
40890
40715
|
);
|
|
40891
40716
|
if (residualFilters.length > 0) {
|
|
40892
|
-
|
|
40717
|
+
logger8.debug("Residual filters detected, falling back to full scan", {
|
|
40893
40718
|
requestId,
|
|
40894
40719
|
resource,
|
|
40895
40720
|
sortField: sort.field,
|
|
@@ -40897,7 +40722,7 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
40897
40722
|
});
|
|
40898
40723
|
return executeFullScanQuery(resource, normalizedParams, costTracker, requestId);
|
|
40899
40724
|
}
|
|
40900
|
-
|
|
40725
|
+
logger8.debug("Executing shadow query", {
|
|
40901
40726
|
requestId,
|
|
40902
40727
|
resource,
|
|
40903
40728
|
sortField: sort.field,
|
|
@@ -40911,7 +40736,8 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
40911
40736
|
nextToken,
|
|
40912
40737
|
isKeyConditionOptimized ? optimizableFilter : void 0,
|
|
40913
40738
|
costTracker,
|
|
40914
|
-
requestId
|
|
40739
|
+
requestId,
|
|
40740
|
+
upperFilter
|
|
40915
40741
|
);
|
|
40916
40742
|
const recordIds = extractRecordIds(shadowRecords.Items || []);
|
|
40917
40743
|
if (recordIds.length === 0) {
|
|
@@ -40945,7 +40771,7 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
40945
40771
|
shadowRecords.LastEvaluatedKey.PK,
|
|
40946
40772
|
shadowRecords.LastEvaluatedKey.SK
|
|
40947
40773
|
) : void 0;
|
|
40948
|
-
|
|
40774
|
+
logger8.info("Shadow query succeeded", {
|
|
40949
40775
|
requestId,
|
|
40950
40776
|
resource,
|
|
40951
40777
|
sortField: sort.field,
|
|
@@ -40969,8 +40795,8 @@ async function executeFilterFirstQuery(resource, normalizedParams, filterCandida
|
|
|
40969
40795
|
const { perPage, nextToken } = pagination;
|
|
40970
40796
|
const offset = nextToken ? decodeOffsetToken(nextToken) ?? 0 : 0;
|
|
40971
40797
|
const filterSort = { field: filterCandidate.parsed.field, order: "ASC" };
|
|
40972
|
-
const remainingFilters = parsedFilters
|
|
40973
|
-
|
|
40798
|
+
const remainingFilters = parsedFilters;
|
|
40799
|
+
logger8.debug("Executing filter-first query", {
|
|
40974
40800
|
requestId,
|
|
40975
40801
|
resource,
|
|
40976
40802
|
filterField: filterCandidate.parsed.field,
|
|
@@ -40993,7 +40819,7 @@ async function executeFilterFirstQuery(resource, normalizedParams, filterCandida
|
|
|
40993
40819
|
const page = items.slice(offset, offset + perPage);
|
|
40994
40820
|
const hasNextPage = offset + perPage < items.length;
|
|
40995
40821
|
const nextTokenValue = hasNextPage ? encodeOffsetToken(offset + perPage) : void 0;
|
|
40996
|
-
|
|
40822
|
+
logger8.info("Filter-first query succeeded", {
|
|
40997
40823
|
requestId,
|
|
40998
40824
|
resource,
|
|
40999
40825
|
filterField: filterCandidate.parsed.field,
|
|
@@ -41014,7 +40840,7 @@ async function executeFullScanQuery(resource, normalizedParams, costTracker, req
|
|
|
41014
40840
|
const { sort, pagination, parsedFilters } = normalizedParams;
|
|
41015
40841
|
const { perPage, nextToken } = pagination;
|
|
41016
40842
|
const offset = nextToken ? decodeOffsetToken(nextToken) ?? 0 : 0;
|
|
41017
|
-
|
|
40843
|
+
logger8.debug("Executing full scan query", {
|
|
41018
40844
|
requestId,
|
|
41019
40845
|
resource,
|
|
41020
40846
|
sortField: sort.field,
|
|
@@ -41035,7 +40861,7 @@ async function executeFullScanQuery(resource, normalizedParams, costTracker, req
|
|
|
41035
40861
|
const page = items.slice(offset, offset + perPage);
|
|
41036
40862
|
const hasNextPage = offset + perPage < items.length;
|
|
41037
40863
|
const nextTokenValue = hasNextPage ? encodeOffsetToken(offset + perPage) : void 0;
|
|
41038
|
-
|
|
40864
|
+
logger8.info("Full scan query succeeded", {
|
|
41039
40865
|
requestId,
|
|
41040
40866
|
resource,
|
|
41041
40867
|
sortField: sort.field,
|
|
@@ -41066,7 +40892,7 @@ async function fetchAllRecordsViaShadowIndex(resource, indexSort, indexFilter, c
|
|
|
41066
40892
|
let iterations = 0;
|
|
41067
40893
|
do {
|
|
41068
40894
|
if (++iterations > MAX_ITERATIONS) {
|
|
41069
|
-
|
|
40895
|
+
logger8.error("fetchAllRecordsViaShadowIndex: \u6700\u5927\u53CD\u5FA9\u56DE\u6570\u3092\u8D85\u904E", {
|
|
41070
40896
|
requestId,
|
|
41071
40897
|
resource,
|
|
41072
40898
|
iterations
|
|
@@ -41096,7 +40922,7 @@ async function fetchAllRecordsViaShadowIndex(resource, indexSort, indexFilter, c
|
|
|
41096
40922
|
const nextKey = result.LastEvaluatedKey;
|
|
41097
40923
|
const nextKeySignature = nextKey ? `${nextKey.PK}#${nextKey.SK}` : void 0;
|
|
41098
40924
|
if (nextKeySignature && nextKeySignature === previousKeySignature) {
|
|
41099
|
-
|
|
40925
|
+
logger8.error("fetchAllRecordsViaShadowIndex: \u540C\u4E00\u306ELastEvaluatedKey\u304C\u8FD4\u5374\u3055\u308C\u305F", {
|
|
41100
40926
|
requestId,
|
|
41101
40927
|
resource,
|
|
41102
40928
|
iterations
|
|
@@ -41131,7 +40957,7 @@ function selectFilterFirstCandidate(parsedFilters, sortField, schema, perPage) {
|
|
|
41131
40957
|
if (eqFilters.length === 0) return void 0;
|
|
41132
40958
|
const cardinality = schema?.cardinality;
|
|
41133
40959
|
if (!cardinality) {
|
|
41134
|
-
return
|
|
40960
|
+
return eqFilters[0];
|
|
41135
40961
|
}
|
|
41136
40962
|
const threshold = perPage / 2;
|
|
41137
40963
|
const scored = eqFilters.map((f5) => ({ f: f5, score: cardinality[f5.parsed.field] ?? 0 })).filter(({ score }) => score > threshold).sort((a5, b5) => b5.score - a5.score);
|
|
@@ -41150,7 +40976,7 @@ function sortInMemory(items, sort) {
|
|
|
41150
40976
|
return 0;
|
|
41151
40977
|
});
|
|
41152
40978
|
}
|
|
41153
|
-
async function executeShadowRecordQuery(resource, sort, perPage, nextToken, optimizableFilter, costTracker, _requestId) {
|
|
40979
|
+
async function executeShadowRecordQuery(resource, sort, perPage, nextToken, optimizableFilter, costTracker, _requestId, secondFilter) {
|
|
41154
40980
|
const dbClient2 = getDBClient();
|
|
41155
40981
|
const tableName = getTableName();
|
|
41156
40982
|
let exclusiveStartKey;
|
|
@@ -41164,7 +40990,8 @@ async function executeShadowRecordQuery(resource, sort, perPage, nextToken, opti
|
|
|
41164
40990
|
const { keyConditionExpression, expressionAttributeValues } = buildKeyCondition(
|
|
41165
40991
|
resource,
|
|
41166
40992
|
sort.field,
|
|
41167
|
-
optimizableFilter
|
|
40993
|
+
optimizableFilter,
|
|
40994
|
+
secondFilter
|
|
41168
40995
|
);
|
|
41169
40996
|
const result = await executeDynamoDBOperation(
|
|
41170
40997
|
() => dbClient2.send(
|
|
@@ -41184,102 +41011,6 @@ async function executeShadowRecordQuery(resource, sort, perPage, nextToken, opti
|
|
|
41184
41011
|
costTracker.add(result.ConsumedCapacity);
|
|
41185
41012
|
return result;
|
|
41186
41013
|
}
|
|
41187
|
-
function buildKeyCondition(resource, sortField, optimizableFilter) {
|
|
41188
|
-
const expressionAttributeValues = {
|
|
41189
|
-
":pk": resource
|
|
41190
|
-
};
|
|
41191
|
-
if (!optimizableFilter) {
|
|
41192
|
-
return {
|
|
41193
|
-
keyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
41194
|
-
expressionAttributeValues: {
|
|
41195
|
-
...expressionAttributeValues,
|
|
41196
|
-
":skPrefix": `${sortField}#`
|
|
41197
|
-
}
|
|
41198
|
-
};
|
|
41199
|
-
}
|
|
41200
|
-
const { operator, type } = optimizableFilter.parsed;
|
|
41201
|
-
const value = optimizableFilter.value;
|
|
41202
|
-
const { encoded, exact } = encodeValueForShadowSK(value, type, operator);
|
|
41203
|
-
const skValue = `${sortField}#${encoded}`;
|
|
41204
|
-
const afterValue = `${skValue}#id#~`;
|
|
41205
|
-
const beforeValue = `${skValue}#id#`;
|
|
41206
|
-
switch (operator) {
|
|
41207
|
-
case "$eq":
|
|
41208
|
-
return {
|
|
41209
|
-
keyConditionExpression: "PK = :pk AND begins_with(SK, :skValue)",
|
|
41210
|
-
expressionAttributeValues: {
|
|
41211
|
-
...expressionAttributeValues,
|
|
41212
|
-
":skValue": beforeValue
|
|
41213
|
-
}
|
|
41214
|
-
};
|
|
41215
|
-
// 範囲検索は SK BETWEEN の 1 条件にする。
|
|
41216
|
-
// - DynamoDB はソートキーに 1 つの条件しか許さない(begins_with と比較を並べると ValidationException)
|
|
41217
|
-
// - 上限・下限を sortField の範囲に閉じないと、他の項目のシャドー(や本体 id#…)まで読む
|
|
41218
|
-
// BETWEEN は両端を含むが、端の値(`…#id#`、`…#id#~`、`{sortField}$`)と一致する SK は実在しない
|
|
41219
|
-
case "$gt":
|
|
41220
|
-
return rangeCondition(
|
|
41221
|
-
expressionAttributeValues,
|
|
41222
|
-
exact ? afterValue : beforeValue,
|
|
41223
|
-
fieldUpperBound(sortField)
|
|
41224
|
-
);
|
|
41225
|
-
case "$gte":
|
|
41226
|
-
return rangeCondition(expressionAttributeValues, beforeValue, fieldUpperBound(sortField));
|
|
41227
|
-
case "$lt":
|
|
41228
|
-
return rangeCondition(
|
|
41229
|
-
expressionAttributeValues,
|
|
41230
|
-
`${sortField}#`,
|
|
41231
|
-
exact ? beforeValue : afterValue
|
|
41232
|
-
);
|
|
41233
|
-
case "$lte":
|
|
41234
|
-
return rangeCondition(expressionAttributeValues, `${sortField}#`, afterValue);
|
|
41235
|
-
case "$starts":
|
|
41236
|
-
return {
|
|
41237
|
-
keyConditionExpression: "PK = :pk AND begins_with(SK, :skValue)",
|
|
41238
|
-
expressionAttributeValues: {
|
|
41239
|
-
...expressionAttributeValues,
|
|
41240
|
-
":skValue": skValue
|
|
41241
|
-
}
|
|
41242
|
-
};
|
|
41243
|
-
default:
|
|
41244
|
-
return {
|
|
41245
|
-
keyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
41246
|
-
expressionAttributeValues: {
|
|
41247
|
-
...expressionAttributeValues,
|
|
41248
|
-
":skPrefix": `${sortField}#`
|
|
41249
|
-
}
|
|
41250
|
-
};
|
|
41251
|
-
}
|
|
41252
|
-
}
|
|
41253
|
-
function fieldUpperBound(sortField) {
|
|
41254
|
-
return `${sortField}$`;
|
|
41255
|
-
}
|
|
41256
|
-
function rangeCondition(base, low, high) {
|
|
41257
|
-
return {
|
|
41258
|
-
keyConditionExpression: "PK = :pk AND SK BETWEEN :skLow AND :skHigh",
|
|
41259
|
-
expressionAttributeValues: { ...base, ":skLow": low, ":skHigh": high }
|
|
41260
|
-
};
|
|
41261
|
-
}
|
|
41262
|
-
function encodeValueForShadowSK(value, type, operator) {
|
|
41263
|
-
const config = getShadowConfig();
|
|
41264
|
-
if (type === "number" || typeof value === "number") {
|
|
41265
|
-
const num = Number(value);
|
|
41266
|
-
return { encoded: formatFieldValue2("number", num, config), exact: false };
|
|
41267
|
-
}
|
|
41268
|
-
if (type === "boolean" || typeof value === "boolean") {
|
|
41269
|
-
const bool = typeof value === "boolean" ? value : String(value).toLowerCase() === "true";
|
|
41270
|
-
return { encoded: formatFieldValue2("boolean", bool, config), exact: true };
|
|
41271
|
-
}
|
|
41272
|
-
const str = String(value);
|
|
41273
|
-
if (operator !== "$starts" && (type === "date" || inferFieldType(str) === "datetime")) {
|
|
41274
|
-
return { encoded: formatFieldValue2("datetime", str, config), exact: true };
|
|
41275
|
-
}
|
|
41276
|
-
const encoded = formatFieldValue2("string", str, config);
|
|
41277
|
-
const bytes = new TextEncoder().encode(str).length;
|
|
41278
|
-
return {
|
|
41279
|
-
encoded,
|
|
41280
|
-
exact: encoded === escapeString2(str) && bytes < config.stringMaxBytes - 3
|
|
41281
|
-
};
|
|
41282
|
-
}
|
|
41283
41014
|
function extractRecordIds(shadowRecords) {
|
|
41284
41015
|
return shadowRecords.map((record) => {
|
|
41285
41016
|
const sk = record.SK;
|
|
@@ -41292,7 +41023,7 @@ async function fetchMainRecords(resource, recordIds, costTracker, requestId) {
|
|
|
41292
41023
|
recordIds.map((id) => ({ PK: resource, SK: `id#${id}` })),
|
|
41293
41024
|
{ consistentRead: true, costTracker, requestId }
|
|
41294
41025
|
);
|
|
41295
|
-
|
|
41026
|
+
logger8.debug("Main records fetched", {
|
|
41296
41027
|
requestId,
|
|
41297
41028
|
resource,
|
|
41298
41029
|
requestedCount: new Set(recordIds).size,
|
|
@@ -41300,24 +41031,23 @@ async function fetchMainRecords(resource, recordIds, costTracker, requestId) {
|
|
|
41300
41031
|
});
|
|
41301
41032
|
return allRecords;
|
|
41302
41033
|
}
|
|
41303
|
-
var import_lib_dynamodb5,
|
|
41034
|
+
var import_lib_dynamodb5, logger8;
|
|
41304
41035
|
var init_shadowQuery = __esm({
|
|
41305
41036
|
"src/server/operations/find/shadowQuery.ts"() {
|
|
41306
41037
|
"use strict";
|
|
41307
41038
|
import_lib_dynamodb5 = __toESM(require_dist_cjs22(), 1);
|
|
41308
41039
|
init_shared();
|
|
41309
|
-
init_shadow();
|
|
41310
41040
|
init_batchGet();
|
|
41311
41041
|
init_cost_tracker();
|
|
41312
41042
|
init_dynamodb3();
|
|
41313
41043
|
init_pagination();
|
|
41314
41044
|
init_scanWarning();
|
|
41045
|
+
init_keyCondition();
|
|
41315
41046
|
init_utils6();
|
|
41316
|
-
|
|
41047
|
+
logger8 = createLogger({
|
|
41317
41048
|
service: "shadow-query",
|
|
41318
41049
|
level: process.env.LOG_LEVEL || "info"
|
|
41319
41050
|
});
|
|
41320
|
-
KEY_CONDITION_OPERATORS = /* @__PURE__ */ new Set(["$eq", "$gt", "$gte", "$lt", "$lte", "$starts"]);
|
|
41321
41051
|
__name(executeShadowQuery, "executeShadowQuery");
|
|
41322
41052
|
__name(executeFilterFirstQuery, "executeFilterFirstQuery");
|
|
41323
41053
|
__name(executeFullScanQuery, "executeFullScanQuery");
|
|
@@ -41325,10 +41055,6 @@ var init_shadowQuery = __esm({
|
|
|
41325
41055
|
__name(selectFilterFirstCandidate, "selectFilterFirstCandidate");
|
|
41326
41056
|
__name(sortInMemory, "sortInMemory");
|
|
41327
41057
|
__name(executeShadowRecordQuery, "executeShadowRecordQuery");
|
|
41328
|
-
__name(buildKeyCondition, "buildKeyCondition");
|
|
41329
|
-
__name(fieldUpperBound, "fieldUpperBound");
|
|
41330
|
-
__name(rangeCondition, "rangeCondition");
|
|
41331
|
-
__name(encodeValueForShadowSK, "encodeValueForShadowSK");
|
|
41332
41058
|
__name(extractRecordIds, "extractRecordIds");
|
|
41333
41059
|
__name(fetchMainRecords, "fetchMainRecords");
|
|
41334
41060
|
}
|
|
@@ -41336,14 +41062,14 @@ var init_shadowQuery = __esm({
|
|
|
41336
41062
|
|
|
41337
41063
|
// src/server/operations/find/handler.ts
|
|
41338
41064
|
async function handleFind(resource, params, requestId) {
|
|
41339
|
-
|
|
41065
|
+
logger9.debug("Executing find", {
|
|
41340
41066
|
requestId,
|
|
41341
41067
|
resource,
|
|
41342
41068
|
params
|
|
41343
41069
|
});
|
|
41344
41070
|
const nearDetection = detectNearQuery(params.filter);
|
|
41345
41071
|
if (nearDetection) {
|
|
41346
|
-
|
|
41072
|
+
logger9.debug("$near operator detected, executing near search", {
|
|
41347
41073
|
requestId,
|
|
41348
41074
|
resource,
|
|
41349
41075
|
fieldName: nearDetection.fieldName
|
|
@@ -41360,7 +41086,7 @@ async function handleFind(resource, params, requestId) {
|
|
|
41360
41086
|
const config = initializeFindConfig();
|
|
41361
41087
|
const normalizedParams = normalizeFindParams(config, resource, params);
|
|
41362
41088
|
validateSortField(config, resource, normalizedParams.sort);
|
|
41363
|
-
|
|
41089
|
+
logger9.debug("Find parameters normalized", {
|
|
41364
41090
|
requestId,
|
|
41365
41091
|
resource,
|
|
41366
41092
|
sort: normalizedParams.sort,
|
|
@@ -41375,7 +41101,7 @@ async function handleFind(resource, params, requestId) {
|
|
|
41375
41101
|
}
|
|
41376
41102
|
return executeShadowQuery(resource, normalizedParams, requestId);
|
|
41377
41103
|
}
|
|
41378
|
-
var
|
|
41104
|
+
var logger9;
|
|
41379
41105
|
var init_handler = __esm({
|
|
41380
41106
|
"src/server/operations/find/handler.ts"() {
|
|
41381
41107
|
"use strict";
|
|
@@ -41385,7 +41111,7 @@ var init_handler = __esm({
|
|
|
41385
41111
|
init_nearQuery();
|
|
41386
41112
|
init_shadowQuery();
|
|
41387
41113
|
init_utils6();
|
|
41388
|
-
|
|
41114
|
+
logger9 = createLogger({
|
|
41389
41115
|
service: "find-handler",
|
|
41390
41116
|
level: process.env.LOG_LEVEL || "info"
|
|
41391
41117
|
});
|
|
@@ -41455,6 +41181,343 @@ var init_findAll = __esm({
|
|
|
41455
41181
|
}
|
|
41456
41182
|
});
|
|
41457
41183
|
|
|
41184
|
+
// src/server/utils/bulkOperations.ts
|
|
41185
|
+
function logLargeBatchWarning(operation2, recordCount, requestId, resource) {
|
|
41186
|
+
if (recordCount > LARGE_BATCH_WARNING_THRESHOLD) {
|
|
41187
|
+
logger10.warn(`Large batch ${operation2} operation detected`, {
|
|
41188
|
+
requestId,
|
|
41189
|
+
resource,
|
|
41190
|
+
recordCount,
|
|
41191
|
+
warningThreshold: LARGE_BATCH_WARNING_THRESHOLD,
|
|
41192
|
+
estimatedTimeoutRisk: "high",
|
|
41193
|
+
recommendation: "Consider splitting the batch into smaller requests to avoid Lambda timeout (15 min limit)"
|
|
41194
|
+
});
|
|
41195
|
+
}
|
|
41196
|
+
}
|
|
41197
|
+
function calculateTimeoutRisk(startTime) {
|
|
41198
|
+
const elapsedMs = Date.now() - startTime;
|
|
41199
|
+
const remainingMs = LAMBDA_TIMEOUT_MS - elapsedMs;
|
|
41200
|
+
const utilizationPercent = Math.round(elapsedMs / LAMBDA_TIMEOUT_MS * 100);
|
|
41201
|
+
const risk = remainingMs < LAMBDA_TIMEOUT_MS * TIMEOUT_RISK_THRESHOLD ? "high" : "low";
|
|
41202
|
+
return {
|
|
41203
|
+
elapsedMs,
|
|
41204
|
+
remainingMs,
|
|
41205
|
+
risk,
|
|
41206
|
+
utilizationPercent
|
|
41207
|
+
};
|
|
41208
|
+
}
|
|
41209
|
+
function logPreparationTimeoutRisk(requestId, resource, totalRecords, chunkCount, riskInfo) {
|
|
41210
|
+
logger10.info("Records prepared for chunk execution", {
|
|
41211
|
+
requestId,
|
|
41212
|
+
resource,
|
|
41213
|
+
totalRecords,
|
|
41214
|
+
chunkCount,
|
|
41215
|
+
preparationTimeMs: riskInfo.elapsedMs,
|
|
41216
|
+
remainingTimeMs: riskInfo.remainingMs,
|
|
41217
|
+
timeoutRisk: riskInfo.risk
|
|
41218
|
+
});
|
|
41219
|
+
if (riskInfo.risk === "high") {
|
|
41220
|
+
logger10.warn("High timeout risk detected during preparation phase", {
|
|
41221
|
+
requestId,
|
|
41222
|
+
resource,
|
|
41223
|
+
preparationElapsedMs: riskInfo.elapsedMs,
|
|
41224
|
+
remainingTimeMs: riskInfo.remainingMs,
|
|
41225
|
+
lambdaTimeoutMs: LAMBDA_TIMEOUT_MS,
|
|
41226
|
+
recommendation: "Consider reducing batch size or optimizing preparation logic"
|
|
41227
|
+
});
|
|
41228
|
+
}
|
|
41229
|
+
}
|
|
41230
|
+
function logBulkOperationComplete(operation2, requestId, resource, requested, succeeded, failed, riskInfo, additionalInfo) {
|
|
41231
|
+
const totalElapsedSeconds = Math.round(riskInfo.elapsedMs / 1e3);
|
|
41232
|
+
logger10.info(`${operation2} completed`, {
|
|
41233
|
+
requestId,
|
|
41234
|
+
resource,
|
|
41235
|
+
requested,
|
|
41236
|
+
succeeded,
|
|
41237
|
+
totalFailed: failed,
|
|
41238
|
+
totalExecutionTimeMs: riskInfo.elapsedMs,
|
|
41239
|
+
totalExecutionTimeSeconds: totalElapsedSeconds,
|
|
41240
|
+
lambdaTimeoutMs: LAMBDA_TIMEOUT_MS,
|
|
41241
|
+
timeoutUtilization: `${riskInfo.utilizationPercent}%`,
|
|
41242
|
+
...additionalInfo
|
|
41243
|
+
});
|
|
41244
|
+
}
|
|
41245
|
+
function logPartialFailure(operation2, requestId, resource, requested, succeeded, failed, errorCodes, additionalInfo) {
|
|
41246
|
+
const failureRate = Math.round(failed / requested * 100);
|
|
41247
|
+
logger10.warn(`Partial failure in ${operation2} operation`, {
|
|
41248
|
+
requestId,
|
|
41249
|
+
resource,
|
|
41250
|
+
totalRequested: requested,
|
|
41251
|
+
successCount: succeeded,
|
|
41252
|
+
failedCount: failed,
|
|
41253
|
+
failureRate: `${failureRate}%`,
|
|
41254
|
+
errorCodes: [...new Set(errorCodes)],
|
|
41255
|
+
...additionalInfo
|
|
41256
|
+
});
|
|
41257
|
+
}
|
|
41258
|
+
var logger10;
|
|
41259
|
+
var init_bulkOperations = __esm({
|
|
41260
|
+
"src/server/utils/bulkOperations.ts"() {
|
|
41261
|
+
"use strict";
|
|
41262
|
+
init_shared();
|
|
41263
|
+
logger10 = createLogger({ service: "records-lambda" });
|
|
41264
|
+
__name(logLargeBatchWarning, "logLargeBatchWarning");
|
|
41265
|
+
__name(calculateTimeoutRisk, "calculateTimeoutRisk");
|
|
41266
|
+
__name(logPreparationTimeoutRisk, "logPreparationTimeoutRisk");
|
|
41267
|
+
__name(logBulkOperationComplete, "logBulkOperationComplete");
|
|
41268
|
+
__name(logPartialFailure, "logPartialFailure");
|
|
41269
|
+
}
|
|
41270
|
+
});
|
|
41271
|
+
|
|
41272
|
+
// src/server/utils/chunking.ts
|
|
41273
|
+
function estimateRecordBytes(record) {
|
|
41274
|
+
return Buffer.byteLength(JSON.stringify(record) ?? "", "utf8");
|
|
41275
|
+
}
|
|
41276
|
+
function calculateChunks(records, getItemCount, getByteSize = estimateRecordBytes) {
|
|
41277
|
+
const chunks = [];
|
|
41278
|
+
const itemCounts = [];
|
|
41279
|
+
let currentChunk = [];
|
|
41280
|
+
let currentItemCount = 0;
|
|
41281
|
+
let currentBytes = 0;
|
|
41282
|
+
for (const record of records) {
|
|
41283
|
+
const itemCount = getItemCount(record);
|
|
41284
|
+
const bytes = getByteSize(record);
|
|
41285
|
+
if (itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS) {
|
|
41286
|
+
const errorMsg = `Single record exceeds ${DYNAMODB_TRANSACT_WRITE_MAX_ITEMS} items limit: ${itemCount} items`;
|
|
41287
|
+
logger11.error("Chunk validation failed", {
|
|
41288
|
+
itemCount,
|
|
41289
|
+
limit: DYNAMODB_TRANSACT_WRITE_MAX_ITEMS
|
|
41290
|
+
});
|
|
41291
|
+
throw new Error(errorMsg);
|
|
41292
|
+
}
|
|
41293
|
+
if (currentItemCount + itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS || currentBytes + bytes > CHUNK_MAX_BYTES) {
|
|
41294
|
+
if (currentChunk.length > 0) {
|
|
41295
|
+
chunks.push(currentChunk);
|
|
41296
|
+
itemCounts.push(currentItemCount);
|
|
41297
|
+
}
|
|
41298
|
+
currentChunk = [record];
|
|
41299
|
+
currentItemCount = itemCount;
|
|
41300
|
+
currentBytes = bytes;
|
|
41301
|
+
} else {
|
|
41302
|
+
currentChunk.push(record);
|
|
41303
|
+
currentItemCount += itemCount;
|
|
41304
|
+
currentBytes += bytes;
|
|
41305
|
+
}
|
|
41306
|
+
}
|
|
41307
|
+
if (currentChunk.length > 0) {
|
|
41308
|
+
chunks.push(currentChunk);
|
|
41309
|
+
itemCounts.push(currentItemCount);
|
|
41310
|
+
}
|
|
41311
|
+
logger11.info("Chunk calculation completed", {
|
|
41312
|
+
totalRecords: records.length,
|
|
41313
|
+
chunkCount: chunks.length,
|
|
41314
|
+
itemCounts,
|
|
41315
|
+
minItemsPerChunk: itemCounts.length > 0 ? Math.min(...itemCounts) : 0,
|
|
41316
|
+
maxItemsPerChunk: itemCounts.length > 0 ? Math.max(...itemCounts) : 0,
|
|
41317
|
+
avgItemsPerChunk: itemCounts.length > 0 ? Math.round(itemCounts.reduce((sum, count) => sum + count, 0) / itemCounts.length) : 0
|
|
41318
|
+
});
|
|
41319
|
+
return { chunks, itemCounts };
|
|
41320
|
+
}
|
|
41321
|
+
async function executeChunks(chunks, executeChunk, getRecordId) {
|
|
41322
|
+
const successRecords = [];
|
|
41323
|
+
const failedIds = [];
|
|
41324
|
+
const errors = [];
|
|
41325
|
+
const totalRecords = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
41326
|
+
const executionStartTime = Date.now();
|
|
41327
|
+
logger11.info("Starting chunk execution", {
|
|
41328
|
+
totalChunks: chunks.length,
|
|
41329
|
+
totalRecords
|
|
41330
|
+
});
|
|
41331
|
+
for (let i5 = 0; i5 < chunks.length; i5++) {
|
|
41332
|
+
const chunk = chunks[i5];
|
|
41333
|
+
const chunkStartTime = Date.now();
|
|
41334
|
+
try {
|
|
41335
|
+
logger11.debug(`Executing chunk ${i5 + 1}/${chunks.length}`, {
|
|
41336
|
+
chunkIndex: i5,
|
|
41337
|
+
recordCount: chunk.length
|
|
41338
|
+
});
|
|
41339
|
+
const successfulRecords = await executeChunk(chunk);
|
|
41340
|
+
successRecords.push(...successfulRecords);
|
|
41341
|
+
const chunkDuration = Date.now() - chunkStartTime;
|
|
41342
|
+
logger11.info(`Chunk ${i5 + 1}/${chunks.length} succeeded`, {
|
|
41343
|
+
chunkIndex: i5,
|
|
41344
|
+
recordCount: chunk.length,
|
|
41345
|
+
durationMs: chunkDuration
|
|
41346
|
+
});
|
|
41347
|
+
} catch (error2) {
|
|
41348
|
+
const chunkDuration = Date.now() - chunkStartTime;
|
|
41349
|
+
const errorMessage = error2 instanceof Error ? error2.message : "Unknown error";
|
|
41350
|
+
const errorCode = getErrorCode(error2);
|
|
41351
|
+
logger11.error(`Chunk ${i5 + 1}/${chunks.length} failed`, {
|
|
41352
|
+
chunkIndex: i5,
|
|
41353
|
+
recordCount: chunk.length,
|
|
41354
|
+
durationMs: chunkDuration,
|
|
41355
|
+
error: errorMessage,
|
|
41356
|
+
errorCode
|
|
41357
|
+
});
|
|
41358
|
+
for (const record of chunk) {
|
|
41359
|
+
const recordId = getRecordId(record);
|
|
41360
|
+
failedIds.push(recordId);
|
|
41361
|
+
errors.push({
|
|
41362
|
+
id: recordId,
|
|
41363
|
+
code: errorCode,
|
|
41364
|
+
message: errorMessage
|
|
41365
|
+
});
|
|
41366
|
+
}
|
|
41367
|
+
}
|
|
41368
|
+
}
|
|
41369
|
+
const totalExecutionTime = Date.now() - executionStartTime;
|
|
41370
|
+
logger11.info("Chunk execution completed", {
|
|
41371
|
+
totalChunks: chunks.length,
|
|
41372
|
+
totalRecords,
|
|
41373
|
+
successCount: successRecords.length,
|
|
41374
|
+
failedCount: failedIds.length,
|
|
41375
|
+
totalExecutionTimeMs: totalExecutionTime,
|
|
41376
|
+
avgTimePerChunkMs: chunks.length > 0 ? Math.round(totalExecutionTime / chunks.length) : 0
|
|
41377
|
+
});
|
|
41378
|
+
if (failedIds.length > 0) {
|
|
41379
|
+
logger11.warn("Partial failure detected in chunk execution", {
|
|
41380
|
+
totalRecords,
|
|
41381
|
+
successCount: successRecords.length,
|
|
41382
|
+
failedCount: failedIds.length,
|
|
41383
|
+
failureRate: `${Math.round(failedIds.length / totalRecords * 100)}%`,
|
|
41384
|
+
failedIds: failedIds.slice(0, 10),
|
|
41385
|
+
// 最初の10件のみログ出力
|
|
41386
|
+
errorSummary: errors.slice(0, 5).map((e5) => ({
|
|
41387
|
+
id: e5.id,
|
|
41388
|
+
code: e5.code,
|
|
41389
|
+
message: e5.message.substring(0, 100)
|
|
41390
|
+
// メッセージを100文字に制限
|
|
41391
|
+
}))
|
|
41392
|
+
});
|
|
41393
|
+
}
|
|
41394
|
+
return {
|
|
41395
|
+
successRecords,
|
|
41396
|
+
failedIds,
|
|
41397
|
+
errors
|
|
41398
|
+
};
|
|
41399
|
+
}
|
|
41400
|
+
function getErrorCode(error2) {
|
|
41401
|
+
if (error2 && typeof error2 === "object") {
|
|
41402
|
+
if ("name" in error2 && typeof error2.name === "string") {
|
|
41403
|
+
return error2.name;
|
|
41404
|
+
}
|
|
41405
|
+
if ("code" in error2 && typeof error2.code === "string") {
|
|
41406
|
+
return error2.code;
|
|
41407
|
+
}
|
|
41408
|
+
}
|
|
41409
|
+
return "TRANSACTION_FAILED";
|
|
41410
|
+
}
|
|
41411
|
+
var logger11, CHUNK_MAX_BYTES;
|
|
41412
|
+
var init_chunking = __esm({
|
|
41413
|
+
"src/server/utils/chunking.ts"() {
|
|
41414
|
+
"use strict";
|
|
41415
|
+
init_shared();
|
|
41416
|
+
logger11 = createLogger({ service: "records-lambda" });
|
|
41417
|
+
CHUNK_MAX_BYTES = 3.5 * 1024 * 1024;
|
|
41418
|
+
__name(estimateRecordBytes, "estimateRecordBytes");
|
|
41419
|
+
__name(calculateChunks, "calculateChunks");
|
|
41420
|
+
__name(executeChunks, "executeChunks");
|
|
41421
|
+
__name(getErrorCode, "getErrorCode");
|
|
41422
|
+
}
|
|
41423
|
+
});
|
|
41424
|
+
|
|
41425
|
+
// src/server/utils/idFilter.ts
|
|
41426
|
+
function splitIdFilter(filter) {
|
|
41427
|
+
const { id, ...rest } = filter ?? {};
|
|
41428
|
+
if (typeof id === "string") {
|
|
41429
|
+
return { id, rest };
|
|
41430
|
+
}
|
|
41431
|
+
if (typeof id === "object" && id !== null && "$in" in id) {
|
|
41432
|
+
return { ids: (id.$in ?? []).slice(), rest };
|
|
41433
|
+
}
|
|
41434
|
+
return { rest: filter ?? {} };
|
|
41435
|
+
}
|
|
41436
|
+
function conditionOf(rest) {
|
|
41437
|
+
return Object.keys(rest).length > 0 ? rest : void 0;
|
|
41438
|
+
}
|
|
41439
|
+
function conditionMatcher(condition) {
|
|
41440
|
+
if (!condition || Object.keys(condition).length === 0) {
|
|
41441
|
+
return () => true;
|
|
41442
|
+
}
|
|
41443
|
+
const parsed = parseFilters(condition);
|
|
41444
|
+
return (record) => matchesAllFilters(record, parsed);
|
|
41445
|
+
}
|
|
41446
|
+
var init_idFilter = __esm({
|
|
41447
|
+
"src/server/utils/idFilter.ts"() {
|
|
41448
|
+
"use strict";
|
|
41449
|
+
init_utils6();
|
|
41450
|
+
__name(splitIdFilter, "splitIdFilter");
|
|
41451
|
+
__name(conditionOf, "conditionOf");
|
|
41452
|
+
__name(conditionMatcher, "conditionMatcher");
|
|
41453
|
+
}
|
|
41454
|
+
});
|
|
41455
|
+
|
|
41456
|
+
// src/server/utils/revision.ts
|
|
41457
|
+
function revisionOf(item) {
|
|
41458
|
+
const rev = item[REVISION_ATTRIBUTE];
|
|
41459
|
+
return typeof rev === "number" ? rev : void 0;
|
|
41460
|
+
}
|
|
41461
|
+
function nextRevision(current) {
|
|
41462
|
+
return (current ?? 0) + 1;
|
|
41463
|
+
}
|
|
41464
|
+
function notExistsCondition() {
|
|
41465
|
+
return { ConditionExpression: "attribute_not_exists(PK)" };
|
|
41466
|
+
}
|
|
41467
|
+
function unchangedCondition(revision) {
|
|
41468
|
+
const names = { "#rev": REVISION_ATTRIBUTE };
|
|
41469
|
+
if (revision === void 0) {
|
|
41470
|
+
return {
|
|
41471
|
+
ConditionExpression: "attribute_exists(PK) AND attribute_not_exists(#rev)",
|
|
41472
|
+
ExpressionAttributeNames: names
|
|
41473
|
+
};
|
|
41474
|
+
}
|
|
41475
|
+
return {
|
|
41476
|
+
ConditionExpression: "#rev = :rev",
|
|
41477
|
+
ExpressionAttributeNames: names,
|
|
41478
|
+
ExpressionAttributeValues: { ":rev": revision }
|
|
41479
|
+
};
|
|
41480
|
+
}
|
|
41481
|
+
function isWriteConflict(error2) {
|
|
41482
|
+
if (!error2 || typeof error2 !== "object") return false;
|
|
41483
|
+
const { name, CancellationReasons } = error2;
|
|
41484
|
+
if (name === "TransactionConflictException") return true;
|
|
41485
|
+
if (name !== "TransactionCanceledException" || !Array.isArray(CancellationReasons)) return false;
|
|
41486
|
+
const codes = CancellationReasons.map((r5) => r5?.Code).filter((c5) => c5 && c5 !== "None");
|
|
41487
|
+
return codes.length > 0 && codes.every((c5) => c5 === "ConditionalCheckFailed" || c5 === "TransactionConflict");
|
|
41488
|
+
}
|
|
41489
|
+
function sleep3(ms) {
|
|
41490
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
41491
|
+
}
|
|
41492
|
+
async function writeWithConflictRetry(initial, write, refresh, baseDelayMs = 20) {
|
|
41493
|
+
let records = initial;
|
|
41494
|
+
for (let attempt = 0; ; attempt++) {
|
|
41495
|
+
try {
|
|
41496
|
+
if (records.length > 0) await write(records);
|
|
41497
|
+
return records;
|
|
41498
|
+
} catch (error2) {
|
|
41499
|
+
if (!isWriteConflict(error2) || attempt >= MAX_CONFLICT_RETRIES) throw error2;
|
|
41500
|
+
await sleep3(baseDelayMs * 2 ** attempt * (0.5 + Math.random() / 2));
|
|
41501
|
+
records = await refresh(records);
|
|
41502
|
+
}
|
|
41503
|
+
}
|
|
41504
|
+
}
|
|
41505
|
+
var REVISION_ATTRIBUTE, MAX_CONFLICT_RETRIES;
|
|
41506
|
+
var init_revision = __esm({
|
|
41507
|
+
"src/server/utils/revision.ts"() {
|
|
41508
|
+
"use strict";
|
|
41509
|
+
REVISION_ATTRIBUTE = "__rev";
|
|
41510
|
+
MAX_CONFLICT_RETRIES = 5;
|
|
41511
|
+
__name(revisionOf, "revisionOf");
|
|
41512
|
+
__name(nextRevision, "nextRevision");
|
|
41513
|
+
__name(notExistsCondition, "notExistsCondition");
|
|
41514
|
+
__name(unchangedCondition, "unchangedCondition");
|
|
41515
|
+
__name(isWriteConflict, "isWriteConflict");
|
|
41516
|
+
__name(sleep3, "sleep");
|
|
41517
|
+
__name(writeWithConflictRetry, "writeWithConflictRetry");
|
|
41518
|
+
}
|
|
41519
|
+
});
|
|
41520
|
+
|
|
41458
41521
|
// src/server/operations/deleteMany.ts
|
|
41459
41522
|
var deleteMany_exports = {};
|
|
41460
41523
|
__export(deleteMany_exports, {
|
|
@@ -41466,7 +41529,7 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
41466
41529
|
let ids;
|
|
41467
41530
|
let condition;
|
|
41468
41531
|
if ("ids" in params) {
|
|
41469
|
-
ids = params.ids;
|
|
41532
|
+
ids = [...new Set(params.ids)];
|
|
41470
41533
|
condition = params.condition;
|
|
41471
41534
|
logger12.debug("Executing deleteMany with ids", {
|
|
41472
41535
|
requestId,
|
|
@@ -41609,7 +41672,7 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
41609
41672
|
if (transactItems.length === 0) return;
|
|
41610
41673
|
const result = await executeDynamoDBOperation(
|
|
41611
41674
|
() => dbClient2.send(
|
|
41612
|
-
new
|
|
41675
|
+
new import_lib_dynamodb7.TransactWriteCommand({
|
|
41613
41676
|
TransactItems: transactItems,
|
|
41614
41677
|
ReturnConsumedCapacity: "TOTAL"
|
|
41615
41678
|
})
|
|
@@ -41720,11 +41783,11 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
41720
41783
|
consumedCapacity: costTracker.getAggregated()
|
|
41721
41784
|
};
|
|
41722
41785
|
}
|
|
41723
|
-
var
|
|
41786
|
+
var import_lib_dynamodb7, logger12;
|
|
41724
41787
|
var init_deleteMany = __esm({
|
|
41725
41788
|
"src/server/operations/deleteMany.ts"() {
|
|
41726
41789
|
"use strict";
|
|
41727
|
-
|
|
41790
|
+
import_lib_dynamodb7 = __toESM(require_dist_cjs22(), 1);
|
|
41728
41791
|
init_shared();
|
|
41729
41792
|
init_shadow();
|
|
41730
41793
|
init_batchGet();
|
|
@@ -41905,56 +41968,6 @@ var init_timestamps = __esm({
|
|
|
41905
41968
|
}
|
|
41906
41969
|
});
|
|
41907
41970
|
|
|
41908
|
-
// src/server/utils/ttl.ts
|
|
41909
|
-
function calculateTTL(resource, createdAt) {
|
|
41910
|
-
const envKey = `${resource.toUpperCase()}_TTL_DAYS`;
|
|
41911
|
-
const ttlDaysStr = process.env[envKey];
|
|
41912
|
-
if (!ttlDaysStr) {
|
|
41913
|
-
return void 0;
|
|
41914
|
-
}
|
|
41915
|
-
const ttlDays = parseInt(ttlDaysStr, 10);
|
|
41916
|
-
if (isNaN(ttlDays) || ttlDays <= 0) {
|
|
41917
|
-
logger17.warn("Invalid TTL_DAYS value", { resource, envKey, value: ttlDaysStr });
|
|
41918
|
-
return void 0;
|
|
41919
|
-
}
|
|
41920
|
-
const createdAtMs = new Date(createdAt).getTime();
|
|
41921
|
-
const ttlMs = createdAtMs + ttlDays * 24 * 60 * 60 * 1e3;
|
|
41922
|
-
const ttl = Math.floor(ttlMs / 1e3);
|
|
41923
|
-
logger17.debug("TTL calculated", {
|
|
41924
|
-
resource,
|
|
41925
|
-
ttlDays,
|
|
41926
|
-
createdAt,
|
|
41927
|
-
ttl,
|
|
41928
|
-
ttlDate: new Date(ttl * 1e3).toISOString()
|
|
41929
|
-
});
|
|
41930
|
-
return ttl;
|
|
41931
|
-
}
|
|
41932
|
-
function addTTL(resource, recordData) {
|
|
41933
|
-
const createdAt = recordData.createdAt;
|
|
41934
|
-
if (!createdAt) {
|
|
41935
|
-
logger17.warn("createdAt not found, skipping TTL calculation", { resource });
|
|
41936
|
-
return recordData;
|
|
41937
|
-
}
|
|
41938
|
-
const ttl = calculateTTL(resource, createdAt);
|
|
41939
|
-
if (ttl === void 0) {
|
|
41940
|
-
return recordData;
|
|
41941
|
-
}
|
|
41942
|
-
return {
|
|
41943
|
-
...recordData,
|
|
41944
|
-
ttl
|
|
41945
|
-
};
|
|
41946
|
-
}
|
|
41947
|
-
var logger17;
|
|
41948
|
-
var init_ttl = __esm({
|
|
41949
|
-
"src/server/utils/ttl.ts"() {
|
|
41950
|
-
"use strict";
|
|
41951
|
-
init_index2();
|
|
41952
|
-
logger17 = createLogger({ service: "records-lambda" });
|
|
41953
|
-
__name(calculateTTL, "calculateTTL");
|
|
41954
|
-
__name(addTTL, "addTTL");
|
|
41955
|
-
}
|
|
41956
|
-
});
|
|
41957
|
-
|
|
41958
41971
|
// src/server/operations/insertMany.ts
|
|
41959
41972
|
var insertMany_exports = {};
|
|
41960
41973
|
__export(insertMany_exports, {
|
|
@@ -41964,7 +41977,7 @@ async function handleInsertMany(resource, params, requestId) {
|
|
|
41964
41977
|
const { data: recordsData } = params;
|
|
41965
41978
|
const startTime = Date.now();
|
|
41966
41979
|
const costTracker = new CostTracker();
|
|
41967
|
-
|
|
41980
|
+
logger17.debug("Executing insertMany", {
|
|
41968
41981
|
requestId,
|
|
41969
41982
|
resource,
|
|
41970
41983
|
count: recordsData.length
|
|
@@ -41989,11 +42002,10 @@ async function handleInsertMany(resource, params, requestId) {
|
|
|
41989
42002
|
const recordData = recordsData[i5];
|
|
41990
42003
|
try {
|
|
41991
42004
|
const id = recordData.id || ulid2();
|
|
41992
|
-
|
|
42005
|
+
const fullRecordData = addCreateTimestamps({
|
|
41993
42006
|
...recordData,
|
|
41994
42007
|
id
|
|
41995
42008
|
});
|
|
41996
|
-
fullRecordData = addTTL(resource, fullRecordData);
|
|
41997
42009
|
const shadowRecords = generateShadowRecords(fullRecordData, resource, shadowConfig);
|
|
41998
42010
|
const shadowKeys = shadowRecords.map((shadow) => shadow.SK);
|
|
41999
42011
|
const mainSK = generateMainRecordSK2(id);
|
|
@@ -42007,7 +42019,7 @@ async function handleInsertMany(resource, params, requestId) {
|
|
|
42007
42019
|
const failedId = recordData.id || `temp-id-${i5}`;
|
|
42008
42020
|
const errorMessage = error2 instanceof Error ? error2.message : "Unknown preparation error";
|
|
42009
42021
|
const errorCode = getPreparationErrorCode(error2);
|
|
42010
|
-
|
|
42022
|
+
logger17.error("Failed to prepare record for creation", {
|
|
42011
42023
|
requestId,
|
|
42012
42024
|
recordId: failedId,
|
|
42013
42025
|
error: errorMessage,
|
|
@@ -42076,7 +42088,7 @@ async function handleInsertMany(resource, params, requestId) {
|
|
|
42076
42088
|
}
|
|
42077
42089
|
const result = await executeDynamoDBOperation(
|
|
42078
42090
|
() => dbClient2.send(
|
|
42079
|
-
new
|
|
42091
|
+
new import_lib_dynamodb9.TransactWriteCommand({
|
|
42080
42092
|
TransactItems: transactItems,
|
|
42081
42093
|
ReturnConsumedCapacity: "TOTAL"
|
|
42082
42094
|
})
|
|
@@ -42201,11 +42213,11 @@ function getPreparationErrorCode(error2) {
|
|
|
42201
42213
|
}
|
|
42202
42214
|
return "VALIDATION_ERROR" /* VALIDATION_ERROR */;
|
|
42203
42215
|
}
|
|
42204
|
-
var
|
|
42216
|
+
var import_lib_dynamodb9, logger17;
|
|
42205
42217
|
var init_insertMany = __esm({
|
|
42206
42218
|
"src/server/operations/insertMany.ts"() {
|
|
42207
42219
|
"use strict";
|
|
42208
|
-
|
|
42220
|
+
import_lib_dynamodb9 = __toESM(require_dist_cjs22(), 1);
|
|
42209
42221
|
init_shared();
|
|
42210
42222
|
init_shadow();
|
|
42211
42223
|
init_shadow();
|
|
@@ -42216,8 +42228,7 @@ var init_insertMany = __esm({
|
|
|
42216
42228
|
init_dynamodb3();
|
|
42217
42229
|
init_revision();
|
|
42218
42230
|
init_timestamps();
|
|
42219
|
-
|
|
42220
|
-
logger18 = createLogger({ service: "records-lambda" });
|
|
42231
|
+
logger17 = createLogger({ service: "records-lambda" });
|
|
42221
42232
|
__name(handleInsertMany, "handleInsertMany");
|
|
42222
42233
|
__name(getPreparationErrorCode, "getPreparationErrorCode");
|
|
42223
42234
|
}
|
|
@@ -42406,7 +42417,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
42406
42417
|
const startTime = Date.now();
|
|
42407
42418
|
const costTracker = new CostTracker();
|
|
42408
42419
|
const update = resolveUpdateOperators(patchData);
|
|
42409
|
-
|
|
42420
|
+
logger19.debug("Executing updateMany", {
|
|
42410
42421
|
requestId,
|
|
42411
42422
|
resource,
|
|
42412
42423
|
upsert
|
|
@@ -42414,15 +42425,15 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
42414
42425
|
let ids;
|
|
42415
42426
|
let condition;
|
|
42416
42427
|
if ("ids" in params) {
|
|
42417
|
-
ids = params.ids;
|
|
42428
|
+
ids = [...new Set(params.ids)];
|
|
42418
42429
|
condition = params.condition;
|
|
42419
|
-
|
|
42430
|
+
logger19.debug("Executing updateMany with ids", {
|
|
42420
42431
|
requestId,
|
|
42421
42432
|
resource,
|
|
42422
42433
|
count: ids.length
|
|
42423
42434
|
});
|
|
42424
42435
|
} else {
|
|
42425
|
-
|
|
42436
|
+
logger19.debug("Executing updateMany with filter", {
|
|
42426
42437
|
requestId,
|
|
42427
42438
|
resource,
|
|
42428
42439
|
filter: params.filter
|
|
@@ -42441,7 +42452,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
42441
42452
|
);
|
|
42442
42453
|
ids = matched.map((item) => item.id);
|
|
42443
42454
|
condition = params.filter;
|
|
42444
|
-
|
|
42455
|
+
logger19.debug("Found records with filter", {
|
|
42445
42456
|
requestId,
|
|
42446
42457
|
resource,
|
|
42447
42458
|
count: ids.length
|
|
@@ -42450,7 +42461,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
42450
42461
|
if (upsert) {
|
|
42451
42462
|
const newId = ulid2();
|
|
42452
42463
|
ids = [newId];
|
|
42453
|
-
|
|
42464
|
+
logger19.info("Creating new record with filter (upsert: true)", {
|
|
42454
42465
|
requestId,
|
|
42455
42466
|
resource,
|
|
42456
42467
|
newId,
|
|
@@ -42489,7 +42500,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
42489
42500
|
);
|
|
42490
42501
|
const notFoundIds2 = targetIds.filter((id) => !existingIds.has(id));
|
|
42491
42502
|
if (!upsert && notFoundIds2.length > 0) {
|
|
42492
|
-
|
|
42503
|
+
logger19.warn("Records not found (upsert: false)", {
|
|
42493
42504
|
requestId,
|
|
42494
42505
|
resource,
|
|
42495
42506
|
notFoundCount: notFoundIds2.length,
|
|
@@ -42498,7 +42509,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
42498
42509
|
});
|
|
42499
42510
|
}
|
|
42500
42511
|
if (upsert && notFoundIds2.length > 0) {
|
|
42501
|
-
|
|
42512
|
+
logger19.info("Creating new records (upsert: true)", {
|
|
42502
42513
|
requestId,
|
|
42503
42514
|
resource,
|
|
42504
42515
|
notFoundCount: notFoundIds2.length,
|
|
@@ -42539,7 +42550,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
42539
42550
|
const failedId = existingData.id || "unknown-id";
|
|
42540
42551
|
const errorMessage = error2 instanceof Error ? error2.message : "Unknown preparation error";
|
|
42541
42552
|
const errorCode = getPreparationErrorCode2(error2);
|
|
42542
|
-
|
|
42553
|
+
logger19.error("Failed to prepare record for update", {
|
|
42543
42554
|
requestId,
|
|
42544
42555
|
recordId: failedId,
|
|
42545
42556
|
error: errorMessage,
|
|
@@ -42577,7 +42588,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
42577
42588
|
} catch (error2) {
|
|
42578
42589
|
const errorMessage = error2 instanceof Error ? error2.message : "Unknown preparation error";
|
|
42579
42590
|
const errorCode = getPreparationErrorCode2(error2);
|
|
42580
|
-
|
|
42591
|
+
logger19.error("Failed to prepare new record for upsert", {
|
|
42581
42592
|
requestId,
|
|
42582
42593
|
recordId: id,
|
|
42583
42594
|
error: errorMessage,
|
|
@@ -42660,7 +42671,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
42660
42671
|
}
|
|
42661
42672
|
const result = await executeDynamoDBOperation(
|
|
42662
42673
|
() => dbClient2.send(
|
|
42663
|
-
new
|
|
42674
|
+
new import_lib_dynamodb10.TransactWriteCommand({
|
|
42664
42675
|
TransactItems: transactItems,
|
|
42665
42676
|
ReturnConsumedCapacity: "TOTAL"
|
|
42666
42677
|
})
|
|
@@ -42679,7 +42690,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
42679
42690
|
const fresh = await prepare(stale.map((record) => record.id));
|
|
42680
42691
|
if (fresh.preparedRecords.length !== stale.length) {
|
|
42681
42692
|
throw new AppError(
|
|
42682
|
-
"
|
|
42693
|
+
"VERSION_CONFLICT" /* VERSION_CONFLICT */,
|
|
42683
42694
|
"Records changed concurrently and could not be re-read for update",
|
|
42684
42695
|
409
|
|
42685
42696
|
);
|
|
@@ -42696,11 +42707,13 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
42696
42707
|
const failedIdsMap = {};
|
|
42697
42708
|
const errorsMap = {};
|
|
42698
42709
|
const successIdSet = new Set(successRecords.map((r5) => r5.id));
|
|
42710
|
+
const upsertedIds = [];
|
|
42699
42711
|
for (let i5 = 0; i5 < ids.length; i5++) {
|
|
42700
42712
|
const id = ids[i5];
|
|
42701
42713
|
if (successIdSet.has(id)) {
|
|
42702
42714
|
successIds[i5] = id;
|
|
42703
42715
|
if (upsert && notFoundIds.includes(id)) {
|
|
42716
|
+
upsertedIds.push(id);
|
|
42704
42717
|
items.push({
|
|
42705
42718
|
id,
|
|
42706
42719
|
...update.setOnInsert,
|
|
@@ -42794,6 +42807,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
42794
42807
|
errors: errorsMap,
|
|
42795
42808
|
items,
|
|
42796
42809
|
// 更新したフィールドのみを含むレコード配列(ADR 001)
|
|
42810
|
+
...upsertedIds.length > 0 && { upsertedIds },
|
|
42797
42811
|
consumedCapacity: costTracker.getAggregated()
|
|
42798
42812
|
};
|
|
42799
42813
|
}
|
|
@@ -42808,11 +42822,11 @@ function getPreparationErrorCode2(error2) {
|
|
|
42808
42822
|
}
|
|
42809
42823
|
return "VALIDATION_ERROR" /* VALIDATION_ERROR */;
|
|
42810
42824
|
}
|
|
42811
|
-
var
|
|
42825
|
+
var import_lib_dynamodb10, logger19;
|
|
42812
42826
|
var init_updateMany = __esm({
|
|
42813
42827
|
"src/server/operations/updateMany.ts"() {
|
|
42814
42828
|
"use strict";
|
|
42815
|
-
|
|
42829
|
+
import_lib_dynamodb10 = __toESM(require_dist_cjs22(), 1);
|
|
42816
42830
|
init_shared();
|
|
42817
42831
|
init_shadow();
|
|
42818
42832
|
init_shadow();
|
|
@@ -42827,7 +42841,7 @@ var init_updateMany = __esm({
|
|
|
42827
42841
|
init_timestamps();
|
|
42828
42842
|
init_updateOperators();
|
|
42829
42843
|
init_findAll();
|
|
42830
|
-
|
|
42844
|
+
logger19 = createLogger({ service: "records-lambda" });
|
|
42831
42845
|
__name(handleUpdateMany, "handleUpdateMany");
|
|
42832
42846
|
__name(getPreparationErrorCode2, "getPreparationErrorCode");
|
|
42833
42847
|
}
|
|
@@ -42844,10 +42858,115 @@ init_shared();
|
|
|
42844
42858
|
|
|
42845
42859
|
// src/server/operations/operationDispatcher.ts
|
|
42846
42860
|
init_shared();
|
|
42861
|
+
|
|
42862
|
+
// src/server/operations/count.ts
|
|
42863
|
+
var import_lib_dynamodb6 = __toESM(require_dist_cjs22(), 1);
|
|
42864
|
+
init_errors();
|
|
42865
|
+
init_cost_tracker();
|
|
42866
|
+
init_dynamodb3();
|
|
42867
|
+
init_keyCondition();
|
|
42868
|
+
init_utils6();
|
|
42869
|
+
init_findAll();
|
|
42870
|
+
function planKeyCountFilters(parsedFilters) {
|
|
42871
|
+
const [first] = parsedFilters;
|
|
42872
|
+
if (!first || first.parsed.field === "id") return void 0;
|
|
42873
|
+
if (!KEY_CONDITION_OPERATORS.has(first.parsed.operator)) return void 0;
|
|
42874
|
+
const second = parsedFilters.length === 2 ? findComplementaryBound(first, parsedFilters) : void 0;
|
|
42875
|
+
if (parsedFilters.length > 1 && !second) return void 0;
|
|
42876
|
+
if (parsedFilters.length > 2) return void 0;
|
|
42877
|
+
const planned = second ? [first, second] : [first];
|
|
42878
|
+
const allExact = planned.every(
|
|
42879
|
+
(f5) => encodeValueForShadowSK(f5.value, f5.parsed.type, f5.parsed.operator).exact
|
|
42880
|
+
);
|
|
42881
|
+
return allExact ? { first, second } : void 0;
|
|
42882
|
+
}
|
|
42883
|
+
__name(planKeyCountFilters, "planKeyCountFilters");
|
|
42884
|
+
async function countByKeyCondition(keyConditionExpression, expressionAttributeValues, costTracker) {
|
|
42885
|
+
const dbClient2 = getDBClient();
|
|
42886
|
+
const tableName = getTableName();
|
|
42887
|
+
let total = 0;
|
|
42888
|
+
let exclusiveStartKey;
|
|
42889
|
+
do {
|
|
42890
|
+
const result = await executeDynamoDBOperation(
|
|
42891
|
+
() => dbClient2.send(
|
|
42892
|
+
new import_lib_dynamodb6.QueryCommand({
|
|
42893
|
+
TableName: tableName,
|
|
42894
|
+
KeyConditionExpression: keyConditionExpression,
|
|
42895
|
+
ExpressionAttributeValues: expressionAttributeValues,
|
|
42896
|
+
Select: "COUNT",
|
|
42897
|
+
ExclusiveStartKey: exclusiveStartKey,
|
|
42898
|
+
ConsistentRead: true,
|
|
42899
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
42900
|
+
})
|
|
42901
|
+
),
|
|
42902
|
+
"Query"
|
|
42903
|
+
);
|
|
42904
|
+
costTracker.add(result.ConsumedCapacity);
|
|
42905
|
+
total += result.Count ?? 0;
|
|
42906
|
+
exclusiveStartKey = result.LastEvaluatedKey;
|
|
42907
|
+
} while (exclusiveStartKey);
|
|
42908
|
+
return total;
|
|
42909
|
+
}
|
|
42910
|
+
__name(countByKeyCondition, "countByKeyCondition");
|
|
42911
|
+
async function handleCount(resource, params, requestId) {
|
|
42912
|
+
const filter = params.filter ?? {};
|
|
42913
|
+
if (detectNearQuery(filter)) {
|
|
42914
|
+
throw new InvalidFilterError("count does not support $near", { filter });
|
|
42915
|
+
}
|
|
42916
|
+
const parsedFilters = parseFilters(filter);
|
|
42917
|
+
const costTracker = new CostTracker();
|
|
42918
|
+
if (parsedFilters.length === 0) {
|
|
42919
|
+
const count = await countByKeyCondition(
|
|
42920
|
+
"PK = :pk AND begins_with(SK, :skPrefix)",
|
|
42921
|
+
{ ":pk": resource, ":skPrefix": "id#" },
|
|
42922
|
+
costTracker
|
|
42923
|
+
);
|
|
42924
|
+
return { count, consumedCapacity: costTracker.getAggregated() };
|
|
42925
|
+
}
|
|
42926
|
+
const plan = planKeyCountFilters(parsedFilters);
|
|
42927
|
+
if (plan) {
|
|
42928
|
+
const { keyConditionExpression, expressionAttributeValues } = buildKeyCondition(
|
|
42929
|
+
resource,
|
|
42930
|
+
plan.first.parsed.field,
|
|
42931
|
+
plan.first,
|
|
42932
|
+
plan.second
|
|
42933
|
+
);
|
|
42934
|
+
const count = await countByKeyCondition(
|
|
42935
|
+
keyConditionExpression,
|
|
42936
|
+
expressionAttributeValues,
|
|
42937
|
+
costTracker
|
|
42938
|
+
);
|
|
42939
|
+
return { count, consumedCapacity: costTracker.getAggregated() };
|
|
42940
|
+
}
|
|
42941
|
+
const items = await findAllByFilter(resource, filter, requestId);
|
|
42942
|
+
return { count: items.length };
|
|
42943
|
+
}
|
|
42944
|
+
__name(handleCount, "handleCount");
|
|
42945
|
+
|
|
42946
|
+
// src/server/operations/operationDispatcher.ts
|
|
42847
42947
|
init_deleteMany();
|
|
42848
42948
|
|
|
42849
42949
|
// src/server/operations/deleteOne.ts
|
|
42850
42950
|
init_shared();
|
|
42951
|
+
|
|
42952
|
+
// src/server/utils/bulkError.ts
|
|
42953
|
+
init_shared();
|
|
42954
|
+
function toAppError(error2, fallbackMessage) {
|
|
42955
|
+
const message = error2?.message ?? fallbackMessage;
|
|
42956
|
+
switch (error2?.code) {
|
|
42957
|
+
case "VALIDATION_ERROR" /* VALIDATION_ERROR */:
|
|
42958
|
+
return new AppError("VALIDATION_ERROR" /* VALIDATION_ERROR */, message, 400);
|
|
42959
|
+
case "ITEM_NOT_FOUND" /* ITEM_NOT_FOUND */:
|
|
42960
|
+
return new AppError("ITEM_NOT_FOUND" /* ITEM_NOT_FOUND */, message, 404);
|
|
42961
|
+
case "VERSION_CONFLICT" /* VERSION_CONFLICT */:
|
|
42962
|
+
return new AppError("VERSION_CONFLICT" /* VERSION_CONFLICT */, message, 409);
|
|
42963
|
+
default:
|
|
42964
|
+
return new AppError("INTERNAL_ERROR" /* INTERNAL_ERROR */, message, 500);
|
|
42965
|
+
}
|
|
42966
|
+
}
|
|
42967
|
+
__name(toAppError, "toAppError");
|
|
42968
|
+
|
|
42969
|
+
// src/server/operations/deleteOne.ts
|
|
42851
42970
|
init_findAll();
|
|
42852
42971
|
var logger13 = createLogger({ service: "records-lambda" });
|
|
42853
42972
|
async function handleDeleteOne(resource, params, requestId) {
|
|
@@ -42870,11 +42989,7 @@ async function handleDeleteOne(resource, params, requestId) {
|
|
|
42870
42989
|
);
|
|
42871
42990
|
if (deleteManyResult.count === 0) {
|
|
42872
42991
|
const error2 = Object.values(deleteManyResult.errors || {})[0];
|
|
42873
|
-
|
|
42874
|
-
throw new Error(`Failed to delete record: ${error2.message}`);
|
|
42875
|
-
} else {
|
|
42876
|
-
throw new Error(`Failed to delete record: ${targetId}`);
|
|
42877
|
-
}
|
|
42992
|
+
throw toAppError(error2, `Failed to delete record: ${targetId}`);
|
|
42878
42993
|
}
|
|
42879
42994
|
return {
|
|
42880
42995
|
acknowledged: true,
|
|
@@ -42901,11 +43016,7 @@ async function handleDeleteOne(resource, params, requestId) {
|
|
|
42901
43016
|
) : await handleDeleteMany2(resource, { ids: [] }, requestId);
|
|
42902
43017
|
if (deleteManyResult.count === 0) {
|
|
42903
43018
|
const error2 = Object.values(deleteManyResult.errors || {})[0];
|
|
42904
|
-
|
|
42905
|
-
throw new Error(`Failed to delete record: ${error2.message}`);
|
|
42906
|
-
} else {
|
|
42907
|
-
throw new Error(`No records found matching filter`);
|
|
42908
|
-
}
|
|
43019
|
+
throw toAppError(error2 ?? { code: "ITEM_NOT_FOUND" }, "No records found matching filter");
|
|
42909
43020
|
}
|
|
42910
43021
|
const deletedId = Object.values(deleteManyResult.successIds || {})[0];
|
|
42911
43022
|
if (!deletedId) {
|
|
@@ -42931,7 +43042,7 @@ init_find();
|
|
|
42931
43042
|
init_findMany();
|
|
42932
43043
|
|
|
42933
43044
|
// src/server/operations/findManyReference.ts
|
|
42934
|
-
var
|
|
43045
|
+
var import_lib_dynamodb8 = __toESM(require_dist_cjs22(), 1);
|
|
42935
43046
|
init_shared();
|
|
42936
43047
|
init_shadow();
|
|
42937
43048
|
init_batchGet();
|
|
@@ -42964,7 +43075,7 @@ async function handleFindManyReference(resource, params, requestId) {
|
|
|
42964
43075
|
}
|
|
42965
43076
|
const queryResult = await executeDynamoDBOperation(
|
|
42966
43077
|
() => dbClient2.send(
|
|
42967
|
-
new
|
|
43078
|
+
new import_lib_dynamodb8.QueryCommand({
|
|
42968
43079
|
TableName: tableName,
|
|
42969
43080
|
KeyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
42970
43081
|
ExpressionAttributeValues: {
|
|
@@ -43043,9 +43154,9 @@ init_insertMany();
|
|
|
43043
43154
|
|
|
43044
43155
|
// src/server/operations/insertOne.ts
|
|
43045
43156
|
init_shared();
|
|
43046
|
-
var
|
|
43157
|
+
var logger18 = createLogger({ service: "records-lambda" });
|
|
43047
43158
|
async function handleInsertOne(resource, params, requestId) {
|
|
43048
|
-
|
|
43159
|
+
logger18.debug("Executing insertOne", {
|
|
43049
43160
|
requestId,
|
|
43050
43161
|
resource
|
|
43051
43162
|
});
|
|
@@ -43059,11 +43170,7 @@ async function handleInsertOne(resource, params, requestId) {
|
|
|
43059
43170
|
);
|
|
43060
43171
|
if (insertManyResult.count === 0) {
|
|
43061
43172
|
const error2 = Object.values(insertManyResult.errors || {})[0];
|
|
43062
|
-
|
|
43063
|
-
throw new Error(`Failed to create record: ${error2.message}`);
|
|
43064
|
-
} else {
|
|
43065
|
-
throw new Error("Failed to create record");
|
|
43066
|
-
}
|
|
43173
|
+
throw toAppError(error2, "Failed to create record");
|
|
43067
43174
|
}
|
|
43068
43175
|
const createdId = Object.values(insertManyResult.successIds || {})[0];
|
|
43069
43176
|
if (!createdId) {
|
|
@@ -43071,7 +43178,7 @@ async function handleInsertOne(resource, params, requestId) {
|
|
|
43071
43178
|
}
|
|
43072
43179
|
const { handleFindOne: handleFindOne2 } = await Promise.resolve().then(() => (init_findOne(), findOne_exports));
|
|
43073
43180
|
const createdRecord = await handleFindOne2(resource, { id: createdId }, requestId);
|
|
43074
|
-
|
|
43181
|
+
logger18.info("insertOne succeeded", {
|
|
43075
43182
|
requestId,
|
|
43076
43183
|
resource,
|
|
43077
43184
|
id: createdId
|
|
@@ -43237,13 +43344,17 @@ init_updateMany();
|
|
|
43237
43344
|
// src/server/operations/updateOne.ts
|
|
43238
43345
|
init_shared();
|
|
43239
43346
|
init_findAll();
|
|
43240
|
-
var
|
|
43347
|
+
var logger20 = createLogger({ service: "records-lambda" });
|
|
43348
|
+
function upsertedIdOf(result, id) {
|
|
43349
|
+
return result.upsertedIds?.includes(id) ? { upsertedId: id } : {};
|
|
43350
|
+
}
|
|
43351
|
+
__name(upsertedIdOf, "upsertedIdOf");
|
|
43241
43352
|
async function handleUpdateOne(resource, params, requestId) {
|
|
43242
43353
|
const { data: patchData, options } = params;
|
|
43243
43354
|
const { handleUpdateMany: handleUpdateMany2 } = await Promise.resolve().then(() => (init_updateMany(), updateMany_exports));
|
|
43244
43355
|
if ("id" in params) {
|
|
43245
43356
|
const targetId = params.id;
|
|
43246
|
-
|
|
43357
|
+
logger20.debug("Executing updateOne with id", {
|
|
43247
43358
|
requestId,
|
|
43248
43359
|
resource,
|
|
43249
43360
|
id: targetId,
|
|
@@ -43261,14 +43372,7 @@ async function handleUpdateOne(resource, params, requestId) {
|
|
|
43261
43372
|
);
|
|
43262
43373
|
if (updateManyResult.count === 0) {
|
|
43263
43374
|
const error2 = Object.values(updateManyResult.errors || {})[0];
|
|
43264
|
-
|
|
43265
|
-
if (error2.code === "VALIDATION_ERROR" /* VALIDATION_ERROR */) {
|
|
43266
|
-
throw new AppError("VALIDATION_ERROR" /* VALIDATION_ERROR */, error2.message ?? "Invalid patch", 400);
|
|
43267
|
-
}
|
|
43268
|
-
throw new Error(`Failed to update record: ${error2.message}`);
|
|
43269
|
-
} else {
|
|
43270
|
-
throw new Error(`Failed to update record: ${targetId}`);
|
|
43271
|
-
}
|
|
43375
|
+
throw toAppError(error2, `Failed to update record: ${targetId}`);
|
|
43272
43376
|
}
|
|
43273
43377
|
if (!updateManyResult.items || updateManyResult.items.length === 0) {
|
|
43274
43378
|
throw new Error("updateMany did not return items");
|
|
@@ -43283,10 +43387,11 @@ async function handleUpdateOne(resource, params, requestId) {
|
|
|
43283
43387
|
modifiedCount: 1,
|
|
43284
43388
|
id: targetId,
|
|
43285
43389
|
...updatedItem,
|
|
43390
|
+
...upsertedIdOf(updateManyResult, targetId),
|
|
43286
43391
|
consumedCapacity: updateManyResult.consumedCapacity
|
|
43287
43392
|
};
|
|
43288
43393
|
} else {
|
|
43289
|
-
|
|
43394
|
+
logger20.debug("Executing updateOne with filter", {
|
|
43290
43395
|
requestId,
|
|
43291
43396
|
resource,
|
|
43292
43397
|
filter: params.filter,
|
|
@@ -43310,14 +43415,10 @@ async function handleUpdateOne(resource, params, requestId) {
|
|
|
43310
43415
|
);
|
|
43311
43416
|
if (updateManyResult.count === 0) {
|
|
43312
43417
|
const error2 = Object.values(updateManyResult.errors || {})[0];
|
|
43313
|
-
|
|
43314
|
-
|
|
43315
|
-
|
|
43316
|
-
|
|
43317
|
-
throw new Error(`Failed to update record: ${error2.message}`);
|
|
43318
|
-
} else {
|
|
43319
|
-
throw new Error(`No records found matching filter`);
|
|
43320
|
-
}
|
|
43418
|
+
throw toAppError(
|
|
43419
|
+
error2 ?? { code: "ITEM_NOT_FOUND" /* ITEM_NOT_FOUND */ },
|
|
43420
|
+
"No records found matching filter"
|
|
43421
|
+
);
|
|
43321
43422
|
}
|
|
43322
43423
|
if (!updateManyResult.items || updateManyResult.items.length === 0) {
|
|
43323
43424
|
throw new Error("updateMany did not return items");
|
|
@@ -43336,6 +43437,7 @@ async function handleUpdateOne(resource, params, requestId) {
|
|
|
43336
43437
|
modifiedCount: 1,
|
|
43337
43438
|
id: updatedId,
|
|
43338
43439
|
...updatedItem,
|
|
43440
|
+
...upsertedIdOf(updateManyResult, updatedId),
|
|
43339
43441
|
consumedCapacity: updateManyResult.consumedCapacity
|
|
43340
43442
|
};
|
|
43341
43443
|
}
|
|
@@ -43343,13 +43445,13 @@ async function handleUpdateOne(resource, params, requestId) {
|
|
|
43343
43445
|
__name(handleUpdateOne, "handleUpdateOne");
|
|
43344
43446
|
|
|
43345
43447
|
// src/server/operations/operationDispatcher.ts
|
|
43346
|
-
var
|
|
43448
|
+
var logger21 = createLogger({
|
|
43347
43449
|
service: "operation-dispatcher",
|
|
43348
43450
|
level: process.env.LOG_LEVEL || "info"
|
|
43349
43451
|
});
|
|
43350
43452
|
async function executeOperation(request2, requestId) {
|
|
43351
43453
|
const { op: op2, resource } = request2;
|
|
43352
|
-
|
|
43454
|
+
logger21.debug("Executing operation", {
|
|
43353
43455
|
requestId,
|
|
43354
43456
|
operation: op2,
|
|
43355
43457
|
resource
|
|
@@ -43373,6 +43475,8 @@ async function executeOperation(request2, requestId) {
|
|
|
43373
43475
|
request2.params,
|
|
43374
43476
|
requestId
|
|
43375
43477
|
);
|
|
43478
|
+
case "count":
|
|
43479
|
+
return await handleCount(resource, request2.params, requestId);
|
|
43376
43480
|
case "insertOne": {
|
|
43377
43481
|
const internalParams = convertInsertOneParams(request2.params);
|
|
43378
43482
|
return await handleInsertOne(resource, internalParams, requestId);
|
|
@@ -44602,13 +44706,13 @@ CognitoJwtVerifier.USER_POOL_ID_REGEX = /^(?<region>(?:eusc-[a-z]{2}|[a-z]{2})-(
|
|
|
44602
44706
|
|
|
44603
44707
|
// src/server/utils/auth.ts
|
|
44604
44708
|
init_index2();
|
|
44605
|
-
var
|
|
44709
|
+
var logger22 = createLogger({ service: "records-lambda" });
|
|
44606
44710
|
var verifierInstance = null;
|
|
44607
44711
|
function getVerifier(userPoolId, clientId) {
|
|
44608
44712
|
if (!verifierInstance) {
|
|
44609
|
-
|
|
44713
|
+
logger22.debug("Creating JWT verifier instance", { userPoolId, clientId });
|
|
44610
44714
|
if (!clientId) {
|
|
44611
|
-
|
|
44715
|
+
logger22.warn(
|
|
44612
44716
|
"COGNITO_CLIENT_ID is not set: JWT audience (aud) verification is DISABLED. Tokens issued to ANY app client of this user pool are accepted. Set cognito_client_id (Terraform) / COGNITO_CLIENT_ID in production. See docs/AUTHORIZATION.md",
|
|
44613
44717
|
{ userPoolId }
|
|
44614
44718
|
);
|
|
@@ -44625,18 +44729,18 @@ function getVerifier(userPoolId, clientId) {
|
|
|
44625
44729
|
}
|
|
44626
44730
|
__name(getVerifier, "getVerifier");
|
|
44627
44731
|
async function verifyJwt(token, userPoolId, clientId) {
|
|
44628
|
-
|
|
44732
|
+
logger22.debug("Verifying JWT token with signature validation");
|
|
44629
44733
|
try {
|
|
44630
44734
|
const verifier = getVerifier(userPoolId, clientId);
|
|
44631
44735
|
const payload2 = await verifier.verify(token);
|
|
44632
|
-
|
|
44736
|
+
logger22.debug("JWT token verified successfully", {
|
|
44633
44737
|
sub: payload2.sub,
|
|
44634
44738
|
email: payload2.email,
|
|
44635
44739
|
tokenUse: payload2.token_use
|
|
44636
44740
|
});
|
|
44637
44741
|
return payload2;
|
|
44638
44742
|
} catch (error2) {
|
|
44639
|
-
|
|
44743
|
+
logger22.error("JWT verification failed", {
|
|
44640
44744
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
44641
44745
|
});
|
|
44642
44746
|
let message = "JWT verification failed";
|
|
@@ -44677,7 +44781,7 @@ async function verifyAuthHeader(authHeader, userPoolId, clientId) {
|
|
|
44677
44781
|
__name(verifyAuthHeader, "verifyAuthHeader");
|
|
44678
44782
|
|
|
44679
44783
|
// src/server/utils/authHandler.ts
|
|
44680
|
-
var
|
|
44784
|
+
var logger23 = createLogger({
|
|
44681
44785
|
service: "auth-handler",
|
|
44682
44786
|
level: process.env.LOG_LEVEL || "info"
|
|
44683
44787
|
});
|
|
@@ -44692,7 +44796,7 @@ async function handleAuthentication(event, requestId) {
|
|
|
44692
44796
|
}
|
|
44693
44797
|
__name(handleAuthentication, "handleAuthentication");
|
|
44694
44798
|
function handleIAMAuthentication(iam, requestId) {
|
|
44695
|
-
|
|
44799
|
+
logger23.info("IAM authenticated request", {
|
|
44696
44800
|
requestId,
|
|
44697
44801
|
userArn: iam.userArn,
|
|
44698
44802
|
accountId: iam.accountId,
|
|
@@ -44707,7 +44811,7 @@ async function handleCognitoAuthentication(authHeader, requestId) {
|
|
|
44707
44811
|
throw new Error("COGNITO_USER_POOL_ID environment variable is required");
|
|
44708
44812
|
}
|
|
44709
44813
|
const jwtPayload = await verifyAuthHeader(authHeader, userPoolId, clientId);
|
|
44710
|
-
|
|
44814
|
+
logger23.debug("Cognito JWT verified", {
|
|
44711
44815
|
requestId,
|
|
44712
44816
|
sub: jwtPayload.sub
|
|
44713
44817
|
});
|
|
@@ -44722,7 +44826,7 @@ init_shared();
|
|
|
44722
44826
|
// src/server/utils/responseBuilder.ts
|
|
44723
44827
|
init_http();
|
|
44724
44828
|
init_shared();
|
|
44725
|
-
var
|
|
44829
|
+
var logger24 = createLogger({
|
|
44726
44830
|
service: "response-builder",
|
|
44727
44831
|
level: process.env.LOG_LEVEL || "info"
|
|
44728
44832
|
});
|
|
@@ -44732,7 +44836,7 @@ function createSuccessResponse(data, requestId) {
|
|
|
44732
44836
|
success: true,
|
|
44733
44837
|
data
|
|
44734
44838
|
};
|
|
44735
|
-
|
|
44839
|
+
logger24.info("Request succeeded", { requestId });
|
|
44736
44840
|
return {
|
|
44737
44841
|
statusCode: HTTP_STATUS.OK,
|
|
44738
44842
|
headers: {
|
|
@@ -44753,7 +44857,7 @@ function createErrorResponse(code, message, statusCode, requestId, logContext) {
|
|
|
44753
44857
|
}
|
|
44754
44858
|
};
|
|
44755
44859
|
const level = statusCode >= 500 ? "error" : "warn";
|
|
44756
|
-
|
|
44860
|
+
logger24[level]("Request failed", {
|
|
44757
44861
|
requestId,
|
|
44758
44862
|
event: code,
|
|
44759
44863
|
message,
|
|
@@ -44872,14 +44976,14 @@ function parseRequestBody(body) {
|
|
|
44872
44976
|
__name(parseRequestBody, "parseRequestBody");
|
|
44873
44977
|
|
|
44874
44978
|
// src/server/handler.ts
|
|
44875
|
-
var
|
|
44979
|
+
var logger25 = createLogger({
|
|
44876
44980
|
service: "records-lambda",
|
|
44877
44981
|
level: process.env.LOG_LEVEL || "info"
|
|
44878
44982
|
});
|
|
44879
|
-
|
|
44983
|
+
logger25.info("Records Lambda started with automatic shadow field detection");
|
|
44880
44984
|
async function handler(event) {
|
|
44881
44985
|
const requestId = event.requestContext.requestId;
|
|
44882
|
-
|
|
44986
|
+
logger25.info("Received request", {
|
|
44883
44987
|
requestId,
|
|
44884
44988
|
method: event.requestContext.http.method,
|
|
44885
44989
|
path: event.requestContext.http.path
|
|
@@ -44889,15 +44993,15 @@ async function handler(event) {
|
|
|
44889
44993
|
return createCorsResponse(HTTP_STATUS.OK);
|
|
44890
44994
|
}
|
|
44891
44995
|
if (event.requestContext.http.method === "GET" && event.requestContext.http.path === "/version") {
|
|
44892
|
-
const version = "1.
|
|
44996
|
+
const version = "1.27.0";
|
|
44893
44997
|
return createSuccessResponse({ version, timestamp: (/* @__PURE__ */ new Date()).toISOString() }, requestId);
|
|
44894
44998
|
}
|
|
44895
44999
|
if (event.requestContext.http.method !== "POST") {
|
|
44896
|
-
throw new
|
|
45000
|
+
throw new AppError("VALIDATION_ERROR" /* VALIDATION_ERROR */, "Only POST method is allowed", 405);
|
|
44897
45001
|
}
|
|
44898
45002
|
await handleAuthentication(event, requestId);
|
|
44899
45003
|
const request2 = parseRequestBody(event.body);
|
|
44900
|
-
|
|
45004
|
+
logger25.info("Parsed request", {
|
|
44901
45005
|
requestId,
|
|
44902
45006
|
operation: request2.op,
|
|
44903
45007
|
resource: request2.resource
|