function toPascal(name: string): string { return name.charAt(0).toUpperCase() + name.slice(1); } export function renderResolverStub(name: string, description: string): string { return `import { createResolver, t } from "@tailor-platform/sdk"; import { createContext } from "@tailor-platform/erp-kit/app"; import { getDB } from "@/generated/kysely-tailordb"; export default createResolver({ name: "${name}", description: ${JSON.stringify(description)}, operation: "mutation", input: { // TODO: define input fields }, body: async (context) => { // oxlint-disable-next-line no-unused-vars -- scaffold: pass ctx to erp-kit commands const ctx = createContext(context); const db = getDB("main-db"); // oxlint-disable-next-line no-unused-vars, typescript/require-await -- scaffold: fill in the transaction body return db.transaction().execute(async (trx) => { // TODO: implement, passing \`trx\` and \`ctx\` to erp-kit commands throw new Error(\`not implemented: ${name}\`); }); }, output: t .object({ // TODO: define output fields }) .description("${toPascal(name)} response"), }); `; } export function renderStoryTestStub(name: string, testCases: string[]): string { const its = testCases .map( (tc) => ` it(${JSON.stringify(tc)}, () => {\n throw new Error(${JSON.stringify(`not implemented: ${tc}`)});\n });`, ) .join("\n\n"); return `import { describe, expect, inject, it } from "vitest"; import { createGraphQLClient } from "@/tests/utils/graphql-client"; describe("${name}", () => { const graphQLClient = createGraphQLClient(inject("url"), inject("token")); ${its} }); `; }