@webiny/api-headless-cms-ddb-es 5.35.2 → 5.36.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _helpers = require("../../helpers");
7
8
  /**
8
9
  * TODO remove rawValue when field aliases and field types targeting will be active.
9
10
  *
@@ -28,23 +29,27 @@ const processToIndex = ({
28
29
  if (!plugin || !plugin.toIndex) {
29
30
  return values;
30
31
  }
32
+ const identifiers = (0, _helpers.getFieldIdentifiers)(sourceValue, sourceRawValue, field);
33
+ if (!identifiers) {
34
+ return values;
35
+ }
31
36
  const {
32
37
  value,
33
38
  rawValue
34
39
  } = plugin.toIndex({
35
40
  model,
36
41
  field,
37
- value: sourceValue[field.storageId],
38
- rawValue: sourceRawValue[field.storageId],
42
+ value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],
43
+ rawValue: sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier],
39
44
  getFieldIndexPlugin,
40
45
  getFieldTypePlugin,
41
46
  plugins
42
47
  });
43
48
  if (value !== undefined) {
44
- values.value[field.storageId] = value;
49
+ values.value[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;
45
50
  }
46
51
  if (rawValue !== undefined) {
47
- values.rawValue[field.storageId] = rawValue;
52
+ values.rawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier] = rawValue;
48
53
  }
49
54
  return values;
50
55
  };
@@ -67,17 +72,21 @@ const processFromIndex = ({
67
72
  if (!plugin || !plugin.fromIndex) {
68
73
  return values;
69
74
  }
75
+ const identifiers = (0, _helpers.getFieldIdentifiers)(sourceValue, sourceRawValue, field);
76
+ if (!identifiers) {
77
+ return values;
78
+ }
70
79
  const value = plugin.fromIndex({
71
80
  plugins,
72
81
  model,
73
82
  field,
74
- value: sourceValue[field.storageId],
75
- rawValue: sourceRawValue[field.storageId],
83
+ value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],
84
+ rawValue: sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier],
76
85
  getFieldIndexPlugin,
77
86
  getFieldTypePlugin
78
87
  });
79
88
  if (value !== undefined) {
80
- values[field.storageId] = value;
89
+ values[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;
81
90
  }
82
91
  return values;
83
92
  };
@@ -1 +1 @@
1
- {"version":3,"names":["processToIndex","fields","value","sourceValue","rawValue","sourceRawValue","getFieldIndexPlugin","getFieldTypePlugin","plugins","model","reducer","values","field","plugin","type","toIndex","storageId","undefined","reduce","processFromIndex","fromIndex","name","fieldType","initialValue","initialRawValue","settings","multipleValues","result","key","Object","keys","length","push","source","map","_","index"],"sources":["objectIndexing.ts"],"sourcesContent":["/**\n * TODO remove rawValue when field aliases and field types targeting will be active.\n *\n * Currently we use rawValue for the values that we do not want to be indexed.\n * When field aliases and types in the value path will be active, we can target the keys directly.\n *\n * This change will be incompatible with the current systems so we will need to release a major version.\n *\n */\n\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport {\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin\n} from \"@webiny/api-headless-cms/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface ProcessToIndex {\n (params: {\n fields: CmsModelField[];\n value: Record<string, any>;\n rawValue: Record<string, any>;\n getFieldIndexPlugin: (fieldType: string) => CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin: (fieldType: string) => CmsModelFieldToGraphQLPlugin;\n plugins: PluginsContainer;\n model: CmsModel;\n }): Record<\"value\" | \"rawValue\", Record<string, any>>;\n}\n\ninterface ProcessFromIndex {\n (params: {\n fields: CmsModelField[];\n value: Record<string, any>;\n rawValue: Record<string, any>;\n getFieldIndexPlugin: (fieldType: string) => CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin: (fieldType: string) => CmsModelFieldToGraphQLPlugin;\n plugins: PluginsContainer;\n model: CmsModel;\n }): Record<string, any>;\n}\n\ninterface ReducerValue {\n value: {\n [key: string]: string;\n };\n rawValue: {\n [key: string]: string;\n };\n}\n\nconst processToIndex: ProcessToIndex = ({\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n plugins,\n model\n}) => {\n const reducer = (values: ReducerValue, field: CmsModelField) => {\n const plugin = getFieldIndexPlugin(field.type);\n if (!plugin || !plugin.toIndex) {\n return values;\n }\n const { value, rawValue } = plugin.toIndex({\n model,\n field,\n value: sourceValue[field.storageId],\n rawValue: sourceRawValue[field.storageId],\n getFieldIndexPlugin,\n getFieldTypePlugin,\n plugins\n });\n\n if (value !== undefined) {\n values.value[field.storageId] = value;\n }\n if (rawValue !== undefined) {\n values.rawValue[field.storageId] = rawValue;\n }\n\n return values;\n };\n\n return fields.reduce(reducer, { value: {}, rawValue: {} });\n};\nconst processFromIndex: ProcessFromIndex = ({\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n plugins,\n model\n}) => {\n const reducer = (values: Record<string, string>, field: CmsModelField) => {\n const plugin = getFieldIndexPlugin(field.type);\n if (!plugin || !plugin.fromIndex) {\n return values;\n }\n const value = plugin.fromIndex({\n plugins,\n model,\n field,\n value: sourceValue[field.storageId],\n rawValue: sourceRawValue[field.storageId],\n getFieldIndexPlugin,\n getFieldTypePlugin\n });\n\n if (value !== undefined) {\n values[field.storageId] = value;\n }\n\n return values;\n };\n\n return fields.reduce(reducer, {});\n};\n\ninterface ToIndexMultipleFieldValue {\n value: Record<string, string>[];\n rawValue: Record<string, string>[];\n}\n\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-object\",\n fieldType: \"object\",\n toIndex({\n plugins,\n model,\n field,\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndexPlugin,\n getFieldTypePlugin\n }) {\n if (!initialValue) {\n return { value: null };\n }\n\n const fields = (field.settings?.fields || []) as CmsModelField[];\n\n /**\n * In \"object\" field, value is either an object or an array of objects.\n */\n if (field.multipleValues) {\n const result: ToIndexMultipleFieldValue = {\n value: [],\n rawValue: []\n };\n for (const key in initialValue) {\n const { value, rawValue } = processToIndex({\n value: initialValue[key],\n rawValue: initialRawValue[key],\n getFieldIndexPlugin,\n getFieldTypePlugin,\n model,\n plugins,\n fields\n });\n if (Object.keys(value).length > 0) {\n result.value.push(value);\n }\n\n if (Object.keys(rawValue).length > 0) {\n result.rawValue.push(rawValue);\n }\n }\n\n return {\n value: result.value.length > 0 ? result.value : undefined,\n rawValue: result.rawValue.length > 0 ? result.rawValue : undefined\n };\n }\n\n return processToIndex({\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n model,\n plugins,\n fields\n });\n },\n fromIndex({ field, value, rawValue, model, plugins, getFieldIndexPlugin, getFieldTypePlugin }) {\n if (!value) {\n return null;\n }\n\n const fields = field.settings?.fields || [];\n\n /**\n * In \"object\" field, value is either an object or an array of objects.\n */\n if (field.multipleValues) {\n /**\n * Why this `value || rawValue || []`?\n * It's possible that an object contains all non-indexable fields, or vice-versa, and so\n * we can never be sure which array we can reliably use as a source of values.\n */\n const source = value || rawValue || [];\n\n return source.map((_: any, index: number) =>\n processFromIndex({\n value: value ? value[index] || {} : {},\n rawValue: rawValue ? rawValue[index] || {} : {},\n getFieldIndexPlugin,\n getFieldTypePlugin,\n model,\n plugins,\n fields\n })\n );\n }\n\n return processFromIndex({\n value,\n rawValue,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n model,\n plugins,\n fields\n });\n }\n});\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA2CA,MAAMA,cAA8B,GAAG,CAAC;EACpCC,MAAM;EACNC,KAAK,EAAEC,WAAW;EAClBC,QAAQ,EAAEC,c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,CAACc,cAAc,EAAE;MACtB;AACZ;AACA;AACA;AACA;MACY,MAAMO,MAAM,GAAG/B,KAAK,IAAIE,QAAQ,IAAI,EAAE;MAEtC,OAAO6B,MAAM,CAACC,GAAG,CAAC,CAACC,CAAM,EAAEC,KAAa,KACpCjB,gBAAgB,CAAC;QACbjB,KAAK,EAAEA,KAAK,GAAGA,KAAK,CAACkC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACtChC,QAAQ,EAAEA,QAAQ,GAAGA,QAAQ,CAACgC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAC/C9B,mBAAmB;QACnBC,kBAAkB;QAClBE,KAAK;QACLD,OAAO;QACPP;MACJ,CAAC,CAAC,CACL;IACL;IAEA,OAAOkB,gBAAgB,CAAC;MACpBjB,KAAK;MACLE,QAAQ;MACRE,mBAAmB;MACnBC,kBAAkB;MAClBE,KAAK;MACLD,OAAO;MACPP;IACJ,CAAC,CAAC;EACN;AACJ,CAAC,CAAC;AAAA"}
1
+ {"version":3,"names":["processToIndex","fields","value","sourceValue","rawValue","sourceRawValue","getFieldIndexPlugin","getFieldTypePlugin","plugins","model","reducer","values","field","plugin","type","toIndex","identifiers","getFieldIdentifiers","valueIdentifier","rawValueIdentifier","undefined","reduce","processFromIndex","fromIndex","name","fieldType","initialValue","initialRawValue","settings","multipleValues","result","key","Object","keys","length","push","source","map","_","index"],"sources":["objectIndexing.ts"],"sourcesContent":["/**\n * TODO remove rawValue when field aliases and field types targeting will be active.\n *\n * Currently we use rawValue for the values that we do not want to be indexed.\n * When field aliases and types in the value path will be active, we can target the keys directly.\n *\n * This change will be incompatible with the current systems so we will need to release a major version.\n *\n */\n\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport {\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin\n} from \"@webiny/api-headless-cms/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { getFieldIdentifiers } from \"~/helpers\";\n\ninterface ProcessToIndex {\n (params: {\n fields: CmsModelField[];\n value: Record<string, any>;\n rawValue: Record<string, any>;\n getFieldIndexPlugin: (fieldType: string) => CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin: (fieldType: string) => CmsModelFieldToGraphQLPlugin;\n plugins: PluginsContainer;\n model: CmsModel;\n }): Record<\"value\" | \"rawValue\", Record<string, any>>;\n}\n\ninterface ProcessFromIndex {\n (params: {\n fields: CmsModelField[];\n value: Record<string, any>;\n rawValue: Record<string, any>;\n getFieldIndexPlugin: (fieldType: string) => CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin: (fieldType: string) => CmsModelFieldToGraphQLPlugin;\n plugins: PluginsContainer;\n model: CmsModel;\n }): Record<string, any>;\n}\n\ninterface ReducerValue {\n value: {\n [key: string]: string;\n };\n rawValue: {\n [key: string]: string;\n };\n}\n\nconst processToIndex: ProcessToIndex = ({\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n plugins,\n model\n}) => {\n const reducer = (values: ReducerValue, field: CmsModelField) => {\n const plugin = getFieldIndexPlugin(field.type);\n if (!plugin || !plugin.toIndex) {\n return values;\n }\n\n const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);\n if (!identifiers) {\n return values;\n }\n\n const { value, rawValue } = plugin.toIndex({\n model,\n field,\n value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],\n rawValue: sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier],\n getFieldIndexPlugin,\n getFieldTypePlugin,\n plugins\n });\n\n if (value !== undefined) {\n values.value[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;\n }\n if (rawValue !== undefined) {\n values.rawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier] =\n rawValue;\n }\n\n return values;\n };\n\n return fields.reduce(reducer, { value: {}, rawValue: {} });\n};\nconst processFromIndex: ProcessFromIndex = ({\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n plugins,\n model\n}) => {\n const reducer = (values: Record<string, string>, field: CmsModelField) => {\n const plugin = getFieldIndexPlugin(field.type);\n if (!plugin || !plugin.fromIndex) {\n return values;\n }\n const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);\n if (!identifiers) {\n return values;\n }\n\n const value = plugin.fromIndex({\n plugins,\n model,\n field,\n value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],\n rawValue: sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier],\n getFieldIndexPlugin,\n getFieldTypePlugin\n });\n\n if (value !== undefined) {\n values[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;\n }\n\n return values;\n };\n\n return fields.reduce(reducer, {});\n};\n\ninterface ToIndexMultipleFieldValue {\n value: Record<string, string>[];\n rawValue: Record<string, string>[];\n}\n\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-object\",\n fieldType: \"object\",\n toIndex({\n plugins,\n model,\n field,\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndexPlugin,\n getFieldTypePlugin\n }) {\n if (!initialValue) {\n return {\n value: null\n };\n }\n\n const fields = (field.settings?.fields || []) as CmsModelField[];\n\n /**\n * In \"object\" field, value is either an object or an array of objects.\n */\n if (field.multipleValues) {\n const result: ToIndexMultipleFieldValue = {\n value: [],\n rawValue: []\n };\n for (const key in initialValue) {\n const { value, rawValue } = processToIndex({\n value: initialValue[key],\n rawValue: initialRawValue[key],\n getFieldIndexPlugin,\n getFieldTypePlugin,\n model,\n plugins,\n fields\n });\n if (Object.keys(value).length > 0) {\n result.value.push(value);\n }\n\n if (Object.keys(rawValue).length > 0) {\n result.rawValue.push(rawValue);\n }\n }\n\n return {\n value: result.value.length > 0 ? result.value : undefined,\n rawValue: result.rawValue.length > 0 ? result.rawValue : undefined\n };\n }\n\n return processToIndex({\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n model,\n plugins,\n fields\n });\n },\n fromIndex({ field, value, rawValue, model, plugins, getFieldIndexPlugin, getFieldTypePlugin }) {\n if (!value) {\n return null;\n }\n\n const fields = field.settings?.fields || [];\n\n /**\n * In \"object\" field, value is either an object or an array of objects.\n */\n if (field.multipleValues) {\n /**\n * Why this `value || rawValue || []`?\n * It's possible that an object contains all non-indexable fields, or vice-versa, and so\n * we can never be sure which array we can reliably use as a source of values.\n */\n const source = value || rawValue || [];\n\n return source.map((_: any, index: number) =>\n processFromIndex({\n value: value ? value[index] || {} : {},\n rawValue: rawValue ? rawValue[index] || {} : {},\n getFieldIndexPlugin,\n getFieldTypePlugin,\n model,\n plugins,\n fields\n })\n );\n }\n\n return processFromIndex({\n value,\n rawValue,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n model,\n plugins,\n fields\n });\n }\n});\n"],"mappings":";;;;;;AAiBA;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4CA,MAAMA,cAA8B,GAAG,CAAC;EACpCC,MAAM;EACNC,KAAK,EAAEC,WAAW;EAClBC,QAAQ,EAAEC,cAAc;EACxBC,mBAAmB;EACnBC,kBAAkB;EAClBC,OAAO;EACPC;AACJ,CAAC,KAAK;EACF,MAAMC,OAAO,GAAG,CAACC,MAAoB,EAAEC,KAAoB,KAAK;IAC5D,MAAMC,MAAM,GAAGP,mBAAmB,CAACM,KAAK,CAACE,IAAI,CAAC;IAC9C,IAAI,CAACD,MAAM,IAAI,CAACA,MAAM,CAACE,OAAO,EAAE;MAC5B,OAAOJ,MAAM;IACjB;IAEA,MAAMK,WAAW,GAAG,IAAAC,4BAAmB,EAACd,WAAW,EAAEE,cAAc,EAAEO,KAAK,CAAC;IAC3E,IAAI,CAACI,WAAW,EAAE;MACd,OAAOL,MAAM;IACjB;IAEA,MAAM;MAAET,KAAK;MAAEE;IAAS,CAAC,GAAG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ACQ,IAAIW,KAAK,CAACiB,cAAc,EAAE;MACtB;AACZ;AACA;AACA;AACA;MACY,MAAMO,MAAM,GAAGlC,KAAK,IAAIE,QAAQ,IAAI,EAAE;MAEtC,OAAOgC,MAAM,CAACC,GAAG,CAAC,CAACC,CAAM,EAAEC,KAAa,KACpCjB,gBAAgB,CAAC;QACbpB,KAAK,EAAEA,KAAK,GAAGA,KAAK,CAACqC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACtCnC,QAAQ,EAAEA,QAAQ,GAAGA,QAAQ,CAACmC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAC/CjC,mBAAmB;QACnBC,kBAAkB;QAClBE,KAAK;QACLD,OAAO;QACPP;MACJ,CAAC,CAAC,CACL;IACL;IAEA,OAAOqB,gBAAgB,CAAC;MACpBpB,KAAK;MACLE,QAAQ;MACRE,mBAAmB;MACnBC,kBAAkB;MAClBE,KAAK;MACLD,OAAO;MACPP;IACJ,CAAC,CAAC;EACN;AACJ,CAAC,CAAC;AAAA"}
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.prepareEntryToIndex = exports.extractEntriesFromIndex = void 0;
8
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
9
  var _error = _interopRequireDefault(require("@webiny/error"));
