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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/client.js +30 -63
  2. package/client.js.map +1 -1
  3. package/cursors.js +20 -32
  4. package/cursors.js.map +1 -1
  5. package/exports/api/opensearch.d.ts +6 -1
  6. package/exports/api/opensearch.js +6 -3
  7. package/features/OpenSearchClient/abstraction.d.ts +3 -3
  8. package/features/OpenSearchClient/abstraction.js +2 -1
  9. package/features/OpenSearchClient/abstraction.js.map +1 -1
  10. package/features/OpenSearchClient/feature.d.ts +2 -1
  11. package/features/OpenSearchClient/feature.js +9 -6
  12. package/features/OpenSearchClient/feature.js.map +1 -1
  13. package/features/OpenSearchClientFactory/OpenSearchClientFactory.js +8 -9
  14. package/features/OpenSearchClientFactory/OpenSearchClientFactory.js.map +1 -1
  15. package/features/OpenSearchClientFactory/abstraction.js +2 -1
  16. package/features/OpenSearchClientFactory/abstraction.js.map +1 -1
  17. package/features/OpenSearchClientFactory/feature.js +6 -5
  18. package/features/OpenSearchClientFactory/feature.js.map +1 -1
  19. package/features/OpenSearchField/OpenSearchField.d.ts +18 -0
  20. package/features/OpenSearchField/OpenSearchField.js +49 -0
  21. package/features/OpenSearchField/OpenSearchField.js.map +1 -0
  22. package/features/OpenSearchField/OpenSearchFieldFactory.d.ts +9 -0
  23. package/features/OpenSearchField/OpenSearchFieldFactory.js +14 -0
  24. package/features/OpenSearchField/OpenSearchFieldFactory.js.map +1 -0
  25. package/features/OpenSearchField/abstractions/OpenSearchField.d.ts +35 -0
  26. package/features/OpenSearchField/abstractions/OpenSearchField.js +6 -0
  27. package/features/OpenSearchField/abstractions/OpenSearchField.js.map +1 -0
  28. package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.d.ts +8 -0
  29. package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.js +5 -0
  30. package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.js.map +1 -0
  31. package/features/OpenSearchField/feature.d.ts +4 -0
  32. package/features/OpenSearchField/feature.js +11 -0
  33. package/features/OpenSearchField/feature.js.map +1 -0
  34. package/features/OpenSearchIndex/OpenSearchIndexRegistry.d.ts +12 -0
  35. package/features/OpenSearchIndex/OpenSearchIndexRegistry.js +30 -0
  36. package/features/OpenSearchIndex/OpenSearchIndexRegistry.js.map +1 -0
  37. package/features/OpenSearchIndex/abstractions/OpenSearchIndex.d.ts +9 -0
  38. package/features/OpenSearchIndex/abstractions/OpenSearchIndex.js +5 -0
  39. package/features/OpenSearchIndex/abstractions/OpenSearchIndex.js.map +1 -0
  40. package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.d.ts +9 -0
  41. package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js +5 -0
  42. package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js.map +1 -0
  43. package/features/OpenSearchIndex/feature.d.ts +4 -0
  44. package/features/OpenSearchIndex/feature.js +11 -0
  45. package/features/OpenSearchIndex/feature.js.map +1 -0
  46. package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.d.ts +12 -0
  47. package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.js +28 -0
  48. package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.js.map +1 -0
  49. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.d.ts +11 -0
  50. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js +5 -0
  51. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js.map +1 -0
  52. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.d.ts +10 -0
  53. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js +5 -0
  54. package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js.map +1 -0
  55. package/features/OpenSearchQueryBuilderOperator/feature.d.ts +4 -0
  56. package/features/OpenSearchQueryBuilderOperator/feature.js +41 -0
  57. package/features/OpenSearchQueryBuilderOperator/feature.js.map +1 -0
  58. package/features/OpenSearchQueryBuilderOperator/operators/AndIn.d.ts +9 -0
  59. package/features/OpenSearchQueryBuilderOperator/operators/AndIn.js +28 -0
  60. package/features/OpenSearchQueryBuilderOperator/operators/AndIn.js.map +1 -0
  61. package/features/OpenSearchQueryBuilderOperator/operators/Between.d.ts +9 -0
  62. package/features/OpenSearchQueryBuilderOperator/operators/Between.js +27 -0
  63. package/features/OpenSearchQueryBuilderOperator/operators/Between.js.map +1 -0
  64. package/features/OpenSearchQueryBuilderOperator/operators/Contains.d.ts +9 -0
  65. package/features/OpenSearchQueryBuilderOperator/operators/Contains.js +27 -0
  66. package/features/OpenSearchQueryBuilderOperator/operators/Contains.js.map +1 -0
  67. package/features/OpenSearchQueryBuilderOperator/operators/Equal.d.ts +9 -0
  68. package/features/OpenSearchQueryBuilderOperator/operators/Equal.js +34 -0
  69. package/features/OpenSearchQueryBuilderOperator/operators/Equal.js.map +1 -0
  70. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.d.ts +9 -0
  71. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.js +23 -0
  72. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.js.map +1 -0
  73. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.d.ts +9 -0
  74. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.js +23 -0
  75. package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.js.map +1 -0
  76. package/features/OpenSearchQueryBuilderOperator/operators/In.d.ts +9 -0
  77. package/features/OpenSearchQueryBuilderOperator/operators/In.js +24 -0
  78. package/features/OpenSearchQueryBuilderOperator/operators/In.js.map +1 -0
  79. package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.d.ts +9 -0
  80. package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.js +23 -0
  81. package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.js.map +1 -0
  82. package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.d.ts +9 -0
  83. package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.js +23 -0
  84. package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.js.map +1 -0
  85. package/features/OpenSearchQueryBuilderOperator/operators/Not.d.ts +9 -0
  86. package/features/OpenSearchQueryBuilderOperator/operators/Not.js +38 -0
  87. package/features/OpenSearchQueryBuilderOperator/operators/Not.js.map +1 -0
  88. package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.d.ts +9 -0
  89. package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.js +27 -0
  90. package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.js.map +1 -0
  91. package/features/OpenSearchQueryBuilderOperator/operators/NotContains.d.ts +9 -0
  92. package/features/OpenSearchQueryBuilderOperator/operators/NotContains.js +27 -0
  93. package/features/OpenSearchQueryBuilderOperator/operators/NotContains.js.map +1 -0
  94. package/features/OpenSearchQueryBuilderOperator/operators/NotIn.d.ts +9 -0
  95. package/features/OpenSearchQueryBuilderOperator/operators/NotIn.js +24 -0
  96. package/features/OpenSearchQueryBuilderOperator/operators/NotIn.js.map +1 -0
  97. package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.d.ts +9 -0
  98. package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js +22 -0
  99. package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js.map +1 -0
  100. package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.d.ts +9 -0
  101. package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.js +22 -0
  102. package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.js.map +1 -0
  103. package/index.d.ts +2 -10
  104. package/index.js +3 -30
  105. package/indexConfiguration/base.js +25 -26
  106. package/indexConfiguration/base.js.map +1 -1
  107. package/indexConfiguration/common.js +39 -41
  108. package/indexConfiguration/common.js.map +1 -1
  109. package/indexConfiguration/index.js +0 -2
  110. package/indexPrefix.js +2 -3
  111. package/indexPrefix.js.map +1 -1
  112. package/indices.d.ts +2 -8
  113. package/indices.js +1 -20
  114. package/limit.js +5 -27
  115. package/limit.js.map +1 -1
  116. package/normalize.js +50 -49
  117. package/normalize.js.map +1 -1
  118. package/operations/OpenSearchCatHealth.js +24 -25
  119. package/operations/OpenSearchCatHealth.js.map +1 -1
  120. package/operations/OpenSearchCatNodes.js +22 -23
  121. package/operations/OpenSearchCatNodes.js.map +1 -1
  122. package/operations/index.js +0 -2
  123. package/operations/stripConnectionFromException.js +11 -14
  124. package/operations/stripConnectionFromException.js.map +1 -1
  125. package/operations/types.js +6 -5
  126. package/operations/types.js.map +1 -1
  127. package/package.json +12 -14
  128. package/registerOpenSearchCore.d.ts +3 -0
  129. package/registerOpenSearchCore.js +20 -0
  130. package/registerOpenSearchCore.js.map +1 -0
  131. package/sharedIndex.js +2 -3
  132. package/sharedIndex.js.map +1 -1
  133. package/sort.d.ts +2 -2
  134. package/sort.js +30 -59
  135. package/sort.js.map +1 -1
  136. package/testing/createBlankQuery.d.ts +2 -0
  137. package/testing/createBlankQuery.js +9 -0
  138. package/testing/createBlankQuery.js.map +1 -0
  139. package/testing/createTestOpenSearchClient.d.ts +11 -0
  140. package/testing/createTestOpenSearchClient.js +162 -0
  141. package/testing/createTestOpenSearchClient.js.map +1 -0
  142. package/testing/index.d.ts +4 -0
  143. package/testing/index.js +4 -0
  144. package/testing/registerOpenSearchCoreForTests.d.ts +1 -0
  145. package/testing/registerOpenSearchCoreForTests.js +9 -0
  146. package/testing/registerOpenSearchCoreForTests.js.map +1 -0
  147. package/testing/setupTestIndexManager.d.ts +13 -0
  148. package/testing/setupTestIndexManager.js +26 -0
  149. package/testing/setupTestIndexManager.js.map +1 -0
  150. package/types.d.ts +0 -8
  151. package/types.js +5 -65
  152. package/types.js.map +1 -1
  153. package/utils/createIndex.d.ts +2 -2
  154. package/utils/createIndex.js +52 -80
  155. package/utils/createIndex.js.map +1 -1
  156. package/utils/index.js +0 -2
  157. package/utils/waitUntilHealthy/UnhealthyClusterError.js +8 -7
  158. package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -1
  159. package/utils/waitUntilHealthy/WaitUntilHealthy.js +111 -141
  160. package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -1
  161. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +8 -7
  162. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -1
  163. package/utils/waitUntilHealthy/index.js +0 -2
  164. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +9 -10
  165. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -1
  166. package/utils/waitUntilHealthy/reason/IReason.js +0 -3
  167. package/utils/waitUntilHealthy/reason/MemoryReason.js +9 -10
  168. package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -1
  169. package/utils/waitUntilHealthy/reason/ProcessorReason.js +9 -10
  170. package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -1
  171. package/utils/waitUntilHealthy/reason/index.js +0 -2
  172. package/where.d.ts +4 -4
  173. package/where.js +43 -76
  174. package/where.js.map +1 -1
  175. package/db/entity.d.ts +0 -7
  176. package/db/entity.js +0 -20
  177. package/db/entity.js.map +0 -1
  178. package/db/index.d.ts +0 -3
  179. package/db/index.js +0 -5
  180. package/db/index.js.map +0 -1
  181. package/db/table.d.ts +0 -7
  182. package/db/table.js +0 -17
  183. package/db/table.js.map +0 -1
  184. package/db/types.d.ts +0 -6
  185. package/db/types.js +0 -3
  186. package/db/types.js.map +0 -1
  187. package/exports/api/opensearch.js.map +0 -1
  188. package/features/OpenSearchClient/OpenSearchClient.d.ts +0 -12
  189. package/features/OpenSearchClient/OpenSearchClient.js +0 -16
  190. package/features/OpenSearchClient/OpenSearchClient.js.map +0 -1
  191. package/features/OpenSearchContext/OpenSearchContext.d.ts +0 -8
  192. package/features/OpenSearchContext/OpenSearchContext.js +0 -13
  193. package/features/OpenSearchContext/OpenSearchContext.js.map +0 -1
  194. package/features/OpenSearchContext/abstraction.d.ts +0 -14
  195. package/features/OpenSearchContext/abstraction.js +0 -4
  196. package/features/OpenSearchContext/abstraction.js.map +0 -1
  197. package/features/OpenSearchContext/feature.d.ts +0 -5
  198. package/features/OpenSearchContext/feature.js +0 -13
  199. package/features/OpenSearchContext/feature.js.map +0 -1
  200. package/index.js.map +0 -1
  201. package/indexConfiguration/index.js.map +0 -1
  202. package/indices.js.map +0 -1
  203. package/operations/index.js.map +0 -1
  204. package/operators.d.ts +0 -6
  205. package/operators.js +0 -9
  206. package/operators.js.map +0 -1
  207. package/plugins/definition/OpenSearchBodyModifierPlugin.d.ts +0 -13
  208. package/plugins/definition/OpenSearchBodyModifierPlugin.js +0 -18
  209. package/plugins/definition/OpenSearchBodyModifierPlugin.js.map +0 -1
  210. package/plugins/definition/OpenSearchFieldPlugin.d.ts +0 -81
  211. package/plugins/definition/OpenSearchFieldPlugin.js +0 -69
  212. package/plugins/definition/OpenSearchFieldPlugin.js.map +0 -1
  213. package/plugins/definition/OpenSearchIndexPlugin.d.ts +0 -10
  214. package/plugins/definition/OpenSearchIndexPlugin.js +0 -17
  215. package/plugins/definition/OpenSearchIndexPlugin.js.map +0 -1
  216. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.d.ts +0 -10
  217. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js +0 -9
  218. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js.map +0 -1
  219. package/plugins/definition/OpenSearchQueryModifierPlugin.d.ts +0 -14
  220. package/plugins/definition/OpenSearchQueryModifierPlugin.js +0 -18
  221. package/plugins/definition/OpenSearchQueryModifierPlugin.js.map +0 -1
  222. package/plugins/definition/OpenSearchSortModifierPlugin.d.ts +0 -13
  223. package/plugins/definition/OpenSearchSortModifierPlugin.js +0 -18
  224. package/plugins/definition/OpenSearchSortModifierPlugin.js.map +0 -1
  225. package/plugins/definition/index.d.ts +0 -6
  226. package/plugins/definition/index.js +0 -8
  227. package/plugins/definition/index.js.map +0 -1
  228. package/plugins/index.d.ts +0 -2
  229. package/plugins/index.js +0 -4
  230. package/plugins/index.js.map +0 -1
  231. package/plugins/operator/andIn.d.ts +0 -7
  232. package/plugins/operator/andIn.js +0 -35
  233. package/plugins/operator/andIn.js.map +0 -1
  234. package/plugins/operator/between.d.ts +0 -7
  235. package/plugins/operator/between.js +0 -32
  236. package/plugins/operator/between.js.map +0 -1
  237. package/plugins/operator/contains.d.ts +0 -7
  238. package/plugins/operator/contains.js +0 -24
  239. package/plugins/operator/contains.js.map +0 -1
  240. package/plugins/operator/equal.d.ts +0 -7
  241. package/plugins/operator/equal.js +0 -50
  242. package/plugins/operator/equal.js.map +0 -1
  243. package/plugins/operator/gt.d.ts +0 -7
  244. package/plugins/operator/gt.js +0 -22
  245. package/plugins/operator/gt.js.map +0 -1
  246. package/plugins/operator/gte.d.ts +0 -7
  247. package/plugins/operator/gte.js +0 -22
  248. package/plugins/operator/gte.js.map +0 -1
  249. package/plugins/operator/in.d.ts +0 -7
  250. package/plugins/operator/in.js +0 -29
  251. package/plugins/operator/in.js.map +0 -1
  252. package/plugins/operator/index.d.ts +0 -15
  253. package/plugins/operator/index.js +0 -17
  254. package/plugins/operator/index.js.map +0 -1
  255. package/plugins/operator/lt.d.ts +0 -7
  256. package/plugins/operator/lt.js +0 -22
  257. package/plugins/operator/lt.js.map +0 -1
  258. package/plugins/operator/lte.d.ts +0 -7
  259. package/plugins/operator/lte.js +0 -22
  260. package/plugins/operator/lte.js.map +0 -1
  261. package/plugins/operator/not.d.ts +0 -7
  262. package/plugins/operator/not.js +0 -44
  263. package/plugins/operator/not.js.map +0 -1
  264. package/plugins/operator/notBetween.d.ts +0 -7
  265. package/plugins/operator/notBetween.js +0 -32
  266. package/plugins/operator/notBetween.js.map +0 -1
  267. package/plugins/operator/notContains.d.ts +0 -7
  268. package/plugins/operator/notContains.js +0 -24
  269. package/plugins/operator/notContains.js.map +0 -1
  270. package/plugins/operator/notIn.d.ts +0 -7
  271. package/plugins/operator/notIn.js +0 -27
  272. package/plugins/operator/notIn.js.map +0 -1
  273. package/plugins/operator/notStartsWith.d.ts +0 -7
  274. package/plugins/operator/notStartsWith.js +0 -23
  275. package/plugins/operator/notStartsWith.js.map +0 -1
  276. package/plugins/operator/startsWith.d.ts +0 -7
  277. package/plugins/operator/startsWith.js +0 -23
  278. package/plugins/operator/startsWith.js.map +0 -1
  279. package/utils/index.js.map +0 -1
  280. package/utils/waitUntilHealthy/index.js.map +0 -1
  281. package/utils/waitUntilHealthy/reason/IReason.js.map +0 -1
  282. package/utils/waitUntilHealthy/reason/index.js.map +0 -1
