@sensinum/strapi-plugin-xecp 5.1.0 → 5.3.0

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 (42) hide show
  1. package/README.md +14 -3
  2. package/dist/admin/App-BbgV5mHU.mjs +2809 -0
  3. package/dist/admin/App-OXf6qXjU.js +74 -0
  4. package/dist/admin/TruncatedTypography-B8iYkeNP.js +12 -0
  5. package/dist/admin/{TruncatedTypography-BIh1V9g2.mjs → TruncatedTypography-BA_MhPw6.mjs} +4 -4
  6. package/dist/admin/de-9eabZie2.mjs +288 -0
  7. package/dist/admin/de-BN51VcbT.js +1 -0
  8. package/dist/admin/en-DI1XKd0e.js +1 -0
  9. package/dist/admin/en-tFIwzuCy.mjs +288 -0
  10. package/dist/admin/fr-BRWFIMrf.mjs +288 -0
  11. package/dist/admin/fr-lAhQzMjM.js +1 -0
  12. package/dist/admin/index-BU_gTHIE.mjs +110 -0
  13. package/dist/admin/index-C5CJ1Sy4.js +1 -0
  14. package/dist/admin/index-CT94KSzm.mjs +656 -0
  15. package/dist/admin/index-CmLDGvPV.js +1 -0
  16. package/dist/admin/{index-Dr164lAs.mjs → index-SQ5frWDn.mjs} +96 -90
  17. package/dist/admin/{index-CzhrALSL.js → index-ghS-FZ_7.js} +8 -8
  18. package/dist/admin/index.js +1 -1
  19. package/dist/admin/index.mjs +3 -2
  20. package/dist/admin/pl-CSVwN6jF.js +1 -0
  21. package/dist/admin/pl-DLMBD4Lc.mjs +288 -0
  22. package/dist/admin/{queryKeys-rUHP1d6p.mjs → queryKeys-LazhiKSv.mjs} +5 -4
  23. package/dist/admin/queryKeys-Y6_AOyGq.js +1 -0
  24. package/dist/server/index.js +7 -7
  25. package/dist/server/index.mjs +8776 -8080
  26. package/package.json +48 -22
  27. package/dist/admin/App-DnN-IvA2.mjs +0 -1947
  28. package/dist/admin/App-fzbS9IJs.js +0 -30
  29. package/dist/admin/TruncatedTypography-IG2-4h8c.js +0 -12
  30. package/dist/admin/de-CXusi8Qg.mjs +0 -203
  31. package/dist/admin/de-DB2gq7qr.js +0 -1
  32. package/dist/admin/en-BuzP59R9.js +0 -1
  33. package/dist/admin/en-Dw6HZo7C.mjs +0 -203
  34. package/dist/admin/fr-CyBDGDh1.mjs +0 -203
  35. package/dist/admin/fr-ISZXcmX2.js +0 -1
  36. package/dist/admin/index-BPA-rtqa.js +0 -1
  37. package/dist/admin/index-CUUBtl-O.mjs +0 -113
  38. package/dist/admin/index-DDj2bCYO.mjs +0 -653
  39. package/dist/admin/index-DGBlS60G.js +0 -1
  40. package/dist/admin/pl-Ds5SR76s.js +0 -1
  41. package/dist/admin/pl-mwGoOpdR.mjs +0 -203
  42. package/dist/admin/queryKeys-B_GC_f73.js +0 -1
