@webiny/api-headless-cms-ddb-es 6.6.0-alpha.12 → 6.6.0-alpha.14
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/feature.d.ts +4 -4
- package/feature.js +4 -60
- package/feature.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/operations/entry/DdbEsCreateEntry.d.ts +3 -1
- package/operations/entry/DdbEsCreateEntry.js +18 -8
- package/operations/entry/DdbEsCreateEntry.js.map +1 -1
- package/operations/entry/DdbEsCreateEntryRevisionFrom.d.ts +3 -1
- package/operations/entry/DdbEsCreateEntryRevisionFrom.js +23 -10
- package/operations/entry/DdbEsCreateEntryRevisionFrom.js.map +1 -1
- package/operations/entry/DdbEsDeleteEntry.d.ts +3 -3
- package/operations/entry/DdbEsDeleteEntry.js +7 -7
- package/operations/entry/DdbEsDeleteEntry.js.map +1 -1
- package/operations/entry/DdbEsDeleteEntryRevision.d.ts +3 -1
- package/operations/entry/DdbEsDeleteEntryRevision.js +27 -11
- package/operations/entry/DdbEsDeleteEntryRevision.js.map +1 -1
- package/operations/entry/DdbEsDeleteMultipleEntries.d.ts +3 -1
- package/operations/entry/DdbEsDeleteMultipleEntries.js +14 -7
- package/operations/entry/DdbEsDeleteMultipleEntries.js.map +1 -1
- package/operations/entry/DdbEsGetEntriesByIds.d.ts +3 -1
- package/operations/entry/DdbEsGetEntriesByIds.js +10 -3
- package/operations/entry/DdbEsGetEntriesByIds.js.map +1 -1
- package/operations/entry/DdbEsGetEntry.d.ts +3 -1
- package/operations/entry/DdbEsGetEntry.js +6 -2
- package/operations/entry/DdbEsGetEntry.js.map +1 -1
- package/operations/entry/DdbEsGetLatestEntriesByIds.d.ts +3 -1
- package/operations/entry/DdbEsGetLatestEntriesByIds.js +10 -3
- package/operations/entry/DdbEsGetLatestEntriesByIds.js.map +1 -1
- package/operations/entry/DdbEsGetLatestRevisionByEntryId.d.ts +3 -1
- package/operations/entry/DdbEsGetLatestRevisionByEntryId.js +10 -3
- package/operations/entry/DdbEsGetLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/DdbEsGetPreviousRevision.d.ts +3 -1
- package/operations/entry/DdbEsGetPreviousRevision.js +6 -3
- package/operations/entry/DdbEsGetPreviousRevision.js.map +1 -1
- package/operations/entry/DdbEsGetPublishedEntriesByIds.d.ts +3 -1
- package/operations/entry/DdbEsGetPublishedEntriesByIds.js +10 -3
- package/operations/entry/DdbEsGetPublishedEntriesByIds.js.map +1 -1
- package/operations/entry/DdbEsGetPublishedRevisionByEntryId.d.ts +3 -1
- package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js +10 -3
- package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/DdbEsGetRevisionById.d.ts +3 -1
- package/operations/entry/DdbEsGetRevisionById.js +10 -3
- package/operations/entry/DdbEsGetRevisionById.js.map +1 -1
- package/operations/entry/DdbEsGetRevisions.d.ts +3 -1
- package/operations/entry/DdbEsGetRevisions.js +10 -3
- package/operations/entry/DdbEsGetRevisions.js.map +1 -1
- package/operations/entry/DdbEsGetUniqueFieldValues.d.ts +3 -1
- package/operations/entry/DdbEsGetUniqueFieldValues.js +6 -2
- package/operations/entry/DdbEsGetUniqueFieldValues.js.map +1 -1
- package/operations/entry/DdbEsListEntries.d.ts +3 -1
- package/operations/entry/DdbEsListEntries.js +6 -2
- package/operations/entry/DdbEsListEntries.js.map +1 -1
- package/operations/entry/DdbEsMoveEntry.d.ts +3 -3
- package/operations/entry/DdbEsMoveEntry.js +8 -8
- package/operations/entry/DdbEsMoveEntry.js.map +1 -1
- package/operations/entry/DdbEsMoveToBin.d.ts +3 -1
- package/operations/entry/DdbEsMoveToBin.js +8 -4
- package/operations/entry/DdbEsMoveToBin.js.map +1 -1
- package/operations/entry/DdbEsPublishEntry.d.ts +3 -1
- package/operations/entry/DdbEsPublishEntry.js +31 -15
- package/operations/entry/DdbEsPublishEntry.js.map +1 -1
- package/operations/entry/DdbEsRestoreFromBin.d.ts +3 -1
- package/operations/entry/DdbEsRestoreFromBin.js +8 -4
- package/operations/entry/DdbEsRestoreFromBin.js.map +1 -1
- package/operations/entry/DdbEsUnpublishEntry.d.ts +3 -1
- package/operations/entry/DdbEsUnpublishEntry.js +22 -9
- package/operations/entry/DdbEsUnpublishEntry.js.map +1 -1
- package/operations/entry/DdbEsUpdateEntry.d.ts +3 -1
- package/operations/entry/DdbEsUpdateEntry.js +27 -11
- package/operations/entry/DdbEsUpdateEntry.js.map +1 -1
- package/operations/entry/keys.d.ts +7 -6
- package/operations/entry/keys.js +6 -6
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/DdbEsCreateGroup.d.ts +3 -1
- package/operations/group/DdbEsCreateGroup.js +14 -4
- package/operations/group/DdbEsCreateGroup.js.map +1 -1
- package/operations/group/DdbEsDeleteGroup.d.ts +3 -1
- package/operations/group/DdbEsDeleteGroup.js +10 -3
- package/operations/group/DdbEsDeleteGroup.js.map +1 -1
- package/operations/group/DdbEsGetGroup.d.ts +3 -1
- package/operations/group/DdbEsGetGroup.js +10 -3
- package/operations/group/DdbEsGetGroup.js.map +1 -1
- package/operations/group/DdbEsListGroups.d.ts +3 -1
- package/operations/group/DdbEsListGroups.js +9 -3
- package/operations/group/DdbEsListGroups.js.map +1 -1
- package/operations/group/DdbEsUpdateGroup.d.ts +3 -1
- package/operations/group/DdbEsUpdateGroup.js +14 -4
- package/operations/group/DdbEsUpdateGroup.js.map +1 -1
- package/operations/model/DdbEsCreateModel.d.ts +3 -1
- package/operations/model/DdbEsCreateModel.js +14 -4
- package/operations/model/DdbEsCreateModel.js.map +1 -1
- package/operations/model/DdbEsDeleteModel.d.ts +3 -1
- package/operations/model/DdbEsDeleteModel.js +10 -3
- package/operations/model/DdbEsDeleteModel.js.map +1 -1
- package/operations/model/DdbEsGetModel.d.ts +3 -1
- package/operations/model/DdbEsGetModel.js +10 -3
- package/operations/model/DdbEsGetModel.js.map +1 -1
- package/operations/model/DdbEsListModels.d.ts +4 -2
- package/operations/model/DdbEsListModels.js +10 -5
- package/operations/model/DdbEsListModels.js.map +1 -1
- package/operations/model/DdbEsUpdateModel.d.ts +3 -1
- package/operations/model/DdbEsUpdateModel.js +14 -4
- package/operations/model/DdbEsUpdateModel.js.map +1 -1
- package/package.json +26 -26
- package/registry/CmsEntitiesDbRegistryDecorator.d.ts +4 -4
- package/registry/CmsEntitiesDbRegistryDecorator.js.map +1 -1
- package/storageFeature.d.ts +12 -0
- package/storageFeature.js +25 -0
- package/storageFeature.js.map +1 -0
- package/tablesFeature.d.ts +8 -0
- package/tablesFeature.js +53 -0
- package/tablesFeature.js.map +1 -0
- package/types.js.map +1 -1
|
@@ -7,11 +7,12 @@ import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/share
|
|
|
7
7
|
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
8
8
|
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
9
9
|
import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
10
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
10
11
|
import { createTransformer } from "./transformations/index.js";
|
|
11
12
|
import { createEntryLatestKeys, createEntryRevisionKeys, createPartitionKey, createPublishedSortKey, createRevisionSortKey } from "./keys.js";
|
|
12
13
|
import { convertToStorageEntry } from "./storageEntryUtils.js";
|
|
13
14
|
class DdbEsDeleteEntryRevisionImpl {
|
|
14
|
-
constructor(entity, esEntity, dataLoaders, storageModelProvider, fieldIndexRegistry, compressionHandler, indexProvider, valuesModifiers){
|
|
15
|
+
constructor(entity, esEntity, dataLoaders, storageModelProvider, fieldIndexRegistry, compressionHandler, indexProvider, valuesModifiers, scopeTenant){
|
|
15
16
|
this.entity = entity;
|
|
16
17
|
this.esEntity = esEntity;
|
|
17
18
|
this.dataLoaders = dataLoaders;
|
|
@@ -20,20 +21,25 @@ class DdbEsDeleteEntryRevisionImpl {
|
|
|
20
21
|
this.compressionHandler = compressionHandler;
|
|
21
22
|
this.indexProvider = indexProvider;
|
|
22
23
|
this.valuesModifiers = valuesModifiers;
|
|
24
|
+
this.scopeTenant = scopeTenant;
|
|
23
25
|
}
|
|
24
26
|
async execute(initialModel, params) {
|
|
25
27
|
const { entry, latestEntry, latestStorageEntry: initialLatestStorageEntry } = params;
|
|
28
|
+
const tenant = this.scopeTenant.getId();
|
|
26
29
|
const model = this.storageModelProvider.getModel(initialModel);
|
|
27
30
|
const partitionKey = createPartitionKey({
|
|
28
31
|
id: entry.id,
|
|
29
|
-
tenant
|
|
32
|
+
tenant
|
|
30
33
|
});
|
|
31
34
|
const configurations = createConfigurations(this.indexProvider);
|
|
32
35
|
const { index } = await configurations.es({
|
|
33
36
|
model
|
|
34
37
|
});
|
|
35
38
|
const [publishedStorageEntry] = await this.dataLoaders.getPublishedRevisionByEntryId({
|
|
36
|
-
model
|
|
39
|
+
model: {
|
|
40
|
+
tenant,
|
|
41
|
+
modelId: model.modelId
|
|
42
|
+
},
|
|
37
43
|
ids: [
|
|
38
44
|
entry.id
|
|
39
45
|
]
|
|
@@ -59,15 +65,18 @@ class DdbEsDeleteEntryRevisionImpl {
|
|
|
59
65
|
}
|
|
60
66
|
if (latestEntry && initialLatestStorageEntry) {
|
|
61
67
|
const latestStorageEntry = convertToStorageEntry({
|
|
62
|
-
storageEntry:
|
|
68
|
+
storageEntry: {
|
|
69
|
+
...initialLatestStorageEntry,
|
|
70
|
+
tenant
|
|
71
|
+
},
|
|
63
72
|
model
|
|
64
73
|
});
|
|
65
|
-
const latestStorageEntryLatestKey = createEntryLatestKeys(latestStorageEntry);
|
|
74
|
+
const latestStorageEntryLatestKey = createEntryLatestKeys(latestStorageEntry, tenant);
|
|
66
75
|
entityBatch.put({
|
|
67
76
|
...latestStorageEntryLatestKey,
|
|
68
77
|
data: latestStorageEntry
|
|
69
78
|
});
|
|
70
|
-
const actualRevisionEntryKey = createEntryRevisionKeys(initialLatestStorageEntry);
|
|
79
|
+
const actualRevisionEntryKey = createEntryRevisionKeys(initialLatestStorageEntry, tenant);
|
|
71
80
|
entityBatch.put({
|
|
72
81
|
...actualRevisionEntryKey,
|
|
73
82
|
data: latestStorageEntry
|
|
@@ -75,13 +84,19 @@ class DdbEsDeleteEntryRevisionImpl {
|
|
|
75
84
|
const latestTransformer = createTransformer({
|
|
76
85
|
valuesModifiers: this.valuesModifiers,
|
|
77
86
|
model,
|
|
78
|
-
entry:
|
|
79
|
-
|
|
87
|
+
entry: {
|
|
88
|
+
...latestEntry,
|
|
89
|
+
tenant
|
|
90
|
+
},
|
|
91
|
+
storageEntry: {
|
|
92
|
+
...initialLatestStorageEntry,
|
|
93
|
+
tenant
|
|
94
|
+
},
|
|
80
95
|
fieldIndexRegistry: this.fieldIndexRegistry,
|
|
81
96
|
compressionHandler: this.compressionHandler
|
|
82
97
|
});
|
|
83
98
|
const esLatestData = await latestTransformer.getElasticsearchLatestEntryData();
|
|
84
|
-
const esLatestKeys = createEntryLatestKeys(latestEntry);
|
|
99
|
+
const esLatestKeys = createEntryLatestKeys(latestEntry, tenant);
|
|
85
100
|
elasticsearchEntityBatch.put({
|
|
86
101
|
...esLatestKeys,
|
|
87
102
|
index,
|
|
@@ -91,7 +106,7 @@ class DdbEsDeleteEntryRevisionImpl {
|
|
|
91
106
|
try {
|
|
92
107
|
await entityBatch.execute();
|
|
93
108
|
this.dataLoaders.clearAll({
|
|
94
|
-
tenant
|
|
109
|
+
tenant
|
|
95
110
|
});
|
|
96
111
|
} catch (ex) {
|
|
97
112
|
throw new error(ex.message || "Could not batch write entry records to DynamoDB table.", ex.code || "DELETE_REVISION_ERROR", {
|
|
@@ -128,7 +143,8 @@ const DdbEsDeleteEntryRevision = DeleteEntryRevisionStorageOperation.createImple
|
|
|
128
143
|
{
|
|
129
144
|
multiple: true
|
|
130
145
|
}
|
|
131
|
-
]
|
|
146
|
+
],
|
|
147
|
+
ScopeTenant
|
|
132
148
|
]
|
|
133
149
|
});
|
|
134
150
|
export { DdbEsDeleteEntryRevision };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbEsDeleteEntryRevision.js","sources":["../../../src/operations/entry/DdbEsDeleteEntryRevision.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 { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsEntryOpenSearchValuesModifier,\n CmsModelOpenSearchIndexProvider\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { createTransformer } from \"./transformations/index.js\";\nimport {\n createEntryLatestKeys,\n createEntryRevisionKeys,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys.js\";\nimport { convertToStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbEsDeleteEntryRevisionImpl implements DeleteEntryRevisionStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n private compressionHandler: CompressionHandler.Interface,\n private indexProvider: CmsModelOpenSearchIndexProvider.Interface,\n private valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams<T>\n ): Promise<void> {\n const { entry, latestEntry, latestStorageEntry: initialLatestStorageEntry } = params;\n const model = this.storageModelProvider.getModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n tenant: model.tenant\n });\n\n const configurations = createConfigurations(this.indexProvider);\n const { index } = await configurations.es({\n model\n });\n /**\n * We need published entry to delete it if necessary.\n */\n const [publishedStorageEntry] = await this.dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n /**\n * We need to delete all existing records of the given entry revision.\n */\n const entityBatch = this.entity.createEntityWriter({\n delete: [\n {\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n }\n ]\n });\n\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter();\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?.id === entry.id) {\n entityBatch.delete({\n PK: partitionKey,\n SK: createPublishedSortKey()\n });\n\n elasticsearchEntityBatch.delete({\n PK: partitionKey,\n SK: createPublishedSortKey()\n });\n }\n\n if (latestEntry && initialLatestStorageEntry) {\n const latestStorageEntry = convertToStorageEntry({\n storageEntry: initialLatestStorageEntry,\n model\n });\n\n /**\n * In the end we need to set the new latest entry.\n */\n const latestStorageEntryLatestKey = createEntryLatestKeys(latestStorageEntry);\n entityBatch.put({\n ...latestStorageEntryLatestKey,\n data: latestStorageEntry\n });\n\n /**\n * Also perform an update on the actual revision. This is needed\n * because of updates on the entry-level meta fields.\n */\n const actualRevisionEntryKey = createEntryRevisionKeys(initialLatestStorageEntry);\n entityBatch.put({\n ...actualRevisionEntryKey,\n data: latestStorageEntry\n });\n\n const latestTransformer = createTransformer({\n valuesModifiers: this.valuesModifiers,\n model,\n entry: latestEntry,\n storageEntry: initialLatestStorageEntry,\n fieldIndexRegistry: this.fieldIndexRegistry,\n compressionHandler: this.compressionHandler\n });\n\n const esLatestData = await latestTransformer.getElasticsearchLatestEntryData();\n\n const esLatestKeys = createEntryLatestKeys(latestEntry);\n elasticsearchEntityBatch.put({\n ...esLatestKeys,\n index,\n data: esLatestData\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(\n ex.message || \"Could not batch write entry records to DynamoDB table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n initialLatestStorageEntry\n }\n );\n }\n\n try {\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not batch write entry records to DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n initialLatestStorageEntry\n }\n );\n }\n }\n}\n\nexport const DdbEsDeleteEntryRevision = DeleteEntryRevisionStorageOperation.createImplementation({\n implementation: DdbEsDeleteEntryRevisionImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n CmsEntryOpenSearchFieldIndexRegistry,\n CompressionHandler,\n CmsModelOpenSearchIndexProvider,\n [CmsEntryOpenSearchValuesModifier, { multiple: true }]\n ]\n});\n"],"names":["DdbEsDeleteEntryRevisionImpl","entity","esEntity","dataLoaders","storageModelProvider","fieldIndexRegistry","compressionHandler","indexProvider","valuesModifiers","initialModel","params","entry","latestEntry","initialLatestStorageEntry","model","partitionKey","createPartitionKey","configurations","createConfigurations","index","publishedStorageEntry","entityBatch","createRevisionSortKey","elasticsearchEntityBatch","createPublishedSortKey","latestStorageEntry","convertToStorageEntry","latestStorageEntryLatestKey","createEntryLatestKeys","actualRevisionEntryKey","createEntryRevisionKeys","latestTransformer","createTransformer","esLatestData","esLatestKeys","ex","WebinyError","DdbEsDeleteEntryRevision","DeleteEntryRevisionStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler","CmsModelOpenSearchIndexProvider","CmsEntryOpenSearchValuesModifier"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsDeleteEntryRevision.js","sources":["../../../src/operations/entry/DdbEsDeleteEntryRevision.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 { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsEntryOpenSearchValuesModifier,\n CmsModelOpenSearchIndexProvider\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { createTransformer } from \"./transformations/index.js\";\nimport {\n createEntryLatestKeys,\n createEntryRevisionKeys,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys.js\";\nimport { convertToStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbEsDeleteEntryRevisionImpl implements DeleteEntryRevisionStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n private compressionHandler: CompressionHandler.Interface,\n private indexProvider: CmsModelOpenSearchIndexProvider.Interface,\n private valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[],\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams<T>\n ): Promise<void> {\n const { entry, latestEntry, latestStorageEntry: initialLatestStorageEntry } = params;\n const tenant = this.scopeTenant.getId();\n const model = this.storageModelProvider.getModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n tenant\n });\n\n const configurations = createConfigurations(this.indexProvider);\n const { index } = await configurations.es({\n model\n });\n /**\n * We need published entry to delete it if necessary.\n */\n const [publishedStorageEntry] = await this.dataLoaders.getPublishedRevisionByEntryId({\n model: { tenant, modelId: model.modelId },\n ids: [entry.id]\n });\n /**\n * We need to delete all existing records of the given entry revision.\n */\n const entityBatch = this.entity.createEntityWriter({\n delete: [\n {\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n }\n ]\n });\n\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter();\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?.id === entry.id) {\n entityBatch.delete({\n PK: partitionKey,\n SK: createPublishedSortKey()\n });\n\n elasticsearchEntityBatch.delete({\n PK: partitionKey,\n SK: createPublishedSortKey()\n });\n }\n\n if (latestEntry && initialLatestStorageEntry) {\n const latestStorageEntry = convertToStorageEntry({\n storageEntry: { ...initialLatestStorageEntry, tenant },\n model\n });\n\n /**\n * In the end we need to set the new latest entry.\n */\n const latestStorageEntryLatestKey = createEntryLatestKeys(latestStorageEntry, tenant);\n entityBatch.put({\n ...latestStorageEntryLatestKey,\n data: latestStorageEntry\n });\n\n /**\n * Also perform an update on the actual revision. This is needed\n * because of updates on the entry-level meta fields.\n */\n const actualRevisionEntryKey = createEntryRevisionKeys(\n initialLatestStorageEntry,\n tenant\n );\n entityBatch.put({\n ...actualRevisionEntryKey,\n data: latestStorageEntry\n });\n\n const latestTransformer = createTransformer({\n valuesModifiers: this.valuesModifiers,\n model,\n entry: { ...latestEntry, tenant },\n storageEntry: { ...initialLatestStorageEntry, tenant },\n fieldIndexRegistry: this.fieldIndexRegistry,\n compressionHandler: this.compressionHandler\n });\n\n const esLatestData = await latestTransformer.getElasticsearchLatestEntryData();\n\n const esLatestKeys = createEntryLatestKeys(latestEntry, tenant);\n elasticsearchEntityBatch.put({\n ...esLatestKeys,\n index,\n data: esLatestData\n });\n }\n\n try {\n await entityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write entry records to DynamoDB table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n initialLatestStorageEntry\n }\n );\n }\n\n try {\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not batch write entry records to DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n initialLatestStorageEntry\n }\n );\n }\n }\n}\n\nexport const DdbEsDeleteEntryRevision = DeleteEntryRevisionStorageOperation.createImplementation({\n implementation: DdbEsDeleteEntryRevisionImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n CmsEntryOpenSearchFieldIndexRegistry,\n CompressionHandler,\n CmsModelOpenSearchIndexProvider,\n [CmsEntryOpenSearchValuesModifier, { multiple: true }],\n ScopeTenant\n ]\n});\n"],"names":["DdbEsDeleteEntryRevisionImpl","entity","esEntity","dataLoaders","storageModelProvider","fieldIndexRegistry","compressionHandler","indexProvider","valuesModifiers","scopeTenant","initialModel","params","entry","latestEntry","initialLatestStorageEntry","tenant","model","partitionKey","createPartitionKey","configurations","createConfigurations","index","publishedStorageEntry","entityBatch","createRevisionSortKey","elasticsearchEntityBatch","createPublishedSortKey","latestStorageEntry","convertToStorageEntry","latestStorageEntryLatestKey","createEntryLatestKeys","actualRevisionEntryKey","createEntryRevisionKeys","latestTransformer","createTransformer","esLatestData","esLatestKeys","ex","WebinyError","DdbEsDeleteEntryRevision","DeleteEntryRevisionStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler","CmsModelOpenSearchIndexProvider","CmsEntryOpenSearchValuesModifier","ScopeTenant"],"mappings":"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"}
|
|
@@ -4,12 +4,14 @@ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
|
4
4
|
import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
|
|
5
5
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
6
6
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
7
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
7
8
|
declare class DdbEsDeleteMultipleEntriesImpl implements DeleteMultipleEntriesStorageOperation.Interface {
|
|
8
9
|
private entity;
|
|
9
10
|
private esEntity;
|
|
10
11
|
private dataLoaders;
|
|
11
12
|
private storageModelProvider;
|
|
12
|
-
|
|
13
|
+
private scopeTenant;
|
|
14
|
+
constructor(entity: CmsDdbEsEntryEntity.Interface, esEntity: CmsDdbEsEntriesEsEntity.Interface, dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, scopeTenant: ScopeTenant.Interface);
|
|
13
15
|
execute(initialModel: CmsModel, params: CmsEntryStorageOperationsDeleteEntriesParams): Promise<void>;
|
|
14
16
|
}
|
|
15
17
|
export declare const DdbEsDeleteMultipleEntries: typeof DdbEsDeleteMultipleEntriesImpl & {
|
|
@@ -3,25 +3,31 @@ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
|
3
3
|
import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
|
|
4
4
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
5
5
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
6
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
6
7
|
import { createPartitionKey, createRevisionSortKey } from "./keys.js";
|
|
7
8
|
class DdbEsDeleteMultipleEntriesImpl {
|
|
8
|
-
constructor(entity, esEntity, dataLoaders, storageModelProvider){
|
|
9
|
+
constructor(entity, esEntity, dataLoaders, storageModelProvider, scopeTenant){
|
|
9
10
|
this.entity = entity;
|
|
10
11
|
this.esEntity = esEntity;
|
|
11
12
|
this.dataLoaders = dataLoaders;
|
|
12
13
|
this.storageModelProvider = storageModelProvider;
|
|
14
|
+
this.scopeTenant = scopeTenant;
|
|
13
15
|
}
|
|
14
16
|
async execute(initialModel, params) {
|
|
15
17
|
const { entries } = params;
|
|
18
|
+
const tenant = this.scopeTenant.getId();
|
|
16
19
|
const model = this.storageModelProvider.getModel(initialModel);
|
|
17
20
|
const revisions = await this.dataLoaders.getAllEntryRevisions({
|
|
18
|
-
model
|
|
21
|
+
model: {
|
|
22
|
+
tenant,
|
|
23
|
+
modelId: model.modelId
|
|
24
|
+
},
|
|
19
25
|
ids: entries
|
|
20
26
|
});
|
|
21
27
|
const esItems = (await Promise.all(entries.map((id)=>this.esEntity.queryAll({
|
|
22
28
|
partitionKey: createPartitionKey({
|
|
23
29
|
id,
|
|
24
|
-
tenant
|
|
30
|
+
tenant
|
|
25
31
|
}),
|
|
26
32
|
options: {
|
|
27
33
|
gte: " "
|
|
@@ -37,7 +43,7 @@ class DdbEsDeleteMultipleEntriesImpl {
|
|
|
37
43
|
for (const id of entries){
|
|
38
44
|
const partitionKey = createPartitionKey({
|
|
39
45
|
id,
|
|
40
|
-
tenant
|
|
46
|
+
tenant
|
|
41
47
|
});
|
|
42
48
|
entityBatch.delete({
|
|
43
49
|
PK: partitionKey,
|
|
@@ -51,7 +57,7 @@ class DdbEsDeleteMultipleEntriesImpl {
|
|
|
51
57
|
for (const revision of revisions)entityBatch.delete({
|
|
52
58
|
PK: createPartitionKey({
|
|
53
59
|
id: revision.id,
|
|
54
|
-
tenant
|
|
60
|
+
tenant
|
|
55
61
|
}),
|
|
56
62
|
SK: createRevisionSortKey({
|
|
57
63
|
version: revision.version
|
|
@@ -60,7 +66,7 @@ class DdbEsDeleteMultipleEntriesImpl {
|
|
|
60
66
|
await entityBatch.execute();
|
|
61
67
|
await elasticsearchEntityBatch.execute();
|
|
62
68
|
this.dataLoaders.clearAll({
|
|
63
|
-
tenant
|
|
69
|
+
tenant
|
|
64
70
|
});
|
|
65
71
|
}
|
|
66
72
|
}
|
|
@@ -70,7 +76,8 @@ const DdbEsDeleteMultipleEntries = DeleteMultipleEntriesStorageOperation.createI
|
|
|
70
76
|
CmsDdbEsEntryEntity,
|
|
71
77
|
CmsDdbEsEntriesEsEntity,
|
|
72
78
|
CmsDdbEsDataLoaders,
|
|
73
|
-
CmsStorageModelProvider
|
|
79
|
+
CmsStorageModelProvider,
|
|
80
|
+
ScopeTenant
|
|
74
81
|
]
|
|
75
82
|
});
|
|
76
83
|
export { DdbEsDeleteMultipleEntries };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbEsDeleteMultipleEntries.js","sources":["../../../src/operations/entry/DdbEsDeleteMultipleEntries.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 { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { createPartitionKey, createRevisionSortKey } from \"./keys.js\";\n\nclass DdbEsDeleteMultipleEntriesImpl implements DeleteMultipleEntriesStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.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 * The Elasticsearch records that exist: an entry that was never published (or was\n * unpublished) has no published record, and deleting a missing record is an error in the\n * stream handling. As DdbEsDeleteEntry does, only the stored records are deleted.\n */\n const esItems = (\n await Promise.all(\n entries.map(id =>\n this.esEntity.queryAll({\n partitionKey: createPartitionKey({\n id,\n tenant
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsDeleteMultipleEntries.js","sources":["../../../src/operations/entry/DdbEsDeleteMultipleEntries.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 { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { createPartitionKey, createRevisionSortKey } from \"./keys.js\";\n\nclass DdbEsDeleteMultipleEntriesImpl implements DeleteMultipleEntriesStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute(initialModel: CmsModel, params: CmsEntryStorageOperationsDeleteEntriesParams) {\n const { entries } = params;\n const tenant = this.scopeTenant.getId();\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: { tenant, modelId: model.modelId },\n ids: entries\n });\n /**\n * The Elasticsearch records that exist: an entry that was never published (or was\n * unpublished) has no published record, and deleting a missing record is an error in the\n * stream handling. As DdbEsDeleteEntry does, only the stored records are deleted.\n */\n const esItems = (\n await Promise.all(\n entries.map(id =>\n this.esEntity.queryAll({\n partitionKey: createPartitionKey({\n id,\n tenant\n }),\n options: {\n gte: \" \"\n }\n })\n )\n )\n ).flat();\n\n const entityBatch = this.entity.createEntityWriter();\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter({\n delete: esItems.map(item => ({ PK: item.PK, SK: item.SK }))\n });\n for (const id of entries) {\n const partitionKey = createPartitionKey({\n id,\n tenant\n });\n /**\n * Latest and published items.\n */\n entityBatch.delete({ PK: partitionKey, SK: \"L\" });\n entityBatch.delete({ PK: partitionKey, SK: \"P\" });\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\n }),\n SK: createRevisionSortKey({\n version: revision.version\n })\n });\n }\n\n await entityBatch.execute();\n await elasticsearchEntityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant\n });\n }\n}\n\nexport const DdbEsDeleteMultipleEntries =\n DeleteMultipleEntriesStorageOperation.createImplementation({\n implementation: DdbEsDeleteMultipleEntriesImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n ScopeTenant\n ]\n });\n"],"names":["DdbEsDeleteMultipleEntriesImpl","entity","esEntity","dataLoaders","storageModelProvider","scopeTenant","initialModel","params","entries","tenant","model","revisions","esItems","Promise","id","createPartitionKey","entityBatch","elasticsearchEntityBatch","item","partitionKey","revision","createRevisionSortKey","DdbEsDeleteMultipleEntries","DeleteMultipleEntriesStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","ScopeTenant"],"mappings":";;;;;;;AAYA,MAAMA;IACF,YACYC,MAAqC,EACrCC,QAA2C,EAC3CC,WAA0C,EAC1CC,oBAAuD,EACvDC,WAAkC,CAC5C;aALUJ,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAC,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QAAQC,YAAsB,EAAEC,MAAoD,EAAE;QACxF,MAAM,EAAEC,OAAO,EAAE,GAAGD;QACpB,MAAME,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK;QACrC,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAACJ;QAIjD,MAAMK,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC;YAC1D,OAAO;gBAAEF;gBAAQ,SAASC,MAAM,OAAO;YAAC;YACxC,KAAKF;QACT;QAMA,MAAMI,UACF,OAAMC,QAAQ,GAAG,CACbL,QAAQ,GAAG,CAACM,CAAAA,KACR,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACnB,cAAcC,mBAAmB;oBAC7BD;oBACAL;gBACJ;gBACA,SAAS;oBACL,KAAK;gBACT;YACJ,MAGV,IAAI;QAEN,MAAMO,cAAc,IAAI,CAAC,MAAM,CAAC,kBAAkB;QAClD,MAAMC,2BAA2B,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC;YAC9D,QAAQL,QAAQ,GAAG,CAACM,CAAAA,OAAS;oBAAE,IAAIA,KAAK,EAAE;oBAAE,IAAIA,KAAK,EAAE;gBAAC;QAC5D;QACA,KAAK,MAAMJ,MAAMN,QAAS;YACtB,MAAMW,eAAeJ,mBAAmB;gBACpCD;gBACAL;YACJ;YAIAO,YAAY,MAAM,CAAC;gBAAE,IAAIG;gBAAc,IAAI;YAAI;YAC/CH,YAAY,MAAM,CAAC;gBAAE,IAAIG;gBAAc,IAAI;YAAI;QACnD;QAIA,KAAK,MAAMC,YAAYT,UACnBK,YAAY,MAAM,CAAC;YACf,IAAID,mBAAmB;gBACnB,IAAIK,SAAS,EAAE;gBACfX;YACJ;YACA,IAAIY,sBAAsB;gBACtB,SAASD,SAAS,OAAO;YAC7B;QACJ;QAGJ,MAAMJ,YAAY,OAAO;QACzB,MAAMC,yBAAyB,OAAO;QAEtC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;YACtBR;QACJ;IACJ;AACJ;AAEO,MAAMa,6BACTC,sCAAsC,oBAAoB,CAAC;IACvD,gBAAgBvB;IAChB,cAAc;QACVwB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -2,10 +2,12 @@ import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetByIdsParams
|
|
|
2
2
|
import { GetEntriesByIdsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
4
4
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
5
6
|
declare class DdbEsGetEntriesByIdsImpl implements GetEntriesByIdsStorageOperation.Interface {
|
|
6
7
|
private dataLoaders;
|
|
7
8
|
private storageModelProvider;
|
|
8
|
-
|
|
9
|
+
private scopeTenant;
|
|
10
|
+
constructor(dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, scopeTenant: ScopeTenant.Interface);
|
|
9
11
|
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetByIdsParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T>[]>;
|
|
10
12
|
}
|
|
11
13
|
export declare const DdbEsGetEntriesByIds: typeof DdbEsGetEntriesByIdsImpl & {
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { GetEntriesByIdsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js";
|
|
2
2
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
3
3
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
|
|
5
6
|
class DdbEsGetEntriesByIdsImpl {
|
|
6
|
-
constructor(dataLoaders, storageModelProvider){
|
|
7
|
+
constructor(dataLoaders, storageModelProvider, scopeTenant){
|
|
7
8
|
this.dataLoaders = dataLoaders;
|
|
8
9
|
this.storageModelProvider = storageModelProvider;
|
|
10
|
+
this.scopeTenant = scopeTenant;
|
|
9
11
|
}
|
|
10
12
|
async execute(initialModel, params) {
|
|
13
|
+
const tenant = this.scopeTenant.getId();
|
|
11
14
|
const model = this.storageModelProvider.getModel(initialModel);
|
|
12
15
|
const entries = await this.dataLoaders.getRevisionById({
|
|
13
|
-
model
|
|
16
|
+
model: {
|
|
17
|
+
tenant,
|
|
18
|
+
modelId: model.modelId
|
|
19
|
+
},
|
|
14
20
|
ids: params.ids
|
|
15
21
|
});
|
|
16
22
|
return entries.map((entry)=>convertEntryKeysFromStorage({
|
|
@@ -23,7 +29,8 @@ const DdbEsGetEntriesByIds = GetEntriesByIdsStorageOperation.createImplementatio
|
|
|
23
29
|
implementation: DdbEsGetEntriesByIdsImpl,
|
|
24
30
|
dependencies: [
|
|
25
31
|
CmsDdbEsDataLoaders,
|
|
26
|
-
CmsStorageModelProvider
|
|
32
|
+
CmsStorageModelProvider,
|
|
33
|
+
ScopeTenant
|
|
27
34
|
]
|
|
28
35
|
});
|
|
29
36
|
export { DdbEsGetEntriesByIds };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbEsGetEntriesByIds.js","sources":["../../../src/operations/entry/DdbEsGetEntriesByIds.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 { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys.js\";\n\nclass DdbEsGetEntriesByIdsImpl implements GetEntriesByIdsStorageOperation.Interface {\n constructor(\n private dataLoaders: CmsDdbEsDataLoaders.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 entries = await this.dataLoaders.getRevisionById<T>({\n model,\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage<T>({\n model,\n entry\n });\n });\n }\n}\n\nexport const DdbEsGetEntriesByIds = GetEntriesByIdsStorageOperation.createImplementation({\n implementation: DdbEsGetEntriesByIdsImpl,\n dependencies: [CmsDdbEsDataLoaders, CmsStorageModelProvider]\n});\n"],"names":["DdbEsGetEntriesByIdsImpl","dataLoaders","storageModelProvider","initialModel","params","model","entries","entry","convertEntryKeysFromStorage","DdbEsGetEntriesByIds","GetEntriesByIdsStorageOperation","CmsDdbEsDataLoaders","CmsStorageModelProvider"],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsGetEntriesByIds.js","sources":["../../../src/operations/entry/DdbEsGetEntriesByIds.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 { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys.js\";\n\nclass DdbEsGetEntriesByIdsImpl implements GetEntriesByIdsStorageOperation.Interface {\n constructor(\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetByIdsParams\n ) {\n const tenant = this.scopeTenant.getId();\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const entries = await this.dataLoaders.getRevisionById<T>({\n model: { tenant, modelId: model.modelId },\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage<T>({\n model,\n entry\n });\n });\n }\n}\n\nexport const DdbEsGetEntriesByIds = GetEntriesByIdsStorageOperation.createImplementation({\n implementation: DdbEsGetEntriesByIdsImpl,\n dependencies: [CmsDdbEsDataLoaders, CmsStorageModelProvider, ScopeTenant]\n});\n"],"names":["DdbEsGetEntriesByIdsImpl","dataLoaders","storageModelProvider","scopeTenant","initialModel","params","tenant","model","entries","entry","convertEntryKeysFromStorage","DdbEsGetEntriesByIds","GetEntriesByIdsStorageOperation","CmsDdbEsDataLoaders","CmsStorageModelProvider","ScopeTenant"],"mappings":";;;;;AAWA,MAAMA;IACF,YACYC,WAA0C,EAC1CC,oBAAuD,EACvDC,WAAkC,CAC5C;aAHUF,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAA+C,EACjD;QACE,MAAMC,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK;QACrC,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIH;QAEpD,MAAMI,UAAU,MAAM,IAAI,CAAC,WAAW,CAAC,eAAe,CAAI;YACtD,OAAO;gBAAEF;gBAAQ,SAASC,MAAM,OAAO;YAAC;YACxC,KAAKF,OAAO,GAAG;QACnB;QAEA,OAAOG,QAAQ,GAAG,CAACC,CAAAA,QACRC,4BAA+B;gBAClCH;gBACAE;YACJ;IAER;AACJ;AAEO,MAAME,uBAAuBC,gCAAgC,oBAAoB,CAAC;IACrF,gBAAgBZ;IAChB,cAAc;QAACa;QAAqBC;QAAyBC;KAAY;AAC7E"}
|
|
@@ -2,10 +2,12 @@ import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetParams } fro
|
|
|
2
2
|
import { GetEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetEntryStorageOperation.js";
|
|
3
3
|
import { ListEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js";
|
|
4
4
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
5
6
|
declare class DdbEsGetEntryImpl implements GetEntryStorageOperation.Interface {
|
|
6
7
|
private listEntries;
|
|
7
8
|
private storageModelProvider;
|
|
8
|
-
|
|
9
|
+
private scopeTenant;
|
|
10
|
+
constructor(listEntries: ListEntriesStorageOperation.Interface, storageModelProvider: CmsStorageModelProvider.Interface, scopeTenant: ScopeTenant.Interface);
|
|
9
11
|
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetParams): Promise<import("@webiny/api-headless-cms/types/types").CmsEntry<T> | null>;
|
|
10
12
|
}
|
|
11
13
|
export declare const DdbEsGetEntry: typeof DdbEsGetEntryImpl & {
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { GetEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetEntryStorageOperation.js";
|
|
2
2
|
import { ListEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js";
|
|
3
3
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
class DdbEsGetEntryImpl {
|
|
5
|
-
constructor(listEntries, storageModelProvider){
|
|
6
|
+
constructor(listEntries, storageModelProvider, scopeTenant){
|
|
6
7
|
this.listEntries = listEntries;
|
|
7
8
|
this.storageModelProvider = storageModelProvider;
|
|
9
|
+
this.scopeTenant = scopeTenant;
|
|
8
10
|
}
|
|
9
11
|
async execute(initialModel, params) {
|
|
12
|
+
this.scopeTenant.getId();
|
|
10
13
|
const model = this.storageModelProvider.getModel(initialModel);
|
|
11
14
|
const { items } = await this.listEntries.execute(model, {
|
|
12
15
|
...params,
|
|
@@ -19,7 +22,8 @@ const DdbEsGetEntry = GetEntryStorageOperation.createImplementation({
|
|
|
19
22
|
implementation: DdbEsGetEntryImpl,
|
|
20
23
|
dependencies: [
|
|
21
24
|
ListEntriesStorageOperation,
|
|
22
|
-
CmsStorageModelProvider
|
|
25
|
+
CmsStorageModelProvider,
|
|
26
|
+
ScopeTenant
|
|
23
27
|
]
|
|
24
28
|
});
|
|
25
29
|
export { DdbEsGetEntry };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbEsGetEntry.js","sources":["../../../src/operations/entry/DdbEsGetEntry.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 DdbEsGetEntryImpl 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 DdbEsGetEntry = GetEntryStorageOperation.createImplementation({\n implementation: DdbEsGetEntryImpl,\n dependencies: [ListEntriesStorageOperation, CmsStorageModelProvider]\n});\n"],"names":["DdbEsGetEntryImpl","listEntries","storageModelProvider","initialModel","params","model","items","DdbEsGetEntry","GetEntryStorageOperation","ListEntriesStorageOperation","CmsStorageModelProvider"],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsGetEntry.js","sources":["../../../src/operations/entry/DdbEsGetEntry.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\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\n\nclass DdbEsGetEntryImpl implements GetEntryStorageOperation.Interface {\n constructor(\n private listEntries: ListEntriesStorageOperation.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetParams\n ) {\n /**\n * Only checked here: the listing reads with the scope's tenant itself.\n */\n this.scopeTenant.getId();\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 DdbEsGetEntry = GetEntryStorageOperation.createImplementation({\n implementation: DdbEsGetEntryImpl,\n dependencies: [ListEntriesStorageOperation, CmsStorageModelProvider, ScopeTenant]\n});\n"],"names":["DdbEsGetEntryImpl","listEntries","storageModelProvider","scopeTenant","initialModel","params","model","items","DdbEsGetEntry","GetEntryStorageOperation","ListEntriesStorageOperation","CmsStorageModelProvider","ScopeTenant"],"mappings":";;;;AAUA,MAAMA;IACF,YACYC,WAAkD,EAClDC,oBAAuD,EACvDC,WAAkC,CAC5C;aAHUF,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAA0C,EAC5C;QAIE,IAAI,CAAC,WAAW,CAAC,KAAK;QACtB,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,gBAAgBC,yBAAyB,oBAAoB,CAAC;IACvE,gBAAgBT;IAChB,cAAc;QAACU;QAA6BC;QAAyBC;KAAY;AACrF"}
|
|
@@ -2,10 +2,12 @@ import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetLatestByIdsP
|
|
|
2
2
|
import { GetLatestEntriesByIdsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
4
4
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
5
6
|
declare class DdbEsGetLatestEntriesByIdsImpl implements GetLatestEntriesByIdsStorageOperation.Interface {
|
|
6
7
|
private dataLoaders;
|
|
7
8
|
private storageModelProvider;
|
|
8
|
-
|
|
9
|
+
private scopeTenant;
|
|
10
|
+
constructor(dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, scopeTenant: ScopeTenant.Interface);
|
|
9
11
|
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetLatestByIdsParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T>[]>;
|
|
10
12
|
}
|
|
11
13
|
export declare const DdbEsGetLatestEntriesByIds: typeof DdbEsGetLatestEntriesByIdsImpl & {
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { GetLatestEntriesByIdsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js";
|
|
2
2
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
3
3
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
|
|
5
6
|
class DdbEsGetLatestEntriesByIdsImpl {
|
|
6
|
-
constructor(dataLoaders, storageModelProvider){
|
|
7
|
+
constructor(dataLoaders, storageModelProvider, scopeTenant){
|
|
7
8
|
this.dataLoaders = dataLoaders;
|
|
8
9
|
this.storageModelProvider = storageModelProvider;
|
|
10
|
+
this.scopeTenant = scopeTenant;
|
|
9
11
|
}
|
|
10
12
|
async execute(initialModel, params) {
|
|
13
|
+
const tenant = this.scopeTenant.getId();
|
|
11
14
|
const model = this.storageModelProvider.getModel(initialModel);
|
|
12
15
|
const entries = await this.dataLoaders.getLatestRevisionByEntryId({
|
|
13
|
-
model
|
|
16
|
+
model: {
|
|
17
|
+
tenant,
|
|
18
|
+
modelId: model.modelId
|
|
19
|
+
},
|
|
14
20
|
ids: params.ids
|
|
15
21
|
});
|
|
16
22
|
return entries.map((entry)=>convertEntryKeysFromStorage({
|
|
@@ -23,7 +29,8 @@ const DdbEsGetLatestEntriesByIds = GetLatestEntriesByIdsStorageOperation.createI
|
|
|
23
29
|
implementation: DdbEsGetLatestEntriesByIdsImpl,
|
|
24
30
|
dependencies: [
|
|
25
31
|
CmsDdbEsDataLoaders,
|
|
26
|
-
CmsStorageModelProvider
|
|
32
|
+
CmsStorageModelProvider,
|
|
33
|
+
ScopeTenant
|
|
27
34
|
]
|
|
28
35
|
});
|
|
29
36
|
export { DdbEsGetLatestEntriesByIds };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbEsGetLatestEntriesByIds.js","sources":["../../../src/operations/entry/DdbEsGetLatestEntriesByIds.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 { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys.js\";\n\nclass DdbEsGetLatestEntriesByIdsImpl implements GetLatestEntriesByIdsStorageOperation.Interface {\n constructor(\n private dataLoaders: CmsDdbEsDataLoaders.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 entries = await this.dataLoaders.getLatestRevisionByEntryId<T>({\n model,\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage<T>({\n model,\n entry\n });\n });\n }\n}\n\nexport const DdbEsGetLatestEntriesByIds =\n GetLatestEntriesByIdsStorageOperation.createImplementation({\n implementation: DdbEsGetLatestEntriesByIdsImpl,\n dependencies: [CmsDdbEsDataLoaders, CmsStorageModelProvider]\n });\n"],"names":["DdbEsGetLatestEntriesByIdsImpl","dataLoaders","storageModelProvider","initialModel","params","model","entries","entry","convertEntryKeysFromStorage","DdbEsGetLatestEntriesByIds","GetLatestEntriesByIdsStorageOperation","CmsDdbEsDataLoaders","CmsStorageModelProvider"],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsGetLatestEntriesByIds.js","sources":["../../../src/operations/entry/DdbEsGetLatestEntriesByIds.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 { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys.js\";\n\nclass DdbEsGetLatestEntriesByIdsImpl implements GetLatestEntriesByIdsStorageOperation.Interface {\n constructor(\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) {\n const tenant = this.scopeTenant.getId();\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const entries = await this.dataLoaders.getLatestRevisionByEntryId<T>({\n model: { tenant, modelId: model.modelId },\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage<T>({\n model,\n entry\n });\n });\n }\n}\n\nexport const DdbEsGetLatestEntriesByIds =\n GetLatestEntriesByIdsStorageOperation.createImplementation({\n implementation: DdbEsGetLatestEntriesByIdsImpl,\n dependencies: [CmsDdbEsDataLoaders, CmsStorageModelProvider, ScopeTenant]\n });\n"],"names":["DdbEsGetLatestEntriesByIdsImpl","dataLoaders","storageModelProvider","scopeTenant","initialModel","params","tenant","model","entries","entry","convertEntryKeysFromStorage","DdbEsGetLatestEntriesByIds","GetLatestEntriesByIdsStorageOperation","CmsDdbEsDataLoaders","CmsStorageModelProvider","ScopeTenant"],"mappings":";;;;;AAWA,MAAMA;IACF,YACYC,WAA0C,EAC1CC,oBAAuD,EACvDC,WAAkC,CAC5C;aAHUF,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAAqD,EACvD;QACE,MAAMC,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK;QACrC,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIH;QAEpD,MAAMI,UAAU,MAAM,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAI;YACjE,OAAO;gBAAEF;gBAAQ,SAASC,MAAM,OAAO;YAAC;YACxC,KAAKF,OAAO,GAAG;QACnB;QAEA,OAAOG,QAAQ,GAAG,CAACC,CAAAA,QACRC,4BAA+B;gBAClCH;gBACAE;YACJ;IAER;AACJ;AAEO,MAAME,6BACTC,sCAAsC,oBAAoB,CAAC;IACvD,gBAAgBZ;IAChB,cAAc;QAACa;QAAqBC;QAAyBC;KAAY;AAC7E"}
|
|
@@ -2,10 +2,12 @@ import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetLatestRevisi
|
|
|
2
2
|
import { GetLatestRevisionByEntryIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
4
4
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
5
6
|
declare class DdbEsGetLatestRevisionByEntryIdImpl implements GetLatestRevisionByEntryIdStorageOperation.Interface {
|
|
6
7
|
private dataLoaders;
|
|
7
8
|
private storageModelProvider;
|
|
8
|
-
|
|
9
|
+
private scopeTenant;
|
|
10
|
+
constructor(dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, scopeTenant: ScopeTenant.Interface);
|
|
9
11
|
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetLatestRevisionParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T> | null>;
|
|
10
12
|
}
|
|
11
13
|
export declare const DdbEsGetLatestRevisionByEntryId: typeof DdbEsGetLatestRevisionByEntryIdImpl & {
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { GetLatestRevisionByEntryIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js";
|
|
2
2
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
3
3
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
|
|
5
6
|
class DdbEsGetLatestRevisionByEntryIdImpl {
|
|
6
|
-
constructor(dataLoaders, storageModelProvider){
|
|
7
|
+
constructor(dataLoaders, storageModelProvider, scopeTenant){
|
|
7
8
|
this.dataLoaders = dataLoaders;
|
|
8
9
|
this.storageModelProvider = storageModelProvider;
|
|
10
|
+
this.scopeTenant = scopeTenant;
|
|
9
11
|
}
|
|
10
12
|
async execute(initialModel, params) {
|
|
13
|
+
const tenant = this.scopeTenant.getId();
|
|
11
14
|
const model = this.storageModelProvider.getModel(initialModel);
|
|
12
15
|
const [entry] = await this.dataLoaders.getLatestRevisionByEntryId({
|
|
13
|
-
model
|
|
16
|
+
model: {
|
|
17
|
+
tenant,
|
|
18
|
+
modelId: model.modelId
|
|
19
|
+
},
|
|
14
20
|
ids: [
|
|
15
21
|
params.id
|
|
16
22
|
]
|
|
@@ -26,7 +32,8 @@ const DdbEsGetLatestRevisionByEntryId = GetLatestRevisionByEntryIdStorageOperati
|
|
|
26
32
|
implementation: DdbEsGetLatestRevisionByEntryIdImpl,
|
|
27
33
|
dependencies: [
|
|
28
34
|
CmsDdbEsDataLoaders,
|
|
29
|
-
CmsStorageModelProvider
|
|
35
|
+
CmsStorageModelProvider,
|
|
36
|
+
ScopeTenant
|
|
30
37
|
]
|
|
31
38
|
});
|
|
32
39
|
export { DdbEsGetLatestRevisionByEntryId };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbEsGetLatestRevisionByEntryId.js","sources":["../../../src/operations/entry/DdbEsGetLatestRevisionByEntryId.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 { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys.js\";\n\nclass DdbEsGetLatestRevisionByEntryIdImpl\n implements GetLatestRevisionByEntryIdStorageOperation.Interface\n{\n constructor(\n private dataLoaders: CmsDdbEsDataLoaders.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 [entry] = await this.dataLoaders.getLatestRevisionByEntryId<T>({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage<T>({\n model,\n entry\n });\n }\n}\n\nexport const DdbEsGetLatestRevisionByEntryId =\n GetLatestRevisionByEntryIdStorageOperation.createImplementation({\n implementation: DdbEsGetLatestRevisionByEntryIdImpl,\n dependencies: [CmsDdbEsDataLoaders, CmsStorageModelProvider]\n });\n"],"names":["DdbEsGetLatestRevisionByEntryIdImpl","dataLoaders","storageModelProvider","initialModel","params","model","entry","convertEntryKeysFromStorage","DdbEsGetLatestRevisionByEntryId","GetLatestRevisionByEntryIdStorageOperation","CmsDdbEsDataLoaders","CmsStorageModelProvider"],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsGetLatestRevisionByEntryId.js","sources":["../../../src/operations/entry/DdbEsGetLatestRevisionByEntryId.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 { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys.js\";\n\nclass DdbEsGetLatestRevisionByEntryIdImpl\n implements GetLatestRevisionByEntryIdStorageOperation.Interface\n{\n constructor(\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) {\n const tenant = this.scopeTenant.getId();\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const [entry] = await this.dataLoaders.getLatestRevisionByEntryId<T>({\n model: { tenant, modelId: model.modelId },\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage<T>({\n model,\n entry\n });\n }\n}\n\nexport const DdbEsGetLatestRevisionByEntryId =\n GetLatestRevisionByEntryIdStorageOperation.createImplementation({\n implementation: DdbEsGetLatestRevisionByEntryIdImpl,\n dependencies: [CmsDdbEsDataLoaders, CmsStorageModelProvider, ScopeTenant]\n });\n"],"names":["DdbEsGetLatestRevisionByEntryIdImpl","dataLoaders","storageModelProvider","scopeTenant","initialModel","params","tenant","model","entry","convertEntryKeysFromStorage","DdbEsGetLatestRevisionByEntryId","GetLatestRevisionByEntryIdStorageOperation","CmsDdbEsDataLoaders","CmsStorageModelProvider","ScopeTenant"],"mappings":";;;;;AAWA,MAAMA;IAGF,YACYC,WAA0C,EAC1CC,oBAAuD,EACvDC,WAAkC,CAC5C;aAHUF,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAAwD,EAC1D;QACE,MAAMC,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK;QACrC,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIH;QAEpD,MAAM,CAACI,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAI;YACjE,OAAO;gBAAEF;gBAAQ,SAASC,MAAM,OAAO;YAAC;YACxC,KAAK;gBAACF,OAAO,EAAE;aAAC;QACpB;QACA,IAAI,CAACG,OACD,OAAO;QAEX,OAAOC,4BAA+B;YAClCF;YACAC;QACJ;IACJ;AACJ;AAEO,MAAME,kCACTC,2CAA2C,oBAAoB,CAAC;IAC5D,gBAAgBX;IAChB,cAAc;QAACY;QAAqBC;QAAyBC;KAAY;AAC7E"}
|
|
@@ -2,10 +2,12 @@ import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetPreviousRevi
|
|
|
2
2
|
import { GetPreviousRevisionStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
4
4
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
5
6
|
declare class DdbEsGetPreviousRevisionImpl implements GetPreviousRevisionStorageOperation.Interface {
|
|
6
7
|
private entity;
|
|
7
8
|
private storageModelProvider;
|
|
8
|
-
|
|
9
|
+
private scopeTenant;
|
|
10
|
+
constructor(entity: CmsDdbEsEntryEntity.Interface, storageModelProvider: CmsStorageModelProvider.Interface, scopeTenant: ScopeTenant.Interface);
|
|
9
11
|
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetPreviousRevisionParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T> | null>;
|
|
10
12
|
}
|
|
11
13
|
export declare const DdbEsGetPreviousRevision: typeof DdbEsGetPreviousRevisionImpl & {
|
|
@@ -3,15 +3,17 @@ import { GetPreviousRevisionStorageOperation } from "@webiny/api-headless-cms/fe
|
|
|
3
3
|
import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
4
4
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
5
|
import { createPartitionKey } from "./keys.js";
|
|
6
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
6
7
|
import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
|
|
7
8
|
class DdbEsGetPreviousRevisionImpl {
|
|
8
|
-
constructor(entity, storageModelProvider){
|
|
9
|
+
constructor(entity, storageModelProvider, scopeTenant){
|
|
9
10
|
this.entity = entity;
|
|
10
11
|
this.storageModelProvider = storageModelProvider;
|
|
12
|
+
this.scopeTenant = scopeTenant;
|
|
11
13
|
}
|
|
12
14
|
async execute(initialModel, params) {
|
|
15
|
+
const tenant = this.scopeTenant.getId();
|
|
13
16
|
const model = this.storageModelProvider.getModel(initialModel);
|
|
14
|
-
const { tenant } = model;
|
|
15
17
|
const { entryId, version } = params;
|
|
16
18
|
const partitionKey = createPartitionKey({
|
|
17
19
|
tenant,
|
|
@@ -48,7 +50,8 @@ const DdbEsGetPreviousRevision = GetPreviousRevisionStorageOperation.createImple
|
|
|
48
50
|
implementation: DdbEsGetPreviousRevisionImpl,
|
|
49
51
|
dependencies: [
|
|
50
52
|
CmsDdbEsEntryEntity,
|
|
51
|
-
CmsStorageModelProvider
|
|
53
|
+
CmsStorageModelProvider,
|
|
54
|
+
ScopeTenant
|
|
52
55
|
]
|
|
53
56
|
});
|
|
54
57
|
export { DdbEsGetPreviousRevision };
|