@webiny/api-opensearch 0.0.0-unstable.0156a4c312

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 (203) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/client.d.ts +8 -0
  4. package/client.js +37 -0
  5. package/client.js.map +1 -0
  6. package/cursors.d.ts +10 -0
  7. package/cursors.js +25 -0
  8. package/cursors.js.map +1 -0
  9. package/exports/api/opensearch.d.ts +9 -0
  10. package/exports/api/opensearch.js +9 -0
  11. package/features/OpenSearchClient/abstraction.d.ts +9 -0
  12. package/features/OpenSearchClient/abstraction.js +5 -0
  13. package/features/OpenSearchClient/abstraction.js.map +1 -0
  14. package/features/OpenSearchClient/feature.d.ts +5 -0
  15. package/features/OpenSearchClient/feature.js +13 -0
  16. package/features/OpenSearchClient/feature.js.map +1 -0
  17. package/features/OpenSearchClientFactory/OpenSearchClientFactory.d.ts +9 -0
  18. package/features/OpenSearchClientFactory/OpenSearchClientFactory.js +15 -0
  19. package/features/OpenSearchClientFactory/OpenSearchClientFactory.js.map +1 -0
  20. package/features/OpenSearchClientFactory/abstraction.d.ts +10 -0
  21. package/features/OpenSearchClientFactory/abstraction.js +5 -0
  22. package/features/OpenSearchClientFactory/abstraction.js.map +1 -0
  23. package/features/OpenSearchClientFactory/feature.d.ts +4 -0
  24. package/features/OpenSearchClientFactory/feature.js +11 -0
  25. package/features/OpenSearchClientFactory/feature.js.map +1 -0
  26. package/features/OpenSearchField/OpenSearchField.d.ts +18 -0
  27. package/features/OpenSearchField/OpenSearchField.js +49 -0
  28. package/features/OpenSearchField/OpenSearchField.js.map +1 -0
  29. package/features/OpenSearchField/OpenSearchFieldFactory.d.ts +9 -0
  30. package/features/OpenSearchField/OpenSearchFieldFactory.js +14 -0
  31. package/features/OpenSearchField/OpenSearchFieldFactory.js.map +1 -0
  32. package/features/OpenSearchField/abstractions/OpenSearchField.d.ts +35 -0
  33. package/features/OpenSearchField/abstractions/OpenSearchField.js +6 -0
  34. package/features/OpenSearchField/abstractions/OpenSearchField.js.map +1 -0
  35. package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.d.ts +8 -0
  36. package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.js +5 -0
  37. package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.js.map +1 -0
  38. package/features/OpenSearchField/feature.d.ts +4 -0
  39. package/features/OpenSearchField/feature.js +11 -0
  40. package/features/OpenSearchField/feature.js.map +1 -0
  41. package/features/OpenSearchIndex/OpenSearchIndexRegistry.d.ts +12 -0
  42. package/features/OpenSearchIndex/OpenSearchIndexRegistry.js +30 -0
  43. package/features/OpenSearchIndex/OpenSearchIndexRegistry.js.map +1 -0
  44. package/features/OpenSearchIndex/abstractions/OpenSearchIndex.d.ts +9 -0
  45. package/features/OpenSearchIndex/abstractions/OpenSearchIndex.js +5 -0
  46. package/features/OpenSearchIndex/abstractions/OpenSearchIndex.js.map +1 -0
  47. package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.d.ts +9 -0
  48. package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js +5 -0
  49. package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js.map +1 -0
  50. package/features/OpenSearchIndex/feature.d.ts +4 -0
  51. package/features/OpenSearchIndex/feature.js +11 -0
  52. package/features/OpenSearchIndex/feature.js.map +1 -0
  53. package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.d.ts +12 -0
  54. package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.js +28 -0
  55. package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.js.map +1 -0
  56. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.d.ts +11 -0
  57. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js +5 -0
  58. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js.map +1 -0
  59. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.d.ts +10 -0
  60. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js +5 -0
  61. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js.map +1 -0
  62. package/features/OpenSearchQueryBuilderOperator/feature.d.ts +4 -0
  63. package/features/OpenSearchQueryBuilderOperator/feature.js +41 -0
  64. package/features/OpenSearchQueryBuilderOperator/feature.js.map +1 -0
  65. package/features/OpenSearchQueryBuilderOperator/operators/AndIn.d.ts +9 -0
  66. package/features/OpenSearchQueryBuilderOperator/operators/AndIn.js +28 -0
  67. package/features/OpenSearchQueryBuilderOperator/operators/AndIn.js.map +1 -0
  68. package/features/OpenSearchQueryBuilderOperator/operators/Between.d.ts +9 -0
  69. package/features/OpenSearchQueryBuilderOperator/operators/Between.js +27 -0
  70. package/features/OpenSearchQueryBuilderOperator/operators/Between.js.map +1 -0
  71. package/features/OpenSearchQueryBuilderOperator/operators/Contains.d.ts +9 -0
  72. package/features/OpenSearchQueryBuilderOperator/operators/Contains.js +27 -0
  73. package/features/OpenSearchQueryBuilderOperator/operators/Contains.js.map +1 -0
  74. package/features/OpenSearchQueryBuilderOperator/operators/Equal.d.ts +9 -0
  75. package/features/OpenSearchQueryBuilderOperator/operators/Equal.js +34 -0
  76. package/features/OpenSearchQueryBuilderOperator/operators/Equal.js.map +1 -0
  77. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.d.ts +9 -0
  78. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.js +23 -0
  79. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.js.map +1 -0
  80. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.d.ts +9 -0
  81. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.js +23 -0
  82. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.js.map +1 -0
  83. package/features/OpenSearchQueryBuilderOperator/operators/In.d.ts +9 -0
  84. package/features/OpenSearchQueryBuilderOperator/operators/In.js +24 -0
  85. package/features/OpenSearchQueryBuilderOperator/operators/In.js.map +1 -0
  86. package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.d.ts +9 -0
  87. package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.js +23 -0
  88. package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.js.map +1 -0
  89. package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.d.ts +9 -0
  90. package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.js +23 -0
  91. package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.js.map +1 -0
  92. package/features/OpenSearchQueryBuilderOperator/operators/Not.d.ts +9 -0
  93. package/features/OpenSearchQueryBuilderOperator/operators/Not.js +38 -0
  94. package/features/OpenSearchQueryBuilderOperator/operators/Not.js.map +1 -0
  95. package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.d.ts +9 -0
  96. package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.js +27 -0
  97. package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.js.map +1 -0
  98. package/features/OpenSearchQueryBuilderOperator/operators/NotContains.d.ts +9 -0
  99. package/features/OpenSearchQueryBuilderOperator/operators/NotContains.js +27 -0
  100. package/features/OpenSearchQueryBuilderOperator/operators/NotContains.js.map +1 -0
  101. package/features/OpenSearchQueryBuilderOperator/operators/NotIn.d.ts +9 -0
  102. package/features/OpenSearchQueryBuilderOperator/operators/NotIn.js +24 -0
  103. package/features/OpenSearchQueryBuilderOperator/operators/NotIn.js.map +1 -0
  104. package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.d.ts +9 -0
  105. package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js +22 -0
  106. package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js.map +1 -0
  107. package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.d.ts +9 -0
  108. package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.js +22 -0
  109. package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.js.map +1 -0
  110. package/index.d.ts +13 -0
  111. package/index.js +13 -0
  112. package/indexConfiguration/base.d.ts +6 -0
  113. package/indexConfiguration/base.js +34 -0
  114. package/indexConfiguration/base.js.map +1 -0
  115. package/indexConfiguration/common.d.ts +9 -0
  116. package/indexConfiguration/common.js +42 -0
  117. package/indexConfiguration/common.js.map +1 -0
  118. package/indexConfiguration/index.d.ts +2 -0
  119. package/indexConfiguration/index.js +2 -0
  120. package/indexPrefix.d.ts +1 -0
  121. package/indexPrefix.js +4 -0
  122. package/indexPrefix.js.map +1 -0
  123. package/indices.d.ts +2 -0
  124. package/indices.js +1 -0
  125. package/limit.d.ts +1 -0
  126. package/limit.js +10 -0
  127. package/limit.js.map +1 -0
  128. package/normalize.d.ts +6 -0
  129. package/normalize.js +55 -0
  130. package/normalize.js.map +1 -0
  131. package/operations/OpenSearchCatHealth.d.ts +7 -0
  132. package/operations/OpenSearchCatHealth.js +30 -0
  133. package/operations/OpenSearchCatHealth.js.map +1 -0
  134. package/operations/OpenSearchCatNodes.d.ts +7 -0
  135. package/operations/OpenSearchCatNodes.js +28 -0
  136. package/operations/OpenSearchCatNodes.js.map +1 -0
  137. package/operations/index.d.ts +3 -0
  138. package/operations/index.js +3 -0
  139. package/operations/stripConnectionFromException.d.ts +1 -0
  140. package/operations/stripConnectionFromException.js +14 -0
  141. package/operations/stripConnectionFromException.js.map +1 -0
  142. package/operations/types.d.ts +12 -0
  143. package/operations/types.js +9 -0
  144. package/operations/types.js.map +1 -0
  145. package/package.json +38 -0
  146. package/registerOpenSearchCore.d.ts +3 -0
  147. package/registerOpenSearchCore.js +20 -0
  148. package/registerOpenSearchCore.js.map +1 -0
  149. package/sharedIndex.d.ts +1 -0
  150. package/sharedIndex.js +4 -0
  151. package/sharedIndex.js.map +1 -0
  152. package/sort.d.ts +13 -0
  153. package/sort.js +36 -0
  154. package/sort.js.map +1 -0
  155. package/testing/createBlankQuery.d.ts +2 -0
  156. package/testing/createBlankQuery.js +9 -0
  157. package/testing/createBlankQuery.js.map +1 -0
  158. package/testing/createTestOpenSearchClient.d.ts +11 -0
  159. package/testing/createTestOpenSearchClient.js +162 -0
  160. package/testing/createTestOpenSearchClient.js.map +1 -0
  161. package/testing/index.d.ts +4 -0
  162. package/testing/index.js +4 -0
  163. package/testing/registerOpenSearchCoreForTests.d.ts +1 -0
  164. package/testing/registerOpenSearchCoreForTests.js +9 -0
  165. package/testing/registerOpenSearchCoreForTests.js.map +1 -0
  166. package/testing/setupTestIndexManager.d.ts +13 -0
  167. package/testing/setupTestIndexManager.js +26 -0
  168. package/testing/setupTestIndexManager.js.map +1 -0
  169. package/types.d.ts +60 -0
  170. package/types.js +8 -0
  171. package/types.js.map +1 -0
  172. package/utils/createIndex.d.ts +19 -0
  173. package/utils/createIndex.js +60 -0
  174. package/utils/createIndex.js.map +1 -0
  175. package/utils/index.d.ts +2 -0
  176. package/utils/index.js +2 -0
  177. package/utils/waitUntilHealthy/UnhealthyClusterError.d.ts +4 -0
  178. package/utils/waitUntilHealthy/UnhealthyClusterError.js +12 -0
  179. package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -0
  180. package/utils/waitUntilHealthy/WaitUntilHealthy.d.ts +72 -0
  181. package/utils/waitUntilHealthy/WaitUntilHealthy.js +130 -0
  182. package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -0
  183. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.d.ts +4 -0
  184. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +12 -0
  185. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -0
  186. package/utils/waitUntilHealthy/index.d.ts +4 -0
  187. package/utils/waitUntilHealthy/index.js +4 -0
  188. package/utils/waitUntilHealthy/reason/ClusterHealthReason.d.ts +15 -0
  189. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +12 -0
  190. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -0
  191. package/utils/waitUntilHealthy/reason/IReason.d.ts +4 -0
  192. package/utils/waitUntilHealthy/reason/IReason.js +0 -0
  193. package/utils/waitUntilHealthy/reason/MemoryReason.d.ts +14 -0
  194. package/utils/waitUntilHealthy/reason/MemoryReason.js +12 -0
  195. package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -0
  196. package/utils/waitUntilHealthy/reason/ProcessorReason.d.ts +14 -0
  197. package/utils/waitUntilHealthy/reason/ProcessorReason.js +12 -0
  198. package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -0
  199. package/utils/waitUntilHealthy/reason/index.d.ts +3 -0
  200. package/utils/waitUntilHealthy/reason/index.js +3 -0
  201. package/where.d.ts +17 -0
  202. package/where.js +49 -0
  203. package/where.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchQueryBuilderOperator/operators/Not.js","sources":["../../../../src/features/OpenSearchQueryBuilderOperator/operators/Not.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperator } from \"../abstractions/OpenSearchQueryBuilderOperator.js\";\n\nclass NotImpl implements OpenSearchQueryBuilderOperator.Interface {\n public getOperator(): string {\n return \"not\";\n }\n\n public apply(\n query: OpenSearchQueryBuilderOperator.Query,\n params: OpenSearchQueryBuilderOperator.Params\n ): void {\n const { value, path, basePath } = params;\n\n if (value === null || value === undefined) {\n query.filter.push({\n exists: {\n field: path\n }\n });\n return;\n }\n\n const typeOf = typeof value;\n\n if (typeOf === \"boolean\") {\n query.filter.push({\n bool: {\n must_not: {\n term: {\n [path]: value\n }\n }\n }\n });\n return;\n }\n\n const useBasePath = typeOf !== \"string\";\n const valuePath = useBasePath ? basePath : path;\n query.must_not.push({\n term: {\n [valuePath]: value\n }\n });\n }\n}\n\nexport const Not = OpenSearchQueryBuilderOperator.createImplementation({\n implementation: NotImpl,\n dependencies: []\n});\n"],"names":["NotImpl","query","params","value","path","basePath","typeOf","useBasePath","valuePath","Not","OpenSearchQueryBuilderOperator"],"mappings":";AAEA,MAAMA;IACK,cAAsB;QACzB,OAAO;IACX;IAEO,MACHC,KAA2C,EAC3CC,MAA6C,EACzC;QACJ,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGH;QAElC,IAAIC,QAAAA,OAAuC,YACvCF,MAAM,MAAM,CAAC,IAAI,CAAC;YACd,QAAQ;gBACJ,OAAOG;YACX;QACJ;QAIJ,MAAME,SAAS,OAAOH;QAEtB,IAAIG,AAAW,cAAXA,QAAsB,YACtBL,MAAM,MAAM,CAAC,IAAI,CAAC;YACd,MAAM;gBACF,UAAU;oBACN,MAAM;wBACF,CAACG,KAAK,EAAED;oBACZ;gBACJ;YACJ;QACJ;QAIJ,MAAMI,cAAcD,AAAW,aAAXA;QACpB,MAAME,YAAYD,cAAcF,WAAWD;QAC3CH,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,MAAM;gBACF,CAACO,UAAU,EAAEL;YACjB;QACJ;IACJ;AACJ;AAEO,MAAMM,MAAMC,+BAA+B,oBAAoB,CAAC;IACnE,gBAAgBV;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,9 @@
