@webiny/api-headless-cms-ddb-es 0.0.0-unstable.97a151f74d → 0.0.0-unstable.aad28a72ae

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.
@@ -80,6 +80,13 @@ const createLongTextStorageTransformPlugin = () => {
80
80
  toStorage: async ({
81
81
  value: initialValue
82
82
  }) => {
83
+ /**
84
+ * There is a possibility that we are trying to compress already compressed value.
85
+ */
86
+ if (initialValue && initialValue.hasOwnProperty("compression") === true) {
87
+ return initialValue;
88
+ }
89
+
83
90
  const isArray = Array.isArray(initialValue);
84
91
  const value = isArray ? JSON.stringify(initialValue) : initialValue;
85
92
  const compressedValue = await (0, _gzip.compress)(value);
@@ -1 +1 @@
1
- {"version":3,"names":["GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","typeOf","Array","isArray","WebinyError","storageId","fieldId","compression","JSON","stringify","buf","ungzip","result","toString","parse","ex","console","log","message","toStorage","initialValue","compressedValue","gzip"],"sources":["longText.ts"],"sourcesContent":["/**\n * File is @internal\n */\n\nimport WebinyError from \"@webiny/error\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer): Buffer => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface StorageValue {\n compression: string;\n value: string;\n isArray?: boolean;\n}\n\nexport const createLongTextStorageTransformPlugin = () => {\n return new StorageTransformPlugin<string | string[], StorageValue>({\n fieldType: \"long-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n const typeOf = typeof storageValue;\n if (\n !storageValue ||\n typeOf === \"string\" ||\n typeOf === \"number\" ||\n Array.isArray(storageValue) === true\n ) {\n return storageValue as unknown as string | string[];\n } else if (typeOf !== \"object\") {\n throw new WebinyError(\n `LongText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n const { compression, value, isArray } = storageValue;\n /**\n * Check if possibly undefined, null, empty...\n */\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.storageId\n }\" - ${field.fieldId}.\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n } else if (compression !== GZIP) {\n throw new WebinyError(\n `This plugin cannot transform something not compressed with \"GZIP\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n const buf = await ungzip(convertToBuffer(value));\n const result = buf.toString(FROM_STORAGE_ENCODING);\n if (!isArray) {\n return result;\n }\n return JSON.parse(result);\n } catch (ex) {\n console.log(\"Error while transforming long-text.\");\n console.log(ex.message);\n return \"\";\n }\n },\n toStorage: async ({ value: initialValue }) => {\n const isArray = Array.isArray(initialValue);\n const value = isArray ? JSON.stringify(initialValue) : initialValue;\n const compressedValue = await gzip(value);\n\n const result: StorageValue = {\n compression: GZIP,\n value: compressedValue.toString(TO_STORAGE_ENCODING)\n };\n if (!isArray) {\n return result;\n }\n result.isArray = isArray;\n return result;\n }\n });\n};\n"],"mappings":";;;;;;;;;AAIA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,MAAb;AACA,MAAMC,mBAAmB,GAAG,QAA5B;AACA,MAAMC,qBAAqB,GAAG,MAA9B;;AAEA,MAAMC,eAAe,GAAIC,KAAD,IAAoC;EACxD,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;IAC3B,OAAOC,MAAM,CAACC,IAAP,CAAYF,KAAZ,EAAmBH,mBAAnB,CAAP;EACH;;EACD,OAAOG,KAAP;AACH,CALD;;AAaO,MAAMG,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,OAAOG,EAAP,EAAW;QACTC,OAAO,CAACC,GAAR,CAAY,qCAAZ;QACAD,OAAO,CAACC,GAAR,CAAYF,EAAE,CAACG,OAAf;QACA,OAAO,EAAP;MACH;IACJ,CAnD8D;IAoD/DC,SAAS,EAAE,OAAO;MAAE3B,KAAK,EAAE4B;IAAT,CAAP,KAAmC;MAC1C,MAAMjB,OAAO,GAAGD,KAAK,CAACC,OAAN,CAAciB,YAAd,CAAhB;MACA,MAAM5B,KAAK,GAAGW,OAAO,GAAGK,IAAI,CAACC,SAAL,CAAeW,YAAf,CAAH,GAAkCA,YAAvD;MACA,MAAMC,eAAe,GAAG,MAAM,IAAAC,cAAA,EAAK9B,KAAL,CAA9B;MAEA,MAAMoB,MAAoB,GAAG;QACzBL,WAAW,EAAEnB,IADY;QAEzBI,KAAK,EAAE6B,eAAe,CAACR,QAAhB,CAAyBxB,mBAAzB;MAFkB,CAA7B;;MAIA,IAAI,CAACc,OAAL,EAAc;QACV,OAAOS,MAAP;MACH;;MACDA,MAAM,CAACT,OAAP,GAAiBA,OAAjB;MACA,OAAOS,MAAP;IACH;EAlE8D,CAA5D,CAAP;AAoEH,CArEM"}
1
+ {"version":3,"names":["GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","typeOf","Array","isArray","WebinyError","storageId","fieldId","compression","JSON","stringify","buf","ungzip","result","toString","parse","ex","console","log","message","toStorage","initialValue","hasOwnProperty","compressedValue","gzip"],"sources":["longText.ts"],"sourcesContent":["/**\n * File is @internal\n */\n\nimport WebinyError from \"@webiny/error\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer): Buffer => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface StorageValue {\n compression: string;\n value: string;\n isArray?: boolean;\n}\n\nexport const createLongTextStorageTransformPlugin = () => {\n return new StorageTransformPlugin<string | string[], StorageValue>({\n fieldType: \"long-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n const typeOf = typeof storageValue;\n if (\n !storageValue ||\n typeOf === \"string\" ||\n typeOf === \"number\" ||\n Array.isArray(storageValue) === true\n ) {\n return storageValue as unknown as string | string[];\n } else if (typeOf !== \"object\") {\n throw new WebinyError(\n `LongText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n const { compression, value, isArray } = storageValue;\n /**\n * Check if possibly undefined, null, empty...\n */\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.storageId\n }\" - ${field.fieldId}.\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n } else if (compression !== GZIP) {\n throw new WebinyError(\n `This plugin cannot transform something not compressed with \"GZIP\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n const buf = await ungzip(convertToBuffer(value));\n const result = buf.toString(FROM_STORAGE_ENCODING);\n if (!isArray) {\n return result;\n }\n return JSON.parse(result);\n } catch (ex) {\n console.log(\"Error while transforming long-text.\");\n console.log(ex.message);\n return \"\";\n }\n },\n toStorage: async ({ value: initialValue }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n */\n if (initialValue && initialValue.hasOwnProperty(\"compression\") === true) {\n return initialValue as any;\n }\n const isArray = Array.isArray(initialValue);\n const value = isArray ? JSON.stringify(initialValue) : initialValue;\n const compressedValue = await gzip(value);\n\n const result: StorageValue = {\n compression: GZIP,\n value: compressedValue.toString(TO_STORAGE_ENCODING)\n };\n if (!isArray) {\n return result;\n }\n result.isArray = isArray;\n return result;\n }\n });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BoolQueryConfig } from "@webiny/api-elasticsearch/types";
2
+ /**
3
+ * This function will assign a minimum_should_match for the query if conditions are met:
4
+ * * should is an array
5
+ * * it is not empty
6
+ * * minimum_should_match is not already set
7
+ *
8
+ *
9
+ * By the default we set it to 1 as we want at least one OR condition to produce results.
10
+ *
11
+ * Users can modify minimum_should_match value via the body or query modification plugins.
12
+ */
13
+ interface Params {
14
+ query: BoolQueryConfig;
15
+ value?: number;
16
+ }
17
+ export declare const assignMinimumShouldMatchToQuery: ({ query, value }: Params) => void;
18
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.assignMinimumShouldMatchToQuery = void 0;
7
+
8
+ /**
9
+ * This function will assign a minimum_should_match for the query if conditions are met:
10
+ * * should is an array
11
+ * * it is not empty
12
+ * * minimum_should_match is not already set
13
+ *
14
+ *
15
+ * By the default we set it to 1 as we want at least one OR condition to produce results.
16
+ *
17
+ * Users can modify minimum_should_match value via the body or query modification plugins.
18
+ */
19
+ const assignMinimumShouldMatchToQuery = ({
20
+ query,
21
+ value = 1
22
+ }) => {
23
+ if (!Array.isArray(query.should)) {
24
+ return;
25
+ } else if (query.should.length === 0) {
26
+ return;
27
+ } else if (query.minimum_should_match) {
28
+ return;
29
+ }
30
+
31
+ query.minimum_should_match = value > 0 ? value : 1;
32
+ };
33
+
34
+ exports.assignMinimumShouldMatchToQuery = assignMinimumShouldMatchToQuery;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["assignMinimumShouldMatchToQuery","query","value","Array","isArray","should","length","minimum_should_match"],"sources":["assignMinimumShouldMatchToQuery.ts"],"sourcesContent":["import { BoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\n\n/**\n * This function will assign a minimum_should_match for the query if conditions are met:\n * * should is an array\n * * it is not empty\n * * minimum_should_match is not already set\n *\n *\n * By the default we set it to 1 as we want at least one OR condition to produce results.\n *\n * Users can modify minimum_should_match value via the body or query modification plugins.\n */\ninterface Params {\n query: BoolQueryConfig;\n value?: number;\n}\nexport const assignMinimumShouldMatchToQuery = ({ query, value = 1 }: Params): void => {\n if (!Array.isArray(query.should)) {\n return;\n } else if (query.should.length === 0) {\n return;\n } else if (query.minimum_should_match) {\n return;\n }\n query.minimum_should_match = value > 0 ? value : 1;\n};\n"],"mappings":";;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKO,MAAMA,+BAA+B,GAAG,CAAC;EAAEC,KAAF;EAASC,KAAK,GAAG;AAAjB,CAAD,KAAwC;EACnF,IAAI,CAACC,KAAK,CAACC,OAAN,CAAcH,KAAK,CAACI,MAApB,CAAL,EAAkC;IAC9B;EACH,CAFD,MAEO,IAAIJ,KAAK,CAACI,MAAN,CAAaC,MAAb,KAAwB,CAA5B,EAA+B;IAClC;EACH,CAFM,MAEA,IAAIL,KAAK,CAACM,oBAAV,EAAgC;IACnC;EACH;;EACDN,KAAK,CAACM,oBAAN,GAA6BL,KAAK,GAAG,CAAR,GAAYA,KAAZ,GAAoB,CAAjD;AACH,CATM"}
@@ -23,6 +23,8 @@ var _sort = require("./sort");
23
23
 
24
24
  var _filtering = require("./filtering");
25
25
 
26
+ var _assignMinimumShouldMatchToQuery = require("./assignMinimumShouldMatchToQuery");
27
+
26
28
  const createElasticsearchBody = ({
27
29
  plugins,
28
30
  model,
@@ -133,11 +135,9 @@ const createElasticsearchBody = ({
133
135
  should: query.should.length > 0 ? query.should : undefined,
134
136
  filter: query.filter.length > 0 ? query.filter : undefined
135
137
  };
136
-
137
- if (Array.isArray(boolQuery.should) && boolQuery.should.length > 1 && !boolQuery.minimum_should_match) {
138
- boolQuery.minimum_should_match = 1;
139
- }
140
-
138
+ (0, _assignMinimumShouldMatchToQuery.assignMinimumShouldMatchToQuery)({
139
+ query: boolQuery
140
+ });
141
141
  const body = {
142
142
  query: {
143
143
  bool: boolQuery
@@ -1 +1 @@
1
- {"version":3,"names":["createElasticsearchBody","plugins","model","params","fields","search","term","where","sort","initialSort","after","limit","modelFields","createModelFields","queryModifierPlugins","createQueryModifierPluginList","sortModifierPlugins","createSortModifierPluginList","bodyModifierPlugins","createBodyModifierPluginList","fullTextSearchFields","createFullTextSearchFields","query","createInitialQuery","applyFullTextSearch","execFiltering","createExecFiltering","pl","modifyQuery","createElasticsearchSort","modifySort","boolQuery","must","length","undefined","must_not","should","filter","Array","isArray","minimum_should_match","body","bool","size","search_after","track_total_hits","modifyBody"],"sources":["body.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryListParams, CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { createModelFields } from \"./fields\";\nimport { createFullTextSearchFields } from \"./fullTextSearchFields\";\nimport { createInitialQuery } from \"./initialQuery\";\nimport { applyFullTextSearch } from \"./fullTextSearch\";\nimport { createQueryModifierPluginList } from \"./plugins/queryModifier\";\nimport { createSortModifierPluginList } from \"./plugins/sortModifier\";\nimport { createBodyModifierPluginList } from \"./plugins/bodyModifier\";\nimport { createElasticsearchSort } from \"./sort\";\nimport { PrimitiveValue, SearchBody, BoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { createExecFiltering } from \"./filtering\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n params: Omit<CmsEntryListParams, \"where\" | \"after\"> & {\n where: CmsEntryListWhere;\n after?: PrimitiveValue[];\n };\n}\nexport const createElasticsearchBody = ({ plugins, model, params }: Params): SearchBody => {\n const { fields, search: term, where, sort: initialSort, after, limit } = params;\n /**\n * We need the model fields constructed as a key -> field value, so we do not need to iterate through array when we require some field.\n */\n const modelFields = createModelFields({\n plugins,\n fields: model.fields\n });\n\n /**\n * We need the query modifier plugins.\n */\n const queryModifierPlugins = createQueryModifierPluginList({\n plugins,\n model\n });\n /**\n * We need the sort modifier plugins.\n */\n const sortModifierPlugins = createSortModifierPluginList({\n plugins,\n model\n });\n /**\n * We need the body modifier plugins.\n */\n const bodyModifierPlugins = createBodyModifierPluginList({\n plugins,\n model\n });\n /**\n * We need the fields which we can search through via the full text search.\n *\n */\n const fullTextSearchFields = createFullTextSearchFields({\n model,\n term,\n 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 query,\n term,\n fields: fullTextSearchFields\n });\n\n const execFiltering = createExecFiltering({\n model,\n fields: modelFields,\n plugins\n });\n\n execFiltering({\n where,\n query\n });\n\n for (const pl of queryModifierPlugins) {\n pl.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSort({\n plugins,\n sort: initialSort,\n modelFields,\n model\n });\n\n for (const pl of sortModifierPlugins) {\n pl.modifySort({\n sort,\n model\n });\n }\n\n const boolQuery: BoolQueryConfig = {\n must: query.must.length > 0 ? query.must : undefined,\n must_not: query.must_not.length > 0 ? query.must_not : undefined,\n should: query.should.length > 0 ? query.should : undefined,\n filter: query.filter.length > 0 ? query.filter : undefined\n };\n if (\n Array.isArray(boolQuery.should) &&\n boolQuery.should.length > 1 &&\n !boolQuery.minimum_should_match\n ) {\n boolQuery.minimum_should_match = 1;\n }\n\n const body: SearchBody = {\n query: {\n bool: boolQuery\n },\n sort,\n size: (limit || 0) + 1,\n search_after: after,\n track_total_hits: true\n };\n\n for (const pl of bodyModifierPlugins) {\n pl.modifyBody({\n body,\n model,\n where\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAUO,MAAMA,uBAAuB,GAAG,CAAC;EAAEC,OAAF;EAAWC,KAAX;EAAkBC;AAAlB,CAAD,KAAoD;EACvF,MAAM;IAAEC,MAAF;IAAUC,MAAM,EAAEC,IAAlB;IAAwBC,KAAxB;IAA+BC,IAAI,EAAEC,WAArC;IAAkDC,KAAlD;IAAyDC;EAAzD,IAAmER,MAAzE;EACA;AACJ;AACA;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","search","term","where","sort","initialSort","after","limit","modelFields","createModelFields","queryModifierPlugins","createQueryModifierPluginList","sortModifierPlugins","createSortModifierPluginList","bodyModifierPlugins","createBodyModifierPluginList","fullTextSearchFields","createFullTextSearchFields","query","createInitialQuery","applyFullTextSearch","execFiltering","createExecFiltering","pl","modifyQuery","createElasticsearchSort","modifySort","boolQuery","must","length","undefined","must_not","should","filter","assignMinimumShouldMatchToQuery","body","bool","size","search_after","track_total_hits","modifyBody"],"sources":["body.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryListParams, CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { createModelFields } from \"./fields\";\nimport { createFullTextSearchFields } from \"./fullTextSearchFields\";\nimport { createInitialQuery } from \"./initialQuery\";\nimport { applyFullTextSearch } from \"./fullTextSearch\";\nimport { createQueryModifierPluginList } from \"./plugins/queryModifier\";\nimport { createSortModifierPluginList } from \"./plugins/sortModifier\";\nimport { createBodyModifierPluginList } from \"./plugins/bodyModifier\";\nimport { createElasticsearchSort } from \"./sort\";\nimport { PrimitiveValue, SearchBody, BoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { createExecFiltering } from \"./filtering\";\nimport { assignMinimumShouldMatchToQuery } from \"./assignMinimumShouldMatchToQuery\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n params: Omit<CmsEntryListParams, \"where\" | \"after\"> & {\n where: CmsEntryListWhere;\n after?: PrimitiveValue[];\n };\n}\nexport const createElasticsearchBody = ({ plugins, model, params }: Params): SearchBody => {\n const { fields, search: term, where, sort: initialSort, after, limit } = params;\n /**\n * We need the model fields constructed as a key -> field value, so we do not need to iterate through array when we require some field.\n */\n const modelFields = createModelFields({\n plugins,\n fields: model.fields\n });\n\n /**\n * We need the query modifier plugins.\n */\n const queryModifierPlugins = createQueryModifierPluginList({\n plugins,\n model\n });\n /**\n * We need the sort modifier plugins.\n */\n const sortModifierPlugins = createSortModifierPluginList({\n plugins,\n model\n });\n /**\n * We need the body modifier plugins.\n */\n const bodyModifierPlugins = createBodyModifierPluginList({\n plugins,\n model\n });\n /**\n * We need the fields which we can search through via the full text search.\n *\n */\n const fullTextSearchFields = createFullTextSearchFields({\n model,\n term,\n 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 query,\n term,\n fields: fullTextSearchFields\n });\n\n const execFiltering = createExecFiltering({\n model,\n fields: modelFields,\n plugins\n });\n\n execFiltering({\n where,\n query\n });\n\n for (const pl of queryModifierPlugins) {\n pl.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSort({\n plugins,\n sort: initialSort,\n modelFields,\n model\n });\n\n for (const pl of sortModifierPlugins) {\n pl.modifySort({\n sort,\n model\n });\n }\n\n const boolQuery: BoolQueryConfig = {\n must: query.must.length > 0 ? query.must : undefined,\n must_not: query.must_not.length > 0 ? query.must_not : undefined,\n should: query.should.length > 0 ? query.should : undefined,\n filter: query.filter.length > 0 ? query.filter : undefined\n };\n\n assignMinimumShouldMatchToQuery({\n query: boolQuery\n });\n\n const body: SearchBody = {\n query: {\n bool: boolQuery\n },\n sort,\n size: (limit || 0) + 1,\n search_after: after,\n track_total_hits: true\n };\n\n for (const pl of bodyModifierPlugins) {\n pl.modifyBody({\n body,\n model,\n where\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAUO,MAAMA,uBAAuB,GAAG,CAAC;EAAEC,OAAF;EAAWC,KAAX;EAAkBC;AAAlB,CAAD,KAAoD;EACvF,MAAM;IAAEC,MAAF;IAAUC,MAAM,EAAEC,IAAlB;IAAwBC,KAAxB;IAA+BC,IAAI,EAAEC,WAArC;IAAkDC,KAAlD;IAAyDC;EAAzD,IAAmER,MAAzE;EACA;AACJ;AACA;;EACI,MAAMS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Ab;;EAOA,KAAK,MAAMyB,EAAX,IAAiBX,mBAAjB,EAAsC;IAClCW,EAAE,CAACG,UAAH,CAAc;MACVtB,IADU;MAEVN;IAFU,CAAd;EAIH;;EAED,MAAM6B,SAA0B,GAAG;IAC/BC,IAAI,EAAEV,KAAK,CAACU,IAAN,CAAWC,MAAX,GAAoB,CAApB,GAAwBX,KAAK,CAACU,IAA9B,GAAqCE,SADZ;IAE/BC,QAAQ,EAAEb,KAAK,CAACa,QAAN,CAAeF,MAAf,GAAwB,CAAxB,GAA4BX,KAAK,CAACa,QAAlC,GAA6CD,SAFxB;IAG/BE,MAAM,EAAEd,KAAK,CAACc,MAAN,CAAaH,MAAb,GAAsB,CAAtB,GAA0BX,KAAK,CAACc,MAAhC,GAAyCF,SAHlB;IAI/BG,MAAM,EAAEf,KAAK,CAACe,MAAN,CAAaJ,MAAb,GAAsB,CAAtB,GAA0BX,KAAK,CAACe,MAAhC,GAAyCH;EAJlB,CAAnC;EAOA,IAAAI,gEAAA,EAAgC;IAC5BhB,KAAK,EAAES;EADqB,CAAhC;EAIA,MAAMQ,IAAgB,GAAG;IACrBjB,KAAK,EAAE;MACHkB,IAAI,EAAET;IADH,CADc;IAIrBvB,IAJqB;IAKrBiC,IAAI,EAAE,CAAC9B,KAAK,IAAI,CAAV,IAAe,CALA;IAMrB+B,YAAY,EAAEhC,KANO;IAOrBiC,gBAAgB,EAAE;EAPG,CAAzB;;EAUA,KAAK,MAAMhB,EAAX,IAAiBT,mBAAjB,EAAsC;IAClCS,EAAE,CAACiB,UAAH,CAAc;MACVL,IADU;MAEVrC,KAFU;MAGVK;IAHU,CAAd;EAKH;;EAED,OAAOgC,IAAP;AACH,CAnHM"}
@@ -27,6 +27,8 @@ var _applyFiltering = require("./applyFiltering");
27
27
 
28
28
  var _CmsEntryFilterPlugin = require("../../../../plugins/CmsEntryFilterPlugin");
29
29
 
30
+ var _assignMinimumShouldMatchToQuery = require("../assignMinimumShouldMatchToQuery");
31
+
30
32
  const createExecFiltering = params => {
31
33
  const {
32
34
  fields,
@@ -147,7 +149,7 @@ const createExecFiltering = params => {
147
149
  }
148
150
 
149
151
  should.push({
150
- bool: (0, _objectSpread2.default)({}, childQueryBool)
152
+ bool: childQueryBool
151
153
  });
152
154
  }
153
155
 
@@ -161,10 +163,9 @@ const createExecFiltering = params => {
161
163
  * Of course, do not override if it's already set.
162
164
  */
163
165
 
164
- if (query.should.length > 0 && !query.minimum_should_match) {
165
- query.minimum_should_match = 1;
166
- }
167
-
166
+ (0, _assignMinimumShouldMatchToQuery.assignMinimumShouldMatchToQuery)({
167
+ query
168
+ });
168
169
  continue;
169
170
  }
170
171
 
@@ -1 +1 @@
1
- {"version":3,"names":["createExecFiltering","params","fields","plugins","model","searchPlugins","createSearchPluginList","operatorPlugins","createOperatorPluginList","locale","applyFiltering","createApplyFiltering","filteringPlugins","byType","CmsEntryFilterPlugin","type","reduce","collection","plugin","fieldType","getFilterPlugin","WebinyError","execFiltering","where","initialWhere","query","keys","Object","length","key","value","undefined","childWhereList","getWhereValues","childQuery","createBaseQuery","childWhere","childQueryBool","getPopulated","filter","push","bool","should","minimum_should_match","field","whereFieldId","operator","parseWhereKey","fieldId","cmsModelField","find","f","filterPlugin","exec"],"sources":["exec.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ModelFields } from \"~/operations/entry/elasticsearch/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchBoolQueryConfig, Query } from \"@webiny/api-elasticsearch/types\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createOperatorPluginList } from \"~/operations/entry/elasticsearch/plugins/operator\";\nimport { createBaseQuery } from \"~/operations/entry/elasticsearch/initialQuery\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport { getWhereValues } from \"./values\";\nimport { getPopulated } from \"./populated\";\nimport { createApplyFiltering } from \"./applyFiltering\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\n\nexport interface CreateExecParams {\n model: CmsModel;\n fields: ModelFields;\n plugins: PluginsContainer;\n}\nexport interface ExecParams {\n where: CmsEntryListWhere;\n query: ElasticsearchBoolQueryConfig;\n}\nexport interface CreateExecFilteringResponse {\n (params: ExecParams): void;\n}\nexport const createExecFiltering = (params: CreateExecParams): CreateExecFilteringResponse => {\n const { fields, plugins, model } = params;\n\n /**\n * We need the search plugins as key -> plugin value, so it is easy to find plugin we need, without iterating through array.\n */\n const searchPlugins = createSearchPluginList({\n plugins\n });\n /**\n * We need the operator plugins, which we execute on our where conditions.\n */\n const operatorPlugins = createOperatorPluginList({\n plugins,\n locale: model.locale\n });\n\n const applyFiltering = createApplyFiltering({\n operatorPlugins,\n searchPlugins\n });\n\n const filteringPlugins = plugins\n .byType<CmsEntryFilterPlugin>(CmsEntryFilterPlugin.type)\n .reduce<Record<string, CmsEntryFilterPlugin>>((collection, plugin) => {\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {});\n\n const getFilterPlugin = (type: string) => {\n const plugin = filteringPlugins[type] || filteringPlugins[\"*\"];\n if (plugin) {\n return plugin;\n }\n throw new WebinyError(\n `There is no filtering plugin for the given field type \"${type}\".`,\n \"FILTERING_PLUGIN_ERROR\",\n {\n type\n }\n );\n };\n\n const execFiltering = (params: ExecParams) => {\n const { where: initialWhere, query } = params;\n /**\n * No point in continuing if no \"where\" conditions exist.\n */\n const keys = Object.keys(initialWhere);\n if (keys.length === 0) {\n return;\n }\n const where: CmsEntryListWhere = {\n ...initialWhere\n };\n\n for (const key in where) {\n const value = where[key] as unknown as any;\n /**\n * We always skip if no value is defined.\n * Only skip undefined value, null is valid.\n */\n if (value === undefined) {\n continue;\n }\n //\n /**\n * When we are running with AND, the \"value\" MUST be an array.\n */\n else if (key === \"AND\") {\n const childWhereList = getWhereValues(value, \"AND\");\n\n const childQuery = createBaseQuery();\n\n for (const childWhere of childWhereList) {\n execFiltering({\n query: childQuery,\n where: childWhere\n });\n }\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n query.filter.push({\n bool: childQueryBool\n });\n\n continue;\n }\n //\n /**\n * When we are running with OR, the \"value\" must be an array.\n */\n else if (key === \"OR\") {\n const childWhereList = getWhereValues(value, \"OR\");\n /**\n * Each of the conditions MUST produce it's own should section.\n */\n const should: Query[] = [];\n for (const childWhere of childWhereList) {\n const childQuery = createBaseQuery();\n execFiltering({\n query: childQuery,\n where: childWhere\n });\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n should.push({\n bool: {\n ...childQueryBool\n }\n });\n }\n if (should.length === 0) {\n continue;\n }\n query.should.push(...should);\n /**\n * If there are any should, minimum to have is 1.\n * Of course, do not override if it's already set.\n */\n if (query.should.length > 0 && !query.minimum_should_match) {\n query.minimum_should_match = 1;\n }\n\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n let fieldId: string = whereFieldId;\n\n /**\n * TODO This will be required until the storage operations receive the fieldId instead of field storageId.\n * TODO For this to work without field searching, we need to refactor how the query looks like.\n *\n * Storage operations should NEVER receive an field storageId, only alias - fieldId.\n */\n const cmsModelField = model.fields.find(f => f.fieldId === fieldId);\n if (!cmsModelField && !fields[fieldId]) {\n throw new WebinyError(`There is no CMS Model Field field \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const field = fields[fieldId];\n if (!field) {\n throw new WebinyError(`There is no field \"${fieldId}\".`);\n }\n const filterPlugin = getFilterPlugin(field.type);\n\n filterPlugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n };\n\n return execFiltering;\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAcO,MAAMA,mBAAmB,GAAIC,MAA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AIdC,KAJc;QAKdgB,QALc;QAMdF,KANc;QAOd1C,MAPc;QAQduB;MARc,CAAlB;IAUH;EACJ,CAzHD;;EA2HA,OAAOH,aAAP;AACH,CAxKM"}
1
+ {"version":3,"names":["createExecFiltering","params","fields","plugins","model","searchPlugins","createSearchPluginList","operatorPlugins","createOperatorPluginList","locale","applyFiltering","createApplyFiltering","filteringPlugins","byType","CmsEntryFilterPlugin","type","reduce","collection","plugin","fieldType","getFilterPlugin","WebinyError","execFiltering","where","initialWhere","query","keys","Object","length","key","value","undefined","childWhereList","getWhereValues","childQuery","createBaseQuery","childWhere","childQueryBool","getPopulated","filter","push","bool","should","assignMinimumShouldMatchToQuery","field","whereFieldId","operator","parseWhereKey","fieldId","cmsModelField","find","f","filterPlugin","exec"],"sources":["exec.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ModelFields } from \"~/operations/entry/elasticsearch/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchBoolQueryConfig, Query } from \"@webiny/api-elasticsearch/types\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createOperatorPluginList } from \"~/operations/entry/elasticsearch/plugins/operator\";\nimport { createBaseQuery } from \"~/operations/entry/elasticsearch/initialQuery\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport { getWhereValues } from \"./values\";\nimport { getPopulated } from \"./populated\";\nimport { createApplyFiltering } from \"./applyFiltering\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { assignMinimumShouldMatchToQuery } from \"~/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery\";\n\nexport interface CreateExecParams {\n model: CmsModel;\n fields: ModelFields;\n plugins: PluginsContainer;\n}\nexport interface ExecParams {\n where: CmsEntryListWhere;\n query: ElasticsearchBoolQueryConfig;\n}\nexport interface CreateExecFilteringResponse {\n (params: ExecParams): void;\n}\nexport const createExecFiltering = (params: CreateExecParams): CreateExecFilteringResponse => {\n const { fields, plugins, model } = params;\n\n /**\n * We need the search plugins as key -> plugin value, so it is easy to find plugin we need, without iterating through array.\n */\n const searchPlugins = createSearchPluginList({\n plugins\n });\n /**\n * We need the operator plugins, which we execute on our where conditions.\n */\n const operatorPlugins = createOperatorPluginList({\n plugins,\n locale: model.locale\n });\n\n const applyFiltering = createApplyFiltering({\n operatorPlugins,\n searchPlugins\n });\n\n const filteringPlugins = plugins\n .byType<CmsEntryFilterPlugin>(CmsEntryFilterPlugin.type)\n .reduce<Record<string, CmsEntryFilterPlugin>>((collection, plugin) => {\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {});\n\n const getFilterPlugin = (type: string) => {\n const plugin = filteringPlugins[type] || filteringPlugins[\"*\"];\n if (plugin) {\n return plugin;\n }\n throw new WebinyError(\n `There is no filtering plugin for the given field type \"${type}\".`,\n \"FILTERING_PLUGIN_ERROR\",\n {\n type\n }\n );\n };\n\n const execFiltering = (params: ExecParams) => {\n const { where: initialWhere, query } = params;\n /**\n * No point in continuing if no \"where\" conditions exist.\n */\n const keys = Object.keys(initialWhere);\n if (keys.length === 0) {\n return;\n }\n const where: CmsEntryListWhere = {\n ...initialWhere\n };\n\n for (const key in where) {\n const value = where[key] as unknown as any;\n /**\n * We always skip if no value is defined.\n * Only skip undefined value, null is valid.\n */\n if (value === undefined) {\n continue;\n }\n //\n /**\n * When we are running with AND, the \"value\" MUST be an array.\n */\n else if (key === \"AND\") {\n const childWhereList = getWhereValues(value, \"AND\");\n\n const childQuery = createBaseQuery();\n\n for (const childWhere of childWhereList) {\n execFiltering({\n query: childQuery,\n where: childWhere\n });\n }\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n query.filter.push({\n bool: childQueryBool\n });\n\n continue;\n }\n //\n /**\n * When we are running with OR, the \"value\" must be an array.\n */\n else if (key === \"OR\") {\n const childWhereList = getWhereValues(value, \"OR\");\n /**\n * Each of the conditions MUST produce it's own should section.\n */\n const should: Query[] = [];\n for (const childWhere of childWhereList) {\n const childQuery = createBaseQuery();\n execFiltering({\n query: childQuery,\n where: childWhere\n });\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n should.push({\n bool: childQueryBool\n });\n }\n if (should.length === 0) {\n continue;\n }\n query.should.push(...should);\n /**\n * If there are any should, minimum to have is 1.\n * Of course, do not override if it's already set.\n */\n assignMinimumShouldMatchToQuery({\n query\n });\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n let fieldId: string = whereFieldId;\n\n /**\n * TODO This will be required until the storage operations receive the fieldId instead of field storageId.\n * TODO For this to work without field searching, we need to refactor how the query looks like.\n *\n * Storage operations should NEVER receive an field storageId, only alias - fieldId.\n */\n const cmsModelField = model.fields.find(f => f.fieldId === fieldId);\n if (!cmsModelField && !fields[fieldId]) {\n throw new WebinyError(`There is no CMS Model Field field \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const field = fields[fieldId];\n if (!field) {\n throw new WebinyError(`There is no field \"${fieldId}\".`);\n }\n const filterPlugin = getFilterPlugin(field.type);\n\n filterPlugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n };\n\n return execFiltering;\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAcO,MAAMA,mBAAmB,GAAIC,MAAD,IAA2D;EAC1F,MAAM;IAAEC,MAAF;IAAUC,OAAV;IAAmBC;EAAnB,IAA6BH,MAAnC;EAEA;AACJ;AACA;;EACI,MAAMI,aAAa,GAAG,IAAAC,8BAAA,EAAuB;IACzCH;EADyC,CAAvB,CAAtB;EAGA;AACJ;AACA;;EACI,MAAMI,eAAe,GAAG,IAAAC,kCAAA,EAAyB;IAC7C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;QACA;AAChB;AACA;AACA;;QACgB,IAAAC,gEAAA,EAAgC;UAC5BlB;QAD4B,CAAhC;QAGA;MACH;;MACD,MAAM;QAAEmB,KAAK,EAAEC,YAAT;QAAuBC;MAAvB,IAAoC,IAAAC,+BAAA,EAAclB,GAAd,CAA1C;MAEA,IAAImB,OAAe,GAAGH,YAAtB;MAEA;AACZ;AACA;AACA;AACA;AACA;;MACY,MAAMI,aAAa,GAAG7C,KAAK,CAACF,MAAN,CAAagD,IAAb,CAAkBC,CAAC,IAAIA,CAAC,CAACH,OAAF,KAAcA,OAArC,CAAtB;;MACA,IAAI,CAACC,aAAD,IAAkB,CAAC/C,MAAM,CAAC8C,OAAD,CAA7B,EAAwC;QACpC,MAAM,IAAI3B,cAAJ,CAAiB,sCAAqC2B,OAAQ,IAA9D,CAAN;MACH,CAFD,MAEO,IAAIC,aAAJ,EAAmB;QACtBD,OAAO,GAAGC,aAAa,CAACD,OAAxB;MACH;;MAED,MAAMJ,KAAK,GAAG1C,MAAM,CAAC8C,OAAD,CAApB;;MACA,IAAI,CAACJ,KAAL,EAAY;QACR,MAAM,IAAIvB,cAAJ,CAAiB,sBAAqB2B,OAAQ,IAA9C,CAAN;MACH;;MACD,MAAMI,YAAY,GAAGhC,eAAe,CAACwB,KAAK,CAAC7B,IAAP,CAApC;MAEAqC,YAAY,CAACC,IAAb,CAAkB;QACd3C,cADc;QAEdU,eAFc;QAGdS,GAHc;QAIdC,KAJc;QAKdgB,QALc;QAMdF,KANc;QAOd1C,MAPc;QAQduB;MARc,CAAlB;IAUH;EACJ,CAtHD;;EAwHA,OAAOH,aAAP;AACH,CArKM"}
@@ -64,7 +64,7 @@ const getESPublishedEntryData = async (plugins, entry) => {
64
64
  }));
65
65
  };
66
66
 
67
- const convertToStorageEntry = params => {
67
+ const convertEntryKeysToStorage = params => {
68
68
  const {
69
69
  model,
70
70
  entry
@@ -78,7 +78,7 @@ const convertToStorageEntry = params => {
78
78
  });
79
79
  };
80
80
 
81
- const convertFromStorageEntry = params => {
81
+ const convertEntryKeysFromStorage = params => {
82
82
  const {
83
83
  model,
84
84
  entry
@@ -110,11 +110,11 @@ const createEntriesStorageOperations = params => {
110
110
  } = params;
111
111
  const isPublished = initialEntry.status === "published";
112
112
  const locked = isPublished ? true : initialEntry.locked;
113
- const entry = convertToStorageEntry({
113
+ const entry = convertEntryKeysToStorage({
114
114
  model,
115
115
  entry: initialEntry
116
116
  });
117
- const storageEntry = convertToStorageEntry({
117
+ const storageEntry = convertEntryKeysToStorage({
118
118
  model,
119
119
  entry: initialStorageEntry
120
120
  });
@@ -228,11 +228,11 @@ const createEntriesStorageOperations = params => {
228
228
  entry: initialEntry,
229
229
  storageEntry: initialStorageEntry
230
230
  } = params;
231
- const entry = convertToStorageEntry({
231
+ const entry = convertEntryKeysToStorage({
232
232
  model,
233
233
  entry: initialEntry
234
234
  });
235
- const storageEntry = convertToStorageEntry({
235
+ const storageEntry = convertEntryKeysToStorage({
236
236
  model,
237
237
  entry: initialStorageEntry
238
238
  });
@@ -315,11 +315,11 @@ const createEntriesStorageOperations = params => {
315
315
  entry: initialEntry,
316
316
  storageEntry: initialStorageEntry
317
317
  } = params;
318
- const entry = convertToStorageEntry({
318
+ const entry = convertEntryKeysToStorage({
319
319
  model,
320
320
  entry: initialEntry
321
321
  });
322
- const storageEntry = convertToStorageEntry({
322
+ const storageEntry = convertEntryKeysToStorage({
323
323
  model,
324
324
  entry: initialStorageEntry
325
325
  });
@@ -736,7 +736,7 @@ const createEntriesStorageOperations = params => {
736
736
  model,
737
737
  entries: hits.map(item => item._source)
738
738
  }).map(item => {
739
- return convertFromStorageEntry({
739
+ return convertEntryKeysFromStorage({
740
740
  model,
741
741
  entry: item
742
742
  });
@@ -778,11 +778,11 @@ const createEntriesStorageOperations = params => {
778
778
  entry: initialEntry,
779
779
  storageEntry: initialStorageEntry
780
780
  } = params;
781
- const entry = convertToStorageEntry({
781
+ const entry = convertEntryKeysToStorage({
782
782
  model,
783
783
  entry: initialEntry
784
784
  });
785
- const storageEntry = convertToStorageEntry({
785
+ const storageEntry = convertEntryKeysToStorage({
786
786
  model,
787
787
  entry: initialStorageEntry
788
788
  });
@@ -975,11 +975,11 @@ const createEntriesStorageOperations = params => {
975
975
  entry: initialEntry,
976
976
  storageEntry: initialStorageEntry
977
977
  } = params;
978
- const entry = convertToStorageEntry({
978
+ const entry = convertEntryKeysToStorage({
979
979
  model,
980
980
  entry: initialEntry
981
981
  });
982
- const storageEntry = convertToStorageEntry({
982
+ const storageEntry = convertEntryKeysToStorage({
983
983
  model,
984
984
  entry: initialStorageEntry
985
985
  });
@@ -1082,7 +1082,7 @@ const createEntriesStorageOperations = params => {
1082
1082
  return null;
1083
1083
  }
1084
1084
 
1085
- return convertFromStorageEntry({
1085
+ return convertEntryKeysFromStorage({
1086
1086
  model,
1087
1087
  entry
1088
1088
  });
@@ -1098,7 +1098,7 @@ const createEntriesStorageOperations = params => {
1098
1098
  return null;
1099
1099
  }
1100
1100
 
1101
- return convertFromStorageEntry({
1101
+ return convertEntryKeysFromStorage({
1102
1102
  model,
1103
1103
  entry
1104
1104
  });
@@ -1114,7 +1114,7 @@ const createEntriesStorageOperations = params => {
1114
1114
  return null;
1115
1115
  }
1116
1116
 
1117
- return convertFromStorageEntry({
1117
+ return convertEntryKeysFromStorage({
1118
1118
  model,
1119
1119
  entry
1120
1120
  });
@@ -1126,7 +1126,7 @@ const createEntriesStorageOperations = params => {
1126
1126
  ids: [params.id]
1127
1127
  });
1128
1128
  return entries.map(entry => {
1129
- return convertFromStorageEntry({
1129
+ return convertEntryKeysFromStorage({
1130
1130
  model,
1131
1131
  entry
1132
1132
  });
@@ -1139,7 +1139,7 @@ const createEntriesStorageOperations = params => {
1139
1139
  ids: params.ids
1140
1140
  });
1141
1141
  return entries.map(entry => {
1142
- return convertFromStorageEntry({
1142
+ return convertEntryKeysFromStorage({
1143
1143
  model,
1144
1144
  entry
1145
1145
  });
@@ -1152,7 +1152,7 @@ const createEntriesStorageOperations = params => {
1152
1152
  ids: params.ids
1153
1153
  });
1154
1154
  return entries.map(entry => {
1155
- return convertFromStorageEntry({
1155
+ return convertEntryKeysFromStorage({
1156
1156
  model,
1157
1157
  entry
1158
1158
  });
@@ -1165,7 +1165,7 @@ const createEntriesStorageOperations = params => {
1165
1165
  ids: params.ids
1166
1166
  });
1167
1167
  return entries.map(entry => {
1168
- return convertFromStorageEntry({
1168
+ return convertEntryKeysFromStorage({
1169
1169
  model,
1170
1170
  entry
1171
1171
  });
@@ -1213,7 +1213,7 @@ const createEntriesStorageOperations = params => {
1213
1213
  return null;
1214
1214
  }
1215
1215
 
1216
- return convertFromStorageEntry({
1216
+ return convertEntryKeysFromStorage({
1217
1217
  entry,
1218
1218
  model
1219
1219
  });