@strapi/content-releases 0.0.0-experimental.f31889311d753b5f7d95198ae84d8fce1d156cd6 → 0.0.0-experimental.f74ae50eea1ce95176f088dba837e95b60fa2a4d

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 (52) hide show
  1. package/dist/_chunks/{App-Cf879yGs.mjs → App-Db0aPjrG.mjs} +40 -17
  2. package/dist/_chunks/App-Db0aPjrG.mjs.map +1 -0
  3. package/dist/_chunks/{App-BjBiAE8g.js → App-xHZkNTlJ.js} +39 -16
  4. package/dist/_chunks/App-xHZkNTlJ.js.map +1 -0
  5. package/dist/_chunks/{ReleasesSettingsPage-BlUuvtd9.mjs → ReleasesSettingsPage-C3rlM6Kf.mjs} +3 -3
  6. package/dist/_chunks/ReleasesSettingsPage-C3rlM6Kf.mjs.map +1 -0
  7. package/dist/_chunks/{ReleasesSettingsPage-D7kMSSvV.js → ReleasesSettingsPage-DxEYftwd.js} +3 -3
  8. package/dist/_chunks/ReleasesSettingsPage-DxEYftwd.js.map +1 -0
  9. package/dist/_chunks/{en-BCDLTJn3.js → en-CmYoEnA7.js} +2 -1
  10. package/dist/_chunks/en-CmYoEnA7.js.map +1 -0
  11. package/dist/_chunks/{en-CGXIF4vQ.mjs → en-D0yVZFqf.mjs} +2 -1
  12. package/dist/_chunks/en-D0yVZFqf.mjs.map +1 -0
  13. package/dist/_chunks/{index-1MxwkUQx.js → index-CulHY6KM.js} +276 -17
  14. package/dist/_chunks/index-CulHY6KM.js.map +1 -0
  15. package/dist/_chunks/{index-BG0Q8zkH.mjs → index-Dj_bL2s7.mjs} +279 -20
  16. package/dist/_chunks/index-Dj_bL2s7.mjs.map +1 -0
  17. package/dist/admin/index.js +1 -1
  18. package/dist/admin/index.mjs +1 -1
  19. package/dist/admin/src/components/ReleaseListCell.d.ts +28 -0
  20. package/dist/admin/src/services/release.d.ts +6 -4
  21. package/dist/server/index.js +101 -77
  22. package/dist/server/index.js.map +1 -1
  23. package/dist/server/index.mjs +101 -77
  24. package/dist/server/index.mjs.map +1 -1
  25. package/dist/server/src/controllers/index.d.ts +2 -0
  26. package/dist/server/src/controllers/index.d.ts.map +1 -1
  27. package/dist/server/src/controllers/release-action.d.ts +1 -0
  28. package/dist/server/src/controllers/release-action.d.ts.map +1 -1
  29. package/dist/server/src/controllers/release.d.ts +1 -0
  30. package/dist/server/src/controllers/release.d.ts.map +1 -1
  31. package/dist/server/src/index.d.ts +4 -0
  32. package/dist/server/src/index.d.ts.map +1 -1
  33. package/dist/server/src/routes/release-action.d.ts.map +1 -1
  34. package/dist/server/src/routes/release.d.ts.map +1 -1
  35. package/dist/server/src/services/index.d.ts +2 -0
  36. package/dist/server/src/services/index.d.ts.map +1 -1
  37. package/dist/server/src/services/release-action.d.ts +3 -1
  38. package/dist/server/src/services/release-action.d.ts.map +1 -1
  39. package/dist/shared/contracts/release-actions.d.ts +3 -5
  40. package/dist/shared/contracts/release-actions.d.ts.map +1 -1
  41. package/dist/shared/contracts/releases.d.ts +3 -2
  42. package/dist/shared/contracts/releases.d.ts.map +1 -1
  43. package/package.json +12 -11
  44. package/dist/_chunks/App-BjBiAE8g.js.map +0 -1
  45. package/dist/_chunks/App-Cf879yGs.mjs.map +0 -1
  46. package/dist/_chunks/ReleasesSettingsPage-BlUuvtd9.mjs.map +0 -1
  47. package/dist/_chunks/ReleasesSettingsPage-D7kMSSvV.js.map +0 -1
  48. package/dist/_chunks/en-BCDLTJn3.js.map +0 -1
  49. package/dist/_chunks/en-CGXIF4vQ.mjs.map +0 -1
  50. package/dist/_chunks/index-1MxwkUQx.js.map +0 -1
  51. package/dist/_chunks/index-BG0Q8zkH.mjs.map +0 -1
  52. package/strapi-server.js +0 -3
