@strapi/review-workflows 5.3.0 → 5.4.0

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.
@@ -7402,8 +7402,9 @@ const stages$1 = ({ strapi: strapi2 }) => {
7402
7402
  /**
7403
7403
  * Update the stage of an entity
7404
7404
  */
7405
- async updateEntity(documentId, locale, model, stageId) {
7405
+ async updateEntity(entityToUpdate, model, stageId) {
7406
7406
  const stage = await this.findById(stageId);
7407
+ const { documentId, locale } = entityToUpdate;
7407
7408
  await workflowValidator.validateWorkflowCount();
7408
7409
  if (!stage) {
7409
7410
  throw new ApplicationError$2(`Selected stage does not exist`);
@@ -7416,6 +7417,10 @@ const stages$1 = ({ strapi: strapi2 }) => {
7416
7417
  data: { [ENTITY_STAGE_ATTRIBUTE]: fp.pick(["id"], stage) },
7417
7418
  populate: [ENTITY_STAGE_ATTRIBUTE]
7418
7419
  });
7420
+ const { tableName } = strapi2.db.metadata.get(model);
7421
+ await strapi2.db.connection(tableName).where({ id: entityToUpdate.id }).update({
7422
+ updated_at: new Date(entityToUpdate.updatedAt)
7423
+ });
7419
7424
  metrics.sendDidChangeEntryStage();
7420
7425
  return entity;
7421
7426
  },
@@ -7562,32 +7567,28 @@ const assignees$1 = ({ strapi: strapi2 }) => {
7562
7567
  /**
7563
7568
  * Update the assignee of an entity
7564
7569
  */
7565
- async updateEntityAssignee(documentId, locale, model, assigneeId) {
7566
- if (fp.isNil(assigneeId)) {
7567
- return this.deleteEntityAssignee(documentId, locale, model);
7568
- }
7569
- const userExists = await getAdminService("user", { strapi: strapi2 }).exists({ id: assigneeId });
7570
- if (!userExists) {
7571
- throw new ApplicationError(`Selected user does not exist`);
7570
+ async updateEntityAssignee(entityToUpdate, model, assigneeId) {
7571
+ const { documentId, locale } = entityToUpdate;
7572
+ if (!fp.isNil(assigneeId)) {
7573
+ const userExists = await getAdminService("user", { strapi: strapi2 }).exists({ id: assigneeId });
7574
+ if (!userExists) {
7575
+ throw new ApplicationError(`Selected user does not exist`);
7576
+ }
7572
7577
  }
7573
- metrics.sendDidEditAssignee(await this.findEntityAssigneeId(documentId, model), assigneeId);
7574
- return strapi2.documents(model).update({
7578
+ const oldAssigneeId = await this.findEntityAssigneeId(entityToUpdate.id, model);
7579
+ metrics.sendDidEditAssignee(oldAssigneeId, assigneeId || null);
7580
+ const entity = await strapi2.documents(model).update({
7575
7581
  documentId,
7576
7582
  locale,
7577
- data: { [ENTITY_ASSIGNEE_ATTRIBUTE]: assigneeId },
7583
+ data: { [ENTITY_ASSIGNEE_ATTRIBUTE]: assigneeId || null },
7578
7584
  populate: [ENTITY_ASSIGNEE_ATTRIBUTE],
7579
7585
  fields: []
7580
7586
  });
7581
- },
7582
- async deleteEntityAssignee(documentId, locale, model) {
7583
- metrics.sendDidEditAssignee(await this.findEntityAssigneeId(documentId, model), null);
7584
- return strapi2.documents(model).update({
7585
- documentId,
7586
- locale,
7587
- data: { [ENTITY_ASSIGNEE_ATTRIBUTE]: null },
7588
- populate: [ENTITY_ASSIGNEE_ATTRIBUTE],
7589
- fields: []
7587
+ const { tableName } = strapi2.db.metadata.get(model);
7588
+ await strapi2.db.connection(tableName).where({ id: entityToUpdate.id }).update({
7589
+ updated_at: new Date(entityToUpdate.updatedAt)
7590
7590
  });
7591
+ return entity;
7591
7592
  }
7592
7593
  };
7593
7594
  };
@@ -8197,12 +8198,7 @@ const stages = {
8197
8198
  );
8198
8199
  const workflow2 = await workflowService.assertContentTypeBelongsToWorkflow(modelUID);
8199
8200
  workflowService.assertStageBelongsToWorkflow(stageId, workflow2);
8200
- const updatedEntity = await stagesService.updateEntity(
8201
- entity.documentId,
8202
- entity.locale,
8203
- modelUID,
8204
- stageId
8205
- );
8201
+ const updatedEntity = await stagesService.updateEntity(entity, modelUID, stageId);
8206
8202
  ctx.body = { data: await sanitizeOutput(updatedEntity) };
8207
8203
  },
8208
8204
  /**
@@ -8299,12 +8295,7 @@ const assignees = {
8299
8295
  "You should pass a valid id to the body of the put request."
8300
8296
  );
8301
8297
  await workflowService.assertContentTypeBelongsToWorkflow(model);
8302
- const updatedEntity = await assigneeService.updateEntityAssignee(
8303
- documentId,
8304
- locale || null,
8305
- model,
8306
- assigneeId
8307
- );
8298
+ const updatedEntity = await assigneeService.updateEntityAssignee(entity, model, assigneeId);
8308
8299
  ctx.body = { data: await sanitizeOutput(updatedEntity) };
8309
8300
  }
8310
8301
  };