@webiny/api-opensearch 6.4.11 → 6.6.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/client.js +1 -24
  2. package/client.js.map +1 -1
  3. package/exports/api/opensearch.d.ts +6 -1
  4. package/exports/api/opensearch.js +6 -1
  5. package/features/OpenSearchClient/abstraction.d.ts +3 -3
  6. package/features/OpenSearchClient/abstraction.js.map +1 -1
  7. package/features/OpenSearchClient/feature.d.ts +2 -1
  8. package/features/OpenSearchClient/feature.js +5 -3
  9. package/features/OpenSearchClient/feature.js.map +1 -1
  10. package/features/OpenSearchField/OpenSearchField.d.ts +18 -0
  11. package/{plugins/definition/OpenSearchFieldPlugin.js → features/OpenSearchField/OpenSearchField.js} +10 -13
  12. package/features/OpenSearchField/OpenSearchField.js.map +1 -0
  13. package/features/OpenSearchField/OpenSearchFieldFactory.d.ts +9 -0
  14. package/features/OpenSearchField/OpenSearchFieldFactory.js +14 -0
  15. package/features/OpenSearchField/OpenSearchFieldFactory.js.map +1 -0
  16. package/features/OpenSearchField/abstractions/OpenSearchField.d.ts +35 -0
  17. package/features/OpenSearchField/abstractions/OpenSearchField.js +6 -0
  18. package/features/OpenSearchField/abstractions/OpenSearchField.js.map +1 -0
  19. package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.d.ts +8 -0
  20. package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.js +5 -0
  21. package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.js.map +1 -0
  22. package/features/OpenSearchField/feature.d.ts +4 -0
  23. package/features/OpenSearchField/feature.js +11 -0
  24. package/features/OpenSearchField/feature.js.map +1 -0
  25. package/features/OpenSearchIndex/OpenSearchIndexRegistry.d.ts +12 -0
  26. package/features/OpenSearchIndex/OpenSearchIndexRegistry.js +30 -0
  27. package/features/OpenSearchIndex/OpenSearchIndexRegistry.js.map +1 -0
  28. package/features/OpenSearchIndex/abstractions/OpenSearchIndex.d.ts +9 -0
  29. package/features/OpenSearchIndex/abstractions/OpenSearchIndex.js +5 -0
  30. package/features/OpenSearchIndex/abstractions/OpenSearchIndex.js.map +1 -0
  31. package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.d.ts +9 -0
  32. package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js +5 -0
  33. package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js.map +1 -0
  34. package/features/OpenSearchIndex/feature.d.ts +4 -0
  35. package/features/OpenSearchIndex/feature.js +11 -0
  36. package/features/OpenSearchIndex/feature.js.map +1 -0
  37. package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.d.ts +12 -0
  38. package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.js +28 -0
  39. package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.js.map +1 -0
  40. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.d.ts +11 -0
  41. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js +5 -0
  42. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js.map +1 -0
  43. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.d.ts +10 -0
  44. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js +5 -0
  45. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js.map +1 -0
  46. package/features/OpenSearchQueryBuilderOperator/feature.d.ts +4 -0
  47. package/features/OpenSearchQueryBuilderOperator/feature.js +41 -0
  48. package/features/OpenSearchQueryBuilderOperator/feature.js.map +1 -0
  49. package/features/OpenSearchQueryBuilderOperator/operators/AndIn.d.ts +9 -0
  50. package/{plugins/operator/andIn.js → features/OpenSearchQueryBuilderOperator/operators/AndIn.js} +8 -7
  51. package/features/OpenSearchQueryBuilderOperator/operators/AndIn.js.map +1 -0
  52. package/features/OpenSearchQueryBuilderOperator/operators/Between.d.ts +9 -0
  53. package/{plugins/operator/between.js → features/OpenSearchQueryBuilderOperator/operators/Between.js} +8 -7
  54. package/features/OpenSearchQueryBuilderOperator/operators/Between.js.map +1 -0
  55. package/features/OpenSearchQueryBuilderOperator/operators/Contains.d.ts +9 -0
  56. package/features/OpenSearchQueryBuilderOperator/operators/Contains.js +27 -0
  57. package/features/OpenSearchQueryBuilderOperator/operators/Contains.js.map +1 -0
  58. package/features/OpenSearchQueryBuilderOperator/operators/Equal.d.ts +9 -0
  59. package/{plugins/operator/equal.js → features/OpenSearchQueryBuilderOperator/operators/Equal.js} +8 -7
  60. package/features/OpenSearchQueryBuilderOperator/operators/Equal.js.map +1 -0
  61. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.d.ts +9 -0
  62. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.js +23 -0
  63. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.js.map +1 -0
  64. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.d.ts +9 -0
  65. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.js +23 -0
  66. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.js.map +1 -0
  67. package/features/OpenSearchQueryBuilderOperator/operators/In.d.ts +9 -0
  68. package/{plugins/operator/in.js → features/OpenSearchQueryBuilderOperator/operators/In.js} +8 -7
  69. package/features/OpenSearchQueryBuilderOperator/operators/In.js.map +1 -0
  70. package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.d.ts +9 -0
  71. package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.js +23 -0
  72. package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.js.map +1 -0
  73. package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.d.ts +9 -0
  74. package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.js +23 -0
  75. package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.js.map +1 -0
  76. package/features/OpenSearchQueryBuilderOperator/operators/Not.d.ts +9 -0
  77. package/{plugins/operator/not.js → features/OpenSearchQueryBuilderOperator/operators/Not.js} +8 -7
  78. package/features/OpenSearchQueryBuilderOperator/operators/Not.js.map +1 -0
  79. package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.d.ts +9 -0
  80. package/{plugins/operator/notBetween.js → features/OpenSearchQueryBuilderOperator/operators/NotBetween.js} +8 -7
  81. package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.js.map +1 -0
  82. package/features/OpenSearchQueryBuilderOperator/operators/NotContains.d.ts +9 -0
  83. package/features/OpenSearchQueryBuilderOperator/operators/NotContains.js +27 -0
  84. package/features/OpenSearchQueryBuilderOperator/operators/NotContains.js.map +1 -0
  85. package/features/OpenSearchQueryBuilderOperator/operators/NotIn.d.ts +9 -0
  86. package/{plugins/operator/notIn.js → features/OpenSearchQueryBuilderOperator/operators/NotIn.js} +8 -7
  87. package/features/OpenSearchQueryBuilderOperator/operators/NotIn.js.map +1 -0
  88. package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.d.ts +9 -0
  89. package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js +22 -0
  90. package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js.map +1 -0
  91. package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.d.ts +9 -0
  92. package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.js +22 -0
  93. package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.js.map +1 -0
  94. package/index.d.ts +2 -10
  95. package/index.js +3 -28
  96. package/indices.d.ts +2 -8
  97. package/indices.js +1 -12
  98. package/package.json +8 -11
  99. package/registerOpenSearchCore.d.ts +3 -0
  100. package/registerOpenSearchCore.js +20 -0
  101. package/registerOpenSearchCore.js.map +1 -0
  102. package/sort.d.ts +2 -2
  103. package/sort.js +2 -2
  104. package/sort.js.map +1 -1
  105. package/testing/createBlankQuery.d.ts +2 -0
  106. package/testing/createBlankQuery.js +9 -0
  107. package/testing/createBlankQuery.js.map +1 -0
  108. package/testing/createTestOpenSearchClient.d.ts +11 -0
  109. package/testing/createTestOpenSearchClient.js +162 -0
  110. package/testing/createTestOpenSearchClient.js.map +1 -0
  111. package/testing/index.d.ts +4 -0
  112. package/testing/index.js +4 -0
  113. package/testing/registerOpenSearchCoreForTests.d.ts +1 -0
  114. package/testing/registerOpenSearchCoreForTests.js +9 -0
  115. package/testing/registerOpenSearchCoreForTests.js.map +1 -0
  116. package/testing/setupTestIndexManager.d.ts +13 -0
  117. package/testing/setupTestIndexManager.js +26 -0
  118. package/testing/setupTestIndexManager.js.map +1 -0
  119. package/types.d.ts +0 -8
  120. package/types.js.map +1 -1
  121. package/utils/createIndex.d.ts +2 -2
  122. package/utils/createIndex.js +2 -8
  123. package/utils/createIndex.js.map +1 -1
  124. package/where.d.ts +4 -4
  125. package/where.js +5 -5
  126. package/where.js.map +1 -1
  127. package/db/entity.d.ts +0 -7
  128. package/db/entity.js +0 -18
  129. package/db/entity.js.map +0 -1
  130. package/db/index.d.ts +0 -3
  131. package/db/index.js +0 -3
  132. package/db/table.d.ts +0 -7
  133. package/db/table.js +0 -13
  134. package/db/table.js.map +0 -1
  135. package/db/types.d.ts +0 -6
  136. package/db/types.js +0 -0
  137. package/features/OpenSearchClient/OpenSearchClient.d.ts +0 -12
  138. package/features/OpenSearchClient/OpenSearchClient.js +0 -19
  139. package/features/OpenSearchClient/OpenSearchClient.js.map +0 -1
  140. package/features/OpenSearchContext/OpenSearchContext.d.ts +0 -8
  141. package/features/OpenSearchContext/OpenSearchContext.js +0 -14
  142. package/features/OpenSearchContext/OpenSearchContext.js.map +0 -1
  143. package/features/OpenSearchContext/abstraction.d.ts +0 -14
  144. package/features/OpenSearchContext/abstraction.js +0 -5
  145. package/features/OpenSearchContext/abstraction.js.map +0 -1
  146. package/features/OpenSearchContext/feature.d.ts +0 -5
  147. package/features/OpenSearchContext/feature.js +0 -12
  148. package/features/OpenSearchContext/feature.js.map +0 -1
  149. package/index.js.map +0 -1
  150. package/indices.js.map +0 -1
  151. package/operators.d.ts +0 -6
  152. package/operators.js +0 -22
  153. package/operators.js.map +0 -1
  154. package/plugins/definition/OpenSearchBodyModifierPlugin.d.ts +0 -13
  155. package/plugins/definition/OpenSearchBodyModifierPlugin.js +0 -17
  156. package/plugins/definition/OpenSearchBodyModifierPlugin.js.map +0 -1
  157. package/plugins/definition/OpenSearchFieldPlugin.d.ts +0 -81
  158. package/plugins/definition/OpenSearchFieldPlugin.js.map +0 -1
  159. package/plugins/definition/OpenSearchIndexPlugin.d.ts +0 -10
  160. package/plugins/definition/OpenSearchIndexPlugin.js +0 -16
  161. package/plugins/definition/OpenSearchIndexPlugin.js.map +0 -1
  162. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.d.ts +0 -10
  163. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js +0 -9
  164. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js.map +0 -1
  165. package/plugins/definition/OpenSearchQueryModifierPlugin.d.ts +0 -14
  166. package/plugins/definition/OpenSearchQueryModifierPlugin.js +0 -17
  167. package/plugins/definition/OpenSearchQueryModifierPlugin.js.map +0 -1
  168. package/plugins/definition/OpenSearchSortModifierPlugin.d.ts +0 -13
  169. package/plugins/definition/OpenSearchSortModifierPlugin.js +0 -17
  170. package/plugins/definition/OpenSearchSortModifierPlugin.js.map +0 -1
  171. package/plugins/definition/index.d.ts +0 -6
  172. package/plugins/definition/index.js +0 -6
  173. package/plugins/index.d.ts +0 -2
  174. package/plugins/index.js +0 -2
  175. package/plugins/operator/andIn.d.ts +0 -7
  176. package/plugins/operator/andIn.js.map +0 -1
  177. package/plugins/operator/between.d.ts +0 -7
  178. package/plugins/operator/between.js.map +0 -1
  179. package/plugins/operator/contains.d.ts +0 -7
  180. package/plugins/operator/contains.js +0 -26
  181. package/plugins/operator/contains.js.map +0 -1
  182. package/plugins/operator/equal.d.ts +0 -7
  183. package/plugins/operator/equal.js.map +0 -1
  184. package/plugins/operator/gt.d.ts +0 -7
  185. package/plugins/operator/gt.js +0 -22
  186. package/plugins/operator/gt.js.map +0 -1
  187. package/plugins/operator/gte.d.ts +0 -7
  188. package/plugins/operator/gte.js +0 -22
  189. package/plugins/operator/gte.js.map +0 -1
  190. package/plugins/operator/in.d.ts +0 -7
  191. package/plugins/operator/in.js.map +0 -1
  192. package/plugins/operator/index.d.ts +0 -15
  193. package/plugins/operator/index.js +0 -15
  194. package/plugins/operator/lt.d.ts +0 -7
  195. package/plugins/operator/lt.js +0 -22
  196. package/plugins/operator/lt.js.map +0 -1
  197. package/plugins/operator/lte.d.ts +0 -7
  198. package/plugins/operator/lte.js +0 -22
  199. package/plugins/operator/lte.js.map +0 -1
  200. package/plugins/operator/not.d.ts +0 -7
  201. package/plugins/operator/not.js.map +0 -1
  202. package/plugins/operator/notBetween.d.ts +0 -7
  203. package/plugins/operator/notBetween.js.map +0 -1
  204. package/plugins/operator/notContains.d.ts +0 -7
  205. package/plugins/operator/notContains.js +0 -26
  206. package/plugins/operator/notContains.js.map +0 -1
  207. package/plugins/operator/notIn.d.ts +0 -7
  208. package/plugins/operator/notIn.js.map +0 -1
  209. package/plugins/operator/notStartsWith.d.ts +0 -7
  210. package/plugins/operator/notStartsWith.js +0 -21
  211. package/plugins/operator/notStartsWith.js.map +0 -1
  212. package/plugins/operator/startsWith.d.ts +0 -7
  213. package/plugins/operator/startsWith.js +0 -21
  214. package/plugins/operator/startsWith.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchQueryBuilderOperator/operators/NotIn.js","sources":["../../../../src/features/OpenSearchQueryBuilderOperator/operators/NotIn.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperator } from \"../abstractions/OpenSearchQueryBuilderOperator.js\";\n\nclass NotInImpl implements OpenSearchQueryBuilderOperator.Interface {\n public getOperator(): string {\n return \"not_in\";\n }\n\n public apply(\n query: OpenSearchQueryBuilderOperator.Query,\n params: OpenSearchQueryBuilderOperator.Params\n ): void {\n const { value: values, path, basePath, name } = params;\n const isArray = Array.isArray(values);\n if (isArray === false || values.length === 0) {\n throw new Error(\n `You cannot filter field \"${name}\" with \"not_in\" operator and not send an array of values.`\n );\n }\n\n const useBasePath = values.some(\n (value: string | number | boolean | null | undefined) => typeof value !== \"string\"\n );\n\n query.must_not.push({\n terms: {\n [useBasePath ? basePath : path]: values\n }\n });\n }\n}\n\nexport const NotIn = OpenSearchQueryBuilderOperator.createImplementation({\n implementation: NotInImpl,\n dependencies: []\n});\n"],"names":["NotInImpl","query","params","values","path","basePath","name","isArray","Array","Error","useBasePath","value","NotIn","OpenSearchQueryBuilderOperator"],"mappings":";AAEA,MAAMA;IACK,cAAsB;QACzB,OAAO;IACX;IAEO,MACHC,KAA2C,EAC3CC,MAA6C,EACzC;QACJ,MAAM,EAAE,OAAOC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGJ;QAChD,MAAMK,UAAUC,MAAM,OAAO,CAACL;QAC9B,IAAII,AAAY,UAAZA,WAAqBJ,AAAkB,MAAlBA,OAAO,MAAM,EAClC,MAAM,IAAIM,MACN,CAAC,yBAAyB,EAAEH,KAAK,yDAAyD,CAAC;QAInG,MAAMI,cAAcP,OAAO,IAAI,CAC3B,CAACQ,QAAwD,AAAiB,YAAjB,OAAOA;QAGpEV,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,OAAO;gBACH,CAACS,cAAcL,WAAWD,KAAK,EAAED;YACrC;QACJ;IACJ;AACJ;AAEO,MAAMS,QAAQC,+BAA+B,oBAAoB,CAAC;IACrE,gBAAgBb;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,9 @@
