@aws-sdk/util-dynamodb 3.721.0 → 3.723.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist-cjs/index.js CHANGED
@@ -30,7 +30,11 @@ __export(src_exports, {
30
30
  module.exports = __toCommonJS(src_exports);
31
31
 
32
32
  // src/NumberValue.ts
33
- var _NumberValue = class _NumberValue {
33
+ var NumberValue = class _NumberValue {
34
+ static {
35
+ __name(this, "NumberValue");
36
+ }
37
+ value;
34
38
  /**
35
39
  * This class does not validate that your string input is a valid number.
36
40
  *
@@ -90,44 +94,41 @@ var _NumberValue = class _NumberValue {
90
94
  return this.toString();
91
95
  }
92
96
  };
93
- __name(_NumberValue, "NumberValue");
94
- var NumberValue = _NumberValue;
95
97
 
96
98
  // src/convertToAttr.ts
97
99
  var convertToAttr = /* @__PURE__ */ __name((data, options) => {
98
- var _a, _b, _c, _d, _e, _f;
99
100
  if (data === void 0) {
100
101
  throw new Error(`Pass options.removeUndefinedValues=true to remove undefined values from map/array/set.`);
101
102
  } else if (data === null && typeof data === "object") {
102
103
  return convertToNullAttr();
103
104
  } else if (Array.isArray(data)) {
104
105
  return convertToListAttr(data, options);
105
- } else if (((_a = data == null ? void 0 : data.constructor) == null ? void 0 : _a.name) === "Set") {
106
+ } else if (data?.constructor?.name === "Set") {
106
107
  return convertToSetAttr(data, options);
107
- } else if (((_b = data == null ? void 0 : data.constructor) == null ? void 0 : _b.name) === "Map") {
108
+ } else if (data?.constructor?.name === "Map") {
108
109
  return convertToMapAttrFromIterable(data, options);
109
- } else if (((_c = data == null ? void 0 : data.constructor) == null ? void 0 : _c.name) === "Object" || // for object which is result of Object.create(null), which doesn't have constructor defined
110
+ } else if (data?.constructor?.name === "Object" || // for object which is result of Object.create(null), which doesn't have constructor defined
110
111
  !data.constructor && typeof data === "object") {
111
112
  return convertToMapAttrFromEnumerableProps(data, options);
112
113
  } else if (isBinary(data)) {
113
- if (data.length === 0 && (options == null ? void 0 : options.convertEmptyValues)) {
114
+ if (data.length === 0 && options?.convertEmptyValues) {
114
115
  return convertToNullAttr();
115
116
  }
116
117
  return convertToBinaryAttr(data);
117
- } else if (typeof data === "boolean" || ((_d = data == null ? void 0 : data.constructor) == null ? void 0 : _d.name) === "Boolean") {
118
+ } else if (typeof data === "boolean" || data?.constructor?.name === "Boolean") {
118
119
  return { BOOL: data.valueOf() };
119
- } else if (typeof data === "number" || ((_e = data == null ? void 0 : data.constructor) == null ? void 0 : _e.name) === "Number") {
120
+ } else if (typeof data === "number" || data?.constructor?.name === "Number") {
120
121
  return convertToNumberAttr(data, options);
121
122
  } else if (data instanceof NumberValue) {
122
123
  return data.toAttributeValue();
123
124
  } else if (typeof data === "bigint") {
124
125
  return convertToBigIntAttr(data);
125
- } else if (typeof data === "string" || ((_f = data == null ? void 0 : data.constructor) == null ? void 0 : _f.name) === "String") {
126
- if (data.length === 0 && (options == null ? void 0 : options.convertEmptyValues)) {
126
+ } else if (typeof data === "string" || data?.constructor?.name === "String") {
127
+ if (data.length === 0 && options?.convertEmptyValues) {
127
128
  return convertToNullAttr();
128
129
  }
129
130
  return convertToStringAttr(data);
130
- } else if ((options == null ? void 0 : options.convertClassInstanceToMap) && typeof data === "object") {
131
+ } else if (options?.convertClassInstanceToMap && typeof data === "object") {
131
132
  return convertToMapAttrFromEnumerableProps(data, options);
132
133
  }
133
134
  throw new Error(
@@ -136,16 +137,16 @@ var convertToAttr = /* @__PURE__ */ __name((data, options) => {
136
137
  }, "convertToAttr");
137
138
  var convertToListAttr = /* @__PURE__ */ __name((data, options) => ({
138
139
  L: data.filter(
139
- (item) => typeof item !== "function" && (!(options == null ? void 0 : options.removeUndefinedValues) || (options == null ? void 0 : options.removeUndefinedValues) && item !== void 0)
140
+ (item) => typeof item !== "function" && (!options?.removeUndefinedValues || options?.removeUndefinedValues && item !== void 0)
140
141
  ).map((item) => convertToAttr(item, options))
141
142
  }), "convertToListAttr");
142
143
  var convertToSetAttr = /* @__PURE__ */ __name((set, options) => {
143
- const setToOperate = (options == null ? void 0 : options.removeUndefinedValues) ? new Set([...set].filter((value) => value !== void 0)) : set;
144
- if (!(options == null ? void 0 : options.removeUndefinedValues) && setToOperate.has(void 0)) {
144
+ const setToOperate = options?.removeUndefinedValues ? new Set([...set].filter((value) => value !== void 0)) : set;
145
+ if (!options?.removeUndefinedValues && setToOperate.has(void 0)) {
145
146
  throw new Error(`Pass options.removeUndefinedValues=true to remove undefined values from map/array/set.`);
146
147
  }
147
148
  if (setToOperate.size === 0) {
148
- if (options == null ? void 0 : options.convertEmptyValues) {
149
+ if (options?.convertEmptyValues) {
149
150
  return convertToNullAttr();
150
151
  }
151
152
  throw new Error(`Pass a non-empty set, or options.convertEmptyValues=true.`);
@@ -181,7 +182,7 @@ var convertToMapAttrFromIterable = /* @__PURE__ */ __name((data, options) => ({
181
182
  M: ((data2) => {
182
183
  const map = {};
183
184
  for (const [key, value] of data2) {
184
- if (typeof value !== "function" && (value !== void 0 || !(options == null ? void 0 : options.removeUndefinedValues))) {
185
+ if (typeof value !== "function" && (value !== void 0 || !options?.removeUndefinedValues)) {
185
186
  map[key] = convertToAttr(value, options);
186
187
  }
187
188
  }
@@ -193,7 +194,7 @@ var convertToMapAttrFromEnumerableProps = /* @__PURE__ */ __name((data, options)
193
194
  const map = {};
194
195
  for (const key in data2) {
195
196
  const value = data2[key];
196
- if (typeof value !== "function" && (value !== void 0 || !(options == null ? void 0 : options.removeUndefinedValues))) {
197
+ if (typeof value !== "function" && (value !== void 0 || !options?.removeUndefinedValues)) {
197
198
  map[key] = convertToAttr(value, options);
198
199
  }
199
200
  }
@@ -210,10 +211,10 @@ var validateBigIntAndThrow = /* @__PURE__ */ __name((errorPrefix) => {
210
211
  var convertToNumberAttr = /* @__PURE__ */ __name((num, options) => {
211
212
  if ([Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY].map((val) => val.toString()).includes(num.toString())) {
212
213
  throw new Error(`Special numeric value ${num.toString()} is not allowed`);
213
- } else if (!(options == null ? void 0 : options.allowImpreciseNumbers)) {
214
- if (num > Number.MAX_SAFE_INTEGER) {
214
+ } else if (!options?.allowImpreciseNumbers) {
215
+ if (Number(num) > Number.MAX_SAFE_INTEGER) {
215
216
  validateBigIntAndThrow(`Number ${num.toString()} is greater than Number.MAX_SAFE_INTEGER.`);
216
- } else if (num < Number.MIN_SAFE_INTEGER) {
217
+ } else if (Number(num) < Number.MIN_SAFE_INTEGER) {
217
218
  validateBigIntAndThrow(`Number ${num.toString()} is lesser than Number.MIN_SAFE_INTEGER.`);
218
219
  }
219
220
  }
@@ -238,7 +239,7 @@ var isBinary = /* @__PURE__ */ __name((data) => {
238
239
  "BigInt64Array",
239
240
  "BigUint64Array"
240
241
  ];
241
- if (data == null ? void 0 : data.constructor) {
242
+ if (data?.constructor) {
242
243
  return binaryTypes.includes(data.constructor.name);
243
244
  }
244
245
  return false;
@@ -277,10 +278,10 @@ var convertToNative = /* @__PURE__ */ __name((data, options) => {
277
278
  throw new Error(`No value defined: ${JSON.stringify(data)}`);
278
279
  }, "convertToNative");
279
280
  var convertNumber = /* @__PURE__ */ __name((numString, options) => {
280
- if (typeof (options == null ? void 0 : options.wrapNumbers) === "function") {
281
- return options == null ? void 0 : options.wrapNumbers(numString);
281
+ if (typeof options?.wrapNumbers === "function") {
282
+ return options?.wrapNumbers(numString);
282
283
  }
283
- if (options == null ? void 0 : options.wrapNumbers) {
284
+ if (options?.wrapNumbers) {
284
285
  return NumberValue.from(numString);
285
286
  }
286
287
  const num = Number(numString);
@@ -314,7 +315,7 @@ function marshall(data, options) {
314
315
  switch (key) {
315
316
  case "M":
316
317
  case "L":
317
- return (options == null ? void 0 : options.convertTopLevelContainer) ? attributeValue : value;
318
+ return options?.convertTopLevelContainer ? attributeValue : value;
318
319
  case "SS":
319
320
  case "NS":
320
321
  case "BS":
@@ -332,7 +333,7 @@ __name(marshall, "marshall");
332
333
 
333
334
  // src/unmarshall.ts
334
335
  var unmarshall = /* @__PURE__ */ __name((data, options) => {
335
- if (options == null ? void 0 : options.convertWithoutMapWrapper) {
336
+ if (options?.convertWithoutMapWrapper) {
336
337
  return convertToNative(data, options);
337
338
  }
338
339
  return convertToNative({ M: data }, options);
@@ -1,4 +1,5 @@
1
1
  export class NumberValue {
2
+ value;
2
3
  constructor(value) {
3
4
  if (typeof value === "object" && "N" in value) {
4
5
  this.value = String(value.N);
@@ -140,10 +140,10 @@ const convertToNumberAttr = (num, options) => {
140
140
  throw new Error(`Special numeric value ${num.toString()} is not allowed`);
141
141
  }
142
142
  else if (!options?.allowImpreciseNumbers) {
143
- if (num > Number.MAX_SAFE_INTEGER) {
143
+ if (Number(num) > Number.MAX_SAFE_INTEGER) {
144
144
  validateBigIntAndThrow(`Number ${num.toString()} is greater than Number.MAX_SAFE_INTEGER.`);
145
145
  }
146
- else if (num < Number.MIN_SAFE_INTEGER) {
146
+ else if (Number(num) < Number.MIN_SAFE_INTEGER) {
147
147
  validateBigIntAndThrow(`Number ${num.toString()} is lesser than Number.MIN_SAFE_INTEGER.`);
148
148
  }
149
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/util-dynamodb",
3
- "version": "3.721.0",
3
+ "version": "3.723.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "node ../../scripts/compilation/inline util-dynamodb",
@@ -25,18 +25,18 @@
25
25
  "tslib": "^2.6.2"
26
26
  },
27
27
  "devDependencies": {
28
- "@aws-sdk/client-dynamodb": "3.721.0",
28
+ "@aws-sdk/client-dynamodb": "3.723.0",
29
29
  "@tsconfig/recommended": "1.0.1",
30
30
  "concurrently": "7.0.0",
31
31
  "downlevel-dts": "0.10.1",
32
32
  "rimraf": "3.0.2",
33
- "typescript": "~4.9.5"
33
+ "typescript": "~5.2.2"
34
34
  },
35
35
  "peerDependencies": {
36
- "@aws-sdk/client-dynamodb": "^3.721.0"
36
+ "@aws-sdk/client-dynamodb": "^3.723.0"
37
37
  },
38
38
  "engines": {
39
- "node": ">=16.0.0"
39
+ "node": ">=18.0.0"
40
40
  },
41
41
  "typesVersions": {
42
42
  "<4.0": {