@strapi/content-releases 5.56.0 → 5.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/components/RelativeTime.js +12 -2
- package/dist/admin/components/RelativeTime.js.map +1 -1
- package/dist/admin/components/RelativeTime.mjs +13 -3
- package/dist/admin/components/RelativeTime.mjs.map +1 -1
- package/dist/server/entitlements.js +21 -0
- package/dist/server/entitlements.js.map +1 -0
- package/dist/server/entitlements.mjs +19 -0
- package/dist/server/entitlements.mjs.map +1 -0
- package/dist/server/migrations/index.js +5 -16
- package/dist/server/migrations/index.js.map +1 -1
- package/dist/server/migrations/index.mjs +3 -14
- package/dist/server/migrations/index.mjs.map +1 -1
- package/dist/server/register.js +2 -0
- package/dist/server/register.js.map +1 -1
- package/dist/server/register.mjs +2 -0
- package/dist/server/register.mjs.map +1 -1
- package/dist/server/services/release-action.js +4 -7
- package/dist/server/services/release-action.js.map +1 -1
- package/dist/server/services/release-action.mjs +4 -7
- package/dist/server/services/release-action.mjs.map +1 -1
- package/dist/server/src/entitlements.d.ts +8 -0
- package/dist/server/src/entitlements.d.ts.map +1 -0
- package/dist/server/src/index.d.ts +1742 -1
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/migrations/index.d.ts.map +1 -1
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +1742 -1
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/release-action.d.ts +1744 -2
- package/dist/server/src/services/release-action.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -48,6 +48,15 @@ const intervals = [
|
|
|
48
48
|
* ```
|
|
49
49
|
*/ const RelativeTime = /*#__PURE__*/ React__namespace.forwardRef(({ timestamp, customIntervals = [], ...restProps }, forwardedRef)=>{
|
|
50
50
|
const { formatRelativeTime, formatDate, formatTime } = reactIntl.useIntl();
|
|
51
|
+
// Invalid Date: intervalToDuration throws RangeError (see #27382).
|
|
52
|
+
if (!dateFns.isValid(timestamp)) {
|
|
53
|
+
return /*#__PURE__*/ jsxRuntime.jsx("time", {
|
|
54
|
+
ref: forwardedRef,
|
|
55
|
+
role: "time",
|
|
56
|
+
...restProps,
|
|
57
|
+
children: "-"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
51
60
|
/**
|
|
52
61
|
* TODO: make this auto-update, like a clock.
|
|
53
62
|
*/ const interval = dateFns.intervalToDuration({
|
|
@@ -56,8 +65,9 @@ const intervals = [
|
|
|
56
65
|
});
|
|
57
66
|
const unit = intervals.find((intervalUnit)=>{
|
|
58
67
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
|
59
|
-
});
|
|
60
|
-
const
|
|
68
|
+
}) ?? 'seconds';
|
|
69
|
+
const value = interval[unit] ?? 0;
|
|
70
|
+
const relativeTime = dateFns.isPast(timestamp) ? -value : value;
|
|
61
71
|
// Display custom text if interval is less than the threshold
|
|
62
72
|
const customInterval = customIntervals.find((custom)=>interval[custom.unit] < custom.threshold);
|
|
63
73
|
const displayText = customInterval ? customInterval.text : formatRelativeTime(relativeTime, unit, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelativeTime.js","sources":["../../../admin/src/components/RelativeTime.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Duration, intervalToDuration, isPast } from 'date-fns';\nimport { useIntl } from 'react-intl';\n\nconst intervals: Array<keyof Duration> = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'];\n\ninterface CustomInterval {\n unit: keyof Duration;\n text: string;\n threshold: number;\n}\n\ninterface RelativeTimeProps extends React.ComponentPropsWithoutRef<'time'> {\n timestamp: Date;\n customIntervals?: CustomInterval[];\n}\n\n/**\n * Displays the relative time between a given timestamp and the current time.\n * You can display a custom message for given time intervals by passing an array of custom intervals.\n *\n * @example\n * ```jsx\n * <caption>Display \"last hour\" if the timestamp is less than an hour ago</caption>\n * <RelativeTime\n * timestamp={new Date('2021-01-01')}\n * customIntervals={[\n * { unit: 'hours', threshold: 1, text: 'last hour' },\n * ]}\n * ```\n */\nconst RelativeTime = React.forwardRef<HTMLTimeElement, RelativeTimeProps>(\n ({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {\n const { formatRelativeTime, formatDate, formatTime } = useIntl();\n\n /**\n * TODO: make this auto-update, like a clock.\n */\n const interval = intervalToDuration({\n start: timestamp,\n end: Date.now(),\n // see https://github.com/date-fns/date-fns/issues/2891 – No idea why it's all partial it returns it every time.\n }) as Required<Duration>;\n\n const unit
|
|
1
|
+
{"version":3,"file":"RelativeTime.js","sources":["../../../admin/src/components/RelativeTime.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Duration, intervalToDuration, isPast, isValid } from 'date-fns';\nimport { useIntl } from 'react-intl';\n\nconst intervals: Array<keyof Duration> = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'];\n\ninterface CustomInterval {\n unit: keyof Duration;\n text: string;\n threshold: number;\n}\n\ninterface RelativeTimeProps extends React.ComponentPropsWithoutRef<'time'> {\n timestamp: Date;\n customIntervals?: CustomInterval[];\n}\n\n/**\n * Displays the relative time between a given timestamp and the current time.\n * You can display a custom message for given time intervals by passing an array of custom intervals.\n *\n * @example\n * ```jsx\n * <caption>Display \"last hour\" if the timestamp is less than an hour ago</caption>\n * <RelativeTime\n * timestamp={new Date('2021-01-01')}\n * customIntervals={[\n * { unit: 'hours', threshold: 1, text: 'last hour' },\n * ]}\n * ```\n */\nconst RelativeTime = React.forwardRef<HTMLTimeElement, RelativeTimeProps>(\n ({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {\n const { formatRelativeTime, formatDate, formatTime } = useIntl();\n\n // Invalid Date: intervalToDuration throws RangeError (see #27382).\n if (!isValid(timestamp)) {\n return (\n <time ref={forwardedRef} role=\"time\" {...restProps}>\n -\n </time>\n );\n }\n\n /**\n * TODO: make this auto-update, like a clock.\n */\n const interval = intervalToDuration({\n start: timestamp,\n end: Date.now(),\n // see https://github.com/date-fns/date-fns/issues/2891 – No idea why it's all partial it returns it every time.\n }) as Required<Duration>;\n\n const unit =\n intervals.find((intervalUnit) => {\n return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);\n }) ?? 'seconds';\n\n const value = interval[unit] ?? 0;\n const relativeTime = isPast(timestamp) ? -value : value;\n\n // Display custom text if interval is less than the threshold\n const customInterval = customIntervals.find(\n (custom) => interval[custom.unit] < custom.threshold\n );\n\n const displayText = customInterval\n ? customInterval.text\n : formatRelativeTime(relativeTime, unit, { numeric: 'auto' });\n\n return (\n <time\n ref={forwardedRef}\n dateTime={timestamp.toISOString()}\n role=\"time\"\n title={`${formatDate(timestamp)} ${formatTime(timestamp)}`}\n {...restProps}\n >\n {displayText}\n </time>\n );\n }\n);\n\nexport { RelativeTime };\nexport type { CustomInterval, RelativeTimeProps };\n"],"names":["intervals","RelativeTime","React","forwardRef","timestamp","customIntervals","restProps","forwardedRef","formatRelativeTime","formatDate","formatTime","useIntl","isValid","_jsx","time","ref","role","interval","intervalToDuration","start","end","Date","now","unit","find","intervalUnit","Object","keys","includes","value","relativeTime","isPast","customInterval","custom","threshold","displayText","text","numeric","dateTime","toISOString","title"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,SAAAA,GAAmC;AAAC,IAAA,OAAA;AAAS,IAAA,QAAA;AAAU,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,SAAA;AAAW,IAAA;AAAU,CAAA;AAanG;;;;;;;;;;;;;AAaC,IACD,MAAMC,YAAAA,iBAAeC,gBAAAA,CAAMC,UAAU,CACnC,CAAC,EAAEC,SAAS,EAAEC,eAAAA,GAAkB,EAAE,EAAE,GAAGC,WAAW,EAAEC,YAAAA,GAAAA;AAClD,IAAA,MAAM,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGC,iBAAAA,EAAAA;;IAGvD,IAAI,CAACC,gBAAQR,SAAAA,CAAAA,EAAY;AACvB,QAAA,qBACES,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WAAWN,SAAAA,CAAAA,CAAAA,CAAY;AACzD,QAAA,GAAGE,SAAS;AAEZ6B,QAAAA,QAAAA,EAAAA;;AAGP,CAAA;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { intervalToDuration, isPast } from 'date-fns';
|
|
3
|
+
import { isValid, intervalToDuration, isPast } from 'date-fns';
|
|
4
4
|
import { useIntl } from 'react-intl';
|
|
5
5
|
|
|
6
6
|
const intervals = [
|
|
@@ -26,6 +26,15 @@ const intervals = [
|
|
|
26
26
|
* ```
|
|
27
27
|
*/ const RelativeTime = /*#__PURE__*/ React.forwardRef(({ timestamp, customIntervals = [], ...restProps }, forwardedRef)=>{
|
|
28
28
|
const { formatRelativeTime, formatDate, formatTime } = useIntl();
|
|
29
|
+
// Invalid Date: intervalToDuration throws RangeError (see #27382).
|
|
30
|
+
if (!isValid(timestamp)) {
|
|
31
|
+
return /*#__PURE__*/ jsx("time", {
|
|
32
|
+
ref: forwardedRef,
|
|
33
|
+
role: "time",
|
|
34
|
+
...restProps,
|
|
35
|
+
children: "-"
|
|
36
|
+
});
|
|
37
|
+
}
|
|
29
38
|
/**
|
|
30
39
|
* TODO: make this auto-update, like a clock.
|
|
31
40
|
*/ const interval = intervalToDuration({
|
|
@@ -34,8 +43,9 @@ const intervals = [
|
|
|
34
43
|
});
|
|
35
44
|
const unit = intervals.find((intervalUnit)=>{
|
|
36
45
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
|
37
|
-
});
|
|
38
|
-
const
|
|
46
|
+
}) ?? 'seconds';
|
|
47
|
+
const value = interval[unit] ?? 0;
|
|
48
|
+
const relativeTime = isPast(timestamp) ? -value : value;
|
|
39
49
|
// Display custom text if interval is less than the threshold
|
|
40
50
|
const customInterval = customIntervals.find((custom)=>interval[custom.unit] < custom.threshold);
|
|
41
51
|
const displayText = customInterval ? customInterval.text : formatRelativeTime(relativeTime, unit, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelativeTime.mjs","sources":["../../../admin/src/components/RelativeTime.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Duration, intervalToDuration, isPast } from 'date-fns';\nimport { useIntl } from 'react-intl';\n\nconst intervals: Array<keyof Duration> = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'];\n\ninterface CustomInterval {\n unit: keyof Duration;\n text: string;\n threshold: number;\n}\n\ninterface RelativeTimeProps extends React.ComponentPropsWithoutRef<'time'> {\n timestamp: Date;\n customIntervals?: CustomInterval[];\n}\n\n/**\n * Displays the relative time between a given timestamp and the current time.\n * You can display a custom message for given time intervals by passing an array of custom intervals.\n *\n * @example\n * ```jsx\n * <caption>Display \"last hour\" if the timestamp is less than an hour ago</caption>\n * <RelativeTime\n * timestamp={new Date('2021-01-01')}\n * customIntervals={[\n * { unit: 'hours', threshold: 1, text: 'last hour' },\n * ]}\n * ```\n */\nconst RelativeTime = React.forwardRef<HTMLTimeElement, RelativeTimeProps>(\n ({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {\n const { formatRelativeTime, formatDate, formatTime } = useIntl();\n\n /**\n * TODO: make this auto-update, like a clock.\n */\n const interval = intervalToDuration({\n start: timestamp,\n end: Date.now(),\n // see https://github.com/date-fns/date-fns/issues/2891 – No idea why it's all partial it returns it every time.\n }) as Required<Duration>;\n\n const unit
|
|
1
|
+
{"version":3,"file":"RelativeTime.mjs","sources":["../../../admin/src/components/RelativeTime.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Duration, intervalToDuration, isPast, isValid } from 'date-fns';\nimport { useIntl } from 'react-intl';\n\nconst intervals: Array<keyof Duration> = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'];\n\ninterface CustomInterval {\n unit: keyof Duration;\n text: string;\n threshold: number;\n}\n\ninterface RelativeTimeProps extends React.ComponentPropsWithoutRef<'time'> {\n timestamp: Date;\n customIntervals?: CustomInterval[];\n}\n\n/**\n * Displays the relative time between a given timestamp and the current time.\n * You can display a custom message for given time intervals by passing an array of custom intervals.\n *\n * @example\n * ```jsx\n * <caption>Display \"last hour\" if the timestamp is less than an hour ago</caption>\n * <RelativeTime\n * timestamp={new Date('2021-01-01')}\n * customIntervals={[\n * { unit: 'hours', threshold: 1, text: 'last hour' },\n * ]}\n * ```\n */\nconst RelativeTime = React.forwardRef<HTMLTimeElement, RelativeTimeProps>(\n ({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {\n const { formatRelativeTime, formatDate, formatTime } = useIntl();\n\n // Invalid Date: intervalToDuration throws RangeError (see #27382).\n if (!isValid(timestamp)) {\n return (\n <time ref={forwardedRef} role=\"time\" {...restProps}>\n -\n </time>\n );\n }\n\n /**\n * TODO: make this auto-update, like a clock.\n */\n const interval = intervalToDuration({\n start: timestamp,\n end: Date.now(),\n // see https://github.com/date-fns/date-fns/issues/2891 – No idea why it's all partial it returns it every time.\n }) as Required<Duration>;\n\n const unit =\n intervals.find((intervalUnit) => {\n return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);\n }) ?? 'seconds';\n\n const value = interval[unit] ?? 0;\n const relativeTime = isPast(timestamp) ? -value : value;\n\n // Display custom text if interval is less than the threshold\n const customInterval = customIntervals.find(\n (custom) => interval[custom.unit] < custom.threshold\n );\n\n const displayText = customInterval\n ? customInterval.text\n : formatRelativeTime(relativeTime, unit, { numeric: 'auto' });\n\n return (\n <time\n ref={forwardedRef}\n dateTime={timestamp.toISOString()}\n role=\"time\"\n title={`${formatDate(timestamp)} ${formatTime(timestamp)}`}\n {...restProps}\n >\n {displayText}\n </time>\n );\n }\n);\n\nexport { RelativeTime };\nexport type { CustomInterval, RelativeTimeProps };\n"],"names":["intervals","RelativeTime","React","forwardRef","timestamp","customIntervals","restProps","forwardedRef","formatRelativeTime","formatDate","formatTime","useIntl","isValid","_jsx","time","ref","role","interval","intervalToDuration","start","end","Date","now","unit","find","intervalUnit","Object","keys","includes","value","relativeTime","isPast","customInterval","custom","threshold","displayText","text","numeric","dateTime","toISOString","title"],"mappings":";;;;;AAKA,MAAMA,SAAAA,GAAmC;AAAC,IAAA,OAAA;AAAS,IAAA,QAAA;AAAU,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,SAAA;AAAW,IAAA;AAAU,CAAA;AAanG;;;;;;;;;;;;;AAaC,IACD,MAAMC,YAAAA,iBAAeC,KAAAA,CAAMC,UAAU,CACnC,CAAC,EAAEC,SAAS,EAAEC,eAAAA,GAAkB,EAAE,EAAE,GAAGC,WAAW,EAAEC,YAAAA,GAAAA;AAClD,IAAA,MAAM,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGC,OAAAA,EAAAA;;IAGvD,IAAI,CAACC,QAAQR,SAAAA,CAAAA,EAAY;AACvB,QAAA,qBACES,GAAA,CAACC,MAAAA,EAAAA;YAAKC,GAAAA,EAAKR,YAAAA;YAAcS,IAAAA,EAAK,MAAA;AAAQ,YAAA,GAAGV,SAAS;AAAE,YAAA,QAAA,EAAA;;AAIxD,IAAA;AAEA;;QAGA,MAAMW,WAAWC,kBAAAA,CAAmB;QAClCC,KAAAA,EAAOf,SAAAA;AACPgB,QAAAA,GAAAA,EAAKC,KAAKC,GAAG;AAEf,KAAA,CAAA;AAEA,IAAA,MAAMC,IAAAA,GACJvB,SAAAA,CAAUwB,IAAI,CAAC,CAACC,YAAAA,GAAAA;QACd,OAAOR,QAAQ,CAACQ,YAAAA,CAAa,GAAG,CAAA,IAAKC,OAAOC,IAAI,CAACV,QAAAA,CAAAA,CAAUW,QAAQ,CAACH,YAAAA,CAAAA;IACtE,CAAA,CAAA,IAAM,SAAA;AAER,IAAA,MAAMI,KAAAA,GAAQZ,QAAQ,CAACM,IAAAA,CAAK,IAAI,CAAA;AAChC,IAAA,MAAMO,YAAAA,GAAeC,MAAAA,CAAO3B,SAAAA,CAAAA,GAAa,CAACyB,KAAAA,GAAQA,KAAAA;;AAGlD,IAAA,MAAMG,cAAAA,GAAiB3B,eAAAA,CAAgBmB,IAAI,CACzC,CAACS,MAAAA,GAAWhB,QAAQ,CAACgB,MAAAA,CAAOV,IAAI,CAAC,GAAGU,OAAOC,SAAS,CAAA;AAGtD,IAAA,MAAMC,cAAcH,cAAAA,GAChBA,cAAAA,CAAeI,IAAI,GACnB5B,kBAAAA,CAAmBsB,cAAcP,IAAAA,EAAM;QAAEc,OAAAA,EAAS;AAAO,KAAA,CAAA;AAE7D,IAAA,qBACExB,GAAA,CAACC,MAAAA,EAAAA;QACCC,GAAAA,EAAKR,YAAAA;AACL+B,QAAAA,QAAAA,EAAUlC,UAAUmC,WAAW,EAAA;QAC/BvB,IAAAA,EAAK,MAAA;AACLwB,QAAAA,KAAAA,EAAO,GAAG/B,UAAAA,CAAWL,SAAAA,CAAAA,CAAW,CAAC,EAAEM,WAAWN,SAAAA,CAAAA,CAAAA,CAAY;AACzD,QAAA,GAAGE,SAAS;AAEZ6B,QAAAA,QAAAA,EAAAA;;AAGP,CAAA;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Exposes the pending-release cap to the Plan card and the debug dump, defaulting the same way
|
|
5
|
+
* `validatePendingReleasesLimit` does. Registered whatever the boot-time license says, so a
|
|
6
|
+
* lapsed or later-renewed license still resolves.
|
|
7
|
+
*/ const registerReleasesEntitlements = (strapi)=>{
|
|
8
|
+
strapi.ee.entitlements.register({
|
|
9
|
+
feature: 'cms-content-releases',
|
|
10
|
+
limits: [
|
|
11
|
+
{
|
|
12
|
+
key: 'maximumReleases',
|
|
13
|
+
unit: 'count',
|
|
14
|
+
get: (feature)=>(typeof feature === 'object' ? feature.options?.maximumReleases : undefined) || 3
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.registerReleasesEntitlements = registerReleasesEntitlements;
|
|
21
|
+
//# sourceMappingURL=entitlements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.js","sources":["../../server/src/entitlements.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\n/**\n * Exposes the pending-release cap to the Plan card and the debug dump, defaulting the same way\n * `validatePendingReleasesLimit` does. Registered whatever the boot-time license says, so a\n * lapsed or later-renewed license still resolves.\n */\nexport const registerReleasesEntitlements = (strapi: Core.Strapi) => {\n strapi.ee.entitlements.register({\n feature: 'cms-content-releases',\n limits: [\n {\n key: 'maximumReleases',\n unit: 'count',\n get: (feature) =>\n (typeof feature === 'object' ? feature.options?.maximumReleases : undefined) || 3,\n },\n ],\n });\n};\n"],"names":["registerReleasesEntitlements","strapi","ee","entitlements","register","feature","limits","key","unit","get","options","maximumReleases","undefined"],"mappings":";;AAEA;;;;IAKO,MAAMA,4BAAAA,GAA+B,CAACC,MAAAA,GAAAA;AAC3CA,IAAAA,MAAAA,CAAOC,EAAE,CAACC,YAAY,CAACC,QAAQ,CAAC;QAC9BC,OAAAA,EAAS,sBAAA;QACTC,MAAAA,EAAQ;AACN,YAAA;gBACEC,GAAAA,EAAK,iBAAA;gBACLC,IAAAA,EAAM,OAAA;AACNC,gBAAAA,GAAAA,EAAK,CAACJ,OAAAA,GACJ,CAAC,OAAOA,OAAAA,KAAY,QAAA,GAAWA,OAAAA,CAAQK,OAAO,EAAEC,eAAAA,GAAkBC,SAAQ,KAAM;AACpF;AACD;AACH,KAAA,CAAA;AACF;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exposes the pending-release cap to the Plan card and the debug dump, defaulting the same way
|
|
3
|
+
* `validatePendingReleasesLimit` does. Registered whatever the boot-time license says, so a
|
|
4
|
+
* lapsed or later-renewed license still resolves.
|
|
5
|
+
*/ const registerReleasesEntitlements = (strapi)=>{
|
|
6
|
+
strapi.ee.entitlements.register({
|
|
7
|
+
feature: 'cms-content-releases',
|
|
8
|
+
limits: [
|
|
9
|
+
{
|
|
10
|
+
key: 'maximumReleases',
|
|
11
|
+
unit: 'count',
|
|
12
|
+
get: (feature)=>(typeof feature === 'object' ? feature.options?.maximumReleases : undefined) || 3
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { registerReleasesEntitlements };
|
|
19
|
+
//# sourceMappingURL=entitlements.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.mjs","sources":["../../server/src/entitlements.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\n/**\n * Exposes the pending-release cap to the Plan card and the debug dump, defaulting the same way\n * `validatePendingReleasesLimit` does. Registered whatever the boot-time license says, so a\n * lapsed or later-renewed license still resolves.\n */\nexport const registerReleasesEntitlements = (strapi: Core.Strapi) => {\n strapi.ee.entitlements.register({\n feature: 'cms-content-releases',\n limits: [\n {\n key: 'maximumReleases',\n unit: 'count',\n get: (feature) =>\n (typeof feature === 'object' ? feature.options?.maximumReleases : undefined) || 3,\n },\n ],\n });\n};\n"],"names":["registerReleasesEntitlements","strapi","ee","entitlements","register","feature","limits","key","unit","get","options","maximumReleases","undefined"],"mappings":"AAEA;;;;IAKO,MAAMA,4BAAAA,GAA+B,CAACC,MAAAA,GAAAA;AAC3CA,IAAAA,MAAAA,CAAOC,EAAE,CAACC,YAAY,CAACC,QAAQ,CAAC;QAC9BC,OAAAA,EAAS,sBAAA;QACTC,MAAAA,EAAQ;AACN,YAAA;gBACEC,GAAAA,EAAK,iBAAA;gBACLC,IAAAA,EAAM,OAAA;AACNC,gBAAAA,GAAAA,EAAK,CAACJ,OAAAA,GACJ,CAAC,OAAOA,OAAAA,KAAY,QAAA,GAAWA,OAAAA,CAAQK,OAAO,EAAEC,eAAAA,GAAkBC,SAAQ,KAAM;AACpF;AACD;AACH,KAAA,CAAA;AACF;;;;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var utils = require('@strapi/utils');
|
|
4
4
|
var isEqual = require('lodash/isEqual');
|
|
5
|
-
var
|
|
5
|
+
var _ = require('lodash');
|
|
6
6
|
var constants = require('../constants.js');
|
|
7
7
|
var index = require('../utils/index.js');
|
|
8
8
|
|
|
@@ -28,7 +28,7 @@ async function deleteActionsOnDisableDraftAndPublish({ oldContentTypes, contentT
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
async function deleteActionsOnDeleteContentType({ oldContentTypes, contentTypes }) {
|
|
31
|
-
const deletedContentTypes =
|
|
31
|
+
const deletedContentTypes = _.difference(_.keys(oldContentTypes), _.keys(contentTypes)) ?? [];
|
|
32
32
|
if (deletedContentTypes.length) {
|
|
33
33
|
await utils.async.map(deletedContentTypes, async (deletedContentTypeUID)=>{
|
|
34
34
|
return strapi.db?.queryBuilder(constants.RELEASE_ACTION_MODEL_UID).delete().where({
|
|
@@ -151,19 +151,14 @@ async function disableContentTypeLocalized({ oldContentTypes, contentTypes }) {
|
|
|
151
151
|
if (!oldContentTypes) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
|
-
const i18nPlugin = strapi.plugin('i18n');
|
|
155
|
-
if (!i18nPlugin) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
154
|
for(const uid in contentTypes){
|
|
159
155
|
if (!oldContentTypes[uid]) {
|
|
160
156
|
continue;
|
|
161
157
|
}
|
|
162
158
|
const oldContentType = oldContentTypes[uid];
|
|
163
159
|
const contentType = contentTypes[uid];
|
|
164
|
-
const { isLocalizedContentType } = i18nPlugin.service('content-types');
|
|
165
160
|
// if i18N is disabled remove non default locales before sync
|
|
166
|
-
if (isLocalizedContentType(oldContentType) &&
|
|
161
|
+
if (strapi.localization.isLocalizedContentType(oldContentType) === true && strapi.localization.isLocalizedContentType(contentType) === false) {
|
|
167
162
|
await strapi.db.queryBuilder(constants.RELEASE_ACTION_MODEL_UID).update({
|
|
168
163
|
locale: null
|
|
169
164
|
}).where({
|
|
@@ -176,21 +171,15 @@ async function enableContentTypeLocalized({ oldContentTypes, contentTypes }) {
|
|
|
176
171
|
if (!oldContentTypes) {
|
|
177
172
|
return;
|
|
178
173
|
}
|
|
179
|
-
const i18nPlugin = strapi.plugin('i18n');
|
|
180
|
-
if (!i18nPlugin) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
174
|
for(const uid in contentTypes){
|
|
184
175
|
if (!oldContentTypes[uid]) {
|
|
185
176
|
continue;
|
|
186
177
|
}
|
|
187
178
|
const oldContentType = oldContentTypes[uid];
|
|
188
179
|
const contentType = contentTypes[uid];
|
|
189
|
-
const { isLocalizedContentType } = i18nPlugin.service('content-types');
|
|
190
|
-
const { getDefaultLocale } = i18nPlugin.service('locales');
|
|
191
180
|
// if i18N is enabled remove non default locales before sync
|
|
192
|
-
if (
|
|
193
|
-
const defaultLocale = await getDefaultLocale();
|
|
181
|
+
if (strapi.localization.isLocalizedContentType(oldContentType) === false && strapi.localization.isLocalizedContentType(contentType) === true) {
|
|
182
|
+
const defaultLocale = await strapi.localization.getDefaultLocale();
|
|
194
183
|
await strapi.db.queryBuilder(constants.RELEASE_ACTION_MODEL_UID).update({
|
|
195
184
|
locale: defaultLocale
|
|
196
185
|
}).where({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../server/src/migrations/index.ts"],"sourcesContent":["import type { Schema, UID } from '@strapi/types';\nimport { contentTypes as contentTypesUtils, async } from '@strapi/utils';\nimport isEqual from 'lodash/isEqual';\n\nimport { difference, keys } from 'lodash';\nimport { RELEASE_ACTION_MODEL_UID, RELEASE_MODEL_UID } from '../constants';\nimport { getDraftEntryValidStatus, getService } from '../utils';\nimport { Release } from '../../../shared/contracts/releases';\nimport { ReleaseAction } from '../../../shared/contracts/release-actions';\n\ninterface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\nexport async function deleteActionsOnDisableDraftAndPublish({\n oldContentTypes,\n contentTypes,\n}: Input) {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db\n ?.queryBuilder(RELEASE_ACTION_MODEL_UID)\n .delete()\n .where({ contentType: uid })\n .execute();\n }\n }\n}\n\nexport async function deleteActionsOnDeleteContentType({ oldContentTypes, contentTypes }: Input) {\n const deletedContentTypes = difference(keys(oldContentTypes), keys(contentTypes)) ?? [];\n\n if (deletedContentTypes.length) {\n await async.map(deletedContentTypes, async (deletedContentTypeUID: unknown) => {\n return strapi.db\n ?.queryBuilder(RELEASE_ACTION_MODEL_UID)\n .delete()\n .where({ contentType: deletedContentTypeUID })\n .execute();\n });\n }\n}\n\nexport async function migrateIsValidAndStatusReleases() {\n const releasesWithoutStatus = (await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n status: null,\n releasedAt: null,\n },\n populate: {\n actions: {\n populate: {\n entry: true,\n },\n },\n },\n })) as Release[];\n\n async.map(releasesWithoutStatus, async (release: Release) => {\n const actions = release.actions;\n\n const notValidatedActions = actions.filter((action) => action.isEntryValid === null);\n\n for (const action of notValidatedActions) {\n // We need to check the Action is related to a valid entry because we can't assume this is gonna be always the case\n // example: users could make changes directly to their database, or data could be lost\n if (action.entry) {\n const isEntryValid = getDraftEntryValidStatus(\n {\n contentType: action.contentType,\n documentId: action.entryDocumentId,\n locale: action.locale,\n },\n { strapi }\n );\n\n await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({\n where: {\n id: action.id,\n },\n data: {\n isEntryValid,\n },\n });\n }\n }\n\n return getService('release', { strapi }).updateReleaseStatus(release.id);\n });\n\n const publishedReleases = await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n status: null,\n releasedAt: {\n $notNull: true,\n },\n },\n });\n\n async.map(publishedReleases, async (release: Release) => {\n return strapi.db.query(RELEASE_MODEL_UID).update({\n where: {\n id: release.id,\n },\n data: {\n status: 'done',\n },\n });\n });\n}\n\nexport async function revalidateChangedContentTypes({ oldContentTypes, contentTypes }: Input) {\n if (oldContentTypes !== undefined && contentTypes !== undefined) {\n const contentTypesWithDraftAndPublish = Object.keys(oldContentTypes).filter(\n (uid) => oldContentTypes[uid]?.options?.draftAndPublish\n );\n const releasesAffected = new Set();\n\n async\n .map(contentTypesWithDraftAndPublish, async (contentTypeUID: UID.ContentType) => {\n const oldContentType = oldContentTypes[contentTypeUID];\n const contentType = contentTypes[contentTypeUID];\n\n // If attributes have changed, we need to revalidate actions because maybe validations rules are different\n if (!isEqual(oldContentType?.attributes, contentType?.attributes)) {\n const actions = await strapi.db.query(RELEASE_ACTION_MODEL_UID).findMany({\n where: {\n contentType: contentTypeUID,\n },\n populate: {\n entry: true,\n release: true,\n },\n });\n\n await async.map(actions, async (action: ReleaseAction) => {\n if (action.entry && action.release && action.type === 'publish') {\n const isEntryValid = await getDraftEntryValidStatus(\n {\n contentType: contentTypeUID,\n documentId: action.entryDocumentId,\n locale: action.locale,\n },\n { strapi }\n );\n\n releasesAffected.add(action.release.id);\n\n await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({\n where: {\n id: action.id,\n },\n data: {\n isEntryValid,\n },\n });\n }\n });\n }\n })\n .then(() => {\n // We need to update the status of the releases affected\n async.map(releasesAffected, async (releaseId: Release['id']) => {\n return getService('release', { strapi }).updateReleaseStatus(releaseId);\n });\n });\n }\n}\n\nexport async function disableContentTypeLocalized({ oldContentTypes, contentTypes }: Input) {\n if (!oldContentTypes) {\n return;\n }\n\n const i18nPlugin = strapi.plugin('i18n');\n if (!i18nPlugin) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n const { isLocalizedContentType } = i18nPlugin.service('content-types');\n\n // if i18N is disabled remove non default locales before sync\n if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {\n await strapi.db\n .queryBuilder(RELEASE_ACTION_MODEL_UID)\n .update({\n locale: null,\n })\n .where({ contentType: uid })\n .execute();\n }\n }\n}\n\nexport async function enableContentTypeLocalized({ oldContentTypes, contentTypes }: Input) {\n if (!oldContentTypes) {\n return;\n }\n\n const i18nPlugin = strapi.plugin('i18n');\n if (!i18nPlugin) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n const { isLocalizedContentType } = i18nPlugin.service('content-types');\n const { getDefaultLocale } = i18nPlugin.service('locales');\n\n // if i18N is enabled remove non default locales before sync\n if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {\n const defaultLocale = await getDefaultLocale();\n\n await strapi.db\n .queryBuilder(RELEASE_ACTION_MODEL_UID)\n .update({\n locale: defaultLocale,\n })\n .where({ contentType: uid })\n .execute();\n }\n }\n}\n"],"names":["deleteActionsOnDisableDraftAndPublish","oldContentTypes","contentTypes","uid","oldContentType","contentType","contentTypesUtils","hasDraftAndPublish","strapi","db","queryBuilder","RELEASE_ACTION_MODEL_UID","delete","where","execute","deleteActionsOnDeleteContentType","deletedContentTypes","difference","keys","length","async","map","deletedContentTypeUID","migrateIsValidAndStatusReleases","releasesWithoutStatus","query","RELEASE_MODEL_UID","findMany","status","releasedAt","populate","actions","entry","release","notValidatedActions","filter","action","isEntryValid","getDraftEntryValidStatus","documentId","entryDocumentId","locale","update","id","data","getService","updateReleaseStatus","publishedReleases","$notNull","revalidateChangedContentTypes","undefined","contentTypesWithDraftAndPublish","Object","options","draftAndPublish","releasesAffected","Set","contentTypeUID","isEqual","attributes","type","add","then","releaseId","disableContentTypeLocalized","i18nPlugin","plugin","isLocalizedContentType","service","enableContentTypeLocalized","getDefaultLocale","defaultLocale"],"mappings":";;;;;;;;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Ac;AAC9B,QAAA,IAAI,CAACD,eAAe,CAACE,GAAAA,CAAI,EAAE;AACzB,YAAA;AACF,QAAA;QAEA,MAAMC,cAAAA,GAAiBH,eAAe,CAACE,GAAAA,CAAI;QAC3C,MAAME,WAAAA,GAAcH,YAAY,CAACC,GAAAA,CAAI;AAErC,QAAA,MAAM,EAAEgE,sBAAsB,EAAE,GAAGF,UAAAA,CAAWG,OAAO,CAAC,eAAA,CAAA;AACtD,QAAA,MAAM,EAAEE,gBAAgB,EAAE,GAAGL,UAAAA,CAAWG,OAAO,CAAC,SAAA,CAAA;;AAGhD,QAAA,IAAI,CAACD,sBAAAA,CAAuB/D,cAAAA,CAAAA,IAAmB+D,sBAAAA,CAAuB9D,WAAAA,CAAAA,EAAc;AAClF,YAAA,MAAMkE,gBAAgB,MAAMD,gBAAAA,EAAAA;AAE5B,YAAA,MAAM9D,OAAOC,EAAE,CACZC,YAAY,CAACC,kCAAAA,CAAAA,CACb+B,MAAM,CAAC;gBACND,MAAAA,EAAQ8B;AACV,aAAA,CAAA,CACC1D,KAAK,CAAC;gBAAER,WAAAA,EAAaF;AAAI,aAAA,CAAA,CACzBW,OAAO,EAAA;AACZ,QAAA;AACF,IAAA;AACF;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../server/src/migrations/index.ts"],"sourcesContent":["import type { Schema, UID } from '@strapi/types';\nimport { contentTypes as contentTypesUtils, async } from '@strapi/utils';\nimport isEqual from 'lodash/isEqual';\n\nimport { difference, keys } from 'lodash';\nimport { RELEASE_ACTION_MODEL_UID, RELEASE_MODEL_UID } from '../constants';\nimport { getDraftEntryValidStatus, getService } from '../utils';\nimport { Release } from '../../../shared/contracts/releases';\nimport { ReleaseAction } from '../../../shared/contracts/release-actions';\n\ninterface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\nexport async function deleteActionsOnDisableDraftAndPublish({\n oldContentTypes,\n contentTypes,\n}: Input) {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db\n ?.queryBuilder(RELEASE_ACTION_MODEL_UID)\n .delete()\n .where({ contentType: uid })\n .execute();\n }\n }\n}\n\nexport async function deleteActionsOnDeleteContentType({ oldContentTypes, contentTypes }: Input) {\n const deletedContentTypes = difference(keys(oldContentTypes), keys(contentTypes)) ?? [];\n\n if (deletedContentTypes.length) {\n await async.map(deletedContentTypes, async (deletedContentTypeUID: unknown) => {\n return strapi.db\n ?.queryBuilder(RELEASE_ACTION_MODEL_UID)\n .delete()\n .where({ contentType: deletedContentTypeUID })\n .execute();\n });\n }\n}\n\nexport async function migrateIsValidAndStatusReleases() {\n const releasesWithoutStatus = (await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n status: null,\n releasedAt: null,\n },\n populate: {\n actions: {\n populate: {\n entry: true,\n },\n },\n },\n })) as Release[];\n\n async.map(releasesWithoutStatus, async (release: Release) => {\n const actions = release.actions;\n\n const notValidatedActions = actions.filter((action) => action.isEntryValid === null);\n\n for (const action of notValidatedActions) {\n // We need to check the Action is related to a valid entry because we can't assume this is gonna be always the case\n // example: users could make changes directly to their database, or data could be lost\n if (action.entry) {\n const isEntryValid = getDraftEntryValidStatus(\n {\n contentType: action.contentType,\n documentId: action.entryDocumentId,\n locale: action.locale,\n },\n { strapi }\n );\n\n await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({\n where: {\n id: action.id,\n },\n data: {\n isEntryValid,\n },\n });\n }\n }\n\n return getService('release', { strapi }).updateReleaseStatus(release.id);\n });\n\n const publishedReleases = await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n status: null,\n releasedAt: {\n $notNull: true,\n },\n },\n });\n\n async.map(publishedReleases, async (release: Release) => {\n return strapi.db.query(RELEASE_MODEL_UID).update({\n where: {\n id: release.id,\n },\n data: {\n status: 'done',\n },\n });\n });\n}\n\nexport async function revalidateChangedContentTypes({ oldContentTypes, contentTypes }: Input) {\n if (oldContentTypes !== undefined && contentTypes !== undefined) {\n const contentTypesWithDraftAndPublish = Object.keys(oldContentTypes).filter(\n (uid) => oldContentTypes[uid]?.options?.draftAndPublish\n );\n const releasesAffected = new Set();\n\n async\n .map(contentTypesWithDraftAndPublish, async (contentTypeUID: UID.ContentType) => {\n const oldContentType = oldContentTypes[contentTypeUID];\n const contentType = contentTypes[contentTypeUID];\n\n // If attributes have changed, we need to revalidate actions because maybe validations rules are different\n if (!isEqual(oldContentType?.attributes, contentType?.attributes)) {\n const actions = await strapi.db.query(RELEASE_ACTION_MODEL_UID).findMany({\n where: {\n contentType: contentTypeUID,\n },\n populate: {\n entry: true,\n release: true,\n },\n });\n\n await async.map(actions, async (action: ReleaseAction) => {\n if (action.entry && action.release && action.type === 'publish') {\n const isEntryValid = await getDraftEntryValidStatus(\n {\n contentType: contentTypeUID,\n documentId: action.entryDocumentId,\n locale: action.locale,\n },\n { strapi }\n );\n\n releasesAffected.add(action.release.id);\n\n await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({\n where: {\n id: action.id,\n },\n data: {\n isEntryValid,\n },\n });\n }\n });\n }\n })\n .then(() => {\n // We need to update the status of the releases affected\n async.map(releasesAffected, async (releaseId: Release['id']) => {\n return getService('release', { strapi }).updateReleaseStatus(releaseId);\n });\n });\n }\n}\n\nexport async function disableContentTypeLocalized({ oldContentTypes, contentTypes }: Input) {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if i18N is disabled remove non default locales before sync\n if (\n strapi.localization.isLocalizedContentType(oldContentType) === true &&\n strapi.localization.isLocalizedContentType(contentType) === false\n ) {\n await strapi.db\n .queryBuilder(RELEASE_ACTION_MODEL_UID)\n .update({\n locale: null,\n })\n .where({ contentType: uid })\n .execute();\n }\n }\n}\n\nexport async function enableContentTypeLocalized({ oldContentTypes, contentTypes }: Input) {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if i18N is enabled remove non default locales before sync\n if (\n strapi.localization.isLocalizedContentType(oldContentType) === false &&\n strapi.localization.isLocalizedContentType(contentType) === true\n ) {\n const defaultLocale = await strapi.localization.getDefaultLocale();\n\n await strapi.db\n .queryBuilder(RELEASE_ACTION_MODEL_UID)\n .update({\n locale: defaultLocale,\n })\n .where({ contentType: uid })\n .execute();\n }\n }\n}\n"],"names":["deleteActionsOnDisableDraftAndPublish","oldContentTypes","contentTypes","uid","oldContentType","contentType","contentTypesUtils","hasDraftAndPublish","strapi","db","queryBuilder","RELEASE_ACTION_MODEL_UID","delete","where","execute","deleteActionsOnDeleteContentType","deletedContentTypes","difference","keys","length","async","map","deletedContentTypeUID","migrateIsValidAndStatusReleases","releasesWithoutStatus","query","RELEASE_MODEL_UID","findMany","status","releasedAt","populate","actions","entry","release","notValidatedActions","filter","action","isEntryValid","getDraftEntryValidStatus","documentId","entryDocumentId","locale","update","id","data","getService","updateReleaseStatus","publishedReleases","$notNull","revalidateChangedContentTypes","undefined","contentTypesWithDraftAndPublish","Object","options","draftAndPublish","releasesAffected","Set","contentTypeUID","isEqual","attributes","type","add","then","releaseId","disableContentTypeLocalized","localization","isLocalizedContentType","enableContentTypeLocalized","defaultLocale","getDefaultLocale"],"mappings":";;;;;;;;;;;;AAeO,eAAeA,qCAAAA,CAAsC,EAC1DC,eAAe,EACfC,YAAY,EACN,EAAA;AACN,IAAA,IAAI,CAACD,eAAAA,EAAiB;AACpB,QAAA;AACF,IAAA;IAEA,IAAK,MAAME,OAAOD,YAAAA,CAAc;AAC9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AAOC,EAAE,CACZC,YAAY,CAACC,kCAAAA,CAAAA,CACb+B,MAAM,CAAC;gBACND,MAAAA,EAAQ2B;AACV,aAAA,CAAA,CACCvD,KAAK,CAAC;gBAAER,WAAAA,EAAaF;AAAI,aAAA,CAAA,CACzBW,OAAO,EAAA;AACZ,QAAA;AACF,IAAA;AACF;;;;;;;;;"}
|
|
@@ -145,19 +145,14 @@ async function disableContentTypeLocalized({ oldContentTypes, contentTypes }) {
|
|
|
145
145
|
if (!oldContentTypes) {
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
|
-
const i18nPlugin = strapi.plugin('i18n');
|
|
149
|
-
if (!i18nPlugin) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
148
|
for(const uid in contentTypes){
|
|
153
149
|
if (!oldContentTypes[uid]) {
|
|
154
150
|
continue;
|
|
155
151
|
}
|
|
156
152
|
const oldContentType = oldContentTypes[uid];
|
|
157
153
|
const contentType = contentTypes[uid];
|
|
158
|
-
const { isLocalizedContentType } = i18nPlugin.service('content-types');
|
|
159
154
|
// if i18N is disabled remove non default locales before sync
|
|
160
|
-
if (isLocalizedContentType(oldContentType) &&
|
|
155
|
+
if (strapi.localization.isLocalizedContentType(oldContentType) === true && strapi.localization.isLocalizedContentType(contentType) === false) {
|
|
161
156
|
await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
|
|
162
157
|
locale: null
|
|
163
158
|
}).where({
|
|
@@ -170,21 +165,15 @@ async function enableContentTypeLocalized({ oldContentTypes, contentTypes }) {
|
|
|
170
165
|
if (!oldContentTypes) {
|
|
171
166
|
return;
|
|
172
167
|
}
|
|
173
|
-
const i18nPlugin = strapi.plugin('i18n');
|
|
174
|
-
if (!i18nPlugin) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
168
|
for(const uid in contentTypes){
|
|
178
169
|
if (!oldContentTypes[uid]) {
|
|
179
170
|
continue;
|
|
180
171
|
}
|
|
181
172
|
const oldContentType = oldContentTypes[uid];
|
|
182
173
|
const contentType = contentTypes[uid];
|
|
183
|
-
const { isLocalizedContentType } = i18nPlugin.service('content-types');
|
|
184
|
-
const { getDefaultLocale } = i18nPlugin.service('locales');
|
|
185
174
|
// if i18N is enabled remove non default locales before sync
|
|
186
|
-
if (
|
|
187
|
-
const defaultLocale = await getDefaultLocale();
|
|
175
|
+
if (strapi.localization.isLocalizedContentType(oldContentType) === false && strapi.localization.isLocalizedContentType(contentType) === true) {
|
|
176
|
+
const defaultLocale = await strapi.localization.getDefaultLocale();
|
|
188
177
|
await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
|
|
189
178
|
locale: defaultLocale
|
|
190
179
|
}).where({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../server/src/migrations/index.ts"],"sourcesContent":["import type { Schema, UID } from '@strapi/types';\nimport { contentTypes as contentTypesUtils, async } from '@strapi/utils';\nimport isEqual from 'lodash/isEqual';\n\nimport { difference, keys } from 'lodash';\nimport { RELEASE_ACTION_MODEL_UID, RELEASE_MODEL_UID } from '../constants';\nimport { getDraftEntryValidStatus, getService } from '../utils';\nimport { Release } from '../../../shared/contracts/releases';\nimport { ReleaseAction } from '../../../shared/contracts/release-actions';\n\ninterface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\nexport async function deleteActionsOnDisableDraftAndPublish({\n oldContentTypes,\n contentTypes,\n}: Input) {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db\n ?.queryBuilder(RELEASE_ACTION_MODEL_UID)\n .delete()\n .where({ contentType: uid })\n .execute();\n }\n }\n}\n\nexport async function deleteActionsOnDeleteContentType({ oldContentTypes, contentTypes }: Input) {\n const deletedContentTypes = difference(keys(oldContentTypes), keys(contentTypes)) ?? [];\n\n if (deletedContentTypes.length) {\n await async.map(deletedContentTypes, async (deletedContentTypeUID: unknown) => {\n return strapi.db\n ?.queryBuilder(RELEASE_ACTION_MODEL_UID)\n .delete()\n .where({ contentType: deletedContentTypeUID })\n .execute();\n });\n }\n}\n\nexport async function migrateIsValidAndStatusReleases() {\n const releasesWithoutStatus = (await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n status: null,\n releasedAt: null,\n },\n populate: {\n actions: {\n populate: {\n entry: true,\n },\n },\n },\n })) as Release[];\n\n async.map(releasesWithoutStatus, async (release: Release) => {\n const actions = release.actions;\n\n const notValidatedActions = actions.filter((action) => action.isEntryValid === null);\n\n for (const action of notValidatedActions) {\n // We need to check the Action is related to a valid entry because we can't assume this is gonna be always the case\n // example: users could make changes directly to their database, or data could be lost\n if (action.entry) {\n const isEntryValid = getDraftEntryValidStatus(\n {\n contentType: action.contentType,\n documentId: action.entryDocumentId,\n locale: action.locale,\n },\n { strapi }\n );\n\n await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({\n where: {\n id: action.id,\n },\n data: {\n isEntryValid,\n },\n });\n }\n }\n\n return getService('release', { strapi }).updateReleaseStatus(release.id);\n });\n\n const publishedReleases = await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n status: null,\n releasedAt: {\n $notNull: true,\n },\n },\n });\n\n async.map(publishedReleases, async (release: Release) => {\n return strapi.db.query(RELEASE_MODEL_UID).update({\n where: {\n id: release.id,\n },\n data: {\n status: 'done',\n },\n });\n });\n}\n\nexport async function revalidateChangedContentTypes({ oldContentTypes, contentTypes }: Input) {\n if (oldContentTypes !== undefined && contentTypes !== undefined) {\n const contentTypesWithDraftAndPublish = Object.keys(oldContentTypes).filter(\n (uid) => oldContentTypes[uid]?.options?.draftAndPublish\n );\n const releasesAffected = new Set();\n\n async\n .map(contentTypesWithDraftAndPublish, async (contentTypeUID: UID.ContentType) => {\n const oldContentType = oldContentTypes[contentTypeUID];\n const contentType = contentTypes[contentTypeUID];\n\n // If attributes have changed, we need to revalidate actions because maybe validations rules are different\n if (!isEqual(oldContentType?.attributes, contentType?.attributes)) {\n const actions = await strapi.db.query(RELEASE_ACTION_MODEL_UID).findMany({\n where: {\n contentType: contentTypeUID,\n },\n populate: {\n entry: true,\n release: true,\n },\n });\n\n await async.map(actions, async (action: ReleaseAction) => {\n if (action.entry && action.release && action.type === 'publish') {\n const isEntryValid = await getDraftEntryValidStatus(\n {\n contentType: contentTypeUID,\n documentId: action.entryDocumentId,\n locale: action.locale,\n },\n { strapi }\n );\n\n releasesAffected.add(action.release.id);\n\n await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({\n where: {\n id: action.id,\n },\n data: {\n isEntryValid,\n },\n });\n }\n });\n }\n })\n .then(() => {\n // We need to update the status of the releases affected\n async.map(releasesAffected, async (releaseId: Release['id']) => {\n return getService('release', { strapi }).updateReleaseStatus(releaseId);\n });\n });\n }\n}\n\nexport async function disableContentTypeLocalized({ oldContentTypes, contentTypes }: Input) {\n if (!oldContentTypes) {\n return;\n }\n\n const i18nPlugin = strapi.plugin('i18n');\n if (!i18nPlugin) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n const { isLocalizedContentType } = i18nPlugin.service('content-types');\n\n // if i18N is disabled remove non default locales before sync\n if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {\n await strapi.db\n .queryBuilder(RELEASE_ACTION_MODEL_UID)\n .update({\n locale: null,\n })\n .where({ contentType: uid })\n .execute();\n }\n }\n}\n\nexport async function enableContentTypeLocalized({ oldContentTypes, contentTypes }: Input) {\n if (!oldContentTypes) {\n return;\n }\n\n const i18nPlugin = strapi.plugin('i18n');\n if (!i18nPlugin) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n const { isLocalizedContentType } = i18nPlugin.service('content-types');\n const { getDefaultLocale } = i18nPlugin.service('locales');\n\n // if i18N is enabled remove non default locales before sync\n if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {\n const defaultLocale = await getDefaultLocale();\n\n await strapi.db\n .queryBuilder(RELEASE_ACTION_MODEL_UID)\n .update({\n locale: defaultLocale,\n })\n .where({ contentType: uid })\n .execute();\n }\n }\n}\n"],"names":["deleteActionsOnDisableDraftAndPublish","oldContentTypes","contentTypes","uid","oldContentType","contentType","contentTypesUtils","hasDraftAndPublish","strapi","db","queryBuilder","RELEASE_ACTION_MODEL_UID","delete","where","execute","deleteActionsOnDeleteContentType","deletedContentTypes","difference","keys","length","async","map","deletedContentTypeUID","migrateIsValidAndStatusReleases","releasesWithoutStatus","query","RELEASE_MODEL_UID","findMany","status","releasedAt","populate","actions","entry","release","notValidatedActions","filter","action","isEntryValid","getDraftEntryValidStatus","documentId","entryDocumentId","locale","update","id","data","getService","updateReleaseStatus","publishedReleases","$notNull","revalidateChangedContentTypes","undefined","contentTypesWithDraftAndPublish","Object","options","draftAndPublish","releasesAffected","Set","contentTypeUID","isEqual","attributes","type","add","then","releaseId","disableContentTypeLocalized","i18nPlugin","plugin","isLocalizedContentType","service","enableContentTypeLocalized","getDefaultLocale","defaultLocale"],"mappings":";;;;;;AAeO,eAAeA,qCAAAA,CAAsC,EAC1DC,eAAe,gBACfC,cAAY,EACN,EAAA;AACN,IAAA,IAAI,CAACD,eAAAA,EAAiB;AACpB,QAAA;AACF,IAAA;IAEA,IAAK,MAAME,OAAOD,cAAAA,CAAc;AAC9B,QAAA,IAAI,CAACD,eAAe,CAACE,GAAAA,CAAI,EAAE;AACzB,YAAA;AACF,QAAA;QAEA,MAAMC,cAAAA,GAAiBH,eAAe,CAACE,GAAAA,CAAI;QAC3C,MAAME,WAAAA,GAAcH,cAAY,CAAC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C,SAAA,CAAA;;AAGhD,QAAA,IAAI,CAACD,sBAAAA,CAAuB/D,cAAAA,CAAAA,IAAmB+D,sBAAAA,CAAuB9D,WAAAA,CAAAA,EAAc;AAClF,YAAA,MAAMkE,gBAAgB,MAAMD,gBAAAA,EAAAA;AAE5B,YAAA,MAAM9D,OAAOC,EAAE,CACZC,YAAY,CAACC,wBAAAA,CAAAA,CACb+B,MAAM,CAAC;gBACND,MAAAA,EAAQ8B;AACV,aAAA,CAAA,CACC1D,KAAK,CAAC;gBAAER,WAAAA,EAAaF;AAAI,aAAA,CAAA,CACzBW,OAAO,EAAA;AACZ,QAAA;AACF,IAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../server/src/migrations/index.ts"],"sourcesContent":["import type { Schema, UID } from '@strapi/types';\nimport { contentTypes as contentTypesUtils, async } from '@strapi/utils';\nimport isEqual from 'lodash/isEqual';\n\nimport { difference, keys } from 'lodash';\nimport { RELEASE_ACTION_MODEL_UID, RELEASE_MODEL_UID } from '../constants';\nimport { getDraftEntryValidStatus, getService } from '../utils';\nimport { Release } from '../../../shared/contracts/releases';\nimport { ReleaseAction } from '../../../shared/contracts/release-actions';\n\ninterface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\nexport async function deleteActionsOnDisableDraftAndPublish({\n oldContentTypes,\n contentTypes,\n}: Input) {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db\n ?.queryBuilder(RELEASE_ACTION_MODEL_UID)\n .delete()\n .where({ contentType: uid })\n .execute();\n }\n }\n}\n\nexport async function deleteActionsOnDeleteContentType({ oldContentTypes, contentTypes }: Input) {\n const deletedContentTypes = difference(keys(oldContentTypes), keys(contentTypes)) ?? [];\n\n if (deletedContentTypes.length) {\n await async.map(deletedContentTypes, async (deletedContentTypeUID: unknown) => {\n return strapi.db\n ?.queryBuilder(RELEASE_ACTION_MODEL_UID)\n .delete()\n .where({ contentType: deletedContentTypeUID })\n .execute();\n });\n }\n}\n\nexport async function migrateIsValidAndStatusReleases() {\n const releasesWithoutStatus = (await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n status: null,\n releasedAt: null,\n },\n populate: {\n actions: {\n populate: {\n entry: true,\n },\n },\n },\n })) as Release[];\n\n async.map(releasesWithoutStatus, async (release: Release) => {\n const actions = release.actions;\n\n const notValidatedActions = actions.filter((action) => action.isEntryValid === null);\n\n for (const action of notValidatedActions) {\n // We need to check the Action is related to a valid entry because we can't assume this is gonna be always the case\n // example: users could make changes directly to their database, or data could be lost\n if (action.entry) {\n const isEntryValid = getDraftEntryValidStatus(\n {\n contentType: action.contentType,\n documentId: action.entryDocumentId,\n locale: action.locale,\n },\n { strapi }\n );\n\n await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({\n where: {\n id: action.id,\n },\n data: {\n isEntryValid,\n },\n });\n }\n }\n\n return getService('release', { strapi }).updateReleaseStatus(release.id);\n });\n\n const publishedReleases = await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n status: null,\n releasedAt: {\n $notNull: true,\n },\n },\n });\n\n async.map(publishedReleases, async (release: Release) => {\n return strapi.db.query(RELEASE_MODEL_UID).update({\n where: {\n id: release.id,\n },\n data: {\n status: 'done',\n },\n });\n });\n}\n\nexport async function revalidateChangedContentTypes({ oldContentTypes, contentTypes }: Input) {\n if (oldContentTypes !== undefined && contentTypes !== undefined) {\n const contentTypesWithDraftAndPublish = Object.keys(oldContentTypes).filter(\n (uid) => oldContentTypes[uid]?.options?.draftAndPublish\n );\n const releasesAffected = new Set();\n\n async\n .map(contentTypesWithDraftAndPublish, async (contentTypeUID: UID.ContentType) => {\n const oldContentType = oldContentTypes[contentTypeUID];\n const contentType = contentTypes[contentTypeUID];\n\n // If attributes have changed, we need to revalidate actions because maybe validations rules are different\n if (!isEqual(oldContentType?.attributes, contentType?.attributes)) {\n const actions = await strapi.db.query(RELEASE_ACTION_MODEL_UID).findMany({\n where: {\n contentType: contentTypeUID,\n },\n populate: {\n entry: true,\n release: true,\n },\n });\n\n await async.map(actions, async (action: ReleaseAction) => {\n if (action.entry && action.release && action.type === 'publish') {\n const isEntryValid = await getDraftEntryValidStatus(\n {\n contentType: contentTypeUID,\n documentId: action.entryDocumentId,\n locale: action.locale,\n },\n { strapi }\n );\n\n releasesAffected.add(action.release.id);\n\n await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({\n where: {\n id: action.id,\n },\n data: {\n isEntryValid,\n },\n });\n }\n });\n }\n })\n .then(() => {\n // We need to update the status of the releases affected\n async.map(releasesAffected, async (releaseId: Release['id']) => {\n return getService('release', { strapi }).updateReleaseStatus(releaseId);\n });\n });\n }\n}\n\nexport async function disableContentTypeLocalized({ oldContentTypes, contentTypes }: Input) {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if i18N is disabled remove non default locales before sync\n if (\n strapi.localization.isLocalizedContentType(oldContentType) === true &&\n strapi.localization.isLocalizedContentType(contentType) === false\n ) {\n await strapi.db\n .queryBuilder(RELEASE_ACTION_MODEL_UID)\n .update({\n locale: null,\n })\n .where({ contentType: uid })\n .execute();\n }\n }\n}\n\nexport async function enableContentTypeLocalized({ oldContentTypes, contentTypes }: Input) {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if i18N is enabled remove non default locales before sync\n if (\n strapi.localization.isLocalizedContentType(oldContentType) === false &&\n strapi.localization.isLocalizedContentType(contentType) === true\n ) {\n const defaultLocale = await strapi.localization.getDefaultLocale();\n\n await strapi.db\n .queryBuilder(RELEASE_ACTION_MODEL_UID)\n .update({\n locale: defaultLocale,\n })\n .where({ contentType: uid })\n .execute();\n }\n }\n}\n"],"names":["deleteActionsOnDisableDraftAndPublish","oldContentTypes","contentTypes","uid","oldContentType","contentType","contentTypesUtils","hasDraftAndPublish","strapi","db","queryBuilder","RELEASE_ACTION_MODEL_UID","delete","where","execute","deleteActionsOnDeleteContentType","deletedContentTypes","difference","keys","length","async","map","deletedContentTypeUID","migrateIsValidAndStatusReleases","releasesWithoutStatus","query","RELEASE_MODEL_UID","findMany","status","releasedAt","populate","actions","entry","release","notValidatedActions","filter","action","isEntryValid","getDraftEntryValidStatus","documentId","entryDocumentId","locale","update","id","data","getService","updateReleaseStatus","publishedReleases","$notNull","revalidateChangedContentTypes","undefined","contentTypesWithDraftAndPublish","Object","options","draftAndPublish","releasesAffected","Set","contentTypeUID","isEqual","attributes","type","add","then","releaseId","disableContentTypeLocalized","localization","isLocalizedContentType","enableContentTypeLocalized","defaultLocale","getDefaultLocale"],"mappings":";;;;;;AAeO,eAAeA,qCAAAA,CAAsC,EAC1DC,eAAe,gBACfC,cAAY,EACN,EAAA;AACN,IAAA,IAAI,CAACD,eAAAA,EAAiB;AACpB,QAAA;AACF,IAAA;IAEA,IAAK,MAAME,OAAOD,cAAAA,CAAc;AAC9B,QAAA,IAAI,CAACD,eAAe,CAACE,GAAAA,CAAI,EAAE;AACzB,YAAA;AACF,QAAA;QAEA,MAAMC,cAAAA,GAAiBH,eAAe,CAACE,GAAAA,CAAI;QAC3C,MAAME,WAAAA,GAAcH,cAAY,CAACC,GAAAA,CAAI;QAErC,IACEG,YAAAA,CAAkBC,kBAAkB,CAACH,cAAAA,CAAAA,IACrC,CAACE,YAAAA,CAAkBC,kBAAkB,CAACF,WAAAA,CAAAA,EACtC;AACA,YAAA,MAAMG,OAAOC,EAAE,EACXC,YAAAA,CAAaC,wBAA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AAA,EAC5D;AACA,YAAA,MAAMG,OAAOC,EAAE,CACZC,YAAY,CAACC,wBAAAA,CAAAA,CACb+B,MAAM,CAAC;gBACND,MAAAA,EAAQ;AACV,aAAA,CAAA,CACC5B,KAAK,CAAC;gBAAER,WAAAA,EAAaF;AAAI,aAAA,CAAA,CACzBW,OAAO,EAAA;AACZ,QAAA;AACF,IAAA;AACF;AAEO,eAAeqD,0BAAAA,CAA2B,EAAElE,eAAe,EAAEC,YAAY,EAAS,EAAA;AACvF,IAAA,IAAI,CAACD,eAAAA,EAAiB;AACpB,QAAA;AACF,IAAA;IAEA,IAAK,MAAME,OAAOD,YAAAA,CAAc;AAC9B,QAAA,IAAI,CAACD,eAAe,CAACE,GAAAA,CAAI,EAAE;AACzB,YAAA;AACF,QAAA;QAEA,MAAMC,cAAAA,GAAiBH,eAAe,CAACE,GAAAA,CAAI;QAC3C,MAAME,WAAAA,GAAcH,YAAY,CAACC,GAAAA,CAAI;;AAGrC,QAAA,IACEK,MAAAA,CAAOyD,YAAY,CAACC,sBAAsB,CAAC9D,cAAAA,CAAAA,KAAoB,KAAA,IAC/DI,MAAAA,CAAOyD,YAAY,CAACC,sBAAsB,CAAC7D,iBAAiB,IAAA,EAC5D;AACA,YAAA,MAAM+D,aAAAA,GAAgB,MAAM5D,MAAAA,CAAOyD,YAAY,CAACI,gBAAgB,EAAA;AAEhE,YAAA,MAAM7D,OAAOC,EAAE,CACZC,YAAY,CAACC,wBAAAA,CAAAA,CACb+B,MAAM,CAAC;gBACND,MAAAA,EAAQ2B;AACV,aAAA,CAAA,CACCvD,KAAK,CAAC;gBAAER,WAAAA,EAAaF;AAAI,aAAA,CAAA,CACzBW,OAAO,EAAA;AACZ,QAAA;AACF,IAAA;AACF;;;;"}
|
package/dist/server/register.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
var constants = require('./constants.js');
|
|
4
4
|
var index = require('./migrations/index.js');
|
|
5
5
|
var _5_0_0DocumentIdInActions = require('./migrations/database/5.0.0-document-id-in-actions.js');
|
|
6
|
+
var entitlements = require('./entitlements.js');
|
|
6
7
|
|
|
7
8
|
const register = async ({ strapi })=>{
|
|
9
|
+
entitlements.registerReleasesEntitlements(strapi);
|
|
8
10
|
if (strapi.ee.features.isEnabled('cms-content-releases')) {
|
|
9
11
|
await strapi.service('admin::permission').actionProvider.registerMany(constants.ACTIONS);
|
|
10
12
|
strapi.db.migrations.providers.internal.register(_5_0_0DocumentIdInActions.addEntryDocumentToReleaseActions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sources":["../../server/src/register.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport type { Core } from '@strapi/types';\n\nimport { ACTIONS, RELEASE_MODEL_UID, RELEASE_ACTION_MODEL_UID } from './constants';\nimport {\n deleteActionsOnDeleteContentType,\n deleteActionsOnDisableDraftAndPublish,\n migrateIsValidAndStatusReleases,\n revalidateChangedContentTypes,\n disableContentTypeLocalized,\n enableContentTypeLocalized,\n} from './migrations';\nimport { addEntryDocumentToReleaseActions } from './migrations/database/5.0.0-document-id-in-actions';\n\nexport const register = async ({ strapi }: { strapi: Core.Strapi }) => {\n if (strapi.ee.features.isEnabled('cms-content-releases')) {\n await strapi.service('admin::permission').actionProvider.registerMany(ACTIONS);\n\n strapi.db.migrations.providers.internal.register(addEntryDocumentToReleaseActions);\n\n strapi\n .hook('strapi::content-types.beforeSync')\n .register(disableContentTypeLocalized)\n .register(deleteActionsOnDisableDraftAndPublish);\n\n strapi\n .hook('strapi::content-types.afterSync')\n .register(deleteActionsOnDeleteContentType)\n .register(enableContentTypeLocalized)\n .register(revalidateChangedContentTypes)\n .register(migrateIsValidAndStatusReleases);\n }\n\n if (strapi.plugin('graphql')) {\n const graphqlExtensionService = strapi.plugin('graphql').service('extension');\n // Exclude the release and release action models from the GraphQL schema\n graphqlExtensionService.shadowCRUD(RELEASE_MODEL_UID).disable();\n graphqlExtensionService.shadowCRUD(RELEASE_ACTION_MODEL_UID).disable();\n }\n};\n"],"names":["register","strapi","ee","features","isEnabled","service","actionProvider","registerMany","ACTIONS","db","migrations","providers","internal","addEntryDocumentToReleaseActions","hook","disableContentTypeLocalized","deleteActionsOnDisableDraftAndPublish","deleteActionsOnDeleteContentType","enableContentTypeLocalized","revalidateChangedContentTypes","migrateIsValidAndStatusReleases","plugin","graphqlExtensionService","shadowCRUD","RELEASE_MODEL_UID","disable","RELEASE_ACTION_MODEL_UID"],"mappings":"
|
|
1
|
+
{"version":3,"file":"register.js","sources":["../../server/src/register.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport type { Core } from '@strapi/types';\n\nimport { ACTIONS, RELEASE_MODEL_UID, RELEASE_ACTION_MODEL_UID } from './constants';\nimport {\n deleteActionsOnDeleteContentType,\n deleteActionsOnDisableDraftAndPublish,\n migrateIsValidAndStatusReleases,\n revalidateChangedContentTypes,\n disableContentTypeLocalized,\n enableContentTypeLocalized,\n} from './migrations';\nimport { addEntryDocumentToReleaseActions } from './migrations/database/5.0.0-document-id-in-actions';\nimport { registerReleasesEntitlements } from './entitlements';\n\nexport const register = async ({ strapi }: { strapi: Core.Strapi }) => {\n registerReleasesEntitlements(strapi);\n\n if (strapi.ee.features.isEnabled('cms-content-releases')) {\n await strapi.service('admin::permission').actionProvider.registerMany(ACTIONS);\n\n strapi.db.migrations.providers.internal.register(addEntryDocumentToReleaseActions);\n\n strapi\n .hook('strapi::content-types.beforeSync')\n .register(disableContentTypeLocalized)\n .register(deleteActionsOnDisableDraftAndPublish);\n\n strapi\n .hook('strapi::content-types.afterSync')\n .register(deleteActionsOnDeleteContentType)\n .register(enableContentTypeLocalized)\n .register(revalidateChangedContentTypes)\n .register(migrateIsValidAndStatusReleases);\n }\n\n if (strapi.plugin('graphql')) {\n const graphqlExtensionService = strapi.plugin('graphql').service('extension');\n // Exclude the release and release action models from the GraphQL schema\n graphqlExtensionService.shadowCRUD(RELEASE_MODEL_UID).disable();\n graphqlExtensionService.shadowCRUD(RELEASE_ACTION_MODEL_UID).disable();\n }\n};\n"],"names":["register","strapi","registerReleasesEntitlements","ee","features","isEnabled","service","actionProvider","registerMany","ACTIONS","db","migrations","providers","internal","addEntryDocumentToReleaseActions","hook","disableContentTypeLocalized","deleteActionsOnDisableDraftAndPublish","deleteActionsOnDeleteContentType","enableContentTypeLocalized","revalidateChangedContentTypes","migrateIsValidAndStatusReleases","plugin","graphqlExtensionService","shadowCRUD","RELEASE_MODEL_UID","disable","RELEASE_ACTION_MODEL_UID"],"mappings":";;;;;;;AAeO,MAAMA,QAAAA,GAAW,OAAO,EAAEC,MAAM,EAA2B,GAAA;IAChEC,yCAAAA,CAA6BD,MAAAA,CAAAA;AAE7B,IAAA,IAAIA,OAAOE,EAAE,CAACC,QAAQ,CAACC,SAAS,CAAC,sBAAA,CAAA,EAAyB;AACxD,QAAA,MAAMJ,OAAOK,OAAO,CAAC,qBAAqBC,cAAc,CAACC,YAAY,CAACC,iBAAAA,CAAAA;QAEtER,MAAAA,CAAOS,EAAE,CAACC,UAAU,CAACC,SAAS,CAACC,QAAQ,CAACb,QAAQ,CAACc,0DAAAA,CAAAA;AAEjDb,QAAAA,MAAAA,CACGc,IAAI,CAAC,kCAAA,CAAA,CACLf,QAAQ,CAACgB,iCAAAA,CAAAA,CACThB,QAAQ,CAACiB,2CAAAA,CAAAA;AAEZhB,QAAAA,MAAAA,CACGc,IAAI,CAAC,iCAAA,CAAA,CACLf,QAAQ,CAACkB,sCAAAA,CAAAA,CACTlB,QAAQ,CAACmB,gCAAAA,CAAAA,CACTnB,QAAQ,CAACoB,mCAAAA,CAAAA,CACTpB,QAAQ,CAACqB,qCAAAA,CAAAA;AACd,IAAA;IAEA,IAAIpB,MAAAA,CAAOqB,MAAM,CAAC,SAAA,CAAA,EAAY;AAC5B,QAAA,MAAMC,0BAA0BtB,MAAAA,CAAOqB,MAAM,CAAC,SAAA,CAAA,CAAWhB,OAAO,CAAC,WAAA,CAAA;;QAEjEiB,uBAAAA,CAAwBC,UAAU,CAACC,2BAAAA,CAAAA,CAAmBC,OAAO,EAAA;QAC7DH,uBAAAA,CAAwBC,UAAU,CAACG,kCAAAA,CAAAA,CAA0BD,OAAO,EAAA;AACtE,IAAA;AACF;;;;"}
|
package/dist/server/register.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ACTIONS, RELEASE_MODEL_UID, RELEASE_ACTION_MODEL_UID } from './constants.mjs';
|
|
2
2
|
import { disableContentTypeLocalized, deleteActionsOnDisableDraftAndPublish, deleteActionsOnDeleteContentType, enableContentTypeLocalized, revalidateChangedContentTypes, migrateIsValidAndStatusReleases } from './migrations/index.mjs';
|
|
3
3
|
import { addEntryDocumentToReleaseActions } from './migrations/database/5.0.0-document-id-in-actions.mjs';
|
|
4
|
+
import { registerReleasesEntitlements } from './entitlements.mjs';
|
|
4
5
|
|
|
5
6
|
const register = async ({ strapi })=>{
|
|
7
|
+
registerReleasesEntitlements(strapi);
|
|
6
8
|
if (strapi.ee.features.isEnabled('cms-content-releases')) {
|
|
7
9
|
await strapi.service('admin::permission').actionProvider.registerMany(ACTIONS);
|
|
8
10
|
strapi.db.migrations.providers.internal.register(addEntryDocumentToReleaseActions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.mjs","sources":["../../server/src/register.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport type { Core } from '@strapi/types';\n\nimport { ACTIONS, RELEASE_MODEL_UID, RELEASE_ACTION_MODEL_UID } from './constants';\nimport {\n deleteActionsOnDeleteContentType,\n deleteActionsOnDisableDraftAndPublish,\n migrateIsValidAndStatusReleases,\n revalidateChangedContentTypes,\n disableContentTypeLocalized,\n enableContentTypeLocalized,\n} from './migrations';\nimport { addEntryDocumentToReleaseActions } from './migrations/database/5.0.0-document-id-in-actions';\n\nexport const register = async ({ strapi }: { strapi: Core.Strapi }) => {\n if (strapi.ee.features.isEnabled('cms-content-releases')) {\n await strapi.service('admin::permission').actionProvider.registerMany(ACTIONS);\n\n strapi.db.migrations.providers.internal.register(addEntryDocumentToReleaseActions);\n\n strapi\n .hook('strapi::content-types.beforeSync')\n .register(disableContentTypeLocalized)\n .register(deleteActionsOnDisableDraftAndPublish);\n\n strapi\n .hook('strapi::content-types.afterSync')\n .register(deleteActionsOnDeleteContentType)\n .register(enableContentTypeLocalized)\n .register(revalidateChangedContentTypes)\n .register(migrateIsValidAndStatusReleases);\n }\n\n if (strapi.plugin('graphql')) {\n const graphqlExtensionService = strapi.plugin('graphql').service('extension');\n // Exclude the release and release action models from the GraphQL schema\n graphqlExtensionService.shadowCRUD(RELEASE_MODEL_UID).disable();\n graphqlExtensionService.shadowCRUD(RELEASE_ACTION_MODEL_UID).disable();\n }\n};\n"],"names":["register","strapi","ee","features","isEnabled","service","actionProvider","registerMany","ACTIONS","db","migrations","providers","internal","addEntryDocumentToReleaseActions","hook","disableContentTypeLocalized","deleteActionsOnDisableDraftAndPublish","deleteActionsOnDeleteContentType","enableContentTypeLocalized","revalidateChangedContentTypes","migrateIsValidAndStatusReleases","plugin","graphqlExtensionService","shadowCRUD","RELEASE_MODEL_UID","disable","RELEASE_ACTION_MODEL_UID"],"mappings":"
|
|
1
|
+
{"version":3,"file":"register.mjs","sources":["../../server/src/register.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport type { Core } from '@strapi/types';\n\nimport { ACTIONS, RELEASE_MODEL_UID, RELEASE_ACTION_MODEL_UID } from './constants';\nimport {\n deleteActionsOnDeleteContentType,\n deleteActionsOnDisableDraftAndPublish,\n migrateIsValidAndStatusReleases,\n revalidateChangedContentTypes,\n disableContentTypeLocalized,\n enableContentTypeLocalized,\n} from './migrations';\nimport { addEntryDocumentToReleaseActions } from './migrations/database/5.0.0-document-id-in-actions';\nimport { registerReleasesEntitlements } from './entitlements';\n\nexport const register = async ({ strapi }: { strapi: Core.Strapi }) => {\n registerReleasesEntitlements(strapi);\n\n if (strapi.ee.features.isEnabled('cms-content-releases')) {\n await strapi.service('admin::permission').actionProvider.registerMany(ACTIONS);\n\n strapi.db.migrations.providers.internal.register(addEntryDocumentToReleaseActions);\n\n strapi\n .hook('strapi::content-types.beforeSync')\n .register(disableContentTypeLocalized)\n .register(deleteActionsOnDisableDraftAndPublish);\n\n strapi\n .hook('strapi::content-types.afterSync')\n .register(deleteActionsOnDeleteContentType)\n .register(enableContentTypeLocalized)\n .register(revalidateChangedContentTypes)\n .register(migrateIsValidAndStatusReleases);\n }\n\n if (strapi.plugin('graphql')) {\n const graphqlExtensionService = strapi.plugin('graphql').service('extension');\n // Exclude the release and release action models from the GraphQL schema\n graphqlExtensionService.shadowCRUD(RELEASE_MODEL_UID).disable();\n graphqlExtensionService.shadowCRUD(RELEASE_ACTION_MODEL_UID).disable();\n }\n};\n"],"names":["register","strapi","registerReleasesEntitlements","ee","features","isEnabled","service","actionProvider","registerMany","ACTIONS","db","migrations","providers","internal","addEntryDocumentToReleaseActions","hook","disableContentTypeLocalized","deleteActionsOnDisableDraftAndPublish","deleteActionsOnDeleteContentType","enableContentTypeLocalized","revalidateChangedContentTypes","migrateIsValidAndStatusReleases","plugin","graphqlExtensionService","shadowCRUD","RELEASE_MODEL_UID","disable","RELEASE_ACTION_MODEL_UID"],"mappings":";;;;;AAeO,MAAMA,QAAAA,GAAW,OAAO,EAAEC,MAAM,EAA2B,GAAA;IAChEC,4BAAAA,CAA6BD,MAAAA,CAAAA;AAE7B,IAAA,IAAIA,OAAOE,EAAE,CAACC,QAAQ,CAACC,SAAS,CAAC,sBAAA,CAAA,EAAyB;AACxD,QAAA,MAAMJ,OAAOK,OAAO,CAAC,qBAAqBC,cAAc,CAACC,YAAY,CAACC,OAAAA,CAAAA;QAEtER,MAAAA,CAAOS,EAAE,CAACC,UAAU,CAACC,SAAS,CAACC,QAAQ,CAACb,QAAQ,CAACc,gCAAAA,CAAAA;AAEjDb,QAAAA,MAAAA,CACGc,IAAI,CAAC,kCAAA,CAAA,CACLf,QAAQ,CAACgB,2BAAAA,CAAAA,CACThB,QAAQ,CAACiB,qCAAAA,CAAAA;AAEZhB,QAAAA,MAAAA,CACGc,IAAI,CAAC,iCAAA,CAAA,CACLf,QAAQ,CAACkB,gCAAAA,CAAAA,CACTlB,QAAQ,CAACmB,0BAAAA,CAAAA,CACTnB,QAAQ,CAACoB,6BAAAA,CAAAA,CACTpB,QAAQ,CAACqB,+BAAAA,CAAAA;AACd,IAAA;IAEA,IAAIpB,MAAAA,CAAOqB,MAAM,CAAC,SAAA,CAAA,EAAY;AAC5B,QAAA,MAAMC,0BAA0BtB,MAAAA,CAAOqB,MAAM,CAAC,SAAA,CAAA,CAAWhB,OAAO,CAAC,WAAA,CAAA;;QAEjEiB,uBAAAA,CAAwBC,UAAU,CAACC,iBAAAA,CAAAA,CAAmBC,OAAO,EAAA;QAC7DH,uBAAAA,CAAwBC,UAAU,CAACG,wBAAAA,CAAAA,CAA0BD,OAAO,EAAA;AACtE,IAAA;AACF;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var utils = require('@strapi/utils');
|
|
4
|
-
var _ = require('lodash
|
|
4
|
+
var _ = require('lodash');
|
|
5
5
|
var constants = require('../constants.js');
|
|
6
6
|
var auditLogs = require('../audit-logs.js');
|
|
7
7
|
var index = require('../utils/index.js');
|
|
@@ -17,17 +17,14 @@ const getGroupName = (queryValue)=>{
|
|
|
17
17
|
case 'type':
|
|
18
18
|
return 'type';
|
|
19
19
|
case 'locale':
|
|
20
|
-
return ___default.default.
|
|
20
|
+
return (action)=>___default.default.get(action, 'locale.name', 'No locale');
|
|
21
21
|
default:
|
|
22
22
|
return 'contentType.displayName';
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
const createReleaseActionService = ({ strapi })=>{
|
|
26
26
|
const getLocalesDataForActions = async ()=>{
|
|
27
|
-
|
|
28
|
-
return {};
|
|
29
|
-
}
|
|
30
|
-
const allLocales = await strapi.plugin('i18n').service('locales').find() || [];
|
|
27
|
+
const allLocales = await strapi.localization.getLocales();
|
|
31
28
|
return allLocales.reduce((acc, locale)=>{
|
|
32
29
|
acc[locale.code] = {
|
|
33
30
|
name: locale.name,
|
|
@@ -190,7 +187,7 @@ const createReleaseActionService = ({ strapi })=>{
|
|
|
190
187
|
};
|
|
191
188
|
});
|
|
192
189
|
const groupName = getGroupName(groupBy);
|
|
193
|
-
return ___default.default.groupBy(groupName)
|
|
190
|
+
return ___default.default.groupBy(formattedData, groupName);
|
|
194
191
|
},
|
|
195
192
|
async getContentTypeModelsFromActions (actions) {
|
|
196
193
|
const contentTypeUids = actions.reduce((acc, action)=>{
|