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