package/client.js CHANGED
@@ -1,70 +1,37 @@
1
- import crypto from "crypto";
2
- import WebinyError from "@webiny/error";
1
+ import crypto_0 from "crypto";
2
+ import error from "@webiny/error";
3
3
  import { Client } from "@opensearch-project/opensearch";
4
- import { AwsSigv4Signer } from "@opensearch-project/opensearch/aws";
5
- export { Client };
6
4
  const clients = new Map();
7
- const createClientKey = options => {
8
- const key = JSON.stringify(options);
9
- const hash = crypto.createHash("sha256");
10
- hash.update(key);
11
- return hash.digest("hex");
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");
12
10
  };
13
- export const createOpenSearchClient = options => {
14
- const key = createClientKey(options);
15
- const existing = clients.get(key);
16
- if (existing) {
17
- return existing;
18
- }
19
- const {
20
- endpoint,
21
- node,
22
- ...rest
23
- } = options;
24
- let clientOptions = {
25
- node: endpoint || node,
26
- ...rest
27
- };
28
- if (!clientOptions.auth) {
29
- const region = process.env.AWS_REGION;
30
- if (!region) {
31
- throw new WebinyError("Missing AWS_REGION environment variable.", "MISSING_AWS_REGION");
32
- }
33
- clientOptions = {
34
- ...clientOptions,
35
- ...AwsSigv4Signer({
36
- region,
37
- service: "es",
38
- getCredentials: () => {
39
- const accessKeyId = process.env.AWS_ACCESS_KEY_ID;
40
- const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
41
- const sessionToken = process.env.AWS_SESSION_TOKEN;
42
- if (!accessKeyId || !secretAccessKey) {
43
- throw new WebinyError("Missing AWS credentials (AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY).", "MISSING_AWS_CREDENTIALS");
44
- }
45
- return Promise.resolve({
46
- accessKeyId,
47
- secretAccessKey,
48
- sessionToken
49
- });
50
- }
51
- })
52
- };
53
- }
54
- try {
55
- const client = new Client(clientOptions);
56
- clients.set(key, client);
57
- return client;
58
- } catch (ex) {
59
- const data = {
60
- error: ex,
61
- node: endpoint || node,
62
- ...rest,
63
- auth: undefined
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
64
19
  };
65
- console.error(data);
66
- throw new WebinyError("Could not connect to OpenSearch.", "OPENSEARCH_CLIENT_ERROR", data);
67
- }
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
+ }
68
34
  };
