@exabugs/dynamodb-client 1.3.43 → 1.3.44
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 +19 -0
- package/README.md +152 -0
- package/dist/client/Collection.d.ts.map +1 -1
- package/dist/client/Collection.js +9 -3
- package/dist/client/Collection.js.map +1 -1
- package/dist/client/FindCursor.d.ts +28 -1
- package/dist/client/FindCursor.d.ts.map +1 -1
- package/dist/client/FindCursor.js +34 -1
- package/dist/client/FindCursor.js.map +1 -1
- package/dist/server/handler.cjs +212 -39
- package/dist/server/handler.cjs.map +3 -3
- package/dist/server/operations/deleteMany.d.ts.map +1 -1
- package/dist/server/operations/deleteMany.js +26 -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 +8 -2
- package/dist/server/operations/deleteOne.js.map +1 -1
- package/dist/server/operations/find/idQuery.d.ts.map +1 -1
- package/dist/server/operations/find/idQuery.js +12 -0
- package/dist/server/operations/find/idQuery.js.map +1 -1
- package/dist/server/operations/find/nearQuery.d.ts.map +1 -1
- package/dist/server/operations/find/nearQuery.js +9 -0
- package/dist/server/operations/find/nearQuery.js.map +1 -1
- package/dist/server/operations/find/shadowQuery.d.ts.map +1 -1
- package/dist/server/operations/find/shadowQuery.js +23 -5
- package/dist/server/operations/find/shadowQuery.js.map +1 -1
- package/dist/server/operations/insertMany.d.ts.map +1 -1
- package/dist/server/operations/insertMany.js +16 -2
- 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 +5 -1
- package/dist/server/operations/insertOne.js.map +1 -1
- package/dist/server/operations/updateMany.d.ts.map +1 -1
- package/dist/server/operations/updateMany.js +25 -1
- 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 -2
- package/dist/server/operations/updateOne.js.map +1 -1
- package/dist/server/types.d.ts +6 -5
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/types.js +0 -5
- package/dist/server/types.js.map +1 -1
- package/dist/server/utils/cost-tracker.d.ts +62 -0
- package/dist/server/utils/cost-tracker.d.ts.map +1 -0
- package/dist/server/utils/cost-tracker.js +76 -0
- package/dist/server/utils/cost-tracker.js.map +1 -0
- package/dist/shared/types/consumed-capacity.d.ts +36 -0
- package/dist/shared/types/consumed-capacity.d.ts.map +1 -0
- package/dist/shared/types/consumed-capacity.js +2 -0
- package/dist/shared/types/consumed-capacity.js.map +1 -0
- package/dist/shared/types/index.d.ts +6 -4
- package/dist/shared/types/index.d.ts.map +1 -1
- package/dist/shared/types/index.js +2 -7
- package/dist/shared/types/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server/handler.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// @exabugs/dynamodb-client v1.3.
|
|
2
|
-
// Built: 2026-01-
|
|
1
|
+
// @exabugs/dynamodb-client v1.3.44
|
|
2
|
+
// Built: 2026-01-17T08:17:02.209Z
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -54,10 +54,18 @@ var init_http = __esm({
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
+
// src/shared/types/consumed-capacity.ts
|
|
58
|
+
var init_consumed_capacity = __esm({
|
|
59
|
+
"src/shared/types/consumed-capacity.ts"() {
|
|
60
|
+
"use strict";
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
57
64
|
// src/shared/types/index.ts
|
|
58
65
|
var init_types = __esm({
|
|
59
66
|
"src/shared/types/index.ts"() {
|
|
60
67
|
"use strict";
|
|
68
|
+
init_consumed_capacity();
|
|
61
69
|
}
|
|
62
70
|
});
|
|
63
71
|
|
|
@@ -29927,6 +29935,72 @@ var init_chunking = __esm({
|
|
|
29927
29935
|
}
|
|
29928
29936
|
});
|
|
29929
29937
|
|
|
29938
|
+
// src/server/utils/cost-tracker.ts
|
|
29939
|
+
var CostTracker;
|
|
29940
|
+
var init_cost_tracker = __esm({
|
|
29941
|
+
"src/server/utils/cost-tracker.ts"() {
|
|
29942
|
+
"use strict";
|
|
29943
|
+
CostTracker = class {
|
|
29944
|
+
static {
|
|
29945
|
+
__name(this, "CostTracker");
|
|
29946
|
+
}
|
|
29947
|
+
totalRCU = 0;
|
|
29948
|
+
totalWCU = 0;
|
|
29949
|
+
operationCount = 0;
|
|
29950
|
+
/**
|
|
29951
|
+
* ConsumedCapacityを追加
|
|
29952
|
+
*
|
|
29953
|
+
* DynamoDB操作のConsumedCapacityを累積します。
|
|
29954
|
+
* undefinedが渡された場合は何もしません(エラーにしない)。
|
|
29955
|
+
*
|
|
29956
|
+
* AWS SDKのConsumedCapacityは以下のフィールドを持ちます:
|
|
29957
|
+
* - CapacityUnits: 総キャパシティユニット(RCU + WCU)
|
|
29958
|
+
* - ReadCapacityUnits: 読み取りキャパシティユニット
|
|
29959
|
+
* - WriteCapacityUnits: 書き込みキャパシティユニット
|
|
29960
|
+
*
|
|
29961
|
+
* このメソッドはReadCapacityUnitsとWriteCapacityUnitsを優先的に使用し、
|
|
29962
|
+
* 存在しない場合はCapacityUnitsを読み取りとして扱います。
|
|
29963
|
+
*
|
|
29964
|
+
* @param consumedCapacity - DynamoDB操作のConsumedCapacity
|
|
29965
|
+
*/
|
|
29966
|
+
add(consumedCapacity) {
|
|
29967
|
+
if (!consumedCapacity) {
|
|
29968
|
+
return;
|
|
29969
|
+
}
|
|
29970
|
+
const rcu = consumedCapacity.ReadCapacityUnits ?? 0;
|
|
29971
|
+
const wcu = consumedCapacity.WriteCapacityUnits ?? 0;
|
|
29972
|
+
this.totalRCU += rcu;
|
|
29973
|
+
this.totalWCU += wcu;
|
|
29974
|
+
this.operationCount += 1;
|
|
29975
|
+
}
|
|
29976
|
+
/**
|
|
29977
|
+
* 集計結果を取得
|
|
29978
|
+
*
|
|
29979
|
+
* これまでに追加されたConsumedCapacityの集計結果を返します。
|
|
29980
|
+
*
|
|
29981
|
+
* @returns 集計されたコスト情報
|
|
29982
|
+
*/
|
|
29983
|
+
getAggregated() {
|
|
29984
|
+
return {
|
|
29985
|
+
totalRCU: this.totalRCU,
|
|
29986
|
+
totalWCU: this.totalWCU,
|
|
29987
|
+
operationCount: this.operationCount
|
|
29988
|
+
};
|
|
29989
|
+
}
|
|
29990
|
+
/**
|
|
29991
|
+
* リセット
|
|
29992
|
+
*
|
|
29993
|
+
* 累積されたコスト情報をクリアします。
|
|
29994
|
+
*/
|
|
29995
|
+
reset() {
|
|
29996
|
+
this.totalRCU = 0;
|
|
29997
|
+
this.totalWCU = 0;
|
|
29998
|
+
this.operationCount = 0;
|
|
29999
|
+
}
|
|
30000
|
+
};
|
|
30001
|
+
}
|
|
30002
|
+
});
|
|
30003
|
+
|
|
29930
30004
|
// src/server/utils/dynamodb.ts
|
|
29931
30005
|
function getDBClient() {
|
|
29932
30006
|
if (!dbClient) {
|
|
@@ -30476,6 +30550,7 @@ async function executeIdQuery(resource, normalizedParams, requestId) {
|
|
|
30476
30550
|
async function executeSpecificIdQuery(resource, targetId, requestId) {
|
|
30477
30551
|
const dbClient2 = getDBClient();
|
|
30478
30552
|
const tableName = getTableName();
|
|
30553
|
+
const costTracker = new CostTracker();
|
|
30479
30554
|
const queryResult = await executeDynamoDBOperation(
|
|
30480
30555
|
() => dbClient2.send(
|
|
30481
30556
|
new import_lib_dynamodb2.QueryCommand({
|
|
@@ -30485,11 +30560,13 @@ async function executeSpecificIdQuery(resource, targetId, requestId) {
|
|
|
30485
30560
|
":pk": resource,
|
|
30486
30561
|
":sk": `id#${targetId}`
|
|
30487
30562
|
},
|
|
30488
|
-
ConsistentRead: true
|
|
30563
|
+
ConsistentRead: true,
|
|
30564
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
30489
30565
|
})
|
|
30490
30566
|
),
|
|
30491
30567
|
"Query"
|
|
30492
30568
|
);
|
|
30569
|
+
costTracker.add(queryResult.ConsumedCapacity);
|
|
30493
30570
|
const mainRecords = queryResult.Items || [];
|
|
30494
30571
|
const items = mainRecords.map((item) => extractCleanRecord(item));
|
|
30495
30572
|
logger6.info("ID specific query succeeded", {
|
|
@@ -30503,12 +30580,14 @@ async function executeSpecificIdQuery(resource, targetId, requestId) {
|
|
|
30503
30580
|
pageInfo: {
|
|
30504
30581
|
hasNextPage: false,
|
|
30505
30582
|
hasPreviousPage: false
|
|
30506
|
-
}
|
|
30583
|
+
},
|
|
30584
|
+
consumedCapacity: costTracker.getAggregated()
|
|
30507
30585
|
};
|
|
30508
30586
|
}
|
|
30509
30587
|
async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsedFilters, requestId) {
|
|
30510
30588
|
const dbClient2 = getDBClient();
|
|
30511
30589
|
const tableName = getTableName();
|
|
30590
|
+
const costTracker = new CostTracker();
|
|
30512
30591
|
let exclusiveStartKey;
|
|
30513
30592
|
if (nextToken) {
|
|
30514
30593
|
const decoded = decodeNextToken(nextToken);
|
|
@@ -30529,11 +30608,13 @@ async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsed
|
|
|
30529
30608
|
ScanIndexForward: sort.order === "ASC",
|
|
30530
30609
|
Limit: perPage,
|
|
30531
30610
|
ExclusiveStartKey: exclusiveStartKey,
|
|
30532
|
-
ConsistentRead: true
|
|
30611
|
+
ConsistentRead: true,
|
|
30612
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
30533
30613
|
})
|
|
30534
30614
|
),
|
|
30535
30615
|
"Query"
|
|
30536
30616
|
);
|
|
30617
|
+
costTracker.add(queryResult.ConsumedCapacity);
|
|
30537
30618
|
const mainRecords = queryResult.Items || [];
|
|
30538
30619
|
if (mainRecords.length === 0) {
|
|
30539
30620
|
return {
|
|
@@ -30541,7 +30622,8 @@ async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsed
|
|
|
30541
30622
|
pageInfo: {
|
|
30542
30623
|
hasNextPage: false,
|
|
30543
30624
|
hasPreviousPage: false
|
|
30544
|
-
}
|
|
30625
|
+
},
|
|
30626
|
+
consumedCapacity: costTracker.getAggregated()
|
|
30545
30627
|
};
|
|
30546
30628
|
}
|
|
30547
30629
|
let items = mainRecords.map((item) => extractCleanRecord(item));
|
|
@@ -30565,7 +30647,8 @@ async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsed
|
|
|
30565
30647
|
hasNextPage,
|
|
30566
30648
|
hasPreviousPage: !!nextToken
|
|
30567
30649
|
},
|
|
30568
|
-
...nextTokenValue && { nextToken: nextTokenValue }
|
|
30650
|
+
...nextTokenValue && { nextToken: nextTokenValue },
|
|
30651
|
+
consumedCapacity: costTracker.getAggregated()
|
|
30569
30652
|
};
|
|
30570
30653
|
}
|
|
30571
30654
|
var import_lib_dynamodb2, logger6;
|
|
@@ -30574,6 +30657,7 @@ var init_idQuery = __esm({
|
|
|
30574
30657
|
"use strict";
|
|
30575
30658
|
import_lib_dynamodb2 = __toESM(require_dist_cjs66(), 1);
|
|
30576
30659
|
init_shared();
|
|
30660
|
+
init_cost_tracker();
|
|
30577
30661
|
init_dynamodb3();
|
|
30578
30662
|
init_pagination();
|
|
30579
30663
|
init_utils4();
|
|
@@ -30596,6 +30680,7 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
30596
30680
|
nearQuery,
|
|
30597
30681
|
limit
|
|
30598
30682
|
});
|
|
30683
|
+
const costTracker = new CostTracker();
|
|
30599
30684
|
const searchFunction = /* @__PURE__ */ __name(async (geohashPrefix) => {
|
|
30600
30685
|
const dbClient2 = getDBClient();
|
|
30601
30686
|
const tableName = getTableName();
|
|
@@ -30615,12 +30700,14 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
30615
30700
|
":pk": resource,
|
|
30616
30701
|
":skPrefix": `${fieldName}#${geohashPrefix}`
|
|
30617
30702
|
},
|
|
30618
|
-
ConsistentRead: false
|
|
30703
|
+
ConsistentRead: false,
|
|
30619
30704
|
// シャドウレコードは結果整合性で十分
|
|
30705
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
30620
30706
|
})
|
|
30621
30707
|
),
|
|
30622
30708
|
"Query"
|
|
30623
30709
|
);
|
|
30710
|
+
costTracker.add(queryResult.ConsumedCapacity);
|
|
30624
30711
|
const shadowRecords = queryResult.Items || [];
|
|
30625
30712
|
logger7.debug("Shadow records found", {
|
|
30626
30713
|
requestId,
|
|
@@ -30651,11 +30738,13 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
30651
30738
|
// venues
|
|
30652
30739
|
":sk": `id#${id}`
|
|
30653
30740
|
},
|
|
30654
|
-
ConsistentRead: true
|
|
30741
|
+
ConsistentRead: true,
|
|
30742
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
30655
30743
|
})
|
|
30656
30744
|
),
|
|
30657
30745
|
"Query"
|
|
30658
30746
|
);
|
|
30747
|
+
costTracker.add(result2.ConsumedCapacity);
|
|
30659
30748
|
return result2.Items?.[0];
|
|
30660
30749
|
})
|
|
30661
30750
|
);
|
|
@@ -30700,7 +30789,8 @@ async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId
|
|
|
30700
30789
|
hasNextPage: false,
|
|
30701
30790
|
// $near検索はページネーション非対応
|
|
30702
30791
|
hasPreviousPage: false
|
|
30703
|
-
}
|
|
30792
|
+
},
|
|
30793
|
+
consumedCapacity: costTracker.getAggregated()
|
|
30704
30794
|
};
|
|
30705
30795
|
}
|
|
30706
30796
|
var import_lib_dynamodb3, logger7;
|
|
@@ -30711,6 +30801,7 @@ var init_nearQuery = __esm({
|
|
|
30711
30801
|
init_geohash();
|
|
30712
30802
|
init_shared();
|
|
30713
30803
|
init_nearSearch();
|
|
30804
|
+
init_cost_tracker();
|
|
30714
30805
|
init_dynamodb3();
|
|
30715
30806
|
logger7 = createLogger({
|
|
30716
30807
|
service: "near-query",
|
|
@@ -30724,6 +30815,7 @@ var init_nearQuery = __esm({
|
|
|
30724
30815
|
async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
30725
30816
|
const { sort, pagination, parsedFilters } = normalizedParams;
|
|
30726
30817
|
const { perPage, nextToken } = pagination;
|
|
30818
|
+
const costTracker = new CostTracker();
|
|
30727
30819
|
logger8.debug("Executing shadow query", {
|
|
30728
30820
|
requestId,
|
|
30729
30821
|
resource,
|
|
@@ -30737,6 +30829,7 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
30737
30829
|
perPage,
|
|
30738
30830
|
nextToken,
|
|
30739
30831
|
optimizableFilter,
|
|
30832
|
+
costTracker,
|
|
30740
30833
|
requestId
|
|
30741
30834
|
);
|
|
30742
30835
|
const recordIds = extractRecordIds(shadowRecords.Items || []);
|
|
@@ -30746,10 +30839,11 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
30746
30839
|
pageInfo: {
|
|
30747
30840
|
hasNextPage: false,
|
|
30748
30841
|
hasPreviousPage: false
|
|
30749
|
-
}
|
|
30842
|
+
},
|
|
30843
|
+
consumedCapacity: costTracker.getAggregated()
|
|
30750
30844
|
};
|
|
30751
30845
|
}
|
|
30752
|
-
const mainRecords = await fetchMainRecords(resource, recordIds, requestId);
|
|
30846
|
+
const mainRecords = await fetchMainRecords(resource, recordIds, costTracker, requestId);
|
|
30753
30847
|
const recordMap = new Map(
|
|
30754
30848
|
mainRecords.map((item) => {
|
|
30755
30849
|
const data2 = item.data;
|
|
@@ -30786,10 +30880,11 @@ async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
|
30786
30880
|
hasNextPage,
|
|
30787
30881
|
hasPreviousPage: !!nextToken
|
|
30788
30882
|
},
|
|
30789
|
-
...nextTokenValue && { nextToken: nextTokenValue }
|
|
30883
|
+
...nextTokenValue && { nextToken: nextTokenValue },
|
|
30884
|
+
consumedCapacity: costTracker.getAggregated()
|
|
30790
30885
|
};
|
|
30791
30886
|
}
|
|
30792
|
-
async function executeShadowRecordQuery(resource, sort, perPage, nextToken, optimizableFilter, _requestId) {
|
|
30887
|
+
async function executeShadowRecordQuery(resource, sort, perPage, nextToken, optimizableFilter, costTracker, _requestId) {
|
|
30793
30888
|
const dbClient2 = getDBClient();
|
|
30794
30889
|
const tableName = getTableName();
|
|
30795
30890
|
let exclusiveStartKey;
|
|
@@ -30805,7 +30900,7 @@ async function executeShadowRecordQuery(resource, sort, perPage, nextToken, opti
|
|
|
30805
30900
|
sort.field,
|
|
30806
30901
|
optimizableFilter
|
|
30807
30902
|
);
|
|
30808
|
-
|
|
30903
|
+
const result = await executeDynamoDBOperation(
|
|
30809
30904
|
() => dbClient2.send(
|
|
30810
30905
|
new import_lib_dynamodb4.QueryCommand({
|
|
30811
30906
|
TableName: tableName,
|
|
@@ -30814,11 +30909,14 @@ async function executeShadowRecordQuery(resource, sort, perPage, nextToken, opti
|
|
|
30814
30909
|
ScanIndexForward: sort.order === "ASC",
|
|
30815
30910
|
Limit: perPage,
|
|
30816
30911
|
ExclusiveStartKey: exclusiveStartKey,
|
|
30817
|
-
ConsistentRead: true
|
|
30912
|
+
ConsistentRead: true,
|
|
30913
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
30818
30914
|
})
|
|
30819
30915
|
),
|
|
30820
30916
|
"Query"
|
|
30821
30917
|
);
|
|
30918
|
+
costTracker.add(result.ConsumedCapacity);
|
|
30919
|
+
return result;
|
|
30822
30920
|
}
|
|
30823
30921
|
function buildKeyCondition(resource, sortField, optimizableFilter) {
|
|
30824
30922
|
const expressionAttributeValues = {
|
|
@@ -30908,7 +31006,7 @@ function extractRecordIds(shadowRecords) {
|
|
|
30908
31006
|
return parts.length > 1 ? parts[1] : null;
|
|
30909
31007
|
}).filter((id) => id !== null);
|
|
30910
31008
|
}
|
|
30911
|
-
async function fetchMainRecords(resource, recordIds, requestId) {
|
|
31009
|
+
async function fetchMainRecords(resource, recordIds, costTracker, requestId) {
|
|
30912
31010
|
const dbClient2 = getDBClient();
|
|
30913
31011
|
const tableName = getTableName();
|
|
30914
31012
|
const uniqueRecordIds = Array.from(new Set(recordIds));
|
|
@@ -30923,11 +31021,17 @@ async function fetchMainRecords(resource, recordIds, requestId) {
|
|
|
30923
31021
|
})),
|
|
30924
31022
|
ConsistentRead: true
|
|
30925
31023
|
}
|
|
30926
|
-
}
|
|
31024
|
+
},
|
|
31025
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
30927
31026
|
})
|
|
30928
31027
|
),
|
|
30929
31028
|
"BatchGetItem"
|
|
30930
31029
|
);
|
|
31030
|
+
if (batchGetResult.ConsumedCapacity) {
|
|
31031
|
+
for (const capacity of batchGetResult.ConsumedCapacity) {
|
|
31032
|
+
costTracker.add(capacity);
|
|
31033
|
+
}
|
|
31034
|
+
}
|
|
30931
31035
|
const mainRecords = batchGetResult.Responses?.[tableName] || [];
|
|
30932
31036
|
logger8.debug("Main records fetched", {
|
|
30933
31037
|
requestId,
|
|
@@ -30944,6 +31048,7 @@ var init_shadowQuery = __esm({
|
|
|
30944
31048
|
import_lib_dynamodb4 = __toESM(require_dist_cjs66(), 1);
|
|
30945
31049
|
init_formatting();
|
|
30946
31050
|
init_shared();
|
|
31051
|
+
init_cost_tracker();
|
|
30947
31052
|
init_dynamodb3();
|
|
30948
31053
|
init_pagination();
|
|
30949
31054
|
init_utils4();
|
|
@@ -31035,6 +31140,7 @@ __export(deleteMany_exports, {
|
|
|
31035
31140
|
});
|
|
31036
31141
|
async function handleDeleteMany(resource, params, requestId) {
|
|
31037
31142
|
const startTime = Date.now();
|
|
31143
|
+
const costTracker = new CostTracker();
|
|
31038
31144
|
let ids;
|
|
31039
31145
|
if ("ids" in params) {
|
|
31040
31146
|
ids = params.ids;
|
|
@@ -31063,7 +31169,8 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
31063
31169
|
count: 0,
|
|
31064
31170
|
successIds: {},
|
|
31065
31171
|
failedIds: {},
|
|
31066
|
-
errors: {}
|
|
31172
|
+
errors: {},
|
|
31173
|
+
consumedCapacity: costTracker.getAggregated()
|
|
31067
31174
|
};
|
|
31068
31175
|
}
|
|
31069
31176
|
logLargeBatchWarning("deleteMany", ids.length, requestId, resource);
|
|
@@ -31081,11 +31188,19 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
31081
31188
|
Keys: keys,
|
|
31082
31189
|
ConsistentRead: true
|
|
31083
31190
|
}
|
|
31084
|
-
}
|
|
31191
|
+
},
|
|
31192
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
31085
31193
|
})
|
|
31086
31194
|
),
|
|
31087
31195
|
"BatchGetItem"
|
|
31088
31196
|
);
|
|
31197
|
+
if (Array.isArray(batchGetResult.ConsumedCapacity)) {
|
|
31198
|
+
for (const capacity of batchGetResult.ConsumedCapacity) {
|
|
31199
|
+
costTracker.add(capacity);
|
|
31200
|
+
}
|
|
31201
|
+
} else {
|
|
31202
|
+
costTracker.add(batchGetResult.ConsumedCapacity);
|
|
31203
|
+
}
|
|
31089
31204
|
const existingItems = batchGetResult.Responses?.[tableName] || [];
|
|
31090
31205
|
const existingIds = /* @__PURE__ */ new Set();
|
|
31091
31206
|
const preparedRecords = [];
|
|
@@ -31129,7 +31244,8 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
31129
31244
|
count: 0,
|
|
31130
31245
|
successIds: {},
|
|
31131
31246
|
failedIds: failedIdsMap2,
|
|
31132
|
-
errors: errorsMap2
|
|
31247
|
+
errors: errorsMap2,
|
|
31248
|
+
consumedCapacity: costTracker.getAggregated()
|
|
31133
31249
|
};
|
|
31134
31250
|
}
|
|
31135
31251
|
const getItemCount = /* @__PURE__ */ __name((record) => {
|
|
@@ -31168,14 +31284,22 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
31168
31284
|
});
|
|
31169
31285
|
}
|
|
31170
31286
|
}
|
|
31171
|
-
await executeDynamoDBOperation(
|
|
31287
|
+
const result = await executeDynamoDBOperation(
|
|
31172
31288
|
() => dbClient2.send(
|
|
31173
31289
|
new import_lib_dynamodb5.TransactWriteCommand({
|
|
31174
|
-
TransactItems: transactItems
|
|
31290
|
+
TransactItems: transactItems,
|
|
31291
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
31175
31292
|
})
|
|
31176
31293
|
),
|
|
31177
31294
|
"TransactWriteItems"
|
|
31178
31295
|
);
|
|
31296
|
+
if (Array.isArray(result.ConsumedCapacity)) {
|
|
31297
|
+
for (const capacity of result.ConsumedCapacity) {
|
|
31298
|
+
costTracker.add(capacity);
|
|
31299
|
+
}
|
|
31300
|
+
} else {
|
|
31301
|
+
costTracker.add(result.ConsumedCapacity);
|
|
31302
|
+
}
|
|
31179
31303
|
return chunk;
|
|
31180
31304
|
}, "executeChunk");
|
|
31181
31305
|
const {
|
|
@@ -31253,7 +31377,8 @@ async function handleDeleteMany(resource, params, requestId) {
|
|
|
31253
31377
|
count,
|
|
31254
31378
|
successIds,
|
|
31255
31379
|
failedIds: failedIdsMap,
|
|
31256
|
-
errors: errorsMap
|
|
31380
|
+
errors: errorsMap,
|
|
31381
|
+
consumedCapacity: costTracker.getAggregated()
|
|
31257
31382
|
};
|
|
31258
31383
|
}
|
|
31259
31384
|
var import_lib_dynamodb5, logger10;
|
|
@@ -31265,6 +31390,7 @@ var init_deleteMany = __esm({
|
|
|
31265
31390
|
init_shadow();
|
|
31266
31391
|
init_bulkOperations();
|
|
31267
31392
|
init_chunking();
|
|
31393
|
+
init_cost_tracker();
|
|
31268
31394
|
init_dynamodb3();
|
|
31269
31395
|
logger10 = createLogger({ service: "records-lambda" });
|
|
31270
31396
|
__name(handleDeleteMany, "handleDeleteMany");
|
|
@@ -31510,6 +31636,7 @@ __export(insertMany_exports, {
|
|
|
31510
31636
|
async function handleInsertMany(resource, params, requestId) {
|
|
31511
31637
|
const { data: recordsData } = params;
|
|
31512
31638
|
const startTime = Date.now();
|
|
31639
|
+
const costTracker = new CostTracker();
|
|
31513
31640
|
logger16.debug("Executing insertMany", {
|
|
31514
31641
|
requestId,
|
|
31515
31642
|
resource,
|
|
@@ -31520,7 +31647,8 @@ async function handleInsertMany(resource, params, requestId) {
|
|
|
31520
31647
|
count: 0,
|
|
31521
31648
|
successIds: {},
|
|
31522
31649
|
failedIds: {},
|
|
31523
|
-
errors: {}
|
|
31650
|
+
errors: {},
|
|
31651
|
+
consumedCapacity: costTracker.getAggregated()
|
|
31524
31652
|
};
|
|
31525
31653
|
}
|
|
31526
31654
|
logLargeBatchWarning("insertMany", recordsData.length, requestId, resource);
|
|
@@ -31608,14 +31736,22 @@ async function handleInsertMany(resource, params, requestId) {
|
|
|
31608
31736
|
});
|
|
31609
31737
|
}
|
|
31610
31738
|
}
|
|
31611
|
-
await executeDynamoDBOperation(
|
|
31739
|
+
const result = await executeDynamoDBOperation(
|
|
31612
31740
|
() => dbClient2.send(
|
|
31613
31741
|
new import_lib_dynamodb8.TransactWriteCommand({
|
|
31614
|
-
TransactItems: transactItems
|
|
31742
|
+
TransactItems: transactItems,
|
|
31743
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
31615
31744
|
})
|
|
31616
31745
|
),
|
|
31617
31746
|
"TransactWriteItems"
|
|
31618
31747
|
);
|
|
31748
|
+
if (Array.isArray(result.ConsumedCapacity)) {
|
|
31749
|
+
for (const capacity of result.ConsumedCapacity) {
|
|
31750
|
+
costTracker.add(capacity);
|
|
31751
|
+
}
|
|
31752
|
+
} else {
|
|
31753
|
+
costTracker.add(result.ConsumedCapacity);
|
|
31754
|
+
}
|
|
31619
31755
|
return chunk;
|
|
31620
31756
|
}, "executeChunk");
|
|
31621
31757
|
const {
|
|
@@ -31694,7 +31830,8 @@ async function handleInsertMany(resource, params, requestId) {
|
|
|
31694
31830
|
count,
|
|
31695
31831
|
successIds,
|
|
31696
31832
|
failedIds: failedIdsMap,
|
|
31697
|
-
errors: errorsMap
|
|
31833
|
+
errors: errorsMap,
|
|
31834
|
+
consumedCapacity: costTracker.getAggregated()
|
|
31698
31835
|
};
|
|
31699
31836
|
}
|
|
31700
31837
|
function getPreparationErrorCode(error2) {
|
|
@@ -31718,6 +31855,7 @@ var init_insertMany = __esm({
|
|
|
31718
31855
|
init_shadow();
|
|
31719
31856
|
init_bulkOperations();
|
|
31720
31857
|
init_chunking();
|
|
31858
|
+
init_cost_tracker();
|
|
31721
31859
|
init_dynamodb3();
|
|
31722
31860
|
init_timestamps();
|
|
31723
31861
|
init_ttl();
|
|
@@ -31776,6 +31914,7 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
31776
31914
|
const { data: patchData, options } = params;
|
|
31777
31915
|
const upsert = options?.upsert ?? false;
|
|
31778
31916
|
const startTime = Date.now();
|
|
31917
|
+
const costTracker = new CostTracker();
|
|
31779
31918
|
logger18.debug("Executing updateMany", {
|
|
31780
31919
|
requestId,
|
|
31781
31920
|
resource,
|
|
@@ -31829,7 +31968,8 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
31829
31968
|
count: 0,
|
|
31830
31969
|
successIds: {},
|
|
31831
31970
|
failedIds: {},
|
|
31832
|
-
errors: {}
|
|
31971
|
+
errors: {},
|
|
31972
|
+
consumedCapacity: costTracker.getAggregated()
|
|
31833
31973
|
};
|
|
31834
31974
|
}
|
|
31835
31975
|
}
|
|
@@ -31849,11 +31989,19 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
31849
31989
|
Keys: keys,
|
|
31850
31990
|
ConsistentRead: true
|
|
31851
31991
|
}
|
|
31852
|
-
}
|
|
31992
|
+
},
|
|
31993
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
31853
31994
|
})
|
|
31854
31995
|
),
|
|
31855
31996
|
"BatchGetItem"
|
|
31856
31997
|
);
|
|
31998
|
+
if (Array.isArray(batchGetResult.ConsumedCapacity)) {
|
|
31999
|
+
for (const capacity of batchGetResult.ConsumedCapacity) {
|
|
32000
|
+
costTracker.add(capacity);
|
|
32001
|
+
}
|
|
32002
|
+
} else {
|
|
32003
|
+
costTracker.add(batchGetResult.ConsumedCapacity);
|
|
32004
|
+
}
|
|
31857
32005
|
const existingItems = batchGetResult.Responses?.[tableName] || [];
|
|
31858
32006
|
const existingIds = new Set(
|
|
31859
32007
|
existingItems.map((item) => {
|
|
@@ -32019,14 +32167,22 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
32019
32167
|
});
|
|
32020
32168
|
}
|
|
32021
32169
|
}
|
|
32022
|
-
await executeDynamoDBOperation(
|
|
32170
|
+
const result = await executeDynamoDBOperation(
|
|
32023
32171
|
() => dbClient2.send(
|
|
32024
32172
|
new import_lib_dynamodb9.TransactWriteCommand({
|
|
32025
|
-
TransactItems: transactItems
|
|
32173
|
+
TransactItems: transactItems,
|
|
32174
|
+
ReturnConsumedCapacity: "TOTAL"
|
|
32026
32175
|
})
|
|
32027
32176
|
),
|
|
32028
32177
|
"TransactWriteItems"
|
|
32029
32178
|
);
|
|
32179
|
+
if (Array.isArray(result.ConsumedCapacity)) {
|
|
32180
|
+
for (const capacity of result.ConsumedCapacity) {
|
|
32181
|
+
costTracker.add(capacity);
|
|
32182
|
+
}
|
|
32183
|
+
} else {
|
|
32184
|
+
costTracker.add(result.ConsumedCapacity);
|
|
32185
|
+
}
|
|
32030
32186
|
return chunk;
|
|
32031
32187
|
}, "executeChunk");
|
|
32032
32188
|
const {
|
|
@@ -32139,8 +32295,9 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
32139
32295
|
successIds,
|
|
32140
32296
|
failedIds: failedIdsMap,
|
|
32141
32297
|
errors: errorsMap,
|
|
32142
|
-
items
|
|
32298
|
+
items,
|
|
32143
32299
|
// 更新したフィールドのみを含むレコード配列(ADR 001)
|
|
32300
|
+
consumedCapacity: costTracker.getAggregated()
|
|
32144
32301
|
};
|
|
32145
32302
|
}
|
|
32146
32303
|
function getPreparationErrorCode2(error2) {
|
|
@@ -32164,6 +32321,7 @@ var init_updateMany = __esm({
|
|
|
32164
32321
|
init_shadow();
|
|
32165
32322
|
init_bulkOperations();
|
|
32166
32323
|
init_chunking();
|
|
32324
|
+
init_cost_tracker();
|
|
32167
32325
|
init_dynamodb3();
|
|
32168
32326
|
init_timestamps();
|
|
32169
32327
|
logger18 = createLogger({ service: "records-lambda" });
|
|
@@ -32215,7 +32373,10 @@ async function handleDeleteOne(resource, params, requestId) {
|
|
|
32215
32373
|
throw new Error(`Failed to delete record: ${targetId}`);
|
|
32216
32374
|
}
|
|
32217
32375
|
}
|
|
32218
|
-
return {
|
|
32376
|
+
return {
|
|
32377
|
+
id: targetId,
|
|
32378
|
+
consumedCapacity: deleteManyResult.consumedCapacity
|
|
32379
|
+
};
|
|
32219
32380
|
} else {
|
|
32220
32381
|
logger11.debug("Executing deleteOne with filter", {
|
|
32221
32382
|
requestId,
|
|
@@ -32246,7 +32407,10 @@ async function handleDeleteOne(resource, params, requestId) {
|
|
|
32246
32407
|
resource,
|
|
32247
32408
|
id: deletedId
|
|
32248
32409
|
});
|
|
32249
|
-
return {
|
|
32410
|
+
return {
|
|
32411
|
+
id: deletedId,
|
|
32412
|
+
consumedCapacity: deleteManyResult.consumedCapacity
|
|
32413
|
+
};
|
|
32250
32414
|
}
|
|
32251
32415
|
}
|
|
32252
32416
|
__name(handleDeleteOne, "handleDeleteOne");
|
|
@@ -32413,7 +32577,10 @@ async function handleInsertOne(resource, params, requestId) {
|
|
|
32413
32577
|
resource,
|
|
32414
32578
|
id: createdId
|
|
32415
32579
|
});
|
|
32416
|
-
return
|
|
32580
|
+
return {
|
|
32581
|
+
...createdRecord,
|
|
32582
|
+
consumedCapacity: insertManyResult.consumedCapacity
|
|
32583
|
+
};
|
|
32417
32584
|
}
|
|
32418
32585
|
__name(handleInsertOne, "handleInsertOne");
|
|
32419
32586
|
|
|
@@ -32454,7 +32621,10 @@ async function handleUpdateOne(resource, params, requestId) {
|
|
|
32454
32621
|
if (!updateManyResult.items || updateManyResult.items.length === 0) {
|
|
32455
32622
|
throw new Error("updateMany did not return items");
|
|
32456
32623
|
}
|
|
32457
|
-
return
|
|
32624
|
+
return {
|
|
32625
|
+
...updateManyResult.items[0],
|
|
32626
|
+
consumedCapacity: updateManyResult.consumedCapacity
|
|
32627
|
+
};
|
|
32458
32628
|
} else {
|
|
32459
32629
|
logger19.debug("Executing updateOne with filter", {
|
|
32460
32630
|
requestId,
|
|
@@ -32482,7 +32652,10 @@ async function handleUpdateOne(resource, params, requestId) {
|
|
|
32482
32652
|
if (!updateManyResult.items || updateManyResult.items.length === 0) {
|
|
32483
32653
|
throw new Error("updateMany did not return items");
|
|
32484
32654
|
}
|
|
32485
|
-
return
|
|
32655
|
+
return {
|
|
32656
|
+
...updateManyResult.items[0],
|
|
32657
|
+
consumedCapacity: updateManyResult.consumedCapacity
|
|
32658
|
+
};
|
|
32486
32659
|
}
|
|
32487
32660
|
}
|
|
32488
32661
|
__name(handleUpdateOne, "handleUpdateOne");
|
|
@@ -34107,7 +34280,7 @@ async function handler(event) {
|
|
|
34107
34280
|
return createCorsResponse(HTTP_STATUS.OK);
|
|
34108
34281
|
}
|
|
34109
34282
|
if (event.requestContext.http.method === "GET" && event.requestContext.http.path === "/version") {
|
|
34110
|
-
const version = "1.3.
|
|
34283
|
+
const version = "1.3.44";
|
|
34111
34284
|
return createSuccessResponse({ version, timestamp: (/* @__PURE__ */ new Date()).toISOString() }, requestId);
|
|
34112
34285
|
}
|
|
34113
34286
|
if (event.requestContext.http.method !== "POST") {
|