dyna-record 0.0.2 → 0.0.4

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 CHANGED
@@ -3,4 +3,4 @@
3
3
  Typescript Object Relational Mapper (ORM) for Dynamo
4
4
 
5
5
  Domain moving soon. More documentation to come soon as well
6
- [Documentation Site](https://dsdavis4.github.io/dyna-record/)
6
+ [Documentation Site](https://dyna-record.com/)
@@ -4,6 +4,8 @@ import type { AttributeOptions } from "../types";
4
4
  /**
5
5
  * A decorator for annotating class fields as foreign keys within the context of a single-table design entity, aimed at establishing and managing relationships between different entities in a relational manner. This decorator enables the clear and explicit declaration of foreign key relationships, contributing to the ORM's ability to navigate and resolve these associations efficiently.
6
6
  *
7
+ * The entity can belong to its associated entity has a {@link HasOne} or {@link HasMany}
8
+ *
7
9
  * Does not allow property to be optional.
8
10
  *
9
11
  * @template T The entity the decorator is applied to.
@@ -14,7 +16,10 @@ import type { AttributeOptions } from "../types";
14
16
  * ```typescript
15
17
  * class Order extends BaseEntity {
16
18
  * @ForeignKeyAttribute({ alias: 'UserID' })
17
- * public userId: string; // Foreign key to the User entity
19
+ * public userId: ForeignKey; // Foreign key to the User entity. Cannot be optional. See {@link NullableForeignKeyAttribute} if it is nullable
20
+ *
21
+ * @BelongsTo(() => User, { foreignKey: "userId" })
22
+ * public readonly user: User; // Cannot be optional
18
23
  * }
19
24
  * ```
20
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ForeignKeyAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/ForeignKeyAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,iBAAS,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAAE,KAAK,CAAC,EAAE,gBAAgB,YAE/D,SAAS,WACR,2BAA2B,CAAC,EAAE,UAAU,CAAC,UAcrD;AAED,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"ForeignKeyAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/ForeignKeyAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAS,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAAE,KAAK,CAAC,EAAE,gBAAgB,YAE/D,SAAS,WACR,2BAA2B,CAAC,EAAE,UAAU,CAAC,UAcrD;AAED,eAAe,mBAAmB,CAAC"}
@@ -7,6 +7,8 @@ const metadata_1 = __importDefault(require("../../metadata"));
7
7
  /**
8
8
  * A decorator for annotating class fields as foreign keys within the context of a single-table design entity, aimed at establishing and managing relationships between different entities in a relational manner. This decorator enables the clear and explicit declaration of foreign key relationships, contributing to the ORM's ability to navigate and resolve these associations efficiently.
9
9
  *
10
+ * The entity can belong to its associated entity has a {@link HasOne} or {@link HasMany}
11
+ *
10
12
  * Does not allow property to be optional.
11
13
  *
12
14
  * @template T The entity the decorator is applied to.
@@ -17,7 +19,10 @@ const metadata_1 = __importDefault(require("../../metadata"));
17
19
  * ```typescript
18
20
  * class Order extends BaseEntity {
19
21
  * @ForeignKeyAttribute({ alias: 'UserID' })
20
- * public userId: string; // Foreign key to the User entity
22
+ * public userId: ForeignKey; // Foreign key to the User entity. Cannot be optional. See {@link NullableForeignKeyAttribute} if it is nullable
23
+ *
24
+ * @BelongsTo(() => User, { foreignKey: "userId" })
25
+ * public readonly user: User; // Cannot be optional
21
26
  * }
22
27
  * ```
23
28
  *
@@ -6,6 +6,8 @@ import type { AttributeOptions } from "../types";
6
6
  *
7
7
  * IMPORTANT - For optimal type safety mark the class field property as optional
8
8
  *
9
+ * The entity can belong to its associated entity has a {@link HasOne} or {@link HasMany}
10
+ *
9
11
  * @template T The entity the decorator is applied to.
10
12
  * @param props An optional object of {@link AttributeOptions}, including configuration options such as metadata attributes.
11
13
  * @returns A class field decorator function that targets and initializes the class's prototype to register the field with the ORM's metadata system.
@@ -14,7 +16,10 @@ import type { AttributeOptions } from "../types";
14
16
  * ```typescript
15
17
  * class User extends BaseEntity {
16
18
  * @NullableForeignKeyAttribute({ alias: 'ProfileId' })
17
- * public profileId?: string; // Set to optional. Nullable foreign key to another entity (e.g., UserProfile)
19
+ * public profileId?: NullableForeignKey; // Set to optional. Nullable foreign key to another entity (e.g., UserProfile)
20
+ *
21
+ * @BelongsTo(() => Profile, { foreignKey: "profileId" })
22
+ * public readonly profile?: Profile; // Set to optional because its linked via a NullableForeignKey
18
23
  * }
19
24
  * ```
20
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"NullableForeignKeyAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/NullableForeignKeyAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,iBAAS,2BAA2B,CAAC,CAAC,SAAS,UAAU,EACvD,KAAK,CAAC,EAAE,gBAAgB,YAGd,SAAS,WACR,2BAA2B,CAAC,EAAE,kBAAkB,CAAC,UAc7D;AAED,eAAe,2BAA2B,CAAC"}
1
+ {"version":3,"file":"NullableForeignKeyAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/NullableForeignKeyAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAS,2BAA2B,CAAC,CAAC,SAAS,UAAU,EACvD,KAAK,CAAC,EAAE,gBAAgB,YAGd,SAAS,WACR,2BAA2B,CAAC,EAAE,kBAAkB,CAAC,UAc7D;AAED,eAAe,2BAA2B,CAAC"}
@@ -9,6 +9,8 @@ const metadata_1 = __importDefault(require("../../metadata"));
9
9
  *
10
10
  * IMPORTANT - For optimal type safety mark the class field property as optional
11
11
  *
12
+ * The entity can belong to its associated entity has a {@link HasOne} or {@link HasMany}
13
+ *
12
14
  * @template T The entity the decorator is applied to.
13
15
  * @param props An optional object of {@link AttributeOptions}, including configuration options such as metadata attributes.
14
16
  * @returns A class field decorator function that targets and initializes the class's prototype to register the field with the ORM's metadata system.
@@ -17,7 +19,10 @@ const metadata_1 = __importDefault(require("../../metadata"));
17
19
  * ```typescript
18
20
  * class User extends BaseEntity {
19
21
  * @NullableForeignKeyAttribute({ alias: 'ProfileId' })
20
- * public profileId?: string; // Set to optional. Nullable foreign key to another entity (e.g., UserProfile)
22
+ * public profileId?: NullableForeignKey; // Set to optional. Nullable foreign key to another entity (e.g., UserProfile)
23
+ *
24
+ * @BelongsTo(() => Profile, { foreignKey: "profileId" })
25
+ * public readonly profile?: Profile; // Set to optional because its linked via a NullableForeignKey
21
26
  * }
22
27
  * ```
23
28
  *
@@ -68,12 +68,12 @@ interface HasAndBelongsToManyProps<T extends DynaRecord, K extends DynaRecord, J
68
68
  * public users: User[];
69
69
  * }
70
70
  *
71
- * class AuthorBook extends JoinTable<User, Group> {
71
+ * class UserGroup extends JoinTable<User, Group> {
72
72
  * public readonly userId: ForeignKey;
73
73
  * public readonly groupId: ForeignKey;
74
74
  * }
75
75
  * ```
76
- * In this example, `User` entities are related to `Group` entities through a many-to-many relationship, with `UserGroupJoin` serving as the join table. The decorator indicates this relationship, allowing for efficient querying and manipulation of related entities.
76
+ * In this example, `User` entities are related to `Group` entities through a many-to-many relationship, with `UserGroup` serving as the join table. The decorator indicates this relationship, allowing for efficient querying and manipulation of related entities.
77
77
  */
78
78
  declare function HasAndBelongsToMany<T extends DynaRecord, K extends DynaRecord, J extends JoinTable<T, K>, L extends JoinTable<K, T>>(getTarget: () => EntityClass<T>, props: HasAndBelongsToManyProps<T, K, J, L>): (_value: undefined, context: ClassFieldDecoratorContext<K, T[]>) => void;
79
79
  export default HasAndBelongsToMany;
@@ -39,12 +39,12 @@ const metadata_1 = __importDefault(require("../../metadata"));
39
39
  * public users: User[];
40
40
  * }
41
41
  *
42
- * class AuthorBook extends JoinTable<User, Group> {
42
+ * class UserGroup extends JoinTable<User, Group> {
43
43
  * public readonly userId: ForeignKey;
44
44
  * public readonly groupId: ForeignKey;
45
45
  * }
46
46
  * ```
47
- * In this example, `User` entities are related to `Group` entities through a many-to-many relationship, with `UserGroupJoin` serving as the join table. The decorator indicates this relationship, allowing for efficient querying and manipulation of related entities.
47
+ * In this example, `User` entities are related to `Group` entities through a many-to-many relationship, with `UserGroup` serving as the join table. The decorator indicates this relationship, allowing for efficient querying and manipulation of related entities.
48
48
  */
49
49
  function HasAndBelongsToMany(getTarget, props) {
50
50
  return (_value, context) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dyna-record",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Typescript Object Relational Mapper (ORM) for Dynamo",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",