35
+ export { Client, createOpenSearchClient };
69
36
 
70
37
  //# sourceMappingURL=client.js.map
package/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["crypto","WebinyError","Client","AwsSigv4Signer","clients","Map","createClientKey","options","key","JSON","stringify","hash","createHash","update","digest","createOpenSearchClient","existing","get","endpoint","node","rest","clientOptions","auth","region","process","env","AWS_REGION","service","getCredentials","accessKeyId","AWS_ACCESS_KEY_ID","secretAccessKey","AWS_SECRET_ACCESS_KEY","sessionToken","AWS_SESSION_TOKEN","Promise","resolve","client","set","ex","data","error","undefined","console"],"sources":["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\";\nimport { AwsSigv4Signer } from \"@opensearch-project/opensearch/aws\";\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 let clientOptions: ClientOptions = {\n node: endpoint || node,\n ...rest\n };\n\n if (!clientOptions.auth) {\n const region = process.env.AWS_REGION;\n if (!region) {\n throw new WebinyError(\"Missing AWS_REGION environment variable.\", \"MISSING_AWS_REGION\");\n }\n\n clientOptions = {\n ...clientOptions,\n ...AwsSigv4Signer({\n region,\n service: \"es\",\n getCredentials: () => {\n const accessKeyId = process.env.AWS_ACCESS_KEY_ID;\n const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;\n const sessionToken = process.env.AWS_SESSION_TOKEN;\n\n if (!accessKeyId || !secretAccessKey) {\n throw new WebinyError(\n \"Missing AWS credentials (AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY).\",\n \"MISSING_AWS_CREDENTIALS\"\n );\n }\n\n return Promise.resolve({ accessKeyId, secretAccessKey, sessionToken });\n }\n })\n };\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"],"mappings":"AAAA,OAAOA,MAAM,MAAM,QAAQ;AAC3B,OAAOC,WAAW,MAAM,eAAe;AACvC,SAASC,MAAM,QAAQ,gCAAgC;AAEvD,SAASC,cAAc,QAAQ,oCAAoC;AAMnE,SAASD,MAAM;AAGf,MAAME,OAAO,GAAG,IAAIC,GAAG,CAAiB,CAAC;AAEzC,MAAMC,eAAe,GAAIC,OAAgC,IAAa;EAClE,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAACH,OAAO,CAAC;EACnC,MAAMI,IAAI,GAAGX,MAAM,CAACY,UAAU,CAAC,QAAQ,CAAC;EACxCD,IAAI,CAACE,MAAM,CAACL,GAAG,CAAC;EAChB,OAAOG,IAAI,CAACG,MAAM,CAAC,KAAK,CAAC;AAC7B,CAAC;AAED,OAAO,MAAMC,sBAAsB,GAAIR,OAAgC,IAAa;EAChF,MAAMC,GAAG,GAAGF,eAAe,CAACC,OAAO,CAAC;EACpC,MAAMS,QAAQ,GAAGZ,OAAO,CAACa,GAAG,CAACT,GAAG,CAAC;EACjC,IAAIQ,QAAQ,EAAE;IACV,OAAOA,QAAQ;EACnB;EAEA,MAAM;IAAEE,QAAQ;IAAEC,IAAI;IAAE,GAAGC;EAAK,CAAC,GAAGb,OAAO;EAE3C,IAAIc,aAA4B,GAAG;IAC/BF,IAAI,EAAED,QAAQ,IAAIC,IAAI;IACtB,GAAGC;EACP,CAAC;EAED,IAAI,CAACC,aAAa,CAACC,IAAI,EAAE;IACrB,MAAMC,MAAM,GAAGC,OAAO,CAACC,GAAG,CAACC,UAAU;IACrC,IAAI,CAACH,MAAM,EAAE;MACT,MAAM,IAAItB,WAAW,CAAC,0CAA0C,EAAE,oBAAoB,CAAC;IAC3F;IAEAoB,aAAa,GAAG;MACZ,GAAGA,aAAa;MAChB,GAAGlB,cAAc,CAAC;QACdoB,MAAM;QACNI,OAAO,EAAE,IAAI;QACbC,cAAc,EAAEA,CAAA,KAAM;UAClB,MAAMC,WAAW,GAAGL,OAAO,CAACC,GAAG,CAACK,iBAAiB;UACjD,MAAMC,eAAe,GAAGP,OAAO,CAACC,GAAG,CAACO,qBAAqB;UACzD,MAAMC,YAAY,GAAGT,OAAO,CAACC,GAAG,CAACS,iBAAiB;UAElD,IAAI,CAACL,WAAW,IAAI,CAACE,eAAe,EAAE;YAClC,MAAM,IAAI9B,WAAW,CACjB,uEAAuE,EACvE,yBACJ,CAAC;UACL;UAEA,OAAOkC,OAAO,CAACC,OAAO,CAAC;YAAEP,WAAW;YAAEE,eAAe;YAAEE;UAAa,CAAC,CAAC;QAC1E;MACJ,CAAC;IACL,CAAC;EACL;EAEA,IAAI;IACA,MAAMI,MAAM,GAAG,IAAInC,MAAM,CAACmB,aAAa,CAAC;IACxCjB,OAAO,CAACkC,GAAG,CAAC9B,GAAG,EAAE6B,MAAM,CAAC;IACxB,OAAOA,MAAM;EACjB,CAAC,CAAC,OAAOE,EAAE,EAAE;IACT,MAAMC,IAAI,GAAG;MACTC,KAAK,EAAEF,EAAE;MACTpB,IAAI,EAAED,QAAQ,IAAIC,IAAI;MACtB,GAAGC,IAAI;MACPE,IAAI,EAAEoB;IACV,CAAC;IACDC,OAAO,CAACF,KAAK,CAACD,IAAI,CAAC;IACnB,MAAM,IAAIvC,WAAW,CAAC,kCAAkC,EAAE,yBAAyB,EAAEuC,IAAI,CAAC;EAC9F;AACJ,CAAC","ignoreList":[]}
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.js CHANGED
@@ -1,37 +1,25 @@
1
- /**
2
- * Encode a received cursor value into something that can be passed on to the user.
3
- */
4
- export const encodeCursor = input => {
5
- if (!input) {
6
- return undefined;
7
- }
8
- const cursor = Array.isArray(input) ? input.filter(item => item != null).map(item => encodeURIComponent(item)) : encodeURIComponent(input);
9
- try {
10
- return Buffer.from(JSON.stringify(cursor)).toString("base64");
11
- } catch (ex) {
12
- console.error(ex.message);
13
- }
14
- return undefined;
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
+ }
15
9
  };
