@webiny/api-elasticsearch 5.41.1 → 5.41.2-beta.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.
- package/cursors.d.ts +1 -1
- package/cursors.js +4 -4
- package/cursors.js.map +1 -1
- package/package.json +8 -8
- package/types.d.ts +25 -18
- package/types.js.map +1 -1
package/cursors.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { PrimitiveValue } from "./types";
|
|
|
2
2
|
/**
|
|
3
3
|
* Encode a received cursor value into something that can be passed on to the user.
|
|
4
4
|
*/
|
|
5
|
-
export declare const encodeCursor: (
|
|
5
|
+
export declare const encodeCursor: (input?: PrimitiveValue[]) => string | undefined;
|
|
6
6
|
/**
|
|
7
7
|
* Decode a received value into a Elasticsearch cursor.
|
|
8
8
|
* If no value is received or is not decodable, return undefined.
|
package/cursors.js
CHANGED
|
@@ -7,11 +7,11 @@ exports.encodeCursor = exports.decodeCursor = void 0;
|
|
|
7
7
|
/**
|
|
8
8
|
* Encode a received cursor value into something that can be passed on to the user.
|
|
9
9
|
*/
|
|
10
|
-
const encodeCursor =
|
|
11
|
-
if (!
|
|
10
|
+
const encodeCursor = input => {
|
|
11
|
+
if (!input) {
|
|
12
12
|
return undefined;
|
|
13
13
|
}
|
|
14
|
-
cursor = Array.isArray(
|
|
14
|
+
const cursor = Array.isArray(input) ? input.filter(item => item !== null).map(item => encodeURIComponent(item)) : encodeURIComponent(input);
|
|
15
15
|
try {
|
|
16
16
|
return Buffer.from(JSON.stringify(cursor)).toString("base64");
|
|
17
17
|
} catch (ex) {
|
|
@@ -31,7 +31,7 @@ const decodeCursor = cursor => {
|
|
|
31
31
|
try {
|
|
32
32
|
const value = JSON.parse(Buffer.from(cursor, "base64").toString("ascii"));
|
|
33
33
|
if (Array.isArray(value)) {
|
|
34
|
-
return value.map(decodeURIComponent);
|
|
34
|
+
return value.filter(item => item !== null).map(decodeURIComponent);
|
|
35
35
|
}
|
|
36
36
|
const decoded = decodeURIComponent(value);
|
|
37
37
|
return decoded ? [decoded] : undefined;
|
package/cursors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["encodeCursor","
|
|
1
|
+
{"version":3,"names":["encodeCursor","input","undefined","cursor","Array","isArray","filter","item","map","encodeURIComponent","Buffer","from","JSON","stringify","toString","ex","console","error","message","exports","decodeCursor","value","parse","decodeURIComponent","decoded"],"sources":["cursors.ts"],"sourcesContent":["import { PrimitiveValue } from \"~/types\";\n\n/**\n * Encode a received cursor value into something that can be passed on to the user.\n */\nexport const encodeCursor = (input?: PrimitiveValue[]): string | undefined => {\n if (!input) {\n return undefined;\n }\n\n const cursor = Array.isArray(input)\n ? input\n .filter((item: PrimitiveValue): item is string | number | boolean => item !== null)\n .map(item => encodeURIComponent(item))\n : encodeURIComponent(input);\n\n try {\n return Buffer.from(JSON.stringify(cursor)).toString(\"base64\");\n } catch (ex) {\n console.error(ex.message);\n }\n return undefined;\n};\n/**\n * Decode a received value into a Elasticsearch cursor.\n * If no value is received or is not decodable, return undefined.\n */\nexport const decodeCursor = (cursor?: string | null): PrimitiveValue[] | undefined => {\n if (!cursor) {\n return undefined;\n }\n try {\n const value = JSON.parse(Buffer.from(cursor, \"base64\").toString(\"ascii\"));\n if (Array.isArray(value)) {\n return value.filter(item => item !== null).map(decodeURIComponent);\n }\n const decoded = decodeURIComponent(value);\n return decoded ? [decoded] : undefined;\n } catch (ex) {\n console.error(ex.message);\n }\n return undefined;\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACO,MAAMA,YAAY,GAAIC,KAAwB,IAAyB;EAC1E,IAAI,CAACA,KAAK,EAAE;IACR,OAAOC,SAAS;EACpB;EAEA,MAAMC,MAAM,GAAGC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,GAC7BA,KAAK,CACAK,MAAM,CAAEC,IAAoB,IAAwCA,IAAI,KAAK,IAAI,CAAC,CAClFC,GAAG,CAACD,IAAI,IAAIE,kBAAkB,CAACF,IAAI,CAAC,CAAC,GAC1CE,kBAAkB,CAACR,KAAK,CAAC;EAE/B,IAAI;IACA,OAAOS,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACV,MAAM,CAAC,CAAC,CAACW,QAAQ,CAAC,QAAQ,CAAC;EACjE,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAACG,OAAO,CAAC;EAC7B;EACA,OAAOhB,SAAS;AACpB,CAAC;AACD;AACA;AACA;AACA;AAHAiB,OAAA,CAAAnB,YAAA,GAAAA,YAAA;AAIO,MAAMoB,YAAY,GAAIjB,MAAsB,IAAmC;EAClF,IAAI,CAACA,MAAM,EAAE;IACT,OAAOD,SAAS;EACpB;EACA,IAAI;IACA,MAAMmB,KAAK,GAAGT,IAAI,CAACU,KAAK,CAACZ,MAAM,CAACC,IAAI,CAACR,MAAM,EAAE,QAAQ,CAAC,CAACW,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzE,IAAIV,KAAK,CAACC,OAAO,CAACgB,KAAK,CAAC,EAAE;MACtB,OAAOA,KAAK,CAACf,MAAM,CAACC,IAAI,IAAIA,IAAI,KAAK,IAAI,CAAC,CAACC,GAAG,CAACe,kBAAkB,CAAC;IACtE;IACA,MAAMC,OAAO,GAAGD,kBAAkB,CAACF,KAAK,CAAC;IACzC,OAAOG,OAAO,GAAG,CAACA,OAAO,CAAC,GAAGtB,SAAS;EAC1C,CAAC,CAAC,OAAOa,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAACG,OAAO,CAAC;EAC7B;EACA,OAAOhB,SAAS;AACpB,CAAC;AAACiB,OAAA,CAAAC,YAAA,GAAAA,YAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-elasticsearch",
|
|
3
|
-
"version": "5.41.1",
|
|
3
|
+
"version": "5.41.2-beta.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/webiny/webiny-js.git",
|
|
@@ -13,18 +13,18 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@elastic/elasticsearch": "7.12.0",
|
|
16
|
-
"@webiny/api": "5.41.1",
|
|
17
|
-
"@webiny/error": "5.41.1",
|
|
18
|
-
"@webiny/plugins": "5.41.1",
|
|
19
|
-
"@webiny/utils": "5.41.1",
|
|
16
|
+
"@webiny/api": "5.41.2-beta.1",
|
|
17
|
+
"@webiny/error": "5.41.2-beta.1",
|
|
18
|
+
"@webiny/plugins": "5.41.2-beta.1",
|
|
19
|
+
"@webiny/utils": "5.41.2-beta.1",
|
|
20
20
|
"aws-elasticsearch-connector": "9.2.0",
|
|
21
21
|
"elastic-ts": "0.8.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@babel/cli": "7.24.1",
|
|
25
25
|
"@babel/core": "7.24.3",
|
|
26
|
-
"@webiny/cli": "5.41.1",
|
|
27
|
-
"@webiny/project-utils": "5.41.1",
|
|
26
|
+
"@webiny/cli": "5.41.2-beta.1",
|
|
27
|
+
"@webiny/project-utils": "5.41.2-beta.1",
|
|
28
28
|
"rimraf": "5.0.5",
|
|
29
29
|
"ttypescript": "1.5.15",
|
|
30
30
|
"typescript": "4.9.5"
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"build": "yarn webiny run build",
|
|
38
38
|
"watch": "yarn webiny run watch"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "69a78b382b4de30846edfc2a9d5f73ca223fcc10"
|
|
41
41
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BoolQueryConfig
|
|
3
|
-
import { Context } from "@webiny/api/types";
|
|
1
|
+
import { ApiResponse, Client } from "@elastic/elasticsearch";
|
|
2
|
+
import { BoolQueryConfig, PrimitiveValue, Query as esQuery } from "elastic-ts";
|
|
3
|
+
import { Context, GenericRecord } from "@webiny/api/types";
|
|
4
4
|
/**
|
|
5
5
|
* Re-export some dep lib types.
|
|
6
6
|
*/
|
|
@@ -13,7 +13,7 @@ export interface ElasticsearchContext extends Context {
|
|
|
13
13
|
* To simplify our plugins, we say that query contains arrays of objects, not single objects.
|
|
14
14
|
* And that they all are defined as empty arrays at the start.
|
|
15
15
|
*/
|
|
16
|
-
export interface ElasticsearchBoolQueryConfig extends
|
|
16
|
+
export interface ElasticsearchBoolQueryConfig extends BoolQueryConfig {
|
|
17
17
|
must: esQuery[];
|
|
18
18
|
filter: esQuery[];
|
|
19
19
|
should: esQuery[];
|
|
@@ -59,28 +59,35 @@ export interface ElasticsearchQueryBuilderArgsPlugin {
|
|
|
59
59
|
* Elasticsearch responses.
|
|
60
60
|
*/
|
|
61
61
|
export interface ElasticsearchSearchResponseHit<T> {
|
|
62
|
+
_index: string;
|
|
63
|
+
_type: string;
|
|
64
|
+
_id: string;
|
|
65
|
+
_score: number | null;
|
|
62
66
|
_source: T;
|
|
63
|
-
sort:
|
|
67
|
+
sort: PrimitiveValue[];
|
|
64
68
|
}
|
|
65
69
|
export interface ElasticsearchSearchResponseAggregationBucket<T> {
|
|
66
70
|
key: T;
|
|
67
71
|
doc_count: number;
|
|
68
72
|
}
|
|
69
|
-
export interface
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
total: {
|
|
74
|
-
value: number;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
aggregations: {
|
|
78
|
-
[key: string]: {
|
|
79
|
-
buckets: ElasticsearchSearchResponseAggregationBucket<T>[];
|
|
80
|
-
};
|
|
81
|
-
};
|
|
73
|
+
export interface ElasticsearchSearchResponseBodyHits<T> {
|
|
74
|
+
hits: ElasticsearchSearchResponseHit<T>[];
|
|
75
|
+
total: {
|
|
76
|
+
value: number;
|
|
82
77
|
};
|
|
83
78
|
}
|
|
79
|
+
export interface ElasticsearchSearchResponseBodyAggregations<T> {
|
|
80
|
+
[key: string]: {
|
|
81
|
+
buckets: ElasticsearchSearchResponseAggregationBucket<T>[];
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export interface ElasticsearchSearchResponseBody<T> {
|
|
85
|
+
hits: ElasticsearchSearchResponseBodyHits<T>;
|
|
86
|
+
aggregations: ElasticsearchSearchResponseBodyAggregations<T>;
|
|
87
|
+
}
|
|
88
|
+
export interface ElasticsearchSearchResponse<T = GenericRecord> {
|
|
89
|
+
body: ElasticsearchSearchResponseBody<T>;
|
|
90
|
+
}
|
|
84
91
|
export interface ElasticsearchIndexRequestBodyMappingsDynamicTemplate {
|
|
85
92
|
[key: string]: {
|
|
86
93
|
path_match?: string;
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_elasticsearch","require","_elasticTs","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["types.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"names":["_elasticsearch","require","_elasticTs","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["types.ts"],"sourcesContent":["import { ApiResponse, Client } from \"@elastic/elasticsearch\";\nimport { BoolQueryConfig, PrimitiveValue, Query as esQuery } from \"elastic-ts\";\nimport { Context, GenericRecord } from \"@webiny/api/types\";\n/**\n * Re-export some dep lib types.\n */\nexport * from \"elastic-ts\";\nexport { ApiResponse };\n\nexport interface ElasticsearchContext extends Context {\n elasticsearch: Client;\n}\n\n/**\n * To simplify our plugins, we say that query contains arrays of objects, not single objects.\n * And that they all are defined as empty arrays at the start.\n */\nexport interface ElasticsearchBoolQueryConfig extends BoolQueryConfig {\n must: esQuery[];\n filter: esQuery[];\n should: esQuery[];\n must_not: esQuery[];\n}\n\n/**\n * Definitions of possible Elasticsearch operators.\n *\n * @category Elasticsearch\n */\nexport type ElasticsearchQueryOperator =\n | \"eq\"\n | \"not\"\n | \"in\"\n | \"not_in\"\n | \"contains\"\n | \"not_contains\"\n | \"between\"\n | \"not_between\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\"\n | string;\n\n/**\n * Definition for arguments of the ElasticsearchQueryBuilderOperatorPlugin.apply method.\n *\n * @see ElasticsearchQueryBuilderOperatorPlugin.apply\n *\n * @category Plugin\n * @category Elasticsearch\n */\nexport interface ElasticsearchQueryBuilderArgsPlugin {\n /**\n * Name of the field.\n */\n name: string;\n /**\n * A full path to the field. Including the \".keyword\" if it is added.\n */\n path: string;\n /**\n * A path to the field, plain.\n */\n basePath: string;\n /**\n * Value to apply.\n */\n value: any;\n /**\n * Is path containing the \".keyword\"\n */\n keyword: boolean;\n}\n\n/**\n * Elasticsearch responses.\n */\nexport interface ElasticsearchSearchResponseHit<T> {\n _index: string;\n _type: string;\n _id: string;\n _score: number | null;\n _source: T;\n sort: PrimitiveValue[];\n}\nexport interface ElasticsearchSearchResponseAggregationBucket<T> {\n key: T;\n doc_count: number;\n}\n\nexport interface ElasticsearchSearchResponseBodyHits<T> {\n hits: ElasticsearchSearchResponseHit<T>[];\n total: {\n value: number;\n };\n}\n\nexport interface ElasticsearchSearchResponseBodyAggregations<T> {\n [key: string]: {\n buckets: ElasticsearchSearchResponseAggregationBucket<T>[];\n };\n}\n\nexport interface ElasticsearchSearchResponseBody<T> {\n hits: ElasticsearchSearchResponseBodyHits<T>;\n aggregations: ElasticsearchSearchResponseBodyAggregations<T>;\n}\n\nexport interface ElasticsearchSearchResponse<T = GenericRecord> {\n body: ElasticsearchSearchResponseBody<T>;\n}\n\nexport interface ElasticsearchIndexRequestBodyMappingsDynamicTemplate {\n [key: string]: {\n path_match?: string;\n path_unmatch?: string;\n match_mapping_type?: string;\n match?: string;\n unmatch?: string;\n mapping?: {\n numeric_detection?: boolean;\n date_detection?: boolean;\n type?:\n | \"string\"\n | \"date\"\n | \"binary\"\n | \"boolean\"\n | \"object\"\n | \"ip\"\n | \"geo\"\n | \"long\"\n | \"integer\"\n | \"short\"\n | \"byte\"\n | \"double\"\n | \"float\"\n | \"half_float\"\n | \"scaled_float\"\n | \"unsigned_long\"\n | string;\n search_analyzer?: string;\n analyzer?: string;\n fields?: {\n [key: string]:\n | {\n type: string;\n search_analyzer?: string;\n analyzer?: string;\n ignore_above?: number;\n [key: string]: any;\n }\n | undefined;\n };\n [key: string]: any;\n };\n [key: string]: any;\n };\n}\n\ninterface ElasticsearchIndexRequestBodySettings {\n analysis?: {\n [key: string]: any;\n };\n number_of_shards?: number;\n number_of_routing_shards?: number;\n codec?: string;\n routing_partition_size?: number;\n soft_deletes?: {\n enabled?: boolean;\n retention_lease?: {\n period?: string;\n };\n };\n load_fixed_bitset_filters_eagerly?: boolean;\n shard?: {\n check_on_startup?: boolean | \"checksum\";\n };\n number_of_replicas?: number;\n auto_expand_replicas?: string | \"all\" | false;\n search?: {\n idle?: {\n after?: string;\n };\n };\n refresh_interval?: string;\n max_result_window?: number;\n max_inner_result_window?: number;\n max_rescore_window?: number;\n max_docvalue_fields_search?: number;\n max_script_fields?: number;\n max_ngram_diff?: number;\n max_shingle_diff?: number;\n max_refresh_listeners?: number;\n analyze?: {\n max_token_count?: number;\n };\n highlight?: {\n max_analyzed_offset?: number;\n };\n max_terms_count?: number;\n max_regex_length?: number;\n query?: {\n default_field?: string;\n };\n routing?: {\n allocation?: {\n enable?: \"all\" | \"primaries\" | \"new_primaries\" | \"none\";\n };\n rebalance?: {\n enable?: \"all\" | \"primaries\" | \"new_primaries\" | \"none\";\n };\n };\n gc_deletes?: string;\n default_pipeline?: string;\n final_pipeline?: string;\n hidden?: boolean;\n [key: string]: any;\n}\n\nexport interface ElasticsearchIndexRequestBody {\n settings?: {\n index?: Partial<ElasticsearchIndexRequestBodySettings>;\n };\n mappings: {\n numeric_detection?: boolean;\n dynamic_templates?: ElasticsearchIndexRequestBodyMappingsDynamicTemplate[];\n properties?: {\n [key: string]: {\n analyzer?: string;\n type?: string;\n normalizer?: string;\n index?: string;\n fields?: {\n [key: string]: {\n type: string;\n ignore_above?: number;\n search_analyzer?: string;\n analyzer?: string;\n [key: string]: any;\n };\n };\n [key: string]: any;\n };\n };\n [key: string]: any;\n };\n aliases?: {\n [key: string]: {\n filter?: {\n [key: string]: any;\n };\n index_routing?: string;\n is_hidden?: boolean;\n is_write_index?: boolean;\n routing?: string;\n search_routing?: string;\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAMA,IAAAC,UAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,UAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,UAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,UAAA,CAAAI,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|