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.
Files changed (239) hide show
  1. package/README.md +3 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +17 -0
  5. package/dist/src/DynaRecord.d.ts +216 -0
  6. package/dist/src/DynaRecord.d.ts.map +1 -0
  7. package/dist/src/DynaRecord.js +217 -0
  8. package/dist/src/Logger.d.ts +42 -0
  9. package/dist/src/Logger.d.ts.map +1 -0
  10. package/dist/src/Logger.js +57 -0
  11. package/dist/src/decorators/Entity.d.ts +23 -0
  12. package/dist/src/decorators/Entity.d.ts.map +1 -0
  13. package/dist/src/decorators/Entity.js +32 -0
  14. package/dist/src/decorators/Table.d.ts +22 -0
  15. package/dist/src/decorators/Table.d.ts.map +1 -0
  16. package/dist/src/decorators/Table.js +31 -0
  17. package/dist/src/decorators/attributes/Attribute.d.ts +26 -0
  18. package/dist/src/decorators/attributes/Attribute.d.ts.map +1 -0
  19. package/dist/src/decorators/attributes/Attribute.js +41 -0
  20. package/dist/src/decorators/attributes/DateAttribute.d.ts +25 -0
  21. package/dist/src/decorators/attributes/DateAttribute.d.ts.map +1 -0
  22. package/dist/src/decorators/attributes/DateAttribute.js +43 -0
  23. package/dist/src/decorators/attributes/DateNullableAttribute.d.ts +26 -0
  24. package/dist/src/decorators/attributes/DateNullableAttribute.d.ts.map +1 -0
  25. package/dist/src/decorators/attributes/DateNullableAttribute.js +43 -0
  26. package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts +25 -0
  27. package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts.map +1 -0
  28. package/dist/src/decorators/attributes/ForeignKeyAttribute.js +40 -0
  29. package/dist/src/decorators/attributes/NullableAttribute.d.ts +27 -0
  30. package/dist/src/decorators/attributes/NullableAttribute.d.ts.map +1 -0
  31. package/dist/src/decorators/attributes/NullableAttribute.js +41 -0
  32. package/dist/src/decorators/attributes/NullableForeignKeyAttribute.d.ts +25 -0
  33. package/dist/src/decorators/attributes/NullableForeignKeyAttribute.d.ts.map +1 -0
  34. package/dist/src/decorators/attributes/NullableForeignKeyAttribute.js +40 -0
  35. package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts +24 -0
  36. package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts.map +1 -0
  37. package/dist/src/decorators/attributes/PartitionKeyAttribute.js +38 -0
  38. package/dist/src/decorators/attributes/SortKeyAttribute.d.ts +24 -0
  39. package/dist/src/decorators/attributes/SortKeyAttribute.d.ts.map +1 -0
  40. package/dist/src/decorators/attributes/SortKeyAttribute.js +38 -0
  41. package/dist/src/decorators/attributes/index.d.ts +10 -0
  42. package/dist/src/decorators/attributes/index.d.ts.map +1 -0
  43. package/dist/src/decorators/attributes/index.js +37 -0
  44. package/dist/src/decorators/attributes/serializers.d.ts +13 -0
  45. package/dist/src/decorators/attributes/serializers.d.ts.map +1 -0
  46. package/dist/src/decorators/attributes/serializers.js +19 -0
  47. package/dist/src/decorators/index.d.ts +6 -0
  48. package/dist/src/decorators/index.d.ts.map +1 -0
  49. package/dist/src/decorators/index.js +27 -0
  50. package/dist/src/decorators/relationships/BelongsTo.d.ts +34 -0
  51. package/dist/src/decorators/relationships/BelongsTo.d.ts.map +1 -0
  52. package/dist/src/decorators/relationships/BelongsTo.js +50 -0
  53. package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts +80 -0
  54. package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts.map +1 -0
  55. package/dist/src/decorators/relationships/HasAndBelongsToMany.js +70 -0
  56. package/dist/src/decorators/relationships/HasMany.d.ts +35 -0
  57. package/dist/src/decorators/relationships/HasMany.d.ts.map +1 -0
  58. package/dist/src/decorators/relationships/HasMany.js +48 -0
  59. package/dist/src/decorators/relationships/HasOne.d.ts +35 -0
  60. package/dist/src/decorators/relationships/HasOne.d.ts.map +1 -0
  61. package/dist/src/decorators/relationships/HasOne.js +48 -0
  62. package/dist/src/decorators/relationships/index.d.ts +6 -0
  63. package/dist/src/decorators/relationships/index.d.ts.map +1 -0
  64. package/dist/src/decorators/relationships/index.js +29 -0
  65. package/dist/src/decorators/relationships/types.d.ts +11 -0
  66. package/dist/src/decorators/relationships/types.d.ts.map +1 -0
  67. package/dist/src/decorators/relationships/types.js +2 -0
  68. package/dist/src/decorators/types.d.ts +30 -0
  69. package/dist/src/decorators/types.d.ts.map +1 -0
  70. package/dist/src/decorators/types.js +2 -0
  71. package/dist/src/dynamo-utils/DynamoClient.d.ts +34 -0
  72. package/dist/src/dynamo-utils/DynamoClient.d.ts.map +1 -0
  73. package/dist/src/dynamo-utils/DynamoClient.js +57 -0
  74. package/dist/src/dynamo-utils/TransactGetBuilder.d.ts +18 -0
  75. package/dist/src/dynamo-utils/TransactGetBuilder.d.ts.map +1 -0
  76. package/dist/src/dynamo-utils/TransactGetBuilder.js +32 -0
  77. package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts +46 -0
  78. package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts.map +1 -0
  79. package/dist/src/dynamo-utils/TransactWriteBuilder.js +100 -0
  80. package/dist/src/dynamo-utils/errors.d.ts +13 -0
  81. package/dist/src/dynamo-utils/errors.d.ts.map +1 -0
  82. package/dist/src/dynamo-utils/errors.js +17 -0
  83. package/dist/src/dynamo-utils/index.d.ts +8 -0
  84. package/dist/src/dynamo-utils/index.d.ts.map +1 -0
  85. package/dist/src/dynamo-utils/index.js +30 -0
  86. package/dist/src/dynamo-utils/types.d.ts +52 -0
  87. package/dist/src/dynamo-utils/types.d.ts.map +1 -0
  88. package/dist/src/dynamo-utils/types.js +2 -0
  89. package/dist/src/errors.d.ts +13 -0
  90. package/dist/src/errors.d.ts.map +1 -0
  91. package/dist/src/errors.js +17 -0
  92. package/dist/src/index.d.ts +6 -0
  93. package/dist/src/index.d.ts.map +1 -0
  94. package/dist/src/index.js +24 -0
  95. package/dist/src/metadata/AttributeMetadata.d.ts +22 -0
  96. package/dist/src/metadata/AttributeMetadata.d.ts.map +1 -0
  97. package/dist/src/metadata/AttributeMetadata.js +27 -0
  98. package/dist/src/metadata/EntityMetadata.d.ts +42 -0
  99. package/dist/src/metadata/EntityMetadata.d.ts.map +1 -0
  100. package/dist/src/metadata/EntityMetadata.js +49 -0
  101. package/dist/src/metadata/JoinTableMetadata.d.ts +23 -0
  102. package/dist/src/metadata/JoinTableMetadata.d.ts.map +1 -0
  103. package/dist/src/metadata/JoinTableMetadata.js +22 -0
  104. package/dist/src/metadata/MetadataStorage.d.ts +104 -0
  105. package/dist/src/metadata/MetadataStorage.d.ts.map +1 -0
  106. package/dist/src/metadata/MetadataStorage.js +194 -0
  107. package/dist/src/metadata/TableMetadata.d.ts +53 -0
  108. package/dist/src/metadata/TableMetadata.d.ts.map +1 -0
  109. package/dist/src/metadata/TableMetadata.js +100 -0
  110. package/dist/src/metadata/index.d.ts +13 -0
  111. package/dist/src/metadata/index.d.ts.map +1 -0
  112. package/dist/src/metadata/index.js +34 -0
  113. package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts +18 -0
  114. package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts.map +1 -0
  115. package/dist/src/metadata/relationship-metadata/BelongsToRelationship.js +26 -0
  116. package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts +16 -0
  117. package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts.map +1 -0
  118. package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.js +25 -0
  119. package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts +18 -0
  120. package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts.map +1 -0
  121. package/dist/src/metadata/relationship-metadata/HasManyRelationship.js +26 -0
  122. package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts +17 -0
  123. package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts.map +1 -0
  124. package/dist/src/metadata/relationship-metadata/HasOneRelationship.js +25 -0
  125. package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts +21 -0
  126. package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts.map +1 -0
  127. package/dist/src/metadata/relationship-metadata/RelationshipMetadata.js +18 -0
  128. package/dist/src/metadata/relationship-metadata/index.d.ts +7 -0
  129. package/dist/src/metadata/relationship-metadata/index.d.ts.map +1 -0
  130. package/dist/src/metadata/relationship-metadata/index.js +29 -0
  131. package/dist/src/metadata/relationship-metadata/types.d.ts +16 -0
  132. package/dist/src/metadata/relationship-metadata/types.d.ts.map +1 -0
  133. package/dist/src/metadata/relationship-metadata/types.js +2 -0
  134. package/dist/src/metadata/relationship-metadata/utils.d.ts +3 -0
  135. package/dist/src/metadata/relationship-metadata/utils.d.ts.map +1 -0
  136. package/dist/src/metadata/relationship-metadata/utils.js +25 -0
  137. package/dist/src/metadata/types.d.ts +90 -0
  138. package/dist/src/metadata/types.d.ts.map +1 -0
  139. package/dist/src/metadata/types.js +2 -0
  140. package/dist/src/metadata/utils.d.ts +42 -0
  141. package/dist/src/metadata/utils.d.ts.map +1 -0
  142. package/dist/src/metadata/utils.js +67 -0
  143. package/dist/src/operations/Create/Create.d.ts +39 -0
  144. package/dist/src/operations/Create/Create.d.ts.map +1 -0
  145. package/dist/src/operations/Create/Create.js +84 -0
  146. package/dist/src/operations/Create/index.d.ts +3 -0
  147. package/dist/src/operations/Create/index.d.ts.map +1 -0
  148. package/dist/src/operations/Create/index.js +23 -0
  149. package/dist/src/operations/Create/types.d.ts +7 -0
  150. package/dist/src/operations/Create/types.d.ts.map +1 -0
  151. package/dist/src/operations/Create/types.js +2 -0
  152. package/dist/src/operations/Delete/Delete.d.ts +74 -0
  153. package/dist/src/operations/Delete/Delete.d.ts.map +1 -0
  154. package/dist/src/operations/Delete/Delete.js +207 -0
  155. package/dist/src/operations/Delete/index.d.ts +2 -0
  156. package/dist/src/operations/Delete/index.d.ts.map +1 -0
  157. package/dist/src/operations/Delete/index.js +8 -0
  158. package/dist/src/operations/Delete/types.d.ts +7 -0
  159. package/dist/src/operations/Delete/types.d.ts.map +1 -0
  160. package/dist/src/operations/Delete/types.js +2 -0
  161. package/dist/src/operations/FindById/FindById.d.ts +91 -0
  162. package/dist/src/operations/FindById/FindById.d.ts.map +1 -0
  163. package/dist/src/operations/FindById/FindById.js +244 -0
  164. package/dist/src/operations/FindById/index.d.ts +3 -0
  165. package/dist/src/operations/FindById/index.d.ts.map +1 -0
  166. package/dist/src/operations/FindById/index.js +23 -0
  167. package/dist/src/operations/FindById/types.d.ts +57 -0
  168. package/dist/src/operations/FindById/types.d.ts.map +1 -0
  169. package/dist/src/operations/FindById/types.js +2 -0
  170. package/dist/src/operations/OperationBase.d.ts +37 -0
  171. package/dist/src/operations/OperationBase.d.ts.map +1 -0
  172. package/dist/src/operations/OperationBase.js +44 -0
  173. package/dist/src/operations/Query/Query.d.ts +45 -0
  174. package/dist/src/operations/Query/Query.d.ts.map +1 -0
  175. package/dist/src/operations/Query/Query.js +84 -0
  176. package/dist/src/operations/Query/index.d.ts +3 -0
  177. package/dist/src/operations/Query/index.d.ts.map +1 -0
  178. package/dist/src/operations/Query/index.js +23 -0
  179. package/dist/src/operations/Query/types.d.ts +38 -0
  180. package/dist/src/operations/Query/types.d.ts.map +1 -0
  181. package/dist/src/operations/Query/types.js +2 -0
  182. package/dist/src/operations/Update/Update.d.ts +48 -0
  183. package/dist/src/operations/Update/Update.d.ts.map +1 -0
  184. package/dist/src/operations/Update/Update.js +118 -0
  185. package/dist/src/operations/Update/index.d.ts +3 -0
  186. package/dist/src/operations/Update/index.d.ts.map +1 -0
  187. package/dist/src/operations/Update/index.js +23 -0
  188. package/dist/src/operations/Update/types.d.ts +32 -0
  189. package/dist/src/operations/Update/types.d.ts.map +1 -0
  190. package/dist/src/operations/Update/types.js +2 -0
  191. package/dist/src/operations/index.d.ts +7 -0
  192. package/dist/src/operations/index.d.ts.map +1 -0
  193. package/dist/src/operations/index.js +22 -0
  194. package/dist/src/operations/types.d.ts +59 -0
  195. package/dist/src/operations/types.d.ts.map +1 -0
  196. package/dist/src/operations/types.js +2 -0
  197. package/dist/src/operations/utils/RelationshipTransactions.d.ts +64 -0
  198. package/dist/src/operations/utils/RelationshipTransactions.d.ts.map +1 -0
  199. package/dist/src/operations/utils/RelationshipTransactions.js +125 -0
  200. package/dist/src/operations/utils/expressionBuilder.d.ts +9 -0
  201. package/dist/src/operations/utils/expressionBuilder.d.ts.map +1 -0
  202. package/dist/src/operations/utils/expressionBuilder.js +106 -0
  203. package/dist/src/operations/utils/index.d.ts +5 -0
  204. package/dist/src/operations/utils/index.d.ts.map +1 -0
  205. package/dist/src/operations/utils/index.js +25 -0
  206. package/dist/src/operations/utils/types.d.ts +21 -0
  207. package/dist/src/operations/utils/types.d.ts.map +1 -0
  208. package/dist/src/operations/utils/types.js +2 -0
  209. package/dist/src/operations/utils/utils.d.ts +19 -0
  210. package/dist/src/operations/utils/utils.d.ts.map +1 -0
  211. package/dist/src/operations/utils/utils.js +36 -0
  212. package/dist/src/query-utils/Filters.d.ts +10 -0
  213. package/dist/src/query-utils/Filters.d.ts.map +1 -0
  214. package/dist/src/query-utils/Filters.js +25 -0
  215. package/dist/src/query-utils/QueryBuilder.d.ts +90 -0
  216. package/dist/src/query-utils/QueryBuilder.d.ts.map +1 -0
  217. package/dist/src/query-utils/QueryBuilder.js +213 -0
  218. package/dist/src/query-utils/index.d.ts +3 -0
  219. package/dist/src/query-utils/index.d.ts.map +1 -0
  220. package/dist/src/query-utils/index.js +23 -0
  221. package/dist/src/query-utils/types.d.ts +89 -0
  222. package/dist/src/query-utils/types.d.ts.map +1 -0
  223. package/dist/src/query-utils/types.js +2 -0
  224. package/dist/src/relationships/BelongsToLink.d.ts +50 -0
  225. package/dist/src/relationships/BelongsToLink.d.ts.map +1 -0
  226. package/dist/src/relationships/BelongsToLink.js +57 -0
  227. package/dist/src/relationships/JoinTable.d.ts +68 -0
  228. package/dist/src/relationships/JoinTable.d.ts.map +1 -0
  229. package/dist/src/relationships/JoinTable.js +133 -0
  230. package/dist/src/relationships/index.d.ts +3 -0
  231. package/dist/src/relationships/index.d.ts.map +1 -0
  232. package/dist/src/relationships/index.js +10 -0
  233. package/dist/src/types.d.ts +73 -0
  234. package/dist/src/types.d.ts.map +1 -0
  235. package/dist/src/types.js +2 -0
  236. package/dist/src/utils.d.ts +89 -0
  237. package/dist/src/utils.d.ts.map +1 -0
  238. package/dist/src/utils.js +168 -0
  239. package/package.json +61 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../src/decorators/Table.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,KAAK,CAAC,KAAK,EAAE,oBAAoB,YACf,iBAAiB,WAAW,qBAAqB,UAK3E;AAED,eAAe,KAAK,CAAC"}
