'use server'; import { z } from 'zod'; import { AppcondaException } from '../../client'; import { getSDKForCurrentUser } from '../../getSDKForCurrentUser'; import { CreateAppSchema, CreateModuleSchema, CreatePageSchema, CreatePageSchemaSchema, GetAppSchema, GetPageBySlugSchema, GetPageSchemaSchema, ListAppsSchema, ListModulesSchema, ListPagesSchema, UpdateAppSchema, UpdateEditorConfigSchema, UpdatePageSchemaSchema } from './schema'; import { Config } from './types'; import { getSDKForService } from '../../getSDKForService'; export const CreateApp = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const app = await builder.CreateApp(parsedInput); return app; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const UpdateApp = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const app = await builder.UpdateApp(parsedInput); return app; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const UpdateEditorConfig = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const app = await builder.UpdateEditorConfig(parsedInput); return app; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const GetEditorConfig = async () => { try { const { builder } = await getSDKForService(); //@ts-ignore const config = await builder.GetEditorConfig(); return config; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const GetApp = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const app = await builder.GetApp(parsedInput); return app; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const ListApps = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const apps = await builder.ListApps(parsedInput); return apps; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const ListBuilderProjects = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const apps = await builder.ListProjects(parsedInput); return apps; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const CreatePage = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const page = await builder.CreatePage(parsedInput); return page; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const ListPages = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const pages = await builder.ListPages(parsedInput); return pages; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const CreatePageSchemaAction = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const pageSchema = await builder.CreatePageSchema(parsedInput); return pageSchema; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const UpdatePageSchema = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const pageSchema = await builder.UpdatePageSchema(parsedInput); return pageSchema; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const GetPageSchema = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const pageSchema = await builder.GetPageSchema(parsedInput); return pageSchema; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const ListModules = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const modules = await builder.ListModules(parsedInput); return modules; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const CreateModule = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const module = await builder.CreateModule(parsedInput); return module; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } }; export const GetPageBySlug = async (parsedInput: z.infer) => { try { const { builder } = await getSDKForService(); //@ts-ignore const page = await builder.GetPageBySlug(parsedInput); return page; } catch (error) { if (error instanceof AppcondaException) { throw new Error(error.message); } throw error; } };