10
+ var _fieldIdentifier = require("./fieldIdentifier");
10
11
  const prepareEntryToIndex = params => {
11
12
  const {
12
13
  plugins,
@@ -38,7 +39,8 @@ const prepareEntryToIndex = params => {
38
39
 
39
40
  // We're only interested in current model fields.
40
41
  for (const field of model.fields) {
41
- if (storageEntry.values.hasOwnProperty(field.storageId) === false) {
42
+ const identifier = (0, _fieldIdentifier.getFieldIdentifier)(storageEntry.values, field);
43
+ if (!identifier) {
42
44
  continue;
43
45
  }
44
46
  const targetFieldPlugin = getFieldIndexPlugin(field.type);
@@ -54,16 +56,16 @@ const prepareEntryToIndex = params => {
54
56
  plugins,
55
57
  model,
56
58
  field,
57
- rawValue: entry.values[field.storageId],
58
- value: storageEntry.values[field.storageId],
59
+ rawValue: entry.values[identifier],
60
+ value: storageEntry.values[identifier],
59
61
  getFieldIndexPlugin,
60
62
  getFieldTypePlugin
61
63
  });
62
64
  if (typeof value !== "undefined") {
63
- values[field.storageId] = value;
65
+ values[identifier] = value;
64
66
  }
65
67
  if (typeof rawValue !== "undefined") {
66
- rawValues[field.storageId] = rawValue;
68
+ rawValues[identifier] = rawValue;
67
69
  }
68
70
  }
69
71
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
@@ -129,18 +131,25 @@ const extractEntriesFromIndex = ({
129
131
  if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {
130
132
  continue;
131
133
  }
134
+ /**
135
+ * We can safely cast as the code will not continue in case of no identifiers.
136
+ */
137
+ const identifiers = (0, _fieldIdentifier.getFieldIdentifiers)(entry.values, entry.rawValues, field);
138
+ if (!identifiers) {
139
+ continue;
140
+ }
132
141
  try {
133
- indexValues[field.storageId] = targetFieldPlugin.fromIndex({
142
+ indexValues[identifiers.valueIdentifier] = targetFieldPlugin.fromIndex({
134
143
  plugins,
135
144
  model,
136
145
  field,
137
146
  getFieldIndexPlugin,
138
147
  getFieldTypePlugin,
139
- value: entry.values[field.storageId],
148
+ value: entry.values[identifiers.valueIdentifier || identifiers.rawValueIdentifier],
140
149
  /**
141
150
  * Possibly no rawValues so we must check for the existence of the field.
142
151
  */
143
- rawValue: entry.rawValues ? entry.rawValues[field.storageId] : null
152
+ rawValue: entry.rawValues ? entry.rawValues[identifiers.rawValueIdentifier || identifiers.valueIdentifier] : null
144
153
  });
145
154
  } catch (ex) {
146
155
  throw new _error.default(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
@@ -1 +1 @@
1
- {"version":3,"names":["prepareEntryToIndex","params","plugins","storageEntry","entry","model","fieldIndexPlugins","defaultIndexFieldPlugin","fieldTypePlugins","setupEntriesIndexHelpers","getFieldIndexPlugin","fieldType","getFieldTypePlugin","pl","WebinyError","values","rawValues","field","fields","hasOwnProperty","storageId","targetFieldPlugin","type","toIndex","value","rawValue","pluginsContainer","byType","plugin","reverse","find","reduce","extractEntriesFromIndex","entries","list","indexValues","fieldTypePlugin","fromIndex","ex","message","code","newEntry","push"],"sources":["entryIndexHelpers.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport { CmsIndexEntry, CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface SetupEntriesIndexHelpersParams {\n plugins: PluginsContainer;\n}\n\ninterface ExtractEntriesFromIndexParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry[];\n}\n\ninterface PrepareElasticsearchDataParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\nexport const prepareEntryToIndex = (params: PrepareElasticsearchDataParams): CmsIndexEntry => {\n const { plugins, storageEntry, entry, model } = params;\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n const pl = fieldTypePlugins[fieldType];\n if (pl) {\n return pl;\n }\n throw new WebinyError(`Missing field type plugin \"${fieldType}\". Prepare entry for index.`);\n }\n\n // These objects will contain values processed by field index plugins\n const values: Record<string, string> = {};\n const rawValues: Record<string, string> = {};\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n if (storageEntry.values.hasOwnProperty(field.storageId) === false) {\n continue;\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n\n // TODO: remove this `if` once we convert this plugin to proper plugin class\n if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {\n continue;\n }\n\n const { value, rawValue } = targetFieldPlugin.toIndex({\n plugins,\n model,\n field,\n rawValue: entry.values[field.storageId],\n value: storageEntry.values[field.storageId],\n getFieldIndexPlugin,\n getFieldTypePlugin\n });\n\n if (typeof value !== \"undefined\") {\n values[field.storageId] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[field.storageId] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n } as CmsIndexEntry;\n};\n\nconst setupEntriesIndexHelpers = ({\n plugins: pluginsContainer\n}: SetupEntriesIndexHelpersParams) => {\n const plugins = pluginsContainer.byType<CmsModelFieldToElasticsearchPlugin>(\n \"cms-model-field-to-elastic-search\"\n );\n\n const fieldIndexPlugins: Record<string, CmsModelFieldToElasticsearchPlugin> = {};\n for (const plugin of plugins.reverse()) {\n if (fieldIndexPlugins[plugin.fieldType]) {\n continue;\n }\n fieldIndexPlugins[plugin.fieldType] = plugin;\n }\n // we will use this plugin if no targeted plugin found\n const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === \"*\");\n\n // CmsModelFieldToGraphQLPlugin plugins\n const fieldTypePlugins: Record<string, CmsModelFieldToGraphQLPlugin> = pluginsContainer\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((plugins, plugin) => ({ ...plugins, [plugin.fieldType]: plugin }), {});\n\n return {\n fieldIndexPlugins,\n defaultIndexFieldPlugin,\n fieldTypePlugins\n };\n};\n\nexport const extractEntriesFromIndex = ({\n plugins,\n entries,\n model\n}: ExtractEntriesFromIndexParams): CmsEntry[] => {\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n return fieldTypePlugins[fieldType];\n }\n\n const list: CmsEntry[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: Record<string, string> = {};\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldTypePlugin = fieldTypePlugins[field.type];\n if (!fieldTypePlugin) {\n throw new WebinyError(\n `Missing field type plugin \"${field.type}\". Extract entries from index.`\n );\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {\n continue;\n }\n try {\n indexValues[field.storageId] = targetFieldPlugin.fromIndex({\n plugins,\n model,\n field,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n value: entry.values[field.storageId],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues ? entry.rawValues[field.storageId] : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-ignore\n delete newEntry[\"rawValues\"];\n // @ts-ignore\n delete newEntry[\"TYPE\"];\n // @ts-ignore\n delete newEntry[\"__type\"];\n // @ts-ignore\n delete newEntry[\"latest\"];\n // @ts-ignore\n delete newEntry[\"published\"];\n list.push({ ...newEntry });\n }\n\n return list;\n};\n"],"mappings":";;;;;;;;AAAA;AAoBO,MAAMA,mBAAmB,GAAIC,MAAsC,IAAoB;EAC1F,MAAM;IAAEC,OAAO;IAAEC,YAAY;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGJ,MAAM;EACtD,MAAM;IAAEK,iBAAiB;IAAEC,uBAAuB;IAAEC;EAAiB,CAAC,GAClEC,wBAAwB,CAAC;IAAEP;EAAQ,CAAC,CAAC;EAEzC,SAASQ,mBAAmB,CAACC,SAAiB,EA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,QAAQ,CAAC,MAAM,CAAC;IACvB;IACA,OAAOA,QAAQ,CAAC,QAAQ,CAAC;IACzB;IACA,OAAOA,QAAQ,CAAC,QAAQ,CAAC;IACzB;IACA,OAAOA,QAAQ,CAAC,WAAW,CAAC;IAC5BP,IAAI,CAACQ,IAAI,iCAAMD,QAAQ,EAAG;EAC9B;EAEA,OAAOP,IAAI;AACf,CAAC;AAAC"}
1
+ {"version":3,"names":["prepareEntryToIndex","params","plugins","storageEntry","entry","model","fieldIndexPlugins","defaultIndexFieldPlugin","fieldTypePlugins","setupEntriesIndexHelpers","getFieldIndexPlugin","fieldType","getFieldTypePlugin","pl","WebinyError","values","rawValues","field","fields","identifier","getFieldIdentifier","targetFieldPlugin","type","toIndex","value","rawValue","pluginsContainer","byType","plugin","reverse","find","reduce","extractEntriesFromIndex","entries","list","indexValues","fieldTypePlugin","fromIndex","identifiers","getFieldIdentifiers","valueIdentifier","rawValueIdentifier","ex","message","code","newEntry","push"],"sources":["entryIndexHelpers.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport { CmsIndexEntry, CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { getFieldIdentifier, getFieldIdentifiers } from \"~/helpers/fieldIdentifier\";\n\ninterface SetupEntriesIndexHelpersParams {\n plugins: PluginsContainer;\n}\n\ninterface ExtractEntriesFromIndexParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry[];\n}\n\ninterface PrepareElasticsearchDataParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\nexport const prepareEntryToIndex = (params: PrepareElasticsearchDataParams): CmsIndexEntry => {\n const { plugins, storageEntry, entry, model } = params;\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n const pl = fieldTypePlugins[fieldType];\n if (pl) {\n return pl;\n }\n throw new WebinyError(`Missing field type plugin \"${fieldType}\". Prepare entry for index.`);\n }\n\n // These objects will contain values processed by field index plugins\n const values: Record<string, string> = {};\n const rawValues: Record<string, string> = {};\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n const identifier = getFieldIdentifier(storageEntry.values, field);\n if (!identifier) {\n continue;\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n\n // TODO: remove this `if` once we convert this plugin to proper plugin class\n if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {\n continue;\n }\n\n const { value, rawValue } = targetFieldPlugin.toIndex({\n plugins,\n model,\n field,\n rawValue: entry.values[identifier],\n value: storageEntry.values[identifier],\n getFieldIndexPlugin,\n getFieldTypePlugin\n });\n\n if (typeof value !== \"undefined\") {\n values[identifier] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[identifier] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n } as CmsIndexEntry;\n};\n\nconst setupEntriesIndexHelpers = ({\n plugins: pluginsContainer\n}: SetupEntriesIndexHelpersParams) => {\n const plugins = pluginsContainer.byType<CmsModelFieldToElasticsearchPlugin>(\n \"cms-model-field-to-elastic-search\"\n );\n\n const fieldIndexPlugins: Record<string, CmsModelFieldToElasticsearchPlugin> = {};\n for (const plugin of plugins.reverse()) {\n if (fieldIndexPlugins[plugin.fieldType]) {\n continue;\n }\n fieldIndexPlugins[plugin.fieldType] = plugin;\n }\n // we will use this plugin if no targeted plugin found\n const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === \"*\");\n\n // CmsModelFieldToGraphQLPlugin plugins\n const fieldTypePlugins: Record<string, CmsModelFieldToGraphQLPlugin> = pluginsContainer\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((plugins, plugin) => ({ ...plugins, [plugin.fieldType]: plugin }), {});\n\n return {\n fieldIndexPlugins,\n defaultIndexFieldPlugin,\n fieldTypePlugins\n };\n};\n\nexport const extractEntriesFromIndex = ({\n plugins,\n entries,\n model\n}: ExtractEntriesFromIndexParams): CmsEntry[] => {\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n return fieldTypePlugins[fieldType];\n }\n\n const list: CmsEntry[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: Record<string, string> = {};\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldTypePlugin = fieldTypePlugins[field.type];\n if (!fieldTypePlugin) {\n throw new WebinyError(\n `Missing field type plugin \"${field.type}\". Extract entries from index.`\n );\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {\n continue;\n }\n /**\n * We can safely cast as the code will not continue in case of no identifiers.\n */\n const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);\n if (!identifiers) {\n continue;\n }\n\n try {\n indexValues[identifiers.valueIdentifier] = targetFieldPlugin.fromIndex({\n plugins,\n model,\n field,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n value: entry.values[\n identifiers.valueIdentifier || identifiers.rawValueIdentifier\n ],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues\n ? entry.rawValues[\n identifiers.rawValueIdentifier || identifiers.valueIdentifier\n ]\n : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-ignore\n delete newEntry[\"rawValues\"];\n // @ts-ignore\n delete newEntry[\"TYPE\"];\n // @ts-ignore\n delete newEntry[\"__type\"];\n // @ts-ignore\n delete newEntry[\"latest\"];\n // @ts-ignore\n delete newEntry[\"published\"];\n list.push({ ...newEntry });\n }\n\n return list;\n};\n"],"mappings":";;;;;;;;AAAA;AAIA;AAiBO,MAAMA,mBAAmB,GAAIC,MAAsC,IAAoB;EAC1F,MAAM;IAAEC,OAAO;IAAEC,YAAY;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGJ,MAAM;EACtD,MAAM;IAAEK,iBAAiB;IAAEC,uBAAuB;IAAEC;EAAiB,CAAC,GAClEC,wBAAwB,CAAC;IAAEP;EAAQ,CAAC,CAAC;EAEzC,SAASQ,mBAAmB,CAACC,SAAiB,EAAE;IAC5C,OAAOL,iBAAiB,CAACK,SAAS,CAAC,IAAIJ,uBAAuB;EAClE;EAEA,SAASK,kBAAkB,CAACD,SAAiB,EAAE;IAC3C,MAAME,EAAE,GAAGL,gBAAgB,CAACG,SAAS,CAAC;IACtC,IAAIE,EAAE,EAAE;MACJ,OAAOA,EAAE;IACb;IACA,MAAM,IAAIC,cAAW,CAAE,8BAA6BH,SAAU,6BAA4B,CAAC;EAC/F;;EAEA;EACA,MAAMI,MAA8B,GAAG,CAAC,CAAC;EACzC,MAAMC,SAAiC,GAAG,CAAC,CAAC;;EAE5C;EACA,KAAK,MAAMC,KAAK,IAAIZ,KAAK,CAACa,MAAM,EAAE;IAC9B,MAAMC,UAAU,GAAG,IAAAC,mCAAkB,EAACjB,YAAY,CAACY,MAAM,EAAEE,KAAK,CAAC;IACjE,IAAI,CAACE,UAAU,EAAE;MACb;IACJ;IAEA,MAAME,iBAAiB,GAAGX,mBAAmB,CAACO,KAAK,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CAAC;MAC7E,IAAI,CAACqB,WAAW,EAAE;QACd;MACJ;MAEA,IAAI;QACAH,WAAW,CAACG,WAAW,CAACE,eAAe,CAAC,GAAGnB,iBAAiB,CAACgB,SAAS,CAAC;UACnEnC,OAAO;UACPG,KAAK;UACLY,KAAK;UACLP,mBAAmB;UACnBE,kBAAkB;UAClBY,KAAK,EAAEpB,KAAK,CAACW,MAAM,CACfuB,WAAW,CAACE,eAAe,IAAIF,WAAW,CAACG,kBAAkB,CAChE;UACD;AACpB;AACA;UACoBhB,QAAQ,EAAErB,KAAK,CAACY,SAAS,GACnBZ,KAAK,CAACY,SAAS,CACXsB,WAAW,CAACG,kBAAkB,IAAIH,WAAW,CAACE,eAAe,CAChE,GACD;QACV,CAAC,CAAC;MACN,CAAC,CAAC,OAAOE,EAAE,EAAE;QACT,MAAM,IAAI5B,cAAW,CACjB4B,EAAE,CAACC,OAAO,IAAI,6CAA6C,EAC3DD,EAAE,CAACE,IAAI,IAAI,wBAAwB,EACnC;UACI3B,KAAK;UACLb;QACJ,CAAC,CACJ;MACL;IACJ;IACA;AACR;AACA;IACQ,MAAMyC,QAAkB,+DACjBzC,KAAK;MACRW,MAAM,EAAEoB;IAAW,EACtB;IACD;AACR;AACA;IACQ;IACA,OAAOU,QAAQ,CAAC,WAAW,CAAC;IAC5B;IACA,OAAOA,QAAQ,CAAC,MAAM,CAAC;IACvB;IACA,OAAOA,QAAQ,CAAC,QAAQ,CAAC;IACzB;IACA,OAAOA,QAAQ,CAAC,QAAQ,CAAC;IACzB;IACA,OAAOA,QAAQ,CAAC,WAAW,CAAC;IAC5BX,IAAI,CAACY,IAAI,iCAAMD,QAAQ,EAAG;EAC9B;EAEA,OAAOX,IAAI;AACf,CAAC;AAAC"}
@@ -0,0 +1,6 @@
1
+ import { CmsEntryValues, CmsModelField } from "@webiny/api-headless-cms/types";
2
+ export declare const getFieldIdentifier: (values: CmsEntryValues, field: CmsModelField) => string | undefined;
3
+ export declare const getFieldIdentifiers: (values: CmsEntryValues, rawValues: CmsEntryValues, field: CmsModelField) => {
4
+ valueIdentifier: string;
5
+ rawValueIdentifier: string;
6
+ } | null;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getFieldIdentifiers = exports.getFieldIdentifier = void 0;
7
+ const hasOwnProperty = (values, property) => {
8
+ if (values.hasOwnProperty) {
9
+ return values.hasOwnProperty(property);
10
+ }
11
+ return values[property] !== undefined;
12
+ };
13
+ const getFieldIdentifier = (values, field) => {
14
+ if (field.storageId && hasOwnProperty(values, field.storageId)) {
15
+ return field.storageId;
16
+ } else if (hasOwnProperty(values, field.fieldId)) {
17
+ return field.fieldId;
18
+ }
19
+ return undefined;
20
+ };
21
+ exports.getFieldIdentifier = getFieldIdentifier;
22
+ const getFieldIdentifiers = (values, rawValues, field) => {
23
+ let valueIdentifier = getFieldIdentifier(values, field);
24
+ let rawValueIdentifier = getFieldIdentifier(rawValues, field);
25
+ if (!valueIdentifier && !rawValueIdentifier) {
26
+ return null;
27
+ }
28
+ if (!valueIdentifier) {
29
+ valueIdentifier = rawValueIdentifier;
30
+ }
31
+ if (!rawValueIdentifier) {
32
+ rawValueIdentifier = valueIdentifier;
33
+ }
34
+ return {
35
+ valueIdentifier,
36
+ rawValueIdentifier
37
+ };
38
+ };
39
+ exports.getFieldIdentifiers = getFieldIdentifiers;
@@ -0,0 +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 +1,2 @@
1
1
  export * from "./entryIndexHelpers";
2
+ export * from "./fieldIdentifier";
package/helpers/index.js CHANGED
@@ -13,4 +13,15 @@ Object.keys(_entryIndexHelpers).forEach(function (key) {
13
13
  return _entryIndexHelpers[key];
14
14
  }
15
15
  });
16
+ });
17
+ var _fieldIdentifier = require("./fieldIdentifier");
18
+ Object.keys(_fieldIdentifier).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _fieldIdentifier[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _fieldIdentifier[key];
25
+ }
26
+ });
16
27
  });
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./entryIndexHelpers\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./entryIndexHelpers\";\nexport * from \"./fieldIdentifier\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -1217,6 +1217,76 @@ const createEntriesStorageOperations = params => {
1217
1217
  }));
