@webiny/api-headless-cms-ddb-es 6.0.0 → 6.1.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/configurations.d.ts +2 -2
- package/configurations.js +2 -2
- package/configurations.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.d.ts +1 -1
- package/elasticsearch/createElasticsearchIndex.js +1 -1
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.d.ts +1 -1
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js +0 -6
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
- package/elasticsearch/indices/base.js +1 -1
- package/elasticsearch/indices/base.js.map +1 -1
- package/index.js +6 -6
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +2 -5
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.js +5 -2
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +5 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +5 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.js +5 -1
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +1 -0
- package/operations/entry/dataLoader/types.js.map +1 -1
- package/operations/entry/dataLoaders.js +3 -1
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.d.ts +1 -1
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +3 -3
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.d.ts +2 -2
- package/operations/entry/elasticsearch/filtering/exec.js +1 -1
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/path.d.ts +2 -2
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -2
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/fullTextSearch.js +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.d.ts +3 -3
- package/operations/entry/elasticsearch/initialQuery.js +1 -1
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/operator.js +2 -2
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/search.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
- package/operations/entry/elasticsearch/sort.d.ts +2 -2
- package/operations/entry/elasticsearch/sort.js +4 -4
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +4 -4
- package/operations/entry/elasticsearch/types.js.map +1 -1
- package/operations/entry/index.d.ts +2 -2
- package/operations/entry/index.js +1 -1
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/transformations/index.js +1 -1
- package/operations/entry/transformations/index.js.map +1 -1
- package/operations/model/index.d.ts +1 -1
- package/operations/model/index.js.map +1 -1
- package/package.json +22 -23
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +2 -2
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +2 -2
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
- package/plugins/CmsEntryFilterPlugin.js.map +1 -1
- package/types.d.ts +2 -2
- package/types.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["assignMinimumShouldMatchToQuery","query","value","Array","isArray","should","length","minimum_should_match"],"sources":["assignMinimumShouldMatchToQuery.ts"],"sourcesContent":["import type { BoolQueryConfig } from \"@webiny/api-
|
|
1
|
+
{"version":3,"names":["assignMinimumShouldMatchToQuery","query","value","Array","isArray","should","length","minimum_should_match"],"sources":["assignMinimumShouldMatchToQuery.ts"],"sourcesContent":["import type { QueryDslBoolQuery as BoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\n\n/**\n * This function will assign a minimum_should_match for the query if conditions are met:\n * * should is an array\n * * it is not empty\n * * minimum_should_match is not already set\n *\n *\n * By the default we set it to 1 as we want at least one OR condition to produce results.\n *\n * Users can modify minimum_should_match value via the body or query modification plugins.\n */\ninterface Params {\n query: BoolQueryConfig;\n value?: number;\n}\nexport const assignMinimumShouldMatchToQuery = ({ query, value = 1 }: Params): void => {\n if (!Array.isArray(query.should)) {\n return;\n } else if (query.should.length === 0) {\n return;\n } else if (query.minimum_should_match) {\n return;\n }\n query.minimum_should_match = value > 0 ? value : 1;\n};\n"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,MAAMA,+BAA+B,GAAGA,CAAC;EAAEC,KAAK;EAAEC,KAAK,GAAG;AAAU,CAAC,KAAW;EACnF,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,KAAK,CAACI,MAAM,CAAC,EAAE;IAC9B;EACJ,CAAC,MAAM,IAAIJ,KAAK,CAACI,MAAM,CAACC,MAAM,KAAK,CAAC,EAAE;IAClC;EACJ,CAAC,MAAM,IAAIL,KAAK,CAACM,oBAAoB,EAAE;IACnC;EACJ;EACAN,KAAK,CAACM,oBAAoB,GAAGL,KAAK,GAAG,CAAC,GAAGA,KAAK,GAAG,CAAC;AACtD,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
2
2
|
import type { CmsEntryListParams, CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
-
import type { PrimitiveValue, SearchBody } from "@webiny/api-
|
|
3
|
+
import type { PrimitiveValue, SearchBody } from "@webiny/api-opensearch/types.js";
|
|
4
4
|
interface Params {
|
|
5
5
|
plugins: PluginsContainer;
|
|
6
6
|
model: CmsModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createModelFields","createFullTextSearchFields","createInitialQuery","applyFullTextSearch","createQueryModifierPluginList","createSortModifierPluginList","createBodyModifierPluginList","createElasticsearchSort","createExecFiltering","assignMinimumShouldMatchToQuery","createElasticsearchBody","plugins","model","params","fields","search","term","where","sort","initialSort","after","limit","modelFields","queryModifierPlugins","sortModifierPlugins","bodyModifierPlugins","fullTextSearchFields","targets","query","execFiltering","pl","modifyQuery","modifySort","boolQuery","must","length","undefined","must_not","should","filter","body","bool","size","search_after","track_total_hits","modifyBody"],"sources":["body.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n CmsEntryListParams,\n CmsEntryListWhere,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { createModelFields } from \"./fields.js\";\nimport { createFullTextSearchFields } from \"./fullTextSearchFields.js\";\nimport { createInitialQuery } from \"./initialQuery.js\";\nimport { applyFullTextSearch } from \"./fullTextSearch.js\";\nimport { createQueryModifierPluginList } from \"./plugins/queryModifier.js\";\nimport { createSortModifierPluginList } from \"./plugins/sortModifier.js\";\nimport { createBodyModifierPluginList } from \"./plugins/bodyModifier.js\";\nimport { createElasticsearchSort } from \"./sort.js\";\nimport type {\n BoolQueryConfig,\n PrimitiveValue,\n SearchBody\n} from \"@webiny/api-
|
|
1
|
+
{"version":3,"names":["createModelFields","createFullTextSearchFields","createInitialQuery","applyFullTextSearch","createQueryModifierPluginList","createSortModifierPluginList","createBodyModifierPluginList","createElasticsearchSort","createExecFiltering","assignMinimumShouldMatchToQuery","createElasticsearchBody","plugins","model","params","fields","search","term","where","sort","initialSort","after","limit","modelFields","queryModifierPlugins","sortModifierPlugins","bodyModifierPlugins","fullTextSearchFields","targets","query","execFiltering","pl","modifyQuery","modifySort","boolQuery","must","length","undefined","must_not","should","filter","body","bool","size","search_after","track_total_hits","modifyBody"],"sources":["body.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n CmsEntryListParams,\n CmsEntryListWhere,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { createModelFields } from \"./fields.js\";\nimport { createFullTextSearchFields } from \"./fullTextSearchFields.js\";\nimport { createInitialQuery } from \"./initialQuery.js\";\nimport { applyFullTextSearch } from \"./fullTextSearch.js\";\nimport { createQueryModifierPluginList } from \"./plugins/queryModifier.js\";\nimport { createSortModifierPluginList } from \"./plugins/sortModifier.js\";\nimport { createBodyModifierPluginList } from \"./plugins/bodyModifier.js\";\nimport { createElasticsearchSort } from \"./sort.js\";\nimport type {\n QueryDslBoolQuery as BoolQueryConfig,\n PrimitiveValue,\n SearchBody\n} from \"@webiny/api-opensearch/types.js\";\nimport { createExecFiltering } from \"./filtering/index.js\";\nimport { assignMinimumShouldMatchToQuery } from \"./assignMinimumShouldMatchToQuery.js\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n params: Omit<CmsEntryListParams, \"where\" | \"after\"> & {\n where: CmsEntryListWhere;\n after?: PrimitiveValue[];\n };\n}\nexport const createElasticsearchBody = ({ plugins, model, params }: Params): SearchBody => {\n const { fields, search: term, where, sort: initialSort, after, limit } = params;\n /**\n * We need the model fields constructed as a key -> field value, so we do not need to iterate through array when we require some field.\n */\n const modelFields = createModelFields({\n plugins,\n model\n });\n\n /**\n * We need the query modifier plugins.\n */\n const queryModifierPlugins = createQueryModifierPluginList({\n plugins,\n model\n });\n /**\n * We need the sort modifier plugins.\n */\n const sortModifierPlugins = createSortModifierPluginList({\n plugins,\n model\n });\n /**\n * We need the body modifier plugins.\n */\n const bodyModifierPlugins = createBodyModifierPluginList({\n plugins,\n model\n });\n /**\n * We need the fields which we can search through via the full text search.\n *\n */\n const fullTextSearchFields = createFullTextSearchFields({\n fields: modelFields,\n term,\n targets: fields\n });\n /**\n * The initial elasticsearch query where we attach some default conditions we always need.\n */\n const query = createInitialQuery({\n where,\n model\n });\n /**\n * Apply the full text search, if term is set.\n */\n applyFullTextSearch({\n model,\n plugins,\n query,\n term,\n fields: fullTextSearchFields\n });\n\n const execFiltering = createExecFiltering({\n model,\n fields: modelFields,\n plugins\n });\n\n execFiltering({\n where,\n query\n });\n\n for (const pl of queryModifierPlugins) {\n pl.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSort({\n plugins,\n sort: initialSort,\n modelFields,\n model\n });\n\n for (const pl of sortModifierPlugins) {\n pl.modifySort({\n sort,\n model\n });\n }\n\n const boolQuery: BoolQueryConfig = {\n must: query.must.length > 0 ? query.must : undefined,\n must_not: query.must_not.length > 0 ? query.must_not : undefined,\n should: query.should.length > 0 ? query.should : undefined,\n filter: query.filter.length > 0 ? query.filter : undefined\n };\n\n assignMinimumShouldMatchToQuery({\n query: boolQuery\n });\n\n const body: SearchBody = {\n query: {\n bool: boolQuery\n },\n sort,\n size: (limit || 0) + 1,\n search_after: after,\n track_total_hits: true\n };\n\n for (const pl of bodyModifierPlugins) {\n pl.modifyBody({\n body,\n model,\n where\n });\n }\n\n return body;\n};\n"],"mappings":"AAMA,SAASA,iBAAiB;AAC1B,SAASC,0BAA0B;AACnC,SAASC,kBAAkB;AAC3B,SAASC,mBAAmB;AAC5B,SAASC,6BAA6B;AACtC,SAASC,4BAA4B;AACrC,SAASC,4BAA4B;AACrC,SAASC,uBAAuB;AAMhC,SAASC,mBAAmB;AAC5B,SAASC,+BAA+B;AAUxC,OAAO,MAAMC,uBAAuB,GAAGA,CAAC;EAAEC,OAAO;EAAEC,KAAK;EAAEC;AAAe,CAAC,KAAiB;EACvF,MAAM;IAAEC,MAAM;IAAEC,MAAM,EAAEC,IAAI;IAAEC,KAAK;IAAEC,IAAI,EAAEC,WAAW;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGR,MAAM;EAC/E;AACJ;AACA;EACI,MAAMS,WAAW,GAAGtB,iBAAiB,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N;EAEA,MAAMqB,SAA0B,GAAG;IAC/BC,IAAI,EAAEN,KAAK,CAACM,IAAI,CAACC,MAAM,GAAG,CAAC,GAAGP,KAAK,CAACM,IAAI,GAAGE,SAAS;IACpDC,QAAQ,EAAET,KAAK,CAACS,QAAQ,CAACF,MAAM,GAAG,CAAC,GAAGP,KAAK,CAACS,QAAQ,GAAGD,SAAS;IAChEE,MAAM,EAAEV,KAAK,CAACU,MAAM,CAACH,MAAM,GAAG,CAAC,GAAGP,KAAK,CAACU,MAAM,GAAGF,SAAS;IAC1DG,MAAM,EAAEX,KAAK,CAACW,MAAM,CAACJ,MAAM,GAAG,CAAC,GAAGP,KAAK,CAACW,MAAM,GAAGH;EACrD,CAAC;EAED3B,+BAA+B,CAAC;IAC5BmB,KAAK,EAAEK;EACX,CAAC,CAAC;EAEF,MAAMO,IAAgB,GAAG;IACrBZ,KAAK,EAAE;MACHa,IAAI,EAAER;IACV,CAAC;IACDf,IAAI;IACJwB,IAAI,EAAE,CAACrB,KAAK,IAAI,CAAC,IAAI,CAAC;IACtBsB,YAAY,EAAEvB,KAAK;IACnBwB,gBAAgB,EAAE;EACtB,CAAC;EAED,KAAK,MAAMd,EAAE,IAAIL,mBAAmB,EAAE;IAClCK,EAAE,CAACe,UAAU,CAAC;MACVL,IAAI;MACJ5B,KAAK;MACLK;IACJ,CAAC,CAAC;EACN;EAEA,OAAOuB,IAAI;AACf,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OpenSearchQueryBuilderOperatorPlugins, OpenSearchQuerySearchValuePlugins } from "../../../../operations/entry/elasticsearch/types.js";
|
|
2
2
|
import type { ApplyFilteringCb } from "../../../../plugins/CmsEntryFilterPlugin.js";
|
|
3
3
|
interface CreateParams {
|
|
4
|
-
operatorPlugins:
|
|
5
|
-
searchPlugins:
|
|
4
|
+
operatorPlugins: OpenSearchQueryBuilderOperatorPlugins;
|
|
5
|
+
searchPlugins: OpenSearchQuerySearchValuePlugins;
|
|
6
6
|
}
|
|
7
7
|
export declare const createApplyFiltering: ({ operatorPlugins, searchPlugins }: CreateParams) => ApplyFilteringCb;
|
|
8
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","transformValueForSearch","hasKeyword","createFieldPathFactory","createApplyFiltering","operatorPlugins","searchPlugins","createFieldPath","plugins","params","key","value","initialValue","query","operator","field","plugin","keyword","basePath","path","originalValue","apply","name","fieldId"],"sources":["applyFiltering.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"~/operations/entry/elasticsearch/transformValueForSearch.js\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword.js\";\nimport type {\n
|
|
1
|
+
{"version":3,"names":["WebinyError","transformValueForSearch","hasKeyword","createFieldPathFactory","createApplyFiltering","operatorPlugins","searchPlugins","createFieldPath","plugins","params","key","value","initialValue","query","operator","field","plugin","keyword","basePath","path","originalValue","apply","name","fieldId"],"sources":["applyFiltering.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"~/operations/entry/elasticsearch/transformValueForSearch.js\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword.js\";\nimport type {\n OpenSearchQueryBuilderOperatorPlugins,\n OpenSearchQuerySearchValuePlugins\n} from \"~/operations/entry/elasticsearch/types.js\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path.js\";\nimport type { ApplyFilteringCb } from \"~/plugins/CmsEntryFilterPlugin.js\";\n\ninterface CreateParams {\n operatorPlugins: OpenSearchQueryBuilderOperatorPlugins;\n searchPlugins: OpenSearchQuerySearchValuePlugins;\n}\n\nexport const createApplyFiltering = ({\n operatorPlugins,\n searchPlugins\n}: CreateParams): ApplyFilteringCb => {\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n return params => {\n const { key, value: initialValue, query, operator, field } = params;\n\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\n `Elasticsearch operator \"${operator}\" plugin missing.`,\n \"PLUGIN_MISSING\",\n {\n operator\n }\n );\n }\n\n const value = transformValueForSearch({\n plugins: searchPlugins,\n field: field.field,\n value: initialValue\n });\n\n const keyword = hasKeyword(field);\n\n const { basePath, path } = createFieldPath({\n field,\n value,\n originalValue: initialValue,\n key,\n keyword\n });\n\n plugin.apply(query, {\n name: field.field.fieldId,\n basePath,\n path,\n value,\n keyword\n });\n };\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,uBAAuB;AAChC,SAASC,UAAU;AAKnB,SAASC,sBAAsB;AAQ/B,OAAO,MAAMC,oBAAoB,GAAGA,CAAC;EACjCC,eAAe;EACfC;AACU,CAAC,KAAuB;EAClC,MAAMC,eAAe,GAAGJ,sBAAsB,CAAC;IAC3CK,OAAO,EAAEF;EACb,CAAC,CAAC;EAEF,OAAOG,MAAM,IAAI;IACb,MAAM;MAAEC,GAAG;MAAEC,KAAK,EAAEC,YAAY;MAAEC,KAAK;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGN,MAAM;IAEnE,MAAMO,MAAM,GAAGX,eAAe,CAACS,QAAQ,CAAC;IACxC,IAAI,CAACE,MAAM,EAAE;MACT,MAAM,IAAIhB,WAAW,CACjB,2BAA2Bc,QAAQ,mBAAmB,EACtD,gBAAgB,EAChB;QACIA;MACJ,CACJ,CAAC;IACL;IAEA,MAAMH,KAAK,GAAGV,uBAAuB,CAAC;MAClCO,OAAO,EAAEF,aAAa;MACtBS,KAAK,EAAEA,KAAK,CAACA,KAAK;MAClBJ,KAAK,EAAEC;IACX,CAAC,CAAC;IAEF,MAAMK,OAAO,GAAGf,UAAU,CAACa,KAAK,CAAC;IAEjC,MAAM;MAAEG,QAAQ;MAAEC;IAAK,CAAC,GAAGZ,eAAe,CAAC;MACvCQ,KAAK;MACLJ,KAAK;MACLS,aAAa,EAAER,YAAY;MAC3BF,GAAG;MACHO;IACJ,CAAC,CAAC;IAEFD,MAAM,CAACK,KAAK,CAACR,KAAK,EAAE;MAChBS,IAAI,EAAEP,KAAK,CAACA,KAAK,CAACQ,OAAO;MACzBL,QAAQ;MACRC,IAAI;MACJR,KAAK;MACLM;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
2
|
import type { ModelFields } from "../../../../operations/entry/elasticsearch/types.js";
|
|
3
3
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
import type {
|
|
4
|
+
import type { OpenSearchBoolQueryConfig } from "@webiny/api-opensearch/types.js";
|
|
5
5
|
export interface CreateExecParams {
|
|
6
6
|
model: CmsModel;
|
|
7
7
|
fields: ModelFields;
|
|
@@ -9,7 +9,7 @@ export interface CreateExecParams {
|
|
|
9
9
|
}
|
|
10
10
|
export interface IExecParams {
|
|
11
11
|
where: CmsEntryListWhere;
|
|
12
|
-
query:
|
|
12
|
+
query: OpenSearchBoolQueryConfig;
|
|
13
13
|
isValues?: boolean;
|
|
14
14
|
}
|
|
15
15
|
export interface CreateExecFilteringResponse {
|
|
@@ -2,7 +2,7 @@ import WebinyError from "@webiny/error";
|
|
|
2
2
|
import { createSearchPluginList } from "../plugins/search.js";
|
|
3
3
|
import { createOperatorPluginList } from "../plugins/operator.js";
|
|
4
4
|
import { createBaseQuery } from "../initialQuery.js";
|
|
5
|
-
import { parseWhereKey } from "@webiny/api-
|
|
5
|
+
import { parseWhereKey } from "@webiny/api-opensearch";
|
|
6
6
|
import { getWhereValues } from "./values.js";
|
|
7
7
|
import { getPopulated } from "./populated.js";
|
|
8
8
|
import { createApplyFiltering } from "./applyFiltering.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","createSearchPluginList","createOperatorPluginList","createBaseQuery","parseWhereKey","getWhereValues","getPopulated","createApplyFiltering","CmsEntryFilterPlugin","assignMinimumShouldMatchToQuery","getBaseFieldType","createExecFiltering","params","fields","plugins","model","searchPlugins","operatorPlugins","applyFiltering","filteringPlugins","byType","type","reduce","collection","plugin","fieldType","getFilterPlugin","execFiltering","where","initialWhere","query","isValues","keys","Object","length","structuredClone","key","value","undefined","childWhereList","childQuery","childWhere","childQueryBool","filter","push","bool","should","field","whereFieldId","operator","fieldId","cmsModelField","find","f","filterPlugin","exec"],"sources":["exec.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { ModelFields } from \"~/operations/entry/elasticsearch/types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { ElasticsearchBoolQueryConfig, Query } from \"@webiny/api-elasticsearch/types.js\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search.js\";\nimport { createOperatorPluginList } from \"~/operations/entry/elasticsearch/plugins/operator.js\";\nimport { createBaseQuery } from \"~/operations/entry/elasticsearch/initialQuery.js\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport { getWhereValues } from \"./values.js\";\nimport { getPopulated } from \"./populated.js\";\nimport { createApplyFiltering } from \"./applyFiltering.js\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin.js\";\nimport { assignMinimumShouldMatchToQuery } from \"~/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nexport interface CreateExecParams {\n model: CmsModel;\n fields: ModelFields;\n plugins: PluginsContainer;\n}\nexport interface IExecParams {\n where: CmsEntryListWhere;\n query: ElasticsearchBoolQueryConfig;\n isValues?: boolean;\n}\nexport interface CreateExecFilteringResponse {\n (params: IExecParams): void;\n}\nexport const createExecFiltering = (params: CreateExecParams): CreateExecFilteringResponse => {\n const { fields, plugins, model } = params;\n\n /**\n * We need the search plugins as key -> plugin value, so it is easy to find plugin we need, without iterating through array.\n */\n const searchPlugins = createSearchPluginList({\n plugins\n });\n /**\n * We need the operator plugins, which we execute on our where conditions.\n */\n const operatorPlugins = createOperatorPluginList({\n plugins\n });\n\n const applyFiltering = createApplyFiltering({\n operatorPlugins,\n searchPlugins\n });\n\n const filteringPlugins = plugins\n .byType<CmsEntryFilterPlugin>(CmsEntryFilterPlugin.type)\n .reduce<Record<string, CmsEntryFilterPlugin>>((collection, plugin) => {\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {});\n\n const getFilterPlugin = (type: string) => {\n const fieldType = getBaseFieldType({\n type\n });\n\n const plugin = filteringPlugins[fieldType] || filteringPlugins[\"*\"];\n if (plugin) {\n return plugin;\n }\n throw new WebinyError(\n `There is no filtering plugin for the given field type \"${fieldType}\".`,\n \"FILTERING_PLUGIN_ERROR\",\n {\n fieldType\n }\n );\n };\n\n const execFiltering = (params: IExecParams) => {\n const { where: initialWhere, query, isValues = false } = params;\n /**\n * No point in continuing if no \"where\" conditions exist.\n */\n const keys = Object.keys(initialWhere);\n if (keys.length === 0) {\n return;\n }\n const where = structuredClone(initialWhere);\n\n for (const key in where) {\n const value = where[key as keyof typeof where];\n /**\n * We always skip if no value is defined.\n * Only skip undefined value, null is valid.\n */\n if (value === undefined) {\n continue;\n }\n //\n /**\n * When we are running with AND, the \"value\" MUST be an array.\n */\n else if (key === \"AND\") {\n const childWhereList = getWhereValues(value, \"AND\");\n\n const childQuery = createBaseQuery();\n\n for (const childWhere of childWhereList) {\n execFiltering({\n query: childQuery,\n where: childWhere,\n isValues\n });\n }\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n query.filter.push({\n bool: childQueryBool\n });\n\n continue;\n }\n //\n /**\n * When we are running with OR, the \"value\" must be an array.\n */\n else if (key === \"OR\") {\n const childWhereList = getWhereValues(value, \"OR\");\n /**\n * Each of the conditions MUST produce it's own should section.\n */\n const should: Query[] = [];\n for (const childWhere of childWhereList) {\n const childQuery = createBaseQuery();\n execFiltering({\n query: childQuery,\n where: childWhere,\n isValues\n });\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n should.push({\n bool: childQueryBool\n });\n }\n if (should.length === 0) {\n continue;\n }\n query.should.push(...should);\n /**\n * If there are any should, minimum to have is 1.\n * Of course, do not override if it's already set.\n */\n assignMinimumShouldMatchToQuery({\n query\n });\n continue;\n } else if (key === \"values\") {\n execFiltering({\n query,\n where: where[key] as CmsEntryListWhere,\n isValues: true\n });\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n let fieldId: string = isValues ? `values.${whereFieldId}` : whereFieldId;\n\n /**\n * TODO This will be required until the storage operations receive the fieldId instead of field storageId.\n * TODO For this to work without field searching, we need to refactor how the query looks like.\n *\n * Storage operations should NEVER receive an field storageId, only alias - fieldId.\n */\n const cmsModelField = model.fields.find(f => f.fieldId === fieldId);\n if (!cmsModelField && !fields[fieldId]) {\n throw new WebinyError(`There is no CMS Model Field \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const field = fields[fieldId];\n if (!field) {\n throw new WebinyError(`There is no field \"${fieldId}\".`, \"EXEC_FILTERING_ERROR\");\n }\n const filterPlugin = getFilterPlugin(field.type);\n\n filterPlugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n };\n\n return execFiltering;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAKvC,SAASC,sBAAsB;AAC/B,SAASC,wBAAwB;AACjC,SAASC,eAAe;AACxB,SAASC,aAAa,QAAQ,2BAA2B;AACzD,SAASC,cAAc;AACvB,SAASC,YAAY;AACrB,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,+BAA+B;AACxC,SAASC,gBAAgB,QAAQ,oDAAoD;AAerF,OAAO,MAAMC,m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B,KAAK,CAAC1B,IAAI,CAAC;MAEhDiC,YAAY,CAACC,IAAI,CAAC;QACdrC,cAAc;QACdQ,eAAe;QACfU,GAAG;QACHC,KAAK;QACLY,QAAQ;QACRF,KAAK;QACLlC,MAAM;QACNiB;MACJ,CAAC,CAAC;IACN;EACJ,CAAC;EAED,OAAOH,aAAa;AACxB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["WebinyError","createSearchPluginList","createOperatorPluginList","createBaseQuery","parseWhereKey","getWhereValues","getPopulated","createApplyFiltering","CmsEntryFilterPlugin","assignMinimumShouldMatchToQuery","getBaseFieldType","createExecFiltering","params","fields","plugins","model","searchPlugins","operatorPlugins","applyFiltering","filteringPlugins","byType","type","reduce","collection","plugin","fieldType","getFilterPlugin","execFiltering","where","initialWhere","query","isValues","keys","Object","length","structuredClone","key","value","undefined","childWhereList","childQuery","childWhere","childQueryBool","filter","push","bool","should","field","whereFieldId","operator","fieldId","cmsModelField","find","f","filterPlugin","exec"],"sources":["exec.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { ModelFields } from \"~/operations/entry/elasticsearch/types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n OpenSearchBoolQueryConfig,\n QueryDslQueryContainer as Query\n} from \"@webiny/api-opensearch/types.js\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search.js\";\nimport { createOperatorPluginList } from \"~/operations/entry/elasticsearch/plugins/operator.js\";\nimport { createBaseQuery } from \"~/operations/entry/elasticsearch/initialQuery.js\";\nimport { parseWhereKey } from \"@webiny/api-opensearch\";\nimport { getWhereValues } from \"./values.js\";\nimport { getPopulated } from \"./populated.js\";\nimport { createApplyFiltering } from \"./applyFiltering.js\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin.js\";\nimport { assignMinimumShouldMatchToQuery } from \"~/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nexport interface CreateExecParams {\n model: CmsModel;\n fields: ModelFields;\n plugins: PluginsContainer;\n}\nexport interface IExecParams {\n where: CmsEntryListWhere;\n query: OpenSearchBoolQueryConfig;\n isValues?: boolean;\n}\nexport interface CreateExecFilteringResponse {\n (params: IExecParams): void;\n}\nexport const createExecFiltering = (params: CreateExecParams): CreateExecFilteringResponse => {\n const { fields, plugins, model } = params;\n\n /**\n * We need the search plugins as key -> plugin value, so it is easy to find plugin we need, without iterating through array.\n */\n const searchPlugins = createSearchPluginList({\n plugins\n });\n /**\n * We need the operator plugins, which we execute on our where conditions.\n */\n const operatorPlugins = createOperatorPluginList({\n plugins\n });\n\n const applyFiltering = createApplyFiltering({\n operatorPlugins,\n searchPlugins\n });\n\n const filteringPlugins = plugins\n .byType<CmsEntryFilterPlugin>(CmsEntryFilterPlugin.type)\n .reduce<Record<string, CmsEntryFilterPlugin>>((collection, plugin) => {\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {});\n\n const getFilterPlugin = (type: string) => {\n const fieldType = getBaseFieldType({\n type\n });\n\n const plugin = filteringPlugins[fieldType] || filteringPlugins[\"*\"];\n if (plugin) {\n return plugin;\n }\n throw new WebinyError(\n `There is no filtering plugin for the given field type \"${fieldType}\".`,\n \"FILTERING_PLUGIN_ERROR\",\n {\n fieldType\n }\n );\n };\n\n const execFiltering = (params: IExecParams) => {\n const { where: initialWhere, query, isValues = false } = params;\n /**\n * No point in continuing if no \"where\" conditions exist.\n */\n const keys = Object.keys(initialWhere);\n if (keys.length === 0) {\n return;\n }\n const where = structuredClone(initialWhere);\n\n for (const key in where) {\n const value = where[key as keyof typeof where];\n /**\n * We always skip if no value is defined.\n * Only skip undefined value, null is valid.\n */\n if (value === undefined) {\n continue;\n }\n //\n /**\n * When we are running with AND, the \"value\" MUST be an array.\n */\n else if (key === \"AND\") {\n const childWhereList = getWhereValues(value, \"AND\");\n\n const childQuery = createBaseQuery();\n\n for (const childWhere of childWhereList) {\n execFiltering({\n query: childQuery,\n where: childWhere,\n isValues\n });\n }\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n query.filter.push({\n bool: childQueryBool\n });\n\n continue;\n }\n //\n /**\n * When we are running with OR, the \"value\" must be an array.\n */\n else if (key === \"OR\") {\n const childWhereList = getWhereValues(value, \"OR\");\n /**\n * Each of the conditions MUST produce it's own should section.\n */\n const should: Query[] = [];\n for (const childWhere of childWhereList) {\n const childQuery = createBaseQuery();\n execFiltering({\n query: childQuery,\n where: childWhere,\n isValues\n });\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n should.push({\n bool: childQueryBool\n });\n }\n if (should.length === 0) {\n continue;\n }\n query.should.push(...should);\n /**\n * If there are any should, minimum to have is 1.\n * Of course, do not override if it's already set.\n */\n assignMinimumShouldMatchToQuery({\n query\n });\n continue;\n } else if (key === \"values\") {\n execFiltering({\n query,\n where: where[key] as CmsEntryListWhere,\n isValues: true\n });\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n let fieldId: string = isValues ? `values.${whereFieldId}` : whereFieldId;\n\n /**\n * TODO This will be required until the storage operations receive the fieldId instead of field storageId.\n * TODO For this to work without field searching, we need to refactor how the query looks like.\n *\n * Storage operations should NEVER receive an field storageId, only alias - fieldId.\n */\n const cmsModelField = model.fields.find(f => f.fieldId === fieldId);\n if (!cmsModelField && !fields[fieldId]) {\n throw new WebinyError(`There is no CMS Model Field \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const field = fields[fieldId];\n if (!field) {\n throw new WebinyError(`There is no field \"${fieldId}\".`, \"EXEC_FILTERING_ERROR\");\n }\n const filterPlugin = getFilterPlugin(field.type);\n\n filterPlugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n oper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MAAM,IAAIlD,WAAW,CAAC,gCAAgCkD,OAAO,IAAI,CAAC;MACtE,CAAC,MAAM,IAAIC,aAAa,EAAE;QACtBD,OAAO,GAAGC,aAAa,CAACD,OAAO;MACnC;MAEA,MAAMH,KAAK,GAAGlC,MAAM,CAACqC,OAAO,CAAC;MAC7B,IAAI,CAACH,KAAK,EAAE;QACR,MAAM,IAAI/C,WAAW,CAAC,sBAAsBkD,OAAO,IAAI,EAAE,sBAAsB,CAAC;MACpF;MACA,MAAMI,YAAY,GAAG5B,eAAe,CAACqB,KAAK,CAAC1B,IAAI,CAAC;MAEhDiC,YAAY,CAACC,IAAI,CAAC;QACdrC,cAAc;QACdQ,eAAe;QACfU,GAAG;QACHC,KAAK;QACLY,QAAQ;QACRF,KAAK;QACLlC,MAAM;QACNiB;MACJ,CAAC,CAAC;IACN;EACJ,CAAC;EAED,OAAOH,aAAa;AACxB,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OpenSearchQuerySearchValuePlugins, ModelField } from "../../../../operations/entry/elasticsearch/types.js";
|
|
2
2
|
interface FieldPathFactoryParams {
|
|
3
|
-
plugins:
|
|
3
|
+
plugins: OpenSearchQuerySearchValuePlugins;
|
|
4
4
|
}
|
|
5
5
|
interface FieldPathParams {
|
|
6
6
|
field: ModelField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getBaseFieldType","createFieldPathFactory","plugins","params","field","key","value","keyword","originalValue","fieldType","plugin","fieldPath","createPath","storageId","path","result","parents","map","p","concat","basePath","join"],"sources":["path.ts"],"sourcesContent":["import type {\n
|
|
1
|
+
{"version":3,"names":["getBaseFieldType","createFieldPathFactory","plugins","params","field","key","value","keyword","originalValue","fieldType","plugin","fieldPath","createPath","storageId","path","result","parents","map","p","concat","basePath","join"],"sources":["path.ts"],"sourcesContent":["import type {\n OpenSearchQuerySearchValuePlugins,\n ModelField\n} from \"~/operations/entry/elasticsearch/types.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\ninterface FieldPathFactoryParams {\n plugins: OpenSearchQuerySearchValuePlugins;\n}\ninterface FieldPathParams {\n field: ModelField;\n key: string;\n value: any;\n originalValue: any;\n keyword: boolean;\n}\n\nexport const createFieldPathFactory = ({ plugins }: FieldPathFactoryParams) => {\n return (params: FieldPathParams) => {\n const { field, key, value, keyword, originalValue } = params;\n const fieldType = getBaseFieldType(field);\n const plugin = plugins[fieldType];\n\n let fieldPath: string | null = null;\n if (plugin) {\n fieldPath = plugin.createPath({ field: field.field, value, key, originalValue });\n }\n if (!fieldPath) {\n fieldPath = field.field.storageId;\n if (field.path) {\n fieldPath = typeof field.path === \"function\" ? field.path(value) : field.path;\n }\n }\n\n const result: string[] = field.parents.map(p => p.storageId).concat([fieldPath]);\n\n return {\n basePath: result.join(\".\"),\n path: result.concat(keyword ? [\"keyword\"] : []).join(\".\")\n };\n };\n};\n"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,oDAAoD;AAarF,OAAO,MAAMC,sBAAsB,GAAGA,CAAC;EAAEC;AAAgC,CAAC,KAAK;EAC3E,OAAQC,MAAuB,IAAK;IAChC,MAAM;MAAEC,KAAK;MAAEC,GAAG;MAAEC,KAAK;MAAEC,OAAO;MAAEC;IAAc,CAAC,GAAGL,MAAM;IAC5D,MAAMM,SAAS,GAAGT,gBAAgB,CAACI,KAAK,CAAC;IACzC,MAAMM,MAAM,GAAGR,OAAO,CAACO,SAAS,CAAC;IAEjC,IAAIE,SAAwB,GAAG,IAAI;IACnC,IAAID,MAAM,EAAE;MACRC,SAAS,GAAGD,MAAM,CAACE,UAAU,CAAC;QAAER,KAAK,EAAEA,KAAK,CAACA,KAAK;QAAEE,KAAK;QAAED,GAAG;QAAEG;MAAc,CAAC,CAAC;IACpF;IACA,IAAI,CAACG,SAAS,EAAE;MACZA,SAAS,GAAGP,KAAK,CAACA,KAAK,CAACS,SAAS;MACjC,IAAIT,KAAK,CAACU,IAAI,EAAE;QACZH,SAAS,GAAG,OAAOP,KAAK,CAACU,IAAI,KAAK,UAAU,GAAGV,KAAK,CAACU,IAAI,CAACR,KAAK,CAAC,GAAGF,KAAK,CAACU,IAAI;MACjF;IACJ;IAEA,MAAMC,MAAgB,GAAGX,KAAK,CAACY,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACL,SAAS,CAAC,CAACM,MAAM,CAAC,CAACR,SAAS,CAAC,CAAC;IAEhF,OAAO;MACHS,QAAQ,EAAEL,MAAM,CAACM,IAAI,CAAC,GAAG,CAAC;MAC1BP,IAAI,EAAEC,MAAM,CAACI,MAAM,CAACZ,OAAO,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAACc,IAAI,CAAC,GAAG;IAC5D,CAAC;EACL,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CmsEntryFilterPlugin } from "../../../../../plugins/CmsEntryFilterPlugin.js";
|
|
2
|
-
import { parseWhereKey } from "@webiny/api-
|
|
2
|
+
import { parseWhereKey } from "@webiny/api-opensearch";
|
|
3
3
|
import WebinyError from "@webiny/error";
|
|
4
4
|
export const createObjectFilterPlugin = () => {
|
|
5
5
|
const plugin = new CmsEntryFilterPlugin({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CmsEntryFilterPlugin","parseWhereKey","WebinyError","createObjectFilterPlugin","plugin","fieldType","exec","params","applyFiltering","value","where","fields","field","parentField","getFilterPlugin","query","key","undefined","whereFieldId","operator","identifier","parents","map","p","fieldId","join","Object","keys","type","name"],"sources":["objectFilterPlugin.ts"],"sourcesContent":["import { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin.js\";\nimport { parseWhereKey } from \"@webiny/api-
|
|
1
|
+
{"version":3,"names":["CmsEntryFilterPlugin","parseWhereKey","WebinyError","createObjectFilterPlugin","plugin","fieldType","exec","params","applyFiltering","value","where","fields","field","parentField","getFilterPlugin","query","key","undefined","whereFieldId","operator","identifier","parents","map","p","fieldId","join","Object","keys","type","name"],"sources":["objectFilterPlugin.ts"],"sourcesContent":["import { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin.js\";\nimport { parseWhereKey } from \"@webiny/api-opensearch\";\nimport WebinyError from \"@webiny/error\";\n\nexport const createObjectFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"object\",\n exec: params => {\n const {\n applyFiltering,\n value: where,\n fields,\n field: parentField,\n getFilterPlugin,\n query\n } = params;\n /**\n * Because this is an object field, we must construct filters based on the value property.\n * Value property is actually a where condition.\n */\n for (const key in where) {\n const value = where[key];\n if (value === undefined) {\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n const identifier = [\n ...parentField.parents.map(p => p.fieldId),\n parentField.field.fieldId,\n whereFieldId\n ].join(\".\");\n const field = fields[identifier];\n if (!field) {\n throw new WebinyError(\n `There is no field \"${identifier}\".`,\n \"OBJECT_FILTER_FIELD_ERROR\",\n {\n fields: Object.keys(fields)\n }\n );\n }\n /**\n * We need to find the filter plugin for the child field.\n * This will throw error if no plugin can be found.\n */\n const plugin = getFilterPlugin(field.type);\n /**\n * Basically this allows us to go into depth as much as we want with the object fields.\n */\n plugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n }\n });\n\n plugin.name = `${plugin.type}.default.object`;\n\n return plugin;\n};\n"],"mappings":"AAAA,SAASA,oBAAoB;AAC7B,SAASC,aAAa,QAAQ,wBAAwB;AACtD,OAAOC,WAAW,MAAM,eAAe;AAEvC,OAAO,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,MAAMC,MAAM,GAAG,IAAIJ,oBAAoB,CAAC;IACpCK,SAAS,EAAE,QAAQ;IACnBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QACFC,cAAc;QACdC,KAAK,EAAEC,KAAK;QACZC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lugin } from "../../../../../plugins/CmsEntryFilterPlugin.js";
|
|
3
|
-
import { parseWhereKey } from "@webiny/api-
|
|
3
|
+
import { parseWhereKey } from "@webiny/api-opensearch";
|
|
4
4
|
export const createRefFilterPlugin = () => {
|
|
5
5
|
const plugin = new CmsEntryFilterPlugin({
|
|
6
6
|
fieldType: "ref",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","CmsEntryFilterPlugin","parseWhereKey","createRefFilterPlugin","plugin","fieldType","exec","params","applyFiltering","query","field","values","value","undefined","entryId","key","operator","name","type"],"sources":["refFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin.js\";\nimport { parseWhereKey } from \"@webiny/api-
|
|
1
|
+
{"version":3,"names":["WebinyError","CmsEntryFilterPlugin","parseWhereKey","createRefFilterPlugin","plugin","fieldType","exec","params","applyFiltering","query","field","values","value","undefined","entryId","key","operator","name","type"],"sources":["refFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin.js\";\nimport { parseWhereKey } from \"@webiny/api-opensearch\";\n\nexport const createRefFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"ref\",\n exec: params => {\n const { applyFiltering, query, field } = params;\n\n let values = params.value;\n /**\n * We must have an object when querying in the ref field.\n */\n if (typeof values !== \"object\") {\n throw new WebinyError(\n `When querying by ref field, value of the field must be an object.`,\n \"OBJECT_REQUIRED\",\n {\n value: values\n }\n );\n }\n\n if (values === null || values === undefined) {\n values = {\n entryId: null\n };\n }\n\n for (const key in values) {\n const { operator } = parseWhereKey(key);\n const value = values[key];\n if (value === undefined) {\n continue;\n }\n\n applyFiltering({\n query,\n field,\n operator,\n key,\n value\n });\n }\n }\n });\n\n plugin.name = `${plugin.type}.default.ref`;\n\n return plugin;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,oBAAoB;AAC7B,SAASC,aAAa,QAAQ,wBAAwB;AAEtD,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,MAAMC,MAAM,GAAG,IAAIH,oBAAoB,CAAC;IACpCI,SAAS,EAAE,KAAK;IAChBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAc;QAAEC,KAAK;QAAEC;MAAM,CAAC,GAAGH,MAAM;MAE/C,IAAII,MAAM,GAAGJ,MAAM,CAACK,KAAK;MACzB;AACZ;AACA;MACY,IAAI,OAAOD,MAAM,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAIX,WAAW,CACjB,mEAAmE,EACnE,iBAAiB,EACjB;UACIY,KAAK,EAAED;QACX,CACJ,CAAC;MACL;MAEA,IAAIA,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKE,SAAS,EAAE;QACzCF,MAAM,GAAG;UACLG,OAAO,EAAE;QACb,CAAC;MACL;MAEA,KAAK,MAAMC,GAAG,IAAIJ,MAAM,EAAE;QACtB,MAAM;UAAEK;QAAS,CAAC,GAAGd,aAAa,CAACa,GAAG,CAAC;QACvC,MAAMH,KAAK,GAAGD,MAAM,CAACI,GAAG,CAAC;QACzB,IAAIH,KAAK,KAAKC,SAAS,EAAE;UACrB;QACJ;QAEAL,cAAc,CAAC;UACXC,KAAK;UACLC,KAAK;UACLM,QAAQ;UACRD,GAAG;UACHH;QACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAEFR,MAAM,CAACa,IAAI,GAAG,GAAGb,MAAM,CAACc,IAAI,cAAc;EAE1C,OAAOd,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const getPopulated: (query:
|
|
1
|
+
import type { OpenSearchBoolQueryConfig } from "@webiny/api-opensearch/types.js";
|
|
2
|
+
export declare const getPopulated: (query: OpenSearchBoolQueryConfig) => Partial<OpenSearchBoolQueryConfig>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getPopulated","query","result","key","value","undefined","Array","isArray","length"],"sources":["populated.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":["getPopulated","query","result","key","value","undefined","Array","isArray","length"],"sources":["populated.ts"],"sourcesContent":["import type { OpenSearchBoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\n\nexport const getPopulated = (\n query: OpenSearchBoolQueryConfig\n): Partial<OpenSearchBoolQueryConfig> => {\n const result: Partial<OpenSearchBoolQueryConfig> = {};\n let key: keyof OpenSearchBoolQueryConfig;\n for (key in query) {\n const value = query[key];\n if (value === undefined || (Array.isArray(value) && value.length === 0)) {\n continue;\n }\n /**\n * TODO figure out better types.\n */\n // @ts-expect-error\n result[key] = value;\n }\n return result;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,YAAY,GACrBC,KAAgC,IACK;EACrC,MAAMC,MAA0C,GAAG,CAAC,CAAC;EACrD,IAAIC,GAAoC;EACxC,KAAKA,GAAG,IAAIF,KAAK,EAAE;IACf,MAAMG,KAAK,GAAGH,KAAK,CAACE,GAAG,CAAC;IACxB,IAAIC,KAAK,KAAKC,SAAS,IAAKC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAIA,KAAK,CAACI,MAAM,KAAK,CAAE,EAAE;MACrE;IACJ;IACA;AACR;AACA;IACQ;IACAN,MAAM,CAACC,GAAG,CAAC,GAAGC,KAAK;EACvB;EACA,OAAOF,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OpenSearchBoolQueryConfig } from "@webiny/api-opensearch/types.js";
|
|
2
2
|
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
3
3
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
4
4
|
import type { ModelFields } from "../../../operations/entry/elasticsearch/types.js";
|
|
5
5
|
interface Params {
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
model: CmsModel;
|
|
8
|
-
query:
|
|
8
|
+
query: OpenSearchBoolQueryConfig;
|
|
9
9
|
term?: string;
|
|
10
10
|
fields: ModelFields;
|
|
11
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeValue } from "@webiny/api-
|
|
1
|
+
import { normalizeValue } from "@webiny/api-opensearch";
|
|
2
2
|
import { CmsEntryElasticsearchFullTextSearchPlugin, createCmsEntryElasticsearchFullTextSearchPlugin } from "../../../plugins/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Our default plugin is working with the AND operator for the multiple words query string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["normalizeValue","CmsEntryElasticsearchFullTextSearchPlugin","createCmsEntryElasticsearchFullTextSearchPlugin","defaultPlugin","apply","params","query","term","fields","createFieldPath","prepareTerm","must","push","query_string","allow_leading_wildcard","Object","values","map","default_operator","name","getPlugin","container","model","plugins","byType","type","reverse","plugin","pl","models","includes","modelId","length","applyFullTextSearch","keys","field","path","systemField","storageId"],"sources":["fullTextSearch.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":["normalizeValue","CmsEntryElasticsearchFullTextSearchPlugin","createCmsEntryElasticsearchFullTextSearchPlugin","defaultPlugin","apply","params","query","term","fields","createFieldPath","prepareTerm","must","push","query_string","allow_leading_wildcard","Object","values","map","default_operator","name","getPlugin","container","model","plugins","byType","type","reverse","plugin","pl","models","includes","modelId","length","applyFullTextSearch","keys","field","path","systemField","storageId"],"sources":["fullTextSearch.ts"],"sourcesContent":["import type { OpenSearchBoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\nimport { normalizeValue } from \"@webiny/api-opensearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsEntryElasticsearchFullTextSearchPlugin,\n createCmsEntryElasticsearchFullTextSearchPlugin\n} from \"~/plugins/index.js\";\nimport type { ModelFields } from \"~/operations/entry/elasticsearch/types.js\";\n\n/**\n * Our default plugin is working with the AND operator for the multiple words query string.\n */\nconst defaultPlugin = createCmsEntryElasticsearchFullTextSearchPlugin({\n apply: params => {\n const { query, term, fields, createFieldPath, prepareTerm } = params;\n\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: Object.values(fields).map(createFieldPath),\n query: `*${prepareTerm(term)}*`,\n default_operator: \"and\"\n }\n });\n }\n});\ndefaultPlugin.name = \"headless-cms.elasticsearch.entry.fullTextSearch.default\";\n\ninterface GetPluginParams {\n container: PluginsContainer;\n model: CmsModel;\n}\nconst getPlugin = (params: GetPluginParams): CmsEntryElasticsearchFullTextSearchPlugin => {\n const { container, model } = params;\n /**\n * We need to reverse the plugins, so we can take the last one first - possibility to override existing plugins.\n */\n const plugins = container\n .byType<CmsEntryElasticsearchFullTextSearchPlugin>(\n CmsEntryElasticsearchFullTextSearchPlugin.type\n )\n .reverse();\n /**\n * We need to find the most specific plugin for the given model.\n * Also, we need to use the first possible plugin if the specific one is not found.\n */\n let plugin: CmsEntryElasticsearchFullTextSearchPlugin | null = null;\n for (const pl of plugins) {\n const models = pl.models || [];\n /**\n * We take the first available plugin for the given model.\n */\n if (models.includes(model.modelId)) {\n return pl;\n }\n /**\n * Then we set the first possible plugin, which has no models defined, as the default one.\n * It is important not to set the plugin which has models defined as they are specifically for the targeted model.\n */\n //\n else if (!plugin && models.length === 0) {\n plugin = pl;\n }\n }\n\n return plugin || defaultPlugin;\n};\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n query: OpenSearchBoolQueryConfig;\n term?: string;\n fields: ModelFields;\n}\nexport const applyFullTextSearch = (params: Params): void => {\n const { plugins, query, term, fields, model } = params;\n const keys = Object.keys(fields);\n if (!term || term.length === 0 || keys.length === 0) {\n return;\n }\n\n const plugin = getPlugin({\n container: plugins,\n model\n });\n\n plugin.apply({\n model,\n createFieldPath: field => {\n if (typeof field.path === \"function\") {\n return field.path(term);\n } else if (field.systemField) {\n return field.path || field.field.storageId;\n }\n return `values.${field.path || field.field.storageId}`;\n },\n fields,\n query,\n term,\n prepareTerm: normalizeValue\n });\n};\n"],"mappings":"AACA,SAASA,cAAc,QAAQ,wBAAwB;AAGvD,SACIC,yCAAyC,EACzCC,+CAA+C;AAInD;AACA;AACA;AACA,MAAMC,aAAa,GAAGD,+CAA+C,CAAC;EAClEE,KAAK,EAAEC,MAAM,IAAI;IACb,MAAM;MAAEC,KAAK;MAAEC,IAAI;MAAEC,MAAM;MAAEC,eAAe;MAAEC;IAAY,CAAC,GAAGL,MAAM;IAEpEC,KAAK,CAACK,IAAI,CAACC,IAAI,CAAC;MACZC,YAAY,EAAE;QACVC,sBAAsB,EAAE,IAAI;QAC5BN,MAAM,EAAEO,MAAM,CAACC,MAAM,CAACR,MAAM,CAAC,CAACS,GAAG,CAACR,eAAe,CAAC;QAClDH,KAAK,EAAE,IAAII,WAAW,CAACH,IAAI,CAAC,GAAG;QAC/BW,gBAAgB,EAAE;MACtB;IACJ,CAAC,CAAC;EACN;AACJ,CAAC,CAAC;AACFf,aAAa,CAACgB,IAAI,GAAG,yDAAyD;AAM9E,MAAMC,SAAS,GAAIf,MAAuB,IAAgD;EACtF,MAAM;IAAEgB,SAAS;IAAEC;EAAM,CAAC,GAAGjB,MAAM;EACnC;AACJ;AACA;EACI,MAAMkB,OAAO,GAAGF,SAAS,CACpBG,MAAM,CACHvB,yCAAyC,CAACwB,IAC9C,CAAC,CACAC,OAAO,CAAC,CAAC;EACd;AACJ;AACA;AACA;EACI,IAAIC,MAAwD,GAAG,IAAI;EACnE,KAAK,MAAMC,EAAE,IAAIL,OAAO,EAAE;IACtB,MAAMM,MAAM,GAAGD,EAAE,CAACC,MAAM,IAAI,EAAE;IAC9B;AACR;AACA;IACQ,IAAIA,MAAM,CAACC,QAAQ,CAACR,KAAK,CAACS,OAAO,CAAC,EAAE;MAChC,OAAOH,EAAE;IACb;IACA;AACR;AACA;AACA;IACQ;IAAA,KACK,IAAI,CAACD,MAAM,IAAIE,MAAM,CAACG,MAAM,KAAK,CAAC,EAAE;MACrCL,MAAM,GAAGC,EAAE;IACf;EACJ;EAEA,OAAOD,MAAM,IAAIxB,aAAa;AAClC,CAAC;AASD,OAAO,MAAM8B,mBAAmB,GAAI5B,MAAc,IAAW;EACzD,MAAM;IAAEkB,OAAO;IAAEjB,KAAK;IAAEC,IAAI;IAAEC,MAAM;IAAEc;EAAM,CAAC,GAAGjB,MAAM;EACtD,MAAM6B,IAAI,GAAGnB,MAAM,CAACmB,IAAI,CAAC1B,MAAM,CAAC;EAChC,IAAI,CAACD,IAAI,IAAIA,IAAI,CAACyB,MAAM,KAAK,CAAC,IAAIE,IAAI,CAACF,MAAM,KAAK,CAAC,EAAE;IACjD;EACJ;EAEA,MAAML,MAAM,GAAGP,SAAS,CAAC;IACrBC,SAAS,EAAEE,OAAO;IAClBD;EACJ,CAAC,CAAC;EAEFK,MAAM,CAACvB,KAAK,CAAC;IACTkB,KAAK;IACLb,eAAe,EAAE0B,KAAK,IAAI;MACtB,IAAI,OAAOA,KAAK,CAACC,IAAI,KAAK,UAAU,EAAE;QAClC,OAAOD,KAAK,CAACC,IAAI,CAAC7B,IAAI,CAAC;MAC3B,CAAC,MAAM,IAAI4B,KAAK,CAACE,WAAW,EAAE;QAC1B,OAAOF,KAAK,CAACC,IAAI,IAAID,KAAK,CAACA,KAAK,CAACG,SAAS;MAC9C;MACA,OAAO,UAAUH,KAAK,CAACC,IAAI,IAAID,KAAK,CAACA,KAAK,CAACG,SAAS,EAAE;IAC1D,CAAC;IACD9B,MAAM;IACNF,KAAK;IACLC,IAAI;IACJG,WAAW,EAAEV;EACjB,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OpenSearchBoolQueryConfig } from "@webiny/api-opensearch/types.js";
|
|
2
2
|
import type { CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
-
export declare const createBaseQuery: () =>
|
|
3
|
+
export declare const createBaseQuery: () => OpenSearchBoolQueryConfig;
|
|
4
4
|
interface Params {
|
|
5
5
|
model: CmsModel;
|
|
6
6
|
where: CmsEntryListWhere;
|
|
@@ -13,5 +13,5 @@ interface Params {
|
|
|
13
13
|
*
|
|
14
14
|
* We add the query.filter terms because we do not need scored search here and it is a bit faster.
|
|
15
15
|
*/
|
|
16
|
-
export declare const createInitialQuery: (params: Params) =>
|
|
16
|
+
export declare const createInitialQuery: (params: Params) => OpenSearchBoolQueryConfig;
|
|
17
17
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebinyError from "@webiny/error";
|
|
2
2
|
import { createLatestRecordType, createPublishedRecordType } from "../recordType.js";
|
|
3
|
-
import { isSharedElasticsearchIndex } from "@webiny/api-
|
|
3
|
+
import { isSharedOpenSearchIndex as isSharedElasticsearchIndex } from "@webiny/api-opensearch";
|
|
4
4
|
export const createBaseQuery = () => {
|
|
5
5
|
return {
|
|
6
6
|
must: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","createLatestRecordType","createPublishedRecordType","isSharedElasticsearchIndex","createBaseQuery","must","must_not","should","filter","createInitialQuery","params","model","where","query","sharedIndex","push","term","tenant","modelId","published","latest"],"sources":["initialQuery.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {
|
|
1
|
+
{"version":3,"names":["WebinyError","createLatestRecordType","createPublishedRecordType","isSharedOpenSearchIndex","isSharedElasticsearchIndex","createBaseQuery","must","must_not","should","filter","createInitialQuery","params","model","where","query","sharedIndex","push","term","tenant","modelId","published","latest"],"sources":["initialQuery.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { OpenSearchBoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\nimport type { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createLatestRecordType, createPublishedRecordType } from \"../recordType.js\";\nimport { isSharedOpenSearchIndex as isSharedElasticsearchIndex } from \"@webiny/api-opensearch\";\n\nexport const createBaseQuery = (): OpenSearchBoolQueryConfig => {\n return {\n must: [],\n must_not: [],\n should: [],\n filter: []\n };\n};\n\ninterface Params {\n model: CmsModel;\n where: CmsEntryListWhere;\n}\n/**\n * Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.\n * We allow either published or either latest.\n * Latest is used in the manage API and published in the read API.\n *\n *\n * We add the query.filter terms because we do not need scored search here and it is a bit faster.\n */\nexport const createInitialQuery = (params: Params): OpenSearchBoolQueryConfig => {\n const { model, where } = params;\n\n const query = createBaseQuery();\n\n /**\n * When ES index is shared between tenants, we need to filter records by tenant ID\n *\n * TODO determine if we want to search across tenants in shared index?\n */\n const sharedIndex = isSharedElasticsearchIndex();\n if (sharedIndex) {\n /**\n * Tenant for the filtering is taken from the model.\n *\n * TODO determine if we want to send it in the \"where\" parameter?\n */\n query.filter.push({\n term: {\n \"tenant.keyword\": model.tenant\n }\n });\n /**\n * Also, we must search only in selected model.\n */\n query.filter.push({\n term: {\n \"modelId.keyword\": model.modelId\n }\n });\n }\n\n /**\n * We must transform published and latest where args into something that is understandable by our Elasticsearch\n */\n if (where.published === true) {\n query.filter.push({\n term: {\n \"__type.keyword\": createPublishedRecordType()\n }\n });\n } else if (where.latest === true) {\n query.filter.push({\n term: {\n \"__type.keyword\": createLatestRecordType()\n }\n });\n }\n //\n /**\n * We do not allow filtering without the published or latest parameter.\n * Also, we do not want to set the default one, as there is a large possibility for user error when filtering.\n */\n else {\n throw new WebinyError(\n `Cannot call Elasticsearch query when not setting \"published\" or \"latest\".`,\n \"OPENSEARCH_UNSUPPORTED_QUERY\",\n {\n where\n }\n );\n }\n /**\n * We need to remove fields that actually do not exist on the record - it will break otherwise.\n * This will modify the original object, which is what we want.\n */\n delete where.published;\n delete where.latest;\n\n return query;\n};\n"],"mappings":"AAAA,OAAOA,WAAW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EACA;AACJ;AACA;AACA,KAHI,KAIK;IACD,MAAM,IAAID,WAAW,CACjB,2EAA2E,EAC3E,8BAA8B,EAC9B;MACIa;IACJ,CACJ,CAAC;EACL;EACA;AACJ;AACA;AACA;EACI,OAAOA,KAAK,CAACO,SAAS;EACtB,OAAOP,KAAK,CAACQ,MAAM;EAEnB,OAAOP,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OpenSearchQueryBuilderOperatorPlugins } from "../types.js";
|
|
3
3
|
interface Params {
|
|
4
4
|
plugins: PluginsContainer;
|
|
5
5
|
}
|
|
6
|
-
export declare const createOperatorPluginList: (params: Params) =>
|
|
6
|
+
export declare const createOperatorPluginList: (params: Params) => OpenSearchQueryBuilderOperatorPlugins;
|
|
7
7
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpenSearchQueryBuilderOperatorPlugin } from "@webiny/api-opensearch";
|
|
2
2
|
export const createOperatorPluginList = params => {
|
|
3
3
|
const {
|
|
4
4
|
plugins
|
|
@@ -7,7 +7,7 @@ export const createOperatorPluginList = params => {
|
|
|
7
7
|
* We always set the last one operator plugin added.
|
|
8
8
|
* This way user can override the plugins.
|
|
9
9
|
*/
|
|
10
|
-
return plugins.byType(
|
|
10
|
+
return plugins.byType(OpenSearchQueryBuilderOperatorPlugin.type).reduce((acc, plugin) => {
|
|
11
11
|
const operator = plugin.getOperator();
|
|
12
12
|
/**
|
|
13
13
|
* We also only allow the override of the plugins if the new plugin is NOT a default one.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["OpenSearchQueryBuilderOperatorPlugin","createOperatorPluginList","params","plugins","byType","type","reduce","acc","plugin","operator","getOperator","name","match"],"sources":["operator.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport { OpenSearchQueryBuilderOperatorPlugin } from \"@webiny/api-opensearch\";\nimport type { OpenSearchQueryBuilderOperatorPlugins } from \"../types.js\";\n\ninterface Params {\n plugins: PluginsContainer;\n}\nexport const createOperatorPluginList = (params: Params): OpenSearchQueryBuilderOperatorPlugins => {\n const { plugins } = params;\n /**\n * We always set the last one operator plugin added.\n * This way user can override the plugins.\n */\n return plugins\n .byType<OpenSearchQueryBuilderOperatorPlugin>(OpenSearchQueryBuilderOperatorPlugin.type)\n .reduce<OpenSearchQueryBuilderOperatorPlugins>((acc, plugin) => {\n const operator = plugin.getOperator();\n /**\n * We also only allow the override of the plugins if the new plugin is NOT a default one.\n * If a user sets the plugin name ending with .default, we cannot do anything about it.\n */\n if (!!acc[operator] && (plugin.name || \"\").match(/\\.default$/)) {\n return acc;\n }\n acc[operator] = plugin;\n return acc;\n }, {});\n};\n"],"mappings":"AACA,SAASA,oCAAoC,QAAQ,wBAAwB;AAM7E,OAAO,MAAMC,wBAAwB,GAAIC,MAAc,IAA4C;EAC/F,MAAM;IAAEC;EAAQ,CAAC,GAAGD,MAAM;EAC1B;AACJ;AACA;AACA;EACI,OAAOC,OAAO,CACTC,MAAM,CAAuCJ,oCAAoC,CAACK,IAAI,CAAC,CACvFC,MAAM,CAAwC,CAACC,GAAG,EAAEC,MAAM,KAAK;IAC5D,MAAMC,QAAQ,GAAGD,MAAM,CAACE,WAAW,CAAC,CAAC;IACrC;AACZ;AACA;AACA;IACY,IAAI,CAAC,CAACH,GAAG,CAACE,QAAQ,CAAC,IAAI,CAACD,MAAM,CAACG,IAAI,IAAI,EAAE,EAAEC,KAAK,CAAC,YAAY,CAAC,EAAE;MAC5D,OAAOL,GAAG;IACd;IACAA,GAAG,CAACE,QAAQ,CAAC,GAAGD,MAAM;IACtB,OAAOD,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OpenSearchQuerySearchValuePlugins } from "../types.js";
|
|
3
3
|
interface Params {
|
|
4
4
|
plugins: PluginsContainer;
|
|
5
5
|
}
|
|
6
|
-
export declare const createSearchPluginList: ({ plugins }: Params) =>
|
|
6
|
+
export declare const createSearchPluginList: ({ plugins }: Params) => OpenSearchQuerySearchValuePlugins;
|
|
7
7
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","createSearchPluginList","plugins","byType","type","reduce","plugin","fieldType","name"],"sources":["search.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins/index.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type {
|
|
1
|
+
{"version":3,"names":["WebinyError","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","createSearchPluginList","plugins","byType","type","reduce","plugin","fieldType","name"],"sources":["search.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins/index.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { OpenSearchQuerySearchValuePlugins } from \"../types.js\";\n\ninterface Params {\n plugins: PluginsContainer;\n}\nexport const createSearchPluginList = ({ plugins }: Params): OpenSearchQuerySearchValuePlugins => {\n return plugins\n .byType<CmsEntryElasticsearchQueryBuilderValueSearchPlugin>(\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type\n )\n .reduce<OpenSearchQuerySearchValuePlugins>((plugins, plugin) => {\n if (plugins[plugin.fieldType]) {\n throw new WebinyError(\n \"There is a ElasticsearchQueryBuilderValueSearchPlugin defined for the field type.\",\n \"PLUGIN_ALREADY_EXISTS\",\n {\n fieldType: plugin.fieldType,\n name: plugin.name || \"unknown\"\n }\n );\n }\n plugins[plugin.fieldType] = plugin;\n\n return plugins;\n }, {});\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,kDAAkD;AAO3D,OAAO,MAAMC,sBAAsB,GAAGA,CAAC;EAAEC;AAAgB,CAAC,KAAwC;EAC9F,OAAOA,OAAO,CACTC,MAAM,CACHH,kDAAkD,CAACI,IACvD,CAAC,CACAC,MAAM,CAAoC,CAACH,OAAO,EAAEI,MAAM,KAAK;IAC5D,IAAIJ,OAAO,CAACI,MAAM,CAACC,SAAS,CAAC,EAAE;MAC3B,MAAM,IAAIR,WAAW,CACjB,mFAAmF,EACnF,uBAAuB,EACvB;QACIQ,SAAS,EAAED,MAAM,CAACC,SAAS;QAC3BC,IAAI,EAAEF,MAAM,CAACE,IAAI,IAAI;MACzB,CACJ,CAAC;IACL;IACAN,OAAO,CAACI,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM;IAElC,OAAOJ,OAAO;EAClB,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const IGNORED_ES_SEARCH_EXCEPTIONS = ["index_not_found_exception", "search_phase_execution_exception"];
|
|
2
2
|
export const shouldIgnoreEsResponseError = error => {
|
|
3
|
-
return IGNORED_ES_SEARCH_EXCEPTIONS.
|
|
3
|
+
return IGNORED_ES_SEARCH_EXCEPTIONS.some(ignoredMessage => error.message.includes(ignoredMessage));
|
|
4
4
|
};
|
|
5
5
|
|
|
6
6
|
//# sourceMappingURL=shouldIgnoreEsResponseError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["IGNORED_ES_SEARCH_EXCEPTIONS","shouldIgnoreEsResponseError","error","
|
|
1
|
+
{"version":3,"names":["IGNORED_ES_SEARCH_EXCEPTIONS","shouldIgnoreEsResponseError","error","some","ignoredMessage","message","includes"],"sources":["shouldIgnoreEsResponseError.ts"],"sourcesContent":["import type WebinyError from \"@webiny/error\";\n\nconst IGNORED_ES_SEARCH_EXCEPTIONS = [\n \"index_not_found_exception\",\n \"search_phase_execution_exception\"\n];\n\nexport const shouldIgnoreEsResponseError = (error: WebinyError) => {\n return IGNORED_ES_SEARCH_EXCEPTIONS.some(ignoredMessage =>\n error.message.includes(ignoredMessage)\n );\n};\n"],"mappings":"AAEA,MAAMA,4BAA4B,GAAG,CACjC,2BAA2B,EAC3B,kCAAkC,CACrC;AAED,OAAO,MAAMC,2BAA2B,GAAIC,KAAkB,IAAK;EAC/D,OAAOF,4BAA4B,CAACG,IAAI,CAACC,cAAc,IACnDF,KAAK,CAACG,OAAO,CAACC,QAAQ,CAACF,cAAc,CACzC,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Sort as
|
|
1
|
+
import type { Sort as OpenSearchSort } from "@webiny/api-opensearch/types.js";
|
|
2
2
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
3
|
import type { CmsEntryListSort, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
4
4
|
import type { ModelFields } from "./types.js";
|
|
@@ -8,5 +8,5 @@ interface Params {
|
|
|
8
8
|
modelFields: ModelFields;
|
|
9
9
|
model: CmsModel;
|
|
10
10
|
}
|
|
11
|
-
export declare const createElasticsearchSort: (params: Params) =>
|
|
11
|
+
export declare const createElasticsearchSort: (params: Params) => OpenSearchSort;
|
|
12
12
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createSort,
|
|
1
|
+
import { createSort, OpenSearchFieldPlugin } from "@webiny/api-opensearch";
|
|
2
2
|
import { hasKeyword } from "./keyword.js";
|
|
3
3
|
import { createSearchPluginList } from "./plugins/search.js";
|
|
4
4
|
import { createFieldPathFactory } from "./filtering/path.js";
|
|
@@ -67,7 +67,7 @@ export const createElasticsearchSort = params => {
|
|
|
67
67
|
/**
|
|
68
68
|
* Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.
|
|
69
69
|
*/
|
|
70
|
-
plugins[fieldIdPath] = new
|
|
70
|
+
plugins[fieldIdPath] = new OpenSearchFieldPlugin({
|
|
71
71
|
unmappedType: field.unmappedType,
|
|
72
72
|
keyword: hasKeyword(field),
|
|
73
73
|
sortable: field.sortable,
|
|
@@ -77,8 +77,8 @@ export const createElasticsearchSort = params => {
|
|
|
77
77
|
});
|
|
78
78
|
return plugins;
|
|
79
79
|
}, {
|
|
80
|
-
["*"]: new
|
|
81
|
-
field:
|
|
80
|
+
["*"]: new OpenSearchFieldPlugin({
|
|
81
|
+
field: OpenSearchFieldPlugin.ALL,
|
|
82
82
|
keyword: false
|
|
83
83
|
})
|
|
84
84
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSort","
|
|
1
|
+
{"version":3,"names":["createSort","OpenSearchFieldPlugin","hasKeyword","createSearchPluginList","createFieldPathFactory","NoValueContainer","matchField","input","valuesMatch","match","fieldId","order","isValues","nonValues","createElasticsearchSort","params","sort","modelFields","plugins","length","searchPlugins","createFieldPath","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","field","parents","fieldIdPath","path","key","storageId","value","create","keyword","originalValue","unmappedType","sortable","searchable","ALL","transformedSort","map","matched","filter","Boolean","fieldPlugins"],"sources":["sort.ts"],"sourcesContent":["import type { Sort as OpenSearchSort } from \"@webiny/api-opensearch/types.js\";\nimport { createSort, OpenSearchFieldPlugin } from \"@webiny/api-opensearch\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { CmsEntryListSort, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { ModelFields } from \"./types.js\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword.js\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search.js\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path.js\";\nimport { NoValueContainer } from \"~/values/NoValueContainer.js\";\n\ninterface IMatchFieldResponse {\n fieldId: string;\n isValues: boolean;\n order: \"ASC\" | \"DESC\";\n}\n\nconst matchField = (input: string): IMatchFieldResponse | null => {\n const valuesMatch = input.match(/^values_([a-zA-Z-0-9_]+)_(ASC|DESC)$/);\n if (valuesMatch) {\n const [, fieldId, order] = valuesMatch;\n return {\n fieldId,\n isValues: true,\n order: order as \"ASC\" | \"DESC\"\n };\n }\n const nonValues = input.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);\n if (!nonValues) {\n return null;\n }\n const [, fieldId, order] = nonValues;\n return {\n fieldId,\n isValues: false,\n order: order as \"ASC\" | \"DESC\"\n };\n};\n\ninterface Params {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n model: CmsModel;\n}\n\nexport const createElasticsearchSort = (params: Params): OpenSearchSort => {\n const { sort, modelFields, plugins } = params;\n\n if (!sort || sort.length === 0) {\n return [\n {\n [\"id.keyword\"]: {\n order: \"asc\"\n }\n }\n ];\n }\n\n const searchPlugins = createSearchPluginList({\n plugins\n });\n\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce<Record<string, OpenSearchFieldPlugin>>(\n (plugins, field) => {\n /**\n * We do not support sorting by nested fields.\n */\n const isValues = field.parents.length === 1 && field.parents[0].fieldId === \"values\";\n if (field.parents.length > 0 && !isValues) {\n return plugins;\n }\n\n const fieldId = field.field.fieldId;\n const fieldIdPath = isValues ? `values.${fieldId}` : fieldId;\n\n fieldIdToStorageIdIdMap[fieldIdPath] = fieldIdPath;\n\n const { path } = createFieldPath({\n key: field.field.storageId,\n field,\n value: NoValueContainer.create(),\n keyword: false,\n originalValue: NoValueContainer.create()\n });\n /**\n * Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.\n */\n plugins[fieldIdPath] = new OpenSearchFieldPlugin({\n unmappedType: field.unmappedType,\n keyword: hasKeyword(field),\n sortable: field.sortable,\n searchable: field.searchable,\n field: fieldId,\n path\n });\n return plugins;\n },\n {\n [\"*\"]: new OpenSearchFieldPlugin({\n field: OpenSearchFieldPlugin.ALL,\n keyword: false\n })\n }\n );\n\n const transformedSort = sort\n .map(value => {\n const matched = matchField(value);\n if (!matched) {\n return null;\n }\n const { fieldId, order, isValues } = matched;\n const key = isValues ? `values.${fieldId}` : fieldId;\n if (fieldIdToStorageIdIdMap[key]) {\n return `${fieldIdToStorageIdIdMap[key]}_${order}`;\n }\n\n return value;\n })\n .filter(Boolean) as string[];\n return createSort({\n fieldPlugins: sortPlugins,\n sort: transformedSort\n });\n};\n"],"mappings":"AACA,SAASA,UAAU,EAAEC,qBAAqB,QAAQ,wBAAwB;AAI1E,SAASC,UAAU;AACnB,SAASC,sBAAsB;AAC/B,SAASC,sBAAsB;AAC/B,SAASC,gBAAgB;AAQzB,MAAMC,UAAU,GAAIC,KAAa,IAAiC;EAC9D,MAAMC,WAAW,GAAGD,KAAK,CAACE,KAAK,CAAC,sCAAsC,CAAC;EACvE,IAAID,WAAW,EAAE;IACb,MAAM,GAAGE,OAAO,EAAEC,KAAK,CAAC,GAAGH,WAAW;IACtC,OAAO;MACHE,OAAO;MACPE,QAAQ,EAAE,IAAI;MACdD,KAAK,EAAEA;IACX,CAAC;EACL;EACA,MAAME,SAAS,GAAGN,KAAK,CAACE,KAAK,CAAC,+BAA+B,CAAC;EAC9D,IAAI,CAACI,SAAS,EAAE;IACZ,OAAO,IAAI;EACf;EACA,MAAM,GAAGH,OAAO,EAAEC,KAAK,CAAC,GAAGE,SAAS;EACpC,OAAO;IACHH,OAAO;IACPE,QAAQ,EAAE,KAAK;IACfD,KAAK,EAAEA;EACX,CAAC;AACL,CAAC;AASD,OAAO,MAAMG,uBAAuB,GAAIC,MAAc,IAAqB;EACvE,MAAM;IAAEC,IAAI;IAAEC,WAAW;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE7C,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5B,OAAO,CACH;MAC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AK,CAAC;MAC1BW,QAAQ,EAAEX,KAAK,CAACW,QAAQ;MACxBC,UAAU,EAAEZ,KAAK,CAACY,UAAU;MAC5BZ,KAAK,EAAEjB,OAAO;MACdoB;IACJ,CAAC,CAAC;IACF,OAAOZ,OAAO;EAClB,CAAC,EACD;IACI,CAAC,GAAG,GAAG,IAAIjB,qBAAqB,CAAC;MAC7B0B,KAAK,EAAE1B,qBAAqB,CAACuC,GAAG;MAChCL,OAAO,EAAE;IACb,CAAC;EACL,CACJ,CAAC;EAED,MAAMM,eAAe,GAAGzB,IAAI,CACvB0B,GAAG,CAACT,KAAK,IAAI;IACV,MAAMU,OAAO,GAAGrC,UAAU,CAAC2B,KAAK,CAAC;IACjC,IAAI,CAACU,OAAO,EAAE;MACV,OAAO,IAAI;IACf;IACA,MAAM;MAAEjC,OAAO;MAAEC,KAAK;MAAEC;IAAS,CAAC,GAAG+B,OAAO;IAC5C,MAAMZ,GAAG,GAAGnB,QAAQ,GAAG,UAAUF,OAAO,EAAE,GAAGA,OAAO;IACpD,IAAIY,uBAAuB,CAACS,GAAG,CAAC,EAAE;MAC9B,OAAO,GAAGT,uBAAuB,CAACS,GAAG,CAAC,IAAIpB,KAAK,EAAE;IACrD;IAEA,OAAOsB,KAAK;EAChB,CAAC,CAAC,CACDW,MAAM,CAACC,OAAO,CAAa;EAChC,OAAO7C,UAAU,CAAC;IACd8C,YAAY,EAAEvB,WAAW;IACzBP,IAAI,EAAEyB;EACV,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Plugin, if exists, makes sure that response value is correct.
|
|
4
4
|
*/
|
|
5
5
|
import type { CmsModelField } from "@webiny/api-headless-cms/types/index.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { OpenSearchQuerySearchValuePlugins } from "./types.js";
|
|
7
7
|
interface Params {
|
|
8
|
-
plugins:
|
|
8
|
+
plugins: OpenSearchQuerySearchValuePlugins;
|
|
9
9
|
field: CmsModelField;
|
|
10
10
|
value: any;
|
|
11
11
|
}
|