dyna-record 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/README.md +3 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +17 -0
  5. package/dist/src/DynaRecord.d.ts +216 -0
  6. package/dist/src/DynaRecord.d.ts.map +1 -0
  7. package/dist/src/DynaRecord.js +217 -0
  8. package/dist/src/Logger.d.ts +42 -0
  9. package/dist/src/Logger.d.ts.map +1 -0
  10. package/dist/src/Logger.js +57 -0
  11. package/dist/src/decorators/Entity.d.ts +23 -0
  12. package/dist/src/decorators/Entity.d.ts.map +1 -0
  13. package/dist/src/decorators/Entity.js +32 -0
  14. package/dist/src/decorators/Table.d.ts +22 -0
  15. package/dist/src/decorators/Table.d.ts.map +1 -0
  16. package/dist/src/decorators/Table.js +31 -0
  17. package/dist/src/decorators/attributes/Attribute.d.ts +26 -0
  18. package/dist/src/decorators/attributes/Attribute.d.ts.map +1 -0
  19. package/dist/src/decorators/attributes/Attribute.js +41 -0
  20. package/dist/src/decorators/attributes/DateAttribute.d.ts +25 -0
  21. package/dist/src/decorators/attributes/DateAttribute.d.ts.map +1 -0
  22. package/dist/src/decorators/attributes/DateAttribute.js +43 -0
  23. package/dist/src/decorators/attributes/DateNullableAttribute.d.ts +26 -0
  24. package/dist/src/decorators/attributes/DateNullableAttribute.d.ts.map +1 -0
  25. package/dist/src/decorators/attributes/DateNullableAttribute.js +43 -0
  26. package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts +25 -0
  27. package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts.map +1 -0
  28. package/dist/src/decorators/attributes/ForeignKeyAttribute.js +40 -0
  29. package/dist/src/decorators/attributes/NullableAttribute.d.ts +27 -0
  30. package/dist/src/decorators/attributes/NullableAttribute.d.ts.map +1 -0
  31. package/dist/src/decorators/attributes/NullableAttribute.js +41 -0
  32. package/dist/src/decorators/attributes/NullableForeignKeyAttribute.d.ts +25 -0
  33. package/dist/src/decorators/attributes/NullableForeignKeyAttribute.d.ts.map +1 -0
  34. package/dist/src/decorators/attributes/NullableForeignKeyAttribute.js +40 -0
  35. package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts +24 -0
  36. package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts.map +1 -0
  37. package/dist/src/decorators/attributes/PartitionKeyAttribute.js +38 -0
  38. package/dist/src/decorators/attributes/SortKeyAttribute.d.ts +24 -0
  39. package/dist/src/decorators/attributes/SortKeyAttribute.d.ts.map +1 -0
  40. package/dist/src/decorators/attributes/SortKeyAttribute.js +38 -0
  41. package/dist/src/decorators/attributes/index.d.ts +10 -0
  42. package/dist/src/decorators/attributes/index.d.ts.map +1 -0
  43. package/dist/src/decorators/attributes/index.js +37 -0
  44. package/dist/src/decorators/attributes/serializers.d.ts +13 -0
  45. package/dist/src/decorators/attributes/serializers.d.ts.map +1 -0
  46. package/dist/src/decorators/attributes/serializers.js +19 -0
  47. package/dist/src/decorators/index.d.ts +6 -0
  48. package/dist/src/decorators/index.d.ts.map +1 -0
  49. package/dist/src/decorators/index.js +27 -0
  50. package/dist/src/decorators/relationships/BelongsTo.d.ts +34 -0
  51. package/dist/src/decorators/relationships/BelongsTo.d.ts.map +1 -0
  52. package/dist/src/decorators/relationships/BelongsTo.js +50 -0
  53. package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts +80 -0
  54. package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts.map +1 -0
  55. package/dist/src/decorators/relationships/HasAndBelongsToMany.js +70 -0
  56. package/dist/src/decorators/relationships/HasMany.d.ts +35 -0
  57. package/dist/src/decorators/relationships/HasMany.d.ts.map +1 -0
  58. package/dist/src/decorators/relationships/HasMany.js +48 -0
  59. package/dist/src/decorators/relationships/HasOne.d.ts +35 -0
  60. package/dist/src/decorators/relationships/HasOne.d.ts.map +1 -0
  61. package/dist/src/decorators/relationships/HasOne.js +48 -0
  62. package/dist/src/decorators/relationships/index.d.ts +6 -0
  63. package/dist/src/decorators/relationships/index.d.ts.map +1 -0
  64. package/dist/src/decorators/relationships/index.js +29 -0
  65. package/dist/src/decorators/relationships/types.d.ts +11 -0
  66. package/dist/src/decorators/relationships/types.d.ts.map +1 -0
  67. package/dist/src/decorators/relationships/types.js +2 -0
  68. package/dist/src/decorators/types.d.ts +30 -0
  69. package/dist/src/decorators/types.d.ts.map +1 -0
  70. package/dist/src/decorators/types.js +2 -0
  71. package/dist/src/dynamo-utils/DynamoClient.d.ts +34 -0
  72. package/dist/src/dynamo-utils/DynamoClient.d.ts.map +1 -0
  73. package/dist/src/dynamo-utils/DynamoClient.js +57 -0
  74. package/dist/src/dynamo-utils/TransactGetBuilder.d.ts +18 -0
  75. package/dist/src/dynamo-utils/TransactGetBuilder.d.ts.map +1 -0
  76. package/dist/src/dynamo-utils/TransactGetBuilder.js +32 -0
  77. package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts +46 -0
  78. package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts.map +1 -0
  79. package/dist/src/dynamo-utils/TransactWriteBuilder.js +100 -0
  80. package/dist/src/dynamo-utils/errors.d.ts +13 -0
  81. package/dist/src/dynamo-utils/errors.d.ts.map +1 -0
  82. package/dist/src/dynamo-utils/errors.js +17 -0
  83. package/dist/src/dynamo-utils/index.d.ts +8 -0
  84. package/dist/src/dynamo-utils/index.d.ts.map +1 -0
  85. package/dist/src/dynamo-utils/index.js +30 -0
  86. package/dist/src/dynamo-utils/types.d.ts +52 -0
  87. package/dist/src/dynamo-utils/types.d.ts.map +1 -0
  88. package/dist/src/dynamo-utils/types.js +2 -0
  89. package/dist/src/errors.d.ts +13 -0
  90. package/dist/src/errors.d.ts.map +1 -0
  91. package/dist/src/errors.js +17 -0
  92. package/dist/src/index.d.ts +6 -0
  93. package/dist/src/index.d.ts.map +1 -0
  94. package/dist/src/index.js +24 -0
  95. package/dist/src/metadata/AttributeMetadata.d.ts +22 -0
  96. package/dist/src/metadata/AttributeMetadata.d.ts.map +1 -0
  97. package/dist/src/metadata/AttributeMetadata.js +27 -0
  98. package/dist/src/metadata/EntityMetadata.d.ts +42 -0
  99. package/dist/src/metadata/EntityMetadata.d.ts.map +1 -0
  100. package/dist/src/metadata/EntityMetadata.js +49 -0
  101. package/dist/src/metadata/JoinTableMetadata.d.ts +23 -0
  102. package/dist/src/metadata/JoinTableMetadata.d.ts.map +1 -0
  103. package/dist/src/metadata/JoinTableMetadata.js +22 -0
  104. package/dist/src/metadata/MetadataStorage.d.ts +104 -0
  105. package/dist/src/metadata/MetadataStorage.d.ts.map +1 -0
  106. package/dist/src/metadata/MetadataStorage.js +194 -0
  107. package/dist/src/metadata/TableMetadata.d.ts +53 -0
  108. package/dist/src/metadata/TableMetadata.d.ts.map +1 -0
  109. package/dist/src/metadata/TableMetadata.js +100 -0
  110. package/dist/src/metadata/index.d.ts +13 -0
  111. package/dist/src/metadata/index.d.ts.map +1 -0
  112. package/dist/src/metadata/index.js +34 -0
  113. package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts +18 -0
  114. package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts.map +1 -0
  115. package/dist/src/metadata/relationship-metadata/BelongsToRelationship.js +26 -0
  116. package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts +16 -0
  117. package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts.map +1 -0
  118. package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.js +25 -0
  119. package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts +18 -0
  120. package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts.map +1 -0
  121. package/dist/src/metadata/relationship-metadata/HasManyRelationship.js +26 -0
  122. package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts +17 -0
  123. package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts.map +1 -0
  124. package/dist/src/metadata/relationship-metadata/HasOneRelationship.js +25 -0
  125. package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts +21 -0
  126. package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts.map +1 -0
  127. package/dist/src/metadata/relationship-metadata/RelationshipMetadata.js +18 -0
  128. package/dist/src/metadata/relationship-metadata/index.d.ts +7 -0
  129. package/dist/src/metadata/relationship-metadata/index.d.ts.map +1 -0
  130. package/dist/src/metadata/relationship-metadata/index.js +29 -0
  131. package/dist/src/metadata/relationship-metadata/types.d.ts +16 -0
  132. package/dist/src/metadata/relationship-metadata/types.d.ts.map +1 -0
  133. package/dist/src/metadata/relationship-metadata/types.js +2 -0
  134. package/dist/src/metadata/relationship-metadata/utils.d.ts +3 -0
  135. package/dist/src/metadata/relationship-metadata/utils.d.ts.map +1 -0
  136. package/dist/src/metadata/relationship-metadata/utils.js +25 -0
  137. package/dist/src/metadata/types.d.ts +90 -0
  138. package/dist/src/metadata/types.d.ts.map +1 -0
  139. package/dist/src/metadata/types.js +2 -0
  140. package/dist/src/metadata/utils.d.ts +42 -0
  141. package/dist/src/metadata/utils.d.ts.map +1 -0
  142. package/dist/src/metadata/utils.js +67 -0
  143. package/dist/src/operations/Create/Create.d.ts +39 -0
  144. package/dist/src/operations/Create/Create.d.ts.map +1 -0
  145. package/dist/src/operations/Create/Create.js +84 -0
  146. package/dist/src/operations/Create/index.d.ts +3 -0
  147. package/dist/src/operations/Create/index.d.ts.map +1 -0
  148. package/dist/src/operations/Create/index.js +23 -0
  149. package/dist/src/operations/Create/types.d.ts +7 -0
  150. package/dist/src/operations/Create/types.d.ts.map +1 -0
  151. package/dist/src/operations/Create/types.js +2 -0
  152. package/dist/src/operations/Delete/Delete.d.ts +74 -0
  153. package/dist/src/operations/Delete/Delete.d.ts.map +1 -0
  154. package/dist/src/operations/Delete/Delete.js +207 -0
  155. package/dist/src/operations/Delete/index.d.ts +2 -0
  156. package/dist/src/operations/Delete/index.d.ts.map +1 -0
  157. package/dist/src/operations/Delete/index.js +8 -0
  158. package/dist/src/operations/Delete/types.d.ts +7 -0
  159. package/dist/src/operations/Delete/types.d.ts.map +1 -0
  160. package/dist/src/operations/Delete/types.js +2 -0
  161. package/dist/src/operations/FindById/FindById.d.ts +91 -0
  162. package/dist/src/operations/FindById/FindById.d.ts.map +1 -0
  163. package/dist/src/operations/FindById/FindById.js +244 -0
  164. package/dist/src/operations/FindById/index.d.ts +3 -0
  165. package/dist/src/operations/FindById/index.d.ts.map +1 -0
  166. package/dist/src/operations/FindById/index.js +23 -0
  167. package/dist/src/operations/FindById/types.d.ts +57 -0
  168. package/dist/src/operations/FindById/types.d.ts.map +1 -0
  169. package/dist/src/operations/FindById/types.js +2 -0
  170. package/dist/src/operations/OperationBase.d.ts +37 -0
  171. package/dist/src/operations/OperationBase.d.ts.map +1 -0
  172. package/dist/src/operations/OperationBase.js +44 -0
  173. package/dist/src/operations/Query/Query.d.ts +45 -0
  174. package/dist/src/operations/Query/Query.d.ts.map +1 -0
  175. package/dist/src/operations/Query/Query.js +84 -0
  176. package/dist/src/operations/Query/index.d.ts +3 -0
  177. package/dist/src/operations/Query/index.d.ts.map +1 -0
  178. package/dist/src/operations/Query/index.js +23 -0
  179. package/dist/src/operations/Query/types.d.ts +38 -0
  180. package/dist/src/operations/Query/types.d.ts.map +1 -0
  181. package/dist/src/operations/Query/types.js +2 -0
  182. package/dist/src/operations/Update/Update.d.ts +48 -0
  183. package/dist/src/operations/Update/Update.d.ts.map +1 -0
  184. package/dist/src/operations/Update/Update.js +118 -0
  185. package/dist/src/operations/Update/index.d.ts +3 -0
  186. package/dist/src/operations/Update/index.d.ts.map +1 -0
  187. package/dist/src/operations/Update/index.js +23 -0
  188. package/dist/src/operations/Update/types.d.ts +32 -0
  189. package/dist/src/operations/Update/types.d.ts.map +1 -0
  190. package/dist/src/operations/Update/types.js +2 -0
  191. package/dist/src/operations/index.d.ts +7 -0
  192. package/dist/src/operations/index.d.ts.map +1 -0
  193. package/dist/src/operations/index.js +22 -0
  194. package/dist/src/operations/types.d.ts +59 -0
  195. package/dist/src/operations/types.d.ts.map +1 -0
  196. package/dist/src/operations/types.js +2 -0
  197. package/dist/src/operations/utils/RelationshipTransactions.d.ts +64 -0
  198. package/dist/src/operations/utils/RelationshipTransactions.d.ts.map +1 -0
  199. package/dist/src/operations/utils/RelationshipTransactions.js +125 -0
  200. package/dist/src/operations/utils/expressionBuilder.d.ts +9 -0
  201. package/dist/src/operations/utils/expressionBuilder.d.ts.map +1 -0
  202. package/dist/src/operations/utils/expressionBuilder.js +106 -0
  203. package/dist/src/operations/utils/index.d.ts +5 -0
  204. package/dist/src/operations/utils/index.d.ts.map +1 -0
  205. package/dist/src/operations/utils/index.js +25 -0
  206. package/dist/src/operations/utils/types.d.ts +21 -0
  207. package/dist/src/operations/utils/types.d.ts.map +1 -0
  208. package/dist/src/operations/utils/types.js +2 -0
  209. package/dist/src/operations/utils/utils.d.ts +19 -0
  210. package/dist/src/operations/utils/utils.d.ts.map +1 -0
  211. package/dist/src/operations/utils/utils.js +36 -0
  212. package/dist/src/query-utils/Filters.d.ts +10 -0
  213. package/dist/src/query-utils/Filters.d.ts.map +1 -0
  214. package/dist/src/query-utils/Filters.js +25 -0
  215. package/dist/src/query-utils/QueryBuilder.d.ts +90 -0
  216. package/dist/src/query-utils/QueryBuilder.d.ts.map +1 -0
  217. package/dist/src/query-utils/QueryBuilder.js +213 -0
  218. package/dist/src/query-utils/index.d.ts +3 -0
  219. package/dist/src/query-utils/index.d.ts.map +1 -0
  220. package/dist/src/query-utils/index.js +23 -0
  221. package/dist/src/query-utils/types.d.ts +89 -0
  222. package/dist/src/query-utils/types.d.ts.map +1 -0
  223. package/dist/src/query-utils/types.js +2 -0
  224. package/dist/src/relationships/BelongsToLink.d.ts +50 -0
  225. package/dist/src/relationships/BelongsToLink.d.ts.map +1 -0
  226. package/dist/src/relationships/BelongsToLink.js +57 -0
  227. package/dist/src/relationships/JoinTable.d.ts +68 -0
  228. package/dist/src/relationships/JoinTable.d.ts.map +1 -0
  229. package/dist/src/relationships/JoinTable.js +133 -0
  230. package/dist/src/relationships/index.d.ts +3 -0
  231. package/dist/src/relationships/index.d.ts.map +1 -0
  232. package/dist/src/relationships/index.js +10 -0
  233. package/dist/src/types.d.ts +73 -0
  234. package/dist/src/types.d.ts.map +1 -0
  235. package/dist/src/types.js +2 -0
  236. package/dist/src/utils.d.ts +89 -0
  237. package/dist/src/utils.d.ts.map +1 -0
  238. package/dist/src/utils.js +168 -0
  239. package/package.json +61 -0
