@webiny/api-headless-cms-ddb 0.0.0-mt-2 → 0.0.0-unstable.0156a4c312
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/README.md +6 -20
- package/abstractions/CmsDdbDataLoaders.d.ts +5 -0
- package/abstractions/CmsDdbDataLoaders.js +5 -0
- package/abstractions/CmsDdbDataLoaders.js.map +1 -0
- package/abstractions/CmsDdbEntryEntity.d.ts +5 -0
- package/abstractions/CmsDdbEntryEntity.js +5 -0
- package/abstractions/CmsDdbEntryEntity.js.map +1 -0
- package/abstractions/CmsDdbGroupEntity.d.ts +5 -0
- package/abstractions/CmsDdbGroupEntity.js +5 -0
- package/abstractions/CmsDdbGroupEntity.js.map +1 -0
- package/abstractions/CmsDdbModelEntity.d.ts +5 -0
- package/abstractions/CmsDdbModelEntity.js +5 -0
- package/abstractions/CmsDdbModelEntity.js.map +1 -0
- package/abstractions/CmsDdbTable.d.ts +5 -0
- package/abstractions/CmsDdbTable.js +5 -0
- package/abstractions/CmsDdbTable.js.map +1 -0
- package/definitions/entry.d.ts +6 -6
- package/definitions/entry.js +9 -95
- package/definitions/entry.js.map +1 -0
- package/definitions/group.d.ts +6 -6
- package/definitions/group.js +9 -72
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +6 -6
- package/definitions/model.js +9 -94
- package/definitions/model.js.map +1 -0
- package/definitions/table.d.ts +6 -7
- package/definitions/table.js +8 -30
- package/definitions/table.js.map +1 -0
- package/definitions/types.d.ts +65 -0
- package/definitions/types.js +0 -0
- package/index.d.ts +10 -2
- package/index.js +45 -123
- package/index.js.map +1 -0
- package/operations/entry/DdbCreateEntry.d.ts +16 -0
- package/operations/entry/DdbCreateEntry.js +77 -0
- package/operations/entry/DdbCreateEntry.js.map +1 -0
- package/operations/entry/DdbCreateEntryRevisionFrom.d.ts +16 -0
- package/operations/entry/DdbCreateEntryRevisionFrom.js +85 -0
- package/operations/entry/DdbCreateEntryRevisionFrom.js.map +1 -0
- package/operations/entry/DdbDeleteEntry.d.ts +16 -0
- package/operations/entry/DdbDeleteEntry.js +65 -0
- package/operations/entry/DdbDeleteEntry.js.map +1 -0
- package/operations/entry/DdbDeleteEntryRevision.d.ts +17 -0
- package/operations/entry/DdbDeleteEntryRevision.js +91 -0
- package/operations/entry/DdbDeleteEntryRevision.js.map +1 -0
- package/operations/entry/DdbDeleteMultipleEntries.d.ts +16 -0
- package/operations/entry/DdbDeleteMultipleEntries.js +59 -0
- package/operations/entry/DdbDeleteMultipleEntries.js.map +1 -0
- package/operations/entry/DdbGetEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbGetEntriesByIds.js +31 -0
- package/operations/entry/DdbGetEntriesByIds.js.map +1 -0
- package/operations/entry/DdbGetEntry.d.ts +14 -0
- package/operations/entry/DdbGetEntry.js +27 -0
- package/operations/entry/DdbGetEntry.js.map +1 -0
- package/operations/entry/DdbGetLatestEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbGetLatestEntriesByIds.js +31 -0
- package/operations/entry/DdbGetLatestEntriesByIds.js.map +1 -0
- package/operations/entry/DdbGetLatestRevisionByEntryId.d.ts +14 -0
- package/operations/entry/DdbGetLatestRevisionByEntryId.js +35 -0
- package/operations/entry/DdbGetLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/DdbGetPreviousRevision.d.ts +14 -0
- package/operations/entry/DdbGetPreviousRevision.js +53 -0
- package/operations/entry/DdbGetPreviousRevision.js.map +1 -0
- package/operations/entry/DdbGetPublishedEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbGetPublishedEntriesByIds.js +31 -0
- package/operations/entry/DdbGetPublishedEntriesByIds.js.map +1 -0
- package/operations/entry/DdbGetPublishedRevisionByEntryId.d.ts +14 -0
- package/operations/entry/DdbGetPublishedRevisionByEntryId.js +35 -0
- package/operations/entry/DdbGetPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/DdbGetRevisionById.d.ts +14 -0
- package/operations/entry/DdbGetRevisionById.js +34 -0
- package/operations/entry/DdbGetRevisionById.js.map +1 -0
- package/operations/entry/DdbGetRevisions.d.ts +14 -0
- package/operations/entry/DdbGetRevisions.js +33 -0
- package/operations/entry/DdbGetRevisions.js.map +1 -0
- package/operations/entry/DdbGetUniqueFieldValues.d.ts +12 -0
- package/operations/entry/DdbGetUniqueFieldValues.js +31 -0
- package/operations/entry/DdbGetUniqueFieldValues.js.map +1 -0
- package/operations/entry/DdbListEntries.d.ts +30 -0
- package/operations/entry/DdbListEntries.js +133 -0
- package/operations/entry/DdbListEntries.js.map +1 -0
- package/operations/entry/DdbMoveEntry.d.ts +16 -0
- package/operations/entry/DdbMoveEntry.js +63 -0
- package/operations/entry/DdbMoveEntry.js.map +1 -0
- package/operations/entry/DdbMoveToBin.d.ts +16 -0
- package/operations/entry/DdbMoveToBin.js +77 -0
- package/operations/entry/DdbMoveToBin.js.map +1 -0
- package/operations/entry/DdbPublishEntry.d.ts +18 -0
- package/operations/entry/DdbPublishEntry.js +162 -0
- package/operations/entry/DdbPublishEntry.js.map +1 -0
- package/operations/entry/DdbRestoreFromBin.d.ts +16 -0
- package/operations/entry/DdbRestoreFromBin.js +78 -0
- package/operations/entry/DdbRestoreFromBin.js.map +1 -0
- package/operations/entry/DdbUnpublishEntry.d.ts +17 -0
- package/operations/entry/DdbUnpublishEntry.js +112 -0
- package/operations/entry/DdbUnpublishEntry.js.map +1 -0
- package/operations/entry/DdbUpdateEntry.d.ts +17 -0
- package/operations/entry/DdbUpdateEntry.js +105 -0
- package/operations/entry/DdbUpdateEntry.js.map +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
- package/operations/entry/dataLoader/constants.d.ts +1 -0
- package/operations/entry/dataLoader/constants.js +5 -0
- package/operations/entry/dataLoader/constants.js.map +1 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +40 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +40 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
- package/operations/entry/dataLoader/getRevisionById.js +42 -0
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
- package/operations/entry/dataLoader/index.d.ts +8 -0
- package/operations/entry/dataLoader/index.js +18 -0
- package/operations/entry/dataLoader/index.js.map +1 -0
- package/operations/entry/dataLoader/types.d.ts +6 -0
- package/operations/entry/dataLoader/types.js +0 -0
- package/operations/entry/dataLoaders.d.ts +20 -31
- package/operations/entry/dataLoaders.js +91 -296
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/feature.d.ts +4 -0
- package/operations/entry/feature.js +55 -0
- package/operations/entry/feature.js.map +1 -0
- package/operations/entry/keys.d.ts +46 -2
- package/operations/entry/keys.js +53 -55
- package/operations/entry/keys.js.map +1 -0
- package/operations/entry/storageEntryUtils.d.ts +8 -0
- package/operations/entry/storageEntryUtils.js +25 -0
- package/operations/entry/storageEntryUtils.js.map +1 -0
- package/operations/group/DdbCreateGroup.d.ts +12 -0
- package/operations/group/DdbCreateGroup.js +35 -0
- package/operations/group/DdbCreateGroup.js.map +1 -0
- package/operations/group/DdbDeleteGroup.d.ts +12 -0
- package/operations/group/DdbDeleteGroup.js +31 -0
- package/operations/group/DdbDeleteGroup.js.map +1 -0
- package/operations/group/DdbGetGroup.d.ts +12 -0
- package/operations/group/DdbGetGroup.js +31 -0
- package/operations/group/DdbGetGroup.js.map +1 -0
- package/operations/group/DdbListGroups.d.ts +14 -0
- package/operations/group/DdbListGroups.js +52 -0
- package/operations/group/DdbListGroups.js.map +1 -0
- package/operations/group/DdbUpdateGroup.d.ts +12 -0
- package/operations/group/DdbUpdateGroup.js +35 -0
- package/operations/group/DdbUpdateGroup.js.map +1 -0
- package/operations/group/feature.d.ts +4 -0
- package/operations/group/feature.js +19 -0
- package/operations/group/feature.js.map +1 -0
- package/operations/group/keys.d.ts +15 -0
- package/operations/group/keys.js +17 -0
- package/operations/group/keys.js.map +1 -0
- package/operations/model/DdbCreateModel.d.ts +12 -0
- package/operations/model/DdbCreateModel.js +37 -0
- package/operations/model/DdbCreateModel.js.map +1 -0
- package/operations/model/DdbDeleteModel.d.ts +12 -0
- package/operations/model/DdbDeleteModel.js +31 -0
- package/operations/model/DdbDeleteModel.js.map +1 -0
- package/operations/model/DdbGetModel.d.ts +12 -0
- package/operations/model/DdbGetModel.js +30 -0
- package/operations/model/DdbGetModel.js.map +1 -0
- package/operations/model/DdbListModels.d.ts +12 -0
- package/operations/model/DdbListModels.js +36 -0
- package/operations/model/DdbListModels.js.map +1 -0
- package/operations/model/DdbUpdateModel.d.ts +12 -0
- package/operations/model/DdbUpdateModel.js +36 -0
- package/operations/model/DdbUpdateModel.js.map +1 -0
- package/operations/model/feature.d.ts +4 -0
- package/operations/model/feature.js +19 -0
- package/operations/model/feature.js.map +1 -0
- package/operations/model/keys.d.ts +15 -0
- package/operations/model/keys.js +16 -0
- package/operations/model/keys.js.map +1 -0
- package/package.json +30 -34
- package/types.d.ts +12 -76
- package/types.js +8 -15
- package/types.js.map +1 -0
- package/definitions/settings.d.ts +0 -8
- package/definitions/settings.js +0 -62
- package/definitions/system.d.ts +0 -8
- package/definitions/system.js +0 -50
- package/dynamoDb/index.d.ts +0 -2
- package/dynamoDb/index.js +0 -24
- package/dynamoDb/path/plainObject.d.ts +0 -3
- package/dynamoDb/path/plainObject.js +0 -33
- package/dynamoDb/path/ref.d.ts +0 -3
- package/dynamoDb/path/ref.js +0 -27
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -65
- package/dynamoDb/storage/longText.d.ts +0 -7
- package/dynamoDb/storage/longText.js +0 -83
- package/dynamoDb/storage/richText.d.ts +0 -8
- package/dynamoDb/storage/richText.js +0 -110
- package/dynamoDb/transformValue/datetime.d.ts +0 -3
- package/dynamoDb/transformValue/datetime.js +0 -47
- package/operations/entry/index.d.ts +0 -8
- package/operations/entry/index.js +0 -823
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -50
- package/operations/entry/utils.d.ts +0 -31
- package/operations/entry/utils.js +0 -406
- package/operations/group/index.d.ts +0 -8
- package/operations/group/index.js +0 -198
- package/operations/model/index.d.ts +0 -6
- package/operations/model/index.js +0 -161
- package/operations/settings/index.d.ts +0 -6
- package/operations/settings/index.js +0 -141
- package/operations/system/index.d.ts +0 -6
- package/operations/system/index.js +0 -105
|
@@ -1,303 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
13
|
-
|
|
14
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
|
-
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
17
|
-
|
|
18
|
-
var _keys = require("./keys");
|
|
19
|
-
|
|
20
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
21
|
-
|
|
22
|
-
var _utils = require("@webiny/utils");
|
|
23
|
-
|
|
24
|
-
var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
|
|
25
|
-
|
|
26
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
|
-
|
|
30
|
-
const getAllEntryRevisions = params => {
|
|
31
|
-
const {
|
|
32
|
-
entity,
|
|
33
|
-
model
|
|
34
|
-
} = params;
|
|
35
|
-
const {
|
|
36
|
-
tenant,
|
|
37
|
-
locale
|
|
38
|
-
} = model;
|
|
39
|
-
return new _dataloader.default(async ids => {
|
|
40
|
-
const results = [];
|
|
41
|
-
|
|
42
|
-
for (const id of ids) {
|
|
43
|
-
const queryAllParams = {
|
|
44
|
-
entity,
|
|
45
|
-
partitionKey: (0, _keys.createPartitionKey)({
|
|
46
|
-
tenant,
|
|
47
|
-
locale,
|
|
48
|
-
id
|
|
49
|
-
}),
|
|
50
|
-
options: {
|
|
51
|
-
beginsWith: "REV#"
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const items = await (0, _query.queryAll)(queryAllParams);
|
|
55
|
-
const entries = (0, _cleanup.cleanupItems)(entity, items);
|
|
56
|
-
results.push(entries);
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
import { DataLoaderCache } from "./dataLoader/DataLoaderCache.js";
|
|
3
|
+
import { getDataLoaderFactory } from "./dataLoader/index.js";
|
|
4
|
+
import { parseIdentifier } from "@webiny/utils";
|
|
5
|
+
import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
|
|
6
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
7
|
+
class DataLoadersHandlerImpl {
|
|
8
|
+
constructor(entity){
|
|
9
|
+
this.entity = entity;
|
|
10
|
+
this.cache = new DataLoaderCache();
|
|
57
11
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const {
|
|
65
|
-
entity,
|
|
66
|
-
model
|
|
67
|
-
} = params;
|
|
68
|
-
const {
|
|
69
|
-
locale,
|
|
70
|
-
tenant
|
|
71
|
-
} = model;
|
|
72
|
-
return new _dataloader.default(async ids => {
|
|
73
|
-
const queries = ids.reduce((collection, id) => {
|
|
74
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
75
|
-
tenant,
|
|
76
|
-
locale,
|
|
77
|
-
id
|
|
78
|
-
});
|
|
79
|
-
const {
|
|
80
|
-
version
|
|
81
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
82
|
-
const sortKey = (0, _keys.createRevisionSortKey)({
|
|
83
|
-
version
|
|
84
|
-
});
|
|
85
|
-
const keys = `${partitionKey}__${sortKey}`;
|
|
86
|
-
|
|
87
|
-
if (collection[keys]) {
|
|
88
|
-
return collection;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
collection[keys] = entity.getBatch({
|
|
92
|
-
PK: partitionKey,
|
|
93
|
-
SK: sortKey
|
|
94
|
-
});
|
|
95
|
-
return collection;
|
|
96
|
-
}, {});
|
|
97
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
98
|
-
table: entity.table,
|
|
99
|
-
items: Object.values(queries)
|
|
100
|
-
});
|
|
101
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
102
|
-
return ids.map(id => {
|
|
103
|
-
return items.filter(item => {
|
|
104
|
-
return id === item.id;
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const getPublishedRevisionByEntryId = params => {
|
|
111
|
-
const {
|
|
112
|
-
entity,
|
|
113
|
-
model
|
|
114
|
-
} = params;
|
|
115
|
-
const {
|
|
116
|
-
locale,
|
|
117
|
-
tenant
|
|
118
|
-
} = model;
|
|
119
|
-
const publishedKey = (0, _keys.createPublishedSortKey)();
|
|
120
|
-
return new _dataloader.default(async ids => {
|
|
121
|
-
const queries = ids.reduce((collection, id) => {
|
|
122
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
123
|
-
tenant,
|
|
124
|
-
locale,
|
|
125
|
-
id
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
if (collection[partitionKey]) {
|
|
129
|
-
return collection;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
collection[partitionKey] = entity.getBatch({
|
|
133
|
-
PK: partitionKey,
|
|
134
|
-
SK: publishedKey
|
|
135
|
-
});
|
|
136
|
-
return collection;
|
|
137
|
-
}, {});
|
|
138
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
139
|
-
table: entity.table,
|
|
140
|
-
items: Object.values(queries)
|
|
141
|
-
});
|
|
142
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
143
|
-
return ids.map(id => {
|
|
144
|
-
const {
|
|
145
|
-
id: entryId
|
|
146
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
147
|
-
return items.filter(item => {
|
|
148
|
-
return entryId === item.entryId;
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const getLatestRevisionByEntryId = params => {
|
|
155
|
-
const {
|
|
156
|
-
entity,
|
|
157
|
-
model
|
|
158
|
-
} = params;
|
|
159
|
-
const {
|
|
160
|
-
locale,
|
|
161
|
-
tenant
|
|
162
|
-
} = model;
|
|
163
|
-
const latestKey = (0, _keys.createLatestSortKey)();
|
|
164
|
-
return new _dataloader.default(async ids => {
|
|
165
|
-
const queries = ids.reduce((collection, id) => {
|
|
166
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
167
|
-
tenant,
|
|
168
|
-
locale,
|
|
169
|
-
id
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
if (collection[partitionKey]) {
|
|
173
|
-
return collection;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
collection[partitionKey] = entity.getBatch({
|
|
177
|
-
PK: partitionKey,
|
|
178
|
-
SK: latestKey
|
|
179
|
-
});
|
|
180
|
-
return collection;
|
|
181
|
-
}, {});
|
|
182
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
183
|
-
table: entity.table,
|
|
184
|
-
items: Object.values(queries)
|
|
185
|
-
});
|
|
186
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
187
|
-
return ids.map(id => {
|
|
188
|
-
const {
|
|
189
|
-
id: entryId
|
|
190
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
191
|
-
return items.filter(item => {
|
|
192
|
-
return entryId === item.entryId;
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const dataLoaders = {
|
|
199
|
-
getAllEntryRevisions,
|
|
200
|
-
getRevisionById,
|
|
201
|
-
getPublishedRevisionByEntryId,
|
|
202
|
-
getLatestRevisionByEntryId
|
|
203
|
-
};
|
|
204
|
-
const loaderNames = Object.keys(dataLoaders);
|
|
205
|
-
|
|
206
|
-
class DataLoadersHandler {
|
|
207
|
-
constructor(params) {
|
|
208
|
-
(0, _defineProperty2.default)(this, "loaders", new Map());
|
|
209
|
-
(0, _defineProperty2.default)(this, "entity", void 0);
|
|
210
|
-
this.entity = params.entity;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
async getAllEntryRevisions(params) {
|
|
214
|
-
return await this.loadMany("getAllEntryRevisions", params, params.ids);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
async getRevisionById(params) {
|
|
218
|
-
return await this.loadMany("getRevisionById", params, params.ids);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
async getPublishedRevisionByEntryId(params) {
|
|
222
|
-
return await this.loadMany("getPublishedRevisionByEntryId", params, params.ids);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
async getLatestRevisionByEntryId(params) {
|
|
226
|
-
return await this.loadMany("getLatestRevisionByEntryId", params, params.ids);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
getLoader(name, params) {
|
|
230
|
-
if (!dataLoaders[name]) {
|
|
231
|
-
throw new _error.default("Unknown data loader.", "UNKNOWN_DATA_LOADER", {
|
|
232
|
-
name
|
|
233
|
-
});
|
|
12
|
+
async getAllEntryRevisions(params) {
|
|
13
|
+
const ids = params.ids.map((id)=>{
|
|
14
|
+
const { id: entryId } = parseIdentifier(id);
|
|
15
|
+
return entryId;
|
|
16
|
+
});
|
|
17
|
+
return await this.loadMany("getAllEntryRevisions", params, ids);
|
|
234
18
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
model
|
|
238
|
-
} = params;
|
|
239
|
-
const {
|
|
240
|
-
tenant,
|
|
241
|
-
locale
|
|
242
|
-
} = model;
|
|
243
|
-
const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;
|
|
244
|
-
|
|
245
|
-
if (!this.loaders.has(loaderKey)) {
|
|
246
|
-
this.loaders.set(loaderKey, dataLoaders[name](_objectSpread(_objectSpread({}, params), {}, {
|
|
247
|
-
entity: this.entity
|
|
248
|
-
})));
|
|
19
|
+
async getRevisionById(params) {
|
|
20
|
+
return await this.loadMany("getRevisionById", params, params.ids);
|
|
249
21
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
try {
|
|
258
|
-
results = await this.getLoader(loader, params).loadMany(ids);
|
|
259
|
-
|
|
260
|
-
if (Array.isArray(results) === true) {
|
|
261
|
-
return results.reduce((acc, res) => {
|
|
262
|
-
if (Array.isArray(res) === false) {
|
|
263
|
-
if (res && res.message) {
|
|
264
|
-
throw new _error.default(res.message, res.code, _objectSpread(_objectSpread({}, res), {}, {
|
|
265
|
-
data: JSON.stringify(res.data || {})
|
|
266
|
-
}));
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", _objectSpread(_objectSpread({}, params), {}, {
|
|
270
|
-
loader
|
|
271
|
-
}));
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
acc.push(...res);
|
|
275
|
-
return acc;
|
|
276
|
-
}, []);
|
|
277
|
-
}
|
|
278
|
-
} catch (ex) {
|
|
279
|
-
throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", _objectSpread(_objectSpread({
|
|
280
|
-
error: ex
|
|
281
|
-
}, params), {}, {
|
|
282
|
-
loader,
|
|
283
|
-
ids
|
|
284
|
-
}));
|
|
22
|
+
async getPublishedRevisionByEntryId(params) {
|
|
23
|
+
const ids = params.ids.map((id)=>{
|
|
24
|
+
const { id: entryId } = parseIdentifier(id);
|
|
25
|
+
return entryId;
|
|
26
|
+
});
|
|
27
|
+
return await this.loadMany("getPublishedRevisionByEntryId", params, ids);
|
|
285
28
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
29
|
+
async getLatestRevisionByEntryId(params) {
|
|
30
|
+
const ids = params.ids.map((id)=>{
|
|
31
|
+
const { id: entryId } = parseIdentifier(id);
|
|
32
|
+
return entryId;
|
|
33
|
+
});
|
|
34
|
+
return await this.loadMany("getLatestRevisionByEntryId", params, ids);
|
|
35
|
+
}
|
|
36
|
+
getLoader(name, params) {
|
|
37
|
+
const { model } = params;
|
|
38
|
+
const cacheParams = {
|
|
39
|
+
tenant: model.tenant,
|
|
40
|
+
modelId: model.modelId,
|
|
41
|
+
name
|
|
42
|
+
};
|
|
43
|
+
let loader = this.cache.getDataLoader(cacheParams);
|
|
44
|
+
if (loader) return loader;
|
|
45
|
+
const factory = getDataLoaderFactory(name);
|
|
46
|
+
loader = factory({
|
|
47
|
+
entity: this.entity,
|
|
48
|
+
tenant: model.tenant,
|
|
49
|
+
modelId: model.modelId
|
|
50
|
+
});
|
|
51
|
+
this.cache.setDataLoader(cacheParams, loader);
|
|
52
|
+
return loader;
|
|
53
|
+
}
|
|
54
|
+
async loadMany(loader, params, ids) {
|
|
55
|
+
let results = [];
|
|
56
|
+
try {
|
|
57
|
+
results = await this.getLoader(loader, params).loadMany(ids);
|
|
58
|
+
if (true === Array.isArray(results)) return results.reduce((acc, res)=>{
|
|
59
|
+
if (false === Array.isArray(res)) {
|
|
60
|
+
if (res && res.message) throw new error(res.message, res.code, {
|
|
61
|
+
...res,
|
|
62
|
+
data: JSON.stringify(res.data || {})
|
|
63
|
+
});
|
|
64
|
+
throw new error("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", {
|
|
65
|
+
...params,
|
|
66
|
+
loader
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
acc.push(...res);
|
|
70
|
+
return acc;
|
|
71
|
+
}, []);
|
|
72
|
+
} catch (ex) {
|
|
73
|
+
throw new error(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", {
|
|
74
|
+
error: ex,
|
|
75
|
+
...params,
|
|
76
|
+
loader,
|
|
77
|
+
ids
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
throw new error("Data loader did not return array of items or empty array.", "INVALID_DATA_LOADER_RESULT", {
|
|
81
|
+
loader,
|
|
82
|
+
ids,
|
|
83
|
+
results
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
clearAll(params) {
|
|
87
|
+
this.cache.clearAll(params);
|
|
298
88
|
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
89
|
}
|
|
90
|
+
const DataLoadersHandler = CmsDdbDataLoaders.createImplementation({
|
|
91
|
+
implementation: DataLoadersHandlerImpl,
|
|
92
|
+
dependencies: [
|
|
93
|
+
CmsDdbEntryEntity
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
export { DataLoadersHandler };
|
|
302
97
|
|
|
303
|
-
|
|
98
|
+
//# sourceMappingURL=dataLoaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoaders.js","sources":["../../../src/operations/entry/dataLoaders.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport type {\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CacheKeyParams } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport { DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport type { DataLoaders } from \"~/operations/entry/dataLoader/index.js\";\nimport { getDataLoaderFactory } from \"~/operations/entry/dataLoader/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type { DataLoadersHandlerInterfaceClearAllParams, IDataLoadersHandler } from \"~/types.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nclass DataLoadersHandlerImpl implements IDataLoadersHandler {\n private readonly cache = new DataLoaderCache();\n\n public constructor(private readonly entity: CmsDdbEntryEntity.Interface) {}\n\n public async getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n return await this.loadMany<T>(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n modelId: model.modelId,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant,\n modelId: model.modelId\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany<T extends CmsEntryValues = CmsEntryValues>(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry<T>[]> {\n let results: any[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params);\n }\n}\n\nexport const DataLoadersHandler = CmsDdbDataLoaders.createImplementation({\n implementation: DataLoadersHandlerImpl,\n dependencies: [CmsDdbEntryEntity]\n});\n"],"names":["DataLoadersHandlerImpl","entity","DataLoaderCache","params","ids","id","entryId","parseIdentifier","name","model","cacheParams","loader","factory","getDataLoaderFactory","results","Array","acc","res","WebinyError","JSON","ex","DataLoadersHandler","CmsDdbDataLoaders","CmsDdbEntryEntity"],"mappings":"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"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api/index.js";
|
|
2
|
+
import { DataLoadersHandler } from "./dataLoaders.js";
|
|
3
|
+
import { DdbCreateEntry } from "./DdbCreateEntry.js";
|
|
4
|
+
import { DdbCreateEntryRevisionFrom } from "./DdbCreateEntryRevisionFrom.js";
|
|
5
|
+
import { DdbUpdateEntry } from "./DdbUpdateEntry.js";
|
|
6
|
+
import { DdbMoveEntry } from "./DdbMoveEntry.js";
|
|
7
|
+
import { DdbMoveToBin } from "./DdbMoveToBin.js";
|
|
8
|
+
import { DdbDeleteEntry } from "./DdbDeleteEntry.js";
|
|
9
|
+
import { DdbRestoreFromBin } from "./DdbRestoreFromBin.js";
|
|
10
|
+
import { DdbDeleteEntryRevision } from "./DdbDeleteEntryRevision.js";
|
|
11
|
+
import { DdbDeleteMultipleEntries } from "./DdbDeleteMultipleEntries.js";
|
|
12
|
+
import { DdbGetEntry } from "./DdbGetEntry.js";
|
|
13
|
+
import { DdbListEntries } from "./DdbListEntries.js";
|
|
14
|
+
import { DdbPublishEntry } from "./DdbPublishEntry.js";
|
|
15
|
+
import { DdbUnpublishEntry } from "./DdbUnpublishEntry.js";
|
|
16
|
+
import { DdbGetEntriesByIds } from "./DdbGetEntriesByIds.js";
|
|
17
|
+
import { DdbGetLatestEntriesByIds } from "./DdbGetLatestEntriesByIds.js";
|
|
18
|
+
import { DdbGetPublishedEntriesByIds } from "./DdbGetPublishedEntriesByIds.js";
|
|
19
|
+
import { DdbGetRevisions } from "./DdbGetRevisions.js";
|
|
20
|
+
import { DdbGetRevisionById } from "./DdbGetRevisionById.js";
|
|
21
|
+
import { DdbGetLatestRevisionByEntryId } from "./DdbGetLatestRevisionByEntryId.js";
|
|
22
|
+
import { DdbGetPublishedRevisionByEntryId } from "./DdbGetPublishedRevisionByEntryId.js";
|
|
23
|
+
import { DdbGetPreviousRevision } from "./DdbGetPreviousRevision.js";
|
|
24
|
+
import { DdbGetUniqueFieldValues } from "./DdbGetUniqueFieldValues.js";
|
|
25
|
+
const DdbEntryStorageOpsFeature = createFeature({
|
|
26
|
+
name: "cms.ddb.entryStorageOps",
|
|
27
|
+
register: (container)=>{
|
|
28
|
+
container.register(DataLoadersHandler).inContainerScope();
|
|
29
|
+
container.register(DdbCreateEntry);
|
|
30
|
+
container.register(DdbCreateEntryRevisionFrom);
|
|
31
|
+
container.register(DdbUpdateEntry);
|
|
32
|
+
container.register(DdbMoveEntry);
|
|
33
|
+
container.register(DdbMoveToBin);
|
|
34
|
+
container.register(DdbDeleteEntry);
|
|
35
|
+
container.register(DdbRestoreFromBin);
|
|
36
|
+
container.register(DdbDeleteEntryRevision);
|
|
37
|
+
container.register(DdbDeleteMultipleEntries);
|
|
38
|
+
container.register(DdbGetEntry);
|
|
39
|
+
container.register(DdbListEntries);
|
|
40
|
+
container.register(DdbPublishEntry);
|
|
41
|
+
container.register(DdbUnpublishEntry);
|
|
42
|
+
container.register(DdbGetEntriesByIds);
|
|
43
|
+
container.register(DdbGetLatestEntriesByIds);
|
|
44
|
+
container.register(DdbGetPublishedEntriesByIds);
|
|
45
|
+
container.register(DdbGetRevisions);
|
|
46
|
+
container.register(DdbGetRevisionById);
|
|
47
|
+
container.register(DdbGetLatestRevisionByEntryId);
|
|
48
|
+
container.register(DdbGetPublishedRevisionByEntryId);
|
|
49
|
+
container.register(DdbGetPreviousRevision);
|
|
50
|
+
container.register(DdbGetUniqueFieldValues);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
export { DdbEntryStorageOpsFeature };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/feature.js","sources":["../../../src/operations/entry/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { DataLoadersHandler } from \"./dataLoaders.js\";\nimport { DdbCreateEntry } from \"./DdbCreateEntry.js\";\nimport { DdbCreateEntryRevisionFrom } from \"./DdbCreateEntryRevisionFrom.js\";\nimport { DdbUpdateEntry } from \"./DdbUpdateEntry.js\";\nimport { DdbMoveEntry } from \"./DdbMoveEntry.js\";\nimport { DdbMoveToBin } from \"./DdbMoveToBin.js\";\nimport { DdbDeleteEntry } from \"./DdbDeleteEntry.js\";\nimport { DdbRestoreFromBin } from \"./DdbRestoreFromBin.js\";\nimport { DdbDeleteEntryRevision } from \"./DdbDeleteEntryRevision.js\";\nimport { DdbDeleteMultipleEntries } from \"./DdbDeleteMultipleEntries.js\";\nimport { DdbGetEntry } from \"./DdbGetEntry.js\";\nimport { DdbListEntries } from \"./DdbListEntries.js\";\nimport { DdbPublishEntry } from \"./DdbPublishEntry.js\";\nimport { DdbUnpublishEntry } from \"./DdbUnpublishEntry.js\";\nimport { DdbGetEntriesByIds } from \"./DdbGetEntriesByIds.js\";\nimport { DdbGetLatestEntriesByIds } from \"./DdbGetLatestEntriesByIds.js\";\nimport { DdbGetPublishedEntriesByIds } from \"./DdbGetPublishedEntriesByIds.js\";\nimport { DdbGetRevisions } from \"./DdbGetRevisions.js\";\nimport { DdbGetRevisionById } from \"./DdbGetRevisionById.js\";\nimport { DdbGetLatestRevisionByEntryId } from \"./DdbGetLatestRevisionByEntryId.js\";\nimport { DdbGetPublishedRevisionByEntryId } from \"./DdbGetPublishedRevisionByEntryId.js\";\nimport { DdbGetPreviousRevision } from \"./DdbGetPreviousRevision.js\";\nimport { DdbGetUniqueFieldValues } from \"./DdbGetUniqueFieldValues.js\";\n\nexport const DdbEntryStorageOpsFeature = createFeature({\n name: \"cms.ddb.entryStorageOps\",\n register: container => {\n // The DataLoader caches reads, so it must live for one request: container scoped, it is built\n // per request (child) container even though the feature is registered once in the root.\n container.register(DataLoadersHandler).inContainerScope();\n container.register(DdbCreateEntry);\n container.register(DdbCreateEntryRevisionFrom);\n container.register(DdbUpdateEntry);\n container.register(DdbMoveEntry);\n container.register(DdbMoveToBin);\n container.register(DdbDeleteEntry);\n container.register(DdbRestoreFromBin);\n container.register(DdbDeleteEntryRevision);\n container.register(DdbDeleteMultipleEntries);\n container.register(DdbGetEntry);\n container.register(DdbListEntries);\n container.register(DdbPublishEntry);\n container.register(DdbUnpublishEntry);\n container.register(DdbGetEntriesByIds);\n container.register(DdbGetLatestEntriesByIds);\n container.register(DdbGetPublishedEntriesByIds);\n container.register(DdbGetRevisions);\n container.register(DdbGetRevisionById);\n container.register(DdbGetLatestRevisionByEntryId);\n container.register(DdbGetPublishedRevisionByEntryId);\n container.register(DdbGetPreviousRevision);\n container.register(DdbGetUniqueFieldValues);\n }\n});\n"],"names":["DdbEntryStorageOpsFeature","createFeature","container","DataLoadersHandler","DdbCreateEntry","DdbCreateEntryRevisionFrom","DdbUpdateEntry","DdbMoveEntry","DdbMoveToBin","DdbDeleteEntry","DdbRestoreFromBin","DdbDeleteEntryRevision","DdbDeleteMultipleEntries","DdbGetEntry","DdbListEntries","DdbPublishEntry","DdbUnpublishEntry","DdbGetEntriesByIds","DdbGetLatestEntriesByIds","DdbGetPublishedEntriesByIds","DdbGetRevisions","DdbGetRevisionById","DdbGetLatestRevisionByEntryId","DdbGetPublishedRevisionByEntryId","DdbGetPreviousRevision","DdbGetUniqueFieldValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAAUC,CAAAA;QAGNA,UAAU,QAAQ,CAACC,oBAAoB,gBAAgB;QACvDD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;QACnBL,UAAU,QAAQ,CAACM;QACnBN,UAAU,QAAQ,CAACO;QACnBP,UAAU,QAAQ,CAACQ;QACnBR,UAAU,QAAQ,CAACS;QACnBT,UAAU,QAAQ,CAACU;QACnBV,UAAU,QAAQ,CAACW;QACnBX,UAAU,QAAQ,CAACY;QACnBZ,UAAU,QAAQ,CAACa;QACnBb,UAAU,QAAQ,CAACc;QACnBd,UAAU,QAAQ,CAACe;QACnBf,UAAU,QAAQ,CAACgB;QACnBhB,UAAU,QAAQ,CAACiB;QACnBjB,UAAU,QAAQ,CAACkB;QACnBlB,UAAU,QAAQ,CAACmB;QACnBnB,UAAU,QAAQ,CAACoB;QACnBpB,UAAU,QAAQ,CAACqB;QACnBrB,UAAU,QAAQ,CAACsB;QACnBtB,UAAU,QAAQ,CAACuB;IACvB;AACJ"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
interface BasePartitionKeyParams {
|
|
2
2
|
tenant: string;
|
|
3
|
-
locale: string;
|
|
4
3
|
}
|
|
5
4
|
export interface PartitionKeyParams extends BasePartitionKeyParams {
|
|
6
5
|
id: string;
|
|
@@ -14,7 +13,6 @@ export declare const createLatestSortKey: () => string;
|
|
|
14
13
|
export declare const createPublishedSortKey: () => string;
|
|
15
14
|
export interface GSIPartitionKeyParams {
|
|
16
15
|
tenant: string;
|
|
17
|
-
locale: string;
|
|
18
16
|
modelId: string;
|
|
19
17
|
}
|
|
20
18
|
export declare const createGSIPartitionKey: (params: GSIPartitionKeyParams, type: "A" | "L" | "P") => string;
|
|
@@ -22,4 +20,50 @@ export interface GSISortKeyParams {
|
|
|
22
20
|
id: string;
|
|
23
21
|
}
|
|
24
22
|
export declare const createGSISortKey: (params: GSISortKeyParams) => string;
|
|
23
|
+
export interface ICreateEntryPublishedKeysParams {
|
|
24
|
+
id: string;
|
|
25
|
+
tenant: string;
|
|
26
|
+
modelId: string;
|
|
27
|
+
expiresAt: number | null;
|
|
28
|
+
}
|
|
29
|
+
export declare const createEntryPublishedKeys: (params: ICreateEntryPublishedKeysParams) => {
|
|
30
|
+
PK: string;
|
|
31
|
+
SK: string;
|
|
32
|
+
GSI1_PK: string;
|
|
33
|
+
GSI1_SK: string;
|
|
34
|
+
TYPE: string;
|
|
35
|
+
GSI_TENANT: string;
|
|
36
|
+
expiresAt: number | null;
|
|
37
|
+
};
|
|
38
|
+
export interface ICreateEntryLatestKeysParams {
|
|
39
|
+
id: string;
|
|
40
|
+
tenant: string;
|
|
41
|
+
modelId: string;
|
|
42
|
+
expiresAt: number | null;
|
|
43
|
+
}
|
|
44
|
+
export declare const createEntryLatestKeys: (params: ICreateEntryLatestKeysParams) => {
|
|
45
|
+
PK: string;
|
|
46
|
+
SK: string;
|
|
47
|
+
GSI1_PK: string;
|
|
48
|
+
GSI1_SK: string;
|
|
49
|
+
TYPE: string;
|
|
50
|
+
GSI_TENANT: string;
|
|
51
|
+
expiresAt: number | null;
|
|
52
|
+
};
|
|
53
|
+
export interface ICreateRevisionKeysParams {
|
|
54
|
+
id: string;
|
|
55
|
+
tenant: string;
|
|
56
|
+
version: number;
|
|
57
|
+
modelId: string;
|
|
58
|
+
expiresAt: number | null;
|
|
59
|
+
}
|
|
60
|
+
export declare const createEntryRevisionKeys: (params: ICreateRevisionKeysParams) => {
|
|
61
|
+
PK: string;
|
|
62
|
+
SK: string;
|
|
63
|
+
GSI1_PK: string;
|
|
64
|
+
GSI1_SK: string;
|
|
65
|
+
TYPE: string;
|
|
66
|
+
GSI_TENANT: string;
|
|
67
|
+
expiresAt: number | null;
|
|
68
|
+
};
|
|
25
69
|
export {};
|
package/operations/entry/keys.js
CHANGED
|
@@ -1,62 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _utils = require("@webiny/utils");
|
|
9
|
-
|
|
10
|
-
const createBasePartitionKey = params => {
|
|
11
|
-
const {
|
|
12
|
-
tenant,
|
|
13
|
-
locale
|
|
14
|
-
} = params;
|
|
15
|
-
return `T#${tenant}#L#${locale}#CMS#CME`;
|
|
1
|
+
import { parseIdentifier, zeroPad } from "@webiny/utils";
|
|
2
|
+
import error from "@webiny/error";
|
|
3
|
+
const createBasePartitionKey = (params)=>{
|
|
4
|
+
const { tenant } = params;
|
|
5
|
+
if (!tenant) throw new error("Missing tenant variable when creating entry basePartitionKey");
|
|
6
|
+
return `T#${tenant}#CMS#CME`;
|
|
16
7
|
};
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
id
|
|
21
|
-
} = params;
|
|
22
|
-
const {
|
|
23
|
-
id
|
|
24
|
-
} = (0, _utils.parseIdentifier)(initialId);
|
|
25
|
-
return `${createBasePartitionKey(params)}#CME#${id}`;
|
|
8
|
+
const createPartitionKey = (params)=>{
|
|
9
|
+
const { id: initialId } = params;
|
|
10
|
+
const { id } = parseIdentifier(initialId);
|
|
11
|
+
return `${createBasePartitionKey(params)}#${id}`;
|
|
26
12
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
13
|
+
const createRevisionSortKey = (params)=>`REV#${zeroPad(params.version)}`;
|
|
14
|
+
const createLatestSortKey = ()=>"L";
|
|
15
|
+
const createPublishedSortKey = ()=>"P";
|
|
16
|
+
const createGSIPartitionKey = (params, type)=>{
|
|
17
|
+
const { modelId } = params;
|
|
18
|
+
const partitionKey = createBasePartitionKey(params);
|
|
19
|
+
return `${partitionKey}#M#${modelId}#${type}`;
|
|
32
20
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
const createGSISortKey = (params)=>params.id;
|
|
22
|
+
const createEntryPublishedKeys = (params)=>{
|
|
23
|
+
const { tenant, expiresAt } = params;
|
|
24
|
+
return {
|
|
25
|
+
PK: createPartitionKey(params),
|
|
26
|
+
SK: createPublishedSortKey(),
|
|
27
|
+
GSI1_PK: createGSIPartitionKey(params, "P"),
|
|
28
|
+
GSI1_SK: createGSISortKey(params),
|
|
29
|
+
TYPE: "cms.entry.p",
|
|
30
|
+
GSI_TENANT: tenant,
|
|
31
|
+
expiresAt
|
|
32
|
+
};
|
|
38
33
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
const createEntryLatestKeys = (params)=>{
|
|
35
|
+
const { tenant, expiresAt } = params;
|
|
36
|
+
return {
|
|
37
|
+
PK: createPartitionKey(params),
|
|
38
|
+
SK: createLatestSortKey(),
|
|
39
|
+
GSI1_PK: createGSIPartitionKey(params, "L"),
|
|
40
|
+
GSI1_SK: createGSISortKey(params),
|
|
41
|
+
TYPE: "cms.entry.l",
|
|
42
|
+
GSI_TENANT: tenant,
|
|
43
|
+
expiresAt
|
|
44
|
+
};
|
|
44
45
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
exports.createGSIPartitionKey = createGSIPartitionKey;
|
|
57
|
-
|
|
58
|
-
const createGSISortKey = params => {
|
|
59
|
-
return params.id;
|
|
46
|
+
const createEntryRevisionKeys = (params)=>{
|
|
47
|
+
const { tenant, expiresAt } = params;
|
|
48
|
+
return {
|
|
49
|
+
PK: createPartitionKey(params),
|
|
50
|
+
SK: createRevisionSortKey(params),
|
|
51
|
+
GSI1_PK: createGSIPartitionKey(params, "A"),
|
|
52
|
+
GSI1_SK: createGSISortKey(params),
|
|
53
|
+
TYPE: "cms.entry",
|
|
54
|
+
GSI_TENANT: tenant,
|
|
55
|
+
expiresAt
|
|
56
|
+
};
|
|
60
57
|
};
|
|
58
|
+
export { createEntryLatestKeys, createEntryPublishedKeys, createEntryRevisionKeys, createGSIPartitionKey, createGSISortKey, createLatestSortKey, createPartitionKey, createPublishedSortKey, createRevisionSortKey };
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
//# sourceMappingURL=keys.js.map
|