@webiny/api-opensearch 0.0.0-unstable.e6f0dc8ca7 → 0.0.0-unstable.eb81deee7e

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 (282) hide show
  1. package/client.js +30 -63
  2. package/client.js.map +1 -1
  3. package/cursors.js +20 -32
  4. package/cursors.js.map +1 -1
  5. package/exports/api/opensearch.d.ts +6 -1
  6. package/exports/api/opensearch.js +6 -3
  7. package/features/OpenSearchClient/abstraction.d.ts +3 -3
  8. package/features/OpenSearchClient/abstraction.js +2 -1
  9. package/features/OpenSearchClient/abstraction.js.map +1 -1
  10. package/features/OpenSearchClient/feature.d.ts +2 -1
  11. package/features/OpenSearchClient/feature.js +9 -6
  12. package/features/OpenSearchClient/feature.js.map +1 -1
  13. package/features/OpenSearchClientFactory/OpenSearchClientFactory.js +8 -9
  14. package/features/OpenSearchClientFactory/OpenSearchClientFactory.js.map +1 -1
  15. package/features/OpenSearchClientFactory/abstraction.js +2 -1
  16. package/features/OpenSearchClientFactory/abstraction.js.map +1 -1
  17. package/features/OpenSearchClientFactory/feature.js +6 -5
  18. package/features/OpenSearchClientFactory/feature.js.map +1 -1
  19. package/features/OpenSearchField/OpenSearchField.d.ts +18 -0
  20. package/features/OpenSearchField/OpenSearchField.js +49 -0
  21. package/features/OpenSearchField/OpenSearchField.js.map +1 -0
  22. package/features/OpenSearchField/OpenSearchFieldFactory.d.ts +9 -0
  23. package/features/OpenSearchField/OpenSearchFieldFactory.js +14 -0
  24. package/features/OpenSearchField/OpenSearchFieldFactory.js.map +1 -0
  25. package/features/OpenSearchField/abstractions/OpenSearchField.d.ts +35 -0
  26. package/features/OpenSearchField/abstractions/OpenSearchField.js +6 -0
  27. package/features/OpenSearchField/abstractions/OpenSearchField.js.map +1 -0
  28. package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.d.ts +8 -0
  29. package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.js +5 -0
  30. package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.js.map +1 -0
  31. package/features/OpenSearchField/feature.d.ts +4 -0
  32. package/features/OpenSearchField/feature.js +11 -0
  33. package/features/OpenSearchField/feature.js.map +1 -0
  34. package/features/OpenSearchIndex/OpenSearchIndexRegistry.d.ts +12 -0
  35. package/features/OpenSearchIndex/OpenSearchIndexRegistry.js +30 -0
  36. package/features/OpenSearchIndex/OpenSearchIndexRegistry.js.map +1 -0
  37. package/features/OpenSearchIndex/abstractions/OpenSearchIndex.d.ts +9 -0
  38. package/features/OpenSearchIndex/abstractions/OpenSearchIndex.js +5 -0
  39. package/features/OpenSearchIndex/abstractions/OpenSearchIndex.js.map +1 -0
  40. package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.d.ts +9 -0
  41. package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js +5 -0
  42. package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js.map +1 -0
  43. package/features/OpenSearchIndex/feature.d.ts +4 -0
  44. package/features/OpenSearchIndex/feature.js +11 -0
  45. package/features/OpenSearchIndex/feature.js.map +1 -0
  46. package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.d.ts +12 -0
  47. package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.js +28 -0
  48. package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.js.map +1 -0
  49. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.d.ts +11 -0
  50. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js +5 -0
  51. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js.map +1 -0
  52. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.d.ts +10 -0
  53. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js +5 -0
  54. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js.map +1 -0
  55. package/features/OpenSearchQueryBuilderOperator/feature.d.ts +4 -0
  56. package/features/OpenSearchQueryBuilderOperator/feature.js +41 -0
  57. package/features/OpenSearchQueryBuilderOperator/feature.js.map +1 -0
  58. package/features/OpenSearchQueryBuilderOperator/operators/AndIn.d.ts +9 -0
  59. package/features/OpenSearchQueryBuilderOperator/operators/AndIn.js +28 -0
  60. package/features/OpenSearchQueryBuilderOperator/operators/AndIn.js.map +1 -0
  61. package/features/OpenSearchQueryBuilderOperator/operators/Between.d.ts +9 -0
  62. package/features/OpenSearchQueryBuilderOperator/operators/Between.js +27 -0
  63. package/features/OpenSearchQueryBuilderOperator/operators/Between.js.map +1 -0
  64. package/features/OpenSearchQueryBuilderOperator/operators/Contains.d.ts +9 -0
  65. package/features/OpenSearchQueryBuilderOperator/operators/Contains.js +27 -0
  66. package/features/OpenSearchQueryBuilderOperator/operators/Contains.js.map +1 -0
  67. package/features/OpenSearchQueryBuilderOperator/operators/Equal.d.ts +9 -0
  68. package/features/OpenSearchQueryBuilderOperator/operators/Equal.js +34 -0
  69. package/features/OpenSearchQueryBuilderOperator/operators/Equal.js.map +1 -0
  70. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.d.ts +9 -0
  71. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.js +23 -0
  72. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.js.map +1 -0
  73. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.d.ts +9 -0
  74. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.js +23 -0
  75. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.js.map +1 -0
  76. package/features/OpenSearchQueryBuilderOperator/operators/In.d.ts +9 -0
  77. package/features/OpenSearchQueryBuilderOperator/operators/In.js +24 -0
  78. package/features/OpenSearchQueryBuilderOperator/operators/In.js.map +1 -0
  79. package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.d.ts +9 -0
  80. package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.js +23 -0
  81. package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.js.map +1 -0
  82. package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.d.ts +9 -0
  83. package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.js +23 -0
  84. package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.js.map +1 -0
  85. package/features/OpenSearchQueryBuilderOperator/operators/Not.d.ts +9 -0
  86. package/features/OpenSearchQueryBuilderOperator/operators/Not.js +38 -0
  87. package/features/OpenSearchQueryBuilderOperator/operators/Not.js.map +1 -0
  88. package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.d.ts +9 -0
  89. package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.js +27 -0
  90. package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.js.map +1 -0
  91. package/features/OpenSearchQueryBuilderOperator/operators/NotContains.d.ts +9 -0
  92. package/features/OpenSearchQueryBuilderOperator/operators/NotContains.js +27 -0
  93. package/features/OpenSearchQueryBuilderOperator/operators/NotContains.js.map +1 -0
  94. package/features/OpenSearchQueryBuilderOperator/operators/NotIn.d.ts +9 -0
  95. package/features/OpenSearchQueryBuilderOperator/operators/NotIn.js +24 -0
  96. package/features/OpenSearchQueryBuilderOperator/operators/NotIn.js.map +1 -0
  97. package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.d.ts +9 -0
  98. package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js +22 -0
  99. package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js.map +1 -0
  100. package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.d.ts +9 -0
  101. package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.js +22 -0
  102. package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.js.map +1 -0
  103. package/index.d.ts +2 -10
  104. package/index.js +3 -30
  105. package/indexConfiguration/base.js +25 -26
  106. package/indexConfiguration/base.js.map +1 -1
  107. package/indexConfiguration/common.js +39 -41
  108. package/indexConfiguration/common.js.map +1 -1
  109. package/indexConfiguration/index.js +0 -2
  110. package/indexPrefix.js +2 -3
  111. package/indexPrefix.js.map +1 -1
  112. package/indices.d.ts +2 -8
  113. package/indices.js +1 -20
  114. package/limit.js +5 -27
  115. package/limit.js.map +1 -1
  116. package/normalize.js +50 -49
  117. package/normalize.js.map +1 -1
  118. package/operations/OpenSearchCatHealth.js +24 -25
  119. package/operations/OpenSearchCatHealth.js.map +1 -1
  120. package/operations/OpenSearchCatNodes.js +22 -23
  121. package/operations/OpenSearchCatNodes.js.map +1 -1
  122. package/operations/index.js +0 -2
  123. package/operations/stripConnectionFromException.js +11 -14
  124. package/operations/stripConnectionFromException.js.map +1 -1
  125. package/operations/types.js +6 -5
  126. package/operations/types.js.map +1 -1
  127. package/package.json +12 -14
  128. package/registerOpenSearchCore.d.ts +3 -0
  129. package/registerOpenSearchCore.js +20 -0
  130. package/registerOpenSearchCore.js.map +1 -0
  131. package/sharedIndex.js +2 -3
  132. package/sharedIndex.js.map +1 -1
  133. package/sort.d.ts +2 -2
  134. package/sort.js +30 -59
  135. package/sort.js.map +1 -1
  136. package/testing/createBlankQuery.d.ts +2 -0
  137. package/testing/createBlankQuery.js +9 -0
  138. package/testing/createBlankQuery.js.map +1 -0
  139. package/testing/createTestOpenSearchClient.d.ts +11 -0
  140. package/testing/createTestOpenSearchClient.js +162 -0
  141. package/testing/createTestOpenSearchClient.js.map +1 -0
  142. package/testing/index.d.ts +4 -0
  143. package/testing/index.js +4 -0
  144. package/testing/registerOpenSearchCoreForTests.d.ts +1 -0
  145. package/testing/registerOpenSearchCoreForTests.js +9 -0
  146. package/testing/registerOpenSearchCoreForTests.js.map +1 -0
  147. package/testing/setupTestIndexManager.d.ts +13 -0
  148. package/testing/setupTestIndexManager.js +26 -0
  149. package/testing/setupTestIndexManager.js.map +1 -0
  150. package/types.d.ts +0 -8
  151. package/types.js +5 -65
  152. package/types.js.map +1 -1
  153. package/utils/createIndex.d.ts +2 -2
  154. package/utils/createIndex.js +52 -80
  155. package/utils/createIndex.js.map +1 -1
  156. package/utils/index.js +0 -2
  157. package/utils/waitUntilHealthy/UnhealthyClusterError.js +8 -7
  158. package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -1
  159. package/utils/waitUntilHealthy/WaitUntilHealthy.js +111 -141
  160. package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -1
  161. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +8 -7
  162. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -1
  163. package/utils/waitUntilHealthy/index.js +0 -2
  164. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +9 -10
  165. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -1
  166. package/utils/waitUntilHealthy/reason/IReason.js +0 -3
  167. package/utils/waitUntilHealthy/reason/MemoryReason.js +9 -10
  168. package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -1
  169. package/utils/waitUntilHealthy/reason/ProcessorReason.js +9 -10
  170. package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -1
  171. package/utils/waitUntilHealthy/reason/index.js +0 -2
  172. package/where.d.ts +4 -4
  173. package/where.js +43 -76
  174. package/where.js.map +1 -1
  175. package/db/entity.d.ts +0 -7
  176. package/db/entity.js +0 -20
  177. package/db/entity.js.map +0 -1
  178. package/db/index.d.ts +0 -3
  179. package/db/index.js +0 -5
  180. package/db/index.js.map +0 -1
  181. package/db/table.d.ts +0 -7
  182. package/db/table.js +0 -17
  183. package/db/table.js.map +0 -1
  184. package/db/types.d.ts +0 -6
  185. package/db/types.js +0 -3
  186. package/db/types.js.map +0 -1
  187. package/exports/api/opensearch.js.map +0 -1
  188. package/features/OpenSearchClient/OpenSearchClient.d.ts +0 -12
  189. package/features/OpenSearchClient/OpenSearchClient.js +0 -16
  190. package/features/OpenSearchClient/OpenSearchClient.js.map +0 -1
  191. package/features/OpenSearchContext/OpenSearchContext.d.ts +0 -8
  192. package/features/OpenSearchContext/OpenSearchContext.js +0 -13
  193. package/features/OpenSearchContext/OpenSearchContext.js.map +0 -1
  194. package/features/OpenSearchContext/abstraction.d.ts +0 -14
  195. package/features/OpenSearchContext/abstraction.js +0 -4
  196. package/features/OpenSearchContext/abstraction.js.map +0 -1
  197. package/features/OpenSearchContext/feature.d.ts +0 -5
  198. package/features/OpenSearchContext/feature.js +0 -13
  199. package/features/OpenSearchContext/feature.js.map +0 -1
  200. package/index.js.map +0 -1
  201. package/indexConfiguration/index.js.map +0 -1
  202. package/indices.js.map +0 -1
  203. package/operations/index.js.map +0 -1
  204. package/operators.d.ts +0 -6
  205. package/operators.js +0 -9
  206. package/operators.js.map +0 -1
  207. package/plugins/definition/OpenSearchBodyModifierPlugin.d.ts +0 -13
  208. package/plugins/definition/OpenSearchBodyModifierPlugin.js +0 -18
  209. package/plugins/definition/OpenSearchBodyModifierPlugin.js.map +0 -1
  210. package/plugins/definition/OpenSearchFieldPlugin.d.ts +0 -81
  211. package/plugins/definition/OpenSearchFieldPlugin.js +0 -69
  212. package/plugins/definition/OpenSearchFieldPlugin.js.map +0 -1
  213. package/plugins/definition/OpenSearchIndexPlugin.d.ts +0 -10
  214. package/plugins/definition/OpenSearchIndexPlugin.js +0 -17
  215. package/plugins/definition/OpenSearchIndexPlugin.js.map +0 -1
  216. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.d.ts +0 -10
  217. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js +0 -9
  218. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js.map +0 -1
  219. package/plugins/definition/OpenSearchQueryModifierPlugin.d.ts +0 -14
  220. package/plugins/definition/OpenSearchQueryModifierPlugin.js +0 -18
  221. package/plugins/definition/OpenSearchQueryModifierPlugin.js.map +0 -1
  222. package/plugins/definition/OpenSearchSortModifierPlugin.d.ts +0 -13
  223. package/plugins/definition/OpenSearchSortModifierPlugin.js +0 -18
  224. package/plugins/definition/OpenSearchSortModifierPlugin.js.map +0 -1
  225. package/plugins/definition/index.d.ts +0 -6
  226. package/plugins/definition/index.js +0 -8
  227. package/plugins/definition/index.js.map +0 -1
  228. package/plugins/index.d.ts +0 -2
  229. package/plugins/index.js +0 -4
  230. package/plugins/index.js.map +0 -1
  231. package/plugins/operator/andIn.d.ts +0 -7
  232. package/plugins/operator/andIn.js +0 -35
  233. package/plugins/operator/andIn.js.map +0 -1
  234. package/plugins/operator/between.d.ts +0 -7
  235. package/plugins/operator/between.js +0 -32
  236. package/plugins/operator/between.js.map +0 -1
  237. package/plugins/operator/contains.d.ts +0 -7
  238. package/plugins/operator/contains.js +0 -24
  239. package/plugins/operator/contains.js.map +0 -1
  240. package/plugins/operator/equal.d.ts +0 -7
  241. package/plugins/operator/equal.js +0 -50
  242. package/plugins/operator/equal.js.map +0 -1
  243. package/plugins/operator/gt.d.ts +0 -7
  244. package/plugins/operator/gt.js +0 -22
  245. package/plugins/operator/gt.js.map +0 -1
  246. package/plugins/operator/gte.d.ts +0 -7
  247. package/plugins/operator/gte.js +0 -22
  248. package/plugins/operator/gte.js.map +0 -1
  249. package/plugins/operator/in.d.ts +0 -7
  250. package/plugins/operator/in.js +0 -29
  251. package/plugins/operator/in.js.map +0 -1
  252. package/plugins/operator/index.d.ts +0 -15
  253. package/plugins/operator/index.js +0 -17
  254. package/plugins/operator/index.js.map +0 -1
  255. package/plugins/operator/lt.d.ts +0 -7
  256. package/plugins/operator/lt.js +0 -22
  257. package/plugins/operator/lt.js.map +0 -1
  258. package/plugins/operator/lte.d.ts +0 -7
  259. package/plugins/operator/lte.js +0 -22
  260. package/plugins/operator/lte.js.map +0 -1
  261. package/plugins/operator/not.d.ts +0 -7
  262. package/plugins/operator/not.js +0 -44
  263. package/plugins/operator/not.js.map +0 -1
  264. package/plugins/operator/notBetween.d.ts +0 -7
  265. package/plugins/operator/notBetween.js +0 -32
  266. package/plugins/operator/notBetween.js.map +0 -1
  267. package/plugins/operator/notContains.d.ts +0 -7
  268. package/plugins/operator/notContains.js +0 -24
  269. package/plugins/operator/notContains.js.map +0 -1
  270. package/plugins/operator/notIn.d.ts +0 -7
  271. package/plugins/operator/notIn.js +0 -27
  272. package/plugins/operator/notIn.js.map +0 -1
  273. package/plugins/operator/notStartsWith.d.ts +0 -7
  274. package/plugins/operator/notStartsWith.js +0 -23
  275. package/plugins/operator/notStartsWith.js.map +0 -1
  276. package/plugins/operator/startsWith.d.ts +0 -7
  277. package/plugins/operator/startsWith.js +0 -23
  278. package/plugins/operator/startsWith.js.map +0 -1
  279. package/utils/index.js.map +0 -1
  280. package/utils/waitUntilHealthy/index.js.map +0 -1
  281. package/utils/waitUntilHealthy/reason/IReason.js.map +0 -1
  282. package/utils/waitUntilHealthy/reason/index.js.map +0 -1