@@ -0,0 +1,168 @@
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.safeAssign = exports.isString = exports.isPropertyKey = exports.chunkArray = exports.isBelongsToLinkDynamoItem = exports.isKeyOfObject = exports.isKeyOfEntity = exports.tableItemToBelongsToLink = exports.tableItemToEntity = exports.entityToTableItem = void 0;
7
+ const metadata_1 = __importDefault(require("./metadata"));
8
+ const relationships_1 = require("./relationships");
9
+ /**
10
+ * Convert an entity to its aliased table item fields to for dynamo interactions
11
+ * @param entityClassName
12
+ * @param entityData
13
+ * @returns
14
+ */
15
+ const entityToTableItem = (EntityClass, entityData) => {
16
+ const attributesMeta = metadata_1.default.getEntityAttributes(EntityClass.name);
17
+ return Object.entries(entityData).reduce((acc, [key, val]) => {
18
+ const attrMeta = attributesMeta[key];
19
+ if (attrMeta !== undefined) {
20
+ const { alias, serializers } = attrMeta;
21
+ // If the attribute has a custom serializer, serialize it
22
+ const value = serializers === undefined ? val : serializers.toTableAttribute(val);
23
+ acc[alias] = value;
24
+ }
25
+ return acc;
26
+ }, {});
27
+ };
28
+ exports.entityToTableItem = entityToTableItem;
29
+ /**
30
+ * Serialize a table item to its associated Entity class, using the class attribute property names
31
+ * @param EntityClass
32
+ * @param tableItem
33
+ * @returns
34
+ */
35
+ const tableItemToEntity = (EntityClass, tableItem) => {
36
+ const tableAttributes = metadata_1.default.getEntityTableAttributes(EntityClass.name);
37
+ const entity = new EntityClass();
38
+ Object.keys(tableItem).forEach(attrName => {
39
+ const attrMeta = tableAttributes[attrName];
40
+ if (attrMeta !== undefined) {
41
+ const { name: entityKey, serializers } = attrMeta;
42
+ if ((0, exports.isKeyOfEntity)(entity, entityKey)) {
43
+ const rawVal = tableItem[attrName];
44
+ const val = serializers?.toEntityAttribute === undefined
45
+ ? rawVal
46
+ : serializers?.toEntityAttribute(rawVal);
47
+ (0, exports.safeAssign)(entity, entityKey, val);
48
+ }
49
+ }
50
+ });
51
+ return entity;
52
+ };
53
+ exports.tableItemToEntity = tableItemToEntity;
54
+ /**
55
+ * Serialize a dynamo table item response to a BelongsToLink
56
+ * @param tableMeta - Table metadata
57
+ * @param tableItem - Table item from dynamo response
58
+ * @returns - { @link BelongsToLink }
59
+ */
60
+ const tableItemToBelongsToLink = (tableMeta, tableItem) => {
61
+ const link = new relationships_1.BelongsToLink();
62
+ const belongsToLinkAttrs = {
63
+ ...{
64
+ [tableMeta.partitionKeyAttribute.alias]: tableMeta.partitionKeyAttribute
65
+ },
66
+ ...{ [tableMeta.sortKeyAttribute.alias]: tableMeta.sortKeyAttribute },
67
+ ...tableMeta.defaultTableAttributes
68
+ };
69
+ Object.keys(tableItem).forEach(attrName => {
70
+ const attrMeta = belongsToLinkAttrs[attrName];
71
+ if (attrMeta !== undefined) {
72
+ const { name: entityKey, serializers } = attrMeta;
73
+ const rawVal = tableItem[attrName];
74
+ const val = serializers?.toEntityAttribute === undefined
75
+ ? rawVal
76
+ : serializers?.toEntityAttribute(rawVal);
77
+ (0, exports.safeAssign)(link, entityKey, val);
78
+ }
79
+ });
80
+ return link;
81
+ };
82
+ exports.tableItemToBelongsToLink = tableItemToBelongsToLink;
83
+ /**
84
+ * Type guard to check if the key is defined on the entity
85
+ */
86
+ const isKeyOfEntity = (entity, key) => {
87
+ return key in entity;
88
+ };
89
+ exports.isKeyOfEntity = isKeyOfEntity;
90
+ /**
91
+ * Type guard to check if the key is a defined property on the entity
92
+ * @param entity
93
+ * @param key
94
+ * @returns
95
+ */
96
+ const isKeyOfObject = (entity, key) => {
97
+ return key in entity;
98
+ };
99
+ exports.isKeyOfObject = isKeyOfObject;
100
+ /**
101
+ * Type guard to check if the DynamoTableItem is a BelongsToLink
102
+ * @param res DynamoTableItem
103
+ * @returns boolean
104
+ */
105
+ const isBelongsToLinkDynamoItem = (res, tableMeta) => {
106
+ return res[tableMeta.defaultAttributes.type.alias] === relationships_1.BelongsToLink.name;
107
+ };
108
+ exports.isBelongsToLinkDynamoItem = isBelongsToLinkDynamoItem;
109
+ /**
110
+ * Break an array into chunks
111
+ * @param array
112
+ * @param size
113
+ * @returns Array split into chunks of given size
114
+ */
115
+ const chunkArray = (array, size) => {
116
+ return Array.from({ length: Math.ceil(array.length / size) }, (_, index) => array.slice(index * size, (index + 1) * size));
117
+ };
118
+ exports.chunkArray = chunkArray;
119
+ /**
120
+ * Checks if a value is a valid property key (string, number, or symbol).
121
+ *
122
+ * @param value The value to be checked. This can be of any type.
123
+ * @returns `true` if the value is a `string`, `number`, or `symbol` (i.e., a valid property key); otherwise, `false`.
124
+ *
125
+ * @example
126
+ * Logger.log(isPropertyKey('test')); // true
127
+ * Logger.log(isPropertyKey(123)); // true
128
+ * Logger.log(isPropertyKey(Symbol('sym'))); // true
129
+ * Logger.log(isPropertyKey({})); // false
130
+ */
131
+ const isPropertyKey = (value) => {
132
+ return (typeof value === "string" ||
133
+ typeof value === "number" ||
134
+ typeof value === "symbol");
135
+ };
136
+ exports.isPropertyKey = isPropertyKey;
137
+ /**
138
+ * Checks if the given value is a string.
139
+ *
140
+ * @param value - The value to check. This can be any type as the function is meant to validate if it's a string.
141
+ * @returns `true` if `value` is a string; otherwise, `false`.
142
+ */
143
+ const isString = (value) => {
144
+ return typeof value === "string";
145
+ };
146
+ exports.isString = isString;
147
+ /**
148
+ * Safely assigns a value to a property of an object.
149
+ * It's useful for dynamically assigning properties to objects where the property names might be known but the types could vary.
150
+ *
151
+ * @template TObject - The object type to which the property belongs.
152
+ * @template TKey - The type of the keys of `TObject`
153
+ * @template TValue - The value to be assigned.
154
+ *
155
+ * @param {TObject} object - The target object to which the property will be assigned.
156
+ * @param {TKey} key - The property name under which the value should be assigned. Must be a key of `TObject`.
157
+ * @param {TValue} value - The value to assign to the property on the object.
158
+ *
159
+ * @returns {void} - This function does not return a value; it performs the assignment operation directly on the passed object.
160
+ *
161
+ * @example
162
+ * let entity = { id: "123" };
163
+ * safeAssign(entity, "name", "Jane Doe");
164
+ */
165
+ const safeAssign = (object, key, value) => {
166
+ object[key] = value;
167
+ };
168
+ exports.safeAssign = safeAssign;
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "dyna-record",
3
+ "version": "0.0.1",
4
+ "description": "Typescript Object Relational Mapper (ORM) for Dynamo",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "watch": "tsc -w",
10
+ "test": "jest",
11
+ "eslint": "npx eslint . --ext .ts",
12
+ "eslint-fix": "npx eslint . --ext .ts --fix",
13
+ "prettier": "npx prettier . --write",
14
+ "docs": "npx typedoc"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/dsdavis4/dyna-record.git"
19
+ },
20
+ "author": "dsdavis4",
21
+ "license": "MIT",
22
+ "bugs": {
23
+ "url": "https://github.com/dsdavis4/dyna-record/issues"
24
+ },
25
+ "homepage": "https://github.com/dsdavis4/dyna-record#readme",
26
+ "dependencies": {
27
+ "@aws-sdk/client-dynamodb": "^3.502.0",
28
+ "@aws-sdk/lib-dynamodb": "^3.502.0",
29
+ "@aws-sdk/util-dynamodb": "^3.509.0",
30
+ "uuid": "^9.0.1"
31
+ },
32
+ "devDependencies": {
33
+ "@aws-sdk/types": "^3.502.0",
34
+ "@tsconfig/recommended": "^1.0.3",
35
+ "@types/jest": "^29.5.12",
36
+ "@types/node": "^20.11.16",
37
+ "@types/uuid": "^9.0.8",
38
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
39
+ "@typescript-eslint/parser": "^6.21.0",
40
+ "eslint": "^8.56.0",
41
+ "eslint-config-prettier": "^9.1.0",
42
+ "eslint-config-standard-with-typescript": "^43.0.1",
43
+ "eslint-plugin-import": "^2.29.1",
44
+ "eslint-plugin-n": "^16.6.2",
45
+ "eslint-plugin-promise": "^6.1.1",
46
+ "jest": "^29.7.0",
47
+ "prettier": "^3.2.5",
48
+ "ts-jest": "^29.1.2",
49
+ "ts-node": "^10.9.2",
50
+ "typedoc": "^0.25.12",
51
+ "typedoc-plugin-missing-exports": "^2.2.0",
52
+ "typescript": "^5.3.3"
53
+ },
54
+ "engines": {
55
+ "npm": ">=10.0.0",
56
+ "node": ">=18.0.0"
57
+ },
58
+ "files": [
59
+ "dist/**/*"
60
+ ]
61
+ }