1
+ import { OpenSearchQueryBuilderOperator } from "../abstractions/OpenSearchQueryBuilderOperator.js";
2
+ declare class NotStartsWithImpl implements OpenSearchQueryBuilderOperator.Interface {
3
+ getOperator(): string;
4
+ apply(query: OpenSearchQueryBuilderOperator.Query, params: OpenSearchQueryBuilderOperator.Params): void;
5
+ }
6
+ export declare const NotStartsWith: typeof NotStartsWithImpl & {
7
+ __abstraction: import("@webiny/di").Abstraction<import("../abstractions/OpenSearchQueryBuilderOperator.js").IOpenSearchQueryBuilderOperator>;
8
+ };
9
+ export {};
@@ -0,0 +1,22 @@
1
+ import { OpenSearchQueryBuilderOperator } from "../abstractions/OpenSearchQueryBuilderOperator.js";
2
+ class NotStartsWithImpl {
3
+ getOperator() {
4
+ return "not_startsWith";
5
+ }
6
+ apply(query, params) {
7
+ const { value, basePath } = params;
8
+ if ("" === value || null == value) return;
9
+ query.must_not.push({
10
+ match_phrase_prefix: {
11
+ [basePath]: value
12
+ }
13
+ });
14
+ }
15
+ }
16
+ const NotStartsWith = OpenSearchQueryBuilderOperator.createImplementation({
17
+ implementation: NotStartsWithImpl,
18
+ dependencies: []
19
+ });
20
+ export { NotStartsWith };
21
+
22
+ //# sourceMappingURL=NotStartsWith.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js","sources":["../../../../src/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperator } from \"../abstractions/OpenSearchQueryBuilderOperator.js\";\n\nclass NotStartsWithImpl implements OpenSearchQueryBuilderOperator.Interface {\n public getOperator(): string {\n return \"not_startsWith\";\n }\n\n public apply(\n query: OpenSearchQueryBuilderOperator.Query,\n params: OpenSearchQueryBuilderOperator.Params\n ): void {\n const { value, basePath } = params;\n if (value === \"\" || value === null || value === undefined) {\n return;\n }\n query.must_not.push({\n match_phrase_prefix: {\n [basePath]: value\n }\n });\n }\n}\n\nexport const NotStartsWith = OpenSearchQueryBuilderOperator.createImplementation({\n implementation: NotStartsWithImpl,\n dependencies: []\n});\n"],"names":["NotStartsWithImpl","query","params","value","basePath","NotStartsWith","OpenSearchQueryBuilderOperator"],"mappings":";AAEA,MAAMA;IACK,cAAsB;QACzB,OAAO;IACX;IAEO,MACHC,KAA2C,EAC3CC,MAA6C,EACzC;QACJ,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGF;QAC5B,IAAIC,AAAU,OAAVA,SAAkCA,QAAlBA,OAChB;QAEJF,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,qBAAqB;gBACjB,CAACG,SAAS,EAAED;YAChB;QACJ;IACJ;AACJ;AAEO,MAAME,gBAAgBC,+BAA+B,oBAAoB,CAAC;IAC7E,gBAAgBN;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,9 @@
1
+ import { OpenSearchQueryBuilderOperator } from "../abstractions/OpenSearchQueryBuilderOperator.js";
2
+ declare class StartsWithImpl implements OpenSearchQueryBuilderOperator.Interface {
3
+ getOperator(): string;
4
+ apply(query: OpenSearchQueryBuilderOperator.Query, params: OpenSearchQueryBuilderOperator.Params): void;
5
+ }
6
+ export declare const StartsWith: typeof StartsWithImpl & {
7
+ __abstraction: import("@webiny/di").Abstraction<import("../abstractions/OpenSearchQueryBuilderOperator.js").IOpenSearchQueryBuilderOperator>;
8
+ };
9
+ export {};
@@ -0,0 +1,22 @@
1
+ import { OpenSearchQueryBuilderOperator } from "../abstractions/OpenSearchQueryBuilderOperator.js";
2
+ class StartsWithImpl {
3
+ getOperator() {
4
+ return "startsWith";
5
+ }
6
+ apply(query, params) {
7
+ const { value, basePath } = params;
8
+ if ("" === value || null == value) return;
9
+ query.filter.push({
10
+ match_phrase_prefix: {
11
+ [basePath]: value
12
+ }
13
+ });
14
+ }
15
+ }
16
+ const StartsWith = OpenSearchQueryBuilderOperator.createImplementation({
17
+ implementation: StartsWithImpl,
18
+ dependencies: []
19
+ });
20
+ export { StartsWith };
21
+
22
+ //# sourceMappingURL=StartsWith.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchQueryBuilderOperator/operators/StartsWith.js","sources":["../../../../src/features/OpenSearchQueryBuilderOperator/operators/StartsWith.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperator } from \"../abstractions/OpenSearchQueryBuilderOperator.js\";\n\nclass StartsWithImpl implements OpenSearchQueryBuilderOperator.Interface {\n public getOperator(): string {\n return \"startsWith\";\n }\n\n public apply(\n query: OpenSearchQueryBuilderOperator.Query,\n params: OpenSearchQueryBuilderOperator.Params\n ): void {\n const { value, basePath } = params;\n if (value === \"\" || value === null || value === undefined) {\n return;\n }\n query.filter.push({\n match_phrase_prefix: {\n [basePath]: value\n }\n });\n }\n}\n\nexport const StartsWith = OpenSearchQueryBuilderOperator.createImplementation({\n implementation: StartsWithImpl,\n dependencies: []\n});\n"],"names":["StartsWithImpl","query","params","value","basePath","StartsWith","OpenSearchQueryBuilderOperator"],"mappings":";AAEA,MAAMA;IACK,cAAsB;QACzB,OAAO;IACX;IAEO,MACHC,KAA2C,EAC3CC,MAA6C,EACzC;QACJ,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGF;QAC5B,IAAIC,AAAU,OAAVA,SAAkCA,QAAlBA,OAChB;QAEJF,MAAM,MAAM,CAAC,IAAI,CAAC;YACd,qBAAqB;gBACjB,CAACG,SAAS,EAAED;YAChB;QACJ;IACJ;AACJ;AAEO,MAAME,aAAaC,+BAA+B,oBAAoB,CAAC;IAC1E,gBAAgBN;IAChB,cAAc,EAAE;AACpB"}
package/index.d.ts CHANGED
@@ -1,21 +1,13 @@
1
- import type { OpenSearchContext } from "./types.js";
2
- import { ContextPlugin } from "@webiny/api";
3
- import type { OpenSearchClientOptions } from "./client.js";
4
- import { Client } from "./client.js";
5
- export * from "./indexConfiguration/index.js";
6
- export * from "./plugins/index.js";
1
+ export { registerOpenSearchCore } from "./registerOpenSearchCore.js";
2
+ export { getCommonMappings, getBaseConfiguration } from "./indexConfiguration/index.js";
7
3
  export * from "./sort.js";
