@webiny/api-headless-cms-bulk-actions 6.6.0-alpha.1 → 6.6.0-alpha.10
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 +1 -1
- package/HcmsBulkActionsFeature.js.map +1 -1
- package/features/DeleteEntriesBulkAction/DeleteEntriesBulkAction.js +1 -0
- package/features/DeleteEntriesBulkAction/DeleteEntriesBulkAction.js.map +1 -1
- package/features/EntriesBulkAction/createBulkActionTasks.d.ts +33 -14
- package/features/EntriesBulkAction/createBulkActionTasks.js +67 -35
- package/features/EntriesBulkAction/createBulkActionTasks.js.map +1 -1
- package/features/EntriesBulkAction/internals/ChildTasksCleanup.d.ts +9 -6
- package/features/EntriesBulkAction/internals/ChildTasksCleanup.js +19 -10
- package/features/EntriesBulkAction/internals/ChildTasksCleanup.js.map +1 -1
- package/features/EntriesBulkAction/internals/CreateTasksByModel.d.ts +2 -1
- package/features/EntriesBulkAction/internals/CreateTasksByModel.js +3 -3
- package/features/EntriesBulkAction/internals/CreateTasksByModel.js.map +1 -1
- package/features/EntriesBulkAction/internals/ProcessTask.d.ts +3 -1
- package/features/EntriesBulkAction/internals/ProcessTask.js +7 -3
- package/features/EntriesBulkAction/internals/ProcessTask.js.map +1 -1
- package/features/EntriesBulkAction/internals/ProcessTasksByModel.js +4 -2
- package/features/EntriesBulkAction/internals/ProcessTasksByModel.js.map +1 -1
- package/features/EntriesBulkAction/internals/TaskCache.d.ts +3 -1
- package/features/EntriesBulkAction/internals/TaskCache.js +9 -3
- package/features/EntriesBulkAction/internals/TaskCache.js.map +1 -1
- package/features/MoveToFolderBulkAction/MoveToFolderBulkAction.js +2 -3
- package/features/MoveToFolderBulkAction/MoveToFolderBulkAction.js.map +1 -1
- package/features/MoveToTrashBulkAction/MoveToTrashBulkAction.js +1 -0
- package/features/MoveToTrashBulkAction/MoveToTrashBulkAction.js.map +1 -1
- package/features/PublishEntriesBulkAction/PublishEntriesBulkAction.js +2 -3
- package/features/PublishEntriesBulkAction/PublishEntriesBulkAction.js.map +1 -1
- package/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.js +1 -0
- package/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.js.map +1 -1
- package/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.js +2 -3
- package/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.js.map +1 -1
- package/graphql/BulkActionsGraphQLSchema.js +2 -1
- package/graphql/BulkActionsGraphQLSchema.js.map +1 -1
- package/graphql/createBulkActionGraphQL.js +2 -1
- package/graphql/createBulkActionGraphQL.js.map +1 -1
- package/graphql/createDefaultGraphQL.js +2 -1
- package/graphql/createDefaultGraphQL.js.map +1 -1
- package/package.json +17 -17
- package/tasks/{EmptyTrashBinTaskDefinition.d.ts → EmptyTrashBinTask.d.ts} +9 -4
- package/tasks/{EmptyTrashBinTaskDefinition.js → EmptyTrashBinTask.js} +36 -15
- package/tasks/EmptyTrashBinTask.js.map +1 -0
- package/types.d.ts +2 -2
- package/types.js.map +1 -1
- package/tasks/EmptyTrashBinTaskDefinition.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/EntriesBulkAction/internals/ProcessTask.js","sources":["../../../../src/features/EntriesBulkAction/internals/ProcessTask.ts"],"sourcesContent":["import { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport { ProcessTaskResult } from \"./ProcessTaskResult.js\";\nimport type { IBulkActionOperationTaskParams } from \"~/types.js\";\n\n/**\n * The `ProcessTask` class is responsible for processing a batch of entries\n * based on the provided parameters. It uses a gateway to perform the actual\n * processing and maintains the results of the operations, including successfully\n * processed and failed entries.\n */\nexport class ProcessTask {\n private readonly result: ProcessTaskResult;\n\n constructor(\n private bulkAction: EntriesBulkAction.Interface,\n private getModel: GetModelUseCase.Interface\n ) {\n this.result = new ProcessTaskResult();\n }\n\n async execute({ input, controller }: IBulkActionOperationTaskParams) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n } else if (controller.runtime.isCloseToTimeout()) {\n return controller.response.continue({\n ...input\n });\n }\n\n // Check if the input contains a model ID.\n if (!input.modelId) {\n return controller.response.error(`Missing \"modelId\" in the input.`);\n }\n\n // Check if the model exists.\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 // Check if there are any IDs to process.\n if (!input.ids || input.ids.length === 0) {\n return controller.response.done(\n `Task done: no entries to process for \"${input.modelId}\" model.`,\n {\n done: [],\n failed: []\n }\n );\n }\n\n // Process each ID in the input.\n for (const id of input.ids) {\n try {\n // Execute the gateway operation for the current ID.\n await this.bulkAction.processData(model, {\n id,\n data: input.data\n });\n\n // Add the ID to the list of successfully processed entries.\n this.result.addDone(id);\n } catch (ex) {\n
|
|
1
|
+
{"version":3,"file":"features/EntriesBulkAction/internals/ProcessTask.js","sources":["../../../../src/features/EntriesBulkAction/internals/ProcessTask.ts"],"sourcesContent":["import { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport { ProcessTaskResult } from \"./ProcessTaskResult.js\";\nimport type { IBulkActionOperationTaskParams } from \"~/types.js\";\nimport type { Logger } from \"@webiny/api-core/features/logger/index.js\";\n\n/**\n * The `ProcessTask` class is responsible for processing a batch of entries\n * based on the provided parameters. It uses a gateway to perform the actual\n * processing and maintains the results of the operations, including successfully\n * processed and failed entries.\n */\nexport class ProcessTask {\n private readonly result: ProcessTaskResult;\n\n constructor(\n private bulkAction: EntriesBulkAction.Interface,\n private getModel: GetModelUseCase.Interface,\n private logger: Logger.Interface\n ) {\n this.result = new ProcessTaskResult();\n }\n\n async execute({ input, controller }: IBulkActionOperationTaskParams) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n } else if (controller.runtime.isCloseToTimeout()) {\n return controller.response.continue({\n ...input\n });\n }\n\n // Check if the input contains a model ID.\n if (!input.modelId) {\n return controller.response.error(`Missing \"modelId\" in the input.`);\n }\n\n // Check if the model exists.\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 // Check if there are any IDs to process.\n if (!input.ids || input.ids.length === 0) {\n return controller.response.done(\n `Task done: no entries to process for \"${input.modelId}\" model.`,\n {\n done: [],\n failed: []\n }\n );\n }\n\n // Process each ID in the input.\n for (const id of input.ids) {\n try {\n // Execute the gateway operation for the current ID.\n await this.bulkAction.processData(model, {\n id,\n data: input.data\n });\n\n // Add the ID to the list of successfully processed entries.\n this.result.addDone(id);\n } catch (ex) {\n this.logger.error(\n { error: ex, id },\n `Failed to process entry with id \"${id}\".`\n );\n // Add the ID to the list of failed entries.\n this.result.addFailed(id);\n }\n }\n\n // Return a done response with the results of the processing.\n return controller.response.done(\n `Task done: all entries processed for \"${model.name}\" model.`,\n {\n done: this.result.getDone(),\n failed: this.result.getFailed()\n }\n );\n } catch (ex) {\n return controller.response.error(ex.message ?? `Error while processing task.`);\n }\n }\n}\n"],"names":["ProcessTask","bulkAction","getModel","logger","ProcessTaskResult","input","controller","modelResult","model","id","ex"],"mappings":";AAYO,MAAMA;IAGT,YACYC,UAAuC,EACvCC,QAAmC,EACnCC,MAAwB,CAClC;aAHUF,UAAU,GAAVA;aACAC,QAAQ,GAARA;aACAC,MAAM,GAANA;QAER,IAAI,CAAC,MAAM,GAAG,IAAIC;IACtB;IAEA,MAAM,QAAQ,EAAEC,KAAK,EAAEC,UAAU,EAAkC,EAAE;QACjE,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;iBAC/B,IAAIA,WAAW,OAAO,CAAC,gBAAgB,IAC1C,OAAOA,WAAW,QAAQ,CAAC,QAAQ,CAAC;gBAChC,GAAGD,KAAK;YACZ;YAIJ,IAAI,CAACA,MAAM,OAAO,EACd,OAAOC,WAAW,QAAQ,CAAC,KAAK,CAAC;YAIrC,MAAMC,cAAc,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACF,MAAM,OAAO;YAE7D,IAAIE,YAAY,MAAM,IAClB,OAAOD,WAAW,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAED,MAAM,OAAO,CAAC,WAAW,CAAC;YAG7E,MAAMG,QAAQD,YAAY,KAAK;YAG/B,IAAI,CAACF,MAAM,GAAG,IAAIA,AAAqB,MAArBA,MAAM,GAAG,CAAC,MAAM,EAC9B,OAAOC,WAAW,QAAQ,CAAC,IAAI,CAC3B,CAAC,sCAAsC,EAAED,MAAM,OAAO,CAAC,QAAQ,CAAC,EAChE;gBACI,MAAM,EAAE;gBACR,QAAQ,EAAE;YACd;YAKR,KAAK,MAAMI,MAAMJ,MAAM,GAAG,CACtB,IAAI;gBAEA,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAACG,OAAO;oBACrCC;oBACA,MAAMJ,MAAM,IAAI;gBACpB;gBAGA,IAAI,CAAC,MAAM,CAAC,OAAO,CAACI;YACxB,EAAE,OAAOC,IAAI;gBACT,IAAI,CAAC,MAAM,CAAC,KAAK,CACb;oBAAE,OAAOA;oBAAID;gBAAG,GAChB,CAAC,iCAAiC,EAAEA,GAAG,EAAE,CAAC;gBAG9C,IAAI,CAAC,MAAM,CAAC,SAAS,CAACA;YAC1B;YAIJ,OAAOH,WAAW,QAAQ,CAAC,IAAI,CAC3B,CAAC,sCAAsC,EAAEE,MAAM,IAAI,CAAC,QAAQ,CAAC,EAC7D;gBACI,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO;gBACzB,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS;YACjC;QAER,EAAE,OAAOE,IAAI;YACT,OAAOJ,WAAW,QAAQ,CAAC,KAAK,CAACI,GAAG,OAAO,IAAI;QACnD;IACJ;AACJ"}
|
|
@@ -8,11 +8,11 @@ class ProcessTasksByModel {
|
|
|
8
8
|
async execute({ input, controller }) {
|
|
9
9
|
try {
|
|
10
10
|
if (controller.runtime.isAborted()) return controller.response.aborted();
|
|
11
|
-
if (controller.runtime.isCloseToTimeout()) return controller.response.continue({
|
|
11
|
+
else if (controller.runtime.isCloseToTimeout()) return controller.response.continue({
|
|
12
12
|
...input,
|
|
13
13
|
action: BulkActionOperationByModelAction.PROCESS_SUBTASKS
|
|
14
14
|
});
|
|
15
|
-
const
|
|
15
|
+
const result = await this.listTasks.execute({
|
|
16
16
|
where: {
|
|
17
17
|
parentId: controller.state.getTask().id,
|
|
18
18
|
definitionId: this.taskDefinition,
|
|
@@ -23,6 +23,8 @@ class ProcessTasksByModel {
|
|
|
23
23
|
},
|
|
24
24
|
limit: 1
|
|
25
25
|
});
|
|
26
|
+
if (result.isFail()) throw result.error;
|
|
27
|
+
const { items } = result.value;
|
|
26
28
|
if (items.length > 0) return controller.response.continue({
|
|
27
29
|
...input,
|
|
28
30
|
action: BulkActionOperationByModelAction.PROCESS_SUBTASKS
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/EntriesBulkAction/internals/ProcessTasksByModel.js","sources":["../../../../src/features/EntriesBulkAction/internals/ProcessTasksByModel.ts"],"sourcesContent":["import { TaskDataStatus } from \"@webiny/background-tasks/api\";\nimport type { ListTasksUseCase } from \"@webiny/background-tasks/api\";\nimport type { IBulkActionOperationByModelTaskParams } from \"~/types.js\";\nimport { BulkActionOperationByModelAction } from \"~/types.js\";\n\n/**\n * The `ProcessTasksByModel` class is responsible for processing tasks for a specific model.\n * It checks for any running or pending tasks from the parent task and continues or completes\n * the task based on the status.\n */\nexport class ProcessTasksByModel {\n private readonly listTasks: ListTasksUseCase.Interface;\n private readonly taskDefinition: string;\n\n constructor(listTasks: ListTasksUseCase.Interface, taskDefinition: string) {\n this.listTasks = listTasks;\n this.taskDefinition = taskDefinition;\n }\n\n async execute({ input, controller }: IBulkActionOperationByModelTaskParams) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n } else if (controller.runtime.isCloseToTimeout()) {\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n const
|
|
1
|
+
{"version":3,"file":"features/EntriesBulkAction/internals/ProcessTasksByModel.js","sources":["../../../../src/features/EntriesBulkAction/internals/ProcessTasksByModel.ts"],"sourcesContent":["import { TaskDataStatus } from \"@webiny/background-tasks/api\";\nimport type { ListTasksUseCase } from \"@webiny/background-tasks/api\";\nimport type { IBulkActionOperationByModelTaskParams } from \"~/types.js\";\nimport { BulkActionOperationByModelAction } from \"~/types.js\";\n\n/**\n * The `ProcessTasksByModel` class is responsible for processing tasks for a specific model.\n * It checks for any running or pending tasks from the parent task and continues or completes\n * the task based on the status.\n */\nexport class ProcessTasksByModel {\n private readonly listTasks: ListTasksUseCase.Interface;\n private readonly taskDefinition: string;\n\n constructor(listTasks: ListTasksUseCase.Interface, taskDefinition: string) {\n this.listTasks = listTasks;\n this.taskDefinition = taskDefinition;\n }\n\n async execute({ input, controller }: IBulkActionOperationByModelTaskParams) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n } else if (controller.runtime.isCloseToTimeout()) {\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n const result = await this.listTasks.execute({\n where: {\n parentId: controller.state.getTask().id,\n definitionId: this.taskDefinition,\n taskStatus_in: [TaskDataStatus.RUNNING, TaskDataStatus.PENDING]\n },\n limit: 1\n });\n if (result.isFail()) {\n throw result.error;\n }\n const { items } = result.value;\n\n // If there are running or pending tasks, continue with a wait.\n if (items.length > 0) {\n return controller.response.continue(\n {\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n },\n {\n seconds: 120\n }\n );\n }\n\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.CHECK_MORE_SUBTASKS\n });\n } catch (ex) {\n return controller.response.error(\n ex.message ?? `Error while processing task \"${this.taskDefinition}\"`\n );\n }\n }\n}\n"],"names":["ProcessTasksByModel","listTasks","taskDefinition","input","controller","BulkActionOperationByModelAction","result","TaskDataStatus","items","ex"],"mappings":";;AAUO,MAAMA;IAIT,YAAYC,SAAqC,EAAEC,cAAsB,CAAE;QACvE,IAAI,CAAC,SAAS,GAAGD;QACjB,IAAI,CAAC,cAAc,GAAGC;IAC1B;IAEA,MAAM,QAAQ,EAAEC,KAAK,EAAEC,UAAU,EAAyC,EAAE;QACxE,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;iBAC/B,IAAIA,WAAW,OAAO,CAAC,gBAAgB,IAC1C,OAAOA,WAAW,QAAQ,CAAC,QAAQ,CAAC;gBAChC,GAAGD,KAAK;gBACR,QAAQE,iCAAiC,gBAAgB;YAC7D;YAGJ,MAAMC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBACxC,OAAO;oBACH,UAAUF,WAAW,KAAK,CAAC,OAAO,GAAG,EAAE;oBACvC,cAAc,IAAI,CAAC,cAAc;oBACjC,eAAe;wBAACG,eAAe,OAAO;wBAAEA,eAAe,OAAO;qBAAC;gBACnE;gBACA,OAAO;YACX;YACA,IAAID,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;YAEtB,MAAM,EAAEE,KAAK,EAAE,GAAGF,OAAO,KAAK;YAG9B,IAAIE,MAAM,MAAM,GAAG,GACf,OAAOJ,WAAW,QAAQ,CAAC,QAAQ,CAC/B;gBACI,GAAGD,KAAK;gBACR,QAAQE,iCAAiC,gBAAgB;YAC7D,GACA;gBACI,SAAS;YACb;YAIR,OAAOD,WAAW,QAAQ,CAAC,QAAQ,CAAC;gBAChC,GAAGD,KAAK;gBACR,QAAQE,iCAAiC,mBAAmB;YAChE;QACJ,EAAE,OAAOI,IAAI;YACT,OAAOL,WAAW,QAAQ,CAAC,KAAK,CAC5BK,GAAG,OAAO,IAAI,CAAC,6BAA6B,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QAE5E;IACJ;AACJ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
2
2
|
import type { TriggerTaskUseCase } from "@webiny/background-tasks/api";
|
|
3
|
+
import type { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
3
4
|
/**
|
|
4
5
|
* TaskCache class for managing and triggering cached tasks.
|
|
5
6
|
* @template TTask - Task input data.
|
|
@@ -7,7 +8,8 @@ import type { TriggerTaskUseCase } from "@webiny/background-tasks/api";
|
|
|
7
8
|
export declare class TaskCache<TTask extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> {
|
|
8
9
|
private readonly taskDefinition;
|
|
9
10
|
private taskCache;
|
|
10
|
-
|
|
11
|
+
private readonly logger;
|
|
12
|
+
constructor(taskDefinition: string, logger: Logger.Interface);
|
|
11
13
|
/**
|
|
12
14
|
* Adds a task to the cache.
|
|
13
15
|
* @param {TTask} item - The task input data to be cached.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
class TaskCache {
|
|
2
|
-
constructor(taskDefinition){
|
|
2
|
+
constructor(taskDefinition, logger){
|
|
3
3
|
this.taskCache = [];
|
|
4
4
|
this.taskDefinition = taskDefinition;
|
|
5
|
+
this.logger = logger;
|
|
5
6
|
}
|
|
6
7
|
cacheTask(item) {
|
|
7
8
|
this.taskCache.push(item);
|
|
@@ -10,13 +11,18 @@ class TaskCache {
|
|
|
10
11
|
const tasks = this.getTasks();
|
|
11
12
|
if (0 === tasks.length) return;
|
|
12
13
|
for (const task of tasks)try {
|
|
13
|
-
await triggerTask.execute({
|
|
14
|
+
const result = await triggerTask.execute({
|
|
14
15
|
definition: this.taskDefinition,
|
|
15
16
|
parent,
|
|
16
17
|
input: task
|
|
17
18
|
});
|
|
19
|
+
if (result.isFail()) this.logger.error({
|
|
20
|
+
error: result.error
|
|
21
|
+
}, "Error triggering task.");
|
|
18
22
|
} catch (error) {
|
|
19
|
-
|
|
23
|
+
this.logger.error({
|
|
24
|
+
error
|
|
25
|
+
}, "Error triggering task.");
|
|
20
26
|
}
|
|
21
27
|
this.clearTasks();
|
|
22
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/EntriesBulkAction/internals/TaskCache.js","sources":["../../../../src/features/EntriesBulkAction/internals/TaskCache.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport type { TriggerTaskUseCase } from \"@webiny/background-tasks/api\";\n\n/**\n * TaskCache class for managing and triggering cached tasks.\n * @template TTask - Task input data.\n */\nexport class TaskCache<TTask extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> {\n private readonly taskDefinition: string;\n private taskCache: TTask[] = [];\n\n constructor(taskDefinition: string) {\n this.taskDefinition = taskDefinition;\n }\n\n /**\n * Adds a task to the cache.\n * @param {TTask} item - The task input data to be cached.\n */\n cacheTask(item: TTask) {\n this.taskCache.push(item);\n }\n\n /**\n * Triggers all cached tasks using the provided TriggerTaskUseCase and parent task.\n * @param {TriggerTaskUseCase.Interface} triggerTask - The use case used to trigger the tasks.\n * @param {ITask} parent - The parent task to associate with the triggered tasks.\n */\n async triggerTask(triggerTask: TriggerTaskUseCase.Interface, parent: TaskDefinition.Task) {\n const tasks = this.getTasks();\n\n if (tasks.length === 0) {\n return;\n }\n\n for (const task of tasks) {\n try {\n await triggerTask.execute<TTask>({\n definition: this.taskDefinition,\n parent,\n input: task\n });\n } catch (error) {\n
|
|
1
|
+
{"version":3,"file":"features/EntriesBulkAction/internals/TaskCache.js","sources":["../../../../src/features/EntriesBulkAction/internals/TaskCache.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport type { TriggerTaskUseCase } from \"@webiny/background-tasks/api\";\nimport type { Logger } from \"@webiny/api-core/features/logger/index.js\";\n\n/**\n * TaskCache class for managing and triggering cached tasks.\n * @template TTask - Task input data.\n */\nexport class TaskCache<TTask extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> {\n private readonly taskDefinition: string;\n private taskCache: TTask[] = [];\n private readonly logger: Logger.Interface;\n\n constructor(taskDefinition: string, logger: Logger.Interface) {\n this.taskDefinition = taskDefinition;\n this.logger = logger;\n }\n\n /**\n * Adds a task to the cache.\n * @param {TTask} item - The task input data to be cached.\n */\n cacheTask(item: TTask) {\n this.taskCache.push(item);\n }\n\n /**\n * Triggers all cached tasks using the provided TriggerTaskUseCase and parent task.\n * @param {TriggerTaskUseCase.Interface} triggerTask - The use case used to trigger the tasks.\n * @param {ITask} parent - The parent task to associate with the triggered tasks.\n */\n async triggerTask(triggerTask: TriggerTaskUseCase.Interface, parent: TaskDefinition.Task) {\n const tasks = this.getTasks();\n\n if (tasks.length === 0) {\n return;\n }\n\n for (const task of tasks) {\n try {\n const result = await triggerTask.execute<TTask>({\n definition: this.taskDefinition,\n parent,\n input: task\n });\n // A failed trigger comes back as a Result as well as a throw; log both.\n if (result.isFail()) {\n this.logger.error({ error: result.error }, \"Error triggering task.\");\n }\n } catch (error) {\n this.logger.error({ error }, \"Error triggering task.\");\n }\n }\n\n // Clear the cache after processing\n this.clearTasks();\n }\n\n /**\n * Retrieves the cached tasks length.\n * @returns number\n */\n getTasksLength() {\n return this.getTasks().length;\n }\n\n /**\n * Retrieves the cached tasks.\n * @returns {TTask[]} The list of cached tasks.\n */\n private getTasks() {\n return this.taskCache;\n }\n\n /**\n * Clears all cached tasks.\n */\n private clearTasks() {\n this.taskCache = [];\n }\n}\n"],"names":["TaskCache","taskDefinition","logger","item","triggerTask","parent","tasks","task","result","error"],"mappings":"AAQO,MAAMA;IAKT,YAAYC,cAAsB,EAAEC,MAAwB,CAAE;aAHtD,SAAS,GAAY,EAAE;QAI3B,IAAI,CAAC,cAAc,GAAGD;QACtB,IAAI,CAAC,MAAM,GAAGC;IAClB;IAMA,UAAUC,IAAW,EAAE;QACnB,IAAI,CAAC,SAAS,CAAC,IAAI,CAACA;IACxB;IAOA,MAAM,YAAYC,WAAyC,EAAEC,MAA2B,EAAE;QACtF,MAAMC,QAAQ,IAAI,CAAC,QAAQ;QAE3B,IAAIA,AAAiB,MAAjBA,MAAM,MAAM,EACZ;QAGJ,KAAK,MAAMC,QAAQD,MACf,IAAI;YACA,MAAME,SAAS,MAAMJ,YAAY,OAAO,CAAQ;gBAC5C,YAAY,IAAI,CAAC,cAAc;gBAC/BC;gBACA,OAAOE;YACX;YAEA,IAAIC,OAAO,MAAM,IACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAE,OAAOA,OAAO,KAAK;YAAC,GAAG;QAEnD,EAAE,OAAOC,OAAO;YACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAEA;YAAM,GAAG;QACjC;QAIJ,IAAI,CAAC,UAAU;IACnB;IAMA,iBAAiB;QACb,OAAO,IAAI,CAAC,QAAQ,GAAG,MAAM;IACjC;IAMQ,WAAW;QACf,OAAO,IAAI,CAAC,SAAS;IACzB;IAKQ,aAAa;QACjB,IAAI,CAAC,SAAS,GAAG,EAAE;IACvB;AACJ"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js";
|
|
2
2
|
import { MoveEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/MoveEntry/index.js";
|
|
3
|
-
import { parseIdentifier } from "@webiny/utils";
|
|
4
3
|
import { EntriesBulkAction } from "../EntriesBulkAction/abstractions.js";
|
|
5
4
|
class MoveToFolderBulkActionImpl {
|
|
6
5
|
constructor(listLatestEntries, moveEntry){
|
|
@@ -10,12 +9,12 @@ class MoveToFolderBulkActionImpl {
|
|
|
10
9
|
}
|
|
11
10
|
async loadData(model, params) {
|
|
12
11
|
const entriesResult = await this.listLatestEntries.execute(model, params);
|
|
12
|
+
if (entriesResult.isFail()) throw entriesResult.error;
|
|
13
13
|
return entriesResult.value;
|
|
14
14
|
}
|
|
15
15
|
async processData(model, params) {
|
|
16
16
|
if (!params.data?.folderId) throw new Error('Missing "data.folderId" in the input.');
|
|
17
|
-
|
|
18
|
-
await this.moveEntry.execute(model, entryId, params.data.folderId);
|
|
17
|
+
await this.moveEntry.execute(model, params.id, params.data.folderId);
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
const MoveToFolderBulkAction = EntriesBulkAction.createImplementation({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/MoveToFolderBulkAction/MoveToFolderBulkAction.js","sources":["../../../src/features/MoveToFolderBulkAction/MoveToFolderBulkAction.ts"],"sourcesContent":["import { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { MoveEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/MoveEntry/index.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/MoveToFolderBulkAction/MoveToFolderBulkAction.js","sources":["../../../src/features/MoveToFolderBulkAction/MoveToFolderBulkAction.ts"],"sourcesContent":["import { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { MoveEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/MoveEntry/index.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\n\nclass MoveToFolderBulkActionImpl implements EntriesBulkAction.Interface {\n readonly name = \"moveToFolder\";\n\n constructor(\n private listLatestEntries: ListLatestEntriesUseCase.Interface,\n private moveEntry: MoveEntryUseCase.Interface\n ) {}\n\n async loadData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.LoadDataParams\n ): Promise<EntriesBulkAction.LoadDataResult> {\n const entriesResult = await this.listLatestEntries.execute(model, params);\n if (entriesResult.isFail()) {\n throw entriesResult.error;\n }\n\n return entriesResult.value;\n }\n\n async processData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.ProcessParams\n ): Promise<void> {\n if (!params.data?.folderId) {\n throw new Error(`Missing \"data.folderId\" in the input.`);\n }\n\n await this.moveEntry.execute(model, params.id, params.data.folderId);\n }\n}\n\nexport const MoveToFolderBulkAction = EntriesBulkAction.createImplementation({\n implementation: MoveToFolderBulkActionImpl,\n dependencies: [ListLatestEntriesUseCase, MoveEntryUseCase]\n});\n"],"names":["MoveToFolderBulkActionImpl","listLatestEntries","moveEntry","model","params","entriesResult","Error","MoveToFolderBulkAction","EntriesBulkAction","ListLatestEntriesUseCase","MoveEntryUseCase"],"mappings":";;;AAIA,MAAMA;IAGF,YACYC,iBAAqD,EACrDC,SAAqC,CAC/C;aAFUD,iBAAiB,GAAjBA;aACAC,SAAS,GAATA;aAJH,IAAI,GAAG;IAKb;IAEH,MAAM,SACFC,KAA8B,EAC9BC,MAAwC,EACC;QACzC,MAAMC,gBAAgB,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAACF,OAAOC;QAClE,IAAIC,cAAc,MAAM,IACpB,MAAMA,cAAc,KAAK;QAG7B,OAAOA,cAAc,KAAK;IAC9B;IAEA,MAAM,YACFF,KAA8B,EAC9BC,MAAuC,EAC1B;QACb,IAAI,CAACA,OAAO,IAAI,EAAE,UACd,MAAM,IAAIE,MAAM;QAGpB,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACH,OAAOC,OAAO,EAAE,EAAEA,OAAO,IAAI,CAAC,QAAQ;IACvE;AACJ;AAEO,MAAMG,yBAAyBC,kBAAkB,oBAAoB,CAAC;IACzE,gBAAgBR;IAChB,cAAc;QAACS;QAA0BC;KAAiB;AAC9D"}
|
|
@@ -10,6 +10,7 @@ class MoveToTrashBulkActionImpl {
|
|
|
10
10
|
}
|
|
11
11
|
async loadData(model, params) {
|
|
12
12
|
const entriesResult = await this.listLatestEntries.execute(model, params);
|
|
13
|
+
if (entriesResult.isFail()) throw entriesResult.error;
|
|
13
14
|
return entriesResult.value;
|
|
14
15
|
}
|
|
15
16
|
async processData(model, params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/MoveToTrashBulkAction/MoveToTrashBulkAction.js","sources":["../../../src/features/MoveToTrashBulkAction/MoveToTrashBulkAction.ts"],"sourcesContent":["import { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { DeleteEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\n\nclass MoveToTrashBulkActionImpl implements EntriesBulkAction.Interface {\n readonly name = \"moveToTrash\";\n\n constructor(\n private listLatestEntries: ListLatestEntriesUseCase.Interface,\n private deleteEntry: DeleteEntryUseCase.Interface\n ) {}\n\n async loadData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.LoadDataParams\n ): Promise<EntriesBulkAction.LoadDataResult> {\n const entriesResult = await this.listLatestEntries.execute(model, params);\n\n return entriesResult.value;\n }\n\n async processData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.ProcessParams\n ): Promise<void> {\n const { id: entryId } = parseIdentifier(params.id);\n\n await this.deleteEntry.execute(model, entryId, {\n permanently: false\n });\n }\n}\n\nexport const MoveToTrashBulkAction = EntriesBulkAction.createImplementation({\n implementation: MoveToTrashBulkActionImpl,\n dependencies: [ListLatestEntriesUseCase, DeleteEntryUseCase]\n});\n"],"names":["MoveToTrashBulkActionImpl","listLatestEntries","deleteEntry","model","params","entriesResult","entryId","parseIdentifier","MoveToTrashBulkAction","EntriesBulkAction","ListLatestEntriesUseCase","DeleteEntryUseCase"],"mappings":";;;;AAKA,MAAMA;IAGF,YACYC,iBAAqD,EACrDC,WAAyC,CACnD;aAFUD,iBAAiB,GAAjBA;aACAC,WAAW,GAAXA;aAJH,IAAI,GAAG;IAKb;IAEH,MAAM,SACFC,KAA8B,EAC9BC,MAAwC,EACC;QACzC,MAAMC,gBAAgB,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAACF,OAAOC;
|
|
1
|
+
{"version":3,"file":"features/MoveToTrashBulkAction/MoveToTrashBulkAction.js","sources":["../../../src/features/MoveToTrashBulkAction/MoveToTrashBulkAction.ts"],"sourcesContent":["import { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { DeleteEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\n\nclass MoveToTrashBulkActionImpl implements EntriesBulkAction.Interface {\n readonly name = \"moveToTrash\";\n\n constructor(\n private listLatestEntries: ListLatestEntriesUseCase.Interface,\n private deleteEntry: DeleteEntryUseCase.Interface\n ) {}\n\n async loadData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.LoadDataParams\n ): Promise<EntriesBulkAction.LoadDataResult> {\n const entriesResult = await this.listLatestEntries.execute(model, params);\n if (entriesResult.isFail()) {\n throw entriesResult.error;\n }\n\n return entriesResult.value;\n }\n\n async processData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.ProcessParams\n ): Promise<void> {\n const { id: entryId } = parseIdentifier(params.id);\n\n await this.deleteEntry.execute(model, entryId, {\n permanently: false\n });\n }\n}\n\nexport const MoveToTrashBulkAction = EntriesBulkAction.createImplementation({\n implementation: MoveToTrashBulkActionImpl,\n dependencies: [ListLatestEntriesUseCase, DeleteEntryUseCase]\n});\n"],"names":["MoveToTrashBulkActionImpl","listLatestEntries","deleteEntry","model","params","entriesResult","entryId","parseIdentifier","MoveToTrashBulkAction","EntriesBulkAction","ListLatestEntriesUseCase","DeleteEntryUseCase"],"mappings":";;;;AAKA,MAAMA;IAGF,YACYC,iBAAqD,EACrDC,WAAyC,CACnD;aAFUD,iBAAiB,GAAjBA;aACAC,WAAW,GAAXA;aAJH,IAAI,GAAG;IAKb;IAEH,MAAM,SACFC,KAA8B,EAC9BC,MAAwC,EACC;QACzC,MAAMC,gBAAgB,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAACF,OAAOC;QAClE,IAAIC,cAAc,MAAM,IACpB,MAAMA,cAAc,KAAK;QAG7B,OAAOA,cAAc,KAAK;IAC9B;IAEA,MAAM,YACFF,KAA8B,EAC9BC,MAAuC,EAC1B;QACb,MAAM,EAAE,IAAIE,OAAO,EAAE,GAAGC,gBAAgBH,OAAO,EAAE;QAEjD,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACD,OAAOG,SAAS;YAC3C,aAAa;QACjB;IACJ;AACJ;AAEO,MAAME,wBAAwBC,kBAAkB,oBAAoB,CAAC;IACxE,gBAAgBT;IAChB,cAAc;QAACU;QAA0BC;KAAmB;AAChE"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js";
|
|
2
2
|
import { PublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/PublishEntry/index.js";
|
|
3
|
-
import { parseIdentifier } from "@webiny/utils";
|
|
4
3
|
import { EntriesBulkAction } from "../EntriesBulkAction/abstractions.js";
|
|
5
4
|
class PublishEntriesBulkActionImpl {
|
|
6
5
|
constructor(listLatestEntries, publishEntry){
|
|
@@ -17,11 +16,11 @@ class PublishEntriesBulkActionImpl {
|
|
|
17
16
|
status_not: "published"
|
|
18
17
|
}
|
|
19
18
|
});
|
|
19
|
+
if (entriesResult.isFail()) throw entriesResult.error;
|
|
20
20
|
return entriesResult.value;
|
|
21
21
|
}
|
|
22
22
|
async processData(model, params) {
|
|
23
|
-
|
|
24
|
-
await this.publishEntry.execute(model, entryId);
|
|
23
|
+
await this.publishEntry.execute(model, params.id);
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
const PublishEntriesBulkAction = EntriesBulkAction.createImplementation({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/PublishEntriesBulkAction/PublishEntriesBulkAction.js","sources":["../../../src/features/PublishEntriesBulkAction/PublishEntriesBulkAction.ts"],"sourcesContent":["import { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { PublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/PublishEntry/index.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/PublishEntriesBulkAction/PublishEntriesBulkAction.js","sources":["../../../src/features/PublishEntriesBulkAction/PublishEntriesBulkAction.ts"],"sourcesContent":["import { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { PublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/PublishEntry/index.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\n\nclass PublishEntriesBulkActionImpl implements EntriesBulkAction.Interface {\n readonly name = \"publish\";\n\n constructor(\n private listLatestEntries: ListLatestEntriesUseCase.Interface,\n private publishEntry: PublishEntryUseCase.Interface\n ) {}\n\n async loadData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.LoadDataParams\n ): Promise<EntriesBulkAction.LoadDataResult> {\n const { where, ...rest } = params;\n\n const entriesResult = await this.listLatestEntries.execute(model, {\n ...rest,\n where: {\n ...where,\n status_not: \"published\"\n }\n });\n\n if (entriesResult.isFail()) {\n throw entriesResult.error;\n }\n\n return entriesResult.value;\n }\n\n async processData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.ProcessParams\n ): Promise<void> {\n await this.publishEntry.execute(model, params.id);\n }\n}\n\nexport const PublishEntriesBulkAction = EntriesBulkAction.createImplementation({\n implementation: PublishEntriesBulkActionImpl,\n dependencies: [ListLatestEntriesUseCase, PublishEntryUseCase]\n});\n"],"names":["PublishEntriesBulkActionImpl","listLatestEntries","publishEntry","model","params","where","rest","entriesResult","PublishEntriesBulkAction","EntriesBulkAction","ListLatestEntriesUseCase","PublishEntryUseCase"],"mappings":";;;AAIA,MAAMA;IAGF,YACYC,iBAAqD,EACrDC,YAA2C,CACrD;aAFUD,iBAAiB,GAAjBA;aACAC,YAAY,GAAZA;aAJH,IAAI,GAAG;IAKb;IAEH,MAAM,SACFC,KAA8B,EAC9BC,MAAwC,EACC;QACzC,MAAM,EAAEC,KAAK,EAAE,GAAGC,MAAM,GAAGF;QAE3B,MAAMG,gBAAgB,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAACJ,OAAO;YAC9D,GAAGG,IAAI;YACP,OAAO;gBACH,GAAGD,KAAK;gBACR,YAAY;YAChB;QACJ;QAEA,IAAIE,cAAc,MAAM,IACpB,MAAMA,cAAc,KAAK;QAG7B,OAAOA,cAAc,KAAK;IAC9B;IAEA,MAAM,YACFJ,KAA8B,EAC9BC,MAAuC,EAC1B;QACb,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAACD,OAAOC,OAAO,EAAE;IACpD;AACJ;AAEO,MAAMI,2BAA2BC,kBAAkB,oBAAoB,CAAC;IAC3E,gBAAgBT;IAChB,cAAc;QAACU;QAA0BC;KAAoB;AACjE"}
|
|
@@ -10,6 +10,7 @@ class RestoreEntriesBulkActionImpl {
|
|
|
10
10
|
}
|
|
11
11
|
async loadData(model, params) {
|
|
12
12
|
const entriesResult = await this.listDeletedEntries.execute(model, params);
|
|
13
|
+
if (entriesResult.isFail()) throw entriesResult.error;
|
|
13
14
|
return entriesResult.value;
|
|
14
15
|
}
|
|
15
16
|
async processData(model, params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.js","sources":["../../../src/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.ts"],"sourcesContent":["import { ListDeletedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { RestoreEntryFromBinUseCase } from \"@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\n\nclass RestoreEntriesBulkActionImpl implements EntriesBulkAction.Interface {\n readonly name = \"restore\";\n\n constructor(\n private listDeletedEntries: ListDeletedEntriesUseCase.Interface,\n private restoreEntry: RestoreEntryFromBinUseCase.Interface\n ) {}\n\n async loadData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.LoadDataParams\n ): Promise<EntriesBulkAction.LoadDataResult> {\n const entriesResult = await this.listDeletedEntries.execute(model, params);\n\n return entriesResult.value;\n }\n\n async processData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.ProcessParams\n ): Promise<void> {\n const { id: entryId } = parseIdentifier(params.id);\n\n await this.restoreEntry.execute(model, entryId);\n }\n}\n\nexport const RestoreEntriesBulkAction = EntriesBulkAction.createImplementation({\n implementation: RestoreEntriesBulkActionImpl,\n dependencies: [ListDeletedEntriesUseCase, RestoreEntryFromBinUseCase]\n});\n"],"names":["RestoreEntriesBulkActionImpl","listDeletedEntries","restoreEntry","model","params","entriesResult","entryId","parseIdentifier","RestoreEntriesBulkAction","EntriesBulkAction","ListDeletedEntriesUseCase","RestoreEntryFromBinUseCase"],"mappings":";;;;AAKA,MAAMA;IAGF,YACYC,kBAAuD,EACvDC,YAAkD,CAC5D;aAFUD,kBAAkB,GAAlBA;aACAC,YAAY,GAAZA;aAJH,IAAI,GAAG;IAKb;IAEH,MAAM,SACFC,KAA8B,EAC9BC,MAAwC,EACC;QACzC,MAAMC,gBAAgB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACF,OAAOC;
|
|
1
|
+
{"version":3,"file":"features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.js","sources":["../../../src/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.ts"],"sourcesContent":["import { ListDeletedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { RestoreEntryFromBinUseCase } from \"@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\n\nclass RestoreEntriesBulkActionImpl implements EntriesBulkAction.Interface {\n readonly name = \"restore\";\n\n constructor(\n private listDeletedEntries: ListDeletedEntriesUseCase.Interface,\n private restoreEntry: RestoreEntryFromBinUseCase.Interface\n ) {}\n\n async loadData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.LoadDataParams\n ): Promise<EntriesBulkAction.LoadDataResult> {\n const entriesResult = await this.listDeletedEntries.execute(model, params);\n if (entriesResult.isFail()) {\n throw entriesResult.error;\n }\n\n return entriesResult.value;\n }\n\n async processData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.ProcessParams\n ): Promise<void> {\n const { id: entryId } = parseIdentifier(params.id);\n\n await this.restoreEntry.execute(model, entryId);\n }\n}\n\nexport const RestoreEntriesBulkAction = EntriesBulkAction.createImplementation({\n implementation: RestoreEntriesBulkActionImpl,\n dependencies: [ListDeletedEntriesUseCase, RestoreEntryFromBinUseCase]\n});\n"],"names":["RestoreEntriesBulkActionImpl","listDeletedEntries","restoreEntry","model","params","entriesResult","entryId","parseIdentifier","RestoreEntriesBulkAction","EntriesBulkAction","ListDeletedEntriesUseCase","RestoreEntryFromBinUseCase"],"mappings":";;;;AAKA,MAAMA;IAGF,YACYC,kBAAuD,EACvDC,YAAkD,CAC5D;aAFUD,kBAAkB,GAAlBA;aACAC,YAAY,GAAZA;aAJH,IAAI,GAAG;IAKb;IAEH,MAAM,SACFC,KAA8B,EAC9BC,MAAwC,EACC;QACzC,MAAMC,gBAAgB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACF,OAAOC;QACnE,IAAIC,cAAc,MAAM,IACpB,MAAMA,cAAc,KAAK;QAG7B,OAAOA,cAAc,KAAK;IAC9B;IAEA,MAAM,YACFF,KAA8B,EAC9BC,MAAuC,EAC1B;QACb,MAAM,EAAE,IAAIE,OAAO,EAAE,GAAGC,gBAAgBH,OAAO,EAAE;QAEjD,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAACD,OAAOG;IAC3C;AACJ;AAEO,MAAME,2BAA2BC,kBAAkB,oBAAoB,CAAC;IAC3E,gBAAgBT;IAChB,cAAc;QAACU;QAA2BC;KAA2B;AACzE"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ListPublishedEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js";
|
|
2
2
|
import { UnpublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UnpublishEntry/index.js";
|
|
3
|
-
import { parseIdentifier } from "@webiny/utils";
|
|
4
3
|
import { EntriesBulkAction } from "../EntriesBulkAction/abstractions.js";
|
|
5
4
|
class UnpublishEntriesBulkActionImpl {
|
|
6
5
|
constructor(listPublishedEntries, unpublishEntry){
|
|
@@ -10,11 +9,11 @@ class UnpublishEntriesBulkActionImpl {
|
|
|
10
9
|
}
|
|
11
10
|
async loadData(model, params) {
|
|
12
11
|
const entriesResult = await this.listPublishedEntries.execute(model, params);
|
|
12
|
+
if (entriesResult.isFail()) throw entriesResult.error;
|
|
13
13
|
return entriesResult.value;
|
|
14
14
|
}
|
|
15
15
|
async processData(model, params) {
|
|
16
|
-
|
|
17
|
-
await this.unpublishEntry.execute(model, entryId);
|
|
16
|
+
await this.unpublishEntry.execute(model, params.id);
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
const UnpublishEntriesBulkAction = EntriesBulkAction.createImplementation({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.js","sources":["../../../src/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.ts"],"sourcesContent":["import { ListPublishedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { UnpublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UnpublishEntry/index.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.js","sources":["../../../src/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.ts"],"sourcesContent":["import { ListPublishedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { UnpublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UnpublishEntry/index.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\n\nclass UnpublishEntriesBulkActionImpl implements EntriesBulkAction.Interface {\n readonly name = \"unpublish\";\n\n constructor(\n private listPublishedEntries: ListPublishedEntriesUseCase.Interface,\n private unpublishEntry: UnpublishEntryUseCase.Interface\n ) {}\n\n async loadData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.LoadDataParams\n ): Promise<EntriesBulkAction.LoadDataResult> {\n const entriesResult = await this.listPublishedEntries.execute(model, params);\n if (entriesResult.isFail()) {\n throw entriesResult.error;\n }\n\n return entriesResult.value;\n }\n\n async processData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.ProcessParams\n ): Promise<void> {\n await this.unpublishEntry.execute(model, params.id);\n }\n}\n\nexport const UnpublishEntriesBulkAction = EntriesBulkAction.createImplementation({\n implementation: UnpublishEntriesBulkActionImpl,\n dependencies: [ListPublishedEntriesUseCase, UnpublishEntryUseCase]\n});\n"],"names":["UnpublishEntriesBulkActionImpl","listPublishedEntries","unpublishEntry","model","params","entriesResult","UnpublishEntriesBulkAction","EntriesBulkAction","ListPublishedEntriesUseCase","UnpublishEntryUseCase"],"mappings":";;;AAIA,MAAMA;IAGF,YACYC,oBAA2D,EAC3DC,cAA+C,CACzD;aAFUD,oBAAoB,GAApBA;aACAC,cAAc,GAAdA;aAJH,IAAI,GAAG;IAKb;IAEH,MAAM,SACFC,KAA8B,EAC9BC,MAAwC,EACC;QACzC,MAAMC,gBAAgB,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAACF,OAAOC;QACrE,IAAIC,cAAc,MAAM,IACpB,MAAMA,cAAc,KAAK;QAG7B,OAAOA,cAAc,KAAK;IAC9B;IAEA,MAAM,YACFF,KAA8B,EAC9BC,MAAuC,EAC1B;QACb,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACD,OAAOC,OAAO,EAAE;IACtD;AACJ;AAEO,MAAME,6BAA6BC,kBAAkB,oBAAoB,CAAC;IAC7E,gBAAgBP;IAChB,cAAc;QAACQ;QAA6BC;KAAsB;AACtE"}
|
|
@@ -3,6 +3,7 @@ import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentMode
|
|
|
3
3
|
import { CMS_MODEL_SINGLETON_TAG } from "@webiny/api-headless-cms/constants.js";
|
|
4
4
|
import { Response } from "@webiny/api-graphql";
|
|
5
5
|
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
6
|
+
import { HeadlessCmsEndpointConfig } from "@webiny/api-headless-cms/HeadlessCmsEndpointConfig.js";
|
|
6
7
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
7
8
|
import { TriggerTaskUseCase } from "@webiny/background-tasks/api";
|
|
8
9
|
import { EntriesBulkAction } from "../features/EntriesBulkAction/abstractions.js";
|
|
@@ -87,7 +88,7 @@ class BulkActionsGraphQLSchemaImpl {
|
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
},
|
|
90
|
-
isApplicable: (context)=>context.container.resolve(TenantContext).getTenant().id === tenant.id
|
|
91
|
+
isApplicable: (context)=>context.container.resolve(TenantContext).getTenant().id === tenant.id && "manage" === context.container.resolve(HeadlessCmsEndpointConfig).type
|
|
91
92
|
});
|
|
92
93
|
modelPlugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}`;
|
|
93
94
|
plugins.push(modelPlugin);
|
|
@@ -1 +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":"
|
|
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 { HeadlessCmsEndpointConfig } from \"@webiny/api-headless-cms/HeadlessCmsEndpointConfig.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 // Bulk actions change entries: manage endpoint only.\n context.container.resolve(HeadlessCmsEndpointConfig).type === \"manage\"\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","HeadlessCmsEndpointConfig","BulkActionsGraphQLSchema","CmsGraphQLSchemaFactory","RequestContainer"],"mappings":";;;;;;;;;;;;AAmBA,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,CAAC,QAAQ,CAACV,MAAM,OAAO;gBAEjD,OAAO;YACX;YAEA,MAAMW,aAAaF,kBACd,GAAG,CAACC,CAAAA,SAAUE,eAAe,IAAI,CAACF,OAAO,IAAI,GAC7C,IAAI,CAAC;YAEV,MAAMG,cAAc,IAAIL,uBAA+C;gBACnE,UAAwB,CAAC;mCACN,EAAER,MAAM,eAAe,CAAC;;wBAEnC,EAAEW,WAAW;;;;kCAIH,EAAEX,MAAM,eAAe,CAAC;8CACZ,EAAEA,MAAM,eAAe,CAAC;mCACnC,EAAEA,MAAM,eAAe,CAAC;;;;;gBAK3C,CAAC;gBACD,WAAW;oBACP,UAAU;wBACN,CAAC,CAAC,UAAU,EAAEA,MAAM,eAAe,EAAE,CAAC,EAAE,OAAOc,GAAGC,MAAMzB;4BACpD,MAAM0B,WAAW1B,QAAQ,SAAS,CAC7B,OAAO,CAACM,iBACR,WAAW;4BAEhB,MAAMqB,WAAW,MAAM3B,QAAQ,SAAS,CACnC,OAAO,CAAC4B,oBACR,OAAO,CAAC;gCACL,YAAYC;gCACZ,OAAO;oCACH,YAAYJ,KAAK,MAAM;oCACvB,SAASf,MAAM,OAAO;oCACtB,OAAOe,KAAK,KAAK;oCACjB,QAAQA,KAAK,MAAM;oCACnB,MAAMA,KAAK,IAAI;oCACfC;gCACJ;4BACJ;4BAEJ,OAAO,IAAII,SAAS;gCAChB,IAAIH,SAAS,KAAK,CAAC,EAAE;4BACzB;wBACJ;oBACJ;gBACJ;gBACA,cAAc3B,CAAAA,UACVA,QAAQ,SAAS,CAAC,OAAO,CAACE,eAAe,SAAS,GAAG,EAAE,KAAKC,OAAO,EAAE,IAErEH,AAA8D,aAA9DA,QAAQ,SAAS,CAAC,OAAO,CAAC+B,2BAA2B,IAAI;YACjE;YAEAR,YAAY,IAAI,GAAG,CAAC,uCAAuC,EAAEb,MAAM,OAAO,EAAE;YAC5EM,QAAQ,IAAI,CAACO;QACjB;QAEA,OAAOP;IACX;AACJ;AAEO,MAAMgB,2BAA2BC,wBAAwB,oBAAoB,CAAC;IACjF,gBAAgBnC;IAChB,cAAc;QAACoC;KAAiB;AACpC"}
|
|
@@ -4,6 +4,7 @@ import { Response } from "@webiny/api-graphql";
|
|
|
4
4
|
import { CMS_MODEL_SINGLETON_TAG } from "@webiny/api-headless-cms/constants.js";
|
|
5
5
|
import { BulkActionName } from "../domain/BulkActionName.js";
|
|
6
6
|
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
7
|
+
import { HeadlessCmsEndpointConfig } from "@webiny/api-headless-cms/HeadlessCmsEndpointConfig.js";
|
|
7
8
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
8
9
|
import { TriggerTaskUseCase } from "@webiny/background-tasks/api";
|
|
9
10
|
const createBulkActionGraphQL = async (context, bulkAction)=>{
|
|
@@ -46,7 +47,7 @@ const createBulkActionGraphQL = async (context, bulkAction)=>{
|
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
},
|
|
49
|
-
isApplicable: (context)=>context.container.resolve(TenantContext).getTenant().id === tenant.id
|
|
50
|
+
isApplicable: (context)=>context.container.resolve(TenantContext).getTenant().id === tenant.id && "manage" === context.container.resolve(HeadlessCmsEndpointConfig).type
|
|
50
51
|
});
|
|
51
52
|
plugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}.${bulkAction.name}`;
|
|
52
53
|
plugins.push(plugin);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/createBulkActionGraphQL.js","sources":["../../src/graphql/createBulkActionGraphQL.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 { Response } from \"@webiny/api-graphql\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/api-headless-cms/constants.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport { BulkActionName } from \"~/domain/BulkActionName.js\";\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\";\n\nexport const createBulkActionGraphQL = async (\n context: HcmsBulkActionsContext,\n bulkAction: EntriesBulkAction.Interface\n) => {\n const tenant = context.container.resolve(TenantContext).getTenant();\n\n if (!(await isHeadlessCmsReady(context))) {\n return;\n }\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 if (tags.includes(CMS_MODEL_SINGLETON_TAG)) {\n return false;\n }\n if (bulkAction.modelIds?.length) {\n return bulkAction.modelIds.includes(model.modelId);\n }\n return true;\n });\n\n const plugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n models.forEach(model => {\n const plugin = new CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>({\n typeDefs: /* GraphQL */ `\n extend enum BulkAction${model.singularApiName}Name {\n ${BulkActionName.from(bulkAction.name)}\n }\n `,\n resolvers: {\n Mutation: {\n [`bulkAction${model.singularApiName}`]: async (_, args, context) => {\n const identity = context.container.resolve(IdentityContext).getIdentity();\n\n const response = await context.container\n .resolve(TriggerTaskUseCase)\n .execute({\n definition: `hcmsBulkList${args.action}Entries`,\n input: {\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 plugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}.${bulkAction.name}`;\n plugins.push(plugin);\n });\n\n context.container.registerInstance(CmsGraphQLSchemaFactory, {\n execute: () => plugins\n });\n};\n"],"names":["createBulkActionGraphQL","context","bulkAction","tenant","TenantContext","isHeadlessCmsReady","modelsResult","IdentityContext","ListModelsUseCase","models","model","tags","Array","CMS_MODEL_SINGLETON_TAG","plugins","plugin","CmsGraphQLSchemaPlugin","BulkActionName","_","args","identity","response","TriggerTaskUseCase","Response","CmsGraphQLSchemaFactory"],"mappings":"
|
|
1
|
+
{"version":3,"file":"graphql/createBulkActionGraphQL.js","sources":["../../src/graphql/createBulkActionGraphQL.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 { Response } from \"@webiny/api-graphql\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/api-headless-cms/constants.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport { BulkActionName } from \"~/domain/BulkActionName.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { HeadlessCmsEndpointConfig } from \"@webiny/api-headless-cms/HeadlessCmsEndpointConfig.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { TriggerTaskUseCase } from \"@webiny/background-tasks/api\";\n\nexport const createBulkActionGraphQL = async (\n context: HcmsBulkActionsContext,\n bulkAction: EntriesBulkAction.Interface\n) => {\n const tenant = context.container.resolve(TenantContext).getTenant();\n\n if (!(await isHeadlessCmsReady(context))) {\n return;\n }\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 if (tags.includes(CMS_MODEL_SINGLETON_TAG)) {\n return false;\n }\n if (bulkAction.modelIds?.length) {\n return bulkAction.modelIds.includes(model.modelId);\n }\n return true;\n });\n\n const plugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n models.forEach(model => {\n const plugin = new CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>({\n typeDefs: /* GraphQL */ `\n extend enum BulkAction${model.singularApiName}Name {\n ${BulkActionName.from(bulkAction.name)}\n }\n `,\n resolvers: {\n Mutation: {\n [`bulkAction${model.singularApiName}`]: async (_, args, context) => {\n const identity = context.container.resolve(IdentityContext).getIdentity();\n\n const response = await context.container\n .resolve(TriggerTaskUseCase)\n .execute({\n definition: `hcmsBulkList${args.action}Entries`,\n input: {\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 // Bulk actions change entries: manage endpoint only.\n context.container.resolve(HeadlessCmsEndpointConfig).type === \"manage\"\n });\n\n plugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}.${bulkAction.name}`;\n plugins.push(plugin);\n });\n\n context.container.registerInstance(CmsGraphQLSchemaFactory, {\n execute: () => plugins\n });\n};\n"],"names":["createBulkActionGraphQL","context","bulkAction","tenant","TenantContext","isHeadlessCmsReady","modelsResult","IdentityContext","ListModelsUseCase","models","model","tags","Array","CMS_MODEL_SINGLETON_TAG","plugins","plugin","CmsGraphQLSchemaPlugin","BulkActionName","_","args","identity","response","TriggerTaskUseCase","Response","HeadlessCmsEndpointConfig","CmsGraphQLSchemaFactory"],"mappings":";;;;;;;;;AAgBO,MAAMA,0BAA0B,OACnCC,SACAC;IAEA,MAAMC,SAASF,QAAQ,SAAS,CAAC,OAAO,CAACG,eAAe,SAAS;IAEjE,IAAI,CAAE,MAAMC,mBAAmBJ,UAC3B;IAGJ,MAAMK,eAAe,MAAML,QAAQ,SAAS,CACvC,OAAO,CAACM,iBACR,oBAAoB,CAAC,UACXN,QAAQ,SAAS,CAAC,OAAO,CAACO,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,IAAIC,KAAK,QAAQ,CAACE,0BACd,OAAO;QAEX,IAAIX,WAAW,QAAQ,EAAE,QACrB,OAAOA,WAAW,QAAQ,CAAC,QAAQ,CAACQ,MAAM,OAAO;QAErD,OAAO;IACX;IAEA,MAAMI,UAA4D,EAAE;IAEpEL,OAAO,OAAO,CAACC,CAAAA;QACX,MAAMK,SAAS,IAAIC,uBAA+C;YAC9D,UAAwB,CAAC;2CACM,EAAEN,MAAM,eAAe,CAAC;wBAC3C,EAAEO,eAAe,IAAI,CAACf,WAAW,IAAI,EAAE;;gBAE/C,CAAC;YACL,WAAW;gBACP,UAAU;oBACN,CAAC,CAAC,UAAU,EAAEQ,MAAM,eAAe,EAAE,CAAC,EAAE,OAAOQ,GAAGC,MAAMlB;wBACpD,MAAMmB,WAAWnB,QAAQ,SAAS,CAAC,OAAO,CAACM,iBAAiB,WAAW;wBAEvE,MAAMc,WAAW,MAAMpB,QAAQ,SAAS,CACnC,OAAO,CAACqB,oBACR,OAAO,CAAC;4BACL,YAAY,CAAC,YAAY,EAAEH,KAAK,MAAM,CAAC,OAAO,CAAC;4BAC/C,OAAO;gCACH,SAAST,MAAM,OAAO;gCACtB,OAAOS,KAAK,KAAK;gCACjB,QAAQA,KAAK,MAAM;gCACnB,MAAMA,KAAK,IAAI;gCACfC;4BACJ;wBACJ;wBAEJ,OAAO,IAAIG,SAAS;4BAChB,IAAIF,SAAS,KAAK,CAAC,EAAE;wBACzB;oBACJ;gBACJ;YACJ;YACA,cAAcpB,CAAAA,UACVA,QAAQ,SAAS,CAAC,OAAO,CAACG,eAAe,SAAS,GAAG,EAAE,KAAKD,OAAO,EAAE,IAErEF,AAA8D,aAA9DA,QAAQ,SAAS,CAAC,OAAO,CAACuB,2BAA2B,IAAI;QACjE;QAEAT,OAAO,IAAI,GAAG,CAAC,uCAAuC,EAAEL,MAAM,OAAO,CAAC,CAAC,EAAER,WAAW,IAAI,EAAE;QAC1FY,QAAQ,IAAI,CAACC;IACjB;IAEAd,QAAQ,SAAS,CAAC,gBAAgB,CAACwB,yBAAyB;QACxD,SAAS,IAAMX;IACnB;AACJ"}
|
|
@@ -2,6 +2,7 @@ import { CmsGraphQLSchemaFactory, CmsGraphQLSchemaPlugin, isHeadlessCmsReady } f
|
|
|
2
2
|
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
3
3
|
import { CMS_MODEL_SINGLETON_TAG } from "@webiny/api-headless-cms/constants.js";
|
|
4
4
|
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
5
|
+
import { HeadlessCmsEndpointConfig } from "@webiny/api-headless-cms/HeadlessCmsEndpointConfig.js";
|
|
5
6
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
6
7
|
const registerDefaultBulkActionGraphQL = async (context)=>{
|
|
7
8
|
const tenant = context.container.resolve(TenantContext).getTenant();
|
|
@@ -43,7 +44,7 @@ const registerDefaultBulkActionGraphQL = async (context)=>{
|
|
|
43
44
|
): BulkActionResponse
|
|
44
45
|
}
|
|
45
46
|
`,
|
|
46
|
-
isApplicable: (context)=>context.container.resolve(TenantContext).getTenant().id === tenant.id
|
|
47
|
+
isApplicable: (context)=>context.container.resolve(TenantContext).getTenant().id === tenant.id && "manage" === context.container.resolve(HeadlessCmsEndpointConfig).type
|
|
47
48
|
});
|
|
48
49
|
plugin.name = `headless-cms.graphql.schema.bulkAction.default.${model.modelId}`;
|
|
49
50
|
modelPlugins.push(plugin);
|
|
@@ -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 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":"
|
|
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 { HeadlessCmsEndpointConfig } from \"@webiny/api-headless-cms/HeadlessCmsEndpointConfig.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 // Bulk actions change entries: manage endpoint only.\n context.container.resolve(HeadlessCmsEndpointConfig).type === \"manage\"\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","HeadlessCmsEndpointConfig","CmsGraphQLSchemaFactory"],"mappings":";;;;;;AAkBO,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,IAErED,AAA8D,aAA9DA,QAAQ,SAAS,CAAC,OAAO,CAACgB,2BAA2B,IAAI;QACjE;QAEAD,OAAO,IAAI,GAAG,CAAC,+CAA+C,EAAEL,MAAM,OAAO,EAAE;QAC/EI,aAAa,IAAI,CAACC;IACtB;IAEAf,QAAQ,SAAS,CAAC,gBAAgB,CAACiB,yBAAyB;QACxD,SAAS,IAAM;gBAACb;mBAAkBU;aAAa;IACnD;AACJ"}
|
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.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -17,26 +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/background-tasks": "6.6.0-alpha.
|
|
23
|
-
"@webiny/event-handler-core": "6.6.0-alpha.
|
|
24
|
-
"@webiny/feature": "6.6.0-alpha.
|
|
25
|
-
"@webiny/handler": "6.6.0-alpha.
|
|
26
|
-
"@webiny/utils": "6.6.0-alpha.
|
|
20
|
+
"@webiny/api-graphql": "6.6.0-alpha.10",
|
|
21
|
+
"@webiny/api-headless-cms": "6.6.0-alpha.10",
|
|
22
|
+
"@webiny/background-tasks": "6.6.0-alpha.10",
|
|
23
|
+
"@webiny/event-handler-core": "6.6.0-alpha.10",
|
|
24
|
+
"@webiny/feature": "6.6.0-alpha.10",
|
|
25
|
+
"@webiny/handler": "6.6.0-alpha.10",
|
|
26
|
+
"@webiny/utils": "6.6.0-alpha.10"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@webiny/api": "6.6.0-alpha.
|
|
30
|
-
"@webiny/api-core": "6.6.0-alpha.
|
|
31
|
-
"@webiny/api-graphql": "6.6.0-alpha.
|
|
32
|
-
"@webiny/api-headless-cms-testing": "6.6.0-alpha.
|
|
33
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
34
|
-
"@webiny/di": "
|
|
35
|
-
"@webiny/plugins": "6.6.0-alpha.
|
|
36
|
-
"@webiny/wcp": "6.6.0-alpha.
|
|
29
|
+
"@webiny/api": "6.6.0-alpha.10",
|
|
30
|
+
"@webiny/api-core": "6.6.0-alpha.10",
|
|
31
|
+
"@webiny/api-graphql": "6.6.0-alpha.10",
|
|
32
|
+
"@webiny/api-headless-cms-testing": "6.6.0-alpha.10",
|
|
33
|
+
"@webiny/build-tools": "6.6.0-alpha.10",
|
|
34
|
+
"@webiny/di": "2.0.0",
|
|
35
|
+
"@webiny/plugins": "6.6.0-alpha.10",
|
|
36
|
+
"@webiny/wcp": "6.6.0-alpha.10",
|
|
37
37
|
"graphql": "16.14.2",
|
|
38
38
|
"typescript": "7.0.2",
|
|
39
|
-
"vitest": "
|
|
39
|
+
"vitest": "5.0.5"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import type { IEmptyTrashBinsInput, IEmptyTrashBinsOutput } from "../types.js";
|
|
2
|
-
import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
2
|
+
import { TaskDefinition, TaskHandler } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
3
3
|
import { ListTenantsUseCase } from "@webiny/api-core/features/tenancy/ListTenants/index.js";
|
|
4
4
|
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
5
5
|
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
6
6
|
import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js";
|
|
7
7
|
import { ListDeletedEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js";
|
|
8
|
-
declare class
|
|
8
|
+
declare class EmptyTrashBinTaskHandlerImpl implements TaskHandler.Interface<IEmptyTrashBinsInput, IEmptyTrashBinsOutput> {
|
|
9
9
|
private tenantContext;
|
|
10
10
|
private listTenants;
|
|
11
11
|
private listModels;
|
|
12
12
|
private listDeletedEntries;
|
|
13
13
|
private deleteEntry;
|
|
14
|
+
constructor(tenantContext: TenantContext.Interface, listTenants: ListTenantsUseCase.Interface, listModels: ListModelsUseCase.Interface, listDeletedEntries: ListDeletedEntriesUseCase.Interface, deleteEntry: DeleteEntryUseCase.Interface);
|
|
15
|
+
run(params: TaskHandler.RunParams<IEmptyTrashBinsInput, IEmptyTrashBinsOutput>): Promise<TaskDefinition.Result<IEmptyTrashBinsInput, IEmptyTrashBinsOutput>>;
|
|
16
|
+
}
|
|
17
|
+
declare class EmptyTrashBinTask implements TaskDefinition.Interface {
|
|
14
18
|
readonly isPrivate = true;
|
|
15
19
|
readonly id = "hcmsEntriesEmptyTrashBins";
|
|
16
20
|
readonly title = "Headless CMS - Empty all trash bins";
|
|
@@ -18,8 +22,9 @@ declare class EmptyTrashBinTask implements TaskDefinition.Interface<IEmptyTrashB
|
|
|
18
22
|
readonly maxIterations = 120;
|
|
19
23
|
readonly databaseLogs = false;
|
|
20
24
|
readonly selfCleanup: ("onAbort" | "onSuccess")[];
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
handler: typeof EmptyTrashBinTaskHandlerImpl & {
|
|
26
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskHandler<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
|
|
27
|
+
};
|
|
23
28
|
}
|
|
24
29
|
export declare const EmptyTrashBinTaskDefinition: typeof EmptyTrashBinTask & {
|
|
25
30
|
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskDefinition<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
|