@strapi/review-workflows 0.0.0-experimental.d954d57341a6623992a0d211daaec8e245c3517d → 0.0.0-experimental.dad3c50630ca4fd9eccdcbe549ee632fc572e23d

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 (88) hide show
  1. package/LICENSE +12 -17
  2. package/dist/_chunks/{Layout-y4m6QHjX.js → Layout-C3IORH2n.js} +10 -12
  3. package/dist/_chunks/Layout-C3IORH2n.js.map +1 -0
  4. package/dist/_chunks/{Layout-BDKzgDbH.mjs → Layout-DNKR5bym.mjs} +9 -10
  5. package/dist/_chunks/Layout-DNKR5bym.mjs.map +1 -0
  6. package/dist/_chunks/{en-xcewH2pC.js → en-CYgjfSep.js} +5 -2
  7. package/dist/_chunks/en-CYgjfSep.js.map +1 -0
  8. package/dist/_chunks/{en-D9ZrQAV6.mjs → en-D9dxziEb.mjs} +5 -2
  9. package/dist/_chunks/en-D9dxziEb.mjs.map +1 -0
  10. package/dist/_chunks/{_id-yOfUu1Rs.mjs → id-C9Ku9Br9.mjs} +108 -88
  11. package/dist/_chunks/id-C9Ku9Br9.mjs.map +1 -0
  12. package/dist/_chunks/{_id-CB3lqKgb.js → id-oOE1bYls.js} +109 -90
  13. package/dist/_chunks/id-oOE1bYls.js.map +1 -0
  14. package/dist/_chunks/{index-Bx0Y1GZR.mjs → index-ByXbOW-R.mjs} +93 -79
  15. package/dist/_chunks/index-ByXbOW-R.mjs.map +1 -0
  16. package/dist/_chunks/{index-CNKQvAnM.js → index-CmHHjN95.js} +12 -34
  17. package/dist/_chunks/index-CmHHjN95.js.map +1 -0
  18. package/dist/_chunks/{index--7HYUi67.mjs → index-CyhaJuJG.mjs} +13 -34
  19. package/dist/_chunks/index-CyhaJuJG.mjs.map +1 -0
  20. package/dist/_chunks/{index-Bj7gelY1.js → index-DMT27jNE.js} +93 -80
  21. package/dist/_chunks/index-DMT27jNE.js.map +1 -0
  22. package/dist/_chunks/{purchase-review-workflows-DlCDg0fD.js → purchase-review-workflows-BxoDFxQ5.js} +2 -2
  23. package/dist/_chunks/purchase-review-workflows-BxoDFxQ5.js.map +1 -0
  24. package/dist/_chunks/{purchase-review-workflows-BN-5Ube7.mjs → purchase-review-workflows-DyFV_H0I.mjs} +2 -2
  25. package/dist/_chunks/{purchase-review-workflows-BN-5Ube7.mjs.map → purchase-review-workflows-DyFV_H0I.mjs.map} +1 -1
  26. package/dist/_chunks/{router-t6Nj4F0T.mjs → router-BPl2HZMq.mjs} +3 -3
  27. package/dist/_chunks/router-BPl2HZMq.mjs.map +1 -0
  28. package/dist/_chunks/{router-LZ2xbb95.js → router-vDfGt9bq.js} +3 -3
  29. package/dist/_chunks/router-vDfGt9bq.js.map +1 -0
  30. package/dist/admin/index.js +1 -1
  31. package/dist/admin/index.mjs +1 -1
  32. package/dist/admin/src/services/admin.d.ts +1 -1
  33. package/dist/admin/src/services/api.d.ts +1 -1
  34. package/dist/admin/src/services/content-manager.d.ts +4 -4
  35. package/dist/admin/src/services/settings.d.ts +1739 -9
  36. package/dist/server/index.js +455 -628
  37. package/dist/server/index.js.map +1 -1
  38. package/dist/server/index.mjs +455 -628
  39. package/dist/server/index.mjs.map +1 -1
  40. package/dist/server/src/bootstrap.d.ts.map +1 -1
  41. package/dist/server/src/constants/workflows.d.ts +1 -0
  42. package/dist/server/src/constants/workflows.d.ts.map +1 -1
  43. package/dist/server/src/content-types/index.d.ts +6 -0
  44. package/dist/server/src/content-types/index.d.ts.map +1 -1
  45. package/dist/server/src/content-types/workflow/index.d.ts +6 -0
  46. package/dist/server/src/content-types/workflow/index.d.ts.map +1 -1
  47. package/dist/server/src/controllers/assignees.d.ts.map +1 -1
  48. package/dist/server/src/controllers/index.d.ts +0 -1
  49. package/dist/server/src/controllers/index.d.ts.map +1 -1
  50. package/dist/server/src/controllers/stages.d.ts.map +1 -1
  51. package/dist/server/src/controllers/workflows.d.ts +0 -7
  52. package/dist/server/src/controllers/workflows.d.ts.map +1 -1
  53. package/dist/server/src/index.d.ts +28 -7
  54. package/dist/server/src/index.d.ts.map +1 -1
  55. package/dist/server/src/register.d.ts.map +1 -1
  56. package/dist/server/src/routes/review-workflows.d.ts.map +1 -1
  57. package/dist/server/src/services/assignees.d.ts +8 -4
  58. package/dist/server/src/services/assignees.d.ts.map +1 -1
  59. package/dist/server/src/services/document-service-middleware.d.ts +1 -0
  60. package/dist/server/src/services/document-service-middleware.d.ts.map +1 -1
  61. package/dist/server/src/services/index.d.ts +16 -6
  62. package/dist/server/src/services/index.d.ts.map +1 -1
  63. package/dist/server/src/services/metrics/index.d.ts +4 -4
  64. package/dist/server/src/services/metrics/index.d.ts.map +1 -1
  65. package/dist/server/src/services/metrics/weekly-metrics.d.ts.map +1 -1
  66. package/dist/server/src/services/stages.d.ts +7 -7
  67. package/dist/server/src/services/stages.d.ts.map +1 -1
  68. package/dist/server/src/services/workflows.d.ts.map +1 -1
  69. package/dist/server/src/validation/review-workflows.d.ts +4 -0
  70. package/dist/server/src/validation/review-workflows.d.ts.map +1 -1
  71. package/dist/shared/contracts/review-workflows.d.ts +9 -17
  72. package/dist/shared/contracts/review-workflows.d.ts.map +1 -1
  73. package/package.json +12 -13
  74. package/dist/_chunks/Layout-BDKzgDbH.mjs.map +0 -1
  75. package/dist/_chunks/Layout-y4m6QHjX.js.map +0 -1
  76. package/dist/_chunks/_id-CB3lqKgb.js.map +0 -1
  77. package/dist/_chunks/_id-yOfUu1Rs.mjs.map +0 -1
  78. package/dist/_chunks/en-D9ZrQAV6.mjs.map +0 -1
  79. package/dist/_chunks/en-xcewH2pC.js.map +0 -1
  80. package/dist/_chunks/index--7HYUi67.mjs.map +0 -1
  81. package/dist/_chunks/index-Bj7gelY1.js.map +0 -1
  82. package/dist/_chunks/index-Bx0Y1GZR.mjs.map +0 -1
  83. package/dist/_chunks/index-CNKQvAnM.js.map +0 -1
  84. package/dist/_chunks/purchase-review-workflows-DlCDg0fD.js.map +0 -1
  85. package/dist/_chunks/router-LZ2xbb95.js.map +0 -1
  86. package/dist/_chunks/router-t6Nj4F0T.mjs.map +0 -1
  87. package/strapi-server.js +0 -3
  88. /package/dist/admin/src/routes/settings/{:id.d.ts → id.d.ts} +0 -0
