dyna-record 0.6.6 → 0.7.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 (244) hide show
  1. package/README.md +23 -7
  2. package/dist/index.d.ts +12 -2
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +13 -22
  5. package/dist/src/DynaRecord.d.ts +3 -3
  6. package/dist/src/DynaRecord.d.ts.map +1 -1
  7. package/dist/src/DynaRecord.js +24 -59
  8. package/dist/src/Logger.js +1 -3
  9. package/dist/src/decorators/Entity.d.ts +1 -1
  10. package/dist/src/decorators/Entity.d.ts.map +1 -1
  11. package/dist/src/decorators/Entity.js +3 -8
  12. package/dist/src/decorators/Table.d.ts +2 -2
  13. package/dist/src/decorators/Table.d.ts.map +1 -1
  14. package/dist/src/decorators/Table.js +3 -8
  15. package/dist/src/decorators/attributes/BooleanAttribute.d.ts +2 -2
  16. package/dist/src/decorators/attributes/BooleanAttribute.d.ts.map +1 -1
  17. package/dist/src/decorators/attributes/BooleanAttribute.js +6 -10
  18. package/dist/src/decorators/attributes/DateAttribute.d.ts +2 -2
  19. package/dist/src/decorators/attributes/DateAttribute.d.ts.map +1 -1
  20. package/dist/src/decorators/attributes/DateAttribute.js +8 -12
  21. package/dist/src/decorators/attributes/EnumAttribute.d.ts +2 -2
  22. package/dist/src/decorators/attributes/EnumAttribute.d.ts.map +1 -1
  23. package/dist/src/decorators/attributes/EnumAttribute.js +7 -10
  24. package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts +3 -3
  25. package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts.map +1 -1
  26. package/dist/src/decorators/attributes/ForeignKeyAttribute.js +6 -10
  27. package/dist/src/decorators/attributes/IdAttribute.d.ts +1 -1
  28. package/dist/src/decorators/attributes/IdAttribute.d.ts.map +1 -1
  29. package/dist/src/decorators/attributes/IdAttribute.js +3 -8
  30. package/dist/src/decorators/attributes/NumberAttribute.d.ts +2 -2
  31. package/dist/src/decorators/attributes/NumberAttribute.d.ts.map +1 -1
  32. package/dist/src/decorators/attributes/NumberAttribute.js +6 -10
  33. package/dist/src/decorators/attributes/ObjectAttribute.d.ts +3 -3
  34. package/dist/src/decorators/attributes/ObjectAttribute.d.ts.map +1 -1
  35. package/dist/src/decorators/attributes/ObjectAttribute.js +17 -21
  36. package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts +3 -3
  37. package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts.map +1 -1
  38. package/dist/src/decorators/attributes/PartitionKeyAttribute.js +6 -10
  39. package/dist/src/decorators/attributes/SortKeyAttribute.d.ts +3 -3
  40. package/dist/src/decorators/attributes/SortKeyAttribute.d.ts.map +1 -1
  41. package/dist/src/decorators/attributes/SortKeyAttribute.js +6 -10
  42. package/dist/src/decorators/attributes/StringAttribute.d.ts +2 -2
  43. package/dist/src/decorators/attributes/StringAttribute.d.ts.map +1 -1
  44. package/dist/src/decorators/attributes/StringAttribute.js +6 -10
  45. package/dist/src/decorators/attributes/index.d.ts +13 -13
  46. package/dist/src/decorators/attributes/index.d.ts.map +1 -1
  47. package/dist/src/decorators/attributes/index.js +11 -41
  48. package/dist/src/decorators/attributes/serializers.d.ts +2 -2
  49. package/dist/src/decorators/attributes/serializers.d.ts.map +1 -1
  50. package/dist/src/decorators/attributes/serializers.js +5 -12
  51. package/dist/src/decorators/attributes/types.js +1 -2
  52. package/dist/src/decorators/index.d.ts +5 -5
  53. package/dist/src/decorators/index.d.ts.map +1 -1
  54. package/dist/src/decorators/index.js +5 -27
  55. package/dist/src/decorators/relationships/BelongsTo.d.ts +4 -4
  56. package/dist/src/decorators/relationships/BelongsTo.d.ts.map +1 -1
  57. package/dist/src/decorators/relationships/BelongsTo.js +3 -8
  58. package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts +3 -3
  59. package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts.map +1 -1
  60. package/dist/src/decorators/relationships/HasAndBelongsToMany.js +4 -9
  61. package/dist/src/decorators/relationships/HasMany.d.ts +3 -3
  62. package/dist/src/decorators/relationships/HasMany.d.ts.map +1 -1
  63. package/dist/src/decorators/relationships/HasMany.js +4 -9
  64. package/dist/src/decorators/relationships/HasOne.d.ts +3 -3
  65. package/dist/src/decorators/relationships/HasOne.d.ts.map +1 -1
  66. package/dist/src/decorators/relationships/HasOne.js +3 -8
  67. package/dist/src/decorators/relationships/index.d.ts +5 -5
  68. package/dist/src/decorators/relationships/index.d.ts.map +1 -1
  69. package/dist/src/decorators/relationships/index.js +5 -29
  70. package/dist/src/decorators/relationships/types.d.ts +3 -3
  71. package/dist/src/decorators/relationships/types.d.ts.map +1 -1
  72. package/dist/src/decorators/relationships/types.js +1 -2
  73. package/dist/src/decorators/types.d.ts +3 -3
  74. package/dist/src/decorators/types.d.ts.map +1 -1
  75. package/dist/src/decorators/types.js +1 -2
  76. package/dist/src/dynamo-utils/DynamoClient.d.ts +1 -1
  77. package/dist/src/dynamo-utils/DynamoClient.d.ts.map +1 -1
  78. package/dist/src/dynamo-utils/DynamoClient.js +13 -18
  79. package/dist/src/dynamo-utils/TransactGetBuilder.d.ts +1 -1
  80. package/dist/src/dynamo-utils/TransactGetBuilder.d.ts.map +1 -1
  81. package/dist/src/dynamo-utils/TransactGetBuilder.js +5 -10
  82. package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts +1 -1
  83. package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts.map +1 -1
  84. package/dist/src/dynamo-utils/TransactWriteBuilder.js +11 -16
  85. package/dist/src/dynamo-utils/errors.js +2 -7
  86. package/dist/src/dynamo-utils/index.d.ts +7 -7
  87. package/dist/src/dynamo-utils/index.d.ts.map +1 -1
  88. package/dist/src/dynamo-utils/index.js +7 -30
  89. package/dist/src/dynamo-utils/types.js +1 -2
  90. package/dist/src/errors.js +3 -9
  91. package/dist/src/id.d.ts +12 -0
  92. package/dist/src/id.d.ts.map +1 -0
  93. package/dist/src/id.js +11 -0
  94. package/dist/src/index.d.ts +8 -6
  95. package/dist/src/index.d.ts.map +1 -1
  96. package/dist/src/index.js +4 -20
  97. package/dist/src/metadata/AttributeMetadata.d.ts +6 -4
  98. package/dist/src/metadata/AttributeMetadata.d.ts.map +1 -1
  99. package/dist/src/metadata/AttributeMetadata.js +5 -3
  100. package/dist/src/metadata/EntityMetadata.d.ts +3 -3
  101. package/dist/src/metadata/EntityMetadata.d.ts.map +1 -1
  102. package/dist/src/metadata/EntityMetadata.js +18 -23
  103. package/dist/src/metadata/JoinTableMetadata.d.ts +3 -3
  104. package/dist/src/metadata/JoinTableMetadata.d.ts.map +1 -1
  105. package/dist/src/metadata/JoinTableMetadata.js +1 -3
  106. package/dist/src/metadata/MetadataStorage.d.ts +7 -7
  107. package/dist/src/metadata/MetadataStorage.d.ts.map +1 -1
  108. package/dist/src/metadata/MetadataStorage.js +12 -17
  109. package/dist/src/metadata/TableMetadata.d.ts +3 -3
  110. package/dist/src/metadata/TableMetadata.d.ts.map +1 -1
  111. package/dist/src/metadata/TableMetadata.js +22 -21
  112. package/dist/src/metadata/index.d.ts +9 -9
  113. package/dist/src/metadata/index.d.ts.map +1 -1
  114. package/dist/src/metadata/index.js +11 -34
  115. package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts +2 -2
  116. package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts.map +1 -1
  117. package/dist/src/metadata/relationship-metadata/BelongsToRelationship.js +3 -8
  118. package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts +1 -1
  119. package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts.map +1 -1
  120. package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.js +3 -8
  121. package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts +2 -2
  122. package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts.map +1 -1
  123. package/dist/src/metadata/relationship-metadata/HasManyRelationship.js +3 -8
  124. package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts +2 -2
  125. package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts.map +1 -1
  126. package/dist/src/metadata/relationship-metadata/HasOneRelationship.js +3 -8
  127. package/dist/src/metadata/relationship-metadata/OwnedByRelationship.d.ts +2 -2
  128. package/dist/src/metadata/relationship-metadata/OwnedByRelationship.d.ts.map +1 -1
  129. package/dist/src/metadata/relationship-metadata/OwnedByRelationship.js +3 -8
  130. package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts +2 -2
  131. package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts.map +1 -1
  132. package/dist/src/metadata/relationship-metadata/RelationshipMetadata.js +1 -3
  133. package/dist/src/metadata/relationship-metadata/index.d.ts +6 -6
  134. package/dist/src/metadata/relationship-metadata/index.d.ts.map +1 -1
  135. package/dist/src/metadata/relationship-metadata/index.js +7 -31
  136. package/dist/src/metadata/relationship-metadata/types.d.ts +5 -5
  137. package/dist/src/metadata/relationship-metadata/types.d.ts.map +1 -1
  138. package/dist/src/metadata/relationship-metadata/types.js +1 -2
  139. package/dist/src/metadata/relationship-metadata/utils.d.ts +1 -1
  140. package/dist/src/metadata/relationship-metadata/utils.d.ts.map +1 -1
  141. package/dist/src/metadata/relationship-metadata/utils.js +11 -18
  142. package/dist/src/metadata/schemas.d.ts +523 -36
  143. package/dist/src/metadata/schemas.d.ts.map +1 -1
  144. package/dist/src/metadata/schemas.js +71 -44
  145. package/dist/src/metadata/types.d.ts +17 -4
  146. package/dist/src/metadata/types.d.ts.map +1 -1
  147. package/dist/src/metadata/types.js +1 -2
  148. package/dist/src/metadata/utils.d.ts +5 -5
  149. package/dist/src/metadata/utils.d.ts.map +1 -1
  150. package/dist/src/metadata/utils.js +14 -29
  151. package/dist/src/operations/Create/Create.d.ts +5 -5
  152. package/dist/src/operations/Create/Create.d.ts.map +1 -1
  153. package/dist/src/operations/Create/Create.js +18 -23
  154. package/dist/src/operations/Create/index.d.ts +2 -2
  155. package/dist/src/operations/Create/index.d.ts.map +1 -1
  156. package/dist/src/operations/Create/index.js +2 -23
  157. package/dist/src/operations/Create/types.d.ts +2 -2
  158. package/dist/src/operations/Create/types.d.ts.map +1 -1
  159. package/dist/src/operations/Create/types.js +1 -2
  160. package/dist/src/operations/Delete/Delete.d.ts +3 -3
  161. package/dist/src/operations/Delete/Delete.d.ts.map +1 -1
  162. package/dist/src/operations/Delete/Delete.js +28 -33
  163. package/dist/src/operations/Delete/index.d.ts +1 -1
  164. package/dist/src/operations/Delete/index.d.ts.map +1 -1
  165. package/dist/src/operations/Delete/index.js +1 -8
  166. package/dist/src/operations/Delete/types.js +1 -2
  167. package/dist/src/operations/FindById/FindById.d.ts +4 -4
  168. package/dist/src/operations/FindById/FindById.d.ts.map +1 -1
  169. package/dist/src/operations/FindById/FindById.js +17 -22
  170. package/dist/src/operations/FindById/index.d.ts +2 -2
  171. package/dist/src/operations/FindById/index.d.ts.map +1 -1
  172. package/dist/src/operations/FindById/index.js +2 -23
  173. package/dist/src/operations/FindById/types.d.ts +3 -3
  174. package/dist/src/operations/FindById/types.d.ts.map +1 -1
  175. package/dist/src/operations/FindById/types.js +1 -2
  176. package/dist/src/operations/OperationBase.d.ts +3 -3
  177. package/dist/src/operations/OperationBase.d.ts.map +1 -1
  178. package/dist/src/operations/OperationBase.js +4 -9
  179. package/dist/src/operations/Query/Query.d.ts +4 -4
  180. package/dist/src/operations/Query/Query.d.ts.map +1 -1
  181. package/dist/src/operations/Query/Query.js +15 -20
  182. package/dist/src/operations/Query/index.d.ts +2 -2
  183. package/dist/src/operations/Query/index.d.ts.map +1 -1
  184. package/dist/src/operations/Query/index.js +2 -23
  185. package/dist/src/operations/Query/types.d.ts +4 -4
  186. package/dist/src/operations/Query/types.d.ts.map +1 -1
  187. package/dist/src/operations/Query/types.js +1 -2
  188. package/dist/src/operations/Update/Update.d.ts +5 -5
  189. package/dist/src/operations/Update/Update.d.ts.map +1 -1
  190. package/dist/src/operations/Update/Update.js +37 -42
  191. package/dist/src/operations/Update/UpdateDryRun.d.ts +2 -2
  192. package/dist/src/operations/Update/UpdateDryRun.d.ts.map +1 -1
  193. package/dist/src/operations/Update/UpdateDryRun.js +3 -8
  194. package/dist/src/operations/Update/index.d.ts +3 -3
  195. package/dist/src/operations/Update/index.d.ts.map +1 -1
  196. package/dist/src/operations/Update/index.js +3 -25
  197. package/dist/src/operations/Update/types.d.ts +2 -2
  198. package/dist/src/operations/Update/types.d.ts.map +1 -1
  199. package/dist/src/operations/Update/types.js +1 -2
  200. package/dist/src/operations/index.d.ts +6 -6
  201. package/dist/src/operations/index.d.ts.map +1 -1
  202. package/dist/src/operations/index.js +6 -22
  203. package/dist/src/operations/types.d.ts +3 -3
  204. package/dist/src/operations/types.d.ts.map +1 -1
  205. package/dist/src/operations/types.js +1 -2
  206. package/dist/src/operations/utils/expressionBuilder.d.ts +2 -2
  207. package/dist/src/operations/utils/expressionBuilder.d.ts.map +1 -1
  208. package/dist/src/operations/utils/expressionBuilder.js +1 -5
  209. package/dist/src/operations/utils/flattenObjectForUpdate.d.ts +2 -2
  210. package/dist/src/operations/utils/flattenObjectForUpdate.d.ts.map +1 -1
  211. package/dist/src/operations/utils/flattenObjectForUpdate.js +3 -6
  212. package/dist/src/operations/utils/index.d.ts +5 -5
  213. package/dist/src/operations/utils/index.d.ts.map +1 -1
  214. package/dist/src/operations/utils/index.js +5 -21
  215. package/dist/src/operations/utils/mergePartialObjectAttributes.d.ts +1 -1
  216. package/dist/src/operations/utils/mergePartialObjectAttributes.d.ts.map +1 -1
  217. package/dist/src/operations/utils/mergePartialObjectAttributes.js +1 -4
  218. package/dist/src/operations/utils/types.js +1 -2
  219. package/dist/src/operations/utils/utils.d.ts +4 -4
  220. package/dist/src/operations/utils/utils.d.ts.map +1 -1
  221. package/dist/src/operations/utils/utils.js +13 -23
  222. package/dist/src/query-utils/Filters.d.ts +2 -2
  223. package/dist/src/query-utils/Filters.d.ts.map +1 -1
  224. package/dist/src/query-utils/Filters.js +1 -4
  225. package/dist/src/query-utils/QueryBuilder.d.ts +1 -1
  226. package/dist/src/query-utils/QueryBuilder.d.ts.map +1 -1
  227. package/dist/src/query-utils/QueryBuilder.js +8 -13
  228. package/dist/src/query-utils/index.d.ts +2 -2
  229. package/dist/src/query-utils/index.d.ts.map +1 -1
  230. package/dist/src/query-utils/index.js +2 -23
  231. package/dist/src/query-utils/types.js +1 -2
  232. package/dist/src/relationships/JoinTable.d.ts +2 -2
  233. package/dist/src/relationships/JoinTable.d.ts.map +1 -1
  234. package/dist/src/relationships/JoinTable.js +14 -19
  235. package/dist/src/relationships/index.d.ts +1 -1
  236. package/dist/src/relationships/index.d.ts.map +1 -1
  237. package/dist/src/relationships/index.js +1 -8
  238. package/dist/src/types.d.ts +2 -2
  239. package/dist/src/types.d.ts.map +1 -1
  240. package/dist/src/types.js +1 -2
  241. package/dist/src/utils.d.ts +3 -3
  242. package/dist/src/utils.d.ts.map +1 -1
  243. package/dist/src/utils.js +16 -31
  244. package/package.json +28 -24
