@paroicms/server
Version:
The ParoiCMS server
30 lines • 1.36 kB
JavaScript
import { parseLNodeId } from "@paroicms/public-anywhere-lib";
import { siteReadyGuard } from "../../graphql/graphql.types.js";
import { permissionGuard } from "../auth/authorization.helper.js";
import { getHistoryEntries } from "./history.queries.js";
import { restoreHistoryEntry } from "./history.service.js";
export const historyResolvers = {
Query: {
historyEntries: async (_parent, { lNodeId }, { siteContext, httpContext }) => {
siteReadyGuard(siteContext);
await permissionGuard(siteContext, httpContext, "document.edit");
const { nodeId, language } = parseLNodeId(lNodeId);
const entries = await getHistoryEntries(siteContext, { nodeId, language });
return entries.map((entry) => ({
id: entry.id,
updatedAt: entry.updatedAt,
timeTier: entry.timeTier,
changeSummary: entry.changeSummary ?? null,
}));
},
},
Mutation: {
restoreHistoryEntry: async (_parent, { entryId }, { siteContext, httpContext }) => {
siteReadyGuard(siteContext);
await permissionGuard(siteContext, httpContext, "document.edit");
await restoreHistoryEntry(siteContext, { entryId });
return true;
},
},
};
//# sourceMappingURL=history.resolver.js.map