@@ -5,17 +5,24 @@ import { useIntl } from "react-intl";
5
5
  import { useParams } from "react-router-dom";
6
6
  import * as React from "react";
7
7
  import { adminApi, useAPIErrorHandler, useNotification, useRBAC, useQueryParams, useAdminUsers } from "@strapi/admin/strapi-admin";
8
- import { useSelector, useDispatch } from "react-redux";
8
+ import { useSelector } from "react-redux";
9
9
  import { useLicenseLimits } from "@strapi/admin/strapi-admin/ee";
10
10
  import { Cross } from "@strapi/icons";
11
11
  import { styled } from "styled-components";
12
- const __variableDynamicImportRuntimeHelper = (glob, path) => {
12
+ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
13
13
  const v = glob[path];
14
14
  if (v) {
15
15
  return typeof v === "function" ? v() : Promise.resolve(v);
16
16
  }
17
17
  return new Promise((_, reject) => {
18
- (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
18
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
19
+ reject.bind(
20
+ null,
21
+ new Error(
22
+ "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
23
+ )
24
+ )
25
+ );
19
26
  });
20
27
  };
21
28
  const PLUGIN_ID = "review-workflows";
@@ -25,8 +32,9 @@ const CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME = "stagesPerWorkflow";
25
32
  const STAGE_COLOR_DEFAULT = lightTheme.colors.primary600;
