@webiny/api-headless-cms-ddb 5.32.0 → 5.33.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dynamoDb/index.js +5 -7
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/plainObject.js +3 -0
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/storage/date.d.ts +1 -2
- package/dynamoDb/storage/date.js +78 -44
- package/dynamoDb/storage/date.js.map +1 -1
- package/dynamoDb/storage/longText.d.ts +5 -2
- package/dynamoDb/storage/longText.js +70 -53
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.d.ts +1 -2
- package/dynamoDb/storage/richText.js +67 -65
- package/dynamoDb/storage/richText.js.map +1 -1
- package/dynamoDb/transformValue/datetime.d.ts +4 -2
- package/dynamoDb/transformValue/datetime.js +31 -26
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/operations/entry/index.js +164 -35
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/systemFields.js +8 -0
- package/operations/entry/systemFields.js.map +1 -1
- package/operations/entry/utils.js +55 -11
- package/operations/entry/utils.js.map +1 -1
- package/operations/model/index.js +2 -2
- package/operations/model/index.js.map +1 -1
- package/package.json +10 -10
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createDatetimeTransformValuePlugin = void 0;
|
|
7
7
|
|
|
8
8
|
var _TimeTransformPlugin = require("@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin");
|
|
9
9
|
|
|
10
10
|
var _DateTimeTransformPlugin = require("@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin");
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* File is @internal
|
|
14
|
+
*/
|
|
12
15
|
const timeTransformer = new _TimeTransformPlugin.TimeTransformPlugin({
|
|
13
16
|
fields: ["*"]
|
|
14
17
|
});
|
|
@@ -16,32 +19,34 @@ const dateTimeTransformer = new _DateTimeTransformPlugin.DateTimeTransformPlugin
|
|
|
16
19
|
fields: ["*"]
|
|
17
20
|
});
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
const createDatetimeTransformValuePlugin = () => {
|
|
23
|
+
return {
|
|
24
|
+
type: "cms-field-filter-value-transform",
|
|
25
|
+
name: "cms-field-value-filter-transform-datetime",
|
|
26
|
+
fieldType: "datetime",
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Always transform into the milliseconds.
|
|
30
|
+
*/
|
|
31
|
+
transform: ({
|
|
32
|
+
field,
|
|
33
|
+
value
|
|
34
|
+
}) => {
|
|
35
|
+
const {
|
|
36
|
+
type
|
|
37
|
+
} = field.settings || {};
|
|
38
|
+
|
|
39
|
+
if (type === "time") {
|
|
40
|
+
return timeTransformer.transform({
|
|
41
|
+
value
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return dateTimeTransformer.transform({
|
|
37
46
|
value
|
|
38
47
|
});
|
|
39
48
|
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
40
51
|
|
|
41
|
-
|
|
42
|
-
value
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
exports.default = _default;
|
|
52
|
+
exports.createDatetimeTransformValuePlugin = createDatetimeTransformValuePlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["timeTransformer","TimeTransformPlugin","fields","dateTimeTransformer","DateTimeTransformPlugin","type","name","fieldType","transform","field","value","settings"],"sources":["datetime.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":["timeTransformer","TimeTransformPlugin","fields","dateTimeTransformer","DateTimeTransformPlugin","createDatetimeTransformValuePlugin","type","name","fieldType","transform","field","value","settings"],"sources":["datetime.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\nimport { TimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin\";\nimport { DateTimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin\";\n\nconst timeTransformer = new TimeTransformPlugin({\n fields: [\"*\"]\n});\nconst dateTimeTransformer = new DateTimeTransformPlugin({\n fields: [\"*\"]\n});\n\nexport const createDatetimeTransformValuePlugin = (): CmsFieldFilterValueTransformPlugin => {\n return {\n type: \"cms-field-filter-value-transform\",\n name: \"cms-field-value-filter-transform-datetime\",\n fieldType: \"datetime\",\n /**\n * Always transform into the milliseconds.\n */\n transform: ({ field, value }) => {\n const { type } = field.settings || {};\n if (type === \"time\") {\n return timeTransformer.transform({\n value\n });\n }\n return dateTimeTransformer.transform({\n value\n });\n }\n };\n};\n"],"mappings":";;;;;;;AAIA;;AACA;;AALA;AACA;AACA;AAKA,MAAMA,eAAe,GAAG,IAAIC,wCAAJ,CAAwB;EAC5CC,MAAM,EAAE,CAAC,GAAD;AADoC,CAAxB,CAAxB;AAGA,MAAMC,mBAAmB,GAAG,IAAIC,gDAAJ,CAA4B;EACpDF,MAAM,EAAE,CAAC,GAAD;AAD4C,CAA5B,CAA5B;;AAIO,MAAMG,kCAAkC,GAAG,MAA0C;EACxF,OAAO;IACHC,IAAI,EAAE,kCADH;IAEHC,IAAI,EAAE,2CAFH;IAGHC,SAAS,EAAE,UAHR;;IAIH;AACR;AACA;IACQC,SAAS,EAAE,CAAC;MAAEC,KAAF;MAASC;IAAT,CAAD,KAAsB;MAC7B,MAAM;QAAEL;MAAF,IAAWI,KAAK,CAACE,QAAN,IAAkB,EAAnC;;MACA,IAAIN,IAAI,KAAK,MAAb,EAAqB;QACjB,OAAON,eAAe,CAACS,SAAhB,CAA0B;UAC7BE;QAD6B,CAA1B,CAAP;MAGH;;MACD,OAAOR,mBAAmB,CAACM,SAApB,CAA8B;QACjCE;MADiC,CAA9B,CAAP;IAGH;EAjBE,CAAP;AAmBH,CApBM"}
|
|
@@ -47,6 +47,34 @@ const createPublishedType = () => {
|
|
|
47
47
|
return `${createType()}.p`;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
const convertToStorageEntry = params => {
|
|
51
|
+
const {
|
|
52
|
+
model,
|
|
53
|
+
storageEntry
|
|
54
|
+
} = params;
|
|
55
|
+
const values = model.convertValueKeyToStorage({
|
|
56
|
+
fields: model.fields,
|
|
57
|
+
values: storageEntry.values
|
|
58
|
+
});
|
|
59
|
+
return _objectSpread(_objectSpread({}, storageEntry), {}, {
|
|
60
|
+
values
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const convertFromStorageEntry = params => {
|
|
65
|
+
const {
|
|
66
|
+
model,
|
|
67
|
+
storageEntry
|
|
68
|
+
} = params;
|
|
69
|
+
const values = model.convertValueKeyFromStorage({
|
|
70
|
+
fields: model.fields,
|
|
71
|
+
values: storageEntry.values
|
|
72
|
+
});
|
|
73
|
+
return _objectSpread(_objectSpread({}, storageEntry), {}, {
|
|
74
|
+
values
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
50
78
|
const createEntriesStorageOperations = params => {
|
|
51
79
|
const {
|
|
52
80
|
entity,
|
|
@@ -82,11 +110,11 @@ const createEntriesStorageOperations = params => {
|
|
|
82
110
|
};
|
|
83
111
|
};
|
|
84
112
|
|
|
85
|
-
const create = async (model,
|
|
113
|
+
const create = async (model, params) => {
|
|
86
114
|
const {
|
|
87
115
|
entry,
|
|
88
|
-
storageEntry
|
|
89
|
-
} =
|
|
116
|
+
storageEntry: initialStorageEntry
|
|
117
|
+
} = params;
|
|
90
118
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
91
119
|
id: entry.id,
|
|
92
120
|
locale: model.locale,
|
|
@@ -94,6 +122,10 @@ const createEntriesStorageOperations = params => {
|
|
|
94
122
|
});
|
|
95
123
|
const isPublished = entry.status === "published";
|
|
96
124
|
const locked = isPublished ? true : entry.locked;
|
|
125
|
+
const storageEntry = convertToStorageEntry({
|
|
126
|
+
model,
|
|
127
|
+
storageEntry: initialStorageEntry
|
|
128
|
+
});
|
|
97
129
|
/**
|
|
98
130
|
* We need to:
|
|
99
131
|
* - create new main entry item
|
|
@@ -145,19 +177,23 @@ const createEntriesStorageOperations = params => {
|
|
|
145
177
|
});
|
|
146
178
|
}
|
|
147
179
|
|
|
148
|
-
return
|
|
180
|
+
return initialStorageEntry;
|
|
149
181
|
};
|
|
150
182
|
|
|
151
183
|
const createRevisionFrom = async (model, params) => {
|
|
152
184
|
const {
|
|
153
185
|
entry,
|
|
154
|
-
storageEntry
|
|
186
|
+
storageEntry: initialStorageEntry
|
|
155
187
|
} = params;
|
|
156
188
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
157
189
|
id: entry.id,
|
|
158
190
|
locale: model.locale,
|
|
159
191
|
tenant: model.tenant
|
|
160
192
|
});
|
|
193
|
+
const storageEntry = convertToStorageEntry({
|
|
194
|
+
storageEntry: initialStorageEntry,
|
|
195
|
+
model
|
|
196
|
+
});
|
|
161
197
|
/**
|
|
162
198
|
* We need to:
|
|
163
199
|
* - create the main entry item
|
|
@@ -198,13 +234,13 @@ const createEntriesStorageOperations = params => {
|
|
|
198
234
|
*/
|
|
199
235
|
|
|
200
236
|
|
|
201
|
-
return
|
|
237
|
+
return initialStorageEntry;
|
|
202
238
|
};
|
|
203
239
|
|
|
204
240
|
const update = async (model, params) => {
|
|
205
241
|
const {
|
|
206
242
|
entry,
|
|
207
|
-
storageEntry
|
|
243
|
+
storageEntry: initialStorageEntry
|
|
208
244
|
} = params;
|
|
209
245
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
210
246
|
id: entry.id,
|
|
@@ -214,6 +250,10 @@ const createEntriesStorageOperations = params => {
|
|
|
214
250
|
const isPublished = entry.status === "published";
|
|
215
251
|
const locked = isPublished ? true : entry.locked;
|
|
216
252
|
const items = [];
|
|
253
|
+
const storageEntry = convertToStorageEntry({
|
|
254
|
+
model,
|
|
255
|
+
storageEntry: initialStorageEntry
|
|
256
|
+
});
|
|
217
257
|
/**
|
|
218
258
|
* We need to:
|
|
219
259
|
* - update the current entry
|
|
@@ -265,7 +305,7 @@ const createEntriesStorageOperations = params => {
|
|
|
265
305
|
dataLoaders.clearAll({
|
|
266
306
|
model
|
|
267
307
|
});
|
|
268
|
-
return
|
|
308
|
+
return initialStorageEntry;
|
|
269
309
|
} catch (ex) {
|
|
270
310
|
throw new _error.default(ex.message || "Could not update entry.", ex.code || "UPDATE_ERROR", {
|
|
271
311
|
error: ex,
|
|
@@ -329,7 +369,7 @@ const createEntriesStorageOperations = params => {
|
|
|
329
369
|
const {
|
|
330
370
|
entry,
|
|
331
371
|
latestEntry,
|
|
332
|
-
latestStorageEntry
|
|
372
|
+
latestStorageEntry: initialLatestStorageEntry
|
|
333
373
|
} = params;
|
|
334
374
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
335
375
|
id: entry.id,
|
|
@@ -352,7 +392,11 @@ const createEntriesStorageOperations = params => {
|
|
|
352
392
|
}));
|
|
353
393
|
}
|
|
354
394
|
|
|
355
|
-
if (
|
|
395
|
+
if (initialLatestStorageEntry) {
|
|
396
|
+
const latestStorageEntry = convertToStorageEntry({
|
|
397
|
+
storageEntry: initialLatestStorageEntry,
|
|
398
|
+
model
|
|
399
|
+
});
|
|
356
400
|
items.push(entity.putBatch(_objectSpread(_objectSpread({}, latestStorageEntry), {}, {
|
|
357
401
|
PK: partitionKey,
|
|
358
402
|
SK: (0, _keys.createLatestSortKey)(),
|
|
@@ -380,55 +424,106 @@ const createEntriesStorageOperations = params => {
|
|
|
380
424
|
};
|
|
381
425
|
|
|
382
426
|
const getLatestRevisionByEntryId = async (model, params) => {
|
|
383
|
-
const
|
|
427
|
+
const items = await dataLoaders.getLatestRevisionByEntryId({
|
|
384
428
|
model,
|
|
385
429
|
ids: [params.id]
|
|
386
430
|
});
|
|
387
|
-
|
|
431
|
+
const item = items.shift() || null;
|
|
432
|
+
|
|
433
|
+
if (!item) {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
return convertFromStorageEntry({
|
|
438
|
+
storageEntry: item,
|
|
439
|
+
model
|
|
440
|
+
});
|
|
388
441
|
};
|
|
389
442
|
|
|
390
443
|
const getPublishedRevisionByEntryId = async (model, params) => {
|
|
391
|
-
const
|
|
444
|
+
const items = await dataLoaders.getPublishedRevisionByEntryId({
|
|
392
445
|
model,
|
|
393
446
|
ids: [params.id]
|
|
394
447
|
});
|
|
395
|
-
|
|
448
|
+
const item = items.shift() || null;
|
|
449
|
+
|
|
450
|
+
if (!item) {
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return convertFromStorageEntry({
|
|
455
|
+
storageEntry: item,
|
|
456
|
+
model
|
|
457
|
+
});
|
|
396
458
|
};
|
|
397
459
|
|
|
398
460
|
const getRevisionById = async (model, params) => {
|
|
399
|
-
const
|
|
461
|
+
const items = await dataLoaders.getRevisionById({
|
|
400
462
|
model,
|
|
401
463
|
ids: [params.id]
|
|
402
464
|
});
|
|
403
|
-
|
|
465
|
+
const item = items.shift() || null;
|
|
466
|
+
|
|
467
|
+
if (!item) {
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return convertFromStorageEntry({
|
|
472
|
+
storageEntry: item,
|
|
473
|
+
model
|
|
474
|
+
});
|
|
404
475
|
};
|
|
405
476
|
|
|
406
477
|
const getRevisions = async (model, params) => {
|
|
407
|
-
|
|
478
|
+
const items = await dataLoaders.getAllEntryRevisions({
|
|
408
479
|
model,
|
|
409
480
|
ids: [params.id]
|
|
410
481
|
});
|
|
482
|
+
return items.map(item => {
|
|
483
|
+
return convertFromStorageEntry({
|
|
484
|
+
storageEntry: item,
|
|
485
|
+
model
|
|
486
|
+
});
|
|
487
|
+
});
|
|
411
488
|
};
|
|
412
489
|
|
|
413
490
|
const getByIds = async (model, params) => {
|
|
414
|
-
|
|
491
|
+
const items = await dataLoaders.getRevisionById({
|
|
415
492
|
model,
|
|
416
493
|
ids: params.ids
|
|
417
494
|
});
|
|
495
|
+
return items.map(item => {
|
|
496
|
+
return convertFromStorageEntry({
|
|
497
|
+
storageEntry: item,
|
|
498
|
+
model
|
|
499
|
+
});
|
|
500
|
+
});
|
|
418
501
|
};
|
|
419
502
|
|
|
420
503
|
const getLatestByIds = async (model, params) => {
|
|
421
|
-
|
|
504
|
+
const items = await dataLoaders.getLatestRevisionByEntryId({
|
|
422
505
|
model,
|
|
423
506
|
ids: params.ids
|
|
424
507
|
});
|
|
508
|
+
return items.map(item => {
|
|
509
|
+
return convertFromStorageEntry({
|
|
510
|
+
storageEntry: item,
|
|
511
|
+
model
|
|
512
|
+
});
|
|
513
|
+
});
|
|
425
514
|
};
|
|
426
515
|
|
|
427
516
|
const getPublishedByIds = async (model, params) => {
|
|
428
|
-
|
|
517
|
+
const items = await dataLoaders.getPublishedRevisionByEntryId({
|
|
429
518
|
model,
|
|
430
519
|
ids: params.ids
|
|
431
520
|
});
|
|
521
|
+
return items.map(item => {
|
|
522
|
+
return convertFromStorageEntry({
|
|
523
|
+
storageEntry: item,
|
|
524
|
+
model
|
|
525
|
+
});
|
|
526
|
+
});
|
|
432
527
|
};
|
|
433
528
|
|
|
434
529
|
const getPreviousRevision = async (model, params) => {
|
|
@@ -462,7 +557,16 @@ const createEntriesStorageOperations = params => {
|
|
|
462
557
|
|
|
463
558
|
try {
|
|
464
559
|
const result = await (0, _query.queryOne)(queryParams);
|
|
465
|
-
|
|
560
|
+
const storageEntry = (0, _cleanup.cleanupItem)(entity, result);
|
|
561
|
+
|
|
562
|
+
if (!storageEntry) {
|
|
563
|
+
return null;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
return convertFromStorageEntry({
|
|
567
|
+
storageEntry,
|
|
568
|
+
model
|
|
569
|
+
});
|
|
466
570
|
} catch (ex) {
|
|
467
571
|
throw new _error.default(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", _objectSpread(_objectSpread({}, params), {}, {
|
|
468
572
|
error: ex,
|
|
@@ -532,7 +636,12 @@ const createEntriesStorageOperations = params => {
|
|
|
532
636
|
*/
|
|
533
637
|
|
|
534
638
|
const filteredItems = await (0, _utils.filterItems)({
|
|
535
|
-
items: records
|
|
639
|
+
items: records.map(record => {
|
|
640
|
+
return convertFromStorageEntry({
|
|
641
|
+
storageEntry: record,
|
|
642
|
+
model
|
|
643
|
+
});
|
|
644
|
+
}),
|
|
536
645
|
where,
|
|
537
646
|
plugins,
|
|
538
647
|
fields: modelFields,
|
|
@@ -583,13 +692,17 @@ const createEntriesStorageOperations = params => {
|
|
|
583
692
|
const requestChanges = async (model, params) => {
|
|
584
693
|
const {
|
|
585
694
|
entry,
|
|
586
|
-
storageEntry
|
|
695
|
+
storageEntry: initialStorageEntry
|
|
587
696
|
} = params;
|
|
588
697
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
589
698
|
id: entry.id,
|
|
590
699
|
locale: model.locale,
|
|
591
700
|
tenant: model.tenant
|
|
592
701
|
});
|
|
702
|
+
const storageEntry = convertToStorageEntry({
|
|
703
|
+
storageEntry: initialStorageEntry,
|
|
704
|
+
model
|
|
705
|
+
});
|
|
593
706
|
/**
|
|
594
707
|
* We need to:
|
|
595
708
|
* - update the existing entry
|
|
@@ -639,13 +752,17 @@ const createEntriesStorageOperations = params => {
|
|
|
639
752
|
const requestReview = async (model, params) => {
|
|
640
753
|
const {
|
|
641
754
|
entry,
|
|
642
|
-
storageEntry
|
|
755
|
+
storageEntry: initialStorageEntry
|
|
643
756
|
} = params;
|
|
644
757
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
645
758
|
id: entry.id,
|
|
646
759
|
locale: model.locale,
|
|
647
760
|
tenant: model.tenant
|
|
648
761
|
});
|
|
762
|
+
const storageEntry = convertToStorageEntry({
|
|
763
|
+
storageEntry: initialStorageEntry,
|
|
764
|
+
model
|
|
765
|
+
});
|
|
649
766
|
/**
|
|
650
767
|
* We need to:
|
|
651
768
|
* - update existing entry
|
|
@@ -683,7 +800,7 @@ const createEntriesStorageOperations = params => {
|
|
|
683
800
|
dataLoaders.clearAll({
|
|
684
801
|
model
|
|
685
802
|
});
|
|
686
|
-
return
|
|
803
|
+
return initialStorageEntry;
|
|
687
804
|
} catch (ex) {
|
|
688
805
|
throw new _error.default(ex.message || "Could not execute request review batch.", ex.code || "REQUEST_REVIEW_ERROR", {
|
|
689
806
|
entry,
|
|
@@ -695,7 +812,7 @@ const createEntriesStorageOperations = params => {
|
|
|
695
812
|
const publish = async (model, params) => {
|
|
696
813
|
const {
|
|
697
814
|
entry,
|
|
698
|
-
storageEntry
|
|
815
|
+
storageEntry: initialStorageEntry
|
|
699
816
|
} = params;
|
|
700
817
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
701
818
|
id: entry.id,
|
|
@@ -706,8 +823,12 @@ const createEntriesStorageOperations = params => {
|
|
|
706
823
|
* We need the latest and published entries to see if something needs to be updated along side the publishing one.
|
|
707
824
|
*/
|
|
708
825
|
|
|
709
|
-
const
|
|
710
|
-
const
|
|
826
|
+
const initialLatestStorageEntry = await getLatestRevisionByEntryId(model, entry);
|
|
827
|
+
const initialPublishedStorageEntry = await getPublishedRevisionByEntryId(model, entry);
|
|
828
|
+
const storageEntry = convertToStorageEntry({
|
|
829
|
+
model,
|
|
830
|
+
storageEntry: initialStorageEntry
|
|
831
|
+
});
|
|
711
832
|
/**
|
|
712
833
|
* We need to update:
|
|
713
834
|
* - current entry revision sort key
|
|
@@ -730,7 +851,7 @@ const createEntriesStorageOperations = params => {
|
|
|
730
851
|
GSI1_SK: (0, _keys.createGSISortKey)(entry)
|
|
731
852
|
}))];
|
|
732
853
|
|
|
733
|
-
if (
|
|
854
|
+
if (initialLatestStorageEntry && entry.id === initialLatestStorageEntry.id) {
|
|
734
855
|
items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
|
|
735
856
|
PK: partitionKey,
|
|
736
857
|
SK: (0, _keys.createLatestSortKey)(),
|
|
@@ -740,7 +861,11 @@ const createEntriesStorageOperations = params => {
|
|
|
740
861
|
})));
|
|
741
862
|
}
|
|
742
863
|
|
|
743
|
-
if (
|
|
864
|
+
if (initialPublishedStorageEntry && initialPublishedStorageEntry.id !== entry.id) {
|
|
865
|
+
const publishedStorageEntry = convertToStorageEntry({
|
|
866
|
+
storageEntry: initialPublishedStorageEntry,
|
|
867
|
+
model
|
|
868
|
+
});
|
|
744
869
|
items.push(entity.putBatch(_objectSpread(_objectSpread({}, publishedStorageEntry), {}, {
|
|
745
870
|
PK: partitionKey,
|
|
746
871
|
SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry),
|
|
@@ -759,12 +884,12 @@ const createEntriesStorageOperations = params => {
|
|
|
759
884
|
dataLoaders.clearAll({
|
|
760
885
|
model
|
|
761
886
|
});
|
|
762
|
-
return
|
|
887
|
+
return initialStorageEntry;
|
|
763
888
|
} catch (ex) {
|
|
764
889
|
throw new _error.default(ex.message || "Could not execute the publishing batch.", ex.code || "PUBLISH_ERROR", {
|
|
765
890
|
entry,
|
|
766
|
-
latestStorageEntry,
|
|
767
|
-
publishedStorageEntry
|
|
891
|
+
latestStorageEntry: initialLatestStorageEntry,
|
|
892
|
+
publishedStorageEntry: initialPublishedStorageEntry
|
|
768
893
|
});
|
|
769
894
|
}
|
|
770
895
|
};
|
|
@@ -772,13 +897,17 @@ const createEntriesStorageOperations = params => {
|
|
|
772
897
|
const unpublish = async (model, params) => {
|
|
773
898
|
const {
|
|
774
899
|
entry,
|
|
775
|
-
storageEntry
|
|
900
|
+
storageEntry: initialStorageEntry
|
|
776
901
|
} = params;
|
|
777
902
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
778
903
|
id: entry.id,
|
|
779
904
|
locale: model.locale,
|
|
780
905
|
tenant: model.tenant
|
|
781
906
|
});
|
|
907
|
+
const storageEntry = convertToStorageEntry({
|
|
908
|
+
storageEntry: initialStorageEntry,
|
|
909
|
+
model
|
|
910
|
+
});
|
|
782
911
|
/**
|
|
783
912
|
* We need to:
|
|
784
913
|
* - delete currently published entry
|
|
@@ -820,7 +949,7 @@ const createEntriesStorageOperations = params => {
|
|
|
820
949
|
dataLoaders.clearAll({
|
|
821
950
|
model
|
|
822
951
|
});
|
|
823
|
-
return
|
|
952
|
+
return initialStorageEntry;
|
|
824
953
|
} catch (ex) {
|
|
825
954
|
throw new _error.default(ex.message || "Could not execute unpublish batch.", ex.code || "UNPUBLISH_ERROR", {
|
|
826
955
|
entry,
|