@webiny/api-headless-cms-ddb 0.0.0-unstable.5e7233243f → 0.0.0-unstable.60a863e033
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 -7
- package/definitions/entry.js.map +1 -1
- package/definitions/group.js +3 -7
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +8 -7
- package/definitions/model.js.map +1 -1
- package/definitions/settings.js +3 -7
- package/definitions/settings.js.map +1 -1
- package/definitions/system.js +3 -7
- package/definitions/system.js.map +1 -1
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/path/plainObject.js +1 -1
- package/dynamoDb/storage/date.d.ts +2 -1
- package/dynamoDb/storage/date.js +14 -4
- package/dynamoDb/storage/date.js.map +1 -1
- package/dynamoDb/storage/longText.d.ts +1 -1
- package/dynamoDb/storage/longText.js +8 -1
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.d.ts +1 -1
- package/dynamoDb/storage/richText.js +1 -1
- package/dynamoDb/storage/richText.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +36 -6
- package/index.js.map +1 -1
- package/operations/entry/dataLoaders.js +7 -9
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.d.ts +26 -0
- package/operations/entry/filtering/createExpressions.js +213 -0
- package/operations/entry/filtering/createExpressions.js.map +1 -0
- package/operations/entry/filtering/createFields.d.ts +14 -0
- package/operations/entry/filtering/createFields.js +123 -0
- package/operations/entry/filtering/createFields.js.map +1 -0
- package/operations/entry/filtering/extractSort.d.ts +17 -0
- package/operations/entry/filtering/extractSort.js +77 -0
- package/operations/entry/filtering/extractSort.js.map +1 -0
- package/operations/entry/filtering/filter.d.ts +15 -0
- package/operations/entry/filtering/filter.js +178 -0
- package/operations/entry/filtering/filter.js.map +1 -0
- package/operations/entry/filtering/fullTextSearch.d.ts +14 -0
- package/operations/entry/filtering/fullTextSearch.js +60 -0
- package/operations/entry/filtering/fullTextSearch.js.map +1 -0
- package/operations/entry/filtering/getValue.d.ts +5 -0
- package/operations/entry/filtering/getValue.js +81 -0
- package/operations/entry/filtering/getValue.js.map +1 -0
- package/operations/entry/filtering/index.d.ts +2 -0
- package/operations/entry/filtering/index.js +21 -0
- package/operations/entry/filtering/index.js.map +1 -0
- package/operations/entry/filtering/mapPlugins.d.ts +8 -0
- package/operations/entry/filtering/mapPlugins.js +39 -0
- package/operations/entry/filtering/mapPlugins.js.map +1 -0
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +48 -0
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/index.d.ts +1 -0
- package/operations/entry/filtering/plugins/index.js +18 -0
- package/operations/entry/filtering/plugins/index.js.map +1 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.js +107 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js +89 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
- package/operations/entry/filtering/sort.d.ts +12 -0
- package/operations/entry/filtering/sort.js +84 -0
- package/operations/entry/filtering/sort.js.map +1 -0
- package/operations/entry/filtering/systemFields.d.ts +4 -0
- package/operations/entry/filtering/systemFields.js +72 -0
- package/operations/entry/filtering/systemFields.js.map +1 -0
- package/operations/entry/filtering/transform.d.ts +6 -0
- package/operations/entry/filtering/transform.js +19 -0
- package/operations/entry/filtering/transform.js.map +1 -0
- package/operations/entry/filtering/types.d.ts +40 -0
- package/operations/entry/filtering/types.js +5 -0
- package/operations/entry/filtering/types.js.map +1 -0
- package/operations/entry/filtering/values.d.ts +2 -0
- package/operations/entry/filtering/values.js +28 -0
- package/operations/entry/filtering/values.js.map +1 -0
- package/operations/entry/filtering/where.d.ts +5 -0
- package/operations/entry/filtering/where.js +38 -0
- package/operations/entry/filtering/where.js.map +1 -0
- package/operations/entry/index.js +56 -166
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +1 -1
- package/operations/entry/systemFields.js +6 -0
- package/operations/entry/systemFields.js.map +1 -1
- package/operations/group/index.js +6 -10
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js +4 -8
- package/operations/model/index.js.map +1 -1
- package/operations/settings/index.js +6 -10
- package/operations/settings/index.js.map +1 -1
- package/operations/system/index.js +4 -8
- package/operations/system/index.js.map +1 -1
- package/package.json +16 -17
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +2 -2
- package/plugins/CmsEntryFieldFilterPathPlugin.js +1 -1
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
- package/plugins/CmsEntryFieldFilterPlugin.js +31 -0
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
- package/plugins/CmsEntryFieldSortingPlugin.js +38 -0
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
- package/plugins/index.d.ts +3 -0
- package/plugins/index.js +44 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +1 -1
- package/types.js.map +1 -1
- package/operations/entry/utils.d.ts +0 -36
- package/operations/entry/utils.js +0 -684
- package/operations/entry/utils.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createEntriesStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
13
|
|
|
@@ -15,8 +15,6 @@ var _dataLoaders = require("./dataLoaders");
|
|
|
15
15
|
|
|
16
16
|
var _types = require("@webiny/api-headless-cms/types");
|
|
17
17
|
|
|
18
|
-
var _utils = require("./utils");
|
|
19
|
-
|
|
20
18
|
var _keys = require("./keys");
|
|
21
19
|
|
|
22
20
|
var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
|
|
@@ -31,9 +29,9 @@ var _zeroPad = require("@webiny/utils/zeroPad");
|
|
|
31
29
|
|
|
32
30
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
var _createFields = require("./filtering/createFields");
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
var _filtering = require("./filtering");
|
|
37
35
|
|
|
38
36
|
const createType = () => {
|
|
39
37
|
return "cms.entry";
|
|
@@ -56,7 +54,7 @@ const convertToStorageEntry = params => {
|
|
|
56
54
|
fields: model.fields,
|
|
57
55
|
values: storageEntry.values
|
|
58
56
|
});
|
|
59
|
-
return
|
|
57
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
60
58
|
values
|
|
61
59
|
});
|
|
62
60
|
};
|
|
@@ -70,7 +68,7 @@ const convertFromStorageEntry = params => {
|
|
|
70
68
|
fields: model.fields,
|
|
71
69
|
values: storageEntry.values
|
|
72
70
|
});
|
|
73
|
-
return
|
|
71
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
74
72
|
values
|
|
75
73
|
});
|
|
76
74
|
};
|
|
@@ -132,14 +130,14 @@ const createEntriesStorageOperations = params => {
|
|
|
132
130
|
* - create new or update latest entry item
|
|
133
131
|
*/
|
|
134
132
|
|
|
135
|
-
const items = [entity.putBatch(
|
|
133
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
136
134
|
locked,
|
|
137
135
|
PK: partitionKey,
|
|
138
136
|
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
139
137
|
TYPE: createType(),
|
|
140
138
|
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
|
|
141
139
|
GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
|
|
142
|
-
})), entity.putBatch(
|
|
140
|
+
})), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
143
141
|
locked,
|
|
144
142
|
PK: partitionKey,
|
|
145
143
|
SK: (0, _keys.createLatestSortKey)(),
|
|
@@ -152,7 +150,7 @@ const createEntriesStorageOperations = params => {
|
|
|
152
150
|
*/
|
|
153
151
|
|
|
154
152
|
if (isPublished) {
|
|
155
|
-
items.push(entity.putBatch(
|
|
153
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
156
154
|
locked,
|
|
157
155
|
PK: partitionKey,
|
|
158
156
|
SK: (0, _keys.createPublishedSortKey)(),
|
|
@@ -200,13 +198,13 @@ const createEntriesStorageOperations = params => {
|
|
|
200
198
|
* - update the last entry item to a current one
|
|
201
199
|
*/
|
|
202
200
|
|
|
203
|
-
const items = [entity.putBatch(
|
|
201
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
204
202
|
PK: partitionKey,
|
|
205
203
|
SK: (0, _keys.createRevisionSortKey)(storageEntry),
|
|
206
204
|
TYPE: createType(),
|
|
207
205
|
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
|
|
208
206
|
GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
|
|
209
|
-
})), entity.putBatch(
|
|
207
|
+
})), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
210
208
|
PK: partitionKey,
|
|
211
209
|
SK: (0, _keys.createLatestSortKey)(),
|
|
212
210
|
TYPE: createLatestType(),
|
|
@@ -260,7 +258,7 @@ const createEntriesStorageOperations = params => {
|
|
|
260
258
|
* - update the latest entry if the current entry is the latest one
|
|
261
259
|
*/
|
|
262
260
|
|
|
263
|
-
items.push(entity.putBatch(
|
|
261
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
264
262
|
locked,
|
|
265
263
|
PK: partitionKey,
|
|
266
264
|
SK: (0, _keys.createRevisionSortKey)(storageEntry),
|
|
@@ -270,7 +268,7 @@ const createEntriesStorageOperations = params => {
|
|
|
270
268
|
})));
|
|
271
269
|
|
|
272
270
|
if (isPublished) {
|
|
273
|
-
items.push(entity.putBatch(
|
|
271
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
274
272
|
locked,
|
|
275
273
|
PK: partitionKey,
|
|
276
274
|
SK: (0, _keys.createPublishedSortKey)(),
|
|
@@ -287,7 +285,7 @@ const createEntriesStorageOperations = params => {
|
|
|
287
285
|
const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
|
|
288
286
|
|
|
289
287
|
if (latestStorageEntry && latestStorageEntry.id === entry.id) {
|
|
290
|
-
items.push(entity.putBatch(
|
|
288
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
291
289
|
locked,
|
|
292
290
|
PK: partitionKey,
|
|
293
291
|
SK: (0, _keys.createLatestSortKey)(),
|
|
@@ -397,7 +395,7 @@ const createEntriesStorageOperations = params => {
|
|
|
397
395
|
storageEntry: initialLatestStorageEntry,
|
|
398
396
|
model
|
|
399
397
|
});
|
|
400
|
-
items.push(entity.putBatch(
|
|
398
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestStorageEntry), {}, {
|
|
401
399
|
PK: partitionKey,
|
|
402
400
|
SK: (0, _keys.createLatestSortKey)(),
|
|
403
401
|
TYPE: createLatestType(),
|
|
@@ -568,7 +566,7 @@ const createEntriesStorageOperations = params => {
|
|
|
568
566
|
model
|
|
569
567
|
});
|
|
570
568
|
} catch (ex) {
|
|
571
|
-
throw new _error.default(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR",
|
|
569
|
+
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), {}, {
|
|
572
570
|
error: ex,
|
|
573
571
|
partitionKey: queryParams.partitionKey,
|
|
574
572
|
options: queryParams.options,
|
|
@@ -582,7 +580,7 @@ const createEntriesStorageOperations = params => {
|
|
|
582
580
|
limit: initialLimit = 10,
|
|
583
581
|
where: initialWhere,
|
|
584
582
|
after,
|
|
585
|
-
sort,
|
|
583
|
+
sort: sortBy,
|
|
586
584
|
fields,
|
|
587
585
|
search
|
|
588
586
|
} = params;
|
|
@@ -596,10 +594,10 @@ const createEntriesStorageOperations = params => {
|
|
|
596
594
|
gte: " "
|
|
597
595
|
}
|
|
598
596
|
};
|
|
599
|
-
let
|
|
597
|
+
let storageEntries = [];
|
|
600
598
|
|
|
601
599
|
try {
|
|
602
|
-
|
|
600
|
+
storageEntries = await (0, _query.queryAll)(queryAllParams);
|
|
603
601
|
} catch (ex) {
|
|
604
602
|
throw new _error.default(ex.message, "QUERY_ENTRIES_ERROR", {
|
|
605
603
|
error: ex,
|
|
@@ -608,7 +606,7 @@ const createEntriesStorageOperations = params => {
|
|
|
608
606
|
});
|
|
609
607
|
}
|
|
610
608
|
|
|
611
|
-
if (
|
|
609
|
+
if (storageEntries.length === 0) {
|
|
612
610
|
return {
|
|
613
611
|
hasMoreItems: false,
|
|
614
612
|
totalCount: 0,
|
|
@@ -617,35 +615,47 @@ const createEntriesStorageOperations = params => {
|
|
|
617
615
|
};
|
|
618
616
|
}
|
|
619
617
|
|
|
620
|
-
const where =
|
|
621
|
-
|
|
618
|
+
const where = (0, _objectSpread2.default)({}, initialWhere);
|
|
622
619
|
delete where["published"];
|
|
623
620
|
delete where["latest"];
|
|
624
621
|
/**
|
|
625
|
-
* We need
|
|
622
|
+
* We need an object containing field, transformers and paths.
|
|
626
623
|
* Just build it here and pass on into other methods that require it to avoid mapping multiple times.
|
|
627
624
|
*/
|
|
628
625
|
|
|
629
|
-
const modelFields = (0,
|
|
626
|
+
const modelFields = (0, _createFields.createFields)({
|
|
630
627
|
plugins,
|
|
631
|
-
model
|
|
628
|
+
fields: model.fields
|
|
632
629
|
});
|
|
630
|
+
const fromStorage = createStorageTransformCallable(model);
|
|
631
|
+
/**
|
|
632
|
+
* Let's transform records from storage ones to regular ones, so we do not need to do it later.
|
|
633
|
+
*
|
|
634
|
+
* This is always being done, but at least its in parallel.
|
|
635
|
+
*/
|
|
636
|
+
|
|
637
|
+
const records = await Promise.all(storageEntries.map(async storageEntry => {
|
|
638
|
+
const entry = convertFromStorageEntry({
|
|
639
|
+
storageEntry,
|
|
640
|
+
model
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
for (const field of model.fields) {
|
|
644
|
+
entry.values[field.fieldId] = await fromStorage(field, entry.values[field.fieldId]);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
return entry;
|
|
648
|
+
}));
|
|
633
649
|
/**
|
|
634
650
|
* Filter the read items via the code.
|
|
635
651
|
* It will build the filters out of the where input and transform the values it is using.
|
|
636
652
|
*/
|
|
637
653
|
|
|
638
|
-
const filteredItems =
|
|
639
|
-
items: records
|
|
640
|
-
return convertFromStorageEntry({
|
|
641
|
-
storageEntry: record,
|
|
642
|
-
model
|
|
643
|
-
});
|
|
644
|
-
}),
|
|
654
|
+
const filteredItems = (0, _filtering.filter)({
|
|
655
|
+
items: records,
|
|
645
656
|
where,
|
|
646
657
|
plugins,
|
|
647
658
|
fields: modelFields,
|
|
648
|
-
fromStorage: createStorageTransformCallable(model),
|
|
649
659
|
fullTextSearch: {
|
|
650
660
|
term: search,
|
|
651
661
|
fields: fields || []
|
|
@@ -657,9 +667,11 @@ const createEntriesStorageOperations = params => {
|
|
|
657
667
|
* It takes the sort input and sorts by it via the lodash sortBy method.
|
|
658
668
|
*/
|
|
659
669
|
|
|
660
|
-
const sortedItems = (0,
|
|
670
|
+
const sortedItems = (0, _filtering.sort)({
|
|
671
|
+
model,
|
|
672
|
+
plugins,
|
|
661
673
|
items: filteredItems,
|
|
662
|
-
sort,
|
|
674
|
+
sort: sortBy,
|
|
663
675
|
fields: modelFields
|
|
664
676
|
});
|
|
665
677
|
const start = parseInt((0, _cursor.decodeCursor)(after) || "0") || 0;
|
|
@@ -683,132 +695,12 @@ const createEntriesStorageOperations = params => {
|
|
|
683
695
|
const get = async (model, params) => {
|
|
684
696
|
const {
|
|
685
697
|
items
|
|
686
|
-
} = await list(model,
|
|
698
|
+
} = await list(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
687
699
|
limit: 1
|
|
688
700
|
}));
|
|
689
701
|
return items.shift() || null;
|
|
690
702
|
};
|
|
691
703
|
|
|
692
|
-
const requestChanges = async (model, params) => {
|
|
693
|
-
const {
|
|
694
|
-
entry,
|
|
695
|
-
storageEntry: initialStorageEntry
|
|
696
|
-
} = params;
|
|
697
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
698
|
-
id: entry.id,
|
|
699
|
-
locale: model.locale,
|
|
700
|
-
tenant: model.tenant
|
|
701
|
-
});
|
|
702
|
-
const storageEntry = convertToStorageEntry({
|
|
703
|
-
storageEntry: initialStorageEntry,
|
|
704
|
-
model
|
|
705
|
-
});
|
|
706
|
-
/**
|
|
707
|
-
* We need to:
|
|
708
|
-
* - update the existing entry
|
|
709
|
-
* - update latest version - if existing entry is the latest version
|
|
710
|
-
*/
|
|
711
|
-
|
|
712
|
-
const items = [entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
|
|
713
|
-
TYPE: createType(),
|
|
714
|
-
PK: partitionKey,
|
|
715
|
-
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
716
|
-
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
|
|
717
|
-
GSI1_SK: (0, _keys.createGSISortKey)(entry)
|
|
718
|
-
}))];
|
|
719
|
-
/**
|
|
720
|
-
* We need the latest entry to see if something needs to be updated along side the request changes one.
|
|
721
|
-
*/
|
|
722
|
-
|
|
723
|
-
const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
|
|
724
|
-
|
|
725
|
-
if (latestStorageEntry && latestStorageEntry.id === entry.id) {
|
|
726
|
-
items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
|
|
727
|
-
PK: partitionKey,
|
|
728
|
-
SK: (0, _keys.createLatestSortKey)(),
|
|
729
|
-
TYPE: createLatestType(),
|
|
730
|
-
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "L"),
|
|
731
|
-
GSI1_SK: (0, _keys.createGSISortKey)(entry)
|
|
732
|
-
})));
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
try {
|
|
736
|
-
await (0, _batchWrite.batchWriteAll)({
|
|
737
|
-
table: entity.table,
|
|
738
|
-
items
|
|
739
|
-
});
|
|
740
|
-
dataLoaders.clearAll({
|
|
741
|
-
model
|
|
742
|
-
});
|
|
743
|
-
} catch (ex) {
|
|
744
|
-
throw new _error.default(ex.message || "Could not execute the request changes batch.", ex.code || "REQUEST_CHANGES_ERROR", {
|
|
745
|
-
entry
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
return entry;
|
|
750
|
-
};
|
|
751
|
-
|
|
752
|
-
const requestReview = async (model, params) => {
|
|
753
|
-
const {
|
|
754
|
-
entry,
|
|
755
|
-
storageEntry: initialStorageEntry
|
|
756
|
-
} = params;
|
|
757
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
758
|
-
id: entry.id,
|
|
759
|
-
locale: model.locale,
|
|
760
|
-
tenant: model.tenant
|
|
761
|
-
});
|
|
762
|
-
const storageEntry = convertToStorageEntry({
|
|
763
|
-
storageEntry: initialStorageEntry,
|
|
764
|
-
model
|
|
765
|
-
});
|
|
766
|
-
/**
|
|
767
|
-
* We need to:
|
|
768
|
-
* - update existing entry
|
|
769
|
-
* - update latest entry - if existing entry is the latest entry
|
|
770
|
-
*/
|
|
771
|
-
|
|
772
|
-
const items = [entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
|
|
773
|
-
TYPE: createType(),
|
|
774
|
-
PK: partitionKey,
|
|
775
|
-
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
776
|
-
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
|
|
777
|
-
GSI1_SK: (0, _keys.createGSISortKey)(entry)
|
|
778
|
-
}))];
|
|
779
|
-
/**
|
|
780
|
-
* We need the latest entry to see if something needs to be updated along side the request review one.
|
|
781
|
-
*/
|
|
782
|
-
|
|
783
|
-
const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
|
|
784
|
-
|
|
785
|
-
if (latestStorageEntry && latestStorageEntry.id === entry.id) {
|
|
786
|
-
items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
|
|
787
|
-
PK: partitionKey,
|
|
788
|
-
SK: (0, _keys.createLatestSortKey)(),
|
|
789
|
-
TYPE: createLatestType(),
|
|
790
|
-
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "L"),
|
|
791
|
-
GSI1_SK: (0, _keys.createGSISortKey)(entry)
|
|
792
|
-
})));
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
try {
|
|
796
|
-
await (0, _batchWrite.batchWriteAll)({
|
|
797
|
-
table: entity.table,
|
|
798
|
-
items
|
|
799
|
-
});
|
|
800
|
-
dataLoaders.clearAll({
|
|
801
|
-
model
|
|
802
|
-
});
|
|
803
|
-
return initialStorageEntry;
|
|
804
|
-
} catch (ex) {
|
|
805
|
-
throw new _error.default(ex.message || "Could not execute request review batch.", ex.code || "REQUEST_REVIEW_ERROR", {
|
|
806
|
-
entry,
|
|
807
|
-
storageEntry
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
};
|
|
811
|
-
|
|
812
704
|
const publish = async (model, params) => {
|
|
813
705
|
const {
|
|
814
706
|
entry,
|
|
@@ -837,13 +729,13 @@ const createEntriesStorageOperations = params => {
|
|
|
837
729
|
* - previous published entry to unpublished status - if any previously published entry
|
|
838
730
|
*/
|
|
839
731
|
|
|
840
|
-
const items = [entity.putBatch(
|
|
732
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
841
733
|
PK: partitionKey,
|
|
842
734
|
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
843
735
|
TYPE: createType(),
|
|
844
736
|
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
|
|
845
737
|
GSI1_SK: (0, _keys.createGSISortKey)(entry)
|
|
846
|
-
})), entity.putBatch(
|
|
738
|
+
})), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
847
739
|
PK: partitionKey,
|
|
848
740
|
SK: (0, _keys.createPublishedSortKey)(),
|
|
849
741
|
TYPE: createPublishedType(),
|
|
@@ -852,7 +744,7 @@ const createEntriesStorageOperations = params => {
|
|
|
852
744
|
}))];
|
|
853
745
|
|
|
854
746
|
if (initialLatestStorageEntry && entry.id === initialLatestStorageEntry.id) {
|
|
855
|
-
items.push(entity.putBatch(
|
|
747
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
856
748
|
PK: partitionKey,
|
|
857
749
|
SK: (0, _keys.createLatestSortKey)(),
|
|
858
750
|
TYPE: createLatestType(),
|
|
@@ -866,7 +758,7 @@ const createEntriesStorageOperations = params => {
|
|
|
866
758
|
storageEntry: initialPublishedStorageEntry,
|
|
867
759
|
model
|
|
868
760
|
});
|
|
869
|
-
items.push(entity.putBatch(
|
|
761
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedStorageEntry), {}, {
|
|
870
762
|
PK: partitionKey,
|
|
871
763
|
SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry),
|
|
872
764
|
TYPE: createType(),
|
|
@@ -918,7 +810,7 @@ const createEntriesStorageOperations = params => {
|
|
|
918
810
|
const items = [entity.deleteBatch({
|
|
919
811
|
PK: partitionKey,
|
|
920
812
|
SK: (0, _keys.createPublishedSortKey)()
|
|
921
|
-
}), entity.putBatch(
|
|
813
|
+
}), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
922
814
|
PK: partitionKey,
|
|
923
815
|
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
924
816
|
TYPE: createType(),
|
|
@@ -932,7 +824,7 @@ const createEntriesStorageOperations = params => {
|
|
|
932
824
|
const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
|
|
933
825
|
|
|
934
826
|
if (latestStorageEntry && entry.id === latestStorageEntry.id) {
|
|
935
|
-
items.push(entity.putBatch(
|
|
827
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
936
828
|
PK: partitionKey,
|
|
937
829
|
SK: (0, _keys.createLatestSortKey)(),
|
|
938
830
|
TYPE: createLatestType(),
|
|
@@ -973,8 +865,6 @@ const createEntriesStorageOperations = params => {
|
|
|
973
865
|
getLatestRevisionByEntryId,
|
|
974
866
|
get,
|
|
975
867
|
getRevisions,
|
|
976
|
-
requestChanges,
|
|
977
|
-
requestReview,
|
|
978
868
|
publish,
|
|
979
869
|
list,
|
|
980
870
|
unpublish
|