@webiny/api-elasticsearch 0.0.0-unstable.5e7233243f → 0.0.0-unstable.60a863e033

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 (96) hide show
  1. package/client.js +9 -27
  2. package/client.js.map +1 -1
  3. package/compression.js +0 -17
  4. package/compression.js.map +1 -1
  5. package/cursors.d.ts +2 -1
  6. package/cursors.js +5 -11
  7. package/cursors.js.map +1 -1
  8. package/index.d.ts +12 -0
  9. package/index.js +144 -11
  10. package/index.js.map +1 -1
  11. package/indexConfiguration/base.d.ts +5 -1
  12. package/indexConfiguration/base.js +22 -16
  13. package/indexConfiguration/base.js.map +1 -1
  14. package/indexConfiguration/common.d.ts +5 -1
  15. package/indexConfiguration/common.js +32 -10
  16. package/indexConfiguration/common.js.map +1 -1
  17. package/indexConfiguration/index.d.ts +3 -0
  18. package/indexConfiguration/index.js +38 -0
  19. package/indexConfiguration/index.js.map +1 -0
  20. package/indexConfiguration/japanese.d.ts +5 -1
  21. package/indexConfiguration/japanese.js +30 -23
  22. package/indexConfiguration/japanese.js.map +1 -1
  23. package/indices.js +1 -8
  24. package/indices.js.map +1 -1
  25. package/limit.js +0 -8
  26. package/limit.js.map +1 -1
  27. package/normalize.js +11 -12
  28. package/normalize.js.map +1 -1
  29. package/operators.js +0 -11
  30. package/operators.js.map +1 -1
  31. package/package.json +10 -10
  32. package/plugins/GzipCompression.d.ts +5 -0
  33. package/plugins/GzipCompression.js +10 -17
  34. package/plugins/GzipCompression.js.map +1 -1
  35. package/plugins/definition/CompressionPlugin.js +1 -6
  36. package/plugins/definition/CompressionPlugin.js.map +1 -1
  37. package/plugins/definition/ElasticsearchBodyModifierPlugin.js +1 -10
  38. package/plugins/definition/ElasticsearchBodyModifierPlugin.js.map +1 -1
  39. package/plugins/definition/ElasticsearchFieldPlugin.js +3 -28
  40. package/plugins/definition/ElasticsearchFieldPlugin.js.map +1 -1
  41. package/plugins/definition/ElasticsearchIndexPlugin.js +3 -15
  42. package/plugins/definition/ElasticsearchIndexPlugin.js.map +1 -1
  43. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js +1 -7
  44. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js.map +1 -1
  45. package/plugins/definition/ElasticsearchQueryModifierPlugin.js +1 -10
  46. package/plugins/definition/ElasticsearchQueryModifierPlugin.js.map +1 -1
  47. package/plugins/definition/ElasticsearchSortModifierPlugin.js +1 -10
  48. package/plugins/definition/ElasticsearchSortModifierPlugin.js.map +1 -1
  49. package/plugins/definition/index.d.ts +7 -0
  50. package/plugins/definition/index.js +82 -0
  51. package/plugins/definition/index.js.map +1 -0
  52. package/plugins/index.d.ts +2 -0
  53. package/plugins/index.js +27 -0
  54. package/plugins/index.js.map +1 -0
  55. package/plugins/operator/andIn.js +4 -15
  56. package/plugins/operator/andIn.js.map +1 -1
  57. package/plugins/operator/between.js +8 -17
  58. package/plugins/operator/between.js.map +1 -1
  59. package/plugins/operator/contains.js +2 -11
  60. package/plugins/operator/contains.js.map +1 -1
  61. package/plugins/operator/equal.js +21 -16
  62. package/plugins/operator/equal.js.map +1 -1
  63. package/plugins/operator/gt.js +2 -10
  64. package/plugins/operator/gt.js.map +1 -1
  65. package/plugins/operator/gte.js +2 -10
  66. package/plugins/operator/gte.js.map +1 -1
  67. package/plugins/operator/in.js +7 -22
  68. package/plugins/operator/in.js.map +1 -1
  69. package/plugins/operator/index.js +0 -32
  70. package/plugins/operator/index.js.map +1 -1
  71. package/plugins/operator/japanese/contains.js +3 -14
  72. package/plugins/operator/japanese/contains.js.map +1 -1
  73. package/plugins/operator/lt.js +2 -10
  74. package/plugins/operator/lt.js.map +1 -1
  75. package/plugins/operator/lte.js +2 -10
  76. package/plugins/operator/lte.js.map +1 -1
  77. package/plugins/operator/not.js +14 -14
  78. package/plugins/operator/not.js.map +1 -1
  79. package/plugins/operator/notBetween.js +7 -16
  80. package/plugins/operator/notBetween.js.map +1 -1
  81. package/plugins/operator/notContains.js +2 -11
  82. package/plugins/operator/notContains.js.map +1 -1
  83. package/plugins/operator/notIn.js +4 -13
  84. package/plugins/operator/notIn.js.map +1 -1
  85. package/plugins/operator/notStartsWith.js +1 -9
  86. package/plugins/operator/notStartsWith.js.map +1 -1
  87. package/plugins/operator/startsWith.js +2 -10
  88. package/plugins/operator/startsWith.js.map +1 -1
  89. package/sort.d.ts +2 -6
  90. package/sort.js +3 -19
  91. package/sort.js.map +1 -1
  92. package/types.d.ts +12 -4
  93. package/types.js +2 -5
  94. package/types.js.map +1 -1
  95. package/where.js +3 -23
  96. package/where.js.map +1 -1
package/client.js CHANGED
@@ -1,61 +1,43 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createElasticsearchClient = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
-
14
10
  var _elasticsearch = require("@elastic/elasticsearch");
15
-
16
11
  var _awsSdk = _interopRequireDefault(require("aws-sdk"));
17
-
18
12
  var _error = _interopRequireDefault(require("@webiny/error"));
19
-
20
13
  var _awsElasticsearchConnector = _interopRequireDefault(require("aws-elasticsearch-connector"));
