@webiny/api-headless-cms-ddb-es 6.4.4-beta.1 → 6.4.4-beta.10
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 +18 -15
- package/configurations.js +22 -16
- package/configurations.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.d.ts +4 -4
- package/elasticsearch/createElasticsearchIndex.js +4 -16
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.d.ts +4 -2
- package/elasticsearch/deleteElasticsearchIndex.js +2 -2
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/exports/api/cms/opensearch.d.ts +1 -1
- package/exports/api/cms/opensearch.js +1 -1
- package/feature.js +13 -7
- package/feature.js.map +1 -1
- package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.d.ts +25 -0
- package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js +36 -0
- package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js.map +1 -0
- package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.d.ts +8 -0
- package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js +17 -0
- package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js.map +1 -0
- package/features/CmsModelOpenSearchIndex/abstractions.d.ts +20 -0
- package/features/CmsModelOpenSearchIndex/abstractions.js +5 -0
- package/features/CmsModelOpenSearchIndex/abstractions.js.map +1 -0
- package/features/{CmsEntryOpenSearchIndex → CmsModelOpenSearchIndex}/feature.d.ts +1 -1
- package/features/CmsModelOpenSearchIndex/feature.js +13 -0
- package/features/CmsModelOpenSearchIndex/feature.js.map +1 -0
- package/features/CmsModelOpenSearchIndex/index.d.ts +3 -0
- package/features/CmsModelOpenSearchIndex/index.js +3 -0
- package/operations/entry/elasticsearch/body.d.ts +2 -1
- package/operations/entry/elasticsearch/body.js +3 -2
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.d.ts +1 -0
- package/operations/entry/elasticsearch/initialQuery.js +2 -4
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/index.d.ts +2 -0
- package/operations/entry/index.js +11 -10
- package/operations/entry/index.js.map +1 -1
- package/operations/model/index.d.ts +2 -0
- package/operations/model/index.js +2 -18
- package/operations/model/index.js.map +1 -1
- package/package.json +23 -23
- package/tasks/createIndexTaskPlugin.js +14 -23
- package/tasks/createIndexTaskPlugin.js.map +1 -1
- package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.d.ts +0 -11
- package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js +0 -17
- package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js.map +0 -1
- package/features/CmsEntryOpenSearchIndex/abstractions.d.ts +0 -14
- package/features/CmsEntryOpenSearchIndex/abstractions.js +0 -5
- package/features/CmsEntryOpenSearchIndex/abstractions.js.map +0 -1
- package/features/CmsEntryOpenSearchIndex/feature.js +0 -11
- package/features/CmsEntryOpenSearchIndex/feature.js.map +0 -1
- package/features/CmsEntryOpenSearchIndex/index.d.ts +0 -3
- package/features/CmsEntryOpenSearchIndex/index.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/elasticsearch/body.js","sources":["../../../../src/operations/entry/elasticsearch/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 type { CmsEntryOpenSearchBodyModifier } from \"~/features/CmsEntryOpenSearchBodyModifier/index.js\";\nimport type { CmsEntryOpenSearchSortModifier } from \"~/features/CmsEntryOpenSearchSortModifier/index.js\";\nimport type { CmsEntryOpenSearchQueryModifier } from \"~/features/CmsEntryOpenSearchQueryModifier/index.js\";\nimport type { CmsEntryOpenSearchValueSearchRegistry } from \"~/features/CmsEntryOpenSearchValueSearch/index.js\";\nimport type { CmsEntryOpenSearchFullTextSearch } from \"~/features/CmsEntryOpenSearchFullTextSearch/index.js\";\nimport { createElasticsearchSort } from \"./sort.js\";\nimport type {\n PrimitiveValue,\n QueryDslBoolQuery as BoolQueryConfig,\n SearchBody\n} from \"@webiny/api-opensearch/types.js\";\nimport { createExecFiltering } from \"./filtering/index.js\";\nimport { assignMinimumShouldMatchToQuery } from \"./assignMinimumShouldMatchToQuery.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/features/graphql/index.js\";\nimport { CmsEntryOpenSearchFieldIndexRegistry } from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\nimport type { CmsEntryOpenSearchFilterRegistry } from \"~/features/CmsEntryOpenSearchFilter/index.js\";\n\ninterface ICreateElasticsearchBodyParams {\n plugins: PluginsContainer;\n model: CmsModel;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;\n bodyModifiers: CmsEntryOpenSearchBodyModifier.Interface[];\n sortModifiers: CmsEntryOpenSearchSortModifier.Interface[];\n queryModifiers: CmsEntryOpenSearchQueryModifier.Interface[];\n valueSearchRegistry: CmsEntryOpenSearchValueSearchRegistry.Interface;\n fullTextSearches: CmsEntryOpenSearchFullTextSearch.Interface[];\n filterRegistry: CmsEntryOpenSearchFilterRegistry.Interface;\n params: Omit<CmsEntryListParams, \"where\" | \"after\"> & {\n where: CmsEntryListWhere;\n after?: PrimitiveValue[];\n };\n}\nexport const createElasticsearchBody = ({\n plugins,\n model,\n params,\n fieldRegistry,\n fieldIndexRegistry,\n bodyModifiers,\n sortModifiers,\n queryModifiers,\n valueSearchRegistry,\n fullTextSearches,\n filterRegistry\n}: ICreateElasticsearchBodyParams): 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 model,\n fieldRegistry,\n fieldIndexRegistry\n });\n\n /**\n * Filter query modifiers applicable to this model.\n */\n const applicableQueryModifiers = queryModifiers.filter(m => {\n return !m.modelId || m.modelId === model.modelId;\n });\n /**\n * Filter sort modifiers applicable to this model.\n */\n const applicableSortModifiers = sortModifiers.filter(\n m => !m.modelId || m.modelId === model.modelId\n );\n /**\n * Filter body modifiers applicable to this model.\n */\n const applicableBodyModifiers = bodyModifiers.filter(m => {\n return !m.modelId || m.modelId === model.modelId;\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 fullTextSearches,\n query,\n term,\n fields: fullTextSearchFields\n });\n\n const execFiltering = createExecFiltering({\n model,\n fields: modelFields,\n plugins,\n valueSearchRegistry,\n filterRegistry\n });\n\n execFiltering({\n where,\n query\n });\n\n for (const modifier of applicableQueryModifiers) {\n modifier.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSort({\n sort: initialSort,\n modelFields,\n model,\n valueSearchRegistry\n });\n\n for (const modifier of applicableSortModifiers) {\n modifier.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 modifier of applicableBodyModifiers) {\n modifier.modifyBody({\n body,\n model,\n where\n });\n }\n\n return body;\n};\n"],"names":["createElasticsearchBody","plugins","model","params","fieldRegistry","fieldIndexRegistry","bodyModifiers","sortModifiers","queryModifiers","valueSearchRegistry","fullTextSearches","filterRegistry","fields","term","where","initialSort","after","limit","modelFields","createModelFields","applicableQueryModifiers","m","applicableSortModifiers","applicableBodyModifiers","fullTextSearchFields","createFullTextSearchFields","query","createInitialQuery","applyFullTextSearch","execFiltering","createExecFiltering","modifier","sort","createElasticsearchSort","boolQuery","undefined","assignMinimumShouldMatchToQuery","body"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"operations/entry/elasticsearch/body.js","sources":["../../../../src/operations/entry/elasticsearch/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 type { CmsEntryOpenSearchBodyModifier } from \"~/features/CmsEntryOpenSearchBodyModifier/index.js\";\nimport type { CmsEntryOpenSearchSortModifier } from \"~/features/CmsEntryOpenSearchSortModifier/index.js\";\nimport type { CmsEntryOpenSearchQueryModifier } from \"~/features/CmsEntryOpenSearchQueryModifier/index.js\";\nimport type { CmsEntryOpenSearchValueSearchRegistry } from \"~/features/CmsEntryOpenSearchValueSearch/index.js\";\nimport type { CmsEntryOpenSearchFullTextSearch } from \"~/features/CmsEntryOpenSearchFullTextSearch/index.js\";\nimport { createElasticsearchSort } from \"./sort.js\";\nimport type {\n PrimitiveValue,\n QueryDslBoolQuery as BoolQueryConfig,\n SearchBody\n} from \"@webiny/api-opensearch/types.js\";\nimport { createExecFiltering } from \"./filtering/index.js\";\nimport { assignMinimumShouldMatchToQuery } from \"./assignMinimumShouldMatchToQuery.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/features/graphql/index.js\";\nimport { CmsEntryOpenSearchFieldIndexRegistry } from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\nimport type { CmsEntryOpenSearchFilterRegistry } from \"~/features/CmsEntryOpenSearchFilter/index.js\";\n\ninterface ICreateElasticsearchBodyParams {\n plugins: PluginsContainer;\n model: CmsModel;\n shared: boolean;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;\n bodyModifiers: CmsEntryOpenSearchBodyModifier.Interface[];\n sortModifiers: CmsEntryOpenSearchSortModifier.Interface[];\n queryModifiers: CmsEntryOpenSearchQueryModifier.Interface[];\n valueSearchRegistry: CmsEntryOpenSearchValueSearchRegistry.Interface;\n fullTextSearches: CmsEntryOpenSearchFullTextSearch.Interface[];\n filterRegistry: CmsEntryOpenSearchFilterRegistry.Interface;\n params: Omit<CmsEntryListParams, \"where\" | \"after\"> & {\n where: CmsEntryListWhere;\n after?: PrimitiveValue[];\n };\n}\nexport const createElasticsearchBody = ({\n plugins,\n model,\n shared,\n params,\n fieldRegistry,\n fieldIndexRegistry,\n bodyModifiers,\n sortModifiers,\n queryModifiers,\n valueSearchRegistry,\n fullTextSearches,\n filterRegistry\n}: ICreateElasticsearchBodyParams): 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 model,\n fieldRegistry,\n fieldIndexRegistry\n });\n\n /**\n * Filter query modifiers applicable to this model.\n */\n const applicableQueryModifiers = queryModifiers.filter(m => {\n return !m.modelId || m.modelId === model.modelId;\n });\n /**\n * Filter sort modifiers applicable to this model.\n */\n const applicableSortModifiers = sortModifiers.filter(\n m => !m.modelId || m.modelId === model.modelId\n );\n /**\n * Filter body modifiers applicable to this model.\n */\n const applicableBodyModifiers = bodyModifiers.filter(m => {\n return !m.modelId || m.modelId === model.modelId;\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 shared\n });\n /**\n * Apply the full text search, if term is set.\n */\n applyFullTextSearch({\n model,\n fullTextSearches,\n query,\n term,\n fields: fullTextSearchFields\n });\n\n const execFiltering = createExecFiltering({\n model,\n fields: modelFields,\n plugins,\n valueSearchRegistry,\n filterRegistry\n });\n\n execFiltering({\n where,\n query\n });\n\n for (const modifier of applicableQueryModifiers) {\n modifier.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSort({\n sort: initialSort,\n modelFields,\n model,\n valueSearchRegistry\n });\n\n for (const modifier of applicableSortModifiers) {\n modifier.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 modifier of applicableBodyModifiers) {\n modifier.modifyBody({\n body,\n model,\n where\n });\n }\n\n return body;\n};\n"],"names":["createElasticsearchBody","plugins","model","shared","params","fieldRegistry","fieldIndexRegistry","bodyModifiers","sortModifiers","queryModifiers","valueSearchRegistry","fullTextSearches","filterRegistry","fields","term","where","initialSort","after","limit","modelFields","createModelFields","applicableQueryModifiers","m","applicableSortModifiers","applicableBodyModifiers","fullTextSearchFields","createFullTextSearchFields","query","createInitialQuery","applyFullTextSearch","execFiltering","createExecFiltering","modifier","sort","createElasticsearchSort","boolQuery","undefined","assignMinimumShouldMatchToQuery","body"],"mappings":";;;;;;;AA4CO,MAAMA,0BAA0B,CAAC,EACpCC,OAAO,EACPC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,kBAAkB,EAClBC,aAAa,EACbC,aAAa,EACbC,cAAc,EACdC,mBAAmB,EACnBC,gBAAgB,EAChBC,cAAc,EACe;IAC7B,MAAM,EAAEC,MAAM,EAAE,QAAQC,IAAI,EAAEC,KAAK,EAAE,MAAMC,WAAW,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGd;IAIzE,MAAMe,cAAcC,kBAAkB;QAClClB;QACAG;QACAC;IACJ;IAKA,MAAMe,2BAA2BZ,eAAe,MAAM,CAACa,CAAAA,IAC5C,CAACA,EAAE,OAAO,IAAIA,EAAE,OAAO,KAAKpB,MAAM,OAAO;IAKpD,MAAMqB,0BAA0Bf,cAAc,MAAM,CAChDc,CAAAA,IAAK,CAACA,EAAE,OAAO,IAAIA,EAAE,OAAO,KAAKpB,MAAM,OAAO;IAKlD,MAAMsB,0BAA0BjB,cAAc,MAAM,CAACe,CAAAA,IAC1C,CAACA,EAAE,OAAO,IAAIA,EAAE,OAAO,KAAKpB,MAAM,OAAO;IAMpD,MAAMuB,uBAAuBC,2BAA2B;QACpD,QAAQP;QACRL;QACA,SAASD;IACb;IAIA,MAAMc,QAAQC,mBAAmB;QAC7Bb;QACAb;QACAC;IACJ;IAIA0B,oBAAoB;QAChB3B;QACAS;QACAgB;QACAb;QACA,QAAQW;IACZ;IAEA,MAAMK,gBAAgBC,oBAAoB;QACtC7B;QACA,QAAQiB;QACRlB;QACAS;QACAE;IACJ;IAEAkB,cAAc;QACVf;QACAY;IACJ;IAEA,KAAK,MAAMK,YAAYX,yBACnBW,SAAS,WAAW,CAAC;QAAEL;QAAOzB;QAAOa;IAAM;IAG/C,MAAMkB,OAAOC,wBAAwB;QACjC,MAAMlB;QACNG;QACAjB;QACAQ;IACJ;IAEA,KAAK,MAAMsB,YAAYT,wBACnBS,SAAS,UAAU,CAAC;QAChBC;QACA/B;IACJ;IAGJ,MAAMiC,YAA6B;QAC/B,MAAMR,MAAM,IAAI,CAAC,MAAM,GAAG,IAAIA,MAAM,IAAI,GAAGS;QAC3C,UAAUT,MAAM,QAAQ,CAAC,MAAM,GAAG,IAAIA,MAAM,QAAQ,GAAGS;QACvD,QAAQT,MAAM,MAAM,CAAC,MAAM,GAAG,IAAIA,MAAM,MAAM,GAAGS;QACjD,QAAQT,MAAM,MAAM,CAAC,MAAM,GAAG,IAAIA,MAAM,MAAM,GAAGS;IACrD;IAEAC,gCAAgC;QAC5B,OAAOF;IACX;IAEA,MAAMG,OAAmB;QACrB,OAAO;YACH,MAAMH;QACV;QACAF;QACA,MAAOf,AAAAA,CAAAA,SAAS,KAAK;QACrB,cAAcD;QACd,kBAAkB;IACtB;IAEA,KAAK,MAAMe,YAAYR,wBACnBQ,SAAS,UAAU,CAAC;QAChBM;QACApC;QACAa;IACJ;IAGJ,OAAOuB;AACX"}
|
|
@@ -4,6 +4,7 @@ export declare const createBaseQuery: () => OpenSearchBoolQueryConfig;
|
|
|
4
4
|
interface Params {
|
|
5
5
|
model: CmsModel;
|
|
6
6
|
where: CmsEntryListWhere;
|
|
7
|
+
shared: boolean;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import error from "@webiny/error";
|
|
2
2
|
import { createLatestRecordType, createPublishedRecordType } from "../recordType.js";
|
|
3
|
-
import { isSharedOpenSearchIndex } from "@webiny/api-opensearch";
|
|
4
3
|
const createBaseQuery = ()=>({
|
|
5
4
|
must: [],
|
|
6
5
|
must_not: [],
|
|
@@ -8,10 +7,9 @@ const createBaseQuery = ()=>({
|
|
|
8
7
|
filter: []
|
|
9
8
|
});
|
|
10
9
|
const createInitialQuery = (params)=>{
|
|
11
|
-
const { model, where } = params;
|
|
10
|
+
const { model, where, shared } = params;
|
|
12
11
|
const query = createBaseQuery();
|
|
13
|
-
|
|
14
|
-
if (sharedIndex) {
|
|
12
|
+
if (shared) {
|
|
15
13
|
query.filter.push({
|
|
16
14
|
term: {
|
|
17
15
|
"tenant.keyword": model.tenant
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/elasticsearch/initialQuery.js","sources":["../../../../src/operations/entry/elasticsearch/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\";\
|
|
1
|
+
{"version":3,"file":"operations/entry/elasticsearch/initialQuery.js","sources":["../../../../src/operations/entry/elasticsearch/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\";\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 shared: boolean;\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, shared } = 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 if (shared) {\n query.filter.push({\n term: {\n \"tenant.keyword\": model.tenant\n }\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"],"names":["createBaseQuery","createInitialQuery","params","model","where","shared","query","createPublishedRecordType","createLatestRecordType","WebinyError"],"mappings":";;AAKO,MAAMA,kBAAkB,IACpB;QACH,MAAM,EAAE;QACR,UAAU,EAAE;QACZ,QAAQ,EAAE;QACV,QAAQ,EAAE;IACd;AAgBG,MAAMC,qBAAqB,CAACC;IAC/B,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAE,GAAGH;IAEjC,MAAMI,QAAQN;IAKd,IAAIK,QAAQ;QACRC,MAAM,MAAM,CAAC,IAAI,CAAC;YACd,MAAM;gBACF,kBAAkBH,MAAM,MAAM;YAClC;QACJ;QACAG,MAAM,MAAM,CAAC,IAAI,CAAC;YACd,MAAM;gBACF,mBAAmBH,MAAM,OAAO;YACpC;QACJ;IACJ;IAKA,IAAIC,AAAoB,SAApBA,MAAM,SAAS,EACfE,MAAM,MAAM,CAAC,IAAI,CAAC;QACd,MAAM;YACF,kBAAkBC;QACtB;IACJ;SACG,IAAIH,AAAiB,SAAjBA,MAAM,MAAM,EACnBE,MAAM,MAAM,CAAC,IAAI,CAAC;QACd,MAAM;YACF,kBAAkBE;QACtB;IACJ;SAQA,MAAM,IAAIC,MACN,6EACA,gCACA;QACIL;IACJ;IAOR,OAAOA,MAAM,SAAS;IACtB,OAAOA,MAAM,MAAM;IAEnB,OAAOE;AACX"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Configurations } from "../../configurations.js";
|
|
1
2
|
import type { Client } from "@webiny/api-opensearch";
|
|
2
3
|
import { type IOpenSearchEntity as IElasticsearchEntity } from "@webiny/api-opensearch";
|
|
3
4
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
@@ -18,6 +19,7 @@ export interface CreateEntriesStorageOperationsParams {
|
|
|
18
19
|
esEntity: IElasticsearchEntity;
|
|
19
20
|
elasticsearch: Client;
|
|
20
21
|
plugins: PluginsContainer;
|
|
22
|
+
configurations: Configurations;
|
|
21
23
|
fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;
|
|
22
24
|
fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;
|
|
23
25
|
compressionHandler: CompressionHandler.Interface;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
2
|
import { CONTENT_ENTRY_STATUS } from "@webiny/api-headless-cms/types/index.js";
|
|
3
3
|
import { extractEntriesFromIndex } from "../../helpers/index.js";
|
|
4
|
-
import { configurations } from "../../configurations.js";
|
|
5
4
|
import { createLimit, decodeCursor, encodeCursor } from "@webiny/api-opensearch";
|
|
6
5
|
import { DataLoadersHandler } from "./dataLoaders.js";
|
|
7
6
|
import { createEntryLatestKeys, createEntryPublishedKeys, createEntryRevisionKeys, createLatestSortKey, createPartitionKey, createPublishedSortKey, createRevisionSortKey } from "./keys.js";
|
|
@@ -24,7 +23,7 @@ const convertToStorageEntry = (params)=>{
|
|
|
24
23
|
};
|
|
25
24
|
};
|
|
26
25
|
const createEntriesStorageOperations = (params)=>{
|
|
27
|
-
const { entity, esEntity, elasticsearch, plugins, fieldRegistry, fieldIndexRegistry, compressionHandler, bodyModifiers, sortModifiers, queryModifiers, valueSearchRegistry, fullTextSearches, valuesModifiers, filterRegistry } = params;
|
|
26
|
+
const { entity, esEntity, elasticsearch, plugins, configurations, fieldRegistry, fieldIndexRegistry, compressionHandler, bodyModifiers, sortModifiers, queryModifiers, valueSearchRegistry, fullTextSearches, valuesModifiers, filterRegistry } = params;
|
|
28
27
|
let storageOperationsCmsModelPlugin;
|
|
29
28
|
const getStorageOperationsCmsModelPlugin = ()=>{
|
|
30
29
|
if (storageOperationsCmsModelPlugin) return storageOperationsCmsModelPlugin;
|
|
@@ -55,7 +54,7 @@ const createEntriesStorageOperations = (params)=>{
|
|
|
55
54
|
});
|
|
56
55
|
const { entry, storageEntry } = transformer.transformEntryKeys();
|
|
57
56
|
const esEntry = transformer.transformToIndex();
|
|
58
|
-
const { index: esIndex } = configurations.es({
|
|
57
|
+
const { index: esIndex } = await configurations.es({
|
|
59
58
|
model
|
|
60
59
|
});
|
|
61
60
|
const revisionKeys = createEntryRevisionKeys(entry);
|
|
@@ -190,7 +189,7 @@ const createEntriesStorageOperations = (params)=>{
|
|
|
190
189
|
storageEntry
|
|
191
190
|
});
|
|
192
191
|
}
|
|
193
|
-
const { index: esIndex } = configurations.es({
|
|
192
|
+
const { index: esIndex } = await configurations.es({
|
|
194
193
|
model
|
|
195
194
|
});
|
|
196
195
|
const elasticsearchEntityBatch = esEntity.createEntityWriter({
|
|
@@ -268,7 +267,7 @@ const createEntriesStorageOperations = (params)=>{
|
|
|
268
267
|
}
|
|
269
268
|
});
|
|
270
269
|
const elasticsearchEntityBatch = esEntity.createEntityWriter();
|
|
271
|
-
const { index: esIndex } = configurations.es({
|
|
270
|
+
const { index: esIndex } = await configurations.es({
|
|
272
271
|
model
|
|
273
272
|
});
|
|
274
273
|
if (latestStorageEntry) {
|
|
@@ -681,7 +680,7 @@ const createEntriesStorageOperations = (params)=>{
|
|
|
681
680
|
id: entry.id,
|
|
682
681
|
tenant: model.tenant
|
|
683
682
|
});
|
|
684
|
-
const { index } = configurations.es({
|
|
683
|
+
const { index } = await configurations.es({
|
|
685
684
|
model
|
|
686
685
|
});
|
|
687
686
|
const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
@@ -818,11 +817,12 @@ const createEntriesStorageOperations = (params)=>{
|
|
|
818
817
|
const list = async (initialModel, params)=>{
|
|
819
818
|
const model = getStorageOperationsModel(initialModel);
|
|
820
819
|
const limit = createLimit(params.limit, 50);
|
|
821
|
-
const { index } = configurations.es({
|
|
820
|
+
const { index, shared } = await configurations.es({
|
|
822
821
|
model
|
|
823
822
|
});
|
|
824
823
|
const body = createElasticsearchBody({
|
|
825
824
|
model,
|
|
825
|
+
shared,
|
|
826
826
|
fieldRegistry,
|
|
827
827
|
fieldIndexRegistry,
|
|
828
828
|
bodyModifiers,
|
|
@@ -942,7 +942,7 @@ const createEntriesStorageOperations = (params)=>{
|
|
|
942
942
|
]
|
|
943
943
|
});
|
|
944
944
|
const elasticsearchEntityWriter = esEntity.createEntityWriter();
|
|
945
|
-
const { index: esIndex } = configurations.es({
|
|
945
|
+
const { index: esIndex } = await configurations.es({
|
|
946
946
|
model
|
|
947
947
|
});
|
|
948
948
|
const publishedRevisionId = publishedStorageEntry?.id;
|
|
@@ -1116,7 +1116,7 @@ const createEntriesStorageOperations = (params)=>{
|
|
|
1116
1116
|
]
|
|
1117
1117
|
});
|
|
1118
1118
|
if (latestStorageEntry?.id === entry.id) {
|
|
1119
|
-
const { index } = configurations.es({
|
|
1119
|
+
const { index } = await configurations.es({
|
|
1120
1120
|
model
|
|
1121
1121
|
});
|
|
1122
1122
|
const entryLatestKeys = createEntryLatestKeys(storageEntry);
|
|
@@ -1276,11 +1276,12 @@ const createEntriesStorageOperations = (params)=>{
|
|
|
1276
1276
|
};
|
|
1277
1277
|
const getUniqueFieldValues = async (model, params)=>{
|
|
1278
1278
|
const { where, fieldId } = params;
|
|
1279
|
-
const { index } = configurations.es({
|
|
1279
|
+
const { index, shared } = await configurations.es({
|
|
1280
1280
|
model
|
|
1281
1281
|
});
|
|
1282
1282
|
const initialBody = createElasticsearchBody({
|
|
1283
1283
|
model,
|
|
1284
|
+
shared,
|
|
1284
1285
|
fieldRegistry,
|
|
1285
1286
|
fieldIndexRegistry,
|
|
1286
1287
|
bodyModifiers,
|