@strapi/review-workflows 5.0.0-rc.3 → 5.0.0-rc.30

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 (55) hide show
  1. package/dist/_chunks/{Layout-Da8jupiA.mjs → Layout-BJOxxAeM.mjs} +7 -8
  2. package/dist/_chunks/Layout-BJOxxAeM.mjs.map +1 -0
  3. package/dist/_chunks/{Layout-D3DDQmMI.js → Layout-DnEAvmeU.js} +7 -8
  4. package/dist/_chunks/Layout-DnEAvmeU.js.map +1 -0
  5. package/dist/_chunks/{_id-xSrgPSJs.mjs → _id-6LK95-rZ.mjs} +13 -39
  6. package/dist/_chunks/_id-6LK95-rZ.mjs.map +1 -0
  7. package/dist/_chunks/{_id-CnRDP3Xx.js → _id-DSDzUpwX.js} +13 -39
  8. package/dist/_chunks/_id-DSDzUpwX.js.map +1 -0
  9. package/dist/_chunks/{index-4kp4AkBB.js → index-6FZL88pd.js} +9 -29
  10. package/dist/_chunks/index-6FZL88pd.js.map +1 -0
  11. package/dist/_chunks/{index-DhPxWpsW.js → index-DZSLya4b.js} +78 -64
  12. package/dist/_chunks/index-DZSLya4b.js.map +1 -0
  13. package/dist/_chunks/{index-jfO5GxtW.mjs → index-Df1alkCk.mjs} +11 -31
  14. package/dist/_chunks/index-Df1alkCk.mjs.map +1 -0
  15. package/dist/_chunks/{index-DDsJlZQw.mjs → index-lJqpw8bs.mjs} +79 -65
  16. package/dist/_chunks/index-lJqpw8bs.mjs.map +1 -0
  17. package/dist/_chunks/{router-DSXpeew4.js → router-CZqe-02r.js} +3 -3
  18. package/dist/_chunks/{router-DSXpeew4.js.map → router-CZqe-02r.js.map} +1 -1
  19. package/dist/_chunks/{router-DOEULOpS.mjs → router-DeSH-NeW.mjs} +3 -3
  20. package/dist/_chunks/{router-DOEULOpS.mjs.map → router-DeSH-NeW.mjs.map} +1 -1
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +1 -1
  23. package/dist/admin/src/services/admin.d.ts +1 -1
  24. package/dist/admin/src/services/api.d.ts +1 -1
  25. package/dist/admin/src/services/content-manager.d.ts +4 -4
  26. package/dist/admin/src/services/settings.d.ts +1733 -7
  27. package/dist/server/index.js +35 -61
  28. package/dist/server/index.js.map +1 -1
  29. package/dist/server/index.mjs +35 -61
  30. package/dist/server/index.mjs.map +1 -1
  31. package/dist/server/src/controllers/assignees.d.ts.map +1 -1
  32. package/dist/server/src/controllers/index.d.ts +0 -1
  33. package/dist/server/src/controllers/index.d.ts.map +1 -1
  34. package/dist/server/src/controllers/stages.d.ts.map +1 -1
  35. package/dist/server/src/controllers/workflows.d.ts +0 -7
  36. package/dist/server/src/controllers/workflows.d.ts.map +1 -1
  37. package/dist/server/src/index.d.ts +1 -2
  38. package/dist/server/src/index.d.ts.map +1 -1
  39. package/dist/server/src/routes/review-workflows.d.ts.map +1 -1
  40. package/dist/server/src/services/document-service-middleware.d.ts.map +1 -1
  41. package/dist/server/src/services/index.d.ts +1 -1
  42. package/dist/server/src/services/stages.d.ts +2 -7
  43. package/dist/server/src/services/stages.d.ts.map +1 -1
  44. package/dist/shared/contracts/review-workflows.d.ts +1 -14
  45. package/dist/shared/contracts/review-workflows.d.ts.map +1 -1
  46. package/package.json +9 -9
  47. package/dist/_chunks/Layout-D3DDQmMI.js.map +0 -1
  48. package/dist/_chunks/Layout-Da8jupiA.mjs.map +0 -1
  49. package/dist/_chunks/_id-CnRDP3Xx.js.map +0 -1
  50. package/dist/_chunks/_id-xSrgPSJs.mjs.map +0 -1
  51. package/dist/_chunks/index-4kp4AkBB.js.map +0 -1
  52. package/dist/_chunks/index-DDsJlZQw.mjs.map +0 -1
  53. package/dist/_chunks/index-DhPxWpsW.js.map +0 -1
  54. package/dist/_chunks/index-jfO5GxtW.mjs.map +0 -1
  55. package/strapi-server.js +0 -3
