@webiny/api-headless-cms-ddb 0.0.0-mt-3 → 0.0.0-unstable.2af142b57e

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.
Files changed (135) hide show
  1. package/definitions/entry.d.ts +2 -1
  2. package/definitions/entry.js +6 -12
  3. package/definitions/entry.js.map +1 -0
  4. package/definitions/group.d.ts +2 -1
  5. package/definitions/group.js +3 -12
  6. package/definitions/group.js.map +1 -0
  7. package/definitions/model.d.ts +2 -1
  8. package/definitions/model.js +8 -12
  9. package/definitions/model.js.map +1 -0
  10. package/definitions/settings.d.ts +2 -1
  11. package/definitions/settings.js +3 -12
  12. package/definitions/settings.js.map +1 -0
  13. package/definitions/system.d.ts +2 -1
  14. package/definitions/system.js +3 -12
  15. package/definitions/system.js.map +1 -0
  16. package/definitions/table.d.ts +2 -1
  17. package/definitions/table.js +0 -3
  18. package/definitions/table.js.map +1 -0
  19. package/dynamoDb/index.d.ts +1 -1
  20. package/dynamoDb/index.js +6 -17
  21. package/dynamoDb/index.js.map +1 -0
  22. package/dynamoDb/path/plainObject.d.ts +2 -3
  23. package/dynamoDb/path/plainObject.js +25 -25
  24. package/dynamoDb/path/plainObject.js.map +1 -0
  25. package/dynamoDb/storage/date.d.ts +3 -3
  26. package/dynamoDb/storage/date.js +80 -54
  27. package/dynamoDb/storage/date.js.map +1 -0
  28. package/dynamoDb/storage/longText.d.ts +7 -4
  29. package/dynamoDb/storage/longText.js +72 -64
  30. package/dynamoDb/storage/longText.js.map +1 -0
  31. package/dynamoDb/storage/richText.d.ts +2 -8
  32. package/dynamoDb/storage/richText.js +62 -77
  33. package/dynamoDb/storage/richText.js.map +1 -0
  34. package/dynamoDb/transformValue/datetime.d.ts +4 -2
  35. package/dynamoDb/transformValue/datetime.js +28 -30
  36. package/dynamoDb/transformValue/datetime.js.map +1 -0
  37. package/index.d.ts +1 -0
  38. package/index.js +50 -41
  39. package/index.js.map +1 -0
  40. package/operations/entry/dataLoaders.d.ts +12 -8
  41. package/operations/entry/dataLoaders.js +27 -52
  42. package/operations/entry/dataLoaders.js.map +1 -0
  43. package/operations/entry/filtering/createExpressions.d.ts +26 -0
  44. package/operations/entry/filtering/createExpressions.js +176 -0
  45. package/operations/entry/filtering/createExpressions.js.map +1 -0
  46. package/operations/entry/filtering/createFields.d.ts +14 -0
  47. package/operations/entry/filtering/createFields.js +105 -0
  48. package/operations/entry/filtering/createFields.js.map +1 -0
  49. package/operations/entry/filtering/extractSort.d.ts +17 -0
  50. package/operations/entry/filtering/extractSort.js +67 -0
  51. package/operations/entry/filtering/extractSort.js.map +1 -0
  52. package/operations/entry/filtering/filter.d.ts +15 -0
  53. package/operations/entry/filtering/filter.js +143 -0
  54. package/operations/entry/filtering/filter.js.map +1 -0
  55. package/operations/entry/filtering/fullTextSearch.d.ts +14 -0
  56. package/operations/entry/filtering/fullTextSearch.js +48 -0
  57. package/operations/entry/filtering/fullTextSearch.js.map +1 -0
  58. package/operations/entry/filtering/getValue.d.ts +5 -0
  59. package/operations/entry/filtering/getValue.js +63 -0
  60. package/operations/entry/filtering/getValue.js.map +1 -0
  61. package/operations/entry/filtering/index.d.ts +2 -0
  62. package/operations/entry/filtering/index.js +19 -0
  63. package/operations/entry/filtering/index.js.map +1 -0
  64. package/operations/entry/filtering/mapPlugins.d.ts +8 -0
  65. package/operations/entry/filtering/mapPlugins.js +31 -0
  66. package/operations/entry/filtering/mapPlugins.js.map +1 -0
  67. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -0
  68. package/operations/entry/filtering/plugins/defaultFilterCreate.js +41 -0
  69. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -0
  70. package/operations/entry/filtering/plugins/index.d.ts +1 -0
  71. package/operations/entry/filtering/plugins/index.js +13 -0
  72. package/operations/entry/filtering/plugins/index.js.map +1 -0
  73. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -0
  74. package/operations/entry/filtering/plugins/objectFilterCreate.js +86 -0
  75. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
  76. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -0
  77. package/operations/entry/filtering/plugins/refFilterCreate.js +71 -0
  78. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
  79. package/operations/entry/filtering/sort.d.ts +12 -0
  80. package/operations/entry/filtering/sort.js +69 -0
  81. package/operations/entry/filtering/sort.js.map +1 -0
  82. package/operations/entry/filtering/systemFields.d.ts +4 -0
  83. package/operations/entry/filtering/systemFields.js +70 -0
  84. package/operations/entry/filtering/systemFields.js.map +1 -0
  85. package/operations/entry/filtering/transform.d.ts +6 -0
  86. package/operations/entry/filtering/transform.js +16 -0
  87. package/operations/entry/filtering/transform.js.map +1 -0
  88. package/operations/entry/filtering/types.d.ts +40 -0
  89. package/operations/entry/filtering/types.js +5 -0
  90. package/operations/entry/filtering/types.js.map +1 -0
  91. package/operations/entry/filtering/values.d.ts +2 -0
  92. package/operations/entry/filtering/values.js +22 -0
  93. package/operations/entry/filtering/values.js.map +1 -0
  94. package/operations/entry/filtering/where.d.ts +5 -0
  95. package/operations/entry/filtering/where.js +32 -0
  96. package/operations/entry/filtering/where.js.map +1 -0
  97. package/operations/entry/index.d.ts +2 -2
  98. package/operations/entry/index.js +273 -309
  99. package/operations/entry/index.js.map +1 -0
  100. package/operations/entry/keys.js +7 -14
  101. package/operations/entry/keys.js.map +1 -0
  102. package/operations/entry/systemFields.js +24 -2
  103. package/operations/entry/systemFields.js.map +1 -0
  104. package/operations/group/index.d.ts +3 -2
  105. package/operations/group/index.js +9 -45
  106. package/operations/group/index.js.map +1 -0
  107. package/operations/model/index.d.ts +3 -2
  108. package/operations/model/index.js +13 -37
  109. package/operations/model/index.js.map +1 -0
  110. package/operations/settings/index.d.ts +3 -2
  111. package/operations/settings/index.js +7 -37
  112. package/operations/settings/index.js.map +1 -0
  113. package/operations/system/index.d.ts +3 -2
  114. package/operations/system/index.js +5 -28
  115. package/operations/system/index.js.map +1 -0
  116. package/package.json +22 -23
  117. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +22 -0
  118. package/plugins/CmsEntryFieldFilterPathPlugin.js +41 -0
  119. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -0
  120. package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
  121. package/plugins/CmsEntryFieldFilterPlugin.js +24 -0
  122. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
  123. package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
  124. package/plugins/CmsEntryFieldSortingPlugin.js +28 -0
  125. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
  126. package/plugins/index.d.ts +3 -0
  127. package/plugins/index.js +38 -0
  128. package/plugins/index.js.map +1 -0
  129. package/types.d.ts +2 -33
  130. package/types.js +0 -1
  131. package/types.js.map +1 -0
  132. package/dynamoDb/path/ref.d.ts +0 -3
  133. package/dynamoDb/path/ref.js +0 -27
  134. package/operations/entry/utils.d.ts +0 -31
  135. package/operations/entry/utils.js +0 -406