8
- export * from "./indices.js";
9
4
  export * from "./where.js";
10
5
  export * from "./limit.js";
11
6
  export * from "./normalize.js";
12
- export * from "./operators.js";
13
7
  export * from "./cursors.js";
14
8
  export { createOpenSearchClient, type Client, type ClientOptions, type OpenSearchClientOptions } from "./client.js";
15
9
  export * from "./utils/index.js";
16
10
  export * from "./operations/index.js";
17
11
  export * from "./sharedIndex.js";
18
12
  export * from "./indexPrefix.js";
19
- export * from "./db/index.js";
20
13
  export * from "./types.js";
21
- export declare const createOpenSearchContext: (params: OpenSearchClientOptions | Client) => ContextPlugin<OpenSearchContext>;
package/index.js CHANGED
@@ -1,38 +1,13 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import { Client, createOpenSearchClient } from "./client.js";
3
- import { getOpenSearchOperators } from "./operators.js";
4
- import { OpenSearchClientFactoryFeature } from "./features/OpenSearchClientFactory/feature.js";
5
- import { OpenSearchClientFeature } from "./features/OpenSearchClient/feature.js";
6
- import { OpenSearchContextFeature } from "./features/OpenSearchContext/feature.js";
7
- export * from "./indexConfiguration/index.js";
8
- export * from "./plugins/index.js";
9
1
  export * from "./sort.js";
10
- export * from "./indices.js";
11
2
  export * from "./where.js";
12
3
  export * from "./limit.js";
