@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @webiny/api-opensearch
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
package/client.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { Client } from "@opensearch-project/opensearch";
2
+ import type { ClientOptions } from "@opensearch-project/opensearch";
3
+ export interface OpenSearchClientOptions extends ClientOptions {
4
+ endpoint?: string;
5
+ }
6
+ export { Client };
7
+ export type { OpenSearchClientOptions as ClientOptions };
8
+ export declare const createOpenSearchClient: (options: OpenSearchClientOptions) => Client;
package/client.js ADDED
@@ -0,0 +1,37 @@
1
+ import crypto_0 from "crypto";
2
+ import error from "@webiny/error";
3
+ import { Client } from "@opensearch-project/opensearch";
4
+ const clients = new Map();
5
+ const createClientKey = (options)=>{
6
+ const key = JSON.stringify(options);
7
+ const hash = crypto_0.createHash("sha256");
8
+ hash.update(key);
9
+ return hash.digest("hex");
10
+ };
11
+ const createOpenSearchClient = (options)=>{
12
+ const key = createClientKey(options);
13
+ const existing = clients.get(key);
14
+ if (existing) return existing;
15
+ const { endpoint, node, ...rest } = options;
16
+ const clientOptions = {
17
+ node: endpoint || node,
18
+ ...rest
19
+ };
20
+ try {
21
+ const client = new Client(clientOptions);
22
+ clients.set(key, client);
23
+ return client;
24
+ } catch (ex) {
25
+ const data = {
26
+ error: ex,
27
+ node: endpoint || node,
28
+ ...rest,
29
+ auth: void 0
30
+ };
31
+ console.error(data);
32
+ throw new error("Could not connect to OpenSearch.", "OPENSEARCH_CLIENT_ERROR", data);
33
+ }
34
+ };
35
+ export { Client, createOpenSearchClient };
36
+
37
+ //# sourceMappingURL=client.js.map
package/client.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sources":["../src/client.ts"],"sourcesContent":["import crypto from \"crypto\";\nimport WebinyError from \"@webiny/error\";\nimport { Client } from \"@opensearch-project/opensearch\";\nimport type { ClientOptions } from \"@opensearch-project/opensearch\";\n\nexport interface OpenSearchClientOptions extends ClientOptions {\n endpoint?: string;\n}\n\nexport { Client };\nexport type { OpenSearchClientOptions as ClientOptions };\n\nconst clients = new Map<string, Client>();\n\nconst createClientKey = (options: OpenSearchClientOptions): string => {\n const key = JSON.stringify(options);\n const hash = crypto.createHash(\"sha256\");\n hash.update(key);\n return hash.digest(\"hex\");\n};\n\nexport const createOpenSearchClient = (options: OpenSearchClientOptions): Client => {\n const key = createClientKey(options);\n const existing = clients.get(key);\n if (existing) {\n return existing;\n }\n\n const { endpoint, node, ...rest } = options;\n\n const clientOptions: ClientOptions = {\n node: endpoint || node,\n ...rest\n };\n\n try {\n const client = new Client(clientOptions);\n clients.set(key, client);\n return client;\n } catch (ex) {\n const data = {\n error: ex,\n node: endpoint || node,\n ...rest,\n auth: undefined\n };\n console.error(data);\n throw new WebinyError(\"Could not connect to OpenSearch.\", \"OPENSEARCH_CLIENT_ERROR\", data);\n }\n};\n"],"names":["clients","Map","createClientKey","options","key","JSON","hash","crypto","createOpenSearchClient","existing","endpoint","node","rest","clientOptions","client","Client","ex","data","undefined","console","WebinyError"],"mappings":";;;AAYA,MAAMA,UAAU,IAAIC;AAEpB,MAAMC,kBAAkB,CAACC;IACrB,MAAMC,MAAMC,KAAK,SAAS,CAACF;IAC3B,MAAMG,OAAOC,SAAAA,UAAiB,CAAC;IAC/BD,KAAK,MAAM,CAACF;IACZ,OAAOE,KAAK,MAAM,CAAC;AACvB;AAEO,MAAME,yBAAyB,CAACL;IACnC,MAAMC,MAAMF,gBAAgBC;IAC5B,MAAMM,WAAWT,QAAQ,GAAG,CAACI;IAC7B,IAAIK,UACA,OAAOA;IAGX,MAAM,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGC,MAAM,GAAGT;IAEpC,MAAMU,gBAA+B;QACjC,MAAMH,YAAYC;QAClB,GAAGC,IAAI;IACX;IAEA,IAAI;QACA,MAAME,SAAS,IAAIC,OAAOF;QAC1Bb,QAAQ,GAAG,CAACI,KAAKU;QACjB,OAAOA;IACX,EAAE,OAAOE,IAAI;QACT,MAAMC,OAAO;YACT,OAAOD;YACP,MAAMN,YAAYC;YAClB,GAAGC,IAAI;YACP,MAAMM;QACV;QACAC,QAAQ,KAAK,CAACF;QACd,MAAM,IAAIG,MAAY,oCAAoC,2BAA2BH;IACzF;AACJ"}
package/cursors.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { PrimitiveValue } from "./types.js";
2
+ /**
3
+ * Encode a received cursor value into something that can be passed on to the user.
4
+ */
5
+ export declare const encodeCursor: (input?: PrimitiveValue[]) => string | undefined;
6
+ /**
7
+ * Decode a received value into an OpenSearch cursor.
8
+ * If no value is received or is not decodable, return undefined.
9
+ */
10
+ export declare const decodeCursor: (cursor?: string | null) => PrimitiveValue[] | undefined;
package/cursors.js ADDED
@@ -0,0 +1,25 @@
1
+ const encodeCursor = (input)=>{
2
+ if (!input) return;
3
+ const cursor = Array.isArray(input) ? input.filter((item)=>null != item).map((item)=>encodeURIComponent(item)) : encodeURIComponent(input);
4
+ try {
5
+ return Buffer.from(JSON.stringify(cursor)).toString("base64");
6
+ } catch (ex) {
7
+ console.error(ex.message);
8
+ }
9
+ };
10
+ const decodeCursor = (cursor)=>{
11
+ if (!cursor) return;
12
+ try {
13
+ const value = JSON.parse(Buffer.from(cursor, "base64").toString("ascii"));
14
+ if (Array.isArray(value)) return value.filter((item)=>null !== item).map(decodeURIComponent);
15
+ const decoded = decodeURIComponent(value);
16
+ return decoded ? [
17
+ decoded
18
+ ] : void 0;
19
+ } catch (ex) {
20
+ console.error(ex.message);
21
+ }
22
+ };
23
+ export { decodeCursor, encodeCursor };
24
+
25
+ //# sourceMappingURL=cursors.js.map
package/cursors.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursors.js","sources":["../src/cursors.ts"],"sourcesContent":["import type { PrimitiveValue } from \"~/types.js\";\n\n/**\n * Encode a received cursor value into something that can be passed on to the user.\n */\nexport const encodeCursor = (input?: PrimitiveValue[]): string | undefined => {\n if (!input) {\n return undefined;\n }\n\n const cursor = Array.isArray(input)\n ? input\n .filter((item: PrimitiveValue): item is string | number | boolean => item != null)\n .map(item => encodeURIComponent(item))\n : encodeURIComponent(input);\n\n try {\n return Buffer.from(JSON.stringify(cursor)).toString(\"base64\");\n } catch (ex) {\n console.error(ex.message);\n }\n return undefined;\n};\n/**\n * Decode a received value into an OpenSearch cursor.\n * If no value is received or is not decodable, return undefined.\n */\nexport const decodeCursor = (cursor?: string | null): PrimitiveValue[] | undefined => {\n if (!cursor) {\n return undefined;\n }\n try {\n const value = JSON.parse(Buffer.from(cursor, \"base64\").toString(\"ascii\"));\n if (Array.isArray(value)) {\n return value.filter(item => item !== null).map(decodeURIComponent);\n }\n const decoded = decodeURIComponent(value);\n return decoded ? [decoded] : undefined;\n } catch (ex) {\n console.error(ex.message);\n }\n return undefined;\n};\n"],"names":["encodeCursor","input","cursor","Array","item","encodeURIComponent","Buffer","JSON","ex","console","decodeCursor","value","decodeURIComponent","decoded","undefined"],"mappings":"AAKO,MAAMA,eAAe,CAACC;IACzB,IAAI,CAACA,OACD;IAGJ,MAAMC,SAASC,MAAM,OAAO,CAACF,SACvBA,MACK,MAAM,CAAC,CAACG,OAA4DA,AAAQ,QAARA,MACpE,GAAG,CAACA,CAAAA,OAAQC,mBAAmBD,SACpCC,mBAAmBJ;IAEzB,IAAI;QACA,OAAOK,OAAO,IAAI,CAACC,KAAK,SAAS,CAACL,SAAS,QAAQ,CAAC;IACxD,EAAE,OAAOM,IAAI;QACTC,QAAQ,KAAK,CAACD,GAAG,OAAO;IAC5B;AAEJ;AAKO,MAAME,eAAe,CAACR;IACzB,IAAI,CAACA,QACD;IAEJ,IAAI;QACA,MAAMS,QAAQJ,KAAK,KAAK,CAACD,OAAO,IAAI,CAACJ,QAAQ,UAAU,QAAQ,CAAC;QAChE,IAAIC,MAAM,OAAO,CAACQ,QACd,OAAOA,MAAM,MAAM,CAACP,CAAAA,OAAQA,AAAS,SAATA,MAAe,GAAG,CAACQ;QAEnD,MAAMC,UAAUD,mBAAmBD;QACnC,OAAOE,UAAU;YAACA;SAAQ,GAAGC;IACjC,EAAE,OAAON,IAAI;QACTC,QAAQ,KAAK,CAACD,GAAG,OAAO;IAC5B;AAEJ"}
@@ -0,0 +1,9 @@
1
+ export { createOpenSearchClient } from "../../client.js";
2
+ export { OpenSearchClient } from "../../features/OpenSearchClient/abstraction.js";
3
+ export { OpenSearchClientFactory } from "../../features/OpenSearchClientFactory/abstraction.js";
4
+ export { OpenSearchQueryBuilderOperator } from "../../features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js";
5
+ export { OpenSearchQueryBuilderOperatorRegistry } from "../../features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js";
6
+ export { OpenSearchField, OpenSearchFieldAll } from "../../features/OpenSearchField/abstractions/OpenSearchField.js";
7
+ export { OpenSearchFieldFactory } from "../../features/OpenSearchField/abstractions/OpenSearchFieldFactory.js";
8
+ export { OpenSearchIndex } from "../../features/OpenSearchIndex/abstractions/OpenSearchIndex.js";
9
+ export { OpenSearchIndexRegistry } from "../../features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js";
@@ -0,0 +1,9 @@
1
+ export { createOpenSearchClient } from "../../client.js";
2
+ export { OpenSearchClient } from "../../features/OpenSearchClient/abstraction.js";
3
+ export { OpenSearchClientFactory } from "../../features/OpenSearchClientFactory/abstraction.js";
4
+ export { OpenSearchQueryBuilderOperator } from "../../features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js";
5
+ export { OpenSearchQueryBuilderOperatorRegistry } from "../../features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js";
6
+ export { OpenSearchField, OpenSearchFieldAll } from "../../features/OpenSearchField/abstractions/OpenSearchField.js";
7
+ export { OpenSearchFieldFactory } from "../../features/OpenSearchField/abstractions/OpenSearchFieldFactory.js";
8
+ export { OpenSearchIndex } from "../../features/OpenSearchIndex/abstractions/OpenSearchIndex.js";
9
+ export { OpenSearchIndexRegistry } from "../../features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js";
@@ -0,0 +1,9 @@
1
+ import type { Client as IClient } from "../../client.js";
2
+ export interface IOpenSearchClient {
3
+ use(): IClient;
4
+ }
5
+ export declare const OpenSearchClient: import("@webiny/di").Abstraction<IOpenSearchClient>;
6
+ export declare namespace OpenSearchClient {
7
+ type Interface = IOpenSearchClient;
8
+ type Client = IClient;
9
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const OpenSearchClient = createAbstraction("OpenSearch/Client");
3
+ export { OpenSearchClient };
4
+
5
+ //# sourceMappingURL=abstraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchClient/abstraction.js","sources":["../../../src/features/OpenSearchClient/abstraction.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Client as IClient } from \"~/client.js\";\n\nexport interface IOpenSearchClient {\n use(): IClient;\n}\n\nexport const OpenSearchClient = createAbstraction<IOpenSearchClient>(\"OpenSearch/Client\");\n\nexport namespace OpenSearchClient {\n export type Interface = IOpenSearchClient;\n export type Client = IClient;\n}\n"],"names":["OpenSearchClient","createAbstraction"],"mappings":";AAOO,MAAMA,mBAAmBC,kBAAqC"}
@@ -0,0 +1,5 @@
1
+ import type { Client } from "../../client.js";
2
+ export declare const OpenSearchClientFeature: {
3
+ name: string;
4
+ register(container: import("@webiny/di").Container, context: Client): void;
5
+ };
@@ -0,0 +1,13 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { OpenSearchClient } from "./abstraction.js";
3
+ const OpenSearchClientFeature = createFeature({
4
+ name: "opensearch.internal.client",
5
+ register (container, client) {
6
+ container.registerInstance(OpenSearchClient, {
7
+ use: ()=>client
8
+ });
9
+ }
10
+ });
11
+ export { OpenSearchClientFeature };
12
+
13
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchClient/feature.js","sources":["../../../src/features/OpenSearchClient/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport type { Client } from \"~/client.js\";\nimport { OpenSearchClient } from \"./abstraction.js\";\n\nexport const OpenSearchClientFeature = createFeature<Client>({\n name: \"opensearch.internal.client\",\n register(container, client) {\n container.registerInstance(OpenSearchClient, {\n use: () => {\n return client;\n }\n });\n }\n});\n"],"names":["OpenSearchClientFeature","createFeature","container","client","OpenSearchClient"],"mappings":";;AAIO,MAAMA,0BAA0BC,cAAsB;IACzD,MAAM;IACN,UAASC,SAAS,EAAEC,MAAM;QACtBD,UAAU,gBAAgB,CAACE,kBAAkB;YACzC,KAAK,IACMD;QAEf;IACJ;AACJ"}
@@ -0,0 +1,9 @@
1
+ import { OpenSearchClientFactory as OpenSearchClientFactoryAbstraction } from "./abstraction.js";
2
+ import { Client, type OpenSearchClientOptions } from "../../client.js";
3
+ declare class OpenSearchClientFactoryImpl implements OpenSearchClientFactoryAbstraction.Interface {
4
+ getClient(params: OpenSearchClientOptions): Client;
5
+ }
6
+ export declare const OpenSearchClientFactory: typeof OpenSearchClientFactoryImpl & {
7
+ __abstraction: import("@webiny/di").Abstraction<import("./abstraction.js").IOpenSearchClientFactory>;
8
+ };
9
+ export {};
@@ -0,0 +1,15 @@
1
+ import { OpenSearchClientFactory } from "./abstraction.js";
2
+ import { createOpenSearchClient } from "../../client.js";
3
+ class OpenSearchClientFactoryImpl {
4
+ getClient(params) {
5
+ if (!params.endpoint && !params.node && !params.nodes) throw new Error("OpenSearch client requires an endpoint, nodes or node to be specified.");
6
+ return createOpenSearchClient(params);
7
+ }
8
+ }
9
+ const OpenSearchClientFactory_OpenSearchClientFactory = OpenSearchClientFactory.createImplementation({
10
+ implementation: OpenSearchClientFactoryImpl,
11
+ dependencies: []
12
+ });
13
+ export { OpenSearchClientFactory_OpenSearchClientFactory as OpenSearchClientFactory };
14
+
15
+ //# sourceMappingURL=OpenSearchClientFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchClientFactory/OpenSearchClientFactory.js","sources":["../../../src/features/OpenSearchClientFactory/OpenSearchClientFactory.ts"],"sourcesContent":["import { OpenSearchClientFactory as OpenSearchClientFactoryAbstraction } from \"./abstraction.js\";\nimport { Client, type OpenSearchClientOptions, createOpenSearchClient } from \"~/client.js\";\n\nclass OpenSearchClientFactoryImpl implements OpenSearchClientFactoryAbstraction.Interface {\n public getClient(params: OpenSearchClientOptions): Client {\n if (!params.endpoint && !params.node && !params.nodes) {\n throw new Error(\n \"OpenSearch client requires an endpoint, nodes or node to be specified.\"\n );\n }\n return createOpenSearchClient(params);\n }\n}\n\nexport const OpenSearchClientFactory = OpenSearchClientFactoryAbstraction.createImplementation({\n implementation: OpenSearchClientFactoryImpl,\n dependencies: []\n});\n"],"names":["OpenSearchClientFactoryImpl","params","Error","createOpenSearchClient","OpenSearchClientFactory","OpenSearchClientFactoryAbstraction"],"mappings":";;AAGA,MAAMA;IACK,UAAUC,MAA+B,EAAU;QACtD,IAAI,CAACA,OAAO,QAAQ,IAAI,CAACA,OAAO,IAAI,IAAI,CAACA,OAAO,KAAK,EACjD,MAAM,IAAIC,MACN;QAGR,OAAOC,uBAAuBF;IAClC;AACJ;AAEO,MAAMG,kDAA0BC,wBAAAA,oBAAuD,CAAC;IAC3F,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,10 @@
1
+ import type { Client, OpenSearchClientOptions } from "../../client.js";
2
+ export interface IOpenSearchClientFactory {
3
+ getClient(params: OpenSearchClientOptions): Client;
4
+ }
5
+ export declare const OpenSearchClientFactory: import("@webiny/di").Abstraction<IOpenSearchClientFactory>;
6
+ export declare namespace OpenSearchClientFactory {
7
+ type Interface = IOpenSearchClientFactory;
8
+ type Params = OpenSearchClientOptions;
9
+ type Return = Client;
10
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const OpenSearchClientFactory = createAbstraction("OpenSearch/ClientFactory");
3
+ export { OpenSearchClientFactory };
4
+
5
+ //# sourceMappingURL=abstraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchClientFactory/abstraction.js","sources":["../../../src/features/OpenSearchClientFactory/abstraction.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Client, OpenSearchClientOptions } from \"~/client.js\";\n\nexport interface IOpenSearchClientFactory {\n getClient(params: OpenSearchClientOptions): Client;\n}\n\nexport const OpenSearchClientFactory = createAbstraction<IOpenSearchClientFactory>(\n \"OpenSearch/ClientFactory\"\n);\n\nexport namespace OpenSearchClientFactory {\n export type Interface = IOpenSearchClientFactory;\n export type Params = OpenSearchClientOptions;\n export type Return = Client;\n}\n"],"names":["OpenSearchClientFactory","createAbstraction"],"mappings":";AAOO,MAAMA,0BAA0BC,kBACnC"}
@@ -0,0 +1,4 @@
1
+ export declare const OpenSearchClientFactoryFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { OpenSearchClientFactory } from "./OpenSearchClientFactory.js";
3
+ const OpenSearchClientFactoryFeature = createFeature({
4
+ name: "opensearch.internal.clientFactory",
5
+ register (container) {
6
+ container.register(OpenSearchClientFactory).inSingletonScope();
7
+ }
8
+ });
9
+ export { OpenSearchClientFactoryFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchClientFactory/feature.js","sources":["../../../src/features/OpenSearchClientFactory/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { OpenSearchClientFactory } from \"./OpenSearchClientFactory.js\";\n\nexport const OpenSearchClientFactoryFeature = createFeature({\n name: \"opensearch.internal.clientFactory\",\n register(container) {\n container.register(OpenSearchClientFactory).inSingletonScope();\n }\n});\n"],"names":["OpenSearchClientFactoryFeature","createFeature","container","OpenSearchClientFactory"],"mappings":";;AAGO,MAAMA,iCAAiCC,cAAc;IACxD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,yBAAyB,gBAAgB;IAChE;AACJ"}
@@ -0,0 +1,18 @@
1
+ import type { FieldSortOptions } from "../../types.js";
2
+ import type { SortOrder } from "../../types.js";
3
+ import type { OpenSearchField as OpenSearchFieldAbstraction } from "./abstractions/OpenSearchField.js";
4
+ export declare class OpenSearchField implements OpenSearchFieldAbstraction.Interface {
5
+ readonly field: string;
6
+ readonly path: string;
7
+ readonly keyword: boolean;
8
+ readonly unmappedType?: string;
9
+ readonly sortable: boolean;
10
+ readonly searchable: boolean;
11
+ private readonly searchValueFn?;
12
+ static create(params: OpenSearchFieldAbstraction.Params): OpenSearchField;
13
+ private constructor();
14
+ getSortOptions(order: SortOrder): FieldSortOptions;
15
+ getPath(field: string): string;
16
+ getBasePath(field: string): string;
17
+ toSearchValue(params: OpenSearchFieldAbstraction.SearchValueParams): any;
18
+ }
@@ -0,0 +1,49 @@
1
+ const keywordLessUnmappedType = [
2
+ "date",
3
+ "long"
4
+ ];
5
+ const unmappedTypeHasKeyword = (type)=>{
6
+ if (type) {
7
+ if (keywordLessUnmappedType.includes(type)) return false;
8
+ }
9
+ return true;
10
+ };
11
+ class OpenSearchField {
12
+ static create(params) {
13
+ return new OpenSearchField(params);
14
+ }
15
+ constructor(params){
16
+ this.field = params.field;
17
+ this.path = params.path || params.field;
18
+ this.unmappedType = params.unmappedType;
19
+ const keyword = void 0 === params.keyword ? true : params.keyword;
20
+ this.keyword = unmappedTypeHasKeyword(params.unmappedType) ? keyword : false;
21
+ this.sortable = void 0 === params.sortable ? true : params.sortable;
22
+ this.searchable = void 0 === params.searchable ? true : params.searchable;
23
+ this.searchValueFn = params.toSearchValue;
24
+ }
25
+ getSortOptions(order) {
26
+ const options = {
27
+ order
28
+ };
29
+ if (!this.unmappedType) return options;
30
+ return {
31
+ ...options,
32
+ unmapped_type: this.unmappedType
33
+ };
34
+ }
35
+ getPath(field) {
36
+ return `${this.getBasePath(field)}${this.keyword ? ".keyword" : ""}`;
37
+ }
38
+ getBasePath(field) {
39
+ if ("*" === this.path) return field;
40
+ return this.path;
41
+ }
42
+ toSearchValue(params) {
43
+ if (this.searchValueFn) return this.searchValueFn(params);
44
+ return params.value;
45
+ }
46
+ }
47
+ export { OpenSearchField };
48
+
49
+ //# sourceMappingURL=OpenSearchField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchField/OpenSearchField.js","sources":["../../../src/features/OpenSearchField/OpenSearchField.ts"],"sourcesContent":["import type { FieldSortOptions } from \"~/types.js\";\nimport type { SortOrder } from \"~/types.js\";\nimport type { OpenSearchField as OpenSearchFieldAbstraction } from \"./abstractions/OpenSearchField.js\";\n\nconst keywordLessUnmappedType = [\"date\", \"long\"];\n\nconst unmappedTypeHasKeyword = (type?: string): boolean => {\n if (!type) {\n return true;\n } else if (keywordLessUnmappedType.includes(type)) {\n return false;\n }\n return true;\n};\n\nexport class OpenSearchField implements OpenSearchFieldAbstraction.Interface {\n public readonly field: string;\n public readonly path: string;\n public readonly keyword: boolean;\n public readonly unmappedType?: string;\n public readonly sortable: boolean;\n public readonly searchable: boolean;\n private readonly searchValueFn?: (params: OpenSearchFieldAbstraction.SearchValueParams) => any;\n\n public static create(params: OpenSearchFieldAbstraction.Params) {\n return new OpenSearchField(params);\n }\n\n private constructor(params: OpenSearchFieldAbstraction.Params) {\n this.field = params.field;\n this.path = params.path || params.field;\n this.unmappedType = params.unmappedType;\n const keyword = params.keyword === undefined ? true : params.keyword;\n this.keyword = unmappedTypeHasKeyword(params.unmappedType) ? keyword : false;\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this.searchable = params.searchable === undefined ? true : params.searchable;\n this.searchValueFn = params.toSearchValue;\n }\n\n public getSortOptions(order: SortOrder): FieldSortOptions {\n const options = {\n order\n };\n if (!this.unmappedType) {\n return options;\n }\n return {\n ...options,\n unmapped_type: this.unmappedType as any\n };\n }\n\n public getPath(field: string): string {\n return `${this.getBasePath(field)}${this.keyword ? \".keyword\" : \"\"}`;\n }\n\n public getBasePath(field: string): string {\n if (this.path === \"*\") {\n return field;\n }\n return this.path;\n }\n\n public toSearchValue(params: OpenSearchFieldAbstraction.SearchValueParams): any {\n if (this.searchValueFn) {\n return this.searchValueFn(params);\n }\n return params.value;\n }\n}\n"],"names":["keywordLessUnmappedType","unmappedTypeHasKeyword","type","OpenSearchField","params","keyword","undefined","order","options","field"],"mappings":"AAIA,MAAMA,0BAA0B;IAAC;IAAQ;CAAO;AAEhD,MAAMC,yBAAyB,CAACC;IAC5B,IAAKA,MAEE;QAAA,IAAIF,wBAAwB,QAAQ,CAACE,OACxC,OAAO;IACX;IACA,OAAO;AACX;AAEO,MAAMC;IAST,OAAc,OAAOC,MAAyC,EAAE;QAC5D,OAAO,IAAID,gBAAgBC;IAC/B;IAEA,YAAoBA,MAAyC,CAAE;QAC3D,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI,IAAIA,OAAO,KAAK;QACvC,IAAI,CAAC,YAAY,GAAGA,OAAO,YAAY;QACvC,MAAMC,UAAUD,AAAmBE,WAAnBF,OAAO,OAAO,GAAiB,OAAOA,OAAO,OAAO;QACpE,IAAI,CAAC,OAAO,GAAGH,uBAAuBG,OAAO,YAAY,IAAIC,UAAU;QACvE,IAAI,CAAC,QAAQ,GAAGD,AAAoBE,WAApBF,OAAO,QAAQ,GAAiB,OAAOA,OAAO,QAAQ;QACtE,IAAI,CAAC,UAAU,GAAGA,AAAsBE,WAAtBF,OAAO,UAAU,GAAiB,OAAOA,OAAO,UAAU;QAC5E,IAAI,CAAC,aAAa,GAAGA,OAAO,aAAa;IAC7C;IAEO,eAAeG,KAAgB,EAAoB;QACtD,MAAMC,UAAU;YACZD;QACJ;QACA,IAAI,CAAC,IAAI,CAAC,YAAY,EAClB,OAAOC;QAEX,OAAO;YACH,GAAGA,OAAO;YACV,eAAe,IAAI,CAAC,YAAY;QACpC;IACJ;IAEO,QAAQC,KAAa,EAAU;QAClC,OAAO,GAAG,IAAI,CAAC,WAAW,CAACA,SAAS,IAAI,CAAC,OAAO,GAAG,aAAa,IAAI;IACxE;IAEO,YAAYA,KAAa,EAAU;QACtC,IAAI,AAAc,QAAd,IAAI,CAAC,IAAI,EACT,OAAOA;QAEX,OAAO,IAAI,CAAC,IAAI;IACpB;IAEO,cAAcL,MAAoD,EAAO;QAC5E,IAAI,IAAI,CAAC,aAAa,EAClB,OAAO,IAAI,CAAC,aAAa,CAACA;QAE9B,OAAOA,OAAO,KAAK;IACvB;AACJ"}
@@ -0,0 +1,9 @@
1
+ import { OpenSearchFieldFactory as Abstraction } from "./abstractions/OpenSearchFieldFactory.js";
2
+ import type { OpenSearchField as OpenSearchFieldAbstraction } from "./abstractions/OpenSearchField.js";
3
+ declare class OpenSearchFieldFactoryImpl implements Abstraction.Interface {
4
+ create(params: OpenSearchFieldAbstraction.Params): OpenSearchFieldAbstraction.Interface;
5
+ }
6
+ export declare const OpenSearchFieldFactory: typeof OpenSearchFieldFactoryImpl & {
7
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/OpenSearchFieldFactory.js").IOpenSearchFieldFactory>;
8
+ };
9
+ export {};
@@ -0,0 +1,14 @@
1
+ import { OpenSearchFieldFactory } from "./abstractions/OpenSearchFieldFactory.js";
2
+ import { OpenSearchField } from "./OpenSearchField.js";
3
+ class OpenSearchFieldFactoryImpl {
4
+ create(params) {
5
+ return OpenSearchField.create(params);
6
+ }
7
+ }
8
+ const OpenSearchFieldFactory_OpenSearchFieldFactory = OpenSearchFieldFactory.createImplementation({
9
+ implementation: OpenSearchFieldFactoryImpl,
10
+ dependencies: []
11
+ });
12
+ export { OpenSearchFieldFactory_OpenSearchFieldFactory as OpenSearchFieldFactory };
13
+
14
+ //# sourceMappingURL=OpenSearchFieldFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchField/OpenSearchFieldFactory.js","sources":["../../../src/features/OpenSearchField/OpenSearchFieldFactory.ts"],"sourcesContent":["import { OpenSearchFieldFactory as Abstraction } from \"./abstractions/OpenSearchFieldFactory.js\";\nimport type { OpenSearchField as OpenSearchFieldAbstraction } from \"./abstractions/OpenSearchField.js\";\nimport { OpenSearchField } from \"./OpenSearchField.js\";\n\nclass OpenSearchFieldFactoryImpl implements Abstraction.Interface {\n public create(params: OpenSearchFieldAbstraction.Params): OpenSearchFieldAbstraction.Interface {\n return OpenSearchField.create(params);\n }\n}\n\nexport const OpenSearchFieldFactory = Abstraction.createImplementation({\n implementation: OpenSearchFieldFactoryImpl,\n dependencies: []\n});\n"],"names":["OpenSearchFieldFactoryImpl","params","OpenSearchField","OpenSearchFieldFactory","Abstraction"],"mappings":";;AAIA,MAAMA;IACK,OAAOC,MAAyC,EAAwC;QAC3F,OAAOC,gBAAgB,MAAM,CAACD;IAClC;AACJ;AAEO,MAAME,gDAAyBC,uBAAAA,oBAAgC,CAAC;IACnE,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,35 @@
1
+ import type { FieldSortOptions } from "../../../types.js";
2
+ import type { SortOrder } from "../../../types.js";
3
+ export interface ToSearchValueParams {
4
+ value: any;
5
+ path: string;
6
+ basePath: string;
7
+ }
8
+ export interface OpenSearchFieldParams {
9
+ field: string;
10
+ path?: string;
11
+ keyword?: boolean;
12
+ unmappedType?: string;
13
+ sortable?: boolean;
14
+ searchable?: boolean;
15
+ toSearchValue?: (params: ToSearchValueParams) => any;
16
+ }
17
+ export interface IOpenSearchField {
18
+ readonly field: string;
19
+ readonly path: string;
20
+ readonly keyword: boolean;
21
+ readonly unmappedType?: string;
22
+ readonly sortable: boolean;
23
+ readonly searchable: boolean;
24
+ getPath(field: string): string;
25
+ getBasePath(field: string): string;
26
+ getSortOptions(order: SortOrder): FieldSortOptions;
27
+ toSearchValue(params: ToSearchValueParams): any;
28
+ }
29
+ export declare const OpenSearchField: import("@webiny/di").Abstraction<IOpenSearchField>;
30
+ export declare namespace OpenSearchField {
31
+ type Interface = IOpenSearchField;
32
+ type Params = OpenSearchFieldParams;
33
+ type SearchValueParams = ToSearchValueParams;
34
+ }
35
+ export declare const OpenSearchFieldAll: "*";
@@ -0,0 +1,6 @@
1
+ import { createAbstraction } from "@webiny/feature/exports/api.js";
2
+ const OpenSearchField = createAbstraction("OpenSearch/Field");
3
+ const OpenSearchFieldAll = "*";
4
+ export { OpenSearchField, OpenSearchFieldAll };
5
+
6
+ //# sourceMappingURL=OpenSearchField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchField/abstractions/OpenSearchField.js","sources":["../../../../src/features/OpenSearchField/abstractions/OpenSearchField.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/exports/api.js\";\nimport type { FieldSortOptions } from \"~/types.js\";\nimport type { SortOrder } from \"~/types.js\";\n\nexport interface ToSearchValueParams {\n value: any;\n path: string;\n basePath: string;\n}\n\nexport interface OpenSearchFieldParams {\n field: string;\n path?: string;\n keyword?: boolean;\n unmappedType?: string;\n sortable?: boolean;\n searchable?: boolean;\n toSearchValue?: (params: ToSearchValueParams) => any;\n}\n\nexport interface IOpenSearchField {\n readonly field: string;\n readonly path: string;\n readonly keyword: boolean;\n readonly unmappedType?: string;\n readonly sortable: boolean;\n readonly searchable: boolean;\n getPath(field: string): string;\n getBasePath(field: string): string;\n getSortOptions(order: SortOrder): FieldSortOptions;\n toSearchValue(params: ToSearchValueParams): any;\n}\n\nexport const OpenSearchField = createAbstraction<IOpenSearchField>(\"OpenSearch/Field\");\n\nexport namespace OpenSearchField {\n export type Interface = IOpenSearchField;\n export type Params = OpenSearchFieldParams;\n export type SearchValueParams = ToSearchValueParams;\n}\n\n/* The wildcard sentinel value used to match any field path. */\nexport const OpenSearchFieldAll = \"*\" as const;\n"],"names":["OpenSearchField","createAbstraction","OpenSearchFieldAll"],"mappings":";AAiCO,MAAMA,kBAAkBC,kBAAoC;AAS5D,MAAMC,qBAAqB"}
@@ -0,0 +1,8 @@
1
+ import type { OpenSearchField } from "./OpenSearchField.js";
2
+ export interface IOpenSearchFieldFactory {
3
+ create(params: OpenSearchField.Params): OpenSearchField.Interface;
4
+ }
5
+ export declare const OpenSearchFieldFactory: import("@webiny/di").Abstraction<IOpenSearchFieldFactory>;
6
+ export declare namespace OpenSearchFieldFactory {
7
+ type Interface = IOpenSearchFieldFactory;
8
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/exports/api.js";
2
+ const OpenSearchFieldFactory = createAbstraction("OpenSearch/FieldFactory");
3
+ export { OpenSearchFieldFactory };
4
+
5
+ //# sourceMappingURL=OpenSearchFieldFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchField/abstractions/OpenSearchFieldFactory.js","sources":["../../../../src/features/OpenSearchField/abstractions/OpenSearchFieldFactory.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/exports/api.js\";\nimport type { OpenSearchField } from \"./OpenSearchField.js\";\n\nexport interface IOpenSearchFieldFactory {\n create(params: OpenSearchField.Params): OpenSearchField.Interface;\n}\n\nexport const OpenSearchFieldFactory =\n createAbstraction<IOpenSearchFieldFactory>(\"OpenSearch/FieldFactory\");\n\nexport namespace OpenSearchFieldFactory {\n export type Interface = IOpenSearchFieldFactory;\n}\n"],"names":["OpenSearchFieldFactory","createAbstraction"],"mappings":";AAOO,MAAMA,yBACTC,kBAA2C"}
@@ -0,0 +1,4 @@
1
+ export declare const OpenSearchFieldFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { OpenSearchFieldFactory } from "./OpenSearchFieldFactory.js";
3
+ const OpenSearchFieldFeature = createFeature({
4
+ name: "opensearch.internal.field",
5
+ register (container) {
6
+ container.register(OpenSearchFieldFactory).inSingletonScope();
7
+ }
8
+ });
9
+ export { OpenSearchFieldFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchField/feature.js","sources":["../../../src/features/OpenSearchField/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { OpenSearchFieldFactory } from \"./OpenSearchFieldFactory.js\";\n\nexport const OpenSearchFieldFeature = createFeature({\n name: \"opensearch.internal.field\",\n register(container) {\n container.register(OpenSearchFieldFactory).inSingletonScope();\n }\n});\n"],"names":["OpenSearchFieldFeature","createFeature","container","OpenSearchFieldFactory"],"mappings":";;AAGO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,wBAAwB,gBAAgB;IAC/D;AACJ"}
@@ -0,0 +1,12 @@
1
+ import { OpenSearchIndex } from "./abstractions/OpenSearchIndex.js";
2
+ import { OpenSearchIndexRegistry as Abstraction } from "./abstractions/OpenSearchIndexRegistry.js";
3
+ declare class OpenSearchIndexRegistryImpl implements Abstraction.Interface {
4
+ private readonly indices;
5
+ constructor(indices: OpenSearchIndex.Interface[]);
6
+ getLastAdded(): OpenSearchIndex.Interface;
7
+ getAll(): OpenSearchIndex.Interface[];
8
+ }
9
+ export declare const OpenSearchIndexRegistry: typeof OpenSearchIndexRegistryImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/OpenSearchIndexRegistry.js").IOpenSearchIndexRegistry>;
11
+ };
12
+ export {};
@@ -0,0 +1,30 @@
1
+ import error from "@webiny/error";
2
+ import { OpenSearchIndex } from "./abstractions/OpenSearchIndex.js";
3
+ import { OpenSearchIndexRegistry } from "./abstractions/OpenSearchIndexRegistry.js";
4
+ class OpenSearchIndexRegistryImpl {
5
+ constructor(indices){
6
+ this.indices = indices;
7
+ }
8
+ getLastAdded() {
9
+ const usable = this.indices.filter((index)=>index.canUse());
10
+ if (0 === usable.length) throw new error("Could not find a single OpenSearchIndex.", "OPENSEARCH_INDEX_TEMPLATE_ERROR");
11
+ return usable[usable.length - 1];
12
+ }
13
+ getAll() {
14
+ return this.indices.filter((index)=>index.canUse());
15
+ }
16
+ }
17
+ const OpenSearchIndexRegistry_OpenSearchIndexRegistry = OpenSearchIndexRegistry.createImplementation({
18
+ implementation: OpenSearchIndexRegistryImpl,
19
+ dependencies: [
20
+ [
21
+ OpenSearchIndex,
22
+ {
23
+ multiple: true
24
+ }
25
+ ]
26
+ ]
27
+ });
28
+ export { OpenSearchIndexRegistry_OpenSearchIndexRegistry as OpenSearchIndexRegistry };
29
+
30
+ //# sourceMappingURL=OpenSearchIndexRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchIndex/OpenSearchIndexRegistry.js","sources":["../../../src/features/OpenSearchIndex/OpenSearchIndexRegistry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { OpenSearchIndex } from \"./abstractions/OpenSearchIndex.js\";\nimport { OpenSearchIndexRegistry as Abstraction } from \"./abstractions/OpenSearchIndexRegistry.js\";\n\nclass OpenSearchIndexRegistryImpl implements Abstraction.Interface {\n private readonly indices: OpenSearchIndex.Interface[];\n\n public constructor(indices: OpenSearchIndex.Interface[]) {\n this.indices = indices;\n }\n\n public getLastAdded(): OpenSearchIndex.Interface {\n const usable = this.indices.filter(index => index.canUse());\n if (usable.length === 0) {\n throw new WebinyError(\n \"Could not find a single OpenSearchIndex.\",\n \"OPENSEARCH_INDEX_TEMPLATE_ERROR\"\n );\n }\n return usable[usable.length - 1];\n }\n\n public getAll(): OpenSearchIndex.Interface[] {\n return this.indices.filter(index => index.canUse());\n }\n}\n\nexport const OpenSearchIndexRegistry = Abstraction.createImplementation({\n implementation: OpenSearchIndexRegistryImpl,\n dependencies: [[OpenSearchIndex, { multiple: true }]]\n});\n"],"names":["OpenSearchIndexRegistryImpl","indices","usable","index","WebinyError","OpenSearchIndexRegistry","Abstraction","OpenSearchIndex"],"mappings":";;;AAIA,MAAMA;IAGF,YAAmBC,OAAoC,CAAE;QACrD,IAAI,CAAC,OAAO,GAAGA;IACnB;IAEO,eAA0C;QAC7C,MAAMC,SAAS,IAAI,CAAC,OAAO,CAAC,MAAM,CAACC,CAAAA,QAASA,MAAM,MAAM;QACxD,IAAID,AAAkB,MAAlBA,OAAO,MAAM,EACb,MAAM,IAAIE,MACN,4CACA;QAGR,OAAOF,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE;IACpC;IAEO,SAAsC;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAACC,CAAAA,QAASA,MAAM,MAAM;IACpD;AACJ;AAEO,MAAME,kDAA0BC,wBAAAA,oBAAgC,CAAC;IACpE,gBAAgBN;IAChB,cAAc;QAAC;YAACO;YAAiB;gBAAE,UAAU;YAAK;SAAE;KAAC;AACzD"}
@@ -0,0 +1,9 @@
1
+ import type { OpenSearchIndexRequestBody } from "../../../types.js";
2
+ export interface IOpenSearchIndex {
3
+ readonly body: OpenSearchIndexRequestBody;
4
+ canUse(): boolean;
5
+ }
6
+ export declare const OpenSearchIndex: import("@webiny/di").Abstraction<IOpenSearchIndex>;
7
+ export declare namespace OpenSearchIndex {
8
+ type Interface = IOpenSearchIndex;
9
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/exports/api.js";
2
+ const OpenSearchIndex = createAbstraction("OpenSearch/Index");
3
+ export { OpenSearchIndex };
4
+
5
+ //# sourceMappingURL=OpenSearchIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchIndex/abstractions/OpenSearchIndex.js","sources":["../../../../src/features/OpenSearchIndex/abstractions/OpenSearchIndex.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/exports/api.js\";\nimport type { OpenSearchIndexRequestBody } from \"~/types.js\";\n\nexport interface IOpenSearchIndex {\n readonly body: OpenSearchIndexRequestBody;\n canUse(): boolean;\n}\n\nexport const OpenSearchIndex = createAbstraction<IOpenSearchIndex>(\"OpenSearch/Index\");\n\nexport namespace OpenSearchIndex {\n export type Interface = IOpenSearchIndex;\n}\n"],"names":["OpenSearchIndex","createAbstraction"],"mappings":";AAQO,MAAMA,kBAAkBC,kBAAoC"}
@@ -0,0 +1,9 @@
1
+ import type { OpenSearchIndex } from "./OpenSearchIndex.js";
2
+ export interface IOpenSearchIndexRegistry {
3
+ getLastAdded(): OpenSearchIndex.Interface;
4
+ getAll(): OpenSearchIndex.Interface[];
5
+ }
6
+ export declare const OpenSearchIndexRegistry: import("@webiny/di").Abstraction<IOpenSearchIndexRegistry>;
7
+ export declare namespace OpenSearchIndexRegistry {
8
+ type Interface = IOpenSearchIndexRegistry;
9
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/exports/api.js";
2
+ const OpenSearchIndexRegistry = createAbstraction("OpenSearch/IndexRegistry");
3
+ export { OpenSearchIndexRegistry };
4
+
5
+ //# sourceMappingURL=OpenSearchIndexRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js","sources":["../../../../src/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/exports/api.js\";\nimport type { OpenSearchIndex } from \"./OpenSearchIndex.js\";\n\nexport interface IOpenSearchIndexRegistry {\n getLastAdded(): OpenSearchIndex.Interface;\n getAll(): OpenSearchIndex.Interface[];\n}\n\nexport const OpenSearchIndexRegistry = createAbstraction<IOpenSearchIndexRegistry>(\n \"OpenSearch/IndexRegistry\"\n);\n\nexport namespace OpenSearchIndexRegistry {\n export type Interface = IOpenSearchIndexRegistry;\n}\n"],"names":["OpenSearchIndexRegistry","createAbstraction"],"mappings":";AAQO,MAAMA,0BAA0BC,kBACnC"}
@@ -0,0 +1,4 @@
1
+ export declare const OpenSearchIndexFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { OpenSearchIndexRegistry } from "./OpenSearchIndexRegistry.js";
3
+ const OpenSearchIndexFeature = createFeature({
4
+ name: "opensearch.internal.index",
5
+ register (container) {
6
+ container.register(OpenSearchIndexRegistry).inContainerScope();
7
+ }
8
+ });
9
+ export { OpenSearchIndexFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map