@webiny/api-opensearch 0.0.0-unstable.7be00a75a9
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/LICENSE +21 -0
- package/README.md +11 -0
- package/client.d.ts +8 -0
- package/client.js +60 -0
- package/client.js.map +1 -0
- package/cursors.d.ts +10 -0
- package/cursors.js +25 -0
- package/cursors.js.map +1 -0
- package/db/entity.d.ts +7 -0
- package/db/entity.js +18 -0
- package/db/entity.js.map +1 -0
- package/db/index.d.ts +3 -0
- package/db/index.js +3 -0
- package/db/table.d.ts +7 -0
- package/db/table.js +13 -0
- package/db/table.js.map +1 -0
- package/db/types.d.ts +6 -0
- package/db/types.js +0 -0
- package/exports/api/opensearch.d.ts +4 -0
- package/exports/api/opensearch.js +4 -0
- package/features/OpenSearchClient/OpenSearchClient.d.ts +12 -0
- package/features/OpenSearchClient/OpenSearchClient.js +19 -0
- package/features/OpenSearchClient/OpenSearchClient.js.map +1 -0
- package/features/OpenSearchClient/abstraction.d.ts +9 -0
- package/features/OpenSearchClient/abstraction.js +5 -0
- package/features/OpenSearchClient/abstraction.js.map +1 -0
- package/features/OpenSearchClient/feature.d.ts +4 -0
- package/features/OpenSearchClient/feature.js +11 -0
- package/features/OpenSearchClient/feature.js.map +1 -0
- package/features/OpenSearchClientFactory/OpenSearchClientFactory.d.ts +9 -0
- package/features/OpenSearchClientFactory/OpenSearchClientFactory.js +15 -0
- package/features/OpenSearchClientFactory/OpenSearchClientFactory.js.map +1 -0
- package/features/OpenSearchClientFactory/abstraction.d.ts +10 -0
- package/features/OpenSearchClientFactory/abstraction.js +5 -0
- package/features/OpenSearchClientFactory/abstraction.js.map +1 -0
- package/features/OpenSearchClientFactory/feature.d.ts +4 -0
- package/features/OpenSearchClientFactory/feature.js +11 -0
- package/features/OpenSearchClientFactory/feature.js.map +1 -0
- package/features/OpenSearchContext/OpenSearchContext.d.ts +8 -0
- package/features/OpenSearchContext/OpenSearchContext.js +14 -0
- package/features/OpenSearchContext/OpenSearchContext.js.map +1 -0
- package/features/OpenSearchContext/abstraction.d.ts +14 -0
- package/features/OpenSearchContext/abstraction.js +5 -0
- package/features/OpenSearchContext/abstraction.js.map +1 -0
- package/features/OpenSearchContext/feature.d.ts +5 -0
- package/features/OpenSearchContext/feature.js +12 -0
- package/features/OpenSearchContext/feature.js.map +1 -0
- package/index.d.ts +21 -0
- package/index.js +38 -0
- package/index.js.map +1 -0
- package/indexConfiguration/base.d.ts +6 -0
- package/indexConfiguration/base.js +34 -0
- package/indexConfiguration/base.js.map +1 -0
- package/indexConfiguration/common.d.ts +9 -0
- package/indexConfiguration/common.js +42 -0
- package/indexConfiguration/common.js.map +1 -0
- package/indexConfiguration/index.d.ts +2 -0
- package/indexConfiguration/index.js +2 -0
- package/indexPrefix.d.ts +1 -0
- package/indexPrefix.js +4 -0
- package/indexPrefix.js.map +1 -0
- package/indices.d.ts +8 -0
- package/indices.js +12 -0
- package/indices.js.map +1 -0
- package/limit.d.ts +1 -0
- package/limit.js +10 -0
- package/limit.js.map +1 -0
- package/normalize.d.ts +6 -0
- package/normalize.js +55 -0
- package/normalize.js.map +1 -0
- package/operations/OpenSearchCatHealth.d.ts +7 -0
- package/operations/OpenSearchCatHealth.js +30 -0
- package/operations/OpenSearchCatHealth.js.map +1 -0
- package/operations/OpenSearchCatNodes.d.ts +7 -0
- package/operations/OpenSearchCatNodes.js +28 -0
- package/operations/OpenSearchCatNodes.js.map +1 -0
- package/operations/index.d.ts +3 -0
- package/operations/index.js +3 -0
- package/operations/stripConnectionFromException.d.ts +1 -0
- package/operations/stripConnectionFromException.js +14 -0
- package/operations/stripConnectionFromException.js.map +1 -0
- package/operations/types.d.ts +12 -0
- package/operations/types.js +9 -0
- package/operations/types.js.map +1 -0
- package/operators.d.ts +6 -0
- package/operators.js +22 -0
- package/operators.js.map +1 -0
- package/package.json +41 -0
- package/plugins/definition/OpenSearchBodyModifierPlugin.d.ts +13 -0
- package/plugins/definition/OpenSearchBodyModifierPlugin.js +17 -0
- package/plugins/definition/OpenSearchBodyModifierPlugin.js.map +1 -0
- package/plugins/definition/OpenSearchFieldPlugin.d.ts +81 -0
- package/plugins/definition/OpenSearchFieldPlugin.js +52 -0
- package/plugins/definition/OpenSearchFieldPlugin.js.map +1 -0
- package/plugins/definition/OpenSearchIndexPlugin.d.ts +10 -0
- package/plugins/definition/OpenSearchIndexPlugin.js +16 -0
- package/plugins/definition/OpenSearchIndexPlugin.js.map +1 -0
- package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.d.ts +10 -0
- package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js +9 -0
- package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js.map +1 -0
- package/plugins/definition/OpenSearchQueryModifierPlugin.d.ts +14 -0
- package/plugins/definition/OpenSearchQueryModifierPlugin.js +17 -0
- package/plugins/definition/OpenSearchQueryModifierPlugin.js.map +1 -0
- package/plugins/definition/OpenSearchSortModifierPlugin.d.ts +13 -0
- package/plugins/definition/OpenSearchSortModifierPlugin.js +17 -0
- package/plugins/definition/OpenSearchSortModifierPlugin.js.map +1 -0
- package/plugins/definition/index.d.ts +6 -0
- package/plugins/definition/index.js +6 -0
- package/plugins/index.d.ts +2 -0
- package/plugins/index.js +2 -0
- package/plugins/operator/andIn.d.ts +7 -0
- package/plugins/operator/andIn.js +27 -0
- package/plugins/operator/andIn.js.map +1 -0
- package/plugins/operator/between.d.ts +7 -0
- package/plugins/operator/between.js +26 -0
- package/plugins/operator/between.js.map +1 -0
- package/plugins/operator/contains.d.ts +7 -0
- package/plugins/operator/contains.js +26 -0
- package/plugins/operator/contains.js.map +1 -0
- package/plugins/operator/equal.d.ts +7 -0
- package/plugins/operator/equal.js +33 -0
- package/plugins/operator/equal.js.map +1 -0
- package/plugins/operator/gt.d.ts +7 -0
- package/plugins/operator/gt.js +22 -0
- package/plugins/operator/gt.js.map +1 -0
- package/plugins/operator/gte.d.ts +7 -0
- package/plugins/operator/gte.js +22 -0
- package/plugins/operator/gte.js.map +1 -0
- package/plugins/operator/in.d.ts +7 -0
- package/plugins/operator/in.js +23 -0
- package/plugins/operator/in.js.map +1 -0
- package/plugins/operator/index.d.ts +15 -0
- package/plugins/operator/index.js +15 -0
- package/plugins/operator/lt.d.ts +7 -0
- package/plugins/operator/lt.js +22 -0
- package/plugins/operator/lt.js.map +1 -0
- package/plugins/operator/lte.d.ts +7 -0
- package/plugins/operator/lte.js +22 -0
- package/plugins/operator/lte.js.map +1 -0
- package/plugins/operator/not.d.ts +7 -0
- package/plugins/operator/not.js +37 -0
- package/plugins/operator/not.js.map +1 -0
- package/plugins/operator/notBetween.d.ts +7 -0
- package/plugins/operator/notBetween.js +26 -0
- package/plugins/operator/notBetween.js.map +1 -0
- package/plugins/operator/notContains.d.ts +7 -0
- package/plugins/operator/notContains.js +26 -0
- package/plugins/operator/notContains.js.map +1 -0
- package/plugins/operator/notIn.d.ts +7 -0
- package/plugins/operator/notIn.js +23 -0
- package/plugins/operator/notIn.js.map +1 -0
- package/plugins/operator/notStartsWith.d.ts +7 -0
- package/plugins/operator/notStartsWith.js +21 -0
- package/plugins/operator/notStartsWith.js.map +1 -0
- package/plugins/operator/startsWith.d.ts +7 -0
- package/plugins/operator/startsWith.js +21 -0
- package/plugins/operator/startsWith.js.map +1 -0
- package/sharedIndex.d.ts +1 -0
- package/sharedIndex.js +4 -0
- package/sharedIndex.js.map +1 -0
- package/sort.d.ts +13 -0
- package/sort.js +36 -0
- package/sort.js.map +1 -0
- package/types.d.ts +68 -0
- package/types.js +8 -0
- package/types.js.map +1 -0
- package/utils/createIndex.d.ts +19 -0
- package/utils/createIndex.js +66 -0
- package/utils/createIndex.js.map +1 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +2 -0
- package/utils/waitUntilHealthy/UnhealthyClusterError.d.ts +4 -0
- package/utils/waitUntilHealthy/UnhealthyClusterError.js +12 -0
- package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -0
- package/utils/waitUntilHealthy/WaitUntilHealthy.d.ts +72 -0
- package/utils/waitUntilHealthy/WaitUntilHealthy.js +131 -0
- package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -0
- package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.d.ts +4 -0
- package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +12 -0
- package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -0
- package/utils/waitUntilHealthy/index.d.ts +4 -0
- package/utils/waitUntilHealthy/index.js +4 -0
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.d.ts +15 -0
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +12 -0
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -0
- package/utils/waitUntilHealthy/reason/IReason.d.ts +4 -0
- package/utils/waitUntilHealthy/reason/IReason.js +0 -0
- package/utils/waitUntilHealthy/reason/MemoryReason.d.ts +14 -0
- package/utils/waitUntilHealthy/reason/MemoryReason.js +12 -0
- package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -0
- package/utils/waitUntilHealthy/reason/ProcessorReason.d.ts +14 -0
- package/utils/waitUntilHealthy/reason/ProcessorReason.js +12 -0
- package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -0
- package/utils/waitUntilHealthy/reason/index.d.ts +3 -0
- package/utils/waitUntilHealthy/reason/index.js +3 -0
- package/where.d.ts +17 -0
- package/where.js +49 -0
- package/where.js.map +1 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getCommonMappings } from "./common.js";
|
|
2
|
+
const config = {
|
|
3
|
+
mappings: {
|
|
4
|
+
dynamic_templates: getCommonMappings((mappings)=>mappings.concat([
|
|
5
|
+
{
|
|
6
|
+
strings: {
|
|
7
|
+
match_mapping_type: "string",
|
|
8
|
+
mapping: {
|
|
9
|
+
type: "text",
|
|
10
|
+
fields: {
|
|
11
|
+
keyword: {
|
|
12
|
+
type: "keyword",
|
|
13
|
+
ignore_above: 256
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
])),
|
|
20
|
+
properties: {
|
|
21
|
+
rawValues: {
|
|
22
|
+
type: "object",
|
|
23
|
+
enabled: false
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const getBaseConfiguration = (modifier)=>{
|
|
29
|
+
if (!modifier) return config;
|
|
30
|
+
return modifier(config);
|
|
31
|
+
};
|
|
32
|
+
export { getBaseConfiguration };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexConfiguration/base.js","sources":["../../src/indexConfiguration/base.ts"],"sourcesContent":["import type { OpenSearchIndexRequestBody } from \"~/types.js\";\nimport { getCommonMappings } from \"./common.js\";\n\nconst config: OpenSearchIndexRequestBody = {\n mappings: {\n dynamic_templates: getCommonMappings(mappings => {\n return mappings.concat([\n {\n strings: {\n match_mapping_type: \"string\",\n mapping: {\n type: \"text\",\n fields: {\n keyword: {\n type: \"keyword\",\n ignore_above: 256\n }\n }\n }\n }\n }\n ]);\n }),\n properties: {\n rawValues: {\n type: \"object\",\n enabled: false\n }\n }\n }\n};\n\ninterface Modifier {\n (config: OpenSearchIndexRequestBody): OpenSearchIndexRequestBody;\n}\nexport const getBaseConfiguration = (modifier?: Modifier) => {\n if (!modifier) {\n return config;\n }\n return modifier(config);\n};\n"],"names":["config","getCommonMappings","mappings","getBaseConfiguration","modifier"],"mappings":";AAGA,MAAMA,SAAqC;IACvC,UAAU;QACN,mBAAmBC,kBAAkBC,CAAAA,WAC1BA,SAAS,MAAM,CAAC;gBACnB;oBACI,SAAS;wBACL,oBAAoB;wBACpB,SAAS;4BACL,MAAM;4BACN,QAAQ;gCACJ,SAAS;oCACL,MAAM;oCACN,cAAc;gCAClB;4BACJ;wBACJ;oBACJ;gBACJ;aACH;QAEL,YAAY;YACR,WAAW;gBACP,MAAM;gBACN,SAAS;YACb;QACJ;IACJ;AACJ;AAKO,MAAMC,uBAAuB,CAACC;IACjC,IAAI,CAACA,UACD,OAAOJ;IAEX,OAAOI,SAASJ;AACpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { OpenSearchIndexRequestBodyMappingsDynamicTemplate } from "../types.js";
|
|
2
|
+
interface Modifier {
|
|
3
|
+
(mappings: OpenSearchIndexRequestBodyMappingsDynamicTemplate[]): OpenSearchIndexRequestBodyMappingsDynamicTemplate[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const getCommonMappings: (cb?: Modifier) => OpenSearchIndexRequestBodyMappingsDynamicTemplate[];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const getDefaultMappings = ()=>[
|
|
2
|
+
{
|
|
3
|
+
ids: {
|
|
4
|
+
match: "^id|entryId$",
|
|
5
|
+
mapping: {
|
|
6
|
+
type: "keyword"
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
dates: {
|
|
12
|
+
match: "^createdOn|savedOn|publishedOn$",
|
|
13
|
+
mapping: {
|
|
14
|
+
type: "date"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
numbers: {
|
|
20
|
+
match: "number@*",
|
|
21
|
+
mapping: {
|
|
22
|
+
type: "scaled_float",
|
|
23
|
+
scaling_factor: 10000
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
booleans: {
|
|
29
|
+
match: "boolean@*",
|
|
30
|
+
mapping: {
|
|
31
|
+
type: "boolean"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
const getCommonMappings = (cb)=>{
|
|
37
|
+
if (!cb) return getDefaultMappings();
|
|
38
|
+
return cb(getDefaultMappings());
|
|
39
|
+
};
|
|
40
|
+
export { getCommonMappings };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexConfiguration/common.js","sources":["../../src/indexConfiguration/common.ts"],"sourcesContent":["import type { OpenSearchIndexRequestBodyMappingsDynamicTemplate } from \"~/types.js\";\n\nconst getDefaultMappings = (): OpenSearchIndexRequestBodyMappingsDynamicTemplate[] => {\n return [\n {\n ids: {\n match: \"^id|entryId$\",\n mapping: {\n type: \"keyword\"\n }\n }\n },\n {\n /* Update with the correct date fields. */\n dates: {\n match: \"^createdOn|savedOn|publishedOn$\",\n mapping: {\n type: \"date\"\n }\n }\n },\n {\n numbers: {\n match: \"number@*\",\n mapping: {\n type: \"scaled_float\",\n scaling_factor: 10000\n }\n }\n },\n {\n booleans: {\n match: \"boolean@*\",\n mapping: {\n type: \"boolean\"\n }\n }\n }\n ];\n};\n\ninterface Modifier {\n (\n mappings: OpenSearchIndexRequestBodyMappingsDynamicTemplate[]\n ): OpenSearchIndexRequestBodyMappingsDynamicTemplate[];\n}\n/**\n * @internal\n */\nexport const getCommonMappings = (\n cb?: Modifier\n): OpenSearchIndexRequestBodyMappingsDynamicTemplate[] => {\n if (!cb) {\n return getDefaultMappings();\n }\n\n return cb(getDefaultMappings());\n};\n"],"names":["getDefaultMappings","getCommonMappings","cb"],"mappings":"AAEA,MAAMA,qBAAqB,IAChB;QACH;YACI,KAAK;gBACD,OAAO;gBACP,SAAS;oBACL,MAAM;gBACV;YACJ;QACJ;QACA;YAEI,OAAO;gBACH,OAAO;gBACP,SAAS;oBACL,MAAM;gBACV;YACJ;QACJ;QACA;YACI,SAAS;gBACL,OAAO;gBACP,SAAS;oBACL,MAAM;oBACN,gBAAgB;gBACpB;YACJ;QACJ;QACA;YACI,UAAU;gBACN,OAAO;gBACP,SAAS;oBACL,MAAM;gBACV;YACJ;QACJ;KACH;AAWE,MAAMC,oBAAoB,CAC7BC;IAEA,IAAI,CAACA,IACD,OAAOF;IAGX,OAAOE,GAAGF;AACd"}
|
package/indexPrefix.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getOpenSearchIndexPrefix: () => string;
|
package/indexPrefix.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const getOpenSearchIndexPrefix = ()=>process.env.OPENSEARCH_INDEX_PREFIX || process.env.ELASTICSEARCH_INDEX_PREFIX || process.env.WEBINY_OPENSEARCH_INDEX_PREFIX || process.env.WEBINY_ELASTICSEARCH_INDEX_PREFIX || "";
|
|
2
|
+
export { getOpenSearchIndexPrefix };
|
|
3
|
+
|
|
4
|
+
//# sourceMappingURL=indexPrefix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexPrefix.js","sources":["../src/indexPrefix.ts"],"sourcesContent":["export const getOpenSearchIndexPrefix = (): string => {\n return (\n process.env.OPENSEARCH_INDEX_PREFIX ||\n process.env.ELASTICSEARCH_INDEX_PREFIX ||\n process.env.WEBINY_OPENSEARCH_INDEX_PREFIX ||\n process.env.WEBINY_ELASTICSEARCH_INDEX_PREFIX ||\n \"\"\n );\n};\n"],"names":["getOpenSearchIndexPrefix","process"],"mappings":"AAAO,MAAMA,2BAA2B,IAEhCC,QAAQ,GAAG,CAAC,uBAAuB,IACnCA,QAAQ,GAAG,CAAC,0BAA0B,IACtCA,QAAQ,GAAG,CAAC,8BAA8B,IAC1CA,QAAQ,GAAG,CAAC,iCAAiC,IAC7C"}
|
package/indices.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OpenSearchIndexPlugin } from "./plugins/definition/OpenSearchIndexPlugin.js";
|
|
2
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
interface IndicesPluginsParams {
|
|
4
|
+
container: PluginsContainer;
|
|
5
|
+
type: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const getLastAddedIndexPlugin: <T extends OpenSearchIndexPlugin>(params: IndicesPluginsParams) => T;
|
|
8
|
+
export {};
|
package/indices.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
const listIndicesPlugins = ({ container, type })=>container.byType(type).filter((plugin)=>plugin.canUse());
|
|
3
|
+
const getLastAddedIndexPlugin = (params)=>{
|
|
4
|
+
const plugins = listIndicesPlugins(params);
|
|
5
|
+
if (0 === plugins.length) throw new error(`Could not find a single OpenSearchIndexPlugin of type "${params.type}".`, "OPENSEARCH_INDEX_TEMPLATE_ERROR", {
|
|
6
|
+
type: params.type
|
|
7
|
+
});
|
|
8
|
+
return plugins.pop();
|
|
9
|
+
};
|
|
10
|
+
export { getLastAddedIndexPlugin };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=indices.js.map
|
package/indices.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indices.js","sources":["../src/indices.ts"],"sourcesContent":["import type { OpenSearchIndexPlugin } from \"~/plugins/definition/OpenSearchIndexPlugin.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\n\ninterface IndicesPluginsParams {\n container: PluginsContainer;\n type: string;\n}\nconst listIndicesPlugins = <T extends OpenSearchIndexPlugin>({\n container,\n type\n}: IndicesPluginsParams): T[] => {\n return container.byType<T>(type).filter(plugin => {\n return plugin.canUse();\n });\n};\n\nexport const getLastAddedIndexPlugin = <T extends OpenSearchIndexPlugin>(\n params: IndicesPluginsParams\n): T => {\n const plugins = listIndicesPlugins<T>(params);\n if (plugins.length === 0) {\n throw new WebinyError(\n `Could not find a single OpenSearchIndexPlugin of type \"${params.type}\".`,\n \"OPENSEARCH_INDEX_TEMPLATE_ERROR\",\n {\n type: params.type\n }\n );\n }\n\n return plugins.pop() as T;\n};\n"],"names":["listIndicesPlugins","container","type","plugin","getLastAddedIndexPlugin","params","plugins","WebinyError"],"mappings":";AAQA,MAAMA,qBAAqB,CAAkC,EACzDC,SAAS,EACTC,IAAI,EACe,GACZD,UAAU,MAAM,CAAIC,MAAM,MAAM,CAACC,CAAAA,SAC7BA,OAAO,MAAM;AAIrB,MAAMC,0BAA0B,CACnCC;IAEA,MAAMC,UAAUN,mBAAsBK;IACtC,IAAIC,AAAmB,MAAnBA,QAAQ,MAAM,EACd,MAAM,IAAIC,MACN,CAAC,uDAAuD,EAAEF,OAAO,IAAI,CAAC,EAAE,CAAC,EACzE,mCACA;QACI,MAAMA,OAAO,IAAI;IACrB;IAIR,OAAOC,QAAQ,GAAG;AACtB"}
|
package/limit.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createLimit: (limit?: number, defaultValue?: number) => number;
|
package/limit.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const ES_LIMIT_MAX = 10000;
|
|
2
|
+
const ES_LIMIT_DEFAULT = 50;
|
|
3
|
+
const createLimit = (limit, defaultValue = ES_LIMIT_DEFAULT)=>{
|
|
4
|
+
if (!limit || limit < 1) return defaultValue;
|
|
5
|
+
if (limit < ES_LIMIT_MAX) return limit;
|
|
6
|
+
return ES_LIMIT_MAX - 1;
|
|
7
|
+
};
|
|
8
|
+
export { createLimit };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=limit.js.map
|
package/limit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limit.js","sources":["../src/limit.ts"],"sourcesContent":["/**\n * This is the max limit of the OpenSearch.\n * Change here if it changes (and if it is necessary).\n */\nconst ES_LIMIT_MAX = 10000;\n/**\n * Our system default limit.\n */\nconst ES_LIMIT_DEFAULT = 50;\n\nexport const createLimit = (limit?: number, defaultValue = ES_LIMIT_DEFAULT): number => {\n /**\n * Limit can possibly be null/undefined or less than 1.\n * In that case return the defaults.\n */\n if (!limit || limit < 1) {\n return defaultValue;\n }\n /**\n * Users input limit cannot be greater than the OpenSearch one.\n * OpenSearch query breaks because of that.\n */\n if (limit < ES_LIMIT_MAX) {\n return limit;\n }\n /**\n * Always reduce by 1 because we check if there are more items by adding 1 to the limit\n * and then remove that last one loaded.\n */\n return ES_LIMIT_MAX - 1;\n};\n"],"names":["ES_LIMIT_MAX","ES_LIMIT_DEFAULT","createLimit","limit","defaultValue"],"mappings":"AAIA,MAAMA,eAAe;AAIrB,MAAMC,mBAAmB;AAElB,MAAMC,cAAc,CAACC,OAAgBC,eAAeH,gBAAgB;IAKvE,IAAI,CAACE,SAASA,QAAQ,GAClB,OAAOC;IAMX,IAAID,QAAQH,cACR,OAAOG;IAMX,OAAOH,eAAe;AAC1B"}
|
package/normalize.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Before performing the query, we need to escape all special characters.
|
|
3
|
+
* @see https://opensearch.org/docs/latest/query-dsl/full-text/query-string/
|
|
4
|
+
*/
|
|
5
|
+
export declare const normalizeValue: (value: string) => string;
|
|
6
|
+
export declare const normalizeValueWithAsterisk: (initial: string) => string;
|
package/normalize.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const specialCharactersToRemove = [
|
|
2
|
+
"\\?"
|
|
3
|
+
];
|
|
4
|
+
const specialCharacterToSpace = [
|
|
5
|
+
"-",
|
|
6
|
+
"\\\\"
|
|
7
|
+
];
|
|
8
|
+
const specialCharacters = [
|
|
9
|
+
"\\\\",
|
|
10
|
+
"\\+",
|
|
11
|
+
"\\=",
|
|
12
|
+
"&",
|
|
13
|
+
"\\|",
|
|
14
|
+
">",
|
|
15
|
+
"<",
|
|
16
|
+
"!",
|
|
17
|
+
"\\(",
|
|
18
|
+
"\\)",
|
|
19
|
+
"\\{",
|
|
20
|
+
"\\}",
|
|
21
|
+
"\\[",
|
|
22
|
+
"\\]",
|
|
23
|
+
"\\^",
|
|
24
|
+
'\\"',
|
|
25
|
+
"\\~",
|
|
26
|
+
"\\*",
|
|
27
|
+
":",
|
|
28
|
+
"/",
|
|
29
|
+
"\\#"
|
|
30
|
+
];
|
|
31
|
+
const normalizeValue = (value)=>{
|
|
32
|
+
let result = value || "";
|
|
33
|
+
if (!result) return result;
|
|
34
|
+
for (const character of specialCharactersToRemove)result = result.replace(new RegExp(character, "g"), "");
|
|
35
|
+
for (const character of specialCharacterToSpace)result = result.replace(new RegExp(character, "g"), " ");
|
|
36
|
+
for (const character of specialCharacters)result = result.replace(new RegExp(character, "g"), `\\${character}`);
|
|
37
|
+
return result || "";
|
|
38
|
+
};
|
|
39
|
+
const hasSpecialChar = (value)=>{
|
|
40
|
+
if (!value) return null;
|
|
41
|
+
return null === value.match(/^([0-9a-zA-Z]+)$/i);
|
|
42
|
+
};
|
|
43
|
+
const normalizeValueWithAsterisk = (initial)=>{
|
|
44
|
+
const value = normalizeValue(initial);
|
|
45
|
+
const results = value.split(" ");
|
|
46
|
+
let result = value;
|
|
47
|
+
const firstWord = results[0];
|
|
48
|
+
if (false === hasSpecialChar(firstWord)) result = `*${result}`;
|
|
49
|
+
const lastWord = results[results.length - 1];
|
|
50
|
+
if (false === hasSpecialChar(lastWord)) result = `${result}*`;
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
export { normalizeValue, normalizeValueWithAsterisk };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=normalize.js.map
|
package/normalize.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sources":["../src/normalize.ts"],"sourcesContent":["/**\n * Before performing the query, we need to escape all special characters.\n * @see https://opensearch.org/docs/latest/query-dsl/full-text/query-string/\n */\n\nconst specialCharactersToRemove = [`\\\\?`];\n\nconst specialCharacterToSpace = [\"-\", \"\\\\\\\\\"];\n\nconst specialCharacters = [\n \"\\\\\\\\\",\n \"\\\\+\",\n // \"\\\\-\",\n \"\\\\=\",\n `&`,\n `\\\\|`,\n \">\",\n \"<\",\n `!`,\n \"\\\\(\",\n \"\\\\)\",\n \"\\\\{\",\n \"\\\\}\",\n \"\\\\[\",\n \"\\\\]\",\n \"\\\\^\",\n '\\\\\"',\n \"\\\\~\",\n \"\\\\*\",\n `:`,\n `/`,\n \"\\\\#\"\n];\n\nexport const normalizeValue = (value: string) => {\n let result = value || \"\";\n if (!result) {\n return result;\n }\n for (const character of specialCharactersToRemove) {\n result = result.replace(new RegExp(character, \"g\"), \"\");\n }\n for (const character of specialCharacterToSpace) {\n result = result.replace(new RegExp(character, \"g\"), \" \");\n }\n\n for (const character of specialCharacters) {\n result = result.replace(new RegExp(character, \"g\"), `\\\\${character}`);\n }\n\n return result || \"\";\n};\n\nconst hasSpecialChar = (value: string): boolean | null => {\n if (!value) {\n return null;\n }\n return value.match(/^([0-9a-zA-Z]+)$/i) === null;\n};\n\nexport const normalizeValueWithAsterisk = (initial: string) => {\n const value = normalizeValue(initial);\n const results = value.split(\" \");\n\n let result = value;\n /**\n * If there is a / in the first word, do not put asterisk in front of it.\n */\n const firstWord = results[0];\n if (hasSpecialChar(firstWord) === false) {\n result = `*${result}`;\n }\n /**\n * If there is a / in the last word, do not put asterisk at the end of it.\n */\n const lastWord = results[results.length - 1];\n if (hasSpecialChar(lastWord) === false) {\n result = `${result}*`;\n }\n\n return result;\n};\n"],"names":["specialCharactersToRemove","specialCharacterToSpace","specialCharacters","normalizeValue","value","result","character","RegExp","hasSpecialChar","normalizeValueWithAsterisk","initial","results","firstWord","lastWord"],"mappings":"AAKA,MAAMA,4BAA4B;IAAC;CAAM;AAEzC,MAAMC,0BAA0B;IAAC;IAAK;CAAO;AAE7C,MAAMC,oBAAoB;IACtB;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAEM,MAAMC,iBAAiB,CAACC;IAC3B,IAAIC,SAASD,SAAS;IACtB,IAAI,CAACC,QACD,OAAOA;IAEX,KAAK,MAAMC,aAAaN,0BACpBK,SAASA,OAAO,OAAO,CAAC,IAAIE,OAAOD,WAAW,MAAM;IAExD,KAAK,MAAMA,aAAaL,wBACpBI,SAASA,OAAO,OAAO,CAAC,IAAIE,OAAOD,WAAW,MAAM;IAGxD,KAAK,MAAMA,aAAaJ,kBACpBG,SAASA,OAAO,OAAO,CAAC,IAAIE,OAAOD,WAAW,MAAM,CAAC,EAAE,EAAEA,WAAW;IAGxE,OAAOD,UAAU;AACrB;AAEA,MAAMG,iBAAiB,CAACJ;IACpB,IAAI,CAACA,OACD,OAAO;IAEX,OAAOA,AAAqC,SAArCA,MAAM,KAAK,CAAC;AACvB;AAEO,MAAMK,6BAA6B,CAACC;IACvC,MAAMN,QAAQD,eAAeO;IAC7B,MAAMC,UAAUP,MAAM,KAAK,CAAC;IAE5B,IAAIC,SAASD;IAIb,MAAMQ,YAAYD,OAAO,CAAC,EAAE;IAC5B,IAAIH,AAA8B,UAA9BA,eAAeI,YACfP,SAAS,CAAC,CAAC,EAAEA,QAAQ;IAKzB,MAAMQ,WAAWF,OAAO,CAACA,QAAQ,MAAM,GAAG,EAAE;IAC5C,IAAIH,AAA6B,UAA7BA,eAAeK,WACfR,SAAS,GAAGA,OAAO,CAAC,CAAC;IAGzB,OAAOA;AACX"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Client } from "../client.js";
|
|
2
|
+
import type { IOpenSearchCatHealthResponse } from "./types.js";
|
|
3
|
+
export declare class OpenSearchCatHealth {
|
|
4
|
+
private readonly client;
|
|
5
|
+
constructor(client: Client);
|
|
6
|
+
getHealth(): Promise<IOpenSearchCatHealthResponse>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
import { stripConnectionFromException } from "./stripConnectionFromException.js";
|
|
3
|
+
class OpenSearchCatHealth {
|
|
4
|
+
constructor(client){
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
async getHealth() {
|
|
8
|
+
try {
|
|
9
|
+
const response = await this.client.cat.health({
|
|
10
|
+
format: "json"
|
|
11
|
+
});
|
|
12
|
+
if (!Array.isArray(response.body) || 0 === response.body.length) throw new WebinyError({
|
|
13
|
+
message: "There is no valid response from cat.health operation.",
|
|
14
|
+
code: "OPENSEARCH_HEALTH_INVALID_RESPONSE",
|
|
15
|
+
data: response.body
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
...response.body[0]
|
|
19
|
+
};
|
|
20
|
+
} catch (ex) {
|
|
21
|
+
console.error(`Could not fetch cluster health information: ${ex.message}`);
|
|
22
|
+
const error = stripConnectionFromException(ex);
|
|
23
|
+
console.log(JSON.stringify(error));
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export { OpenSearchCatHealth };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=OpenSearchCatHealth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/OpenSearchCatHealth.js","sources":["../../src/operations/OpenSearchCatHealth.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { Client } from \"~/client.js\";\nimport type { IOpenSearchCatHealthResponse } from \"./types.js\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException.js\";\n\nexport class OpenSearchCatHealth {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getHealth(): Promise<IOpenSearchCatHealthResponse> {\n try {\n const response = await this.client.cat.health({\n format: \"json\"\n });\n\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.health operation.`,\n code: \"OPENSEARCH_HEALTH_INVALID_RESPONSE\",\n data: response.body\n });\n }\n\n return {\n ...response.body[0]\n };\n } catch (ex) {\n console.error(`Could not fetch cluster health information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"names":["OpenSearchCatHealth","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,YAAmD;QAC5D,IAAI;YACA,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;gBAC1C,QAAQ;YACZ;YAEA,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;YAGJ,OAAO;gBACH,GAAGA,SAAS,IAAI,CAAC,EAAE;YACvB;QACJ,EAAE,OAAOG,IAAI;YACTC,QAAQ,KAAK,CAAC,CAAC,4CAA4C,EAAED,GAAG,OAAO,EAAE;YACzE,MAAME,QAAQC,6BAA6BH;YAC3CC,QAAQ,GAAG,CAACG,KAAK,SAAS,CAACF;YAC3B,MAAMA;QACV;IACJ;AACJ"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
import { stripConnectionFromException } from "./stripConnectionFromException.js";
|
|
3
|
+
class OpenSearchCatNodes {
|
|
4
|
+
constructor(client){
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
async getNodes() {
|
|
8
|
+
try {
|
|
9
|
+
const response = await this.client.cat.nodes({
|
|
10
|
+
format: "json"
|
|
11
|
+
});
|
|
12
|
+
if (!Array.isArray(response.body) || 0 === response.body.length) throw new WebinyError({
|
|
13
|
+
message: "There is no valid response from cat.nodes operation.",
|
|
14
|
+
code: "OPENSEARCH_NODES_INVALID_RESPONSE",
|
|
15
|
+
data: response.body
|
|
16
|
+
});
|
|
17
|
+
return response.body;
|
|
18
|
+
} catch (ex) {
|
|
19
|
+
console.error(`Could not fetch cluster nodes information: ${ex.message}`);
|
|
20
|
+
const error = stripConnectionFromException(ex);
|
|
21
|
+
console.log(JSON.stringify(error));
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export { OpenSearchCatNodes };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=OpenSearchCatNodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const stripConnectionFromException: (ex: any) => any;
|
|
@@ -0,0 +1,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
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export { stripConnectionFromException };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=stripConnectionFromException.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Cat_Health_ResponseBody, Cat_Nodes_ResponseBody } from "@opensearch-project/opensearch/api/index.js";
|
|
2
|
+
export declare enum OpenSearchCatClusterHealthStatus {
|
|
3
|
+
Green = "green",
|
|
4
|
+
Yellow = "yellow",
|
|
5
|
+
Red = "red"
|
|
6
|
+
}
|
|
7
|
+
type HealthRecord = Cat_Health_ResponseBody[number];
|
|
8
|
+
type NodesRecord = Cat_Nodes_ResponseBody[number];
|
|
9
|
+
export type IOpenSearchCatHealthResponse = HealthRecord;
|
|
10
|
+
export type IOpenSearchCatNodeResponse = NodesRecord;
|
|
11
|
+
export type IOpenSearchCatNodesResponse = IOpenSearchCatNodeResponse[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var types_OpenSearchCatClusterHealthStatus = /*#__PURE__*/ function(OpenSearchCatClusterHealthStatus) {
|
|
2
|
+
OpenSearchCatClusterHealthStatus["Green"] = "green";
|
|
3
|
+
OpenSearchCatClusterHealthStatus["Yellow"] = "yellow";
|
|
4
|
+
OpenSearchCatClusterHealthStatus["Red"] = "red";
|
|
5
|
+
return OpenSearchCatClusterHealthStatus;
|
|
6
|
+
}({});
|
|
7
|
+
export { types_OpenSearchCatClusterHealthStatus as OpenSearchCatClusterHealthStatus };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OpenSearchQueryBuilderOperatorBetweenPlugin, OpenSearchQueryBuilderOperatorAndInPlugin, OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin, OpenSearchQueryBuilderOperatorGreaterThanPlugin, OpenSearchQueryBuilderOperatorContainsPlugin, OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin, OpenSearchQueryBuilderOperatorInPlugin, OpenSearchQueryBuilderOperatorLesserThanPlugin, OpenSearchQueryBuilderOperatorNotBetweenPlugin, OpenSearchQueryBuilderOperatorNotContainsPlugin, OpenSearchQueryBuilderOperatorNotPlugin, OpenSearchQueryBuilderOperatorNotInPlugin, OpenSearchQueryBuilderOperatorEqualPlugin, OpenSearchQueryBuilderOperatorStartsWithPlugin, OpenSearchQueryBuilderOperatorNotStartsWithPlugin } from "./plugins/operator/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* We export as a function because there might be something to be sent to the operators at some point.
|
|
4
|
+
* This way, we make it easier to upgrade.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getOpenSearchOperators: () => (OpenSearchQueryBuilderOperatorBetweenPlugin | OpenSearchQueryBuilderOperatorContainsPlugin | OpenSearchQueryBuilderOperatorEqualPlugin | OpenSearchQueryBuilderOperatorGreaterThanPlugin | OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin | OpenSearchQueryBuilderOperatorAndInPlugin | OpenSearchQueryBuilderOperatorInPlugin | OpenSearchQueryBuilderOperatorLesserThanPlugin | OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin | OpenSearchQueryBuilderOperatorNotPlugin | OpenSearchQueryBuilderOperatorNotBetweenPlugin | OpenSearchQueryBuilderOperatorNotContainsPlugin | OpenSearchQueryBuilderOperatorNotInPlugin | OpenSearchQueryBuilderOperatorStartsWithPlugin | OpenSearchQueryBuilderOperatorNotStartsWithPlugin)[];
|
package/operators.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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 };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=operators.js.map
|
package/operators.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/api-opensearch",
|
|
3
|
+
"version": "0.0.0-unstable.7be00a75a9",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/webiny/webiny-js.git",
|
|
12
|
+
"directory": "packages/api-opensearch"
|
|
13
|
+
},
|
|
14
|
+
"description": "A set of plugins to work with OpenSearch.",
|
|
15
|
+
"contributors": [
|
|
16
|
+
"Pavel Denisjuk <pavel@webiny.com>"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@opensearch-project/opensearch": "3.6.0",
|
|
21
|
+
"@webiny/api": "0.0.0-unstable.7be00a75a9",
|
|
22
|
+
"@webiny/aws-sdk": "0.0.0-unstable.7be00a75a9",
|
|
23
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.7be00a75a9",
|
|
24
|
+
"@webiny/error": "0.0.0-unstable.7be00a75a9",
|
|
25
|
+
"@webiny/feature": "0.0.0-unstable.7be00a75a9",
|
|
26
|
+
"@webiny/plugins": "0.0.0-unstable.7be00a75a9"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@webiny/build-tools": "0.0.0-unstable.7be00a75a9",
|
|
30
|
+
"@webiny/project-utils": "0.0.0-unstable.7be00a75a9",
|
|
31
|
+
"rimraf": "6.1.3",
|
|
32
|
+
"typescript": "6.0.3",
|
|
33
|
+
"vitest": "4.1.7"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"webiny": {
|
|
39
|
+
"publishFrom": "dist"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { SearchBody } from "../../types.js";
|
|
3
|
+
export interface ModifyBodyParams {
|
|
4
|
+
body: SearchBody;
|
|
5
|
+
}
|
|
6
|
+
export interface ModifyBodyCallable<T extends ModifyBodyParams> {
|
|
7
|
+
(params: T): void;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class OpenSearchBodyModifierPlugin<T extends ModifyBodyParams = ModifyBodyParams> extends Plugin {
|
|
10
|
+
private readonly callable?;
|
|
11
|
+
constructor(callable?: ModifyBodyCallable<T>);
|
|
12
|
+
modifyBody(params: T): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
import { Plugin } from "@webiny/plugins";
|
|
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
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export { OpenSearchBodyModifierPlugin };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=OpenSearchBodyModifierPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { FieldSortOptions, SortOrder } from "../../types.js";
|
|
3
|
+
export type UnmappedTypes = "date" | "long" | string;
|
|
4
|
+
export interface ToSearchValueParams {
|
|
5
|
+
/**
|
|
6
|
+
* The value to transform.
|
|
7
|
+
*/
|
|
8
|
+
value: any;
|
|
9
|
+
/**
|
|
10
|
+
* When using toSearchValue() in our code we send a field.getPath() value here.
|
|
11
|
+
*/
|
|
12
|
+
path: string;
|
|
13
|
+
/**
|
|
14
|
+
* When using toSearchValue() in our code we send a field.getBasePath() value here.
|
|
15
|
+
*/
|
|
16
|
+
basePath: string;
|
|
17
|
+
}
|
|
18
|
+
export interface OpenSearchFieldPluginParams {
|
|
19
|
+
/**
|
|
20
|
+
* Which field is this plugin for.
|
|
21
|
+
*/
|
|
22
|
+
field: string;
|
|
23
|
+
/**
|
|
24
|
+
* Some specific path of a field?
|
|
25
|
+
* Example: createdBy is createdBy.id
|
|
26
|
+
*/
|
|
27
|
+
path?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Add a .keyword at the end of the field path?
|
|
30
|
+
*/
|
|
31
|
+
keyword?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Is the field of a specific type, but possibly not mapped?
|
|
34
|
+
* Happens when inserting a date in string format.
|
|
35
|
+
* You need to cast it as date when running the search/sort to work correctly.
|
|
36
|
+
*/
|
|
37
|
+
unmappedType?: UnmappedTypes;
|
|
38
|
+
/**
|
|
39
|
+
* Is the field sortable?
|
|
40
|
+
*/
|
|
41
|
+
sortable?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Is the field searchable?
|
|
44
|
+
*/
|
|
45
|
+
searchable?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Used to transform the input value for the search.
|
|
48
|
+
*/
|
|
49
|
+
toSearchValue?: (params: ToSearchValueParams) => any;
|
|
50
|
+
}
|
|
51
|
+
export declare class OpenSearchFieldPlugin extends Plugin {
|
|
52
|
+
static readonly type: string;
|
|
53
|
+
static readonly ALL: string;
|
|
54
|
+
readonly field: string;
|
|
55
|
+
readonly path: string;
|
|
56
|
+
readonly keyword: boolean;
|
|
57
|
+
readonly unmappedType?: string;
|
|
58
|
+
readonly sortable: boolean;
|
|
59
|
+
readonly searchable: boolean;
|
|
60
|
+
constructor(params: OpenSearchFieldPluginParams);
|
|
61
|
+
/**
|
|
62
|
+
* The default sort options. Extend in your own plugin if you want to add more options.
|
|
63
|
+
*/
|
|
64
|
+
getSortOptions(order: SortOrder): FieldSortOptions;
|
|
65
|
+
/**
|
|
66
|
+
* The default path generator. Extend in your own plugin if you want to add more options.
|
|
67
|
+
* 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.
|
|
68
|
+
*/
|
|
69
|
+
getPath(field: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* @see getPath
|
|
72
|
+
*
|
|
73
|
+
* This is the default base path generator. Basically it replaces ALL with given field name.
|
|
74
|
+
*/
|
|
75
|
+
getBasePath(field: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* The default transformer. Just returns the value by default.
|
|
78
|
+
* Override to implement what ever is required.
|
|
79
|
+
*/
|
|
80
|
+
toSearchValue(params: ToSearchValueParams): any;
|
|
81
|
+
}
|