@webiny/api-headless-cms-ddb-es 6.6.0-alpha.12 → 6.6.0-alpha.13
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/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/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, createEntryPublishedKeys, createEntryRevisionKeys, createPartitionKey, createRevisionSortKey } from "./keys.js";
|
|
12
13
|
import { isEntryLevelEntryMetaField, pickEntryMetaFields } from "@webiny/api-headless-cms/constants.js";
|
|
13
14
|
class DdbEsUpdateEntryImpl {
|
|
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,32 +21,46 @@ class DdbEsUpdateEntryImpl {
|
|
|
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: initialEntry, storageEntry: initialStorageEntry } = params;
|
|
28
|
+
const tenant = this.scopeTenant.getId();
|
|
26
29
|
const model = this.storageModelProvider.getModel(initialModel);
|
|
27
30
|
const transformer = createTransformer({
|
|
28
31
|
valuesModifiers: this.valuesModifiers,
|
|
29
32
|
model,
|
|
30
|
-
entry:
|
|
31
|
-
|
|
33
|
+
entry: {
|
|
34
|
+
...initialEntry,
|
|
35
|
+
tenant
|
|
36
|
+
},
|
|
37
|
+
storageEntry: {
|
|
38
|
+
...initialStorageEntry,
|
|
39
|
+
tenant
|
|
40
|
+
},
|
|
32
41
|
fieldIndexRegistry: this.fieldIndexRegistry,
|
|
33
42
|
compressionHandler: this.compressionHandler
|
|
34
43
|
});
|
|
35
44
|
const { entry, storageEntry } = transformer.transformEntryKeys();
|
|
36
45
|
const isPublished = "published" === entry.status;
|
|
37
46
|
const locked = isPublished ? true : entry.locked;
|
|
38
|
-
const revisionKeys = createEntryRevisionKeys(entry);
|
|
39
|
-
const latestKeys = createEntryLatestKeys(entry);
|
|
40
|
-
const publishedKeys = createEntryPublishedKeys(entry);
|
|
47
|
+
const revisionKeys = createEntryRevisionKeys(entry, tenant);
|
|
48
|
+
const latestKeys = createEntryLatestKeys(entry, tenant);
|
|
49
|
+
const publishedKeys = createEntryPublishedKeys(entry, tenant);
|
|
41
50
|
const [latestStorageEntry] = await this.dataLoaders.getLatestRevisionByEntryId({
|
|
42
|
-
model
|
|
51
|
+
model: {
|
|
52
|
+
tenant,
|
|
53
|
+
modelId: model.modelId
|
|
54
|
+
},
|
|
43
55
|
ids: [
|
|
44
56
|
entry.id
|
|
45
57
|
]
|
|
46
58
|
});
|
|
47
59
|
const [publishedStorageEntry] = await this.dataLoaders.getPublishedRevisionByEntryId({
|
|
48
|
-
model
|
|
60
|
+
model: {
|
|
61
|
+
tenant,
|
|
62
|
+
modelId: model.modelId
|
|
63
|
+
},
|
|
49
64
|
ids: [
|
|
50
65
|
entry.id
|
|
51
66
|
]
|
|
@@ -99,7 +114,7 @@ class DdbEsUpdateEntryImpl {
|
|
|
99
114
|
...updatedLatestStorageEntry,
|
|
100
115
|
PK: createPartitionKey({
|
|
101
116
|
id: latestStorageEntry.id,
|
|
102
|
-
tenant
|
|
117
|
+
tenant
|
|
103
118
|
}),
|
|
104
119
|
SK: createRevisionSortKey(latestStorageEntry)
|
|
105
120
|
});
|
|
@@ -132,7 +147,7 @@ class DdbEsUpdateEntryImpl {
|
|
|
132
147
|
try {
|
|
133
148
|
await entityBatch.execute();
|
|
134
149
|
this.dataLoaders.clearAll({
|
|
135
|
-
tenant
|
|
150
|
+
tenant
|
|
136
151
|
});
|
|
137
152
|
} catch (ex) {
|
|
138
153
|
throw new error(ex.message || "Could not update entry DynamoDB records.", ex.code || "UPDATE_ENTRY_ERROR", {
|
|
@@ -167,7 +182,8 @@ const DdbEsUpdateEntry = UpdateEntryStorageOperation.createImplementation({
|
|
|
167
182
|
{
|
|
168
183
|
multiple: true
|
|
169
184
|
}
|
|
170
|
-
]
|
|
185
|
+
],
|
|
186
|
+
ScopeTenant
|
|
171
187
|
]
|
|
172
188
|
});
|
|
173
189
|
export { DdbEsUpdateEntry };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbEsUpdateEntry.js","sources":["../../../src/operations/entry/DdbEsUpdateEntry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { UpdateEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/UpdateEntryStorageOperation.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 createEntryPublishedKeys,\n createEntryRevisionKeys,\n createPartitionKey,\n createRevisionSortKey\n} from \"./keys.js\";\nimport {\n isEntryLevelEntryMetaField,\n pickEntryMetaFields\n} from \"@webiny/api-headless-cms/constants.js\";\nimport type { IEntryEntityAttributes } from \"~/definitions/types.js\";\nimport type { CmsIndexEntry } from \"@webiny/api-headless-cms-utils-os/types.js\";\n\nclass DdbEsUpdateEntryImpl implements UpdateEntryStorageOperation.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: CmsEntryStorageOperationsUpdateParams<T>\n ) {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = this.storageModelProvider.getModel(initialModel);\n\n const transformer = createTransformer({\n valuesModifiers: this.valuesModifiers,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry,\n fieldIndexRegistry: this.fieldIndexRegistry,\n compressionHandler: this.compressionHandler\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const revisionKeys = createEntryRevisionKeys(entry);\n const latestKeys = createEntryLatestKeys(entry);\n const publishedKeys = createEntryPublishedKeys(entry);\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await this.dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const [publishedStorageEntry] = await this.dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const entityBatch = this.entity.createEntityWriter({\n put: [\n {\n ...revisionKeys,\n data: {\n ...storageEntry,\n locked\n }\n }\n ]\n });\n\n if (isPublished) {\n entityBatch.put({\n ...publishedKeys,\n data: {\n ...storageEntry,\n locked\n }\n });\n }\n\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter();\n\n const configurations = createConfigurations(this.indexProvider);\n const { index: esIndex } = await configurations.es({\n model\n });\n\n /**\n * If the latest entry is the one being updated, we need to create a new latest entry records.\n */\n if (latestStorageEntry) {\n const updatingLatestRevision = latestStorageEntry.id === entry.id;\n if (updatingLatestRevision) {\n /**\n * First we update the regular DynamoDB table.\n */\n entityBatch.put({\n ...latestKeys,\n data: storageEntry\n });\n\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n const elasticsearchLatestData = await transformer.getElasticsearchLatestEntryData();\n\n elasticsearchEntityBatch.put({\n ...latestKeys,\n index: esIndex,\n data: elasticsearchLatestData\n });\n } else {\n /**\n * If not updating latest revision, we still want to update the latest revision's\n * entry-level meta fields to match the current revision's entry-level meta fields.\n */\n const updatedEntryLevelMetaFields = pickEntryMetaFields(\n entry,\n isEntryLevelEntryMetaField\n );\n\n const updatedLatestStorageEntry: IEntryEntityAttributes = {\n ...latestKeys,\n data: {\n ...latestStorageEntry,\n ...updatedEntryLevelMetaFields\n }\n };\n\n /**\n * First we update the regular DynamoDB table. Two updates are needed:\n * - one for the actual revision record\n * - one for the latest record\n */\n entityBatch.put({\n ...updatedLatestStorageEntry,\n PK: createPartitionKey({\n id: latestStorageEntry.id,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(latestStorageEntry)\n });\n\n entityBatch.put({\n ...updatedLatestStorageEntry\n });\n\n /**\n * Update the Elasticsearch table to propagate changes to the Elasticsearch.\n */\n const latestEsEntry = await this.esEntity.getClean(latestKeys);\n\n if (latestEsEntry) {\n const latestEsEntryDataDecompressed = (await this.compressionHandler.decompress(\n latestEsEntry.data\n )) as CmsIndexEntry;\n\n const updatedLatestEntry = await this.compressionHandler.compress({\n ...latestEsEntryDataDecompressed,\n ...updatedEntryLevelMetaFields\n });\n\n elasticsearchEntityBatch.put({\n ...latestKeys,\n index: esIndex,\n data: updatedLatestEntry\n });\n }\n }\n }\n\n if (isPublished && publishedStorageEntry?.id === entry.id) {\n const elasticsearchPublishedData =\n await transformer.getElasticsearchPublishedEntryData();\n elasticsearchEntityBatch.put({\n ...publishedKeys,\n index: esIndex,\n data: elasticsearchPublishedData\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 update entry DynamoDB records.\",\n ex.code || \"UPDATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n try {\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB Elasticsearch records.\",\n ex.code || \"UPDATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n return initialStorageEntry;\n }\n}\n\nexport const DdbEsUpdateEntry = UpdateEntryStorageOperation.createImplementation({\n implementation: DdbEsUpdateEntryImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n CmsEntryOpenSearchFieldIndexRegistry,\n CompressionHandler,\n CmsModelOpenSearchIndexProvider,\n [CmsEntryOpenSearchValuesModifier, { multiple: true }]\n ]\n});\n"],"names":["DdbEsUpdateEntryImpl","entity","esEntity","dataLoaders","storageModelProvider","fieldIndexRegistry","compressionHandler","indexProvider","valuesModifiers","initialModel","params","initialEntry","initialStorageEntry","model","transformer","createTransformer","entry","storageEntry","isPublished","locked","revisionKeys","createEntryRevisionKeys","latestKeys","createEntryLatestKeys","publishedKeys","createEntryPublishedKeys","latestStorageEntry","publishedStorageEntry","entityBatch","elasticsearchEntityBatch","configurations","createConfigurations","esIndex","updatingLatestRevision","elasticsearchLatestData","updatedEntryLevelMetaFields","pickEntryMetaFields","isEntryLevelEntryMetaField","updatedLatestStorageEntry","createPartitionKey","createRevisionSortKey","latestEsEntry","latestEsEntryDataDecompressed","updatedLatestEntry","elasticsearchPublishedData","ex","WebinyError","DdbEsUpdateEntry","UpdateEntryStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler","CmsModelOpenSearchIndexProvider","CmsEntryOpenSearchValuesModifier"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsUpdateEntry.js","sources":["../../../src/operations/entry/DdbEsUpdateEntry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { UpdateEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/UpdateEntryStorageOperation.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 createEntryPublishedKeys,\n createEntryRevisionKeys,\n createPartitionKey,\n createRevisionSortKey\n} from \"./keys.js\";\nimport {\n isEntryLevelEntryMetaField,\n pickEntryMetaFields\n} from \"@webiny/api-headless-cms/constants.js\";\nimport type { IEntryEntityAttributes } from \"~/definitions/types.js\";\nimport type { CmsIndexEntry } from \"@webiny/api-headless-cms-utils-os/types.js\";\n\nclass DdbEsUpdateEntryImpl implements UpdateEntryStorageOperation.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: CmsEntryStorageOperationsUpdateParams<T>\n ) {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const tenant = this.scopeTenant.getId();\n const model = this.storageModelProvider.getModel(initialModel);\n\n const transformer = createTransformer({\n valuesModifiers: this.valuesModifiers,\n model,\n entry: { ...initialEntry, tenant },\n storageEntry: { ...initialStorageEntry, tenant },\n fieldIndexRegistry: this.fieldIndexRegistry,\n compressionHandler: this.compressionHandler\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const revisionKeys = createEntryRevisionKeys(entry, tenant);\n const latestKeys = createEntryLatestKeys(entry, tenant);\n const publishedKeys = createEntryPublishedKeys(entry, tenant);\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await this.dataLoaders.getLatestRevisionByEntryId({\n model: { tenant, modelId: model.modelId },\n ids: [entry.id]\n });\n\n const [publishedStorageEntry] = await this.dataLoaders.getPublishedRevisionByEntryId({\n model: { tenant, modelId: model.modelId },\n ids: [entry.id]\n });\n\n const entityBatch = this.entity.createEntityWriter({\n put: [\n {\n ...revisionKeys,\n data: {\n ...storageEntry,\n locked\n }\n }\n ]\n });\n\n if (isPublished) {\n entityBatch.put({\n ...publishedKeys,\n data: {\n ...storageEntry,\n locked\n }\n });\n }\n\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter();\n\n const configurations = createConfigurations(this.indexProvider);\n const { index: esIndex } = await configurations.es({\n model\n });\n\n /**\n * If the latest entry is the one being updated, we need to create a new latest entry records.\n */\n if (latestStorageEntry) {\n const updatingLatestRevision = latestStorageEntry.id === entry.id;\n if (updatingLatestRevision) {\n /**\n * First we update the regular DynamoDB table.\n */\n entityBatch.put({\n ...latestKeys,\n data: storageEntry\n });\n\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n const elasticsearchLatestData = await transformer.getElasticsearchLatestEntryData();\n\n elasticsearchEntityBatch.put({\n ...latestKeys,\n index: esIndex,\n data: elasticsearchLatestData\n });\n } else {\n /**\n * If not updating latest revision, we still want to update the latest revision's\n * entry-level meta fields to match the current revision's entry-level meta fields.\n */\n const updatedEntryLevelMetaFields = pickEntryMetaFields(\n entry,\n isEntryLevelEntryMetaField\n );\n\n const updatedLatestStorageEntry: IEntryEntityAttributes = {\n ...latestKeys,\n data: {\n ...latestStorageEntry,\n ...updatedEntryLevelMetaFields\n }\n };\n\n /**\n * First we update the regular DynamoDB table. Two updates are needed:\n * - one for the actual revision record\n * - one for the latest record\n */\n entityBatch.put({\n ...updatedLatestStorageEntry,\n PK: createPartitionKey({\n id: latestStorageEntry.id,\n tenant\n }),\n SK: createRevisionSortKey(latestStorageEntry)\n });\n\n entityBatch.put({\n ...updatedLatestStorageEntry\n });\n\n /**\n * Update the Elasticsearch table to propagate changes to the Elasticsearch.\n */\n const latestEsEntry = await this.esEntity.getClean(latestKeys);\n\n if (latestEsEntry) {\n const latestEsEntryDataDecompressed = (await this.compressionHandler.decompress(\n latestEsEntry.data\n )) as CmsIndexEntry;\n\n const updatedLatestEntry = await this.compressionHandler.compress({\n ...latestEsEntryDataDecompressed,\n ...updatedEntryLevelMetaFields\n });\n\n elasticsearchEntityBatch.put({\n ...latestKeys,\n index: esIndex,\n data: updatedLatestEntry\n });\n }\n }\n }\n\n if (isPublished && publishedStorageEntry?.id === entry.id) {\n const elasticsearchPublishedData =\n await transformer.getElasticsearchPublishedEntryData();\n elasticsearchEntityBatch.put({\n ...publishedKeys,\n index: esIndex,\n data: elasticsearchPublishedData\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 update entry DynamoDB records.\",\n ex.code || \"UPDATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n try {\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB Elasticsearch records.\",\n ex.code || \"UPDATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n return initialStorageEntry;\n }\n}\n\nexport const DdbEsUpdateEntry = UpdateEntryStorageOperation.createImplementation({\n implementation: DdbEsUpdateEntryImpl,\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":["DdbEsUpdateEntryImpl","entity","esEntity","dataLoaders","storageModelProvider","fieldIndexRegistry","compressionHandler","indexProvider","valuesModifiers","scopeTenant","initialModel","params","initialEntry","initialStorageEntry","tenant","model","transformer","createTransformer","entry","storageEntry","isPublished","locked","revisionKeys","createEntryRevisionKeys","latestKeys","createEntryLatestKeys","publishedKeys","createEntryPublishedKeys","latestStorageEntry","publishedStorageEntry","entityBatch","elasticsearchEntityBatch","configurations","createConfigurations","esIndex","updatingLatestRevision","elasticsearchLatestData","updatedEntryLevelMetaFields","pickEntryMetaFields","isEntryLevelEntryMetaField","updatedLatestStorageEntry","createPartitionKey","createRevisionSortKey","latestEsEntry","latestEsEntryDataDecompressed","updatedLatestEntry","elasticsearchPublishedData","ex","WebinyError","DdbEsUpdateEntry","UpdateEntryStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler","CmsModelOpenSearchIndexProvider","CmsEntryOpenSearchValuesModifier","ScopeTenant"],"mappings":"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"}
|
|
@@ -11,9 +11,12 @@ export declare const createLatestSortKey: () => string;
|
|
|
11
11
|
export declare const createPublishedSortKey: () => string;
|
|
12
12
|
export interface ICreateEntryPublishedKeysParams {
|
|
13
13
|
id: string;
|
|
14
|
-
tenant: string;
|
|
15
14
|
}
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The tenant is passed separately from the record: it is the storage scope's tenant, never one read
|
|
17
|
+
* off the record.
|
|
18
|
+
*/
|
|
19
|
+
export declare const createEntryPublishedKeys: (params: ICreateEntryPublishedKeysParams, tenant: string) => {
|
|
17
20
|
PK: string;
|
|
18
21
|
SK: string;
|
|
19
22
|
TYPE: string;
|
|
@@ -21,9 +24,8 @@ export declare const createEntryPublishedKeys: (params: ICreateEntryPublishedKey
|
|
|
21
24
|
};
|
|
22
25
|
export interface ICreateEntryLatestKeysParams {
|
|
23
26
|
id: string;
|
|
24
|
-
tenant: string;
|
|
25
27
|
}
|
|
26
|
-
export declare const createEntryLatestKeys: (params: ICreateEntryLatestKeysParams) => {
|
|
28
|
+
export declare const createEntryLatestKeys: (params: ICreateEntryLatestKeysParams, tenant: string) => {
|
|
27
29
|
PK: string;
|
|
28
30
|
SK: string;
|
|
29
31
|
TYPE: string;
|
|
@@ -31,10 +33,9 @@ export declare const createEntryLatestKeys: (params: ICreateEntryLatestKeysParam
|
|
|
31
33
|
};
|
|
32
34
|
export interface ICreateRevisionKeysParams {
|
|
33
35
|
id: string;
|
|
34
|
-
tenant: string;
|
|
35
36
|
version: number;
|
|
36
37
|
}
|
|
37
|
-
export declare const createEntryRevisionKeys: (params: ICreateRevisionKeysParams) => {
|
|
38
|
+
export declare const createEntryRevisionKeys: (params: ICreateRevisionKeysParams, tenant: string) => {
|
|
38
39
|
PK: string;
|
|
39
40
|
SK: string;
|
|
40
41
|
TYPE: string;
|
package/operations/entry/keys.js
CHANGED
|
@@ -7,8 +7,8 @@ const createPartitionKey = (params)=>{
|
|
|
7
7
|
const createRevisionSortKey = (params)=>`REV#${zeroPad(params.version)}`;
|
|
8
8
|
const createLatestSortKey = ()=>"L";
|
|
9
9
|
const createPublishedSortKey = ()=>"P";
|
|
10
|
-
const createEntryPublishedKeys = (params)=>{
|
|
11
|
-
const { id
|
|
10
|
+
const createEntryPublishedKeys = (params, tenant)=>{
|
|
11
|
+
const { id } = params;
|
|
12
12
|
return {
|
|
13
13
|
PK: createPartitionKey({
|
|
14
14
|
id,
|
|
@@ -19,8 +19,8 @@ const createEntryPublishedKeys = (params)=>{
|
|
|
19
19
|
GSI_TENANT: tenant
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
const createEntryLatestKeys = (params)=>{
|
|
23
|
-
const { id
|
|
22
|
+
const createEntryLatestKeys = (params, tenant)=>{
|
|
23
|
+
const { id } = params;
|
|
24
24
|
return {
|
|
25
25
|
PK: createPartitionKey({
|
|
26
26
|
id,
|
|
@@ -31,8 +31,8 @@ const createEntryLatestKeys = (params)=>{
|
|
|
31
31
|
GSI_TENANT: tenant
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
const createEntryRevisionKeys = (params)=>{
|
|
35
|
-
const { id,
|
|
34
|
+
const createEntryRevisionKeys = (params, tenant)=>{
|
|
35
|
+
const { id, version } = params;
|
|
36
36
|
return {
|
|
37
37
|
PK: createPartitionKey({
|
|
38
38
|
id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/keys.js","sources":["../../../src/operations/entry/keys.ts"],"sourcesContent":["import { parseIdentifier, zeroPad } from \"@webiny/utils\";\n\nexport interface PartitionKeyParams {\n id: string;\n tenant: string;\n}\nexport const createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant, id: initialId } = params;\n const { id } = parseIdentifier(initialId);\n return `T#${tenant}#CMS#CME#${id}`;\n};\n\nexport interface SortKeyParams {\n version: number;\n}\nexport const createRevisionSortKey = (params: SortKeyParams): string => {\n return `REV#${zeroPad(params.version)}`;\n};\n\nexport const createLatestSortKey = (): string => {\n return \"L\";\n};\n\nexport const createPublishedSortKey = (): string => {\n return \"P\";\n};\n\nexport interface ICreateEntryPublishedKeysParams {\n id: string;\n
|
|
1
|
+
{"version":3,"file":"operations/entry/keys.js","sources":["../../../src/operations/entry/keys.ts"],"sourcesContent":["import { parseIdentifier, zeroPad } from \"@webiny/utils\";\n\nexport interface PartitionKeyParams {\n id: string;\n tenant: string;\n}\nexport const createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant, id: initialId } = params;\n const { id } = parseIdentifier(initialId);\n return `T#${tenant}#CMS#CME#${id}`;\n};\n\nexport interface SortKeyParams {\n version: number;\n}\nexport const createRevisionSortKey = (params: SortKeyParams): string => {\n return `REV#${zeroPad(params.version)}`;\n};\n\nexport const createLatestSortKey = (): string => {\n return \"L\";\n};\n\nexport const createPublishedSortKey = (): string => {\n return \"P\";\n};\n\nexport interface ICreateEntryPublishedKeysParams {\n id: string;\n}\n\n/**\n * The tenant is passed separately from the record: it is the storage scope's tenant, never one read\n * off the record.\n */\nexport const createEntryPublishedKeys = (\n params: ICreateEntryPublishedKeysParams,\n tenant: string\n) => {\n const { id } = params;\n return {\n PK: createPartitionKey({\n id,\n tenant\n }),\n SK: createPublishedSortKey(),\n TYPE: `cms.entry.p`,\n GSI_TENANT: tenant\n };\n};\n\nexport interface ICreateEntryLatestKeysParams {\n id: string;\n}\n\nexport const createEntryLatestKeys = (params: ICreateEntryLatestKeysParams, tenant: string) => {\n const { id } = params;\n return {\n PK: createPartitionKey({\n id,\n tenant\n }),\n SK: createLatestSortKey(),\n TYPE: `cms.entry.l`,\n GSI_TENANT: tenant\n };\n};\n\nexport interface ICreateRevisionKeysParams {\n id: string;\n version: number;\n}\n\nexport const createEntryRevisionKeys = (params: ICreateRevisionKeysParams, tenant: string) => {\n const { id, version } = params;\n return {\n PK: createPartitionKey({\n id,\n tenant\n }),\n SK: createRevisionSortKey({\n version\n }),\n TYPE: `cms.entry`,\n GSI_TENANT: tenant\n };\n};\n"],"names":["createPartitionKey","params","tenant","initialId","id","parseIdentifier","createRevisionSortKey","zeroPad","createLatestSortKey","createPublishedSortKey","createEntryPublishedKeys","createEntryLatestKeys","createEntryRevisionKeys","version"],"mappings":";AAMO,MAAMA,qBAAqB,CAACC;IAC/B,MAAM,EAAEC,MAAM,EAAE,IAAIC,SAAS,EAAE,GAAGF;IAClC,MAAM,EAAEG,EAAE,EAAE,GAAGC,gBAAgBF;IAC/B,OAAO,CAAC,EAAE,EAAED,OAAO,SAAS,EAAEE,IAAI;AACtC;AAKO,MAAME,wBAAwB,CAACL,SAC3B,CAAC,IAAI,EAAEM,QAAQN,OAAO,OAAO,GAAG;AAGpC,MAAMO,sBAAsB,IACxB;AAGJ,MAAMC,yBAAyB,IAC3B;AAWJ,MAAMC,2BAA2B,CACpCT,QACAC;IAEA,MAAM,EAAEE,EAAE,EAAE,GAAGH;IACf,OAAO;QACH,IAAID,mBAAmB;YACnBI;YACAF;QACJ;QACA,IAAIO;QACJ,MAAM;QACN,YAAYP;IAChB;AACJ;AAMO,MAAMS,wBAAwB,CAACV,QAAsCC;IACxE,MAAM,EAAEE,EAAE,EAAE,GAAGH;IACf,OAAO;QACH,IAAID,mBAAmB;YACnBI;YACAF;QACJ;QACA,IAAIM;QACJ,MAAM;QACN,YAAYN;IAChB;AACJ;AAOO,MAAMU,0BAA0B,CAACX,QAAmCC;IACvE,MAAM,EAAEE,EAAE,EAAES,OAAO,EAAE,GAAGZ;IACxB,OAAO;QACH,IAAID,mBAAmB;YACnBI;YACAF;QACJ;QACA,IAAII,sBAAsB;YACtBO;QACJ;QACA,MAAM;QACN,YAAYX;IAChB;AACJ"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { CmsGroupStorageOperationsCreateParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
2
|
import { CreateGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/CreateGroupStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsGroupEntity } from "../../abstractions/CmsDdbEsGroupEntity.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
declare class DdbEsCreateGroupImpl implements CreateGroupStorageOperation.Interface {
|
|
5
6
|
private entity;
|
|
6
|
-
|
|
7
|
+
private scopeTenant;
|
|
8
|
+
constructor(entity: CmsDdbEsGroupEntity.Interface, scopeTenant: ScopeTenant.Interface);
|
|
7
9
|
execute(params: CmsGroupStorageOperationsCreateParams): Promise<void>;
|
|
8
10
|
}
|
|
9
11
|
export declare const DdbEsCreateGroup: typeof DdbEsCreateGroupImpl & {
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import error from "@webiny/error";
|
|
2
2
|
import { CreateGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/CreateGroupStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsGroupEntity } from "../../abstractions/CmsDdbEsGroupEntity.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
import { createKeys, createType } from "./keys.js";
|
|
5
6
|
class DdbEsCreateGroupImpl {
|
|
6
|
-
constructor(entity){
|
|
7
|
+
constructor(entity, scopeTenant){
|
|
7
8
|
this.entity = entity;
|
|
9
|
+
this.scopeTenant = scopeTenant;
|
|
8
10
|
}
|
|
9
11
|
async execute(params) {
|
|
10
12
|
const { group } = params;
|
|
11
|
-
const
|
|
13
|
+
const tenant = this.scopeTenant.getId();
|
|
14
|
+
const keys = createKeys({
|
|
15
|
+
tenant,
|
|
16
|
+
id: group.id
|
|
17
|
+
});
|
|
12
18
|
try {
|
|
13
19
|
await this.entity.put({
|
|
14
|
-
data:
|
|
20
|
+
data: {
|
|
21
|
+
...group,
|
|
22
|
+
tenant
|
|
23
|
+
},
|
|
15
24
|
TYPE: createType(),
|
|
16
25
|
...keys
|
|
17
26
|
});
|
|
@@ -27,7 +36,8 @@ class DdbEsCreateGroupImpl {
|
|
|
27
36
|
const DdbEsCreateGroup = CreateGroupStorageOperation.createImplementation({
|
|
28
37
|
implementation: DdbEsCreateGroupImpl,
|
|
29
38
|
dependencies: [
|
|
30
|
-
CmsDdbEsGroupEntity
|
|
39
|
+
CmsDdbEsGroupEntity,
|
|
40
|
+
ScopeTenant
|
|
31
41
|
]
|
|
32
42
|
});
|
|
33
43
|
export { DdbEsCreateGroup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/group/DdbEsCreateGroup.js","sources":["../../../src/operations/group/DdbEsCreateGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsCreateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { CreateGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/CreateGroupStorageOperation.js\";\nimport { CmsDdbEsGroupEntity } from \"~/abstractions/CmsDdbEsGroupEntity.js\";\nimport { createKeys, createType } from \"./keys.js\";\n\nclass DdbEsCreateGroupImpl implements CreateGroupStorageOperation.Interface {\n constructor(private entity: CmsDdbEsGroupEntity.Interface) {}\n\n async execute(params: CmsGroupStorageOperationsCreateParams) {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await this.entity.put({\n data: group,\n TYPE: createType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create group.\",\n ex.code || \"CREATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n }\n}\n\nexport const DdbEsCreateGroup = CreateGroupStorageOperation.createImplementation({\n implementation: DdbEsCreateGroupImpl,\n dependencies: [CmsDdbEsGroupEntity]\n});\n"],"names":["DdbEsCreateGroupImpl","entity","params","group","keys","createKeys","createType","ex","WebinyError","DdbEsCreateGroup","CreateGroupStorageOperation","CmsDdbEsGroupEntity"],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations/group/DdbEsCreateGroup.js","sources":["../../../src/operations/group/DdbEsCreateGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsCreateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { CreateGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/CreateGroupStorageOperation.js\";\nimport { CmsDdbEsGroupEntity } from \"~/abstractions/CmsDdbEsGroupEntity.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { createKeys, createType } from \"./keys.js\";\n\nclass DdbEsCreateGroupImpl implements CreateGroupStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsGroupEntity.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute(params: CmsGroupStorageOperationsCreateParams) {\n const { group } = params;\n const tenant = this.scopeTenant.getId();\n const keys = createKeys({ tenant, id: group.id });\n try {\n await this.entity.put({\n data: { ...group, tenant },\n TYPE: createType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create group.\",\n ex.code || \"CREATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n }\n}\n\nexport const DdbEsCreateGroup = CreateGroupStorageOperation.createImplementation({\n implementation: DdbEsCreateGroupImpl,\n dependencies: [CmsDdbEsGroupEntity, ScopeTenant]\n});\n"],"names":["DdbEsCreateGroupImpl","entity","scopeTenant","params","group","tenant","keys","createKeys","createType","ex","WebinyError","DdbEsCreateGroup","CreateGroupStorageOperation","CmsDdbEsGroupEntity","ScopeTenant"],"mappings":";;;;;AAOA,MAAMA;IACF,YACYC,MAAqC,EACrCC,WAAkC,CAC5C;aAFUD,MAAM,GAANA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QAAQC,MAA6C,EAAE;QACzD,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAClB,MAAME,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK;QACrC,MAAMC,OAAOC,WAAW;YAAEF;YAAQ,IAAID,MAAM,EAAE;QAAC;QAC/C,IAAI;YACA,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;gBAClB,MAAM;oBAAE,GAAGA,KAAK;oBAAEC;gBAAO;gBACzB,MAAMG;gBACN,GAAGF,IAAI;YACX;QACJ,EAAE,OAAOG,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,2BACdA,GAAG,IAAI,IAAI,sBACX;gBACI,OAAOA;gBACPL;gBACAE;YACJ;QAER;IACJ;AACJ;AAEO,MAAMK,mBAAmBC,4BAA4B,oBAAoB,CAAC;IAC7E,gBAAgBZ;IAChB,cAAc;QAACa;QAAqBC;KAAY;AACpD"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { CmsGroupStorageOperationsDeleteParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
2
|
import { DeleteGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/DeleteGroupStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsGroupEntity } from "../../abstractions/CmsDdbEsGroupEntity.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
declare class DdbEsDeleteGroupImpl implements DeleteGroupStorageOperation.Interface {
|
|
5
6
|
private entity;
|
|
6
|
-
|
|
7
|
+
private scopeTenant;
|
|
8
|
+
constructor(entity: CmsDdbEsGroupEntity.Interface, scopeTenant: ScopeTenant.Interface);
|
|
7
9
|
execute(params: CmsGroupStorageOperationsDeleteParams): Promise<void>;
|
|
8
10
|
}
|
|
9
11
|
export declare const DdbEsDeleteGroup: typeof DdbEsDeleteGroupImpl & {
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import error from "@webiny/error";
|
|
2
2
|
import { DeleteGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/DeleteGroupStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsGroupEntity } from "../../abstractions/CmsDdbEsGroupEntity.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
import { createKeys } from "./keys.js";
|
|
5
6
|
class DdbEsDeleteGroupImpl {
|
|
6
|
-
constructor(entity){
|
|
7
|
+
constructor(entity, scopeTenant){
|
|
7
8
|
this.entity = entity;
|
|
9
|
+
this.scopeTenant = scopeTenant;
|
|
8
10
|
}
|
|
9
11
|
async execute(params) {
|
|
10
12
|
const { group } = params;
|
|
11
|
-
const
|
|
13
|
+
const tenant = this.scopeTenant.getId();
|
|
14
|
+
const keys = createKeys({
|
|
15
|
+
tenant,
|
|
16
|
+
id: group.id
|
|
17
|
+
});
|
|
12
18
|
try {
|
|
13
19
|
await this.entity.delete(keys);
|
|
14
20
|
} catch (ex) {
|
|
@@ -23,7 +29,8 @@ class DdbEsDeleteGroupImpl {
|
|
|
23
29
|
const DdbEsDeleteGroup = DeleteGroupStorageOperation.createImplementation({
|
|
24
30
|
implementation: DdbEsDeleteGroupImpl,
|
|
25
31
|
dependencies: [
|
|
26
|
-
CmsDdbEsGroupEntity
|
|
32
|
+
CmsDdbEsGroupEntity,
|
|
33
|
+
ScopeTenant
|
|
27
34
|
]
|
|
28
35
|
});
|
|
29
36
|
export { DdbEsDeleteGroup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/group/DdbEsDeleteGroup.js","sources":["../../../src/operations/group/DdbEsDeleteGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsDeleteParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { DeleteGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/DeleteGroupStorageOperation.js\";\nimport { CmsDdbEsGroupEntity } from \"~/abstractions/CmsDdbEsGroupEntity.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbEsDeleteGroupImpl implements DeleteGroupStorageOperation.Interface {\n constructor(private entity: CmsDdbEsGroupEntity.Interface) {}\n\n async execute(params: CmsGroupStorageOperationsDeleteParams) {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await this.entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete group.\",\n ex.code || \"DELETE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n }\n}\n\nexport const DdbEsDeleteGroup = DeleteGroupStorageOperation.createImplementation({\n implementation: DdbEsDeleteGroupImpl,\n dependencies: [CmsDdbEsGroupEntity]\n});\n"],"names":["DdbEsDeleteGroupImpl","entity","params","group","keys","createKeys","ex","WebinyError","DdbEsDeleteGroup","DeleteGroupStorageOperation","CmsDdbEsGroupEntity"],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations/group/DdbEsDeleteGroup.js","sources":["../../../src/operations/group/DdbEsDeleteGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsDeleteParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { DeleteGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/DeleteGroupStorageOperation.js\";\nimport { CmsDdbEsGroupEntity } from \"~/abstractions/CmsDdbEsGroupEntity.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbEsDeleteGroupImpl implements DeleteGroupStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsGroupEntity.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute(params: CmsGroupStorageOperationsDeleteParams) {\n const { group } = params;\n const tenant = this.scopeTenant.getId();\n const keys = createKeys({ tenant, id: group.id });\n try {\n await this.entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete group.\",\n ex.code || \"DELETE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n }\n}\n\nexport const DdbEsDeleteGroup = DeleteGroupStorageOperation.createImplementation({\n implementation: DdbEsDeleteGroupImpl,\n dependencies: [CmsDdbEsGroupEntity, ScopeTenant]\n});\n"],"names":["DdbEsDeleteGroupImpl","entity","scopeTenant","params","group","tenant","keys","createKeys","ex","WebinyError","DdbEsDeleteGroup","DeleteGroupStorageOperation","CmsDdbEsGroupEntity","ScopeTenant"],"mappings":";;;;;AAOA,MAAMA;IACF,YACYC,MAAqC,EACrCC,WAAkC,CAC5C;aAFUD,MAAM,GAANA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QAAQC,MAA6C,EAAE;QACzD,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAClB,MAAME,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK;QACrC,MAAMC,OAAOC,WAAW;YAAEF;YAAQ,IAAID,MAAM,EAAE;QAAC;QAC/C,IAAI;YACA,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAACE;QAC7B,EAAE,OAAOE,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,2BACdA,GAAG,IAAI,IAAI,sBACX;gBACI,OAAOA;gBACPJ;gBACAE;YACJ;QAER;IACJ;AACJ;AAEO,MAAMI,mBAAmBC,4BAA4B,oBAAoB,CAAC;IAC7E,gBAAgBX;IAChB,cAAc;QAACY;QAAqBC;KAAY;AACpD"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { CmsGroupStorageOperationsGetParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
2
|
import { GetGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/GetGroupStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsGroupEntity } from "../../abstractions/CmsDdbEsGroupEntity.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
declare class DdbEsGetGroupImpl implements GetGroupStorageOperation.Interface {
|
|
5
6
|
private entity;
|
|
6
|
-
|
|
7
|
+
private scopeTenant;
|
|
8
|
+
constructor(entity: CmsDdbEsGroupEntity.Interface, scopeTenant: ScopeTenant.Interface);
|
|
7
9
|
execute(params: CmsGroupStorageOperationsGetParams): Promise<import("@webiny/api-headless-cms/types/modelGroup.js").CmsGroup | null>;
|
|
8
10
|
}
|
|
9
11
|
export declare const DdbEsGetGroup: typeof DdbEsGetGroupImpl & {
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import error from "@webiny/error";
|
|
2
2
|
import { GetGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/GetGroupStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsGroupEntity } from "../../abstractions/CmsDdbEsGroupEntity.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
import { createKeys } from "./keys.js";
|
|
5
6
|
class DdbEsGetGroupImpl {
|
|
6
|
-
constructor(entity){
|
|
7
|
+
constructor(entity, scopeTenant){
|
|
7
8
|
this.entity = entity;
|
|
9
|
+
this.scopeTenant = scopeTenant;
|
|
8
10
|
}
|
|
9
11
|
async execute(params) {
|
|
10
|
-
const
|
|
12
|
+
const tenant = this.scopeTenant.getId();
|
|
13
|
+
const keys = createKeys({
|
|
14
|
+
tenant,
|
|
15
|
+
id: params.id
|
|
16
|
+
});
|
|
11
17
|
try {
|
|
12
18
|
const result = await this.entity.get(keys);
|
|
13
19
|
return result?.data || null;
|
|
@@ -23,7 +29,8 @@ class DdbEsGetGroupImpl {
|
|
|
23
29
|
const DdbEsGetGroup = GetGroupStorageOperation.createImplementation({
|
|
24
30
|
implementation: DdbEsGetGroupImpl,
|
|
25
31
|
dependencies: [
|
|
26
|
-
CmsDdbEsGroupEntity
|
|
32
|
+
CmsDdbEsGroupEntity,
|
|
33
|
+
ScopeTenant
|
|
27
34
|
]
|
|
28
35
|
});
|
|
29
36
|
export { DdbEsGetGroup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/group/DdbEsGetGroup.js","sources":["../../../src/operations/group/DdbEsGetGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsGetParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { GetGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/GetGroupStorageOperation.js\";\nimport { CmsDdbEsGroupEntity } from \"~/abstractions/CmsDdbEsGroupEntity.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbEsGetGroupImpl implements GetGroupStorageOperation.Interface {\n constructor(private entity: CmsDdbEsGroupEntity.Interface) {}\n\n async execute(params: CmsGroupStorageOperationsGetParams) {\n const keys = createKeys(params);\n\n try {\n const result = await this.entity.get(keys);\n\n return result?.data || null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get group.\",\n ex.code || \"GET_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n keys\n }\n );\n }\n }\n}\n\nexport const DdbEsGetGroup = GetGroupStorageOperation.createImplementation({\n implementation: DdbEsGetGroupImpl,\n dependencies: [CmsDdbEsGroupEntity]\n});\n"],"names":["DdbEsGetGroupImpl","entity","params","keys","createKeys","result","ex","WebinyError","DdbEsGetGroup","GetGroupStorageOperation","CmsDdbEsGroupEntity"],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations/group/DdbEsGetGroup.js","sources":["../../../src/operations/group/DdbEsGetGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsGetParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { GetGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/GetGroupStorageOperation.js\";\nimport { CmsDdbEsGroupEntity } from \"~/abstractions/CmsDdbEsGroupEntity.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbEsGetGroupImpl implements GetGroupStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsGroupEntity.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute(params: CmsGroupStorageOperationsGetParams) {\n const tenant = this.scopeTenant.getId();\n const keys = createKeys({ tenant, id: params.id });\n\n try {\n const result = await this.entity.get(keys);\n\n return result?.data || null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get group.\",\n ex.code || \"GET_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n keys\n }\n );\n }\n }\n}\n\nexport const DdbEsGetGroup = GetGroupStorageOperation.createImplementation({\n implementation: DdbEsGetGroupImpl,\n dependencies: [CmsDdbEsGroupEntity, ScopeTenant]\n});\n"],"names":["DdbEsGetGroupImpl","entity","scopeTenant","params","tenant","keys","createKeys","result","ex","WebinyError","DdbEsGetGroup","GetGroupStorageOperation","CmsDdbEsGroupEntity","ScopeTenant"],"mappings":";;;;;AAOA,MAAMA;IACF,YACYC,MAAqC,EACrCC,WAAkC,CAC5C;aAFUD,MAAM,GAANA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QAAQC,MAA0C,EAAE;QACtD,MAAMC,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK;QACrC,MAAMC,OAAOC,WAAW;YAAEF;YAAQ,IAAID,OAAO,EAAE;QAAC;QAEhD,IAAI;YACA,MAAMI,SAAS,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAACF;YAErC,OAAOE,QAAQ,QAAQ;QAC3B,EAAE,OAAOC,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,wBACdA,GAAG,IAAI,IAAI,mBACX;gBACI,OAAOA;gBACP,GAAGL,MAAM;gBACTE;YACJ;QAER;IACJ;AACJ;AAEO,MAAMK,gBAAgBC,yBAAyB,oBAAoB,CAAC;IACvE,gBAAgBX;IAChB,cAAc;QAACY;QAAqBC;KAAY;AACpD"}
|
|
@@ -2,10 +2,12 @@ import type { CmsGroup, CmsGroupStorageOperationsListParams } from "@webiny/api-
|
|
|
2
2
|
import { ListGroupsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsGroupEntity } from "../../abstractions/CmsDdbEsGroupEntity.js";
|
|
4
4
|
import { FilterUtil } from "@webiny/db-dynamodb/exports/api/db.js";
|
|
5
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
5
6
|
declare class DdbEsListGroupsImpl implements ListGroupsStorageOperation.Interface {
|
|
6
7
|
private entity;
|
|
7
8
|
private filterUtil;
|
|
8
|
-
|
|
9
|
+
private scopeTenant;
|
|
10
|
+
constructor(entity: CmsDdbEsGroupEntity.Interface, filterUtil: FilterUtil.Interface, scopeTenant: ScopeTenant.Interface);
|
|
9
11
|
execute(params: CmsGroupStorageOperationsListParams): Promise<CmsGroup[]>;
|
|
10
12
|
}
|
|
11
13
|
export declare const DdbEsListGroups: typeof DdbEsListGroupsImpl & {
|
|
@@ -4,17 +4,22 @@ import { ListGroupsStorageOperation } from "@webiny/api-headless-cms/features/sh
|
|
|
4
4
|
import { CmsDdbEsGroupEntity } from "../../abstractions/CmsDdbEsGroupEntity.js";
|
|
5
5
|
import { FilterUtil } from "@webiny/db-dynamodb/exports/api/db.js";
|
|
6
6
|
import { createPartitionKey } from "./keys.js";
|
|
7
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
7
8
|
class DdbEsListGroupsImpl {
|
|
8
|
-
constructor(entity, filterUtil){
|
|
9
|
+
constructor(entity, filterUtil, scopeTenant){
|
|
9
10
|
this.entity = entity;
|
|
10
11
|
this.filterUtil = filterUtil;
|
|
12
|
+
this.scopeTenant = scopeTenant;
|
|
11
13
|
}
|
|
12
14
|
async execute(params) {
|
|
13
15
|
const { sort, where } = params;
|
|
16
|
+
const tenant = this.scopeTenant.getId();
|
|
14
17
|
let records = [];
|
|
15
18
|
try {
|
|
16
19
|
const ddbRecords = await this.entity.queryAll({
|
|
17
|
-
partitionKey: createPartitionKey(
|
|
20
|
+
partitionKey: createPartitionKey({
|
|
21
|
+
tenant
|
|
22
|
+
}),
|
|
18
23
|
options: {
|
|
19
24
|
gte: " "
|
|
20
25
|
}
|
|
@@ -44,7 +49,8 @@ const DdbEsListGroups = ListGroupsStorageOperation.createImplementation({
|
|
|
44
49
|
implementation: DdbEsListGroupsImpl,
|
|
45
50
|
dependencies: [
|
|
46
51
|
CmsDdbEsGroupEntity,
|
|
47
|
-
FilterUtil
|
|
52
|
+
FilterUtil,
|
|
53
|
+
ScopeTenant
|
|
48
54
|
]
|
|
49
55
|
});
|
|
50
56
|
export { DdbEsListGroups };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/group/DdbEsListGroups.js","sources":["../../../src/operations/group/DdbEsListGroups.ts"],"sourcesContent":["import type {\n CmsGroup,\n CmsGroupStorageOperationsListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { sortItems } from \"@webiny/db-dynamodb\";\nimport { ListGroupsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js\";\nimport { CmsDdbEsGroupEntity } from \"~/abstractions/CmsDdbEsGroupEntity.js\";\nimport { FilterUtil } from \"@webiny/db-dynamodb/exports/api/db.js\";\nimport { createPartitionKey } from \"./keys.js\";\n\nclass DdbEsListGroupsImpl implements ListGroupsStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsGroupEntity.Interface,\n private filterUtil: FilterUtil.Interface\n ) {}\n\n async execute(params: CmsGroupStorageOperationsListParams) {\n const { sort, where } = params;\n\n let records: CmsGroup[] = [];\n try {\n const ddbRecords = await this.entity.queryAll({\n partitionKey: createPartitionKey(
|
|
1
|
+
{"version":3,"file":"operations/group/DdbEsListGroups.js","sources":["../../../src/operations/group/DdbEsListGroups.ts"],"sourcesContent":["import type {\n CmsGroup,\n CmsGroupStorageOperationsListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { sortItems } from \"@webiny/db-dynamodb\";\nimport { ListGroupsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js\";\nimport { CmsDdbEsGroupEntity } from \"~/abstractions/CmsDdbEsGroupEntity.js\";\nimport { FilterUtil } from \"@webiny/db-dynamodb/exports/api/db.js\";\nimport { createPartitionKey } from \"./keys.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\n\nclass DdbEsListGroupsImpl implements ListGroupsStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsGroupEntity.Interface,\n private filterUtil: FilterUtil.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute(params: CmsGroupStorageOperationsListParams) {\n const { sort, where } = params;\n const tenant = this.scopeTenant.getId();\n\n let records: CmsGroup[] = [];\n try {\n const ddbRecords = await this.entity.queryAll({\n partitionKey: createPartitionKey({ tenant }),\n options: {\n gte: \" \"\n }\n });\n records = ddbRecords.map(item => item.data);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list groups.\",\n ex.code || \"LIST_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n sort,\n where\n }\n );\n }\n\n const filteredItems = this.filterUtil.filter({\n items: records,\n where,\n fields: []\n });\n if (!sort || sort.length === 0) {\n return filteredItems;\n }\n\n return sortItems({\n items: filteredItems,\n sort\n });\n }\n}\n\nexport const DdbEsListGroups = ListGroupsStorageOperation.createImplementation({\n implementation: DdbEsListGroupsImpl,\n dependencies: [CmsDdbEsGroupEntity, FilterUtil, ScopeTenant]\n});\n"],"names":["DdbEsListGroupsImpl","entity","filterUtil","scopeTenant","params","sort","where","tenant","records","ddbRecords","createPartitionKey","item","ex","WebinyError","filteredItems","sortItems","DdbEsListGroups","ListGroupsStorageOperation","CmsDdbEsGroupEntity","FilterUtil","ScopeTenant"],"mappings":";;;;;;;AAYA,MAAMA;IACF,YACYC,MAAqC,EACrCC,UAAgC,EAChCC,WAAkC,CAC5C;aAHUF,MAAM,GAANA;aACAC,UAAU,GAAVA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QAAQC,MAA2C,EAAE;QACvD,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGF;QACxB,MAAMG,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK;QAErC,IAAIC,UAAsB,EAAE;QAC5B,IAAI;YACA,MAAMC,aAAa,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;gBAC1C,cAAcC,mBAAmB;oBAAEH;gBAAO;gBAC1C,SAAS;oBACL,KAAK;gBACT;YACJ;YACAC,UAAUC,WAAW,GAAG,CAACE,CAAAA,OAAQA,KAAK,IAAI;QAC9C,EAAE,OAAOC,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,0BACdA,GAAG,IAAI,IAAI,oBACX;gBACI,OAAOA;gBACP,GAAGR,MAAM;gBACTC;gBACAC;YACJ;QAER;QAEA,MAAMQ,gBAAgB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YACzC,OAAON;YACPF;YACA,QAAQ,EAAE;QACd;QACA,IAAI,CAACD,QAAQA,AAAgB,MAAhBA,KAAK,MAAM,EACpB,OAAOS;QAGX,OAAOC,UAAU;YACb,OAAOD;YACPT;QACJ;IACJ;AACJ;AAEO,MAAMW,kBAAkBC,2BAA2B,oBAAoB,CAAC;IAC3E,gBAAgBjB;IAChB,cAAc;QAACkB;QAAqBC;QAAYC;KAAY;AAChE"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { CmsGroupStorageOperationsUpdateParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
2
|
import { UpdateGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/UpdateGroupStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsGroupEntity } from "../../abstractions/CmsDdbEsGroupEntity.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
declare class DdbEsUpdateGroupImpl implements UpdateGroupStorageOperation.Interface {
|
|
5
6
|
private entity;
|
|
6
|
-
|
|
7
|
+
private scopeTenant;
|
|
8
|
+
constructor(entity: CmsDdbEsGroupEntity.Interface, scopeTenant: ScopeTenant.Interface);
|
|
7
9
|
execute(params: CmsGroupStorageOperationsUpdateParams): Promise<void>;
|
|
8
10
|
}
|
|
9
11
|
export declare const DdbEsUpdateGroup: typeof DdbEsUpdateGroupImpl & {
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import error from "@webiny/error";
|
|
2
2
|
import { UpdateGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/UpdateGroupStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsGroupEntity } from "../../abstractions/CmsDdbEsGroupEntity.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
import { createKeys, createType } from "./keys.js";
|
|
5
6
|
class DdbEsUpdateGroupImpl {
|
|
6
|
-
constructor(entity){
|
|
7
|
+
constructor(entity, scopeTenant){
|
|
7
8
|
this.entity = entity;
|
|
9
|
+
this.scopeTenant = scopeTenant;
|
|
8
10
|
}
|
|
9
11
|
async execute(params) {
|
|
10
12
|
const { group } = params;
|
|
11
|
-
const
|
|
13
|
+
const tenant = this.scopeTenant.getId();
|
|
14
|
+
const keys = createKeys({
|
|
15
|
+
tenant,
|
|
16
|
+
id: group.id
|
|
17
|
+
});
|
|
12
18
|
try {
|
|
13
19
|
await this.entity.put({
|
|
14
|
-
data:
|
|
20
|
+
data: {
|
|
21
|
+
...group,
|
|
22
|
+
tenant
|
|
23
|
+
},
|
|
15
24
|
TYPE: createType(),
|
|
16
25
|
...keys
|
|
17
26
|
});
|
|
@@ -27,7 +36,8 @@ class DdbEsUpdateGroupImpl {
|
|
|
27
36
|
const DdbEsUpdateGroup = UpdateGroupStorageOperation.createImplementation({
|
|
28
37
|
implementation: DdbEsUpdateGroupImpl,
|
|
29
38
|
dependencies: [
|
|
30
|
-
CmsDdbEsGroupEntity
|
|
39
|
+
CmsDdbEsGroupEntity,
|
|
40
|
+
ScopeTenant
|
|
31
41
|
]
|
|
32
42
|
});
|
|
33
43
|
export { DdbEsUpdateGroup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/group/DdbEsUpdateGroup.js","sources":["../../../src/operations/group/DdbEsUpdateGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsUpdateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { UpdateGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/UpdateGroupStorageOperation.js\";\nimport { CmsDdbEsGroupEntity } from \"~/abstractions/CmsDdbEsGroupEntity.js\";\nimport { createKeys, createType } from \"./keys.js\";\n\nclass DdbEsUpdateGroupImpl implements UpdateGroupStorageOperation.Interface {\n constructor(private entity: CmsDdbEsGroupEntity.Interface) {}\n\n async execute(params: CmsGroupStorageOperationsUpdateParams) {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await this.entity.put({\n data: group,\n TYPE: createType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update group.\",\n ex.code || \"UPDATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n }\n}\n\nexport const DdbEsUpdateGroup = UpdateGroupStorageOperation.createImplementation({\n implementation: DdbEsUpdateGroupImpl,\n dependencies: [CmsDdbEsGroupEntity]\n});\n"],"names":["DdbEsUpdateGroupImpl","entity","params","group","keys","createKeys","createType","ex","WebinyError","DdbEsUpdateGroup","UpdateGroupStorageOperation","CmsDdbEsGroupEntity"],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations/group/DdbEsUpdateGroup.js","sources":["../../../src/operations/group/DdbEsUpdateGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsUpdateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { UpdateGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/UpdateGroupStorageOperation.js\";\nimport { CmsDdbEsGroupEntity } from \"~/abstractions/CmsDdbEsGroupEntity.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { createKeys, createType } from \"./keys.js\";\n\nclass DdbEsUpdateGroupImpl implements UpdateGroupStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsGroupEntity.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute(params: CmsGroupStorageOperationsUpdateParams) {\n const { group } = params;\n const tenant = this.scopeTenant.getId();\n const keys = createKeys({ tenant, id: group.id });\n try {\n await this.entity.put({\n data: { ...group, tenant },\n TYPE: createType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update group.\",\n ex.code || \"UPDATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n }\n}\n\nexport const DdbEsUpdateGroup = UpdateGroupStorageOperation.createImplementation({\n implementation: DdbEsUpdateGroupImpl,\n dependencies: [CmsDdbEsGroupEntity, ScopeTenant]\n});\n"],"names":["DdbEsUpdateGroupImpl","entity","scopeTenant","params","group","tenant","keys","createKeys","createType","ex","WebinyError","DdbEsUpdateGroup","UpdateGroupStorageOperation","CmsDdbEsGroupEntity","ScopeTenant"],"mappings":";;;;;AAOA,MAAMA;IACF,YACYC,MAAqC,EACrCC,WAAkC,CAC5C;aAFUD,MAAM,GAANA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QAAQC,MAA6C,EAAE;QACzD,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAClB,MAAME,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK;QACrC,MAAMC,OAAOC,WAAW;YAAEF;YAAQ,IAAID,MAAM,EAAE;QAAC;QAC/C,IAAI;YACA,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;gBAClB,MAAM;oBAAE,GAAGA,KAAK;oBAAEC;gBAAO;gBACzB,MAAMG;gBACN,GAAGF,IAAI;YACX;QACJ,EAAE,OAAOG,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,2BACdA,GAAG,IAAI,IAAI,sBACX;gBACI,OAAOA;gBACPL;gBACAE;YACJ;QAER;IACJ;AACJ;AAEO,MAAMK,mBAAmBC,4BAA4B,oBAAoB,CAAC;IAC7E,gBAAgBZ;IAChB,cAAc;QAACa;QAAqBC;KAAY;AACpD"}
|
|
@@ -2,12 +2,14 @@ import type { CmsModelStorageOperationsCreateParams } from "@webiny/api-headless
|
|
|
2
2
|
import { CreateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsModelEntity } from "../../abstractions/CmsDdbEsModelEntity.js";
|
|
4
4
|
import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
|
|
5
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
5
6
|
import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
6
7
|
declare class DdbEsCreateModelImpl implements CreateModelStorageOperation.Interface {
|
|
7
8
|
private entity;
|
|
8
9
|
private indexProvider;
|
|
10
|
+
private scopeTenant;
|
|
9
11
|
private elasticsearch;
|
|
10
|
-
constructor(entity: CmsDdbEsModelEntity.Interface, openSearchClient: OpenSearchClient.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface);
|
|
12
|
+
constructor(entity: CmsDdbEsModelEntity.Interface, openSearchClient: OpenSearchClient.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface, scopeTenant: ScopeTenant.Interface);
|
|
11
13
|
execute(params: CmsModelStorageOperationsCreateParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel>;
|
|
12
14
|
}
|
|
13
15
|
export declare const DdbEsCreateModel: typeof DdbEsCreateModelImpl & {
|