@exabugs/dynamodb-client 1.6.2 → 1.7.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 +13 -0
- package/dist/server/handler.cjs +126 -48
- package/dist/server/handler.cjs.map +4 -4
- package/dist/server/media-handler.cjs +2 -2
- package/dist/server/media-process-handler-dlq.cjs +131 -53
- package/dist/server/media-process-handler-dlq.cjs.map +4 -4
- package/dist/server/media-process-handler.cjs +131 -53
- package/dist/server/media-process-handler.cjs.map +4 -4
- package/dist/server/operations/find/utils.js +2 -2
- package/dist/server/operations/find/utils.js.map +1 -1
- package/dist/server/operations/updateMany.d.ts.map +1 -1
- package/dist/server/operations/updateMany.js +6 -76
- 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 +9 -1
- package/dist/server/operations/updateOne.js.map +1 -1
- package/dist/server/utils/mergePatch.d.ts +8 -0
- package/dist/server/utils/mergePatch.d.ts.map +1 -0
- package/dist/server/utils/mergePatch.js +127 -0
- package/dist/server/utils/mergePatch.js.map +1 -0
- package/dist/server/utils/timestamps.d.ts.map +1 -1
- package/dist/server/utils/timestamps.js +2 -1
- package/dist/server/utils/timestamps.js.map +1 -1
- package/dist/sharp-layer.zip +0 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// @exabugs/dynamodb-client v1.
|
|
2
|
-
// Built: 2026-10-
|
|
1
|
+
// @exabugs/dynamodb-client v1.7.0
|
|
2
|
+
// Built: 2026-10-11T16:38:03.698Z
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -50105,7 +50105,7 @@ var init_types2 = __esm({
|
|
|
50105
50105
|
});
|
|
50106
50106
|
|
|
50107
50107
|
// src/shared/errors/index.ts
|
|
50108
|
-
var AppError, ConfigError, InvalidTokenError;
|
|
50108
|
+
var AppError, ConfigError, InvalidFilterError, InvalidTokenError;
|
|
50109
50109
|
var init_errors4 = __esm({
|
|
50110
50110
|
"src/shared/errors/index.ts"() {
|
|
50111
50111
|
"use strict";
|
|
@@ -50141,6 +50141,14 @@ var init_errors4 = __esm({
|
|
|
50141
50141
|
super("CONFIG_ERROR" /* CONFIG_ERROR */, message, 500, details);
|
|
50142
50142
|
}
|
|
50143
50143
|
};
|
|
50144
|
+
InvalidFilterError = class extends AppError {
|
|
50145
|
+
static {
|
|
50146
|
+
__name(this, "InvalidFilterError");
|
|
50147
|
+
}
|
|
50148
|
+
constructor(message, details) {
|
|
50149
|
+
super("INVALID_FILTER" /* INVALID_FILTER */, message, 400, details);
|
|
50150
|
+
}
|
|
50151
|
+
};
|
|
50144
50152
|
InvalidTokenError = class extends AppError {
|
|
50145
50153
|
static {
|
|
50146
50154
|
__name(this, "InvalidTokenError");
|
|
@@ -58478,7 +58486,7 @@ function parseFilters(filter) {
|
|
|
58478
58486
|
fieldKey,
|
|
58479
58487
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
58480
58488
|
});
|
|
58481
|
-
throw new
|
|
58489
|
+
throw new InvalidFilterError(`Invalid filter field syntax: ${fieldKey}`, {
|
|
58482
58490
|
field: fieldKey,
|
|
58483
58491
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
58484
58492
|
});
|
|
@@ -59738,6 +59746,113 @@ var init_chunking = __esm({
|
|
|
59738
59746
|
}
|
|
59739
59747
|
});
|
|
59740
59748
|
|
|
59749
|
+
// src/server/utils/mergePatch.ts
|
|
59750
|
+
function isPlainObject(value) {
|
|
59751
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
59752
|
+
}
|
|
59753
|
+
function invalidPath(path, reason) {
|
|
59754
|
+
return new AppError("VALIDATION_ERROR" /* VALIDATION_ERROR */, `Invalid patch path "${path}": ${reason}`, 400, {
|
|
59755
|
+
path
|
|
59756
|
+
});
|
|
59757
|
+
}
|
|
59758
|
+
function mergeInto(target, patch) {
|
|
59759
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
59760
|
+
if (key.includes(".")) {
|
|
59761
|
+
setByPath(target, key, value);
|
|
59762
|
+
} else {
|
|
59763
|
+
setKey(target, key, value, key);
|
|
59764
|
+
}
|
|
59765
|
+
}
|
|
59766
|
+
}
|
|
59767
|
+
function setKey(target, key, value, path) {
|
|
59768
|
+
if (key === "__proto__") {
|
|
59769
|
+
throw invalidPath(path, "forbidden segment");
|
|
59770
|
+
}
|
|
59771
|
+
if (value === null) {
|
|
59772
|
+
delete target[key];
|
|
59773
|
+
} else if (isPlainObject(value) && isPlainObject(target[key])) {
|
|
59774
|
+
mergeInto(target[key], value);
|
|
59775
|
+
} else {
|
|
59776
|
+
target[key] = value;
|
|
59777
|
+
}
|
|
59778
|
+
}
|
|
59779
|
+
function setByPath(target, path, value) {
|
|
59780
|
+
const keys = path.split(".");
|
|
59781
|
+
if (keys.some((k4) => k4 === "")) {
|
|
59782
|
+
throw invalidPath(path, "empty segment");
|
|
59783
|
+
}
|
|
59784
|
+
let current = target;
|
|
59785
|
+
for (let i4 = 0; i4 < keys.length; i4++) {
|
|
59786
|
+
const key = keys[i4];
|
|
59787
|
+
const isLast = i4 === keys.length - 1;
|
|
59788
|
+
if (Array.isArray(current)) {
|
|
59789
|
+
if (!/^(0|[1-9]\d*)$/.test(key) || Number(key) >= current.length) {
|
|
59790
|
+
throw invalidPath(path, `"${key}" is not a valid index (length ${current.length})`);
|
|
59791
|
+
}
|
|
59792
|
+
const index = Number(key);
|
|
59793
|
+
if (isLast) {
|
|
59794
|
+
if (value === null) {
|
|
59795
|
+
throw invalidPath(path, "array elements cannot be deleted by path");
|
|
59796
|
+
}
|
|
59797
|
+
const existing = current[index];
|
|
59798
|
+
if (isPlainObject(value) && isPlainObject(existing)) {
|
|
59799
|
+
mergeInto(existing, value);
|
|
59800
|
+
} else {
|
|
59801
|
+
current[index] = value;
|
|
59802
|
+
}
|
|
59803
|
+
return;
|
|
59804
|
+
}
|
|
59805
|
+
const next2 = current[index];
|
|
59806
|
+
if (isPlainObject(next2) || Array.isArray(next2)) {
|
|
59807
|
+
current = next2;
|
|
59808
|
+
} else {
|
|
59809
|
+
if (value === null) {
|
|
59810
|
+
return;
|
|
59811
|
+
}
|
|
59812
|
+
const created = {};
|
|
59813
|
+
current[index] = created;
|
|
59814
|
+
current = created;
|
|
59815
|
+
}
|
|
59816
|
+
continue;
|
|
59817
|
+
}
|
|
59818
|
+
if (isLast) {
|
|
59819
|
+
setKey(current, key, value, path);
|
|
59820
|
+
return;
|
|
59821
|
+
}
|
|
59822
|
+
if (key === "__proto__") {
|
|
59823
|
+
throw invalidPath(path, "forbidden segment");
|
|
59824
|
+
}
|
|
59825
|
+
const next = current[key];
|
|
59826
|
+
if (isPlainObject(next) || Array.isArray(next)) {
|
|
59827
|
+
current = next;
|
|
59828
|
+
} else {
|
|
59829
|
+
if (value === null) {
|
|
59830
|
+
return;
|
|
59831
|
+
}
|
|
59832
|
+
const created = {};
|
|
59833
|
+
current[key] = created;
|
|
59834
|
+
current = created;
|
|
59835
|
+
}
|
|
59836
|
+
}
|
|
59837
|
+
}
|
|
59838
|
+
function applyJsonMergePatch(target, patch) {
|
|
59839
|
+
const result = structuredClone(target);
|
|
59840
|
+
mergeInto(result, structuredClone(patch));
|
|
59841
|
+
return result;
|
|
59842
|
+
}
|
|
59843
|
+
var init_mergePatch = __esm({
|
|
59844
|
+
"src/server/utils/mergePatch.ts"() {
|
|
59845
|
+
"use strict";
|
|
59846
|
+
init_shared();
|
|
59847
|
+
__name(isPlainObject, "isPlainObject");
|
|
59848
|
+
__name(invalidPath, "invalidPath");
|
|
59849
|
+
__name(mergeInto, "mergeInto");
|
|
59850
|
+
__name(setKey, "setKey");
|
|
59851
|
+
__name(setByPath, "setByPath");
|
|
59852
|
+
__name(applyJsonMergePatch, "applyJsonMergePatch");
|
|
59853
|
+
}
|
|
59854
|
+
});
|
|
59855
|
+
|
|
59741
59856
|
// src/server/utils/timestamps.ts
|
|
59742
59857
|
var timestamps_exports = {};
|
|
59743
59858
|
__export(timestamps_exports, {
|
|
@@ -59771,8 +59886,8 @@ function addUpdateTimestamp(data) {
|
|
|
59771
59886
|
}
|
|
59772
59887
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
59773
59888
|
return {
|
|
59774
|
-
|
|
59775
|
-
|
|
59889
|
+
...data,
|
|
59890
|
+
[timestampFields.updatedAt]: data[timestampFields.updatedAt] ?? now
|
|
59776
59891
|
};
|
|
59777
59892
|
}
|
|
59778
59893
|
var init_timestamps = __esm({
|
|
@@ -59790,46 +59905,6 @@ var updateMany_exports = {};
|
|
|
59790
59905
|
__export(updateMany_exports, {
|
|
59791
59906
|
handleUpdateMany: () => handleUpdateMany
|
|
59792
59907
|
});
|
|
59793
|
-
function expandDotNotation(patch) {
|
|
59794
|
-
const result = {};
|
|
59795
|
-
for (const [key, value] of Object.entries(patch)) {
|
|
59796
|
-
if (key.includes(".")) {
|
|
59797
|
-
const keys = key.split(".");
|
|
59798
|
-
let current = result;
|
|
59799
|
-
for (let i4 = 0; i4 < keys.length - 1; i4++) {
|
|
59800
|
-
const k4 = keys[i4];
|
|
59801
|
-
if (!(k4 in current)) {
|
|
59802
|
-
current[k4] = {};
|
|
59803
|
-
} else if (typeof current[k4] !== "object" || Array.isArray(current[k4])) {
|
|
59804
|
-
current[k4] = {};
|
|
59805
|
-
}
|
|
59806
|
-
current = current[k4];
|
|
59807
|
-
}
|
|
59808
|
-
const lastKey = keys[keys.length - 1];
|
|
59809
|
-
current[lastKey] = value;
|
|
59810
|
-
} else {
|
|
59811
|
-
result[key] = value;
|
|
59812
|
-
}
|
|
59813
|
-
}
|
|
59814
|
-
return result;
|
|
59815
|
-
}
|
|
59816
|
-
function applyJsonMergePatch(target, patch) {
|
|
59817
|
-
const expandedPatch = expandDotNotation(patch);
|
|
59818
|
-
const result = { ...target };
|
|
59819
|
-
for (const [key, value] of Object.entries(expandedPatch)) {
|
|
59820
|
-
if (value === null) {
|
|
59821
|
-
delete result[key];
|
|
59822
|
-
} else if (typeof value === "object" && !Array.isArray(value) && value !== null && typeof result[key] === "object" && !Array.isArray(result[key]) && result[key] !== null) {
|
|
59823
|
-
result[key] = applyJsonMergePatch(
|
|
59824
|
-
result[key],
|
|
59825
|
-
value
|
|
59826
|
-
);
|
|
59827
|
-
} else {
|
|
59828
|
-
result[key] = value;
|
|
59829
|
-
}
|
|
59830
|
-
}
|
|
59831
|
-
return result;
|
|
59832
|
-
}
|
|
59833
59908
|
async function handleUpdateMany(resource, params, requestId) {
|
|
59834
59909
|
const { data: patchData, options } = params;
|
|
59835
59910
|
const upsert = options?.upsert ?? false;
|
|
@@ -59957,11 +60032,9 @@ async function handleUpdateMany(resource, params, requestId) {
|
|
|
59957
60032
|
const id = existingData.id;
|
|
59958
60033
|
const oldShadowKeys = item.__shadowKeys ?? existingData.__shadowKeys ?? [];
|
|
59959
60034
|
const actualPatchData2 = patchData.$set ? patchData.$set : patchData;
|
|
59960
|
-
const
|
|
59961
|
-
const
|
|
59962
|
-
|
|
59963
|
-
id
|
|
59964
|
-
});
|
|
60035
|
+
const timestampedPatch = addUpdateTimestamp(actualPatchData2);
|
|
60036
|
+
const mergedData = applyJsonMergePatch(removeShadowKeys(existingData), timestampedPatch);
|
|
60037
|
+
const updatedData = { ...mergedData, id };
|
|
59965
60038
|
const newShadowRecords = generateShadowRecords(updatedData, resource, shadowConfig);
|
|
59966
60039
|
const newShadowKeys = newShadowRecords.map((shadow) => shadow.SK);
|
|
59967
60040
|
const mainSK = generateMainRecordSK2(id);
|
|
@@ -60242,10 +60315,9 @@ var init_updateMany = __esm({
|
|
|
60242
60315
|
init_chunking();
|
|
60243
60316
|
init_cost_tracker();
|
|
60244
60317
|
init_dynamodb3();
|
|
60318
|
+
init_mergePatch();
|
|
60245
60319
|
init_timestamps();
|
|
60246
60320
|
logger11 = createLogger({ service: "records-lambda" });
|
|
60247
|
-
__name(expandDotNotation, "expandDotNotation");
|
|
60248
|
-
__name(applyJsonMergePatch, "applyJsonMergePatch");
|
|
60249
60321
|
__name(handleUpdateMany, "handleUpdateMany");
|
|
60250
60322
|
__name(getPreparationErrorCode, "getPreparationErrorCode");
|
|
60251
60323
|
}
|
|
@@ -60361,6 +60433,9 @@ async function handleUpdateOne(resource, params, requestId) {
|
|
|
60361
60433
|
if (updateManyResult.count === 0) {
|
|
60362
60434
|
const error2 = Object.values(updateManyResult.errors || {})[0];
|
|
60363
60435
|
if (error2) {
|
|
60436
|
+
if (error2.code === "VALIDATION_ERROR" /* VALIDATION_ERROR */) {
|
|
60437
|
+
throw new AppError("VALIDATION_ERROR" /* VALIDATION_ERROR */, error2.message ?? "Invalid patch", 400);
|
|
60438
|
+
}
|
|
60364
60439
|
throw new Error(`Failed to update record: ${error2.message}`);
|
|
60365
60440
|
} else {
|
|
60366
60441
|
throw new Error(`Failed to update record: ${targetId}`);
|
|
@@ -60400,6 +60475,9 @@ async function handleUpdateOne(resource, params, requestId) {
|
|
|
60400
60475
|
if (updateManyResult.count === 0) {
|
|
60401
60476
|
const error2 = Object.values(updateManyResult.errors || {})[0];
|
|
60402
60477
|
if (error2) {
|
|
60478
|
+
if (error2.code === "VALIDATION_ERROR" /* VALIDATION_ERROR */) {
|
|
60479
|
+
throw new AppError("VALIDATION_ERROR" /* VALIDATION_ERROR */, error2.message ?? "Invalid patch", 400);
|
|
60480
|
+
}
|
|
60403
60481
|
throw new Error(`Failed to update record: ${error2.message}`);
|
|
60404
60482
|
} else {
|
|
60405
60483
|
throw new Error(`No records found matching filter`);
|