dyna-record 0.4.11 → 0.5.1
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 +53 -6
- package/dist/src/DynaRecord.d.ts +28 -19
- package/dist/src/DynaRecord.d.ts.map +1 -1
- package/dist/src/DynaRecord.js +24 -6
- package/dist/src/Logger.d.ts.map +1 -1
- package/dist/src/Logger.js +0 -1
- 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 -5
- package/dist/src/decorators/Table.d.ts +1 -1
- package/dist/src/decorators/Table.d.ts.map +1 -1
- package/dist/src/decorators/Table.js +2 -4
- package/dist/src/decorators/attributes/BooleanAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/BooleanAttribute.js +7 -9
- package/dist/src/decorators/attributes/DateAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/DateAttribute.js +8 -10
- package/dist/src/decorators/attributes/EnumAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/EnumAttribute.js +7 -9
- package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/ForeignKeyAttribute.js +9 -11
- package/dist/src/decorators/attributes/NumberAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/NumberAttribute.js +7 -9
- package/dist/src/decorators/attributes/ObjectAttribute.d.ts +40 -17
- package/dist/src/decorators/attributes/ObjectAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/ObjectAttribute.js +80 -29
- package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/PartitionKeyAttribute.js +6 -8
- package/dist/src/decorators/attributes/SortKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/SortKeyAttribute.js +6 -8
- package/dist/src/decorators/attributes/StringAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/StringAttribute.js +7 -9
- package/dist/src/decorators/attributes/serializers.d.ts +4 -3
- package/dist/src/decorators/attributes/serializers.d.ts.map +1 -1
- package/dist/src/decorators/attributes/serializers.js +2 -1
- package/dist/src/decorators/attributes/types.d.ts +20 -6
- package/dist/src/decorators/attributes/types.d.ts.map +1 -1
- package/dist/src/decorators/relationships/BelongsTo.d.ts.map +1 -1
- package/dist/src/decorators/relationships/BelongsTo.js +7 -9
- package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasAndBelongsToMany.js +13 -15
- package/dist/src/decorators/relationships/HasMany.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasMany.js +15 -17
- package/dist/src/decorators/relationships/HasOne.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasOne.js +7 -9
- package/dist/src/metadata/AttributeMetadata.d.ts +3 -0
- package/dist/src/metadata/AttributeMetadata.d.ts.map +1 -1
- package/dist/src/metadata/AttributeMetadata.js +5 -0
- package/dist/src/metadata/EntityMetadata.d.ts +2 -2
- package/dist/src/metadata/EntityMetadata.d.ts.map +1 -1
- package/dist/src/metadata/EntityMetadata.js +8 -1
- package/dist/src/metadata/MetadataStorage.d.ts.map +1 -1
- package/dist/src/metadata/MetadataStorage.js +6 -6
- package/dist/src/metadata/TableMetadata.d.ts.map +1 -1
- package/dist/src/metadata/TableMetadata.js +7 -1
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.js +1 -3
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.js +1 -3
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.js +1 -3
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.js +1 -3
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.js +1 -3
- package/dist/src/metadata/types.d.ts +14 -3
- package/dist/src/metadata/types.d.ts.map +1 -1
- package/dist/src/metadata/utils.js +4 -4
- package/dist/src/operations/Create/Create.js +3 -5
- package/dist/src/operations/Delete/Delete.d.ts.map +1 -1
- package/dist/src/operations/Delete/Delete.js +3 -2
- package/dist/src/operations/FindById/FindById.d.ts.map +1 -1
- package/dist/src/operations/FindById/FindById.js +4 -4
- package/dist/src/operations/Query/Query.d.ts.map +1 -1
- package/dist/src/operations/Query/Query.js +2 -1
- package/dist/src/operations/Update/Update.d.ts +6 -1
- package/dist/src/operations/Update/Update.d.ts.map +1 -1
- package/dist/src/operations/Update/Update.js +41 -17
- package/dist/src/operations/Update/types.d.ts +14 -4
- package/dist/src/operations/Update/types.d.ts.map +1 -1
- package/dist/src/operations/types.d.ts +1 -1
- package/dist/src/operations/types.d.ts.map +1 -1
- package/dist/src/operations/utils/expressionBuilder.d.ts +4 -3
- package/dist/src/operations/utils/expressionBuilder.d.ts.map +1 -1
- package/dist/src/operations/utils/expressionBuilder.js +66 -2
- package/dist/src/operations/utils/flattenObjectForUpdate.d.ts +19 -0
- package/dist/src/operations/utils/flattenObjectForUpdate.d.ts.map +1 -0
- package/dist/src/operations/utils/flattenObjectForUpdate.js +45 -0
- package/dist/src/operations/utils/index.d.ts +2 -0
- package/dist/src/operations/utils/index.d.ts.map +1 -1
- package/dist/src/operations/utils/index.js +2 -0
- package/dist/src/operations/utils/mergePartialObjectAttributes.d.ts +8 -0
- package/dist/src/operations/utils/mergePartialObjectAttributes.d.ts.map +1 -0
- package/dist/src/operations/utils/mergePartialObjectAttributes.js +60 -0
- package/dist/src/operations/utils/types.d.ts +16 -0
- package/dist/src/operations/utils/types.d.ts.map +1 -1
- package/dist/src/operations/utils/utils.d.ts +2 -2
- package/dist/src/operations/utils/utils.d.ts.map +1 -1
- package/dist/src/query-utils/QueryBuilder.d.ts.map +1 -1
- package/dist/src/query-utils/QueryBuilder.js +11 -7
- package/dist/src/query-utils/types.d.ts.map +1 -1
- package/dist/src/relationships/JoinTable.d.ts.map +1 -1
- package/dist/src/relationships/JoinTable.js +4 -3
- package/dist/src/utils.d.ts +4 -4
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +13 -11
- package/package.json +10 -12
|
@@ -32,26 +32,24 @@ const metadata_1 = __importDefault(require("../../metadata"));
|
|
|
32
32
|
*/
|
|
33
33
|
function HasMany(getTarget, props) {
|
|
34
34
|
return (_value, context) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
propertyName: props.foreignKey,
|
|
42
|
-
foreignKey: props.foreignKey,
|
|
43
|
-
target: this.constructor
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
metadata_1.default.addEntityRelationship(this.constructor.name, {
|
|
47
|
-
type: "HasMany",
|
|
48
|
-
propertyName: context.name,
|
|
49
|
-
target,
|
|
35
|
+
context.addInitializer(function () {
|
|
36
|
+
const target = getTarget();
|
|
37
|
+
if (props.uniDirectional === true) {
|
|
38
|
+
metadata_1.default.addEntityRelationship(target.name, {
|
|
39
|
+
type: "OwnedBy",
|
|
40
|
+
propertyName: props.foreignKey,
|
|
50
41
|
foreignKey: props.foreignKey,
|
|
51
|
-
|
|
42
|
+
target: this.constructor
|
|
52
43
|
});
|
|
44
|
+
}
|
|
45
|
+
metadata_1.default.addEntityRelationship(this.constructor.name, {
|
|
46
|
+
type: "HasMany",
|
|
47
|
+
propertyName: context.name,
|
|
48
|
+
target,
|
|
49
|
+
foreignKey: props.foreignKey,
|
|
50
|
+
uniDirectional: props.uniDirectional
|
|
53
51
|
});
|
|
54
|
-
}
|
|
52
|
+
});
|
|
55
53
|
};
|
|
56
54
|
}
|
|
57
55
|
exports.default = HasMany;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasOne.d.ts","sourceRoot":"","sources":["../../../../src/decorators/relationships/HasOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAsB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEvD,UAAU,WAAW,CAAC,CAAC,SAAS,UAAU;IACxC,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;CACjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,iBAAS,MAAM,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,UAAU,EACxD,SAAS,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,EAC/B,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,YAGX,SAAS,WACR,0BAA0B,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"HasOne.d.ts","sourceRoot":"","sources":["../../../../src/decorators/relationships/HasOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAsB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEvD,UAAU,WAAW,CAAC,CAAC,SAAS,UAAU;IACxC,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;CACjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,iBAAS,MAAM,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,UAAU,EACxD,SAAS,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,EAC/B,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,YAGX,SAAS,WACR,0BAA0B,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,UAWtD;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -32,16 +32,14 @@ const metadata_1 = __importDefault(require("../../metadata"));
|
|
|
32
32
|
*/
|
|
33
33
|
function HasOne(getTarget, props) {
|
|
34
34
|
return function (_value, context) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
foreignKey: props.foreignKey
|
|
42
|
-
});
|
|
35
|
+
context.addInitializer(function () {
|
|
36
|
+
metadata_1.default.addEntityRelationship(this.constructor.name, {
|
|
37
|
+
type: "HasOne",
|
|
38
|
+
propertyName: context.name,
|
|
39
|
+
target: getTarget(),
|
|
40
|
+
foreignKey: props.foreignKey
|
|
43
41
|
});
|
|
44
|
-
}
|
|
42
|
+
});
|
|
45
43
|
};
|
|
46
44
|
}
|
|
47
45
|
exports.default = HasOne;
|
|
@@ -2,6 +2,7 @@ import { type ZodType } from "zod";
|
|
|
2
2
|
import type DynaRecord from "../DynaRecord";
|
|
3
3
|
import type { AttributeMetadataOptions, Serializers } from "./types";
|
|
4
4
|
import type { EntityClass } from "../types";
|
|
5
|
+
import type { ObjectSchema } from "../decorators/attributes/types";
|
|
5
6
|
/**
|
|
6
7
|
* Represents the metadata for an attribute of an entity, including its name, alias (if any), nullability, and serialization strategies.
|
|
7
8
|
*
|
|
@@ -23,6 +24,8 @@ declare class AttributeMetadata {
|
|
|
23
24
|
readonly serializers?: Serializers;
|
|
24
25
|
readonly type: ZodType;
|
|
25
26
|
readonly foreignKeyTarget?: EntityClass<DynaRecord>;
|
|
27
|
+
readonly objectSchema?: ObjectSchema;
|
|
28
|
+
readonly partialType?: ZodType;
|
|
26
29
|
constructor(options: AttributeMetadataOptions);
|
|
27
30
|
}
|
|
28
31
|
export default AttributeMetadata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/AttributeMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"AttributeMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/AttributeMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;;;;;;;;;;;;GAaG;AACH,cAAM,iBAAiB;IACrB,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,SAAgB,QAAQ,EAAE,OAAO,CAAC;IAClC,SAAgB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1C,SAAgB,IAAI,EAAE,OAAO,CAAC;IAC9B,SAAgB,gBAAgB,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3D,SAAgB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5C,SAAgB,WAAW,CAAC,EAAE,OAAO,CAAC;gBAE1B,OAAO,EAAE,wBAAwB;CAe9C;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -21,17 +21,22 @@ class AttributeMetadata {
|
|
|
21
21
|
serializers;
|
|
22
22
|
type;
|
|
23
23
|
foreignKeyTarget;
|
|
24
|
+
objectSchema;
|
|
25
|
+
partialType;
|
|
24
26
|
constructor(options) {
|
|
25
27
|
this.name = options.attributeName;
|
|
26
28
|
this.alias = options.alias ?? options.attributeName;
|
|
27
29
|
this.nullable = options.nullable ?? false;
|
|
28
30
|
this.serializers = options.serializers;
|
|
29
31
|
this.foreignKeyTarget = options.foreignKeyTarget;
|
|
32
|
+
this.objectSchema = options.objectSchema;
|
|
30
33
|
if (options.nullable === true) {
|
|
31
34
|
this.type = options.type.optional().nullable();
|
|
35
|
+
this.partialType = options.partialType?.optional().nullable();
|
|
32
36
|
}
|
|
33
37
|
else {
|
|
34
38
|
this.type = options.type;
|
|
39
|
+
this.partialType = options.partialType;
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BelongsToRelationship, HasRelationships, AttributeMetadata, AttributeMetadataStorage, RelationshipMetadataStorage, RelationshipMetadata, OwnedByRelationship, BelongsToOrOwnedByRelationship, ForeignKeyAttributeMetadata } from ".";
|
|
2
2
|
import type DynaRecord from "../DynaRecord";
|
|
3
3
|
import { type EntityDefinedAttributes } from "../operations";
|
|
4
|
-
type EntityClass = new (...args:
|
|
4
|
+
type EntityClass = new (...args: unknown[]) => DynaRecord;
|
|
5
5
|
/**
|
|
6
6
|
* Represents metadata for an entity within the ORM system, encapsulating information about the entity's attributes, relationships, and its associated database table.
|
|
7
7
|
*
|
|
@@ -36,7 +36,7 @@ declare class EntityMetadata {
|
|
|
36
36
|
/**
|
|
37
37
|
* Optional attribute of an entity, used with @IdAttribute decorator when an entity has a custom id field
|
|
38
38
|
*/
|
|
39
|
-
idField
|
|
39
|
+
idField?: string;
|
|
40
40
|
constructor(entityClass: EntityClass, tableClassName: string);
|
|
41
41
|
/**
|
|
42
42
|
* Add attribute metadata to an entity
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/EntityMetadata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC9B,2BAA2B,EAC5B,MAAM,GAAG,CAAC;AACX,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAY7D,KAAK,WAAW,GAAG,KAAK,GAAG,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"EntityMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/EntityMetadata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC9B,2BAA2B,EAC5B,MAAM,GAAG,CAAC;AACX,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAY7D,KAAK,WAAW,GAAG,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,UAAU,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,cAAM,cAAc;;IAClB;;OAEG;IACH,SAAgB,cAAc,EAAE,MAAM,CAAC;IACvC;;OAEG;IACH,SAAgB,UAAU,EAAE,wBAAwB,CAAC;IACrD;;OAEG;IACH,SAAgB,eAAe,EAAE,wBAAwB,CAAC;IAE1D;;OAEG;IACH,SAAgB,aAAa,EAAE,2BAA2B,CAAC;IAE3D,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC;;OAEG;IACI,OAAO,CAAC,EAAE,MAAM,CAAC;gBAuBZ,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM;IAS5D;;;OAGG;IACI,YAAY,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAStD;;;;;OAKG;IACI,+BAA+B,CACpC,UAAU,EAAE,uBAAuB,CAAC,UAAU,CAAC,GAC9C,uBAAuB,CAAC,UAAU,CAAC;IAetC;;;;;;OAMG;IACI,sCAAsC,CAC3C,UAAU,EAAE,OAAO,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC,GACvD,OAAO,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;IA4B/C;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAM5B;;OAEG;IACH,IAAW,gBAAgB,IAAI,oBAAoB,EAAE,CAEpD;IAED;;OAEG;IACH,IAAW,sBAAsB,IAAI,qBAAqB,EAAE,CAI3D;IAED;;OAEG;IACH,IAAW,oBAAoB,IAAI,mBAAmB,EAAE,CAIvD;IAED;;OAEG;IACH,IAAW,+BAA+B,IAAI,8BAA8B,EAAE,CAE7E;IAED;;OAEG;IACH,IAAW,gBAAgB,IAAI,gBAAgB,CAO9C;IAED;;;OAGG;IACH,IAAW,oBAAoB,IAAI,2BAA2B,EAAE,CAE/D;IAED;;;OAGG;IACH,IAAW,8BAA8B,IAAI,2BAA2B,EAAE,CAUzE;CACF;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -53,6 +53,11 @@ class EntityMetadata {
|
|
|
53
53
|
* Object containing zod attributes. Built programmatically via decorators and used to create schemas
|
|
54
54
|
*/
|
|
55
55
|
#zodAttributes = {};
|
|
56
|
+
/**
|
|
57
|
+
* Object containing zod attributes for partial (update) validation.
|
|
58
|
+
* ObjectAttributes use their partialType; others use the standard type.
|
|
59
|
+
*/
|
|
60
|
+
#zodPartialAttributes = {};
|
|
56
61
|
constructor(entityClass, tableClassName) {
|
|
57
62
|
this.EntityClass = entityClass;
|
|
58
63
|
this.tableClassName = tableClassName;
|
|
@@ -68,6 +73,8 @@ class EntityMetadata {
|
|
|
68
73
|
this.attributes[attrMeta.name] = attrMeta;
|
|
69
74
|
this.tableAttributes[attrMeta.alias] = attrMeta;
|
|
70
75
|
this.#zodAttributes[attrMeta.name] = attrMeta.type;
|
|
76
|
+
this.#zodPartialAttributes[attrMeta.name] =
|
|
77
|
+
attrMeta.partialType ?? attrMeta.type;
|
|
71
78
|
}
|
|
72
79
|
/**
|
|
73
80
|
* Parse raw entity defined attributes (not reserved/relationship attributes) from input and ensure they are entity defined attributes.
|
|
@@ -98,7 +105,7 @@ class EntityMetadata {
|
|
|
98
105
|
if (this.#schemaPartial === undefined) {
|
|
99
106
|
const tableMeta = _1.default.getTable(this.tableClassName);
|
|
100
107
|
this.#schemaPartial = zod_1.z
|
|
101
|
-
.object(this.#
|
|
108
|
+
.object(this.#zodPartialAttributes)
|
|
102
109
|
.omit(tableMeta.reservedKeys)
|
|
103
110
|
.partial()
|
|
104
111
|
.transform((data) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetadataStorage.d.ts","sourceRoot":"","sources":["../../../src/metadata/MetadataStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EACV,wBAAwB,EAExB,qBAAqB,EAErB,oBAAoB,EAEpB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB;;;;GAIG;AACH,cAAM,eAAe;;IAOnB;;;;OAIG;IACI,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc;IAKpD;;;;OAIG;IACI,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa;IAKjD;;;;OAIG;IACI,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa;IAMxD;;;;OAIG;IACI,YAAY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C,CAAC,MAAM,CAAC,GACrE,IAAI;IAQP;;OAEG;IACH,OAAO,CAAC,IAAI;IAUZ;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;CAe/B;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -122,7 +122,7 @@ class MetadataStorage {
|
|
|
122
122
|
*/
|
|
123
123
|
addEntityRelationship(entityName, options) {
|
|
124
124
|
const entityMetadata = this.#entities[entityName];
|
|
125
|
-
if (
|
|
125
|
+
if (!(options.propertyName in entityMetadata.relationships)) {
|
|
126
126
|
entityMetadata.relationships[options.propertyName] =
|
|
127
127
|
(0, utils_1.createRelationshipInstance)(options);
|
|
128
128
|
}
|
|
@@ -133,8 +133,7 @@ class MetadataStorage {
|
|
|
133
133
|
* @param options
|
|
134
134
|
*/
|
|
135
135
|
addJoinTable(joinTableName, options) {
|
|
136
|
-
|
|
137
|
-
if (metadata === undefined) {
|
|
136
|
+
if (!(joinTableName in this.#joinTables)) {
|
|
138
137
|
const meta = new JoinTableMetadata_1.default(options.entity, options.foreignKey);
|
|
139
138
|
this.#joinTables[joinTableName] = [meta];
|
|
140
139
|
}
|
|
@@ -152,9 +151,10 @@ class MetadataStorage {
|
|
|
152
151
|
addEntityAttribute(entityName, options) {
|
|
153
152
|
const entityMetadata = this.#entities[entityName];
|
|
154
153
|
const { defaultAttributes } = this.#tables[entityMetadata.tableClassName];
|
|
155
|
-
const defaultAttrMeta = defaultAttributes[options.attributeName];
|
|
156
154
|
// The property is a default field assign it, otherwise instantiate new AttributeMetadata
|
|
157
|
-
const meta =
|
|
155
|
+
const meta = options.attributeName in defaultAttributes
|
|
156
|
+
? defaultAttributes[options.attributeName]
|
|
157
|
+
: new AttributeMetadata_1.default(options);
|
|
158
158
|
entityMetadata.addAttribute(meta);
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
@@ -207,7 +207,7 @@ class MetadataStorage {
|
|
|
207
207
|
const protoType = Object.getPrototypeOf(classPrototype);
|
|
208
208
|
if (protoType === null)
|
|
209
209
|
return;
|
|
210
|
-
if (
|
|
210
|
+
if (protoType.constructor.name in this.#tables) {
|
|
211
211
|
return this.#tables[protoType.constructor.name];
|
|
212
212
|
}
|
|
213
213
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/TableMetadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,GAAG,CAAC;AAEtC,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EAGb,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,WAAW,CAAC;AAEnB,eAAO,MAAM,gBAAgB;;;CAAiD,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CACrC,aAAa,EACb;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,CAMhB,CAAC;AAEX;;;;;;;;;;;;;GAaG;AACH,cAAM,aAAa;IACjB,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,iBAAiB,EAAE,MAAM,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAC5E,SAAgB,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACnE,qBAAqB,EAAE,iBAAiB,CAAC;IACzC,gBAAgB,EAAE,iBAAiB,CAAC;IAE3C;;;;;;;;;;;;;;;;OAgBG;IACI,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAE9B,OAAO,EAAE,oBAAoB;IA4BzC;;;;OAIG;IACH,OAAO,CAAC,8BAA8B;IAgCtC;;;OAGG;IACI,wBAAwB,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI;IAO5E;;;OAGG;IACI,mBAAmB,CAAC,OAAO,EAAE,4BAA4B,GAAG,I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BAAuB;CAYxE;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -130,7 +130,13 @@ class TableMetadata {
|
|
|
130
130
|
*/
|
|
131
131
|
toJSON(entities) {
|
|
132
132
|
return schemas_1.TableMetadataTransform.parse({
|
|
133
|
-
|
|
133
|
+
name: this.name,
|
|
134
|
+
delimiter: this.delimiter,
|
|
135
|
+
defaultAttributes: this.defaultAttributes,
|
|
136
|
+
defaultTableAttributes: this.defaultTableAttributes,
|
|
137
|
+
partitionKeyAttribute: this.partitionKeyAttribute,
|
|
138
|
+
sortKeyAttribute: this.sortKeyAttribute,
|
|
139
|
+
reservedKeys: this.reservedKeys,
|
|
134
140
|
entities
|
|
135
141
|
});
|
|
136
142
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BelongsToRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/BelongsToRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;GAQG;AACH,cAAM,qBAAsB,SAAQ,oBAAoB;IACtD,IAAI,
|
|
1
|
+
{"version":3,"file":"BelongsToRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/BelongsToRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;GAQG;AACH,cAAM,qBAAsB,SAAQ,oBAAoB;IACtD,IAAI,EAAG,WAAW,CAAU;IAC5B,UAAU,EAAE,kBAAkB,CAAC;gBAEnB,IAAI,EAAE,oBAAoB;CAIvC;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -18,9 +18,7 @@ class BelongsToRelationship extends RelationshipMetadata_1.default {
|
|
|
18
18
|
foreignKey;
|
|
19
19
|
constructor(item) {
|
|
20
20
|
super();
|
|
21
|
-
|
|
22
|
-
Object.assign(this, item);
|
|
23
|
-
}
|
|
21
|
+
Object.assign(this, item);
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
exports.default = BelongsToRelationship;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasAndBelongsToManyRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;GAOG;AACH,cAAM,+BAAgC,SAAQ,oBAAoB;IAChE,IAAI,
|
|
1
|
+
{"version":3,"file":"HasAndBelongsToManyRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;GAOG;AACH,cAAM,+BAAgC,SAAQ,oBAAoB;IAChE,IAAI,EAAG,qBAAqB,CAAU;IACtC,aAAa,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,oBAAoB;CAIvC;AAED,eAAe,+BAA+B,CAAC"}
|
|
@@ -17,9 +17,7 @@ class HasAndBelongsToManyRelationship extends RelationshipMetadata_1.default {
|
|
|
17
17
|
joinTableName;
|
|
18
18
|
constructor(item) {
|
|
19
19
|
super();
|
|
20
|
-
|
|
21
|
-
Object.assign(this, item);
|
|
22
|
-
}
|
|
20
|
+
Object.assign(this, item);
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
exports.default = HasAndBelongsToManyRelationship;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasManyRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasManyRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;GAQG;AACH,cAAM,mBAAoB,SAAQ,oBAAoB;IACpD,IAAI,
|
|
1
|
+
{"version":3,"file":"HasManyRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasManyRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;GAQG;AACH,cAAM,mBAAoB,SAAQ,oBAAoB;IACpD,IAAI,EAAG,SAAS,CAAU;IAC1B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAS;gBAErB,IAAI,EAAE,oBAAoB;CAIvC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -19,9 +19,7 @@ class HasManyRelationship extends RelationshipMetadata_1.default {
|
|
|
19
19
|
uniDirectional = false;
|
|
20
20
|
constructor(item) {
|
|
21
21
|
super();
|
|
22
|
-
|
|
23
|
-
Object.assign(this, item);
|
|
24
|
-
}
|
|
22
|
+
Object.assign(this, item);
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
exports.default = HasManyRelationship;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasOneRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasOneRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;GAOG;AACH,cAAM,kBAAmB,SAAQ,oBAAoB;IACnD,IAAI,
|
|
1
|
+
{"version":3,"file":"HasOneRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasOneRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;GAOG;AACH,cAAM,kBAAmB,SAAQ,oBAAoB;IACnD,IAAI,EAAG,QAAQ,CAAU;IACzB,UAAU,EAAE,kBAAkB,CAAC;gBAEnB,IAAI,EAAE,oBAAoB;CAIvC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -17,9 +17,7 @@ class HasOneRelationship extends RelationshipMetadata_1.default {
|
|
|
17
17
|
foreignKey;
|
|
18
18
|
constructor(item) {
|
|
19
19
|
super();
|
|
20
|
-
|
|
21
|
-
Object.assign(this, item);
|
|
22
|
-
}
|
|
20
|
+
Object.assign(this, item);
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
exports.default = HasOneRelationship;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OwnedByRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/OwnedByRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;GAQG;AACH,cAAM,mBAAoB,SAAQ,oBAAoB;IACpD,IAAI,
|
|
1
|
+
{"version":3,"file":"OwnedByRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/OwnedByRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;GAQG;AACH,cAAM,mBAAoB,SAAQ,oBAAoB;IACpD,IAAI,EAAG,SAAS,CAAU;IAC1B,UAAU,EAAE,kBAAkB,CAAC;gBAEnB,IAAI,EAAE,oBAAoB;CAIvC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -18,9 +18,7 @@ class OwnedByRelationship extends RelationshipMetadata_1.default {
|
|
|
18
18
|
foreignKey;
|
|
19
19
|
constructor(item) {
|
|
20
20
|
super();
|
|
21
|
-
|
|
22
|
-
Object.assign(this, item);
|
|
23
|
-
}
|
|
21
|
+
Object.assign(this, item);
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
exports.default = OwnedByRelationship;
|
|
@@ -3,6 +3,7 @@ import type { AttributeMetadata, BelongsToRelationship, EntityMetadata, JoinTabl
|
|
|
3
3
|
import type DynaRecord from "../DynaRecord";
|
|
4
4
|
import type { EntityClass, MakeOptional } from "../types";
|
|
5
5
|
import type { ZodType } from "zod";
|
|
6
|
+
import type { ObjectSchema } from "../decorators/attributes/types";
|
|
6
7
|
/**
|
|
7
8
|
* Represents relationship metadata that includes a foreign key reference to another entity.
|
|
8
9
|
*/
|
|
@@ -37,7 +38,7 @@ export type DefaultDateFields = "createdAt" | "updatedAt";
|
|
|
37
38
|
* Specifies the default fields used in entities, including fields from `DynaRecord`. Instance methods are excluded
|
|
38
39
|
*/
|
|
39
40
|
export type DefaultFields = {
|
|
40
|
-
[K in keyof DynaRecord]: DynaRecord[K] extends (...args:
|
|
41
|
+
[K in keyof DynaRecord]: DynaRecord[K] extends (...args: never[]) => unknown ? never : K;
|
|
41
42
|
}[keyof DynaRecord];
|
|
42
43
|
/**
|
|
43
44
|
* Defines the structure for default fields within a table, mapping field names to their `AttributeMetadata` aliases.
|
|
@@ -61,11 +62,11 @@ export type KeysAttributeMetadataOptions = MakeOptional<Omit<AttributeMetadataOp
|
|
|
61
62
|
/**
|
|
62
63
|
* Function that takes a attribute from a Dynamo table item, and serialize it to a non-Dynamo native type (EX: Date)
|
|
63
64
|
*/
|
|
64
|
-
export type EntitySerializer = (param: NativeAttributeValue) =>
|
|
65
|
+
export type EntitySerializer = (param: NativeAttributeValue) => unknown;
|
|
65
66
|
/**
|
|
66
67
|
* Function that takes a attribute from an Entity which is not a native Dynamo type and serializes it a type that is supported by Dynamo
|
|
67
68
|
*/
|
|
68
|
-
export type TableSerializer = (param:
|
|
69
|
+
export type TableSerializer = (param: unknown) => NativeAttributeValue;
|
|
69
70
|
/**
|
|
70
71
|
* Functions for serializing attribute types that are not native to Dynamo from table item -> entity and entity -> table item
|
|
71
72
|
* EX: See DateAttribute decorator
|
|
@@ -99,6 +100,16 @@ export interface AttributeMetadataOptions {
|
|
|
99
100
|
* Used to enforce referential integrity even when a relationship decorator is not present.
|
|
100
101
|
*/
|
|
101
102
|
foreignKeyTarget?: EntityClass<DynaRecord>;
|
|
103
|
+
/**
|
|
104
|
+
* When the attribute is an ObjectAttribute, stores the original ObjectSchema
|
|
105
|
+
* for use in partial update operations (document path expressions).
|
|
106
|
+
*/
|
|
107
|
+
objectSchema?: ObjectSchema;
|
|
108
|
+
/**
|
|
109
|
+
* When present, an alternative Zod type used for partial (update) validation.
|
|
110
|
+
* ObjectAttributes use this to allow partial field updates.
|
|
111
|
+
*/
|
|
112
|
+
partialType?: ZodType;
|
|
102
113
|
}
|
|
103
114
|
/**
|
|
104
115
|
* A relationship that is either BelongsTo (bi-directional to parent) or OwnedBy (uni directional to parent)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/metadata/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACd,MAAM,GAAG,CAAC;AACX,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/metadata/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAA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mBAAmB,CAAC;AAExB;;;GAGG;AACH,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB;IACpE,gBAAgB,EAAE,WAAW,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC;CACtE"}
|
|
@@ -9,28 +9,28 @@ const _1 = __importDefault(require("./"));
|
|
|
9
9
|
* Type guard to check if the relationship is a HasMany
|
|
10
10
|
*/
|
|
11
11
|
const isHasManyRelationship = (rel) => {
|
|
12
|
-
return rel.type === "HasMany" &&
|
|
12
|
+
return rel.type === "HasMany" && "foreignKey" in rel;
|
|
13
13
|
};
|
|
14
14
|
exports.isHasManyRelationship = isHasManyRelationship;
|
|
15
15
|
/**
|
|
16
16
|
* Type guard to check if the relationship is a BelongsTo
|
|
17
17
|
*/
|
|
18
18
|
const isBelongsToRelationship = (rel) => {
|
|
19
|
-
return rel.type === "BelongsTo" &&
|
|
19
|
+
return rel.type === "BelongsTo" && "foreignKey" in rel;
|
|
20
20
|
};
|
|
21
21
|
exports.isBelongsToRelationship = isBelongsToRelationship;
|
|
22
22
|
/**
|
|
23
23
|
* Type guard to check if the relationship is a HasOne
|
|
24
24
|
*/
|
|
25
25
|
const isHasOneRelationship = (rel) => {
|
|
26
|
-
return rel.type === "HasOne" &&
|
|
26
|
+
return rel.type === "HasOne" && "foreignKey" in rel;
|
|
27
27
|
};
|
|
28
28
|
exports.isHasOneRelationship = isHasOneRelationship;
|
|
29
29
|
/**
|
|
30
30
|
* Type guard to check if the relationship is a HasOne
|
|
31
31
|
*/
|
|
32
32
|
const isHasAndBelongsToManyRelationship = (rel) => {
|
|
33
|
-
return rel.type === "HasAndBelongsToMany" &&
|
|
33
|
+
return rel.type === "HasAndBelongsToMany" && "joinTableName" in rel;
|
|
34
34
|
};
|
|
35
35
|
exports.isHasAndBelongsToManyRelationship = isHasAndBelongsToManyRelationship;
|
|
36
36
|
/**
|
|
@@ -137,7 +137,7 @@ class Create extends OperationBase_1.default {
|
|
|
137
137
|
const relMetadata = this.entityMetadata.belongsToOrOwnedByRelationships;
|
|
138
138
|
for (const relMeta of relMetadata) {
|
|
139
139
|
const foreignKey = (0, utils_2.extractForeignKeyFromEntity)(relMeta, entityData);
|
|
140
|
-
if (foreignKey
|
|
140
|
+
if (foreignKey != null) {
|
|
141
141
|
// Ensure referenced entity exists before linking
|
|
142
142
|
if (referentialIntegrityCheck) {
|
|
143
143
|
this.buildRelationshipExistsConditionTransaction(relMeta, foreignKey);
|
|
@@ -201,7 +201,7 @@ class Create extends OperationBase_1.default {
|
|
|
201
201
|
const belongsToRelMetas = Object.values(relMetas).filter(relMeta => (0, utils_3.isBelongsToRelationship)(relMeta));
|
|
202
202
|
belongsToRelMetas.forEach(relMeta => {
|
|
203
203
|
const fk = (0, utils_2.extractForeignKeyFromEntity)(relMeta, entityData);
|
|
204
|
-
if (fk
|
|
204
|
+
if (fk != null) {
|
|
205
205
|
transactionBuilder.addGet({
|
|
206
206
|
TableName: tableName,
|
|
207
207
|
Key: {
|
|
@@ -270,9 +270,7 @@ class Create extends OperationBase_1.default {
|
|
|
270
270
|
TableName: this.tableMetadata.name,
|
|
271
271
|
Item: { ...tableItem, ...key },
|
|
272
272
|
ConditionExpression: `attribute_not_exists(${this.partitionKeyAlias})`
|
|
273
|
-
},
|
|
274
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
275
|
-
`${this.EntityClass.name} already has an associated ${relationshipType}`);
|
|
273
|
+
}, `${this.EntityClass.name} already has an associated ${relationshipType}`);
|
|
276
274
|
});
|
|
277
275
|
}
|
|
278
276
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Delete.d.ts","sourceRoot":"","sources":["../../../../src/operations/Delete/Delete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAY/C,OAAO,KAAK,EAEV,WAAW,EAEZ,MAAM,aAAa,CAAC;AAErB,OAAO,aAAa,MAAM,kBAAkB,CAAC;AA2B7C;;;;;;;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G;IACH,OAAO,CAAC,mCAAmC;IAiB3C;;;OAGG;IACH,OAAO,CAAC,+BAA+B;IAqBvC;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,cAAc;CAcvB;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -168,9 +168,10 @@ class Delete extends OperationBase_1.default {
|
|
|
168
168
|
*/
|
|
169
169
|
buildDeleteAssociatedBelongsTransaction(entityId, item) {
|
|
170
170
|
this.#belongsToRelationships.forEach(relMeta => {
|
|
171
|
-
if ((0, utils_2.isKeyOfObject)(item, relMeta.foreignKey)
|
|
172
|
-
item[relMeta.foreignKey] !== undefined) {
|
|
171
|
+
if ((0, utils_2.isKeyOfObject)(item, relMeta.foreignKey)) {
|
|
173
172
|
const foreignKeyValue = item[relMeta.foreignKey];
|
|
173
|
+
if (foreignKeyValue === undefined)
|
|
174
|
+
return;
|
|
174
175
|
const belongsToLinksKeys = (0, utils_3.buildBelongsToLinkKey)(this.EntityClass, entityId, relMeta, foreignKeyValue);
|
|
175
176
|
this.buildDeleteItemTransaction(belongsToLinksKeys, {
|
|
176
177
|
errorMessage: `Failed to delete denormalized record with keys: ${JSON.stringify(belongsToLinksKeys)}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FindById.d.ts","sourceRoot":"","sources":["../../../../src/operations/FindById/FindById.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAI/C,OAAO,KAAK,EAAE,QAAQ,EAAsB,MAAM,aAAa,CAAC;AAEhE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAQjB;;;;;;GAMG;AACH,cAAM,QAAQ,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IAC3D;;;;;;;OAOG;IACU,GAAG,CAAC,GAAG,SAAS,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4BtC;;;;;;;OAOG;IACH,OAAO,CAAC,+BAA+B;CAaxC;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -34,7 +34,7 @@ class FindById extends OperationBase_1.default {
|
|
|
34
34
|
else {
|
|
35
35
|
return await this.findByIdWithIncludes(id, {
|
|
36
36
|
includedAssociations: options.include,
|
|
37
|
-
consistentRead: options
|
|
37
|
+
consistentRead: options.consistentRead
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -106,9 +106,9 @@ class FindById extends OperationBase_1.default {
|
|
|
106
106
|
getIncludedRelationships(includedAssociations) {
|
|
107
107
|
return includedAssociations.reduce((acc, includedRel) => {
|
|
108
108
|
const key = includedRel.association;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
if (key in this.entityMetadata.relationships) {
|
|
110
|
+
acc.push(this.entityMetadata.relationships[key]);
|
|
111
|
+
}
|
|
112
112
|
return acc;
|
|
113
113
|
}, []);
|
|
114
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../../../src/operations/Query/Query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAEL,KAAK,YAAY,IAAI,mBAAmB,EACzC,MAAM,mBAAmB,CAAC;AAI3B,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EACV,wBAAwB,EACxB,YAAY,EAEZ,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB;;;;;;GAMG;AACH,cAAM,KAAK,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IACxD;;;;;OAKG;IACU,GAAG,CACd,GAAG,EAAE,MAAM,GAAG,wBAAwB,CAAC,CAAC,CAAC,EACzC,OAAO,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,GAC9D,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAQ3B;;;;;;OAMG;YACW,UAAU;IAexB;;;;;;;OAOG;YACW,WAAW;
|
|
1
|
+
{"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../../../src/operations/Query/Query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAEL,KAAK,YAAY,IAAI,mBAAmB,EACzC,MAAM,mBAAmB,CAAC;AAI3B,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EACV,wBAAwB,EACxB,YAAY,EAEZ,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB;;;;;;GAMG;AACH,cAAM,KAAK,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IACxD;;;;;OAKG;IACU,GAAG,CACd,GAAG,EAAE,MAAM,GAAG,wBAAwB,CAAC,CAAC,CAAC,EACzC,OAAO,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,GAC9D,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAQ3B;;;;;;OAMG;YACW,UAAU;IAexB;;;;;;;OAOG;YACW,WAAW;IA0BzB;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,uBAAuB;CAchC;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -60,7 +60,8 @@ class Query extends OperationBase_1.default {
|
|
|
60
60
|
const keyCondition = {
|
|
61
61
|
[modelPk]: this.EntityClass.partitionKeyValue(id),
|
|
62
62
|
...(options?.skCondition !== undefined && {
|
|
63
|
-
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- SortKeyCondition includes NativeAttributeValue (any) from AWS SDK
|
|
64
|
+
[modelSk]: options.skCondition
|
|
64
65
|
})
|
|
65
66
|
};
|
|
66
67
|
const params = new query_utils_1.QueryBuilder({
|
|
@@ -85,7 +85,12 @@ declare class Update<T extends DynaRecord> extends OperationBase<T> {
|
|
|
85
85
|
*
|
|
86
86
|
* **What it does:**
|
|
87
87
|
* - Merges the provided attributes with `updatedAt` (automatically set to the current time).
|
|
88
|
-
* -
|
|
88
|
+
* - For `@ObjectAttribute` fields with non-null values, flattens the partial object into
|
|
89
|
+
* {@link DocumentPathOperation | document path operations} (e.g., `SET #address.#street = :address_street`)
|
|
90
|
+
* instead of replacing the entire map. Nested objects are recursively flattened.
|
|
91
|
+
* - For regular attributes and `@ObjectAttribute` fields set to `null`, uses the standard
|
|
92
|
+
* expression builder (existing full-replacement / REMOVE behavior).
|
|
93
|
+
* - Combines both regular and document path expressions into a single DynamoDB update expression.
|
|
89
94
|
*
|
|
90
95
|
* @param attributes - The partial attributes to be updated on the entity.
|
|
91
96
|
* @returns An object containing:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Update.d.ts","sourceRoot":"","sources":["../../../../src/operations/Update/Update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAGL,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Update.d.ts","sourceRoot":"","sources":["../../../../src/operations/Update/Update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAGL,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAqB5B,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,sBAAsB,EACvB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAmB,WAAW,EAAgB,MAAM,aAAa,CAAC;AA4D9E;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAM,MAAM,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IACzD,SAAS,CAAC,QAAQ,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