@webiny/db-dynamodb 0.0.0-unstable.6f45466a1d → 0.0.0-unstable.7be00a75a9

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 (215) hide show
  1. package/DynamoDbDriver.js +204 -209
  2. package/DynamoDbDriver.js.map +1 -1
  3. package/exports/api/db.d.ts +2 -0
  4. package/exports/api/db.js +2 -0
  5. package/feature/FilterUtil/FilterUtil.d.ts +11 -0
  6. package/feature/FilterUtil/FilterUtil.js +26 -0
  7. package/feature/FilterUtil/FilterUtil.js.map +1 -0
  8. package/feature/FilterUtil/abstractions/FilterUtil.d.ts +17 -0
  9. package/feature/FilterUtil/abstractions/FilterUtil.js +5 -0
  10. package/feature/FilterUtil/abstractions/FilterUtil.js.map +1 -0
  11. package/feature/FilterUtil/createFilters.d.ts +22 -0
  12. package/feature/FilterUtil/createFilters.js +92 -0
  13. package/feature/FilterUtil/createFilters.js.map +1 -0
  14. package/feature/FilterUtil/extractWhereArgs.d.ts +7 -0
  15. package/feature/FilterUtil/extractWhereArgs.js +20 -0
  16. package/feature/FilterUtil/extractWhereArgs.js.map +1 -0
  17. package/feature/FilterUtil/feature.d.ts +4 -0
  18. package/feature/FilterUtil/feature.js +11 -0
  19. package/feature/FilterUtil/feature.js.map +1 -0
  20. package/feature/FilterUtil/index.d.ts +2 -0
  21. package/feature/FilterUtil/index.js +2 -0
  22. package/feature/ValueFilter/ValueFilterRegistry.d.ts +12 -0
  23. package/feature/ValueFilter/ValueFilterRegistry.js +27 -0
  24. package/feature/ValueFilter/ValueFilterRegistry.js.map +1 -0
  25. package/feature/ValueFilter/abstractions/ValueFilter.d.ts +22 -0
  26. package/feature/ValueFilter/abstractions/ValueFilter.js +5 -0
  27. package/feature/ValueFilter/abstractions/ValueFilter.js.map +1 -0
  28. package/feature/ValueFilter/abstractions/ValueFilterRegistry.d.ts +10 -0
  29. package/feature/ValueFilter/abstractions/ValueFilterRegistry.js +5 -0
  30. package/feature/ValueFilter/abstractions/ValueFilterRegistry.js.map +1 -0
  31. package/feature/ValueFilter/feature.d.ts +4 -0
  32. package/feature/ValueFilter/feature.js +33 -0
  33. package/feature/ValueFilter/feature.js.map +1 -0
  34. package/feature/ValueFilter/filters/AndInFilter.d.ts +11 -0
  35. package/feature/ValueFilter/filters/AndInFilter.js +28 -0
  36. package/feature/ValueFilter/filters/AndInFilter.js.map +1 -0
  37. package/feature/ValueFilter/filters/BetweenFilter.d.ts +11 -0
  38. package/feature/ValueFilter/filters/BetweenFilter.js +31 -0
  39. package/feature/ValueFilter/filters/BetweenFilter.js.map +1 -0
  40. package/feature/ValueFilter/filters/ContainsFilter.d.ts +11 -0
  41. package/feature/ValueFilter/filters/ContainsFilter.js +42 -0
  42. package/feature/ValueFilter/filters/ContainsFilter.js.map +1 -0
  43. package/feature/ValueFilter/filters/EqFilter.d.ts +11 -0
  44. package/feature/ValueFilter/filters/EqFilter.js +24 -0
  45. package/feature/ValueFilter/filters/EqFilter.js.map +1 -0
  46. package/feature/ValueFilter/filters/FuzzyFilter.d.ts +11 -0
  47. package/feature/ValueFilter/filters/FuzzyFilter.js +37 -0
  48. package/feature/ValueFilter/filters/FuzzyFilter.js.map +1 -0
  49. package/feature/ValueFilter/filters/GtFilter.d.ts +11 -0
  50. package/feature/ValueFilter/filters/GtFilter.js +22 -0
  51. package/feature/ValueFilter/filters/GtFilter.js.map +1 -0
  52. package/feature/ValueFilter/filters/GteFilter.d.ts +11 -0
  53. package/feature/ValueFilter/filters/GteFilter.js +22 -0
  54. package/feature/ValueFilter/filters/GteFilter.js.map +1 -0
  55. package/feature/ValueFilter/filters/InFilter.d.ts +11 -0
  56. package/feature/ValueFilter/filters/InFilter.js +28 -0
  57. package/feature/ValueFilter/filters/InFilter.js.map +1 -0
  58. package/feature/ValueFilter/filters/LtFilter.d.ts +11 -0
  59. package/feature/ValueFilter/filters/LtFilter.js +22 -0
  60. package/feature/ValueFilter/filters/LtFilter.js.map +1 -0
  61. package/feature/ValueFilter/filters/LteFilter.d.ts +11 -0
  62. package/feature/ValueFilter/filters/LteFilter.js +22 -0
  63. package/feature/ValueFilter/filters/LteFilter.js.map +1 -0
  64. package/feature/ValueFilter/filters/StartsWithFilter.d.ts +11 -0
  65. package/feature/ValueFilter/filters/StartsWithFilter.js +29 -0
  66. package/feature/ValueFilter/filters/StartsWithFilter.js.map +1 -0
  67. package/feature/ValueFilter/index.d.ts +3 -0
  68. package/feature/ValueFilter/index.js +3 -0
  69. package/index.d.ts +1 -0
  70. package/index.js +9 -2
  71. package/index.js.map +1 -1
  72. package/package.json +28 -20
  73. package/plugins/definitions/DateTimeTransformPlugin.js +18 -27
  74. package/plugins/definitions/DateTimeTransformPlugin.js.map +1 -1
  75. package/plugins/definitions/FieldPlugin.js +34 -37
  76. package/plugins/definitions/FieldPlugin.js.map +1 -1
  77. package/plugins/definitions/TimeTransformPlugin.js +25 -37
  78. package/plugins/definitions/TimeTransformPlugin.js.map +1 -1
  79. package/plugins/definitions/ValueTransformPlugin.d.ts +1 -6
  80. package/plugins/definitions/ValueTransformPlugin.js +17 -22
  81. package/plugins/definitions/ValueTransformPlugin.js.map +1 -1
  82. package/plugins/definitions/assignFields.js +14 -18
  83. package/plugins/definitions/assignFields.js.map +1 -1
  84. package/plugins/index.d.ts +0 -5
  85. package/plugins/index.js +0 -12
  86. package/store/entity.js +6 -9
  87. package/store/entity.js.map +1 -1
  88. package/store/keys.js +6 -13
  89. package/store/keys.js.map +1 -1
  90. package/store/types.js +0 -3
  91. package/toolbox.d.ts +53 -1
  92. package/toolbox.js +0 -4
  93. package/types.js +0 -3
  94. package/utils/batch/batchRead.js +37 -56
  95. package/utils/batch/batchRead.js.map +1 -1
  96. package/utils/batch/batchWrite.js +33 -51
  97. package/utils/batch/batchWrite.js.map +1 -1
  98. package/utils/batch/index.js +0 -2
  99. package/utils/batch/types.js +0 -3
  100. package/utils/cleanup.js +35 -25
  101. package/utils/cleanup.js.map +1 -1
  102. package/utils/count.js +8 -13
  103. package/utils/count.js.map +1 -1
  104. package/utils/createEntity.d.ts +1 -1
  105. package/utils/createEntity.js +75 -78
  106. package/utils/createEntity.js.map +1 -1
  107. package/utils/createTable.js +25 -35
  108. package/utils/createTable.js.map +1 -1
  109. package/utils/cursor.js +7 -10
  110. package/utils/cursor.js.map +1 -1
  111. package/utils/delete.js +6 -8
  112. package/utils/delete.js.map +1 -1
  113. package/utils/entity/Entity.d.ts +1 -1
  114. package/utils/entity/Entity.js +85 -89
  115. package/utils/entity/Entity.js.map +1 -1
  116. package/utils/entity/EntityReadBatch.js +23 -31
  117. package/utils/entity/EntityReadBatch.js.map +1 -1
  118. package/utils/entity/EntityReadBatchBuilder.js +12 -15
  119. package/utils/entity/EntityReadBatchBuilder.js.map +1 -1
  120. package/utils/entity/EntityWriteBatch.js +34 -41
  121. package/utils/entity/EntityWriteBatch.js.map +1 -1
  122. package/utils/entity/EntityWriteBatchBuilder.js +15 -16
  123. package/utils/entity/EntityWriteBatchBuilder.js.map +1 -1
  124. package/utils/entity/getEntity.js +8 -9
  125. package/utils/entity/getEntity.js.map +1 -1
  126. package/utils/entity/index.js +0 -2
  127. package/utils/entity/types.js +0 -4
  128. package/utils/get.js +12 -26
  129. package/utils/get.js.map +1 -1
  130. package/utils/index.d.ts +1 -5
  131. package/utils/index.js +1 -7
  132. package/utils/put.js +7 -9
  133. package/utils/put.js.map +1 -1
  134. package/utils/query.js +77 -128
  135. package/utils/query.js.map +1 -1
  136. package/utils/scan.js +47 -73
  137. package/utils/scan.js.map +1 -1
  138. package/utils/sort.js +37 -61
  139. package/utils/sort.js.map +1 -1
  140. package/utils/table/Table.js +22 -21
  141. package/utils/table/Table.js.map +1 -1
  142. package/utils/table/TableReadBatch.js +37 -45
  143. package/utils/table/TableReadBatch.js.map +1 -1
  144. package/utils/table/TableWriteBatch.js +47 -56
  145. package/utils/table/TableWriteBatch.js.map +1 -1
  146. package/utils/table/index.js +0 -2
  147. package/utils/table/types.js +0 -3
  148. package/plugins/definitions/AttributePlugin.d.ts +0 -18
  149. package/plugins/definitions/AttributePlugin.js +0 -38
  150. package/plugins/definitions/AttributePlugin.js.map +0 -1
  151. package/plugins/definitions/FieldPathPlugin.d.ts +0 -22
  152. package/plugins/definitions/FieldPathPlugin.js +0 -26
  153. package/plugins/definitions/FieldPathPlugin.js.map +0 -1
  154. package/plugins/definitions/ValueFilterPlugin.d.ts +0 -22
  155. package/plugins/definitions/ValueFilterPlugin.js +0 -35
  156. package/plugins/definitions/ValueFilterPlugin.js.map +0 -1
  157. package/plugins/filters/andIn.d.ts +0 -3
  158. package/plugins/filters/andIn.js +0 -24
  159. package/plugins/filters/andIn.js.map +0 -1
  160. package/plugins/filters/between.d.ts +0 -3
  161. package/plugins/filters/between.js +0 -25
  162. package/plugins/filters/between.js.map +0 -1
  163. package/plugins/filters/contains.d.ts +0 -3
  164. package/plugins/filters/contains.js +0 -53
  165. package/plugins/filters/contains.js.map +0 -1
  166. package/plugins/filters/eq.d.ts +0 -3
  167. package/plugins/filters/eq.js +0 -26
  168. package/plugins/filters/eq.js.map +0 -1
  169. package/plugins/filters/fuzzy.d.ts +0 -3
  170. package/plugins/filters/fuzzy.js +0 -29
  171. package/plugins/filters/fuzzy.js.map +0 -1
  172. package/plugins/filters/gt.d.ts +0 -3
  173. package/plugins/filters/gt.js +0 -14
  174. package/plugins/filters/gt.js.map +0 -1
  175. package/plugins/filters/gte.d.ts +0 -3
  176. package/plugins/filters/gte.js +0 -14
  177. package/plugins/filters/gte.js.map +0 -1
  178. package/plugins/filters/in.d.ts +0 -3
  179. package/plugins/filters/in.js +0 -24
  180. package/plugins/filters/in.js.map +0 -1
  181. package/plugins/filters/index.d.ts +0 -2
  182. package/plugins/filters/index.js +0 -14
  183. package/plugins/filters/index.js.map +0 -1
  184. package/plugins/filters/lt.d.ts +0 -3
  185. package/plugins/filters/lt.js +0 -14
  186. package/plugins/filters/lt.js.map +0 -1
  187. package/plugins/filters/lte.d.ts +0 -3
  188. package/plugins/filters/lte.js +0 -14
  189. package/plugins/filters/lte.js.map +0 -1
  190. package/plugins/filters/startsWith.d.ts +0 -3
  191. package/plugins/filters/startsWith.js +0 -34
  192. package/plugins/filters/startsWith.js.map +0 -1
  193. package/plugins/index.js.map +0 -1
  194. package/store/types.js.map +0 -1
  195. package/toolbox.js.map +0 -1
  196. package/types.js.map +0 -1
  197. package/utils/attributes.d.ts +0 -10
  198. package/utils/attributes.js +0 -19
  199. package/utils/attributes.js.map +0 -1
  200. package/utils/batch/index.js.map +0 -1
  201. package/utils/batch/types.js.map +0 -1
  202. package/utils/entity/index.js.map +0 -1
  203. package/utils/entity/types.js.map +0 -1
  204. package/utils/filter.d.ts +0 -12
  205. package/utils/filter.js +0 -174
  206. package/utils/filter.js.map +0 -1
  207. package/utils/index.js.map +0 -1
  208. package/utils/listResponse.d.ts +0 -13
  209. package/utils/listResponse.js +0 -25
  210. package/utils/listResponse.js.map +0 -1
  211. package/utils/table/index.js.map +0 -1
  212. package/utils/table/types.js.map +0 -1
  213. package/utils/update.d.ts +0 -12
  214. package/utils/update.js +0 -12
  215. package/utils/update.js.map +0 -1
