UNPKG

convex

Version:

Client for the Convex Cloud

64 lines (62 loc) 2.22 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var api_exports = {}; __export(api_exports, { apiCodegen: () => apiCodegen, importPath: () => importPath, moduleIdentifier: () => moduleIdentifier }); module.exports = __toCommonJS(api_exports); var import_common = require("./common.js"); function importPath(modulePath) { const filePath = modulePath.replace("\\", "/"); const lastDot = filePath.lastIndexOf("."); return filePath.slice(0, lastDot === -1 ? void 0 : lastDot); } function moduleIdentifier(modulePath) { return importPath(modulePath).replace("/", "_"); } function apiCodegen(modulePaths) { const reactDTS = `${(0, import_common.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