@webiny/api-opensearch 6.4.5 → 6.6.0-alpha.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 +1 -24
- package/client.js.map +1 -1
- package/exports/api/opensearch.d.ts +6 -1
- package/exports/api/opensearch.js +6 -1
- package/features/OpenSearchClient/abstraction.d.ts +3 -3
- package/features/OpenSearchClient/abstraction.js.map +1 -1
- package/features/OpenSearchClient/feature.d.ts +2 -1
- package/features/OpenSearchClient/feature.js +5 -3
- package/features/OpenSearchClient/feature.js.map +1 -1
- package/features/OpenSearchField/OpenSearchField.d.ts +18 -0
- package/{plugins/definition/OpenSearchFieldPlugin.js → features/OpenSearchField/OpenSearchField.js} +10 -13
- 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/{plugins/operator/andIn.js → features/OpenSearchQueryBuilderOperator/operators/AndIn.js} +8 -7
- package/features/OpenSearchQueryBuilderOperator/operators/AndIn.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Between.d.ts +9 -0
- package/{plugins/operator/between.js → features/OpenSearchQueryBuilderOperator/operators/Between.js} +8 -7
- 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/{plugins/operator/equal.js → features/OpenSearchQueryBuilderOperator/operators/Equal.js} +8 -7
- 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/{plugins/operator/in.js → features/OpenSearchQueryBuilderOperator/operators/In.js} +8 -7
- 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/{plugins/operator/not.js → features/OpenSearchQueryBuilderOperator/operators/Not.js} +8 -7
- package/features/OpenSearchQueryBuilderOperator/operators/Not.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.d.ts +9 -0
- package/{plugins/operator/notBetween.js → features/OpenSearchQueryBuilderOperator/operators/NotBetween.js} +8 -7
- 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/{plugins/operator/notIn.js → features/OpenSearchQueryBuilderOperator/operators/NotIn.js} +8 -7
- 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 +2 -9
- package/index.js +3 -27
- package/indices.d.ts +2 -8
- package/indices.js +1 -12
- package/package.json +11 -10
- package/registerOpenSearchCore.d.ts +3 -0
- package/registerOpenSearchCore.js +20 -0
- package/registerOpenSearchCore.js.map +1 -0
- package/sort.d.ts +2 -2
- package/sort.js +2 -2
- package/sort.js.map +1 -1
- 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 +0 -8
- package/types.js.map +1 -1
- package/utils/createIndex.d.ts +2 -2
- package/utils/createIndex.js +2 -8
- package/utils/createIndex.js.map +1 -1
- package/where.d.ts +4 -4
- package/where.js +5 -5
- package/where.js.map +1 -1
- package/features/OpenSearchClient/OpenSearchClient.d.ts +0 -12
- package/features/OpenSearchClient/OpenSearchClient.js +0 -19
- package/features/OpenSearchClient/OpenSearchClient.js.map +0 -1
- package/features/OpenSearchContext/OpenSearchContext.d.ts +0 -8
- package/features/OpenSearchContext/OpenSearchContext.js +0 -14
- package/features/OpenSearchContext/OpenSearchContext.js.map +0 -1
- package/features/OpenSearchContext/abstraction.d.ts +0 -14
- package/features/OpenSearchContext/abstraction.js +0 -5
- package/features/OpenSearchContext/abstraction.js.map +0 -1
- package/features/OpenSearchContext/feature.d.ts +0 -5
- package/features/OpenSearchContext/feature.js +0 -12
- package/features/OpenSearchContext/feature.js.map +0 -1
- package/index.js.map +0 -1
- package/indices.js.map +0 -1
- package/operators.d.ts +0 -6
- package/operators.js +0 -22
- package/operators.js.map +0 -1
- package/plugins/definition/OpenSearchBodyModifierPlugin.d.ts +0 -13
- package/plugins/definition/OpenSearchBodyModifierPlugin.js +0 -17
- package/plugins/definition/OpenSearchBodyModifierPlugin.js.map +0 -1
- package/plugins/definition/OpenSearchFieldPlugin.d.ts +0 -81
- package/plugins/definition/OpenSearchFieldPlugin.js.map +0 -1
- package/plugins/definition/OpenSearchIndexPlugin.d.ts +0 -10
- package/plugins/definition/OpenSearchIndexPlugin.js +0 -16
- package/plugins/definition/OpenSearchIndexPlugin.js.map +0 -1
- package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.d.ts +0 -10
- package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js +0 -9
- package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js.map +0 -1
- package/plugins/definition/OpenSearchQueryModifierPlugin.d.ts +0 -14
- package/plugins/definition/OpenSearchQueryModifierPlugin.js +0 -17
- package/plugins/definition/OpenSearchQueryModifierPlugin.js.map +0 -1
- package/plugins/definition/OpenSearchSortModifierPlugin.d.ts +0 -13
- package/plugins/definition/OpenSearchSortModifierPlugin.js +0 -17
- package/plugins/definition/OpenSearchSortModifierPlugin.js.map +0 -1
- package/plugins/definition/index.d.ts +0 -6
- package/plugins/definition/index.js +0 -6
- package/plugins/index.d.ts +0 -2
- package/plugins/index.js +0 -2
- package/plugins/operator/andIn.d.ts +0 -7
- package/plugins/operator/andIn.js.map +0 -1
- package/plugins/operator/between.d.ts +0 -7
- package/plugins/operator/between.js.map +0 -1
- package/plugins/operator/contains.d.ts +0 -7
- package/plugins/operator/contains.js +0 -26
- package/plugins/operator/contains.js.map +0 -1
- package/plugins/operator/equal.d.ts +0 -7
- package/plugins/operator/equal.js.map +0 -1
- package/plugins/operator/gt.d.ts +0 -7
- package/plugins/operator/gt.js +0 -22
- package/plugins/operator/gt.js.map +0 -1
- package/plugins/operator/gte.d.ts +0 -7
- package/plugins/operator/gte.js +0 -22
- package/plugins/operator/gte.js.map +0 -1
- package/plugins/operator/in.d.ts +0 -7
- package/plugins/operator/in.js.map +0 -1
- package/plugins/operator/index.d.ts +0 -15
- package/plugins/operator/index.js +0 -15
- package/plugins/operator/lt.d.ts +0 -7
- package/plugins/operator/lt.js +0 -22
- package/plugins/operator/lt.js.map +0 -1
- package/plugins/operator/lte.d.ts +0 -7
- package/plugins/operator/lte.js +0 -22
- package/plugins/operator/lte.js.map +0 -1
- package/plugins/operator/not.d.ts +0 -7
- package/plugins/operator/not.js.map +0 -1
- package/plugins/operator/notBetween.d.ts +0 -7
- package/plugins/operator/notBetween.js.map +0 -1
- package/plugins/operator/notContains.d.ts +0 -7
- package/plugins/operator/notContains.js +0 -26
- package/plugins/operator/notContains.js.map +0 -1
- package/plugins/operator/notIn.d.ts +0 -7
- package/plugins/operator/notIn.js.map +0 -1
- package/plugins/operator/notStartsWith.d.ts +0 -7
- package/plugins/operator/notStartsWith.js +0 -21
- package/plugins/operator/notStartsWith.js.map +0 -1
- package/plugins/operator/startsWith.d.ts +0 -7
- package/plugins/operator/startsWith.js +0 -21
- package/plugins/operator/startsWith.js.map +0 -1
package/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Client } from "@opensearch-project/opensearch";
|
|
2
2
|
import type { Search_RequestBody as SearchRequestBody, Search_Response, Indices_Create_RequestBody } from "@opensearch-project/opensearch/api/index.js";
|
|
3
|
-
import type { Context } from "@webiny/api/types.js";
|
|
4
3
|
type QueryDslQueryContainer = NonNullable<SearchRequestBody["query"]>;
|
|
5
4
|
type QueryDslBoolQuery = NonNullable<QueryDslQueryContainer["bool"]>;
|
|
6
5
|
type SearchSort = NonNullable<SearchRequestBody["sort"]>;
|
|
@@ -29,13 +28,6 @@ export type SortType = Record<string, FieldSortOptions>;
|
|
|
29
28
|
export type SearchBody = Omit<SearchRequestBody, "search_after"> & {
|
|
30
29
|
search_after?: PrimitiveValue[];
|
|
31
30
|
};
|
|
32
|
-
export interface OpenSearchContext extends Context {
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated Use `context.opensearch` instead.
|
|
35
|
-
*/
|
|
36
|
-
elasticsearch: Client;
|
|
37
|
-
opensearch: Client;
|
|
38
|
-
}
|
|
39
31
|
export interface OpenSearchBoolQueryConfig extends QueryDslBoolQuery {
|
|
40
32
|
must: QueryDslQueryContainer[];
|
|
41
33
|
filter: QueryDslQueryContainer[];
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { Client } from \"@opensearch-project/opensearch\";\nimport type {\n Search_RequestBody as SearchRequestBody,\n Search_Response,\n Indices_Create_RequestBody\n} from \"@opensearch-project/opensearch/api/index.js\";\
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { Client } from \"@opensearch-project/opensearch\";\nimport type {\n Search_RequestBody as SearchRequestBody,\n Search_Response,\n Indices_Create_RequestBody\n} from \"@opensearch-project/opensearch/api/index.js\";\n\n// ---------------------------------------------------------------------------\n// Types inferred from the accessible API surface.\n// The `_types/` directory in the opensearch package only ships `.d.ts` files\n// (no `.js` runtime modules), so deep imports are unresolvable under\n// `moduleResolution: \"bundler\"`. We infer what we can from the public\n// barrel (`api/index.js`) and use `string` where structural extraction\n// is not possible.\n// ---------------------------------------------------------------------------\n\ntype QueryDslQueryContainer = NonNullable<SearchRequestBody[\"query\"]>;\ntype QueryDslBoolQuery = NonNullable<QueryDslQueryContainer[\"bool\"]>;\ntype SearchSort = NonNullable<SearchRequestBody[\"sort\"]>;\ntype SearchSortOrder = \"asc\" | \"desc\";\n\n// Distribute over the SortOptions union and extract only the Record<string, FieldSort> variant.\ntype _ExtractRecordValue<T> = T extends Record<string, infer V> ? V : never;\ntype _SortMember =\n NonNullable<SearchRequestBody[\"sort\"]> extends (infer U)[] | (infer U) ? U : never;\ntype SearchFieldSort = _ExtractRecordValue<Exclude<_SortMember, string>>;\n\ntype DynamicTemplate = NonNullable<\n NonNullable<Indices_Create_RequestBody[\"mappings\"]>[\"dynamic_templates\"]\n>[number][string];\n\nexport type { ApiResponse } from \"@opensearch-project/opensearch\";\n\nexport type { Client };\n\n// ---------------------------------------------------------------------------\n// Local type aliases replacing elastic-ts\n// ---------------------------------------------------------------------------\n\n/** Replaces elastic-ts PrimitiveValue. Aligns with opensearch FieldValue. */\nexport type PrimitiveValue = boolean | undefined | number | string;\n\n/** Replaces elastic-ts Query */\nexport type { QueryDslQueryContainer };\n\n/** Replaces elastic-ts BoolQueryConfig */\nexport type { QueryDslBoolQuery };\n\n/** Replaces elastic-ts FieldSortOptions */\nexport type FieldSortOptions = SearchFieldSort;\n\n/** Replaces elastic-ts SortOrder. Narrowed to \"asc\" | \"desc\" (excludes \"_doc\"). */\nexport type SortOrder = \"asc\" | \"desc\";\n\n/** Replaces elastic-ts Sort */\nexport type { SearchSort as Sort };\n\n/** Single sort entry as an object map. Replaces elastic-ts SortType. */\nexport type SortType = Record<string, FieldSortOptions>;\n\n/** Replaces elastic-ts SearchBody. Overrides search_after to allow PrimitiveValue[] (null | boolean | string | number). */\nexport type SearchBody = Omit<SearchRequestBody, \"search_after\"> & {\n search_after?: PrimitiveValue[];\n};\n\n// ---------------------------------------------------------------------------\n// Bool query with required arrays (our convention)\n// ---------------------------------------------------------------------------\n\nexport interface OpenSearchBoolQueryConfig extends QueryDslBoolQuery {\n must: QueryDslQueryContainer[];\n filter: QueryDslQueryContainer[];\n should: QueryDslQueryContainer[];\n must_not: QueryDslQueryContainer[];\n}\n\n// ---------------------------------------------------------------------------\n// Operator plugin types\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchQueryOperator =\n | \"eq\"\n | \"not\"\n | \"in\"\n | \"not_in\"\n | \"contains\"\n | \"not_contains\"\n | \"between\"\n | \"not_between\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\"\n | string;\n\nexport interface OpenSearchQueryBuilderArgsPlugin {\n name: string;\n path: string;\n basePath: string;\n value: any;\n keyword: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Search response shapes (aligned with @opensearch-project/opensearch v3)\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchSearchResponseHit = Search_Response[\"body\"][\"hits\"][\"hits\"][number];\n\nexport interface OpenSearchSearchResponseAggregationBucket {\n key: PrimitiveValue;\n doc_count: number;\n}\n\nexport type OpenSearchSearchResponseBodyHits = Search_Response[\"body\"][\"hits\"];\n\nexport type OpenSearchSearchResponseBody = Search_Response[\"body\"];\n\nexport type OpenSearchSearchResponse = Search_Response;\n\n/**\n * Extract the total count from an opensearch hits response.\n * Handles both `TotalHits` (object with `value`) and plain `number` formats.\n */\nexport const getTotalCount = (total: OpenSearchSearchResponseBodyHits[\"total\"]): number => {\n if (total === undefined || total === null) {\n return 0;\n }\n if (typeof total === \"number\") {\n return total;\n }\n return total.value;\n};\n\n// ---------------------------------------------------------------------------\n// Index request body shapes (re-exported from opensearch package)\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchIndexRequestBodyMappingsDynamicTemplate = Record<string, DynamicTemplate>;\n\nexport type OpenSearchIndexRequestBody = Indices_Create_RequestBody;\n\n// Re-export SearchSortOrder for consumers that need it (including \"_doc\")\nexport type { SearchSortOrder };\n"],"names":["getTotalCount","total"],"mappings":"AA4HO,MAAMA,gBAAgB,CAACC;IAC1B,IAAIA,QAAAA,OACA,OAAO;IAEX,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAOA;IAEX,OAAOA,MAAM,KAAK;AACtB"}
|
package/utils/createIndex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Client } from "../client.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OpenSearchIndex } from "../features/OpenSearchIndex/abstractions/OpenSearchIndex.js";
|
|
3
3
|
interface OnExists {
|
|
4
4
|
(): void;
|
|
5
5
|
}
|
|
@@ -8,7 +8,7 @@ interface OnError {
|
|
|
8
8
|
}
|
|
9
9
|
interface CreateIndexParams {
|
|
10
10
|
client: Client;
|
|
11
|
-
|
|
11
|
+
plugin: OpenSearchIndex.Interface;
|
|
12
12
|
type: string;
|
|
13
13
|
tenant: string;
|
|
14
14
|
index: string;
|
package/utils/createIndex.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { getLastAddedIndexPlugin } from "../indices.js";
|
|
2
1
|
import _webiny_error from "@webiny/error";
|
|
3
2
|
const indexExists = async (params)=>{
|
|
4
|
-
const { client, index
|
|
3
|
+
const { client, index } = params;
|
|
5
4
|
try {
|
|
6
5
|
const response = await client.indices.exists({
|
|
7
6
|
index,
|
|
@@ -12,7 +11,6 @@ const indexExists = async (params)=>{
|
|
|
12
11
|
local: false
|
|
13
12
|
});
|
|
14
13
|
if (!response.body) return false;
|
|
15
|
-
if (onExists) onExists();
|
|
16
14
|
return true;
|
|
17
15
|
} catch {
|
|
18
16
|
console.error(`Could not determine if the index "${index}" exists.`);
|
|
@@ -46,11 +44,7 @@ const indexCreate = async (params)=>{
|
|
|
46
44
|
}
|
|
47
45
|
};
|
|
48
46
|
const createIndex = async (params)=>{
|
|
49
|
-
const {
|
|
50
|
-
const plugin = getLastAddedIndexPlugin({
|
|
51
|
-
container: plugins,
|
|
52
|
-
type
|
|
53
|
-
});
|
|
47
|
+
const { plugin, onExists } = params;
|
|
54
48
|
const exists = await indexExists(params);
|
|
55
49
|
if (exists) {
|
|
56
50
|
if (onExists) onExists();
|
package/utils/createIndex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/createIndex.js","sources":["../../src/utils/createIndex.ts"],"sourcesContent":["import type { Client } from \"~/client.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"utils/createIndex.js","sources":["../../src/utils/createIndex.ts"],"sourcesContent":["import type { Client } from \"~/client.js\";\nimport type { OpenSearchIndex } from \"~/features/OpenSearchIndex/abstractions/OpenSearchIndex.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface OnExists {\n (): void;\n}\n\ninterface OnError {\n (ex: Error): Error;\n}\n\ninterface ExistsIndexParams {\n client: Client;\n index: string;\n}\n\nconst indexExists = async (params: ExistsIndexParams): Promise<boolean> => {\n const { client, index } = params;\n\n try {\n const response = await client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n if (!response.body) {\n return false;\n }\n return true;\n } catch {\n console.error(`Could not determine if the index \"${index}\" exists.`);\n }\n return false;\n};\n\ninterface IndexCreateParams {\n client: Client;\n index: string;\n type: string;\n tenant: string;\n plugin: OpenSearchIndex.Interface;\n onError?: OnError;\n}\n\nconst indexCreate = async (params: IndexCreateParams): Promise<void> => {\n const { client, index, plugin, tenant, type, onError } = params;\n\n try {\n await client.indices.create({\n index,\n body: {\n ...plugin.body\n }\n });\n } catch (ex) {\n let error = ex;\n if (onError) {\n error = onError(ex);\n }\n throw new WebinyError(\n error.message || `Could not create OpenSearch index for the ${type}.`,\n error.code || \"CREATE_OPENSEARCH_INDEX_ERROR\",\n {\n error: {\n ...error,\n message: error.message,\n code: error.code,\n data: error.data\n },\n type,\n tenant,\n index,\n body: plugin.body\n }\n );\n }\n};\n\ninterface CreateIndexParams {\n client: Client;\n plugin: OpenSearchIndex.Interface;\n type: string;\n tenant: string;\n index: string;\n onExists?: OnExists;\n onError?: OnError;\n}\n\nexport const createIndex = async (params: CreateIndexParams): Promise<void> => {\n const { plugin, onExists } = params;\n\n const exists = await indexExists(params);\n if (exists) {\n if (onExists) {\n onExists();\n }\n return;\n }\n\n await indexCreate({\n ...params,\n plugin\n });\n};\n"],"names":["indexExists","params","client","index","response","console","indexCreate","plugin","tenant","type","onError","ex","error","WebinyError","createIndex","onExists","exists"],"mappings":";AAiBA,MAAMA,cAAc,OAAOC;IACvB,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGF;IAE1B,IAAI;QACA,MAAMG,WAAW,MAAMF,OAAO,OAAO,CAAC,MAAM,CAAC;YACzCC;YACA,oBAAoB;YACpB,kBAAkB;YAClB,kBAAkB;YAClB,eAAe;YACf,OAAO;QACX;QACA,IAAI,CAACC,SAAS,IAAI,EACd,OAAO;QAEX,OAAO;IACX,EAAE,OAAM;QACJC,QAAQ,KAAK,CAAC,CAAC,kCAAkC,EAAEF,MAAM,SAAS,CAAC;IACvE;IACA,OAAO;AACX;AAWA,MAAMG,cAAc,OAAOL;IACvB,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAEI,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAE,GAAGT;IAEzD,IAAI;QACA,MAAMC,OAAO,OAAO,CAAC,MAAM,CAAC;YACxBC;YACA,MAAM;gBACF,GAAGI,OAAO,IAAI;YAClB;QACJ;IACJ,EAAE,OAAOI,IAAI;QACT,IAAIC,QAAQD;QACZ,IAAID,SACAE,QAAQF,QAAQC;QAEpB,MAAM,IAAIE,cACND,MAAM,OAAO,IAAI,CAAC,0CAA0C,EAAEH,KAAK,CAAC,CAAC,EACrEG,MAAM,IAAI,IAAI,iCACd;YACI,OAAO;gBACH,GAAGA,KAAK;gBACR,SAASA,MAAM,OAAO;gBACtB,MAAMA,MAAM,IAAI;gBAChB,MAAMA,MAAM,IAAI;YACpB;YACAH;YACAD;YACAL;YACA,MAAMI,OAAO,IAAI;QACrB;IAER;AACJ;AAYO,MAAMO,cAAc,OAAOb;IAC9B,MAAM,EAAEM,MAAM,EAAEQ,QAAQ,EAAE,GAAGd;IAE7B,MAAMe,SAAS,MAAMhB,YAAYC;IACjC,IAAIe,QAAQ;QACR,IAAID,UACAA;QAEJ;IACJ;IAEA,MAAMT,YAAY;QACd,GAAGL,MAAM;QACTM;IACJ;AACJ"}
|
package/where.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { OpenSearchBoolQueryConfig } from "./types.js";
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
2
|
+
import { OpenSearchField } from "./features/OpenSearchField/abstractions/OpenSearchField.js";
|
|
3
|
+
import type { OpenSearchQueryBuilderOperator } from "./features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js";
|
|
4
4
|
type Records<T> = Record<string, T>;
|
|
5
5
|
export interface ApplyWhereParams {
|
|
6
6
|
query: OpenSearchBoolQueryConfig;
|
|
7
7
|
where: Records<any>;
|
|
8
|
-
fields: Records<
|
|
9
|
-
operators: Records<
|
|
8
|
+
fields: Records<OpenSearchField.Interface>;
|
|
9
|
+
operators: Records<OpenSearchQueryBuilderOperator.Interface>;
|
|
10
10
|
}
|
|
11
11
|
export interface ParseWhereKeyResult {
|
|
12
12
|
field: string;
|
package/where.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpenSearchFieldAll } from "./features/OpenSearchField/abstractions/OpenSearchField.js";
|
|
2
2
|
import error from "@webiny/error";
|
|
3
3
|
const parseWhereKeyRegExp = new RegExp(/^((?:wbyAco_)?[a-zA-Z0-9]+)(_[a-zA-Z0-9_]+)?$/);
|
|
4
4
|
const parseWhereKey = (key)=>{
|
|
@@ -12,7 +12,7 @@ const parseWhereKey = (key)=>{
|
|
|
12
12
|
operator
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
const ALL =
|
|
15
|
+
const ALL = OpenSearchFieldAll;
|
|
16
16
|
const applyWhere = (params)=>{
|
|
17
17
|
const { query, where, fields, operators } = params;
|
|
18
18
|
for(const key in where){
|
|
@@ -24,8 +24,8 @@ const applyWhere = (params)=>{
|
|
|
24
24
|
if (!fieldPlugin) throw new error(`Missing plugin for the field "${field}".`, "PLUGIN_WHERE_ERROR", {
|
|
25
25
|
field
|
|
26
26
|
});
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
27
|
+
const operatorInstance = operators[operator];
|
|
28
|
+
if (!operatorInstance) throw new error(`Missing plugin for the operator "${operator}"`, "PLUGIN_WHERE_ERROR", {
|
|
29
29
|
operator
|
|
30
30
|
});
|
|
31
31
|
const path = fieldPlugin.getPath(field);
|
|
@@ -35,7 +35,7 @@ const applyWhere = (params)=>{
|
|
|
35
35
|
path,
|
|
36
36
|
basePath
|
|
37
37
|
});
|
|
38
|
-
|
|
38
|
+
operatorInstance.apply(query, {
|
|
39
39
|
name: field,
|
|
40
40
|
value,
|
|
41
41
|
path,
|
package/where.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"where.js","sources":["../src/where.ts"],"sourcesContent":["import type { OpenSearchBoolQueryConfig } from \"~/types.js\";\nimport {
|
|
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"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { OpenSearchClient as OpenSearchClientAbstraction } from "./abstraction.js";
|
|
2
|
-
import type { Client } from "../../types.js";
|
|
3
|
-
import { OpenSearchContext } from "../../features/OpenSearchContext/abstraction.js";
|
|
4
|
-
declare class OpenSearchClientImpl implements OpenSearchClientAbstraction.Interface {
|
|
5
|
-
private readonly context;
|
|
6
|
-
constructor(context: OpenSearchContext.Interface);
|
|
7
|
-
use(): Client;
|
|
8
|
-
}
|
|
9
|
-
export declare const OpenSearchClient: typeof OpenSearchClientImpl & {
|
|
10
|
-
__abstraction: import("@webiny/di").Abstraction<import("./abstraction.js").IOpenSearchClient>;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { OpenSearchClient } from "./abstraction.js";
|
|
2
|
-
import { OpenSearchContext } from "../OpenSearchContext/abstraction.js";
|
|
3
|
-
class OpenSearchClientImpl {
|
|
4
|
-
constructor(context){
|
|
5
|
-
this.context = context;
|
|
6
|
-
}
|
|
7
|
-
use() {
|
|
8
|
-
return this.context.opensearch;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
const OpenSearchClient_OpenSearchClient = OpenSearchClient.createImplementation({
|
|
12
|
-
implementation: OpenSearchClientImpl,
|
|
13
|
-
dependencies: [
|
|
14
|
-
OpenSearchContext
|
|
15
|
-
]
|
|
16
|
-
});
|
|
17
|
-
export { OpenSearchClient_OpenSearchClient as OpenSearchClient };
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=OpenSearchClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features/OpenSearchClient/OpenSearchClient.js","sources":["../../../src/features/OpenSearchClient/OpenSearchClient.ts"],"sourcesContent":["import { OpenSearchClient as OpenSearchClientAbstraction } from \"./abstraction.js\";\nimport type { Client } from \"~/types.js\";\nimport { OpenSearchContext } from \"~/features/OpenSearchContext/abstraction.js\";\n\nclass OpenSearchClientImpl implements OpenSearchClientAbstraction.Interface {\n public constructor(private readonly context: OpenSearchContext.Interface) {}\n\n public use(): Client {\n return this.context.opensearch;\n }\n}\n\nexport const OpenSearchClient = OpenSearchClientAbstraction.createImplementation({\n implementation: OpenSearchClientImpl,\n dependencies: [OpenSearchContext]\n});\n"],"names":["OpenSearchClientImpl","context","OpenSearchClient","OpenSearchClientAbstraction","OpenSearchContext"],"mappings":";;AAIA,MAAMA;IACF,YAAoCC,OAAoC,CAAE;aAAtCA,OAAO,GAAPA;IAAuC;IAEpE,MAAc;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU;IAClC;AACJ;AAEO,MAAMC,oCAAmBC,iBAAAA,oBAAgD,CAAC;IAC7E,gBAAgBH;IAChB,cAAc;QAACI;KAAkB;AACrC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { OpenSearchContext as OpenSearchContextAbstraction } from "./abstraction.js";
|
|
2
|
-
import { OpenSearchContext as OpenSearchContextType } from "../../types.js";
|
|
3
|
-
export declare class OpenSearchContext implements OpenSearchContextAbstraction.Interface {
|
|
4
|
-
private readonly context;
|
|
5
|
-
constructor(context: OpenSearchContextType);
|
|
6
|
-
get opensearch(): OpenSearchContextAbstraction.Client;
|
|
7
|
-
get elasticsearch(): OpenSearchContextAbstraction.Client;
|
|
8
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
class OpenSearchContext {
|
|
2
|
-
constructor(context){
|
|
3
|
-
this.context = context;
|
|
4
|
-
}
|
|
5
|
-
get opensearch() {
|
|
6
|
-
return this.context.opensearch;
|
|
7
|
-
}
|
|
8
|
-
get elasticsearch() {
|
|
9
|
-
return this.context.opensearch;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export { OpenSearchContext };
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=OpenSearchContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features/OpenSearchContext/OpenSearchContext.js","sources":["../../../src/features/OpenSearchContext/OpenSearchContext.ts"],"sourcesContent":["import { OpenSearchContext as OpenSearchContextAbstraction } from \"./abstraction.js\";\nimport { OpenSearchContext as OpenSearchContextType } from \"~/types.js\";\n\nexport class OpenSearchContext implements OpenSearchContextAbstraction.Interface {\n private readonly context;\n\n public constructor(context: OpenSearchContextType) {\n this.context = context;\n }\n\n public get opensearch(): OpenSearchContextAbstraction.Client {\n return this.context.opensearch;\n }\n\n public get elasticsearch(): OpenSearchContextAbstraction.Client {\n return this.context.opensearch;\n }\n}\n"],"names":["OpenSearchContext","context"],"mappings":"AAGO,MAAMA;IAGT,YAAmBC,OAA8B,CAAE;QAC/C,IAAI,CAAC,OAAO,GAAGA;IACnB;IAEA,IAAW,aAAkD;QACzD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU;IAClC;IAEA,IAAW,gBAAqD;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU;IAClC;AACJ"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Client as OpenSearchClient } from "../../types.js";
|
|
2
|
-
export interface IOpenSearchContext {
|
|
3
|
-
opensearch: OpenSearchClient;
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated use `opensearch`property instead.
|
|
6
|
-
* @see IOpenSearchContext.opensearch
|
|
7
|
-
*/
|
|
8
|
-
elasticsearch: OpenSearchClient;
|
|
9
|
-
}
|
|
10
|
-
export declare const OpenSearchContext: import("@webiny/di").Abstraction<IOpenSearchContext>;
|
|
11
|
-
export declare namespace OpenSearchContext {
|
|
12
|
-
type Interface = IOpenSearchContext;
|
|
13
|
-
type Client = OpenSearchClient;
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features/OpenSearchContext/abstraction.js","sources":["../../../src/features/OpenSearchContext/abstraction.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Client as OpenSearchClient } from \"~/types.js\";\n\nexport interface IOpenSearchContext {\n opensearch: OpenSearchClient;\n /**\n * @deprecated use `opensearch`property instead.\n * @see IOpenSearchContext.opensearch\n */\n elasticsearch: OpenSearchClient;\n}\n\nexport const OpenSearchContext = createAbstraction<IOpenSearchContext>(\"OpenSearch/Context\");\n\nexport namespace OpenSearchContext {\n export type Interface = IOpenSearchContext;\n export type Client = OpenSearchClient;\n}\n"],"names":["OpenSearchContext","createAbstraction"],"mappings":";AAYO,MAAMA,oBAAoBC,kBAAsC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createFeature } from "@webiny/feature/api/index.js";
|
|
2
|
-
import { OpenSearchContext } from "./abstraction.js";
|
|
3
|
-
import { OpenSearchContext as external_OpenSearchContext_js_OpenSearchContext } from "./OpenSearchContext.js";
|
|
4
|
-
const OpenSearchContextFeature = createFeature({
|
|
5
|
-
name: "opensearch.internal.context",
|
|
6
|
-
register (container, context) {
|
|
7
|
-
container.registerFactory(OpenSearchContext, ()=>new external_OpenSearchContext_js_OpenSearchContext(context));
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
export { OpenSearchContextFeature };
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features/OpenSearchContext/feature.js","sources":["../../../src/features/OpenSearchContext/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { OpenSearchContext } from \"./abstraction.js\";\nimport { OpenSearchContext as OpenSearchContextType } from \"~/types.js\";\nimport { OpenSearchContext as OpenSearchContextImplementation } from \"./OpenSearchContext.js\";\n\nexport const OpenSearchContextFeature = createFeature<OpenSearchContextType>({\n name: \"opensearch.internal.context\",\n register(container, context) {\n container.registerFactory(OpenSearchContext, () => {\n return new OpenSearchContextImplementation(context!);\n });\n }\n});\n"],"names":["OpenSearchContextFeature","createFeature","container","context","OpenSearchContext","OpenSearchContextImplementation"],"mappings":";;;AAKO,MAAMA,2BAA2BC,cAAqC;IACzE,MAAM;IACN,UAASC,SAAS,EAAEC,OAAO;QACvBD,UAAU,eAAe,CAACE,mBAAmB,IAClC,IAAIC,gDAAgCF;IAEnD;AACJ"}
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/indices.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/operators.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugins/definition/OpenSearchBodyModifierPlugin.js","sources":["../../../src/plugins/definition/OpenSearchBodyModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { SearchBody } from \"~/types.js\";\n\nexport interface ModifyBodyParams {\n body: SearchBody;\n}\n\nexport interface ModifyBodyCallable<T extends ModifyBodyParams> {\n (params: T): void;\n}\n\nexport abstract class OpenSearchBodyModifierPlugin<\n T extends ModifyBodyParams = ModifyBodyParams\n> extends Plugin {\n private readonly callable?: ModifyBodyCallable<T>;\n\n public constructor(callable?: ModifyBodyCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyBody(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the body.`,\n \"BODY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"names":["OpenSearchBodyModifierPlugin","Plugin","callable","params","WebinyError"],"mappings":";;AAYO,MAAeA,qCAEZC;IAGN,YAAmBC,QAAgC,CAAE;QACjD,KAAK;QACL,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEO,WAAWC,MAAS,EAAQ;QAC/B,IAAI,AAAyB,cAAzB,OAAO,IAAI,CAAC,QAAQ,EACpB,MAAM,IAAIC,MACN,sCACA,6BACA;YACID;QACJ;QAGR,IAAI,CAAC,QAAQ,CAACA;IAClB;AACJ"}
|
|
@@ -1,81 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugins/definition/OpenSearchFieldPlugin.js","sources":["../../../src/plugins/definition/OpenSearchFieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { FieldSortOptions, SortOrder } from \"~/types.js\";\n\nexport type UnmappedTypes = \"date\" | \"long\" | string;\n\nconst keywordLessUnmappedType = [\"date\", \"long\"];\n\nconst unmappedTypeHasKeyword = (type?: string): boolean => {\n if (!type) {\n return true;\n } else if (keywordLessUnmappedType.includes(type)) {\n return false;\n }\n return true;\n};\n\nexport interface ToSearchValueParams {\n /**\n * The value to transform.\n */\n value: any;\n /**\n * When using toSearchValue() in our code we send a field.getPath() value here.\n */\n path: string;\n /**\n * When using toSearchValue() in our code we send a field.getBasePath() value here.\n */\n basePath: string;\n}\nexport interface OpenSearchFieldPluginParams {\n /**\n * Which field is this plugin for.\n */\n field: string;\n /**\n * Some specific path of a field?\n * Example: createdBy is createdBy.id\n */\n path?: string;\n /**\n * Add a .keyword at the end of the field path?\n */\n keyword?: boolean;\n /**\n * Is the field of a specific type, but possibly not mapped?\n * Happens when inserting a date in string format.\n * You need to cast it as date when running the search/sort to work correctly.\n */\n unmappedType?: UnmappedTypes;\n /**\n * Is the field sortable?\n */\n sortable?: boolean;\n /**\n * Is the field searchable?\n */\n searchable?: boolean;\n /**\n * Used to transform the input value for the search.\n */\n toSearchValue?: (params: ToSearchValueParams) => any;\n}\n\nexport class OpenSearchFieldPlugin extends Plugin {\n public static override readonly type: string = \"opensearch.fieldDefinition\";\n public static readonly ALL: string = \"*\";\n\n public readonly field: string;\n public readonly path: string;\n public readonly keyword: boolean;\n public readonly unmappedType?: string;\n public readonly sortable: boolean;\n public readonly searchable: boolean;\n\n constructor(params: OpenSearchFieldPluginParams) {\n super();\n this.field = params.field;\n this.path = params.path || params.field;\n this.keyword = params.keyword === undefined ? true : params.keyword;\n this.unmappedType = params.unmappedType;\n if (unmappedTypeHasKeyword(params.unmappedType) === false) {\n this.keyword = false;\n }\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this.searchable = params.searchable === undefined ? true : params.searchable;\n }\n /**\n * The default sort options. Extend in your own plugin if you want to add more options.\n */\n public getSortOptions(order: SortOrder): FieldSortOptions {\n const options = {\n order\n };\n if (!this.unmappedType) {\n return options;\n }\n return {\n ...options,\n // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.\n unmapped_type: this.unmappedType as any\n };\n }\n /**\n * The default path generator. Extend in your own plugin if you want to add more options.\n * Field parameter is here because there is a possibility that this is the ALL field plugin, so we need to know which field are we working on.\n */\n public getPath(field: string): string {\n return `${this.getBasePath(field)}${this.keyword ? \".keyword\" : \"\"}`;\n }\n /**\n * @see getPath\n *\n * This is the default base path generator. Basically it replaces ALL with given field name.\n */\n public getBasePath(field: string): string {\n if (this.path === OpenSearchFieldPlugin.ALL) {\n return field;\n }\n return this.path;\n }\n /**\n * The default transformer. Just returns the value by default.\n * Override to implement what ever is required.\n */\n public toSearchValue(params: ToSearchValueParams): any {\n return params.value;\n }\n}\n"],"names":["keywordLessUnmappedType","unmappedTypeHasKeyword","type","OpenSearchFieldPlugin","Plugin","params","undefined","order","options","field"],"mappings":";AAKA,MAAMA,0BAA0B;IAAC;IAAQ;CAAO;AAEhD,MAAMC,yBAAyB,CAACC;IAC5B,IAAKA,MAEE;QAAA,IAAIF,wBAAwB,QAAQ,CAACE,OACxC,OAAO;IACX;IACA,OAAO;AACX;AAkDO,MAAMC,8BAA8BC;;aACP,IAAI,GAAW;;;aACxB,GAAG,GAAW;;IASrC,YAAYC,MAAmC,CAAE;QAC7C,KAAK;QACL,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI,IAAIA,OAAO,KAAK;QACvC,IAAI,CAAC,OAAO,GAAGA,AAAmBC,WAAnBD,OAAO,OAAO,GAAiB,OAAOA,OAAO,OAAO;QACnE,IAAI,CAAC,YAAY,GAAGA,OAAO,YAAY;QACvC,IAAIJ,AAAgD,UAAhDA,uBAAuBI,OAAO,YAAY,GAC1C,IAAI,CAAC,OAAO,GAAG;QAEnB,IAAI,CAAC,QAAQ,GAAGA,AAAoBC,WAApBD,OAAO,QAAQ,GAAiB,OAAOA,OAAO,QAAQ;QACtE,IAAI,CAAC,UAAU,GAAGA,AAAsBC,WAAtBD,OAAO,UAAU,GAAiB,OAAOA,OAAO,UAAU;IAChF;IAIO,eAAeE,KAAgB,EAAoB;QACtD,MAAMC,UAAU;YACZD;QACJ;QACA,IAAI,CAAC,IAAI,CAAC,YAAY,EAClB,OAAOC;QAEX,OAAO;YACH,GAAGA,OAAO;YAEV,eAAe,IAAI,CAAC,YAAY;QACpC;IACJ;IAKO,QAAQC,KAAa,EAAU;QAClC,OAAO,GAAG,IAAI,CAAC,WAAW,CAACA,SAAS,IAAI,CAAC,OAAO,GAAG,aAAa,IAAI;IACxE;IAMO,YAAYA,KAAa,EAAU;QACtC,IAAI,IAAI,CAAC,IAAI,KAAKN,sBAAsB,GAAG,EACvC,OAAOM;QAEX,OAAO,IAAI,CAAC,IAAI;IACpB;IAKO,cAAcJ,MAA2B,EAAO;QACnD,OAAOA,OAAO,KAAK;IACvB;AACJ"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { OpenSearchIndexRequestBody } from "../../types.js";
|
|
3
|
-
export interface OpenSearchIndexPluginParams {
|
|
4
|
-
body: OpenSearchIndexRequestBody;
|
|
5
|
-
}
|
|
6
|
-
export declare abstract class OpenSearchIndexPlugin extends Plugin {
|
|
7
|
-
readonly body: OpenSearchIndexRequestBody;
|
|
8
|
-
constructor(params: OpenSearchIndexPluginParams);
|
|
9
|
-
canUse(): boolean;
|
|
10
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
class OpenSearchIndexPlugin extends Plugin {
|
|
3
|
-
constructor(params){
|
|
4
|
-
super();
|
|
5
|
-
const { body } = params;
|
|
6
|
-
this.body = {
|
|
7
|
-
...body
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
canUse() {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export { OpenSearchIndexPlugin };
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=OpenSearchIndexPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugins/definition/OpenSearchIndexPlugin.js","sources":["../../../src/plugins/definition/OpenSearchIndexPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { OpenSearchIndexRequestBody } from \"~/types.js\";\n\nexport interface OpenSearchIndexPluginParams {\n body: OpenSearchIndexRequestBody;\n}\n\nexport abstract class OpenSearchIndexPlugin extends Plugin {\n public readonly body: OpenSearchIndexRequestBody;\n\n public constructor(params: OpenSearchIndexPluginParams) {\n super();\n const { body } = params;\n this.body = {\n ...body\n };\n }\n\n public canUse(): boolean {\n return true;\n }\n}\n"],"names":["OpenSearchIndexPlugin","Plugin","params","body"],"mappings":";AAOO,MAAeA,8BAA8BC;IAGhD,YAAmBC,MAAmC,CAAE;QACpD,KAAK;QACL,MAAM,EAAEC,IAAI,EAAE,GAAGD;QACjB,IAAI,CAAC,IAAI,GAAG;YACR,GAAGC,IAAI;QACX;IACJ;IAEO,SAAkB;QACrB,OAAO;IACX;AACJ"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from "../../types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class OpenSearchQueryBuilderOperatorPlugin extends Plugin {
|
|
7
|
-
static readonly type: string;
|
|
8
|
-
abstract getOperator(): string;
|
|
9
|
-
abstract apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void;
|
|
10
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
class OpenSearchQueryBuilderOperatorPlugin extends Plugin {
|
|
3
|
-
static{
|
|
4
|
-
this.type = "opensearch.queryBuilder.operator";
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export { OpenSearchQueryBuilderOperatorPlugin };
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=OpenSearchQueryBuilderOperatorPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js","sources":["../../../src/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\n/**\n * Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.\n */\nexport abstract class OpenSearchQueryBuilderOperatorPlugin extends Plugin {\n public static override readonly type: string = \"opensearch.queryBuilder.operator\";\n\n public abstract getOperator(): string;\n\n public abstract apply(\n query: OpenSearchBoolQueryConfig,\n params: OpenSearchQueryBuilderArgsPlugin\n ): void;\n}\n"],"names":["OpenSearchQueryBuilderOperatorPlugin","Plugin"],"mappings":";AAMO,MAAeA,6CAA6CC;;aAC/B,IAAI,GAAW;;AAQnD"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { OpenSearchBoolQueryConfig } from "../../types.js";
|
|
3
|
-
export interface ModifyQueryParams {
|
|
4
|
-
query: OpenSearchBoolQueryConfig;
|
|
5
|
-
where: Record<string, any>;
|
|
6
|
-
}
|
|
7
|
-
export interface ModifyQueryCallable<T extends ModifyQueryParams> {
|
|
8
|
-
(params: T): void;
|
|
9
|
-
}
|
|
10
|
-
export declare abstract class OpenSearchQueryModifierPlugin<T extends ModifyQueryParams = ModifyQueryParams> extends Plugin {
|
|
11
|
-
private readonly callable?;
|
|
12
|
-
constructor(callable?: ModifyQueryCallable<T>);
|
|
13
|
-
modifyQuery(params: T): void;
|
|
14
|
-
}
|