@webiny/api-elasticsearch 0.0.0-mt-1

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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/client.d.ts +5 -0
  4. package/client.js +47 -0
  5. package/compression.d.ts +6 -0
  6. package/compression.js +68 -0
  7. package/cursors.d.ts +9 -0
  8. package/cursors.js +49 -0
  9. package/index.d.ts +9 -0
  10. package/index.js +38 -0
  11. package/limit.d.ts +1 -0
  12. package/limit.js +45 -0
  13. package/normalize.d.ts +5 -0
  14. package/normalize.js +27 -0
  15. package/operators.d.ts +18 -0
  16. package/operators.js +42 -0
  17. package/package.json +49 -0
  18. package/plugins/GzipCompression.d.ts +19 -0
  19. package/plugins/GzipCompression.js +75 -0
  20. package/plugins/definition/CompressionPlugin.d.ts +20 -0
  21. package/plugins/definition/CompressionPlugin.js +17 -0
  22. package/plugins/definition/ElasticsearchBodyModifierPlugin.d.ts +13 -0
  23. package/plugins/definition/ElasticsearchBodyModifierPlugin.js +35 -0
  24. package/plugins/definition/ElasticsearchFieldPlugin.d.ts +87 -0
  25. package/plugins/definition/ElasticsearchFieldPlugin.js +128 -0
  26. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.d.ts +10 -0
  27. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js +20 -0
  28. package/plugins/definition/ElasticsearchQueryModifierPlugin.d.ts +14 -0
  29. package/plugins/definition/ElasticsearchQueryModifierPlugin.js +35 -0
  30. package/plugins/definition/ElasticsearchSortModifierPlugin.d.ts +13 -0
  31. package/plugins/definition/ElasticsearchSortModifierPlugin.js +35 -0
  32. package/plugins/operator/andIn.d.ts +7 -0
  33. package/plugins/operator/andIn.js +56 -0
  34. package/plugins/operator/between.d.ts +7 -0
  35. package/plugins/operator/between.js +51 -0
  36. package/plugins/operator/contains.d.ts +7 -0
  37. package/plugins/operator/contains.js +43 -0
  38. package/plugins/operator/equal.d.ts +7 -0
  39. package/plugins/operator/equal.js +45 -0
  40. package/plugins/operator/gt.d.ts +7 -0
  41. package/plugins/operator/gt.js +40 -0
  42. package/plugins/operator/gte.d.ts +7 -0
  43. package/plugins/operator/gte.js +40 -0
  44. package/plugins/operator/in.d.ts +7 -0
  45. package/plugins/operator/in.js +54 -0
  46. package/plugins/operator/index.d.ts +13 -0
  47. package/plugins/operator/index.js +174 -0
  48. package/plugins/operator/lt.d.ts +7 -0
  49. package/plugins/operator/lt.js +40 -0
  50. package/plugins/operator/lte.d.ts +7 -0
  51. package/plugins/operator/lte.js +40 -0
  52. package/plugins/operator/not.d.ts +7 -0
  53. package/plugins/operator/not.js +40 -0
  54. package/plugins/operator/notBetween.d.ts +7 -0
  55. package/plugins/operator/notBetween.js +51 -0
  56. package/plugins/operator/notContains.d.ts +7 -0
  57. package/plugins/operator/notContains.js +43 -0
  58. package/plugins/operator/notIn.d.ts +7 -0
  59. package/plugins/operator/notIn.js +46 -0
  60. package/sort.d.ts +12 -0
  61. package/sort.js +67 -0
  62. package/types.d.ts +49 -0
  63. package/types.js +18 -0
  64. package/where.d.ts +17 -0
  65. package/where.js +106 -0
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ElasticsearchQueryBuilderOperatorPlugin = require("../definition/ElasticsearchQueryBuilderOperatorPlugin");
13
+
14
+ class ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin extends _ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin {
15
+ constructor(...args) {
16
+ super(...args);
17
+ (0, _defineProperty2.default)(this, "name", "elasticsearch.queryBuilder.operator.greaterThanOrEqualTo.default");
18
+ }
19
+
20
+ getOperator() {
21
+ return "gte";
22
+ }
23
+
24
+ apply(query, params) {
25
+ const {
26
+ value,
27
+ basePath
28
+ } = params;
29
+ query.must.push({
30
+ range: {
31
+ [basePath]: {
32
+ gte: value
33
+ }
34
+ }
35
+ });
36
+ }
37
+
38
+ }
39
+
40
+ exports.ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin = ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin;
@@ -0,0 +1,7 @@
1
+ import { ElasticsearchQueryBuilderOperatorPlugin } from "../definition/ElasticsearchQueryBuilderOperatorPlugin";
2
+ import { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from "../../types";
3
+ export declare class ElasticsearchQueryBuilderOperatorInPlugin extends ElasticsearchQueryBuilderOperatorPlugin {
4
+ name: string;
5
+ getOperator(): string;
6
+ apply(query: ElasticsearchBoolQueryConfig, params: ElasticsearchQueryBuilderArgsPlugin): void;
7
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ElasticsearchQueryBuilderOperatorInPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ElasticsearchQueryBuilderOperatorPlugin = require("../definition/ElasticsearchQueryBuilderOperatorPlugin");
13
+
14
+ class ElasticsearchQueryBuilderOperatorInPlugin extends _ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin {
15
+ constructor(...args) {
16
+ super(...args);
17
+ (0, _defineProperty2.default)(this, "name", "elasticsearch.queryBuilder.operator.in.default");
18
+ }
19
+
20
+ getOperator() {
21
+ return "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
+ query.must.push({
46
+ terms: {
47
+ [useBasePath ? basePath : path]: values
48
+ }
49
+ });
50
+ }
51
+
52
+ }
53
+
54
+ exports.ElasticsearchQueryBuilderOperatorInPlugin = ElasticsearchQueryBuilderOperatorInPlugin;
@@ -0,0 +1,13 @@
1
+ export * from "./between";
2
+ export * from "./contains";
3
+ export * from "./equal";
4
+ export * from "./gt";
5
+ export * from "./gte";
6
+ export * from "./andIn";
7
+ export * from "./in";
8
+ export * from "./lt";
9
+ export * from "./lte";
10
+ export * from "./not";
11
+ export * from "./notBetween";
12
+ export * from "./notContains";
13
+ export * from "./notIn";
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _between = require("./between");
8
+
9
+ Object.keys(_between).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _between[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _between[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _contains = require("./contains");
21
+
22
+ Object.keys(_contains).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _contains[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _contains[key];
29
+ }
30
+ });
31
+ });
32
+
33
+ var _equal = require("./equal");
34
+
35
+ Object.keys(_equal).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _equal[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _equal[key];
42
+ }
43
+ });
44
+ });
45
+
46
+ var _gt = require("./gt");
47
+
48
+ Object.keys(_gt).forEach(function (key) {
49
+ if (key === "default" || key === "__esModule") return;
50
+ if (key in exports && exports[key] === _gt[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _gt[key];
55
+ }
56
+ });
57
+ });
58
+
59
+ var _gte = require("./gte");
60
+
61
+ Object.keys(_gte).forEach(function (key) {
62
+ if (key === "default" || key === "__esModule") return;
63
+ if (key in exports && exports[key] === _gte[key]) return;
64
+ Object.defineProperty(exports, key, {
65
+ enumerable: true,
66
+ get: function () {
67
+ return _gte[key];
68
+ }
69
+ });
70
+ });
71
+
72
+ var _andIn = require("./andIn");
73
+
74
+ Object.keys(_andIn).forEach(function (key) {
75
+ if (key === "default" || key === "__esModule") return;
76
+ if (key in exports && exports[key] === _andIn[key]) return;
77
+ Object.defineProperty(exports, key, {
78
+ enumerable: true,
79
+ get: function () {
80
+ return _andIn[key];
81
+ }
82
+ });
83
+ });
84
+
85
+ var _in = require("./in");
86
+
87
+ Object.keys(_in).forEach(function (key) {
88
+ if (key === "default" || key === "__esModule") return;
89
+ if (key in exports && exports[key] === _in[key]) return;
90
+ Object.defineProperty(exports, key, {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _in[key];
94
+ }
95
+ });
96
+ });
97
+
98
+ var _lt = require("./lt");
99
+
100
+ Object.keys(_lt).forEach(function (key) {
101
+ if (key === "default" || key === "__esModule") return;
102
+ if (key in exports && exports[key] === _lt[key]) return;
103
+ Object.defineProperty(exports, key, {
104
+ enumerable: true,
105
+ get: function () {
106
+ return _lt[key];
107
+ }
108
+ });
109
+ });
110
+
111
+ var _lte = require("./lte");
112
+
113
+ Object.keys(_lte).forEach(function (key) {
114
+ if (key === "default" || key === "__esModule") return;
115
+ if (key in exports && exports[key] === _lte[key]) return;
116
+ Object.defineProperty(exports, key, {
117
+ enumerable: true,
118
+ get: function () {
119
+ return _lte[key];
120
+ }
121
+ });
122
+ });
123
+
124
+ var _not = require("./not");
125
+
126
+ Object.keys(_not).forEach(function (key) {
127
+ if (key === "default" || key === "__esModule") return;
128
+ if (key in exports && exports[key] === _not[key]) return;
129
+ Object.defineProperty(exports, key, {
130
+ enumerable: true,
131
+ get: function () {
132
+ return _not[key];
133
+ }
134
+ });
135
+ });
136
+
137
+ var _notBetween = require("./notBetween");
138
+
139
+ Object.keys(_notBetween).forEach(function (key) {
140
+ if (key === "default" || key === "__esModule") return;
141
+ if (key in exports && exports[key] === _notBetween[key]) return;
142
+ Object.defineProperty(exports, key, {
143
+ enumerable: true,
144
+ get: function () {
145
+ return _notBetween[key];
146
+ }
147
+ });
148
+ });
149
+
150
+ var _notContains = require("./notContains");
151
+
152
+ Object.keys(_notContains).forEach(function (key) {
153
+ if (key === "default" || key === "__esModule") return;
154
+ if (key in exports && exports[key] === _notContains[key]) return;
155
+ Object.defineProperty(exports, key, {
156
+ enumerable: true,
157
+ get: function () {
158
+ return _notContains[key];
159
+ }
160
+ });
161
+ });
162
+
163
+ var _notIn = require("./notIn");
164
+
165
+ Object.keys(_notIn).forEach(function (key) {
166
+ if (key === "default" || key === "__esModule") return;
167
+ if (key in exports && exports[key] === _notIn[key]) return;
168
+ Object.defineProperty(exports, key, {
169
+ enumerable: true,
170
+ get: function () {
171
+ return _notIn[key];
172
+ }
173
+ });
174
+ });
@@ -0,0 +1,7 @@
1
+ import { ElasticsearchQueryBuilderOperatorPlugin } from "../definition/ElasticsearchQueryBuilderOperatorPlugin";
2
+ import { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from "../../types";
3
+ export declare class ElasticsearchQueryBuilderOperatorLesserThanPlugin extends ElasticsearchQueryBuilderOperatorPlugin {
4
+ name: string;
5
+ getOperator(): string;
6
+ apply(query: ElasticsearchBoolQueryConfig, params: ElasticsearchQueryBuilderArgsPlugin): void;
7
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ElasticsearchQueryBuilderOperatorLesserThanPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ElasticsearchQueryBuilderOperatorPlugin = require("../definition/ElasticsearchQueryBuilderOperatorPlugin");
13
+
14
+ class ElasticsearchQueryBuilderOperatorLesserThanPlugin extends _ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin {
15
+ constructor(...args) {
16
+ super(...args);
17
+ (0, _defineProperty2.default)(this, "name", "elasticsearch.queryBuilder.operator.lesserThan.default");
18
+ }
19
+
20
+ getOperator() {
21
+ return "lt";
22
+ }
23
+
24
+ apply(query, params) {
25
+ const {
26
+ value,
27
+ basePath
28
+ } = params;
29
+ query.must.push({
30
+ range: {
31
+ [basePath]: {
32
+ lt: value
33
+ }
34
+ }
35
+ });
36
+ }
37
+
38
+ }
39
+
40
+ exports.ElasticsearchQueryBuilderOperatorLesserThanPlugin = ElasticsearchQueryBuilderOperatorLesserThanPlugin;
@@ -0,0 +1,7 @@
1
+ import { ElasticsearchQueryBuilderOperatorPlugin } from "../definition/ElasticsearchQueryBuilderOperatorPlugin";
2
+ import { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from "../../types";
3
+ export declare class ElasticsearchQueryBuilderOperatorLesserThanOrEqualToPlugin extends ElasticsearchQueryBuilderOperatorPlugin {
4
+ name: string;
5
+ getOperator(): string;
6
+ apply(query: ElasticsearchBoolQueryConfig, params: ElasticsearchQueryBuilderArgsPlugin): void;
7
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ElasticsearchQueryBuilderOperatorLesserThanOrEqualToPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ElasticsearchQueryBuilderOperatorPlugin = require("../definition/ElasticsearchQueryBuilderOperatorPlugin");
13
+
14
+ class ElasticsearchQueryBuilderOperatorLesserThanOrEqualToPlugin extends _ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin {
15
+ constructor(...args) {
16
+ super(...args);
17
+ (0, _defineProperty2.default)(this, "name", "elasticsearch.queryBuilder.operator.lesserThanOrEqualTo.default");
18
+ }
19
+
20
+ getOperator() {
21
+ return "lte";
22
+ }
23
+
24
+ apply(query, params) {
25
+ const {
26
+ value,
27
+ basePath
28
+ } = params;
29
+ query.must.push({
30
+ range: {
31
+ [basePath]: {
32
+ lte: value
33
+ }
34
+ }
35
+ });
36
+ }
37
+
38
+ }
39
+
40
+ exports.ElasticsearchQueryBuilderOperatorLesserThanOrEqualToPlugin = ElasticsearchQueryBuilderOperatorLesserThanOrEqualToPlugin;
@@ -0,0 +1,7 @@
1
+ import { ElasticsearchQueryBuilderOperatorPlugin } from "../definition/ElasticsearchQueryBuilderOperatorPlugin";
2
+ import { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from "../../types";
3
+ export declare class ElasticsearchQueryBuilderOperatorNotPlugin extends ElasticsearchQueryBuilderOperatorPlugin {
4
+ name: string;
5
+ getOperator(): string;
6
+ apply(query: ElasticsearchBoolQueryConfig, params: ElasticsearchQueryBuilderArgsPlugin): void;
7
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ElasticsearchQueryBuilderOperatorNotPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ElasticsearchQueryBuilderOperatorPlugin = require("../definition/ElasticsearchQueryBuilderOperatorPlugin");
13
+
14
+ class ElasticsearchQueryBuilderOperatorNotPlugin extends _ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin {
15
+ constructor(...args) {
16
+ super(...args);
17
+ (0, _defineProperty2.default)(this, "name", "elasticsearch.queryBuilder.operator.not.default");
18
+ }
19
+
20
+ getOperator() {
21
+ return "not";
22
+ }
23
+
24
+ apply(query, params) {
25
+ const {
26
+ value,
27
+ path,
28
+ basePath
29
+ } = params;
30
+ const useBasePath = typeof value !== "string";
31
+ query.must_not.push({
32
+ term: {
33
+ [useBasePath ? basePath : path]: value
34
+ }
35
+ });
36
+ }
37
+
38
+ }
39
+
40
+ exports.ElasticsearchQueryBuilderOperatorNotPlugin = ElasticsearchQueryBuilderOperatorNotPlugin;
@@ -0,0 +1,7 @@
1
+ import { ElasticsearchQueryBuilderOperatorPlugin } from "../definition/ElasticsearchQueryBuilderOperatorPlugin";
2
+ import { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from "../../types";
3
+ export declare class ElasticsearchQueryBuilderOperatorNotBetweenPlugin extends ElasticsearchQueryBuilderOperatorPlugin {
4
+ name: string;
5
+ getOperator(): string;
6
+ apply(query: ElasticsearchBoolQueryConfig, params: ElasticsearchQueryBuilderArgsPlugin): void;
7
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ElasticsearchQueryBuilderOperatorNotBetweenPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ElasticsearchQueryBuilderOperatorPlugin = require("../definition/ElasticsearchQueryBuilderOperatorPlugin");
13
+
14
+ class ElasticsearchQueryBuilderOperatorNotBetweenPlugin extends _ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin {
15
+ constructor(...args) {
16
+ super(...args);
17
+ (0, _defineProperty2.default)(this, "name", "elasticsearch.queryBuilder.operator.notBetween.default");
18
+ }
19
+
20
+ getOperator() {
21
+ return "not_between";
22
+ }
23
+
24
+ apply(query, params) {
25
+ const {
26
+ value,
27
+ basePath
28
+ } = params;
29
+
30
+ if (Array.isArray(value) === false) {
31
+ throw new Error(`You cannot filter field path "${basePath}" with between query and not send an array of values.`);
32
+ } else if (value.length !== 2) {
33
+ throw new Error(`You must pass 2 values in the array for field path "${basePath}" filtering.`);
34
+ } // we take gte first because it should be a lesser value than lte, eg [5, 10]
35
+ // 6 >= gte && 6 <= lte === true which in this case it means that record will not match
36
+
37
+
38
+ const [gte, lte] = value;
39
+ query.must_not.push({
40
+ range: {
41
+ [basePath]: {
42
+ lte,
43
+ gte
44
+ }
45
+ }
46
+ });
47
+ }
48
+
49
+ }
50
+
51
+ exports.ElasticsearchQueryBuilderOperatorNotBetweenPlugin = ElasticsearchQueryBuilderOperatorNotBetweenPlugin;
@@ -0,0 +1,7 @@
1
+ import { ElasticsearchQueryBuilderOperatorPlugin } from "../definition/ElasticsearchQueryBuilderOperatorPlugin";
2
+ import { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from "../../types";
3
+ export declare class ElasticsearchQueryBuilderOperatorNotContainsPlugin extends ElasticsearchQueryBuilderOperatorPlugin {
4
+ name: string;
5
+ getOperator(): string;
6
+ apply(query: ElasticsearchBoolQueryConfig, params: ElasticsearchQueryBuilderArgsPlugin): void;
7
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ElasticsearchQueryBuilderOperatorNotContainsPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ElasticsearchQueryBuilderOperatorPlugin = require("../definition/ElasticsearchQueryBuilderOperatorPlugin");
13
+
14
+ var _normalize = require("../../normalize");
15
+
16
+ class ElasticsearchQueryBuilderOperatorNotContainsPlugin extends _ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin {
17
+ constructor(...args) {
18
+ super(...args);
19
+ (0, _defineProperty2.default)(this, "name", "elasticsearch.queryBuilder.operator.notContains.default");
20
+ }
21
+
22
+ getOperator() {
23
+ return "not_contains";
24
+ }
25
+
26
+ apply(query, params) {
27
+ const {
28
+ value,
29
+ basePath
30
+ } = params;
31
+ query.must_not.push({
32
+ query_string: {
33
+ allow_leading_wildcard: true,
34
+ fields: [basePath],
35
+ query: (0, _normalize.normalizeValue)(value),
36
+ default_operator: "and"
37
+ }
38
+ });
39
+ }
40
+
41
+ }
42
+
43
+ exports.ElasticsearchQueryBuilderOperatorNotContainsPlugin = ElasticsearchQueryBuilderOperatorNotContainsPlugin;
@@ -0,0 +1,7 @@
1
+ import { ElasticsearchQueryBuilderOperatorPlugin } from "../definition/ElasticsearchQueryBuilderOperatorPlugin";
2
+ import { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from "../../types";
3
+ export declare class ElasticsearchQueryBuilderOperatorNotInPlugin extends ElasticsearchQueryBuilderOperatorPlugin {
4
+ name: string;
5
+ getOperator(): string;
6
+ apply(query: ElasticsearchBoolQueryConfig, params: ElasticsearchQueryBuilderArgsPlugin): void;
7
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ElasticsearchQueryBuilderOperatorNotInPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ElasticsearchQueryBuilderOperatorPlugin = require("../definition/ElasticsearchQueryBuilderOperatorPlugin");
13
+
14
+ class ElasticsearchQueryBuilderOperatorNotInPlugin extends _ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin {
15
+ constructor(...args) {
16
+ super(...args);
17
+ (0, _defineProperty2.default)(this, "name", "elasticsearch.queryBuilder.operator.notIn.default");
18
+ }
19
+
20
+ getOperator() {
21
+ return "not_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 "${basePath}" with not_in and not send an array of values.`);
34
+ }
35
+
36
+ const useBasePath = values.some(value => typeof value !== "string");
37
+ query.must_not.push({
38
+ terms: {
39
+ [useBasePath ? basePath : path]: values
40
+ }
41
+ });
42
+ }
43
+
44
+ }
45
+
46
+ exports.ElasticsearchQueryBuilderOperatorNotInPlugin = ElasticsearchQueryBuilderOperatorNotInPlugin;
package/sort.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { SortType, SortOrder } from "./types";
2
+ import { ElasticsearchFieldPlugin } from "./plugins/definition/ElasticsearchFieldPlugin";
3
+ export interface Params {
4
+ sort: string[];
5
+ defaults?: {
6
+ field?: string;
7
+ order?: SortOrder;
8
+ unmappedType?: string;
9
+ };
10
+ fieldPlugins: Record<string, ElasticsearchFieldPlugin>;
11
+ }
12
+ export declare const createSort: (params: Params) => SortType;