@@ -0,0 +1,31 @@
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 metadata_1 = __importDefault(require("../metadata"));
7
+ /**
8
+ * A class decorator for defining and customizing the table metadata associated with an entity class within the ORM system. This decorator enriches the entity with additional metadata, specifying how the entity relates to the underlying database table. By providing custom table options, such as table names or schema definitions, this decorator plays a crucial role in bridging the gap between the ORM's abstract entities and their concrete database representations.
9
+ *
10
+ * IMPORTANT - All entity classes should extend a table
11
+ *
12
+ * @param props The {@link TableMetadataOptions} object containing metadata configuration for the table. This can include options like the table's name, delimiter and default field customizations.
13
+ * @returns A class decorator factory function that takes a target class extending `DynaRecord` and a context object provided by the TypeScript runtime. The decorator function registers the provided metadata options with the ORM's metadata system, ensuring the entity is properly configured and recognized by the ORM.
14
+ *
15
+ * Usage example:
16
+ * ```typescript
17
+ * @Table({ name: 'my-table', delimiter: '"#",' })
18
+ * class MyTable extends DynaRecord {
19
+ * // User entity implementation
20
+ * }
21
+ * ```
22
+ * In this example, the `@Table` decorator is applied to the `User` class, specifying custom table metadata options, including the table name (`users`) and the schema (`public`). These options are registered with the ORM, which then uses them to correctly map the `User` entity to the corresponding table in the database. This mapping is critical for executing ORM operations such as querying, inserting, and updating records in the `users` table.
23
+ */
24
+ function Table(props) {
25
+ return function (target, context) {
26
+ if (context.kind === "class") {
27
+ metadata_1.default.addTable(target.name, props);
28
+ }
29
+ };
30
+ }
31
+ exports.default = Table;
@@ -0,0 +1,26 @@
1
+ import type DynaRecord from "../../DynaRecord";
2
+ import type { AttributeOptions, NotForeignKey } from "../types";
3
+ import { type NativeScalarAttributeValue } from "@aws-sdk/util-dynamodb";
4
+ /**
5
+ * A decorator for marking class fields as attributes within the context of a single-table design entity, with a specific restriction against using foreign key types.
6
+ *
7
+ * IMPORTANT! - This decorator explicitly disallows the use of {@link ForeignKey} and {@link NullableForeignKey} types to maintain clear separation between entity relationships and scalar attributes for improved data integrity and type safety.
8
+ *
9
+ * @template T The entity the decorator is applied to.
10
+ * @template K The type of the attribute, restricted to native scalar attribute values and excluding foreign key types.
11
+ * @param props An optional object of {@link AttributeOptions}, including configuration options such as metadata attributes and additional property characteristics.
12
+ * @returns A class field decorator function that targets and initializes the class's prototype to register the attribute with the ORM's metadata system, ensuring proper handling and validation of the entity's scalar values.
13
+ *
14
+ * Usage example:
15
+ * ```typescript
16
+ * class Product extends BaseEntity {
17
+ * @Attribute({ alias: 'SKU' })
18
+ * public stockKeepingUnit: string; // Simple scalar attribute representing the product's SKU
19
+ * }
20
+ * ```
21
+ *
22
+ * Here, `@Attribute` decorates `stockKeepingUnit` of `Product` as a simple, non-foreign key attribute, facilitating its management within the ORM system.
23
+ */
24
+ declare function Attribute<T extends DynaRecord, K extends NativeScalarAttributeValue>(props?: AttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, NotForeignKey<K>>) => void;
25
+ export default Attribute;
26
+ //# sourceMappingURL=Attribute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Attribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/Attribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,0BAA0B,EAC3E,KAAK,CAAC,EAAE,gBAAgB,YAGd,SAAS,WACR,2BAA2B,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,UAc3D;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,41 @@
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 metadata_1 = __importDefault(require("../../metadata"));
7
+ /**
8
+ * A decorator for marking class fields as attributes within the context of a single-table design entity, with a specific restriction against using foreign key types.
9
+ *
10
+ * IMPORTANT! - This decorator explicitly disallows the use of {@link ForeignKey} and {@link NullableForeignKey} types to maintain clear separation between entity relationships and scalar attributes for improved data integrity and type safety.
11
+ *
12
+ * @template T The entity the decorator is applied to.
13
+ * @template K The type of the attribute, restricted to native scalar attribute values and excluding foreign key types.
14
+ * @param props An optional object of {@link AttributeOptions}, including configuration options such as metadata attributes and additional property characteristics.
15
+ * @returns A class field decorator function that targets and initializes the class's prototype to register the attribute with the ORM's metadata system, ensuring proper handling and validation of the entity's scalar values.
16
+ *
17
+ * Usage example:
18
+ * ```typescript
19
+ * class Product extends BaseEntity {
20
+ * @Attribute({ alias: 'SKU' })
21
+ * public stockKeepingUnit: string; // Simple scalar attribute representing the product's SKU
22
+ * }
23
+ * ```
24
+ *
25
+ * Here, `@Attribute` decorates `stockKeepingUnit` of `Product` as a simple, non-foreign key attribute, facilitating its management within the ORM system.
26
+ */
27
+ function Attribute(props) {
28
+ return function (_value, context) {
29
+ if (context.kind === "field") {
30
+ context.addInitializer(function () {
31
+ const entity = Object.getPrototypeOf(this);
32
+ metadata_1.default.addEntityAttribute(entity.constructor.name, {
33
+ attributeName: context.name.toString(),
34
+ nullable: false,
35
+ ...props
36
+ });
37
+ });
38
+ }
39
+ };
40
+ }
41
+ exports.default = Attribute;
@@ -0,0 +1,25 @@
1
+ import type DynaRecord from "../../DynaRecord";
2
+ import type { AttributeOptions } from "../types";
3
+ /**
4
+ * Similar to '@Attribute' but specific to Dates since Dates are not native types to dynamo
5
+ *
6
+ * Does not allow property to be optional.
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 `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.
11
+ * @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
+ *
13
+ * Usage example:
14
+ * ```typescript
15
+ * class MyEntity extends MyTable {
16
+ * @DateAttribute({ alias: 'MyField' })
17
+ * public myField: Date;
18
+ * }
19
+ * ```
20
+ *
21
+ * Here, `@Attribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
22
+ */
23
+ declare function DateAttribute<T extends DynaRecord, K extends Date>(props?: AttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, K>) => void;
24
+ export default DateAttribute;
25
+ //# sourceMappingURL=DateAttribute.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,43 @@
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 metadata_1 = __importDefault(require("../../metadata"));
7
+ const serializers_1 = require("./serializers");
8
+ /**
9
+ * Similar to '@Attribute' but specific to Dates since Dates are not native types to dynamo
10
+ *
11
+ * Does not allow property to be optional.
12
+ *
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; the 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.
17
+ *
18
+ * Usage example:
19
+ * ```typescript
20
+ * class MyEntity extends MyTable {
21
+ * @DateAttribute({ alias: 'MyField' })
22
+ * public myField: Date;
23
+ * }
24
+ * ```
25
+ *
26
+ * Here, `@Attribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
27
+ */
28
+ function DateAttribute(props) {
29
+ return function (_value, context) {
30
+ if (context.kind === "field") {
31
+ context.addInitializer(function () {
32
+ const entity = Object.getPrototypeOf(this);
33
+ metadata_1.default.addEntityAttribute(entity.constructor.name, {
34
+ attributeName: context.name.toString(),
35
+ nullable: false,
36
+ serializers: serializers_1.dateSerializer,
37
+ ...props
38
+ });
39
+ });
40
+ }
41
+ };
42
+ }
43
+ exports.default = DateAttribute;
@@ -0,0 +1,26 @@
1
+ import type DynaRecord from "../../DynaRecord";
2
+ import type { Optional } from "../../types";
3
+ import type { AttributeOptions } from "../types";
4
+ /**
5
+ * Similar to '@Attribute' but specific to Dates since Dates are not native types to dynamo
6
+ *
7
+ * IMPORTANT - For optimal type safety mark the class field property as optional
8
+ *
9
+ * @template T The class type that the decorator is applied to, ensuring type safety and integration within specific class instances.
10
+ * @template K A type constraint extending `Date`, ensuring that the decorator is only applied to class fields specifically intended to represent dates.
11
+ * @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.
12
+ * @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.
13
+ *
14
+ * Usage example:
15
+ * ```typescript
16
+ * class MyEntity extends MyTable {
17
+ * @DateNullableAttribute({ alias: 'MyField' })
18
+ * public myField?: Date; // Set to Optional
19
+ * }
20
+ * ```
21
+ *
22
+ * Here, `@Attribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
23
+ */
24
+ declare function DateNullableAttribute<T extends DynaRecord, K extends Date>(props?: AttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, Optional<K>>) => void;
25
+ export default DateNullableAttribute;
26
+ //# sourceMappingURL=DateNullableAttribute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateNullableAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/DateNullableAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,qBAAqB,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,IAAI,EACjE,KAAK,CAAC,EAAE,gBAAgB,YAGd,SAAS,WACR,2BAA2B,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,UAetD;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,43 @@
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 metadata_1 = __importDefault(require("../../metadata"));
7
+ const serializers_1 = require("./serializers");
8
+ /**
9
+ * Similar to '@Attribute' but specific to Dates since Dates are not native types to dynamo
10
+ *
11
+ * IMPORTANT - For optimal type safety mark the class field property as optional
12
+ *
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.
17
+ *
18
+ * Usage example:
19
+ * ```typescript
20
+ * class MyEntity extends MyTable {
21
+ * @DateNullableAttribute({ alias: 'MyField' })
22
+ * public myField?: Date; // Set to Optional
23
+ * }
24
+ * ```
25
+ *
26
+ * Here, `@Attribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
27
+ */
28
+ function DateNullableAttribute(props) {
29
+ return function (_value, context) {
30
+ if (context.kind === "field") {
31
+ context.addInitializer(function () {
32
+ const entity = Object.getPrototypeOf(this);
33
+ metadata_1.default.addEntityAttribute(entity.constructor.name, {
34
+ attributeName: context.name.toString(),
35
+ nullable: true,
36
+ serializers: serializers_1.dateSerializer,
37
+ ...props
38
+ });
39
+ });
40
+ }
41
+ };
42
+ }
43
+ exports.default = DateNullableAttribute;
@@ -0,0 +1,25 @@
1
+ import type DynaRecord from "../../DynaRecord";
2
+ import type { ForeignKey } from "../../types";
3
+ import type { AttributeOptions } from "../types";
4
+ /**
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
+ *
7
+ * Does not allow property to be optional.
8
+ *
9
+ * @template T The entity the decorator is applied to.
10
+ * @param props An optional object of {@link AttributeOptions}, including configuration options such as metadata attributes. These options allow for additional customization of the foreign key attribute, including aliasing and metadata tagging.
11
+ * @returns A class field decorator function that targets and initializes the class's prototype to register the foreign key with the ORM's metadata system. This registration is crucial for enabling the ORM to correctly interpret and manage the relationships between entities.
12
+ *
13
+ * Usage example:
14
+ * ```typescript
15
+ * class Order extends BaseEntity {
16
+ * @ForeignKeyAttribute({ alias: 'UserID' })
17
+ * public userId: string; // Foreign key to the User entity
18
+ * }
19
+ * ```
20
+ *
21
+ * 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.
22
+ */
23
+ declare function ForeignKeyAttribute<T extends DynaRecord>(props?: AttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, ForeignKey>) => void;
24
+ export default ForeignKeyAttribute;
25
+ //# sourceMappingURL=ForeignKeyAttribute.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,40 @@
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 metadata_1 = __importDefault(require("../../metadata"));
7
+ /**
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
+ *
10
+ * Does not allow property to be optional.
11
+ *
12
+ * @template T The entity the decorator is applied to.
13
+ * @param props An optional object of {@link AttributeOptions}, including configuration options such as metadata attributes. These options allow for additional customization of the foreign key attribute, including aliasing and metadata tagging.
14
+ * @returns A class field decorator function that targets and initializes the class's prototype to register the foreign key with the ORM's metadata system. This registration is crucial for enabling the ORM to correctly interpret and manage the relationships between entities.
15
+ *
16
+ * Usage example:
17
+ * ```typescript
18
+ * class Order extends BaseEntity {
19
+ * @ForeignKeyAttribute({ alias: 'UserID' })
20
+ * public userId: string; // Foreign key to the User entity
21
+ * }
22
+ * ```
23
+ *
24
+ * 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.
25
+ */
26
+ function ForeignKeyAttribute(props) {
27
+ return function (_value, context) {
28
+ if (context.kind === "field") {
29
+ context.addInitializer(function () {
30
+ const entity = Object.getPrototypeOf(this);
31
+ metadata_1.default.addEntityAttribute(entity.constructor.name, {
32
+ attributeName: context.name.toString(),
33
+ nullable: false,
34
+ ...props
35
+ });
36
+ });
37
+ }
38
+ };
39
+ }
40
+ exports.default = ForeignKeyAttribute;
@@ -0,0 +1,27 @@
1
+ import type DynaRecord from "../../DynaRecord";
2
+ import { type Optional } from "../../types";
3
+ import type { AttributeOptions, NotForeignKey } from "../types";
4
+ import { type NativeScalarAttributeValue } from "@aws-sdk/util-dynamodb";
5
+ /**
6
+ * Similar to '@Attribute' but specific to Dates since Dates are not native types to dynamo
7
+ *
8
+ * IMPORTANT - For optimal type safety mark the class field property as optional
9
+ *
10
+ * @template T The class type that the decorator is applied to, ensuring type safety and integration within specific class instances.
11
+ * @template K A type constraint extending `Date`, ensuring that the decorator is only applied to class fields specifically intended to represent dates.
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 `true` by default, indicating that the date attribute can be empty.
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.
14
+ *
15
+ * Usage example:
16
+ * ```typescript
17
+ * class MyEntity extends MyTable {
18
+ * @NullableAttribute({ alias: 'MyField' })
19
+ * public myField?: string; // Set to Optional
20
+ * }
21
+ * ```
22
+ *
23
+ * Here, `@Attribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
24
+ */
25
+ declare function NullableAttribute<T extends DynaRecord, K extends NativeScalarAttributeValue>(props?: AttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, Optional<NotForeignKey<K>>>) => void;
26
+ export default NullableAttribute;
27
+ //# sourceMappingURL=NullableAttribute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NullableAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/NullableAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,iBAAiB,CACxB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,0BAA0B,EACpC,KAAK,CAAC,EAAE,gBAAgB,YAEd,SAAS,WACR,2BAA2B,CAAC,EAAE,SAAS,cAAc,CAAC,CAAC,CAAC,CAAC,UAcrE;AAED,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,41 @@
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 metadata_1 = __importDefault(require("../../metadata"));
7
+ /**
8
+ * Similar to '@Attribute' but specific to Dates since Dates are not native types to dynamo
9
+ *
10
+ * IMPORTANT - For optimal type safety mark the class field property as optional
11
+ *
12
+ * @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.
16
+ *
17
+ * Usage example:
18
+ * ```typescript
19
+ * class MyEntity extends MyTable {
20
+ * @NullableAttribute({ alias: 'MyField' })
21
+ * public myField?: string; // Set to Optional
22
+ * }
23
+ * ```
24
+ *
25
+ * Here, `@Attribute` decorates `myField` of `MyEntity`, marking it as an entity attribute with an alias 'MyField' for ORM purposes.
26
+ */
27
+ function NullableAttribute(props) {
28
+ return function (_value, context) {
29
+ if (context.kind === "field") {
30
+ context.addInitializer(function () {
31
+ const entity = Object.getPrototypeOf(this);
32
+ metadata_1.default.addEntityAttribute(entity.constructor.name, {
33
+ attributeName: context.name.toString(),
34
+ nullable: true,
35
+ ...props
36
+ });
37
+ });
38
+ }
39
+ };
40
+ }
41
+ exports.default = NullableAttribute;
@@ -0,0 +1,25 @@
1
+ import type DynaRecord from "../../DynaRecord";
2
+ import type { NullableForeignKey } from "../../types";
3
+ import type { AttributeOptions } from "../types";
4
+ /**
5
+ * A decorator for annotating class fields as nullable foreign keys within the context of a single-table design entity. This decorator is specifically designed for attributes that represent nullable foreign keys, facilitating the representation and management of relationships between entities.
6
+ *
7
+ * IMPORTANT - For optimal type safety mark the class field property as optional
8
+ *
9
+ * @template T The entity the decorator is applied to.
10
+ * @param props An optional object of {@link AttributeOptions}, including configuration options such as metadata attributes.
11
+ * @returns A class field decorator function that targets and initializes the class's prototype to register the field with the ORM's metadata system.
12
+ *
13
+ * Usage example:
14
+ * ```typescript
15
+ * class User extends BaseEntity {
16
+ * @NullableForeignKeyAttribute({ alias: 'ProfileId' })
17
+ * public profileId?: string; // Set to optional. Nullable foreign key to another entity (e.g., UserProfile)
18
+ * }
19
+ * ```
20
+ *
21
+ * Here, `@NullableForeignKeyAttribute` decorates `profileId` of `User`, indicating it as a nullable foreign key.
22
+ */
23
+ declare function NullableForeignKeyAttribute<T extends DynaRecord>(props?: AttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, NullableForeignKey>) => void;
24
+ export default NullableForeignKeyAttribute;
25
+ //# sourceMappingURL=NullableForeignKeyAttribute.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,40 @@
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 metadata_1 = __importDefault(require("../../metadata"));
7
+ /**
8
+ * A decorator for annotating class fields as nullable foreign keys within the context of a single-table design entity. This decorator is specifically designed for attributes that represent nullable foreign keys, facilitating the representation and management of relationships between entities.
9
+ *
10
+ * IMPORTANT - For optimal type safety mark the class field property as optional
11
+ *
12
+ * @template T The entity the decorator is applied to.
13
+ * @param props An optional object of {@link AttributeOptions}, including configuration options such as metadata attributes.
14
+ * @returns A class field decorator function that targets and initializes the class's prototype to register the field with the ORM's metadata system.
15
+ *
16
+ * Usage example:
17
+ * ```typescript
18
+ * class User extends BaseEntity {
19
+ * @NullableForeignKeyAttribute({ alias: 'ProfileId' })
20
+ * public profileId?: string; // Set to optional. Nullable foreign key to another entity (e.g., UserProfile)
21
+ * }
22
+ * ```
23
+ *
24
+ * Here, `@NullableForeignKeyAttribute` decorates `profileId` of `User`, indicating it as a nullable foreign key.
25
+ */
26
+ function NullableForeignKeyAttribute(props) {
27
+ return function (_value, context) {
28
+ if (context.kind === "field") {
29
+ context.addInitializer(function () {
30
+ const entity = Object.getPrototypeOf(this);
31
+ metadata_1.default.addEntityAttribute(entity.constructor.name, {
32
+ attributeName: context.name.toString(),
33
+ nullable: true,
34
+ ...props
35
+ });
36
+ });
37
+ }
38
+ };
39
+ }
40
+ exports.default = NullableForeignKeyAttribute;
@@ -0,0 +1,24 @@
1
+ import type DynaRecord from "../../DynaRecord";
2
+ import { type PartitionKey } from "../../types";
3
+ import type { AttributeOptions } from "../types";
4
+ /**
5
+ * A decorator for designating the field for the partition key on the dynamo table.
6
+ *
7
+ * @template T The entity to which the decorator is applied.
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.
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
+ *
12
+ * Usage example:
13
+ * ```typescript
14
+ * class User extends BaseEntity {
15
+ * @PartitionKeyAttribute()
16
+ * public pk: PartitionKey;
17
+ * }
18
+ * ```
19
+ *
20
+ * In this example, `@PartitionKeyAttribute` decorates the `pk` field of `User`, marking it as the entity's partition key.
21
+ */
22
+ declare function PartitionKeyAttribute<T extends DynaRecord, K extends PartitionKey>(props?: AttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, K>) => void;
23
+ export default PartitionKeyAttribute;
24
+ //# sourceMappingURL=PartitionKeyAttribute.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,38 @@
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 metadata_1 = __importDefault(require("../../metadata"));
7
+ /**
8
+ * A decorator for designating the field for the partition key on the dynamo table.
9
+ *
10
+ * @template T The entity to which the decorator is applied.
11
+ * @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
+ * @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
+ * Usage example:
16
+ * ```typescript
17
+ * class User extends BaseEntity {
18
+ * @PartitionKeyAttribute()
19
+ * public pk: PartitionKey;
20
+ * }
21
+ * ```
22
+ *
23
+ * In this example, `@PartitionKeyAttribute` decorates the `pk` field of `User`, marking it as the entity's partition key.
24
+ */
25
+ function PartitionKeyAttribute(props) {
26
+ return function (_value, context) {
27
+ if (context.kind === "field") {
28
+ context.addInitializer(function () {
29
+ const entity = Object.getPrototypeOf(this);
30
+ metadata_1.default.addPartitionKeyAttribute(entity, {
31
+ attributeName: context.name.toString(),
32
+ ...props
33
+ });
34
+ });
35
+ }
36
+ };
37
+ }
38
+ exports.default = PartitionKeyAttribute;
@@ -0,0 +1,24 @@
1
+ import type DynaRecord from "../../DynaRecord";
2
+ import { type SortKey } from "../../types";
3
+ import type { AttributeOptions } from "../types";
4
+ /**
5
+ * A decorator for designating the field for the sort key on the dynamo table.
6
+ *
7
+ * @template T The entity to which the decorator is applied.
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.
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
+ *
12
+ * Usage example:
13
+ * ```typescript
14
+ * class User extends BaseEntity {
15
+ * @SortKeyAttribute()
16
+ * public sk: SortKey;
17
+ * }
18
+ * ```
19
+ *
20
+ * In this example, `@SortKeyAttribute` decorates the `sk` field of `User`, marking it as the entity's sort key.
21
+ */
22
+ declare function SortKeyAttribute<T extends DynaRecord, K extends SortKey>(props?: AttributeOptions): (_value: undefined, context: ClassFieldDecoratorContext<T, K>) => void;
23
+ export default SortKeyAttribute;
24
+ //# sourceMappingURL=SortKeyAttribute.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,38 @@
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 metadata_1 = __importDefault(require("../../metadata"));
7
+ /**
8
+ * A decorator for designating the field for the sort key on the dynamo table.
9
+ *
10
+ * @template T The entity to which the decorator is applied.
11
+ * @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
+ * @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
+ * Usage example:
16
+ * ```typescript
17
+ * class User extends BaseEntity {
18
+ * @SortKeyAttribute()
19
+ * public sk: SortKey;
20
+ * }
21
+ * ```
22
+ *
23
+ * In this example, `@SortKeyAttribute` decorates the `sk` field of `User`, marking it as the entity's sort key.
24
+ */
25
+ function SortKeyAttribute(props) {
26
+ return function (_value, context) {
27
+ if (context.kind === "field") {
28
+ context.addInitializer(function () {
29
+ const entity = Object.getPrototypeOf(this);
30
+ metadata_1.default.addSortKeyAttribute(entity, {
31
+ attributeName: context.name.toString(),
32
+ ...props
33
+ });
34
+ });
35
+ }
36
+ };
37
+ }
38
+ exports.default = SortKeyAttribute;
@@ -0,0 +1,10 @@
1
+ export { default as Attribute } from "./Attribute";
2
+ export { default as NullableAttribute } from "./NullableAttribute";
3
+ export { default as PartitionKeyAttribute } from "./PartitionKeyAttribute";
4
+ export { default as SortKeyAttribute } from "./SortKeyAttribute";
5
+ export { default as ForeignKeyAttribute } from "./ForeignKeyAttribute";
6
+ export { default as NullableForeignKeyAttribute } from "./NullableForeignKeyAttribute";
7
+ export { default as DateAttribute } from "./DateAttribute";
8
+ export { default as DateNullableAttribute } from "./DateNullableAttribute";
9
+ export * from "./serializers";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,cAAc,eAAe,CAAC"}