package/indices.js CHANGED
@@ -1,20 +1 @@
1
- import WebinyError from "@webiny/error";
2
- const listIndicesPlugins = ({
3
- container,
4
- type
5
- }) => {
6
- return container.byType(type).filter(plugin => {
7
- return plugin.canUse();
8
- });
9
- };
10
- export const getLastAddedIndexPlugin = params => {
11
- const plugins = listIndicesPlugins(params);
12
- if (plugins.length === 0) {
13
- throw new WebinyError(`Could not find a single OpenSearchIndexPlugin of type "${params.type}".`, "OPENSEARCH_INDEX_TEMPLATE_ERROR", {
14
- type: params.type
15
- });
16
- }
17
- return plugins.pop();
18
- };
19
-
20
- //# sourceMappingURL=indices.js.map
1
+ export { OpenSearchIndexRegistry } from "./features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js";
package/limit.js CHANGED
@@ -1,32 +1,10 @@
1
- /**
2
- * This is the max limit of the OpenSearch.
3
- * Change here if it changes (and if it is necessary).
4
- */
5
1
  const ES_LIMIT_MAX = 10000;
6
- /**
7
- * Our system default limit.
8
- */
9
2
  const ES_LIMIT_DEFAULT = 50;
10
- export const createLimit = (limit, defaultValue = ES_LIMIT_DEFAULT) => {
11
- /**
12
- * Limit can possibly be null/undefined or less than 1.
13
- * In that case return the defaults.
14
- */
15
- if (!limit || limit < 1) {
16
- return defaultValue;
17
- }
18
- /**
19
- * Users input limit cannot be greater than the OpenSearch one.
20
- * OpenSearch query breaks because of that.
21
- */
22
- if (limit < ES_LIMIT_MAX) {
23
- return limit;
24
- }
25
- /**
26
- * Always reduce by 1 because we check if there are more items by adding 1 to the limit
27
- * and then remove that last one loaded.
28
- */
29
- return ES_LIMIT_MAX - 1;
3
+ const createLimit = (limit, defaultValue = ES_LIMIT_DEFAULT)=>{
4
+ if (!limit || limit < 1) return defaultValue;
5
+ if (limit < ES_LIMIT_MAX) return limit;
6
+ return ES_LIMIT_MAX - 1;
30
7
  };
8
+ export { createLimit };
31
9
 
32
10
  //# sourceMappingURL=limit.js.map
package/limit.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ES_LIMIT_MAX","ES_LIMIT_DEFAULT","createLimit","limit","defaultValue"],"sources":["limit.ts"],"sourcesContent":["/**\n * This is the max limit of the OpenSearch.\n * Change here if it changes (and if it is necessary).\n */\nconst ES_LIMIT_MAX = 10000;\n/**\n * Our system default limit.\n */\nconst ES_LIMIT_DEFAULT = 50;\n\nexport const createLimit = (limit?: number, defaultValue = ES_LIMIT_DEFAULT): number => {\n /**\n * Limit can possibly be null/undefined or less than 1.\n * In that case return the defaults.\n */\n if (!limit || limit < 1) {\n return defaultValue;\n }\n /**\n * Users input limit cannot be greater than the OpenSearch one.\n * OpenSearch query breaks because of that.\n */\n if (limit < ES_LIMIT_MAX) {\n return limit;\n }\n /**\n * Always reduce by 1 because we check if there are more items by adding 1 to the limit\n * and then remove that last one loaded.\n */\n return ES_LIMIT_MAX - 1;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,MAAMA,YAAY,GAAG,KAAK;AAC1B;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG,EAAE;AAE3B,OAAO,MAAMC,WAAW,GAAGA,CAACC,KAAc,EAAEC,YAAY,GAAGH,gBAAgB,KAAa;EACpF;AACJ;AACA;AACA;EACI,IAAI,CAACE,KAAK,IAAIA,KAAK,GAAG,CAAC,EAAE;IACrB,OAAOC,YAAY;EACvB;EACA;AACJ;AACA;AACA;EACI,IAAID,KAAK,GAAGH,YAAY,EAAE;IACtB,OAAOG,KAAK;EAChB;EACA;AACJ;AACA;AACA;EACI,OAAOH,YAAY,GAAG,CAAC;AAC3B,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"limit.js","sources":["../src/limit.ts"],"sourcesContent":["/**\n * This is the max limit of the OpenSearch.\n * Change here if it changes (and if it is necessary).\n */\nconst ES_LIMIT_MAX = 10000;\n/**\n * Our system default limit.\n */\nconst ES_LIMIT_DEFAULT = 50;\n\nexport const createLimit = (limit?: number, defaultValue = ES_LIMIT_DEFAULT): number => {\n /**\n * Limit can possibly be null/undefined or less than 1.\n * In that case return the defaults.\n */\n if (!limit || limit < 1) {\n return defaultValue;\n }\n /**\n * Users input limit cannot be greater than the OpenSearch one.\n * OpenSearch query breaks because of that.\n */\n if (limit < ES_LIMIT_MAX) {\n return limit;\n }\n /**\n * Always reduce by 1 because we check if there are more items by adding 1 to the limit\n * and then remove that last one loaded.\n */\n return ES_LIMIT_MAX - 1;\n};\n"],"names":["ES_LIMIT_MAX","ES_LIMIT_DEFAULT","createLimit","limit","defaultValue"],"mappings":"AAIA,MAAMA,eAAe;AAIrB,MAAMC,mBAAmB;AAElB,MAAMC,cAAc,CAACC,OAAgBC,eAAeH,gBAAgB;IAKvE,IAAI,CAACE,SAASA,QAAQ,GAClB,OAAOC;IAMX,IAAID,QAAQH,cACR,OAAOG;IAMX,OAAOH,eAAe;AAC1B"}
package/normalize.js CHANGED
@@ -1,54 +1,55 @@
1
- /**
2
- * Before performing the query, we need to escape all special characters.
3
- * @see https://opensearch.org/docs/latest/query-dsl/full-text/query-string/
4
- */
5
-
6
- const specialCharactersToRemove = [`\\?`];
7
- const specialCharacterToSpace = ["-", "\\\\"];
8
- const specialCharacters = ["\\\\", "\\+",
9
- // "\\-",
10
- "\\=", `&`, `\\|`, ">", "<", `!`, "\\(", "\\)", "\\{", "\\}", "\\[", "\\]", "\\^", '\\"', "\\~", "\\*", `:`, `/`, "\\#"];
11
- export const normalizeValue = value => {
12
- let result = value || "";
13
- if (!result) {
14
- return result;
15
- }
16
- for (const character of specialCharactersToRemove) {
17
- result = result.replace(new RegExp(character, "g"), "");
18
- }
19
- for (const character of specialCharacterToSpace) {
20
- result = result.replace(new RegExp(character, "g"), " ");
21
- }
22
- for (const character of specialCharacters) {
23
- result = result.replace(new RegExp(character, "g"), `\\${character}`);
24
- }
25
- return result || "";
1
+ const specialCharactersToRemove = [
2
+ "\\?"
3
+ ];
4
+ const specialCharacterToSpace = [
5
+ "-",
6
+ "\\\\"
7
+ ];
8
+ const specialCharacters = [
9
+ "\\\\",
10
+ "\\+",
11
+ "\\=",
12
+ "&",
13
+ "\\|",
14
+ ">",
15
+ "<",
16
+ "!",
17
+ "\\(",
18
+ "\\)",
19
+ "\\{",
20
+ "\\}",
21
+ "\\[",
22
+ "\\]",
23
+ "\\^",
24
+ '\\"',
25
+ "\\~",
26
+ "\\*",
27
+ ":",
28
+ "/",
29
+ "\\#"
30
+ ];
31
+ const normalizeValue = (value)=>{
32
+ let result = value || "";
33
+ if (!result) return result;
34
+ for (const character of specialCharactersToRemove)result = result.replace(new RegExp(character, "g"), "");
35
+ for (const character of specialCharacterToSpace)result = result.replace(new RegExp(character, "g"), " ");
36
+ for (const character of specialCharacters)result = result.replace(new RegExp(character, "g"), `\\${character}`);
37
+ return result || "";
26
38
  };
27
- const hasSpecialChar = value => {
28
- if (!value) {
29
- return null;
30
- }
31
- return value.match(/^([0-9a-zA-Z]+)$/i) === null;
39
+ const hasSpecialChar = (value)=>{
40
+ if (!value) return null;
41
+ return null === value.match(/^([0-9a-zA-Z]+)$/i);
32
42
  };
33
- export const normalizeValueWithAsterisk = initial => {
34
- const value = normalizeValue(initial);
35
- const results = value.split(" ");
36
- let result = value;
37
- /**
38
- * If there is a / in the first word, do not put asterisk in front of it.
39
- */
40
- const firstWord = results[0];
41
- if (hasSpecialChar(firstWord) === false) {
42
- result = `*${result}`;
43
- }
44
- /**
45
- * If there is a / in the last word, do not put asterisk at the end of it.
46
- */
47
- const lastWord = results[results.length - 1];
48
- if (hasSpecialChar(lastWord) === false) {
49
- result = `${result}*`;
50
- }
51
- return result;
43
+ const normalizeValueWithAsterisk = (initial)=>{
44
+ const value = normalizeValue(initial);
45
+ const results = value.split(" ");
46
+ let result = value;
47
+ const firstWord = results[0];
48
+ if (false === hasSpecialChar(firstWord)) result = `*${result}`;
49
+ const lastWord = results[results.length - 1];
50
+ if (false === hasSpecialChar(lastWord)) result = `${result}*`;
51
+ return result;
52
52
  };
53
+ export { normalizeValue, normalizeValueWithAsterisk };
53
54
 
54
55
  //# sourceMappingURL=normalize.js.map
package/normalize.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["specialCharactersToRemove","specialCharacterToSpace","specialCharacters","normalizeValue","value","result","character","replace","RegExp","hasSpecialChar","match","normalizeValueWithAsterisk","initial","results","split","firstWord","lastWord","length"],"sources":["normalize.ts"],"sourcesContent":["/**\n * Before performing the query, we need to escape all special characters.\n * @see https://opensearch.org/docs/latest/query-dsl/full-text/query-string/\n */\n\nconst specialCharactersToRemove = [`\\\\?`];\n\nconst specialCharacterToSpace = [\"-\", \"\\\\\\\\\"];\n\nconst specialCharacters = [\n \"\\\\\\\\\",\n \"\\\\+\",\n // \"\\\\-\",\n \"\\\\=\",\n `&`,\n `\\\\|`,\n \">\",\n \"<\",\n `!`,\n \"\\\\(\",\n \"\\\\)\",\n \"\\\\{\",\n \"\\\\}\",\n \"\\\\[\",\n \"\\\\]\",\n \"\\\\^\",\n '\\\\\"',\n \"\\\\~\",\n \"\\\\*\",\n `:`,\n `/`,\n \"\\\\#\"\n];\n\nexport const normalizeValue = (value: string) => {\n let result = value || \"\";\n if (!result) {\n return result;\n }\n for (const character of specialCharactersToRemove) {\n result = result.replace(new RegExp(character, \"g\"), \"\");\n }\n for (const character of specialCharacterToSpace) {\n result = result.replace(new RegExp(character, \"g\"), \" \");\n }\n\n for (const character of specialCharacters) {\n result = result.replace(new RegExp(character, \"g\"), `\\\\${character}`);\n }\n\n return result || \"\";\n};\n\nconst hasSpecialChar = (value: string): boolean | null => {\n if (!value) {\n return null;\n }\n return value.match(/^([0-9a-zA-Z]+)$/i) === null;\n};\n\nexport const normalizeValueWithAsterisk = (initial: string) => {\n const value = normalizeValue(initial);\n const results = value.split(\" \");\n\n let result = value;\n /**\n * If there is a / in the first word, do not put asterisk in front of it.\n */\n const firstWord = results[0];\n if (hasSpecialChar(firstWord) === false) {\n result = `*${result}`;\n }\n /**\n * If there is a / in the last word, do not put asterisk at the end of it.\n */\n const lastWord = results[results.length - 1];\n if (hasSpecialChar(lastWord) === false) {\n result = `${result}*`;\n }\n\n return result;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA,MAAMA,yBAAyB,GAAG,CAAC,KAAK,CAAC;AAEzC,MAAMC,uBAAuB,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC;AAE7C,MAAMC,iBAAiB,GAAG,CACtB,MAAM,EACN,KAAK;AACL;AACA,KAAK,EACL,GAAG,EACH,KAAK,EACL,GAAG,EACH,GAAG,EACH,GAAG,EACH,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,GAAG,EACH,GAAG,EACH,KAAK,CACR;AAED,OAAO,MAAMC,cAAc,GAAIC,KAAa,IAAK;EAC7C,IAAIC,MAAM,GAAGD,KAAK,IAAI,EAAE;EACxB,IAAI,CAACC,MAAM,EAAE;IACT,OAAOA,MAAM;EACjB;EACA,KAAK,MAAMC,SAAS,IAAIN,yBAAyB,EAAE;IAC/CK,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;EAC3D;EACA,KAAK,MAAMA,SAAS,IAAIL,uBAAuB,EAAE;IAC7CI,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC;EAC5D;EAEA,KAAK,MAAMA,SAAS,IAAIJ,iBAAiB,EAAE;IACvCG,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,KAAKA,SAAS,EAAE,CAAC;EACzE;EAEA,OAAOD,MAAM,IAAI,EAAE;AACvB,CAAC;AAED,MAAMI,cAAc,GAAIL,KAAa,IAAqB;EACtD,IAAI,CAACA,KAAK,EAAE;IACR,OAAO,IAAI;EACf;EACA,OAAOA,KAAK,CAACM,KAAK,CAAC,mBAAmB,CAAC,KAAK,IAAI;AACpD,CAAC;AAED,OAAO,MAAMC,0BAA0B,GAAIC,OAAe,IAAK;EAC3D,MAAMR,KAAK,GAAGD,cAAc,CAACS,OAAO,CAAC;EACrC,MAAMC,OAAO,GAAGT,KAAK,CAACU,KAAK,CAAC,GAAG,CAAC;EAEhC,IAAIT,MAAM,GAAGD,KAAK;EAClB;AACJ;AACA;EACI,MAAMW,SAAS,GAAGF,OAAO,CAAC,CAAC,CAAC;EAC5B,IAAIJ,cAAc,CAACM,SAAS,CAAC,KAAK,KAAK,EAAE;IACrCV,MAAM,GAAG,IAAIA,MAAM,EAAE;EACzB;EACA;AACJ;AACA;EACI,MAAMW,QAAQ,GAAGH,OAAO,CAACA,OAAO,CAACI,MAAM,GAAG,CAAC,CAAC;EAC5C,IAAIR,cAAc,CAACO,QAAQ,CAAC,KAAK,KAAK,EAAE;IACpCX,MAAM,GAAG,GAAGA,MAAM,GAAG;EACzB;EAEA,OAAOA,MAAM;AACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"normalize.js","sources":["../src/normalize.ts"],"sourcesContent":["/**\n * Before performing the query, we need to escape all special characters.\n * @see https://opensearch.org/docs/latest/query-dsl/full-text/query-string/\n */\n\nconst specialCharactersToRemove = [`\\\\?`];\n\nconst specialCharacterToSpace = [\"-\", \"\\\\\\\\\"];\n\nconst specialCharacters = [\n \"\\\\\\\\\",\n \"\\\\+\",\n // \"\\\\-\",\n \"\\\\=\",\n `&`,\n `\\\\|`,\n \">\",\n \"<\",\n `!`,\n \"\\\\(\",\n \"\\\\)\",\n \"\\\\{\",\n \"\\\\}\",\n \"\\\\[\",\n \"\\\\]\",\n \"\\\\^\",\n '\\\\\"',\n \"\\\\~\",\n \"\\\\*\",\n `:`,\n `/`,\n \"\\\\#\"\n];\n\nexport const normalizeValue = (value: string) => {\n let result = value || \"\";\n if (!result) {\n return result;\n }\n for (const character of specialCharactersToRemove) {\n result = result.replace(new RegExp(character, \"g\"), \"\");\n }\n for (const character of specialCharacterToSpace) {\n result = result.replace(new RegExp(character, \"g\"), \" \");\n }\n\n for (const character of specialCharacters) {\n result = result.replace(new RegExp(character, \"g\"), `\\\\${character}`);\n }\n\n return result || \"\";\n};\n\nconst hasSpecialChar = (value: string): boolean | null => {\n if (!value) {\n return null;\n }\n return value.match(/^([0-9a-zA-Z]+)$/i) === null;\n};\n\nexport const normalizeValueWithAsterisk = (initial: string) => {\n const value = normalizeValue(initial);\n const results = value.split(\" \");\n\n let result = value;\n /**\n * If there is a / in the first word, do not put asterisk in front of it.\n */\n const firstWord = results[0];\n if (hasSpecialChar(firstWord) === false) {\n result = `*${result}`;\n }\n /**\n * If there is a / in the last word, do not put asterisk at the end of it.\n */\n const lastWord = results[results.length - 1];\n if (hasSpecialChar(lastWord) === false) {\n result = `${result}*`;\n }\n\n return result;\n};\n"],"names":["specialCharactersToRemove","specialCharacterToSpace","specialCharacters","normalizeValue","value","result","character","RegExp","hasSpecialChar","normalizeValueWithAsterisk","initial","results","firstWord","lastWord"],"mappings":"AAKA,MAAMA,4BAA4B;IAAC;CAAM;AAEzC,MAAMC,0BAA0B;IAAC;IAAK;CAAO;AAE7C,MAAMC,oBAAoB;IACtB;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAEM,MAAMC,iBAAiB,CAACC;IAC3B,IAAIC,SAASD,SAAS;IACtB,IAAI,CAACC,QACD,OAAOA;IAEX,KAAK,MAAMC,aAAaN,0BACpBK,SAASA,OAAO,OAAO,CAAC,IAAIE,OAAOD,WAAW,MAAM;IAExD,KAAK,MAAMA,aAAaL,wBACpBI,SAASA,OAAO,OAAO,CAAC,IAAIE,OAAOD,WAAW,MAAM;IAGxD,KAAK,MAAMA,aAAaJ,kBACpBG,SAASA,OAAO,OAAO,CAAC,IAAIE,OAAOD,WAAW,MAAM,CAAC,EAAE,EAAEA,WAAW;IAGxE,OAAOD,UAAU;AACrB;AAEA,MAAMG,iBAAiB,CAACJ;IACpB,IAAI,CAACA,OACD,OAAO;IAEX,OAAOA,AAAqC,SAArCA,MAAM,KAAK,CAAC;AACvB;AAEO,MAAMK,6BAA6B,CAACC;IACvC,MAAMN,QAAQD,eAAeO;IAC7B,MAAMC,UAAUP,MAAM,KAAK,CAAC;IAE5B,IAAIC,SAASD;IAIb,MAAMQ,YAAYD,OAAO,CAAC,EAAE;IAC5B,IAAIH,AAA8B,UAA9BA,eAAeI,YACfP,SAAS,CAAC,CAAC,EAAEA,QAAQ;IAKzB,MAAMQ,WAAWF,OAAO,CAACA,QAAQ,MAAM,GAAG,EAAE;IAC5C,IAAIH,AAA6B,UAA7BA,eAAeK,WACfR,SAAS,GAAGA,OAAO,CAAC,CAAC;IAGzB,OAAOA;AACX"}
@@ -1,31 +1,30 @@
1
1
  import { WebinyError } from "@webiny/error";
2
2
  import { stripConnectionFromException } from "./stripConnectionFromException.js";
3
- export class OpenSearchCatHealth {
4
- constructor(client) {
5
- this.client = client;
6
- }
7
- async getHealth() {
8
- try {
9
- const response = await this.client.cat.health({
10
- format: "json"
11
- });
12
- if (!Array.isArray(response.body) || response.body.length === 0) {
13
- throw new WebinyError({
14
- message: `There is no valid response from cat.health operation.`,
15
- code: "OPENSEARCH_HEALTH_INVALID_RESPONSE",
16
- data: response.body
17
- });
18
- }
19
- return {
20
- ...response.body[0]
21
- };
22
- } catch (ex) {
23
- console.error(`Could not fetch cluster health information: ${ex.message}`);
24
- const error = stripConnectionFromException(ex);
25
- console.log(JSON.stringify(error));
26
- throw error;
3
+ class OpenSearchCatHealth {
4
+ constructor(client){
5
+ this.client = client;
6
+ }
7
+ async getHealth() {
8
+ try {
9
+ const response = await this.client.cat.health({
10
+ format: "json"
11
+ });
12
+ if (!Array.isArray(response.body) || 0 === response.body.length) throw new WebinyError({
13
+ message: "There is no valid response from cat.health operation.",
14
+ code: "OPENSEARCH_HEALTH_INVALID_RESPONSE",
15
+ data: response.body
16
+ });
17
+ return {
18
+ ...response.body[0]
19
+ };
20
+ } catch (ex) {
21
+ console.error(`Could not fetch cluster health information: ${ex.message}`);
22
+ const error = stripConnectionFromException(ex);
23
+ console.log(JSON.stringify(error));
24
+ throw error;
25
+ }
27
26
  }
28
- }
29
27
  }
28
+ export { OpenSearchCatHealth };
30
29
 
31
30
  //# sourceMappingURL=OpenSearchCatHealth.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","stripConnectionFromException","OpenSearchCatHealth","constructor","client","getHealth","response","cat","health","format","Array","isArray","body","length","message","code","data","ex","console","error","log","JSON","stringify"],"sources":["OpenSearchCatHealth.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { Client } from \"~/client.js\";\nimport type { IOpenSearchCatHealthResponse } from \"./types.js\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException.js\";\n\nexport class OpenSearchCatHealth {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getHealth(): Promise<IOpenSearchCatHealthResponse> {\n try {\n const response = await this.client.cat.health({\n format: \"json\"\n });\n\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.health operation.`,\n code: \"OPENSEARCH_HEALTH_INVALID_RESPONSE\",\n data: response.body\n });\n }\n\n return {\n ...response.body[0]\n };\n } catch (ex) {\n console.error(`Could not fetch cluster health information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAG3C,SAASC,4BAA4B;AAErC,OAAO,MAAMC,mBAAmB,CAAC;EAGtBC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAaC,SAASA,CAAA,EAA0C;IAC5D,IAAI;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACF,MAAM,CAACG,GAAG,CAACC,MAAM,CAAC;QAC1CC,MAAM,EAAE;MACZ,CAAC,CAAC;MAEF,IAAI,CAACC,KAAK,CAACC,OAAO,CAACL,QAAQ,CAACM,IAAI,CAAC,IAAIN,QAAQ,CAACM,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;QAC7D,MAAM,IAAIb,WAAW,CAAC;UAClBc,OAAO,EAAE,uDAAuD;UAChEC,IAAI,EAAE,oCAAoC;UAC1CC,IAAI,EAAEV,QAAQ,CAACM;QACnB,CAAC,CAAC;MACN;MAEA,OAAO;QACH,GAAGN,QAAQ,CAACM,IAAI,CAAC,CAAC;MACtB,CAAC;IACL,CAAC,CAAC,OAAOK,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CAAC,+CAA+CF,EAAE,CAACH,OAAO,EAAE,CAAC;MAC1E,MAAMK,KAAK,GAAGlB,4BAA4B,CAACgB,EAAE,CAAC;MAC9CC,OAAO,CAACE,GAAG,CAACC,IAAI,CAACC,SAAS,CAACH,KAAK,CAAC,CAAC;MAClC,MAAMA,KAAK;IACf;EACJ;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"operations/OpenSearchCatHealth.js","sources":["../../src/operations/OpenSearchCatHealth.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { Client } from \"~/client.js\";\nimport type { IOpenSearchCatHealthResponse } from \"./types.js\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException.js\";\n\nexport class OpenSearchCatHealth {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getHealth(): Promise<IOpenSearchCatHealthResponse> {\n try {\n const response = await this.client.cat.health({\n format: \"json\"\n });\n\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.health operation.`,\n code: \"OPENSEARCH_HEALTH_INVALID_RESPONSE\",\n data: response.body\n });\n }\n\n return {\n ...response.body[0]\n };\n } catch (ex) {\n console.error(`Could not fetch cluster health information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"names":["OpenSearchCatHealth","client","response","Array","WebinyError","ex","console","error","stripConnectionFromException","JSON"],"mappings":";;AAKO,MAAMA;IAGT,YAAmBC,MAAc,CAAE;QAC/B,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,MAAa,YAAmD;QAC5D,IAAI;YACA,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;gBAC1C,QAAQ;YACZ;YAEA,IAAI,CAACC,MAAM,OAAO,CAACD,SAAS,IAAI,KAAKA,AAAyB,MAAzBA,SAAS,IAAI,CAAC,MAAM,EACrD,MAAM,IAAIE,YAAY;gBAClB,SAAS;gBACT,MAAM;gBACN,MAAMF,SAAS,IAAI;YACvB;YAGJ,OAAO;gBACH,GAAGA,SAAS,IAAI,CAAC,EAAE;YACvB;QACJ,EAAE,OAAOG,IAAI;YACTC,QAAQ,KAAK,CAAC,CAAC,4CAA4C,EAAED,GAAG,OAAO,EAAE;YACzE,MAAME,QAAQC,6BAA6BH;YAC3CC,QAAQ,GAAG,CAACG,KAAK,SAAS,CAACF;YAC3B,MAAMA;QACV;IACJ;AACJ"}
@@ -1,29 +1,28 @@
1
1
  import { WebinyError } from "@webiny/error";
2
2
  import { stripConnectionFromException } from "./stripConnectionFromException.js";
3
- export class OpenSearchCatNodes {
4
- constructor(client) {
5
- this.client = client;
6
- }
7
- async getNodes() {
8
- try {
9
- const response = await this.client.cat.nodes({
10
- format: "json"
11
- });
12
- if (!Array.isArray(response.body) || response.body.length === 0) {
13
- throw new WebinyError({
14
- message: `There is no valid response from cat.nodes operation.`,
15
- code: "OPENSEARCH_NODES_INVALID_RESPONSE",
16
- data: response.body
17
- });
18
- }
19
- return response.body;
20
- } catch (ex) {
21
- console.error(`Could not fetch cluster nodes information: ${ex.message}`);
22
- const error = stripConnectionFromException(ex);
23
- console.log(JSON.stringify(error));
24
- throw error;
3
+ class OpenSearchCatNodes {
4
+ constructor(client){
5
+ this.client = client;
6
+ }
7
+ async getNodes() {
8
+ try {
9
+ const response = await this.client.cat.nodes({
10
+ format: "json"
11
+ });
12
+ if (!Array.isArray(response.body) || 0 === response.body.length) throw new WebinyError({
13
+ message: "There is no valid response from cat.nodes operation.",
14
+ code: "OPENSEARCH_NODES_INVALID_RESPONSE",
15
+ data: response.body
16
+ });
17
+ return response.body;
18
+ } catch (ex) {
19
+ console.error(`Could not fetch cluster nodes information: ${ex.message}`);
20
+ const error = stripConnectionFromException(ex);
21
+ console.log(JSON.stringify(error));
22
+ throw error;
23
+ }
25
24
  }
26
- }
27
25
  }
26
+ export { OpenSearchCatNodes };
28
27
 
29
28
  //# sourceMappingURL=OpenSearchCatNodes.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","stripConnectionFromException","OpenSearchCatNodes","constructor","client","getNodes","response","cat","nodes","format","Array","isArray","body","length","message","code","data","ex","console","error","log","JSON","stringify"],"sources":["OpenSearchCatNodes.ts"],"sourcesContent":["import type { IOpenSearchCatNodesResponse } from \"./types.js\";\nimport type { Client } from \"~/client.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException.js\";\n\nexport class OpenSearchCatNodes {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getNodes(): Promise<IOpenSearchCatNodesResponse> {\n try {\n const response = await this.client.cat.nodes({\n format: \"json\"\n });\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.nodes operation.`,\n code: \"OPENSEARCH_NODES_INVALID_RESPONSE\",\n data: response.body\n });\n }\n return response.body;\n } catch (ex) {\n console.error(`Could not fetch cluster nodes information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"mappings":"AAEA,SAASA,WAAW,QAAQ,eAAe;AAC3C,SAASC,4BAA4B;AAErC,OAAO,MAAMC,kBAAkB,CAAC;EAGrBC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAaC,QAAQA,CAAA,EAAyC;IAC1D,IAAI;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACF,MAAM,CAACG,GAAG,CAACC,KAAK,CAAC;QACzCC,MAAM,EAAE;MACZ,CAAC,CAAC;MACF,IAAI,CAACC,KAAK,CAACC,OAAO,CAACL,QAAQ,CAACM,IAAI,CAAC,IAAIN,QAAQ,CAACM,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;QAC7D,MAAM,IAAIb,WAAW,CAAC;UAClBc,OAAO,EAAE,sDAAsD;UAC/DC,IAAI,EAAE,mCAAmC;UACzCC,IAAI,EAAEV,QAAQ,CAACM;QACnB,CAAC,CAAC;MACN;MACA,OAAON,QAAQ,CAACM,IAAI;IACxB,CAAC,CAAC,OAAOK,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CAAC,8CAA8CF,EAAE,CAACH,OAAO,EAAE,CAAC;MACzE,MAAMK,KAAK,GAAGlB,4BAA4B,CAACgB,EAAE,CAAC;MAC9CC,OAAO,CAACE,GAAG,CAACC,IAAI,CAACC,SAAS,CAACH,KAAK,CAAC,CAAC;MAClC,MAAMA,KAAK;IACf;EACJ;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"operations/OpenSearchCatNodes.js","sources":["../../src/operations/OpenSearchCatNodes.ts"],"sourcesContent":["import type { IOpenSearchCatNodesResponse } from \"./types.js\";\nimport type { Client } from \"~/client.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException.js\";\n\nexport class OpenSearchCatNodes {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getNodes(): Promise<IOpenSearchCatNodesResponse> {\n try {\n const response = await this.client.cat.nodes({\n format: \"json\"\n });\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.nodes operation.`,\n code: \"OPENSEARCH_NODES_INVALID_RESPONSE\",\n data: response.body\n });\n }\n return response.body;\n } catch (ex) {\n console.error(`Could not fetch cluster nodes information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"names":["OpenSearchCatNodes","client","response","Array","WebinyError","ex","console","error","stripConnectionFromException","JSON"],"mappings":";;AAKO,MAAMA;IAGT,YAAmBC,MAAc,CAAE;QAC/B,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,MAAa,WAAiD;QAC1D,IAAI;YACA,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;gBACzC,QAAQ;YACZ;YACA,IAAI,CAACC,MAAM,OAAO,CAACD,SAAS,IAAI,KAAKA,AAAyB,MAAzBA,SAAS,IAAI,CAAC,MAAM,EACrD,MAAM,IAAIE,YAAY;gBAClB,SAAS;gBACT,MAAM;gBACN,MAAMF,SAAS,IAAI;YACvB;YAEJ,OAAOA,SAAS,IAAI;QACxB,EAAE,OAAOG,IAAI;YACTC,QAAQ,KAAK,CAAC,CAAC,2CAA2C,EAAED,GAAG,OAAO,EAAE;YACxE,MAAME,QAAQC,6BAA6BH;YAC3CC,QAAQ,GAAG,CAACG,KAAK,SAAS,CAACF;YAC3B,MAAMA;QACV;IACJ;AACJ"}
@@ -1,5 +1,3 @@
1
1
  export * from "./OpenSearchCatHealth.js";
2
2
  export * from "./OpenSearchCatNodes.js";
3
3
  export * from "./types.js";
4
-
5
- //# sourceMappingURL=index.js.map
@@ -1,17 +1,14 @@
1
- export const stripConnectionFromException = ex => {
2
- if (typeof ex !== "object") {
3
- return ex;
4
- }
5
- if (!ex?.meta?.meta?.connection) {
6
- return ex;
7
- }
8
- return {
9
- ...ex.meta,
10
- meta: {
11
- ...ex.meta.meta,
12
- connection: null
13
- }
14
- };
1
+ const stripConnectionFromException = (ex)=>{
2
+ if ("object" != typeof ex) return ex;
3
+ if (!ex?.meta?.meta?.connection) return ex;
4
+ return {
5
+ ...ex.meta,
6
+ meta: {
7
+ ...ex.meta.meta,
8
+ connection: null
9
+ }
10
+ };
15
11
  };
12
+ export { stripConnectionFromException };
16
13
 
17
14
  //# sourceMappingURL=stripConnectionFromException.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["stripConnectionFromException","ex","meta","connection"],"sources":["stripConnectionFromException.ts"],"sourcesContent":["export const stripConnectionFromException = (ex: any): any => {\n if (typeof ex !== \"object\") {\n return ex;\n }\n if (!ex?.meta?.meta?.connection) {\n return ex;\n }\n return {\n ...ex.meta,\n meta: {\n ...ex.meta.meta,\n connection: null\n }\n };\n};\n"],"mappings":"AAAA,OAAO,MAAMA,4BAA4B,GAAIC,EAAO,IAAU;EAC1D,IAAI,OAAOA,EAAE,KAAK,QAAQ,EAAE;IACxB,OAAOA,EAAE;EACb;EACA,IAAI,CAACA,EAAE,EAAEC,IAAI,EAAEA,IAAI,EAAEC,UAAU,EAAE;IAC7B,OAAOF,EAAE;EACb;EACA,OAAO;IACH,GAAGA,EAAE,CAACC,IAAI;IACVA,IAAI,EAAE;MACF,GAAGD,EAAE,CAACC,IAAI,CAACA,IAAI;MACfC,UAAU,EAAE;IAChB;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"operations/stripConnectionFromException.js","sources":["../../src/operations/stripConnectionFromException.ts"],"sourcesContent":["export const stripConnectionFromException = (ex: any): any => {\n if (typeof ex !== \"object\") {\n return ex;\n }\n if (!ex?.meta?.meta?.connection) {\n return ex;\n }\n return {\n ...ex.meta,\n meta: {\n ...ex.meta.meta,\n connection: null\n }\n };\n};\n"],"names":["stripConnectionFromException","ex"],"mappings":"AAAO,MAAMA,+BAA+B,CAACC;IACzC,IAAI,AAAc,YAAd,OAAOA,IACP,OAAOA;IAEX,IAAI,CAACA,IAAI,MAAM,MAAM,YACjB,OAAOA;IAEX,OAAO;QACH,GAAGA,GAAG,IAAI;QACV,MAAM;YACF,GAAGA,GAAG,IAAI,CAAC,IAAI;YACf,YAAY;QAChB;IACJ;AACJ"}
@@ -1,8 +1,9 @@
1
- export let OpenSearchCatClusterHealthStatus = /*#__PURE__*/function (OpenSearchCatClusterHealthStatus) {
2
- OpenSearchCatClusterHealthStatus["Green"] = "green";
3
- OpenSearchCatClusterHealthStatus["Yellow"] = "yellow";
4
- OpenSearchCatClusterHealthStatus["Red"] = "red";
5
- return OpenSearchCatClusterHealthStatus;
1
+ var types_OpenSearchCatClusterHealthStatus = /*#__PURE__*/ function(OpenSearchCatClusterHealthStatus) {
2
+ OpenSearchCatClusterHealthStatus["Green"] = "green";
3
+ OpenSearchCatClusterHealthStatus["Yellow"] = "yellow";
4
+ OpenSearchCatClusterHealthStatus["Red"] = "red";
5
+ return OpenSearchCatClusterHealthStatus;
6
6
  }({});
7
+ export { types_OpenSearchCatClusterHealthStatus as OpenSearchCatClusterHealthStatus };
7
8
 
8
9
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["OpenSearchCatClusterHealthStatus"],"sources":["types.ts"],"sourcesContent":["import type {\n Cat_Health_ResponseBody,\n Cat_Nodes_ResponseBody\n} from \"@opensearch-project/opensearch/api/index.js\";\n\nexport enum OpenSearchCatClusterHealthStatus {\n Green = \"green\",\n Yellow = \"yellow\",\n Red = \"red\"\n}\n\ntype HealthRecord = Cat_Health_ResponseBody[number];\n\ntype NodesRecord = Cat_Nodes_ResponseBody[number];\n\nexport type IOpenSearchCatHealthResponse = HealthRecord;\n\nexport type IOpenSearchCatNodeResponse = NodesRecord;\n\nexport type IOpenSearchCatNodesResponse = IOpenSearchCatNodeResponse[];\n"],"mappings":"AAKA,WAAYA,gCAAgC,0BAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAA,OAAhCA,gCAAgC;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"operations/types.js","sources":["../../src/operations/types.ts"],"sourcesContent":["import type {\n Cat_Health_ResponseBody,\n Cat_Nodes_ResponseBody\n} from \"@opensearch-project/opensearch/api/index.js\";\n\nexport enum OpenSearchCatClusterHealthStatus {\n Green = \"green\",\n Yellow = \"yellow\",\n Red = \"red\"\n}\n\ntype HealthRecord = Cat_Health_ResponseBody[number];\n\ntype NodesRecord = Cat_Nodes_ResponseBody[number];\n\nexport type IOpenSearchCatHealthResponse = HealthRecord;\n\nexport type IOpenSearchCatNodeResponse = NodesRecord;\n\nexport type IOpenSearchCatNodesResponse = IOpenSearchCatNodeResponse[];\n"],"names":["OpenSearchCatClusterHealthStatus"],"mappings":"AAKO,IAAKA,yCAAgCA,WAAAA,GAAAA,SAAhCA,gCAAgC;;;;WAAhCA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-opensearch",
3
- "version": "0.0.0-unstable.e6f0dc8ca7",
3
+ "version": "0.0.0-unstable.eb81deee7e",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -18,23 +18,21 @@
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
20
  "@opensearch-project/opensearch": "3.6.0",
21
- "@webiny/api": "0.0.0-unstable.e6f0dc8ca7",
22
- "@webiny/aws-sdk": "0.0.0-unstable.e6f0dc8ca7",
23
- "@webiny/db-dynamodb": "0.0.0-unstable.e6f0dc8ca7",
24
- "@webiny/error": "0.0.0-unstable.e6f0dc8ca7",
25
- "@webiny/feature": "0.0.0-unstable.e6f0dc8ca7",
26
- "@webiny/plugins": "0.0.0-unstable.e6f0dc8ca7"
21
+ "@webiny/error": "0.0.0-unstable.eb81deee7e",
22
+ "@webiny/feature": "0.0.0-unstable.eb81deee7e",
23
+ "@webiny/handler": "0.0.0-unstable.eb81deee7e"
27
24
  },
28
25
  "devDependencies": {
29
- "@webiny/build-tools": "0.0.0-unstable.e6f0dc8ca7",
30
- "@webiny/project-utils": "0.0.0-unstable.e6f0dc8ca7",
26
+ "@webiny/build-tools": "0.0.0-unstable.eb81deee7e",
27
+ "@webiny/di": "1.1.0",
31
28
  "rimraf": "6.1.3",
32
- "typescript": "6.0.3",
33
- "vitest": "4.1.5"
29
+ "typescript": "7.0.2",
30
+ "vitest": "4.1.11"
34
31
  },
35
32
  "publishConfig": {
36
- "access": "public",
37
- "directory": "dist"
33
+ "access": "public"
38
34
  },
39
- "gitHead": "e6f0dc8ca741c1fcc3fec9a5b9e86fdd49544641"
35
+ "webiny": {
36
+ "publishFrom": "dist"
37
+ }
40
38
  }
@@ -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/sharedIndex.js CHANGED
@@ -1,5 +1,4 @@
1
- export const isSharedOpenSearchIndex = () => {
2
- return process.env.OPENSEARCH_SHARED_INDEXES === "true";
3
- };
1
+ const isSharedOpenSearchIndex = ()=>"true" === process.env.OPENSEARCH_SHARED_INDEXES;
2
+ export { isSharedOpenSearchIndex };
4
3
 
5
4
  //# sourceMappingURL=sharedIndex.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isSharedOpenSearchIndex","process","env","OPENSEARCH_SHARED_INDEXES"],"sources":["sharedIndex.ts"],"sourcesContent":["export const isSharedOpenSearchIndex = () => {\n return process.env.OPENSEARCH_SHARED_INDEXES === \"true\";\n};\n"],"mappings":"AAAA,OAAO,MAAMA,uBAAuB,GAAGA,CAAA,KAAM;EACzC,OAAOC,OAAO,CAACC,GAAG,CAACC,yBAAyB,KAAK,MAAM;AAC3D,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"sharedIndex.js","sources":["../src/sharedIndex.ts"],"sourcesContent":["export const isSharedOpenSearchIndex = () => {\n return process.env.OPENSEARCH_SHARED_INDEXES === \"true\";\n};\n"],"names":["isSharedOpenSearchIndex","process"],"mappings":"AAAO,MAAMA,0BAA0B,IAC5BC,AAA0C,WAA1CA,QAAQ,GAAG,CAAC,yBAAyB"}
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 {};