@strapi/content-releases 5.0.0-rc.0 → 5.0.0-rc.10

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.
Files changed (67) hide show
  1. package/dist/_chunks/{App-6gbM0io-.mjs → App-DMILern_.mjs} +152 -100
  2. package/dist/_chunks/App-DMILern_.mjs.map +1 -0
  3. package/dist/_chunks/{App-zzUitryC.js → App-fAgiijnc.js} +148 -96
  4. package/dist/_chunks/App-fAgiijnc.js.map +1 -0
  5. package/dist/_chunks/{SettingsPage-CTOl3Qtw.js → ReleasesSettingsPage-YVZJH-oN.js} +35 -14
  6. package/dist/_chunks/ReleasesSettingsPage-YVZJH-oN.js.map +1 -0
  7. package/dist/_chunks/{SettingsPage-CuSH193e.mjs → ReleasesSettingsPage-dwoRuXB-.mjs} +35 -14
  8. package/dist/_chunks/ReleasesSettingsPage-dwoRuXB-.mjs.map +1 -0
  9. package/dist/_chunks/{en-1_1re1mc.js → en-CmYoEnA7.js} +3 -1
  10. package/dist/_chunks/en-CmYoEnA7.js.map +1 -0
  11. package/dist/_chunks/{en-C3sq5KNP.mjs → en-D0yVZFqf.mjs} +3 -1
  12. package/dist/_chunks/en-D0yVZFqf.mjs.map +1 -0
  13. package/dist/_chunks/{index-BxRiXenX.js → index--_NWfuDG.js} +251 -11
  14. package/dist/_chunks/index--_NWfuDG.js.map +1 -0
  15. package/dist/_chunks/{index-CuchqQ4_.mjs → index-CYsQToWs.mjs} +265 -25
  16. package/dist/_chunks/index-CYsQToWs.mjs.map +1 -0
  17. package/dist/_chunks/schemas-63pFihNF.mjs +44 -0
  18. package/dist/_chunks/schemas-63pFihNF.mjs.map +1 -0
  19. package/dist/_chunks/{validation-schemas-bib1fBc7.js → schemas-z5zp-_Gd.js} +21 -6
  20. package/dist/_chunks/schemas-z5zp-_Gd.js.map +1 -0
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +1 -1
  23. package/dist/admin/src/components/ReleaseListCell.d.ts +28 -0
  24. package/dist/admin/src/constants.d.ts +18 -0
  25. package/dist/admin/src/modules/hooks.d.ts +7 -0
  26. package/dist/admin/src/pages/ReleasesSettingsPage.d.ts +1 -0
  27. package/dist/admin/src/services/release.d.ts +6 -4
  28. package/dist/admin/src/validation/schemas.d.ts +6 -0
  29. package/dist/server/index.js +83 -94
  30. package/dist/server/index.js.map +1 -1
  31. package/dist/server/index.mjs +83 -94
  32. package/dist/server/index.mjs.map +1 -1
  33. package/dist/server/src/controllers/index.d.ts +2 -0
  34. package/dist/server/src/controllers/index.d.ts.map +1 -1
  35. package/dist/server/src/controllers/release-action.d.ts +1 -0
  36. package/dist/server/src/controllers/release-action.d.ts.map +1 -1
  37. package/dist/server/src/controllers/release.d.ts +1 -0
  38. package/dist/server/src/controllers/release.d.ts.map +1 -1
  39. package/dist/server/src/controllers/validation/release.d.ts +1 -0
  40. package/dist/server/src/controllers/validation/release.d.ts.map +1 -1
  41. package/dist/server/src/controllers/validation/settings.d.ts +1 -0
  42. package/dist/server/src/controllers/validation/settings.d.ts.map +1 -1
  43. package/dist/server/src/index.d.ts +2 -0
  44. package/dist/server/src/index.d.ts.map +1 -1
  45. package/dist/server/src/routes/release-action.d.ts.map +1 -1
  46. package/dist/server/src/routes/release.d.ts.map +1 -1
  47. package/dist/shared/contracts/release-actions.d.ts +3 -5
  48. package/dist/shared/contracts/release-actions.d.ts.map +1 -1
  49. package/dist/shared/contracts/releases.d.ts +3 -2
  50. package/dist/shared/contracts/releases.d.ts.map +1 -1
  51. package/dist/shared/contracts/settings.d.ts +1 -1
  52. package/dist/shared/contracts/settings.d.ts.map +1 -1
  53. package/package.json +10 -10
  54. package/dist/_chunks/App-6gbM0io-.mjs.map +0 -1
  55. package/dist/_chunks/App-zzUitryC.js.map +0 -1
  56. package/dist/_chunks/SettingsPage-CTOl3Qtw.js.map +0 -1
  57. package/dist/_chunks/SettingsPage-CuSH193e.mjs.map +0 -1
  58. package/dist/_chunks/en-1_1re1mc.js.map +0 -1
  59. package/dist/_chunks/en-C3sq5KNP.mjs.map +0 -1
  60. package/dist/_chunks/index-BxRiXenX.js.map +0 -1
  61. package/dist/_chunks/index-CuchqQ4_.mjs.map +0 -1
  62. package/dist/_chunks/validation-schemas-C7P2rhPu.mjs +0 -29
  63. package/dist/_chunks/validation-schemas-C7P2rhPu.mjs.map +0 -1
  64. package/dist/_chunks/validation-schemas-bib1fBc7.js.map +0 -1
  65. package/dist/admin/src/pages/SettingsPage.d.ts +0 -1
  66. package/dist/shared/validation-schemas.d.ts +0 -3
  67. package/dist/shared/validation-schemas.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas-63pFihNF.mjs","sources":["../../admin/src/validation/schemas.ts"],"sourcesContent":["import { translatedErrors } from '@strapi/admin/strapi-admin';\nimport { zonedTimeToUtc } from 'date-fns-tz';\nimport * as yup from 'yup';\n\n/**\n * FormikErrors type enforce us to always return a string as error.\n * We need these errors to be translated, so we need to create a hook to be able to use the formatMessage function.\n */\nexport const RELEASE_SCHEMA = yup\n .object()\n .shape({\n name: yup.string().trim().required(translatedErrors.required.id),\n scheduledAt: yup.string().nullable(),\n isScheduled: yup.boolean().optional(),\n time: yup\n .string()\n .when('isScheduled', {\n is: true,\n then: yup.string().trim().required(translatedErrors.required.id),\n otherwise: yup.string().nullable(),\n })\n .test(\n 'time-in-future-if-today',\n 'content-releases.modal.form.time.has-passed',\n function (time) {\n const { date, timezone } = this.parent;\n\n if (!date || !timezone || !time) {\n return true;\n }\n\n // Timezone is in format \"UTC&Europe/Paris\", so we get the region part for the dates functions\n const region = timezone.split('&')[1];\n\n const selectedTime = zonedTimeToUtc(`${date} ${time}`, region);\n const now = new Date();\n\n return selectedTime > now;\n }\n ),\n timezone: yup.string().when('isScheduled', {\n is: true,\n then: yup.string().required(translatedErrors.required.id).nullable(),\n otherwise: yup.string().nullable(),\n }),\n date: yup.string().when('isScheduled', {\n is: true,\n then: yup.string().required(translatedErrors.required.id).nullable(),\n otherwise: yup.string().nullable(),\n }),\n })\n .required()\n .noUnknown();\n\nexport const SETTINGS_SCHEMA = yup\n .object()\n .shape({\n defaultTimezone: yup.string().nullable().default(null),\n })\n .required()\n .noUnknown();\n"],"names":[],"mappings":";;;AAQO,MAAM,iBAAiB,IAC3B,OAAO,EACP,MAAM;AAAA,EACL,MAAM,IAAI,SAAS,KAAO,EAAA,SAAS,iBAAiB,SAAS,EAAE;AAAA,EAC/D,aAAa,IAAI,OAAO,EAAE,SAAS;AAAA,EACnC,aAAa,IAAI,QAAQ,EAAE,SAAS;AAAA,EACpC,MAAM,IACH,SACA,KAAK,eAAe;AAAA,IACnB,IAAI;AAAA,IACJ,MAAM,IAAI,SAAS,KAAO,EAAA,SAAS,iBAAiB,SAAS,EAAE;AAAA,IAC/D,WAAW,IAAI,OAAO,EAAE,SAAS;AAAA,EAClC,CAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,IACA,SAAU,MAAM;AACd,YAAM,EAAE,MAAM,aAAa,KAAK;AAEhC,UAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM;AACxB,eAAA;AAAA,MACT;AAGA,YAAM,SAAS,SAAS,MAAM,GAAG,EAAE,CAAC;AAEpC,YAAM,eAAe,eAAe,GAAG,IAAI,IAAI,IAAI,IAAI,MAAM;AACvD,YAAA,0BAAU;AAEhB,aAAO,eAAe;AAAA,IACxB;AAAA,EACF;AAAA,EACF,UAAU,IAAI,SAAS,KAAK,eAAe;AAAA,IACzC,IAAI;AAAA,IACJ,MAAM,IAAI,SAAS,SAAS,iBAAiB,SAAS,EAAE,EAAE,SAAS;AAAA,IACnE,WAAW,IAAI,OAAO,EAAE,SAAS;AAAA,EAAA,CAClC;AAAA,EACD,MAAM,IAAI,SAAS,KAAK,eAAe;AAAA,IACrC,IAAI;AAAA,IACJ,MAAM,IAAI,SAAS,SAAS,iBAAiB,SAAS,EAAE,EAAE,SAAS;AAAA,IACnE,WAAW,IAAI,OAAO,EAAE,SAAS;AAAA,EAAA,CAClC;AACH,CAAC,EACA,SAAS,EACT,UAAU;AAEN,MAAM,kBAAkB,IAC5B,OAAO,EACP,MAAM;AAAA,EACL,iBAAiB,IAAI,OAAA,EAAS,SAAS,EAAE,QAAQ,IAAI;AACvD,CAAC,EACA,SAAS,EACT,UAAU;"}
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ const strapiAdmin = require("@strapi/admin/strapi-admin");
3
+ const dateFnsTz = require("date-fns-tz");
2
4
  const yup = require("yup");
3
5
  function _interopNamespace(e) {
4
6
  if (e && e.__esModule)
@@ -20,22 +22,35 @@ function _interopNamespace(e) {
20
22
  }
21
23
  const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
22
24
  const RELEASE_SCHEMA = yup__namespace.object().shape({
23
- name: yup__namespace.string().trim().required(),
25
+ name: yup__namespace.string().trim().required(strapiAdmin.translatedErrors.required.id),
24
26
  scheduledAt: yup__namespace.string().nullable(),
25
27
  isScheduled: yup__namespace.boolean().optional(),
26
28
  time: yup__namespace.string().when("isScheduled", {
27
29
  is: true,
28
- then: yup__namespace.string().trim().required(),
30
+ then: yup__namespace.string().trim().required(strapiAdmin.translatedErrors.required.id),
29
31
  otherwise: yup__namespace.string().nullable()
30
- }),
32
+ }).test(
33
+ "time-in-future-if-today",
34
+ "content-releases.modal.form.time.has-passed",
35
+ function(time) {
36
+ const { date, timezone } = this.parent;
37
+ if (!date || !timezone || !time) {
38
+ return true;
39
+ }
40
+ const region = timezone.split("&")[1];
41
+ const selectedTime = dateFnsTz.zonedTimeToUtc(`${date} ${time}`, region);
42
+ const now = /* @__PURE__ */ new Date();
43
+ return selectedTime > now;
44
+ }
45
+ ),
31
46
  timezone: yup__namespace.string().when("isScheduled", {
32
47
  is: true,
33
- then: yup__namespace.string().required().nullable(),
48
+ then: yup__namespace.string().required(strapiAdmin.translatedErrors.required.id).nullable(),
34
49
  otherwise: yup__namespace.string().nullable()
35
50
  }),
36
51
  date: yup__namespace.string().when("isScheduled", {
37
52
  is: true,
38
- then: yup__namespace.string().required().nullable(),
53
+ then: yup__namespace.string().required(strapiAdmin.translatedErrors.required.id).nullable(),
39
54
  otherwise: yup__namespace.string().nullable()
40
55
  })
41
56
  }).required().noUnknown();
@@ -44,4 +59,4 @@ const SETTINGS_SCHEMA = yup__namespace.object().shape({
44
59
  }).required().noUnknown();
45
60
  exports.RELEASE_SCHEMA = RELEASE_SCHEMA;
46
61
  exports.SETTINGS_SCHEMA = SETTINGS_SCHEMA;
47
- //# sourceMappingURL=validation-schemas-bib1fBc7.js.map
62
+ //# sourceMappingURL=schemas-z5zp-_Gd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas-z5zp-_Gd.js","sources":["../../admin/src/validation/schemas.ts"],"sourcesContent":["import { translatedErrors } from '@strapi/admin/strapi-admin';\nimport { zonedTimeToUtc } from 'date-fns-tz';\nimport * as yup from 'yup';\n\n/**\n * FormikErrors type enforce us to always return a string as error.\n * We need these errors to be translated, so we need to create a hook to be able to use the formatMessage function.\n */\nexport const RELEASE_SCHEMA = yup\n .object()\n .shape({\n name: yup.string().trim().required(translatedErrors.required.id),\n scheduledAt: yup.string().nullable(),\n isScheduled: yup.boolean().optional(),\n time: yup\n .string()\n .when('isScheduled', {\n is: true,\n then: yup.string().trim().required(translatedErrors.required.id),\n otherwise: yup.string().nullable(),\n })\n .test(\n 'time-in-future-if-today',\n 'content-releases.modal.form.time.has-passed',\n function (time) {\n const { date, timezone } = this.parent;\n\n if (!date || !timezone || !time) {\n return true;\n }\n\n // Timezone is in format \"UTC&Europe/Paris\", so we get the region part for the dates functions\n const region = timezone.split('&')[1];\n\n const selectedTime = zonedTimeToUtc(`${date} ${time}`, region);\n const now = new Date();\n\n return selectedTime > now;\n }\n ),\n timezone: yup.string().when('isScheduled', {\n is: true,\n then: yup.string().required(translatedErrors.required.id).nullable(),\n otherwise: yup.string().nullable(),\n }),\n date: yup.string().when('isScheduled', {\n is: true,\n then: yup.string().required(translatedErrors.required.id).nullable(),\n otherwise: yup.string().nullable(),\n }),\n })\n .required()\n .noUnknown();\n\nexport const SETTINGS_SCHEMA = yup\n .object()\n .shape({\n defaultTimezone: yup.string().nullable().default(null),\n })\n .required()\n .noUnknown();\n"],"names":["yup","translatedErrors","zonedTimeToUtc"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM,iBAAiBA,eAC3B,OAAO,EACP,MAAM;AAAA,EACL,MAAMA,eAAI,SAAS,KAAO,EAAA,SAASC,YAAAA,iBAAiB,SAAS,EAAE;AAAA,EAC/D,aAAaD,eAAI,OAAO,EAAE,SAAS;AAAA,EACnC,aAAaA,eAAI,QAAQ,EAAE,SAAS;AAAA,EACpC,MAAMA,eACH,SACA,KAAK,eAAe;AAAA,IACnB,IAAI;AAAA,IACJ,MAAMA,eAAI,SAAS,KAAO,EAAA,SAASC,YAAAA,iBAAiB,SAAS,EAAE;AAAA,IAC/D,WAAWD,eAAI,OAAO,EAAE,SAAS;AAAA,EAClC,CAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,IACA,SAAU,MAAM;AACd,YAAM,EAAE,MAAM,aAAa,KAAK;AAEhC,UAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM;AACxB,eAAA;AAAA,MACT;AAGA,YAAM,SAAS,SAAS,MAAM,GAAG,EAAE,CAAC;AAEpC,YAAM,eAAeE,UAAe,eAAA,GAAG,IAAI,IAAI,IAAI,IAAI,MAAM;AACvD,YAAA,0BAAU;AAEhB,aAAO,eAAe;AAAA,IACxB;AAAA,EACF;AAAA,EACF,UAAUF,eAAI,SAAS,KAAK,eAAe;AAAA,IACzC,IAAI;AAAA,IACJ,MAAMA,eAAI,SAAS,SAASC,YAAAA,iBAAiB,SAAS,EAAE,EAAE,SAAS;AAAA,IACnE,WAAWD,eAAI,OAAO,EAAE,SAAS;AAAA,EAAA,CAClC;AAAA,EACD,MAAMA,eAAI,SAAS,KAAK,eAAe;AAAA,IACrC,IAAI;AAAA,IACJ,MAAMA,eAAI,SAAS,SAASC,YAAAA,iBAAiB,SAAS,EAAE,EAAE,SAAS;AAAA,IACnE,WAAWD,eAAI,OAAO,EAAE,SAAS;AAAA,EAAA,CAClC;AACH,CAAC,EACA,SAAS,EACT,UAAU;AAEN,MAAM,kBAAkBA,eAC5B,OAAO,EACP,MAAM;AAAA,EACL,iBAAiBA,eAAI,OAAA,EAAS,SAAS,EAAE,QAAQ,IAAI;AACvD,CAAC,EACA,SAAS,EACT,UAAU;;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-BxRiXenX.js");
2
+ const index = require("../_chunks/index--_NWfuDG.js");
3
3
  require("@strapi/icons");
4
4
  module.exports = index.admin;
5
5
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { m } from "../_chunks/index-CuchqQ4_.mjs";
1
+ import { m } from "../_chunks/index-CYsQToWs.mjs";
2
2
  import "@strapi/icons";
3
3
  export {
4
4
  m as default
@@ -0,0 +1,28 @@
1
+ import { ListFieldLayout, ListLayout } from '@strapi/content-manager/strapi-admin';
2
+ import { Modules, UID } from '@strapi/types';
3
+ interface AddColumnToTableHookArgs {
4
+ layout: ListLayout;
5
+ displayedHeaders: ListFieldLayout[];
6
+ }
7
+ declare const addColumnToTableHook: ({ displayedHeaders, layout }: AddColumnToTableHookArgs) => {
8
+ displayedHeaders: (ListFieldLayout | {
9
+ searchable: boolean;
10
+ sortable: boolean;
11
+ name: string;
12
+ label: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ };
16
+ cellFormatter: (props: Modules.Documents.AnyDocument, _: any, { model }: {
17
+ model: UID.ContentType;
18
+ }) => import("react/jsx-runtime").JSX.Element;
19
+ })[];
20
+ layout: ListLayout;
21
+ };
22
+ interface ReleaseListCellProps extends Modules.Documents.AnyDocument {
23
+ documentId: Modules.Documents.ID;
24
+ model: UID.ContentType;
25
+ }
26
+ declare const ReleaseListCell: ({ documentId, model }: ReleaseListCellProps) => import("react/jsx-runtime").JSX.Element;
27
+ export { ReleaseListCell, addColumnToTableHook };
28
+ export type { ReleaseListCellProps };
@@ -56,3 +56,21 @@ export declare const PERMISSIONS: {
56
56
  conditions: never[];
57
57
  }[];
58
58
  };
59
+ export declare const PERMISSIONS_SETTINGS: {
60
+ read: {
61
+ action: string;
62
+ subject: null;
63
+ id: string;
64
+ actionParameters: {};
65
+ properties: {};
66
+ conditions: never[];
67
+ }[];
68
+ update: {
69
+ action: string;
70
+ subject: null;
71
+ id: string;
72
+ actionParameters: {};
73
+ properties: {};
74
+ conditions: never[];
75
+ }[];
76
+ };
@@ -0,0 +1,7 @@
1
+ import { Dispatch } from '@reduxjs/toolkit';
2
+ import { TypedUseSelectorHook } from 'react-redux';
3
+ import type { Store } from '@strapi/admin/strapi-admin';
4
+ type RootState = ReturnType<Store['getState']>;
5
+ declare const useTypedDispatch: () => Dispatch;
6
+ declare const useTypedSelector: TypedUseSelectorHook<RootState>;
7
+ export { useTypedSelector, useTypedDispatch };
@@ -0,0 +1 @@
1
+ export declare const ProtectedReleasesSettingsPage: () => import("react/jsx-runtime").JSX.Element;
@@ -65,9 +65,10 @@ declare const releaseApi: import("@reduxjs/toolkit/query").Api<import("@reduxjs/
65
65
  }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "Release" | "ReleaseAction" | "EntriesInRelease" | "ReleaseSettings", DeleteRelease.Response, "adminApi">;
66
66
  getMappedEntriesInReleases: import("@reduxjs/toolkit/query").QueryDefinition<{
67
67
  contentTypeUid: import("@strapi/types/dist/uid").ContentType;
68
- entriesIds: number[];
68
+ documentIds: string[];
69
+ locale?: string | undefined;
69
70
  }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "Release" | "ReleaseAction" | "EntriesInRelease" | "ReleaseSettings", {
70
- [entryId: number]: Pick<import("../../../shared/contracts/releases").Release, "id" | "name">[];
71
+ [documentId: string]: Pick<import("../../../shared/contracts/releases").Release, "id" | "name">[];
71
72
  }, "adminApi">;
72
73
  getReleaseSettings: import("@reduxjs/toolkit/query").QueryDefinition<void | GetSettings.Request, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "Release" | "ReleaseAction" | "EntriesInRelease" | "ReleaseSettings", GetSettings.Response, "adminApi">;
73
74
  updateReleaseSettings: import("@reduxjs/toolkit/query").MutationDefinition<import("../../../shared/contracts/settings").Settings, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "Release" | "ReleaseAction" | "EntriesInRelease" | "ReleaseSettings", void, "adminApi">;
@@ -103,8 +104,9 @@ declare const useGetReleasesQuery: import("@reduxjs/toolkit/dist/query/react/bui
103
104
  id: import("@strapi/types/dist/data").ID;
104
105
  }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "Release" | "ReleaseAction" | "EntriesInRelease" | "ReleaseSettings", DeleteRelease.Response, "adminApi">>, useGetMappedEntriesInReleasesQuery: import("@reduxjs/toolkit/dist/query/react/buildHooks").UseQuery<import("@reduxjs/toolkit/query").QueryDefinition<{
105
106
  contentTypeUid: import("@strapi/types/dist/uid").ContentType;
106
- entriesIds: number[];
107
+ documentIds: string[];
108
+ locale?: string | undefined;
107
109
  }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "Release" | "ReleaseAction" | "EntriesInRelease" | "ReleaseSettings", {
108
- [entryId: number]: Pick<import("../../../shared/contracts/releases").Release, "id" | "name">[];
110
+ [documentId: string]: Pick<import("../../../shared/contracts/releases").Release, "id" | "name">[];
109
111
  }, "adminApi">>, useGetReleaseSettingsQuery: import("@reduxjs/toolkit/dist/query/react/buildHooks").UseQuery<import("@reduxjs/toolkit/query").QueryDefinition<void | GetSettings.Request, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "Release" | "ReleaseAction" | "EntriesInRelease" | "ReleaseSettings", GetSettings.Response, "adminApi">>, useUpdateReleaseSettingsMutation: import("@reduxjs/toolkit/dist/query/react/buildHooks").UseMutation<import("@reduxjs/toolkit/query").MutationDefinition<import("../../../shared/contracts/settings").Settings, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "Release" | "ReleaseAction" | "EntriesInRelease" | "ReleaseSettings", void, "adminApi">>;
110
112
  export { useGetReleasesQuery, useGetReleasesForEntryQuery, useGetReleaseQuery, useGetReleaseActionsQuery, useCreateReleaseMutation, useCreateReleaseActionMutation, useCreateManyReleaseActionsMutation, useUpdateReleaseMutation, useUpdateReleaseActionMutation, usePublishReleaseMutation, useDeleteReleaseActionMutation, useDeleteReleaseMutation, useGetMappedEntriesInReleasesQuery, useGetReleaseSettingsQuery, useUpdateReleaseSettingsMutation, releaseApi, };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * FormikErrors type enforce us to always return a string as error.
3
+ * We need these errors to be translated, so we need to create a hook to be able to use the formatMessage function.
4
+ */
5
+ export declare const RELEASE_SCHEMA: any;
6
+ export declare const SETTINGS_SCHEMA: any;
@@ -1135,11 +1135,11 @@ const createReleaseValidationService = ({ strapi: strapi2 }) => ({
1135
1135
  throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
1136
1136
  }
1137
1137
  const isEntryInRelease = release2.actions.some(
1138
- (action) => Number(action.entryDocumentId) === Number(releaseActionArgs.entryDocumentId) && action.contentType === releaseActionArgs.contentType && action.locale === releaseActionArgs.locale
1138
+ (action) => action.entryDocumentId === releaseActionArgs.entryDocumentId && action.contentType === releaseActionArgs.contentType && (releaseActionArgs.locale ? action.locale === releaseActionArgs.locale : true)
1139
1139
  );
1140
1140
  if (isEntryInRelease) {
1141
1141
  throw new AlreadyOnReleaseError(
1142
- `Entry with documentId ${releaseActionArgs.entryDocumentId} ${releaseActionArgs.locale ? `(${releaseActionArgs.locale})` : ""} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`
1142
+ `Entry with documentId ${releaseActionArgs.entryDocumentId}${releaseActionArgs.locale ? `( ${releaseActionArgs.locale})` : ""} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`
1143
1143
  );
1144
1144
  }
1145
1145
  },
@@ -1272,29 +1272,15 @@ const services = {
1272
1272
  scheduling: createSchedulingService,
1273
1273
  settings: createSettingsService
1274
1274
  };
1275
- const RELEASE_SCHEMA = yup__namespace.object().shape({
1276
- name: yup__namespace.string().trim().required(),
1277
- scheduledAt: yup__namespace.string().nullable(),
1278
- isScheduled: yup__namespace.boolean().optional(),
1279
- time: yup__namespace.string().when("isScheduled", {
1280
- is: true,
1281
- then: yup__namespace.string().trim().required(),
1282
- otherwise: yup__namespace.string().nullable()
1283
- }),
1284
- timezone: yup__namespace.string().when("isScheduled", {
1285
- is: true,
1286
- then: yup__namespace.string().required().nullable(),
1287
- otherwise: yup__namespace.string().nullable()
1288
- }),
1289
- date: yup__namespace.string().when("isScheduled", {
1290
- is: true,
1291
- then: yup__namespace.string().required().nullable(),
1292
- otherwise: yup__namespace.string().nullable()
1275
+ const RELEASE_SCHEMA = utils.yup.object().shape({
1276
+ name: utils.yup.string().trim().required(),
1277
+ scheduledAt: utils.yup.string().nullable(),
1278
+ timezone: utils.yup.string().when("scheduledAt", {
1279
+ is: (value) => value !== null && value !== void 0,
1280
+ then: utils.yup.string().required(),
1281
+ otherwise: utils.yup.string().nullable()
1293
1282
  })
1294
1283
  }).required().noUnknown();
1295
- const SETTINGS_SCHEMA = yup__namespace.object().shape({
1296
- defaultTimezone: yup__namespace.string().nullable().default(null)
1297
- }).required().noUnknown();
1298
1284
  const FIND_BY_DOCUMENT_ATTACHED_PARAMS_SCHEMA = utils.yup.object().shape({
1299
1285
  contentType: utils.yup.string().required(),
1300
1286
  entryDocumentId: utils.yup.string().nullable(),
@@ -1422,43 +1408,50 @@ const releaseController = {
1422
1408
  };
1423
1409
  ctx.body = { data };
1424
1410
  },
1425
- /* @TODO: Migrate to new api
1426
- async mapEntriesToReleases(ctx: Koa.Context) {
1427
- const { contentTypeUid, entriesIds } = ctx.query;
1428
-
1429
- if (!contentTypeUid || !entriesIds) {
1430
- throw new errors.ValidationError('Missing required query parameters');
1411
+ async mapEntriesToReleases(ctx) {
1412
+ const { contentTypeUid, documentIds, locale } = ctx.query;
1413
+ if (!contentTypeUid || !documentIds) {
1414
+ throw new utils.errors.ValidationError("Missing required query parameters");
1415
+ }
1416
+ const releaseService = getService("release", { strapi });
1417
+ const releasesWithActions = await releaseService.findMany({
1418
+ where: {
1419
+ releasedAt: null,
1420
+ actions: {
1421
+ contentType: contentTypeUid,
1422
+ entryDocumentId: {
1423
+ $in: documentIds
1424
+ },
1425
+ locale
1426
+ }
1427
+ },
1428
+ populate: {
1429
+ actions: true
1431
1430
  }
1432
-
1433
- const releaseService = getService('release', { strapi });
1434
-
1435
- const releasesWithActions = await releaseService.findMany(
1436
- contentTypeUid,
1437
- entriesIds
1438
- );
1439
-
1440
- const mappedEntriesInReleases = releasesWithActions.reduce(
1441
- // TODO: Fix for v5 removed mappedEntriedToRelease
1442
- (acc: MapEntriesToReleases.Response['data'], release: Release) => {
1443
- release.actions.forEach((action) => {
1444
- if (!acc[action.entry.id]) {
1445
- acc[action.entry.id] = [{ id: release.id, name: release.name }];
1446
- } else {
1447
- acc[action.entry.id].push({ id: release.id, name: release.name });
1448
- }
1449
- });
1450
-
1451
- return acc;
1452
- },
1453
- // TODO: Fix for v5 removed mappedEntriedToRelease
1454
- {} as MapEntriesToReleases.Response['data']
1455
- );
1456
-
1457
- ctx.body = {
1458
- data: mappedEntriesInReleases,
1459
- };
1460
- },
1461
- */
1431
+ });
1432
+ const mappedEntriesInReleases = releasesWithActions.reduce(
1433
+ (acc, release2) => {
1434
+ release2.actions.forEach((action) => {
1435
+ if (action.contentType !== contentTypeUid) {
1436
+ return;
1437
+ }
1438
+ if (locale && action.locale !== locale) {
1439
+ return;
1440
+ }
1441
+ if (!acc[action.entryDocumentId]) {
1442
+ acc[action.entryDocumentId] = [{ id: release2.id, name: release2.name }];
1443
+ } else {
1444
+ acc[action.entryDocumentId].push({ id: release2.id, name: release2.name });
1445
+ }
1446
+ });
1447
+ return acc;
1448
+ },
1449
+ {}
1450
+ );
1451
+ ctx.body = {
1452
+ data: mappedEntriesInReleases
1453
+ };
1454
+ },
1462
1455
  async create(ctx) {
1463
1456
  const user = ctx.state.user;
1464
1457
  const releaseArgs = ctx.request.body;
@@ -1551,22 +1544,20 @@ const releaseActionController = {
1551
1544
  data: releaseAction2
1552
1545
  });
1553
1546
  },
1554
- /*
1555
- async createMany(ctx: Koa.Context) {
1556
- const releaseId: CreateManyReleaseActions.Request['params']['releaseId'] = ctx.params.releaseId;
1557
- const releaseActionsArgs = ctx.request.body as CreateManyReleaseActions.Request['body'];
1547
+ async createMany(ctx) {
1548
+ const releaseId = ctx.params.releaseId;
1549
+ const releaseActionsArgs = ctx.request.body;
1558
1550
  await Promise.all(
1559
1551
  releaseActionsArgs.map((releaseActionArgs) => validateReleaseAction(releaseActionArgs))
1560
1552
  );
1561
- const releaseActionService = getService('release-action', { strapi });
1553
+ const releaseActionService = getService("release-action", { strapi });
1562
1554
  const releaseActions = await strapi.db.transaction(async () => {
1563
- const releaseActions = await Promise.all(
1555
+ const releaseActions2 = await Promise.all(
1564
1556
  releaseActionsArgs.map(async (releaseActionArgs) => {
1565
1557
  try {
1566
1558
  const action = await releaseActionService.create(releaseId, releaseActionArgs);
1567
1559
  return action;
1568
1560
  } catch (error) {
1569
- // If the entry is already in the release, we don't want to throw an error, so we catch and ignore it
1570
1561
  if (error instanceof AlreadyOnReleaseError) {
1571
1562
  return null;
1572
1563
  }
@@ -1574,18 +1565,17 @@ const releaseActionController = {
1574
1565
  }
1575
1566
  })
1576
1567
  );
1577
- return releaseActions;
1568
+ return releaseActions2;
1578
1569
  });
1579
1570
  const newReleaseActions = releaseActions.filter((action) => action !== null);
1580
1571
  ctx.created({
1581
1572
  data: newReleaseActions,
1582
1573
  meta: {
1583
1574
  entriesAlreadyInRelease: releaseActions.length - newReleaseActions.length,
1584
- totalEntries: releaseActions.length,
1585
- },
1575
+ totalEntries: releaseActions.length
1576
+ }
1586
1577
  });
1587
1578
  },
1588
- */
1589
1579
  async findMany(ctx) {
1590
1580
  const releaseId = ctx.params.releaseId;
1591
1581
  const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
@@ -1658,6 +1648,9 @@ const releaseActionController = {
1658
1648
  };
1659
1649
  }
1660
1650
  };
1651
+ const SETTINGS_SCHEMA = yup__namespace.object().shape({
1652
+ defaultTimezone: yup__namespace.string().nullable().default(null)
1653
+ }).required().noUnknown();
1661
1654
  const validateSettings = utils.validateYupSchema(SETTINGS_SCHEMA);
1662
1655
  const settingsController = {
1663
1656
  async find(ctx) {
@@ -1681,24 +1674,22 @@ const controllers = {
1681
1674
  const release = {
1682
1675
  type: "admin",
1683
1676
  routes: [
1684
- /*
1685
1677
  {
1686
- method: 'GET',
1687
- path: '/mapEntriesToReleases',
1688
- handler: 'release.mapEntriesToReleases',
1678
+ method: "GET",
1679
+ path: "/mapEntriesToReleases",
1680
+ handler: "release.mapEntriesToReleases",
1689
1681
  config: {
1690
1682
  policies: [
1691
- 'admin::isAuthenticatedAdmin',
1683
+ "admin::isAuthenticatedAdmin",
1692
1684
  {
1693
- name: 'admin::hasPermissions',
1685
+ name: "admin::hasPermissions",
1694
1686
  config: {
1695
- actions: ['plugin::content-releases.read'],
1696
- },
1697
- },
1698
- ],
1699
- },
1687
+ actions: ["plugin::content-releases.read"]
1688
+ }
1689
+ }
1690
+ ]
1691
+ }
1700
1692
  },
1701
- */
1702
1693
  {
1703
1694
  method: "GET",
1704
1695
  path: "/getByDocumentAttached",
@@ -1832,24 +1823,22 @@ const releaseAction = {
1832
1823
  ]
1833
1824
  }
1834
1825
  },
1835
- /*
1836
1826
  {
1837
- method: 'POST',
1838
- path: '/:releaseId/actions/bulk',
1839
- handler: 'release-action.createMany',
1827
+ method: "POST",
1828
+ path: "/:releaseId/actions/bulk",
1829
+ handler: "release-action.createMany",
1840
1830
  config: {
1841
1831
  policies: [
1842
- 'admin::isAuthenticatedAdmin',
1832
+ "admin::isAuthenticatedAdmin",
1843
1833
  {
1844
- name: 'admin::hasPermissions',
1834
+ name: "admin::hasPermissions",
1845
1835
  config: {
1846
- actions: ['plugin::content-releases.create-action'],
1847
- },
1848
- },
1849
- ],
1850
- },
1836
+ actions: ["plugin::content-releases.create-action"]
1837
+ }
1838
+ }
1839
+ ]
1840
+ }
1851
1841
  },
1852
- */
1853
1842
  {
1854
1843
  method: "GET",
1855
1844
  path: "/:releaseId/actions",