@webiny/api-headless-cms-ddb 0.0.0-unstable.3386f66516 → 0.0.0-unstable.496cf268ac
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/definitions/entry.js +3 -5
- package/definitions/entry.js.map +1 -1
- package/definitions/group.js +0 -5
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +17 -5
- package/definitions/model.js.map +1 -1
- package/definitions/settings.js +0 -5
- package/definitions/settings.js.map +1 -1
- package/definitions/system.js +0 -5
- package/definitions/system.js.map +1 -1
- package/definitions/table.js +0 -3
- package/definitions/table.js.map +1 -1
- package/dynamoDb/index.js +0 -7
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/plainObject.js +1 -8
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/storage/date.js +1 -19
- package/dynamoDb/storage/date.js.map +1 -1
- package/dynamoDb/storage/longText.js +1 -18
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +0 -18
- package/dynamoDb/storage/richText.js.map +1 -1
- package/dynamoDb/transformValue/datetime.js +1 -8
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.js +5 -30
- package/index.js.map +1 -1
- package/operations/entry/dataLoaders.js +1 -44
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.js +2 -39
- package/operations/entry/filtering/createExpressions.js.map +1 -1
- package/operations/entry/filtering/createFields.js +0 -18
- package/operations/entry/filtering/createFields.js.map +1 -1
- package/operations/entry/filtering/extractSort.js +0 -10
- package/operations/entry/filtering/extractSort.js.map +1 -1
- package/operations/entry/filtering/filter.js +1 -36
- package/operations/entry/filtering/filter.js.map +1 -1
- package/operations/entry/filtering/fullTextSearch.js +0 -12
- package/operations/entry/filtering/fullTextSearch.js.map +1 -1
- package/operations/entry/filtering/getValue.js +0 -18
- package/operations/entry/filtering/getValue.js.map +1 -1
- package/operations/entry/filtering/index.js +0 -2
- package/operations/entry/filtering/index.js.map +1 -1
- package/operations/entry/filtering/mapPlugins.js +0 -8
- package/operations/entry/filtering/mapPlugins.js.map +1 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -7
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/index.js +0 -5
- package/operations/entry/filtering/plugins/index.js.map +1 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -21
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/refFilterCreate.js +0 -18
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
- package/operations/entry/filtering/sort.js +0 -15
- package/operations/entry/filtering/sort.js.map +1 -1
- package/operations/entry/filtering/systemFields.js +0 -2
- package/operations/entry/filtering/systemFields.js.map +1 -1
- package/operations/entry/filtering/transform.js +0 -3
- package/operations/entry/filtering/transform.js.map +1 -1
- package/operations/entry/filtering/values.js +0 -6
- package/operations/entry/filtering/values.js.map +1 -1
- package/operations/entry/filtering/where.js +0 -6
- package/operations/entry/filtering/where.js.map +1 -1
- package/operations/entry/index.js +6 -93
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +0 -18
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/systemFields.js +0 -2
- package/operations/entry/systemFields.js.map +1 -1
- package/operations/group/index.js +2 -32
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js +0 -25
- package/operations/model/index.js.map +1 -1
- package/operations/settings/index.js +0 -24
- package/operations/settings/index.js.map +1 -1
- package/operations/system/index.js +0 -17
- package/operations/system/index.js.map +1 -1
- package/package.json +13 -13
- package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -14
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.js +0 -7
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldSortingPlugin.js +0 -10
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js +24 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +11 -6
- package/plugins/index.js.map +1 -1
- package/types.js +0 -1
- package/types.js.map +1 -1
|
@@ -1,50 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createEntriesStorageOperations = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
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
12
|
var _keys = require("./keys");
|
|
19
|
-
|
|
20
13
|
var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
|
|
21
|
-
|
|
22
14
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
23
|
-
|
|
24
15
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
25
|
-
|
|
26
16
|
var _cursor = require("@webiny/utils/cursor");
|
|
27
|
-
|
|
28
17
|
var _zeroPad = require("@webiny/utils/zeroPad");
|
|
29
|
-
|
|
30
18
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
31
|
-
|
|
32
19
|
var _createFields = require("./filtering/createFields");
|
|
33
|
-
|
|
34
20
|
var _filtering = require("./filtering");
|
|
35
|
-
|
|
36
21
|
const createType = () => {
|
|
37
22
|
return "cms.entry";
|
|
38
23
|
};
|
|
39
|
-
|
|
40
24
|
const createLatestType = () => {
|
|
41
25
|
return `${createType()}.l`;
|
|
42
26
|
};
|
|
43
|
-
|
|
44
27
|
const createPublishedType = () => {
|
|
45
28
|
return `${createType()}.p`;
|
|
46
29
|
};
|
|
47
|
-
|
|
48
30
|
const convertToStorageEntry = params => {
|
|
49
31
|
const {
|
|
50
32
|
model,
|
|
@@ -58,7 +40,6 @@ const convertToStorageEntry = params => {
|
|
|
58
40
|
values
|
|
59
41
|
});
|
|
60
42
|
};
|
|
61
|
-
|
|
62
43
|
const convertFromStorageEntry = params => {
|
|
63
44
|
const {
|
|
64
45
|
model,
|
|
@@ -72,7 +53,6 @@ const convertFromStorageEntry = params => {
|
|
|
72
53
|
values
|
|
73
54
|
});
|
|
74
55
|
};
|
|
75
|
-
|
|
76
56
|
const createEntriesStorageOperations = params => {
|
|
77
57
|
const {
|
|
78
58
|
entity,
|
|
@@ -85,29 +65,23 @@ const createEntriesStorageOperations = params => {
|
|
|
85
65
|
collection[plugin.fieldType] = plugin;
|
|
86
66
|
return collection;
|
|
87
67
|
}, {});
|
|
88
|
-
|
|
89
68
|
const createStorageTransformCallable = model => {
|
|
90
69
|
return (field, value) => {
|
|
91
70
|
const plugin = storageTransformPlugins[field.type];
|
|
92
|
-
|
|
93
71
|
if (!plugin) {
|
|
94
72
|
return value;
|
|
95
73
|
}
|
|
96
|
-
|
|
97
74
|
return plugin.fromStorage({
|
|
98
75
|
model,
|
|
99
76
|
field,
|
|
100
77
|
value,
|
|
101
|
-
|
|
102
78
|
getStoragePlugin(fieldType) {
|
|
103
79
|
return storageTransformPlugins[fieldType] || storageTransformPlugins["*"];
|
|
104
80
|
},
|
|
105
|
-
|
|
106
81
|
plugins
|
|
107
82
|
});
|
|
108
83
|
};
|
|
109
84
|
};
|
|
110
|
-
|
|
111
85
|
const create = async (model, params) => {
|
|
112
86
|
const {
|
|
113
87
|
entry,
|
|
@@ -129,7 +103,6 @@ const createEntriesStorageOperations = params => {
|
|
|
129
103
|
* - create new main entry item
|
|
130
104
|
* - create new or update latest entry item
|
|
131
105
|
*/
|
|
132
|
-
|
|
133
106
|
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
134
107
|
locked,
|
|
135
108
|
PK: partitionKey,
|
|
@@ -145,10 +118,10 @@ const createEntriesStorageOperations = params => {
|
|
|
145
118
|
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "L"),
|
|
146
119
|
GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
|
|
147
120
|
}))];
|
|
121
|
+
|
|
148
122
|
/**
|
|
149
123
|
* We need to create published entry if
|
|
150
124
|
*/
|
|
151
|
-
|
|
152
125
|
if (isPublished) {
|
|
153
126
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
154
127
|
locked,
|
|
@@ -159,7 +132,6 @@ const createEntriesStorageOperations = params => {
|
|
|
159
132
|
GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
|
|
160
133
|
})));
|
|
161
134
|
}
|
|
162
|
-
|
|
163
135
|
try {
|
|
164
136
|
await (0, _batchWrite.batchWriteAll)({
|
|
165
137
|
table: entity.table,
|
|
@@ -174,10 +146,8 @@ const createEntriesStorageOperations = params => {
|
|
|
174
146
|
entry
|
|
175
147
|
});
|
|
176
148
|
}
|
|
177
|
-
|
|
178
149
|
return initialStorageEntry;
|
|
179
150
|
};
|
|
180
|
-
|
|
181
151
|
const createRevisionFrom = async (model, params) => {
|
|
182
152
|
const {
|
|
183
153
|
entry,
|
|
@@ -197,7 +167,6 @@ const createEntriesStorageOperations = params => {
|
|
|
197
167
|
* - create the main entry item
|
|
198
168
|
* - update the last entry item to a current one
|
|
199
169
|
*/
|
|
200
|
-
|
|
201
170
|
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
202
171
|
PK: partitionKey,
|
|
203
172
|
SK: (0, _keys.createRevisionSortKey)(storageEntry),
|
|
@@ -211,7 +180,6 @@ const createEntriesStorageOperations = params => {
|
|
|
211
180
|
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "L"),
|
|
212
181
|
GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
|
|
213
182
|
}))];
|
|
214
|
-
|
|
215
183
|
try {
|
|
216
184
|
await (0, _batchWrite.batchWriteAll)({
|
|
217
185
|
table: entity.table,
|
|
@@ -230,11 +198,8 @@ const createEntriesStorageOperations = params => {
|
|
|
230
198
|
/**
|
|
231
199
|
* There are no modifications on the entry created so just return the data.
|
|
232
200
|
*/
|
|
233
|
-
|
|
234
|
-
|
|
235
201
|
return initialStorageEntry;
|
|
236
202
|
};
|
|
237
|
-
|
|
238
203
|
const update = async (model, params) => {
|
|
239
204
|
const {
|
|
240
205
|
entry,
|
|
@@ -257,7 +222,6 @@ const createEntriesStorageOperations = params => {
|
|
|
257
222
|
* - update the current entry
|
|
258
223
|
* - update the latest entry if the current entry is the latest one
|
|
259
224
|
*/
|
|
260
|
-
|
|
261
225
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
262
226
|
locked,
|
|
263
227
|
PK: partitionKey,
|
|
@@ -266,7 +230,6 @@ const createEntriesStorageOperations = params => {
|
|
|
266
230
|
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
|
|
267
231
|
GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
|
|
268
232
|
})));
|
|
269
|
-
|
|
270
233
|
if (isPublished) {
|
|
271
234
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
272
235
|
locked,
|
|
@@ -277,13 +240,11 @@ const createEntriesStorageOperations = params => {
|
|
|
277
240
|
GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
|
|
278
241
|
})));
|
|
279
242
|
}
|
|
243
|
+
|
|
280
244
|
/**
|
|
281
245
|
* We need the latest entry to update it as well if neccessary.
|
|
282
246
|
*/
|
|
283
|
-
|
|
284
|
-
|
|
285
247
|
const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
|
|
286
|
-
|
|
287
248
|
if (latestStorageEntry && latestStorageEntry.id === entry.id) {
|
|
288
249
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
289
250
|
locked,
|
|
@@ -294,7 +255,6 @@ const createEntriesStorageOperations = params => {
|
|
|
294
255
|
GSI1_SK: (0, _keys.createGSISortKey)(entry)
|
|
295
256
|
})));
|
|
296
257
|
}
|
|
297
|
-
|
|
298
258
|
try {
|
|
299
259
|
await (0, _batchWrite.batchWriteAll)({
|
|
300
260
|
table: entity.table,
|
|
@@ -312,7 +272,6 @@ const createEntriesStorageOperations = params => {
|
|
|
312
272
|
});
|
|
313
273
|
}
|
|
314
274
|
};
|
|
315
|
-
|
|
316
275
|
const deleteEntry = async (model, params) => {
|
|
317
276
|
const {
|
|
318
277
|
entry
|
|
@@ -329,7 +288,6 @@ const createEntriesStorageOperations = params => {
|
|
|
329
288
|
}
|
|
330
289
|
};
|
|
331
290
|
let records = [];
|
|
332
|
-
|
|
333
291
|
try {
|
|
334
292
|
records = await (0, _query.queryAll)(queryAllParams);
|
|
335
293
|
} catch (ex) {
|
|
@@ -338,14 +296,12 @@ const createEntriesStorageOperations = params => {
|
|
|
338
296
|
entry
|
|
339
297
|
});
|
|
340
298
|
}
|
|
341
|
-
|
|
342
299
|
const items = records.map(item => {
|
|
343
300
|
return entity.deleteBatch({
|
|
344
301
|
PK: item.PK,
|
|
345
302
|
SK: item.SK
|
|
346
303
|
});
|
|
347
304
|
});
|
|
348
|
-
|
|
349
305
|
try {
|
|
350
306
|
await (0, _batchWrite.batchWriteAll)({
|
|
351
307
|
table: entity.table,
|
|
@@ -362,7 +318,6 @@ const createEntriesStorageOperations = params => {
|
|
|
362
318
|
});
|
|
363
319
|
}
|
|
364
320
|
};
|
|
365
|
-
|
|
366
321
|
const deleteRevision = async (model, params) => {
|
|
367
322
|
const {
|
|
368
323
|
entry,
|
|
@@ -379,17 +334,16 @@ const createEntriesStorageOperations = params => {
|
|
|
379
334
|
SK: (0, _keys.createRevisionSortKey)(entry)
|
|
380
335
|
})];
|
|
381
336
|
const publishedStorageEntry = await getPublishedRevisionByEntryId(model, entry);
|
|
337
|
+
|
|
382
338
|
/**
|
|
383
339
|
* If revision we are deleting is the published one as well, we need to delete those records as well.
|
|
384
340
|
*/
|
|
385
|
-
|
|
386
341
|
if (publishedStorageEntry && entry.id === publishedStorageEntry.id) {
|
|
387
342
|
items.push(entity.deleteBatch({
|
|
388
343
|
PK: partitionKey,
|
|
389
344
|
SK: (0, _keys.createPublishedSortKey)()
|
|
390
345
|
}));
|
|
391
346
|
}
|
|
392
|
-
|
|
393
347
|
if (initialLatestStorageEntry) {
|
|
394
348
|
const latestStorageEntry = convertToStorageEntry({
|
|
395
349
|
storageEntry: initialLatestStorageEntry,
|
|
@@ -403,7 +357,6 @@ const createEntriesStorageOperations = params => {
|
|
|
403
357
|
GSI1_SK: (0, _keys.createGSISortKey)(latestStorageEntry)
|
|
404
358
|
})));
|
|
405
359
|
}
|
|
406
|
-
|
|
407
360
|
try {
|
|
408
361
|
await (0, _batchWrite.batchWriteAll)({
|
|
409
362
|
table: entity.table,
|
|
@@ -420,58 +373,48 @@ const createEntriesStorageOperations = params => {
|
|
|
420
373
|
});
|
|
421
374
|
}
|
|
422
375
|
};
|
|
423
|
-
|
|
424
376
|
const getLatestRevisionByEntryId = async (model, params) => {
|
|
425
377
|
const items = await dataLoaders.getLatestRevisionByEntryId({
|
|
426
378
|
model,
|
|
427
379
|
ids: [params.id]
|
|
428
380
|
});
|
|
429
381
|
const item = items.shift() || null;
|
|
430
|
-
|
|
431
382
|
if (!item) {
|
|
432
383
|
return null;
|
|
433
384
|
}
|
|
434
|
-
|
|
435
385
|
return convertFromStorageEntry({
|
|
436
386
|
storageEntry: item,
|
|
437
387
|
model
|
|
438
388
|
});
|
|
439
389
|
};
|
|
440
|
-
|
|
441
390
|
const getPublishedRevisionByEntryId = async (model, params) => {
|
|
442
391
|
const items = await dataLoaders.getPublishedRevisionByEntryId({
|
|
443
392
|
model,
|
|
444
393
|
ids: [params.id]
|
|
445
394
|
});
|
|
446
395
|
const item = items.shift() || null;
|
|
447
|
-
|
|
448
396
|
if (!item) {
|
|
449
397
|
return null;
|
|
450
398
|
}
|
|
451
|
-
|
|
452
399
|
return convertFromStorageEntry({
|
|
453
400
|
storageEntry: item,
|
|
454
401
|
model
|
|
455
402
|
});
|
|
456
403
|
};
|
|
457
|
-
|
|
458
404
|
const getRevisionById = async (model, params) => {
|
|
459
405
|
const items = await dataLoaders.getRevisionById({
|
|
460
406
|
model,
|
|
461
407
|
ids: [params.id]
|
|
462
408
|
});
|
|
463
409
|
const item = items.shift() || null;
|
|
464
|
-
|
|
465
410
|
if (!item) {
|
|
466
411
|
return null;
|
|
467
412
|
}
|
|
468
|
-
|
|
469
413
|
return convertFromStorageEntry({
|
|
470
414
|
storageEntry: item,
|
|
471
415
|
model
|
|
472
416
|
});
|
|
473
417
|
};
|
|
474
|
-
|
|
475
418
|
const getRevisions = async (model, params) => {
|
|
476
419
|
const items = await dataLoaders.getAllEntryRevisions({
|
|
477
420
|
model,
|
|
@@ -484,7 +427,6 @@ const createEntriesStorageOperations = params => {
|
|
|
484
427
|
});
|
|
485
428
|
});
|
|
486
429
|
};
|
|
487
|
-
|
|
488
430
|
const getByIds = async (model, params) => {
|
|
489
431
|
const items = await dataLoaders.getRevisionById({
|
|
490
432
|
model,
|
|
@@ -497,7 +439,6 @@ const createEntriesStorageOperations = params => {
|
|
|
497
439
|
});
|
|
498
440
|
});
|
|
499
441
|
};
|
|
500
|
-
|
|
501
442
|
const getLatestByIds = async (model, params) => {
|
|
502
443
|
const items = await dataLoaders.getLatestRevisionByEntryId({
|
|
503
444
|
model,
|
|
@@ -510,7 +451,6 @@ const createEntriesStorageOperations = params => {
|
|
|
510
451
|
});
|
|
511
452
|
});
|
|
512
453
|
};
|
|
513
|
-
|
|
514
454
|
const getPublishedByIds = async (model, params) => {
|
|
515
455
|
const items = await dataLoaders.getPublishedRevisionByEntryId({
|
|
516
456
|
model,
|
|
@@ -523,7 +463,6 @@ const createEntriesStorageOperations = params => {
|
|
|
523
463
|
});
|
|
524
464
|
});
|
|
525
465
|
};
|
|
526
|
-
|
|
527
466
|
const getPreviousRevision = async (model, params) => {
|
|
528
467
|
const {
|
|
529
468
|
entryId,
|
|
@@ -538,7 +477,6 @@ const createEntriesStorageOperations = params => {
|
|
|
538
477
|
}),
|
|
539
478
|
options: {
|
|
540
479
|
lt: `REV#${(0, _zeroPad.zeroPad)(version)}`,
|
|
541
|
-
|
|
542
480
|
/**
|
|
543
481
|
* We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.
|
|
544
482
|
*/
|
|
@@ -552,15 +490,12 @@ const createEntriesStorageOperations = params => {
|
|
|
552
490
|
reverse: true
|
|
553
491
|
}
|
|
554
492
|
};
|
|
555
|
-
|
|
556
493
|
try {
|
|
557
494
|
const result = await (0, _query.queryOne)(queryParams);
|
|
558
495
|
const storageEntry = (0, _cleanup.cleanupItem)(entity, result);
|
|
559
|
-
|
|
560
496
|
if (!storageEntry) {
|
|
561
497
|
return null;
|
|
562
498
|
}
|
|
563
|
-
|
|
564
499
|
return convertFromStorageEntry({
|
|
565
500
|
storageEntry,
|
|
566
501
|
model
|
|
@@ -574,7 +509,6 @@ const createEntriesStorageOperations = params => {
|
|
|
574
509
|
}));
|
|
575
510
|
}
|
|
576
511
|
};
|
|
577
|
-
|
|
578
512
|
const list = async (model, params) => {
|
|
579
513
|
const {
|
|
580
514
|
limit: initialLimit = 10,
|
|
@@ -595,7 +529,6 @@ const createEntriesStorageOperations = params => {
|
|
|
595
529
|
}
|
|
596
530
|
};
|
|
597
531
|
let storageEntries = [];
|
|
598
|
-
|
|
599
532
|
try {
|
|
600
533
|
storageEntries = await (0, _query.queryAll)(queryAllParams);
|
|
601
534
|
} catch (ex) {
|
|
@@ -605,7 +538,6 @@ const createEntriesStorageOperations = params => {
|
|
|
605
538
|
options: queryAllParams.options
|
|
606
539
|
});
|
|
607
540
|
}
|
|
608
|
-
|
|
609
541
|
if (storageEntries.length === 0) {
|
|
610
542
|
return {
|
|
611
543
|
hasMoreItems: false,
|
|
@@ -614,7 +546,6 @@ const createEntriesStorageOperations = params => {
|
|
|
614
546
|
items: []
|
|
615
547
|
};
|
|
616
548
|
}
|
|
617
|
-
|
|
618
549
|
const where = (0, _objectSpread2.default)({}, initialWhere);
|
|
619
550
|
delete where["published"];
|
|
620
551
|
delete where["latest"];
|
|
@@ -622,7 +553,6 @@ const createEntriesStorageOperations = params => {
|
|
|
622
553
|
* We need an object containing field, transformers and paths.
|
|
623
554
|
* Just build it here and pass on into other methods that require it to avoid mapping multiple times.
|
|
624
555
|
*/
|
|
625
|
-
|
|
626
556
|
const modelFields = (0, _createFields.createFields)({
|
|
627
557
|
plugins,
|
|
628
558
|
fields: model.fields
|
|
@@ -633,24 +563,20 @@ const createEntriesStorageOperations = params => {
|
|
|
633
563
|
*
|
|
634
564
|
* This is always being done, but at least its in parallel.
|
|
635
565
|
*/
|
|
636
|
-
|
|
637
566
|
const records = await Promise.all(storageEntries.map(async storageEntry => {
|
|
638
567
|
const entry = convertFromStorageEntry({
|
|
639
568
|
storageEntry,
|
|
640
569
|
model
|
|
641
570
|
});
|
|
642
|
-
|
|
643
571
|
for (const field of model.fields) {
|
|
644
572
|
entry.values[field.fieldId] = await fromStorage(field, entry.values[field.fieldId]);
|
|
645
573
|
}
|
|
646
|
-
|
|
647
574
|
return entry;
|
|
648
575
|
}));
|
|
649
576
|
/**
|
|
650
577
|
* Filter the read items via the code.
|
|
651
578
|
* It will build the filters out of the where input and transform the values it is using.
|
|
652
579
|
*/
|
|
653
|
-
|
|
654
580
|
const filteredItems = (0, _filtering.filter)({
|
|
655
581
|
items: records,
|
|
656
582
|
where,
|
|
@@ -662,11 +588,11 @@ const createEntriesStorageOperations = params => {
|
|
|
662
588
|
}
|
|
663
589
|
});
|
|
664
590
|
const totalCount = filteredItems.length;
|
|
591
|
+
|
|
665
592
|
/**
|
|
666
593
|
* Sorting is also done via the code.
|
|
667
594
|
* It takes the sort input and sorts by it via the lodash sortBy method.
|
|
668
595
|
*/
|
|
669
|
-
|
|
670
596
|
const sortedItems = (0, _filtering.sort)({
|
|
671
597
|
model,
|
|
672
598
|
plugins,
|
|
@@ -682,7 +608,6 @@ const createEntriesStorageOperations = params => {
|
|
|
682
608
|
* Although we do not need a cursor here, we will use it as such to keep it standardized.
|
|
683
609
|
* Number is simply encoded.
|
|
684
610
|
*/
|
|
685
|
-
|
|
686
611
|
const cursor = totalCount > start + limit ? (0, _cursor.encodeCursor)(`${start + limit}`) : null;
|
|
687
612
|
return {
|
|
688
613
|
hasMoreItems,
|
|
@@ -691,7 +616,6 @@ const createEntriesStorageOperations = params => {
|
|
|
691
616
|
items: (0, _cleanup.cleanupItems)(entity, slicedItems)
|
|
692
617
|
};
|
|
693
618
|
};
|
|
694
|
-
|
|
695
619
|
const get = async (model, params) => {
|
|
696
620
|
const {
|
|
697
621
|
items
|
|
@@ -700,7 +624,6 @@ const createEntriesStorageOperations = params => {
|
|
|
700
624
|
}));
|
|
701
625
|
return items.shift() || null;
|
|
702
626
|
};
|
|
703
|
-
|
|
704
627
|
const publish = async (model, params) => {
|
|
705
628
|
const {
|
|
706
629
|
entry,
|
|
@@ -711,10 +634,10 @@ const createEntriesStorageOperations = params => {
|
|
|
711
634
|
locale: model.locale,
|
|
712
635
|
tenant: model.tenant
|
|
713
636
|
});
|
|
637
|
+
|
|
714
638
|
/**
|
|
715
639
|
* We need the latest and published entries to see if something needs to be updated along side the publishing one.
|
|
716
640
|
*/
|
|
717
|
-
|
|
718
641
|
const initialLatestStorageEntry = await getLatestRevisionByEntryId(model, entry);
|
|
719
642
|
const initialPublishedStorageEntry = await getPublishedRevisionByEntryId(model, entry);
|
|
720
643
|
const storageEntry = convertToStorageEntry({
|
|
@@ -728,7 +651,6 @@ const createEntriesStorageOperations = params => {
|
|
|
728
651
|
* - latest sort key - if entry updated is actually latest
|
|
729
652
|
* - previous published entry to unpublished status - if any previously published entry
|
|
730
653
|
*/
|
|
731
|
-
|
|
732
654
|
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
733
655
|
PK: partitionKey,
|
|
734
656
|
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
@@ -742,7 +664,6 @@ const createEntriesStorageOperations = params => {
|
|
|
742
664
|
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "P"),
|
|
743
665
|
GSI1_SK: (0, _keys.createGSISortKey)(entry)
|
|
744
666
|
}))];
|
|
745
|
-
|
|
746
667
|
if (initialLatestStorageEntry && entry.id === initialLatestStorageEntry.id) {
|
|
747
668
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
748
669
|
PK: partitionKey,
|
|
@@ -752,7 +673,6 @@ const createEntriesStorageOperations = params => {
|
|
|
752
673
|
GSI1_SK: (0, _keys.createGSISortKey)(entry)
|
|
753
674
|
})));
|
|
754
675
|
}
|
|
755
|
-
|
|
756
676
|
if (initialPublishedStorageEntry && initialPublishedStorageEntry.id !== entry.id) {
|
|
757
677
|
const publishedStorageEntry = convertToStorageEntry({
|
|
758
678
|
storageEntry: initialPublishedStorageEntry,
|
|
@@ -767,7 +687,6 @@ const createEntriesStorageOperations = params => {
|
|
|
767
687
|
GSI1_SK: (0, _keys.createGSISortKey)(publishedStorageEntry)
|
|
768
688
|
})));
|
|
769
689
|
}
|
|
770
|
-
|
|
771
690
|
try {
|
|
772
691
|
await (0, _batchWrite.batchWriteAll)({
|
|
773
692
|
table: entity.table,
|
|
@@ -785,7 +704,6 @@ const createEntriesStorageOperations = params => {
|
|
|
785
704
|
});
|
|
786
705
|
}
|
|
787
706
|
};
|
|
788
|
-
|
|
789
707
|
const unpublish = async (model, params) => {
|
|
790
708
|
const {
|
|
791
709
|
entry,
|
|
@@ -806,7 +724,6 @@ const createEntriesStorageOperations = params => {
|
|
|
806
724
|
* - update current entry revision with new data
|
|
807
725
|
* - update latest entry status - if entry being unpublished is latest
|
|
808
726
|
*/
|
|
809
|
-
|
|
810
727
|
const items = [entity.deleteBatch({
|
|
811
728
|
PK: partitionKey,
|
|
812
729
|
SK: (0, _keys.createPublishedSortKey)()
|
|
@@ -817,12 +734,11 @@ const createEntriesStorageOperations = params => {
|
|
|
817
734
|
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
|
|
818
735
|
GSI1_SK: (0, _keys.createGSISortKey)(entry)
|
|
819
736
|
}))];
|
|
737
|
+
|
|
820
738
|
/**
|
|
821
739
|
* We need the latest entry to see if something needs to be updated along side the unpublishing one.
|
|
822
740
|
*/
|
|
823
|
-
|
|
824
741
|
const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
|
|
825
|
-
|
|
826
742
|
if (latestStorageEntry && entry.id === latestStorageEntry.id) {
|
|
827
743
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
828
744
|
PK: partitionKey,
|
|
@@ -832,7 +748,6 @@ const createEntriesStorageOperations = params => {
|
|
|
832
748
|
GSI1_SK: (0, _keys.createGSISortKey)(entry)
|
|
833
749
|
})));
|
|
834
750
|
}
|
|
835
|
-
|
|
836
751
|
try {
|
|
837
752
|
await (0, _batchWrite.batchWriteAll)({
|
|
838
753
|
table: entity.table,
|
|
@@ -849,7 +764,6 @@ const createEntriesStorageOperations = params => {
|
|
|
849
764
|
});
|
|
850
765
|
}
|
|
851
766
|
};
|
|
852
|
-
|
|
853
767
|
return {
|
|
854
768
|
create,
|
|
855
769
|
createRevisionFrom,
|
|
@@ -870,5 +784,4 @@ const createEntriesStorageOperations = params => {
|
|
|
870
784
|
unpublish
|
|
871
785
|
};
|
|
872
786
|
};
|
|
873
|
-
|
|
874
787
|
exports.createEntriesStorageOperations = createEntriesStorageOperations;
|