1218
1218
  }
1219
1219
  };
1220
+ const getUniqueFieldValues = async (model, params) => {
1221
+ const {
1222
+ where,
1223
+ fieldId
1224
+ } = params;
1225
+ const {
1226
+ index
1227
+ } = _configurations.configurations.es({
1228
+ model
1229
+ });
1230
+ try {
1231
+ const result = await elasticsearch.indices.exists({
1232
+ index
1233
+ });
1234
+ if (!(result !== null && result !== void 0 && result.body)) {
1235
+ return [];
1236
+ }
1237
+ } catch (ex) {
1238
+ throw new _error.default("Could not determine if Elasticsearch index exists.", "ELASTICSEARCH_INDEX_CHECK_ERROR", {
1239
+ error: ex,
1240
+ index
1241
+ });
1242
+ }
1243
+ const initialBody = (0, _body.createElasticsearchBody)({
1244
+ model,
1245
+ params: {
1246
+ limit: 1,
1247
+ where
1248
+ },
1249
+ plugins
1250
+ });
1251
+ const field = model.fields.find(f => f.fieldId === fieldId);
1252
+ if (!field) {
1253
+ throw new _error.default(`Could not find field with given "fieldId" value.`, "FIELD_NOT_FOUND", {
1254
+ fieldId
1255
+ });
1256
+ }
1257
+ const body = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, initialBody), {}, {
1258
+ /**
1259
+ * We do not need any hits returned, we only need the aggregations.
1260
+ */
1261
+ size: 0,
1262
+ aggregations: {
1263
+ getUniqueFieldValues: {
1264
+ terms: {
1265
+ field: `values.${field.storageId}.keyword`,
1266
+ size: 1000000
1267
+ }
1268
+ }
1269
+ }
1270
+ });
1271
+ let response = undefined;
1272
+ try {
1273
+ response = await elasticsearch.search({
1274
+ index,
1275
+ body
1276
+ });
1277
+ } catch (ex) {
1278
+ throw new _error.default(ex.message || "Error in the Elasticsearch query.", ex.code || "ELASTICSEARCH_ERROR", {
1279
+ error: ex,
1280
+ index,
1281
+ model,
1282
+ body
1283
+ });
1284
+ }
1285
+ const values = response.body.aggregations["getUniqueFieldValues"] || {
1286
+ buckets: []
1287
+ };
1288
+ return values.buckets.map(item => item.key) || [];
1289
+ };
1220
1290
  return {
1221
1291
  create,
1222
1292
  createRevisionFrom,
@@ -1236,6 +1306,7 @@ const createEntriesStorageOperations = params => {
1236
1306
  getLatestByIds,
1237
1307
  getPublishedByIds,
1238
1308
  getPreviousRevision,
1309
+ getUniqueFieldValues,
1239
1310
  dataLoaders
1240
1311
  };
1241
1312
  };