13
4
  export * from "./normalize.js";
14
- export * from "./operators.js";
15
5
  export * from "./cursors.js";
16
6
  export * from "./utils/index.js";
17
7
  export * from "./operations/index.js";
18
8
  export * from "./sharedIndex.js";
19
9
  export * from "./indexPrefix.js";
20
- export * from "./db/index.js";
21
10
  export * from "./types.js";
22
- const createOpenSearchContext = (params)=>{
23
- const plugin = new ContextPlugin((context)=>{
24
- if (context.opensearch) throw new Error("OpenSearch context must not be loaded more than once!");
25
- const client = params instanceof Client ? params : createOpenSearchClient(params);
26
- context.opensearch = client;
27
- context.elasticsearch = client;
28
- context.plugins.register(getOpenSearchOperators());
29
- OpenSearchContextFeature.register(context.container, context);
30
- OpenSearchClientFeature.register(context.container);
31
- OpenSearchClientFactoryFeature.register(context.container);
32
- });
33
- plugin.name = "context.opensearch";
34
- return plugin;
35
- };
36
- export { createOpenSearchClient, createOpenSearchContext };
37
-
38
- //# sourceMappingURL=index.js.map
11
+ export { registerOpenSearchCore } from "./registerOpenSearchCore.js";
12
+ export { getBaseConfiguration, getCommonMappings } from "./indexConfiguration/index.js";
13
+ export { createOpenSearchClient } from "./client.js";
package/indices.d.ts CHANGED
@@ -1,8 +1,2 @@
1
- import type { OpenSearchIndexPlugin } from "./plugins/definition/OpenSearchIndexPlugin.js";
2
- import type { PluginsContainer } from "@webiny/plugins";
3
- interface IndicesPluginsParams {
4
- container: PluginsContainer;
5
- type: string;
6
- }
7
- export declare const getLastAddedIndexPlugin: <T extends OpenSearchIndexPlugin>(params: IndicesPluginsParams) => T;
8
- export {};
1
+ import { OpenSearchIndexRegistry } from "./features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js";
2
+ export { OpenSearchIndexRegistry };
package/indices.js CHANGED
@@ -1,12 +1 @@
1
- import error from "@webiny/error";
2
- const listIndicesPlugins = ({ container, type })=>container.byType(type).filter((plugin)=>plugin.canUse());
3
- const getLastAddedIndexPlugin = (params)=>{
4
- const plugins = listIndicesPlugins(params);
5
- if (0 === plugins.length) throw new error(`Could not find a single OpenSearchIndexPlugin of type "${params.type}".`, "OPENSEARCH_INDEX_TEMPLATE_ERROR", {
6
- type: params.type
7
- });
8
- return plugins.pop();
9
- };
10
- export { getLastAddedIndexPlugin };
11
-
12
- //# sourceMappingURL=indices.js.map
1
+ export { OpenSearchIndexRegistry } from "./features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-opensearch",
3
- "version": "6.4.11",
3
+ "version": "6.6.0-alpha.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -18,19 +18,16 @@
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
20
  "@opensearch-project/opensearch": "3.6.0",
21
- "@webiny/api": "6.4.11",
22
- "@webiny/aws-sdk": "6.4.11",
23
- "@webiny/db-dynamodb": "6.4.11",
24
- "@webiny/error": "6.4.11",
25
- "@webiny/feature": "6.4.11",
26
- "@webiny/plugins": "6.4.11"
21
+ "@webiny/error": "6.6.0-alpha.1",
22
+ "@webiny/feature": "6.6.0-alpha.1",
23
+ "@webiny/handler": "6.6.0-alpha.1"
27
24
  },
28
25
  "devDependencies": {
29
- "@webiny/build-tools": "6.4.11",
30
- "@webiny/project-utils": "6.4.11",
26
+ "@webiny/build-tools": "6.6.0-alpha.1",
27
+ "@webiny/di": "1.1.0",
31
28
  "rimraf": "6.1.3",
32
- "typescript": "6.0.3",
33
- "vitest": "4.1.10"
29
+ "typescript": "7.0.2",
30
+ "vitest": "4.1.11"
34
31
  },