16
- /**
17
- * Decode a received value into an OpenSearch cursor.
18
- * If no value is received or is not decodable, return undefined.
19
- */
20
- export const decodeCursor = cursor => {
21
- if (!cursor) {
22
- return undefined;
23
- }
24
- try {
25
- const value = JSON.parse(Buffer.from(cursor, "base64").toString("ascii"));
26
- if (Array.isArray(value)) {
27
- return value.filter(item => item !== null).map(decodeURIComponent);
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);
28
21
  }
29
- const decoded = decodeURIComponent(value);
30
- return decoded ? [decoded] : undefined;
31
- } catch (ex) {
32
- console.error(ex.message);
33
- }
34
- return undefined;
35
22
  };
23
+ export { decodeCursor, encodeCursor };
36
24
 
37
25
  //# sourceMappingURL=cursors.js.map
package/cursors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["encodeCursor","input","undefined","cursor","Array","isArray","filter","item","map","encodeURIComponent","Buffer","from","JSON","stringify","toString","ex","console","error","message","decodeCursor","value","parse","decodeURIComponent","decoded"],"sources":["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"],"mappings":"AAEA;AACA;AACA;AACA,OAAO,MAAMA,YAAY,GAAIC,KAAwB,IAAyB;EAC1E,IAAI,CAACA,KAAK,EAAE;IACR,OAAOC,SAAS;EACpB;EAEA,MAAMC,MAAM,GAAGC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,GAC7BA,KAAK,CACAK,MAAM,CAAEC,IAAoB,IAAwCA,IAAI,IAAI,IAAI,CAAC,CACjFC,GAAG,CAACD,IAAI,IAAIE,kBAAkB,CAACF,IAAI,CAAC,CAAC,GAC1CE,kBAAkB,CAACR,KAAK,CAAC;EAE/B,IAAI;IACA,OAAOS,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACV,MAAM,CAAC,CAAC,CAACW,QAAQ,CAAC,QAAQ,CAAC;EACjE,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAACG,OAAO,CAAC;EAC7B;EACA,OAAOhB,SAAS;AACpB,CAAC;AACD;AACA;AACA;AACA;AACA,OAAO,MAAMiB,YAAY,GAAIhB,MAAsB,IAAmC;EAClF,IAAI,CAACA,MAAM,EAAE;IACT,OAAOD,SAAS;EACpB;EACA,IAAI;IACA,MAAMkB,KAAK,GAAGR,IAAI,CAACS,KAAK,CAACX,MAAM,CAACC,IAAI,CAACR,MAAM,EAAE,QAAQ,CAAC,CAACW,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzE,IAAIV,KAAK,CAACC,OAAO,CAACe,KAAK,CAAC,EAAE;MACtB,OAAOA,KAAK,CAACd,MAAM,CAACC,IAAI,IAAIA,IAAI,KAAK,IAAI,CAAC,CAACC,GAAG,CAACc,kBAAkB,CAAC;IACtE;IACA,MAAMC,OAAO,GAAGD,kBAAkB,CAACF,KAAK,CAAC;IACzC,OAAOG,OAAO,GAAG,CAACA,OAAO,CAAC,GAAGrB,SAAS;EAC1C,CAAC,CAAC,OAAOa,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAACG,OAAO,CAAC;EAC7B;EACA,OAAOhB,SAAS;AACpB,CAAC","ignoreList":[]}
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"}
@@ -1,4 +1,9 @@
1
1
  export { createOpenSearchClient } from "../../client.js";
