@strapi/review-workflows 0.0.0-experimental.edc24aaa3bb5a90fa5fd4fee208167dd4e2e38d4 → 0.0.0-experimental.f0a0bc26f5ef0693aaea2a616bc6b816cfee54b6

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 (82) hide show
  1. package/dist/_chunks/{Layout-Da8jupiA.mjs → Layout-DU1Rt4Mu.mjs} +8 -9
  2. package/dist/_chunks/Layout-DU1Rt4Mu.mjs.map +1 -0
  3. package/dist/_chunks/{Layout-D3DDQmMI.js → Layout-ywt0cSLq.js} +8 -9
  4. package/dist/_chunks/Layout-ywt0cSLq.js.map +1 -0
  5. package/dist/_chunks/{en-xcewH2pC.js → en-CYgjfSep.js} +5 -2
  6. package/dist/_chunks/en-CYgjfSep.js.map +1 -0
  7. package/dist/_chunks/{en-D9ZrQAV6.mjs → en-D9dxziEb.mjs} +5 -2
  8. package/dist/_chunks/en-D9dxziEb.mjs.map +1 -0
  9. package/dist/_chunks/{_id-xSrgPSJs.mjs → id-MDQVDdXD.mjs} +82 -49
  10. package/dist/_chunks/id-MDQVDdXD.mjs.map +1 -0
  11. package/dist/_chunks/{_id-CnRDP3Xx.js → id-StiN3nkI.js} +82 -49
  12. package/dist/_chunks/id-StiN3nkI.js.map +1 -0
  13. package/dist/_chunks/{index-DDsJlZQw.mjs → index-BRmc4tbQ.mjs} +80 -72
  14. package/dist/_chunks/index-BRmc4tbQ.mjs.map +1 -0
  15. package/dist/_chunks/{index-DhPxWpsW.js → index-BSsDJNiQ.js} +79 -71
  16. package/dist/_chunks/index-BSsDJNiQ.js.map +1 -0
  17. package/dist/_chunks/{index-jfO5GxtW.mjs → index-CsOMMJ--.mjs} +12 -32
  18. package/dist/_chunks/index-CsOMMJ--.mjs.map +1 -0
  19. package/dist/_chunks/{index-4kp4AkBB.js → index-dc2WfugK.js} +10 -30
  20. package/dist/_chunks/index-dc2WfugK.js.map +1 -0
  21. package/dist/_chunks/{router-DSXpeew4.js → router-C5QvEzrI.js} +3 -3
  22. package/dist/_chunks/router-C5QvEzrI.js.map +1 -0
  23. package/dist/_chunks/{router-DOEULOpS.mjs → router-CZH4yq9s.mjs} +3 -3
  24. package/dist/_chunks/router-CZH4yq9s.mjs.map +1 -0
  25. package/dist/admin/index.js +1 -1
  26. package/dist/admin/index.mjs +1 -1
  27. package/dist/admin/src/services/admin.d.ts +1 -1
  28. package/dist/admin/src/services/api.d.ts +1 -1
  29. package/dist/admin/src/services/content-manager.d.ts +4 -4
  30. package/dist/admin/src/services/settings.d.ts +1739 -9
  31. package/dist/server/index.js +180 -108
  32. package/dist/server/index.js.map +1 -1
  33. package/dist/server/index.mjs +180 -108
  34. package/dist/server/index.mjs.map +1 -1
  35. package/dist/server/src/bootstrap.d.ts.map +1 -1
  36. package/dist/server/src/constants/workflows.d.ts +1 -0
  37. package/dist/server/src/constants/workflows.d.ts.map +1 -1
  38. package/dist/server/src/content-types/index.d.ts +6 -0
  39. package/dist/server/src/content-types/index.d.ts.map +1 -1
  40. package/dist/server/src/content-types/workflow/index.d.ts +6 -0
  41. package/dist/server/src/content-types/workflow/index.d.ts.map +1 -1
  42. package/dist/server/src/controllers/assignees.d.ts.map +1 -1
  43. package/dist/server/src/controllers/index.d.ts +0 -1
  44. package/dist/server/src/controllers/index.d.ts.map +1 -1
  45. package/dist/server/src/controllers/stages.d.ts.map +1 -1
  46. package/dist/server/src/controllers/workflows.d.ts +0 -7
  47. package/dist/server/src/controllers/workflows.d.ts.map +1 -1
  48. package/dist/server/src/index.d.ts +28 -7
  49. package/dist/server/src/index.d.ts.map +1 -1
  50. package/dist/server/src/register.d.ts.map +1 -1
  51. package/dist/server/src/routes/review-workflows.d.ts.map +1 -1
  52. package/dist/server/src/services/assignees.d.ts +8 -4
  53. package/dist/server/src/services/assignees.d.ts.map +1 -1
  54. package/dist/server/src/services/document-service-middleware.d.ts +1 -0
  55. package/dist/server/src/services/document-service-middleware.d.ts.map +1 -1
  56. package/dist/server/src/services/index.d.ts +16 -6
  57. package/dist/server/src/services/index.d.ts.map +1 -1
  58. package/dist/server/src/services/metrics/index.d.ts +4 -4
  59. package/dist/server/src/services/metrics/index.d.ts.map +1 -1
  60. package/dist/server/src/services/metrics/weekly-metrics.d.ts.map +1 -1
  61. package/dist/server/src/services/stages.d.ts +7 -7
  62. package/dist/server/src/services/stages.d.ts.map +1 -1
  63. package/dist/server/src/services/workflows.d.ts.map +1 -1
  64. package/dist/server/src/validation/review-workflows.d.ts +4 -0
  65. package/dist/server/src/validation/review-workflows.d.ts.map +1 -1
  66. package/dist/shared/contracts/review-workflows.d.ts +9 -17
  67. package/dist/shared/contracts/review-workflows.d.ts.map +1 -1
  68. package/package.json +12 -12
  69. package/dist/_chunks/Layout-D3DDQmMI.js.map +0 -1
  70. package/dist/_chunks/Layout-Da8jupiA.mjs.map +0 -1
  71. package/dist/_chunks/_id-CnRDP3Xx.js.map +0 -1
  72. package/dist/_chunks/_id-xSrgPSJs.mjs.map +0 -1
  73. package/dist/_chunks/en-D9ZrQAV6.mjs.map +0 -1
  74. package/dist/_chunks/en-xcewH2pC.js.map +0 -1
  75. package/dist/_chunks/index-4kp4AkBB.js.map +0 -1
  76. package/dist/_chunks/index-DDsJlZQw.mjs.map +0 -1
  77. package/dist/_chunks/index-DhPxWpsW.js.map +0 -1
  78. package/dist/_chunks/index-jfO5GxtW.mjs.map +0 -1
  79. package/dist/_chunks/router-DOEULOpS.mjs.map +0 -1
  80. package/dist/_chunks/router-DSXpeew4.js.map +0 -1
  81. package/strapi-server.js +0 -3
  82. /package/dist/admin/src/routes/settings/{:id.d.ts → id.d.ts} +0 -0
