@webiny/api-opensearch 6.3.0-beta.4 → 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
package/index.js
CHANGED
|
@@ -13,28 +13,26 @@ export * from "./limit.js";
|
|
|
13
13
|
export * from "./normalize.js";
|
|
14
14
|
export * from "./operators.js";
|
|
15
15
|
export * from "./cursors.js";
|
|
16
|
-
export { createOpenSearchClient } from "./client.js";
|
|
17
16
|
export * from "./utils/index.js";
|
|
18
17
|
export * from "./operations/index.js";
|
|
19
18
|
export * from "./sharedIndex.js";
|
|
20
19
|
export * from "./indexPrefix.js";
|
|
21
20
|
export * from "./db/index.js";
|
|
22
21
|
export * from "./types.js";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
plugin.name = "context.opensearch";
|
|
37
|
-
return plugin;
|
|
22
|
+
const createOpenSearchContext = (params)=>{
|
|
23
|
+
const plugin = new ContextPlugin((context)=>{
|
|
24
|
+
if (context.opensearch) throw new Error("OpenSearch context must not be loaded more than once!");
|
|
25
|
+
const client = params instanceof Client ? params : createOpenSearchClient(params);
|
|
26
|
+
context.opensearch = client;
|
|
27
|
+
context.elasticsearch = client;
|
|
28
|
+
context.plugins.register(getOpenSearchOperators());
|
|
29
|
+
OpenSearchContextFeature.register(context.container, context);
|
|
30
|
+
OpenSearchClientFeature.register(context.container);
|
|
31
|
+
OpenSearchClientFactoryFeature.register(context.container);
|
|
32
|
+
});
|
|
33
|
+
plugin.name = "context.opensearch";
|
|
34
|
+
return plugin;
|
|
38
35
|
};
|
|
36
|
+
export { createOpenSearchClient, createOpenSearchContext };
|
|
39
37
|
|
|
40
38
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { OpenSearchContext } from \"./types.js\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport type { OpenSearchClientOptions } from \"./client.js\";\nimport { Client, createOpenSearchClient } from \"./client.js\";\nimport { getOpenSearchOperators } from \"./operators.js\";\nimport { OpenSearchClientFactoryFeature } from \"./features/OpenSearchClientFactory/feature.js\";\nimport { OpenSearchClientFeature } from \"./features/OpenSearchClient/feature.js\";\nimport { OpenSearchContextFeature } from \"~/features/OpenSearchContext/feature.js\";\n\nexport * from \"./indexConfiguration/index.js\";\nexport * from \"./plugins/index.js\";\nexport * from \"./sort.js\";\nexport * from \"./indices.js\";\nexport * from \"./where.js\";\nexport * from \"./limit.js\";\nexport * from \"./normalize.js\";\nexport * from \"./operators.js\";\nexport * from \"./cursors.js\";\nexport {\n createOpenSearchClient,\n type Client,\n type ClientOptions,\n type OpenSearchClientOptions\n} from \"./client.js\";\nexport * from \"./utils/index.js\";\nexport * from \"./operations/index.js\";\nexport * from \"./sharedIndex.js\";\nexport * from \"./indexPrefix.js\";\nexport * from \"./db/index.js\";\nexport * from \"./types.js\";\n\nexport const createOpenSearchContext = (\n params: OpenSearchClientOptions | Client\n): ContextPlugin<OpenSearchContext> => {\n const plugin = new ContextPlugin<OpenSearchContext>(context => {\n if (context.opensearch) {\n throw new Error(\"OpenSearch context must not be loaded more than once!\");\n }\n const client = params instanceof Client ? params : createOpenSearchClient(params);\n context.opensearch = client;\n context.elasticsearch = client;\n\n context.plugins.register(getOpenSearchOperators());\n\n OpenSearchContextFeature.register(context.container, context);\n OpenSearchClientFeature.register(context.container);\n OpenSearchClientFactoryFeature.register(context.container);\n });\n\n plugin.name = \"context.opensearch\";\n\n return plugin;\n};\n"],"names":["createOpenSearchContext","params","plugin","ContextPlugin","context","Error","client","Client","createOpenSearchClient","getOpenSearchOperators","OpenSearchContextFeature","OpenSearchClientFeature","OpenSearchClientFactoryFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+BO,MAAMA,0BAA0B,CACnCC;IAEA,MAAMC,SAAS,IAAIC,cAAiCC,CAAAA;QAChD,IAAIA,QAAQ,UAAU,EAClB,MAAM,IAAIC,MAAM;QAEpB,MAAMC,SAASL,kBAAkBM,SAASN,SAASO,uBAAuBP;QAC1EG,QAAQ,UAAU,GAAGE;QACrBF,QAAQ,aAAa,GAAGE;QAExBF,QAAQ,OAAO,CAAC,QAAQ,CAACK;QAEzBC,yBAAyB,QAAQ,CAACN,QAAQ,SAAS,EAAEA;QACrDO,wBAAwB,QAAQ,CAACP,QAAQ,SAAS;QAClDQ,+BAA+B,QAAQ,CAACR,QAAQ,SAAS;IAC7D;IAEAF,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
|
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
import { getCommonMappings } from "./common.js";
|
|
2
2
|
const config = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
15
24
|
}
|
|
16
|
-
}
|
|
17
25
|
}
|
|
18
|
-
}]);
|
|
19
|
-
}),
|
|
20
|
-
properties: {
|
|
21
|
-
rawValues: {
|
|
22
|
-
type: "object",
|
|
23
|
-
enabled: false
|
|
24
|
-
}
|
|
25
26
|
}
|
|
26
|
-
}
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return config;
|
|
31
|
-
}
|
|
32
|
-
return modifier(config);
|
|
28
|
+
const getBaseConfiguration = (modifier)=>{
|
|
29
|
+
if (!modifier) return config;
|
|
30
|
+
return modifier(config);
|
|
33
31
|
};
|
|
32
|
+
export { getBaseConfiguration };
|
|
34
33
|
|
|
35
34
|
//# sourceMappingURL=base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
@@ -1,44 +1,42 @@
|
|
|
1
|
-
const getDefaultMappings = ()
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return getDefaultMappings();
|
|
40
|
-
}
|
|
41
|
-
return cb(getDefaultMappings());
|
|
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());
|
|
42
39
|
};
|
|
40
|
+
export { getCommonMappings };
|
|
43
41
|
|
|
44
42
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
};
|
|
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 };
|
|
4
3
|
|
|
5
4
|
//# sourceMappingURL=indexPrefix.js.map
|
package/indexPrefix.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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.js
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
const listIndicesPlugins = ({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return plugin.canUse();
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export const getLastAddedIndexPlugin = params => {
|
|
11
|
-
const plugins = listIndicesPlugins(params);
|
|
12
|
-
if (plugins.length === 0) {
|
|
13
|
-
throw new WebinyError(`Could not find a single OpenSearchIndexPlugin of type "${params.type}".`, "OPENSEARCH_INDEX_TEMPLATE_ERROR", {
|
|
14
|
-
type: params.type
|
|
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
|
|
15
7
|
});
|
|
16
|
-
|
|
17
|
-
return plugins.pop();
|
|
8
|
+
return plugins.pop();
|
|
18
9
|
};
|
|
10
|
+
export { getLastAddedIndexPlugin };
|
|
19
11
|
|
|
20
12
|
//# sourceMappingURL=indices.js.map
|
package/indices.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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.js
CHANGED
|
@@ -1,32 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is the max limit of the OpenSearch.
|
|
3
|
-
* Change here if it changes (and if it is necessary).
|
|
4
|
-
*/
|
|
5
1
|
const ES_LIMIT_MAX = 10000;
|
|
6
|
-
/**
|
|
7
|
-
* Our system default limit.
|
|
8
|
-
*/
|
|
9
2
|
const ES_LIMIT_DEFAULT = 50;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
if (!limit || limit < 1) {
|
|
16
|
-
return defaultValue;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Users input limit cannot be greater than the OpenSearch one.
|
|
20
|
-
* OpenSearch query breaks because of that.
|
|
21
|
-
*/
|
|
22
|
-
if (limit < ES_LIMIT_MAX) {
|
|
23
|
-
return limit;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Always reduce by 1 because we check if there are more items by adding 1 to the limit
|
|
27
|
-
* and then remove that last one loaded.
|
|
28
|
-
*/
|
|
29
|
-
return ES_LIMIT_MAX - 1;
|
|
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;
|
|
30
7
|
};
|
|
8
|
+
export { createLimit };
|
|
31
9
|
|
|
32
10
|
//# sourceMappingURL=limit.js.map
|
package/limit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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.js
CHANGED
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const specialCharacters = [
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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 || "";
|
|
26
38
|
};
|
|
27
|
-
const hasSpecialChar = value
|
|
28
|
-
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
return value.match(/^([0-9a-zA-Z]+)$/i) === null;
|
|
39
|
+
const hasSpecialChar = (value)=>{
|
|
40
|
+
if (!value) return null;
|
|
41
|
+
return null === value.match(/^([0-9a-zA-Z]+)$/i);
|
|
32
42
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
result = `*${result}`;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* If there is a / in the last word, do not put asterisk at the end of it.
|
|
46
|
-
*/
|
|
47
|
-
const lastWord = results[results.length - 1];
|
|
48
|
-
if (hasSpecialChar(lastWord) === false) {
|
|
49
|
-
result = `${result}*`;
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
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
52
|
};
|
|
53
|
+
export { normalizeValue, normalizeValueWithAsterisk };
|
|
53
54
|
|
|
54
55
|
//# sourceMappingURL=normalize.js.map
|
package/normalize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
2
|
import { stripConnectionFromException } from "./stripConnectionFromException.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
throw error;
|
|
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
|
+
}
|
|
27
26
|
}
|
|
28
|
-
}
|
|
29
27
|
}
|
|
28
|
+
export { OpenSearchCatHealth };
|
|
30
29
|
|
|
31
30
|
//# sourceMappingURL=OpenSearchCatHealth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
2
|
import { stripConnectionFromException } from "./stripConnectionFromException.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
throw error;
|
|
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
|
+
}
|
|
25
24
|
}
|
|
26
|
-
}
|
|
27
25
|
}
|
|
26
|
+
export { OpenSearchCatNodes };
|
|
28
27
|
|
|
29
28
|
//# sourceMappingURL=OpenSearchCatNodes.js.map
|