@@ -1,52 +1,58 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createEntriesStorageOperations = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
9
  var _error = _interopRequireDefault(require("@webiny/error"));
13
-
14
10
  var _dataLoaders = require("./dataLoaders");
15
-
16
11
  var _types = require("@webiny/api-headless-cms/types");
17
-
18
- var _utils = require("./utils");
19
-
20
12
  var _keys = require("./keys");
21
-
22
13
  var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
23
-
24
14
  var _query = require("@webiny/db-dynamodb/utils/query");
25
-
26
15
  var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
27
-
28
16
  var _cursor = require("@webiny/utils/cursor");
29
-
30
17
  var _zeroPad = require("@webiny/utils/zeroPad");
31
-
32
18
  var _apiHeadlessCms = require("@webiny/api-headless-cms");
33
-
34
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
35
-
36
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
37
-
19
+ var _createFields = require("./filtering/createFields");
20
+ var _filtering = require("./filtering");
38
21
  const createType = () => {
39
22
  return "cms.entry";
40
23
  };
41
-
42
24
  const createLatestType = () => {
43
25
  return `${createType()}.l`;
44
26
  };
45
-
46
27
  const createPublishedType = () => {
47
28
  return `${createType()}.p`;
48
29
  };
49
-
30
+ const convertToStorageEntry = params => {
31
+ const {
32
+ model,
33
+ storageEntry
34
+ } = params;
35
+ const values = model.convertValueKeyToStorage({
36
+ fields: model.fields,
37
+ values: storageEntry.values
38
+ });
39
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
40
+ values
41
+ });
42
+ };
43
+ const convertFromStorageEntry = params => {
44
+ const {
45
+ model,
46
+ storageEntry
47
+ } = params;
48
+ const values = model.convertValueKeyFromStorage({
49
+ fields: model.fields,
50
+ values: storageEntry.values
51
+ });
52
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
53
+ values
54
+ });
55
+ };
50
56
  const createEntriesStorageOperations = params => {
51
57
  const {
52
58
  entity,
@@ -59,48 +65,53 @@ const createEntriesStorageOperations = params => {
59
65
  collection[plugin.fieldType] = plugin;
60
66
  return collection;
61
67
  }, {});
62
-
63
68
  const createStorageTransformCallable = model => {
64
69
  return (field, value) => {
65
70
  const plugin = storageTransformPlugins[field.type];
66
-
67
71
  if (!plugin) {
68
72
  return value;
69
73
  }
70
-
71
74
  return plugin.fromStorage({
72
75
  model,
73
76
  field,
74
77
  value,
75
-
76
78
  getStoragePlugin(fieldType) {
77
79
  return storageTransformPlugins[fieldType] || storageTransformPlugins["*"];
78
80
  },
79
-
80
81
  plugins
81
82
  });
82
83
  };
83
84
  };
84
-
85
- const create = async (model, args) => {
85
+ const create = async (model, params) => {
86
86
  const {
87
87
  entry,
88
- storageEntry
89
- } = args;
90
- const partitionKey = (0, _keys.createPartitionKey)(entry);
88
+ storageEntry: initialStorageEntry
89
+ } = params;
90
+ const partitionKey = (0, _keys.createPartitionKey)({
91
+ id: entry.id,
92
+ locale: model.locale,
93
+ tenant: model.tenant
94
+ });
95
+ const isPublished = entry.status === "published";
96
+ const locked = isPublished ? true : entry.locked;
97
+ const storageEntry = convertToStorageEntry({
98
+ model,
99
+ storageEntry: initialStorageEntry
100
+ });
91
101
  /**
92
102
  * We need to:
93
103
  * - create new main entry item
94
104
  * - create new or update latest entry item
95
105
  */
96
-
97
- const items = [entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
106
+ const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
107
+ locked,
98
108
  PK: partitionKey,
99
109
  SK: (0, _keys.createRevisionSortKey)(entry),
100
110
  TYPE: createType(),
101
111
  GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
102
112
  GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
103
- })), entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
113
+ })), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
114
+ locked,
104
115
  PK: partitionKey,
