@webiny/db-dynamodb 0.0.0-unstable.b14eaecf38 → 0.0.0-unstable.b6d7105cee

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 (258) hide show
  1. package/DynamoDbDriver.d.ts +18 -32
  2. package/DynamoDbDriver.js +216 -227
  3. package/DynamoDbDriver.js.map +1 -1
  4. package/README.md +6 -62
  5. package/exports/api/db.d.ts +3 -0
  6. package/exports/api/db.js +3 -0
  7. package/feature/DynamoDBClient/DynamoDBClient.d.ts +9 -0
  8. package/feature/DynamoDBClient/DynamoDBClient.js +8 -0
  9. package/feature/DynamoDBClient/DynamoDBClient.js.map +1 -0
  10. package/feature/DynamoDBClient/abstractions.d.ts +8 -0
  11. package/feature/DynamoDBClient/abstractions.js +5 -0
  12. package/feature/DynamoDBClient/abstractions.js.map +1 -0
  13. package/feature/DynamoDBClient/index.d.ts +6 -0
  14. package/feature/DynamoDBClient/index.js +15 -0
  15. package/feature/DynamoDBClient/index.js.map +1 -0
  16. package/feature/FilterUtil/FilterUtil.d.ts +11 -0
  17. package/feature/FilterUtil/FilterUtil.js +26 -0
  18. package/feature/FilterUtil/FilterUtil.js.map +1 -0
  19. package/feature/FilterUtil/abstractions/FilterUtil.d.ts +17 -0
  20. package/feature/FilterUtil/abstractions/FilterUtil.js +5 -0
  21. package/feature/FilterUtil/abstractions/FilterUtil.js.map +1 -0
  22. package/feature/FilterUtil/createFilters.d.ts +22 -0
  23. package/feature/FilterUtil/createFilters.js +92 -0
  24. package/feature/FilterUtil/createFilters.js.map +1 -0
  25. package/feature/FilterUtil/extractWhereArgs.d.ts +7 -0
  26. package/feature/FilterUtil/extractWhereArgs.js +20 -0
  27. package/feature/FilterUtil/extractWhereArgs.js.map +1 -0
  28. package/feature/FilterUtil/feature.d.ts +4 -0
  29. package/feature/FilterUtil/feature.js +11 -0
  30. package/feature/FilterUtil/feature.js.map +1 -0
  31. package/feature/FilterUtil/index.d.ts +2 -0
  32. package/feature/FilterUtil/index.js +2 -0
  33. package/feature/ValueFilter/index.d.ts +3 -0
  34. package/feature/ValueFilter/index.js +1 -0
  35. package/index.d.ts +10 -3
  36. package/index.js +14 -35
  37. package/index.js.map +1 -1
  38. package/package.json +32 -30
  39. package/plugins/definitions/DateTimeTransformPlugin.d.ts +2 -1
  40. package/plugins/definitions/DateTimeTransformPlugin.js +22 -37
  41. package/plugins/definitions/DateTimeTransformPlugin.js.map +1 -1
  42. package/plugins/definitions/FieldPlugin.d.ts +2 -2
  43. package/plugins/definitions/FieldPlugin.js +37 -53
  44. package/plugins/definitions/FieldPlugin.js.map +1 -1
  45. package/plugins/definitions/TimeTransformPlugin.d.ts +2 -1
  46. package/plugins/definitions/TimeTransformPlugin.js +30 -43
  47. package/plugins/definitions/TimeTransformPlugin.js.map +1 -1
  48. package/plugins/definitions/ValueTransformPlugin.d.ts +2 -7
  49. package/plugins/definitions/ValueTransformPlugin.js +21 -34
  50. package/plugins/definitions/ValueTransformPlugin.js.map +1 -1
  51. package/plugins/definitions/assignFields.js +16 -26
  52. package/plugins/definitions/assignFields.js.map +1 -1
  53. package/plugins/index.d.ts +5 -2
  54. package/plugins/index.js +5 -15
  55. package/store/entity.d.ts +6 -0
  56. package/store/entity.js +8 -0
  57. package/store/entity.js.map +1 -0
  58. package/store/keys.d.ts +6 -0
  59. package/store/keys.js +9 -0
  60. package/store/keys.js.map +1 -0
  61. package/store/types.d.ts +6 -0
  62. package/store/types.js +0 -0
  63. package/toolbox.d.ts +60 -0
  64. package/toolbox.js +1 -0
  65. package/types.d.ts +3 -24
  66. package/types.js +0 -5
  67. package/utils/batch/batchRead.d.ts +15 -0
  68. package/utils/batch/batchRead.js +45 -0
  69. package/utils/batch/batchRead.js.map +1 -0
  70. package/utils/batch/batchWrite.d.ts +13 -0
  71. package/utils/batch/batchWrite.js +39 -0
  72. package/utils/batch/batchWrite.js.map +1 -0
  73. package/utils/batch/index.d.ts +3 -0
  74. package/utils/batch/index.js +3 -0
  75. package/utils/batch/types.d.ts +30 -0
  76. package/utils/batch/types.js +0 -0
  77. package/utils/cleanup.d.ts +3 -3
  78. package/utils/cleanup.js +36 -31
  79. package/utils/cleanup.js.map +1 -1
  80. package/utils/count.d.ts +2 -0
  81. package/utils/count.js +11 -0
  82. package/utils/count.js.map +1 -0
  83. package/utils/createEntity.d.ts +36 -0
  84. package/utils/createEntity.js +82 -0
  85. package/utils/createEntity.js.map +1 -0
  86. package/utils/createTable.d.ts +11 -0
  87. package/utils/createTable.js +29 -0
  88. package/utils/createTable.js.map +1 -0
  89. package/utils/cursor.js +9 -18
  90. package/utils/cursor.js.map +1 -1
  91. package/utils/delete.d.ts +10 -0
  92. package/utils/delete.js +9 -0
  93. package/utils/delete.js.map +1 -0
  94. package/utils/entity/Entity.d.ts +28 -0
  95. package/utils/entity/Entity.js +95 -0
  96. package/utils/entity/Entity.js.map +1 -0
  97. package/utils/entity/EntityReadBatch.d.ts +18 -0
  98. package/utils/entity/EntityReadBatch.js +31 -0
  99. package/utils/entity/EntityReadBatch.js.map +1 -0
  100. package/utils/entity/EntityReadBatchBuilder.d.ts +10 -0
  101. package/utils/entity/EntityReadBatchBuilder.js +18 -0
  102. package/utils/entity/EntityReadBatchBuilder.js.map +1 -0
  103. package/utils/entity/EntityWriteBatch.d.ts +23 -0
  104. package/utils/entity/EntityWriteBatch.js +44 -0
  105. package/utils/entity/EntityWriteBatch.js.map +1 -0
  106. package/utils/entity/EntityWriteBatchBuilder.d.ts +11 -0
  107. package/utils/entity/EntityWriteBatchBuilder.js +19 -0
  108. package/utils/entity/EntityWriteBatchBuilder.js.map +1 -0
  109. package/utils/entity/getEntity.d.ts +4 -0
  110. package/utils/entity/getEntity.js +11 -0
  111. package/utils/entity/getEntity.js.map +1 -0
  112. package/utils/entity/index.d.ts +7 -0
  113. package/utils/entity/index.js +7 -0
  114. package/utils/entity/types.d.ts +75 -0
  115. package/utils/entity/types.js +0 -0
  116. package/utils/get.d.ts +8 -6
  117. package/utils/get.js +16 -25
  118. package/utils/get.js.map +1 -1
  119. package/utils/index.d.ts +13 -0
  120. package/utils/index.js +13 -0
  121. package/utils/put.d.ts +12 -0
  122. package/utils/put.js +10 -0
  123. package/utils/put.js.map +1 -0
  124. package/utils/query.d.ts +15 -14
  125. package/utils/query.js +83 -107
  126. package/utils/query.js.map +1 -1
  127. package/utils/scan.d.ts +38 -0
  128. package/utils/scan.js +56 -0
  129. package/utils/scan.js.map +1 -0
  130. package/utils/sort.d.ts +1 -1
  131. package/utils/sort.js +39 -68
  132. package/utils/sort.js.map +1 -1
  133. package/utils/table/Table.d.ts +10 -0
  134. package/utils/table/Table.js +28 -0
  135. package/utils/table/Table.js.map +1 -0
  136. package/utils/table/TableReadBatch.d.ts +19 -0
  137. package/utils/table/TableReadBatch.js +46 -0
  138. package/utils/table/TableReadBatch.js.map +1 -0
  139. package/utils/table/TableWriteBatch.d.ts +21 -0
  140. package/utils/table/TableWriteBatch.js +52 -0
  141. package/utils/table/TableWriteBatch.js.map +1 -0
  142. package/utils/table/index.d.ts +4 -0
  143. package/utils/table/index.js +4 -0
  144. package/utils/table/types.d.ts +39 -0
  145. package/utils/table/types.js +0 -0
  146. package/BatchProcess.d.ts +0 -47
  147. package/BatchProcess.js +0 -164
  148. package/BatchProcess.js.map +0 -1
  149. package/QueryGenerator.d.ts +0 -21
  150. package/QueryGenerator.js +0 -64
  151. package/QueryGenerator.js.map +0 -1
  152. package/operators/comparison/beginsWith.d.ts +0 -3
  153. package/operators/comparison/beginsWith.js +0 -24
  154. package/operators/comparison/beginsWith.js.map +0 -1
  155. package/operators/comparison/between.d.ts +0 -3
  156. package/operators/comparison/between.js +0 -30
  157. package/operators/comparison/between.js.map +0 -1
  158. package/operators/comparison/eq.d.ts +0 -3
  159. package/operators/comparison/eq.js +0 -32
  160. package/operators/comparison/eq.js.map +0 -1
  161. package/operators/comparison/gt.d.ts +0 -3
  162. package/operators/comparison/gt.js +0 -24
  163. package/operators/comparison/gt.js.map +0 -1
  164. package/operators/comparison/gte.d.ts +0 -3
  165. package/operators/comparison/gte.js +0 -24
  166. package/operators/comparison/gte.js.map +0 -1
  167. package/operators/comparison/lt.d.ts +0 -3
  168. package/operators/comparison/lt.js +0 -24
  169. package/operators/comparison/lt.js.map +0 -1
  170. package/operators/comparison/lte.d.ts +0 -3
  171. package/operators/comparison/lte.js +0 -24
  172. package/operators/comparison/lte.js.map +0 -1
  173. package/operators/index.d.ts +0 -12
  174. package/operators/index.js +0 -28
  175. package/operators/index.js.map +0 -1
  176. package/operators/logical/and.d.ts +0 -3
  177. package/operators/logical/and.js +0 -58
  178. package/operators/logical/and.js.map +0 -1
  179. package/operators/logical/or.d.ts +0 -3
  180. package/operators/logical/or.js +0 -58
  181. package/operators/logical/or.js.map +0 -1
  182. package/plugins/definitions/AttributePlugin.d.ts +0 -20
  183. package/plugins/definitions/AttributePlugin.js +0 -48
  184. package/plugins/definitions/AttributePlugin.js.map +0 -1
  185. package/plugins/definitions/FieldPathPlugin.d.ts +0 -22
  186. package/plugins/definitions/FieldPathPlugin.js +0 -34
  187. package/plugins/definitions/FieldPathPlugin.js.map +0 -1
  188. package/plugins/definitions/NumberTransformPlugin.d.ts +0 -4
  189. package/plugins/definitions/NumberTransformPlugin.js +0 -34
  190. package/plugins/definitions/NumberTransformPlugin.js.map +0 -1
  191. package/plugins/definitions/ValueFilterPlugin.d.ts +0 -20
  192. package/plugins/definitions/ValueFilterPlugin.js +0 -37
  193. package/plugins/definitions/ValueFilterPlugin.js.map +0 -1
  194. package/plugins/filters/andIn.d.ts +0 -3
  195. package/plugins/filters/andIn.js +0 -30
  196. package/plugins/filters/andIn.js.map +0 -1
  197. package/plugins/filters/between.d.ts +0 -3
  198. package/plugins/filters/between.js +0 -31
  199. package/plugins/filters/between.js.map +0 -1
  200. package/plugins/filters/contains.d.ts +0 -3
  201. package/plugins/filters/contains.js +0 -29
  202. package/plugins/filters/contains.js.map +0 -1
  203. package/plugins/filters/eq.d.ts +0 -3
  204. package/plugins/filters/eq.js +0 -31
  205. package/plugins/filters/eq.js.map +0 -1
  206. package/plugins/filters/fuzzy.d.ts +0 -3
  207. package/plugins/filters/fuzzy.js +0 -26
  208. package/plugins/filters/fuzzy.js.map +0 -1
  209. package/plugins/filters/gt.d.ts +0 -3
  210. package/plugins/filters/gt.js +0 -19
  211. package/plugins/filters/gt.js.map +0 -1
  212. package/plugins/filters/gte.d.ts +0 -3
  213. package/plugins/filters/gte.js +0 -19
  214. package/plugins/filters/gte.js.map +0 -1
  215. package/plugins/filters/in.d.ts +0 -3
  216. package/plugins/filters/in.js +0 -30
  217. package/plugins/filters/in.js.map +0 -1
  218. package/plugins/filters/index.d.ts +0 -2
  219. package/plugins/filters/index.js +0 -20
  220. package/plugins/filters/index.js.map +0 -1
  221. package/plugins/filters/lt.d.ts +0 -3
  222. package/plugins/filters/lt.js +0 -19
  223. package/plugins/filters/lt.js.map +0 -1
  224. package/plugins/filters/lte.d.ts +0 -3
  225. package/plugins/filters/lte.js +0 -19
  226. package/plugins/filters/lte.js.map +0 -1
  227. package/plugins/filters/startsWith.d.ts +0 -3
  228. package/plugins/filters/startsWith.js +0 -29
  229. package/plugins/filters/startsWith.js.map +0 -1
  230. package/plugins/index.js.map +0 -1
  231. package/statements/createKeyConditionExpressionArgs.d.ts +0 -15
  232. package/statements/createKeyConditionExpressionArgs.js +0 -45
  233. package/statements/createKeyConditionExpressionArgs.js.map +0 -1
  234. package/statements/processStatement.d.ts +0 -3
  235. package/statements/processStatement.js +0 -35
  236. package/statements/processStatement.js.map +0 -1
  237. package/types.js.map +0 -1
  238. package/utils/attributes.d.ts +0 -10
  239. package/utils/attributes.js +0 -24
  240. package/utils/attributes.js.map +0 -1
  241. package/utils/batchRead.d.ts +0 -15
  242. package/utils/batchRead.js +0 -67
  243. package/utils/batchRead.js.map +0 -1
  244. package/utils/batchWrite.d.ts +0 -17
  245. package/utils/batchWrite.js +0 -24
  246. package/utils/batchWrite.js.map +0 -1
  247. package/utils/createStandardEntity.d.ts +0 -2
  248. package/utils/createStandardEntity.js +0 -34
  249. package/utils/createStandardEntity.js.map +0 -1
  250. package/utils/filter.d.ts +0 -12
  251. package/utils/filter.js +0 -176
  252. package/utils/filter.js.map +0 -1
  253. package/utils/listResponse.d.ts +0 -13
  254. package/utils/listResponse.js +0 -29
  255. package/utils/listResponse.js.map +0 -1
  256. package/utils/table.d.ts +0 -7
  257. package/utils/table.js +0 -22
  258. package/utils/table.js.map +0 -1
