@webiny/api-elasticsearch 0.0.0-mt-2 → 0.0.0-unstable.1e66d121db

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 (92) hide show
  1. package/client.js +17 -9
  2. package/client.js.map +1 -0
  3. package/compression.js.map +1 -0
  4. package/cursors.d.ts +2 -2
  5. package/cursors.js.map +1 -0
  6. package/index.d.ts +2 -2
  7. package/index.js +4 -4
  8. package/index.js.map +1 -0
  9. package/indexConfiguration/base.d.ts +2 -0
  10. package/indexConfiguration/base.js +34 -0
  11. package/indexConfiguration/base.js.map +1 -0
  12. package/indexConfiguration/common.d.ts +5 -0
  13. package/indexConfiguration/common.js +19 -0
  14. package/indexConfiguration/common.js.map +1 -0
  15. package/indexConfiguration/japanese.d.ts +2 -0
  16. package/indexConfiguration/japanese.js +112 -0
  17. package/indexConfiguration/japanese.js.map +1 -0
  18. package/indices.d.ts +9 -0
  19. package/indices.js +35 -0
  20. package/indices.js.map +1 -0
  21. package/limit.js.map +1 -0
  22. package/normalize.js.map +1 -0
  23. package/operators.d.ts +5 -14
  24. package/operators.js +41 -27
  25. package/operators.js.map +1 -0
  26. package/package.json +14 -14
  27. package/plugins/GzipCompression.js.map +1 -0
  28. package/plugins/definition/CompressionPlugin.d.ts +1 -1
  29. package/plugins/definition/CompressionPlugin.js +1 -1
  30. package/plugins/definition/CompressionPlugin.js.map +1 -0
  31. package/plugins/definition/ElasticsearchBodyModifierPlugin.js +1 -1
  32. package/plugins/definition/ElasticsearchBodyModifierPlugin.js.map +1 -0
  33. package/plugins/definition/ElasticsearchFieldPlugin.d.ts +8 -14
  34. package/plugins/definition/ElasticsearchFieldPlugin.js +25 -49
  35. package/plugins/definition/ElasticsearchFieldPlugin.js.map +1 -0
  36. package/plugins/definition/ElasticsearchIndexPlugin.d.ts +18 -0
  37. package/plugins/definition/ElasticsearchIndexPlugin.js +46 -0
  38. package/plugins/definition/ElasticsearchIndexPlugin.js.map +1 -0
  39. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.d.ts +5 -1
  40. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js +11 -2
  41. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js.map +1 -0
  42. package/plugins/definition/ElasticsearchQueryModifierPlugin.js +1 -1
  43. package/plugins/definition/ElasticsearchQueryModifierPlugin.js.map +1 -0
  44. package/plugins/definition/ElasticsearchSortModifierPlugin.js +1 -1
  45. package/plugins/definition/ElasticsearchSortModifierPlugin.js.map +1 -0
  46. package/plugins/operator/andIn.js +1 -1
  47. package/plugins/operator/andIn.js.map +1 -0
  48. package/plugins/operator/between.js +1 -1
  49. package/plugins/operator/between.js.map +1 -0
  50. package/plugins/operator/contains.js +1 -1
  51. package/plugins/operator/contains.js.map +1 -0
  52. package/plugins/operator/equal.js +11 -1
  53. package/plugins/operator/equal.js.map +1 -0
  54. package/plugins/operator/gt.js +1 -1
  55. package/plugins/operator/gt.js.map +1 -0
  56. package/plugins/operator/gte.js +1 -1
  57. package/plugins/operator/gte.js.map +1 -0
  58. package/plugins/operator/in.js +1 -1
  59. package/plugins/operator/in.js.map +1 -0
  60. package/plugins/operator/index.d.ts +3 -0
  61. package/plugins/operator/index.js +39 -0
  62. package/plugins/operator/index.js.map +1 -0
  63. package/plugins/operator/japanese/contains.d.ts +8 -0
  64. package/plugins/operator/japanese/contains.js +58 -0
  65. package/plugins/operator/japanese/contains.js.map +1 -0
  66. package/plugins/operator/lt.js +1 -1
  67. package/plugins/operator/lt.js.map +1 -0
  68. package/plugins/operator/lte.js +1 -1
  69. package/plugins/operator/lte.js.map +1 -0
  70. package/plugins/operator/not.js +11 -1
  71. package/plugins/operator/not.js.map +1 -0
  72. package/plugins/operator/notBetween.js +1 -1
  73. package/plugins/operator/notBetween.js.map +1 -0
  74. package/plugins/operator/notContains.js +1 -1
  75. package/plugins/operator/notContains.js.map +1 -0
  76. package/plugins/operator/notIn.js +1 -1
  77. package/plugins/operator/notIn.js.map +1 -0
  78. package/plugins/operator/notStartsWith.d.ts +7 -0
  79. package/plugins/operator/notStartsWith.js +38 -0
  80. package/plugins/operator/notStartsWith.js.map +1 -0
  81. package/plugins/operator/startsWith.d.ts +7 -0
  82. package/plugins/operator/startsWith.js +38 -0
  83. package/plugins/operator/startsWith.js.map +1 -0
  84. package/sort.d.ts +8 -3
  85. package/sort.js +12 -2
  86. package/sort.js.map +1 -0
  87. package/types.d.ts +153 -2
  88. package/types.js +12 -0
  89. package/types.js.map +1 -0
  90. package/where.d.ts +2 -2
  91. package/where.js +2 -2
  92. package/where.js.map +1 -0
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
2
  export declare abstract class CompressionPlugin extends Plugin {
3
- static readonly type = "elasticsearch.compression";
3
+ static readonly type: string;
4
4
  /**
5
5
  * Check if data can be compressed.
6
6
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CompressionPlugin","Plugin"],"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;;AAEO,MAAeA,iBAAf,SAAyCC,eAAzC,CAAgD;;;8BAAjCD,iB,UAC6B,2B"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ElasticsearchBodyModifierPlugin","Plugin","constructor","callable","modifyBody","params","WebinyError"],"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;;AACA;;AAWO,MAAeA,+BAAf,SAEGC,eAFH,CAEU;EAGNC,WAAW,CAACC,QAAD,EAAmC;IACjD;IADiD;IAEjD,KAAKA,QAAL,GAAgBA,QAAhB;EACH;;EAEMC,UAAU,CAACC,MAAD,EAAkB;IAC/B,IAAI,OAAO,KAAKF,QAAZ,KAAyB,UAA7B,EAAyC;MACrC,MAAM,IAAIG,cAAJ,CACD,oCADC,EAEF,2BAFE,EAGF;QACID;MADJ,CAHE,CAAN;IAOH;;IACD,KAAKF,QAAL,CAAcE,MAAd;EACH;;AAnBY"}
@@ -15,7 +15,7 @@ export interface ToSearchValueParams {
15
15
  */
16
16
  basePath: string;
17
17
  }