@@ -0,0 +1,22 @@
1
+ import { ValueFilter } from "../abstractions/ValueFilter.js";
2
+ class GtFilterImpl {
3
+ is(operation) {
4
+ return this.operation === operation;
5
+ }
6
+ canUse() {
7
+ return true;
8
+ }
9
+ matches({ value, compareValue }) {
10
+ return value > compareValue;
11
+ }
12
+ constructor(){
13
+ this.operation = "gt";
14
+ }
15
+ }
16
+ const GtFilter = ValueFilter.createImplementation({
17
+ implementation: GtFilterImpl,
18
+ dependencies: []
19
+ });
20
+ export { GtFilter };
21
+
22
+ //# sourceMappingURL=GtFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/ValueFilter/filters/GtFilter.js","sources":["../../../../src/feature/ValueFilter/filters/GtFilter.ts"],"sourcesContent":["import { ValueFilter } from \"../abstractions/ValueFilter.js\";\n\nclass GtFilterImpl implements ValueFilter.Interface {\n public readonly operation = \"gt\";\n\n public is(operation: string): boolean {\n return this.operation === operation;\n }\n\n public canUse(): boolean {\n return true;\n }\n\n public matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result {\n return value > compareValue;\n }\n}\n\nexport const GtFilter = ValueFilter.createImplementation({\n implementation: GtFilterImpl,\n dependencies: []\n});\n"],"names":["GtFilterImpl","operation","value","compareValue","GtFilter","ValueFilter"],"mappings":";AAEA,MAAMA;IAGK,GAAGC,SAAiB,EAAW;QAClC,OAAO,IAAI,CAAC,SAAS,KAAKA;IAC9B;IAEO,SAAkB;QACrB,OAAO;IACX;IAEO,QAAQ,EAAEC,KAAK,EAAEC,YAAY,EAA6B,EAAsB;QACnF,OAAOD,QAAQC;IACnB;;aAZgB,SAAS,GAAG;;AAahC;AAEO,MAAMC,WAAWC,YAAY,oBAAoB,CAAC;IACrD,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,11 @@
1
+ import { ValueFilter } from "../abstractions/ValueFilter.js";
2
+ declare class GteFilterImpl implements ValueFilter.Interface {
3
+ readonly operation = "gte";
4
+ is(operation: string): boolean;
5
+ canUse(): boolean;
6
+ matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result;
7
+ }
8
+ export declare const GteFilter: typeof GteFilterImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("../abstractions/ValueFilter.js").IValueFilter<any, any>>;
10
+ };
11
+ export {};
@@ -0,0 +1,22 @@
1
+ import { ValueFilter } from "../abstractions/ValueFilter.js";
2
+ class GteFilterImpl {
3
+ is(operation) {
4
+ return this.operation === operation;
5
+ }
6
+ canUse() {
7
+ return true;
8
+ }
9
+ matches({ value, compareValue }) {
10
+ return value >= compareValue;
11
+ }
12
+ constructor(){
13
+ this.operation = "gte";
14
+ }
15
+ }
16
+ const GteFilter = ValueFilter.createImplementation({
17
+ implementation: GteFilterImpl,
18
+ dependencies: []
19
+ });
20
+ export { GteFilter };
21
+
22
+ //# sourceMappingURL=GteFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/ValueFilter/filters/GteFilter.js","sources":["../../../../src/feature/ValueFilter/filters/GteFilter.ts"],"sourcesContent":["import { ValueFilter } from \"../abstractions/ValueFilter.js\";\n\nclass GteFilterImpl implements ValueFilter.Interface {\n public readonly operation = \"gte\";\n\n public is(operation: string): boolean {\n return this.operation === operation;\n }\n\n public canUse(): boolean {\n return true;\n }\n\n public matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result {\n return value >= compareValue;\n }\n}\n\nexport const GteFilter = ValueFilter.createImplementation({\n implementation: GteFilterImpl,\n dependencies: []\n});\n"],"names":["GteFilterImpl","operation","value","compareValue","GteFilter","ValueFilter"],"mappings":";AAEA,MAAMA;IAGK,GAAGC,SAAiB,EAAW;QAClC,OAAO,IAAI,CAAC,SAAS,KAAKA;IAC9B;IAEO,SAAkB;QACrB,OAAO;IACX;IAEO,QAAQ,EAAEC,KAAK,EAAEC,YAAY,EAA6B,EAAsB;QACnF,OAAOD,SAASC;IACpB;;aAZgB,SAAS,GAAG;;AAahC;AAEO,MAAMC,YAAYC,YAAY,oBAAoB,CAAC;IACtD,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,11 @@
1
+ import { ValueFilter } from "../abstractions/ValueFilter.js";
2
+ declare class InFilterImpl implements ValueFilter.Interface {
3
+ readonly operation = "in";
4
+ is(operation: string): boolean;
5
+ canUse(): boolean;
6
+ matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result;
7
+ }
8
+ export declare const InFilter: typeof InFilterImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("../abstractions/ValueFilter.js").IValueFilter<any, any>>;
10
+ };
11
+ export {};
@@ -0,0 +1,28 @@
1
+ import { WebinyError } from "@webiny/error";
2
+ import { ValueFilter } from "../abstractions/ValueFilter.js";
3
+ class InFilterImpl {
4
+ is(operation) {
5
+ return this.operation === operation;
6
+ }
7
+ canUse() {
8
+ return true;
9
+ }
10
+ matches({ value, compareValue }) {
11
+ if (!compareValue || false === Array.isArray(compareValue)) throw new WebinyError('The value given as "compareValue" must be an array!', "COMPARE_VALUE_ERROR", {
12
+ value,
13
+ compareValue
14
+ });
15
+ if (true === Array.isArray(value)) return compareValue.some((c)=>value.includes(c));
16
+ return compareValue.includes(value);
17
+ }
18
+ constructor(){
19
+ this.operation = "in";
20
+ }
21
+ }
22
+ const InFilter = ValueFilter.createImplementation({
23
+ implementation: InFilterImpl,
24
+ dependencies: []
25
+ });
26
+ export { InFilter };
27
+
28
+ //# sourceMappingURL=InFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/ValueFilter/filters/InFilter.js","sources":["../../../../src/feature/ValueFilter/filters/InFilter.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { ValueFilter } from \"../abstractions/ValueFilter.js\";\n\nclass InFilterImpl implements ValueFilter.Interface {\n public readonly operation = \"in\";\n\n public is(operation: string): boolean {\n return this.operation === operation;\n }\n\n public canUse(): boolean {\n return true;\n }\n\n public matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result {\n if (!compareValue || Array.isArray(compareValue) === false) {\n throw new WebinyError(\n `The value given as \"compareValue\" must be an array!`,\n \"COMPARE_VALUE_ERROR\",\n {\n value,\n compareValue\n }\n );\n }\n if (Array.isArray(value) === true) {\n return compareValue.some((c: any) => value.includes(c));\n }\n return compareValue.includes(value);\n }\n}\n\nexport const InFilter = ValueFilter.createImplementation({\n implementation: InFilterImpl,\n dependencies: []\n});\n"],"names":["InFilterImpl","operation","value","compareValue","Array","WebinyError","c","InFilter","ValueFilter"],"mappings":";;AAGA,MAAMA;IAGK,GAAGC,SAAiB,EAAW;QAClC,OAAO,IAAI,CAAC,SAAS,KAAKA;IAC9B;IAEO,SAAkB;QACrB,OAAO;IACX;IAEO,QAAQ,EAAEC,KAAK,EAAEC,YAAY,EAA6B,EAAsB;QACnF,IAAI,CAACA,gBAAgBC,AAAgC,UAAhCA,MAAM,OAAO,CAACD,eAC/B,MAAM,IAAIE,YACN,uDACA,uBACA;YACIH;YACAC;QACJ;QAGR,IAAIC,AAAyB,SAAzBA,MAAM,OAAO,CAACF,QACd,OAAOC,aAAa,IAAI,CAAC,CAACG,IAAWJ,MAAM,QAAQ,CAACI;QAExD,OAAOH,aAAa,QAAQ,CAACD;IACjC;;aAzBgB,SAAS,GAAG;;AA0BhC;AAEO,MAAMK,WAAWC,YAAY,oBAAoB,CAAC;IACrD,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,11 @@
1
+ import { ValueFilter } from "../abstractions/ValueFilter.js";
2
+ declare class LtFilterImpl implements ValueFilter.Interface {
3
+ readonly operation = "lt";
4
+ is(operation: string): boolean;
5
+ canUse(): boolean;
6
+ matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result;
7
+ }
8
+ export declare const LtFilter: typeof LtFilterImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("../abstractions/ValueFilter.js").IValueFilter<any, any>>;
10
+ };
11
+ export {};
@@ -0,0 +1,22 @@
1
+ import { ValueFilter } from "../abstractions/ValueFilter.js";
2
+ class LtFilterImpl {
3
+ is(operation) {
4
+ return this.operation === operation;
5
+ }
6
+ canUse() {
7
+ return true;
8
+ }
9
+ matches({ value, compareValue }) {
10
+ return value < compareValue;
11
+ }
12
+ constructor(){
13
+ this.operation = "lt";
14
+ }
15
+ }
16
+ const LtFilter = ValueFilter.createImplementation({
17
+ implementation: LtFilterImpl,
18
+ dependencies: []
19
+ });
20
+ export { LtFilter };
21
+
22
+ //# sourceMappingURL=LtFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/ValueFilter/filters/LtFilter.js","sources":["../../../../src/feature/ValueFilter/filters/LtFilter.ts"],"sourcesContent":["import { ValueFilter } from \"../abstractions/ValueFilter.js\";\n\nclass LtFilterImpl implements ValueFilter.Interface {\n public readonly operation = \"lt\";\n\n public is(operation: string): boolean {\n return this.operation === operation;\n }\n\n public canUse(): boolean {\n return true;\n }\n\n public matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result {\n return value < compareValue;\n }\n}\n\nexport const LtFilter = ValueFilter.createImplementation({\n implementation: LtFilterImpl,\n dependencies: []\n});\n"],"names":["LtFilterImpl","operation","value","compareValue","LtFilter","ValueFilter"],"mappings":";AAEA,MAAMA;IAGK,GAAGC,SAAiB,EAAW;QAClC,OAAO,IAAI,CAAC,SAAS,KAAKA;IAC9B;IAEO,SAAkB;QACrB,OAAO;IACX;IAEO,QAAQ,EAAEC,KAAK,EAAEC,YAAY,EAA6B,EAAsB;QACnF,OAAOD,QAAQC;IACnB;;aAZgB,SAAS,GAAG;;AAahC;AAEO,MAAMC,WAAWC,YAAY,oBAAoB,CAAC;IACrD,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,11 @@
1
+ import { ValueFilter } from "../abstractions/ValueFilter.js";
2
+ declare class LteFilterImpl implements ValueFilter.Interface {
3
+ readonly operation = "lte";
4
+ is(operation: string): boolean;
5
+ canUse(): boolean;
6
+ matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result;
7
+ }
8
+ export declare const LteFilter: typeof LteFilterImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("../abstractions/ValueFilter.js").IValueFilter<any, any>>;
10
+ };
11
+ export {};
@@ -0,0 +1,22 @@
1
+ import { ValueFilter } from "../abstractions/ValueFilter.js";
2
+ class LteFilterImpl {
3
+ is(operation) {
4
+ return this.operation === operation;
5
+ }
6
+ canUse() {
7
+ return true;
8
+ }
9
+ matches({ value, compareValue }) {
10
+ return value <= compareValue;
11
+ }
12
+ constructor(){
13
+ this.operation = "lte";
14
+ }
15
+ }
16
+ const LteFilter = ValueFilter.createImplementation({
17
+ implementation: LteFilterImpl,
18
+ dependencies: []
19
+ });
20
+ export { LteFilter };
21
+
22
+ //# sourceMappingURL=LteFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/ValueFilter/filters/LteFilter.js","sources":["../../../../src/feature/ValueFilter/filters/LteFilter.ts"],"sourcesContent":["import { ValueFilter } from \"../abstractions/ValueFilter.js\";\n\nclass LteFilterImpl implements ValueFilter.Interface {\n public readonly operation = \"lte\";\n\n public is(operation: string): boolean {\n return this.operation === operation;\n }\n\n public canUse(): boolean {\n return true;\n }\n\n public matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result {\n return value <= compareValue;\n }\n}\n\nexport const LteFilter = ValueFilter.createImplementation({\n implementation: LteFilterImpl,\n dependencies: []\n});\n"],"names":["LteFilterImpl","operation","value","compareValue","LteFilter","ValueFilter"],"mappings":";AAEA,MAAMA;IAGK,GAAGC,SAAiB,EAAW;QAClC,OAAO,IAAI,CAAC,SAAS,KAAKA;IAC9B;IAEO,SAAkB;QACrB,OAAO;IACX;IAEO,QAAQ,EAAEC,KAAK,EAAEC,YAAY,EAA6B,EAAsB;QACnF,OAAOD,SAASC;IACpB;;aAZgB,SAAS,GAAG;;AAahC;AAEO,MAAMC,YAAYC,YAAY,oBAAoB,CAAC;IACtD,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,11 @@
1
+ import { ValueFilter } from "../abstractions/ValueFilter.js";
2
+ declare class StartsWithFilterImpl implements ValueFilter.Interface {
3
+ readonly operation = "startsWith";
4
+ is(operation: string): boolean;
5
+ canUse({ compareValue }: ValueFilter.CanUseParams): boolean;
6
+ matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result;
7
+ }
8
+ export declare const StartsWithFilter: typeof StartsWithFilterImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("../abstractions/ValueFilter.js").IValueFilter<any, any>>;
10
+ };
11
+ export {};
@@ -0,0 +1,29 @@
1
+ import { ValueFilter } from "../abstractions/ValueFilter.js";
2
+ class StartsWithFilterImpl {
3
+ is(operation) {
4
+ return this.operation === operation;
5
+ }
6
+ canUse({ compareValue }) {
7
+ if ("" === compareValue || null == compareValue) return false;
8
+ return true;
9
+ }
10
+ matches({ value, compareValue }) {
11
+ if (null === value && null === compareValue || void 0 === value && void 0 === compareValue) return true;
12
+ const compareValueInLowerCase = compareValue.toLowerCase();
13
+ if ("string" != typeof value) {
14
+ if (true === Array.isArray(value)) return value.some((v)=>v.toLowerCase().startsWith(compareValueInLowerCase));
15
+ return false;
16
+ }
17
+ return value.toLowerCase().startsWith(compareValueInLowerCase);
18
+ }
19
+ constructor(){
20
+ this.operation = "startsWith";
21
+ }
22
+ }
23
+ const StartsWithFilter = ValueFilter.createImplementation({
24
+ implementation: StartsWithFilterImpl,
25
+ dependencies: []
26
+ });
27
+ export { StartsWithFilter };
28
+
29
+ //# sourceMappingURL=StartsWithFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/ValueFilter/filters/StartsWithFilter.js","sources":["../../../../src/feature/ValueFilter/filters/StartsWithFilter.ts"],"sourcesContent":["import { ValueFilter } from \"../abstractions/ValueFilter.js\";\n\nclass StartsWithFilterImpl implements ValueFilter.Interface {\n public readonly operation = \"startsWith\";\n\n public is(operation: string): boolean {\n return this.operation === operation;\n }\n\n public canUse({ compareValue }: ValueFilter.CanUseParams): boolean {\n if (compareValue === \"\" || compareValue === null || compareValue === undefined) {\n return false;\n }\n return true;\n }\n\n public matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result {\n /**\n * Match null/undefined values.\n */\n if (\n (value === null && compareValue === null) ||\n (value === undefined && compareValue === undefined)\n ) {\n return true;\n }\n /**\n * We do \"case-insensitive\" comparison.\n */\n const compareValueInLowerCase = compareValue.toLowerCase();\n\n if (typeof value !== \"string\") {\n if (Array.isArray(value) === true) {\n return value.some((v: string) => {\n return v.toLowerCase().startsWith(compareValueInLowerCase);\n });\n }\n return false;\n }\n\n return value.toLowerCase().startsWith(compareValueInLowerCase);\n }\n}\n\nexport const StartsWithFilter = ValueFilter.createImplementation({\n implementation: StartsWithFilterImpl,\n dependencies: []\n});\n"],"names":["StartsWithFilterImpl","operation","compareValue","value","undefined","compareValueInLowerCase","Array","v","StartsWithFilter","ValueFilter"],"mappings":";AAEA,MAAMA;IAGK,GAAGC,SAAiB,EAAW;QAClC,OAAO,IAAI,CAAC,SAAS,KAAKA;IAC9B;IAEO,OAAO,EAAEC,YAAY,EAA4B,EAAW;QAC/D,IAAIA,AAAiB,OAAjBA,gBAAgDA,QAAzBA,cACvB,OAAO;QAEX,OAAO;IACX;IAEO,QAAQ,EAAEC,KAAK,EAAED,YAAY,EAA6B,EAAsB;QAInF,IACKC,AAAU,SAAVA,SAAkBD,AAAiB,SAAjBA,gBAClBC,AAAUC,WAAVD,SAAuBD,AAAiBE,WAAjBF,cAExB,OAAO;QAKX,MAAMG,0BAA0BH,aAAa,WAAW;QAExD,IAAI,AAAiB,YAAjB,OAAOC,OAAoB;YAC3B,IAAIG,AAAyB,SAAzBA,MAAM,OAAO,CAACH,QACd,OAAOA,MAAM,IAAI,CAAC,CAACI,IACRA,EAAE,WAAW,GAAG,UAAU,CAACF;YAG1C,OAAO;QACX;QAEA,OAAOF,MAAM,WAAW,GAAG,UAAU,CAACE;IAC1C;;aAtCgB,SAAS,GAAG;;AAuChC;AAEO,MAAMG,mBAAmBC,YAAY,oBAAoB,CAAC;IAC7D,gBAAgBT;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,3 @@
1
+ export { ValueFilter } from "./abstractions/ValueFilter.js";
2
+ export { ValueFilterRegistry } from "./abstractions/ValueFilterRegistry.js";
3
+ export { ValueFilterFeature } from "./feature.js";
@@ -0,0 +1,3 @@
1
+ export { ValueFilter } from "./abstractions/ValueFilter.js";
2
+ export { ValueFilterRegistry } from "./abstractions/ValueFilterRegistry.js";
3
+ export { ValueFilterFeature } from "./feature.js";
package/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from "./utils/index.js";
3
3
  export * from "./plugins/index.js";
