@webiny/api-opensearch 6.1.0-beta.0

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 (213) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/client.d.ts +8 -0
  4. package/client.js +70 -0
  5. package/client.js.map +1 -0
  6. package/compression.d.ts +6 -0
  7. package/compression.js +25 -0
  8. package/compression.js.map +1 -0
  9. package/cursors.d.ts +10 -0
  10. package/cursors.js +37 -0
  11. package/cursors.js.map +1 -0
  12. package/db/entity.d.ts +7 -0
  13. package/db/entity.js +20 -0
  14. package/db/entity.js.map +1 -0
  15. package/db/index.d.ts +3 -0
  16. package/db/index.js +5 -0
  17. package/db/index.js.map +1 -0
  18. package/db/table.d.ts +7 -0
  19. package/db/table.js +17 -0
  20. package/db/table.js.map +1 -0
  21. package/db/types.d.ts +6 -0
  22. package/db/types.js +3 -0
  23. package/db/types.js.map +1 -0
  24. package/exports/api/opensearch.d.ts +4 -0
  25. package/exports/api/opensearch.js +6 -0
  26. package/exports/api/opensearch.js.map +1 -0
  27. package/features/OpenSearchClient/OpenSearchClient.d.ts +12 -0
  28. package/features/OpenSearchClient/OpenSearchClient.js +16 -0
  29. package/features/OpenSearchClient/OpenSearchClient.js.map +1 -0
  30. package/features/OpenSearchClient/abstraction.d.ts +9 -0
  31. package/features/OpenSearchClient/abstraction.js +4 -0
  32. package/features/OpenSearchClient/abstraction.js.map +1 -0
  33. package/features/OpenSearchClient/feature.d.ts +1 -0
  34. package/features/OpenSearchClient/feature.js +10 -0
  35. package/features/OpenSearchClient/feature.js.map +1 -0
  36. package/features/OpenSearchClientFactory/OpenSearchClientFactory.d.ts +9 -0
  37. package/features/OpenSearchClientFactory/OpenSearchClientFactory.js +16 -0
  38. package/features/OpenSearchClientFactory/OpenSearchClientFactory.js.map +1 -0
  39. package/features/OpenSearchClientFactory/abstraction.d.ts +10 -0
  40. package/features/OpenSearchClientFactory/abstraction.js +4 -0
  41. package/features/OpenSearchClientFactory/abstraction.js.map +1 -0
  42. package/features/OpenSearchClientFactory/feature.d.ts +1 -0
  43. package/features/OpenSearchClientFactory/feature.js +10 -0
  44. package/features/OpenSearchClientFactory/feature.js.map +1 -0
  45. package/features/OpenSearchContext/OpenSearchContext.d.ts +8 -0
  46. package/features/OpenSearchContext/OpenSearchContext.js +13 -0
  47. package/features/OpenSearchContext/OpenSearchContext.js.map +1 -0
  48. package/features/OpenSearchContext/abstraction.d.ts +14 -0
  49. package/features/OpenSearchContext/abstraction.js +4 -0
  50. package/features/OpenSearchContext/abstraction.js.map +1 -0
  51. package/features/OpenSearchContext/feature.d.ts +2 -0
  52. package/features/OpenSearchContext/feature.js +13 -0
  53. package/features/OpenSearchContext/feature.js.map +1 -0
  54. package/index.d.ts +22 -0
  55. package/index.js +41 -0
  56. package/index.js.map +1 -0
  57. package/indexConfiguration/base.d.ts +6 -0
  58. package/indexConfiguration/base.js +35 -0
  59. package/indexConfiguration/base.js.map +1 -0
  60. package/indexConfiguration/common.d.ts +9 -0
  61. package/indexConfiguration/common.js +47 -0
  62. package/indexConfiguration/common.js.map +1 -0
  63. package/indexConfiguration/index.d.ts +2 -0
  64. package/indexConfiguration/index.js +4 -0
  65. package/indexConfiguration/index.js.map +1 -0
  66. package/indexPrefix.d.ts +1 -0
  67. package/indexPrefix.js +5 -0
  68. package/indexPrefix.js.map +1 -0
  69. package/indices.d.ts +8 -0
  70. package/indices.js +20 -0
  71. package/indices.js.map +1 -0
  72. package/limit.d.ts +1 -0
  73. package/limit.js +32 -0
  74. package/limit.js.map +1 -0
  75. package/normalize.d.ts +6 -0
  76. package/normalize.js +54 -0
  77. package/normalize.js.map +1 -0
  78. package/operations/OpenSearchCatHealth.d.ts +7 -0
  79. package/operations/OpenSearchCatHealth.js +31 -0
  80. package/operations/OpenSearchCatHealth.js.map +1 -0
  81. package/operations/OpenSearchCatNodes.d.ts +7 -0
  82. package/operations/OpenSearchCatNodes.js +29 -0
  83. package/operations/OpenSearchCatNodes.js.map +1 -0
  84. package/operations/index.d.ts +3 -0
  85. package/operations/index.js +5 -0
  86. package/operations/index.js.map +1 -0
  87. package/operations/stripConnectionFromException.d.ts +1 -0
  88. package/operations/stripConnectionFromException.js +17 -0
  89. package/operations/stripConnectionFromException.js.map +1 -0
  90. package/operations/types.d.ts +35 -0
  91. package/operations/types.js +8 -0
  92. package/operations/types.js.map +1 -0
  93. package/operators.d.ts +6 -0
  94. package/operators.js +9 -0
  95. package/operators.js.map +1 -0
  96. package/package.json +36 -0
  97. package/plugins/definition/OpenSearchBodyModifierPlugin.d.ts +13 -0
  98. package/plugins/definition/OpenSearchBodyModifierPlugin.js +18 -0
  99. package/plugins/definition/OpenSearchBodyModifierPlugin.js.map +1 -0
  100. package/plugins/definition/OpenSearchFieldPlugin.d.ts +81 -0
  101. package/plugins/definition/OpenSearchFieldPlugin.js +68 -0
  102. package/plugins/definition/OpenSearchFieldPlugin.js.map +1 -0
  103. package/plugins/definition/OpenSearchIndexPlugin.d.ts +10 -0
  104. package/plugins/definition/OpenSearchIndexPlugin.js +17 -0
  105. package/plugins/definition/OpenSearchIndexPlugin.js.map +1 -0
  106. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.d.ts +10 -0
  107. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js +9 -0
  108. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js.map +1 -0
  109. package/plugins/definition/OpenSearchQueryModifierPlugin.d.ts +14 -0
  110. package/plugins/definition/OpenSearchQueryModifierPlugin.js +18 -0
  111. package/plugins/definition/OpenSearchQueryModifierPlugin.js.map +1 -0
  112. package/plugins/definition/OpenSearchSortModifierPlugin.d.ts +13 -0
  113. package/plugins/definition/OpenSearchSortModifierPlugin.js +18 -0
  114. package/plugins/definition/OpenSearchSortModifierPlugin.js.map +1 -0
  115. package/plugins/definition/index.d.ts +6 -0
  116. package/plugins/definition/index.js +8 -0
  117. package/plugins/definition/index.js.map +1 -0
  118. package/plugins/index.d.ts +2 -0
  119. package/plugins/index.js +4 -0
  120. package/plugins/index.js.map +1 -0
  121. package/plugins/operator/andIn.d.ts +7 -0
  122. package/plugins/operator/andIn.js +35 -0
  123. package/plugins/operator/andIn.js.map +1 -0
  124. package/plugins/operator/between.d.ts +7 -0
  125. package/plugins/operator/between.js +32 -0
  126. package/plugins/operator/between.js.map +1 -0
  127. package/plugins/operator/contains.d.ts +7 -0
  128. package/plugins/operator/contains.js +24 -0
  129. package/plugins/operator/contains.js.map +1 -0
  130. package/plugins/operator/equal.d.ts +7 -0
  131. package/plugins/operator/equal.js +50 -0
  132. package/plugins/operator/equal.js.map +1 -0
  133. package/plugins/operator/gt.d.ts +7 -0
  134. package/plugins/operator/gt.js +22 -0
  135. package/plugins/operator/gt.js.map +1 -0
  136. package/plugins/operator/gte.d.ts +7 -0
  137. package/plugins/operator/gte.js +22 -0
  138. package/plugins/operator/gte.js.map +1 -0
  139. package/plugins/operator/in.d.ts +7 -0
  140. package/plugins/operator/in.js +29 -0
  141. package/plugins/operator/in.js.map +1 -0
  142. package/plugins/operator/index.d.ts +15 -0
  143. package/plugins/operator/index.js +17 -0
  144. package/plugins/operator/index.js.map +1 -0
  145. package/plugins/operator/lt.d.ts +7 -0
  146. package/plugins/operator/lt.js +22 -0
  147. package/plugins/operator/lt.js.map +1 -0
  148. package/plugins/operator/lte.d.ts +7 -0
  149. package/plugins/operator/lte.js +22 -0
  150. package/plugins/operator/lte.js.map +1 -0
  151. package/plugins/operator/not.d.ts +7 -0
  152. package/plugins/operator/not.js +44 -0
  153. package/plugins/operator/not.js.map +1 -0
  154. package/plugins/operator/notBetween.d.ts +7 -0
  155. package/plugins/operator/notBetween.js +32 -0
  156. package/plugins/operator/notBetween.js.map +1 -0
  157. package/plugins/operator/notContains.d.ts +7 -0
  158. package/plugins/operator/notContains.js +24 -0
  159. package/plugins/operator/notContains.js.map +1 -0
  160. package/plugins/operator/notIn.d.ts +7 -0
  161. package/plugins/operator/notIn.js +27 -0
  162. package/plugins/operator/notIn.js.map +1 -0
  163. package/plugins/operator/notStartsWith.d.ts +7 -0
  164. package/plugins/operator/notStartsWith.js +23 -0
  165. package/plugins/operator/notStartsWith.js.map +1 -0
  166. package/plugins/operator/startsWith.d.ts +7 -0
  167. package/plugins/operator/startsWith.js +23 -0
  168. package/plugins/operator/startsWith.js.map +1 -0
  169. package/sharedIndex.d.ts +1 -0
  170. package/sharedIndex.js +5 -0
  171. package/sharedIndex.js.map +1 -0
  172. package/sort.d.ts +13 -0
  173. package/sort.js +64 -0
  174. package/sort.js.map +1 -0
  175. package/types.d.ts +179 -0
  176. package/types.js +3 -0
  177. package/types.js.map +1 -0
  178. package/utils/createIndex.d.ts +19 -0
  179. package/utils/createIndex.js +88 -0
  180. package/utils/createIndex.js.map +1 -0
  181. package/utils/index.d.ts +2 -0
  182. package/utils/index.js +4 -0
  183. package/utils/index.js.map +1 -0
  184. package/utils/waitUntilHealthy/UnhealthyClusterError.d.ts +4 -0
  185. package/utils/waitUntilHealthy/UnhealthyClusterError.js +11 -0
  186. package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -0
  187. package/utils/waitUntilHealthy/WaitUntilHealthy.d.ts +71 -0
  188. package/utils/waitUntilHealthy/WaitUntilHealthy.js +150 -0
  189. package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -0
  190. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.d.ts +4 -0
  191. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +11 -0
  192. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -0
  193. package/utils/waitUntilHealthy/index.d.ts +4 -0
  194. package/utils/waitUntilHealthy/index.js +6 -0
  195. package/utils/waitUntilHealthy/index.js.map +1 -0
  196. package/utils/waitUntilHealthy/reason/ClusterHealthReason.d.ts +15 -0
  197. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +13 -0
  198. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -0
  199. package/utils/waitUntilHealthy/reason/IReason.d.ts +4 -0
  200. package/utils/waitUntilHealthy/reason/IReason.js +3 -0
  201. package/utils/waitUntilHealthy/reason/IReason.js.map +1 -0
  202. package/utils/waitUntilHealthy/reason/MemoryReason.d.ts +14 -0
  203. package/utils/waitUntilHealthy/reason/MemoryReason.js +13 -0
  204. package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -0
  205. package/utils/waitUntilHealthy/reason/ProcessorReason.d.ts +14 -0
  206. package/utils/waitUntilHealthy/reason/ProcessorReason.js +13 -0
  207. package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -0
  208. package/utils/waitUntilHealthy/reason/index.d.ts +3 -0
  209. package/utils/waitUntilHealthy/reason/index.js +5 -0
  210. package/utils/waitUntilHealthy/reason/index.js.map +1 -0
  211. package/where.d.ts +17 -0
  212. package/where.js +82 -0
  213. 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,70 @@
