@webiny/api-headless-cms-ddb 0.0.0-unstable.496cf268ac → 0.0.0-unstable.5387e5f7c8
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 +4 -5
- package/definitions/entry.js +10 -93
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -5
- package/definitions/group.js +10 -64
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -5
- package/definitions/model.js +10 -108
- package/definitions/model.js.map +1 -1
- package/definitions/table.d.ts +4 -6
- package/definitions/table.js +7 -26
- package/definitions/table.js.map +1 -1
- package/definitions/types.d.ts +65 -0
- package/definitions/types.js +0 -0
- package/index.d.ts +10 -3
- package/index.js +45 -129
- package/index.js.map +1 -1
- 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 +28 -0
- package/operations/entry/DdbListEntries.js +124 -0
- package/operations/entry/DdbListEntries.js.map +1 -0
- package/operations/entry/DdbMoveEntry.d.ts +14 -0
- package/operations/entry/DdbMoveEntry.js +57 -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 +16 -31
- package/operations/entry/dataLoaders.js +92 -272
- package/operations/entry/dataLoaders.js.map +1 -1
- 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 +54 -49
- package/operations/entry/keys.js.map +1 -1
- 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 -33
- package/types.d.ts +12 -45
- package/types.js +8 -14
- package/types.js.map +1 -1
- package/definitions/settings.d.ts +0 -9
- package/definitions/settings.js +0 -53
- package/definitions/settings.js.map +0 -1
- package/definitions/system.d.ts +0 -9
- package/definitions/system.js +0 -41
- package/definitions/system.js.map +0 -1
- package/dynamoDb/index.d.ts +0 -2
- package/dynamoDb/index.js +0 -13
- package/dynamoDb/index.js.map +0 -1
- package/dynamoDb/path/plainObject.d.ts +0 -2
- package/dynamoDb/path/plainObject.js +0 -33
- package/dynamoDb/path/plainObject.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -91
- package/dynamoDb/storage/date.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -91
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -95
- package/dynamoDb/storage/richText.js.map +0 -1
- package/dynamoDb/transformValue/datetime.d.ts +0 -5
- package/dynamoDb/transformValue/datetime.js +0 -45
- package/dynamoDb/transformValue/datetime.js.map +0 -1
- package/operations/entry/filtering/createExpressions.d.ts +0 -26
- package/operations/entry/filtering/createExpressions.js +0 -176
- package/operations/entry/filtering/createExpressions.js.map +0 -1
- package/operations/entry/filtering/createFields.d.ts +0 -14
- package/operations/entry/filtering/createFields.js +0 -105
- package/operations/entry/filtering/createFields.js.map +0 -1
- package/operations/entry/filtering/extractSort.d.ts +0 -17
- package/operations/entry/filtering/extractSort.js +0 -67
- package/operations/entry/filtering/extractSort.js.map +0 -1
- package/operations/entry/filtering/filter.d.ts +0 -15
- package/operations/entry/filtering/filter.js +0 -143
- package/operations/entry/filtering/filter.js.map +0 -1
- package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
- package/operations/entry/filtering/fullTextSearch.js +0 -48
- package/operations/entry/filtering/fullTextSearch.js.map +0 -1
- package/operations/entry/filtering/getValue.d.ts +0 -5
- package/operations/entry/filtering/getValue.js +0 -63
- package/operations/entry/filtering/getValue.js.map +0 -1
- package/operations/entry/filtering/index.d.ts +0 -2
- package/operations/entry/filtering/index.js +0 -19
- package/operations/entry/filtering/index.js.map +0 -1
- package/operations/entry/filtering/mapPlugins.d.ts +0 -8
- package/operations/entry/filtering/mapPlugins.js +0 -31
- package/operations/entry/filtering/mapPlugins.js.map +0 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -41
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/index.d.ts +0 -1
- package/operations/entry/filtering/plugins/index.js +0 -13
- package/operations/entry/filtering/plugins/index.js.map +0 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -86
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/refFilterCreate.js +0 -71
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
- package/operations/entry/filtering/sort.d.ts +0 -12
- package/operations/entry/filtering/sort.js +0 -69
- package/operations/entry/filtering/sort.js.map +0 -1
- package/operations/entry/filtering/systemFields.d.ts +0 -4
- package/operations/entry/filtering/systemFields.js +0 -70
- package/operations/entry/filtering/systemFields.js.map +0 -1
- package/operations/entry/filtering/transform.d.ts +0 -6
- package/operations/entry/filtering/transform.js +0 -16
- package/operations/entry/filtering/transform.js.map +0 -1
- package/operations/entry/filtering/types.d.ts +0 -40
- package/operations/entry/filtering/types.js +0 -5
- package/operations/entry/filtering/types.js.map +0 -1
- package/operations/entry/filtering/values.d.ts +0 -2
- package/operations/entry/filtering/values.js +0 -22
- package/operations/entry/filtering/values.js.map +0 -1
- package/operations/entry/filtering/where.d.ts +0 -5
- package/operations/entry/filtering/where.js +0 -32
- package/operations/entry/filtering/where.js.map +0 -1
- package/operations/entry/index.d.ts +0 -8
- package/operations/entry/index.js +0 -787
- package/operations/entry/index.js.map +0 -1
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -72
- package/operations/entry/systemFields.js.map +0 -1
- package/operations/group/index.d.ts +0 -9
- package/operations/group/index.js +0 -162
- package/operations/group/index.js.map +0 -1
- package/operations/model/index.d.ts +0 -7
- package/operations/model/index.js +0 -137
- package/operations/model/index.js.map +0 -1
- package/operations/settings/index.d.ts +0 -7
- package/operations/settings/index.js +0 -111
- package/operations/settings/index.js.map +0 -1
- package/operations/system/index.d.ts +0 -7
- package/operations/system/index.js +0 -82
- package/operations/system/index.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -22
- package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -41
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
- package/plugins/CmsEntryFieldFilterPlugin.js +0 -24
- package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
- package/plugins/CmsEntryFieldSortingPlugin.js +0 -28
- package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
- package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -24
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
- package/plugins/index.d.ts +0 -4
- package/plugins/index.js +0 -49
- package/plugins/index.js.map +0 -1
|
@@ -1,278 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
12
|
-
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
13
|
-
var _keys = require("./keys");
|
|
14
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
15
|
-
var _utils = require("@webiny/utils");
|
|
16
|
-
var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
|
|
17
|
-
const getAllEntryRevisions = params => {
|
|
18
|
-
const {
|
|
19
|
-
entity,
|
|
20
|
-
model
|
|
21
|
-
} = params;
|
|
22
|
-
const {
|
|
23
|
-
tenant,
|
|
24
|
-
locale
|
|
25
|
-
} = model;
|
|
26
|
-
return new _dataloader.default(async ids => {
|
|
27
|
-
const results = {};
|
|
28
|
-
for (const id of ids) {
|
|
29
|
-
const queryAllParams = {
|
|
30
|
-
entity,
|
|
31
|
-
partitionKey: (0, _keys.createPartitionKey)({
|
|
32
|
-
tenant,
|
|
33
|
-
locale,
|
|
34
|
-
id
|
|
35
|
-
}),
|
|
36
|
-
options: {
|
|
37
|
-
beginsWith: "REV#"
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const items = await (0, _query.queryAll)(queryAllParams);
|
|
41
|
-
results[id] = (0, _cleanup.cleanupItems)(entity, items);
|
|
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();
|
|
42
11
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
} = params;
|
|
53
|
-
const {
|
|
54
|
-
locale,
|
|
55
|
-
tenant
|
|
56
|
-
} = model;
|
|
57
|
-
return new _dataloader.default(async ids => {
|
|
58
|
-
const queries = ids.reduce((collection, id) => {
|
|
59
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
60
|
-
tenant,
|
|
61
|
-
locale,
|
|
62
|
-
id
|
|
63
|
-
});
|
|
64
|
-
const {
|
|
65
|
-
version
|
|
66
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
67
|
-
if (version === null) {
|
|
68
|
-
return collection;
|
|
69
|
-
}
|
|
70
|
-
const sortKey = (0, _keys.createRevisionSortKey)({
|
|
71
|
-
version
|
|
72
|
-
});
|
|
73
|
-
const keys = `${partitionKey}__${sortKey}`;
|
|
74
|
-
if (collection[keys]) {
|
|
75
|
-
return collection;
|
|
76
|
-
}
|
|
77
|
-
collection[keys] = entity.getBatch({
|
|
78
|
-
PK: partitionKey,
|
|
79
|
-
SK: sortKey
|
|
80
|
-
});
|
|
81
|
-
return collection;
|
|
82
|
-
/**
|
|
83
|
-
* We cast as any because there is no return type defined.
|
|
84
|
-
*/
|
|
85
|
-
}, {});
|
|
86
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
87
|
-
table: entity.table,
|
|
88
|
-
items: Object.values(queries)
|
|
89
|
-
});
|
|
90
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
91
|
-
return ids.map(id => {
|
|
92
|
-
return items.filter(item => {
|
|
93
|
-
return id === item.id;
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
const getPublishedRevisionByEntryId = params => {
|
|
99
|
-
const {
|
|
100
|
-
entity,
|
|
101
|
-
model
|
|
102
|
-
} = params;
|
|
103
|
-
const {
|
|
104
|
-
locale,
|
|
105
|
-
tenant
|
|
106
|
-
} = model;
|
|
107
|
-
const publishedKey = (0, _keys.createPublishedSortKey)();
|
|
108
|
-
return new _dataloader.default(async ids => {
|
|
109
|
-
const queries = ids.reduce((collection, id) => {
|
|
110
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
111
|
-
tenant,
|
|
112
|
-
locale,
|
|
113
|
-
id
|
|
114
|
-
});
|
|
115
|
-
if (collection[partitionKey]) {
|
|
116
|
-
return collection;
|
|
117
|
-
}
|
|
118
|
-
collection[partitionKey] = entity.getBatch({
|
|
119
|
-
PK: partitionKey,
|
|
120
|
-
SK: publishedKey
|
|
121
|
-
});
|
|
122
|
-
return collection;
|
|
123
|
-
/**
|
|
124
|
-
* We cast as any because there is no return type defined.
|
|
125
|
-
*/
|
|
126
|
-
}, {});
|
|
127
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
128
|
-
table: entity.table,
|
|
129
|
-
items: Object.values(queries)
|
|
130
|
-
});
|
|
131
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
132
|
-
return ids.map(id => {
|
|
133
|
-
const {
|
|
134
|
-
id: entryId
|
|
135
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
136
|
-
return items.filter(item => {
|
|
137
|
-
return entryId === item.entryId;
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
const getLatestRevisionByEntryId = params => {
|
|
143
|
-
const {
|
|
144
|
-
entity,
|
|
145
|
-
model
|
|
146
|
-
} = params;
|
|
147
|
-
const {
|
|
148
|
-
locale,
|
|
149
|
-
tenant
|
|
150
|
-
} = model;
|
|
151
|
-
const latestKey = (0, _keys.createLatestSortKey)();
|
|
152
|
-
return new _dataloader.default(async ids => {
|
|
153
|
-
const queries = ids.reduce((collection, id) => {
|
|
154
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
155
|
-
tenant,
|
|
156
|
-
locale,
|
|
157
|
-
id
|
|
158
|
-
});
|
|
159
|
-
if (collection[partitionKey]) {
|
|
160
|
-
return collection;
|
|
161
|
-
}
|
|
162
|
-
collection[partitionKey] = entity.getBatch({
|
|
163
|
-
PK: partitionKey,
|
|
164
|
-
SK: latestKey
|
|
165
|
-
});
|
|
166
|
-
return collection;
|
|
167
|
-
/**
|
|
168
|
-
* We cast as any because there is no return type defined.
|
|
169
|
-
*/
|
|
170
|
-
}, {});
|
|
171
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
172
|
-
table: entity.table,
|
|
173
|
-
items: Object.values(queries)
|
|
174
|
-
});
|
|
175
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
176
|
-
return ids.map(id => {
|
|
177
|
-
const {
|
|
178
|
-
id: entryId
|
|
179
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
180
|
-
return items.filter(item => {
|
|
181
|
-
return entryId === item.entryId;
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
};
|
|
186
|
-
const dataLoaders = {
|
|
187
|
-
getAllEntryRevisions,
|
|
188
|
-
getRevisionById,
|
|
189
|
-
getPublishedRevisionByEntryId,
|
|
190
|
-
getLatestRevisionByEntryId
|
|
191
|
-
};
|
|
192
|
-
const loaderNames = Object.keys(dataLoaders);
|
|
193
|
-
class DataLoadersHandler {
|
|
194
|
-
constructor(params) {
|
|
195
|
-
(0, _defineProperty2.default)(this, "loaders", new Map());
|
|
196
|
-
(0, _defineProperty2.default)(this, "entity", void 0);
|
|
197
|
-
this.entity = params.entity;
|
|
198
|
-
}
|
|
199
|
-
async getAllEntryRevisions(params) {
|
|
200
|
-
return await this.loadMany("getAllEntryRevisions", params, params.ids);
|
|
201
|
-
}
|
|
202
|
-
async getRevisionById(params) {
|
|
203
|
-
return await this.loadMany("getRevisionById", params, params.ids);
|
|
204
|
-
}
|
|
205
|
-
async getPublishedRevisionByEntryId(params) {
|
|
206
|
-
return await this.loadMany("getPublishedRevisionByEntryId", params, params.ids);
|
|
207
|
-
}
|
|
208
|
-
async getLatestRevisionByEntryId(params) {
|
|
209
|
-
return await this.loadMany("getLatestRevisionByEntryId", params, params.ids);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* TODO @ts-refactor
|
|
214
|
-
* Maybe pass on the generics to DataLoader definition?
|
|
215
|
-
*/
|
|
216
|
-
getLoader(name, params) {
|
|
217
|
-
if (!dataLoaders[name]) {
|
|
218
|
-
throw new _error.default("Unknown data loader.", "UNKNOWN_DATA_LOADER", {
|
|
219
|
-
name
|
|
220
|
-
});
|
|
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);
|
|
18
|
+
}
|
|
19
|
+
async getRevisionById(params) {
|
|
20
|
+
return await this.loadMany("getRevisionById", params, params.ids);
|
|
221
21
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
} = model;
|
|
229
|
-
const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;
|
|
230
|
-
if (!this.loaders.has(loaderKey)) {
|
|
231
|
-
this.loaders.set(loaderKey, dataLoaders[name]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
232
|
-
entity: this.entity
|
|
233
|
-
})));
|
|
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);
|
|
234
28
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if (Array.isArray(results) === true) {
|
|
242
|
-
return results.reduce((acc, res) => {
|
|
243
|
-
if (Array.isArray(res) === false) {
|
|
244
|
-
if (res && res.message) {
|
|
245
|
-
throw new _error.default(res.message, res.code, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, res), {}, {
|
|
246
|
-
data: JSON.stringify(res.data || {})
|
|
247
|
-
}));
|
|
248
|
-
}
|
|
249
|
-
throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
250
|
-
loader
|
|
251
|
-
}));
|
|
252
|
-
}
|
|
253
|
-
acc.push(...res);
|
|
254
|
-
return acc;
|
|
255
|
-
}, []);
|
|
256
|
-
}
|
|
257
|
-
} catch (ex) {
|
|
258
|
-
throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
259
|
-
error: ex
|
|
260
|
-
}, params), {}, {
|
|
261
|
-
loader,
|
|
262
|
-
ids
|
|
263
|
-
}));
|
|
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);
|
|
264
35
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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);
|
|
275
88
|
}
|
|
276
|
-
}
|
|
277
89
|
}
|
|
278
|
-
|
|
90
|
+
const DataLoadersHandler = CmsDdbDataLoaders.createImplementation({
|
|
91
|
+
implementation: DataLoadersHandlerImpl,
|
|
92
|
+
dependencies: [
|
|
93
|
+
CmsDdbEntryEntity
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
export { DataLoadersHandler };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=dataLoaders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getAllEntryRevisions","params","entity","model","tenant","locale","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","getRevisionById","queries","reduce","collection","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","Object","values","filter","item","getPublishedRevisionByEntryId","publishedKey","createPublishedSortKey","entryId","getLatestRevisionByEntryId","latestKey","createLatestSortKey","dataLoaders","loaderNames","DataLoadersHandler","constructor","Map","loadMany","getLoader","name","WebinyError","loaderKey","modelId","loaders","has","set","get","loader","Array","isArray","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll"],"sources":["dataLoaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { CmsStorageEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\n\nconst getAllEntryRevisions = (params: LoaderParams) => {\n const { entity, model } = params;\n const { tenant, locale } = model;\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const results: Record<string, CmsStorageEntry[]> = {};\n for (const id of ids) {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n };\n const items = await queryAll<CmsStorageEntry>(queryAllParams);\n results[id] = cleanupItems(entity, items);\n }\n\n return ids.map(id => {\n return results[id] || [];\n });\n });\n};\n\nconst getRevisionById = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n /**\n * We cast as any because there is no return type defined.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n });\n};\n\nconst getPublishedRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const publishedKey = createPublishedSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: publishedKey\n });\n return collection;\n /**\n * We cast as any because there is no return type defined.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst getLatestRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: latestKey\n });\n return collection;\n /**\n * We cast as any because there is no return type defined.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst dataLoaders: Record<Loaders, any> = {\n getAllEntryRevisions,\n getRevisionById,\n getPublishedRevisionByEntryId,\n getLatestRevisionByEntryId\n};\n\nexport interface GetAllEntryRevisionsParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetRevisionByIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetPublishedRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetLatestRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\ninterface LoaderParams {\n entity: Entity<any>;\n model: CmsModel;\n}\n\ninterface GetLoaderParams {\n model: CmsModel;\n}\n\ninterface ClearLoaderParams {\n model: CmsModel;\n entry?: CmsStorageEntry;\n}\n\ntype Loaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nconst loaderNames = Object.keys(dataLoaders) as Loaders[];\n\ninterface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\nexport class DataLoadersHandler {\n private readonly loaders: Map<string, DataLoader<any, any>> = new Map();\n private readonly entity: Entity<any>;\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(\n params: GetAllEntryRevisionsParams\n ): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getAllEntryRevisions\", params, params.ids);\n }\n\n public async getRevisionById(params: GetRevisionByIdParams): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId(\n params: GetPublishedRevisionByEntryIdParams\n ): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, params.ids);\n }\n\n public async getLatestRevisionByEntryId(\n params: GetLatestRevisionByEntryIdParams\n ): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getLatestRevisionByEntryId\", params, params.ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: Loaders, params: GetLoaderParams): DataLoader<any, any> {\n if (!dataLoaders[name]) {\n throw new WebinyError(\"Unknown data loader.\", \"UNKNOWN_DATA_LOADER\", {\n name\n });\n }\n const { model } = params;\n const { tenant, locale } = model;\n const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;\n if (!this.loaders.has(loaderKey)) {\n this.loaders.set(\n loaderKey,\n dataLoaders[name]({\n ...params,\n entity: this.entity\n })\n );\n }\n return this.loaders.get(loaderKey) as DataLoader<any, any>;\n }\n\n private async loadMany(\n loader: Loaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry[]> {\n let results;\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: Omit<ClearLoaderParams, \"entry\">): void {\n for (const name of loaderNames) {\n const loader = this.getLoader(name, params);\n loader.clearAll();\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA;AAEA;AAEA;AACA;AAMA;AACA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A0D,EAC3D,4BAA4B,EAC5B;MACIO,MAAM;MACNrD,GAAG;MACHC;IACJ,CAAC,CACJ;EACL;EAEOiE,QAAQ,CAACxE,MAAwC,EAAQ;IAC5D,KAAK,MAAMmD,IAAI,IAAIN,WAAW,EAAE;MAC5B,MAAMc,MAAM,GAAG,IAAI,CAACT,SAAS,CAACC,IAAI,EAAEnD,MAAM,CAAC;MAC3C2D,MAAM,CAACa,QAAQ,EAAE;IACrB;EACJ;AACJ;AAAC"}
|
|
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":";;;;;;AAyBA,MAAMA;IAGF,YAAoCC,MAAmC,CAAE;aAArCA,MAAM,GAANA;aAFnB,KAAK,GAAG,IAAIC;IAE6C;IAE1E,MAAa,qBACTC,MAAwB,EACK;QAC7B,MAAMC,MAAMD,OAAO,GAAG,CAAC,GAAG,CAACE,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,wBAAwBH,QAAQC;IAClE;IAEA,MAAa,gBACTD,MAAwB,EACK;QAC7B,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,mBAAmBA,QAAQA,OAAO,GAAG;IACvE;IAEA,MAAa,8BACTA,MAAwB,EACK;QAC7B,MAAMC,MAAMD,OAAO,GAAG,CAAC,GAAG,CAACE,CAAAA;YACvB,MAAM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AAG;wBACN,MAAME,KAAK,SAAS,CAACF,IAAI,IAAI,IAAI,CAAC;oBACtC;oBAEJ,MAAM,IAAIC,MACN,yFACA,6BACA;wBACI,GAAGf,MAAM;wBACTQ;oBACJ;gBAER;gBACAK,IAAI,IAAI,IAAIC;gBACZ,OAAOD;YACX,GAAG,EAAE;QAEb,EAAE,OAAOI,IAAI;YACT,MAAM,IAAIF,MACNE,GAAG,OAAO,IAAI,sBACdA,GAAG,IAAI,IAAI,qBACX;gBACI,OAAOA;gBACP,GAAGjB,MAAM;gBACTQ;gBACAP;YACJ;QAER;QACA,MAAM,IAAIc,MACN,6DACA,8BACA;YACIP;YACAP;YACAU;QACJ;IAER;IAEO,SAASX,MAAkD,EAAQ;QACtE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAACA;IACxB;AACJ;AAEO,MAAMkB,qBAAqBC,kBAAkB,oBAAoB,CAAC;IACrE,gBAAgBtB;IAChB,cAAc;QAACuB;KAAkB;AACrC"}
|
|
@@ -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 {};
|