@webiny/api-headless-cms-ddb 0.0.0-unstable.5e7233243f → 0.0.0-unstable.fcdad0bc61
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 +3 -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.js +1 -1
- package/dynamoDb/storage/longText.js +1 -1
- package/dynamoDb/storage/richText.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +23 -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/index.js +22 -149
- 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/entry/utils.js +3 -7
- package/operations/entry/utils.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 +15 -16
- package/plugins/CmsEntryFieldFilterPathPlugin.js +1 -1
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +18 -0
- package/plugins/index.js.map +1 -0
|
@@ -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
|
|
|
@@ -31,10 +31,6 @@ var _zeroPad = require("@webiny/utils/zeroPad");
|
|
|
31
31
|
|
|
32
32
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
33
33
|
|
|
34
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
37
|
-
|
|
38
34
|
const createType = () => {
|
|
39
35
|
return "cms.entry";
|
|
40
36
|
};
|
|
@@ -56,7 +52,7 @@ const convertToStorageEntry = params => {
|
|
|
56
52
|
fields: model.fields,
|
|
57
53
|
values: storageEntry.values
|
|
58
54
|
});
|
|
59
|
-
return
|
|
55
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
60
56
|
values
|
|
61
57
|
});
|
|
62
58
|
};
|
|
@@ -70,7 +66,7 @@ const convertFromStorageEntry = params => {
|
|
|
70
66
|
fields: model.fields,
|
|
71
67
|
values: storageEntry.values
|
|
72
68
|
});
|
|
73
|
-
return
|
|
69
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
74
70
|
values
|
|
75
71
|
});
|
|
76
72
|
};
|
|
@@ -132,14 +128,14 @@ const createEntriesStorageOperations = params => {
|
|
|
132
128
|
* - create new or update latest entry item
|
|
133
129
|
*/
|
|
134
130
|
|
|
135
|
-
const items = [entity.putBatch(
|
|
131
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
136
132
|
locked,
|
|
137
133
|
PK: partitionKey,
|
|
138
134
|
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
139
135
|
TYPE: createType(),
|
|
140
136
|
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
|
|
141
137
|
GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
|
|
142
|
-
})), entity.putBatch(
|
|
138
|
+
})), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
143
139
|
locked,
|
|
144
140
|
PK: partitionKey,
|
|
145
141
|
SK: (0, _keys.createLatestSortKey)(),
|
|
@@ -152,7 +148,7 @@ const createEntriesStorageOperations = params => {
|
|
|
152
148
|
*/
|
|
153
149
|
|
|
154
150
|
if (isPublished) {
|
|
155
|
-
items.push(entity.putBatch(
|
|
151
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
156
152
|
locked,
|
|
157
153
|
PK: partitionKey,
|
|
158
154
|
SK: (0, _keys.createPublishedSortKey)(),
|
|
@@ -200,13 +196,13 @@ const createEntriesStorageOperations = params => {
|
|
|
200
196
|
* - update the last entry item to a current one
|
|
201
197
|
*/
|
|
202
198
|
|
|
203
|
-
const items = [entity.putBatch(
|
|
199
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
204
200
|
PK: partitionKey,
|
|
205
201
|
SK: (0, _keys.createRevisionSortKey)(storageEntry),
|
|
206
202
|
TYPE: createType(),
|
|
207
203
|
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
|
|
208
204
|
GSI1_SK: (0, _keys.createGSISortKey)(storageEntry)
|
|
209
|
-
})), entity.putBatch(
|
|
205
|
+
})), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
210
206
|
PK: partitionKey,
|
|
211
207
|
SK: (0, _keys.createLatestSortKey)(),
|
|
212
208
|
TYPE: createLatestType(),
|
|
@@ -260,7 +256,7 @@ const createEntriesStorageOperations = params => {
|
|
|
260
256
|
* - update the latest entry if the current entry is the latest one
|
|
261
257
|
*/
|
|
262
258
|
|
|
263
|
-
items.push(entity.putBatch(
|
|
259
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
264
260
|
locked,
|
|
265
261
|
PK: partitionKey,
|
|
266
262
|
SK: (0, _keys.createRevisionSortKey)(storageEntry),
|
|
@@ -270,7 +266,7 @@ const createEntriesStorageOperations = params => {
|
|
|
270
266
|
})));
|
|
271
267
|
|
|
272
268
|
if (isPublished) {
|
|
273
|
-
items.push(entity.putBatch(
|
|
269
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
274
270
|
locked,
|
|
275
271
|
PK: partitionKey,
|
|
276
272
|
SK: (0, _keys.createPublishedSortKey)(),
|
|
@@ -287,7 +283,7 @@ const createEntriesStorageOperations = params => {
|
|
|
287
283
|
const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
|
|
288
284
|
|
|
289
285
|
if (latestStorageEntry && latestStorageEntry.id === entry.id) {
|
|
290
|
-
items.push(entity.putBatch(
|
|
286
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
291
287
|
locked,
|
|
292
288
|
PK: partitionKey,
|
|
293
289
|
SK: (0, _keys.createLatestSortKey)(),
|
|
@@ -397,7 +393,7 @@ const createEntriesStorageOperations = params => {
|
|
|
397
393
|
storageEntry: initialLatestStorageEntry,
|
|
398
394
|
model
|
|
399
395
|
});
|
|
400
|
-
items.push(entity.putBatch(
|
|
396
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestStorageEntry), {}, {
|
|
401
397
|
PK: partitionKey,
|
|
402
398
|
SK: (0, _keys.createLatestSortKey)(),
|
|
403
399
|
TYPE: createLatestType(),
|
|
@@ -568,7 +564,7 @@ const createEntriesStorageOperations = params => {
|
|
|
568
564
|
model
|
|
569
565
|
});
|
|
570
566
|
} catch (ex) {
|
|
571
|
-
throw new _error.default(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR",
|
|
567
|
+
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
568
|
error: ex,
|
|
573
569
|
partitionKey: queryParams.partitionKey,
|
|
574
570
|
options: queryParams.options,
|
|
@@ -617,8 +613,7 @@ const createEntriesStorageOperations = params => {
|
|
|
617
613
|
};
|
|
618
614
|
}
|
|
619
615
|
|
|
620
|
-
const where =
|
|
621
|
-
|
|
616
|
+
const where = (0, _objectSpread2.default)({}, initialWhere);
|
|
622
617
|
delete where["published"];
|
|
623
618
|
delete where["latest"];
|
|
624
619
|
/**
|
|
@@ -683,132 +678,12 @@ const createEntriesStorageOperations = params => {
|
|
|
683
678
|
const get = async (model, params) => {
|
|
684
679
|
const {
|
|
685
680
|
items
|
|
686
|
-
} = await list(model,
|
|
681
|
+
} = await list(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
687
682
|
limit: 1
|
|
688
683
|
}));
|
|
689
684
|
return items.shift() || null;
|
|
690
685
|
};
|
|
691
686
|
|
|
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
687
|
const publish = async (model, params) => {
|
|
813
688
|
const {
|
|
814
689
|
entry,
|
|
@@ -837,13 +712,13 @@ const createEntriesStorageOperations = params => {
|
|
|
837
712
|
* - previous published entry to unpublished status - if any previously published entry
|
|
838
713
|
*/
|
|
839
714
|
|
|
840
|
-
const items = [entity.putBatch(
|
|
715
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
841
716
|
PK: partitionKey,
|
|
842
717
|
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
843
718
|
TYPE: createType(),
|
|
844
719
|
GSI1_PK: (0, _keys.createGSIPartitionKey)(model, "A"),
|
|
845
720
|
GSI1_SK: (0, _keys.createGSISortKey)(entry)
|
|
846
|
-
})), entity.putBatch(
|
|
721
|
+
})), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
847
722
|
PK: partitionKey,
|
|
848
723
|
SK: (0, _keys.createPublishedSortKey)(),
|
|
849
724
|
TYPE: createPublishedType(),
|
|
@@ -852,7 +727,7 @@ const createEntriesStorageOperations = params => {
|
|
|
852
727
|
}))];
|
|
853
728
|
|
|
854
729
|
if (initialLatestStorageEntry && entry.id === initialLatestStorageEntry.id) {
|
|
855
|
-
items.push(entity.putBatch(
|
|
730
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
856
731
|
PK: partitionKey,
|
|
857
732
|
SK: (0, _keys.createLatestSortKey)(),
|
|
858
733
|
TYPE: createLatestType(),
|
|
@@ -866,7 +741,7 @@ const createEntriesStorageOperations = params => {
|
|
|
866
741
|
storageEntry: initialPublishedStorageEntry,
|
|
867
742
|
model
|
|
868
743
|
});
|
|
869
|
-
items.push(entity.putBatch(
|
|
744
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedStorageEntry), {}, {
|
|
870
745
|
PK: partitionKey,
|
|
871
746
|
SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry),
|
|
872
747
|
TYPE: createType(),
|
|
@@ -918,7 +793,7 @@ const createEntriesStorageOperations = params => {
|
|
|
918
793
|
const items = [entity.deleteBatch({
|
|
919
794
|
PK: partitionKey,
|
|
920
795
|
SK: (0, _keys.createPublishedSortKey)()
|
|
921
|
-
}), entity.putBatch(
|
|
796
|
+
}), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
922
797
|
PK: partitionKey,
|
|
923
798
|
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
924
799
|
TYPE: createType(),
|
|
@@ -932,7 +807,7 @@ const createEntriesStorageOperations = params => {
|
|
|
932
807
|
const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);
|
|
933
808
|
|
|
934
809
|
if (latestStorageEntry && entry.id === latestStorageEntry.id) {
|
|
935
|
-
items.push(entity.putBatch(
|
|
810
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
936
811
|
PK: partitionKey,
|
|
937
812
|
SK: (0, _keys.createLatestSortKey)(),
|
|
938
813
|
TYPE: createLatestType(),
|
|
@@ -973,8 +848,6 @@ const createEntriesStorageOperations = params => {
|
|
|
973
848
|
getLatestRevisionByEntryId,
|
|
974
849
|
get,
|
|
975
850
|
getRevisions,
|
|
976
|
-
requestChanges,
|
|
977
|
-
requestReview,
|
|
978
851
|
publish,
|
|
979
852
|
list,
|
|
980
853
|
unpublish
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createType","createLatestType","createPublishedType","convertToStorageEntry","params","model","storageEntry","values","convertValueKeyToStorage","fields","convertFromStorageEntry","convertValueKeyFromStorage","createEntriesStorageOperations","entity","plugins","dataLoaders","DataLoadersHandler","storageTransformPlugins","byType","StorageTransformPlugin","type","reduce","collection","plugin","fieldType","createStorageTransformCallable","field","value","fromStorage","getStoragePlugin","create","entry","initialStorageEntry","partitionKey","createPartitionKey","id","locale","tenant","isPublished","status","locked","items","putBatch","PK","SK","createRevisionSortKey","TYPE","GSI1_PK","createGSIPartitionKey","GSI1_SK","createGSISortKey","createLatestSortKey","push","createPublishedSortKey","batchWriteAll","table","clearAll","ex","WebinyError","message","code","error","createRevisionFrom","update","latestStorageEntry","getLatestRevisionByEntryId","deleteEntry","queryAllParams","options","gte","records","queryAll","map","item","deleteBatch","deleteRevision","latestEntry","initialLatestStorageEntry","publishedStorageEntry","getPublishedRevisionByEntryId","ids","shift","getRevisionById","getRevisions","getAllEntryRevisions","getByIds","getLatestByIds","getPublishedByIds","getPreviousRevision","entryId","version","queryParams","lt","zeroPad","filters","attr","eq","reverse","result","queryOne","cleanupItem","list","limit","initialLimit","where","initialWhere","after","sort","search","published","index","length","hasMoreItems","totalCount","cursor","modelFields","buildModelFields","filteredItems","filterItems","record","fullTextSearch","term","sortedItems","sortEntryItems","start","parseInt","decodeCursor","end","undefined","slicedItems","slice","encodeCursor","cleanupItems","get","requestChanges","requestReview","publish","initialPublishedStorageEntry","CONTENT_ENTRY_STATUS","UNPUBLISHED","unpublish","delete"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { DataLoadersHandler } from \"./dataLoaders\";\nimport {\n CmsEntry,\n CmsEntryListWhere,\n CmsEntryStorageOperations,\n CmsEntryStorageOperationsCreateParams,\n CmsEntryStorageOperationsCreateRevisionFromParams,\n CmsEntryStorageOperationsDeleteParams,\n CmsEntryStorageOperationsDeleteRevisionParams,\n CmsEntryStorageOperationsGetByIdsParams,\n CmsEntryStorageOperationsGetLatestByIdsParams,\n CmsEntryStorageOperationsGetLatestRevisionParams,\n CmsEntryStorageOperationsGetParams,\n CmsEntryStorageOperationsGetPreviousRevisionParams,\n CmsEntryStorageOperationsGetPublishedByIdsParams,\n CmsEntryStorageOperationsGetRevisionParams,\n CmsEntryStorageOperationsGetRevisionsParams,\n CmsEntryStorageOperationsListParams,\n CmsEntryStorageOperationsPublishParams,\n CmsEntryStorageOperationsRequestChangesParams,\n CmsEntryStorageOperationsRequestReviewParams,\n CmsEntryStorageOperationsUnpublishParams,\n CmsEntryStorageOperationsUpdateParams,\n StorageOperationsCmsModel,\n CONTENT_ENTRY_STATUS,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { filterItems, buildModelFields, sortEntryItems, FilterItemFromStorage } from \"./utils\";\nimport {\n createGSIPartitionKey,\n createGSISortKey,\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"~/operations/entry/keys\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport {\n queryAll,\n QueryAllParams,\n queryOne,\n QueryOneParams\n} from \"@webiny/db-dynamodb/utils/query\";\nimport { cleanupItem, cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { decodeCursor, encodeCursor } from \"@webiny/utils/cursor\";\nimport { zeroPad } from \"@webiny/utils/zeroPad\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst createType = (): string => {\n return \"cms.entry\";\n};\nconst createLatestType = (): string => {\n return `${createType()}.l`;\n};\nconst createPublishedType = (): string => {\n return `${createType()}.p`;\n};\n\ninterface ConvertStorageEntryParams {\n storageEntry: CmsStorageEntry;\n model: StorageOperationsCmsModel;\n}\nconst convertToStorageEntry = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, storageEntry } = params;\n\n const values = model.convertValueKeyToStorage({\n fields: model.fields,\n values: storageEntry.values\n });\n return {\n ...storageEntry,\n values\n };\n};\n\nconst convertFromStorageEntry = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, storageEntry } = params;\n\n const values = model.convertValueKeyFromStorage({\n fields: model.fields,\n values: storageEntry.values\n });\n return {\n ...storageEntry,\n values\n };\n};\n\nexport interface CreateEntriesStorageOperationsParams {\n entity: Entity<any>;\n plugins: PluginsContainer;\n}\nexport const createEntriesStorageOperations = (\n params: CreateEntriesStorageOperationsParams\n): CmsEntryStorageOperations => {\n const { entity, plugins } = params;\n\n const dataLoaders = new DataLoadersHandler({\n entity\n });\n\n const storageTransformPlugins = plugins\n .byType<StorageTransformPlugin>(StorageTransformPlugin.type)\n .reduce((collection, plugin) => {\n collection[plugin.fieldType] = plugin;\n return collection;\n }, {} as Record<string, StorageTransformPlugin>);\n\n const createStorageTransformCallable = (\n model: StorageOperationsCmsModel\n ): FilterItemFromStorage => {\n return (field, value) => {\n const plugin: StorageTransformPlugin = storageTransformPlugins[field.type];\n if (!plugin) {\n return value;\n }\n return plugin.fromStorage({\n model,\n field,\n value,\n getStoragePlugin(fieldType: string): StorageTransformPlugin {\n return storageTransformPlugins[fieldType] || storageTransformPlugins[\"*\"];\n },\n plugins\n });\n };\n };\n\n const create = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsCreateParams\n ) => {\n const { entry, storageEntry: initialStorageEntry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const isPublished = entry.status === \"published\";\n\n const locked = isPublished ? true : entry.locked;\n\n const storageEntry = convertToStorageEntry({\n model,\n storageEntry: initialStorageEntry\n });\n /**\n * We need to:\n * - create new main entry item\n * - create new or update latest entry item\n */\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createType(),\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(storageEntry)\n }),\n entity.putBatch({\n ...storageEntry,\n locked,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(storageEntry)\n })\n ];\n\n /**\n * We need to create published entry if\n */\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n PK: partitionKey,\n SK: createPublishedSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"P\"),\n GSI1_SK: createGSISortKey(storageEntry)\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert data into the DynamoDB.\",\n ex.code || \"CREATE_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n\n return initialStorageEntry;\n };\n\n const createRevisionFrom = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams\n ) => {\n const { entry, storageEntry: initialStorageEntry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const storageEntry = convertToStorageEntry({\n storageEntry: initialStorageEntry,\n model\n });\n /**\n * We need to:\n * - create the main entry item\n * - update the last entry item to a current one\n */\n const items = [\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(storageEntry),\n TYPE: createType(),\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(storageEntry)\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(storageEntry)\n })\n ];\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create revision from given entry.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n /**\n * There are no modifications on the entry created so just return the data.\n */\n return initialStorageEntry;\n };\n\n const update = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsUpdateParams\n ) => {\n const { entry, storageEntry: initialStorageEntry } = params;\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const items = [];\n\n const storageEntry = convertToStorageEntry({\n model,\n storageEntry: initialStorageEntry\n });\n /**\n * We need to:\n * - update the current entry\n * - update the latest entry if the current entry is the latest one\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n PK: partitionKey,\n SK: createRevisionSortKey(storageEntry),\n TYPE: createType(),\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(storageEntry)\n })\n );\n\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n PK: partitionKey,\n SK: createPublishedSortKey(),\n TYPE: createPublishedType(),\n GSI1_PK: createGSIPartitionKey(model, \"P\"),\n GSI1_SK: createGSISortKey(storageEntry)\n })\n );\n }\n\n /**\n * We need the latest entry to update it as well if neccessary.\n */\n const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);\n\n if (latestStorageEntry && latestStorageEntry.id === entry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(entry)\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n return initialStorageEntry;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry.\",\n ex.code || \"UPDATE_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry\n }\n );\n }\n };\n\n const deleteEntry = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsDeleteParams\n ) => {\n const { entry } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n options: {\n gte: \" \"\n }\n };\n\n let records = [];\n try {\n records = await queryAll(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not load all records.\",\n ex.code || \"LOAD_ALL_RECORDS_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n const items = records.map(item => {\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete the entry.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n partitionKey: queryAllParams.partitionKey,\n entry\n }\n );\n }\n };\n\n const deleteRevision = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams\n ) => {\n const { entry, latestEntry, latestStorageEntry: initialLatestStorageEntry } = params;\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n })\n ];\n\n const publishedStorageEntry = await getPublishedRevisionByEntryId(model, entry);\n\n /**\n * If revision we are deleting is the published one as well, we need to delete those records as well.\n */\n if (publishedStorageEntry && entry.id === publishedStorageEntry.id) {\n items.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n if (initialLatestStorageEntry) {\n const latestStorageEntry = convertToStorageEntry({\n storageEntry: initialLatestStorageEntry,\n model\n });\n items.push(\n entity.putBatch({\n ...latestStorageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(latestStorageEntry)\n })\n );\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code, {\n error: ex,\n entry,\n latestEntry\n });\n }\n };\n\n const getLatestRevisionByEntryId = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => {\n const items = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [params.id]\n });\n const item = items.shift() || null;\n if (!item) {\n return null;\n }\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n };\n const getPublishedRevisionByEntryId = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => {\n const items = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [params.id]\n });\n const item = items.shift() || null;\n if (!item) {\n return null;\n }\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n };\n\n const getRevisionById = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) => {\n const items = await dataLoaders.getRevisionById({\n model,\n ids: [params.id]\n });\n const item = items.shift() || null;\n if (!item) {\n return null;\n }\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n };\n\n const getRevisions = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) => {\n const items = await dataLoaders.getAllEntryRevisions({\n model,\n ids: [params.id]\n });\n\n return items.map(item => {\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n });\n };\n\n const getByIds = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetByIdsParams\n ) => {\n const items = await dataLoaders.getRevisionById({\n model,\n ids: params.ids\n });\n\n return items.map(item => {\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n });\n };\n\n const getLatestByIds = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) => {\n const items = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: params.ids\n });\n\n return items.map(item => {\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n });\n };\n\n const getPublishedByIds = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) => {\n const items = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: params.ids\n });\n\n return items.map(item => {\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n });\n };\n\n const getPreviousRevision = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) => {\n const { entryId, version } = params;\n const queryParams: QueryOneParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant: model.tenant,\n locale: model.locale,\n id: entryId\n }),\n options: {\n lt: `REV#${zeroPad(version)}`,\n /**\n * We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.\n */\n filters: [\n {\n attr: \"TYPE\",\n eq: createType()\n },\n {\n attr: \"version\",\n lt: version\n }\n ],\n reverse: true\n }\n };\n\n try {\n const result = await queryOne<CmsEntry>(queryParams);\n\n const storageEntry = cleanupItem(entity, result);\n if (!storageEntry) {\n return null;\n }\n return convertFromStorageEntry({\n storageEntry,\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get previous version of given entry.\",\n ex.code || \"GET_PREVIOUS_VERSION_ERROR\",\n {\n ...params,\n error: ex,\n partitionKey: queryParams.partitionKey,\n options: queryParams.options,\n model\n }\n );\n }\n };\n\n const list = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsListParams\n ) => {\n const {\n limit: initialLimit = 10,\n where: initialWhere,\n after,\n sort,\n fields,\n search\n } = params;\n const limit = initialLimit <= 0 || initialLimit >= 10000 ? 10000 : initialLimit;\n\n const type = initialWhere.published ? \"P\" : \"L\";\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createGSIPartitionKey(model, type),\n options: {\n index: \"GSI1\",\n gte: \" \"\n }\n };\n let records = [];\n try {\n records = await queryAll(queryAllParams);\n } catch (ex) {\n throw new WebinyError(ex.message, \"QUERY_ENTRIES_ERROR\", {\n error: ex,\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n });\n }\n if (records.length === 0) {\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: []\n };\n }\n const where: Partial<CmsEntryListWhere> = {\n ...initialWhere\n };\n delete where[\"published\"];\n delete where[\"latest\"];\n /**\n * We need a object containing field, transformers and paths.\n * Just build it here and pass on into other methods that require it to avoid mapping multiple times.\n */\n const modelFields = buildModelFields({\n plugins,\n model\n });\n /**\n * Filter the read items via the code.\n * It will build the filters out of the where input and transform the values it is using.\n */\n const filteredItems = await filterItems({\n items: records.map(record => {\n return convertFromStorageEntry({\n storageEntry: record,\n model\n });\n }),\n where,\n plugins,\n fields: modelFields,\n fromStorage: createStorageTransformCallable(model),\n fullTextSearch: {\n term: search,\n fields: fields || []\n }\n });\n\n const totalCount = filteredItems.length;\n\n /**\n * Sorting is also done via the code.\n * It takes the sort input and sorts by it via the lodash sortBy method.\n */\n const sortedItems = sortEntryItems({\n items: filteredItems,\n sort,\n fields: modelFields\n });\n\n const start = parseInt((decodeCursor(after) as string) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const end = limit > totalCount + start + limit ? undefined : start + limit;\n const slicedItems = sortedItems.slice(start, end);\n /**\n * Although we do not need a cursor here, we will use it as such to keep it standardized.\n * Number is simply encoded.\n */\n const cursor = totalCount > start + limit ? encodeCursor(`${start + limit}`) : null;\n return {\n hasMoreItems,\n totalCount,\n cursor,\n items: cleanupItems(entity, slicedItems)\n };\n };\n\n const get = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetParams\n ) => {\n const { items } = await list(model, {\n ...params,\n limit: 1\n });\n return items.shift() || null;\n };\n\n const requestChanges = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsRequestChangesParams\n ) => {\n const { entry, storageEntry: initialStorageEntry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const storageEntry = convertToStorageEntry({\n storageEntry: initialStorageEntry,\n model\n });\n\n /**\n * We need to:\n * - update the existing entry\n * - update latest version - if existing entry is the latest version\n */\n const items = [\n entity.putBatch({\n ...storageEntry,\n TYPE: createType(),\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(entry)\n })\n ];\n\n /**\n * We need the latest entry to see if something needs to be updated along side the request changes one.\n */\n const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);\n\n if (latestStorageEntry && latestStorageEntry.id === entry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(entry)\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not execute the request changes batch.\",\n ex.code || \"REQUEST_CHANGES_ERROR\",\n {\n entry\n }\n );\n }\n return entry;\n };\n\n const requestReview = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsRequestReviewParams\n ) => {\n const { entry, storageEntry: initialStorageEntry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const storageEntry = convertToStorageEntry({\n storageEntry: initialStorageEntry,\n model\n });\n /**\n * We need to:\n * - update existing entry\n * - update latest entry - if existing entry is the latest entry\n */\n const items = [\n entity.putBatch({\n ...storageEntry,\n TYPE: createType(),\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(entry)\n })\n ];\n\n /**\n * We need the latest entry to see if something needs to be updated along side the request review one.\n */\n const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);\n\n if (latestStorageEntry && latestStorageEntry.id === entry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(entry)\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n return initialStorageEntry;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not execute request review batch.\",\n ex.code || \"REQUEST_REVIEW_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n };\n\n const publish = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsPublishParams\n ) => {\n const { entry, storageEntry: initialStorageEntry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n /**\n * We need the latest and published entries to see if something needs to be updated along side the publishing one.\n */\n const initialLatestStorageEntry = await getLatestRevisionByEntryId(model, entry);\n const initialPublishedStorageEntry = await getPublishedRevisionByEntryId(model, entry);\n\n const storageEntry = convertToStorageEntry({\n model,\n storageEntry: initialStorageEntry\n });\n /**\n * We need to update:\n * - current entry revision sort key\n * - published sort key\n * - latest sort key - if entry updated is actually latest\n * - previous published entry to unpublished status - if any previously published entry\n */\n const items = [\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createType(),\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(entry)\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createPublishedSortKey(),\n TYPE: createPublishedType(),\n GSI1_PK: createGSIPartitionKey(model, \"P\"),\n GSI1_SK: createGSISortKey(entry)\n })\n ];\n if (initialLatestStorageEntry && entry.id === initialLatestStorageEntry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(entry)\n })\n );\n }\n if (initialPublishedStorageEntry && initialPublishedStorageEntry.id !== entry.id) {\n const publishedStorageEntry = convertToStorageEntry({\n storageEntry: initialPublishedStorageEntry,\n model\n });\n items.push(\n entity.putBatch({\n ...publishedStorageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(publishedStorageEntry),\n TYPE: createType(),\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED,\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(publishedStorageEntry)\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n return initialStorageEntry;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not execute the publishing batch.\",\n ex.code || \"PUBLISH_ERROR\",\n {\n entry,\n latestStorageEntry: initialLatestStorageEntry,\n publishedStorageEntry: initialPublishedStorageEntry\n }\n );\n }\n };\n\n const unpublish = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsUnpublishParams\n ) => {\n const { entry, storageEntry: initialStorageEntry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const storageEntry = convertToStorageEntry({\n storageEntry: initialStorageEntry,\n model\n });\n /**\n * We need to:\n * - delete currently published entry\n * - update current entry revision with new data\n * - update latest entry status - if entry being unpublished is latest\n */\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createType(),\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(entry)\n })\n ];\n\n /**\n * We need the latest entry to see if something needs to be updated along side the unpublishing one.\n */\n const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);\n\n if (latestStorageEntry && entry.id === latestStorageEntry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(entry)\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n return initialStorageEntry;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not execute unpublish batch.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n };\n\n return {\n create,\n createRevisionFrom,\n update,\n delete: deleteEntry,\n deleteRevision,\n getPreviousRevision,\n getPublishedByIds,\n getLatestByIds,\n getByIds,\n getRevisionById,\n getPublishedRevisionByEntryId,\n getLatestRevisionByEntryId,\n get,\n getRevisions,\n requestChanges,\n requestReview,\n publish,\n list,\n unpublish\n };\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AA2BA;;AACA;;AAQA;;AACA;;AAMA;;AAEA;;AACA;;AACA;;;;;;AAEA,MAAMA,UAAU,GAAG,MAAc;EAC7B,OAAO,WAAP;AACH,CAFD;;AAGA,MAAMC,g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B;MANb,GADJ;IAUH;;IAED,IAAI;MACA,MAAM,IAAAuB,yBAAA,EAAc;QAChBC,KAAK,EAAE1C,MAAM,CAAC0C,KADE;QAEhBd;MAFgB,CAAd,CAAN;MAIA1B,WAAW,CAACyC,QAAZ,CAAqB;QACjBnD;MADiB,CAArB;MAGA,OAAO2B,mBAAP;IACH,CATD,CASE,OAAOyB,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,oCADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,iBAFT,EAGF;QACI7B,KADJ;QAEIzB;MAFJ,CAHE,CAAN;IAQH;EACJ,CA1ED;;EA4EA,OAAO;IACHwB,MADG;IAEHgC,kBAFG;IAGHC,MAHG;IAIH8E,MAAM,EAAE3E,WAJL;IAKHS,cALG;IAMHa,mBANG;IAOHD,iBAPG;IAQHD,cARG;IASHD,QATG;IAUHH,eAVG;IAWHH,6BAXG;IAYHd,0BAZG;IAaHoE,GAbG;IAcHlD,YAdG;IAeHmD,cAfG;IAgBHC,aAhBG;IAiBHC,OAjBG;IAkBHnC,IAlBG;IAmBHuC;EAnBG,CAAP;AAqBH,CAxgCM"}
|
|
1
|
+
{"version":3,"names":["createType","createLatestType","createPublishedType","convertToStorageEntry","params","model","storageEntry","values","convertValueKeyToStorage","fields","convertFromStorageEntry","convertValueKeyFromStorage","createEntriesStorageOperations","entity","plugins","dataLoaders","DataLoadersHandler","storageTransformPlugins","byType","StorageTransformPlugin","type","reduce","collection","plugin","fieldType","createStorageTransformCallable","field","value","fromStorage","getStoragePlugin","create","entry","initialStorageEntry","partitionKey","createPartitionKey","id","locale","tenant","isPublished","status","locked","items","putBatch","PK","SK","createRevisionSortKey","TYPE","GSI1_PK","createGSIPartitionKey","GSI1_SK","createGSISortKey","createLatestSortKey","push","createPublishedSortKey","batchWriteAll","table","clearAll","ex","WebinyError","message","code","error","createRevisionFrom","update","latestStorageEntry","getLatestRevisionByEntryId","deleteEntry","queryAllParams","options","gte","records","queryAll","map","item","deleteBatch","deleteRevision","latestEntry","initialLatestStorageEntry","publishedStorageEntry","getPublishedRevisionByEntryId","ids","shift","getRevisionById","getRevisions","getAllEntryRevisions","getByIds","getLatestByIds","getPublishedByIds","getPreviousRevision","entryId","version","queryParams","lt","zeroPad","filters","attr","eq","reverse","result","queryOne","cleanupItem","list","limit","initialLimit","where","initialWhere","after","sort","search","published","index","length","hasMoreItems","totalCount","cursor","modelFields","buildModelFields","filteredItems","filterItems","record","fullTextSearch","term","sortedItems","sortEntryItems","start","parseInt","decodeCursor","end","undefined","slicedItems","slice","encodeCursor","cleanupItems","get","publish","initialPublishedStorageEntry","CONTENT_ENTRY_STATUS","UNPUBLISHED","unpublish","delete"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { DataLoadersHandler } from \"./dataLoaders\";\nimport {\n CmsEntry,\n CmsEntryListWhere,\n CmsEntryStorageOperations,\n CmsEntryStorageOperationsCreateParams,\n CmsEntryStorageOperationsCreateRevisionFromParams,\n CmsEntryStorageOperationsDeleteParams,\n CmsEntryStorageOperationsDeleteRevisionParams,\n CmsEntryStorageOperationsGetByIdsParams,\n CmsEntryStorageOperationsGetLatestByIdsParams,\n CmsEntryStorageOperationsGetLatestRevisionParams,\n CmsEntryStorageOperationsGetParams,\n CmsEntryStorageOperationsGetPreviousRevisionParams,\n CmsEntryStorageOperationsGetPublishedByIdsParams,\n CmsEntryStorageOperationsGetRevisionParams,\n CmsEntryStorageOperationsGetRevisionsParams,\n CmsEntryStorageOperationsListParams,\n CmsEntryStorageOperationsPublishParams,\n CmsEntryStorageOperationsUnpublishParams,\n CmsEntryStorageOperationsUpdateParams,\n StorageOperationsCmsModel,\n CONTENT_ENTRY_STATUS,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { filterItems, buildModelFields, sortEntryItems, FilterItemFromStorage } from \"./utils\";\nimport {\n createGSIPartitionKey,\n createGSISortKey,\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"~/operations/entry/keys\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport {\n queryAll,\n QueryAllParams,\n queryOne,\n QueryOneParams\n} from \"@webiny/db-dynamodb/utils/query\";\nimport { cleanupItem, cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { decodeCursor, encodeCursor } from \"@webiny/utils/cursor\";\nimport { zeroPad } from \"@webiny/utils/zeroPad\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst createType = (): string => {\n return \"cms.entry\";\n};\nconst createLatestType = (): string => {\n return `${createType()}.l`;\n};\nconst createPublishedType = (): string => {\n return `${createType()}.p`;\n};\n\ninterface ConvertStorageEntryParams {\n storageEntry: CmsStorageEntry;\n model: StorageOperationsCmsModel;\n}\nconst convertToStorageEntry = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, storageEntry } = params;\n\n const values = model.convertValueKeyToStorage({\n fields: model.fields,\n values: storageEntry.values\n });\n return {\n ...storageEntry,\n values\n };\n};\n\nconst convertFromStorageEntry = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, storageEntry } = params;\n\n const values = model.convertValueKeyFromStorage({\n fields: model.fields,\n values: storageEntry.values\n });\n return {\n ...storageEntry,\n values\n };\n};\n\nexport interface CreateEntriesStorageOperationsParams {\n entity: Entity<any>;\n plugins: PluginsContainer;\n}\nexport const createEntriesStorageOperations = (\n params: CreateEntriesStorageOperationsParams\n): CmsEntryStorageOperations => {\n const { entity, plugins } = params;\n\n const dataLoaders = new DataLoadersHandler({\n entity\n });\n\n const storageTransformPlugins = plugins\n .byType<StorageTransformPlugin>(StorageTransformPlugin.type)\n .reduce((collection, plugin) => {\n collection[plugin.fieldType] = plugin;\n return collection;\n }, {} as Record<string, StorageTransformPlugin>);\n\n const createStorageTransformCallable = (\n model: StorageOperationsCmsModel\n ): FilterItemFromStorage => {\n return (field, value) => {\n const plugin: StorageTransformPlugin = storageTransformPlugins[field.type];\n if (!plugin) {\n return value;\n }\n return plugin.fromStorage({\n model,\n field,\n value,\n getStoragePlugin(fieldType: string): StorageTransformPlugin {\n return storageTransformPlugins[fieldType] || storageTransformPlugins[\"*\"];\n },\n plugins\n });\n };\n };\n\n const create = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsCreateParams\n ) => {\n const { entry, storageEntry: initialStorageEntry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const isPublished = entry.status === \"published\";\n\n const locked = isPublished ? true : entry.locked;\n\n const storageEntry = convertToStorageEntry({\n model,\n storageEntry: initialStorageEntry\n });\n /**\n * We need to:\n * - create new main entry item\n * - create new or update latest entry item\n */\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createType(),\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(storageEntry)\n }),\n entity.putBatch({\n ...storageEntry,\n locked,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(storageEntry)\n })\n ];\n\n /**\n * We need to create published entry if\n */\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n PK: partitionKey,\n SK: createPublishedSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"P\"),\n GSI1_SK: createGSISortKey(storageEntry)\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert data into the DynamoDB.\",\n ex.code || \"CREATE_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n\n return initialStorageEntry;\n };\n\n const createRevisionFrom = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams\n ) => {\n const { entry, storageEntry: initialStorageEntry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const storageEntry = convertToStorageEntry({\n storageEntry: initialStorageEntry,\n model\n });\n /**\n * We need to:\n * - create the main entry item\n * - update the last entry item to a current one\n */\n const items = [\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(storageEntry),\n TYPE: createType(),\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(storageEntry)\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(storageEntry)\n })\n ];\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create revision from given entry.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n /**\n * There are no modifications on the entry created so just return the data.\n */\n return initialStorageEntry;\n };\n\n const update = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsUpdateParams\n ) => {\n const { entry, storageEntry: initialStorageEntry } = params;\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const items = [];\n\n const storageEntry = convertToStorageEntry({\n model,\n storageEntry: initialStorageEntry\n });\n /**\n * We need to:\n * - update the current entry\n * - update the latest entry if the current entry is the latest one\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n PK: partitionKey,\n SK: createRevisionSortKey(storageEntry),\n TYPE: createType(),\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(storageEntry)\n })\n );\n\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n PK: partitionKey,\n SK: createPublishedSortKey(),\n TYPE: createPublishedType(),\n GSI1_PK: createGSIPartitionKey(model, \"P\"),\n GSI1_SK: createGSISortKey(storageEntry)\n })\n );\n }\n\n /**\n * We need the latest entry to update it as well if neccessary.\n */\n const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);\n\n if (latestStorageEntry && latestStorageEntry.id === entry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(entry)\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n return initialStorageEntry;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry.\",\n ex.code || \"UPDATE_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry\n }\n );\n }\n };\n\n const deleteEntry = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsDeleteParams\n ) => {\n const { entry } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n options: {\n gte: \" \"\n }\n };\n\n let records = [];\n try {\n records = await queryAll(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not load all records.\",\n ex.code || \"LOAD_ALL_RECORDS_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n const items = records.map(item => {\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete the entry.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n partitionKey: queryAllParams.partitionKey,\n entry\n }\n );\n }\n };\n\n const deleteRevision = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams\n ) => {\n const { entry, latestEntry, latestStorageEntry: initialLatestStorageEntry } = params;\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n })\n ];\n\n const publishedStorageEntry = await getPublishedRevisionByEntryId(model, entry);\n\n /**\n * If revision we are deleting is the published one as well, we need to delete those records as well.\n */\n if (publishedStorageEntry && entry.id === publishedStorageEntry.id) {\n items.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n if (initialLatestStorageEntry) {\n const latestStorageEntry = convertToStorageEntry({\n storageEntry: initialLatestStorageEntry,\n model\n });\n items.push(\n entity.putBatch({\n ...latestStorageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(latestStorageEntry)\n })\n );\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code, {\n error: ex,\n entry,\n latestEntry\n });\n }\n };\n\n const getLatestRevisionByEntryId = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => {\n const items = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [params.id]\n });\n const item = items.shift() || null;\n if (!item) {\n return null;\n }\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n };\n const getPublishedRevisionByEntryId = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => {\n const items = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [params.id]\n });\n const item = items.shift() || null;\n if (!item) {\n return null;\n }\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n };\n\n const getRevisionById = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) => {\n const items = await dataLoaders.getRevisionById({\n model,\n ids: [params.id]\n });\n const item = items.shift() || null;\n if (!item) {\n return null;\n }\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n };\n\n const getRevisions = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) => {\n const items = await dataLoaders.getAllEntryRevisions({\n model,\n ids: [params.id]\n });\n\n return items.map(item => {\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n });\n };\n\n const getByIds = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetByIdsParams\n ) => {\n const items = await dataLoaders.getRevisionById({\n model,\n ids: params.ids\n });\n\n return items.map(item => {\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n });\n };\n\n const getLatestByIds = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) => {\n const items = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: params.ids\n });\n\n return items.map(item => {\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n });\n };\n\n const getPublishedByIds = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) => {\n const items = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: params.ids\n });\n\n return items.map(item => {\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n });\n };\n\n const getPreviousRevision = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) => {\n const { entryId, version } = params;\n const queryParams: QueryOneParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant: model.tenant,\n locale: model.locale,\n id: entryId\n }),\n options: {\n lt: `REV#${zeroPad(version)}`,\n /**\n * We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.\n */\n filters: [\n {\n attr: \"TYPE\",\n eq: createType()\n },\n {\n attr: \"version\",\n lt: version\n }\n ],\n reverse: true\n }\n };\n\n try {\n const result = await queryOne<CmsEntry>(queryParams);\n\n const storageEntry = cleanupItem(entity, result);\n if (!storageEntry) {\n return null;\n }\n return convertFromStorageEntry({\n storageEntry,\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get previous version of given entry.\",\n ex.code || \"GET_PREVIOUS_VERSION_ERROR\",\n {\n ...params,\n error: ex,\n partitionKey: queryParams.partitionKey,\n options: queryParams.options,\n model\n }\n );\n }\n };\n\n const list = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsListParams\n ) => {\n const {\n limit: initialLimit = 10,\n where: initialWhere,\n after,\n sort,\n fields,\n search\n } = params;\n const limit = initialLimit <= 0 || initialLimit >= 10000 ? 10000 : initialLimit;\n\n const type = initialWhere.published ? \"P\" : \"L\";\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createGSIPartitionKey(model, type),\n options: {\n index: \"GSI1\",\n gte: \" \"\n }\n };\n let records = [];\n try {\n records = await queryAll(queryAllParams);\n } catch (ex) {\n throw new WebinyError(ex.message, \"QUERY_ENTRIES_ERROR\", {\n error: ex,\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n });\n }\n if (records.length === 0) {\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: []\n };\n }\n const where: Partial<CmsEntryListWhere> = {\n ...initialWhere\n };\n delete where[\"published\"];\n delete where[\"latest\"];\n /**\n * We need a object containing field, transformers and paths.\n * Just build it here and pass on into other methods that require it to avoid mapping multiple times.\n */\n const modelFields = buildModelFields({\n plugins,\n model\n });\n /**\n * Filter the read items via the code.\n * It will build the filters out of the where input and transform the values it is using.\n */\n const filteredItems = await filterItems({\n items: records.map(record => {\n return convertFromStorageEntry({\n storageEntry: record,\n model\n });\n }),\n where,\n plugins,\n fields: modelFields,\n fromStorage: createStorageTransformCallable(model),\n fullTextSearch: {\n term: search,\n fields: fields || []\n }\n });\n\n const totalCount = filteredItems.length;\n\n /**\n * Sorting is also done via the code.\n * It takes the sort input and sorts by it via the lodash sortBy method.\n */\n const sortedItems = sortEntryItems({\n items: filteredItems,\n sort,\n fields: modelFields\n });\n\n const start = parseInt((decodeCursor(after) as string) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const end = limit > totalCount + start + limit ? undefined : start + limit;\n const slicedItems = sortedItems.slice(start, end);\n /**\n * Although we do not need a cursor here, we will use it as such to keep it standardized.\n * Number is simply encoded.\n */\n const cursor = totalCount > start + limit ? encodeCursor(`${start + limit}`) : null;\n return {\n hasMoreItems,\n totalCount,\n cursor,\n items: cleanupItems(entity, slicedItems)\n };\n };\n\n const get = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetParams\n ) => {\n const { items } = await list(model, {\n ...params,\n limit: 1\n });\n return items.shift() || null;\n };\n\n const publish = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsPublishParams\n ) => {\n const { entry, storageEntry: initialStorageEntry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n /**\n * We need the latest and published entries to see if something needs to be updated along side the publishing one.\n */\n const initialLatestStorageEntry = await getLatestRevisionByEntryId(model, entry);\n const initialPublishedStorageEntry = await getPublishedRevisionByEntryId(model, entry);\n\n const storageEntry = convertToStorageEntry({\n model,\n storageEntry: initialStorageEntry\n });\n /**\n * We need to update:\n * - current entry revision sort key\n * - published sort key\n * - latest sort key - if entry updated is actually latest\n * - previous published entry to unpublished status - if any previously published entry\n */\n const items = [\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createType(),\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(entry)\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createPublishedSortKey(),\n TYPE: createPublishedType(),\n GSI1_PK: createGSIPartitionKey(model, \"P\"),\n GSI1_SK: createGSISortKey(entry)\n })\n ];\n if (initialLatestStorageEntry && entry.id === initialLatestStorageEntry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(entry)\n })\n );\n }\n if (initialPublishedStorageEntry && initialPublishedStorageEntry.id !== entry.id) {\n const publishedStorageEntry = convertToStorageEntry({\n storageEntry: initialPublishedStorageEntry,\n model\n });\n items.push(\n entity.putBatch({\n ...publishedStorageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(publishedStorageEntry),\n TYPE: createType(),\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED,\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(publishedStorageEntry)\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n return initialStorageEntry;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not execute the publishing batch.\",\n ex.code || \"PUBLISH_ERROR\",\n {\n entry,\n latestStorageEntry: initialLatestStorageEntry,\n publishedStorageEntry: initialPublishedStorageEntry\n }\n );\n }\n };\n\n const unpublish = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsUnpublishParams\n ) => {\n const { entry, storageEntry: initialStorageEntry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const storageEntry = convertToStorageEntry({\n storageEntry: initialStorageEntry,\n model\n });\n /**\n * We need to:\n * - delete currently published entry\n * - update current entry revision with new data\n * - update latest entry status - if entry being unpublished is latest\n */\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createType(),\n GSI1_PK: createGSIPartitionKey(model, \"A\"),\n GSI1_SK: createGSISortKey(entry)\n })\n ];\n\n /**\n * We need the latest entry to see if something needs to be updated along side the unpublishing one.\n */\n const latestStorageEntry = await getLatestRevisionByEntryId(model, entry);\n\n if (latestStorageEntry && entry.id === latestStorageEntry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestType(),\n GSI1_PK: createGSIPartitionKey(model, \"L\"),\n GSI1_SK: createGSISortKey(entry)\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n return initialStorageEntry;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not execute unpublish batch.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n };\n\n return {\n create,\n createRevisionFrom,\n update,\n delete: deleteEntry,\n deleteRevision,\n getPreviousRevision,\n getPublishedByIds,\n getLatestByIds,\n getByIds,\n getRevisionById,\n getPublishedRevisionByEntryId,\n getLatestRevisionByEntryId,\n get,\n getRevisions,\n publish,\n list,\n unpublish\n };\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAyBA;;AACA;;AAQA;;AACA;;AAMA;;AAEA;;AACA;;AACA;;AAEA,MAAMA,UAAU,GAAG,MAAc;EAC7B,OAAO,WAAP;AACH,CAFD;;AAGA,MAAMC,gBAAgB,GAAG,MAAc;EACnC,OAAQ,GAAED,UAAU,EAAG,IAAvB;AACH,CAFD;;AAGA,MAAME,mBAAmB,GAAG,MAAc;EACtC,OAAQ,GAAEF,UAAU,EAAG,IAAvB;AACH,CAFD;;AAQA,MAAMG,qBAAqB,GAAIC,MAAD,IAAwD;EAClF,MAAM;IAAEC,KAAF;IAASC;EAAT,IAA0BF,MAAhC;EAEA,MAAMG,MAAM,GAAGF,KAAK,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,EAAsB3C,KAAtB,EAA6B,GAA7B,CALb;QAMI4C,OAAO,EAAE,IAAAC,sBAAA,EAAiBnB,KAAjB;MANb,GADJ;IAUH;;IAED,IAAI;MACA,MAAM,IAAAuB,yBAAA,EAAc;QAChBC,KAAK,EAAE1C,MAAM,CAAC0C,KADE;QAEhBd;MAFgB,CAAd,CAAN;MAIA1B,WAAW,CAACyC,QAAZ,CAAqB;QACjBnD;MADiB,CAArB;MAGA,OAAO2B,mBAAP;IACH,CATD,CASE,OAAOyB,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,oCADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,iBAFT,EAGF;QACI7B,KADJ;QAEIzB;MAFJ,CAHE,CAAN;IAQH;EACJ,CA1ED;;EA4EA,OAAO;IACHwB,MADG;IAEHgC,kBAFG;IAGHC,MAHG;IAIH4E,MAAM,EAAEzE,WAJL;IAKHS,cALG;IAMHa,mBANG;IAOHD,iBAPG;IAQHD,cARG;IASHD,QATG;IAUHH,eAVG;IAWHH,6BAXG;IAYHd,0BAZG;IAaHoE,GAbG;IAcHlD,YAdG;IAeHmD,OAfG;IAgBHjC,IAhBG;IAiBHqC;EAjBG,CAAP;AAmBH,CAx3BM"}
|
package/operations/entry/keys.js
CHANGED
|
@@ -63,6 +63,12 @@ const systemFields = {
|
|
|
63
63
|
type: "number",
|
|
64
64
|
storageId: "version",
|
|
65
65
|
fieldId: "version"
|
|
66
|
+
}),
|
|
67
|
+
status: createSystemField({
|
|
68
|
+
id: "status",
|
|
69
|
+
type: "string",
|
|
70
|
+
storageId: "status",
|
|
71
|
+
fieldId: "status"
|
|
66
72
|
})
|
|
67
73
|
};
|
|
68
74
|
exports.systemFields = systemFields;
|