@webiny/api-elasticsearch 0.0.0-ee-vpcs.549378cf03

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 (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/client.d.ts +5 -0
  4. package/client.js +55 -0
  5. package/client.js.map +1 -0
  6. package/compression.d.ts +6 -0
  7. package/compression.js +68 -0
  8. package/compression.js.map +1 -0
  9. package/cursors.d.ts +10 -0
  10. package/cursors.js +55 -0
  11. package/cursors.js.map +1 -0
  12. package/index.d.ts +21 -0
  13. package/index.js +203 -0
  14. package/index.js.map +1 -0
  15. package/indexConfiguration/base.d.ts +6 -0
  16. package/indexConfiguration/base.js +45 -0
  17. package/indexConfiguration/base.js.map +1 -0
  18. package/indexConfiguration/common.d.ts +9 -0
  19. package/indexConfiguration/common.js +45 -0
  20. package/indexConfiguration/common.js.map +1 -0
  21. package/indexConfiguration/index.d.ts +3 -0
  22. package/indexConfiguration/index.js +44 -0
  23. package/indexConfiguration/index.js.map +1 -0
  24. package/indexConfiguration/japanese.d.ts +6 -0
  25. package/indexConfiguration/japanese.js +124 -0
  26. package/indexConfiguration/japanese.js.map +1 -0
  27. package/indices.d.ts +9 -0
  28. package/indices.js +35 -0
  29. package/indices.js.map +1 -0
  30. package/limit.d.ts +1 -0
  31. package/limit.js +45 -0
  32. package/limit.js.map +1 -0
  33. package/normalize.d.ts +5 -0
  34. package/normalize.js +24 -0
  35. package/normalize.js.map +1 -0
  36. package/operators.d.ts +9 -0
  37. package/operators.js +56 -0
  38. package/operators.js.map +1 -0
  39. package/package.json +49 -0
  40. package/plugins/GzipCompression.d.ts +24 -0
  41. package/plugins/GzipCompression.js +86 -0
  42. package/plugins/GzipCompression.js.map +1 -0
  43. package/plugins/definition/CompressionPlugin.d.ts +20 -0
  44. package/plugins/definition/CompressionPlugin.js +17 -0
  45. package/plugins/definition/CompressionPlugin.js.map +1 -0
  46. package/plugins/definition/ElasticsearchBodyModifierPlugin.d.ts +13 -0
  47. package/plugins/definition/ElasticsearchBodyModifierPlugin.js +35 -0
  48. package/plugins/definition/ElasticsearchBodyModifierPlugin.js.map +1 -0
  49. package/plugins/definition/ElasticsearchFieldPlugin.d.ts +81 -0
  50. package/plugins/definition/ElasticsearchFieldPlugin.js +104 -0
  51. package/plugins/definition/ElasticsearchFieldPlugin.js.map +1 -0
  52. package/plugins/definition/ElasticsearchIndexPlugin.d.ts +18 -0
  53. package/plugins/definition/ElasticsearchIndexPlugin.js +46 -0
  54. package/plugins/definition/ElasticsearchIndexPlugin.js.map +1 -0
  55. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.d.ts +14 -0
  56. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js +29 -0
  57. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js.map +1 -0
  58. package/plugins/definition/ElasticsearchQueryModifierPlugin.d.ts +14 -0
  59. package/plugins/definition/ElasticsearchQueryModifierPlugin.js +35 -0
  60. package/plugins/definition/ElasticsearchQueryModifierPlugin.js.map +1 -0
  61. package/plugins/definition/ElasticsearchSortModifierPlugin.d.ts +13 -0
  62. package/plugins/definition/ElasticsearchSortModifierPlugin.js +35 -0
  63. package/plugins/definition/ElasticsearchSortModifierPlugin.js.map +1 -0
  64. package/plugins/definition/index.d.ts +7 -0
  65. package/plugins/definition/index.js +96 -0
  66. package/plugins/definition/index.js.map +1 -0
  67. package/plugins/index.d.ts +2 -0
  68. package/plugins/index.js +31 -0
  69. package/plugins/index.js.map +1 -0
  70. package/plugins/operator/andIn.d.ts +7 -0
  71. package/plugins/operator/andIn.js +56 -0
  72. package/plugins/operator/andIn.js.map +1 -0
  73. package/plugins/operator/between.d.ts +7 -0
  74. package/plugins/operator/between.js +52 -0
  75. package/plugins/operator/between.js.map +1 -0
  76. package/plugins/operator/contains.d.ts +7 -0
  77. package/plugins/operator/contains.js +43 -0
  78. package/plugins/operator/contains.js.map +1 -0
  79. package/plugins/operator/equal.d.ts +7 -0
  80. package/plugins/operator/equal.js +74 -0
  81. package/plugins/operator/equal.js.map +1 -0
  82. package/plugins/operator/gt.d.ts +7 -0
  83. package/plugins/operator/gt.js +40 -0
  84. package/plugins/operator/gt.js.map +1 -0
  85. package/plugins/operator/gte.d.ts +7 -0
  86. package/plugins/operator/gte.js +40 -0
  87. package/plugins/operator/gte.js.map +1 -0
  88. package/plugins/operator/in.d.ts +7 -0
  89. package/plugins/operator/in.js +48 -0
  90. package/plugins/operator/in.js.map +1 -0
  91. package/plugins/operator/index.d.ts +16 -0
  92. package/plugins/operator/index.js +213 -0
  93. package/plugins/operator/index.js.map +1 -0
  94. package/plugins/operator/japanese/contains.d.ts +8 -0
  95. package/plugins/operator/japanese/contains.js +58 -0
  96. package/plugins/operator/japanese/contains.js.map +1 -0
  97. package/plugins/operator/lt.d.ts +7 -0
  98. package/plugins/operator/lt.js +40 -0
  99. package/plugins/operator/lt.js.map +1 -0
  100. package/plugins/operator/lte.d.ts +7 -0
  101. package/plugins/operator/lte.js +40 -0
  102. package/plugins/operator/lte.js.map +1 -0
  103. package/plugins/operator/not.d.ts +7 -0
  104. package/plugins/operator/not.js +62 -0
  105. package/plugins/operator/not.js.map +1 -0
  106. package/plugins/operator/notBetween.d.ts +7 -0
  107. package/plugins/operator/notBetween.js +52 -0
  108. package/plugins/operator/notBetween.js.map +1 -0
  109. package/plugins/operator/notContains.d.ts +7 -0
  110. package/plugins/operator/notContains.js +43 -0
  111. package/plugins/operator/notContains.js.map +1 -0
  112. package/plugins/operator/notIn.d.ts +7 -0
  113. package/plugins/operator/notIn.js +47 -0
  114. package/plugins/operator/notIn.js.map +1 -0
  115. package/plugins/operator/notStartsWith.d.ts +7 -0
  116. package/plugins/operator/notStartsWith.js +38 -0
  117. package/plugins/operator/notStartsWith.js.map +1 -0
  118. package/plugins/operator/startsWith.d.ts +7 -0
  119. package/plugins/operator/startsWith.js +38 -0
  120. package/plugins/operator/startsWith.js.map +1 -0
  121. package/sort.d.ts +13 -0
  122. package/sort.js +75 -0
  123. package/sort.js.map +1 -0
  124. package/types.d.ts +208 -0
  125. package/types.js +30 -0
  126. package/types.js.map +1 -0
  127. package/where.d.ts +17 -0
  128. package/where.js +107 -0
  129. package/where.js.map +1 -0
@@ -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"}
@@ -0,0 +1,81 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { FieldSortOptions, SortOrder } from "elastic-ts";
3
+ export declare type UnmappedTypes = "date" | "long" | string;
4
+ export interface ToSearchValueParams {
5
+ /**
6
+ * The value to transform.
7
+ */
8
+ value: any;
9
+ /**
10
+ * When using toSearchValue() in our code we send a field.getPath() value here.
11
+ */
12
+ path: string;
13
+ /**
14
+ * When using toSearchValue() in our code we send a field.getBasePath() value here.
15
+ */
16
+ basePath: string;
17
+ }
18
+ export interface ElasticsearchFieldPluginParams {
19
+ /**
20
+ * Which field is this plugin for.
21
+ */
22
+ field: string;
23
+ /**
24
+ * Some specific path of a field?
25
+ * Example: createdBy is createdBy.id
26
+ */
27
+ path?: string;
28
+ /**
29
+ * Add a .keyword at the end of the field path?
30
+ */
31
+ keyword?: boolean;
32
+ /**
33
+ * Is the field of a specific type, but possibly not mapped?
34
+ * Happens when inserting a date in string format.
35
+ * You need to cast it as date when running the search/sort to work correctly.
36
+ */
37
+ unmappedType?: UnmappedTypes;
38
+ /**
39
+ * Is the field sortable?
40
+ */
41
+ sortable?: boolean;
42
+ /**
43
+ * Is the field searchable?
44
+ */
45
+ searchable?: boolean;
46
+ /**
47
+ * Used to transform the input value for the search.
48
+ */
49
+ toSearchValue?: (params: ToSearchValueParams) => any;
50
+ }
51
+ export declare abstract class ElasticsearchFieldPlugin extends Plugin {
52
+ static readonly type: string;
53
+ static readonly ALL: string;
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);
61
+ /**
62
+ * The default sort options. Extend in your own plugin if you want to add more options.
63
+ */
64
+ getSortOptions(order: SortOrder): FieldSortOptions;
65
+ /**
66
+ * The default path generator. Extend in your own plugin if you want to add more options.
67
+ * 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.
68
+ */
69
+ getPath(field: string): string;
70
+ /**
71
+ * @see getPath
72
+ *
73
+ * This is the default base path generator. Basically it replaces ALL with given field name.
74
+ */
75
+ getBasePath(field: string): string;
76
+ /**
77
+ * The default transformer. Just returns the value by default.
78
+ * Override to implement what ever is required.
79
+ */
80
+ toSearchValue(params: ToSearchValueParams): any;
81
+ }
@@ -0,0 +1,104 @@
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.ElasticsearchFieldPlugin = 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 _plugins = require("@webiny/plugins");
15
+
16
+ const keywordLessUnmappedType = ["date", "long"];
17
+
18
+ const unmappedTypeHasKeyword = type => {
19
+ if (!type) {
20
+ return true;
21
+ } else if (keywordLessUnmappedType.includes(type)) {
22
+ return false;
23
+ }
24
+
25
+ return true;
26
+ };
27
+
28
+ class ElasticsearchFieldPlugin extends _plugins.Plugin {
29
+ constructor(params) {
30
+ super();
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;
41
+
42
+ if (unmappedTypeHasKeyword(params.unmappedType) === false) {
43
+ this.keyword = false;
44
+ }
45
+
46
+ this.sortable = params.sortable === undefined ? true : params.sortable;
47
+ this.searchable = params.searchable === undefined ? true : params.searchable;
48
+ }
49
+ /**
50
+ * The default sort options. Extend in your own plugin if you want to add more options.
51
+ */
52
+
53
+
54
+ getSortOptions(order) {
55
+ const options = {
56
+ order
57
+ };
58
+
59
+ if (!this.unmappedType) {
60
+ return options;
61
+ }
62
+
63
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, options), {}, {
64
+ unmapped_type: this.unmappedType
65
+ });
66
+ }
67
+ /**
68
+ * The default path generator. Extend in your own plugin if you want to add more options.
69
+ * 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.
70
+ */
71
+
72
+
73
+ getPath(field) {
74
+ return `${this.getBasePath(field)}${this.keyword ? ".keyword" : ""}`;
75
+ }
76
+ /**
77
+ * @see getPath
78
+ *
79
+ * This is the default base path generator. Basically it replaces ALL with given field name.
80
+ */
81
+
82
+
83
+ getBasePath(field) {
84
+ if (this.path === ElasticsearchFieldPlugin.ALL) {
85
+ return field;
86
+ }
87
+
88
+ return this.path;
89
+ }
90
+ /**
91
+ * The default transformer. Just returns the value by default.
92
+ * Override to implement what ever is required.
93
+ */
94
+
95
+
96
+ toSearchValue(params) {
97
+ return params.value;
98
+ }
99
+
100
+ }
101
+
102
+ exports.ElasticsearchFieldPlugin = ElasticsearchFieldPlugin;
103
+ (0, _defineProperty2.default)(ElasticsearchFieldPlugin, "type", "elasticsearch.fieldDefinition");
104
+ (0, _defineProperty2.default)(ElasticsearchFieldPlugin, "ALL", "*");
@@ -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"}
@@ -0,0 +1,14 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from "../../types";
3
+ /**
4
+ * Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.
5
+ */
6
+ export declare abstract class ElasticsearchQueryBuilderOperatorPlugin extends Plugin {
7
+ static readonly type: string;
8
+ /**
9
+ * Check if current locale is supported by this plugin.
10
+ */
11
+ isLocaleSupported(_: string): boolean;
12
+ abstract getOperator(): string;
13
+ abstract apply(query: ElasticsearchBoolQueryConfig, params: ElasticsearchQueryBuilderArgsPlugin): void;
14
+ }
@@ -0,0 +1,29 @@
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.ElasticsearchQueryBuilderOperatorPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _plugins = require("@webiny/plugins");
13
+
14
+ /**
15
+ * Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.
16
+ */
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
+ }
27
+
28
+ exports.ElasticsearchQueryBuilderOperatorPlugin = ElasticsearchQueryBuilderOperatorPlugin;
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"}
@@ -0,0 +1,14 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { ElasticsearchBoolQueryConfig } from "../../types";
3
+ export interface ModifyQueryParams {
4
+ query: ElasticsearchBoolQueryConfig;
5
+ where: Record<string, any>;
6
+ }
7
+ export interface ModifyQueryCallable<T extends ModifyQueryParams> {
8
+ (params: T): void;
9
+ }
10
+ export declare abstract class ElasticsearchQueryModifierPlugin<T extends ModifyQueryParams = ModifyQueryParams> extends Plugin {
11
+ private readonly callable?;
12
+ constructor(callable?: ModifyQueryCallable<T>);
13
+ modifyQuery(params: T): void;
14
+ }
@@ -0,0 +1,35 @@
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.ElasticsearchQueryModifierPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ var _plugins = require("@webiny/plugins");
15
+
16
+ class ElasticsearchQueryModifierPlugin extends _plugins.Plugin {
17
+ constructor(callable) {
18
+ super();
19
+ (0, _defineProperty2.default)(this, "callable", void 0);
20
+ this.callable = callable;
21
+ }
22
+
23
+ modifyQuery(params) {
24
+ if (typeof this.callable !== "function") {
25
+ throw new _error.default(`Missing modification for the query.`, "QUERY_MODIFICATION_MISSING", {
26
+ params
27
+ });
28
+ }
29
+
30
+ this.callable(params);
31
+ }
32
+
33
+ }
34
+
35
+ exports.ElasticsearchQueryModifierPlugin = ElasticsearchQueryModifierPlugin;
@@ -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"}
@@ -0,0 +1,13 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { Sort } from "elastic-ts";
3
+ export interface ModifySortParams {
4
+ sort: Sort;
5
+ }
6
+ export interface ModifySortCallable<T extends ModifySortParams> {
7
+ (params: T): void;
8
+ }
9
+ export declare abstract class ElasticsearchSortModifierPlugin<T extends ModifySortParams = ModifySortParams> extends Plugin {
10
+ private readonly callable?;
11
+ constructor(callable?: ModifySortCallable<T>);
12
+ modifySort(params: T): void;
13
+ }
@@ -0,0 +1,35 @@
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.ElasticsearchSortModifierPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ var _plugins = require("@webiny/plugins");
15
+
16
+ class ElasticsearchSortModifierPlugin extends _plugins.Plugin {
17
+ constructor(callable) {
18
+ super();
19
+ (0, _defineProperty2.default)(this, "callable", void 0);
20
+ this.callable = callable;
21
+ }
22
+
23
+ modifySort(params) {
24
+ if (typeof this.callable !== "function") {
25
+ throw new _error.default(`Missing modification for the sort.`, "SORT_MODIFICATION_MISSING", {
26
+ params
27
+ });
28
+ }
29
+
30
+ this.callable(params);
31
+ }
32
+
33
+ }
34
+
35
+ exports.ElasticsearchSortModifierPlugin = ElasticsearchSortModifierPlugin;
@@ -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"}
@@ -0,0 +1,7 @@
1
+ export * from "./CompressionPlugin";
2
+ export * from "./ElasticsearchBodyModifierPlugin";
3
+ export * from "./ElasticsearchFieldPlugin";
4
+ export * from "./ElasticsearchIndexPlugin";
5
+ export * from "./ElasticsearchQueryBuilderOperatorPlugin";
6
+ export * from "./ElasticsearchQueryModifierPlugin";
7
+ export * from "./ElasticsearchSortModifierPlugin";
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _CompressionPlugin = require("./CompressionPlugin");
8
+
9
+ Object.keys(_CompressionPlugin).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _CompressionPlugin[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _CompressionPlugin[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _ElasticsearchBodyModifierPlugin = require("./ElasticsearchBodyModifierPlugin");
21
+
22
+ Object.keys(_ElasticsearchBodyModifierPlugin).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _ElasticsearchBodyModifierPlugin[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _ElasticsearchBodyModifierPlugin[key];
29
+ }
30
+ });
31
+ });
32
+
33
+ var _ElasticsearchFieldPlugin = require("./ElasticsearchFieldPlugin");
34
+
35
+ Object.keys(_ElasticsearchFieldPlugin).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _ElasticsearchFieldPlugin[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _ElasticsearchFieldPlugin[key];
42
+ }
43
+ });
44
+ });
45
+
46
+ var _ElasticsearchIndexPlugin = require("./ElasticsearchIndexPlugin");
47
+
48
+ Object.keys(_ElasticsearchIndexPlugin).forEach(function (key) {
49
+ if (key === "default" || key === "__esModule") return;
50
+ if (key in exports && exports[key] === _ElasticsearchIndexPlugin[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _ElasticsearchIndexPlugin[key];
55
+ }
56
+ });
57
+ });
58
+
59
+ var _ElasticsearchQueryBuilderOperatorPlugin = require("./ElasticsearchQueryBuilderOperatorPlugin");
60
+
61
+ Object.keys(_ElasticsearchQueryBuilderOperatorPlugin).forEach(function (key) {
62
+ if (key === "default" || key === "__esModule") return;
63
+ if (key in exports && exports[key] === _ElasticsearchQueryBuilderOperatorPlugin[key]) return;
64
+ Object.defineProperty(exports, key, {
65
+ enumerable: true,
66
+ get: function () {
67
+ return _ElasticsearchQueryBuilderOperatorPlugin[key];
68
+ }
69
+ });
70
+ });
71
+
72
+ var _ElasticsearchQueryModifierPlugin = require("./ElasticsearchQueryModifierPlugin");
73
+
74
+ Object.keys(_ElasticsearchQueryModifierPlugin).forEach(function (key) {
75
+ if (key === "default" || key === "__esModule") return;
76
+ if (key in exports && exports[key] === _ElasticsearchQueryModifierPlugin[key]) return;
77
+ Object.defineProperty(exports, key, {
78
+ enumerable: true,
79
+ get: function () {
80
+ return _ElasticsearchQueryModifierPlugin[key];
81
+ }
82
+ });
83
+ });
84
+
85
+ var _ElasticsearchSortModifierPlugin = require("./ElasticsearchSortModifierPlugin");
86
+
87
+ Object.keys(_ElasticsearchSortModifierPlugin).forEach(function (key) {
88
+ if (key === "default" || key === "__esModule") return;
89
+ if (key in exports && exports[key] === _ElasticsearchSortModifierPlugin[key]) return;
90
+ Object.defineProperty(exports, key, {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _ElasticsearchSortModifierPlugin[key];
94
+ }
95
+ });
96
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./CompressionPlugin\";\nexport * from \"./ElasticsearchBodyModifierPlugin\";\nexport * from \"./ElasticsearchFieldPlugin\";\nexport * from \"./ElasticsearchIndexPlugin\";\nexport * from \"./ElasticsearchQueryBuilderOperatorPlugin\";\nexport * from \"./ElasticsearchQueryModifierPlugin\";\nexport * from \"./ElasticsearchSortModifierPlugin\";\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"}
@@ -0,0 +1,2 @@
1
+ export * from "./operator";
2
+ export * from "./definition";
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _operator = require("./operator");
8
+
9
+ Object.keys(_operator).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _operator[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _operator[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _definition = require("./definition");
21
+
22
+ Object.keys(_definition).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _definition[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _definition[key];
29
+ }
30
+ });
31
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./operator\";\nexport * from \"./definition\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,7 @@
1
+ import { ElasticsearchQueryBuilderOperatorPlugin } from "../definition/ElasticsearchQueryBuilderOperatorPlugin";
2
+ import { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from "../../types";
3
+ export declare class ElasticsearchQueryBuilderOperatorAndInPlugin extends ElasticsearchQueryBuilderOperatorPlugin {
4
+ name: string;
5
+ getOperator(): string;
6
+ apply(query: ElasticsearchBoolQueryConfig, params: ElasticsearchQueryBuilderArgsPlugin): void;
7
+ }
@@ -0,0 +1,56 @@
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.ElasticsearchQueryBuilderOperatorAndInPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ElasticsearchQueryBuilderOperatorPlugin = require("../definition/ElasticsearchQueryBuilderOperatorPlugin");
13
+
14
+ class ElasticsearchQueryBuilderOperatorAndInPlugin extends _ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin {
15
+ constructor(...args) {
16
+ super(...args);
17
+ (0, _defineProperty2.default)(this, "name", "elasticsearch.queryBuilder.operator.andIn.default");
18
+ }
19
+
20
+ getOperator() {
21
+ return "and_in";
22
+ }
23
+
24
+ apply(query, params) {
25
+ const {
26
+ value: values,
27
+ path,
28
+ basePath
29
+ } = params;
30
+ const isArray = Array.isArray(values);
31
+
32
+ if (isArray === false || values.length === 0) {
33
+ throw new Error(`You cannot filter field "${path}" with "in" operator and not send an array of values.`);
34
+ }
35
+
36
+ let useBasePath = false; // Only use ".keyword" if all of the provided values are strings.
37
+
38
+ for (const value of values) {
39
+ if (typeof value !== "string") {
40
+ useBasePath = true;
41
+ break;
42
+ }
43
+ }
44
+
45
+ for (const value of values) {
46
+ query.filter.push({
47
+ term: {
48
+ [useBasePath ? basePath : path]: value
49
+ }
50
+ });
51
+ }
52
+ }
53
+
54
+ }
55
+
56
+ exports.ElasticsearchQueryBuilderOperatorAndInPlugin = ElasticsearchQueryBuilderOperatorAndInPlugin;