dyna-record 0.0.20 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +19 -39
  2. package/dist/src/DynaRecord.d.ts +1 -1
  3. package/dist/src/DynaRecord.js +3 -3
  4. package/dist/src/decorators/attributes/BooleanAttribute.d.ts +28 -0
  5. package/dist/src/decorators/attributes/BooleanAttribute.d.ts.map +1 -0
  6. package/dist/src/decorators/attributes/{NullableAttribute.js → BooleanAttribute.js} +16 -11
  7. package/dist/src/decorators/attributes/DateAttribute.d.ts +11 -6
  8. package/dist/src/decorators/attributes/DateAttribute.d.ts.map +1 -1
  9. package/dist/src/decorators/attributes/DateAttribute.js +12 -5
  10. package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts +10 -4
  11. package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts.map +1 -1
  12. package/dist/src/decorators/attributes/ForeignKeyAttribute.js +10 -2
  13. package/dist/src/decorators/attributes/NumberAttribute.d.ts +28 -0
  14. package/dist/src/decorators/attributes/NumberAttribute.d.ts.map +1 -0
  15. package/dist/src/decorators/attributes/{DateNullableAttribute.js → NumberAttribute.js} +16 -13
  16. package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts +3 -3
  17. package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts.map +1 -1
  18. package/dist/src/decorators/attributes/PartitionKeyAttribute.js +3 -1
  19. package/dist/src/decorators/attributes/SortKeyAttribute.d.ts +3 -3
  20. package/dist/src/decorators/attributes/SortKeyAttribute.d.ts.map +1 -1
  21. package/dist/src/decorators/attributes/SortKeyAttribute.js +3 -1
  22. package/dist/src/decorators/attributes/StringAttribute.d.ts +28 -0
  23. package/dist/src/decorators/attributes/StringAttribute.d.ts.map +1 -0
  24. package/dist/src/decorators/attributes/{Attribute.js → StringAttribute.js} +15 -10
  25. package/dist/src/decorators/attributes/index.d.ts +3 -4
  26. package/dist/src/decorators/attributes/index.d.ts.map +1 -1
  27. package/dist/src/decorators/attributes/index.js +7 -9
  28. package/dist/src/decorators/attributes/serializers.d.ts +1 -1
  29. package/dist/src/decorators/attributes/serializers.d.ts.map +1 -1
  30. package/dist/src/decorators/attributes/serializers.js +1 -1
  31. package/dist/src/decorators/types.d.ts +9 -0
  32. package/dist/src/decorators/types.d.ts.map +1 -1
  33. package/dist/src/errors.d.ts +6 -0
  34. package/dist/src/errors.d.ts.map +1 -1
  35. package/dist/src/errors.js +8 -1
  36. package/dist/src/metadata/AttributeMetadata.d.ts +3 -0
  37. package/dist/src/metadata/AttributeMetadata.d.ts.map +1 -1
  38. package/dist/src/metadata/AttributeMetadata.js +9 -1
  39. package/dist/src/metadata/EntityMetadata.d.ts +16 -0
  40. package/dist/src/metadata/EntityMetadata.d.ts.map +1 -1
  41. package/dist/src/metadata/EntityMetadata.js +53 -0
  42. package/dist/src/metadata/TableMetadata.d.ts.map +1 -1
  43. package/dist/src/metadata/TableMetadata.js +7 -3
  44. package/dist/src/metadata/types.d.ts +3 -1
  45. package/dist/src/metadata/types.d.ts.map +1 -1
  46. package/dist/src/operations/Create/Create.d.ts.map +1 -1
  47. package/dist/src/operations/Create/Create.js +3 -0
  48. package/dist/src/operations/Update/Update.d.ts.map +1 -1
  49. package/dist/src/operations/Update/Update.js +3 -0
  50. package/dist/src/operations/types.d.ts +1 -1
  51. package/package.json +3 -2
  52. package/dist/src/decorators/attributes/Attribute.d.ts +0 -26
  53. package/dist/src/decorators/attributes/Attribute.d.ts.map +0 -1
  54. package/dist/src/decorators/attributes/DateNullableAttribute.d.ts +0 -26
  55. package/dist/src/decorators/attributes/DateNullableAttribute.d.ts.map +0 -1
  56. package/dist/src/decorators/attributes/NullableAttribute.d.ts +0 -27
  57. package/dist/src/decorators/attributes/NullableAttribute.d.ts.map +0 -1
  58. package/dist/src/decorators/attributes/NullableForeignKeyAttribute.d.ts +0 -30
  59. package/dist/src/decorators/attributes/NullableForeignKeyAttribute.d.ts.map +0 -1
  60. package/dist/src/decorators/attributes/NullableForeignKeyAttribute.js +0 -45
