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
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/operations/utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EACV,8BAA8B,EAC9B,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAQxB,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,UAAU,EACV,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,kBAC1B,oBAAoB,EAAE,KACpC,mBAaF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,YAC7B,oBAAoB,UACrB,OAAO,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,KAChD,UAAU,GAAG,IAAI,GAAG,SAKtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,gBACnB,WAAW,CAAC,UAAU,CAAC,YAC1B,MAAM,WACP,8BAA8B,cAC3B,MAAM,KACjB,eAqBF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,SAAU,OAAO,KAAG,OAEjD,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/operations/utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EACV,8BAA8B,EAC9B,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAQjC,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,UAAU,EACV,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,GACzC,eAAe,oBAAoB,EAAE,KACpC,mBAaF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAS,oBAAoB,EAC7B,QAAQ,OAAO,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,KAChD,UAAU,GAAG,IAAI,GAAG,SAKtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,aAAa,WAAW,CAAC,UAAU,CAAC,EACpC,UAAU,MAAM,EAChB,SAAS,8BAA8B,EACvC,YAAY,MAAM,KACjB,eAqBF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,OAAO,KAAG,OAEjD,CAAC"}
@@ -1,12 +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
- exports.consistentReadVal = exports.buildBelongsToLinkKey = exports.extractForeignKeyFromEntity = exports.buildEntityRelationshipMetaObj = void 0;
7
- const metadata_1 = __importDefault(require("../../metadata"));
8
- const utils_1 = require("../../metadata/utils");
9
- const utils_2 = require("../../utils");
1
+ import Metadata from "../../metadata/index.js";
2
+ import { doesEntityBelongToRelAsHasMany, doesEntityBelongToRelAsHasOne, isBelongsToRelationship, isRelationshipMetadataWithForeignKey } from "../../metadata/utils.js";
3
+ import { isKeyOfObject } from "../../utils.js";
10
4
  /**
11
5
  * Creates an object including
12
6
  * - relationsLookup: Object to look up RelationshipMetadata by Entity name
@@ -14,29 +8,27 @@ const utils_2 = require("../../utils");
14
8
  * @param includedRelationships
15
9
  * @returns
16
10
  */
