@webiny/api-page-builder-so-ddb-es 5.41.0-dbt.0 → 5.41.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.js +2 -2
- package/configurations.js.map +1 -1
- package/operations/pages/elasticsearchQueryBody.js +1 -1
- package/operations/pages/elasticsearchQueryBody.js.map +1 -1
- package/operations/pages/index.js +14 -1
- package/operations/pages/index.js.map +1 -1
- package/operations/pages/logIgnoredEsResponseError.d.ts +7 -0
- package/operations/pages/logIgnoredEsResponseError.js +28 -0
- package/operations/pages/logIgnoredEsResponseError.js.map +1 -0
- package/operations/pages/shouldIgnoreEsResponseError.d.ts +2 -0
- package/operations/pages/shouldIgnoreEsResponseError.js +13 -0
- package/operations/pages/shouldIgnoreEsResponseError.js.map +1 -0
- package/package.json +30 -30
package/configurations.js
CHANGED
|
@@ -17,7 +17,7 @@ const configurations = exports.configurations = {
|
|
|
17
17
|
if (!tenant) {
|
|
18
18
|
throw new _error.default(`Missing "tenant" parameter when trying to create Elasticsearch index name.`, "TENANT_ERROR");
|
|
19
19
|
}
|
|
20
|
-
const sharedIndex =
|
|
20
|
+
const sharedIndex = (0, _apiElasticsearch.isSharedElasticsearchIndex)();
|
|
21
21
|
const tenantId = sharedIndex ? "root" : tenant;
|
|
22
22
|
let localeCode = null;
|
|
23
23
|
if (process.env.WEBINY_ELASTICSEARCH_INDEX_LOCALE === "true") {
|
|
@@ -27,7 +27,7 @@ const configurations = exports.configurations = {
|
|
|
27
27
|
localeCode = locale;
|
|
28
28
|
}
|
|
29
29
|
const index = [tenantId, localeCode, "page-builder"].filter(Boolean).join("-").toLowerCase();
|
|
30
|
-
const prefix =
|
|
30
|
+
const prefix = (0, _apiElasticsearch.getElasticsearchIndexPrefix)();
|
|
31
31
|
if (!prefix) {
|
|
32
32
|
return {
|
|
33
33
|
index
|
package/configurations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_apiElasticsearch","_plugins","configurations","exports","es","params","tenant","locale","WebinyError","sharedIndex","
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_apiElasticsearch","_plugins","configurations","exports","es","params","tenant","locale","WebinyError","sharedIndex","isSharedElasticsearchIndex","tenantId","localeCode","process","env","WEBINY_ELASTICSEARCH_INDEX_LOCALE","index","filter","Boolean","join","toLowerCase","prefix","getElasticsearchIndexPrefix","indexSettings","context","plugin","getLastAddedIndexPlugin","container","plugins","type","PageElasticsearchIndexPlugin","body"],"sources":["configurations.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n getElasticsearchIndexPrefix,\n getLastAddedIndexPlugin,\n isSharedElasticsearchIndex\n} from \"@webiny/api-elasticsearch\";\nimport { PageElasticsearchIndexPlugin } from \"~/plugins\";\nimport { PbContext } from \"~/types\";\nimport { ElasticsearchIndexRequestBody } from \"@webiny/api-elasticsearch/types\";\n\nexport interface ConfigurationsElasticsearch {\n index: string;\n}\n\nexport interface ConfigurationsElasticsearchParams {\n tenant: string;\n locale: string;\n}\n\nexport interface ConfigurationsIndexSettingsParams {\n context: PbContext;\n locale: string;\n}\n\nexport interface Configurations {\n es: (params: ConfigurationsElasticsearchParams) => ConfigurationsElasticsearch;\n indexSettings: (\n params: ConfigurationsIndexSettingsParams\n ) => Partial<ElasticsearchIndexRequestBody>;\n}\n\nexport const configurations: Configurations = {\n es: params => {\n const { tenant, locale } = params;\n if (!tenant) {\n throw new WebinyError(\n `Missing \"tenant\" parameter when trying to create Elasticsearch index name.`,\n \"TENANT_ERROR\"\n );\n }\n const sharedIndex = isSharedElasticsearchIndex();\n\n const tenantId = sharedIndex ? \"root\" : tenant;\n let localeCode: string | null = null;\n if (process.env.WEBINY_ELASTICSEARCH_INDEX_LOCALE === \"true\") {\n if (!locale) {\n throw new WebinyError(\n `Missing \"locale\" parameter when trying to create Elasticsearch index name.`,\n \"LOCALE_ERROR\"\n );\n }\n localeCode = locale;\n }\n\n const index = [tenantId, localeCode, \"page-builder\"]\n .filter(Boolean)\n .join(\"-\")\n .toLowerCase();\n\n const prefix = getElasticsearchIndexPrefix();\n if (!prefix) {\n return {\n index\n };\n }\n return {\n index: prefix + index\n };\n },\n indexSettings: ({ context, locale }) => {\n const plugin = getLastAddedIndexPlugin<PageElasticsearchIndexPlugin>({\n container: context.plugins,\n type: PageElasticsearchIndexPlugin.type,\n locale\n });\n\n return plugin ? plugin.body : {};\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAF,OAAA;AAyBO,MAAMG,cAA8B,GAAAC,OAAA,CAAAD,cAAA,GAAG;EAC1CE,EAAE,EAAEC,MAAM,IAAI;IACV,MAAM;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGF,MAAM;IACjC,IAAI,CAACC,MAAM,EAAE;MACT,MAAM,IAAIE,cAAW,CAChB,4EAA2E,EAC5E,cACJ,CAAC;IACL;IACA,MAAMC,WAAW,GAAG,IAAAC,4CAA0B,EAAC,CAAC;IAEhD,MAAMC,QAAQ,GAAGF,WAAW,GAAG,MAAM,GAAGH,MAAM;IAC9C,IAAIM,UAAyB,GAAG,IAAI;IACpC,IAAIC,OAAO,CAACC,GAAG,CAACC,iCAAiC,KAAK,MAAM,EAAE;MAC1D,IAAI,CAACR,MAAM,EAAE;QACT,MAAM,IAAIC,cAAW,CAChB,4EAA2E,EAC5E,cACJ,CAAC;MACL;MACAI,UAAU,GAAGL,MAAM;IACvB;IAEA,MAAMS,KAAK,GAAG,CAACL,QAAQ,EAAEC,UAAU,EAAE,cAAc,CAAC,CAC/CK,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,CAAC,GAAG,CAAC,CACTC,WAAW,CAAC,CAAC;IAElB,MAAMC,MAAM,GAAG,IAAAC,6CAA2B,EAAC,CAAC;IAC5C,IAAI,CAACD,MAAM,EAAE;MACT,OAAO;QACHL;MACJ,CAAC;IACL;IACA,OAAO;MACHA,KAAK,EAAEK,MAAM,GAAGL;IACpB,CAAC;EACL,CAAC;EACDO,aAAa,EAAEA,CAAC;IAAEC,OAAO;IAAEjB;EAAO,CAAC,KAAK;IACpC,MAAMkB,MAAM,GAAG,IAAAC,yCAAuB,EAA+B;MACjEC,SAAS,EAAEH,OAAO,CAACI,OAAO;MAC1BC,IAAI,EAAEC,qCAA4B,CAACD,IAAI;MACvCtB;IACJ,CAAC,CAAC;IAEF,OAAOkB,MAAM,GAAGA,MAAM,CAACM,IAAI,GAAG,CAAC,CAAC;EACpC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -123,7 +123,7 @@ const createElasticsearchQuery = params => {
|
|
|
123
123
|
*
|
|
124
124
|
* When ES index is shared between tenants, we need to filter records by tenant ID.
|
|
125
125
|
*/
|
|
126
|
-
const sharedIndex =
|
|
126
|
+
const sharedIndex = (0, _apiElasticsearch.isSharedElasticsearchIndex)();
|
|
127
127
|
if (sharedIndex) {
|
|
128
128
|
const tenant = initialWhere.tenant;
|
|
129
129
|
query.must.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_apiElasticsearch","_PageElasticsearchFieldPlugin","_PageElasticsearchSortModifierPlugin","_PageElasticsearchQueryModifierPlugin","_PageElasticsearchBodyModifierPlugin","createInitialQueryValue","args","where","query","must","must_not","should","filter","published","push","term","latest","WebinyError","createElasticsearchQuery","params","plugins","initialWhere","fieldPlugins","operatorPlugins","getElasticsearchOperatorPluginsByLocale","locale","tags_in","tags","tags_rule","tagsRule","Array","isArray","length","terms","bool","map","tag","search","query_string","allow_leading_wildcard","fields","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","tenant","applyWhere","operators","createElasticsearchQueryBody","limit","initialLimit","sort","initialSort","after","byType","PageElasticsearchFieldPlugin","type","reduce","acc","plugin","field","createLimit","createSort","queryModifiers","PageElasticsearchQueryModifierPlugin","modifyQuery","sortModifiers","PageElasticsearchSortModifierPlugin","modifySort","body","constant_score","size","search_after","decodeCursor","bodyModifiers","PageElasticsearchBodyModifierPlugin","modifyBody","exports"],"sources":["elasticsearchQueryBody.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { SearchBody as esSearchBody } from \"elastic-ts\";\nimport {\n applyWhere,\n createLimit,\n createSort,\n decodeCursor,\n getElasticsearchOperatorPluginsByLocale\n} from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { PageStorageOperationsListWhere } from \"@webiny/api-page-builder/types\";\nimport { PageElasticsearchFieldPlugin } from \"~/plugins/definitions/PageElasticsearchFieldPlugin\";\nimport { PageElasticsearchSortModifierPlugin } from \"~/plugins/definitions/PageElasticsearchSortModifierPlugin\";\nimport { PageElasticsearchQueryModifierPlugin } from \"~/plugins/definitions/PageElasticsearchQueryModifierPlugin\";\nimport { PageElasticsearchBodyModifierPlugin } from \"~/plugins/definitions/PageElasticsearchBodyModifierPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface CreateElasticsearchQueryArgs {\n where: PageStorageOperationsListWhere;\n}\n\n/**\n * Latest and published are specific in Elasticsearch to that extend that they are tagged in the published or latest property.\n * We allow either published or either latest.\n * Latest is used in the manage API and published in the read API.\n */\nconst createInitialQueryValue = (\n args: CreateElasticsearchQueryArgs\n): ElasticsearchBoolQueryConfig => {\n const { where } = args;\n\n const query: ElasticsearchBoolQueryConfig = {\n must: [],\n must_not: [],\n should: [],\n filter: []\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.must.push({\n term: {\n published: true\n }\n });\n } else if (where.latest === true) {\n query.must.push({\n term: {\n latest: true\n }\n });\n }\n // we do not allow not published and not latest\n else if (where.published === false) {\n throw new WebinyError(\n `Cannot call Elasticsearch query with \"published\" set at false.`,\n \"ELASTICSEARCH_UNSUPPORTED_QUERY\",\n {\n where\n }\n );\n } else if (where.latest === false) {\n throw new WebinyError(\n `Cannot call Elasticsearch query with \"latest\" set at false.`,\n \"ELASTICSEARCH_UNSUPPORTED_QUERY\",\n {\n where\n }\n );\n }\n delete where.published;\n delete where.latest;\n //\n return query;\n};\n\ninterface CreateElasticsearchBodyParams {\n plugins: PluginsContainer;\n where: PageStorageOperationsListWhere;\n limit: number;\n after: string | null;\n sort: string[];\n fieldPlugins: Record<string, PageElasticsearchFieldPlugin>;\n}\n\nconst createElasticsearchQuery = (params: CreateElasticsearchBodyParams) => {\n const { plugins, where: initialWhere, fieldPlugins } = params;\n const query = createInitialQueryValue({\n where: initialWhere\n });\n /**\n * Be aware that, if having more registered operator plugins of same type, the last one will be used.\n */\n const operatorPlugins = getElasticsearchOperatorPluginsByLocale(plugins, initialWhere.locale);\n\n const where: Partial<PageStorageOperationsListWhere> = {\n ...initialWhere\n };\n /**\n * Tags are specific so extract them and remove from where.\n */\n const { tags_in: tags, tags_rule: tagsRule } = initialWhere;\n delete where[\"tags_in\"];\n delete where[\"tags_rule\"];\n if (tags && Array.isArray(tags) === true && tags.length > 0) {\n if (tagsRule === \"any\") {\n query.filter.push({\n terms: {\n \"tags.keyword\": tags\n }\n });\n } else {\n query.filter.push({\n bool: {\n must: tags.map(tag => {\n return {\n term: {\n \"tags.keyword\": tag\n }\n };\n })\n }\n });\n }\n }\n /**\n * Specific search parameter\n */\n if (where.search) {\n query.must.push({\n query_string: {\n query: `*${where.search}*`,\n allow_leading_wildcard: true,\n fields: [\"titleLC\", \"snippet\"]\n }\n });\n }\n delete where.search;\n\n /**\n * !!! IMPORTANT !!! There are few specific cases where we hardcode the query conditions.\n *\n * When ES index is shared between tenants, we need to filter records by tenant ID.\n */\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n if (sharedIndex) {\n const tenant = initialWhere.tenant;\n query.must.push({ term: { \"tenant.keyword\": tenant } });\n /**\n * Remove so it is not applied again later.\n * Possibly tenant is not defined, but just in case, remove it.\n */\n delete where[\"tenant\"];\n }\n /**\n * We apply other conditions as they are passed via the where value.\n */\n applyWhere({\n query,\n where,\n fields: fieldPlugins,\n operators: operatorPlugins\n });\n\n return query;\n};\n\nexport const createElasticsearchQueryBody = (\n params: Omit<CreateElasticsearchBodyParams, \"fieldPlugins\">\n): esSearchBody & Pick<Required<esSearchBody>, \"sort\"> => {\n const { plugins, where, limit: initialLimit, sort: initialSort, after } = params;\n\n const fieldPlugins = plugins\n .byType<PageElasticsearchFieldPlugin>(PageElasticsearchFieldPlugin.type)\n .reduce((acc, plugin) => {\n acc[plugin.field] = plugin;\n return acc;\n }, {} as Record<string, PageElasticsearchFieldPlugin>);\n\n const limit = createLimit(initialLimit, 100);\n\n const query = createElasticsearchQuery({\n ...params,\n fieldPlugins\n });\n\n const sort = createSort({\n sort: initialSort,\n fieldPlugins\n });\n\n const queryModifiers = plugins.byType<PageElasticsearchQueryModifierPlugin>(\n PageElasticsearchQueryModifierPlugin.type\n );\n for (const plugin of queryModifiers) {\n plugin.modifyQuery({\n query,\n where,\n sort,\n limit\n });\n }\n\n const sortModifiers = plugins.byType<PageElasticsearchSortModifierPlugin>(\n PageElasticsearchSortModifierPlugin.type\n );\n for (const plugin of sortModifiers) {\n plugin.modifySort({\n sort,\n where\n });\n }\n\n const body = {\n query: {\n constant_score: {\n filter: {\n bool: {\n ...query\n }\n }\n }\n },\n size: limit + 1,\n search_after: decodeCursor(after),\n sort\n };\n\n const bodyModifiers = plugins.byType<PageElasticsearchBodyModifierPlugin>(\n PageElasticsearchBodyModifierPlugin.type\n );\n for (const plugin of bodyModifiers) {\n plugin.modifyBody({\n body,\n where\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AASA,IAAAE,6BAAA,GAAAF,OAAA;AACA,IAAAG,oCAAA,GAAAH,OAAA;AACA,IAAAI,qCAAA,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AACM,WAAW,CAAC;MACfzD,KAAK;MACLD,KAAK;MACL4C,IAAI;MACJF;IACJ,CAAC,CAAC;EACN;EAEA,MAAMiB,aAAa,GAAG9C,OAAO,CAACkC,MAAM,CAChCa,wEAAmC,CAACX,IACxC,CAAC;EACD,KAAK,MAAMG,MAAM,IAAIO,aAAa,EAAE;IAChCP,MAAM,CAACS,UAAU,CAAC;MACdjB,IAAI;MACJ5C;IACJ,CAAC,CAAC;EACN;EAEA,MAAM8D,IAAI,GAAG;IACT7D,KAAK,EAAE;MACH8D,cAAc,EAAE;QACZ1D,MAAM,EAAE;UACJsB,IAAI,EAAE;YACF,GAAG1B;UACP;QACJ;MACJ;IACJ,CAAC;IACD+D,IAAI,EAAEtB,KAAK,GAAG,CAAC;IACfuB,YAAY,EAAE,IAAAC,8BAAY,EAACpB,KAAK,CAAC;IACjCF;EACJ,CAAC;EAED,MAAMuB,aAAa,GAAGtD,OAAO,CAACkC,MAAM,CAChCqB,wEAAmC,CAACnB,IACxC,CAAC;EACD,KAAK,MAAMG,MAAM,IAAIe,aAAa,EAAE;IAChCf,MAAM,CAACiB,UAAU,CAAC;MACdP,IAAI;MACJ9D;IACJ,CAAC,CAAC;EACN;EAEA,OAAO8D,IAAI;AACf,CAAC;AAACQ,OAAA,CAAA7B,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_apiElasticsearch","_PageElasticsearchFieldPlugin","_PageElasticsearchSortModifierPlugin","_PageElasticsearchQueryModifierPlugin","_PageElasticsearchBodyModifierPlugin","createInitialQueryValue","args","where","query","must","must_not","should","filter","published","push","term","latest","WebinyError","createElasticsearchQuery","params","plugins","initialWhere","fieldPlugins","operatorPlugins","getElasticsearchOperatorPluginsByLocale","locale","tags_in","tags","tags_rule","tagsRule","Array","isArray","length","terms","bool","map","tag","search","query_string","allow_leading_wildcard","fields","sharedIndex","isSharedElasticsearchIndex","tenant","applyWhere","operators","createElasticsearchQueryBody","limit","initialLimit","sort","initialSort","after","byType","PageElasticsearchFieldPlugin","type","reduce","acc","plugin","field","createLimit","createSort","queryModifiers","PageElasticsearchQueryModifierPlugin","modifyQuery","sortModifiers","PageElasticsearchSortModifierPlugin","modifySort","body","constant_score","size","search_after","decodeCursor","bodyModifiers","PageElasticsearchBodyModifierPlugin","modifyBody","exports"],"sources":["elasticsearchQueryBody.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { SearchBody as esSearchBody } from \"elastic-ts\";\nimport {\n applyWhere,\n createLimit,\n createSort,\n decodeCursor,\n getElasticsearchOperatorPluginsByLocale,\n isSharedElasticsearchIndex\n} from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { PageStorageOperationsListWhere } from \"@webiny/api-page-builder/types\";\nimport { PageElasticsearchFieldPlugin } from \"~/plugins/definitions/PageElasticsearchFieldPlugin\";\nimport { PageElasticsearchSortModifierPlugin } from \"~/plugins/definitions/PageElasticsearchSortModifierPlugin\";\nimport { PageElasticsearchQueryModifierPlugin } from \"~/plugins/definitions/PageElasticsearchQueryModifierPlugin\";\nimport { PageElasticsearchBodyModifierPlugin } from \"~/plugins/definitions/PageElasticsearchBodyModifierPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface CreateElasticsearchQueryArgs {\n where: PageStorageOperationsListWhere;\n}\n\n/**\n * Latest and published are specific in Elasticsearch to that extend that they are tagged in the published or latest property.\n * We allow either published or either latest.\n * Latest is used in the manage API and published in the read API.\n */\nconst createInitialQueryValue = (\n args: CreateElasticsearchQueryArgs\n): ElasticsearchBoolQueryConfig => {\n const { where } = args;\n\n const query: ElasticsearchBoolQueryConfig = {\n must: [],\n must_not: [],\n should: [],\n filter: []\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.must.push({\n term: {\n published: true\n }\n });\n } else if (where.latest === true) {\n query.must.push({\n term: {\n latest: true\n }\n });\n }\n // we do not allow not published and not latest\n else if (where.published === false) {\n throw new WebinyError(\n `Cannot call Elasticsearch query with \"published\" set at false.`,\n \"ELASTICSEARCH_UNSUPPORTED_QUERY\",\n {\n where\n }\n );\n } else if (where.latest === false) {\n throw new WebinyError(\n `Cannot call Elasticsearch query with \"latest\" set at false.`,\n \"ELASTICSEARCH_UNSUPPORTED_QUERY\",\n {\n where\n }\n );\n }\n delete where.published;\n delete where.latest;\n //\n return query;\n};\n\ninterface CreateElasticsearchBodyParams {\n plugins: PluginsContainer;\n where: PageStorageOperationsListWhere;\n limit: number;\n after: string | null;\n sort: string[];\n fieldPlugins: Record<string, PageElasticsearchFieldPlugin>;\n}\n\nconst createElasticsearchQuery = (params: CreateElasticsearchBodyParams) => {\n const { plugins, where: initialWhere, fieldPlugins } = params;\n const query = createInitialQueryValue({\n where: initialWhere\n });\n /**\n * Be aware that, if having more registered operator plugins of same type, the last one will be used.\n */\n const operatorPlugins = getElasticsearchOperatorPluginsByLocale(plugins, initialWhere.locale);\n\n const where: Partial<PageStorageOperationsListWhere> = {\n ...initialWhere\n };\n /**\n * Tags are specific so extract them and remove from where.\n */\n const { tags_in: tags, tags_rule: tagsRule } = initialWhere;\n delete where[\"tags_in\"];\n delete where[\"tags_rule\"];\n if (tags && Array.isArray(tags) === true && tags.length > 0) {\n if (tagsRule === \"any\") {\n query.filter.push({\n terms: {\n \"tags.keyword\": tags\n }\n });\n } else {\n query.filter.push({\n bool: {\n must: tags.map(tag => {\n return {\n term: {\n \"tags.keyword\": tag\n }\n };\n })\n }\n });\n }\n }\n /**\n * Specific search parameter\n */\n if (where.search) {\n query.must.push({\n query_string: {\n query: `*${where.search}*`,\n allow_leading_wildcard: true,\n fields: [\"titleLC\", \"snippet\"]\n }\n });\n }\n delete where.search;\n\n /**\n * !!! IMPORTANT !!! There are few specific cases where we hardcode the query conditions.\n *\n * When ES index is shared between tenants, we need to filter records by tenant ID.\n */\n const sharedIndex = isSharedElasticsearchIndex();\n if (sharedIndex) {\n const tenant = initialWhere.tenant;\n query.must.push({ term: { \"tenant.keyword\": tenant } });\n /**\n * Remove so it is not applied again later.\n * Possibly tenant is not defined, but just in case, remove it.\n */\n delete where[\"tenant\"];\n }\n /**\n * We apply other conditions as they are passed via the where value.\n */\n applyWhere({\n query,\n where,\n fields: fieldPlugins,\n operators: operatorPlugins\n });\n\n return query;\n};\n\nexport const createElasticsearchQueryBody = (\n params: Omit<CreateElasticsearchBodyParams, \"fieldPlugins\">\n): esSearchBody & Pick<Required<esSearchBody>, \"sort\"> => {\n const { plugins, where, limit: initialLimit, sort: initialSort, after } = params;\n\n const fieldPlugins = plugins\n .byType<PageElasticsearchFieldPlugin>(PageElasticsearchFieldPlugin.type)\n .reduce((acc, plugin) => {\n acc[plugin.field] = plugin;\n return acc;\n }, {} as Record<string, PageElasticsearchFieldPlugin>);\n\n const limit = createLimit(initialLimit, 100);\n\n const query = createElasticsearchQuery({\n ...params,\n fieldPlugins\n });\n\n const sort = createSort({\n sort: initialSort,\n fieldPlugins\n });\n\n const queryModifiers = plugins.byType<PageElasticsearchQueryModifierPlugin>(\n PageElasticsearchQueryModifierPlugin.type\n );\n for (const plugin of queryModifiers) {\n plugin.modifyQuery({\n query,\n where,\n sort,\n limit\n });\n }\n\n const sortModifiers = plugins.byType<PageElasticsearchSortModifierPlugin>(\n PageElasticsearchSortModifierPlugin.type\n );\n for (const plugin of sortModifiers) {\n plugin.modifySort({\n sort,\n where\n });\n }\n\n const body = {\n query: {\n constant_score: {\n filter: {\n bool: {\n ...query\n }\n }\n }\n },\n size: limit + 1,\n search_after: decodeCursor(after),\n sort\n };\n\n const bodyModifiers = plugins.byType<PageElasticsearchBodyModifierPlugin>(\n PageElasticsearchBodyModifierPlugin.type\n );\n for (const plugin of bodyModifiers) {\n plugin.modifyBody({\n body,\n where\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,iBA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0EAAoC,CAACR,IACzC,CAAC;EACD,KAAK,MAAMG,MAAM,IAAII,cAAc,EAAE;IACjCJ,MAAM,CAACM,WAAW,CAAC;MACfvD,KAAK;MACLD,KAAK;MACL0C,IAAI;MACJF;IACJ,CAAC,CAAC;EACN;EAEA,MAAMiB,aAAa,GAAG5C,OAAO,CAACgC,MAAM,CAChCa,wEAAmC,CAACX,IACxC,CAAC;EACD,KAAK,MAAMG,MAAM,IAAIO,aAAa,EAAE;IAChCP,MAAM,CAACS,UAAU,CAAC;MACdjB,IAAI;MACJ1C;IACJ,CAAC,CAAC;EACN;EAEA,MAAM4D,IAAI,GAAG;IACT3D,KAAK,EAAE;MACH4D,cAAc,EAAE;QACZxD,MAAM,EAAE;UACJsB,IAAI,EAAE;YACF,GAAG1B;UACP;QACJ;MACJ;IACJ,CAAC;IACD6D,IAAI,EAAEtB,KAAK,GAAG,CAAC;IACfuB,YAAY,EAAE,IAAAC,8BAAY,EAACpB,KAAK,CAAC;IACjCF;EACJ,CAAC;EAED,MAAMuB,aAAa,GAAGpD,OAAO,CAACgC,MAAM,CAChCqB,wEAAmC,CAACnB,IACxC,CAAC;EACD,KAAK,MAAMG,MAAM,IAAIe,aAAa,EAAE;IAChCf,MAAM,CAACiB,UAAU,CAAC;MACdP,IAAI;MACJ5D;IACJ,CAAC,CAAC;EACN;EAEA,OAAO4D,IAAI;AACf,CAAC;AAACQ,OAAA,CAAA7B,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
@@ -20,6 +20,8 @@ var _keys = require("./keys");
|
|
|
20
20
|
var _sort = require("@webiny/db-dynamodb/utils/sort");
|
|
21
21
|
var _PageDynamoDbElasticsearchFieldPlugin = require("../../plugins/definitions/PageDynamoDbElasticsearchFieldPlugin");
|
|
22
22
|
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
23
|
+
var _shouldIgnoreEsResponseError = require("./shouldIgnoreEsResponseError");
|
|
24
|
+
var _logIgnoredEsResponseError = require("./logIgnoredEsResponseError");
|
|
23
25
|
/**
|
|
24
26
|
* This function removes attributes that were once present in the Page record, which we no longer need.
|
|
25
27
|
*/
|
|
@@ -642,7 +644,11 @@ const createPageStorageOperations = params => {
|
|
|
642
644
|
* Do not throw the error if Elasticsearch index does not exist.
|
|
643
645
|
* In some CRUDs we try to get list of pages but index was not created yet.
|
|
644
646
|
*/
|
|
645
|
-
if (
|
|
647
|
+
if ((0, _shouldIgnoreEsResponseError.shouldIgnoreEsResponseError)(ex)) {
|
|
648
|
+
(0, _logIgnoredEsResponseError.logIgnoredEsResponseError)({
|
|
649
|
+
error: ex,
|
|
650
|
+
indexName: esConfig.index
|
|
651
|
+
});
|
|
646
652
|
return {
|
|
647
653
|
items: [],
|
|
648
654
|
meta: {
|
|
@@ -725,6 +731,13 @@ const createPageStorageOperations = params => {
|
|
|
725
731
|
}
|
|
726
732
|
return tags.buckets.map(item => item.key);
|
|
727
733
|
} catch (ex) {
|
|
734
|
+
if ((0, _shouldIgnoreEsResponseError.shouldIgnoreEsResponseError)(ex)) {
|
|
735
|
+
(0, _logIgnoredEsResponseError.logIgnoredEsResponseError)({
|
|
736
|
+
error: ex,
|
|
737
|
+
indexName: esConfig.index
|
|
738
|
+
});
|
|
739
|
+
return [];
|
|
740
|
+
}
|
|
728
741
|
throw new _error.default(ex.message || "Could not list tags by given parameters.", ex.code || "LIST_TAGS_ERROR", {
|
|
729
742
|
body,
|
|
730
743
|
where
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_omit","_interopRequireDefault","require","_error","_cleanup","_configurations","_apiElasticsearch","_elasticsearchQueryBody","_SearchLatestPagesPlugin","_SearchPublishedPagesPlugin","_query","_batchWrite","_helpers","_keys","_sort","_PageDynamoDbElasticsearchFieldPlugin","_dbDynamodb","removePageAttributes","item","omit","createPageStorageOperations","params","entity","esEntity","elasticsearch","plugins","create","page","input","versionKeys","PK","createPartitionKey","SK","createSortKey","latestKeys","createLatestSortKey","items","putBatch","TYPE","createBasicType","createLatestType","esData","getESLatestPageData","batchWriteAll","table","put","index","configurations","es","data","ex","WebinyError","message","code","createFrom","latestPage","original","update","keys","getClean","id","push","deleteOne","publishedPage","partitionKey","deleteBatch","esItems","createPublishedSortKey","createPathPartitionKey","createPathSortKey","previousLatestPage","previousLatestRecord","queryOne","options","lt","reverse","cleanupItem","length","deleteAll","queryAllParams","gte","revisions","queryAll","publishedPathEntryDeleted","revision","status","path","publish","getESPublishedPageData","createPublishedPathType","createPublishedType","unpublish","get","where","pid","published","version","includes","Number","split","pop","sortKey","list","latest","after","previousCursor","limit","initialLimit","createLimit","body","createElasticsearchQueryBody","searchPlugins","byType","SearchPublishedPagesPlugin","type","SearchLatestPagesPlugin","plugin","modifyQuery","query","args","modifySort","sort","response","esConfig","search","meta","hasMoreItems","totalCount","cursor","hits","total","map","_source","encodeCursor","value","listTags","tenant","locale","undefined","size","aggs","tags","terms","field","include","aggregations","Array","isArray","buckets","key","listRevisions","beginsWith","fields","PageDynamoDbElasticsearchFieldPlugin","sortItems","delete","exports"],"sources":["index.ts"],"sourcesContent":["import {\n Page,\n PageStorageOperations,\n PageStorageOperationsCreateFromParams,\n PageStorageOperationsCreateParams,\n PageStorageOperationsDeleteAllParams,\n PageStorageOperationsDeleteParams,\n PageStorageOperationsGetParams,\n PageStorageOperationsListParams,\n PageStorageOperationsListResponse,\n PageStorageOperationsListRevisionsParams,\n PageStorageOperationsListTagsParams,\n PageStorageOperationsPublishParams,\n PageStorageOperationsUnpublishParams,\n PageStorageOperationsUpdateParams\n} from \"@webiny/api-page-builder/types\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport omit from \"lodash/omit\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport {\n ElasticsearchBoolQueryConfig,\n ElasticsearchSearchResponse\n} from \"@webiny/api-elasticsearch/types\";\nimport { configurations } from \"~/configurations\";\nimport { createLimit, encodeCursor } from \"@webiny/api-elasticsearch\";\nimport { createElasticsearchQueryBody } from \"./elasticsearchQueryBody\";\nimport { SearchLatestPagesPlugin } from \"~/plugins/definitions/SearchLatestPagesPlugin\";\nimport { SearchPublishedPagesPlugin } from \"~/plugins/definitions/SearchPublishedPagesPlugin\";\nimport { DbItem, queryAll, QueryAllParams, queryOne } from \"@webiny/db-dynamodb/utils/query\";\nimport { SearchPagesPlugin } from \"~/plugins/definitions/SearchPagesPlugin\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { getESLatestPageData, getESPublishedPageData } from \"./helpers\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n createBasicType,\n createLatestSortKey,\n createLatestType,\n createPartitionKey,\n createPathPartitionKey,\n createPathSortKey,\n createPublishedPathType,\n createPublishedSortKey,\n createPublishedType,\n createSortKey\n} from \"./keys\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { PageDynamoDbElasticsearchFieldPlugin } from \"~/plugins/definitions/PageDynamoDbElasticsearchFieldPlugin\";\nimport { getClean, put } from \"@webiny/db-dynamodb\";\n\n/**\n * This function removes attributes that were once present in the Page record, which we no longer need.\n */\nfunction removePageAttributes(item: Page): Page {\n return omit(item, [\"home\", \"notFound\", \"visibility\"]) as Page;\n}\n\nexport interface CreatePageStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\nexport const createPageStorageOperations = (\n params: CreatePageStorageOperationsParams\n): PageStorageOperations => {\n const { entity, esEntity, elasticsearch, plugins } = params;\n\n const create = async (params: PageStorageOperationsCreateParams): Promise<Page> => {\n const { page, input } = params;\n\n const versionKeys = {\n PK: createPartitionKey(page),\n SK: createSortKey(page)\n };\n const latestKeys = {\n ...versionKeys,\n SK: createLatestSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...page,\n ...versionKeys,\n TYPE: createBasicType()\n }),\n entity.putBatch({\n ...page,\n ...latestKeys,\n TYPE: createLatestType()\n })\n ];\n const esData = getESLatestPageData(plugins, page, input);\n try {\n await batchWriteAll({\n table: entity.table,\n items: items\n });\n await put({\n entity: esEntity,\n item: {\n index: configurations.es(page).index,\n data: esData,\n ...latestKeys\n }\n });\n return page;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create new page.\",\n ex.code || \"CREATE_PAGE_ERROR\",\n {\n versionKeys,\n latestKeys,\n page\n }\n );\n }\n };\n\n const createFrom = async (params: PageStorageOperationsCreateFromParams): Promise<Page> => {\n const { page, latestPage, original } = params;\n\n const versionKeys = {\n PK: createPartitionKey(page),\n SK: createSortKey(page)\n };\n const latestKeys = {\n ...versionKeys,\n SK: createLatestSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...page,\n TYPE: createBasicType(),\n ...versionKeys\n }),\n entity.putBatch({\n ...page,\n TYPE: createLatestType(),\n ...latestKeys\n })\n ];\n\n const esData = getESLatestPageData(plugins, page);\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n\n await put({\n entity: esEntity,\n item: {\n index: configurations.es(page).index,\n data: esData,\n ...latestKeys\n }\n });\n return page;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create new page from existing page.\",\n ex.code || \"CREATE_PAGE_FROM_ERROR\",\n {\n versionKeys,\n latestKeys,\n latestPage,\n original,\n page\n }\n );\n }\n };\n\n const update = async (params: PageStorageOperationsUpdateParams): Promise<Page> => {\n const { original, page, input } = params;\n\n const keys = {\n PK: createPartitionKey(page),\n SK: createSortKey(page)\n };\n\n const latestKeys = {\n ...keys,\n SK: createLatestSortKey()\n };\n const latestPage = await getClean<Page>({\n entity,\n keys: latestKeys\n });\n\n const items = [\n entity.putBatch({\n ...page,\n TYPE: createBasicType(),\n ...keys\n })\n ];\n\n const esData = getESLatestPageData(plugins, page, input);\n\n if (latestPage && latestPage?.id === page.id) {\n /**\n * We also update the regular record.\n */\n items.push(\n entity.putBatch({\n ...page,\n TYPE: createLatestType(),\n ...latestKeys\n })\n );\n }\n /**\n * Unfortunately we cannot push regular and es record in the batch write because they are two separate tables.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n\n await put({\n entity: esEntity,\n item: {\n index: configurations.es(page).index,\n data: esData,\n ...latestKeys\n }\n });\n\n return page;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update existing page.\",\n ex.code || \"UPDATE_PAGE_ERROR\",\n {\n original,\n page,\n latestPage,\n latestKeys,\n keys\n }\n );\n }\n };\n\n /**\n * In case of delete, we must delete records:\n * - revision\n * - path if published\n * Update:\n * - latest\n */\n const deleteOne = async (\n params: PageStorageOperationsDeleteParams\n ): Promise<[Page, Page | null]> => {\n const { page, latestPage, publishedPage } = params;\n\n const partitionKey = createPartitionKey(page);\n\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createSortKey(page)\n })\n ];\n const esItems = [];\n if (publishedPage && publishedPage.id === page.id) {\n items.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n items.push(\n entity.deleteBatch({\n PK: createPathPartitionKey(page),\n SK: createPathSortKey(page)\n })\n );\n esItems.push(\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n let previousLatestPage: Page | null = null;\n if (latestPage && latestPage.id === page.id) {\n const previousLatestRecord = await queryOne<Page>({\n entity,\n partitionKey,\n options: {\n lt: createSortKey(latestPage),\n reverse: true\n }\n });\n if (previousLatestRecord) {\n items.push(\n entity.putBatch({\n ...previousLatestRecord,\n TYPE: createLatestType(),\n PK: partitionKey,\n SK: createLatestSortKey()\n })\n );\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index: configurations.es(page).index,\n data: getESLatestPageData(plugins, previousLatestRecord)\n })\n );\n previousLatestPage = cleanupItem(entity, previousLatestRecord);\n }\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write all the page records.\",\n ex.code || \"BATCH_WRITE_RECORDS_ERROR\"\n );\n }\n if (esItems.length === 0) {\n return [page, previousLatestPage];\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write all the page Elasticsearch records.\",\n ex.code || \"BATCH_WRITE_ELASTICSEARCH_RECORDS_ERROR\"\n );\n }\n return [page, previousLatestPage];\n };\n\n /**\n * In case of deleteAll, we must delete records:\n * - latest\n * - published\n * - path if published\n * - revision\n * - es latest\n * - es published\n */\n const deleteAll = async (params: PageStorageOperationsDeleteAllParams): Promise<[Page]> => {\n const { page } = params;\n\n const partitionKey = createPartitionKey(page);\n const queryAllParams = {\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n };\n let revisions: DbItem<Page>[];\n try {\n revisions = await queryAll<Page>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not query for all revisions of the page.\",\n ex.code || \"LIST_REVISIONS_ERROR\",\n {\n params: queryAllParams\n }\n );\n }\n\n /**\n * We need to go through all possible entries and delete them.\n * Also, delete the published entry path record.\n */\n const items = [];\n let publishedPathEntryDeleted = false;\n for (const revision of revisions) {\n if (revision.status === \"published\" && !publishedPathEntryDeleted) {\n publishedPathEntryDeleted = true;\n items.push(\n entity.deleteBatch({\n PK: createPathPartitionKey(page),\n SK: revision.path\n })\n );\n }\n items.push(\n entity.deleteBatch({\n PK: revision.PK,\n SK: revision.SK\n })\n );\n }\n const esItems = [\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createLatestSortKey()\n })\n ];\n /**\n * Delete published record if it is published.\n */\n if (publishedPathEntryDeleted) {\n esItems.push(\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete all the page records.\",\n ex.code || \"DELETE_RECORDS_ERROR\"\n );\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete all the page Elasticsearch records.\",\n ex.code || \"DELETE_ELASTICSEARCH_RECORDS_ERROR\"\n );\n }\n return [page];\n };\n\n const publish = async (params: PageStorageOperationsPublishParams): Promise<Page> => {\n const { page, latestPage, publishedPage } = params;\n\n page.status = \"published\";\n\n /**\n * Update the given revision of the page.\n */\n const items = [\n entity.putBatch({\n ...page,\n TYPE: createBasicType(),\n PK: createPartitionKey(page),\n SK: createSortKey(page)\n })\n ];\n const esItems = [];\n /**\n * If we are publishing the latest revision, update the latest revision\n * status in ES. We also need to update the latest page revision entry in ES.\n */\n if (latestPage.id === page.id) {\n items.push(\n entity.putBatch({\n ...page,\n TYPE: createLatestType(),\n PK: createPartitionKey(page),\n SK: createLatestSortKey()\n })\n );\n\n esItems.push(\n esEntity.putBatch({\n PK: createPartitionKey(page),\n SK: createLatestSortKey(),\n index: configurations.es(page).index,\n data: getESLatestPageData(plugins, page)\n })\n );\n }\n /**\n * If we already have a published revision, and it's not the revision being published:\n * - set the existing published revision to \"unpublished\"\n */\n if (publishedPage && publishedPage.id !== page.id) {\n items.push(\n entity.putBatch({\n ...publishedPage,\n status: \"unpublished\",\n PK: createPartitionKey(publishedPage),\n SK: createSortKey(publishedPage)\n })\n );\n /**\n * Remove old published path if required.\n */\n if (publishedPage.path !== page.path) {\n items.push(\n entity.deleteBatch({\n PK: createPathPartitionKey(page),\n SK: publishedPage.path\n })\n );\n }\n }\n\n esItems.push(\n esEntity.putBatch({\n PK: createPartitionKey(page),\n SK: createPublishedSortKey(),\n index: configurations.es(page).index,\n data: getESPublishedPageData(plugins, page)\n })\n );\n\n /**\n * Update or insert published path.\n */\n items.push(\n entity.putBatch({\n ...page,\n TYPE: createPublishedPathType(),\n PK: createPathPartitionKey(page),\n SK: createPathSortKey(page)\n })\n );\n /**\n * Update or insert published page.\n */\n items.push(\n entity.putBatch({\n ...page,\n TYPE: createPublishedType(),\n PK: createPartitionKey(page),\n SK: createPublishedSortKey()\n })\n );\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update all the page records when publishing.\",\n ex.code || \"UPDATE_RECORDS_ERROR\"\n );\n }\n /**\n * No point in continuing if there are no items in Elasticsearch data\n */\n if (esItems.length === 0) {\n return page;\n }\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not update all the page Elasticsearch records when publishing.\",\n ex.code || \"UPDATE_ELASTICSEARCH_RECORDS_ERROR\"\n );\n }\n return page;\n };\n\n const unpublish = async (params: PageStorageOperationsUnpublishParams): Promise<Page> => {\n const { page, latestPage } = params;\n\n page.status = \"unpublished\";\n\n const items = [\n entity.deleteBatch({\n PK: createPartitionKey(page),\n SK: createPublishedSortKey()\n }),\n entity.deleteBatch({\n PK: createPathPartitionKey(page),\n SK: createPathSortKey(page)\n }),\n entity.putBatch({\n ...page,\n TYPE: createBasicType(),\n PK: createPartitionKey(page),\n SK: createSortKey(page)\n })\n ];\n const esItems = [];\n /*\n * If we are unpublishing the latest revision, let's also update the latest revision entry's status in ES.\n */\n if (latestPage.id === page.id) {\n items.push(\n entity.putBatch({\n ...page,\n TYPE: createLatestType(),\n PK: createPartitionKey(page),\n SK: createLatestSortKey()\n })\n );\n esItems.push(\n esEntity.putBatch({\n PK: createPartitionKey(page),\n SK: createLatestSortKey(),\n index: configurations.es(page).index,\n data: getESLatestPageData(plugins, page)\n })\n );\n }\n\n esItems.push(\n esEntity.deleteBatch({\n PK: createPartitionKey(page),\n SK: createPublishedSortKey()\n })\n );\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update all the page records when unpublishing.\",\n ex.code || \"UPDATE_RECORDS_ERROR\"\n );\n }\n /**\n * No need to go further if no Elasticsearch items to be applied.\n */\n if (esItems.length === 0) {\n return page;\n }\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not update all the page Elasticsearch records when unpublishing.\",\n ex.code || \"UPDATE_ELASTICSEARCH_RECORDS_ERROR\"\n );\n }\n return page;\n };\n\n const get = async (params: PageStorageOperationsGetParams): Promise<Page | null> => {\n const { where } = params;\n const { pid, id, path, published } = where;\n let { version } = where;\n /**\n * In case of having full ID and not having version we can take the version from the id.\n */\n if (id && id.includes(\"#\") && !version) {\n version = Number(id.split(\"#\").pop());\n }\n let partitionKey: string | null = null;\n let sortKey: string;\n if (path) {\n partitionKey = createPathPartitionKey(where);\n sortKey = path;\n } else if (published) {\n sortKey = createPublishedSortKey();\n } else if (version) {\n sortKey = createSortKey({\n version\n });\n } else {\n sortKey = createLatestSortKey();\n }\n /**\n * If partition key is still undefined, create one with id or pid\n */\n if (!partitionKey) {\n partitionKey = createPartitionKey({\n ...where,\n id: pid || (id as string)\n });\n }\n const keys = {\n PK: partitionKey,\n SK: sortKey\n };\n try {\n return await getClean({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not load page by given params.\",\n ex.code || \"GET_PAGE_ERROR\",\n {\n where,\n keys\n }\n );\n }\n };\n\n const list = async (\n params: PageStorageOperationsListParams\n ): Promise<PageStorageOperationsListResponse> => {\n /**\n * We do not allow loading both published and latest at the same time.\n * @see PageStorageOperationsListWhere\n */\n if (params.where.published && params.where.latest) {\n throw new WebinyError(\n \"Both published and latest cannot be defined at the same time.\",\n \"MALFORMED_WHERE_ERROR\",\n {\n where: params.where\n }\n );\n }\n\n const { after: previousCursor = null, limit: initialLimit } = params;\n\n const limit = createLimit(initialLimit, 50);\n const body = createElasticsearchQueryBody({\n ...params,\n where: {\n ...params.where\n },\n limit,\n after: previousCursor,\n plugins\n });\n\n let searchPlugins: SearchPagesPlugin[] = [];\n if (params.where.published) {\n searchPlugins = plugins.byType<SearchPublishedPagesPlugin>(\n SearchPublishedPagesPlugin.type\n );\n } else if (params.where.latest) {\n searchPlugins = plugins.byType<SearchLatestPagesPlugin>(SearchLatestPagesPlugin.type);\n } else {\n throw new WebinyError(\n \"Only published or latest can be listed. Missing where condition.\",\n \"MALFORMED_WHERE_ERROR\",\n {\n where: params.where\n }\n );\n }\n\n for (const plugin of searchPlugins) {\n /**\n * Apply query modifications\n */\n plugin.modifyQuery({\n query: body.query as unknown as ElasticsearchBoolQueryConfig,\n args: params,\n plugins\n });\n\n /**\n * Apply sort modifications\n */\n plugin.modifySort({\n sort: body.sort,\n args: params,\n plugins\n });\n }\n\n let response: ElasticsearchSearchResponse<Page>;\n const esConfig = configurations.es(params.where);\n try {\n response = await elasticsearch.search({\n ...esConfig,\n body\n });\n } catch (ex) {\n /**\n * Do not throw the error if Elasticsearch index does not exist.\n * In some CRUDs we try to get list of pages but index was not created yet.\n */\n if (ex.message === \"index_not_found_exception\") {\n return {\n items: [],\n meta: {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null\n }\n };\n }\n throw new WebinyError(\n ex.message || \"Could not load pages by given Elasticsearch body.\",\n ex.code || \"LIST_PAGES_ERROR\",\n {\n body\n }\n );\n }\n const { hits, total } = response.body.hits;\n const items = hits.map(item => item._source).map(item => removePageAttributes(item));\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const cursor =\n items.length > 0 && hasMoreItems\n ? encodeCursor(hits[items.length - 1].sort) || null\n : null;\n return {\n items,\n meta: {\n hasMoreItems,\n totalCount: total.value,\n cursor\n }\n };\n };\n\n const listTags = async (params: PageStorageOperationsListTagsParams): Promise<string[]> => {\n const { where } = params;\n\n const tenant: string = where.tenant;\n const body = createElasticsearchQueryBody({\n ...params,\n where: {\n locale: where.locale,\n search: undefined,\n tenant\n },\n sort: [],\n after: null,\n limit: 100000,\n plugins\n });\n\n const esConfig = configurations.es(where);\n\n try {\n const response: ElasticsearchSearchResponse<string> = await elasticsearch.search({\n ...esConfig,\n body: {\n ...body,\n sort: undefined,\n limit: undefined,\n size: 0,\n aggs: {\n tags: {\n terms: {\n field: \"tags.keyword\",\n include: `.*${where.search}.*`,\n size: 10\n }\n }\n }\n }\n });\n\n const tags = response.body.aggregations[\"tags\"];\n if (!tags || Array.isArray(tags.buckets) === false) {\n return [];\n }\n return tags.buckets.map(item => item.key);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list tags by given parameters.\",\n ex.code || \"LIST_TAGS_ERROR\",\n {\n body,\n where\n }\n );\n }\n };\n\n const listRevisions = async (\n params: PageStorageOperationsListRevisionsParams\n ): Promise<Page[]> => {\n const { where, sort } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n ...where,\n id: where.pid\n }),\n options: {\n beginsWith: \"REV#\",\n reverse: false\n }\n };\n\n let items: Page[] = [];\n try {\n items = await queryAll<Page>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not load all the revisions from requested page.\",\n ex.code || \"LOAD_PAGE_REVISIONS_ERROR\",\n {\n params\n }\n );\n }\n\n const fields = plugins.byType<PageDynamoDbElasticsearchFieldPlugin>(\n PageDynamoDbElasticsearchFieldPlugin.type\n );\n\n return sortItems({\n items: items.map(item => removePageAttributes(item)),\n fields,\n sort\n });\n };\n\n return {\n create,\n createFrom,\n update,\n delete: deleteOne,\n deleteAll: deleteAll,\n publish,\n unpublish,\n get,\n list,\n listRevisions,\n listTags\n };\n};\n"],"mappings":";;;;;;;AAiBA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,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,CAAC,CAAC,OAAO7B,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,uDAAuD,EACrEF,EAAE,CAACG,IAAI,IAAI,2BAA2B,EACtC;QACIhC;MACJ,CACJ,CAAC;IACL;IAEA,MAAMmI,MAAM,GAAG/H,OAAO,CAACuF,MAAM,CACzByC,0EAAoC,CAACvC,IACzC,CAAC;IAED,OAAO,IAAAwC,eAAS,EAAC;MACbtH,KAAK,EAAEA,KAAK,CAAC+F,GAAG,CAACjH,IAAI,IAAID,oBAAoB,CAACC,IAAI,CAAC,CAAC;MACpDsI,MAAM;MACN/B;IACJ,CAAC,CAAC;EACN,CAAC;EAED,OAAO;IACH/F,MAAM;IACN4B,UAAU;IACVG,MAAM;IACNkG,MAAM,EAAE7F,SAAS;IACjBgB,SAAS,EAAEA,SAAS;IACpBS,OAAO;IACPI,SAAS;IACTC,GAAG;IACHU,IAAI;IACJgD,aAAa;IACbf;EACJ,CAAC;AACL,CAAC;AAACqB,OAAA,CAAAxI,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_omit","_interopRequireDefault","require","_error","_cleanup","_configurations","_apiElasticsearch","_elasticsearchQueryBody","_SearchLatestPagesPlugin","_SearchPublishedPagesPlugin","_query","_batchWrite","_helpers","_keys","_sort","_PageDynamoDbElasticsearchFieldPlugin","_dbDynamodb","_shouldIgnoreEsResponseError","_logIgnoredEsResponseError","removePageAttributes","item","omit","createPageStorageOperations","params","entity","esEntity","elasticsearch","plugins","create","page","input","versionKeys","PK","createPartitionKey","SK","createSortKey","latestKeys","createLatestSortKey","items","putBatch","TYPE","createBasicType","createLatestType","esData","getESLatestPageData","batchWriteAll","table","put","index","configurations","es","data","ex","WebinyError","message","code","createFrom","latestPage","original","update","keys","getClean","id","push","deleteOne","publishedPage","partitionKey","deleteBatch","esItems","createPublishedSortKey","createPathPartitionKey","createPathSortKey","previousLatestPage","previousLatestRecord","queryOne","options","lt","reverse","cleanupItem","length","deleteAll","queryAllParams","gte","revisions","queryAll","publishedPathEntryDeleted","revision","status","path","publish","getESPublishedPageData","createPublishedPathType","createPublishedType","unpublish","get","where","pid","published","version","includes","Number","split","pop","sortKey","list","latest","after","previousCursor","limit","initialLimit","createLimit","body","createElasticsearchQueryBody","searchPlugins","byType","SearchPublishedPagesPlugin","type","SearchLatestPagesPlugin","plugin","modifyQuery","query","args","modifySort","sort","response","esConfig","search","shouldIgnoreEsResponseError","logIgnoredEsResponseError","error","indexName","meta","hasMoreItems","totalCount","cursor","hits","total","map","_source","encodeCursor","value","listTags","tenant","locale","undefined","size","aggs","tags","terms","field","include","aggregations","Array","isArray","buckets","key","listRevisions","beginsWith","fields","PageDynamoDbElasticsearchFieldPlugin","sortItems","delete","exports"],"sources":["index.ts"],"sourcesContent":["import {\n Page,\n PageStorageOperations,\n PageStorageOperationsCreateFromParams,\n PageStorageOperationsCreateParams,\n PageStorageOperationsDeleteAllParams,\n PageStorageOperationsDeleteParams,\n PageStorageOperationsGetParams,\n PageStorageOperationsListParams,\n PageStorageOperationsListResponse,\n PageStorageOperationsListRevisionsParams,\n PageStorageOperationsListTagsParams,\n PageStorageOperationsPublishParams,\n PageStorageOperationsUnpublishParams,\n PageStorageOperationsUpdateParams\n} from \"@webiny/api-page-builder/types\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport omit from \"lodash/omit\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport {\n ElasticsearchBoolQueryConfig,\n ElasticsearchSearchResponse\n} from \"@webiny/api-elasticsearch/types\";\nimport { configurations } from \"~/configurations\";\nimport { createLimit, encodeCursor } from \"@webiny/api-elasticsearch\";\nimport { createElasticsearchQueryBody } from \"./elasticsearchQueryBody\";\nimport { SearchLatestPagesPlugin } from \"~/plugins/definitions/SearchLatestPagesPlugin\";\nimport { SearchPublishedPagesPlugin } from \"~/plugins/definitions/SearchPublishedPagesPlugin\";\nimport { DbItem, queryAll, QueryAllParams, queryOne } from \"@webiny/db-dynamodb/utils/query\";\nimport { SearchPagesPlugin } from \"~/plugins/definitions/SearchPagesPlugin\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { getESLatestPageData, getESPublishedPageData } from \"./helpers\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n createBasicType,\n createLatestSortKey,\n createLatestType,\n createPartitionKey,\n createPathPartitionKey,\n createPathSortKey,\n createPublishedPathType,\n createPublishedSortKey,\n createPublishedType,\n createSortKey\n} from \"./keys\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { PageDynamoDbElasticsearchFieldPlugin } from \"~/plugins/definitions/PageDynamoDbElasticsearchFieldPlugin\";\nimport { getClean, put } from \"@webiny/db-dynamodb\";\nimport { shouldIgnoreEsResponseError } from \"~/operations/pages/shouldIgnoreEsResponseError\";\nimport { logIgnoredEsResponseError } from \"~/operations/pages/logIgnoredEsResponseError\";\n\n/**\n * This function removes attributes that were once present in the Page record, which we no longer need.\n */\nfunction removePageAttributes(item: Page): Page {\n return omit(item, [\"home\", \"notFound\", \"visibility\"]) as Page;\n}\n\nexport interface CreatePageStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\nexport const createPageStorageOperations = (\n params: CreatePageStorageOperationsParams\n): PageStorageOperations => {\n const { entity, esEntity, elasticsearch, plugins } = params;\n\n const create = async (params: PageStorageOperationsCreateParams): Promise<Page> => {\n const { page, input } = params;\n\n const versionKeys = {\n PK: createPartitionKey(page),\n SK: createSortKey(page)\n };\n const latestKeys = {\n ...versionKeys,\n SK: createLatestSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...page,\n ...versionKeys,\n TYPE: createBasicType()\n }),\n entity.putBatch({\n ...page,\n ...latestKeys,\n TYPE: createLatestType()\n })\n ];\n const esData = getESLatestPageData(plugins, page, input);\n try {\n await batchWriteAll({\n table: entity.table,\n items: items\n });\n await put({\n entity: esEntity,\n item: {\n index: configurations.es(page).index,\n data: esData,\n ...latestKeys\n }\n });\n return page;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create new page.\",\n ex.code || \"CREATE_PAGE_ERROR\",\n {\n versionKeys,\n latestKeys,\n page\n }\n );\n }\n };\n\n const createFrom = async (params: PageStorageOperationsCreateFromParams): Promise<Page> => {\n const { page, latestPage, original } = params;\n\n const versionKeys = {\n PK: createPartitionKey(page),\n SK: createSortKey(page)\n };\n const latestKeys = {\n ...versionKeys,\n SK: createLatestSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...page,\n TYPE: createBasicType(),\n ...versionKeys\n }),\n entity.putBatch({\n ...page,\n TYPE: createLatestType(),\n ...latestKeys\n })\n ];\n\n const esData = getESLatestPageData(plugins, page);\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n\n await put({\n entity: esEntity,\n item: {\n index: configurations.es(page).index,\n data: esData,\n ...latestKeys\n }\n });\n return page;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create new page from existing page.\",\n ex.code || \"CREATE_PAGE_FROM_ERROR\",\n {\n versionKeys,\n latestKeys,\n latestPage,\n original,\n page\n }\n );\n }\n };\n\n const update = async (params: PageStorageOperationsUpdateParams): Promise<Page> => {\n const { original, page, input } = params;\n\n const keys = {\n PK: createPartitionKey(page),\n SK: createSortKey(page)\n };\n\n const latestKeys = {\n ...keys,\n SK: createLatestSortKey()\n };\n const latestPage = await getClean<Page>({\n entity,\n keys: latestKeys\n });\n\n const items = [\n entity.putBatch({\n ...page,\n TYPE: createBasicType(),\n ...keys\n })\n ];\n\n const esData = getESLatestPageData(plugins, page, input);\n\n if (latestPage && latestPage?.id === page.id) {\n /**\n * We also update the regular record.\n */\n items.push(\n entity.putBatch({\n ...page,\n TYPE: createLatestType(),\n ...latestKeys\n })\n );\n }\n /**\n * Unfortunately we cannot push regular and es record in the batch write because they are two separate tables.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n\n await put({\n entity: esEntity,\n item: {\n index: configurations.es(page).index,\n data: esData,\n ...latestKeys\n }\n });\n\n return page;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update existing page.\",\n ex.code || \"UPDATE_PAGE_ERROR\",\n {\n original,\n page,\n latestPage,\n latestKeys,\n keys\n }\n );\n }\n };\n\n /**\n * In case of delete, we must delete records:\n * - revision\n * - path if published\n * Update:\n * - latest\n */\n const deleteOne = async (\n params: PageStorageOperationsDeleteParams\n ): Promise<[Page, Page | null]> => {\n const { page, latestPage, publishedPage } = params;\n\n const partitionKey = createPartitionKey(page);\n\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createSortKey(page)\n })\n ];\n const esItems = [];\n if (publishedPage && publishedPage.id === page.id) {\n items.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n items.push(\n entity.deleteBatch({\n PK: createPathPartitionKey(page),\n SK: createPathSortKey(page)\n })\n );\n esItems.push(\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n let previousLatestPage: Page | null = null;\n if (latestPage && latestPage.id === page.id) {\n const previousLatestRecord = await queryOne<Page>({\n entity,\n partitionKey,\n options: {\n lt: createSortKey(latestPage),\n reverse: true\n }\n });\n if (previousLatestRecord) {\n items.push(\n entity.putBatch({\n ...previousLatestRecord,\n TYPE: createLatestType(),\n PK: partitionKey,\n SK: createLatestSortKey()\n })\n );\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index: configurations.es(page).index,\n data: getESLatestPageData(plugins, previousLatestRecord)\n })\n );\n previousLatestPage = cleanupItem(entity, previousLatestRecord);\n }\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write all the page records.\",\n ex.code || \"BATCH_WRITE_RECORDS_ERROR\"\n );\n }\n if (esItems.length === 0) {\n return [page, previousLatestPage];\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write all the page Elasticsearch records.\",\n ex.code || \"BATCH_WRITE_ELASTICSEARCH_RECORDS_ERROR\"\n );\n }\n return [page, previousLatestPage];\n };\n\n /**\n * In case of deleteAll, we must delete records:\n * - latest\n * - published\n * - path if published\n * - revision\n * - es latest\n * - es published\n */\n const deleteAll = async (params: PageStorageOperationsDeleteAllParams): Promise<[Page]> => {\n const { page } = params;\n\n const partitionKey = createPartitionKey(page);\n const queryAllParams = {\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n };\n let revisions: DbItem<Page>[];\n try {\n revisions = await queryAll<Page>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not query for all revisions of the page.\",\n ex.code || \"LIST_REVISIONS_ERROR\",\n {\n params: queryAllParams\n }\n );\n }\n\n /**\n * We need to go through all possible entries and delete them.\n * Also, delete the published entry path record.\n */\n const items = [];\n let publishedPathEntryDeleted = false;\n for (const revision of revisions) {\n if (revision.status === \"published\" && !publishedPathEntryDeleted) {\n publishedPathEntryDeleted = true;\n items.push(\n entity.deleteBatch({\n PK: createPathPartitionKey(page),\n SK: revision.path\n })\n );\n }\n items.push(\n entity.deleteBatch({\n PK: revision.PK,\n SK: revision.SK\n })\n );\n }\n const esItems = [\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createLatestSortKey()\n })\n ];\n /**\n * Delete published record if it is published.\n */\n if (publishedPathEntryDeleted) {\n esItems.push(\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete all the page records.\",\n ex.code || \"DELETE_RECORDS_ERROR\"\n );\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete all the page Elasticsearch records.\",\n ex.code || \"DELETE_ELASTICSEARCH_RECORDS_ERROR\"\n );\n }\n return [page];\n };\n\n const publish = async (params: PageStorageOperationsPublishParams): Promise<Page> => {\n const { page, latestPage, publishedPage } = params;\n\n page.status = \"published\";\n\n /**\n * Update the given revision of the page.\n */\n const items = [\n entity.putBatch({\n ...page,\n TYPE: createBasicType(),\n PK: createPartitionKey(page),\n SK: createSortKey(page)\n })\n ];\n const esItems = [];\n /**\n * If we are publishing the latest revision, update the latest revision\n * status in ES. We also need to update the latest page revision entry in ES.\n */\n if (latestPage.id === page.id) {\n items.push(\n entity.putBatch({\n ...page,\n TYPE: createLatestType(),\n PK: createPartitionKey(page),\n SK: createLatestSortKey()\n })\n );\n\n esItems.push(\n esEntity.putBatch({\n PK: createPartitionKey(page),\n SK: createLatestSortKey(),\n index: configurations.es(page).index,\n data: getESLatestPageData(plugins, page)\n })\n );\n }\n /**\n * If we already have a published revision, and it's not the revision being published:\n * - set the existing published revision to \"unpublished\"\n */\n if (publishedPage && publishedPage.id !== page.id) {\n items.push(\n entity.putBatch({\n ...publishedPage,\n status: \"unpublished\",\n PK: createPartitionKey(publishedPage),\n SK: createSortKey(publishedPage)\n })\n );\n /**\n * Remove old published path if required.\n */\n if (publishedPage.path !== page.path) {\n items.push(\n entity.deleteBatch({\n PK: createPathPartitionKey(page),\n SK: publishedPage.path\n })\n );\n }\n }\n\n esItems.push(\n esEntity.putBatch({\n PK: createPartitionKey(page),\n SK: createPublishedSortKey(),\n index: configurations.es(page).index,\n data: getESPublishedPageData(plugins, page)\n })\n );\n\n /**\n * Update or insert published path.\n */\n items.push(\n entity.putBatch({\n ...page,\n TYPE: createPublishedPathType(),\n PK: createPathPartitionKey(page),\n SK: createPathSortKey(page)\n })\n );\n /**\n * Update or insert published page.\n */\n items.push(\n entity.putBatch({\n ...page,\n TYPE: createPublishedType(),\n PK: createPartitionKey(page),\n SK: createPublishedSortKey()\n })\n );\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update all the page records when publishing.\",\n ex.code || \"UPDATE_RECORDS_ERROR\"\n );\n }\n /**\n * No point in continuing if there are no items in Elasticsearch data\n */\n if (esItems.length === 0) {\n return page;\n }\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not update all the page Elasticsearch records when publishing.\",\n ex.code || \"UPDATE_ELASTICSEARCH_RECORDS_ERROR\"\n );\n }\n return page;\n };\n\n const unpublish = async (params: PageStorageOperationsUnpublishParams): Promise<Page> => {\n const { page, latestPage } = params;\n\n page.status = \"unpublished\";\n\n const items = [\n entity.deleteBatch({\n PK: createPartitionKey(page),\n SK: createPublishedSortKey()\n }),\n entity.deleteBatch({\n PK: createPathPartitionKey(page),\n SK: createPathSortKey(page)\n }),\n entity.putBatch({\n ...page,\n TYPE: createBasicType(),\n PK: createPartitionKey(page),\n SK: createSortKey(page)\n })\n ];\n const esItems = [];\n /*\n * If we are unpublishing the latest revision, let's also update the latest revision entry's status in ES.\n */\n if (latestPage.id === page.id) {\n items.push(\n entity.putBatch({\n ...page,\n TYPE: createLatestType(),\n PK: createPartitionKey(page),\n SK: createLatestSortKey()\n })\n );\n esItems.push(\n esEntity.putBatch({\n PK: createPartitionKey(page),\n SK: createLatestSortKey(),\n index: configurations.es(page).index,\n data: getESLatestPageData(plugins, page)\n })\n );\n }\n\n esItems.push(\n esEntity.deleteBatch({\n PK: createPartitionKey(page),\n SK: createPublishedSortKey()\n })\n );\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update all the page records when unpublishing.\",\n ex.code || \"UPDATE_RECORDS_ERROR\"\n );\n }\n /**\n * No need to go further if no Elasticsearch items to be applied.\n */\n if (esItems.length === 0) {\n return page;\n }\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not update all the page Elasticsearch records when unpublishing.\",\n ex.code || \"UPDATE_ELASTICSEARCH_RECORDS_ERROR\"\n );\n }\n return page;\n };\n\n const get = async (params: PageStorageOperationsGetParams): Promise<Page | null> => {\n const { where } = params;\n const { pid, id, path, published } = where;\n let { version } = where;\n /**\n * In case of having full ID and not having version we can take the version from the id.\n */\n if (id && id.includes(\"#\") && !version) {\n version = Number(id.split(\"#\").pop());\n }\n let partitionKey: string | null = null;\n let sortKey: string;\n if (path) {\n partitionKey = createPathPartitionKey(where);\n sortKey = path;\n } else if (published) {\n sortKey = createPublishedSortKey();\n } else if (version) {\n sortKey = createSortKey({\n version\n });\n } else {\n sortKey = createLatestSortKey();\n }\n /**\n * If partition key is still undefined, create one with id or pid\n */\n if (!partitionKey) {\n partitionKey = createPartitionKey({\n ...where,\n id: pid || (id as string)\n });\n }\n const keys = {\n PK: partitionKey,\n SK: sortKey\n };\n try {\n return await getClean({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not load page by given params.\",\n ex.code || \"GET_PAGE_ERROR\",\n {\n where,\n keys\n }\n );\n }\n };\n\n const list = async (\n params: PageStorageOperationsListParams\n ): Promise<PageStorageOperationsListResponse> => {\n /**\n * We do not allow loading both published and latest at the same time.\n * @see PageStorageOperationsListWhere\n */\n if (params.where.published && params.where.latest) {\n throw new WebinyError(\n \"Both published and latest cannot be defined at the same time.\",\n \"MALFORMED_WHERE_ERROR\",\n {\n where: params.where\n }\n );\n }\n\n const { after: previousCursor = null, limit: initialLimit } = params;\n\n const limit = createLimit(initialLimit, 50);\n const body = createElasticsearchQueryBody({\n ...params,\n where: {\n ...params.where\n },\n limit,\n after: previousCursor,\n plugins\n });\n\n let searchPlugins: SearchPagesPlugin[] = [];\n if (params.where.published) {\n searchPlugins = plugins.byType<SearchPublishedPagesPlugin>(\n SearchPublishedPagesPlugin.type\n );\n } else if (params.where.latest) {\n searchPlugins = plugins.byType<SearchLatestPagesPlugin>(SearchLatestPagesPlugin.type);\n } else {\n throw new WebinyError(\n \"Only published or latest can be listed. Missing where condition.\",\n \"MALFORMED_WHERE_ERROR\",\n {\n where: params.where\n }\n );\n }\n\n for (const plugin of searchPlugins) {\n /**\n * Apply query modifications\n */\n plugin.modifyQuery({\n query: body.query as unknown as ElasticsearchBoolQueryConfig,\n args: params,\n plugins\n });\n\n /**\n * Apply sort modifications\n */\n plugin.modifySort({\n sort: body.sort,\n args: params,\n plugins\n });\n }\n\n let response: ElasticsearchSearchResponse<Page>;\n const esConfig = configurations.es(params.where);\n try {\n response = await elasticsearch.search({\n ...esConfig,\n body\n });\n } catch (ex) {\n /**\n * Do not throw the error if Elasticsearch index does not exist.\n * In some CRUDs we try to get list of pages but index was not created yet.\n */\n if (shouldIgnoreEsResponseError(ex)) {\n logIgnoredEsResponseError({\n error: ex,\n indexName: esConfig.index\n });\n return {\n items: [],\n meta: {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null\n }\n };\n }\n throw new WebinyError(\n ex.message || \"Could not load pages by given Elasticsearch body.\",\n ex.code || \"LIST_PAGES_ERROR\",\n {\n body\n }\n );\n }\n const { hits, total } = response.body.hits;\n const items = hits.map(item => item._source).map(item => removePageAttributes(item));\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const cursor =\n items.length > 0 && hasMoreItems\n ? encodeCursor(hits[items.length - 1].sort) || null\n : null;\n return {\n items,\n meta: {\n hasMoreItems,\n totalCount: total.value,\n cursor\n }\n };\n };\n\n const listTags = async (params: PageStorageOperationsListTagsParams): Promise<string[]> => {\n const { where } = params;\n\n const tenant: string = where.tenant;\n const body = createElasticsearchQueryBody({\n ...params,\n where: {\n locale: where.locale,\n search: undefined,\n tenant\n },\n sort: [],\n after: null,\n limit: 100000,\n plugins\n });\n\n const esConfig = configurations.es(where);\n\n try {\n const response: ElasticsearchSearchResponse<string> = await elasticsearch.search({\n ...esConfig,\n body: {\n ...body,\n sort: undefined,\n limit: undefined,\n size: 0,\n aggs: {\n tags: {\n terms: {\n field: \"tags.keyword\",\n include: `.*${where.search}.*`,\n size: 10\n }\n }\n }\n }\n });\n\n const tags = response.body.aggregations[\"tags\"];\n if (!tags || Array.isArray(tags.buckets) === false) {\n return [];\n }\n return tags.buckets.map(item => item.key);\n } catch (ex) {\n if (shouldIgnoreEsResponseError(ex)) {\n logIgnoredEsResponseError({\n error: ex,\n indexName: esConfig.index\n });\n return [];\n }\n throw new WebinyError(\n ex.message || \"Could not list tags by given parameters.\",\n ex.code || \"LIST_TAGS_ERROR\",\n {\n body,\n where\n }\n );\n }\n };\n\n const listRevisions = async (\n params: PageStorageOperationsListRevisionsParams\n ): Promise<Page[]> => {\n const { where, sort } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n ...where,\n id: where.pid\n }),\n options: {\n beginsWith: \"REV#\",\n reverse: false\n }\n };\n\n let items: Page[] = [];\n try {\n items = await queryAll<Page>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not load all the revisions from requested page.\",\n ex.code || \"LOAD_PAGE_REVISIONS_ERROR\",\n {\n params\n }\n );\n }\n\n const fields = plugins.byType<PageDynamoDbElasticsearchFieldPlugin>(\n PageDynamoDbElasticsearchFieldPlugin.type\n );\n\n return sortItems({\n items: items.map(item => removePageAttributes(item)),\n fields,\n sort\n });\n };\n\n return {\n create,\n createFrom,\n update,\n delete: deleteOne,\n deleteAll: deleteAll,\n publish,\n unpublish,\n get,\n list,\n listRevisions,\n listTags\n };\n};\n"],"mappings":";;;;;;;AAiBA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA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exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.logIgnoredEsResponseError = void 0;
|
|
7
|
+
const logIgnoredEsResponseError = params => {
|
|
8
|
+
const {
|
|
9
|
+
error,
|
|
10
|
+
indexName
|
|
11
|
+
} = params;
|
|
12
|
+
if (process.env.DEBUG !== "true") {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
console.log(`Ignoring Elasticsearch response error: ${error.message}`, {
|
|
16
|
+
usedIndexName: indexName,
|
|
17
|
+
error: {
|
|
18
|
+
...error,
|
|
19
|
+
message: error.message,
|
|
20
|
+
code: error.code,
|
|
21
|
+
data: error.data,
|
|
22
|
+
stack: error.stack
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.logIgnoredEsResponseError = logIgnoredEsResponseError;
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=logIgnoredEsResponseError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["logIgnoredEsResponseError","params","error","indexName","process","env","DEBUG","console","log","message","usedIndexName","code","data","stack","exports"],"sources":["logIgnoredEsResponseError.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\ninterface LogIgnoredElasticsearchExceptionParams {\n error: WebinyError;\n indexName: string;\n}\n\nexport const logIgnoredEsResponseError = (params: LogIgnoredElasticsearchExceptionParams) => {\n const { error, indexName } = params;\n if (process.env.DEBUG !== \"true\") {\n return;\n }\n console.log(`Ignoring Elasticsearch response error: ${error.message}`, {\n usedIndexName: indexName,\n error: {\n ...error,\n message: error.message,\n code: error.code,\n data: error.data,\n stack: error.stack\n }\n });\n};\n"],"mappings":";;;;;;AAOO,MAAMA,yBAAyB,GAAIC,MAA8C,IAAK;EACzF,MAAM;IAAEC,KAAK;IAAEC;EAAU,CAAC,GAAGF,MAAM;EACnC,IAAIG,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,MAAM,EAAE;IAC9B;EACJ;EACAC,OAAO,CAACC,GAAG,CAAE,0CAAyCN,KAAK,CAACO,OAAQ,EAAC,EAAE;IACnEC,aAAa,EAAEP,SAAS;IACxBD,KAAK,EAAE;MACH,GAAGA,KAAK;MACRO,OAAO,EAAEP,KAAK,CAACO,OAAO;MACtBE,IAAI,EAAET,KAAK,CAACS,IAAI;MAChBC,IAAI,EAAEV,KAAK,CAACU,IAAI;MAChBC,KAAK,EAAEX,KAAK,CAACW;IACjB;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAd,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shouldIgnoreEsResponseError = void 0;
|
|
7
|
+
const IGNORED_ES_SEARCH_EXCEPTIONS = ["index_not_found_exception", "search_phase_execution_exception"];
|
|
8
|
+
const shouldIgnoreEsResponseError = error => {
|
|
9
|
+
return IGNORED_ES_SEARCH_EXCEPTIONS.includes(error.message);
|
|
10
|
+
};
|
|
11
|
+
exports.shouldIgnoreEsResponseError = shouldIgnoreEsResponseError;
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=shouldIgnoreEsResponseError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["IGNORED_ES_SEARCH_EXCEPTIONS","shouldIgnoreEsResponseError","error","includes","message","exports"],"sources":["shouldIgnoreEsResponseError.ts"],"sourcesContent":["import 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.includes(error.message);\n};\n"],"mappings":";;;;;;AAEA,MAAMA,4BAA4B,GAAG,CACjC,2BAA2B,EAC3B,kCAAkC,CACrC;AAEM,MAAMC,2BAA2B,GAAIC,KAAkB,IAAK;EAC/D,OAAOF,4BAA4B,CAACG,QAAQ,CAACD,KAAK,CAACE,OAAO,CAAC;AAC/D,CAAC;AAACC,OAAA,CAAAJ,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-page-builder-so-ddb-es",
|
|
3
|
-
"version": "5.41.0
|
|
3
|
+
"version": "5.41.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-page-builder",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@babel/runtime": "7.24.1",
|
|
26
|
-
"@webiny/api-elasticsearch": "5.41.0
|
|
27
|
-
"@webiny/api-elasticsearch-tasks": "5.41.0
|
|
28
|
-
"@webiny/api-page-builder": "5.41.0
|
|
29
|
-
"@webiny/aws-sdk": "5.41.0
|
|
30
|
-
"@webiny/db-dynamodb": "5.41.0
|
|
31
|
-
"@webiny/error": "5.41.0
|
|
32
|
-
"@webiny/handler-db": "5.41.0
|
|
33
|
-
"@webiny/plugins": "5.41.0
|
|
34
|
-
"@webiny/utils": "5.41.0
|
|
26
|
+
"@webiny/api-elasticsearch": "5.41.0",
|
|
27
|
+
"@webiny/api-elasticsearch-tasks": "5.41.0",
|
|
28
|
+
"@webiny/api-page-builder": "5.41.0",
|
|
29
|
+
"@webiny/aws-sdk": "5.41.0",
|
|
30
|
+
"@webiny/db-dynamodb": "5.41.0",
|
|
31
|
+
"@webiny/error": "5.41.0",
|
|
32
|
+
"@webiny/handler-db": "5.41.0",
|
|
33
|
+
"@webiny/plugins": "5.41.0",
|
|
34
|
+
"@webiny/utils": "5.41.0",
|
|
35
35
|
"dataloader": "2.2.1",
|
|
36
36
|
"elastic-ts": "0.8.0",
|
|
37
37
|
"lodash": "4.17.21"
|
|
@@ -43,25 +43,25 @@
|
|
|
43
43
|
"@babel/preset-typescript": "7.24.1",
|
|
44
44
|
"@elastic/elasticsearch": "7.12.0",
|
|
45
45
|
"@elastic/elasticsearch-mock": "0.3.0",
|
|
46
|
-
"@webiny/api": "5.41.0
|
|
47
|
-
"@webiny/api-aco": "5.41.0
|
|
48
|
-
"@webiny/api-dynamodb-to-elasticsearch": "5.41.0
|
|
49
|
-
"@webiny/api-headless-cms": "5.41.0
|
|
50
|
-
"@webiny/api-headless-cms-ddb-es": "5.41.0
|
|
51
|
-
"@webiny/api-i18n": "5.41.0
|
|
52
|
-
"@webiny/api-i18n-ddb": "5.41.0
|
|
53
|
-
"@webiny/api-page-builder-aco": "5.41.0
|
|
54
|
-
"@webiny/api-prerendering-service": "5.41.0
|
|
55
|
-
"@webiny/api-security": "5.41.0
|
|
56
|
-
"@webiny/api-security-so-ddb": "5.41.0
|
|
57
|
-
"@webiny/api-tenancy": "5.41.0
|
|
58
|
-
"@webiny/api-tenancy-so-ddb": "5.41.0
|
|
59
|
-
"@webiny/api-wcp": "5.41.0
|
|
60
|
-
"@webiny/cli": "5.41.0
|
|
61
|
-
"@webiny/handler": "5.41.0
|
|
62
|
-
"@webiny/handler-aws": "5.41.0
|
|
63
|
-
"@webiny/handler-graphql": "5.41.0
|
|
64
|
-
"@webiny/project-utils": "5.41.0
|
|
46
|
+
"@webiny/api": "5.41.0",
|
|
47
|
+
"@webiny/api-aco": "5.41.0",
|
|
48
|
+
"@webiny/api-dynamodb-to-elasticsearch": "5.41.0",
|
|
49
|
+
"@webiny/api-headless-cms": "5.41.0",
|
|
50
|
+
"@webiny/api-headless-cms-ddb-es": "5.41.0",
|
|
51
|
+
"@webiny/api-i18n": "5.41.0",
|
|
52
|
+
"@webiny/api-i18n-ddb": "5.41.0",
|
|
53
|
+
"@webiny/api-page-builder-aco": "5.41.0",
|
|
54
|
+
"@webiny/api-prerendering-service": "5.41.0",
|
|
55
|
+
"@webiny/api-security": "5.41.0",
|
|
56
|
+
"@webiny/api-security-so-ddb": "5.41.0",
|
|
57
|
+
"@webiny/api-tenancy": "5.41.0",
|
|
58
|
+
"@webiny/api-tenancy-so-ddb": "5.41.0",
|
|
59
|
+
"@webiny/api-wcp": "5.41.0",
|
|
60
|
+
"@webiny/cli": "5.41.0",
|
|
61
|
+
"@webiny/handler": "5.41.0",
|
|
62
|
+
"@webiny/handler-aws": "5.41.0",
|
|
63
|
+
"@webiny/handler-graphql": "5.41.0",
|
|
64
|
+
"@webiny/project-utils": "5.41.0",
|
|
65
65
|
"graphql": "15.8.0",
|
|
66
66
|
"jest": "29.7.0",
|
|
67
67
|
"jest-dynalite": "3.6.1",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"build": "yarn webiny run build",
|
|
78
78
|
"watch": "yarn webiny run watch"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "a542f4d0806744c5e2333b3786478c4af3b6b750"
|
|
81
81
|
}
|