1
+ import { OpenSearchQueryBuilderOperator } from "../abstractions/OpenSearchQueryBuilderOperator.js";
2
+ declare class NotBetweenImpl implements OpenSearchQueryBuilderOperator.Interface {
3
+ getOperator(): string;
4
+ apply(query: OpenSearchQueryBuilderOperator.Query, params: OpenSearchQueryBuilderOperator.Params): void;
5
+ }
6
+ export declare const NotBetween: typeof NotBetweenImpl & {
7
+ __abstraction: import("@webiny/di").Abstraction<import("../abstractions/OpenSearchQueryBuilderOperator.js").IOpenSearchQueryBuilderOperator>;
8
+ };
9
+ export {};
@@ -0,0 +1,27 @@
1
+ import { OpenSearchQueryBuilderOperator } from "../abstractions/OpenSearchQueryBuilderOperator.js";
2
+ class NotBetweenImpl {
3
+ getOperator() {
4
+ return "not_between";
5
+ }
6
+ apply(query, params) {
7
+ const { value, basePath, name } = params;
8
+ if (false === Array.isArray(value)) throw new Error(`You cannot filter field path "${name}" with "not_between" query and not send an array of values.`);
9
+ else if (2 !== value.length) throw new Error(`You must pass 2 values in the array for field path "${name}" filtering.`);
10
+ const [gte, lte] = value;
11
+ query.must_not.push({
12
+ range: {
13
+ [basePath]: {
14
+ lte,
15
+ gte
16
+ }
17
+ }
18
+ });
19
+ }
20
+ }
21
+ const NotBetween = OpenSearchQueryBuilderOperator.createImplementation({
22
+ implementation: NotBetweenImpl,
23
+ dependencies: []
24
+ });
25
+ export { NotBetween };
26
+
27
+ //# sourceMappingURL=NotBetween.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchQueryBuilderOperator/operators/NotBetween.js","sources":["../../../../src/features/OpenSearchQueryBuilderOperator/operators/NotBetween.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperator } from \"../abstractions/OpenSearchQueryBuilderOperator.js\";\n\nclass NotBetweenImpl implements OpenSearchQueryBuilderOperator.Interface {\n public getOperator(): string {\n return \"not_between\";\n }\n\n public apply(\n query: OpenSearchQueryBuilderOperator.Query,\n params: OpenSearchQueryBuilderOperator.Params\n ): void {\n const { value, basePath, name } = params;\n if (Array.isArray(value) === false) {\n throw new Error(\n `You cannot filter field path \"${name}\" with \"not_between\" query and not send an array of values.`\n );\n } else if (value.length !== 2) {\n throw new Error(\n `You must pass 2 values in the array for field path \"${name}\" filtering.`\n );\n }\n const [gte, lte] = value;\n query.must_not.push({\n range: {\n [basePath]: {\n lte,\n gte\n }\n }\n });\n }\n}\n\nexport const NotBetween = OpenSearchQueryBuilderOperator.createImplementation({\n implementation: NotBetweenImpl,\n dependencies: []\n});\n"],"names":["NotBetweenImpl","query","params","value","basePath","name","Array","Error","gte","lte","NotBetween","OpenSearchQueryBuilderOperator"],"mappings":";AAEA,MAAMA;IACK,cAAsB;QACzB,OAAO;IACX;IAEO,MACHC,KAA2C,EAC3CC,MAA6C,EACzC;QACJ,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGH;QAClC,IAAII,AAAyB,UAAzBA,MAAM,OAAO,CAACH,QACd,MAAM,IAAII,MACN,CAAC,8BAA8B,EAAEF,KAAK,2DAA2D,CAAC;aAEnG,IAAIF,AAAiB,MAAjBA,MAAM,MAAM,EACnB,MAAM,IAAII,MACN,CAAC,oDAAoD,EAAEF,KAAK,YAAY,CAAC;QAGjF,MAAM,CAACG,KAAKC,IAAI,GAAGN;QACnBF,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,OAAO;gBACH,CAACG,SAAS,EAAE;oBACRK;oBACAD;gBACJ;YACJ;QACJ;IACJ;AACJ;AAEO,MAAME,aAAaC,+BAA+B,oBAAoB,CAAC;IAC1E,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,9 @@
1
+ import { OpenSearchQueryBuilderOperator } from "../abstractions/OpenSearchQueryBuilderOperator.js";
2
+ declare class NotContainsImpl implements OpenSearchQueryBuilderOperator.Interface {
3
+ getOperator(): string;
4
+ apply(query: OpenSearchQueryBuilderOperator.Query, params: OpenSearchQueryBuilderOperator.Params): void;
5
+ }
6
+ export declare const NotContains: typeof NotContainsImpl & {
7
+ __abstraction: import("@webiny/di").Abstraction<import("../abstractions/OpenSearchQueryBuilderOperator.js").IOpenSearchQueryBuilderOperator>;
8
+ };
9
+ export {};
@@ -0,0 +1,27 @@
1
+ import { normalizeValueWithAsterisk } from "../../../normalize.js";
2
+ import { OpenSearchQueryBuilderOperator } from "../abstractions/OpenSearchQueryBuilderOperator.js";
3
+ class NotContainsImpl {
4
+ getOperator() {
5
+ return "not_contains";
6
+ }
7
+ apply(query, params) {
8
+ const { value, basePath } = params;
9
+ query.must_not.push({
10
+ query_string: {
11
+ allow_leading_wildcard: true,
12
+ fields: [
13
+ basePath
14
+ ],
15
+ query: normalizeValueWithAsterisk(value),
16
+ default_operator: "and"
17
+ }
18
+ });
19
+ }
20
+ }
21
+ const NotContains = OpenSearchQueryBuilderOperator.createImplementation({
22
+ implementation: NotContainsImpl,
23
+ dependencies: []
24
+ });
25
+ export { NotContains };
26
+
27
+ //# sourceMappingURL=NotContains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchQueryBuilderOperator/operators/NotContains.js","sources":["../../../../src/features/OpenSearchQueryBuilderOperator/operators/NotContains.ts"],"sourcesContent":["import { normalizeValueWithAsterisk } from \"~/normalize.js\";\nimport { OpenSearchQueryBuilderOperator } from \"../abstractions/OpenSearchQueryBuilderOperator.js\";\n\nclass NotContainsImpl implements OpenSearchQueryBuilderOperator.Interface {\n public getOperator(): string {\n return \"not_contains\";\n }\n\n public apply(\n query: OpenSearchQueryBuilderOperator.Query,\n params: OpenSearchQueryBuilderOperator.Params\n ): void {\n const { value, basePath } = params;\n query.must_not.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: [basePath],\n query: normalizeValueWithAsterisk(value),\n default_operator: \"and\"\n }\n });\n }\n}\n\nexport const NotContains = OpenSearchQueryBuilderOperator.createImplementation({\n implementation: NotContainsImpl,\n dependencies: []\n});\n"],"names":["NotContainsImpl","query","params","value","basePath","normalizeValueWithAsterisk","NotContains","OpenSearchQueryBuilderOperator"],"mappings":";;AAGA,MAAMA;IACK,cAAsB;QACzB,OAAO;IACX;IAEO,MACHC,KAA2C,EAC3CC,MAA6C,EACzC;QACJ,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGF;QAC5BD,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,cAAc;gBACV,wBAAwB;gBACxB,QAAQ;oBAACG;iBAAS;gBAClB,OAAOC,2BAA2BF;gBAClC,kBAAkB;YACtB;QACJ;IACJ;AACJ;AAEO,MAAMG,cAAcC,+BAA+B,oBAAoB,CAAC;IAC3E,gBAAgBP;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,9 @@
1
+ import { OpenSearchQueryBuilderOperator } from "../abstractions/OpenSearchQueryBuilderOperator.js";
2
+ declare class NotInImpl implements OpenSearchQueryBuilderOperator.Interface {
3
+ getOperator(): string;
4
+ apply(query: OpenSearchQueryBuilderOperator.Query, params: OpenSearchQueryBuilderOperator.Params): void;
5
+ }
6
+ export declare const NotIn: typeof NotInImpl & {
7
+ __abstraction: import("@webiny/di").Abstraction<import("../abstractions/OpenSearchQueryBuilderOperator.js").IOpenSearchQueryBuilderOperator>;
8
+ };
9
+ export {};
@@ -0,0 +1,24 @@
1
+ import { OpenSearchQueryBuilderOperator } from "../abstractions/OpenSearchQueryBuilderOperator.js";
2
+ class NotInImpl {
3
+ getOperator() {
4
+ return "not_in";
5
+ }
6
+ apply(query, params) {
7
+ const { value: values, path, basePath, name } = params;
8
+ const isArray = Array.isArray(values);
9
+ if (false === isArray || 0 === values.length) throw new Error(`You cannot filter field "${name}" with "not_in" operator and not send an array of values.`);
10
+ const useBasePath = values.some((value)=>"string" != typeof value);
11
+ query.must_not.push({
12
+ terms: {
13
+ [useBasePath ? basePath : path]: values
14
+ }
15
+ });
16
+ }
17
+ }
18
+ const NotIn = OpenSearchQueryBuilderOperator.createImplementation({
19
+ implementation: NotInImpl,
20
+ dependencies: []
21
+ });
22
+ export { NotIn };
23
+
24
+ //# sourceMappingURL=NotIn.js.map
@@ -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 ADDED
@@ -0,0 +1,13 @@
1
+ export { registerOpenSearchCore } from "./registerOpenSearchCore.js";
2
+ export { getCommonMappings, getBaseConfiguration } from "./indexConfiguration/index.js";
3
+ export * from "./sort.js";
4
+ export * from "./where.js";
5
+ export * from "./limit.js";
6
+ export * from "./normalize.js";
7
+ export * from "./cursors.js";
8
+ export { createOpenSearchClient, type Client, type ClientOptions, type OpenSearchClientOptions } from "./client.js";
9
+ export * from "./utils/index.js";
10
+ export * from "./operations/index.js";
11
+ export * from "./sharedIndex.js";
12
+ export * from "./indexPrefix.js";
13
+ export * from "./types.js";
package/index.js ADDED
@@ -0,0 +1,13 @@
1
+ export * from "./sort.js";
2
+ export * from "./where.js";
3
+ export * from "./limit.js";
4
+ export * from "./normalize.js";
5
+ export * from "./cursors.js";
6
+ export * from "./utils/index.js";
7
+ export * from "./operations/index.js";
8
+ export * from "./sharedIndex.js";
9
+ export * from "./indexPrefix.js";
10
+ export * from "./types.js";
11
+ export { registerOpenSearchCore } from "./registerOpenSearchCore.js";
12
+ export { getBaseConfiguration, getCommonMappings } from "./indexConfiguration/index.js";
13
+ export { createOpenSearchClient } from "./client.js";
@@ -0,0 +1,6 @@
1
+ import type { OpenSearchIndexRequestBody } from "../types.js";
2
+ interface Modifier {
3
+ (config: OpenSearchIndexRequestBody): OpenSearchIndexRequestBody;
4
+ }
5
+ export declare const getBaseConfiguration: (modifier?: Modifier) => import("@opensearch-project/opensearch/api/index.js").Indices_Create_RequestBody;
6
+ export {};
@@ -0,0 +1,34 @@
1
+ import { getCommonMappings } from "./common.js";
2
+ const config = {
3
+ mappings: {
4
+ dynamic_templates: getCommonMappings((mappings)=>mappings.concat([
5
+ {
6
+ strings: {
7
+ match_mapping_type: "string",
8
+ mapping: {
9
+ type: "text",
10
+ fields: {
11
+ keyword: {
12
+ type: "keyword",
13
+ ignore_above: 256
14
+ }
15
+ }
16
+ }
17
+ }
18
+ }
19
+ ])),
20
+ properties: {
21
+ rawValues: {
22
+ type: "object",
23
+ enabled: false
24
+ }
25
+ }
26
+ }
27
+ };
28
+ const getBaseConfiguration = (modifier)=>{
29
+ if (!modifier) return config;
30
+ return modifier(config);
31
+ };
32
+ export { getBaseConfiguration };
33
+
34
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexConfiguration/base.js","sources":["../../src/indexConfiguration/base.ts"],"sourcesContent":["import type { OpenSearchIndexRequestBody } from \"~/types.js\";\nimport { getCommonMappings } from \"./common.js\";\n\nconst config: OpenSearchIndexRequestBody = {\n mappings: {\n dynamic_templates: getCommonMappings(mappings => {\n return mappings.concat([\n {\n strings: {\n match_mapping_type: \"string\",\n mapping: {\n type: \"text\",\n fields: {\n keyword: {\n type: \"keyword\",\n ignore_above: 256\n }\n }\n }\n }\n }\n ]);\n }),\n properties: {\n rawValues: {\n type: \"object\",\n enabled: false\n }\n }\n }\n};\n\ninterface Modifier {\n (config: OpenSearchIndexRequestBody): OpenSearchIndexRequestBody;\n}\nexport const getBaseConfiguration = (modifier?: Modifier) => {\n if (!modifier) {\n return config;\n }\n return modifier(config);\n};\n"],"names":["config","getCommonMappings","mappings","getBaseConfiguration","modifier"],"mappings":";AAGA,MAAMA,SAAqC;IACvC,UAAU;QACN,mBAAmBC,kBAAkBC,CAAAA,WAC1BA,SAAS,MAAM,CAAC;gBACnB;oBACI,SAAS;wBACL,oBAAoB;wBACpB,SAAS;4BACL,MAAM;4BACN,QAAQ;gCACJ,SAAS;oCACL,MAAM;oCACN,cAAc;gCAClB;4BACJ;wBACJ;oBACJ;gBACJ;aACH;QAEL,YAAY;YACR,WAAW;gBACP,MAAM;gBACN,SAAS;YACb;QACJ;IACJ;AACJ;AAKO,MAAMC,uBAAuB,CAACC;IACjC,IAAI,CAACA,UACD,OAAOJ;IAEX,OAAOI,SAASJ;AACpB"}
@@ -0,0 +1,9 @@
1
+ import type { OpenSearchIndexRequestBodyMappingsDynamicTemplate } from "../types.js";
2
+ interface Modifier {
3
+ (mappings: OpenSearchIndexRequestBodyMappingsDynamicTemplate[]): OpenSearchIndexRequestBodyMappingsDynamicTemplate[];
4
+ }
5
+ /**
6
+ * @internal
7
+ */
8
+ export declare const getCommonMappings: (cb?: Modifier) => OpenSearchIndexRequestBodyMappingsDynamicTemplate[];
9
+ export {};
@@ -0,0 +1,42 @@
1
+ const getDefaultMappings = ()=>[
2
+ {
3
+ ids: {
4
+ match: "^id|entryId$",
5
+ mapping: {
6
+ type: "keyword"
7
+ }
8
+ }
9
+ },
10
+ {
11
+ dates: {
12
+ match: "^createdOn|savedOn|publishedOn$",
13
+ mapping: {
14
+ type: "date"
15
+ }
16
+ }
17
+ },
18
+ {
19
+ numbers: {
20
+ match: "number@*",
21
+ mapping: {
22
+ type: "scaled_float",
23
+ scaling_factor: 10000
24
+ }
25
+ }
26
+ },
27
+ {
28
+ booleans: {
29
+ match: "boolean@*",
30
+ mapping: {
31
+ type: "boolean"
32
+ }
33
+ }
34
+ }
35
+ ];
36
+ const getCommonMappings = (cb)=>{
37
+ if (!cb) return getDefaultMappings();
38
+ return cb(getDefaultMappings());
39
+ };
40
+ export { getCommonMappings };
41
+
42
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexConfiguration/common.js","sources":["../../src/indexConfiguration/common.ts"],"sourcesContent":["import type { OpenSearchIndexRequestBodyMappingsDynamicTemplate } from \"~/types.js\";\n\nconst getDefaultMappings = (): OpenSearchIndexRequestBodyMappingsDynamicTemplate[] => {\n return [\n {\n ids: {\n match: \"^id|entryId$\",\n mapping: {\n type: \"keyword\"\n }\n }\n },\n {\n /* Update with the correct date fields. */\n dates: {\n match: \"^createdOn|savedOn|publishedOn$\",\n mapping: {\n type: \"date\"\n }\n }\n },\n {\n numbers: {\n match: \"number@*\",\n mapping: {\n type: \"scaled_float\",\n scaling_factor: 10000\n }\n }\n },\n {\n booleans: {\n match: \"boolean@*\",\n mapping: {\n type: \"boolean\"\n }\n }\n }\n ];\n};\n\ninterface Modifier {\n (\n mappings: OpenSearchIndexRequestBodyMappingsDynamicTemplate[]\n ): OpenSearchIndexRequestBodyMappingsDynamicTemplate[];\n}\n/**\n * @internal\n */\nexport const getCommonMappings = (\n cb?: Modifier\n): OpenSearchIndexRequestBodyMappingsDynamicTemplate[] => {\n if (!cb) {\n return getDefaultMappings();\n }\n\n return cb(getDefaultMappings());\n};\n"],"names":["getDefaultMappings","getCommonMappings","cb"],"mappings":"AAEA,MAAMA,qBAAqB,IAChB;QACH;YACI,KAAK;gBACD,OAAO;gBACP,SAAS;oBACL,MAAM;gBACV;YACJ;QACJ;QACA;YAEI,OAAO;gBACH,OAAO;gBACP,SAAS;oBACL,MAAM;gBACV;YACJ;QACJ;QACA;YACI,SAAS;gBACL,OAAO;gBACP,SAAS;oBACL,MAAM;oBACN,gBAAgB;gBACpB;YACJ;QACJ;QACA;YACI,UAAU;gBACN,OAAO;gBACP,SAAS;oBACL,MAAM;gBACV;YACJ;QACJ;KACH;AAWE,MAAMC,oBAAoB,CAC7BC;IAEA,IAAI,CAACA,IACD,OAAOF;IAGX,OAAOE,GAAGF;AACd"}
@@ -0,0 +1,2 @@
1
+ export * from "./base.js";
2
+ export * from "./common.js";
@@ -0,0 +1,2 @@
1
+ export * from "./base.js";
2
+ export * from "./common.js";
@@ -0,0 +1 @@
1
+ export declare const getOpenSearchIndexPrefix: () => string;
package/indexPrefix.js ADDED
@@ -0,0 +1,4 @@
1
+ const getOpenSearchIndexPrefix = ()=>process.env.OPENSEARCH_INDEX_PREFIX || process.env.ELASTICSEARCH_INDEX_PREFIX || process.env.WEBINY_OPENSEARCH_INDEX_PREFIX || process.env.WEBINY_ELASTICSEARCH_INDEX_PREFIX || "";
2
+ export { getOpenSearchIndexPrefix };
3
+
4
+ //# sourceMappingURL=indexPrefix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexPrefix.js","sources":["../src/indexPrefix.ts"],"sourcesContent":["export const getOpenSearchIndexPrefix = (): string => {\n return (\n process.env.OPENSEARCH_INDEX_PREFIX ||\n process.env.ELASTICSEARCH_INDEX_PREFIX ||\n process.env.WEBINY_OPENSEARCH_INDEX_PREFIX ||\n process.env.WEBINY_ELASTICSEARCH_INDEX_PREFIX ||\n \"\"\n );\n};\n"],"names":["getOpenSearchIndexPrefix","process"],"mappings":"AAAO,MAAMA,2BAA2B,IAEhCC,QAAQ,GAAG,CAAC,uBAAuB,IACnCA,QAAQ,GAAG,CAAC,0BAA0B,IACtCA,QAAQ,GAAG,CAAC,8BAA8B,IAC1CA,QAAQ,GAAG,CAAC,iCAAiC,IAC7C"}
package/indices.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { OpenSearchIndexRegistry } from "./features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js";
2
+ export { OpenSearchIndexRegistry };
package/indices.js ADDED
@@ -0,0 +1 @@
1
+ export { OpenSearchIndexRegistry } from "./features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js";
package/limit.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const createLimit: (limit?: number, defaultValue?: number) => number;
package/limit.js ADDED
@@ -0,0 +1,10 @@
1
+ const ES_LIMIT_MAX = 10000;
2
+ const ES_LIMIT_DEFAULT = 50;
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;
7
+ };
8
+ export { createLimit };
9
+
10
+ //# sourceMappingURL=limit.js.map
package/limit.js.map ADDED
@@ -0,0 +1 @@
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.d.ts ADDED
@@ -0,0 +1,6 @@
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
+ export declare const normalizeValue: (value: string) => string;
6
+ export declare const normalizeValueWithAsterisk: (initial: string) => string;
package/normalize.js ADDED
@@ -0,0 +1,55 @@
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 || "";
38
+ };
39
+ const hasSpecialChar = (value)=>{
40
+ if (!value) return null;
41
+ return null === value.match(/^([0-9a-zA-Z]+)$/i);
42
+ };
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
+ };
53
+ export { normalizeValue, normalizeValueWithAsterisk };
54
+
55
+ //# sourceMappingURL=normalize.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,7 @@
1
+ import type { Client } from "../client.js";
2
+ import type { IOpenSearchCatHealthResponse } from "./types.js";
3
+ export declare class OpenSearchCatHealth {
4
+ private readonly client;
5
+ constructor(client: Client);
6
+ getHealth(): Promise<IOpenSearchCatHealthResponse>;
7
+ }
@@ -0,0 +1,30 @@
1
+ import { WebinyError } from "@webiny/error";
2
+ import { stripConnectionFromException } from "./stripConnectionFromException.js";
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
+ }
26
+ }
27
+ }
28
+ export { OpenSearchCatHealth };
29
+
30
+ //# sourceMappingURL=OpenSearchCatHealth.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,7 @@
1
+ import type { IOpenSearchCatNodesResponse } from "./types.js";
2
+ import type { Client } from "../client.js";
3
+ export declare class OpenSearchCatNodes {
4
+ private readonly client;
5
+ constructor(client: Client);
6
+ getNodes(): Promise<IOpenSearchCatNodesResponse>;
7
+ }
@@ -0,0 +1,28 @@
1
+ import { WebinyError } from "@webiny/error";
2
+ import { stripConnectionFromException } from "./stripConnectionFromException.js";
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
+ }
24
+ }
25
+ }
26
+ export { OpenSearchCatNodes };
27
+
28
+ //# sourceMappingURL=OpenSearchCatNodes.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,3 @@
1
+ export * from "./OpenSearchCatHealth.js";
2
+ export * from "./OpenSearchCatNodes.js";
3
+ export * from "./types.js";
@@ -0,0 +1,3 @@
1
+ export * from "./OpenSearchCatHealth.js";
2
+ export * from "./OpenSearchCatNodes.js";
3
+ export * from "./types.js";
@@ -0,0 +1 @@
1
+ export declare const stripConnectionFromException: (ex: any) => any;
@@ -0,0 +1,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
+ };
11
+ };
12
+ export { stripConnectionFromException };
13
+
14
+ //# sourceMappingURL=stripConnectionFromException.js.map
@@ -0,0 +1 @@
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"}