package/README.md CHANGED
@@ -33,18 +33,34 @@ Note: ACID compliant according to DynamoDB [limitations](https://docs.aws.amazon
33
33
 
34
34
  ### Installation
35
35
 
36
- To install Dyna-Record, use npm or yarn:
36
+ Requires Node.js `>=22` and TypeScript `>=6`.
37
37
 
38
38
  ```bash
39
39
  npm install dyna-record
40
+ # or
41
+ yarn add dyna-record
42
+ # or
43
+ pnpm add dyna-record
40
44
  ```
41
45
 
42
- or
46
+ dyna-record is **ESM-only** as of 0.7.0:
43
47
 
44
- ```bash
45
- yarn add dyna-record
48
+ ```ts
49
+ // ESM
50
+ import DynaRecord, { Entity, Table } from "dyna-record";
51
+ ```
52
+
53
+ If your project is still on CommonJS, use a dynamic import:
54
+
55
+ ```js
56
+ // CommonJS (any modern Node) via dynamic import
57
+ const { default: DynaRecord, Entity, Table } = await import("dyna-record");
46
58
  ```
47
59
 
60
+ Direct `require("dyna-record")` only works on Node 22.12+ via Node's stabilized `require(esm)` and is not an officially supported contract — prefer dynamic `import()` for portability.
61
+
62
+ > dyna-record uses **TC39 Stage 3 decorators** (the TypeScript 5+/6 default). Do **not** enable `experimentalDecorators` in your `tsconfig.json`.
63
+
48
64
  ## Defining Entities
49
65
 
50
66
  Entities in Dyna-Record represent your DynamoDB table structure and relationships. Think of each entity as a table in a relational database, even though they will be represented on a single table.
@@ -118,7 +134,7 @@ By default, each entity will have [default attributes](https://docs.dyna-record.
118
134
 
119
135
  - The partition key defined on the [table](#table) class
120
136
  - The sort key defined on the [table](#table) class
121
- - [id](https://docs.dyna-record.com/classes/default.html#id) - The id for the model. This will be an autogenerated uuid unless [IdAttribute](<(https://docs.dyna-record.com/functions/IdAttribute.html)>) is set on a non-nullable entity attribute.
137
+ - [id](https://docs.dyna-record.com/classes/default.html#id) - The id for the model. This will be an autogenerated UUID (v4, via Node's built-in `crypto.randomUUID()`) unless [IdAttribute](<(https://docs.dyna-record.com/functions/IdAttribute.html)>) is set on a non-nullable entity attribute.
122
138
  - [type](https://docs.dyna-record.com/classes/default.html#type) - The type of the entity. Value is the entity class name. Must be declared as a string literal via `declare readonly type: "ClassName"`.
123
139
  - [createdAt](https://docs.dyna-record.com/classes/default.html#createdAt) - The timestamp of when the entity was created
124
140
  - [updatedAt](https://docs.dyna-record.com/classes/default.html#updatedAt) - Timestamp of when the entity was updated last
@@ -513,7 +529,7 @@ class Student extends OtherTable {
513
529
 
514
530
  [Docs](https://docs.dyna-record.com/classes/default.html#create)
515
531
 
516
- The create method is used to insert a new record into a DynamoDB table. This method automatically handles key generation (using UUIDs or custom id field if [IdAttribute](<(https://docs.dyna-record.com/functions/IdAttribute.html)>) is set), timestamps for [createdAt](https://docs.dyna-record.com/classes/default.html#createdAt) and [updatedAt](https://docs.dyna-record.com/classes/default.html#updatedAt) fields, and the management of relationships between entities. It leverages AWS SDK's [TransactWriteCommand](https://www.google.com/search?q=aws+transact+write+command&oq=aws+transact+write+command&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQRRg7MgYIAhBFGDvSAQgzMjAzajBqN6gCALACAA&sourceid=chrome&ie=UTF-8) for transactional integrity, ensuring either complete success or rollback in case of any failure. The method handles conditional checks to ensure data integrity and consistency during creation. If a foreignKey is set on create, dyna-record will de-normalize the data required in order to support the relationship
532
+ The create method is used to insert a new record into a DynamoDB table. This method automatically handles key generation (using v4 UUIDs or a custom id field if [IdAttribute](<(https://docs.dyna-record.com/functions/IdAttribute.html)>) is set), timestamps for [createdAt](https://docs.dyna-record.com/classes/default.html#createdAt) and [updatedAt](https://docs.dyna-record.com/classes/default.html#updatedAt) fields, and the management of relationships between entities. It leverages AWS SDK's [TransactWriteCommand](https://www.google.com/search?q=aws+transact+write+command&oq=aws+transact+write+command&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQRRg7MgYIAhBFGDvSAQgzMjAzajBqN6gCALACAA&sourceid=chrome&ie=UTF-8) for transactional integrity, ensuring either complete success or rollback in case of any failure. The method handles conditional checks to ensure data integrity and consistency during creation. If a foreignKey is set on create, dyna-record will de-normalize the data required in order to support the relationship
517
533
 
518
534
  To use the create method, call it on the model class you wish to create a new record for. Pass the properties of the new record as an object argument to the method. Only attributes defined on the model can be configured, and will be enforced via types and runtime schema validation.
519
535
 
@@ -563,7 +579,7 @@ The method is designed to throw errors under various conditions, such as transac
563
579
  #### Notes
564
580
 
565
581
  - Automatic Timestamp Management: The [createdAt](https://docs.dyna-record.com/classes/default.html#createdAt) and [updatedAt](https://docs.dyna-record.com/classes/default.html#updatedAt) fields are managed automatically and reflect the time of creation and the last update, respectively.
566
- - Automatic ID Generation: Each entity created gets a unique [id](https://docs.dyna-record.com/classes/default.html#id) generated by the uuidv4 method.
582
+ - Automatic ID Generation: Each entity created gets a unique [id](https://docs.dyna-record.com/classes/default.html#id) as a v4 uuid.
567
583
  - This can be customized [IdAttribute](<(https://docs.dyna-record.com/functions/IdAttribute.html)>) to support custom id attributes
568
584
  - Relationship Management: The ORM manages entity relationships through DynamoDB's single-table design patterns, creating and maintaining the necessary links between related entities.
569
585
  - Conditional Checks: To ensure data integrity, the create method performs various conditional checks, such as verifying the existence of entities that new records relate to.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,14 @@
1
- import DynaRecord from "./src/DynaRecord";
1
+ /**
2
+ * dyna-record — strongly-typed DynamoDB ORM with single-table relational
3
+ * modeling.
4
+ *
5
+ * The default export is the {@link DynaRecord} base class; all entity
6
+ * decorators, relationship decorators, utility types, and error classes are
7
+ * re-exported from `./src`.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ import DynaRecord from "./src/DynaRecord.js";
2
12
  export default DynaRecord;
3
- export * from "./src";
13
+ export * from "./src/index.js";
4
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C,eAAe,UAAU,CAAC;AAC1B,cAAc,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,eAAe,UAAU,CAAC;AAC1B,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,22 +1,13 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- const DynaRecord_1 = __importDefault(require("./src/DynaRecord"));
21
- exports.default = DynaRecord_1.default;
22
- __exportStar(require("./src"), exports);
1
+ /**
2
+ * dyna-record strongly-typed DynamoDB ORM with single-table relational
3
+ * modeling.
4
+ *
5
+ * The default export is the {@link DynaRecord} base class; all entity
6
+ * decorators, relationship decorators, utility types, and error classes are
7
+ * re-exported from `./src`.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ import DynaRecord from "./src/DynaRecord.js";
12
+ export default DynaRecord;
13
+ export * from "./src/index.js";
@@ -1,6 +1,6 @@
1
- import { type TableMetadata } from "./metadata";
2
- import { type FindByIdOptions, type FindByIdIncludesRes, type EntityKeyConditions, type QueryResults, Create, type CreateOptions, type UpdateOptions, type EntityAttributesInstance, type IncludedAssociations, type IndexKeyConditions, type OptionsWithoutIndex, type OptionsWithIndex, type TypedFilterParams, type TypedSortKeyCondition, type InferQueryResults, type SKScopedFilterParams } from "./operations";
3
- import type { DynamoTableItem, EntityClass, Optional } from "./types";
1
+ import { type TableMetadata } from "./metadata/index.js";
2
+ import { type FindByIdOptions, type FindByIdIncludesRes, type EntityKeyConditions, type QueryResults, Create, type CreateOptions, type UpdateOptions, type EntityAttributesInstance, type IncludedAssociations, type IndexKeyConditions, type OptionsWithoutIndex, type OptionsWithIndex, type TypedFilterParams, type TypedSortKeyCondition, type InferQueryResults, type SKScopedFilterParams } from "./operations/index.js";
3
+ import type { DynamoTableItem, EntityClass, Optional } from "./types.js";
4
4
  interface DynaRecordBase {
5
5
  id: string;
6
6
  type: string;
@@ -1 +1 @@
1
- {"version":3,"file":"DynaRecord.d.ts","sourceRoot":"","sources":["../../src/DynaRecord.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAsB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9E,OAAO,EAEL,KAAK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AC,EAAE;QAAE,yBAAyB,CAAC,EAAE,OAAO,CAAA;KAAE,GAChD,OAAO,CAAC,IAAI,CAAC;IAKhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACU,MAAM,CAAC,CAAC,SAAS,IAAI,EAChC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,EAC5B,OAAO,CAAC,EAAE;QAAE,yBAAyB,CAAC,EAAE,OAAO,CAAA;KAAE,GAChD,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC;IAuBvC;;;;;;;;;;OAUG;WACiB,MAAM,CAAC,CAAC,SAAS,UAAU,EAC7C,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC;IAKhB;;;;;;;;;OASG;WACW,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAKnD;;OAEG;WACW,iBAAiB,CAAC,CAAC,SAAS,UAAU,EAClD,IAAI,EAAE,UAAU,CAAC,EACjB,SAAS,EAAE,eAAe,GACzB,wBAAwB,CAAC,CAAC,CAAC;IAW9B;;;OAGG;IACI,iBAAiB,IAAI,MAAM;IAIlC;;;;;;;;;;;;OAYG;WACW,QAAQ,IAAI,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;CAK9D;AAED,eAAe,UAAU,CAAC"}
@@ -1,20 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
1
  var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
19
2
  function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
20
3
  var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
@@ -49,29 +32,11 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
49
32
  }
50
33
  return useValue ? value : void 0;
51
34
  };
52
- var __importStar = (this && this.__importStar) || (function () {
53
- var ownKeys = function(o) {
54
- ownKeys = Object.getOwnPropertyNames || function (o) {
55
- var ar = [];
56
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
57
- return ar;
58
- };
59
- return ownKeys(o);
60
- };
61
- return function (mod) {
62
- if (mod && mod.__esModule) return mod;
63
- var result = {};
64
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
65
- __setModuleDefault(result, mod);
66
- return result;
67
- };
68
- })();
69
- Object.defineProperty(exports, "__esModule", { value: true });
70
- const metadata_1 = __importStar(require("./metadata"));
71
- const decorators_1 = require("./decorators");
72
- const operations_1 = require("./operations");
73
- const utils_1 = require("./operations/utils");
74
- const utils_2 = require("./utils");
35
+ import Metadata, { tableDefaultFields } from "./metadata/index.js";
36
+ import { DateAttribute, StringAttribute } from "./decorators/index.js";
37
+ import { FindById, Query, Create, Update, Delete } from "./operations/index.js";
38
+ import { mergePartialObjectAttributes } from "./operations/utils/index.js";
39
+ import { createInstance, tableItemToEntity } from "./utils.js";
75
40
  /**
76
41
  * Serves as an abstract base class for entities in the ORM system. It defines standard fields such as `id`, `type`, `createdAt`, and `updatedAt`, and provides static methods for CRUD operations and queries. This class encapsulates common behaviors and properties that all entities share, leveraging decorators for attribute metadata and supporting operations like finding, creating, updating, and deleting entities.
77
42
  *
@@ -112,10 +77,10 @@ let DynaRecord = (() => {
112
77
  return class DynaRecord {
113
78
  static {
114
79
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
115
- _id_decorators = [(0, decorators_1.StringAttribute)({ alias: metadata_1.tableDefaultFields.id.alias })];
116
- _type_decorators = [(0, decorators_1.StringAttribute)({ alias: metadata_1.tableDefaultFields.type.alias })];
117
- _createdAt_decorators = [(0, decorators_1.DateAttribute)({ alias: metadata_1.tableDefaultFields.createdAt.alias })];
118
- _updatedAt_decorators = [(0, decorators_1.DateAttribute)({ alias: metadata_1.tableDefaultFields.updatedAt.alias })];
80
+ _id_decorators = [StringAttribute({ alias: tableDefaultFields.id.alias })];
81
+ _type_decorators = [StringAttribute({ alias: tableDefaultFields.type.alias })];
82
+ _createdAt_decorators = [DateAttribute({ alias: tableDefaultFields.createdAt.alias })];
83
+ _updatedAt_decorators = [DateAttribute({ alias: tableDefaultFields.updatedAt.alias })];
119
84
  __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, _id_extraInitializers);
120
85
  __esDecorate(null, null, _type_decorators, { kind: "field", name: "type", static: false, private: false, access: { has: obj => "type" in obj, get: obj => obj.type, set: (obj, value) => { obj.type = value; } }, metadata: _metadata }, _type_initializers, _type_extraInitializers);
121
86
  __esDecorate(null, null, _createdAt_decorators, { kind: "field", name: "createdAt", static: false, private: false, access: { has: obj => "createdAt" in obj, get: obj => obj.createdAt, set: (obj, value) => { obj.createdAt = value; } }, metadata: _metadata }, _createdAt_initializers, _createdAt_extraInitializers);
@@ -143,11 +108,11 @@ let DynaRecord = (() => {
143
108
  */
144
109
  updatedAt = (__runInitializers(this, _createdAt_extraInitializers), __runInitializers(this, _updatedAt_initializers, void 0));
145
110
  static async findById(id, options) {
146
- const op = new operations_1.FindById(this);
111
+ const op = new FindById(this);
147
112
  return await op.run(id, options);
148
113
  }
149
114
  static async query(key, options) {
150
- const op = new operations_1.Query(this);
115
+ const op = new Query(this);
151
116
  return await op.run(key, options);
152
117
  }
153
118
  /**
@@ -170,7 +135,7 @@ let DynaRecord = (() => {
170
135
  * ```
171
136
  */
172
137
  static async create(attributes, options) {
173
- const op = new operations_1.Create(this);
138
+ const op = new Create(this);
174
139
  return await op.run(attributes, options);
175
140
  }
176
141
  /**
@@ -208,7 +173,7 @@ let DynaRecord = (() => {
208
173
  * ```
209
174
  */
210
175
  static async update(id, attributes, options) {
211
- const op = new operations_1.Update(this);
176
+ const op = new Update(this);
212
177
  await op.run(id, attributes, options);
213
178
  }
214
179
  /**
@@ -245,15 +210,15 @@ let DynaRecord = (() => {
245
210
  */
246
211
  async update(attributes, options) {
247
212
  const InstanceClass = this.constructor;
248
- const op = new operations_1.Update(InstanceClass);
213
+ const op = new Update(InstanceClass);
249
214
  const updatedAttributes = await op.run(this.id, attributes, options);
250
215
  const clone = structuredClone(this);
251
- const entityAttrs = metadata_1.default.getEntityAttributes(InstanceClass.name);
216
+ const entityAttrs = Metadata.getEntityAttributes(InstanceClass.name);
252
217
  // Deep merge ObjectAttributes, shallow assign everything else
253
- (0, utils_1.mergePartialObjectAttributes)(clone, updatedAttributes, entityAttrs);
218
+ mergePartialObjectAttributes(clone, updatedAttributes, entityAttrs);
254
219
  const updatedInstance = Object.fromEntries(Object.entries(clone).filter(([_, value]) => value !== null));
255
220
  // Return the updated instance, which is of type `this`
256
- return (0, utils_2.createInstance)(InstanceClass, updatedInstance);
221
+ return createInstance(InstanceClass, updatedInstance);
257
222
  }
258
223
  /**
259
224
  * Delete an entity by ID
@@ -267,7 +232,7 @@ let DynaRecord = (() => {
267
232
  * ```
268
233
  */
269
234
  static async delete(id) {
270
- const op = new operations_1.Delete(this);
235
+ const op = new Delete(this);
271
236
  await op.run(id);
272
237
  }
273
238
  /**
@@ -281,19 +246,19 @@ let DynaRecord = (() => {
281
246
  * ```
282
247
  */
283
248
  static partitionKeyValue(id) {
284
- const { delimiter } = metadata_1.default.getEntityTable(this.name);
249
+ const { delimiter } = Metadata.getEntityTable(this.name);
285
250
  return `${this.name}${delimiter}${id}`;
286
251
  }
287
252
  /**
288
253
  * Takes a table item and serializes it to an entity instance
289
254
  */
290
255
  static tableItemToEntity(tableItem) {
291
- const tableMeta = metadata_1.default.getEntityTable(this.name);
256
+ const tableMeta = Metadata.getEntityTable(this.name);
292
257
  const typeAlias = tableMeta.defaultAttributes.type.alias;
293
258
  if (tableItem[typeAlias] !== this.name) {
294
259
  throw new Error("Unable to convert dynamo item to entity. Invalid type");
295
260
  }
296
- return (0, utils_2.tableItemToEntity)(this, tableItem);
261
+ return tableItemToEntity(this, tableItem);
297
262
  }
298
263
  /**
299
264
  * Get the partition key for an entity
@@ -316,8 +281,8 @@ let DynaRecord = (() => {
316
281
  * ```
317
282
  */
318
283
  static metadata() {
319
- const tableMetadata = metadata_1.default.getTable(this.name);
320
- const entities = metadata_1.default.getEntitiesForTable(this.name);
284
+ const tableMetadata = Metadata.getTable(this.name);
285
+ const entities = Metadata.getEntitiesForTable(this.name);
321
286
  return tableMetadata.toJSON(entities);
322
287
  }
323
288
  constructor() {
@@ -325,4 +290,4 @@ let DynaRecord = (() => {
325
290
  }
326
291
  };
327
292
  })();
