@webiny/api-elasticsearch 6.0.0-alpha.5 → 6.0.0-rc.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 (174) hide show
  1. package/README.md +10 -0
  2. package/client.d.ts +2 -2
  3. package/client.js +11 -30
  4. package/client.js.map +1 -1
  5. package/compression.js +7 -14
  6. package/compression.js.map +1 -1
  7. package/cursors.d.ts +1 -1
  8. package/cursors.js +2 -10
  9. package/cursors.js.map +1 -1
  10. package/db/entity.d.ts +7 -0
  11. package/db/entity.js +20 -0
  12. package/db/entity.js.map +1 -0
  13. package/db/index.d.ts +3 -0
  14. package/db/index.js +5 -0
  15. package/db/index.js.map +1 -0
  16. package/db/table.d.ts +7 -0
  17. package/db/table.js +17 -0
  18. package/db/table.js.map +1 -0
  19. package/db/types.d.ts +6 -0
  20. package/db/types.js +3 -0
  21. package/db/types.js.map +1 -0
  22. package/index.d.ts +18 -17
  23. package/index.js +27 -197
  24. package/index.js.map +1 -1
  25. package/indexConfiguration/base.d.ts +1 -1
  26. package/indexConfiguration/base.js +3 -10
  27. package/indexConfiguration/base.js.map +1 -1
  28. package/indexConfiguration/common.d.ts +1 -1
  29. package/indexConfiguration/common.js +1 -8
  30. package/indexConfiguration/common.js.map +1 -1
  31. package/indexConfiguration/index.d.ts +2 -3
  32. package/indexConfiguration/index.js +2 -38
  33. package/indexConfiguration/index.js.map +1 -1
  34. package/indexPrefix.js +2 -9
  35. package/indexPrefix.js.map +1 -1
  36. package/indices.d.ts +1 -2
  37. package/indices.js +6 -16
  38. package/indices.js.map +1 -1
  39. package/limit.js +1 -8
  40. package/limit.js.map +1 -1
  41. package/normalize.js +3 -11
  42. package/normalize.js.map +1 -1
  43. package/operations/ElasticsearchCatHealth.d.ts +2 -2
  44. package/operations/ElasticsearchCatHealth.js +6 -13
  45. package/operations/ElasticsearchCatHealth.js.map +1 -1
  46. package/operations/ElasticsearchCatNodes.d.ts +2 -2
  47. package/operations/ElasticsearchCatNodes.js +6 -13
  48. package/operations/ElasticsearchCatNodes.js.map +1 -1
  49. package/operations/index.d.ts +3 -3
  50. package/operations/index.js +3 -38
  51. package/operations/index.js.map +1 -1
  52. package/operations/stripConnectionFromException.js +1 -8
  53. package/operations/stripConnectionFromException.js.map +1 -1
  54. package/operations/types.js +1 -7
  55. package/operations/types.js.map +1 -1
  56. package/operators.d.ts +2 -5
  57. package/operators.js +3 -41
  58. package/operators.js.map +1 -1
  59. package/package.json +13 -12
  60. package/plugins/definition/ElasticsearchBodyModifierPlugin.js +4 -12
  61. package/plugins/definition/ElasticsearchBodyModifierPlugin.js.map +1 -1
  62. package/plugins/definition/ElasticsearchFieldPlugin.js +2 -9
  63. package/plugins/definition/ElasticsearchFieldPlugin.js.map +1 -1
  64. package/plugins/definition/ElasticsearchIndexPlugin.d.ts +2 -10
  65. package/plugins/definition/ElasticsearchIndexPlugin.js +4 -23
  66. package/plugins/definition/ElasticsearchIndexPlugin.js.map +1 -1
  67. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.d.ts +1 -5
  68. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js +2 -17
  69. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js.map +1 -1
  70. package/plugins/definition/ElasticsearchQueryModifierPlugin.d.ts +1 -1
  71. package/plugins/definition/ElasticsearchQueryModifierPlugin.js +4 -12
  72. package/plugins/definition/ElasticsearchQueryModifierPlugin.js.map +1 -1
  73. package/plugins/definition/ElasticsearchSortModifierPlugin.js +4 -12
  74. package/plugins/definition/ElasticsearchSortModifierPlugin.js.map +1 -1
  75. package/plugins/definition/index.d.ts +6 -6
  76. package/plugins/definition/index.js +6 -71
  77. package/plugins/definition/index.js.map +1 -1
  78. package/plugins/index.d.ts +2 -2
  79. package/plugins/index.js +2 -27
  80. package/plugins/index.js.map +1 -1
  81. package/plugins/operator/andIn.d.ts +2 -2
  82. package/plugins/operator/andIn.js +2 -9
  83. package/plugins/operator/andIn.js.map +1 -1
  84. package/plugins/operator/between.d.ts +2 -2
  85. package/plugins/operator/between.js +2 -9
  86. package/plugins/operator/between.js.map +1 -1
  87. package/plugins/operator/contains.d.ts +2 -2
  88. package/plugins/operator/contains.js +4 -11
  89. package/plugins/operator/contains.js.map +1 -1
  90. package/plugins/operator/equal.d.ts +2 -2
  91. package/plugins/operator/equal.js +2 -9
  92. package/plugins/operator/equal.js.map +1 -1
  93. package/plugins/operator/gt.d.ts +2 -2
  94. package/plugins/operator/gt.js +2 -9
  95. package/plugins/operator/gt.js.map +1 -1
  96. package/plugins/operator/gte.d.ts +2 -2
  97. package/plugins/operator/gte.js +2 -9
  98. package/plugins/operator/gte.js.map +1 -1
  99. package/plugins/operator/in.d.ts +2 -2
  100. package/plugins/operator/in.js +2 -9
  101. package/plugins/operator/in.js.map +1 -1
  102. package/plugins/operator/index.d.ts +15 -16
  103. package/plugins/operator/index.js +15 -181
  104. package/plugins/operator/index.js.map +1 -1
  105. package/plugins/operator/lt.d.ts +2 -2
  106. package/plugins/operator/lt.js +2 -9
  107. package/plugins/operator/lt.js.map +1 -1
  108. package/plugins/operator/lte.d.ts +2 -2
  109. package/plugins/operator/lte.js +2 -9
  110. package/plugins/operator/lte.js.map +1 -1
  111. package/plugins/operator/not.d.ts +2 -2
  112. package/plugins/operator/not.js +2 -9
  113. package/plugins/operator/not.js.map +1 -1
  114. package/plugins/operator/notBetween.d.ts +2 -2
  115. package/plugins/operator/notBetween.js +2 -9
  116. package/plugins/operator/notBetween.js.map +1 -1
  117. package/plugins/operator/notContains.d.ts +2 -2
  118. package/plugins/operator/notContains.js +4 -11
  119. package/plugins/operator/notContains.js.map +1 -1
  120. package/plugins/operator/notIn.d.ts +2 -2
  121. package/plugins/operator/notIn.js +2 -9
  122. package/plugins/operator/notIn.js.map +1 -1
  123. package/plugins/operator/notStartsWith.d.ts +2 -2
  124. package/plugins/operator/notStartsWith.js +2 -9
  125. package/plugins/operator/notStartsWith.js.map +1 -1
  126. package/plugins/operator/startsWith.d.ts +2 -2
  127. package/plugins/operator/startsWith.js +2 -9
  128. package/plugins/operator/startsWith.js.map +1 -1
  129. package/sharedIndex.js +2 -9
  130. package/sharedIndex.js.map +1 -1
  131. package/sort.d.ts +2 -2
  132. package/sort.js +8 -16
  133. package/sort.js.map +1 -1
  134. package/types.d.ts +3 -3
  135. package/types.js +28 -26
  136. package/types.js.map +1 -1
  137. package/utils/createIndex.d.ts +0 -1
  138. package/utils/createIndex.js +7 -19
  139. package/utils/createIndex.js.map +1 -1
  140. package/utils/index.d.ts +3 -3
  141. package/utils/index.js +3 -27
  142. package/utils/index.js.map +1 -1
  143. package/utils/waitUntilHealthy/UnhealthyClusterError.js +2 -9
  144. package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -1
  145. package/utils/waitUntilHealthy/WaitUntilHealthy.d.ts +3 -3
  146. package/utils/waitUntilHealthy/WaitUntilHealthy.js +22 -29
  147. package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -1
  148. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +2 -9
  149. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -1
  150. package/utils/waitUntilHealthy/index.d.ts +6 -6
  151. package/utils/waitUntilHealthy/index.js +6 -49
  152. package/utils/waitUntilHealthy/index.js.map +1 -1
  153. package/utils/waitUntilHealthy/reason/ClusterHealthReason.d.ts +2 -2
  154. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +2 -10
  155. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -1
  156. package/utils/waitUntilHealthy/reason/IReason.js +1 -5
  157. package/utils/waitUntilHealthy/reason/MemoryReason.d.ts +1 -1
  158. package/utils/waitUntilHealthy/reason/MemoryReason.js +2 -10
  159. package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -1
  160. package/utils/waitUntilHealthy/reason/ProcessorReason.d.ts +1 -1
  161. package/utils/waitUntilHealthy/reason/ProcessorReason.js +2 -10
  162. package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -1
  163. package/utils/waitUntilHealthy/reason/index.d.ts +3 -3
  164. package/utils/waitUntilHealthy/reason/index.js +3 -38
  165. package/utils/waitUntilHealthy/reason/index.js.map +1 -1
  166. package/where.d.ts +3 -3
  167. package/where.js +7 -16
  168. package/where.js.map +1 -1
  169. package/indexConfiguration/japanese.d.ts +0 -6
  170. package/indexConfiguration/japanese.js +0 -121
  171. package/indexConfiguration/japanese.js.map +0 -1
  172. package/plugins/operator/japanese/contains.d.ts +0 -8
  173. package/plugins/operator/japanese/contains.js +0 -44
  174. package/plugins/operator/japanese/contains.js.map +0 -1