package/README.md CHANGED
@@ -134,49 +134,37 @@ class Course extends MyTable {
134
134
 
135
135
  ### Attributes
136
136
 
137
- For [natively supported data types](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes), define attributes using the [@Attribute](https://dyna-record.com/functions/Attribute.html) or [@NullableAttribute](https://dyna-record.com/functions/NullableAttribute.html) decorators. This decorator maps class properties to DynamoDB table attributes.
137
+ For [natively supported data types](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes), define attributes using the [@Attribute](https://dyna-record.com/functions/Attribute.html) decorator. This decorator maps class properties to DynamoDB table attributes.
138
+
139
+ Use the attribute decorators below to define attributes on a model. The decorator maps class properties to DynamoDB table attributes.
140
+
141
+ - Attribute decorators
142
+
143
+ - [@StringAttribute](https://dyna-record.com/functions/StringAttribute.html)
144
+ - [@NumberAttribute](https://dyna-record.com/functions/NumberAttribute.html)
145
+ - [@BooleanAttribute](https://dyna-record.com/functions/BooleanAttribute.html)
146
+ - [@DateAttribute](https://dyna-record.com/functions/DateAttribute.html)
138
147
 
139
148
  - The [alias](https://dyna-record.com/interfaces/AttributeOptions.html#alias) option allows you to specify the attribute name as it appears in the DynamoDB table, different from your class property name.
140
149
  - Set nullable attributes as optional for optimal type safety
141
150
  - Attempting to remove a non-nullable attribute will result in a [NullConstrainViolationError](https://dyna-record.com/classes/NullConstraintViolationError.html)
142
151
 
143
152
  ```typescript
144
- import { Entity, Attribute, NullableAttribute } from "dyna-record";
153
+ import { Entity, Attribute } from "dyna-record";
145
154
 
146
155
  @Entity
147
156
  class Student extends MyTable {
148
- @Attribute({ alias: "Username" }) // Sets alias if field in Dynamo is different then on the model
157
+ @StringAttribute({ alias: "Username" }) // Sets alias if field in Dynamo is different then on the model
149
158
  public username: string;
150
159
 
151
- @Attribute() // Dynamo field and entity field are the same
160
+ @StringAttribute() // Dynamo field and entity field are the same
152
161
  public email: string;
153
162
 
154
- @NullableAttribute()
163
+ @NumberAttribute({ nullable: true })
155
164
  public someAttribute?: number; // Mark as optional
156
165
  }
157
166
  ```
158
167
 
159
- ### Date Attributes
160
-
161
- Dates are not natively supported in Dynamo. To define a date attribute use [@DateAttribute](https://dyna-record.com/functions/DateAttribute.html) or [@NullableDateAttribute](https://dyna-record.com/functions/DateNullableAttribute.html) decorators. dyna-record will save the values as ISO strings in Dynamo, but serialize them as JS date objects on the entity instance
162
-
163
- - The [alias](https://dyna-record.com/interfaces/AttributeOptions.html#alias) option allows you to specify the attribute name as it appears in the DynamoDB table, different from your class property name.
164
- - Set nullable attributes as optional for optimal type safety
165
- - Attempting to remove a non-nullable attribute will result in a [NullConstrainViolationError](https://dyna-record.com/classes/NullConstraintViolationError.html)
166
-
167
- ```typescript
168
- import { Entity, DateAttribute, NullableDateAttribute } from "dyna-record";
169
-
170
- @Entity
171
- class Student extends MyTable {
172
- @DateAttribute()
173
- public readonly signUpDate: Date;
174
-
175
- @NullableDateAttribute({ alias: "LastLogin" })
176
- public readonly lastLogin?: Date; // Set as optional
177
- }
178
- ```
179
-
180
168
  ### Foreign Keys
181
169
 
182
170
  Define foreign keys in order to support [@BelongsTo](https://dyna-record.com/functions/BelongsTo.html) relationships. A foreign key is required for [@HasOne](https://dyna-record.com/functions/HasOne.html) and [@HasMany](https://dyna-record.com/functions/HasMany.html) relationships.
@@ -190,7 +178,6 @@ import {
190
178
  Entity,
191
179
  ForeignKeyAttribute,
192
180
  ForeignKey,
193
- NullableForeignKeyAttribute,
194
181
  NullableForeignKey,
195
182
  BelongsTo
196
183
  } from "dyna-record";
@@ -206,7 +193,7 @@ class Assignment extends MyTable {
206
193
 
207
194
  @Entity
208
195
  class Course extends MyTable {
209
- @NullableForeignKeyAttribute()
196
+ @ForeignKeyAttribute({ nullable: true })
210
197
  public readonly teacherId?: NullableForeignKey; // Set as optional
211
198
 
212
199
  @BelongsTo(() => Teacher, { foreignKey: "teacherId" })
@@ -220,8 +207,7 @@ Dyna-Record supports defining relationships between entities such as [@HasOne](h
220
207
 
221
208
  A relationship can be defined as nullable or non-nullable. Non-nullable relationships will be enforced via transactions and violations will result in [NullConstraintViolationError](https://dyna-record.com/classes/NullConstraintViolationError.html)
222
209
 
223
- - [@ForeignKeyAttribute](https://dyna-record.com/functions/ForeignKeyAttribute.html) is used to define a foreign key that links to another entity and is not nullable.
224
- - [@NullableForeignKeyAttribute](https://dyna-record.com/functions/NullableForeignKeyAttribute.html) is used to define a foreign key that links to another entity and is nullable.
210
+ - [@ForeignKeyAttribute](https://dyna-record.com/functions/ForeignKeyAttribute.html) is used to define a foreign key that links to another entity
225
211
  - Relationship decorators ([@HasOne](#hasone), [@HasMany](#hasmany), [@BelongsTo](https://dyna-record.com/functions/BelongsTo.html), [@HasAndBelongsToMany](#hasandbelongstomany)) define how entities relate to each other.
226
212
 
227
213
  #### HasOne
@@ -260,13 +246,7 @@ class Grade extends MyTable {
260
246
  [Docs](https://dyna-record.com/functions/HasMany.html)
261
247
 
262
248
  ```typescript
263
- import {
264
- Entity,
265
- NullableForeignKeyAttribute,
266
- NullableForeignKey,
267
- BelongsTo,
268
- HasMany
269
- } from "dyna-record";
249
+ import { Entity, NullableForeignKey, BelongsTo, HasMany } from "dyna-record";
270
250
 
271
251
  @Entity
272
252
  class Teacher extends MyTable {
@@ -277,8 +257,8 @@ class Teacher extends MyTable {
277
257
 
278
258
  @Entity
279
259
  class Course extends MyTable {
280
- @NullableForeignKeyAttribute()
281
- public readonly teacherId?: NullableForeignKey;
260
+ @ForeignKeyAttribute({ nullable: true })
261
+ public readonly teacherId?: NullableForeignKey; // Mark as optional
282
262
 
283
263
  // 'teacherId' Must be defined on self as ForeignKey or NullableForeignKey
284
264
  @BelongsTo(() => Teacher, { foreignKey: "teacherId" })
@@ -171,7 +171,7 @@ declare abstract class DynaRecord implements DynaRecordBase {
171
171
  * Update an entity. If foreign keys are included in the attribute then:
172
172
  * - BelongsToLinks will be created accordingly
173
173
  * - If the entity already had a foreign key relationship, then those BelongsToLinks will be deleted
174
- * - If the foreign key is not nullable then a {@link NullConstraintViolationError} is thrown. See {@link NullableForeignKeyAttribute}
174
+ * - If the foreign key is not nullable then a {@link NullConstraintViolationError} is thrown.
175
175
  * - Validation errors will be thrown if the attribute being removed is not nullable
176
176
  * @param id - The id of the entity to update
177
177
  * @param attributes - Attributes to update
@@ -96,8 +96,8 @@ let DynaRecord = (() => {
96
96
  return class DynaRecord {
97
97
  static {
98
98
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
99
- _id_decorators = [(0, decorators_1.Attribute)({ alias: metadata_1.tableDefaultFields.id.alias })];
100
- _type_decorators = [(0, decorators_1.Attribute)({ alias: metadata_1.tableDefaultFields.type.alias })];
99
+ _id_decorators = [(0, decorators_1.StringAttribute)({ alias: metadata_1.tableDefaultFields.id.alias })];
100
+ _type_decorators = [(0, decorators_1.StringAttribute)({ alias: metadata_1.tableDefaultFields.type.alias })];
101
101
  _createdAt_decorators = [(0, decorators_1.DateAttribute)({ alias: metadata_1.tableDefaultFields.createdAt.alias })];
102
102
  _updatedAt_decorators = [(0, decorators_1.DateAttribute)({ alias: metadata_1.tableDefaultFields.updatedAt.alias })];
103
103
  __esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _instanceExtraInitializers);
@@ -163,7 +163,7 @@ let DynaRecord = (() => {
163
163
  * Update an entity. If foreign keys are included in the attribute then:
164
164
  * - BelongsToLinks will be created accordingly
165
165
  * - If the entity already had a foreign key relationship, then those BelongsToLinks will be deleted
166
- * - If the foreign key is not nullable then a {@link NullConstraintViolationError} is thrown. See {@link NullableForeignKeyAttribute}
166
+ * - If the foreign key is not nullable then a {@link NullConstraintViolationError} is thrown.
167
167
  * - Validation errors will be thrown if the attribute being removed is not nullable
168
168
  * @param id - The id of the entity to update
169
169
  * @param attributes - Attributes to update
@@ -0,0 +1,28 @@
1
+ import type DynaRecord from "../../DynaRecord";
2
+ import type { AttributeDecoratorContext, AttributeOptions } from "../types";
3
+ /**
4
+ * A decorator for marking class fields as boolean attributes within the context of a single-table design entity
5
+ *
6
+ * Can be set to nullable via decorator props
7
+ *
8
+ * @template T The class type that the decorator is applied to, ensuring type safety and integration within specific class instances.
9
+ * @template K A type constraint extending `boolean`, ensuring that the decorator is only applied to class fields specifically intended to represent booleans.
10
+ * @param props An {@link AttributeOptions} object providing configuration options for the attribute, such as its `alias` which allows the attribute to be referred to by an alternative name in the database context. The `nullable` property is also set to `false` by default.
11
+ * @returns A class field decorator function that operates within the class field's context. It configures the field as a boolean attribute and defines how it should be serialized and deserialized to/from DynamoDB.
12
+ *
13
+ * Usage example:
14
+ * ```typescript
15
+ * class MyEntity extends MyTable {
16
+ * @BooleanAttribute({ alias: 'MyField' })
17
+ * public myField: boolean;
18
+ *
19
+ * @BooleanAttribute({ alias: 'MyNullableField', nullable: true })
20
+ * public myField?: boolean; // Set to Optional
21
+ * }
22
+ * ```
23
+ *
24
+ * Here, `@BooleanAttribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
25
+ */
26
+ declare function BooleanAttribute<T extends DynaRecord, K extends boolean, P extends AttributeOptions>(props?: P): (_value: undefined, context: AttributeDecoratorContext<T, K, P>) => void;
27
+ export default BooleanAttribute;
28
+ //# sourceMappingURL=BooleanAttribute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BooleanAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/BooleanAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,gBAAgB,CACvB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,gBAAgB,EAC1B,KAAK,CAAC,EAAE,CAAC,YAEC,SAAS,WACR,0BAA0B,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAe9C;AAED,eAAe,gBAAgB,CAAC"}
@@ -3,39 +3,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const zod_1 = require("zod");
6
7
  const metadata_1 = __importDefault(require("../../metadata"));
7
8
  /**
8
- * Similar to '@Attribute' but specific to Dates since Dates are not native types to dynamo
9
+ * A decorator for marking class fields as boolean attributes within the context of a single-table design entity
9
10
  *
10
- * IMPORTANT - For optimal type safety mark the class field property as optional
11
+ * Can be set to nullable via decorator props
11
12
  *
12
13
  * @template T The class type that the decorator is applied to, ensuring type safety and integration within specific class instances.
13
- * @template K A type constraint extending `Date`, ensuring that the decorator is only applied to class fields specifically intended to represent dates.
14
- * @param props An {@link AttributeOptions} object providing configuration options for the attribute, such as its `alias` which allows the attribute to be referred to by an alternative name in the database context. The `nullable` property is also set to `true` by default, indicating that the date attribute can be empty.
15
- * @returns A class field decorator function that operates within the class field's context. It configures the field as a date attribute and defines how it should be serialized and deserialized to/from DynamoDB.
14
+ * @template K A type constraint extending `boolean`, ensuring that the decorator is only applied to class fields specifically intended to represent booleans.
15
+ * @param props An {@link AttributeOptions} object providing configuration options for the attribute, such as its `alias` which allows the attribute to be referred to by an alternative name in the database context. The `nullable` property is also set to `false` by default.
16
+ * @returns A class field decorator function that operates within the class field's context. It configures the field as a boolean attribute and defines how it should be serialized and deserialized to/from DynamoDB.
16
17
  *
17
18
  * Usage example:
18
19
  * ```typescript
19
20
  * class MyEntity extends MyTable {
20
- * @NullableAttribute({ alias: 'MyField' })
21
- * public myField?: string; // Set to Optional
21
+ * @BooleanAttribute({ alias: 'MyField' })
22
+ * public myField: boolean;
23
+ *
24
+ * @BooleanAttribute({ alias: 'MyNullableField', nullable: true })
25
+ * public myField?: boolean; // Set to Optional
22
26
  * }
23
27
  * ```
24
28
  *
25
- * Here, `@Attribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
29
+ * Here, `@BooleanAttribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
26
30
  */
27
- function NullableAttribute(props) {
31
+ function BooleanAttribute(props) {
28
32
  return function (_value, context) {
29
33
  if (context.kind === "field") {
30
34
  context.addInitializer(function () {
31
35
  const entity = Object.getPrototypeOf(this);
32
36
  metadata_1.default.addEntityAttribute(entity.constructor.name, {
33
37
  attributeName: context.name.toString(),
34
- nullable: true,
38
+ nullable: props?.nullable,
39
+ type: zod_1.z.boolean(),
35
40
  ...props
36
41
  });
37
42
  });
38
43
  }
39
44
  };
40
45
  }
41
- exports.default = NullableAttribute;
46
+ exports.default = BooleanAttribute;
@@ -1,13 +1,15 @@
1
1
  import type DynaRecord from "../../DynaRecord";
2
- import type { AttributeOptions } from "../types";
2
+ import type { AttributeDecoratorContext, AttributeOptions } from "../types";
3
3
  /**
4
- * Similar to '@Attribute' but specific to Dates since Dates are not native types to dynamo
4
+ * A decorator for marking class fields as date attributes within the context of a single-table design entity
5
5
  *
6
- * Does not allow property to be optional.
6
+ * Because dates are not natively supported data types in dynamo, they will be converted to iso string's within dynamo, and serialized to date objects on the entity class
7
+ *
8
+ * Can be set to nullable via decorator props
7
9
  *
8
10
  * @template T The class type that the decorator is applied to, ensuring type safety and integration within specific class instances.
9
11
  * @template K A type constraint extending `Date`, ensuring that the decorator is only applied to class fields specifically intended to represent dates.
10
- * @param props An {@link AttributeOptions} object providing configuration options for the attribute, such as its `alias` which allows the attribute to be referred to by an alternative name in the database context. The `nullable` property is also set to `false` by default; the attribute must not be empty.
12
+ * @param props An {@link AttributeOptions} object providing configuration options for the attribute, such as its `alias` which allows the attribute to be referred to by an alternative name in the database context. The `nullable` property is also set to `false` by default.
11
13
  * @returns A class field decorator function that operates within the class field's context. It configures the field as a date attribute and defines how it should be serialized and deserialized to/from DynamoDB.
12
14
  *
13
15
  * Usage example:
@@ -15,11 +17,14 @@ import type { AttributeOptions } from "../types";
15
17
  * class MyEntity extends MyTable {
16
18
  * @DateAttribute({ alias: 'MyField' })
17
19
  * public myField: Date;
20
+ *
21
+ * @DateAttribute({ alias: 'MyNullableField', nullable: true })
22
+ * public myField?: Date; // Set to Optional
18
23
  * }
19
24
  * ```
20
25
  *
21
- * Here, `@Attribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
26
+ * Here, `@DateAttribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
22
27
  */
23
- declare function DateAttribute<T extends DynaRecord, K extends Date>(props?: AttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, K>) => void;
28
+ declare function DateAttribute<T extends DynaRecord, K extends Date, P extends AttributeOptions>(props?: P): (_value: undefined, context: AttributeDecoratorContext<T, K, P>) => void;
24
29
  export default DateAttribute;
25
30
  //# sourceMappingURL=DateAttribute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/DateAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,aAAa,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,IAAI,EACzD,KAAK,CAAC,EAAE,gBAAgB,YAGd,SAAS,WACR,2BAA2B,CAAC,EAAE,CAAC,CAAC,UAe5C;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"DateAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/DateAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,iBAAS,aAAa,CACpB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,IAAI,EACd,CAAC,SAAS,gBAAgB,EAC1B,KAAK,CAAC,EAAE,CAAC,YAEC,SAAS,WACR,0BAA0B,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAgB9C;AAED,eAAe,aAAa,CAAC"}
@@ -3,16 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const zod_1 = require("zod");
6
7
  const metadata_1 = __importDefault(require("../../metadata"));
7
8
  const serializers_1 = require("./serializers");
8
9
  /**
9
- * Similar to '@Attribute' but specific to Dates since Dates are not native types to dynamo
10
+ * A decorator for marking class fields as date attributes within the context of a single-table design entity
10
11
  *
11
- * Does not allow property to be optional.
12
+ * Because dates are not natively supported data types in dynamo, they will be converted to iso string's within dynamo, and serialized to date objects on the entity class
13
+ *
14
+ * Can be set to nullable via decorator props
12
15
  *
13
16
  * @template T The class type that the decorator is applied to, ensuring type safety and integration within specific class instances.
14
17
  * @template K A type constraint extending `Date`, ensuring that the decorator is only applied to class fields specifically intended to represent dates.
15
- * @param props An {@link AttributeOptions} object providing configuration options for the attribute, such as its `alias` which allows the attribute to be referred to by an alternative name in the database context. The `nullable` property is also set to `false` by default; the attribute must not be empty.
18
+ * @param props An {@link AttributeOptions} object providing configuration options for the attribute, such as its `alias` which allows the attribute to be referred to by an alternative name in the database context. The `nullable` property is also set to `false` by default.
16
19
  * @returns A class field decorator function that operates within the class field's context. It configures the field as a date attribute and defines how it should be serialized and deserialized to/from DynamoDB.
17
20
  *
18
21
  * Usage example:
@@ -20,10 +23,13 @@ const serializers_1 = require("./serializers");
20
23
  * class MyEntity extends MyTable {
21
24
  * @DateAttribute({ alias: 'MyField' })
22
25
  * public myField: Date;
26
+ *
27
+ * @DateAttribute({ alias: 'MyNullableField', nullable: true })
28
+ * public myField?: Date; // Set to Optional
23
29
  * }
24
30
  * ```
25
31
  *
26
- * Here, `@Attribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
32
+ * Here, `@DateAttribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
27
33
  */
28
34
  function DateAttribute(props) {
29
35
  return function (_value, context) {
@@ -32,8 +38,9 @@ function DateAttribute(props) {
32
38
  const entity = Object.getPrototypeOf(this);
33
39
  metadata_1.default.addEntityAttribute(entity.constructor.name, {
34
40
  attributeName: context.name.toString(),
35
- nullable: false,
41
+ nullable: props?.nullable,
36
42
  serializers: serializers_1.dateSerializer,
43
+ type: zod_1.z.date(),
37
44
  ...props
38
45
  });
39
46
  });
@@ -1,6 +1,6 @@
1
1
  import type DynaRecord from "../../DynaRecord";
2
- import type { ForeignKey } from "../../types";
3
- import type { AttributeOptions } from "../types";
2
+ import type { ForeignKey, NullableForeignKey } from "../../types";
3
+ import type { AttributeDecoratorContext, 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
  *
@@ -16,15 +16,21 @@ import type { AttributeOptions } from "../types";
16
16
  * ```typescript
17
17
  * class Order extends BaseEntity {
18
18
  * @ForeignKeyAttribute({ alias: 'UserID' })
19
- * public userId: ForeignKey; // Foreign key to the User entity. Cannot be optional. See NullableForeignKeyAttribute otherwise
19
+ * public userId: ForeignKey; // Foreign key to the User entity. Cannot be optional.
20
20
  *
21
21
  * @BelongsTo(() => User, { foreignKey: "userId" })
22
22
  * public readonly user: User; // Cannot be optional
23
+ *
24
+ * @ForeignKeyAttribute({ alias: 'ProfileId', nullable: true })
25
+ * public profileId?: NullableForeignKey; // Set to optional. Nullable foreign key to another entity (e.g., UserProfile)
26
+ *
27
+ * @BelongsTo(() => Profile, { foreignKey: "profileId" })
28
+ * public readonly profile?: Profile; // Set to optional because its linked via a NullableForeignKey
23
29
  * }
24
30
  * ```
25
31
  *
26
32
  * Here, `@ForeignKeyAttribute` decorates `userId` of `Order`, designating it as a foreign key that references the `User` entity. This decoration not only clarifies the nature of the relationship but also empowers the ORM to enforce relational integrity and facilitate entity association operations.
27
33
  */
28
- declare function ForeignKeyAttribute<T extends DynaRecord>(props?: AttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, ForeignKey>) => void;
34
+ declare function ForeignKeyAttribute<T extends DynaRecord, P extends AttributeOptions>(props?: P): (_value: undefined, context: AttributeDecoratorContext<T, P["nullable"] extends true ? NullableForeignKey : ForeignKey, P>) => void;
29
35
  export default ForeignKeyAttribute;
30
36
  //# sourceMappingURL=ForeignKeyAttribute.d.ts.map
@@ -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;;;;;;;;;;;;;;;;;;;;;;;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"}
1
+ {"version":3,"file":"ForeignKeyAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/ForeignKeyAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,iBAAS,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,gBAAgB,EAC3E,KAAK,CAAC,EAAE,CAAC,YAGC,SAAS,WACR,0BACP,CAAC,EACD,CAAC,CAAC,UAAU,CAAC,SAAS,IAAI,GAAG,kBAAkB,GAAG,UAAU,EAC5D,CAAC,CACF,UAeJ;AAED,eAAe,mBAAmB,CAAC"}
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const zod_1 = require("zod");
6
7
  const metadata_1 = __importDefault(require("../../metadata"));
7
8
  /**
8
9
  * 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.
@@ -19,10 +20,16 @@ const metadata_1 = __importDefault(require("../../metadata"));
19
20
  * ```typescript
20
21
  * class Order extends BaseEntity {
21
22
  * @ForeignKeyAttribute({ alias: 'UserID' })
22
- * public userId: ForeignKey; // Foreign key to the User entity. Cannot be optional. See NullableForeignKeyAttribute otherwise
23
+ * public userId: ForeignKey; // Foreign key to the User entity. Cannot be optional.
23
24
  *
24
25
  * @BelongsTo(() => User, { foreignKey: "userId" })
25
26
  * public readonly user: User; // Cannot be optional
27
+ *
28
+ * @ForeignKeyAttribute({ alias: 'ProfileId', nullable: true })
29
+ * public profileId?: NullableForeignKey; // Set to optional. Nullable foreign key to another entity (e.g., UserProfile)
30
+ *
31
+ * @BelongsTo(() => Profile, { foreignKey: "profileId" })
32
+ * public readonly profile?: Profile; // Set to optional because its linked via a NullableForeignKey
26
33
  * }
27
34
  * ```
28
35
  *
@@ -35,7 +42,8 @@ function ForeignKeyAttribute(props) {
35
42
  const entity = Object.getPrototypeOf(this);
36
43
  metadata_1.default.addEntityAttribute(entity.constructor.name, {
37
44
  attributeName: context.name.toString(),
38
- nullable: false,
45
+ nullable: props?.nullable,
46
+ type: zod_1.z.string(),
39
47
  ...props
40
48
  });
41
49
  });
@@ -0,0 +1,28 @@
1
+ import type DynaRecord from "../../DynaRecord";
2
+ import type { AttributeDecoratorContext, AttributeOptions } from "../types";
3
+ /**
4
+ * A decorator for marking class fields as number attributes within the context of a single-table design entity
5
+ *
6
+ * Can be set to nullable via decorator props
7
+ *
8
+ * @template T The class type that the decorator is applied to, ensuring type safety and integration within specific class instances.
9
+ * @template K A type constraint extending `number`, ensuring that the decorator is only applied to class fields specifically intended to represent numbers.
10
+ * @param props An {@link AttributeOptions} object providing configuration options for the attribute, such as its `alias` which allows the attribute to be referred to by an alternative name in the database context. The `nullable` property is also set to `false` by default.
11
+ * @returns A class field decorator function that operates within the class field's context. It configures the field as a number attribute and defines how it should be serialized and deserialized to/from DynamoDB.
12
+ *
13
+ * Usage example:
14
+ * ```typescript
15
+ * class MyEntity extends MyTable {
16
+ * @NumberAttribute({ alias: 'MyField' })
17
+ * public myField: number;
18
+ *
19
+ * @NumberAttribute({ alias: 'MyNullableField', nullable: true })
20
+ * public myField?: number; // Set to Optional
21
+ * }
22
+ * ```
23
+ *
24
+ * Here, `@NumberAttribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
25
+ */
26
+ declare function NumberAttribute<T extends DynaRecord, K extends number, P extends AttributeOptions>(props?: P): (_value: undefined, context: AttributeDecoratorContext<T, K, P>) => void;
27
+ export default NumberAttribute;
28
+ //# sourceMappingURL=NumberAttribute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/NumberAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,eAAe,CACtB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,gBAAgB,EAC1B,KAAK,CAAC,EAAE,CAAC,YAEC,SAAS,WACR,0BAA0B,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAe9C;AAED,eAAe,eAAe,CAAC"}
@@ -3,41 +3,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const zod_1 = require("zod");
6
7
  const metadata_1 = __importDefault(require("../../metadata"));
7
- const serializers_1 = require("./serializers");
8
8
  /**
9
- * Similar to '@Attribute' but specific to Dates since Dates are not native types to dynamo
9
+ * A decorator for marking class fields as number attributes within the context of a single-table design entity
10
10
  *
11
- * IMPORTANT - For optimal type safety mark the class field property as optional
11
+ * Can be set to nullable via decorator props
12
12
  *
13
13
  * @template T The class type that the decorator is applied to, ensuring type safety and integration within specific class instances.
14
- * @template K A type constraint extending `Date`, ensuring that the decorator is only applied to class fields specifically intended to represent dates.
15
- * @param props An {@link AttributeOptions} object providing configuration options for the attribute, such as its `alias` which allows the attribute to be referred to by an alternative name in the database context. The `nullable` property is also set to `false` by default, indicating that the date attribute must not be empty.
16
- * @returns A class field decorator function that operates within the class field's context. It configures the field as a date attribute and defines how it should be serialized and deserialized to/from DynamoDB.
14
+ * @template K A type constraint extending `number`, ensuring that the decorator is only applied to class fields specifically intended to represent numbers.
15
+ * @param props An {@link AttributeOptions} object providing configuration options for the attribute, such as its `alias` which allows the attribute to be referred to by an alternative name in the database context. The `nullable` property is also set to `false` by default.
16
+ * @returns A class field decorator function that operates within the class field's context. It configures the field as a number attribute and defines how it should be serialized and deserialized to/from DynamoDB.
17
17
  *
18
18
  * Usage example:
19
19
  * ```typescript
20
20
  * class MyEntity extends MyTable {
21
- * @DateNullableAttribute({ alias: 'MyField' })
22
- * public myField?: Date; // Set to Optional
21
+ * @NumberAttribute({ alias: 'MyField' })
22
+ * public myField: number;
23
+ *
24
+ * @NumberAttribute({ alias: 'MyNullableField', nullable: true })
25
+ * public myField?: number; // Set to Optional
23
26
  * }
24
27
  * ```
25
28
  *
26
- * Here, `@Attribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
29
+ * Here, `@NumberAttribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
27
30
  */
28
- function DateNullableAttribute(props) {
31
+ function NumberAttribute(props) {
29
32
  return function (_value, context) {
30
33
  if (context.kind === "field") {
31
34
  context.addInitializer(function () {
32
35
  const entity = Object.getPrototypeOf(this);
33
36
  metadata_1.default.addEntityAttribute(entity.constructor.name, {
34
37
  attributeName: context.name.toString(),
35
- nullable: true,
36
- serializers: serializers_1.dateSerializer,
38
+ nullable: props?.nullable,
39
+ type: zod_1.z.number(),
37
40
  ...props
38
41
  });
39
42
  });
40
43
  }
41
44
  };
42
45
  }
43
- exports.default = DateNullableAttribute;
46
+ exports.default = NumberAttribute;
@@ -1,12 +1,12 @@
1
1
  import type DynaRecord from "../../DynaRecord";
2
2
  import { type PartitionKey } from "../../types";
3
- import type { AttributeOptions } from "../types";
3
+ import type { NonNullAttributeOptions } from "../types";
4
4
  /**
5
5
  * A decorator for designating the field for the partition key on the dynamo table.
6
6
  *
7
7
  * @template T The entity to which the decorator is applied.
8
8
  * @template K The type constraint ensuring the field is suitable to be a partition key.
9
- * @param props An optional object of {@link AttributeOptions}, providing additional configuration for the partition key attribute, such as custom metadata.
9
+ * @param props An optional object of {@link NonNullAttributeOptions}, providing additional configuration for the partition key attribute, such as custom metadata.
10
10
  * @returns A class field decorator function that targets and initializes the class's prototype to register the partition key with the ORM's metadata system.
11
11
  *
12
12
  * Usage example:
@@ -19,6 +19,6 @@ import type { AttributeOptions } from "../types";
19
19
  *
20
20
  * In this example, `@PartitionKeyAttribute` decorates the `pk` field of `User`, marking it as the entity's partition key.
21
21
  */
22
- declare function PartitionKeyAttribute<T extends DynaRecord, K extends PartitionKey>(props?: AttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, K>) => void;
22
+ declare function PartitionKeyAttribute<T extends DynaRecord, K extends PartitionKey>(props?: NonNullAttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, K>) => void;
23
23
  export default PartitionKeyAttribute;
24
24
  //# sourceMappingURL=PartitionKeyAttribute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PartitionKeyAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/PartitionKeyAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,qBAAqB,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,YAAY,EACzE,KAAK,CAAC,EAAE,gBAAgB,YAGd,SAAS,WACR,2BAA2B,CAAC,EAAE,CAAC,CAAC,UAa5C;AAED,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"PartitionKeyAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/PartitionKeyAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,qBAAqB,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,YAAY,EACzE,KAAK,CAAC,EAAE,uBAAuB,YAGrB,SAAS,WACR,2BAA2B,CAAC,EAAE,CAAC,CAAC,UAc5C;AAED,eAAe,qBAAqB,CAAC"}
@@ -3,13 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const zod_1 = require("zod");
6
7
  const metadata_1 = __importDefault(require("../../metadata"));
7
8
  /**
8
9
  * A decorator for designating the field for the partition key on the dynamo table.
9
10
  *
10
11
  * @template T The entity to which the decorator is applied.
11
12
  * @template K The type constraint ensuring the field is suitable to be a partition key.
12
- * @param props An optional object of {@link AttributeOptions}, providing additional configuration for the partition key attribute, such as custom metadata.
13
+ * @param props An optional object of {@link NonNullAttributeOptions}, providing additional configuration for the partition key attribute, such as custom metadata.
13
14
  * @returns A class field decorator function that targets and initializes the class's prototype to register the partition key with the ORM's metadata system.
14
15
  *
15
16
  * Usage example:
@@ -29,6 +30,7 @@ function PartitionKeyAttribute(props) {
29
30
  const entity = Object.getPrototypeOf(this);
30
31
  metadata_1.default.addPartitionKeyAttribute(entity, {
31
32
  attributeName: context.name.toString(),
33
+ type: zod_1.z.string(),
32
34
  ...props
33
35
  });
34
36
  });
@@ -1,12 +1,12 @@
1
1
  import type DynaRecord from "../../DynaRecord";
2
2
  import { type SortKey } from "../../types";
3
- import type { AttributeOptions } from "../types";
3
+ import type { NonNullAttributeOptions } from "../types";
4
4
  /**
5
5
  * A decorator for designating the field for the sort key on the dynamo table.
6
6
  *
7
7
  * @template T The entity to which the decorator is applied.
8
8
  * @template K The type constraint ensuring the field is suitable to be a partition key.
9
- * @param props An optional object of {@link AttributeOptions}, providing additional configuration for the sort key attribute, such as custom metadata.
9
+ * @param props An optional object of {@link NonNullAttributeOptions}, providing additional configuration for the sort key attribute, such as custom metadata.
10
10
  * @returns A class field decorator function that targets and initializes the class's prototype to register the sort key with the ORM's metadata system.
11
11
  *
12
12
  * Usage example:
@@ -19,6 +19,6 @@ import type { AttributeOptions } from "../types";
19
19
  *
20
20
  * In this example, `@SortKeyAttribute` decorates the `sk` field of `User`, marking it as the entity's sort key.
21
21
  */
22
- declare function SortKeyAttribute<T extends DynaRecord, K extends SortKey>(props?: AttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, K>) => void;
22
+ declare function SortKeyAttribute<T extends DynaRecord, K extends SortKey>(props?: NonNullAttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, K>) => void;
23
23
  export default SortKeyAttribute;
24
24
  //# sourceMappingURL=SortKeyAttribute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SortKeyAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/SortKeyAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,gBAAgB,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,OAAO,EAC/D,KAAK,CAAC,EAAE,gBAAgB,YAGd,SAAS,WACR,2BAA2B,CAAC,EAAE,CAAC,CAAC,UAa5C;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"SortKeyAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/SortKeyAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,gBAAgB,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,OAAO,EAC/D,KAAK,CAAC,EAAE,uBAAuB,YAGrB,SAAS,WACR,2BAA2B,CAAC,EAAE,CAAC,CAAC,UAc5C;AAED,eAAe,gBAAgB,CAAC"}
@@ -3,13 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const zod_1 = require("zod");
6
7
  const metadata_1 = __importDefault(require("../../metadata"));
7
8
  /**
8
9
  * A decorator for designating the field for the sort key on the dynamo table.
9
10
  *
10
11
  * @template T The entity to which the decorator is applied.
11
12
  * @template K The type constraint ensuring the field is suitable to be a partition key.
12
- * @param props An optional object of {@link AttributeOptions}, providing additional configuration for the sort key attribute, such as custom metadata.
13
+ * @param props An optional object of {@link NonNullAttributeOptions}, providing additional configuration for the sort key attribute, such as custom metadata.
13
14
  * @returns A class field decorator function that targets and initializes the class's prototype to register the sort key with the ORM's metadata system.
14
15
  *
15
16
  * Usage example:
@@ -29,6 +30,7 @@ function SortKeyAttribute(props) {
29
30
  const entity = Object.getPrototypeOf(this);
30
31
  metadata_1.default.addSortKeyAttribute(entity, {
31
32
  attributeName: context.name.toString(),
33
+ type: zod_1.z.string(),
32
34
  ...props
33
35
  });
34
36
  });