@@ -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 };
@@ -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, };
@@ -929,7 +929,7 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
929
929
  return contentTypesData;
930
930
  };
931
931
  return {
932
- async create(releaseId, action) {
932
+ async create(releaseId, action, { disableUpdateReleaseStatus = false } = {}) {
933
933
  const { validateEntryData, validateUniqueEntry } = getService("release-validation", {
934
934
  strapi: strapi2
935
935
  });
@@ -937,6 +937,14 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
937
937
  validateEntryData(action.contentType, action.entryDocumentId),
938
938
  validateUniqueEntry(releaseId, action)
939
939
  ]);
940
+ const model = strapi2.contentType(action.contentType);
941
+ if (model.kind === "singleType") {
942
+ const document = await strapi2.db.query(model.uid).findOne({ select: ["documentId"] });
943
+ if (!document) {
944
+ throw new utils.errors.NotFoundError(`No entry found for contentType ${action.contentType}`);
945
+ }
946
+ action.entryDocumentId = document.documentId;
947
+ }
940
948
  const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id: releaseId } });
941
949
  if (!release2) {
942
950
  throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
@@ -962,7 +970,9 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
962
970
  },
963
971
  populate: { release: { select: ["id"] } }
964
972
  });
965
- getService("release", { strapi: strapi2 }).updateReleaseStatus(release2.id);
973
+ if (!disableUpdateReleaseStatus) {
974
+ getService("release", { strapi: strapi2 }).updateReleaseStatus(release2.id);
975
+ }
966
976
  return releaseAction2;
967
977
  },