328
- exports.default = DynaRecord;
293
+ export default DynaRecord;
@@ -1,6 +1,4 @@
1
- "use strict";
2
1
  /* eslint-disable @typescript-eslint/no-extraneous-class */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
2
  /**
5
3
  * Facilitates logging throughout the ORM system with support for different log levels: log, warn, error, and info. Logging can be toggled through the `DYNA_RECORD_LOGGING_ENABLED` environment variable. When enabled, logs are output to the console, allowing for easy tracking and debugging of the system's operations.
6
4
  *
@@ -53,4 +51,4 @@ class Logger {
53
51
  this._log("info", ...messages);
54
52
  }
55
53
  }
56
- exports.default = Logger;
54
+ export default Logger;
@@ -1,4 +1,4 @@
1
- import type DynaRecord from "../DynaRecord";
1
+ import type DynaRecord from "../DynaRecord.js";
2
2
  /**
3
3
  * A class decorator for marking a class as an entity within the context of the ORM system. This decorator is essential for registering the class as a distinct entity in the ORM's metadata system, enabling the ORM to recognize and manage instances of this class as part of its data model. By designating classes as entities, it facilitates their integration into the ORM framework, allowing for operations such as querying, persisting, and managing relationships between entities.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../src/decorators/Entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,MAAM,CAAC,CAAC,SAAS,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,UAAU,EACrE,MAAM,EAAE,CAAC,GACP,CAAC,MAAM,SAAS,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GACnC;IACE,iBAAiB,EAAE,yDAAyD,CAAC;CAC9E,GACD,OAAO,CAAC,EACd,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC,GACjC,IAAI,CAKN;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../src/decorators/Entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,MAAM,CAAC,CAAC,SAAS,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,UAAU,EACrE,MAAM,EAAE,CAAC,GACP,CAAC,MAAM,SAAS,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GACnC;IACE,iBAAiB,EAAE,yDAAyD,CAAC;CAC9E,GACD,OAAO,CAAC,EACd,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC,GACjC,IAAI,CAKN;AAED,eAAe,MAAM,CAAC"}
@@ -1,9 +1,4 @@
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"));
1
+ import Metadata from "../metadata/index.js";
7
2
  /**
8
3
  * A class decorator for marking a class as an entity within the context of the ORM system. This decorator is essential for registering the class as a distinct entity in the ORM's metadata system, enabling the ORM to recognize and manage instances of this class as part of its data model. By designating classes as entities, it facilitates their integration into the ORM framework, allowing for operations such as querying, persisting, and managing relationships between entities.
9
4
  *
@@ -29,6 +24,6 @@ const metadata_1 = __importDefault(require("../metadata"));
29
24
  */