2
2
  export { OpenSearchClient } from "../../features/OpenSearchClient/abstraction.js";
3
- export { OpenSearchContext } from "../../features/OpenSearchContext/abstraction.js";
4
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";
@@ -1,6 +1,9 @@
1
1
  export { createOpenSearchClient } from "../../client.js";
2
2
  export { OpenSearchClient } from "../../features/OpenSearchClient/abstraction.js";
3
- export { OpenSearchContext } from "../../features/OpenSearchContext/abstraction.js";
4
3
  export { OpenSearchClientFactory } from "../../features/OpenSearchClientFactory/abstraction.js";
5
-
6
- //# sourceMappingURL=opensearch.js.map
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";
@@ -1,9 +1,9 @@
1
- import type { Client } from "../../client.js";
1
+ import type { Client as IClient } from "../../client.js";
2
2
  export interface IOpenSearchClient {
3
- use(): Client;
3
+ use(): IClient;
4
4
  }
5
5
  export declare const OpenSearchClient: import("@webiny/di").Abstraction<IOpenSearchClient>;
6
6
  export declare namespace OpenSearchClient {
7
7
  type Interface = IOpenSearchClient;
8
- type Return = Client;
8
+ type Client = IClient;
9
9
  }
@@ -1,4 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- export const OpenSearchClient = createAbstraction("OpenSearch/Client");
2
+ const OpenSearchClient = createAbstraction("OpenSearch/Client");
3
+ export { OpenSearchClient };
3
4
 
