@webiny/api-headless-cms-ddb 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/DdbCreateEntry.d.ts +3 -1
- package/operations/entry/DdbCreateEntry.js +17 -10
- package/operations/entry/DdbCreateEntry.js.map +1 -1
- package/operations/entry/DdbCreateEntryRevisionFrom.d.ts +3 -1
- package/operations/entry/DdbCreateEntryRevisionFrom.js +22 -12
- package/operations/entry/DdbCreateEntryRevisionFrom.js.map +1 -1
- package/operations/entry/DdbDeleteEntry.d.ts +3 -3
- package/operations/entry/DdbDeleteEntry.js +7 -7
- package/operations/entry/DdbDeleteEntry.js.map +1 -1
- package/operations/entry/DdbDeleteEntryRevision.d.ts +3 -1
- package/operations/entry/DdbDeleteEntryRevision.js +23 -13
- package/operations/entry/DdbDeleteEntryRevision.js.map +1 -1
- package/operations/entry/DdbDeleteMultipleEntries.d.ts +3 -1
- package/operations/entry/DdbDeleteMultipleEntries.js +13 -6
- package/operations/entry/DdbDeleteMultipleEntries.js.map +1 -1
- package/operations/entry/DdbGetEntriesByIds.d.ts +3 -1
- package/operations/entry/DdbGetEntriesByIds.js +10 -3
- package/operations/entry/DdbGetEntriesByIds.js.map +1 -1
- package/operations/entry/DdbGetEntry.d.ts +3 -1
- package/operations/entry/DdbGetEntry.js +6 -2
- package/operations/entry/DdbGetEntry.js.map +1 -1
- package/operations/entry/DdbGetLatestEntriesByIds.d.ts +3 -1
- package/operations/entry/DdbGetLatestEntriesByIds.js +10 -3
- package/operations/entry/DdbGetLatestEntriesByIds.js.map +1 -1
- package/operations/entry/DdbGetLatestRevisionByEntryId.d.ts +3 -1
- package/operations/entry/DdbGetLatestRevisionByEntryId.js +10 -3
- package/operations/entry/DdbGetLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/DdbGetPreviousRevision.d.ts +3 -1
- package/operations/entry/DdbGetPreviousRevision.js +7 -3
- package/operations/entry/DdbGetPreviousRevision.js.map +1 -1
- package/operations/entry/DdbGetPublishedEntriesByIds.d.ts +3 -1
- package/operations/entry/DdbGetPublishedEntriesByIds.js +10 -3
- package/operations/entry/DdbGetPublishedEntriesByIds.js.map +1 -1
- package/operations/entry/DdbGetPublishedRevisionByEntryId.d.ts +3 -1
- package/operations/entry/DdbGetPublishedRevisionByEntryId.js +10 -3
- package/operations/entry/DdbGetPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/DdbGetRevisionById.d.ts +3 -1
- package/operations/entry/DdbGetRevisionById.js +10 -3
- package/operations/entry/DdbGetRevisionById.js.map +1 -1
- package/operations/entry/DdbGetRevisions.d.ts +3 -1
- package/operations/entry/DdbGetRevisions.js +10 -3
- package/operations/entry/DdbGetRevisions.js.map +1 -1
- package/operations/entry/DdbGetUniqueFieldValues.d.ts +3 -1
- package/operations/entry/DdbGetUniqueFieldValues.js +6 -2
- package/operations/entry/DdbGetUniqueFieldValues.js.map +1 -1
- package/operations/entry/DdbListEntries.d.ts +3 -1
- package/operations/entry/DdbListEntries.js +10 -3
- package/operations/entry/DdbListEntries.js.map +1 -1
- package/operations/entry/DdbMoveEntry.d.ts +3 -3
- package/operations/entry/DdbMoveEntry.js +7 -7
- package/operations/entry/DdbMoveEntry.js.map +1 -1
- package/operations/entry/DdbMoveToBin.d.ts +3 -1
- package/operations/entry/DdbMoveToBin.js +8 -4
- package/operations/entry/DdbMoveToBin.js.map +1 -1
- package/operations/entry/DdbPublishEntry.d.ts +3 -1
- package/operations/entry/DdbPublishEntry.js +54 -32
- package/operations/entry/DdbPublishEntry.js.map +1 -1
- package/operations/entry/DdbRestoreFromBin.d.ts +3 -1
- package/operations/entry/DdbRestoreFromBin.js +8 -4
- package/operations/entry/DdbRestoreFromBin.js.map +1 -1
- package/operations/entry/DdbUnpublishEntry.d.ts +3 -1
- package/operations/entry/DdbUnpublishEntry.js +32 -19
- package/operations/entry/DdbUnpublishEntry.js.map +1 -1
- package/operations/entry/DdbUpdateEntry.d.ts +3 -1
- package/operations/entry/DdbUpdateEntry.js +25 -15
- package/operations/entry/DdbUpdateEntry.js.map +1 -1
- package/operations/entry/keys.d.ts +15 -6
- package/operations/entry/keys.js +30 -12
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/DdbCreateGroup.d.ts +3 -1
- package/operations/group/DdbCreateGroup.js +14 -4
- package/operations/group/DdbCreateGroup.js.map +1 -1
- package/operations/group/DdbDeleteGroup.d.ts +3 -1
- package/operations/group/DdbDeleteGroup.js +10 -3
- package/operations/group/DdbDeleteGroup.js.map +1 -1
- package/operations/group/DdbGetGroup.d.ts +3 -1
- package/operations/group/DdbGetGroup.js +10 -3
- package/operations/group/DdbGetGroup.js.map +1 -1
- package/operations/group/DdbListGroups.d.ts +3 -1
- package/operations/group/DdbListGroups.js +9 -3
- package/operations/group/DdbListGroups.js.map +1 -1
- package/operations/group/DdbUpdateGroup.d.ts +3 -1
- package/operations/group/DdbUpdateGroup.js +14 -4
- package/operations/group/DdbUpdateGroup.js.map +1 -1
- package/operations/model/DdbCreateModel.d.ts +3 -1
- package/operations/model/DdbCreateModel.js +14 -4
- package/operations/model/DdbCreateModel.js.map +1 -1
- package/operations/model/DdbDeleteModel.d.ts +3 -1
- package/operations/model/DdbDeleteModel.js +10 -3
- package/operations/model/DdbDeleteModel.js.map +1 -1
- package/operations/model/DdbGetModel.d.ts +3 -1
- package/operations/model/DdbGetModel.js +10 -3
- package/operations/model/DdbGetModel.js.map +1 -1
- package/operations/model/DdbListModels.d.ts +4 -2
- package/operations/model/DdbListModels.js +10 -5
- package/operations/model/DdbListModels.js.map +1 -1
- package/operations/model/DdbUpdateModel.d.ts +3 -1
- package/operations/model/DdbUpdateModel.js +14 -4
- package/operations/model/DdbUpdateModel.js.map +1 -1
- package/package.json +14 -14
- package/types.js.map +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import error from "@webiny/error";
|
|
2
2
|
import { UpdateEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js";
|
|
3
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
3
4
|
import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
|
|
4
5
|
import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
|
|
5
6
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
@@ -7,15 +8,19 @@ import { createEntryLatestKeys, createEntryPublishedKeys, createEntryRevisionKey
|
|
|
7
8
|
import { isEntryLevelEntryMetaField, pickEntryMetaFields } from "@webiny/api-headless-cms/constants.js";
|
|
8
9
|
import { convertToStorageEntry } from "./storageEntryUtils.js";
|
|
9
10
|
class DdbUpdateEntryImpl {
|
|
10
|
-
constructor(entity, dataLoaders, storageModelProvider){
|
|
11
|
+
constructor(entity, dataLoaders, storageModelProvider, scopeTenant){
|
|
11
12
|
this.entity = entity;
|
|
12
13
|
this.dataLoaders = dataLoaders;
|
|
13
14
|
this.storageModelProvider = storageModelProvider;
|
|
15
|
+
this.scopeTenant = scopeTenant;
|
|
14
16
|
}
|
|
15
|
-
async getLatestRevisionByEntryId(initialModel, params) {
|
|
17
|
+
async getLatestRevisionByEntryId(initialModel, tenant, params) {
|
|
16
18
|
const model = this.storageModelProvider.getModel(initialModel);
|
|
17
19
|
const items = await this.dataLoaders.getLatestRevisionByEntryId({
|
|
18
|
-
model
|
|
20
|
+
model: {
|
|
21
|
+
tenant,
|
|
22
|
+
modelId: model.modelId
|
|
23
|
+
},
|
|
19
24
|
ids: [
|
|
20
25
|
params.id
|
|
21
26
|
]
|
|
@@ -24,17 +29,21 @@ class DdbUpdateEntryImpl {
|
|
|
24
29
|
}
|
|
25
30
|
async execute(initialModel, params) {
|
|
26
31
|
const { entry, storageEntry: initialStorageEntry } = params;
|
|
32
|
+
const tenant = this.scopeTenant.getId();
|
|
27
33
|
const model = this.storageModelProvider.getModel(initialModel);
|
|
28
34
|
const isPublished = "published" === entry.status;
|
|
29
35
|
const locked = isPublished ? true : entry.locked;
|
|
30
|
-
const storageEntry =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
const storageEntry = {
|
|
37
|
+
...convertToStorageEntry({
|
|
38
|
+
model,
|
|
39
|
+
storageEntry: initialStorageEntry
|
|
40
|
+
}),
|
|
41
|
+
tenant
|
|
42
|
+
};
|
|
34
43
|
const entityBatch = this.entity.createEntityWriter({
|
|
35
44
|
put: [
|
|
36
45
|
{
|
|
37
|
-
...createEntryRevisionKeys(storageEntry),
|
|
46
|
+
...createEntryRevisionKeys(storageEntry, tenant),
|
|
38
47
|
data: {
|
|
39
48
|
...storageEntry,
|
|
40
49
|
locked
|
|
@@ -43,17 +52,17 @@ class DdbUpdateEntryImpl {
|
|
|
43
52
|
]
|
|
44
53
|
});
|
|
45
54
|
if (isPublished) entityBatch.put({
|
|
46
|
-
...createEntryPublishedKeys(storageEntry),
|
|
55
|
+
...createEntryPublishedKeys(storageEntry, tenant),
|
|
47
56
|
data: {
|
|
48
57
|
...storageEntry,
|
|
49
58
|
locked
|
|
50
59
|
}
|
|
51
60
|
});
|
|
52
|
-
const latestStorageEntry = await this.getLatestRevisionByEntryId(model, entry);
|
|
61
|
+
const latestStorageEntry = await this.getLatestRevisionByEntryId(model, tenant, entry);
|
|
53
62
|
if (latestStorageEntry) {
|
|
54
63
|
const updatingLatestRevision = latestStorageEntry.id === entry.id;
|
|
55
64
|
if (updatingLatestRevision) entityBatch.put({
|
|
56
|
-
...createEntryLatestKeys(storageEntry),
|
|
65
|
+
...createEntryLatestKeys(storageEntry, tenant),
|
|
57
66
|
data: {
|
|
58
67
|
...storageEntry,
|
|
59
68
|
locked
|
|
@@ -62,14 +71,14 @@ class DdbUpdateEntryImpl {
|
|
|
62
71
|
else {
|
|
63
72
|
const updatedEntryLevelMetaFields = pickEntryMetaFields(entry, isEntryLevelEntryMetaField);
|
|
64
73
|
entityBatch.put({
|
|
65
|
-
...createEntryRevisionKeys(latestStorageEntry),
|
|
74
|
+
...createEntryRevisionKeys(latestStorageEntry, tenant),
|
|
66
75
|
data: {
|
|
67
76
|
...latestStorageEntry,
|
|
68
77
|
...updatedEntryLevelMetaFields
|
|
69
78
|
}
|
|
70
79
|
});
|
|
71
80
|
entityBatch.put({
|
|
72
|
-
...createEntryLatestKeys(latestStorageEntry),
|
|
81
|
+
...createEntryLatestKeys(latestStorageEntry, tenant),
|
|
73
82
|
data: {
|
|
74
83
|
...latestStorageEntry,
|
|
75
84
|
...updatedEntryLevelMetaFields
|
|
@@ -80,7 +89,7 @@ class DdbUpdateEntryImpl {
|
|
|
80
89
|
try {
|
|
81
90
|
await entityBatch.execute();
|
|
82
91
|
this.dataLoaders.clearAll({
|
|
83
|
-
tenant
|
|
92
|
+
tenant
|
|
84
93
|
});
|
|
85
94
|
return initialStorageEntry;
|
|
86
95
|
} catch (ex) {
|
|
@@ -97,7 +106,8 @@ const DdbUpdateEntry = UpdateEntryStorageOperation.createImplementation({
|
|
|
97
106
|
dependencies: [
|
|
98
107
|
CmsDdbEntryEntity,
|
|
99
108
|
CmsDdbDataLoaders,
|
|
100
|
-
CmsStorageModelProvider
|
|
109
|
+
CmsStorageModelProvider,
|
|
110
|
+
ScopeTenant
|
|
101
111
|
]
|
|
102
112
|
});
|
|
103
113
|
export { DdbUpdateEntry };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbUpdateEntry.js","sources":["../../../src/operations/entry/DdbUpdateEntry.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 { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n createEntryLatestKeys,\n createEntryPublishedKeys,\n createEntryRevisionKeys\n} from \"~/operations/entry/keys.js\";\nimport {\n isEntryLevelEntryMetaField,\n pickEntryMetaFields\n} from \"@webiny/api-headless-cms/constants.js\";\nimport { convertToStorageEntry } from \"./storageEntryUtils.js\";\n\ninterface IGetLatestRevisionByEntryIdParams {\n id: string;\n}\n\nclass DdbUpdateEntryImpl implements UpdateEntryStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEntryEntity.Interface,\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n private async getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: IGetLatestRevisionByEntryIdParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const items = await this.dataLoaders.getLatestRevisionByEntryId<T>({\n model,\n ids: [params.id]\n });\n return items.shift() || null;\n }\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsUpdateParams<T>\n ) {\n const { entry, storageEntry: initialStorageEntry } = params;\n const model = this.storageModelProvider.getModel(initialModel);\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const storageEntry = convertToStorageEntry({\n
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbUpdateEntry.js","sources":["../../../src/operations/entry/DdbUpdateEntry.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 { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n createEntryLatestKeys,\n createEntryPublishedKeys,\n createEntryRevisionKeys\n} from \"~/operations/entry/keys.js\";\nimport {\n isEntryLevelEntryMetaField,\n pickEntryMetaFields\n} from \"@webiny/api-headless-cms/constants.js\";\nimport { convertToStorageEntry } from \"./storageEntryUtils.js\";\n\ninterface IGetLatestRevisionByEntryIdParams {\n id: string;\n}\n\nclass DdbUpdateEntryImpl implements UpdateEntryStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEntryEntity.Interface,\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n private async getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n tenant: string,\n params: IGetLatestRevisionByEntryIdParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const items = await this.dataLoaders.getLatestRevisionByEntryId<T>({\n model: { tenant, modelId: model.modelId },\n ids: [params.id]\n });\n return items.shift() || null;\n }\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsUpdateParams<T>\n ) {\n const { entry, storageEntry: initialStorageEntry } = params;\n const tenant = this.scopeTenant.getId();\n const model = this.storageModelProvider.getModel(initialModel);\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const storageEntry = {\n ...convertToStorageEntry({\n model,\n storageEntry: initialStorageEntry\n }),\n tenant\n };\n /**\n * We need to:\n * - update the current entry\n * - update the latest entry if the current entry is the latest one\n */\n\n const entityBatch = this.entity.createEntityWriter({\n put: [\n {\n ...createEntryRevisionKeys(storageEntry, tenant),\n data: {\n ...storageEntry,\n locked\n }\n }\n ]\n });\n\n if (isPublished) {\n entityBatch.put({\n ...createEntryPublishedKeys(storageEntry, tenant),\n data: {\n ...storageEntry,\n locked\n }\n });\n }\n\n /**\n * We need the latest entry to update it as well if necessary.\n */\n const latestStorageEntry = await this.getLatestRevisionByEntryId(model, tenant, entry);\n\n if (latestStorageEntry) {\n const updatingLatestRevision = latestStorageEntry.id === entry.id;\n if (updatingLatestRevision) {\n entityBatch.put({\n ...createEntryLatestKeys(storageEntry, tenant),\n data: {\n ...storageEntry,\n locked\n }\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 /**\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 ...createEntryRevisionKeys(latestStorageEntry, tenant),\n data: {\n ...latestStorageEntry,\n ...updatedEntryLevelMetaFields\n }\n });\n\n entityBatch.put({\n ...createEntryLatestKeys(latestStorageEntry, tenant),\n data: {\n ...latestStorageEntry,\n ...updatedEntryLevelMetaFields\n }\n });\n }\n }\n\n try {\n await entityBatch.execute();\n this.dataLoaders.clearAll({ tenant });\n return initialStorageEntry;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry.\",\n ex.code || \"UPDATE_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry\n }\n );\n }\n }\n}\n\nexport const DdbUpdateEntry = UpdateEntryStorageOperation.createImplementation({\n implementation: DdbUpdateEntryImpl,\n dependencies: [CmsDdbEntryEntity, CmsDdbDataLoaders, CmsStorageModelProvider, ScopeTenant]\n});\n"],"names":["DdbUpdateEntryImpl","entity","dataLoaders","storageModelProvider","scopeTenant","initialModel","tenant","params","model","items","entry","initialStorageEntry","isPublished","locked","storageEntry","convertToStorageEntry","entityBatch","createEntryRevisionKeys","createEntryPublishedKeys","latestStorageEntry","updatingLatestRevision","createEntryLatestKeys","updatedEntryLevelMetaFields","pickEntryMetaFields","isEntryLevelEntryMetaField","ex","WebinyError","DdbUpdateEntry","UpdateEntryStorageOperation","CmsDdbEntryEntity","CmsDdbDataLoaders","CmsStorageModelProvider","ScopeTenant"],"mappings":";;;;;;;;;AA0BA,MAAMA;IACF,YACYC,MAAmC,EACnCC,WAAwC,EACxCC,oBAAuD,EACvDC,WAAkC,CAC5C;aAJUH,MAAM,GAANA;aACAC,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAc,2BACVC,YAAsB,EACtBC,MAAc,EACdC,MAAyC,EAC3C;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIH;QAEpD,MAAMI,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAI;YAC/D,OAAO;gBAAEH;gBAAQ,SAASE,MAAM,OAAO;YAAC;YACxC,KAAK;gBAACD,OAAO,EAAE;aAAC;QACpB;QACA,OAAOE,MAAM,KAAK,MAAM;IAC5B;IAEA,MAAM,QACFJ,YAAsB,EACtBE,MAAgD,EAClD;QACE,MAAM,EAAEG,KAAK,EAAE,cAAcC,mBAAmB,EAAE,GAAGJ;QACrD,MAAMD,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK;QACrC,MAAME,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAACH;QAEjD,MAAMO,cAAcF,AAAiB,gBAAjBA,MAAM,MAAM;QAChC,MAAMG,SAASD,cAAc,OAAOF,MAAM,MAAM;QAEhD,MAAMI,eAAe;YACjB,GAAGC,sBAAsB;gBACrBP;gBACA,cAAcG;YAClB,EAAE;YACFL;QACJ;QAOA,MAAMU,cAAc,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;YAC/C,KAAK;gBACD;oBACI,GAAGC,wBAAwBH,cAAcR,OAAO;oBAChD,MAAM;wBACF,GAAGQ,YAAY;wBACfD;oBACJ;gBACJ;aACH;QACL;QAEA,IAAID,aACAI,YAAY,GAAG,CAAC;YACZ,GAAGE,yBAAyBJ,cAAcR,OAAO;YACjD,MAAM;gBACF,GAAGQ,YAAY;gBACfD;YACJ;QACJ;QAMJ,MAAMM,qBAAqB,MAAM,IAAI,CAAC,0BAA0B,CAACX,OAAOF,QAAQI;QAEhF,IAAIS,oBAAoB;YACpB,MAAMC,yBAAyBD,mBAAmB,EAAE,KAAKT,MAAM,EAAE;YACjE,IAAIU,wBACAJ,YAAY,GAAG,CAAC;gBACZ,GAAGK,sBAAsBP,cAAcR,OAAO;gBAC9C,MAAM;oBACF,GAAGQ,YAAY;oBACfD;gBACJ;YACJ;iBACG;gBAKH,MAAMS,8BAA8BC,oBAChCb,OACAc;gBAQJR,YAAY,GAAG,CAAC;oBACZ,GAAGC,wBAAwBE,oBAAoBb,OAAO;oBACtD,MAAM;wBACF,GAAGa,kBAAkB;wBACrB,GAAGG,2BAA2B;oBAClC;gBACJ;gBAEAN,YAAY,GAAG,CAAC;oBACZ,GAAGK,sBAAsBF,oBAAoBb,OAAO;oBACpD,MAAM;wBACF,GAAGa,kBAAkB;wBACrB,GAAGG,2BAA2B;oBAClC;gBACJ;YACJ;QACJ;QAEA,IAAI;YACA,MAAMN,YAAY,OAAO;YACzB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;gBAAEV;YAAO;YACnC,OAAOK;QACX,EAAE,OAAOc,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,2BACdA,GAAG,IAAI,IAAI,gBACX;gBACI,OAAOA;gBACPf;gBACAS;YACJ;QAER;IACJ;AACJ;AAEO,MAAMQ,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgB5B;IAChB,cAAc;QAAC6B;QAAmBC;QAAmBC;QAAyBC;KAAY;AAC9F"}
|
|
@@ -22,11 +22,14 @@ export interface GSISortKeyParams {
|
|
|
22
22
|
export declare const createGSISortKey: (params: GSISortKeyParams) => string;
|
|
23
23
|
export interface ICreateEntryPublishedKeysParams {
|
|
24
24
|
id: string;
|
|
25
|
-
tenant: string;
|
|
26
25
|
modelId: string;
|
|
27
26
|
expiresAt: number | null;
|
|
28
27
|
}
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The record's keys in the given tenant: the tenant of the storage operation's scope, never the one
|
|
30
|
+
* the record carries.
|
|
31
|
+
*/
|
|
32
|
+
export declare const createEntryPublishedKeys: (params: ICreateEntryPublishedKeysParams, tenant: string) => {
|
|
30
33
|
PK: string;
|
|
31
34
|
SK: string;
|
|
32
35
|
GSI1_PK: string;
|
|
@@ -37,11 +40,14 @@ export declare const createEntryPublishedKeys: (params: ICreateEntryPublishedKey
|
|
|
37
40
|
};
|
|
38
41
|
export interface ICreateEntryLatestKeysParams {
|
|
39
42
|
id: string;
|
|
40
|
-
tenant: string;
|
|
41
43
|
modelId: string;
|
|
42
44
|
expiresAt: number | null;
|
|
43
45
|
}
|
|
44
|
-
|
|
46
|
+
/**
|
|
47
|
+
* The record's keys in the given tenant: the tenant of the storage operation's scope, never the one
|
|
48
|
+
* the record carries.
|
|
49
|
+
*/
|
|
50
|
+
export declare const createEntryLatestKeys: (params: ICreateEntryLatestKeysParams, tenant: string) => {
|
|
45
51
|
PK: string;
|
|
46
52
|
SK: string;
|
|
47
53
|
GSI1_PK: string;
|
|
@@ -52,12 +58,15 @@ export declare const createEntryLatestKeys: (params: ICreateEntryLatestKeysParam
|
|
|
52
58
|
};
|
|
53
59
|
export interface ICreateRevisionKeysParams {
|
|
54
60
|
id: string;
|
|
55
|
-
tenant: string;
|
|
56
61
|
version: number;
|
|
57
62
|
modelId: string;
|
|
58
63
|
expiresAt: number | null;
|
|
59
64
|
}
|
|
60
|
-
|
|
65
|
+
/**
|
|
66
|
+
* The record's keys in the given tenant: the tenant of the storage operation's scope, never the one
|
|
67
|
+
* the record carries.
|
|
68
|
+
*/
|
|
69
|
+
export declare const createEntryRevisionKeys: (params: ICreateRevisionKeysParams, tenant: string) => {
|
|
61
70
|
PK: string;
|
|
62
71
|
SK: string;
|
|
63
72
|
GSI1_PK: string;
|
package/operations/entry/keys.js
CHANGED
|
@@ -19,36 +19,54 @@ const createGSIPartitionKey = (params, type)=>{
|
|
|
19
19
|
return `${partitionKey}#M#${modelId}#${type}`;
|
|
20
20
|
};
|
|
21
21
|
const createGSISortKey = (params)=>params.id;
|
|
22
|
-
const createEntryPublishedKeys = (params)=>{
|
|
23
|
-
const {
|
|
22
|
+
const createEntryPublishedKeys = (params, tenant)=>{
|
|
23
|
+
const { id, modelId, expiresAt } = params;
|
|
24
24
|
return {
|
|
25
|
-
PK: createPartitionKey(
|
|
25
|
+
PK: createPartitionKey({
|
|
26
|
+
id,
|
|
27
|
+
tenant
|
|
28
|
+
}),
|
|
26
29
|
SK: createPublishedSortKey(),
|
|
27
|
-
GSI1_PK: createGSIPartitionKey(
|
|
30
|
+
GSI1_PK: createGSIPartitionKey({
|
|
31
|
+
tenant,
|
|
32
|
+
modelId
|
|
33
|
+
}, "P"),
|
|
28
34
|
GSI1_SK: createGSISortKey(params),
|
|
29
35
|
TYPE: "cms.entry.p",
|
|
30
36
|
GSI_TENANT: tenant,
|
|
31
37
|
expiresAt
|
|
32
38
|
};
|
|
33
39
|
};
|
|
34
|
-
const createEntryLatestKeys = (params)=>{
|
|
35
|
-
const {
|
|
40
|
+
const createEntryLatestKeys = (params, tenant)=>{
|
|
41
|
+
const { id, modelId, expiresAt } = params;
|
|
36
42
|
return {
|
|
37
|
-
PK: createPartitionKey(
|
|
43
|
+
PK: createPartitionKey({
|
|
44
|
+
id,
|
|
45
|
+
tenant
|
|
46
|
+
}),
|
|
38
47
|
SK: createLatestSortKey(),
|
|
39
|
-
GSI1_PK: createGSIPartitionKey(
|
|
48
|
+
GSI1_PK: createGSIPartitionKey({
|
|
49
|
+
tenant,
|
|
50
|
+
modelId
|
|
51
|
+
}, "L"),
|
|
40
52
|
GSI1_SK: createGSISortKey(params),
|
|
41
53
|
TYPE: "cms.entry.l",
|
|
42
54
|
GSI_TENANT: tenant,
|
|
43
55
|
expiresAt
|
|
44
56
|
};
|
|
45
57
|
};
|
|
46
|
-
const createEntryRevisionKeys = (params)=>{
|
|
47
|
-
const {
|
|
58
|
+
const createEntryRevisionKeys = (params, tenant)=>{
|
|
59
|
+
const { id, modelId, expiresAt } = params;
|
|
48
60
|
return {
|
|
49
|
-
PK: createPartitionKey(
|
|
61
|
+
PK: createPartitionKey({
|
|
62
|
+
id,
|
|
63
|
+
tenant
|
|
64
|
+
}),
|
|
50
65
|
SK: createRevisionSortKey(params),
|
|
51
|
-
GSI1_PK: createGSIPartitionKey(
|
|
66
|
+
GSI1_PK: createGSIPartitionKey({
|
|
67
|
+
tenant,
|
|
68
|
+
modelId
|
|
69
|
+
}, "A"),
|
|
52
70
|
GSI1_SK: createGSISortKey(params),
|
|
53
71
|
TYPE: "cms.entry",
|
|
54
72
|
GSI_TENANT: tenant,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/keys.js","sources":["../../../src/operations/entry/keys.ts"],"sourcesContent":["import { parseIdentifier, zeroPad } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\n\ninterface BasePartitionKeyParams {\n tenant: string;\n}\nconst createBasePartitionKey = (params: BasePartitionKeyParams): string => {\n const { tenant } = params;\n if (!tenant) {\n throw new WebinyError(`Missing tenant variable when creating entry basePartitionKey`);\n }\n return `T#${tenant}#CMS#CME`;\n};\n\nexport interface PartitionKeyParams extends BasePartitionKeyParams {\n id: string;\n}\nexport const createPartitionKey = (params: PartitionKeyParams): string => {\n const { id: initialId } = params;\n const { id } = parseIdentifier(initialId);\n return `${createBasePartitionKey(params)}#${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 GSIPartitionKeyParams {\n tenant: string;\n modelId: string;\n}\nexport const createGSIPartitionKey = (params: GSIPartitionKeyParams, type: \"A\" | \"L\" | \"P\") => {\n const { modelId } = params;\n const partitionKey = createBasePartitionKey(params);\n return `${partitionKey}#M#${modelId}#${type}`;\n};\n\nexport interface GSISortKeyParams {\n id: string;\n}\nexport const createGSISortKey = (params: GSISortKeyParams): string => {\n return params.id;\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\";\nimport WebinyError from \"@webiny/error\";\n\ninterface BasePartitionKeyParams {\n tenant: string;\n}\nconst createBasePartitionKey = (params: BasePartitionKeyParams): string => {\n const { tenant } = params;\n if (!tenant) {\n throw new WebinyError(`Missing tenant variable when creating entry basePartitionKey`);\n }\n return `T#${tenant}#CMS#CME`;\n};\n\nexport interface PartitionKeyParams extends BasePartitionKeyParams {\n id: string;\n}\nexport const createPartitionKey = (params: PartitionKeyParams): string => {\n const { id: initialId } = params;\n const { id } = parseIdentifier(initialId);\n return `${createBasePartitionKey(params)}#${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 GSIPartitionKeyParams {\n tenant: string;\n modelId: string;\n}\nexport const createGSIPartitionKey = (params: GSIPartitionKeyParams, type: \"A\" | \"L\" | \"P\") => {\n const { modelId } = params;\n const partitionKey = createBasePartitionKey(params);\n return `${partitionKey}#M#${modelId}#${type}`;\n};\n\nexport interface GSISortKeyParams {\n id: string;\n}\nexport const createGSISortKey = (params: GSISortKeyParams): string => {\n return params.id;\n};\n\nexport interface ICreateEntryPublishedKeysParams {\n id: string;\n modelId: string;\n expiresAt: number | null;\n}\n\n/**\n * The record's keys in the given tenant: the tenant of the storage operation's scope, never the one\n * the record carries.\n */\nexport const createEntryPublishedKeys = (\n params: ICreateEntryPublishedKeysParams,\n tenant: string\n) => {\n const { id, modelId, expiresAt } = params;\n return {\n PK: createPartitionKey({ id, tenant }),\n SK: createPublishedSortKey(),\n GSI1_PK: createGSIPartitionKey({ tenant, modelId }, \"P\"),\n GSI1_SK: createGSISortKey(params),\n TYPE: `cms.entry.p`,\n GSI_TENANT: tenant,\n expiresAt\n };\n};\n\nexport interface ICreateEntryLatestKeysParams {\n id: string;\n modelId: string;\n expiresAt: number | null;\n}\n\n/**\n * The record's keys in the given tenant: the tenant of the storage operation's scope, never the one\n * the record carries.\n */\nexport const createEntryLatestKeys = (params: ICreateEntryLatestKeysParams, tenant: string) => {\n const { id, modelId, expiresAt } = params;\n return {\n PK: createPartitionKey({ id, tenant }),\n SK: createLatestSortKey(),\n GSI1_PK: createGSIPartitionKey({ tenant, modelId }, \"L\"),\n GSI1_SK: createGSISortKey(params),\n TYPE: `cms.entry.l`,\n GSI_TENANT: tenant,\n expiresAt\n };\n};\n\nexport interface ICreateRevisionKeysParams {\n id: string;\n version: number;\n modelId: string;\n expiresAt: number | null;\n}\n\n/**\n * The record's keys in the given tenant: the tenant of the storage operation's scope, never the one\n * the record carries.\n */\nexport const createEntryRevisionKeys = (params: ICreateRevisionKeysParams, tenant: string) => {\n const { id, modelId, expiresAt } = params;\n return {\n PK: createPartitionKey({ id, tenant }),\n SK: createRevisionSortKey(params),\n GSI1_PK: createGSIPartitionKey({ tenant, modelId }, \"A\"),\n GSI1_SK: createGSISortKey(params),\n TYPE: `cms.entry`,\n GSI_TENANT: tenant,\n expiresAt\n };\n};\n"],"names":["createBasePartitionKey","params","tenant","WebinyError","createPartitionKey","initialId","id","parseIdentifier","createRevisionSortKey","zeroPad","createLatestSortKey","createPublishedSortKey","createGSIPartitionKey","type","modelId","partitionKey","createGSISortKey","createEntryPublishedKeys","expiresAt","createEntryLatestKeys","createEntryRevisionKeys"],"mappings":";;AAMA,MAAMA,yBAAyB,CAACC;IAC5B,MAAM,EAAEC,MAAM,EAAE,GAAGD;IACnB,IAAI,CAACC,QACD,MAAM,IAAIC,MAAY;IAE1B,OAAO,CAAC,EAAE,EAAED,OAAO,QAAQ,CAAC;AAChC;AAKO,MAAME,qBAAqB,CAACH;IAC/B,MAAM,EAAE,IAAII,SAAS,EAAE,GAAGJ;IAC1B,MAAM,EAAEK,EAAE,EAAE,GAAGC,gBAAgBF;IAC/B,OAAO,GAAGL,uBAAuBC,QAAQ,CAAC,EAAEK,IAAI;AACpD;AAKO,MAAME,wBAAwB,CAACP,SAC3B,CAAC,IAAI,EAAEQ,QAAQR,OAAO,OAAO,GAAG;AAGpC,MAAMS,sBAAsB,IACxB;AAGJ,MAAMC,yBAAyB,IAC3B;AAOJ,MAAMC,wBAAwB,CAACX,QAA+BY;IACjE,MAAM,EAAEC,OAAO,EAAE,GAAGb;IACpB,MAAMc,eAAef,uBAAuBC;IAC5C,OAAO,GAAGc,aAAa,GAAG,EAAED,QAAQ,CAAC,EAAED,MAAM;AACjD;AAKO,MAAMG,mBAAmB,CAACf,SACtBA,OAAO,EAAE;AAab,MAAMgB,2BAA2B,CACpChB,QACAC;IAEA,MAAM,EAAEI,EAAE,EAAEQ,OAAO,EAAEI,SAAS,EAAE,GAAGjB;IACnC,OAAO;QACH,IAAIG,mBAAmB;YAAEE;YAAIJ;QAAO;QACpC,IAAIS;QACJ,SAASC,sBAAsB;YAAEV;YAAQY;QAAQ,GAAG;QACpD,SAASE,iBAAiBf;QAC1B,MAAM;QACN,YAAYC;QACZgB;IACJ;AACJ;AAYO,MAAMC,wBAAwB,CAAClB,QAAsCC;IACxE,MAAM,EAAEI,EAAE,EAAEQ,OAAO,EAAEI,SAAS,EAAE,GAAGjB;IACnC,OAAO;QACH,IAAIG,mBAAmB;YAAEE;YAAIJ;QAAO;QACpC,IAAIQ;QACJ,SAASE,sBAAsB;YAAEV;YAAQY;QAAQ,GAAG;QACpD,SAASE,iBAAiBf;QAC1B,MAAM;QACN,YAAYC;QACZgB;IACJ;AACJ;AAaO,MAAME,0BAA0B,CAACnB,QAAmCC;IACvE,MAAM,EAAEI,EAAE,EAAEQ,OAAO,EAAEI,SAAS,EAAE,GAAGjB;IACnC,OAAO;QACH,IAAIG,mBAAmB;YAAEE;YAAIJ;QAAO;QACpC,IAAIM,sBAAsBP;QAC1B,SAASW,sBAAsB;YAAEV;YAAQY;QAAQ,GAAG;QACpD,SAASE,iBAAiBf;QAC1B,MAAM;QACN,YAAYC;QACZgB;IACJ;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
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
3
4
|
import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
|
|
4
5
|
declare class DdbCreateGroupImpl implements CreateGroupStorageOperation.Interface {
|
|
5
6
|
private entity;
|
|
6
|
-
|
|
7
|
+
private scopeTenant;
|
|
8
|
+
constructor(entity: CmsDdbGroupEntity.Interface, scopeTenant: ScopeTenant.Interface);
|
|
7
9
|
execute(params: CmsGroupStorageOperationsCreateParams): Promise<void>;
|
|
8
10
|
}
|
|
9
11
|
export declare const DdbCreateGroup: typeof DdbCreateGroupImpl & {
|
|
@@ -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
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
3
4
|
import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
|
|
4
5
|
import { createKeys, createType } from "./keys.js";
|
|
5
6
|
class DdbCreateGroupImpl {
|
|
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 DdbCreateGroupImpl {
|
|
|
27
36
|
const DdbCreateGroup = CreateGroupStorageOperation.createImplementation({
|
|
28
37
|
implementation: DdbCreateGroupImpl,
|
|
29
38
|
dependencies: [
|
|
30
|
-
CmsDdbGroupEntity
|
|
39
|
+
CmsDdbGroupEntity,
|
|
40
|
+
ScopeTenant
|
|
31
41
|
]
|
|
32
42
|
});
|
|
33
43
|
export { DdbCreateGroup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/group/DdbCreateGroup.js","sources":["../../../src/operations/group/DdbCreateGroup.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 { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { createKeys, createType } from \"./keys.js\";\n\nclass DdbCreateGroupImpl implements CreateGroupStorageOperation.Interface {\n constructor(private entity: CmsDdbGroupEntity.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 { error: ex, group, keys }\n );\n }\n }\n}\n\nexport const DdbCreateGroup = CreateGroupStorageOperation.createImplementation({\n implementation: DdbCreateGroupImpl,\n dependencies: [CmsDdbGroupEntity]\n});\n"],"names":["DdbCreateGroupImpl","entity","params","group","keys","createKeys","createType","ex","WebinyError","DdbCreateGroup","CreateGroupStorageOperation","CmsDdbGroupEntity"],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations/group/DdbCreateGroup.js","sources":["../../../src/operations/group/DdbCreateGroup.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 { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { createKeys, createType } from \"./keys.js\";\n\nclass DdbCreateGroupImpl implements CreateGroupStorageOperation.Interface {\n constructor(\n private entity: CmsDdbGroupEntity.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 { error: ex, group, keys }\n );\n }\n }\n}\n\nexport const DdbCreateGroup = CreateGroupStorageOperation.createImplementation({\n implementation: DdbCreateGroupImpl,\n dependencies: [CmsDdbGroupEntity, ScopeTenant]\n});\n"],"names":["DdbCreateGroupImpl","entity","scopeTenant","params","group","tenant","keys","createKeys","createType","ex","WebinyError","DdbCreateGroup","CreateGroupStorageOperation","CmsDdbGroupEntity","ScopeTenant"],"mappings":";;;;;AAOA,MAAMA;IACF,YACYC,MAAmC,EACnCC,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;gBAAE,OAAOA;gBAAIL;gBAAOE;YAAK;QAEjC;IACJ;AACJ;AAEO,MAAMK,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBZ;IAChB,cAAc;QAACa;QAAmBC;KAAY;AAClD"}
|
|
@@ -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
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
3
4
|
import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
|
|
4
5
|
declare class DdbDeleteGroupImpl implements DeleteGroupStorageOperation.Interface {
|
|
5
6
|
private entity;
|
|
6
|
-
|
|
7
|
+
private scopeTenant;
|
|
8
|
+
constructor(entity: CmsDdbGroupEntity.Interface, scopeTenant: ScopeTenant.Interface);
|
|
7
9
|
execute(params: CmsGroupStorageOperationsDeleteParams): Promise<void>;
|
|
8
10
|
}
|
|
9
11
|
export declare const DdbDeleteGroup: typeof DdbDeleteGroupImpl & {
|
|
@@ -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
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
3
4
|
import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
|
|
4
5
|
import { createKeys } from "./keys.js";
|
|
5
6
|
class DdbDeleteGroupImpl {
|
|
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 DdbDeleteGroupImpl {
|
|
|
23
29
|
const DdbDeleteGroup = DeleteGroupStorageOperation.createImplementation({
|
|
24
30
|
implementation: DdbDeleteGroupImpl,
|
|
25
31
|
dependencies: [
|
|
26
|
-
CmsDdbGroupEntity
|
|
32
|
+
CmsDdbGroupEntity,
|
|
33
|
+
ScopeTenant
|
|
27
34
|
]
|
|
28
35
|
});
|
|
29
36
|
export { DdbDeleteGroup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/group/DdbDeleteGroup.js","sources":["../../../src/operations/group/DdbDeleteGroup.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 { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbDeleteGroupImpl implements DeleteGroupStorageOperation.Interface {\n constructor(private entity: CmsDdbGroupEntity.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 { error: ex, group, keys }\n );\n }\n }\n}\n\nexport const DdbDeleteGroup = DeleteGroupStorageOperation.createImplementation({\n implementation: DdbDeleteGroupImpl,\n dependencies: [CmsDdbGroupEntity]\n});\n"],"names":["DdbDeleteGroupImpl","entity","params","group","keys","createKeys","ex","WebinyError","DdbDeleteGroup","DeleteGroupStorageOperation","CmsDdbGroupEntity"],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations/group/DdbDeleteGroup.js","sources":["../../../src/operations/group/DdbDeleteGroup.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 { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbDeleteGroupImpl implements DeleteGroupStorageOperation.Interface {\n constructor(\n private entity: CmsDdbGroupEntity.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 { error: ex, group, keys }\n );\n }\n }\n}\n\nexport const DdbDeleteGroup = DeleteGroupStorageOperation.createImplementation({\n implementation: DdbDeleteGroupImpl,\n dependencies: [CmsDdbGroupEntity, ScopeTenant]\n});\n"],"names":["DdbDeleteGroupImpl","entity","scopeTenant","params","group","tenant","keys","createKeys","ex","WebinyError","DdbDeleteGroup","DeleteGroupStorageOperation","CmsDdbGroupEntity","ScopeTenant"],"mappings":";;;;;AAOA,MAAMA;IACF,YACYC,MAAmC,EACnCC,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;gBAAE,OAAOA;gBAAIJ;gBAAOE;YAAK;QAEjC;IACJ;AACJ;AAEO,MAAMI,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBX;IAChB,cAAc;QAACY;QAAmBC;KAAY;AAClD"}
|
|
@@ -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
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
3
4
|
import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
|
|
4
5
|
declare class DdbGetGroupImpl implements GetGroupStorageOperation.Interface {
|
|
5
6
|
private entity;
|
|
6
|
-
|
|
7
|
+
private scopeTenant;
|
|
8
|
+
constructor(entity: CmsDdbGroupEntity.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 DdbGetGroup: typeof DdbGetGroupImpl & {
|
|
@@ -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
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
3
4
|
import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
|
|
4
5
|
import { createKeys } from "./keys.js";
|
|
5
6
|
class DdbGetGroupImpl {
|
|
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 DdbGetGroupImpl {
|
|
|
23
29
|
const DdbGetGroup = GetGroupStorageOperation.createImplementation({
|
|
24
30
|
implementation: DdbGetGroupImpl,
|
|
25
31
|
dependencies: [
|
|
26
|
-
CmsDdbGroupEntity
|
|
32
|
+
CmsDdbGroupEntity,
|
|
33
|
+
ScopeTenant
|
|
27
34
|
]
|
|
28
35
|
});
|
|
29
36
|
export { DdbGetGroup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/group/DdbGetGroup.js","sources":["../../../src/operations/group/DdbGetGroup.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 { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbGetGroupImpl implements GetGroupStorageOperation.Interface {\n constructor(private entity: CmsDdbGroupEntity.Interface) {}\n\n async execute(params: CmsGroupStorageOperationsGetParams) {\n const keys = createKeys(params);\n try {\n const result = await this.entity.get(keys);\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 { error: ex, ...params, keys }\n );\n }\n }\n}\n\nexport const DdbGetGroup = GetGroupStorageOperation.createImplementation({\n implementation: DdbGetGroupImpl,\n dependencies: [CmsDdbGroupEntity]\n});\n"],"names":["DdbGetGroupImpl","entity","params","keys","createKeys","result","ex","WebinyError","DdbGetGroup","GetGroupStorageOperation","CmsDdbGroupEntity"],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations/group/DdbGetGroup.js","sources":["../../../src/operations/group/DdbGetGroup.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 { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbGetGroupImpl implements GetGroupStorageOperation.Interface {\n constructor(\n private entity: CmsDdbGroupEntity.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 try {\n const result = await this.entity.get(keys);\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 { error: ex, ...params, keys }\n );\n }\n }\n}\n\nexport const DdbGetGroup = GetGroupStorageOperation.createImplementation({\n implementation: DdbGetGroupImpl,\n dependencies: [CmsDdbGroupEntity, ScopeTenant]\n});\n"],"names":["DdbGetGroupImpl","entity","scopeTenant","params","tenant","keys","createKeys","result","ex","WebinyError","DdbGetGroup","GetGroupStorageOperation","CmsDdbGroupEntity","ScopeTenant"],"mappings":";;;;;AAOA,MAAMA;IACF,YACYC,MAAmC,EACnCC,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;QAChD,IAAI;YACA,MAAMI,SAAS,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAACF;YACrC,OAAOE,QAAQ,QAAQ;QAC3B,EAAE,OAAOC,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,wBACdA,GAAG,IAAI,IAAI,mBACX;gBAAE,OAAOA;gBAAI,GAAGL,MAAM;gBAAEE;YAAK;QAErC;IACJ;AACJ;AAEO,MAAMK,cAAcC,yBAAyB,oBAAoB,CAAC;IACrE,gBAAgBX;IAChB,cAAc;QAACY;QAAmBC;KAAY;AAClD"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { CmsGroup, CmsGroupStorageOperationsListParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
2
|
import { ListGroupsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js";
|
|
3
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
3
4
|
import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
|
|
4
5
|
import { FilterUtil } from "@webiny/db-dynamodb/feature/FilterUtil/index.js";
|
|
5
6
|
declare class DdbListGroupsImpl implements ListGroupsStorageOperation.Interface {
|
|
6
7
|
private entity;
|
|
7
8
|
private filterUtil;
|
|
8
|
-
|
|
9
|
+
private scopeTenant;
|
|
10
|
+
constructor(entity: CmsDdbGroupEntity.Interface, filterUtil: FilterUtil.Interface, scopeTenant: ScopeTenant.Interface);
|
|
9
11
|
execute(params: CmsGroupStorageOperationsListParams): Promise<CmsGroup[]>;
|
|
10
12
|
}
|
|
11
13
|
export declare const DdbListGroups: typeof DdbListGroupsImpl & {
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import error from "@webiny/error";
|
|
2
2
|
import { sortItems } from "@webiny/db-dynamodb";
|
|
3
3
|
import { ListGroupsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js";
|
|
4
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
5
|
import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
|
|
5
6
|
import { FilterUtil } from "@webiny/db-dynamodb/feature/FilterUtil/index.js";
|
|
6
7
|
import { createPartitionKey } from "./keys.js";
|
|
7
8
|
class DdbListGroupsImpl {
|
|
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 DdbListGroups = ListGroupsStorageOperation.createImplementation({
|
|
|
44
49
|
implementation: DdbListGroupsImpl,
|
|
45
50
|
dependencies: [
|
|
46
51
|
CmsDdbGroupEntity,
|
|
47
|
-
FilterUtil
|
|
52
|
+
FilterUtil,
|
|
53
|
+
ScopeTenant
|
|
48
54
|
]
|
|
49
55
|
});
|
|
50
56
|
export { DdbListGroups };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/group/DdbListGroups.js","sources":["../../../src/operations/group/DdbListGroups.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 { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { FilterUtil } from \"@webiny/db-dynamodb/feature/FilterUtil/index.js\";\nimport { createPartitionKey } from \"./keys.js\";\n\nclass DdbListGroupsImpl implements ListGroupsStorageOperation.Interface {\n constructor(\n private entity: CmsDdbGroupEntity.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/DdbListGroups.js","sources":["../../../src/operations/group/DdbListGroups.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 { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { FilterUtil } from \"@webiny/db-dynamodb/feature/FilterUtil/index.js\";\nimport { createPartitionKey } from \"./keys.js\";\n\nclass DdbListGroupsImpl implements ListGroupsStorageOperation.Interface {\n constructor(\n private entity: CmsDdbGroupEntity.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: { gte: \" \" }\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 { error: ex, ...params, sort, where }\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({ items: filteredItems, sort });\n }\n}\n\nexport const DdbListGroups = ListGroupsStorageOperation.createImplementation({\n implementation: DdbListGroupsImpl,\n dependencies: [CmsDdbGroupEntity, FilterUtil, ScopeTenant]\n});\n"],"names":["DdbListGroupsImpl","entity","filterUtil","scopeTenant","params","sort","where","tenant","records","ddbRecords","createPartitionKey","item","ex","WebinyError","filteredItems","sortItems","DdbListGroups","ListGroupsStorageOperation","CmsDdbGroupEntity","FilterUtil","ScopeTenant"],"mappings":";;;;;;;AAYA,MAAMA;IACF,YACYC,MAAmC,EACnCC,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;oBAAE,KAAK;gBAAI;YACxB;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;gBAAE,OAAOA;gBAAI,GAAGR,MAAM;gBAAEC;gBAAMC;YAAM;QAE5C;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;YAAE,OAAOD;YAAeT;QAAK;IAClD;AACJ;AAEO,MAAMW,gBAAgBC,2BAA2B,oBAAoB,CAAC;IACzE,gBAAgBjB;IAChB,cAAc;QAACkB;QAAmBC;QAAYC;KAAY;AAC9D"}
|
|
@@ -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
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
3
4
|
import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
|
|
4
5
|
declare class DdbUpdateGroupImpl implements UpdateGroupStorageOperation.Interface {
|
|
5
6
|
private entity;
|
|
6
|
-
|
|
7
|
+
private scopeTenant;
|
|
8
|
+
constructor(entity: CmsDdbGroupEntity.Interface, scopeTenant: ScopeTenant.Interface);
|
|
7
9
|
execute(params: CmsGroupStorageOperationsUpdateParams): Promise<void>;
|
|
8
10
|
}
|
|
9
11
|
export declare const DdbUpdateGroup: typeof DdbUpdateGroupImpl & {
|
|
@@ -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
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
3
4
|
import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
|
|
4
5
|
import { createKeys, createType } from "./keys.js";
|
|
5
6
|
class DdbUpdateGroupImpl {
|
|
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 DdbUpdateGroupImpl {
|
|
|
27
36
|
const DdbUpdateGroup = UpdateGroupStorageOperation.createImplementation({
|
|
28
37
|
implementation: DdbUpdateGroupImpl,
|
|
29
38
|
dependencies: [
|
|
30
|
-
CmsDdbGroupEntity
|
|
39
|
+
CmsDdbGroupEntity,
|
|
40
|
+
ScopeTenant
|
|
31
41
|
]
|
|
32
42
|
});
|
|
33
43
|
export { DdbUpdateGroup };
|