UNPKG

convex

Version:

Client for the Convex Cloud

40 lines (38 loc) 1.23 kB
"use strict"; import { header } from "./common.js"; export function importPath(modulePath) { const filePath = modulePath.replace("\\", "/"); const lastDot = filePath.lastIndexOf("."); return filePath.slice(0, lastDot === -1 ? void 0 : lastDot); } export function moduleIdentifier(modulePath) { return importPath(modulePath).replace("/", "_"); } export function apiCodegen(modulePaths) { const reactDTS = `${header("Generated API.")} import type { ApiFromModules } from "convex/api"; ${modulePaths.map( (modulePath) => `import type * as ${moduleIdentifier(modulePath)} from "../${importPath( modulePath )}";` ).join("\n")} /** * A type describing your app's public Convex API. * * This \`API\` type includes information about the arguments and return * types of your app's query and mutation functions. * * This type should be used with type-parameterized classes like * \`ConvexReactClient\` to create app-specific types. */ export type API = ApiFromModules<{ ${modulePaths.map( (modulePath) => `"${importPath(modulePath)}": typeof ${moduleIdentifier(modulePath)},` ).join("\n")} }>; `; return { DTS: reactDTS }; } //# sourceMappingURL=api.js.map