@moicky/dynamodb 2.5.7 → 2.5.9

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/index.d.ts CHANGED
@@ -3,5 +3,5 @@ export * from "./operations";
3
3
  export * from "./transactions";
4
4
  export { createCustomReference, getDependencies, resolveReferences, } from "./transactions/references";
5
5
  export type { DynamoDBItemKey, ItemWithKey, Prettify, DynamoDBSet, } from "./transactions/types";
6
- export type { ReferenceMetadata, ReferenceTo, ResolvedItem, WithoutReferences, } from "./transactions/references/types";
6
+ export type { DynamoDBReference, ReferenceMetadata, ReferenceTo, ResolvedItem, WithoutReferences, } from "./transactions/references/types";
7
7
  export type * from "./types";
@@ -7,14 +7,14 @@ const createReference = (ref, transaction) => {
7
7
  const { item, references, onAttribute } = ref;
8
8
  const referenceKey = {
9
9
  PK: references.PK,
10
- ...(references.SK && { SK: references.SK }),
10
+ ...(references.SK !== undefined && { SK: references.SK }),
11
11
  };
12
12
  const referenceItem = {
13
13
  PK: "dynamodb:reference",
14
14
  SK: (0, crypto_1.randomUUID)(),
15
15
  item: {
16
16
  PK: item.PK,
17
- ...(item.SK && { SK: item.SK }),
17
+ ...(item.SK !== undefined && { SK: item.SK }),
18
18
  },
19
19
  references: referenceKey,
20
20
  onAttribute,
@@ -79,11 +79,11 @@ const createCustomReference = async (baseItem, references, onAttribute) => (0, o
79
79
  SK: (0, crypto_1.randomUUID)(),
80
80
  item: {
81
81
  PK: baseItem.PK,
82
- ...(baseItem.SK && { SK: baseItem.SK }),
82
+ ...(baseItem.SK !== undefined && { SK: baseItem.SK }),
83
83
  },
84
84
  references: {
85
85
  PK: references.PK,
86
- ...(references.SK && { SK: references.SK }),
86
+ ...(references.SK !== undefined && { SK: references.SK }),
87
87
  },
88
88
  onAttribute: onAttribute || "",
89
89
  }, { ReturnValues: "ALL_NEW" });
@@ -101,7 +101,7 @@ const getDependencies = async (item) => (0, operations_1.queryAllItems)("#PK = :
101
101
  PK: "dynamodb:reference",
102
102
  references: {
103
103
  PK: item.PK,
104
- ...(item.SK && { SK: item.SK }),
104
+ ...(item.SK !== undefined && { SK: item.SK }),
105
105
  },
106
106
  }, { FilterExpression: "#references = :references" });
107
107
  exports.getDependencies = getDependencies;
@@ -1,6 +1,6 @@
1
1
  import { DynamoDBItem } from "../../types";
2
2
  import { DynamoDBItemKey, ItemWithKey } from "../types";
3
- export type DynamoDBReference<T extends ItemWithKey = ItemWithKey> = T extends any[] ? never : {
3
+ export type DynamoDBReference<T extends DynamoDBItemKey = DynamoDBItemKey> = T extends any[] ? never : {
4
4
  _type: "dynamodb:reference";
5
5
  _target: T;
6
6
  _refId: ReferenceMetadata["SK"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moicky/dynamodb",
3
- "version": "2.5.7",
3
+ "version": "2.5.9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Contains a collection of convenience functions for working with AWS DynamoDB",