EDIT!!!
Switch
const isUnpublishingOrDraft = (cmsData: CmsData) => !cmsData.publishedAt;
to
const isPublishingOrUpdatingPublished = (entityData: any, cmsData: CmsData) => {
return entityData.publishedAt === null && cmsData.publishedAt || // Publishing
entityData.publishedAt && cmsData.publishedAt === undefined; // Updating published
}
Remove
if (isUnpublishingOrDraft(cmsData)) {
return;
}
And put it like this
const contentTypeId = where?.id || result?.id;
const entityData = await getEntity(contentTypeId, contentTypeName, relationsToCheck);
// Do not check if entity is being updated in a draft mode
if (!isPublishingOrUpdatingPublished(entityData, cmsData)) {
return;
}