@strapi/content-releases 5.61.1 → 5.63.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.
- package/dist/admin/components/CreateReleaseFromSkippedDrawer.js +244 -0
- package/dist/admin/components/CreateReleaseFromSkippedDrawer.js.map +1 -0
- package/dist/admin/components/CreateReleaseFromSkippedDrawer.mjs +218 -0
- package/dist/admin/components/CreateReleaseFromSkippedDrawer.mjs.map +1 -0
- package/dist/admin/components/EntryLinkButton.js +81 -0
- package/dist/admin/components/EntryLinkButton.js.map +1 -0
- package/dist/admin/components/EntryLinkButton.mjs +57 -0
- package/dist/admin/components/EntryLinkButton.mjs.map +1 -0
- package/dist/admin/components/EntryReasonDrawer.js +509 -0
- package/dist/admin/components/EntryReasonDrawer.js.map +1 -0
- package/dist/admin/components/EntryReasonDrawer.mjs +486 -0
- package/dist/admin/components/EntryReasonDrawer.mjs.map +1 -0
- package/dist/admin/components/RelativeTime.js +4 -2
- package/dist/admin/components/RelativeTime.js.map +1 -1
- package/dist/admin/components/RelativeTime.mjs +5 -3
- package/dist/admin/components/RelativeTime.mjs.map +1 -1
- package/dist/admin/components/ReleaseAction.js +10 -8
- package/dist/admin/components/ReleaseAction.js.map +1 -1
- package/dist/admin/components/ReleaseAction.mjs +11 -9
- package/dist/admin/components/ReleaseAction.mjs.map +1 -1
- package/dist/admin/components/ReleaseActionMenu.js +31 -63
- package/dist/admin/components/ReleaseActionMenu.js.map +1 -1
- package/dist/admin/components/ReleaseActionMenu.mjs +32 -44
- package/dist/admin/components/ReleaseActionMenu.mjs.map +1 -1
- package/dist/admin/components/ReleaseActionModal.js +23 -13
- package/dist/admin/components/ReleaseActionModal.js.map +1 -1
- package/dist/admin/components/ReleaseActionModal.mjs +24 -14
- package/dist/admin/components/ReleaseActionModal.mjs.map +1 -1
- package/dist/admin/components/ReleaseActionOptions.js +55 -90
- package/dist/admin/components/ReleaseActionOptions.js.map +1 -1
- package/dist/admin/components/ReleaseActionOptions.mjs +56 -91
- package/dist/admin/components/ReleaseActionOptions.mjs.map +1 -1
- package/dist/admin/components/ReleaseActionStatus.js +173 -0
- package/dist/admin/components/ReleaseActionStatus.js.map +1 -0
- package/dist/admin/components/ReleaseActionStatus.mjs +165 -0
- package/dist/admin/components/ReleaseActionStatus.mjs.map +1 -0
- package/dist/admin/components/ReleaseDrawer.js +529 -0
- package/dist/admin/components/ReleaseDrawer.js.map +1 -0
- package/dist/admin/components/ReleaseDrawer.mjs +506 -0
- package/dist/admin/components/ReleaseDrawer.mjs.map +1 -0
- package/dist/admin/components/ReleaseStatusBadge.js +122 -0
- package/dist/admin/components/ReleaseStatusBadge.js.map +1 -0
- package/dist/admin/components/ReleaseStatusBadge.mjs +118 -0
- package/dist/admin/components/ReleaseStatusBadge.mjs.map +1 -0
- package/dist/admin/components/ReleasesPanel.js +12 -7
- package/dist/admin/components/ReleasesPanel.js.map +1 -1
- package/dist/admin/components/ReleasesPanel.mjs +12 -7
- package/dist/admin/components/ReleasesPanel.mjs.map +1 -1
- package/dist/admin/components/ScheduleFilterInput.js +100 -0
- package/dist/admin/components/ScheduleFilterInput.js.map +1 -0
- package/dist/admin/components/ScheduleFilterInput.mjs +78 -0
- package/dist/admin/components/ScheduleFilterInput.mjs.map +1 -0
- package/dist/admin/components/ScheduleIcons.js +29 -0
- package/dist/admin/components/ScheduleIcons.js.map +1 -0
- package/dist/admin/components/ScheduleIcons.mjs +26 -0
- package/dist/admin/components/ScheduleIcons.mjs.map +1 -0
- package/dist/admin/components/Widgets.js +5 -5
- package/dist/admin/components/Widgets.js.map +1 -1
- package/dist/admin/components/Widgets.mjs +6 -6
- package/dist/admin/components/Widgets.mjs.map +1 -1
- package/dist/admin/index.js +1 -2
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +1 -2
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/pages/ReleaseDetailsPage.js +784 -269
- package/dist/admin/pages/ReleaseDetailsPage.js.map +1 -1
- package/dist/admin/pages/ReleaseDetailsPage.mjs +789 -271
- package/dist/admin/pages/ReleaseDetailsPage.mjs.map +1 -1
- package/dist/admin/pages/ReleasesPage.js +583 -213
- package/dist/admin/pages/ReleasesPage.js.map +1 -1
- package/dist/admin/pages/ReleasesPage.mjs +587 -216
- package/dist/admin/pages/ReleasesPage.mjs.map +1 -1
- package/dist/admin/services/release.js +72 -112
- package/dist/admin/services/release.js.map +1 -1
- package/dist/admin/services/release.mjs +71 -113
- package/dist/admin/services/release.mjs.map +1 -1
- package/dist/admin/shared/constants.js +42 -0
- package/dist/admin/shared/constants.js.map +1 -0
- package/dist/admin/shared/constants.mjs +36 -0
- package/dist/admin/shared/constants.mjs.map +1 -0
- package/dist/admin/shared/license.js +20 -0
- package/dist/admin/shared/license.js.map +1 -0
- package/dist/admin/shared/license.mjs +17 -0
- package/dist/admin/shared/license.mjs.map +1 -0
- package/dist/admin/src/components/CreateReleaseFromSkippedDrawer.d.ts +23 -0
- package/dist/admin/src/components/EntryLinkButton.d.ts +27 -0
- package/dist/admin/src/components/EntryReasonDrawer.d.ts +52 -0
- package/dist/admin/src/components/ReleaseActionMenu.d.ts +3 -8
- package/dist/admin/src/components/ReleaseActionOptions.d.ts +17 -4
- package/dist/admin/src/components/ReleaseActionStatus.d.ts +75 -0
- package/dist/admin/src/components/ReleaseDrawer.d.ts +30 -0
- package/dist/admin/src/components/ReleaseStatusBadge.d.ts +37 -0
- package/dist/admin/src/components/ScheduleFilterInput.d.ts +7 -0
- package/dist/admin/src/components/ScheduleIcons.d.ts +14 -0
- package/dist/admin/src/pages/ReleasesPage.d.ts +1 -7
- package/dist/admin/src/pages/tests/mockReleaseDetailsPageData.d.ts +4 -0
- package/dist/admin/src/pages/tests/mockReleasesPageData.d.ts +37 -11
- package/dist/admin/src/services/release.d.ts +69 -38
- package/dist/admin/src/utils/fieldErrors.d.ts +12 -0
- package/dist/admin/src/utils/scheduleFilters.d.ts +23 -0
- package/dist/admin/src/utils/time.d.ts +23 -4
- package/dist/admin/translations/ar.json.js +111 -0
- package/dist/admin/translations/ar.json.js.map +1 -0
- package/dist/admin/translations/ar.json.mjs +109 -0
- package/dist/admin/translations/ar.json.mjs.map +1 -0
- package/dist/admin/translations/cs.json.js +0 -24
- package/dist/admin/translations/cs.json.js.map +1 -1
- package/dist/admin/translations/cs.json.mjs +0 -24
- package/dist/admin/translations/cs.json.mjs.map +1 -1
- package/dist/admin/translations/en.json.js +127 -25
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +127 -25
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/admin/translations/es.json.js +1 -25
- package/dist/admin/translations/es.json.js.map +1 -1
- package/dist/admin/translations/es.json.mjs +1 -25
- package/dist/admin/translations/es.json.mjs.map +1 -1
- package/dist/admin/translations/ja.json.js +0 -24
- package/dist/admin/translations/ja.json.js.map +1 -1
- package/dist/admin/translations/ja.json.mjs +0 -24
- package/dist/admin/translations/ja.json.mjs.map +1 -1
- package/dist/admin/translations/ko.json.js +0 -24
- package/dist/admin/translations/ko.json.js.map +1 -1
- package/dist/admin/translations/ko.json.mjs +0 -24
- package/dist/admin/translations/ko.json.mjs.map +1 -1
- package/dist/admin/translations/nl.json.js +0 -24
- package/dist/admin/translations/nl.json.js.map +1 -1
- package/dist/admin/translations/nl.json.mjs +0 -24
- package/dist/admin/translations/nl.json.mjs.map +1 -1
- package/dist/admin/translations/pl.json.js +0 -24
- package/dist/admin/translations/pl.json.js.map +1 -1
- package/dist/admin/translations/pl.json.mjs +0 -24
- package/dist/admin/translations/pl.json.mjs.map +1 -1
- package/dist/admin/translations/sk.json.js +0 -24
- package/dist/admin/translations/sk.json.js.map +1 -1
- package/dist/admin/translations/sk.json.mjs +0 -24
- package/dist/admin/translations/sk.json.mjs.map +1 -1
- package/dist/admin/translations/uk.json.js +1 -25
- package/dist/admin/translations/uk.json.js.map +1 -1
- package/dist/admin/translations/uk.json.mjs +1 -25
- package/dist/admin/translations/uk.json.mjs.map +1 -1
- package/dist/admin/utils/fieldErrors.js +100 -0
- package/dist/admin/utils/fieldErrors.js.map +1 -0
- package/dist/admin/utils/fieldErrors.mjs +97 -0
- package/dist/admin/utils/fieldErrors.mjs.map +1 -0
- package/dist/admin/utils/scheduleFilters.js +157 -0
- package/dist/admin/utils/scheduleFilters.js.map +1 -0
- package/dist/admin/utils/scheduleFilters.mjs +153 -0
- package/dist/admin/utils/scheduleFilters.mjs.map +1 -0
- package/dist/admin/utils/time.js +47 -1
- package/dist/admin/utils/time.js.map +1 -1
- package/dist/admin/utils/time.mjs +45 -2
- package/dist/admin/utils/time.mjs.map +1 -1
- package/dist/admin/validation/schemas.js +13 -7
- package/dist/admin/validation/schemas.js.map +1 -1
- package/dist/admin/validation/schemas.mjs +13 -7
- package/dist/admin/validation/schemas.mjs.map +1 -1
- package/dist/server/audit-logs.js +13 -20
- package/dist/server/audit-logs.js.map +1 -1
- package/dist/server/audit-logs.mjs +13 -20
- package/dist/server/audit-logs.mjs.map +1 -1
- package/dist/server/bootstrap.js +53 -39
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/server/bootstrap.mjs +56 -42
- package/dist/server/bootstrap.mjs.map +1 -1
- package/dist/server/constants.js +8 -0
- package/dist/server/constants.js.map +1 -1
- package/dist/server/constants.mjs +7 -1
- package/dist/server/constants.mjs.map +1 -1
- package/dist/server/content-types/release/schema.js +27 -5
- package/dist/server/content-types/release/schema.js.map +1 -1
- package/dist/server/content-types/release/schema.mjs +27 -5
- package/dist/server/content-types/release/schema.mjs.map +1 -1
- package/dist/server/content-types/release-action/schema.js +13 -2
- package/dist/server/content-types/release-action/schema.js.map +1 -1
- package/dist/server/content-types/release-action/schema.mjs +11 -0
- package/dist/server/content-types/release-action/schema.mjs.map +1 -1
- package/dist/server/controllers/release-action.js +8 -31
- package/dist/server/controllers/release-action.js.map +1 -1
- package/dist/server/controllers/release-action.mjs +8 -31
- package/dist/server/controllers/release-action.mjs.map +1 -1
- package/dist/server/controllers/release.js +63 -17
- package/dist/server/controllers/release.js.map +1 -1
- package/dist/server/controllers/release.mjs +64 -18
- package/dist/server/controllers/release.mjs.map +1 -1
- package/dist/server/controllers/validation/release-action.js +4 -0
- package/dist/server/controllers/validation/release-action.js.map +1 -1
- package/dist/server/controllers/validation/release-action.mjs +4 -0
- package/dist/server/controllers/validation/release-action.mjs.map +1 -1
- package/dist/server/controllers/validation/release.js +14 -2
- package/dist/server/controllers/validation/release.js.map +1 -1
- package/dist/server/controllers/validation/release.mjs +14 -3
- package/dist/server/controllers/validation/release.mjs.map +1 -1
- package/dist/server/entitlements.js +3 -1
- package/dist/server/entitlements.js.map +1 -1
- package/dist/server/entitlements.mjs +3 -1
- package/dist/server/entitlements.mjs.map +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/middlewares/documents.js +63 -86
- package/dist/server/middlewares/documents.js.map +1 -1
- package/dist/server/middlewares/documents.mjs +63 -86
- package/dist/server/middlewares/documents.mjs.map +1 -1
- package/dist/server/migrations/index.js +172 -111
- package/dist/server/migrations/index.js.map +1 -1
- package/dist/server/migrations/index.mjs +173 -115
- package/dist/server/migrations/index.mjs.map +1 -1
- package/dist/server/register.js +23 -2
- package/dist/server/register.js.map +1 -1
- package/dist/server/register.mjs +24 -3
- package/dist/server/register.mjs.map +1 -1
- package/dist/server/routes/release.js +19 -0
- package/dist/server/routes/release.js.map +1 -1
- package/dist/server/routes/release.mjs +19 -0
- package/dist/server/routes/release.mjs.map +1 -1
- package/dist/server/services/homepage.js +34 -19
- package/dist/server/services/homepage.js.map +1 -1
- package/dist/server/services/homepage.mjs +34 -19
- package/dist/server/services/homepage.mjs.map +1 -1
- package/dist/server/services/release-action.js +541 -182
- package/dist/server/services/release-action.js.map +1 -1
- package/dist/server/services/release-action.mjs +543 -184
- package/dist/server/services/release-action.mjs.map +1 -1
- package/dist/server/services/release-run.js +378 -0
- package/dist/server/services/release-run.js.map +1 -0
- package/dist/server/services/release-run.mjs +376 -0
- package/dist/server/services/release-run.mjs.map +1 -0
- package/dist/server/services/release.js +459 -327
- package/dist/server/services/release.js.map +1 -1
- package/dist/server/services/release.mjs +462 -330
- package/dist/server/services/release.mjs.map +1 -1
- package/dist/server/services/scheduling.js +174 -18
- package/dist/server/services/scheduling.js.map +1 -1
- package/dist/server/services/scheduling.mjs +175 -19
- package/dist/server/services/scheduling.mjs.map +1 -1
- package/dist/server/services/validation.js +2 -2
- package/dist/server/services/validation.js.map +1 -1
- package/dist/server/services/validation.mjs +2 -2
- package/dist/server/services/validation.mjs.map +1 -1
- package/dist/server/shared/constants.js +58 -0
- package/dist/server/shared/constants.js.map +1 -0
- package/dist/server/shared/constants.mjs +49 -0
- package/dist/server/shared/constants.mjs.map +1 -0
- package/dist/server/shared/license.js +20 -0
- package/dist/server/shared/license.js.map +1 -0
- package/dist/server/shared/license.mjs +17 -0
- package/dist/server/shared/license.mjs.map +1 -0
- package/dist/server/src/audit-logs.d.ts +13 -13
- package/dist/server/src/audit-logs.d.ts.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/constants.d.ts +2 -0
- package/dist/server/src/constants.d.ts.map +1 -1
- package/dist/server/src/content-types/index.d.ts +27 -1
- package/dist/server/src/content-types/index.d.ts.map +1 -1
- package/dist/server/src/content-types/release/index.d.ts +20 -1
- package/dist/server/src/content-types/release/index.d.ts.map +1 -1
- package/dist/server/src/content-types/release/schema.d.ts +20 -1
- package/dist/server/src/content-types/release/schema.d.ts.map +1 -1
- package/dist/server/src/content-types/release-action/index.d.ts +7 -0
- package/dist/server/src/content-types/release-action/index.d.ts.map +1 -1
- package/dist/server/src/content-types/release-action/schema.d.ts +7 -0
- package/dist/server/src/content-types/release-action/schema.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts +1 -0
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/release-action.d.ts.map +1 -1
- package/dist/server/src/controllers/release.d.ts +1 -0
- package/dist/server/src/controllers/release.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/release-action.d.ts +1 -0
- package/dist/server/src/controllers/validation/release-action.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/release.d.ts +1 -0
- package/dist/server/src/controllers/validation/release.d.ts.map +1 -1
- package/dist/server/src/entitlements.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +174 -1828
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/middlewares/documents.d.ts +8 -4
- package/dist/server/src/middlewares/documents.d.ts.map +1 -1
- package/dist/server/src/migrations/index.d.ts +29 -9
- package/dist/server/src/migrations/index.d.ts.map +1 -1
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/release.d.ts.map +1 -1
- package/dist/server/src/services/homepage.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +46 -1753
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/release-action.d.ts +31 -1734
- package/dist/server/src/services/release-action.d.ts.map +1 -1
- package/dist/server/src/services/release-run.d.ts +29 -0
- package/dist/server/src/services/release-run.d.ts.map +1 -0
- package/dist/server/src/services/release.d.ts +29 -20
- package/dist/server/src/services/release.d.ts.map +1 -1
- package/dist/server/src/services/scheduling.d.ts +11 -5
- package/dist/server/src/services/scheduling.d.ts.map +1 -1
- package/dist/server/src/services/validation.d.ts.map +1 -1
- package/dist/server/src/utils/action-filters.d.ts +28 -0
- package/dist/server/src/utils/action-filters.d.ts.map +1 -0
- package/dist/server/src/utils/entries.d.ts +18 -0
- package/dist/server/src/utils/entries.d.ts.map +1 -0
- package/dist/server/src/utils/index.d.ts +7 -46
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/server/src/utils/publish-order.d.ts +18 -0
- package/dist/server/src/utils/publish-order.d.ts.map +1 -0
- package/dist/server/src/utils/publishability.d.ts +78 -0
- package/dist/server/src/utils/publishability.d.ts.map +1 -0
- package/dist/server/src/utils/release-status.d.ts +14 -0
- package/dist/server/src/utils/release-status.d.ts.map +1 -0
- package/dist/server/src/utils/transactions.d.ts +12 -0
- package/dist/server/src/utils/transactions.d.ts.map +1 -0
- package/dist/server/utils/action-filters.js +92 -0
- package/dist/server/utils/action-filters.js.map +1 -0
- package/dist/server/utils/action-filters.mjs +88 -0
- package/dist/server/utils/action-filters.mjs.map +1 -0
- package/dist/server/utils/entries.js +54 -0
- package/dist/server/utils/entries.js.map +1 -0
- package/dist/server/utils/entries.mjs +51 -0
- package/dist/server/utils/entries.mjs.map +1 -0
- package/dist/server/utils/index.js +4 -211
- package/dist/server/utils/index.js.map +1 -1
- package/dist/server/utils/index.mjs +5 -206
- package/dist/server/utils/index.mjs.map +1 -1
- package/dist/server/utils/publish-order.js +95 -0
- package/dist/server/utils/publish-order.js.map +1 -0
- package/dist/server/utils/publish-order.mjs +93 -0
- package/dist/server/utils/publish-order.mjs.map +1 -0
- package/dist/server/utils/publishability.js +420 -0
- package/dist/server/utils/publishability.js.map +1 -0
- package/dist/server/utils/publishability.mjs +406 -0
- package/dist/server/utils/publishability.mjs.map +1 -0
- package/dist/server/utils/release-status.js +15 -0
- package/dist/server/utils/release-status.js.map +1 -0
- package/dist/server/utils/release-status.mjs +12 -0
- package/dist/server/utils/release-status.mjs.map +1 -0
- package/dist/server/utils/transactions.js +52 -0
- package/dist/server/utils/transactions.js.map +1 -0
- package/dist/server/utils/transactions.mjs +48 -0
- package/dist/server/utils/transactions.mjs.map +1 -0
- package/dist/shared/constants.d.ts +16 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/contracts/release-actions.d.ts +44 -5
- package/dist/shared/contracts/release-actions.d.ts.map +1 -1
- package/dist/shared/contracts/releases.d.ts +43 -4
- package/dist/shared/contracts/releases.d.ts.map +1 -1
- package/dist/shared/license.d.ts +10 -0
- package/dist/shared/license.d.ts.map +1 -0
- package/package.json +12 -14
- package/dist/admin/components/EntryValidationPopover.js +0 -310
- package/dist/admin/components/EntryValidationPopover.js.map +0 -1
- package/dist/admin/components/EntryValidationPopover.mjs +0 -308
- package/dist/admin/components/EntryValidationPopover.mjs.map +0 -1
- package/dist/admin/components/ReleaseModal.js +0 -332
- package/dist/admin/components/ReleaseModal.js.map +0 -1
- package/dist/admin/components/ReleaseModal.mjs +0 -310
- package/dist/admin/components/ReleaseModal.mjs.map +0 -1
- package/dist/admin/src/components/EntryValidationPopover.d.ts +0 -13
- package/dist/admin/src/components/ReleaseModal.d.ts +0 -17
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release-run.js","sources":["../../../server/src/services/release-run.ts"],"sourcesContent":["import { errors, quoteForLog } from '@strapi/utils';\n\nimport type { Core, Modules } from '@strapi/types';\nimport type { ParameterizedContext } from 'koa';\n\nimport { RELEASE_ACTION_MODEL_UID, RELEASE_MODEL_UID } from '../constants';\nimport { RELEASED_OUTCOME_BY_TYPE } from '../../../shared/constants';\nimport type { Release } from '../../../shared/contracts/releases';\nimport type {\n ReleaseAction,\n ReleaseActionOutcome,\n ReleaseActionReason,\n} from '../../../shared/contracts/release-actions';\nimport {\n getErrorName,\n getService,\n getPublishOrderForContentTypes,\n getPublishabilityForActions,\n getStageReason,\n isFailedBeforeUpgrade,\n isReleaseBlocked,\n isRunConflict,\n isStageError,\n toError,\n toErrorReason,\n toValidationReason,\n lockPlannedRelease,\n toEntryValidity,\n} from '../utils';\nimport type { PublishabilityOutcome } from '../utils';\n\nexport type PublishTrigger = 'manual' | 'scheduled';\n\n// Set by every run, so never null on what a run returns\nexport type RunTotals = {\n [K in 'totalPublishedEntries' | 'totalUnpublishedEntries' | 'totalSkippedEntries']: NonNullable<\n Release[K]\n >;\n};\n\nexport type RecordedRelease = Pick<\n Release,\n 'id' | 'name' | 'releasedAt' | 'status' | 'releaseCondition' | 'failureReason'\n> &\n RunTotals;\n\ntype RunOutcome = Exclude<ReleaseActionOutcome, 'skipped_missed'>;\n\ninterface RecordedOutcome {\n outcome: RunOutcome;\n reason: ReleaseActionReason | null;\n // Overrides the validity the outcome implies (an entry whose check threw wasn't publishable)\n isEntryValid?: boolean;\n}\n\n// Raised by the run for an unpublish of an entry that's gone (deleted after it was planned):\n// recorded like a publish of an entry that's gone. An entry already unpublished is released.\nconst ENTRY_NOT_FOUND_MESSAGE = 'Entry not found';\n\n// The validity a run stores with each outcome, so the two never contradict each other (an\n// outcome may override it: an entry whose check threw is stored as not valid)\nconst IS_ENTRY_VALID_BY_OUTCOME: Record<PublishabilityOutcome, false> &\n Record<Exclude<RunOutcome, PublishabilityOutcome>, true> = {\n published: true,\n unpublished: true,\n skipped_held: true,\n skipped_error: true,\n skipped_invalid: false,\n skipped_not_approved: false,\n};\n\n// Every entry the run didn't release counts as skipped\nconst getRunTotals = (entriesCount: number, outcomes: Outcomes): RunTotals => {\n let totalPublishedEntries = 0;\n let totalUnpublishedEntries = 0;\n for (const { outcome } of outcomes.values()) {\n if (outcome === 'published') {\n totalPublishedEntries += 1;\n } else if (outcome === 'unpublished') {\n totalUnpublishedEntries += 1;\n }\n }\n\n return {\n totalPublishedEntries,\n totalUnpublishedEntries,\n totalSkippedEntries: entriesCount - totalPublishedEntries - totalUnpublishedEntries,\n };\n};\n\nexport type LockedPublishResult =\n | { kind: 'released'; release: RecordedRelease }\n | { kind: 'failed'; error: Error; release: RecordedRelease }\n | { kind: 'rejected'; error: Error };\n\ntype Outcomes = Map<ReleaseAction['id'], RecordedOutcome>;\n\nconst getReleasedOutcome = (action: ReleaseAction): RecordedOutcome => ({\n outcome: RELEASED_OUTCOME_BY_TYPE[action.type],\n reason: null,\n});\n\n/**\n * A release's run: what it checks, releases and records, under the release lock. Internal to the\n * release service (not a registered service), which passes it its status recalculation.\n */\nexport const createReleaseRun = ({\n strapi,\n updateReleaseStatus,\n}: {\n strapi: Core.Strapi;\n updateReleaseStatus: (releaseId: Release['id']) => Promise<void>;\n}) => {\n /**\n * Content types in relation dependency order (a relation's target before its source), then\n * within each type publishes before unpublishes, each in the order they were added.\n */\n const getActionsInRunOrder = async (releaseId: Release['id']) => {\n const actions = (await strapi.db.query(RELEASE_ACTION_MODEL_UID).findMany({\n where: {\n release: {\n id: releaseId,\n },\n },\n orderBy: { id: 'asc' },\n })) as ReleaseAction[];\n\n const contentTypeOrder = new Map(\n getPublishOrderForContentTypes(\n actions.map((action) => action.contentType),\n { strapi }\n ).map((contentTypeUid, index) => [contentTypeUid, index])\n );\n const rank = (action: ReleaseAction) =>\n contentTypeOrder.get(action.contentType)! * 2 + (action.type === 'unpublish' ? 1 : 0);\n\n // A stable sort keeps the order they were added within each rank\n return [...actions].sort((a, b) => rank(a) - rank(b));\n };\n\n // With `server.webhooks.deduplicateReleaseWebhooks`, the entry is released in a request context\n // that marks it as part of the release, so webhooks subscribed to `releases.publish` skip its\n // entry event\n const runReleaseAction = async (\n releaseId: Release['id'],\n releaseAction: Modules.WebhookRunner.ReleaseAction,\n work: () => Promise<void>\n ) => {\n const deduplicateReleaseWebhooks =\n strapi.config.get<boolean>('server.webhooks.deduplicateReleaseWebhooks', false) === true;\n if (!deduplicateReleaseWebhooks) {\n return work();\n }\n\n const locale = strapi.localization.isLocalizedContentType(\n strapi.contentTypes[releaseAction.uid]\n )\n ? releaseAction.locale || (await strapi.localization.getDefaultLocale())\n : undefined;\n const context = strapi.requestContext.get();\n\n return strapi.requestContext.run(\n {\n ...context,\n request: context?.request ?? { url: '' },\n state: {\n ...context?.state,\n releaseId,\n releaseAction: { ...releaseAction, locale: locale ?? undefined },\n },\n } as ParameterizedContext,\n work\n );\n };\n\n const releaseEntry = async (releaseId: Release['id'], action: ReleaseAction) => {\n const params = { documentId: action.entryDocumentId, locale: action.locale };\n\n if (action.type === 'publish') {\n await runReleaseAction(\n releaseId,\n { uid: action.contentType, ...params, event: 'entry.publish' },\n async () => {\n // Publishes nothing, without an error, when the entry has no draft (deleted since the check)\n const { entries } = await strapi.documents(action.contentType).publish(params);\n if (entries.length === 0) {\n throw new errors.ValidationError(ENTRY_NOT_FOUND_MESSAGE);\n }\n }\n );\n } else {\n await runReleaseAction(\n releaseId,\n { uid: action.contentType, ...params, event: 'entry.unpublish' },\n async () => {\n const { entries } = await strapi.documents(action.contentType).unpublish(params);\n if (\n entries.length === 0 &&\n !(await strapi.documents(action.contentType).findOne({ ...params, status: 'draft' }))\n ) {\n throw new errors.ValidationError(ENTRY_NOT_FOUND_MESSAGE);\n }\n }\n );\n }\n };\n\n // A validation error raised by the run (e.g. a unique clash between two of its entries) keeps\n // its field errors, like one found by the check before the run. A publish review-workflows\n // refused on the stage is not approved, with the stages as the check records them (or, if they\n // can't be read, the error).\n const getErrorOutcome = async (\n action: ReleaseAction,\n error: unknown\n ): Promise<RecordedOutcome> => {\n if (isStageError(error)) {\n return {\n outcome: 'skipped_not_approved',\n reason: (await getStageReason(action, { strapi })) ?? toErrorReason(error),\n };\n }\n\n return error instanceof errors.ValidationError\n ? { outcome: 'skipped_invalid', reason: toValidationReason(error) }\n : { outcome: 'skipped_error', reason: toErrorReason(error) };\n };\n\n // Entries without a reason or validity override share one write per outcome; the others are\n // written per entry\n const recordOutcomes = async (outcomes: Outcomes) => {\n const idsByOutcome = new Map<RunOutcome, ReleaseAction['id'][]>();\n for (const [id, { outcome, reason, isEntryValid }] of outcomes) {\n if (reason || isEntryValid !== undefined) {\n await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({\n where: { id },\n data: {\n outcome,\n reason,\n isEntryValid: isEntryValid ?? IS_ENTRY_VALID_BY_OUTCOME[outcome],\n },\n });\n } else {\n const ids = idsByOutcome.get(outcome) ?? [];\n ids.push(id);\n idsByOutcome.set(outcome, ids);\n }\n }\n\n for (const [outcome, ids] of idsByOutcome) {\n // Clears any reason stored before the run: the run's record replaces it\n await strapi.db.query(RELEASE_ACTION_MODEL_UID).updateMany({\n where: { id: { $in: ids } },\n data: { outcome, reason: null, isEntryValid: IS_ENTRY_VALID_BY_OUTCOME[outcome] },\n });\n }\n };\n\n // An `all_or_nothing` run that releases nothing holds back every entry it didn't skip\n const holdUnrecorded = (actions: ReleaseAction[], outcomes: Outcomes) => {\n for (const action of actions) {\n if (!outcomes.has(action.id)) {\n outcomes.set(action.id, { outcome: 'skipped_held', reason: null });\n }\n }\n };\n\n // Each entry's outcome, then the release's status and totals: `releasedAt` freezes it\n const recordRun = async (\n releaseId: Release['id'],\n {\n status,\n totals,\n outcomes,\n }: {\n status: Extract<Release['status'], 'done' | 'partial' | 'failed'>;\n totals: RunTotals;\n outcomes: Outcomes;\n }\n ): Promise<RecordedRelease> => {\n await recordOutcomes(outcomes);\n\n return strapi.db.query(RELEASE_MODEL_UID).update({\n where: { id: releaseId },\n data: { status, releasedAt: new Date(), ...totals },\n });\n };\n\n // `allow_partial`: each entry in its own savepoint, so one that fails is skipped with its\n // published version restored, and the others still go out. Not after a run conflict (see\n // `isRunConflict`): the run fails with it and records nothing, the release stays planned.\n const releaseEachEntry = async (\n release: Pick<Release, 'id' | 'name'>,\n actions: ReleaseAction[],\n outcomes: Outcomes\n ) => {\n // Serialized: concurrent publishes of related documents can race on shared join tables\n for (const action of actions) {\n try {\n await strapi.db.savepoint(() => releaseEntry(release.id, action));\n outcomes.set(action.id, getReleasedOutcome(action));\n } catch (actionError) {\n if (isRunConflict(actionError)) {\n throw actionError;\n }\n outcomes.set(action.id, await getErrorOutcome(action, actionError));\n strapi.log.warn(\n `[Content Releases] Release ${quoteForLog(\n release.name\n )}: skipped an entry that failed to ${action.type} (${getErrorName(actionError)})`\n );\n }\n }\n };\n\n // `all_or_nothing`: one savepoint for every entry, so the first error rolls back the ones\n // before it. Returns that error, unless it's a run conflict, which fails the run.\n const releaseAllEntries = async (\n releaseId: Release['id'],\n actions: ReleaseAction[],\n outcomes: Outcomes\n ): Promise<{ error: unknown } | null> => {\n let inFlight: ReleaseAction | undefined;\n try {\n await strapi.db.savepoint(async () => {\n for (const action of actions) {\n inFlight = action;\n await releaseEntry(releaseId, action);\n inFlight = undefined;\n }\n });\n } catch (error) {\n if (isRunConflict(error)) {\n throw error;\n }\n if (inFlight) {\n outcomes.set(inFlight.id, await getErrorOutcome(inFlight, error));\n }\n return { error };\n }\n\n for (const action of actions) {\n outcomes.set(action.id, getReleasedOutcome(action));\n }\n return null;\n };\n\n // A run, in the transaction that holds the release lock\n const runLocked = async (\n releaseId: Release['id'],\n trigger: PublishTrigger\n ): Promise<LockedPublishResult> => {\n const release = await lockPlannedRelease(releaseId, ['name', 'status', 'releaseCondition'], {\n strapi,\n });\n\n // Not frozen by the sweep yet\n if (isFailedBeforeUpgrade(release)) {\n throw new errors.ValidationError('Release failed to publish');\n }\n\n strapi.log.info(`[Content Releases] Starting to publish release ${quoteForLog(release.name)}`);\n\n const allowPartial = release.releaseCondition === 'allow_partial';\n const actions = await getActionsInRunOrder(releaseId);\n const outcomes: Outcomes = new Map();\n\n const fail = async (error: unknown): Promise<LockedPublishResult> => ({\n kind: 'failed',\n error: toError(error),\n release: await recordRun(releaseId, {\n status: 'failed',\n totals: getRunTotals(actions.length, outcomes),\n outcomes,\n }),\n });\n\n // Checked before anything is written: a publish that fails validation halfway can already\n // have removed the entry's published version\n const checks = await getPublishabilityForActions(actions, { strapi });\n // Not publishable: invalid or not approved (the entry's own error), or its check threw (stored\n // as not publishable, whatever the error class: a thrown check isn't a validation result)\n const entryErrors: Error[] = [];\n const checkErrors: Error[] = [];\n for (const [id, check] of checks) {\n if (check instanceof Error) {\n outcomes.set(id, {\n outcome: 'skipped_error',\n reason: toErrorReason(check),\n isEntryValid: false,\n });\n checkErrors.push(check);\n } else if (!check.publishable) {\n outcomes.set(id, { outcome: check.outcome, reason: check.reason });\n entryErrors.push(check.error);\n }\n }\n\n if (\n isReleaseBlocked(release.releaseCondition, {\n total: actions.length,\n notPublishable: entryErrors.length + checkErrors.length,\n })\n ) {\n if (trigger === 'manual') {\n // Not a run: each entry's check is stored so the release reads as checked, then the\n // publish is refused. A check that threw (e.g. a transient read error) found nothing about\n // its entry: what was stored before stays.\n await getService('release-action', { strapi }).storePublishValidities(\n new Map(\n [...checks].flatMap(([id, check]) =>\n check instanceof Error ? [] : [[id, toEntryValidity(check)] as const]\n )\n )\n );\n await updateReleaseStatus(releaseId);\n\n // Refused like any blocked release (400), on an entry's own error first. What stopped a\n // check is named, never quoted: its message can carry row contents.\n return {\n kind: 'rejected',\n error:\n entryErrors[0] ??\n new errors.ValidationError(\n `An entry couldn't be checked (${getErrorName(checkErrors[0])})`\n ),\n };\n }\n\n if (!allowPartial) {\n holdUnrecorded(actions, outcomes);\n }\n\n return fail(\n allowPartial\n ? new errors.ValidationError('No entries were published')\n : (entryErrors[0] ?? checkErrors[0])\n );\n }\n\n const releasable = actions.filter((action) => !outcomes.has(action.id));\n\n if (allowPartial) {\n await releaseEachEntry({ id: releaseId, name: release.name }, releasable, outcomes);\n } else {\n const failure = await releaseAllEntries(releaseId, releasable, outcomes);\n if (failure) {\n holdUnrecorded(actions, outcomes);\n return fail(failure.error);\n }\n }\n\n const totals = getRunTotals(actions.length, outcomes);\n\n if (actions.length > 0 && totals.totalSkippedEntries === actions.length) {\n return fail(new errors.ValidationError('No entries were published'));\n }\n\n return {\n kind: 'released',\n release: await recordRun(releaseId, {\n status: totals.totalSkippedEntries === 0 ? 'done' : 'partial',\n totals,\n outcomes,\n }),\n };\n };\n\n return { runLocked };\n};\n"],"names":["ENTRY_NOT_FOUND_MESSAGE","IS_ENTRY_VALID_BY_OUTCOME","published","unpublished","skipped_held","skipped_error","skipped_invalid","skipped_not_approved","getRunTotals","entriesCount","outcomes","totalPublishedEntries","totalUnpublishedEntries","outcome","values","totalSkippedEntries","getReleasedOutcome","action","RELEASED_OUTCOME_BY_TYPE","type","reason","createReleaseRun","strapi","updateReleaseStatus","getActionsInRunOrder","releaseId","actions","db","query","RELEASE_ACTION_MODEL_UID","findMany","where","release","id","orderBy","contentTypeOrder","Map","getPublishOrderForContentTypes","map","contentType","contentTypeUid","index","rank","get","sort","a","b","runReleaseAction","releaseAction","work","deduplicateReleaseWebhooks","config","locale","localization","isLocalizedContentType","contentTypes","uid","getDefaultLocale","undefined","context","requestContext","run","request","url","state","releaseEntry","params","documentId","entryDocumentId","event","entries","documents","publish","length","errors","ValidationError","unpublish","findOne","status","getErrorOutcome","error","isStageError","getStageReason","toErrorReason","toValidationReason","recordOutcomes","idsByOutcome","isEntryValid","update","data","ids","push","set","updateMany","$in","holdUnrecorded","has","recordRun","totals","RELEASE_MODEL_UID","releasedAt","Date","releaseEachEntry","savepoint","actionError","isRunConflict","log","warn","quoteForLog","name","getErrorName","releaseAllEntries","inFlight","runLocked","trigger","lockPlannedRelease","isFailedBeforeUpgrade","info","allowPartial","releaseCondition","fail","kind","toError","checks","getPublishabilityForActions","entryErrors","checkErrors","check","Error","publishable","isReleaseBlocked","total","notPublishable","getService","storePublishValidities","flatMap","toEntryValidity","releasable","filter","failure"],"mappings":";;;;;;;;;;;AAuDA;AACA;AACA,MAAMA,uBAAAA,GAA0B,iBAAA;AAEhC;AACA;AACA,MAAMC,yBAAAA,GACuD;IAC3DC,SAAAA,EAAW,IAAA;IACXC,WAAAA,EAAa,IAAA;IACbC,YAAAA,EAAc,IAAA;IACdC,aAAAA,EAAe,IAAA;IACfC,eAAAA,EAAiB,KAAA;IACjBC,oBAAAA,EAAsB;AACxB,CAAA;AAEA;AACA,MAAMC,YAAAA,GAAe,CAACC,YAAAA,EAAsBC,QAAAA,GAAAA;AAC1C,IAAA,IAAIC,qBAAAA,GAAwB,CAAA;AAC5B,IAAA,IAAIC,uBAAAA,GAA0B,CAAA;AAC9B,IAAA,KAAK,MAAM,EAAEC,OAAO,EAAE,IAAIH,QAAAA,CAASI,MAAM,EAAA,CAAI;AAC3C,QAAA,IAAID,YAAY,WAAA,EAAa;YAC3BF,qBAAAA,IAAyB,CAAA;QAC3B,CAAA,MAAO,IAAIE,YAAY,aAAA,EAAe;YACpCD,uBAAAA,IAA2B,CAAA;AAC7B,QAAA;AACF,IAAA;IAEA,OAAO;AACLD,QAAAA,qBAAAA;AACAC,QAAAA,uBAAAA;AACAG,QAAAA,mBAAAA,EAAqBN,eAAeE,qBAAAA,GAAwBC;AAC9D,KAAA;AACF,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AA;AACrB;;;;"}
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { errors, quoteForLog } from '@strapi/utils';
|
|
2
|
+
import { RELEASE_ACTION_MODEL_UID, RELEASE_MODEL_UID } from '../constants.mjs';
|
|
3
|
+
import { RELEASED_OUTCOME_BY_TYPE } from '../shared/constants.mjs';
|
|
4
|
+
import { getService } from '../utils/index.mjs';
|
|
5
|
+
import { lockPlannedRelease } from '../utils/transactions.mjs';
|
|
6
|
+
import { isFailedBeforeUpgrade, isReleaseBlocked } from '../utils/release-status.mjs';
|
|
7
|
+
import { getPublishabilityForActions, toErrorReason, toEntryValidity, getErrorName, toError, isRunConflict, isStageError, getStageReason, toValidationReason } from '../utils/publishability.mjs';
|
|
8
|
+
import { getPublishOrderForContentTypes } from '../utils/publish-order.mjs';
|
|
9
|
+
|
|
10
|
+
// Raised by the run for an unpublish of an entry that's gone (deleted after it was planned):
|
|
11
|
+
// recorded like a publish of an entry that's gone. An entry already unpublished is released.
|
|
12
|
+
const ENTRY_NOT_FOUND_MESSAGE = 'Entry not found';
|
|
13
|
+
// The validity a run stores with each outcome, so the two never contradict each other (an
|
|
14
|
+
// outcome may override it: an entry whose check threw is stored as not valid)
|
|
15
|
+
const IS_ENTRY_VALID_BY_OUTCOME = {
|
|
16
|
+
published: true,
|
|
17
|
+
unpublished: true,
|
|
18
|
+
skipped_held: true,
|
|
19
|
+
skipped_error: true,
|
|
20
|
+
skipped_invalid: false,
|
|
21
|
+
skipped_not_approved: false
|
|
22
|
+
};
|
|
23
|
+
// Every entry the run didn't release counts as skipped
|
|
24
|
+
const getRunTotals = (entriesCount, outcomes)=>{
|
|
25
|
+
let totalPublishedEntries = 0;
|
|
26
|
+
let totalUnpublishedEntries = 0;
|
|
27
|
+
for (const { outcome } of outcomes.values()){
|
|
28
|
+
if (outcome === 'published') {
|
|
29
|
+
totalPublishedEntries += 1;
|
|
30
|
+
} else if (outcome === 'unpublished') {
|
|
31
|
+
totalUnpublishedEntries += 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
totalPublishedEntries,
|
|
36
|
+
totalUnpublishedEntries,
|
|
37
|
+
totalSkippedEntries: entriesCount - totalPublishedEntries - totalUnpublishedEntries
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const getReleasedOutcome = (action)=>({
|
|
41
|
+
outcome: RELEASED_OUTCOME_BY_TYPE[action.type],
|
|
42
|
+
reason: null
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* A release's run: what it checks, releases and records, under the release lock. Internal to the
|
|
46
|
+
* release service (not a registered service), which passes it its status recalculation.
|
|
47
|
+
*/ const createReleaseRun = ({ strapi, updateReleaseStatus })=>{
|
|
48
|
+
/**
|
|
49
|
+
* Content types in relation dependency order (a relation's target before its source), then
|
|
50
|
+
* within each type publishes before unpublishes, each in the order they were added.
|
|
51
|
+
*/ const getActionsInRunOrder = async (releaseId)=>{
|
|
52
|
+
const actions = await strapi.db.query(RELEASE_ACTION_MODEL_UID).findMany({
|
|
53
|
+
where: {
|
|
54
|
+
release: {
|
|
55
|
+
id: releaseId
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
orderBy: {
|
|
59
|
+
id: 'asc'
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const contentTypeOrder = new Map(getPublishOrderForContentTypes(actions.map((action)=>action.contentType), {
|
|
63
|
+
strapi
|
|
64
|
+
}).map((contentTypeUid, index)=>[
|
|
65
|
+
contentTypeUid,
|
|
66
|
+
index
|
|
67
|
+
]));
|
|
68
|
+
const rank = (action)=>contentTypeOrder.get(action.contentType) * 2 + (action.type === 'unpublish' ? 1 : 0);
|
|
69
|
+
// A stable sort keeps the order they were added within each rank
|
|
70
|
+
return [
|
|
71
|
+
...actions
|
|
72
|
+
].sort((a, b)=>rank(a) - rank(b));
|
|
73
|
+
};
|
|
74
|
+
// With `server.webhooks.deduplicateReleaseWebhooks`, the entry is released in a request context
|
|
75
|
+
// that marks it as part of the release, so webhooks subscribed to `releases.publish` skip its
|
|
76
|
+
// entry event
|
|
77
|
+
const runReleaseAction = async (releaseId, releaseAction, work)=>{
|
|
78
|
+
const deduplicateReleaseWebhooks = strapi.config.get('server.webhooks.deduplicateReleaseWebhooks', false) === true;
|
|
79
|
+
if (!deduplicateReleaseWebhooks) {
|
|
80
|
+
return work();
|
|
81
|
+
}
|
|
82
|
+
const locale = strapi.localization.isLocalizedContentType(strapi.contentTypes[releaseAction.uid]) ? releaseAction.locale || await strapi.localization.getDefaultLocale() : undefined;
|
|
83
|
+
const context = strapi.requestContext.get();
|
|
84
|
+
return strapi.requestContext.run({
|
|
85
|
+
...context,
|
|
86
|
+
request: context?.request ?? {
|
|
87
|
+
url: ''
|
|
88
|
+
},
|
|
89
|
+
state: {
|
|
90
|
+
...context?.state,
|
|
91
|
+
releaseId,
|
|
92
|
+
releaseAction: {
|
|
93
|
+
...releaseAction,
|
|
94
|
+
locale: locale ?? undefined
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, work);
|
|
98
|
+
};
|
|
99
|
+
const releaseEntry = async (releaseId, action)=>{
|
|
100
|
+
const params = {
|
|
101
|
+
documentId: action.entryDocumentId,
|
|
102
|
+
locale: action.locale
|
|
103
|
+
};
|
|
104
|
+
if (action.type === 'publish') {
|
|
105
|
+
await runReleaseAction(releaseId, {
|
|
106
|
+
uid: action.contentType,
|
|
107
|
+
...params,
|
|
108
|
+
event: 'entry.publish'
|
|
109
|
+
}, async ()=>{
|
|
110
|
+
// Publishes nothing, without an error, when the entry has no draft (deleted since the check)
|
|
111
|
+
const { entries } = await strapi.documents(action.contentType).publish(params);
|
|
112
|
+
if (entries.length === 0) {
|
|
113
|
+
throw new errors.ValidationError(ENTRY_NOT_FOUND_MESSAGE);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
} else {
|
|
117
|
+
await runReleaseAction(releaseId, {
|
|
118
|
+
uid: action.contentType,
|
|
119
|
+
...params,
|
|
120
|
+
event: 'entry.unpublish'
|
|
121
|
+
}, async ()=>{
|
|
122
|
+
const { entries } = await strapi.documents(action.contentType).unpublish(params);
|
|
123
|
+
if (entries.length === 0 && !await strapi.documents(action.contentType).findOne({
|
|
124
|
+
...params,
|
|
125
|
+
status: 'draft'
|
|
126
|
+
})) {
|
|
127
|
+
throw new errors.ValidationError(ENTRY_NOT_FOUND_MESSAGE);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
// A validation error raised by the run (e.g. a unique clash between two of its entries) keeps
|
|
133
|
+
// its field errors, like one found by the check before the run. A publish review-workflows
|
|
134
|
+
// refused on the stage is not approved, with the stages as the check records them (or, if they
|
|
135
|
+
// can't be read, the error).
|
|
136
|
+
const getErrorOutcome = async (action, error)=>{
|
|
137
|
+
if (isStageError(error)) {
|
|
138
|
+
return {
|
|
139
|
+
outcome: 'skipped_not_approved',
|
|
140
|
+
reason: await getStageReason(action, {
|
|
141
|
+
strapi
|
|
142
|
+
}) ?? toErrorReason(error)
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
return error instanceof errors.ValidationError ? {
|
|
146
|
+
outcome: 'skipped_invalid',
|
|
147
|
+
reason: toValidationReason(error)
|
|
148
|
+
} : {
|
|
149
|
+
outcome: 'skipped_error',
|
|
150
|
+
reason: toErrorReason(error)
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
// Entries without a reason or validity override share one write per outcome; the others are
|
|
154
|
+
// written per entry
|
|
155
|
+
const recordOutcomes = async (outcomes)=>{
|
|
156
|
+
const idsByOutcome = new Map();
|
|
157
|
+
for (const [id, { outcome, reason, isEntryValid }] of outcomes){
|
|
158
|
+
if (reason || isEntryValid !== undefined) {
|
|
159
|
+
await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({
|
|
160
|
+
where: {
|
|
161
|
+
id
|
|
162
|
+
},
|
|
163
|
+
data: {
|
|
164
|
+
outcome,
|
|
165
|
+
reason,
|
|
166
|
+
isEntryValid: isEntryValid ?? IS_ENTRY_VALID_BY_OUTCOME[outcome]
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
} else {
|
|
170
|
+
const ids = idsByOutcome.get(outcome) ?? [];
|
|
171
|
+
ids.push(id);
|
|
172
|
+
idsByOutcome.set(outcome, ids);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
for (const [outcome, ids] of idsByOutcome){
|
|
176
|
+
// Clears any reason stored before the run: the run's record replaces it
|
|
177
|
+
await strapi.db.query(RELEASE_ACTION_MODEL_UID).updateMany({
|
|
178
|
+
where: {
|
|
179
|
+
id: {
|
|
180
|
+
$in: ids
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
data: {
|
|
184
|
+
outcome,
|
|
185
|
+
reason: null,
|
|
186
|
+
isEntryValid: IS_ENTRY_VALID_BY_OUTCOME[outcome]
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
// An `all_or_nothing` run that releases nothing holds back every entry it didn't skip
|
|
192
|
+
const holdUnrecorded = (actions, outcomes)=>{
|
|
193
|
+
for (const action of actions){
|
|
194
|
+
if (!outcomes.has(action.id)) {
|
|
195
|
+
outcomes.set(action.id, {
|
|
196
|
+
outcome: 'skipped_held',
|
|
197
|
+
reason: null
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
// Each entry's outcome, then the release's status and totals: `releasedAt` freezes it
|
|
203
|
+
const recordRun = async (releaseId, { status, totals, outcomes })=>{
|
|
204
|
+
await recordOutcomes(outcomes);
|
|
205
|
+
return strapi.db.query(RELEASE_MODEL_UID).update({
|
|
206
|
+
where: {
|
|
207
|
+
id: releaseId
|
|
208
|
+
},
|
|
209
|
+
data: {
|
|
210
|
+
status,
|
|
211
|
+
releasedAt: new Date(),
|
|
212
|
+
...totals
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
// `allow_partial`: each entry in its own savepoint, so one that fails is skipped with its
|
|
217
|
+
// published version restored, and the others still go out. Not after a run conflict (see
|
|
218
|
+
// `isRunConflict`): the run fails with it and records nothing, the release stays planned.
|
|
219
|
+
const releaseEachEntry = async (release, actions, outcomes)=>{
|
|
220
|
+
// Serialized: concurrent publishes of related documents can race on shared join tables
|
|
221
|
+
for (const action of actions){
|
|
222
|
+
try {
|
|
223
|
+
await strapi.db.savepoint(()=>releaseEntry(release.id, action));
|
|
224
|
+
outcomes.set(action.id, getReleasedOutcome(action));
|
|
225
|
+
} catch (actionError) {
|
|
226
|
+
if (isRunConflict(actionError)) {
|
|
227
|
+
throw actionError;
|
|
228
|
+
}
|
|
229
|
+
outcomes.set(action.id, await getErrorOutcome(action, actionError));
|
|
230
|
+
strapi.log.warn(`[Content Releases] Release ${quoteForLog(release.name)}: skipped an entry that failed to ${action.type} (${getErrorName(actionError)})`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
// `all_or_nothing`: one savepoint for every entry, so the first error rolls back the ones
|
|
235
|
+
// before it. Returns that error, unless it's a run conflict, which fails the run.
|
|
236
|
+
const releaseAllEntries = async (releaseId, actions, outcomes)=>{
|
|
237
|
+
let inFlight;
|
|
238
|
+
try {
|
|
239
|
+
await strapi.db.savepoint(async ()=>{
|
|
240
|
+
for (const action of actions){
|
|
241
|
+
inFlight = action;
|
|
242
|
+
await releaseEntry(releaseId, action);
|
|
243
|
+
inFlight = undefined;
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
} catch (error) {
|
|
247
|
+
if (isRunConflict(error)) {
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
if (inFlight) {
|
|
251
|
+
outcomes.set(inFlight.id, await getErrorOutcome(inFlight, error));
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
error
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
for (const action of actions){
|
|
258
|
+
outcomes.set(action.id, getReleasedOutcome(action));
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
};
|
|
262
|
+
// A run, in the transaction that holds the release lock
|
|
263
|
+
const runLocked = async (releaseId, trigger)=>{
|
|
264
|
+
const release = await lockPlannedRelease(releaseId, [
|
|
265
|
+
'name',
|
|
266
|
+
'status',
|
|
267
|
+
'releaseCondition'
|
|
268
|
+
], {
|
|
269
|
+
strapi
|
|
270
|
+
});
|
|
271
|
+
// Not frozen by the sweep yet
|
|
272
|
+
if (isFailedBeforeUpgrade(release)) {
|
|
273
|
+
throw new errors.ValidationError('Release failed to publish');
|
|
274
|
+
}
|
|
275
|
+
strapi.log.info(`[Content Releases] Starting to publish release ${quoteForLog(release.name)}`);
|
|
276
|
+
const allowPartial = release.releaseCondition === 'allow_partial';
|
|
277
|
+
const actions = await getActionsInRunOrder(releaseId);
|
|
278
|
+
const outcomes = new Map();
|
|
279
|
+
const fail = async (error)=>({
|
|
280
|
+
kind: 'failed',
|
|
281
|
+
error: toError(error),
|
|
282
|
+
release: await recordRun(releaseId, {
|
|
283
|
+
status: 'failed',
|
|
284
|
+
totals: getRunTotals(actions.length, outcomes),
|
|
285
|
+
outcomes
|
|
286
|
+
})
|
|
287
|
+
});
|
|
288
|
+
// Checked before anything is written: a publish that fails validation halfway can already
|
|
289
|
+
// have removed the entry's published version
|
|
290
|
+
const checks = await getPublishabilityForActions(actions, {
|
|
291
|
+
strapi
|
|
292
|
+
});
|
|
293
|
+
// Not publishable: invalid or not approved (the entry's own error), or its check threw (stored
|
|
294
|
+
// as not publishable, whatever the error class: a thrown check isn't a validation result)
|
|
295
|
+
const entryErrors = [];
|
|
296
|
+
const checkErrors = [];
|
|
297
|
+
for (const [id, check] of checks){
|
|
298
|
+
if (check instanceof Error) {
|
|
299
|
+
outcomes.set(id, {
|
|
300
|
+
outcome: 'skipped_error',
|
|
301
|
+
reason: toErrorReason(check),
|
|
302
|
+
isEntryValid: false
|
|
303
|
+
});
|
|
304
|
+
checkErrors.push(check);
|
|
305
|
+
} else if (!check.publishable) {
|
|
306
|
+
outcomes.set(id, {
|
|
307
|
+
outcome: check.outcome,
|
|
308
|
+
reason: check.reason
|
|
309
|
+
});
|
|
310
|
+
entryErrors.push(check.error);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (isReleaseBlocked(release.releaseCondition, {
|
|
314
|
+
total: actions.length,
|
|
315
|
+
notPublishable: entryErrors.length + checkErrors.length
|
|
316
|
+
})) {
|
|
317
|
+
if (trigger === 'manual') {
|
|
318
|
+
// Not a run: each entry's check is stored so the release reads as checked, then the
|
|
319
|
+
// publish is refused. A check that threw (e.g. a transient read error) found nothing about
|
|
320
|
+
// its entry: what was stored before stays.
|
|
321
|
+
await getService('release-action', {
|
|
322
|
+
strapi
|
|
323
|
+
}).storePublishValidities(new Map([
|
|
324
|
+
...checks
|
|
325
|
+
].flatMap(([id, check])=>check instanceof Error ? [] : [
|
|
326
|
+
[
|
|
327
|
+
id,
|
|
328
|
+
toEntryValidity(check)
|
|
329
|
+
]
|
|
330
|
+
])));
|
|
331
|
+
await updateReleaseStatus(releaseId);
|
|
332
|
+
// Refused like any blocked release (400), on an entry's own error first. What stopped a
|
|
333
|
+
// check is named, never quoted: its message can carry row contents.
|
|
334
|
+
return {
|
|
335
|
+
kind: 'rejected',
|
|
336
|
+
error: entryErrors[0] ?? new errors.ValidationError(`An entry couldn't be checked (${getErrorName(checkErrors[0])})`)
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
if (!allowPartial) {
|
|
340
|
+
holdUnrecorded(actions, outcomes);
|
|
341
|
+
}
|
|
342
|
+
return fail(allowPartial ? new errors.ValidationError('No entries were published') : entryErrors[0] ?? checkErrors[0]);
|
|
343
|
+
}
|
|
344
|
+
const releasable = actions.filter((action)=>!outcomes.has(action.id));
|
|
345
|
+
if (allowPartial) {
|
|
346
|
+
await releaseEachEntry({
|
|
347
|
+
id: releaseId,
|
|
348
|
+
name: release.name
|
|
349
|
+
}, releasable, outcomes);
|
|
350
|
+
} else {
|
|
351
|
+
const failure = await releaseAllEntries(releaseId, releasable, outcomes);
|
|
352
|
+
if (failure) {
|
|
353
|
+
holdUnrecorded(actions, outcomes);
|
|
354
|
+
return fail(failure.error);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
const totals = getRunTotals(actions.length, outcomes);
|
|
358
|
+
if (actions.length > 0 && totals.totalSkippedEntries === actions.length) {
|
|
359
|
+
return fail(new errors.ValidationError('No entries were published'));
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
kind: 'released',
|
|
363
|
+
release: await recordRun(releaseId, {
|
|
364
|
+
status: totals.totalSkippedEntries === 0 ? 'done' : 'partial',
|
|
365
|
+
totals,
|
|
366
|
+
outcomes
|
|
367
|
+
})
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
return {
|
|
371
|
+
runLocked
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
export { createReleaseRun };
|
|
376
|
+
//# sourceMappingURL=release-run.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release-run.mjs","sources":["../../../server/src/services/release-run.ts"],"sourcesContent":["import { errors, quoteForLog } from '@strapi/utils';\n\nimport type { Core, Modules } from '@strapi/types';\nimport type { ParameterizedContext } from 'koa';\n\nimport { RELEASE_ACTION_MODEL_UID, RELEASE_MODEL_UID } from '../constants';\nimport { RELEASED_OUTCOME_BY_TYPE } from '../../../shared/constants';\nimport type { Release } from '../../../shared/contracts/releases';\nimport type {\n ReleaseAction,\n ReleaseActionOutcome,\n ReleaseActionReason,\n} from '../../../shared/contracts/release-actions';\nimport {\n getErrorName,\n getService,\n getPublishOrderForContentTypes,\n getPublishabilityForActions,\n getStageReason,\n isFailedBeforeUpgrade,\n isReleaseBlocked,\n isRunConflict,\n isStageError,\n toError,\n toErrorReason,\n toValidationReason,\n lockPlannedRelease,\n toEntryValidity,\n} from '../utils';\nimport type { PublishabilityOutcome } from '../utils';\n\nexport type PublishTrigger = 'manual' | 'scheduled';\n\n// Set by every run, so never null on what a run returns\nexport type RunTotals = {\n [K in 'totalPublishedEntries' | 'totalUnpublishedEntries' | 'totalSkippedEntries']: NonNullable<\n Release[K]\n >;\n};\n\nexport type RecordedRelease = Pick<\n Release,\n 'id' | 'name' | 'releasedAt' | 'status' | 'releaseCondition' | 'failureReason'\n> &\n RunTotals;\n\ntype RunOutcome = Exclude<ReleaseActionOutcome, 'skipped_missed'>;\n\ninterface RecordedOutcome {\n outcome: RunOutcome;\n reason: ReleaseActionReason | null;\n // Overrides the validity the outcome implies (an entry whose check threw wasn't publishable)\n isEntryValid?: boolean;\n}\n\n// Raised by the run for an unpublish of an entry that's gone (deleted after it was planned):\n// recorded like a publish of an entry that's gone. An entry already unpublished is released.\nconst ENTRY_NOT_FOUND_MESSAGE = 'Entry not found';\n\n// The validity a run stores with each outcome, so the two never contradict each other (an\n// outcome may override it: an entry whose check threw is stored as not valid)\nconst IS_ENTRY_VALID_BY_OUTCOME: Record<PublishabilityOutcome, false> &\n Record<Exclude<RunOutcome, PublishabilityOutcome>, true> = {\n published: true,\n unpublished: true,\n skipped_held: true,\n skipped_error: true,\n skipped_invalid: false,\n skipped_not_approved: false,\n};\n\n// Every entry the run didn't release counts as skipped\nconst getRunTotals = (entriesCount: number, outcomes: Outcomes): RunTotals => {\n let totalPublishedEntries = 0;\n let totalUnpublishedEntries = 0;\n for (const { outcome } of outcomes.values()) {\n if (outcome === 'published') {\n totalPublishedEntries += 1;\n } else if (outcome === 'unpublished') {\n totalUnpublishedEntries += 1;\n }\n }\n\n return {\n totalPublishedEntries,\n totalUnpublishedEntries,\n totalSkippedEntries: entriesCount - totalPublishedEntries - totalUnpublishedEntries,\n };\n};\n\nexport type LockedPublishResult =\n | { kind: 'released'; release: RecordedRelease }\n | { kind: 'failed'; error: Error; release: RecordedRelease }\n | { kind: 'rejected'; error: Error };\n\ntype Outcomes = Map<ReleaseAction['id'], RecordedOutcome>;\n\nconst getReleasedOutcome = (action: ReleaseAction): RecordedOutcome => ({\n outcome: RELEASED_OUTCOME_BY_TYPE[action.type],\n reason: null,\n});\n\n/**\n * A release's run: what it checks, releases and records, under the release lock. Internal to the\n * release service (not a registered service), which passes it its status recalculation.\n */\nexport const createReleaseRun = ({\n strapi,\n updateReleaseStatus,\n}: {\n strapi: Core.Strapi;\n updateReleaseStatus: (releaseId: Release['id']) => Promise<void>;\n}) => {\n /**\n * Content types in relation dependency order (a relation's target before its source), then\n * within each type publishes before unpublishes, each in the order they were added.\n */\n const getActionsInRunOrder = async (releaseId: Release['id']) => {\n const actions = (await strapi.db.query(RELEASE_ACTION_MODEL_UID).findMany({\n where: {\n release: {\n id: releaseId,\n },\n },\n orderBy: { id: 'asc' },\n })) as ReleaseAction[];\n\n const contentTypeOrder = new Map(\n getPublishOrderForContentTypes(\n actions.map((action) => action.contentType),\n { strapi }\n ).map((contentTypeUid, index) => [contentTypeUid, index])\n );\n const rank = (action: ReleaseAction) =>\n contentTypeOrder.get(action.contentType)! * 2 + (action.type === 'unpublish' ? 1 : 0);\n\n // A stable sort keeps the order they were added within each rank\n return [...actions].sort((a, b) => rank(a) - rank(b));\n };\n\n // With `server.webhooks.deduplicateReleaseWebhooks`, the entry is released in a request context\n // that marks it as part of the release, so webhooks subscribed to `releases.publish` skip its\n // entry event\n const runReleaseAction = async (\n releaseId: Release['id'],\n releaseAction: Modules.WebhookRunner.ReleaseAction,\n work: () => Promise<void>\n ) => {\n const deduplicateReleaseWebhooks =\n strapi.config.get<boolean>('server.webhooks.deduplicateReleaseWebhooks', false) === true;\n if (!deduplicateReleaseWebhooks) {\n return work();\n }\n\n const locale = strapi.localization.isLocalizedContentType(\n strapi.contentTypes[releaseAction.uid]\n )\n ? releaseAction.locale || (await strapi.localization.getDefaultLocale())\n : undefined;\n const context = strapi.requestContext.get();\n\n return strapi.requestContext.run(\n {\n ...context,\n request: context?.request ?? { url: '' },\n state: {\n ...context?.state,\n releaseId,\n releaseAction: { ...releaseAction, locale: locale ?? undefined },\n },\n } as ParameterizedContext,\n work\n );\n };\n\n const releaseEntry = async (releaseId: Release['id'], action: ReleaseAction) => {\n const params = { documentId: action.entryDocumentId, locale: action.locale };\n\n if (action.type === 'publish') {\n await runReleaseAction(\n releaseId,\n { uid: action.contentType, ...params, event: 'entry.publish' },\n async () => {\n // Publishes nothing, without an error, when the entry has no draft (deleted since the check)\n const { entries } = await strapi.documents(action.contentType).publish(params);\n if (entries.length === 0) {\n throw new errors.ValidationError(ENTRY_NOT_FOUND_MESSAGE);\n }\n }\n );\n } else {\n await runReleaseAction(\n releaseId,\n { uid: action.contentType, ...params, event: 'entry.unpublish' },\n async () => {\n const { entries } = await strapi.documents(action.contentType).unpublish(params);\n if (\n entries.length === 0 &&\n !(await strapi.documents(action.contentType).findOne({ ...params, status: 'draft' }))\n ) {\n throw new errors.ValidationError(ENTRY_NOT_FOUND_MESSAGE);\n }\n }\n );\n }\n };\n\n // A validation error raised by the run (e.g. a unique clash between two of its entries) keeps\n // its field errors, like one found by the check before the run. A publish review-workflows\n // refused on the stage is not approved, with the stages as the check records them (or, if they\n // can't be read, the error).\n const getErrorOutcome = async (\n action: ReleaseAction,\n error: unknown\n ): Promise<RecordedOutcome> => {\n if (isStageError(error)) {\n return {\n outcome: 'skipped_not_approved',\n reason: (await getStageReason(action, { strapi })) ?? toErrorReason(error),\n };\n }\n\n return error instanceof errors.ValidationError\n ? { outcome: 'skipped_invalid', reason: toValidationReason(error) }\n : { outcome: 'skipped_error', reason: toErrorReason(error) };\n };\n\n // Entries without a reason or validity override share one write per outcome; the others are\n // written per entry\n const recordOutcomes = async (outcomes: Outcomes) => {\n const idsByOutcome = new Map<RunOutcome, ReleaseAction['id'][]>();\n for (const [id, { outcome, reason, isEntryValid }] of outcomes) {\n if (reason || isEntryValid !== undefined) {\n await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({\n where: { id },\n data: {\n outcome,\n reason,\n isEntryValid: isEntryValid ?? IS_ENTRY_VALID_BY_OUTCOME[outcome],\n },\n });\n } else {\n const ids = idsByOutcome.get(outcome) ?? [];\n ids.push(id);\n idsByOutcome.set(outcome, ids);\n }\n }\n\n for (const [outcome, ids] of idsByOutcome) {\n // Clears any reason stored before the run: the run's record replaces it\n await strapi.db.query(RELEASE_ACTION_MODEL_UID).updateMany({\n where: { id: { $in: ids } },\n data: { outcome, reason: null, isEntryValid: IS_ENTRY_VALID_BY_OUTCOME[outcome] },\n });\n }\n };\n\n // An `all_or_nothing` run that releases nothing holds back every entry it didn't skip\n const holdUnrecorded = (actions: ReleaseAction[], outcomes: Outcomes) => {\n for (const action of actions) {\n if (!outcomes.has(action.id)) {\n outcomes.set(action.id, { outcome: 'skipped_held', reason: null });\n }\n }\n };\n\n // Each entry's outcome, then the release's status and totals: `releasedAt` freezes it\n const recordRun = async (\n releaseId: Release['id'],\n {\n status,\n totals,\n outcomes,\n }: {\n status: Extract<Release['status'], 'done' | 'partial' | 'failed'>;\n totals: RunTotals;\n outcomes: Outcomes;\n }\n ): Promise<RecordedRelease> => {\n await recordOutcomes(outcomes);\n\n return strapi.db.query(RELEASE_MODEL_UID).update({\n where: { id: releaseId },\n data: { status, releasedAt: new Date(), ...totals },\n });\n };\n\n // `allow_partial`: each entry in its own savepoint, so one that fails is skipped with its\n // published version restored, and the others still go out. Not after a run conflict (see\n // `isRunConflict`): the run fails with it and records nothing, the release stays planned.\n const releaseEachEntry = async (\n release: Pick<Release, 'id' | 'name'>,\n actions: ReleaseAction[],\n outcomes: Outcomes\n ) => {\n // Serialized: concurrent publishes of related documents can race on shared join tables\n for (const action of actions) {\n try {\n await strapi.db.savepoint(() => releaseEntry(release.id, action));\n outcomes.set(action.id, getReleasedOutcome(action));\n } catch (actionError) {\n if (isRunConflict(actionError)) {\n throw actionError;\n }\n outcomes.set(action.id, await getErrorOutcome(action, actionError));\n strapi.log.warn(\n `[Content Releases] Release ${quoteForLog(\n release.name\n )}: skipped an entry that failed to ${action.type} (${getErrorName(actionError)})`\n );\n }\n }\n };\n\n // `all_or_nothing`: one savepoint for every entry, so the first error rolls back the ones\n // before it. Returns that error, unless it's a run conflict, which fails the run.\n const releaseAllEntries = async (\n releaseId: Release['id'],\n actions: ReleaseAction[],\n outcomes: Outcomes\n ): Promise<{ error: unknown } | null> => {\n let inFlight: ReleaseAction | undefined;\n try {\n await strapi.db.savepoint(async () => {\n for (const action of actions) {\n inFlight = action;\n await releaseEntry(releaseId, action);\n inFlight = undefined;\n }\n });\n } catch (error) {\n if (isRunConflict(error)) {\n throw error;\n }\n if (inFlight) {\n outcomes.set(inFlight.id, await getErrorOutcome(inFlight, error));\n }\n return { error };\n }\n\n for (const action of actions) {\n outcomes.set(action.id, getReleasedOutcome(action));\n }\n return null;\n };\n\n // A run, in the transaction that holds the release lock\n const runLocked = async (\n releaseId: Release['id'],\n trigger: PublishTrigger\n ): Promise<LockedPublishResult> => {\n const release = await lockPlannedRelease(releaseId, ['name', 'status', 'releaseCondition'], {\n strapi,\n });\n\n // Not frozen by the sweep yet\n if (isFailedBeforeUpgrade(release)) {\n throw new errors.ValidationError('Release failed to publish');\n }\n\n strapi.log.info(`[Content Releases] Starting to publish release ${quoteForLog(release.name)}`);\n\n const allowPartial = release.releaseCondition === 'allow_partial';\n const actions = await getActionsInRunOrder(releaseId);\n const outcomes: Outcomes = new Map();\n\n const fail = async (error: unknown): Promise<LockedPublishResult> => ({\n kind: 'failed',\n error: toError(error),\n release: await recordRun(releaseId, {\n status: 'failed',\n totals: getRunTotals(actions.length, outcomes),\n outcomes,\n }),\n });\n\n // Checked before anything is written: a publish that fails validation halfway can already\n // have removed the entry's published version\n const checks = await getPublishabilityForActions(actions, { strapi });\n // Not publishable: invalid or not approved (the entry's own error), or its check threw (stored\n // as not publishable, whatever the error class: a thrown check isn't a validation result)\n const entryErrors: Error[] = [];\n const checkErrors: Error[] = [];\n for (const [id, check] of checks) {\n if (check instanceof Error) {\n outcomes.set(id, {\n outcome: 'skipped_error',\n reason: toErrorReason(check),\n isEntryValid: false,\n });\n checkErrors.push(check);\n } else if (!check.publishable) {\n outcomes.set(id, { outcome: check.outcome, reason: check.reason });\n entryErrors.push(check.error);\n }\n }\n\n if (\n isReleaseBlocked(release.releaseCondition, {\n total: actions.length,\n notPublishable: entryErrors.length + checkErrors.length,\n })\n ) {\n if (trigger === 'manual') {\n // Not a run: each entry's check is stored so the release reads as checked, then the\n // publish is refused. A check that threw (e.g. a transient read error) found nothing about\n // its entry: what was stored before stays.\n await getService('release-action', { strapi }).storePublishValidities(\n new Map(\n [...checks].flatMap(([id, check]) =>\n check instanceof Error ? [] : [[id, toEntryValidity(check)] as const]\n )\n )\n );\n await updateReleaseStatus(releaseId);\n\n // Refused like any blocked release (400), on an entry's own error first. What stopped a\n // check is named, never quoted: its message can carry row contents.\n return {\n kind: 'rejected',\n error:\n entryErrors[0] ??\n new errors.ValidationError(\n `An entry couldn't be checked (${getErrorName(checkErrors[0])})`\n ),\n };\n }\n\n if (!allowPartial) {\n holdUnrecorded(actions, outcomes);\n }\n\n return fail(\n allowPartial\n ? new errors.ValidationError('No entries were published')\n : (entryErrors[0] ?? checkErrors[0])\n );\n }\n\n const releasable = actions.filter((action) => !outcomes.has(action.id));\n\n if (allowPartial) {\n await releaseEachEntry({ id: releaseId, name: release.name }, releasable, outcomes);\n } else {\n const failure = await releaseAllEntries(releaseId, releasable, outcomes);\n if (failure) {\n holdUnrecorded(actions, outcomes);\n return fail(failure.error);\n }\n }\n\n const totals = getRunTotals(actions.length, outcomes);\n\n if (actions.length > 0 && totals.totalSkippedEntries === actions.length) {\n return fail(new errors.ValidationError('No entries were published'));\n }\n\n return {\n kind: 'released',\n release: await recordRun(releaseId, {\n status: totals.totalSkippedEntries === 0 ? 'done' : 'partial',\n totals,\n outcomes,\n }),\n };\n };\n\n return { runLocked };\n};\n"],"names":["ENTRY_NOT_FOUND_MESSAGE","IS_ENTRY_VALID_BY_OUTCOME","published","unpublished","skipped_held","skipped_error","skipped_invalid","skipped_not_approved","getRunTotals","entriesCount","outcomes","totalPublishedEntries","totalUnpublishedEntries","outcome","values","totalSkippedEntries","getReleasedOutcome","action","RELEASED_OUTCOME_BY_TYPE","type","reason","createReleaseRun","strapi","updateReleaseStatus","getActionsInRunOrder","releaseId","actions","db","query","RELEASE_ACTION_MODEL_UID","findMany","where","release","id","orderBy","contentTypeOrder","Map","getPublishOrderForContentTypes","map","contentType","contentTypeUid","index","rank","get","sort","a","b","runReleaseAction","releaseAction","work","deduplicateReleaseWebhooks","config","locale","localization","isLocalizedContentType","contentTypes","uid","getDefaultLocale","undefined","context","requestContext","run","request","url","state","releaseEntry","params","documentId","entryDocumentId","event","entries","documents","publish","length","errors","ValidationError","unpublish","findOne","status","getErrorOutcome","error","isStageError","getStageReason","toErrorReason","toValidationReason","recordOutcomes","idsByOutcome","isEntryValid","update","data","ids","push","set","updateMany","$in","holdUnrecorded","has","recordRun","totals","RELEASE_MODEL_UID","releasedAt","Date","releaseEachEntry","savepoint","actionError","isRunConflict","log","warn","quoteForLog","name","getErrorName","releaseAllEntries","inFlight","runLocked","trigger","lockPlannedRelease","isFailedBeforeUpgrade","info","allowPartial","releaseCondition","fail","kind","toError","checks","getPublishabilityForActions","entryErrors","checkErrors","check","Error","publishable","isReleaseBlocked","total","notPublishable","getService","storePublishValidities","flatMap","toEntryValidity","releasable","filter","failure"],"mappings":";;;;;;;;;AAuDA;AACA;AACA,MAAMA,uBAAAA,GAA0B,iBAAA;AAEhC;AACA;AACA,MAAMC,yBAAAA,GACuD;IAC3DC,SAAAA,EAAW,IAAA;IACXC,WAAAA,EAAa,IAAA;IACbC,YAAAA,EAAc,IAAA;IACdC,aAAAA,EAAe,IAAA;IACfC,eAAAA,EAAiB,KAAA;IACjBC,oBAAAA,EAAsB;AACxB,CAAA;AAEA;AACA,MAAMC,YAAAA,GAAe,CAACC,YAAAA,EAAsBC,QAAAA,GAAAA;AAC1C,IAAA,IAAIC,qBAAAA,GAAwB,CAAA;AAC5B,IAAA,IAAIC,uBAAAA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