@@ -45,8 +45,9 @@ const CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME = "stagesPerWorkflow";
45
45
  const STAGE_COLOR_DEFAULT = designSystem.lightTheme.colors.primary600;
46
46
  const useTypedSelector = reactRedux.useSelector;
47
47
  const reviewWorkflowsApi = strapiAdmin.adminApi.enhanceEndpoints({
48
- addTagTypes: ["ReviewWorkflow", "ReviewWorkflowStages"]
48
+ addTagTypes: ["ReviewWorkflow", "ReviewWorkflowStages", "Document", "ContentTypeSettings"]
49
49
  });
50
+ const SINGLE_TYPES = "single-types";
50
51
  const contentManagerApi = reviewWorkflowsApi.injectEndpoints({
51
52
  endpoints: (builder) => ({
52
53
  getStages: builder.query({
@@ -74,7 +75,17 @@ const contentManagerApi = reviewWorkflowsApi.injectEndpoints({
74
75
  params
75
76
  }
76
77
  }),
77
- transformResponse: (res) => res.data
78
+ transformResponse: (res) => res.data,
79
+ invalidatesTags: (_result, _error, { slug, id, model }) => {
80
+ return [
81
+ {
82
+ type: "Document",
83
+ id: slug !== SINGLE_TYPES ? `${model}_${id}` : model
84
+ },
85
+ { type: "Document", id: `${model}_LIST` },
86
+ "ReviewWorkflowStages"
87
+ ];
88
+ }
78
89
  }),
79
90
  updateAssignee: builder.mutation({
80
91
  query: ({ model, slug, id, params, ...data }) => ({
@@ -85,7 +96,16 @@ const contentManagerApi = reviewWorkflowsApi.injectEndpoints({
85
96
  params
86
97
  }
87
98
  }),
88
- transformResponse: (res) => res.data
99
+ transformResponse: (res) => res.data,
100
+ invalidatesTags: (_result, _error, { slug, id, model }) => {
101
+ return [
102
+ {
103
+ type: "Document",
104
+ id: slug !== SINGLE_TYPES ? `${model}_${id}` : model
105
+ },
106
+ { type: "Document", id: `${model}_LIST` }
107
+ ];
108
+ }
89
109
  }),
90
110
  getContentTypes: builder.query({
91
111
  query: () => ({
@@ -156,7 +176,6 @@ const AssigneeSelect = () => {
156
176
  id,
157
177
  slug: model = ""
158
178
  } = reactRouterDom.useParams();
159
- const dispatch = reactRedux.useDispatch();
160
179
  const permissions = useTypedSelector((state) => state.admin_app.permissions);
161
180
  const { formatMessage } = reactIntl.useIntl();
162
181
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
@@ -177,13 +196,13 @@ const AssigneeSelect = () => {
177
196
  documentId: id
178
197
  },
179
198
  {
180
- skip: !id
199
+ skip: !id && collectionType !== "single-types"
181
200
  }
182
201
  );
183
202
  const users = data?.users || [];
184
203
  const currentAssignee = document ? document[ASSIGNEE_ATTRIBUTE_NAME] : null;
185
204
  const [updateAssignee, { error, isLoading: isMutating }] = useUpdateAssigneeMutation();
186
- if (!collectionType || !model || !id) {
205
+ if (!collectionType || !model || !document?.documentId) {
187
206
  return null;
188
207
  }
189
208
  const handleChange = async (assigneeId) => {
@@ -193,22 +212,13 @@ const AssigneeSelect = () => {
193
212
  const res = await updateAssignee({
194
213
  slug: collectionType,
195
214
  model,
196
- id,
215
+ id: document.documentId,
197
216
  params,
198
217
  data: {
199
218
  id: assigneeId ? parseInt(assigneeId, 10) : null
200
219
  }
201
220
  });
202
221
  if ("data" in res) {
203
- dispatch({
204
- type: "contentManagerApi/invalidateTags",
205
- payload: [
206
- {
207
- type: "Document",
208
- id: `${model}_${id}`
209
- }
210
- ]
211
- });
212
222
  toggleNotification({
213
223
  type: "success",
214
224
  message: formatMessage({
@@ -239,7 +249,7 @@ const AssigneeSelect = () => {
239
249
  id: "content-manager.reviewWorkflows.assignee.clear",
240
250
  defaultMessage: "Clear assignee"
241
251
  }),
242
- disabled: !isLoadingPermissions && !isLoading && users.length === 0 || !id,
252
+ disabled: !isLoadingPermissions && !isLoading && users.length === 0 || !document.documentId,
243
253
  value: currentAssignee ? currentAssignee.id.toString() : null,
244
254
  onChange: handleChange,
245
255
  onClear: () => handleChange(null),
@@ -376,31 +386,31 @@ const StageSelect = () => {
376
386
  slug: model = "",
377
387
  id = ""
378
388
  } = reactRouterDom.useParams();
379
- const dispatch = reactRedux.useDispatch();
380
389
  const { formatMessage } = reactIntl.useIntl();
381
390
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
382
391
  const { toggleNotification } = strapiAdmin.useNotification();
383
392
  const [{ query }] = strapiAdmin.useQueryParams();
384
393
  const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
385
- const { data, isLoading } = useGetStagesQuery(
394
+ const { document, isLoading: isLoadingDocument } = strapiAdmin$1.unstable_useDocument(
386
395
  {
387
- slug: collectionType,
396
+ collectionType,
388
397
  model,
389
- id,
390
- params
398
+ documentId: id
391
399
  },
392
400
  {
393
- skip: !id
401
+ skip: !id && collectionType !== "single-types"
394
402
  }
395
403
  );
396
- const { document } = strapiAdmin$1.unstable_useDocument(
404
+ const { data, isLoading: isLoadingStages } = useGetStagesQuery(
397
405
  {
398
- collectionType,
406
+ slug: collectionType,
399
407
  model,
400
- documentId: id
408
+ // @ts-expect-error – `id` is not correctly typed in the DS.
409
+ id: document?.documentId,
410
+ params
401
411
  },
402
412
  {
403
- skip: !id
413
+ skip: !document?.documentId
404
414
  }
405
415
  );
406
416
  const { meta, stages = [] } = data ?? {};
@@ -416,24 +426,15 @@ const StageSelect = () => {
416
426
  } else if (limits?.[CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME] && parseInt(limits[CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME], 10) < stages.length) {
417
427
  setShowLimitModal("stage");
418
428
  } else {
419
- if (id) {
429
+ if (document?.documentId) {
420
430
  const res = await updateStage({
421
431
  model,
422
- id,
432
+ id: document.documentId,
423
433
  slug: collectionType,
424
434
  params,
425
435
  data: { id: stageId }
426
436
  });
427
437
  if ("data" in res) {
428
- dispatch({
429
- type: "contentManagerApi/invalidateTags",
430
- payload: [
431
- {
432
- type: "Document",
433
- id: `${model}_${id}`
434
- }
435
- ]
436
- });
437
438
  toggleNotification({
438
439
  type: "success",
439
440
  message: formatMessage({
@@ -455,6 +456,7 @@ const StageSelect = () => {
455
456
  }
456
457
  };
457
458
  const { themeColorName } = getStageColorByHex(activeWorkflowStage?.color) ?? {};
459
+ const isLoading = isLoadingStages || isLoadingDocument;
458
460
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
459
461
  /* @__PURE__ */ jsxRuntime.jsxs(
460
462
  designSystem.Field.Root,
@@ -567,12 +569,16 @@ const StageSelect = () => {
567
569
  ] });
568
570
  };
569
571
  const Panel = () => {
570
- const { slug = "", id } = reactRouterDom.useParams();
572
+ const {
573
+ slug = "",
574
+ id,
575
+ collectionType
576
+ } = reactRouterDom.useParams();
571
577
  const {
572
578
  edit: { options }
573
579
  } = strapiAdmin$1.unstable_useDocumentLayout(slug);
574
580
  const { formatMessage } = reactIntl.useIntl();
575
- if (!window.strapi.isEE || !options?.reviewWorkflows || !id || id === "create") {
581
+ if (!window.strapi.isEE || !options?.reviewWorkflows || collectionType !== "single-types" && !id || id === "create") {
576
582
  return null;
577
583
  }
578
584
  return {
@@ -591,36 +597,25 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
591
597
  endpoints: (builder) => ({
592
598
  getWorkflows: builder.query({
593
599
  query: (args) => {
594
- const { id, ...params } = args ?? {};
595
600
  return {
596
- url: `/review-workflows/workflows${id ? `/${id}` : ""}`,
601
+ url: "/review-workflows/workflows",
597
602
  method: "GET",
598
603
  config: {
599
- params
604
+ params: args ?? {}
600
605
  }
601
606
  };
602
607
  },
603
608
  transformResponse: (res) => {
604
- let workflows = [];
605
- if (Array.isArray(res.data)) {
606
- workflows = res.data;
607
- } else {
608
- workflows = [res.data];
609
- }
610
609
  return {
611
- workflows,
610
+ workflows: res.data,
612
611
  meta: "meta" in res ? res.meta : void 0
613
612
  };
614
613
  },
615
- providesTags: (res, _err, arg) => {
616
- if (typeof arg === "object" && "id" in arg && arg.id !== "") {
617
- return [{ type: "ReviewWorkflow", id: arg.id }];
618
- } else {
619
- return [
620
- ...res?.workflows.map(({ id }) => ({ type: "ReviewWorkflow", id })) ?? [],
621
- { type: "ReviewWorkflow", id: "LIST" }
622
- ];
623
- }
614
+ providesTags: (res) => {
615
+ return [
616
+ ...res?.workflows.map(({ id }) => ({ type: "ReviewWorkflow", id })) ?? [],
617
+ { type: "ReviewWorkflow", id: "LIST" }
618
+ ];
624
619
  }
625
620
  }),
626
621
  createWorkflow: builder.mutation({
@@ -630,7 +625,18 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
630
625
  data
631
626
  }),
632
627
  transformResponse: (res) => res.data,
633
- invalidatesTags: [{ type: "ReviewWorkflow", id: "LIST" }, "ReviewWorkflowStages"]
628
+ invalidatesTags(res) {
629
+ return [
630
+ { type: "ReviewWorkflow", id: "LIST" },
631
+ "ReviewWorkflowStages",
632
+ { type: "Document", id: `ALL_LIST` },
633
+ { type: "ContentTypeSettings", id: "LIST" },
634
+ ...res?.contentTypes.map((uid) => ({
635
+ type: "Document",
636
+ id: `${uid}_ALL_ITEMS`
637
+ })) ?? []
638
+ ];
639
+ }
634
640
  }),
635
641
  updateWorkflow: builder.mutation({
636
642
  query: ({ id, ...data }) => ({
@@ -641,7 +647,13 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
641
647
  transformResponse: (res) => res.data,
642
648
  invalidatesTags: (res, _err, arg) => [
643
649
  { type: "ReviewWorkflow", id: arg.id },
644
- "ReviewWorkflowStages"
650
+ "ReviewWorkflowStages",
651
+ { type: "Document", id: "ALL_LIST" },
652
+ { type: "ContentTypeSettings", id: "LIST" },
653
+ ...res?.contentTypes.map((uid) => ({
654
+ type: "Document",
655
+ id: `${uid}_ALL_ITEMS`
656
+ })) ?? []
645
657
  ]
646
658
  }),
647
659
  deleteWorkflow: builder.mutation({
@@ -652,7 +664,9 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
652
664
  transformResponse: (res) => res.data,
653
665
  invalidatesTags: (res, _err, arg) => [
654
666
  { type: "ReviewWorkflow", id: arg.id },
655
- "ReviewWorkflowStages"
667
+ "ReviewWorkflowStages",
668
+ { type: "Document", id: `ALL_LIST` },
669
+ { type: "ContentTypeSettings", id: "LIST" }
656
670
  ]
657
671
  })
658
672
  }),
@@ -762,7 +776,7 @@ const admin = {
762
776
  },
763
777
  permissions: [],
764
778
  async Component() {
765
- const { Router } = await Promise.resolve().then(() => require("./router-DSXpeew4.js"));
779
+ const { Router } = await Promise.resolve().then(() => require("./router-CZqe-02r.js"));
766
780
  return { default: Router };
767
781
  }
768
782
  });
@@ -816,4 +830,4 @@ exports.useGetContentTypesQuery = useGetContentTypesQuery;
816
830
  exports.useGetWorkflowsQuery = useGetWorkflowsQuery;
817
831
  exports.useTypedSelector = useTypedSelector;
818
832
  exports.useUpdateWorkflowMutation = useUpdateWorkflowMutation;
819
- //# sourceMappingURL=index-DhPxWpsW.js.map
833
+ //# sourceMappingURL=index-DZSLya4b.js.map