968
978
  async findPage(releaseId, query) {
@@ -1135,11 +1145,11 @@ const createReleaseValidationService = ({ strapi: strapi2 }) => ({
1135
1145
  throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
1136
1146
  }
1137
1147
  const isEntryInRelease = release2.actions.some(
1138
- (action) => Number(action.entryDocumentId) === Number(releaseActionArgs.entryDocumentId) && action.contentType === releaseActionArgs.contentType && action.locale === releaseActionArgs.locale
1148
+ (action) => action.entryDocumentId === releaseActionArgs.entryDocumentId && action.contentType === releaseActionArgs.contentType && (releaseActionArgs.locale ? action.locale === releaseActionArgs.locale : true)
1139
1149
  );
1140
1150
  if (isEntryInRelease) {
1141
1151
  throw new AlreadyOnReleaseError(
1142
- `Entry with documentId ${releaseActionArgs.entryDocumentId} ${releaseActionArgs.locale ? `(${releaseActionArgs.locale})` : ""} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`
1152
+ `Entry with documentId ${releaseActionArgs.entryDocumentId}${releaseActionArgs.locale ? `( ${releaseActionArgs.locale})` : ""} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`
1143
1153
  );
1144
1154
  }
1145
1155
  },
@@ -1306,7 +1316,15 @@ const releaseController = {
1306
1316
  const releaseService = getService("release", { strapi });
1307
1317
  const query = await permissionsManager.sanitizeQuery(ctx.query);
1308
1318
  await validatefindByDocumentAttachedParams(query);
1309
- const { contentType, entryDocumentId, hasEntryAttached, locale } = query;
1319
+ const model = strapi.getModel(query.contentType);
1320
+ if (model.kind && model.kind === "singleType") {
1321
+ const document = await strapi.db.query(model.uid).findOne({ select: ["documentId"] });
1322
+ if (!document) {
1323
+ throw new utils.errors.NotFoundError(`No entry found for contentType ${query.contentType}`);
1324
+ }
1325
+ query.entryDocumentId = document.documentId;
1326
+ }
1327
+ const { contentType, hasEntryAttached, entryDocumentId, locale } = query;
1310
1328
  const isEntryAttached = typeof hasEntryAttached === "string" ? Boolean(JSON.parse(hasEntryAttached)) : false;
1311
1329
  if (isEntryAttached) {
1312
1330
  const releases = await releaseService.findMany({
@@ -1408,43 +1426,50 @@ const releaseController = {
1408
1426
  };
1409
1427
  ctx.body = { data };
1410
1428
  },
1411
- /* @TODO: Migrate to new api
1412
- async mapEntriesToReleases(ctx: Koa.Context) {
1413
- const { contentTypeUid, entriesIds } = ctx.query;
1414
-
1415
- if (!contentTypeUid || !entriesIds) {
1416
- throw new errors.ValidationError('Missing required query parameters');
1429
+ async mapEntriesToReleases(ctx) {
1430
+ const { contentTypeUid, documentIds, locale } = ctx.query;
1431
+ if (!contentTypeUid || !documentIds) {
1432
+ throw new utils.errors.ValidationError("Missing required query parameters");
1433
+ }
1434
+ const releaseService = getService("release", { strapi });
1435
+ const releasesWithActions = await releaseService.findMany({
1436
+ where: {
1437
+ releasedAt: null,
1438
+ actions: {
1439
+ contentType: contentTypeUid,
1440
+ entryDocumentId: {
1441
+ $in: documentIds
1442
+ },
1443
+ locale
1444
+ }
1445
+ },
1446
+ populate: {
1447
+ actions: true
1417
1448
  }
1418
-
1419
- const releaseService = getService('release', { strapi });
1420
-
1421
- const releasesWithActions = await releaseService.findMany(
1422
- contentTypeUid,
1423
- entriesIds
1424
- );
1425
-
1426
- const mappedEntriesInReleases = releasesWithActions.reduce(
1427
- // TODO: Fix for v5 removed mappedEntriedToRelease
1428
- (acc: MapEntriesToReleases.Response['data'], release: Release) => {
1429
- release.actions.forEach((action) => {
1430
- if (!acc[action.entry.id]) {
1431
- acc[action.entry.id] = [{ id: release.id, name: release.name }];
1432
- } else {
1433
- acc[action.entry.id].push({ id: release.id, name: release.name });
1434
- }
1435
- });
1436
-
1437
- return acc;
1438
- },
1439
- // TODO: Fix for v5 removed mappedEntriedToRelease
1440
- {} as MapEntriesToReleases.Response['data']
1441
- );
1442
-
1443
- ctx.body = {
1444
- data: mappedEntriesInReleases,
1445
- };
1446
- },
1447
- */
1449
+ });
1450
+ const mappedEntriesInReleases = releasesWithActions.reduce(
1451
+ (acc, release2) => {
1452
+ release2.actions.forEach((action) => {
1453
+ if (action.contentType !== contentTypeUid) {
1454
+ return;
1455
+ }
1456
+ if (locale && action.locale !== locale) {
1457
+ return;
1458
+ }
1459
+ if (!acc[action.entryDocumentId]) {
1460
+ acc[action.entryDocumentId] = [{ id: release2.id, name: release2.name }];
1461
+ } else {
1462
+ acc[action.entryDocumentId].push({ id: release2.id, name: release2.name });
1463
+ }
1464
+ });
1465
+ return acc;
1466
+ },
1467
+ {}
1468
+ );
1469
+ ctx.body = {
1470
+ data: mappedEntriesInReleases
1471
+ };
1472
+ },
1448
1473
  async create(ctx) {
1449
1474
  const user = ctx.state.user;
1450
1475
  const releaseArgs = ctx.request.body;
@@ -1537,22 +1562,23 @@ const releaseActionController = {
1537
1562
  data: releaseAction2
1538
1563
  });
1539
1564
  },
