@webiny/api-elasticsearch 5.39.0-beta.1 → 5.39.0-beta.3

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 (52) hide show
  1. package/client.d.ts +1 -0
  2. package/client.js +77 -35
  3. package/client.js.map +1 -1
  4. package/package.json +8 -16
  5. package/plugins/definition/CompressionPlugin.js +18 -4
  6. package/plugins/definition/CompressionPlugin.js.map +1 -1
  7. package/plugins/definition/ElasticsearchBodyModifierPlugin.js +0 -2
  8. package/plugins/definition/ElasticsearchBodyModifierPlugin.js.map +1 -1
  9. package/plugins/definition/ElasticsearchFieldPlugin.js +5 -13
  10. package/plugins/definition/ElasticsearchFieldPlugin.js.map +1 -1
  11. package/plugins/definition/ElasticsearchIndexPlugin.js +3 -5
  12. package/plugins/definition/ElasticsearchIndexPlugin.js.map +1 -1
  13. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js +4 -4
  14. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js.map +1 -1
  15. package/plugins/definition/ElasticsearchQueryModifierPlugin.js +0 -2
  16. package/plugins/definition/ElasticsearchQueryModifierPlugin.js.map +1 -1
  17. package/plugins/definition/ElasticsearchSortModifierPlugin.js +0 -2
  18. package/plugins/definition/ElasticsearchSortModifierPlugin.js.map +1 -1
  19. package/plugins/operator/andIn.js +1 -6
  20. package/plugins/operator/andIn.js.map +1 -1
  21. package/plugins/operator/between.js +1 -6
  22. package/plugins/operator/between.js.map +1 -1
  23. package/plugins/operator/contains.js +1 -6
  24. package/plugins/operator/contains.js.map +1 -1
  25. package/plugins/operator/equal.js +1 -6
  26. package/plugins/operator/equal.js.map +1 -1
  27. package/plugins/operator/gt.js +1 -6
  28. package/plugins/operator/gt.js.map +1 -1
  29. package/plugins/operator/gte.js +1 -6
  30. package/plugins/operator/gte.js.map +1 -1
  31. package/plugins/operator/in.js +1 -6
  32. package/plugins/operator/in.js.map +1 -1
  33. package/plugins/operator/japanese/contains.js +1 -6
  34. package/plugins/operator/japanese/contains.js.map +1 -1
  35. package/plugins/operator/lt.js +1 -6
  36. package/plugins/operator/lt.js.map +1 -1
  37. package/plugins/operator/lte.js +1 -6
  38. package/plugins/operator/lte.js.map +1 -1
  39. package/plugins/operator/not.js +1 -6
  40. package/plugins/operator/not.js.map +1 -1
  41. package/plugins/operator/notBetween.js +1 -6
  42. package/plugins/operator/notBetween.js.map +1 -1
  43. package/plugins/operator/notContains.js +1 -6
  44. package/plugins/operator/notContains.js.map +1 -1
  45. package/plugins/operator/notIn.js +1 -6
  46. package/plugins/operator/notIn.js.map +1 -1
  47. package/plugins/operator/notStartsWith.js +1 -6
  48. package/plugins/operator/notStartsWith.js.map +1 -1
  49. package/plugins/operator/startsWith.js +1 -6
  50. package/plugins/operator/startsWith.js.map +1 -1
  51. package/utils/createIndex.js +9 -6
  52. package/utils/createIndex.js.map +1 -1
package/client.d.ts CHANGED
@@ -2,4 +2,5 @@ import { Client, ClientOptions } from "@elastic/elasticsearch";
2
2
  export interface ElasticsearchClientOptions extends ClientOptions {
3
3
  endpoint?: string;
4
4
  }
5
+ export { Client, ClientOptions };
5
6
  export declare const createElasticsearchClient: (options: ElasticsearchClientOptions) => Client;
package/client.js CHANGED
@@ -4,45 +4,87 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
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
+ });
7
19
  exports.createElasticsearchClient = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
- var _elasticsearch = require("@elastic/elasticsearch");
11
- var _awsSdk = _interopRequireDefault(require("aws-sdk"));
12
- var _error = _interopRequireDefault(require("@webiny/error"));
13
20
  var _awsElasticsearchConnector = _interopRequireDefault(require("aws-elasticsearch-connector"));
