dyna-record 0.6.6 → 0.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/README.md +23 -7
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -22
- package/dist/src/DynaRecord.d.ts +3 -3
- package/dist/src/DynaRecord.d.ts.map +1 -1
- package/dist/src/DynaRecord.js +24 -59
- package/dist/src/Logger.js +1 -3
- package/dist/src/decorators/Entity.d.ts +1 -1
- package/dist/src/decorators/Entity.d.ts.map +1 -1
- package/dist/src/decorators/Entity.js +3 -8
- package/dist/src/decorators/Table.d.ts +2 -2
- package/dist/src/decorators/Table.d.ts.map +1 -1
- package/dist/src/decorators/Table.js +3 -8
- package/dist/src/decorators/attributes/BooleanAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/BooleanAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/BooleanAttribute.js +6 -10
- package/dist/src/decorators/attributes/DateAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/DateAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/DateAttribute.js +8 -12
- package/dist/src/decorators/attributes/EnumAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/EnumAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/EnumAttribute.js +7 -10
- package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts +3 -3
- package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/ForeignKeyAttribute.js +6 -10
- package/dist/src/decorators/attributes/IdAttribute.d.ts +1 -1
- package/dist/src/decorators/attributes/IdAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/IdAttribute.js +3 -8
- package/dist/src/decorators/attributes/NumberAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/NumberAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/NumberAttribute.js +6 -10
- package/dist/src/decorators/attributes/ObjectAttribute.d.ts +3 -3
- package/dist/src/decorators/attributes/ObjectAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/ObjectAttribute.js +17 -21
- package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts +3 -3
- package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/PartitionKeyAttribute.js +6 -10
- package/dist/src/decorators/attributes/SortKeyAttribute.d.ts +3 -3
- package/dist/src/decorators/attributes/SortKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/SortKeyAttribute.js +6 -10
- package/dist/src/decorators/attributes/StringAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/StringAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/StringAttribute.js +6 -10
- package/dist/src/decorators/attributes/index.d.ts +13 -13
- package/dist/src/decorators/attributes/index.d.ts.map +1 -1
- package/dist/src/decorators/attributes/index.js +11 -41
- package/dist/src/decorators/attributes/serializers.d.ts +2 -2
- package/dist/src/decorators/attributes/serializers.d.ts.map +1 -1
- package/dist/src/decorators/attributes/serializers.js +5 -12
- package/dist/src/decorators/attributes/types.js +1 -2
- package/dist/src/decorators/index.d.ts +5 -5
- package/dist/src/decorators/index.d.ts.map +1 -1
- package/dist/src/decorators/index.js +5 -27
- package/dist/src/decorators/relationships/BelongsTo.d.ts +4 -4
- package/dist/src/decorators/relationships/BelongsTo.d.ts.map +1 -1
- package/dist/src/decorators/relationships/BelongsTo.js +3 -8
- package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts +3 -3
- package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasAndBelongsToMany.js +4 -9
- package/dist/src/decorators/relationships/HasMany.d.ts +3 -3
- package/dist/src/decorators/relationships/HasMany.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasMany.js +4 -9
- package/dist/src/decorators/relationships/HasOne.d.ts +3 -3
- package/dist/src/decorators/relationships/HasOne.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasOne.js +3 -8
- package/dist/src/decorators/relationships/index.d.ts +5 -5
- package/dist/src/decorators/relationships/index.d.ts.map +1 -1
- package/dist/src/decorators/relationships/index.js +5 -29
- package/dist/src/decorators/relationships/types.d.ts +3 -3
- package/dist/src/decorators/relationships/types.d.ts.map +1 -1
- package/dist/src/decorators/relationships/types.js +1 -2
- package/dist/src/decorators/types.d.ts +3 -3
- package/dist/src/decorators/types.d.ts.map +1 -1
- package/dist/src/decorators/types.js +1 -2
- package/dist/src/dynamo-utils/DynamoClient.d.ts +1 -1
- package/dist/src/dynamo-utils/DynamoClient.d.ts.map +1 -1
- package/dist/src/dynamo-utils/DynamoClient.js +13 -18
- package/dist/src/dynamo-utils/TransactGetBuilder.d.ts +1 -1
- package/dist/src/dynamo-utils/TransactGetBuilder.d.ts.map +1 -1
- package/dist/src/dynamo-utils/TransactGetBuilder.js +5 -10
- package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts +1 -1
- package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts.map +1 -1
- package/dist/src/dynamo-utils/TransactWriteBuilder.js +11 -16
- package/dist/src/dynamo-utils/errors.js +2 -7
- package/dist/src/dynamo-utils/index.d.ts +7 -7
- package/dist/src/dynamo-utils/index.d.ts.map +1 -1
- package/dist/src/dynamo-utils/index.js +7 -30
- package/dist/src/dynamo-utils/types.js +1 -2
- package/dist/src/errors.js +3 -9
- package/dist/src/id.d.ts +12 -0
- package/dist/src/id.d.ts.map +1 -0
- package/dist/src/id.js +11 -0
- package/dist/src/index.d.ts +8 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -20
- package/dist/src/metadata/AttributeMetadata.d.ts +6 -4
- package/dist/src/metadata/AttributeMetadata.d.ts.map +1 -1
- package/dist/src/metadata/AttributeMetadata.js +5 -3
- package/dist/src/metadata/EntityMetadata.d.ts +3 -3
- package/dist/src/metadata/EntityMetadata.d.ts.map +1 -1
- package/dist/src/metadata/EntityMetadata.js +18 -23
- package/dist/src/metadata/JoinTableMetadata.d.ts +3 -3
- package/dist/src/metadata/JoinTableMetadata.d.ts.map +1 -1
- package/dist/src/metadata/JoinTableMetadata.js +1 -3
- package/dist/src/metadata/MetadataStorage.d.ts +7 -7
- package/dist/src/metadata/MetadataStorage.d.ts.map +1 -1
- package/dist/src/metadata/MetadataStorage.js +12 -17
- package/dist/src/metadata/TableMetadata.d.ts +3 -3
- package/dist/src/metadata/TableMetadata.d.ts.map +1 -1
- package/dist/src/metadata/TableMetadata.js +22 -21
- package/dist/src/metadata/index.d.ts +9 -9
- package/dist/src/metadata/index.d.ts.map +1 -1
- package/dist/src/metadata/index.js +11 -34
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts +1 -1
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/RelationshipMetadata.js +1 -3
- package/dist/src/metadata/relationship-metadata/index.d.ts +6 -6
- package/dist/src/metadata/relationship-metadata/index.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/index.js +7 -31
- package/dist/src/metadata/relationship-metadata/types.d.ts +5 -5
- package/dist/src/metadata/relationship-metadata/types.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/types.js +1 -2
- package/dist/src/metadata/relationship-metadata/utils.d.ts +1 -1
- package/dist/src/metadata/relationship-metadata/utils.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/utils.js +11 -18
- package/dist/src/metadata/schemas.d.ts +523 -36
- package/dist/src/metadata/schemas.d.ts.map +1 -1
- package/dist/src/metadata/schemas.js +71 -44
- package/dist/src/metadata/types.d.ts +17 -4
- package/dist/src/metadata/types.d.ts.map +1 -1
- package/dist/src/metadata/types.js +1 -2
- package/dist/src/metadata/utils.d.ts +5 -5
- package/dist/src/metadata/utils.d.ts.map +1 -1
- package/dist/src/metadata/utils.js +14 -29
- package/dist/src/operations/Create/Create.d.ts +5 -5
- package/dist/src/operations/Create/Create.d.ts.map +1 -1
- package/dist/src/operations/Create/Create.js +18 -23
- package/dist/src/operations/Create/index.d.ts +2 -2
- package/dist/src/operations/Create/index.d.ts.map +1 -1
- package/dist/src/operations/Create/index.js +2 -23
- package/dist/src/operations/Create/types.d.ts +2 -2
- package/dist/src/operations/Create/types.d.ts.map +1 -1
- package/dist/src/operations/Create/types.js +1 -2
- package/dist/src/operations/Delete/Delete.d.ts +3 -3
- package/dist/src/operations/Delete/Delete.d.ts.map +1 -1
- package/dist/src/operations/Delete/Delete.js +28 -33
- package/dist/src/operations/Delete/index.d.ts +1 -1
- package/dist/src/operations/Delete/index.d.ts.map +1 -1
- package/dist/src/operations/Delete/index.js +1 -8
- package/dist/src/operations/Delete/types.js +1 -2
- package/dist/src/operations/FindById/FindById.d.ts +4 -4
- package/dist/src/operations/FindById/FindById.d.ts.map +1 -1
- package/dist/src/operations/FindById/FindById.js +17 -22
- package/dist/src/operations/FindById/index.d.ts +2 -2
- package/dist/src/operations/FindById/index.d.ts.map +1 -1
- package/dist/src/operations/FindById/index.js +2 -23
- package/dist/src/operations/FindById/types.d.ts +3 -3
- package/dist/src/operations/FindById/types.d.ts.map +1 -1
- package/dist/src/operations/FindById/types.js +1 -2
- package/dist/src/operations/OperationBase.d.ts +3 -3
- package/dist/src/operations/OperationBase.d.ts.map +1 -1
- package/dist/src/operations/OperationBase.js +4 -9
- package/dist/src/operations/Query/Query.d.ts +4 -4
- package/dist/src/operations/Query/Query.d.ts.map +1 -1
- package/dist/src/operations/Query/Query.js +15 -20
- package/dist/src/operations/Query/index.d.ts +2 -2
- package/dist/src/operations/Query/index.d.ts.map +1 -1
- package/dist/src/operations/Query/index.js +2 -23
- package/dist/src/operations/Query/types.d.ts +4 -4
- package/dist/src/operations/Query/types.d.ts.map +1 -1
- package/dist/src/operations/Query/types.js +1 -2
- package/dist/src/operations/Update/Update.d.ts +5 -5
- package/dist/src/operations/Update/Update.d.ts.map +1 -1
- package/dist/src/operations/Update/Update.js +37 -42
- package/dist/src/operations/Update/UpdateDryRun.d.ts +2 -2
- package/dist/src/operations/Update/UpdateDryRun.d.ts.map +1 -1
- package/dist/src/operations/Update/UpdateDryRun.js +3 -8
- package/dist/src/operations/Update/index.d.ts +3 -3
- package/dist/src/operations/Update/index.d.ts.map +1 -1
- package/dist/src/operations/Update/index.js +3 -25
- package/dist/src/operations/Update/types.d.ts +2 -2
- package/dist/src/operations/Update/types.d.ts.map +1 -1
- package/dist/src/operations/Update/types.js +1 -2
- package/dist/src/operations/index.d.ts +6 -6
- package/dist/src/operations/index.d.ts.map +1 -1
- package/dist/src/operations/index.js +6 -22
- package/dist/src/operations/types.d.ts +3 -3
- package/dist/src/operations/types.d.ts.map +1 -1
- package/dist/src/operations/types.js +1 -2
- package/dist/src/operations/utils/expressionBuilder.d.ts +2 -2
- package/dist/src/operations/utils/expressionBuilder.d.ts.map +1 -1
- package/dist/src/operations/utils/expressionBuilder.js +1 -5
- package/dist/src/operations/utils/flattenObjectForUpdate.d.ts +2 -2
- package/dist/src/operations/utils/flattenObjectForUpdate.d.ts.map +1 -1
- package/dist/src/operations/utils/flattenObjectForUpdate.js +3 -6
- package/dist/src/operations/utils/index.d.ts +5 -5
- package/dist/src/operations/utils/index.d.ts.map +1 -1
- package/dist/src/operations/utils/index.js +5 -21
- package/dist/src/operations/utils/mergePartialObjectAttributes.d.ts +1 -1
- package/dist/src/operations/utils/mergePartialObjectAttributes.d.ts.map +1 -1
- package/dist/src/operations/utils/mergePartialObjectAttributes.js +1 -4
- package/dist/src/operations/utils/types.js +1 -2
- package/dist/src/operations/utils/utils.d.ts +4 -4
- package/dist/src/operations/utils/utils.d.ts.map +1 -1
- package/dist/src/operations/utils/utils.js +13 -23
- package/dist/src/query-utils/Filters.d.ts +2 -2
- package/dist/src/query-utils/Filters.d.ts.map +1 -1
- package/dist/src/query-utils/Filters.js +1 -4
- package/dist/src/query-utils/QueryBuilder.d.ts +1 -1
- package/dist/src/query-utils/QueryBuilder.d.ts.map +1 -1
- package/dist/src/query-utils/QueryBuilder.js +8 -13
- package/dist/src/query-utils/index.d.ts +2 -2
- package/dist/src/query-utils/index.d.ts.map +1 -1
- package/dist/src/query-utils/index.js +2 -23
- package/dist/src/query-utils/types.js +1 -2
- package/dist/src/relationships/JoinTable.d.ts +2 -2
- package/dist/src/relationships/JoinTable.d.ts.map +1 -1
- package/dist/src/relationships/JoinTable.js +14 -19
- package/dist/src/relationships/index.d.ts +1 -1
- package/dist/src/relationships/index.d.ts.map +1 -1
- package/dist/src/relationships/index.js +1 -8
- package/dist/src/types.d.ts +2 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -2
- package/dist/src/utils.d.ts +3 -3
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +16 -31
- package/package.json +28 -24
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type DynaRecord from "../../DynaRecord";
|
|
2
|
-
import { TransactWriteBuilder } from "../../dynamo-utils";
|
|
3
|
-
import OperationBase from "../OperationBase";
|
|
4
|
-
import type { UpdatedAttributes, UpdateOptions, UpdateOperationOptions } from "./types";
|
|
5
|
-
import type { EntityClass } from "../../types";
|
|
1
|
+
import type DynaRecord from "../../DynaRecord.js";
|
|
2
|
+
import { TransactWriteBuilder } from "../../dynamo-utils/index.js";
|
|
3
|
+
import OperationBase from "../OperationBase.js";
|
|
4
|
+
import type { UpdatedAttributes, UpdateOptions, UpdateOperationOptions } from "./types.js";
|
|
5
|
+
import type { EntityClass } from "../../types.js";
|
|
6
6
|
/**
|
|
7
7
|
* Represents an update operation for a DynaRecord-backed entity, handling both attribute updates and relationship consistency via denormalization.
|
|
8
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Update.d.ts","sourceRoot":"","sources":["../../../../src/operations/Update/Update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"Update.d.ts","sourceRoot":"","sources":["../../../../src/operations/Update/Update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAGL,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AAqBrC,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAEV,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AA4DxB;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAM,MAAM,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IACzD,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,oBAAoB,CAAC;gBAG1D,MAAM,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5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const utils_2 = require("../utils");
|
|
9
|
-
const OperationBase_1 = __importDefault(require("../OperationBase"));
|
|
10
|
-
const metadata_1 = __importDefault(require("../../metadata"));
|
|
11
|
-
const errors_1 = require("../../errors");
|
|
12
|
-
const utils_3 = require("../../metadata/utils");
|
|
1
|
+
import { TransactGetBuilder, TransactWriteBuilder } from "../../dynamo-utils/index.js";
|
|
2
|
+
import { entityToTableItem, isKeyOfObject, isNullableString, isString, tableItemToEntity } from "../../utils.js";
|
|
3
|
+
import { buildBelongsToLinkKey, expressionBuilder, extractForeignKeyFromEntity, flattenObjectForUpdate } from "../utils/index.js";
|
|
4
|
+
import OperationBase from "../OperationBase.js";
|
|
5
|
+
import Metadata from "../../metadata/index.js";
|
|
6
|
+
import { NotFoundError } from "../../errors.js";
|
|
7
|
+
import { isBelongsToRelationship, isHasManyRelationship } from "../../metadata/utils.js";
|
|
13
8
|
/**
|
|
14
9
|
* Represents an update operation for a DynaRecord-backed entity, handling both attribute updates and relationship consistency via denormalization.
|
|
15
10
|
*
|
|
@@ -28,12 +23,12 @@ const utils_3 = require("../../metadata/utils");
|
|
|
28
23
|
*
|
|
29
24
|
* @template T - The type of the entity being updated, extending `DynaRecord`.
|
|
30
25
|
*/
|
|
31
|
-
class Update extends
|
|
26
|
+
class Update extends OperationBase {
|
|
32
27
|
transactionBuilder;
|
|
33
28
|
constructor(Entity, transactionBuilder) {
|
|
34
29
|
super(Entity);
|
|
35
30
|
// Use the transaction builder passed to the class, or instantiate a new one
|
|
36
|
-
this.transactionBuilder = transactionBuilder ?? new
|
|
31
|
+
this.transactionBuilder = transactionBuilder ?? new TransactWriteBuilder();
|
|
37
32
|
}
|
|
38
33
|
/**
|
|
39
34
|
* Executes the update operation against DynamoDB.
|
|
@@ -52,7 +47,7 @@ class Update extends OperationBase_1.default {
|
|
|
52
47
|
*/
|
|
53
48
|
async run(id, attributes, options) {
|
|
54
49
|
const referentialIntegrityCheck = options?.referentialIntegrityCheck ?? true;
|
|
55
|
-
const entityMeta =
|
|
50
|
+
const entityMeta = Metadata.getEntity(this.EntityClass.name);
|
|
56
51
|
const entityAttrs = entityMeta.parseRawEntityDefinedAttributesPartial(attributes);
|
|
57
52
|
const { updatedAttrs, expression } = this.buildUpdateMetadata(entityAttrs);
|
|
58
53
|
this.buildUpdateItemTransaction(id, expression);
|
|
@@ -83,7 +78,7 @@ class Update extends OperationBase_1.default {
|
|
|
83
78
|
*/
|
|
84
79
|
getBelongsToRelMetaAndKeyForUpdatedKeys(attributes) {
|
|
85
80
|
return this.entityMetadata.belongsToRelationships.reduce((acc, meta) => {
|
|
86
|
-
const foreignKeyVal =
|
|
81
|
+
const foreignKeyVal = extractForeignKeyFromEntity(meta, attributes);
|
|
87
82
|
if (foreignKeyVal != null)
|
|
88
83
|
acc.push({ meta, foreignKeyVal });
|
|
89
84
|
return acc;
|
|
@@ -103,10 +98,10 @@ class Update extends OperationBase_1.default {
|
|
|
103
98
|
const standaloneForeignKeys = this.entityMetadata.standaloneForeignKeyAttributes;
|
|
104
99
|
for (const attrMeta of standaloneForeignKeys) {
|
|
105
100
|
const target = attrMeta.foreignKeyTarget;
|
|
106
|
-
if (!
|
|
101
|
+
if (!isKeyOfObject(attributes, attrMeta.name))
|
|
107
102
|
continue;
|
|
108
103
|
const foreignKeyValue = attributes[attrMeta.name];
|
|
109
|
-
if (!
|
|
104
|
+
if (!isString(foreignKeyValue))
|
|
110
105
|
continue;
|
|
111
106
|
const foreignKey = foreignKeyValue;
|
|
112
107
|
const errMsg = `${target.name} with ID '${foreignKey}' does not exist`;
|
|
@@ -138,9 +133,9 @@ class Update extends OperationBase_1.default {
|
|
|
138
133
|
* @private
|
|
139
134
|
*/
|
|
140
135
|
async preFetch(id, belongsToRelFkAndMetas) {
|
|
141
|
-
const hasRelMetas = this.entityMetadata.hasRelationships.filter(rel => !
|
|
136
|
+
const hasRelMetas = this.entityMetadata.hasRelationships.filter(rel => !isHasManyRelationship(rel) || rel.uniDirectional !== true);
|
|
142
137
|
const { name: tableName } = this.tableMetadata;
|
|
143
|
-
const transactionBuilder = new
|
|
138
|
+
const transactionBuilder = new TransactGetBuilder();
|
|
144
139
|
// Get the new BelongsTo relationship entities that are being updated
|
|
145
140
|
belongsToRelFkAndMetas.forEach(({ meta, foreignKeyVal }) => {
|
|
146
141
|
transactionBuilder.addGet({
|
|
@@ -167,9 +162,9 @@ class Update extends OperationBase_1.default {
|
|
|
167
162
|
]);
|
|
168
163
|
// Serialize table items to entities
|
|
169
164
|
const foreignEntities = transactionResults.reduce((acc, res) => {
|
|
170
|
-
if (res.Item !== undefined &&
|
|
171
|
-
const entityMeta =
|
|
172
|
-
const entity =
|
|
165
|
+
if (res.Item !== undefined && isString(res.Item[typeAlias])) {
|
|
166
|
+
const entityMeta = Metadata.getEntity(res.Item[typeAlias]);
|
|
167
|
+
const entity = tableItemToEntity(entityMeta.EntityClass, res.Item);
|
|
173
168
|
acc.push(entity);
|
|
174
169
|
}
|
|
175
170
|
return acc;
|
|
@@ -199,7 +194,7 @@ class Update extends OperationBase_1.default {
|
|
|
199
194
|
}
|
|
200
195
|
});
|
|
201
196
|
if (entityPreUpdate === undefined) {
|
|
202
|
-
throw new
|
|
197
|
+
throw new NotFoundError(`${this.EntityClass.name} does not exist: ${id}`);
|
|
203
198
|
}
|
|
204
199
|
return { entityPreUpdate, relatedEntities, newBelongsToEntityLookup };
|
|
205
200
|
}
|
|
@@ -226,7 +221,7 @@ class Update extends OperationBase_1.default {
|
|
|
226
221
|
...attributes,
|
|
227
222
|
updatedAt: new Date()
|
|
228
223
|
};
|
|
229
|
-
const entityAttrs =
|
|
224
|
+
const entityAttrs = Metadata.getEntityAttributes(this.EntityClass.name);
|
|
230
225
|
// Separate ObjectAttribute fields (non-null) for document path handling
|
|
231
226
|
const regularAttrs = {};
|
|
232
227
|
const allDocumentPathOps = [];
|
|
@@ -239,7 +234,7 @@ class Update extends OperationBase_1.default {
|
|
|
239
234
|
if (attrMeta.objectSchema !== undefined) {
|
|
240
235
|
// ObjectAttribute → flatten for document path updates (objects are never nullable)
|
|
241
236
|
const alias = attrMeta.alias;
|
|
242
|
-
const ops =
|
|
237
|
+
const ops = flattenObjectForUpdate([alias], attrMeta.objectSchema, val);
|
|
243
238
|
allDocumentPathOps.push(...ops);
|
|
244
239
|
}
|
|
245
240
|
else {
|
|
@@ -247,8 +242,8 @@ class Update extends OperationBase_1.default {
|
|
|
247
242
|
regularAttrs[key] = val;
|
|
248
243
|
}
|
|
249
244
|
}
|
|
250
|
-
const tableAttrs =
|
|
251
|
-
const expression =
|
|
245
|
+
const tableAttrs = entityToTableItem(this.EntityClass, regularAttrs);
|
|
246
|
+
const expression = expressionBuilder(tableAttrs, allDocumentPathOps);
|
|
252
247
|
return { updatedAttrs, expression };
|
|
253
248
|
}
|
|
254
249
|
/**
|
|
@@ -270,7 +265,7 @@ class Update extends OperationBase_1.default {
|
|
|
270
265
|
[pk]: this.EntityClass.partitionKeyValue(id),
|
|
271
266
|
[sk]: this.EntityClass.name
|
|
272
267
|
};
|
|
273
|
-
const tableKeys =
|
|
268
|
+
const tableKeys = entityToTableItem(this.EntityClass, keys);
|
|
274
269
|
this.transactionBuilder.addUpdate({
|
|
275
270
|
TableName: tableName,
|
|
276
271
|
Key: tableKeys,
|
|
@@ -297,11 +292,11 @@ class Update extends OperationBase_1.default {
|
|
|
297
292
|
const entityId = entityPreUpdate.id;
|
|
298
293
|
const relMetas = this.entityMetadata.belongsToOrOwnedByRelationships;
|
|
299
294
|
for (const relMeta of relMetas) {
|
|
300
|
-
const foreignKey =
|
|
295
|
+
const foreignKey = extractForeignKeyFromEntity(relMeta, updatedEntity);
|
|
301
296
|
const isUpdatingRelationshipId = foreignKey !== undefined;
|
|
302
|
-
if (isUpdatingRelationshipId &&
|
|
297
|
+
if (isUpdatingRelationshipId && isNullableString(foreignKey)) {
|
|
303
298
|
// Handle removal of old link if the foreign key changed.
|
|
304
|
-
const oldFk =
|
|
299
|
+
const oldFk = extractForeignKeyFromEntity(relMeta, entityPreUpdate);
|
|
305
300
|
const isAddingForeignKey = oldFk === undefined && foreignKey !== null;
|
|
306
301
|
const isUpdatingForeignKey = oldFk !== undefined && oldFk !== foreignKey;
|
|
307
302
|
const isRemovingForeignKey = isUpdatingForeignKey && foreignKey === null;
|
|
@@ -335,7 +330,7 @@ class Update extends OperationBase_1.default {
|
|
|
335
330
|
*/
|
|
336
331
|
buildUpdateBelongsToLinkedRecords(entityId, relMeta, foreignKey, updateExpression) {
|
|
337
332
|
const { name: tableName } = this.tableMetadata;
|
|
338
|
-
const newKey =
|
|
333
|
+
const newKey = buildBelongsToLinkKey(this.EntityClass, entityId, relMeta, foreignKey);
|
|
339
334
|
this.transactionBuilder.addUpdate({
|
|
340
335
|
TableName: tableName,
|
|
341
336
|
Key: newKey,
|
|
@@ -363,7 +358,7 @@ class Update extends OperationBase_1.default {
|
|
|
363
358
|
}
|
|
364
359
|
// Denormalize entity being updated to foreign partition
|
|
365
360
|
this.buildLinkToForeignEntityTransaction(updatedEntity, relMeta, foreignKey);
|
|
366
|
-
if (
|
|
361
|
+
if (isBelongsToRelationship(relMeta)) {
|
|
367
362
|
// Add denormalized record for new entity to self
|
|
368
363
|
this.buildAddForeignEntityToSelfTransaction(updatedEntity, relMeta, foreignKey, newBelongsToEntityLookup, persistToSelfCondition, persistToSelfConditionErrMessage);
|
|
369
364
|
}
|
|
@@ -392,8 +387,8 @@ class Update extends OperationBase_1.default {
|
|
|
392
387
|
* @param foreignKey
|
|
393
388
|
*/
|
|
394
389
|
buildLinkToForeignEntityTransaction(updatedEntity, relMeta, foreignKey) {
|
|
395
|
-
const key =
|
|
396
|
-
const tableItem =
|
|
390
|
+
const key = buildBelongsToLinkKey(this.EntityClass, updatedEntity.id, relMeta, foreignKey);
|
|
391
|
+
const tableItem = entityToTableItem(this.EntityClass, updatedEntity);
|
|
397
392
|
this.transactionBuilder.addPut({
|
|
398
393
|
TableName: this.tableMetadata.name,
|
|
399
394
|
Item: { ...tableItem, ...key },
|
|
@@ -411,14 +406,14 @@ class Update extends OperationBase_1.default {
|
|
|
411
406
|
*/
|
|
412
407
|
buildAddForeignEntityToSelfTransaction(updatedEntity, relMeta, foreignKey, newBelongsToEntityLookup, persistToSelfCondition, persistToSelfConditionErrMessage) {
|
|
413
408
|
if (!(foreignKey in newBelongsToEntityLookup)) {
|
|
414
|
-
throw new
|
|
409
|
+
throw new NotFoundError(`${relMeta.target.name} does not exist: ${foreignKey}`);
|
|
415
410
|
}
|
|
416
411
|
const linkedEntity = newBelongsToEntityLookup[foreignKey];
|
|
417
412
|
const key = {
|
|
418
413
|
[this.partitionKeyAlias]: this.EntityClass.partitionKeyValue(updatedEntity.id),
|
|
419
414
|
[this.sortKeyAlias]: relMeta.target.name
|
|
420
415
|
};
|
|
421
|
-
const linkedRecordTableItem =
|
|
416
|
+
const linkedRecordTableItem = entityToTableItem(relMeta.target, linkedEntity);
|
|
422
417
|
this.transactionBuilder.addPut({
|
|
423
418
|
TableName: this.tableMetadata.name,
|
|
424
419
|
Item: { ...linkedRecordTableItem, ...key },
|
|
@@ -443,9 +438,9 @@ class Update extends OperationBase_1.default {
|
|
|
443
438
|
[this.sortKeyAlias]: relMeta.target.name
|
|
444
439
|
};
|
|
445
440
|
// Keys to delete the linked record from the foreign entities partition
|
|
446
|
-
const oldKeysToForeignEntity =
|
|
441
|
+
const oldKeysToForeignEntity = buildBelongsToLinkKey(this.EntityClass, entityId, relMeta, oldForeignKey);
|
|
447
442
|
// OwnedByRelationships do not have a record to delete from their own partition because its unidirectional
|
|
448
|
-
if (
|
|
443
|
+
if (isBelongsToRelationship(relMeta)) {
|
|
449
444
|
this.transactionBuilder.addDelete({
|
|
450
445
|
TableName: this.tableMetadata.name,
|
|
451
446
|
Key: oldKeysToSelf
|
|
@@ -468,7 +463,7 @@ class Update extends OperationBase_1.default {
|
|
|
468
463
|
*/
|
|
469
464
|
updateForeignKeyTransactions(updatedEntity, relMeta, newForeignKey, oldForeignKey, newBelongsToEntityLookup, referentialIntegrityCheck) {
|
|
470
465
|
// Keys to delete the linked record from the foreign entities partition
|
|
471
|
-
const oldKeysToForeignEntity =
|
|
466
|
+
const oldKeysToForeignEntity = buildBelongsToLinkKey(this.EntityClass, updatedEntity.id, relMeta, oldForeignKey);
|
|
472
467
|
this.transactionBuilder.addDelete({
|
|
473
468
|
TableName: this.tableMetadata.name,
|
|
474
469
|
Key: oldKeysToForeignEntity
|
|
@@ -527,4 +522,4 @@ class Update extends OperationBase_1.default {
|
|
|
527
522
|
}, {});
|
|
528
523
|
}
|
|
529
524
|
}
|
|
530
|
-
|
|
525
|
+
export default Update;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateDryRun.d.ts","sourceRoot":"","sources":["../../../../src/operations/Update/UpdateDryRun.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"UpdateDryRun.d.ts","sourceRoot":"","sources":["../../../../src/operations/Update/UpdateDryRun.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC;;GAEG;AACH,cAAM,YAAY,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,MAAM,CAAC,CAAC,CAAC;cAC/B,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5D;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const Update_1 = __importDefault(require("./Update"));
|
|
1
|
+
import Update from "./Update.js";
|
|
7
2
|
/**
|
|
8
3
|
* Runs Update operation with out committing the transaction
|
|
9
4
|
*/
|
|
10
|
-
class UpdateDryRun extends
|
|
5
|
+
class UpdateDryRun extends Update {
|
|
11
6
|
async commitTransaction() {
|
|
12
7
|
// No-op
|
|
13
8
|
}
|
|
14
9
|
}
|
|
15
|
-
|
|
10
|
+
export default UpdateDryRun;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as Update } from "./Update";
|
|
2
|
-
export * from "./types";
|
|
3
|
-
export { default as UpdateDryRun } from "./UpdateDryRun";
|
|
1
|
+
export { default as Update } from "./Update.js";
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export { default as UpdateDryRun } from "./UpdateDryRun.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/operations/Update/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/operations/Update/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.UpdateDryRun = exports.Update = void 0;
|
|
21
|
-
var Update_1 = require("./Update");
|
|
22
|
-
Object.defineProperty(exports, "Update", { enumerable: true, get: function () { return __importDefault(Update_1).default; } });
|
|
23
|
-
__exportStar(require("./types"), exports);
|
|
24
|
-
var UpdateDryRun_1 = require("./UpdateDryRun");
|
|
25
|
-
Object.defineProperty(exports, "UpdateDryRun", { enumerable: true, get: function () { return __importDefault(UpdateDryRun_1).default; } });
|
|
1
|
+
export { default as Update } from "./Update.js";
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export { default as UpdateDryRun } from "./UpdateDryRun.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type DynaRecord from "../../DynaRecord";
|
|
2
|
-
import type { EntityDefinedAttributes } from "../types";
|
|
1
|
+
import type DynaRecord from "../../DynaRecord.js";
|
|
2
|
+
import type { EntityDefinedAttributes } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Extracts the keys of properties in type `T` that are explicitly allowed to be `undefined`.
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/operations/Update/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/operations/Update/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D;;;;;GAKG;AACH,KAAK,kBAAkB,CAAC,CAAC,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, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./FindById";
|
|
2
|
-
export * from "./Query";
|
|
3
|
-
export * from "./Update";
|
|
4
|
-
export * from "./Create";
|
|
5
|
-
export * from "./Delete";
|
|
6
|
-
export * from "./types";
|
|
1
|
+
export * from "./FindById/index.js";
|
|
2
|
+
export * from "./Query/index.js";
|
|
3
|
+
export * from "./Update/index.js";
|
|
4
|
+
export * from "./Create/index.js";
|
|
5
|
+
export * from "./Delete/index.js";
|
|
6
|
+
export * from "./types.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/operations/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/operations/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./FindById"), exports);
|
|
18
|
-
__exportStar(require("./Query"), exports);
|
|
19
|
-
__exportStar(require("./Update"), exports);
|
|
20
|
-
__exportStar(require("./Create"), exports);
|
|
21
|
-
__exportStar(require("./Delete"), exports);
|
|
22
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
export * from "./FindById/index.js";
|
|
2
|
+
export * from "./Query/index.js";
|
|
3
|
+
export * from "./Update/index.js";
|
|
4
|
+
export * from "./Create/index.js";
|
|
5
|
+
export * from "./Delete/index.js";
|
|
6
|
+
export * from "./types.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type DynaRecord from "../DynaRecord";
|
|
2
|
-
import { type DefaultFields } from "../metadata";
|
|
3
|
-
import type { ForeignKey, NullableForeignKey, Optional, PartitionKey, SortKey } from "../types";
|
|
1
|
+
import type DynaRecord from "../DynaRecord.js";
|
|
2
|
+
import { type DefaultFields } from "../metadata/index.js";
|
|
3
|
+
import type { ForeignKey, NullableForeignKey, Optional, PartitionKey, SortKey } from "../types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Represents the type of the partition key attribute for a given entity. It identifies the specific property of the entity that is marked as the partition key, which uniquely identifies each instance of the entity in the database.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/operations/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/operations/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,OAAO,EACR,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI;KACpC,CAAC,IAAI,MAAM,CAAC,GAAG,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AC,CAAC,SAAS,UAAU,IAAI;KAChD,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,SAAS,MAAM,CAAC,GAC7D,CAAC,SAAS,gBAAgB,GACxB,KAAK,GACL,CAAC,SAAS,MAAM,GACd,WAAW,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM,GAC3C,GAAG,CAAC,IAAI,CAAC,EAAE,GACX,KAAK,GACP,KAAK,GACT,KAAK;CACV,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;AAEpB;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,UAAU,IACjD,OAAO,CACL,MAAM,oBAAoB,CAAC,CAAC,CAAC,GAAG,MAAM,EACtC,qBAAqB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM,CACxD,GACD,cAAc,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DynamoTableItem } from "../../types";
|
|
2
|
-
import type { UpdateExpression, DocumentPathOperation } from "./types";
|
|
1
|
+
import type { DynamoTableItem } from "../../types.js";
|
|
2
|
+
import type { UpdateExpression, DocumentPathOperation } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Builds a dynamo expression given the table attributes and optional document path operations
|
|
5
5
|
* @param tableAttrs The table aliases of the entity attributes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expressionBuilder.d.ts","sourceRoot":"","sources":["../../../../src/operations/utils/expressionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"expressionBuilder.d.ts","sourceRoot":"","sources":["../../../../src/operations/utils/expressionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EACV,gBAAgB,EAGhB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAyBpB;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,YAAY,eAAe,EAC3B,kBAAkB,qBAAqB,EAAE,KACxC,gBAiEF,CAAC"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expressionBuilder = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Builds a dynamo expression given the table attributes and optional document path operations
|
|
6
3
|
* @param tableAttrs The table aliases of the entity attributes
|
|
7
4
|
* @param documentPathOps Optional document path operations for partial ObjectAttribute updates
|
|
8
5
|
* @returns
|
|
9
6
|
*/
|
|
10
|
-
const expressionBuilder = (tableAttrs, documentPathOps) => {
|
|
7
|
+
export const expressionBuilder = (tableAttrs, documentPathOps) => {
|
|
11
8
|
const sorted = sortAttributesByOperand(tableAttrs);
|
|
12
9
|
const setExpression = buildUpdateSetExpression(sorted.set);
|
|
13
10
|
const removeExpression = buildUpdateRemoveExpression(sorted.remove);
|
|
@@ -57,7 +54,6 @@ const expressionBuilder = (tableAttrs, documentPathOps) => {
|
|
|
57
54
|
.join(" ")
|
|
58
55
|
};
|
|
59
56
|
};
|
|
60
|
-
exports.expressionBuilder = expressionBuilder;
|
|
61
57
|
/**
|
|
62
58
|
* Build document path expressions from DocumentPathOperations
|
|
63
59
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ObjectSchema } from "../../decorators/attributes/types";
|
|
2
|
-
import type { DocumentPathOperation } from "./types";
|
|
1
|
+
import type { ObjectSchema } from "../../decorators/attributes/types.js";
|
|
2
|
+
import type { DocumentPathOperation } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Flattens a partial object value into document path operations for DynamoDB
|
|
5
5
|
* update expressions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenObjectForUpdate.d.ts","sourceRoot":"","sources":["../../../../src/operations/utils/flattenObjectForUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"flattenObjectForUpdate.d.ts","sourceRoot":"","sources":["../../../../src/operations/utils/flattenObjectForUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,EAAE,EACpB,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpC,qBAAqB,EAAE,CAkCzB"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.flattenObjectForUpdate = flattenObjectForUpdate;
|
|
4
|
-
const serializers_1 = require("../../decorators/attributes/serializers");
|
|
1
|
+
import { convertFieldToTableItem } from "../../decorators/attributes/serializers.js";
|
|
5
2
|
/**
|
|
6
3
|
* Flattens a partial object value into document path operations for DynamoDB
|
|
7
4
|
* update expressions.
|
|
@@ -18,7 +15,7 @@ const serializers_1 = require("../../decorators/attributes/serializers");
|
|
|
18
15
|
* @param partialValue The partial object value to flatten
|
|
19
16
|
* @returns Array of DocumentPathOperation for use in expressionBuilder
|
|
20
17
|
*/
|
|
21
|
-
function flattenObjectForUpdate(parentPath, schema, partialValue) {
|
|
18
|
+
export function flattenObjectForUpdate(parentPath, schema, partialValue) {
|
|
22
19
|
const ops = [];
|
|
23
20
|
for (const [key, val] of Object.entries(partialValue)) {
|
|
24
21
|
if (!(key in schema))
|
|
@@ -38,7 +35,7 @@ function flattenObjectForUpdate(parentPath, schema, partialValue) {
|
|
|
38
35
|
ops.push(...nestedOps);
|
|
39
36
|
continue;
|
|
40
37
|
}
|
|
41
|
-
const serialized =
|
|
38
|
+
const serialized = convertFieldToTableItem(fieldDef, val);
|
|
42
39
|
ops.push({ type: "set", path: fieldPath, value: serialized });
|
|
43
40
|
}
|
|
44
41
|
return ops;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./expressionBuilder";
|
|
2
|
-
export * from "./flattenObjectForUpdate";
|
|
3
|
-
export * from "./mergePartialObjectAttributes";
|
|
4
|
-
export * from "./types";
|
|
5
|
-
export * from "./utils";
|
|
1
|
+
export * from "./expressionBuilder.js";
|
|
2
|
+
export * from "./flattenObjectForUpdate.js";
|
|
3
|
+
export * from "./mergePartialObjectAttributes.js";
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export * from "./utils.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/operations/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/operations/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./expressionBuilder"), exports);
|
|
18
|
-
__exportStar(require("./flattenObjectForUpdate"), exports);
|
|
19
|
-
__exportStar(require("./mergePartialObjectAttributes"), exports);
|
|
20
|
-
__exportStar(require("./types"), exports);
|
|
21
|
-
__exportStar(require("./utils"), exports);
|
|
1
|
+
export * from "./expressionBuilder.js";
|
|
2
|
+
export * from "./flattenObjectForUpdate.js";
|
|
3
|
+
export * from "./mergePartialObjectAttributes.js";
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export * from "./utils.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AttributeMetadataStorage } from "../../metadata";
|
|
1
|
+
import type { AttributeMetadataStorage } from "../../metadata/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Deep merges partial ObjectAttribute updates into the target object.
|
|
4
4
|
* For ObjectAttribute fields: recursively merges using the schema, removing null fields.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergePartialObjectAttributes.d.ts","sourceRoot":"","sources":["../../../../src/operations/utils/mergePartialObjectAttributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mergePartialObjectAttributes.d.ts","sourceRoot":"","sources":["../../../../src/operations/utils/mergePartialObjectAttributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAGxE;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,WAAW,EAAE,wBAAwB,GACpC,IAAI,CAqBN"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergePartialObjectAttributes = mergePartialObjectAttributes;
|
|
4
1
|
/**
|
|
5
2
|
* Deep merges partial ObjectAttribute updates into the target object.
|
|
6
3
|
* For ObjectAttribute fields: recursively merges using the schema, removing null fields.
|
|
7
4
|
* For regular fields: shallow assigns (existing behavior).
|
|
8
5
|
*/
|
|
9
|
-
function mergePartialObjectAttributes(target, partial, entityAttrs) {
|
|
6
|
+
export function mergePartialObjectAttributes(target, partial, entityAttrs) {
|
|
10
7
|
for (const [key, val] of Object.entries(partial)) {
|
|
11
8
|
if (!(key in entityAttrs)) {
|
|
12
9
|
target[key] = val;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type DynaRecord from "../../DynaRecord";
|
|
2
|
-
import type { BelongsToOrOwnedByRelationship, RelationshipMetadata } from "../../metadata";
|
|
3
|
-
import type { DynamoTableItem, EntityClass, ForeignKey, RelationshipMetaObj } from "../../types";
|
|
4
|
-
import { type EntityAttributesOnly } from "../types";
|
|
1
|
+
import type DynaRecord from "../../DynaRecord.js";
|
|
2
|
+
import type { BelongsToOrOwnedByRelationship, RelationshipMetadata } from "../../metadata/index.js";
|
|
3
|
+
import type { DynamoTableItem, EntityClass, ForeignKey, RelationshipMetaObj } from "../../types.js";
|
|
4
|
+
import { type EntityAttributesOnly } from "../types.js";
|
|
5
5
|
/**
|
|
6
6
|
* Creates an object including
|
|
7
7
|
* - relationsLookup: Object to look up RelationshipMetadata by Entity name
|