4
4
  export type { DbItem } from "./types.js";
5
5
  export { DynamoDbDriver };
6
+ export declare const registerExtension: () => import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>;
package/index.js CHANGED
@@ -1,6 +1,13 @@
1
- import { default as DynamoDbDriver } from "./DynamoDbDriver.js";
1
+ import { createRegisterExtensionPlugin } from "@webiny/handler";
2
+ import { FilterUtilFeature } from "./feature/FilterUtil/index.js";
3
+ import { ValueFilterFeature } from "./feature/ValueFilter/index.js";
2
4
  export * from "./utils/index.js";
3
5
  export * from "./plugins/index.js";
4
- export { DynamoDbDriver };
6
+ const registerExtension = ()=>createRegisterExtensionPlugin(async (context)=>{
7
+ FilterUtilFeature.register(context.container);
8
+ ValueFilterFeature.register(context.container);
9
+ });
10
+ export { default as DynamoDbDriver } from "./DynamoDbDriver.js";
11
+ export { registerExtension };
5
12
 
6
13
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["default","DynamoDbDriver"],"sources":["index.ts"],"sourcesContent":["import { default as DynamoDbDriver } from \"./DynamoDbDriver.js\";\n\nexport * from \"./utils/index.js\";\nexport * from \"./plugins/index.js\";\nexport type { DbItem } from \"./types.js\";\n\nexport { DynamoDbDriver };\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,cAAc;AAElC;AACA;AAGA,SAASA,cAAc","ignoreList":[]}
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 \"~/feature/ValueFilter/index.js\";\nimport { FilterUtilFeature } from \"~/feature/FilterUtil/index.js\";\n\nexport * from \"./utils/index.js\";\nexport * from \"./plugins/index.js\";\nexport type { DbItem } from \"./types.js\";\n\nexport { DynamoDbDriver };\n\nexport const registerExtension = () => {\n return createRegisterExtensionPlugin(async context => {\n FilterUtilFeature.register(context.container);\n ValueFilterFeature.register(context.container);\n });\n};\n"],"names":["registerExtension","createRegisterExtensionPlugin","context","FilterUtilFeature","ValueFilterFeature"],"mappings":";;;;;AAWO,MAAMA,oBAAoB,IACtBC,8BAA8B,OAAMC;QACvCC,kBAAkB,QAAQ,CAACD,QAAQ,SAAS;QAC5CE,mBAAmB,QAAQ,CAACF,QAAQ,SAAS;IACjD"}
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/db-dynamodb",
3
- "version": "0.0.0-unstable.6f45466a1d",
3
+ "version": "0.0.0-unstable.7be00a75a9",
4
4
  "type": "module",