1540
- /*
1541
- async createMany(ctx: Koa.Context) {
1542
- const releaseId: CreateManyReleaseActions.Request['params']['releaseId'] = ctx.params.releaseId;
1543
- const releaseActionsArgs = ctx.request.body as CreateManyReleaseActions.Request['body'];
1565
+ async createMany(ctx) {
1566
+ const releaseId = ctx.params.releaseId;
1567
+ const releaseActionsArgs = ctx.request.body;
1544
1568
  await Promise.all(
1545
1569
  releaseActionsArgs.map((releaseActionArgs) => validateReleaseAction(releaseActionArgs))
1546
1570
  );
1547
- const releaseActionService = getService('release-action', { strapi });
1571
+ const releaseActionService = getService("release-action", { strapi });
1572
+ const releaseService = getService("release", { strapi });
1548
1573
  const releaseActions = await strapi.db.transaction(async () => {
1549
- const releaseActions = await Promise.all(
1574
+ const releaseActions2 = await Promise.all(
1550
1575
  releaseActionsArgs.map(async (releaseActionArgs) => {
1551
1576
  try {
1552
- const action = await releaseActionService.create(releaseId, releaseActionArgs);
1577
+ const action = await releaseActionService.create(releaseId, releaseActionArgs, {
1578
+ disableUpdateReleaseStatus: true
1579
+ });
1553
1580
  return action;
1554
1581
  } catch (error) {
1555
- // If the entry is already in the release, we don't want to throw an error, so we catch and ignore it
1556
1582
  if (error instanceof AlreadyOnReleaseError) {
1557
1583
  return null;
1558
1584
  }
@@ -1560,18 +1586,20 @@ const releaseActionController = {
1560
1586
  }
1561
1587
  })
1562
1588
  );
1563
- return releaseActions;
1589
+ return releaseActions2;
1564
1590
  });
1565
1591
  const newReleaseActions = releaseActions.filter((action) => action !== null);
1592
+ if (newReleaseActions.length > 0) {
1593
+ releaseService.updateReleaseStatus(releaseId);
1594
+ }
1566
1595
  ctx.created({
1567
1596
  data: newReleaseActions,
1568
1597
  meta: {
1569
1598
  entriesAlreadyInRelease: releaseActions.length - newReleaseActions.length,
1570
- totalEntries: releaseActions.length,
1571
- },
1599
+ totalEntries: releaseActions.length
1600
+ }
1572
1601
  });
1573
1602
  },
1574
- */
1575
1603
  async findMany(ctx) {
1576
1604
  const releaseId = ctx.params.releaseId;
1577
1605
  const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
@@ -1670,24 +1698,22 @@ const controllers = {
1670
1698
  const release = {
1671
1699
  type: "admin",
1672
1700
  routes: [
1673
- /*
1674
1701
  {
1675
- method: 'GET',
1676
- path: '/mapEntriesToReleases',
1677
- handler: 'release.mapEntriesToReleases',
1702
+ method: "GET",
1703
+ path: "/mapEntriesToReleases",
1704
+ handler: "release.mapEntriesToReleases",
1678
1705
  config: {
1679
1706
  policies: [
1680
- 'admin::isAuthenticatedAdmin',
1707
+ "admin::isAuthenticatedAdmin",
1681
1708
  {
1682
- name: 'admin::hasPermissions',
1709
+ name: "admin::hasPermissions",
1683
1710
  config: {
1684
- actions: ['plugin::content-releases.read'],
1685
- },
1686
- },
1687
- ],
1688
- },
1711
+ actions: ["plugin::content-releases.read"]
1712
+ }
1713
+ }
1714
+ ]
1715
+ }
1689
1716
  },
1690
- */
1691
1717
  {
1692
1718
  method: "GET",
1693
1719
  path: "/getByDocumentAttached",
@@ -1821,24 +1847,22 @@ const releaseAction = {
1821
1847
  ]
1822
1848
  }
1823
1849
  },
1824
- /*
1825
1850
  {
1826
- method: 'POST',
1827
- path: '/:releaseId/actions/bulk',
1828
- handler: 'release-action.createMany',
1851
+ method: "POST",
1852
+ path: "/:releaseId/actions/bulk",
1853
+ handler: "release-action.createMany",
1829
1854
  config: {
1830
1855
  policies: [
1831
- 'admin::isAuthenticatedAdmin',
1856
+ "admin::isAuthenticatedAdmin",
1832
1857
  {
1833
- name: 'admin::hasPermissions',
1858
+ name: "admin::hasPermissions",
1834
1859
  config: {
1835
- actions: ['plugin::content-releases.create-action'],
1836
- },
1837
- },
1838
- ],
1839
- },
1860
+ actions: ["plugin::content-releases.create-action"]
1861
+ }
1862
+ }
1863
+ ]
1864
+ }
1840
1865
  },
1841
- */
1842
1866
  {
1843
1867
  method: "GET",
1844
1868
  path: "/:releaseId/actions",