4
5
  //# sourceMappingURL=abstraction.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","OpenSearchClient"],"sources":["abstraction.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Client } from \"~/client.js\";\n\nexport interface IOpenSearchClient {\n use(): Client;\n}\n\nexport const OpenSearchClient = createAbstraction<IOpenSearchClient>(\"OpenSearch/Client\");\n\nexport namespace OpenSearchClient {\n export type Interface = IOpenSearchClient;\n export type Return = Client;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAOvD,OAAO,MAAMC,gBAAgB,GAAGD,iBAAiB,CAAoB,mBAAmB,CAAC","ignoreList":[]}
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"}
@@ -1,4 +1,5 @@
1
+ import type { Client } from "../../client.js";
1
2
  export declare const OpenSearchClientFeature: {
2
3
  name: string;
3
- register(container: import("@webiny/di").Container): void;
4
+ register(container: import("@webiny/di").Container, context: Client): void;
4
5
  };
@@ -1,10 +1,13 @@
1
1
  import { createFeature } from "@webiny/feature/api/index.js";
2
- import { OpenSearchClient } from "./OpenSearchClient.js";
3
- export const OpenSearchClientFeature = createFeature({
4
- name: "opensearch.internal.client",
5
- register(container) {
6
- container.register(OpenSearchClient);
7
- }
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
+ }
8
10
  });
