@webiny/api-headless-cms-ddb-es 0.0.0-unstable.c59b9cc5b9 → 0.0.0-unstable.c7dec08bb0

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.
@@ -76,6 +76,9 @@ const createEntryEntity = params => {
76
76
  status: {
77
77
  type: "string"
78
78
  },
79
+ location: {
80
+ type: "map"
81
+ },
79
82
  values: {
80
83
  type: "map"
81
84
  },
@@ -1 +1 @@
1
- {"version":3,"names":["createEntryEntity","params","table","entityName","attributes","Entity","name","PK","type","partitionKey","SK","sortKey","TYPE","__type","webinyVersion","tenant","entryId","id","createdBy","ownedBy","modifiedBy","createdOn","savedOn","modelId","locale","publishedOn","version","locked","status","values","meta"],"sources":["entry.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\nexport interface CreateEntryEntityParams {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\nexport const createEntryEntity = (params: CreateEntryEntityParams): Entity<any> => {\n const { table, entityName, attributes } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n type: \"string\",\n partitionKey: true\n },\n SK: {\n type: \"string\",\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n __type: {\n type: \"string\"\n },\n webinyVersion: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n entryId: {\n type: \"string\"\n },\n id: {\n type: \"string\"\n },\n createdBy: {\n type: \"map\"\n },\n ownedBy: {\n type: \"map\"\n },\n modifiedBy: {\n type: \"map\"\n },\n createdOn: {\n type: \"string\"\n },\n savedOn: {\n type: \"string\"\n },\n modelId: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n publishedOn: {\n type: \"string\"\n },\n version: {\n type: \"number\"\n },\n locked: {\n type: \"boolean\"\n },\n status: {\n type: \"string\"\n },\n values: {\n type: \"map\"\n },\n meta: {\n type: \"map\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":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I,EAAE;QACFtB,IAAI,EAAE;MACV;IAAC,GACGJ,UAAU,IAAI,CAAC,CAAC;EAE5B,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["createEntryEntity","params","table","entityName","attributes","Entity","name","PK","type","partitionKey","SK","sortKey","TYPE","__type","webinyVersion","tenant","entryId","id","createdBy","ownedBy","modifiedBy","createdOn","savedOn","modelId","locale","publishedOn","version","locked","status","location","values","meta"],"sources":["entry.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\nexport interface CreateEntryEntityParams {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\nexport const createEntryEntity = (params: CreateEntryEntityParams): Entity<any> => {\n const { table, entityName, attributes } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n type: \"string\",\n partitionKey: true\n },\n SK: {\n type: \"string\",\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n __type: {\n type: \"string\"\n },\n webinyVersion: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n entryId: {\n type: \"string\"\n },\n id: {\n type: \"string\"\n },\n createdBy: {\n type: \"map\"\n },\n ownedBy: {\n type: \"map\"\n },\n modifiedBy: {\n type: \"map\"\n },\n createdOn: {\n type: \"string\"\n },\n savedOn: {\n type: \"string\"\n },\n modelId: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n publishedOn: {\n type: \"string\"\n },\n version: {\n type: \"number\"\n },\n locked: {\n type: \"boolean\"\n },\n status: {\n type: \"string\"\n },\n location: {\n type: \"map\"\n },\n values: {\n type: \"map\"\n },\n meta: {\n type: \"map\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAQO,MAAMA,iBAAiB,GAAIC,MAA+B,IAAkB;EAC/E,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACd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16 +68,7 @@ const createDateStorageTransformPlugin = () => {
68
68
  return convertValueToStorage(field, v);
69
69
  });
70
70
  }
71
- if (value.toISOString) {
72
- return value.toISOString();
73
- } else if (typeof value === "string") {
74
- return value;
75
- }
76
- throw new _error.default("Error converting value to a storage type.", "TO_STORAGE_ERROR", {
77
- value,
78
- fieldId: field.fieldId,
79
- storageId: field.storageId
80
- });
71
+ return convertValueToStorage(field, value);
81
72
  }
82
73
  });
83
74
  plugin.name = `headless-cms.dynamodb.storageTransform.date`;