14
- const _excluded = ["endpoint", "node"];
15
- /**
16
- * Package aws-elasticsearch-connector does not have types.
17
- */
18
- // @ts-ignore
21
+ var _crypto = _interopRequireDefault(require("crypto"));
22
+ var _error = _interopRequireDefault(require("@webiny/error"));
23
+ var _elasticsearch = require("@elastic/elasticsearch");
24
+ const clients = new Map();
25
+ const createClientKey = options => {
26
+ const key = JSON.stringify(options);
27
+ const hash = _crypto.default.createHash("sha1");
28
+ hash.update(key);
29
+ return hash.digest("hex");
30
+ };
19
31
  const createElasticsearchClient = options => {
20
- const {
21
- endpoint,
22
- node
23
- } = options,
24
- rest = (0, _objectWithoutProperties2.default)(options, _excluded);
25
- const clientOptions = (0, _objectSpread2.default)({
26
- node: endpoint || node
27
- }, rest);
28
- if (!clientOptions.auth) {
29
- /**
30
- * If no `auth` configuration is present, we setup AWS connector.
31
- */
32
- Object.assign(clientOptions, (0, _awsElasticsearchConnector.default)(_awsSdk.default.config));
33
- }
34
- try {
35
- return new _elasticsearch.Client(clientOptions);
36
- } catch (ex) {
37
- const data = (0, _objectSpread2.default)((0, _objectSpread2.default)({
38
- error: ex,
39
- node: endpoint || node
40
- }, rest), {}, {
41
- auth: undefined
42
- });
43
- console.log((0, _objectSpread2.default)({}, data));
44
- throw new _error.default("Could not connect to Elasticsearch.", "ELASTICSEARCH_CLIENT_ERROR", data);
32
+ const key = createClientKey(options);
33
+ const existing = clients.get(key);
34
+ if (existing) {
35
+ return existing;
45
36
  }
37
+ const cached = () => {
38
+ const {
39
+ endpoint,
40
+ node,
41
+ ...rest
42
+ } = options;
43
+ let clientOptions = {
44
+ node: endpoint || node,
45
+ ...rest
46
+ };
47
+ if (!clientOptions.auth) {
48
+ const region = String(process.env.AWS_REGION);
49
+ const credentials = {
50
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
51
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
52
+ sessionToken: process.env.AWS_SESSION_TOKEN
53
+ };
54
+ const errors = Object.keys(credentials).filter(key => {
55
+ const value = credentials[key];
56
+ return !value;
57
+ });
58
+ if (errors.length > 0) {
59
+ throw new _error.default(`Missing keys values: ${errors.join(", ")}`, "MISSING_AWS_CREDENTIALS");
60
+ }
61
+ clientOptions = {
62
+ ...clientOptions,
63
+ ...(0, _awsElasticsearchConnector.default)({
64
+ region,
65
+ // @ts-expect-error
66
+ credentials
67
+ })
68
+ };
69
+ }
70
+ try {
71
+ return new _elasticsearch.Client(clientOptions);
72
+ } catch (ex) {
73
+ const data = {
74
+ error: ex,
75
+ node: endpoint || node,
76
+ ...rest,
77
+ auth: undefined
78
+ };
79
+ console.log({
80
+ ...data
81
+ });
82
+ throw new _error.default("Could not connect to Elasticsearch.", "ELASTICSEARCH_CLIENT_ERROR", data);
83
+ }
84
+ };
85
+ const client = cached();
86
+ clients.set(key, client);
87
+ return client;
46
88
  };
47
89
  exports.createElasticsearchClient = createElasticsearchClient;
48
90
 
package/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_elasticsearch","require","_awsSdk","_interopRequireDefault","_error","_awsElasticsearchConnector","_excluded","createElasticsearchClient","options","endpoint","node","rest","_objectWithoutProperties2","default","clientOptions","_objectSpread2","auth","Object","assign","createAwsElasticsearchConnector","AWS","config","Client","ex","data","error","undefined","console","log","WebinyError","exports"],"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,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AAKA,IAAAI,0BAAA,GAAAF,sBAAA,CAAAF,OAAA;AAA0E,MAAAK,SAAA;AAJ1E;AACA;AACA;AACA;AAOO,MAAMC,yBAAyB,GAAIC,OAAmC,IAAK;EAC9E,MAAM;MAAEC,QAAQ;MAAEC;IAAc,CAAC,GAAGF,OAAO;IAAhBG,IAAI,OAAAC,yBAAA,CAAAC,OAAA,EAAKL,OAAO,EAAAF,SAAA;EAE3C,MAAMQ,aAA4B,OAAAC,cAAA,CAAAF,OAAA;IAC9BH,IAAI,EAAED,QAAQ,IAAIC;EAAI,GACnBC,IAAI,CACV;EAED,IAAI,CAACG,aAAa,CAACE,IAAI,EAAE;IACrB;AACR;AACA;IACQC,MAAM,CAACC,MAAM,CAACJ,aAAa,EAAE,IAAAK,kCAA+B,EAACC,eAAG,CAACC,MAAM,CAAC,CAAC;EAC7E;EAEA,IAAI;IACA,OAAO,IAAIC,qBAAM,CAACR,aAAa,CAAC;EACpC,CAAC,CAAC,OAAOS,EAAE,EAAE;IACT,MAAMC,IAAI,OAAAT,cAAA,CAAAF,OAAA,MAAAE,cAAA,CAAAF,OAAA;MACNY,KAAK,EAAEF,EAAE;MACTb,IAAI,EAAED,QAAQ,IAAIC;IAAI,GACnBC,IAAI;MACPK,IAAI,EAAEU;IAAS,EAClB;IACDC,OAAO,CAACC,GAAG,KAAAb,cAAA,CAAAF,OAAA,MACJW,IAAI,CACV,CAAC;IACF,MAAM,IAAIK,cAAW,CACjB,qCAAqC,EACrC,4BAA4B,EAC5BL,IACJ,CAAC;EACL;AACJ,CAAC;AAACM,OAAA,CAAAvB,yBAAA,GAAAA,yBAAA"}
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","log","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 // @ts-expect-error\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.log({\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,CAChB,wBAAuBN,MAAM,CAACO,IAAI,CAAC,IAAI,CAAE,EAAC,EAC3C,yBACJ,CAAC;MACL;MAEArB,aAAa,GAAG;QACZ,GAAGA,aAAa;QAChB,GAAG,IAAAsB,kCAA+B,EAAC;UAC/BpB,MAAM;UACN;UACAK;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,CAACC,GAAG,CAAC;QACR,GAAGJ;MACP,CAAC,CAAC;MACF,MAAM,IAAIL,cAAW,CACjB,qCAAqC,EACrC,4BAA4B,EAC5BK,IACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMK,MAAM,GAAGlC,MAAM,CAAC,CAAC;EAEvBf,OAAO,CAACkD,GAAG,CAAC9C,GAAG,EAAE6C,MAAM,CAAC;EACxB,OAAOA,MAAM;AACjB,CAAC;AAACE,OAAA,CAAAvC,yBAAA,GAAAA,yBAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-elasticsearch",
3
- "version": "5.39.0-beta.1",
3
+ "version": "5.39.0-beta.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/webiny/webiny-js.git",
@@ -13,19 +13,18 @@
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
15
  "@elastic/elasticsearch": "7.12.0",
16
- "@webiny/api": "5.39.0-beta.1",
17
- "@webiny/error": "5.39.0-beta.1",
18
- "@webiny/plugins": "5.39.0-beta.1",
19
- "@webiny/utils": "5.39.0-beta.1",
16
+ "@webiny/api": "5.39.0-beta.3",
17
+ "@webiny/error": "5.39.0-beta.3",
18
+ "@webiny/plugins": "5.39.0-beta.3",
19
+ "@webiny/utils": "5.39.0-beta.3",
20
20
  "aws-elasticsearch-connector": "9.2.0",
21
- "aws-sdk": "2.1310.0",
22
21
  "elastic-ts": "0.8.0"
23
22
  },
24
23
  "devDependencies": {
25
24
  "@babel/cli": "7.22.6",
26
25
  "@babel/core": "7.22.8",
27
- "@webiny/cli": "5.39.0-beta.1",
28
- "@webiny/project-utils": "5.39.0-beta.1",
26
+ "@webiny/cli": "5.39.0-beta.3",
27
+ "@webiny/project-utils": "5.39.0-beta.3",
29
28
  "rimraf": "3.0.2",
30
29
  "ttypescript": "1.5.15",
31
30
  "typescript": "4.7.4"
@@ -38,12 +37,5 @@
38
37
  "build": "yarn webiny run build",
39
38
  "watch": "yarn webiny run watch"
40
39
  },
41
- "adio": {
42
- "ignore": {
43
- "src": [
44
- "aws-sdk"
45
- ]
46
- }
47
- },
48
- "gitHead": "a22d4ab9fbb4ad35106687cbe17b51a84afd4976"
40
+ "gitHead": "3846541fd9c1764e6a8041f0b4208d720eb9c314"
49
41
  }
@@ -1,14 +1,28 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.CompressionPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _plugins = require("@webiny/plugins");
10
- class CompressionPlugin extends _plugins.Plugin {}
8
+ class CompressionPlugin extends _plugins.Plugin {
9
+ static type = "elasticsearch.compression";
10
+ /**
11
+ * Check if data can be compressed.
12
+ */
13
+
14
+ /**
15
+ * Pass the data to get the compressed one back.
16
+ */
17
+
18
+ /**
19
+ * Check if data can be decompressed.
20
+ */
21
+
22
+ /**
23
+ * Passed the compressed data to get the original data back.
24
+ */
25
+ }
11
26
  exports.CompressionPlugin = CompressionPlugin;
12
- (0, _defineProperty2.default)(CompressionPlugin, "type", "elasticsearch.compression");
13
27
 
14
28
  //# sourceMappingURL=CompressionPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","CompressionPlugin","Plugin","exports","_defineProperty2","default"],"sources":["CompressionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\n\nexport abstract class CompressionPlugin extends Plugin {\n public static override readonly type: string = \"elasticsearch.compression\";\n /**\n * Check if data can be compressed.\n */\n public abstract canCompress(data: any): boolean;\n /**\n * Pass the data to get the compressed one back.\n */\n public abstract compress(data: any): Promise<any>;\n /**\n * Check if data can be decompressed.\n */\n public abstract canDecompress(data: any): boolean;\n /**\n * Passed the compressed data to get the original data back.\n */\n public abstract decompress(data: any): Promise<any>;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEO,MAAeC,iBAAiB,SAASC,eAAM,CAAC;AAkBtDC,OAAA,CAAAF,iBAAA,GAAAA,iBAAA;AAAA,IAAAG,gBAAA,CAAAC,OAAA,EAlBqBJ,iBAAiB,UACY,2BAA2B"}