@@ -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: () => ({
@@ -129,9 +149,6 @@ const buildValidParams = (query) => {
129
149
  {}
130
150
  )
131
151
  };
132
- if ("_q" in validQueryParams) {
133
- validQueryParams._q = encodeURIComponent(validQueryParams._q);
134
- }
135
152
  return validQueryParams;
136
153
  };
137
154
  const getDisplayName = ({
@@ -156,7 +173,6 @@ const AssigneeSelect = () => {
156
173
  id,
157
174
  slug: model = ""
158
175
  } = reactRouterDom.useParams();
159
- const dispatch = reactRedux.useDispatch();
160
176
  const permissions = useTypedSelector((state) => state.admin_app.permissions);
161
177
  const { formatMessage } = reactIntl.useIntl();
162
178
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
@@ -177,13 +193,13 @@ const AssigneeSelect = () => {
177
193
  documentId: id
178
194
  },
179
195
  {
180
- skip: !id
196
+ skip: !id && collectionType !== "single-types"
181
197
  }
182
198
  );
183
199
  const users = data?.users || [];
184
200
  const currentAssignee = document ? document[ASSIGNEE_ATTRIBUTE_NAME] : null;
185
201
  const [updateAssignee, { error, isLoading: isMutating }] = useUpdateAssigneeMutation();
186
- if (!collectionType || !model || !id) {
202
+ if (!collectionType || !model || !document?.documentId) {
187
203
  return null;
188
204
  }
189
205
  const handleChange = async (assigneeId) => {
@@ -193,22 +209,13 @@ const AssigneeSelect = () => {
193
209
  const res = await updateAssignee({
194
210
  slug: collectionType,
195
211
  model,
196
- id,
212
+ id: document.documentId,
197
213
  params,
198
214
  data: {
199
215
  id: assigneeId ? parseInt(assigneeId, 10) : null
200
216
  }
201
217
  });
202
218
  if ("data" in res) {
203
- dispatch({
204
- type: "contentManagerApi/invalidateTags",
205
- payload: [
206
- {
207
- type: "Document",
208
- id: `${model}_${id}`
209
- }
210
- ]
211
- });
212
219
  toggleNotification({
213
220
  type: "success",
214
221
  message: formatMessage({
@@ -239,7 +246,7 @@ const AssigneeSelect = () => {
239
246
  id: "content-manager.reviewWorkflows.assignee.clear",
240
247
  defaultMessage: "Clear assignee"
241
248
  }),
242
- disabled: !isLoadingPermissions && !isLoading && users.length === 0 || !id,
249
+ disabled: !isLoadingPermissions && !isLoading && users.length === 0 || !document.documentId,
243
250
  value: currentAssignee ? currentAssignee.id.toString() : null,
244
251
  onChange: handleChange,
245
252
  onClear: () => handleChange(null),
@@ -376,31 +383,31 @@ const StageSelect = () => {
376
383
  slug: model = "",
377
384
  id = ""
378
385
  } = reactRouterDom.useParams();
379
- const dispatch = reactRedux.useDispatch();
380
386
  const { formatMessage } = reactIntl.useIntl();
381
387
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
382
388
  const { toggleNotification } = strapiAdmin.useNotification();
383
389
  const [{ query }] = strapiAdmin.useQueryParams();
384
390
  const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
385
- const { data, isLoading } = useGetStagesQuery(
391
+ const { document, isLoading: isLoadingDocument } = strapiAdmin$1.unstable_useDocument(
386
392
  {
387
- slug: collectionType,
393
+ collectionType,
388
394
  model,
389
- id,
390
- params
395
+ documentId: id
391
396
  },
392
397
  {
393
- skip: !id
398
+ skip: !id && collectionType !== "single-types"
394
399
  }
395
400
  );
396
- const { document } = strapiAdmin$1.unstable_useDocument(
401
+ const { data, isLoading: isLoadingStages } = useGetStagesQuery(
397
402
  {
398
- collectionType,
403
+ slug: collectionType,
399
404
  model,
400
- documentId: id
405
+ // @ts-expect-error – `id` is not correctly typed in the DS.
406
+ id: document?.documentId,
407
+ params
401
408
  },
402
409
  {
403
- skip: !id
410
+ skip: !document?.documentId
404
411
  }
405
412
  );
406
413
  const { meta, stages = [] } = data ?? {};
@@ -416,24 +423,15 @@ const StageSelect = () => {
416
423
  } else if (limits?.[CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME] && parseInt(limits[CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME], 10) < stages.length) {
417
424
  setShowLimitModal("stage");
418
425
  } else {
419
- if (id) {
426
+ if (document?.documentId) {
420
427
  const res = await updateStage({
421
428
  model,
422
- id,
429
+ id: document.documentId,
423
430
  slug: collectionType,
424
431
  params,
425
432
  data: { id: stageId }
426
433
  });
427
434
  if ("data" in res) {
428
- dispatch({
429
- type: "contentManagerApi/invalidateTags",
430
- payload: [
431
- {
432
- type: "Document",
433
- id: `${model}_${id}`
434
- }
435
- ]
436
- });
437
435
  toggleNotification({
438
436
  type: "success",
439
437
  message: formatMessage({
@@ -455,6 +453,7 @@ const StageSelect = () => {
455
453
  }
456
454
  };
457
455
  const { themeColorName } = getStageColorByHex(activeWorkflowStage?.color) ?? {};
456
+ const isLoading = isLoadingStages || isLoadingDocument;
458
457
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
459
458
  /* @__PURE__ */ jsxRuntime.jsxs(
460
459
  designSystem.Field.Root,
@@ -567,12 +566,16 @@ const StageSelect = () => {
567
566
  ] });
568
567
  };
569
568
  const Panel = () => {
570
- const { slug = "", id } = reactRouterDom.useParams();
569
+ const {
570
+ slug = "",
571
+ id,
572
+ collectionType
573
+ } = reactRouterDom.useParams();
571
574
  const {
572
575
  edit: { options }
573
576
  } = strapiAdmin$1.unstable_useDocumentLayout(slug);
574
577
  const { formatMessage } = reactIntl.useIntl();
575
- if (!window.strapi.isEE || !options?.reviewWorkflows || !id || id === "create") {
578
+ if (!window.strapi.isEE || !options?.reviewWorkflows || collectionType !== "single-types" && !id || id === "create") {
576
579
  return null;
577
580
  }
578
581
  return {
@@ -591,36 +594,25 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
591
594
  endpoints: (builder) => ({
592
595
  getWorkflows: builder.query({
593
596
  query: (args) => {
594
- const { id, ...params } = args ?? {};
595
597
  return {
596
- url: `/review-workflows/workflows${id ? `/${id}` : ""}`,
598
+ url: "/review-workflows/workflows",
597
599
  method: "GET",
598
600
  config: {
599
- params
601
+ params: args ?? {}
600
602
  }
601
603
  };
602
604
  },
603
605
  transformResponse: (res) => {
604
- let workflows = [];
605
- if (Array.isArray(res.data)) {
606
- workflows = res.data;
607
- } else {
608
- workflows = [res.data];
609
- }
610
606
  return {
611
- workflows,
607
+ workflows: res.data,
612
608
  meta: "meta" in res ? res.meta : void 0
613
609
  };
614
610
  },
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
- }
611
+ providesTags: (res) => {
612
+ return [
613
+ ...res?.workflows.map(({ id }) => ({ type: "ReviewWorkflow", id })) ?? [],
614
+ { type: "ReviewWorkflow", id: "LIST" }
615
+ ];
624
616
  }
625
617
  }),
626
618
  createWorkflow: builder.mutation({
@@ -630,7 +622,18 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
630
622
  data
631
623
  }),
632
624
  transformResponse: (res) => res.data,
633
- invalidatesTags: [{ type: "ReviewWorkflow", id: "LIST" }, "ReviewWorkflowStages"]
625
+ invalidatesTags(res) {
626
+ return [
627
+ { type: "ReviewWorkflow", id: "LIST" },
628
+ "ReviewWorkflowStages",
629
+ { type: "Document", id: `ALL_LIST` },
630
+ { type: "ContentTypeSettings", id: "LIST" },
631
+ ...res?.contentTypes.map((uid) => ({
632
+ type: "Document",
633
+ id: `${uid}_ALL_ITEMS`
634
+ })) ?? []
635
+ ];
636
+ }
634
637
  }),
635
638
  updateWorkflow: builder.mutation({
636
639
  query: ({ id, ...data }) => ({
@@ -641,7 +644,13 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
641
644
  transformResponse: (res) => res.data,
642
645
  invalidatesTags: (res, _err, arg) => [
643
646
  { type: "ReviewWorkflow", id: arg.id },
644
- "ReviewWorkflowStages"
647
+ "ReviewWorkflowStages",
648
+ { type: "Document", id: "ALL_LIST" },
649
+ { type: "ContentTypeSettings", id: "LIST" },
650
+ ...res?.contentTypes.map((uid) => ({
651
+ type: "Document",
652
+ id: `${uid}_ALL_ITEMS`
653
+ })) ?? []
645
654
  ]
646
655
  }),
647
656
  deleteWorkflow: builder.mutation({
@@ -652,7 +661,9 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
652
661
  transformResponse: (res) => res.data,
653
662
  invalidatesTags: (res, _err, arg) => [
654
663
  { type: "ReviewWorkflow", id: arg.id },
655
- "ReviewWorkflowStages"
664
+ "ReviewWorkflowStages",
665
+ { type: "Document", id: `ALL_LIST` },
666
+ { type: "ContentTypeSettings", id: "LIST" }
656
667
  ]
657
668
  })
658
669
  }),
@@ -737,9 +748,6 @@ const addColumnToTableHook = ({ displayedHeaders, layout }) => {
737
748
  };
738
749
  };
739
750
  const prefixPluginTranslations = (trad, pluginId) => {
740
- if (!pluginId) {
741
- throw new TypeError("pluginId can't be empty");
742
- }
743
751
  return Object.keys(trad).reduce((acc, current) => {
744
752
  acc[`${pluginId}.${current}`] = trad[current];
745
753
  return acc;
@@ -762,7 +770,7 @@ const admin = {
762
770
  },
763
771
  permissions: [],
764
772
  async Component() {
765
- const { Router } = await Promise.resolve().then(() => require("./router-DSXpeew4.js"));
773
+ const { Router } = await Promise.resolve().then(() => require("./router-C5QvEzrI.js"));
766
774
  return { default: Router };
767
775
  }
768
776
  });
@@ -786,7 +794,7 @@ const admin = {
786
794
  async registerTrads({ locales }) {
787
795
  const importedTrads = await Promise.all(
788
796
  locales.map((locale) => {
789
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-xcewH2pC.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
797
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-CYgjfSep.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
790
798
  return {
791
799
  data: prefixPluginTranslations(data, PLUGIN_ID),
792
800
  locale
@@ -816,4 +824,4 @@ exports.useGetContentTypesQuery = useGetContentTypesQuery;
816
824
  exports.useGetWorkflowsQuery = useGetWorkflowsQuery;
817
825
  exports.useTypedSelector = useTypedSelector;
818
826
  exports.useUpdateWorkflowMutation = useUpdateWorkflowMutation;
819
- //# sourceMappingURL=index-DhPxWpsW.js.map
827
+ //# sourceMappingURL=index-BSsDJNiQ.js.map