@webiny/api-headless-cms-ddb-es 5.41.4 → 5.42.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configurations.js.map +1 -1
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/elasticsearch/search/refSearch.js.map +1 -1
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/fields.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +1 -1
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.js.map +1 -1
- package/operations/entry/transformations/index.js.map +1 -1
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js.map +1 -1
- package/operations/system/index.js.map +1 -1
- package/package.json +26 -31
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
package/configurations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_apiElasticsearch","_plugins","configurations","exports","es","model","tenant","locale","WebinyError","sharedIndex","isSharedElasticsearchIndex","index","modelId","join","toLowerCase","prefix","getElasticsearchIndexPrefix","indexSettings","context","plugin","getLastAddedIndexPlugin","container","plugins","type","CmsEntryElasticsearchIndexPlugin","body"],"sources":["configurations.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsContext } from \"~/types\";\nimport {\n getElasticsearchIndexPrefix,\n getLastAddedIndexPlugin,\n isSharedElasticsearchIndex\n} from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchIndexRequestBody } from \"@webiny/api-elasticsearch/types\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins\";\n\ninterface ConfigurationsElasticsearch {\n index: string;\n}\n\nexport interface CmsElasticsearchParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n}\n\nexport interface ConfigurationsIndexSettingsParams {\n context: CmsContext;\n model: Pick<CmsModel, \"locale\">;\n}\n\nexport interface Configurations {\n es: (params: CmsElasticsearchParams) => ConfigurationsElasticsearch;\n indexSettings: (\n params: ConfigurationsIndexSettingsParams\n ) => Partial<ElasticsearchIndexRequestBody>;\n}\n\nexport const configurations: Configurations = {\n es({ model }) {\n const { tenant, locale } = model;\n\n if (!tenant) {\n throw new WebinyError(\n `Missing \"tenant\" parameter when trying to create Elasticsearch index name.`,\n \"TENANT_ERROR\"\n );\n } else if (!locale) {\n throw new WebinyError(\n `Missing \"locale\" parameter when trying to create Elasticsearch index name.`,\n \"LOCALE_ERROR\"\n );\n }\n\n const sharedIndex = isSharedElasticsearchIndex();\n const index = [sharedIndex ? \"root\" : tenant, \"headless-cms\", locale, model.modelId]\n .join(\"-\")\n .toLowerCase();\n\n const prefix = getElasticsearchIndexPrefix();\n\n if (!prefix) {\n return {\n index\n };\n }\n return {\n index: prefix + index\n };\n },\n indexSettings: ({ context, model }) => {\n const plugin = getLastAddedIndexPlugin<CmsEntryElasticsearchIndexPlugin>({\n container: context.plugins,\n type: CmsEntryElasticsearchIndexPlugin.type,\n locale: model.locale\n });\n\n return plugin ? plugin.body : {};\n }\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AAsBO,MAAMG,cAA8B,GAAAC,OAAA,CAAAD,cAAA,GAAG;EAC1CE,EAAEA,CAAC;IAAEC;EAAM,CAAC,EAAE;IACV,MAAM;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGF,KAAK;IAEhC,IAAI,CAACC,MAAM,EAAE;MACT,MAAM,IAAIE,cAAW,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_apiElasticsearch","_plugins","configurations","exports","es","model","tenant","locale","WebinyError","sharedIndex","isSharedElasticsearchIndex","index","modelId","join","toLowerCase","prefix","getElasticsearchIndexPrefix","indexSettings","context","plugin","getLastAddedIndexPlugin","container","plugins","type","CmsEntryElasticsearchIndexPlugin","body"],"sources":["configurations.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsContext } from \"~/types\";\nimport {\n getElasticsearchIndexPrefix,\n getLastAddedIndexPlugin,\n isSharedElasticsearchIndex\n} from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchIndexRequestBody } from \"@webiny/api-elasticsearch/types\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins\";\n\ninterface ConfigurationsElasticsearch {\n index: string;\n}\n\nexport interface CmsElasticsearchParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n}\n\nexport interface ConfigurationsIndexSettingsParams {\n context: CmsContext;\n model: Pick<CmsModel, \"locale\">;\n}\n\nexport interface Configurations {\n es: (params: CmsElasticsearchParams) => ConfigurationsElasticsearch;\n indexSettings: (\n params: ConfigurationsIndexSettingsParams\n ) => Partial<ElasticsearchIndexRequestBody>;\n}\n\nexport const configurations: Configurations = {\n es({ model }) {\n const { tenant, locale } = model;\n\n if (!tenant) {\n throw new WebinyError(\n `Missing \"tenant\" parameter when trying to create Elasticsearch index name.`,\n \"TENANT_ERROR\"\n );\n } else if (!locale) {\n throw new WebinyError(\n `Missing \"locale\" parameter when trying to create Elasticsearch index name.`,\n \"LOCALE_ERROR\"\n );\n }\n\n const sharedIndex = isSharedElasticsearchIndex();\n const index = [sharedIndex ? \"root\" : tenant, \"headless-cms\", locale, model.modelId]\n .join(\"-\")\n .toLowerCase();\n\n const prefix = getElasticsearchIndexPrefix();\n\n if (!prefix) {\n return {\n index\n };\n }\n return {\n index: prefix + index\n };\n },\n indexSettings: ({ context, model }) => {\n const plugin = getLastAddedIndexPlugin<CmsEntryElasticsearchIndexPlugin>({\n container: context.plugins,\n type: CmsEntryElasticsearchIndexPlugin.type,\n locale: model.locale\n });\n\n return plugin ? plugin.body : {};\n }\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AAsBO,MAAMG,cAA8B,GAAAC,OAAA,CAAAD,cAAA,GAAG;EAC1CE,EAAEA,CAAC;IAAEC;EAAM,CAAC,EAAE;IACV,MAAM;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGF,KAAK;IAEhC,IAAI,CAACC,MAAM,EAAE;MACT,MAAM,IAAIE,cAAW,CACjB,4EAA4E,EAC5E,cACJ,CAAC;IACL,CAAC,MAAM,IAAI,CAACD,MAAM,EAAE;MAChB,MAAM,IAAIC,cAAW,CACjB,4EAA4E,EAC5E,cACJ,CAAC;IACL;IAEA,MAAMC,WAAW,GAAG,IAAAC,4CAA0B,EAAC,CAAC;IAChD,MAAMC,KAAK,GAAG,CAACF,WAAW,GAAG,MAAM,GAAGH,MAAM,EAAE,cAAc,EAAEC,MAAM,EAAEF,KAAK,CAACO,OAAO,CAAC,CAC/EC,IAAI,CAAC,GAAG,CAAC,CACTC,WAAW,CAAC,CAAC;IAElB,MAAMC,MAAM,GAAG,IAAAC,6CAA2B,EAAC,CAAC;IAE5C,IAAI,CAACD,MAAM,EAAE;MACT,OAAO;QACHJ;MACJ,CAAC;IACL;IACA,OAAO;MACHA,KAAK,EAAEI,MAAM,GAAGJ;IACpB,CAAC;EACL,CAAC;EACDM,aAAa,EAAEA,CAAC;IAAEC,OAAO;IAAEb;EAAM,CAAC,KAAK;IACnC,MAAMc,MAAM,GAAG,IAAAC,yCAAuB,EAAmC;MACrEC,SAAS,EAAEH,OAAO,CAACI,OAAO;MAC1BC,IAAI,EAAEC,yCAAgC,CAACD,IAAI;MAC3ChB,MAAM,EAAEF,KAAK,CAACE;IAClB,CAAC,CAAC;IAEF,OAAOY,MAAM,GAAGA,MAAM,CAACM,IAAI,GAAG,CAAC,CAAC;EACpC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_gzip","_apiHeadlessCms","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","plugin","StorageTransformPlugin","name","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","exports"],"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 const plugin = new StorageTransformPlugin<string | string[], StorageValue>({\n name: \"headless-cms.storage-transform.long-text.default\",\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 unknown as StorageValue;\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 });\n plugin.name = plugin.name = `headless-cms.dynamodb.storageTransform.long-text`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAIA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AANA;AACA;AACA;;AAMA,MAAMG,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,qBAAqB,GAAG,MAAM;AAEpC,MAAMC,eAAe,GAAIC,KAAsB,IAAa;EACxD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOC,MAAM,CAACC,IAAI,CAACF,KAAK,EAAEH,mBAAmB,CAAC;EAClD;EACA,OAAOG,KAAK;AAChB,CAAC;AAQM,MAAMG,oCAAoC,GAAGA,CAAA,KAAM;EACtD,MAAMC,MAAM,GAAG,IAAIC,sCAAsB,CAAkC;IACvEC,IAAI,EAAE,kDAAkD;IACxDC,SAAS,EAAE,WAAW;IACtBC,WAAW,EAAE,MAAAA,CAAO;MAAEC,KAAK;MAAET,KAAK,EAAEU;IAAa,CAAC,KAAK;MACnD,MAAMC,MAAM,GAAG,OAAOD,YAAY;MAClC,IACI,CAACA,YAAY,IACbC,MAAM,KAAK,QAAQ,IACnBA,MAAM,KAAK,QAAQ,IACnBC,KAAK,CAACC,OAAO,CAACH,YAAY,CAAC,KAAK,IAAI,EACtC;QACE,OAAOA,YAAY;MACvB,CAAC,MAAM,IAAIC,MAAM,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAIG,cAAW,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_gzip","_apiHeadlessCms","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","plugin","StorageTransformPlugin","name","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","exports"],"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 const plugin = new StorageTransformPlugin<string | string[], StorageValue>({\n name: \"headless-cms.storage-transform.long-text.default\",\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 unknown as StorageValue;\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 });\n plugin.name = plugin.name = `headless-cms.dynamodb.storageTransform.long-text`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAIA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AANA;AACA;AACA;;AAMA,MAAMG,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,qBAAqB,GAAG,MAAM;AAEpC,MAAMC,eAAe,GAAIC,KAAsB,IAAa;EACxD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOC,MAAM,CAACC,IAAI,CAACF,KAAK,EAAEH,mBAAmB,CAAC;EAClD;EACA,OAAOG,KAAK;AAChB,CAAC;AAQM,MAAMG,oCAAoC,GAAGA,CAAA,KAAM;EACtD,MAAMC,MAAM,GAAG,IAAIC,sCAAsB,CAAkC;IACvEC,IAAI,EAAE,kDAAkD;IACxDC,SAAS,EAAE,WAAW;IACtBC,WAAW,EAAE,MAAAA,CAAO;MAAEC,KAAK;MAAET,KAAK,EAAEU;IAAa,CAAC,KAAK;MACnD,MAAMC,MAAM,GAAG,OAAOD,YAAY;MAClC,IACI,CAACA,YAAY,IACbC,MAAM,KAAK,QAAQ,IAC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Y,IAAIA,YAAY,IAAIA,YAAY,CAACC,cAAc,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE;QACrE,OAAOD,YAAY;MACvB;MACA,MAAMjB,OAAO,GAAGD,KAAK,CAACC,OAAO,CAACiB,YAAY,CAAC;MAC3C,MAAM9B,KAAK,GAAGa,OAAO,GAAGK,IAAI,CAACC,SAAS,CAACW,YAAY,CAAC,GAAGA,YAAY;MACnE,MAAME,eAAe,GAAG,MAAM,IAAAC,cAAI,EAACjC,KAAK,CAAC;MAEzC,MAAMsB,MAAoB,GAAG;QACzBL,WAAW,EAAErB,IAAI;QACjBI,KAAK,EAAEgC,eAAe,CAACT,QAAQ,CAAC1B,mBAAmB;MACvD,CAAC;MACD,IAAI,CAACgB,OAAO,EAAE;QACV,OAAOS,MAAM;MACjB;MACAA,MAAM,CAACT,OAAO,GAAGA,OAAO;MACxB,OAAOS,MAAM;IACjB;EACJ,CAAC,CAAC;EACFlB,MAAM,CAACE,IAAI,GAAGF,MAAM,CAACE,IAAI,GAAG,kDAAkD;EAE9E,OAAOF,MAAM;AACjB,CAAC;AAAC8B,OAAA,CAAA/B,oCAAA,GAAAA,oCAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_jsonpack","_interopRequireDefault","require","_error","_apiHeadlessCms","transformArray","value","isArray","Array","shouldBeArray","from","k","createRichTextStorageTransformPlugin","plugin","StorageTransformPlugin","name","fieldType","fromStorage","field","storageValue","WebinyError","storageId","compression","jsonpack","unpack","ex","toStorage","jsonValue","pack","process","env","DEBUG","console","log","message","exports"],"sources":["richText.ts"],"sourcesContent":["import jsonpack from \"jsonpack\";\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nexport type OriginalValue = Record<string, any> | any[];\n\nexport interface StorageValue {\n compression: string;\n value: any;\n}\n\n/**\n * Remove when jsonpack gets PR with a fix merged\n * https://github.com/rgcl/jsonpack/pull/25/files\n * NOTE 2021-07-28: it seems PR is not going to be merged so keep this.\n */\n// TODO @ts-refactor figure better type\nconst transformArray = (value: any) => {\n if (!value) {\n return value;\n }\n let isArray = Array.isArray(value);\n const shouldBeArray = value instanceof Array === false && isArray;\n if (shouldBeArray) {\n value = Array.from(value);\n isArray = true;\n }\n if (typeof value === \"object\" || isArray) {\n for (const k in value) {\n value[k] = transformArray(value[k]);\n }\n }\n return value;\n};\n\nexport const createRichTextStorageTransformPlugin = () => {\n const plugin = new StorageTransformPlugin({\n name: \"headless-cms.storage-transform.rich-text.default\",\n fieldType: \"rich-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n if (!storageValue) {\n return storageValue;\n } else if (typeof storageValue !== \"object\") {\n throw new WebinyError(\n `RichText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\".`\n );\n }\n /**\n * This is to circumvent a bug introduced with 5.8.0 storage operations.\n * Do not remove.\n */\n if (!storageValue[\"compression\"]) {\n return storageValue;\n }\n const { compression, value } = storageValue;\n if (compression !== \"jsonpack\") {\n throw new WebinyError(\n `This plugin cannot transform something not packed with \"jsonpack\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n /**\n * No point in going further if no value.\n */\n if (!value) {\n return null;\n }\n try {\n return jsonpack.unpack(value);\n } catch (ex) {\n return null;\n }\n },\n toStorage: async ({ value }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n * Introduced a bug with 5.8.0 storage operations, so just return the value to correct it.\n */\n if (!!value?.compression) {\n return value;\n }\n value = transformArray(value);\n\n let jsonValue: string | null = null;\n try {\n jsonValue = jsonpack.pack(value);\n } catch (ex) {\n if (process.env.DEBUG !== \"true\") {\n return null;\n }\n console.log(\"Error while compressing rich-text.\");\n console.log(ex.message);\n }\n return {\n compression: \"jsonpack\",\n value: jsonValue\n };\n }\n });\n plugin.name = `headless-cms.dynamodb.storageTransform.rich-text`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AASA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,cAAc,GAAIC,KAAU,IAAK;EACnC,IAAI,CAACA,KAAK,EAAE;IACR,OAAOA,KAAK;EAChB;EACA,IAAIC,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACD,KAAK,CAAC;EAClC,MAAMG,aAAa,GAAGH,KAAK,YAAYE,KAAK,KAAK,KAAK,IAAID,OAAO;EACjE,IAAIE,aAAa,EAAE;IACfH,KAAK,GAAGE,KAAK,CAACE,IAAI,CAACJ,KAAK,CAAC;IACzBC,OAAO,GAAG,IAAI;EAClB;EACA,IAAI,OAAOD,KAAK,KAAK,QAAQ,IAAIC,OAAO,EAAE;IACtC,KAAK,MAAMI,CAAC,IAAIL,KAAK,EAAE;MACnBA,KAAK,CAACK,CAAC,CAAC,GAAGN,cAAc,CAACC,KAAK,CAACK,CAAC,CAAC,CAAC;IACvC;EACJ;EACA,OAAOL,KAAK;AAChB,CAAC;AAEM,MAAMM,oCAAoC,GAAGA,CAAA,KAAM;EACtD,MAAMC,MAAM,GAAG,IAAIC,sCAAsB,CAAC;IACtCC,IAAI,EAAE,kDAAkD;IACxDC,SAAS,EAAE,WAAW;IACtBC,WAAW,EAAE,MAAAA,CAAO;MAAEC,KAAK;MAAEZ,KAAK,EAAEa;IAAa,CAAC,KAAK;MACnD,IAAI,CAACA,YAAY,EAAE;QACf,OAAOA,YAAY;MACvB,CAAC,MAAM,IAAI,OAAOA,YAAY,KAAK,QAAQ,EAAE;QACzC,MAAM,IAAIC,cAAW,
|
|
1
|
+
{"version":3,"names":["_jsonpack","_interopRequireDefault","require","_error","_apiHeadlessCms","transformArray","value","isArray","Array","shouldBeArray","from","k","createRichTextStorageTransformPlugin","plugin","StorageTransformPlugin","name","fieldType","fromStorage","field","storageValue","WebinyError","storageId","compression","jsonpack","unpack","ex","toStorage","jsonValue","pack","process","env","DEBUG","console","log","message","exports"],"sources":["richText.ts"],"sourcesContent":["import jsonpack from \"jsonpack\";\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nexport type OriginalValue = Record<string, any> | any[];\n\nexport interface StorageValue {\n compression: string;\n value: any;\n}\n\n/**\n * Remove when jsonpack gets PR with a fix merged\n * https://github.com/rgcl/jsonpack/pull/25/files\n * NOTE 2021-07-28: it seems PR is not going to be merged so keep this.\n */\n// TODO @ts-refactor figure better type\nconst transformArray = (value: any) => {\n if (!value) {\n return value;\n }\n let isArray = Array.isArray(value);\n const shouldBeArray = value instanceof Array === false && isArray;\n if (shouldBeArray) {\n value = Array.from(value);\n isArray = true;\n }\n if (typeof value === \"object\" || isArray) {\n for (const k in value) {\n value[k] = transformArray(value[k]);\n }\n }\n return value;\n};\n\nexport const createRichTextStorageTransformPlugin = () => {\n const plugin = new StorageTransformPlugin({\n name: \"headless-cms.storage-transform.rich-text.default\",\n fieldType: \"rich-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n if (!storageValue) {\n return storageValue;\n } else if (typeof storageValue !== \"object\") {\n throw new WebinyError(\n `RichText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\".`\n );\n }\n /**\n * This is to circumvent a bug introduced with 5.8.0 storage operations.\n * Do not remove.\n */\n if (!storageValue[\"compression\"]) {\n return storageValue;\n }\n const { compression, value } = storageValue;\n if (compression !== \"jsonpack\") {\n throw new WebinyError(\n `This plugin cannot transform something not packed with \"jsonpack\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n /**\n * No point in going further if no value.\n */\n if (!value) {\n return null;\n }\n try {\n return jsonpack.unpack(value);\n } catch (ex) {\n return null;\n }\n },\n toStorage: async ({ value }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n * Introduced a bug with 5.8.0 storage operations, so just return the value to correct it.\n */\n if (!!value?.compression) {\n return value;\n }\n value = transformArray(value);\n\n let jsonValue: string | null = null;\n try {\n jsonValue = jsonpack.pack(value);\n } catch (ex) {\n if (process.env.DEBUG !== \"true\") {\n return null;\n }\n console.log(\"Error while compressing rich-text.\");\n console.log(ex.message);\n }\n return {\n compression: \"jsonpack\",\n value: jsonValue\n };\n }\n });\n plugin.name = `headless-cms.dynamodb.storageTransform.rich-text`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AASA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,cAAc,GAAIC,KAAU,IAAK;EACnC,IAAI,CAACA,KAAK,EAAE;IACR,OAAOA,KAAK;EAChB;EACA,IAAIC,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACD,KAAK,CAAC;EAClC,MAAMG,aAAa,GAAGH,KAAK,YAAYE,KAAK,KAAK,KAAK,IAAID,OAAO;EACjE,IAAIE,aAAa,EAAE;IACfH,KAAK,GAAGE,KAAK,CAACE,IAAI,CAACJ,KAAK,CAAC;IACzBC,OAAO,GAAG,IAAI;EAClB;EACA,IAAI,OAAOD,KAAK,KAAK,QAAQ,IAAIC,OAAO,EAAE;IACtC,KAAK,MAAMI,CAAC,IAAIL,KAAK,EAAE;MACnBA,KAAK,CAACK,CAAC,CAAC,GAAGN,cAAc,CAACC,KAAK,CAACK,CAAC,CAAC,CAAC;IACvC;EACJ;EACA,OAAOL,KAAK;AAChB,CAAC;AAEM,MAAMM,oCAAoC,GAAGA,CAAA,KAAM;EACtD,MAAMC,MAAM,GAAG,IAAIC,sCAAsB,CAAC;IACtCC,IAAI,EAAE,kDAAkD;IACxDC,SAAS,EAAE,WAAW;IACtBC,WAAW,EAAE,MAAAA,CAAO;MAAEC,KAAK;MAAEZ,KAAK,EAAEa;IAAa,CAAC,KAAK;MACnD,IAAI,CAACA,YAAY,EAAE;QACf,OAAOA,YAAY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,CAAC,CAAC;EACFd,MAAM,CAACE,IAAI,GAAG,kDAAkD;EAEhE,OAAOF,MAAM;AACjB,CAAC;AAACsB,OAAA,CAAAvB,oCAAA,GAAAA,oCAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_CmsEntryElasticsearchIndexPlugin","require","_apiElasticsearch","_configurations","createElasticsearchIndex","params","client","plugins","model","index","configurations","es","createIndex","type","CmsEntryElasticsearchIndexPlugin","tenant","locale","onExists","console","log","name","onError","ex","error","exports"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\nimport { createIndex } from \"@webiny/api-elasticsearch\";\nimport { configurations } from \"~/configurations\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreateElasticsearchIndexParams {\n client: Client;\n plugins: PluginsContainer;\n model: CmsModel;\n}\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { client, plugins, model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n await createIndex({\n client,\n index,\n type: CmsEntryElasticsearchIndexPlugin.type,\n tenant: model.tenant,\n locale: model.locale,\n plugins,\n onExists: () => {\n console.log(\n `Elasticsearch index \"${index}\" for the CMS model \"${model.name}\" already exists.`\n );\n },\n onError: ex => {\n console.error(\n `Could not create Elasticsearch index \"${index}\" for the CMS model \"${model.name}\".`\n );\n console.error(ex);\n return ex;\n }\n });\n};\n"],"mappings":";;;;;;AAEA,IAAAA,iCAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AASO,MAAMG,wBAAwB,GAAG,MAAOC,MAAsC,IAAK;EACtF,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAEzC,MAAM;IAAEI;EAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;IAChCH;EACJ,CAAC,CAAC;EAEF,MAAM,IAAAI,6BAAW,EAAC;IACdN,MAAM;IACNG,KAAK;IACLI,IAAI,EAAEC,kEAAgC,CAACD,IAAI;IAC3CE,MAAM,EAAEP,KAAK,CAACO,MAAM;IACpBC,MAAM,EAAER,KAAK,CAACQ,MAAM;IACpBT,OAAO;IACPU,QAAQ,EAAEA,CAAA,KAAM;MACZC,OAAO,CAACC,GAAG,
|
|
1
|
+
{"version":3,"names":["_CmsEntryElasticsearchIndexPlugin","require","_apiElasticsearch","_configurations","createElasticsearchIndex","params","client","plugins","model","index","configurations","es","createIndex","type","CmsEntryElasticsearchIndexPlugin","tenant","locale","onExists","console","log","name","onError","ex","error","exports"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\nimport { createIndex } from \"@webiny/api-elasticsearch\";\nimport { configurations } from \"~/configurations\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreateElasticsearchIndexParams {\n client: Client;\n plugins: PluginsContainer;\n model: CmsModel;\n}\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { client, plugins, model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n await createIndex({\n client,\n index,\n type: CmsEntryElasticsearchIndexPlugin.type,\n tenant: model.tenant,\n locale: model.locale,\n plugins,\n onExists: () => {\n console.log(\n `Elasticsearch index \"${index}\" for the CMS model \"${model.name}\" already exists.`\n );\n },\n onError: ex => {\n console.error(\n `Could not create Elasticsearch index \"${index}\" for the CMS model \"${model.name}\".`\n );\n console.error(ex);\n return ex;\n }\n });\n};\n"],"mappings":";;;;;;AAEA,IAAAA,iCAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AASO,MAAMG,wBAAwB,GAAG,MAAOC,MAAsC,IAAK;EACtF,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAEzC,MAAM;IAAEI;EAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;IAChCH;EACJ,CAAC,CAAC;EAEF,MAAM,IAAAI,6BAAW,EAAC;IACdN,MAAM;IACNG,KAAK;IACLI,IAAI,EAAEC,kEAAgC,CAACD,IAAI;IAC3CE,MAAM,EAAEP,KAAK,CAACO,MAAM;IACpBC,MAAM,EAAER,KAAK,CAACQ,MAAM;IACpBT,OAAO;IACPU,QAAQ,EAAEA,CAAA,KAAM;MACZC,OAAO,CAACC,GAAG,CACP,wBAAwBV,KAAK,wBAAwBD,KAAK,CAACY,IAAI,mBACnE,CAAC;IACL,CAAC;IACDC,OAAO,EAAEC,EAAE,IAAI;MACXJ,OAAO,CAACK,KAAK,CACT,yCAAyCd,KAAK,wBAAwBD,KAAK,CAACY,IAAI,IACpF,CAAC;MACDF,OAAO,CAACK,KAAK,CAACD,EAAE,CAAC;MACjB,OAAOA,EAAE;IACb;EACJ,CAAC,CAAC;AACN,CAAC;AAACE,OAAA,CAAApB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configurations","require","deleteElasticsearchIndex","params","client","model","index","configurations","es","body","exists","indices","delete","ignore_unavailable","ex","console","log","message","exports"],"sources":["deleteElasticsearchIndex.ts"],"sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { configurations } from \"~/configurations\";\n\ninterface DeleteElasticsearchIndexParams {\n client: Client;\n model: CmsModel;\n}\n\nexport const deleteElasticsearchIndex = async (\n params: DeleteElasticsearchIndexParams\n): Promise<void> => {\n const { client, model } = params;\n\n const { index } = configurations.es({\n model\n });\n const { body: exists } = await client.indices.exists({\n index\n });\n if (!exists) {\n return;\n }\n\n try {\n await client.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n console.log(`Could not delete Elasticsearch index \"${index}\". Please do it manually.`);\n console.log(ex.message);\n }\n};\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AAOO,MAAMC,wBAAwB,GAAG,MACpCC,MAAsC,IACtB;EAChB,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEhC,MAAM;IAAEG;EAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;IAChCH;EACJ,CAAC,CAAC;EACF,MAAM;IAAEI,IAAI,EAAEC;EAAO,CAAC,GAAG,MAAMN,MAAM,CAACO,OAAO,CAACD,MAAM,CAAC;IACjDJ;EACJ,CAAC,CAAC;EACF,IAAI,CAACI,MAAM,EAAE;IACT;EACJ;EAEA,IAAI;IACA,MAAMN,MAAM,CAACO,OAAO,CAACC,MAAM,CAAC;MACxBN,KAAK;MACLO,kBAAkB,EAAE;IACxB,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,
|
|
1
|
+
{"version":3,"names":["_configurations","require","deleteElasticsearchIndex","params","client","model","index","configurations","es","body","exists","indices","delete","ignore_unavailable","ex","console","log","message","exports"],"sources":["deleteElasticsearchIndex.ts"],"sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { configurations } from \"~/configurations\";\n\ninterface DeleteElasticsearchIndexParams {\n client: Client;\n model: CmsModel;\n}\n\nexport const deleteElasticsearchIndex = async (\n params: DeleteElasticsearchIndexParams\n): Promise<void> => {\n const { client, model } = params;\n\n const { index } = configurations.es({\n model\n });\n const { body: exists } = await client.indices.exists({\n index\n });\n if (!exists) {\n return;\n }\n\n try {\n await client.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n console.log(`Could not delete Elasticsearch index \"${index}\". Please do it manually.`);\n console.log(ex.message);\n }\n};\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AAOO,MAAMC,wBAAwB,GAAG,MACpCC,MAAsC,IACtB;EAChB,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEhC,MAAM;IAAEG;EAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;IAChCH;EACJ,CAAC,CAAC;EACF,MAAM;IAAEI,IAAI,EAAEC;EAAO,CAAC,GAAG,MAAMN,MAAM,CAACO,OAAO,CAACD,MAAM,CAAC;IACjDJ;EACJ,CAAC,CAAC;EACF,IAAI,CAACI,MAAM,EAAE;IACT;EACJ;EAEA,IAAI;IACA,MAAMN,MAAM,CAACO,OAAO,CAACC,MAAM,CAAC;MACxBN,KAAK;MACLO,kBAAkB,EAAE;IACxB,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAC,yCAAyCV,KAAK,2BAA2B,CAAC;IACtFS,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;EAC3B;AACJ,CAAC;AAACC,OAAA,CAAAhB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_CmsEntryElasticsearchQueryBuilderValueSearchPlugin","require","createPath","field","key","match","storageId","transform","value","createRefSearchPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","fieldType","path","exports"],"sources":["refSearch.ts"],"sourcesContent":["import {\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CreatePathCallable,\n TransformCallable\n} from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\nconst createPath: CreatePathCallable<string> = ({ field, key }) => {\n if (key && key.match(\"entryId\") === null) {\n return `${field.storageId}.id`;\n }\n return `${field.storageId}.entryId`;\n};\n\nconst transform: TransformCallable = ({ value }) => {\n return value;\n};\n\nexport const createRefSearchPlugin = (): CmsEntryElasticsearchQueryBuilderValueSearchPlugin => {\n return new CmsEntryElasticsearchQueryBuilderValueSearchPlugin({\n fieldType: \"ref\",\n path: createPath,\n transform\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,mDAAA,GAAAC,OAAA;AAMA,MAAMC,UAAsC,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAI,CAAC,KAAK;EAC/D,IAAIA,GAAG,IAAIA,GAAG,CAACC,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;IACtC,
|
|
1
|
+
{"version":3,"names":["_CmsEntryElasticsearchQueryBuilderValueSearchPlugin","require","createPath","field","key","match","storageId","transform","value","createRefSearchPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","fieldType","path","exports"],"sources":["refSearch.ts"],"sourcesContent":["import {\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CreatePathCallable,\n TransformCallable\n} from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\nconst createPath: CreatePathCallable<string> = ({ field, key }) => {\n if (key && key.match(\"entryId\") === null) {\n return `${field.storageId}.id`;\n }\n return `${field.storageId}.entryId`;\n};\n\nconst transform: TransformCallable = ({ value }) => {\n return value;\n};\n\nexport const createRefSearchPlugin = (): CmsEntryElasticsearchQueryBuilderValueSearchPlugin => {\n return new CmsEntryElasticsearchQueryBuilderValueSearchPlugin({\n fieldType: \"ref\",\n path: createPath,\n transform\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,mDAAA,GAAAC,OAAA;AAMA,MAAMC,UAAsC,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAI,CAAC,KAAK;EAC/D,IAAIA,GAAG,IAAIA,GAAG,CAACC,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;IACtC,OAAO,GAAGF,KAAK,CAACG,SAAS,KAAK;EAClC;EACA,OAAO,GAAGH,KAAK,CAACG,SAAS,UAAU;AACvC,CAAC;AAED,MAAMC,SAA4B,GAAGA,CAAC;EAAEC;AAAM,CAAC,KAAK;EAChD,OAAOA,KAAK;AAChB,CAAC;AAEM,MAAMC,qBAAqB,GAAGA,CAAA,KAA0D;EAC3F,OAAO,IAAIC,sGAAkD,CAAC;IAC1DC,SAAS,EAAE,KAAK;IAChBC,IAAI,EAAEV,UAAU;IAChBK;EACJ,CAAC,CAAC;AACN,CAAC;AAACM,OAAA,CAAAJ,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_fieldIdentifier","prepareEntryToIndex","params","plugins","storageEntry","entry","model","fieldIndexPlugins","defaultIndexFieldPlugin","fieldTypePlugins","setupEntriesIndexHelpers","getFieldIndexPlugin","fieldType","getFieldTypePlugin","pl","WebinyError","values","rawValues","field","fields","identifier","getFieldIdentifier","targetFieldPlugin","type","toIndex","value","rawValue","exports","pluginsContainer","byType","plugin","reverse","find","reduce","extractEntriesFromIndex","entries","list","indexValues","fieldTypePlugin","fromIndex","identifiers","getFieldIdentifiers","valueIdentifier","rawValueIdentifier","ex","message","code","newEntry","push"],"sources":["entryIndexHelpers.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport { CmsIndexEntry, CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { getFieldIdentifier, getFieldIdentifiers } from \"~/helpers/fieldIdentifier\";\n\ninterface SetupEntriesIndexHelpersParams {\n plugins: PluginsContainer;\n}\n\ninterface ExtractEntriesFromIndexParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry[];\n}\n\ninterface PrepareElasticsearchDataParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\nexport const prepareEntryToIndex = (params: PrepareElasticsearchDataParams): CmsIndexEntry => {\n const { plugins, storageEntry, entry, model } = params;\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n const pl = fieldTypePlugins[fieldType];\n if (pl) {\n return pl;\n }\n throw new WebinyError(`Missing field type plugin \"${fieldType}\". Prepare entry for index.`);\n }\n\n // These objects will contain values processed by field index plugins\n const values: Record<string, string> = {};\n const rawValues: Record<string, string> = {};\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n const identifier = getFieldIdentifier(storageEntry.values, field);\n if (!identifier) {\n continue;\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n\n // TODO: remove this `if` once we convert this plugin to proper plugin class\n if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {\n continue;\n }\n\n const { value, rawValue } = targetFieldPlugin.toIndex({\n plugins,\n model,\n field,\n rawValue: entry.values[identifier],\n value: storageEntry.values[identifier],\n getFieldIndexPlugin,\n getFieldTypePlugin\n });\n\n if (typeof value !== \"undefined\") {\n values[identifier] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[identifier] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n } as CmsIndexEntry;\n};\n\nconst setupEntriesIndexHelpers = ({\n plugins: pluginsContainer\n}: SetupEntriesIndexHelpersParams) => {\n const plugins = pluginsContainer.byType<CmsModelFieldToElasticsearchPlugin>(\n \"cms-model-field-to-elastic-search\"\n );\n\n const fieldIndexPlugins: Record<string, CmsModelFieldToElasticsearchPlugin> = {};\n for (const plugin of plugins.reverse()) {\n if (fieldIndexPlugins[plugin.fieldType]) {\n continue;\n }\n fieldIndexPlugins[plugin.fieldType] = plugin;\n }\n // we will use this plugin if no targeted plugin found\n const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === \"*\");\n\n // CmsModelFieldToGraphQLPlugin plugins\n const fieldTypePlugins: Record<string, CmsModelFieldToGraphQLPlugin> = pluginsContainer\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((plugins, plugin) => ({ ...plugins, [plugin.fieldType]: plugin }), {});\n\n return {\n fieldIndexPlugins,\n defaultIndexFieldPlugin,\n fieldTypePlugins\n };\n};\n\nexport const extractEntriesFromIndex = ({\n plugins,\n entries,\n model\n}: ExtractEntriesFromIndexParams): CmsEntry[] => {\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n return fieldTypePlugins[fieldType];\n }\n\n const list: CmsEntry[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: Record<string, string> = {};\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldTypePlugin = fieldTypePlugins[field.type];\n if (!fieldTypePlugin) {\n throw new WebinyError(\n `Missing field type plugin \"${field.type}\". Extract entries from index.`\n );\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {\n continue;\n }\n /**\n * We can safely cast as the code will not continue in case of no identifiers.\n */\n const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);\n if (!identifiers) {\n continue;\n }\n\n try {\n indexValues[identifiers.valueIdentifier] = targetFieldPlugin.fromIndex({\n plugins,\n model,\n field,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n value: entry.values[\n identifiers.valueIdentifier || identifiers.rawValueIdentifier\n ],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues\n ? entry.rawValues[\n identifiers.rawValueIdentifier || identifiers.valueIdentifier\n ]\n : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-expect-error\n delete newEntry[\"rawValues\"];\n // @ts-expect-error\n delete newEntry[\"TYPE\"];\n // @ts-expect-error\n delete newEntry[\"__type\"];\n // @ts-expect-error\n delete newEntry[\"latest\"];\n // @ts-expect-error\n delete newEntry[\"published\"];\n list.push({ ...newEntry });\n }\n\n return list;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,gBAAA,GAAAD,OAAA;AAiBO,MAAME,mBAAmB,GAAIC,MAAsC,IAAoB;EAC1F,MAAM;IAAEC,OAAO;IAAEC,YAAY;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGJ,MAAM;EACtD,MAAM;IAAEK,iBAAiB;IAAEC,uBAAuB;IAAEC;EAAiB,CAAC,GAClEC,wBAAwB,CAAC;IAAEP;EAAQ,CAAC,CAAC;EAEzC,SAASQ,mBAAmBA,CAACC,SAAiB,EAAE;IAC5C,OAAOL,iBAAiB,CAACK,SAAS,CAAC,IAAIJ,uBAAuB;EAClE;EAEA,SAASK,kBAAkBA,CAACD,SAAiB,EAAE;IAC3C,MAAME,EAAE,GAAGL,gBAAgB,CAACG,SAAS,CAAC;IACtC,IAAIE,EAAE,EAAE;MACJ,OAAOA,EAAE;IACb;IACA,MAAM,IAAIC,cAAW,CAAE,8BAA6BH,SAAU,6BAA4B,CAAC;EAC/F;;EAEA;EACA,MAAMI,MAA8B,GAAG,CAAC,CAAC;EACzC,MAAMC,SAAiC,GAAG,CAAC,CAAC;;EAE5C;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AOA,QAAQ,CAAC,QAAQ,CAAC;IACzB;IACA,OAAOA,QAAQ,CAAC,WAAW,CAAC;IAC5BX,IAAI,CAACY,IAAI,CAAC;MAAE,GAAGD;IAAS,CAAC,CAAC;EAC9B;EAEA,OAAOX,IAAI;AACf,CAAC;AAACT,OAAA,CAAAO,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_fieldIdentifier","prepareEntryToIndex","params","plugins","storageEntry","entry","model","fieldIndexPlugins","defaultIndexFieldPlugin","fieldTypePlugins","setupEntriesIndexHelpers","getFieldIndexPlugin","fieldType","getFieldTypePlugin","pl","WebinyError","values","rawValues","field","fields","identifier","getFieldIdentifier","targetFieldPlugin","type","toIndex","value","rawValue","exports","pluginsContainer","byType","plugin","reverse","find","reduce","extractEntriesFromIndex","entries","list","indexValues","fieldTypePlugin","fromIndex","identifiers","getFieldIdentifiers","valueIdentifier","rawValueIdentifier","ex","message","code","newEntry","push"],"sources":["entryIndexHelpers.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport { CmsIndexEntry, CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { getFieldIdentifier, getFieldIdentifiers } from \"~/helpers/fieldIdentifier\";\n\ninterface SetupEntriesIndexHelpersParams {\n plugins: PluginsContainer;\n}\n\ninterface ExtractEntriesFromIndexParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry[];\n}\n\ninterface PrepareElasticsearchDataParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\nexport const prepareEntryToIndex = (params: PrepareElasticsearchDataParams): CmsIndexEntry => {\n const { plugins, storageEntry, entry, model } = params;\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n const pl = fieldTypePlugins[fieldType];\n if (pl) {\n return pl;\n }\n throw new WebinyError(`Missing field type plugin \"${fieldType}\". Prepare entry for index.`);\n }\n\n // These objects will contain values processed by field index plugins\n const values: Record<string, string> = {};\n const rawValues: Record<string, string> = {};\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n const identifier = getFieldIdentifier(storageEntry.values, field);\n if (!identifier) {\n continue;\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n\n // TODO: remove this `if` once we convert this plugin to proper plugin class\n if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {\n continue;\n }\n\n const { value, rawValue } = targetFieldPlugin.toIndex({\n plugins,\n model,\n field,\n rawValue: entry.values[identifier],\n value: storageEntry.values[identifier],\n getFieldIndexPlugin,\n getFieldTypePlugin\n });\n\n if (typeof value !== \"undefined\") {\n values[identifier] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[identifier] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n } as CmsIndexEntry;\n};\n\nconst setupEntriesIndexHelpers = ({\n plugins: pluginsContainer\n}: SetupEntriesIndexHelpersParams) => {\n const plugins = pluginsContainer.byType<CmsModelFieldToElasticsearchPlugin>(\n \"cms-model-field-to-elastic-search\"\n );\n\n const fieldIndexPlugins: Record<string, CmsModelFieldToElasticsearchPlugin> = {};\n for (const plugin of plugins.reverse()) {\n if (fieldIndexPlugins[plugin.fieldType]) {\n continue;\n }\n fieldIndexPlugins[plugin.fieldType] = plugin;\n }\n // we will use this plugin if no targeted plugin found\n const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === \"*\");\n\n // CmsModelFieldToGraphQLPlugin plugins\n const fieldTypePlugins: Record<string, CmsModelFieldToGraphQLPlugin> = pluginsContainer\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((plugins, plugin) => ({ ...plugins, [plugin.fieldType]: plugin }), {});\n\n return {\n fieldIndexPlugins,\n defaultIndexFieldPlugin,\n fieldTypePlugins\n };\n};\n\nexport const extractEntriesFromIndex = ({\n plugins,\n entries,\n model\n}: ExtractEntriesFromIndexParams): CmsEntry[] => {\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n return fieldTypePlugins[fieldType];\n }\n\n const list: CmsEntry[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: Record<string, string> = {};\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldTypePlugin = fieldTypePlugins[field.type];\n if (!fieldTypePlugin) {\n throw new WebinyError(\n `Missing field type plugin \"${field.type}\". Extract entries from index.`\n );\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {\n continue;\n }\n /**\n * We can safely cast as the code will not continue in case of no identifiers.\n */\n const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);\n if (!identifiers) {\n continue;\n }\n\n try {\n indexValues[identifiers.valueIdentifier] = targetFieldPlugin.fromIndex({\n plugins,\n model,\n field,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n value: entry.values[\n identifiers.valueIdentifier || identifiers.rawValueIdentifier\n ],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues\n ? entry.rawValues[\n identifiers.rawValueIdentifier || identifiers.valueIdentifier\n ]\n : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-expect-error\n delete newEntry[\"rawValues\"];\n // @ts-expect-error\n delete newEntry[\"TYPE\"];\n // @ts-expect-error\n delete newEntry[\"__type\"];\n // @ts-expect-error\n delete newEntry[\"latest\"];\n // @ts-expect-error\n delete newEntry[\"published\"];\n list.push({ ...newEntry });\n }\n\n return list;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,gBAAA,GAAAD,OAAA;AAiBO,MAAME,mBAAmB,GAAIC,MAAsC,IAAoB;EAC1F,MAAM;IAAEC,OAAO;IAAEC,YAAY;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGJ,MAAM;EACtD,MAAM;IAAEK,iBAAiB;IAAEC,uBAAuB;IAAEC;EAAiB,CAAC,GAClEC,wBAAwB,CAAC;IAAEP;EAAQ,CAAC,CAAC;EAEzC,SAASQ,mBAAmBA,CAACC,SAAiB,EAAE;IAC5C,OAAOL,iBAAiB,CAACK,SAAS,CAAC,IAAIJ,uBAAuB;EAClE;EAEA,SAASK,kBAAkBA,CAACD,SAAiB,EAAE;IAC3C,MAAME,EAAE,GAAGL,gBAAgB,CAACG,SAAS,CAAC;IACtC,IAAIE,EAAE,EAAE;MACJ,OAAOA,EAAE;IACb;IACA,MAAM,IAAIC,cAAW,CAAC,8BAA8BH,SAAS,6BAA6B,CAAC;EAC/F;;EAEA;EACA,MAAMI,MAA8B,GAAG,CAAC,CAAC;EACzC,MAAMC,SAAiC,GAAG,CAAC,CAAC;;EAE5C;EACA,KAAK,MAAMC,KAAK,IAAIZ,KAAK,CAACa,MAAM,EAAE;IAC9B,MAAMC,UAAU,GAAG,IAAAC,mCAAkB,EAACjB,YAAY,CAACY,MAAM,EAAEE,KAAK,CAAC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9B;EAEA,OAAOX,IAAI;AACf,CAAC;AAACT,OAAA,CAAAO,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DataLoaderCache","cache","getDataLoader","params","key","createKey","setDataLoader","dataLoader","clearAll","current","name","startsWith","tenant","locale","exports"],"sources":["DataLoaderCache.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n locale: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n locale: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = this.createKey({\n ...params,\n name: \"\"\n });\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.locale}_${params.name}`;\n }\n}\n"],"mappings":";;;;;;AAaO,MAAMA,eAAe,CAAC;EACRC,KAAK,GAAyC,CAAC,CAAC;EAE1DC,aAAaA,CAAmBC,MAAsB,EAA2B;IACpF,MAAMC,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAElC,OAAO,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,IAAI,IAAI;EAClC;EAEOE,aAAaA,CAACH,MAAsB,EAAEI,UAAgC,EAAQ;IACjF,MAAMH,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAClC,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,GAAGG,UAAU;EAChC;EAEOC,QAAQA,CAACL,MAAuB,EAAQ;IAC3C,IAAI,CAACA,MAAM,EAAE;MACT,KAAK,MAAMM,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;QAC9B,IAAI,CAACA,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;MAClC;MACA;IACJ;IACA,MAAMJ,GAAG,GAAG,IAAI,CAACC,SAAS,CAAC;MACvB,GAAGF,MAAM;MACTO,IAAI,EAAE;IACV,CAAC,CAAC;IACF,KAAK,MAAMD,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;MAC9B,IAAIQ,OAAO,CAACE,UAAU,CAACP,GAAG,CAAC,KAAK,KAAK,EAAE;QACnC;MACJ;MACA,IAAI,CAACH,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;IAClC;EACJ;EAEQH,SAASA,CAACF,MAAsB,EAAU;IAC9C,
|
|
1
|
+
{"version":3,"names":["DataLoaderCache","cache","getDataLoader","params","key","createKey","setDataLoader","dataLoader","clearAll","current","name","startsWith","tenant","locale","exports"],"sources":["DataLoaderCache.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n locale: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n locale: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = this.createKey({\n ...params,\n name: \"\"\n });\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.locale}_${params.name}`;\n }\n}\n"],"mappings":";;;;;;AAaO,MAAMA,eAAe,CAAC;EACRC,KAAK,GAAyC,CAAC,CAAC;EAE1DC,aAAaA,CAAmBC,MAAsB,EAA2B;IACpF,MAAMC,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAElC,OAAO,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,IAAI,IAAI;EAClC;EAEOE,aAAaA,CAACH,MAAsB,EAAEI,UAAgC,EAAQ;IACjF,MAAMH,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAClC,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,GAAGG,UAAU;EAChC;EAEOC,QAAQA,CAACL,MAAuB,EAAQ;IAC3C,IAAI,CAACA,MAAM,EAAE;MACT,KAAK,MAAMM,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;QAC9B,IAAI,CAACA,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;MAClC;MACA;IACJ;IACA,MAAMJ,GAAG,GAAG,IAAI,CAACC,SAAS,CAAC;MACvB,GAAGF,MAAM;MACTO,IAAI,EAAE;IACV,CAAC,CAAC;IACF,KAAK,MAAMD,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;MAC9B,IAAIQ,OAAO,CAACE,UAAU,CAACP,GAAG,CAAC,KAAK,KAAK,EAAE;QACnC;MACJ;MACA,IAAI,CAACH,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;IAClC;EACJ;EAEQH,SAASA,CAACF,MAAsB,EAAU;IAC9C,OAAO,GAAGA,MAAM,CAACS,MAAM,IAAIT,MAAM,CAACU,MAAM,IAAIV,MAAM,CAACO,IAAI,EAAE;EAC7D;AACJ;AAACI,OAAA,CAAAd,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dataloader","_interopRequireDefault","require","_dbDynamodb","_cleanup","_keys","_utils","_createBatchScheduleFn","createGetRevisionById","params","entity","tenant","locale","DataLoader","ids","queries","reduce","collection","id","partitionKey","createPartitionKey","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","items","Object","values","cleanupItems","map","filter","item","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getRevisionById.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb\";\nimport { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys\";\nimport { DataLoaderParams } from \"./types\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\n\nexport const createGetRevisionById = (params: DataLoaderParams) => {\n const { entity, tenant, locale } = params;\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const queries = ids.reduce<Record<string, ReturnType<typeof entity.getBatch>>>(\n (collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n },\n {}\n );\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AAEO,MAAMM,qBAAqB,GAAIC,MAAwB,IAAK;EAC/D,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEzC,OAAO,IAAII,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAAO,GAAGD,GAAG,CAACE,MAAM,CACtB,CAACC,UAAU,EAAEC,EAAE,KAAK;MAChB,MAAMC,YAAY,GAAG,IAAAC,wBAAkB,EAAC;QACpCT,MAAM;QACNC,MAAM;QACNM;MACJ,CAAC,CAAC;MACF,MAAM;QAAEG;MAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACJ,EAAE,CAAC;MACvC,IAAIG,OAAO,KAAK,IAAI,EAAE;QAClB,OAAOJ,UAAU;MACrB;MACA,MAAMM,OAAO,GAAG,IAAAC,2BAAqB,EAAC;QAClCH;MACJ,CAAC,CAAC;MACF,MAAMI,IAAI,
|
|
1
|
+
{"version":3,"names":["_dataloader","_interopRequireDefault","require","_dbDynamodb","_cleanup","_keys","_utils","_createBatchScheduleFn","createGetRevisionById","params","entity","tenant","locale","DataLoader","ids","queries","reduce","collection","id","partitionKey","createPartitionKey","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","items","Object","values","cleanupItems","map","filter","item","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getRevisionById.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb\";\nimport { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys\";\nimport { DataLoaderParams } from \"./types\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\n\nexport const createGetRevisionById = (params: DataLoaderParams) => {\n const { entity, tenant, locale } = params;\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const queries = ids.reduce<Record<string, ReturnType<typeof entity.getBatch>>>(\n (collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n },\n {}\n );\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AAEO,MAAMM,qBAAqB,GAAIC,MAAwB,IAAK;EAC/D,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEzC,OAAO,IAAII,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAAO,GAAGD,GAAG,CAACE,MAAM,CACtB,CAACC,UAAU,EAAEC,EAAE,KAAK;MAChB,MAAMC,YAAY,GAAG,IAAAC,wBAAkB,EAAC;QACpCT,MAAM;QACNC,MAAM;QACNM;MACJ,CAAC,CAAC;MACF,MAAM;QAAEG;MAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACJ,EAAE,CAAC;MACvC,IAAIG,OAAO,KAAK,IAAI,EAAE;QAClB,OAAOJ,UAAU;MACrB;MACA,MAAMM,OAAO,GAAG,IAAAC,2BAAqB,EAAC;QAClCH;MACJ,CAAC,CAAC;MACF,MAAMI,IAAI,GAAG,GAAGN,YAAY,KAAKI,OAAO,EAAE;MAC1C,IAAIN,UAAU,CAACQ,IAAI,CAAC,EAAE;QAClB,OAAOR,UAAU;MACrB;MAEAA,UAAU,CAACQ,IAAI,CAAC,GAAGf,MAAM,CAACgB,QAAQ,CAAC;QAC/BC,EAAE,EAAER,YAAY;QAChBS,EAAE,EAAEL;MACR,CAAC,CAAC;MAEF,OAAON,UAAU;IACrB,CAAC,EACD,CAAC,CACL,CAAC;IAED,MAAMY,OAAO,GAAG,MAAM,IAAAC,wBAAY,EAAkB;MAChDC,KAAK,EAAErB,MAAM,CAACqB,KAAK;MACnBC,KAAK,EAAEC,MAAM,CAACC,MAAM,CAACnB,OAAO;IAChC,CAAC,CAAC;IACF,MAAMiB,KAAK,GAAG,IAAAG,qBAAY,EAACzB,MAAM,EAAEmB,OAAO,CAAC;IAE3C,OAAOf,GAAG,CAACsB,GAAG,CAAClB,EAAE,IAAI;MACjB,OAAOc,KAAK,CAACK,MAAM,CAACC,IAAI,IAAI;QACxB,OAAOpB,EAAE,KAAKoB,IAAI,CAACpB,EAAE;MACzB,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIqB,eAAe,EAAE,IAAAC,4CAAqB,EAAC;EAC3C,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAjC,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_getAllEntryRevisions","require","_getLatestRevisionByEntryId","_getPublishedRevisionByEntryId","_getRevisionById","_DataLoaderCache","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","dataLoaders","getAllEntryRevisions","createGetAllEntryRevisions","getLatestRevisionByEntryId","createGetLatestRevisionByEntryId","getPublishedRevisionByEntryId","createGetPublishedRevisionByEntryId","getRevisionById","createGetRevisionById","getDataLoaderFactory","name","Error"],"sources":["index.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { DataLoaderParams } from \"./types\";\nimport { createGetAllEntryRevisions } from \"./getAllEntryRevisions\";\nimport { createGetLatestRevisionByEntryId } from \"./getLatestRevisionByEntryId\";\nimport { createGetPublishedRevisionByEntryId } from \"./getPublishedRevisionByEntryId\";\nimport { createGetRevisionById } from \"./getRevisionById\";\n\nexport * from \"./DataLoaderCache\";\n\ninterface Callable {\n (params: DataLoaderParams): DataLoader<any, any>;\n}\n\nconst dataLoaders: Record<string, Callable> = {\n getAllEntryRevisions: createGetAllEntryRevisions,\n getLatestRevisionByEntryId: createGetLatestRevisionByEntryId,\n getPublishedRevisionByEntryId: createGetPublishedRevisionByEntryId,\n getRevisionById: createGetRevisionById\n};\n\nexport type DataLoaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nexport const getDataLoaderFactory = (name: string) => {\n if (!dataLoaders[name]) {\n throw new Error(`Missing data loader \"${name}\".`);\n }\n return dataLoaders[name];\n};\n"],"mappings":";;;;;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAD,OAAA;AACA,IAAAE,8BAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAJ,OAAA;AAAAK,MAAA,CAAAC,IAAA,CAAAF,gBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,gBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,gBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAMA,MAAMS,WAAqC,GAAG;EAC1CC,oBAAoB,EAAEC,gDAA0B;EAChDC,0BAA0B,EAAEC,4DAAgC;EAC5DC,6BAA6B,EAAEC,kEAAmC;EAClEC,eAAe,EAAEC;AACrB,CAAC;AAQM,MAAMC,oBAAoB,GAAIC,IAAY,IAAK;EAClD,IAAI,CAACV,WAAW,CAACU,IAAI,CAAC,EAAE;IACpB,MAAM,IAAIC,KAAK,
|
|
1
|
+
{"version":3,"names":["_getAllEntryRevisions","require","_getLatestRevisionByEntryId","_getPublishedRevisionByEntryId","_getRevisionById","_DataLoaderCache","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","dataLoaders","getAllEntryRevisions","createGetAllEntryRevisions","getLatestRevisionByEntryId","createGetLatestRevisionByEntryId","getPublishedRevisionByEntryId","createGetPublishedRevisionByEntryId","getRevisionById","createGetRevisionById","getDataLoaderFactory","name","Error"],"sources":["index.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { DataLoaderParams } from \"./types\";\nimport { createGetAllEntryRevisions } from \"./getAllEntryRevisions\";\nimport { createGetLatestRevisionByEntryId } from \"./getLatestRevisionByEntryId\";\nimport { createGetPublishedRevisionByEntryId } from \"./getPublishedRevisionByEntryId\";\nimport { createGetRevisionById } from \"./getRevisionById\";\n\nexport * from \"./DataLoaderCache\";\n\ninterface Callable {\n (params: DataLoaderParams): DataLoader<any, any>;\n}\n\nconst dataLoaders: Record<string, Callable> = {\n getAllEntryRevisions: createGetAllEntryRevisions,\n getLatestRevisionByEntryId: createGetLatestRevisionByEntryId,\n getPublishedRevisionByEntryId: createGetPublishedRevisionByEntryId,\n getRevisionById: createGetRevisionById\n};\n\nexport type DataLoaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nexport const getDataLoaderFactory = (name: string) => {\n if (!dataLoaders[name]) {\n throw new Error(`Missing data loader \"${name}\".`);\n }\n return dataLoaders[name];\n};\n"],"mappings":";;;;;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAD,OAAA;AACA,IAAAE,8BAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAJ,OAAA;AAAAK,MAAA,CAAAC,IAAA,CAAAF,gBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,gBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,gBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAMA,MAAMS,WAAqC,GAAG;EAC1CC,oBAAoB,EAAEC,gDAA0B;EAChDC,0BAA0B,EAAEC,4DAAgC;EAC5DC,6BAA6B,EAAEC,kEAAmC;EAClEC,eAAe,EAAEC;AACrB,CAAC;AAQM,MAAMC,oBAAoB,GAAIC,IAAY,IAAK;EAClD,IAAI,CAACV,WAAW,CAACU,IAAI,CAAC,EAAE;IACpB,MAAM,IAAIC,KAAK,CAAC,wBAAwBD,IAAI,IAAI,CAAC;EACrD;EACA,OAAOV,WAAW,CAACU,IAAI,CAAC;AAC5B,CAAC;AAACd,OAAA,CAAAa,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_DataLoaderCache","_dataLoader","_utils","DataLoadersHandler","cache","DataLoaderCache","constructor","params","entity","getAllEntryRevisions","ids","map","id","entryId","parseIdentifier","loadMany","getRevisionById","getPublishedRevisionByEntryId","getLatestRevisionByEntryId","getLoader","name","model","cacheParams","tenant","locale","loader","getDataLoader","factory","getDataLoaderFactory","setDataLoader","results","Array","isArray","reduce","acc","res","message","WebinyError","code","data","JSON","stringify","push","ex","error","clearAll","exports"],"sources":["dataLoaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsModel, CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { CacheKeyParams, DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { DataLoaders, getDataLoaderFactory } from \"~/operations/entry/dataLoader\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { DataLoadersHandlerInterface, DataLoadersHandlerInterfaceClearAllParams } from \"~/types\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n}\n\ninterface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\n\nexport interface ClearAllParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n}\n\nexport class DataLoadersHandler implements DataLoadersHandlerInterface {\n private readonly entity: Entity<any>;\n private readonly cache: DataLoaderCache = new DataLoaderCache();\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(params: DataLoaderParams): Promise<CmsStorageEntry[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById(params: DataLoaderParams): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n locale: model.locale,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant,\n locale: model.locale\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry[]> {\n let results: any[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params?.model);\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,gBAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAoBO,MAAMI,kBAAkB,CAAwC;EAElDC,KAAK,GAAoB,IAAIC,gCAAe,CAAC,CAAC;EAExDC,WAAWA,CAACC,MAAgC,EAAE;IACjD,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EAEA,MAAaC,oBAAoBA,CAACF,MAAwB,EAA8B;IACpF,MAAMG,GAAG,GAAGH,MAAM,CAACG,GAAG,CAACC,GAAG,CAACC,EAAE,IAAI;MAC7B,MAAM;QAAEA,EAAE,EAAEC;MAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACF,EAAE,CAAC;MAC3C,OAAOC,OAAO;IAClB,CAAC,CAAC;IACF,OAAO,MAAM,IAAI,CAACE,QAAQ,CAAC,sBAAsB,EAAER,MAAM,EAAEG,GAAG,CAAC;EACnE;EAEA,MAAaM,eAAeA,CAACT,MAAwB,EAA8B;IAC/E,OAAO,MAAM,IAAI,CAACQ,QAAQ,CAAC,iBAAiB,EAAER,MAAM,EAAEA,MAAM,CAACG,GAAG,CAAC;EACrE;EAEA,MAAaO,6BAA6BA,CACtCV,MAAwB,EACE;IAC1B,MAAMG,GAAG,GAAGH,MAAM,CAACG,GAAG,CAACC,GAAG,CAACC,EAAE,IAAI;MAC7B,MAAM;QAAEA,EAAE,EAAEC;MAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACF,EAAE,CAAC;MAC3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;IACvB,IAAI;MACAA,OAAO,GAAG,MAAM,IAAI,CAACX,SAAS,CAACM,MAAM,EAAElB,MAAM,CAAC,CAACQ,QAAQ,CAACL,GAAG,CAAC;MAC5D,IAAIqB,KAAK,CAACC,OAAO,CAACF,OAAO,CAAC,KAAK,IAAI,EAAE;QACjC,OAAOA,OAAO,CAACG,MAAM,CAAC,CAACC,GAAG,EAAEC,GAAG,KAAK;UAChC,IAAIJ,KAAK,CAACC,OAAO,CAACG,GAAG,CAAC,KAAK,KAAK,EAAE;YAC9B,IAAIA,GAAG,IAAIA,GAAG,CAACC,OAAO,EAAE;cACpB,MAAM,IAAIC,cAAW,CAACF,GAAG,CAACC,OAAO,EAAED,GAAG,CAACG,IAAI,EAAE;gBACzC,GAAGH,GAAG;gBACNI,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACN,GAAG,CAACI,IAAI,IAAI,CAAC,CAAC;cACvC,CAAC,CAAC;YACN;YACA,MAAM,IAAIF,cAAW,CACjB,uFAAuF,EACvF,2BAA2B,EAC3B;cACI,GAAG9B,MAAM;cACTkB;YACJ,CACJ,CAAC;UACL;UACAS,GAAG,CAACQ,IAAI,CAAC,GAAGP,GAAG,CAAC;UAChB,OAAOD,GAAG;QACd,CAAC,EAAE,EAAE,CAAC;MACV;IACJ,CAAC,CAAC,OAAOS,EAAE,EAAE;MACT,MAAM,IAAIN,cAAW,CACjBM,EAAE,CAACP,OAAO,IAAI,oBAAoB,EAClCO,EAAE,CAACL,IAAI,IAAI,mBAAmB,EAC9B;QACIM,KAAK,EAAED,EAAE;QACT,GAAGpC,MAAM;QACTkB,MAAM;QACNf;MACJ,CACJ,CAAC;IACL;IACA,MAAM,IAAI2B,cAAW,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_DataLoaderCache","_dataLoader","_utils","DataLoadersHandler","cache","DataLoaderCache","constructor","params","entity","getAllEntryRevisions","ids","map","id","entryId","parseIdentifier","loadMany","getRevisionById","getPublishedRevisionByEntryId","getLatestRevisionByEntryId","getLoader","name","model","cacheParams","tenant","locale","loader","getDataLoader","factory","getDataLoaderFactory","setDataLoader","results","Array","isArray","reduce","acc","res","message","WebinyError","code","data","JSON","stringify","push","ex","error","clearAll","exports"],"sources":["dataLoaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsModel, CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { CacheKeyParams, DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { DataLoaders, getDataLoaderFactory } from \"~/operations/entry/dataLoader\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { DataLoadersHandlerInterface, DataLoadersHandlerInterfaceClearAllParams } from \"~/types\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n}\n\ninterface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\n\nexport interface ClearAllParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n}\n\nexport class DataLoadersHandler implements DataLoadersHandlerInterface {\n private readonly entity: Entity<any>;\n private readonly cache: DataLoaderCache = new DataLoaderCache();\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(params: DataLoaderParams): Promise<CmsStorageEntry[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById(params: DataLoaderParams): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n locale: model.locale,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant,\n locale: model.locale\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry[]> {\n let results: any[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params?.model);\n }\n}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CAAC,CAACC,GAAG,EAAEC,GAAG,KAAK;UAChC,IAAIJ,KAAK,CAACC,OAAO,CAACG,GAAG,CAAC,KAAK,KAAK,EAAE;YAC9B,IAAIA,GAAG,IAAIA,GAAG,CAACC,OAAO,EAAE;cACpB,MAAM,IAAIC,cAAW,CAACF,GAAG,CAACC,OAAO,EAAED,GAAG,CAACG,IAAI,EAAE;gBACzC,GAAGH,GAAG;gBACNI,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACN,GAAG,CAACI,IAAI,IAAI,CAAC,CAAC;cACvC,CAAC,CAAC;YACN;YACA,MAAM,IAAIF,cAAW,CACjB,uFAAuF,EACvF,2BAA2B,EAC3B;cACI,GAAG9B,MAAM;cACTkB;YACJ,CACJ,CAAC;UACL;UACAS,GAAG,CAACQ,IAAI,CAAC,GAAGP,GAAG,CAAC;UAChB,OAAOD,GAAG;QACd,CAAC,EAAE,EAAE,CAAC;MACV;IACJ,CAAC,CAAC,OAAOS,EAAE,EAAE;MACT,MAAM,IAAIN,cAAW,CACjBM,EAAE,CAACP,OAAO,IAAI,oBAAoB,EAClCO,EAAE,CAACL,IAAI,IAAI,mBAAmB,EAC9B;QACIM,KAAK,EAAED,EAAE;QACT,GAAGpC,MAAM;QACTkB,MAAM;QACNf;MACJ,CACJ,CAAC;IACL;IACA,MAAM,IAAI2B,cAAW,CACjB,2DAA2D,EAC3D,4BAA4B,EAC5B;MACIZ,MAAM;MACNf,GAAG;MACHoB;IACJ,CACJ,CAAC;EACL;EAEOe,QAAQA,CAACtC,MAAkD,EAAQ;IACtE,IAAI,CAACH,KAAK,CAACyC,QAAQ,CAACtC,MAAM,EAAEc,KAAK,CAAC;EACtC;AACJ;AAACyB,OAAA,CAAA3C,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_plugins","_constants","createSystemField","field","id","fieldId","label","createSystemFields","onMetaFields","ENTRY_META_FIELDS","filter","isDateTimeEntryMetaField","reduce","current","fieldName","type","unmappedType","keyword","systemField","searchable","sortable","storageId","settings","parents","byMetaFields","isIdentityEntryMetaField","undefined","path","entryId","wbyAco_location","fields","version","status","wbyDeleted","binOriginalFolderId","buildCustomFields","params","fieldTypePlugins","collection","typePlugin","fieldType","fullTextSearch","buildFieldsList","plugins","result","plugin","WebinyError","childFields","length","childResult","Object","assign","identifier","map","p","join","createModelFields","model","fieldDefinitionPlugins","byType","CmsElasticsearchModelFieldPlugin","canBeApplied","modelId","unmappedTypes","acc","types","isSearchable","isSortable","exports"],"sources":["fields.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin\n} from \"@webiny/api-headless-cms/types\";\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { ModelFieldParent, ModelFields } from \"./types\";\nimport { CmsElasticsearchModelFieldPlugin } from \"~/plugins\";\nimport {\n ENTRY_META_FIELDS,\n isDateTimeEntryMetaField,\n isIdentityEntryMetaField\n} from \"@webiny/api-headless-cms/constants\";\n\ntype PartialCmsModelField = Partial<CmsModelField> &\n Pick<CmsModelField, \"storageId\" | \"fieldId\" | \"type\">;\nconst createSystemField = (field: PartialCmsModelField): CmsModelField => {\n return {\n ...field,\n id: field.fieldId,\n label: field.fieldId\n };\n};\n\nconst createSystemFields = (): ModelFields => {\n const onMetaFields = ENTRY_META_FIELDS.filter(isDateTimeEntryMetaField).reduce(\n (current, fieldName) => {\n return {\n ...current,\n [fieldName]: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: fieldName,\n fieldId: fieldName,\n type: \"text\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n }),\n parents: []\n }\n };\n },\n {}\n );\n\n const byMetaFields = ENTRY_META_FIELDS.filter(isIdentityEntryMetaField).reduce(\n (current, fieldName) => {\n return {\n ...current,\n [fieldName]: {\n type: \"text\",\n unmappedType: undefined,\n systemField: true,\n searchable: true,\n sortable: true,\n path: `${fieldName}.id`,\n field: createSystemField({\n storageId: fieldName,\n fieldId: fieldName,\n type: \"text\"\n }),\n parents: []\n }\n };\n },\n {}\n );\n\n return {\n id: {\n type: \"text\",\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"id\",\n fieldId: \"id\",\n type: \"text\"\n }),\n parents: []\n },\n entryId: {\n type: \"text\",\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"entryId\",\n fieldId: \"entryId\",\n type: \"text\"\n }),\n parents: []\n },\n\n ...onMetaFields,\n ...byMetaFields,\n\n wbyAco_location: {\n type: \"object\",\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"location\",\n fieldId: \"wbyAco_location\",\n type: \"object\",\n settings: {\n fields: [\n {\n id: \"folderId\",\n fieldId: \"folderId\",\n storageId: \"folderId\",\n type: \"text\",\n label: \"Folder ID\"\n }\n ]\n }\n }),\n parents: []\n },\n \"wbyAco_location.folderId\": {\n type: \"text\",\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n id: \"folderId\",\n fieldId: \"folderId\",\n storageId: \"folderId\",\n type: \"text\",\n label: \"Folder ID\"\n }),\n parents: [\n {\n fieldId: \"wbyAco_location\",\n type: \"object\",\n storageId: \"location\"\n }\n ]\n },\n version: {\n type: \"number\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"version\",\n fieldId: \"version\",\n type: \"number\"\n }),\n parents: []\n },\n status: {\n type: \"string\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"status\",\n fieldId: \"status\",\n type: \"string\"\n }),\n parents: []\n },\n wbyDeleted: {\n type: \"boolean\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"wbyDeleted\",\n fieldId: \"wbyDeleted\",\n type: \"boolean\"\n }),\n parents: []\n },\n binOriginalFolderId: {\n type: \"text\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"binOriginalFolderId\",\n fieldId: \"binOriginalFolderId\",\n type: \"text\"\n }),\n parents: []\n }\n };\n};\n\ninterface UnmappedFieldTypes {\n [type: string]: (field: Pick<CmsModelField, \"fieldId\" | \"type\">) => string | undefined;\n}\n\ninterface FieldTypePlugin {\n unmappedType?: (field: Pick<CmsModelField, \"fieldId\" | \"type\">) => string | undefined;\n searchable: boolean;\n sortable: boolean;\n fullTextSearch?: boolean;\n}\n\ninterface FieldTypePlugins {\n [key: string]: FieldTypePlugin;\n}\n\ninterface BuildCustomFieldsParams {\n fields: CmsElasticsearchModelFieldPlugin[];\n fieldTypePlugins: FieldTypePlugins;\n}\n\nconst buildCustomFields = (params: BuildCustomFieldsParams) => {\n const { fields, fieldTypePlugins } = params;\n\n return fields.reduce<ModelFields>((collection, field) => {\n const typePlugin = fieldTypePlugins[field.fieldType];\n if (!typePlugin) {\n return collection;\n }\n let unmappedType: string | undefined = undefined;\n if (typePlugin.unmappedType) {\n unmappedType = typePlugin.unmappedType(field);\n }\n\n collection[field.fieldId] = {\n type: field.fieldType,\n field: createSystemField({\n storageId: field.fieldId,\n fieldId: field.fieldId,\n type: field.fieldType\n }),\n unmappedType,\n fullTextSearch: field.searchable ? typePlugin.fullTextSearch : false,\n searchable: field.searchable || typePlugin.searchable,\n sortable: field.sortable || typePlugin.sortable,\n systemField: false,\n path: field.path,\n parents: []\n };\n\n return collection;\n }, {});\n};\n\ninterface BuildParams {\n plugins: FieldTypePlugins;\n fields: CmsModelField[];\n parents: ModelFieldParent[];\n}\n\nconst buildFieldsList = (params: BuildParams): ModelFields => {\n const { plugins, fields, parents } = params;\n\n return fields.reduce<ModelFields>((result, field) => {\n const plugin = plugins[field.type];\n if (!plugin) {\n throw new WebinyError(`There is no plugin for field type \"${field.type}\".`);\n }\n\n const { searchable, sortable, unmappedType, fullTextSearch } = plugin;\n /**\n * If a field has child fields, go through them and add them to a result.\n */\n const childFields = field.settings?.fields || [];\n if (childFields.length > 0) {\n /**\n * Let's build all the child fields\n */\n const childResult = buildFieldsList({\n fields: childFields,\n plugins,\n parents: [\n ...parents,\n {\n fieldId: field.fieldId,\n storageId: field.storageId,\n type: field.type\n }\n ]\n });\n Object.assign(result, childResult);\n }\n\n const identifier = [...parents.map(p => p.fieldId), field.fieldId].join(\".\");\n\n result[identifier] = {\n type: field.type,\n parents,\n searchable,\n sortable,\n fullTextSearch,\n unmappedType: typeof unmappedType === \"function\" ? unmappedType(field) : undefined,\n systemField: false,\n field\n };\n\n return result;\n }, {});\n};\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n}\n\nexport const createModelFields = ({ plugins, model }: Params) => {\n const fields = model.fields;\n const fieldDefinitionPlugins = plugins\n .byType<CmsElasticsearchModelFieldPlugin>(CmsElasticsearchModelFieldPlugin.type)\n .filter(plugin => {\n return plugin.canBeApplied(model.modelId);\n });\n /**\n * Collect all unmappedType from elastic plugins.\n */\n const unmappedTypes = plugins\n .byType<CmsModelFieldToElasticsearchPlugin>(\"cms-model-field-to-elastic-search\")\n .reduce<UnmappedFieldTypes>((acc, plugin) => {\n if (!plugin.unmappedType) {\n return acc;\n }\n acc[plugin.fieldType] = plugin.unmappedType;\n return acc;\n }, {});\n /**\n * Collect all field types from the plugins.\n */\n const fieldTypePlugins = plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce<FieldTypePlugins>((types, plugin) => {\n const { fieldType, fullTextSearch } = plugin;\n types[fieldType] = {\n unmappedType: unmappedTypes[fieldType],\n searchable: plugin.isSearchable,\n sortable: plugin.isSortable,\n fullTextSearch\n };\n return types;\n }, {});\n\n return {\n ...createSystemFields(),\n ...buildCustomFields({\n fields: fieldDefinitionPlugins,\n fieldTypePlugins\n }),\n ...buildFieldsList({\n fields,\n plugins: fieldTypePlugins,\n parents: []\n })\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AASA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAQA,MAAMG,iBAAiB,GAAIC,KAA2B,IAAoB;EACtE,OAAO;IACH,GAAGA,KAAK;IACRC,EAAE,EAAED,KAAK,CAACE,OAAO;IACjBC,KAAK,EAAEH,KAAK,CAACE;EACjB,CAAC;AACL,CAAC;AAED,MAAME,kBAAkB,GAAGA,CAAA,KAAmB;EAC1C,MAAMC,YAAY,GAAGC,4BAAiB,CAACC,MAAM,CAACC,mCAAwB,CAAC,CAACC,MAAM,CAC1E,CAACC,OAAO,EAAEC,SAAS,KAAK;IACpB,OAAO;MACH,GAAGD,OAAO;MACV,CAACC,SAAS,GAAG;QACTC,IAAI,EAAE,MAAM;QACZC,YAAY,EAAE,MAAM;QACpBC,OAAO,EAAE,KAAK;QACdC,WAAW,EAAE,IAAI;QACjBC,UAAU,EAAE,IAAI;QAChBC,QAAQ,EAAE,IAAI;QACdjB,KAAK,EAAED,iBAAiB,CAAC;UACrBmB,SAAS,EAAEP,SAAS;UACpBT,OAAO,EAAES,SAAS;UAClBC,IAAI,EAAE,MAAM;UACZO,QAAQ,EAAE;YACNP,IAAI,EAAE;UACV;QACJ,CAAC,CAAC;QACFQ,OAAO,EAAE;MACb;IACJ,CAAC;EACL,CAAC,EACD,CAAC,CACL,CAAC;EAED,MAAMC,YAAY,GAAGf,4BAAiB,CAACC,MAAM,CAACe,mCAAwB,CAAC,CAACb,MAAM,CAC1E,CAACC,OAAO,EAAEC,SAAS,KAAK;IACpB,OAAO;MACH,GAAGD,OAAO;MACV,CAACC,SAAS,GAAG;QACTC,IAAI,EAAE,MAAM;QACZC,YAAY,EAAEU,SAAS;QACvBR,WA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nB,MAAM,CAACL,SAAS,CAAC,GAAGK,MAAM,CAAC7B,YAAY;IAC3C,OAAOgD,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC;EACV;AACJ;AACA;EACI,MAAM3B,gBAAgB,GAAGM,OAAO,CAC3BgB,MAAM,CAA+B,4BAA4B,CAAC,CAClE/C,MAAM,CAAmB,CAACqD,KAAK,EAAEpB,MAAM,KAAK;IACzC,MAAM;MAAEL,SAAS;MAAEC;IAAe,CAAC,GAAGI,MAAM;IAC5CoB,KAAK,CAACzB,SAAS,CAAC,GAAG;MACfxB,YAAY,EAAE+C,aAAa,CAACvB,SAAS,CAAC;MACtCrB,UAAU,EAAE0B,MAAM,CAACqB,YAAY;MAC/B9C,QAAQ,EAAEyB,MAAM,CAACsB,UAAU;MAC3B1B;IACJ,CAAC;IACD,OAAOwB,KAAK;EAChB,CAAC,EAAE,CAAC,CAAC,CAAC;EAEV,OAAO;IACH,GAAG1D,kBAAkB,CAAC,CAAC;IACvB,GAAG4B,iBAAiB,CAAC;MACjBL,MAAM,EAAE4B,sBAAsB;MAC9BrB;IACJ,CAAC,CAAC;IACF,GAAGK,eAAe,CAAC;MACfZ,MAAM;MACNa,OAAO,EAAEN,gBAAgB;MACzBd,OAAO,EAAE;IACb,CAAC;EACL,CAAC;AACL,CAAC;AAAC6C,OAAA,CAAAZ,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_plugins","_constants","createSystemField","field","id","fieldId","label","createSystemFields","onMetaFields","ENTRY_META_FIELDS","filter","isDateTimeEntryMetaField","reduce","current","fieldName","type","unmappedType","keyword","systemField","searchable","sortable","storageId","settings","parents","byMetaFields","isIdentityEntryMetaField","undefined","path","entryId","wbyAco_location","fields","version","status","wbyDeleted","binOriginalFolderId","buildCustomFields","params","fieldTypePlugins","collection","typePlugin","fieldType","fullTextSearch","buildFieldsList","plugins","result","plugin","WebinyError","childFields","length","childResult","Object","assign","identifier","map","p","join","createModelFields","model","fieldDefinitionPlugins","byType","CmsElasticsearchModelFieldPlugin","canBeApplied","modelId","unmappedTypes","acc","types","isSearchable","isSortable","exports"],"sources":["fields.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin\n} from \"@webiny/api-headless-cms/types\";\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { ModelFieldParent, ModelFields } from \"./types\";\nimport { CmsElasticsearchModelFieldPlugin } from \"~/plugins\";\nimport {\n ENTRY_META_FIELDS,\n isDateTimeEntryMetaField,\n isIdentityEntryMetaField\n} from \"@webiny/api-headless-cms/constants\";\n\ntype PartialCmsModelField = Partial<CmsModelField> &\n Pick<CmsModelField, \"storageId\" | \"fieldId\" | \"type\">;\nconst createSystemField = (field: PartialCmsModelField): CmsModelField => {\n return {\n ...field,\n id: field.fieldId,\n label: field.fieldId\n };\n};\n\nconst createSystemFields = (): ModelFields => {\n const onMetaFields = ENTRY_META_FIELDS.filter(isDateTimeEntryMetaField).reduce(\n (current, fieldName) => {\n return {\n ...current,\n [fieldName]: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: fieldName,\n fieldId: fieldName,\n type: \"text\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n }),\n parents: []\n }\n };\n },\n {}\n );\n\n const byMetaFields = ENTRY_META_FIELDS.filter(isIdentityEntryMetaField).reduce(\n (current, fieldName) => {\n return {\n ...current,\n [fieldName]: {\n type: \"text\",\n unmappedType: undefined,\n systemField: true,\n searchable: true,\n sortable: true,\n path: `${fieldName}.id`,\n field: createSystemField({\n storageId: fieldName,\n fieldId: fieldName,\n type: \"text\"\n }),\n parents: []\n }\n };\n },\n {}\n );\n\n return {\n id: {\n type: \"text\",\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"id\",\n fieldId: \"id\",\n type: \"text\"\n }),\n parents: []\n },\n entryId: {\n type: \"text\",\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"entryId\",\n fieldId: \"entryId\",\n type: \"text\"\n }),\n parents: []\n },\n\n ...onMetaFields,\n ...byMetaFields,\n\n wbyAco_location: {\n type: \"object\",\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"location\",\n fieldId: \"wbyAco_location\",\n type: \"object\",\n settings: {\n fields: [\n {\n id: \"folderId\",\n fieldId: \"folderId\",\n storageId: \"folderId\",\n type: \"text\",\n label: \"Folder ID\"\n }\n ]\n }\n }),\n parents: []\n },\n \"wbyAco_location.folderId\": {\n type: \"text\",\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n id: \"folderId\",\n fieldId: \"folderId\",\n storageId: \"folderId\",\n type: \"text\",\n label: \"Folder ID\"\n }),\n parents: [\n {\n fieldId: \"wbyAco_location\",\n type: \"object\",\n storageId: \"location\"\n }\n ]\n },\n version: {\n type: \"number\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"version\",\n fieldId: \"version\",\n type: \"number\"\n }),\n parents: []\n },\n status: {\n type: \"string\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"status\",\n fieldId: \"status\",\n type: \"string\"\n }),\n parents: []\n },\n wbyDeleted: {\n type: \"boolean\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"wbyDeleted\",\n fieldId: \"wbyDeleted\",\n type: \"boolean\"\n }),\n parents: []\n },\n binOriginalFolderId: {\n type: \"text\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"binOriginalFolderId\",\n fieldId: \"binOriginalFolderId\",\n type: \"text\"\n }),\n parents: []\n }\n };\n};\n\ninterface UnmappedFieldTypes {\n [type: string]: (field: Pick<CmsModelField, \"fieldId\" | \"type\">) => string | undefined;\n}\n\ninterface FieldTypePlugin {\n unmappedType?: (field: Pick<CmsModelField, \"fieldId\" | \"type\">) => string | undefined;\n searchable: boolean;\n sortable: boolean;\n fullTextSearch?: boolean;\n}\n\ninterface FieldTypePlugins {\n [key: string]: FieldTypePlugin;\n}\n\ninterface BuildCustomFieldsParams {\n fields: CmsElasticsearchModelFieldPlugin[];\n fieldTypePlugins: FieldTypePlugins;\n}\n\nconst buildCustomFields = (params: BuildCustomFieldsParams) => {\n const { fields, fieldTypePlugins } = params;\n\n return fields.reduce<ModelFields>((collection, field) => {\n const typePlugin = fieldTypePlugins[field.fieldType];\n if (!typePlugin) {\n return collection;\n }\n let unmappedType: string | undefined = undefined;\n if (typePlugin.unmappedType) {\n unmappedType = typePlugin.unmappedType(field);\n }\n\n collection[field.fieldId] = {\n type: field.fieldType,\n field: createSystemField({\n storageId: field.fieldId,\n fieldId: field.fieldId,\n type: field.fieldType\n }),\n unmappedType,\n fullTextSearch: field.searchable ? typePlugin.fullTextSearch : false,\n searchable: field.searchable || typePlugin.searchable,\n sortable: field.sortable || typePlugin.sortable,\n systemField: false,\n path: field.path,\n parents: []\n };\n\n return collection;\n }, {});\n};\n\ninterface BuildParams {\n plugins: FieldTypePlugins;\n fields: CmsModelField[];\n parents: ModelFieldParent[];\n}\n\nconst buildFieldsList = (params: BuildParams): ModelFields => {\n const { plugins, fields, parents } = params;\n\n return fields.reduce<ModelFields>((result, field) => {\n const plugin = plugins[field.type];\n if (!plugin) {\n throw new WebinyError(`There is no plugin for field type \"${field.type}\".`);\n }\n\n const { searchable, sortable, unmappedType, fullTextSearch } = plugin;\n /**\n * If a field has child fields, go through them and add them to a result.\n */\n const childFields = field.settings?.fields || [];\n if (childFields.length > 0) {\n /**\n * Let's build all the child fields\n */\n const childResult = buildFieldsList({\n fields: childFields,\n plugins,\n parents: [\n ...parents,\n {\n fieldId: field.fieldId,\n storageId: field.storageId,\n type: field.type\n }\n ]\n });\n Object.assign(result, childResult);\n }\n\n const identifier = [...parents.map(p => p.fieldId), field.fieldId].join(\".\");\n\n result[identifier] = {\n type: field.type,\n parents,\n searchable,\n sortable,\n fullTextSearch,\n unmappedType: typeof unmappedType === \"function\" ? unmappedType(field) : undefined,\n systemField: false,\n field\n };\n\n return result;\n }, {});\n};\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n}\n\nexport const createModelFields = ({ plugins, model }: Params) => {\n const fields = model.fields;\n const fieldDefinitionPlugins = plugins\n .byType<CmsElasticsearchModelFieldPlugin>(CmsElasticsearchModelFieldPlugin.type)\n .filter(plugin => {\n return plugin.canBeApplied(model.modelId);\n });\n /**\n * Collect all unmappedType from elastic plugins.\n */\n const unmappedTypes = plugins\n .byType<CmsModelFieldToElasticsearchPlugin>(\"cms-model-field-to-elastic-search\")\n .reduce<UnmappedFieldTypes>((acc, plugin) => {\n if (!plugin.unmappedType) {\n return acc;\n }\n acc[plugin.fieldType] = plugin.unmappedType;\n return acc;\n }, {});\n /**\n * Collect all field types from the plugins.\n */\n const fieldTypePlugins = plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce<FieldTypePlugins>((types, plugin) => {\n const { fieldType, fullTextSearch } = plugin;\n types[fieldType] = {\n unmappedType: unmappedTypes[fieldType],\n searchable: plugin.isSearchable,\n sortable: plugin.isSortable,\n fullTextSearch\n };\n return types;\n }, {});\n\n return {\n ...createSystemFields(),\n ...buildCustomFields({\n fields: fieldDefinitionPlugins,\n fieldTypePlugins\n }),\n ...buildFieldsList({\n fields,\n plugins: fieldTypePlugins,\n parents: []\n })\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AASA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAQA,MAAMG,i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AK;IACzC,MAAM;MAAEL,SAAS;MAAEC;IAAe,CAAC,GAAGI,MAAM;IAC5CoB,KAAK,CAACzB,SAAS,CAAC,GAAG;MACfxB,YAAY,EAAE+C,aAAa,CAACvB,SAAS,CAAC;MACtCrB,UAAU,EAAE0B,MAAM,CAACqB,YAAY;MAC/B9C,QAAQ,EAAEyB,MAAM,CAACsB,UAAU;MAC3B1B;IACJ,CAAC;IACD,OAAOwB,KAAK;EAChB,CAAC,EAAE,CAAC,CAAC,CAAC;EAEV,OAAO;IACH,GAAG1D,kBAAkB,CAAC,CAAC;IACvB,GAAG4B,iBAAiB,CAAC;MACjBL,MAAM,EAAE4B,sBAAsB;MAC9BrB;IACJ,CAAC,CAAC;IACF,GAAGK,eAAe,CAAC;MACfZ,MAAM;MACNa,OAAO,EAAEN,gBAAgB;MACzBd,OAAO,EAAE;IACb,CAAC;EACL,CAAC;AACL,CAAC;AAAC6C,OAAA,CAAAZ,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_transformValueForSearch","_keyword","_path","createApplyFiltering","operatorPlugins","searchPlugins","createFieldPath","createFieldPathFactory","plugins","params","key","value","initialValue","query","operator","field","plugin","WebinyError","transformValueForSearch","keyword","hasKeyword","basePath","path","apply","name","fieldId","exports"],"sources":["applyFiltering.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"~/operations/entry/elasticsearch/transformValueForSearch\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport {\n ElasticsearchQueryBuilderOperatorPlugins,\n ElasticsearchQuerySearchValuePlugins\n} from \"~/operations/entry/elasticsearch/types\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\nimport { ApplyFilteringCb } from \"~/plugins/CmsEntryFilterPlugin\";\n\ninterface CreateParams {\n operatorPlugins: ElasticsearchQueryBuilderOperatorPlugins;\n searchPlugins: ElasticsearchQuerySearchValuePlugins;\n}\n\nexport const createApplyFiltering = ({\n operatorPlugins,\n searchPlugins\n}: CreateParams): ApplyFilteringCb => {\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n return params => {\n const { key, value: initialValue, query, operator, field } = params;\n\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\n `Elasticsearch operator \"${operator}\" plugin missing.`,\n \"PLUGIN_MISSING\",\n {\n operator\n }\n );\n }\n\n const value = transformValueForSearch({\n plugins: searchPlugins,\n field: field.field,\n value: initialValue\n });\n\n const keyword = hasKeyword(field);\n\n const { basePath, path } = createFieldPath({\n field,\n value,\n key,\n keyword\n });\n\n plugin.apply(query, {\n name: field.field.fieldId,\n basePath,\n path,\n value,\n keyword\n });\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AAQO,MAAMI,oBAAoB,GAAGA,CAAC;EACjCC,eAAe;EACfC;AACU,CAAC,KAAuB;EAClC,MAAMC,eAAe,GAAG,IAAAC,4BAAsB,EAAC;IAC3CC,OAAO,EAAEH;EACb,CAAC,CAAC;EAEF,OAAOI,MAAM,IAAI;IACb,MAAM;MAAEC,GAAG;MAAEC,KAAK,EAAEC,YAAY;MAAEC,KAAK;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGN,MAAM;IAEnE,MAAMO,MAAM,GAAGZ,eAAe,CAACU,QAAQ,CAAC;IACxC,IAAI,CAACE,MAAM,EAAE;MACT,MAAM,IAAIC,cAAW,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_transformValueForSearch","_keyword","_path","createApplyFiltering","operatorPlugins","searchPlugins","createFieldPath","createFieldPathFactory","plugins","params","key","value","initialValue","query","operator","field","plugin","WebinyError","transformValueForSearch","keyword","hasKeyword","basePath","path","apply","name","fieldId","exports"],"sources":["applyFiltering.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"~/operations/entry/elasticsearch/transformValueForSearch\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport {\n ElasticsearchQueryBuilderOperatorPlugins,\n ElasticsearchQuerySearchValuePlugins\n} from \"~/operations/entry/elasticsearch/types\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\nimport { ApplyFilteringCb } from \"~/plugins/CmsEntryFilterPlugin\";\n\ninterface CreateParams {\n operatorPlugins: ElasticsearchQueryBuilderOperatorPlugins;\n searchPlugins: ElasticsearchQuerySearchValuePlugins;\n}\n\nexport const createApplyFiltering = ({\n operatorPlugins,\n searchPlugins\n}: CreateParams): ApplyFilteringCb => {\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n return params => {\n const { key, value: initialValue, query, operator, field } = params;\n\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\n `Elasticsearch operator \"${operator}\" plugin missing.`,\n \"PLUGIN_MISSING\",\n {\n operator\n }\n );\n }\n\n const value = transformValueForSearch({\n plugins: searchPlugins,\n field: field.field,\n value: initialValue\n });\n\n const keyword = hasKeyword(field);\n\n const { basePath, path } = createFieldPath({\n field,\n value,\n key,\n keyword\n });\n\n plugin.apply(query, {\n name: field.field.fieldId,\n basePath,\n path,\n value,\n keyword\n });\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AAQO,MAAMI,oBAAoB,GAAGA,CAAC;EACjCC,eAAe;EACfC;AACU,CAAC,KAAuB;EAClC,MAAMC,eAAe,GAAG,IAAAC,4BAAsB,EAAC;IAC3CC,OAAO,EAAEH;EACb,CAAC,CAAC;EAEF,OAAOI,MAAM,IAAI;IACb,MAAM;MAAEC,GAAG;MAAEC,KAAK,EAAEC,YAAY;MAAEC,KAAK;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGN,MAAM;IAEnE,MAAMO,MAAM,GAAGZ,eAAe,CAACU,QAAQ,CAAC;IACxC,IAAI,CAACE,MAAM,EAAE;MACT,MAAM,IAAIC,cAAW,CACjB,2BAA2BH,QAAQ,mBAAmB,EACtD,gBAAgB,EAChB;QACIA;MACJ,CACJ,CAAC;IACL;IAEA,MAAMH,KAAK,GAAG,IAAAO,gDAAuB,EAAC;MAClCV,OAAO,EAAEH,aAAa;MACtBU,KAAK,EAAEA,KAAK,CAACA,KAAK;MAClBJ,KAAK,EAAEC;IACX,CAAC,CAAC;IAEF,MAAMO,OAAO,GAAG,IAAAC,mBAAU,EAACL,KAAK,CAAC;IAEjC,MAAM;MAAEM,QAAQ;MAAEC;IAAK,CAAC,GAAGhB,eAAe,CAAC;MACvCS,KAAK;MACLJ,KAAK;MACLD,GAAG;MACHS;IACJ,CAAC,CAAC;IAEFH,MAAM,CAACO,KAAK,CAACV,KAAK,EAAE;MAChBW,IAAI,EAAET,KAAK,CAACA,KAAK,CAACU,OAAO;MACzBJ,QAAQ;MACRC,IAAI;MACJX,KAAK;MACLQ;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACO,OAAA,CAAAvB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_search","_operator","_initialQuery","_apiElasticsearch","_values","_populated","_applyFiltering","_CmsEntryFilterPlugin","_assignMinimumShouldMatchToQuery","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","exports"],"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];\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 \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const field = fields[fieldId];\n if (!field) {\n throw new WebinyError(`There is no field \"${fieldId}\".`, \"EXEC_FILTERING_ERROR\");\n }\n const filterPlugin = getFilterPlugin(field.type);\n\n filterPlugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n };\n\n return execFiltering;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA;AACA,IAAAQ,qBAAA,GAAAR,OAAA;AACA,IAAAS,gCAAA,GAAAT,OAAA;AAcO,MAAMU,mBAAmB,GAAIC,MAAwB,IAAkC;EAC1F,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;;EAEzC;AACJ;AACA;EACI,MAAMI,aAAa,GAAG,IAAAC,8BAAsB,EAAC;IACzCH;EACJ,CAAC,CAAC;EACF;AACJ;AACA;EACI,MAAMI,eAAe,GAAG,IAAAC,kCAAwB,EAAC;IAC7CL,OAAO;IACPM,MAAM,EAAEL,KAAK,CAAC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ACA,MAAM;QAAEmB,KAAK,EAAEC,YAAY;QAAEC;MAAS,CAAC,GAAG,IAAAC,+BAAa,EAAClB,GAAG,CAAC;MAE5D,IAAImB,OAAe,GAAGH,YAAY;;MAElC;AACZ;AACA;AACA;AACA;AACA;MACY,MAAMI,aAAa,GAAG7C,KAAK,CAACF,MAAM,CAACgD,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACH,OAAO,KAAKA,OAAO,CAAC;MACnE,IAAI,CAACC,aAAa,IAAI,CAAC/C,MAAM,CAAC8C,OAAO,CAAC,EAAE;QACpC,MAAM,IAAI3B,cAAW,CAAE,gCAA+B2B,OAAQ,IAAG,CAAC;MACtE,CAAC,MAAM,IAAIC,aAAa,EAAE;QACtBD,OAAO,GAAGC,aAAa,CAACD,OAAO;MACnC;MAEA,MAAMJ,KAAK,GAAG1C,MAAM,CAAC8C,OAAO,CAAC;MAC7B,IAAI,CAACJ,KAAK,EAAE;QACR,MAAM,IAAIvB,cAAW,CAAE,sBAAqB2B,OAAQ,IAAG,EAAE,sBAAsB,CAAC;MACpF;MACA,MAAMI,YAAY,GAAGhC,eAAe,CAACwB,KAAK,CAAC7B,IAAI,CAAC;MAEhDqC,YAAY,CAACC,IAAI,CAAC;QACd3C,cAAc;QACdU,eAAe;QACfS,GAAG;QACHC,KAAK;QACLgB,QAAQ;QACRF,KAAK;QACL1C,MAAM;QACNuB;MACJ,CAAC,CAAC;IACN;EACJ,CAAC;EAED,OAAOH,aAAa;AACxB,CAAC;AAACgC,OAAA,CAAAtD,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_search","_operator","_initialQuery","_apiElasticsearch","_values","_populated","_applyFiltering","_CmsEntryFilterPlugin","_assignMinimumShouldMatchToQuery","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","exports"],"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];\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 \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const field = fields[fieldId];\n if (!field) {\n throw new WebinyError(`There is no field \"${fieldId}\".`, \"EXEC_FILTERING_ERROR\");\n }\n const filterPlugin = getFilterPlugin(field.type);\n\n filterPlugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n };\n\n return execFiltering;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA;AACA,IAAAQ,qBAAA,GAAAR,OAAA;AACA,IAAAS,gCAAA,GAAAT,OAAA;AAcO,MAAMU,mBAAmB,GAAIC,MAAwB,IAAkC;EAC1F,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;;EAEzC;AACJ;AACA;EACI,MAAMI,aAAa,GAAG,IAAAC,8BAAsB,EAAC;IACzCH;EACJ,CAAC,CAAC;EACF;AACJ;AACA;EACI,MAAMI,eAAe,GAAG,IAAAC,kCAA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EAA+B,EAAC;UAC5BlB;QACJ,CAAC,CAAC;QACF;MACJ;MACA,MAAM;QAAEmB,KAAK,EAAEC,YAAY;QAAEC;MAAS,CAAC,GAAG,IAAAC,+BAAa,EAAClB,GAAG,CAAC;MAE5D,IAAImB,OAAe,GAAGH,YAAY;;MAElC;AACZ;AACA;AACA;AACA;AACA;MACY,MAAMI,aAAa,GAAG7C,KAAK,CAACF,MAAM,CAACgD,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACH,OAAO,KAAKA,OAAO,CAAC;MACnE,IAAI,CAACC,aAAa,IAAI,CAAC/C,MAAM,CAAC8C,OAAO,CAAC,EAAE;QACpC,MAAM,IAAI3B,cAAW,CAAC,gCAAgC2B,OAAO,IAAI,CAAC;MACtE,CAAC,MAAM,IAAIC,aAAa,EAAE;QACtBD,OAAO,GAAGC,aAAa,CAACD,OAAO;MACnC;MAEA,MAAMJ,KAAK,GAAG1C,MAAM,CAAC8C,OAAO,CAAC;MAC7B,IAAI,CAACJ,KAAK,EAAE;QACR,MAAM,IAAIvB,cAAW,CAAC,sBAAsB2B,OAAO,IAAI,EAAE,sBAAsB,CAAC;MACpF;MACA,MAAMI,YAAY,GAAGhC,eAAe,CAACwB,KAAK,CAAC7B,IAAI,CAAC;MAEhDqC,YAAY,CAACC,IAAI,CAAC;QACd3C,cAAc;QACdU,eAAe;QACfS,GAAG;QACHC,KAAK;QACLgB,QAAQ;QACRF,KAAK;QACL1C,MAAM;QACNuB;MACJ,CAAC,CAAC;IACN;EACJ,CAAC;EAED,OAAOH,aAAa;AACxB,CAAC;AAACgC,OAAA,CAAAtD,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFilterPlugin","createDefaultFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","ALL","exec","params","applyFiltering","field","searchable","identifier","parents","map","p","fieldId","join","WebinyError","name","type","exports"],"sources":["defaultFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\n\nexport const createDefaultFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: CmsEntryFilterPlugin.ALL,\n exec: params => {\n const { applyFiltering, field } = params;\n if (!params.field.searchable) {\n const identifier = [...field.parents.map(p => p.fieldId), field.field.fieldId].join(\n \".\"\n );\n throw new WebinyError(`Field \"${identifier}\" is not searchable.`);\n }\n applyFiltering(params);\n }\n });\n\n plugin.name = `${plugin.type}.default.all`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AAEO,MAAME,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAED,0CAAoB,CAACE,GAAG;IACnCC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAc;QAAEC;MAAM,CAAC,GAAGF,MAAM;MACxC,IAAI,CAACA,MAAM,CAACE,KAAK,CAACC,UAAU,EAAE;QAC1B,MAAMC,UAAU,GAAG,CAAC,GAAGF,KAAK,CAACG,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAAEN,KAAK,CAACA,KAAK,CAACM,OAAO,CAAC,CAACC,IAAI,CAC/E,GACJ,CAAC;QACD,MAAM,IAAIC,cAAW,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFilterPlugin","createDefaultFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","ALL","exec","params","applyFiltering","field","searchable","identifier","parents","map","p","fieldId","join","WebinyError","name","type","exports"],"sources":["defaultFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\n\nexport const createDefaultFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: CmsEntryFilterPlugin.ALL,\n exec: params => {\n const { applyFiltering, field } = params;\n if (!params.field.searchable) {\n const identifier = [...field.parents.map(p => p.fieldId), field.field.fieldId].join(\n \".\"\n );\n throw new WebinyError(`Field \"${identifier}\" is not searchable.`);\n }\n applyFiltering(params);\n }\n });\n\n plugin.name = `${plugin.type}.default.all`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AAEO,MAAME,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAED,0CAAoB,CAACE,GAAG;IACnCC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAc;QAAEC;MAAM,CAAC,GAAGF,MAAM;MACxC,IAAI,CAACA,MAAM,CAACE,KAAK,CAACC,UAAU,EAAE;QAC1B,MAAMC,UAAU,GAAG,CAAC,GAAGF,KAAK,CAACG,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAAEN,KAAK,CAACA,KAAK,CAACM,OAAO,CAAC,CAACC,IAAI,CAC/E,GACJ,CAAC;QACD,MAAM,IAAIC,cAAW,CAAC,UAAUN,UAAU,sBAAsB,CAAC;MACrE;MACAH,cAAc,CAACD,MAAM,CAAC;IAC1B;EACJ,CAAC,CAAC;EAEFL,MAAM,CAACgB,IAAI,GAAG,GAAGhB,MAAM,CAACiB,IAAI,cAAc;EAE1C,OAAOjB,MAAM;AACjB,CAAC;AAACkB,OAAA,CAAAnB,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_CmsEntryFilterPlugin","require","_apiElasticsearch","_error","_interopRequireDefault","createObjectFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","value","where","fields","field","parentField","getFilterPlugin","query","key","undefined","whereFieldId","operator","parseWhereKey","identifier","parents","map","p","fieldId","join","WebinyError","Object","keys","type","name","exports"],"sources":["objectFilterPlugin.ts"],"sourcesContent":["import { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport WebinyError from \"@webiny/error\";\n\nexport const createObjectFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"object\",\n exec: params => {\n const {\n applyFiltering,\n value: where,\n fields,\n field: parentField,\n getFilterPlugin,\n query\n } = params;\n /**\n * Because this is an object field, we must construct filters based on the value property.\n * Value property is actually a where condition.\n */\n for (const key in where) {\n const value = where[key];\n if (value === undefined) {\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n const identifier = [\n ...parentField.parents.map(p => p.fieldId),\n parentField.field.fieldId,\n whereFieldId\n ].join(\".\");\n const field = fields[identifier];\n if (!field) {\n throw new WebinyError(\n `There is no field \"${identifier}\".`,\n \"OBJECT_FILTER_FIELD_ERROR\",\n {\n fields: Object.keys(fields)\n }\n );\n }\n /**\n * We need to find the filter plugin for the child field.\n * This will throw error if no plugin can be found.\n */\n const plugin = getFilterPlugin(field.type);\n /**\n * Basically this allows us to go into depth as much as we want with the object fields.\n */\n plugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n }\n });\n\n plugin.name = `${plugin.type}.default.object`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEO,MAAMI,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAE,QAAQ;IACnBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QACFC,cAAc;QACdC,KAAK,EAAEC,KAAK;QACZC,MAAM;QACNC,KAAK,EAAEC,WAAW;QAClBC,eAAe;QACfC;MACJ,CAAC,GAAGR,MAAM;MACV;AACZ;AACA;AACA;MACY,KAAK,MAAMS,GAAG,IAAIN,KAAK,EAAE;QACrB,MAAMD,KAAK,GAAGC,KAAK,CAACM,GAAG,CAAC;QACxB,IAAIP,KAAK,KAAKQ,SAAS,EAAE;UACrB;QACJ;QACA,MAAM;UAAEL,KAAK,EAAEM,YAAY;UAAEC;QAAS,CAAC,GAAG,IAAAC,+BAAa,EAACJ,GAAG,CAAC;QAE5D,MAAMK,UAAU,GAAG,CACf,GAAGR,WAAW,CAACS,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAC1CZ,WAAW,CAACD,KAAK,CAACa,OAAO,EACzBP,YAAY,CACf,CAACQ,IAAI,CAAC,GAAG,CAAC;QACX,MAAMd,KAAK,GAAGD,MAAM,CAACU,UAAU,CAAC;QAChC,IAAI,CAACT,KAAK,EAAE;UACR,MAAM,IAAIe,cAAW,
|
|
1
|
+
{"version":3,"names":["_CmsEntryFilterPlugin","require","_apiElasticsearch","_error","_interopRequireDefault","createObjectFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","value","where","fields","field","parentField","getFilterPlugin","query","key","undefined","whereFieldId","operator","parseWhereKey","identifier","parents","map","p","fieldId","join","WebinyError","Object","keys","type","name","exports"],"sources":["objectFilterPlugin.ts"],"sourcesContent":["import { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport WebinyError from \"@webiny/error\";\n\nexport const createObjectFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"object\",\n exec: params => {\n const {\n applyFiltering,\n value: where,\n fields,\n field: parentField,\n getFilterPlugin,\n query\n } = params;\n /**\n * Because this is an object field, we must construct filters based on the value property.\n * Value property is actually a where condition.\n */\n for (const key in where) {\n const value = where[key];\n if (value === undefined) {\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n const identifier = [\n ...parentField.parents.map(p => p.fieldId),\n parentField.field.fieldId,\n whereFieldId\n ].join(\".\");\n const field = fields[identifier];\n if (!field) {\n throw new WebinyError(\n `There is no field \"${identifier}\".`,\n \"OBJECT_FILTER_FIELD_ERROR\",\n {\n fields: Object.keys(fields)\n }\n );\n }\n /**\n * We need to find the filter plugin for the child field.\n * This will throw error if no plugin can be found.\n */\n const plugin = getFilterPlugin(field.type);\n /**\n * Basically this allows us to go into depth as much as we want with the object fields.\n */\n plugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n }\n });\n\n plugin.name = `${plugin.type}.default.object`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEO,MAAMI,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAE,QAAQ;IACnBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QACFC,cAAc;QACdC,KAAK,EAAEC,KAAK;QACZC,MAAM;QACNC,KAAK,EAAEC,WAAW;QAClBC,eAAe;QACfC;MACJ,CAAC,GAAGR,MAAM;MACV;AACZ;AACA;AACA;MACY,KAAK,MAAMS,GAAG,IAAIN,KAAK,EAAE;QACrB,MAAMD,KAAK,GAAGC,KAAK,CAACM,GAAG,CAAC;QACxB,IAAIP,KAAK,KAAKQ,SAAS,EAAE;UACrB;QACJ;QACA,MAAM;UAAEL,KAAK,EAAEM,YAAY;UAAEC;QAAS,CAAC,GAAG,IAAAC,+BAAa,EAACJ,GAAG,CAAC;QAE5D,MAAMK,UAAU,GAAG,CACf,GAAGR,WAAW,CAACS,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAC1CZ,WAAW,CAACD,KAAK,CAACa,OAAO,EACzBP,YAAY,CACf,CAACQ,IAAI,CAAC,GAAG,CAAC;QACX,MAAMd,KAAK,GAAGD,MAAM,CAACU,UAAU,CAAC;QAChC,IAAI,CAACT,KAAK,EAAE;UACR,MAAM,IAAIe,cAAW,CACjB,sBAAsBN,UAAU,IAAI,EACpC,2BAA2B,EAC3B;YACIV,MAAM,EAAEiB,MAAM,CAACC,IAAI,CAAClB,MAAM;UAC9B,CACJ,CAAC;QACL;QACA;AAChB;AACA;AACA;QACgB,MAAMR,MAAM,GAAGW,eAAe,CAACF,KAAK,CAACkB,IAAI,CAAC;QAC1C;AAChB;AACA;QACgB3B,MAAM,CAACG,IAAI,CAAC;UACRE,cAAc;UACdM,eAAe;UACfE,GAAG;UACHP,KAAK;UACLU,QAAQ;UACRP,KAAK;UACLD,MAAM;UACNI;QACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAEFZ,MAAM,CAAC4B,IAAI,GAAG,GAAG5B,MAAM,CAAC2B,IAAI,iBAAiB;EAE7C,OAAO3B,MAAM;AACjB,CAAC;AAAC6B,OAAA,CAAA9B,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFilterPlugin","_apiElasticsearch","createRefFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","query","field","values","value","WebinyError","undefined","entryId","key","operator","parseWhereKey","name","type","exports"],"sources":["refFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\n\nexport const createRefFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"ref\",\n exec: params => {\n const { applyFiltering, query, field } = params;\n\n let values = params.value;\n /**\n * We must have an object when querying in the ref field.\n */\n if (typeof values !== \"object\") {\n throw new WebinyError(\n `When querying by ref field, value of the field must be an object.`,\n \"OBJECT_REQUIRED\",\n {\n value: values\n }\n );\n }\n\n if (values === null || values === undefined) {\n values = {\n entryId: null\n };\n }\n\n for (const key in values) {\n const { operator } = parseWhereKey(key);\n const value = values[key];\n if (value === undefined) {\n continue;\n }\n\n applyFiltering({\n query,\n field,\n operator,\n key,\n value\n });\n }\n }\n });\n\n plugin.name = `${plugin.type}.default.ref`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,MAAMG,qBAAqB,GAAGA,CAAA,KAAM;EACvC,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAE,KAAK;IAChBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAc;QAAEC,KAAK;QAAEC;MAAM,CAAC,GAAGH,MAAM;MAE/C,IAAII,MAAM,GAAGJ,MAAM,CAACK,KAAK;MACzB;AACZ;AACA;MACY,IAAI,OAAOD,MAAM,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAIE,cAAW,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFilterPlugin","_apiElasticsearch","createRefFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","query","field","values","value","WebinyError","undefined","entryId","key","operator","parseWhereKey","name","type","exports"],"sources":["refFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\n\nexport const createRefFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"ref\",\n exec: params => {\n const { applyFiltering, query, field } = params;\n\n let values = params.value;\n /**\n * We must have an object when querying in the ref field.\n */\n if (typeof values !== \"object\") {\n throw new WebinyError(\n `When querying by ref field, value of the field must be an object.`,\n \"OBJECT_REQUIRED\",\n {\n value: values\n }\n );\n }\n\n if (values === null || values === undefined) {\n values = {\n entryId: null\n };\n }\n\n for (const key in values) {\n const { operator } = parseWhereKey(key);\n const value = values[key];\n if (value === undefined) {\n continue;\n }\n\n applyFiltering({\n query,\n field,\n operator,\n key,\n value\n });\n }\n }\n });\n\n plugin.name = `${plugin.type}.default.ref`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,MAAMG,qBAAqB,GAAGA,CAAA,KAAM;EACvC,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAE,KAAK;IAChBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAc;QAAEC,KAAK;QAAEC;MAAM,CAAC,GAAGH,MAAM;MAE/C,IAAII,MAAM,GAAGJ,MAAM,CAACK,KAAK;MACzB;AACZ;AACA;MACY,IAAI,OAAOD,MAAM,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAIE,cAAW,CACjB,mEAAmE,EACnE,iBAAiB,EACjB;UACID,KAAK,EAAED;QACX,CACJ,CAAC;MACL;MAEA,IAAIA,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKG,SAAS,EAAE;QACzCH,MAAM,GAAG;UACLI,OAAO,EAAE;QACb,CAAC;MACL;MAEA,KAAK,MAAMC,GAAG,IAAIL,MAAM,EAAE;QACtB,MAAM;UAAEM;QAAS,CAAC,GAAG,IAAAC,+BAAa,EAACF,GAAG,CAAC;QACvC,MAAMJ,KAAK,GAAGD,MAAM,CAACK,GAAG,CAAC;QACzB,IAAIJ,KAAK,KAAKE,SAAS,EAAE;UACrB;QACJ;QAEAN,cAAc,CAAC;UACXC,KAAK;UACLC,KAAK;UACLO,QAAQ;UACRD,GAAG;UACHJ;QACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAEFT,MAAM,CAACgB,IAAI,GAAG,GAAGhB,MAAM,CAACiB,IAAI,cAAc;EAE1C,OAAOjB,MAAM;AACjB,CAAC;AAACkB,OAAA,CAAAnB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","getWhereValues","value","condition","values","Array","isArray","WebinyError","length","exports"],"sources":["values.ts"],"sourcesContent":["import { CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getWhereValues = (value: unknown, condition: \"AND\" | \"OR\") => {\n const values = value as CmsEntryListWhere[] | undefined;\n if (!Array.isArray(values)) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is not an array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n } else if (values.length === 0) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is empty array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n }\n return values;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,cAAc,GAAGA,CAACC,KAAc,EAAEC,SAAuB,KAAK;EACvE,MAAMC,MAAM,GAAGF,KAAwC;EACvD,IAAI,CAACG,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IACxB,MAAM,IAAIG,cAAW,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","getWhereValues","value","condition","values","Array","isArray","WebinyError","length","exports"],"sources":["values.ts"],"sourcesContent":["import { CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getWhereValues = (value: unknown, condition: \"AND\" | \"OR\") => {\n const values = value as CmsEntryListWhere[] | undefined;\n if (!Array.isArray(values)) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is not an array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n } else if (values.length === 0) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is empty array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n }\n return values;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,cAAc,GAAGA,CAACC,KAAc,EAAEC,SAAuB,KAAK;EACvE,MAAMC,MAAM,GAAGF,KAAwC;EACvD,IAAI,CAACG,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IACxB,MAAM,IAAIG,cAAW,CACjB,iCAAiCJ,SAAS,wCAAwC,EAClF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL,CAAC,MAAM,IAAIE,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAID,cAAW,CACjB,iCAAiCJ,SAAS,uCAAuC,EACjF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL;EACA,OAAOE,MAAM;AACjB,CAAC;AAACK,OAAA,CAAAR,cAAA,GAAAA,cAAA","ignoreList":[]}
|