package/README.md CHANGED
@@ -1 +1,11 @@
1
1
  # @webiny/api-elasticsearch
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 CHANGED
@@ -1,6 +1,6 @@
1
- import { Client, ClientOptions } from "@elastic/elasticsearch";
1
+ import { Client, type ClientOptions } from "@elastic/elasticsearch";
2
2
  export interface ElasticsearchClientOptions extends ClientOptions {
3
3
  endpoint?: string;
4
4
  }
5
- export { Client, ClientOptions };
5
+ export { Client, type ClientOptions };
6
6
  export declare const createElasticsearchClient: (options: ElasticsearchClientOptions) => Client;
package/client.js CHANGED
@@ -1,34 +1,16 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- Object.defineProperty(exports, "Client", {
8
- enumerable: true,
9
- get: function () {
10
- return _elasticsearch.Client;
11
- }
12
- });
13
- Object.defineProperty(exports, "ClientOptions", {
14
- enumerable: true,
15
- get: function () {
16
- return _elasticsearch.ClientOptions;
17
- }
18
- });
19
- exports.createElasticsearchClient = void 0;
20
- var _awsElasticsearchConnector = _interopRequireDefault(require("aws-elasticsearch-connector"));
21
- var _crypto = _interopRequireDefault(require("crypto"));
22
- var _error = _interopRequireDefault(require("@webiny/error"));
23
- var _elasticsearch = require("@elastic/elasticsearch");
1
+ import createAwsElasticsearchConnector from "aws-elasticsearch-connector";
2
+ import crypto from "crypto";
3
+ import WebinyError from "@webiny/error";
4
+ import { Client } from "@elastic/elasticsearch";
24
5
  const clients = new Map();