30
25
  function Entity(target, _context) {
31
26
  const tableClassName = Object.getPrototypeOf(target).name;
32
- metadata_1.default.addEntity(target, tableClassName);
27
+ Metadata.addEntity(target, tableClassName);
33
28
  }
34
- exports.default = Entity;
29
+ export default Entity;
@@ -1,5 +1,5 @@
1
- import { type TableMetadataOptions } from "../metadata";
2
- import type DynaRecord from "../DynaRecord";
1
+ import { type TableMetadataOptions } from "../metadata/index.js";
2
+ import type DynaRecord from "../DynaRecord.js";
3
3
  /**
4
4
  * 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.
5
5
  *
@@ -1 +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,OAAO,UAAU,YAAY,qBAAqB,UAG5E;AAED,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../src/decorators/Table.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,KAAK,CAAC,KAAK,EAAE,oBAAoB,IACvB,QAAQ,OAAO,UAAU,EAAE,UAAU,qBAAqB,UAG5E;AAED,eAAe,KAAK,CAAC"}
@@ -1,9 +1,4 @@
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"));
1
+ import Metadata from "../metadata/index.js";
7
2
  /**
8
3
  * 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
4
  *
@@ -23,7 +18,7 @@ const metadata_1 = __importDefault(require("../metadata"));
23
18
  */