21
-
22
14
  const _excluded = ["endpoint", "node"];
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
-
28
15
  const createElasticsearchClient = options => {
29
16
  const {
30
- endpoint,
31
- node
32
- } = options,
33
- rest = (0, _objectWithoutProperties2.default)(options, _excluded);
34
-
35
- const clientOptions = _objectSpread({
17
+ endpoint,
18
+ node
19
+ } = options,
20
+ rest = (0, _objectWithoutProperties2.default)(options, _excluded);
21
+ const clientOptions = (0, _objectSpread2.default)({
36
22
  node: endpoint || node
37
23
  }, rest);
38
-
39
24
  if (!clientOptions.auth) {
40
25
  /**
41
26
  * If no `auth` configuration is present, we setup AWS connector.
42
27
  */
43
28
  Object.assign(clientOptions, (0, _awsElasticsearchConnector.default)(_awsSdk.default.config));
44
29
  }
45
-
46
30
  try {
47
31
  return new _elasticsearch.Client(clientOptions);
48
32
  } catch (ex) {
49
- const data = _objectSpread(_objectSpread({
33
+ const data = (0, _objectSpread2.default)((0, _objectSpread2.default)({
50
34
  error: ex,
51
35
  node: endpoint || node
52
36
  }, rest), {}, {
53
37
  auth: undefined
54
38
  });
55
-
56
- console.log(_objectSpread({}, data));
39
+ console.log((0, _objectSpread2.default)({}, data));
57
40
  throw new _error.default("Could not connect to Elasticsearch.", "ELASTICSEARCH_CLIENT_ERROR", data);
58
41
  }
59
42
  };
60
-
61
43
  exports.createElasticsearchClient = createElasticsearchClient;
package/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["createElasticsearchClient","options","endpoint","node","rest","clientOptions","auth","Object","assign","createAwsElasticsearchConnector","AWS","config","Client","ex","data","error","undefined","console","log","WebinyError"],"sources":["client.ts"],"sourcesContent":["import { Client, ClientOptions } from \"@elastic/elasticsearch\";\nimport AWS from \"aws-sdk\";\nimport WebinyError from \"@webiny/error\";\n/**\n * Package aws-elasticsearch-connector does not have types.\n */\n// @ts-ignore\nimport createAwsElasticsearchConnector from \"aws-elasticsearch-connector\";\n\nexport interface ElasticsearchClientOptions extends ClientOptions {\n endpoint?: string;\n}\n\nexport const createElasticsearchClient = (options: ElasticsearchClientOptions) => {\n const { endpoint, node, ...rest } = options;\n\n const clientOptions: ClientOptions = {\n node: endpoint || node,\n ...rest\n };\n\n if (!clientOptions.auth) {\n /**\n * If no `auth` configuration is present, we setup AWS connector.\n */\n Object.assign(clientOptions, createAwsElasticsearchConnector(AWS.config));\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.log({\n ...data\n });\n throw new WebinyError(\n \"Could not connect to Elasticsearch.\",\n \"ELASTICSEARCH_CLIENT_ERROR\",\n data\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAKA;;;;;;;;AAMO,MAAMA,yBAAyB,GAAIC,OAAD,IAAyC;EAC9E,MAAM;IAAEC,QAAF;IAAYC;EAAZ,IAA8BF,OAApC;EAAA,MAA2BG,IAA3B,0CAAoCH,OAApC;;EAEA,MAAMI,aAA4B;IAC9BF,IAAI,EAAED,QAAQ,IAAIC;EADY,GAE3BC,IAF2B,CAAlC;;EAKA,IAAI,CAACC,aAAa,CAACC,IAAnB,EAAyB;IACrB;AACR;AACA;IACQC,MAAM,CAACC,MAAP,CAAcH,aAAd,EAA6B,IAAAI,kCAAA,EAAgCC,eAAA,CAAIC,MAApC,CAA7B;EACH;;EAED,IAAI;IACA,OAAO,IAAIC,qBAAJ,CAAWP,aAAX,CAAP;EACH,CAFD,CAEE,OAAOQ,EAAP,EAAW;IACT,MAAMC,IAAI;MACNC,KAAK,EAAEF,EADD;MAENV,IAAI,EAAED,QAAQ,IAAIC;IAFZ,GAGHC,IAHG;MAINE,IAAI,EAAEU;IAJA,EAAV;;IAMAC,OAAO,CAACC,GAAR,mBACOJ,IADP;IAGA,MAAM,IAAIK,cAAJ,CACF,qCADE,EAEF,4BAFE,EAGFL,IAHE,CAAN;EAKH;AACJ,CAjCM"}
1
+ {"version":3,"names":["createElasticsearchClient","options","endpoint","node","rest","clientOptions","auth","Object","assign","createAwsElasticsearchConnector","AWS","config","Client","ex","data","error","undefined","console","log","WebinyError"],"sources":["client.ts"],"sourcesContent":["import { Client, ClientOptions } from \"@elastic/elasticsearch\";\nimport AWS from \"aws-sdk\";\nimport WebinyError from \"@webiny/error\";\n/**\n * Package aws-elasticsearch-connector does not have types.\n */\n// @ts-ignore\nimport createAwsElasticsearchConnector from \"aws-elasticsearch-connector\";\n\nexport interface ElasticsearchClientOptions extends ClientOptions {\n endpoint?: string;\n}\n\nexport const createElasticsearchClient = (options: ElasticsearchClientOptions) => {\n const { endpoint, node, ...rest } = options;\n\n const clientOptions: ClientOptions = {\n node: endpoint || node,\n ...rest\n };\n\n if (!clientOptions.auth) {\n /**\n * If no `auth` configuration is present, we setup AWS connector.\n */\n Object.assign(clientOptions, createAwsElasticsearchConnector(AWS.config));\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.log({\n ...data\n });\n throw new WebinyError(\n \"Could not connect to Elasticsearch.\",\n \"ELASTICSEARCH_CLIENT_ERROR\",\n data\n );\n }\n};\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AAKA;AAA0E;AAMnE,MAAMA,yBAAyB,GAAIC,OAAmC,IAAK;EAC9E,MAAM;MAAEC,QAAQ;MAAEC;IAAc,CAAC,GAAGF,OAAO;IAAhBG,IAAI,0CAAKH,OAAO;EAE3C,MAAMI,aAA4B;IAC9BF,IAAI,EAAED,QAAQ,IAAIC;EAAI,GACnBC,IAAI,CACV;EAED,IAAI,CAACC,aAAa,CAACC,IAAI,EAAE;IACrB;AACR;AACA;IACQC,MAAM,CAACC,MAAM,CAACH,aAAa,EAAE,IAAAI,kCAA+B,EAACC,eAAG,CAACC,MAAM,CAAC,CAAC;EAC7E;EAEA,IAAI;IACA,OAAO,IAAIC,qBAAM,CAACP,aAAa,CAAC;EACpC,CAAC,CAAC,OAAOQ,EAAE,EAAE;IACT,MAAMC,IAAI;MACNC,KAAK,EAAEF,EAAE;MACTV,IAAI,EAAED,QAAQ,IAAIC;IAAI,GACnBC,IAAI;MACPE,IAAI,EAAEU;IAAS,EAClB;IACDC,OAAO,CAACC,GAAG,iCACJJ,IAAI,EACT;IACF,MAAM,IAAIK,cAAW,CACjB,qCAAqC,EACrC,4BAA4B,EAC5BL,IAAI,CACP;EACL;AACJ,CAAC;AAAC"}
package/compression.js CHANGED
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.decompress = exports.compress = void 0;
7
-
8
7
  var _CompressionPlugin = require("./plugins/definition/CompressionPlugin");
9
-
10
8
  /**
11
9
  * Get the compression plugins, in reverse order, because we want to use the last one added - first.
12
10
  */
@@ -16,53 +14,38 @@ const getCompressionPlugins = plugins => {
16
14
  /**
17
15
  * Method to compress the elasticsearch data that is going to be stored into the DynamoDB table that is meant for elasticsearch.
18
16
  */
19
-
20
-
21
17
  const compress = async (pluginsContainer, data) => {
22
18
  const plugins = getCompressionPlugins(pluginsContainer);
23
-
24
19
  if (plugins.length === 0) {
25
20
  console.log("No compression plugins");
26
21
  return data;
27
22
  }
28
-
29
23
  for (const plugin of plugins) {
30
24
  if (plugin.canCompress(data) === false) {
31
25
  continue;
32
26
  }
33
-
34
27
  return await plugin.compress(data);
35
28
  }
36
29
  /**
37
30
  * Possibly no plugins that can compress, just return the data.
38
31
  */
39
-
40
-
41
32
  return data;
42
33
  };
43
-
44
34
  exports.compress = compress;
45
-
46
35
  const decompress = async (pluginsContainer, data) => {
47
36
  const plugins = getCompressionPlugins(pluginsContainer);
48
-
49
37
  if (plugins.length === 0) {
50
38
  return data;
51
39
  }
52
-
53
40
  for (const plugin of plugins) {
54
41
  if (plugin.canDecompress(data) === false) {
55
42
  continue;
56
43
  }
57
-
58
44
  return await plugin.decompress(data);
59
45
  }
60
46
  /**
61
47
  * Possibly no plugins that can decompress, just return the data.
62
48
  */
63
-
64
-
65
49
  return data;
66
50
  };
67
-
68
51
  exports.decompress = decompress;
@@ -1 +1 @@
1
- {"version":3,"names":["getCompressionPlugins","plugins","byType","CompressionPlugin","type","reverse","compress","pluginsContainer","data","length","console","log","plugin","canCompress","decompress","canDecompress"],"sources":["compression.ts"],"sourcesContent":["import { CompressionPlugin } from \"~/plugins/definition/CompressionPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\n/**\n * Get the compression plugins, in reverse order, because we want to use the last one added - first.\n */\nconst getCompressionPlugins = (plugins: PluginsContainer): CompressionPlugin[] => {\n return plugins.byType<CompressionPlugin>(CompressionPlugin.type).reverse();\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 const plugins = getCompressionPlugins(pluginsContainer);\n if (plugins.length === 0) {\n console.log(\"No compression plugins\");\n return data;\n }\n for (const plugin of plugins) {\n if (plugin.canCompress(data) === false) {\n continue;\n }\n return await plugin.compress(data);\n }\n /**\n * Possibly no plugins that can compress, just return the data.\n */\n return data;\n};\n\nexport const decompress = async (\n pluginsContainer: PluginsContainer,\n data: Record<string, any>\n): Promise<Record<string, any>> => {\n const plugins = getCompressionPlugins(pluginsContainer);\n if (plugins.length === 0) {\n return data;\n }\n for (const plugin of plugins) {\n if (plugin.canDecompress(data) === false) {\n continue;\n }\n return await plugin.decompress(data);\n }\n /**\n * Possibly no plugins that can decompress, just return the data.\n */\n return data;\n};\n"],"mappings":";;;;;;;AAAA;;AAGA;AACA;AACA;AACA,MAAMA,qBAAqB,GAAIC,OAAD,IAAoD;EAC9E,OAAOA,OAAO,CAACC,MAAR,CAAkCC,oCAAA,CAAkBC,IAApD,EAA0DC,OAA1D,EAAP;AACH,CAFD;AAGA;AACA;AACA;;;AACO,MAAMC,QAAQ,GAAG,OACpBC,gBADoB,EAEpBC,IAFoB,KAGW;EAC/B,MAAMP,OAAO,GAAGD,qBAAqB,CAACO,gBAAD,CAArC;;EACA,IAAIN,OAAO,CAACQ,MAAR,KAAmB,CAAvB,EAA0B;IACtBC,OAAO,CAACC,GAAR,CAAY,wBAAZ;IACA,OAAOH,IAAP;EACH;;EACD,KAAK,MAAMI,MAAX,IAAqBX,OAArB,EAA8B;IAC1B,IAAIW,MAAM,CAACC,WAAP,CAAmBL,IAAnB,MAA6B,KAAjC,EAAwC;MACpC;IACH;;IACD,OAAO,MAAMI,MAAM,CAACN,QAAP,CAAgBE,IAAhB,CAAb;EACH;EACD;AACJ;AACA;;;EACI,OAAOA,IAAP;AACH,CAnBM;;;;AAqBA,MAAMM,UAAU,GAAG,OACtBP,gBADsB,EAEtBC,IAFsB,KAGS;EAC/B,MAAMP,OAAO,GAAGD,qBAAqB,CAACO,gBAAD,CAArC;;EACA,IAAIN,OAAO,CAACQ,MAAR,KAAmB,CAAvB,EAA0B;IACtB,OAAOD,IAAP;EACH;;EACD,KAAK,MAAMI,MAAX,IAAqBX,OAArB,EAA8B;IAC1B,IAAIW,MAAM,CAACG,aAAP,CAAqBP,IAArB,MAA+B,KAAnC,EAA0C;MACtC;IACH;;IACD,OAAO,MAAMI,MAAM,CAACE,UAAP,CAAkBN,IAAlB,CAAb;EACH;EACD;AACJ;AACA;;;EACI,OAAOA,IAAP;AACH,CAlBM"}
1
+ {"version":3,"names":["getCompressionPlugins","plugins","byType","CompressionPlugin","type","reverse","compress","pluginsContainer","data","length","console","log","plugin","canCompress","decompress","canDecompress"],"sources":["compression.ts"],"sourcesContent":["import { CompressionPlugin } from \"~/plugins/definition/CompressionPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\n/**\n * Get the compression plugins, in reverse order, because we want to use the last one added - first.\n */\nconst getCompressionPlugins = (plugins: PluginsContainer): CompressionPlugin[] => {\n return plugins.byType<CompressionPlugin>(CompressionPlugin.type).reverse();\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 const plugins = getCompressionPlugins(pluginsContainer);\n if (plugins.length === 0) {\n console.log(\"No compression plugins\");\n return data;\n }\n for (const plugin of plugins) {\n if (plugin.canCompress(data) === false) {\n continue;\n }\n return await plugin.compress(data);\n }\n /**\n * Possibly no plugins that can compress, just return the data.\n */\n return data;\n};\n\nexport const decompress = async (\n pluginsContainer: PluginsContainer,\n data: Record<string, any>\n): Promise<Record<string, any>> => {\n const plugins = getCompressionPlugins(pluginsContainer);\n if (plugins.length === 0) {\n return data;\n }\n for (const plugin of plugins) {\n if (plugin.canDecompress(data) === false) {\n continue;\n }\n return await plugin.decompress(data);\n }\n /**\n * Possibly no plugins that can decompress, just return the data.\n */\n return data;\n};\n"],"mappings":";;;;;;AAAA;AAGA;AACA;AACA;AACA,MAAMA,qBAAqB,GAAIC,OAAyB,IAA0B;EAC9E,OAAOA,OAAO,CAACC,MAAM,CAAoBC,oCAAiB,CAACC,IAAI,CAAC,CAACC,OAAO,EAAE;AAC9E,CAAC;AACD;AACA;AACA;AACO,MAAMC,QAAQ,GAAG,OACpBC,gBAAkC,EAClCC,IAAyB,KACM;EAC/B,MAAMP,OAAO,GAAGD,qBAAqB,CAACO,gBAAgB,CAAC;EACvD,IAAIN,OAAO,CAACQ,MAAM,KAAK,CAAC,EAAE;IACtBC,OAAO,CAACC,GAAG,CAAC,wBAAwB,CAAC;IACrC,OAAOH,IAAI;EACf;EACA,KAAK,MAAMI,MAAM,IAAIX,OAAO,EAAE;IAC1B,IAAIW,MAAM,CAACC,WAAW,CAACL,IAAI,CAAC,KAAK,KAAK,EAAE;MACpC;IACJ;IACA,OAAO,MAAMI,MAAM,CAACN,QAAQ,CAACE,IAAI,CAAC;EACtC;EACA;AACJ;AACA;EACI,OAAOA,IAAI;AACf,CAAC;AAAC;AAEK,MAAMM,UAAU,GAAG,OACtBP,gBAAkC,EAClCC,IAAyB,KACM;EAC/B,MAAMP,OAAO,GAAGD,qBAAqB,CAACO,gBAAgB,CAAC;EACvD,IAAIN,OAAO,CAACQ,MAAM,KAAK,CAAC,EAAE;IACtB,OAAOD,IAAI;EACf;EACA,KAAK,MAAMI,MAAM,IAAIX,OAAO,EAAE;IAC1B,IAAIW,MAAM,CAACG,aAAa,CAACP,IAAI,CAAC,KAAK,KAAK,EAAE;MACtC;IACJ;IACA,OAAO,MAAMI,MAAM,CAACE,UAAU,CAACN,IAAI,CAAC;EACxC;EACA;AACJ;AACA;EACI,OAAOA,IAAI;AACf,CAAC;AAAC"}
package/cursors.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { PrimitiveValue } from "./types";
1
2
  /**
2
3
  * Encode a received cursor value into something that can be passed on to the user.
3
4
  */
@@ -6,4 +7,4 @@ export declare const encodeCursor: (cursor?: string | string[] | null) => string
6
7
  * Decode a received value into a Elasticsearch cursor.
7
8
  * If no value is received or is not decodable, return undefined.
8
9
  */
9
- export declare const decodeCursor: (cursor?: string | null) => string[] | string | undefined;
10
+ export declare const decodeCursor: (cursor?: string | null) => PrimitiveValue[] | undefined;
package/cursors.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.encodeCursor = exports.decodeCursor = void 0;
7
-
8
7
  /**
9
8
  * Encode a received cursor value into something that can be passed on to the user.
10
9
  */
@@ -12,38 +11,33 @@ const encodeCursor = cursor => {
12
11
  if (!cursor) {
13
12
  return undefined;
14
13
  }
15
-
16
14
  cursor = Array.isArray(cursor) ? cursor.map(encodeURIComponent) : encodeURIComponent(cursor);
17
-
18
15
  try {
19
16
  return Buffer.from(JSON.stringify(cursor)).toString("base64");
20
17
  } catch (ex) {
21
18
  console.error(ex.message);
22
19
  }
23
-
24
20
  return undefined;
25
21
  };
26
22
  /**
27
23
  * Decode a received value into a Elasticsearch cursor.
28
24
  * If no value is received or is not decodable, return undefined.
29
25
  */
30
-
31
-
32
26
  exports.encodeCursor = encodeCursor;
33
-
34
27
  const decodeCursor = cursor => {
35
28
  if (!cursor) {
36
29
  return undefined;
37
30
  }
38
-
39
31
  try {
40
32
  const value = JSON.parse(Buffer.from(cursor, "base64").toString("ascii"));
41
- return Array.isArray(value) ? value.map(decodeURIComponent) : decodeURIComponent(value);
33
+ if (Array.isArray(value)) {
34
+ return value.map(decodeURIComponent);
35
+ }
36
+ const decoded = decodeURIComponent(value);
37
+ return decoded ? [decoded] : undefined;
42
38
  } catch (ex) {
43
39
  console.error(ex.message);
44
40
  }
45
-
46
41
  return undefined;
47
42
  };
48
-
49
43
  exports.decodeCursor = decodeCursor;
package/cursors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["encodeCursor","cursor","undefined","Array","isArray","map","encodeURIComponent","Buffer","from","JSON","stringify","toString","ex","console","error","message","decodeCursor","value","parse","decodeURIComponent"],"sources":["cursors.ts"],"sourcesContent":["/**\n * Encode a received cursor value into something that can be passed on to the user.\n */\nexport const encodeCursor = (cursor?: string | string[] | null): string | undefined => {\n if (!cursor) {\n return undefined;\n }\n\n cursor = Array.isArray(cursor) ? cursor.map(encodeURIComponent) : encodeURIComponent(cursor);\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): string[] | string | undefined => {\n if (!cursor) {\n return undefined;\n }\n try {\n const value = JSON.parse(Buffer.from(cursor, \"base64\").toString(\"ascii\"));\n\n return Array.isArray(value) ? value.map(decodeURIComponent) : decodeURIComponent(value);\n } catch (ex) {\n console.error(ex.message);\n }\n return undefined;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACO,MAAMA,YAAY,GAAIC,MAAD,IAA2D;EACnF,IAAI,CAACA,MAAL,EAAa;IACT,OAAOC,SAAP;EACH;;EAEDD,MAAM,GAAGE,KAAK,CAACC,OAAN,CAAcH,MAAd,IAAwBA,MAAM,CAACI,GAAP,CAAWC,kBAAX,CAAxB,GAAyDA,kBAAkB,CAACL,MAAD,CAApF;;EAEA,IAAI;IACA,OAAOM,MAAM,CAACC,IAAP,CAAYC,IAAI,CAACC,SAAL,CAAeT,MAAf,CAAZ,EAAoCU,QAApC,CAA6C,QAA7C,CAAP;EACH,CAFD,CAEE,OAAOC,EAAP,EAAW;IACTC,OAAO,CAACC,KAAR,CAAcF,EAAE,CAACG,OAAjB;EACH;;EACD,OAAOb,SAAP;AACH,CAbM;AAcP;AACA;AACA;AACA;;;;;AACO,MAAMc,YAAY,GAAIf,MAAD,IAA2D;EACnF,IAAI,CAACA,MAAL,EAAa;IACT,OAAOC,SAAP;EACH;;EACD,IAAI;IACA,MAAMe,KAAK,GAAGR,IAAI,CAACS,KAAL,CAAWX,MAAM,CAACC,IAAP,CAAYP,MAAZ,EAAoB,QAApB,EAA8BU,QAA9B,CAAuC,OAAvC,CAAX,CAAd;IAEA,OAAOR,KAAK,CAACC,OAAN,CAAca,KAAd,IAAuBA,KAAK,CAACZ,GAAN,CAAUc,kBAAV,CAAvB,GAAuDA,kBAAkB,CAACF,KAAD,CAAhF;EACH,CAJD,CAIE,OAAOL,EAAP,EAAW;IACTC,OAAO,CAACC,KAAR,CAAcF,EAAE,CAACG,OAAjB;EACH;;EACD,OAAOb,SAAP;AACH,CAZM"}
1
+ {"version":3,"names":["encodeCursor","cursor","undefined","Array","isArray","map","encodeURIComponent","Buffer","from","JSON","stringify","toString","ex","console","error","message","decodeCursor","value","parse","decodeURIComponent","decoded"],"sources":["cursors.ts"],"sourcesContent":["import { 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 = (cursor?: string | string[] | null): string | undefined => {\n if (!cursor) {\n return undefined;\n }\n\n cursor = Array.isArray(cursor) ? cursor.map(encodeURIComponent) : encodeURIComponent(cursor);\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.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,MAAiC,IAAyB;EACnF,IAAI,CAACA,MAAM,EAAE;IACT,OAAOC,SAAS;EACpB;EAEAD,MAAM,GAAGE,KAAK,CAACC,OAAO,CAACH,MAAM,CAAC,GAAGA,MAAM,CAACI,GAAG,CAACC,kBAAkB,CAAC,GAAGA,kBAAkB,CAACL,MAAM,CAAC;EAE5F,IAAI;IACA,OAAOM,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACT,MAAM,CAAC,CAAC,CAACU,QAAQ,CAAC,QAAQ,CAAC;EACjE,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAACG,OAAO,CAAC;EAC7B;EACA,OAAOb,SAAS;AACpB,CAAC;AACD;AACA;AACA;AACA;AAHA;AAIO,MAAMc,YAAY,GAAIf,MAAsB,IAAmC;EAClF,IAAI,CAACA,MAAM,EAAE;IACT,OAAOC,SAAS;EACpB;EACA,IAAI;IACA,MAAMe,KAAK,GAAGR,IAAI,CAACS,KAAK,CAACX,MAAM,CAACC,IAAI,CAACP,MAAM,EAAE,QAAQ,CAAC,CAACU,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzE,IAAIR,KAAK,CAACC,OAAO,CAACa,KAAK,CAAC,EAAE;MACtB,OAAOA,KAAK,CAACZ,GAAG,CAACc,kBAAkB,CAAC;IACxC;IACA,MAAMC,OAAO,GAAGD,kBAAkB,CAACF,KAAK,CAAC;IACzC,OAAOG,OAAO,GAAG,CAACA,OAAO,CAAC,GAAGlB,SAAS;EAC1C,CAAC,CAAC,OAAOU,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAACG,OAAO,CAAC;EAC7B;EACA,OAAOb,SAAS;AACpB,CAAC;AAAC"}
package/index.d.ts CHANGED
@@ -2,6 +2,18 @@ import { ElasticsearchContext } from "./types";
2
2
  import { ContextPlugin } from "@webiny/api";
3
3
  import { ElasticsearchClientOptions } from "./client";
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 { createGzipCompression } from "./plugins/GzipCompression";
5
17
  /**
6
18
  * We must accept either Elasticsearch client or options that create the client.
7
19
  */
package/index.js CHANGED
@@ -1,22 +1,158 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
7
+ var _exportNames = {
8
+ createGzipCompression: true
9
+ };
10
+ Object.defineProperty(exports, "createGzipCompression", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _GzipCompression.createGzipCompression;
14
+ }
15
+ });
8
16
  exports.default = void 0;
9
-
10
17
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
18
  var _api = require("@webiny/api");
13
-
14
19
  var _client = require("./client");
15
-
20
+ Object.keys(_client).forEach(function (key) {
21
+ if (key === "default" || key === "__esModule") return;
22
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
23
+ if (key in exports && exports[key] === _client[key]) return;
24
+ Object.defineProperty(exports, key, {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _client[key];
28
+ }
29
+ });
30
+ });
16
31
  var _operators = require("./operators");
17
-
32
+ Object.keys(_operators).forEach(function (key) {
33
+ if (key === "default" || key === "__esModule") return;
34
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
35
+ if (key in exports && exports[key] === _operators[key]) return;
36
+ Object.defineProperty(exports, key, {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _operators[key];
40
+ }
41
+ });
42
+ });
18
43
  var _elasticsearch = require("@elastic/elasticsearch");
19
-
44
+ var _indexConfiguration = require("./indexConfiguration");
45
+ Object.keys(_indexConfiguration).forEach(function (key) {
46
+ if (key === "default" || key === "__esModule") return;
47
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
48
+ if (key in exports && exports[key] === _indexConfiguration[key]) return;
49
+ Object.defineProperty(exports, key, {
50
+ enumerable: true,
51
+ get: function () {
52
+ return _indexConfiguration[key];
53
+ }
54
+ });
55
+ });
56
+ var _plugins = require("./plugins");
57
+ Object.keys(_plugins).forEach(function (key) {
58
+ if (key === "default" || key === "__esModule") return;
59
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
60
+ if (key in exports && exports[key] === _plugins[key]) return;
61
+ Object.defineProperty(exports, key, {
62
+ enumerable: true,
63
+ get: function () {
64
+ return _plugins[key];
65
+ }
66
+ });
67
+ });
68
+ var _sort = require("./sort");
69
+ Object.keys(_sort).forEach(function (key) {
70
+ if (key === "default" || key === "__esModule") return;
71
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
72
+ if (key in exports && exports[key] === _sort[key]) return;
73
+ Object.defineProperty(exports, key, {
74
+ enumerable: true,
75
+ get: function () {
76
+ return _sort[key];
77
+ }
78
+ });
79
+ });
80
+ var _indices = require("./indices");
81
+ Object.keys(_indices).forEach(function (key) {
82
+ if (key === "default" || key === "__esModule") return;
83
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
84
+ if (key in exports && exports[key] === _indices[key]) return;
85
+ Object.defineProperty(exports, key, {
86
+ enumerable: true,
87
+ get: function () {
88
+ return _indices[key];
89
+ }
90
+ });
91
+ });
92
+ var _where = require("./where");
93
+ Object.keys(_where).forEach(function (key) {
94
+ if (key === "default" || key === "__esModule") return;
95
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
96
+ if (key in exports && exports[key] === _where[key]) return;
97
+ Object.defineProperty(exports, key, {
98
+ enumerable: true,
99
+ get: function () {
100
+ return _where[key];
101
+ }
102
+ });
103
+ });
104
+ var _limit = require("./limit");
105
+ Object.keys(_limit).forEach(function (key) {
106
+ if (key === "default" || key === "__esModule") return;
107
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
108
+ if (key in exports && exports[key] === _limit[key]) return;
109
+ Object.defineProperty(exports, key, {
110
+ enumerable: true,
111
+ get: function () {
112
+ return _limit[key];
113
+ }
114
+ });
115
+ });
116
+ var _normalize = require("./normalize");
117
+ Object.keys(_normalize).forEach(function (key) {
118
+ if (key === "default" || key === "__esModule") return;
119
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
120
+ if (key in exports && exports[key] === _normalize[key]) return;
121
+ Object.defineProperty(exports, key, {
122
+ enumerable: true,
123
+ get: function () {
124
+ return _normalize[key];
125
+ }
126
+ });
127
+ });
128
+ var _compression = require("./compression");
129
+ Object.keys(_compression).forEach(function (key) {
130
+ if (key === "default" || key === "__esModule") return;
131
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
132
+ if (key in exports && exports[key] === _compression[key]) return;
133
+ Object.defineProperty(exports, key, {
134
+ enumerable: true,
135
+ get: function () {
136
+ return _compression[key];
137
+ }
138
+ });
139
+ });
140
+ var _cursors = require("./cursors");
141
+ Object.keys(_cursors).forEach(function (key) {
142
+ if (key === "default" || key === "__esModule") return;
143
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
144
+ if (key in exports && exports[key] === _cursors[key]) return;
145
+ Object.defineProperty(exports, key, {
146
+ enumerable: true,
147
+ get: function () {
148
+ return _cursors[key];
149
+ }
150
+ });
151
+ });
152
+ var _GzipCompression = require("./plugins/GzipCompression");
153
+ /**
154
+ * TODO File should contain only exports from other files.
155
+ */
20
156
  /**
21
157
  * We must accept either Elasticsearch client or options that create the client.
22
158
  */
@@ -28,11 +164,8 @@ var _default = params => {
28
164
  /**
29
165
  * Initialize the Elasticsearch client.
30
166
  */
31
-
32
-
33
167
  context.elasticsearch = params instanceof _elasticsearch.Client ? params : (0, _client.createElasticsearchClient)(params);
34
168
  context.plugins.register((0, _operators.getElasticsearchOperators)());
35
169
  });
36
170
  };
37
-
38
171
  exports.default = _default;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["params","ContextPlugin","context","elasticsearch","WebinyError","Client","createElasticsearchClient","plugins","register","getElasticsearchOperators"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ElasticsearchContext } from \"~/types\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { createElasticsearchClient, ElasticsearchClientOptions } from \"~/client\";\nimport { getElasticsearchOperators } from \"~/operators\";\nimport { Client } from \"@elastic/elasticsearch\";\n\n/**\n * We must accept either Elasticsearch client or options that create the client.\n */\nexport default (\n params: ElasticsearchClientOptions | Client\n): ContextPlugin<ElasticsearchContext> => {\n return new ContextPlugin<ElasticsearchContext>(context => {\n if (context.elasticsearch) {\n throw new WebinyError(\n \"Elasticsearch client is already initialized, no need to define it again. Check your code for duplicate initializations.\",\n \"ELASTICSEARCH_ALREADY_INITIALIZED\"\n );\n }\n /**\n * Initialize the Elasticsearch client.\n */\n context.elasticsearch =\n params instanceof Client ? params : createElasticsearchClient(params);\n\n context.plugins.register(getElasticsearchOperators());\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AAEA;AACA;AACA;eAEIA,MADW,IAE2B;EACtC,OAAO,IAAIC,kBAAJ,CAAwCC,OAAO,IAAI;IACtD,IAAIA,OAAO,CAACC,aAAZ,EAA2B;MACvB,MAAM,IAAIC,cAAJ,CACF,yHADE,EAEF,mCAFE,CAAN;IAIH;IACD;AACR;AACA;;;IACQF,OAAO,CAACC,aAAR,GACIH,MAAM,YAAYK,qBAAlB,GAA2BL,MAA3B,GAAoC,IAAAM,iCAAA,EAA0BN,MAA1B,CADxC;IAGAE,OAAO,CAACK,OAAR,CAAgBC,QAAhB,CAAyB,IAAAC,oCAAA,GAAzB;EACH,CAdM,CAAP;AAeH,C"}