@@ -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","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 { ElasticsearchSearchResponse } 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 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 dataLoaders\n };\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AAOA;AACA;AAIA;AACA;AACA;AAMA;AACA;AAOA;AACA;AACA;AAGA;AACA;AACA;AAGA,MAAMA,YAAY,GAAIC,KAAe,IAAe;EAChD,MAAMC,MAAW,mCACVD,KAA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O,EAAChD,OAAO,CAAE,EAAC;QAC7B;AAChB;AACA;QACgBiD,OAAO,EAAE,CACL;UACIC,IAAI,EAAE,MAAM;UACZC,EAAE,EAAE,IAAA7F,4BAAgB;QACxB,CAAC,EACD;UACI4F,IAAI,EAAE,SAAS;UACfH,EAAE,EAAE/C;QACR,CAAC,CACJ;QACDoD,OAAO,EAAE;MACb;IACJ,CAAC;IAED,IAAI;MACA,MAAMhD,MAAM,GAAG,MAAM,IAAAiD,eAAQ,EAAWP,WAAW,CAAC;MAEpD,MAAMtJ,KAAK,GAAG,IAAA8J,oBAAW,EAAC5I,MAAM,EAAE0F,MAAM,CAAC;MAEzC,IAAI,CAAC5G,KAAK,EAAE;QACR,OAAO,IAAI;MACf;MACA,OAAOe,2BAA2B,CAAC;QAC/Bf,KAAK;QACLW;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOwD,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,gDAAgD,EAC9DF,EAAE,CAACG,IAAI,IAAI,4BAA4B,8DAEhC5D,MAAM;QACT6D,KAAK,EAAEJ,EAAE;QACTqB,YAAY,EAAE8D,WAAW,CAAC9D,YAAY;QACtCE,OAAO,EAAE4D,WAAW,CAAC5D,OAAO;QAC5B/E;MAAK,GAEZ;IACL;EACJ,CAAC;EAED,OAAO;IACHoB,MAAM;IACN2C,kBAAkB;IAClBE,MAAM;IACNmF,MAAM,EAAEzE,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;IACnBxH;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","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,EA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BAA6B;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,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb-es",
3
- "version": "5.35.2",
3
+ "version": "5.36.0-beta.0",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-headless-cms",
@@ -23,14 +23,14 @@
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
25
  "@babel/runtime": "7.20.13",