105
116
  SK: (0, _keys.createLatestSortKey)(),
106
117
  TYPE: createLatestType(),
@@ -108,6 +119,19 @@ const createEntriesStorageOperations = params => {
108
119
  GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
109
120
  }))];
110
121
 
122
+ /**
123
+ * We need to create published entry if
124
+ */
125
+ if (isPublished) {
126
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
127
+ locked,
128
+ PK: partitionKey,
129
+ SK: (0, _keys.createPublishedSortKey)(),
130
+ TYPE: createLatestType(),
131
+ GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "P"),
132
+ GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
133
+ })));
134
+ }
111
135
  try {
112
136
  await (0, _batchWrite.batchWriteAll)({
113
137
  table: entity.table,
@@ -122,38 +146,40 @@ const createEntriesStorageOperations = params => {
122
146
  entry
123
147
  });
124
148
  }
125
-
126
- return storageEntry;
149
+ return initialStorageEntry;
127
150
  };
128
-
129
151
  const createRevisionFrom = async (model, params) => {
130
152
  const {
131
- originalEntry,
132
153
  entry,
133
- storageEntry,
134
- latestEntry
154
+ storageEntry: initialStorageEntry
135
155
  } = params;
136
- const partitionKey = (0, _keys.createPartitionKey)(storageEntry);
156
+ const partitionKey = (0, _keys.createPartitionKey)({
157
+ id: entry.id,
158
+ locale: model.locale,
159
+ tenant: model.tenant
160
+ });
161
+ const storageEntry = convertToStorageEntry({
162
+ storageEntry: initialStorageEntry,
163
+ model
164
+ });
137
165
  /**
138
166
  * We need to:
139
167
  * - create the main entry item
140
168
  * - update the last entry item to a current one
141
169
  */
142
-
143
- const items = [entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
170
+ const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
144
171
  PK: partitionKey,
145
172
  SK: (0, _keys.createRevisionSortKey)(storageEntry),
146
173
  TYPE: createType(),
147
174
  GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
148
175
  GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
149
- })), entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
176
+ })), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
150
177
  PK: partitionKey,
151
178
  SK: (0, _keys.createLatestSortKey)(),
152
179
  TYPE: createLatestType(),
153
180
  GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "L"),
154
181
  GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
155
182
  }))];
156
-
157
183
  try {
158
184
  await (0, _batchWrite.batchWriteAll)({
159
185
  table: entity.table,
@@ -165,8 +191,6 @@ const createEntriesStorageOperations = params => {
165
191
  } catch (ex) {
166
192
  throw new _error.default(ex.message || "Could not create revision from given entry.", ex.code || "CREATE_REVISION_ERROR", {
167
193
  error: ex,
168
- originalEntry,
169
- latestEntry,
170
194
  entry,
171
195
  storageEntry
172
196
  });
@@ -174,40 +198,56 @@ const createEntriesStorageOperations = params => {
174
198
  /**
175
199
  * There are no modifications on the entry created so just return the data.
176
200
  */
177
-
178
-
179
- return storageEntry;
201
+ return initialStorageEntry;
180
202
  };
181
-
182
203
  const update = async (model, params) => {
183
204
  const {
184
- originalEntry,
185
205
  entry,
186
- storageEntry
206
+ storageEntry: initialStorageEntry
187
207
  } = params;
188
- const partitionKey = (0, _keys.createPartitionKey)(originalEntry);
208
+ const partitionKey = (0, _keys.createPartitionKey)({
209
+ id: entry.id,
210
+ locale: model.locale,
211
+ tenant: model.tenant
212
+ });
213
+ const isPublished = entry.status === "published";
214
+ const locked = isPublished ? true : entry.locked;
189
215
  const items = [];
216
+ const storageEntry = convertToStorageEntry({
217
+ model,
218
+ storageEntry: initialStorageEntry
219
+ });
190
220
  /**
191
221
  * We need to:
192
222
  * - update the current entry
193
223
  * - update the latest entry if the current entry is the latest one
194
224
  */
195
-
196
- items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
225
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
226
+ locked,
197
227
  PK: partitionKey,
198
228
  SK: (0, _keys.createRevisionSortKey)(storageEntry),
199
229
  TYPE: createType(),
200
230
  GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
201
231
  GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
202
232
  })));
233
+ if (isPublished) {
234
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
235
+ locked,
236
+ PK: partitionKey,
237
+ SK: (0, _keys.createPublishedSortKey)(),
238
+ TYPE: createPublishedType(),
239
+ GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "P"),
240
+ GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
241
+ })));
242
+ }
243
+
203
244
  /**
204
245
  * We need the latest entry to update it as well if neccessary.
205
246
  */