1
+ {"version":3,"names":["params","ContextPlugin","context","elasticsearch","WebinyError","Client","createElasticsearchClient","plugins","register","getElasticsearchOperators"],"sources":["index.ts"],"sourcesContent":["/**\n * TODO File should contain only exports from other files.\n */\nimport WebinyError from \"@webiny/error\";\nimport { ElasticsearchContext } from \"~/types\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { createElasticsearchClient, ElasticsearchClientOptions } from \"~/client\";\nimport { getElasticsearchOperators } from \"~/operators\";\nimport { Client } from \"@elastic/elasticsearch\";\n\nexport * from \"./indexConfiguration\";\nexport * from \"./plugins\";\nexport * from \"./sort\";\nexport * from \"./indices\";\nexport * from \"./where\";\nexport * from \"./limit\";\nexport * from \"./normalize\";\nexport * from \"./compression\";\nexport * from \"./operators\";\nexport * from \"./cursors\";\nexport * from \"./client\";\nexport { createGzipCompression } from \"./plugins/GzipCompression\";\n\n/**\n * We must accept either Elasticsearch client or options that create the client.\n */\nexport default (\n params: ElasticsearchClientOptions | Client\n): ContextPlugin<ElasticsearchContext> => {\n return new ContextPlugin<ElasticsearchContext>(context => {\n if (context.elasticsearch) {\n throw new WebinyError(\n \"Elasticsearch client is already initialized, no need to define it again. Check your code for duplicate initializations.\",\n \"ELASTICSEARCH_ALREADY_INITIALIZED\"\n );\n }\n /**\n * Initialize the Elasticsearch client.\n */\n context.elasticsearch =\n params instanceof Client ? params : createElasticsearchClient(params);\n\n context.plugins.register(getElasticsearchOperators());\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAGA;AAEA;AACA;AAcA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAbA;AAWA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAVA;AAEA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAEA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAEA;AArBA;AACA;AACA;AAqBA;AACA;AACA;AAFA,eAIIA,MAA2C,IACL;EACtC,OAAO,IAAIC,kBAAa,CAAuBC,OAAO,IAAI;IACtD,IAAIA,OAAO,CAACC,aAAa,EAAE;MACvB,MAAM,IAAIC,cAAW,CACjB,yHAAyH,EACzH,mCAAmC,CACtC;IACL;IACA;AACR;AACA;IACQF,OAAO,CAACC,aAAa,GACjBH,MAAM,YAAYK,qBAAM,GAAGL,MAAM,GAAG,IAAAM,iCAAyB,EAACN,MAAM,CAAC;IAEzEE,OAAO,CAACK,OAAO,CAACC,QAAQ,CAAC,IAAAC,oCAAyB,GAAE,CAAC;EACzD,CAAC,CAAC;AACN,CAAC;AAAA"}
@@ -1,2 +1,6 @@
1
1
  import { ElasticsearchIndexRequestBody } from "../types";
2
- export declare const base: ElasticsearchIndexRequestBody;
2
+ interface Modifier {
3
+ (config: ElasticsearchIndexRequestBody): ElasticsearchIndexRequestBody;
4
+ }
5
+ export declare const getBaseConfiguration: (modifier?: Modifier) => ElasticsearchIndexRequestBody;
6
+ export {};
@@ -3,26 +3,26 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.base = void 0;
7
-
6
+ exports.getBaseConfiguration = void 0;
8
7
  var _common = require("./common");
9
-
10
- const base = {
8
+ const config = {
11
9
  mappings: {
12
- dynamic_templates: _common.dynamicTemplateDates.concat([{
13
- strings: {
14
- match_mapping_type: "string",
15
- mapping: {
16
- type: "text",
17
- fields: {
18
- keyword: {
19
- type: "keyword",
20
- ignore_above: 256
10
+ dynamic_templates: (0, _common.getCommonMappings)(mappings => {
11
+ return mappings.concat([{
12
+ strings: {
13
+ match_mapping_type: "string",
14
+ mapping: {
15
+ type: "text",
16
+ fields: {
17
+ keyword: {
18
+ type: "keyword",
19
+ ignore_above: 256
20
+ }
21
21
  }
22
22
  }
23
23
  }
24
- }
25
- }]),
24
+ }]);
25
+ }),
26
26
  properties: {
27
27
  rawValues: {
28
28
  type: "object",
@@ -31,4 +31,10 @@ const base = {
31
31
  }
32
32
  }
33
33
  };
34
- exports.base = base;
34
+ const getBaseConfiguration = modifier => {
35
+ if (!modifier) {
36
+ return config;
37
+ }
38
+ return modifier(config);
39
+ };
40
+ exports.getBaseConfiguration = getBaseConfiguration;
@@ -1 +1 @@
1
- {"version":3,"names":["base","mappings","dynamic_templates","dynamicTemplateDates","concat","strings","match_mapping_type","mapping","type","fields","keyword","ignore_above","properties","rawValues","enabled"],"sources":["base.ts"],"sourcesContent":["import { ElasticsearchIndexRequestBody } from \"~/types\";\nimport { dynamicTemplateDates } from \"./common\";\n\nexport const base: ElasticsearchIndexRequestBody = {\n mappings: {\n dynamic_templates: dynamicTemplateDates.concat([\n {\n strings: {\n match_mapping_type: \"string\",\n mapping: {\n type: \"text\",\n fields: {\n keyword: {\n type: \"keyword\",\n ignore_above: 256\n }\n }\n }\n }\n }\n ]),\n properties: {\n rawValues: {\n type: \"object\",\n enabled: false\n }\n }\n }\n};\n"],"mappings":";;;;;;;AACA;;AAEO,MAAMA,IAAmC,GAAG;EAC/CC,QAAQ,EAAE;IACNC,iBAAiB,EAAEC,4BAAA,CAAqBC,MAArB,CAA4B,CAC3C;MACIC,OAAO,EAAE;QACLC,kBAAkB,EAAE,QADf;QAELC,OAAO,EAAE;UACLC,IAAI,EAAE,MADD;UAELC,MAAM,EAAE;YACJC,OAAO,EAAE;cACLF,IAAI,EAAE,SADD;cAELG,YAAY,EAAE;YAFT;UADL;QAFH;MAFJ;IADb,CAD2C,CAA5B,CADb;IAiBNC,UAAU,EAAE;MACRC,SAAS,EAAE;QACPL,IAAI,EAAE,QADC;QAEPM,OAAO,EAAE;MAFF;IADH;EAjBN;AADqC,CAA5C"}
1
+ {"version":3,"names":["config","mappings","dynamic_templates","getCommonMappings","concat","strings","match_mapping_type","mapping","type","fields","keyword","ignore_above","properties","rawValues","enabled","getBaseConfiguration","modifier"],"sources":["base.ts"],"sourcesContent":["import { ElasticsearchIndexRequestBody } from \"~/types\";\nimport { getCommonMappings } from \"./common\";\n\nconst config: ElasticsearchIndexRequestBody = {\n mappings: {\n dynamic_templates: getCommonMappings(mappings => {\n return mappings.concat([\n {\n strings: {\n match_mapping_type: \"string\",\n mapping: {\n type: \"text\",\n fields: {\n keyword: {\n type: \"keyword\",\n ignore_above: 256\n }\n }\n }\n }\n }\n ]);\n }),\n properties: {\n rawValues: {\n type: \"object\",\n enabled: false\n }\n }\n }\n};\n\ninterface Modifier {\n (config: ElasticsearchIndexRequestBody): ElasticsearchIndexRequestBody;\n}\nexport const getBaseConfiguration = (modifier?: Modifier) => {\n if (!modifier) {\n return config;\n }\n return modifier(config);\n};\n"],"mappings":";;;;;;AACA;AAEA,MAAMA,MAAqC,GAAG;EAC1CC,QAAQ,EAAE;IACNC,iBAAiB,EAAE,IAAAC,yBAAiB,EAACF,QAAQ,IAAI;MAC7C,OAAOA,QAAQ,CAACG,MAAM,CAAC,CACnB;QACIC,OAAO,EAAE;UACLC,kBAAkB,EAAE,QAAQ;UAC5BC,OAAO,EAAE;YACLC,IAAI,EAAE,MAAM;YACZC,MAAM,EAAE;cACJC,OAAO,EAAE;gBACLF,IAAI,EAAE,SAAS;gBACfG,YAAY,EAAE;cAClB;YACJ;UACJ;QACJ;MACJ,CAAC,CACJ,CAAC;IACN,CAAC,CAAC;IACFC,UAAU,EAAE;MACRC,SAAS,EAAE;QACPL,IAAI,EAAE,QAAQ;QACdM,OAAO,EAAE;MACb;IACJ;EACJ;AACJ,CAAC;AAKM,MAAMC,oBAAoB,GAAIC,QAAmB,IAAK;EACzD,IAAI,CAACA,QAAQ,EAAE;IACX,OAAOhB,MAAM;EACjB;EACA,OAAOgB,QAAQ,CAAChB,MAAM,CAAC;AAC3B,CAAC;AAAC"}
@@ -1,5 +1,9 @@
1
1
  import { ElasticsearchIndexRequestBodyMappingsDynamicTemplate } from "../types";
2
+ interface Modifier {
3
+ (mappings: ElasticsearchIndexRequestBodyMappingsDynamicTemplate[]): ElasticsearchIndexRequestBodyMappingsDynamicTemplate[];
4
+ }
2
5
  /**
3
6
  * @internal
4
7
  */
5
- export declare const dynamicTemplateDates: ElasticsearchIndexRequestBodyMappingsDynamicTemplate[];
8
+ export declare const getCommonMappings: (cb?: Modifier) => ElasticsearchIndexRequestBodyMappingsDynamicTemplate[];
9
+ export {};
@@ -3,17 +3,39 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.dynamicTemplateDates = void 0;
7
-
6
+ exports.getCommonMappings = void 0;
7
+ const getDefaultMappings = () => {
8
+ return [{
9
+ dates: {
10
+ match: "^createdOn|savedOn|publishedOn$",
11
+ mapping: {
12
+ type: "date"
13
+ }
14
+ }
15
+ }, {
16
+ numbers: {
17
+ match: "number@*",
18
+ mapping: {
19
+ type: "scaled_float",
20
+ scaling_factor: 10000
21
+ }
22
+ }
23
+ }, {
24
+ booleans: {
25
+ match: "boolean@*",
26
+ mapping: {
27
+ type: "boolean"
28
+ }
29
+ }
30
+ }];
31
+ };
8
32
  /**
9
33
  * @internal
10
34
  */
11
- const dynamicTemplateDates = [{
12
- dates: {
13
- match: "^createdOn|savedOn|publishedOn$",
14
- mapping: {
15
- type: "date"
16
- }
35
+ const getCommonMappings = cb => {
36
+ if (!cb) {
37
+ return getDefaultMappings();
17
38
  }
18
- }];
19
- exports.dynamicTemplateDates = dynamicTemplateDates;
39
+ return cb(getDefaultMappings());
40
+ };
41
+ exports.getCommonMappings = getCommonMappings;
@@ -1 +1 @@
1
- {"version":3,"names":["dynamicTemplateDates","dates","match","mapping","type"],"sources":["common.ts"],"sourcesContent":["import { ElasticsearchIndexRequestBodyMappingsDynamicTemplate } from \"~/types\";\n\n/**\n * @internal\n */\nexport const dynamicTemplateDates: ElasticsearchIndexRequestBodyMappingsDynamicTemplate[] = [\n {\n dates: {\n match: \"^createdOn|savedOn|publishedOn$\",\n mapping: {\n type: \"date\"\n }\n }\n }\n];\n"],"mappings":";;;;;;;AAEA;AACA;AACA;AACO,MAAMA,oBAA4E,GAAG,CACxF;EACIC,KAAK,EAAE;IACHC,KAAK,EAAE,iCADJ;IAEHC,OAAO,EAAE;MACLC,IAAI,EAAE;IADD;EAFN;AADX,CADwF,CAArF"}
1
+ {"version":3,"names":["getDefaultMappings","dates","match","mapping","type","numbers","scaling_factor","booleans","getCommonMappings","cb"],"sources":["common.ts"],"sourcesContent":["import { ElasticsearchIndexRequestBodyMappingsDynamicTemplate } from \"~/types\";\n\nconst getDefaultMappings = (): ElasticsearchIndexRequestBodyMappingsDynamicTemplate[] => {\n return [\n {\n dates: {\n match: \"^createdOn|savedOn|publishedOn$\",\n mapping: {\n type: \"date\"\n }\n }\n },\n {\n numbers: {\n match: \"number@*\",\n mapping: {\n type: \"scaled_float\",\n scaling_factor: 10000\n }\n }\n },\n {\n booleans: {\n match: \"boolean@*\",\n mapping: {\n type: \"boolean\"\n }\n }\n }\n ];\n};\n\ninterface Modifier {\n (\n mappings: ElasticsearchIndexRequestBodyMappingsDynamicTemplate[]\n ): ElasticsearchIndexRequestBodyMappingsDynamicTemplate[];\n}\n/**\n * @internal\n */\nexport const getCommonMappings = (\n cb?: Modifier\n): ElasticsearchIndexRequestBodyMappingsDynamicTemplate[] => {\n if (!cb) {\n return getDefaultMappings();\n }\n\n return cb(getDefaultMappings());\n};\n"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,GAAG,MAA8D;EACrF,OAAO,CACH;IACIC,KAAK,EAAE;MACHC,KAAK,EAAE,iCAAiC;MACxCC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,EACD;IACIC,OAAO,EAAE;MACLH,KAAK,EAAE,UAAU;MACjBC,OAAO,EAAE;QACLC,IAAI,EAAE,cAAc;QACpBE,cAAc,EAAE;MACpB;IACJ;EACJ,CAAC,EACD;IACIC,QAAQ,EAAE;MACNL,KAAK,EAAE,WAAW;MAClBC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,CACJ;AACL,CAAC;AAOD;AACA;AACA;AACO,MAAMI,iBAAiB,GAC1BC,EAAa,IAC4C;EACzD,IAAI,CAACA,EAAE,EAAE;IACL,OAAOT,kBAAkB,EAAE;EAC/B;EAEA,OAAOS,EAAE,CAACT,kBAAkB,EAAE,CAAC;AACnC,CAAC;AAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./base";
2
+ export * from "./common";
3
+ export * from "./japanese";