@@ -0,0 +1,9 @@
1
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
+ import type { DynamoDBClient as Abstraction } from "./abstractions.js";
3
+ export interface IDynamoDBClientParams {
4
+ client: DynamoDBDocument;
5
+ }
6
+ export declare class DynamoDBClient implements Abstraction.Interface {
7
+ readonly client: DynamoDBDocument;
8
+ constructor(params: IDynamoDBClientParams);
9
+ }
@@ -0,0 +1,8 @@
1
+ class DynamoDBClient {
2
+ constructor(params){
3
+ this.client = params.client;
4
+ }
5
+ }
6
+ export { DynamoDBClient };
7
+
8
+ //# sourceMappingURL=DynamoDBClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/DynamoDBClient/DynamoDBClient.js","sources":["../../../src/feature/DynamoDBClient/DynamoDBClient.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { DynamoDBClient as Abstraction } from \"./abstractions.js\";\n\nexport interface IDynamoDBClientParams {\n client: DynamoDBDocument;\n}\n\nexport class DynamoDBClient implements Abstraction.Interface {\n public readonly client: DynamoDBDocument;\n\n public constructor(params: IDynamoDBClientParams) {\n this.client = params.client;\n }\n}\n"],"names":["DynamoDBClient","params"],"mappings":"AAOO,MAAMA;IAGT,YAAmBC,MAA6B,CAAE;QAC9C,IAAI,CAAC,MAAM,GAAGA,OAAO,MAAM;IAC/B;AACJ"}
@@ -0,0 +1,8 @@
1
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
+ export interface IDynamoDBClient {
3
+ readonly client: DynamoDBDocument;
4
+ }
5
+ export declare const DynamoDBClient: import("@webiny/di").Abstraction<IDynamoDBClient>;
6
+ export declare namespace DynamoDBClient {
7
+ type Interface = IDynamoDBClient;
8
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const DynamoDBClient = createAbstraction("Db/DynamoDB/DynamoDBClient");
3
+ export { DynamoDBClient };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/DynamoDBClient/abstractions.js","sources":["../../../src/feature/DynamoDBClient/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\n\nexport interface IDynamoDBClient {\n readonly client: DynamoDBDocument;\n}\n\nexport const DynamoDBClient = createAbstraction<IDynamoDBClient>(\"Db/DynamoDB/DynamoDBClient\");\n\nexport namespace DynamoDBClient {\n export type Interface = IDynamoDBClient;\n}\n"],"names":["DynamoDBClient","createAbstraction"],"mappings":";AAOO,MAAMA,iBAAiBC,kBAAmC"}
@@ -0,0 +1,6 @@
1
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
+ export { DynamoDBClient } from "./abstractions.js";
3
+ export declare const DynamoDBClientFeature: {
4
+ name: string;
5
+ register(container: import("@webiny/di").Container, context: DynamoDBDocument): void;
6
+ };
@@ -0,0 +1,15 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { DynamoDBClient } from "./abstractions.js";
3
+ import { DynamoDBClient as external_DynamoDBClient_js_DynamoDBClient } from "./DynamoDBClient.js";
4
+ const DynamoDBClientFeature = createFeature({
5
+ name: "Db/DynamoDB/DynamoDBClientFeature",
6
+ register (container, documentClient) {
7
+ const client = new external_DynamoDBClient_js_DynamoDBClient({
8
+ client: documentClient
9
+ });
10
+ container.registerInstance(DynamoDBClient, client);
11
+ }
12
+ });
13
+ export { DynamoDBClient, DynamoDBClientFeature };
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/DynamoDBClient/index.js","sources":["../../../src/feature/DynamoDBClient/index.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { DynamoDBClient as DynamoDBClientAbstraction } from \"./abstractions.js\";\nimport { DynamoDBClient } from \"./DynamoDBClient.js\";\n\nexport { DynamoDBClient } from \"./abstractions.js\";\n\nexport const DynamoDBClientFeature = createFeature<DynamoDBDocument>({\n name: \"Db/DynamoDB/DynamoDBClientFeature\",\n register(container, documentClient) {\n const client = new DynamoDBClient({ client: documentClient });\n container.registerInstance(DynamoDBClientAbstraction, client);\n }\n});\n"],"names":["DynamoDBClientFeature","createFeature","container","documentClient","client","DynamoDBClient","DynamoDBClientAbstraction"],"mappings":";;;AAOO,MAAMA,wBAAwBC,cAAgC;IACjE,MAAM;IACN,UAASC,SAAS,EAAEC,cAAc;QAC9B,MAAMC,SAAS,IAAIC,0CAAe;YAAE,QAAQF;QAAe;QAC3DD,UAAU,gBAAgB,CAACI,gBAA2BF;IAC1D;AACJ"}
@@ -0,0 +1,11 @@
1
+ import { FilterUtil as Abstraction } from "./abstractions/FilterUtil.js";
2
+ import { ValueFilterRegistry } from "../../feature/ValueFilter/index.js";
3
+ declare class FilterUtilImpl implements Abstraction.Interface {
4
+ private readonly filterRegistry;
5
+ constructor(filterRegistry: ValueFilterRegistry.Interface);
6
+ filter<T = any>(params: Abstraction.Params<T>): T[];
7
+ }
8
+ export declare const FilterUtil: typeof FilterUtilImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/FilterUtil.js").IFilterUtil>;
10
+ };
11
+ export {};
@@ -0,0 +1,26 @@
1
+ import { FilterUtil } from "./abstractions/FilterUtil.js";
2
+ import { ValueFilterRegistry } from "../ValueFilter/index.js";
3
+ import { createFilterCallable } from "./createFilters.js";
4
+ class FilterUtilImpl {
5
+ constructor(filterRegistry){
6
+ this.filterRegistry = filterRegistry;
7
+ }
8
+ filter(params) {
9
+ const filterFn = createFilterCallable({
10
+ filterRegistry: this.filterRegistry,
11
+ where: params.where,
12
+ fields: params.fields
13
+ });
14
+ if (!filterFn) return params.items;
15
+ return params.items.filter(filterFn);
16
+ }
17
+ }
18
+ const FilterUtil_FilterUtil = FilterUtil.createImplementation({
19
+ implementation: FilterUtilImpl,
20
+ dependencies: [
21
+ ValueFilterRegistry
22
+ ]
23
+ });
24
+ export { FilterUtil_FilterUtil as FilterUtil };
25
+
26
+ //# sourceMappingURL=FilterUtil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/FilterUtil/FilterUtil.js","sources":["../../../src/feature/FilterUtil/FilterUtil.ts"],"sourcesContent":["import { FilterUtil as Abstraction } from \"./abstractions/FilterUtil.js\";\nimport { ValueFilterRegistry } from \"~/feature/ValueFilter/index.js\";\nimport { createFilterCallable } from \"./createFilters.js\";\n\nclass FilterUtilImpl implements Abstraction.Interface {\n public constructor(private readonly filterRegistry: ValueFilterRegistry.Interface) {}\n\n public filter<T = any>(params: Abstraction.Params<T>): T[] {\n const filterFn = createFilterCallable({\n filterRegistry: this.filterRegistry,\n where: params.where,\n fields: params.fields\n });\n /**\n * No point in going through all the items when there are no filters to be applied.\n */\n if (!filterFn) {\n return params.items;\n }\n return params.items.filter(filterFn);\n }\n}\n\nexport const FilterUtil = Abstraction.createImplementation({\n implementation: FilterUtilImpl,\n dependencies: [ValueFilterRegistry]\n});\n"],"names":["FilterUtilImpl","filterRegistry","params","filterFn","createFilterCallable","FilterUtil","Abstraction","ValueFilterRegistry"],"mappings":";;;AAIA,MAAMA;IACF,YAAoCC,cAA6C,CAAE;aAA/CA,cAAc,GAAdA;IAAgD;IAE7E,OAAgBC,MAA6B,EAAO;QACvD,MAAMC,WAAWC,qBAAqB;YAClC,gBAAgB,IAAI,CAAC,cAAc;YACnC,OAAOF,OAAO,KAAK;YACnB,QAAQA,OAAO,MAAM;QACzB;QAIA,IAAI,CAACC,UACD,OAAOD,OAAO,KAAK;QAEvB,OAAOA,OAAO,KAAK,CAAC,MAAM,CAACC;IAC/B;AACJ;AAEO,MAAME,wBAAaC,WAAAA,oBAAgC,CAAC;IACvD,gBAAgBN;IAChB,cAAc;QAACO;KAAoB;AACvC"}
@@ -0,0 +1,17 @@
1
+ import type { FieldPlugin } from "../../../plugins/definitions/FieldPlugin.js";
2
+ export interface IFilterUtilParams<T = any> {
3
+ items: T[];
4
+ where: Record<string, any>;
5
+ /**
6
+ * An array of fields that require some special operation.
7
+ */
8
+ fields: FieldPlugin[];
9
+ }
10
+ export interface IFilterUtil {
11
+ filter<T = any>(params: IFilterUtilParams<T>): T[];
12
+ }
13
+ export declare const FilterUtil: import("@webiny/di").Abstraction<IFilterUtil>;
14
+ export declare namespace FilterUtil {
15
+ type Interface = IFilterUtil;
16
+ type Params<T = any> = IFilterUtilParams<T>;
17
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const FilterUtil = createAbstraction("Db/DynamoDB/FilterUtil");
3
+ export { FilterUtil };
4
+
5
+ //# sourceMappingURL=FilterUtil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/FilterUtil/abstractions/FilterUtil.js","sources":["../../../../src/feature/FilterUtil/abstractions/FilterUtil.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { FieldPlugin } from \"~/plugins/definitions/FieldPlugin.js\";\n\nexport interface IFilterUtilParams<T = any> {\n items: T[];\n where: Record<string, any>;\n /**\n * An array of fields that require some special operation.\n */\n fields: FieldPlugin[];\n}\n\nexport interface IFilterUtil {\n filter<T = any>(params: IFilterUtilParams<T>): T[];\n}\n\nexport const FilterUtil = createAbstraction<IFilterUtil>(\"Db/DynamoDB/FilterUtil\");\n\nexport namespace FilterUtil {\n export type Interface = IFilterUtil;\n export type Params<T = any> = IFilterUtilParams<T>;\n}\n"],"names":["FilterUtil","createAbstraction"],"mappings":";AAgBO,MAAMA,aAAaC,kBAA+B"}
@@ -0,0 +1,22 @@
1
+ import type { FieldPlugin } from "../../plugins/definitions/FieldPlugin.js";
2
+ import type { ValueFilter, ValueFilterRegistry } from "../../feature/ValueFilter/index.js";
3
+ type TransformValue = (value: any) => any;
4
+ interface Filter {
5
+ operation: string;
6
+ compareValue: any;
7
+ filter: ValueFilter.Interface;
8
+ transformValue?: TransformValue;
9
+ paths: string[];
10
+ negate: boolean;
11
+ }
12
+ interface CreateFiltersParams {
13
+ filterRegistry: ValueFilterRegistry.Interface;
14
+ where: Record<string, any>;
15
+ fields: FieldPlugin[];
16
+ }
17
+ export declare const createFilters: (params: CreateFiltersParams) => Filter[];
18
+ /**
19
+ * Creates a filter callable that we can send to the .filter() method of the array.
20
+ */
21
+ export declare const createFilterCallable: (params: CreateFiltersParams) => ((item: any) => boolean) | null;
22
+ export {};
@@ -0,0 +1,92 @@
1
+ import { WebinyError } from "@webiny/error";
2
+ import { extractWhereArgs } from "./extractWhereArgs.js";
3
+ import * as __rspack_external_dot_prop_0ebbd169 from "dot-prop";
4
+ const findFilter = (registry, operation)=>{
5
+ const filter = registry.get(operation);
6
+ if (filter) return filter;
7
+ throw new WebinyError("Missing filter plugin definition.", "FILTER_PLUGIN_ERROR", {
8
+ operation
9
+ });
10
+ };
11
+ const multiSearchFieldOperations = [
12
+ "contains",
13
+ "fuzzy"
14
+ ];
15
+ const createFilters = (params)=>{
16
+ const { where, fields, filterRegistry } = params;
17
+ const keys = Object.keys(where);
18
+ if (0 === keys.length) return [];
19
+ return keys.reduce((filters, key)=>{
20
+ const compareValue = where[key];
21
+ if (void 0 === compareValue) return filters;
22
+ if (true === multiSearchFieldOperations.includes(key)) {
23
+ const data = compareValue;
24
+ let transformValue;
25
+ const paths = data.fields.map((field)=>{
26
+ const fieldPlugin = fields.find((plugin)=>plugin.getField() === field);
27
+ if (fieldPlugin) {
28
+ transformValue = (value)=>fieldPlugin.transformValue(value);
29
+ return fieldPlugin.getPath();
30
+ }
31
+ return field;
32
+ });
33
+ const filter = findFilter(filterRegistry, key);
34
+ filters.push({
35
+ operation: filter.operation,
36
+ compareValue: data.value,
37
+ filter,
38
+ transformValue,
39
+ paths,
40
+ negate: false
41
+ });
42
+ return filters;
43
+ }
44
+ const { field, operation, negate } = extractWhereArgs(key);
45
+ const filter = findFilter(filterRegistry, operation);
46
+ const fieldPlugin = fields.find((plugin)=>plugin.getField() === field);
47
+ let path = field;
48
+ let transformValue;
49
+ if (fieldPlugin) {
50
+ transformValue = (value)=>fieldPlugin.transformValue(value);
51
+ path = fieldPlugin.getPath();
52
+ }
53
+ filters.push({
54
+ operation: filter.operation,
55
+ compareValue,
56
+ filter,
57
+ transformValue,
58
+ paths: [
59
+ path
60
+ ],
61
+ negate
62
+ });
63
+ return filters;
64
+ }, []);
65
+ };
66
+ const transform = (value, transformValue)=>{
67
+ if (!transformValue) return value;
68
+ if (Array.isArray(value)) return value.map((v)=>transformValue(v));
69
+ return transformValue(value);
70
+ };
71
+ const createFilterCallable = (params)=>{
72
+ const filters = createFilters(params);
73
+ if (0 === filters.length) return null;
74
+ return (item)=>{
75
+ for (const filter of filters){
76
+ const result = filter.paths.some((path)=>{
77
+ const value = transform(__rspack_external_dot_prop_0ebbd169.getProperty(item, path), filter.transformValue);
78
+ const compareValue = transform(filter.compareValue, filter.transformValue);
79
+ const matched = filter.filter.matches({
80
+ value,
81
+ compareValue
82
+ });
83
+ return filter.negate ? !matched : matched;
84
+ });
85
+ if (false === result) return false;
86
+ }
87
+ return true;
88
+ };
89
+ };
90
+ export { createFilterCallable, createFilters };
91
+
92
+ //# sourceMappingURL=createFilters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/FilterUtil/createFilters.js","sources":["../../../src/feature/FilterUtil/createFilters.ts"],"sourcesContent":["import * as dotProp from \"dot-prop\";\nimport { WebinyError } from \"@webiny/error\";\nimport type { FieldPlugin } from \"~/plugins/definitions/FieldPlugin.js\";\nimport type { DynamoDbContainsFilter } from \"~/types.js\";\nimport type { ValueFilter, ValueFilterRegistry } from \"~/feature/ValueFilter/index.js\";\nimport { extractWhereArgs } from \"./extractWhereArgs.js\";\n\ntype TransformValue = (value: any) => any;\n\ninterface Filter {\n operation: string;\n compareValue: any;\n filter: ValueFilter.Interface;\n transformValue?: TransformValue;\n paths: string[];\n negate: boolean;\n}\n\ninterface CreateFiltersParams {\n filterRegistry: ValueFilterRegistry.Interface;\n where: Record<string, any>;\n fields: FieldPlugin[];\n}\n\nconst findFilter = (\n registry: ValueFilterRegistry.Interface,\n operation: string\n): ValueFilter.Interface => {\n const filter = registry.get(operation);\n if (filter) {\n return filter;\n }\n throw new WebinyError(`Missing filter plugin definition.`, \"FILTER_PLUGIN_ERROR\", {\n operation\n });\n};\n\nconst multiSearchFieldOperations = [\"contains\", \"fuzzy\"];\n\nexport const createFilters = (params: CreateFiltersParams): Filter[] => {\n const { where, fields, filterRegistry } = params;\n\n const keys = Object.keys(where);\n /**\n * Skip everything if there are no conditions to be applied.\n */\n if (keys.length === 0) {\n return [];\n }\n\n return keys.reduce((filters, key) => {\n const compareValue = where[key];\n if (compareValue === undefined) {\n return filters;\n }\n /**\n * @see DynamoDbContainsFilter\n */\n if (multiSearchFieldOperations.includes(key) === true) {\n const data: DynamoDbContainsFilter = compareValue;\n let transformValue: TransformValue | undefined = undefined;\n const paths = data.fields.map(field => {\n const fieldPlugin = fields.find(plugin => plugin.getField() === field);\n if (fieldPlugin) {\n transformValue = (value: any) => {\n return fieldPlugin.transformValue(value);\n };\n return fieldPlugin.getPath();\n }\n return field;\n });\n\n const filter = findFilter(filterRegistry, key);\n filters.push({\n operation: filter.operation,\n compareValue: data.value,\n filter,\n transformValue,\n paths,\n negate: false\n });\n return filters;\n }\n\n const { field, operation, negate } = extractWhereArgs(key);\n\n const filter = findFilter(filterRegistry, operation);\n\n const fieldPlugin = fields.find(plugin => plugin.getField() === field);\n let path: string = field;\n let transformValue: TransformValue | undefined = undefined;\n if (fieldPlugin) {\n transformValue = (value: any) => {\n return fieldPlugin.transformValue(value);\n };\n path = fieldPlugin.getPath();\n }\n\n filters.push({\n operation: filter.operation,\n compareValue,\n filter,\n transformValue,\n paths: [path],\n negate\n });\n\n return filters;\n }, [] as Filter[]);\n};\n\n/**\n * Transforms the value with given transformer callable.\n */\nconst transform = (value: any, transformValue?: TransformValue): any => {\n if (!transformValue) {\n return value;\n }\n if (Array.isArray(value)) {\n return value.map(v => transformValue(v));\n }\n return transformValue(value);\n};\n\n/**\n * Creates a filter callable that we can send to the .filter() method of the array.\n */\nexport const createFilterCallable = (\n params: CreateFiltersParams\n): ((item: any) => boolean) | null => {\n const filters = createFilters(params);\n /**\n * Just return null so there are no filters to be applied.\n * Later in the code we check for null so we do not loop through the items.\n */\n if (filters.length === 0) {\n return null;\n }\n\n return (item: any) => {\n for (const filter of filters) {\n const result = filter.paths.some(path => {\n const value = transform(dotProp.getProperty(item, path), filter.transformValue);\n const compareValue = transform(filter.compareValue, filter.transformValue);\n const matched = filter.filter.matches({\n value,\n compareValue\n });\n\n return filter.negate ? !matched : matched;\n });\n if (result === false) {\n return false;\n }\n }\n return true;\n };\n};\n"],"names":["findFilter","registry","operation","filter","WebinyError","multiSearchFieldOperations","createFilters","params","where","fields","filterRegistry","keys","Object","filters","key","compareValue","undefined","data","transformValue","paths","field","fieldPlugin","plugin","value","negate","extractWhereArgs","path","transform","Array","v","createFilterCallable","item","result","dotProp","matched"],"mappings":";;;AAwBA,MAAMA,aAAa,CACfC,UACAC;IAEA,MAAMC,SAASF,SAAS,GAAG,CAACC;IAC5B,IAAIC,QACA,OAAOA;IAEX,MAAM,IAAIC,YAAY,qCAAqC,uBAAuB;QAC9EF;IACJ;AACJ;AAEA,MAAMG,6BAA6B;IAAC;IAAY;CAAQ;AAEjD,MAAMC,gBAAgB,CAACC;IAC1B,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,cAAc,EAAE,GAAGH;IAE1C,MAAMI,OAAOC,OAAO,IAAI,CAACJ;IAIzB,IAAIG,AAAgB,MAAhBA,KAAK,MAAM,EACX,OAAO,EAAE;IAGb,OAAOA,KAAK,MAAM,CAAC,CAACE,SAASC;QACzB,MAAMC,eAAeP,KAAK,CAACM,IAAI;QAC/B,IAAIC,AAAiBC,WAAjBD,cACA,OAAOF;QAKX,IAAIR,AAA6C,SAA7CA,2BAA2B,QAAQ,CAACS,MAAe;YACnD,MAAMG,OAA+BF;YACrC,IAAIG;YACJ,MAAMC,QAAQF,KAAK,MAAM,CAAC,GAAG,CAACG,CAAAA;gBAC1B,MAAMC,cAAcZ,OAAO,IAAI,CAACa,CAAAA,SAAUA,OAAO,QAAQ,OAAOF;gBAChE,IAAIC,aAAa;oBACbH,iBAAiB,CAACK,QACPF,YAAY,cAAc,CAACE;oBAEtC,OAAOF,YAAY,OAAO;gBAC9B;gBACA,OAAOD;YACX;YAEA,MAAMjB,SAASH,WAAWU,gBAAgBI;YAC1CD,QAAQ,IAAI,CAAC;gBACT,WAAWV,OAAO,SAAS;gBAC3B,cAAcc,KAAK,KAAK;gBACxBd;gBACAe;gBACAC;gBACA,QAAQ;YACZ;YACA,OAAON;QACX;QAEA,MAAM,EAAEO,KAAK,EAAElB,SAAS,EAAEsB,MAAM,EAAE,GAAGC,iBAAiBX;QAEtD,MAAMX,SAASH,WAAWU,gBAAgBR;QAE1C,MAAMmB,cAAcZ,OAAO,IAAI,CAACa,CAAAA,SAAUA,OAAO,QAAQ,OAAOF;QAChE,IAAIM,OAAeN;QACnB,IAAIF;QACJ,IAAIG,aAAa;YACbH,iBAAiB,CAACK,QACPF,YAAY,cAAc,CAACE;YAEtCG,OAAOL,YAAY,OAAO;QAC9B;QAEAR,QAAQ,IAAI,CAAC;YACT,WAAWV,OAAO,SAAS;YAC3BY;YACAZ;YACAe;YACA,OAAO;gBAACQ;aAAK;YACbF;QACJ;QAEA,OAAOX;IACX,GAAG,EAAE;AACT;AAKA,MAAMc,YAAY,CAACJ,OAAYL;IAC3B,IAAI,CAACA,gBACD,OAAOK;IAEX,IAAIK,MAAM,OAAO,CAACL,QACd,OAAOA,MAAM,GAAG,CAACM,CAAAA,IAAKX,eAAeW;IAEzC,OAAOX,eAAeK;AAC1B;AAKO,MAAMO,uBAAuB,CAChCvB;IAEA,MAAMM,UAAUP,cAAcC;IAK9B,IAAIM,AAAmB,MAAnBA,QAAQ,MAAM,EACd,OAAO;IAGX,OAAO,CAACkB;QACJ,KAAK,MAAM5B,UAAUU,QAAS;YAC1B,MAAMmB,SAAS7B,OAAO,KAAK,CAAC,IAAI,CAACuB,CAAAA;gBAC7B,MAAMH,QAAQI,UAAUM,oCAAAA,WAAmB,CAACF,MAAML,OAAOvB,OAAO,cAAc;gBAC9E,MAAMY,eAAeY,UAAUxB,OAAO,YAAY,EAAEA,OAAO,cAAc;gBACzE,MAAM+B,UAAU/B,OAAO,MAAM,CAAC,OAAO,CAAC;oBAClCoB;oBACAR;gBACJ;gBAEA,OAAOZ,OAAO,MAAM,GAAG,CAAC+B,UAAUA;YACtC;YACA,IAAIF,AAAW,UAAXA,QACA,OAAO;QAEf;QACA,OAAO;IACX;AACJ"}
@@ -0,0 +1,7 @@
1
+ interface ExtractWhereArgsResult {
2
+ field: string;
3
+ operation: string;
4
+ negate: boolean;
5
+ }
6
+ export declare const extractWhereArgs: (key: string) => ExtractWhereArgsResult;
7
+ export {};
@@ -0,0 +1,20 @@
1
+ const extractWhereArgs = (key)=>{
2
+ const result = key.split("_");
3
+ const field = result.shift();
4
+ const rawOp = 0 === result.length ? "eq" : result.join("_");
5
+ if ("not" === rawOp) return {
6
+ field,
7
+ operation: "eq",
8
+ negate: true
9
+ };
10
+ const negate = null !== rawOp.match("not_");
11
+ const operation = rawOp.replace("not_", "");
12
+ return {
13
+ field,
14
+ operation,
15
+ negate
16
+ };
17
+ };
18
+ export { extractWhereArgs };
19
+
20
+ //# sourceMappingURL=extractWhereArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/FilterUtil/extractWhereArgs.js","sources":["../../../src/feature/FilterUtil/extractWhereArgs.ts"],"sourcesContent":["interface ExtractWhereArgsResult {\n field: string;\n operation: string;\n negate: boolean;\n}\n\nexport const extractWhereArgs = (key: string): ExtractWhereArgsResult => {\n const result = key.split(\"_\");\n const field = result.shift() as string;\n const rawOp = result.length === 0 ? \"eq\" : result.join(\"_\");\n /**\n * When rawOp is not, it means it is equal negated so just return that.\n */\n if (rawOp === \"not\") {\n return {\n field,\n operation: \"eq\",\n negate: true\n };\n }\n const negate = rawOp.match(\"not_\") !== null;\n const operation = rawOp.replace(\"not_\", \"\");\n return {\n field,\n operation,\n negate\n };\n};\n"],"names":["extractWhereArgs","key","result","field","rawOp","negate","operation"],"mappings":"AAMO,MAAMA,mBAAmB,CAACC;IAC7B,MAAMC,SAASD,IAAI,KAAK,CAAC;IACzB,MAAME,QAAQD,OAAO,KAAK;IAC1B,MAAME,QAAQF,AAAkB,MAAlBA,OAAO,MAAM,GAAS,OAAOA,OAAO,IAAI,CAAC;IAIvD,IAAIE,AAAU,UAAVA,OACA,OAAO;QACHD;QACA,WAAW;QACX,QAAQ;IACZ;IAEJ,MAAME,SAASD,AAAwB,SAAxBA,MAAM,KAAK,CAAC;IAC3B,MAAME,YAAYF,MAAM,OAAO,CAAC,QAAQ;IACxC,OAAO;QACHD;QACAG;QACAD;IACJ;AACJ"}
@@ -0,0 +1,4 @@
1
+ export declare const FilterUtilFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { FilterUtil } from "./FilterUtil.js";
3
+ const FilterUtilFeature = createFeature({
4
+ name: "Db/DynamoDB/FilterUtilFeature",
5
+ register: (container)=>{
6
+ container.register(FilterUtil);
7
+ }
8
+ });
9
+ export { FilterUtilFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/FilterUtil/feature.js","sources":["../../../src/feature/FilterUtil/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { FilterUtil } from \"./FilterUtil.js\";\n\nexport const FilterUtilFeature = createFeature({\n name: \"Db/DynamoDB/FilterUtilFeature\",\n register: container => {\n container.register(FilterUtil);\n }\n});\n"],"names":["FilterUtilFeature","createFeature","container","FilterUtil"],"mappings":";;AAGO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAAUC,CAAAA;QACNA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -0,0 +1,2 @@
1
+ export { FilterUtil } from "./abstractions/FilterUtil.js";
2
+ export { FilterUtilFeature } from "./feature.js";
@@ -0,0 +1,2 @@
1
+ export { FilterUtil } from "./abstractions/FilterUtil.js";
2
+ export { FilterUtilFeature } from "./feature.js";
@@ -0,0 +1,3 @@
1
+ export { ValueFilter } from "@webiny/db-utils";
2
+ export { ValueFilterRegistry } from "@webiny/db-utils";
3
+ export { ValueFilterFeature } from "@webiny/db-utils";
@@ -0,0 +1 @@
1
+ export { ValueFilter, ValueFilterFeature, ValueFilterRegistry } from "@webiny/db-utils";
package/index.d.ts CHANGED
@@ -1,4 +1,11 @@
1
- import { default as DynamoDbDriver } from "./DynamoDbDriver";
2
- export * from "./utils/createStandardEntity";
3
- export { DbItem } from "./types";
1
+ import { default as DynamoDbDriver } from "./DynamoDbDriver.js";
2
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
3
+ export * from "./utils/index.js";
4
+ export * from "./plugins/index.js";
5
+ export type { DbItem } from "./types.js";
4
6
  export { DynamoDbDriver };
7
+ interface IRegisterDbDynamoDbExtension {
8
+ documentClient: DynamoDBDocument;
9
+ }
10
+ export { DynamoDBClient } from "./feature/DynamoDBClient/index.js";
11
+ export declare const registerDynamoDBCore: ({ documentClient }: IRegisterDbDynamoDbExtension) => import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>;
package/index.js CHANGED
@@ -1,36 +1,15 @@
1
- "use strict";
1
+ import { createRegisterExtensionPlugin } from "@webiny/handler";
2
+ import { DynamoDBClient, DynamoDBClientFeature } from "./feature/DynamoDBClient/index.js";
3
+ import { ValueFilterFeature } from "@webiny/db-utils";
4
+ import { FilterUtilFeature } from "./feature/FilterUtil/index.js";
5
+ export * from "./utils/index.js";
6
+ export * from "./plugins/index.js";
7
+ const registerDynamoDBCore = ({ documentClient })=>createRegisterExtensionPlugin(async (context)=>{
8
+ DynamoDBClientFeature.register(context.container, documentClient);
9
+ FilterUtilFeature.register(context.container);
10
+ ValueFilterFeature.register(context.container);
11
+ });
12
+ export { default as DynamoDbDriver } from "./DynamoDbDriver.js";
13
+ export { DynamoDBClient, registerDynamoDBCore };
2
14
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- var _exportNames = {
8
- DynamoDbDriver: true,
9
- DbItem: true
10
- };
11
- Object.defineProperty(exports, "DbItem", {
12
- enumerable: true,
13
- get: function () {
14
- return _types.DbItem;
15
- }
16
- });
17
- Object.defineProperty(exports, "DynamoDbDriver", {
18
- enumerable: true,
19
- get: function () {
20
- return _DynamoDbDriver.default;
21
- }
22
- });
23
- var _DynamoDbDriver = _interopRequireDefault(require("./DynamoDbDriver"));
24
- var _createStandardEntity = require("./utils/createStandardEntity");
25
- Object.keys(_createStandardEntity).forEach(function (key) {
26
- if (key === "default" || key === "__esModule") return;
27
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
28
- if (key in exports && exports[key] === _createStandardEntity[key]) return;
29
- Object.defineProperty(exports, key, {
30
- enumerable: true,
31
- get: function () {
32
- return _createStandardEntity[key];
33
- }
34
- });
35
- });
36
- var _types = require("./types");
15
+ //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import { default as DynamoDbDriver } from \"./DynamoDbDriver\";\nexport * from \"./utils/createStandardEntity\";\nexport { DbItem } from \"./types\";\n\nexport { DynamoDbDriver };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { default as DynamoDbDriver } from \"./DynamoDbDriver.js\";\nimport { ValueFilterFeature } from \"@webiny/db-utils\";\nimport { FilterUtilFeature } from \"~/feature/FilterUtil/index.js\";\nimport { DynamoDBClientFeature } from \"~/feature/DynamoDBClient/index.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\n\nexport * from \"./utils/index.js\";\nexport * from \"./plugins/index.js\";\nexport type { DbItem } from \"./types.js\";\n\nexport { DynamoDbDriver };\n\ninterface IRegisterDbDynamoDbExtension {\n documentClient: DynamoDBDocument;\n}\n\nexport { DynamoDBClient } from \"~/feature/DynamoDBClient/index.js\";\n\nexport const registerDynamoDBCore = ({ documentClient }: IRegisterDbDynamoDbExtension) => {\n return createRegisterExtensionPlugin(async context => {\n DynamoDBClientFeature.register(context.container, documentClient);\n FilterUtilFeature.register(context.container);\n ValueFilterFeature.register(context.container);\n });\n};\n"],"names":["registerDynamoDBCore","documentClient","createRegisterExtensionPlugin","context","DynamoDBClientFeature","FilterUtilFeature","ValueFilterFeature"],"mappings":";;;;;;AAmBO,MAAMA,uBAAuB,CAAC,EAAEC,cAAc,EAAgC,GAC1EC,8BAA8B,OAAMC;QACvCC,sBAAsB,QAAQ,CAACD,QAAQ,SAAS,EAAEF;QAClDI,kBAAkB,QAAQ,CAACF,QAAQ,SAAS;QAC5CG,mBAAmB,QAAQ,CAACH,QAAQ,SAAS;IACjD"}
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/db-dynamodb",
3
- "version": "0.0.0-unstable.b14eaecf38",
4
- "main": "index.js",
3
+ "version": "0.0.0-unstable.b6d7105cee",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
5
9
  "repository": {
6
10
  "type": "git",
7
11
  "url": "https://github.com/webiny/webiny-js.git"
@@ -10,37 +14,35 @@
10
14
  "author": "Webiny Ltd",
11
15
  "license": "MIT",
12
16
  "dependencies": {
13
- "@webiny/api": "0.0.0-unstable.b14eaecf38",
14
- "@webiny/db": "0.0.0-unstable.b14eaecf38",
15
- "@webiny/error": "0.0.0-unstable.b14eaecf38",
16
- "@webiny/handler-db": "0.0.0-unstable.b14eaecf38",
17
- "@webiny/plugins": "0.0.0-unstable.b14eaecf38",
18
- "date-fns": "2.29.3",
19
- "dot-prop": "6.0.1",
20
- "fuse.js": "6.6.2",
21
- "is-number": "7.0.0",
22
- "lodash": "4.17.21"
17
+ "@webiny/api": "0.0.0-unstable.b6d7105cee",
18
+ "@webiny/aws-sdk": "0.0.0-unstable.b6d7105cee",
19
+ "@webiny/db": "0.0.0-unstable.b6d7105cee",
20
+ "@webiny/db-utils": "0.0.0-unstable.b6d7105cee",
21
+ "@webiny/error": "0.0.0-unstable.b6d7105cee",
22
+ "@webiny/feature": "0.0.0-unstable.b6d7105cee",
23
+ "@webiny/handler": "0.0.0-unstable.b6d7105cee",
24
+ "@webiny/plugins": "0.0.0-unstable.b6d7105cee",
25
+ "@webiny/utils": "0.0.0-unstable.b6d7105cee",
26
+ "date-fns": "4.4.0",
27
+ "dot-prop": "10.2.0",
28
+ "dynamodb-toolbox": "0.9.5",
29
+ "lodash": "4.18.1"
23
30
  },
24
31
  "devDependencies": {
25
- "@babel/cli": "^7.19.3",
26
- "@babel/core": "^7.19.3",
27
- "@types/is-number": "^7.0.2",
28
- "@webiny/cli": "^0.0.0-unstable.b14eaecf38",
29
- "@webiny/project-utils": "^0.0.0-unstable.b14eaecf38",
30
- "dynamodb-toolbox": "^0.3.5",
31
- "jest": "^28.1.0",
32
- "jest-dynalite": "^3.2.0",
33
- "rimraf": "^3.0.2",
34
- "ttypescript": "^1.5.12",
35
- "typescript": "4.7.4"
32
+ "@types/is-number": "7.0.5",
33
+ "@webiny/build-tools": "0.0.0-unstable.b6d7105cee",
34
+ "@webiny/di": "1.0.2",
35
+ "@webiny/project-utils": "0.0.0-unstable.b6d7105cee",
36
+ "jest-dynalite": "3.6.1",
37
+ "rimraf": "6.1.3",
38
+ "typescript": "7.0.2",
39
+ "vitest": "4.1.10"
36
40
  },
37
41
  "publishConfig": {
38
- "access": "public",
39
- "directory": "dist"
40
- },
41
- "scripts": {
42
- "build": "yarn webiny run build",
43
- "watch": "yarn webiny run watch"
42
+ "access": "public"
44
43
  },
45
- "gitHead": "b14eaecf387253ed23cb96f8d31b7d16b5061936"
44
+ "gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
45
+ "webiny": {
46
+ "publishFrom": "dist"
47
+ }
46
48
  }
@@ -1,4 +1,5 @@
1
- import { ValueTransformPlugin, ValueTransformPluginParams } from "./ValueTransformPlugin";
1
+ import type { ValueTransformPluginParams } from "./ValueTransformPlugin.js";
2
+ import { ValueTransformPlugin } from "./ValueTransformPlugin.js";
2
3
  export declare class DateTimeTransformPlugin extends ValueTransformPlugin {
3
4
  constructor(params: Omit<ValueTransformPluginParams, "transform">);
4
5
  }
@@ -1,40 +1,25 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.DateTimeTransformPlugin = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _ValueTransformPlugin = require("./ValueTransformPlugin");
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
- var _dateFns = require("date-fns");
12
- const transformDateTime = params => {
13
- const {
14
- value
15
- } = params;
16
- if (value === null) {
1
+ import { ValueTransformPlugin } from "./ValueTransformPlugin.js";
2
+ import { parseISO } from "date-fns";
3
+ const transformDateTime = (params)=>{
4
+ const { value } = params;
5
+ if (null == value) return null;
6
+ if ("string" == typeof value) {
7
+ const parsedDateTime = parseISO(value).getTime();
8
+ if (false === isNaN(parsedDateTime)) return parsedDateTime;
9
+ } else if (value instanceof Date || "function" == typeof value?.getTime) return value.getTime();
10
+ console.warn("Could not parse given dateTime value.", "PARSE_DATE_ERROR", {
11
+ value
12
+ });
17
13
  return null;
18
- }
19
- if (value && typeof value.getTime === "function") {
20
- /**
21
- * In this case we assume this is a date object and we just get the time.
22
- */
23
- return value.getTime();
24
- }
25
- const parsedDateTime = (0, _dateFns.parseISO)(value).getTime();
26
- if (isNaN(parsedDateTime) === false) {
27
- return parsedDateTime;
28
- }
29
- throw new _error.default("Could not parse given dateTime value.", "PARSE_DATE_ERROR", {
30
- value
31
- });
32
14
  };
33
- class DateTimeTransformPlugin extends _ValueTransformPlugin.ValueTransformPlugin {
34
- constructor(params) {
35
- super((0, _objectSpread2.default)({
36
- transform: transformDateTime
37
- }, params));
38
- }
15
+ class DateTimeTransformPlugin extends ValueTransformPlugin {
16
+ constructor(params){
17
+ super({
18
+ transform: transformDateTime,
19
+ ...params
20
+ });
21
+ }
39
22
  }
40
- exports.DateTimeTransformPlugin = DateTimeTransformPlugin;
23
+ export { DateTimeTransformPlugin };
24
+
25
+ //# sourceMappingURL=DateTimeTransformPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["transformDateTime","params","value","getTime","parsedDateTime","parseISO","isNaN","WebinyError","DateTimeTransformPlugin","ValueTransformPlugin","constructor","transform"],"sources":["DateTimeTransformPlugin.ts"],"sourcesContent":["import {\n ValueTransformPlugin,\n ValueTransformPluginParams,\n ValueTransformPluginParamsTransformParams\n} from \"./ValueTransformPlugin\";\nimport WebinyError from \"@webiny/error\";\nimport { parseISO } from \"date-fns\";\n\nconst transformDateTime = (params: ValueTransformPluginParamsTransformParams): number | null => {\n const { value } = params;\n if (value === null) {\n return null;\n }\n if (value && typeof (value as any).getTime === \"function\") {\n /**\n * In this case we assume this is a date object and we just get the time.\n */\n return (value as Date).getTime();\n }\n const parsedDateTime = parseISO(value).getTime();\n if (isNaN(parsedDateTime) === false) {\n return parsedDateTime;\n }\n throw new WebinyError(\"Could not parse given dateTime value.\", \"PARSE_DATE_ERROR\", {\n value\n });\n};\n\nexport class DateTimeTransformPlugin extends ValueTransformPlugin {\n public constructor(params: Omit<ValueTransformPluginParams, \"transform\">) {\n super({\n transform: transformDateTime,\n ...params\n });\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAKA;AACA;AAEA,MAAMA,iBAAiB,GAAIC,MAAiD,IAAoB;EAC5F,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EACxB,IAAIC,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,IAAI;EACf;EACA,IAAIA,KAAK,IAAI,OAAQA,KAAK,CAASC,OAAO,KAAK,UAAU,EAAE;IACvD;AACR;AACA;IACQ,OAAQD,KAAK,CAAUC,OAAO,EAAE;EACpC;EACA,MAAMC,cAAc,GAAG,IAAAC,iBAAQ,EAACH,KAAK,CAAC,CAACC,OAAO,EAAE;EAChD,IAAIG,KAAK,CAACF,cAAc,CAAC,KAAK,KAAK,EAAE;IACjC,OAAOA,cAAc;EACzB;EACA,MAAM,IAAIG,cAAW,CAAC,uCAAuC,EAAE,kBAAkB,EAAE;IAC/EL;EACJ,CAAC,CAAC;AACN,CAAC;AAEM,MAAMM,uBAAuB,SAASC,0CAAoB,CAAC;EACvDC,WAAW,CAACT,MAAqD,EAAE;IACtE,KAAK;MACDU,SAAS,EAAEX;IAAiB,GACzBC,MAAM,EACX;EACN;AACJ;AAAC"}
1
+ {"version":3,"file":"plugins/definitions/DateTimeTransformPlugin.js","sources":["../../../src/plugins/definitions/DateTimeTransformPlugin.ts"],"sourcesContent":["import type {\n ValueTransformPluginParams,\n ValueTransformPluginParamsTransformParams\n} from \"./ValueTransformPlugin.js\";\nimport { ValueTransformPlugin } from \"./ValueTransformPlugin.js\";\nimport { parseISO } from \"date-fns\";\n\nconst transformDateTime = (params: ValueTransformPluginParamsTransformParams): number | null => {\n const { value } = params;\n if (value === null || value === undefined) {\n return null;\n } else if (typeof value === \"string\") {\n const parsedDateTime = parseISO(value).getTime();\n if (isNaN(parsedDateTime) === false) {\n return parsedDateTime;\n }\n } else if (value instanceof Date || typeof (value as unknown as Date)?.getTime === \"function\") {\n /**\n * In this case we assume this is a date object, and we just get the time.\n */\n return value.getTime();\n }\n /**\n * No point in throwing an error here, as this would cause the entire transformation to fail. Instead, we just log a warning and return null.\n */\n console.warn(\"Could not parse given dateTime value.\", \"PARSE_DATE_ERROR\", {\n value\n });\n return null;\n};\n\nexport class DateTimeTransformPlugin extends ValueTransformPlugin {\n public constructor(params: Omit<ValueTransformPluginParams, \"transform\">) {\n super({\n transform: transformDateTime,\n ...params\n });\n }\n}\n"],"names":["transformDateTime","params","value","parsedDateTime","parseISO","isNaN","Date","console","DateTimeTransformPlugin","ValueTransformPlugin"],"mappings":";;AAOA,MAAMA,oBAAoB,CAACC;IACvB,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,IAAIC,QAAAA,OACA,OAAO;IACJ,IAAI,AAAiB,YAAjB,OAAOA,OAAoB;QAClC,MAAMC,iBAAiBC,SAASF,OAAO,OAAO;QAC9C,IAAIG,AAA0B,UAA1BA,MAAMF,iBACN,OAAOA;IAEf,OAAO,IAAID,iBAAiBI,QAAQ,AAA+C,cAA/C,OAAQJ,OAA2B,SAInE,OAAOA,MAAM,OAAO;IAKxBK,QAAQ,IAAI,CAAC,yCAAyC,oBAAoB;QACtEL;IACJ;IACA,OAAO;AACX;AAEO,MAAMM,gCAAgCC;IACzC,YAAmBR,MAAqD,CAAE;QACtE,KAAK,CAAC;YACF,WAAWD;YACX,GAAGC,MAAM;QACb;IACJ;AACJ"}
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- import { DynamoDBTypes } from "dynamodb-toolbox/dist/classes/Table";
3
- export declare type FieldType = DynamoDBTypes & "date" & any;
2
+ import type { DynamoDBTypes } from "../../toolbox.js";
3
+ export type FieldType = DynamoDBTypes & "date" & any;
4
4
  export interface TransformValueCb {
5
5
  (value: any): any;
6
6
  }