11
+ export { OpenSearchClientFeature };
9
12
 
10
13
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","OpenSearchClient","OpenSearchClientFeature","name","register","container"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\n\nimport { OpenSearchClient } from \"./OpenSearchClient.js\";\n\nexport const OpenSearchClientFeature = createFeature({\n name: \"opensearch.internal.client\",\n register(container) {\n container.register(OpenSearchClient);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,8BAA8B;AAE5D,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,uBAAuB,GAAGF,aAAa,CAAC;EACjDG,IAAI,EAAE,4BAA4B;EAClCC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,gBAAgB,CAAC;EACxC;AACJ,CAAC,CAAC","ignoreList":[]}
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"}
@@ -1,16 +1,15 @@
1
- import { OpenSearchClientFactory as OpenSearchClientFactoryAbstraction } from "./abstraction.js";
1
+ import { OpenSearchClientFactory } from "./abstraction.js";
2
2
  import { createOpenSearchClient } from "../../client.js";
3
3
  class OpenSearchClientFactoryImpl {
4
- getClient(params) {
5
- if (!params.endpoint && !params.node && !params.nodes) {
6
- throw new Error("OpenSearch client requires an endpoint, nodes or node to be specified.");
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
7
  }
8
- return createOpenSearchClient(params);
9
- }
10
8
  }