5
- "main": "index.js",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
6
9
  "repository": {
7
10
  "type": "git",
8
11
  "url": "https://github.com/webiny/webiny-js.git"
@@ -11,30 +14,35 @@
11
14
  "author": "Webiny Ltd",
12
15
  "license": "MIT",
13
16
  "dependencies": {
14
- "@webiny/api": "0.0.0-unstable.6f45466a1d",
15
- "@webiny/aws-sdk": "0.0.0-unstable.6f45466a1d",
16
- "@webiny/db": "0.0.0-unstable.6f45466a1d",
17
- "@webiny/error": "0.0.0-unstable.6f45466a1d",
18
- "@webiny/plugins": "0.0.0-unstable.6f45466a1d",
19
- "@webiny/utils": "0.0.0-unstable.6f45466a1d",
20
- "date-fns": "2.30.0",
21
- "dot-prop": "6.0.1",
17
+ "@webiny/api": "0.0.0-unstable.7be00a75a9",
18
+ "@webiny/aws-sdk": "0.0.0-unstable.7be00a75a9",
19
+ "@webiny/db": "0.0.0-unstable.7be00a75a9",
20
+ "@webiny/error": "0.0.0-unstable.7be00a75a9",
21
+ "@webiny/feature": "0.0.0-unstable.7be00a75a9",
22
+ "@webiny/plugins": "0.0.0-unstable.7be00a75a9",
23
+ "@webiny/utils": "0.0.0-unstable.7be00a75a9",
24
+ "date-fns": "4.2.1",
25
+ "dot-prop": "10.1.0",
22
26
  "dynamodb-toolbox": "0.9.5",
23
- "fuse.js": "7.1.0",
24
- "lodash": "4.17.23"
27
+ "fuse.js": "7.3.0",
28
+ "lodash": "4.18.1"
25
29
  },
26
30
  "devDependencies": {
27
31
  "@types/is-number": "7.0.5",
28
- "@webiny/build-tools": "0.0.0-unstable.6f45466a1d",
29
- "@webiny/project-utils": "0.0.0-unstable.6f45466a1d",
32
+ "@webiny/build-tools": "0.0.0-unstable.7be00a75a9",
33
+ "@webiny/di": "0.0.0-unstable.7be00a75a9",
34
+ "@webiny/handler": "0.0.0-unstable.7be00a75a9",
35
+ "@webiny/project-utils": "0.0.0-unstable.7be00a75a9",
30
36
  "jest-dynalite": "3.6.1",
31
- "rimraf": "6.1.2",
32
- "typescript": "5.9.3",
33
- "vitest": "3.2.4"
37
+ "rimraf": "6.1.3",
38
+ "typescript": "6.0.3",
39
+ "vitest": "4.1.7"
34
40
  },
35
41
  "publishConfig": {
36
- "access": "public",
37
- "directory": "dist"
42
+ "access": "public"
38
43
  },
39
- "gitHead": "6f45466a1d9fb94f6156923501eb90ac303b81a5"
44
+ "gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
45
+ "webiny": {
46
+ "publishFrom": "dist"
47
+ }
40
48
  }