26
33
  const useTypedSelector = useSelector;
27
34
  const reviewWorkflowsApi = adminApi.enhanceEndpoints({
28
- addTagTypes: ["ReviewWorkflow", "ReviewWorkflowStages"]
35
+ addTagTypes: ["ReviewWorkflow", "ReviewWorkflowStages", "Document", "ContentTypeSettings"]
29
36
  });
37
+ const SINGLE_TYPES = "single-types";
30
38
  const contentManagerApi = reviewWorkflowsApi.injectEndpoints({
31
39
  endpoints: (builder) => ({
32
40
  getStages: builder.query({
@@ -54,7 +62,17 @@ const contentManagerApi = reviewWorkflowsApi.injectEndpoints({
54
62
  params
55
63
  }
56
64
  }),
57
- transformResponse: (res) => res.data
65
+ transformResponse: (res) => res.data,
66
+ invalidatesTags: (_result, _error, { slug, id, model }) => {
67
+ return [
68
+ {
69
+ type: "Document",
70
+ id: slug !== SINGLE_TYPES ? `${model}_${id}` : model
71
+ },
72
+ { type: "Document", id: `${model}_LIST` },
73
+ "ReviewWorkflowStages"
74
+ ];
75
+ }
58
76
  }),
59
77
  updateAssignee: builder.mutation({
60
78
  query: ({ model, slug, id, params, ...data }) => ({
@@ -65,7 +83,16 @@ const contentManagerApi = reviewWorkflowsApi.injectEndpoints({
65
83
  params
66
84
  }
67
85
  }),
68
- transformResponse: (res) => res.data
86
+ transformResponse: (res) => res.data,
87
+ invalidatesTags: (_result, _error, { slug, id, model }) => {
88
+ return [
89
+ {
90
+ type: "Document",
91
+ id: slug !== SINGLE_TYPES ? `${model}_${id}` : model
92
+ },
93
+ { type: "Document", id: `${model}_LIST` }
94
+ ];
95
+ }
69
96
  }),
70
97
  getContentTypes: builder.query({
71
98
  query: () => ({
@@ -100,8 +127,7 @@ const isBaseQueryError = (error) => {
100
127
  return error.name !== void 0;
101
128
  };
102
129
  const buildValidParams = (query) => {
103
- if (!query)
104
- return query;
130
+ if (!query) return query;
105
131
  const { plugins: _, ...validQueryParams } = {
106
132
  ...query,
107
133
  ...Object.values(query?.plugins ?? {}).reduce(
@@ -109,9 +135,6 @@ const buildValidParams = (query) => {
109
135
  {}
110
136
  )
111
137
  };
112
- if ("_q" in validQueryParams) {
113
- validQueryParams._q = encodeURIComponent(validQueryParams._q);
114
- }
115
138
  return validQueryParams;
116
139
  };
117
140
  const getDisplayName = ({
@@ -136,7 +159,6 @@ const AssigneeSelect = () => {
136
159
  id,
137
160
  slug: model = ""
138
161
  } = useParams();
139
- const dispatch = useDispatch();
140
162
  const permissions = useTypedSelector((state) => state.admin_app.permissions);
141
163
  const { formatMessage } = useIntl();
142
164
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
@@ -157,13 +179,13 @@ const AssigneeSelect = () => {
157
179
  documentId: id
158
180
  },
159
181
  {
160
- skip: !id
182
+ skip: !id && collectionType !== "single-types"
161
183
  }
162
184
  );
163
185
  const users = data?.users || [];
164
186
  const currentAssignee = document ? document[ASSIGNEE_ATTRIBUTE_NAME] : null;
165
187
  const [updateAssignee, { error, isLoading: isMutating }] = useUpdateAssigneeMutation();
166
- if (!collectionType || !model || !id) {
188
+ if (!collectionType || !model || !document?.documentId) {
167
189
  return null;
168
190
  }
169
191
  const handleChange = async (assigneeId) => {
@@ -173,22 +195,13 @@ const AssigneeSelect = () => {
173
195
  const res = await updateAssignee({
174
196
  slug: collectionType,
175
197
  model,
176
- id,
198
+ id: document.documentId,
177
199
  params,
178
200
  data: {
179
201
  id: assigneeId ? parseInt(assigneeId, 10) : null
180
202
  }
181
203
  });
182
204
  if ("data" in res) {
183
- dispatch({
184
- type: "contentManagerApi/invalidateTags",
185
- payload: [
186
- {
187
- type: "Document",
188
- id: `${model}_${id}`
189
- }
190
- ]
191
- });
192
205
  toggleNotification({
193
206
  type: "success",
194
207
  message: formatMessage({
@@ -219,7 +232,7 @@ const AssigneeSelect = () => {
219
232
  id: "content-manager.reviewWorkflows.assignee.clear",
220
233
  defaultMessage: "Clear assignee"
221
234
  }),
222
- disabled: !isLoadingPermissions && !isLoading && users.length === 0 || !id,
235
+ disabled: !isLoadingPermissions && !isLoading && users.length === 0 || !document.documentId,
223
236
  value: currentAssignee ? currentAssignee.id.toString() : null,
224
237
  onChange: handleChange,
225
238
  onClear: () => handleChange(null),
@@ -356,31 +369,31 @@ const StageSelect = () => {
356
369
  slug: model = "",
357
370
  id = ""
358
371
  } = useParams();
359
- const dispatch = useDispatch();
360
372
  const { formatMessage } = useIntl();
361
373
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
362
374
  const { toggleNotification } = useNotification();
363
375
  const [{ query }] = useQueryParams();
364
376
  const params = React.useMemo(() => buildValidParams(query), [query]);
365
- const { data, isLoading } = useGetStagesQuery(
377
+ const { document, isLoading: isLoadingDocument } = unstable_useDocument(
366
378
  {
367
- slug: collectionType,
379
+ collectionType,
368
380
  model,
369
- id,
370
- params
381
+ documentId: id
371
382
  },
372
383
  {
373
- skip: !id
384
+ skip: !id && collectionType !== "single-types"
374
385
  }
375
386
  );
376
- const { document } = unstable_useDocument(
387
+ const { data, isLoading: isLoadingStages } = useGetStagesQuery(
377
388
  {
378
- collectionType,
389
+ slug: collectionType,
379
390
  model,
380
- documentId: id
391
+ // @ts-expect-error – `id` is not correctly typed in the DS.
392
+ id: document?.documentId,
393
+ params
381
394
  },
382
395
  {
383
- skip: !id
396
+ skip: !document?.documentId
384
397
  }
385
398
  );
386
399
  const { meta, stages = [] } = data ?? {};
@@ -396,24 +409,15 @@ const StageSelect = () => {
396
409
  } else if (limits?.[CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME] && parseInt(limits[CHARGEBEE_STAGES_PER_WORKFLOW_ENTITLEMENT_NAME], 10) < stages.length) {
397
410
  setShowLimitModal("stage");
398
411
  } else {
399
- if (id) {
412
+ if (document?.documentId) {
400
413
  const res = await updateStage({
401
414
  model,
402
- id,
415
+ id: document.documentId,
403
416
  slug: collectionType,
404
417
  params,
405
418
  data: { id: stageId }
406
419
  });
407
420
  if ("data" in res) {
408
- dispatch({
409
- type: "contentManagerApi/invalidateTags",
410
- payload: [
411
- {
412
- type: "Document",
413
- id: `${model}_${id}`
414
- }
415
- ]
416
- });
417
421
  toggleNotification({
418
422
  type: "success",
419
423
  message: formatMessage({
@@ -435,6 +439,7 @@ const StageSelect = () => {
435
439
  }
436
440
  };
437
441
  const { themeColorName } = getStageColorByHex(activeWorkflowStage?.color) ?? {};
442
+ const isLoading = isLoadingStages || isLoadingDocument;
438
443
  return /* @__PURE__ */ jsxs(Fragment, { children: [
439
444
  /* @__PURE__ */ jsxs(
440
445
  Field.Root,
@@ -547,12 +552,16 @@ const StageSelect = () => {
547
552
  ] });
548
553
  };
549
554
  const Panel = () => {
550
- const { slug = "", id } = useParams();
555
+ const {
556
+ slug = "",
557
+ id,
558
+ collectionType
559
+ } = useParams();
551
560
  const {
552
561
  edit: { options }
553
562
  } = unstable_useDocumentLayout(slug);
554
563
  const { formatMessage } = useIntl();
555
- if (!window.strapi.isEE || !options?.reviewWorkflows || !id || id === "create") {
564
+ if (!window.strapi.isEE || !options?.reviewWorkflows || collectionType !== "single-types" && !id || id === "create") {
556
565
  return null;
557
566
  }
558
567
  return {
@@ -571,36 +580,25 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
571
580
  endpoints: (builder) => ({
572
581
  getWorkflows: builder.query({
573
582
  query: (args) => {
574
- const { id, ...params } = args ?? {};
575
583
  return {
576
- url: `/review-workflows/workflows${id ? `/${id}` : ""}`,
584
+ url: "/review-workflows/workflows",
577
585
  method: "GET",
578
586
  config: {
579
- params
587
+ params: args ?? {}
580
588
  }
581
589
  };
582
590
  },
583
591
  transformResponse: (res) => {
584
- let workflows = [];
585
- if (Array.isArray(res.data)) {
586
- workflows = res.data;
587
- } else {
588
- workflows = [res.data];
589
- }
590
592
  return {
591
- workflows,
593
+ workflows: res.data,
592
594
  meta: "meta" in res ? res.meta : void 0
593
595
  };
594
596
  },
595
- providesTags: (res, _err, arg) => {
596
- if (typeof arg === "object" && "id" in arg && arg.id !== "") {
597
- return [{ type: "ReviewWorkflow", id: arg.id }];
598
- } else {
599
- return [
600
- ...res?.workflows.map(({ id }) => ({ type: "ReviewWorkflow", id })) ?? [],
601
- { type: "ReviewWorkflow", id: "LIST" }
602
- ];
603
- }
597
+ providesTags: (res) => {
598
+ return [
599
+ ...res?.workflows.map(({ id }) => ({ type: "ReviewWorkflow", id })) ?? [],
600
+ { type: "ReviewWorkflow", id: "LIST" }
601
+ ];
604
602
  }
605
603
  }),
606
604
  createWorkflow: builder.mutation({
@@ -610,7 +608,18 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
610
608
  data
611
609
  }),
612
610
  transformResponse: (res) => res.data,
613
- invalidatesTags: [{ type: "ReviewWorkflow", id: "LIST" }, "ReviewWorkflowStages"]
611
+ invalidatesTags(res) {
612
+ return [
613
+ { type: "ReviewWorkflow", id: "LIST" },
614
+ "ReviewWorkflowStages",
615
+ { type: "Document", id: `ALL_LIST` },
616
+ { type: "ContentTypeSettings", id: "LIST" },
617
+ ...res?.contentTypes.map((uid) => ({
618
+ type: "Document",
619
+ id: `${uid}_ALL_ITEMS`
620
+ })) ?? []
621
+ ];
622
+ }
614
623
  }),
615
624
  updateWorkflow: builder.mutation({
616
625
  query: ({ id, ...data }) => ({
@@ -621,7 +630,13 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
621
630
  transformResponse: (res) => res.data,
622
631
  invalidatesTags: (res, _err, arg) => [
623
632
  { type: "ReviewWorkflow", id: arg.id },
624
- "ReviewWorkflowStages"
633
+ "ReviewWorkflowStages",
634
+ { type: "Document", id: "ALL_LIST" },
635
+ { type: "ContentTypeSettings", id: "LIST" },
636
+ ...res?.contentTypes.map((uid) => ({
637
+ type: "Document",
638
+ id: `${uid}_ALL_ITEMS`
639
+ })) ?? []
625
640
  ]
626
641
  }),
627
642
  deleteWorkflow: builder.mutation({
@@ -632,7 +647,9 @@ const settingsApi = reviewWorkflowsApi.injectEndpoints({
632
647
  transformResponse: (res) => res.data,
633
648
  invalidatesTags: (res, _err, arg) => [
634
649
  { type: "ReviewWorkflow", id: arg.id },
635
- "ReviewWorkflowStages"
650
+ "ReviewWorkflowStages",
651
+ { type: "Document", id: `ALL_LIST` },
652
+ { type: "ContentTypeSettings", id: "LIST" }
636
653
  ]
637
654
  })
638
655
  }),
@@ -717,9 +734,6 @@ const addColumnToTableHook = ({ displayedHeaders, layout }) => {
717
734
  };
718
735
  };
719
736
  const prefixPluginTranslations = (trad, pluginId) => {
720
- if (!pluginId) {
721
- throw new TypeError("pluginId can't be empty");
722
- }
723
737
  return Object.keys(trad).reduce((acc, current) => {
724
738
  acc[`${pluginId}.${current}`] = trad[current];
725
739
  return acc;
@@ -742,7 +756,7 @@ const admin = {
742
756
  },
743
757
  permissions: [],
744
758
  async Component() {
745
- const { Router } = await import("./router-t6Nj4F0T.mjs");
759
+ const { Router } = await import("./router-BPl2HZMq.mjs");
746
760
  return { default: Router };
747
761
  }
748
762
  });
@@ -754,19 +768,19 @@ const admin = {
754
768
  id: `${PLUGIN_ID}.plugin.name`,
755
769
  defaultMessage: "Review Workflows"
756
770
  },
771
+ licenseOnly: true,
757
772
  permissions: [],
758
773
  async Component() {
759
- const { PurchaseReviewWorkflows } = await import("./purchase-review-workflows-BN-5Ube7.mjs");
774
+ const { PurchaseReviewWorkflows } = await import("./purchase-review-workflows-DyFV_H0I.mjs");
760
775
  return { default: PurchaseReviewWorkflows };
761
- },
762
- lockIcon: true
776
+ }
763
777
  });
764
778
  }
765
779
  },
766
780
  async registerTrads({ locales }) {
767
781
  const importedTrads = await Promise.all(
768
782
  locales.map((locale) => {
769
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-D9ZrQAV6.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
783
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-D9dxziEb.mjs") }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
770
784
  return {
771
785
  data: prefixPluginTranslations(data, PLUGIN_ID),
772
786
  locale
@@ -798,4 +812,4 @@ export {
798
812
  reviewWorkflowsApi as r,
799
813
  useGetContentTypesQuery as u
800
814
  };
801
- //# sourceMappingURL=index-Bx0Y1GZR.mjs.map
815
+ //# sourceMappingURL=index-ByXbOW-R.mjs.map