@@ -0,0 +1,656 @@
1
+ import { jsx as t, Fragment as G, jsxs as u } from "react/jsx-runtime";
2
+ import { useFetchClient as K, useForm as re, useNotification as se, Layouts as O, useRBAC as ae, Page as k, Form as le } from "@strapi/strapi/admin";
3
+ import { U as P, g as a, P as W } from "./index-BU_gTHIE.mjs";
4
+ import { S as D, P as de, Q as ce } from "./queryKeys-LazhiKSv.mjs";
5
+ import { useEffect as pe, useRef as me, useMemo as ue } from "react";
6
+ import { useIntl as E } from "react-intl";
7
+ import ge, { z as h } from "zod";
8
+ import { useQuery as _, queryOptions as he, useQueryClient as ye, useMutation as H } from "@tanstack/react-query";
9
+ import { Box as C, Field as T, SingleSelect as Te, SingleSelectOption as fe, Typography as v, Table as ve, Thead as Ee, Tr as j, Th as I, Tbody as Ce, Td as V, MultiSelect as be, MultiSelectOption as Se, Flex as z, Tooltip as Ae, Grid as A, NumberInput as we, TextInput as Q, Button as X, Loader as Re } from "@strapi/design-system";
10
+ import { Information as Ke, Check as Z } from "@strapi/icons";
11
+ import { T as B, A as J, b as Pe } from "./TruncatedTypography-BA_MhPw6.mjs";
12
+ import { isEqual as Fe } from "lodash";
13
+ const ke = 3, w = h.enum(["Related", "Promotable"]);
14
+ h.object({
15
+ targetEnvApiKey: h.string().optional(),
16
+ targetEnvApiUrl: h.url().optional(),
17
+ comparisonDepth: h.number().positive().optional(),
18
+ contentTypes: h.array(h.object({ uid: h.string(), key: h.string(), kind: w })).optional()
19
+ });
20
+ const De = () => {
21
+ const { get: e } = K();
22
+ return _({
23
+ queryKey: [D],
24
+ queryFn: async () => {
25
+ const { data: n } = await e(`/${P}/settings`);
26
+ return n;
27
+ }
28
+ });
29
+ }, Ue = [
30
+ D,
31
+ "content-type-options"
32
+ ], Le = () => {
33
+ const { get: e } = K();
34
+ return _({
35
+ queryKey: Ue,
36
+ queryFn: async () => {
37
+ const { data: n } = await e(
38
+ `/${P}/settings/content-type-options`
39
+ );
40
+ return n;
41
+ }
42
+ });
43
+ }, qe = (e) => [D, "related-content-types", e], Ie = (e, n) => he({
44
+ queryKey: qe(n),
45
+ queryFn: async () => {
46
+ const { data: o } = await e(
47
+ `/${P}/settings/related-content-types`,
48
+ {
49
+ params: {
50
+ allowed: n.join(",")
51
+ }
52
+ }
53
+ );
54
+ return o;
55
+ }
56
+ }), N = (e) => {
57
+ const { get: n } = K();
58
+ return _({
59
+ ...Ie(n, e),
60
+ enabled: e.length > 0
61
+ });
62
+ }, Ve = () => {
63
+ const { put: e } = K(), n = ye();
64
+ return H({
65
+ mutationFn: async (o) => e(`/${P}/settings`, o),
66
+ onSuccess: async () => {
67
+ await Promise.all([
68
+ n.invalidateQueries({ queryKey: [D] }),
69
+ n.invalidateQueries({ queryKey: [de] })
70
+ ]);
71
+ }
72
+ });
73
+ }, Me = (e, n) => Object.fromEntries(
74
+ Object.entries(n).filter(
75
+ ([o, r]) => !Fe(r, e[o])
76
+ )
77
+ ), ee = h.object({
78
+ allowedContentTypes: h.array(h.string()).min(1, { message: "settings.form.error.minimalArrayLength" }),
79
+ contentTypeSettings: h.record(
80
+ h.string(),
81
+ h.object({
82
+ key: h.string({ message: "settings.form.error.required" }).min(1, { message: "settings.form.error.required" }).optional()
83
+ }).optional()
84
+ ),
85
+ targetEnvApiKey: h.string({ message: "settings.form.error.required" }).min(1, { message: "settings.form.error.required" }),
86
+ targetEnvApiUrl: h.url({ message: "settings.form.error.validURL" }),
87
+ comparisonDepth: h.number({ message: "settings.form.error.required" }).positive({ message: "settings.form.error.positive" })
88
+ }), _e = ee.extend({
89
+ relatedContentTypes: h.string().array()
90
+ }), Ne = _e.refine(
91
+ (e) => [
92
+ ...e.allowedContentTypes,
93
+ ...e.relatedContentTypes
94
+ ].every(
95
+ (o) => !!e.contentTypeSettings[o]?.key
96
+ ),
97
+ {
98
+ path: ["allowedContentTypes"],
99
+ message: "settings.form.error.uniqueKeyRequired",
100
+ when(e) {
101
+ return ee.pick({ contentTypeSettings: !0 }).safeParse(e.value).success;
102
+ }
103
+ }
104
+ ), xe = (e, n) => {
105
+ const o = [...e.allowedContentTypes, ...n];
106
+ return {
107
+ ...e,
108
+ contentTypeSettings: Object.fromEntries(
109
+ o.map((r) => [
110
+ r,
111
+ e.contentTypeSettings[r]
112
+ ])
113
+ )
114
+ };
115
+ }, te = (e) => e.replace(".", ":"), M = (e) => e.replace(/:(?!.*:)/, "."), Oe = (e, n) => {
116
+ const r = {
117
+ ...xe(n, e),
118
+ relatedContentTypes: e
119
+ }, i = Ne.parse(r);
120
+ return {
121
+ contentTypes: [
122
+ ...i.allowedContentTypes,
123
+ ...i.relatedContentTypes
124
+ ].map((c) => ({
125
+ uid: M(c),
126
+ key: i.contentTypeSettings[c]?.key,
127
+ kind: i.allowedContentTypes.includes(c) ? w.enum.Promotable : w.enum.Related
128
+ })),
129
+ targetEnvApiKey: i.targetEnvApiKey,
130
+ targetEnvApiUrl: i.targetEnvApiUrl,
131
+ comparisonDepth: i.comparisonDepth
132
+ };
133
+ }, je = {
134
+ background: "neutral0",
135
+ hasRadius: !0,
136
+ shadow: "filterShadow",
137
+ padding: 6,
138
+ width: "100%"
139
+ }, x = ({ children: e, marginTop: n }) => /* @__PURE__ */ t(C, { ...je, marginTop: n, children: e }), Qe = ({
140
+ onChange: e,
141
+ uniqueKeys: n,
142
+ value: o,
143
+ name: r,
144
+ error: i,
145
+ disabled: l = !1
146
+ }) => {
147
+ const { formatMessage: c } = E(), g = Object.keys(n).filter((m) => n[m] === "ok");
148
+ return pe(() => {
149
+ !o && g.length > 0 && e("");
150
+ }, []), /* @__PURE__ */ t(G, { children: g.length > 0 ? /* @__PURE__ */ u(T.Root, { error: i && c({ id: a(i) }), children: [
151
+ /* @__PURE__ */ t(
152
+ Te,
153
+ {
154
+ name: r,
155
+ value: o,
156
+ onChange: e,
157
+ required: !0,
158
+ disabled: l,
159
+ children: g.map((m) => /* @__PURE__ */ t(fe, { value: m, children: m }, m))
160
+ }
161
+ ),
162
+ /* @__PURE__ */ t(T.Error, {})
163
+ ] }) : /* @__PURE__ */ t(
164
+ T.Root,
165
+ {
166
+ error: c({ id: a("settings.table.uniqueKeyRequiredWarning") }),
167
+ children: /* @__PURE__ */ t(T.Error, {})
168
+ }
169
+ ) });
170
+ }, Y = ({
171
+ label: e,
172
+ contentTypes: n,
173
+ setFormValue: o,
174
+ errors: r,
175
+ contentTypeSettings: i,
176
+ shouldShowRequiredBy: l,
177
+ isReadOnly: c,
178
+ environmentSpecificFields: g = {}
179
+ }) => {
180
+ const { formatMessage: m } = E();
181
+ return /* @__PURE__ */ u(C, { marginTop: 4, width: "100%", paddingTop: 4, children: [
182
+ /* @__PURE__ */ t(C, { marginBottom: 1, children: /* @__PURE__ */ t(v, { variant: "pi", textColor: "neutral800", fontWeight: "bold", children: e }) }),
183
+ /* @__PURE__ */ u(ve, { width: "100%", rowCount: n.length, colCount: l ? 3 : 2, children: [
184
+ /* @__PURE__ */ t(Ee, { children: /* @__PURE__ */ u(j, { children: [
185
+ /* @__PURE__ */ t(I, { children: /* @__PURE__ */ t(v, { variant: "sigma", children: m({ id: a("settings.table.contentType") }) }) }),
186
+ l && /* @__PURE__ */ t(I, { children: /* @__PURE__ */ t(v, { variant: "sigma", children: m({ id: a("settings.table.requiredBy") }) }) }),
187
+ /* @__PURE__ */ t(I, { children: /* @__PURE__ */ t(v, { variant: "sigma", children: m({ id: a("settings.table.uniqueKey") }) }) })
188
+ ] }) }),
189
+ /* @__PURE__ */ t(Ce, { children: n.map((s) => {
190
+ const d = `contentTypeSettings.${s.uid}.key`, p = g[s.uid] ?? [];
191
+ return /* @__PURE__ */ u(j, { children: [
192
+ /* @__PURE__ */ t(V, { width: l ? "25%" : "50%", children: /* @__PURE__ */ t(
193
+ B,
194
+ {
195
+ maxCharacters: 55,
196
+ text: s.displayName,
197
+ textColor: "neutral800"
198
+ }
199
+ ) }),
200
+ l && /* @__PURE__ */ t(V, { width: "25%", children: /* @__PURE__ */ t(
201
+ B,
202
+ {
203
+ maxCharacters: 55,
204
+ text: s.requiredBy,
205
+ textColor: "neutral800"
206
+ }
207
+ ) }),
208
+ /* @__PURE__ */ u(V, { width: "50%", children: [
209
+ /* @__PURE__ */ t(
210
+ Qe,
211
+ {
212
+ onChange: (y) => {
213
+ o(d, y);
214
+ },
215
+ value: i[s.uid]?.key,
216
+ uniqueKeys: s.uniqueKeys,
217
+ name: d,
218
+ error: r[d],
219
+ disabled: c
220
+ }
221
+ ),
222
+ p.length > 0 && /* @__PURE__ */ t(C, { marginTop: 1, children: /* @__PURE__ */ t(
223
+ v,
224
+ {
225
+ variant: "pi",
226
+ textColor: "neutral600",
227
+ style: { whiteSpace: "normal", overflowWrap: "anywhere" },
228
+ children: m(
229
+ { id: a("settings.table.environmentSpecificFields") },
230
+ { fields: p.join(", ") }
231
+ )
232
+ }
233
+ ) })
234
+ ] })
235
+ ] }, s.uid);
236
+ }) })
237
+ ] })
238
+ ] });
239
+ }, Be = ({
240
+ allowedContentTypes: e,
241
+ contentTypeSettings: n,
242
+ setFormValue: o,
243
+ promotableContentTypes: r,
244
+ errors: i,
245
+ isReadOnly: l,
246
+ environmentSpecificFields: c
247
+ }) => {
248
+ const { formatMessage: g } = E(), m = e.flatMap((p) => {
249
+ const y = r?.find(({ uid: F }) => F === p);
250
+ return y ? [y] : [];
251
+ }), { data: s, isLoading: d } = N(e);
252
+ return d ? null : /* @__PURE__ */ u(x, { children: [
253
+ /* @__PURE__ */ t(v, { variant: "delta", children: g({ id: a("settings.allowedContentTypes") }) }),
254
+ /* @__PURE__ */ t(C, { marginTop: 4, width: "100%", children: /* @__PURE__ */ u(
255
+ T.Root,
256
+ {
257
+ width: "100%",
258
+ error: i.allowedContentTypes && g({ id: a(i.allowedContentTypes) }),
259
+ children: [
260
+ /* @__PURE__ */ t(T.Label, { children: g({ id: a("settings.allowedContentTypes.label") }) }),
261
+ /* @__PURE__ */ t(
262
+ be,
263
+ {
264
+ withTags: !0,
265
+ name: "allowedContentTypes",
266
+ value: e,
267
+ onChange: (p) => {
268
+ o("allowedContentTypes", p);
269
+ },
270
+ hasError: !!i.allowedContentTypes,
271
+ disabled: l,
272
+ children: r?.map((p) => /* @__PURE__ */ t(Se, { value: p.uid, children: p.displayName }, p.uid))
273
+ }
274
+ ),
275
+ /* @__PURE__ */ t(T.Error, {})
276
+ ]
277
+ }
278
+ ) }),
279
+ e?.length > 0 && /* @__PURE__ */ t(
280
+ Y,
281
+ {
282
+ label: g({
283
+ id: a("settings.table.keyForEligibleContentTypes")
284
+ }),
285
+ contentTypes: m,
286
+ setFormValue: o,
287
+ errors: i,
288
+ contentTypeSettings: n,
289
+ isReadOnly: l,
290
+ environmentSpecificFields: c
291
+ }
292
+ ),
293
+ (s?.length ?? 0) > 0 && /* @__PURE__ */ t(
294
+ Y,
295
+ {
296
+ label: g({
297
+ id: a("settings.table.keyForRelatedContentTypes")
298
+ }),
299
+ contentTypes: s ?? [],
300
+ setFormValue: o,
301
+ errors: i,
302
+ contentTypeSettings: n,
303
+ shouldShowRequiredBy: !0,
304
+ isReadOnly: l,
305
+ environmentSpecificFields: c
306
+ }
307
+ )
308
+ ] });
309
+ }, Ye = () => {
310
+ const { formatMessage: e } = E();
311
+ return /* @__PURE__ */ t(C, { marginTop: 4, children: /* @__PURE__ */ t(
312
+ J,
313
+ {
314
+ title: e({ id: a("settings.alert.comparisonDepthHigh.title") }),
315
+ variant: "warning",
316
+ description: e({
317
+ id: a("settings.alert.comparisonDepthHigh.description")
318
+ })
319
+ }
320
+ ) });
321
+ }, $e = ({ comparisonDepth: e, setFormValue: n, errors: o, isReadOnly: r }) => {
322
+ const { formatMessage: i } = E();
323
+ return /* @__PURE__ */ u(x, { marginTop: 4, children: [
324
+ /* @__PURE__ */ u(z, { marginBottom: 4, gap: 1, children: [
325
+ /* @__PURE__ */ t(v, { variant: "delta", children: i({ id: a("settings.comparisonDepth") }) }),
326
+ /* @__PURE__ */ t(Ae, { label: i({ id: a("settings.comparisonDepth.tooltip") }), children: /* @__PURE__ */ t(Ke, {}) })
327
+ ] }),
328
+ /* @__PURE__ */ t(A.Root, { gap: 4, children: /* @__PURE__ */ t(A.Item, { col: 6, alignItems: "start", children: /* @__PURE__ */ u(
329
+ T.Root,
330
+ {
331
+ error: o.comparisonDepth && i({ id: a(o.comparisonDepth) }),
332
+ width: "100%",
333
+ children: [
334
+ /* @__PURE__ */ t(T.Label, { children: i({ id: a("settings.comparisonDepth.label") }) }),
335
+ /* @__PURE__ */ t(
336
+ we,
337
+ {
338
+ value: e,
339
+ onValueChange: (l) => n("comparisonDepth", l),
340
+ name: "comparisonDepth",
341
+ disabled: r
342
+ }
343
+ ),
344
+ /* @__PURE__ */ t(T.Error, {})
345
+ ]
346
+ }
347
+ ) }) }),
348
+ e > 5 && /* @__PURE__ */ t(Ye, {})
349
+ ] });
350
+ }, Ge = ({ staleValueMessages: e }) => {
351
+ const { formatMessage: n } = E();
352
+ return /* @__PURE__ */ t(C, { marginBottom: 4, children: /* @__PURE__ */ u(
353
+ J,
354
+ {
355
+ title: n({ id: a("settings.alert.staleValuesRemoved.title") }),
356
+ variant: "danger",
357
+ children: [
358
+ n({ id: a("settings.alert.staleValuesRemoved.description") }),
359
+ e.map((o, r) => (
360
+ // oxlint-disable-next-line react/no-array-index-key -- messages have no stable id
361
+ /* @__PURE__ */ u("span", { children: [
362
+ /* @__PURE__ */ t("br", {}),
363
+ r + 1,
364
+ ".",
365
+ " ",
366
+ n(
367
+ {
368
+ id: a(o.message)
369
+ },
370
+ o.variables
371
+ )
372
+ ] }, r)
373
+ ))
374
+ ]
375
+ }
376
+ ) });
377
+ }, We = () => {
378
+ const { post: e } = K();
379
+ return H({
380
+ mutationFn: async (n) => {
381
+ const { data: o } = await e(
382
+ `/${P}/settings/testConnection`,
383
+ n
384
+ );
385
+ return o;
386
+ }
387
+ });
388
+ }, He = "settings.form.error.badApiUrl", ze = {
389
+ badApiKey: "settings.form.error.badApiKey",
390
+ badPermissions: "settings.form.error.badKeyPermissions"
391
+ }, Xe = ({
392
+ targetEnvApiKey: e,
393
+ targetEnvApiUrl: n,
394
+ setFormValue: o,
395
+ errors: r,
396
+ isReadOnly: i
397
+ }) => {
398
+ const { formatMessage: l } = E(), c = We(), { setErrors: g } = re("TargetEnvConfigurationSection", (p) => p), m = async () => {
399
+ const p = (y) => {
400
+ g({
401
+ ...r,
402
+ targetEnvApiUrl: y.outcome === "badUrl" ? He : void 0,
403
+ targetEnvApiKey: ze[y.outcome]
404
+ });
405
+ };
406
+ try {
407
+ const y = await c.mutateAsync({
408
+ targetEnvApiKey: e,
409
+ targetEnvApiUrl: n
410
+ });
411
+ p(y);
412
+ } catch {
413
+ p({ outcome: "unexpected" });
414
+ }
415
+ }, s = c.isSuccess && c.data?.outcome === "reachable", d = c.isError || c.data?.outcome === "unexpected";
416
+ return /* @__PURE__ */ u(x, { marginTop: 4, children: [
417
+ /* @__PURE__ */ t(C, { marginBottom: 4, children: /* @__PURE__ */ t(v, { variant: "delta", children: l({ id: a("settings.targetEnvConfiguration") }) }) }),
418
+ /* @__PURE__ */ u(A.Root, { gap: 4, children: [
419
+ /* @__PURE__ */ t(A.Item, { col: 6, alignItems: "start", children: /* @__PURE__ */ u(
420
+ T.Root,
421
+ {
422
+ error: r.targetEnvApiUrl && l({ id: a(r.targetEnvApiUrl) }),
423
+ width: "100%",
424
+ children: [
425
+ /* @__PURE__ */ t(T.Label, { children: l({ id: a("settings.targetEnvApiUrl.label") }) }),
426
+ /* @__PURE__ */ t(
427
+ Q,
428
+ {
429
+ name: "targetEnvApiUrl",
430
+ value: n,
431
+ onChange: o,
432
+ disabled: i
433
+ }
434
+ ),
435
+ /* @__PURE__ */ t(T.Error, {})
436
+ ]
437
+ }
438
+ ) }),
439
+ /* @__PURE__ */ t(A.Item, { col: 6, alignItems: "start", children: /* @__PURE__ */ u(
440
+ T.Root,
441
+ {
442
+ error: r.targetEnvApiKey && l({ id: a(r.targetEnvApiKey) }),
443
+ width: "100%",
444
+ children: [
445
+ /* @__PURE__ */ t(T.Label, { children: l({ id: a("settings.targetEnvApiKey.label") }) }),
446
+ /* @__PURE__ */ t(
447
+ Q,
448
+ {
449
+ name: "targetEnvApiKey",
450
+ value: e,
451
+ onChange: o,
452
+ disabled: i
453
+ }
454
+ ),
455
+ /* @__PURE__ */ t(T.Error, {})
456
+ ]
457
+ }
458
+ ) }),
459
+ /* @__PURE__ */ u(A.Item, { col: 6, children: [
460
+ i ? null : /* @__PURE__ */ t(X, { onClick: m, disabled: c.isPending, children: l({ id: a("settings.form.testConnection") }) }),
461
+ /* @__PURE__ */ u(z, { marginLeft: 1, alignItems: "center", gap: 2, children: [
462
+ c.isPending && /* @__PURE__ */ t(Re, { small: !0 }),
463
+ s && /* @__PURE__ */ t(Z, { color: "#5cb176" }),
464
+ d && /* @__PURE__ */ t(v, { variant: "pi", textColor: "danger600", children: l({ id: a("settings.form.error.connectionFailed") }) })
465
+ ] })
466
+ ] })
467
+ ] })
468
+ ] });
469
+ }, Ze = ({
470
+ values: e,
471
+ onChange: n,
472
+ errors: o,
473
+ setErrors: r,
474
+ modified: i,
475
+ settings: l,
476
+ promotableContentTypes: c,
477
+ staleValuesMessages: g,
478
+ isReadOnly: m,
479
+ environmentSpecificFields: s
480
+ }) => {
481
+ const { formatMessage: d } = E(), { toggleNotification: p } = se(), y = Ve(), { data: F = [], isFetching: U } = N(e.allowedContentTypes), L = async () => {
482
+ try {
483
+ const b = F.map((S) => S.uid), R = Oe(b, e), f = Me(l, R);
484
+ await y.mutateAsync(f, {
485
+ onSuccess: () => {
486
+ r({}), p({
487
+ type: "success",
488
+ message: d({ id: a("settings.form.savedSuccessfully") })
489
+ });
490
+ }
491
+ });
492
+ } catch (b) {
493
+ if (b instanceof ge.ZodError) {
494
+ const R = b.issues.reduce((f, S) => (f[S.path.join(".")] = S.message, f), {});
495
+ r(R), p({
496
+ type: "warning",
497
+ message: d({ id: a("settings.form.error.validationMessage") })
498
+ });
499
+ } else
500
+ p({
501
+ type: "warning",
502
+ message: Pe(b, d) ?? d({ id: a("settings.form.error.other") })
503
+ });
504
+ }
505
+ }, q = m || !i && g.length === 0 || U || y.isPending;
506
+ return /* @__PURE__ */ u(G, { children: [
507
+ /* @__PURE__ */ t(
508
+ O.Header,
509
+ {
510
+ title: d({ id: a("settings.title") }),
511
+ subtitle: d({ id: a("settings.subtitle") }),
512
+ primaryAction: m ? null : /* @__PURE__ */ t(
513
+ X,
514
+ {
515
+ type: "submit",
516
+ startIcon: /* @__PURE__ */ t(Z, {}),
517
+ onClick: L,
518
+ disabled: q,
519
+ children: d({
520
+ id: a("settings.form.submit")
521
+ })
522
+ }
523
+ )
524
+ }
525
+ ),
526
+ /* @__PURE__ */ u(O.Content, { children: [
527
+ g.length > 0 && /* @__PURE__ */ t(Ge, { staleValueMessages: g }),
528
+ /* @__PURE__ */ t(
529
+ Be,
530
+ {
531
+ allowedContentTypes: e.allowedContentTypes,
532
+ contentTypeSettings: e.contentTypeSettings,
533
+ setFormValue: n,
534
+ promotableContentTypes: c,
535
+ errors: o,
536
+ isReadOnly: m,
537
+ environmentSpecificFields: s
538
+ }
539
+ ),
540
+ /* @__PURE__ */ t(
541
+ $e,
542
+ {
543
+ setFormValue: n,
544
+ errors: o,
545
+ comparisonDepth: e.comparisonDepth,
546
+ isReadOnly: m
547
+ }
548
+ ),
549
+ /* @__PURE__ */ t(
550
+ Xe,
551
+ {
552
+ targetEnvApiKey: e.targetEnvApiKey,
553
+ targetEnvApiUrl: e.targetEnvApiUrl,
554
+ setFormValue: n,
555
+ errors: o,
556
+ isReadOnly: m
557
+ }
558
+ )
559
+ ] })
560
+ ] });
561
+ }, $ = (e) => {
562
+ const n = e.contentTypes ?? [], o = n.filter((i) => i.kind === w.enum.Promotable).map((i) => i.uid), r = Object.fromEntries(
563
+ n.map((i) => [i.uid, { key: i.key }])
564
+ );
565
+ return {
566
+ allowedContentTypes: o,
567
+ contentTypeSettings: r,
568
+ targetEnvApiKey: e?.targetEnvApiKey ?? "",
569
+ targetEnvApiUrl: e?.targetEnvApiUrl ?? "",
570
+ comparisonDepth: e?.comparisonDepth ?? ke
571
+ };
572
+ }, Je = {
573
+ ok: void 0,
574
+ notUnique: "settings.alert.staleValuesRemoved.keyDeleted",
575
+ environmentSpecific: "settings.alert.staleValuesRemoved.keyEnvironmentSpecific",
576
+ private: "settings.alert.staleValuesRemoved.keyPrivate"
577
+ }, et = (e, n, o) => {
578
+ if (!e.contentTypes)
579
+ return [$(e), []];
580
+ const r = [], i = e.contentTypes.map((s) => ({
581
+ ...s,
582
+ uid: te(s.uid)
583
+ })), l = n.map((s) => s.uid), g = i.filter(
584
+ (s) => {
585
+ const d = !l.includes(s.uid);
586
+ return d && r.push({
587
+ message: "settings.alert.staleValuesRemoved.contentTypeDeleted",
588
+ variables: { uid: M(s.uid) }
589
+ }), !d;
590
+ }
591
+ ).filter((s) => {
592
+ const d = !o.includes(s.uid) && s.kind === w.enum.Related;
593
+ return d && r.push({
594
+ message: "settings.alert.staleValuesRemoved.relationDeleted",
595
+ variables: { uid: M(s.uid) }
596
+ }), !d;
597
+ }).map((s) => {
598
+ const d = n.find(
599
+ (y) => y.uid === s.uid
600
+ ), p = Je[d?.uniqueKeys[s.key] ?? "notUnique"];
601
+ return p && r.push({
602
+ message: p,
603
+ variables: {
604
+ key: s.key,
605
+ schemaDisplayName: d?.displayName
606
+ }
607
+ }), {
608
+ ...s,
609
+ key: p ? void 0 : s.key
610
+ };
611
+ });
612
+ return [$({
613
+ ...e,
614
+ contentTypes: g
615
+ }), r];
616
+ }, tt = () => {
617
+ const { formatMessage: e } = E(), n = me(null), {
618
+ isLoading: o,
619
+ allowedActions: { canUpdate: r }
620
+ } = ae([...W.settingsUpdate]), { data: i, isLoading: l } = De(), { data: c, isLoading: g } = Le(), m = ue(
621
+ () => (i?.contentTypes ?? []).filter((f) => f.kind === w.enum.Promotable).map((f) => te(f.uid)),
622
+ [i?.contentTypes]
623
+ ), {
624
+ data: s = [],
625
+ isLoading: d,
626
+ isFetched: p
627
+ } = N(m), y = m.length === 0 || p;
628
+ if (o || l || g || d || !y || !i || !c)
629
+ return /* @__PURE__ */ t(k.Loading, {});
630
+ const { promotableContentTypes: U, relationLookupContentTypes: L, environmentSpecificFields: q } = c, [b, R] = et(
631
+ i,
632
+ L,
633
+ s.map((f) => f.uid)
634
+ );
635
+ return /* @__PURE__ */ u(k.Main, { children: [
636
+ /* @__PURE__ */ t(k.Title, { children: e({ id: a("settings.metadata.title") }) }),
637
+ /* @__PURE__ */ t(le, { width: "100%", height: "100%", ref: n, method: "PUT", initialValues: b, children: ({ values: f, onChange: S, errors: ne, setErrors: ie, modified: oe }) => /* @__PURE__ */ t(
638
+ Ze,
639
+ {
640
+ values: f,
641
+ onChange: S,
642
+ errors: ne,
643
+ setErrors: ie,
644
+ modified: oe,
645
+ settings: i,
646
+ promotableContentTypes: U,
647
+ staleValuesMessages: R,
648
+ isReadOnly: !r,
649
+ environmentSpecificFields: q
650
+ }
651
+ ) })
652
+ ] });
653
+ }, gt = () => /* @__PURE__ */ t(k.Protect, { permissions: [...W.settingsRead], children: /* @__PURE__ */ t(ce, { children: /* @__PURE__ */ t(tt, {}) }) });
654
+ export {
655
+ gt as default
656
+ };
@@ -0,0 +1 @@
1
+ "use strict";const p=require("zod"),c=require("react"),g=require("@strapi/icons"),f=e=>e&&e.__esModule?e:{default:e},P=f(p),b=(e,t,s)=>{const i=e[t];return i?typeof i=="function"?i():Promise.resolve(i):new Promise((L,m)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(m.bind(null,new Error("Unknown variable dynamic import: "+t+(t.split("/").length!==s?". Note that variables only represent file names one level deep.":""))))})},R="@sensinum/strapi-plugin-xecp",v="5.3.0",q={name:"content-promotion"},d={name:R,version:v,strapi:q},n=P.default.literal("content-promotion").parse(d.strapi.name),a="xecp",o={settings:{read:"settings.read",update:"settings.update"},promotion:{read:"promotion.read",execute:"promotion.execute"}},I=e=>`plugin::${n}.${e}`,r=e=>({action:I(e),subject:null}),u={settingsRead:[r(o.settings.read)],settingsUpdate:[r(o.settings.update)],promotionRead:[r(o.promotion.read)],promotionExecute:[r(o.promotion.execute)]},_=({setPlugin:e})=>{const t=c.useRef(e);return c.useEffect(()=>{t.current(n)},[]),null},l=e=>`${n}.${e}`,$=e=>Object.keys(e).reduce((t,s)=>(t[`${n}.${s}`]=e[s],t),{}),y={register(e){e.addMenuLink({to:`plugins/${a}`,icon:g.Files,intlLabel:{id:`${n}.plugin.name`,defaultMessage:n},Component:()=>Promise.resolve().then(()=>require("./App-OXf6qXjU.js")),permissions:[...u.promotionRead]}),e.addSettingsLink({id:n,intlLabel:{id:l("settings.section.sectionName"),defaultMessage:"Content Promotion Plugin"}},[{intlLabel:{id:l("settings.section.about"),defaultMessage:"About"},id:"about",to:`${a}/about`,Component:()=>Promise.resolve().then(()=>require("./index-ghS-FZ_7.js")),permissions:[...u.settingsRead]},{intlLabel:{id:l("settings.section.configuration"),defaultMessage:"Configuration"},id:"configuration",to:`${a}/configuration`,Component:()=>Promise.resolve().then(()=>require("./index-C5CJ1Sy4.js")),permissions:[...u.settingsRead]}]),e.registerPlugin({id:n,initializer:_,isReady:!1,name:n})},async registerTrads({locales:e}){return Promise.all(e.map(async t=>{try{const{default:s}=await b(Object.assign({"./translations/de.json":()=>Promise.resolve().then(()=>require("./de-BN51VcbT.js")),"./translations/en.json":()=>Promise.resolve().then(()=>require("./en-DI1XKd0e.js")),"./translations/fr.json":()=>Promise.resolve().then(()=>require("./fr-lAhQzMjM.js")),"./translations/pl.json":()=>Promise.resolve().then(()=>require("./pl-CSVwN6jF.js"))}),`./translations/${t}.json`,3);return{data:$(s),locale:t}}catch{return{data:{},locale:t}}}))}};exports.PERMISSIONS=u;exports.PLUGIN_ID=n;exports.URL_PREFIX=a;exports.getTranslation=l;exports.index=y;exports.packageJson=d;