les-revisions 1.0.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 (41) hide show
  1. package/README.md +3 -0
  2. package/dist/_chunks/App-BkgPjE-W.js +726 -0
  3. package/dist/_chunks/App-CYbCF5EG.mjs +726 -0
  4. package/dist/_chunks/en-Cx-m8SNd.mjs +63 -0
  5. package/dist/_chunks/en-Edhi5HYx.js +63 -0
  6. package/dist/_chunks/fr-DXjiOCnX.js +63 -0
  7. package/dist/_chunks/fr-Dbv27Oj8.mjs +63 -0
  8. package/dist/_chunks/index-BYJMXObQ.mjs +70 -0
  9. package/dist/_chunks/index-C7ce1PfW.js +69 -0
  10. package/dist/admin/index.js +3 -0
  11. package/dist/admin/index.mjs +4 -0
  12. package/dist/admin/src/components/Initializer.d.ts +5 -0
  13. package/dist/admin/src/components/PluginIcon.d.ts +2 -0
  14. package/dist/admin/src/index.d.ts +10 -0
  15. package/dist/admin/src/pages/App.d.ts +2 -0
  16. package/dist/admin/src/pages/ComparePage.d.ts +2 -0
  17. package/dist/admin/src/pages/EntriesPage.d.ts +2 -0
  18. package/dist/admin/src/pages/HomePage.d.ts +2 -0
  19. package/dist/admin/src/pages/RevisionHistoryPage.d.ts +2 -0
  20. package/dist/admin/src/pluginId.d.ts +1 -0
  21. package/dist/admin/src/utils/api.d.ts +14 -0
  22. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  23. package/dist/server/index.js +900 -0
  24. package/dist/server/index.mjs +901 -0
  25. package/dist/server/src/bootstrap.d.ts +5 -0
  26. package/dist/server/src/config/index.d.ts +12 -0
  27. package/dist/server/src/content-types/index.d.ts +76 -0
  28. package/dist/server/src/content-types/revision/index.d.ts +74 -0
  29. package/dist/server/src/controllers/index.d.ts +15 -0
  30. package/dist/server/src/controllers/revision.d.ts +41 -0
  31. package/dist/server/src/destroy.d.ts +5 -0
  32. package/dist/server/src/index.d.ts +189 -0
  33. package/dist/server/src/middlewares/index.d.ts +2 -0
  34. package/dist/server/src/policies/index.d.ts +2 -0
  35. package/dist/server/src/register.d.ts +5 -0
  36. package/dist/server/src/routes/admin/index.d.ts +12 -0
  37. package/dist/server/src/routes/content-api/index.d.ts +5 -0
  38. package/dist/server/src/routes/index.d.ts +18 -0
  39. package/dist/server/src/services/index.d.ts +59 -0
  40. package/dist/server/src/services/revision.d.ts +84 -0
  41. package/package.json +69 -0