26
- "@webiny/api": "^5.35.2",
27
- "@webiny/api-elasticsearch": "^5.35.2",
28
- "@webiny/api-headless-cms": "^5.35.2",
29
- "@webiny/db-dynamodb": "^5.35.2",
30
- "@webiny/error": "^5.35.2",
31
- "@webiny/handler-db": "^5.35.2",
32
- "@webiny/plugins": "^5.35.2",
33
- "@webiny/utils": "^5.35.2",
26
+ "@webiny/api": "5.36.0-beta.0",
27
+ "@webiny/api-elasticsearch": "5.36.0-beta.0",
28
+ "@webiny/api-headless-cms": "5.36.0-beta.0",
29
+ "@webiny/db-dynamodb": "5.36.0-beta.0",
30
+ "@webiny/error": "5.36.0-beta.0",
31
+ "@webiny/handler-db": "5.36.0-beta.0",
32
+ "@webiny/plugins": "5.36.0-beta.0",
33
+ "@webiny/utils": "5.36.0-beta.0",
34
34
  "dataloader": "2.2.1",
35
35
  "dynamodb-toolbox": "0.3.5",
36
36
  "jsonpack": "1.1.5",
@@ -42,21 +42,20 @@
42
42
  "@babel/preset-env": "7.20.2",
