@webiny/api-headless-cms-tasks 0.0.0-unstable.06b2ede40f → 0.0.0-unstable.0d717d18dd
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/HcmsTasksFeature.d.ts +4 -0
- package/HcmsTasksFeature.js +20 -0
- package/HcmsTasksFeature.js.map +1 -0
- package/README.md +10 -14
- package/constants.js +4 -0
- package/constants.js.map +1 -0
- package/features/DeleteModelTask/DeleteModel.d.ts +16 -0
- package/features/DeleteModelTask/DeleteModel.js +113 -0
- package/features/DeleteModelTask/DeleteModel.js.map +1 -0
- package/features/DeleteModelTask/DeleteModelTask.d.ts +25 -0
- package/features/DeleteModelTask/DeleteModelTask.js +42 -0
- package/features/DeleteModelTask/DeleteModelTask.js.map +1 -0
- package/features/DeleteModelTask/feature.d.ts +4 -0
- package/features/DeleteModelTask/feature.js +11 -0
- package/features/DeleteModelTask/feature.js.map +1 -0
- package/{tasks/deleteModel → features/DeleteModelTask}/types.d.ts +3 -7
- package/features/DeleteModelTask/types.js +10 -0
- package/features/DeleteModelTask/types.js.map +1 -0
- package/features/DisableModel/BlockActionIfModelDisabled.d.ts +8 -0
- package/features/DisableModel/BlockActionIfModelDisabled.js +14 -0
- package/features/DisableModel/BlockActionIfModelDisabled.js.map +1 -0
- package/features/DisableModel/abstractions.d.ts +8 -0
- package/features/DisableModel/abstractions.js +5 -0
- package/features/DisableModel/abstractions.js.map +1 -0
- package/features/DisableModel/feature.d.ts +4 -0
- package/features/DisableModel/feature.js +34 -0
- package/features/DisableModel/feature.js.map +1 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeCreate.d.ts +11 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeCreate.js +19 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeCreate.js.map +1 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeMove.d.ts +11 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeMove.js +19 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeMove.js.map +1 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforePublish.d.ts +11 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforePublish.js +19 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforePublish.js.map +1 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeRepublish.d.ts +11 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeRepublish.js +19 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeRepublish.js.map +1 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeRestoreFromBin.d.ts +11 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeRestoreFromBin.js +19 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeRestoreFromBin.js.map +1 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeUnpublish.d.ts +11 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeUnpublish.js +19 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeUnpublish.js.map +1 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeUpdate.d.ts +11 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeUpdate.js +19 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeUpdate.js.map +1 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryRevisionBeforeCreate.d.ts +11 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryRevisionBeforeCreate.js +19 -0
- package/features/DisableModel/handlers/BlockModelActionOnEntryRevisionBeforeCreate.js.map +1 -0
- package/features/DisableModel/handlers/BlockModelActionOnModelBeforeCreateFrom.d.ts +11 -0
- package/features/DisableModel/handlers/BlockModelActionOnModelBeforeCreateFrom.js +19 -0
- package/features/DisableModel/handlers/BlockModelActionOnModelBeforeCreateFrom.js.map +1 -0
- package/features/DisableModel/handlers/BlockModelActionOnModelBeforeUpdate.d.ts +11 -0
- package/features/DisableModel/handlers/BlockModelActionOnModelBeforeUpdate.js +19 -0
- package/features/DisableModel/handlers/BlockModelActionOnModelBeforeUpdate.js.map +1 -0
- package/features/DisableModel/index.d.ts +1 -0
- package/features/DisableModel/index.js +1 -0
- package/graphql/deleteModel/abstractions.d.ts +12 -0
- package/graphql/deleteModel/abstractions.js +5 -0
- package/graphql/deleteModel/abstractions.js.map +1 -0
- package/graphql/deleteModel/cancelDeleteModel.d.ts +7 -0
- package/graphql/deleteModel/cancelDeleteModel.js +57 -0
- package/graphql/deleteModel/cancelDeleteModel.js.map +1 -0
- package/graphql/deleteModel/crud.d.ts +2 -0
- package/graphql/deleteModel/crud.js +56 -0
- package/graphql/deleteModel/crud.js.map +1 -0
- package/graphql/deleteModel/fullyDeleteModel.d.ts +7 -0
- package/graphql/deleteModel/fullyDeleteModel.js +58 -0
- package/graphql/deleteModel/fullyDeleteModel.js.map +1 -0
- package/graphql/deleteModel/getDeleteModelProgress.d.ts +7 -0
- package/graphql/deleteModel/getDeleteModelProgress.js +61 -0
- package/graphql/deleteModel/getDeleteModelProgress.js.map +1 -0
- package/graphql/deleteModel/index.d.ts +3 -0
- package/graphql/deleteModel/index.js +143 -0
- package/graphql/deleteModel/index.js.map +1 -0
- package/graphql/deleteModel/status.d.ts +3 -0
- package/graphql/deleteModel/status.js +18 -0
- package/graphql/deleteModel/status.js.map +1 -0
- package/helpers/confirmation.js +9 -0
- package/helpers/confirmation.js.map +1 -0
- package/helpers/store.d.ts +14 -0
- package/helpers/store.js +40 -0
- package/helpers/store.js.map +1 -0
- package/index.d.ts +1 -3
- package/index.js +1 -19
- package/package.json +31 -29
- package/types.d.ts +2 -12
- package/types.js +0 -7
- package/index.js.map +0 -1
- package/tasks/deleteModel/DeleteModelRunner.d.ts +0 -19
- package/tasks/deleteModel/DeleteModelRunner.js +0 -139
- package/tasks/deleteModel/DeleteModelRunner.js.map +0 -1
- package/tasks/deleteModel/constants.js +0 -9
- package/tasks/deleteModel/constants.js.map +0 -1
- package/tasks/deleteModel/graphql/attachLifecycleEvents.d.ts +0 -5
- package/tasks/deleteModel/graphql/attachLifecycleEvents.js +0 -40
- package/tasks/deleteModel/graphql/attachLifecycleEvents.js.map +0 -1
- package/tasks/deleteModel/graphql/cancelDeleteModel.d.ts +0 -7
- package/tasks/deleteModel/graphql/cancelDeleteModel.js +0 -64
- package/tasks/deleteModel/graphql/cancelDeleteModel.js.map +0 -1
- package/tasks/deleteModel/graphql/crud.d.ts +0 -3
- package/tasks/deleteModel/graphql/crud.js +0 -82
- package/tasks/deleteModel/graphql/crud.js.map +0 -1
- package/tasks/deleteModel/graphql/fullyDeleteModel.d.ts +0 -7
- package/tasks/deleteModel/graphql/fullyDeleteModel.js +0 -57
- package/tasks/deleteModel/graphql/fullyDeleteModel.js.map +0 -1
- package/tasks/deleteModel/graphql/getDeleteModelProgress.d.ts +0 -7
- package/tasks/deleteModel/graphql/getDeleteModelProgress.js +0 -66
- package/tasks/deleteModel/graphql/getDeleteModelProgress.js.map +0 -1
- package/tasks/deleteModel/graphql/index.d.ts +0 -3
- package/tasks/deleteModel/graphql/index.js +0 -166
- package/tasks/deleteModel/graphql/index.js.map +0 -1
- package/tasks/deleteModel/graphql/isModelBeingDeleted.d.ts +0 -5
- package/tasks/deleteModel/graphql/isModelBeingDeleted.js +0 -15
- package/tasks/deleteModel/graphql/isModelBeingDeleted.js.map +0 -1
- package/tasks/deleteModel/graphql/status.d.ts +0 -3
- package/tasks/deleteModel/graphql/status.js +0 -24
- package/tasks/deleteModel/graphql/status.js.map +0 -1
- package/tasks/deleteModel/helpers/confirmation.js +0 -23
- package/tasks/deleteModel/helpers/confirmation.js.map +0 -1
- package/tasks/deleteModel/helpers/store.d.ts +0 -10
- package/tasks/deleteModel/helpers/store.js +0 -26
- package/tasks/deleteModel/helpers/store.js.map +0 -1
- package/tasks/deleteModel/index.d.ts +0 -3
- package/tasks/deleteModel/index.js +0 -50
- package/tasks/deleteModel/index.js.map +0 -1
- package/tasks/deleteModel/types.js +0 -15
- package/tasks/deleteModel/types.js.map +0 -1
- package/types.js.map +0 -1
- /package/{tasks/deleteModel/constants.d.ts → constants.d.ts} +0 -0
- /package/{tasks/deleteModel/helpers → helpers}/confirmation.d.ts +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EntryBeforeRepublishEventHandler } from "@webiny/api-headless-cms/features/contentEntry/RepublishEntry/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
class BlockModelActionOnEntryBeforeRepublishImpl {
|
|
4
|
+
constructor(blockAction){
|
|
5
|
+
this.blockAction = blockAction;
|
|
6
|
+
}
|
|
7
|
+
async handle(event) {
|
|
8
|
+
await this.blockAction.execute(event.payload.model);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const BlockModelActionOnEntryBeforeRepublish = EntryBeforeRepublishEventHandler.createImplementation({
|
|
12
|
+
implementation: BlockModelActionOnEntryBeforeRepublishImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
BlockActionIfModelDisabled
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { BlockModelActionOnEntryBeforeRepublish };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=BlockModelActionOnEntryBeforeRepublish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/DisableModel/handlers/BlockModelActionOnEntryBeforeRepublish.js","sources":["../../../../src/features/DisableModel/handlers/BlockModelActionOnEntryBeforeRepublish.ts"],"sourcesContent":["import { EntryBeforeRepublishEventHandler } from \"@webiny/api-headless-cms/features/contentEntry/RepublishEntry/events.js\";\nimport { BlockActionIfModelDisabled } from \"../abstractions.js\";\n\nclass BlockModelActionOnEntryBeforeRepublishImpl\n implements EntryBeforeRepublishEventHandler.Interface\n{\n constructor(private blockAction: BlockActionIfModelDisabled.Interface) {}\n\n async handle(event: EntryBeforeRepublishEventHandler.Event): Promise<void> {\n await this.blockAction.execute(event.payload.model);\n }\n}\n\nexport const BlockModelActionOnEntryBeforeRepublish =\n EntryBeforeRepublishEventHandler.createImplementation({\n implementation: BlockModelActionOnEntryBeforeRepublishImpl,\n dependencies: [BlockActionIfModelDisabled]\n });\n"],"names":["BlockModelActionOnEntryBeforeRepublishImpl","blockAction","event","BlockModelActionOnEntryBeforeRepublish","EntryBeforeRepublishEventHandler","BlockActionIfModelDisabled"],"mappings":";;AAGA,MAAMA;IAGF,YAAoBC,WAAiD,CAAE;aAAnDA,WAAW,GAAXA;IAAoD;IAExE,MAAM,OAAOC,KAA6C,EAAiB;QACvE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACA,MAAM,OAAO,CAAC,KAAK;IACtD;AACJ;AAEO,MAAMC,yCACTC,iCAAiC,oBAAoB,CAAC;IAClD,gBAAgBJ;IAChB,cAAc;QAACK;KAA2B;AAC9C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EntryBeforeRestoreFromBinEventHandler } from "@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
declare class BlockModelActionOnEntryBeforeRestoreFromBinImpl implements EntryBeforeRestoreFromBinEventHandler.Interface {
|
|
4
|
+
private blockAction;
|
|
5
|
+
constructor(blockAction: BlockActionIfModelDisabled.Interface);
|
|
6
|
+
handle(event: EntryBeforeRestoreFromBinEventHandler.Event): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const BlockModelActionOnEntryBeforeRestoreFromBin: typeof BlockModelActionOnEntryBeforeRestoreFromBinImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/events.js").EntryBeforeRestoreFromBinEvent>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EntryBeforeRestoreFromBinEventHandler } from "@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
class BlockModelActionOnEntryBeforeRestoreFromBinImpl {
|
|
4
|
+
constructor(blockAction){
|
|
5
|
+
this.blockAction = blockAction;
|
|
6
|
+
}
|
|
7
|
+
async handle(event) {
|
|
8
|
+
await this.blockAction.execute(event.payload.model);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const BlockModelActionOnEntryBeforeRestoreFromBin = EntryBeforeRestoreFromBinEventHandler.createImplementation({
|
|
12
|
+
implementation: BlockModelActionOnEntryBeforeRestoreFromBinImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
BlockActionIfModelDisabled
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { BlockModelActionOnEntryBeforeRestoreFromBin };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=BlockModelActionOnEntryBeforeRestoreFromBin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/DisableModel/handlers/BlockModelActionOnEntryBeforeRestoreFromBin.js","sources":["../../../../src/features/DisableModel/handlers/BlockModelActionOnEntryBeforeRestoreFromBin.ts"],"sourcesContent":["import { EntryBeforeRestoreFromBinEventHandler } from \"@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/events.js\";\nimport { BlockActionIfModelDisabled } from \"../abstractions.js\";\n\nclass BlockModelActionOnEntryBeforeRestoreFromBinImpl\n implements EntryBeforeRestoreFromBinEventHandler.Interface\n{\n constructor(private blockAction: BlockActionIfModelDisabled.Interface) {}\n\n async handle(event: EntryBeforeRestoreFromBinEventHandler.Event): Promise<void> {\n await this.blockAction.execute(event.payload.model);\n }\n}\n\nexport const BlockModelActionOnEntryBeforeRestoreFromBin =\n EntryBeforeRestoreFromBinEventHandler.createImplementation({\n implementation: BlockModelActionOnEntryBeforeRestoreFromBinImpl,\n dependencies: [BlockActionIfModelDisabled]\n });\n"],"names":["BlockModelActionOnEntryBeforeRestoreFromBinImpl","blockAction","event","BlockModelActionOnEntryBeforeRestoreFromBin","EntryBeforeRestoreFromBinEventHandler","BlockActionIfModelDisabled"],"mappings":";;AAGA,MAAMA;IAGF,YAAoBC,WAAiD,CAAE;aAAnDA,WAAW,GAAXA;IAAoD;IAExE,MAAM,OAAOC,KAAkD,EAAiB;QAC5E,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACA,MAAM,OAAO,CAAC,KAAK;IACtD;AACJ;AAEO,MAAMC,8CACTC,sCAAsC,oBAAoB,CAAC;IACvD,gBAAgBJ;IAChB,cAAc;QAACK;KAA2B;AAC9C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EntryBeforeUnpublishEventHandler } from "@webiny/api-headless-cms/features/contentEntry/UnpublishEntry/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
declare class BlockModelActionOnEntryBeforeUnpublishImpl implements EntryBeforeUnpublishEventHandler.Interface {
|
|
4
|
+
private blockAction;
|
|
5
|
+
constructor(blockAction: BlockActionIfModelDisabled.Interface);
|
|
6
|
+
handle(event: EntryBeforeUnpublishEventHandler.Event): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const BlockModelActionOnEntryBeforeUnpublish: typeof BlockModelActionOnEntryBeforeUnpublishImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-headless-cms/features/contentEntry/UnpublishEntry/events.js").EntryBeforeUnpublishEvent>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EntryBeforeUnpublishEventHandler } from "@webiny/api-headless-cms/features/contentEntry/UnpublishEntry/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
class BlockModelActionOnEntryBeforeUnpublishImpl {
|
|
4
|
+
constructor(blockAction){
|
|
5
|
+
this.blockAction = blockAction;
|
|
6
|
+
}
|
|
7
|
+
async handle(event) {
|
|
8
|
+
await this.blockAction.execute(event.payload.model);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const BlockModelActionOnEntryBeforeUnpublish = EntryBeforeUnpublishEventHandler.createImplementation({
|
|
12
|
+
implementation: BlockModelActionOnEntryBeforeUnpublishImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
BlockActionIfModelDisabled
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { BlockModelActionOnEntryBeforeUnpublish };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=BlockModelActionOnEntryBeforeUnpublish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/DisableModel/handlers/BlockModelActionOnEntryBeforeUnpublish.js","sources":["../../../../src/features/DisableModel/handlers/BlockModelActionOnEntryBeforeUnpublish.ts"],"sourcesContent":["import { EntryBeforeUnpublishEventHandler } from \"@webiny/api-headless-cms/features/contentEntry/UnpublishEntry/events.js\";\nimport { BlockActionIfModelDisabled } from \"../abstractions.js\";\n\nclass BlockModelActionOnEntryBeforeUnpublishImpl\n implements EntryBeforeUnpublishEventHandler.Interface\n{\n constructor(private blockAction: BlockActionIfModelDisabled.Interface) {}\n\n async handle(event: EntryBeforeUnpublishEventHandler.Event): Promise<void> {\n await this.blockAction.execute(event.payload.model);\n }\n}\n\nexport const BlockModelActionOnEntryBeforeUnpublish =\n EntryBeforeUnpublishEventHandler.createImplementation({\n implementation: BlockModelActionOnEntryBeforeUnpublishImpl,\n dependencies: [BlockActionIfModelDisabled]\n });\n"],"names":["BlockModelActionOnEntryBeforeUnpublishImpl","blockAction","event","BlockModelActionOnEntryBeforeUnpublish","EntryBeforeUnpublishEventHandler","BlockActionIfModelDisabled"],"mappings":";;AAGA,MAAMA;IAGF,YAAoBC,WAAiD,CAAE;aAAnDA,WAAW,GAAXA;IAAoD;IAExE,MAAM,OAAOC,KAA6C,EAAiB;QACvE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACA,MAAM,OAAO,CAAC,KAAK;IACtD;AACJ;AAEO,MAAMC,yCACTC,iCAAiC,oBAAoB,CAAC;IAClD,gBAAgBJ;IAChB,cAAc;QAACK;KAA2B;AAC9C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EntryBeforeUpdateEventHandler } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
declare class BlockModelActionOnEntryBeforeUpdateImpl implements EntryBeforeUpdateEventHandler.Interface {
|
|
4
|
+
private blockAction;
|
|
5
|
+
constructor(blockAction: BlockActionIfModelDisabled.Interface);
|
|
6
|
+
handle(event: EntryBeforeUpdateEventHandler.Event): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const BlockModelActionOnEntryBeforeUpdate: typeof BlockModelActionOnEntryBeforeUpdateImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-headless-cms/features/contentEntry/UpdateEntry/events.js").EntryBeforeUpdateEvent>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EntryBeforeUpdateEventHandler } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
class BlockModelActionOnEntryBeforeUpdateImpl {
|
|
4
|
+
constructor(blockAction){
|
|
5
|
+
this.blockAction = blockAction;
|
|
6
|
+
}
|
|
7
|
+
async handle(event) {
|
|
8
|
+
await this.blockAction.execute(event.payload.model);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const BlockModelActionOnEntryBeforeUpdate = EntryBeforeUpdateEventHandler.createImplementation({
|
|
12
|
+
implementation: BlockModelActionOnEntryBeforeUpdateImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
BlockActionIfModelDisabled
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { BlockModelActionOnEntryBeforeUpdate };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=BlockModelActionOnEntryBeforeUpdate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/DisableModel/handlers/BlockModelActionOnEntryBeforeUpdate.js","sources":["../../../../src/features/DisableModel/handlers/BlockModelActionOnEntryBeforeUpdate.ts"],"sourcesContent":["import { EntryBeforeUpdateEventHandler } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/events.js\";\nimport { BlockActionIfModelDisabled } from \"../abstractions.js\";\n\nclass BlockModelActionOnEntryBeforeUpdateImpl implements EntryBeforeUpdateEventHandler.Interface {\n constructor(private blockAction: BlockActionIfModelDisabled.Interface) {}\n\n async handle(event: EntryBeforeUpdateEventHandler.Event): Promise<void> {\n await this.blockAction.execute(event.payload.model);\n }\n}\n\nexport const BlockModelActionOnEntryBeforeUpdate =\n EntryBeforeUpdateEventHandler.createImplementation({\n implementation: BlockModelActionOnEntryBeforeUpdateImpl,\n dependencies: [BlockActionIfModelDisabled]\n });\n"],"names":["BlockModelActionOnEntryBeforeUpdateImpl","blockAction","event","BlockModelActionOnEntryBeforeUpdate","EntryBeforeUpdateEventHandler","BlockActionIfModelDisabled"],"mappings":";;AAGA,MAAMA;IACF,YAAoBC,WAAiD,CAAE;aAAnDA,WAAW,GAAXA;IAAoD;IAExE,MAAM,OAAOC,KAA0C,EAAiB;QACpE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACA,MAAM,OAAO,CAAC,KAAK;IACtD;AACJ;AAEO,MAAMC,sCACTC,8BAA8B,oBAAoB,CAAC;IAC/C,gBAAgBJ;IAChB,cAAc;QAACK;KAA2B;AAC9C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EntryRevisionBeforeCreateEventHandler } from "@webiny/api-headless-cms/features/contentEntry/CreateEntryRevisionFrom/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
declare class BlockModelActionOnEntryRevisionBeforeCreateImpl implements EntryRevisionBeforeCreateEventHandler.Interface {
|
|
4
|
+
private blockAction;
|
|
5
|
+
constructor(blockAction: BlockActionIfModelDisabled.Interface);
|
|
6
|
+
handle(event: EntryRevisionBeforeCreateEventHandler.Event): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const BlockModelActionOnEntryRevisionBeforeCreate: typeof BlockModelActionOnEntryRevisionBeforeCreateImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-headless-cms/features/contentEntry/CreateEntryRevisionFrom/events.js").EntryRevisionBeforeCreateEvent>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EntryRevisionBeforeCreateEventHandler } from "@webiny/api-headless-cms/features/contentEntry/CreateEntryRevisionFrom/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
class BlockModelActionOnEntryRevisionBeforeCreateImpl {
|
|
4
|
+
constructor(blockAction){
|
|
5
|
+
this.blockAction = blockAction;
|
|
6
|
+
}
|
|
7
|
+
async handle(event) {
|
|
8
|
+
await this.blockAction.execute(event.payload.model);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const BlockModelActionOnEntryRevisionBeforeCreate = EntryRevisionBeforeCreateEventHandler.createImplementation({
|
|
12
|
+
implementation: BlockModelActionOnEntryRevisionBeforeCreateImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
BlockActionIfModelDisabled
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { BlockModelActionOnEntryRevisionBeforeCreate };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=BlockModelActionOnEntryRevisionBeforeCreate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/DisableModel/handlers/BlockModelActionOnEntryRevisionBeforeCreate.js","sources":["../../../../src/features/DisableModel/handlers/BlockModelActionOnEntryRevisionBeforeCreate.ts"],"sourcesContent":["import { EntryRevisionBeforeCreateEventHandler } from \"@webiny/api-headless-cms/features/contentEntry/CreateEntryRevisionFrom/events.js\";\nimport { BlockActionIfModelDisabled } from \"../abstractions.js\";\n\nclass BlockModelActionOnEntryRevisionBeforeCreateImpl\n implements EntryRevisionBeforeCreateEventHandler.Interface\n{\n constructor(private blockAction: BlockActionIfModelDisabled.Interface) {}\n\n async handle(event: EntryRevisionBeforeCreateEventHandler.Event): Promise<void> {\n await this.blockAction.execute(event.payload.model);\n }\n}\n\nexport const BlockModelActionOnEntryRevisionBeforeCreate =\n EntryRevisionBeforeCreateEventHandler.createImplementation({\n implementation: BlockModelActionOnEntryRevisionBeforeCreateImpl,\n dependencies: [BlockActionIfModelDisabled]\n });\n"],"names":["BlockModelActionOnEntryRevisionBeforeCreateImpl","blockAction","event","BlockModelActionOnEntryRevisionBeforeCreate","EntryRevisionBeforeCreateEventHandler","BlockActionIfModelDisabled"],"mappings":";;AAGA,MAAMA;IAGF,YAAoBC,WAAiD,CAAE;aAAnDA,WAAW,GAAXA;IAAoD;IAExE,MAAM,OAAOC,KAAkD,EAAiB;QAC5E,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACA,MAAM,OAAO,CAAC,KAAK;IACtD;AACJ;AAEO,MAAMC,8CACTC,sCAAsC,oBAAoB,CAAC;IACvD,gBAAgBJ;IAChB,cAAc;QAACK;KAA2B;AAC9C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModelBeforeCreateFromEventHandler } from "@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
declare class BlockModelActionOnModelBeforeCreateFromImpl implements ModelBeforeCreateFromEventHandler.Interface {
|
|
4
|
+
private blockAction;
|
|
5
|
+
constructor(blockAction: BlockActionIfModelDisabled.Interface);
|
|
6
|
+
handle(event: ModelBeforeCreateFromEventHandler.Event): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const BlockModelActionOnModelBeforeCreateFrom: typeof BlockModelActionOnModelBeforeCreateFromImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js").ModelBeforeCreateFromEvent>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ModelBeforeCreateFromEventHandler } from "@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
class BlockModelActionOnModelBeforeCreateFromImpl {
|
|
4
|
+
constructor(blockAction){
|
|
5
|
+
this.blockAction = blockAction;
|
|
6
|
+
}
|
|
7
|
+
async handle(event) {
|
|
8
|
+
await this.blockAction.execute(event.payload.model);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const BlockModelActionOnModelBeforeCreateFrom = ModelBeforeCreateFromEventHandler.createImplementation({
|
|
12
|
+
implementation: BlockModelActionOnModelBeforeCreateFromImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
BlockActionIfModelDisabled
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { BlockModelActionOnModelBeforeCreateFrom };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=BlockModelActionOnModelBeforeCreateFrom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/DisableModel/handlers/BlockModelActionOnModelBeforeCreateFrom.js","sources":["../../../../src/features/DisableModel/handlers/BlockModelActionOnModelBeforeCreateFrom.ts"],"sourcesContent":["import { ModelBeforeCreateFromEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js\";\nimport { BlockActionIfModelDisabled } from \"../abstractions.js\";\n\nclass BlockModelActionOnModelBeforeCreateFromImpl\n implements ModelBeforeCreateFromEventHandler.Interface\n{\n constructor(private blockAction: BlockActionIfModelDisabled.Interface) {}\n\n async handle(event: ModelBeforeCreateFromEventHandler.Event): Promise<void> {\n await this.blockAction.execute(event.payload.model);\n }\n}\n\nexport const BlockModelActionOnModelBeforeCreateFrom =\n ModelBeforeCreateFromEventHandler.createImplementation({\n implementation: BlockModelActionOnModelBeforeCreateFromImpl,\n dependencies: [BlockActionIfModelDisabled]\n });\n"],"names":["BlockModelActionOnModelBeforeCreateFromImpl","blockAction","event","BlockModelActionOnModelBeforeCreateFrom","ModelBeforeCreateFromEventHandler","BlockActionIfModelDisabled"],"mappings":";;AAGA,MAAMA;IAGF,YAAoBC,WAAiD,CAAE;aAAnDA,WAAW,GAAXA;IAAoD;IAExE,MAAM,OAAOC,KAA8C,EAAiB;QACxE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACA,MAAM,OAAO,CAAC,KAAK;IACtD;AACJ;AAEO,MAAMC,0CACTC,kCAAkC,oBAAoB,CAAC;IACnD,gBAAgBJ;IAChB,cAAc;QAACK;KAA2B;AAC9C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModelBeforeUpdateEventHandler } from "@webiny/api-headless-cms/features/contentModel/UpdateModel/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
declare class BlockModelActionOnModelBeforeUpdateImpl implements ModelBeforeUpdateEventHandler.Interface {
|
|
4
|
+
private blockAction;
|
|
5
|
+
constructor(blockAction: BlockActionIfModelDisabled.Interface);
|
|
6
|
+
handle(event: ModelBeforeUpdateEventHandler.Event): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const BlockModelActionOnModelBeforeUpdate: typeof BlockModelActionOnModelBeforeUpdateImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-headless-cms/features/contentModel/UpdateModel/events.js").ModelBeforeUpdateEvent>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ModelBeforeUpdateEventHandler } from "@webiny/api-headless-cms/features/contentModel/UpdateModel/events.js";
|
|
2
|
+
import { BlockActionIfModelDisabled } from "../abstractions.js";
|
|
3
|
+
class BlockModelActionOnModelBeforeUpdateImpl {
|
|
4
|
+
constructor(blockAction){
|
|
5
|
+
this.blockAction = blockAction;
|
|
6
|
+
}
|
|
7
|
+
async handle(event) {
|
|
8
|
+
await this.blockAction.execute(event.payload.model);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const BlockModelActionOnModelBeforeUpdate = ModelBeforeUpdateEventHandler.createImplementation({
|
|
12
|
+
implementation: BlockModelActionOnModelBeforeUpdateImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
BlockActionIfModelDisabled
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { BlockModelActionOnModelBeforeUpdate };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=BlockModelActionOnModelBeforeUpdate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/DisableModel/handlers/BlockModelActionOnModelBeforeUpdate.js","sources":["../../../../src/features/DisableModel/handlers/BlockModelActionOnModelBeforeUpdate.ts"],"sourcesContent":["import { ModelBeforeUpdateEventHandler } from \"@webiny/api-headless-cms/features/contentModel/UpdateModel/events.js\";\nimport { BlockActionIfModelDisabled } from \"../abstractions.js\";\n\nclass BlockModelActionOnModelBeforeUpdateImpl implements ModelBeforeUpdateEventHandler.Interface {\n constructor(private blockAction: BlockActionIfModelDisabled.Interface) {}\n\n async handle(event: ModelBeforeUpdateEventHandler.Event): Promise<void> {\n await this.blockAction.execute(event.payload.model);\n }\n}\n\nexport const BlockModelActionOnModelBeforeUpdate =\n ModelBeforeUpdateEventHandler.createImplementation({\n implementation: BlockModelActionOnModelBeforeUpdateImpl,\n dependencies: [BlockActionIfModelDisabled]\n });\n"],"names":["BlockModelActionOnModelBeforeUpdateImpl","blockAction","event","BlockModelActionOnModelBeforeUpdate","ModelBeforeUpdateEventHandler","BlockActionIfModelDisabled"],"mappings":";;AAGA,MAAMA;IACF,YAAoBC,WAAiD,CAAE;aAAnDA,WAAW,GAAXA;IAAoD;IAExE,MAAM,OAAOC,KAA0C,EAAiB;QACpE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACA,MAAM,OAAO,CAAC,KAAK;IACtD;AACJ;AAEO,MAAMC,sCACTC,8BAA8B,oBAAoB,CAAC;IAC/C,gBAAgBJ;IAChB,cAAc;QAACK;KAA2B;AAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DisableModelFeature } from "./feature.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DisableModelFeature } from "./feature.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IDeleteCmsModelTask, IStoreValue } from "../../features/DeleteModelTask/types.js";
|
|
2
|
+
export interface IDeleteModelOperations {
|
|
3
|
+
listModelsBeingDeleted(): Promise<IStoreValue[]>;
|
|
4
|
+
isModelBeingDeleted(modelId: string): Promise<boolean>;
|
|
5
|
+
fullyDeleteModel(modelId: string): Promise<IDeleteCmsModelTask>;
|
|
6
|
+
cancelFullyDeleteModel(modelId: string): Promise<IDeleteCmsModelTask>;
|
|
7
|
+
getDeleteModelProgress(modelId: string): Promise<IDeleteCmsModelTask>;
|
|
8
|
+
}
|
|
9
|
+
export declare const DeleteModelOperations: import("@webiny/di").Abstraction<IDeleteModelOperations>;
|
|
10
|
+
export declare namespace DeleteModelOperations {
|
|
11
|
+
type Interface = IDeleteModelOperations;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/deleteModel/abstractions.js","sources":["../../../src/graphql/deleteModel/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { IDeleteCmsModelTask, IStoreValue } from \"~/features/DeleteModelTask/types.js\";\n\nexport interface IDeleteModelOperations {\n listModelsBeingDeleted(): Promise<IStoreValue[]>;\n isModelBeingDeleted(modelId: string): Promise<boolean>;\n fullyDeleteModel(modelId: string): Promise<IDeleteCmsModelTask>;\n cancelFullyDeleteModel(modelId: string): Promise<IDeleteCmsModelTask>;\n getDeleteModelProgress(modelId: string): Promise<IDeleteCmsModelTask>;\n}\n\nexport const DeleteModelOperations =\n createAbstraction<IDeleteModelOperations>(\"DeleteModelOperations\");\n\nexport namespace DeleteModelOperations {\n export type Interface = IDeleteModelOperations;\n}\n"],"names":["DeleteModelOperations","createAbstraction"],"mappings":";AAWO,MAAMA,wBACTC,kBAA0C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HcmsTasksContext } from "../../types.js";
|
|
2
|
+
import type { IDeleteCmsModelTask } from "../../features/DeleteModelTask/types.js";
|
|
3
|
+
export interface ICancelDeleteModelParams {
|
|
4
|
+
readonly context: Pick<HcmsTasksContext, "container">;
|
|
5
|
+
readonly modelId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const cancelDeleteModel: (params: ICancelDeleteModelParams) => Promise<IDeleteCmsModelTask>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
import { createDeleteModelStore } from "../../helpers/store.js";
|
|
3
|
+
import { DELETE_MODEL_TASK } from "../../constants.js";
|
|
4
|
+
import { getStatus } from "./status.js";
|
|
5
|
+
import { NotAuthorizedError } from "@webiny/api-headless-cms/utils/errors.js";
|
|
6
|
+
import { AccessControl } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
7
|
+
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
8
|
+
import { GlobalKeyValueStore } from "@webiny/api-core/features/keyValueStore/abstractions.js";
|
|
9
|
+
import { AbortTaskUseCase, GetTaskUseCase } from "@webiny/background-tasks/api";
|
|
10
|
+
const cancelDeleteModel = async (params)=>{
|
|
11
|
+
const { context, modelId } = params;
|
|
12
|
+
const modelResult = await context.container.resolve(GetModelUseCase).execute(modelId);
|
|
13
|
+
if (modelResult.isFail()) throw modelResult.error;
|
|
14
|
+
const model = modelResult.value;
|
|
15
|
+
const accessControl = context.container.resolve(AccessControl);
|
|
16
|
+
const canAccessModel = await accessControl.canAccessModel({
|
|
17
|
+
model,
|
|
18
|
+
rwd: "d"
|
|
19
|
+
});
|
|
20
|
+
if (!canAccessModel) throw new NotAuthorizedError(`Not allowed to access content model "${model.name}".`);
|
|
21
|
+
const canAccessEntry = await accessControl.canAccessEntry({
|
|
22
|
+
model,
|
|
23
|
+
rwd: "w"
|
|
24
|
+
});
|
|
25
|
+
if (!canAccessEntry) throw new NotAuthorizedError(`Not allowed to access "${model.modelId}" entries.`);
|
|
26
|
+
const store = createDeleteModelStore(context.container.resolve(GlobalKeyValueStore), model.tenant);
|
|
27
|
+
const existing = await store.get(model.modelId);
|
|
28
|
+
const taskId = existing?.task;
|
|
29
|
+
await store.remove(model.modelId);
|
|
30
|
+
if (!taskId) throw new WebinyError({
|
|
31
|
+
message: `Model "${modelId}" is not being deleted.`,
|
|
32
|
+
code: "MODEL_NOT_BEING_DELETED"
|
|
33
|
+
});
|
|
34
|
+
const task = await context.container.resolve(GetTaskUseCase).execute(taskId);
|
|
35
|
+
if (task?.definitionId !== DELETE_MODEL_TASK) throw new WebinyError({
|
|
36
|
+
message: `The task which is deleting a model cannot be found. Please check Step Functions for more info. Task id: ${taskId}`,
|
|
37
|
+
code: "DELETE_MODEL_TASK_NOT_FOUND",
|
|
38
|
+
data: {
|
|
39
|
+
model: model.modelId,
|
|
40
|
+
task: taskId
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const abortResult = await context.container.resolve(AbortTaskUseCase).execute({
|
|
44
|
+
id: task.id,
|
|
45
|
+
message: "User canceled the task."
|
|
46
|
+
});
|
|
47
|
+
const canceledTask = abortResult.value;
|
|
48
|
+
return {
|
|
49
|
+
id: canceledTask.id,
|
|
50
|
+
status: getStatus(canceledTask.taskStatus),
|
|
51
|
+
total: canceledTask.output?.total || 0,
|
|
52
|
+
deleted: canceledTask.output?.deleted || 0
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export { cancelDeleteModel };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=cancelDeleteModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/deleteModel/cancelDeleteModel.js","sources":["../../../src/graphql/deleteModel/cancelDeleteModel.ts"],"sourcesContent":["import type { HcmsTasksContext } from \"~/types.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport type {\n IDeleteCmsModelTask,\n IDeleteModelTaskInput,\n IDeleteModelTaskOutput\n} from \"~/features/DeleteModelTask/types.js\";\nimport { createDeleteModelStore } from \"~/helpers/store.js\";\nimport { DELETE_MODEL_TASK } from \"~/constants.js\";\nimport { getStatus } from \"~/graphql/deleteModel/status.js\";\nimport { NotAuthorizedError } from \"@webiny/api-headless-cms/utils/errors.js\";\nimport { AccessControl } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { GlobalKeyValueStore } from \"@webiny/api-core/features/keyValueStore/abstractions.js\";\nimport { GetTaskUseCase, AbortTaskUseCase } from \"@webiny/background-tasks/api\";\n\nexport interface ICancelDeleteModelParams {\n readonly context: Pick<HcmsTasksContext, \"container\">;\n readonly modelId: string;\n}\n\nexport const cancelDeleteModel = async (\n params: ICancelDeleteModelParams\n): Promise<IDeleteCmsModelTask> => {\n const { context, modelId } = params;\n\n const modelResult = await context.container.resolve(GetModelUseCase).execute(modelId);\n if (modelResult.isFail()) {\n throw modelResult.error;\n }\n const model = modelResult.value;\n const accessControl = context.container.resolve(AccessControl);\n\n const canAccessModel = await accessControl.canAccessModel({ model, rwd: \"d\" });\n if (!canAccessModel) {\n throw new NotAuthorizedError(`Not allowed to access content model \"${model.name}\".`);\n }\n\n const canAccessEntry = await accessControl.canAccessEntry({ model, rwd: \"w\" });\n if (!canAccessEntry) {\n throw new NotAuthorizedError(`Not allowed to access \"${model.modelId}\" entries.`);\n }\n\n const store = createDeleteModelStore(\n context.container.resolve(GlobalKeyValueStore),\n model.tenant\n );\n const existing = await store.get(model.modelId);\n const taskId = existing?.task;\n\n await store.remove(model.modelId);\n if (!taskId) {\n throw new WebinyError({\n message: `Model \"${modelId}\" is not being deleted.`,\n code: \"MODEL_NOT_BEING_DELETED\"\n });\n }\n\n const task = await context.container\n .resolve(GetTaskUseCase)\n .execute<IDeleteModelTaskInput, IDeleteModelTaskOutput>(taskId);\n if (task?.definitionId !== DELETE_MODEL_TASK) {\n throw new WebinyError({\n message: `The task which is deleting a model cannot be found. Please check Step Functions for more info. Task id: ${taskId}`,\n code: \"DELETE_MODEL_TASK_NOT_FOUND\",\n data: {\n model: model.modelId,\n task: taskId\n }\n });\n }\n\n const abortResult = await context.container\n .resolve(AbortTaskUseCase)\n .execute<IDeleteModelTaskInput, IDeleteModelTaskOutput>({\n id: task.id,\n message: \"User canceled the task.\"\n });\n\n const canceledTask = abortResult.value;\n\n return {\n id: canceledTask.id,\n status: getStatus(canceledTask.taskStatus),\n total: canceledTask.output?.total || 0,\n deleted: canceledTask.output?.deleted || 0\n };\n};\n"],"names":["cancelDeleteModel","params","context","modelId","modelResult","GetModelUseCase","model","accessControl","AccessControl","canAccessModel","NotAuthorizedError","canAccessEntry","store","createDeleteModelStore","GlobalKeyValueStore","existing","taskId","WebinyError","task","GetTaskUseCase","DELETE_MODEL_TASK","abortResult","AbortTaskUseCase","canceledTask","getStatus"],"mappings":";;;;;;;;;AAqBO,MAAMA,oBAAoB,OAC7BC;IAEA,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGF;IAE7B,MAAMG,cAAc,MAAMF,QAAQ,SAAS,CAAC,OAAO,CAACG,iBAAiB,OAAO,CAACF;IAC7E,IAAIC,YAAY,MAAM,IAClB,MAAMA,YAAY,KAAK;IAE3B,MAAME,QAAQF,YAAY,KAAK;IAC/B,MAAMG,gBAAgBL,QAAQ,SAAS,CAAC,OAAO,CAACM;IAEhD,MAAMC,iBAAiB,MAAMF,cAAc,cAAc,CAAC;QAAED;QAAO,KAAK;IAAI;IAC5E,IAAI,CAACG,gBACD,MAAM,IAAIC,mBAAmB,CAAC,qCAAqC,EAAEJ,MAAM,IAAI,CAAC,EAAE,CAAC;IAGvF,MAAMK,iBAAiB,MAAMJ,cAAc,cAAc,CAAC;QAAED;QAAO,KAAK;IAAI;IAC5E,IAAI,CAACK,gBACD,MAAM,IAAID,mBAAmB,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,UAAU,CAAC;IAGpF,MAAMM,QAAQC,uBACVX,QAAQ,SAAS,CAAC,OAAO,CAACY,sBAC1BR,MAAM,MAAM;IAEhB,MAAMS,WAAW,MAAMH,MAAM,GAAG,CAACN,MAAM,OAAO;IAC9C,MAAMU,SAASD,UAAU;IAEzB,MAAMH,MAAM,MAAM,CAACN,MAAM,OAAO;IAChC,IAAI,CAACU,QACD,MAAM,IAAIC,YAAY;QAClB,SAAS,CAAC,OAAO,EAAEd,QAAQ,uBAAuB,CAAC;QACnD,MAAM;IACV;IAGJ,MAAMe,OAAO,MAAMhB,QAAQ,SAAS,CAC/B,OAAO,CAACiB,gBACR,OAAO,CAAgDH;IAC5D,IAAIE,MAAM,iBAAiBE,mBACvB,MAAM,IAAIH,YAAY;QAClB,SAAS,CAAC,wGAAwG,EAAED,QAAQ;QAC5H,MAAM;QACN,MAAM;YACF,OAAOV,MAAM,OAAO;YACpB,MAAMU;QACV;IACJ;IAGJ,MAAMK,cAAc,MAAMnB,QAAQ,SAAS,CACtC,OAAO,CAACoB,kBACR,OAAO,CAAgD;QACpD,IAAIJ,KAAK,EAAE;QACX,SAAS;IACb;IAEJ,MAAMK,eAAeF,YAAY,KAAK;IAEtC,OAAO;QACH,IAAIE,aAAa,EAAE;QACnB,QAAQC,UAAUD,aAAa,UAAU;QACzC,OAAOA,aAAa,MAAM,EAAE,SAAS;QACrC,SAASA,aAAa,MAAM,EAAE,WAAW;IAC7C;AACJ"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/abstractions.js";
|
|
2
|
+
import { GlobalKeyValueStore } from "@webiny/api-core/features/keyValueStore/abstractions.js";
|
|
3
|
+
import { createCacheKey, createMemoryCache } from "@webiny/api-headless-cms/utils/index.js";
|
|
4
|
+
import { DisableModelFeature } from "../../features/DisableModel/feature.js";
|
|
5
|
+
import { createDeleteModelStore } from "../../helpers/store.js";
|
|
6
|
+
import { fullyDeleteModel } from "./fullyDeleteModel.js";
|
|
7
|
+
import { cancelDeleteModel } from "./cancelDeleteModel.js";
|
|
8
|
+
import { getDeleteModelProgress } from "./getDeleteModelProgress.js";
|
|
9
|
+
import { DeleteModelOperations } from "./abstractions.js";
|
|
10
|
+
const createDeleteModelCrud = ()=>({
|
|
11
|
+
async init (context) {
|
|
12
|
+
const getTenant = ()=>context.container.resolve(TenantContext).getTenant().id;
|
|
13
|
+
const getStore = ()=>createDeleteModelStore(context.container.resolve(GlobalKeyValueStore), getTenant());
|
|
14
|
+
const cache = createMemoryCache();
|
|
15
|
+
const listModelsBeingDeleted = async ()=>{
|
|
16
|
+
const cacheKey = createCacheKey({
|
|
17
|
+
tenant: getTenant(),
|
|
18
|
+
type: "deleteModel"
|
|
19
|
+
});
|
|
20
|
+
return cache.getOrSet(cacheKey, ()=>getStore().list());
|
|
21
|
+
};
|
|
22
|
+
const isModelBeingDeleted = async (modelId)=>{
|
|
23
|
+
const items = await listModelsBeingDeleted();
|
|
24
|
+
return items.some((item)=>item.modelId === modelId);
|
|
25
|
+
};
|
|
26
|
+
const operations = {
|
|
27
|
+
listModelsBeingDeleted,
|
|
28
|
+
isModelBeingDeleted,
|
|
29
|
+
fullyDeleteModel: async (modelId)=>{
|
|
30
|
+
const result = await fullyDeleteModel({
|
|
31
|
+
context,
|
|
32
|
+
modelId
|
|
33
|
+
});
|
|
34
|
+
cache.clear();
|
|
35
|
+
return result;
|
|
36
|
+
},
|
|
37
|
+
cancelFullyDeleteModel: async (modelId)=>{
|
|
38
|
+
const result = await cancelDeleteModel({
|
|
39
|
+
context,
|
|
40
|
+
modelId
|
|
41
|
+
});
|
|
42
|
+
cache.clear();
|
|
43
|
+
return result;
|
|
44
|
+
},
|
|
45
|
+
getDeleteModelProgress: async (modelId)=>getDeleteModelProgress({
|
|
46
|
+
context,
|
|
47
|
+
modelId
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
context.container.registerInstance(DeleteModelOperations, operations);
|
|
51
|
+
DisableModelFeature.register(context.container);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
export { createDeleteModelCrud };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=crud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/deleteModel/crud.js","sources":["../../../src/graphql/deleteModel/crud.ts"],"sourcesContent":["import type { HcmsTasksContext } from \"~/types.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/abstractions.js\";\nimport { GlobalKeyValueStore } from \"@webiny/api-core/features/keyValueStore/abstractions.js\";\nimport { createCacheKey } from \"@webiny/api-headless-cms/utils/index.js\";\nimport { createMemoryCache } from \"@webiny/api-headless-cms/utils/index.js\";\nimport type { IStoreValue } from \"~/features/DeleteModelTask/types.js\";\nimport type { RequestContextInitializer } from \"@webiny/event-handler-core\";\nimport { DisableModelFeature } from \"~/features/DisableModel/feature.js\";\nimport { createDeleteModelStore } from \"~/helpers/store.js\";\nimport { fullyDeleteModel } from \"~/graphql/deleteModel/fullyDeleteModel.js\";\nimport { cancelDeleteModel } from \"~/graphql/deleteModel/cancelDeleteModel.js\";\nimport { getDeleteModelProgress } from \"~/graphql/deleteModel/getDeleteModelProgress.js\";\nimport { DeleteModelOperations } from \"~/graphql/deleteModel/abstractions.js\";\n\nexport const createDeleteModelCrud = (): RequestContextInitializer.Interface => ({\n async init(context: HcmsTasksContext) {\n const getTenant = (): string => {\n return context.container.resolve(TenantContext).getTenant().id;\n };\n\n const getStore = () => {\n return createDeleteModelStore(\n context.container.resolve(GlobalKeyValueStore),\n getTenant()\n );\n };\n\n const cache = createMemoryCache<Promise<IStoreValue[]>>();\n\n const listModelsBeingDeleted = async (): Promise<IStoreValue[]> => {\n const cacheKey = createCacheKey({\n tenant: getTenant(),\n type: \"deleteModel\"\n });\n\n return cache.getOrSet(cacheKey, () => getStore().list());\n };\n\n const isModelBeingDeleted = async (modelId: string): Promise<boolean> => {\n const items = await listModelsBeingDeleted();\n return items.some(item => item.modelId === modelId);\n };\n\n const operations: DeleteModelOperations.Interface = {\n listModelsBeingDeleted,\n isModelBeingDeleted,\n fullyDeleteModel: async (modelId: string) => {\n const result = await fullyDeleteModel({ context, modelId });\n cache.clear();\n return result;\n },\n cancelFullyDeleteModel: async (modelId: string) => {\n const result = await cancelDeleteModel({ context, modelId });\n cache.clear();\n return result;\n },\n getDeleteModelProgress: async (modelId: string) => {\n return getDeleteModelProgress({ context, modelId });\n }\n };\n\n context.container.registerInstance(DeleteModelOperations, operations);\n\n DisableModelFeature.register(context.container);\n }\n});\n"],"names":["createDeleteModelCrud","context","getTenant","TenantContext","getStore","createDeleteModelStore","GlobalKeyValueStore","cache","createMemoryCache","listModelsBeingDeleted","cacheKey","createCacheKey","isModelBeingDeleted","modelId","items","item","operations","result","fullyDeleteModel","cancelDeleteModel","getDeleteModelProgress","DeleteModelOperations","DisableModelFeature"],"mappings":";;;;;;;;;AAcO,MAAMA,wBAAwB,IAA4C;QAC7E,MAAM,MAAKC,OAAyB;YAChC,MAAMC,YAAY,IACPD,QAAQ,SAAS,CAAC,OAAO,CAACE,eAAe,SAAS,GAAG,EAAE;YAGlE,MAAMC,WAAW,IACNC,uBACHJ,QAAQ,SAAS,CAAC,OAAO,CAACK,sBAC1BJ;YAIR,MAAMK,QAAQC;YAEd,MAAMC,yBAAyB;gBAC3B,MAAMC,WAAWC,eAAe;oBAC5B,QAAQT;oBACR,MAAM;gBACV;gBAEA,OAAOK,MAAM,QAAQ,CAACG,UAAU,IAAMN,WAAW,IAAI;YACzD;YAEA,MAAMQ,sBAAsB,OAAOC;gBAC/B,MAAMC,QAAQ,MAAML;gBACpB,OAAOK,MAAM,IAAI,CAACC,CAAAA,OAAQA,KAAK,OAAO,KAAKF;YAC/C;YAEA,MAAMG,aAA8C;gBAChDP;gBACAG;gBACA,kBAAkB,OAAOC;oBACrB,MAAMI,SAAS,MAAMC,iBAAiB;wBAAEjB;wBAASY;oBAAQ;oBACzDN,MAAM,KAAK;oBACX,OAAOU;gBACX;gBACA,wBAAwB,OAAOJ;oBAC3B,MAAMI,SAAS,MAAME,kBAAkB;wBAAElB;wBAASY;oBAAQ;oBAC1DN,MAAM,KAAK;oBACX,OAAOU;gBACX;gBACA,wBAAwB,OAAOJ,UACpBO,uBAAuB;wBAAEnB;wBAASY;oBAAQ;YAEzD;YAEAZ,QAAQ,SAAS,CAAC,gBAAgB,CAACoB,uBAAuBL;YAE1DM,oBAAoB,QAAQ,CAACrB,QAAQ,SAAS;QAClD;IACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HcmsTasksContext } from "../../types.js";
|
|
2
|
+
import type { IDeleteCmsModelTask } from "../../features/DeleteModelTask/types.js";
|
|
3
|
+
export interface IFullyDeleteModelParams {
|
|
4
|
+
readonly context: Pick<HcmsTasksContext, "container">;
|
|
5
|
+
readonly modelId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const fullyDeleteModel: (params: IFullyDeleteModelParams) => Promise<IDeleteCmsModelTask>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
2
|
+
import { createDeleteModelStore, createStoreValue } from "../../helpers/store.js";
|
|
3
|
+
import { DELETE_MODEL_TASK } from "../../constants.js";
|
|
4
|
+
import { getStatus } from "./status.js";
|
|
5
|
+
import { NotAuthorizedError } from "@webiny/api-headless-cms/utils/errors.js";
|
|
6
|
+
import { AccessControl } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
7
|
+
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
8
|
+
import { GlobalKeyValueStore } from "@webiny/api-core/features/keyValueStore/abstractions.js";
|
|
9
|
+
import { TriggerTaskUseCase } from "@webiny/background-tasks/api";
|
|
10
|
+
const fullyDeleteModel = async (params)=>{
|
|
11
|
+
const { context, modelId } = params;
|
|
12
|
+
const modelResult = await context.container.resolve(GetModelUseCase).execute(modelId);
|
|
13
|
+
if (modelResult.isFail()) throw modelResult.error;
|
|
14
|
+
const model = modelResult.value;
|
|
15
|
+
if (model.isPrivate) throw new Error("Cannot delete private model.");
|
|
16
|
+
const accessControl = context.container.resolve(AccessControl);
|
|
17
|
+
const canAccessModel = await accessControl.canAccessModel({
|
|
18
|
+
model,
|
|
19
|
+
rwd: "d"
|
|
20
|
+
});
|
|
21
|
+
if (!canAccessModel) throw new NotAuthorizedError(`Not allowed to access content model "${model.name}".`);
|
|
22
|
+
const canAccessEntry = await accessControl.canAccessEntry({
|
|
23
|
+
model,
|
|
24
|
+
rwd: "w"
|
|
25
|
+
});
|
|
26
|
+
if (!canAccessEntry) throw new NotAuthorizedError(`Not allowed to access "${model.modelId}" entries.`);
|
|
27
|
+
if (!model) throw new Error(`Model "${modelId}" not found.`);
|
|
28
|
+
const store = createDeleteModelStore(context.container.resolve(GlobalKeyValueStore), model.tenant);
|
|
29
|
+
const existing = await store.get(model.modelId);
|
|
30
|
+
if (existing?.task) throw new Error(`Model "${modelId}" is already getting deleted. Task id: ${existing.task}.`);
|
|
31
|
+
const triggerResult = await context.container.resolve(TriggerTaskUseCase).execute({
|
|
32
|
+
input: {
|
|
33
|
+
modelId
|
|
34
|
+
},
|
|
35
|
+
definition: DELETE_MODEL_TASK,
|
|
36
|
+
name: `Fully delete model: ${modelId}`
|
|
37
|
+
});
|
|
38
|
+
const task = triggerResult.value;
|
|
39
|
+
const identity = context.container.resolve(IdentityContext).getIdentity();
|
|
40
|
+
await store.set(createStoreValue({
|
|
41
|
+
...model,
|
|
42
|
+
identity: {
|
|
43
|
+
id: identity.id,
|
|
44
|
+
type: identity.type,
|
|
45
|
+
displayName: identity.displayName
|
|
46
|
+
},
|
|
47
|
+
task: task.id
|
|
48
|
+
}));
|
|
49
|
+
return {
|
|
50
|
+
id: task.id,
|
|
51
|
+
status: getStatus(task.taskStatus),
|
|
52
|
+
total: 0,
|
|
53
|
+
deleted: 0
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export { fullyDeleteModel };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=fullyDeleteModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/deleteModel/fullyDeleteModel.js","sources":["../../../src/graphql/deleteModel/fullyDeleteModel.ts"],"sourcesContent":["import type { HcmsTasksContext } from \"~/types.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport type {\n IDeleteCmsModelTask,\n IDeleteModelTaskInput\n} from \"~/features/DeleteModelTask/types.js\";\nimport { createDeleteModelStore, createStoreValue } from \"~/helpers/store.js\";\nimport { DELETE_MODEL_TASK } from \"~/constants.js\";\nimport { getStatus } from \"~/graphql/deleteModel/status.js\";\nimport { NotAuthorizedError } from \"@webiny/api-headless-cms/utils/errors.js\";\nimport { AccessControl } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { GlobalKeyValueStore } from \"@webiny/api-core/features/keyValueStore/abstractions.js\";\nimport { TriggerTaskUseCase } from \"@webiny/background-tasks/api\";\n\nexport interface IFullyDeleteModelParams {\n readonly context: Pick<HcmsTasksContext, \"container\">;\n readonly modelId: string;\n}\n\nexport const fullyDeleteModel = async (\n params: IFullyDeleteModelParams\n): Promise<IDeleteCmsModelTask> => {\n const { context, modelId } = params;\n\n const modelResult = await context.container.resolve(GetModelUseCase).execute(modelId);\n if (modelResult.isFail()) {\n throw modelResult.error;\n }\n const model = modelResult.value;\n\n if (model.isPrivate) {\n throw new Error(`Cannot delete private model.`);\n }\n\n const accessControl = context.container.resolve(AccessControl);\n const canAccessModel = await accessControl.canAccessModel({ model, rwd: \"d\" });\n if (!canAccessModel) {\n throw new NotAuthorizedError(`Not allowed to access content model \"${model.name}\".`);\n }\n\n const canAccessEntry = await accessControl.canAccessEntry({ model, rwd: \"w\" });\n if (!canAccessEntry) {\n throw new NotAuthorizedError(`Not allowed to access \"${model.modelId}\" entries.`);\n }\n\n if (!model) {\n throw new Error(`Model \"${modelId}\" not found.`);\n }\n const store = createDeleteModelStore(\n context.container.resolve(GlobalKeyValueStore),\n model.tenant\n );\n const existing = await store.get(model.modelId);\n if (existing?.task) {\n throw new Error(\n `Model \"${modelId}\" is already getting deleted. Task id: ${existing.task}.`\n );\n }\n\n const triggerResult = await context.container\n .resolve(TriggerTaskUseCase)\n .execute<IDeleteModelTaskInput>({\n input: {\n modelId\n },\n definition: DELETE_MODEL_TASK,\n name: `Fully delete model: ${modelId}`\n });\n\n const task = triggerResult.value;\n\n const identity = context.container.resolve(IdentityContext).getIdentity();\n\n await store.set(\n createStoreValue({\n ...model,\n identity: {\n id: identity.id,\n type: identity.type,\n displayName: identity.displayName\n },\n task: task.id\n })\n );\n\n return {\n id: task.id,\n status: getStatus(task.taskStatus),\n total: 0,\n deleted: 0\n };\n};\n"],"names":["fullyDeleteModel","params","context","modelId","modelResult","GetModelUseCase","model","Error","accessControl","AccessControl","canAccessModel","NotAuthorizedError","canAccessEntry","store","createDeleteModelStore","GlobalKeyValueStore","existing","triggerResult","TriggerTaskUseCase","DELETE_MODEL_TASK","task","identity","IdentityContext","createStoreValue","getStatus"],"mappings":";;;;;;;;;AAoBO,MAAMA,mBAAmB,OAC5BC;IAEA,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGF;IAE7B,MAAMG,cAAc,MAAMF,QAAQ,SAAS,CAAC,OAAO,CAACG,iBAAiB,OAAO,CAACF;IAC7E,IAAIC,YAAY,MAAM,IAClB,MAAMA,YAAY,KAAK;IAE3B,MAAME,QAAQF,YAAY,KAAK;IAE/B,IAAIE,MAAM,SAAS,EACf,MAAM,IAAIC,MAAM;IAGpB,MAAMC,gBAAgBN,QAAQ,SAAS,CAAC,OAAO,CAACO;IAChD,MAAMC,iBAAiB,MAAMF,cAAc,cAAc,CAAC;QAAEF;QAAO,KAAK;IAAI;IAC5E,IAAI,CAACI,gBACD,MAAM,IAAIC,mBAAmB,CAAC,qCAAqC,EAAEL,MAAM,IAAI,CAAC,EAAE,CAAC;IAGvF,MAAMM,iBAAiB,MAAMJ,cAAc,cAAc,CAAC;QAAEF;QAAO,KAAK;IAAI;IAC5E,IAAI,CAACM,gBACD,MAAM,IAAID,mBAAmB,CAAC,uBAAuB,EAAEL,MAAM,OAAO,CAAC,UAAU,CAAC;IAGpF,IAAI,CAACA,OACD,MAAM,IAAIC,MAAM,CAAC,OAAO,EAAEJ,QAAQ,YAAY,CAAC;IAEnD,MAAMU,QAAQC,uBACVZ,QAAQ,SAAS,CAAC,OAAO,CAACa,sBAC1BT,MAAM,MAAM;IAEhB,MAAMU,WAAW,MAAMH,MAAM,GAAG,CAACP,MAAM,OAAO;IAC9C,IAAIU,UAAU,MACV,MAAM,IAAIT,MACN,CAAC,OAAO,EAAEJ,QAAQ,uCAAuC,EAAEa,SAAS,IAAI,CAAC,CAAC,CAAC;IAInF,MAAMC,gBAAgB,MAAMf,QAAQ,SAAS,CACxC,OAAO,CAACgB,oBACR,OAAO,CAAwB;QAC5B,OAAO;YACHf;QACJ;QACA,YAAYgB;QACZ,MAAM,CAAC,oBAAoB,EAAEhB,SAAS;IAC1C;IAEJ,MAAMiB,OAAOH,cAAc,KAAK;IAEhC,MAAMI,WAAWnB,QAAQ,SAAS,CAAC,OAAO,CAACoB,iBAAiB,WAAW;IAEvE,MAAMT,MAAM,GAAG,CACXU,iBAAiB;QACb,GAAGjB,KAAK;QACR,UAAU;YACN,IAAIe,SAAS,EAAE;YACf,MAAMA,SAAS,IAAI;YACnB,aAAaA,SAAS,WAAW;QACrC;QACA,MAAMD,KAAK,EAAE;IACjB;IAGJ,OAAO;QACH,IAAIA,KAAK,EAAE;QACX,QAAQI,UAAUJ,KAAK,UAAU;QACjC,OAAO;QACP,SAAS;IACb;AACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HcmsTasksContext } from "../../types.js";
|
|
2
|
+
import type { IDeleteCmsModelTask } from "../../features/DeleteModelTask/types.js";
|
|
3
|
+
export interface IGetDeleteModelProgress {
|
|
4
|
+
readonly context: Pick<HcmsTasksContext, "container">;
|
|
5
|
+
readonly modelId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const getDeleteModelProgress: (params: IGetDeleteModelProgress) => Promise<IDeleteCmsModelTask>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
import { NotFoundError } from "@webiny/api-graphql";
|
|
3
|
+
import { createDeleteModelStore } from "../../helpers/store.js";
|
|
4
|
+
import { DELETE_MODEL_TASK } from "../../constants.js";
|
|
5
|
+
import { getStatus } from "./status.js";
|
|
6
|
+
import { NotAuthorizedError } from "@webiny/api-headless-cms/utils/errors.js";
|
|
7
|
+
import { AccessControl } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
8
|
+
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
9
|
+
import { GlobalKeyValueStore } from "@webiny/api-core/features/keyValueStore/abstractions.js";
|
|
10
|
+
import { GetTaskUseCase } from "@webiny/background-tasks/api";
|
|
11
|
+
const getDeleteModelProgress = async (params)=>{
|
|
12
|
+
const { context, modelId } = params;
|
|
13
|
+
let model;
|
|
14
|
+
try {
|
|
15
|
+
const modelResult = await context.container.resolve(GetModelUseCase).execute(modelId);
|
|
16
|
+
if (modelResult.isFail()) throw modelResult.error;
|
|
17
|
+
model = modelResult.value;
|
|
18
|
+
} catch (ex) {
|
|
19
|
+
if (ex instanceof NotFoundError === false) throw ex;
|
|
20
|
+
throw new WebinyError({
|
|
21
|
+
message: "Model not found. It must have been deleted already.",
|
|
22
|
+
code: "MODEL_ALREADY_DELETED_FOUND",
|
|
23
|
+
data: {
|
|
24
|
+
model: modelId
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const accessControl = context.container.resolve(AccessControl);
|
|
29
|
+
const canAccessModel = await accessControl.canAccessModel({
|
|
30
|
+
model,
|
|
31
|
+
rwd: "d"
|
|
32
|
+
});
|
|
33
|
+
if (!canAccessModel) throw new NotAuthorizedError(`Not allowed to access content model "${model.name}".`);
|
|
34
|
+
const canAccessEntry = await accessControl.canAccessEntry({
|
|
35
|
+
model,
|
|
36
|
+
rwd: "w"
|
|
37
|
+
});
|
|
38
|
+
if (!canAccessEntry) throw new NotAuthorizedError(`Not allowed to access "${model.modelId}" entries.`);
|
|
39
|
+
const store = createDeleteModelStore(context.container.resolve(GlobalKeyValueStore), model.tenant);
|
|
40
|
+
const existing = await store.get(model.modelId);
|
|
41
|
+
const taskId = existing?.task;
|
|
42
|
+
if (!taskId) throw new Error(`Model "${modelId}" is not being deleted.`);
|
|
43
|
+
const task = await context.container.resolve(GetTaskUseCase).execute(taskId);
|
|
44
|
+
if (task?.definitionId !== DELETE_MODEL_TASK) throw new WebinyError({
|
|
45
|
+
message: "The task which is deleting a model cannot be found.",
|
|
46
|
+
code: "DELETE_MODEL_TASK_NOT_FOUND",
|
|
47
|
+
data: {
|
|
48
|
+
model: model.modelId,
|
|
49
|
+
task: taskId
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
id: task.id,
|
|
54
|
+
status: getStatus(task.taskStatus),
|
|
55
|
+
total: task.output?.total || 0,
|
|
56
|
+
deleted: task.output?.deleted || 0
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export { getDeleteModelProgress };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=getDeleteModelProgress.js.map
|