convex 1.42.2-alpha.0 → 1.42.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/browser.bundle.js +1 -1
- package/dist/browser.bundle.js.map +1 -1
- package/dist/cjs/cli/codegen_templates/common.js +6 -0
- package/dist/cjs/cli/codegen_templates/common.js.map +2 -2
- package/dist/cjs/cli/lib/codegen.js +2 -1
- package/dist/cjs/cli/lib/codegen.js.map +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/server/meta.js.map +1 -1
- package/dist/cjs-types/cli/codegen_templates/common.d.ts +12 -0
- package/dist/cjs-types/cli/codegen_templates/common.d.ts.map +1 -1
- package/dist/cjs-types/cli/codegen_templates/common.test.d.ts +2 -0
- package/dist/cjs-types/cli/codegen_templates/common.test.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/codegen.d.ts.map +1 -1
- package/dist/cjs-types/index.d.ts +1 -1
- package/dist/cjs-types/index.d.ts.map +1 -1
- package/dist/cjs-types/server/meta.d.ts +8 -0
- package/dist/cjs-types/server/meta.d.ts.map +1 -1
- package/dist/cli.bundle.cjs +7 -2
- package/dist/cli.bundle.cjs.map +2 -2
- package/dist/esm/cli/codegen_templates/common.js +5 -0
- package/dist/esm/cli/codegen_templates/common.js.map +2 -2
- package/dist/esm/cli/lib/codegen.js +2 -1
- package/dist/esm/cli/lib/codegen.js.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm-types/cli/codegen_templates/common.d.ts +12 -0
- package/dist/esm-types/cli/codegen_templates/common.d.ts.map +1 -1
- package/dist/esm-types/cli/codegen_templates/common.test.d.ts +2 -0
- package/dist/esm-types/cli/codegen_templates/common.test.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/codegen.d.ts.map +1 -1
- package/dist/esm-types/index.d.ts +1 -1
- package/dist/esm-types/index.d.ts.map +1 -1
- package/dist/esm-types/server/meta.d.ts +8 -0
- package/dist/esm-types/server/meta.d.ts.map +1 -1
- package/dist/react.bundle.js +1 -1
- package/dist/react.bundle.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/codegen_templates/common.test.ts +52 -0
- package/src/cli/codegen_templates/common.ts +17 -0
- package/src/cli/lib/codegen.ts +2 -1
- package/src/index.ts +1 -1
- package/src/server/meta.ts +0 -2
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var common_exports = {};
|
|
20
20
|
__export(common_exports, {
|
|
21
21
|
apiComment: () => apiComment,
|
|
22
|
+
compareModulePaths: () => compareModulePaths,
|
|
22
23
|
compareStrings: () => compareStrings,
|
|
23
24
|
header: () => header
|
|
24
25
|
});
|
|
@@ -56,4 +57,9 @@ const collator = new Intl.Collator("en-US", {
|
|
|
56
57
|
function compareStrings(a, b) {
|
|
57
58
|
return collator.compare(a, b);
|
|
58
59
|
}
|
|
60
|
+
function compareModulePaths(a, b) {
|
|
61
|
+
const aNormalized = a.replace(/\\/g, "/");
|
|
62
|
+
const bNormalized = b.replace(/\\/g, "/");
|
|
63
|
+
return aNormalized < bNormalized ? -1 : aNormalized > bNormalized ? 1 : 0;
|
|
64
|
+
}
|
|
59
65
|
//# sourceMappingURL=common.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cli/codegen_templates/common.ts"],
|
|
4
|
-
"sourcesContent": ["export function header(oneLineDescription: string) {\n return `/* eslint-disable */\n /**\n * ${oneLineDescription}\n *\n * THIS CODE IS AUTOMATICALLY GENERATED.\n *\n * To regenerate, run \\`npx convex dev\\`.\n * @module\n */\n `;\n}\n\nexport function apiComment(\n apiName: string,\n type: \"public\" | \"internal\" | undefined,\n) {\n return `\n /**\n * A utility for referencing Convex functions in your app's${type ? ` ${type}` : \"\"} API.\n *\n * Usage:\n * \\`\\`\\`js\n * const myFunctionReference = ${apiName}.myModule.myFunction;\n * \\`\\`\\`\n */`;\n}\n\nconst collator = new Intl.Collator(\"en-US\", {\n usage: \"sort\",\n numeric: true,\n sensitivity: \"case\",\n ignorePunctuation: false,\n caseFirst: \"false\",\n});\n\n/**\n * Comparison function for sorting strings alphabetically.\n *\n * Usage: array.sort(compareStrings)\n * or with entries: Object.entries(obj).sort(([a], [b]) => compareStrings(a, b))\n */\nexport function compareStrings(a: string, b: string): number {\n return collator.compare(a, b);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,OAAO,oBAA4B;AACjD,SAAO;AAAA;AAAA,OAEF,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQzB;AAEO,SAAS,WACd,SACA,MACA;AACA,SAAO;AAAA;AAAA,iEAEwD,OAAO,IAAI,IAAI,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA,qCAIlD,OAAO;AAAA;AAAA;AAG5C;AAEA,MAAM,WAAW,IAAI,KAAK,SAAS,SAAS;AAAA,EAC1C,OAAO;AAAA,EACP,SAAS;AAAA,EACT,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,WAAW;AACb,CAAC;AAQM,SAAS,eAAe,GAAW,GAAmB;AAC3D,SAAO,SAAS,QAAQ,GAAG,CAAC;AAC9B;",
|
|
4
|
+
"sourcesContent": ["export function header(oneLineDescription: string) {\n return `/* eslint-disable */\n /**\n * ${oneLineDescription}\n *\n * THIS CODE IS AUTOMATICALLY GENERATED.\n *\n * To regenerate, run \\`npx convex dev\\`.\n * @module\n */\n `;\n}\n\nexport function apiComment(\n apiName: string,\n type: \"public\" | \"internal\" | undefined,\n) {\n return `\n /**\n * A utility for referencing Convex functions in your app's${type ? ` ${type}` : \"\"} API.\n *\n * Usage:\n * \\`\\`\\`js\n * const myFunctionReference = ${apiName}.myModule.myFunction;\n * \\`\\`\\`\n */`;\n}\n\nconst collator = new Intl.Collator(\"en-US\", {\n usage: \"sort\",\n numeric: true,\n sensitivity: \"case\",\n ignorePunctuation: false,\n caseFirst: \"false\",\n});\n\n/**\n * Comparison function for sorting strings alphabetically.\n *\n * Usage: array.sort(compareStrings)\n * or with entries: Object.entries(obj).sort(([a], [b]) => compareStrings(a, b))\n */\nexport function compareStrings(a: string, b: string): number {\n return collator.compare(a, b);\n}\n\n/**\n * Comparison function for sorting module paths in codegen output.\n *\n * Compares the forward slash normalized form of each path so the resulting\n * order is identical on every platform. Sorting OS-native paths directly\n * diverges on Windows because \"\\\" (0x5C) sorts after letters while \"/\"\n * (0x2F) sorts before them. Uses plain code unit comparison to match the\n * default Array.prototype.sort() order these paths sorted with on POSIX.\n *\n * Usage: modulePaths.sort(compareModulePaths)\n */\nexport function compareModulePaths(a: string, b: string): number {\n const aNormalized = a.replace(/\\\\/g, \"/\");\n const bNormalized = b.replace(/\\\\/g, \"/\");\n return aNormalized < bNormalized ? -1 : aNormalized > bNormalized ? 1 : 0;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,OAAO,oBAA4B;AACjD,SAAO;AAAA;AAAA,OAEF,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQzB;AAEO,SAAS,WACd,SACA,MACA;AACA,SAAO;AAAA;AAAA,iEAEwD,OAAO,IAAI,IAAI,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA,qCAIlD,OAAO;AAAA;AAAA;AAG5C;AAEA,MAAM,WAAW,IAAI,KAAK,SAAS,SAAS;AAAA,EAC1C,OAAO;AAAA,EACP,SAAS;AAAA,EACT,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,WAAW;AACb,CAAC;AAQM,SAAS,eAAe,GAAW,GAAmB;AAC3D,SAAO,SAAS,QAAQ,GAAG,CAAC;AAC9B;AAaO,SAAS,mBAAmB,GAAW,GAAmB;AAC/D,QAAM,cAAc,EAAE,QAAQ,OAAO,GAAG;AACxC,QAAM,cAAc,EAAE,QAAQ,OAAO,GAAG;AACxC,SAAO,cAAc,cAAc,KAAK,cAAc,cAAc,IAAI;AAC1E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -42,6 +42,7 @@ var import_fs = require("../../bundler/fs.js");
|
|
|
42
42
|
var import_bundler = require("../../bundler/index.js");
|
|
43
43
|
var import_api = require("../codegen_templates/api.js");
|
|
44
44
|
var import_api_cjs = require("../codegen_templates/api_cjs.js");
|
|
45
|
+
var import_common = require("../codegen_templates/common.js");
|
|
45
46
|
var import_dataModel = require("../codegen_templates/dataModel.js");
|
|
46
47
|
var import_readme = require("../codegen_templates/readme.js");
|
|
47
48
|
var import_server = require("../codegen_templates/server.js");
|
|
@@ -564,7 +565,7 @@ async function doInitialComponentApiCodegen(ctx, isRoot, tmpDir, codegenDir, use
|
|
|
564
565
|
}
|
|
565
566
|
async function doApiCodegen(ctx, tmpDir, functionsDir2, codegenDir, useTypeScript, generateCommonJSApi, opts) {
|
|
566
567
|
const absModulePaths = await (0, import_bundler.entryPoints)(ctx, functionsDir2);
|
|
567
|
-
const modulePaths = absModulePaths.map((p) => import_path.default.relative(functionsDir2, p)).sort();
|
|
568
|
+
const modulePaths = absModulePaths.map((p) => import_path.default.relative(functionsDir2, p)).sort(import_common.compareModulePaths);
|
|
568
569
|
const writtenFiles = [];
|
|
569
570
|
if (!useTypeScript) {
|
|
570
571
|
const apiContent = (0, import_api.apiCodegen)(modulePaths, { useTypeScript: false });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cli/lib/codegen.ts"],
|
|
4
|
-
"sourcesContent": ["import path from \"path\";\nimport prettier from \"prettier\";\nimport { withTmpDir, TempDir } from \"../../bundler/fs.js\";\nimport { entryPoints } from \"../../bundler/index.js\";\nimport { apiCodegen } from \"../codegen_templates/api.js\";\nimport { apiCjsCodegen } from \"../codegen_templates/api_cjs.js\";\nimport {\n dynamicDataModelDTS,\n dynamicDataModelTS,\n noSchemaDataModelDTS,\n noSchemaDataModelTS,\n staticDataModelDTS,\n staticDataModelTS,\n} from \"../codegen_templates/dataModel.js\";\nimport { readmeCodegen } from \"../codegen_templates/readme.js\";\nimport { serverCodegen, EnvVarMeta } from \"../codegen_templates/server.js\";\nimport { tsconfigCodegen } from \"../codegen_templates/tsconfig.js\";\nimport { Context } from \"../../bundler/context.js\";\nimport {\n logError,\n logMessage,\n logOutput,\n logVerbose,\n} from \"../../bundler/log.js\";\nimport { typeCheckFunctionsInMode, TypeCheckMode } from \"./typecheck.js\";\nimport {\n readProjectConfig,\n usesTypeScriptCodegen,\n usesComponentApiImports,\n} from \"./config.js\";\nimport { recursivelyDelete } from \"./fsUtils.js\";\nimport { componentServerTS } from \"../codegen_templates/component_server.js\";\nimport {\n ComponentDirectory,\n toComponentDefinitionPath,\n} from \"./components/definition/directoryStructure.js\";\nimport { StartPushResponse } from \"./deployApi/startPush.js\";\nimport {\n componentApiDTS,\n componentApiJs,\n componentApiStubDTS,\n componentApiStubTS,\n componentApiTSWithTypes,\n componentTS,\n rootComponentApiCJS,\n} from \"../codegen_templates/component_api.js\";\nimport { functionsDir } from \"./utils/utils.js\";\nimport { LargeIndexDeletionCheck } from \"./indexes.js\";\n\nconst PRESERVED_GENERATED_ENTRIES = new Set([\"ai\"]);\n\nexport function cleanupStaleGeneratedEntries(\n ctx: Context,\n codegenDir: string,\n writtenFiles: string[],\n opts?: { debug?: boolean; force?: boolean; dryRun?: boolean },\n) {\n // Skip cleanup in debug mode since we don't actually write files in that mode.\n if (opts?.debug) {\n return;\n }\n for (const file of ctx.fs.listDir(codegenDir)) {\n if (PRESERVED_GENERATED_ENTRIES.has(file.name)) {\n continue;\n }\n if (!writtenFiles.includes(file.name)) {\n recursivelyDelete(ctx, path.join(codegenDir, file.name), opts);\n }\n }\n}\n\nexport type CodegenOptions = {\n url?: string | undefined;\n adminKey?: string | undefined;\n dryRun: boolean;\n debug: boolean;\n typecheck: TypeCheckMode;\n init: boolean;\n commonjs: boolean;\n liveComponentSources: boolean;\n debugNodeApis: boolean;\n systemUdfs: boolean;\n largeIndexDeletionCheck: LargeIndexDeletionCheck;\n codegenOnlyThisComponent?: string | undefined;\n};\n\nexport async function doInitConvexFolder(\n ctx: Context,\n functionsFolder?: string,\n opts?: {\n dryRun?: boolean;\n debug?: boolean;\n },\n) {\n const skipIfExists = true;\n let folder: string;\n if (functionsFolder) {\n folder = functionsFolder;\n } else {\n const { projectConfig, configPath } = await readProjectConfig(ctx);\n folder = functionsDir(configPath, projectConfig);\n }\n const { functionsDirExistedBeforeCodegen } = await prepareForCodegen(\n ctx,\n folder,\n opts,\n );\n await withTmpDir(async (tmpDir) => {\n await doReadmeCodegen(\n ctx,\n tmpDir,\n folder,\n skipIfExists && functionsDirExistedBeforeCodegen,\n opts,\n );\n await doTsconfigCodegen(ctx, tmpDir, folder, skipIfExists, opts);\n });\n}\n\nasync function prepareForCodegen(\n ctx: Context,\n functionsDir: string,\n opts?: { dryRun?: boolean },\n) {\n const functionsDirExistedBeforeCodegen = ctx.fs.exists(functionsDir);\n // Delete the old _generated.ts because v0.1.2 used to put the react generated\n // code there\n const legacyCodegenPath = path.join(functionsDir, \"_generated.ts\");\n if (ctx.fs.exists(legacyCodegenPath)) {\n if (opts?.dryRun) {\n logError(\n `Command would delete legacy codegen file: ${legacyCodegenPath}}`,\n );\n } else {\n logError(`Deleting legacy codegen file: ${legacyCodegenPath}}`);\n ctx.fs.unlink(legacyCodegenPath);\n }\n }\n\n // Create the codegen dir if it doesn't already exist.\n const codegenDir = path.join(functionsDir, \"_generated\");\n ctx.fs.mkdir(codegenDir, { allowExisting: true, recursive: true });\n return { codegenDir, functionsDirExistedBeforeCodegen };\n}\n\n/** Codegen only for an application (a root component) */\nexport async function doCodegen(\n ctx: Context,\n functionsDir: string,\n typeCheckMode: TypeCheckMode,\n opts?: { dryRun?: boolean; generateCommonJSApi?: boolean; debug?: boolean },\n) {\n const { projectConfig } = await readProjectConfig(ctx);\n const { codegenDir } = await prepareForCodegen(ctx, functionsDir, opts);\n\n await withTmpDir(async (tmpDir) => {\n // Write files in dependency order so a watching dev server doesn't\n // see inconsistent results where a file we write imports from a\n // file that doesn't exist yet. We'll collect all the paths we write\n // and then delete any remaining paths at the end.\n const writtenFiles = [];\n\n const useTypeScript = usesTypeScriptCodegen(projectConfig);\n const generateCommonJSApi =\n opts?.generateCommonJSApi || projectConfig.generateCommonJSApi;\n\n // First, `dataModel.d.ts` imports from the developer's `schema.js` file.\n const schemaFiles = await doDataModelCodegen(\n ctx,\n tmpDir,\n functionsDir,\n codegenDir,\n useTypeScript,\n opts,\n );\n writtenFiles.push(...schemaFiles);\n\n // Next, the `server.d.ts` file imports from `dataModel.d.ts`.\n const serverFiles = await writeServerFiles(\n ctx,\n tmpDir,\n codegenDir,\n useTypeScript,\n undefined,\n opts,\n );\n writtenFiles.push(...serverFiles);\n\n // The `api.d.ts` file imports from the developer's modules, which then\n // import from `server.d.ts`. Note that there's a cycle here, since the\n // developer's modules could also import from the `api.{js,d.ts}` files.\n const apiFiles = await doApiCodegen(\n ctx,\n tmpDir,\n functionsDir,\n codegenDir,\n useTypeScript,\n generateCommonJSApi,\n opts,\n );\n writtenFiles.push(...apiFiles);\n\n // Cleanup any files that weren't written in this run.\n cleanupStaleGeneratedEntries(ctx, codegenDir, writtenFiles, opts);\n\n // Generated code is updated, typecheck the query and mutation functions.\n await typeCheckFunctionsInMode(ctx, typeCheckMode, functionsDir);\n });\n}\n\n// Just enough to be able to bundle code for analysis: we need an api proxy object\n// so that imports aren't broken, we need basics in server, we need something in\n// data model.\nexport async function doInitialComponentCodegen(\n ctx: Context,\n tmpDir: TempDir,\n componentDirectory: ComponentDirectory,\n opts?: {\n dryRun?: boolean;\n generateCommonJSApi?: boolean;\n debug?: boolean;\n verbose?: boolean;\n },\n) {\n const { projectConfig } = await readProjectConfig(ctx);\n\n if (isPublishedPackage(componentDirectory)) {\n if (opts?.verbose) {\n logMessage(\n `skipping initial codegen for installed package ${componentDirectory.path}`,\n );\n }\n return;\n }\n\n const { codegenDir } = await prepareForCodegen(\n ctx,\n componentDirectory.path,\n opts,\n );\n\n // Write files in dependency order so a watching dev server doesn't\n // see inconsistent results where a file we write imports from a\n // file that doesn't exist yet. We'll collect all the paths we write\n // and then delete any remaining paths at the end.\n const writtenFiles = [];\n\n // Non-root components always use .ts files; root components respect the config\n // But for initial (placeholder, stub) codegen we don't care, just use .d.ts and .js.\n const useTypeScript =\n !componentDirectory.isRoot || usesTypeScriptCodegen(projectConfig);\n\n const generateCommonJSApi =\n opts?.generateCommonJSApi || projectConfig.generateCommonJSApi;\n\n // First, `dataModel.d.ts` imports from the developer's `schema.js` file.\n const dataModelFiles = await doInitialComponentDataModelCodegen(\n ctx,\n tmpDir,\n componentDirectory,\n codegenDir,\n useTypeScript,\n opts,\n );\n writtenFiles.push(...dataModelFiles);\n\n // Next, the `server.d.ts` file imports from `dataModel.d.ts`.\n const serverFiles = await doInitialComponentServerCodegen(\n ctx,\n componentDirectory.isRoot,\n tmpDir,\n codegenDir,\n useTypeScript,\n undefined,\n opts,\n );\n writtenFiles.push(...serverFiles);\n\n // The `api.d.ts` file imports from the developer's modules, which then\n // import from `server.d.ts`. Note that there's a cycle here, since the\n // developer's modules could also import from the `api.{js,d.ts}` files.\n const apiFiles = await doInitialComponentApiCodegen(\n ctx,\n componentDirectory.isRoot,\n tmpDir,\n codegenDir,\n useTypeScript,\n generateCommonJSApi,\n opts,\n );\n writtenFiles.push(...apiFiles);\n\n // component.ts is generated in doFinalComponentCodegen, but don't delete\n // if it already exists from a previous full codegen run.\n if (!componentDirectory.isRoot) {\n const componentTSPath = path.join(codegenDir, \"component.ts\");\n if (ctx.fs.exists(componentTSPath)) {\n writtenFiles.push(\"component.ts\");\n }\n }\n\n // Cleanup any files that weren't written in this run.\n cleanupStaleGeneratedEntries(ctx, codegenDir, writtenFiles, opts);\n}\n\n/* This component defined in a dist directory; it is probably in a node_module\n * directory, installed from a package. It is stuck with the files it has.\n * Heuristics for this:\n * - component definition has a dist/ directory as an ancestor\n * - component definition is a .js file\n * - presence of .js.map files\n * We may improve this heuristic.\n */\nexport function isPublishedPackage(componentDirectory: ComponentDirectory) {\n return (\n componentDirectory.definitionPath.endsWith(\".js\") &&\n !componentDirectory.isRoot\n );\n}\n\n// Handles root and non-root components; it's \"component\" codegen because\n// it's not the old legacy path.\nexport async function doFinalComponentCodegen(\n ctx: Context,\n tmpDir: TempDir,\n rootComponent: ComponentDirectory,\n componentDirectory: ComponentDirectory,\n startPushResponse: StartPushResponse,\n componentsMap: Map<string, ComponentDirectory>,\n opts?: {\n dryRun?: boolean;\n debug?: boolean;\n generateCommonJSApi?: boolean;\n },\n) {\n const { projectConfig } = await readProjectConfig(ctx);\n\n const isPublishedPackage =\n componentDirectory.definitionPath.endsWith(\".js\") &&\n !componentDirectory.isRoot;\n // We never codegen for a published package (you need to link to the convex.config.ts file instead).\n if (isPublishedPackage) {\n return;\n }\n\n const codegenDir = path.join(componentDirectory.path, \"_generated\");\n ctx.fs.mkdir(codegenDir, { allowExisting: true, recursive: true });\n\n // Non-root components always use .ts files; root components respect the config\n const useTypeScript =\n !componentDirectory.isRoot || usesTypeScriptCodegen(projectConfig);\n\n // `dataModel` and `api` files depend on analyze results so will get replaced\n // in the later post-analysis codegen phase, but `server` files don't need\n // analysis info so the stubs from initial codegen are sufficient.\n\n // dataModel\n const hasSchemaFile = schemaFileExists(ctx, componentDirectory.path);\n let dataModelContents: string;\n if (hasSchemaFile) {\n if (projectConfig.codegen.staticDataModel) {\n dataModelContents = useTypeScript\n ? await staticDataModelTS(\n ctx,\n startPushResponse,\n rootComponent,\n componentDirectory,\n )\n : await staticDataModelDTS(\n ctx,\n startPushResponse,\n rootComponent,\n componentDirectory,\n );\n } else {\n dataModelContents = useTypeScript\n ? dynamicDataModelTS()\n : dynamicDataModelDTS();\n }\n } else {\n dataModelContents = useTypeScript\n ? noSchemaDataModelTS()\n : noSchemaDataModelDTS();\n }\n const dataModelPath = path.join(\n codegenDir,\n useTypeScript ? \"dataModel.ts\" : \"dataModel.d.ts\",\n );\n await writeFormattedFile(\n ctx,\n tmpDir,\n dataModelContents,\n \"typescript\",\n dataModelPath,\n opts,\n );\n\n // component.ts\n if (!componentDirectory.isRoot) {\n const componentTSPath = path.join(codegenDir, \"component.ts\");\n const componentTSContents = await componentTS(\n ctx,\n startPushResponse,\n rootComponent,\n componentDirectory,\n );\n await writeFormattedFile(\n ctx,\n tmpDir,\n componentTSContents,\n \"typescript\",\n componentTSPath,\n opts,\n );\n }\n\n // server.ts - regenerate it in final codegen so we can emit typed env vars.\n const definitionPath = toComponentDefinitionPath(\n rootComponent,\n componentDirectory,\n );\n const analysis = startPushResponse.analysis[definitionPath];\n const envVars: EnvVarMeta[] =\n analysis?.definition.envVars && analysis.definition.envVars.length > 0\n ? analysis.definition.envVars\n : [];\n await writeServerFilesForComponent(\n ctx,\n componentDirectory.isRoot,\n tmpDir,\n codegenDir,\n useTypeScript,\n envVars,\n opts,\n );\n\n // api\n if (!useTypeScript) {\n const apiDTSPath = path.join(codegenDir, \"api.d.ts\");\n const apiContents = await componentApiDTS(\n ctx,\n startPushResponse,\n rootComponent,\n componentDirectory,\n componentsMap,\n {\n staticApi: projectConfig.codegen.staticApi,\n useComponentApiImports: usesComponentApiImports(projectConfig),\n },\n );\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiContents,\n \"typescript\",\n apiDTSPath,\n opts,\n );\n\n if (opts?.generateCommonJSApi || projectConfig.generateCommonJSApi) {\n const apiCjsDTSPath = path.join(codegenDir, \"api_cjs.d.cts\");\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiContents,\n \"typescript\",\n apiCjsDTSPath,\n opts,\n );\n }\n } else {\n const apiTSPath = path.join(codegenDir, \"api.ts\");\n const apiContents = await componentApiTSWithTypes(\n ctx,\n startPushResponse,\n rootComponent,\n componentDirectory,\n componentsMap,\n {\n staticApi: projectConfig.codegen.staticApi,\n useComponentApiImports: usesComponentApiImports(projectConfig),\n },\n );\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiContents,\n \"typescript\",\n apiTSPath,\n opts,\n );\n }\n}\n\nasync function doReadmeCodegen(\n ctx: Context,\n tmpDir: TempDir,\n functionsDir: string,\n skip: boolean,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n const readmePath = path.join(functionsDir, \"README.md\");\n if (skip) {\n logVerbose(`Not overwriting README.md.`);\n return;\n }\n await writeFormattedFile(\n ctx,\n tmpDir,\n readmeCodegen(),\n \"markdown\",\n readmePath,\n opts,\n );\n}\n\nasync function doTsconfigCodegen(\n ctx: Context,\n tmpDir: TempDir,\n functionsDir: string,\n skipIfExists: boolean,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n const tsconfigPath = path.join(functionsDir, \"tsconfig.json\");\n if (skipIfExists && ctx.fs.exists(tsconfigPath)) {\n logVerbose(`Not overwriting tsconfig.json.`);\n return;\n }\n await writeFormattedFile(\n ctx,\n tmpDir,\n tsconfigCodegen(),\n \"json\",\n tsconfigPath,\n opts,\n );\n}\n\nfunction schemaFileExists(ctx: Context, functionsDir: string) {\n let schemaPath = path.join(functionsDir, \"schema.ts\");\n let hasSchemaFile = ctx.fs.exists(schemaPath);\n if (!hasSchemaFile) {\n schemaPath = path.join(functionsDir, \"schema.js\");\n hasSchemaFile = ctx.fs.exists(schemaPath);\n }\n return hasSchemaFile;\n}\n\nasync function doDataModelCodegen(\n ctx: Context,\n tmpDir: TempDir,\n functionsDir: string,\n codegenDir: string,\n useTypeScript: boolean,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n const hasSchemaFile = schemaFileExists(ctx, functionsDir);\n const schemaContent = hasSchemaFile\n ? useTypeScript\n ? dynamicDataModelTS()\n : dynamicDataModelDTS()\n : useTypeScript\n ? noSchemaDataModelTS()\n : noSchemaDataModelDTS();\n\n const filename = useTypeScript ? \"dataModel.ts\" : \"dataModel.d.ts\";\n await writeFormattedFile(\n ctx,\n tmpDir,\n schemaContent,\n \"typescript\",\n path.join(codegenDir, filename),\n opts,\n );\n return [filename];\n}\n\n/**\n * Write server.ts/.js/.d.ts files for root components.\n * Returns list of filenames written.\n */\nasync function writeServerFiles(\n ctx: Context,\n tmpDir: TempDir,\n codegenDir: string,\n useTypeScript: boolean,\n envVars: EnvVarMeta[] | undefined,\n opts?: { dryRun?: boolean; debug?: boolean },\n): Promise<string[]> {\n if (!useTypeScript) {\n const serverContent = serverCodegen({\n useTypeScript: false,\n envVars,\n });\n await writeFormattedFile(\n ctx,\n tmpDir,\n serverContent.JS!,\n \"typescript\",\n path.join(codegenDir, \"server.js\"),\n opts,\n );\n\n await writeFormattedFile(\n ctx,\n tmpDir,\n serverContent.DTS!,\n \"typescript\",\n path.join(codegenDir, \"server.d.ts\"),\n opts,\n );\n\n return [\"server.js\", \"server.d.ts\"];\n } else {\n const serverContent = serverCodegen({\n useTypeScript: true,\n envVars,\n });\n await writeFormattedFile(\n ctx,\n tmpDir,\n serverContent.TS!,\n \"typescript\",\n path.join(codegenDir, \"server.ts\"),\n opts,\n );\n\n return [\"server.ts\"];\n }\n}\n\n/**\n * Write server.ts file for non-root components.\n * Returns list of filenames written.\n */\nasync function writeComponentServerFile(\n ctx: Context,\n tmpDir: TempDir,\n codegenDir: string,\n envVars: EnvVarMeta[] | undefined,\n opts?: { dryRun?: boolean; debug?: boolean },\n): Promise<string[]> {\n const serverTSPath = path.join(codegenDir, \"server.ts\");\n const serverTSContents = componentServerTS(false, envVars);\n await writeFormattedFile(\n ctx,\n tmpDir,\n serverTSContents,\n \"typescript\",\n serverTSPath,\n opts,\n );\n return [\"server.ts\"];\n}\n\n/**\n * Write server files for either root or non-root components.\n * Root components get server.ts/server.js/server.d.ts based on useTypeScript.\n * Non-root components always get server.ts.\n * Returns list of filenames written.\n */\nasync function writeServerFilesForComponent(\n ctx: Context,\n isRoot: boolean,\n tmpDir: TempDir,\n codegenDir: string,\n useTypeScript: boolean,\n envVars: EnvVarMeta[] | undefined,\n opts?: { dryRun?: boolean; debug?: boolean },\n): Promise<string[]> {\n if (isRoot) {\n return await writeServerFiles(\n ctx,\n tmpDir,\n codegenDir,\n useTypeScript,\n envVars,\n opts,\n );\n } else {\n return await writeComponentServerFile(\n ctx,\n tmpDir,\n codegenDir,\n envVars,\n opts,\n );\n }\n}\n\nasync function doInitialComponentServerCodegen(\n ctx: Context,\n isRoot: boolean,\n tmpDir: TempDir,\n codegenDir: string,\n useTypeScript: boolean,\n envVars: EnvVarMeta[] | undefined,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n // Don't write our stub if the file already exists, since it may have\n // better type information from `doFinalComponentCodegen` (e.g. env vars).\n const serverFilename = useTypeScript ? \"server.ts\" : \"server.js\";\n if (ctx.fs.exists(path.join(codegenDir, serverFilename))) {\n const filenames = [serverFilename];\n if (!useTypeScript) {\n filenames.push(\"server.d.ts\");\n }\n return filenames;\n }\n return await writeServerFilesForComponent(\n ctx,\n isRoot,\n tmpDir,\n codegenDir,\n useTypeScript,\n envVars,\n opts,\n );\n}\n\nasync function doInitialComponentDataModelCodegen(\n ctx: Context,\n tmpDir: TempDir,\n componentDirectory: ComponentDirectory,\n codegenDir: string,\n useTypeScript: boolean,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n const hasSchemaFile = schemaFileExists(ctx, componentDirectory.path);\n const dataModelContent = hasSchemaFile\n ? useTypeScript\n ? dynamicDataModelTS()\n : dynamicDataModelDTS()\n : useTypeScript\n ? noSchemaDataModelTS()\n : noSchemaDataModelDTS();\n const filename = useTypeScript ? \"dataModel.ts\" : \"dataModel.d.ts\";\n const dataModelPath = path.join(codegenDir, filename);\n\n // Don't write our stub if the file already exists, since it may have\n // better type information from `doFinalComponentDataModelCodegen`.\n if (!ctx.fs.exists(dataModelPath)) {\n await writeFormattedFile(\n ctx,\n tmpDir,\n dataModelContent,\n \"typescript\",\n dataModelPath,\n opts,\n );\n }\n return [filename];\n}\n\nasync function doInitialComponentApiCodegen(\n ctx: Context,\n isRoot: boolean,\n tmpDir: TempDir,\n codegenDir: string,\n useTypeScript: boolean,\n generateCommonJSApi: boolean,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n const writtenFiles: string[] = [];\n\n if (!useTypeScript) {\n const apiJS = componentApiJs();\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiJS,\n \"typescript\",\n path.join(codegenDir, \"api.js\"),\n opts,\n );\n\n // Don't write the `.d.ts` stub if it already exists.\n const apiDTSPath = path.join(codegenDir, \"api.d.ts\");\n const apiStubDTS = componentApiStubDTS();\n if (!ctx.fs.exists(apiDTSPath)) {\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiStubDTS,\n \"typescript\",\n apiDTSPath,\n opts,\n );\n }\n\n writtenFiles.push(\"api.js\", \"api.d.ts\");\n\n if (generateCommonJSApi && isRoot) {\n const apiCjsJS = rootComponentApiCJS();\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiCjsJS,\n \"typescript\",\n path.join(codegenDir, \"api_cjs.cjs\"),\n opts,\n );\n\n const cjsStubPath = path.join(codegenDir, \"api_cjs.d.cts\");\n if (!ctx.fs.exists(cjsStubPath)) {\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiStubDTS,\n \"typescript\",\n cjsStubPath,\n opts,\n );\n }\n writtenFiles.push(\"api_cjs.cjs\", \"api_cjs.d.cts\");\n }\n } else {\n const apiTSPath = path.join(codegenDir, \"api.ts\");\n const apiTS = componentApiStubTS();\n // Don't write the `.ts` stub if it already exists.\n if (!ctx.fs.exists(apiTSPath)) {\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiTS,\n \"typescript\",\n apiTSPath,\n opts,\n );\n }\n writtenFiles.push(\"api.ts\");\n }\n\n return writtenFiles;\n}\n\nasync function doApiCodegen(\n ctx: Context,\n tmpDir: TempDir,\n functionsDir: string,\n codegenDir: string,\n useTypeScript: boolean,\n generateCommonJSApi: boolean,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n const absModulePaths = await entryPoints(ctx, functionsDir);\n const modulePaths = absModulePaths\n .map((p) => path.relative(functionsDir, p))\n .sort();\n\n const writtenFiles: string[] = [];\n\n if (!useTypeScript) {\n const apiContent = apiCodegen(modulePaths, { useTypeScript: false });\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiContent.JS!,\n \"typescript\",\n path.join(codegenDir, \"api.js\"),\n opts,\n );\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiContent.DTS!,\n \"typescript\",\n path.join(codegenDir, \"api.d.ts\"),\n opts,\n );\n writtenFiles.push(\"api.js\", \"api.d.ts\");\n\n if (generateCommonJSApi) {\n const apiCjsContent = apiCjsCodegen(modulePaths);\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiCjsContent.JS!,\n \"typescript\",\n path.join(codegenDir, \"api_cjs.cjs\"),\n opts,\n );\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiCjsContent.DTS!,\n \"typescript\",\n path.join(codegenDir, \"api_cjs.d.cts\"),\n opts,\n );\n writtenFiles.push(\"api_cjs.cjs\", \"api_cjs.d.cts\");\n }\n } else {\n const apiContent = apiCodegen(modulePaths, { useTypeScript: true });\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiContent.TS!,\n \"typescript\",\n path.join(codegenDir, \"api.ts\"),\n opts,\n );\n writtenFiles.push(\"api.ts\");\n }\n\n return writtenFiles;\n}\n\nasync function writeFormattedFile(\n ctx: Context,\n tmpDir: TempDir,\n contents: string,\n filetype: string,\n destination: string,\n options?: {\n dryRun?: boolean;\n debug?: boolean;\n },\n) {\n // Run prettier so we don't have to think about formatting!\n //\n // This is a little sketchy because we are using the default prettier config\n // (not our user's one) but it's better than nothing.\n const formattedContents = await prettier.format(contents, {\n parser: filetype,\n pluginSearchDirs: false,\n });\n if (options?.debug) {\n // NB: The `test_codegen_projects_are_up_to_date` smoke test depends\n // on this output format.\n logOutput(`# ${path.resolve(destination)}`);\n logOutput(formattedContents);\n return;\n }\n try {\n const existing = ctx.fs.readUtf8File(destination);\n if (existing === formattedContents) {\n return;\n }\n } catch (err: any) {\n if (err.code !== \"ENOENT\") {\n // eslint-disable-next-line no-restricted-syntax\n throw err;\n }\n }\n if (options?.dryRun) {\n logOutput(`Command would write file: ${destination}`);\n return;\n }\n const tmpPath = tmpDir.writeUtf8File(formattedContents);\n ctx.fs.swapTmpFile(tmpPath, destination);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,sBAAqB;AACrB,gBAAoC;AACpC,qBAA4B;AAC5B,iBAA2B;AAC3B,qBAA8B;AAC9B,uBAOO;AACP,oBAA8B;AAC9B,oBAA0C;AAC1C,sBAAgC;AAEhC,iBAKO;AACP,uBAAwD;AACxD,oBAIO;AACP,qBAAkC;AAClC,8BAAkC;AAClC,gCAGO;AAEP,2BAQO;AACP,mBAA6B;AAG7B,MAAM,8BAA8B,oBAAI,IAAI,CAAC,IAAI,CAAC;AAE3C,SAAS,6BACd,KACA,YACA,cACA,MACA;AAEA,MAAI,MAAM,OAAO;AACf;AAAA,EACF;AACA,aAAW,QAAQ,IAAI,GAAG,QAAQ,UAAU,GAAG;AAC7C,QAAI,4BAA4B,IAAI,KAAK,IAAI,GAAG;AAC9C;AAAA,IACF;AACA,QAAI,CAAC,aAAa,SAAS,KAAK,IAAI,GAAG;AACrC,4CAAkB,KAAK,YAAAA,QAAK,KAAK,YAAY,KAAK,IAAI,GAAG,IAAI;AAAA,IAC/D;AAAA,EACF;AACF;AAiBA,eAAsB,mBACpB,KACA,iBACA,MAIA;AACA,QAAM,eAAe;AACrB,MAAI;AACJ,MAAI,iBAAiB;AACnB,aAAS;AAAA,EACX,OAAO;AACL,UAAM,EAAE,eAAe,WAAW,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,MAAI,SAAS,OAAO;AAGlB,8BAAU,KAAK,YAAAH,QAAK,QAAQ,WAAW,CAAC,EAAE;AAC1C,8BAAU,iBAAiB;AAC3B;AAAA,EACF;AACA,MAAI;AACF,UAAM,WAAW,IAAI,GAAG,aAAa,WAAW;AAChD,QAAI,aAAa,mBAAmB;AAClC;AAAA,IACF;AAAA,EACF,SAAS,KAAU;AACjB,QAAI,IAAI,SAAS,UAAU;AAEzB,YAAM;AAAA,IACR;AAAA,EACF;AACA,MAAI,SAAS,QAAQ;AACnB,8BAAU,6BAA6B,WAAW,EAAE;AACpD;AAAA,EACF;AACA,QAAM,UAAU,OAAO,cAAc,iBAAiB;AACtD,MAAI,GAAG,YAAY,SAAS,WAAW;AACzC;",
|
|
4
|
+
"sourcesContent": ["import path from \"path\";\nimport prettier from \"prettier\";\nimport { withTmpDir, TempDir } from \"../../bundler/fs.js\";\nimport { entryPoints } from \"../../bundler/index.js\";\nimport { apiCodegen } from \"../codegen_templates/api.js\";\nimport { apiCjsCodegen } from \"../codegen_templates/api_cjs.js\";\nimport { compareModulePaths } from \"../codegen_templates/common.js\";\nimport {\n dynamicDataModelDTS,\n dynamicDataModelTS,\n noSchemaDataModelDTS,\n noSchemaDataModelTS,\n staticDataModelDTS,\n staticDataModelTS,\n} from \"../codegen_templates/dataModel.js\";\nimport { readmeCodegen } from \"../codegen_templates/readme.js\";\nimport { serverCodegen, EnvVarMeta } from \"../codegen_templates/server.js\";\nimport { tsconfigCodegen } from \"../codegen_templates/tsconfig.js\";\nimport { Context } from \"../../bundler/context.js\";\nimport {\n logError,\n logMessage,\n logOutput,\n logVerbose,\n} from \"../../bundler/log.js\";\nimport { typeCheckFunctionsInMode, TypeCheckMode } from \"./typecheck.js\";\nimport {\n readProjectConfig,\n usesTypeScriptCodegen,\n usesComponentApiImports,\n} from \"./config.js\";\nimport { recursivelyDelete } from \"./fsUtils.js\";\nimport { componentServerTS } from \"../codegen_templates/component_server.js\";\nimport {\n ComponentDirectory,\n toComponentDefinitionPath,\n} from \"./components/definition/directoryStructure.js\";\nimport { StartPushResponse } from \"./deployApi/startPush.js\";\nimport {\n componentApiDTS,\n componentApiJs,\n componentApiStubDTS,\n componentApiStubTS,\n componentApiTSWithTypes,\n componentTS,\n rootComponentApiCJS,\n} from \"../codegen_templates/component_api.js\";\nimport { functionsDir } from \"./utils/utils.js\";\nimport { LargeIndexDeletionCheck } from \"./indexes.js\";\n\nconst PRESERVED_GENERATED_ENTRIES = new Set([\"ai\"]);\n\nexport function cleanupStaleGeneratedEntries(\n ctx: Context,\n codegenDir: string,\n writtenFiles: string[],\n opts?: { debug?: boolean; force?: boolean; dryRun?: boolean },\n) {\n // Skip cleanup in debug mode since we don't actually write files in that mode.\n if (opts?.debug) {\n return;\n }\n for (const file of ctx.fs.listDir(codegenDir)) {\n if (PRESERVED_GENERATED_ENTRIES.has(file.name)) {\n continue;\n }\n if (!writtenFiles.includes(file.name)) {\n recursivelyDelete(ctx, path.join(codegenDir, file.name), opts);\n }\n }\n}\n\nexport type CodegenOptions = {\n url?: string | undefined;\n adminKey?: string | undefined;\n dryRun: boolean;\n debug: boolean;\n typecheck: TypeCheckMode;\n init: boolean;\n commonjs: boolean;\n liveComponentSources: boolean;\n debugNodeApis: boolean;\n systemUdfs: boolean;\n largeIndexDeletionCheck: LargeIndexDeletionCheck;\n codegenOnlyThisComponent?: string | undefined;\n};\n\nexport async function doInitConvexFolder(\n ctx: Context,\n functionsFolder?: string,\n opts?: {\n dryRun?: boolean;\n debug?: boolean;\n },\n) {\n const skipIfExists = true;\n let folder: string;\n if (functionsFolder) {\n folder = functionsFolder;\n } else {\n const { projectConfig, configPath } = await readProjectConfig(ctx);\n folder = functionsDir(configPath, projectConfig);\n }\n const { functionsDirExistedBeforeCodegen } = await prepareForCodegen(\n ctx,\n folder,\n opts,\n );\n await withTmpDir(async (tmpDir) => {\n await doReadmeCodegen(\n ctx,\n tmpDir,\n folder,\n skipIfExists && functionsDirExistedBeforeCodegen,\n opts,\n );\n await doTsconfigCodegen(ctx, tmpDir, folder, skipIfExists, opts);\n });\n}\n\nasync function prepareForCodegen(\n ctx: Context,\n functionsDir: string,\n opts?: { dryRun?: boolean },\n) {\n const functionsDirExistedBeforeCodegen = ctx.fs.exists(functionsDir);\n // Delete the old _generated.ts because v0.1.2 used to put the react generated\n // code there\n const legacyCodegenPath = path.join(functionsDir, \"_generated.ts\");\n if (ctx.fs.exists(legacyCodegenPath)) {\n if (opts?.dryRun) {\n logError(\n `Command would delete legacy codegen file: ${legacyCodegenPath}}`,\n );\n } else {\n logError(`Deleting legacy codegen file: ${legacyCodegenPath}}`);\n ctx.fs.unlink(legacyCodegenPath);\n }\n }\n\n // Create the codegen dir if it doesn't already exist.\n const codegenDir = path.join(functionsDir, \"_generated\");\n ctx.fs.mkdir(codegenDir, { allowExisting: true, recursive: true });\n return { codegenDir, functionsDirExistedBeforeCodegen };\n}\n\n/** Codegen only for an application (a root component) */\nexport async function doCodegen(\n ctx: Context,\n functionsDir: string,\n typeCheckMode: TypeCheckMode,\n opts?: { dryRun?: boolean; generateCommonJSApi?: boolean; debug?: boolean },\n) {\n const { projectConfig } = await readProjectConfig(ctx);\n const { codegenDir } = await prepareForCodegen(ctx, functionsDir, opts);\n\n await withTmpDir(async (tmpDir) => {\n // Write files in dependency order so a watching dev server doesn't\n // see inconsistent results where a file we write imports from a\n // file that doesn't exist yet. We'll collect all the paths we write\n // and then delete any remaining paths at the end.\n const writtenFiles = [];\n\n const useTypeScript = usesTypeScriptCodegen(projectConfig);\n const generateCommonJSApi =\n opts?.generateCommonJSApi || projectConfig.generateCommonJSApi;\n\n // First, `dataModel.d.ts` imports from the developer's `schema.js` file.\n const schemaFiles = await doDataModelCodegen(\n ctx,\n tmpDir,\n functionsDir,\n codegenDir,\n useTypeScript,\n opts,\n );\n writtenFiles.push(...schemaFiles);\n\n // Next, the `server.d.ts` file imports from `dataModel.d.ts`.\n const serverFiles = await writeServerFiles(\n ctx,\n tmpDir,\n codegenDir,\n useTypeScript,\n undefined,\n opts,\n );\n writtenFiles.push(...serverFiles);\n\n // The `api.d.ts` file imports from the developer's modules, which then\n // import from `server.d.ts`. Note that there's a cycle here, since the\n // developer's modules could also import from the `api.{js,d.ts}` files.\n const apiFiles = await doApiCodegen(\n ctx,\n tmpDir,\n functionsDir,\n codegenDir,\n useTypeScript,\n generateCommonJSApi,\n opts,\n );\n writtenFiles.push(...apiFiles);\n\n // Cleanup any files that weren't written in this run.\n cleanupStaleGeneratedEntries(ctx, codegenDir, writtenFiles, opts);\n\n // Generated code is updated, typecheck the query and mutation functions.\n await typeCheckFunctionsInMode(ctx, typeCheckMode, functionsDir);\n });\n}\n\n// Just enough to be able to bundle code for analysis: we need an api proxy object\n// so that imports aren't broken, we need basics in server, we need something in\n// data model.\nexport async function doInitialComponentCodegen(\n ctx: Context,\n tmpDir: TempDir,\n componentDirectory: ComponentDirectory,\n opts?: {\n dryRun?: boolean;\n generateCommonJSApi?: boolean;\n debug?: boolean;\n verbose?: boolean;\n },\n) {\n const { projectConfig } = await readProjectConfig(ctx);\n\n if (isPublishedPackage(componentDirectory)) {\n if (opts?.verbose) {\n logMessage(\n `skipping initial codegen for installed package ${componentDirectory.path}`,\n );\n }\n return;\n }\n\n const { codegenDir } = await prepareForCodegen(\n ctx,\n componentDirectory.path,\n opts,\n );\n\n // Write files in dependency order so a watching dev server doesn't\n // see inconsistent results where a file we write imports from a\n // file that doesn't exist yet. We'll collect all the paths we write\n // and then delete any remaining paths at the end.\n const writtenFiles = [];\n\n // Non-root components always use .ts files; root components respect the config\n // But for initial (placeholder, stub) codegen we don't care, just use .d.ts and .js.\n const useTypeScript =\n !componentDirectory.isRoot || usesTypeScriptCodegen(projectConfig);\n\n const generateCommonJSApi =\n opts?.generateCommonJSApi || projectConfig.generateCommonJSApi;\n\n // First, `dataModel.d.ts` imports from the developer's `schema.js` file.\n const dataModelFiles = await doInitialComponentDataModelCodegen(\n ctx,\n tmpDir,\n componentDirectory,\n codegenDir,\n useTypeScript,\n opts,\n );\n writtenFiles.push(...dataModelFiles);\n\n // Next, the `server.d.ts` file imports from `dataModel.d.ts`.\n const serverFiles = await doInitialComponentServerCodegen(\n ctx,\n componentDirectory.isRoot,\n tmpDir,\n codegenDir,\n useTypeScript,\n undefined,\n opts,\n );\n writtenFiles.push(...serverFiles);\n\n // The `api.d.ts` file imports from the developer's modules, which then\n // import from `server.d.ts`. Note that there's a cycle here, since the\n // developer's modules could also import from the `api.{js,d.ts}` files.\n const apiFiles = await doInitialComponentApiCodegen(\n ctx,\n componentDirectory.isRoot,\n tmpDir,\n codegenDir,\n useTypeScript,\n generateCommonJSApi,\n opts,\n );\n writtenFiles.push(...apiFiles);\n\n // component.ts is generated in doFinalComponentCodegen, but don't delete\n // if it already exists from a previous full codegen run.\n if (!componentDirectory.isRoot) {\n const componentTSPath = path.join(codegenDir, \"component.ts\");\n if (ctx.fs.exists(componentTSPath)) {\n writtenFiles.push(\"component.ts\");\n }\n }\n\n // Cleanup any files that weren't written in this run.\n cleanupStaleGeneratedEntries(ctx, codegenDir, writtenFiles, opts);\n}\n\n/* This component defined in a dist directory; it is probably in a node_module\n * directory, installed from a package. It is stuck with the files it has.\n * Heuristics for this:\n * - component definition has a dist/ directory as an ancestor\n * - component definition is a .js file\n * - presence of .js.map files\n * We may improve this heuristic.\n */\nexport function isPublishedPackage(componentDirectory: ComponentDirectory) {\n return (\n componentDirectory.definitionPath.endsWith(\".js\") &&\n !componentDirectory.isRoot\n );\n}\n\n// Handles root and non-root components; it's \"component\" codegen because\n// it's not the old legacy path.\nexport async function doFinalComponentCodegen(\n ctx: Context,\n tmpDir: TempDir,\n rootComponent: ComponentDirectory,\n componentDirectory: ComponentDirectory,\n startPushResponse: StartPushResponse,\n componentsMap: Map<string, ComponentDirectory>,\n opts?: {\n dryRun?: boolean;\n debug?: boolean;\n generateCommonJSApi?: boolean;\n },\n) {\n const { projectConfig } = await readProjectConfig(ctx);\n\n const isPublishedPackage =\n componentDirectory.definitionPath.endsWith(\".js\") &&\n !componentDirectory.isRoot;\n // We never codegen for a published package (you need to link to the convex.config.ts file instead).\n if (isPublishedPackage) {\n return;\n }\n\n const codegenDir = path.join(componentDirectory.path, \"_generated\");\n ctx.fs.mkdir(codegenDir, { allowExisting: true, recursive: true });\n\n // Non-root components always use .ts files; root components respect the config\n const useTypeScript =\n !componentDirectory.isRoot || usesTypeScriptCodegen(projectConfig);\n\n // `dataModel` and `api` files depend on analyze results so will get replaced\n // in the later post-analysis codegen phase, but `server` files don't need\n // analysis info so the stubs from initial codegen are sufficient.\n\n // dataModel\n const hasSchemaFile = schemaFileExists(ctx, componentDirectory.path);\n let dataModelContents: string;\n if (hasSchemaFile) {\n if (projectConfig.codegen.staticDataModel) {\n dataModelContents = useTypeScript\n ? await staticDataModelTS(\n ctx,\n startPushResponse,\n rootComponent,\n componentDirectory,\n )\n : await staticDataModelDTS(\n ctx,\n startPushResponse,\n rootComponent,\n componentDirectory,\n );\n } else {\n dataModelContents = useTypeScript\n ? dynamicDataModelTS()\n : dynamicDataModelDTS();\n }\n } else {\n dataModelContents = useTypeScript\n ? noSchemaDataModelTS()\n : noSchemaDataModelDTS();\n }\n const dataModelPath = path.join(\n codegenDir,\n useTypeScript ? \"dataModel.ts\" : \"dataModel.d.ts\",\n );\n await writeFormattedFile(\n ctx,\n tmpDir,\n dataModelContents,\n \"typescript\",\n dataModelPath,\n opts,\n );\n\n // component.ts\n if (!componentDirectory.isRoot) {\n const componentTSPath = path.join(codegenDir, \"component.ts\");\n const componentTSContents = await componentTS(\n ctx,\n startPushResponse,\n rootComponent,\n componentDirectory,\n );\n await writeFormattedFile(\n ctx,\n tmpDir,\n componentTSContents,\n \"typescript\",\n componentTSPath,\n opts,\n );\n }\n\n // server.ts - regenerate it in final codegen so we can emit typed env vars.\n const definitionPath = toComponentDefinitionPath(\n rootComponent,\n componentDirectory,\n );\n const analysis = startPushResponse.analysis[definitionPath];\n const envVars: EnvVarMeta[] =\n analysis?.definition.envVars && analysis.definition.envVars.length > 0\n ? analysis.definition.envVars\n : [];\n await writeServerFilesForComponent(\n ctx,\n componentDirectory.isRoot,\n tmpDir,\n codegenDir,\n useTypeScript,\n envVars,\n opts,\n );\n\n // api\n if (!useTypeScript) {\n const apiDTSPath = path.join(codegenDir, \"api.d.ts\");\n const apiContents = await componentApiDTS(\n ctx,\n startPushResponse,\n rootComponent,\n componentDirectory,\n componentsMap,\n {\n staticApi: projectConfig.codegen.staticApi,\n useComponentApiImports: usesComponentApiImports(projectConfig),\n },\n );\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiContents,\n \"typescript\",\n apiDTSPath,\n opts,\n );\n\n if (opts?.generateCommonJSApi || projectConfig.generateCommonJSApi) {\n const apiCjsDTSPath = path.join(codegenDir, \"api_cjs.d.cts\");\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiContents,\n \"typescript\",\n apiCjsDTSPath,\n opts,\n );\n }\n } else {\n const apiTSPath = path.join(codegenDir, \"api.ts\");\n const apiContents = await componentApiTSWithTypes(\n ctx,\n startPushResponse,\n rootComponent,\n componentDirectory,\n componentsMap,\n {\n staticApi: projectConfig.codegen.staticApi,\n useComponentApiImports: usesComponentApiImports(projectConfig),\n },\n );\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiContents,\n \"typescript\",\n apiTSPath,\n opts,\n );\n }\n}\n\nasync function doReadmeCodegen(\n ctx: Context,\n tmpDir: TempDir,\n functionsDir: string,\n skip: boolean,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n const readmePath = path.join(functionsDir, \"README.md\");\n if (skip) {\n logVerbose(`Not overwriting README.md.`);\n return;\n }\n await writeFormattedFile(\n ctx,\n tmpDir,\n readmeCodegen(),\n \"markdown\",\n readmePath,\n opts,\n );\n}\n\nasync function doTsconfigCodegen(\n ctx: Context,\n tmpDir: TempDir,\n functionsDir: string,\n skipIfExists: boolean,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n const tsconfigPath = path.join(functionsDir, \"tsconfig.json\");\n if (skipIfExists && ctx.fs.exists(tsconfigPath)) {\n logVerbose(`Not overwriting tsconfig.json.`);\n return;\n }\n await writeFormattedFile(\n ctx,\n tmpDir,\n tsconfigCodegen(),\n \"json\",\n tsconfigPath,\n opts,\n );\n}\n\nfunction schemaFileExists(ctx: Context, functionsDir: string) {\n let schemaPath = path.join(functionsDir, \"schema.ts\");\n let hasSchemaFile = ctx.fs.exists(schemaPath);\n if (!hasSchemaFile) {\n schemaPath = path.join(functionsDir, \"schema.js\");\n hasSchemaFile = ctx.fs.exists(schemaPath);\n }\n return hasSchemaFile;\n}\n\nasync function doDataModelCodegen(\n ctx: Context,\n tmpDir: TempDir,\n functionsDir: string,\n codegenDir: string,\n useTypeScript: boolean,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n const hasSchemaFile = schemaFileExists(ctx, functionsDir);\n const schemaContent = hasSchemaFile\n ? useTypeScript\n ? dynamicDataModelTS()\n : dynamicDataModelDTS()\n : useTypeScript\n ? noSchemaDataModelTS()\n : noSchemaDataModelDTS();\n\n const filename = useTypeScript ? \"dataModel.ts\" : \"dataModel.d.ts\";\n await writeFormattedFile(\n ctx,\n tmpDir,\n schemaContent,\n \"typescript\",\n path.join(codegenDir, filename),\n opts,\n );\n return [filename];\n}\n\n/**\n * Write server.ts/.js/.d.ts files for root components.\n * Returns list of filenames written.\n */\nasync function writeServerFiles(\n ctx: Context,\n tmpDir: TempDir,\n codegenDir: string,\n useTypeScript: boolean,\n envVars: EnvVarMeta[] | undefined,\n opts?: { dryRun?: boolean; debug?: boolean },\n): Promise<string[]> {\n if (!useTypeScript) {\n const serverContent = serverCodegen({\n useTypeScript: false,\n envVars,\n });\n await writeFormattedFile(\n ctx,\n tmpDir,\n serverContent.JS!,\n \"typescript\",\n path.join(codegenDir, \"server.js\"),\n opts,\n );\n\n await writeFormattedFile(\n ctx,\n tmpDir,\n serverContent.DTS!,\n \"typescript\",\n path.join(codegenDir, \"server.d.ts\"),\n opts,\n );\n\n return [\"server.js\", \"server.d.ts\"];\n } else {\n const serverContent = serverCodegen({\n useTypeScript: true,\n envVars,\n });\n await writeFormattedFile(\n ctx,\n tmpDir,\n serverContent.TS!,\n \"typescript\",\n path.join(codegenDir, \"server.ts\"),\n opts,\n );\n\n return [\"server.ts\"];\n }\n}\n\n/**\n * Write server.ts file for non-root components.\n * Returns list of filenames written.\n */\nasync function writeComponentServerFile(\n ctx: Context,\n tmpDir: TempDir,\n codegenDir: string,\n envVars: EnvVarMeta[] | undefined,\n opts?: { dryRun?: boolean; debug?: boolean },\n): Promise<string[]> {\n const serverTSPath = path.join(codegenDir, \"server.ts\");\n const serverTSContents = componentServerTS(false, envVars);\n await writeFormattedFile(\n ctx,\n tmpDir,\n serverTSContents,\n \"typescript\",\n serverTSPath,\n opts,\n );\n return [\"server.ts\"];\n}\n\n/**\n * Write server files for either root or non-root components.\n * Root components get server.ts/server.js/server.d.ts based on useTypeScript.\n * Non-root components always get server.ts.\n * Returns list of filenames written.\n */\nasync function writeServerFilesForComponent(\n ctx: Context,\n isRoot: boolean,\n tmpDir: TempDir,\n codegenDir: string,\n useTypeScript: boolean,\n envVars: EnvVarMeta[] | undefined,\n opts?: { dryRun?: boolean; debug?: boolean },\n): Promise<string[]> {\n if (isRoot) {\n return await writeServerFiles(\n ctx,\n tmpDir,\n codegenDir,\n useTypeScript,\n envVars,\n opts,\n );\n } else {\n return await writeComponentServerFile(\n ctx,\n tmpDir,\n codegenDir,\n envVars,\n opts,\n );\n }\n}\n\nasync function doInitialComponentServerCodegen(\n ctx: Context,\n isRoot: boolean,\n tmpDir: TempDir,\n codegenDir: string,\n useTypeScript: boolean,\n envVars: EnvVarMeta[] | undefined,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n // Don't write our stub if the file already exists, since it may have\n // better type information from `doFinalComponentCodegen` (e.g. env vars).\n const serverFilename = useTypeScript ? \"server.ts\" : \"server.js\";\n if (ctx.fs.exists(path.join(codegenDir, serverFilename))) {\n const filenames = [serverFilename];\n if (!useTypeScript) {\n filenames.push(\"server.d.ts\");\n }\n return filenames;\n }\n return await writeServerFilesForComponent(\n ctx,\n isRoot,\n tmpDir,\n codegenDir,\n useTypeScript,\n envVars,\n opts,\n );\n}\n\nasync function doInitialComponentDataModelCodegen(\n ctx: Context,\n tmpDir: TempDir,\n componentDirectory: ComponentDirectory,\n codegenDir: string,\n useTypeScript: boolean,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n const hasSchemaFile = schemaFileExists(ctx, componentDirectory.path);\n const dataModelContent = hasSchemaFile\n ? useTypeScript\n ? dynamicDataModelTS()\n : dynamicDataModelDTS()\n : useTypeScript\n ? noSchemaDataModelTS()\n : noSchemaDataModelDTS();\n const filename = useTypeScript ? \"dataModel.ts\" : \"dataModel.d.ts\";\n const dataModelPath = path.join(codegenDir, filename);\n\n // Don't write our stub if the file already exists, since it may have\n // better type information from `doFinalComponentDataModelCodegen`.\n if (!ctx.fs.exists(dataModelPath)) {\n await writeFormattedFile(\n ctx,\n tmpDir,\n dataModelContent,\n \"typescript\",\n dataModelPath,\n opts,\n );\n }\n return [filename];\n}\n\nasync function doInitialComponentApiCodegen(\n ctx: Context,\n isRoot: boolean,\n tmpDir: TempDir,\n codegenDir: string,\n useTypeScript: boolean,\n generateCommonJSApi: boolean,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n const writtenFiles: string[] = [];\n\n if (!useTypeScript) {\n const apiJS = componentApiJs();\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiJS,\n \"typescript\",\n path.join(codegenDir, \"api.js\"),\n opts,\n );\n\n // Don't write the `.d.ts` stub if it already exists.\n const apiDTSPath = path.join(codegenDir, \"api.d.ts\");\n const apiStubDTS = componentApiStubDTS();\n if (!ctx.fs.exists(apiDTSPath)) {\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiStubDTS,\n \"typescript\",\n apiDTSPath,\n opts,\n );\n }\n\n writtenFiles.push(\"api.js\", \"api.d.ts\");\n\n if (generateCommonJSApi && isRoot) {\n const apiCjsJS = rootComponentApiCJS();\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiCjsJS,\n \"typescript\",\n path.join(codegenDir, \"api_cjs.cjs\"),\n opts,\n );\n\n const cjsStubPath = path.join(codegenDir, \"api_cjs.d.cts\");\n if (!ctx.fs.exists(cjsStubPath)) {\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiStubDTS,\n \"typescript\",\n cjsStubPath,\n opts,\n );\n }\n writtenFiles.push(\"api_cjs.cjs\", \"api_cjs.d.cts\");\n }\n } else {\n const apiTSPath = path.join(codegenDir, \"api.ts\");\n const apiTS = componentApiStubTS();\n // Don't write the `.ts` stub if it already exists.\n if (!ctx.fs.exists(apiTSPath)) {\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiTS,\n \"typescript\",\n apiTSPath,\n opts,\n );\n }\n writtenFiles.push(\"api.ts\");\n }\n\n return writtenFiles;\n}\n\nasync function doApiCodegen(\n ctx: Context,\n tmpDir: TempDir,\n functionsDir: string,\n codegenDir: string,\n useTypeScript: boolean,\n generateCommonJSApi: boolean,\n opts?: { dryRun?: boolean; debug?: boolean },\n) {\n const absModulePaths = await entryPoints(ctx, functionsDir);\n const modulePaths = absModulePaths\n .map((p) => path.relative(functionsDir, p))\n .sort(compareModulePaths);\n\n const writtenFiles: string[] = [];\n\n if (!useTypeScript) {\n const apiContent = apiCodegen(modulePaths, { useTypeScript: false });\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiContent.JS!,\n \"typescript\",\n path.join(codegenDir, \"api.js\"),\n opts,\n );\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiContent.DTS!,\n \"typescript\",\n path.join(codegenDir, \"api.d.ts\"),\n opts,\n );\n writtenFiles.push(\"api.js\", \"api.d.ts\");\n\n if (generateCommonJSApi) {\n const apiCjsContent = apiCjsCodegen(modulePaths);\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiCjsContent.JS!,\n \"typescript\",\n path.join(codegenDir, \"api_cjs.cjs\"),\n opts,\n );\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiCjsContent.DTS!,\n \"typescript\",\n path.join(codegenDir, \"api_cjs.d.cts\"),\n opts,\n );\n writtenFiles.push(\"api_cjs.cjs\", \"api_cjs.d.cts\");\n }\n } else {\n const apiContent = apiCodegen(modulePaths, { useTypeScript: true });\n await writeFormattedFile(\n ctx,\n tmpDir,\n apiContent.TS!,\n \"typescript\",\n path.join(codegenDir, \"api.ts\"),\n opts,\n );\n writtenFiles.push(\"api.ts\");\n }\n\n return writtenFiles;\n}\n\nasync function writeFormattedFile(\n ctx: Context,\n tmpDir: TempDir,\n contents: string,\n filetype: string,\n destination: string,\n options?: {\n dryRun?: boolean;\n debug?: boolean;\n },\n) {\n // Run prettier so we don't have to think about formatting!\n //\n // This is a little sketchy because we are using the default prettier config\n // (not our user's one) but it's better than nothing.\n const formattedContents = await prettier.format(contents, {\n parser: filetype,\n pluginSearchDirs: false,\n });\n if (options?.debug) {\n // NB: The `test_codegen_projects_are_up_to_date` smoke test depends\n // on this output format.\n logOutput(`# ${path.resolve(destination)}`);\n logOutput(formattedContents);\n return;\n }\n try {\n const existing = ctx.fs.readUtf8File(destination);\n if (existing === formattedContents) {\n return;\n }\n } catch (err: any) {\n if (err.code !== \"ENOENT\") {\n // eslint-disable-next-line no-restricted-syntax\n throw err;\n }\n }\n if (options?.dryRun) {\n logOutput(`Command would write file: ${destination}`);\n return;\n }\n const tmpPath = tmpDir.writeUtf8File(formattedContents);\n ctx.fs.swapTmpFile(tmpPath, destination);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,sBAAqB;AACrB,gBAAoC;AACpC,qBAA4B;AAC5B,iBAA2B;AAC3B,qBAA8B;AAC9B,oBAAmC;AACnC,uBAOO;AACP,oBAA8B;AAC9B,oBAA0C;AAC1C,sBAAgC;AAEhC,iBAKO;AACP,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,QAAK,KAAK,YAAY,aAAa;AAAA,QACnC;AAAA,MACF;AACA,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA,cAAc;AAAA,QACd;AAAA,QACA,YAAAA,QAAK,KAAK,YAAY,eAAe;AAAA,QACrC;AAAA,MACF;AACA,mBAAa,KAAK,eAAe,eAAe;AAAA,IAClD;AAAA,EACF,OAAO;AACL,UAAM,iBAAa,uBAAW,aAAa,EAAE,eAAe,KAAK,CAAC;AAClE,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX;AAAA,MACA,YAAAA,QAAK,KAAK,YAAY,QAAQ;AAAA,MAC9B;AAAA,IACF;AACA,iBAAa,KAAK,QAAQ;AAAA,EAC5B;AAEA,SAAO;AACT;AAEA,eAAe,mBACb,KACA,QACA,UACA,UACA,aACA,SAIA;AAKA,QAAM,oBAAoB,MAAM,gBAAAG,QAAS,OAAO,UAAU;AAAA,IACxD,QAAQ;AAAA,IACR,kBAAkB;AAAA,EACpB,CAAC;AACD,MAAI,SAAS,OAAO;AAGlB,8BAAU,KAAK,YAAAH,QAAK,QAAQ,WAAW,CAAC,EAAE;AAC1C,8BAAU,iBAAiB;AAC3B;AAAA,EACF;AACA,MAAI;AACF,UAAM,WAAW,IAAI,GAAG,aAAa,WAAW;AAChD,QAAI,aAAa,mBAAmB;AAClC;AAAA,IACF;AAAA,EACF,SAAS,KAAU;AACjB,QAAI,IAAI,SAAS,UAAU;AAEzB,YAAM;AAAA,IACR;AAAA,EACF;AACA,MAAI,SAAS,QAAQ;AACnB,8BAAU,6BAA6B,WAAW,EAAE;AACpD;AAAA,EACF;AACA,QAAM,UAAU,OAAO,cAAc,iBAAiB;AACtD,MAAI,GAAG,YAAY,SAAS,WAAW;AACzC;",
|
|
6
6
|
"names": ["path", "functionsDir", "isPublishedPackage", "prettier"]
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export const version = \"1.42.2
|
|
4
|
+
"sourcesContent": ["export const version = \"1.42.2\";\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,UAAU;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/server/meta.ts"],
|
|
4
|
-
"sourcesContent": ["import { FunctionType } from \"./api.js\";\nimport { FunctionVisibility } from \"./registration.js\";\n\n/**\n * Used and remaining amounts for a single transaction limit.\n *\n * @public\n */\nexport type TransactionMetric = {\n used: number;\n remaining: number;\n};\n\n/**\n * The remaining headroom for a transaction before hitting limits.\n *\n * See https://docs.convex.dev/production/state/limits\n *\n * @public\n */\nexport type TransactionMetrics = {\n bytesRead: TransactionMetric;\n bytesWritten: TransactionMetric;\n databaseQueries: TransactionMetric;\n documentsRead: TransactionMetric;\n documentsWritten: TransactionMetric;\n functionsScheduled: TransactionMetric;\n scheduledFunctionArgsBytes: TransactionMetric;\n};\n\n/**\n * Custom limits for a nested transaction. Each field specifies the absolute\n * maximum allowed for the nested function call. Values are capped at the\n * global transaction limits, so they can only lower limits, never raise them.\n *\n * @public\n */\nexport interface TransactionLimits {\n bytesRead?: number;\n bytesWritten?: number;\n databaseQueries?: number;\n documentsRead?: number;\n documentsWritten?: number;\n functionsScheduled?: number;\n scheduledFunctionArgsBytes?: number;\n}\n\n/**\n * Metadata about the currently executing Convex function.\n *\n * @public\n */\nexport type FunctionMetadata = {\n /**\n * The name of the function, in the format `\"path/to/module:functionName\"`\n */\n name: string;\n /**\n * The path of the component this function belongs to.\n * This is an empty string `\"\"` for the app.\n */\n componentPath: string;\n /** Whether it's a query, mutation, or action. */\n type: FunctionType;\n /** Whether the function is public or internal. */\n visibility: FunctionVisibility;\n};\n\n/**\n * Metadata about the deployment this function is running on.\n *\n * @public\n */\nexport type DeploymentMetadata = {\n /**\n * The deployment name, e.g. `\"tall-tiger-123\"` for cloud deployments,\n * `\"local-my_team-my_project\"` for local deployments, or\n * `\"anonymous-*\"` for anonymous deployments.\n */\n name: string;\n /**\n * The deployment region, e.g. `\"aws-us-east-1\"`.\n * `null` for local and self-hosted deployments.\n */\n region: string | null;\n /**\n * The deployment class, e.g. `\"s16\"`, `\"s256\"`, or `\"d1024\"`.\n */\n class: \"s16\" | \"s256\" | \"d1024\";\n};\n\n/**\n * Metadata about the HTTP request that triggered the current function execution.\n *\n * `ip` and `userAgent` are `null` when the function was not triggered by an\n * HTTP request (e.g. scheduled jobs or cron jobs).\n *\n * Functions called from within a function (i.e. using `runMutation` or\n * `runAction`) will have the same request metadata as the parent function.\n *\n * @public\n */\nexport type RequestMetadata = {\n ip: string | null;\n userAgent: string | null;\n requestId: string;\n /**\n * The ID of the scheduled function document (in `_scheduled_functions`) that\n * this execution belongs to, or `null` otherwise.\n *\n * This is set for the scheduled function itself and for any functions it\n * calls (e.g. a mutation invoked via `runMutation` by a scheduled action),\n * propagating the top-level scheduled function's ID down the call tree. It is\n * `null` when the function was not scheduled.\n */\n scheduledFunctionId: string | null;\n /**\n * The raw auth token (a JWT) the request was authenticated with, or `null`\n * when the request was unauthenticated or authenticated with an admin key.\n *\n * This is the same token that `ctx.auth.getUserIdentity()` derives its\n * attributes from.\n
|
|
4
|
+
"sourcesContent": ["import { FunctionType } from \"./api.js\";\nimport { FunctionVisibility } from \"./registration.js\";\n\n/**\n * Used and remaining amounts for a single transaction limit.\n *\n * @public\n */\nexport type TransactionMetric = {\n used: number;\n remaining: number;\n};\n\n/**\n * The remaining headroom for a transaction before hitting limits.\n *\n * See https://docs.convex.dev/production/state/limits\n *\n * @public\n */\nexport type TransactionMetrics = {\n bytesRead: TransactionMetric;\n bytesWritten: TransactionMetric;\n databaseQueries: TransactionMetric;\n documentsRead: TransactionMetric;\n documentsWritten: TransactionMetric;\n functionsScheduled: TransactionMetric;\n scheduledFunctionArgsBytes: TransactionMetric;\n};\n\n/**\n * Custom limits for a nested transaction. Each field specifies the absolute\n * maximum allowed for the nested function call. Values are capped at the\n * global transaction limits, so they can only lower limits, never raise them.\n *\n * @public\n */\nexport interface TransactionLimits {\n bytesRead?: number;\n bytesWritten?: number;\n databaseQueries?: number;\n documentsRead?: number;\n documentsWritten?: number;\n functionsScheduled?: number;\n scheduledFunctionArgsBytes?: number;\n}\n\n/**\n * Metadata about the currently executing Convex function.\n *\n * @public\n */\nexport type FunctionMetadata = {\n /**\n * The name of the function, in the format `\"path/to/module:functionName\"`\n */\n name: string;\n /**\n * The path of the component this function belongs to.\n * This is an empty string `\"\"` for the app.\n */\n componentPath: string;\n /** Whether it's a query, mutation, or action. */\n type: FunctionType;\n /** Whether the function is public or internal. */\n visibility: FunctionVisibility;\n};\n\n/**\n * Metadata about the deployment this function is running on.\n *\n * @public\n */\nexport type DeploymentMetadata = {\n /**\n * The deployment name, e.g. `\"tall-tiger-123\"` for cloud deployments,\n * `\"local-my_team-my_project\"` for local deployments, or\n * `\"anonymous-*\"` for anonymous deployments.\n */\n name: string;\n /**\n * The deployment region, e.g. `\"aws-us-east-1\"`.\n * `null` for local and self-hosted deployments.\n */\n region: string | null;\n /**\n * The deployment class, e.g. `\"s16\"`, `\"s256\"`, or `\"d1024\"`.\n */\n class: \"s16\" | \"s256\" | \"d1024\";\n};\n\n/**\n * Metadata about the HTTP request that triggered the current function execution.\n *\n * `ip` and `userAgent` are `null` when the function was not triggered by an\n * HTTP request (e.g. scheduled jobs or cron jobs).\n *\n * Functions called from within a function (i.e. using `runMutation` or\n * `runAction`) will have the same request metadata as the parent function.\n *\n * @public\n */\nexport type RequestMetadata = {\n ip: string | null;\n userAgent: string | null;\n requestId: string;\n /**\n * The ID of the scheduled function document (in `_scheduled_functions`) that\n * this execution belongs to, or `null` otherwise.\n *\n * This is set for the scheduled function itself and for any functions it\n * calls (e.g. a mutation invoked via `runMutation` by a scheduled action),\n * propagating the top-level scheduled function's ID down the call tree. It is\n * `null` when the function was not scheduled.\n */\n scheduledFunctionId: string | null;\n /**\n * The raw auth token (a JWT) the request was authenticated with, or `null`\n * when the request was unauthenticated or authenticated with an admin key.\n *\n * This is the same token that `ctx.auth.getUserIdentity()` derives its\n * attributes from.\n */\n authToken: string | null;\n};\n\n/**\n * Extra context available in Convex query functions.\n *\n * @public\n */\nexport interface QueryMeta {\n getFunctionMetadata(): Promise<FunctionMetadata>;\n getTransactionMetrics(): Promise<TransactionMetrics>;\n getDeploymentMetadata(): Promise<DeploymentMetadata>;\n}\n\n/**\n * Extra context available in Convex mutation functions.\n *\n * @public\n */\nexport interface MutationMeta extends QueryMeta {\n getRequestMetadata(): Promise<RequestMetadata>;\n}\n\n/**\n * Extra context available in Convex action functions.\n *\n * @public\n */\nexport interface ActionMeta {\n getFunctionMetadata(): Promise<FunctionMetadata>;\n getDeploymentMetadata(): Promise<DeploymentMetadata>;\n getRequestMetadata(): Promise<RequestMetadata>;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,4 +7,16 @@ export declare function apiComment(apiName: string, type: "public" | "internal"
|
|
|
7
7
|
* or with entries: Object.entries(obj).sort(([a], [b]) => compareStrings(a, b))
|
|
8
8
|
*/
|
|
9
9
|
export declare function compareStrings(a: string, b: string): number;
|
|
10
|
+
/**
|
|
11
|
+
* Comparison function for sorting module paths in codegen output.
|
|
12
|
+
*
|
|
13
|
+
* Compares the forward slash normalized form of each path so the resulting
|
|
14
|
+
* order is identical on every platform. Sorting OS-native paths directly
|
|
15
|
+
* diverges on Windows because "\" (0x5C) sorts after letters while "/"
|
|
16
|
+
* (0x2F) sorts before them. Uses plain code unit comparison to match the
|
|
17
|
+
* default Array.prototype.sort() order these paths sorted with on POSIX.
|
|
18
|
+
*
|
|
19
|
+
* Usage: modulePaths.sort(compareModulePaths)
|
|
20
|
+
*/
|
|
21
|
+
export declare function compareModulePaths(a: string, b: string): number;
|
|
10
22
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/cli/codegen_templates/common.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,kBAAkB,EAAE,MAAM,UAWhD;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,UAWxC;AAUD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D"}
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/cli/codegen_templates/common.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,kBAAkB,EAAE,MAAM,UAWhD;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,UAWxC;AAUD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAI/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.test.d.ts","sourceRoot":"","sources":["../../../../src/cli/codegen_templates/common.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../../../src/cli/lib/codegen.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,OAAO,EAAE,MAAM,qBAAqB,C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L,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,iBAyBF;AA4BD,yDAAyD;AACzD,wBAAsB,SAAS,CAC7B,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,aAAa,EAC5B,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,iBA0D5E;AAKD,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,OAAO,EACf,kBAAkB,EAAE,kBAAkB,EACtC,IAAI,CAAC,EAAE;IACL,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,iBAiFF;AAUD,wBAAgB,kBAAkB,CAAC,kBAAkB,EAAE,kBAAkB,WAKxE;AAID,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,OAAO,EACf,aAAa,EAAE,kBAAkB,EACjC,kBAAkB,EAAE,kBAAkB,EACtC,iBAAiB,EAAE,iBAAiB,EACpC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC9C,IAAI,CAAC,EAAE;IACL,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,iBA+JF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.42.2
|
|
1
|
+
export declare const version = "1.42.2";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
|
@@ -108,6 +108,14 @@ export type RequestMetadata = {
|
|
|
108
108
|
* `null` when the function was not scheduled.
|
|
109
109
|
*/
|
|
110
110
|
scheduledFunctionId: string | null;
|
|
111
|
+
/**
|
|
112
|
+
* The raw auth token (a JWT) the request was authenticated with, or `null`
|
|
113
|
+
* when the request was unauthenticated or authenticated with an admin key.
|
|
114
|
+
*
|
|
115
|
+
* This is the same token that `ctx.auth.getUserIdentity()` derives its
|
|
116
|
+
* attributes from.
|
|
117
|
+
*/
|
|
118
|
+
authToken: string | null;
|
|
111
119
|
};
|
|
112
120
|
/**
|
|
113
121
|
* Extra context available in Convex query functions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/server/meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,YAAY,EAAE,iBAAiB,CAAC;IAChC,eAAe,EAAE,iBAAiB,CAAC;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,kBAAkB,EAAE,iBAAiB,CAAC;IACtC,0BAA0B,EAAE,iBAAiB,CAAC;CAC/C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;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AAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;OAQG;IACH,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjD,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACrD,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACtD;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,kBAAkB,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;CAChD;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjD,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACrD,kBAAkB,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;CAChD"}
|
package/dist/cli.bundle.cjs
CHANGED
|
@@ -47526,7 +47526,7 @@ var version;
|
|
|
47526
47526
|
var init_index = __esm({
|
|
47527
47527
|
"src/index.ts"() {
|
|
47528
47528
|
"use strict";
|
|
47529
|
-
version = "1.42.2
|
|
47529
|
+
version = "1.42.2";
|
|
47530
47530
|
}
|
|
47531
47531
|
});
|
|
47532
47532
|
|
|
@@ -123395,6 +123395,11 @@ var collator = new Intl.Collator("en-US", {
|
|
|
123395
123395
|
function compareStrings(a, b) {
|
|
123396
123396
|
return collator.compare(a, b);
|
|
123397
123397
|
}
|
|
123398
|
+
function compareModulePaths(a, b) {
|
|
123399
|
+
const aNormalized = a.replace(/\\/g, "/");
|
|
123400
|
+
const bNormalized = b.replace(/\\/g, "/");
|
|
123401
|
+
return aNormalized < bNormalized ? -1 : aNormalized > bNormalized ? 1 : 0;
|
|
123402
|
+
}
|
|
123398
123403
|
|
|
123399
123404
|
// src/cli/codegen_templates/api.ts
|
|
123400
123405
|
function importPath(modulePath) {
|
|
@@ -126047,7 +126052,7 @@ async function doInitialComponentApiCodegen(ctx, isRoot, tmpDir, codegenDir, use
|
|
|
126047
126052
|
}
|
|
126048
126053
|
async function doApiCodegen(ctx, tmpDir, functionsDir2, codegenDir, useTypeScript, generateCommonJSApi, opts) {
|
|
126049
126054
|
const absModulePaths = await entryPoints(ctx, functionsDir2);
|
|
126050
|
-
const modulePaths = absModulePaths.map((p) => import_path17.default.relative(functionsDir2, p)).sort();
|
|
126055
|
+
const modulePaths = absModulePaths.map((p) => import_path17.default.relative(functionsDir2, p)).sort(compareModulePaths);
|
|
126051
126056
|
const writtenFiles = [];
|
|
126052
126057
|
if (!useTypeScript) {
|
|
126053
126058
|
const apiContent = apiCodegen(modulePaths, { useTypeScript: false });
|