43
43
  "@elastic/elasticsearch": "7.12.0",
44
44
  "@types/jsonpack": "1.1.2",
45
- "@webiny/api-dynamodb-to-elasticsearch": "^5.35.2",
46
- "@webiny/api-i18n": "^5.35.2",
47
- "@webiny/api-i18n-ddb": "^5.35.2",
48
- "@webiny/api-security": "^5.35.2",
49
- "@webiny/api-security-so-ddb": "^5.35.2",
50
- "@webiny/api-tenancy": "^5.35.2",
51
- "@webiny/api-tenancy-so-ddb": "^5.35.2",
52
- "@webiny/cli": "^5.35.2",
53
- "@webiny/handler": "^5.35.2",
54
- "@webiny/handler-aws": "^5.35.2",
55
- "@webiny/project-utils": "^5.35.2",
45
+ "@webiny/api-dynamodb-to-elasticsearch": "5.36.0-beta.0",
46
+ "@webiny/api-i18n": "5.36.0-beta.0",
47
+ "@webiny/api-i18n-ddb": "5.36.0-beta.0",
48
+ "@webiny/api-security": "5.36.0-beta.0",
49
+ "@webiny/api-security-so-ddb": "5.36.0-beta.0",
50
+ "@webiny/api-tenancy": "5.36.0-beta.0",
51
+ "@webiny/api-tenancy-so-ddb": "5.36.0-beta.0",
52
+ "@webiny/cli": "5.36.0-beta.0",
53
+ "@webiny/handler": "5.36.0-beta.0",
54
+ "@webiny/handler-aws": "5.36.0-beta.0",
55
+ "@webiny/project-utils": "5.36.0-beta.0",
56
56
  "jest": "28.1.3",
57
57
  "jest-dynalite": "3.6.1",
58
58
  "jest-environment-node": "27.5.1",
59
- "mdbid": "1.0.0",
60
59
  "prettier": "2.8.3",
61
60
  "rimraf": "3.0.2",
62
61
  "sinon": "9.2.4",
@@ -71,5 +70,5 @@
71
70
  "build": "yarn webiny run build",
72
71
  "watch": "yarn webiny run watch"
73
72
  },
74
- "gitHead": "d3f7b134892b6c5ea794e9e7dd4811b27cdf6eb1"
73
+ "gitHead": "c59b9cc5b96b7fd91388de93c7fff2d977d25220"
75
74
  }