@@ -1 +1 @@
1
- {"version":3,"names":["excludeTypes","convertFromStorage","field","value","multipleValues","filter","v","map","Date","console","log","convertValueToStorage","toISOString","WebinyError","fieldId","storageId","createDateStorageTransformPlugin","plugin","StorageTransformPlugin","fieldType","fromStorage","type","settings","includes","toStorage","name"],"sources":["date.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\ntype PartialCmsModelField = Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"multipleValues\">;\n\nconst excludeTypes = [\"time\", \"dateTimeWithTimezone\"];\n\nconst convertFromStorage = (field: PartialCmsModelField, value: string | string[]) => {\n try {\n if (field.multipleValues) {\n return ((value as string[]) || [])\n .filter(v => !!v)\n .map((v: string) => {\n return new Date(v);\n });\n }\n return new Date(value as string);\n } catch {\n console.log(`Could not transform from storage for field type`);\n return value;\n }\n};\n\nconst convertValueToStorage = (field: PartialCmsModelField, value: any): any => {\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value: value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n};\n\nexport const createDateStorageTransformPlugin = () => {\n const plugin = new StorageTransformPlugin({\n fieldType: \"datetime\",\n fromStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n return convertFromStorage(field, value);\n },\n toStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n if (field.multipleValues) {\n const multipleValues = value as (string | Date | null | undefined)[];\n return (multipleValues || [])\n .filter(v => !!v)\n .map(v => {\n return convertValueToStorage(field, v);\n });\n }\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n }\n });\n plugin.name = `headless-cms.dynamodb.storageTransform.date`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAGA;AACA;AAJA;AACA;AACA;;AAOA,MAAMA,YAAY,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC;AAErD,MAAMC,kBAAkB,GAAG,CAACC,KAA2B,EAAEC,KAAwB,KAAK;EAClF,IAAI;IACA,IAAID,KAAK,CAACE,cAAc,EAAE;MACtB,OAAO,CAAED,KAAK,IAAiB,EAAE,EAC5BE,MAAM,CAACC,CAAC,IAAI,CAAC,CAACA,CAAC,CAAC,CAChBC,GAAG,CAAED,CAAS,IAAK;QAChB,OAAO,IAAIE,IAAI,CAACF,CAAC,CAAC;MACtB,CAAC,CAAC;IACV;IACA,OAAO,IAAIE,IAAI,CAACL,KAAK,CAAW;EACpC,CAAC,CAAC,MAAM;IACJM,OAAO,CAACC,GAAG,CAAE,iDAAgD,CAAC;IAC9D,OAAOP,KAAK;EAChB;AACJ,CAAC;AAED,MAAMQ,qBAAqB,GAAG,CAACT,KAA2B,EAAEC,KAAU,KAAU;EAC5E,IAAKA,KAAK,CAASS,WAAW,EAAE;IAC5B,OAAQT,KAAK,CAAUS,WAAW,EAAE;EACxC,CAAC,MAAM,IAAI,OAAOT,KAAK,KAAK,QAAQ,EAAE;IAClC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,CAAUS,WAAW,EAAE;MACxC,CAAC,MAAM,IAAI,OAAOT,KAAK,KAAK,QAAQ,EAAE;QAClC,OAAOA,KAAK;MAChB;MACA,MAAM,IAAIU,cAAW,CAAC,2CAA2C,EAAE,kBAAkB,EAAE;QACnFV,KAAK;QACLW,OAAO,EAAEZ,KAAK,CAACY,OAAO;QACtBC,SAAS,EAAEb,KAAK,CAACa;MACrB,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;EACFE,MAAM,CAACQ,IAAI,GAAI,6CAA4C;EAE3D,OAAOR,MAAM;AACjB,CAAC;AAAC"}
1
+ {"version":3,"names":["excludeTypes","convertFromStorage","field","value","multipleValues","filter","v","map","Date","console","log","convertValueToStorage","toISOString","WebinyError","fieldId","storageId","createDateStorageTransformPlugin","plugin","StorageTransformPlugin","fieldType","fromStorage","type","settings","includes","toStorage","name"],"sources":["date.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\ntype PartialCmsModelField = Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"multipleValues\">;\n\nconst excludeTypes = [\"time\", \"dateTimeWithTimezone\"];\n\nconst convertFromStorage = (field: PartialCmsModelField, value: string | string[]) => {\n try {\n if (field.multipleValues) {\n return ((value as string[]) || [])\n .filter(v => !!v)\n .map((v: string) => {\n return new Date(v);\n });\n }\n return new Date(value as string);\n } catch {\n console.log(`Could not transform from storage for field type`);\n return value;\n }\n};\n\nconst convertValueToStorage = (field: PartialCmsModelField, value: any): any => {\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value: value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n};\n\nexport const createDateStorageTransformPlugin = () => {\n const plugin = new StorageTransformPlugin({\n fieldType: \"datetime\",\n fromStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n return convertFromStorage(field, value);\n },\n toStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n if (field.multipleValues) {\n const multipleValues = value as (string | Date | null | undefined)[];\n return (multipleValues || [])\n .filter(v => !!v)\n .map(v => {\n return convertValueToStorage(field, v);\n });\n }\n return convertValueToStorage(field, value);\n }\n });\n plugin.name = `headless-cms.dynamodb.storageTransform.date`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAGA;AACA;AAJA;AACA;AACA;;AAOA,MAAMA,YAAY,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC;AAErD,MAAMC,kBAAkB,GAAG,CAACC,KAA2B,EAAEC,KAAwB,KAAK;EAClF,IAAI;IACA,IAAID,KAAK,CAACE,cAAc,EAAE;MACtB,OAAO,CAAED,KAAK,IAAiB,EAAE,EAC5BE,MAAM,CAACC,CAAC,IAAI,CAAC,CAACA,CAAC,CAAC,CAChBC,GAAG,CAAED,CAAS,IAAK;QAChB,OAAO,IAAIE,IAAI,CAACF,CAAC,CAAC;MACtB,CAAC,CAAC;IACV;IACA,OAAO,IAAIE,IAAI,CAACL,KAAK,CAAW;EACpC,CAAC,CAAC,MAAM;IACJM,OAAO,CAACC,GAAG,CAAE,iDAAgD,CAAC;IAC9D,OAAOP,KAAK;EAChB;AACJ,CAAC;AAED,MAAMQ,qBAAqB,GAAG,CAACT,KAA2B,EAAEC,KAAU,KAAU;EAC5E,IAAKA,KAAK,CAASS,WAAW,EAAE;IAC5B,OAAQT,KAAK,CAAUS,WAAW,EAAE;EACxC,CAAC,MAAM,IAAI,OAAOT,KAAK,KAAK,QAAQ,EAAE;IAClC,OAAOA,KAAK;EAChB;EACA,MAAM,IAAIU,cAAW,CAAC,2CAA2C,EAAE,kBAAkB,EAAE;IACnFV,KAAK,EAAEA,KAAK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 -68,11 +68,6 @@ const createRichTextStorageTransformPlugin = () => {
68
68
  try {
69
69
  return _jsonpack.default.unpack(value);
70
70
  } catch (ex) {
71
- if (process.env.DEBUG !== "true") {
72
- return null;
73
- }
74
- console.log("Error while decompressing rich-text.");
75
- console.log(ex.message);
76
71
  return null;
77
72
  }
78
73
  },
@@ -1 +1 @@
1
- {"version":3,"names":["transformArray","value","isArray","Array","shouldBeArray","from","k","createRichTextStorageTransformPlugin","plugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","WebinyError","storageId","compression","jsonpack","unpack","ex","process","env","DEBUG","console","log","message","toStorage","jsonValue","pack","name"],"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 as any);\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 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 if (process.env.DEBUG !== \"true\") {\n return null;\n }\n console.log(\"Error while decompressing rich-text.\");\n console.log(ex.message);\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 as any;\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;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,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,CAAQ;IAChCC,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;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GAAGD,cAAc,CAACC,KAAK,CAAC;MAE7B,IAAI0B,SAAwB,GAAG,IAAI;MACnC,IAAI;QACAA,SAAS,GAAGV,iBAAQ,CAACW,IAAI,CAAC3B,KAAK,CAAC;MACpC,CAAC,CAAC,OAAOkB,EAAE,EAAE;QACT,IAAIC,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,MAAM,EAAE;UAC9B,OAAO,IAAI;QACf;QACAC,OAAO,CAACC,GAAG,CAAC,oCAAoC,CAAC;QACjDD,OAAO,CAACC,GAAG,CAACL,EAAE,CAACM,OAAO,CAAC;MAC3B;MACA,OAAO;QACHT,WAAW,EAAE,UAAU;QACvBf,KAAK,EAAE0B;MACX,CAAC;IACL;EACJ,CAAC,CAAC;EACFnB,MAAM,CAACqB,IAAI,GAAI,kDAAiD;EAEhE,OAAOrB,MAAM;AACjB,CAAC;AAAC"}
1
+ {"version":3,"names":["transformArray","value","isArray","Array","shouldBeArray","from","k","createRichTextStorageTransformPlugin","plugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","WebinyError","storageId","compression","jsonpack","unpack","ex","toStorage","jsonValue","pack","process","env","DEBUG","console","log","message","name"],"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 as any);\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 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 as any;\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;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,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,I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,mCAAL,OAAOe,WAAW,GAAE;QACtB,OAAOf,KAAK;MAChB;MACAA,KAAK,GAAGD,cAAc,CAACC,KAAK,CAAC;MAE7B,IAAIoB,SAAwB,GAAG,IAAI;MACnC,IAAI;QACAA,SAAS,GAAGJ,iBAAQ,CAACK,IAAI,CAACrB,KAAK,CAAC;MACpC,CAAC,CAAC,OAAOkB,EAAE,EAAE;QACT,IAAII,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,MAAM,EAAE;UAC9B,OAAO,IAAI;QACf;QACAC,OAAO,CAACC,GAAG,CAAC,oCAAoC,CAAC;QACjDD,OAAO,CAACC,GAAG,CAACR,EAAE,CAACS,OAAO,CAAC;MAC3B;MACA,OAAO;QACHZ,WAAW,EAAE,UAAU;QACvBf,KAAK,EAAEoB;MACX,CAAC;IACL;EACJ,CAAC,CAAC;EACFb,MAAM,CAACqB,IAAI,GAAI,kDAAiD;EAEhE,OAAOrB,MAAM;AACjB,CAAC;AAAC"}
@@ -27,7 +27,8 @@ const convertNumberToTime = value => {
27
27
  return [hours, minutes, seconds].map(v => String(v).padStart(2, "0")).join(":");
28
28
  };
29
29
  const convertValueFromIndex = (value, field) => {
30
- const type = field.settings.type;
30
+ var _field$settings;
31
+ const type = (_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.type;
31
32
  if (type === "time") {
32
33
  return convertNumberToTime(value);
33
34
  } else if (!value) {
@@ -41,9 +42,10 @@ const convertValueFromIndex = (value, field) => {
41
42
  return new Date(value).toISOString();
42
43
  };
43
44
  const convertValueToIndex = (value, field) => {
45
+ var _field$settings2;
44
46
  if (!value) {
45
47
  return null;
46
- } else if (field.settings.type === "time") {
48
+ } else if (((_field$settings2 = field.settings) === null || _field$settings2 === void 0 ? void 0 : _field$settings2.type) === "time") {
47
49
  return convertTimeToNumber(value);
48
50
  }
49
51
  return value;
@@ -1 +1 @@
1
- {"version":3,"names":["convertTimeToNumber","time","hours","minutes","seconds","split","map","Number","convertNumberToTime","value","undefined","String","match","Math","floor","v","padStart","join","convertValueFromIndex","field","type","settings","dateValue","Date","toISOString","slice","convertValueToIndex","name","fieldType","unmappedType","toIndex","Array","isArray","fromIndex"],"sources":["dateTimeIndexing.ts"],"sourcesContent":["import { CmsModelDateTimeField } from \"@webiny/api-headless-cms/types\";\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\nconst convertTimeToNumber = (time?: string): number | null => {\n if (!time) {\n return null;\n }\n const [hours, minutes, seconds = 0] = time.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n};\n\nconst convertNumberToTime = (value?: number): string | null => {\n if (value === undefined || value === null) {\n return null;\n }\n // TODO remove when v5 goes out\n // this is a fix for pre beta.5\n if (String(value).match(/^([0-9]{2}):([0-9]{2})/) !== null) {\n return String(value);\n }\n //\n const hours = Math.floor(value / 60 / 60);\n\n const minutes = Math.floor((value - hours * 60 * 60) / 60);\n\n const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);\n\n return [hours, minutes, seconds].map(v => String(v).padStart(2, \"0\")).join(\":\");\n};\n\nconst convertValueFromIndex = (\n value: string | number,\n field: CmsModelDateTimeField\n): string | null => {\n const type = field.settings.type;\n if (type === \"time\") {\n return convertNumberToTime(value as number);\n } else if (!value) {\n return null;\n } else if (type === \"dateTimeWithTimezone\") {\n return value as string;\n } else if (type === \"date\") {\n const dateValue = new Date(value);\n return dateValue.toISOString().slice(0, 10);\n }\n return new Date(value).toISOString();\n};\n\nconst convertValueToIndex = (value: string, field: CmsModelDateTimeField) => {\n if (!value) {\n return null;\n } else if (field.settings.type === \"time\") {\n return convertTimeToNumber(value);\n }\n return value;\n};\n\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-datetime\",\n fieldType: \"datetime\",\n unmappedType: () => {\n return \"date\";\n },\n toIndex({ field, value }) {\n if (Array.isArray(value) === true) {\n return {\n value: value.map((v: string) => {\n return convertValueToIndex(v, field as CmsModelDateTimeField);\n })\n };\n }\n const dateValue = convertValueToIndex(value, field as CmsModelDateTimeField);\n return {\n value: dateValue\n };\n },\n fromIndex({ field, value }) {\n if (Array.isArray(value)) {\n return value.map((v: string) => {\n return convertValueFromIndex(v, field as CmsModelDateTimeField);\n });\n }\n return convertValueFromIndex(value, field as CmsModelDateTimeField);\n }\n});\n"],"mappings":";;;;;;AAGA,MAAMA,mBAAmB,GAAIC,IAAa,IAAoB;EAC1D,IAAI,CAACA,IAAI,EAAE;IACP,OAAO,IAAI;EACf;EACA,MAAM,CAACC,KAAK,EAAEC,OAAO,EAAEC,OAAO,GAAG,CAAC,CAAC,GAAGH,IAAI,CAACI,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;EACjE,OAAOL,KAAK,GAAG,EAAE,GAAG,EAAE,GAAGC,OAAO,GAAG,EAAE,GAAGC,OAAO;AACnD,CAAC;AAED,MAAMI,mBAAmB,GAAIC,KAAc,IAAoB;EAC3D,IAAIA,KAAK,KAAKC,SAAS,IAAID,KAAK,KAAK,IAAI,EAAE;IACvC,OAAO,IAAI;EACf;EACA;EACA;EACA,IAAIE,MAAM,CAACF,KAAK,CAAC,CAACG,KAAK,CAAC,wBAAwB,CAAC,KAAK,IAAI,EAAE;IACxD,OAAOD,MAAM,CAACF,KAAK,CAAC;EACxB;EACA;EACA,MAAMP,KAAK,GAAGW,IAAI,CAACC,KAAK,CAACL,KAAK,GAAG,EAAE,GAAG,EAAE,CAAC;EAEzC,MAAMN,OAAO,GAAGU,IAAI,CAACC,KAAK,CAAC,CAACL,KAAK,GAAGP,KAAK,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;EAE1D,MAAME,OAAO,GAAGS,IAAI,CAACC,KAAK,CAACL,KAAK,GAAGP,KAAK,GAAG,EAAE,GAAG,EAAE,GAAGC,OAAO,GAAG,EAAE,CAAC;EAElE,OAAO,CAACD,KAAK,EAAEC,OAAO,EAAEC,OAAO,CAA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AACC,OAAO,CAACvB,KAAK,CAAC,KAAK,IAAI,EAAE;MAC/B,OAAO;QACHA,KAAK,EAAEA,KAAK,CAACH,GAAG,CAAES,CAAS,IAAK;UAC5B,OAAOW,mBAAmB,CAACX,CAAC,EAAEI,KAAK,CAA0B;QACjE,CAAC;MACL,CAAC;IACL;IACA,MAAMG,SAAS,GAAGI,mBAAmB,CAACjB,KAAK,EAAEU,KAAK,CAA0B;IAC5E,OAAO;MACHV,KAAK,EAAEa;IACX,CAAC;EACL,CAAC;EACDW,SAAS,CAAC;IAAEd,KAAK;IAAEV;EAAM,CAAC,EAAE;IACxB,IAAIsB,KAAK,CAACC,OAAO,CAACvB,KAAK,CAAC,EAAE;MACtB,OAAOA,KAAK,CAACH,GAAG,CAAES,CAAS,IAAK;QAC5B,OAAOG,qBAAqB,CAACH,CAAC,EAAEI,KAAK,CAA0B;MACnE,CAAC,CAAC;IACN;IACA,OAAOD,qBAAqB,CAACT,KAAK,EAAEU,KAAK,CAA0B;EACvE;AACJ,CAAC,CAAC;AAAA"}
1
+ {"version":3,"names":["convertTimeToNumber","time","hours","minutes","seconds","split","map","Number","convertNumberToTime","value","undefined","String","match","Math","floor","v","padStart","join","convertValueFromIndex","field","type","settings","dateValue","Date","toISOString","slice","convertValueToIndex","name","fieldType","unmappedType","toIndex","Array","isArray","fromIndex"],"sources":["dateTimeIndexing.ts"],"sourcesContent":["import { CmsModelDateTimeField } from \"@webiny/api-headless-cms/types\";\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\nconst convertTimeToNumber = (time?: string): number | null => {\n if (!time) {\n return null;\n }\n const [hours, minutes, seconds = 0] = time.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n};\n\nconst convertNumberToTime = (value?: number): string | null => {\n if (value === undefined || value === null) {\n return null;\n }\n // TODO remove when v5 goes out\n // this is a fix for pre beta.5\n if (String(value).match(/^([0-9]{2}):([0-9]{2})/) !== null) {\n return String(value);\n }\n //\n const hours = Math.floor(value / 60 / 60);\n\n const minutes = Math.floor((value - hours * 60 * 60) / 60);\n\n const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);\n\n return [hours, minutes, seconds].map(v => String(v).padStart(2, \"0\")).join(\":\");\n};\n\nconst convertValueFromIndex = (\n value: string | number,\n field: CmsModelDateTimeField\n): string | null => {\n const type = field.settings?.type;\n if (type === \"time\") {\n return convertNumberToTime(value as number);\n } else if (!value) {\n return null;\n } else if (type === \"dateTimeWithTimezone\") {\n return value as string;\n } else if (type === \"date\") {\n const dateValue = new Date(value);\n return dateValue.toISOString().slice(0, 10);\n }\n return new Date(value).toISOString();\n};\n\nconst convertValueToIndex = (value: string, field: CmsModelDateTimeField) => {\n if (!value) {\n return null;\n } else if (field.settings?.type === \"time\") {\n return convertTimeToNumber(value);\n }\n return value;\n};\n\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-datetime\",\n fieldType: \"datetime\",\n unmappedType: () => {\n return \"date\";\n },\n toIndex({ field, value }) {\n if (Array.isArray(value) === true) {\n return {\n value: value.map((v: string) => {\n return convertValueToIndex(v, field as CmsModelDateTimeField);\n })\n };\n }\n const dateValue = convertValueToIndex(value, field as CmsModelDateTimeField);\n return {\n value: dateValue\n };\n },\n fromIndex({ field, value }) {\n if (Array.isArray(value)) {\n return value.map((v: string) => {\n return convertValueFromIndex(v, field as CmsModelDateTimeField);\n });\n }\n return convertValueFromIndex(value, field as CmsModelDateTimeField);\n }\n});\n"],"mappings":";;;;;;AAGA,MAAMA,mBAAmB,GAAIC,IAAa,IAAoB;EAC1D,IAAI,CAACA,IAAI,EAAE;IACP,OAAO,IAAI;EACf;EACA,MAAM,CAACC,KAAK,EAAEC,OAAO,EAAEC,OAAO,GAAG,CAAC,CAAC,GAAGH,IAAI,CAACI,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;EACjE,OAAOL,KAAK,GAAG,EAA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AES,CAAS,IAAK;QAC5B,OAAOG,qBAAqB,CAACH,CAAC,EAAEI,KAAK,CAA0B;MACnE,CAAC,CAAC;IACN;IACA,OAAOD,qBAAqB,CAACT,KAAK,EAAEU,KAAK,CAA0B;EACvE;AACJ,CAAC,CAAC;AAAA"}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getFieldIdentifiers = exports.getFieldIdentifier = void 0;
7
- const hasOwnProperty = (values, property) => {
7
+ const hasOwnProperty = (values = {}, property) => {
8
8
  if (values.hasOwnProperty) {
9
9
  return values.hasOwnProperty(property);
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"names":["hasOwnProperty","values","property","undefined","getFieldIdentifier","field","storageId","fieldId","getFieldIdentifiers","rawValues","valueIdentifier","rawValueIdentifier"],"sources":["fieldIdentifier.ts"],"sourcesContent":["import { CmsEntryValues, CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nconst hasOwnProperty = (values: CmsEntryValues, property: string): boolean => {\n if (values.hasOwnProperty) {\n return values.hasOwnProperty(property);\n }\n return values[property] !== undefined;\n};\n\nexport const getFieldIdentifier = (\n values: CmsEntryValues,\n field: CmsModelField\n): string | undefined => {\n if (field.storageId && hasOwnProperty(values, field.storageId)) {\n return field.storageId;\n } else if (hasOwnProperty(values, field.fieldId)) {\n return field.fieldId;\n }\n return undefined;\n};\n\nexport const getFieldIdentifiers = (\n values: CmsEntryValues,\n rawValues: CmsEntryValues,\n field: CmsModelField\n) => {\n let valueIdentifier = getFieldIdentifier(values, field);\n let rawValueIdentifier = getFieldIdentifier(rawValues, field);\n if (!valueIdentifier && !rawValueIdentifier) {\n return null;\n }\n if (!valueIdentifier) {\n valueIdentifier = rawValueIdentifier as string;\n }\n if (!rawValueIdentifier) {\n rawValueIdentifier = valueIdentifier as string;\n }\n return {\n valueIdentifier,\n rawValueIdentifier\n };\n};\n"],"mappings":";;;;;;AAEA,MAAMA,cAAc,GAAG,CAACC,MAAsB,EAAEC,QAAgB,KAAc;EAC1E,IAAID,MAAM,CAACD,cAAc,EAAE;IACvB,OAAOC,MAAM,CAACD,cAAc,CAACE,QAAQ,CAAC;EAC1C;EACA,OAAOD,MAAM,CAACC,QAAQ,CAAC,KAAKC,SAAS;AACzC,CAAC;AAEM,MAAMC,kBAAkB,GAAG,CAC9BH,MAAsB,EACtBI,KAAoB,KACC;EACrB,IAAIA,KAAK,CAACC,SAAS,IAAIN,cAAc,CAACC,MAAM,EAAEI,KAAK,CAACC,SAAS,CAAC,EAAE;IAC5D,OAAOD,KAAK,CAACC,SAAS;EAC1B,CAAC,MAAM,IAAIN,cAAc,CAACC,MAAM,EAAEI,KAAK,CAACE,OAAO,CAAC,EAAE;IAC9C,OAAOF,KAAK,CAACE,OAAO;EACxB;EACA,OAAOJ,SAAS;AACpB,CAAC;AAAC;AAEK,MAAMK,mBAAmB,GAAG,CAC/BP,MAAsB,EACtBQ,SAAyB,EACzBJ,KAAoB,KACnB;EACD,IAAIK,eAAe,GAAGN,kBAAkB,CAACH,MAAM,EAAEI,KAAK,CAAC;EACvD,IAAIM,kBAAkB,GAAGP,kBAAkB,CAACK,SAAS,EAAEJ,KAAK,CAAC;EAC7D,IAAI,CAACK,eAAe,IAAI,CAACC,kBAAkB,EAAE;IACzC,OAAO,IAAI;EACf;EACA,IAAI,CAACD,eAAe,EAAE;IAClBA,eAAe,GAAGC,kBAA4B;EAClD;EACA,IAAI,CAACA,kBAAkB,EAAE;IACrBA,kBAAkB,GAAGD,eAAyB;EAClD;EACA,OAAO;IACHA,eAAe;IACfC;EACJ,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["hasOwnProperty","values","property","undefined","getFieldIdentifier","field","storageId","fieldId","getFieldIdentifiers","rawValues","valueIdentifier","rawValueIdentifier"],"sources":["fieldIdentifier.ts"],"sourcesContent":["import { CmsEntryValues, CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nconst hasOwnProperty = (values: CmsEntryValues = {}, property: string): boolean => {\n if (values.hasOwnProperty) {\n return values.hasOwnProperty(property);\n }\n return values[property] !== undefined;\n};\n\nexport const getFieldIdentifier = (\n values: CmsEntryValues,\n field: CmsModelField\n): string | undefined => {\n if (field.storageId && hasOwnProperty(values, field.storageId)) {\n return field.storageId;\n } else if (hasOwnProperty(values, field.fieldId)) {\n return field.fieldId;\n }\n return undefined;\n};\n\nexport const getFieldIdentifiers = (\n values: CmsEntryValues,\n rawValues: CmsEntryValues,\n field: CmsModelField\n) => {\n let valueIdentifier = getFieldIdentifier(values, field);\n let rawValueIdentifier = getFieldIdentifier(rawValues, field);\n if (!valueIdentifier && !rawValueIdentifier) {\n return null;\n }\n if (!valueIdentifier) {\n valueIdentifier = rawValueIdentifier as string;\n }\n if (!rawValueIdentifier) {\n rawValueIdentifier = valueIdentifier as string;\n }\n return {\n valueIdentifier,\n rawValueIdentifier\n };\n};\n"],"mappings":";;;;;;AAEA,MAAMA,cAAc,GAAG,CAACC,MAAsB,GAAG,CAAC,CAAC,EAAEC,QAAgB,KAAc;EAC/E,IAAID,MAAM,CAACD,cAAc,EAAE;IACvB,OAAOC,MAAM,CAACD,cAAc,CAACE,QAAQ,CAAC;EAC1C;EACA,OAAOD,MAAM,CAACC,QAAQ,CAAC,KAAKC,SAAS;AACzC,CAAC;AAEM,MAAMC,kBAAkB,GAAG,CAC9BH,MAAsB,EACtBI,KAAoB,KACC;EACrB,IAAIA,KAAK,CAACC,SAAS,IAAIN,cAAc,CAACC,MAAM,EAAEI,KAAK,CAACC,SAAS,CAAC,EAAE;IAC5D,OAAOD,KAAK,CAACC,SAAS;EAC1B,CAAC,MAAM,IAAIN,cAAc,CAACC,MAAM,EAAEI,KAAK,CAACE,OAAO,CAAC,EAAE;IAC9C,OAAOF,KAAK,CAACE,OAAO;EACxB;EACA,OAAOJ,SAAS;AACpB,CAAC;AAAC;AAEK,MAAMK,mBAAmB,GAAG,CAC/BP,MAAsB,EACtBQ,SAAyB,EACzBJ,KAAoB,KACnB;EACD,IAAIK,eAAe,GAAGN,kBAAkB,CAACH,MAAM,EAAEI,KAAK,CAAC;EACvD,IAAIM,kBAAkB,GAAGP,kBAAkB,CAACK,SAAS,EAAEJ,KAAK,CAAC;EAC7D,IAAI,CAACK,eAAe,IAAI,CAACC,kBAAkB,EAAE;IACzC,OAAO,IAAI;EACf;EACA,IAAI,CAACD,eAAe,EAAE;IAClBA,eAAe,GAAGC,kBAA4B;EAClD;EACA,IAAI,CAACA,kBAAkB,EAAE;IACrBA,kBAAkB,GAAGD,eAAyB;EAClD;EACA,OAAO;IACHA,eAAe;IACfC;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -102,6 +102,45 @@ const createSystemFields = () => {
102
102
  }),
103
103
  parents: []
104
104
  },
105
+ wbyAco_location: {
106
+ type: "object",
107
+ systemField: true,
108
+ searchable: true,
109
+ sortable: true,
110
+ field: createSystemField({
111
+ storageId: "location",
112
+ fieldId: "wbyAco_location",
113
+ type: "object",
114
+ settings: {
115
+ fields: [{
116
+ id: "folderId",
117
+ fieldId: "folderId",
118
+ storageId: "folderId",
119
+ type: "text",
120
+ label: "Folder ID"
121
+ }]
122
+ }
123
+ }),
124
+ parents: []
125
+ },
126
+ "wbyAco_location.folderId": {
127
+ type: "text",
128
+ systemField: true,
129
+ searchable: true,
130
+ sortable: true,
131
+ field: createSystemField({
132
+ id: "folderId",
133
+ fieldId: "folderId",
134
+ storageId: "folderId",
135
+ type: "text",
136
+ label: "Folder ID"
137
+ }),
138
+ parents: [{
139
+ fieldId: "wbyAco_location",
140
+ type: "object",
141
+ storageId: "location"
142
+ }]
143
+ },
105
144
  version: {
106
145
  type: "number",
107
146
  unmappedType: undefined,
@@ -1 +1 @@
1
- {"version":3,"names":["createSystemField","field","id","fieldId","label","createSystemFields","type","systemField","searchable","sortable","storageId","parents","entryId","savedOn","unmappedType","keyword","settings","createdOn","createdBy","undefined","path","ownedBy","version","status","buildCustomFields","params","fields","fieldTypePlugins","reduce","collection","typePlugin","fieldType","fullTextSearch","buildFieldsList","plugins","result","plugin","WebinyError","childFields","length","childResult","Object","assign","identifier","map","p","join","createModelFields","model","fieldDefinitionPlugins","byType","CmsElasticsearchModelFieldPlugin","filter","canBeApplied","modelId","unmappedTypes","acc","types","isSearchable","isSortable"],"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\";\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 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 savedOn: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"savedOn\",\n fieldId: \"savedOn\",\n type: \"datetime\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n }),\n parents: []\n },\n createdOn: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"createdOn\",\n fieldId: \"createdOn\",\n type: \"text\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n }),\n parents: []\n },\n createdBy: {\n type: \"text\",\n unmappedType: undefined,\n systemField: true,\n searchable: true,\n sortable: false,\n path: \"createdBy.id\",\n field: createSystemField({\n storageId: \"createdBy\",\n fieldId: \"createdBy\",\n type: \"text\"\n }),\n parents: []\n },\n ownedBy: {\n type: \"text\",\n unmappedType: undefined,\n systemField: true,\n searchable: true,\n sortable: false,\n path: \"ownedBy.id\",\n field: createSystemField({\n storageId: \"ownedBy\",\n fieldId: \"ownedBy\",\n type: \"text\"\n }),\n parents: []\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 };\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;AASA;AAIA,MAAMA,iBAAiB,GAAIC,KAA2B,IAAoB;EACtE,mEACOA,KAAK;IACRC,EAAE,EAAED,KAAK,CAACE,OAAO;IACjBC,KAAK,EAAEH,KAAK,CAACE;EAAO;AAE5B,CAAC;AAED,MAAME,kBAAkB,GAAG,MAAmB;EAC1C,OAAO;IACHH,EAAE,EAAE;MACAI,IAAI,EAAE,MAAM;MACZC,WAAW,EAAE,IAAI;MACjBC,UAAU,EAAE,IAAI;MAChBC,QAAQ,EAAE,IAAI;MACdR,KAAK,EAAED,iBAAiB,CAAC;QACrBU,SAAS,EAAE,IAAI;QACfP,OAAO,EAAE,IAAI;QACbG,IAAI,EAAE;MACV,CAAC,CAAC;MACFK,OAAO,EAAE;IACb,CAAC;IACDC,OAAO,EAAE;MACLN,IAAI,EAAE,MAAM;MACZC,WAAW,EAAE,IAAI;MACjBC,UAAU,EAAE,IAAI;MAChBC,QAAQ,EAAE,IAAI;MACdR,KAAK,EAAED,iBAAiB,CAAC;QACrBU,SAAS,EAAE,SAAS;QACpBP,OAAO,EAAE,SAAS;QAClBG,IAAI,EAAE;MACV,CAAC,CAAC;MACFK,OAAO,EAAE;IACb,CAAC;IACDE,OAAO,EAAE;MACLP,IAAI,EAAE,MAAM;MACZQ,YAAY,EAAE,MAAM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B,CAAC4B,GAAG,EAAEpB,MAAM,KAAK;IACzC,IAAI,CAACA,MAAM,CAACtB,YAAY,EAAE;MACtB,OAAO0C,GAAG;IACd;IACAA,GAAG,CAACpB,MAAM,CAACL,SAAS,CAAC,GAAGK,MAAM,CAACtB,YAAY;IAC3C,OAAO0C,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC;EACV;AACJ;AACA;EACI,MAAM7B,gBAAgB,GAAGO,OAAO,CAC3BgB,MAAM,CAA+B,4BAA4B,CAAC,CAClEtB,MAAM,CAAmB,CAAC6B,KAAK,EAAErB,MAAM,KAAK;IACzC,MAAM;MAAEL,SAAS;MAAEC;IAAe,CAAC,GAAGI,MAAM;IAC5CqB,KAAK,CAAC1B,SAAS,CAAC,GAAG;MACfjB,YAAY,EAAEyC,aAAa,CAACxB,SAAS,CAAC;MACtCvB,UAAU,EAAE4B,MAAM,CAACsB,YAAY;MAC/BjD,QAAQ,EAAE2B,MAAM,CAACuB,UAAU;MAC3B3B;IACJ,CAAC;IACD,OAAOyB,KAAK;EAChB,CAAC,EAAE,CAAC,CAAC,CAAC;EAEV,+FACOpD,kBAAkB,EAAE,GACpBmB,iBAAiB,CAAC;IACjBE,MAAM,EAAEuB,sBAAsB;IAC9BtB;EACJ,CAAC,CAAC,GACCM,eAAe,CAAC;IACfP,MAAM;IACNQ,OAAO,EAAEP,gBAAgB;IACzBhB,OAAO,EAAE;EACb,CAAC,CAAC;AAEV,CAAC;AAAC"}
1
+ {"version":3,"names":["createSystemField","field","id","fieldId","label","createSystemFields","type","systemField","searchable","sortable","storageId","parents","entryId","savedOn","unmappedType","keyword","settings","createdOn","createdBy","undefined","path","ownedBy","wbyAco_location","fields","version","status","buildCustomFields","params","fieldTypePlugins","reduce","collection","typePlugin","fieldType","fullTextSearch","buildFieldsList","plugins","result","plugin","WebinyError","childFields","length","childResult","Object","assign","identifier","map","p","join","createModelFields","model","fieldDefinitionPlugins","byType","CmsElasticsearchModelFieldPlugin","filter","canBeApplied","modelId","unmappedTypes","acc","types","isSearchable","isSortable"],"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\";\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 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 savedOn: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"savedOn\",\n fieldId: \"savedOn\",\n type: \"datetime\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n }),\n parents: []\n },\n createdOn: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"createdOn\",\n fieldId: \"createdOn\",\n type: \"text\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n }),\n parents: []\n },\n createdBy: {\n type: \"text\",\n unmappedType: undefined,\n systemField: true,\n searchable: true,\n sortable: false,\n path: \"createdBy.id\",\n field: createSystemField({\n storageId: \"createdBy\",\n fieldId: \"createdBy\",\n type: \"text\"\n }),\n parents: []\n },\n ownedBy: {\n type: \"text\",\n unmappedType: undefined,\n systemField: true,\n searchable: true,\n sortable: false,\n path: \"ownedBy.id\",\n field: createSystemField({\n storageId: \"ownedBy\",\n fieldId: \"ownedBy\",\n type: \"text\"\n }),\n parents: []\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 };\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;AASA;AAIA,MAAMA,iBAAiB,GAAIC,KAA2B,IAAoB;EACtE,mEACOA,KAAK;IACRC,EAAE,EAAED,KAAK,CAACE,OAAO;IACjBC,KAAK,EAAEH,KAAK,CAACE;EAAO;AAE5B,CAAC;AAED,MAAME,kBAAkB,GAAG,MAAmB;EAC1C,OAAO;IACHH,EAAE,EAAE;MACAI,IAAI,EAAE,MAAM;MACZC,WAAW,EAAE,IAAI;MACjBC,UAAU,EAAE,IAAI;MAChBC,QAAQ,EAAE,IAAI;MACdR,KAAK,EAAED,iBAAiB,CAAC;QACrBU,SAAS,EAAE,IAAI;QACfP,OAAO,EAAE,IAAI;QACbG,IAAI,EAAE;MACV,CAAC,CAAC;MACFK,OAAO,EAAE;IACb,CAAC;IACDC,OAAO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AM,KAAK;IACzC,IAAI,CAACA,MAAM,CAACvB,YAAY,EAAE;MACtB,OAAO2C,GAAG;IACd;IACAA,GAAG,CAACpB,MAAM,CAACL,SAAS,CAAC,GAAGK,MAAM,CAACvB,YAAY;IAC3C,OAAO2C,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC;EACV;AACJ;AACA;EACI,MAAM7B,gBAAgB,GAAGO,OAAO,CAC3BgB,MAAM,CAA+B,4BAA4B,CAAC,CAClEtB,MAAM,CAAmB,CAAC6B,KAAK,EAAErB,MAAM,KAAK;IACzC,MAAM;MAAEL,SAAS;MAAEC;IAAe,CAAC,GAAGI,MAAM;IAC5CqB,KAAK,CAAC1B,SAAS,CAAC,GAAG;MACflB,YAAY,EAAE0C,aAAa,CAACxB,SAAS,CAAC;MACtCxB,UAAU,EAAE6B,MAAM,CAACsB,YAAY;MAC/BlD,QAAQ,EAAE4B,MAAM,CAACuB,UAAU;MAC3B3B;IACJ,CAAC;IACD,OAAOyB,KAAK;EAChB,CAAC,EAAE,CAAC,CAAC,CAAC;EAEV,+FACOrD,kBAAkB,EAAE,GACpBqB,iBAAiB,CAAC;IACjBH,MAAM,EAAE2B,sBAAsB;IAC9BtB;EACJ,CAAC,CAAC,GACCM,eAAe,CAAC;IACfX,MAAM;IACNY,OAAO,EAAEP,gBAAgB;IACzBjB,OAAO,EAAE;EACb,CAAC,CAAC;AAEV,CAAC;AAAC"}
@@ -152,7 +152,7 @@ const createExecFiltering = params => {
152
152
  }
153
153
  const field = fields[fieldId];
154
154
  if (!field) {
155
- throw new _error.default(`There is no field "${fieldId}".`);
155
+ throw new _error.default(`There is no field "${fieldId}".`, "EXEC_FILTERING_ERROR");
156
156
  }
157
157
  const filterPlugin = getFilterPlugin(field.type);
158
158
  filterPlugin.exec({
@@ -1 +1 @@
1
- {"version":3,"names":["createExecFiltering","params","fields","plugins","model","searchPlugins","createSearchPluginList","operatorPlugins","createOperatorPluginList","locale","applyFiltering","createApplyFiltering","filteringPlugins","byType","CmsEntryFilterPlugin","type","reduce","collection","plugin","fieldType","getFilterPlugin","WebinyError","execFiltering","where","initialWhere","query","keys","Object","length","key","value","undefined","childWhereList","getWhereValues","childQuery","createBaseQuery","childWhere","childQueryBool","getPopulated","filter","push","bool","should","assignMinimumShouldMatchToQuery","field","whereFieldId","operator","parseWhereKey","fieldId","cmsModelField","find","f","filterPlugin","exec"],"sources":["exec.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ModelFields } from \"~/operations/entry/elasticsearch/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchBoolQueryConfig, Query } from \"@webiny/api-elasticsearch/types\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createOperatorPluginList } from \"~/operations/entry/elasticsearch/plugins/operator\";\nimport { createBaseQuery } from \"~/operations/entry/elasticsearch/initialQuery\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport { getWhereValues } from \"./values\";\nimport { getPopulated } from \"./populated\";\nimport { createApplyFiltering } from \"./applyFiltering\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { assignMinimumShouldMatchToQuery } from \"~/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery\";\n\nexport interface CreateExecParams {\n model: CmsModel;\n fields: ModelFields;\n plugins: PluginsContainer;\n}\nexport interface ExecParams {\n where: CmsEntryListWhere;\n query: ElasticsearchBoolQueryConfig;\n}\nexport interface CreateExecFilteringResponse {\n (params: ExecParams): void;\n}\nexport const createExecFiltering = (params: CreateExecParams): CreateExecFilteringResponse => {\n const { fields, plugins, model } = params;\n\n /**\n * We need the search plugins as key -> plugin value, so it is easy to find plugin we need, without iterating through array.\n */\n const searchPlugins = createSearchPluginList({\n plugins\n });\n /**\n * We need the operator plugins, which we execute on our where conditions.\n */\n const operatorPlugins = createOperatorPluginList({\n plugins,\n locale: model.locale\n });\n\n const applyFiltering = createApplyFiltering({\n operatorPlugins,\n searchPlugins\n });\n\n const filteringPlugins = plugins\n .byType<CmsEntryFilterPlugin>(CmsEntryFilterPlugin.type)\n .reduce<Record<string, CmsEntryFilterPlugin>>((collection, plugin) => {\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {});\n\n const getFilterPlugin = (type: string) => {\n const plugin = filteringPlugins[type] || filteringPlugins[\"*\"];\n if (plugin) {\n return plugin;\n }\n throw new WebinyError(\n `There is no filtering plugin for the given field type \"${type}\".`,\n \"FILTERING_PLUGIN_ERROR\",\n {\n type\n }\n );\n };\n\n const execFiltering = (params: ExecParams) => {\n const { where: initialWhere, query } = params;\n /**\n * No point in continuing if no \"where\" conditions exist.\n */\n const keys = Object.keys(initialWhere);\n if (keys.length === 0) {\n return;\n }\n const where: CmsEntryListWhere = {\n ...initialWhere\n };\n\n for (const key in where) {\n const value = where[key] as unknown as any;\n /**\n * We always skip if no value is defined.\n * Only skip undefined value, null is valid.\n */\n if (value === undefined) {\n continue;\n }\n //\n /**\n * When we are running with AND, the \"value\" MUST be an array.\n */\n else if (key === \"AND\") {\n const childWhereList = getWhereValues(value, \"AND\");\n\n const childQuery = createBaseQuery();\n\n for (const childWhere of childWhereList) {\n execFiltering({\n query: childQuery,\n where: childWhere\n });\n }\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n query.filter.push({\n bool: childQueryBool\n });\n\n continue;\n }\n //\n /**\n * When we are running with OR, the \"value\" must be an array.\n */\n else if (key === \"OR\") {\n const childWhereList = getWhereValues(value, \"OR\");\n /**\n * Each of the conditions MUST produce it's own should section.\n */\n const should: Query[] = [];\n for (const childWhere of childWhereList) {\n const childQuery = createBaseQuery();\n execFiltering({\n query: childQuery,\n where: childWhere\n });\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n should.push({\n bool: childQueryBool\n });\n }\n if (should.length === 0) {\n continue;\n }\n query.should.push(...should);\n /**\n * If there are any should, minimum to have is 1.\n * Of course, do not override if it's already set.\n */\n assignMinimumShouldMatchToQuery({\n query\n });\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n let fieldId: string = whereFieldId;\n\n /**\n * TODO This will be required until the storage operations receive the fieldId instead of field storageId.\n * TODO For this to work without field searching, we need to refactor how the query looks like.\n *\n * Storage operations should NEVER receive an field storageId, only alias - fieldId.\n */\n const cmsModelField = model.fields.find(f => f.fieldId === fieldId);\n if (!cmsModelField && !fields[fieldId]) {\n throw new WebinyError(`There is no CMS Model Field \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const field = fields[fieldId];\n if (!field) {\n throw new WebinyError(`There is no field \"${fieldId}\".`);\n }\n const filterPlugin = getFilterPlugin(field.type);\n\n filterPlugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n };\n\n return execFiltering;\n};\n"],"mappings":";;;;;;;;AAAA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcO,MAAMA,mBAAmB,GAAIC,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,CAACK;EAClB,CAAC,CAAC;EAEF,MAAMC,cAAc,GAAG,IAAAC,oCAAoB,EAAC;IACxCJ,eAAe;IACfF;EACJ,CAAC,CAAC;EAEF,MAAMO,gBAAgB,GAAGT,OAAO,CAC3BU,MAAM,CAAuBC,0CAAoB,CAACC,IAAI,CAAC,CACvDC,MAAM,CAAuC,CAACC,UA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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,CAAC;MAC5D;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;AAAC"}
1
+ {"version":3,"names":["createExecFiltering","params","fields","plugins","model","searchPlugins","createSearchPluginList","operatorPlugins","createOperatorPluginList","locale","applyFiltering","createApplyFiltering","filteringPlugins","byType","CmsEntryFilterPlugin","type","reduce","collection","plugin","fieldType","getFilterPlugin","WebinyError","execFiltering","where","initialWhere","query","keys","Object","length","key","value","undefined","childWhereList","getWhereValues","childQuery","createBaseQuery","childWhere","childQueryBool","getPopulated","filter","push","bool","should","assignMinimumShouldMatchToQuery","field","whereFieldId","operator","parseWhereKey","fieldId","cmsModelField","find","f","filterPlugin","exec"],"sources":["exec.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ModelFields } from \"~/operations/entry/elasticsearch/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchBoolQueryConfig, Query } from \"@webiny/api-elasticsearch/types\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createOperatorPluginList } from \"~/operations/entry/elasticsearch/plugins/operator\";\nimport { createBaseQuery } from \"~/operations/entry/elasticsearch/initialQuery\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport { getWhereValues } from \"./values\";\nimport { getPopulated } from \"./populated\";\nimport { createApplyFiltering } from \"./applyFiltering\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { assignMinimumShouldMatchToQuery } from \"~/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery\";\n\nexport interface CreateExecParams {\n model: CmsModel;\n fields: ModelFields;\n plugins: PluginsContainer;\n}\nexport interface ExecParams {\n where: CmsEntryListWhere;\n query: ElasticsearchBoolQueryConfig;\n}\nexport interface CreateExecFilteringResponse {\n (params: ExecParams): void;\n}\nexport const createExecFiltering = (params: CreateExecParams): CreateExecFilteringResponse => {\n const { fields, plugins, model } = params;\n\n /**\n * We need the search plugins as key -> plugin value, so it is easy to find plugin we need, without iterating through array.\n */\n const searchPlugins = createSearchPluginList({\n plugins\n });\n /**\n * We need the operator plugins, which we execute on our where conditions.\n */\n const operatorPlugins = createOperatorPluginList({\n plugins,\n locale: model.locale\n });\n\n const applyFiltering = createApplyFiltering({\n operatorPlugins,\n searchPlugins\n });\n\n const filteringPlugins = plugins\n .byType<CmsEntryFilterPlugin>(CmsEntryFilterPlugin.type)\n .reduce<Record<string, CmsEntryFilterPlugin>>((collection, plugin) => {\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {});\n\n const getFilterPlugin = (type: string) => {\n const plugin = filteringPlugins[type] || filteringPlugins[\"*\"];\n if (plugin) {\n return plugin;\n }\n throw new WebinyError(\n `There is no filtering plugin for the given field type \"${type}\".`,\n \"FILTERING_PLUGIN_ERROR\",\n {\n type\n }\n );\n };\n\n const execFiltering = (params: ExecParams) => {\n const { where: initialWhere, query } = params;\n /**\n * No point in continuing if no \"where\" conditions exist.\n */\n const keys = Object.keys(initialWhere);\n if (keys.length === 0) {\n return;\n }\n const where: CmsEntryListWhere = {\n ...initialWhere\n };\n\n for (const key in where) {\n const value = where[key] as unknown as any;\n /**\n * We always skip if no value is defined.\n * Only skip undefined value, null is valid.\n */\n if (value === undefined) {\n continue;\n }\n //\n /**\n * When we are running with AND, the \"value\" MUST be an array.\n */\n else if (key === \"AND\") {\n const childWhereList = getWhereValues(value, \"AND\");\n\n const childQuery = createBaseQuery();\n\n for (const childWhere of childWhereList) {\n execFiltering({\n query: childQuery,\n where: childWhere\n });\n }\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n query.filter.push({\n bool: childQueryBool\n });\n\n continue;\n }\n //\n /**\n * When we are running with OR, the \"value\" must be an array.\n */\n else if (key === \"OR\") {\n const childWhereList = getWhereValues(value, \"OR\");\n /**\n * Each of the conditions MUST produce it's own should section.\n */\n const should: Query[] = [];\n for (const childWhere of childWhereList) {\n const childQuery = createBaseQuery();\n execFiltering({\n query: childQuery,\n where: childWhere\n });\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n should.push({\n bool: childQueryBool\n });\n }\n if (should.length === 0) {\n continue;\n }\n query.should.push(...should);\n /**\n * If there are any should, minimum to have is 1.\n * Of course, do not override if it's already set.\n */\n assignMinimumShouldMatchToQuery({\n query\n });\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n let fieldId: string = whereFieldId;\n\n /**\n * TODO This will be required until the storage operations receive the fieldId instead of field storageId.\n * TODO For this to work without field searching, we need to refactor how the query looks like.\n *\n * Storage operations should NEVER receive an field storageId, only alias - fieldId.\n */\n const cmsModelField = model.fields.find(f => f.fieldId === fieldId);\n if (!cmsModelField && !fields[fieldId]) {\n throw new WebinyError(`There is no CMS Model Field \"${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;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcO,MAAMA,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,CAACK;EAClB,CAAC,CAAC;EAEF,MAAMC,cAAc,GAAG,IAAAC,oCAAoB,EAAC;IACxCJ,eAAe;IACfF;EACJ,CAAC,CAAC;EAEF,MAAMO,gBAAgB,GAAGT,OAAO,CAC3BU,MAAM,CAAuBC,0CAAoB,CAACC,IAAI,CAAC,CACvDC,MAAM,CAAuC,CAACC,UAAU,EAAEC,MAAM,KAAK;IAClED,UAAU,CAACC,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM;IAErC,OAAOD,UAAU;EACrB,CAAC,EAAE,CAAC,CAAC,CAAC;EAEV,MAAMG,eAAe,GAAIL,IAAY,IAAK;IACtC,MAAMG,MAAM,GAAGN,gBAAgB,CAACG,IAAI,CAAC,IAAIH,gBAAgB,CAAC,GAAG,CAAC;IAC9D,IAAIM,MAAM,EAAE;MACR,OAAOA,MAAM;IACjB;IACA,MAAM,IAAIG,cAAW,CAChB,0DAAyDN,IAAK,IAAG,EAClE,wBAAwB,EACxB;MACIA;IACJ,CAAC,CACJ;EACL,CAAC;EA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pF;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;AAAC"}
@@ -36,7 +36,9 @@ const createObjectFilterPlugin = () => {
36
36
  const identifier = [...parentField.parents.map(p => p.fieldId), parentField.field.fieldId, whereFieldId].join(".");
37
37
  const field = fields[identifier];
38
38
  if (!field) {
39
- throw new _error.default(`There is no field "${identifier}".`);
39
+ throw new _error.default(`There is no field "${identifier}".`, "OBJECT_FILTER_FIELD_ERROR", {
40
+ fields: Object.keys(fields)
41
+ });
40
42
  }
41
43
  /**
42
44
  * We need to find the filter plugin for the child field.
@@ -1 +1 @@
1
- {"version":3,"names":["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","type","name"],"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(`There is no field \"${identifier}\".`);\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;AACA;AACA;AAEO,MAAMA,wBAAwB,GAAG,MAAM;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,CAAE,sBAAqBN,UAAW,IAAG,CAAC;QAC/D;QACA;AAChB;AACA;AACA;QACgB,MAAMlB,MAAM,GAAGW,eAAe,CAACF,KAAK,CAACgB,IAAI,CAAC;QAC1C;AAChB;AACA;QACgBzB,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,CAAC0B,IAAI,GAAI,GAAE1B,MAAM,CAACyB,IAAK,iBAAgB;EAE7C,OAAOzB,MAAM;AACjB,CAAC;AAAC"}
1
+ {"version":3,"names":["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"],"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;AACA;AACA;AAEO,MAAMA,wBAAwB,GAAG,MAAM;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,CAChB,sBAAqBN,UAAW,IAAG,EACpC,2BAA2B,EAC3B;YACIV,MAAM,EAAEiB,MAAM,CAACC,IAAI,CAAClB,MAAM;UAC9B,CAAC,CACJ;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,GAAI,GAAE5B,MAAM,CAAC2B,IAAK,iBAAgB;EAE7C,OAAO3B,MAAM;AACjB,CAAC;AAAC"}
@@ -1218,6 +1218,7 @@ const createEntriesStorageOperations = params => {
1218
1218
  }
1219
1219
  };
1220
1220
  const getUniqueFieldValues = async (model, params) => {
1221
+ var _response$body$aggreg;
1221
1222
  const {
1222
1223
  where,
1223
1224
  fieldId
@@ -1282,10 +1283,13 @@ const createEntriesStorageOperations = params => {
1282
1283
  body
1283
1284
  });
1284
1285
  }
1285
- const values = response.body.aggregations["getUniqueFieldValues"] || {
1286
- buckets: []
1287
- };
1288
- return values.buckets.map(item => item.key) || [];
1286
+ const buckets = ((_response$body$aggreg = response.body.aggregations["getUniqueFieldValues"]) === null || _response$body$aggreg === void 0 ? void 0 : _response$body$aggreg.buckets) || [];
1287
+ return buckets.map(file => {
1288
+ return {
1289
+ value: file.key,
1290
+ count: file.doc_count
1291
+ };
1292
+ });
1289
1293
  };
1290
1294
  return {
1291
1295
  create,
@@ -1 +1 @@
1
- {"version":3,"names":["getEntryData","input","output","getESLatestEntryData","plugins","entry","compress","latest","TYPE","createLatestRecordType","__type","getESPublishedEntryData","published","createPublishedRecordType","convertEntryKeysToStorage","params","model","values","convertValueKeyToStorage","fields","convertEntryKeysFromStorage","convertValueKeyFromStorage","createEntriesStorageOperations","entity","esEntity","elasticsearch","storageOperationsCmsModelPlugin","getStorageOperationsCmsModelPlugin","oneByType","StorageOperationsCmsModelPlugin","type","getStorageOperationsModel","plugin","getModel","dataLoaders","DataLoadersHandler","create","initialModel","initialEntry","storageEntry","initialStorageEntry","isPublished","status","locked","esEntry","prepareEntryToIndex","lodashCloneDeep","index","esIndex","configurations","es","esLatestData","esPublishedData","revisionKeys","PK","createPartitionKey","id","locale","tenant","SK","createRevisionSortKey","latestKeys","createLatestSortKey","publishedKeys","createPublishedSortKey","items","putBatch","createRecordType","push","batchWriteAll","table","clearAll","ex","WebinyError","message","code","error","esItems","data","createRevisionFrom","put","update","latestStorageEntry","getLatestRevisionByEntryId","ids","publishedStorageEntry","getPublishedRevisionByEntryId","undefined","elasticsearchLatestData","elasticsearchPublishedData","length","deleteEntry","entryId","partitionKey","queryAll","options","gte","deleteItems","map","item","deleteBatch","deleteEsItems","deleteRevision","latestEntry","deleteMultipleEntries","entries","revisions","getAllEntryRevisions","revision","version","list","limit","createLimit","result","indices","exists","body","hasMoreItems","totalCount","cursor","createElasticsearchBody","after","decodeCursor","response","search","hits","total","extractEntriesFromIndex","_source","pop","encodeCursor","sort","value","get","shift","publish","latestEsEntry","getRecord","keys","previouslyPublishedEntry","getRevisionById","CONTENT_ENTRY_STATUS","UNPUBLISHED","savedOn","latestEsEntryDataDecompressed","decompress","PUBLISHED","publishedOn","preparedEntryData","unpublish","getRevisions","getByIds","getLatestByIds","getPublishedByIds","getPreviousRevision","queryParams","lt","zeroPad","filters","attr","eq","reverse","queryOne","cleanupItem","getUniqueFieldValues","where","fieldId","initialBody","field","find","f","size","aggregations","terms","storageId","buckets","key","delete"],"sources":["index.ts"],"sourcesContent":["import lodashCloneDeep from \"lodash/cloneDeep\";\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsEntry,\n CmsModel,\n CmsStorageEntry,\n CONTENT_ENTRY_STATUS,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { extractEntriesFromIndex, prepareEntryToIndex } from \"~/helpers\";\nimport { configurations } from \"~/configurations\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { DataLoadersHandler } from \"~/operations/entry/dataLoaders\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"~/operations/entry/keys\";\nimport { queryAll, queryOne, QueryOneParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n compress,\n createLimit,\n decodeCursor,\n decompress,\n encodeCursor\n} from \"@webiny/api-elasticsearch\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport {\n ElasticsearchSearchResponse,\n SearchBody as ElasticsearchSearchBody\n} from \"@webiny/api-elasticsearch/types\";\nimport { CmsEntryStorageOperations, CmsIndexEntry } from \"~/types\";\nimport { createElasticsearchBody } from \"~/operations/entry/elasticsearch/body\";\nimport { createLatestRecordType, createPublishedRecordType, createRecordType } from \"./recordType\";\nimport { StorageOperationsCmsModelPlugin } from \"@webiny/api-headless-cms\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\n\nconst getEntryData = (input: CmsEntry): CmsEntry => {\n const output: any = {\n ...input\n };\n delete output[\"PK\"];\n delete output[\"SK\"];\n delete output[\"published\"];\n delete output[\"latest\"];\n\n return output;\n};\n\nconst getESLatestEntryData = async (plugins: PluginsContainer, entry: CmsEntry) => {\n return compress(plugins, {\n ...getEntryData(entry),\n latest: true,\n TYPE: createLatestRecordType(),\n __type: createLatestRecordType()\n });\n};\n\nconst getESPublishedEntryData = async (plugins: PluginsContainer, entry: CmsEntry) => {\n return compress(plugins, {\n ...getEntryData(entry),\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n });\n};\n\ninterface ConvertStorageEntryParams {\n entry: CmsStorageEntry;\n model: StorageOperationsCmsModel;\n}\nconst convertEntryKeysToStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyToStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n\nconst convertEntryKeysFromStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyFromStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n\ninterface ElasticsearchDbRecord {\n index: string;\n data: Record<string, string>;\n}\n\nexport interface CreateEntriesStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\nexport const createEntriesStorageOperations = (\n params: CreateEntriesStorageOperationsParams\n): CmsEntryStorageOperations => {\n const { entity, esEntity, elasticsearch, plugins } = params;\n\n let storageOperationsCmsModelPlugin: StorageOperationsCmsModelPlugin | undefined;\n const getStorageOperationsCmsModelPlugin = () => {\n if (storageOperationsCmsModelPlugin) {\n return storageOperationsCmsModelPlugin;\n }\n storageOperationsCmsModelPlugin = plugins.oneByType<StorageOperationsCmsModelPlugin>(\n StorageOperationsCmsModelPlugin.type\n );\n return storageOperationsCmsModelPlugin;\n };\n\n const getStorageOperationsModel = (model: CmsModel): StorageOperationsCmsModel => {\n const plugin = getStorageOperationsCmsModelPlugin();\n return plugin.getModel(model);\n };\n\n const dataLoaders = new DataLoadersHandler({\n entity\n });\n\n const create: CmsEntryStorageOperations[\"create\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const model = getStorageOperationsModel(initialModel);\n\n const isPublished = initialEntry.status === \"published\";\n const locked = isPublished ? true : initialEntry.locked;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({ ...entry, locked }),\n storageEntry: lodashCloneDeep({ ...storageEntry, locked })\n });\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n const esPublishedData = await getESPublishedEntryData(plugins, esEntry);\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n }),\n entity.putBatch({\n ...storageEntry,\n locked,\n ...latestKeys,\n TYPE: createLatestRecordType()\n })\n ];\n\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the DynamoDB table.\",\n ex.code || \"CREATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n const esItems = [\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: esLatestData\n })\n ];\n if (isPublished) {\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the Elasticsearch DynamoDB table.\",\n ex.code || \"CREATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n esEntry\n }\n );\n }\n\n return initialStorageEntry;\n };\n\n const createRevisionFrom: CmsEntryStorageOperations[\"createRevisionFrom\"] = async (\n initialModel,\n params\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n TYPE: createRecordType(),\n ...revisionKeys\n }),\n entity.putBatch({\n ...storageEntry,\n TYPE: createLatestRecordType(),\n ...latestKeys\n })\n ];\n\n const { index } = configurations.es({\n model\n });\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create revision from given entry in the DynamoDB table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n /**\n * Update the \"latest\" entry item in the Elasticsearch\n */\n try {\n await esEntity.put({\n ...latestKeys,\n index,\n data: esLatestData\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update latest entry in the DynamoDB Elasticsearch table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n /**\n * There are no modifications on the entry created so just return the data.\n */\n return initialStorageEntry;\n };\n\n const update: CmsEntryStorageOperations[\"update\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n const esItems = [];\n\n const { index: esIndex } = configurations.es({\n model\n });\n /**\n * Variable for the elasticsearch entry so we do not convert it more than once\n */\n let esEntry: CmsIndexEntry | undefined = undefined;\n /**\n * If the latest entry is the one being updated, we need to create a new latest entry records.\n */\n let elasticsearchLatestData: any = null;\n if (latestStorageEntry?.id === entry.id) {\n /**\n * First we update the regular DynamoDB table\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys,\n TYPE: createLatestSortKey()\n })\n );\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({\n ...entry,\n locked\n }),\n storageEntry: lodashCloneDeep({\n ...storageEntry,\n locked\n })\n });\n\n elasticsearchLatestData = await getESLatestEntryData(plugins, esEntry);\n\n esItems.push(\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: elasticsearchLatestData\n })\n );\n }\n let elasticsearchPublishedData = null;\n if (isPublished && publishedStorageEntry?.id === entry.id) {\n if (!elasticsearchLatestData) {\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n if (!esEntry) {\n esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({\n ...entry,\n locked\n }),\n storageEntry: lodashCloneDeep({\n ...storageEntry,\n locked\n })\n });\n }\n elasticsearchPublishedData = await getESPublishedEntryData(plugins, esEntry);\n } else {\n elasticsearchPublishedData = {\n ...elasticsearchLatestData,\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n };\n delete elasticsearchPublishedData.latest;\n }\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: elasticsearchPublishedData\n })\n );\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB records.\",\n ex.code || \"UPDATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n if (esItems.length === 0) {\n return initialStorageEntry;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB Elasticsearch records.\",\n ex.code || \"UPDATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const deleteEntry: CmsEntryStorageOperations[\"delete\"] = async (initialModel, params) => {\n const { entry } = params;\n const id = entry.id || entry.entryId;\n const model = getStorageOperationsModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = await queryAll<CmsEntry>({\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const esItems = await queryAll<CmsEntry>({\n entity: esEntity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const deleteItems = items.map(item => {\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n const deleteEsItems = esItems.map(item => {\n return esEntity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n try {\n await batchWriteAll({\n table: entity.table,\n items: deleteItems\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete entry records from DynamoDB table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n id\n }\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: deleteEsItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete entry records from DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n id\n }\n );\n }\n };\n\n const deleteRevision: CmsEntryStorageOperations[\"deleteRevision\"] = async (\n initialModel,\n params\n ) => {\n const { entry, latestEntry, latestStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const { index } = configurations.es({\n model\n });\n /**\n * We need published entry to delete it if necessary.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n /**\n * We need to delete all existing records of the given entry revision.\n */\n const items = [\n /**\n * Delete records of given entry revision.\n */\n entity.deleteBatch({\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n })\n ];\n\n const esItems = [];\n\n /**\n * If revision we are deleting is the published one as well, we need to delete those records as well.\n */\n if (publishedStorageEntry?.id === entry.id) {\n items.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n esItems.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n if (latestEntry && latestStorageEntry) {\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(latestEntry),\n storageEntry: lodashCloneDeep(latestStorageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n /**\n * In the end we need to set the new latest entry\n */\n items.push(\n entity.putBatch({\n ...latestStorageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestRecordType()\n })\n );\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write entry records to DynamoDB table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n latestStorageEntry\n }\n );\n }\n\n if (esItems.length === 0) {\n return;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not batch write entry records to DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n latestStorageEntry\n }\n );\n }\n };\n\n const deleteMultipleEntries: CmsEntryStorageOperations[\"deleteMultipleEntries\"] = async (\n initialModel,\n params\n ) => {\n const { entries } = params;\n const model = getStorageOperationsModel(initialModel);\n /**\n * First we need all the revisions of the entries we want to delete.\n */\n const revisions = await dataLoaders.getAllEntryRevisions({\n model,\n ids: entries\n });\n /**\n * Then we need to construct the queries for all the revisions and entries.\n */\n const items: Record<string, DocumentClient.WriteRequest>[] = [];\n const esItems: Record<string, DocumentClient.WriteRequest>[] = [];\n for (const id of entries) {\n /**\n * Latest item.\n */\n items.push(\n entity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"L\"\n })\n );\n esItems.push(\n esEntity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"L\"\n })\n );\n /**\n * Published item.\n */\n items.push(\n entity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"P\"\n })\n );\n esItems.push(\n esEntity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"P\"\n })\n );\n }\n /**\n * Exact revisions of all the entries\n */\n for (const revision of revisions) {\n items.push(\n entity.deleteBatch({\n PK: createPartitionKey({\n id: revision.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey({\n version: revision.version\n })\n })\n );\n }\n\n await batchWriteAll({\n table: entity.table,\n items\n });\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n };\n\n const list: CmsEntryStorageOperations[\"list\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const limit = createLimit(params.limit, 50);\n const { index } = configurations.es({\n model\n });\n\n try {\n const result = await elasticsearch.indices.exists({\n index\n });\n if (!result?.body) {\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: []\n };\n }\n } catch (ex) {\n throw new WebinyError(\n \"Could not determine if Elasticsearch index exists.\",\n \"ELASTICSEARCH_INDEX_CHECK_ERROR\",\n {\n error: ex,\n index\n }\n );\n }\n\n const body = createElasticsearchBody({\n model,\n params: {\n ...params,\n limit,\n after: decodeCursor(params.after)\n },\n plugins\n });\n\n let response: ElasticsearchSearchResponse<CmsIndexEntry>;\n try {\n response = await elasticsearch.search({\n index,\n body\n });\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code || \"ELASTICSEARCH_ERROR\", {\n error: ex,\n index,\n body,\n model\n });\n }\n\n const { hits, total } = response?.body?.hits || {};\n\n const items = extractEntriesFromIndex({\n plugins,\n model,\n entries: hits.map(item => item._source)\n }).map(item => {\n return convertEntryKeysFromStorage({\n model,\n entry: item\n });\n });\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;\n return {\n hasMoreItems,\n totalCount: total.value,\n cursor,\n items\n };\n };\n\n const get: CmsEntryStorageOperations[\"get\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const { items } = await list(model, {\n ...params,\n limit: 1\n });\n return items.shift() || null;\n };\n\n const publish: CmsEntryStorageOperations[\"publish\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n /**\n * We need currently published entry to check if need to remove it.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n let latestEsEntry: ElasticsearchDbRecord | null = null;\n try {\n latestEsEntry = await getRecord<ElasticsearchDbRecord>({\n entity: esEntity,\n keys: latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not read Elasticsearch latest or published data.\",\n ex.code || \"PUBLISH_BATCH_READ\",\n {\n error: ex,\n latestKeys: latestKeys,\n publishedKeys: publishedKeys\n }\n );\n }\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n const esItems = [];\n\n const { index } = configurations.es({\n model\n });\n\n if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {\n /**\n * If there is a `published` entry already, we need to set it to `unpublished`. We need to\n * execute two updates: update the previously published entry's status and the published entry record.\n * DynamoDB does not support `batchUpdate` - so here we load the previously published\n * entry's data to update its status within a batch operation. If, hopefully,\n * they introduce a true update batch operation, remove this `read` call.\n */\n const [previouslyPublishedEntry] = await dataLoaders.getRevisionById({\n model,\n ids: [publishedStorageEntry.id]\n });\n items.push(\n /**\n * Update currently published entry (unpublish it)\n */\n entity.putBatch({\n ...previouslyPublishedEntry,\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED,\n savedOn: entry.savedOn,\n TYPE: createRecordType(),\n PK: createPartitionKey(publishedStorageEntry),\n SK: createRevisionSortKey(publishedStorageEntry)\n })\n );\n }\n /**\n * Update the helper item in DB with the new published entry\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n\n /**\n * We need the latest entry to check if it needs to be updated as well in the Elasticsearch.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n if (latestStorageEntry?.id === entry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys\n })\n );\n }\n /**\n * If we are publishing the latest revision, let's also update the latest revision's status in ES.\n */\n if (latestEsEntry && latestStorageEntry?.id === entry.id) {\n /**\n * Need to decompress the data from Elasticsearch DynamoDB table.\n *\n * No need to transform it for the storage because it was fetched directly from the Elasticsearch table, where it sits transformed.\n */\n const latestEsEntryDataDecompressed: CmsEntry = (await decompress(\n plugins,\n latestEsEntry.data\n )) as any;\n\n esItems.push(\n esEntity.putBatch({\n index,\n PK: createPartitionKey(latestEsEntryDataDecompressed),\n SK: createLatestSortKey(),\n data: await getESLatestEntryData(plugins, {\n ...latestEsEntryDataDecompressed,\n status: CONTENT_ENTRY_STATUS.PUBLISHED,\n locked: true,\n savedOn: entry.savedOn,\n publishedOn: entry.publishedOn\n })\n })\n );\n }\n\n const preparedEntryData = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n /**\n * Update the published revision entry in ES.\n */\n const esPublishedData = await getESPublishedEntryData(plugins, preparedEntryData);\n\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index,\n data: esPublishedData\n })\n );\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store publish entry records in DynamoDB table.\",\n ex.code || \"PUBLISH_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store publish entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"PUBLISH_ES_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const unpublish: CmsEntryStorageOperations[\"unpublish\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createRecordType()\n })\n ];\n\n const esItems = [\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n ];\n /**\n * If we are unpublishing the latest revision, let's also update the latest revision entry's status in ES.\n */\n if (latestStorageEntry?.id === entry.id) {\n const { index } = configurations.es({\n model\n });\n\n const preparedEntryData = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, preparedEntryData);\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store unpublished entry records in DynamoDB table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store unpublished entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const getLatestRevisionByEntryId: CmsEntryStorageOperations[\"getLatestRevisionByEntryId\"] =\n async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getPublishedRevisionByEntryId: CmsEntryStorageOperations[\"getPublishedRevisionByEntryId\"] =\n async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisionById: CmsEntryStorageOperations[\"getRevisionById\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getRevisionById({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisions: CmsEntryStorageOperations[\"getRevisions\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getAllEntryRevisions({\n model,\n ids: [params.id]\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getByIds: CmsEntryStorageOperations[\"getByIds\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getRevisionById({\n model,\n ids: params.ids\n });\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getLatestByIds: CmsEntryStorageOperations[\"getLatestByIds\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: params.ids\n });\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPublishedByIds: CmsEntryStorageOperations[\"getPublishedByIds\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPreviousRevision: CmsEntryStorageOperations[\"getPreviousRevision\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const { tenant, locale } = model;\n const { entryId, version } = params;\n const queryParams: QueryOneParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id: entryId\n }),\n options: {\n lt: `REV#${zeroPad(version)}`,\n /**\n * We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.\n */\n filters: [\n {\n attr: \"TYPE\",\n eq: createRecordType()\n },\n {\n attr: \"version\",\n lt: version\n }\n ],\n reverse: true\n }\n };\n\n try {\n const result = await queryOne<CmsEntry>(queryParams);\n\n const entry = cleanupItem(entity, result);\n\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n entry,\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get previous version of given entry.\",\n ex.code || \"GET_PREVIOUS_VERSION_ERROR\",\n {\n ...params,\n error: ex,\n partitionKey: queryParams.partitionKey,\n options: queryParams.options,\n model\n }\n );\n }\n };\n\n const getUniqueFieldValues: CmsEntryStorageOperations[\"getUniqueFieldValues\"] = async (\n model,\n params\n ) => {\n const { where, fieldId } = params;\n\n const { index } = configurations.es({\n model\n });\n\n try {\n const result = await elasticsearch.indices.exists({\n index\n });\n if (!result?.body) {\n return [];\n }\n } catch (ex) {\n throw new WebinyError(\n \"Could not determine if Elasticsearch index exists.\",\n \"ELASTICSEARCH_INDEX_CHECK_ERROR\",\n {\n error: ex,\n index\n }\n );\n }\n\n const initialBody = createElasticsearchBody({\n model,\n params: {\n limit: 1,\n where\n },\n plugins\n });\n\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n throw new WebinyError(\n `Could not find field with given \"fieldId\" value.`,\n \"FIELD_NOT_FOUND\",\n {\n fieldId\n }\n );\n }\n\n const body: ElasticsearchSearchBody = {\n ...initialBody,\n /**\n * We do not need any hits returned, we only need the aggregations.\n */\n size: 0,\n aggregations: {\n getUniqueFieldValues: {\n terms: {\n field: `values.${field.storageId}.keyword`,\n size: 1000000\n }\n }\n }\n };\n\n let response: ElasticsearchSearchResponse<string> | undefined = undefined;\n\n try {\n response = await elasticsearch.search({\n index,\n body\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Error in the Elasticsearch query.\",\n ex.code || \"ELASTICSEARCH_ERROR\",\n {\n error: ex,\n index,\n model,\n body\n }\n );\n }\n\n const values = response.body.aggregations[\"getUniqueFieldValues\"] || { buckets: [] };\n\n return values.buckets.map(item => item.key) || [];\n };\n\n return {\n create,\n createRevisionFrom,\n update,\n delete: deleteEntry,\n deleteRevision,\n deleteMultipleEntries,\n get,\n publish,\n unpublish,\n list,\n getLatestRevisionByEntryId,\n getPublishedRevisionByEntryId,\n getRevisionById,\n getRevisions,\n getByIds,\n getLatestByIds,\n getPublishedByIds,\n getPreviousRevision,\n getUniqueFieldValues,\n dataLoaders\n };\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AAOA;AACA;AAIA;AACA;AACA;AAMA;AACA;AAOA;AACA;AACA;AAMA;AACA;AACA;AAGA,MAAMA,YAAY,GAAIC,KAAe,IAAe;EAChD,MAAMC,MAAW,mCACVD,KAAK,CACX;EACD,OAAOC,MAAM,CAAC,IAAI,CAAC;EACnB,OAAOA,MAAM,CAAC,IAAI,CAAC;EACnB,OAAOA,MAAM,CAAC,WAAW,CAAC;EAC1B,OAAOA,MAAM,CAAC,QAAQ,CAAC;EAEvB,OAAOA,MAAM;AACjB,CAAC;AAED,MAAMC,oBAAoB,GAAG,OAAOC,OAAyB,EAAEC,KAAe,KAAK;EAC/E,OAAO,IAAAC,0BAAQ,EAACF,OAAO,8DAChBJ,YAAY,CAACK,KAAK,CAAC;IACtBE,MAAM,EAAE,IAAI;IACZC,IAAI,EAAE,IAAAC,kCAAsB,GAAE;IAC9BC,MAAM,EAAE,IAAAD,kCAAsB;EAAE,GAClC;AACN,CAAC;AAED,MAAME,uBAAuB,GAAG,OAAOP,OAAyB,EAAEC,KAAe,KAAK;EAClF,OAAO,IAAAC,0BAAQ,EAACF,OAAO,8DAChBJ,YAAY,CAACK,KAAK,CAAC;IACtBO,SAAS,EAAE,IAAI;IACfJ,IAAI,EAAE,IAAAK,qCAAyB,GAAE;IAC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YAAY,EAAE;QACVR,oBAAoB,EAAE;UAClBS,KAAK,EAAE;YACHL,KAAK,EAAG,UAASA,KAAK,CAACM,SAAU,UAAS;YAC1CH,IAAI,EAAE;UACV;QACJ;MACJ;IAAC,EACJ;IAED,IAAIhD,QAAyD,GAAGpC,SAAS;IAEzE,IAAI;MACAoC,QAAQ,GAAG,MAAMlG,aAAa,CAACmG,MAAM,CAAC;QAClC7E,KAAK;QACLqE;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAO5C,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,mCAAmC,EACjDF,EAAE,CAACG,IAAI,IAAI,qBAAqB,EAChC;QACIC,KAAK,EAAEJ,EAAE;QACTzB,KAAK;QACL/B,KAAK;QACLoG;MACJ,CAAC,CACJ;IACL;IAEA,MAAMnG,MAAM,GAAG0G,QAAQ,CAACP,IAAI,CAACwD,YAAY,CAAC,sBAAsB,CAAC,IAAI;MAAEG,OAAO,EAAE;IAAG,CAAC;IAEpF,OAAO9J,MAAM,CAAC8J,OAAO,CAAC7E,GAAG,CAACC,IAAI,IAAIA,IAAI,CAAC6E,GAAG,CAAC,IAAI,EAAE;EACrD,CAAC;EAED,OAAO;IACH5I,MAAM;IACN2C,kBAAkB;IAClBE,MAAM;IACNgG,MAAM,EAAEtF,WAAW;IACnBW,cAAc;IACdE,qBAAqB;IACrB6B,GAAG;IACHE,OAAO;IACPc,SAAS;IACTvC,IAAI;IACJ3B,0BAA0B;IAC1BG,6BAA6B;IAC7BsD,eAAe;IACfU,YAAY;IACZC,QAAQ;IACRC,cAAc;IACdC,iBAAiB;IACjBC,mBAAmB;IACnBU,oBAAoB;IACpBlI;EACJ,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["getEntryData","input","output","getESLatestEntryData","plugins","entry","compress","latest","TYPE","createLatestRecordType","__type","getESPublishedEntryData","published","createPublishedRecordType","convertEntryKeysToStorage","params","model","values","convertValueKeyToStorage","fields","convertEntryKeysFromStorage","convertValueKeyFromStorage","createEntriesStorageOperations","entity","esEntity","elasticsearch","storageOperationsCmsModelPlugin","getStorageOperationsCmsModelPlugin","oneByType","StorageOperationsCmsModelPlugin","type","getStorageOperationsModel","plugin","getModel","dataLoaders","DataLoadersHandler","create","initialModel","initialEntry","storageEntry","initialStorageEntry","isPublished","status","locked","esEntry","prepareEntryToIndex","lodashCloneDeep","index","esIndex","configurations","es","esLatestData","esPublishedData","revisionKeys","PK","createPartitionKey","id","locale","tenant","SK","createRevisionSortKey","latestKeys","createLatestSortKey","publishedKeys","createPublishedSortKey","items","putBatch","createRecordType","push","batchWriteAll","table","clearAll","ex","WebinyError","message","code","error","esItems","data","createRevisionFrom","put","update","latestStorageEntry","getLatestRevisionByEntryId","ids","publishedStorageEntry","getPublishedRevisionByEntryId","undefined","elasticsearchLatestData","elasticsearchPublishedData","length","deleteEntry","entryId","partitionKey","queryAll","options","gte","deleteItems","map","item","deleteBatch","deleteEsItems","deleteRevision","latestEntry","deleteMultipleEntries","entries","revisions","getAllEntryRevisions","revision","version","list","limit","createLimit","result","indices","exists","body","hasMoreItems","totalCount","cursor","createElasticsearchBody","after","decodeCursor","response","search","hits","total","extractEntriesFromIndex","_source","pop","encodeCursor","sort","value","get","shift","publish","latestEsEntry","getRecord","keys","previouslyPublishedEntry","getRevisionById","CONTENT_ENTRY_STATUS","UNPUBLISHED","savedOn","latestEsEntryDataDecompressed","decompress","PUBLISHED","publishedOn","preparedEntryData","unpublish","getRevisions","getByIds","getLatestByIds","getPublishedByIds","getPreviousRevision","queryParams","lt","zeroPad","filters","attr","eq","reverse","queryOne","cleanupItem","getUniqueFieldValues","where","fieldId","initialBody","field","find","f","size","aggregations","terms","storageId","buckets","file","key","count","doc_count","delete"],"sources":["index.ts"],"sourcesContent":["import lodashCloneDeep from \"lodash/cloneDeep\";\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsEntry,\n CmsModel,\n CmsStorageEntry,\n CONTENT_ENTRY_STATUS,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { extractEntriesFromIndex, prepareEntryToIndex } from \"~/helpers\";\nimport { configurations } from \"~/configurations\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { DataLoadersHandler } from \"~/operations/entry/dataLoaders\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"~/operations/entry/keys\";\nimport { queryAll, queryOne, QueryOneParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n compress,\n createLimit,\n decodeCursor,\n decompress,\n encodeCursor\n} from \"@webiny/api-elasticsearch\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport {\n ElasticsearchSearchResponse,\n SearchBody as ElasticsearchSearchBody\n} from \"@webiny/api-elasticsearch/types\";\nimport { CmsEntryStorageOperations, CmsIndexEntry } from \"~/types\";\nimport { createElasticsearchBody } from \"~/operations/entry/elasticsearch/body\";\nimport { createLatestRecordType, createPublishedRecordType, createRecordType } from \"./recordType\";\nimport { StorageOperationsCmsModelPlugin } from \"@webiny/api-headless-cms\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\n\nconst getEntryData = (input: CmsEntry): CmsEntry => {\n const output: any = {\n ...input\n };\n delete output[\"PK\"];\n delete output[\"SK\"];\n delete output[\"published\"];\n delete output[\"latest\"];\n\n return output;\n};\n\nconst getESLatestEntryData = async (plugins: PluginsContainer, entry: CmsEntry) => {\n return compress(plugins, {\n ...getEntryData(entry),\n latest: true,\n TYPE: createLatestRecordType(),\n __type: createLatestRecordType()\n });\n};\n\nconst getESPublishedEntryData = async (plugins: PluginsContainer, entry: CmsEntry) => {\n return compress(plugins, {\n ...getEntryData(entry),\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n });\n};\n\ninterface ConvertStorageEntryParams {\n entry: CmsStorageEntry;\n model: StorageOperationsCmsModel;\n}\nconst convertEntryKeysToStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyToStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n\nconst convertEntryKeysFromStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyFromStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n\ninterface ElasticsearchDbRecord {\n index: string;\n data: Record<string, string>;\n}\n\nexport interface CreateEntriesStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\nexport const createEntriesStorageOperations = (\n params: CreateEntriesStorageOperationsParams\n): CmsEntryStorageOperations => {\n const { entity, esEntity, elasticsearch, plugins } = params;\n\n let storageOperationsCmsModelPlugin: StorageOperationsCmsModelPlugin | undefined;\n const getStorageOperationsCmsModelPlugin = () => {\n if (storageOperationsCmsModelPlugin) {\n return storageOperationsCmsModelPlugin;\n }\n storageOperationsCmsModelPlugin = plugins.oneByType<StorageOperationsCmsModelPlugin>(\n StorageOperationsCmsModelPlugin.type\n );\n return storageOperationsCmsModelPlugin;\n };\n\n const getStorageOperationsModel = (model: CmsModel): StorageOperationsCmsModel => {\n const plugin = getStorageOperationsCmsModelPlugin();\n return plugin.getModel(model);\n };\n\n const dataLoaders = new DataLoadersHandler({\n entity\n });\n\n const create: CmsEntryStorageOperations[\"create\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const model = getStorageOperationsModel(initialModel);\n\n const isPublished = initialEntry.status === \"published\";\n const locked = isPublished ? true : initialEntry.locked;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({ ...entry, locked }),\n storageEntry: lodashCloneDeep({ ...storageEntry, locked })\n });\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n const esPublishedData = await getESPublishedEntryData(plugins, esEntry);\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n }),\n entity.putBatch({\n ...storageEntry,\n locked,\n ...latestKeys,\n TYPE: createLatestRecordType()\n })\n ];\n\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the DynamoDB table.\",\n ex.code || \"CREATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n const esItems = [\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: esLatestData\n })\n ];\n if (isPublished) {\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the Elasticsearch DynamoDB table.\",\n ex.code || \"CREATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n esEntry\n }\n );\n }\n\n return initialStorageEntry;\n };\n\n const createRevisionFrom: CmsEntryStorageOperations[\"createRevisionFrom\"] = async (\n initialModel,\n params\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n TYPE: createRecordType(),\n ...revisionKeys\n }),\n entity.putBatch({\n ...storageEntry,\n TYPE: createLatestRecordType(),\n ...latestKeys\n })\n ];\n\n const { index } = configurations.es({\n model\n });\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create revision from given entry in the DynamoDB table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n /**\n * Update the \"latest\" entry item in the Elasticsearch\n */\n try {\n await esEntity.put({\n ...latestKeys,\n index,\n data: esLatestData\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update latest entry in the DynamoDB Elasticsearch table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n /**\n * There are no modifications on the entry created so just return the data.\n */\n return initialStorageEntry;\n };\n\n const update: CmsEntryStorageOperations[\"update\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n const esItems = [];\n\n const { index: esIndex } = configurations.es({\n model\n });\n /**\n * Variable for the elasticsearch entry so we do not convert it more than once\n */\n let esEntry: CmsIndexEntry | undefined = undefined;\n /**\n * If the latest entry is the one being updated, we need to create a new latest entry records.\n */\n let elasticsearchLatestData: any = null;\n if (latestStorageEntry?.id === entry.id) {\n /**\n * First we update the regular DynamoDB table\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys,\n TYPE: createLatestSortKey()\n })\n );\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({\n ...entry,\n locked\n }),\n storageEntry: lodashCloneDeep({\n ...storageEntry,\n locked\n })\n });\n\n elasticsearchLatestData = await getESLatestEntryData(plugins, esEntry);\n\n esItems.push(\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: elasticsearchLatestData\n })\n );\n }\n let elasticsearchPublishedData = null;\n if (isPublished && publishedStorageEntry?.id === entry.id) {\n if (!elasticsearchLatestData) {\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n if (!esEntry) {\n esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({\n ...entry,\n locked\n }),\n storageEntry: lodashCloneDeep({\n ...storageEntry,\n locked\n })\n });\n }\n elasticsearchPublishedData = await getESPublishedEntryData(plugins, esEntry);\n } else {\n elasticsearchPublishedData = {\n ...elasticsearchLatestData,\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n };\n delete elasticsearchPublishedData.latest;\n }\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: elasticsearchPublishedData\n })\n );\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB records.\",\n ex.code || \"UPDATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n if (esItems.length === 0) {\n return initialStorageEntry;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB Elasticsearch records.\",\n ex.code || \"UPDATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const deleteEntry: CmsEntryStorageOperations[\"delete\"] = async (initialModel, params) => {\n const { entry } = params;\n const id = entry.id || entry.entryId;\n const model = getStorageOperationsModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = await queryAll<CmsEntry>({\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const esItems = await queryAll<CmsEntry>({\n entity: esEntity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const deleteItems = items.map(item => {\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n const deleteEsItems = esItems.map(item => {\n return esEntity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n try {\n await batchWriteAll({\n table: entity.table,\n items: deleteItems\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete entry records from DynamoDB table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n id\n }\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: deleteEsItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete entry records from DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n id\n }\n );\n }\n };\n\n const deleteRevision: CmsEntryStorageOperations[\"deleteRevision\"] = async (\n initialModel,\n params\n ) => {\n const { entry, latestEntry, latestStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const { index } = configurations.es({\n model\n });\n /**\n * We need published entry to delete it if necessary.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n /**\n * We need to delete all existing records of the given entry revision.\n */\n const items = [\n /**\n * Delete records of given entry revision.\n */\n entity.deleteBatch({\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n })\n ];\n\n const esItems = [];\n\n /**\n * If revision we are deleting is the published one as well, we need to delete those records as well.\n */\n if (publishedStorageEntry?.id === entry.id) {\n items.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n esItems.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n if (latestEntry && latestStorageEntry) {\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(latestEntry),\n storageEntry: lodashCloneDeep(latestStorageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n /**\n * In the end we need to set the new latest entry\n */\n items.push(\n entity.putBatch({\n ...latestStorageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestRecordType()\n })\n );\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write entry records to DynamoDB table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n latestStorageEntry\n }\n );\n }\n\n if (esItems.length === 0) {\n return;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not batch write entry records to DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n latestStorageEntry\n }\n );\n }\n };\n\n const deleteMultipleEntries: CmsEntryStorageOperations[\"deleteMultipleEntries\"] = async (\n initialModel,\n params\n ) => {\n const { entries } = params;\n const model = getStorageOperationsModel(initialModel);\n /**\n * First we need all the revisions of the entries we want to delete.\n */\n const revisions = await dataLoaders.getAllEntryRevisions({\n model,\n ids: entries\n });\n /**\n * Then we need to construct the queries for all the revisions and entries.\n */\n const items: Record<string, DocumentClient.WriteRequest>[] = [];\n const esItems: Record<string, DocumentClient.WriteRequest>[] = [];\n for (const id of entries) {\n /**\n * Latest item.\n */\n items.push(\n entity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"L\"\n })\n );\n esItems.push(\n esEntity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"L\"\n })\n );\n /**\n * Published item.\n */\n items.push(\n entity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"P\"\n })\n );\n esItems.push(\n esEntity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"P\"\n })\n );\n }\n /**\n * Exact revisions of all the entries\n */\n for (const revision of revisions) {\n items.push(\n entity.deleteBatch({\n PK: createPartitionKey({\n id: revision.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey({\n version: revision.version\n })\n })\n );\n }\n\n await batchWriteAll({\n table: entity.table,\n items\n });\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n };\n\n const list: CmsEntryStorageOperations[\"list\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const limit = createLimit(params.limit, 50);\n const { index } = configurations.es({\n model\n });\n\n try {\n const result = await elasticsearch.indices.exists({\n index\n });\n if (!result?.body) {\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: []\n };\n }\n } catch (ex) {\n throw new WebinyError(\n \"Could not determine if Elasticsearch index exists.\",\n \"ELASTICSEARCH_INDEX_CHECK_ERROR\",\n {\n error: ex,\n index\n }\n );\n }\n\n const body = createElasticsearchBody({\n model,\n params: {\n ...params,\n limit,\n after: decodeCursor(params.after)\n },\n plugins\n });\n\n let response: ElasticsearchSearchResponse<CmsIndexEntry>;\n try {\n response = await elasticsearch.search({\n index,\n body\n });\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code || \"ELASTICSEARCH_ERROR\", {\n error: ex,\n index,\n body,\n model\n });\n }\n\n const { hits, total } = response?.body?.hits || {};\n\n const items = extractEntriesFromIndex({\n plugins,\n model,\n entries: hits.map(item => item._source)\n }).map(item => {\n return convertEntryKeysFromStorage({\n model,\n entry: item\n });\n });\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;\n return {\n hasMoreItems,\n totalCount: total.value,\n cursor,\n items\n };\n };\n\n const get: CmsEntryStorageOperations[\"get\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const { items } = await list(model, {\n ...params,\n limit: 1\n });\n return items.shift() || null;\n };\n\n const publish: CmsEntryStorageOperations[\"publish\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n /**\n * We need currently published entry to check if need to remove it.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n let latestEsEntry: ElasticsearchDbRecord | null = null;\n try {\n latestEsEntry = await getRecord<ElasticsearchDbRecord>({\n entity: esEntity,\n keys: latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not read Elasticsearch latest or published data.\",\n ex.code || \"PUBLISH_BATCH_READ\",\n {\n error: ex,\n latestKeys: latestKeys,\n publishedKeys: publishedKeys\n }\n );\n }\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n const esItems = [];\n\n const { index } = configurations.es({\n model\n });\n\n if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {\n /**\n * If there is a `published` entry already, we need to set it to `unpublished`. We need to\n * execute two updates: update the previously published entry's status and the published entry record.\n * DynamoDB does not support `batchUpdate` - so here we load the previously published\n * entry's data to update its status within a batch operation. If, hopefully,\n * they introduce a true update batch operation, remove this `read` call.\n */\n const [previouslyPublishedEntry] = await dataLoaders.getRevisionById({\n model,\n ids: [publishedStorageEntry.id]\n });\n items.push(\n /**\n * Update currently published entry (unpublish it)\n */\n entity.putBatch({\n ...previouslyPublishedEntry,\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED,\n savedOn: entry.savedOn,\n TYPE: createRecordType(),\n PK: createPartitionKey(publishedStorageEntry),\n SK: createRevisionSortKey(publishedStorageEntry)\n })\n );\n }\n /**\n * Update the helper item in DB with the new published entry\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n\n /**\n * We need the latest entry to check if it needs to be updated as well in the Elasticsearch.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n if (latestStorageEntry?.id === entry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys\n })\n );\n }\n /**\n * If we are publishing the latest revision, let's also update the latest revision's status in ES.\n */\n if (latestEsEntry && latestStorageEntry?.id === entry.id) {\n /**\n * Need to decompress the data from Elasticsearch DynamoDB table.\n *\n * No need to transform it for the storage because it was fetched directly from the Elasticsearch table, where it sits transformed.\n */\n const latestEsEntryDataDecompressed: CmsEntry = (await decompress(\n plugins,\n latestEsEntry.data\n )) as any;\n\n esItems.push(\n esEntity.putBatch({\n index,\n PK: createPartitionKey(latestEsEntryDataDecompressed),\n SK: createLatestSortKey(),\n data: await getESLatestEntryData(plugins, {\n ...latestEsEntryDataDecompressed,\n status: CONTENT_ENTRY_STATUS.PUBLISHED,\n locked: true,\n savedOn: entry.savedOn,\n publishedOn: entry.publishedOn\n })\n })\n );\n }\n\n const preparedEntryData = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n /**\n * Update the published revision entry in ES.\n */\n const esPublishedData = await getESPublishedEntryData(plugins, preparedEntryData);\n\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index,\n data: esPublishedData\n })\n );\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store publish entry records in DynamoDB table.\",\n ex.code || \"PUBLISH_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store publish entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"PUBLISH_ES_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const unpublish: CmsEntryStorageOperations[\"unpublish\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createRecordType()\n })\n ];\n\n const esItems = [\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n ];\n /**\n * If we are unpublishing the latest revision, let's also update the latest revision entry's status in ES.\n */\n if (latestStorageEntry?.id === entry.id) {\n const { index } = configurations.es({\n model\n });\n\n const preparedEntryData = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, preparedEntryData);\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store unpublished entry records in DynamoDB table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store unpublished entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const getLatestRevisionByEntryId: CmsEntryStorageOperations[\"getLatestRevisionByEntryId\"] =\n async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getPublishedRevisionByEntryId: CmsEntryStorageOperations[\"getPublishedRevisionByEntryId\"] =\n async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisionById: CmsEntryStorageOperations[\"getRevisionById\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getRevisionById({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisions: CmsEntryStorageOperations[\"getRevisions\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getAllEntryRevisions({\n model,\n ids: [params.id]\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getByIds: CmsEntryStorageOperations[\"getByIds\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getRevisionById({\n model,\n ids: params.ids\n });\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getLatestByIds: CmsEntryStorageOperations[\"getLatestByIds\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: params.ids\n });\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPublishedByIds: CmsEntryStorageOperations[\"getPublishedByIds\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPreviousRevision: CmsEntryStorageOperations[\"getPreviousRevision\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const { tenant, locale } = model;\n const { entryId, version } = params;\n const queryParams: QueryOneParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id: entryId\n }),\n options: {\n lt: `REV#${zeroPad(version)}`,\n /**\n * We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.\n */\n filters: [\n {\n attr: \"TYPE\",\n eq: createRecordType()\n },\n {\n attr: \"version\",\n lt: version\n }\n ],\n reverse: true\n }\n };\n\n try {\n const result = await queryOne<CmsEntry>(queryParams);\n\n const entry = cleanupItem(entity, result);\n\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n entry,\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get previous version of given entry.\",\n ex.code || \"GET_PREVIOUS_VERSION_ERROR\",\n {\n ...params,\n error: ex,\n partitionKey: queryParams.partitionKey,\n options: queryParams.options,\n model\n }\n );\n }\n };\n\n const getUniqueFieldValues: CmsEntryStorageOperations[\"getUniqueFieldValues\"] = async (\n model,\n params\n ) => {\n const { where, fieldId } = params;\n\n const { index } = configurations.es({\n model\n });\n\n try {\n const result = await elasticsearch.indices.exists({\n index\n });\n if (!result?.body) {\n return [];\n }\n } catch (ex) {\n throw new WebinyError(\n \"Could not determine if Elasticsearch index exists.\",\n \"ELASTICSEARCH_INDEX_CHECK_ERROR\",\n {\n error: ex,\n index\n }\n );\n }\n\n const initialBody = createElasticsearchBody({\n model,\n params: {\n limit: 1,\n where\n },\n plugins\n });\n\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n throw new WebinyError(\n `Could not find field with given \"fieldId\" value.`,\n \"FIELD_NOT_FOUND\",\n {\n fieldId\n }\n );\n }\n\n const body: ElasticsearchSearchBody = {\n ...initialBody,\n /**\n * We do not need any hits returned, we only need the aggregations.\n */\n size: 0,\n aggregations: {\n getUniqueFieldValues: {\n terms: {\n field: `values.${field.storageId}.keyword`,\n size: 1000000\n }\n }\n }\n };\n\n let response: ElasticsearchSearchResponse<string> | undefined = undefined;\n\n try {\n response = await elasticsearch.search({\n index,\n body\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Error in the Elasticsearch query.\",\n ex.code || \"ELASTICSEARCH_ERROR\",\n {\n error: ex,\n index,\n model,\n body\n }\n );\n }\n\n const buckets = response.body.aggregations[\"getUniqueFieldValues\"]?.buckets || [];\n return buckets.map(file => {\n return {\n value: file.key,\n count: file.doc_count\n };\n });\n };\n\n return {\n create,\n createRevisionFrom,\n update,\n delete: deleteEntry,\n deleteRevision,\n deleteMultipleEntries,\n get,\n publish,\n unpublish,\n list,\n getLatestRevisionByEntryId,\n getPublishedRevisionByEntryId,\n getRevisionById,\n getRevisions,\n getByIds,\n getLatestByIds,\n getPublishedByIds,\n getPreviousRevision,\n getUniqueFieldValues,\n dataLoaders\n };\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AAOA;AACA;AAIA;AACA;AACA;AAMA;AACA;AAOA;AACA;AACA;AAMA;AACA;AACA;AAGA,MAAMA,YAAY,GAAIC,KAAe,IAAe;EAChD,MAAMC,MAAW,mCACVD,KAAK,CACX;EACD,OAAOC,MAAM,CAAC,IAAI,CAAC;EACnB,OAAOA,MAAM,CAAC,IAAI,CAAC;EACnB,OAAOA,MAAM,CAAC,WAAW,CAAC;EAC1B,OAAOA,MAAM,CAAC,QAAQ,CAAC;EAEvB,OAAOA,MAAM;AACjB,CAAC;AAED,MAAMC,oBAAoB,GAAG,OAAOC,OAAyB,EAAEC,KAAe,KAAK;EAC/E,OAAO,IAAAC,0BAAQ,EAACF,OAAO,8DAChBJ,YAAY,CAACK,KAAK,CAAC;IACtBE,MAAM,EAAE,IAAI;IACZC,IAAI,EAAE,IAAAC,kCAAsB,GAAE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AS;IACTvC,IAAI;IACJ3B,0BAA0B;IAC1BG,6BAA6B;IAC7BsD,eAAe;IACfU,YAAY;IACZC,QAAQ;IACRC,cAAc;IACdC,iBAAiB;IACjBC,mBAAmB;IACnBU,oBAAoB;IACpBlI;EACJ,CAAC;AACL,CAAC;AAAC"}
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb-es",
3
- "version": "0.0.0-unstable.c59b9cc5b9",
3
+ "version": "0.0.0-unstable.c7dec08bb0",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-headless-cms",
7
7
  "storage-operations",
8
8
  "dynamodb",
9
9
  "elasticsearch",
10
+ "ddb-es",
10
11
  "cms:ddb-es"
11
12
  ],
12
13
  "repository": {
@@ -23,14 +24,14 @@
23
24
  "license": "MIT",
24
25
  "dependencies": {
25
26
  "@babel/runtime": "7.20.13",
26
- "@webiny/api": "0.0.0-unstable.c59b9cc5b9",
27
- "@webiny/api-elasticsearch": "0.0.0-unstable.c59b9cc5b9",
28
- "@webiny/api-headless-cms": "0.0.0-unstable.c59b9cc5b9",
29
- "@webiny/db-dynamodb": "0.0.0-unstable.c59b9cc5b9",
30
- "@webiny/error": "0.0.0-unstable.c59b9cc5b9",
31
- "@webiny/handler-db": "0.0.0-unstable.c59b9cc5b9",
32
- "@webiny/plugins": "0.0.0-unstable.c59b9cc5b9",
33
- "@webiny/utils": "0.0.0-unstable.c59b9cc5b9",
27
+ "@webiny/api": "0.0.0-unstable.c7dec08bb0",
28
+ "@webiny/api-elasticsearch": "0.0.0-unstable.c7dec08bb0",
29
+ "@webiny/api-headless-cms": "0.0.0-unstable.c7dec08bb0",
30
+ "@webiny/db-dynamodb": "0.0.0-unstable.c7dec08bb0",
31
+ "@webiny/error": "0.0.0-unstable.c7dec08bb0",
32
+ "@webiny/handler-db": "0.0.0-unstable.c7dec08bb0",
33
+ "@webiny/plugins": "0.0.0-unstable.c7dec08bb0",
34
+ "@webiny/utils": "0.0.0-unstable.c7dec08bb0",
34
35
  "dataloader": "2.2.1",
35
36
  "dynamodb-toolbox": "0.3.5",
36
37
  "jsonpack": "1.1.5",
@@ -42,20 +43,16 @@
42
43
  "@babel/preset-env": "7.20.2",
43
44
  "@elastic/elasticsearch": "7.12.0",
44
45
  "@types/jsonpack": "1.1.2",
45
- "@webiny/api-dynamodb-to-elasticsearch": "0.0.0-unstable.c59b9cc5b9",
46
- "@webiny/api-i18n": "0.0.0-unstable.c59b9cc5b9",
47
- "@webiny/api-i18n-ddb": "0.0.0-unstable.c59b9cc5b9",
48
- "@webiny/api-security": "0.0.0-unstable.c59b9cc5b9",
49
- "@webiny/api-security-so-ddb": "0.0.0-unstable.c59b9cc5b9",
50
- "@webiny/api-tenancy": "0.0.0-unstable.c59b9cc5b9",
51
- "@webiny/api-tenancy-so-ddb": "0.0.0-unstable.c59b9cc5b9",
52
- "@webiny/cli": "0.0.0-unstable.c59b9cc5b9",
53
- "@webiny/handler": "0.0.0-unstable.c59b9cc5b9",
54
- "@webiny/handler-aws": "0.0.0-unstable.c59b9cc5b9",
55
- "@webiny/project-utils": "0.0.0-unstable.c59b9cc5b9",
56
- "jest": "28.1.3",
46
+ "@webiny/api-dynamodb-to-elasticsearch": "0.0.0-unstable.c7dec08bb0",
47
+ "@webiny/api-i18n": "0.0.0-unstable.c7dec08bb0",
48
+ "@webiny/api-security": "0.0.0-unstable.c7dec08bb0",
49
+ "@webiny/api-tenancy": "0.0.0-unstable.c7dec08bb0",
50
+ "@webiny/cli": "0.0.0-unstable.c7dec08bb0",
51
+ "@webiny/handler": "0.0.0-unstable.c7dec08bb0",
52
+ "@webiny/handler-aws": "0.0.0-unstable.c7dec08bb0",
53
+ "@webiny/project-utils": "0.0.0-unstable.c7dec08bb0",
54
+ "jest": "29.5.0",
57
55
  "jest-dynalite": "3.6.1",
58
- "jest-environment-node": "27.5.1",
59
56
  "prettier": "2.8.3",
60
57
  "rimraf": "3.0.2",
61
58
  "sinon": "9.2.4",
@@ -70,5 +67,5 @@
70
67
  "build": "yarn webiny run build",
71
68
  "watch": "yarn webiny run watch"
72
69
  },
73
- "gitHead": "c59b9cc5b96b7fd91388de93c7fff2d977d25220"
70
+ "gitHead": "c7dec08bb095467cca6a61381bd399d66b7bb147"
74
71
  }