@webiny/api-headless-cms-tasks 0.0.0-unstable.e622468070 → 0.0.0-unstable.e6f0dc8ca7
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/features/DeleteModelTask/DeleteModelTask.d.ts +1 -0
- package/features/DeleteModelTask/DeleteModelTask.js +1 -0
- package/features/DeleteModelTask/DeleteModelTask.js.map +1 -1
- package/features/DeleteModelTask/feature.d.ts +4 -1
- package/features/DisableModel/feature.d.ts +4 -1
- package/features/DisableModel/feature.js.map +1 -1
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeCreate.d.ts +1 -1
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeMove.d.ts +1 -1
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforePublish.d.ts +1 -1
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeRepublish.d.ts +1 -1
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeRestoreFromBin.d.ts +1 -1
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeUnpublish.d.ts +1 -1
- package/features/DisableModel/handlers/BlockModelActionOnEntryBeforeUpdate.d.ts +1 -1
- package/features/DisableModel/handlers/BlockModelActionOnEntryRevisionBeforeCreate.d.ts +1 -1
- package/features/DisableModel/handlers/BlockModelActionOnModelBeforeCreateFrom.d.ts +1 -1
- package/features/DisableModel/handlers/BlockModelActionOnModelBeforeUpdate.d.ts +1 -1
- package/graphql/deleteModel/cancelDeleteModel.d.ts +1 -1
- package/graphql/deleteModel/cancelDeleteModel.js +11 -2
- package/graphql/deleteModel/cancelDeleteModel.js.map +1 -1
- package/graphql/deleteModel/fullyDeleteModel.js +9 -2
- package/graphql/deleteModel/fullyDeleteModel.js.map +1 -1
- package/graphql/deleteModel/getDeleteModelProgress.js +9 -2
- package/graphql/deleteModel/getDeleteModelProgress.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -2
- package/index.js.map +1 -1
- package/package.json +26 -24
|
@@ -11,6 +11,7 @@ declare class DeleteModelTaskDefinition implements TaskDefinition.Interface<IDel
|
|
|
11
11
|
isPrivate: boolean;
|
|
12
12
|
databaseLogs: boolean;
|
|
13
13
|
description: string;
|
|
14
|
+
readonly selfCleanup: ("onSuccess" | "onAbort")[];
|
|
14
15
|
constructor(context: CmsContext.Interface);
|
|
15
16
|
run(params: IRunParams): Promise<TaskDefinition.Result<IDeleteModelTaskInput, IDeleteModelTaskOutput>>;
|
|
16
17
|
createInputValidation({ validator }: TaskDefinition.CreateInputValidationParams): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TaskDefinition","CmsContext","DELETE_MODEL_TASK","DeleteModelTaskDefinition","id","title","maxIterations","isPrivate","databaseLogs","description","constructor","context","run","params","DeleteModel","runner","ex","controller","response","error","createInputValidation","validator","modelId","string","lastDeletedId","optional","DeleteModelTask","createImplementation","implementation","dependencies"],"sources":["DeleteModelTask.ts"],"sourcesContent":["import type { IDeleteModelTaskInput } from \"./types.js\";\nimport type { IDeleteModelTaskOutput } from \"./types.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { DELETE_MODEL_TASK } from \"~/constants.js\";\n\ntype IRunParams = TaskDefinition.RunParams<IDeleteModelTaskInput, IDeleteModelTaskOutput>;\n\nclass DeleteModelTaskDefinition
|
|
1
|
+
{"version":3,"names":["TaskDefinition","CmsContext","DELETE_MODEL_TASK","DeleteModelTaskDefinition","id","title","maxIterations","isPrivate","databaseLogs","description","selfCleanup","constructor","context","run","params","DeleteModel","runner","ex","controller","response","error","createInputValidation","validator","modelId","string","lastDeletedId","optional","DeleteModelTask","createImplementation","implementation","dependencies"],"sources":["DeleteModelTask.ts"],"sourcesContent":["import type { IDeleteModelTaskInput } from \"./types.js\";\nimport type { IDeleteModelTaskOutput } from \"./types.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { DELETE_MODEL_TASK } from \"~/constants.js\";\n\ntype IRunParams = TaskDefinition.RunParams<IDeleteModelTaskInput, IDeleteModelTaskOutput>;\n\nclass DeleteModelTaskDefinition implements TaskDefinition.Interface<\n IDeleteModelTaskInput,\n IDeleteModelTaskOutput\n> {\n id = DELETE_MODEL_TASK;\n title = \"Delete model and all of the entries\";\n maxIterations = 50;\n isPrivate = true;\n databaseLogs = false;\n description = \"Delete a content model and all associated entries.\";\n\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { DeleteModel } = await import(\n /* webpackChunkName: \"createDeleteModel\" */ \"./DeleteModel.js\"\n );\n\n try {\n const runner = new DeleteModel(this.context);\n return await runner.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n\n createInputValidation({ validator }: TaskDefinition.CreateInputValidationParams) {\n return {\n modelId: validator.string(),\n lastDeletedId: validator.string().optional()\n };\n }\n}\n\nexport const DeleteModelTask = TaskDefinition.createImplementation({\n implementation: DeleteModelTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,UAAU,QAAQ,0DAA0D;AACrF,SAASC,iBAAiB;AAI1B,MAAMC,yBAAyB,CAG7B;EACEC,EAAE,GAAGF,iBAAiB;EACtBG,KAAK,GAAG,qCAAqC;EAC7CC,aAAa,GAAG,EAAE;EAClBC,SAAS,GAAG,IAAI;EAChBC,YAAY,GAAG,KAAK;EACpBC,WAAW,GAAG,oDAAoD;EAElDC,WAAW,GAAG,CAAC,WAAW,EAAW,SAAS,CAAU;EAExEC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAAY,CAAC,GAAG,MAAM,MAAM,CAChC,6DACJ,CAAC;IAED,IAAI;MACA,MAAMC,MAAM,GAAG,IAAID,WAAW,CAAC,IAAI,CAACH,OAAO,CAAC;MAC5C,OAAO,MAAMI,MAAM,CAACH,GAAG,CAACC,MAAM,CAAC;IACnC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACI,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACH,EAAE,CAAC;IAC/C;EACJ;EAEAI,qBAAqBA,CAAC;IAAEC;EAAsD,CAAC,EAAE;IAC7E,OAAO;MACHC,OAAO,EAAED,SAAS,CAACE,MAAM,CAAC,CAAC;MAC3BC,aAAa,EAAEH,SAAS,CAACE,MAAM,CAAC,CAAC,CAACE,QAAQ,CAAC;IAC/C,CAAC;EACL;AACJ;AAEA,OAAO,MAAMC,eAAe,GAAG3B,cAAc,CAAC4B,oBAAoB,CAAC;EAC/DC,cAAc,EAAE1B,yBAAyB;EACzC2B,YAAY,EAAE,CAAC7B,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -2,4 +2,7 @@ import type { HeadlessCmsFullyDeleteModel } from "../../types.js";
|
|
|
2
2
|
export interface LegacyDeps {
|
|
3
3
|
isModelBeingDeleted: HeadlessCmsFullyDeleteModel["isModelBeingDeleted"];
|
|
4
4
|
}
|
|
5
|
-
export declare const DisableModelFeature:
|
|
5
|
+
export declare const DisableModelFeature: {
|
|
6
|
+
name: string;
|
|
7
|
+
register(container: import("@webiny/di").Container, context: LegacyDeps): void;
|
|
8
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFeature","BlockActionIfModelDisabled","Abstraction","BlockModelActionOnEntryBeforeCreate","BlockModelActionOnEntryRevisionBeforeCreate","BlockModelActionOnEntryBeforeUpdate","BlockModelActionOnEntryBeforeUnpublish","BlockModelActionOnEntryBeforePublish","BlockModelActionOnEntryBeforeRepublish","BlockModelActionOnEntryBeforeRestoreFromBin","BlockModelActionOnEntryBeforeMove","BlockModelActionOnModelBeforeUpdate","BlockModelActionOnModelBeforeCreateFrom","DisableModelFeature","name","register","container","params","registerInstance","isModelBeingDeleted"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { BlockActionIfModelDisabled as Abstraction } from \"./abstractions.js\";\nimport { BlockActionIfModelDisabled } from \"./BlockActionIfModelDisabled.js\";\nimport type { HeadlessCmsFullyDeleteModel } from \"~/types.js\";\nimport { BlockModelActionOnEntryBeforeCreate } from \"./handlers/BlockModelActionOnEntryBeforeCreate.js\";\nimport { BlockModelActionOnEntryRevisionBeforeCreate } from \"./handlers/BlockModelActionOnEntryRevisionBeforeCreate.js\";\nimport { BlockModelActionOnEntryBeforeUpdate } from \"./handlers/BlockModelActionOnEntryBeforeUpdate.js\";\nimport { BlockModelActionOnEntryBeforeUnpublish } from \"./handlers/BlockModelActionOnEntryBeforeUnpublish.js\";\nimport { BlockModelActionOnEntryBeforePublish } from \"./handlers/BlockModelActionOnEntryBeforePublish.js\";\nimport { BlockModelActionOnEntryBeforeRepublish } from \"./handlers/BlockModelActionOnEntryBeforeRepublish.js\";\nimport { BlockModelActionOnEntryBeforeRestoreFromBin } from \"./handlers/BlockModelActionOnEntryBeforeRestoreFromBin.js\";\nimport { BlockModelActionOnEntryBeforeMove } from \"./handlers/BlockModelActionOnEntryBeforeMove.js\";\nimport { BlockModelActionOnModelBeforeUpdate } from \"./handlers/BlockModelActionOnModelBeforeUpdate.js\";\nimport { BlockModelActionOnModelBeforeCreateFrom } from \"./handlers/BlockModelActionOnModelBeforeCreateFrom.js\";\n\nexport interface LegacyDeps {\n isModelBeingDeleted: HeadlessCmsFullyDeleteModel[\"isModelBeingDeleted\"];\n}\n\nexport const DisableModelFeature = createFeature({\n name: \"DisableModel\",\n register(container, params
|
|
1
|
+
{"version":3,"names":["createFeature","BlockActionIfModelDisabled","Abstraction","BlockModelActionOnEntryBeforeCreate","BlockModelActionOnEntryRevisionBeforeCreate","BlockModelActionOnEntryBeforeUpdate","BlockModelActionOnEntryBeforeUnpublish","BlockModelActionOnEntryBeforePublish","BlockModelActionOnEntryBeforeRepublish","BlockModelActionOnEntryBeforeRestoreFromBin","BlockModelActionOnEntryBeforeMove","BlockModelActionOnModelBeforeUpdate","BlockModelActionOnModelBeforeCreateFrom","DisableModelFeature","name","register","container","params","registerInstance","isModelBeingDeleted"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { BlockActionIfModelDisabled as Abstraction } from \"./abstractions.js\";\nimport { BlockActionIfModelDisabled } from \"./BlockActionIfModelDisabled.js\";\nimport type { HeadlessCmsFullyDeleteModel } from \"~/types.js\";\nimport { BlockModelActionOnEntryBeforeCreate } from \"./handlers/BlockModelActionOnEntryBeforeCreate.js\";\nimport { BlockModelActionOnEntryRevisionBeforeCreate } from \"./handlers/BlockModelActionOnEntryRevisionBeforeCreate.js\";\nimport { BlockModelActionOnEntryBeforeUpdate } from \"./handlers/BlockModelActionOnEntryBeforeUpdate.js\";\nimport { BlockModelActionOnEntryBeforeUnpublish } from \"./handlers/BlockModelActionOnEntryBeforeUnpublish.js\";\nimport { BlockModelActionOnEntryBeforePublish } from \"./handlers/BlockModelActionOnEntryBeforePublish.js\";\nimport { BlockModelActionOnEntryBeforeRepublish } from \"./handlers/BlockModelActionOnEntryBeforeRepublish.js\";\nimport { BlockModelActionOnEntryBeforeRestoreFromBin } from \"./handlers/BlockModelActionOnEntryBeforeRestoreFromBin.js\";\nimport { BlockModelActionOnEntryBeforeMove } from \"./handlers/BlockModelActionOnEntryBeforeMove.js\";\nimport { BlockModelActionOnModelBeforeUpdate } from \"./handlers/BlockModelActionOnModelBeforeUpdate.js\";\nimport { BlockModelActionOnModelBeforeCreateFrom } from \"./handlers/BlockModelActionOnModelBeforeCreateFrom.js\";\n\nexport interface LegacyDeps {\n isModelBeingDeleted: HeadlessCmsFullyDeleteModel[\"isModelBeingDeleted\"];\n}\n\nexport const DisableModelFeature = createFeature<LegacyDeps>({\n name: \"DisableModel\",\n register(container, params) {\n // Register the blocking service\n container.registerInstance(\n Abstraction,\n new BlockActionIfModelDisabled(params.isModelBeingDeleted)\n );\n\n // Register entry event handlers\n container.register(BlockModelActionOnEntryBeforeCreate);\n container.register(BlockModelActionOnEntryRevisionBeforeCreate);\n container.register(BlockModelActionOnEntryBeforeUpdate);\n container.register(BlockModelActionOnEntryBeforeUnpublish);\n container.register(BlockModelActionOnEntryBeforePublish);\n container.register(BlockModelActionOnEntryBeforeRepublish);\n container.register(BlockModelActionOnEntryBeforeRestoreFromBin);\n container.register(BlockModelActionOnEntryBeforeMove);\n\n // Register model event handlers\n container.register(BlockModelActionOnModelBeforeUpdate);\n container.register(BlockModelActionOnModelBeforeCreateFrom);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,0BAA0B,IAAIC,WAAW;AAClD,SAASD,0BAA0B;AAEnC,SAASE,mCAAmC;AAC5C,SAASC,2CAA2C;AACpD,SAASC,mCAAmC;AAC5C,SAASC,sCAAsC;AAC/C,SAASC,oCAAoC;AAC7C,SAASC,sCAAsC;AAC/C,SAASC,2CAA2C;AACpD,SAASC,iCAAiC;AAC1C,SAASC,mCAAmC;AAC5C,SAASC,uCAAuC;AAMhD,OAAO,MAAMC,mBAAmB,GAAGb,aAAa,CAAa;EACzDc,IAAI,EAAE,cAAc;EACpBC,QAAQA,CAACC,SAAS,EAAEC,MAAM,EAAE;IACxB;IACAD,SAAS,CAACE,gBAAgB,CACtBhB,WAAW,EACX,IAAID,0BAA0B,CAACgB,MAAM,CAACE,mBAAmB,CAC7D,CAAC;;IAED;IACAH,SAAS,CAACD,QAAQ,CAACZ,mCAAmC,CAAC;IACvDa,SAAS,CAACD,QAAQ,CAACX,2CAA2C,CAAC;IAC/DY,SAAS,CAACD,QAAQ,CAACV,mCAAmC,CAAC;IACvDW,SAAS,CAACD,QAAQ,CAACT,sCAAsC,CAAC;IAC1DU,SAAS,CAACD,QAAQ,CAACR,oCAAoC,CAAC;IACxDS,SAAS,CAACD,QAAQ,CAACP,sCAAsC,CAAC;IAC1DQ,SAAS,CAACD,QAAQ,CAACN,2CAA2C,CAAC;IAC/DO,SAAS,CAACD,QAAQ,CAACL,iCAAiC,CAAC;;IAErD;IACAM,SAAS,CAACD,QAAQ,CAACJ,mCAAmC,CAAC;IACvDK,SAAS,CAACD,QAAQ,CAACH,uCAAuC,CAAC;EAC/D;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -6,6 +6,6 @@ declare class BlockModelActionOnEntryBeforeCreateImpl implements EntryBeforeCrea
|
|
|
6
6
|
handle(event: EntryBeforeCreateEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const BlockModelActionOnEntryBeforeCreate: typeof BlockModelActionOnEntryBeforeCreateImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-headless-cms/features/contentEntry/CreateEntry/events.js").EntryBeforeCreateEvent>>;
|
|
10
10
|
};
|
|
11
11
|
export {};
|
|
@@ -6,6 +6,6 @@ declare class BlockModelActionOnEntryBeforeMoveImpl implements EntryBeforeMoveEv
|
|
|
6
6
|
handle(event: EntryBeforeMoveEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const BlockModelActionOnEntryBeforeMove: typeof BlockModelActionOnEntryBeforeMoveImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-headless-cms/features/contentEntry/MoveEntry/events.js").EntryBeforeMoveEvent>>;
|
|
10
10
|
};
|
|
11
11
|
export {};
|
|
@@ -6,6 +6,6 @@ declare class BlockModelActionOnEntryBeforePublishImpl implements EntryBeforePub
|
|
|
6
6
|
handle(event: EntryBeforePublishEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const BlockModelActionOnEntryBeforePublish: typeof BlockModelActionOnEntryBeforePublishImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-headless-cms/features/contentEntry/PublishEntry/events.js").EntryBeforePublishEvent>>;
|
|
10
10
|
};
|
|
11
11
|
export {};
|
|
@@ -6,6 +6,6 @@ declare class BlockModelActionOnEntryBeforeRepublishImpl implements EntryBeforeR
|
|
|
6
6
|
handle(event: EntryBeforeRepublishEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const BlockModelActionOnEntryBeforeRepublish: typeof BlockModelActionOnEntryBeforeRepublishImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-headless-cms/features/contentEntry/RepublishEntry/events.js").EntryBeforeRepublishEvent>>;
|
|
10
10
|
};
|
|
11
11
|
export {};
|
|
@@ -6,6 +6,6 @@ declare class BlockModelActionOnEntryBeforeRestoreFromBinImpl implements EntryBe
|
|
|
6
6
|
handle(event: EntryBeforeRestoreFromBinEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const BlockModelActionOnEntryBeforeRestoreFromBin: typeof BlockModelActionOnEntryBeforeRestoreFromBinImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
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
10
|
};
|
|
11
11
|
export {};
|
|
@@ -6,6 +6,6 @@ declare class BlockModelActionOnEntryBeforeUnpublishImpl implements EntryBeforeU
|
|
|
6
6
|
handle(event: EntryBeforeUnpublishEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const BlockModelActionOnEntryBeforeUnpublish: typeof BlockModelActionOnEntryBeforeUnpublishImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
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
10
|
};
|
|
11
11
|
export {};
|
|
@@ -6,6 +6,6 @@ declare class BlockModelActionOnEntryBeforeUpdateImpl implements EntryBeforeUpda
|
|
|
6
6
|
handle(event: EntryBeforeUpdateEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const BlockModelActionOnEntryBeforeUpdate: typeof BlockModelActionOnEntryBeforeUpdateImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
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
10
|
};
|
|
11
11
|
export {};
|
|
@@ -6,6 +6,6 @@ declare class BlockModelActionOnEntryRevisionBeforeCreateImpl implements EntryRe
|
|
|
6
6
|
handle(event: EntryRevisionBeforeCreateEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const BlockModelActionOnEntryRevisionBeforeCreate: typeof BlockModelActionOnEntryRevisionBeforeCreateImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
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
10
|
};
|
|
11
11
|
export {};
|
|
@@ -6,6 +6,6 @@ declare class BlockModelActionOnModelBeforeCreateFromImpl implements ModelBefore
|
|
|
6
6
|
handle(event: ModelBeforeCreateFromEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const BlockModelActionOnModelBeforeCreateFrom: typeof BlockModelActionOnModelBeforeCreateFromImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
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
10
|
};
|
|
11
11
|
export {};
|
|
@@ -6,6 +6,6 @@ declare class BlockModelActionOnModelBeforeUpdateImpl implements ModelBeforeUpda
|
|
|
6
6
|
handle(event: ModelBeforeUpdateEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const BlockModelActionOnModelBeforeUpdate: typeof BlockModelActionOnModelBeforeUpdateImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
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
10
|
};
|
|
11
11
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HcmsTasksContext } from "../../types.js";
|
|
2
2
|
import type { IDeleteCmsModelTask } from "../../features/DeleteModelTask/types.js";
|
|
3
3
|
export interface ICancelDeleteModelParams {
|
|
4
|
-
readonly context: Pick<HcmsTasksContext, "cms" | "tasks" | "db">;
|
|
4
|
+
readonly context: Pick<HcmsTasksContext, "cms" | "tasks" | "db" | "container">;
|
|
5
5
|
readonly modelId: string;
|
|
6
6
|
}
|
|
7
7
|
export declare const cancelDeleteModel: (params: ICancelDeleteModelParams) => Promise<IDeleteCmsModelTask>;
|
|
@@ -2,20 +2,29 @@ import { WebinyError } from "@webiny/error";
|
|
|
2
2
|
import { createStoreKey } from "../../helpers/store.js";
|
|
3
3
|
import { DELETE_MODEL_TASK } from "../../constants.js";
|
|
4
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";
|
|
5
7
|
export const cancelDeleteModel = async params => {
|
|
6
8
|
const {
|
|
7
9
|
context,
|
|
8
10
|
modelId
|
|
9
11
|
} = params;
|
|
10
12
|
const model = await context.cms.getModel(modelId);
|
|
11
|
-
|
|
13
|
+
const accessControl = context.container.resolve(AccessControl);
|
|
14
|
+
const canAccessModel = await accessControl.canAccessModel({
|
|
12
15
|
model,
|
|
13
16
|
rwd: "d"
|
|
14
17
|
});
|
|
15
|
-
|
|
18
|
+
if (!canAccessModel) {
|
|
19
|
+
throw new NotAuthorizedError(`Not allowed to access content model "${model.name}".`);
|
|
20
|
+
}
|
|
21
|
+
const canAccessEntry = await accessControl.canAccessEntry({
|
|
16
22
|
model,
|
|
17
23
|
rwd: "w"
|
|
18
24
|
});
|
|
25
|
+
if (!canAccessEntry) {
|
|
26
|
+
throw new NotAuthorizedError(`Not allowed to access "${model.modelId}" entries.`);
|
|
27
|
+
}
|
|
19
28
|
const storeKey = createStoreKey(model);
|
|
20
29
|
const result = await context.db.store.getValue(storeKey);
|
|
21
30
|
const taskId = result.data?.task;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","createStoreKey","DELETE_MODEL_TASK","getStatus","cancelDeleteModel","params","context","modelId","model","cms","getModel","accessControl","
|
|
1
|
+
{"version":3,"names":["WebinyError","createStoreKey","DELETE_MODEL_TASK","getStatus","NotAuthorizedError","AccessControl","cancelDeleteModel","params","context","modelId","model","cms","getModel","accessControl","container","resolve","canAccessModel","rwd","name","canAccessEntry","storeKey","result","db","store","getValue","taskId","data","task","removeValue","error","from","code","message","tasks","getTask","definitionId","abortResult","abort","id","canceledTask","value","status","taskStatus","total","output","deleted"],"sources":["cancelDeleteModel.ts"],"sourcesContent":["import type { HcmsTasksContext } from \"~/types.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport type {\n IDeleteCmsModelTask,\n IDeleteModelTaskInput,\n IDeleteModelTaskOutput,\n IStoreValue\n} from \"~/features/DeleteModelTask/types.js\";\nimport { createStoreKey } 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\";\n\nexport interface ICancelDeleteModelParams {\n readonly context: Pick<HcmsTasksContext, \"cms\" | \"tasks\" | \"db\" | \"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 model = await context.cms.getModel(modelId);\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 storeKey = createStoreKey(model);\n\n const result = await context.db.store.getValue<IStoreValue>(storeKey);\n\n const taskId = result.data?.task;\n\n await context.db.store.removeValue(storeKey);\n if (!taskId) {\n if (result.error) {\n throw WebinyError.from(result.error, {\n code: \"DELETE_MODEL_NO_TASK_DEFINED\"\n });\n }\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.tasks.getTask<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.tasks.abort<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"],"mappings":"AACA,SAASA,WAAW,QAAQ,eAAe;AAO3C,SAASC,cAAc;AACvB,SAASC,iBAAiB;AAC1B,SAASC,SAAS;AAClB,SAASC,kBAAkB,QAAQ,0CAA0C;AAC7E,SAASC,aAAa,QAAQ,0DAA0D;AAOxF,OAAO,MAAMC,iBAAiB,GAAG,MAC7BC,MAAgC,IACD;EAC/B,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAEnC,MAAMG,KAAK,GAAG,MAAMF,OAAO,CAACG,GAAG,CAACC,QAAQ,CAACH,OAAO,CAAC;EACjD,MAAMI,aAAa,GAAGL,OAAO,CAACM,SAAS,CAACC,OAAO,CAACV,aAAa,CAAC;EAE9D,MAAMW,cAAc,GAAG,MAAMH,aAAa,CAACG,cAAc,CAAC;IAAEN,KAAK;IAAEO,GAAG,EAAE;EAAI,CAAC,CAAC;EAC9E,IAAI,CAACD,cA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CAAC;EACN;EAEA,MAAMW,WAAW,GAAG,MAAM5B,OAAO,CAACyB,KAAK,CAACI,KAAK,CAAgD;IACzFC,EAAE,EAAEX,IAAI,CAACW,EAAE;IACXN,OAAO,EAAE;EACb,CAAC,CAAC;EAEF,MAAMO,YAAY,GAAGH,WAAW,CAACI,KAAK;EAEtC,OAAO;IACHF,EAAE,EAAEC,YAAY,CAACD,EAAE;IACnBG,MAAM,EAAEtC,SAAS,CAACoC,YAAY,CAACG,UAAU,CAAC;IAC1CC,KAAK,EAAEJ,YAAY,CAACK,MAAM,EAAED,KAAK,IAAI,CAAC;IACtCE,OAAO,EAAEN,YAAY,CAACK,MAAM,EAAEC,OAAO,IAAI;EAC7C,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createStoreKey, createStoreValue } from "../../helpers/store.js";
|
|
2
2
|
import { DELETE_MODEL_TASK } from "../../constants.js";
|
|
3
3
|
import { getStatus } from "./status.js";
|
|
4
|
+
import { NotAuthorizedError } from "@webiny/api-headless-cms/utils/errors.js";
|
|
4
5
|
export const fullyDeleteModel = async params => {
|
|
5
6
|
const {
|
|
6
7
|
context,
|
|
@@ -10,14 +11,20 @@ export const fullyDeleteModel = async params => {
|
|
|
10
11
|
if (model.isPrivate) {
|
|
11
12
|
throw new Error(`Cannot delete private model.`);
|
|
12
13
|
}
|
|
13
|
-
await context.cms.accessControl.
|
|
14
|
+
const canAccessModel = await context.cms.accessControl.canAccessModel({
|
|
14
15
|
model,
|
|
15
16
|
rwd: "d"
|
|
16
17
|
});
|
|
17
|
-
|
|
18
|
+
if (!canAccessModel) {
|
|
19
|
+
throw new NotAuthorizedError(`Not allowed to access content model "${model.name}".`);
|
|
20
|
+
}
|
|
21
|
+
const canAccessEntry = await context.cms.accessControl.canAccessEntry({
|
|
18
22
|
model,
|
|
19
23
|
rwd: "w"
|
|
20
24
|
});
|
|
25
|
+
if (!canAccessEntry) {
|
|
26
|
+
throw new NotAuthorizedError(`Not allowed to access "${model.modelId}" entries.`);
|
|
27
|
+
}
|
|
21
28
|
if (!model) {
|
|
22
29
|
throw new Error(`Model "${modelId}" not found.`);
|
|
23
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createStoreKey","createStoreValue","DELETE_MODEL_TASK","getStatus","fullyDeleteModel","params","context","modelId","model","cms","getModel","isPrivate","Error","
|
|
1
|
+
{"version":3,"names":["createStoreKey","createStoreValue","DELETE_MODEL_TASK","getStatus","NotAuthorizedError","fullyDeleteModel","params","context","modelId","model","cms","getModel","isPrivate","Error","canAccessModel","accessControl","rwd","name","canAccessEntry","storeKey","result","db","store","getValue","taskId","data","task","triggerResult","tasks","trigger","input","definition","value","identity","security","getIdentity","storeValue","id","type","displayName","status","taskStatus","total","deleted"],"sources":["fullyDeleteModel.ts"],"sourcesContent":["import type { HcmsTasksContext } from \"~/types.js\";\nimport type {\n IDeleteCmsModelTask,\n IDeleteModelTaskInput,\n IStoreValue\n} from \"~/features/DeleteModelTask/types.js\";\nimport { createStoreKey, 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\";\n\nexport interface IFullyDeleteModelParams {\n readonly context: Pick<HcmsTasksContext, \"cms\" | \"tasks\" | \"db\" | \"security\">;\n readonly modelId: string;\n}\n\nexport const fullyDeleteModel = async (\n params: IFullyDeleteModelParams\n): Promise<IDeleteCmsModelTask> => {\n const { context, modelId } = params;\n\n const model = await context.cms.getModel(modelId);\n\n if (model.isPrivate) {\n throw new Error(`Cannot delete private model.`);\n }\n\n const canAccessModel = await context.cms.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 context.cms.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 storeKey = createStoreKey(model);\n const result = await context.db.store.getValue<IStoreValue>(storeKey);\n const taskId = result.data?.task;\n if (taskId) {\n throw new Error(`Model \"${modelId}\" is already getting deleted. Task id: ${taskId}.`);\n }\n\n const triggerResult = await context.tasks.trigger<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.security.getIdentity();\n\n await context.db.store.storeValue(\n storeKey,\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"],"mappings":"AAMA,SAASA,cAAc,EAAEC,gBAAgB;AACzC,SAASC,iBAAiB;AAC1B,SAASC,SAAS;AAClB,SAASC,kBAAkB,QAAQ,0CAA0C;AAO7E,OAAO,MAAMC,gBAAgB,GAAG,MAC5BC,MAA+B,IACA;EAC/B,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAEnC,MAAMG,KAAK,GAAG,MAAMF,OAAO,CAACG,GAAG,CAACC,QAAQ,CAACH,OAAO,CAAC;EAEjD,IAAIC,KAAK,CAACG,SAAS,EAAE;IACjB,MAAM,IAAIC,KAAK,CAAC,8BAA8B,CAAC;EACnD;EAEA,MAAMC,cAAc,GAAG,MAAMP,OAAO,CAACG,GAAG,CAACK,aAAa,CAACD,cAAc,CAAC;IAAEL,KAAK;IAAEO,GAAG,EAAE;EAAI,CAAC,CAAC;EAC1F,IAAI,CAACF,cAAc,EAAE;IACjB,MAAM,IAAIV,kBAAkB,CAAC,wCAAwCK,KAAK,CAACQ,IAAI,IAAI,CAAC;EACxF;EAEA,MAAMC,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AACW;EACf,CAAC,CACL,CAAC;EAED,OAAO;IACHA,EAAE,EAAEX,IAAI,CAACW,EAAE;IACXG,MAAM,EAAErC,SAAS,CAACuB,IAAI,CAACe,UAAU,CAAC;IAClCC,KAAK,EAAE,CAAC;IACRC,OAAO,EAAE;EACb,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@ import { NotFoundError } from "@webiny/handler-graphql";
|
|
|
3
3
|
import { createStoreKey } from "../../helpers/store.js";
|
|
4
4
|
import { DELETE_MODEL_TASK } from "../../constants.js";
|
|
5
5
|
import { getStatus } from "./status.js";
|
|
6
|
+
import { NotAuthorizedError } from "@webiny/api-headless-cms/utils/errors.js";
|
|
6
7
|
export const getDeleteModelProgress = async params => {
|
|
7
8
|
const {
|
|
8
9
|
context,
|
|
@@ -23,14 +24,20 @@ export const getDeleteModelProgress = async params => {
|
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
|
-
await context.cms.accessControl.
|
|
27
|
+
const canAccessModel = await context.cms.accessControl.canAccessModel({
|
|
27
28
|
model,
|
|
28
29
|
rwd: "d"
|
|
29
30
|
});
|
|
30
|
-
|
|
31
|
+
if (!canAccessModel) {
|
|
32
|
+
throw new NotAuthorizedError(`Not allowed to access content model "${model.name}".`);
|
|
33
|
+
}
|
|
34
|
+
const canAccessEntry = await context.cms.accessControl.canAccessEntry({
|
|
31
35
|
model,
|
|
32
36
|
rwd: "w"
|
|
33
37
|
});
|
|
38
|
+
if (!canAccessEntry) {
|
|
39
|
+
throw new NotAuthorizedError(`Not allowed to access "${model.modelId}" entries.`);
|
|
40
|
+
}
|
|
34
41
|
const storeKey = createStoreKey(model);
|
|
35
42
|
const result = await context.db.store.getValue(storeKey);
|
|
36
43
|
const taskId = result.data?.task;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","NotFoundError","createStoreKey","DELETE_MODEL_TASK","getStatus","getDeleteModelProgress","params","context","modelId","model","cms","getModel","ex","message","code","data","
|
|
1
|
+
{"version":3,"names":["WebinyError","NotFoundError","createStoreKey","DELETE_MODEL_TASK","getStatus","NotAuthorizedError","getDeleteModelProgress","params","context","modelId","model","cms","getModel","ex","message","code","data","canAccessModel","accessControl","rwd","name","canAccessEntry","storeKey","result","db","store","getValue","taskId","task","Error","tasks","getTask","definitionId","id","status","taskStatus","total","output","deleted"],"sources":["getDeleteModelProgress.ts"],"sourcesContent":["import type { HcmsTasksContext } from \"~/types.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type {\n IDeleteCmsModelTask,\n IDeleteModelTaskInput,\n IDeleteModelTaskOutput,\n IStoreValue\n} from \"~/features/DeleteModelTask/types.js\";\nimport { createStoreKey } 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\";\n\nexport interface IGetDeleteModelProgress {\n readonly context: Pick<HcmsTasksContext, \"cms\" | \"tasks\" | \"db\">;\n readonly modelId: string;\n}\n\nexport const getDeleteModelProgress = async (\n params: IGetDeleteModelProgress\n): Promise<IDeleteCmsModelTask> => {\n const { context, modelId } = params;\n\n let model: CmsModel;\n try {\n model = await context.cms.getModel(modelId);\n } catch (ex) {\n if (ex instanceof NotFoundError === false) {\n throw ex;\n }\n throw new WebinyError({\n message: \"Model not found. It must have been deleted already.\",\n code: \"MODEL_ALREADY_DELETED_FOUND\",\n data: {\n model: modelId\n }\n });\n }\n\n const canAccessModel = await context.cms.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 context.cms.accessControl.canAccessEntry({ model, rwd: \"w\" });\n if (!canAccessEntry) {\n throw new NotAuthorizedError(`Not allowed to access \"${model.modelId}\" entries.`);\n }\n\n const storeKey = createStoreKey(model);\n const result = await context.db.store.getValue<IStoreValue>(storeKey);\n\n const taskId = result.data?.task;\n if (!taskId) {\n throw new Error(`Model \"${modelId}\" is not being deleted.`);\n }\n\n const task = await context.tasks.getTask<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.`,\n code: \"DELETE_MODEL_TASK_NOT_FOUND\",\n data: {\n model: model.modelId,\n task: taskId\n }\n });\n }\n return {\n id: task.id,\n status: getStatus(task.taskStatus),\n total: task.output?.total || 0,\n deleted: task.output?.deleted || 0\n };\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,eAAe;AAC3C,SAASC,aAAa,QAAQ,yBAAyB;AAQvD,SAASC,cAAc;AACvB,SAASC,iBAAiB;AAC1B,SAASC,SAAS;AAClB,SAASC,kBAAkB,QAAQ,0CAA0C;AAO7E,OAAO,MAAMC,sBAAsB,GAAG,MAClCC,MAA+B,IACA;EAC/B,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAEnC,IAAIG,KAAe;EACnB,IAAI;IACAA,KAAK,GAAG,MAAMF,OAAO,CAACG,GAAG,CAACC,QAAQ,CAACH,OAAO,CAAC;EAC/C,CAAC,CAAC,OAAOI,EAAE,EAAE;IACT,IAAIA,EAAE,YAAYZ,aAAa,KAAK,KAAK,EAAE;MACvC,MAAMY,EAAE;IACZ;IACA,MAAM,IAAIb,WAAW,CAAC;MAClBc,OAAO,EAAE,qDAAqD;MAC9DC,IAAI,EAAE,6BAA6B;MACnCC,IAAI,EAAE;QACFN,KAAK,EAAED;MACX;IACJ,CAAC,CAAC;EACN;EAEA,MAAMQ,cAAc,GAAG,MAAMT,OAAO,CAACG,GAAG,CAACO,aAAa,CAACD,cAAc,CAAC;IAAEP,KAAK;IAAES,GAAG,EAAE;EAAI,CAAC,CAAC;E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AAC;AACL,CAAC","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const createDeleteModelTask: () => import("@webiny/api").ContextPlugin<import("./types").HcmsTasksContext>[];
|
|
2
|
-
export declare const createHcmsTasks: () => (import("@webiny/api").ContextPlugin<import("@webiny/api/types").Context> | (import("@webiny/api").ContextPlugin<import("@webiny/api/types").Context> | (import("@webiny/handler-aws/eventBridge").EventBridgeEventHandler<"WebinyEmptyTrashBin", Record<string, any>, any> | import("@webiny/handler/index").HandlerOnRequestPlugin<import("@webiny/handler/types").Context>)[] | import("@webiny/handler/index").BeforeHandlerPlugin<import("@webiny/api-headless-cms-bulk-actions/types").HcmsBulkActionsContext>)[]
|
|
2
|
+
export declare const createHcmsTasks: () => (import("@webiny/api").ContextPlugin<import("@webiny/api/types").Context> | (import("@webiny/api").ContextPlugin<import("@webiny/api/types").Context> | (import("@webiny/handler-aws/eventBridge").EventBridgeEventHandler<"WebinyEmptyTrashBin", Record<string, any>, any> | import("@webiny/handler/index").HandlerOnRequestPlugin<import("@webiny/handler/types").Context>)[] | import("@webiny/handler/index").BeforeHandlerPlugin<import("@webiny/api-headless-cms-bulk-actions/types").HcmsBulkActionsContext>)[])[];
|
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createEmptyTrashBinsTask, createHcmsBulkActions } from "@webiny/api-headless-cms-bulk-actions";
|
|
2
|
-
import { createHeadlessCmsImportExport } from "@webiny/api-headless-cms-import-export";
|
|
3
2
|
import { createContextPlugin } from "@webiny/api";
|
|
4
3
|
import { DeleteModelTaskFeature } from "./features/DeleteModelTask/feature.js";
|
|
5
4
|
import { createDeleteModelCrud } from "./graphql/deleteModel/crud.js";
|
|
@@ -11,6 +10,6 @@ export const createDeleteModelTask = () => {
|
|
|
11
10
|
};
|
|
12
11
|
export const createHcmsTasks = () => [createHcmsBulkActions({
|
|
13
12
|
batchSize: 100
|
|
14
|
-
}), createEmptyTrashBinsTask(),
|
|
13
|
+
}), createEmptyTrashBinsTask(), createDeleteModelTask()];
|
|
15
14
|
|
|
16
15
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createEmptyTrashBinsTask","createHcmsBulkActions","
|
|
1
|
+
{"version":3,"names":["createEmptyTrashBinsTask","createHcmsBulkActions","createContextPlugin","DeleteModelTaskFeature","createDeleteModelCrud","createDeleteModelGraphQl","createDeleteModelTask","context","register","container","createHcmsTasks","batchSize"],"sources":["index.ts"],"sourcesContent":["import {\n createEmptyTrashBinsTask,\n createHcmsBulkActions\n} from \"@webiny/api-headless-cms-bulk-actions\";\nimport { createContextPlugin } from \"@webiny/api\";\nimport { DeleteModelTaskFeature } from \"~/features/DeleteModelTask/feature.js\";\nimport { createDeleteModelCrud } from \"~/graphql/deleteModel/crud.js\";\nimport { createDeleteModelGraphQl } from \"~/graphql/deleteModel/index.js\";\n\nexport const createDeleteModelTask = () => {\n return [\n createDeleteModelCrud(),\n createDeleteModelGraphQl(),\n createContextPlugin(context => {\n DeleteModelTaskFeature.register(context.container);\n })\n ];\n};\n\nexport const createHcmsTasks = () => [\n createHcmsBulkActions({ batchSize: 100 }),\n createEmptyTrashBinsTask(),\n createDeleteModelTask()\n];\n"],"mappings":"AAAA,SACIA,wBAAwB,EACxBC,qBAAqB,QAClB,uCAAuC;AAC9C,SAASC,mBAAmB,QAAQ,aAAa;AACjD,SAASC,sBAAsB;AAC/B,SAASC,qBAAqB;AAC9B,SAASC,wBAAwB;AAEjC,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,OAAO,CACHF,qBAAqB,CAAC,CAAC,EACvBC,wBAAwB,CAAC,CAAC,EAC1BH,mBAAmB,CAACK,OAAO,IAAI;IAC3BJ,sBAAsB,CAACK,QAAQ,CAACD,OAAO,CAACE,SAAS,CAAC;EACtD,CAAC,CAAC,CACL;AACL,CAAC;AAED,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAAM,CACjCT,qBAAqB,CAAC;EAAEU,SAAS,EAAE;AAAI,CAAC,CAAC,EACzCX,wBAAwB,CAAC,CAAC,EAC1BM,qBAAqB,CAAC,CAAC,CAC1B","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-tasks",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.e6f0dc8ca7",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
6
9
|
"description": "Background tasks for Webiny Headless CMS",
|
|
7
10
|
"keywords": [
|
|
8
11
|
"api-headless-cms-tasks:base"
|
|
@@ -14,33 +17,32 @@
|
|
|
14
17
|
},
|
|
15
18
|
"license": "MIT",
|
|
16
19
|
"dependencies": {
|
|
17
|
-
"@webiny/api": "0.0.0-unstable.
|
|
18
|
-
"@webiny/api-aco": "0.0.0-unstable.
|
|
19
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
20
|
-
"@webiny/api-headless-cms-bulk-actions": "0.0.0-unstable.
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/
|
|
25
|
-
"@webiny/
|
|
26
|
-
"@webiny/
|
|
27
|
-
"
|
|
28
|
-
"zod": "3.25.76"
|
|
20
|
+
"@webiny/api": "0.0.0-unstable.e6f0dc8ca7",
|
|
21
|
+
"@webiny/api-aco": "0.0.0-unstable.e6f0dc8ca7",
|
|
22
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.e6f0dc8ca7",
|
|
23
|
+
"@webiny/api-headless-cms-bulk-actions": "0.0.0-unstable.e6f0dc8ca7",
|
|
24
|
+
"@webiny/db": "0.0.0-unstable.e6f0dc8ca7",
|
|
25
|
+
"@webiny/error": "0.0.0-unstable.e6f0dc8ca7",
|
|
26
|
+
"@webiny/feature": "0.0.0-unstable.e6f0dc8ca7",
|
|
27
|
+
"@webiny/handler-graphql": "0.0.0-unstable.e6f0dc8ca7",
|
|
28
|
+
"@webiny/tasks": "0.0.0-unstable.e6f0dc8ca7",
|
|
29
|
+
"@webiny/utils": "0.0.0-unstable.e6f0dc8ca7",
|
|
30
|
+
"zod": "4.4.3"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
|
-
"@webiny/api-core": "0.0.0-unstable.
|
|
32
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
33
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
34
|
-
"@webiny/handler-aws": "0.0.0-unstable.
|
|
35
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
36
|
-
"@webiny/project-utils": "0.0.0-unstable.
|
|
37
|
-
"@webiny/wcp": "0.0.0-unstable.
|
|
38
|
-
"typescript": "
|
|
39
|
-
"vitest": "
|
|
33
|
+
"@webiny/api-core": "0.0.0-unstable.e6f0dc8ca7",
|
|
34
|
+
"@webiny/build-tools": "0.0.0-unstable.e6f0dc8ca7",
|
|
35
|
+
"@webiny/handler": "0.0.0-unstable.e6f0dc8ca7",
|
|
36
|
+
"@webiny/handler-aws": "0.0.0-unstable.e6f0dc8ca7",
|
|
37
|
+
"@webiny/plugins": "0.0.0-unstable.e6f0dc8ca7",
|
|
38
|
+
"@webiny/project-utils": "0.0.0-unstable.e6f0dc8ca7",
|
|
39
|
+
"@webiny/wcp": "0.0.0-unstable.e6f0dc8ca7",
|
|
40
|
+
"typescript": "6.0.3",
|
|
41
|
+
"vitest": "4.1.5"
|
|
40
42
|
},
|
|
41
43
|
"publishConfig": {
|
|
42
44
|
"access": "public",
|
|
43
45
|
"directory": "dist"
|
|
44
46
|
},
|
|
45
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "e6f0dc8ca741c1fcc3fec9a5b9e86fdd49544641"
|
|
46
48
|
}
|