@@ -0,0 +1,726 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const admin = require("@strapi/strapi/admin");
5
+ const reactRouterDom = require("react-router-dom");
6
+ const designSystem = require("@strapi/design-system");
7
+ const styledComponents = require("styled-components");
8
+ const react = require("react");
9
+ const reactIntl = require("react-intl");
10
+ const icons = require("@strapi/icons");
11
+ const index = require("./index-C7ce1PfW.js");
12
+ const getTranslation = (id) => `${index.PLUGIN_ID}.${id}`;
13
+ const API_BASE = `/${index.PLUGIN_ID}`;
14
+ const API_ROUTES = {
15
+ contentTypes: `${API_BASE}/content-types`,
16
+ entries: `${API_BASE}/entries`,
17
+ revisions: `${API_BASE}/revisions`,
18
+ compare: `${API_BASE}/revisions/compare`,
19
+ config: `${API_BASE}/config`
20
+ };
21
+ const PLUGIN_ROUTES = {
22
+ home: `/plugins/${index.PLUGIN_ID}`,
23
+ entries: `/plugins/${index.PLUGIN_ID}/entries`,
24
+ history: `/plugins/${index.PLUGIN_ID}/history`,
25
+ compare: `/plugins/${index.PLUGIN_ID}/compare`
26
+ };
27
+ const HomePage = () => {
28
+ const navigate = reactRouterDom.useNavigate();
29
+ const { get } = admin.useFetchClient();
30
+ const { formatMessage } = reactIntl.useIntl();
31
+ const [contentTypes, setContentTypes] = react.useState([]);
32
+ const [loading, setLoading] = react.useState(true);
33
+ const [error, setError] = react.useState(null);
34
+ react.useEffect(() => {
35
+ const fetchData = async () => {
36
+ try {
37
+ const { data } = await get(API_ROUTES.contentTypes);
38
+ setContentTypes(data);
39
+ } catch (err) {
40
+ setError(err?.message || "Failed to load content types");
41
+ } finally {
42
+ setLoading(false);
43
+ }
44
+ };
45
+ fetchData();
46
+ }, [get]);
47
+ if (loading) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
48
+ if (error) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {});
49
+ const totalRevisions = contentTypes.reduce((sum, ct) => sum + ct.revisionCount, 0);
50
+ const avgPerType = contentTypes.length > 0 ? Math.round(totalRevisions / contentTypes.length) : 0;
51
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
52
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: formatMessage({ id: getTranslation("page.home.title") }) }),
53
+ /* @__PURE__ */ jsxRuntime.jsx(
54
+ admin.Layouts.Header,
55
+ {
56
+ title: formatMessage({ id: getTranslation("page.home.title") }),
57
+ subtitle: formatMessage({ id: getTranslation("page.home.subtitle") })
58
+ }
59
+ ),
60
+ /* @__PURE__ */ jsxRuntime.jsxs(admin.Layouts.Content, { children: [
61
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, marginBottom: 6, children: [
62
+ /* @__PURE__ */ jsxRuntime.jsx(
63
+ StatCard,
64
+ {
65
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Stack, { width: "2.4rem", height: "2.4rem" }),
66
+ iconBg: "primary100",
67
+ value: contentTypes.length,
68
+ label: formatMessage({ id: getTranslation("stats.contentTypes") })
69
+ }
70
+ ),
71
+ /* @__PURE__ */ jsxRuntime.jsx(
72
+ StatCard,
73
+ {
74
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Clock, { width: "2.4rem", height: "2.4rem" }),
75
+ iconBg: "success100",
76
+ value: totalRevisions,
77
+ label: formatMessage({ id: getTranslation("stats.totalRevisions") })
78
+ }
79
+ ),
80
+ /* @__PURE__ */ jsxRuntime.jsx(
81
+ StatCard,
82
+ {
83
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Clock, { width: "2.4rem", height: "2.4rem" }),
84
+ iconBg: "warning100",
85
+ value: avgPerType,
86
+ label: formatMessage({ id: getTranslation("stats.avgPerType") })
87
+ }
88
+ )
89
+ ] }),
90
+ contentTypes.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
91
+ designSystem.EmptyStateLayout,
92
+ {
93
+ content: formatMessage({ id: getTranslation("page.home.empty") })
94
+ }
95
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 4, rowCount: contentTypes.length + 1, children: [
96
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
97
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({ id: getTranslation("table.contentType") }) }) }),
98
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({ id: getTranslation("table.uid") }) }) }),
99
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({ id: getTranslation("table.revisions") }) }) }),
100
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: formatMessage({ id: getTranslation("table.actions") }) }) })
101
+ ] }) }),
102
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: contentTypes.map((ct) => /* @__PURE__ */ jsxRuntime.jsxs(
103
+ designSystem.Tr,
104
+ {
105
+ cursor: "pointer",
106
+ onClick: () => navigate(
107
+ `${PLUGIN_ROUTES.entries}?contentType=${encodeURIComponent(ct.uid)}`
108
+ ),
109
+ children: [
110
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", fontWeight: "bold", children: ct.info.displayName }) }),
111
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: ct.uid }) }),
112
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { active: ct.revisionCount > 0, children: ct.revisionCount }) }),
113
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsx(
114
+ designSystem.IconButton,
115
+ {
116
+ label: formatMessage({ id: getTranslation("action.viewEntries") }),
117
+ variant: "ghost",
118
+ onClick: () => navigate(
119
+ `${PLUGIN_ROUTES.entries}?contentType=${encodeURIComponent(ct.uid)}`
120
+ ),
121
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRight, {})
122
+ }
123
+ ) }) })
124
+ ]
125
+ },
126
+ ct.uid
127
+ )) })
128
+ ] })
129
+ ] })
130
+ ] });
131
+ };
132
+ const StatCard = ({
133
+ icon,
134
+ iconBg,
135
+ value,
136
+ label
137
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(
138
+ designSystem.Flex,
139
+ {
140
+ flex: "1",
141
+ shadow: "tableShadow",
142
+ hasRadius: true,
143
+ padding: 6,
144
+ background: "neutral0",
145
+ gap: 4,
146
+ alignItems: "center",
147
+ children: [
148
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { background: iconBg, hasRadius: true, padding: 3, justifyContent: "center", alignItems: "center", children: icon }),
149
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, children: [
150
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", fontWeight: "bold", children: value }),
151
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: label })
152
+ ] })
153
+ ]
154
+ }
155
+ );
156
+ const EntriesPage = () => {
157
+ const navigate = reactRouterDom.useNavigate();
158
+ const { get } = admin.useFetchClient();
159
+ const { formatMessage } = reactIntl.useIntl();
160
+ const params = new URLSearchParams(window.location.search);
161
+ const contentType = params.get("contentType") || "";
162
+ const [data, setData] = react.useState(null);
163
+ const [loading, setLoading] = react.useState(true);
164
+ const [page, setPage] = react.useState(1);
165
+ const fetchEntries = react.useCallback(async () => {
166
+ if (!contentType) return;
167
+ setLoading(true);
168
+ try {
169
+ const { data: result } = await get(API_ROUTES.entries, {
170
+ params: { contentType, page, pageSize: 25 }
171
+ });
172
+ setData(result);
173
+ } catch {
174
+ setData(null);
175
+ } finally {
176
+ setLoading(false);
177
+ }
178
+ }, [get, contentType, page]);
179
+ react.useEffect(() => {
180
+ fetchEntries();
181
+ }, [fetchEntries]);
182
+ if (loading) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
183
+ const displayName = contentType.split(".").pop() || contentType;
184
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
185
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: formatMessage(
186
+ { id: getTranslation("page.entries.title") },
187
+ { contentType: displayName }
188
+ ) }),
189
+ /* @__PURE__ */ jsxRuntime.jsx(
190
+ admin.Layouts.Header,
191
+ {
192
+ title: formatMessage(
193
+ { id: getTranslation("page.entries.title") },
194
+ { contentType: displayName }
195
+ ),
196
+ subtitle: formatMessage(
197
+ { id: getTranslation("page.entries.subtitle") }
198
+ ),
199
+ navigationAction: /* @__PURE__ */ jsxRuntime.jsx(admin.BackButton, { disabled: false, fallback: PLUGIN_ROUTES.home })
200
+ }
201
+ ),
202
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: !data || data.results.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
203
+ designSystem.EmptyStateLayout,
204
+ {
205
+ content: formatMessage({ id: getTranslation("page.entries.empty") })
206
+ }
207
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
208
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 4, rowCount: data.results.length + 1, children: [
209
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
210
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({ id: getTranslation("table.entry") }) }) }),
211
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({ id: getTranslation("table.versions") }) }) }),
212
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({ id: getTranslation("table.lastModified") }) }) }),
213
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: formatMessage({ id: getTranslation("table.actions") }) }) })
214
+ ] }) }),
215
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: data.results.map((entry) => /* @__PURE__ */ jsxRuntime.jsxs(
216
+ designSystem.Tr,
217
+ {
218
+ cursor: "pointer",
219
+ onClick: () => navigate(
220
+ `${PLUGIN_ROUTES.history}?contentType=${encodeURIComponent(contentType)}&documentId=${entry.documentId}`
221
+ ),
222
+ children: [
223
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, children: [
224
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
225
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", fontWeight: "bold", children: entry.entryTitle }),
226
+ !entry.exists && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { variant: "danger", size: "S", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", children: formatMessage({ id: getTranslation("entry.deleted") }) }) })
227
+ ] }),
228
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: entry.documentId })
229
+ ] }) }),
230
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { active: entry.count > 0, children: entry.count }) }),
231
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: new Date(entry.lastModified).toLocaleDateString() }) }),
232
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsx(
233
+ designSystem.IconButton,
234
+ {
235
+ label: formatMessage({ id: getTranslation("action.viewRevisions") }),
236
+ variant: "ghost",
237
+ onClick: () => navigate(
238
+ `${PLUGIN_ROUTES.history}?contentType=${encodeURIComponent(contentType)}&documentId=${entry.documentId}`
239
+ ),
240
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRight, {})
241
+ }
242
+ ) }) })
243
+ ]
244
+ },
245
+ entry.documentId
246
+ )) })
247
+ ] }),
248
+ data.pagination.pageCount > 1 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "center", alignItems: "center", gap: 4, children: [
249
+ /* @__PURE__ */ jsxRuntime.jsx(
250
+ designSystem.Button,
251
+ {
252
+ variant: "tertiary",
253
+ size: "S",
254
+ disabled: page <= 1,
255
+ onClick: () => setPage((p) => Math.max(1, p - 1)),
256
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, {}),
257
+ children: formatMessage({ id: getTranslation("pagination.previous") })
258
+ }
259
+ ),
260
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral600", children: [
261
+ page,
262
+ " / ",
263
+ data.pagination.pageCount
264
+ ] }),
265
+ /* @__PURE__ */ jsxRuntime.jsx(
266
+ designSystem.Button,
267
+ {
268
+ variant: "tertiary",
269
+ size: "S",
270
+ disabled: page >= data.pagination.pageCount,
271
+ onClick: () => setPage((p) => p + 1),
272
+ endIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRight, {}),
273
+ children: formatMessage({ id: getTranslation("pagination.next") })
274
+ }
275
+ )
276
+ ] }) })
277
+ ] }) })
278
+ ] });
279
+ };
280
+ const CHANGE_TYPE_VARIANT = {
281
+ create: "success",
282
+ update: "warning",
283
+ delete: "danger"
284
+ };
285
+ const RevisionHistoryPage = () => {
286
+ const navigate = reactRouterDom.useNavigate();
287
+ const { get, post, del } = admin.useFetchClient();
288
+ const { formatMessage } = reactIntl.useIntl();
289
+ const { toggleNotification } = admin.useNotification();
290
+ const params = new URLSearchParams(window.location.search);
291
+ const contentType = params.get("contentType") || "";
292
+ const documentId = params.get("documentId") || "";
293
+ const [data, setData] = react.useState(null);
294
+ const [loading, setLoading] = react.useState(true);
295
+ const [page, setPage] = react.useState(1);
296
+ const [selected, setSelected] = react.useState(/* @__PURE__ */ new Set());
297
+ const [snapshotModal, setSnapshotModal] = react.useState(null);
298
+ const fetchRevisions = react.useCallback(async () => {
299
+ if (!contentType || !documentId) return;
300
+ setLoading(true);
301
+ try {
302
+ const { data: result } = await get(API_ROUTES.revisions, {
303
+ params: { contentType, documentId, page, pageSize: 25 }
304
+ });
305
+ setData(result);
306
+ } catch {
307
+ setData(null);
308
+ } finally {
309
+ setLoading(false);
310
+ }
311
+ }, [get, contentType, documentId, page]);
312
+ react.useEffect(() => {
313
+ fetchRevisions();
314
+ }, [fetchRevisions]);
315
+ const toggleSelection = (docId) => {
316
+ setSelected((prev) => {
317
+ const next = new Set(prev);
318
+ if (next.has(docId)) {
319
+ next.delete(docId);
320
+ } else {
321
+ if (next.size >= 2) {
322
+ const first = next.values().next().value;
323
+ if (first) next.delete(first);
324
+ }
325
+ next.add(docId);
326
+ }
327
+ return next;
328
+ });
329
+ };
330
+ const handleRestore = async (revisionDocId) => {
331
+ if (!window.confirm(formatMessage({ id: getTranslation("confirm.restore") }))) return;
332
+ try {
333
+ await post(`${API_ROUTES.revisions}/${revisionDocId}/restore`);
334
+ toggleNotification({
335
+ type: "success",
336
+ message: formatMessage({ id: getTranslation("notification.restore.success") })
337
+ });
338
+ await fetchRevisions();
339
+ } catch {
340
+ toggleNotification({
341
+ type: "danger",
342
+ message: formatMessage({ id: getTranslation("notification.restore.error") })
343
+ });
344
+ }
345
+ };
346
+ const handleDelete = async (revisionDocId) => {
347
+ if (!window.confirm(formatMessage({ id: getTranslation("confirm.delete") }))) return;
348
+ try {
349
+ await del(`${API_ROUTES.revisions}/${revisionDocId}`);
350
+ toggleNotification({
351
+ type: "success",
352
+ message: formatMessage({ id: getTranslation("notification.delete.success") })
353
+ });
354
+ setSelected((prev) => {
355
+ const next = new Set(prev);
356
+ next.delete(revisionDocId);
357
+ return next;
358
+ });
359
+ await fetchRevisions();
360
+ } catch {
361
+ toggleNotification({
362
+ type: "danger",
363
+ message: formatMessage({ id: getTranslation("notification.delete.error") })
364
+ });
365
+ }
366
+ };
367
+ const handleCompare = () => {
368
+ if (selected.size !== 2) return;
369
+ const [rev1, rev2] = Array.from(selected);
370
+ navigate(
371
+ `${PLUGIN_ROUTES.compare}?rev1=${rev1}&rev2=${rev2}&contentType=${encodeURIComponent(contentType)}&documentId=${documentId}`
372
+ );
373
+ };
374
+ if (loading) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
375
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
376
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: formatMessage({ id: getTranslation("page.history.title") }) }),
377
+ /* @__PURE__ */ jsxRuntime.jsx(
378
+ admin.Layouts.Header,
379
+ {
380
+ title: formatMessage({ id: getTranslation("page.history.title") }),
381
+ subtitle: formatMessage(
382
+ { id: getTranslation("page.history.subtitle") },
383
+ { count: data?.pagination.total ?? 0 }
384
+ ),
385
+ navigationAction: /* @__PURE__ */ jsxRuntime.jsx(
386
+ admin.BackButton,
387
+ {
388
+ disabled: false,
389
+ fallback: `${PLUGIN_ROUTES.entries}?contentType=${encodeURIComponent(contentType)}`
390
+ }
391
+ ),
392
+ primaryAction: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Button, { disabled: selected.size !== 2, onClick: handleCompare, children: [
393
+ formatMessage({ id: getTranslation("action.compare") }),
394
+ selected.size > 0 && ` (${selected.size}/2)`
395
+ ] })
396
+ }
397
+ ),
398
+ /* @__PURE__ */ jsxRuntime.jsxs(admin.Layouts.Content, { children: [
399
+ !data || data.results.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
400
+ designSystem.EmptyStateLayout,
401
+ {
402
+ content: formatMessage({ id: getTranslation("page.history.empty") })
403
+ }
404
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
405
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 6, rowCount: data.results.length + 1, children: [
406
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
407
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: formatMessage({ id: getTranslation("select.compare.hint") }) }) }),
408
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({ id: getTranslation("table.version") }) }) }),
409
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({ id: getTranslation("table.changeType") }) }) }),
410
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({ id: getTranslation("table.changedBy") }) }) }),
411
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({ id: getTranslation("table.date") }) }) }),
412
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: formatMessage({ id: getTranslation("table.actions") }) }) })
413
+ ] }) }),
414
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: data.results.map((rev, index2) => {
415
+ const isLatest = index2 === 0;
416
+ const isSelected = selected.has(rev.documentId);
417
+ const variant = CHANGE_TYPE_VARIANT[rev.changeType] || "warning";
418
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
419
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
420
+ designSystem.Checkbox,
421
+ {
422
+ checked: isSelected,
423
+ onCheckedChange: () => toggleSelection(rev.documentId)
424
+ }
425
+ ) }),
426
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 2, children: [
427
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { textColor: "neutral800", fontWeight: "bold", children: [
428
+ "v",
429
+ rev.version
430
+ ] }),
431
+ isLatest && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { active: true, children: formatMessage({ id: getTranslation("badge.latest") }) })
432
+ ] }) }),
433
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { variant, size: "S", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({ id: getTranslation(`badge.${rev.changeType}`) }) }) }) }),
434
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: rev.changedByName || rev.changedByEmail || "—" }) }),
435
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: new Date(rev.createdAt).toLocaleString() }) }),
436
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "flex-end", gap: 1, children: [
437
+ /* @__PURE__ */ jsxRuntime.jsx(
438
+ designSystem.IconButton,
439
+ {
440
+ label: formatMessage({ id: getTranslation("action.viewSnapshot") }),
441
+ variant: "ghost",
442
+ onClick: () => setSnapshotModal(rev),
443
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
444
+ }
445
+ ),
446
+ /* @__PURE__ */ jsxRuntime.jsx(
447
+ designSystem.IconButton,
448
+ {
449
+ label: formatMessage({ id: getTranslation("action.restore") }),
450
+ variant: "ghost",
451
+ onClick: () => handleRestore(rev.documentId),
452
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {})
453
+ }
454
+ ),
455
+ /* @__PURE__ */ jsxRuntime.jsx(
456
+ designSystem.IconButton,
457
+ {
458
+ label: formatMessage({ id: getTranslation("action.delete") }),
459
+ variant: "ghost",
460
+ onClick: () => handleDelete(rev.documentId),
461
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
462
+ }
463
+ )
464
+ ] }) })
465
+ ] }, rev.documentId);
466
+ }) })
467
+ ] }),
468
+ data.pagination.pageCount > 1 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "center", alignItems: "center", gap: 4, children: [
469
+ /* @__PURE__ */ jsxRuntime.jsx(
470
+ designSystem.Button,
471
+ {
472
+ variant: "tertiary",
473
+ size: "S",
474
+ disabled: page <= 1,
475
+ onClick: () => setPage((p) => Math.max(1, p - 1)),
476
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, {}),
477
+ children: formatMessage({ id: getTranslation("pagination.previous") })
478
+ }
479
+ ),
480
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral600", children: [
481
+ page,
482
+ " / ",
483
+ data.pagination.pageCount
484
+ ] }),
485
+ /* @__PURE__ */ jsxRuntime.jsx(
486
+ designSystem.Button,
487
+ {
488
+ variant: "tertiary",
489
+ size: "S",
490
+ disabled: page >= data.pagination.pageCount,
491
+ onClick: () => setPage((p) => p + 1),
492
+ endIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRight, {}),
493
+ children: formatMessage({ id: getTranslation("pagination.next") })
494
+ }
495
+ )
496
+ ] }) })
497
+ ] }),
498
+ snapshotModal && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: !!snapshotModal, onOpenChange: () => setSnapshotModal(null), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
499
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Title, { children: [
500
+ "Snapshot — v",
501
+ snapshotModal.version
502
+ ] }) }),
503
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(
504
+ designSystem.Box,
505
+ {
506
+ padding: 4,
507
+ background: "neutral100",
508
+ hasRadius: true,
509
+ style: {
510
+ maxHeight: "60vh",
511
+ overflow: "auto",
512
+ fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',
513
+ fontSize: "13px",
514
+ lineHeight: "1.6",
515
+ whiteSpace: "pre-wrap",
516
+ wordBreak: "break-word"
517
+ },
518
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral800", children: JSON.stringify(snapshotModal.snapshot, null, 2) })
519
+ }
520
+ ) }),
521
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
522
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({ id: getTranslation("action.close") }) }) }),
523
+ /* @__PURE__ */ jsxRuntime.jsx(
524
+ designSystem.Button,
525
+ {
526
+ onClick: () => {
527
+ handleRestore(snapshotModal.documentId);
528
+ setSnapshotModal(null);
529
+ },
530
+ children: formatMessage({ id: getTranslation("action.restore") })
531
+ }
532
+ )
533
+ ] })
534
+ ] }) })
535
+ ] })
536
+ ] });
537
+ };
538
+ const DIFF_VARIANT = {
539
+ added: "success",
540
+ removed: "danger",
541
+ changed: "warning"
542
+ };
543
+ const VALUE_BG_TOKENS = {
544
+ added: { old: "transparent", new: "success100" },
545
+ removed: { old: "danger100", new: "transparent" },
546
+ changed: { old: "warning100", new: "primary100" }
547
+ };
548
+ const ComparePage = () => {
549
+ const { get } = admin.useFetchClient();
550
+ const { formatMessage } = reactIntl.useIntl();
551
+ const params = new URLSearchParams(window.location.search);
552
+ const rev1 = params.get("rev1") || "";
553
+ const rev2 = params.get("rev2") || "";
554
+ const contentType = params.get("contentType") || "";
555
+ const documentId = params.get("documentId") || "";
556
+ const [data, setData] = react.useState(null);
557
+ const [loading, setLoading] = react.useState(true);
558
+ const [error, setError] = react.useState(null);
559
+ react.useEffect(() => {
560
+ if (!rev1 || !rev2) return;
561
+ const fetchComparison = async () => {
562
+ setLoading(true);
563
+ try {
564
+ const { data: result } = await get(API_ROUTES.compare, {
565
+ params: { rev1, rev2 }
566
+ });
567
+ setData(result);
568
+ } catch (err) {
569
+ setError(
570
+ err?.response?.data?.error?.message || err?.message || "Comparison failed"
571
+ );
572
+ } finally {
573
+ setLoading(false);
574
+ }
575
+ };
576
+ fetchComparison();
577
+ }, [get, rev1, rev2]);
578
+ if (loading) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
579
+ if (error) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {});
580
+ const v1 = data?.revision1?.version ?? "?";
581
+ const v2 = data?.revision2?.version ?? "?";
582
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
583
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: formatMessage({ id: getTranslation("page.compare.title") }) }),
584
+ /* @__PURE__ */ jsxRuntime.jsx(
585
+ admin.Layouts.Header,
586
+ {
587
+ title: formatMessage({ id: getTranslation("page.compare.title") }),
588
+ subtitle: formatMessage(
589
+ { id: getTranslation("page.compare.subtitle") },
590
+ { v1, v2 }
591
+ ),
592
+ navigationAction: /* @__PURE__ */ jsxRuntime.jsx(
593
+ admin.BackButton,
594
+ {
595
+ disabled: false,
596
+ fallback: `${PLUGIN_ROUTES.history}?contentType=${encodeURIComponent(contentType)}&documentId=${documentId}`
597
+ }
598
+ )
599
+ }
600
+ ),
601
+ /* @__PURE__ */ jsxRuntime.jsxs(admin.Layouts.Content, { children: [
602
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, marginBottom: 6, children: [
603
+ /* @__PURE__ */ jsxRuntime.jsx(
604
+ RevisionCard,
605
+ {
606
+ label: `v${v1}`,
607
+ name: data?.revision1?.changedByName || data?.revision1?.changedByEmail || "—",
608
+ date: data?.revision1?.createdAt,
609
+ changeType: data?.revision1?.changeType
610
+ }
611
+ ),
612
+ /* @__PURE__ */ jsxRuntime.jsx(
613
+ RevisionCard,
614
+ {
615
+ label: `v${v2}`,
616
+ name: data?.revision2?.changedByName || data?.revision2?.changedByEmail || "—",
617
+ date: data?.revision2?.createdAt,
618
+ changeType: data?.revision2?.changeType
619
+ }
620
+ )
621
+ ] }),
622
+ !data?.diff || data.diff.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
623
+ designSystem.EmptyStateLayout,
624
+ {
625
+ content: formatMessage({ id: getTranslation("page.compare.no-diff") })
626
+ }
627
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 4, rowCount: data.diff.length + 1, children: [
628
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
629
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({ id: getTranslation("table.path") }) }) }),
630
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({ id: getTranslation("table.type") }) }) }),
631
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: [
632
+ formatMessage({ id: getTranslation("table.oldValue") }),
633
+ " (v",
634
+ v1,
635
+ ")"
636
+ ] }) }),
637
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: [
638
+ formatMessage({ id: getTranslation("table.newValue") }),
639
+ " (v",
640
+ v2,
641
+ ")"
642
+ ] }) })
643
+ ] }) }),
644
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: data.diff.map((entry, index2) => {
645
+ const variant = DIFF_VARIANT[entry.type] || "warning";
646
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
647
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", fontWeight: "bold", children: entry.path }) }),
648
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { variant, size: "S", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({ id: getTranslation(`diff.${entry.type}`) }) }) }) }),
649
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: { verticalAlign: "top" }, children: /* @__PURE__ */ jsxRuntime.jsx(ValueCell, { value: entry.oldValue, type: entry.type, side: "old" }) }),
650
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: { verticalAlign: "top" }, children: /* @__PURE__ */ jsxRuntime.jsx(ValueCell, { value: entry.newValue, type: entry.type, side: "new" }) })
651
+ ] }, index2);
652
+ }) })
653
+ ] })
654
+ ] })
655
+ ] });
656
+ };
657
+ const RevisionCard = ({
658
+ label,
659
+ name,
660
+ date,
661
+ changeType
662
+ }) => {
663
+ const { formatMessage } = reactIntl.useIntl();
664
+ const variant = changeType ? DIFF_VARIANT[changeType] || "warning" : "warning";
665
+ return /* @__PURE__ */ jsxRuntime.jsxs(
666
+ designSystem.Flex,
667
+ {
668
+ flex: "1",
669
+ shadow: "tableShadow",
670
+ hasRadius: true,
671
+ padding: 6,
672
+ background: "neutral0",
673
+ direction: "column",
674
+ gap: 3,
675
+ children: [
676
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", children: [
677
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", fontWeight: "bold", children: label }),
678
+ changeType && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { variant, size: "S", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({ id: getTranslation(`badge.${changeType}`) }) }) })
679
+ ] }),
680
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: name }),
681
+ date && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: new Date(date).toLocaleString() })
682
+ ]
683
+ }
684
+ );
685
+ };
686
+ const ValueCell = ({
687
+ value,
688
+ type,
689
+ side
690
+ }) => {
691
+ if (value === void 0) {
692
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral400", children: "—" });
693
+ }
694
+ const tokens = VALUE_BG_TOKENS[type] || VALUE_BG_TOKENS.changed;
695
+ const bgToken = tokens[side] || "transparent";
696
+ const formatted = typeof value === "object" ? JSON.stringify(value, null, 2) : String(value);
697
+ return /* @__PURE__ */ jsxRuntime.jsx(
698
+ designSystem.Box,
699
+ {
700
+ padding: 2,
701
+ hasRadius: true,
702
+ background: bgToken !== "transparent" ? bgToken : void 0,
703
+ style: {
704
+ fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',
705
+ fontSize: "12px",
706
+ lineHeight: "1.5",
707
+ whiteSpace: "pre-wrap",
708
+ wordBreak: "break-word",
709
+ maxHeight: "220px",
710
+ overflow: "auto"
711
+ },
712
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral800", children: formatted })
713
+ }
714
+ );
715
+ };
716
+ const App = () => {
717
+ const theme = styledComponents.useTheme();
718
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.DesignSystemProvider, { theme, children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
719
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { index: true, element: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) }),
720
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "entries", element: /* @__PURE__ */ jsxRuntime.jsx(EntriesPage, {}) }),
721
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "history", element: /* @__PURE__ */ jsxRuntime.jsx(RevisionHistoryPage, {}) }),
722
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "compare", element: /* @__PURE__ */ jsxRuntime.jsx(ComparePage, {}) }),
723
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {}) })
724
+ ] }) });
725
+ };
726
+ exports.App = App;