18
- export interface Params {
18
+ export interface ElasticsearchFieldPluginParams {
19
19
  /**
20
20
  * Which field is this plugin for.
21
21
  */
@@ -51,19 +51,13 @@ export interface Params {
51
51
  export declare abstract class ElasticsearchFieldPlugin extends Plugin {
52
52
  static readonly type: string;
53
53
  static readonly ALL: string;
54
- private readonly _field;
55
- private readonly _path;
56
- private readonly _keyword;
57
- private readonly _unmappedType;
58
- private readonly _sortable;
59
- private readonly _searchable;
60
- get field(): string;
61
- get path(): string;
62
- get keyword(): boolean;
63
- get unmappedType(): string | undefined;
64
- get sortable(): boolean;
65
- get searchable(): boolean;
66
- constructor(params: Params);
54
+ readonly field: string;
55
+ readonly path: string;
56
+ readonly keyword: boolean;
57
+ readonly unmappedType?: string;
58
+ readonly sortable: boolean;
59
+ readonly searchable: boolean;
60
+ constructor(params: ElasticsearchFieldPluginParams);
67
61
  /**
68
62
  * The default sort options. Extend in your own plugin if you want to add more options.
69
63
  */
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.ElasticsearchFieldPlugin = void 0;
9
9
 
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
10
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
13
 
12
14
  var _plugins = require("@webiny/plugins");
13
15
 
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
-
18
16
  const keywordLessUnmappedType = ["date", "long"];
19
17
 
20
18
  const unmappedTypeHasKeyword = type => {
21
- if (keywordLessUnmappedType.includes(type)) {
19
+ if (!type) {
20
+ return true;
21
+ } else if (keywordLessUnmappedType.includes(type)) {
22
22
  return false;
23
23
  }
24
24
 
@@ -26,49 +26,25 @@ const unmappedTypeHasKeyword = type => {
26
26
  };
27
27
 
28
28
  class ElasticsearchFieldPlugin extends _plugins.Plugin {
29
- get field() {
30
- return this._field;
31
- }
32
-
33
- get path() {
34
- return this._path;
35
- }
36
-
37
- get keyword() {
38
- return this._keyword;
39
- }
40
-
41
- get unmappedType() {
42
- return this._unmappedType;
43
- }
44
-
45
- get sortable() {
46
- return this._sortable;
47
- }
48
-
49
- get searchable() {
50
- return this._searchable;
51
- }
52
-
53
29
  constructor(params) {
54
30
  super();
55
- (0, _defineProperty2.default)(this, "_field", void 0);
56
- (0, _defineProperty2.default)(this, "_path", void 0);
57
- (0, _defineProperty2.default)(this, "_keyword", void 0);
58
- (0, _defineProperty2.default)(this, "_unmappedType", void 0);
59
- (0, _defineProperty2.default)(this, "_sortable", void 0);
60
- (0, _defineProperty2.default)(this, "_searchable", void 0);
61
- this._field = params.field;
62
- this._path = params.path || params.field;
63
- this._keyword = params.keyword === undefined ? true : params.keyword;
64
- this._unmappedType = params.unmappedType;
31
+ (0, _defineProperty2.default)(this, "field", void 0);
32
+ (0, _defineProperty2.default)(this, "path", void 0);
33
+ (0, _defineProperty2.default)(this, "keyword", void 0);
34
+ (0, _defineProperty2.default)(this, "unmappedType", void 0);
35
+ (0, _defineProperty2.default)(this, "sortable", void 0);
36
+ (0, _defineProperty2.default)(this, "searchable", void 0);
37
+ this.field = params.field;
38
+ this.path = params.path || params.field;
39
+ this.keyword = params.keyword === undefined ? true : params.keyword;
40
+ this.unmappedType = params.unmappedType;
65
41
 
66
42
  if (unmappedTypeHasKeyword(params.unmappedType) === false) {
67
- this._keyword = false;
43
+ this.keyword = false;
68
44
  }
69
45
 
70
- this._sortable = params.sortable === undefined ? true : params.sortable;
71
- this._searchable = params.searchable === undefined ? true : params.searchable;
46
+ this.sortable = params.sortable === undefined ? true : params.sortable;
47
+ this.searchable = params.searchable === undefined ? true : params.searchable;
72
48
  }
73
49
  /**
74
50
  * The default sort options. Extend in your own plugin if you want to add more options.
@@ -80,12 +56,12 @@ class ElasticsearchFieldPlugin extends _plugins.Plugin {
80
56
  order
81
57
  };
82
58
 
83
- if (!this._unmappedType) {
59
+ if (!this.unmappedType) {
84
60
  return options;
85
61
  }
86
62
 
87
- return _objectSpread(_objectSpread({}, options), {}, {
88
- unmapped_type: this._unmappedType
63
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, options), {}, {
64
+ unmapped_type: this.unmappedType
89
65
  });
90
66
  }
91
67
  /**
@@ -95,7 +71,7 @@ class ElasticsearchFieldPlugin extends _plugins.Plugin {
95
71
 
96
72
 
97
73
  getPath(field) {
98
- return `${this.getBasePath(field)}${this._keyword ? ".keyword" : ""}`;
74
+ return `${this.getBasePath(field)}${this.keyword ? ".keyword" : ""}`;
99
75
  }
100
76
  /**
101
77
  * @see getPath
@@ -105,11 +81,11 @@ class ElasticsearchFieldPlugin extends _plugins.Plugin {
105
81
 
106
82
 
107
83
  getBasePath(field) {
108
- if (this._path === this.constructor.ALL) {
84
+ if (this.path === ElasticsearchFieldPlugin.ALL) {
109
85
  return field;
110
86
  }
111
87
 
112
- return this._path;
88
+ return this.path;
113
89
  }
114
90
  /**
115
91
  * The default transformer. Just returns the value by default.
@@ -0,0 +1 @@
1
+ {"version":3,"names":["keywordLessUnmappedType","unmappedTypeHasKeyword","type","includes","ElasticsearchFieldPlugin","Plugin","constructor","params","field","path","keyword","undefined","unmappedType","sortable","searchable","getSortOptions","order","options","unmapped_type","getPath","getBasePath","ALL","toSearchValue","value"],"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 abstract 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;;AAKA,MAAMA,uBAAuB,GAAG,CAAC,MAAD,EAAS,MAAT,CAAhC;;AAEA,MAAMC,sBAAsB,GAAIC,IAAD,IAA4B;EACvD,IAAI,CAACA,IAAL,EAAW;IACP,OAAO,IAAP;EACH,CAFD,MAEO,IAAIF,uBAAuB,CAACG,QAAxB,CAAiCD,IAAjC,CAAJ,EAA4C;IAC/C,OAAO,KAAP;EACH;;EACD,OAAO,IAAP;AACH,CAPD;;AAyDO,MAAeE,wBAAf,SAAgDC,eAAhD,CAAuD;EAW1DC,WAAW,CAACC,MAAD,EAAyC;IAChD;IADgD;IAAA;IAAA;IAAA;IAAA;IAAA;IAEhD,KAAKC,KAAL,GAAaD,MAAM,CAACC,KAApB;IACA,KAAKC,IAAL,GAAYF,MAAM,CAACE,IAAP,IAAeF,MAAM,CAACC,KAAlC;IACA,KAAKE,OAAL,GAAeH,MAAM,CAACG,OAAP,KAAmBC,SAAnB,GAA+B,IAA/B,GAAsCJ,MAAM,CAACG,OAA5D;IACA,KAAKE,YAAL,GAAoBL,MAAM,CAACK,YAA3B;;IACA,IAAIX,sBAAsB,CAACM,MAAM,CAACK,YAAR,CAAtB,KAAgD,KAApD,EAA2D;MACvD,KAAKF,OAAL,GAAe,KAAf;IACH;;IACD,KAAKG,QAAL,GAAgBN,MAAM,CAACM,QAAP,KAAoBF,SAApB,GAAgC,IAAhC,GAAuCJ,MAAM,CAACM,QAA9D;IACA,KAAKC,UAAL,GAAkBP,MAAM,CAACO,UAAP,KAAsBH,SAAtB,GAAkC,IAAlC,GAAyCJ,MAAM,CAACO,UAAlE;EACH;EACD;AACJ;AACA;;;EACWC,cAAc,CAACC,KAAD,EAAqC;IACtD,MAAMC,OAAO,GAAG;MACZD;IADY,CAAhB;;IAGA,IAAI,CAAC,KAAKJ,YAAV,EAAwB;MACpB,OAAOK,OAAP;IACH;;IACD,mEACOA,OADP;MAEIC,aAAa,EAAE,KAAKN;IAFxB;EAIH;EACD;AACJ;AACA;AACA;;;EACWO,OAAO,CAACX,KAAD,EAAwB;IAClC,OAAQ,GAAE,KAAKY,WAAL,CAAiBZ,KAAjB,CAAwB,GAAE,KAAKE,OAAL,GAAe,UAAf,GAA4B,EAAG,EAAnE;EACH;EACD;AACJ;AACA;AACA;AACA;;;EACWU,WAAW,CAACZ,KAAD,EAAwB;IACtC,IAAI,KAAKC,IAAL,KAAcL,wBAAwB,CAACiB,GAA3C,EAAgD;MAC5C,OAAOb,KAAP;IACH;;IACD,OAAO,KAAKC,IAAZ;EACH;EACD;AACJ;AACA;AACA;;;EACWa,aAAa,CAACf,MAAD,EAAmC;IACnD,OAAOA,MAAM,CAACgB,KAAd;EACH;;AA9DyD;;;8BAAxCnB,wB,UAC6B,+B;8BAD7BA,wB,SAEmB,G"}
@@ -0,0 +1,18 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { ElasticsearchIndexRequestBody } from "../../types";
3
+ export interface ElasticsearchIndexPluginParams {
4
+ /**
5
+ * For which locales are we applying this plugin.
6
+ * Options:
7
+ * - locale codes to target specific locale
8
+ * - null for all
9
+ */
10
+ locales?: string[];
11
+ body: ElasticsearchIndexRequestBody;
12
+ }
13
+ export declare abstract class ElasticsearchIndexPlugin extends Plugin {
14
+ readonly body: ElasticsearchIndexRequestBody;
15
+ private readonly locales;
16
+ constructor(params: ElasticsearchIndexPluginParams);
17
+ canUse(locale: string): boolean;
18
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ElasticsearchIndexPlugin = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _error = _interopRequireDefault(require("@webiny/error"));
15
+
16
+ var _plugins = require("@webiny/plugins");
17
+
18
+ class ElasticsearchIndexPlugin extends _plugins.Plugin {
19
+ constructor(params) {
20
+ super();
21
+ (0, _defineProperty2.default)(this, "body", void 0);
22
+ (0, _defineProperty2.default)(this, "locales", void 0);
23
+ const {
24
+ locales,
25
+ body
26
+ } = params;
27
+ this.body = (0, _objectSpread2.default)({}, body);
28
+ this.locales = locales ? locales.map(locale => locale.toLowerCase()) : undefined;
29
+ }
30
+
31
+ canUse(locale) {
32
+ if (!this.locales) {
33
+ return true;
34
+ } else if (this.locales.length === 0) {
35
+ throw new _error.default("Cannot have Elasticsearch Index Template plugin with no locales defined.", "LOCALES_ERROR", {
36
+ body: this.body,
37
+ locales: this.locales
38
+ });
39
+ }
40
+
41
+ return this.locales.includes(locale.toLowerCase());
42
+ }
43
+
44
+ }
45
+
46
+ exports.ElasticsearchIndexPlugin = ElasticsearchIndexPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ElasticsearchIndexPlugin","Plugin","constructor","params","locales","body","map","locale","toLowerCase","undefined","canUse","length","WebinyError","includes"],"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;;AACA;;AAcO,MAAeA,wBAAf,SAAgDC,eAAhD,CAAuD;EAInDC,WAAW,CAACC,MAAD,EAAyC;IACvD;IADuD;IAAA;IAEvD,MAAM;MAAEC,OAAF;MAAWC;IAAX,IAAoBF,MAA1B;IACA,KAAKE,IAAL,mCACOA,IADP;IAGA,KAAKD,OAAL,GAAeA,OAAO,GAAGA,OAAO,CAACE,GAAR,CAAYC,MAAM,IAAIA,MAAM,CAACC,WAAP,EAAtB,CAAH,GAAiDC,SAAvE;EACH;;EAEMC,MAAM,CAACH,MAAD,EAA0B;IACnC,IAAI,CAAC,KAAKH,OAAV,EAAmB;MACf,OAAO,IAAP;IACH,CAFD,MAEO,IAAI,KAAKA,OAAL,CAAaO,MAAb,KAAwB,CAA5B,EAA+B;MAClC,MAAM,IAAIC,cAAJ,CACF,0EADE,EAEF,eAFE,EAGF;QACIP,IAAI,EAAE,KAAKA,IADf;QAEID,OAAO,EAAE,KAAKA;MAFlB,CAHE,CAAN;IAQH;;IACD,OAAO,KAAKA,OAAL,CAAaS,QAAb,CAAsBN,MAAM,CAACC,WAAP,EAAtB,CAAP;EACH;;AA3ByD"}
@@ -4,7 +4,11 @@ import { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } fro
4
4
  * Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.
5
5
  */
6
6
  export declare abstract class ElasticsearchQueryBuilderOperatorPlugin extends Plugin {
7
- static readonly type = "elasticsearch.queryBuilder.operator";
7
+ static readonly type: string;
8
+ /**
9
+ * Check if current locale is supported by this plugin.
10
+ */
11
+ isLocaleSupported(_: string): boolean;
8
12
  abstract getOperator(): string;
9
13
  abstract apply(query: ElasticsearchBoolQueryConfig, params: ElasticsearchQueryBuilderArgsPlugin): void;
10
14
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -14,7 +14,16 @@ var _plugins = require("@webiny/plugins");
14
14
  /**
15
15
  * Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.
16
16
  */
17
- class ElasticsearchQueryBuilderOperatorPlugin extends _plugins.Plugin {}
17
+ class ElasticsearchQueryBuilderOperatorPlugin extends _plugins.Plugin {
18
+ /**
19
+ * Check if current locale is supported by this plugin.
20
+ */
21
+ // eslint-disable-next-line
22
+ isLocaleSupported(_) {
23
+ return true;
24
+ }
25
+
26
+ }
18
27
 
19
28
  exports.ElasticsearchQueryBuilderOperatorPlugin = ElasticsearchQueryBuilderOperatorPlugin;
20
29
  (0, _defineProperty2.default)(ElasticsearchQueryBuilderOperatorPlugin, "type", "elasticsearch.queryBuilder.operator");
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ElasticsearchQueryBuilderOperatorPlugin","Plugin","isLocaleSupported","_"],"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;;AAGA;AACA;AACA;AACO,MAAeA,uCAAf,SAA+DC,eAA/D,CAAsE;EAGzE;AACJ;AACA;EACI;EACOC,iBAAiB,CAACC,CAAD,EAAqB;IACzC,OAAO,IAAP;EACH;;AATwE;;;8BAAvDH,uC,UAC6B,qC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ElasticsearchQueryModifierPlugin","Plugin","constructor","callable","modifyQuery","params","WebinyError"],"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;;AACA;;AAYO,MAAeA,gCAAf,SAEGC,eAFH,CAEU;EAGNC,WAAW,CAACC,QAAD,EAAoC;IAClD;IADkD;IAElD,KAAKA,QAAL,GAAgBA,QAAhB;EACH;;EAEMC,WAAW,CAACC,MAAD,EAAkB;IAChC,IAAI,OAAO,KAAKF,QAAZ,KAAyB,UAA7B,EAAyC;MACrC,MAAM,IAAIG,cAAJ,CACD,qCADC,EAEF,4BAFE,EAGF;QACID;MADJ,CAHE,CAAN;IAOH;;IACD,KAAKF,QAAL,CAAcE,MAAd;EACH;;AAnBY"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ElasticsearchSortModifierPlugin","Plugin","constructor","callable","modifySort","params","WebinyError"],"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;;AACA;;AAWO,MAAeA,+BAAf,SAEGC,eAFH,CAEU;EAGNC,WAAW,CAACC,QAAD,EAAmC;IACjD;IADiD;IAEjD,KAAKA,QAAL,GAAgBA,QAAhB;EACH;;EAEMC,UAAU,CAACC,MAAD,EAAkB;IAC/B,IAAI,OAAO,KAAKF,QAAZ,KAAyB,UAA7B,EAAyC;MACrC,MAAM,IAAIG,cAAJ,CACD,oCADC,EAEF,2BAFE,EAGF;QACID;MADJ,CAHE,CAAN;IAOH;;IACD,KAAKF,QAAL,CAAcE,MAAd;EACH;;AAnBY"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ElasticsearchQueryBuilderOperatorAndInPlugin","ElasticsearchQueryBuilderOperatorPlugin","getOperator","apply","query","params","value","values","path","basePath","isArray","Array","length","Error","useBasePath","must","push","term"],"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.must.push({\n term: {\n [useBasePath ? basePath : path]: value\n }\n });\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAGO,MAAMA,4CAAN,SAA2DC,gFAA3D,CAAmG;EAAA;IAAA;IAAA,4CAC/E,mDAD+E;EAAA;;EAG/FC,WAAW,GAAW;IACzB,OAAO,QAAP;EACH;;EAEMC,KAAK,CACRC,KADQ,EAERC,MAFQ,EAGJ;IACJ,MAAM;MAAEC,KAAK,EAAEC,MAAT;MAAiBC,IAAjB;MAAuBC;IAAvB,IAAoCJ,MAA1C;IACA,MAAMK,OAAO,GAAGC,KAAK,CAACD,OAAN,CAAcH,MAAd,CAAhB;;IACA,IAAIG,OAAO,KAAK,KAAZ,IAAqBH,MAAM,CAACK,MAAP,KAAkB,CAA3C,EAA8C;MAC1C,MAAM,IAAIC,KAAJ,CACD,4BAA2BL,IAAK,uDAD/B,CAAN;IAGH;;IAED,IAAIM,WAAW,GAAG,KAAlB,CATI,CAUJ;;IACA,KAAK,MAAMR,KAAX,IAAoBC,MAApB,EAA4B;MACxB,IAAI,OAAOD,KAAP,KAAiB,QAArB,EAA+B;QAC3BQ,WAAW,GAAG,IAAd;QACA;MACH;IACJ;;IAED,KAAK,MAAMR,KAAX,IAAoBC,MAApB,EAA4B;MACxBH,KAAK,CAACW,IAAN,CAAWC,IAAX,CAAgB;QACZC,IAAI,EAAE;UACF,CAACH,WAAW,GAAGL,QAAH,GAAcD,IAA1B,GAAiCF;QAD/B;MADM,CAAhB;IAKH;EACJ;;AAnCqG"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ElasticsearchQueryBuilderOperatorBetweenPlugin","ElasticsearchQueryBuilderOperatorPlugin","getOperator","apply","query","params","value","basePath","Array","isArray","Error","length","gte","lte","must","push","range"],"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 } = params;\n if (Array.isArray(value) === false) {\n throw new Error(\n `You cannot filter field path \"${basePath}\" 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 \"${basePath}\" 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.must.push({\n range: {\n [basePath]: {\n lte,\n gte\n }\n }\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAGO,MAAMA,8CAAN,SAA6DC,gFAA7D,CAAqG;EAAA;IAAA;IAAA,4CACjF,qDADiF;EAAA;;EAGjGC,WAAW,GAAW;IACzB,OAAO,SAAP;EACH;;EAEMC,KAAK,CACRC,KADQ,EAERC,MAFQ,EAGJ;IACJ,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAsBF,MAA5B;;IACA,IAAIG,KAAK,CAACC,OAAN,CAAcH,KAAd,MAAyB,KAA7B,EAAoC;MAChC,MAAM,IAAII,KAAJ,CACD,iCAAgCH,QAAS,uDADxC,CAAN;IAGH,CAJD,MAIO,IAAID,KAAK,CAACK,MAAN,KAAiB,CAArB,EAAwB;MAC3B,MAAM,IAAID,KAAJ,CACD,uDAAsDH,QAAS,cAD9D,CAAN;IAGH,CAVG,CAWJ;IACA;;;IACA,MAAM,CAACK,GAAD,EAAMC,GAAN,IAAaP,KAAnB;IACAF,KAAK,CAACU,IAAN,CAAWC,IAAX,CAAgB;MACZC,KAAK,EAAE;QACH,CAACT,QAAD,GAAY;UACRM,GADQ;UAERD;QAFQ;MADT;IADK,CAAhB;EAQH;;AAhCuG"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ElasticsearchQueryBuilderOperatorContainsPlugin","ElasticsearchQueryBuilderOperatorPlugin","getOperator","apply","query","params","value","basePath","must","push","query_string","allow_leading_wildcard","fields","normalizeValue","default_operator"],"sources":["contains.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { normalizeValue } 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: normalizeValue(value),\n default_operator: \"and\"\n }\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAGO,MAAMA,+CAAN,SAA8DC,gFAA9D,CAAsG;EAAA;IAAA;IAAA,4CAClF,sDADkF;EAAA;;EAGlGC,WAAW,GAAW;IACzB,OAAO,UAAP;EACH;;EAEMC,KAAK,CACRC,KADQ,EAERC,MAFQ,EAGJ;IACJ,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAsBF,MAA5B;IACAD,KAAK,CAACI,IAAN,CAAWC,IAAX,CAAgB;MACZC,YAAY,EAAE;QACVC,sBAAsB,EAAE,IADd;QAEVC,MAAM,EAAE,CAACL,QAAD,CAFE;QAGVH,KAAK,EAAE,IAAAS,yBAAA,EAAeP,KAAf,CAHG;QAIVQ,gBAAgB,EAAE;MAJR;IADF,CAAhB;EAQH;;AApBwG"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -27,11 +27,21 @@ class ElasticsearchQueryBuilderOperatorEqualPlugin extends _ElasticsearchQueryBu
27
27
  path,
28
28
  basePath
29
29
  } = params;
30
+
31
+ if (value === null) {
32
+ query.must_not.push({
33
+ exists: {
34
+ field: path
35
+ }
36
+ });
37
+ return;
38
+ }
30
39
  /**
31
40
  * In case we are searching for a string, use regular path.
32
41
  * Otherwise use base path
33
42
  */
34
43
 
44
+
35
45
  const useBasePath = typeof value !== "string";
36
46
  query.must.push({
37
47
  term: {
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ElasticsearchQueryBuilderOperatorEqualPlugin","ElasticsearchQueryBuilderOperatorPlugin","getOperator","apply","query","params","value","path","basePath","must_not","push","exists","field","useBasePath","must","term"],"sources":["equal.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorEqualPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.equal.default\";\n\n public getOperator(): string {\n return \"eq\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value, path, basePath } = params;\n\n if (value === null) {\n query.must_not.push({\n exists: {\n field: path\n }\n });\n return;\n }\n /**\n * In case we are searching for a string, use regular path.\n * Otherwise use base path\n */\n const useBasePath = typeof value !== \"string\";\n query.must.push({\n term: {\n [useBasePath ? basePath : path]: value\n }\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAGO,MAAMA,4CAAN,SAA2DC,gFAA3D,CAAmG;EAAA;IAAA;IAAA,4CAC/E,mDAD+E;EAAA;;EAG/FC,WAAW,GAAW;IACzB,OAAO,IAAP;EACH;;EAEMC,KAAK,CACRC,KADQ,EAERC,MAFQ,EAGJ;IACJ,MAAM;MAAEC,KAAF;MAASC,IAAT;MAAeC;IAAf,IAA4BH,MAAlC;;IAEA,IAAIC,KAAK,KAAK,IAAd,EAAoB;MAChBF,KAAK,CAACK,QAAN,CAAeC,IAAf,CAAoB;QAChBC,MAAM,EAAE;UACJC,KAAK,EAAEL;QADH;MADQ,CAApB;MAKA;IACH;IACD;AACR;AACA;AACA;;;IACQ,MAAMM,WAAW,GAAG,OAAOP,KAAP,KAAiB,QAArC;IACAF,KAAK,CAACU,IAAN,CAAWJ,IAAX,CAAgB;MACZK,IAAI,EAAE;QACF,CAACF,WAAW,GAAGL,QAAH,GAAcD,IAA1B,GAAiCD;MAD/B;IADM,CAAhB;EAKH;;AA/BqG"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ElasticsearchQueryBuilderOperatorGreaterThanPlugin","ElasticsearchQueryBuilderOperatorPlugin","getOperator","apply","query","params","value","basePath","must","push","range","gt"],"sources":["gt.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorGreaterThanPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.greaterThan.default\";\n\n public getOperator(): string {\n return \"gt\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value, basePath } = params;\n query.must.push({\n range: {\n [basePath]: {\n gt: value\n }\n }\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAGO,MAAMA,kDAAN,SAAiEC,gFAAjE,CAAyG;EAAA;IAAA;IAAA,4CACrF,yDADqF;EAAA;;EAGrGC,WAAW,GAAW;IACzB,OAAO,IAAP;EACH;;EAEMC,KAAK,CACRC,KADQ,EAERC,MAFQ,EAGJ;IACJ,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAsBF,MAA5B;IACAD,KAAK,CAACI,IAAN,CAAWC,IAAX,CAAgB;MACZC,KAAK,EAAE;QACH,CAACH,QAAD,GAAY;UACRI,EAAE,EAAEL;QADI;MADT;IADK,CAAhB;EAOH;;AAnB2G"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin","ElasticsearchQueryBuilderOperatorPlugin","getOperator","apply","query","params","value","basePath","must","push","range","gte"],"sources":["gte.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.greaterThanOrEqualTo.default\";\n\n public getOperator(): string {\n return \"gte\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value, basePath } = params;\n query.must.push({\n range: {\n [basePath]: {\n gte: value\n }\n }\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAGO,MAAMA,2DAAN,SAA0EC,gFAA1E,CAAkH;EAAA;IAAA;IAAA,4CAC9F,kEAD8F;EAAA;;EAG9GC,WAAW,GAAW;IACzB,OAAO,KAAP;EACH;;EAEMC,KAAK,CACRC,KADQ,EAERC,MAFQ,EAGJ;IACJ,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAsBF,MAA5B;IACAD,KAAK,CAACI,IAAN,CAAWC,IAAX,CAAgB;MACZC,KAAK,EAAE;QACH,CAACH,QAAD,GAAY;UACRI,GAAG,EAAEL;QADG;MADT;IADK,CAAhB;EAOH;;AAnBoH"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ElasticsearchQueryBuilderOperatorInPlugin","ElasticsearchQueryBuilderOperatorPlugin","getOperator","apply","query","params","value","values","path","basePath","isArray","Array","length","Error","useBasePath","must","push","terms"],"sources":["in.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorInPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.in.default\";\n\n public getOperator(): string {\n return \"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 query.must.push({\n terms: {\n [useBasePath ? basePath : path]: values\n }\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAGO,MAAMA,yCAAN,SAAwDC,gFAAxD,CAAgG;EAAA;IAAA;IAAA,4CAC5E,gDAD4E;EAAA;;EAG5FC,WAAW,GAAW;IACzB,OAAO,IAAP;EACH;;EAEMC,KAAK,CACRC,KADQ,EAERC,MAFQ,EAGJ;IACJ,MAAM;MAAEC,KAAK,EAAEC,MAAT;MAAiBC,IAAjB;MAAuBC;IAAvB,IAAoCJ,MAA1C;IACA,MAAMK,OAAO,GAAGC,KAAK,CAACD,OAAN,CAAcH,MAAd,CAAhB;;IACA,IAAIG,OAAO,KAAK,KAAZ,IAAqBH,MAAM,CAACK,MAAP,KAAkB,CAA3C,EAA8C;MAC1C,MAAM,IAAIC,KAAJ,CACD,4BAA2BL,IAAK,uDAD/B,CAAN;IAGH;;IAED,IAAIM,WAAW,GAAG,KAAlB,CATI,CAUJ;;IACA,KAAK,MAAMR,KAAX,IAAoBC,MAApB,EAA4B;MACxB,IAAI,OAAOD,KAAP,KAAiB,QAArB,EAA+B;QAC3BQ,WAAW,GAAG,IAAd;QACA;MACH;IACJ;;IAEDV,KAAK,CAACW,IAAN,CAAWC,IAAX,CAAgB;MACZC,KAAK,EAAE;QACH,CAACH,WAAW,GAAGL,QAAH,GAAcD,IAA1B,GAAiCD;MAD9B;IADK,CAAhB;EAKH;;AAjCkG"}
@@ -11,3 +11,6 @@ export * from "./not";
11
11
  export * from "./notBetween";
12
12
  export * from "./notContains";
13
13
  export * from "./notIn";
14
+ export * from "./startsWith";
15
+ export * from "./notStartsWith";
16
+ export * from "./japanese/contains";
@@ -171,4 +171,43 @@ Object.keys(_notIn).forEach(function (key) {
171
171
  return _notIn[key];
172
172
  }
173
173
  });
174
+ });
175
+
176
+ var _startsWith = require("./startsWith");
177
+
178
+ Object.keys(_startsWith).forEach(function (key) {
179
+ if (key === "default" || key === "__esModule") return;
180
+ if (key in exports && exports[key] === _startsWith[key]) return;
181
+ Object.defineProperty(exports, key, {
182
+ enumerable: true,
183
+ get: function () {
184
+ return _startsWith[key];
185
+ }
186
+ });
187
+ });
188
+
189
+ var _notStartsWith = require("./notStartsWith");
190
+
191
+ Object.keys(_notStartsWith).forEach(function (key) {
192
+ if (key === "default" || key === "__esModule") return;
193
+ if (key in exports && exports[key] === _notStartsWith[key]) return;
194
+ Object.defineProperty(exports, key, {
195
+ enumerable: true,
196
+ get: function () {
197
+ return _notStartsWith[key];
198
+ }
199
+ });
200
+ });
201
+
202
+ var _contains2 = require("./japanese/contains");
203
+
204
+ Object.keys(_contains2).forEach(function (key) {
205
+ if (key === "default" || key === "__esModule") return;
206
+ if (key in exports && exports[key] === _contains2[key]) return;
207
+ Object.defineProperty(exports, key, {
208
+ enumerable: true,
209
+ get: function () {
210
+ return _contains2[key];
211
+ }
212
+ });
174
213
  });
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./between\";\nexport * from \"./contains\";\nexport * from \"./equal\";\nexport * from \"./gt\";\nexport * from \"./gte\";\nexport * from \"./andIn\";\nexport * from \"./in\";\nexport * from \"./lt\";\nexport * from \"./lte\";\nexport * from \"./not\";\nexport * from \"./notBetween\";\nexport * from \"./notContains\";\nexport * from \"./notIn\";\nexport * from \"./startsWith\";\nexport * from \"./notStartsWith\";\nexport * from \"./japanese/contains\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,8 @@
1
+ import { ElasticsearchQueryBuilderOperatorPlugin } from "../../definition/ElasticsearchQueryBuilderOperatorPlugin";
2
+ import { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from "../../../types";
3
+ export declare class ElasticsearchQueryBuilderJapaneseOperatorContainsPlugin extends ElasticsearchQueryBuilderOperatorPlugin {
4
+ name: string;
5
+ isLocaleSupported(code: string): boolean;
6
+ getOperator(): string;
7
+ apply(query: ElasticsearchBoolQueryConfig, params: ElasticsearchQueryBuilderArgsPlugin): void;
8
+ }