@exabugs/dynamodb-client 1.3.21 → 1.3.22

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 CHANGED
@@ -7,6 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.3.22] - 2026-01-05
11
+
12
+ ### Added
13
+
14
+ - **$setOnInsert オペレータ**: MongoDB互換のupsert専用フィールド設定機能
15
+ - upsert時のinsert専用フィールドを指定可能(`$setOnInsert`)
16
+ - update時は`$setOnInsert`が無視され、`$set`のみが適用される
17
+ - `$set`と`$setOnInsert`で同じフィールドを指定した場合、`$set`が優先
18
+ - タイムスタンプ管理(`createdAt`は初回のみ、`updatedAt`は常に更新)が明確に
19
+ - MongoDB公式ドキュメントと完全互換
20
+
21
+ ### Changed
22
+
23
+ - **UpdateOperators型**: `$setOnInsert?: Partial<T>` フィールドを追加
24
+ - **handleUpsertCreate**: `$set`と`$setOnInsert`をマージして新規作成(`$set`が優先)
25
+ - **handleUpsertUpdate**: `$setOnInsert`を無視して`$set`のみを適用
26
+
27
+ ### Documentation
28
+
29
+ - **API.md**: `$setOnInsert`オペレータの詳細な説明を追加
30
+ - 動作仕様(insert時/update時の挙動)
31
+ - 使用例とコードスニペット
32
+ - MongoDB互換性の説明
33
+ - ユースケース(タイムスタンプ管理、デフォルト値設定、初期ステータス)
34
+
35
+ ### Technical
36
+
37
+ - **テスト**: 包括的なテストカバレッジ(単体テスト・統合テスト)
38
+ - insert時に`$set`と`$setOnInsert`の両方を適用するテスト
39
+ - update時に`$setOnInsert`を無視するテスト
40
+ - `$set`が`$setOnInsert`より優先されるテスト
41
+ - `createdAt`の保持テスト
42
+ - シャドウレコード生成の確認
43
+ - 後方互換性テスト(従来のパッチ形式)
44
+
10
45
  ## [1.3.21] - 2026-01-04
11
46
 
12
47
  ### Changed
@@ -1,5 +1,5 @@
1
- // @exabugs/dynamodb-client v1.3.21
2
- // Built: 2026-01-04T11:18:43.181Z
1
+ // @exabugs/dynamodb-client v1.3.22
2
+ // Built: 2026-01-05T00:55:07.904Z
3
3
  "use strict";
4
4
  var __create = Object.create;
5
5
  var __defProp = Object.defineProperty;
@@ -31504,7 +31504,8 @@ async function handleUpdateMany(resource, params, requestId) {
31504
31504
  const existingData = item.data;
31505
31505
  const id = existingData.id;
31506
31506
  const oldShadowKeys = existingData.__shadowKeys || [];
31507
- const mergedData = applyJsonMergePatch(removeShadowKeys(existingData), patchData);
31507
+ const actualPatchData = patchData.$set ? patchData.$set : patchData;
31508
+ const mergedData = applyJsonMergePatch(removeShadowKeys(existingData), actualPatchData);
31508
31509
  const updatedData = addUpdateTimestamp({
31509
31510
  ...mergedData,
31510
31511
  id
@@ -31762,7 +31763,13 @@ async function handleUpdateOne(resource, params, requestId) {
31762
31763
  }
31763
31764
  __name(handleUpdateOne, "handleUpdateOne");
31764
31765
  async function handleUpsertCreate(resource, id, data2, requestId) {
31765
- const recordData = addCreateTimestamps({ ...data2, id });
31766
+ const $set = data2.$set || {};
31767
+ const $setOnInsert = data2.$setOnInsert || {};
31768
+ const mergedData = {
31769
+ ...$setOnInsert,
31770
+ ...$set
31771
+ };
31772
+ const recordData = addCreateTimestamps({ ...mergedData, id });
31766
31773
  const shadowConfig = getShadowConfig();
31767
31774
  const shadowRecords = generateShadowRecords(recordData, resource, shadowConfig);
31768
31775
  const shadowKeys = shadowRecords.map((shadow) => shadow.SK);
@@ -31811,7 +31818,8 @@ __name(handleUpsertCreate, "handleUpsertCreate");
31811
31818
  async function handleUpsertUpdate(resource, id, existingItem, patchData, requestId) {
31812
31819
  const existingData = existingItem.data;
31813
31820
  const oldShadowKeys = existingData.__shadowKeys || [];
31814
- const mergedData = applyJsonMergePatch2(removeShadowKeys(existingData), patchData);
31821
+ const actualPatchData = patchData.$set ? patchData.$set : patchData;
31822
+ const mergedData = applyJsonMergePatch2(removeShadowKeys(existingData), actualPatchData);
31815
31823
  const updatedData = addUpdateTimestamp({
31816
31824
  ...mergedData,
31817
31825
  id
@@ -33459,7 +33467,7 @@ async function handler(event) {
33459
33467
  return createCorsResponse(HTTP_STATUS.OK);
33460
33468
  }
33461
33469
  if (event.requestContext.http.method === "GET" && event.requestContext.http.path === "/version") {
33462
- const version = "1.3.21";
33470
+ const version = "1.3.22";
33463
33471
  return createSuccessResponse({ version, timestamp: (/* @__PURE__ */ new Date()).toISOString() }, requestId);
33464
33472
  }
33465
33473
  if (event.requestContext.http.method !== "POST") {