17
- const buildEntityRelationshipMetaObj = (relationships) => {
11
+ export const buildEntityRelationshipMetaObj = (relationships) => {
18
12
  return Object.values(relationships).reduce((acc, rel) => {
19
- if ((0, utils_1.isBelongsToRelationship)(rel)) {
13
+ if (isBelongsToRelationship(rel)) {
20
14
  acc.belongsToRelationships.push(rel);
21
15
  }
22
16
  acc.relationsLookup[rel.target.name] = rel;
23
17
  return acc;
24
18
  }, { relationsLookup: {}, belongsToRelationships: [] });
25
19
  };
26
- exports.buildEntityRelationshipMetaObj = buildEntityRelationshipMetaObj;
27
20
  /**
28
21
  * Extracts a ForeignKey value from an entity instance
29
22
  * @param relMeta - RelationshipMetadata for associated foreignKey
30
23
  * @param entity - instance of DynaRecord
31
24
  * @returns
32
25
  */
33
- const extractForeignKeyFromEntity = (relMeta, entity) => {
34
- return (0, utils_1.isRelationshipMetadataWithForeignKey)(relMeta) &&
35
- (0, utils_2.isKeyOfObject)(entity, relMeta.foreignKey)
26
+ export const extractForeignKeyFromEntity = (relMeta, entity) => {
27
+ return isRelationshipMetadataWithForeignKey(relMeta) &&
28
+ isKeyOfObject(entity, relMeta.foreignKey)
36
29
  ? entity[relMeta.foreignKey]
37
30
  : undefined;
38
31
  };
39
- exports.extractForeignKeyFromEntity = extractForeignKeyFromEntity;
40
32
  /**
41
33
  * Creates the PK and SK (key) for a table item that BelongsTo another as HasMany or HasOne
42
34
  * @param entityClass
@@ -45,17 +37,17 @@ exports.extractForeignKeyFromEntity = extractForeignKeyFromEntity;
45
37
  * @param foreignKey
46
38
  * @returns
47
39
  */
48
- const buildBelongsToLinkKey = (entityClass, entityId, relMeta, foreignKey) => {
49
- const tableMeta = metadata_1.default.getEntityTable(entityClass.name);
40
+ export const buildBelongsToLinkKey = (entityClass, entityId, relMeta, foreignKey) => {
41
+ const tableMeta = Metadata.getEntityTable(entityClass.name);
50
42
  const partitionKeyAlias = tableMeta.partitionKeyAttribute.alias;
51
43
  const sortKeyAlias = tableMeta.sortKeyAttribute.alias;
52
- if ((0, utils_1.doesEntityBelongToRelAsHasMany)(entityClass, relMeta)) {
44
+ if (doesEntityBelongToRelAsHasMany(entityClass, relMeta)) {
53
45
  return {
54
46
  [partitionKeyAlias]: relMeta.target.partitionKeyValue(foreignKey),
55
47
  [sortKeyAlias]: entityClass.partitionKeyValue(entityId)
56
48
  };
57
49
  }
58
- if ((0, utils_1.doesEntityBelongToRelAsHasOne)(entityClass, relMeta)) {
50
+ if (doesEntityBelongToRelAsHasOne(entityClass, relMeta)) {
59
51
  return {
60
52
  [partitionKeyAlias]: relMeta.target.partitionKeyValue(foreignKey),
61
53
  [sortKeyAlias]: entityClass.name
@@ -63,12 +55,10 @@ const buildBelongsToLinkKey = (entityClass, entityId, relMeta, foreignKey) => {
63
55
  }
64
56
  throw new Error("Failed to build BelongsTo key for linked record");
65
57
  };
66
- exports.buildBelongsToLinkKey = buildBelongsToLinkKey;
67
58
  /**
68
59
  * Consistent read value.
69
60
  * @default false
70
61
  */
71
- const consistentReadVal = (val) => {
62
+ export const consistentReadVal = (val) => {
72
63
  return val ?? false;
73
64
  };
74
- exports.consistentReadVal = consistentReadVal;
@@ -1,5 +1,5 @@
1
- import { type RelationshipMetadata } from "../metadata";
2
- import { type OrFilter } from "./types";
1
+ import { type RelationshipMetadata } from "../metadata/index.js";
2
+ import { type OrFilter } from "./types.js";
3
3
  /**
4
4
  * Builds the filter so that relationships that are included in the query will have their relationships included in the query
5
5
  * @param parentClassName
@@ -1 +1 @@
1
- {"version":3,"file":"Filters.d.ts","sourceRoot":"","sources":["../../../src/query-utils/Filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,MAAM,EACvB,qBAAqB,EAAE,oBAAoB,EAAE,GAC5C,QAAQ,CASV"}
1
+ {"version":3,"file":"Filters.d.ts","sourceRoot":"","sources":["../../../src/query-utils/Filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,MAAM,EACvB,qBAAqB,EAAE,oBAAoB,EAAE,GAC5C,QAAQ,CASV"}
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.includedRelationshipsFilter = includedRelationshipsFilter;
4
1
  /**
5
2
  * Builds the filter so that relationships that are included in the query will have their relationships included in the query
6
3
  * @param parentClassName
7
4
  * @param includedRelationships
8
5
  * @returns
9
6
  */
10
- function includedRelationshipsFilter(parentClassName, includedRelationships) {
7
+ export function includedRelationshipsFilter(parentClassName, includedRelationships) {
11
8
  const includedTypes = [
12
9
  parentClassName,
13
10
  ...includedRelationships.map(rel => rel.target.name)
@@ -1,5 +1,5 @@
1
1
  import { type QueryCommandInput } from "@aws-sdk/lib-dynamodb";
2
- import type { QueryCommandProps } from "./types";
2
+ import type { QueryCommandProps } from "./types.js";
3
3
  /**
4
4
  * Constructs and formats a DynamoDB query command based on provided key conditions and query options. This class simplifies the creation of complex DynamoDB queries by abstracting the underlying AWS SDK query command structure, particularly handling the construction of key condition expressions, filter expressions, and expression attribute names and values.
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"QueryBuilder.d.ts","sourceRoot":"","sources":["../../../src/query-utils/QueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO/D,OAAO,KAAK,EAUV,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAgBjB;;;;GAIG;AACH,cAAM,YAAY;;gBASJ,KAAK,EAAE,iBAAiB;IAmBpC;;;OAGG;IACI,KAAK,IAAI,iBAAiB;IAwBjC;;;;;OAKG;IACH,OAAO,CAAC,8BAA8B;IAgBtC;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAgChC;;;;;;;;;OASG;IACH,OAAO,CAAC,YAAY;IAWpB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IASnB;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAejB;;;;;;;OAOG;IACH,OAAO,CAAC,YAAY;IAkCpB;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;IAkCvB;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAehB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAI1B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAIrB;;;;OAIG;IACH,OAAO,CAAC,UAAU;CAGnB;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"QueryBuilder.d.ts","sourceRoot":"","sources":["../../../src/query-utils/QueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO/D,OAAO,KAAK,EAUV,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAgBpB;;;;GAIG;AACH,cAAM,YAAY;;gBASJ,KAAK,EAAE,iBAAiB;IAmBpC;;;OAGG;IACI,KAAK,IAAI,iBAAiB;IAwBjC;;;;;OAKG;IACH,OAAO,CAAC,8BAA8B;IAgBtC;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAgChC;;;;;;;;;OASG;IACH,OAAO,CAAC,YAAY;IAWpB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IASnB;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAejB;;;;;;;OAOG;IACH,OAAO,CAAC,YAAY;IAkCpB;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;IAkCvB;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAehB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAI1B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAIrB;;;;OAIG;IACH,OAAO,CAAC,UAAU;CAGnB;AAED,eAAe,YAAY,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 metadata_1 = __importDefault(require("../metadata"));
7
- const utils_1 = require("../operations/utils");
1
+ import Metadata from "../metadata/index.js";
2
+ import { consistentReadVal } from "../operations/utils/index.js";
8
3
  /**
9
4
  * Constructs and formats a DynamoDB query command based on provided key conditions and query options. This class simplifies the creation of complex DynamoDB queries by abstracting the underlying AWS SDK query command structure, particularly handling the construction of key condition expressions, filter expressions, and expression attribute names and values.
10
5
  *
@@ -21,10 +16,10 @@ class QueryBuilder {
21
16
  constructor(props) {
22
17
  this.#props = props;
23
18
  this.#attrCounter = 0;
24
- const entityMetadata = metadata_1.default.getEntity(props.entityClassName);
25
- this.#tableMetadata = metadata_1.default.getTable(entityMetadata.tableClassName);
26
- const relationshipsAttributesMeta = Object.values(entityMetadata.relationships).map(relMeta => metadata_1.default.getEntityAttributes(relMeta.target.name));
27
- const entityAttrMeta = metadata_1.default.getEntityAttributes(props.entityClassName);
19
+ const entityMetadata = Metadata.getEntity(props.entityClassName);
20
+ this.#tableMetadata = Metadata.getTable(entityMetadata.tableClassName);
21
+ const relationshipsAttributesMeta = Object.values(entityMetadata.relationships).map(relMeta => Metadata.getEntityAttributes(relMeta.target.name));
22
+ const entityAttrMeta = Metadata.getEntityAttributes(props.entityClassName);
28
23
  const allAttrMeta = [...relationshipsAttributesMeta, entityAttrMeta];
29
24
  this.#attributeMetadata = allAttrMeta.reduce((allAttrMeta, attrMeta) => {
30
25
  return { ...allAttrMeta, ...attrMeta };
@@ -47,7 +42,7 @@ class QueryBuilder {
47
42
  KeyConditionExpression: keyFilter.expression,
48
43
  ExpressionAttributeNames: this.expressionAttributeNames(),
49
44
  ExpressionAttributeValues: this.expressionAttributeValueParams(keyFilter, filterParams),
50
- ConsistentRead: (0, utils_1.consistentReadVal)(this.#props.options?.consistentRead)
45
+ ConsistentRead: consistentReadVal(this.#props.options?.consistentRead)
51
46
  };
52
47
  }
53
48
  /**
@@ -273,4 +268,4 @@ class QueryBuilder {
273
268
  return filter.$or !== undefined;
274
269
  }
275
270
  }
276
- exports.default = QueryBuilder;
271
+ export default QueryBuilder;
@@ -1,3 +1,3 @@
1
- export { default as QueryBuilder } from "./QueryBuilder";
2
- export * from "./types";
1
+ export { default as QueryBuilder } from "./QueryBuilder.js";
2
+ export * from "./types.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/query-utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/query-utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5D,cAAc,YAAY,CAAC"}
@@ -1,23 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.QueryBuilder = void 0;
21
- var QueryBuilder_1 = require("./QueryBuilder");
22
- Object.defineProperty(exports, "QueryBuilder", { enumerable: true, get: function () { return __importDefault(QueryBuilder_1).default; } });
23
- __exportStar(require("./types"), exports);
1
+ export { default as QueryBuilder } from "./QueryBuilder.js";
2
+ export * from "./types.js";
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,5 +1,5 @@
1
- import type DynaRecord from "../DynaRecord";
2
- import type { ForeignKey, EntityClass } from "../types";
1
+ import type DynaRecord from "../DynaRecord.js";
2
+ import type { ForeignKey, EntityClass } from "../types.js";
3
3
  /**
4
4
  * Exclude the type1 type2 instance keys
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"JoinTable.d.ts","sourceRoot":"","sources":["../../../src/relationships/JoinTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAW5C,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW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AAM,CACxB,SAAS,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EACjC,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,UAAU,EAEpB,IAAI,EAAE,KAAK,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,SAAS,EACrE,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,EACrC,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,IAAI,CAAC;IA6BhB;;;;;OAKG;WACiB,MAAM,CACxB,SAAS,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EACjC,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,UAAU,EAEpB,IAAI,EAAE,KAAK,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,SAAS,EACrE,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC;mBAWK,QAAQ;IAoD7B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IA8CpC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAcpC;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IA0BzB,OAAO,CAAC,MAAM,CAAC,YAAY;IAoB3B,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAoB/B,OAAO,CAAC,MAAM,CAAC,4BAA4B;CA+B5C;AAED,eAAe,SAAS,CAAC"}
@@ -1,12 +1,7 @@
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 dynamo_utils_1 = require("../dynamo-utils");
7
- const TransactWriteBuilder_1 = __importDefault(require("../dynamo-utils/TransactWriteBuilder"));
8
- const errors_1 = require("../errors");
9
- const metadata_1 = __importDefault(require("../metadata"));
1
+ import { TransactGetBuilder } from "../dynamo-utils/index.js";
2
+ import TransactionBuilder from "../dynamo-utils/TransactWriteBuilder.js";
3
+ import { NotFoundError } from "../errors.js";
4
+ import Metadata from "../metadata/index.js";
10
5
  /**
11
6
  * Abstract class representing a join table for HasAndBelongsToMany relationships.
12
7
  * This class should be extended for specific join table implementations.
@@ -37,8 +32,8 @@ class JoinTable {
37
32
  */
38
33
  static async create(keys, options) {
39
34
  const referentialIntegrityCheck = options?.referentialIntegrityCheck ?? true;
40
- const transactionBuilder = new TransactWriteBuilder_1.default();
41
- const [rel1, rel2] = metadata_1.default.getJoinTable(this.name);
35
+ const transactionBuilder = new TransactionBuilder();
36
+ const [rel1, rel2] = Metadata.getJoinTable(this.name);
42
37
  const transactionProps = JoinTable.transactionProps(keys, rel2, rel1);
43
38
  const lookupTableItem = await JoinTable.preFetch(transactionProps);
44
39
  JoinTable.denormalizeLinkRecord(transactionBuilder, keys, rel1, rel2, lookupTableItem[transactionProps.ids.linkedEntityId], referentialIntegrityCheck);
@@ -52,8 +47,8 @@ class JoinTable {
52
47
  * @param keys
53
48
  */
54
49
  static async delete(keys) {
55
- const transactionBuilder = new TransactWriteBuilder_1.default();
56
- const [rel1, rel2] = metadata_1.default.getJoinTable(this.name);
50
+ const transactionBuilder = new TransactionBuilder();
51
+ const [rel1, rel2] = Metadata.getJoinTable(this.name);
57
52
  JoinTable.deleteLink(transactionBuilder, keys, rel1, rel2);
58
53
  JoinTable.deleteLink(transactionBuilder, keys, rel2, rel1);
59
54
  await transactionBuilder.executeTransaction();
@@ -63,7 +58,7 @@ class JoinTable {
63
58
  const idAlias = tableProps.defaultAttributes.id.alias;
64
59
  const parentKey = JoinTable.buildForeignEntityKey(tableProps, entities.linkedEntity, ids.parentId);
65
60
  const linkedKey = JoinTable.buildForeignEntityKey(tableProps, entities.parentEntity, ids.linkedEntityId);
66
- const transactionGetBuilder = new dynamo_utils_1.TransactGetBuilder();
61
+ const transactionGetBuilder = new TransactGetBuilder();
67
62
  transactionGetBuilder.addGet({
68
63
  TableName: tableProps.name,
69
64
  Key: parentKey
@@ -75,7 +70,7 @@ class JoinTable {
75
70
  const transactionResults = await transactionGetBuilder.executeTransaction();
76
71
  if (transactionResults.length !== 2) {
77
72
  const errorMessage = this.preFetchNotFoundErrorMessage(transactionResults, entities, ids);
78
- throw new errors_1.NotFoundError(errorMessage);
73
+ throw new NotFoundError(errorMessage);
79
74
  }
80
75
  return transactionResults.reduce((acc, res) => {
81
76
  if (res.Item !== undefined) {
@@ -147,7 +142,7 @@ class JoinTable {
147
142
  const { entity: linkedEntity, foreignKey: linkedKey } = linkedEntityMeta;
148
143
  const parentId = keys[parentKey];
149
144
  const linkedEntityId = keys[linkedKey];
150
- const { name: tableName, partitionKeyAttribute } = metadata_1.default.getEntityTable(parentEntity.name);
145
+ const { name: tableName, partitionKeyAttribute } = Metadata.getEntityTable(parentEntity.name);
151
146
  transactionBuilder.addDelete({
152
147
  TableName: tableName,
153
148
  Key: this.joinTableKey(keys, parentEntityMeta, linkedEntityMeta),
@@ -167,7 +162,7 @@ class JoinTable {
167
162
  static transactionProps(keys, parentEntityMeta, linkedEntityMeta) {
168
163
  const { entity: parentEntity, foreignKey: parentFK } = parentEntityMeta;
169
164
  const { entity: linkedEntity, foreignKey: linkedFK } = linkedEntityMeta;
170
- const tableMetadata = metadata_1.default.getEntityTable(parentEntity.name);
165
+ const tableMetadata = Metadata.getEntityTable(parentEntity.name);
171
166
  const parentId = keys[parentFK];
172
167
  const linkedEntityId = keys[linkedFK];
173
168
  return {
@@ -181,7 +176,7 @@ class JoinTable {
181
176
  { entityId: ids.parentId, entityName: entities.linkedEntity.name },
182
177
  { entityId: ids.linkedEntityId, entityName: entities.parentEntity.name }
183
178
  ];
184
- const tableMeta = metadata_1.default.getEntityTable(entities.parentEntity.name);
179
+ const tableMeta = Metadata.getEntityTable(entities.parentEntity.name);
185
180
  const idAlias = tableMeta.defaultAttributes.id.alias;
186
181
  const foundEntityIds = new Set(transactionResults
187
182
  .filter(result => result.Item !== undefined)
@@ -195,4 +190,4 @@ class JoinTable {
195
190
  return `Entities not found: ${missingEntityStr}`;
196
191
  }
197
192
  }
198
- exports.default = JoinTable;
193
+ export default JoinTable;
@@ -1,2 +1,2 @@
1
- export { default as JoinTable } from "./JoinTable";
1
+ export { default as JoinTable } from "./JoinTable.js";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/relationships/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/relationships/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1,8 +1 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.JoinTable = void 0;
7
- var JoinTable_1 = require("./JoinTable");
8
- Object.defineProperty(exports, "JoinTable", { enumerable: true, get: function () { return __importDefault(JoinTable_1).default; } });
1
+ export { default as JoinTable } from "./JoinTable.js";
@@ -1,6 +1,6 @@
1
1
  import { type NativeAttributeValue } from "@aws-sdk/util-dynamodb";
2
- import type { BelongsToRelationship, RelationshipMetadata } from "./metadata";
3
- import type DynaRecord from "./DynaRecord";
2
+ import type { BelongsToRelationship, RelationshipMetadata } from "./metadata/index.js";
3
+ import type DynaRecord from "./DynaRecord.js";
4
4
  /**
5
5
  * A utility type for branding primitives to ensure type safety with unique identifiers.
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oB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IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACzD,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEtB;;;GAGG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,OAAO,UAAU,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;KAC3D,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACjB,CAAC"}
package/dist/src/types.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,6 +1,6 @@
1
- import type DynaRecord from "./DynaRecord";
2
- import type { DynamoTableItem, Nullable } from "./types";
3
- import { type EntityAttributesOnly } from "./operations";
1
+ import type DynaRecord from "./DynaRecord.js";
2
+ import type { DynamoTableItem, Nullable } from "./types.js";
3
+ import { type EntityAttributesOnly } from "./operations/index.js";
4
4
  /**
5
5
  * Convert an entity to its aliased table item fields to for dynamo interactions
6
6
  * @param entityClassName
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEzD,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,gBACf,UAAU,UAAU,cACrB,OAAO,CAAC,UAAU,C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B,GAC5B,aAAa,UAAU,UAAU,EACjC,YAAY,OAAO,CAAC,UAAU,CAAC,KAC9B,eAoBF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,UAAU,EACpD,aAAa,UAAU,CAAC,EACxB,WAAW,eAAe,KACzB,CAsBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,UAAU,EACjD,aAAa,UAAU,CAAC,EACxB,YAAY,oBAAoB,CAAC,CAAC,CAAC,KAClC,CAUF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,UAAU,EAClB,KAAK,MAAM,KACV,GAAG,IAAI,MAAM,UAEf,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,aAAa,GAAI,CAAC,EAC7B,QAAQ,OAAO,CAAC,UAAU,CAAC,EAC3B,KAAK,WAAW,KACf,GAAG,IAAI,MAAM,CAEf,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,MAAM,KAAG,CAAC,EAAE,EAI3D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAElD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,SAAS,oBAAoB,CAAC,UAAU,CAAC,EACzE,QAAQ,OAAO,EACf,KAAK,MAAM,OAAO,EAClB,OAAO,OAAO,KACb,IAEF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,QAAQ,CAAC,MAAM,CAErE,CAAC"}
package/dist/src/utils.js CHANGED
@@ -1,18 +1,12 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isNullableString = exports.safeAssign = exports.isString = exports.chunkArray = exports.isKeyOfObject = exports.isKeyOfEntity = exports.createInstance = exports.tableItemToEntity = exports.entityToTableItem = void 0;
7
- const metadata_1 = __importDefault(require("./metadata"));
1
+ import Metadata from "./metadata/index.js";
8
2
  /**
9
3
  * Convert an entity to its aliased table item fields to for dynamo interactions
10
4
  * @param entityClassName
11
5
  * @param entityData
12
6
  * @returns
13
7
  */
14
- const entityToTableItem = (EntityClass, entityData) => {
15
- const attributesMeta = metadata_1.default.getEntityAttributes(EntityClass.name);
8
+ export const entityToTableItem = (EntityClass, entityData) => {
9
+ const attributesMeta = Metadata.getEntityAttributes(EntityClass.name);
16
10
  return Object.entries(entityData).reduce((acc, [key, rawVal]) => {
17
11
  if (key in attributesMeta) {
18
12
  const attrMeta = attributesMeta[key];
@@ -27,52 +21,48 @@ const entityToTableItem = (EntityClass, entityData) => {
27
21
  return acc;
28
22
  }, {});
29
23
  };
30
- exports.entityToTableItem = entityToTableItem;
31
24
  /**
32
25
  * Serialize a table item to its associated Entity class, using the class attribute property names
33
26
  * @param EntityClass
34
27
  * @param tableItem
35
28
  * @returns
36
29
  */
37
- const tableItemToEntity = (EntityClass, tableItem) => {
38
- const tableAttributes = metadata_1.default.getEntityTableAttributes(EntityClass.name);
30
+ export const tableItemToEntity = (EntityClass, tableItem) => {
31
+ const tableAttributes = Metadata.getEntityTableAttributes(EntityClass.name);
39
32
  const entity = new EntityClass();
40
33
  Object.keys(tableItem).forEach(attrName => {
41
34
  if (attrName in tableAttributes) {
42
35
  const attrMeta = tableAttributes[attrName];
43
36
  const { name: entityKey, serializers } = attrMeta;
44
- if ((0, exports.isKeyOfEntity)(entity, entityKey)) {
37
+ if (isKeyOfEntity(entity, entityKey)) {
45
38
  const rawVal = tableItem[attrName];
46
39
  const val = serializers?.toEntityAttribute === undefined
47
40
  ? rawVal
48
41
  : serializers.toEntityAttribute(rawVal);
49
- (0, exports.safeAssign)(entity, entityKey, val);
42
+ safeAssign(entity, entityKey, val);
50
43
  }
51
44
  }
52
45
  });
53
46
  return entity;
54
47
  };
55
- exports.tableItemToEntity = tableItemToEntity;
56
48
  /**
57
49
  * Create an instance of a dyna record class
58
50
  */
59
- const createInstance = (EntityClass, attributes) => {
51
+ export const createInstance = (EntityClass, attributes) => {
60
52
  const entity = new EntityClass();
61
53
  Object.entries(attributes).forEach(([attrName, val]) => {
62
- if ((0, exports.isKeyOfEntity)(entity, attrName)) {
63
- (0, exports.safeAssign)(entity, attrName, val);
54
+ if (isKeyOfEntity(entity, attrName)) {
55
+ safeAssign(entity, attrName, val);
64
56
  }
65
57
  });
66
58
  return entity;
67
59
  };
68
- exports.createInstance = createInstance;
69
60
  /**
70
61
  * Type guard to check if the key is defined on the entity
71
62
  */
72
- const isKeyOfEntity = (entity, key) => {
63
+ export const isKeyOfEntity = (entity, key) => {
73
64
  return key in entity;
74
65
  };
75
- exports.isKeyOfEntity = isKeyOfEntity;
76
66
  /**
77
67
  * Type guard to check if the key is a defined property on the entity
78
68
  * @param entity
@@ -80,30 +70,27 @@ exports.isKeyOfEntity = isKeyOfEntity;
80
70
  * @returns
81
71
  */
82
72
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- Generic T needed for narrowing key to keyof T at call sites
83
- const isKeyOfObject = (entity, key) => {
73
+ export const isKeyOfObject = (entity, key) => {
84
74
  return key in entity;
85
75
  };
86
- exports.isKeyOfObject = isKeyOfObject;
87
76
  /**
88
77
  * Break an array into chunks
89
78
  * @param array
90
79
  * @param size
91
80
  * @returns Array split into chunks of given size
92
81
  */
93
- const chunkArray = (array, size) => {
82
+ export const chunkArray = (array, size) => {
94
83
  return Array.from({ length: Math.ceil(array.length / size) }, (_, index) => array.slice(index * size, (index + 1) * size));
95
84
  };
96
- exports.chunkArray = chunkArray;
97
85
  /**
98
86
  * Checks if the given value is a string.
99
87
  *
100
88
  * @param value - The value to check. This can be any type as the function is meant to validate if it's a string.
101
89
  * @returns `true` if `value` is a string; otherwise, `false`.
102
90
  */
103
- const isString = (value) => {
91
+ export const isString = (value) => {
104
92
  return typeof value === "string";
105
93
  };
106
- exports.isString = isString;
107
94
  /**
108
95
  * Safely assigns a value to a property of an object.
109
96
  * It's useful for dynamically assigning properties to objects where the property names might be known but the types could vary.
@@ -122,16 +109,14 @@ exports.isString = isString;
122
109
  * let entity = { id: "123" };
123
110
  * safeAssign(entity, "name", "Jane Doe");
124
111
  */
125
- const safeAssign = (object, key, value) => {
112
+ export const safeAssign = (object, key, value) => {
126
113
  object[key] = value;
127
114
  };
128
- exports.safeAssign = safeAssign;
129
115
  /**
130
116
  * Type guard to check if a string is a Nullable<string>
131
117
  * @param val
132
118
  * @returns
133
119
  */
134
- const isNullableString = (val) => {
120
+ export const isNullableString = (val) => {
135
121
  return typeof val === "string" || val === null;
136
122
  };
137
- exports.isNullableString = isNullableString;
package/package.json CHANGED
@@ -1,20 +1,29 @@
1
1
  {
2
2
  "name": "dyna-record",
3
- "version": "0.6.6",
3
+ "version": "0.7.0",
4
4
  "description": "Typescript Data Modeler and ORM for Dynamo",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "type": "module",
6
+ "types": "./dist/index.d.ts",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
7
15
  "scripts": {
8
16
  "build": "tsc",
9
- "watch": "tsc -w",
17
+ "watch": "tsc --watch",
10
18
  "typecheck": "tsc --noEmit && tsc -p tsconfig.dev.json --noEmit",
11
19
  "typecheck:tests": "tsc -p tsconfig.dev.json --noEmit",
12
- "test": "tsc -p tsconfig.dev.json --noEmit && jest",
13
- "test:watch": "jest --watch",
20
+ "test": "tsc -p tsconfig.dev.json --noEmit && vitest run",
21
+ "test:watch": "vitest",
14
22
  "eslint": "npx eslint .",
15
23
  "eslint:fix": "npx eslint . --fix",
16
24
  "prettier": "npx prettier . --write",
17
- "docs": "npx typedoc"
25
+ "docs": "npx typedoc",
26
+ "prepublishOnly": "npm run build && npx publint"
18
27
  },
19
28
  "repository": {
20
29
  "type": "git",
@@ -30,32 +39,27 @@
30
39
  "@aws-sdk/client-dynamodb": "^3.502.0",
31
40
  "@aws-sdk/lib-dynamodb": "^3.502.0",
32
41
  "@aws-sdk/util-dynamodb": "^3.509.0",
33
- "uuid": "^9.0.1",
34
42
  "zod": "^4.3.6"
35
43
  },
36
44
  "devDependencies": {
37
- "@aws-sdk/types": "^3.502.0",
38
- "@eslint/js": "^9.39.3",
39
- "@tsconfig/recommended": "^1.0.3",
40
- "@types/jest": "^29.5.12",
41
- "@types/node": "^20.11.16",
42
- "@types/uuid": "^9.0.8",
43
- "@typescript-eslint/eslint-plugin": "^8.56.1",
44
- "eslint": "^9.39.3",
45
+ "@eslint/js": "^10.0.1",
46
+ "@types/node": "^22.19.19",
47
+ "@typescript-eslint/eslint-plugin": "^8.60.0",
48
+ "@vitest/coverage-v8": "^3.2.4",
49
+ "eslint": "^10.4.0",
45
50
  "eslint-config-prettier": "^10.1.8",
46
51
  "globals": "^16.5.0",
47
- "jest": "^29.7.0",
48
52
  "prettier": "^3.2.5",
49
- "ts-jest": "^29.1.2",
50
- "ts-node": "^10.9.2",
51
- "typedoc": "^0.27.6",
52
- "typedoc-plugin-missing-exports": "^3.1.0",
53
- "typescript": "^5.7.2",
54
- "typescript-eslint": "^8.56.1"
53
+ "publint": "^0.3.21",
54
+ "typedoc": "^0.28.19",
55
+ "typedoc-plugin-missing-exports": "^4.1.3",
56
+ "typescript": "^6.0.3",
57
+ "typescript-eslint": "^8.60.0",
58
+ "vitest": "^3.2.4"
55
59
  },
56
60
  "engines": {
57
61
  "npm": ">=10.0.0",
58
- "node": ">=18.0.0"
62
+ "node": ">=22.12.0"
59
63
  },
60
64
  "files": [
61
65
  "dist/**/*"