@webiny/api-headless-cms-bulk-actions 6.6.0-alpha.0 → 6.6.0-alpha.2
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/HcmsBulkActionsFeature.js +6 -14
- package/HcmsBulkActionsFeature.js.map +1 -1
- package/exports/api/cms/entry.d.ts +1 -0
- package/exports/api/cms/entry.js +1 -0
- package/features/DeleteEntriesBulkAction/DeleteEntriesBulkAction.d.ts +1 -1
- package/features/EntriesBulkAction/abstractions.d.ts +7 -7
- package/features/EntriesBulkAction/abstractions.js.map +1 -1
- package/features/EntriesBulkAction/createBulkActionTasks.d.ts +47 -4
- package/features/EntriesBulkAction/createBulkActionTasks.js +131 -120
- package/features/EntriesBulkAction/createBulkActionTasks.js.map +1 -1
- package/features/EntriesBulkAction/internals/CreateTasksByModel.js +1 -0
- package/features/EntriesBulkAction/internals/CreateTasksByModel.js.map +1 -1
- package/features/MoveToFolderBulkAction/MoveToFolderBulkAction.d.ts +1 -1
- package/features/MoveToTrashBulkAction/MoveToTrashBulkAction.d.ts +1 -1
- package/features/PublishEntriesBulkAction/PublishEntriesBulkAction.d.ts +1 -1
- package/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.d.ts +1 -1
- package/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.d.ts +1 -1
- package/graphql/BulkActionsGraphQLSchema.d.ts +12 -0
- package/graphql/BulkActionsGraphQLSchema.js +106 -0
- package/graphql/BulkActionsGraphQLSchema.js.map +1 -0
- package/graphql/createDefaultGraphQL.d.ts +2 -2
- package/graphql/createDefaultGraphQL.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/package.json +17 -20
- package/types.d.ts +2 -0
- package/types.js.map +1 -1
- package/BulkActionsEventBridgeLambdaHandler.d.ts +0 -13
- package/BulkActionsEventBridgeLambdaHandler.js +0 -33
- package/BulkActionsEventBridgeLambdaHandler.js.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { createBulkActionTasks } from "./features/EntriesBulkAction/createBulkActionTasks.js";
|
|
2
|
+
import { EntriesBulkActionConfig } from "./features/EntriesBulkAction/abstractions.js";
|
|
3
|
+
import { BulkActionListTaskDefinition, BulkActionProcessTaskDefinition } from "./features/EntriesBulkAction/createBulkActionTasks.js";
|
|
5
4
|
import { DeleteEntriesBulkActionFeature } from "./features/DeleteEntriesBulkAction/feature.js";
|
|
6
5
|
import { MoveToFolderBulkActionFeature } from "./features/MoveToFolderBulkAction/feature.js";
|
|
7
6
|
import { MoveToTrashBulkActionFeature } from "./features/MoveToTrashBulkAction/feature.js";
|
|
@@ -9,8 +8,7 @@ import { PublishEntriesBulkActionFeature } from "./features/PublishEntriesBulkAc
|
|
|
9
8
|
import { UnpublishEntriesBulkActionFeature } from "./features/UnpublishEntriesBulkAction/feature.js";
|
|
10
9
|
import { RestoreEntriesBulkActionFeature } from "./features/RestoreEntriesBulkAction/feature.js";
|
|
11
10
|
import { EmptyTrashBinTaskDefinition } from "./tasks/EmptyTrashBinTaskDefinition.js";
|
|
12
|
-
import {
|
|
13
|
-
import { createBulkActionGraphQL } from "./graphql/createBulkActionGraphQL.js";
|
|
11
|
+
import { BulkActionsGraphQLSchema } from "./graphql/BulkActionsGraphQLSchema.js";
|
|
14
12
|
const HcmsBulkActionsFeature = createFeature({
|
|
15
13
|
name: "HcmsBulkActions",
|
|
16
14
|
register (container, config) {
|
|
@@ -24,15 +22,9 @@ const HcmsBulkActionsFeature = createFeature({
|
|
|
24
22
|
UnpublishEntriesBulkActionFeature.register(container);
|
|
25
23
|
RestoreEntriesBulkActionFeature.register(container);
|
|
26
24
|
container.register(EmptyTrashBinTaskDefinition);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
container.
|
|
30
|
-
async init (ctx) {
|
|
31
|
-
const context = ctx;
|
|
32
|
-
await registerDefaultBulkActionGraphQL(context);
|
|
33
|
-
for (const bulkAction of container.resolveAll(EntriesBulkAction))await createBulkActionGraphQL(context, bulkAction);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
25
|
+
container.register(BulkActionListTaskDefinition);
|
|
26
|
+
container.register(BulkActionProcessTaskDefinition);
|
|
27
|
+
container.register(BulkActionsGraphQLSchema);
|
|
36
28
|
}
|
|
37
29
|
});
|
|
38
30
|
export { HcmsBulkActionsFeature };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HcmsBulkActionsFeature.js","sources":["../src/HcmsBulkActionsFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport {
|
|
1
|
+
{"version":3,"file":"HcmsBulkActionsFeature.js","sources":["../src/HcmsBulkActionsFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { EntriesBulkActionConfig } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport {\n BulkActionListTaskDefinition,\n BulkActionProcessTaskDefinition\n} from \"~/features/EntriesBulkAction/createBulkActionTasks.js\";\nimport { DeleteEntriesBulkActionFeature } from \"~/features/DeleteEntriesBulkAction/feature.js\";\nimport { MoveToFolderBulkActionFeature } from \"~/features/MoveToFolderBulkAction/feature.js\";\nimport { MoveToTrashBulkActionFeature } from \"~/features/MoveToTrashBulkAction/feature.js\";\nimport { PublishEntriesBulkActionFeature } from \"~/features/PublishEntriesBulkAction/feature.js\";\nimport { UnpublishEntriesBulkActionFeature } from \"~/features/UnpublishEntriesBulkAction/feature.js\";\nimport { RestoreEntriesBulkActionFeature } from \"~/features/RestoreEntriesBulkAction/feature.js\";\nimport { EmptyTrashBinTaskDefinition } from \"~/tasks/EmptyTrashBinTaskDefinition.js\";\nimport { BulkActionsGraphQLSchema } from \"~/graphql/BulkActionsGraphQLSchema.js\";\n\nexport interface HcmsBulkActionsFeatureConfig {\n batchSize?: number;\n}\n\nexport const HcmsBulkActionsFeature = createFeature<HcmsBulkActionsFeatureConfig | undefined>({\n name: \"HcmsBulkActions\",\n register(container, config) {\n container.registerInstance(EntriesBulkActionConfig, {\n batchSize: config?.batchSize ?? 100\n });\n\n DeleteEntriesBulkActionFeature.register(container);\n MoveToFolderBulkActionFeature.register(container);\n MoveToTrashBulkActionFeature.register(container);\n PublishEntriesBulkActionFeature.register(container);\n UnpublishEntriesBulkActionFeature.register(container);\n RestoreEntriesBulkActionFeature.register(container);\n\n container.register(EmptyTrashBinTaskDefinition);\n container.register(BulkActionListTaskDefinition);\n container.register(BulkActionProcessTaskDefinition);\n container.register(BulkActionsGraphQLSchema);\n }\n});\n"],"names":["HcmsBulkActionsFeature","createFeature","container","config","EntriesBulkActionConfig","DeleteEntriesBulkActionFeature","MoveToFolderBulkActionFeature","MoveToTrashBulkActionFeature","PublishEntriesBulkActionFeature","UnpublishEntriesBulkActionFeature","RestoreEntriesBulkActionFeature","EmptyTrashBinTaskDefinition","BulkActionListTaskDefinition","BulkActionProcessTaskDefinition","BulkActionsGraphQLSchema"],"mappings":";;;;;;;;;;;AAmBO,MAAMA,yBAAyBC,cAAwD;IAC1F,MAAM;IACN,UAASC,SAAS,EAAEC,MAAM;QACtBD,UAAU,gBAAgB,CAACE,yBAAyB;YAChD,WAAWD,QAAQ,aAAa;QACpC;QAEAE,+BAA+B,QAAQ,CAACH;QACxCI,8BAA8B,QAAQ,CAACJ;QACvCK,6BAA6B,QAAQ,CAACL;QACtCM,gCAAgC,QAAQ,CAACN;QACzCO,kCAAkC,QAAQ,CAACP;QAC3CQ,gCAAgC,QAAQ,CAACR;QAEzCA,UAAU,QAAQ,CAACS;QACnBT,UAAU,QAAQ,CAACU;QACnBV,UAAU,QAAQ,CAACW;QACnBX,UAAU,QAAQ,CAACY;IACvB;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EntriesBulkAction } from "../../../features/EntriesBulkAction/abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EntriesBulkAction } from "../../../features/EntriesBulkAction/abstractions.js";
|
|
@@ -10,6 +10,6 @@ declare class DeleteEntriesBulkActionImpl implements EntriesBulkAction.Interface
|
|
|
10
10
|
processData(model: EntriesBulkAction.Model, params: EntriesBulkAction.ProcessParams): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export declare const DeleteEntriesBulkAction: typeof DeleteEntriesBulkActionImpl & {
|
|
13
|
-
__abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction<Record<string, any>>>;
|
|
14
14
|
};
|
|
15
15
|
export {};
|
|
@@ -9,24 +9,24 @@ export interface IBulkActionListResult {
|
|
|
9
9
|
entries: CmsEntry[];
|
|
10
10
|
meta: CmsEntryMeta;
|
|
11
11
|
}
|
|
12
|
-
export interface IBulkActionProcessParams {
|
|
12
|
+
export interface IBulkActionProcessParams<TData = Record<string, any>> {
|
|
13
13
|
id: string;
|
|
14
|
-
data?:
|
|
14
|
+
data?: TData;
|
|
15
15
|
}
|
|
16
|
-
export interface IEntriesBulkAction {
|
|
16
|
+
export interface IEntriesBulkAction<TData = Record<string, any>> {
|
|
17
17
|
readonly name: string;
|
|
18
18
|
readonly modelIds?: string[];
|
|
19
19
|
readonly batchSize?: number;
|
|
20
20
|
loadData(model: CmsModel, params: IBulkActionListParams): Promise<IBulkActionListResult>;
|
|
21
|
-
processData(model: CmsModel, params: IBulkActionProcessParams): Promise<void>;
|
|
21
|
+
processData(model: CmsModel, params: IBulkActionProcessParams<TData>): Promise<void>;
|
|
22
22
|
}
|
|
23
|
-
export declare const EntriesBulkAction: import("@webiny/di").Abstraction<IEntriesBulkAction
|
|
23
|
+
export declare const EntriesBulkAction: import("@webiny/di").Abstraction<IEntriesBulkAction<Record<string, any>>>;
|
|
24
24
|
export declare namespace EntriesBulkAction {
|
|
25
|
-
type Interface = IEntriesBulkAction
|
|
25
|
+
type Interface<TData = Record<string, any>> = IEntriesBulkAction<TData>;
|
|
26
26
|
type Model = CmsModel;
|
|
27
27
|
type LoadDataParams = IBulkActionListParams;
|
|
28
28
|
type LoadDataResult = IBulkActionListResult;
|
|
29
|
-
type ProcessParams = IBulkActionProcessParams
|
|
29
|
+
type ProcessParams<TData = Record<string, any>> = IBulkActionProcessParams<TData>;
|
|
30
30
|
}
|
|
31
31
|
interface IEntriesBulkActionConfig {
|
|
32
32
|
batchSize: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/EntriesBulkAction/abstractions.js","sources":["../../../src/features/EntriesBulkAction/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsEntry, CmsEntryMeta, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface IBulkActionListParams {\n where?: Record<string, any>;\n search?: string;\n after?: string | null;\n limit?: number;\n}\n\nexport interface IBulkActionListResult {\n entries: CmsEntry[];\n meta: CmsEntryMeta;\n}\n\nexport interface IBulkActionProcessParams {\n id: string;\n data
|
|
1
|
+
{"version":3,"file":"features/EntriesBulkAction/abstractions.js","sources":["../../../src/features/EntriesBulkAction/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsEntry, CmsEntryMeta, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface IBulkActionListParams {\n where?: Record<string, any>;\n search?: string;\n after?: string | null;\n limit?: number;\n}\n\nexport interface IBulkActionListResult {\n entries: CmsEntry[];\n meta: CmsEntryMeta;\n}\n\nexport interface IBulkActionProcessParams<TData = Record<string, any>> {\n id: string;\n // The `data` payload the Admin action sent along with the trigger. Type it by\n // parameterizing `EntriesBulkAction.Interface<TData>` on your implementation.\n data?: TData;\n}\n\nexport interface IEntriesBulkAction<TData = Record<string, any>> {\n readonly name: string;\n readonly modelIds?: string[]; // Optional: filter which models get GraphQL mutations\n readonly batchSize?: number;\n loadData(model: CmsModel, params: IBulkActionListParams): Promise<IBulkActionListResult>;\n processData(model: CmsModel, params: IBulkActionProcessParams<TData>): Promise<void>;\n}\n\nexport const EntriesBulkAction = createAbstraction<IEntriesBulkAction>(\"EntriesBulkAction\");\n\nexport namespace EntriesBulkAction {\n export type Interface<TData = Record<string, any>> = IEntriesBulkAction<TData>;\n export type Model = CmsModel;\n export type LoadDataParams = IBulkActionListParams;\n export type LoadDataResult = IBulkActionListResult;\n export type ProcessParams<TData = Record<string, any>> = IBulkActionProcessParams<TData>;\n}\n\ninterface IEntriesBulkActionConfig {\n batchSize: number;\n}\n\nexport const EntriesBulkActionConfig =\n createAbstraction<IEntriesBulkActionConfig>(\"EntriesBulkActionConfig\");\n\nexport namespace EntriesBulkActionConfig {\n export type Interface = IEntriesBulkActionConfig;\n}\n"],"names":["EntriesBulkAction","createAbstraction","EntriesBulkActionConfig"],"mappings":";AA8BO,MAAMA,oBAAoBC,kBAAsC;AAchE,MAAMC,0BACTD,kBAA4C"}
|
|
@@ -1,5 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
2
|
+
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
3
|
+
import { ListTasksUseCase, TriggerTaskUseCase, TasksCrud } from "@webiny/background-tasks/api";
|
|
4
|
+
import type { IBulkActionOperationByModelInput, IBulkActionOperationByModelOutput, IBulkActionOperationInput, IBulkActionOperationOutput } from "../../types.js";
|
|
5
|
+
import { EntriesBulkActionConfig } from "./abstractions.js";
|
|
6
|
+
import type { Container } from "@webiny/di";
|
|
7
|
+
export declare const BULK_ACTION_LIST_TASK_ID = "hcmsBulkListEntries";
|
|
8
|
+
export declare const BULK_ACTION_PROCESS_TASK_ID = "hcmsBulkProcessEntries";
|
|
9
|
+
declare class BulkActionListTask implements TaskDefinition.Interface<IBulkActionOperationByModelInput, IBulkActionOperationByModelOutput> {
|
|
10
|
+
private readonly container;
|
|
11
|
+
private readonly getModel;
|
|
12
|
+
private readonly listTasks;
|
|
13
|
+
private readonly triggerTask;
|
|
14
|
+
private readonly tasksCrud;
|
|
15
|
+
private readonly bulkActionsConfig;
|
|
16
|
+
readonly id = "hcmsBulkListEntries";
|
|
17
|
+
readonly title = "Headless CMS: list entries for bulk action";
|
|
18
|
+
readonly maxIterations = 500;
|
|
19
|
+
readonly databaseLogs = false;
|
|
20
|
+
readonly isPrivate = true;
|
|
21
|
+
readonly selfCleanup: ("onAbort" | "onSuccess")[];
|
|
22
|
+
constructor(container: Container, getModel: GetModelUseCase.Interface, listTasks: ListTasksUseCase.Interface, triggerTask: TriggerTaskUseCase.Interface, tasksCrud: TasksCrud.Interface, bulkActionsConfig: EntriesBulkActionConfig.Interface);
|
|
23
|
+
run({ input, controller, definition }: TaskDefinition.RunParams<IBulkActionOperationByModelInput, IBulkActionOperationByModelOutput>): Promise<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskResultAborted | import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskResultError | TaskDefinition.ResultContinue<IBulkActionOperationByModelInput> | TaskDefinition.ResultDone<IBulkActionOperationByModelOutput>>;
|
|
24
|
+
onDone({ task }: TaskDefinition.LifecycleHookParams): Promise<void>;
|
|
25
|
+
onError({ task }: TaskDefinition.LifecycleHookParams): Promise<void>;
|
|
26
|
+
onAbort({ task }: TaskDefinition.LifecycleHookParams): Promise<void>;
|
|
27
|
+
onMaxIterations({ task }: TaskDefinition.LifecycleHookParams): Promise<void>;
|
|
28
|
+
cleanup(task: TaskDefinition.Task): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
declare class BulkActionProcessTask implements TaskDefinition.Interface<IBulkActionOperationInput, IBulkActionOperationOutput> {
|
|
31
|
+
private readonly container;
|
|
32
|
+
private readonly getModel;
|
|
33
|
+
readonly id = "hcmsBulkProcessEntries";
|
|
34
|
+
readonly title = "Headless CMS: process entries for bulk action";
|
|
35
|
+
readonly maxIterations = 2;
|
|
36
|
+
readonly databaseLogs = false;
|
|
37
|
+
readonly isPrivate = true;
|
|
38
|
+
readonly selfCleanup: ("onAbort" | "onSuccess")[];
|
|
39
|
+
constructor(container: Container, getModel: GetModelUseCase.Interface);
|
|
40
|
+
run({ input, controller, definition }: TaskDefinition.RunParams<IBulkActionOperationInput, IBulkActionOperationOutput>): Promise<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskResultAborted | import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskResultError | TaskDefinition.ResultContinue<IBulkActionOperationInput> | TaskDefinition.ResultDone<IBulkActionOperationOutput>>;
|
|
41
|
+
}
|
|
42
|
+
export declare const BulkActionListTaskDefinition: typeof BulkActionListTask & {
|
|
43
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskDefinition<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskOutput>>;
|
|
5
44
|
};
|
|
45
|
+
export declare const BulkActionProcessTaskDefinition: typeof BulkActionProcessTask & {
|
|
46
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskDefinition<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskOutput>>;
|
|
47
|
+
};
|
|
48
|
+
export {};
|
|
@@ -1,136 +1,147 @@
|
|
|
1
|
-
import { createFeature } from "@webiny/feature/api";
|
|
2
1
|
import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
3
2
|
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
4
3
|
import { ListTasksUseCase, TasksCrud, TriggerTaskUseCase } from "@webiny/background-tasks/api";
|
|
4
|
+
import { BulkActionOperationByModelAction } from "../../types.js";
|
|
5
|
+
import { EntriesBulkAction, EntriesBulkActionConfig } from "./abstractions.js";
|
|
5
6
|
import { BulkActionName } from "../../domain/BulkActionName.js";
|
|
6
7
|
import { ChildTasksCleanup } from "./internals/ChildTasksCleanup.js";
|
|
7
8
|
import { ProcessTask } from "./internals/ProcessTask.js";
|
|
8
9
|
import { CreateTasksByModel } from "./internals/CreateTasksByModel.js";
|
|
9
10
|
import { ProcessTasksByModel } from "./internals/ProcessTasksByModel.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
async onAbort({ task }) {
|
|
69
|
-
await this.cleanup(task);
|
|
70
|
-
}
|
|
71
|
-
async onMaxIterations({ task }) {
|
|
72
|
-
await this.cleanup(task);
|
|
73
|
-
}
|
|
74
|
-
async cleanup(task) {
|
|
75
|
-
const childTasksCleanup = new ChildTasksCleanup();
|
|
76
|
-
try {
|
|
77
|
-
await childTasksCleanup.execute({
|
|
78
|
-
tasksCrud: this.tasksCrud,
|
|
79
|
-
task
|
|
80
|
-
});
|
|
81
|
-
} catch (ex) {
|
|
82
|
-
console.error(`Error while cleaning "${listTaskId}" child tasks.`, ex);
|
|
11
|
+
import { RequestContainer } from "@webiny/event-handler-core";
|
|
12
|
+
const BULK_ACTION_LIST_TASK_ID = "hcmsBulkListEntries";
|
|
13
|
+
const BULK_ACTION_PROCESS_TASK_ID = "hcmsBulkProcessEntries";
|
|
14
|
+
const resolveBulkAction = (container, actionName)=>{
|
|
15
|
+
const bulkActions = container.resolveAll(EntriesBulkAction);
|
|
16
|
+
const action = bulkActions.find((a)=>BulkActionName.from(a.name) === actionName);
|
|
17
|
+
if (!action) throw new Error(`Unknown bulk action: "${actionName}"`);
|
|
18
|
+
return action;
|
|
19
|
+
};
|
|
20
|
+
class BulkActionListTask {
|
|
21
|
+
constructor(container, getModel, listTasks, triggerTask, tasksCrud, bulkActionsConfig){
|
|
22
|
+
this.container = container;
|
|
23
|
+
this.getModel = getModel;
|
|
24
|
+
this.listTasks = listTasks;
|
|
25
|
+
this.triggerTask = triggerTask;
|
|
26
|
+
this.tasksCrud = tasksCrud;
|
|
27
|
+
this.bulkActionsConfig = bulkActionsConfig;
|
|
28
|
+
this.id = BULK_ACTION_LIST_TASK_ID;
|
|
29
|
+
this.title = "Headless CMS: list entries for bulk action";
|
|
30
|
+
this.maxIterations = 500;
|
|
31
|
+
this.databaseLogs = false;
|
|
32
|
+
this.isPrivate = true;
|
|
33
|
+
this.selfCleanup = [
|
|
34
|
+
"onSuccess",
|
|
35
|
+
"onAbort"
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
async run({ input, controller, definition }) {
|
|
39
|
+
try {
|
|
40
|
+
if (!input.modelId) return controller.response.error('Missing "modelId" in the input.');
|
|
41
|
+
if (!input.actionName) return controller.response.error('Missing "actionName" in the input.');
|
|
42
|
+
const bulkAction = resolveBulkAction(this.container, input.actionName);
|
|
43
|
+
const batchSize = bulkAction.batchSize ?? this.bulkActionsConfig.batchSize ?? 100;
|
|
44
|
+
const action = input.action ?? BulkActionOperationByModelAction.CREATE_SUBTASKS;
|
|
45
|
+
switch(action){
|
|
46
|
+
case BulkActionOperationByModelAction.PROCESS_SUBTASKS:
|
|
47
|
+
{
|
|
48
|
+
const processTasks = new ProcessTasksByModel(this.listTasks, BULK_ACTION_PROCESS_TASK_ID);
|
|
49
|
+
return await processTasks.execute({
|
|
50
|
+
input,
|
|
51
|
+
controller,
|
|
52
|
+
definition
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
case BulkActionOperationByModelAction.CREATE_SUBTASKS:
|
|
56
|
+
case BulkActionOperationByModelAction.CHECK_MORE_SUBTASKS:
|
|
57
|
+
{
|
|
58
|
+
const createTasks = new CreateTasksByModel(this.getModel, this.triggerTask, bulkAction, BULK_ACTION_PROCESS_TASK_ID, batchSize);
|
|
59
|
+
return await createTasks.execute({
|
|
60
|
+
input,
|
|
61
|
+
controller,
|
|
62
|
+
definition
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
case BulkActionOperationByModelAction.END_TASK:
|
|
66
|
+
return controller.response.done(`Task done: bulk action "${input.actionName}" has been successfully processed for entries from "${input.modelId}" model.`);
|
|
67
|
+
default:
|
|
68
|
+
return controller.response.error(`Unknown action: ${action}`);
|
|
83
69
|
}
|
|
70
|
+
} catch (ex) {
|
|
71
|
+
return controller.response.error(ex.message ?? "Error while executing bulk action list task");
|
|
84
72
|
}
|
|
85
73
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return controller.response.error(ex.message ?? "Error while executing process task");
|
|
108
|
-
}
|
|
74
|
+
async onDone({ task }) {
|
|
75
|
+
await this.cleanup(task);
|
|
76
|
+
}
|
|
77
|
+
async onError({ task }) {
|
|
78
|
+
await this.cleanup(task);
|
|
79
|
+
}
|
|
80
|
+
async onAbort({ task }) {
|
|
81
|
+
await this.cleanup(task);
|
|
82
|
+
}
|
|
83
|
+
async onMaxIterations({ task }) {
|
|
84
|
+
await this.cleanup(task);
|
|
85
|
+
}
|
|
86
|
+
async cleanup(task) {
|
|
87
|
+
const childTasksCleanup = new ChildTasksCleanup();
|
|
88
|
+
try {
|
|
89
|
+
await childTasksCleanup.execute({
|
|
90
|
+
tasksCrud: this.tasksCrud,
|
|
91
|
+
task
|
|
92
|
+
});
|
|
93
|
+
} catch (ex) {
|
|
94
|
+
console.error("Error while cleaning bulk action list child tasks.", ex);
|
|
109
95
|
}
|
|
110
96
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
]
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
container.
|
|
130
|
-
|
|
97
|
+
}
|
|
98
|
+
class BulkActionProcessTask {
|
|
99
|
+
constructor(container, getModel){
|
|
100
|
+
this.container = container;
|
|
101
|
+
this.getModel = getModel;
|
|
102
|
+
this.id = BULK_ACTION_PROCESS_TASK_ID;
|
|
103
|
+
this.title = "Headless CMS: process entries for bulk action";
|
|
104
|
+
this.maxIterations = 2;
|
|
105
|
+
this.databaseLogs = false;
|
|
106
|
+
this.isPrivate = true;
|
|
107
|
+
this.selfCleanup = [
|
|
108
|
+
"onSuccess",
|
|
109
|
+
"onAbort"
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
async run({ input, controller, definition }) {
|
|
113
|
+
try {
|
|
114
|
+
if (!input.actionName) return controller.response.error('Missing "actionName" in the input.');
|
|
115
|
+
const bulkAction = resolveBulkAction(this.container, input.actionName);
|
|
116
|
+
const processTask = new ProcessTask(bulkAction, this.getModel);
|
|
117
|
+
return await processTask.execute({
|
|
118
|
+
input,
|
|
119
|
+
controller,
|
|
120
|
+
definition
|
|
121
|
+
});
|
|
122
|
+
} catch (ex) {
|
|
123
|
+
return controller.response.error(ex.message ?? "Error while executing bulk action process task");
|
|
131
124
|
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const BulkActionListTaskDefinition = TaskDefinition.createImplementation({
|
|
128
|
+
implementation: BulkActionListTask,
|
|
129
|
+
dependencies: [
|
|
130
|
+
RequestContainer,
|
|
131
|
+
GetModelUseCase,
|
|
132
|
+
ListTasksUseCase,
|
|
133
|
+
TriggerTaskUseCase,
|
|
134
|
+
TasksCrud,
|
|
135
|
+
EntriesBulkActionConfig
|
|
136
|
+
]
|
|
137
|
+
});
|
|
138
|
+
const BulkActionProcessTaskDefinition = TaskDefinition.createImplementation({
|
|
139
|
+
implementation: BulkActionProcessTask,
|
|
140
|
+
dependencies: [
|
|
141
|
+
RequestContainer,
|
|
142
|
+
GetModelUseCase
|
|
143
|
+
]
|
|
144
|
+
});
|
|
145
|
+
export { BULK_ACTION_LIST_TASK_ID, BULK_ACTION_PROCESS_TASK_ID, BulkActionListTaskDefinition, BulkActionProcessTaskDefinition };
|
|
135
146
|
|
|
136
147
|
//# sourceMappingURL=createBulkActionTasks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/EntriesBulkAction/createBulkActionTasks.js","sources":["../../../src/features/EntriesBulkAction/createBulkActionTasks.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { ListTasksUseCase, TriggerTaskUseCase, TasksCrud } from \"@webiny/background-tasks/api\";\nimport type {\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput,\n IBulkActionOperationInput,\n IBulkActionOperationOutput\n} from \"~/types.js\";\nimport { EntriesBulkAction, EntriesBulkActionConfig } from \"./abstractions.js\";\nimport { BulkActionName } from \"~/domain/BulkActionName.js\";\nimport { ChildTasksCleanup } from \"./internals/ChildTasksCleanup.js\";\nimport { ProcessTask } from \"./internals/ProcessTask.js\";\nimport { CreateTasksByModel } from \"./internals/CreateTasksByModel.js\";\nimport { ProcessTasksByModel } from \"./internals/ProcessTasksByModel.js\";\n\nenum BulkActionOperationByModelAction {\n CREATE_SUBTASKS = \"CREATE_SUBTASKS\",\n CHECK_MORE_SUBTASKS = \"CHECK_MORE_SUBTASKS\",\n PROCESS_SUBTASKS = \"PROCESS_SUBTASKS\",\n END_TASK = \"END_TASK\"\n}\n\nexport const createBulkActionTasks = (\n bulkAction: EntriesBulkAction.Interface,\n bulkActionsConfig: EntriesBulkActionConfig.Interface\n) => {\n const bulkActionName = BulkActionName.from(bulkAction.name);\n const batchSize = bulkAction.batchSize ?? bulkActionsConfig.batchSize ?? 100;\n const listTaskId = `hcmsBulkList${bulkActionName}Entries`;\n const processTaskId = `hcmsBulkProcess${bulkActionName}Entries`;\n\n // List Task - manages pagination and creates subtasks\n class BulkActionListTask implements TaskDefinition.Interface<\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput\n > {\n public readonly id = listTaskId;\n public readonly title = `Headless CMS: list \"${bulkActionName}\" entries by model`;\n public readonly maxIterations = 500;\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly getModel: GetModelUseCase.Interface;\n public readonly listTasks: ListTasksUseCase.Interface;\n public readonly triggerTask: TriggerTaskUseCase.Interface;\n public readonly tasksCrud: TasksCrud.Interface;\n\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n constructor(\n getModel: GetModelUseCase.Interface,\n listTasks: ListTasksUseCase.Interface,\n triggerTask: TriggerTaskUseCase.Interface,\n tasksCrud: TasksCrud.Interface\n ) {\n this.getModel = getModel;\n this.listTasks = listTasks;\n this.triggerTask = triggerTask;\n this.tasksCrud = tasksCrud;\n }\n\n async run({\n input,\n controller\n }: TaskDefinition.RunParams<\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput\n >) {\n try {\n if (!input.modelId) {\n return controller.response.error(`Missing \"modelId\" in the input.`);\n }\n\n const action = input.action ?? BulkActionOperationByModelAction.CREATE_SUBTASKS;\n\n switch (action) {\n case BulkActionOperationByModelAction.PROCESS_SUBTASKS: {\n const processTasks = new ProcessTasksByModel(this.listTasks, processTaskId);\n return await processTasks.execute({ input, controller });\n }\n case BulkActionOperationByModelAction.CREATE_SUBTASKS:\n case BulkActionOperationByModelAction.CHECK_MORE_SUBTASKS: {\n const createTasks = new CreateTasksByModel(\n this.getModel,\n this.triggerTask,\n bulkAction,\n processTaskId,\n batchSize\n );\n return await createTasks.execute({ input, controller });\n }\n case BulkActionOperationByModelAction.END_TASK: {\n return controller.response.done(\n `Task done: task \"${processTaskId}\" has been successfully processed for entries from \"${\n input.modelId\n }\" model.`\n );\n }\n default:\n return controller.response.error(`Unknown action: ${action}`);\n }\n } catch (ex) {\n return controller.response.error(ex.message ?? \"Error while executing list task\");\n }\n }\n\n async onDone({ task }: TaskDefinition.LifecycleHookParams): Promise<void> {\n await this.cleanup(task);\n }\n\n async onError({ task }: TaskDefinition.LifecycleHookParams) {\n await this.cleanup(task);\n }\n\n async onAbort({ task }: TaskDefinition.LifecycleHookParams) {\n await this.cleanup(task);\n }\n\n async onMaxIterations({ task }: TaskDefinition.LifecycleHookParams) {\n await this.cleanup(task);\n }\n\n async cleanup(task: TaskDefinition.Task) {\n const childTasksCleanup = new ChildTasksCleanup();\n try {\n await childTasksCleanup.execute({ tasksCrud: this.tasksCrud, task });\n } catch (ex) {\n console.error(`Error while cleaning \"${listTaskId}\" child tasks.`, ex);\n }\n }\n }\n\n // Process Task - processes individual batches of entries\n class BulkActionProcessTask implements TaskDefinition.Interface<\n IBulkActionOperationInput,\n IBulkActionOperationOutput\n > {\n public readonly id = processTaskId;\n public readonly title = `Headless CMS: process \"${bulkActionName}\" entries`;\n public readonly maxIterations = 2;\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly getModel: GetModelUseCase.Interface;\n\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n constructor(getModel: GetModelUseCase.Interface) {\n this.getModel = getModel;\n }\n\n async run({\n input,\n controller\n }: TaskDefinition.RunParams<IBulkActionOperationInput, IBulkActionOperationOutput>) {\n try {\n const processTask = new ProcessTask(bulkAction, this.getModel);\n return await processTask.execute({ input, controller });\n } catch (ex) {\n return controller.response.error(\n ex.message ?? \"Error while executing process task\"\n );\n }\n }\n }\n\n const BulkListTask = TaskDefinition.createImplementation({\n implementation: BulkActionListTask,\n dependencies: [GetModelUseCase, ListTasksUseCase, TriggerTaskUseCase, TasksCrud]\n });\n\n const BulkProcessTask = TaskDefinition.createImplementation({\n implementation: BulkActionProcessTask,\n dependencies: [GetModelUseCase]\n });\n\n return createFeature({\n name: `HeadlessCms/BulkActionTasks/${bulkActionName}`,\n register(container) {\n container.register(BulkListTask);\n container.register(BulkProcessTask);\n }\n });\n};\n"],"names":["createBulkActionTasks","bulkAction","bulkActionsConfig","bulkActionName","BulkActionName","batchSize","listTaskId","processTaskId","BulkActionListTask","getModel","listTasks","triggerTask","tasksCrud","input","controller","action","processTasks","ProcessTasksByModel","createTasks","CreateTasksByModel","ex","task","childTasksCleanup","ChildTasksCleanup","console","BulkActionProcessTask","processTask","ProcessTask","BulkListTask","TaskDefinition","GetModelUseCase","ListTasksUseCase","TriggerTaskUseCase","TasksCrud","BulkProcessTask","createFeature","container"],"mappings":";;;;;;;;;AAwBO,MAAMA,wBAAwB,CACjCC,YACAC;IAEA,MAAMC,iBAAiBC,eAAe,IAAI,CAACH,WAAW,I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gBAC7D,OAAO,MAAMyB,YAAY,OAAO,CAAC;oBAAEb;oBAAOC;gBAAW;YACzD,EAAE,OAAOM,IAAI;gBACT,OAAON,WAAW,QAAQ,CAAC,KAAK,CAC5BM,GAAG,OAAO,IAAI;YAEtB;QACJ;IACJ;IAEA,MAAMQ,eAAeC,eAAe,oBAAoB,CAAC;QACrD,gBAAgBrB;QAChB,cAAc;YAACsB;YAAiBC;YAAkBC;YAAoBC;SAAU;IACpF;IAEA,MAAMC,kBAAkBL,eAAe,oBAAoB,CAAC;QACxD,gBAAgBJ;QAChB,cAAc;YAACK;SAAgB;IACnC;IAEA,OAAOK,cAAc;QACjB,MAAM,CAAC,4BAA4B,EAAEhC,gBAAgB;QACrD,UAASiC,SAAS;YACdA,UAAU,QAAQ,CAACR;YACnBQ,UAAU,QAAQ,CAACF;QACvB;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"features/EntriesBulkAction/createBulkActionTasks.js","sources":["../../../src/features/EntriesBulkAction/createBulkActionTasks.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { ListTasksUseCase, TriggerTaskUseCase, TasksCrud } from \"@webiny/background-tasks/api\";\nimport type {\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput,\n IBulkActionOperationInput,\n IBulkActionOperationOutput\n} from \"~/types.js\";\nimport { BulkActionOperationByModelAction } from \"~/types.js\";\nimport { EntriesBulkAction, EntriesBulkActionConfig } from \"./abstractions.js\";\nimport { BulkActionName } from \"~/domain/BulkActionName.js\";\nimport { ChildTasksCleanup } from \"./internals/ChildTasksCleanup.js\";\nimport { ProcessTask } from \"./internals/ProcessTask.js\";\nimport { CreateTasksByModel } from \"./internals/CreateTasksByModel.js\";\nimport { ProcessTasksByModel } from \"./internals/ProcessTasksByModel.js\";\nimport type { Container } from \"@webiny/di\";\n\nexport const BULK_ACTION_LIST_TASK_ID = \"hcmsBulkListEntries\";\nexport const BULK_ACTION_PROCESS_TASK_ID = \"hcmsBulkProcessEntries\";\n\nconst resolveBulkAction = (container: Container, actionName: string) => {\n const bulkActions = container.resolveAll(EntriesBulkAction);\n const action = bulkActions.find(a => BulkActionName.from(a.name) === actionName);\n if (!action) {\n throw new Error(`Unknown bulk action: \"${actionName}\"`);\n }\n return action;\n};\n\nclass BulkActionListTask implements TaskDefinition.Interface<\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput\n> {\n public readonly id = BULK_ACTION_LIST_TASK_ID;\n public readonly title = \"Headless CMS: list entries for bulk action\";\n public readonly maxIterations = 500;\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n constructor(\n private readonly container: Container,\n private readonly getModel: GetModelUseCase.Interface,\n private readonly listTasks: ListTasksUseCase.Interface,\n private readonly triggerTask: TriggerTaskUseCase.Interface,\n private readonly tasksCrud: TasksCrud.Interface,\n private readonly bulkActionsConfig: EntriesBulkActionConfig.Interface\n ) {}\n\n async run({\n input,\n controller,\n definition\n }: TaskDefinition.RunParams<\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput\n >) {\n try {\n if (!input.modelId) {\n return controller.response.error(`Missing \"modelId\" in the input.`);\n }\n if (!input.actionName) {\n return controller.response.error(`Missing \"actionName\" in the input.`);\n }\n\n const bulkAction = resolveBulkAction(this.container, input.actionName);\n const batchSize = bulkAction.batchSize ?? this.bulkActionsConfig.batchSize ?? 100;\n const action = input.action ?? BulkActionOperationByModelAction.CREATE_SUBTASKS;\n\n switch (action) {\n case BulkActionOperationByModelAction.PROCESS_SUBTASKS: {\n const processTasks = new ProcessTasksByModel(\n this.listTasks,\n BULK_ACTION_PROCESS_TASK_ID\n );\n return await processTasks.execute({ input, controller, definition });\n }\n case BulkActionOperationByModelAction.CREATE_SUBTASKS:\n case BulkActionOperationByModelAction.CHECK_MORE_SUBTASKS: {\n const createTasks = new CreateTasksByModel(\n this.getModel,\n this.triggerTask,\n bulkAction,\n BULK_ACTION_PROCESS_TASK_ID,\n batchSize\n );\n return await createTasks.execute({ input, controller, definition });\n }\n case BulkActionOperationByModelAction.END_TASK: {\n return controller.response.done(\n `Task done: bulk action \"${input.actionName}\" has been successfully processed for entries from \"${input.modelId}\" model.`\n );\n }\n default:\n return controller.response.error(`Unknown action: ${action}`);\n }\n } catch (ex) {\n return controller.response.error(\n ex.message ?? \"Error while executing bulk action list task\"\n );\n }\n }\n\n async onDone({ task }: TaskDefinition.LifecycleHookParams): Promise<void> {\n await this.cleanup(task);\n }\n\n async onError({ task }: TaskDefinition.LifecycleHookParams) {\n await this.cleanup(task);\n }\n\n async onAbort({ task }: TaskDefinition.LifecycleHookParams) {\n await this.cleanup(task);\n }\n\n async onMaxIterations({ task }: TaskDefinition.LifecycleHookParams) {\n await this.cleanup(task);\n }\n\n async cleanup(task: TaskDefinition.Task) {\n const childTasksCleanup = new ChildTasksCleanup();\n try {\n await childTasksCleanup.execute({ tasksCrud: this.tasksCrud, task });\n } catch (ex) {\n console.error(`Error while cleaning bulk action list child tasks.`, ex);\n }\n }\n}\n\nclass BulkActionProcessTask implements TaskDefinition.Interface<\n IBulkActionOperationInput,\n IBulkActionOperationOutput\n> {\n public readonly id = BULK_ACTION_PROCESS_TASK_ID;\n public readonly title = \"Headless CMS: process entries for bulk action\";\n public readonly maxIterations = 2;\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n constructor(\n private readonly container: Container,\n private readonly getModel: GetModelUseCase.Interface\n ) {}\n\n async run({\n input,\n controller,\n definition\n }: TaskDefinition.RunParams<IBulkActionOperationInput, IBulkActionOperationOutput>) {\n try {\n if (!input.actionName) {\n return controller.response.error(`Missing \"actionName\" in the input.`);\n }\n\n const bulkAction = resolveBulkAction(this.container, input.actionName);\n const processTask = new ProcessTask(bulkAction, this.getModel);\n return await processTask.execute({ input, controller, definition });\n } catch (ex) {\n return controller.response.error(\n ex.message ?? \"Error while executing bulk action process task\"\n );\n }\n }\n}\n\nimport { RequestContainer } from \"@webiny/event-handler-core\";\n\nexport const BulkActionListTaskDefinition = TaskDefinition.createImplementation({\n implementation: BulkActionListTask,\n dependencies: [\n RequestContainer,\n GetModelUseCase,\n ListTasksUseCase,\n TriggerTaskUseCase,\n TasksCrud,\n EntriesBulkActionConfig\n ]\n});\n\nexport const BulkActionProcessTaskDefinition = TaskDefinition.createImplementation({\n implementation: BulkActionProcessTask,\n dependencies: [RequestContainer, GetModelUseCase]\n});\n"],"names":["BULK_ACTION_LIST_TASK_ID","BULK_ACTION_PROCESS_TASK_ID","resolveBulkAction","container","actionName","bulkActions","EntriesBulkAction","action","a","BulkActionName","Error","BulkActionListTask","getModel","listTasks","triggerTask","tasksCrud","bulkActionsConfig","input","controller","definition","bulkAction","batchSize","BulkActionOperationByModelAction","processTasks","ProcessTasksByModel","createTasks","CreateTasksByModel","ex","task","childTasksCleanup","ChildTasksCleanup","console","BulkActionProcessTask","processTask","ProcessTask","BulkActionListTaskDefinition","TaskDefinition","RequestContainer","GetModelUseCase","ListTasksUseCase","TriggerTaskUseCase","TasksCrud","EntriesBulkActionConfig","BulkActionProcessTaskDefinition"],"mappings":";;;;;;;;;;;AAkBO,MAAMA,2BAA2B;AACjC,MAAMC,8BAA8B;AAE3C,MAAMC,oBAAoB,CAACC,WAAsBC;IAC7C,MAAMC,cAAcF,UAAU,UAAU,CAACG;IACzC,MAAMC,SAASF,YAAY,IAAI,CAACG,CAAAA,IAAKC,eAAe,IAAI,CAACD,EAAE,IAAI,MAAMJ;IACrE,IAAI,CAACG,QACD,MAAM,IAAIG,MAAM,CAAC,sBAAsB,EAAEN,WAAW,CAAC,CAAC;IAE1D,OAAOG;AACX;AAEA,MAAMI;IAWF,YACqBR,SAAoB,EACpBS,QAAmC,EACnCC,SAAqC,EACrCC,WAAyC,EACzCC,SAA8B,EAC9BC,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kBAAkB,IAAI,CAAC,SAAS,EAAEe,MAAM,UAAU;YACrE,MAAMgB,cAAc,IAAIC,YAAYd,YAAY,IAAI,CAAC,QAAQ;YAC7D,OAAO,MAAMa,YAAY,OAAO,CAAC;gBAAEhB;gBAAOC;gBAAYC;YAAW;QACrE,EAAE,OAAOQ,IAAI;YACT,OAAOT,WAAW,QAAQ,CAAC,KAAK,CAC5BS,GAAG,OAAO,IAAI;QAEtB;IACJ;AACJ;AAIO,MAAMQ,+BAA+BC,eAAe,oBAAoB,CAAC;IAC5E,gBAAgBzB;IAChB,cAAc;QACV0B;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL;AAEO,MAAMC,kCAAkCP,eAAe,oBAAoB,CAAC;IAC/E,gBAAgBJ;IAChB,cAAc;QAACK;QAAkBC;KAAgB;AACrD"}
|
|
@@ -52,6 +52,7 @@ class CreateTasksByModel {
|
|
|
52
52
|
const ids = [];
|
|
53
53
|
for(let i = 0; i < entries.length; i++)ids.push(entries[i].id);
|
|
54
54
|
if (ids.length > 0) this.taskCache.cacheTask({
|
|
55
|
+
actionName: input.actionName,
|
|
55
56
|
modelId: input.modelId,
|
|
56
57
|
identity: input.identity,
|
|
57
58
|
data: input.data,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/EntriesBulkAction/internals/CreateTasksByModel.js","sources":["../../../../src/features/EntriesBulkAction/internals/CreateTasksByModel.ts"],"sourcesContent":["import type { CmsEntryListParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport { TaskCache } from \"./TaskCache.js\";\nimport type { IBulkActionOperationByModelTaskParams } from \"~/types.js\";\nimport { BulkActionOperationByModelAction } from \"~/types.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport type { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport type { TriggerTaskUseCase } from \"@webiny/background-tasks/api\";\n\nconst MAX_TASK_LIST_LENGTH = 10;\n\n/**\n * The `CreateTasksByModel` class handles the execution of a task to process entries in batches.\n */\nexport class CreateTasksByModel {\n private readonly taskCache: TaskCache;\n private readonly batchSize: number;\n private readonly bulkAction: EntriesBulkAction.Interface;\n private readonly triggerTask: TriggerTaskUseCase.Interface;\n private readonly getModel: GetModelUseCase.Interface;\n\n constructor(\n getModel: GetModelUseCase.Interface,\n triggerTask: TriggerTaskUseCase.Interface,\n bulkAction: EntriesBulkAction.Interface,\n taskDefinition: string,\n batchSize: number\n ) {\n this.getModel = getModel;\n this.taskCache = new TaskCache(taskDefinition);\n this.batchSize = batchSize;\n this.bulkAction = bulkAction;\n this.triggerTask = triggerTask;\n }\n\n async execute(params: IBulkActionOperationByModelTaskParams) {\n const { input, controller } = params;\n\n try {\n const modelResult = await this.getModel.execute(input.modelId);\n\n if (modelResult.isFail()) {\n return controller.response.error(`Model with ${input.modelId} not found!`);\n }\n\n const model = modelResult.value;\n\n const listEntriesParams: CmsEntryListParams = {\n where: input.where,\n search: input.search,\n after: input.after,\n limit: this.batchSize\n };\n\n while (true) {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n } else if (controller.runtime.isCloseToTimeout()) {\n await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n // List entries from the HCMS based on the provided query\n const { entries, meta } = await this.bulkAction.loadData(model, listEntriesParams);\n\n // End the task if no entries match the query\n if (meta.totalCount === 0) {\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.END_TASK\n });\n }\n\n // Continue processing if we are reached the task list length limit\n if (this.taskCache.getTasksLength() === MAX_TASK_LIST_LENGTH) {\n await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n // Continue processing if no entries are returned in the current batch\n if (entries.length === 0) {\n await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n // Extract entry IDs\n const ids: string[] = [];\n for (let i = 0; i < entries.length; i++) {\n ids.push(entries[i].id);\n }\n\n if (ids.length > 0) {\n
|
|
1
|
+
{"version":3,"file":"features/EntriesBulkAction/internals/CreateTasksByModel.js","sources":["../../../../src/features/EntriesBulkAction/internals/CreateTasksByModel.ts"],"sourcesContent":["import type { CmsEntryListParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport { TaskCache } from \"./TaskCache.js\";\nimport type { IBulkActionOperationByModelTaskParams } from \"~/types.js\";\nimport { BulkActionOperationByModelAction } from \"~/types.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport type { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport type { TriggerTaskUseCase } from \"@webiny/background-tasks/api\";\n\nconst MAX_TASK_LIST_LENGTH = 10;\n\n/**\n * The `CreateTasksByModel` class handles the execution of a task to process entries in batches.\n */\nexport class CreateTasksByModel {\n private readonly taskCache: TaskCache;\n private readonly batchSize: number;\n private readonly bulkAction: EntriesBulkAction.Interface;\n private readonly triggerTask: TriggerTaskUseCase.Interface;\n private readonly getModel: GetModelUseCase.Interface;\n\n constructor(\n getModel: GetModelUseCase.Interface,\n triggerTask: TriggerTaskUseCase.Interface,\n bulkAction: EntriesBulkAction.Interface,\n taskDefinition: string,\n batchSize: number\n ) {\n this.getModel = getModel;\n this.taskCache = new TaskCache(taskDefinition);\n this.batchSize = batchSize;\n this.bulkAction = bulkAction;\n this.triggerTask = triggerTask;\n }\n\n async execute(params: IBulkActionOperationByModelTaskParams) {\n const { input, controller } = params;\n\n try {\n const modelResult = await this.getModel.execute(input.modelId);\n\n if (modelResult.isFail()) {\n return controller.response.error(`Model with ${input.modelId} not found!`);\n }\n\n const model = modelResult.value;\n\n const listEntriesParams: CmsEntryListParams = {\n where: input.where,\n search: input.search,\n after: input.after,\n limit: this.batchSize\n };\n\n while (true) {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n } else if (controller.runtime.isCloseToTimeout()) {\n await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n // List entries from the HCMS based on the provided query\n const { entries, meta } = await this.bulkAction.loadData(model, listEntriesParams);\n\n // End the task if no entries match the query\n if (meta.totalCount === 0) {\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.END_TASK\n });\n }\n\n // Continue processing if we are reached the task list length limit\n if (this.taskCache.getTasksLength() === MAX_TASK_LIST_LENGTH) {\n await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n // Continue processing if no entries are returned in the current batch\n if (entries.length === 0) {\n await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n // Extract entry IDs\n const ids: string[] = [];\n for (let i = 0; i < entries.length; i++) {\n ids.push(entries[i].id);\n }\n\n if (ids.length > 0) {\n this.taskCache.cacheTask({\n actionName: input.actionName,\n modelId: input.modelId,\n identity: input.identity,\n data: input.data,\n ids\n });\n }\n\n // Continue processing if there are no more entries or pagination is complete\n if (!meta.hasMoreItems || !meta.cursor) {\n await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());\n\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n listEntriesParams.after = meta.cursor;\n }\n } catch (ex) {\n return controller.response.error(ex.message ?? `Error while creating task.`);\n }\n }\n}\n"],"names":["MAX_TASK_LIST_LENGTH","CreateTasksByModel","getModel","triggerTask","bulkAction","taskDefinition","batchSize","TaskCache","params","input","controller","modelResult","model","listEntriesParams","BulkActionOperationByModel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CAAC,QAAQ,CAAC;wBAChC,GAAGD,KAAK;wBACR,QAAQK,iCAAiC,gBAAgB;oBAC7D;gBACJ;gBAEAD,kBAAkB,KAAK,GAAGG,KAAK,MAAM;YACzC;QACJ,EAAE,OAAOG,IAAI;YACT,OAAOT,WAAW,QAAQ,CAAC,KAAK,CAACS,GAAG,OAAO,IAAI;QACnD;IACJ;AACJ"}
|
|
@@ -10,6 +10,6 @@ declare class MoveToFolderBulkActionImpl implements EntriesBulkAction.Interface
|
|
|
10
10
|
processData(model: EntriesBulkAction.Model, params: EntriesBulkAction.ProcessParams): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export declare const MoveToFolderBulkAction: typeof MoveToFolderBulkActionImpl & {
|
|
13
|
-
__abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction<Record<string, any>>>;
|
|
14
14
|
};
|
|
15
15
|
export {};
|
|
@@ -10,6 +10,6 @@ declare class MoveToTrashBulkActionImpl implements EntriesBulkAction.Interface {
|
|
|
10
10
|
processData(model: EntriesBulkAction.Model, params: EntriesBulkAction.ProcessParams): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export declare const MoveToTrashBulkAction: typeof MoveToTrashBulkActionImpl & {
|
|
13
|
-
__abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction<Record<string, any>>>;
|
|
14
14
|
};
|
|
15
15
|
export {};
|
|
@@ -10,6 +10,6 @@ declare class PublishEntriesBulkActionImpl implements EntriesBulkAction.Interfac
|
|
|
10
10
|
processData(model: EntriesBulkAction.Model, params: EntriesBulkAction.ProcessParams): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export declare const PublishEntriesBulkAction: typeof PublishEntriesBulkActionImpl & {
|
|
13
|
-
__abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction<Record<string, any>>>;
|
|
14
14
|
};
|
|
15
15
|
export {};
|
|
@@ -10,6 +10,6 @@ declare class RestoreEntriesBulkActionImpl implements EntriesBulkAction.Interfac
|
|
|
10
10
|
processData(model: EntriesBulkAction.Model, params: EntriesBulkAction.ProcessParams): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export declare const RestoreEntriesBulkAction: typeof RestoreEntriesBulkActionImpl & {
|
|
13
|
-
__abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction<Record<string, any>>>;
|
|
14
14
|
};
|
|
15
15
|
export {};
|
|
@@ -10,6 +10,6 @@ declare class UnpublishEntriesBulkActionImpl implements EntriesBulkAction.Interf
|
|
|
10
10
|
processData(model: EntriesBulkAction.Model, params: EntriesBulkAction.ProcessParams): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export declare const UnpublishEntriesBulkAction: typeof UnpublishEntriesBulkActionImpl & {
|
|
13
|
-
__abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction<Record<string, any>>>;
|
|
14
14
|
};
|
|
15
15
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Container } from "@webiny/di";
|
|
2
|
+
import { CmsGraphQLSchemaPlugin, CmsGraphQLSchemaFactory } from "@webiny/api-headless-cms";
|
|
3
|
+
import type { HcmsBulkActionsContext } from "../types.js";
|
|
4
|
+
declare class BulkActionsGraphQLSchemaImpl implements CmsGraphQLSchemaFactory.Interface {
|
|
5
|
+
private readonly container;
|
|
6
|
+
constructor(container: Container);
|
|
7
|
+
execute(): Promise<CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[]>;
|
|
8
|
+
}
|
|
9
|
+
export declare const BulkActionsGraphQLSchema: typeof BulkActionsGraphQLSchemaImpl & {
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms").ICmsGraphQLSchemaFactory>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { CmsGraphQLSchemaFactory, CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from "@webiny/api-headless-cms";
|
|
2
|
+
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
3
|
+
import { CMS_MODEL_SINGLETON_TAG } from "@webiny/api-headless-cms/constants.js";
|
|
4
|
+
import { Response } from "@webiny/api-graphql";
|
|
5
|
+
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
6
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
7
|
+
import { TriggerTaskUseCase } from "@webiny/background-tasks/api";
|
|
8
|
+
import { EntriesBulkAction } from "../features/EntriesBulkAction/abstractions.js";
|
|
9
|
+
import { BulkActionName } from "../domain/BulkActionName.js";
|
|
10
|
+
import { BULK_ACTION_LIST_TASK_ID } from "../features/EntriesBulkAction/createBulkActionTasks.js";
|
|
11
|
+
import { RequestContainer } from "@webiny/event-handler-core";
|
|
12
|
+
class BulkActionsGraphQLSchemaImpl {
|
|
13
|
+
constructor(container){
|
|
14
|
+
this.container = container;
|
|
15
|
+
}
|
|
16
|
+
async execute() {
|
|
17
|
+
const context = {
|
|
18
|
+
container: this.container
|
|
19
|
+
};
|
|
20
|
+
const tenantCtx = this.container.resolve(TenantContext);
|
|
21
|
+
const tenant = tenantCtx.getTenant();
|
|
22
|
+
if (!await isHeadlessCmsReady(context)) return [];
|
|
23
|
+
const identityCtx = this.container.resolve(IdentityContext);
|
|
24
|
+
const modelsResult = await identityCtx.withoutAuthorization(async ()=>this.container.resolve(ListModelsUseCase).execute());
|
|
25
|
+
if (modelsResult.isFail()) return [];
|
|
26
|
+
const allModels = modelsResult.value.filter((model)=>{
|
|
27
|
+
if (model.isPrivate) return false;
|
|
28
|
+
const tags = Array.isArray(model.tags) ? model.tags : [];
|
|
29
|
+
return !tags.includes(CMS_MODEL_SINGLETON_TAG);
|
|
30
|
+
});
|
|
31
|
+
const bulkActions = this.container.resolveAll(EntriesBulkAction);
|
|
32
|
+
const plugins = [];
|
|
33
|
+
const defaultPlugin = new CmsGraphQLSchemaPlugin({
|
|
34
|
+
typeDefs: `
|
|
35
|
+
type BulkActionResponseData {
|
|
36
|
+
id: String
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type BulkActionResponse {
|
|
40
|
+
data: BulkActionResponseData
|
|
41
|
+
error: CmsError
|
|
42
|
+
}
|
|
43
|
+
`
|
|
44
|
+
});
|
|
45
|
+
defaultPlugin.name = "headless-cms.graphql.schema.bulkAction.default";
|
|
46
|
+
plugins.push(defaultPlugin);
|
|
47
|
+
for (const model of allModels){
|
|
48
|
+
const applicableActions = bulkActions.filter((action)=>{
|
|
49
|
+
if (action.modelIds?.length) return action.modelIds.includes(model.modelId);
|
|
50
|
+
return true;
|
|
51
|
+
});
|
|
52
|
+
const enumValues = applicableActions.map((action)=>BulkActionName.from(action.name)).join("\n ");
|
|
53
|
+
const modelPlugin = new CmsGraphQLSchemaPlugin({
|
|
54
|
+
typeDefs: `
|
|
55
|
+
enum BulkAction${model.singularApiName}Name {
|
|
56
|
+
_empty
|
|
57
|
+
${enumValues}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
extend type Mutation {
|
|
61
|
+
bulkAction${model.singularApiName}(
|
|
62
|
+
action: BulkAction${model.singularApiName}Name!
|
|
63
|
+
where: ${model.singularApiName}ListWhereInput
|
|
64
|
+
search: String
|
|
65
|
+
data: JSON
|
|
66
|
+
): BulkActionResponse
|
|
67
|
+
}
|
|
68
|
+
`,
|
|
69
|
+
resolvers: {
|
|
70
|
+
Mutation: {
|
|
71
|
+
[`bulkAction${model.singularApiName}`]: async (_, args, context)=>{
|
|
72
|
+
const identity = context.container.resolve(IdentityContext).getIdentity();
|
|
73
|
+
const response = await context.container.resolve(TriggerTaskUseCase).execute({
|
|
74
|
+
definition: BULK_ACTION_LIST_TASK_ID,
|
|
75
|
+
input: {
|
|
76
|
+
actionName: args.action,
|
|
77
|
+
modelId: model.modelId,
|
|
78
|
+
where: args.where,
|
|
79
|
+
search: args.search,
|
|
80
|
+
data: args.data,
|
|
81
|
+
identity
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return new Response({
|
|
85
|
+
id: response.value.id
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
isApplicable: (context)=>context.container.resolve(TenantContext).getTenant().id === tenant.id
|
|
91
|
+
});
|
|
92
|
+
modelPlugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}`;
|
|
93
|
+
plugins.push(modelPlugin);
|
|
94
|
+
}
|
|
95
|
+
return plugins;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const BulkActionsGraphQLSchema = CmsGraphQLSchemaFactory.createImplementation({
|
|
99
|
+
implementation: BulkActionsGraphQLSchemaImpl,
|
|
100
|
+
dependencies: [
|
|
101
|
+
RequestContainer
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
export { BulkActionsGraphQLSchema };
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=BulkActionsGraphQLSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/BulkActionsGraphQLSchema.js","sources":["../../src/graphql/BulkActionsGraphQLSchema.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport {\n CmsGraphQLSchemaPlugin,\n CmsGraphQLSchemaFactory,\n isHeadlessCmsReady\n} from \"@webiny/api-headless-cms\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/api-headless-cms/constants.js\";\nimport { Response } from \"@webiny/api-graphql\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { TriggerTaskUseCase } from \"@webiny/background-tasks/api\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport { BulkActionName } from \"~/domain/BulkActionName.js\";\nimport { BULK_ACTION_LIST_TASK_ID } from \"~/features/EntriesBulkAction/createBulkActionTasks.js\";\nimport { RequestContainer } from \"@webiny/event-handler-core\";\nimport type { HcmsBulkActionsContext } from \"~/types.js\";\n\nclass BulkActionsGraphQLSchemaImpl implements CmsGraphQLSchemaFactory.Interface {\n constructor(private readonly container: Container) {}\n\n async execute() {\n const context = { container: this.container } as HcmsBulkActionsContext;\n const tenantCtx = this.container.resolve(TenantContext);\n const tenant = tenantCtx.getTenant();\n\n if (!(await isHeadlessCmsReady(context))) {\n return [];\n }\n\n const identityCtx = this.container.resolve(IdentityContext);\n const modelsResult = await identityCtx.withoutAuthorization(async () => {\n return this.container.resolve(ListModelsUseCase).execute();\n });\n\n if (modelsResult.isFail()) {\n return [];\n }\n\n const allModels = modelsResult.value.filter(model => {\n if (model.isPrivate) {\n return false;\n }\n const tags = Array.isArray(model.tags) ? model.tags : [];\n return !tags.includes(CMS_MODEL_SINGLETON_TAG);\n });\n\n const bulkActions = this.container.resolveAll(EntriesBulkAction);\n const plugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n const defaultPlugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type BulkActionResponseData {\n id: String\n }\n\n type BulkActionResponse {\n data: BulkActionResponseData\n error: CmsError\n }\n `\n });\n defaultPlugin.name = \"headless-cms.graphql.schema.bulkAction.default\";\n plugins.push(defaultPlugin);\n\n for (const model of allModels) {\n const applicableActions = bulkActions.filter(action => {\n if (action.modelIds?.length) {\n return action.modelIds.includes(model.modelId);\n }\n return true;\n });\n\n const enumValues = applicableActions\n .map(action => BulkActionName.from(action.name))\n .join(\"\\n \");\n\n const modelPlugin = new CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>({\n typeDefs: /* GraphQL */ `\n enum BulkAction${model.singularApiName}Name {\n _empty\n ${enumValues}\n }\n\n extend type Mutation {\n bulkAction${model.singularApiName}(\n action: BulkAction${model.singularApiName}Name!\n where: ${model.singularApiName}ListWhereInput\n search: String\n data: JSON\n ): BulkActionResponse\n }\n `,\n resolvers: {\n Mutation: {\n [`bulkAction${model.singularApiName}`]: async (_, args, context) => {\n const identity = context.container\n .resolve(IdentityContext)\n .getIdentity();\n\n const response = await context.container\n .resolve(TriggerTaskUseCase)\n .execute({\n definition: BULK_ACTION_LIST_TASK_ID,\n input: {\n actionName: args.action,\n modelId: model.modelId,\n where: args.where,\n search: args.search,\n data: args.data,\n identity\n }\n });\n\n return new Response({\n id: response.value.id\n });\n }\n }\n },\n isApplicable: context =>\n context.container.resolve(TenantContext).getTenant().id === tenant.id\n });\n\n modelPlugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}`;\n plugins.push(modelPlugin);\n }\n\n return plugins;\n }\n}\n\nexport const BulkActionsGraphQLSchema = CmsGraphQLSchemaFactory.createImplementation({\n implementation: BulkActionsGraphQLSchemaImpl,\n dependencies: [RequestContainer]\n});\n"],"names":["BulkActionsGraphQLSchemaImpl","container","context","tenantCtx","TenantContext","tenant","isHeadlessCmsReady","identityCtx","IdentityContext","modelsResult","ListModelsUseCase","allModels","model","tags","Array","CMS_MODEL_SINGLETON_TAG","bulkActions","EntriesBulkAction","plugins","defaultPlugin","CmsGraphQLSchemaPlugin","applicableActions","action","enumValues","BulkActionName","modelPlugin","_","args","identity","response","TriggerTaskUseCase","BULK_ACTION_LIST_TASK_ID","Response","BulkActionsGraphQLSchema","CmsGraphQLSchemaFactory","RequestContainer"],"mappings":";;;;;;;;;;;AAkBA,MAAMA;IACF,YAA6BC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAEpD,MAAM,UAAU;QACZ,MAAMC,UAAU;YAAE,WAAW,IAAI,CAAC,SAAS;QAAC;QAC5C,MAAMC,YAAY,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QACzC,MAAMC,SAASF,UAAU,SAAS;QAElC,IAAI,CAAE,MAAMG,mBAAmBJ,UAC3B,OAAO,EAAE;QAGb,MAAMK,cAAc,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAC3C,MAAMC,eAAe,MAAMF,YAAY,oBAAoB,CAAC,UACjD,IAAI,CAAC,SAAS,CAAC,OAAO,CAACG,mBAAmB,OAAO;QAG5D,IAAID,aAAa,MAAM,IACnB,OAAO,EAAE;QAGb,MAAME,YAAYF,aAAa,KAAK,CAAC,MAAM,CAACG,CAAAA;YACxC,IAAIA,MAAM,SAAS,EACf,OAAO;YAEX,MAAMC,OAAOC,MAAM,OAAO,CAACF,MAAM,IAAI,IAAIA,MAAM,IAAI,GAAG,EAAE;YACxD,OAAO,CAACC,KAAK,QAAQ,CAACE;QAC1B;QAEA,MAAMC,cAAc,IAAI,CAAC,SAAS,CAAC,UAAU,CAACC;QAC9C,MAAMC,UAA4D,EAAE;QAEpE,MAAMC,gBAAgB,IAAIC,uBAAuB;YAC7C,UAAwB,CAAC;;;;;;;;;YASzB,CAAC;QACL;QACAD,cAAc,IAAI,GAAG;QACrBD,QAAQ,IAAI,CAACC;QAEb,KAAK,MAAMP,SAASD,UAAW;YAC3B,MAAMU,oBAAoBL,YAAY,MAAM,CAACM,CAAAA;gBACzC,IAAIA,OAAO,QAAQ,EAAE,QACjB,OAAOA,OAAO,QAAQ,CAA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;AACpC"}
|
|
@@ -2,7 +2,7 @@ import type { HcmsBulkActionsContext } from "../types.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Registers the "default" bulk-action GraphQL for every public model: the shared response types plus,
|
|
4
4
|
* per model, an empty `BulkAction<Model>Name` enum + `bulkAction<Model>` mutation skeleton (each
|
|
5
|
-
* action extends the enum via createBulkActionGraphQL). Run per
|
|
6
|
-
*
|
|
5
|
+
* action extends the enum via createBulkActionGraphQL). Run per request, since models are only
|
|
6
|
+
* known at request time.
|
|
7
7
|
*/
|
|
8
8
|
export declare const registerDefaultBulkActionGraphQL: (context: HcmsBulkActionsContext) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/createDefaultGraphQL.js","sources":["../../src/graphql/createDefaultGraphQL.ts"],"sourcesContent":["import type { HcmsBulkActionsContext } from \"~/types.js\";\nimport {\n CmsGraphQLSchemaPlugin,\n CmsGraphQLSchemaFactory,\n isHeadlessCmsReady\n} from \"@webiny/api-headless-cms\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/api-headless-cms/constants.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\n\n/**\n * Registers the \"default\" bulk-action GraphQL for every public model: the shared response types plus,\n * per model, an empty `BulkAction<Model>Name` enum + `bulkAction<Model>` mutation skeleton (each\n * action extends the enum via createBulkActionGraphQL). Run per
|
|
1
|
+
{"version":3,"file":"graphql/createDefaultGraphQL.js","sources":["../../src/graphql/createDefaultGraphQL.ts"],"sourcesContent":["import type { HcmsBulkActionsContext } from \"~/types.js\";\nimport {\n CmsGraphQLSchemaPlugin,\n CmsGraphQLSchemaFactory,\n isHeadlessCmsReady\n} from \"@webiny/api-headless-cms\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/api-headless-cms/constants.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\n\n/**\n * Registers the \"default\" bulk-action GraphQL for every public model: the shared response types plus,\n * per model, an empty `BulkAction<Model>Name` enum + `bulkAction<Model>` mutation skeleton (each\n * action extends the enum via createBulkActionGraphQL). Run per request, since models are only\n * known at request time.\n */\nexport const registerDefaultBulkActionGraphQL = async (context: HcmsBulkActionsContext) => {\n const tenant = context.container.resolve(TenantContext).getTenant();\n\n if (!(await isHeadlessCmsReady(context))) {\n return;\n }\n\n const defaultPlugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type BulkActionResponseData {\n id: String\n }\n\n type BulkActionResponse {\n data: BulkActionResponseData\n error: CmsError\n }\n `\n });\n defaultPlugin.name = `headless-cms.graphql.schema.bulkAction.default`;\n\n const modelsResult = await context.container\n .resolve(IdentityContext)\n .withoutAuthorization(async () => {\n return context.container.resolve(ListModelsUseCase).execute();\n });\n if (modelsResult.isFail()) {\n return;\n }\n const models = modelsResult.value.filter(model => {\n if (model.isPrivate) {\n return false;\n }\n const tags = Array.isArray(model.tags) ? model.tags : [];\n return !tags.includes(CMS_MODEL_SINGLETON_TAG);\n });\n\n const modelPlugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n models.forEach(model => {\n const plugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n enum BulkAction${model.singularApiName}Name {\n _empty\n }\n \n extend type Mutation {\n bulkAction${model.singularApiName}(\n action: BulkAction${model.singularApiName}Name!\n where: ${model.singularApiName}ListWhereInput\n search: String\n data: JSON\n ): BulkActionResponse\n }\n `,\n isApplicable: context =>\n context.container.resolve(TenantContext).getTenant().id === tenant.id\n });\n\n plugin.name = `headless-cms.graphql.schema.bulkAction.default.${model.modelId}`;\n modelPlugins.push(plugin);\n });\n\n context.container.registerInstance(CmsGraphQLSchemaFactory, {\n execute: () => [defaultPlugin, ...modelPlugins]\n });\n};\n"],"names":["registerDefaultBulkActionGraphQL","context","tenant","TenantContext","isHeadlessCmsReady","defaultPlugin","CmsGraphQLSchemaPlugin","modelsResult","IdentityContext","ListModelsUseCase","models","model","tags","Array","CMS_MODEL_SINGLETON_TAG","modelPlugins","plugin","CmsGraphQLSchemaFactory"],"mappings":";;;;;AAiBO,MAAMA,mCAAmC,OAAOC;IACnD,MAAMC,SAASD,QAAQ,SAAS,CAAC,OAAO,CAACE,eAAe,SAAS;IAEjE,IAAI,CAAE,MAAMC,mBAAmBH,UAC3B;IAGJ,MAAMI,gBAAgB,IAAIC,uBAAuB;QAC7C,UAAwB,CAAC;;;;;;;;;QASzB,CAAC;IACL;IACAD,cAAc,IAAI,GAAG;IAErB,MAAME,eAAe,MAAMN,QAAQ,SAAS,CACvC,OAAO,CAACO,iBACR,oBAAoB,CAAC,UACXP,QAAQ,SAAS,CAAC,OAAO,CAACQ,mBAAmB,OAAO;IAEnE,IAAIF,aAAa,MAAM,IACnB;IAEJ,MAAMG,SAASH,aAAa,KAAK,CAAC,MAAM,CAACI,CAAAA;QACrC,IAAIA,MAAM,SAAS,EACf,OAAO;QAEX,MAAMC,OAAOC,MAAM,OAAO,CAACF,MAAM,IAAI,IAAIA,MAAM,IAAI,GAAG,EAAE;QACxD,OAAO,CAACC,KAAK,QAAQ,CAACE;IAC1B;IAEA,MAAMC,eAAiE,EAAE;IAEzEL,OAAO,OAAO,CAACC,CAAAA;QACX,MAAMK,SAAS,IAAIV,uBAAuB;YACtC,UAAwB,CAAC;mCACF,EAAEK,MAAM,eAAe,CAAC;;;;;kCAKzB,EAAEA,MAAM,eAAe,CAAC;8CACZ,EAAEA,MAAM,eAAe,CAAC;mCACnC,EAAEA,MAAM,eAAe,CAAC;;;;;gBAK3C,CAAC;YACL,cAAcV,CAAAA,UACVA,QAAQ,SAAS,CAAC,OAAO,CAACE,eAAe,SAAS,GAAG,EAAE,KAAKD,OAAO,EAAE;QAC7E;QAEAc,OAAO,IAAI,GAAG,CAAC,+CAA+C,EAAEL,MAAM,OAAO,EAAE;QAC/EI,aAAa,IAAI,CAACC;IACtB;IAEAf,QAAQ,SAAS,CAAC,gBAAgB,CAACgB,yBAAyB;QACxD,SAAS,IAAM;gBAACZ;mBAAkBU;aAAa;IACnD;AACJ"}
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export type * from "./abstractions/index.js";
|
|
2
|
-
export { BulkActionsEventBridgeLambdaHandler } from "./BulkActionsEventBridgeLambdaHandler.js";
|
|
3
2
|
export { HcmsBulkActionsFeature } from "./HcmsBulkActionsFeature.js";
|
|
4
3
|
export type { HcmsBulkActionsFeatureConfig } from "./HcmsBulkActionsFeature.js";
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-bulk-actions",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -17,29 +17,26 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@webiny/api-graphql": "6.6.0-alpha.
|
|
21
|
-
"@webiny/api-headless-cms": "6.6.0-alpha.
|
|
22
|
-
"@webiny/
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/
|
|
25
|
-
"@webiny/
|
|
26
|
-
"@webiny/
|
|
27
|
-
"@webiny/handler": "6.6.0-alpha.0",
|
|
28
|
-
"@webiny/utils": "6.6.0-alpha.0"
|
|
20
|
+
"@webiny/api-graphql": "6.6.0-alpha.2",
|
|
21
|
+
"@webiny/api-headless-cms": "6.6.0-alpha.2",
|
|
22
|
+
"@webiny/background-tasks": "6.6.0-alpha.2",
|
|
23
|
+
"@webiny/event-handler-core": "6.6.0-alpha.2",
|
|
24
|
+
"@webiny/feature": "6.6.0-alpha.2",
|
|
25
|
+
"@webiny/handler": "6.6.0-alpha.2",
|
|
26
|
+
"@webiny/utils": "6.6.0-alpha.2"
|
|
29
27
|
},
|
|
30
28
|
"devDependencies": {
|
|
31
|
-
"@webiny/api": "6.6.0-alpha.
|
|
32
|
-
"@webiny/api-core": "6.6.0-alpha.
|
|
33
|
-
"@webiny/api-graphql": "6.6.0-alpha.
|
|
34
|
-
"@webiny/api-headless-cms-testing": "6.6.0-alpha.
|
|
35
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
36
|
-
"@webiny/di": "1.0
|
|
37
|
-
"@webiny/plugins": "6.6.0-alpha.
|
|
38
|
-
"@webiny/
|
|
39
|
-
"@webiny/wcp": "6.6.0-alpha.0",
|
|
29
|
+
"@webiny/api": "6.6.0-alpha.2",
|
|
30
|
+
"@webiny/api-core": "6.6.0-alpha.2",
|
|
31
|
+
"@webiny/api-graphql": "6.6.0-alpha.2",
|
|
32
|
+
"@webiny/api-headless-cms-testing": "6.6.0-alpha.2",
|
|
33
|
+
"@webiny/build-tools": "6.6.0-alpha.2",
|
|
34
|
+
"@webiny/di": "1.1.0",
|
|
35
|
+
"@webiny/plugins": "6.6.0-alpha.2",
|
|
36
|
+
"@webiny/wcp": "6.6.0-alpha.2",
|
|
40
37
|
"graphql": "16.14.2",
|
|
41
38
|
"typescript": "7.0.2",
|
|
42
|
-
"vitest": "4.1.
|
|
39
|
+
"vitest": "4.1.11"
|
|
43
40
|
},
|
|
44
41
|
"publishConfig": {
|
|
45
42
|
"access": "public"
|
package/types.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface HcmsBulkActionsContext extends BaseContext, CmsContext, TasksCo
|
|
|
8
8
|
* Bulk Action Operation
|
|
9
9
|
*/
|
|
10
10
|
export interface IBulkActionOperationInput {
|
|
11
|
+
actionName: string;
|
|
11
12
|
modelId: string;
|
|
12
13
|
ids: string[];
|
|
13
14
|
data?: Record<string, any>;
|
|
@@ -30,6 +31,7 @@ export declare enum BulkActionOperationByModelAction {
|
|
|
30
31
|
END_TASK = "END_TASK"
|
|
31
32
|
}
|
|
32
33
|
export interface IBulkActionOperationByModelInput {
|
|
34
|
+
actionName: string;
|
|
33
35
|
modelId: string;
|
|
34
36
|
identity?: ITaskIdentity;
|
|
35
37
|
where?: Record<string, any>;
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { CmsContext } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { Context as BaseContext } from \"@webiny/handler/types.js\";\nimport type { Context as TasksContext, ITaskIdentity } from \"@webiny/background-tasks/api/types.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport interface HcmsBulkActionsContext extends BaseContext, CmsContext, TasksContext {}\n\n/**\n * Bulk Action Operation\n */\n\nexport interface IBulkActionOperationInput {\n modelId: string;\n ids: string[];\n data?: Record<string, any>;\n identity: ITaskIdentity;\n done?: string[];\n failed?: string[];\n}\n\nexport interface IBulkActionOperationOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationTaskParams = TaskDefinition.RunParams<\n IBulkActionOperationInput,\n IBulkActionOperationOutput\n>;\n\n/**\n * Bulk Action Operation By Model\n */\n\nexport enum BulkActionOperationByModelAction {\n CREATE_SUBTASKS = \"CREATE_SUBTASKS\",\n CHECK_MORE_SUBTASKS = \"CHECK_MORE_SUBTASKS\",\n PROCESS_SUBTASKS = \"PROCESS_SUBTASKS\",\n END_TASK = \"END_TASK\"\n}\n\nexport interface IBulkActionOperationByModelInput {\n modelId: string;\n identity?: ITaskIdentity;\n where?: Record<string, any>;\n search?: string;\n after?: string | null;\n data?: Record<string, any>;\n action?: BulkActionOperationByModelAction;\n}\n\nexport interface IBulkActionOperationByModelOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationByModelTaskParams = TaskDefinition.RunParams<\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput\n>;\n\n/**\n * Empty Trash Bin\n */\n\nexport interface IEmptyTrashBinsInput {\n executedTenantIds?: string[] | null;\n}\n\nexport type IEmptyTrashBinsOutput = TaskDefinition.ResultDone;\n\nexport type IEmptyTrashBinsTaskParams = TaskDefinition.RunParams<\n IEmptyTrashBinsInput,\n IEmptyTrashBinsOutput\n>;\n"],"names":["BulkActionOperationByModelAction"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { CmsContext } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { Context as BaseContext } from \"@webiny/handler/types.js\";\nimport type { Context as TasksContext, ITaskIdentity } from \"@webiny/background-tasks/api/types.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport interface HcmsBulkActionsContext extends BaseContext, CmsContext, TasksContext {}\n\n/**\n * Bulk Action Operation\n */\n\nexport interface IBulkActionOperationInput {\n actionName: string;\n modelId: string;\n ids: string[];\n data?: Record<string, any>;\n identity: ITaskIdentity;\n done?: string[];\n failed?: string[];\n}\n\nexport interface IBulkActionOperationOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationTaskParams = TaskDefinition.RunParams<\n IBulkActionOperationInput,\n IBulkActionOperationOutput\n>;\n\n/**\n * Bulk Action Operation By Model\n */\n\nexport enum BulkActionOperationByModelAction {\n CREATE_SUBTASKS = \"CREATE_SUBTASKS\",\n CHECK_MORE_SUBTASKS = \"CHECK_MORE_SUBTASKS\",\n PROCESS_SUBTASKS = \"PROCESS_SUBTASKS\",\n END_TASK = \"END_TASK\"\n}\n\nexport interface IBulkActionOperationByModelInput {\n actionName: string;\n modelId: string;\n identity?: ITaskIdentity;\n where?: Record<string, any>;\n search?: string;\n after?: string | null;\n data?: Record<string, any>;\n action?: BulkActionOperationByModelAction;\n}\n\nexport interface IBulkActionOperationByModelOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationByModelTaskParams = TaskDefinition.RunParams<\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput\n>;\n\n/**\n * Empty Trash Bin\n */\n\nexport interface IEmptyTrashBinsInput {\n executedTenantIds?: string[] | null;\n}\n\nexport type IEmptyTrashBinsOutput = TaskDefinition.ResultDone;\n\nexport type IEmptyTrashBinsTaskParams = TaskDefinition.RunParams<\n IEmptyTrashBinsInput,\n IEmptyTrashBinsOutput\n>;\n"],"names":["BulkActionOperationByModelAction"],"mappings":"AAmCO,IAAKA,yCAAgCA,WAAAA,GAAAA,SAAhCA,gCAAgC;;;;;WAAhCA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Container } from "@webiny/feature/api";
|
|
2
|
-
import type { EventBridgeEvent } from "@webiny/aws-sdk/types/index.js";
|
|
3
|
-
import { EventBridgeEventHandler, type EventBridgeResult } from "@webiny/event-handler-aws/abstractions/handlers/EventBridgeEventHandler.js";
|
|
4
|
-
import type { EventContext, NextFunction } from "@webiny/event-handler-core";
|
|
5
|
-
declare class BulkActionsEventBridgeLambdaHandlerImpl implements EventBridgeEventHandler.Interface {
|
|
6
|
-
private container;
|
|
7
|
-
constructor(container: Container);
|
|
8
|
-
execute(eventCtx: EventContext<EventBridgeEvent<string, any>>, _next: NextFunction): Promise<EventBridgeResult>;
|
|
9
|
-
}
|
|
10
|
-
export declare const BulkActionsEventBridgeLambdaHandler: typeof BulkActionsEventBridgeLambdaHandlerImpl & {
|
|
11
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/event-handler-aws/abstractions/handlers/EventBridgeEventHandler.js").IEventBridgeEventHandler>;
|
|
12
|
-
};
|
|
13
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { EventBridgeEventHandler } from "@webiny/event-handler-aws/abstractions/handlers/EventBridgeEventHandler.js";
|
|
2
|
-
import { RequestContainer } from "@webiny/event-handler-core";
|
|
3
|
-
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
4
|
-
import { TaskService } from "@webiny/api-core/features/task/TaskService/abstractions.js";
|
|
5
|
-
const DETAIL_TYPE = "WebinyEmptyTrashBin";
|
|
6
|
-
class BulkActionsEventBridgeLambdaHandlerImpl {
|
|
7
|
-
constructor(container){
|
|
8
|
-
this.container = container;
|
|
9
|
-
}
|
|
10
|
-
async execute(eventCtx, _next) {
|
|
11
|
-
if (eventCtx.event["detail-type"] !== DETAIL_TYPE) return {
|
|
12
|
-
success: true,
|
|
13
|
-
message: "Not a bulk action event."
|
|
14
|
-
};
|
|
15
|
-
await this.container.resolve(TenantContext).withRootTenant(async ()=>{
|
|
16
|
-
await this.container.resolve(TaskService).trigger({
|
|
17
|
-
definition: "hcmsEntriesEmptyTrashBins"
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
return {
|
|
21
|
-
success: true
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const BulkActionsEventBridgeLambdaHandler = EventBridgeEventHandler.createImplementation({
|
|
26
|
-
implementation: BulkActionsEventBridgeLambdaHandlerImpl,
|
|
27
|
-
dependencies: [
|
|
28
|
-
RequestContainer
|
|
29
|
-
]
|
|
30
|
-
});
|
|
31
|
-
export { BulkActionsEventBridgeLambdaHandler };
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=BulkActionsEventBridgeLambdaHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BulkActionsEventBridgeLambdaHandler.js","sources":["../src/BulkActionsEventBridgeLambdaHandler.ts"],"sourcesContent":["import type { Container } from \"@webiny/feature/api\";\nimport type { EventBridgeEvent } from \"@webiny/aws-sdk/types/index.js\";\nimport {\n EventBridgeEventHandler,\n type EventBridgeResult\n} from \"@webiny/event-handler-aws/abstractions/handlers/EventBridgeEventHandler.js\";\nimport { RequestContainer } from \"@webiny/event-handler-core\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { TaskService } from \"@webiny/api-core/features/task/TaskService/abstractions.js\";\nimport type { EventContext, NextFunction } from \"@webiny/event-handler-core\";\n\nconst DETAIL_TYPE = \"WebinyEmptyTrashBin\";\n\nclass BulkActionsEventBridgeLambdaHandlerImpl implements EventBridgeEventHandler.Interface {\n constructor(private container: Container) {}\n\n async execute(\n eventCtx: EventContext<EventBridgeEvent<string, any>>,\n _next: NextFunction\n ): Promise<EventBridgeResult> {\n if (eventCtx.event[\"detail-type\"] !== DETAIL_TYPE) {\n return { success: true, message: \"Not a bulk action event.\" };\n }\n\n await this.container.resolve(TenantContext).withRootTenant(async () => {\n await this.container\n .resolve(TaskService)\n .trigger({ definition: \"hcmsEntriesEmptyTrashBins\" });\n });\n\n return { success: true };\n }\n}\n\nexport const BulkActionsEventBridgeLambdaHandler = EventBridgeEventHandler.createImplementation({\n implementation: BulkActionsEventBridgeLambdaHandlerImpl,\n dependencies: [RequestContainer]\n});\n"],"names":["DETAIL_TYPE","BulkActionsEventBridgeLambdaHandlerImpl","container","eventCtx","_next","TenantContext","TaskService","BulkActionsEventBridgeLambdaHandler","EventBridgeEventHandler","RequestContainer"],"mappings":";;;;AAWA,MAAMA,cAAc;AAEpB,MAAMC;IACF,YAAoBC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAE3C,MAAM,QACFC,QAAqD,EACrDC,KAAmB,EACO;QAC1B,IAAID,SAAS,KAAK,CAAC,cAAc,KAAKH,aAClC,OAAO;YAAE,SAAS;YAAM,SAAS;QAA2B;QAGhE,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACK,eAAe,cAAc,CAAC;YACvD,MAAM,IAAI,CAAC,SAAS,CACf,OAAO,CAACC,aACR,OAAO,CAAC;gBAAE,YAAY;YAA4B;QAC3D;QAEA,OAAO;YAAE,SAAS;QAAK;IAC3B;AACJ;AAEO,MAAMC,sCAAsCC,wBAAwB,oBAAoB,CAAC;IAC5F,gBAAgBP;IAChB,cAAc;QAACQ;KAAiB;AACpC"}
|