@webiny/api-headless-cms-ddb 0.0.0-unstable.eb196ccd2f → 0.0.0-unstable.eb81deee7e
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 -6
- package/definitions/entry.js +8 -185
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -6
- package/definitions/group.js +8 -63
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -6
- package/definitions/model.js +8 -107
- package/definitions/model.js.map +1 -1
- package/definitions/table.d.ts +3 -5
- package/definitions/table.js +6 -29
- package/definitions/table.js.map +1 -1
- package/definitions/types.d.ts +65 -0
- package/definitions/types.js +0 -0
- package/index.d.ts +17 -3
- package/index.js +36 -123
- 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 +1 -2
- package/operations/entry/dataLoader/DataLoaderCache.js +21 -35
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +2 -7
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +7 -22
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
- package/operations/entry/dataLoader/getAllEntryRevisions.js +20 -41
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +36 -52
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +36 -52
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
- package/operations/entry/dataLoader/getRevisionById.js +38 -58
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.d.ts +3 -3
- package/operations/entry/dataLoader/index.js +13 -35
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +4 -4
- package/operations/entry/dataLoader/types.js +0 -7
- package/operations/entry/dataLoaders.d.ts +13 -13
- package/operations/entry/dataLoaders.js +92 -110
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/feature.d.ts +4 -0
- package/operations/entry/feature.js +53 -0
- package/operations/entry/feature.js.map +1 -0
- package/operations/entry/keys.d.ts +46 -2
- package/operations/entry/keys.js +52 -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 +27 -25
- package/requestFeature.d.ts +17 -0
- package/requestFeature.js +19 -0
- package/requestFeature.js.map +1 -0
- package/types.d.ts +11 -51
- package/types.js +6 -12
- package/types.js.map +1 -1
- package/definitions/system.d.ts +0 -10
- package/definitions/system.js +0 -42
- package/definitions/system.js.map +0 -1
- package/dynamoDb/index.d.ts +0 -2
- package/dynamoDb/index.js +0 -15
- package/dynamoDb/index.js.map +0 -1
- package/dynamoDb/path/locationFolderId.d.ts +0 -2
- package/dynamoDb/path/locationFolderId.js +0 -43
- package/dynamoDb/path/locationFolderId.js.map +0 -1
- package/dynamoDb/path/plainObject.d.ts +0 -2
- package/dynamoDb/path/plainObject.js +0 -35
- package/dynamoDb/path/plainObject.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -94
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -61
- package/dynamoDb/storage/richText.js.map +0 -1
- package/dynamoDb/transformValue/datetime.d.ts +0 -5
- package/dynamoDb/transformValue/datetime.js +0 -47
- package/dynamoDb/transformValue/datetime.js.map +0 -1
- package/operations/entry/dataLoader/types.js.map +0 -1
- package/operations/entry/filtering/createExpressions.d.ts +0 -26
- package/operations/entry/filtering/createExpressions.js +0 -178
- package/operations/entry/filtering/createExpressions.js.map +0 -1
- package/operations/entry/filtering/createFields.d.ts +0 -16
- package/operations/entry/filtering/createFields.js +0 -108
- 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 -69
- 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 -158
- 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 -50
- 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 -66
- 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 -21
- 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 -33
- 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 -45
- 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 -16
- 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 -90
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -3
- package/operations/entry/filtering/plugins/refFilterCreate.js +0 -80
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +0 -65
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +0 -1
- package/operations/entry/filtering/sort.d.ts +0 -12
- package/operations/entry/filtering/sort.js +0 -71
- 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 -90
- 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 -18
- 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 -7
- 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 -24
- 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 -35
- package/operations/entry/filtering/where.js.map +0 -1
- package/operations/entry/index.d.ts +0 -8
- package/operations/entry/index.js +0 -1306
- package/operations/entry/index.js.map +0 -1
- package/operations/group/index.d.ts +0 -9
- package/operations/group/index.js +0 -174
- package/operations/group/index.js.map +0 -1
- package/operations/model/index.d.ts +0 -7
- package/operations/model/index.js +0 -150
- package/operations/model/index.js.map +0 -1
- package/operations/system/index.d.ts +0 -7
- package/operations/system/index.js +0 -94
- package/operations/system/index.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -23
- package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -48
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
- package/plugins/CmsEntryFieldFilterPlugin.js +0 -27
- package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
- package/plugins/CmsEntryFieldSortingPlugin.js +0 -27
- package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
- package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -23
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
- package/plugins/index.d.ts +0 -4
- package/plugins/index.js +0 -51
- package/plugins/index.js.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
import { DeleteEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteEntryStorageOperation.js";
|
|
3
|
+
import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
|
|
4
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
5
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
6
|
+
import { createPartitionKey } from "./keys.js";
|
|
7
|
+
class DdbDeleteEntryImpl {
|
|
8
|
+
constructor(entity, dataLoaders, storageModelProvider){
|
|
9
|
+
this.entity = entity;
|
|
10
|
+
this.dataLoaders = dataLoaders;
|
|
11
|
+
this.storageModelProvider = storageModelProvider;
|
|
12
|
+
}
|
|
13
|
+
async execute(initialModel, params) {
|
|
14
|
+
const { entry } = params;
|
|
15
|
+
const id = entry.id || entry.entryId;
|
|
16
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
17
|
+
const partitionKey = createPartitionKey({
|
|
18
|
+
id,
|
|
19
|
+
tenant: model.tenant
|
|
20
|
+
});
|
|
21
|
+
let records = [];
|
|
22
|
+
try {
|
|
23
|
+
records = await this.entity.queryAll({
|
|
24
|
+
partitionKey,
|
|
25
|
+
options: {
|
|
26
|
+
gte: " "
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
} catch (ex) {
|
|
30
|
+
throw new error(ex.message || "Could not load all records.", ex.code || "LOAD_ALL_RECORDS_ERROR", {
|
|
31
|
+
error: ex,
|
|
32
|
+
id
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const entityBatch = this.entity.createEntityWriter({
|
|
36
|
+
delete: records.map((item)=>({
|
|
37
|
+
PK: item.PK,
|
|
38
|
+
SK: item.SK
|
|
39
|
+
}))
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
await entityBatch.execute();
|
|
43
|
+
this.dataLoaders.clearAll({
|
|
44
|
+
tenant: entry.tenant
|
|
45
|
+
});
|
|
46
|
+
} catch (ex) {
|
|
47
|
+
throw new error(ex.message || "Could not delete the entry.", ex.code || "DELETE_ENTRY_ERROR", {
|
|
48
|
+
error: ex,
|
|
49
|
+
partitionKey,
|
|
50
|
+
id
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const DdbDeleteEntry = DeleteEntryStorageOperation.createImplementation({
|
|
56
|
+
implementation: DdbDeleteEntryImpl,
|
|
57
|
+
dependencies: [
|
|
58
|
+
CmsDdbEntryEntity,
|
|
59
|
+
CmsDdbDataLoaders,
|
|
60
|
+
CmsStorageModelProvider
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
export { DdbDeleteEntry };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=DdbDeleteEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbDeleteEntry.js","sources":["../../../src/operations/entry/DdbDeleteEntry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryStorageOperationsDeleteParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { DeleteEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteEntryStorageOperation.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\n\nclass DdbDeleteEntryImpl implements DeleteEntryStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEntryEntity.Interface,\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute(initialModel: CmsModel, params: CmsEntryStorageOperationsDeleteParams) {\n const { entry } = params;\n const id = entry.id || entry.entryId;\n const model = this.storageModelProvider.getModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id,\n tenant: model.tenant\n });\n\n let records: Awaited<ReturnType<typeof this.entity.queryAll>> = [];\n try {\n records = await this.entity.queryAll({\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not load all records.\",\n ex.code || \"LOAD_ALL_RECORDS_ERROR\",\n {\n error: ex,\n id\n }\n );\n }\n\n const entityBatch = this.entity.createEntityWriter({\n delete: records.map(item => {\n return {\n PK: item.PK,\n SK: item.SK\n };\n })\n });\n\n try {\n await entityBatch.execute();\n this.dataLoaders.clearAll({\n tenant: entry.tenant\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete the entry.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n partitionKey,\n id\n }\n );\n }\n }\n}\n\nexport const DdbDeleteEntry = DeleteEntryStorageOperation.createImplementation({\n implementation: DdbDeleteEntryImpl,\n dependencies: [CmsDdbEntryEntity, CmsDdbDataLoaders, CmsStorageModelProvider]\n});\n"],"names":["DdbDeleteEntryImpl","entity","dataLoaders","storageModelProvider","initialModel","params","entry","id","model","partitionKey","createPartitionKey","records","ex","WebinyError","entityBatch","item","DdbDeleteEntry","DeleteEntryStorageOperation","CmsDdbEntryEntity","CmsDdbDataLoaders","CmsStorageModelProvider"],"mappings":";;;;;;AAWA,MAAMA;IACF,YACYC,MAAmC,EACnCC,WAAwC,EACxCC,oBAAuD,CACjE;aAHUF,MAAM,GAANA;aACAC,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QAAQC,YAAsB,EAAEC,MAA6C,EAAE;QACjF,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAClB,MAAME,KAAKD,MAAM,EAAE,IAAIA,MAAM,OAAO;QACpC,MAAME,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAACJ;QAEjD,MAAMK,eAAeC,mBAAmB;YACpCH;YACA,QAAQC,MAAM,MAAM;QACxB;QAEA,IAAIG,UAA4D,EAAE;QAClE,IAAI;YACAA,UAAU,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACjCF;gBACA,SAAS;oBACL,KAAK;gBACT;YACJ;QACJ,EAAE,OAAOG,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,+BACdA,GAAG,IAAI,IAAI,0BACX;gBACI,OAAOA;gBACPL;YACJ;QAER;QAEA,MAAMO,cAAc,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;YAC/C,QAAQH,QAAQ,GAAG,CAACI,CAAAA,OACT;oBACH,IAAIA,KAAK,EAAE;oBACX,IAAIA,KAAK,EAAE;gBACf;QAER;QAEA,IAAI;YACA,MAAMD,YAAY,OAAO;YACzB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;gBACtB,QAAQR,MAAM,MAAM;YACxB;QACJ,EAAE,OAAOM,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,+BACdA,GAAG,IAAI,IAAI,sBACX;gBACI,OAAOA;gBACPH;gBACAF;YACJ;QAER;IACJ;AACJ;AAEO,MAAMS,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBjB;IAChB,cAAc;QAACkB;QAAmBC;QAAmBC;KAAwB;AACjF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsDeleteRevisionParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { DeleteEntryRevisionStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js";
|
|
3
|
+
import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
|
|
4
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
5
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
6
|
+
declare class DdbDeleteEntryRevisionImpl implements DeleteEntryRevisionStorageOperation.Interface {
|
|
7
|
+
private entity;
|
|
8
|
+
private dataLoaders;
|
|
9
|
+
private storageModelProvider;
|
|
10
|
+
constructor(entity: CmsDdbEntryEntity.Interface, dataLoaders: CmsDdbDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
11
|
+
private getPublishedRevisionByEntryId;
|
|
12
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsDeleteRevisionParams<T>): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare const DdbDeleteEntryRevision: typeof DdbDeleteEntryRevisionImpl & {
|
|
15
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js").IDeleteEntryRevisionStorageOperation>;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
import { DeleteEntryRevisionStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js";
|
|
3
|
+
import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
|
|
4
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
5
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
6
|
+
import { createEntryLatestKeys, createEntryRevisionKeys, createPartitionKey, createPublishedSortKey, createRevisionSortKey } from "./keys.js";
|
|
7
|
+
import { convertFromStorageEntry, convertToStorageEntry } from "./storageEntryUtils.js";
|
|
8
|
+
class DdbDeleteEntryRevisionImpl {
|
|
9
|
+
constructor(entity, dataLoaders, storageModelProvider){
|
|
10
|
+
this.entity = entity;
|
|
11
|
+
this.dataLoaders = dataLoaders;
|
|
12
|
+
this.storageModelProvider = storageModelProvider;
|
|
13
|
+
}
|
|
14
|
+
async getPublishedRevisionByEntryId(initialModel, params) {
|
|
15
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
16
|
+
const items = await this.dataLoaders.getPublishedRevisionByEntryId({
|
|
17
|
+
model,
|
|
18
|
+
ids: [
|
|
19
|
+
params.id
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
const item = items.shift() || null;
|
|
23
|
+
if (!item) return null;
|
|
24
|
+
return convertFromStorageEntry({
|
|
25
|
+
storageEntry: item,
|
|
26
|
+
model
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async execute(initialModel, params) {
|
|
30
|
+
const { entry, latestEntry, latestStorageEntry: initialLatestStorageEntry } = params;
|
|
31
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
32
|
+
const partitionKey = createPartitionKey({
|
|
33
|
+
id: entry.id,
|
|
34
|
+
tenant: model.tenant
|
|
35
|
+
});
|
|
36
|
+
const entityBatch = this.entity.createEntityWriter({
|
|
37
|
+
delete: [
|
|
38
|
+
{
|
|
39
|
+
PK: partitionKey,
|
|
40
|
+
SK: createRevisionSortKey(entry)
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
const publishedStorageEntry = await this.getPublishedRevisionByEntryId(model, entry);
|
|
45
|
+
if (publishedStorageEntry && entry.id === publishedStorageEntry.id) entityBatch.delete({
|
|
46
|
+
PK: partitionKey,
|
|
47
|
+
SK: createPublishedSortKey()
|
|
48
|
+
});
|
|
49
|
+
if (initialLatestStorageEntry) {
|
|
50
|
+
const latestStorageEntry = convertToStorageEntry({
|
|
51
|
+
storageEntry: initialLatestStorageEntry,
|
|
52
|
+
model
|
|
53
|
+
});
|
|
54
|
+
entityBatch.put({
|
|
55
|
+
...createEntryLatestKeys(latestStorageEntry),
|
|
56
|
+
data: {
|
|
57
|
+
...latestStorageEntry
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
entityBatch.put({
|
|
61
|
+
...createEntryRevisionKeys(latestStorageEntry),
|
|
62
|
+
data: {
|
|
63
|
+
...latestStorageEntry
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
await entityBatch.execute();
|
|
69
|
+
this.dataLoaders.clearAll({
|
|
70
|
+
tenant: entry.tenant
|
|
71
|
+
});
|
|
72
|
+
} catch (ex) {
|
|
73
|
+
throw new error(ex.message, ex.code, {
|
|
74
|
+
error: ex,
|
|
75
|
+
entry,
|
|
76
|
+
latestEntry
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const DdbDeleteEntryRevision = DeleteEntryRevisionStorageOperation.createImplementation({
|
|
82
|
+
implementation: DdbDeleteEntryRevisionImpl,
|
|
83
|
+
dependencies: [
|
|
84
|
+
CmsDdbEntryEntity,
|
|
85
|
+
CmsDdbDataLoaders,
|
|
86
|
+
CmsStorageModelProvider
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
export { DdbDeleteEntryRevision };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=DdbDeleteEntryRevision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbDeleteEntryRevision.js","sources":["../../../src/operations/entry/DdbDeleteEntryRevision.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsDeleteRevisionParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { DeleteEntryRevisionStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n createEntryLatestKeys,\n createEntryRevisionKeys,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"~/operations/entry/keys.js\";\nimport { convertFromStorageEntry, convertToStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbDeleteEntryRevisionImpl implements DeleteEntryRevisionStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEntryEntity.Interface,\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n private async getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: { id: string }\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const items = await this.dataLoaders.getPublishedRevisionByEntryId<T>({\n model,\n ids: [params.id]\n });\n const item = items.shift() || null;\n if (!item) {\n return null;\n }\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n }\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams<T>\n ) {\n const { entry, latestEntry, latestStorageEntry: initialLatestStorageEntry } = params;\n\n const model = this.storageModelProvider.getModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n tenant: model.tenant\n });\n\n const entityBatch = this.entity.createEntityWriter({\n delete: [\n {\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n }\n ]\n });\n\n const publishedStorageEntry = await this.getPublishedRevisionByEntryId(model, entry);\n\n /**\n * If revision we are deleting is the published one as well, we need to delete those records as well.\n */\n if (publishedStorageEntry && entry.id === publishedStorageEntry.id) {\n entityBatch.delete({\n PK: partitionKey,\n SK: createPublishedSortKey()\n });\n }\n\n if (initialLatestStorageEntry) {\n const latestStorageEntry = convertToStorageEntry({\n storageEntry: initialLatestStorageEntry,\n model\n });\n entityBatch.put({\n ...createEntryLatestKeys(latestStorageEntry),\n data: {\n ...latestStorageEntry\n }\n });\n\n // Do an update on the latest revision. We need to update the latest revision's\n // entry-level meta fields to match the previous revision's entry-level meta fields.\n entityBatch.put({\n ...createEntryRevisionKeys(latestStorageEntry),\n data: {\n ...latestStorageEntry\n }\n });\n }\n try {\n await entityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant: entry.tenant\n });\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code, {\n error: ex,\n entry,\n latestEntry\n });\n }\n }\n}\n\nexport const DdbDeleteEntryRevision = DeleteEntryRevisionStorageOperation.createImplementation({\n implementation: DdbDeleteEntryRevisionImpl,\n dependencies: [CmsDdbEntryEntity, CmsDdbDataLoaders, CmsStorageModelProvider]\n});\n"],"names":["DdbDeleteEntryRevisionImpl","entity","dataLoaders","storageModelProvider","initialModel","params","model","items","item","convertFromStorageEntry","entry","latestEntry","initialLatestStorageEntry","partitionKey","createPartitionKey","entityBatch","createRevisionSortKey","publishedStorageEntry","createPublishedSortKey","latestStorageEntry","convertToStorageEntry","createEntryLatestKeys","createEntryRevisionKeys","ex","WebinyError","DdbDeleteEntryRevision","DeleteEntryRevisionStorageOperation","CmsDdbEntryEntity","CmsDdbDataLoaders","CmsStorageModelProvider"],"mappings":";;;;;;;AAmBA,MAAMA;IACF,YACYC,MAAmC,EACnCC,WAAwC,EACxCC,oBAAuD,CACjE;aAHUF,MAAM,GAANA;aACAC,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAc,8BACVC,YAAsB,EACtBC,MAAsB,EACxB;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIF;QAEpD,MAAMG,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,6BAA6B,CAAI;YAClED;YACA,KAAK;gBAACD,OAAO,EAAE;aAAC;QACpB;QACA,MAAMG,OAAOD,MAAM,KAAK,MAAM;QAC9B,IAAI,CAACC,MACD,OAAO;QAEX,OAAOC,wBAAwB;YAC3B,cAAcD;YACdF;QACJ;IACJ;IAEA,MAAM,QACFF,YAAsB,EACtBC,MAAwD,EAC1D;QACE,MAAM,EAAEK,KAAK,EAAEC,WAAW,EAAE,oBAAoBC,yBAAyB,EAAE,GAAGP;QAE9E,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAACF;QAEjD,MAAMS,eAAeC,mBAAmB;YACpC,IAAIJ,MAAM,EAAE;YACZ,QAAQJ,MAAM,MAAM;QACxB;QAEA,MAAMS,cAAc,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;YAC/C,QAAQ;gBACJ;oBACI,IAAIF;oBACJ,IAAIG,sBAAsBN;gBAC9B;aACH;QACL;QAEA,MAAMO,wBAAwB,MAAM,IAAI,CAAC,6BAA6B,CAACX,OAAOI;QAK9E,IAAIO,yBAAyBP,MAAM,EAAE,KAAKO,sBAAsB,EAAE,EAC9DF,YAAY,MAAM,CAAC;YACf,IAAIF;YACJ,IAAIK;QACR;QAGJ,IAAIN,2BAA2B;YAC3B,MAAMO,qBAAqBC,sBAAsB;gBAC7C,cAAcR;gBACdN;YACJ;YACAS,YAAY,GAAG,CAAC;gBACZ,GAAGM,sBAAsBF,mBAAmB;gBAC5C,MAAM;oBACF,GAAGA,kBAAkB;gBACzB;YACJ;YAIAJ,YAAY,GAAG,CAAC;gBACZ,GAAGO,wBAAwBH,mBAAmB;gBAC9C,MAAM;oBACF,GAAGA,kBAAkB;gBACzB;YACJ;QACJ;QACA,IAAI;YACA,MAAMJ,YAAY,OAAO;YAEzB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;gBACtB,QAAQL,MAAM,MAAM;YACxB;QACJ,EAAE,OAAOa,IAAI;YACT,MAAM,IAAIC,MAAYD,GAAG,OAAO,EAAEA,GAAG,IAAI,EAAE;gBACvC,OAAOA;gBACPb;gBACAC;YACJ;QACJ;IACJ;AACJ;AAEO,MAAMc,yBAAyBC,oCAAoC,oBAAoB,CAAC;IAC3F,gBAAgB1B;IAChB,cAAc;QAAC2B;QAAmBC;QAAmBC;KAAwB;AACjF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryStorageOperationsDeleteEntriesParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { DeleteMultipleEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js";
|
|
3
|
+
import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
|
|
4
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
5
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
6
|
+
declare class DdbDeleteMultipleEntriesImpl implements DeleteMultipleEntriesStorageOperation.Interface {
|
|
7
|
+
private entity;
|
|
8
|
+
private dataLoaders;
|
|
9
|
+
private storageModelProvider;
|
|
10
|
+
constructor(entity: CmsDdbEntryEntity.Interface, dataLoaders: CmsDdbDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
11
|
+
execute(initialModel: CmsModel, params: CmsEntryStorageOperationsDeleteEntriesParams): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare const DdbDeleteMultipleEntries: typeof DdbDeleteMultipleEntriesImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js").IDeleteMultipleEntriesStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DeleteMultipleEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js";
|
|
2
|
+
import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
|
|
3
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
import { createPartitionKey, createRevisionSortKey } from "./keys.js";
|
|
6
|
+
class DdbDeleteMultipleEntriesImpl {
|
|
7
|
+
constructor(entity, dataLoaders, storageModelProvider){
|
|
8
|
+
this.entity = entity;
|
|
9
|
+
this.dataLoaders = dataLoaders;
|
|
10
|
+
this.storageModelProvider = storageModelProvider;
|
|
11
|
+
}
|
|
12
|
+
async execute(initialModel, params) {
|
|
13
|
+
const { entries } = params;
|
|
14
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
15
|
+
const revisions = await this.dataLoaders.getAllEntryRevisions({
|
|
16
|
+
model,
|
|
17
|
+
ids: entries
|
|
18
|
+
});
|
|
19
|
+
const entityBatch = this.entity.createEntityWriter();
|
|
20
|
+
for (const id of entries){
|
|
21
|
+
const partitionKey = createPartitionKey({
|
|
22
|
+
id,
|
|
23
|
+
tenant: model.tenant
|
|
24
|
+
});
|
|
25
|
+
entityBatch.delete({
|
|
26
|
+
PK: partitionKey,
|
|
27
|
+
SK: "L"
|
|
28
|
+
});
|
|
29
|
+
entityBatch.delete({
|
|
30
|
+
PK: partitionKey,
|
|
31
|
+
SK: "P"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
for (const revision of revisions)entityBatch.delete({
|
|
35
|
+
PK: createPartitionKey({
|
|
36
|
+
id: revision.id,
|
|
37
|
+
tenant: model.tenant
|
|
38
|
+
}),
|
|
39
|
+
SK: createRevisionSortKey({
|
|
40
|
+
version: revision.version
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
await entityBatch.execute();
|
|
44
|
+
this.dataLoaders.clearAll({
|
|
45
|
+
tenant: model.tenant
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const DdbDeleteMultipleEntries = DeleteMultipleEntriesStorageOperation.createImplementation({
|
|
50
|
+
implementation: DdbDeleteMultipleEntriesImpl,
|
|
51
|
+
dependencies: [
|
|
52
|
+
CmsDdbEntryEntity,
|
|
53
|
+
CmsDdbDataLoaders,
|
|
54
|
+
CmsStorageModelProvider
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
export { DdbDeleteMultipleEntries };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=DdbDeleteMultipleEntries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbDeleteMultipleEntries.js","sources":["../../../src/operations/entry/DdbDeleteMultipleEntries.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryStorageOperationsDeleteEntriesParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { DeleteMultipleEntriesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys.js\";\n\nclass DdbDeleteMultipleEntriesImpl implements DeleteMultipleEntriesStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEntryEntity.Interface,\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute(initialModel: CmsModel, params: CmsEntryStorageOperationsDeleteEntriesParams) {\n const { entries } = params;\n const model = this.storageModelProvider.getModel(initialModel);\n /**\n * First we need all the revisions of the entries we want to delete.\n */\n const revisions = await this.dataLoaders.getAllEntryRevisions({\n model,\n ids: entries\n });\n /**\n * Then we need to construct the queries for all the revisions and entries.\n */\n\n const entityBatch = this.entity.createEntityWriter();\n\n for (const id of entries) {\n const partitionKey = createPartitionKey({\n id,\n tenant: model.tenant\n });\n entityBatch.delete({\n PK: partitionKey,\n SK: \"L\"\n });\n entityBatch.delete({\n PK: partitionKey,\n SK: \"P\"\n });\n }\n /**\n * Exact revisions of all the entries\n */\n for (const revision of revisions) {\n entityBatch.delete({\n PK: createPartitionKey({\n id: revision.id,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey({\n version: revision.version\n })\n });\n }\n\n await entityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant: model.tenant\n });\n }\n}\n\nexport const DdbDeleteMultipleEntries = DeleteMultipleEntriesStorageOperation.createImplementation({\n implementation: DdbDeleteMultipleEntriesImpl,\n dependencies: [CmsDdbEntryEntity, CmsDdbDataLoaders, CmsStorageModelProvider]\n});\n"],"names":["DdbDeleteMultipleEntriesImpl","entity","dataLoaders","storageModelProvider","initialModel","params","entries","model","revisions","entityBatch","id","partitionKey","createPartitionKey","revision","createRevisionSortKey","DdbDeleteMultipleEntries","DeleteMultipleEntriesStorageOperation","CmsDdbEntryEntity","CmsDdbDataLoaders","CmsStorageModelProvider"],"mappings":";;;;;AAUA,MAAMA;IACF,YACYC,MAAmC,EACnCC,WAAwC,EACxCC,oBAAuD,CACjE;aAHUF,MAAM,GAANA;aACAC,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QAAQC,YAAsB,EAAEC,MAAoD,EAAE;QACxF,MAAM,EAAEC,OAAO,EAAE,GAAGD;QACpB,MAAME,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAACH;QAIjD,MAAMI,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC;YAC1DD;YACA,KAAKD;QACT;QAKA,MAAMG,cAAc,IAAI,CAAC,MAAM,CAAC,kBAAkB;QAElD,KAAK,MAAMC,MAAMJ,QAAS;YACtB,MAAMK,eAAeC,mBAAmB;gBACpCF;gBACA,QAAQH,MAAM,MAAM;YACxB;YACAE,YAAY,MAAM,CAAC;gBACf,IAAIE;gBACJ,IAAI;YACR;YACAF,YAAY,MAAM,CAAC;gBACf,IAAIE;gBACJ,IAAI;YACR;QACJ;QAIA,KAAK,MAAME,YAAYL,UACnBC,YAAY,MAAM,CAAC;YACf,IAAIG,mBAAmB;gBACnB,IAAIC,SAAS,EAAE;gBACf,QAAQN,MAAM,MAAM;YACxB;YACA,IAAIO,sBAAsB;gBACtB,SAASD,SAAS,OAAO;YAC7B;QACJ;QAGJ,MAAMJ,YAAY,OAAO;QAEzB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;YACtB,QAAQF,MAAM,MAAM;QACxB;IACJ;AACJ;AAEO,MAAMQ,2BAA2BC,sCAAsC,oBAAoB,CAAC;IAC/F,gBAAgBhB;IAChB,cAAc;QAACiB;QAAmBC;QAAmBC;KAAwB;AACjF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetByIdsParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetEntriesByIdsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js";
|
|
3
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
declare class DdbGetEntriesByIdsImpl implements GetEntriesByIdsStorageOperation.Interface {
|
|
6
|
+
private dataLoaders;
|
|
7
|
+
private storageModelProvider;
|
|
8
|
+
constructor(dataLoaders: CmsDdbDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
9
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetByIdsParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T>[]>;
|
|
10
|
+
}
|
|
11
|
+
export declare const DdbGetEntriesByIds: typeof DdbGetEntriesByIdsImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js").IGetEntriesByIdsStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GetEntriesByIdsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js";
|
|
2
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
3
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { convertFromStorageEntry } from "./storageEntryUtils.js";
|
|
5
|
+
class DdbGetEntriesByIdsImpl {
|
|
6
|
+
constructor(dataLoaders, storageModelProvider){
|
|
7
|
+
this.dataLoaders = dataLoaders;
|
|
8
|
+
this.storageModelProvider = storageModelProvider;
|
|
9
|
+
}
|
|
10
|
+
async execute(initialModel, params) {
|
|
11
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
12
|
+
const items = await this.dataLoaders.getRevisionById({
|
|
13
|
+
model,
|
|
14
|
+
ids: params.ids
|
|
15
|
+
});
|
|
16
|
+
return items.map((item)=>convertFromStorageEntry({
|
|
17
|
+
storageEntry: item,
|
|
18
|
+
model
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const DdbGetEntriesByIds = GetEntriesByIdsStorageOperation.createImplementation({
|
|
23
|
+
implementation: DdbGetEntriesByIdsImpl,
|
|
24
|
+
dependencies: [
|
|
25
|
+
CmsDdbDataLoaders,
|
|
26
|
+
CmsStorageModelProvider
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
export { DdbGetEntriesByIds };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=DdbGetEntriesByIds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbGetEntriesByIds.js","sources":["../../../src/operations/entry/DdbGetEntriesByIds.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsGetByIdsParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetEntriesByIdsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { convertFromStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbGetEntriesByIdsImpl implements GetEntriesByIdsStorageOperation.Interface {\n constructor(\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetByIdsParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const items = await this.dataLoaders.getRevisionById<T>({\n model,\n ids: params.ids\n });\n\n return items.map(item => {\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n });\n }\n}\n\nexport const DdbGetEntriesByIds = GetEntriesByIdsStorageOperation.createImplementation({\n implementation: DdbGetEntriesByIdsImpl,\n dependencies: [CmsDdbDataLoaders, CmsStorageModelProvider]\n});\n"],"names":["DdbGetEntriesByIdsImpl","dataLoaders","storageModelProvider","initialModel","params","model","items","item","convertFromStorageEntry","DdbGetEntriesByIds","GetEntriesByIdsStorageOperation","CmsDdbDataLoaders","CmsStorageModelProvider"],"mappings":";;;;AAUA,MAAMA;IACF,YACYC,WAAwC,EACxCC,oBAAuD,CACjE;aAFUD,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAA+C,EACjD;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIF;QAEpD,MAAMG,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,eAAe,CAAI;YACpDD;YACA,KAAKD,OAAO,GAAG;QACnB;QAEA,OAAOE,MAAM,GAAG,CAACC,CAAAA,OACNC,wBAAwB;gBAC3B,cAAcD;gBACdF;YACJ;IAER;AACJ;AAEO,MAAMI,qBAAqBC,gCAAgC,oBAAoB,CAAC;IACnF,gBAAgBV;IAChB,cAAc;QAACW;QAAmBC;KAAwB;AAC9D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetEntryStorageOperation.js";
|
|
3
|
+
import { ListEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
declare class DdbGetEntryImpl implements GetEntryStorageOperation.Interface {
|
|
6
|
+
private listEntries;
|
|
7
|
+
private storageModelProvider;
|
|
8
|
+
constructor(listEntries: ListEntriesStorageOperation.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
9
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetParams): Promise<import("@webiny/api-headless-cms/types/types").CmsEntry<T> | null>;
|
|
10
|
+
}
|
|
11
|
+
export declare const DdbGetEntry: typeof DdbGetEntryImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetEntryStorageOperation.js").IGetEntryStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GetEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetEntryStorageOperation.js";
|
|
2
|
+
import { ListEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js";
|
|
3
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
class DdbGetEntryImpl {
|
|
5
|
+
constructor(listEntries, storageModelProvider){
|
|
6
|
+
this.listEntries = listEntries;
|
|
7
|
+
this.storageModelProvider = storageModelProvider;
|
|
8
|
+
}
|
|
9
|
+
async execute(initialModel, params) {
|
|
10
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
11
|
+
const { items } = await this.listEntries.execute(model, {
|
|
12
|
+
...params,
|
|
13
|
+
limit: 1
|
|
14
|
+
});
|
|
15
|
+
return items.shift() || null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const DdbGetEntry = GetEntryStorageOperation.createImplementation({
|
|
19
|
+
implementation: DdbGetEntryImpl,
|
|
20
|
+
dependencies: [
|
|
21
|
+
ListEntriesStorageOperation,
|
|
22
|
+
CmsStorageModelProvider
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
export { DdbGetEntry };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=DdbGetEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbGetEntry.js","sources":["../../../src/operations/entry/DdbGetEntry.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsGetParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetEntryStorageOperation.js\";\nimport { ListEntriesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\n\nclass DdbGetEntryImpl implements GetEntryStorageOperation.Interface {\n constructor(\n private listEntries: ListEntriesStorageOperation.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetParams\n ) {\n const model = this.storageModelProvider.getModel(initialModel);\n\n const { items } = await this.listEntries.execute<T>(model, {\n ...params,\n limit: 1\n });\n return items.shift() || null;\n }\n}\n\nexport const DdbGetEntry = GetEntryStorageOperation.createImplementation({\n implementation: DdbGetEntryImpl,\n dependencies: [ListEntriesStorageOperation, CmsStorageModelProvider]\n});\n"],"names":["DdbGetEntryImpl","listEntries","storageModelProvider","initialModel","params","model","items","DdbGetEntry","GetEntryStorageOperation","ListEntriesStorageOperation","CmsStorageModelProvider"],"mappings":";;;AASA,MAAMA;IACF,YACYC,WAAkD,EAClDC,oBAAuD,CACjE;aAFUD,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAA0C,EAC5C;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAACF;QAEjD,MAAM,EAAEG,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAID,OAAO;YACvD,GAAGD,MAAM;YACT,OAAO;QACX;QACA,OAAOE,MAAM,KAAK,MAAM;IAC5B;AACJ;AAEO,MAAMC,cAAcC,yBAAyB,oBAAoB,CAAC;IACrE,gBAAgBR;IAChB,cAAc;QAACS;QAA6BC;KAAwB;AACxE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetLatestByIdsParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetLatestEntriesByIdsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js";
|
|
3
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
declare class DdbGetLatestEntriesByIdsImpl implements GetLatestEntriesByIdsStorageOperation.Interface {
|
|
6
|
+
private dataLoaders;
|
|
7
|
+
private storageModelProvider;
|
|
8
|
+
constructor(dataLoaders: CmsDdbDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
9
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetLatestByIdsParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T>[]>;
|
|
10
|
+
}
|
|
11
|
+
export declare const DdbGetLatestEntriesByIds: typeof DdbGetLatestEntriesByIdsImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js").IGetLatestEntriesByIdsStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GetLatestEntriesByIdsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js";
|
|
2
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
3
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { convertFromStorageEntry } from "./storageEntryUtils.js";
|
|
5
|
+
class DdbGetLatestEntriesByIdsImpl {
|
|
6
|
+
constructor(dataLoaders, storageModelProvider){
|
|
7
|
+
this.dataLoaders = dataLoaders;
|
|
8
|
+
this.storageModelProvider = storageModelProvider;
|
|
9
|
+
}
|
|
10
|
+
async execute(initialModel, params) {
|
|
11
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
12
|
+
const items = await this.dataLoaders.getLatestRevisionByEntryId({
|
|
13
|
+
model,
|
|
14
|
+
ids: params.ids
|
|
15
|
+
});
|
|
16
|
+
return items.map((item)=>convertFromStorageEntry({
|
|
17
|
+
storageEntry: item,
|
|
18
|
+
model
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const DdbGetLatestEntriesByIds = GetLatestEntriesByIdsStorageOperation.createImplementation({
|
|
23
|
+
implementation: DdbGetLatestEntriesByIdsImpl,
|
|
24
|
+
dependencies: [
|
|
25
|
+
CmsDdbDataLoaders,
|
|
26
|
+
CmsStorageModelProvider
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
export { DdbGetLatestEntriesByIds };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=DdbGetLatestEntriesByIds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbGetLatestEntriesByIds.js","sources":["../../../src/operations/entry/DdbGetLatestEntriesByIds.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsGetLatestByIdsParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetLatestEntriesByIdsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { convertFromStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbGetLatestEntriesByIdsImpl implements GetLatestEntriesByIdsStorageOperation.Interface {\n constructor(\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const items = await this.dataLoaders.getLatestRevisionByEntryId<T>({\n model,\n ids: params.ids\n });\n\n return items.map(item => {\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n });\n }\n}\n\nexport const DdbGetLatestEntriesByIds = GetLatestEntriesByIdsStorageOperation.createImplementation({\n implementation: DdbGetLatestEntriesByIdsImpl,\n dependencies: [CmsDdbDataLoaders, CmsStorageModelProvider]\n});\n"],"names":["DdbGetLatestEntriesByIdsImpl","dataLoaders","storageModelProvider","initialModel","params","model","items","item","convertFromStorageEntry","DdbGetLatestEntriesByIds","GetLatestEntriesByIdsStorageOperation","CmsDdbDataLoaders","CmsStorageModelProvider"],"mappings":";;;;AAUA,MAAMA;IACF,YACYC,WAAwC,EACxCC,oBAAuD,CACjE;aAFUD,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAAqD,EACvD;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIF;QAEpD,MAAMG,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAI;YAC/DD;YACA,KAAKD,OAAO,GAAG;QACnB;QAEA,OAAOE,MAAM,GAAG,CAACC,CAAAA,OACNC,wBAAwB;gBAC3B,cAAcD;gBACdF;YACJ;IAER;AACJ;AAEO,MAAMI,2BAA2BC,sCAAsC,oBAAoB,CAAC;IAC/F,gBAAgBV;IAChB,cAAc;QAACW;QAAmBC;KAAwB;AAC9D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetLatestRevisionParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetLatestRevisionByEntryIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js";
|
|
3
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
declare class DdbGetLatestRevisionByEntryIdImpl implements GetLatestRevisionByEntryIdStorageOperation.Interface {
|
|
6
|
+
private dataLoaders;
|
|
7
|
+
private storageModelProvider;
|
|
8
|
+
constructor(dataLoaders: CmsDdbDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
9
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetLatestRevisionParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T> | null>;
|
|
10
|
+
}
|
|
11
|
+
export declare const DdbGetLatestRevisionByEntryId: typeof DdbGetLatestRevisionByEntryIdImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js").IGetLatestRevisionByEntryIdStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GetLatestRevisionByEntryIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js";
|
|
2
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
3
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { convertFromStorageEntry } from "./storageEntryUtils.js";
|
|
5
|
+
class DdbGetLatestRevisionByEntryIdImpl {
|
|
6
|
+
constructor(dataLoaders, storageModelProvider){
|
|
7
|
+
this.dataLoaders = dataLoaders;
|
|
8
|
+
this.storageModelProvider = storageModelProvider;
|
|
9
|
+
}
|
|
10
|
+
async execute(initialModel, params) {
|
|
11
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
12
|
+
const items = await this.dataLoaders.getLatestRevisionByEntryId({
|
|
13
|
+
model,
|
|
14
|
+
ids: [
|
|
15
|
+
params.id
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
const item = items.shift() || null;
|
|
19
|
+
if (!item) return null;
|
|
20
|
+
return convertFromStorageEntry({
|
|
21
|
+
storageEntry: item,
|
|
22
|
+
model
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const DdbGetLatestRevisionByEntryId = GetLatestRevisionByEntryIdStorageOperation.createImplementation({
|
|
27
|
+
implementation: DdbGetLatestRevisionByEntryIdImpl,
|
|
28
|
+
dependencies: [
|
|
29
|
+
CmsDdbDataLoaders,
|
|
30
|
+
CmsStorageModelProvider
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
export { DdbGetLatestRevisionByEntryId };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=DdbGetLatestRevisionByEntryId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbGetLatestRevisionByEntryId.js","sources":["../../../src/operations/entry/DdbGetLatestRevisionByEntryId.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsGetLatestRevisionParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetLatestRevisionByEntryIdStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { convertFromStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbGetLatestRevisionByEntryIdImpl\n implements GetLatestRevisionByEntryIdStorageOperation.Interface\n{\n constructor(\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const items = await this.dataLoaders.getLatestRevisionByEntryId<T>({\n model,\n ids: [params.id]\n });\n const item = items.shift() || null;\n if (!item) {\n return null;\n }\n return convertFromStorageEntry({\n storageEntry: item,\n model\n });\n }\n}\n\nexport const DdbGetLatestRevisionByEntryId =\n GetLatestRevisionByEntryIdStorageOperation.createImplementation({\n implementation: DdbGetLatestRevisionByEntryIdImpl,\n dependencies: [CmsDdbDataLoaders, CmsStorageModelProvider]\n });\n"],"names":["DdbGetLatestRevisionByEntryIdImpl","dataLoaders","storageModelProvider","initialModel","params","model","items","item","convertFromStorageEntry","DdbGetLatestRevisionByEntryId","GetLatestRevisionByEntryIdStorageOperation","CmsDdbDataLoaders","CmsStorageModelProvider"],"mappings":";;;;AAUA,MAAMA;IAGF,YACYC,WAAwC,EACxCC,oBAAuD,CACjE;aAFUD,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAAwD,EAC1D;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIF;QAEpD,MAAMG,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAI;YAC/DD;YACA,KAAK;gBAACD,OAAO,EAAE;aAAC;QACpB;QACA,MAAMG,OAAOD,MAAM,KAAK,MAAM;QAC9B,IAAI,CAACC,MACD,OAAO;QAEX,OAAOC,wBAAwB;YAC3B,cAAcD;YACdF;QACJ;IACJ;AACJ;AAEO,MAAMI,gCACTC,2CAA2C,oBAAoB,CAAC;IAC5D,gBAAgBV;IAChB,cAAc;QAACW;QAAmBC;KAAwB;AAC9D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetPreviousRevisionParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetPreviousRevisionStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js";
|
|
3
|
+
import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
declare class DdbGetPreviousRevisionImpl implements GetPreviousRevisionStorageOperation.Interface {
|
|
6
|
+
private entity;
|
|
7
|
+
private storageModelProvider;
|
|
8
|
+
constructor(entity: CmsDdbEntryEntity.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
9
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetPreviousRevisionParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<import("@webiny/api/types.js").GenericRecord> | null>;
|
|
10
|
+
}
|
|
11
|
+
export declare const DdbGetPreviousRevision: typeof DdbGetPreviousRevisionImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js").IGetPreviousRevisionStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
import { GetPreviousRevisionStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js";
|
|
3
|
+
import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
import { createPartitionKey } from "./keys.js";
|
|
6
|
+
import { convertFromStorageEntry } from "./storageEntryUtils.js";
|
|
7
|
+
class DdbGetPreviousRevisionImpl {
|
|
8
|
+
constructor(entity, storageModelProvider){
|
|
9
|
+
this.entity = entity;
|
|
10
|
+
this.storageModelProvider = storageModelProvider;
|
|
11
|
+
}
|
|
12
|
+
async execute(initialModel, params) {
|
|
13
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
14
|
+
const { entryId, version } = params;
|
|
15
|
+
const partitionKey = createPartitionKey({
|
|
16
|
+
tenant: model.tenant,
|
|
17
|
+
id: entryId
|
|
18
|
+
});
|
|
19
|
+
const unfilteredRevisions = await this.entity.queryAll({
|
|
20
|
+
partitionKey,
|
|
21
|
+
options: {
|
|
22
|
+
beginsWith: "REV#",
|
|
23
|
+
reverse: true
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const filteredRevisions = unfilteredRevisions.filter((item)=>item.data.modelId === model.modelId && item.data.version < version);
|
|
27
|
+
const storageEntry = filteredRevisions[0];
|
|
28
|
+
if (!storageEntry) return null;
|
|
29
|
+
try {
|
|
30
|
+
return convertFromStorageEntry({
|
|
31
|
+
storageEntry: storageEntry.data,
|
|
32
|
+
model
|
|
33
|
+
});
|
|
34
|
+
} catch (ex) {
|
|
35
|
+
throw new error(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", {
|
|
36
|
+
...params,
|
|
37
|
+
error: ex,
|
|
38
|
+
partitionKey,
|
|
39
|
+
model
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const DdbGetPreviousRevision = GetPreviousRevisionStorageOperation.createImplementation({
|
|
45
|
+
implementation: DdbGetPreviousRevisionImpl,
|
|
46
|
+
dependencies: [
|
|
47
|
+
CmsDdbEntryEntity,
|
|
48
|
+
CmsStorageModelProvider
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
export { DdbGetPreviousRevision };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=DdbGetPreviousRevision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbGetPreviousRevision.js","sources":["../../../src/operations/entry/DdbGetPreviousRevision.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsGetPreviousRevisionParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetPreviousRevisionStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\nimport { convertFromStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbGetPreviousRevisionImpl implements GetPreviousRevisionStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEntryEntity.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const { entryId, version } = params;\n const partitionKey = createPartitionKey({\n tenant: model.tenant,\n id: entryId\n });\n\n const unfilteredRevisions = await this.entity.queryAll({\n partitionKey,\n options: {\n beginsWith: `REV#`,\n reverse: true\n }\n });\n /**\n * The partition key does not include the model, so filter by it as well.\n */\n const filteredRevisions = unfilteredRevisions.filter(item => {\n return item.data.modelId === model.modelId && item.data.version < version;\n });\n const storageEntry = filteredRevisions[0];\n if (!storageEntry) {\n return null;\n }\n\n try {\n return convertFromStorageEntry({\n storageEntry: storageEntry.data,\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get previous version of given entry.\",\n ex.code || \"GET_PREVIOUS_VERSION_ERROR\",\n {\n ...params,\n error: ex,\n partitionKey,\n model\n }\n );\n }\n }\n}\n\nexport const DdbGetPreviousRevision = GetPreviousRevisionStorageOperation.createImplementation({\n implementation: DdbGetPreviousRevisionImpl,\n dependencies: [CmsDdbEntryEntity, CmsStorageModelProvider]\n});\n"],"names":["DdbGetPreviousRevisionImpl","entity","storageModelProvider","initialModel","params","model","entryId","version","partitionKey","createPartitionKey","unfilteredRevisions","filteredRevisions","item","storageEntry","convertFromStorageEntry","ex","WebinyError","DdbGetPreviousRevision","GetPreviousRevisionStorageOperation","CmsDdbEntryEntity","CmsStorageModelProvider"],"mappings":";;;;;;AAYA,MAAMA;IACF,YACYC,MAAmC,EACnCC,oBAAuD,CACjE;aAFUD,MAAM,GAANA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAA0D,EAC5D;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIF;QAEpD,MAAM,EAAEG,OAAO,EAAEC,OAAO,EAAE,GAAGH;QAC7B,MAAMI,eAAeC,mBAAmB;YACpC,QAAQJ,MAAM,MAAM;YACpB,IAAIC;QACR;QAEA,MAAMI,sBAAsB,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YACnDF;YACA,SAAS;gBACL,YAAY;gBACZ,SAAS;YACb;QACJ;QAIA,MAAMG,oBAAoBD,oBAAoB,MAAM,CAACE,CAAAA,OAC1CA,KAAK,IAAI,CAAC,OAAO,KAAKP,MAAM,OAAO,IAAIO,KAAK,IAAI,CAAC,OAAO,GAAGL;QAEtE,MAAMM,eAAeF,iBAAiB,CAAC,EAAE;QACzC,IAAI,CAACE,cACD,OAAO;QAGX,IAAI;YACA,OAAOC,wBAAwB;gBAC3B,cAAcD,aAAa,IAAI;gBAC/BR;YACJ;QACJ,EAAE,OAAOU,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,kDACdA,GAAG,IAAI,IAAI,8BACX;gBACI,GAAGX,MAAM;gBACT,OAAOW;gBACPP;gBACAH;YACJ;QAER;IACJ;AACJ;AAEO,MAAMY,yBAAyBC,oCAAoC,oBAAoB,CAAC;IAC3F,gBAAgBlB;IAChB,cAAc;QAACmB;QAAmBC;KAAwB;AAC9D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetPublishedByIdsParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetPublishedEntriesByIdsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js";
|
|
3
|
+
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
declare class DdbGetPublishedEntriesByIdsImpl implements GetPublishedEntriesByIdsStorageOperation.Interface {
|
|
6
|
+
private dataLoaders;
|
|
7
|
+
private storageModelProvider;
|
|
8
|
+
constructor(dataLoaders: CmsDdbDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
9
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetPublishedByIdsParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T>[]>;
|
|
10
|
+
}
|
|
11
|
+
export declare const DdbGetPublishedEntriesByIds: typeof DdbGetPublishedEntriesByIdsImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js").IGetPublishedEntriesByIdsStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|