@@ -1,34 +1,25 @@
1
1
  import { ValueTransformPlugin } from "./ValueTransformPlugin.js";
2
- import WebinyError from "@webiny/error";
3
2
  import { parseISO } from "date-fns";
4
- const transformDateTime = params => {
5
- const {
6
- value
7
- } = params;
8
- if (value === null || value === undefined) {
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
+ });
9
13
  return null;
10
- } else if (typeof value === "string") {
11
- const parsedDateTime = parseISO(value).getTime();
12
- if (isNaN(parsedDateTime) === false) {
13
- return parsedDateTime;
14
- }
15
- } else if (value instanceof Date || typeof value?.getTime === "function") {
16
- /**
17
- * In this case we assume this is a date object, and we just get the time.
18
- */
19
- return value.getTime();
20
- }
21
- throw new WebinyError("Could not parse given dateTime value.", "PARSE_DATE_ERROR", {
22
- value
23
- });
24
14
  };
25
- export class DateTimeTransformPlugin extends ValueTransformPlugin {
26
- constructor(params) {
27
- super({
28
- transform: transformDateTime,
29
- ...params
30
- });
31
- }
15
+ class DateTimeTransformPlugin extends ValueTransformPlugin {
16
+ constructor(params){
17
+ super({
18
+ transform: transformDateTime,
19
+ ...params
20
+ });
21
+ }
32
22
  }
23
+ export { DateTimeTransformPlugin };
33
24
 
34
25
  //# sourceMappingURL=DateTimeTransformPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ValueTransformPlugin","WebinyError","parseISO","transformDateTime","params","value","undefined","parsedDateTime","getTime","isNaN","Date","DateTimeTransformPlugin","constructor","transform"],"sources":["DateTimeTransformPlugin.ts"],"sourcesContent":["import type {\n ValueTransformPluginParams,\n ValueTransformPluginParamsTransformParams\n} from \"./ValueTransformPlugin.js\";\nimport { ValueTransformPlugin } from \"./ValueTransformPlugin.js\";\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 || 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 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":"AAIA,SAASA,oBAAoB;AAC7B,OAAOC,WAAW,MAAM,eAAe;AACvC,SAASC,QAAQ,QAAQ,UAAU;AAEnC,MAAMC,iBAAiB,GAAIC,MAAiD,IAAoB;EAC5F,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EACxB,IAAIC,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKC,SAAS,EAAE;IACvC,OAAO,IAAI;EACf,CAAC,MAAM,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;IAClC,MAAME,cAAc,GAAGL,QAAQ,CAACG,KAAK,CAAC,CAACG,OAAO,CAAC,CAAC;IAChD,IAAIC,KAAK,CAACF,cAAc,CAAC,KAAK,KAAK,EAAE;MACjC,OAAOA,cAAc;IACzB;EACJ,CAAC,MAAM,IAAIF,KAAK,YAAYK,IAAI,IAAI,OAAQL,KAAK,EAAsBG,OAAO,KAAK,UAAU,EAAE;IAC3F;AACR;AACA;IACQ,OAAOH,KAAK,CAACG,OAAO,CAAC,CAAC;EAC1B;EAEA,MAAM,IAAIP,WAAW,CAAC,uCAAuC,EAAE,kBAAkB,EAAE;IAC/EI;EACJ,CAAC,CAAC;AACN,CAAC;AAED,OAAO,MAAMM,uBAAuB,SAASX,oBAAoB,CAAC;EACvDY,WAAWA,CAACR,MAAqD,EAAE;IACtE,KAAK,CAAC;MACFS,SAAS,EAAEV,iBAAiB;MAC5B,GAAGC;IACP,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
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,44 +1,41 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- export class FieldPlugin extends Plugin {
3
- constructor(params) {
4
- super();
5
- this.fieldType = params.type || "string";
6
- this.dynamoDbType = params.type === "date" ? "string" : params.type;
7
- this.field = params.field;
8
- this.path = params.path;
9
- this.sortable = params.sortable === undefined ? true : params.sortable;
10
- this._transformValue = params.transformValue;
11
- }
12
- getPath() {
13
- return this.path || this.field;
14
- }
15
- getType() {
16
- return this.fieldType;
17
- }
18
- getField() {
19
- return this.field;
20
- }
21
- getDynamoDbType() {
22
- return this.dynamoDbType;
23
- }
24
- transformValue(value) {
25
- if (this._transformValue) {
26
- return this.transformValue(value);
2
+ class FieldPlugin extends Plugin {
3
+ constructor(params){
4
+ super();
5
+ this.fieldType = params.type || "string";
6
+ this.dynamoDbType = "date" === params.type ? "string" : params.type;
7
+ this.field = params.field;
8
+ this.path = params.path;
9
+ this.sortable = void 0 === params.sortable ? true : params.sortable;
10
+ this._transformValue = params.transformValue;
27
11
  }
28
- switch (this.fieldType) {
29
- case "number":
30
- return Number(value);
31
- case "date":
32
- if (!value) {
33
- return null;
12
+ getPath() {
13
+ return this.path || this.field;
14
+ }
15
+ getType() {
16
+ return this.fieldType;
17
+ }
18
+ getField() {
19
+ return this.field;
20
+ }
21
+ getDynamoDbType() {
22
+ return this.dynamoDbType;
23
+ }
24
+ transformValue(value) {
25
+ if (this._transformValue) return this.transformValue(value);
26
+ switch(this.fieldType){
27
+ case "number":
28
+ return Number(value);
29
+ case "date":
30
+ if (!value) return null;
31
+ return new Date(value);
34
32
  }
35
- return new Date(value);
33
+ return value;
34
+ }
35
+ isSortable() {
36
+ return this.sortable;
36
37
  }
37
- return value;
38
- }
39
- isSortable() {
40
- return this.sortable;
41
- }
42
38
  }
39
+ export { FieldPlugin };
43
40
 
44
41
  //# sourceMappingURL=FieldPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Plugin","FieldPlugin","constructor","params","fieldType","type","dynamoDbType","field","path","sortable","undefined","_transformValue","transformValue","getPath","getType","getField","getDynamoDbType","value","Number","Date","isSortable"],"sources":["FieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { DynamoDBTypes } from \"~/toolbox.js\";\n\nexport type FieldType = DynamoDBTypes & \"date\" & any;\n\nexport interface TransformValueCb {\n (value: any): any;\n}\n\nexport interface FieldPluginParams {\n /**\n * Default is string.\n */\n type?: FieldType;\n field: string;\n path?: string;\n /**\n * Default is true.\n */\n sortable?: boolean;\n\n transformValue?: TransformValueCb;\n}\n\nexport abstract class FieldPlugin extends Plugin {\n private readonly path?: string;\n private readonly field: string;\n private readonly fieldType: FieldType;\n private readonly dynamoDbType: DynamoDBTypes;\n private readonly sortable: boolean;\n private readonly _transformValue: TransformValueCb | undefined;\n\n public constructor(params: FieldPluginParams) {\n super();\n this.fieldType = params.type || \"string\";\n this.dynamoDbType = params.type === \"date\" ? \"string\" : params.type;\n this.field = params.field;\n this.path = params.path;\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this._transformValue = params.transformValue;\n }\n\n public getPath(): string {\n return this.path || this.field;\n }\n\n public getType(): FieldType {\n return this.fieldType;\n }\n\n public getField(): string {\n return this.field;\n }\n\n public getDynamoDbType(): string {\n return this.dynamoDbType;\n }\n\n public transformValue(value: any): any {\n if (this._transformValue) {\n return this.transformValue(value);\n }\n switch (this.fieldType) {\n case \"number\":\n return Number(value);\n case \"date\":\n if (!value) {\n return null;\n }\n return new Date(value);\n }\n return value;\n }\n\n public isSortable(): boolean {\n return this.sortable;\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAwBxC,OAAO,MAAeC,WAAW,SAASD,MAAM,CAAC;EAQtCE,WAAWA,CAACC,MAAyB,EAAE;IAC1C,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,MAAM,CAACE,IAAI,IAAI,QAAQ;IACxC,IAAI,CAACC,YAAY,GAAGH,MAAM,CAACE,IAAI,KAAK,MAAM,GAAG,QAAQ,GAAGF,MAAM,CAACE,IAAI;IACnE,IAAI,CAACE,KAAK,GAAGJ,MAAM,CAACI,KAAK;IACzB,IAAI,CAACC,IAAI,GAAGL,MAAM,CAACK,IAAI;IACvB,IAAI,CAACC,QAAQ,GAAGN,MAAM,CAACM,QAAQ,KAAKC,SAAS,GAAG,IAAI,GAAGP,MAAM,CAACM,QAAQ;IACtE,IAAI,CAACE,eAAe,GAAGR,MAAM,CAACS,cAAc;EAChD;EAEOC,OAAOA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACL,IAAI,IAAI,IAAI,CAACD,KAAK;EAClC;EAEOO,OAAOA,CAAA,EAAc;IACxB,OAAO,IAAI,CAACV,SAAS;EACzB;EAEOW,QAAQA,CAAA,EAAW;IACtB,OAAO,IAAI,CAACR,KAAK;EACrB;EAEOS,eAAeA,CAAA,EAAW;IAC7B,OAAO,IAAI,CAACV,YAAY;EAC5B;EAEOM,cAAcA,CAACK,KAAU,EAAO;IACnC,IAAI,IAAI,CAACN,eAAe,EAAE;MACtB,OAAO,IAAI,CAACC,cAAc,CAACK,KAAK,CAAC;IACrC;IACA,QAAQ,IAAI,CAACb,SAAS;MAClB,KAAK,QAAQ;QACT,OAAOc,MAAM,CAACD,KAAK,CAAC;MACxB,KAAK,MAAM;QACP,IAAI,CAACA,KAAK,EAAE;UACR,OAAO,IAAI;QACf;QACA,OAAO,IAAIE,IAAI,CAACF,KAAK,CAAC;IAC9B;IACA,OAAOA,KAAK;EAChB;EAEOG,UAAUA,CAAA,EAAY;IACzB,OAAO,IAAI,CAACX,QAAQ;EACxB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"plugins/definitions/FieldPlugin.js","sources":["../../../src/plugins/definitions/FieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { DynamoDBTypes } from \"~/toolbox.js\";\n\nexport type FieldType = DynamoDBTypes & \"date\" & any;\n\nexport interface TransformValueCb {\n (value: any): any;\n}\n\nexport interface FieldPluginParams {\n /**\n * Default is string.\n */\n type?: FieldType;\n field: string;\n path?: string;\n /**\n * Default is true.\n */\n sortable?: boolean;\n\n transformValue?: TransformValueCb;\n}\n\nexport abstract class FieldPlugin extends Plugin {\n private readonly path?: string;\n private readonly field: string;\n private readonly fieldType: FieldType;\n private readonly dynamoDbType: DynamoDBTypes;\n private readonly sortable: boolean;\n private readonly _transformValue: TransformValueCb | undefined;\n\n public constructor(params: FieldPluginParams) {\n super();\n this.fieldType = params.type || \"string\";\n this.dynamoDbType = params.type === \"date\" ? \"string\" : params.type;\n this.field = params.field;\n this.path = params.path;\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this._transformValue = params.transformValue;\n }\n\n public getPath(): string {\n return this.path || this.field;\n }\n\n public getType(): FieldType {\n return this.fieldType;\n }\n\n public getField(): string {\n return this.field;\n }\n\n public getDynamoDbType(): string {\n return this.dynamoDbType;\n }\n\n public transformValue(value: any): any {\n if (this._transformValue) {\n return this.transformValue(value);\n }\n switch (this.fieldType) {\n case \"number\":\n return Number(value);\n case \"date\":\n if (!value) {\n return null;\n }\n return new Date(value);\n }\n return value;\n }\n\n public isSortable(): boolean {\n return this.sortable;\n }\n}\n"],"names":["FieldPlugin","Plugin","params","undefined","value","Number","Date"],"mappings":";AAwBO,MAAeA,oBAAoBC;IAQtC,YAAmBC,MAAyB,CAAE;QAC1C,KAAK;QACL,IAAI,CAAC,SAAS,GAAGA,OAAO,IAAI,IAAI;QAChC,IAAI,CAAC,YAAY,GAAGA,AAAgB,WAAhBA,OAAO,IAAI,GAAc,WAAWA,OAAO,IAAI;QACnE,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI;QACvB,IAAI,CAAC,QAAQ,GAAGA,AAAoBC,WAApBD,OAAO,QAAQ,GAAiB,OAAOA,OAAO,QAAQ;QACtE,IAAI,CAAC,eAAe,GAAGA,OAAO,cAAc;IAChD;IAEO,UAAkB;QACrB,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK;IAClC;IAEO,UAAqB;QACxB,OAAO,IAAI,CAAC,SAAS;IACzB;IAEO,WAAmB;QACtB,OAAO,IAAI,CAAC,KAAK;IACrB;IAEO,kBAA0B;QAC7B,OAAO,IAAI,CAAC,YAAY;IAC5B;IAEO,eAAeE,KAAU,EAAO;QACnC,IAAI,IAAI,CAAC,eAAe,EACpB,OAAO,IAAI,CAAC,cAAc,CAACA;QAE/B,OAAQ,IAAI,CAAC,SAAS;YAClB,KAAK;gBACD,OAAOC,OAAOD;YAClB,KAAK;gBACD,IAAI,CAACA,OACD,OAAO;gBAEX,OAAO,IAAIE,KAAKF;QACxB;QACA,OAAOA;IACX;IAEO,aAAsB;QACzB,OAAO,IAAI,CAAC,QAAQ;IACxB;AACJ"}
@@ -1,46 +1,34 @@
1
1
  import { ValueTransformPlugin } from "./ValueTransformPlugin.js";
2
- import WebinyError from "@webiny/error";
3
- const transformTime = params => {
4
- const {
5
- value
6
- } = params;
7
- if (value === undefined || value === null) {
8
- throw new WebinyError(`Time value is null or undefined.`, "TIME_PARSE_ERROR", {
9
- value
2
+ import error from "@webiny/error";
3
+ const transformTime = (params)=>{
4
+ const { value } = params;
5
+ if (null == value) throw new error("Time value is null or undefined.", "TIME_PARSE_ERROR", {
6
+ value
10
7
  });
11
- } else if (typeof value === "boolean" || value === "" || Array.isArray(value)) {
12
- throw new WebinyError("Field value must be a string because field is defined as time.", "TIME_PARSE_ERROR", {
13
- value
8
+ if ("boolean" == typeof value || "" === value || Array.isArray(value)) throw new error("Field value must be a string because field is defined as time.", "TIME_PARSE_ERROR", {
9
+ value
14
10
  });
15
- }
16
- const converted = Number(`${value}`);
17
- if (typeof value === "number" || isNaN(converted) === false) {
18
- return Number(value);
19
- } else if (typeof value !== "string") {
20
- throw new WebinyError("Field value must be a string because field is defined as time.", "TIME_PARSE_ERROR", {
21
- value
11
+ const converted = Number(`${value}`);
12
+ if ("number" == typeof value || false === isNaN(converted)) return Number(value);
13
+ if ("string" != typeof value) throw new error("Field value must be a string because field is defined as time.", "TIME_PARSE_ERROR", {
14
+ value
22
15
  });
23
- }
24
- /**
25
- * This is for the time format, eg. 12:36:25 or 12:36:25.881
26
- */
27
- const [time, milliseconds = 0] = value.split(".");
28
- const values = time.split(":").map(Number);
29
- if (values.length < 2) {
30
- throw new WebinyError("Time must contain at least hours and minutes.", "TIME_PARSE_ERROR", {
31
- value
16
+ const [time, milliseconds = 0] = value.split(".");
17
+ const values = time.split(":").map(Number);
18
+ if (values.length < 2) throw new error("Time must contain at least hours and minutes.", "TIME_PARSE_ERROR", {
19
+ value
32
20
  });
33
- }
34
- const [hours, minutes, seconds = 0] = values;
35
- return (hours * 60 * 60 + minutes * 60 + seconds) * 1000 + Number(milliseconds);
21
+ const [hours, minutes, seconds = 0] = values;
22
+ return (60 * hours * 60 + 60 * minutes + seconds) * 1000 + Number(milliseconds);
36
23
  };
37
- export class TimeTransformPlugin extends ValueTransformPlugin {
38
- constructor(params) {
39
- super({
40
- transform: transformTime,
41
- ...params
42
- });
43
- }
24
+ class TimeTransformPlugin extends ValueTransformPlugin {
25
+ constructor(params){
26
+ super({
27
+ transform: transformTime,
28
+ ...params
29
+ });
30
+ }
44
31
  }
32
+ export { TimeTransformPlugin };
45
33
 
46
34
  //# sourceMappingURL=TimeTransformPlugin.js.map