@strapi/content-releases 0.0.0-next.ec9b1b708d4d319f2b8b39d9397bd752d250d541 → 0.0.0-next.ed7c7c54ff46bcd4c15cc57d65066008685aefd4
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/assets/purchase-page-illustration-dark.svg.js +6 -0
- package/dist/admin/assets/purchase-page-illustration-dark.svg.js.map +1 -0
- package/dist/admin/assets/purchase-page-illustration-dark.svg.mjs +4 -0
- package/dist/admin/assets/purchase-page-illustration-dark.svg.mjs.map +1 -0
- package/dist/admin/assets/purchase-page-illustration-light.svg.js +6 -0
- package/dist/admin/assets/purchase-page-illustration-light.svg.js.map +1 -0
- package/dist/admin/assets/purchase-page-illustration-light.svg.mjs +4 -0
- package/dist/admin/assets/purchase-page-illustration-light.svg.mjs.map +1 -0
- package/dist/admin/components/EntryValidationPopover.js +344 -0
- package/dist/admin/components/EntryValidationPopover.js.map +1 -0
- package/dist/admin/components/EntryValidationPopover.mjs +342 -0
- package/dist/admin/components/EntryValidationPopover.mjs.map +1 -0
- package/dist/admin/components/RelativeTime.js +76 -0
- package/dist/admin/components/RelativeTime.js.map +1 -0
- package/dist/admin/components/RelativeTime.mjs +55 -0
- package/dist/admin/components/RelativeTime.mjs.map +1 -0
- package/dist/admin/components/ReleaseAction.js +203 -0
- package/dist/admin/components/ReleaseAction.js.map +1 -0
- package/dist/admin/components/ReleaseAction.mjs +201 -0
- package/dist/admin/components/ReleaseAction.mjs.map +1 -0
- package/dist/admin/components/ReleaseActionMenu.js +194 -0
- package/dist/admin/components/ReleaseActionMenu.js.map +1 -0
- package/dist/admin/components/ReleaseActionMenu.mjs +173 -0
- package/dist/admin/components/ReleaseActionMenu.mjs.map +1 -0
- package/dist/admin/components/ReleaseActionModal.js +268 -0
- package/dist/admin/components/ReleaseActionModal.js.map +1 -0
- package/dist/admin/components/ReleaseActionModal.mjs +244 -0
- package/dist/admin/components/ReleaseActionModal.mjs.map +1 -0
- package/dist/admin/components/ReleaseActionOptions.js +104 -0
- package/dist/admin/components/ReleaseActionOptions.js.map +1 -0
- package/dist/admin/components/ReleaseActionOptions.mjs +102 -0
- package/dist/admin/components/ReleaseActionOptions.mjs.map +1 -0
- package/dist/admin/components/ReleaseListCell.js +103 -0
- package/dist/admin/components/ReleaseListCell.js.map +1 -0
- package/dist/admin/components/ReleaseListCell.mjs +100 -0
- package/dist/admin/components/ReleaseListCell.mjs.map +1 -0
- package/dist/admin/components/ReleaseModal.js +323 -0
- package/dist/admin/components/ReleaseModal.js.map +1 -0
- package/dist/admin/components/ReleaseModal.mjs +302 -0
- package/dist/admin/components/ReleaseModal.mjs.map +1 -0
- package/dist/admin/components/ReleasesPanel.js +138 -0
- package/dist/admin/components/ReleasesPanel.js.map +1 -0
- package/dist/admin/components/ReleasesPanel.mjs +136 -0
- package/dist/admin/components/ReleasesPanel.mjs.map +1 -0
- package/dist/admin/constants.js +77 -0
- package/dist/admin/constants.js.map +1 -0
- package/dist/admin/constants.mjs +75 -0
- package/dist/admin/constants.mjs.map +1 -0
- package/dist/admin/index.js +125 -4
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +120 -4
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/modules/hooks.js +8 -0
- package/dist/admin/modules/hooks.js.map +1 -0
- package/dist/admin/modules/hooks.mjs +6 -0
- package/dist/admin/modules/hooks.mjs.map +1 -0
- package/dist/admin/pages/App.js +29 -0
- package/dist/admin/pages/App.js.map +1 -0
- package/dist/admin/pages/App.mjs +27 -0
- package/dist/admin/pages/App.mjs.map +1 -0
- package/dist/admin/pages/PurchaseContentReleases.js +192 -0
- package/dist/admin/pages/PurchaseContentReleases.js.map +1 -0
- package/dist/admin/pages/PurchaseContentReleases.mjs +190 -0
- package/dist/admin/pages/PurchaseContentReleases.mjs.map +1 -0
- package/dist/admin/pages/ReleaseDetailsPage.js +772 -0
- package/dist/admin/pages/ReleaseDetailsPage.js.map +1 -0
- package/dist/admin/pages/ReleaseDetailsPage.mjs +751 -0
- package/dist/admin/pages/ReleaseDetailsPage.mjs.map +1 -0
- package/dist/admin/pages/ReleasesPage.js +403 -0
- package/dist/admin/pages/ReleasesPage.js.map +1 -0
- package/dist/admin/pages/ReleasesPage.mjs +381 -0
- package/dist/admin/pages/ReleasesPage.mjs.map +1 -0
- package/dist/admin/pages/ReleasesSettingsPage.js +225 -0
- package/dist/admin/pages/ReleasesSettingsPage.js.map +1 -0
- package/dist/admin/pages/ReleasesSettingsPage.mjs +223 -0
- package/dist/admin/pages/ReleasesSettingsPage.mjs.map +1 -0
- package/dist/admin/pluginId.js +6 -0
- package/dist/admin/pluginId.js.map +1 -0
- package/dist/admin/pluginId.mjs +4 -0
- package/dist/admin/pluginId.mjs.map +1 -0
- package/dist/admin/services/release.js +464 -0
- package/dist/admin/services/release.js.map +1 -0
- package/dist/admin/services/release.mjs +447 -0
- package/dist/admin/services/release.mjs.map +1 -0
- package/dist/admin/src/components/ReleaseListCell.d.ts +1 -1
- package/dist/admin/store/hooks.js +8 -0
- package/dist/admin/store/hooks.js.map +1 -0
- package/dist/admin/store/hooks.mjs +6 -0
- package/dist/admin/store/hooks.mjs.map +1 -0
- package/dist/admin/translations/en.json.js +108 -0
- package/dist/admin/translations/en.json.js.map +1 -0
- package/dist/admin/translations/en.json.mjs +106 -0
- package/dist/admin/translations/en.json.mjs.map +1 -0
- package/dist/admin/translations/uk.json.js +103 -0
- package/dist/admin/translations/uk.json.js.map +1 -0
- package/dist/admin/translations/uk.json.mjs +101 -0
- package/dist/admin/translations/uk.json.mjs.map +1 -0
- package/dist/admin/utils/api.js +8 -0
- package/dist/admin/utils/api.js.map +1 -0
- package/dist/admin/utils/api.mjs +6 -0
- package/dist/admin/utils/api.mjs.map +1 -0
- package/dist/admin/utils/prefixPluginTranslations.js +11 -0
- package/dist/admin/utils/prefixPluginTranslations.js.map +1 -0
- package/dist/admin/utils/prefixPluginTranslations.mjs +9 -0
- package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -0
- package/dist/admin/utils/time.js +42 -0
- package/dist/admin/utils/time.js.map +1 -0
- package/dist/admin/utils/time.mjs +39 -0
- package/dist/admin/utils/time.mjs.map +1 -0
- package/dist/admin/validation/schemas.js +65 -0
- package/dist/admin/validation/schemas.js.map +1 -0
- package/dist/admin/validation/schemas.mjs +43 -0
- package/dist/admin/validation/schemas.mjs.map +1 -0
- package/dist/server/bootstrap.js +68 -0
- package/dist/server/bootstrap.js.map +1 -0
- package/dist/server/bootstrap.mjs +66 -0
- package/dist/server/bootstrap.mjs.map +1 -0
- package/dist/server/constants.js +74 -0
- package/dist/server/constants.js.map +1 -0
- package/dist/server/constants.mjs +69 -0
- package/dist/server/constants.mjs.map +1 -0
- package/dist/server/content-types/index.js +12 -0
- package/dist/server/content-types/index.js.map +1 -0
- package/dist/server/content-types/index.mjs +10 -0
- package/dist/server/content-types/index.mjs.map +1 -0
- package/dist/server/content-types/release/index.js +10 -0
- package/dist/server/content-types/release/index.js.map +1 -0
- package/dist/server/content-types/release/index.mjs +8 -0
- package/dist/server/content-types/release/index.mjs.map +1 -0
- package/dist/server/content-types/release/schema.js +58 -0
- package/dist/server/content-types/release/schema.js.map +1 -0
- package/dist/server/content-types/release/schema.mjs +56 -0
- package/dist/server/content-types/release/schema.mjs.map +1 -0
- package/dist/server/content-types/release-action/index.js +10 -0
- package/dist/server/content-types/release-action/index.js.map +1 -0
- package/dist/server/content-types/release-action/index.mjs +8 -0
- package/dist/server/content-types/release-action/index.mjs.map +1 -0
- package/dist/server/content-types/release-action/schema.js +55 -0
- package/dist/server/content-types/release-action/schema.js.map +1 -0
- package/dist/server/content-types/release-action/schema.mjs +53 -0
- package/dist/server/content-types/release-action/schema.mjs.map +1 -0
- package/dist/server/controllers/index.js +14 -0
- package/dist/server/controllers/index.js.map +1 -0
- package/dist/server/controllers/index.mjs +12 -0
- package/dist/server/controllers/index.mjs.map +1 -0
- package/dist/server/controllers/release-action.js +150 -0
- package/dist/server/controllers/release-action.js.map +1 -0
- package/dist/server/controllers/release-action.mjs +148 -0
- package/dist/server/controllers/release-action.mjs.map +1 -0
- package/dist/server/controllers/release.js +302 -0
- package/dist/server/controllers/release.js.map +1 -0
- package/dist/server/controllers/release.mjs +300 -0
- package/dist/server/controllers/release.mjs.map +1 -0
- package/dist/server/controllers/settings.js +37 -0
- package/dist/server/controllers/settings.js.map +1 -0
- package/dist/server/controllers/settings.mjs +35 -0
- package/dist/server/controllers/settings.mjs.map +1 -0
- package/dist/server/controllers/validation/release-action.js +34 -0
- package/dist/server/controllers/validation/release-action.js.map +1 -0
- package/dist/server/controllers/validation/release-action.mjs +30 -0
- package/dist/server/controllers/validation/release-action.mjs.map +1 -0
- package/dist/server/controllers/validation/release.js +26 -0
- package/dist/server/controllers/validation/release.js.map +1 -0
- package/dist/server/controllers/validation/release.mjs +22 -0
- package/dist/server/controllers/validation/release.mjs.map +1 -0
- package/dist/server/controllers/validation/settings.js +32 -0
- package/dist/server/controllers/validation/settings.js.map +1 -0
- package/dist/server/controllers/validation/settings.mjs +10 -0
- package/dist/server/controllers/validation/settings.mjs.map +1 -0
- package/dist/server/destroy.js +15 -0
- package/dist/server/destroy.js.map +1 -0
- package/dist/server/destroy.mjs +13 -0
- package/dist/server/destroy.mjs.map +1 -0
- package/dist/server/index.js +25 -2050
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +24 -2030
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/middlewares/documents.js +104 -0
- package/dist/server/middlewares/documents.js.map +1 -0
- package/dist/server/middlewares/documents.mjs +101 -0
- package/dist/server/middlewares/documents.mjs.map +1 -0
- package/dist/server/migrations/database/5.0.0-document-id-in-actions.js +51 -0
- package/dist/server/migrations/database/5.0.0-document-id-in-actions.js.map +1 -0
- package/dist/server/migrations/database/5.0.0-document-id-in-actions.mjs +49 -0
- package/dist/server/migrations/database/5.0.0-document-id-in-actions.mjs.map +1 -0
- package/dist/server/migrations/index.js +205 -0
- package/dist/server/migrations/index.js.map +1 -0
- package/dist/server/migrations/index.mjs +198 -0
- package/dist/server/migrations/index.mjs.map +1 -0
- package/dist/server/register.js +23 -0
- package/dist/server/register.js.map +1 -0
- package/dist/server/register.mjs +21 -0
- package/dist/server/register.mjs.map +1 -0
- package/dist/server/routes/index.js +14 -0
- package/dist/server/routes/index.js.map +1 -0
- package/dist/server/routes/index.mjs +12 -0
- package/dist/server/routes/index.mjs.map +1 -0
- package/dist/server/routes/release-action.js +100 -0
- package/dist/server/routes/release-action.js.map +1 -0
- package/dist/server/routes/release-action.mjs +98 -0
- package/dist/server/routes/release-action.mjs.map +1 -0
- package/dist/server/routes/release.js +154 -0
- package/dist/server/routes/release.js.map +1 -0
- package/dist/server/routes/release.mjs +152 -0
- package/dist/server/routes/release.mjs.map +1 -0
- package/dist/server/routes/settings.js +46 -0
- package/dist/server/routes/settings.js.map +1 -0
- package/dist/server/routes/settings.mjs +44 -0
- package/dist/server/routes/settings.mjs.map +1 -0
- package/dist/server/services/index.js +18 -0
- package/dist/server/services/index.js.map +1 -0
- package/dist/server/services/index.mjs +16 -0
- package/dist/server/services/index.mjs.map +1 -0
- package/dist/server/services/release-action.js +324 -0
- package/dist/server/services/release-action.js.map +1 -0
- package/dist/server/services/release-action.mjs +322 -0
- package/dist/server/services/release-action.mjs.map +1 -0
- package/dist/server/services/release.js +324 -0
- package/dist/server/services/release.js.map +1 -0
- package/dist/server/services/release.mjs +322 -0
- package/dist/server/services/release.mjs.map +1 -0
- package/dist/server/services/scheduling.js +70 -0
- package/dist/server/services/scheduling.js.map +1 -0
- package/dist/server/services/scheduling.mjs +68 -0
- package/dist/server/services/scheduling.mjs.map +1 -0
- package/dist/server/services/settings.js +34 -0
- package/dist/server/services/settings.js.map +1 -0
- package/dist/server/services/settings.mjs +32 -0
- package/dist/server/services/settings.mjs.map +1 -0
- package/dist/server/services/validation.js +91 -0
- package/dist/server/services/validation.js.map +1 -0
- package/dist/server/services/validation.mjs +86 -0
- package/dist/server/services/validation.mjs.map +1 -0
- package/dist/server/src/destroy.d.ts +1 -1
- package/dist/server/src/destroy.d.ts.map +1 -1
- package/dist/server/src/middlewares/documents.d.ts +1 -1
- package/dist/server/src/middlewares/documents.d.ts.map +1 -1
- package/dist/server/src/services/release-action.d.ts.map +1 -1
- package/dist/server/src/services/scheduling.d.ts +1 -1
- package/dist/server/src/services/scheduling.d.ts.map +1 -1
- package/dist/server/src/services/validation.d.ts +1 -1
- package/dist/server/src/services/validation.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/server/utils/index.js +94 -0
- package/dist/server/utils/index.js.map +1 -0
- package/dist/server/utils/index.mjs +88 -0
- package/dist/server/utils/index.mjs.map +1 -0
- package/dist/shared/contracts/release-actions.d.ts +0 -1
- package/dist/shared/contracts/releases.d.ts +0 -1
- package/dist/shared/contracts/settings.d.ts +1 -2
- package/dist/shared/contracts/settings.d.ts.map +1 -1
- package/dist/shared/types.d.ts +0 -1
- package/package.json +18 -16
- package/dist/_chunks/App-FQyYFBJT.mjs +0 -1559
- package/dist/_chunks/App-FQyYFBJT.mjs.map +0 -1
- package/dist/_chunks/App-lx4Ucy9W.js +0 -1580
- package/dist/_chunks/App-lx4Ucy9W.js.map +0 -1
- package/dist/_chunks/PurchaseContentReleases-Be3acS2L.js +0 -52
- package/dist/_chunks/PurchaseContentReleases-Be3acS2L.js.map +0 -1
- package/dist/_chunks/PurchaseContentReleases-_MxP6-Dt.mjs +0 -52
- package/dist/_chunks/PurchaseContentReleases-_MxP6-Dt.mjs.map +0 -1
- package/dist/_chunks/ReleasesSettingsPage-DqBxvJ9i.mjs +0 -178
- package/dist/_chunks/ReleasesSettingsPage-DqBxvJ9i.mjs.map +0 -1
- package/dist/_chunks/ReleasesSettingsPage-T5VEAV03.js +0 -178
- package/dist/_chunks/ReleasesSettingsPage-T5VEAV03.js.map +0 -1
- package/dist/_chunks/en-BWPPsSH-.js +0 -102
- package/dist/_chunks/en-BWPPsSH-.js.map +0 -1
- package/dist/_chunks/en-D9Q4YW03.mjs +0 -102
- package/dist/_chunks/en-D9Q4YW03.mjs.map +0 -1
- package/dist/_chunks/index-CK9G80CL.mjs +0 -1380
- package/dist/_chunks/index-CK9G80CL.mjs.map +0 -1
- package/dist/_chunks/index-Cl3tM1YW.js +0 -1399
- package/dist/_chunks/index-Cl3tM1YW.js.map +0 -1
- package/dist/_chunks/schemas-BE1LxE9J.js +0 -62
- package/dist/_chunks/schemas-BE1LxE9J.js.map +0 -1
- package/dist/_chunks/schemas-DdA2ic2U.mjs +0 -44
- package/dist/_chunks/schemas-DdA2ic2U.mjs.map +0 -1
package/dist/server/index.js
CHANGED
|
@@ -1,2058 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (e) {
|
|
14
|
-
for (const k in e) {
|
|
15
|
-
if (k !== "default") {
|
|
16
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: () => e[k]
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
n.default = e;
|
|
25
|
-
return Object.freeze(n);
|
|
26
|
-
}
|
|
27
|
-
const isEqual__default = /* @__PURE__ */ _interopDefault(isEqual);
|
|
28
|
-
const ___default = /* @__PURE__ */ _interopDefault(_);
|
|
29
|
-
const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
|
30
|
-
const RELEASE_MODEL_UID = "plugin::content-releases.release";
|
|
31
|
-
const RELEASE_ACTION_MODEL_UID = "plugin::content-releases.release-action";
|
|
32
|
-
const ACTIONS = [
|
|
33
|
-
{
|
|
34
|
-
section: "plugins",
|
|
35
|
-
displayName: "Read",
|
|
36
|
-
uid: "read",
|
|
37
|
-
pluginName: "content-releases"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
section: "plugins",
|
|
41
|
-
displayName: "Create",
|
|
42
|
-
uid: "create",
|
|
43
|
-
pluginName: "content-releases"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
section: "plugins",
|
|
47
|
-
displayName: "Edit",
|
|
48
|
-
uid: "update",
|
|
49
|
-
pluginName: "content-releases"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
section: "plugins",
|
|
53
|
-
displayName: "Delete",
|
|
54
|
-
uid: "delete",
|
|
55
|
-
pluginName: "content-releases"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
section: "plugins",
|
|
59
|
-
displayName: "Publish",
|
|
60
|
-
uid: "publish",
|
|
61
|
-
pluginName: "content-releases"
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
section: "plugins",
|
|
65
|
-
displayName: "Remove an entry from a release",
|
|
66
|
-
uid: "delete-action",
|
|
67
|
-
pluginName: "content-releases"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
section: "plugins",
|
|
71
|
-
displayName: "Add an entry to a release",
|
|
72
|
-
uid: "create-action",
|
|
73
|
-
pluginName: "content-releases"
|
|
74
|
-
},
|
|
75
|
-
// Settings
|
|
76
|
-
{
|
|
77
|
-
uid: "settings.read",
|
|
78
|
-
section: "settings",
|
|
79
|
-
displayName: "Read",
|
|
80
|
-
category: "content releases",
|
|
81
|
-
subCategory: "options",
|
|
82
|
-
pluginName: "content-releases"
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
uid: "settings.update",
|
|
86
|
-
section: "settings",
|
|
87
|
-
displayName: "Edit",
|
|
88
|
-
category: "content releases",
|
|
89
|
-
subCategory: "options",
|
|
90
|
-
pluginName: "content-releases"
|
|
91
|
-
}
|
|
92
|
-
];
|
|
93
|
-
const ALLOWED_WEBHOOK_EVENTS = {
|
|
94
|
-
RELEASES_PUBLISH: "releases.publish"
|
|
95
|
-
};
|
|
96
|
-
const getService = (name, { strapi: strapi2 }) => {
|
|
97
|
-
return strapi2.plugin("content-releases").service(name);
|
|
98
|
-
};
|
|
99
|
-
const getDraftEntryValidStatus = async ({ contentType, documentId, locale }, { strapi: strapi2 }) => {
|
|
100
|
-
const populateBuilderService = strapi2.plugin("content-manager").service("populate-builder");
|
|
101
|
-
const populate = await populateBuilderService(contentType).populateDeep(Infinity).build();
|
|
102
|
-
const entry = await getEntry({ contentType, documentId, locale, populate }, { strapi: strapi2 });
|
|
103
|
-
return isEntryValid(contentType, entry, { strapi: strapi2 });
|
|
104
|
-
};
|
|
105
|
-
const isEntryValid = async (contentTypeUid, entry, { strapi: strapi2 }) => {
|
|
106
|
-
try {
|
|
107
|
-
await strapi2.entityValidator.validateEntityCreation(
|
|
108
|
-
strapi2.getModel(contentTypeUid),
|
|
109
|
-
entry,
|
|
110
|
-
void 0,
|
|
111
|
-
// @ts-expect-error - FIXME: entity here is unnecessary
|
|
112
|
-
entry
|
|
113
|
-
);
|
|
114
|
-
const workflowsService = strapi2.plugin("review-workflows").service("workflows");
|
|
115
|
-
const workflow = await workflowsService.getAssignedWorkflow(contentTypeUid, {
|
|
116
|
-
populate: "stageRequiredToPublish"
|
|
117
|
-
});
|
|
118
|
-
if (workflow?.stageRequiredToPublish) {
|
|
119
|
-
return entry.strapi_stage.id === workflow.stageRequiredToPublish.id;
|
|
120
|
-
}
|
|
121
|
-
return true;
|
|
122
|
-
} catch {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
const getEntry = async ({
|
|
127
|
-
contentType,
|
|
128
|
-
documentId,
|
|
129
|
-
locale,
|
|
130
|
-
populate,
|
|
131
|
-
status = "draft"
|
|
132
|
-
}, { strapi: strapi2 }) => {
|
|
133
|
-
if (documentId) {
|
|
134
|
-
const entry = await strapi2.documents(contentType).findOne({ documentId, locale, populate, status });
|
|
135
|
-
if (status === "published" && !entry) {
|
|
136
|
-
return strapi2.documents(contentType).findOne({ documentId, locale, populate, status: "draft" });
|
|
137
|
-
}
|
|
138
|
-
return entry;
|
|
139
|
-
}
|
|
140
|
-
return strapi2.documents(contentType).findFirst({ locale, populate, status });
|
|
141
|
-
};
|
|
142
|
-
const getEntryStatus = async (contentType, entry) => {
|
|
143
|
-
if (entry.publishedAt) {
|
|
144
|
-
return "published";
|
|
145
|
-
}
|
|
146
|
-
const publishedEntry = await strapi.documents(contentType).findOne({
|
|
147
|
-
documentId: entry.documentId,
|
|
148
|
-
locale: entry.locale,
|
|
149
|
-
status: "published",
|
|
150
|
-
fields: ["updatedAt"]
|
|
151
|
-
});
|
|
152
|
-
if (!publishedEntry) {
|
|
153
|
-
return "draft";
|
|
154
|
-
}
|
|
155
|
-
const entryUpdatedAt = new Date(entry.updatedAt).getTime();
|
|
156
|
-
const publishedEntryUpdatedAt = new Date(publishedEntry.updatedAt).getTime();
|
|
157
|
-
if (entryUpdatedAt > publishedEntryUpdatedAt) {
|
|
158
|
-
return "modified";
|
|
159
|
-
}
|
|
160
|
-
return "published";
|
|
161
|
-
};
|
|
162
|
-
async function deleteActionsOnDisableDraftAndPublish({
|
|
163
|
-
oldContentTypes,
|
|
164
|
-
contentTypes: contentTypes2
|
|
165
|
-
}) {
|
|
166
|
-
if (!oldContentTypes) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
for (const uid in contentTypes2) {
|
|
170
|
-
if (!oldContentTypes[uid]) {
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
const oldContentType = oldContentTypes[uid];
|
|
174
|
-
const contentType = contentTypes2[uid];
|
|
175
|
-
if (utils.contentTypes.hasDraftAndPublish(oldContentType) && !utils.contentTypes.hasDraftAndPublish(contentType)) {
|
|
176
|
-
await strapi.db?.queryBuilder(RELEASE_ACTION_MODEL_UID).delete().where({ contentType: uid }).execute();
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
async function deleteActionsOnDeleteContentType({ oldContentTypes, contentTypes: contentTypes2 }) {
|
|
181
|
-
const deletedContentTypes = lodash.difference(lodash.keys(oldContentTypes), lodash.keys(contentTypes2)) ?? [];
|
|
182
|
-
if (deletedContentTypes.length) {
|
|
183
|
-
await utils.async.map(deletedContentTypes, async (deletedContentTypeUID) => {
|
|
184
|
-
return strapi.db?.queryBuilder(RELEASE_ACTION_MODEL_UID).delete().where({ contentType: deletedContentTypeUID }).execute();
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
async function migrateIsValidAndStatusReleases() {
|
|
189
|
-
const releasesWithoutStatus = await strapi.db.query(RELEASE_MODEL_UID).findMany({
|
|
190
|
-
where: {
|
|
191
|
-
status: null,
|
|
192
|
-
releasedAt: null
|
|
193
|
-
},
|
|
194
|
-
populate: {
|
|
195
|
-
actions: {
|
|
196
|
-
populate: {
|
|
197
|
-
entry: true
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
utils.async.map(releasesWithoutStatus, async (release2) => {
|
|
203
|
-
const actions = release2.actions;
|
|
204
|
-
const notValidatedActions = actions.filter((action) => action.isEntryValid === null);
|
|
205
|
-
for (const action of notValidatedActions) {
|
|
206
|
-
if (action.entry) {
|
|
207
|
-
const isEntryValid2 = getDraftEntryValidStatus(
|
|
208
|
-
{
|
|
209
|
-
contentType: action.contentType,
|
|
210
|
-
documentId: action.entryDocumentId,
|
|
211
|
-
locale: action.locale
|
|
212
|
-
},
|
|
213
|
-
{ strapi }
|
|
214
|
-
);
|
|
215
|
-
await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({
|
|
216
|
-
where: {
|
|
217
|
-
id: action.id
|
|
218
|
-
},
|
|
219
|
-
data: {
|
|
220
|
-
isEntryValid: isEntryValid2
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
return getService("release", { strapi }).updateReleaseStatus(release2.id);
|
|
226
|
-
});
|
|
227
|
-
const publishedReleases = await strapi.db.query(RELEASE_MODEL_UID).findMany({
|
|
228
|
-
where: {
|
|
229
|
-
status: null,
|
|
230
|
-
releasedAt: {
|
|
231
|
-
$notNull: true
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
utils.async.map(publishedReleases, async (release2) => {
|
|
236
|
-
return strapi.db.query(RELEASE_MODEL_UID).update({
|
|
237
|
-
where: {
|
|
238
|
-
id: release2.id
|
|
239
|
-
},
|
|
240
|
-
data: {
|
|
241
|
-
status: "done"
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
async function revalidateChangedContentTypes({ oldContentTypes, contentTypes: contentTypes2 }) {
|
|
247
|
-
if (oldContentTypes !== void 0 && contentTypes2 !== void 0) {
|
|
248
|
-
const contentTypesWithDraftAndPublish = Object.keys(oldContentTypes).filter(
|
|
249
|
-
(uid) => oldContentTypes[uid]?.options?.draftAndPublish
|
|
250
|
-
);
|
|
251
|
-
const releasesAffected = /* @__PURE__ */ new Set();
|
|
252
|
-
utils.async.map(contentTypesWithDraftAndPublish, async (contentTypeUID) => {
|
|
253
|
-
const oldContentType = oldContentTypes[contentTypeUID];
|
|
254
|
-
const contentType = contentTypes2[contentTypeUID];
|
|
255
|
-
if (!isEqual__default.default(oldContentType?.attributes, contentType?.attributes)) {
|
|
256
|
-
const actions = await strapi.db.query(RELEASE_ACTION_MODEL_UID).findMany({
|
|
257
|
-
where: {
|
|
258
|
-
contentType: contentTypeUID
|
|
259
|
-
},
|
|
260
|
-
populate: {
|
|
261
|
-
entry: true,
|
|
262
|
-
release: true
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
await utils.async.map(actions, async (action) => {
|
|
266
|
-
if (action.entry && action.release && action.type === "publish") {
|
|
267
|
-
const isEntryValid2 = await getDraftEntryValidStatus(
|
|
268
|
-
{
|
|
269
|
-
contentType: contentTypeUID,
|
|
270
|
-
documentId: action.entryDocumentId,
|
|
271
|
-
locale: action.locale
|
|
272
|
-
},
|
|
273
|
-
{ strapi }
|
|
274
|
-
);
|
|
275
|
-
releasesAffected.add(action.release.id);
|
|
276
|
-
await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({
|
|
277
|
-
where: {
|
|
278
|
-
id: action.id
|
|
279
|
-
},
|
|
280
|
-
data: {
|
|
281
|
-
isEntryValid: isEntryValid2
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
}).then(() => {
|
|
288
|
-
utils.async.map(releasesAffected, async (releaseId) => {
|
|
289
|
-
return getService("release", { strapi }).updateReleaseStatus(releaseId);
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
async function disableContentTypeLocalized({ oldContentTypes, contentTypes: contentTypes2 }) {
|
|
295
|
-
if (!oldContentTypes) {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
const i18nPlugin = strapi.plugin("i18n");
|
|
299
|
-
if (!i18nPlugin) {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
for (const uid in contentTypes2) {
|
|
303
|
-
if (!oldContentTypes[uid]) {
|
|
304
|
-
continue;
|
|
305
|
-
}
|
|
306
|
-
const oldContentType = oldContentTypes[uid];
|
|
307
|
-
const contentType = contentTypes2[uid];
|
|
308
|
-
const { isLocalizedContentType } = i18nPlugin.service("content-types");
|
|
309
|
-
if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {
|
|
310
|
-
await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
|
|
311
|
-
locale: null
|
|
312
|
-
}).where({ contentType: uid }).execute();
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
async function enableContentTypeLocalized({ oldContentTypes, contentTypes: contentTypes2 }) {
|
|
317
|
-
if (!oldContentTypes) {
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
const i18nPlugin = strapi.plugin("i18n");
|
|
321
|
-
if (!i18nPlugin) {
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
for (const uid in contentTypes2) {
|
|
325
|
-
if (!oldContentTypes[uid]) {
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
const oldContentType = oldContentTypes[uid];
|
|
329
|
-
const contentType = contentTypes2[uid];
|
|
330
|
-
const { isLocalizedContentType } = i18nPlugin.service("content-types");
|
|
331
|
-
const { getDefaultLocale } = i18nPlugin.service("locales");
|
|
332
|
-
if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {
|
|
333
|
-
const defaultLocale = await getDefaultLocale();
|
|
334
|
-
await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
|
|
335
|
-
locale: defaultLocale
|
|
336
|
-
}).where({ contentType: uid }).execute();
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
const addEntryDocumentToReleaseActions = {
|
|
341
|
-
name: "content-releases::5.0.0-add-entry-document-id-to-release-actions",
|
|
342
|
-
async up(trx, db) {
|
|
343
|
-
const hasTable = await trx.schema.hasTable("strapi_release_actions");
|
|
344
|
-
if (!hasTable) {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
const hasPolymorphicColumn = await trx.schema.hasColumn("strapi_release_actions", "target_id");
|
|
348
|
-
if (hasPolymorphicColumn) {
|
|
349
|
-
const hasEntryDocumentIdColumn = await trx.schema.hasColumn(
|
|
350
|
-
"strapi_release_actions",
|
|
351
|
-
"entry_document_id"
|
|
352
|
-
);
|
|
353
|
-
if (!hasEntryDocumentIdColumn) {
|
|
354
|
-
await trx.schema.alterTable("strapi_release_actions", (table) => {
|
|
355
|
-
table.string("entry_document_id");
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
const releaseActions = await trx.select("*").from("strapi_release_actions");
|
|
359
|
-
utils.async.map(releaseActions, async (action) => {
|
|
360
|
-
const { target_type, target_id } = action;
|
|
361
|
-
const entry = await db.query(target_type).findOne({ where: { id: target_id } });
|
|
362
|
-
if (entry) {
|
|
363
|
-
await trx("strapi_release_actions").update({ entry_document_id: entry.documentId }).where("id", action.id);
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
},
|
|
368
|
-
async down() {
|
|
369
|
-
throw new Error("not implemented");
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
const register = async ({ strapi: strapi2 }) => {
|
|
373
|
-
if (strapi2.ee.features.isEnabled("cms-content-releases")) {
|
|
374
|
-
await strapi2.service("admin::permission").actionProvider.registerMany(ACTIONS);
|
|
375
|
-
strapi2.db.migrations.providers.internal.register(addEntryDocumentToReleaseActions);
|
|
376
|
-
strapi2.hook("strapi::content-types.beforeSync").register(disableContentTypeLocalized).register(deleteActionsOnDisableDraftAndPublish);
|
|
377
|
-
strapi2.hook("strapi::content-types.afterSync").register(deleteActionsOnDeleteContentType).register(enableContentTypeLocalized).register(revalidateChangedContentTypes).register(migrateIsValidAndStatusReleases);
|
|
378
|
-
}
|
|
379
|
-
if (strapi2.plugin("graphql")) {
|
|
380
|
-
const graphqlExtensionService = strapi2.plugin("graphql").service("extension");
|
|
381
|
-
graphqlExtensionService.shadowCRUD(RELEASE_MODEL_UID).disable();
|
|
382
|
-
graphqlExtensionService.shadowCRUD(RELEASE_ACTION_MODEL_UID).disable();
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) => {
|
|
386
|
-
const releases = await strapi.db.query(RELEASE_MODEL_UID).findMany({
|
|
387
|
-
where: {
|
|
388
|
-
releasedAt: null,
|
|
389
|
-
actions: {
|
|
390
|
-
contentType,
|
|
391
|
-
entryDocumentId: entry.documentId,
|
|
392
|
-
locale: entry.locale
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
const entryStatus = await isEntryValid(contentType, entry, { strapi });
|
|
397
|
-
await strapi.db.query(RELEASE_ACTION_MODEL_UID).updateMany({
|
|
398
|
-
where: {
|
|
399
|
-
contentType,
|
|
400
|
-
entryDocumentId: entry.documentId,
|
|
401
|
-
locale: entry.locale
|
|
402
|
-
},
|
|
403
|
-
data: {
|
|
404
|
-
isEntryValid: entryStatus
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
for (const release2 of releases) {
|
|
408
|
-
getService("release", { strapi }).updateReleaseStatus(release2.id);
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
const deleteActionsAndUpdateReleaseStatus = async (params) => {
|
|
412
|
-
const releases = await strapi.db.query(RELEASE_MODEL_UID).findMany({
|
|
413
|
-
where: {
|
|
414
|
-
actions: params
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
await strapi.db.query(RELEASE_ACTION_MODEL_UID).deleteMany({
|
|
418
|
-
where: params
|
|
419
|
-
});
|
|
420
|
-
for (const release2 of releases) {
|
|
421
|
-
getService("release", { strapi }).updateReleaseStatus(release2.id);
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
const deleteActionsOnDelete = async (ctx, next) => {
|
|
425
|
-
if (ctx.action !== "delete") {
|
|
426
|
-
return next();
|
|
427
|
-
}
|
|
428
|
-
if (!utils.contentTypes.hasDraftAndPublish(ctx.contentType)) {
|
|
429
|
-
return next();
|
|
430
|
-
}
|
|
431
|
-
const contentType = ctx.contentType.uid;
|
|
432
|
-
const { documentId, locale } = ctx.params;
|
|
433
|
-
const result = await next();
|
|
434
|
-
if (!result) {
|
|
435
|
-
return result;
|
|
436
|
-
}
|
|
437
|
-
try {
|
|
438
|
-
deleteActionsAndUpdateReleaseStatus({
|
|
439
|
-
contentType,
|
|
440
|
-
entryDocumentId: documentId,
|
|
441
|
-
...locale !== "*" && { locale }
|
|
442
|
-
});
|
|
443
|
-
} catch (error) {
|
|
444
|
-
strapi.log.error("Error while deleting release actions after delete", {
|
|
445
|
-
error
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
return result;
|
|
449
|
-
};
|
|
450
|
-
const updateActionsOnUpdate = async (ctx, next) => {
|
|
451
|
-
if (ctx.action !== "update") {
|
|
452
|
-
return next();
|
|
453
|
-
}
|
|
454
|
-
if (!utils.contentTypes.hasDraftAndPublish(ctx.contentType)) {
|
|
455
|
-
return next();
|
|
456
|
-
}
|
|
457
|
-
const contentType = ctx.contentType.uid;
|
|
458
|
-
const result = await next();
|
|
459
|
-
if (!result) {
|
|
460
|
-
return result;
|
|
461
|
-
}
|
|
462
|
-
try {
|
|
463
|
-
updateActionsStatusAndUpdateReleaseStatus(contentType, result);
|
|
464
|
-
} catch (error) {
|
|
465
|
-
strapi.log.error("Error while updating release actions after update", {
|
|
466
|
-
error
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
return result;
|
|
470
|
-
};
|
|
471
|
-
const deleteReleasesActionsAndUpdateReleaseStatus = async (params) => {
|
|
472
|
-
const releases = await strapi.db.query(RELEASE_MODEL_UID).findMany({
|
|
473
|
-
where: {
|
|
474
|
-
actions: params
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
await strapi.db.query(RELEASE_ACTION_MODEL_UID).deleteMany({
|
|
478
|
-
where: params
|
|
479
|
-
});
|
|
480
|
-
for (const release2 of releases) {
|
|
481
|
-
getService("release", { strapi }).updateReleaseStatus(release2.id);
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
const bootstrap = async ({ strapi: strapi2 }) => {
|
|
485
|
-
if (strapi2.ee.features.isEnabled("cms-content-releases")) {
|
|
486
|
-
const contentTypesWithDraftAndPublish = Object.keys(strapi2.contentTypes).filter(
|
|
487
|
-
(uid) => strapi2.contentTypes[uid]?.options?.draftAndPublish
|
|
488
|
-
);
|
|
489
|
-
strapi2.db.lifecycles.subscribe({
|
|
490
|
-
models: contentTypesWithDraftAndPublish,
|
|
491
|
-
/**
|
|
492
|
-
* deleteMany is still used outside documents service, for example when deleting a locale
|
|
493
|
-
*/
|
|
494
|
-
async afterDeleteMany(event) {
|
|
495
|
-
try {
|
|
496
|
-
const model = strapi2.getModel(event.model.uid);
|
|
497
|
-
if (model.kind === "collectionType" && model.options?.draftAndPublish) {
|
|
498
|
-
const { where } = event.params;
|
|
499
|
-
deleteReleasesActionsAndUpdateReleaseStatus({
|
|
500
|
-
contentType: model.uid,
|
|
501
|
-
locale: where?.locale ?? null,
|
|
502
|
-
...where?.documentId && { entryDocumentId: where.documentId }
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
} catch (error) {
|
|
506
|
-
strapi2.log.error("Error while deleting release actions after entry deleteMany", {
|
|
507
|
-
error
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
strapi2.documents.use(deleteActionsOnDelete);
|
|
513
|
-
strapi2.documents.use(updateActionsOnUpdate);
|
|
514
|
-
getService("scheduling", { strapi: strapi2 }).syncFromDatabase().catch((err) => {
|
|
515
|
-
strapi2.log.error(
|
|
516
|
-
"Error while syncing scheduled jobs from the database in the content-releases plugin. This could lead to errors in the releases scheduling."
|
|
517
|
-
);
|
|
518
|
-
throw err;
|
|
519
|
-
});
|
|
520
|
-
Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
|
|
521
|
-
strapi2.get("webhookStore").addAllowedEvent(key, value);
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
};
|
|
525
|
-
const destroy = async ({ strapi: strapi2 }) => {
|
|
526
|
-
const scheduledJobs = getService("scheduling", {
|
|
527
|
-
strapi: strapi2
|
|
528
|
-
}).getAll();
|
|
529
|
-
for (const [, job] of scheduledJobs) {
|
|
530
|
-
job.cancel();
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
const schema$1 = {
|
|
534
|
-
collectionName: "strapi_releases",
|
|
535
|
-
info: {
|
|
536
|
-
singularName: "release",
|
|
537
|
-
pluralName: "releases",
|
|
538
|
-
displayName: "Release"
|
|
539
|
-
},
|
|
540
|
-
options: {
|
|
541
|
-
draftAndPublish: false
|
|
542
|
-
},
|
|
543
|
-
pluginOptions: {
|
|
544
|
-
"content-manager": {
|
|
545
|
-
visible: false
|
|
546
|
-
},
|
|
547
|
-
"content-type-builder": {
|
|
548
|
-
visible: false
|
|
549
|
-
}
|
|
550
|
-
},
|
|
551
|
-
attributes: {
|
|
552
|
-
name: {
|
|
553
|
-
type: "string",
|
|
554
|
-
required: true
|
|
555
|
-
},
|
|
556
|
-
releasedAt: {
|
|
557
|
-
type: "datetime"
|
|
558
|
-
},
|
|
559
|
-
scheduledAt: {
|
|
560
|
-
type: "datetime"
|
|
561
|
-
},
|
|
562
|
-
timezone: {
|
|
563
|
-
type: "string"
|
|
564
|
-
},
|
|
565
|
-
status: {
|
|
566
|
-
type: "enumeration",
|
|
567
|
-
enum: ["ready", "blocked", "failed", "done", "empty"],
|
|
568
|
-
required: true
|
|
569
|
-
},
|
|
570
|
-
actions: {
|
|
571
|
-
type: "relation",
|
|
572
|
-
relation: "oneToMany",
|
|
573
|
-
target: RELEASE_ACTION_MODEL_UID,
|
|
574
|
-
mappedBy: "release"
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
const release$1 = {
|
|
579
|
-
schema: schema$1
|
|
580
|
-
};
|
|
581
|
-
const schema = {
|
|
582
|
-
collectionName: "strapi_release_actions",
|
|
583
|
-
info: {
|
|
584
|
-
singularName: "release-action",
|
|
585
|
-
pluralName: "release-actions",
|
|
586
|
-
displayName: "Release Action"
|
|
587
|
-
},
|
|
588
|
-
options: {
|
|
589
|
-
draftAndPublish: false
|
|
590
|
-
},
|
|
591
|
-
pluginOptions: {
|
|
592
|
-
"content-manager": {
|
|
593
|
-
visible: false
|
|
594
|
-
},
|
|
595
|
-
"content-type-builder": {
|
|
596
|
-
visible: false
|
|
597
|
-
}
|
|
598
|
-
},
|
|
599
|
-
attributes: {
|
|
600
|
-
type: {
|
|
601
|
-
type: "enumeration",
|
|
602
|
-
enum: ["publish", "unpublish"],
|
|
603
|
-
required: true
|
|
604
|
-
},
|
|
605
|
-
contentType: {
|
|
606
|
-
type: "string",
|
|
607
|
-
required: true
|
|
608
|
-
},
|
|
609
|
-
entryDocumentId: {
|
|
610
|
-
type: "string"
|
|
611
|
-
},
|
|
612
|
-
locale: {
|
|
613
|
-
type: "string"
|
|
614
|
-
},
|
|
615
|
-
release: {
|
|
616
|
-
type: "relation",
|
|
617
|
-
relation: "manyToOne",
|
|
618
|
-
target: RELEASE_MODEL_UID,
|
|
619
|
-
inversedBy: "actions"
|
|
620
|
-
},
|
|
621
|
-
isEntryValid: {
|
|
622
|
-
type: "boolean"
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
const releaseAction$1 = {
|
|
627
|
-
schema
|
|
628
|
-
};
|
|
629
|
-
const contentTypes = {
|
|
630
|
-
release: release$1,
|
|
631
|
-
"release-action": releaseAction$1
|
|
632
|
-
};
|
|
633
|
-
const createReleaseService = ({ strapi: strapi2 }) => {
|
|
634
|
-
const dispatchWebhook = (event, { isPublished, release: release2, error }) => {
|
|
635
|
-
strapi2.eventHub.emit(event, {
|
|
636
|
-
isPublished,
|
|
637
|
-
error,
|
|
638
|
-
release: release2
|
|
639
|
-
});
|
|
640
|
-
};
|
|
641
|
-
const getFormattedActions = async (releaseId) => {
|
|
642
|
-
const actions = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).findMany({
|
|
643
|
-
where: {
|
|
644
|
-
release: {
|
|
645
|
-
id: releaseId
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
if (actions.length === 0) {
|
|
650
|
-
throw new utils.errors.ValidationError("No entries to publish");
|
|
651
|
-
}
|
|
652
|
-
const formattedActions = {};
|
|
653
|
-
for (const action of actions) {
|
|
654
|
-
const contentTypeUid = action.contentType;
|
|
655
|
-
if (!formattedActions[contentTypeUid]) {
|
|
656
|
-
formattedActions[contentTypeUid] = {
|
|
657
|
-
publish: [],
|
|
658
|
-
unpublish: []
|
|
659
|
-
};
|
|
660
|
-
}
|
|
661
|
-
formattedActions[contentTypeUid][action.type].push({
|
|
662
|
-
documentId: action.entryDocumentId,
|
|
663
|
-
locale: action.locale
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
return formattedActions;
|
|
667
|
-
};
|
|
668
|
-
return {
|
|
669
|
-
async create(releaseData, { user }) {
|
|
670
|
-
const releaseWithCreatorFields = await utils.setCreatorFields({ user })(releaseData);
|
|
671
|
-
const {
|
|
672
|
-
validatePendingReleasesLimit,
|
|
673
|
-
validateUniqueNameForPendingRelease,
|
|
674
|
-
validateScheduledAtIsLaterThanNow
|
|
675
|
-
} = getService("release-validation", { strapi: strapi2 });
|
|
676
|
-
await Promise.all([
|
|
677
|
-
validatePendingReleasesLimit(),
|
|
678
|
-
validateUniqueNameForPendingRelease(releaseWithCreatorFields.name),
|
|
679
|
-
validateScheduledAtIsLaterThanNow(releaseWithCreatorFields.scheduledAt)
|
|
680
|
-
]);
|
|
681
|
-
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).create({
|
|
682
|
-
data: {
|
|
683
|
-
...releaseWithCreatorFields,
|
|
684
|
-
status: "empty"
|
|
685
|
-
}
|
|
686
|
-
});
|
|
687
|
-
if (releaseWithCreatorFields.scheduledAt) {
|
|
688
|
-
const schedulingService = getService("scheduling", { strapi: strapi2 });
|
|
689
|
-
await schedulingService.set(release2.id, release2.scheduledAt);
|
|
690
|
-
}
|
|
691
|
-
strapi2.telemetry.send("didCreateContentRelease");
|
|
692
|
-
return release2;
|
|
693
|
-
},
|
|
694
|
-
async findOne(id, query = {}) {
|
|
695
|
-
const dbQuery = strapi2.get("query-params").transform(RELEASE_MODEL_UID, query);
|
|
696
|
-
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
|
|
697
|
-
...dbQuery,
|
|
698
|
-
where: { id }
|
|
699
|
-
});
|
|
700
|
-
return release2;
|
|
701
|
-
},
|
|
702
|
-
findPage(query) {
|
|
703
|
-
const dbQuery = strapi2.get("query-params").transform(RELEASE_MODEL_UID, query ?? {});
|
|
704
|
-
return strapi2.db.query(RELEASE_MODEL_UID).findPage({
|
|
705
|
-
...dbQuery,
|
|
706
|
-
populate: {
|
|
707
|
-
actions: {
|
|
708
|
-
count: true
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
});
|
|
712
|
-
},
|
|
713
|
-
findMany(query) {
|
|
714
|
-
const dbQuery = strapi2.get("query-params").transform(RELEASE_MODEL_UID, query ?? {});
|
|
715
|
-
return strapi2.db.query(RELEASE_MODEL_UID).findMany({
|
|
716
|
-
...dbQuery
|
|
717
|
-
});
|
|
718
|
-
},
|
|
719
|
-
async update(id, releaseData, { user }) {
|
|
720
|
-
const releaseWithCreatorFields = await utils.setCreatorFields({ user, isEdition: true })(
|
|
721
|
-
releaseData
|
|
722
|
-
);
|
|
723
|
-
const { validateUniqueNameForPendingRelease, validateScheduledAtIsLaterThanNow } = getService(
|
|
724
|
-
"release-validation",
|
|
725
|
-
{ strapi: strapi2 }
|
|
726
|
-
);
|
|
727
|
-
await Promise.all([
|
|
728
|
-
validateUniqueNameForPendingRelease(releaseWithCreatorFields.name, id),
|
|
729
|
-
validateScheduledAtIsLaterThanNow(releaseWithCreatorFields.scheduledAt)
|
|
730
|
-
]);
|
|
731
|
-
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id } });
|
|
732
|
-
if (!release2) {
|
|
733
|
-
throw new utils.errors.NotFoundError(`No release found for id ${id}`);
|
|
734
|
-
}
|
|
735
|
-
if (release2.releasedAt) {
|
|
736
|
-
throw new utils.errors.ValidationError("Release already published");
|
|
737
|
-
}
|
|
738
|
-
const updatedRelease = await strapi2.db.query(RELEASE_MODEL_UID).update({
|
|
739
|
-
where: { id },
|
|
740
|
-
data: releaseWithCreatorFields
|
|
741
|
-
});
|
|
742
|
-
const schedulingService = getService("scheduling", { strapi: strapi2 });
|
|
743
|
-
if (releaseData.scheduledAt) {
|
|
744
|
-
await schedulingService.set(id, releaseData.scheduledAt);
|
|
745
|
-
} else if (release2.scheduledAt) {
|
|
746
|
-
schedulingService.cancel(id);
|
|
747
|
-
}
|
|
748
|
-
this.updateReleaseStatus(id);
|
|
749
|
-
strapi2.telemetry.send("didUpdateContentRelease");
|
|
750
|
-
return updatedRelease;
|
|
751
|
-
},
|
|
752
|
-
async getAllComponents() {
|
|
753
|
-
const contentManagerComponentsService = strapi2.plugin("content-manager").service("components");
|
|
754
|
-
const components = await contentManagerComponentsService.findAllComponents();
|
|
755
|
-
const componentsMap = components.reduce(
|
|
756
|
-
(acc, component) => {
|
|
757
|
-
acc[component.uid] = component;
|
|
758
|
-
return acc;
|
|
759
|
-
},
|
|
760
|
-
{}
|
|
761
|
-
);
|
|
762
|
-
return componentsMap;
|
|
763
|
-
},
|
|
764
|
-
async delete(releaseId) {
|
|
765
|
-
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
|
|
766
|
-
where: { id: releaseId },
|
|
767
|
-
populate: {
|
|
768
|
-
actions: {
|
|
769
|
-
select: ["id"]
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
});
|
|
773
|
-
if (!release2) {
|
|
774
|
-
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
775
|
-
}
|
|
776
|
-
if (release2.releasedAt) {
|
|
777
|
-
throw new utils.errors.ValidationError("Release already published");
|
|
778
|
-
}
|
|
779
|
-
await strapi2.db.transaction(async () => {
|
|
780
|
-
await strapi2.db.query(RELEASE_ACTION_MODEL_UID).deleteMany({
|
|
781
|
-
where: {
|
|
782
|
-
id: {
|
|
783
|
-
$in: release2.actions.map((action) => action.id)
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
});
|
|
787
|
-
await strapi2.db.query(RELEASE_MODEL_UID).delete({
|
|
788
|
-
where: {
|
|
789
|
-
id: releaseId
|
|
790
|
-
}
|
|
791
|
-
});
|
|
792
|
-
});
|
|
793
|
-
if (release2.scheduledAt) {
|
|
794
|
-
const schedulingService = getService("scheduling", { strapi: strapi2 });
|
|
795
|
-
await schedulingService.cancel(release2.id);
|
|
796
|
-
}
|
|
797
|
-
strapi2.telemetry.send("didDeleteContentRelease");
|
|
798
|
-
return release2;
|
|
799
|
-
},
|
|
800
|
-
async publish(releaseId) {
|
|
801
|
-
const {
|
|
802
|
-
release: release2,
|
|
803
|
-
error
|
|
804
|
-
} = await strapi2.db.transaction(async ({ trx }) => {
|
|
805
|
-
const lockedRelease = await strapi2.db?.queryBuilder(RELEASE_MODEL_UID).where({ id: releaseId }).select(["id", "name", "releasedAt", "status"]).first().transacting(trx).forUpdate().execute();
|
|
806
|
-
if (!lockedRelease) {
|
|
807
|
-
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
808
|
-
}
|
|
809
|
-
if (lockedRelease.releasedAt) {
|
|
810
|
-
throw new utils.errors.ValidationError("Release already published");
|
|
811
|
-
}
|
|
812
|
-
if (lockedRelease.status === "failed") {
|
|
813
|
-
throw new utils.errors.ValidationError("Release failed to publish");
|
|
814
|
-
}
|
|
815
|
-
try {
|
|
816
|
-
strapi2.log.info(`[Content Releases] Starting to publish release ${lockedRelease.name}`);
|
|
817
|
-
const formattedActions = await getFormattedActions(releaseId);
|
|
818
|
-
await strapi2.db.transaction(
|
|
819
|
-
async () => Promise.all(
|
|
820
|
-
Object.keys(formattedActions).map(async (contentTypeUid) => {
|
|
821
|
-
const contentType = contentTypeUid;
|
|
822
|
-
const { publish, unpublish } = formattedActions[contentType];
|
|
823
|
-
return Promise.all([
|
|
824
|
-
...publish.map((params) => strapi2.documents(contentType).publish(params)),
|
|
825
|
-
...unpublish.map((params) => strapi2.documents(contentType).unpublish(params))
|
|
826
|
-
]);
|
|
827
|
-
})
|
|
828
|
-
)
|
|
829
|
-
);
|
|
830
|
-
const release22 = await strapi2.db.query(RELEASE_MODEL_UID).update({
|
|
831
|
-
where: {
|
|
832
|
-
id: releaseId
|
|
833
|
-
},
|
|
834
|
-
data: {
|
|
835
|
-
status: "done",
|
|
836
|
-
releasedAt: /* @__PURE__ */ new Date()
|
|
837
|
-
}
|
|
838
|
-
});
|
|
839
|
-
dispatchWebhook(ALLOWED_WEBHOOK_EVENTS.RELEASES_PUBLISH, {
|
|
840
|
-
isPublished: true,
|
|
841
|
-
release: release22
|
|
842
|
-
});
|
|
843
|
-
strapi2.telemetry.send("didPublishContentRelease");
|
|
844
|
-
return { release: release22, error: null };
|
|
845
|
-
} catch (error2) {
|
|
846
|
-
dispatchWebhook(ALLOWED_WEBHOOK_EVENTS.RELEASES_PUBLISH, {
|
|
847
|
-
isPublished: false,
|
|
848
|
-
error: error2
|
|
849
|
-
});
|
|
850
|
-
await strapi2.db?.queryBuilder(RELEASE_MODEL_UID).where({ id: releaseId }).update({
|
|
851
|
-
status: "failed"
|
|
852
|
-
}).transacting(trx).execute();
|
|
853
|
-
return {
|
|
854
|
-
release: null,
|
|
855
|
-
error: error2
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
});
|
|
859
|
-
if (error instanceof Error) {
|
|
860
|
-
throw error;
|
|
861
|
-
}
|
|
862
|
-
return release2;
|
|
863
|
-
},
|
|
864
|
-
async updateReleaseStatus(releaseId) {
|
|
865
|
-
const releaseActionService = getService("release-action", { strapi: strapi2 });
|
|
866
|
-
const [totalActions, invalidActions] = await Promise.all([
|
|
867
|
-
releaseActionService.countActions({
|
|
868
|
-
filters: {
|
|
869
|
-
release: releaseId
|
|
870
|
-
}
|
|
871
|
-
}),
|
|
872
|
-
releaseActionService.countActions({
|
|
873
|
-
filters: {
|
|
874
|
-
release: releaseId,
|
|
875
|
-
isEntryValid: false
|
|
876
|
-
}
|
|
877
|
-
})
|
|
878
|
-
]);
|
|
879
|
-
if (totalActions > 0) {
|
|
880
|
-
if (invalidActions > 0) {
|
|
881
|
-
return strapi2.db.query(RELEASE_MODEL_UID).update({
|
|
882
|
-
where: {
|
|
883
|
-
id: releaseId
|
|
884
|
-
},
|
|
885
|
-
data: {
|
|
886
|
-
status: "blocked"
|
|
887
|
-
}
|
|
888
|
-
});
|
|
889
|
-
}
|
|
890
|
-
return strapi2.db.query(RELEASE_MODEL_UID).update({
|
|
891
|
-
where: {
|
|
892
|
-
id: releaseId
|
|
893
|
-
},
|
|
894
|
-
data: {
|
|
895
|
-
status: "ready"
|
|
896
|
-
}
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
return strapi2.db.query(RELEASE_MODEL_UID).update({
|
|
900
|
-
where: {
|
|
901
|
-
id: releaseId
|
|
902
|
-
},
|
|
903
|
-
data: {
|
|
904
|
-
status: "empty"
|
|
905
|
-
}
|
|
906
|
-
});
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
};
|
|
910
|
-
const getGroupName = (queryValue) => {
|
|
911
|
-
switch (queryValue) {
|
|
912
|
-
case "contentType":
|
|
913
|
-
return "contentType.displayName";
|
|
914
|
-
case "type":
|
|
915
|
-
return "type";
|
|
916
|
-
case "locale":
|
|
917
|
-
return ___default.default.getOr("No locale", "locale.name");
|
|
918
|
-
default:
|
|
919
|
-
return "contentType.displayName";
|
|
920
|
-
}
|
|
921
|
-
};
|
|
922
|
-
const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
923
|
-
const getLocalesDataForActions = async () => {
|
|
924
|
-
if (!strapi2.plugin("i18n")) {
|
|
925
|
-
return {};
|
|
926
|
-
}
|
|
927
|
-
const allLocales = await strapi2.plugin("i18n").service("locales").find() || [];
|
|
928
|
-
return allLocales.reduce((acc, locale) => {
|
|
929
|
-
acc[locale.code] = { name: locale.name, code: locale.code };
|
|
930
|
-
return acc;
|
|
931
|
-
}, {});
|
|
932
|
-
};
|
|
933
|
-
const getContentTypesDataForActions = async (contentTypesUids) => {
|
|
934
|
-
const contentManagerContentTypeService = strapi2.plugin("content-manager").service("content-types");
|
|
935
|
-
const contentTypesData = {};
|
|
936
|
-
for (const contentTypeUid of contentTypesUids) {
|
|
937
|
-
const contentTypeConfig = await contentManagerContentTypeService.findConfiguration({
|
|
938
|
-
uid: contentTypeUid
|
|
939
|
-
});
|
|
940
|
-
contentTypesData[contentTypeUid] = {
|
|
941
|
-
mainField: contentTypeConfig.settings.mainField,
|
|
942
|
-
displayName: strapi2.getModel(contentTypeUid).info.displayName
|
|
943
|
-
};
|
|
944
|
-
}
|
|
945
|
-
return contentTypesData;
|
|
946
|
-
};
|
|
947
|
-
return {
|
|
948
|
-
async create(releaseId, action, { disableUpdateReleaseStatus = false } = {}) {
|
|
949
|
-
const { validateEntryData, validateUniqueEntry } = getService("release-validation", {
|
|
950
|
-
strapi: strapi2
|
|
951
|
-
});
|
|
952
|
-
await Promise.all([
|
|
953
|
-
validateEntryData(action.contentType, action.entryDocumentId),
|
|
954
|
-
validateUniqueEntry(releaseId, action)
|
|
955
|
-
]);
|
|
956
|
-
const model = strapi2.contentType(action.contentType);
|
|
957
|
-
if (model.kind === "singleType") {
|
|
958
|
-
const document = await strapi2.db.query(model.uid).findOne({ select: ["documentId"] });
|
|
959
|
-
if (!document) {
|
|
960
|
-
throw new utils.errors.NotFoundError(`No entry found for contentType ${action.contentType}`);
|
|
961
|
-
}
|
|
962
|
-
action.entryDocumentId = document.documentId;
|
|
963
|
-
}
|
|
964
|
-
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id: releaseId } });
|
|
965
|
-
if (!release2) {
|
|
966
|
-
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
967
|
-
}
|
|
968
|
-
if (release2.releasedAt) {
|
|
969
|
-
throw new utils.errors.ValidationError("Release already published");
|
|
970
|
-
}
|
|
971
|
-
const actionStatus = action.type === "publish" ? await getDraftEntryValidStatus(
|
|
972
|
-
{
|
|
973
|
-
contentType: action.contentType,
|
|
974
|
-
documentId: action.entryDocumentId,
|
|
975
|
-
locale: action.locale
|
|
976
|
-
},
|
|
977
|
-
{
|
|
978
|
-
strapi: strapi2
|
|
979
|
-
}
|
|
980
|
-
) : true;
|
|
981
|
-
const releaseAction2 = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).create({
|
|
982
|
-
data: {
|
|
983
|
-
...action,
|
|
984
|
-
release: release2.id,
|
|
985
|
-
isEntryValid: actionStatus
|
|
986
|
-
},
|
|
987
|
-
populate: { release: { select: ["id"] } }
|
|
988
|
-
});
|
|
989
|
-
if (!disableUpdateReleaseStatus) {
|
|
990
|
-
getService("release", { strapi: strapi2 }).updateReleaseStatus(release2.id);
|
|
991
|
-
}
|
|
992
|
-
return releaseAction2;
|
|
993
|
-
},
|
|
994
|
-
async findPage(releaseId, query) {
|
|
995
|
-
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
|
|
996
|
-
where: { id: releaseId },
|
|
997
|
-
select: ["id"]
|
|
998
|
-
});
|
|
999
|
-
if (!release2) {
|
|
1000
|
-
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
1001
|
-
}
|
|
1002
|
-
const dbQuery = strapi2.get("query-params").transform(RELEASE_ACTION_MODEL_UID, query ?? {});
|
|
1003
|
-
const { results: actions, pagination } = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).findPage({
|
|
1004
|
-
...dbQuery,
|
|
1005
|
-
where: {
|
|
1006
|
-
release: releaseId
|
|
1007
|
-
}
|
|
1008
|
-
});
|
|
1009
|
-
const populateBuilderService = strapi2.plugin("content-manager").service("populate-builder");
|
|
1010
|
-
const actionsWithEntry = await utils.async.map(actions, async (action) => {
|
|
1011
|
-
const populate = await populateBuilderService(action.contentType).populateDeep(Infinity).build();
|
|
1012
|
-
const entry = await getEntry(
|
|
1013
|
-
{
|
|
1014
|
-
contentType: action.contentType,
|
|
1015
|
-
documentId: action.entryDocumentId,
|
|
1016
|
-
locale: action.locale,
|
|
1017
|
-
populate,
|
|
1018
|
-
status: action.type === "publish" ? "draft" : "published"
|
|
1019
|
-
},
|
|
1020
|
-
{ strapi: strapi2 }
|
|
1021
|
-
);
|
|
1022
|
-
return {
|
|
1023
|
-
...action,
|
|
1024
|
-
entry,
|
|
1025
|
-
status: entry ? await getEntryStatus(action.contentType, entry) : null
|
|
1026
|
-
};
|
|
1027
|
-
});
|
|
1028
|
-
return {
|
|
1029
|
-
results: actionsWithEntry,
|
|
1030
|
-
pagination
|
|
1031
|
-
};
|
|
1032
|
-
},
|
|
1033
|
-
async groupActions(actions, groupBy) {
|
|
1034
|
-
const contentTypeUids = actions.reduce((acc, action) => {
|
|
1035
|
-
if (!acc.includes(action.contentType)) {
|
|
1036
|
-
acc.push(action.contentType);
|
|
1037
|
-
}
|
|
1038
|
-
return acc;
|
|
1039
|
-
}, []);
|
|
1040
|
-
const allReleaseContentTypesDictionary = await getContentTypesDataForActions(contentTypeUids);
|
|
1041
|
-
const allLocalesDictionary = await getLocalesDataForActions();
|
|
1042
|
-
const formattedData = actions.map((action) => {
|
|
1043
|
-
const { mainField, displayName } = allReleaseContentTypesDictionary[action.contentType];
|
|
1044
|
-
return {
|
|
1045
|
-
...action,
|
|
1046
|
-
locale: action.locale ? allLocalesDictionary[action.locale] : null,
|
|
1047
|
-
contentType: {
|
|
1048
|
-
displayName,
|
|
1049
|
-
mainFieldValue: action.entry[mainField],
|
|
1050
|
-
uid: action.contentType
|
|
1051
|
-
}
|
|
1052
|
-
};
|
|
1053
|
-
});
|
|
1054
|
-
const groupName = getGroupName(groupBy);
|
|
1055
|
-
return ___default.default.groupBy(groupName)(formattedData);
|
|
1056
|
-
},
|
|
1057
|
-
async getContentTypeModelsFromActions(actions) {
|
|
1058
|
-
const contentTypeUids = actions.reduce((acc, action) => {
|
|
1059
|
-
if (!acc.includes(action.contentType)) {
|
|
1060
|
-
acc.push(action.contentType);
|
|
1061
|
-
}
|
|
1062
|
-
return acc;
|
|
1063
|
-
}, []);
|
|
1064
|
-
const workflowsService = strapi2.plugin("review-workflows").service("workflows");
|
|
1065
|
-
const contentTypeModelsMap = await utils.async.reduce(contentTypeUids)(
|
|
1066
|
-
async (accPromise, contentTypeUid) => {
|
|
1067
|
-
const acc = await accPromise;
|
|
1068
|
-
const contentTypeModel = strapi2.getModel(contentTypeUid);
|
|
1069
|
-
const workflow = await workflowsService.getAssignedWorkflow(contentTypeUid, {
|
|
1070
|
-
populate: "stageRequiredToPublish"
|
|
1071
|
-
});
|
|
1072
|
-
acc[contentTypeUid] = {
|
|
1073
|
-
...contentTypeModel,
|
|
1074
|
-
hasReviewWorkflow: !!workflow,
|
|
1075
|
-
stageRequiredToPublish: workflow?.stageRequiredToPublish
|
|
1076
|
-
};
|
|
1077
|
-
return acc;
|
|
1078
|
-
},
|
|
1079
|
-
{}
|
|
1080
|
-
);
|
|
1081
|
-
return contentTypeModelsMap;
|
|
1082
|
-
},
|
|
1083
|
-
async countActions(query) {
|
|
1084
|
-
const dbQuery = strapi2.get("query-params").transform(RELEASE_ACTION_MODEL_UID, query ?? {});
|
|
1085
|
-
return strapi2.db.query(RELEASE_ACTION_MODEL_UID).count(dbQuery);
|
|
1086
|
-
},
|
|
1087
|
-
async update(actionId, releaseId, update) {
|
|
1088
|
-
const action = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).findOne({
|
|
1089
|
-
where: {
|
|
1090
|
-
id: actionId,
|
|
1091
|
-
release: {
|
|
1092
|
-
id: releaseId,
|
|
1093
|
-
releasedAt: {
|
|
1094
|
-
$null: true
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
});
|
|
1099
|
-
if (!action) {
|
|
1100
|
-
throw new utils.errors.NotFoundError(
|
|
1101
|
-
`Action with id ${actionId} not found in release with id ${releaseId} or it is already published`
|
|
1102
|
-
);
|
|
1103
|
-
}
|
|
1104
|
-
const actionStatus = update.type === "publish" ? await getDraftEntryValidStatus(
|
|
1105
|
-
{
|
|
1106
|
-
contentType: action.contentType,
|
|
1107
|
-
documentId: action.entryDocumentId,
|
|
1108
|
-
locale: action.locale
|
|
1109
|
-
},
|
|
1110
|
-
{
|
|
1111
|
-
strapi: strapi2
|
|
1112
|
-
}
|
|
1113
|
-
) : true;
|
|
1114
|
-
const updatedAction = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).update({
|
|
1115
|
-
where: {
|
|
1116
|
-
id: actionId,
|
|
1117
|
-
release: {
|
|
1118
|
-
id: releaseId,
|
|
1119
|
-
releasedAt: {
|
|
1120
|
-
$null: true
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
},
|
|
1124
|
-
data: {
|
|
1125
|
-
...update,
|
|
1126
|
-
isEntryValid: actionStatus
|
|
1127
|
-
}
|
|
1128
|
-
});
|
|
1129
|
-
getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
|
|
1130
|
-
return updatedAction;
|
|
1131
|
-
},
|
|
1132
|
-
async delete(actionId, releaseId) {
|
|
1133
|
-
const deletedAction = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).delete({
|
|
1134
|
-
where: {
|
|
1135
|
-
id: actionId,
|
|
1136
|
-
release: {
|
|
1137
|
-
id: releaseId,
|
|
1138
|
-
releasedAt: {
|
|
1139
|
-
$null: true
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
});
|
|
1144
|
-
if (!deletedAction) {
|
|
1145
|
-
throw new utils.errors.NotFoundError(
|
|
1146
|
-
`Action with id ${actionId} not found in release with id ${releaseId} or it is already published`
|
|
1147
|
-
);
|
|
1148
|
-
}
|
|
1149
|
-
getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
|
|
1150
|
-
return deletedAction;
|
|
1151
|
-
},
|
|
1152
|
-
async validateActionsByContentTypes(contentTypeUids) {
|
|
1153
|
-
const actions = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).findMany({
|
|
1154
|
-
where: {
|
|
1155
|
-
contentType: {
|
|
1156
|
-
$in: contentTypeUids
|
|
1157
|
-
},
|
|
1158
|
-
// We only want to validate actions that are going to be published
|
|
1159
|
-
type: "publish",
|
|
1160
|
-
release: {
|
|
1161
|
-
releasedAt: {
|
|
1162
|
-
$null: true
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
},
|
|
1166
|
-
populate: { release: true }
|
|
1167
|
-
});
|
|
1168
|
-
const releasesUpdated = [];
|
|
1169
|
-
await utils.async.map(actions, async (action) => {
|
|
1170
|
-
const isValid = await getDraftEntryValidStatus(
|
|
1171
|
-
{
|
|
1172
|
-
contentType: action.contentType,
|
|
1173
|
-
documentId: action.entryDocumentId,
|
|
1174
|
-
locale: action.locale
|
|
1175
|
-
},
|
|
1176
|
-
{ strapi: strapi2 }
|
|
1177
|
-
);
|
|
1178
|
-
await strapi2.db.query(RELEASE_ACTION_MODEL_UID).update({
|
|
1179
|
-
where: {
|
|
1180
|
-
id: action.id
|
|
1181
|
-
},
|
|
1182
|
-
data: {
|
|
1183
|
-
isEntryValid: isValid
|
|
1184
|
-
}
|
|
1185
|
-
});
|
|
1186
|
-
if (!releasesUpdated.includes(action.release.id)) {
|
|
1187
|
-
releasesUpdated.push(action.release.id);
|
|
1188
|
-
}
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var register = require('./register.js');
|
|
4
|
+
var bootstrap = require('./bootstrap.js');
|
|
5
|
+
var destroy = require('./destroy.js');
|
|
6
|
+
var index$1 = require('./content-types/index.js');
|
|
7
|
+
var index$2 = require('./services/index.js');
|
|
8
|
+
var index$3 = require('./controllers/index.js');
|
|
9
|
+
var index$4 = require('./routes/index.js');
|
|
10
|
+
|
|
11
|
+
const getPlugin = ()=>{
|
|
12
|
+
if (strapi.ee.features.isEnabled('cms-content-releases')) {
|
|
1189
13
|
return {
|
|
1190
|
-
|
|
1191
|
-
|
|
14
|
+
register: register.register,
|
|
15
|
+
bootstrap: bootstrap.bootstrap,
|
|
16
|
+
destroy: destroy.destroy,
|
|
17
|
+
contentTypes: index$1.contentTypes,
|
|
18
|
+
services: index$2.services,
|
|
19
|
+
controllers: index$3.controllers,
|
|
20
|
+
routes: index$4.routes
|
|
1192
21
|
};
|
|
1193
|
-
});
|
|
1194
|
-
if (releasesUpdated.length > 0) {
|
|
1195
|
-
await utils.async.map(releasesUpdated, async (releaseId) => {
|
|
1196
|
-
await getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
};
|
|
1201
|
-
};
|
|
1202
|
-
class AlreadyOnReleaseError extends utils.errors.ApplicationError {
|
|
1203
|
-
constructor(message) {
|
|
1204
|
-
super(message);
|
|
1205
|
-
this.name = "AlreadyOnReleaseError";
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
const createReleaseValidationService = ({ strapi: strapi2 }) => ({
|
|
1209
|
-
async validateUniqueEntry(releaseId, releaseActionArgs) {
|
|
1210
|
-
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
|
|
1211
|
-
where: {
|
|
1212
|
-
id: releaseId
|
|
1213
|
-
},
|
|
1214
|
-
populate: {
|
|
1215
|
-
actions: true
|
|
1216
|
-
}
|
|
1217
|
-
});
|
|
1218
|
-
if (!release2) {
|
|
1219
|
-
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
1220
|
-
}
|
|
1221
|
-
const isEntryInRelease = release2.actions.some(
|
|
1222
|
-
(action) => action.entryDocumentId === releaseActionArgs.entryDocumentId && action.contentType === releaseActionArgs.contentType && (releaseActionArgs.locale ? action.locale === releaseActionArgs.locale : true)
|
|
1223
|
-
);
|
|
1224
|
-
if (isEntryInRelease) {
|
|
1225
|
-
throw new AlreadyOnReleaseError(
|
|
1226
|
-
`Entry with documentId ${releaseActionArgs.entryDocumentId}${releaseActionArgs.locale ? `( ${releaseActionArgs.locale})` : ""} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`
|
|
1227
|
-
);
|
|
1228
|
-
}
|
|
1229
|
-
},
|
|
1230
|
-
validateEntryData(contentTypeUid, entryDocumentId) {
|
|
1231
|
-
const contentType = strapi2.contentType(contentTypeUid);
|
|
1232
|
-
if (!contentType) {
|
|
1233
|
-
throw new utils.errors.NotFoundError(`No content type found for uid ${contentTypeUid}`);
|
|
1234
|
-
}
|
|
1235
|
-
if (!utils.contentTypes.hasDraftAndPublish(contentType)) {
|
|
1236
|
-
throw new utils.errors.ValidationError(
|
|
1237
|
-
`Content type with uid ${contentTypeUid} does not have draftAndPublish enabled`
|
|
1238
|
-
);
|
|
1239
|
-
}
|
|
1240
|
-
if (contentType.kind === "collectionType" && !entryDocumentId) {
|
|
1241
|
-
throw new utils.errors.ValidationError("Document id is required for collection type");
|
|
1242
|
-
}
|
|
1243
|
-
},
|
|
1244
|
-
async validatePendingReleasesLimit() {
|
|
1245
|
-
const featureCfg = strapi2.ee.features.get("cms-content-releases");
|
|
1246
|
-
const maximumPendingReleases = typeof featureCfg === "object" && featureCfg?.options?.maximumReleases || 3;
|
|
1247
|
-
const [, pendingReleasesCount] = await strapi2.db.query(RELEASE_MODEL_UID).findWithCount({
|
|
1248
|
-
filters: {
|
|
1249
|
-
releasedAt: {
|
|
1250
|
-
$null: true
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
});
|
|
1254
|
-
if (pendingReleasesCount >= maximumPendingReleases) {
|
|
1255
|
-
throw new utils.errors.ValidationError("You have reached the maximum number of pending releases");
|
|
1256
|
-
}
|
|
1257
|
-
},
|
|
1258
|
-
async validateUniqueNameForPendingRelease(name, id) {
|
|
1259
|
-
const pendingReleases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
|
|
1260
|
-
where: {
|
|
1261
|
-
releasedAt: {
|
|
1262
|
-
$null: true
|
|
1263
|
-
},
|
|
1264
|
-
name,
|
|
1265
|
-
...id && { id: { $ne: id } }
|
|
1266
|
-
}
|
|
1267
|
-
});
|
|
1268
|
-
const isNameUnique = pendingReleases.length === 0;
|
|
1269
|
-
if (!isNameUnique) {
|
|
1270
|
-
throw new utils.errors.ValidationError(`Release with name ${name} already exists`);
|
|
1271
|
-
}
|
|
1272
|
-
},
|
|
1273
|
-
async validateScheduledAtIsLaterThanNow(scheduledAt) {
|
|
1274
|
-
if (scheduledAt && new Date(scheduledAt) <= /* @__PURE__ */ new Date()) {
|
|
1275
|
-
throw new utils.errors.ValidationError("Scheduled at must be later than now");
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
});
|
|
1279
|
-
const createSchedulingService = ({ strapi: strapi2 }) => {
|
|
1280
|
-
const scheduledJobs = /* @__PURE__ */ new Map();
|
|
1281
|
-
return {
|
|
1282
|
-
async set(releaseId, scheduleDate) {
|
|
1283
|
-
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id: releaseId, releasedAt: null } });
|
|
1284
|
-
if (!release2) {
|
|
1285
|
-
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
1286
|
-
}
|
|
1287
|
-
const job = nodeSchedule.scheduleJob(scheduleDate, async () => {
|
|
1288
|
-
try {
|
|
1289
|
-
await getService("release", { strapi: strapi2 }).publish(releaseId);
|
|
1290
|
-
} catch (error) {
|
|
1291
|
-
}
|
|
1292
|
-
this.cancel(releaseId);
|
|
1293
|
-
});
|
|
1294
|
-
if (scheduledJobs.has(releaseId)) {
|
|
1295
|
-
this.cancel(releaseId);
|
|
1296
|
-
}
|
|
1297
|
-
scheduledJobs.set(releaseId, job);
|
|
1298
|
-
return scheduledJobs;
|
|
1299
|
-
},
|
|
1300
|
-
cancel(releaseId) {
|
|
1301
|
-
if (scheduledJobs.has(releaseId)) {
|
|
1302
|
-
scheduledJobs.get(releaseId).cancel();
|
|
1303
|
-
scheduledJobs.delete(releaseId);
|
|
1304
|
-
}
|
|
1305
|
-
return scheduledJobs;
|
|
1306
|
-
},
|
|
1307
|
-
getAll() {
|
|
1308
|
-
return scheduledJobs;
|
|
1309
|
-
},
|
|
1310
|
-
/**
|
|
1311
|
-
* On bootstrap, we can use this function to make sure to sync the scheduled jobs from the database that are not yet released
|
|
1312
|
-
* This is useful in case the server was restarted and the scheduled jobs were lost
|
|
1313
|
-
* This also could be used to sync different Strapi instances in case of a cluster
|
|
1314
|
-
*/
|
|
1315
|
-
async syncFromDatabase() {
|
|
1316
|
-
const releases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
|
|
1317
|
-
where: {
|
|
1318
|
-
scheduledAt: {
|
|
1319
|
-
$gte: /* @__PURE__ */ new Date()
|
|
1320
|
-
},
|
|
1321
|
-
releasedAt: null
|
|
1322
|
-
}
|
|
1323
|
-
});
|
|
1324
|
-
for (const release2 of releases) {
|
|
1325
|
-
this.set(release2.id, release2.scheduledAt);
|
|
1326
|
-
}
|
|
1327
|
-
return scheduledJobs;
|
|
1328
|
-
}
|
|
1329
|
-
};
|
|
1330
|
-
};
|
|
1331
|
-
const DEFAULT_SETTINGS = {
|
|
1332
|
-
defaultTimezone: null
|
|
1333
|
-
};
|
|
1334
|
-
const createSettingsService = ({ strapi: strapi2 }) => {
|
|
1335
|
-
const getStore = async () => strapi2.store({ type: "core", name: "content-releases" });
|
|
1336
|
-
return {
|
|
1337
|
-
async update({ settings: settings2 }) {
|
|
1338
|
-
const store = await getStore();
|
|
1339
|
-
store.set({ key: "settings", value: settings2 });
|
|
1340
|
-
return settings2;
|
|
1341
|
-
},
|
|
1342
|
-
async find() {
|
|
1343
|
-
const store = await getStore();
|
|
1344
|
-
const settings2 = await store.get({ key: "settings" });
|
|
1345
|
-
return {
|
|
1346
|
-
...DEFAULT_SETTINGS,
|
|
1347
|
-
...settings2 || {}
|
|
1348
|
-
};
|
|
1349
|
-
}
|
|
1350
|
-
};
|
|
1351
|
-
};
|
|
1352
|
-
const services = {
|
|
1353
|
-
release: createReleaseService,
|
|
1354
|
-
"release-action": createReleaseActionService,
|
|
1355
|
-
"release-validation": createReleaseValidationService,
|
|
1356
|
-
scheduling: createSchedulingService,
|
|
1357
|
-
settings: createSettingsService
|
|
1358
|
-
};
|
|
1359
|
-
const RELEASE_SCHEMA = utils.yup.object().shape({
|
|
1360
|
-
name: utils.yup.string().trim().required(),
|
|
1361
|
-
scheduledAt: utils.yup.string().nullable(),
|
|
1362
|
-
timezone: utils.yup.string().when("scheduledAt", {
|
|
1363
|
-
is: (value) => value !== null && value !== void 0,
|
|
1364
|
-
then: utils.yup.string().required(),
|
|
1365
|
-
otherwise: utils.yup.string().nullable()
|
|
1366
|
-
})
|
|
1367
|
-
}).required().noUnknown();
|
|
1368
|
-
const FIND_BY_DOCUMENT_ATTACHED_PARAMS_SCHEMA = utils.yup.object().shape({
|
|
1369
|
-
contentType: utils.yup.string().required(),
|
|
1370
|
-
entryDocumentId: utils.yup.string().nullable(),
|
|
1371
|
-
hasEntryAttached: utils.yup.string().nullable(),
|
|
1372
|
-
locale: utils.yup.string().nullable()
|
|
1373
|
-
}).required().noUnknown();
|
|
1374
|
-
const validateRelease = utils.validateYupSchema(RELEASE_SCHEMA);
|
|
1375
|
-
const validatefindByDocumentAttachedParams = utils.validateYupSchema(
|
|
1376
|
-
FIND_BY_DOCUMENT_ATTACHED_PARAMS_SCHEMA
|
|
1377
|
-
);
|
|
1378
|
-
const releaseController = {
|
|
1379
|
-
/**
|
|
1380
|
-
* Find releases based on documents attached or not to the release.
|
|
1381
|
-
* If `hasEntryAttached` is true, it will return all releases that have the entry attached.
|
|
1382
|
-
* If `hasEntryAttached` is false, it will return all releases that don't have the entry attached.
|
|
1383
|
-
*/
|
|
1384
|
-
async findByDocumentAttached(ctx) {
|
|
1385
|
-
const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
|
|
1386
|
-
ability: ctx.state.userAbility,
|
|
1387
|
-
model: RELEASE_MODEL_UID
|
|
1388
|
-
});
|
|
1389
|
-
await permissionsManager.validateQuery(ctx.query);
|
|
1390
|
-
const releaseService = getService("release", { strapi });
|
|
1391
|
-
const query = await permissionsManager.sanitizeQuery(ctx.query);
|
|
1392
|
-
await validatefindByDocumentAttachedParams(query);
|
|
1393
|
-
const model = strapi.getModel(query.contentType);
|
|
1394
|
-
if (model.kind && model.kind === "singleType") {
|
|
1395
|
-
const document = await strapi.db.query(model.uid).findOne({ select: ["documentId"] });
|
|
1396
|
-
if (!document) {
|
|
1397
|
-
throw new utils.errors.NotFoundError(`No entry found for contentType ${query.contentType}`);
|
|
1398
|
-
}
|
|
1399
|
-
query.entryDocumentId = document.documentId;
|
|
1400
|
-
}
|
|
1401
|
-
const { contentType, hasEntryAttached, entryDocumentId, locale } = query;
|
|
1402
|
-
const isEntryAttached = typeof hasEntryAttached === "string" ? Boolean(JSON.parse(hasEntryAttached)) : false;
|
|
1403
|
-
if (isEntryAttached) {
|
|
1404
|
-
const releases = await releaseService.findMany({
|
|
1405
|
-
where: {
|
|
1406
|
-
releasedAt: null,
|
|
1407
|
-
actions: {
|
|
1408
|
-
contentType,
|
|
1409
|
-
entryDocumentId: entryDocumentId ?? null,
|
|
1410
|
-
locale: locale ?? null
|
|
1411
|
-
}
|
|
1412
|
-
},
|
|
1413
|
-
populate: {
|
|
1414
|
-
actions: {
|
|
1415
|
-
fields: ["type"],
|
|
1416
|
-
filters: {
|
|
1417
|
-
contentType,
|
|
1418
|
-
entryDocumentId: entryDocumentId ?? null,
|
|
1419
|
-
locale: locale ?? null
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
});
|
|
1424
|
-
ctx.body = { data: releases };
|
|
1425
|
-
} else {
|
|
1426
|
-
const relatedReleases = await releaseService.findMany({
|
|
1427
|
-
where: {
|
|
1428
|
-
releasedAt: null,
|
|
1429
|
-
actions: {
|
|
1430
|
-
contentType,
|
|
1431
|
-
entryDocumentId: entryDocumentId ?? null,
|
|
1432
|
-
locale: locale ?? null
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
});
|
|
1436
|
-
const releases = await releaseService.findMany({
|
|
1437
|
-
where: {
|
|
1438
|
-
$or: [
|
|
1439
|
-
{
|
|
1440
|
-
id: {
|
|
1441
|
-
$notIn: relatedReleases.map((release2) => release2.id)
|
|
1442
|
-
}
|
|
1443
|
-
},
|
|
1444
|
-
{
|
|
1445
|
-
actions: null
|
|
1446
|
-
}
|
|
1447
|
-
],
|
|
1448
|
-
releasedAt: null
|
|
1449
|
-
}
|
|
1450
|
-
});
|
|
1451
|
-
ctx.body = { data: releases };
|
|
1452
|
-
}
|
|
1453
|
-
},
|
|
1454
|
-
async findPage(ctx) {
|
|
1455
|
-
const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
|
|
1456
|
-
ability: ctx.state.userAbility,
|
|
1457
|
-
model: RELEASE_MODEL_UID
|
|
1458
|
-
});
|
|
1459
|
-
await permissionsManager.validateQuery(ctx.query);
|
|
1460
|
-
const releaseService = getService("release", { strapi });
|
|
1461
|
-
const query = await permissionsManager.sanitizeQuery(ctx.query);
|
|
1462
|
-
const { results, pagination } = await releaseService.findPage(query);
|
|
1463
|
-
const data = results.map((release2) => {
|
|
1464
|
-
const { actions, ...releaseData } = release2;
|
|
1465
|
-
return {
|
|
1466
|
-
...releaseData,
|
|
1467
|
-
actions: {
|
|
1468
|
-
meta: {
|
|
1469
|
-
count: actions.count
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
};
|
|
1473
|
-
});
|
|
1474
|
-
const pendingReleasesCount = await strapi.db.query(RELEASE_MODEL_UID).count({
|
|
1475
|
-
where: {
|
|
1476
|
-
releasedAt: null
|
|
1477
|
-
}
|
|
1478
|
-
});
|
|
1479
|
-
ctx.body = { data, meta: { pagination, pendingReleasesCount } };
|
|
1480
|
-
},
|
|
1481
|
-
async findOne(ctx) {
|
|
1482
|
-
const id = ctx.params.id;
|
|
1483
|
-
const releaseService = getService("release", { strapi });
|
|
1484
|
-
const releaseActionService = getService("release-action", { strapi });
|
|
1485
|
-
const release2 = await releaseService.findOne(id, { populate: ["createdBy"] });
|
|
1486
|
-
if (!release2) {
|
|
1487
|
-
throw new utils.errors.NotFoundError(`Release not found for id: ${id}`);
|
|
1488
22
|
}
|
|
1489
|
-
const count = await releaseActionService.countActions({
|
|
1490
|
-
filters: {
|
|
1491
|
-
release: id
|
|
1492
|
-
}
|
|
1493
|
-
});
|
|
1494
|
-
const sanitizedRelease = {
|
|
1495
|
-
...release2,
|
|
1496
|
-
createdBy: release2.createdBy ? strapi.service("admin::user").sanitizeUser(release2.createdBy) : null
|
|
1497
|
-
};
|
|
1498
|
-
const data = {
|
|
1499
|
-
...sanitizedRelease,
|
|
1500
|
-
actions: {
|
|
1501
|
-
meta: {
|
|
1502
|
-
count
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
};
|
|
1506
|
-
ctx.body = { data };
|
|
1507
|
-
},
|
|
1508
|
-
async mapEntriesToReleases(ctx) {
|
|
1509
|
-
const { contentTypeUid, documentIds, locale } = ctx.query;
|
|
1510
|
-
if (!contentTypeUid || !documentIds) {
|
|
1511
|
-
throw new utils.errors.ValidationError("Missing required query parameters");
|
|
1512
|
-
}
|
|
1513
|
-
const releaseService = getService("release", { strapi });
|
|
1514
|
-
const releasesWithActions = await releaseService.findMany({
|
|
1515
|
-
where: {
|
|
1516
|
-
releasedAt: null,
|
|
1517
|
-
actions: {
|
|
1518
|
-
contentType: contentTypeUid,
|
|
1519
|
-
entryDocumentId: {
|
|
1520
|
-
$in: documentIds
|
|
1521
|
-
},
|
|
1522
|
-
locale
|
|
1523
|
-
}
|
|
1524
|
-
},
|
|
1525
|
-
populate: {
|
|
1526
|
-
actions: true
|
|
1527
|
-
}
|
|
1528
|
-
});
|
|
1529
|
-
const mappedEntriesInReleases = releasesWithActions.reduce(
|
|
1530
|
-
(acc, release2) => {
|
|
1531
|
-
release2.actions.forEach((action) => {
|
|
1532
|
-
if (action.contentType !== contentTypeUid) {
|
|
1533
|
-
return;
|
|
1534
|
-
}
|
|
1535
|
-
if (locale && action.locale !== locale) {
|
|
1536
|
-
return;
|
|
1537
|
-
}
|
|
1538
|
-
if (!acc[action.entryDocumentId]) {
|
|
1539
|
-
acc[action.entryDocumentId] = [{ id: release2.id, name: release2.name }];
|
|
1540
|
-
} else {
|
|
1541
|
-
acc[action.entryDocumentId].push({ id: release2.id, name: release2.name });
|
|
1542
|
-
}
|
|
1543
|
-
});
|
|
1544
|
-
return acc;
|
|
1545
|
-
},
|
|
1546
|
-
{}
|
|
1547
|
-
);
|
|
1548
|
-
ctx.body = {
|
|
1549
|
-
data: mappedEntriesInReleases
|
|
1550
|
-
};
|
|
1551
|
-
},
|
|
1552
|
-
async create(ctx) {
|
|
1553
|
-
const user = ctx.state.user;
|
|
1554
|
-
const releaseArgs = ctx.request.body;
|
|
1555
|
-
await validateRelease(releaseArgs);
|
|
1556
|
-
const releaseService = getService("release", { strapi });
|
|
1557
|
-
const release2 = await releaseService.create(releaseArgs, { user });
|
|
1558
|
-
const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
|
|
1559
|
-
ability: ctx.state.userAbility,
|
|
1560
|
-
model: RELEASE_MODEL_UID
|
|
1561
|
-
});
|
|
1562
|
-
ctx.created({
|
|
1563
|
-
data: await permissionsManager.sanitizeOutput(release2)
|
|
1564
|
-
});
|
|
1565
|
-
},
|
|
1566
|
-
async update(ctx) {
|
|
1567
|
-
const user = ctx.state.user;
|
|
1568
|
-
const releaseArgs = ctx.request.body;
|
|
1569
|
-
const id = ctx.params.id;
|
|
1570
|
-
await validateRelease(releaseArgs);
|
|
1571
|
-
const releaseService = getService("release", { strapi });
|
|
1572
|
-
const release2 = await releaseService.update(id, releaseArgs, { user });
|
|
1573
|
-
const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
|
|
1574
|
-
ability: ctx.state.userAbility,
|
|
1575
|
-
model: RELEASE_MODEL_UID
|
|
1576
|
-
});
|
|
1577
|
-
ctx.body = {
|
|
1578
|
-
data: await permissionsManager.sanitizeOutput(release2)
|
|
1579
|
-
};
|
|
1580
|
-
},
|
|
1581
|
-
async delete(ctx) {
|
|
1582
|
-
const id = ctx.params.id;
|
|
1583
|
-
const releaseService = getService("release", { strapi });
|
|
1584
|
-
const release2 = await releaseService.delete(id);
|
|
1585
|
-
ctx.body = {
|
|
1586
|
-
data: release2
|
|
1587
|
-
};
|
|
1588
|
-
},
|
|
1589
|
-
async publish(ctx) {
|
|
1590
|
-
const id = ctx.params.id;
|
|
1591
|
-
const releaseService = getService("release", { strapi });
|
|
1592
|
-
const releaseActionService = getService("release-action", { strapi });
|
|
1593
|
-
const release2 = await releaseService.publish(id);
|
|
1594
|
-
const [countPublishActions, countUnpublishActions] = await Promise.all([
|
|
1595
|
-
releaseActionService.countActions({
|
|
1596
|
-
filters: {
|
|
1597
|
-
release: id,
|
|
1598
|
-
type: "publish"
|
|
1599
|
-
}
|
|
1600
|
-
}),
|
|
1601
|
-
releaseActionService.countActions({
|
|
1602
|
-
filters: {
|
|
1603
|
-
release: id,
|
|
1604
|
-
type: "unpublish"
|
|
1605
|
-
}
|
|
1606
|
-
})
|
|
1607
|
-
]);
|
|
1608
|
-
ctx.body = {
|
|
1609
|
-
data: release2,
|
|
1610
|
-
meta: {
|
|
1611
|
-
totalEntries: countPublishActions + countUnpublishActions,
|
|
1612
|
-
totalPublishedEntries: countPublishActions,
|
|
1613
|
-
totalUnpublishedEntries: countUnpublishActions
|
|
1614
|
-
}
|
|
1615
|
-
};
|
|
1616
|
-
}
|
|
1617
|
-
};
|
|
1618
|
-
const RELEASE_ACTION_SCHEMA = utils.yup.object().shape({
|
|
1619
|
-
contentType: utils.yup.string().required(),
|
|
1620
|
-
entryDocumentId: utils.yup.strapiID(),
|
|
1621
|
-
locale: utils.yup.string(),
|
|
1622
|
-
type: utils.yup.string().oneOf(["publish", "unpublish"]).required()
|
|
1623
|
-
});
|
|
1624
|
-
const RELEASE_ACTION_UPDATE_SCHEMA = utils.yup.object().shape({
|
|
1625
|
-
type: utils.yup.string().oneOf(["publish", "unpublish"]).required()
|
|
1626
|
-
});
|
|
1627
|
-
const FIND_MANY_ACTIONS_PARAMS = utils.yup.object().shape({
|
|
1628
|
-
groupBy: utils.yup.string().oneOf(["action", "contentType", "locale"])
|
|
1629
|
-
});
|
|
1630
|
-
const validateReleaseAction = utils.validateYupSchema(RELEASE_ACTION_SCHEMA);
|
|
1631
|
-
const validateReleaseActionUpdateSchema = utils.validateYupSchema(RELEASE_ACTION_UPDATE_SCHEMA);
|
|
1632
|
-
const validateFindManyActionsParams = utils.validateYupSchema(FIND_MANY_ACTIONS_PARAMS);
|
|
1633
|
-
const releaseActionController = {
|
|
1634
|
-
async create(ctx) {
|
|
1635
|
-
const releaseId = ctx.params.releaseId;
|
|
1636
|
-
const releaseActionArgs = ctx.request.body;
|
|
1637
|
-
await validateReleaseAction(releaseActionArgs);
|
|
1638
|
-
const releaseActionService = getService("release-action", { strapi });
|
|
1639
|
-
const releaseAction2 = await releaseActionService.create(releaseId, releaseActionArgs);
|
|
1640
|
-
ctx.created({
|
|
1641
|
-
data: releaseAction2
|
|
1642
|
-
});
|
|
1643
|
-
},
|
|
1644
|
-
async createMany(ctx) {
|
|
1645
|
-
const releaseId = ctx.params.releaseId;
|
|
1646
|
-
const releaseActionsArgs = ctx.request.body;
|
|
1647
|
-
await Promise.all(
|
|
1648
|
-
releaseActionsArgs.map((releaseActionArgs) => validateReleaseAction(releaseActionArgs))
|
|
1649
|
-
);
|
|
1650
|
-
const releaseActionService = getService("release-action", { strapi });
|
|
1651
|
-
const releaseService = getService("release", { strapi });
|
|
1652
|
-
const releaseActions = await strapi.db.transaction(async () => {
|
|
1653
|
-
const releaseActions2 = await Promise.all(
|
|
1654
|
-
releaseActionsArgs.map(async (releaseActionArgs) => {
|
|
1655
|
-
try {
|
|
1656
|
-
const action = await releaseActionService.create(releaseId, releaseActionArgs, {
|
|
1657
|
-
disableUpdateReleaseStatus: true
|
|
1658
|
-
});
|
|
1659
|
-
return action;
|
|
1660
|
-
} catch (error) {
|
|
1661
|
-
if (error instanceof AlreadyOnReleaseError) {
|
|
1662
|
-
return null;
|
|
1663
|
-
}
|
|
1664
|
-
throw error;
|
|
1665
|
-
}
|
|
1666
|
-
})
|
|
1667
|
-
);
|
|
1668
|
-
return releaseActions2;
|
|
1669
|
-
});
|
|
1670
|
-
const newReleaseActions = releaseActions.filter((action) => action !== null);
|
|
1671
|
-
if (newReleaseActions.length > 0) {
|
|
1672
|
-
releaseService.updateReleaseStatus(releaseId);
|
|
1673
|
-
}
|
|
1674
|
-
ctx.created({
|
|
1675
|
-
data: newReleaseActions,
|
|
1676
|
-
meta: {
|
|
1677
|
-
entriesAlreadyInRelease: releaseActions.length - newReleaseActions.length,
|
|
1678
|
-
totalEntries: releaseActions.length
|
|
1679
|
-
}
|
|
1680
|
-
});
|
|
1681
|
-
},
|
|
1682
|
-
async findMany(ctx) {
|
|
1683
|
-
const releaseId = ctx.params.releaseId;
|
|
1684
|
-
const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
|
|
1685
|
-
ability: ctx.state.userAbility,
|
|
1686
|
-
model: RELEASE_ACTION_MODEL_UID
|
|
1687
|
-
});
|
|
1688
|
-
await validateFindManyActionsParams(ctx.query);
|
|
1689
|
-
if (ctx.query.groupBy) {
|
|
1690
|
-
if (!["action", "contentType", "locale"].includes(ctx.query.groupBy)) {
|
|
1691
|
-
ctx.badRequest("Invalid groupBy parameter");
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
ctx.query.sort = ctx.query.groupBy === "action" ? "type" : ctx.query.groupBy;
|
|
1695
|
-
delete ctx.query.groupBy;
|
|
1696
|
-
const query = await permissionsManager.sanitizeQuery(ctx.query);
|
|
1697
|
-
const releaseActionService = getService("release-action", { strapi });
|
|
1698
|
-
const { results, pagination } = await releaseActionService.findPage(releaseId, {
|
|
1699
|
-
...query
|
|
1700
|
-
});
|
|
1701
|
-
const contentTypeOutputSanitizers = results.reduce((acc, action) => {
|
|
1702
|
-
if (acc[action.contentType]) {
|
|
1703
|
-
return acc;
|
|
1704
|
-
}
|
|
1705
|
-
const contentTypePermissionsManager = strapi.service("admin::permission").createPermissionsManager({
|
|
1706
|
-
ability: ctx.state.userAbility,
|
|
1707
|
-
model: action.contentType
|
|
1708
|
-
});
|
|
1709
|
-
acc[action.contentType] = contentTypePermissionsManager.sanitizeOutput;
|
|
1710
|
-
return acc;
|
|
1711
|
-
}, {});
|
|
1712
|
-
const sanitizedResults = await utils.async.map(results, async (action) => ({
|
|
1713
|
-
...action,
|
|
1714
|
-
entry: action.entry ? await contentTypeOutputSanitizers[action.contentType](action.entry) : {}
|
|
1715
|
-
}));
|
|
1716
|
-
const groupedData = await releaseActionService.groupActions(sanitizedResults, query.sort);
|
|
1717
|
-
const contentTypes2 = await releaseActionService.getContentTypeModelsFromActions(results);
|
|
1718
|
-
const releaseService = getService("release", { strapi });
|
|
1719
|
-
const components = await releaseService.getAllComponents();
|
|
1720
|
-
ctx.body = {
|
|
1721
|
-
data: groupedData,
|
|
1722
|
-
meta: {
|
|
1723
|
-
pagination,
|
|
1724
|
-
contentTypes: contentTypes2,
|
|
1725
|
-
components
|
|
1726
|
-
}
|
|
1727
|
-
};
|
|
1728
|
-
},
|
|
1729
|
-
async update(ctx) {
|
|
1730
|
-
const actionId = ctx.params.actionId;
|
|
1731
|
-
const releaseId = ctx.params.releaseId;
|
|
1732
|
-
const releaseActionUpdateArgs = ctx.request.body;
|
|
1733
|
-
await validateReleaseActionUpdateSchema(releaseActionUpdateArgs);
|
|
1734
|
-
const releaseActionService = getService("release-action", { strapi });
|
|
1735
|
-
const updatedAction = await releaseActionService.update(
|
|
1736
|
-
actionId,
|
|
1737
|
-
releaseId,
|
|
1738
|
-
releaseActionUpdateArgs
|
|
1739
|
-
);
|
|
1740
|
-
ctx.body = {
|
|
1741
|
-
data: updatedAction
|
|
1742
|
-
};
|
|
1743
|
-
},
|
|
1744
|
-
async delete(ctx) {
|
|
1745
|
-
const actionId = ctx.params.actionId;
|
|
1746
|
-
const releaseId = ctx.params.releaseId;
|
|
1747
|
-
const releaseActionService = getService("release-action", { strapi });
|
|
1748
|
-
const deletedReleaseAction = await releaseActionService.delete(actionId, releaseId);
|
|
1749
|
-
ctx.body = {
|
|
1750
|
-
data: deletedReleaseAction
|
|
1751
|
-
};
|
|
1752
|
-
}
|
|
1753
|
-
};
|
|
1754
|
-
const SETTINGS_SCHEMA = yup__namespace.object().shape({
|
|
1755
|
-
defaultTimezone: yup__namespace.string().nullable().default(null)
|
|
1756
|
-
}).required().noUnknown();
|
|
1757
|
-
const validateSettings = utils.validateYupSchema(SETTINGS_SCHEMA);
|
|
1758
|
-
const settingsController = {
|
|
1759
|
-
async find(ctx) {
|
|
1760
|
-
const settingsService = getService("settings", { strapi });
|
|
1761
|
-
const settings2 = await settingsService.find();
|
|
1762
|
-
ctx.body = { data: settings2 };
|
|
1763
|
-
},
|
|
1764
|
-
async update(ctx) {
|
|
1765
|
-
const settingsBody = ctx.request.body;
|
|
1766
|
-
const settings2 = await validateSettings(settingsBody);
|
|
1767
|
-
const settingsService = getService("settings", { strapi });
|
|
1768
|
-
const updatedSettings = await settingsService.update({ settings: settings2 });
|
|
1769
|
-
ctx.body = { data: updatedSettings };
|
|
1770
|
-
}
|
|
1771
|
-
};
|
|
1772
|
-
const controllers = {
|
|
1773
|
-
release: releaseController,
|
|
1774
|
-
"release-action": releaseActionController,
|
|
1775
|
-
settings: settingsController
|
|
1776
|
-
};
|
|
1777
|
-
const release = {
|
|
1778
|
-
type: "admin",
|
|
1779
|
-
routes: [
|
|
1780
|
-
{
|
|
1781
|
-
method: "GET",
|
|
1782
|
-
path: "/mapEntriesToReleases",
|
|
1783
|
-
handler: "release.mapEntriesToReleases",
|
|
1784
|
-
config: {
|
|
1785
|
-
policies: [
|
|
1786
|
-
"admin::isAuthenticatedAdmin",
|
|
1787
|
-
{
|
|
1788
|
-
name: "admin::hasPermissions",
|
|
1789
|
-
config: {
|
|
1790
|
-
actions: ["plugin::content-releases.read"]
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
]
|
|
1794
|
-
}
|
|
1795
|
-
},
|
|
1796
|
-
{
|
|
1797
|
-
method: "GET",
|
|
1798
|
-
path: "/getByDocumentAttached",
|
|
1799
|
-
handler: "release.findByDocumentAttached",
|
|
1800
|
-
config: {
|
|
1801
|
-
policies: [
|
|
1802
|
-
"admin::isAuthenticatedAdmin",
|
|
1803
|
-
{
|
|
1804
|
-
name: "admin::hasPermissions",
|
|
1805
|
-
config: {
|
|
1806
|
-
actions: ["plugin::content-releases.read"]
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
]
|
|
1810
|
-
}
|
|
1811
|
-
},
|
|
1812
|
-
{
|
|
1813
|
-
method: "POST",
|
|
1814
|
-
path: "/",
|
|
1815
|
-
handler: "release.create",
|
|
1816
|
-
config: {
|
|
1817
|
-
policies: [
|
|
1818
|
-
"admin::isAuthenticatedAdmin",
|
|
1819
|
-
{
|
|
1820
|
-
name: "admin::hasPermissions",
|
|
1821
|
-
config: {
|
|
1822
|
-
actions: ["plugin::content-releases.create"]
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
1825
|
-
]
|
|
1826
|
-
}
|
|
1827
|
-
},
|
|
1828
|
-
{
|
|
1829
|
-
method: "GET",
|
|
1830
|
-
path: "/",
|
|
1831
|
-
handler: "release.findPage",
|
|
1832
|
-
config: {
|
|
1833
|
-
policies: [
|
|
1834
|
-
"admin::isAuthenticatedAdmin",
|
|
1835
|
-
{
|
|
1836
|
-
name: "admin::hasPermissions",
|
|
1837
|
-
config: {
|
|
1838
|
-
actions: ["plugin::content-releases.read"]
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
1841
|
-
]
|
|
1842
|
-
}
|
|
1843
|
-
},
|
|
1844
|
-
{
|
|
1845
|
-
method: "GET",
|
|
1846
|
-
path: "/:id",
|
|
1847
|
-
handler: "release.findOne",
|
|
1848
|
-
config: {
|
|
1849
|
-
policies: [
|
|
1850
|
-
"admin::isAuthenticatedAdmin",
|
|
1851
|
-
{
|
|
1852
|
-
name: "admin::hasPermissions",
|
|
1853
|
-
config: {
|
|
1854
|
-
actions: ["plugin::content-releases.read"]
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
]
|
|
1858
|
-
}
|
|
1859
|
-
},
|
|
1860
|
-
{
|
|
1861
|
-
method: "PUT",
|
|
1862
|
-
path: "/:id",
|
|
1863
|
-
handler: "release.update",
|
|
1864
|
-
config: {
|
|
1865
|
-
policies: [
|
|
1866
|
-
"admin::isAuthenticatedAdmin",
|
|
1867
|
-
{
|
|
1868
|
-
name: "admin::hasPermissions",
|
|
1869
|
-
config: {
|
|
1870
|
-
actions: ["plugin::content-releases.update"]
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
]
|
|
1874
|
-
}
|
|
1875
|
-
},
|
|
1876
|
-
{
|
|
1877
|
-
method: "DELETE",
|
|
1878
|
-
path: "/:id",
|
|
1879
|
-
handler: "release.delete",
|
|
1880
|
-
config: {
|
|
1881
|
-
policies: [
|
|
1882
|
-
"admin::isAuthenticatedAdmin",
|
|
1883
|
-
{
|
|
1884
|
-
name: "admin::hasPermissions",
|
|
1885
|
-
config: {
|
|
1886
|
-
actions: ["plugin::content-releases.delete"]
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
]
|
|
1890
|
-
}
|
|
1891
|
-
},
|
|
1892
|
-
{
|
|
1893
|
-
method: "POST",
|
|
1894
|
-
path: "/:id/publish",
|
|
1895
|
-
handler: "release.publish",
|
|
1896
|
-
config: {
|
|
1897
|
-
policies: [
|
|
1898
|
-
"admin::isAuthenticatedAdmin",
|
|
1899
|
-
{
|
|
1900
|
-
name: "admin::hasPermissions",
|
|
1901
|
-
config: {
|
|
1902
|
-
actions: ["plugin::content-releases.publish"]
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
|
-
]
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
]
|
|
1909
|
-
};
|
|
1910
|
-
const releaseAction = {
|
|
1911
|
-
type: "admin",
|
|
1912
|
-
routes: [
|
|
1913
|
-
{
|
|
1914
|
-
method: "POST",
|
|
1915
|
-
path: "/:releaseId/actions",
|
|
1916
|
-
handler: "release-action.create",
|
|
1917
|
-
config: {
|
|
1918
|
-
policies: [
|
|
1919
|
-
"admin::isAuthenticatedAdmin",
|
|
1920
|
-
{
|
|
1921
|
-
name: "admin::hasPermissions",
|
|
1922
|
-
config: {
|
|
1923
|
-
actions: ["plugin::content-releases.create-action"]
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
]
|
|
1927
|
-
}
|
|
1928
|
-
},
|
|
1929
|
-
{
|
|
1930
|
-
method: "POST",
|
|
1931
|
-
path: "/:releaseId/actions/bulk",
|
|
1932
|
-
handler: "release-action.createMany",
|
|
1933
|
-
config: {
|
|
1934
|
-
policies: [
|
|
1935
|
-
"admin::isAuthenticatedAdmin",
|
|
1936
|
-
{
|
|
1937
|
-
name: "admin::hasPermissions",
|
|
1938
|
-
config: {
|
|
1939
|
-
actions: ["plugin::content-releases.create-action"]
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
1942
|
-
]
|
|
1943
|
-
}
|
|
1944
|
-
},
|
|
1945
|
-
{
|
|
1946
|
-
method: "GET",
|
|
1947
|
-
path: "/:releaseId/actions",
|
|
1948
|
-
handler: "release-action.findMany",
|
|
1949
|
-
config: {
|
|
1950
|
-
policies: [
|
|
1951
|
-
"admin::isAuthenticatedAdmin",
|
|
1952
|
-
{
|
|
1953
|
-
name: "admin::hasPermissions",
|
|
1954
|
-
config: {
|
|
1955
|
-
actions: ["plugin::content-releases.read"]
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
]
|
|
1959
|
-
}
|
|
1960
|
-
},
|
|
1961
|
-
{
|
|
1962
|
-
method: "PUT",
|
|
1963
|
-
path: "/:releaseId/actions/:actionId",
|
|
1964
|
-
handler: "release-action.update",
|
|
1965
|
-
config: {
|
|
1966
|
-
policies: [
|
|
1967
|
-
"admin::isAuthenticatedAdmin",
|
|
1968
|
-
{
|
|
1969
|
-
name: "admin::hasPermissions",
|
|
1970
|
-
config: {
|
|
1971
|
-
actions: ["plugin::content-releases.update"]
|
|
1972
|
-
}
|
|
1973
|
-
}
|
|
1974
|
-
]
|
|
1975
|
-
}
|
|
1976
|
-
},
|
|
1977
|
-
{
|
|
1978
|
-
method: "DELETE",
|
|
1979
|
-
path: "/:releaseId/actions/:actionId",
|
|
1980
|
-
handler: "release-action.delete",
|
|
1981
|
-
config: {
|
|
1982
|
-
policies: [
|
|
1983
|
-
"admin::isAuthenticatedAdmin",
|
|
1984
|
-
{
|
|
1985
|
-
name: "admin::hasPermissions",
|
|
1986
|
-
config: {
|
|
1987
|
-
actions: ["plugin::content-releases.delete-action"]
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
]
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
]
|
|
1994
|
-
};
|
|
1995
|
-
const settings = {
|
|
1996
|
-
type: "admin",
|
|
1997
|
-
routes: [
|
|
1998
|
-
{
|
|
1999
|
-
method: "GET",
|
|
2000
|
-
path: "/settings",
|
|
2001
|
-
handler: "settings.find",
|
|
2002
|
-
config: {
|
|
2003
|
-
policies: [
|
|
2004
|
-
"admin::isAuthenticatedAdmin",
|
|
2005
|
-
{
|
|
2006
|
-
name: "admin::hasPermissions",
|
|
2007
|
-
config: {
|
|
2008
|
-
actions: ["plugin::content-releases.settings.read"]
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
]
|
|
2012
|
-
}
|
|
2013
|
-
},
|
|
2014
|
-
{
|
|
2015
|
-
method: "PUT",
|
|
2016
|
-
path: "/settings",
|
|
2017
|
-
handler: "settings.update",
|
|
2018
|
-
config: {
|
|
2019
|
-
policies: [
|
|
2020
|
-
"admin::isAuthenticatedAdmin",
|
|
2021
|
-
{
|
|
2022
|
-
name: "admin::hasPermissions",
|
|
2023
|
-
config: {
|
|
2024
|
-
actions: ["plugin::content-releases.settings.update"]
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
|
-
]
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
]
|
|
2031
|
-
};
|
|
2032
|
-
const routes = {
|
|
2033
|
-
settings,
|
|
2034
|
-
release,
|
|
2035
|
-
"release-action": releaseAction
|
|
2036
|
-
};
|
|
2037
|
-
const getPlugin = () => {
|
|
2038
|
-
if (strapi.ee.features.isEnabled("cms-content-releases")) {
|
|
2039
23
|
return {
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
services,
|
|
2045
|
-
controllers,
|
|
2046
|
-
routes
|
|
24
|
+
// Always return register, it handles its own feature check
|
|
25
|
+
register: register.register,
|
|
26
|
+
// Always return contentTypes to avoid losing data when the feature is disabled
|
|
27
|
+
contentTypes: index$1.contentTypes
|
|
2047
28
|
};
|
|
2048
|
-
}
|
|
2049
|
-
return {
|
|
2050
|
-
// Always return register, it handles its own feature check
|
|
2051
|
-
register,
|
|
2052
|
-
// Always return contentTypes to avoid losing data when the feature is disabled
|
|
2053
|
-
contentTypes
|
|
2054
|
-
};
|
|
2055
29
|
};
|
|
2056
|
-
|
|
30
|
+
var index = getPlugin();
|
|
31
|
+
|
|
2057
32
|
module.exports = index;
|
|
2058
33
|
//# sourceMappingURL=index.js.map
|