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