1
+ {"version":3,"names":["_plugins","require","CompressionPlugin","Plugin","type","exports"],"sources":["CompressionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\n\nexport abstract class CompressionPlugin extends Plugin {\n public static override readonly type: string = \"elasticsearch.compression\";\n /**\n * Check if data can be compressed.\n */\n public abstract canCompress(data: any): boolean;\n /**\n * Pass the data to get the compressed one back.\n */\n public abstract compress(data: any): Promise<any>;\n /**\n * Check if data can be decompressed.\n */\n public abstract canDecompress(data: any): boolean;\n /**\n * Passed the compressed data to get the original data back.\n */\n public abstract decompress(data: any): Promise<any>;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEO,MAAeC,iBAAiB,SAASC,eAAM,CAAC;EACnD,OAAgCC,IAAI,GAAW,2BAA2B;EAC1E;AACJ;AACA;;EAEI;AACJ;AACA;;EAEI;AACJ;AACA;;EAEI;AACJ;AACA;AAEA;AAACC,OAAA,CAAAH,iBAAA,GAAAA,iBAAA"}
@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.ElasticsearchBodyModifierPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
8
  var _error = _interopRequireDefault(require("@webiny/error"));
10
9
  var _plugins = require("@webiny/plugins");
11
10
  class ElasticsearchBodyModifierPlugin extends _plugins.Plugin {
12
11
  constructor(callable) {
13
12
  super();
14
- (0, _defineProperty2.default)(this, "callable", void 0);
15
13
  this.callable = callable;
16
14
  }
17
15
  modifyBody(params) {
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchBodyModifierPlugin","Plugin","constructor","callable","_defineProperty2","default","modifyBody","params","WebinyError","exports"],"sources":["ElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { SearchBody } from \"elastic-ts\";\n\nexport interface ModifyBodyParams {\n body: SearchBody;\n}\n\nexport interface ModifyBodyCallable<T extends ModifyBodyParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchBodyModifierPlugin<\n T extends ModifyBodyParams = ModifyBodyParams\n> extends Plugin {\n private readonly callable?: ModifyBodyCallable<T>;\n\n public constructor(callable?: ModifyBodyCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyBody(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the body.`,\n \"BODY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAWO,MAAeE,+BAA+B,SAE3CC,eAAM,CAAC;EAGNC,WAAWA,CAACC,QAAgC,EAAE;IACjD,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IACR,IAAI,CAACF,QAAQ,GAAGA,QAAQ;EAC5B;EAEOG,UAAUA,CAACC,MAAS,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACJ,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIK,cAAW,CAChB,oCAAmC,EACpC,2BAA2B,EAC3B;QACID;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACJ,QAAQ,CAACI,MAAM,CAAC;EACzB;AACJ;AAACE,OAAA,CAAAT,+BAAA,GAAAA,+BAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchBodyModifierPlugin","Plugin","constructor","callable","modifyBody","params","WebinyError","exports"],"sources":["ElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { SearchBody } from \"elastic-ts\";\n\nexport interface ModifyBodyParams {\n body: SearchBody;\n}\n\nexport interface ModifyBodyCallable<T extends ModifyBodyParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchBodyModifierPlugin<\n T extends ModifyBodyParams = ModifyBodyParams\n> extends Plugin {\n private readonly callable?: ModifyBodyCallable<T>;\n\n public constructor(callable?: ModifyBodyCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyBody(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the body.`,\n \"BODY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAWO,MAAeE,+BAA+B,SAE3CC,eAAM,CAAC;EAGNC,WAAWA,CAACC,QAAgC,EAAE;IACjD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,UAAUA,CAACC,MAAS,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIG,cAAW,CAChB,oCAAmC,EACpC,2BAA2B,EAC3B;QACID;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ;AAACE,OAAA,CAAAP,+BAAA,GAAAA,+BAAA"}
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.ElasticsearchFieldPlugin = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
7
  var _plugins = require("@webiny/plugins");
11
8
  const keywordLessUnmappedType = ["date", "long"];
12
9
  const unmappedTypeHasKeyword = type => {
@@ -18,14 +15,10 @@ const unmappedTypeHasKeyword = type => {
18
15
  return true;
19
16
  };
20
17
  class ElasticsearchFieldPlugin extends _plugins.Plugin {
18
+ static type = "elasticsearch.fieldDefinition";
19
+ static ALL = "*";
21
20
  constructor(params) {
22
21
  super();
23
- (0, _defineProperty2.default)(this, "field", void 0);
24
- (0, _defineProperty2.default)(this, "path", void 0);
25
- (0, _defineProperty2.default)(this, "keyword", void 0);
26
- (0, _defineProperty2.default)(this, "unmappedType", void 0);
27
- (0, _defineProperty2.default)(this, "sortable", void 0);
28
- (0, _defineProperty2.default)(this, "searchable", void 0);
29
22
  this.field = params.field;
30
23
  this.path = params.path || params.field;
31
24
  this.keyword = params.keyword === undefined ? true : params.keyword;
@@ -46,9 +39,10 @@ class ElasticsearchFieldPlugin extends _plugins.Plugin {
46
39
  if (!this.unmappedType) {
47
40
  return options;
48
41
  }
49
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, options), {}, {
42
+ return {
43
+ ...options,
50
44
  unmapped_type: this.unmappedType
51
- });
45
+ };
52
46
  }
53
47
  /**
54
48
  * The default path generator. Extend in your own plugin if you want to add more options.
@@ -77,7 +71,5 @@ class ElasticsearchFieldPlugin extends _plugins.Plugin {
77
71
  }
78
72
  }
79
73
  exports.ElasticsearchFieldPlugin = ElasticsearchFieldPlugin;
80
- (0, _defineProperty2.default)(ElasticsearchFieldPlugin, "type", "elasticsearch.fieldDefinition");
81
- (0, _defineProperty2.default)(ElasticsearchFieldPlugin, "ALL", "*");
82
74
 
83
75
  //# sourceMappingURL=ElasticsearchFieldPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","keywordLessUnmappedType","unmappedTypeHasKeyword","type","includes","ElasticsearchFieldPlugin","Plugin","constructor","params","_defineProperty2","default","field","path","keyword","undefined","unmappedType","sortable","searchable","getSortOptions","order","options","_objectSpread2","unmapped_type","getPath","getBasePath","ALL","toSearchValue","value","exports"],"sources":["ElasticsearchFieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FieldSortOptions, SortOrder } from \"elastic-ts\";\n\nexport type UnmappedTypes = \"date\" | \"long\" | string;\n\nconst keywordLessUnmappedType = [\"date\", \"long\"];\n\nconst unmappedTypeHasKeyword = (type?: string): boolean => {\n if (!type) {\n return true;\n } else if (keywordLessUnmappedType.includes(type)) {\n return false;\n }\n return true;\n};\n\nexport interface ToSearchValueParams {\n /**\n * The value to transform.\n */\n value: any;\n /**\n * When using toSearchValue() in our code we send a field.getPath() value here.\n */\n path: string;\n /**\n * When using toSearchValue() in our code we send a field.getBasePath() value here.\n */\n basePath: string;\n}\nexport interface ElasticsearchFieldPluginParams {\n /**\n * Which field is this plugin for.\n */\n field: string;\n /**\n * Some specific path of a field?\n * Example: createdBy is createdBy.id\n */\n path?: string;\n /**\n * Add a .keyword at the end of the field path?\n */\n keyword?: boolean;\n /**\n * Is the field of a specific type, but possibly not mapped?\n * Happens when inserting a date in string format.\n * You need to cast it as date when running the search/sort to work correctly.\n */\n unmappedType?: UnmappedTypes;\n /**\n * Is the field sortable?\n */\n sortable?: boolean;\n /**\n * Is the field searchable?\n */\n searchable?: boolean;\n /**\n * Used to transform the input value for the search.\n */\n toSearchValue?: (params: ToSearchValueParams) => any;\n}\n\nexport class ElasticsearchFieldPlugin extends Plugin {\n public static override readonly type: string = \"elasticsearch.fieldDefinition\";\n public static readonly ALL: string = \"*\";\n\n public readonly field: string;\n public readonly path: string;\n public readonly keyword: boolean;\n public readonly unmappedType?: string;\n public readonly sortable: boolean;\n public readonly searchable: boolean;\n\n constructor(params: ElasticsearchFieldPluginParams) {\n super();\n this.field = params.field;\n this.path = params.path || params.field;\n this.keyword = params.keyword === undefined ? true : params.keyword;\n this.unmappedType = params.unmappedType;\n if (unmappedTypeHasKeyword(params.unmappedType) === false) {\n this.keyword = false;\n }\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this.searchable = params.searchable === undefined ? true : params.searchable;\n }\n /**\n * The default sort options. Extend in your own plugin if you want to add more options.\n */\n public getSortOptions(order: SortOrder): FieldSortOptions {\n const options = {\n order\n };\n if (!this.unmappedType) {\n return options;\n }\n return {\n ...options,\n unmapped_type: this.unmappedType\n };\n }\n /**\n * The default path generator. Extend in your own plugin if you want to add more options.\n * Field parameter is here because there is a possibility that this is the ALL field plugin, so we need to know which field are we working on.\n */\n public getPath(field: string): string {\n return `${this.getBasePath(field)}${this.keyword ? \".keyword\" : \"\"}`;\n }\n /**\n * @see getPath\n *\n * This is the default base path generator. Basically it replaces ALL with given field name.\n */\n public getBasePath(field: string): string {\n if (this.path === ElasticsearchFieldPlugin.ALL) {\n return field;\n }\n return this.path;\n }\n /**\n * The default transformer. Just returns the value by default.\n * Override to implement what ever is required.\n */\n public toSearchValue(params: ToSearchValueParams): any {\n return params.value;\n }\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAKA,MAAMC,uBAAuB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;AAEhD,MAAMC,sBAAsB,GAAIC,IAAa,IAAc;EACvD,IAAI,CAACA,IAAI,EAAE;IACP,OAAO,IAAI;EACf,CAAC,MAAM,IAAIF,uBAAuB,CAACG,QAAQ,CAACD,IAAI,CAAC,EAAE;IAC/C,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAkDM,MAAME,wBAAwB,SAASC,eAAM,CAAC;EAWjDC,WAAWA,CAACC,MAAsC,EAAE;IAChD,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IACR,IAAI,CAACC,KAAK,GAAGH,MAAM,CAACG,KAAK;IACzB,IAAI,CAACC,IAAI,GAAGJ,MAAM,CAACI,IAAI,IAAIJ,MAAM,CAACG,KAAK;IACvC,IAAI,CAACE,OAAO,GAAGL,MAAM,CAACK,OAAO,KAAKC,SAAS,GAAG,IAAI,GAAGN,MAAM,CAACK,OAAO;IACnE,IAAI,CAACE,YAAY,GAAGP,MAAM,CAACO,YAAY;IACvC,IAAIb,sBAAsB,CAACM,MAAM,CAACO,YAAY,CAAC,KAAK,KAAK,EAAE;MACvD,IAAI,CAACF,OAAO,GAAG,KAAK;IACxB;IACA,IAAI,CAACG,QAAQ,GAAGR,MAAM,CAACQ,QAAQ,KAAKF,SAAS,GAAG,IAAI,GAAGN,MAAM,CAACQ,QAAQ;IACtE,IAAI,CAACC,UAAU,GAAGT,MAAM,CAACS,UAAU,KAAKH,SAAS,GAAG,IAAI,GAAGN,MAAM,CAACS,UAAU;EAChF;EACA;AACJ;AACA;EACWC,cAAcA,CAACC,KAAgB,EAAoB;IACtD,MAAMC,OAAO,GAAG;MACZD;IACJ,CAAC;IACD,IAAI,CAAC,IAAI,CAACJ,YAAY,EAAE;MACpB,OAAOK,OAAO;IAClB;IACA,WAAAC,cAAA,CAAAX,OAAA,MAAAW,cAAA,CAAAX,OAAA,MACOU,OAAO;MACVE,aAAa,EAAE,IAAI,CAACP;IAAY;EAExC;EACA;AACJ;AACA;AACA;EACWQ,OAAOA,CAACZ,KAAa,EAAU;IAClC,OAAQ,GAAE,IAAI,CAACa,WAAW,CAACb,KAAK,CAAE,GAAE,IAAI,CAACE,OAAO,GAAG,UAAU,GAAG,EAAG,EAAC;EACxE;EACA;AACJ;AACA;AACA;AACA;EACWW,WAAWA,CAACb,KAAa,EAAU;IACtC,IAAI,IAAI,CAACC,IAAI,KAAKP,wBAAwB,CAACoB,GAAG,EAAE;MAC5C,OAAOd,KAAK;IAChB;IACA,OAAO,IAAI,CAACC,IAAI;EACpB;EACA;AACJ;AACA;AACA;EACWc,aAAaA,CAAClB,MAA2B,EAAO;IACnD,OAAOA,MAAM,CAACmB,KAAK;EACvB;AACJ;AAACC,OAAA,CAAAvB,wBAAA,GAAAA,wBAAA;AAAA,IAAAI,gBAAA,CAAAC,OAAA,EA/DYL,wBAAwB,UACc,+BAA+B;AAAA,IAAAI,gBAAA,CAAAC,OAAA,EADrEL,wBAAwB,SAEI,GAAG"}
1
+ {"version":3,"names":["_plugins","require","keywordLessUnmappedType","unmappedTypeHasKeyword","type","includes","ElasticsearchFieldPlugin","Plugin","ALL","constructor","params","field","path","keyword","undefined","unmappedType","sortable","searchable","getSortOptions","order","options","unmapped_type","getPath","getBasePath","toSearchValue","value","exports"],"sources":["ElasticsearchFieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FieldSortOptions, SortOrder } from \"elastic-ts\";\n\nexport type UnmappedTypes = \"date\" | \"long\" | string;\n\nconst keywordLessUnmappedType = [\"date\", \"long\"];\n\nconst unmappedTypeHasKeyword = (type?: string): boolean => {\n if (!type) {\n return true;\n } else if (keywordLessUnmappedType.includes(type)) {\n return false;\n }\n return true;\n};\n\nexport interface ToSearchValueParams {\n /**\n * The value to transform.\n */\n value: any;\n /**\n * When using toSearchValue() in our code we send a field.getPath() value here.\n */\n path: string;\n /**\n * When using toSearchValue() in our code we send a field.getBasePath() value here.\n */\n basePath: string;\n}\nexport interface ElasticsearchFieldPluginParams {\n /**\n * Which field is this plugin for.\n */\n field: string;\n /**\n * Some specific path of a field?\n * Example: createdBy is createdBy.id\n */\n path?: string;\n /**\n * Add a .keyword at the end of the field path?\n */\n keyword?: boolean;\n /**\n * Is the field of a specific type, but possibly not mapped?\n * Happens when inserting a date in string format.\n * You need to cast it as date when running the search/sort to work correctly.\n */\n unmappedType?: UnmappedTypes;\n /**\n * Is the field sortable?\n */\n sortable?: boolean;\n /**\n * Is the field searchable?\n */\n searchable?: boolean;\n /**\n * Used to transform the input value for the search.\n */\n toSearchValue?: (params: ToSearchValueParams) => any;\n}\n\nexport class ElasticsearchFieldPlugin extends Plugin {\n public static override readonly type: string = \"elasticsearch.fieldDefinition\";\n public static readonly ALL: string = \"*\";\n\n public readonly field: string;\n public readonly path: string;\n public readonly keyword: boolean;\n public readonly unmappedType?: string;\n public readonly sortable: boolean;\n public readonly searchable: boolean;\n\n constructor(params: ElasticsearchFieldPluginParams) {\n super();\n this.field = params.field;\n this.path = params.path || params.field;\n this.keyword = params.keyword === undefined ? true : params.keyword;\n this.unmappedType = params.unmappedType;\n if (unmappedTypeHasKeyword(params.unmappedType) === false) {\n this.keyword = false;\n }\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this.searchable = params.searchable === undefined ? true : params.searchable;\n }\n /**\n * The default sort options. Extend in your own plugin if you want to add more options.\n */\n public getSortOptions(order: SortOrder): FieldSortOptions {\n const options = {\n order\n };\n if (!this.unmappedType) {\n return options;\n }\n return {\n ...options,\n unmapped_type: this.unmappedType\n };\n }\n /**\n * The default path generator. Extend in your own plugin if you want to add more options.\n * Field parameter is here because there is a possibility that this is the ALL field plugin, so we need to know which field are we working on.\n */\n public getPath(field: string): string {\n return `${this.getBasePath(field)}${this.keyword ? \".keyword\" : \"\"}`;\n }\n /**\n * @see getPath\n *\n * This is the default base path generator. Basically it replaces ALL with given field name.\n */\n public getBasePath(field: string): string {\n if (this.path === ElasticsearchFieldPlugin.ALL) {\n return field;\n }\n return this.path;\n }\n /**\n * The default transformer. Just returns the value by default.\n * Override to implement what ever is required.\n */\n public toSearchValue(params: ToSearchValueParams): any {\n return params.value;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAKA,MAAMC,uBAAuB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;AAEhD,MAAMC,sBAAsB,GAAIC,IAAa,IAAc;EACvD,IAAI,CAACA,IAAI,EAAE;IACP,OAAO,IAAI;EACf,CAAC,MAAM,IAAIF,uBAAuB,CAACG,QAAQ,CAACD,IAAI,CAAC,EAAE;IAC/C,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAkDM,MAAME,wBAAwB,SAASC,eAAM,CAAC;EACjD,OAAgCH,IAAI,GAAW,+BAA+B;EAC9E,OAAuBI,GAAG,GAAW,GAAG;EASxCC,WAAWA,CAACC,MAAsC,EAAE;IAChD,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,KAAK,GAAGD,MAAM,CAACC,KAAK;IACzB,IAAI,CAACC,IAAI,GAAGF,MAAM,CAACE,IAAI,IAAIF,MAAM,CAACC,KAAK;IACvC,IAAI,CAACE,OAAO,GAAGH,MAAM,CAACG,OAAO,KAAKC,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACG,OAAO;IACnE,IAAI,CAACE,YAAY,GAAGL,MAAM,CAACK,YAAY;IACvC,IAAIZ,sBAAsB,CAACO,MAAM,CAACK,YAAY,CAAC,KAAK,KAAK,EAAE;MACvD,IAAI,CAACF,OAAO,GAAG,KAAK;IACxB;IACA,IAAI,CAACG,QAAQ,GAAGN,MAAM,CAACM,QAAQ,KAAKF,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACM,QAAQ;IACtE,IAAI,CAACC,UAAU,GAAGP,MAAM,CAACO,UAAU,KAAKH,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACO,UAAU;EAChF;EACA;AACJ;AACA;EACWC,cAAcA,CAACC,KAAgB,EAAoB;IACtD,MAAMC,OAAO,GAAG;MACZD;IACJ,CAAC;IACD,IAAI,CAAC,IAAI,CAACJ,YAAY,EAAE;MACpB,OAAOK,OAAO;IAClB;IACA,OAAO;MACH,GAAGA,OAAO;MACVC,aAAa,EAAE,IAAI,CAACN;IACxB,CAAC;EACL;EACA;AACJ;AACA;AACA;EACWO,OAAOA,CAACX,KAAa,EAAU;IAClC,OAAQ,GAAE,IAAI,CAACY,WAAW,CAACZ,KAAK,CAAE,GAAE,IAAI,CAACE,OAAO,GAAG,UAAU,GAAG,EAAG,EAAC;EACxE;EACA;AACJ;AACA;AACA;AACA;EACWU,WAAWA,CAACZ,KAAa,EAAU;IACtC,IAAI,IAAI,CAACC,IAAI,KAAKN,wBAAwB,CAACE,GAAG,EAAE;MAC5C,OAAOG,KAAK;IAChB;IACA,OAAO,IAAI,CAACC,IAAI;EACpB;EACA;AACJ;AACA;AACA;EACWY,aAAaA,CAACd,MAA2B,EAAO;IACnD,OAAOA,MAAM,CAACe,KAAK;EACvB;AACJ;AAACC,OAAA,CAAApB,wBAAA,GAAAA,wBAAA"}
@@ -5,20 +5,18 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.ElasticsearchIndexPlugin = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
9
  var _plugins = require("@webiny/plugins");
12
10
  class ElasticsearchIndexPlugin extends _plugins.Plugin {
13
11
  constructor(params) {
14
12
  super();
15
- (0, _defineProperty2.default)(this, "body", void 0);
16
- (0, _defineProperty2.default)(this, "locales", void 0);
17
13
  const {
18
14
  locales,
19
15
  body
20
16
  } = params;
21
- this.body = (0, _objectSpread2.default)({}, body);
17
+ this.body = {
18
+ ...body
19
+ };
22
20
  this.locales = locales ? locales.map(locale => locale.toLowerCase()) : undefined;
23
21
  }
24
22
  canUse(locale) {
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchIndexPlugin","Plugin","constructor","params","_defineProperty2","default","locales","body","_objectSpread2","map","locale","toLowerCase","undefined","canUse","length","WebinyError","includes","exports"],"sources":["ElasticsearchIndexPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { ElasticsearchIndexRequestBody } from \"~/types\";\n\nexport interface ElasticsearchIndexPluginParams {\n /**\n * For which locales are we applying this plugin.\n * Options:\n * - locale codes to target specific locale\n * - null for all\n */\n locales?: string[];\n body: ElasticsearchIndexRequestBody;\n}\n\nexport abstract class ElasticsearchIndexPlugin extends Plugin {\n public readonly body: ElasticsearchIndexRequestBody;\n private readonly locales: string[] | undefined;\n\n public constructor(params: ElasticsearchIndexPluginParams) {\n super();\n const { locales, body } = params;\n this.body = {\n ...body\n };\n this.locales = locales ? locales.map(locale => locale.toLowerCase()) : undefined;\n }\n\n public canUse(locale: string): boolean {\n if (!this.locales) {\n return true;\n } else if (this.locales.length === 0) {\n throw new WebinyError(\n \"Cannot have Elasticsearch Index Template plugin with no locales defined.\",\n \"LOCALES_ERROR\",\n {\n body: this.body,\n locales: this.locales\n }\n );\n }\n return this.locales.includes(locale.toLowerCase());\n }\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAcO,MAAeE,wBAAwB,SAASC,eAAM,CAAC;EAInDC,WAAWA,CAACC,MAAsC,EAAE;IACvD,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IACR,MAAM;MAAEC,OAAO;MAAEC;IAAK,CAAC,GAAGJ,MAAM;IAChC,IAAI,CAACI,IAAI,OAAAC,cAAA,CAAAH,OAAA,MACFE,IAAI,CACV;IACD,IAAI,CAACD,OAAO,GAAGA,OAAO,GAAGA,OAAO,CAACG,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACC,WAAW,CAAC,CAAC,CAAC,GAAGC,SAAS;EACpF;EAEOC,MAAMA,CAACH,MAAc,EAAW;IACnC,IAAI,CAAC,IAAI,CAACJ,OAAO,EAAE;MACf,OAAO,IAAI;IACf,CAAC,MAAM,IAAI,IAAI,CAACA,OAAO,CAACQ,MAAM,KAAK,CAAC,EAAE;MAClC,MAAM,IAAIC,cAAW,CACjB,0EAA0E,EAC1E,eAAe,EACf;QACIR,IAAI,EAAE,IAAI,CAACA,IAAI;QACfD,OAAO,EAAE,IAAI,CAACA;MAClB,CACJ,CAAC;IACL;IACA,OAAO,IAAI,CAACA,OAAO,CAACU,QAAQ,CAACN,MAAM,CAACC,WAAW,CAAC,CAAC,CAAC;EACtD;AACJ;AAACM,OAAA,CAAAjB,wBAAA,GAAAA,wBAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchIndexPlugin","Plugin","constructor","params","locales","body","map","locale","toLowerCase","undefined","canUse","length","WebinyError","includes","exports"],"sources":["ElasticsearchIndexPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { ElasticsearchIndexRequestBody } from \"~/types\";\n\nexport interface ElasticsearchIndexPluginParams {\n /**\n * For which locales are we applying this plugin.\n * Options:\n * - locale codes to target specific locale\n * - null for all\n */\n locales?: string[];\n body: ElasticsearchIndexRequestBody;\n}\n\nexport abstract class ElasticsearchIndexPlugin extends Plugin {\n public readonly body: ElasticsearchIndexRequestBody;\n private readonly locales: string[] | undefined;\n\n public constructor(params: ElasticsearchIndexPluginParams) {\n super();\n const { locales, body } = params;\n this.body = {\n ...body\n };\n this.locales = locales ? locales.map(locale => locale.toLowerCase()) : undefined;\n }\n\n public canUse(locale: string): boolean {\n if (!this.locales) {\n return true;\n } else if (this.locales.length === 0) {\n throw new WebinyError(\n \"Cannot have Elasticsearch Index Template plugin with no locales defined.\",\n \"LOCALES_ERROR\",\n {\n body: this.body,\n locales: this.locales\n }\n );\n }\n return this.locales.includes(locale.toLowerCase());\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAcO,MAAeE,wBAAwB,SAASC,eAAM,CAAC;EAInDC,WAAWA,CAACC,MAAsC,EAAE;IACvD,KAAK,CAAC,CAAC;IACP,MAAM;MAAEC,OAAO;MAAEC;IAAK,CAAC,GAAGF,MAAM;IAChC,IAAI,CAACE,IAAI,GAAG;MACR,GAAGA;IACP,CAAC;IACD,IAAI,CAACD,OAAO,GAAGA,OAAO,GAAGA,OAAO,CAACE,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACC,WAAW,CAAC,CAAC,CAAC,GAAGC,SAAS;EACpF;EAEOC,MAAMA,CAACH,MAAc,EAAW;IACnC,IAAI,CAAC,IAAI,CAACH,OAAO,EAAE;MACf,OAAO,IAAI;IACf,CAAC,MAAM,IAAI,IAAI,CAACA,OAAO,CAACO,MAAM,KAAK,CAAC,EAAE;MAClC,MAAM,IAAIC,cAAW,CACjB,0EAA0E,EAC1E,eAAe,EACf;QACIP,IAAI,EAAE,IAAI,CAACA,IAAI;QACfD,OAAO,EAAE,IAAI,CAACA;MAClB,CACJ,CAAC;IACL;IACA,OAAO,IAAI,CAACA,OAAO,CAACS,QAAQ,CAACN,MAAM,CAACC,WAAW,CAAC,CAAC,CAAC;EACtD;AACJ;AAACM,OAAA,CAAAd,wBAAA,GAAAA,wBAAA"}
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.ElasticsearchQueryBuilderOperatorPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _plugins = require("@webiny/plugins");
10
8
  /**
11
9
  * Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.
12
10
  */
13
11
  class ElasticsearchQueryBuilderOperatorPlugin extends _plugins.Plugin {
12
+ static type = "elasticsearch.queryBuilder.operator";
13
+
14
14
  /**
15
15
  * Check if current locale is supported by this plugin.
16
- */ // eslint-disable-next-line
16
+ */
17
+ // eslint-disable-next-line
17
18
  isLocaleSupported(_) {
18
19
  return true;
19
20
  }
20
21
  }
21
22
  exports.ElasticsearchQueryBuilderOperatorPlugin = ElasticsearchQueryBuilderOperatorPlugin;
22
- (0, _defineProperty2.default)(ElasticsearchQueryBuilderOperatorPlugin, "type", "elasticsearch.queryBuilder.operator");
23
23
 
24
24
  //# sourceMappingURL=ElasticsearchQueryBuilderOperatorPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","ElasticsearchQueryBuilderOperatorPlugin","Plugin","isLocaleSupported","_","exports","_defineProperty2","default"],"sources":["ElasticsearchQueryBuilderOperatorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\n/**\n * Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.\n */\nexport abstract class ElasticsearchQueryBuilderOperatorPlugin extends Plugin {\n public static override readonly type: string = \"elasticsearch.queryBuilder.operator\";\n\n /**\n * Check if current locale is supported by this plugin.\n */\n // eslint-disable-next-line\n public isLocaleSupported(_: string): boolean {\n return true;\n }\n\n public abstract getOperator(): string;\n\n public abstract apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACO,MAAeC,uCAAuC,SAASC,eAAM,CAAC;EAGzE;AACJ;AACA,KAFI,CAGA;EACOC,iBAAiBA,CAACC,CAAS,EAAW;IACzC,OAAO,IAAI;EACf;AAQJ;AAACC,OAAA,CAAAJ,uCAAA,GAAAA,uCAAA;AAAA,IAAAK,gBAAA,CAAAC,OAAA,EAjBqBN,uCAAuC,UACV,qCAAqC"}
1
+ {"version":3,"names":["_plugins","require","ElasticsearchQueryBuilderOperatorPlugin","Plugin","type","isLocaleSupported","_","exports"],"sources":["ElasticsearchQueryBuilderOperatorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\n/**\n * Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.\n */\nexport abstract class ElasticsearchQueryBuilderOperatorPlugin extends Plugin {\n public static override readonly type: string = \"elasticsearch.queryBuilder.operator\";\n\n /**\n * Check if current locale is supported by this plugin.\n */\n // eslint-disable-next-line\n public isLocaleSupported(_: string): boolean {\n return true;\n }\n\n public abstract getOperator(): string;\n\n public abstract apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACO,MAAeC,uCAAuC,SAASC,eAAM,CAAC;EACzE,OAAgCC,IAAI,GAAW,qCAAqC;;EAEpF;AACJ;AACA;EACI;EACOC,iBAAiBA,CAACC,CAAS,EAAW;IACzC,OAAO,IAAI;EACf;AAQJ;AAACC,OAAA,CAAAL,uCAAA,GAAAA,uCAAA"}
@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.ElasticsearchQueryModifierPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
8
  var _error = _interopRequireDefault(require("@webiny/error"));
10
9
  var _plugins = require("@webiny/plugins");
11
10
  class ElasticsearchQueryModifierPlugin extends _plugins.Plugin {
12
11
  constructor(callable) {
13
12
  super();
14
- (0, _defineProperty2.default)(this, "callable", void 0);
15
13
  this.callable = callable;
16
14
  }
17
15
  modifyQuery(params) {
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchQueryModifierPlugin","Plugin","constructor","callable","_defineProperty2","default","modifyQuery","params","WebinyError","exports"],"sources":["ElasticsearchQueryModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { ElasticsearchBoolQueryConfig } from \"~/types\";\n\nexport interface ModifyQueryParams {\n query: ElasticsearchBoolQueryConfig;\n where: Record<string, any>;\n}\n\nexport interface ModifyQueryCallable<T extends ModifyQueryParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchQueryModifierPlugin<\n T extends ModifyQueryParams = ModifyQueryParams\n> extends Plugin {\n private readonly callable?: ModifyQueryCallable<T>;\n\n public constructor(callable?: ModifyQueryCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyQuery(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the query.`,\n \"QUERY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAYO,MAAeE,gCAAgC,SAE5CC,eAAM,CAAC;EAGNC,WAAWA,CAACC,QAAiC,EAAE;IAClD,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IACR,IAAI,CAACF,QAAQ,GAAGA,QAAQ;EAC5B;EAEOG,WAAWA,CAACC,MAAS,EAAQ;IAChC,IAAI,OAAO,IAAI,CAACJ,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIK,cAAW,CAChB,qCAAoC,EACrC,4BAA4B,EAC5B;QACID;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACJ,QAAQ,CAACI,MAAM,CAAC;EACzB;AACJ;AAACE,OAAA,CAAAT,gCAAA,GAAAA,gCAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchQueryModifierPlugin","Plugin","constructor","callable","modifyQuery","params","WebinyError","exports"],"sources":["ElasticsearchQueryModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { ElasticsearchBoolQueryConfig } from \"~/types\";\n\nexport interface ModifyQueryParams {\n query: ElasticsearchBoolQueryConfig;\n where: Record<string, any>;\n}\n\nexport interface ModifyQueryCallable<T extends ModifyQueryParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchQueryModifierPlugin<\n T extends ModifyQueryParams = ModifyQueryParams\n> extends Plugin {\n private readonly callable?: ModifyQueryCallable<T>;\n\n public constructor(callable?: ModifyQueryCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyQuery(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the query.`,\n \"QUERY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAYO,MAAeE,gCAAgC,SAE5CC,eAAM,CAAC;EAGNC,WAAWA,CAACC,QAAiC,EAAE;IAClD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,WAAWA,CAACC,MAAS,EAAQ;IAChC,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIG,cAAW,CAChB,qCAAoC,EACrC,4BAA4B,EAC5B;QACID;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ;AAACE,OAAA,CAAAP,gCAAA,GAAAA,gCAAA"}
@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.ElasticsearchSortModifierPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
8
  var _error = _interopRequireDefault(require("@webiny/error"));
10
9
  var _plugins = require("@webiny/plugins");
11
10
  class ElasticsearchSortModifierPlugin extends _plugins.Plugin {
12
11
  constructor(callable) {
13
12
  super();
14
- (0, _defineProperty2.default)(this, "callable", void 0);
15
13
  this.callable = callable;
16
14
  }
17
15
  modifySort(params) {
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchSortModifierPlugin","Plugin","constructor","callable","_defineProperty2","default","modifySort","params","WebinyError","exports"],"sources":["ElasticsearchSortModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { Sort } from \"elastic-ts\";\n\nexport interface ModifySortParams {\n sort: Sort;\n}\n\nexport interface ModifySortCallable<T extends ModifySortParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchSortModifierPlugin<\n T extends ModifySortParams = ModifySortParams\n> extends Plugin {\n private readonly callable?: ModifySortCallable<T>;\n\n public constructor(callable?: ModifySortCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifySort(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the sort.`,\n \"SORT_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAWO,MAAeE,+BAA+B,SAE3CC,eAAM,CAAC;EAGNC,WAAWA,CAACC,QAAgC,EAAE;IACjD,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IACR,IAAI,CAACF,QAAQ,GAAGA,QAAQ;EAC5B;EAEOG,UAAUA,CAACC,MAAS,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACJ,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIK,cAAW,CAChB,oCAAmC,EACpC,2BAA2B,EAC3B;QACID;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACJ,QAAQ,CAACI,MAAM,CAAC;EACzB;AACJ;AAACE,OAAA,CAAAT,+BAAA,GAAAA,+BAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchSortModifierPlugin","Plugin","constructor","callable","modifySort","params","WebinyError","exports"],"sources":["ElasticsearchSortModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { Sort } from \"elastic-ts\";\n\nexport interface ModifySortParams {\n sort: Sort;\n}\n\nexport interface ModifySortCallable<T extends ModifySortParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchSortModifierPlugin<\n T extends ModifySortParams = ModifySortParams\n> extends Plugin {\n private readonly callable?: ModifySortCallable<T>;\n\n public constructor(callable?: ModifySortCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifySort(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the sort.`,\n \"SORT_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAWO,MAAeE,+BAA+B,SAE3CC,eAAM,CAAC;EAGNC,WAAWA,CAACC,QAAgC,EAAE;IACjD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,UAAUA,CAACC,MAAS,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIG,cAAW,CAChB,oCAAmC,EACpC,2BAA2B,EAC3B;QACID;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ;AAACE,OAAA,CAAAP,+BAAA,GAAAA,+BAAA"}
@@ -1,17 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.ElasticsearchQueryBuilderOperatorAndInPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _ElasticsearchQueryBuilderOperatorPlugin = require("../definition/ElasticsearchQueryBuilderOperatorPlugin");
10
8
  class ElasticsearchQueryBuilderOperatorAndInPlugin extends _ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin {
11
- constructor(...args) {
12
- super(...args);
13
- (0, _defineProperty2.default)(this, "name", "elasticsearch.queryBuilder.operator.andIn.default");
14
- }
9
+ name = "elasticsearch.queryBuilder.operator.andIn.default";
15
10
  getOperator() {
16
11
  return "and_in";
17
12
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorAndInPlugin","ElasticsearchQueryBuilderOperatorPlugin","constructor","args","_defineProperty2","default","getOperator","apply","query","params","value","values","path","basePath","isArray","Array","length","Error","useBasePath","filter","push","term","exports"],"sources":["andIn.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorAndInPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.andIn.default\";\n\n public getOperator(): string {\n return \"and_in\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value: values, path, basePath } = params;\n const isArray = Array.isArray(values);\n if (isArray === false || values.length === 0) {\n throw new Error(\n `You cannot filter field \"${path}\" with \"in\" operator and not send an array of values.`\n );\n }\n\n let useBasePath = false;\n // Only use \".keyword\" if all of the provided values are strings.\n for (const value of values) {\n if (typeof value !== \"string\") {\n useBasePath = true;\n break;\n }\n }\n\n for (const value of values) {\n query.filter.push({\n term: {\n [useBasePath ? basePath : path]: value\n }\n });\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,4CAA4C,SAASC,gFAAuC,CAAC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,gBAC/E,mDAAmD;EAAA;EAEnEC,WAAWA,CAAA,EAAW;IACzB,OAAO,QAAQ;EACnB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK,EAAEC,MAAM;MAAEC,IAAI;MAAEC;IAAS,CAAC,GAAGJ,MAAM;IAChD,MAAMK,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACH,MAAM,CAAC;IACrC,IAAIG,OAAO,KAAK,KAAK,IAAIH,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;MAC1C,MAAM,IAAIC,KAAK,CACV,4BAA2BL,IAAK,uDACrC,CAAC;IACL;IAEA,IAAIM,WAAW,GAAG,KAAK;IACvB;IACA,KAAK,MAAMR,KAAK,IAAIC,MAAM,EAAE;MACxB,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;QAC3BQ,WAAW,GAAG,IAAI;QAClB;MACJ;IACJ;IAEA,KAAK,MAAMR,KAAK,IAAIC,MAAM,EAAE;MACxBH,KAAK,CAACW,MAAM,CAACC,IAAI,CAAC;QACdC,IAAI,EAAE;UACF,CAACH,WAAW,GAAGL,QAAQ,GAAGD,IAAI,GAAGF;QACrC;MACJ,CAAC,CAAC;IACN;EACJ;AACJ;AAACY,OAAA,CAAAtB,4CAAA,GAAAA,4CAAA"}
1
+ {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorAndInPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","values","path","basePath","isArray","Array","length","Error","useBasePath","filter","push","term","exports"],"sources":["andIn.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorAndInPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.andIn.default\";\n\n public getOperator(): string {\n return \"and_in\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value: values, path, basePath } = params;\n const isArray = Array.isArray(values);\n if (isArray === false || values.length === 0) {\n throw new Error(\n `You cannot filter field \"${path}\" with \"in\" operator and not send an array of values.`\n );\n }\n\n let useBasePath = false;\n // Only use \".keyword\" if all of the provided values are strings.\n for (const value of values) {\n if (typeof value !== \"string\") {\n useBasePath = true;\n break;\n }\n }\n\n for (const value of values) {\n query.filter.push({\n term: {\n [useBasePath ? basePath : path]: value\n }\n });\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,4CAA4C,SAASC,gFAAuC,CAAC;EACtFC,IAAI,GAAG,mDAAmD;EAEnEC,WAAWA,CAAA,EAAW;IACzB,OAAO,QAAQ;EACnB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK,EAAEC,MAAM;MAAEC,IAAI;MAAEC;IAAS,CAAC,GAAGJ,MAAM;IAChD,MAAMK,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACH,MAAM,CAAC;IACrC,IAAIG,OAAO,KAAK,KAAK,IAAIH,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;MAC1C,MAAM,IAAIC,KAAK,CACV,4BAA2BL,IAAK,uDACrC,CAAC;IACL;IAEA,IAAIM,WAAW,GAAG,KAAK;IACvB;IACA,KAAK,MAAMR,KAAK,IAAIC,MAAM,EAAE;MACxB,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;QAC3BQ,WAAW,GAAG,IAAI;QAClB;MACJ;IACJ;IAEA,KAAK,MAAMR,KAAK,IAAIC,MAAM,EAAE;MACxBH,KAAK,CAACW,MAAM,CAACC,IAAI,CAAC;QACdC,IAAI,EAAE;UACF,CAACH,WAAW,GAAGL,QAAQ,GAAGD,IAAI,GAAGF;QACrC;MACJ,CAAC,CAAC;IACN;EACJ;AACJ;AAACY,OAAA,CAAAnB,4CAAA,GAAAA,4CAAA"}
@@ -1,17 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.ElasticsearchQueryBuilderOperatorBetweenPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _ElasticsearchQueryBuilderOperatorPlugin = require("../definition/ElasticsearchQueryBuilderOperatorPlugin");
10
8
  class ElasticsearchQueryBuilderOperatorBetweenPlugin extends _ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin {
11
- constructor(...args) {
12
- super(...args);
13
- (0, _defineProperty2.default)(this, "name", "elasticsearch.queryBuilder.operator.between.default");
14
- }
9
+ name = "elasticsearch.queryBuilder.operator.between.default";
15
10
  getOperator() {
16
11
  return "between";
17
12
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorBetweenPlugin","ElasticsearchQueryBuilderOperatorPlugin","constructor","args","_defineProperty2","default","getOperator","apply","query","params","value","basePath","name","Array","isArray","Error","length","gte","lte","filter","push","range","exports"],"sources":["between.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorBetweenPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.between.default\";\n\n public getOperator(): string {\n return \"between\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value, basePath, name } = params;\n if (Array.isArray(value) === false) {\n throw new Error(\n `You cannot filter field path \"${name}\" with between query and not send an array of values.`\n );\n } else if (value.length !== 2) {\n throw new Error(\n `You must pass 2 values in the array for field path \"${name}\" filtering.`\n );\n }\n // we take gte first because it should be a lesser value than lte, eg [5, 10]\n // 6 >= gte && 6 <= lte\n const [gte, lte] = value;\n query.filter.push({\n range: {\n [basePath]: {\n lte,\n gte\n }\n }\n });\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,8CAA8C,SAASC,gFAAuC,CAAC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,gBACjF,qDAAqD;EAAA;EAErEC,WAAWA,CAAA,EAAW;IACzB,OAAO,SAAS;EACpB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK;MAAEC,QAAQ;MAAEC;IAAK,CAAC,GAAGH,MAAM;IACxC,IAAII,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,KAAK,KAAK,EAAE;MAChC,MAAM,IAAIK,KAAK,CACV,iCAAgCH,IAAK,uDAC1C,CAAC;IACL,CAAC,MAAM,IAAIF,KAAK,CAACM,MAAM,KAAK,CAAC,EAAE;MAC3B,MAAM,IAAID,KAAK,CACV,uDAAsDH,IAAK,cAChE,CAAC;IACL;IACA;IACA;IACA,MAAM,CAACK,GAAG,EAAEC,GAAG,CAAC,GAAGR,KAAK;IACxBF,KAAK,CAACW,MAAM,CAACC,IAAI,CAAC;MACdC,KAAK,EAAE;QACH,CAACV,QAAQ,GAAG;UACRO,GAAG;UACHD;QACJ;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACK,OAAA,CAAAtB,8CAAA,GAAAA,8CAAA"}
1
+ {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorBetweenPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","basePath","Array","isArray","Error","length","gte","lte","filter","push","range","exports"],"sources":["between.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorBetweenPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.between.default\";\n\n public getOperator(): string {\n return \"between\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value, basePath, name } = params;\n if (Array.isArray(value) === false) {\n throw new Error(\n `You cannot filter field path \"${name}\" with between query and not send an array of values.`\n );\n } else if (value.length !== 2) {\n throw new Error(\n `You must pass 2 values in the array for field path \"${name}\" filtering.`\n );\n }\n // we take gte first because it should be a lesser value than lte, eg [5, 10]\n // 6 >= gte && 6 <= lte\n const [gte, lte] = value;\n query.filter.push({\n range: {\n [basePath]: {\n lte,\n gte\n }\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,8CAA8C,SAASC,gFAAuC,CAAC;EACxFC,IAAI,GAAG,qDAAqD;EAErEC,WAAWA,CAAA,EAAW;IACzB,OAAO,SAAS;EACpB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK;MAAEC,QAAQ;MAAEN;IAAK,CAAC,GAAGI,MAAM;IACxC,IAAIG,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,KAAK,EAAE;MAChC,MAAM,IAAII,KAAK,CACV,iCAAgCT,IAAK,uDAC1C,CAAC;IACL,CAAC,MAAM,IAAIK,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;MAC3B,MAAM,IAAID,KAAK,CACV,uDAAsDT,IAAK,cAChE,CAAC;IACL;IACA;IACA;IACA,MAAM,CAACW,GAAG,EAAEC,GAAG,CAAC,GAAGP,KAAK;IACxBF,KAAK,CAACU,MAAM,CAACC,IAAI,CAAC;MACdC,KAAK,EAAE;QACH,CAACT,QAAQ,GAAG;UACRM,GAAG;UACHD;QACJ;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACK,OAAA,CAAAlB,8CAAA,GAAAA,8CAAA"}
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.ElasticsearchQueryBuilderOperatorContainsPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _ElasticsearchQueryBuilderOperatorPlugin = require("../definition/ElasticsearchQueryBuilderOperatorPlugin");
10
8
  var _normalize = require("../../normalize");
11
9
  class ElasticsearchQueryBuilderOperatorContainsPlugin extends _ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin {
12
- constructor(...args) {
13
- super(...args);
14
- (0, _defineProperty2.default)(this, "name", "elasticsearch.queryBuilder.operator.contains.default");
15
- }
10
+ name = "elasticsearch.queryBuilder.operator.contains.default";
16
11
  getOperator() {
17
12
  return "contains";
18
13
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","_normalize","ElasticsearchQueryBuilderOperatorContainsPlugin","ElasticsearchQueryBuilderOperatorPlugin","constructor","args","_defineProperty2","default","getOperator","apply","query","params","value","basePath","must","push","query_string","allow_leading_wildcard","fields","normalizeValueWithAsterisk","default_operator","exports"],"sources":["contains.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { normalizeValueWithAsterisk } from \"~/normalize\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorContainsPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.contains.default\";\n\n public getOperator(): string {\n return \"contains\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value, basePath } = params;\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: [basePath],\n query: normalizeValueWithAsterisk(value),\n default_operator: \"and\"\n }\n });\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGO,MAAME,+CAA+C,SAASC,gFAAuC,CAAC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,gBAClF,sDAAsD;EAAA;EAEtEC,WAAWA,CAAA,EAAW;IACzB,OAAO,UAAU;EACrB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK;MAAEC;IAAS,CAAC,GAAGF,MAAM;IAClCD,KAAK,CAACI,IAAI,CAACC,IAAI,CAAC;MACZC,YAAY,EAAE;QACVC,sBAAsB,EAAE,IAAI;QAC5BC,MAAM,EAAE,CAACL,QAAQ,CAAC;QAClBH,KAAK,EAAE,IAAAS,qCAA0B,EAACP,KAAK,CAAC;QACxCQ,gBAAgB,EAAE;MACtB;IACJ,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAAnB,+CAAA,GAAAA,+CAAA"}
1
+ {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","_normalize","ElasticsearchQueryBuilderOperatorContainsPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","basePath","must","push","query_string","allow_leading_wildcard","fields","normalizeValueWithAsterisk","default_operator","exports"],"sources":["contains.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { normalizeValueWithAsterisk } from \"~/normalize\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorContainsPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.contains.default\";\n\n public getOperator(): string {\n return \"contains\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value, basePath } = params;\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: [basePath],\n query: normalizeValueWithAsterisk(value),\n default_operator: \"and\"\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGO,MAAME,+CAA+C,SAASC,gFAAuC,CAAC;EACzFC,IAAI,GAAG,sDAAsD;EAEtEC,WAAWA,CAAA,EAAW;IACzB,OAAO,UAAU;EACrB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK;MAAEC;IAAS,CAAC,GAAGF,MAAM;IAClCD,KAAK,CAACI,IAAI,CAACC,IAAI,CAAC;MACZC,YAAY,EAAE;QACVC,sBAAsB,EAAE,IAAI;QAC5BC,MAAM,EAAE,CAACL,QAAQ,CAAC;QAClBH,KAAK,EAAE,IAAAS,qCAA0B,EAACP,KAAK,CAAC;QACxCQ,gBAAgB,EAAE;MACtB;IACJ,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAAhB,+CAAA,GAAAA,+CAAA"}