11
- export const OpenSearchClientFactory = OpenSearchClientFactoryAbstraction.createImplementation({
12
- implementation: OpenSearchClientFactoryImpl,
13
- dependencies: []
9
+ const OpenSearchClientFactory_OpenSearchClientFactory = OpenSearchClientFactory.createImplementation({
10
+ implementation: OpenSearchClientFactoryImpl,
11
+ dependencies: []
14
12
  });
13
+ export { OpenSearchClientFactory_OpenSearchClientFactory as OpenSearchClientFactory };
15
14
 
16
15
  //# sourceMappingURL=OpenSearchClientFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["OpenSearchClientFactory","OpenSearchClientFactoryAbstraction","createOpenSearchClient","OpenSearchClientFactoryImpl","getClient","params","endpoint","node","nodes","Error","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AAAA,SAASA,uBAAuB,IAAIC,kCAAkC;AACtE,SAA+CC,sBAAsB;AAErE,MAAMC,2BAA2B,CAAyD;EAC/EC,SAASA,CAACC,MAA+B,EAAU;IACtD,IAAI,CAACA,MAAM,CAACC,QAAQ,IAAI,CAACD,MAAM,CAACE,IAAI,IAAI,CAACF,MAAM,CAACG,KAAK,EAAE;MACnD,MAAM,IAAIC,KAAK,CACX,wEACJ,CAAC;IACL;IACA,OAAOP,sBAAsB,CAACG,MAAM,CAAC;EACzC;AACJ;AAEA,OAAO,MAAML,uBAAuB,GAAGC,kCAAkC,CAACS,oBAAoB,CAAC;EAC3FC,cAAc,EAAER,2BAA2B;EAC3CS,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
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"}
@@ -1,4 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- export const OpenSearchClientFactory = createAbstraction("OpenSearch/ClientFactory");
2
+ const OpenSearchClientFactory = createAbstraction("OpenSearch/ClientFactory");
3
+ export { OpenSearchClientFactory };
3
4
 
4
5
  //# sourceMappingURL=abstraction.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","OpenSearchClientFactory"],"sources":["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"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAOvD,OAAO,MAAMC,uBAAuB,GAAGD,iBAAiB,CACpD,0BACJ,CAAC","ignoreList":[]}
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"}
@@ -1,10 +1,11 @@
1
1
  import { createFeature } from "@webiny/feature/api/index.js";
2
2
  import { OpenSearchClientFactory } from "./OpenSearchClientFactory.js";
3
- export const OpenSearchClientFactoryFeature = createFeature({
4
- name: "opensearch.internal.clientFactory",
5
- register(container) {
6
- container.register(OpenSearchClientFactory).inSingletonScope();
7
- }
3
+ const OpenSearchClientFactoryFeature = createFeature({
4
+ name: "opensearch.internal.clientFactory",
5
+ register (container) {
6
+ container.register(OpenSearchClientFactory).inSingletonScope();
7
+ }
8
8
  });
9
+ export { OpenSearchClientFactoryFeature };
9
10
 
10
11
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","OpenSearchClientFactory","OpenSearchClientFactoryFeature","name","register","container","inSingletonScope"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,8BAA8B;AAC5D,SAASC,uBAAuB;AAEhC,OAAO,MAAMC,8BAA8B,GAAGF,aAAa,CAAC;EACxDG,IAAI,EAAE,mCAAmC;EACzCC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,uBAAuB,CAAC,CAACK,gBAAgB,CAAC,CAAC;EAClE;AACJ,CAAC,CAAC","ignoreList":[]}
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 {};