@aws-sdk/util-dynamodb 3.425.0 → 3.428.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.
@@ -8,7 +8,7 @@ function marshall(data, options) {
8
8
  switch (key) {
9
9
  case "M":
10
10
  case "L":
11
- return value;
11
+ return (options === null || options === void 0 ? void 0 : options.convertTopLevelContainer) ? attributeValue : value;
12
12
  case "SS":
13
13
  case "NS":
14
14
  case "BS":
@@ -2,5 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.unmarshall = void 0;
4
4
  const convertToNative_1 = require("./convertToNative");
5
- const unmarshall = (data, options) => (0, convertToNative_1.convertToNative)({ M: data }, options);
5
+ const unmarshall = (data, options) => {
6
+ if (options === null || options === void 0 ? void 0 : options.convertWithoutMapWrapper) {
7
+ return (0, convertToNative_1.convertToNative)(data, options);
8
+ }
9
+ return (0, convertToNative_1.convertToNative)({ M: data }, options);
10
+ };
6
11
  exports.unmarshall = unmarshall;
@@ -5,7 +5,7 @@ export function marshall(data, options) {
5
5
  switch (key) {
6
6
  case "M":
7
7
  case "L":
8
- return value;
8
+ return options?.convertTopLevelContainer ? attributeValue : value;
9
9
  case "SS":
10
10
  case "NS":
11
11
  case "BS":
@@ -1,2 +1,7 @@
1
1
  import { convertToNative } from "./convertToNative";
2
- export const unmarshall = (data, options) => convertToNative({ M: data }, options);
2
+ export const unmarshall = (data, options) => {
3
+ if (options?.convertWithoutMapWrapper) {
4
+ return convertToNative(data, options);
5
+ }
6
+ return convertToNative({ M: data }, options);
7
+ };
@@ -2,9 +2,9 @@ import { AttributeValue } from "@aws-sdk/client-dynamodb";
2
2
  import { marshallOptions } from "./marshall";
3
3
  import { NativeAttributeValue } from "./models";
4
4
  /**
5
- * Convert a JavaScript value to its equivalent DynamoDB AttributeValue type
5
+ * Convert a JavaScript value to its equivalent DynamoDB AttributeValue type.
6
6
  *
7
- * @param {NativeAttributeValue} data - The data to convert to a DynamoDB AttributeValue
8
- * @param {marshallOptions} options - An optional configuration object for `convertToAttr`
7
+ * @param data - The data to convert to a DynamoDB AttributeValue.
8
+ * @param options - An optional configuration object for `convertToAttr`.
9
9
  */
10
10
  export declare const convertToAttr: (data: NativeAttributeValue, options?: marshallOptions) => AttributeValue;
@@ -4,7 +4,7 @@ import { unmarshallOptions } from "./unmarshall";
4
4
  /**
5
5
  * Convert a DynamoDB AttributeValue object to its equivalent JavaScript type.
6
6
  *
7
- * @param {AttributeValue} data - The DynamoDB record to convert to JavaScript type.
8
- * @param {unmarshallOptions} options - An optional configuration object for `convertToNative`.
7
+ * @param data - The DynamoDB record to convert to JavaScript type.
8
+ * @param options - An optional configuration object for `convertToNative`.
9
9
  */
10
10
  export declare const convertToNative: (data: AttributeValue, options?: unmarshallOptions) => NativeAttributeValue;
@@ -16,12 +16,20 @@ export interface marshallOptions {
16
16
  * Whether to convert typeof object to map attribute.
17
17
  */
18
18
  convertClassInstanceToMap?: boolean;
19
+ /**
20
+ * Whether to convert the top level container
21
+ * if it is a map or list.
22
+ *
23
+ * Default is true when using the DynamoDBDocumentClient,
24
+ * but false if directly using the marshall function (backwards compatibility).
25
+ */
26
+ convertTopLevelContainer?: boolean;
19
27
  }
20
28
  /**
21
29
  * Convert a JavaScript object into a DynamoDB record.
22
30
  *
23
- * @param {any} data - The data to convert to a DynamoDB record
24
- * @param {marshallOptions} options - An optional configuration object for `marshall`
31
+ * @param data - The data to convert to a DynamoDB record
32
+ * @param options - An optional configuration object for `marshall`
25
33
  *
26
34
  */
27
35
  export declare function marshall(data: Set<string>, options?: marshallOptions): AttributeValue.SSMember;
@@ -4,6 +4,7 @@ export interface marshallOptions {
4
4
  convertEmptyValues?: boolean;
5
5
  removeUndefinedValues?: boolean;
6
6
  convertClassInstanceToMap?: boolean;
7
+ convertTopLevelContainer?: boolean;
7
8
  }
8
9
  export declare function marshall(
9
10
  data: Set<string>,
@@ -2,8 +2,9 @@ import { AttributeValue } from "@aws-sdk/client-dynamodb";
2
2
  import { NativeAttributeValue } from "./models";
3
3
  export interface unmarshallOptions {
4
4
  wrapNumbers?: boolean;
5
+ convertWithoutMapWrapper?: boolean;
5
6
  }
6
7
  export declare const unmarshall: (
7
- data: Record<string, AttributeValue>,
8
+ data: Record<string, AttributeValue> | AttributeValue,
8
9
  options?: unmarshallOptions
9
10
  ) => Record<string, NativeAttributeValue>;
@@ -9,11 +9,18 @@ export interface unmarshallOptions {
9
9
  * This allows for the safe round-trip transport of numbers of arbitrary size.
10
10
  */
11
11
  wrapNumbers?: boolean;
12
+ /**
13
+ * When true, skip wrapping the data in `{ M: data }` before converting.
14
+ *
15
+ * Default is true when using the DynamoDBDocumentClient,
16
+ * but false if directly using the unmarshall function (backwards compatibility).
17
+ */
18
+ convertWithoutMapWrapper?: boolean;
12
19
  }
13
20
  /**
14
21
  * Convert a DynamoDB record into a JavaScript object.
15
22
  *
16
- * @param {any} data - The DynamoDB record
17
- * @param {unmarshallOptions} options - An optional configuration object for `unmarshall`
23
+ * @param data - The DynamoDB record
24
+ * @param options - An optional configuration object for `unmarshall`
18
25
  */
19
- export declare const unmarshall: (data: Record<string, AttributeValue>, options?: unmarshallOptions) => Record<string, NativeAttributeValue>;
26
+ export declare const unmarshall: (data: Record<string, AttributeValue> | AttributeValue, options?: unmarshallOptions) => Record<string, NativeAttributeValue>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/util-dynamodb",
3
- "version": "3.425.0",
3
+ "version": "3.428.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",
@@ -24,7 +24,7 @@
24
24
  "tslib": "^2.5.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@aws-sdk/client-dynamodb": "3.425.0",
27
+ "@aws-sdk/client-dynamodb": "3.428.0",
28
28
  "@tsconfig/recommended": "1.0.1",
29
29
  "concurrently": "7.0.0",
30
30
  "downlevel-dts": "0.10.1",