206
-
207
247
  const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
208
-
209
248
  if (latestStorageEntry && latestStorageEntry.id === entry.id) {
210
- items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
249
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
250
+ locked,
211
251
  PK: partitionKey,
212
252
  SK: (0, _keys.createLatestSortKey)(),
213
253
  TYPE: createLatestType(),
@@ -215,7 +255,6 @@ const createEntriesStorageOperations = params => {
215
255
  GSI1_SK: (0, _keys.createGSISortKey)(entry)
216
256
  })));
217
257
  }
218
-
219
258
  try {
220
259
  await (0, _batchWrite.batchWriteAll)({
221
260
  table: entity.table,
@@ -224,30 +263,31 @@ const createEntriesStorageOperations = params => {
224
263
  dataLoaders.clearAll({
225
264
  model
226
265
  });
227
- return storageEntry;
266
+ return initialStorageEntry;
228
267
  } catch (ex) {
229
268
  throw new _error.default(ex.message || "Could not update entry.", ex.code || "UPDATE_ERROR", {
230
269
  error: ex,
231
- originalEntry,
232
270
  entry,
233
271
  latestStorageEntry
234
272
  });
235
273
  }
236
274
  };
237
-
238
275
  const deleteEntry = async (model, params) => {
239
276
  const {
240
277
  entry
241
278
  } = params;
242
279
  const queryAllParams = {
243
280
  entity,
244
- partitionKey: (0, _keys.createPartitionKey)(entry),
281
+ partitionKey: (0, _keys.createPartitionKey)({
282
+ id: entry.id,
283
+ locale: model.locale,
284
+ tenant: model.tenant
285
+ }),
245
286
  options: {
246
287
  gte: " "
247
288
  }
248
289
  };
249
290
  let records = [];
250
-
251
291
  try {
252
292
  records = await (0, _query.queryAll)(queryAllParams);
253
293
  } catch (ex) {
@@ -256,14 +296,12 @@ const createEntriesStorageOperations = params => {
256
296
  entry
257
297
  });
258
298
  }
259
-
260
299
  const items = records.map(item => {
261
300
  return entity.deleteBatch({
262
301
  PK: item.PK,
263
302
  SK: item.SK
264
303
  });
265
304
  });
266
-
267
305
  try {
268
306
  await (0, _batchWrite.batchWriteAll)({
269
307
  table: entity.table,
@@ -280,40 +318,45 @@ const createEntriesStorageOperations = params => {
280
318
  });
281
319
  }
282
320
  };
283
-
284
321
  const deleteRevision = async (model, params) => {
285
322
  const {
286
- entryToDelete,
287
- entryToSetAsLatest,
288
- storageEntryToSetAsLatest
323
+ entry,
324
+ latestEntry,
325
+ latestStorageEntry: initialLatestStorageEntry
289
326
  } = params;
290
- const partitionKey = (0, _keys.createPartitionKey)(entryToDelete);
327
+ const partitionKey = (0, _keys.createPartitionKey)({
328
+ id: entry.id,
329
+ locale: model.locale,
330
+ tenant: model.tenant
331
+ });
291
332
  const items = [entity.deleteBatch({
292
333
  PK: partitionKey,
293
- SK: (0, _keys.createRevisionSortKey)(entryToDelete)
334
+ SK: (0, _keys.createRevisionSortKey)(entry)
294
335
  })];
295
- const publishedStorageEntry = await getPublishedRevisionByEntryId(model, entryToDelete);
336
+ const publishedStorageEntry = await getPublishedRevisionByEntryId(model, entry);
337
+
296
338
  /**
297
339
  * If revision we are deleting is the published one as well, we need to delete those records as well.
298
340
  */
299
-
300
- if (publishedStorageEntry && entryToDelete.id === publishedStorageEntry.id) {
341
+ if (publishedStorageEntry && entry.id === publishedStorageEntry.id) {
301
342
  items.push(entity.deleteBatch({
302
343
  PK: partitionKey,
303
344
  SK: (0, _keys.createPublishedSortKey)()
304
345
  }));
305
346
  }
306
-
307
- if (storageEntryToSetAsLatest) {
308
- items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntryToSetAsLatest), {}, {
347
+ if (initialLatestStorageEntry) {
348
+ const latestStorageEntry = convertToStorageEntry({
349
+ storageEntry: initialLatestStorageEntry,
350
+ model
351
+ });
352
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestStorageEntry), {}, {
309
353
  PK: partitionKey,
310
354
  SK: (0, _keys.createLatestSortKey)(),
311
355
  TYPE: createLatestType(),
312
356
  GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "L"),
313
- GSI1_SK: (0, _keys.createGSISortKey)(storageEntryToSetAsLatest)
357
+ GSI1_SK: (0, _keys.createGSISortKey)(latestStorageEntry)
314
358
  })));
315
359
  }
