@webiny/api-elasticsearch 5.40.5 → 5.40.6-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/package.json +8 -8
- package/plugins/operator/equal.js +1 -1
- package/plugins/operator/equal.js.map +1 -1
- package/plugins/operator/not.js +1 -1
- package/plugins/operator/not.js.map +1 -1
- package/sort.d.ts +1 -1
- package/sort.js +10 -1
- package/sort.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-elasticsearch",
|
|
3
|
-
"version": "5.40.
|
|
3
|
+
"version": "5.40.6-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.40.
|
|
17
|
-
"@webiny/error": "5.40.
|
|
18
|
-
"@webiny/plugins": "5.40.
|
|
19
|
-
"@webiny/utils": "5.40.
|
|
16
|
+
"@webiny/api": "5.40.6-beta.1",
|
|
17
|
+
"@webiny/error": "5.40.6-beta.1",
|
|
18
|
+
"@webiny/plugins": "5.40.6-beta.1",
|
|
19
|
+
"@webiny/utils": "5.40.6-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.40.
|
|
27
|
-
"@webiny/project-utils": "5.40.
|
|
26
|
+
"@webiny/cli": "5.40.6-beta.1",
|
|
27
|
+
"@webiny/project-utils": "5.40.6-beta.1",
|
|
28
28
|
"rimraf": "5.0.5",
|
|
29
29
|
"ttypescript": "1.5.15",
|
|
30
30
|
"typescript": "4.7.4"
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"build": "yarn webiny run build",
|
|
38
38
|
"watch": "yarn webiny run watch"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "8e5c47c1cbad8da50813bea5257f9ab1eb8718c8"
|
|
41
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorEqualPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","path","basePath","must_not","push","exists","field","typeOf","filter","term","useBasePath","valuePath","exports"],"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 const typeOf = typeof value;\n /**\n * If value is a number or boolean, use filtering instead of must/term\n */\n if (typeOf === \"number\" || typeOf === \"boolean\") {\n query.filter.push({\n term: {\n [basePath]: value\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 !== \"string\";\n const valuePath = useBasePath ? basePath : path;\n /**\n * String or something else.\n */\n query.filter.push({\n term: {\n [valuePath]: value\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,4CAA4C,SAASC,gFAAuC,CAAC;EACtFC,IAAI,GAAG,mDAAmD;EAEnEC,WAAWA,CAAA,EAAW;IACzB,OAAO,IAAI;EACf;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK;MAAEC,IAAI;MAAEC;IAAS,CAAC,GAAGH,MAAM;IAExC,IAAIC,KAAK,KAAK,IAAI,EAAE;
|
|
1
|
+
{"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorEqualPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","path","basePath","undefined","must_not","push","exists","field","typeOf","filter","term","useBasePath","valuePath","exports"],"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 || value === undefined) {\n query.must_not.push({\n exists: {\n field: path\n }\n });\n return;\n }\n const typeOf = typeof value;\n /**\n * If value is a number or boolean, use filtering instead of must/term\n */\n if (typeOf === \"number\" || typeOf === \"boolean\") {\n query.filter.push({\n term: {\n [basePath]: value\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 !== \"string\";\n const valuePath = useBasePath ? basePath : path;\n /**\n * String or something else.\n */\n query.filter.push({\n term: {\n [valuePath]: value\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,4CAA4C,SAASC,gFAAuC,CAAC;EACtFC,IAAI,GAAG,mDAAmD;EAEnEC,WAAWA,CAAA,EAAW;IACzB,OAAO,IAAI;EACf;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK;MAAEC,IAAI;MAAEC;IAAS,CAAC,GAAGH,MAAM;IAExC,IAAIC,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKG,SAAS,EAAE;MACvCL,KAAK,CAACM,QAAQ,CAACC,IAAI,CAAC;QAChBC,MAAM,EAAE;UACJC,KAAK,EAAEN;QACX;MACJ,CAAC,CAAC;MACF;IACJ;IACA,MAAMO,MAAM,GAAG,OAAOR,KAAK;IAC3B;AACR;AACA;IACQ,IAAIQ,MAAM,KAAK,QAAQ,IAAIA,MAAM,KAAK,SAAS,EAAE;MAC7CV,KAAK,CAACW,MAAM,CAACJ,IAAI,CAAC;QACdK,IAAI,EAAE;UACF,CAACR,QAAQ,GAAGF;QAChB;MACJ,CAAC,CAAC;MACF;IACJ;IACA;AACR;AACA;AACA;IACQ,MAAMW,WAAW,GAAGH,MAAM,KAAK,QAAQ;IACvC,MAAMI,SAAS,GAAGD,WAAW,GAAGT,QAAQ,GAAGD,IAAI;IAC/C;AACR;AACA;IACQH,KAAK,CAACW,MAAM,CAACJ,IAAI,CAAC;MACdK,IAAI,EAAE;QACF,CAACE,SAAS,GAAGZ;MACjB;IACJ,CAAC,CAAC;EACN;AACJ;AAACa,OAAA,CAAApB,4CAAA,GAAAA,4CAAA","ignoreList":[]}
|
package/plugins/operator/not.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorNotPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","path","basePath","filter","push","exists","field","typeOf","bool","must_not","term","useBasePath","valuePath","exports"],"sources":["not.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorNotPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.not.default\";\n\n public getOperator(): string {\n return \"not\";\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.filter.push({\n exists: {\n field: path\n }\n });\n return;\n }\n\n const typeOf = typeof value;\n\n if (typeOf === \"boolean\") {\n query.filter.push({\n bool: {\n must_not: {\n term: {\n [path]: value\n }\n }\n }\n });\n return;\n }\n\n const useBasePath = typeOf !== \"string\";\n const valuePath = useBasePath ? basePath : path;\n query.must_not.push({\n term: {\n [valuePath]: value\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,0CAA0C,SAASC,gFAAuC,CAAC;EACpFC,IAAI,GAAG,iDAAiD;EAEjEC,WAAWA,CAAA,EAAW;IACzB,OAAO,KAAK;EAChB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK;MAAEC,IAAI;MAAEC;IAAS,CAAC,GAAGH,MAAM;IAExC,IAAIC,KAAK,KAAK,IAAI,EAAE;
|
|
1
|
+
{"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorNotPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","path","basePath","undefined","filter","push","exists","field","typeOf","bool","must_not","term","useBasePath","valuePath","exports"],"sources":["not.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorNotPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.not.default\";\n\n public getOperator(): string {\n return \"not\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value, path, basePath } = params;\n\n if (value === null || value === undefined) {\n query.filter.push({\n exists: {\n field: path\n }\n });\n return;\n }\n\n const typeOf = typeof value;\n\n if (typeOf === \"boolean\") {\n query.filter.push({\n bool: {\n must_not: {\n term: {\n [path]: value\n }\n }\n }\n });\n return;\n }\n\n const useBasePath = typeOf !== \"string\";\n const valuePath = useBasePath ? basePath : path;\n query.must_not.push({\n term: {\n [valuePath]: value\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,0CAA0C,SAASC,gFAAuC,CAAC;EACpFC,IAAI,GAAG,iDAAiD;EAEjEC,WAAWA,CAAA,EAAW;IACzB,OAAO,KAAK;EAChB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK;MAAEC,IAAI;MAAEC;IAAS,CAAC,GAAGH,MAAM;IAExC,IAAIC,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKG,SAAS,EAAE;MACvCL,KAAK,CAACM,MAAM,CAACC,IAAI,CAAC;QACdC,MAAM,EAAE;UACJC,KAAK,EAAEN;QACX;MACJ,CAAC,CAAC;MACF;IACJ;IAEA,MAAMO,MAAM,GAAG,OAAOR,KAAK;IAE3B,IAAIQ,MAAM,KAAK,SAAS,EAAE;MACtBV,KAAK,CAACM,MAAM,CAACC,IAAI,CAAC;QACdI,IAAI,EAAE;UACFC,QAAQ,EAAE;YACNC,IAAI,EAAE;cACF,CAACV,IAAI,GAAGD;YACZ;UACJ;QACJ;MACJ,CAAC,CAAC;MACF;IACJ;IAEA,MAAMY,WAAW,GAAGJ,MAAM,KAAK,QAAQ;IACvC,MAAMK,SAAS,GAAGD,WAAW,GAAGV,QAAQ,GAAGD,IAAI;IAC/CH,KAAK,CAACY,QAAQ,CAACL,IAAI,CAAC;MAChBM,IAAI,EAAE;QACF,CAACE,SAAS,GAAGb;MACjB;IACJ,CAAC,CAAC;EACN;AACJ;AAACc,OAAA,CAAArB,0CAAA,GAAAA,0CAAA","ignoreList":[]}
|
package/sort.d.ts
CHANGED
package/sort.js
CHANGED
|
@@ -33,7 +33,7 @@ const createSort = params => {
|
|
|
33
33
|
/**
|
|
34
34
|
* Cast as string because nothing else should be allowed yet.
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
const result = sort.reduce((acc, value) => {
|
|
37
37
|
if (typeof value !== "string") {
|
|
38
38
|
throw new _error.default(`Sort as object is not supported..`);
|
|
39
39
|
}
|
|
@@ -57,6 +57,15 @@ const createSort = params => {
|
|
|
57
57
|
acc[path] = plugin.getSortOptions(order);
|
|
58
58
|
return acc;
|
|
59
59
|
}, {});
|
|
60
|
+
/**
|
|
61
|
+
* If we do not have id in the sort, we add it as we need a tie_breaker for the Elasticsearch to be able to sort consistently.
|
|
62
|
+
*/
|
|
63
|
+
if (!result["id.keyword"] && !result["id"]) {
|
|
64
|
+
result["id.keyword"] = {
|
|
65
|
+
order: "asc"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
60
69
|
};
|
|
61
70
|
exports.createSort = createSort;
|
|
62
71
|
|
package/sort.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_plugins","sortRegExp","RegExp","createSort","params","sort","defaults","fieldPlugins","length","field","order","unmappedType","unmapped_type","undefined","reduce","acc","value","WebinyError","match","initialOrder","toLowerCase","plugin","ElasticsearchFieldPlugin","ALL","path","getPath","getSortOptions","exports"],"sources":["sort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { FieldSortOptions,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_plugins","sortRegExp","RegExp","createSort","params","sort","defaults","fieldPlugins","length","field","order","unmappedType","unmapped_type","undefined","result","reduce","acc","value","WebinyError","match","initialOrder","toLowerCase","plugin","ElasticsearchFieldPlugin","ALL","path","getPath","getSortOptions","exports"],"sources":["sort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { FieldSortOptions, SortOrder, SortType } from \"~/types\";\nimport { ElasticsearchFieldPlugin } from \"~/plugins\";\n\nconst sortRegExp = new RegExp(/^([a-zA-Z-0-9_@]+)_(ASC|DESC)$/);\n\ninterface CreateSortParams {\n sort: string[];\n defaults?: {\n field?: string;\n order?: SortOrder;\n unmappedType?: string;\n };\n fieldPlugins: Record<string, ElasticsearchFieldPlugin>;\n}\n\nexport const createSort = (params: CreateSortParams): SortType => {\n const { sort, defaults, fieldPlugins } = params;\n if (!sort || sort.length === 0) {\n const { field, order, unmappedType } = defaults || {};\n /**\n * We say that our system defaults is always id since all records we create have some kind of primary ID.\n */\n return {\n [field || \"id.keyword\"]: {\n order: order || \"desc\",\n unmapped_type: unmappedType || undefined\n }\n };\n }\n /**\n * Cast as string because nothing else should be allowed yet.\n */\n const result = sort.reduce((acc, value) => {\n if (typeof value !== \"string\") {\n throw new WebinyError(`Sort as object is not supported..`);\n }\n const match = value.match(sortRegExp);\n\n if (!match) {\n throw new WebinyError(`Cannot sort by \"${value}\".`);\n }\n\n const [, field, initialOrder] = match;\n const order: SortOrder = initialOrder.toLowerCase() === \"asc\" ? \"asc\" : \"desc\";\n\n const plugin: ElasticsearchFieldPlugin =\n fieldPlugins[field] || fieldPlugins[ElasticsearchFieldPlugin.ALL];\n if (!plugin) {\n throw new WebinyError(`Missing plugin for the field \"${field}\"`, \"PLUGIN_SORT_ERROR\", {\n field\n });\n }\n /**\n * In case field plugin is the global one, change the * with actual field name.\n * Custom path methods will return their own values anyway so replacing * will not matter.\n */\n const path = plugin.getPath(field);\n\n acc[path] = plugin.getSortOptions(order);\n\n return acc;\n }, {} as Record<string, FieldSortOptions>);\n /**\n * If we do not have id in the sort, we add it as we need a tie_breaker for the Elasticsearch to be able to sort consistently.\n */\n if (!result[\"id.keyword\"] && !result[\"id\"]) {\n result[\"id.keyword\"] = {\n order: \"asc\"\n };\n }\n return result;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,UAAU,GAAG,IAAIC,MAAM,CAAC,gCAAgC,CAAC;AAYxD,MAAMC,UAAU,GAAIC,MAAwB,IAAe;EAC9D,MAAM;IAAEC,IAAI;IAAEC,QAAQ;IAAEC;EAAa,CAAC,GAAGH,MAAM;EAC/C,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM;MAAEC,KAAK;MAAEC,KAAK;MAAEC;IAAa,CAAC,GAAGL,QAAQ,IAAI,CAAC,CAAC;IACrD;AACR;AACA;IACQ,OAAO;MACH,CAACG,KAAK,IAAI,YAAY,GAAG;QACrBC,KAAK,EAAEA,KAAK,IAAI,MAAM;QACtBE,aAAa,EAAED,YAAY,IAAIE;MACnC;IACJ,CAAC;EACL;EACA;AACJ;AACA;EACI,MAAMC,MAAM,GAAGT,IAAI,CAACU,MAAM,CAAC,CAACC,GAAG,EAAEC,KAAK,KAAK;IACvC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC3B,MAAM,IAAIC,cAAW,CAAE,mCAAkC,CAAC;IAC9D;IACA,MAAMC,KAAK,GAAGF,KAAK,CAACE,KAAK,CAAClB,UAAU,CAAC;IAErC,IAAI,CAACkB,KAAK,EAAE;MACR,MAAM,IAAID,cAAW,CAAE,mBAAkBD,KAAM,IAAG,CAAC;IACvD;IAEA,MAAM,GAAGR,KAAK,EAAEW,YAAY,CAAC,GAAGD,KAAK;IACrC,MAAMT,KAAgB,GAAGU,YAAY,CAACC,WAAW,CAAC,CAAC,KAAK,KAAK,GAAG,KAAK,GAAG,MAAM;IAE9E,MAAMC,MAAgC,GAClCf,YAAY,CAACE,KAAK,CAAC,IAAIF,YAAY,CAACgB,iCAAwB,CAACC,GAAG,CAAC;IACrE,IAAI,CAACF,MAAM,EAAE;MACT,MAAM,IAAIJ,cAAW,CAAE,iCAAgCT,KAAM,GAAE,EAAE,mBAAmB,EAAE;QAClFA;MACJ,CAAC,CAAC;IACN;IACA;AACR;AACA;AACA;IACQ,MAAMgB,IAAI,GAAGH,MAAM,CAACI,OAAO,CAACjB,KAAK,CAAC;IAElCO,GAAG,CAACS,IAAI,CAAC,GAAGH,MAAM,CAACK,cAAc,CAACjB,KAAK,CAAC;IAExC,OAAOM,GAAG;EACd,CAAC,EAAE,CAAC,CAAqC,CAAC;EAC1C;AACJ;AACA;EACI,IAAI,CAACF,MAAM,CAAC,YAAY,CAAC,IAAI,CAACA,MAAM,CAAC,IAAI,CAAC,EAAE;IACxCA,MAAM,CAAC,YAAY,CAAC,GAAG;MACnBJ,KAAK,EAAE;IACX,CAAC;EACL;EACA,OAAOI,MAAM;AACjB,CAAC;AAACc,OAAA,CAAAzB,UAAA,GAAAA,UAAA","ignoreList":[]}
|