dyna-record 0.0.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 +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/src/DynaRecord.d.ts +216 -0
- package/dist/src/DynaRecord.d.ts.map +1 -0
- package/dist/src/DynaRecord.js +217 -0
- package/dist/src/Logger.d.ts +42 -0
- package/dist/src/Logger.d.ts.map +1 -0
- package/dist/src/Logger.js +57 -0
- package/dist/src/decorators/Entity.d.ts +23 -0
- package/dist/src/decorators/Entity.d.ts.map +1 -0
- package/dist/src/decorators/Entity.js +32 -0
- package/dist/src/decorators/Table.d.ts +22 -0
- package/dist/src/decorators/Table.d.ts.map +1 -0
- package/dist/src/decorators/Table.js +31 -0
- package/dist/src/decorators/attributes/Attribute.d.ts +26 -0
- package/dist/src/decorators/attributes/Attribute.d.ts.map +1 -0
- package/dist/src/decorators/attributes/Attribute.js +41 -0
- package/dist/src/decorators/attributes/DateAttribute.d.ts +25 -0
- package/dist/src/decorators/attributes/DateAttribute.d.ts.map +1 -0
- package/dist/src/decorators/attributes/DateAttribute.js +43 -0
- package/dist/src/decorators/attributes/DateNullableAttribute.d.ts +26 -0
- package/dist/src/decorators/attributes/DateNullableAttribute.d.ts.map +1 -0
- package/dist/src/decorators/attributes/DateNullableAttribute.js +43 -0
- package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts +25 -0
- package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts.map +1 -0
- package/dist/src/decorators/attributes/ForeignKeyAttribute.js +40 -0
- package/dist/src/decorators/attributes/NullableAttribute.d.ts +27 -0
- package/dist/src/decorators/attributes/NullableAttribute.d.ts.map +1 -0
- package/dist/src/decorators/attributes/NullableAttribute.js +41 -0
- package/dist/src/decorators/attributes/NullableForeignKeyAttribute.d.ts +25 -0
- package/dist/src/decorators/attributes/NullableForeignKeyAttribute.d.ts.map +1 -0
- package/dist/src/decorators/attributes/NullableForeignKeyAttribute.js +40 -0
- package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts +24 -0
- package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts.map +1 -0
- package/dist/src/decorators/attributes/PartitionKeyAttribute.js +38 -0
- package/dist/src/decorators/attributes/SortKeyAttribute.d.ts +24 -0
- package/dist/src/decorators/attributes/SortKeyAttribute.d.ts.map +1 -0
- package/dist/src/decorators/attributes/SortKeyAttribute.js +38 -0
- package/dist/src/decorators/attributes/index.d.ts +10 -0
- package/dist/src/decorators/attributes/index.d.ts.map +1 -0
- package/dist/src/decorators/attributes/index.js +37 -0
- package/dist/src/decorators/attributes/serializers.d.ts +13 -0
- package/dist/src/decorators/attributes/serializers.d.ts.map +1 -0
- package/dist/src/decorators/attributes/serializers.js +19 -0
- package/dist/src/decorators/index.d.ts +6 -0
- package/dist/src/decorators/index.d.ts.map +1 -0
- package/dist/src/decorators/index.js +27 -0
- package/dist/src/decorators/relationships/BelongsTo.d.ts +34 -0
- package/dist/src/decorators/relationships/BelongsTo.d.ts.map +1 -0
- package/dist/src/decorators/relationships/BelongsTo.js +50 -0
- package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts +80 -0
- package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts.map +1 -0
- package/dist/src/decorators/relationships/HasAndBelongsToMany.js +70 -0
- package/dist/src/decorators/relationships/HasMany.d.ts +35 -0
- package/dist/src/decorators/relationships/HasMany.d.ts.map +1 -0
- package/dist/src/decorators/relationships/HasMany.js +48 -0
- package/dist/src/decorators/relationships/HasOne.d.ts +35 -0
- package/dist/src/decorators/relationships/HasOne.d.ts.map +1 -0
- package/dist/src/decorators/relationships/HasOne.js +48 -0
- package/dist/src/decorators/relationships/index.d.ts +6 -0
- package/dist/src/decorators/relationships/index.d.ts.map +1 -0
- package/dist/src/decorators/relationships/index.js +29 -0
- package/dist/src/decorators/relationships/types.d.ts +11 -0
- package/dist/src/decorators/relationships/types.d.ts.map +1 -0
- package/dist/src/decorators/relationships/types.js +2 -0
- package/dist/src/decorators/types.d.ts +30 -0
- package/dist/src/decorators/types.d.ts.map +1 -0
- package/dist/src/decorators/types.js +2 -0
- package/dist/src/dynamo-utils/DynamoClient.d.ts +34 -0
- package/dist/src/dynamo-utils/DynamoClient.d.ts.map +1 -0
- package/dist/src/dynamo-utils/DynamoClient.js +57 -0
- package/dist/src/dynamo-utils/TransactGetBuilder.d.ts +18 -0
- package/dist/src/dynamo-utils/TransactGetBuilder.d.ts.map +1 -0
- package/dist/src/dynamo-utils/TransactGetBuilder.js +32 -0
- package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts +46 -0
- package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts.map +1 -0
- package/dist/src/dynamo-utils/TransactWriteBuilder.js +100 -0
- package/dist/src/dynamo-utils/errors.d.ts +13 -0
- package/dist/src/dynamo-utils/errors.d.ts.map +1 -0
- package/dist/src/dynamo-utils/errors.js +17 -0
- package/dist/src/dynamo-utils/index.d.ts +8 -0
- package/dist/src/dynamo-utils/index.d.ts.map +1 -0
- package/dist/src/dynamo-utils/index.js +30 -0
- package/dist/src/dynamo-utils/types.d.ts +52 -0
- package/dist/src/dynamo-utils/types.d.ts.map +1 -0
- package/dist/src/dynamo-utils/types.js +2 -0
- package/dist/src/errors.d.ts +13 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +17 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +24 -0
- package/dist/src/metadata/AttributeMetadata.d.ts +22 -0
- package/dist/src/metadata/AttributeMetadata.d.ts.map +1 -0
- package/dist/src/metadata/AttributeMetadata.js +27 -0
- package/dist/src/metadata/EntityMetadata.d.ts +42 -0
- package/dist/src/metadata/EntityMetadata.d.ts.map +1 -0
- package/dist/src/metadata/EntityMetadata.js +49 -0
- package/dist/src/metadata/JoinTableMetadata.d.ts +23 -0
- package/dist/src/metadata/JoinTableMetadata.d.ts.map +1 -0
- package/dist/src/metadata/JoinTableMetadata.js +22 -0
- package/dist/src/metadata/MetadataStorage.d.ts +104 -0
- package/dist/src/metadata/MetadataStorage.d.ts.map +1 -0
- package/dist/src/metadata/MetadataStorage.js +194 -0
- package/dist/src/metadata/TableMetadata.d.ts +53 -0
- package/dist/src/metadata/TableMetadata.d.ts.map +1 -0
- package/dist/src/metadata/TableMetadata.js +100 -0
- package/dist/src/metadata/index.d.ts +13 -0
- package/dist/src/metadata/index.d.ts.map +1 -0
- package/dist/src/metadata/index.js +34 -0
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts +18 -0
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts.map +1 -0
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.js +26 -0
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts +16 -0
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts.map +1 -0
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.js +25 -0
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts +18 -0
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts.map +1 -0
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.js +26 -0
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts +17 -0
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts.map +1 -0
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.js +25 -0
- package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts +21 -0
- package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts.map +1 -0
- package/dist/src/metadata/relationship-metadata/RelationshipMetadata.js +18 -0
- package/dist/src/metadata/relationship-metadata/index.d.ts +7 -0
- package/dist/src/metadata/relationship-metadata/index.d.ts.map +1 -0
- package/dist/src/metadata/relationship-metadata/index.js +29 -0
- package/dist/src/metadata/relationship-metadata/types.d.ts +16 -0
- package/dist/src/metadata/relationship-metadata/types.d.ts.map +1 -0
- package/dist/src/metadata/relationship-metadata/types.js +2 -0
- package/dist/src/metadata/relationship-metadata/utils.d.ts +3 -0
- package/dist/src/metadata/relationship-metadata/utils.d.ts.map +1 -0
- package/dist/src/metadata/relationship-metadata/utils.js +25 -0
- package/dist/src/metadata/types.d.ts +90 -0
- package/dist/src/metadata/types.d.ts.map +1 -0
- package/dist/src/metadata/types.js +2 -0
- package/dist/src/metadata/utils.d.ts +42 -0
- package/dist/src/metadata/utils.d.ts.map +1 -0
- package/dist/src/metadata/utils.js +67 -0
- package/dist/src/operations/Create/Create.d.ts +39 -0
- package/dist/src/operations/Create/Create.d.ts.map +1 -0
- package/dist/src/operations/Create/Create.js +84 -0
- package/dist/src/operations/Create/index.d.ts +3 -0
- package/dist/src/operations/Create/index.d.ts.map +1 -0
- package/dist/src/operations/Create/index.js +23 -0
- package/dist/src/operations/Create/types.d.ts +7 -0
- package/dist/src/operations/Create/types.d.ts.map +1 -0
- package/dist/src/operations/Create/types.js +2 -0
- package/dist/src/operations/Delete/Delete.d.ts +74 -0
- package/dist/src/operations/Delete/Delete.d.ts.map +1 -0
- package/dist/src/operations/Delete/Delete.js +207 -0
- package/dist/src/operations/Delete/index.d.ts +2 -0
- package/dist/src/operations/Delete/index.d.ts.map +1 -0
- package/dist/src/operations/Delete/index.js +8 -0
- package/dist/src/operations/Delete/types.d.ts +7 -0
- package/dist/src/operations/Delete/types.d.ts.map +1 -0
- package/dist/src/operations/Delete/types.js +2 -0
- package/dist/src/operations/FindById/FindById.d.ts +91 -0
- package/dist/src/operations/FindById/FindById.d.ts.map +1 -0
- package/dist/src/operations/FindById/FindById.js +244 -0
- package/dist/src/operations/FindById/index.d.ts +3 -0
- package/dist/src/operations/FindById/index.d.ts.map +1 -0
- package/dist/src/operations/FindById/index.js +23 -0
- package/dist/src/operations/FindById/types.d.ts +57 -0
- package/dist/src/operations/FindById/types.d.ts.map +1 -0
- package/dist/src/operations/FindById/types.js +2 -0
- package/dist/src/operations/OperationBase.d.ts +37 -0
- package/dist/src/operations/OperationBase.d.ts.map +1 -0
- package/dist/src/operations/OperationBase.js +44 -0
- package/dist/src/operations/Query/Query.d.ts +45 -0
- package/dist/src/operations/Query/Query.d.ts.map +1 -0
- package/dist/src/operations/Query/Query.js +84 -0
- package/dist/src/operations/Query/index.d.ts +3 -0
- package/dist/src/operations/Query/index.d.ts.map +1 -0
- package/dist/src/operations/Query/index.js +23 -0
- package/dist/src/operations/Query/types.d.ts +38 -0
- package/dist/src/operations/Query/types.d.ts.map +1 -0
- package/dist/src/operations/Query/types.js +2 -0
- package/dist/src/operations/Update/Update.d.ts +48 -0
- package/dist/src/operations/Update/Update.d.ts.map +1 -0
- package/dist/src/operations/Update/Update.js +118 -0
- package/dist/src/operations/Update/index.d.ts +3 -0
- package/dist/src/operations/Update/index.d.ts.map +1 -0
- package/dist/src/operations/Update/index.js +23 -0
- package/dist/src/operations/Update/types.d.ts +32 -0
- package/dist/src/operations/Update/types.d.ts.map +1 -0
- package/dist/src/operations/Update/types.js +2 -0
- package/dist/src/operations/index.d.ts +7 -0
- package/dist/src/operations/index.d.ts.map +1 -0
- package/dist/src/operations/index.js +22 -0
- package/dist/src/operations/types.d.ts +59 -0
- package/dist/src/operations/types.d.ts.map +1 -0
- package/dist/src/operations/types.js +2 -0
- package/dist/src/operations/utils/RelationshipTransactions.d.ts +64 -0
- package/dist/src/operations/utils/RelationshipTransactions.d.ts.map +1 -0
- package/dist/src/operations/utils/RelationshipTransactions.js +125 -0
- package/dist/src/operations/utils/expressionBuilder.d.ts +9 -0
- package/dist/src/operations/utils/expressionBuilder.d.ts.map +1 -0
- package/dist/src/operations/utils/expressionBuilder.js +106 -0
- package/dist/src/operations/utils/index.d.ts +5 -0
- package/dist/src/operations/utils/index.d.ts.map +1 -0
- package/dist/src/operations/utils/index.js +25 -0
- package/dist/src/operations/utils/types.d.ts +21 -0
- package/dist/src/operations/utils/types.d.ts.map +1 -0
- package/dist/src/operations/utils/types.js +2 -0
- package/dist/src/operations/utils/utils.d.ts +19 -0
- package/dist/src/operations/utils/utils.d.ts.map +1 -0
- package/dist/src/operations/utils/utils.js +36 -0
- package/dist/src/query-utils/Filters.d.ts +10 -0
- package/dist/src/query-utils/Filters.d.ts.map +1 -0
- package/dist/src/query-utils/Filters.js +25 -0
- package/dist/src/query-utils/QueryBuilder.d.ts +90 -0
- package/dist/src/query-utils/QueryBuilder.d.ts.map +1 -0
- package/dist/src/query-utils/QueryBuilder.js +213 -0
- package/dist/src/query-utils/index.d.ts +3 -0
- package/dist/src/query-utils/index.d.ts.map +1 -0
- package/dist/src/query-utils/index.js +23 -0
- package/dist/src/query-utils/types.d.ts +89 -0
- package/dist/src/query-utils/types.d.ts.map +1 -0
- package/dist/src/query-utils/types.js +2 -0
- package/dist/src/relationships/BelongsToLink.d.ts +50 -0
- package/dist/src/relationships/BelongsToLink.d.ts.map +1 -0
- package/dist/src/relationships/BelongsToLink.js +57 -0
- package/dist/src/relationships/JoinTable.d.ts +68 -0
- package/dist/src/relationships/JoinTable.d.ts.map +1 -0
- package/dist/src/relationships/JoinTable.js +133 -0
- package/dist/src/relationships/index.d.ts +3 -0
- package/dist/src/relationships/index.d.ts.map +1 -0
- package/dist/src/relationships/index.js +10 -0
- package/dist/src/types.d.ts +73 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/utils.d.ts +89 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +168 -0
- package/package.json +61 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ForeignKeyProperty } from "../../types";
|
|
2
|
+
import RelationshipMetadata from "./RelationshipMetadata";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a "Belongs To" relationship metadata within the ORM system.
|
|
5
|
+
*
|
|
6
|
+
* @extends {RelationshipMetadata} Inherits the base functionality and properties of `RelationshipMetadata`.
|
|
7
|
+
* @property {"BelongsTo"} type - The type of the relationship, statically set to "BelongsTo" to signify the nature of the relationship.
|
|
8
|
+
* @property {ForeignKeyProperty} foreignKey - The attribute representing the foreign key in the relationship. This specifies the field in the entity that links to another entity, serving as the cornerstone for relationship queries and operations.
|
|
9
|
+
*
|
|
10
|
+
* @param {RelationshipMetadata} item - The initial relationship metadata to be copied into this "Belongs To" relationship instance. This allows for easy creation and setup of relationship metadata based on existing configurations.
|
|
11
|
+
*/
|
|
12
|
+
declare class BelongsToRelationship extends RelationshipMetadata {
|
|
13
|
+
type: "BelongsTo";
|
|
14
|
+
foreignKey: ForeignKeyProperty;
|
|
15
|
+
constructor(item: RelationshipMetadata);
|
|
16
|
+
}
|
|
17
|
+
export default BelongsToRelationship;
|
|
18
|
+
//# sourceMappingURL=BelongsToRelationship.d.ts.map
|
|
@@ -0,0 +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,EAAE,WAAW,CAAe;IAChC,UAAU,EAAE,kBAAkB,CAAC;gBAEnB,IAAI,EAAE,oBAAoB;CAMvC;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
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 RelationshipMetadata_1 = __importDefault(require("./RelationshipMetadata"));
|
|
7
|
+
/**
|
|
8
|
+
* Represents a "Belongs To" relationship metadata within the ORM system.
|
|
9
|
+
*
|
|
10
|
+
* @extends {RelationshipMetadata} Inherits the base functionality and properties of `RelationshipMetadata`.
|
|
11
|
+
* @property {"BelongsTo"} type - The type of the relationship, statically set to "BelongsTo" to signify the nature of the relationship.
|
|
12
|
+
* @property {ForeignKeyProperty} foreignKey - The attribute representing the foreign key in the relationship. This specifies the field in the entity that links to another entity, serving as the cornerstone for relationship queries and operations.
|
|
13
|
+
*
|
|
14
|
+
* @param {RelationshipMetadata} item - The initial relationship metadata to be copied into this "Belongs To" relationship instance. This allows for easy creation and setup of relationship metadata based on existing configurations.
|
|
15
|
+
*/
|
|
16
|
+
class BelongsToRelationship extends RelationshipMetadata_1.default {
|
|
17
|
+
type = "BelongsTo";
|
|
18
|
+
foreignKey;
|
|
19
|
+
constructor(item) {
|
|
20
|
+
super();
|
|
21
|
+
if (item !== undefined) {
|
|
22
|
+
Object.assign(this, item);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = BelongsToRelationship;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import RelationshipMetadata from "./RelationshipMetadata";
|
|
2
|
+
/**
|
|
3
|
+
* Represents the metadata for a "HasAndBelongsToMany" relationship metadata within the ORM system.
|
|
4
|
+
*
|
|
5
|
+
* @property {"HasAndBelongsToMany"} type - A literal string indicating the type of the relationship as "HasAndBelongsToMany". This helps in distinguishing between different types of relationships within the ORM.
|
|
6
|
+
* @property {string} joinTableName - The name of the join table used to facilitate the many-to-many relationship between entities. This table contains the foreign keys that link the related entities together.
|
|
7
|
+
*
|
|
8
|
+
* @param {RelationshipMetadata} item - An instance of `RelationshipMetadata` containing the initial settings for the relationship. This can include properties like `joinTableName`, which are specific to many-to-many relationships.
|
|
9
|
+
*/
|
|
10
|
+
declare class HasAndBelongsToManyRelationship extends RelationshipMetadata {
|
|
11
|
+
type: "HasAndBelongsToMany";
|
|
12
|
+
joinTableName: string;
|
|
13
|
+
constructor(item: RelationshipMetadata);
|
|
14
|
+
}
|
|
15
|
+
export default HasAndBelongsToManyRelationship;
|
|
16
|
+
//# sourceMappingURL=HasAndBelongsToManyRelationship.d.ts.map
|
|
@@ -0,0 +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,EAAE,qBAAqB,CAAyB;IACpD,aAAa,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,oBAAoB;CAMvC;AAED,eAAe,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
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 RelationshipMetadata_1 = __importDefault(require("./RelationshipMetadata"));
|
|
7
|
+
/**
|
|
8
|
+
* Represents the metadata for a "HasAndBelongsToMany" relationship metadata within the ORM system.
|
|
9
|
+
*
|
|
10
|
+
* @property {"HasAndBelongsToMany"} type - A literal string indicating the type of the relationship as "HasAndBelongsToMany". This helps in distinguishing between different types of relationships within the ORM.
|
|
11
|
+
* @property {string} joinTableName - The name of the join table used to facilitate the many-to-many relationship between entities. This table contains the foreign keys that link the related entities together.
|
|
12
|
+
*
|
|
13
|
+
* @param {RelationshipMetadata} item - An instance of `RelationshipMetadata` containing the initial settings for the relationship. This can include properties like `joinTableName`, which are specific to many-to-many relationships.
|
|
14
|
+
*/
|
|
15
|
+
class HasAndBelongsToManyRelationship extends RelationshipMetadata_1.default {
|
|
16
|
+
type = "HasAndBelongsToMany";
|
|
17
|
+
joinTableName;
|
|
18
|
+
constructor(item) {
|
|
19
|
+
super();
|
|
20
|
+
if (item !== undefined) {
|
|
21
|
+
Object.assign(this, item);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = HasAndBelongsToManyRelationship;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ForeignKeyProperty } from "../../types";
|
|
2
|
+
import RelationshipMetadata from "./RelationshipMetadata";
|
|
3
|
+
/**
|
|
4
|
+
* Extends `RelationshipMetadata` to specifically handle "HasMany" relationship metadata within the ORM system.
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* @property {"HasMany"} type - A literal string that explicitly defines the type of relationship as "HasMany". This classification helps the ORM to apply the correct logic for relationship handling.
|
|
8
|
+
* @property {ForeignKeyProperty} foreignKey - The attribute in the associated entity that serves as a foreign key, linking back to the partition key of the owning entity. This key is essential for maintaining the integrity of the "HasMany" relationship.
|
|
9
|
+
*
|
|
10
|
+
* @param {RelationshipMetadata} item - An existing set of relationship metadata that should be applied to the newly created `HasManyRelationship` instance. This parameter allows for the inheritance and augmentation of relationship properties.
|
|
11
|
+
*/
|
|
12
|
+
declare class HasManyRelationship extends RelationshipMetadata {
|
|
13
|
+
type: "HasMany";
|
|
14
|
+
foreignKey: ForeignKeyProperty;
|
|
15
|
+
constructor(item: RelationshipMetadata);
|
|
16
|
+
}
|
|
17
|
+
export default HasManyRelationship;
|
|
18
|
+
//# sourceMappingURL=HasManyRelationship.d.ts.map
|
|
@@ -0,0 +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,EAAE,SAAS,CAAa;IAC5B,UAAU,EAAE,kBAAkB,CAAC;gBAEnB,IAAI,EAAE,oBAAoB;CAMvC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
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 RelationshipMetadata_1 = __importDefault(require("./RelationshipMetadata"));
|
|
7
|
+
/**
|
|
8
|
+
* Extends `RelationshipMetadata` to specifically handle "HasMany" relationship metadata within the ORM system.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* @property {"HasMany"} type - A literal string that explicitly defines the type of relationship as "HasMany". This classification helps the ORM to apply the correct logic for relationship handling.
|
|
12
|
+
* @property {ForeignKeyProperty} foreignKey - The attribute in the associated entity that serves as a foreign key, linking back to the partition key of the owning entity. This key is essential for maintaining the integrity of the "HasMany" relationship.
|
|
13
|
+
*
|
|
14
|
+
* @param {RelationshipMetadata} item - An existing set of relationship metadata that should be applied to the newly created `HasManyRelationship` instance. This parameter allows for the inheritance and augmentation of relationship properties.
|
|
15
|
+
*/
|
|
16
|
+
class HasManyRelationship extends RelationshipMetadata_1.default {
|
|
17
|
+
type = "HasMany";
|
|
18
|
+
foreignKey;
|
|
19
|
+
constructor(item) {
|
|
20
|
+
super();
|
|
21
|
+
if (item !== undefined) {
|
|
22
|
+
Object.assign(this, item);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = HasManyRelationship;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ForeignKeyProperty } from "../../types";
|
|
2
|
+
import RelationshipMetadata from "./RelationshipMetadata";
|
|
3
|
+
/**
|
|
4
|
+
* Represents the metadata for a "HasOne" relationship metadata in the ORM system,
|
|
5
|
+
*
|
|
6
|
+
* @property {"HasOne"} type - A literal string identifying the type of relationship as "HasOne". This classification enables the ORM to apply appropriate handling logic specific to "HasOne" relationships.
|
|
7
|
+
* @property {ForeignKeyProperty} foreignKey - The attribute in the associated entity that functions as a foreign key, establishing a link back to the partition key of the owning entity. This key is vital for maintaining the relationship's integrity and navigability.
|
|
8
|
+
*
|
|
9
|
+
* @param {RelationshipMetadata} item - An instance of `RelationshipMetadata` containing the initial settings for the relationship. This can include the `foreignKey` and other properties relevant to establishing a "HasOne" relationship.
|
|
10
|
+
*/
|
|
11
|
+
declare class HasOneRelationship extends RelationshipMetadata {
|
|
12
|
+
type: "HasOne";
|
|
13
|
+
foreignKey: ForeignKeyProperty;
|
|
14
|
+
constructor(item: RelationshipMetadata);
|
|
15
|
+
}
|
|
16
|
+
export default HasOneRelationship;
|
|
17
|
+
//# sourceMappingURL=HasOneRelationship.d.ts.map
|
|
@@ -0,0 +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,EAAE,QAAQ,CAAY;IAC1B,UAAU,EAAE,kBAAkB,CAAC;gBAEnB,IAAI,EAAE,oBAAoB;CAMvC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
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 RelationshipMetadata_1 = __importDefault(require("./RelationshipMetadata"));
|
|
7
|
+
/**
|
|
8
|
+
* Represents the metadata for a "HasOne" relationship metadata in the ORM system,
|
|
9
|
+
*
|
|
10
|
+
* @property {"HasOne"} type - A literal string identifying the type of relationship as "HasOne". This classification enables the ORM to apply appropriate handling logic specific to "HasOne" relationships.
|
|
11
|
+
* @property {ForeignKeyProperty} foreignKey - The attribute in the associated entity that functions as a foreign key, establishing a link back to the partition key of the owning entity. This key is vital for maintaining the relationship's integrity and navigability.
|
|
12
|
+
*
|
|
13
|
+
* @param {RelationshipMetadata} item - An instance of `RelationshipMetadata` containing the initial settings for the relationship. This can include the `foreignKey` and other properties relevant to establishing a "HasOne" relationship.
|
|
14
|
+
*/
|
|
15
|
+
class HasOneRelationship extends RelationshipMetadata_1.default {
|
|
16
|
+
type = "HasOne";
|
|
17
|
+
foreignKey;
|
|
18
|
+
constructor(item) {
|
|
19
|
+
super();
|
|
20
|
+
if (item !== undefined) {
|
|
21
|
+
Object.assign(this, item);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = HasOneRelationship;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type DynaRecord from "../../DynaRecord";
|
|
2
|
+
import type { EntityClass } from "../../types";
|
|
3
|
+
type RelationshipType = "HasMany" | "BelongsTo" | "HasOne" | "HasAndBelongsToMany";
|
|
4
|
+
/**
|
|
5
|
+
* Serves as the base class for defining metadata related to various types of relationships within the ORM system, such as "HasMany", "BelongsTo", "HasOne", and "HasAndBelongsToMany". This abstract class provides a common structure for relationship metadata, encapsulating the relationship type, target entity, and property name.
|
|
6
|
+
*
|
|
7
|
+
* Each subclass of `RelationshipMetadata` specifies a concrete type of relationship, leveraging this base class to ensure consistency and reusability across different relationship types. The metadata captured here is essential for the ORM to accurately manage and navigate relationships between entities, enabling operations like query construction, relationship traversal, and data integrity enforcement.
|
|
8
|
+
*
|
|
9
|
+
* @property {RelationshipType} type - An abstract property that must be defined by subclasses, indicating the specific type of relationship ("HasMany", "BelongsTo", "HasOne", "HasAndBelongsToMany").
|
|
10
|
+
* @property {EntityClass<DynaRecord>} target - The entity class that is the target of the relationship. This specifies the class of the entity on the "other side" of the relationship.
|
|
11
|
+
* @property {keyof DynaRecord} propertyName - The property name on the source entity that holds or references the related entity or entities. This name is used within the source entity's class definition to access the related entity.
|
|
12
|
+
*
|
|
13
|
+
* Note: This class is abstract and cannot be instantiated directly. Instead, it should be extended by specific relationship metadata classes that define concrete types of relationships.
|
|
14
|
+
*/
|
|
15
|
+
declare abstract class RelationshipMetadata {
|
|
16
|
+
abstract type: RelationshipType;
|
|
17
|
+
target: EntityClass<DynaRecord>;
|
|
18
|
+
propertyName: keyof DynaRecord;
|
|
19
|
+
}
|
|
20
|
+
export default RelationshipMetadata;
|
|
21
|
+
//# sourceMappingURL=RelationshipMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RelationshipMetadata.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/RelationshipMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,KAAK,gBAAgB,GACjB,SAAS,GACT,WAAW,GACX,QAAQ,GACR,qBAAqB,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,uBAAe,oBAAoB;IACjC,SAAgB,IAAI,EAAE,gBAAgB,CAAC;IAChC,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAChC,YAAY,EAAE,MAAM,UAAU,CAAC;CACvC;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Serves as the base class for defining metadata related to various types of relationships within the ORM system, such as "HasMany", "BelongsTo", "HasOne", and "HasAndBelongsToMany". This abstract class provides a common structure for relationship metadata, encapsulating the relationship type, target entity, and property name.
|
|
5
|
+
*
|
|
6
|
+
* Each subclass of `RelationshipMetadata` specifies a concrete type of relationship, leveraging this base class to ensure consistency and reusability across different relationship types. The metadata captured here is essential for the ORM to accurately manage and navigate relationships between entities, enabling operations like query construction, relationship traversal, and data integrity enforcement.
|
|
7
|
+
*
|
|
8
|
+
* @property {RelationshipType} type - An abstract property that must be defined by subclasses, indicating the specific type of relationship ("HasMany", "BelongsTo", "HasOne", "HasAndBelongsToMany").
|
|
9
|
+
* @property {EntityClass<DynaRecord>} target - The entity class that is the target of the relationship. This specifies the class of the entity on the "other side" of the relationship.
|
|
10
|
+
* @property {keyof DynaRecord} propertyName - The property name on the source entity that holds or references the related entity or entities. This name is used within the source entity's class definition to access the related entity.
|
|
11
|
+
*
|
|
12
|
+
* Note: This class is abstract and cannot be instantiated directly. Instead, it should be extended by specific relationship metadata classes that define concrete types of relationships.
|
|
13
|
+
*/
|
|
14
|
+
class RelationshipMetadata {
|
|
15
|
+
target;
|
|
16
|
+
propertyName;
|
|
17
|
+
}
|
|
18
|
+
exports.default = RelationshipMetadata;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import BelongsToRelationship from "./BelongsToRelationship";
|
|
2
|
+
import HasAndBelongsToManyRelationship from "./HasAndBelongsToManyRelationship";
|
|
3
|
+
import HasManyRelationship from "./HasManyRelationship";
|
|
4
|
+
import HasOneRelationship from "./HasOneRelationship";
|
|
5
|
+
export * from "./types";
|
|
6
|
+
export { BelongsToRelationship, HasAndBelongsToManyRelationship, HasManyRelationship, HasOneRelationship };
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,+BAA+B,MAAM,mCAAmC,CAAC;AAChF,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,qBAAqB,EACrB,+BAA+B,EAC/B,mBAAmB,EACnB,kBAAkB,EACnB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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.HasOneRelationship = exports.HasManyRelationship = exports.HasAndBelongsToManyRelationship = exports.BelongsToRelationship = void 0;
|
|
21
|
+
const BelongsToRelationship_1 = __importDefault(require("./BelongsToRelationship"));
|
|
22
|
+
exports.BelongsToRelationship = BelongsToRelationship_1.default;
|
|
23
|
+
const HasAndBelongsToManyRelationship_1 = __importDefault(require("./HasAndBelongsToManyRelationship"));
|
|
24
|
+
exports.HasAndBelongsToManyRelationship = HasAndBelongsToManyRelationship_1.default;
|
|
25
|
+
const HasManyRelationship_1 = __importDefault(require("./HasManyRelationship"));
|
|
26
|
+
exports.HasManyRelationship = HasManyRelationship_1.default;
|
|
27
|
+
const HasOneRelationship_1 = __importDefault(require("./HasOneRelationship"));
|
|
28
|
+
exports.HasOneRelationship = HasOneRelationship_1.default;
|
|
29
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type BelongsToRelationship from "./BelongsToRelationship";
|
|
2
|
+
import type HasAndBelongsToManyRelationship from "./HasAndBelongsToManyRelationship";
|
|
3
|
+
import type HasManyRelationship from "./HasManyRelationship";
|
|
4
|
+
import type HasOneRelationship from "./HasOneRelationship";
|
|
5
|
+
/**
|
|
6
|
+
* A union type that encompasses all possible relationship metadata classes within the ORM system. This type is used to represent the metadata for various types of relationships that can exist between entities, such as "BelongsTo", "HasMany", "HasOne", and "HasAndBelongsToMany" relationships.
|
|
7
|
+
*
|
|
8
|
+
* Each variant in the union corresponds to a specific relationship type, with its own set of properties and behaviors that define how entities are related to each other. This type enables the ORM to handle relationship metadata in a generic manner while still allowing for the specific characteristics of each relationship type to be accessed and utilized.
|
|
9
|
+
*
|
|
10
|
+
* - `BelongsToRelationship`: Represents a "BelongsTo" relationship, indicating that the entity has a foreign key pointing to another entity.
|
|
11
|
+
* - `HasManyRelationship`: Represents a "HasMany" relationship, indicating that the entity can be associated with multiple instances of another entity.
|
|
12
|
+
* - `HasOneRelationship`: Represents a "HasOne" relationship, indicating that the entity is associated with at most one instance of another entity.
|
|
13
|
+
* - `HasAndBelongsToManyRelationship`: Represents a "HasAndBelongsToMany" relationship, facilitated by a join table, indicating that the entity can have many-to-many associations with another entity.
|
|
14
|
+
*/
|
|
15
|
+
export type RelationshipMetadata = BelongsToRelationship | HasManyRelationship | HasOneRelationship | HasAndBelongsToManyRelationship;
|
|
16
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,qBAAqB,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,+BAA+B,MAAM,mCAAmC,CAAC;AACrF,OAAO,KAAK,mBAAmB,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AAE3D;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,GAC5B,qBAAqB,GACrB,mBAAmB,GACnB,kBAAkB,GAClB,+BAA+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,eAAO,MAAM,0BAA0B,YAC5B,oBAAoB,KAC5B,oBAaF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
exports.createRelationshipInstance = void 0;
|
|
7
|
+
const BelongsToRelationship_1 = __importDefault(require("./BelongsToRelationship"));
|
|
8
|
+
const HasAndBelongsToManyRelationship_1 = __importDefault(require("./HasAndBelongsToManyRelationship"));
|
|
9
|
+
const HasManyRelationship_1 = __importDefault(require("./HasManyRelationship"));
|
|
10
|
+
const HasOneRelationship_1 = __importDefault(require("./HasOneRelationship"));
|
|
11
|
+
const createRelationshipInstance = (options) => {
|
|
12
|
+
switch (options.type) {
|
|
13
|
+
case "BelongsTo":
|
|
14
|
+
return new BelongsToRelationship_1.default(options);
|
|
15
|
+
case "HasAndBelongsToMany":
|
|
16
|
+
return new HasAndBelongsToManyRelationship_1.default(options);
|
|
17
|
+
case "HasMany":
|
|
18
|
+
return new HasManyRelationship_1.default(options);
|
|
19
|
+
case "HasOne":
|
|
20
|
+
return new HasOneRelationship_1.default(options);
|
|
21
|
+
default:
|
|
22
|
+
throw new Error("Invalid relationship type");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.createRelationshipInstance = createRelationshipInstance;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { NativeScalarAttributeValue } from "@aws-sdk/util-dynamodb";
|
|
2
|
+
import type { AttributeMetadata, EntityMetadata, JoinTableMetadata, RelationshipMetadata, TableMetadata } from ".";
|
|
3
|
+
import type DynaRecord from "../DynaRecord";
|
|
4
|
+
import type { BelongsToLink } from "../relationships";
|
|
5
|
+
import type { MakeOptional } from "../types";
|
|
6
|
+
/**
|
|
7
|
+
* Represents relationship metadata that includes a foreign key reference to another entity.
|
|
8
|
+
*/
|
|
9
|
+
export type RelationshipMetadataWithForeignKey = Extract<RelationshipMetadata, {
|
|
10
|
+
foreignKey: keyof DynaRecord;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* A record mapping string keys to `AttributeMetadata`, used for storing metadata about entity attributes and looking up by entity attribute name.
|
|
14
|
+
*/
|
|
15
|
+
export type AttributeMetadataStorage = Record<string, AttributeMetadata>;
|
|
16
|
+
/**
|
|
17
|
+
* A record mapping string keys to `RelationshipMetadata`, used for storing metadata about entity relationships and looking up by entity attribute name.
|
|
18
|
+
*/
|
|
19
|
+
export type RelationshipMetadataStorage = Record<string, RelationshipMetadata>;
|
|
20
|
+
/**
|
|
21
|
+
* A record mapping string keys to `TableMetadata`, used for storing metadata about tables associated with entities and looking up table class name.
|
|
22
|
+
*/
|
|
23
|
+
export type TableMetadataStorage = Record<string, TableMetadata>;
|
|
24
|
+
/**
|
|
25
|
+
* A record mapping string keys to `EntityMetadata`, used for storing metadata about entities and looking up by entity class name.
|
|
26
|
+
*/
|
|
27
|
+
export type EntityMetadataStorage = Record<string, EntityMetadata>;
|
|
28
|
+
/**
|
|
29
|
+
* A record mapping string keys to an array of `JoinTableMetadata`, used for storing metadata about join tables in relationships and looking up by join table class name.
|
|
30
|
+
*/
|
|
31
|
+
export type JoinTableMetadataStorage = Record<string, JoinTableMetadata[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Specifies the default date fields commonly used in entities: `createdAt` and `updatedAt`.
|
|
34
|
+
*/
|
|
35
|
+
export type DefaultDateFields = "createdAt" | "updatedAt";
|
|
36
|
+
/**
|
|
37
|
+
* Specifies the default fields used in entities, including fields from `DynaRecord` or `BelongsToLink`.
|
|
38
|
+
*/
|
|
39
|
+
export type DefaultFields = keyof DynaRecord | keyof BelongsToLink;
|
|
40
|
+
/**
|
|
41
|
+
* Defines the structure for default fields within a table, mapping field names to their `AttributeMetadata` aliases.
|
|
42
|
+
*/
|
|
43
|
+
export type TableDefaultFields = Record<DefaultFields, Pick<AttributeMetadata, "alias">>;
|
|
44
|
+
/**
|
|
45
|
+
* Options for configuring table metadata, including the table name, delimiter, and default fields.
|
|
46
|
+
*/
|
|
47
|
+
export type TableMetadataOptions = Pick<TableMetadata, "name" | "delimiter"> & {
|
|
48
|
+
defaultFields?: Partial<TableDefaultFields>;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Options for configuring keys in attribute metadata, making all properties except `nullable` optional, including `alias`.
|
|
52
|
+
*/
|
|
53
|
+
export type KeysAttributeMetadataOptions = MakeOptional<Omit<AttributeMetadataOptions, "nullable">, "alias">;
|
|
54
|
+
/**
|
|
55
|
+
* Function that takes a attribute from a Dynamo table item, and serialize it to a non-Dynamo native type (EX: Date)
|
|
56
|
+
*/
|
|
57
|
+
export type EntitySerializer = (param: NativeScalarAttributeValue) => any;
|
|
58
|
+
/**
|
|
59
|
+
* 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
|
|
60
|
+
*/
|
|
61
|
+
export type TableSerializer = (param: any) => NativeScalarAttributeValue;
|
|
62
|
+
/**
|
|
63
|
+
* Functions for serializing attribute types that are not native to Dynamo from table item -> entity and entity -> table item
|
|
64
|
+
* EX: See DateAttribute decorator
|
|
65
|
+
*/
|
|
66
|
+
export interface Serializers {
|
|
67
|
+
/**
|
|
68
|
+
* Function to serialize a Dynamo table item attribute to Entity attribute. Used when the type defined on the entity is not a native type to Dynamo (EX: Date)
|
|
69
|
+
*/
|
|
70
|
+
toEntityAttribute: EntitySerializer;
|
|
71
|
+
/**
|
|
72
|
+
* Function to serialize an Entity attribute to an attribute type that Dynamo supports. (EX: Date->string)
|
|
73
|
+
*/
|
|
74
|
+
toTableAttribute: TableSerializer;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Defines the options for configuring attribute metadata within the ORM system. This interface specifies the settings used to describe and manage an attribute's representation and behavior in both the entity model and the underlying database schema, particularly focusing on attributes' names, aliases, nullability, and serialization strategies.
|
|
78
|
+
*
|
|
79
|
+
* @property {string} attributeName - The name of the attribute as defined in the entity. This is the primary identifier for the attribute within the ORM and is used in entity operations.
|
|
80
|
+
* @property {string} [alias] - An optional alias for the attribute that represents its name within the database. This is used for mapping the attribute to its corresponding column in the database table. If not specified, the `attributeName` is used as the column name.
|
|
81
|
+
* @property {boolean} nullable - Indicates whether the attribute is allowed to have null values. This property is crucial for enforcing data integrity and validation rules at the database level.
|
|
82
|
+
* @property {Serializers} [serializers] - Optional custom serialization strategies for the attribute. These strategies define how to convert the attribute's value between its representation in the entity and its representation in the database. This is particularly useful for handling complex data types or custom transformations.
|
|
83
|
+
*/
|
|
84
|
+
export interface AttributeMetadataOptions {
|
|
85
|
+
attributeName: string;
|
|
86
|
+
alias?: string;
|
|
87
|
+
nullable: boolean;
|
|
88
|
+
serializers?: Serializers;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/metadata/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACd,MAAM,GAAG,CAAC;AACX,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG,OAAO,CACtD,oBAAoB,EACpB;IAAE,UAAU,EAAE,MAAM,UAAU,CAAA;CAAE,CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,WAAW,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CACrC,aAAa,EACb,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,WAAW,CAAC,GAAG;IAC7E,aAAa,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC7C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,YAAY,CACrD,IAAI,CAAC,wBAAwB,EAAE,UAAU,CAAC,EAC1C,OAAO,CACR,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,0BAA0B,KAAK,GAAG,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,0BAA0B,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,iBAAiB,EAAE,gBAAgB,CAAC;IACpC;;OAEG;IACH,gBAAgB,EAAE,eAAe,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { RelationshipMetadata, HasManyRelationship, BelongsToRelationship, HasOneRelationship, HasAndBelongsToManyRelationship } from ".";
|
|
2
|
+
import type DynaRecord from "../DynaRecord";
|
|
3
|
+
import type { RelationshipMetadataWithForeignKey } from "./types";
|
|
4
|
+
import type { EntityClass } from "../types";
|
|
5
|
+
/**
|
|
6
|
+
* Type guard to check if the relationship is a HasMany
|
|
7
|
+
*/
|
|
8
|
+
export declare const isHasManyRelationship: (rel: RelationshipMetadata) => rel is HasManyRelationship;
|
|
9
|
+
/**
|
|
10
|
+
* Type guard to check if the relationship is a BelongsTo
|
|
11
|
+
*/
|
|
12
|
+
export declare const isBelongsToRelationship: (rel: RelationshipMetadata) => rel is BelongsToRelationship;
|
|
13
|
+
/**
|
|
14
|
+
* Type guard to check if the relationship is a HasOne
|
|
15
|
+
*/
|
|
16
|
+
export declare const isHasOneRelationship: (rel: RelationshipMetadata) => rel is HasOneRelationship;
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to check if the relationship is a HasOne
|
|
19
|
+
*/
|
|
20
|
+
export declare const isHasAndBelongsToManyRelationship: (rel: RelationshipMetadata) => rel is HasAndBelongsToManyRelationship;
|
|
21
|
+
/**
|
|
22
|
+
* Type guard to check if the relationship metadata includes a foreignKey
|
|
23
|
+
* @param rel
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
export declare const isRelationshipMetadataWithForeignKey: (rel: RelationshipMetadata) => rel is RelationshipMetadataWithForeignKey;
|
|
27
|
+
/**
|
|
28
|
+
* Returns true if an "Entity" BelongsTo the provided relationship as a HasOne
|
|
29
|
+
* @param Entity
|
|
30
|
+
* @param rel
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export declare const doesEntityBelongToRelAsHasOne: <T extends DynaRecord>(Entity: EntityClass<T>, rel: BelongsToRelationship) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Returns true if an "Entity" BelongsTo the provided relationship as a HasMany
|
|
36
|
+
* @param Entity
|
|
37
|
+
* @param rel
|
|
38
|
+
* @param foreignKey
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export declare const doesEntityBelongToRelAsHasMany: <T extends DynaRecord>(Entity: EntityClass<T>, rel: BelongsToRelationship) => boolean;
|
|
42
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/metadata/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,+BAA+B,EAChC,MAAM,GAAG,CAAC;AACX,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAC3B,oBAAoB,+BAG1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,QAC7B,oBAAoB,iCAG1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,QAC1B,oBAAoB,8BAG1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,QACvC,oBAAoB,2CAG1B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,QAC1C,oBAAoB,8CAG1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,sDAEnC,qBAAqB,KACzB,OAMF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,sDAEpC,qBAAqB,KACzB,OAMF,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
exports.doesEntityBelongToRelAsHasMany = exports.doesEntityBelongToRelAsHasOne = exports.isRelationshipMetadataWithForeignKey = exports.isHasAndBelongsToManyRelationship = exports.isHasOneRelationship = exports.isBelongsToRelationship = exports.isHasManyRelationship = void 0;
|
|
7
|
+
const _1 = __importDefault(require("./"));
|
|
8
|
+
/**
|
|
9
|
+
* Type guard to check if the relationship is a HasMany
|
|
10
|
+
*/
|
|
11
|
+
const isHasManyRelationship = (rel) => {
|
|
12
|
+
return rel.type === "HasMany" && rel.foreignKey !== undefined;
|
|
13
|
+
};
|
|
14
|
+
exports.isHasManyRelationship = isHasManyRelationship;
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to check if the relationship is a BelongsTo
|
|
17
|
+
*/
|
|
18
|
+
const isBelongsToRelationship = (rel) => {
|
|
19
|
+
return rel.type === "BelongsTo" && rel.foreignKey !== undefined;
|
|
20
|
+
};
|
|
21
|
+
exports.isBelongsToRelationship = isBelongsToRelationship;
|
|
22
|
+
/**
|
|
23
|
+
* Type guard to check if the relationship is a HasOne
|
|
24
|
+
*/
|
|
25
|
+
const isHasOneRelationship = (rel) => {
|
|
26
|
+
return rel.type === "HasOne" && rel.foreignKey !== undefined;
|
|
27
|
+
};
|
|
28
|
+
exports.isHasOneRelationship = isHasOneRelationship;
|
|
29
|
+
/**
|
|
30
|
+
* Type guard to check if the relationship is a HasOne
|
|
31
|
+
*/
|
|
32
|
+
const isHasAndBelongsToManyRelationship = (rel) => {
|
|
33
|
+
return rel.type === "HasAndBelongsToMany" && rel.joinTableName !== undefined;
|
|
34
|
+
};
|
|
35
|
+
exports.isHasAndBelongsToManyRelationship = isHasAndBelongsToManyRelationship;
|
|
36
|
+
/**
|
|
37
|
+
* Type guard to check if the relationship metadata includes a foreignKey
|
|
38
|
+
* @param rel
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
const isRelationshipMetadataWithForeignKey = (rel) => {
|
|
42
|
+
return "foreignKey" in rel;
|
|
43
|
+
};
|
|
44
|
+
exports.isRelationshipMetadataWithForeignKey = isRelationshipMetadataWithForeignKey;
|
|
45
|
+
/**
|
|
46
|
+
* Returns true if an "Entity" BelongsTo the provided relationship as a HasOne
|
|
47
|
+
* @param Entity
|
|
48
|
+
* @param rel
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
const doesEntityBelongToRelAsHasOne = (Entity, rel) => {
|
|
52
|
+
const relMetadata = _1.default.getEntity(rel.target.name);
|
|
53
|
+
return Object.values(relMetadata.relationships).some(rel => (0, exports.isHasOneRelationship)(rel) && rel.target === Entity);
|
|
54
|
+
};
|
|
55
|
+
exports.doesEntityBelongToRelAsHasOne = doesEntityBelongToRelAsHasOne;
|
|
56
|
+
/**
|
|
57
|
+
* Returns true if an "Entity" BelongsTo the provided relationship as a HasMany
|
|
58
|
+
* @param Entity
|
|
59
|
+
* @param rel
|
|
60
|
+
* @param foreignKey
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
const doesEntityBelongToRelAsHasMany = (Entity, rel) => {
|
|
64
|
+
const relMetadata = _1.default.getEntity(rel.target.name);
|
|
65
|
+
return Object.values(relMetadata.relationships).some(rel => (0, exports.isHasManyRelationship)(rel) && rel.target === Entity);
|
|
66
|
+
};
|
|
67
|
+
exports.doesEntityBelongToRelAsHasMany = doesEntityBelongToRelAsHasMany;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type DynaRecord from "../../DynaRecord";
|
|
2
|
+
import type { EntityClass } from "../../types";
|
|
3
|
+
import OperationBase from "../OperationBase";
|
|
4
|
+
import type { CreateOptions } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Represents the operation for creating a new entity in the database, including handling its attributes and any related entities' associations. It will handle de-normalizing data to support relationships
|
|
7
|
+
*
|
|
8
|
+
* It encapsulates the logic required to translate entity attributes to a format suitable for DynamoDB, execute the creation transaction, and manage any relationships defined by the entity, such as "BelongsTo" or "HasMany" links.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The type of the entity being created, extending `DynaRecord`.
|
|
11
|
+
*/
|
|
12
|
+
declare class Create<T extends DynaRecord> extends OperationBase<T> {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(Entity: EntityClass<T>);
|
|
15
|
+
/**
|
|
16
|
+
* Create an entity transaction, including relationship transactions (EX: Creating BelongsToLinks for HasMany, checking existence of relationships, etc)
|
|
17
|
+
* @param attributes
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
run(attributes: CreateOptions<T>): Promise<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Builds the entity attributes
|
|
23
|
+
* @param attributes
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
private buildEntityData;
|
|
27
|
+
/**
|
|
28
|
+
* Build the transaction for the parent entity Create item request
|
|
29
|
+
* @param tableItem
|
|
30
|
+
*/
|
|
31
|
+
private buildPutItemTransaction;
|
|
32
|
+
/**
|
|
33
|
+
* Build transaction items for associations
|
|
34
|
+
* @param entityData
|
|
35
|
+
*/
|
|
36
|
+
private buildRelationshipTransactions;
|
|
37
|
+
}
|
|
38
|
+
export default Create;
|
|
39
|
+
//# sourceMappingURL=Create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Create.d.ts","sourceRoot":"","sources":["../../../../src/operations/Create/Create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,aAAa,CAAC;AAGhE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;GAMG;AACH,cAAM,MAAM,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;;gBAG7C,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IAKlC;;;;OAIG;IACU,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAa1D;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAsBvB;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAW/B;;;OAGG;YACW,6BAA6B;CAU5C;AAED,eAAe,MAAM,CAAC"}
|