@webiny/api-opensearch 6.3.0 → 6.4.0-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/client.js +52 -62
- package/client.js.map +1 -1
- package/cursors.js +20 -32
- package/cursors.js.map +1 -1
- package/db/entity.js +14 -16
- package/db/entity.js.map +1 -1
- package/db/index.js +0 -2
- package/db/table.js +10 -14
- package/db/table.js.map +1 -1
- package/db/types.js +0 -3
- package/exports/api/opensearch.js +0 -2
- package/features/OpenSearchClient/OpenSearchClient.js +13 -10
- package/features/OpenSearchClient/OpenSearchClient.js.map +1 -1
- package/features/OpenSearchClient/abstraction.js +2 -1
- package/features/OpenSearchClient/abstraction.js.map +1 -1
- package/features/OpenSearchClient/feature.js +6 -5
- package/features/OpenSearchClient/feature.js.map +1 -1
- package/features/OpenSearchClientFactory/OpenSearchClientFactory.js +8 -9
- package/features/OpenSearchClientFactory/OpenSearchClientFactory.js.map +1 -1
- package/features/OpenSearchClientFactory/abstraction.js +2 -1
- package/features/OpenSearchClientFactory/abstraction.js.map +1 -1
- package/features/OpenSearchClientFactory/feature.js +6 -5
- package/features/OpenSearchClientFactory/feature.js.map +1 -1
- package/features/OpenSearchContext/OpenSearchContext.js +11 -10
- package/features/OpenSearchContext/OpenSearchContext.js.map +1 -1
- package/features/OpenSearchContext/abstraction.js +2 -1
- package/features/OpenSearchContext/abstraction.js.map +1 -1
- package/features/OpenSearchContext/feature.js +7 -8
- package/features/OpenSearchContext/feature.js.map +1 -1
- package/index.js +14 -16
- package/index.js.map +1 -1
- package/indexConfiguration/base.js +25 -26
- package/indexConfiguration/base.js.map +1 -1
- package/indexConfiguration/common.js +39 -41
- package/indexConfiguration/common.js.map +1 -1
- package/indexConfiguration/index.js +0 -2
- package/indexPrefix.js +2 -3
- package/indexPrefix.js.map +1 -1
- package/indices.js +8 -16
- package/indices.js.map +1 -1
- package/limit.js +5 -27
- package/limit.js.map +1 -1
- package/normalize.js +50 -49
- package/normalize.js.map +1 -1
- package/operations/OpenSearchCatHealth.js +24 -25
- package/operations/OpenSearchCatHealth.js.map +1 -1
- package/operations/OpenSearchCatNodes.js +22 -23
- package/operations/OpenSearchCatNodes.js.map +1 -1
- package/operations/index.js +0 -2
- package/operations/stripConnectionFromException.js +11 -14
- package/operations/stripConnectionFromException.js.map +1 -1
- package/operations/types.js +6 -5
- package/operations/types.js.map +1 -1
- package/operators.js +20 -7
- package/operators.js.map +1 -1
- package/package.json +11 -11
- package/plugins/definition/OpenSearchBodyModifierPlugin.js +12 -13
- package/plugins/definition/OpenSearchBodyModifierPlugin.js.map +1 -1
- package/plugins/definition/OpenSearchFieldPlugin.js +43 -60
- package/plugins/definition/OpenSearchFieldPlugin.js.map +1 -1
- package/plugins/definition/OpenSearchIndexPlugin.js +12 -13
- package/plugins/definition/OpenSearchIndexPlugin.js.map +1 -1
- package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js +5 -5
- package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js.map +1 -1
- package/plugins/definition/OpenSearchQueryModifierPlugin.js +12 -13
- package/plugins/definition/OpenSearchQueryModifierPlugin.js.map +1 -1
- package/plugins/definition/OpenSearchSortModifierPlugin.js +12 -13
- package/plugins/definition/OpenSearchSortModifierPlugin.js.map +1 -1
- package/plugins/definition/index.js +0 -2
- package/plugins/index.js +0 -2
- package/plugins/operator/andIn.js +20 -28
- package/plugins/operator/andIn.js.map +1 -1
- package/plugins/operator/between.js +21 -27
- package/plugins/operator/between.js.map +1 -1
- package/plugins/operator/contains.js +21 -19
- package/plugins/operator/contains.js.map +1 -1
- package/plugins/operator/equal.js +27 -44
- package/plugins/operator/equal.js.map +1 -1
- package/plugins/operator/gt.js +18 -18
- package/plugins/operator/gt.js.map +1 -1
- package/plugins/operator/gte.js +18 -18
- package/plugins/operator/gte.js.map +1 -1
- package/plugins/operator/in.js +18 -24
- package/plugins/operator/in.js.map +1 -1
- package/plugins/operator/index.js +0 -2
- package/plugins/operator/lt.js +18 -18
- package/plugins/operator/lt.js.map +1 -1
- package/plugins/operator/lte.js +18 -18
- package/plugins/operator/lte.js.map +1 -1
- package/plugins/operator/not.js +29 -36
- package/plugins/operator/not.js.map +1 -1
- package/plugins/operator/notBetween.js +21 -27
- package/plugins/operator/notBetween.js.map +1 -1
- package/plugins/operator/notContains.js +21 -19
- package/plugins/operator/notContains.js.map +1 -1
- package/plugins/operator/notIn.js +18 -22
- package/plugins/operator/notIn.js.map +1 -1
- package/plugins/operator/notStartsWith.js +16 -18
- package/plugins/operator/notStartsWith.js.map +1 -1
- package/plugins/operator/startsWith.js +16 -18
- package/plugins/operator/startsWith.js.map +1 -1
- package/sharedIndex.js +2 -3
- package/sharedIndex.js.map +1 -1
- package/sort.js +29 -58
- package/sort.js.map +1 -1
- package/types.js +5 -65
- package/types.js.map +1 -1
- package/utils/createIndex.js +56 -78
- package/utils/createIndex.js.map +1 -1
- package/utils/index.js +0 -2
- package/utils/waitUntilHealthy/UnhealthyClusterError.js +8 -7
- package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -1
- package/utils/waitUntilHealthy/WaitUntilHealthy.js +111 -141
- package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -1
- package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +8 -7
- package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -1
- package/utils/waitUntilHealthy/index.js +0 -2
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +9 -10
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -1
- package/utils/waitUntilHealthy/reason/IReason.js +0 -3
- package/utils/waitUntilHealthy/reason/MemoryReason.js +9 -10
- package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -1
- package/utils/waitUntilHealthy/reason/ProcessorReason.js +9 -10
- package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -1
- package/utils/waitUntilHealthy/reason/index.js +0 -2
- package/where.js +41 -74
- package/where.js.map +1 -1
- package/db/index.js.map +0 -1
- package/db/types.js.map +0 -1
- package/exports/api/opensearch.js.map +0 -1
- package/indexConfiguration/index.js.map +0 -1
- package/operations/index.js.map +0 -1
- package/plugins/definition/index.js.map +0 -1
- package/plugins/index.js.map +0 -1
- package/plugins/operator/index.js.map +0 -1
- package/utils/index.js.map +0 -1
- package/utils/waitUntilHealthy/index.js.map +0 -1
- package/utils/waitUntilHealthy/reason/IReason.js.map +0 -1
- package/utils/waitUntilHealthy/reason/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operations/OpenSearchCatNodes.js","sources":["../../src/operations/OpenSearchCatNodes.ts"],"sourcesContent":["import type { IOpenSearchCatNodesResponse } from \"./types.js\";\nimport type { Client } from \"~/client.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException.js\";\n\nexport class OpenSearchCatNodes {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getNodes(): Promise<IOpenSearchCatNodesResponse> {\n try {\n const response = await this.client.cat.nodes({\n format: \"json\"\n });\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.nodes operation.`,\n code: \"OPENSEARCH_NODES_INVALID_RESPONSE\",\n data: response.body\n });\n }\n return response.body;\n } catch (ex) {\n console.error(`Could not fetch cluster nodes information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"names":["OpenSearchCatNodes","client","response","Array","WebinyError","ex","console","error","stripConnectionFromException","JSON"],"mappings":";;AAKO,MAAMA;IAGT,YAAmBC,MAAc,CAAE;QAC/B,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,MAAa,WAAiD;QAC1D,IAAI;YACA,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;gBACzC,QAAQ;YACZ;YACA,IAAI,CAACC,MAAM,OAAO,CAACD,SAAS,IAAI,KAAKA,AAAyB,MAAzBA,SAAS,IAAI,CAAC,MAAM,EACrD,MAAM,IAAIE,YAAY;gBAClB,SAAS;gBACT,MAAM;gBACN,MAAMF,SAAS,IAAI;YACvB;YAEJ,OAAOA,SAAS,IAAI;QACxB,EAAE,OAAOG,IAAI;YACTC,QAAQ,KAAK,CAAC,CAAC,2CAA2C,EAAED,GAAG,OAAO,EAAE;YACxE,MAAME,QAAQC,6BAA6BH;YAC3CC,QAAQ,GAAG,CAACG,KAAK,SAAS,CAACF;YAC3B,MAAMA;QACV;IACJ;AACJ"}
|
package/operations/index.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return ex;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
...ex.meta.meta,
|
|
12
|
-
connection: null
|
|
13
|
-
}
|
|
14
|
-
};
|
|
1
|
+
const stripConnectionFromException = (ex)=>{
|
|
2
|
+
if ("object" != typeof ex) return ex;
|
|
3
|
+
if (!ex?.meta?.meta?.connection) return ex;
|
|
4
|
+
return {
|
|
5
|
+
...ex.meta,
|
|
6
|
+
meta: {
|
|
7
|
+
...ex.meta.meta,
|
|
8
|
+
connection: null
|
|
9
|
+
}
|
|
10
|
+
};
|
|
15
11
|
};
|
|
12
|
+
export { stripConnectionFromException };
|
|
16
13
|
|
|
17
14
|
//# sourceMappingURL=stripConnectionFromException.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operations/stripConnectionFromException.js","sources":["../../src/operations/stripConnectionFromException.ts"],"sourcesContent":["export const stripConnectionFromException = (ex: any): any => {\n if (typeof ex !== \"object\") {\n return ex;\n }\n if (!ex?.meta?.meta?.connection) {\n return ex;\n }\n return {\n ...ex.meta,\n meta: {\n ...ex.meta.meta,\n connection: null\n }\n };\n};\n"],"names":["stripConnectionFromException","ex"],"mappings":"AAAO,MAAMA,+BAA+B,CAACC;IACzC,IAAI,AAAc,YAAd,OAAOA,IACP,OAAOA;IAEX,IAAI,CAACA,IAAI,MAAM,MAAM,YACjB,OAAOA;IAEX,OAAO;QACH,GAAGA,GAAG,IAAI;QACV,MAAM;YACF,GAAGA,GAAG,IAAI,CAAC,IAAI;YACf,YAAY;QAChB;IACJ;AACJ"}
|
package/operations/types.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var types_OpenSearchCatClusterHealthStatus = /*#__PURE__*/ function(OpenSearchCatClusterHealthStatus) {
|
|
2
|
+
OpenSearchCatClusterHealthStatus["Green"] = "green";
|
|
3
|
+
OpenSearchCatClusterHealthStatus["Yellow"] = "yellow";
|
|
4
|
+
OpenSearchCatClusterHealthStatus["Red"] = "red";
|
|
5
|
+
return OpenSearchCatClusterHealthStatus;
|
|
6
6
|
}({});
|
|
7
|
+
export { types_OpenSearchCatClusterHealthStatus as OpenSearchCatClusterHealthStatus };
|
|
7
8
|
|
|
8
9
|
//# sourceMappingURL=types.js.map
|
package/operations/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operations/types.js","sources":["../../src/operations/types.ts"],"sourcesContent":["import type {\n Cat_Health_ResponseBody,\n Cat_Nodes_ResponseBody\n} from \"@opensearch-project/opensearch/api/index.js\";\n\nexport enum OpenSearchCatClusterHealthStatus {\n Green = \"green\",\n Yellow = \"yellow\",\n Red = \"red\"\n}\n\ntype HealthRecord = Cat_Health_ResponseBody[number];\n\ntype NodesRecord = Cat_Nodes_ResponseBody[number];\n\nexport type IOpenSearchCatHealthResponse = HealthRecord;\n\nexport type IOpenSearchCatNodeResponse = NodesRecord;\n\nexport type IOpenSearchCatNodesResponse = IOpenSearchCatNodeResponse[];\n"],"names":["OpenSearchCatClusterHealthStatus"],"mappings":"AAKO,IAAKA,yCAAgCA,WAAAA,GAAAA,SAAhCA,gCAAgC;;;;WAAhCA"}
|
package/operators.js
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import { OpenSearchQueryBuilderOperatorBetweenPlugin,
|
|
2
|
-
const operators = [
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { OpenSearchQueryBuilderOperatorAndInPlugin, OpenSearchQueryBuilderOperatorBetweenPlugin, OpenSearchQueryBuilderOperatorContainsPlugin, OpenSearchQueryBuilderOperatorEqualPlugin, OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin, OpenSearchQueryBuilderOperatorGreaterThanPlugin, OpenSearchQueryBuilderOperatorInPlugin, OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin, OpenSearchQueryBuilderOperatorLesserThanPlugin, OpenSearchQueryBuilderOperatorNotBetweenPlugin, OpenSearchQueryBuilderOperatorNotContainsPlugin, OpenSearchQueryBuilderOperatorNotInPlugin, OpenSearchQueryBuilderOperatorNotPlugin, OpenSearchQueryBuilderOperatorNotStartsWithPlugin, OpenSearchQueryBuilderOperatorStartsWithPlugin } from "./plugins/operator/index.js";
|
|
2
|
+
const operators = [
|
|
3
|
+
new OpenSearchQueryBuilderOperatorBetweenPlugin(),
|
|
4
|
+
new OpenSearchQueryBuilderOperatorNotBetweenPlugin(),
|
|
5
|
+
new OpenSearchQueryBuilderOperatorContainsPlugin(),
|
|
6
|
+
new OpenSearchQueryBuilderOperatorNotContainsPlugin(),
|
|
7
|
+
new OpenSearchQueryBuilderOperatorEqualPlugin(),
|
|
8
|
+
new OpenSearchQueryBuilderOperatorNotPlugin(),
|
|
9
|
+
new OpenSearchQueryBuilderOperatorGreaterThanPlugin(),
|
|
10
|
+
new OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin(),
|
|
11
|
+
new OpenSearchQueryBuilderOperatorLesserThanPlugin(),
|
|
12
|
+
new OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin(),
|
|
13
|
+
new OpenSearchQueryBuilderOperatorInPlugin(),
|
|
14
|
+
new OpenSearchQueryBuilderOperatorAndInPlugin(),
|
|
15
|
+
new OpenSearchQueryBuilderOperatorNotInPlugin(),
|
|
16
|
+
new OpenSearchQueryBuilderOperatorStartsWithPlugin(),
|
|
17
|
+
new OpenSearchQueryBuilderOperatorNotStartsWithPlugin()
|
|
18
|
+
];
|
|
19
|
+
const getOpenSearchOperators = ()=>operators;
|
|
20
|
+
export { getOpenSearchOperators };
|
|
8
21
|
|
|
9
22
|
//# sourceMappingURL=operators.js.map
|
package/operators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operators.js","sources":["../src/operators.ts"],"sourcesContent":["import {\n OpenSearchQueryBuilderOperatorBetweenPlugin,\n OpenSearchQueryBuilderOperatorAndInPlugin,\n OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin,\n OpenSearchQueryBuilderOperatorGreaterThanPlugin,\n OpenSearchQueryBuilderOperatorContainsPlugin,\n OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin,\n OpenSearchQueryBuilderOperatorInPlugin,\n OpenSearchQueryBuilderOperatorLesserThanPlugin,\n OpenSearchQueryBuilderOperatorNotBetweenPlugin,\n OpenSearchQueryBuilderOperatorNotContainsPlugin,\n OpenSearchQueryBuilderOperatorNotPlugin,\n OpenSearchQueryBuilderOperatorNotInPlugin,\n OpenSearchQueryBuilderOperatorEqualPlugin,\n OpenSearchQueryBuilderOperatorStartsWithPlugin,\n OpenSearchQueryBuilderOperatorNotStartsWithPlugin\n} from \"~/plugins/operator/index.js\";\n\nconst operators = [\n new OpenSearchQueryBuilderOperatorBetweenPlugin(),\n new OpenSearchQueryBuilderOperatorNotBetweenPlugin(),\n new OpenSearchQueryBuilderOperatorContainsPlugin(),\n new OpenSearchQueryBuilderOperatorNotContainsPlugin(),\n new OpenSearchQueryBuilderOperatorEqualPlugin(),\n new OpenSearchQueryBuilderOperatorNotPlugin(),\n new OpenSearchQueryBuilderOperatorGreaterThanPlugin(),\n new OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin(),\n new OpenSearchQueryBuilderOperatorLesserThanPlugin(),\n new OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin(),\n new OpenSearchQueryBuilderOperatorInPlugin(),\n new OpenSearchQueryBuilderOperatorAndInPlugin(),\n new OpenSearchQueryBuilderOperatorNotInPlugin(),\n new OpenSearchQueryBuilderOperatorStartsWithPlugin(),\n new OpenSearchQueryBuilderOperatorNotStartsWithPlugin()\n];\n/**\n * We export as a function because there might be something to be sent to the operators at some point.\n * This way, we make it easier to upgrade.\n */\nexport const getOpenSearchOperators = () => operators;\n"],"names":["operators","OpenSearchQueryBuilderOperatorBetweenPlugin","OpenSearchQueryBuilderOperatorNotBetweenPlugin","OpenSearchQueryBuilderOperatorContainsPlugin","OpenSearchQueryBuilderOperatorNotContainsPlugin","OpenSearchQueryBuilderOperatorEqualPlugin","OpenSearchQueryBuilderOperatorNotPlugin","OpenSearchQueryBuilderOperatorGreaterThanPlugin","OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin","OpenSearchQueryBuilderOperatorLesserThanPlugin","OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin","OpenSearchQueryBuilderOperatorInPlugin","OpenSearchQueryBuilderOperatorAndInPlugin","OpenSearchQueryBuilderOperatorNotInPlugin","OpenSearchQueryBuilderOperatorStartsWithPlugin","OpenSearchQueryBuilderOperatorNotStartsWithPlugin","getOpenSearchOperators"],"mappings":";AAkBA,MAAMA,YAAY;IACd,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;CACP;AAKM,MAAMC,yBAAyB,IAAMhB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-opensearch",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -18,23 +18,23 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@opensearch-project/opensearch": "3.6.0",
|
|
21
|
-
"@webiny/api": "6.
|
|
22
|
-
"@webiny/aws-sdk": "6.
|
|
23
|
-
"@webiny/db-dynamodb": "6.
|
|
24
|
-
"@webiny/error": "6.
|
|
25
|
-
"@webiny/feature": "6.
|
|
26
|
-
"@webiny/plugins": "6.
|
|
21
|
+
"@webiny/api": "6.4.0-beta.1",
|
|
22
|
+
"@webiny/aws-sdk": "6.4.0-beta.1",
|
|
23
|
+
"@webiny/db-dynamodb": "6.4.0-beta.1",
|
|
24
|
+
"@webiny/error": "6.4.0-beta.1",
|
|
25
|
+
"@webiny/feature": "6.4.0-beta.1",
|
|
26
|
+
"@webiny/plugins": "6.4.0-beta.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@webiny/build-tools": "6.
|
|
30
|
-
"@webiny/project-utils": "6.
|
|
29
|
+
"@webiny/build-tools": "6.4.0-beta.1",
|
|
30
|
+
"@webiny/project-utils": "6.4.0-beta.1",
|
|
31
31
|
"rimraf": "6.1.3",
|
|
32
32
|
"typescript": "6.0.3",
|
|
33
|
-
"vitest": "4.1.
|
|
33
|
+
"vitest": "4.1.6"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public",
|
|
37
37
|
"directory": "dist"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "73237b8243693038c072bae1c0b783387448cbbe"
|
|
40
40
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import error from "@webiny/error";
|
|
2
2
|
import { Plugin } from "@webiny/plugins";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
class OpenSearchBodyModifierPlugin extends Plugin {
|
|
4
|
+
constructor(callable){
|
|
5
|
+
super();
|
|
6
|
+
this.callable = callable;
|
|
7
|
+
}
|
|
8
|
+
modifyBody(params) {
|
|
9
|
+
if ("function" != typeof this.callable) throw new error("Missing modification for the body.", "BODY_MODIFICATION_MISSING", {
|
|
10
|
+
params
|
|
11
|
+
});
|
|
12
|
+
this.callable(params);
|
|
13
13
|
}
|
|
14
|
-
this.callable(params);
|
|
15
|
-
}
|
|
16
14
|
}
|
|
15
|
+
export { OpenSearchBodyModifierPlugin };
|
|
17
16
|
|
|
18
17
|
//# sourceMappingURL=OpenSearchBodyModifierPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/definition/OpenSearchBodyModifierPlugin.js","sources":["../../../src/plugins/definition/OpenSearchBodyModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { SearchBody } from \"~/types.js\";\n\nexport interface ModifyBodyParams {\n body: SearchBody;\n}\n\nexport interface ModifyBodyCallable<T extends ModifyBodyParams> {\n (params: T): void;\n}\n\nexport abstract class OpenSearchBodyModifierPlugin<\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"],"names":["OpenSearchBodyModifierPlugin","Plugin","callable","params","WebinyError"],"mappings":";;AAYO,MAAeA,qCAEZC;IAGN,YAAmBC,QAAgC,CAAE;QACjD,KAAK;QACL,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEO,WAAWC,MAAS,EAAQ;QAC/B,IAAI,AAAyB,cAAzB,OAAO,IAAI,CAAC,QAAQ,EACpB,MAAM,IAAIC,MACN,sCACA,6BACA;YACID;QACJ;QAGR,IAAI,CAAC,QAAQ,CAACA;IAClB;AACJ"}
|
|
@@ -1,69 +1,52 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
const keywordLessUnmappedType = [
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const keywordLessUnmappedType = [
|
|
3
|
+
"date",
|
|
4
|
+
"long"
|
|
5
|
+
];
|
|
6
|
+
const unmappedTypeHasKeyword = (type)=>{
|
|
7
|
+
if (type) {
|
|
8
|
+
if (keywordLessUnmappedType.includes(type)) return false;
|
|
9
|
+
}
|
|
5
10
|
return true;
|
|
6
|
-
} else if (keywordLessUnmappedType.includes(type)) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
return true;
|
|
10
11
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
class OpenSearchFieldPlugin extends Plugin {
|
|
13
|
+
static{
|
|
14
|
+
this.type = "opensearch.fieldDefinition";
|
|
15
|
+
}
|
|
16
|
+
static{
|
|
17
|
+
this.ALL = "*";
|
|
18
|
+
}
|
|
19
|
+
constructor(params){
|
|
20
|
+
super();
|
|
21
|
+
this.field = params.field;
|
|
22
|
+
this.path = params.path || params.field;
|
|
23
|
+
this.keyword = void 0 === params.keyword ? true : params.keyword;
|
|
24
|
+
this.unmappedType = params.unmappedType;
|
|
25
|
+
if (false === unmappedTypeHasKeyword(params.unmappedType)) this.keyword = false;
|
|
26
|
+
this.sortable = void 0 === params.sortable ? true : params.sortable;
|
|
27
|
+
this.searchable = void 0 === params.searchable ? true : params.searchable;
|
|
28
|
+
}
|
|
29
|
+
getSortOptions(order) {
|
|
30
|
+
const options = {
|
|
31
|
+
order
|
|
32
|
+
};
|
|
33
|
+
if (!this.unmappedType) return options;
|
|
34
|
+
return {
|
|
35
|
+
...options,
|
|
36
|
+
unmapped_type: this.unmappedType
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
getPath(field) {
|
|
40
|
+
return `${this.getBasePath(field)}${this.keyword ? ".keyword" : ""}`;
|
|
22
41
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The default sort options. Extend in your own plugin if you want to add more options.
|
|
28
|
-
*/
|
|
29
|
-
getSortOptions(order) {
|
|
30
|
-
const options = {
|
|
31
|
-
order
|
|
32
|
-
};
|
|
33
|
-
if (!this.unmappedType) {
|
|
34
|
-
return options;
|
|
42
|
+
getBasePath(field) {
|
|
43
|
+
if (this.path === OpenSearchFieldPlugin.ALL) return field;
|
|
44
|
+
return this.path;
|
|
35
45
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.
|
|
39
|
-
unmapped_type: this.unmappedType
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* The default path generator. Extend in your own plugin if you want to add more options.
|
|
44
|
-
* 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.
|
|
45
|
-
*/
|
|
46
|
-
getPath(field) {
|
|
47
|
-
return `${this.getBasePath(field)}${this.keyword ? ".keyword" : ""}`;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* @see getPath
|
|
51
|
-
*
|
|
52
|
-
* This is the default base path generator. Basically it replaces ALL with given field name.
|
|
53
|
-
*/
|
|
54
|
-
getBasePath(field) {
|
|
55
|
-
if (this.path === OpenSearchFieldPlugin.ALL) {
|
|
56
|
-
return field;
|
|
46
|
+
toSearchValue(params) {
|
|
47
|
+
return params.value;
|
|
57
48
|
}
|
|
58
|
-
return this.path;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* The default transformer. Just returns the value by default.
|
|
62
|
-
* Override to implement what ever is required.
|
|
63
|
-
*/
|
|
64
|
-
toSearchValue(params) {
|
|
65
|
-
return params.value;
|
|
66
|
-
}
|
|
67
49
|
}
|
|
50
|
+
export { OpenSearchFieldPlugin };
|
|
68
51
|
|
|
69
52
|
//# sourceMappingURL=OpenSearchFieldPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/definition/OpenSearchFieldPlugin.js","sources":["../../../src/plugins/definition/OpenSearchFieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { FieldSortOptions, SortOrder } from \"~/types.js\";\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 OpenSearchFieldPluginParams {\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 class OpenSearchFieldPlugin extends Plugin {\n public static override readonly type: string = \"opensearch.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: OpenSearchFieldPluginParams) {\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 // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.\n unmapped_type: this.unmappedType as any\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 === OpenSearchFieldPlugin.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"],"names":["keywordLessUnmappedType","unmappedTypeHasKeyword","type","OpenSearchFieldPlugin","Plugin","params","undefined","order","options","field"],"mappings":";AAKA,MAAMA,0BAA0B;IAAC;IAAQ;CAAO;AAEhD,MAAMC,yBAAyB,CAACC;IAC5B,IAAKA,MAEE;QAAA,IAAIF,wBAAwB,QAAQ,CAACE,OACxC,OAAO;IACX;IACA,OAAO;AACX;AAkDO,MAAMC,8BAA8BC;;aACP,IAAI,GAAW;;;aACxB,GAAG,GAAW;;IASrC,YAAYC,MAAmC,CAAE;QAC7C,KAAK;QACL,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI,IAAIA,OAAO,KAAK;QACvC,IAAI,CAAC,OAAO,GAAGA,AAAmBC,WAAnBD,OAAO,OAAO,GAAiB,OAAOA,OAAO,OAAO;QACnE,IAAI,CAAC,YAAY,GAAGA,OAAO,YAAY;QACvC,IAAIJ,AAAgD,UAAhDA,uBAAuBI,OAAO,YAAY,GAC1C,IAAI,CAAC,OAAO,GAAG;QAEnB,IAAI,CAAC,QAAQ,GAAGA,AAAoBC,WAApBD,OAAO,QAAQ,GAAiB,OAAOA,OAAO,QAAQ;QACtE,IAAI,CAAC,UAAU,GAAGA,AAAsBC,WAAtBD,OAAO,UAAU,GAAiB,OAAOA,OAAO,UAAU;IAChF;IAIO,eAAeE,KAAgB,EAAoB;QACtD,MAAMC,UAAU;YACZD;QACJ;QACA,IAAI,CAAC,IAAI,CAAC,YAAY,EAClB,OAAOC;QAEX,OAAO;YACH,GAAGA,OAAO;YAEV,eAAe,IAAI,CAAC,YAAY;QACpC;IACJ;IAKO,QAAQC,KAAa,EAAU;QAClC,OAAO,GAAG,IAAI,CAAC,WAAW,CAACA,SAAS,IAAI,CAAC,OAAO,GAAG,aAAa,IAAI;IACxE;IAMO,YAAYA,KAAa,EAAU;QACtC,IAAI,IAAI,CAAC,IAAI,KAAKN,sBAAsB,GAAG,EACvC,OAAOM;QAEX,OAAO,IAAI,CAAC,IAAI;IACpB;IAKO,cAAcJ,MAA2B,EAAO;QACnD,OAAOA,OAAO,KAAK;IACvB;AACJ"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
2
|
+
class OpenSearchIndexPlugin extends Plugin {
|
|
3
|
+
constructor(params){
|
|
4
|
+
super();
|
|
5
|
+
const { body } = params;
|
|
6
|
+
this.body = {
|
|
7
|
+
...body
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
canUse() {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
15
13
|
}
|
|
14
|
+
export { OpenSearchIndexPlugin };
|
|
16
15
|
|
|
17
16
|
//# sourceMappingURL=OpenSearchIndexPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/definition/OpenSearchIndexPlugin.js","sources":["../../../src/plugins/definition/OpenSearchIndexPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { OpenSearchIndexRequestBody } from \"~/types.js\";\n\nexport interface OpenSearchIndexPluginParams {\n body: OpenSearchIndexRequestBody;\n}\n\nexport abstract class OpenSearchIndexPlugin extends Plugin {\n public readonly body: OpenSearchIndexRequestBody;\n\n public constructor(params: OpenSearchIndexPluginParams) {\n super();\n const { body } = params;\n this.body = {\n ...body\n };\n }\n\n public canUse(): boolean {\n return true;\n }\n}\n"],"names":["OpenSearchIndexPlugin","Plugin","params","body"],"mappings":";AAOO,MAAeA,8BAA8BC;IAGhD,YAAmBC,MAAmC,CAAE;QACpD,KAAK;QACL,MAAM,EAAEC,IAAI,EAAE,GAAGD;QACjB,IAAI,CAAC,IAAI,GAAG;YACR,GAAGC,IAAI;QACX;IACJ;IAEO,SAAkB;QACrB,OAAO;IACX;AACJ"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
static type = "opensearch.queryBuilder.operator";
|
|
2
|
+
class OpenSearchQueryBuilderOperatorPlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "opensearch.queryBuilder.operator";
|
|
5
|
+
}
|
|
7
6
|
}
|
|
7
|
+
export { OpenSearchQueryBuilderOperatorPlugin };
|
|
8
8
|
|
|
9
9
|
//# sourceMappingURL=OpenSearchQueryBuilderOperatorPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js","sources":["../../../src/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\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 OpenSearchQueryBuilderOperatorPlugin extends Plugin {\n public static override readonly type: string = \"opensearch.queryBuilder.operator\";\n\n public abstract getOperator(): string;\n\n public abstract apply(\n query: OpenSearchBoolQueryConfig,\n params: OpenSearchQueryBuilderArgsPlugin\n ): void;\n}\n"],"names":["OpenSearchQueryBuilderOperatorPlugin","Plugin"],"mappings":";AAMO,MAAeA,6CAA6CC;;aAC/B,IAAI,GAAW;;AAQnD"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import error from "@webiny/error";
|
|
2
2
|
import { Plugin } from "@webiny/plugins";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
class OpenSearchQueryModifierPlugin extends Plugin {
|
|
4
|
+
constructor(callable){
|
|
5
|
+
super();
|
|
6
|
+
this.callable = callable;
|
|
7
|
+
}
|
|
8
|
+
modifyQuery(params) {
|
|
9
|
+
if ("function" != typeof this.callable) throw new error("Missing modification for the query.", "QUERY_MODIFICATION_MISSING", {
|
|
10
|
+
params
|
|
11
|
+
});
|
|
12
|
+
this.callable(params);
|
|
13
13
|
}
|
|
14
|
-
this.callable(params);
|
|
15
|
-
}
|
|
16
14
|
}
|
|
15
|
+
export { OpenSearchQueryModifierPlugin };
|
|
17
16
|
|
|
18
17
|
//# sourceMappingURL=OpenSearchQueryModifierPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/definition/OpenSearchQueryModifierPlugin.js","sources":["../../../src/plugins/definition/OpenSearchQueryModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { OpenSearchBoolQueryConfig } from \"~/types.js\";\n\nexport interface ModifyQueryParams {\n query: OpenSearchBoolQueryConfig;\n where: Record<string, any>;\n}\n\nexport interface ModifyQueryCallable<T extends ModifyQueryParams> {\n (params: T): void;\n}\n\nexport abstract class OpenSearchQueryModifierPlugin<\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"],"names":["OpenSearchQueryModifierPlugin","Plugin","callable","params","WebinyError"],"mappings":";;AAaO,MAAeA,sCAEZC;IAGN,YAAmBC,QAAiC,CAAE;QAClD,KAAK;QACL,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEO,YAAYC,MAAS,EAAQ;QAChC,IAAI,AAAyB,cAAzB,OAAO,IAAI,CAAC,QAAQ,EACpB,MAAM,IAAIC,MACN,uCACA,8BACA;YACID;QACJ;QAGR,IAAI,CAAC,QAAQ,CAACA;IAClB;AACJ"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import error from "@webiny/error";
|
|
2
2
|
import { Plugin } from "@webiny/plugins";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
class OpenSearchSortModifierPlugin extends Plugin {
|
|
4
|
+
constructor(callable){
|
|
5
|
+
super();
|
|
6
|
+
this.callable = callable;
|
|
7
|
+
}
|
|
8
|
+
modifySort(params) {
|
|
9
|
+
if ("function" != typeof this.callable) throw new error("Missing modification for the sort.", "SORT_MODIFICATION_MISSING", {
|
|
10
|
+
params
|
|
11
|
+
});
|
|
12
|
+
this.callable(params);
|
|
13
13
|
}
|
|
14
|
-
this.callable(params);
|
|
15
|
-
}
|
|
16
14
|
}
|
|
15
|
+
export { OpenSearchSortModifierPlugin };
|
|
17
16
|
|
|
18
17
|
//# sourceMappingURL=OpenSearchSortModifierPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/definition/OpenSearchSortModifierPlugin.js","sources":["../../../src/plugins/definition/OpenSearchSortModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { Sort } from \"~/types.js\";\n\nexport interface ModifySortParams {\n sort: Sort;\n}\n\nexport interface ModifySortCallable<T extends ModifySortParams> {\n (params: T): void;\n}\n\nexport abstract class OpenSearchSortModifierPlugin<\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"],"names":["OpenSearchSortModifierPlugin","Plugin","callable","params","WebinyError"],"mappings":";;AAYO,MAAeA,qCAEZC;IAGN,YAAmBC,QAAgC,CAAE;QACjD,KAAK;QACL,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEO,WAAWC,MAAS,EAAQ;QAC/B,IAAI,AAAyB,cAAzB,OAAO,IAAI,CAAC,QAAQ,EACpB,MAAM,IAAIC,MACN,sCACA,6BACA;YACID;QACJ;QAGR,IAAI,CAAC,QAAQ,CAACA;IAClB;AACJ"}
|
package/plugins/index.js
CHANGED
|
@@ -1,35 +1,27 @@
|
|
|
1
1
|
import { OpenSearchQueryBuilderOperatorPlugin } from "../definition/OpenSearchQueryBuilderOperatorPlugin.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return "and_in";
|
|
6
|
-
}
|
|
7
|
-
apply(query, params) {
|
|
8
|
-
const {
|
|
9
|
-
value: values,
|
|
10
|
-
path,
|
|
11
|
-
basePath
|
|
12
|
-
} = params;
|
|
13
|
-
const isArray = Array.isArray(values);
|
|
14
|
-
if (isArray === false || values.length === 0) {
|
|
15
|
-
throw new Error(`You cannot filter field "${path}" with "in" operator and not send an array of values.`);
|
|
2
|
+
class OpenSearchQueryBuilderOperatorAndInPlugin extends OpenSearchQueryBuilderOperatorPlugin {
|
|
3
|
+
getOperator() {
|
|
4
|
+
return "and_in";
|
|
16
5
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
useBasePath =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for (const value of values) {
|
|
26
|
-
query.filter.push({
|
|
27
|
-
term: {
|
|
28
|
-
[useBasePath ? basePath : path]: value
|
|
6
|
+
apply(query, params) {
|
|
7
|
+
const { value: values, path, basePath } = params;
|
|
8
|
+
const isArray = Array.isArray(values);
|
|
9
|
+
if (false === isArray || 0 === values.length) throw new Error(`You cannot filter field "${path}" with "in" operator and not send an array of values.`);
|
|
10
|
+
let useBasePath = false;
|
|
11
|
+
for (const value of values)if ("string" != typeof value) {
|
|
12
|
+
useBasePath = true;
|
|
13
|
+
break;
|
|
29
14
|
}
|
|
30
|
-
|
|
15
|
+
for (const value of values)query.filter.push({
|
|
16
|
+
term: {
|
|
17
|
+
[useBasePath ? basePath : path]: value
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
constructor(...args){
|
|
22
|
+
super(...args), this.name = "opensearch.queryBuilder.operator.andIn.default";
|
|
31
23
|
}
|
|
32
|
-
}
|
|
33
24
|
}
|
|
25
|
+
export { OpenSearchQueryBuilderOperatorAndInPlugin };
|
|
34
26
|
|
|
35
27
|
//# sourceMappingURL=andIn.js.map
|