24
19
  function Table(props) {
25
20
  return function (target, _context) {
26
- metadata_1.default.addTable(target.name, props);
21
+ Metadata.addTable(target.name, props);
27
22
  };
28
23
  }
29
- exports.default = Table;
24
+ export default Table;
@@ -1,5 +1,5 @@
1
- import type DynaRecord from "../../DynaRecord";
2
- import type { AttributeDecoratorContext, AttributeOptions } from "../types";
1
+ import type DynaRecord from "../../DynaRecord.js";
2
+ import type { AttributeDecoratorContext, AttributeOptions } from "../types.js";
3
3
  /**
4
4
  * A decorator for marking class fields as boolean attributes within the context of a single-table design entity
5
5
  *
@@ -1 +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,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAW9C;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"BooleanAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/BooleanAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,gBAAgB,CACvB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,gBAAgB,EAC1B,KAAK,CAAC,EAAE,CAAC,IAEP,QAAQ,SAAS,EACjB,SAAS,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAY9C;AAED,eAAe,gBAAgB,CAAC"}
@@ -1,10 +1,5 @@
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 zod_1 = require("zod");
7
- const metadata_1 = __importDefault(require("../../metadata"));
1
+ import { z } from "zod";
2
+ import Metadata from "../../metadata/index.js";
8
3
  /**
9
4
  * A decorator for marking class fields as boolean attributes within the context of a single-table design entity
10
5
  *
@@ -31,13 +26,14 @@ const metadata_1 = __importDefault(require("../../metadata"));
31
26
  function BooleanAttribute(props) {
32
27
  return function (_value, context) {
33
28
  context.addInitializer(function () {
34
- metadata_1.default.addEntityAttribute(this.constructor.name, {
29
+ Metadata.addEntityAttribute(this.constructor.name, {
35
30
  attributeName: context.name.toString(),
31
+ kind: "boolean",
36
32
  nullable: props?.nullable,
37
- type: zod_1.z.boolean(),
33
+ type: z.boolean(),
38
34
  ...props
39
35
  });
40
36
  });
41
37
  };
42
38
  }
43
- exports.default = BooleanAttribute;
39
+ export default BooleanAttribute;
@@ -1,5 +1,5 @@
1
- import type DynaRecord from "../../DynaRecord";
2
- import type { AttributeDecoratorContext, AttributeOptions } from "../types";
1
+ import type DynaRecord from "../../DynaRecord.js";
2
+ import type { AttributeDecoratorContext, AttributeOptions } from "../types.js";
3
3
  /**
4
4
  * A decorator for marking class fields as date attributes within the context of a single-table design entity
5
5
  *
@@ -1 +1 @@
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,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAY9C;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,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,iBAAS,aAAa,CACpB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,IAAI,EACd,CAAC,SAAS,gBAAgB,EAC1B,KAAK,CAAC,EAAE,CAAC,IAEP,QAAQ,SAAS,EACjB,SAAS,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAa9C;AAED,eAAe,aAAa,CAAC"}
@@ -1,11 +1,6 @@
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 zod_1 = require("zod");
7
- const metadata_1 = __importDefault(require("../../metadata"));
8
- const serializers_1 = require("./serializers");
1
+ import { z } from "zod";
2
+ import Metadata from "../../metadata/index.js";
3
+ import { dateSerializer } from "./serializers.js";
9
4
  /**
10
5
  * A decorator for marking class fields as date attributes within the context of a single-table design entity
11
6
  *
@@ -34,14 +29,15 @@ const serializers_1 = require("./serializers");
34
29
  function DateAttribute(props) {
35
30
  return function (_value, context) {
36
31
  context.addInitializer(function () {
37
- metadata_1.default.addEntityAttribute(this.constructor.name, {
32
+ Metadata.addEntityAttribute(this.constructor.name, {
38
33
  attributeName: context.name.toString(),
34
+ kind: "date",
39
35
  nullable: props?.nullable,
40
- serializers: serializers_1.dateSerializer,
41
- type: zod_1.z.date(),
36
+ serializers: dateSerializer,
37
+ type: z.date(),
42
38
  ...props
43
39
  });
44
40
  });
45
41
  };
46
42
  }
47
- exports.default = DateAttribute;
43
+ export default DateAttribute;
@@ -1,5 +1,5 @@
1
- import type DynaRecord from "../../DynaRecord";
2
- import type { AttributeDecoratorContext, AttributeOptions } from "../types";
1
+ import type DynaRecord from "../../DynaRecord.js";
2
+ import type { AttributeDecoratorContext, AttributeOptions } from "../types.js";
3
3
  /**
4
4
  * Extends {@link AttributeOptions} but requires that the allowed values are set on `values`
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"EnumAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/EnumAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAG5D,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,iBAAS,aAAa,CACpB,CAAC,SAAS,UAAU,EACpB,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EACnC,KAAK,CAAC,CAAC,SAAS,oBAAoB,EACpC,KAAK,EAAE,CAAC,YAEE,SAAS,WACR,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAW9C;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"EnumAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/EnumAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAG5D,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,iBAAS,aAAa,CACpB,CAAC,SAAS,UAAU,EACpB,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EACnC,KAAK,CAAC,CAAC,SAAS,oBAAoB,EACpC,KAAK,EAAE,CAAC,IAEN,QAAQ,SAAS,EACjB,SAAS,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAa9C;AAED,eAAe,aAAa,CAAC"}
@@ -1,10 +1,5 @@
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 zod_1 = require("zod");
7
- const metadata_1 = __importDefault(require("../../metadata"));
1
+ import { z } from "zod";
2
+ import Metadata from "../../metadata/index.js";
8
3
  /**
9
4
  * A decorator for marking class fields as enum attributes within the context of a single-table design entity. Only the types specified in `values` are allowed via both the type system and runtime schema checks.
10
5
  *
@@ -29,13 +24,15 @@ const metadata_1 = __importDefault(require("../../metadata"));
29
24
  function EnumAttribute(props) {
30
25
  return function (_value, context) {
31
26
  context.addInitializer(function () {
32
- metadata_1.default.addEntityAttribute(this.constructor.name, {
27
+ Metadata.addEntityAttribute(this.constructor.name, {
33
28
  attributeName: context.name.toString(),
29
+ kind: "enum",
34
30
  nullable: props.nullable,
35
- type: zod_1.z.enum(props.values),
31
+ type: z.enum(props.values),
32
+ enumValues: props.values,
36
33
  ...props
37
34
  });
38
35
  });
39
36
  };
40
37
  }
41
- exports.default = EnumAttribute;
38
+ export default EnumAttribute;
@@ -1,6 +1,6 @@
1
- import type DynaRecord from "../../DynaRecord";
2
- import type { EntityClass, ForeignKey, NullableForeignKey } from "../../types";
3
- import type { AttributeDecoratorContext, AttributeOptions } from "../types";
1
+ import type DynaRecord from "../../DynaRecord.js";
2
+ import type { EntityClass, ForeignKey, NullableForeignKey } from "../../types.js";
3
+ import type { AttributeDecoratorContext, AttributeOptions } from "../types.js";
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
  *
@@ -1 +1 @@
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,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,iBAAS,mBAAmB,CAC1B,YAAY,SAAS,UAAU,EAC/B,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,gBAAgB,EAC1B,SAAS,EAAE,MAAM,WAAW,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,YAE3C,SAAS,WACR,yBAAyB,CAChC,CAAC,EACD,CAAC,CAAC,UAAU,CAAC,SAAS,IAAI,GACtB,kBAAkB,CAAC,YAAY,CAAC,GAChC,UAAU,CAAC,YAAY,CAAC,EAC5B,CAAC,CACF,UAcJ;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,qBAAqB,CAAC;AAElD,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,iBAAS,mBAAmB,CAC1B,YAAY,SAAS,UAAU,EAC/B,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,gBAAgB,EAC1B,SAAS,EAAE,MAAM,WAAW,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,IAEnD,QAAQ,SAAS,EACjB,SAAS,yBAAyB,CAChC,CAAC,EACD,CAAC,CAAC,UAAU,CAAC,SAAS,IAAI,GACtB,kBAAkB,CAAC,YAAY,CAAC,GAChC,UAAU,CAAC,YAAY,CAAC,EAC5B,CAAC,CACF,UAeJ;AAED,eAAe,mBAAmB,CAAC"}
@@ -1,10 +1,5 @@
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 zod_1 = require("zod");
7
- const metadata_1 = __importDefault(require("../../metadata"));
1
+ import { z } from "zod";
2
+ import Metadata from "../../metadata/index.js";
8
3
  /**
9
4
  * 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.
10
5
  *
@@ -43,14 +38,15 @@ function ForeignKeyAttribute(getTarget, props) {
43
38
  return function (_value, context) {
44
39
  context.addInitializer(function () {
45
40
  const targetEntity = getTarget();
46
- metadata_1.default.addEntityAttribute(this.constructor.name, {
41
+ Metadata.addEntityAttribute(this.constructor.name, {
47
42
  attributeName: context.name.toString(),
43
+ kind: "foreignKey",
48
44
  nullable: props?.nullable,
49
- type: zod_1.z.string(),
45
+ type: z.string(),
50
46
  foreignKeyTarget: targetEntity,
51
47
  ...props
52
48
  });
53
49
  });
54
50
  };
55
51
  }
56
- exports.default = ForeignKeyAttribute;
52
+ export default ForeignKeyAttribute;