@webiny/api-opensearch 0.0.0-unstable.0d717d18dd
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 +37 -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 +9 -0
- package/exports/api/opensearch.js +9 -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 +5 -0
- package/features/OpenSearchClient/feature.js +13 -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/OpenSearchField/OpenSearchField.d.ts +18 -0
- package/features/OpenSearchField/OpenSearchField.js +49 -0
- package/features/OpenSearchField/OpenSearchField.js.map +1 -0
- package/features/OpenSearchField/OpenSearchFieldFactory.d.ts +9 -0
- package/features/OpenSearchField/OpenSearchFieldFactory.js +14 -0
- package/features/OpenSearchField/OpenSearchFieldFactory.js.map +1 -0
- package/features/OpenSearchField/abstractions/OpenSearchField.d.ts +35 -0
- package/features/OpenSearchField/abstractions/OpenSearchField.js +6 -0
- package/features/OpenSearchField/abstractions/OpenSearchField.js.map +1 -0
- package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.d.ts +8 -0
- package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.js +5 -0
- package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.js.map +1 -0
- package/features/OpenSearchField/feature.d.ts +4 -0
- package/features/OpenSearchField/feature.js +11 -0
- package/features/OpenSearchField/feature.js.map +1 -0
- package/features/OpenSearchIndex/OpenSearchIndexRegistry.d.ts +12 -0
- package/features/OpenSearchIndex/OpenSearchIndexRegistry.js +30 -0
- package/features/OpenSearchIndex/OpenSearchIndexRegistry.js.map +1 -0
- package/features/OpenSearchIndex/abstractions/OpenSearchIndex.d.ts +9 -0
- package/features/OpenSearchIndex/abstractions/OpenSearchIndex.js +5 -0
- package/features/OpenSearchIndex/abstractions/OpenSearchIndex.js.map +1 -0
- package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.d.ts +9 -0
- package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js +5 -0
- package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js.map +1 -0
- package/features/OpenSearchIndex/feature.d.ts +4 -0
- package/features/OpenSearchIndex/feature.js +11 -0
- package/features/OpenSearchIndex/feature.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.d.ts +12 -0
- package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.js +28 -0
- package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.d.ts +11 -0
- package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js +5 -0
- package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.d.ts +10 -0
- package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js +5 -0
- package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/feature.d.ts +4 -0
- package/features/OpenSearchQueryBuilderOperator/feature.js +41 -0
- package/features/OpenSearchQueryBuilderOperator/feature.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/AndIn.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/AndIn.js +28 -0
- package/features/OpenSearchQueryBuilderOperator/operators/AndIn.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Between.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Between.js +27 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Between.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Contains.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Contains.js +27 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Contains.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Equal.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Equal.js +34 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Equal.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.js +23 -0
- package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.js +23 -0
- package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/In.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/In.js +24 -0
- package/features/OpenSearchQueryBuilderOperator/operators/In.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.js +23 -0
- package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.js +23 -0
- package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Not.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Not.js +38 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Not.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.js +27 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotContains.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotContains.js +27 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotContains.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotIn.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotIn.js +24 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotIn.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js +22 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.js +22 -0
- package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.js.map +1 -0
- package/index.d.ts +14 -0
- package/index.js +14 -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 +2 -0
- package/indices.js +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/package.json +42 -0
- package/registerOpenSearchCore.d.ts +3 -0
- package/registerOpenSearchCore.js +20 -0
- package/registerOpenSearchCore.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/testing/createBlankQuery.d.ts +2 -0
- package/testing/createBlankQuery.js +9 -0
- package/testing/createBlankQuery.js.map +1 -0
- package/testing/createTestOpenSearchClient.d.ts +11 -0
- package/testing/createTestOpenSearchClient.js +162 -0
- package/testing/createTestOpenSearchClient.js.map +1 -0
- package/testing/index.d.ts +4 -0
- package/testing/index.js +4 -0
- package/testing/registerOpenSearchCoreForTests.d.ts +1 -0
- package/testing/registerOpenSearchCoreForTests.js +9 -0
- package/testing/registerOpenSearchCoreForTests.js.map +1 -0
- package/testing/setupTestIndexManager.d.ts +13 -0
- package/testing/setupTestIndexManager.js +26 -0
- package/testing/setupTestIndexManager.js.map +1 -0
- package/types.d.ts +60 -0
- package/types.js +8 -0
- package/types.js.map +1 -0
- package/utils/createIndex.d.ts +19 -0
- package/utils/createIndex.js +60 -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
package/where.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { OpenSearchFieldAll } from "./features/OpenSearchField/abstractions/OpenSearchField.js";
|
|
2
|
+
import error from "@webiny/error";
|
|
3
|
+
const parseWhereKeyRegExp = new RegExp(/^((?:wbyAco_)?[a-zA-Z0-9]+)(_[a-zA-Z0-9_]+)?$/);
|
|
4
|
+
const parseWhereKey = (key)=>{
|
|
5
|
+
const match = key.match(parseWhereKeyRegExp);
|
|
6
|
+
if (!match) throw new Error(`It is not possible to search by key "${key}"`);
|
|
7
|
+
const [, field, operation = "eq"] = match;
|
|
8
|
+
if (!field.match(/^(?:wbyAco_)?([a-zA-Z0-9]+)$/)) throw new Error(`Cannot filter by "${field}".`);
|
|
9
|
+
const operator = operation.match(/^_/) ? operation.slice(1) : operation;
|
|
10
|
+
return {
|
|
11
|
+
field,
|
|
12
|
+
operator
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
const ALL = OpenSearchFieldAll;
|
|
16
|
+
const applyWhere = (params)=>{
|
|
17
|
+
const { query, where, fields, operators } = params;
|
|
18
|
+
for(const key in where){
|
|
19
|
+
if (false === where.hasOwnProperty(key)) continue;
|
|
20
|
+
const initialValue = where[key];
|
|
21
|
+
if (void 0 === initialValue) continue;
|
|
22
|
+
const { field, operator } = parseWhereKey(key);
|
|
23
|
+
const fieldPlugin = fields[field] || fields[ALL];
|
|
24
|
+
if (!fieldPlugin) throw new error(`Missing plugin for the field "${field}".`, "PLUGIN_WHERE_ERROR", {
|
|
25
|
+
field
|
|
26
|
+
});
|
|
27
|
+
const operatorInstance = operators[operator];
|
|
28
|
+
if (!operatorInstance) throw new error(`Missing plugin for the operator "${operator}"`, "PLUGIN_WHERE_ERROR", {
|
|
29
|
+
operator
|
|
30
|
+
});
|
|
31
|
+
const path = fieldPlugin.getPath(field);
|
|
32
|
+
const basePath = fieldPlugin.getBasePath(field);
|
|
33
|
+
const value = fieldPlugin.toSearchValue({
|
|
34
|
+
value: initialValue,
|
|
35
|
+
path,
|
|
36
|
+
basePath
|
|
37
|
+
});
|
|
38
|
+
operatorInstance.apply(query, {
|
|
39
|
+
name: field,
|
|
40
|
+
value,
|
|
41
|
+
path,
|
|
42
|
+
basePath,
|
|
43
|
+
keyword: fieldPlugin.keyword
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export { applyWhere, parseWhereKey };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=where.js.map
|
package/where.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"where.js","sources":["../src/where.ts"],"sourcesContent":["import type { OpenSearchBoolQueryConfig } from \"~/types.js\";\nimport {\n OpenSearchField,\n OpenSearchFieldAll\n} from \"~/features/OpenSearchField/abstractions/OpenSearchField.js\";\nimport type { OpenSearchQueryBuilderOperator } from \"~/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js\";\nimport WebinyError from \"@webiny/error\";\n\ntype Records<T> = Record<string, T>;\n\nexport interface ApplyWhereParams {\n query: OpenSearchBoolQueryConfig;\n where: Records<any>;\n fields: Records<OpenSearchField.Interface>;\n operators: Records<OpenSearchQueryBuilderOperator.Interface>;\n}\n\nexport interface ParseWhereKeyResult {\n field: string;\n operator: string;\n}\n\nconst parseWhereKeyRegExp = new RegExp(/^((?:wbyAco_)?[a-zA-Z0-9]+)(_[a-zA-Z0-9_]+)?$/);\n\nexport const parseWhereKey = (key: string): ParseWhereKeyResult => {\n const match = key.match(parseWhereKeyRegExp);\n\n if (!match) {\n throw new Error(`It is not possible to search by key \"${key}\"`);\n }\n\n const [, field, operation = \"eq\"] = match;\n\n if (!field.match(/^(?:wbyAco_)?([a-zA-Z0-9]+)$/)) {\n throw new Error(`Cannot filter by \"${field}\".`);\n }\n\n const operator = operation.match(/^_/) ? operation.slice(1) : operation;\n\n return { field, operator };\n};\n\nconst ALL = OpenSearchFieldAll;\n\nexport const applyWhere = (params: ApplyWhereParams): void => {\n const { query, where, fields, operators } = params;\n\n for (const key in where) {\n if (where.hasOwnProperty(key) === false) {\n continue;\n }\n const initialValue = where[key];\n if (initialValue === undefined) {\n continue;\n }\n const { field, operator } = parseWhereKey(key);\n const fieldPlugin: OpenSearchField.Interface = fields[field] || fields[ALL];\n if (!fieldPlugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\".`,\n \"PLUGIN_WHERE_ERROR\",\n {\n field\n }\n );\n }\n const operatorInstance = operators[operator];\n if (!operatorInstance) {\n throw new WebinyError(\n `Missing plugin for the operator \"${operator}\"`,\n \"PLUGIN_WHERE_ERROR\",\n {\n operator\n }\n );\n }\n\n const path = fieldPlugin.getPath(field);\n const basePath = fieldPlugin.getBasePath(field);\n const value = fieldPlugin.toSearchValue({\n value: initialValue,\n path,\n basePath\n });\n\n operatorInstance.apply(query, {\n name: field,\n value,\n path,\n basePath,\n keyword: fieldPlugin.keyword\n });\n }\n};\n"],"names":["parseWhereKeyRegExp","RegExp","parseWhereKey","key","match","Error","field","operation","operator","ALL","OpenSearchFieldAll","applyWhere","params","query","where","fields","operators","initialValue","undefined","fieldPlugin","WebinyError","operatorInstance","path","basePath","value"],"mappings":";;AAsBA,MAAMA,sBAAsB,IAAIC,OAAO;AAEhC,MAAMC,gBAAgB,CAACC;IAC1B,MAAMC,QAAQD,IAAI,KAAK,CAACH;IAExB,IAAI,CAACI,OACD,MAAM,IAAIC,MAAM,CAAC,qCAAqC,EAAEF,IAAI,CAAC,CAAC;IAGlE,MAAM,GAAGG,OAAOC,YAAY,IAAI,CAAC,GAAGH;IAEpC,IAAI,CAACE,MAAM,KAAK,CAAC,iCACb,MAAM,IAAID,MAAM,CAAC,kBAAkB,EAAEC,MAAM,EAAE,CAAC;IAGlD,MAAME,WAAWD,UAAU,KAAK,CAAC,QAAQA,UAAU,KAAK,CAAC,KAAKA;IAE9D,OAAO;QAAED;QAAOE;IAAS;AAC7B;AAEA,MAAMC,MAAMC;AAEL,MAAMC,aAAa,CAACC;IACvB,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAEC,SAAS,EAAE,GAAGJ;IAE5C,IAAK,MAAMT,OAAOW,MAAO;QACrB,IAAIA,AAA8B,UAA9BA,MAAM,cAAc,CAACX,MACrB;QAEJ,MAAMc,eAAeH,KAAK,CAACX,IAAI;QAC/B,IAAIc,AAAiBC,WAAjBD,cACA;QAEJ,MAAM,EAAEX,KAAK,EAAEE,QAAQ,EAAE,GAAGN,cAAcC;QAC1C,MAAMgB,cAAyCJ,MAAM,CAACT,MAAM,IAAIS,MAAM,CAACN,IAAI;QAC3E,IAAI,CAACU,aACD,MAAM,IAAIC,MACN,CAAC,8BAA8B,EAAEd,MAAM,EAAE,CAAC,EAC1C,sBACA;YACIA;QACJ;QAGR,MAAMe,mBAAmBL,SAAS,CAACR,SAAS;QAC5C,IAAI,CAACa,kBACD,MAAM,IAAID,MACN,CAAC,iCAAiC,EAAEZ,SAAS,CAAC,CAAC,EAC/C,sBACA;YACIA;QACJ;QAIR,MAAMc,OAAOH,YAAY,OAAO,CAACb;QACjC,MAAMiB,WAAWJ,YAAY,WAAW,CAACb;QACzC,MAAMkB,QAAQL,YAAY,aAAa,CAAC;YACpC,OAAOF;YACPK;YACAC;QACJ;QAEAF,iBAAiB,KAAK,CAACR,OAAO;YAC1B,MAAMP;YACNkB;YACAF;YACAC;YACA,SAASJ,YAAY,OAAO;QAChC;IACJ;AACJ"}
|