25
6
  const createClientKey = options => {
26
7
  const key = JSON.stringify(options);
27
- const hash = _crypto.default.createHash("sha1");
8
+ const hash = crypto.createHash("sha1");
28
9
  hash.update(key);
29
10
  return hash.digest("hex");
30
11
  };
31
- const createElasticsearchClient = options => {
12
+ export { Client };
13
+ export const createElasticsearchClient = options => {
32
14
  const key = createClientKey(options);
33
15
  const existing = clients.get(key);
34
16
  if (existing) {
@@ -56,18 +38,18 @@ const createElasticsearchClient = options => {
56
38
  return !value;
57
39
  });
58
40
  if (errors.length > 0) {
59
- throw new _error.default(`Missing keys values: ${errors.join(", ")}`, "MISSING_AWS_CREDENTIALS");
41
+ throw new WebinyError(`Missing keys values: ${errors.join(", ")}`, "MISSING_AWS_CREDENTIALS");
60
42
  }
61
43
  clientOptions = {
62
44
  ...clientOptions,
63
- ...(0, _awsElasticsearchConnector.default)({
45
+ ...createAwsElasticsearchConnector({
64
46
  region,
65
47
  credentials
66
48
  })
67
49
  };
68
50
  }
69
51
  try {
70
- return new _elasticsearch.Client(clientOptions);
52
+ return new Client(clientOptions);
71
53
  } catch (ex) {
72
54
  const data = {
73
55
  error: ex,
@@ -78,13 +60,12 @@ const createElasticsearchClient = options => {
78
60
  console.error({
79
61
  ...data
80
62
  });
81
- throw new _error.default("Could not connect to Elasticsearch.", "ELASTICSEARCH_CLIENT_ERROR", data);
63
+ throw new WebinyError("Could not connect to Elasticsearch.", "OPENSEARCH_CLIENT_ERROR", data);
82
64
  }
83
65
  };
84
66
  const client = cached();
85
67
  clients.set(key, client);
86
68
  return client;
87
69
  };
88
- exports.createElasticsearchClient = createElasticsearchClient;
89
70
 
90
71
  //# sourceMappingURL=client.js.map
package/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_awsElasticsearchConnector","_interopRequireDefault","require","_crypto","_error","_elasticsearch","clients","Map","createClientKey","options","key","JSON","stringify","hash","crypto","createHash","update","digest","createElasticsearchClient","existing","get","cached","endpoint","node","rest","clientOptions","auth","region","String","process","env","AWS_REGION","credentials","accessKeyId","AWS_ACCESS_KEY_ID","secretAccessKey","AWS_SECRET_ACCESS_KEY","sessionToken","AWS_SESSION_TOKEN","errors","Object","keys","filter","value","length","WebinyError","join","createAwsElasticsearchConnector","Client","ex","data","error","undefined","console","client","set","exports"],"sources":["client.ts"],"sourcesContent":["import createAwsElasticsearchConnector from \"aws-elasticsearch-connector\";\nimport crypto from \"crypto\";\nimport WebinyError from \"@webiny/error\";\nimport { Client, ClientOptions } from \"@elastic/elasticsearch\";\n\nexport interface ElasticsearchClientOptions extends ClientOptions {\n endpoint?: string;\n}\n\nconst clients = new Map<string, Client>();\n\nconst createClientKey = (options: ElasticsearchClientOptions) => {\n const key = JSON.stringify(options);\n const hash = crypto.createHash(\"sha1\");\n hash.update(key);\n return hash.digest(\"hex\");\n};\n\nexport { Client, ClientOptions };\n\nexport const createElasticsearchClient = (options: ElasticsearchClientOptions): Client => {\n const key = createClientKey(options);\n const existing = clients.get(key);\n if (existing) {\n return existing;\n }\n\n const cached = (): Client => {\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 = String(process.env.AWS_REGION);\n\n const credentials = {\n accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n sessionToken: process.env.AWS_SESSION_TOKEN\n };\n\n const errors = Object.keys(credentials).filter(key => {\n const value = credentials[key as keyof typeof credentials];\n return !value;\n });\n if (errors.length > 0) {\n throw new WebinyError(\n `Missing keys values: ${errors.join(\", \")}`,\n \"MISSING_AWS_CREDENTIALS\"\n );\n }\n\n clientOptions = {\n ...clientOptions,\n ...createAwsElasticsearchConnector({\n region,\n credentials\n })\n };\n }\n\n try {\n return new Client(clientOptions);\n } catch (ex) {\n const data = {\n error: ex,\n node: endpoint || node,\n ...rest,\n auth: undefined\n };\n console.error({\n ...data\n });\n throw new WebinyError(\n \"Could not connect to Elasticsearch.\",\n \"ELASTICSEARCH_CLIENT_ERROR\",\n data\n );\n }\n };\n\n const client = cached();\n\n clients.set(key, client);\n return client;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAMA,MAAMI,OAAO,GAAG,IAAIC,GAAG,CAAiB,CAAC;AAEzC,MAAMC,eAAe,GAAIC,OAAmC,IAAK;EAC7D,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAACH,OAAO,CAAC;EACnC,MAAMI,IAAI,GAAGC,eAAM,CAACC,UAAU,CAAC,MAAM,CAAC;EACtCF,IAAI,CAACG,MAAM,CAACN,GAAG,CAAC;EAChB,OAAOG,IAAI,CAACI,MAAM,CAAC,KAAK,CAAC;AAC7B,CAAC;AAIM,MAAMC,yBAAyB,GAAIT,OAAmC,IAAa;EACtF,MAAMC,GAAG,GAAGF,eAAe,CAACC,OAAO,CAAC;EACpC,MAAMU,QAAQ,GAAGb,OAAO,CAACc,GAAG,CAACV,GAAG,CAAC;EACjC,IAAIS,QAAQ,EAAE;IACV,OAAOA,QAAQ;EACnB;EAEA,MAAME,MAAM,GAAGA,CAAA,KAAc;IACzB,MAAM;MAAEC,QAAQ;MAAEC,IAAI;MAAE,GAAGC;IAAK,CAAC,GAAGf,OAAO;IAE3C,IAAIgB,aAA4B,GAAG;MAC/BF,IAAI,EAAED,QAAQ,IAAIC,IAAI;MACtB,GAAGC;IACP,CAAC;IAED,IAAI,CAACC,aAAa,CAACC,IAAI,EAAE;MACrB,MAAMC,MAAM,GAAGC,MAAM,CAACC,OAAO,CAACC,GAAG,CAACC,UAAU,CAAC;MAE7C,MAAMC,WAAW,GAAG;QAChBC,WAAW,EAAEJ,OAAO,CAACC,GAAG,CAACI,iBAAiB;QAC1CC,eAAe,EAAEN,OAAO,CAACC,GAAG,CAACM,qBAAqB;QAClDC,YAAY,EAAER,OAAO,CAACC,GAAG,CAACQ;MAC9B,CAAC;MAED,MAAMC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACT,WAAW,CAAC,CAACU,MAAM,CAAChC,GAAG,IAAI;QAClD,MAAMiC,KAAK,GAAGX,WAAW,CAACtB,GAAG,CAA6B;QAC1D,OAAO,CAACiC,KAAK;MACjB,CAAC,CAAC;MACF,IAAIJ,MAAM,CAACK,MAAM,GAAG,CAAC,EAAE;QACnB,MAAM,IAAIC,cAAW,CACjB,wBAAwBN,MAAM,CAACO,IAAI,CAAC,IAAI,CAAC,EAAE,EAC3C,yBACJ,CAAC;MACL;MAEArB,aAAa,GAAG;QACZ,GAAGA,aAAa;QAChB,GAAG,IAAAsB,kCAA+B,EAAC;UAC/BpB,MAAM;UACNK;QACJ,CAAC;MACL,CAAC;IACL;IAEA,IAAI;MACA,OAAO,IAAIgB,qBAAM,CAACvB,aAAa,CAAC;IACpC,CAAC,CAAC,OAAOwB,EAAE,EAAE;MACT,MAAMC,IAAI,GAAG;QACTC,KAAK,EAAEF,EAAE;QACT1B,IAAI,EAAED,QAAQ,IAAIC,IAAI;QACtB,GAAGC,IAAI;QACPE,IAAI,EAAE0B;MACV,CAAC;MACDC,OAAO,CAACF,KAAK,CAAC;QACV,GAAGD;MACP,CAAC,CAAC;MACF,MAAM,IAAIL,cAAW,CACjB,qCAAqC,EACrC,4BAA4B,EAC5BK,IACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMI,MAAM,GAAGjC,MAAM,CAAC,CAAC;EAEvBf,OAAO,CAACiD,GAAG,CAAC7C,GAAG,EAAE4C,MAAM,CAAC;EACxB,OAAOA,MAAM;AACjB,CAAC;AAACE,OAAA,CAAAtC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
1
+ {"version":3,"names":["createAwsElasticsearchConnector","crypto","WebinyError","Client","clients","Map","createClientKey","options","key","JSON","stringify","hash","createHash","update","digest","createElasticsearchClient","existing","get","cached","endpoint","node","rest","clientOptions","auth","region","String","process","env","AWS_REGION","credentials","accessKeyId","AWS_ACCESS_KEY_ID","secretAccessKey","AWS_SECRET_ACCESS_KEY","sessionToken","AWS_SESSION_TOKEN","errors","Object","keys","filter","value","length","join","ex","data","error","undefined","console","client","set"],"sources":["client.ts"],"sourcesContent":["import createAwsElasticsearchConnector from \"aws-elasticsearch-connector\";\nimport crypto from \"crypto\";\nimport WebinyError from \"@webiny/error\";\nimport { Client, type ClientOptions } from \"@elastic/elasticsearch\";\n\nexport interface ElasticsearchClientOptions extends ClientOptions {\n endpoint?: string;\n}\n\nconst clients = new Map<string, Client>();\n\nconst createClientKey = (options: ElasticsearchClientOptions) => {\n const key = JSON.stringify(options);\n const hash = crypto.createHash(\"sha1\");\n hash.update(key);\n return hash.digest(\"hex\");\n};\n\nexport { Client, type ClientOptions };\n\nexport const createElasticsearchClient = (options: ElasticsearchClientOptions): Client => {\n const key = createClientKey(options);\n const existing = clients.get(key);\n if (existing) {\n return existing;\n }\n\n const cached = (): Client => {\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 = String(process.env.AWS_REGION);\n\n const credentials = {\n accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n sessionToken: process.env.AWS_SESSION_TOKEN\n };\n\n const errors = Object.keys(credentials).filter(key => {\n const value = credentials[key as keyof typeof credentials];\n return !value;\n });\n if (errors.length > 0) {\n throw new WebinyError(\n `Missing keys values: ${errors.join(\", \")}`,\n \"MISSING_AWS_CREDENTIALS\"\n );\n }\n\n clientOptions = {\n ...clientOptions,\n ...createAwsElasticsearchConnector({\n region,\n credentials\n })\n };\n }\n\n try {\n return new Client(clientOptions);\n } catch (ex) {\n const data = {\n error: ex,\n node: endpoint || node,\n ...rest,\n auth: undefined\n };\n console.error({\n ...data\n });\n throw new WebinyError(\n \"Could not connect to Elasticsearch.\",\n \"OPENSEARCH_CLIENT_ERROR\",\n data\n );\n }\n };\n\n const client = cached();\n\n clients.set(key, client);\n return client;\n};\n"],"mappings":"AAAA,OAAOA,+BAA+B,MAAM,6BAA6B;AACzE,OAAOC,MAAM,MAAM,QAAQ;AAC3B,OAAOC,WAAW,MAAM,eAAe;AACvC,SAASC,MAAM,QAA4B,wBAAwB;AAMnE,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAAiB,CAAC;AAEzC,MAAMC,eAAe,GAAIC,OAAmC,IAAK;EAC7D,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAACH,OAAO,CAAC;EACnC,MAAMI,IAAI,GAAGV,MAAM,CAACW,UAAU,CAAC,MAAM,CAAC;EACtCD,IAAI,CAACE,MAAM,CAACL,GAAG,CAAC;EAChB,OAAOG,IAAI,CAACG,MAAM,CAAC,KAAK,CAAC;AAC7B,CAAC;AAED,SAASX,MAAM;AAEf,OAAO,MAAMY,yBAAyB,GAAIR,OAAmC,IAAa;EACtF,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,MAAME,MAAM,GAAGA,CAAA,KAAc;IACzB,MAAM;MAAEC,QAAQ;MAAEC,IAAI;MAAE,GAAGC;IAAK,CAAC,GAAGd,OAAO;IAE3C,IAAIe,aAA4B,GAAG;MAC/BF,IAAI,EAAED,QAAQ,IAAIC,IAAI;MACtB,GAAGC;IACP,CAAC;IAED,IAAI,CAACC,aAAa,CAACC,IAAI,EAAE;MACrB,MAAMC,MAAM,GAAGC,MAAM,CAACC,OAAO,CAACC,GAAG,CAACC,UAAU,CAAC;MAE7C,MAAMC,WAAW,GAAG;QAChBC,WAAW,EAAEJ,OAAO,CAACC,GAAG,CAACI,iBAAiB;QAC1CC,eAAe,EAAEN,OAAO,CAACC,GAAG,CAACM,qBAAqB;QAClDC,YAAY,EAAER,OAAO,CAACC,GAAG,CAACQ;MAC9B,CAAC;MAED,MAAMC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACT,WAAW,CAAC,CAACU,MAAM,CAAC/B,GAAG,IAAI;QAClD,MAAMgC,KAAK,GAAGX,WAAW,CAACrB,GAAG,CAA6B;QAC1D,OAAO,CAACgC,KAAK;MACjB,CAAC,CAAC;MACF,IAAIJ,MAAM,CAACK,MAAM,GAAG,CAAC,EAAE;QACnB,MAAM,IAAIvC,WAAW,CACjB,wBAAwBkC,MAAM,CAACM,IAAI,CAAC,IAAI,CAAC,EAAE,EAC3C,yBACJ,CAAC;MACL;MAEApB,aAAa,GAAG;QACZ,GAAGA,aAAa;QAChB,GAAGtB,+BAA+B,CAAC;UAC/BwB,MAAM;UACNK;QACJ,CAAC;MACL,CAAC;IACL;IAEA,IAAI;MACA,OAAO,IAAI1B,MAAM,CAACmB,aAAa,CAAC;IACpC,CAAC,CAAC,OAAOqB,EAAE,EAAE;MACT,MAAMC,IAAI,GAAG;QACTC,KAAK,EAAEF,EAAE;QACTvB,IAAI,EAAED,QAAQ,IAAIC,IAAI;QACtB,GAAGC,IAAI;QACPE,IAAI,EAAEuB;MACV,CAAC;MACDC,OAAO,CAACF,KAAK,CAAC;QACV,GAAGD;MACP,CAAC,CAAC;MACF,MAAM,IAAI1C,WAAW,CACjB,qCAAqC,EACrC,yBAAyB,EACzB0C,IACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMI,MAAM,GAAG9B,MAAM,CAAC,CAAC;EAEvBd,OAAO,CAAC6C,GAAG,CAACzC,GAAG,EAAEwC,MAAM,CAAC;EACxB,OAAOA,MAAM;AACjB,CAAC","ignoreList":[]}
package/compression.js CHANGED
@@ -1,32 +1,25 @@
1
- "use strict";
1
+ import { CompressorPlugin } from "@webiny/api";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.decompress = exports.compress = void 0;
7
- var _api = require("@webiny/api");
8
3
  /**
9
4
  * Method to compress the elasticsearch data that is going to be stored into the DynamoDB table that is meant for elasticsearch.
10
5
  */
11
- const compress = async (pluginsContainer, data) => {
6
+ export const compress = async (pluginsContainer, data) => {
12
7
  let plugin;
13
8
  try {
14
- plugin = pluginsContainer.oneByType(_api.CompressorPlugin.type);
15
- } catch (ex) {
9
+ plugin = pluginsContainer.oneByType(CompressorPlugin.type);
10
+ } catch {
16
11
  return data;
17
12
  }
18
13
  return plugin.getCompressor().compress(data);
19
14
  };
20
- exports.compress = compress;
21
- const decompress = async (pluginsContainer, data) => {
15
+ export const decompress = async (pluginsContainer, data) => {
22
16
  let plugin;
23
17
  try {
24
- plugin = pluginsContainer.oneByType(_api.CompressorPlugin.type);
25
- } catch (ex) {
18
+ plugin = pluginsContainer.oneByType(CompressorPlugin.type);
19
+ } catch {
26
20
  return data;
27
21
  }
28
22
  return plugin.getCompressor().decompress(data);
29
23
  };
30
- exports.decompress = decompress;
31
24
 
32
25
  //# sourceMappingURL=compression.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_api","require","compress","pluginsContainer","data","plugin","oneByType","CompressorPlugin","type","ex","getCompressor","exports","decompress"],"sources":["compression.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport { CompressorPlugin } from \"@webiny/api\";\n\n/**\n * Method to compress the elasticsearch data that is going to be stored into the DynamoDB table that is meant for elasticsearch.\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 (ex) {\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 (ex) {\n return data;\n }\n return plugin.getCompressor().decompress(data);\n};\n"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACO,MAAMC,QAAQ,GAAG,MAAAA,CACpBC,gBAAkC,EAClCC,IAAyB,KACM;EAC/B,IAAIC,MAAwB;EAC5B,IAAI;IACAA,MAAM,GAAGF,gBAAgB,CAACG,SAAS,CAAmBC,qBAAgB,CAACC,IAAI,CAAC;EAChF,CAAC,CAAC,OAAOC,EAAE,EAAE;IACT,OAAOL,IAAI;EACf;EACA,OAAOC,MAAM,CAACK,aAAa,CAAC,CAAC,CAACR,QAAQ,CAACE,IAAI,CAAC;AAChD,CAAC;AAACO,OAAA,CAAAT,QAAA,GAAAA,QAAA;AAEK,MAAMU,UAAU,GAAG,MAAAA,CACtBT,gBAAkC,EAClCC,IAAyB,KACM;EAC/B,IAAIC,MAAwB;EAC5B,IAAI;IACAA,MAAM,GAAGF,gBAAgB,CAACG,SAAS,CAAmBC,qBAAgB,CAACC,IAAI,CAAC;EAChF,CAAC,CAAC,OAAOC,EAAE,EAAE;IACT,OAAOL,IAAI;EACf;EACA,OAAOC,MAAM,CAACK,aAAa,CAAC,CAAC,CAACE,UAAU,CAACR,IAAI,CAAC;AAClD,CAAC;AAACO,OAAA,CAAAC,UAAA,GAAAA,UAAA","ignoreList":[]}
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 elasticsearch data that is going to be stored into the DynamoDB table that is meant for elasticsearch.\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 CHANGED
@@ -1,4 +1,4 @@
1
- import type { PrimitiveValue } from "./types";
1
+ import type { PrimitiveValue } from "./types.js";
2
2
  /**
3
3
  * Encode a received cursor value into something that can be passed on to the user.
4
4
  */
package/cursors.js CHANGED
@@ -1,13 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.encodeCursor = exports.decodeCursor = void 0;
7
1
  /**
8
2
  * Encode a received cursor value into something that can be passed on to the user.
9
3
  */
10
- const encodeCursor = input => {
4
+ export const encodeCursor = input => {
11
5
  if (!input) {
12
6
  return undefined;
13
7
  }
@@ -23,8 +17,7 @@ const encodeCursor = input => {
23
17
  * Decode a received value into a Elasticsearch cursor.
24
18
  * If no value is received or is not decodable, return undefined.
25
19
  */
26
- exports.encodeCursor = encodeCursor;
27
- const decodeCursor = cursor => {
20
+ export const decodeCursor = cursor => {
28
21
  if (!cursor) {
29
22
  return undefined;
30
23
  }
@@ -40,6 +33,5 @@ const decodeCursor = cursor => {
40
33
  }
41
34
  return undefined;
42
35
  };
43
- exports.decodeCursor = decodeCursor;
44
36
 
45
37
  //# 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","exports","decodeCursor","value","parse","decodeURIComponent","decoded"],"sources":["cursors.ts"],"sourcesContent":["import type { PrimitiveValue } from \"~/types\";\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 a Elasticsearch 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;AACO,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;AAHAiB,OAAA,CAAAnB,YAAA,GAAAA,YAAA;AAIO,MAAMoB,YAAY,GAAIjB,MAAsB,IAAmC;EAClF,IAAI,CAACA,MAAM,EAAE;IACT,OAAOD,SAAS;EACpB;EACA,IAAI;IACA,MAAMmB,KAAK,GAAGT,IAAI,CAACU,KAAK,CAACZ,MAAM,CAACC,IAAI,CAACR,MAAM,EAAE,QAAQ,CAAC,CAACW,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzE,IAAIV,KAAK,CAACC,OAAO,CAACgB,KAAK,CAAC,EAAE;MACtB,OAAOA,KAAK,CAACf,MAAM,CAACC,IAAI,IAAIA,IAAI,KAAK,IAAI,CAAC,CAACC,GAAG,CAACe,kBAAkB,CAAC;IACtE;IACA,MAAMC,OAAO,GAAGD,kBAAkB,CAACF,KAAK,CAAC;IACzC,OAAOG,OAAO,GAAG,CAACA,OAAO,CAAC,GAAGtB,SAAS;EAC1C,CAAC,CAAC,OAAOa,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAACG,OAAO,CAAC;EAC7B;EACA,OAAOhB,SAAS;AACpB,CAAC;AAACiB,OAAA,CAAAC,YAAA,GAAAA,YAAA","ignoreList":[]}
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 a Elasticsearch 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 { IElasticsearchEntity } from "../db/types.js";
3
+ export interface ICreateElasticsearchEntityParams {
4
+ table: ITable;
5
+ entityName: string;
6
+ }
7
+ export declare const createElasticsearchEntity: (params: ICreateElasticsearchEntityParams) => IElasticsearchEntity;
package/db/entity.js ADDED
@@ -0,0 +1,20 @@
1
+ import { createEntity, standardEntityAttributes } from "@webiny/db-dynamodb";
2
+ export const createElasticsearchEntity = 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","createElasticsearchEntity","params","table","entityName","name","attributes","index","type","required"],"sources":["entity.ts"],"sourcesContent":["import { createEntity, type ITable, standardEntityAttributes } from \"@webiny/db-dynamodb\";\nimport type { IElasticsearchEntity, IElasticsearchEntityAttributes } from \"~/db/types.js\";\n\nexport interface ICreateElasticsearchEntityParams {\n table: ITable;\n entityName: string;\n}\n\nexport const createElasticsearchEntity = (\n params: ICreateElasticsearchEntityParams\n): IElasticsearchEntity => {\n const { table, entityName } = params;\n return createEntity<IElasticsearchEntityAttributes>({\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,yBAAyB,GAClCC,MAAwC,IACjB;EACvB,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,MAAM;EACpC,OAAOH,YAAY,CAAiC;IAChDM,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 ICreateElasticsearchTableParams {
4
+ name?: string;
5
+ documentClient: DynamoDBDocument;
6
+ }
7
+ export declare const createElasticsearchTable: ({ name, documentClient }: ICreateElasticsearchTableParams) => ITable;
package/db/table.js ADDED
@@ -0,0 +1,17 @@
1
+ import { createTable } from "@webiny/db-dynamodb";
2
+ export const createElasticsearchTable = ({
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","createElasticsearchTable","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 ICreateElasticsearchTableParams {\n name?: string;\n documentClient: DynamoDBDocument;\n}\n\nexport const createElasticsearchTable = ({\n name,\n documentClient\n}: ICreateElasticsearchTableParams): 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,wBAAwB,GAAGA,CAAC;EACrCC,IAAI;EACJC;AAC6B,CAAC,KAAa;EAC3C,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 IElasticsearchEntityAttributes extends IStandardEntityAttributes<GenericRecord> {
4
+ index: string;
5
+ }
6
+ export type IElasticsearchEntity = IEntity<IElasticsearchEntityAttributes>;
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 IElasticsearchEntityAttributes extends IStandardEntityAttributes<GenericRecord> {\n index: string;\n}\n\nexport type IElasticsearchEntity = IEntity<IElasticsearchEntityAttributes>;\n"],"mappings":"","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,22 +1,23 @@
1
- import type { ElasticsearchContext } from "./types";
1
+ import type { ElasticsearchContext } from "./types.js";
2
2
  import { ContextPlugin } from "@webiny/api";
3
- import type { ElasticsearchClientOptions } from "./client";
3
+ import type { ElasticsearchClientOptions } from "./client.js";
4
4
  import { Client } from "@elastic/elasticsearch";
5
- export * from "./indexConfiguration";
6
- export * from "./plugins";
7
- export * from "./sort";
8
- export * from "./indices";
9
- export * from "./where";
10
- export * from "./limit";
11
- export * from "./normalize";
12
- export * from "./compression";
13
- export * from "./operators";
14
- export * from "./cursors";
15
- export * from "./client";
16
- export * from "./utils";
17
- export * from "./operations";
18
- export * from "./sharedIndex";
19
- export * from "./indexPrefix";
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 * 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";
20
21
  /**
21
22
  * We must accept either Elasticsearch client or options that create the client.
22
23
  */
package/index.js CHANGED
@@ -1,212 +1,42 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- var _exportNames = {};
8
- exports.default = void 0;
9
- var _error = _interopRequireDefault(require("@webiny/error"));
10
- var _api = require("@webiny/api");
11
- var _client = require("./client");
12
- Object.keys(_client).forEach(function (key) {
13
- if (key === "default" || key === "__esModule") return;
14
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
15
- if (key in exports && exports[key] === _client[key]) return;
16
- Object.defineProperty(exports, key, {
17
- enumerable: true,
18
- get: function () {
19
- return _client[key];
20
- }
21
- });
22
- });
23
- var _operators = require("./operators");
24
- Object.keys(_operators).forEach(function (key) {
25
- if (key === "default" || key === "__esModule") return;
26
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
27
- if (key in exports && exports[key] === _operators[key]) return;
28
- Object.defineProperty(exports, key, {
29
- enumerable: true,
30
- get: function () {
31
- return _operators[key];
32
- }
33
- });
34
- });
35
- var _elasticsearch = require("@elastic/elasticsearch");
36
- var _indexConfiguration = require("./indexConfiguration");
37
- Object.keys(_indexConfiguration).forEach(function (key) {
38
- if (key === "default" || key === "__esModule") return;
39
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
40
- if (key in exports && exports[key] === _indexConfiguration[key]) return;
41
- Object.defineProperty(exports, key, {
42
- enumerable: true,
43
- get: function () {
44
- return _indexConfiguration[key];
45
- }
46
- });
47
- });
48
- var _plugins = require("./plugins");
49
- Object.keys(_plugins).forEach(function (key) {
50
- if (key === "default" || key === "__esModule") return;
51
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
52
- if (key in exports && exports[key] === _plugins[key]) return;
53
- Object.defineProperty(exports, key, {
54
- enumerable: true,
55
- get: function () {
56
- return _plugins[key];
57
- }
58
- });
59
- });
60
- var _sort = require("./sort");
61
- Object.keys(_sort).forEach(function (key) {
62
- if (key === "default" || key === "__esModule") return;
63
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
64
- if (key in exports && exports[key] === _sort[key]) return;
65
- Object.defineProperty(exports, key, {
66
- enumerable: true,
67
- get: function () {
68
- return _sort[key];
69
- }
70
- });
71
- });
72
- var _indices = require("./indices");
73
- Object.keys(_indices).forEach(function (key) {
74
- if (key === "default" || key === "__esModule") return;
75
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
76
- if (key in exports && exports[key] === _indices[key]) return;
77
- Object.defineProperty(exports, key, {
78
- enumerable: true,
79
- get: function () {
80
- return _indices[key];
81
- }
82
- });
83
- });
84
- var _where = require("./where");
85
- Object.keys(_where).forEach(function (key) {
86
- if (key === "default" || key === "__esModule") return;
87
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
88
- if (key in exports && exports[key] === _where[key]) return;
89
- Object.defineProperty(exports, key, {
90
- enumerable: true,
91
- get: function () {
92
- return _where[key];
93
- }
94
- });
95
- });
96
- var _limit = require("./limit");
97
- Object.keys(_limit).forEach(function (key) {
98
- if (key === "default" || key === "__esModule") return;
99
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
100
- if (key in exports && exports[key] === _limit[key]) return;
101
- Object.defineProperty(exports, key, {
102
- enumerable: true,
103
- get: function () {
104
- return _limit[key];
105
- }
106
- });
107
- });
108
- var _normalize = require("./normalize");
109
- Object.keys(_normalize).forEach(function (key) {
110
- if (key === "default" || key === "__esModule") return;
111
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
112
- if (key in exports && exports[key] === _normalize[key]) return;
113
- Object.defineProperty(exports, key, {
114
- enumerable: true,
115
- get: function () {
116
- return _normalize[key];
117
- }
118
- });
119
- });
120
- var _compression = require("./compression");
121
- Object.keys(_compression).forEach(function (key) {
122
- if (key === "default" || key === "__esModule") return;
123
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
124
- if (key in exports && exports[key] === _compression[key]) return;
125
- Object.defineProperty(exports, key, {
126
- enumerable: true,
127
- get: function () {
128
- return _compression[key];
129
- }
130
- });
131
- });
132
- var _cursors = require("./cursors");
133
- Object.keys(_cursors).forEach(function (key) {
134
- if (key === "default" || key === "__esModule") return;
135
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
136
- if (key in exports && exports[key] === _cursors[key]) return;
137
- Object.defineProperty(exports, key, {
138
- enumerable: true,
139
- get: function () {
140
- return _cursors[key];
141
- }
142
- });
143
- });
144
- var _utils = require("./utils");
145
- Object.keys(_utils).forEach(function (key) {
146
- if (key === "default" || key === "__esModule") return;
147
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
148
- if (key in exports && exports[key] === _utils[key]) return;
149
- Object.defineProperty(exports, key, {
150
- enumerable: true,
151
- get: function () {
152
- return _utils[key];
153
- }
154
- });
155
- });
156
- var _operations = require("./operations");
157
- Object.keys(_operations).forEach(function (key) {
158
- if (key === "default" || key === "__esModule") return;
159
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
160
- if (key in exports && exports[key] === _operations[key]) return;
161
- Object.defineProperty(exports, key, {
162
- enumerable: true,
163
- get: function () {
164
- return _operations[key];
165
- }
166
- });
167
- });
168
- var _sharedIndex = require("./sharedIndex");
169
- Object.keys(_sharedIndex).forEach(function (key) {
170
- if (key === "default" || key === "__esModule") return;
171
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
172
- if (key in exports && exports[key] === _sharedIndex[key]) return;
173
- Object.defineProperty(exports, key, {
174
- enumerable: true,
175
- get: function () {
176
- return _sharedIndex[key];
177
- }
178
- });
179
- });
180
- var _indexPrefix = require("./indexPrefix");
181
- Object.keys(_indexPrefix).forEach(function (key) {
182
- if (key === "default" || key === "__esModule") return;
183
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
184
- if (key in exports && exports[key] === _indexPrefix[key]) return;
185
- Object.defineProperty(exports, key, {
186
- enumerable: true,
187
- get: function () {
188
- return _indexPrefix[key];
189
- }
190
- });
191
- });
192
1
  /**
193
2
  * TODO File should contain only exports from other files.
194
3
  */
4
+ import WebinyError from "@webiny/error";
5
+ import { ContextPlugin } from "@webiny/api";
6
+ import { createElasticsearchClient } from "./client.js";
7
+ import { getElasticsearchOperators } from "./operators.js";
8
+ import { Client } from "@elastic/elasticsearch";
9
+ export * from "./indexConfiguration/index.js";
10
+ export * from "./plugins/index.js";
11
+ export * from "./sort.js";
12
+ export * from "./indices.js";
13
+ export * from "./where.js";
14
+ export * from "./limit.js";
15
+ export * from "./normalize.js";
16
+ export * from "./compression.js";
17
+ export * from "./operators.js";
18
+ export * from "./cursors.js";
19
+ export * from "./client.js";
20
+ export * from "./utils/index.js";
21
+ export * from "./operations/index.js";
22
+ export * from "./sharedIndex.js";
23
+ export * from "./indexPrefix.js";
24
+ export * from "./db/index.js";
25
+
195
26
  /**
196
27
  * We must accept either Elasticsearch client or options that create the client.
197
28
  */
198
- var _default = params => {
199
- return new _api.ContextPlugin(context => {
29
+ export default params => {
30
+ return new ContextPlugin(context => {
200
31
  if (context.elasticsearch) {
201
- throw new _error.default("Elasticsearch client is already initialized, no need to define it again. Check your code for duplicate initializations.", "ELASTICSEARCH_ALREADY_INITIALIZED");
32
+ throw new WebinyError("Elasticsearch client is already initialized, no need to define it again. Check your code for duplicate initializations.", "OPENSEARCH_ALREADY_INITIALIZED");
202
33
  }
203
34
  /**
204
35
  * Initialize the Elasticsearch client.
205
36
  */
206
- context.elasticsearch = params instanceof _elasticsearch.Client ? params : (0, _client.createElasticsearchClient)(params);
207
- context.plugins.register((0, _operators.getElasticsearchOperators)());
37
+ context.elasticsearch = params instanceof Client ? params : createElasticsearchClient(params);
38
+ context.plugins.register(getElasticsearchOperators());
208
39
  });
209
40
  };
210
- exports.default = _default;
211
41
 
212
42
  //# sourceMappingURL=index.js.map