316
-
317
360
  try {
318
361
  await (0, _batchWrite.batchWriteAll)({
319
362
  table: entity.table,
@@ -325,91 +368,102 @@ const createEntriesStorageOperations = params => {
325
368
  } catch (ex) {
326
369
  throw new _error.default(ex.message, ex.code, {
327
370
  error: ex,
328
- entryToDelete,
329
- entryToSetAsLatest
371
+ entry,
372
+ latestEntry
330
373
  });
331
374
  }
332
375
  };
333
-
334
- const getAllRevisionsByIds = async (model, params) => {
335
- return await dataLoaders.getAllEntryRevisions({
336
- model,
337
- ids: params.ids
338
- });
339
- };
340
-
341
376
  const getLatestRevisionByEntryId = async (model, params) => {
342
- const result = await dataLoaders.getLatestRevisionByEntryId({
377
+ const items = await dataLoaders.getLatestRevisionByEntryId({
343
378
  model,
344
379
  ids: [params.id]
345
380
  });
346
-
347
- if (result.length === 0) {
381
+ const item = items.shift() || null;
382
+ if (!item) {
348
383
  return null;
349
384
  }
350
-
351
- return result.shift();
385
+ return convertFromStorageEntry({
386
+ storageEntry: item,
387
+ model
388
+ });
352
389
  };
353
-
354
390
  const getPublishedRevisionByEntryId = async (model, params) => {
355
- const result = await dataLoaders.getPublishedRevisionByEntryId({
391
+ const items = await dataLoaders.getPublishedRevisionByEntryId({
356
392
  model,
357
393
  ids: [params.id]
358
394
  });
359
-
360
- if (result.length === 0) {
395
+ const item = items.shift() || null;
396
+ if (!item) {
361
397
  return null;
362
398
  }
363
-
364
- return result.shift();
399
+ return convertFromStorageEntry({
400
+ storageEntry: item,
401
+ model
402
+ });
365
403
  };
366
-
367
404
  const getRevisionById = async (model, params) => {
368
- const result = await dataLoaders.getRevisionById({
405
+ const items = await dataLoaders.getRevisionById({
369
406
  model,
370
407
  ids: [params.id]
371
408
  });
372
-
373
- if (result.length === 0) {
409
+ const item = items.shift() || null;
410
+ if (!item) {
374
411
  return null;
375
412
  }
376
-
377
- return result.shift();
413
+ return convertFromStorageEntry({
414
+ storageEntry: item,
415
+ model
416
+ });
378
417
  };
379
-
380
418
  const getRevisions = async (model, params) => {
381
- return await dataLoaders.getAllEntryRevisions({
419
+ const items = await dataLoaders.getAllEntryRevisions({
382
420
  model,
383
421
  ids: [params.id]
384
422
  });
423
+ return items.map(item => {
424
+ return convertFromStorageEntry({
425
+ storageEntry: item,
426
+ model
427
+ });
428
+ });
385
429
  };
386
-
387
430
  const getByIds = async (model, params) => {
388
- return dataLoaders.getRevisionById({
431
+ const items = await dataLoaders.getRevisionById({
389
432
  model,
390
433
  ids: params.ids
391
434
  });
435
+ return items.map(item => {
436
+ return convertFromStorageEntry({
437
+ storageEntry: item,
438
+ model
439
+ });
440
+ });
392
441
  };
393
-
394
442
  const getLatestByIds = async (model, params) => {
395
- return dataLoaders.getLatestRevisionByEntryId({
443
+ const items = await dataLoaders.getLatestRevisionByEntryId({
396
444
  model,
397
445
  ids: params.ids
398
446
  });
447
+ return items.map(item => {
448
+ return convertFromStorageEntry({
449
+ storageEntry: item,
450
+ model
451
+ });
452
+ });
399
453
  };
400
-
401
454
  const getPublishedByIds = async (model, params) => {
402
- return dataLoaders.getPublishedRevisionByEntryId({
455
+ const items = await dataLoaders.getPublishedRevisionByEntryId({
403
456
  model,
404
457
  ids: params.ids
405
458
  });
459
+ return items.map(item => {
460
+ return convertFromStorageEntry({
461
+ storageEntry: item,
462
+ model
463
+ });
464
+ });
406
465
  };
407
-
408
466
  const getPreviousRevision = async (model, params) => {
409
- const {
410
- tenant,
411
- locale
412
- } = model;
413
467
  const {
414
468
  entryId,
415
469
  version
@@ -417,13 +471,12 @@ const createEntriesStorageOperations = params => {
417
471
  const queryParams = {
418
472
  entity,
419
473
  partitionKey: (0, _keys.createPartitionKey)({
420
- tenant,
421
- locale,
474
+ tenant: model.tenant,
475
+ locale: model.locale,
422
476
  id: entryId
423
477
  }),
424
478
  options: {
425
479
  lt: `REV#${(0, _zeroPad.zeroPad)(version)}`,
426
-
427
480
  /**
428
481
  * We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.
429
482
  */
@@ -437,12 +490,18 @@ const createEntriesStorageOperations = params => {
437
490
  reverse: true
438
491
  }
439
492
  };
440
-
441
493
  try {
442
494
  const result = await (0, _query.queryOne)(queryParams);
443
- return (0, _cleanup.cleanupItem)(entity, result);
495
+ const storageEntry = (0, _cleanup.cleanupItem)(entity, result);
496
+ if (!storageEntry) {
497
+ return null;
498
+ }
499
+ return convertFromStorageEntry({
500
+ storageEntry,
501
+ model
502
+ });
444
503
  } catch (ex) {
445
- throw new _error.default(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", _objectSpread(_objectSpread({}, params), {}, {
504
+ throw new _error.default(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
446
505
  error: ex,
447
506
  partitionKey: queryParams.partitionKey,
448
507
  options: queryParams.options,
@@ -450,16 +509,17 @@ const createEntriesStorageOperations = params => {
450
509
  }));
451
510
  }
452
511
  };
453
-
454
512
  const list = async (model, params) => {
455
513
  const {
456
514
  limit: initialLimit = 10,
457
- where: originalWhere,
515
+ where: initialWhere,
458
516
  after,
459
- sort
517
+ sort: sortBy,
518
+ fields,
519
+ search
460
520
  } = params;
461
- const limit = initialLimit <= 0 || initialLimit >= 100 ? 100 : initialLimit;
462
- const type = originalWhere.published ? "P" : "L";
521
+ const limit = initialLimit <= 0 || initialLimit >= 10000 ? 10000 : initialLimit;
522
+ const type = initialWhere.published ? "P" : "L";
463
523
  const queryAllParams = {
464
524
  entity,
465
525
  partitionKey: (0, _keys.createGSIPartitionKey)(model, type),
@@ -468,10 +528,9 @@ const createEntriesStorageOperations = params => {
468
528
  gte: " "
469
529
  }
470
530
  };
471
- let records = [];
472
-
531
+ let storageEntries = [];
473
532
  try {
474
- records = await (0, _query.queryAll)(queryAllParams);
533
+ storageEntries = await (0, _query.queryAll)(queryAllParams);
475
534
  } catch (ex) {
476
535
  throw new _error.default(ex.message, "QUERY_ENTRIES_ERROR", {
477
536
  error: ex,
@@ -479,8 +538,7 @@ const createEntriesStorageOperations = params => {
479
538
  options: queryAllParams.options
480
539
  });
481
540
  }
482
-
483
- if (records.length === 0) {
541
+ if (storageEntries.length === 0) {
484
542
  return {
485
543
  hasMoreItems: false,
486
544
  totalCount: 0,
@@ -488,46 +546,61 @@ const createEntriesStorageOperations = params => {
488
546
  items: []
489
547
  };
490
548
  }
491
-
492
- const where = _objectSpread({}, originalWhere);
493
-
549
+ const where = (0, _objectSpread2.default)({}, initialWhere);
494
550
  delete where["published"];
495
551
  delete where["latest"];
496
- delete where["locale"];
497
- delete where["tenant"];
498
552
  /**
499
- * We need a object containing field, transformers and paths.
553
+ * We need an object containing field, transformers and paths.
500
554
  * Just build it here and pass on into other methods that require it to avoid mapping multiple times.
501
555
  */
502
-
503
- const modelFields = (0, _utils.buildModelFields)({
556
+ const modelFields = (0, _createFields.createFields)({
504
557
  plugins,
505
- model
558
+ fields: model.fields
506
559
  });
560
+ const fromStorage = createStorageTransformCallable(model);
561
+ /**
562
+ * Let's transform records from storage ones to regular ones, so we do not need to do it later.
563
+ *
564
+ * This is always being done, but at least its in parallel.
565
+ */
566
+ const records = await Promise.all(storageEntries.map(async storageEntry => {
567
+ const entry = convertFromStorageEntry({
568
+ storageEntry,
569
+ model
570
+ });
571
+ for (const field of model.fields) {
572
+ entry.values[field.fieldId] = await fromStorage(field, entry.values[field.fieldId]);
573
+ }
574
+ return entry;
575
+ }));
507
576
  /**
508
577
  * Filter the read items via the code.
509
578
  * It will build the filters out of the where input and transform the values it is using.
510
579
  */
511
-
512
- const filteredItems = await (0, _utils.filterItems)({
580
+ const filteredItems = (0, _filtering.filter)({
513
581
  items: records,
514
582
  where,
515
583
  plugins,
516
584
  fields: modelFields,
517
- fromStorage: createStorageTransformCallable(model)
585
+ fullTextSearch: {
586
+ term: search,
587
+ fields: fields || []
588
+ }
518
589
  });
519
590
  const totalCount = filteredItems.length;
591
+
520
592
  /**
521
593
  * Sorting is also done via the code.
522
594
  * It takes the sort input and sorts by it via the lodash sortBy method.
523
595
  */
524
-
525
- const sortedItems = (0, _utils.sortEntryItems)({
596
+ const sortedItems = (0, _filtering.sort)({
597
+ model,
598
+ plugins,
526
599
  items: filteredItems,
527
- sort,
600
+ sort: sortBy,
528
601
  fields: modelFields
529
602
  });
530
- const start = (0, _cursor.decodeCursor)(after) || 0;
603
+ const start = parseInt((0, _cursor.decodeCursor)(after) || "0") || 0;
531
604
  const hasMoreItems = totalCount > start + limit;
532
605
  const end = limit > totalCount + start + limit ? undefined : start + limit;
533
606
  const slicedItems = sortedItems.slice(start, end);
@@ -535,8 +608,7 @@ const createEntriesStorageOperations = params => {
535
608
  * Although we do not need a cursor here, we will use it as such to keep it standardized.
536
609
  * Number is simply encoded.
537
610
  */
538
-
539
- const cursor = totalCount > start + limit ? (0, _cursor.encodeCursor)(start + limit) : null;
611
+ const cursor = totalCount > start + limit ? (0, _cursor.encodeCursor)(`${start + limit}`) : null;
540
612
  return {
541
613
  hasMoreItems,
542
614
  totalCount,
@@ -544,141 +616,34 @@ const createEntriesStorageOperations = params => {
544
616
  items: (0, _cleanup.cleanupItems)(entity, slicedItems)
545
617
  };
546
618
  };
547
-
548
619
  const get = async (model, params) => {
549
620
  const {
550
621
  items
551
- } = await list(model, _objectSpread(_objectSpread({}, params), {}, {
622
+ } = await list(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
552
623
  limit: 1
553
624
  }));
554
-
555
- if (items.length === 0) {
556
- return null;
557
- }
558
-
559
- return items.shift();
625
+ return items.shift() || null;
560
626
  };
561
-
562
- const requestChanges = async (model, params) => {
563
- const {
564
- entry,
565
- storageEntry,
566
- originalEntry
567
- } = params;
568
- const partitionKey = (0, _keys.createPartitionKey)(entry);
569
- /**
570
- * We need to:
571
- * - update the existing entry
572
- * - update latest version - if existing entry is the latest version
573
- */
574
-
575
- const items = [entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
576
- TYPE: createType(),
577
- PK: partitionKey,
578
- SK: (0, _keys.createRevisionSortKey)(entry),
579
- GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
580
- GSI1_SK: (0, _keys.createGSISortKey)(entry)
581
- }))];
582
- /**
583
- * We need the latest entry to see if something needs to be updated along side the request changes one.
584
- */
585
-
586
- const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
587
-
588
- if (latestStorageEntry.id === entry.id) {
589
- items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
590
- PK: partitionKey,
591
- SK: (0, _keys.createLatestSortKey)(),
592
- TYPE: createLatestType(),
593
- GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "L"),
594
- GSI1_SK: (0, _keys.createGSISortKey)(entry)
595
- })));
596
- }
597
-
598
- try {
599
- await (0, _batchWrite.batchWriteAll)({
600
- table: entity.table,
601
- items
602
- });
603
- dataLoaders.clearAll({
604
- model
605
- });
606
- } catch (ex) {
607
- throw new _error.default(ex.message || "Could not execute the request changes batch.", ex.code || "REQUEST_CHANGES_ERROR", {
608
- entry,
609
- originalEntry
610
- });
611
- }
612
-
613
- return entry;
614
- };
615
-
616
- const requestReview = async (model, params) => {
617
- const {
618
- entry,
619
- storageEntry,
620
- originalEntry
621
- } = params;
622
- const partitionKey = (0, _keys.createPartitionKey)(entry);
623
- /**
624
- * We need to:
625
- * - update existing entry
626
- * - update latest entry - if existing entry is the latest entry
627
- */
628
-
629
- const items = [entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
630
- TYPE: createType(),
631
- PK: partitionKey,
632
- SK: (0, _keys.createRevisionSortKey)(entry),
633
- GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
634
- GSI1_SK: (0, _keys.createGSISortKey)(entry)
635
- }))];
636
- /**
637
- * We need the latest entry to see if something needs to be updated along side the request review one.
638
- */
639
-
640
- const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
641
-
642
- if (latestStorageEntry.id === entry.id) {
643
- items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
644
- PK: partitionKey,
645
- SK: (0, _keys.createLatestSortKey)(),
646
- TYPE: createLatestType(),
647
- GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "L"),
648
- GSI1_SK: (0, _keys.createGSISortKey)(entry)
649
- })));
650
- }
651
-
652
- try {
653
- await (0, _batchWrite.batchWriteAll)({
654
- table: entity.table,
655
- items
656
- });
657
- dataLoaders.clearAll({
658
- model
659
- });
660
- return entry;
661
- } catch (ex) {
662
- throw new _error.default(ex.message || "Could not execute request review batch.", ex.code || "REQUEST_REVIEW_ERROR", {
663
- entry,
664
- storageEntry,
665
- originalEntry
666
- });
667
- }
668
- };
669
-
670
627
  const publish = async (model, params) => {
671
628
  const {
672
629
  entry,
673
- storageEntry
630
+ storageEntry: initialStorageEntry
674
631
  } = params;
675
- const partitionKey = (0, _keys.createPartitionKey)(entry);
632
+ const partitionKey = (0, _keys.createPartitionKey)({
633
+ id: entry.id,
634
+ locale: model.locale,
635
+ tenant: model.tenant
636
+ });
637
+
676
638
  /**
677
639
  * We need the latest and published entries to see if something needs to be updated along side the publishing one.
678
640
  */
679
-
680
- const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
681
- const publishedStorageEntry = await getPublishedRevisionByEntryId(model, entry);
641
+ const initialLatestStorageEntry = await getLatestRevisionByEntryId(model, entry);
642
+ const initialPublishedStorageEntry = await getPublishedRevisionByEntryId(model, entry);
643
+ const storageEntry = convertToStorageEntry({
644
+ model,
645
+ storageEntry: initialStorageEntry
646
+ });
682
647
  /**
683
648
  * We need to update:
684
649
  * - current entry revision sort key
@@ -686,23 +651,21 @@ const createEntriesStorageOperations = params => {
686
651
  * - latest sort key - if entry updated is actually latest
687
652
  * - previous published entry to unpublished status - if any previously published entry
688
653
  */
689
-
690
- const items = [entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
654
+ const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
691
655
  PK: partitionKey,
692
656
  SK: (0, _keys.createRevisionSortKey)(entry),
693
657
  TYPE: createType(),
694
658
  GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
695
659
  GSI1_SK: (0, _keys.createGSISortKey)(entry)
696
- })), entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
660
+ })), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
697
661
  PK: partitionKey,
698
662
  SK: (0, _keys.createPublishedSortKey)(),
699
663
  TYPE: createPublishedType(),
700
664
  GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "P"),
701
665
  GSI1_SK: (0, _keys.createGSISortKey)(entry)
702
666
  }))];
703
-
704
- if (entry.id === latestStorageEntry.id) {
705
- items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
667
+ if (initialLatestStorageEntry && entry.id === initialLatestStorageEntry.id) {
668
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
706
669
  PK: partitionKey,
707
670
  SK: (0, _keys.createLatestSortKey)(),
708
671
  TYPE: createLatestType(),
@@ -710,9 +673,12 @@ const createEntriesStorageOperations = params => {
710
673
  GSI1_SK: (0, _keys.createGSISortKey)(entry)
711
674
  })));
712
675
  }
713
-
714
- if (publishedStorageEntry) {
715
- items.push(entity.putBatch(_objectSpread(_objectSpread({}, publishedStorageEntry), {}, {
676
+ if (initialPublishedStorageEntry && initialPublishedStorageEntry.id !== entry.id) {
677
+ const publishedStorageEntry = convertToStorageEntry({
678
+ storageEntry: initialPublishedStorageEntry,
679
+ model
680
+ });
681
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedStorageEntry), {}, {
716
682
  PK: partitionKey,
717
683
  SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry),
718
684
  TYPE: createType(),
@@ -721,7 +687,6 @@ const createEntriesStorageOperations = params => {
721
687
  GSI1_SK: (0, _keys.createGSISortKey)(publishedStorageEntry)
722
688
  })));
723
689
  }
724
-
725
690
  try {
726
691
  await (0, _batchWrite.batchWriteAll)({
727
692
  table: entity.table,
@@ -730,47 +695,52 @@ const createEntriesStorageOperations = params => {
730
695
  dataLoaders.clearAll({
731
696
  model
732
697
  });
733
- return entry;
698
+ return initialStorageEntry;
734
699
  } catch (ex) {
735
700
  throw new _error.default(ex.message || "Could not execute the publishing batch.", ex.code || "PUBLISH_ERROR", {
736
701
  entry,
737
- latestStorageEntry,
738
- publishedStorageEntry
702
+ latestStorageEntry: initialLatestStorageEntry,
703
+ publishedStorageEntry: initialPublishedStorageEntry
739
704
  });
740
705
  }
741
706
  };
742
-
743
707
  const unpublish = async (model, params) => {
744
708
  const {
745
709
  entry,
746
- storageEntry
710
+ storageEntry: initialStorageEntry
747
711
  } = params;
748
- const partitionKey = (0, _keys.createPartitionKey)(entry);
712
+ const partitionKey = (0, _keys.createPartitionKey)({
713
+ id: entry.id,
714
+ locale: model.locale,
715
+ tenant: model.tenant
716
+ });
717
+ const storageEntry = convertToStorageEntry({
718
+ storageEntry: initialStorageEntry,
719
+ model
720
+ });
749
721
  /**
750
722
  * We need to:
751
723
  * - delete currently published entry
752
724
  * - update current entry revision with new data
753
725
  * - update latest entry status - if entry being unpublished is latest
754
726
  */
755
-
756
727
  const items = [entity.deleteBatch({
757
728
  PK: partitionKey,
758
729
  SK: (0, _keys.createPublishedSortKey)()
759
- }), entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
730
+ }), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
760
731
  PK: partitionKey,
761
732
  SK: (0, _keys.createRevisionSortKey)(entry),
762
733
  TYPE: createType(),
763
734
  GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
764
735
  GSI1_SK: (0, _keys.createGSISortKey)(entry)
765
736
  }))];
737
+
766
738
  /**
767
739
  * We need the latest entry to see if something needs to be updated along side the unpublishing one.
768
740
  */
769
-
770
741
  const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
771
-
772
- if (entry.id === latestStorageEntry.id) {
773
- items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
742
+ if (latestStorageEntry && entry.id === latestStorageEntry.id) {
743
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
774
744
  PK: partitionKey,
775
745
  SK: (0, _keys.createLatestSortKey)(),
776
746
  TYPE: createLatestType(),
@@ -778,7 +748,6 @@ const createEntriesStorageOperations = params => {
778
748
  GSI1_SK: (0, _keys.createGSISortKey)(entry)
779
749
  })));
780
750
  }
781
-
782
751
  try {
783
752
  await (0, _batchWrite.batchWriteAll)({
784
753
  table: entity.table,
@@ -787,7 +756,7 @@ const createEntriesStorageOperations = params => {
787
756
  dataLoaders.clearAll({
788
757
  model
789
758
  });
790
- return storageEntry;
759
+ return initialStorageEntry;
791
760
  } catch (ex) {
792
761
  throw new _error.default(ex.message || "Could not execute unpublish batch.", ex.code || "UNPUBLISH_ERROR", {
793
762
  entry,
@@ -795,7 +764,6 @@ const createEntriesStorageOperations = params => {
795
764
  });
796
765
  }
797
766
  };
798
-
799
767
  return {
800
768
  create,
801
769
  createRevisionFrom,
@@ -808,16 +776,12 @@ const createEntriesStorageOperations = params => {
808
776
  getByIds,
809
777
  getRevisionById,
810
778
  getPublishedRevisionByEntryId,
811
- getAllRevisionsByIds,
812
779
  getLatestRevisionByEntryId,
813
780
  get,
814
781
  getRevisions,
815
- requestChanges,
816
- requestReview,
817
782
  publish,
818
783
  list,
819
784
  unpublish
820
785
  };
821
786
  };
822
-
823
787
  exports.createEntriesStorageOperations = createEntriesStorageOperations;