@oberoncms/core
Version:
OberonCMS is a cloud deployable CMS written in typescript based on the Puck visual editor
52 lines (51 loc) • 1.35 kB
JavaScript
import { redirect } from "next/navigation";
import { ResponseError } from "../lib/dtd.js";
import { getInitialData } from "./get-initial-data.js";
const mockUser = {
id: "test-id",
email: "test@tohuhono.com",
role: "admin"
};
const mockSite = {
version: 1,
components: {},
updatedAt: /* @__PURE__ */ new Date(),
updatedBy: "test@tohuhono.com"
};
const mockPage = getInitialData();
const mockAllPages = [
{
key: mockPage.key,
updatedAt: mockPage.updatedAt,
updatedBy: mockPage.updatedBy
}
];
function notAvailable() {
throw new ResponseError("This action is not available in the demo");
}
const mockPlugin = () => ({
name: "mock-plugin",
adapter: {
addImage: notAvailable,
addPage: notAvailable,
addUser: async () => mockUser,
changeRole: notAvailable,
deleteImage: notAvailable,
deletePage: notAvailable,
deleteUser: notAvailable,
getAllImages: async () => [],
getAllPages: async () => mockAllPages,
getAllUsers: async () => [mockUser],
getCurrentUser: async () => mockUser,
getPageData: async (key) => key === "/" ? mockPage.data : null,
getSite: async () => mockSite,
hasPermission: () => true,
updatePageData: notAvailable,
updateSite: notAvailable,
signIn: notAvailable,
signOut: async () => redirect("/")
}
});
export {
mockPlugin
};