35
32
  "publishConfig": {
36
33
  "access": "public"
@@ -0,0 +1,3 @@
1
+ import type { OpenSearchClientOptions } from "./client.js";
2
+ import { Client } from "./client.js";
3
+ export declare const registerOpenSearchCore: (params: OpenSearchClientOptions | Client) => import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types").Context>;
@@ -0,0 +1,20 @@
1
+ import { createRegisterExtensionPlugin } from "@webiny/handler";
2
+ import { OpenSearchClientFeature } from "./features/OpenSearchClient/feature.js";
3
+ import { OpenSearchClientFactoryFeature } from "./features/OpenSearchClientFactory/feature.js";
4
+ import { OpenSearchQueryBuilderOperatorFeature } from "./features/OpenSearchQueryBuilderOperator/feature.js";
5
+ import { OpenSearchFieldFeature } from "./features/OpenSearchField/feature.js";
6
+ import { OpenSearchIndexFeature } from "./features/OpenSearchIndex/feature.js";
7
+ import { Client, createOpenSearchClient } from "./client.js";
8
+ const registerOpenSearchCore = (params)=>createRegisterExtensionPlugin(async (context)=>{
9
+ if (context.__registeredOpensearch) throw new Error("OpenSearch core must not be loaded more than once!");
10
+ const client = params instanceof Client ? params : createOpenSearchClient(params);
11
+ context.__registeredOpensearch = true;
12
+ OpenSearchClientFeature.register(context.container, client);
13
+ OpenSearchClientFactoryFeature.register(context.container);
14
+ OpenSearchQueryBuilderOperatorFeature.register(context.container);
15
+ OpenSearchFieldFeature.register(context.container);
16
+ OpenSearchIndexFeature.register(context.container);
17
+ });
18
+ export { registerOpenSearchCore };
19
+
20
+ //# sourceMappingURL=registerOpenSearchCore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerOpenSearchCore.js","sources":["../src/registerOpenSearchCore.ts"],"sourcesContent":["import { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { OpenSearchClientFeature } from \"~/features/OpenSearchClient/feature.js\";\nimport { OpenSearchClientFactoryFeature } from \"~/features/OpenSearchClientFactory/feature.js\";\nimport { OpenSearchQueryBuilderOperatorFeature } from \"~/features/OpenSearchQueryBuilderOperator/feature.js\";\nimport { OpenSearchFieldFeature } from \"~/features/OpenSearchField/feature.js\";\nimport { OpenSearchIndexFeature } from \"~/features/OpenSearchIndex/feature.js\";\nimport type { OpenSearchClientOptions } from \"~/client.js\";\nimport { Client, createOpenSearchClient } from \"~/client.js\";\n\nexport const registerOpenSearchCore = (params: OpenSearchClientOptions | Client) => {\n return createRegisterExtensionPlugin(async context => {\n // @ts-expect-error\n if (context.__registeredOpensearch) {\n throw new Error(\"OpenSearch core must not be loaded more than once!\");\n }\n const client = params instanceof Client ? params : createOpenSearchClient(params);\n // @ts-expect-error\n context.__registeredOpensearch = true;\n\n OpenSearchClientFeature.register(context.container, client);\n OpenSearchClientFactoryFeature.register(context.container);\n OpenSearchQueryBuilderOperatorFeature.register(context.container);\n OpenSearchFieldFeature.register(context.container);\n OpenSearchIndexFeature.register(context.container);\n });\n};\n"],"names":["registerOpenSearchCore","params","createRegisterExtensionPlugin","context","Error","client","Client","createOpenSearchClient","OpenSearchClientFeature","OpenSearchClientFactoryFeature","OpenSearchQueryBuilderOperatorFeature","OpenSearchFieldFeature","OpenSearchIndexFeature"],"mappings":";;;;;;;AASO,MAAMA,yBAAyB,CAACC,SAC5BC,8BAA8B,OAAMC;QAEvC,IAAIA,QAAQ,sBAAsB,EAC9B,MAAM,IAAIC,MAAM;QAEpB,MAAMC,SAASJ,kBAAkBK,SAASL,SAASM,uBAAuBN;QAE1EE,QAAQ,sBAAsB,GAAG;QAEjCK,wBAAwB,QAAQ,CAACL,QAAQ,SAAS,EAAEE;QACpDI,+BAA+B,QAAQ,CAACN,QAAQ,SAAS;QACzDO,sCAAsC,QAAQ,CAACP,QAAQ,SAAS;QAChEQ,uBAAuB,QAAQ,CAACR,QAAQ,SAAS;QACjDS,uBAAuB,QAAQ,CAACT,QAAQ,SAAS;IACrD"}
package/sort.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { SortOrder, SortType } from "./types.js";
2
- import { OpenSearchFieldPlugin } from "./plugins/index.js";
2
+ import { OpenSearchField } from "./features/OpenSearchField/abstractions/OpenSearchField.js";
3
3
  interface CreateSortParams {
4
4
  sort: string[];
5
5
  defaults?: {
@@ -7,7 +7,7 @@ interface CreateSortParams {
7
7
  order?: SortOrder;
8
8
  unmappedType?: string;
9
9
  };
10
- fieldPlugins: Record<string, OpenSearchFieldPlugin>;
10
+ fieldPlugins: Record<string, OpenSearchField.Interface>;
11
11
  }
12
12
  export declare const createSort: (params: CreateSortParams) => SortType;
13
13
  export {};
package/sort.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import error from "@webiny/error";
2
- import { OpenSearchFieldPlugin } from "./plugins/index.js";
2
+ import { OpenSearchFieldAll } from "./features/OpenSearchField/abstractions/OpenSearchField.js";
3
3
  const sortRegExp = /^((?:values\.)?[a-zA-Z0-9_@-]+)_(ASC|DESC)$/;
4
4
  const createSort = (params)=>{
5
5
  const { sort, defaults, fieldPlugins } = params;
@@ -18,7 +18,7 @@ const createSort = (params)=>{
18
18
  if (!match) throw new error(`Cannot sort by "${value}".`);
19
19
  const [, field, initialOrder] = match;
20
20
  const order = "asc" === initialOrder.toLowerCase() ? "asc" : "desc";
21
- const plugin = fieldPlugins[field] || fieldPlugins[OpenSearchFieldPlugin.ALL];
21
+ const plugin = fieldPlugins[field] || fieldPlugins[OpenSearchFieldAll];
22
22
  if (!plugin) throw new error(`Missing plugin for the field "${field}"`, "PLUGIN_SORT_ERROR", {
23
23
  field
24
24
  });
package/sort.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sort.js","sources":["../src/sort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { FieldSortOptions, SortOrder, SortType } from \"~/types.js\";\nimport { OpenSearchFieldPlugin } from \"~/plugins/index.js\";\n\nconst sortRegExp = /^((?:values\\.)?[a-zA-Z0-9_@-]+)_(ASC|DESC)$/;\n\ninterface CreateSortParams {\n sort: string[];\n defaults?: {\n field?: string;\n order?: SortOrder;\n unmappedType?: string;\n };\n fieldPlugins: Record<string, OpenSearchFieldPlugin>;\n}\n\nexport const createSort = (params: CreateSortParams): SortType => {\n const { sort, defaults, fieldPlugins } = params;\n if (!sort || sort.length === 0) {\n const { field, order, unmappedType } = defaults || {};\n /**\n * We say that our system defaults is always id since all records we create have some kind of primary ID.\n */\n return {\n [field || \"id.keyword\"]: {\n order: order || \"desc\",\n // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.\n unmapped_type: (unmappedType || undefined) as any\n }\n };\n }\n /**\n * Cast as string because nothing else should be allowed yet.\n */\n const result = sort.reduce(\n (acc, value) => {\n if (typeof value !== \"string\") {\n throw new WebinyError(`Sort as object is not supported..`);\n }\n const match = value.match(sortRegExp);\n\n if (!match) {\n throw new WebinyError(`Cannot sort by \"${value}\".`);\n }\n\n const [, field, initialOrder] = match;\n const order: SortOrder = initialOrder.toLowerCase() === \"asc\" ? \"asc\" : \"desc\";\n\n const plugin: OpenSearchFieldPlugin =\n fieldPlugins[field] || fieldPlugins[OpenSearchFieldPlugin.ALL];\n if (!plugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\"`,\n \"PLUGIN_SORT_ERROR\",\n {\n field\n }\n );\n }\n /**\n * In case field plugin is the global one, change the * with actual field name.\n * Custom path methods will return their own values anyway so replacing * will not matter.\n */\n const path = plugin.getPath(field);\n\n acc[path] = plugin.getSortOptions(order);\n\n return acc;\n },\n {} as Record<string, FieldSortOptions>\n );\n /**\n * If we do not have id in the sort, we add it as we need a tie_breaker for the OpenSearch to be able to sort consistently.\n */\n if (!result[\"id.keyword\"] && !result[\"id\"]) {\n result[\"id.keyword\"] = {\n order: \"asc\"\n };\n }\n return result;\n};\n"],"names":["sortRegExp","createSort","params","sort","defaults","fieldPlugins","field","order","unmappedType","undefined","result","acc","value","WebinyError","match","initialOrder","plugin","OpenSearchFieldPlugin","path"],"mappings":";;AAIA,MAAMA,aAAa;AAYZ,MAAMC,aAAa,CAACC;IACvB,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAGH;IACzC,IAAI,CAACC,QAAQA,AAAgB,MAAhBA,KAAK,MAAM,EAAQ;QAC5B,MAAM,EAAEG,KAAK,EAAEC,KAAK,EAAEC,YAAY,EAAE,GAAGJ,YAAY,CAAC;QAIpD,OAAO;YACH,CAACE,SAAS,aAAa,EAAE;gBACrB,OAAOC,SAAS;gBAEhB,eAAgBC,gBAAgBC;YACpC;QACJ;IACJ;IAIA,MAAMC,SAASP,KAAK,MAAM,CACtB,CAACQ,KAAKC;QACF,IAAI,AAAiB,YAAjB,OAAOA,OACP,MAAM,IAAIC,MAAY;QAE1B,MAAMC,QAAQF,MAAM,KAAK,CAACZ;QAE1B,IAAI,CAACc,OACD,MAAM,IAAID,MAAY,CAAC,gBAAgB,EAAED,MAAM,EAAE,CAAC;QAGtD,MAAM,GAAGN,OAAOS,aAAa,GAAGD;QAChC,MAAMP,QAAmBQ,AAA+B,UAA/BA,aAAa,WAAW,KAAe,QAAQ;QAExE,MAAMC,SACFX,YAAY,CAACC,MAAM,IAAID,YAAY,CAACY,sBAAsB,GAAG,CAAC;QAClE,IAAI,CAACD,QACD,MAAM,IAAIH,MACN,CAAC,8BAA8B,EAAEP,MAAM,CAAC,CAAC,EACzC,qBACA;YACIA;QACJ;QAOR,MAAMY,OAAOF,OAAO,OAAO,CAACV;QAE5BK,GAAG,CAACO,KAAK,GAAGF,OAAO,cAAc,CAACT;QAElC,OAAOI;IACX,GACA,CAAC;IAKL,IAAI,CAACD,MAAM,CAAC,aAAa,IAAI,CAACA,MAAM,CAAC,KAAK,EACtCA,MAAM,CAAC,aAAa,GAAG;QACnB,OAAO;IACX;IAEJ,OAAOA;AACX"}
1
+ {"version":3,"file":"sort.js","sources":["../src/sort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { FieldSortOptions, SortOrder, SortType } from \"~/types.js\";\nimport {\n OpenSearchField,\n OpenSearchFieldAll\n} from \"~/features/OpenSearchField/abstractions/OpenSearchField.js\";\n\nconst sortRegExp = /^((?:values\\.)?[a-zA-Z0-9_@-]+)_(ASC|DESC)$/;\n\ninterface CreateSortParams {\n sort: string[];\n defaults?: {\n field?: string;\n order?: SortOrder;\n unmappedType?: string;\n };\n fieldPlugins: Record<string, OpenSearchField.Interface>;\n}\n\nexport const createSort = (params: CreateSortParams): SortType => {\n const { sort, defaults, fieldPlugins } = params;\n if (!sort || sort.length === 0) {\n const { field, order, unmappedType } = defaults || {};\n return {\n [field || \"id.keyword\"]: {\n order: order || \"desc\",\n unmapped_type: (unmappedType || undefined) as any\n }\n };\n }\n const result = sort.reduce(\n (acc, value) => {\n if (typeof value !== \"string\") {\n throw new WebinyError(`Sort as object is not supported..`);\n }\n const match = value.match(sortRegExp);\n\n if (!match) {\n throw new WebinyError(`Cannot sort by \"${value}\".`);\n }\n\n const [, field, initialOrder] = match;\n const order: SortOrder = initialOrder.toLowerCase() === \"asc\" ? \"asc\" : \"desc\";\n\n const plugin: OpenSearchField.Interface =\n fieldPlugins[field] || fieldPlugins[OpenSearchFieldAll];\n if (!plugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\"`,\n \"PLUGIN_SORT_ERROR\",\n {\n field\n }\n );\n }\n const path = plugin.getPath(field);\n\n acc[path] = plugin.getSortOptions(order);\n\n return acc;\n },\n {} as Record<string, FieldSortOptions>\n );\n if (!result[\"id.keyword\"] && !result[\"id\"]) {\n result[\"id.keyword\"] = {\n order: \"asc\"\n };\n }\n return result;\n};\n"],"names":["sortRegExp","createSort","params","sort","defaults","fieldPlugins","field","order","unmappedType","undefined","result","acc","value","WebinyError","match","initialOrder","plugin","OpenSearchFieldAll","path"],"mappings":";;AAOA,MAAMA,aAAa;AAYZ,MAAMC,aAAa,CAACC;IACvB,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAGH;IACzC,IAAI,CAACC,QAAQA,AAAgB,MAAhBA,KAAK,MAAM,EAAQ;QAC5B,MAAM,EAAEG,KAAK,EAAEC,KAAK,EAAEC,YAAY,EAAE,GAAGJ,YAAY,CAAC;QACpD,OAAO;YACH,CAACE,SAAS,aAAa,EAAE;gBACrB,OAAOC,SAAS;gBAChB,eAAgBC,gBAAgBC;YACpC;QACJ;IACJ;IACA,MAAMC,SAASP,KAAK,MAAM,CACtB,CAACQ,KAAKC;QACF,IAAI,AAAiB,YAAjB,OAAOA,OACP,MAAM,IAAIC,MAAY;QAE1B,MAAMC,QAAQF,MAAM,KAAK,CAACZ;QAE1B,IAAI,CAACc,OACD,MAAM,IAAID,MAAY,CAAC,gBAAgB,EAAED,MAAM,EAAE,CAAC;QAGtD,MAAM,GAAGN,OAAOS,aAAa,GAAGD;QAChC,MAAMP,QAAmBQ,AAA+B,UAA/BA,aAAa,WAAW,KAAe,QAAQ;QAExE,MAAMC,SACFX,YAAY,CAACC,MAAM,IAAID,YAAY,CAACY,mBAAmB;QAC3D,IAAI,CAACD,QACD,MAAM,IAAIH,MACN,CAAC,8BAA8B,EAAEP,MAAM,CAAC,CAAC,EACzC,qBACA;YACIA;QACJ;QAGR,MAAMY,OAAOF,OAAO,OAAO,CAACV;QAE5BK,GAAG,CAACO,KAAK,GAAGF,OAAO,cAAc,CAACT;QAElC,OAAOI;IACX,GACA,CAAC;IAEL,IAAI,CAACD,MAAM,CAAC,aAAa,IAAI,CAACA,MAAM,CAAC,KAAK,EACtCA,MAAM,CAAC,aAAa,GAAG;QACnB,OAAO;IACX;IAEJ,OAAOA;AACX"}
@@ -0,0 +1,2 @@
1
+ import type { OpenSearchBoolQueryConfig } from "../types.js";
2
+ export declare const createBlankQuery: () => OpenSearchBoolQueryConfig;
@@ -0,0 +1,9 @@
1
+ const createBlankQuery = ()=>({
2
+ must_not: [],
3
+ must: [],
4
+ filter: [],
5
+ should: []
6
+ });
7
+ export { createBlankQuery };
8
+
9
+ //# sourceMappingURL=createBlankQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing/createBlankQuery.js","sources":["../../src/testing/createBlankQuery.ts"],"sourcesContent":["import type { OpenSearchBoolQueryConfig } from \"~/types.js\";\n\nexport const createBlankQuery = (): OpenSearchBoolQueryConfig => ({\n must_not: [],\n must: [],\n filter: [],\n should: []\n});\n"],"names":["createBlankQuery"],"mappings":"AAEO,MAAMA,mBAAmB,IAAkC;QAC9D,UAAU,EAAE;QACZ,MAAM,EAAE;QACR,QAAQ,EAAE;QACV,QAAQ,EAAE;IACd"}
@@ -0,0 +1,11 @@
1
+ import { Client } from "@opensearch-project/opensearch";
2
+ import type { ClientOptions } from "@opensearch-project/opensearch";
3
+ export interface TestOpenSearchClient extends Client {
4
+ indices: Client["indices"] & {
5
+ deleteAll: () => Promise<void>;
6
+ refreshAll: (indexes?: string[] | null) => Promise<void>;
7
+ registerIndex: (names: string[] | string) => void;
8
+ };
9
+ }
10
+ export declare const createTestOpenSearchClient: (options?: Partial<ClientOptions>) => TestOpenSearchClient;
11
+ export declare const getTestOpenSearchClient: () => TestOpenSearchClient;
@@ -0,0 +1,162 @@
1
+ import { Client } from "@opensearch-project/opensearch";
2
+ const OPENSEARCH_PORT = process.env.OPENSEARCH_PORT || 9200;
3
+ const getDefaultOptions = ()=>{
4
+ const endpoint = process.env.OPENSEARCH_ENDPOINT;
5
+ const username = process.env.OPENSEARCH_USERNAME;
6
+ const password = process.env.OPENSEARCH_PASSWORD;
7
+ const options = {
8
+ node: `http://localhost:${OPENSEARCH_PORT}`,
9
+ maxRetries: 10,
10
+ pingTimeout: 500
11
+ };
12
+ if (username && password) options.auth = {
13
+ username,
14
+ password
15
+ };
16
+ if (endpoint) options.node = null === endpoint.match(/^http/) ? `https://${endpoint}` : endpoint;
17
+ return options;
18
+ };
19
+ const SNAPSHOT_ERROR = "snapshot_in_progress_exception";
20
+ const isSnapshotError = (ex)=>{
21
+ if (ex.meta?.body?.error?.type === SNAPSHOT_ERROR) return true;
22
+ const rootCauses = ex.meta?.body?.error?.root_cause;
23
+ if (!Array.isArray(rootCauses)) return false;
24
+ return rootCauses.some((rc)=>rc.type === SNAPSHOT_ERROR);
25
+ };
26
+ const wait = (ms)=>new Promise((resolve)=>setTimeout(resolve, ms));
27
+ const createDeleteIndex = (client)=>{
28
+ const maxRetries = 10;
29
+ return async (index)=>{
30
+ for(let attempt = 0; attempt <= maxRetries; attempt++){
31
+ try {
32
+ const { body: exists } = await client.indices.exists({
33
+ index,
34
+ ignore_unavailable: true
35
+ });
36
+ if (!exists) return;
37
+ } catch (ex) {
38
+ console.log(`Could not determine that index exists: ${index}`);
39
+ console.log(ex.message);
40
+ return;
41
+ }
42
+ try {
43
+ await client.indices.delete({
44
+ index,
45
+ ignore_unavailable: true
46
+ });
47
+ return;
48
+ } catch (ex) {
49
+ console.log(`Could not delete index: ${index}`);
50
+ if (!isSnapshotError(ex)) return;
51
+ console.log("Snapshot in progress, retrying...");
52
+ }
53
+ await wait(1000);
54
+ }
55
+ };
56
+ };
57
+ const attachTestBehavior = (client)=>{
58
+ const registeredIndexes = new Set();
59
+ const dirtyIndexes = new Set();
60
+ const originalCreate = client.indices.create;
61
+ const originalExists = client.indices.exists;
62
+ const deleteIndex = createDeleteIndex(client);
63
+ const registerIndex = (input)=>{
64
+ if (!input) return;
65
+ const names = Array.isArray(input) ? input : [
66
+ input
67
+ ];
68
+ for (const name of names)registeredIndexes.add(name);
69
+ };
70
+ const refreshIndex = async (index)=>{
71
+ try {
72
+ await client.indices.refresh({
73
+ index,
74
+ ignore_unavailable: true
75
+ });
76
+ } catch (ex) {
77
+ console.log(`Could not refresh index "${index}": ${ex.message}`);
78
+ throw ex;
79
+ }
80
+ };
81
+ const refreshAll = async (indexes = null)=>{
82
+ const targets = indexes?.length ? indexes : Array.from(registeredIndexes.values());
83
+ for (const index of targets){
84
+ await refreshIndex(index);
85
+ dirtyIndexes.delete(index);
86
+ }
87
+ };
88
+ client.indices.exists = async (params, options = {})=>{
89
+ registerIndex(params.index);
90
+ return originalExists.apply(client.indices, [
91
+ params,
92
+ options
93
+ ]);
94
+ };
95
+ client.indices.create = async (params, options = {})=>{
96
+ await deleteIndex(params.index);
97
+ const response = await originalCreate.apply(client.indices, [
98
+ params,
99
+ options
100
+ ]);
101
+ registeredIndexes.add(params.index);
102
+ await client.indices.refresh({
103
+ index: params.index
104
+ });
105
+ return response;
106
+ };
107
+ const testClient = client;
108
+ testClient.indices.deleteAll = async ()=>{
109
+ const indexes = Array.from(registeredIndexes.values());
110
+ for (const index of indexes)try {
111
+ await deleteIndex(index);
112
+ } catch {
113
+ console.log(`Could not delete index "${index}".`);
114
+ }
115
+ };
116
+ testClient.indices.refreshAll = refreshAll;
117
+ testClient.indices.registerIndex = registerIndex;
118
+ const originalSearch = client.search;
119
+ client.search = async (...params)=>{
120
+ const [param] = params;
121
+ const index = param?.index;
122
+ if (index && dirtyIndexes.has(index)) {
123
+ await refreshIndex(index);
124
+ dirtyIndexes.delete(index);
125
+ }
126
+ return await originalSearch.apply(client, params);
127
+ };
128
+ const originalBulk = client.bulk;
129
+ client.bulk = async (...params)=>{
130
+ const [param] = params;
131
+ const { body } = param;
132
+ const deletedIndexes = new Set();
133
+ if (Array.isArray(body)) {
134
+ for (const item of body)if (item.index?._index) {
135
+ dirtyIndexes.add(item.index._index);
136
+ registerIndex(item.index._index);
137
+ } else if (item.delete?._index) {
138
+ deletedIndexes.add(item.delete._index);
139
+ registerIndex(item.delete._index);
140
+ }
141
+ }
142
+ const result = await originalBulk.apply(client, params);
143
+ if (deletedIndexes.size > 0) await refreshAll(Array.from(deletedIndexes));
144
+ return result;
145
+ };
146
+ return testClient;
147
+ };
148
+ const createTestOpenSearchClient = (options = {})=>{
149
+ const client = new Client({
150
+ ...getDefaultOptions(),
151
+ ...options
152
+ });
153
+ return attachTestBehavior(client);
154
+ };
155
+ let singletonClient = null;
156
+ const getTestOpenSearchClient = ()=>{
157
+ if (!singletonClient) singletonClient = createTestOpenSearchClient();
158
+ return singletonClient;
159
+ };
160
+ export { createTestOpenSearchClient, getTestOpenSearchClient };
161
+
162
+ //# sourceMappingURL=createTestOpenSearchClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing/createTestOpenSearchClient.js","sources":["../../src/testing/createTestOpenSearchClient.ts"],"sourcesContent":["import { Client } from \"@opensearch-project/opensearch\";\nimport type { ClientOptions } from \"@opensearch-project/opensearch\";\n\nconst OPENSEARCH_PORT = process.env.OPENSEARCH_PORT || 9200;\n\nconst getDefaultOptions = (): Partial<ClientOptions> => {\n const endpoint = process.env.OPENSEARCH_ENDPOINT;\n const username = process.env.OPENSEARCH_USERNAME;\n const password = process.env.OPENSEARCH_PASSWORD;\n\n const options: Partial<ClientOptions> = {\n node: `http://localhost:${OPENSEARCH_PORT}`,\n maxRetries: 10,\n pingTimeout: 500\n };\n\n if (username && password) {\n options.auth = { username, password };\n }\n\n if (endpoint) {\n options.node = endpoint.match(/^http/) === null ? `https://${endpoint}` : endpoint;\n }\n\n return options;\n};\n\nconst SNAPSHOT_ERROR = \"snapshot_in_progress_exception\";\n\nconst isSnapshotError = (ex: any): boolean => {\n if (ex.meta?.body?.error?.type === SNAPSHOT_ERROR) {\n return true;\n }\n const rootCauses = ex.meta?.body?.error?.root_cause;\n if (!Array.isArray(rootCauses)) {\n return false;\n }\n return rootCauses.some((rc: any) => rc.type === SNAPSHOT_ERROR);\n};\n\nconst wait = (ms: number): Promise<void> => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n\nconst createDeleteIndex = (client: Client) => {\n const maxRetries = 10;\n\n return async (index: string): Promise<void> => {\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n const { body: exists } = await client.indices.exists({\n index,\n ignore_unavailable: true\n });\n if (!exists) {\n return;\n }\n } catch (ex: any) {\n console.log(`Could not determine that index exists: ${index}`);\n console.log(ex.message);\n return;\n }\n\n try {\n await client.indices.delete({ index, ignore_unavailable: true });\n return;\n } catch (ex: any) {\n console.log(`Could not delete index: ${index}`);\n if (!isSnapshotError(ex)) {\n return;\n }\n console.log(\"Snapshot in progress, retrying...\");\n }\n\n await wait(1000);\n }\n };\n};\n\nexport interface TestOpenSearchClient extends Client {\n indices: Client[\"indices\"] & {\n deleteAll: () => Promise<void>;\n refreshAll: (indexes?: string[] | null) => Promise<void>;\n registerIndex: (names: string[] | string) => void;\n };\n}\n\nconst attachTestBehavior = (client: Client): TestOpenSearchClient => {\n const registeredIndexes = new Set<string>();\n const dirtyIndexes = new Set<string>();\n const originalCreate = client.indices.create;\n const originalExists = client.indices.exists;\n const deleteIndex = createDeleteIndex(client);\n\n const registerIndex = (input: string[] | string) => {\n if (!input) {\n return;\n }\n const names = Array.isArray(input) ? input : [input];\n for (const name of names) {\n registeredIndexes.add(name);\n }\n };\n\n const refreshIndex = async (index: string) => {\n try {\n await client.indices.refresh({ index, ignore_unavailable: true });\n } catch (ex: any) {\n console.log(`Could not refresh index \"${index}\": ${ex.message}`);\n throw ex;\n }\n };\n\n const refreshAll = async (indexes: string[] | null = null) => {\n const targets = indexes?.length ? indexes : Array.from(registeredIndexes.values());\n for (const index of targets) {\n await refreshIndex(index);\n dirtyIndexes.delete(index);\n }\n };\n\n // @ts-expect-error\n client.indices.exists = async (params: any, options: any = {}) => {\n registerIndex(params.index);\n // @ts-expect-error\n return originalExists.apply(client.indices, [params, options]);\n };\n\n // @ts-expect-error\n client.indices.create = async (params: any, options: any = {}) => {\n await deleteIndex(params.index);\n // @ts-expect-error\n const response = await originalCreate.apply(client.indices, [params, options]);\n registeredIndexes.add(params.index);\n await client.indices.refresh({ index: params.index });\n return response;\n };\n\n const testClient = client as TestOpenSearchClient;\n\n testClient.indices.deleteAll = async () => {\n const indexes = Array.from(registeredIndexes.values());\n for (const index of indexes) {\n try {\n await deleteIndex(index);\n } catch {\n console.log(`Could not delete index \"${index}\".`);\n }\n }\n };\n\n testClient.indices.refreshAll = refreshAll;\n testClient.indices.registerIndex = registerIndex;\n\n const originalSearch = client.search;\n // @ts-expect-error\n client.search = async (...params: any[]) => {\n const [param] = params;\n const index = param?.index;\n if (index && dirtyIndexes.has(index)) {\n await refreshIndex(index);\n dirtyIndexes.delete(index);\n }\n // @ts-expect-error\n return await originalSearch.apply(client, params);\n };\n\n const originalBulk = client.bulk;\n // @ts-expect-error\n client.bulk = async (...params: any[]) => {\n const [param] = params;\n const { body } = param;\n const deletedIndexes = new Set<string>();\n if (Array.isArray(body)) {\n for (const item of body) {\n if (item.index?._index) {\n dirtyIndexes.add(item.index._index);\n registerIndex(item.index._index);\n } else if (item.delete?._index) {\n deletedIndexes.add(item.delete._index);\n registerIndex(item.delete._index);\n }\n }\n }\n // @ts-expect-error\n const result = await originalBulk.apply(client, params);\n if (deletedIndexes.size > 0) {\n await refreshAll(Array.from(deletedIndexes));\n }\n return result;\n };\n\n return testClient;\n};\n\nexport const createTestOpenSearchClient = (\n options: Partial<ClientOptions> = {}\n): TestOpenSearchClient => {\n const client = new Client({\n ...getDefaultOptions(),\n ...options\n });\n return attachTestBehavior(client);\n};\n\nlet singletonClient: TestOpenSearchClient | null = null;\n\nexport const getTestOpenSearchClient = (): TestOpenSearchClient => {\n if (!singletonClient) {\n singletonClient = createTestOpenSearchClient();\n }\n return singletonClient;\n};\n"],"names":["OPENSEARCH_PORT","process","getDefaultOptions","endpoint","username","password","options","SNAPSHOT_ERROR","isSnapshotError","ex","rootCauses","Array","rc","wait","ms","Promise","resolve","setTimeout","createDeleteIndex","client","maxRetries","index","attempt","exists","console","attachTestBehavior","registeredIndexes","Set","dirtyIndexes","originalCreate","originalExists","deleteIndex","registerIndex","input","names","name","refreshIndex","refreshAll","indexes","targets","params","response","testClient","originalSearch","param","originalBulk","body","deletedIndexes","item","result","createTestOpenSearchClient","Client","singletonClient","getTestOpenSearchClient"],"mappings":"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"}
@@ -0,0 +1,4 @@
1
+ export { createTestOpenSearchClient, getTestOpenSearchClient, type TestOpenSearchClient } from "./createTestOpenSearchClient.js";
2
+ export { registerOpenSearchCoreForTests } from "./registerOpenSearchCoreForTests.js";
3
+ export { setupTestIndexManager } from "./setupTestIndexManager.js";
4
+ export { createBlankQuery } from "./createBlankQuery.js";
@@ -0,0 +1,4 @@
1
+ export { createTestOpenSearchClient, getTestOpenSearchClient } from "./createTestOpenSearchClient.js";
2
+ export { registerOpenSearchCoreForTests } from "./registerOpenSearchCoreForTests.js";
3
+ export { setupTestIndexManager } from "./setupTestIndexManager.js";
4
+ export { createBlankQuery } from "./createBlankQuery.js";
@@ -0,0 +1 @@
1
+ export declare const registerOpenSearchCoreForTests: () => import("@webiny/handler/index.js").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>;
@@ -0,0 +1,9 @@
1
+ import { registerOpenSearchCore } from "../registerOpenSearchCore.js";
2
+ import { getTestOpenSearchClient } from "./createTestOpenSearchClient.js";
3
+ const registerOpenSearchCoreForTests = ()=>{
4
+ const client = getTestOpenSearchClient();
5
+ return registerOpenSearchCore(client);
6
+ };
7
+ export { registerOpenSearchCoreForTests };
8
+
9
+ //# sourceMappingURL=registerOpenSearchCoreForTests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing/registerOpenSearchCoreForTests.js","sources":["../../src/testing/registerOpenSearchCoreForTests.ts"],"sourcesContent":["import { registerOpenSearchCore } from \"~/registerOpenSearchCore.js\";\nimport { getTestOpenSearchClient } from \"./createTestOpenSearchClient.js\";\n\nexport const registerOpenSearchCoreForTests = () => {\n const client = getTestOpenSearchClient();\n return registerOpenSearchCore(client);\n};\n"],"names":["registerOpenSearchCoreForTests","client","getTestOpenSearchClient","registerOpenSearchCore"],"mappings":";;AAGO,MAAMA,iCAAiC;IAC1C,MAAMC,SAASC;IACf,OAAOC,uBAAuBF;AAClC"}
@@ -0,0 +1,13 @@
1
+ type LifecycleHook = () => Promise<void>;
2
+ interface TestGlobal {
3
+ __beforeEach: LifecycleHook;
4
+ __afterEach: LifecycleHook;
5
+ __beforeAll: LifecycleHook;
6
+ __afterAll: LifecycleHook;
7
+ }
8
+ interface SetupTestIndexManagerParams {
9
+ global: typeof globalThis & Partial<TestGlobal>;
10
+ onBeforeEach?: () => Promise<void> | void;
11
+ }
12
+ export declare const setupTestIndexManager: (params: SetupTestIndexManagerParams) => void;
13
+ export {};
@@ -0,0 +1,26 @@
1
+ import { getTestOpenSearchClient } from "./createTestOpenSearchClient.js";
2
+ const setupTestIndexManager = (params)=>{
3
+ const { global, onBeforeEach } = params;
4
+ const client = getTestOpenSearchClient();
5
+ const clearIndices = async ()=>{
6
+ try {
7
+ await client.indices.deleteAll();
8
+ } catch {}
9
+ };
10
+ global.__beforeEach = async ()=>{
11
+ await clearIndices();
12
+ if (onBeforeEach) await onBeforeEach();
13
+ };
14
+ global.__afterEach = async ()=>{
15
+ await clearIndices();
16
+ };
17
+ global.__beforeAll = async ()=>{
18
+ await clearIndices();
19
+ };
20
+ global.__afterAll = async ()=>{
21
+ await clearIndices();
22
+ };
23
+ };
24
+ export { setupTestIndexManager };
25
+
26
+ //# sourceMappingURL=setupTestIndexManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing/setupTestIndexManager.js","sources":["../../src/testing/setupTestIndexManager.ts"],"sourcesContent":["import { getTestOpenSearchClient } from \"./createTestOpenSearchClient.js\";\n\ntype LifecycleHook = () => Promise<void>;\n\ninterface TestGlobal {\n __beforeEach: LifecycleHook;\n __afterEach: LifecycleHook;\n __beforeAll: LifecycleHook;\n __afterAll: LifecycleHook;\n}\n\ninterface SetupTestIndexManagerParams {\n global: typeof globalThis & Partial<TestGlobal>;\n onBeforeEach?: () => Promise<void> | void;\n}\n\nexport const setupTestIndexManager = (params: SetupTestIndexManagerParams) => {\n const { global, onBeforeEach } = params;\n const client = getTestOpenSearchClient();\n\n const clearIndices = async () => {\n try {\n await client.indices.deleteAll();\n } catch {\n /* Intentionally swallowed. */\n }\n };\n\n global.__beforeEach = async () => {\n await clearIndices();\n if (onBeforeEach) {\n await onBeforeEach();\n }\n };\n\n global.__afterEach = async () => {\n await clearIndices();\n };\n\n global.__beforeAll = async () => {\n await clearIndices();\n };\n\n global.__afterAll = async () => {\n await clearIndices();\n };\n};\n"],"names":["setupTestIndexManager","params","global","onBeforeEach","client","getTestOpenSearchClient","clearIndices"],"mappings":";AAgBO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,MAAM,EAAEC,YAAY,EAAE,GAAGF;IACjC,MAAMG,SAASC;IAEf,MAAMC,eAAe;QACjB,IAAI;YACA,MAAMF,OAAO,OAAO,CAAC,SAAS;QAClC,EAAE,OAAM,CAER;IACJ;IAEAF,OAAO,YAAY,GAAG;QAClB,MAAMI;QACN,IAAIH,cACA,MAAMA;IAEd;IAEAD,OAAO,WAAW,GAAG;QACjB,MAAMI;IACV;IAEAJ,OAAO,WAAW,GAAG;QACjB,MAAMI;IACV;IAEAJ,OAAO,UAAU,GAAG;QAChB,MAAMI;IACV;AACJ"}