@webiny/api-opensearch 6.3.0 → 6.4.0-beta.0
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":"plugins/operator/not.js","sources":["../../../src/plugins/operator/not.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.not.default\";\n\n public getOperator(): string {\n return \"not\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): 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"],"names":["OpenSearchQueryBuilderOperatorNotPlugin","OpenSearchQueryBuilderOperatorPlugin","query","params","value","path","basePath","typeOf","useBasePath","valuePath"],"mappings":";AAGO,MAAMA,gDAAgDC;IAGlD,cAAsB;QACzB,OAAO;IACX;IAEO,MAAMC,KAAgC,EAAEC,MAAwC,EAAQ;QAC3F,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGH;QAElC,IAAIC,QAAAA,OAAuC,YACvCF,MAAM,MAAM,CAAC,IAAI,CAAC;YACd,QAAQ;gBACJ,OAAOG;YACX;QACJ;QAIJ,MAAME,SAAS,OAAOH;QAEtB,IAAIG,AAAW,cAAXA,QAAsB,YACtBL,MAAM,MAAM,CAAC,IAAI,CAAC;YACd,MAAM;gBACF,UAAU;oBACN,MAAM;wBACF,CAACG,KAAK,EAAED;oBACZ;gBACJ;YACJ;QACJ;QAIJ,MAAMI,cAAcD,AAAW,aAAXA;QACpB,MAAME,YAAYD,cAAcF,WAAWD;QAC3CH,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,MAAM;gBACF,CAACO,UAAU,EAAEL;YACjB;QACJ;IACJ;;QAzCG,qBACa,IAAI,GAAG;;AAyC3B"}
|
|
@@ -1,32 +1,26 @@
|
|
|
1
1
|
import { OpenSearchQueryBuilderOperatorPlugin } from "../definition/OpenSearchQueryBuilderOperatorPlugin.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
class OpenSearchQueryBuilderOperatorNotBetweenPlugin extends OpenSearchQueryBuilderOperatorPlugin {
|
|
3
|
+
getOperator() {
|
|
4
|
+
return "not_between";
|
|
5
|
+
}
|
|
6
|
+
apply(query, params) {
|
|
7
|
+
const { value, basePath, name } = params;
|
|
8
|
+
if (false === Array.isArray(value)) throw new Error(`You cannot filter field path "${name}" with "not_between" query and not send an array of values.`);
|
|
9
|
+
if (2 !== value.length) throw new Error(`You must pass 2 values in the array for field path "${name}" filtering.`);
|
|
10
|
+
const [gte, lte] = value;
|
|
11
|
+
query.must_not.push({
|
|
12
|
+
range: {
|
|
13
|
+
[basePath]: {
|
|
14
|
+
lte,
|
|
15
|
+
gte
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
constructor(...args){
|
|
21
|
+
super(...args), this.name = "opensearch.queryBuilder.operator.notBetween.default";
|
|
17
22
|
}
|
|
18
|
-
// we take gte first because it should be a lesser value than lte, eg [5, 10]
|
|
19
|
-
// 6 >= gte && 6 <= lte === true which in this case it means that record will not match
|
|
20
|
-
const [gte, lte] = value;
|
|
21
|
-
query.must_not.push({
|
|
22
|
-
range: {
|
|
23
|
-
[basePath]: {
|
|
24
|
-
lte,
|
|
25
|
-
gte
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
23
|
}
|
|
24
|
+
export { OpenSearchQueryBuilderOperatorNotBetweenPlugin };
|
|
31
25
|
|
|
32
26
|
//# sourceMappingURL=notBetween.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/operator/notBetween.js","sources":["../../../src/plugins/operator/notBetween.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotBetweenPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.notBetween.default\";\n\n public getOperator(): string {\n return \"not_between\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, basePath, name } = params;\n if (Array.isArray(value) === false) {\n throw new Error(\n `You cannot filter field path \"${name}\" with \"not_between\" query and not send an array of values.`\n );\n } else if (value.length !== 2) {\n throw new Error(\n `You must pass 2 values in the array for field path \"${name}\" filtering.`\n );\n }\n // we take gte first because it should be a lesser value than lte, eg [5, 10]\n // 6 >= gte && 6 <= lte === true which in this case it means that record will not match\n const [gte, lte] = value;\n query.must_not.push({\n range: {\n [basePath]: {\n lte,\n gte\n }\n }\n });\n }\n}\n"],"names":["OpenSearchQueryBuilderOperatorNotBetweenPlugin","OpenSearchQueryBuilderOperatorPlugin","query","params","value","basePath","name","Array","Error","gte","lte"],"mappings":";AAGO,MAAMA,uDAAuDC;IAGzD,cAAsB;QACzB,OAAO;IACX;IAEO,MAAMC,KAAgC,EAAEC,MAAwC,EAAQ;QAC3F,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGH;QAClC,IAAII,AAAyB,UAAzBA,MAAM,OAAO,CAACH,QACd,MAAM,IAAII,MACN,CAAC,8BAA8B,EAAEF,KAAK,2DAA2D,CAAC;QAEnG,IAAIF,AAAiB,MAAjBA,MAAM,MAAM,EACnB,MAAM,IAAII,MACN,CAAC,oDAAoD,EAAEF,KAAK,YAAY,CAAC;QAKjF,MAAM,CAACG,KAAKC,IAAI,GAAGN;QACnBF,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,OAAO;gBACH,CAACG,SAAS,EAAE;oBACRK;oBACAD;gBACJ;YACJ;QACJ;IACJ;;QA7BG,qBACa,IAAI,GAAG;;AA6B3B"}
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { OpenSearchQueryBuilderOperatorPlugin } from "../definition/OpenSearchQueryBuilderOperatorPlugin.js";
|
|
2
2
|
import { normalizeValueWithAsterisk } from "../../normalize.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
class OpenSearchQueryBuilderOperatorNotContainsPlugin extends OpenSearchQueryBuilderOperatorPlugin {
|
|
4
|
+
getOperator() {
|
|
5
|
+
return "not_contains";
|
|
6
|
+
}
|
|
7
|
+
apply(query, params) {
|
|
8
|
+
const { value, basePath } = params;
|
|
9
|
+
query.must_not.push({
|
|
10
|
+
query_string: {
|
|
11
|
+
allow_leading_wildcard: true,
|
|
12
|
+
fields: [
|
|
13
|
+
basePath
|
|
14
|
+
],
|
|
15
|
+
query: normalizeValueWithAsterisk(value),
|
|
16
|
+
default_operator: "and"
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
constructor(...args){
|
|
21
|
+
super(...args), this.name = "opensearch.queryBuilder.operator.notContains.default";
|
|
22
|
+
}
|
|
22
23
|
}
|
|
24
|
+
export { OpenSearchQueryBuilderOperatorNotContainsPlugin };
|
|
23
25
|
|
|
24
26
|
//# sourceMappingURL=notContains.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/operator/notContains.js","sources":["../../../src/plugins/operator/notContains.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport { normalizeValueWithAsterisk } from \"~/normalize.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotContainsPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.notContains.default\";\n\n public getOperator(): string {\n return \"not_contains\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, basePath } = params;\n query.must_not.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: [basePath],\n query: normalizeValueWithAsterisk(value),\n default_operator: \"and\"\n }\n });\n }\n}\n"],"names":["OpenSearchQueryBuilderOperatorNotContainsPlugin","OpenSearchQueryBuilderOperatorPlugin","query","params","value","basePath","normalizeValueWithAsterisk"],"mappings":";;AAIO,MAAMA,wDAAwDC;IAG1D,cAAsB;QACzB,OAAO;IACX;IAEO,MAAMC,KAAgC,EAAEC,MAAwC,EAAQ;QAC3F,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGF;QAC5BD,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,cAAc;gBACV,wBAAwB;gBACxB,QAAQ;oBAACG;iBAAS;gBAClB,OAAOC,2BAA2BF;gBAClC,kBAAkB;YACtB;QACJ;IACJ;;QAjBG,qBACa,IAAI,GAAG;;AAiB3B"}
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
import { OpenSearchQueryBuilderOperatorPlugin } from "../definition/OpenSearchQueryBuilderOperatorPlugin.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
class OpenSearchQueryBuilderOperatorNotInPlugin extends OpenSearchQueryBuilderOperatorPlugin {
|
|
3
|
+
getOperator() {
|
|
4
|
+
return "not_in";
|
|
5
|
+
}
|
|
6
|
+
apply(query, params) {
|
|
7
|
+
const { value: values, path, basePath, name } = params;
|
|
8
|
+
const isArray = Array.isArray(values);
|
|
9
|
+
if (false === isArray || 0 === values.length) throw new Error(`You cannot filter field "${name}" with "not_in" operator and not send an array of values.`);
|
|
10
|
+
const useBasePath = values.some((value)=>"string" != typeof value);
|
|
11
|
+
query.must_not.push({
|
|
12
|
+
terms: {
|
|
13
|
+
[useBasePath ? basePath : path]: values
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
constructor(...args){
|
|
18
|
+
super(...args), this.name = "opensearch.queryBuilder.operator.notIn.default";
|
|
17
19
|
}
|
|
18
|
-
const useBasePath = values.some(value => typeof value !== "string");
|
|
19
|
-
query.must_not.push({
|
|
20
|
-
terms: {
|
|
21
|
-
[useBasePath ? basePath : path]: values
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
20
|
}
|
|
21
|
+
export { OpenSearchQueryBuilderOperatorNotInPlugin };
|
|
26
22
|
|
|
27
23
|
//# sourceMappingURL=notIn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/operator/notIn.js","sources":["../../../src/plugins/operator/notIn.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotInPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.notIn.default\";\n\n public getOperator(): string {\n return \"not_in\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value: values, path, basePath, name } = params;\n const isArray = Array.isArray(values);\n if (isArray === false || values.length === 0) {\n throw new Error(\n `You cannot filter field \"${name}\" with \"not_in\" operator and not send an array of values.`\n );\n }\n\n const useBasePath = values.some(\n (value: string | number | boolean | null | undefined) => typeof value !== \"string\"\n );\n\n query.must_not.push({\n terms: {\n [useBasePath ? basePath : path]: values\n }\n });\n }\n}\n"],"names":["OpenSearchQueryBuilderOperatorNotInPlugin","OpenSearchQueryBuilderOperatorPlugin","query","params","values","path","basePath","name","isArray","Array","Error","useBasePath","value"],"mappings":";AAGO,MAAMA,kDAAkDC;IAGpD,cAAsB;QACzB,OAAO;IACX;IAEO,MAAMC,KAAgC,EAAEC,MAAwC,EAAQ;QAC3F,MAAM,EAAE,OAAOC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGJ;QAChD,MAAMK,UAAUC,MAAM,OAAO,CAACL;QAC9B,IAAII,AAAY,UAAZA,WAAqBJ,AAAkB,MAAlBA,OAAO,MAAM,EAClC,MAAM,IAAIM,MACN,CAAC,yBAAyB,EAAEH,KAAK,yDAAyD,CAAC;QAInG,MAAMI,cAAcP,OAAO,IAAI,CAC3B,CAACQ,QAAwD,AAAiB,YAAjB,OAAOA;QAGpEV,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,OAAO;gBACH,CAACS,cAAcL,WAAWD,KAAK,EAAED;YACrC;QACJ;IACJ;;QAzBG,qBACa,IAAI,GAAG;;AAyB3B"}
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { OpenSearchQueryBuilderOperatorPlugin } from "../definition/OpenSearchQueryBuilderOperatorPlugin.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
class OpenSearchQueryBuilderOperatorNotStartsWithPlugin extends OpenSearchQueryBuilderOperatorPlugin {
|
|
3
|
+
getOperator() {
|
|
4
|
+
return "not_startsWith";
|
|
5
|
+
}
|
|
6
|
+
apply(query, params) {
|
|
7
|
+
const { value, basePath } = params;
|
|
8
|
+
if ("" === value || null == value) return;
|
|
9
|
+
query.must_not.push({
|
|
10
|
+
match_phrase_prefix: {
|
|
11
|
+
[basePath]: value
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
constructor(...args){
|
|
16
|
+
super(...args), this.name = "opensearch.queryBuilder.operator.notStartsWith.default";
|
|
14
17
|
}
|
|
15
|
-
query.must_not.push({
|
|
16
|
-
match_phrase_prefix: {
|
|
17
|
-
[basePath]: value
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
18
|
}
|
|
19
|
+
export { OpenSearchQueryBuilderOperatorNotStartsWithPlugin };
|
|
22
20
|
|
|
23
21
|
//# sourceMappingURL=notStartsWith.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/operator/notStartsWith.js","sources":["../../../src/plugins/operator/notStartsWith.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotStartsWithPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.notStartsWith.default\";\n\n public getOperator(): string {\n return \"not_startsWith\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, basePath } = params;\n if (value === \"\" || value === null || value === undefined) {\n return;\n }\n query.must_not.push({\n match_phrase_prefix: {\n [basePath]: value\n }\n });\n }\n}\n"],"names":["OpenSearchQueryBuilderOperatorNotStartsWithPlugin","OpenSearchQueryBuilderOperatorPlugin","query","params","value","basePath"],"mappings":";AAGO,MAAMA,0DAA0DC;IAG5D,cAAsB;QACzB,OAAO;IACX;IAEO,MAAMC,KAAgC,EAAEC,MAAwC,EAAQ;QAC3F,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGF;QAC5B,IAAIC,AAAU,OAAVA,SAAkCA,QAAlBA,OAChB;QAEJF,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,qBAAqB;gBACjB,CAACG,SAAS,EAAED;YAChB;QACJ;IACJ;;QAjBG,qBACa,IAAI,GAAG;;AAiB3B"}
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { OpenSearchQueryBuilderOperatorPlugin } from "../definition/OpenSearchQueryBuilderOperatorPlugin.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
class OpenSearchQueryBuilderOperatorStartsWithPlugin extends OpenSearchQueryBuilderOperatorPlugin {
|
|
3
|
+
getOperator() {
|
|
4
|
+
return "startsWith";
|
|
5
|
+
}
|
|
6
|
+
apply(query, params) {
|
|
7
|
+
const { value, basePath } = params;
|
|
8
|
+
if ("" === value || null == value) return;
|
|
9
|
+
query.filter.push({
|
|
10
|
+
match_phrase_prefix: {
|
|
11
|
+
[basePath]: value
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
constructor(...args){
|
|
16
|
+
super(...args), this.name = "opensearch.queryBuilder.operator.startsWith.default";
|
|
14
17
|
}
|
|
15
|
-
query.filter.push({
|
|
16
|
-
match_phrase_prefix: {
|
|
17
|
-
[basePath]: value
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
18
|
}
|
|
19
|
+
export { OpenSearchQueryBuilderOperatorStartsWithPlugin };
|
|
22
20
|
|
|
23
21
|
//# sourceMappingURL=startsWith.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/operator/startsWith.js","sources":["../../../src/plugins/operator/startsWith.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorStartsWithPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.startsWith.default\";\n\n public getOperator(): string {\n return \"startsWith\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, basePath } = params;\n if (value === \"\" || value === null || value === undefined) {\n return;\n }\n query.filter.push({\n match_phrase_prefix: {\n [basePath]: value\n }\n });\n }\n}\n"],"names":["OpenSearchQueryBuilderOperatorStartsWithPlugin","OpenSearchQueryBuilderOperatorPlugin","query","params","value","basePath"],"mappings":";AAGO,MAAMA,uDAAuDC;IAGzD,cAAsB;QACzB,OAAO;IACX;IAEO,MAAMC,KAAgC,EAAEC,MAAwC,EAAQ;QAC3F,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGF;QAC5B,IAAIC,AAAU,OAAVA,SAAkCA,QAAlBA,OAChB;QAEJF,MAAM,MAAM,CAAC,IAAI,CAAC;YACd,qBAAqB;gBACjB,CAACG,SAAS,EAAED;YAChB;QACJ;IACJ;;QAjBG,qBACa,IAAI,GAAG;;AAiB3B"}
|
package/sharedIndex.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
};
|
|
1
|
+
const isSharedOpenSearchIndex = ()=>"true" === process.env.OPENSEARCH_SHARED_INDEXES;
|
|
2
|
+
export { isSharedOpenSearchIndex };
|
|
4
3
|
|
|
5
4
|
//# sourceMappingURL=sharedIndex.js.map
|
package/sharedIndex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"sharedIndex.js","sources":["../src/sharedIndex.ts"],"sourcesContent":["export const isSharedOpenSearchIndex = () => {\n return process.env.OPENSEARCH_SHARED_INDEXES === \"true\";\n};\n"],"names":["isSharedOpenSearchIndex","process"],"mappings":"AAAO,MAAMA,0BAA0B,IAC5BC,AAA0C,WAA1CA,QAAQ,GAAG,CAAC,yBAAyB"}
|
package/sort.js
CHANGED
|
@@ -1,65 +1,36 @@
|
|
|
1
|
-
import
|
|
1
|
+
import error from "@webiny/error";
|
|
2
2
|
import { OpenSearchFieldPlugin } from "./plugins/index.js";
|
|
3
3
|
const sortRegExp = /^((?:values\.)?[a-zA-Z0-9_@-]+)_(ASC|DESC)$/;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
sort
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
unmappedType
|
|
15
|
-
} = defaults || {};
|
|
16
|
-
/**
|
|
17
|
-
* We say that our system defaults is always id since all records we create have some kind of primary ID.
|
|
18
|
-
*/
|
|
19
|
-
return {
|
|
20
|
-
[field || "id.keyword"]: {
|
|
21
|
-
order: order || "desc",
|
|
22
|
-
// TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.
|
|
23
|
-
unmapped_type: unmappedType || undefined
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Cast as string because nothing else should be allowed yet.
|
|
29
|
-
*/
|
|
30
|
-
const result = sort.reduce((acc, value) => {
|
|
31
|
-
if (typeof value !== "string") {
|
|
32
|
-
throw new WebinyError(`Sort as object is not supported..`);
|
|
33
|
-
}
|
|
34
|
-
const match = value.match(sortRegExp);
|
|
35
|
-
if (!match) {
|
|
36
|
-
throw new WebinyError(`Cannot sort by "${value}".`);
|
|
37
|
-
}
|
|
38
|
-
const [, field, initialOrder] = match;
|
|
39
|
-
const order = initialOrder.toLowerCase() === "asc" ? "asc" : "desc";
|
|
40
|
-
const plugin = fieldPlugins[field] || fieldPlugins[OpenSearchFieldPlugin.ALL];
|
|
41
|
-
if (!plugin) {
|
|
42
|
-
throw new WebinyError(`Missing plugin for the field "${field}"`, "PLUGIN_SORT_ERROR", {
|
|
43
|
-
field
|
|
44
|
-
});
|
|
4
|
+
const createSort = (params)=>{
|
|
5
|
+
const { sort, defaults, fieldPlugins } = params;
|
|
6
|
+
if (!sort || 0 === sort.length) {
|
|
7
|
+
const { field, order, unmappedType } = defaults || {};
|
|
8
|
+
return {
|
|
9
|
+
[field || "id.keyword"]: {
|
|
10
|
+
order: order || "desc",
|
|
11
|
+
unmapped_type: unmappedType || void 0
|
|
12
|
+
}
|
|
13
|
+
};
|
|
45
14
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
15
|
+
const result = sort.reduce((acc, value)=>{
|
|
16
|
+
if ("string" != typeof value) throw new error("Sort as object is not supported..");
|
|
17
|
+
const match = value.match(sortRegExp);
|
|
18
|
+
if (!match) throw new error(`Cannot sort by "${value}".`);
|
|
19
|
+
const [, field, initialOrder] = match;
|
|
20
|
+
const order = "asc" === initialOrder.toLowerCase() ? "asc" : "desc";
|
|
21
|
+
const plugin = fieldPlugins[field] || fieldPlugins[OpenSearchFieldPlugin.ALL];
|
|
22
|
+
if (!plugin) throw new error(`Missing plugin for the field "${field}"`, "PLUGIN_SORT_ERROR", {
|
|
23
|
+
field
|
|
24
|
+
});
|
|
25
|
+
const path = plugin.getPath(field);
|
|
26
|
+
acc[path] = plugin.getSortOptions(order);
|
|
27
|
+
return acc;
|
|
28
|
+
}, {});
|
|
29
|
+
if (!result["id.keyword"] && !result["id"]) result["id.keyword"] = {
|
|
30
|
+
order: "asc"
|
|
60
31
|
};
|
|
61
|
-
|
|
62
|
-
return result;
|
|
32
|
+
return result;
|
|
63
33
|
};
|
|
34
|
+
export { createSort };
|
|
64
35
|
|
|
65
36
|
//# sourceMappingURL=sort.js.map
|
package/sort.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"sort.js","sources":["../src/sort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { FieldSortOptions, SortOrder, SortType } from \"~/types.js\";\nimport { OpenSearchFieldPlugin } from \"~/plugins/index.js\";\n\nconst sortRegExp = /^((?:values\\.)?[a-zA-Z0-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, OpenSearchFieldPlugin>;\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 // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.\n unmapped_type: (unmappedType || undefined) as any\n }\n };\n }\n /**\n * Cast as string because nothing else should be allowed yet.\n */\n const result = sort.reduce(\n (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: OpenSearchFieldPlugin =\n fieldPlugins[field] || fieldPlugins[OpenSearchFieldPlugin.ALL];\n if (!plugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\"`,\n \"PLUGIN_SORT_ERROR\",\n {\n field\n }\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 },\n {} as Record<string, FieldSortOptions>\n );\n /**\n * If we do not have id in the sort, we add it as we need a tie_breaker for the OpenSearch 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"],"names":["sortRegExp","createSort","params","sort","defaults","fieldPlugins","field","order","unmappedType","undefined","result","acc","value","WebinyError","match","initialOrder","plugin","OpenSearchFieldPlugin","path"],"mappings":";;AAIA,MAAMA,aAAa;AAYZ,MAAMC,aAAa,CAACC;IACvB,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAGH;IACzC,IAAI,CAACC,QAAQA,AAAgB,MAAhBA,KAAK,MAAM,EAAQ;QAC5B,MAAM,EAAEG,KAAK,EAAEC,KAAK,EAAEC,YAAY,EAAE,GAAGJ,YAAY,CAAC;QAIpD,OAAO;YACH,CAACE,SAAS,aAAa,EAAE;gBACrB,OAAOC,SAAS;gBAEhB,eAAgBC,gBAAgBC;YACpC;QACJ;IACJ;IAIA,MAAMC,SAASP,KAAK,MAAM,CACtB,CAACQ,KAAKC;QACF,IAAI,AAAiB,YAAjB,OAAOA,OACP,MAAM,IAAIC,MAAY;QAE1B,MAAMC,QAAQF,MAAM,KAAK,CAACZ;QAE1B,IAAI,CAACc,OACD,MAAM,IAAID,MAAY,CAAC,gBAAgB,EAAED,MAAM,EAAE,CAAC;QAGtD,MAAM,GAAGN,OAAOS,aAAa,GAAGD;QAChC,MAAMP,QAAmBQ,AAA+B,UAA/BA,aAAa,WAAW,KAAe,QAAQ;QAExE,MAAMC,SACFX,YAAY,CAACC,MAAM,IAAID,YAAY,CAACY,sBAAsB,GAAG,CAAC;QAClE,IAAI,CAACD,QACD,MAAM,IAAIH,MACN,CAAC,8BAA8B,EAAEP,MAAM,CAAC,CAAC,EACzC,qBACA;YACIA;QACJ;QAOR,MAAMY,OAAOF,OAAO,OAAO,CAACV;QAE5BK,GAAG,CAACO,KAAK,GAAGF,OAAO,cAAc,CAACT;QAElC,OAAOI;IACX,GACA,CAAC;IAKL,IAAI,CAACD,MAAM,CAAC,aAAa,IAAI,CAACA,MAAM,CAAC,KAAK,EACtCA,MAAM,CAAC,aAAa,GAAG;QACnB,OAAO;IACX;IAEJ,OAAOA;AACX"}
|
package/types.js
CHANGED
|
@@ -1,68 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// `moduleResolution: "bundler"`. We infer what we can from the public
|
|
6
|
-
// barrel (`api/index.js`) and use `string` where structural extraction
|
|
7
|
-
// is not possible.
|
|
8
|
-
// ---------------------------------------------------------------------------
|
|
9
|
-
|
|
10
|
-
// Distribute over the SortOptions union and extract only the Record<string, FieldSort> variant.
|
|
11
|
-
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
// Local type aliases replacing elastic-ts
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
|
|
16
|
-
/** Replaces elastic-ts PrimitiveValue. Aligns with opensearch FieldValue. */
|
|
17
|
-
|
|
18
|
-
/** Replaces elastic-ts Query */
|
|
19
|
-
|
|
20
|
-
/** Replaces elastic-ts BoolQueryConfig */
|
|
21
|
-
|
|
22
|
-
/** Replaces elastic-ts FieldSortOptions */
|
|
23
|
-
|
|
24
|
-
/** Replaces elastic-ts SortOrder. Narrowed to "asc" | "desc" (excludes "_doc"). */
|
|
25
|
-
|
|
26
|
-
/** Replaces elastic-ts Sort */
|
|
27
|
-
|
|
28
|
-
/** Single sort entry as an object map. Replaces elastic-ts SortType. */
|
|
29
|
-
|
|
30
|
-
/** Replaces elastic-ts SearchBody. Overrides search_after to allow PrimitiveValue[] (null | boolean | string | number). */
|
|
31
|
-
|
|
32
|
-
// ---------------------------------------------------------------------------
|
|
33
|
-
// Context
|
|
34
|
-
// ---------------------------------------------------------------------------
|
|
35
|
-
|
|
36
|
-
// ---------------------------------------------------------------------------
|
|
37
|
-
// Bool query with required arrays (our convention)
|
|
38
|
-
// ---------------------------------------------------------------------------
|
|
39
|
-
|
|
40
|
-
// ---------------------------------------------------------------------------
|
|
41
|
-
// Operator plugin types
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
// Search response shapes (aligned with @opensearch-project/opensearch v3)
|
|
46
|
-
// ---------------------------------------------------------------------------
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Extract the total count from an opensearch hits response.
|
|
50
|
-
* Handles both `TotalHits` (object with `value`) and plain `number` formats.
|
|
51
|
-
*/
|
|
52
|
-
export const getTotalCount = total => {
|
|
53
|
-
if (total === undefined || total === null) {
|
|
54
|
-
return 0;
|
|
55
|
-
}
|
|
56
|
-
if (typeof total === "number") {
|
|
57
|
-
return total;
|
|
58
|
-
}
|
|
59
|
-
return total.value;
|
|
1
|
+
const getTotalCount = (total)=>{
|
|
2
|
+
if (null == total) return 0;
|
|
3
|
+
if ("number" == typeof total) return total;
|
|
4
|
+
return total.value;
|
|
60
5
|
};
|
|
61
|
-
|
|
62
|
-
// ---------------------------------------------------------------------------
|
|
63
|
-
// Index request body shapes (re-exported from opensearch package)
|
|
64
|
-
// ---------------------------------------------------------------------------
|
|
65
|
-
|
|
66
|
-
// Re-export SearchSortOrder for consumers that need it (including "_doc")
|
|
6
|
+
export { getTotalCount };
|
|
67
7
|
|
|
68
8
|
//# sourceMappingURL=types.js.map
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { Client } from \"@opensearch-project/opensearch\";\nimport type {\n Search_RequestBody as SearchRequestBody,\n Search_Response,\n Indices_Create_RequestBody\n} from \"@opensearch-project/opensearch/api/index.js\";\nimport type { Context } from \"@webiny/api/types.js\";\n\n// ---------------------------------------------------------------------------\n// Types inferred from the accessible API surface.\n// The `_types/` directory in the opensearch package only ships `.d.ts` files\n// (no `.js` runtime modules), so deep imports are unresolvable under\n// `moduleResolution: \"bundler\"`. We infer what we can from the public\n// barrel (`api/index.js`) and use `string` where structural extraction\n// is not possible.\n// ---------------------------------------------------------------------------\n\ntype QueryDslQueryContainer = NonNullable<SearchRequestBody[\"query\"]>;\ntype QueryDslBoolQuery = NonNullable<QueryDslQueryContainer[\"bool\"]>;\ntype SearchSort = NonNullable<SearchRequestBody[\"sort\"]>;\ntype SearchSortOrder = \"asc\" | \"desc\";\n\n// Distribute over the SortOptions union and extract only the Record<string, FieldSort> variant.\ntype _ExtractRecordValue<T> = T extends Record<string, infer V> ? V : never;\ntype _SortMember =\n NonNullable<SearchRequestBody[\"sort\"]> extends (infer U)[] | (infer U) ? U : never;\ntype SearchFieldSort = _ExtractRecordValue<Exclude<_SortMember, string>>;\n\ntype DynamicTemplate = NonNullable<\n NonNullable<Indices_Create_RequestBody[\"mappings\"]>[\"dynamic_templates\"]\n>[number][string];\n\nexport type { ApiResponse } from \"@opensearch-project/opensearch\";\n\nexport type { Client };\n\n// ---------------------------------------------------------------------------\n// Local type aliases replacing elastic-ts\n// ---------------------------------------------------------------------------\n\n/** Replaces elastic-ts PrimitiveValue. Aligns with opensearch FieldValue. */\nexport type PrimitiveValue = boolean | undefined | number | string;\n\n/** Replaces elastic-ts Query */\nexport type { QueryDslQueryContainer };\n\n/** Replaces elastic-ts BoolQueryConfig */\nexport type { QueryDslBoolQuery };\n\n/** Replaces elastic-ts FieldSortOptions */\nexport type FieldSortOptions = SearchFieldSort;\n\n/** Replaces elastic-ts SortOrder. Narrowed to \"asc\" | \"desc\" (excludes \"_doc\"). */\nexport type SortOrder = \"asc\" | \"desc\";\n\n/** Replaces elastic-ts Sort */\nexport type { SearchSort as Sort };\n\n/** Single sort entry as an object map. Replaces elastic-ts SortType. */\nexport type SortType = Record<string, FieldSortOptions>;\n\n/** Replaces elastic-ts SearchBody. Overrides search_after to allow PrimitiveValue[] (null | boolean | string | number). */\nexport type SearchBody = Omit<SearchRequestBody, \"search_after\"> & {\n search_after?: PrimitiveValue[];\n};\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nexport interface OpenSearchContext extends Context {\n /**\n * @deprecated Use `context.opensearch` instead.\n */\n elasticsearch: Client;\n opensearch: Client;\n}\n\n// ---------------------------------------------------------------------------\n// Bool query with required arrays (our convention)\n// ---------------------------------------------------------------------------\n\nexport interface OpenSearchBoolQueryConfig extends QueryDslBoolQuery {\n must: QueryDslQueryContainer[];\n filter: QueryDslQueryContainer[];\n should: QueryDslQueryContainer[];\n must_not: QueryDslQueryContainer[];\n}\n\n// ---------------------------------------------------------------------------\n// Operator plugin types\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchQueryOperator =\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\nexport interface OpenSearchQueryBuilderArgsPlugin {\n name: string;\n path: string;\n basePath: string;\n value: any;\n keyword: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Search response shapes (aligned with @opensearch-project/opensearch v3)\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchSearchResponseHit = Search_Response[\"body\"][\"hits\"][\"hits\"][number];\n\nexport interface OpenSearchSearchResponseAggregationBucket {\n key: PrimitiveValue;\n doc_count: number;\n}\n\nexport type OpenSearchSearchResponseBodyHits = Search_Response[\"body\"][\"hits\"];\n\nexport type OpenSearchSearchResponseBody = Search_Response[\"body\"];\n\nexport type OpenSearchSearchResponse = Search_Response;\n\n/**\n * Extract the total count from an opensearch hits response.\n * Handles both `TotalHits` (object with `value`) and plain `number` formats.\n */\nexport const getTotalCount = (total: OpenSearchSearchResponseBodyHits[\"total\"]): number => {\n if (total === undefined || total === null) {\n return 0;\n }\n if (typeof total === \"number\") {\n return total;\n }\n return total.value;\n};\n\n// ---------------------------------------------------------------------------\n// Index request body shapes (re-exported from opensearch package)\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchIndexRequestBodyMappingsDynamicTemplate = Record<string, DynamicTemplate>;\n\nexport type OpenSearchIndexRequestBody = Indices_Create_RequestBody;\n\n// Re-export SearchSortOrder for consumers that need it (including \"_doc\")\nexport type { SearchSortOrder };\n"],"names":["getTotalCount","total"],"mappings":"AAyIO,MAAMA,gBAAgB,CAACC;IAC1B,IAAIA,QAAAA,OACA,OAAO;IAEX,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAOA;IAEX,OAAOA,MAAM,KAAK;AACtB"}
|