1
+ import crypto from "crypto";
2
+ import WebinyError from "@webiny/error";
3
+ import { Client } from "@opensearch-project/opensearch";
4
+ import { AwsSigv4Signer } from "@opensearch-project/opensearch/aws";
5
+ export { Client };
6
+ const clients = new Map();
7
+ const createClientKey = options => {
8
+ const key = JSON.stringify(options);
9
+ const hash = crypto.createHash("sha1");
10
+ hash.update(key);
11
+ return hash.digest("hex");
12
+ };
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
64
+ };
65
+ console.error(data);
66
+ throw new WebinyError("Could not connect to OpenSearch.", "OPENSEARCH_CLIENT_ERROR", data);
67
+ }
68
+ };
69
+
70
+ //# sourceMappingURL=client.js.map
package/client.js.map ADDED
@@ -0,0 +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(\"sha1\");\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,MAAM,CAAC;EACtCD,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":[]}
@@ -0,0 +1,6 @@
1
+ import type { PluginsContainer } from "@webiny/plugins";
2
+ /**
3
+ * Method to compress the opensearch data that is going to be stored into the DynamoDB table that is meant for opensearch.
4
+ */
5
+ export declare const compress: (pluginsContainer: PluginsContainer, data: Record<string, any>) => Promise<Record<string, any>>;
6
+ export declare const decompress: (pluginsContainer: PluginsContainer, data: Record<string, any>) => Promise<Record<string, any>>;
package/compression.js ADDED
@@ -0,0 +1,25 @@
1
+ import { CompressorPlugin } from "@webiny/api";
2
+
3
+ /**
4
+ * Method to compress the opensearch data that is going to be stored into the DynamoDB table that is meant for opensearch.
5
+ */
6
+ export const compress = async (pluginsContainer, data) => {
7
+ let plugin;
8
+ try {
9
+ plugin = pluginsContainer.oneByType(CompressorPlugin.type);
10
+ } catch {
11
+ return data;
12
+ }
13
+ return plugin.getCompressor().compress(data);
14
+ };
15
+ export const decompress = async (pluginsContainer, data) => {
16
+ let plugin;
17
+ try {
18
+ plugin = pluginsContainer.oneByType(CompressorPlugin.type);
19
+ } catch {
20
+ return data;
21
+ }
22
+ return plugin.getCompressor().decompress(data);
23
+ };
24
+
25
+ //# sourceMappingURL=compression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CompressorPlugin","compress","pluginsContainer","data","plugin","oneByType","type","getCompressor","decompress"],"sources":["compression.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport { CompressorPlugin } from \"@webiny/api\";\n\n/**\n * Method to compress the opensearch data that is going to be stored into the DynamoDB table that is meant for opensearch.\n */\nexport const compress = async (\n pluginsContainer: PluginsContainer,\n data: Record<string, any>\n): Promise<Record<string, any>> => {\n let plugin: CompressorPlugin;\n try {\n plugin = pluginsContainer.oneByType<CompressorPlugin>(CompressorPlugin.type);\n } catch {\n return data;\n }\n return plugin.getCompressor().compress(data);\n};\n\nexport const decompress = async (\n pluginsContainer: PluginsContainer,\n data: Record<string, any>\n): Promise<Record<string, any>> => {\n let plugin: CompressorPlugin;\n try {\n plugin = pluginsContainer.oneByType<CompressorPlugin>(CompressorPlugin.type);\n } catch {\n return data;\n }\n return plugin.getCompressor().decompress(data);\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,aAAa;;AAE9C;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG,MAAAA,CACpBC,gBAAkC,EAClCC,IAAyB,KACM;EAC/B,IAAIC,MAAwB;EAC5B,IAAI;IACAA,MAAM,GAAGF,gBAAgB,CAACG,SAAS,CAAmBL,gBAAgB,CAACM,IAAI,CAAC;EAChF,CAAC,CAAC,MAAM;IACJ,OAAOH,IAAI;EACf;EACA,OAAOC,MAAM,CAACG,aAAa,CAAC,CAAC,CAACN,QAAQ,CAACE,IAAI,CAAC;AAChD,CAAC;AAED,OAAO,MAAMK,UAAU,GAAG,MAAAA,CACtBN,gBAAkC,EAClCC,IAAyB,KACM;EAC/B,IAAIC,MAAwB;EAC5B,IAAI;IACAA,MAAM,GAAGF,gBAAgB,CAACG,SAAS,CAAmBL,gBAAgB,CAACM,IAAI,CAAC;EAChF,CAAC,CAAC,MAAM;IACJ,OAAOH,IAAI;EACf;EACA,OAAOC,MAAM,CAACG,aAAa,CAAC,CAAC,CAACC,UAAU,CAACL,IAAI,CAAC;AAClD,CAAC","ignoreList":[]}
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,37 @@
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;
15
+ };
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);
28
+ }
29
+ const decoded = decodeURIComponent(value);
30
+ return decoded ? [decoded] : undefined;
31
+ } catch (ex) {
32
+ console.error(ex.message);
33
+ }
34
+ return undefined;
35
+ };
36
+
37
+ //# sourceMappingURL=cursors.js.map
package/cursors.js.map ADDED
@@ -0,0 +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,KAAK,IAAI,CAAC,CAClFC,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":[]}
package/db/entity.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { type ITable } from "@webiny/db-dynamodb";
2
+ import type { IOpenSearchEntity } from "../db/types.js";
3
+ export interface ICreateOpenSearchEntityParams {
4
+ table: ITable;
5
+ entityName: string;
6
+ }
7
+ export declare const createOpenSearchEntity: (params: ICreateOpenSearchEntityParams) => IOpenSearchEntity;
package/db/entity.js ADDED
@@ -0,0 +1,20 @@
1
+ import { createEntity, standardEntityAttributes } from "@webiny/db-dynamodb";
2
+ export const createOpenSearchEntity = params => {
3
+ const {
4
+ table,
5
+ entityName
6
+ } = params;
7
+ return createEntity({
8
+ name: entityName,
9
+ table: table.table,
10
+ attributes: {
11
+ ...standardEntityAttributes,
12
+ index: {
13
+ type: "string",
14
+ required: true
15
+ }
16
+ }
17
+ });
18
+ };
19
+
20
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createEntity","standardEntityAttributes","createOpenSearchEntity","params","table","entityName","name","attributes","index","type","required"],"sources":["entity.ts"],"sourcesContent":["import { createEntity, type ITable, standardEntityAttributes } from \"@webiny/db-dynamodb\";\nimport type { IOpenSearchEntity, IOpenSearchEntityAttributes } from \"~/db/types.js\";\n\nexport interface ICreateOpenSearchEntityParams {\n table: ITable;\n entityName: string;\n}\n\nexport const createOpenSearchEntity = (\n params: ICreateOpenSearchEntityParams\n): IOpenSearchEntity => {\n const { table, entityName } = params;\n return createEntity<IOpenSearchEntityAttributes>({\n name: entityName,\n table: table.table,\n attributes: {\n ...standardEntityAttributes,\n index: {\n type: \"string\",\n required: true\n }\n }\n });\n};\n"],"mappings":"AAAA,SAASA,YAAY,EAAeC,wBAAwB,QAAQ,qBAAqB;AAQzF,OAAO,MAAMC,sBAAsB,GAC/BC,MAAqC,IACjB;EACpB,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,MAAM;EACpC,OAAOH,YAAY,CAA8B;IAC7CM,IAAI,EAAED,UAAU;IAChBD,KAAK,EAAEA,KAAK,CAACA,KAAK;IAClBG,UAAU,EAAE;MACR,GAAGN,wBAAwB;MAC3BO,KAAK,EAAE;QACHC,IAAI,EAAE,QAAQ;QACdC,QAAQ,EAAE;MACd;IACJ;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
package/db/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./table.js";
2
+ export * from "./entity.js";
3
+ export * from "./types.js";
package/db/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./table.js";
2
+ export * from "./entity.js";
3
+ export * from "./types.js";
4
+
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./table.js\";\nexport * from \"./entity.js\";\nexport * from \"./types.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
package/db/table.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
+ import { type ITable } from "@webiny/db-dynamodb";
3
+ export interface ICreateOpenSearchTableParams {
4
+ name?: string;
5
+ documentClient: DynamoDBDocument;
6
+ }
7
+ export declare const createOpenSearchTable: ({ name, documentClient }: ICreateOpenSearchTableParams) => ITable;
package/db/table.js ADDED
@@ -0,0 +1,17 @@
1
+ import { createTable } from "@webiny/db-dynamodb";
2
+ export const createOpenSearchTable = ({
3
+ name,
4
+ documentClient
5
+ }) => {
6
+ return createTable({
7
+ name: name || process.env.DB_TABLE_OPENSEARCH,
8
+ indexes: {
9
+ GSI_TENANT: {
10
+ partitionKey: "GSI_TENANT"
11
+ }
12
+ },
13
+ documentClient
14
+ });
15
+ };
16
+
17
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createTable","createOpenSearchTable","name","documentClient","process","env","DB_TABLE_OPENSEARCH","indexes","GSI_TENANT","partitionKey"],"sources":["table.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createTable, type ITable } from \"@webiny/db-dynamodb\";\n\nexport interface ICreateOpenSearchTableParams {\n name?: string;\n documentClient: DynamoDBDocument;\n}\n\nexport const createOpenSearchTable = ({\n name,\n documentClient\n}: ICreateOpenSearchTableParams): ITable => {\n return createTable({\n name: name || (process.env.DB_TABLE_OPENSEARCH as string),\n indexes: {\n GSI_TENANT: {\n partitionKey: \"GSI_TENANT\"\n }\n },\n documentClient\n });\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAqB,qBAAqB;AAO9D,OAAO,MAAMC,qBAAqB,GAAGA,CAAC;EAClCC,IAAI;EACJC;AAC0B,CAAC,KAAa;EACxC,OAAOH,WAAW,CAAC;IACfE,IAAI,EAAEA,IAAI,IAAKE,OAAO,CAACC,GAAG,CAACC,mBAA8B;IACzDC,OAAO,EAAE;MACLC,UAAU,EAAE;QACRC,YAAY,EAAE;MAClB;IACJ,CAAC;IACDN;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
package/db/types.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { IEntity, IStandardEntityAttributes } from "@webiny/db-dynamodb";
2
+ import type { GenericRecord } from "@webiny/api/types.js";
3
+ export interface IOpenSearchEntityAttributes extends IStandardEntityAttributes<GenericRecord> {
4
+ index: string;
5
+ }
6
+ export type IOpenSearchEntity = IEntity<IOpenSearchEntityAttributes>;
package/db/types.js ADDED
@@ -0,0 +1,3 @@
1
+ export {};
2
+
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IEntity, IStandardEntityAttributes } from \"@webiny/db-dynamodb\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport interface IOpenSearchEntityAttributes extends IStandardEntityAttributes<GenericRecord> {\n index: string;\n}\n\nexport type IOpenSearchEntity = IEntity<IOpenSearchEntityAttributes>;\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export { createOpenSearchClient } from "../../client.js";
2
+ export { OpenSearchClient } from "../../features/OpenSearchClient/abstraction.js";
3
+ export { OpenSearchContext } from "../../features/OpenSearchContext/abstraction.js";
4
+ export { OpenSearchClientFactory } from "../../features/OpenSearchClientFactory/abstraction.js";
@@ -0,0 +1,6 @@
1
+ export { createOpenSearchClient } from "../../client.js";
2
+ export { OpenSearchClient } from "../../features/OpenSearchClient/abstraction.js";
3
+ export { OpenSearchContext } from "../../features/OpenSearchContext/abstraction.js";
4
+ export { OpenSearchClientFactory } from "../../features/OpenSearchClientFactory/abstraction.js";
5
+
6
+ //# sourceMappingURL=opensearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createOpenSearchClient","OpenSearchClient","OpenSearchContext","OpenSearchClientFactory"],"sources":["opensearch.ts"],"sourcesContent":["export { createOpenSearchClient } from \"~/client.js\";\nexport { OpenSearchClient } from \"~/features/OpenSearchClient/abstraction.js\";\nexport { OpenSearchContext } from \"~/features/OpenSearchContext/abstraction.js\";\nexport { OpenSearchClientFactory } from \"~/features/OpenSearchClientFactory/abstraction.js\";\n"],"mappings":"AAAA,SAASA,sBAAsB;AAC/B,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,uBAAuB","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ import { OpenSearchClient as OpenSearchClientAbstraction } from "./abstraction.js";
2
+ import type { Client } from "../../types.js";
3
+ import { OpenSearchContext } from "../../features/OpenSearchContext/abstraction.js";
4
+ declare class OpenSearchClientImpl implements OpenSearchClientAbstraction.Interface {
5
+ private readonly context;
6
+ constructor(context: OpenSearchContext.Interface);
7
+ use(): Client;
8
+ }
9
+ export declare const OpenSearchClient: typeof OpenSearchClientImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("./abstraction.js").IOpenSearchClient>;
11
+ };
12
+ export {};
@@ -0,0 +1,16 @@
1
+ import { OpenSearchClient as OpenSearchClientAbstraction } from "./abstraction.js";
2
+ import { OpenSearchContext } from "../OpenSearchContext/abstraction.js";
3
+ class OpenSearchClientImpl {
4
+ constructor(context) {
5
+ this.context = context;
6
+ }
7
+ use() {
8
+ return this.context.opensearch;
9
+ }
10
+ }
11
+ export const OpenSearchClient = OpenSearchClientAbstraction.createImplementation({
12
+ implementation: OpenSearchClientImpl,
13
+ dependencies: [OpenSearchContext]
14
+ });
15
+
16
+ //# sourceMappingURL=OpenSearchClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["OpenSearchClient","OpenSearchClientAbstraction","OpenSearchContext","OpenSearchClientImpl","constructor","context","use","opensearch","createImplementation","implementation","dependencies"],"sources":["OpenSearchClient.ts"],"sourcesContent":["import { OpenSearchClient as OpenSearchClientAbstraction } from \"./abstraction.js\";\nimport type { Client } from \"~/types.js\";\nimport { OpenSearchContext } from \"~/features/OpenSearchContext/abstraction.js\";\n\nclass OpenSearchClientImpl implements OpenSearchClientAbstraction.Interface {\n public constructor(private readonly context: OpenSearchContext.Interface) {}\n\n public use(): Client {\n return this.context.opensearch;\n }\n}\n\nexport const OpenSearchClient = OpenSearchClientAbstraction.createImplementation({\n implementation: OpenSearchClientImpl,\n dependencies: [OpenSearchContext]\n});\n"],"mappings":"AAAA,SAASA,gBAAgB,IAAIC,2BAA2B;AAExD,SAASC,iBAAiB;AAE1B,MAAMC,oBAAoB,CAAkD;EACjEC,WAAWA,CAAkBC,OAAoC,EAAE;IAAA,KAAtCA,OAAoC,GAApCA,OAAoC;EAAG;EAEpEC,GAAGA,CAAA,EAAW;IACjB,OAAO,IAAI,CAACD,OAAO,CAACE,UAAU;EAClC;AACJ;AAEA,OAAO,MAAMP,gBAAgB,GAAGC,2BAA2B,CAACO,oBAAoB,CAAC;EAC7EC,cAAc,EAAEN,oBAAoB;EACpCO,YAAY,EAAE,CAACR,iBAAiB;AACpC,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import type { Client } from "../../client.js";
2
+ export interface IOpenSearchClient {
3
+ use(): Client;
4
+ }
5
+ export declare const OpenSearchClient: import("@webiny/di").Abstraction<IOpenSearchClient>;
6
+ export declare namespace OpenSearchClient {
7
+ type Interface = IOpenSearchClient;
8
+ type Return = Client;
9
+ }
@@ -0,0 +1,4 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ export const OpenSearchClient = createAbstraction("OpenSearch/Client");
3
+
4
+ //# sourceMappingURL=abstraction.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1 @@
1
+ export declare const OpenSearchClientFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
@@ -0,0 +1,10 @@
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
+ }
8
+ });
9
+
10
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +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":[]}
@@ -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,16 @@
1
+ import { OpenSearchClientFactory as OpenSearchClientFactoryAbstraction } from "./abstraction.js";
2
+ import { createOpenSearchClient } from "../../client.js";
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.");
7
+ }
8
+ return createOpenSearchClient(params);
9
+ }
10
+ }
11
+ export const OpenSearchClientFactory = OpenSearchClientFactoryAbstraction.createImplementation({
12
+ implementation: OpenSearchClientFactoryImpl,
13
+ dependencies: []
14
+ });
15
+
16
+ //# sourceMappingURL=OpenSearchClientFactory.js.map
@@ -0,0 +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":[]}
@@ -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,4 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ export const OpenSearchClientFactory = createAbstraction("OpenSearch/ClientFactory");
3
+
4
+ //# sourceMappingURL=abstraction.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1 @@
1
+ export declare const OpenSearchClientFactoryFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
@@ -0,0 +1,10 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
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
+ }
8
+ });
9
+
10
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,8 @@
1
+ import { OpenSearchContext as OpenSearchContextAbstraction } from "./abstraction.js";
2
+ import { OpenSearchContext as OpenSearchContextType } from "../../types.js";
3
+ export declare class OpenSearchContext implements OpenSearchContextAbstraction.Interface {
4
+ private readonly context;
5
+ constructor(context: OpenSearchContextType);
6
+ get opensearch(): OpenSearchContextAbstraction.Client;
7
+ get elasticsearch(): OpenSearchContextAbstraction.Client;
8
+ }
@@ -0,0 +1,13 @@
1
+ export class OpenSearchContext {
2
+ constructor(context) {
3
+ this.context = context;
4
+ }
5
+ get opensearch() {
6
+ return this.context.opensearch;
7
+ }
8
+ get elasticsearch() {
9
+ return this.context.opensearch;
10
+ }
11
+ }
12
+
13
+ //# sourceMappingURL=OpenSearchContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["OpenSearchContext","constructor","context","opensearch","elasticsearch"],"sources":["OpenSearchContext.ts"],"sourcesContent":["import { OpenSearchContext as OpenSearchContextAbstraction } from \"./abstraction.js\";\nimport { OpenSearchContext as OpenSearchContextType } from \"~/types.js\";\n\nexport class OpenSearchContext implements OpenSearchContextAbstraction.Interface {\n private readonly context;\n\n public constructor(context: OpenSearchContextType) {\n this.context = context;\n }\n\n public get opensearch(): OpenSearchContextAbstraction.Client {\n return this.context.opensearch;\n }\n\n public get elasticsearch(): OpenSearchContextAbstraction.Client {\n return this.context.opensearch;\n }\n}\n"],"mappings":"AAGA,OAAO,MAAMA,iBAAiB,CAAmD;EAGtEC,WAAWA,CAACC,OAA8B,EAAE;IAC/C,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EAEA,IAAWC,UAAUA,CAAA,EAAwC;IACzD,OAAO,IAAI,CAACD,OAAO,CAACC,UAAU;EAClC;EAEA,IAAWC,aAAaA,CAAA,EAAwC;IAC5D,OAAO,IAAI,CAACF,OAAO,CAACC,UAAU;EAClC;AACJ","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ import type { Client as OpenSearchClient } from "../../types.js";
2
+ export interface IOpenSearchContext {
3
+ opensearch: OpenSearchClient;
4
+ /**
5
+ * @deprecated use `opensearch`property instead.
6
+ * @see IOpenSearchContext.opensearch
7
+ */
8
+ elasticsearch: OpenSearchClient;
9
+ }
10
+ export declare const OpenSearchContext: import("@webiny/di").Abstraction<IOpenSearchContext>;
11
+ export declare namespace OpenSearchContext {
12
+ type Interface = IOpenSearchContext;
13
+ type Client = OpenSearchClient;
14
+ }
@@ -0,0 +1,4 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ export const OpenSearchContext = createAbstraction("OpenSearch/Context");
3
+
4
+ //# sourceMappingURL=abstraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createAbstraction","OpenSearchContext"],"sources":["abstraction.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Client as OpenSearchClient } from \"~/types.js\";\n\nexport interface IOpenSearchContext {\n opensearch: OpenSearchClient;\n /**\n * @deprecated use `opensearch`property instead.\n * @see IOpenSearchContext.opensearch\n */\n elasticsearch: OpenSearchClient;\n}\n\nexport const OpenSearchContext = createAbstraction<IOpenSearchContext>(\"OpenSearch/Context\");\n\nexport namespace OpenSearchContext {\n export type Interface = IOpenSearchContext;\n export type Client = OpenSearchClient;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAYvD,OAAO,MAAMC,iBAAiB,GAAGD,iBAAiB,CAAqB,oBAAoB,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import { OpenSearchContext as OpenSearchContextType } from "../../types.js";
2
+ export declare const OpenSearchContextFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<OpenSearchContextType>;
@@ -0,0 +1,13 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { OpenSearchContext } from "./abstraction.js";
3
+ import { OpenSearchContext as OpenSearchContextImplementation } from "./OpenSearchContext.js";
4
+ export const OpenSearchContextFeature = createFeature({
5
+ name: "opensearch.internal.context",
6
+ register(container, context) {
7
+ container.registerFactory(OpenSearchContext, () => {
8
+ return new OpenSearchContextImplementation(context);
9
+ });
10
+ }
11
+ });
12
+
13
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFeature","OpenSearchContext","OpenSearchContextImplementation","OpenSearchContextFeature","name","register","container","context","registerFactory"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { OpenSearchContext } from \"./abstraction.js\";\nimport { OpenSearchContext as OpenSearchContextType } from \"~/types.js\";\nimport { OpenSearchContext as OpenSearchContextImplementation } from \"./OpenSearchContext.js\";\n\nexport const OpenSearchContextFeature = createFeature<OpenSearchContextType>({\n name: \"opensearch.internal.context\",\n register(container, context) {\n container.registerFactory(OpenSearchContext, () => {\n return new OpenSearchContextImplementation(context!);\n });\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,8BAA8B;AAC5D,SAASC,iBAAiB;AAE1B,SAASA,iBAAiB,IAAIC,+BAA+B;AAE7D,OAAO,MAAMC,wBAAwB,GAAGH,aAAa,CAAwB;EACzEI,IAAI,EAAE,6BAA6B;EACnCC,QAAQA,CAACC,SAAS,EAAEC,OAAO,EAAE;IACzBD,SAAS,CAACE,eAAe,CAACP,iBAAiB,EAAE,MAAM;MAC/C,OAAO,IAAIC,+BAA+B,CAACK,OAAQ,CAAC;IACxD,CAAC,CAAC;EACN;AACJ,CAAC,CAAC","ignoreList":[]}
package/index.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import type { OpenSearchContext } from "./types.js";
2
+ import { ContextPlugin } from "@webiny/api";
3
+ import type { OpenSearchClientOptions } from "./client.js";
4
+ import { Client } from "./client.js";
5
+ export * from "./indexConfiguration/index.js";
6
+ export * from "./plugins/index.js";
7
+ export * from "./sort.js";
8
+ export * from "./indices.js";
9
+ export * from "./where.js";
10
+ export * from "./limit.js";
11
+ export * from "./normalize.js";
12
+ export * from "./compression.js";
13
+ export * from "./operators.js";
14
+ export * from "./cursors.js";
15
+ export { createOpenSearchClient, type Client, type ClientOptions, type OpenSearchClientOptions } from "./client.js";
16
+ export * from "./utils/index.js";
17
+ export * from "./operations/index.js";
18
+ export * from "./sharedIndex.js";
19
+ export * from "./indexPrefix.js";
20
+ export * from "./db/index.js";
21
+ export * from "./types.js";
22
+ export declare const createOpenSearchContext: (params: OpenSearchClientOptions | Client) => ContextPlugin<OpenSearchContext>;