@gaganref/confect-cli 10.3.1-fork.17 → 10.3.1-fork.18

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.
@@ -84,6 +84,7 @@ var HandWrittenConvexFileError = class extends Schema.TaggedError()("HandWritten
84
84
  convexPath: Schema.String,
85
85
  declarationPath: Schema.String
86
86
  }) {};
87
+ var UnownedConvexEntrypointError = class extends Schema.TaggedError()("UnownedConvexEntrypointError", { filePaths: Schema.Array(Schema.String) }) {};
87
88
  var DeclarationKindMismatchError = class extends Schema.TaggedError()("DeclarationKindMismatchError", {
88
89
  declarationPath: Schema.String,
89
90
  declaredKind: Schema.Literals(["app", "component"]),
@@ -118,6 +119,7 @@ const CodegenError = Schema.Union([
118
119
  InvalidConvexConfigError,
119
120
  InvalidDeclarationError,
120
121
  HandWrittenConvexFileError,
122
+ UnownedConvexEntrypointError,
121
123
  DeclarationKindMismatchError,
122
124
  CallbackPrefixError
123
125
  ]);
@@ -180,6 +182,7 @@ const renderCodegenError = (error) => {
180
182
  if (error._tag === "DeclarationKindMismatchError") return singleLine("Declaration ", formatPath(error.declarationPath), ` declares kind "${error.declaredKind}", but the target directory is kind "${error.targetKind}".`);
181
183
  if (error._tag === "CallbackPrefixError") return singleLine("Callback contract ", `"${error.contractId}" in `, formatPath(error.declarationPath), ` must start with "${error.componentName}/" for component "${error.componentName}".`);
182
184
  if (error._tag === "HandWrittenConvexFileError") return singleLine("Found a hand-written ", formatPath(error.convexPath), ". `confect codegen` writes it from ", formatPath(error.declarationPath), " now; move its contents there and delete the file.");
185
+ if (error._tag === "UnownedConvexEntrypointError") return singleLine(error.filePaths.map((file) => formatPath(file)).join(", "), error.filePaths.length === 1 ? " was" : " were", " not written by confect codegen. Generated files only re-export the registry; put authored code outside convex/. If a file is stale generated output, delete it and run codegen again.");
183
186
  return Match.value(error).pipe(Match.tag("SnapshotError", ({ reason, relativePath, pathSegments }) => singleLine(`Invalid generation metadata (${reason})`, relativePath === "" ? "" : ` for ${relativePath}`, pathSegments.length === 0 ? "." : ` at ${pathSegments.join("/")}.`)), Match.tag("MissingImplFileError", renderMissingImplFileError), Match.tag("MissingSpecFileError", renderMissingSpecFileError), Match.tag("SpecMissingDefaultGroupSpecError", renderSpecMissingDefaultGroupSpecError), Match.tag("SpecImportsServerError", renderSpecImportsServerError), Match.tag("InvalidMiddlewareAttachmentError", (attachmentError) => singleLine("Spec ", formatPath(attachmentError.specPath), `: ${attachmentError.message}`)), Match.tag("ImplMissingSpecImportError", renderImplMissingSpecImportError), Match.tag("ImplMissingDefaultLayerError", renderImplMissingDefaultLayerError), Match.tag("ImplNotFinalizedError", renderImplNotFinalizedError), Match.tag("ImplMissingFunctionsError", renderImplMissingFunctionsError), Match.tag("ImplMissingMiddlewareError", renderImplMissingMiddlewareError), Match.tag("ParentChildNameCollisionError", renderParentChildNameCollisionError), Match.tag("InvalidTableDefaultExportError", renderInvalidTableDefaultExportError), Match.tag("InvalidTableFilenameError", renderInvalidTableFilenameError), Match.tag("DuplicateTableNameError", renderDuplicateTableNameError), Match.tag("LegacySchemaFileError", renderLegacySchemaFileError), Match.tag("ConflictingDocNameError", renderConflictingDocNameError), Match.tag("InvalidConvexConfigError", renderInvalidConvexConfigError), Match.exhaustive);
184
187
  };
185
188
  const logCodegenError = (error) => Console.error(renderCodegenError(error));
@@ -189,6 +192,6 @@ const logCodegenError = (error) => Console.error(renderCodegenError(error));
189
192
  */
190
193
  const tapAndLog = (effect) => effect.pipe(Effect.tapError((error) => isCodegenError(error) ? logCodegenError(error) : Effect.void));
191
194
  //#endregion
192
- export { CallbackPrefixError, CodegenError, ComponentNodeGroupError, ConflictingDocNameError, DeclarationKindMismatchError, DuplicateTableNameError, HandWrittenConvexFileError, ImplMissingDefaultLayerError, ImplMissingFunctionsError, ImplMissingMiddlewareError, ImplMissingSpecImportError, ImplNotFinalizedError, InvalidConvexConfigError, InvalidDeclarationError, InvalidMiddlewareAttachmentError, InvalidTableDefaultExportError, InvalidTableFilenameError, LegacySchemaFileError, MissingImplFileError, MissingSpecFileError, ParentChildNameCollisionError, RemoveBusyError, SpecImportsServerError, SpecMissingDefaultGroupSpecError, isCodegenError, logCodegenError, renderCodegenError, tapAndLog };
195
+ export { CallbackPrefixError, CodegenError, ComponentNodeGroupError, ConflictingDocNameError, DeclarationKindMismatchError, DuplicateTableNameError, HandWrittenConvexFileError, ImplMissingDefaultLayerError, ImplMissingFunctionsError, ImplMissingMiddlewareError, ImplMissingSpecImportError, ImplNotFinalizedError, InvalidConvexConfigError, InvalidDeclarationError, InvalidMiddlewareAttachmentError, InvalidTableDefaultExportError, InvalidTableFilenameError, LegacySchemaFileError, MissingImplFileError, MissingSpecFileError, ParentChildNameCollisionError, RemoveBusyError, SpecImportsServerError, SpecMissingDefaultGroupSpecError, UnownedConvexEntrypointError, isCodegenError, logCodegenError, renderCodegenError, tapAndLog };
193
196
 
194
197
  //# sourceMappingURL=CodegenError.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodegenError.mjs","names":["Ansi.red"],"sources":["../src/CodegenError.ts"],"sourcesContent":["import * as Array from \"effect/Array\";\nimport * as Console from \"effect/Console\";\nimport { pipe } from \"effect/Function\";\nimport * as Effect from \"effect/Effect\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport { BuildError, isBuildError } from \"./BuildError.js\";\nimport { SnapshotError } from \"./SnapshotError.js\";\nimport * as Ansi from \"./Ansi.js\";\nimport { formatPath, renderBuildError } from \"./log.js\";\n\n// --- Variants ---\n\nexport class MissingImplFileError extends Schema.TaggedError<MissingImplFileError>()(\n \"MissingImplFileError\",\n {\n specPath: Schema.String,\n expectedImplPath: Schema.String,\n },\n) {}\n\nexport class MissingSpecFileError extends Schema.TaggedError<MissingSpecFileError>()(\n \"MissingSpecFileError\",\n {\n implPath: Schema.String,\n expectedSpecPath: Schema.String,\n },\n) {}\n\nexport class SpecMissingDefaultGroupSpecError extends Schema.TaggedError<SpecMissingDefaultGroupSpecError>()(\n \"SpecMissingDefaultGroupSpecError\",\n {\n specPath: Schema.String,\n },\n) {}\n\nexport class RemoveBusyError extends Schema.TaggedError<RemoveBusyError>()(\n \"RemoveBusyError\",\n { path: Schema.String, attempts: Schema.Finite, cause: Schema.Unknown },\n) {}\n\nexport class ComponentNodeGroupError extends Schema.TaggedError<ComponentNodeGroupError>()(\n \"ComponentNodeGroupError\",\n {\n specPath: Schema.String,\n groupPath: Schema.String,\n },\n) {}\n\nexport class SpecImportsServerError extends Schema.TaggedError<SpecImportsServerError>()(\n \"SpecImportsServerError\",\n {\n specPath: Schema.String,\n importerPaths: Schema.Array(Schema.String),\n },\n) {}\n\nexport class InvalidMiddlewareAttachmentError extends Schema.TaggedError<InvalidMiddlewareAttachmentError>()(\n \"InvalidMiddlewareAttachmentError\",\n { specPath: Schema.String, message: Schema.String },\n) {}\n\nexport class ImplMissingSpecImportError extends Schema.TaggedError<ImplMissingSpecImportError>()(\n \"ImplMissingSpecImportError\",\n {\n implPath: Schema.String,\n expectedSpecPath: Schema.String,\n },\n) {}\n\nexport class ImplMissingDefaultLayerError extends Schema.TaggedError<ImplMissingDefaultLayerError>()(\n \"ImplMissingDefaultLayerError\",\n {\n implPath: Schema.String,\n },\n) {}\n\nexport class ImplNotFinalizedError extends Schema.TaggedError<ImplNotFinalizedError>()(\n \"ImplNotFinalizedError\",\n {\n implPath: Schema.String,\n },\n) {}\n\nexport class ImplMissingFunctionsError extends Schema.TaggedError<ImplMissingFunctionsError>()(\n \"ImplMissingFunctionsError\",\n {\n implPath: Schema.String,\n groupPath: Schema.String,\n missingFunctionNames: Schema.Array(Schema.String),\n },\n) {}\n\nexport class ImplMissingMiddlewareError extends Schema.TaggedError<ImplMissingMiddlewareError>()(\n \"ImplMissingMiddlewareError\",\n {\n implPath: Schema.String,\n groupPath: Schema.String,\n missingMiddlewareKeys: Schema.Array(Schema.String),\n },\n) {}\n\nexport class ParentChildNameCollisionError extends Schema.TaggedError<ParentChildNameCollisionError>()(\n \"ParentChildNameCollisionError\",\n {\n parentSpecPath: Schema.String,\n childSpecPath: Schema.String,\n collisionName: Schema.String,\n collisionKind: Schema.Literals([\"function\", \"group\"]),\n },\n) {}\n\nexport class InvalidTableDefaultExportError extends Schema.TaggedError<InvalidTableDefaultExportError>()(\n \"InvalidTableDefaultExportError\",\n {\n tablePath: Schema.String,\n },\n) {}\n\nexport class InvalidTableFilenameError extends Schema.TaggedError<InvalidTableFilenameError>()(\n \"InvalidTableFilenameError\",\n {\n tablePath: Schema.String,\n reason: Schema.String,\n },\n) {}\n\nexport class DuplicateTableNameError extends Schema.TaggedError<DuplicateTableNameError>()(\n \"DuplicateTableNameError\",\n {\n // Every table name that more than one file resolves to, each paired with\n // the colliding file paths. All collisions are captured in a single pass\n // so the user can fix them together rather than re-running codegen once\n // per conflict.\n collisions: Schema.Array(\n Schema.Struct({\n tableName: Schema.String,\n tablePaths: Schema.Array(Schema.String),\n }),\n ),\n },\n) {}\n\nexport class LegacySchemaFileError extends Schema.TaggedError<LegacySchemaFileError>()(\n \"LegacySchemaFileError\",\n {\n schemaPath: Schema.String,\n },\n) {}\n\nexport class ConflictingDocNameError extends Schema.TaggedError<ConflictingDocNameError>()(\n \"ConflictingDocNameError\",\n {\n collisions: Schema.Array(\n Schema.Struct({\n docName: Schema.String,\n tableNames: Schema.Array(Schema.String),\n }),\n ),\n },\n) {}\n\nexport class InvalidConvexConfigError extends Schema.TaggedError<InvalidConvexConfigError>()(\n \"InvalidConvexConfigError\",\n {\n configPath: Schema.String,\n reason: Schema.String,\n },\n) {}\n\nexport class InvalidDeclarationError extends Schema.TaggedError<InvalidDeclarationError>()(\n \"InvalidDeclarationError\",\n {\n declarationPath: Schema.String,\n reason: Schema.String,\n },\n) {}\n\nexport class HandWrittenConvexFileError extends Schema.TaggedError<HandWrittenConvexFileError>()(\n \"HandWrittenConvexFileError\",\n {\n convexPath: Schema.String,\n declarationPath: Schema.String,\n },\n) {}\n\nexport class DeclarationKindMismatchError extends Schema.TaggedError<DeclarationKindMismatchError>()(\n \"DeclarationKindMismatchError\",\n {\n declarationPath: Schema.String,\n declaredKind: Schema.Literals([\"app\", \"component\"]),\n targetKind: Schema.Literals([\"app\", \"component\"]),\n },\n) {}\n\nexport class CallbackPrefixError extends Schema.TaggedError<CallbackPrefixError>()(\n \"CallbackPrefixError\",\n {\n declarationPath: Schema.String,\n contractId: Schema.String,\n componentName: Schema.String,\n },\n) {}\n\nexport const CodegenError = Schema.Union([\n SnapshotError,\n BuildError,\n MissingImplFileError,\n MissingSpecFileError,\n SpecMissingDefaultGroupSpecError,\n ComponentNodeGroupError,\n RemoveBusyError,\n SpecImportsServerError,\n InvalidMiddlewareAttachmentError,\n ImplMissingSpecImportError,\n ImplMissingDefaultLayerError,\n ImplNotFinalizedError,\n ImplMissingFunctionsError,\n ImplMissingMiddlewareError,\n ParentChildNameCollisionError,\n InvalidTableDefaultExportError,\n InvalidTableFilenameError,\n DuplicateTableNameError,\n LegacySchemaFileError,\n ConflictingDocNameError,\n InvalidConvexConfigError,\n InvalidDeclarationError,\n HandWrittenConvexFileError,\n DeclarationKindMismatchError,\n CallbackPrefixError,\n]);\nexport type CodegenError = typeof CodegenError.Type;\n\nexport const isCodegenError = (error: unknown): error is CodegenError => {\n if (isBuildError(error)) return true;\n return Schema.is(CodegenError)(error);\n};\n\n// --- Per-variant rendering ---\n\nconst cross = Ansi.red(\"✘\");\n\nconst stemFromSpecPath = (specPath: string): string => {\n const lastSep = Math.max(\n specPath.lastIndexOf(\"/\"),\n specPath.lastIndexOf(\"\\\\\"),\n );\n const basename = lastSep < 0 ? specPath : specPath.slice(lastSep + 1);\n return basename.endsWith(\".spec.ts\")\n ? basename.slice(0, -\".spec.ts\".length)\n : basename;\n};\n\nconst singleLine = (...parts: ReadonlyArray<string>): string =>\n `${cross} ${parts.join(\"\")}`;\n\nconst renderMissingImplFileError = (error: MissingImplFileError): string =>\n singleLine(\n \"Spec \",\n formatPath(error.specPath),\n \" has no sibling impl; create \",\n formatPath(error.expectedImplPath),\n \" and default-export a GroupImpl layer from it.\",\n );\n\nconst renderMissingSpecFileError = (error: MissingSpecFileError): string =>\n singleLine(\n \"Impl \",\n formatPath(error.implPath),\n \" has no sibling spec; create \",\n formatPath(error.expectedSpecPath),\n \" and default-export a GroupSpec from it, or remove the impl.\",\n );\n\nconst renderSpecMissingDefaultGroupSpecError = (\n error: SpecMissingDefaultGroupSpecError,\n): string =>\n singleLine(\n \"Spec \",\n formatPath(error.specPath),\n \" must default-export a GroupSpec; build it with GroupSpec.make() or GroupSpec.makeNode().\",\n );\n\nconst renderSpecImportsServerError = (\n error: SpecImportsServerError,\n): string => {\n const importers = error.importerPaths.join(\", \");\n return singleLine(\n \"Spec \",\n formatPath(error.specPath),\n ` reaches a module that imports \\`@confect/server\\`: ${importers}. Spec modules are bundled into your client, so anything they import ships to the browser—move the server logic into a \\`*.impl.ts\\` module, or use \\`import type\\` if you only need the types.`,\n );\n};\n\nconst renderImplMissingSpecImportError = (\n error: ImplMissingSpecImportError,\n): string => {\n const stem = stemFromSpecPath(error.expectedSpecPath);\n return singleLine(\n \"Impl \",\n formatPath(error.implPath),\n ` does not import its sibling spec; add \\`import ${stem} from \"./${stem}.spec.js\"\\` and pass it to FunctionImpl.make/GroupImpl.make.`,\n );\n};\n\nconst renderImplMissingDefaultLayerError = (\n error: ImplMissingDefaultLayerError,\n): string =>\n singleLine(\n \"Impl \",\n formatPath(error.implPath),\n \" must default-export a GroupImpl layer; wrap your handlers with `GroupImpl.make(databaseSchema, groupSpec).pipe(Layer.provide(...))` and `export default` it.\",\n );\n\nconst renderImplNotFinalizedError = (error: ImplNotFinalizedError): string =>\n singleLine(\n \"Impl \",\n formatPath(error.implPath),\n \" is not finalized; append `GroupImpl.finalize` to the end of the pipeline (e.g. `GroupImpl.make(databaseSchema, group).pipe(Layer.provide(...), GroupImpl.finalize)`).\",\n );\n\nconst renderImplMissingFunctionsError = (\n error: ImplMissingFunctionsError,\n): string => {\n const names = error.missingFunctionNames.join(\", \");\n return singleLine(\n \"Impl \",\n formatPath(error.implPath),\n ` does not implement every function declared by group \\`${error.groupPath}\\`; missing: ${names}. Add a \\`FunctionImpl.make\\` for each missing function and provide it to the group layer.`,\n );\n};\n\nconst renderImplMissingMiddlewareError = (\n error: ImplMissingMiddlewareError,\n): string => {\n const keys = error.missingMiddlewareKeys.join(\", \");\n return singleLine(\n \"Impl \",\n formatPath(error.implPath),\n ` does not implement every middleware attached to group \\`${error.groupPath}\\`; missing: ${keys}. Provide a \\`MiddlewareImpl.make\\` (or \\`makeByFunctionType\\`/\\`provides\\`) layer for each missing middleware to the group layer.`,\n );\n};\n\nconst renderInvalidTableDefaultExportError = (\n error: InvalidTableDefaultExportError,\n): string =>\n singleLine(\n \"Table \",\n formatPath(error.tablePath),\n \" must default-export a Table (e.g. `export default Table.make({ ... })`); convert any named export to a default export.\",\n );\n\nconst renderInvalidTableFilenameError = (\n error: InvalidTableFilenameError,\n): string =>\n singleLine(\n \"Table \",\n formatPath(error.tablePath),\n ` has an invalid filename: ${error.reason} Convex table names must start with a letter and contain only letters, numbers, and underscores; leading underscores are reserved for system tables.`,\n );\n\nconst renderDuplicateTableNameError = (\n error: DuplicateTableNameError,\n): string => {\n const conflicts = error.collisions\n .map(\n ({ tableName, tablePaths }) =>\n `\\`${tableName}\\` (${tablePaths.join(\", \")})`,\n )\n .join(\"; \");\n return singleLine(\n `Multiple files under \\`confect/tables/\\` resolve to the same table name. Table names are derived from filenames, so each must be unique across the directory (including subdirectories); rename or remove all but one. Conflicts: ${conflicts}.`,\n );\n};\n\nconst renderConflictingDocNameError = (\n error: ConflictingDocNameError,\n): string => {\n const conflicts = pipe(\n error.collisions,\n Array.map(\n ({ docName, tableNames }) =>\n `\\`${docName}\\` (${Array.join(tableNames, \", \")})`,\n ),\n Array.join(\"; \"),\n );\n return singleLine(\n `Multiple tables fold to the same generated document type name. Table names are converted to PascalCase (so \\`user_profiles\\` and \\`userProfiles\\` both become \\`UserProfilesDoc\\`); rename all but one of each colliding group. Conflicts: ${conflicts}.`,\n );\n};\n\nconst renderInvalidConvexConfigError = (\n error: InvalidConvexConfigError,\n): string =>\n singleLine(\n \"Convex config \",\n formatPath(error.configPath),\n ` could not be evaluated: ${error.reason}`,\n );\n\nconst renderLegacySchemaFileError = (error: LegacySchemaFileError): string =>\n singleLine(\n \"Found a legacy \",\n formatPath(error.schemaPath),\n \". Delete it: tables in `confect/tables/*.ts` are now the single source of truth, and the runtime schema is generated as `confect/_generated/schema.ts`.\",\n );\n\nconst renderParentChildNameCollisionError = (\n error: ParentChildNameCollisionError,\n): string =>\n singleLine(\n \"Spec \",\n formatPath(error.parentSpecPath),\n ` declares a ${error.collisionKind} \\`${error.collisionName}\\` whose name collides with the sibling subdirectory spec `,\n formatPath(error.childSpecPath),\n `. Rename one of them so the assembled spec has a unique key at this path.`,\n );\n\n/**\n * Render any {@link CodegenError} into a styled, ready-to-print string.\n * Single-error variants render to a one-line `✘`-prefixed message;\n * `BundleFailedError` (the only multi-error variant) renders to a header plus\n * an esbuild diagnostic block.\n */\nexport const renderCodegenError = (error: CodegenError): string => {\n if (isBuildError(error)) return renderBuildError(error);\n // The renderer pipeline below is at Effect's pipe arity limit, so the\n // fork's errors render here.\n if (error._tag === \"ComponentNodeGroupError\") {\n return singleLine(\n `Group \"${error.groupPath}\" in ${error.specPath} uses the Node runtime. Convex components do not support Node.js functions.`,\n );\n }\n if (error._tag === \"RemoveBusyError\") {\n return singleLine(\n \"Could not remove \",\n formatPath(error.path),\n ` after ${error.attempts} attempts because it is busy. Close other tools using it and try again.`,\n );\n }\n if (error._tag === \"InvalidDeclarationError\") {\n return singleLine(\n \"Declaration \",\n formatPath(error.declarationPath),\n ` is invalid: ${error.reason}`,\n );\n }\n if (error._tag === \"DeclarationKindMismatchError\") {\n return singleLine(\n \"Declaration \",\n formatPath(error.declarationPath),\n ` declares kind \"${error.declaredKind}\", but the target directory is kind \"${error.targetKind}\".`,\n );\n }\n if (error._tag === \"CallbackPrefixError\") {\n return singleLine(\n \"Callback contract \",\n `\"${error.contractId}\" in `,\n formatPath(error.declarationPath),\n ` must start with \"${error.componentName}/\" for component \"${error.componentName}\".`,\n );\n }\n if (error._tag === \"HandWrittenConvexFileError\") {\n return singleLine(\n \"Found a hand-written \",\n formatPath(error.convexPath),\n \". `confect codegen` writes it from \",\n formatPath(error.declarationPath),\n \" now; move its contents there and delete the file.\",\n );\n }\n return Match.value(error).pipe(\n Match.tag(\"SnapshotError\", ({ reason, relativePath, pathSegments }) =>\n singleLine(\n `Invalid generation metadata (${reason})`,\n relativePath === \"\" ? \"\" : ` for ${relativePath}`,\n pathSegments.length === 0 ? \".\" : ` at ${pathSegments.join(\"/\")}.`,\n ),\n ),\n Match.tag(\"MissingImplFileError\", renderMissingImplFileError),\n Match.tag(\"MissingSpecFileError\", renderMissingSpecFileError),\n Match.tag(\n \"SpecMissingDefaultGroupSpecError\",\n renderSpecMissingDefaultGroupSpecError,\n ),\n Match.tag(\"SpecImportsServerError\", renderSpecImportsServerError),\n Match.tag(\"InvalidMiddlewareAttachmentError\", (attachmentError) =>\n singleLine(\n \"Spec \",\n formatPath(attachmentError.specPath),\n `: ${attachmentError.message}`,\n ),\n ),\n Match.tag(\"ImplMissingSpecImportError\", renderImplMissingSpecImportError),\n Match.tag(\n \"ImplMissingDefaultLayerError\",\n renderImplMissingDefaultLayerError,\n ),\n Match.tag(\"ImplNotFinalizedError\", renderImplNotFinalizedError),\n Match.tag(\"ImplMissingFunctionsError\", renderImplMissingFunctionsError),\n Match.tag(\"ImplMissingMiddlewareError\", renderImplMissingMiddlewareError),\n Match.tag(\n \"ParentChildNameCollisionError\",\n renderParentChildNameCollisionError,\n ),\n Match.tag(\n \"InvalidTableDefaultExportError\",\n renderInvalidTableDefaultExportError,\n ),\n Match.tag(\"InvalidTableFilenameError\", renderInvalidTableFilenameError),\n Match.tag(\"DuplicateTableNameError\", renderDuplicateTableNameError),\n Match.tag(\"LegacySchemaFileError\", renderLegacySchemaFileError),\n Match.tag(\"ConflictingDocNameError\", renderConflictingDocNameError),\n Match.tag(\"InvalidConvexConfigError\", renderInvalidConvexConfigError),\n Match.exhaustive,\n );\n};\n\nexport const logCodegenError = (error: CodegenError) =>\n Console.error(renderCodegenError(error));\n\n// --- Effect combinators ---\n\n/**\n * Log any {@link CodegenError} thrown by `effect` and propagate the failure\n * unchanged so the caller's error channel is preserved.\n */\nexport const tapAndLog = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n): Effect.Effect<A, E, R> =>\n effect.pipe(\n Effect.tapError((error) =>\n isCodegenError(error) ? logCodegenError(error) : Effect.void,\n ),\n );\n\n/**\n * Catch any {@link CodegenError} thrown by `effect`, log it, and resolve to\n * `Option.none()`. Success resolves to `Option.some(value)`.\n */\n// oxlint-disable effecttsgo/unsafe-effect-type-assertion -- catchIf removes the error variant selected by this refinement.\nexport const catchAndLog = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n): Effect.Effect<Option.Option<A>, Exclude<E, CodegenError>, R> =>\n Effect.catchIf(Effect.map(effect, Option.some<A>), isCodegenError, (error) =>\n logCodegenError(error).pipe(Effect.as(Option.none<A>())),\n ) as Effect.Effect<Option.Option<A>, Exclude<E, CodegenError>, R>;\n// oxlint-enable effecttsgo/unsafe-effect-type-assertion\n"],"mappings":";;;;;;;;;;;;AAcA,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,UAAU,OAAO;CACjB,kBAAkB,OAAO;AAC3B,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,UAAU,OAAO;CACjB,kBAAkB,OAAO;AAC3B,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,mCAAb,cAAsD,OAAO,YAA8C,CAAC,CAC1G,oCACA,EACE,UAAU,OAAO,OACnB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,kBAAb,cAAqC,OAAO,YAA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MAAM,OAAO,aAAa,KAAK,GAAG,EAAE,EAClE,CACF,GACA,MAAM,IAAI,wBAAwB,0BAA0B,GAC5D,MAAM,IAAI,wBAAwB,0BAA0B,GAC5D,MAAM,IACJ,oCACA,sCACF,GACA,MAAM,IAAI,0BAA0B,4BAA4B,GAChE,MAAM,IAAI,qCAAqC,oBAC7C,WACE,SACA,WAAW,gBAAgB,QAAQ,GACnC,KAAK,gBAAgB,SACvB,CACF,GACA,MAAM,IAAI,8BAA8B,gCAAgC,GACxE,MAAM,IACJ,gCACA,kCACF,GACA,MAAM,IAAI,yBAAyB,2BAA2B,GAC9D,MAAM,IAAI,6BAA6B,+BAA+B,GACtE,MAAM,IAAI,8BAA8B,gCAAgC,GACxE,MAAM,IACJ,iCACA,mCACF,GACA,MAAM,IACJ,kCACA,oCACF,GACA,MAAM,IAAI,6BAA6B,+BAA+B,GACtE,MAAM,IAAI,2BAA2B,6BAA6B,GAClE,MAAM,IAAI,yBAAyB,2BAA2B,GAC9D,MAAM,IAAI,2BAA2B,6BAA6B,GAClE,MAAM,IAAI,4BAA4B,8BAA8B,GACpE,MAAM,UACR;AACF;AAEA,MAAa,mBAAmB,UAC9B,QAAQ,MAAM,mBAAmB,KAAK,CAAC;;;;;AAQzC,MAAa,aACX,WAEA,OAAO,KACL,OAAO,UAAU,UACf,eAAe,KAAK,IAAI,gBAAgB,KAAK,IAAI,OAAO,IAC1D,CACF"}
1
+ {"version":3,"file":"CodegenError.mjs","names":["Ansi.red"],"sources":["../src/CodegenError.ts"],"sourcesContent":["import * as Array from \"effect/Array\";\nimport * as Console from \"effect/Console\";\nimport { pipe } from \"effect/Function\";\nimport * as Effect from \"effect/Effect\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport { BuildError, isBuildError } from \"./BuildError.js\";\nimport { SnapshotError } from \"./SnapshotError.js\";\nimport * as Ansi from \"./Ansi.js\";\nimport { formatPath, renderBuildError } from \"./log.js\";\n\n// --- Variants ---\n\nexport class MissingImplFileError extends Schema.TaggedError<MissingImplFileError>()(\n \"MissingImplFileError\",\n {\n specPath: Schema.String,\n expectedImplPath: Schema.String,\n },\n) {}\n\nexport class MissingSpecFileError extends Schema.TaggedError<MissingSpecFileError>()(\n \"MissingSpecFileError\",\n {\n implPath: Schema.String,\n expectedSpecPath: Schema.String,\n },\n) {}\n\nexport class SpecMissingDefaultGroupSpecError extends Schema.TaggedError<SpecMissingDefaultGroupSpecError>()(\n \"SpecMissingDefaultGroupSpecError\",\n {\n specPath: Schema.String,\n },\n) {}\n\nexport class RemoveBusyError extends Schema.TaggedError<RemoveBusyError>()(\n \"RemoveBusyError\",\n { path: Schema.String, attempts: Schema.Finite, cause: Schema.Unknown },\n) {}\n\nexport class ComponentNodeGroupError extends Schema.TaggedError<ComponentNodeGroupError>()(\n \"ComponentNodeGroupError\",\n {\n specPath: Schema.String,\n groupPath: Schema.String,\n },\n) {}\n\nexport class SpecImportsServerError extends Schema.TaggedError<SpecImportsServerError>()(\n \"SpecImportsServerError\",\n {\n specPath: Schema.String,\n importerPaths: Schema.Array(Schema.String),\n },\n) {}\n\nexport class InvalidMiddlewareAttachmentError extends Schema.TaggedError<InvalidMiddlewareAttachmentError>()(\n \"InvalidMiddlewareAttachmentError\",\n { specPath: Schema.String, message: Schema.String },\n) {}\n\nexport class ImplMissingSpecImportError extends Schema.TaggedError<ImplMissingSpecImportError>()(\n \"ImplMissingSpecImportError\",\n {\n implPath: Schema.String,\n expectedSpecPath: Schema.String,\n },\n) {}\n\nexport class ImplMissingDefaultLayerError extends Schema.TaggedError<ImplMissingDefaultLayerError>()(\n \"ImplMissingDefaultLayerError\",\n {\n implPath: Schema.String,\n },\n) {}\n\nexport class ImplNotFinalizedError extends Schema.TaggedError<ImplNotFinalizedError>()(\n \"ImplNotFinalizedError\",\n {\n implPath: Schema.String,\n },\n) {}\n\nexport class ImplMissingFunctionsError extends Schema.TaggedError<ImplMissingFunctionsError>()(\n \"ImplMissingFunctionsError\",\n {\n implPath: Schema.String,\n groupPath: Schema.String,\n missingFunctionNames: Schema.Array(Schema.String),\n },\n) {}\n\nexport class ImplMissingMiddlewareError extends Schema.TaggedError<ImplMissingMiddlewareError>()(\n \"ImplMissingMiddlewareError\",\n {\n implPath: Schema.String,\n groupPath: Schema.String,\n missingMiddlewareKeys: Schema.Array(Schema.String),\n },\n) {}\n\nexport class ParentChildNameCollisionError extends Schema.TaggedError<ParentChildNameCollisionError>()(\n \"ParentChildNameCollisionError\",\n {\n parentSpecPath: Schema.String,\n childSpecPath: Schema.String,\n collisionName: Schema.String,\n collisionKind: Schema.Literals([\"function\", \"group\"]),\n },\n) {}\n\nexport class InvalidTableDefaultExportError extends Schema.TaggedError<InvalidTableDefaultExportError>()(\n \"InvalidTableDefaultExportError\",\n {\n tablePath: Schema.String,\n },\n) {}\n\nexport class InvalidTableFilenameError extends Schema.TaggedError<InvalidTableFilenameError>()(\n \"InvalidTableFilenameError\",\n {\n tablePath: Schema.String,\n reason: Schema.String,\n },\n) {}\n\nexport class DuplicateTableNameError extends Schema.TaggedError<DuplicateTableNameError>()(\n \"DuplicateTableNameError\",\n {\n // Every table name that more than one file resolves to, each paired with\n // the colliding file paths. All collisions are captured in a single pass\n // so the user can fix them together rather than re-running codegen once\n // per conflict.\n collisions: Schema.Array(\n Schema.Struct({\n tableName: Schema.String,\n tablePaths: Schema.Array(Schema.String),\n }),\n ),\n },\n) {}\n\nexport class LegacySchemaFileError extends Schema.TaggedError<LegacySchemaFileError>()(\n \"LegacySchemaFileError\",\n {\n schemaPath: Schema.String,\n },\n) {}\n\nexport class ConflictingDocNameError extends Schema.TaggedError<ConflictingDocNameError>()(\n \"ConflictingDocNameError\",\n {\n collisions: Schema.Array(\n Schema.Struct({\n docName: Schema.String,\n tableNames: Schema.Array(Schema.String),\n }),\n ),\n },\n) {}\n\nexport class InvalidConvexConfigError extends Schema.TaggedError<InvalidConvexConfigError>()(\n \"InvalidConvexConfigError\",\n {\n configPath: Schema.String,\n reason: Schema.String,\n },\n) {}\n\nexport class InvalidDeclarationError extends Schema.TaggedError<InvalidDeclarationError>()(\n \"InvalidDeclarationError\",\n {\n declarationPath: Schema.String,\n reason: Schema.String,\n },\n) {}\n\nexport class HandWrittenConvexFileError extends Schema.TaggedError<HandWrittenConvexFileError>()(\n \"HandWrittenConvexFileError\",\n {\n convexPath: Schema.String,\n declarationPath: Schema.String,\n },\n) {}\n\nexport class UnownedConvexEntrypointError extends Schema.TaggedError<UnownedConvexEntrypointError>()(\n \"UnownedConvexEntrypointError\",\n { filePaths: Schema.Array(Schema.String) },\n) {}\n\nexport class DeclarationKindMismatchError extends Schema.TaggedError<DeclarationKindMismatchError>()(\n \"DeclarationKindMismatchError\",\n {\n declarationPath: Schema.String,\n declaredKind: Schema.Literals([\"app\", \"component\"]),\n targetKind: Schema.Literals([\"app\", \"component\"]),\n },\n) {}\n\nexport class CallbackPrefixError extends Schema.TaggedError<CallbackPrefixError>()(\n \"CallbackPrefixError\",\n {\n declarationPath: Schema.String,\n contractId: Schema.String,\n componentName: Schema.String,\n },\n) {}\n\nexport const CodegenError = Schema.Union([\n SnapshotError,\n BuildError,\n MissingImplFileError,\n MissingSpecFileError,\n SpecMissingDefaultGroupSpecError,\n ComponentNodeGroupError,\n RemoveBusyError,\n SpecImportsServerError,\n InvalidMiddlewareAttachmentError,\n ImplMissingSpecImportError,\n ImplMissingDefaultLayerError,\n ImplNotFinalizedError,\n ImplMissingFunctionsError,\n ImplMissingMiddlewareError,\n ParentChildNameCollisionError,\n InvalidTableDefaultExportError,\n InvalidTableFilenameError,\n DuplicateTableNameError,\n LegacySchemaFileError,\n ConflictingDocNameError,\n InvalidConvexConfigError,\n InvalidDeclarationError,\n HandWrittenConvexFileError,\n UnownedConvexEntrypointError,\n DeclarationKindMismatchError,\n CallbackPrefixError,\n]);\nexport type CodegenError = typeof CodegenError.Type;\n\nexport const isCodegenError = (error: unknown): error is CodegenError => {\n if (isBuildError(error)) return true;\n return Schema.is(CodegenError)(error);\n};\n\n// --- Per-variant rendering ---\n\nconst cross = Ansi.red(\"✘\");\n\nconst stemFromSpecPath = (specPath: string): string => {\n const lastSep = Math.max(\n specPath.lastIndexOf(\"/\"),\n specPath.lastIndexOf(\"\\\\\"),\n );\n const basename = lastSep < 0 ? specPath : specPath.slice(lastSep + 1);\n return basename.endsWith(\".spec.ts\")\n ? basename.slice(0, -\".spec.ts\".length)\n : basename;\n};\n\nconst singleLine = (...parts: ReadonlyArray<string>): string =>\n `${cross} ${parts.join(\"\")}`;\n\nconst renderMissingImplFileError = (error: MissingImplFileError): string =>\n singleLine(\n \"Spec \",\n formatPath(error.specPath),\n \" has no sibling impl; create \",\n formatPath(error.expectedImplPath),\n \" and default-export a GroupImpl layer from it.\",\n );\n\nconst renderMissingSpecFileError = (error: MissingSpecFileError): string =>\n singleLine(\n \"Impl \",\n formatPath(error.implPath),\n \" has no sibling spec; create \",\n formatPath(error.expectedSpecPath),\n \" and default-export a GroupSpec from it, or remove the impl.\",\n );\n\nconst renderSpecMissingDefaultGroupSpecError = (\n error: SpecMissingDefaultGroupSpecError,\n): string =>\n singleLine(\n \"Spec \",\n formatPath(error.specPath),\n \" must default-export a GroupSpec; build it with GroupSpec.make() or GroupSpec.makeNode().\",\n );\n\nconst renderSpecImportsServerError = (\n error: SpecImportsServerError,\n): string => {\n const importers = error.importerPaths.join(\", \");\n return singleLine(\n \"Spec \",\n formatPath(error.specPath),\n ` reaches a module that imports \\`@confect/server\\`: ${importers}. Spec modules are bundled into your client, so anything they import ships to the browser—move the server logic into a \\`*.impl.ts\\` module, or use \\`import type\\` if you only need the types.`,\n );\n};\n\nconst renderImplMissingSpecImportError = (\n error: ImplMissingSpecImportError,\n): string => {\n const stem = stemFromSpecPath(error.expectedSpecPath);\n return singleLine(\n \"Impl \",\n formatPath(error.implPath),\n ` does not import its sibling spec; add \\`import ${stem} from \"./${stem}.spec.js\"\\` and pass it to FunctionImpl.make/GroupImpl.make.`,\n );\n};\n\nconst renderImplMissingDefaultLayerError = (\n error: ImplMissingDefaultLayerError,\n): string =>\n singleLine(\n \"Impl \",\n formatPath(error.implPath),\n \" must default-export a GroupImpl layer; wrap your handlers with `GroupImpl.make(databaseSchema, groupSpec).pipe(Layer.provide(...))` and `export default` it.\",\n );\n\nconst renderImplNotFinalizedError = (error: ImplNotFinalizedError): string =>\n singleLine(\n \"Impl \",\n formatPath(error.implPath),\n \" is not finalized; append `GroupImpl.finalize` to the end of the pipeline (e.g. `GroupImpl.make(databaseSchema, group).pipe(Layer.provide(...), GroupImpl.finalize)`).\",\n );\n\nconst renderImplMissingFunctionsError = (\n error: ImplMissingFunctionsError,\n): string => {\n const names = error.missingFunctionNames.join(\", \");\n return singleLine(\n \"Impl \",\n formatPath(error.implPath),\n ` does not implement every function declared by group \\`${error.groupPath}\\`; missing: ${names}. Add a \\`FunctionImpl.make\\` for each missing function and provide it to the group layer.`,\n );\n};\n\nconst renderImplMissingMiddlewareError = (\n error: ImplMissingMiddlewareError,\n): string => {\n const keys = error.missingMiddlewareKeys.join(\", \");\n return singleLine(\n \"Impl \",\n formatPath(error.implPath),\n ` does not implement every middleware attached to group \\`${error.groupPath}\\`; missing: ${keys}. Provide a \\`MiddlewareImpl.make\\` (or \\`makeByFunctionType\\`/\\`provides\\`) layer for each missing middleware to the group layer.`,\n );\n};\n\nconst renderInvalidTableDefaultExportError = (\n error: InvalidTableDefaultExportError,\n): string =>\n singleLine(\n \"Table \",\n formatPath(error.tablePath),\n \" must default-export a Table (e.g. `export default Table.make({ ... })`); convert any named export to a default export.\",\n );\n\nconst renderInvalidTableFilenameError = (\n error: InvalidTableFilenameError,\n): string =>\n singleLine(\n \"Table \",\n formatPath(error.tablePath),\n ` has an invalid filename: ${error.reason} Convex table names must start with a letter and contain only letters, numbers, and underscores; leading underscores are reserved for system tables.`,\n );\n\nconst renderDuplicateTableNameError = (\n error: DuplicateTableNameError,\n): string => {\n const conflicts = error.collisions\n .map(\n ({ tableName, tablePaths }) =>\n `\\`${tableName}\\` (${tablePaths.join(\", \")})`,\n )\n .join(\"; \");\n return singleLine(\n `Multiple files under \\`confect/tables/\\` resolve to the same table name. Table names are derived from filenames, so each must be unique across the directory (including subdirectories); rename or remove all but one. Conflicts: ${conflicts}.`,\n );\n};\n\nconst renderConflictingDocNameError = (\n error: ConflictingDocNameError,\n): string => {\n const conflicts = pipe(\n error.collisions,\n Array.map(\n ({ docName, tableNames }) =>\n `\\`${docName}\\` (${Array.join(tableNames, \", \")})`,\n ),\n Array.join(\"; \"),\n );\n return singleLine(\n `Multiple tables fold to the same generated document type name. Table names are converted to PascalCase (so \\`user_profiles\\` and \\`userProfiles\\` both become \\`UserProfilesDoc\\`); rename all but one of each colliding group. Conflicts: ${conflicts}.`,\n );\n};\n\nconst renderInvalidConvexConfigError = (\n error: InvalidConvexConfigError,\n): string =>\n singleLine(\n \"Convex config \",\n formatPath(error.configPath),\n ` could not be evaluated: ${error.reason}`,\n );\n\nconst renderLegacySchemaFileError = (error: LegacySchemaFileError): string =>\n singleLine(\n \"Found a legacy \",\n formatPath(error.schemaPath),\n \". Delete it: tables in `confect/tables/*.ts` are now the single source of truth, and the runtime schema is generated as `confect/_generated/schema.ts`.\",\n );\n\nconst renderParentChildNameCollisionError = (\n error: ParentChildNameCollisionError,\n): string =>\n singleLine(\n \"Spec \",\n formatPath(error.parentSpecPath),\n ` declares a ${error.collisionKind} \\`${error.collisionName}\\` whose name collides with the sibling subdirectory spec `,\n formatPath(error.childSpecPath),\n `. Rename one of them so the assembled spec has a unique key at this path.`,\n );\n\n/**\n * Render any {@link CodegenError} into a styled, ready-to-print string.\n * Single-error variants render to a one-line `✘`-prefixed message;\n * `BundleFailedError` (the only multi-error variant) renders to a header plus\n * an esbuild diagnostic block.\n */\nexport const renderCodegenError = (error: CodegenError): string => {\n if (isBuildError(error)) return renderBuildError(error);\n // The renderer pipeline below is at Effect's pipe arity limit, so the\n // fork's errors render here.\n if (error._tag === \"ComponentNodeGroupError\") {\n return singleLine(\n `Group \"${error.groupPath}\" in ${error.specPath} uses the Node runtime. Convex components do not support Node.js functions.`,\n );\n }\n if (error._tag === \"RemoveBusyError\") {\n return singleLine(\n \"Could not remove \",\n formatPath(error.path),\n ` after ${error.attempts} attempts because it is busy. Close other tools using it and try again.`,\n );\n }\n if (error._tag === \"InvalidDeclarationError\") {\n return singleLine(\n \"Declaration \",\n formatPath(error.declarationPath),\n ` is invalid: ${error.reason}`,\n );\n }\n if (error._tag === \"DeclarationKindMismatchError\") {\n return singleLine(\n \"Declaration \",\n formatPath(error.declarationPath),\n ` declares kind \"${error.declaredKind}\", but the target directory is kind \"${error.targetKind}\".`,\n );\n }\n if (error._tag === \"CallbackPrefixError\") {\n return singleLine(\n \"Callback contract \",\n `\"${error.contractId}\" in `,\n formatPath(error.declarationPath),\n ` must start with \"${error.componentName}/\" for component \"${error.componentName}\".`,\n );\n }\n if (error._tag === \"HandWrittenConvexFileError\") {\n return singleLine(\n \"Found a hand-written \",\n formatPath(error.convexPath),\n \". `confect codegen` writes it from \",\n formatPath(error.declarationPath),\n \" now; move its contents there and delete the file.\",\n );\n }\n if (error._tag === \"UnownedConvexEntrypointError\") {\n return singleLine(\n error.filePaths.map((file) => formatPath(file)).join(\", \"),\n error.filePaths.length === 1 ? \" was\" : \" were\",\n \" not written by confect codegen. Generated files only re-export the registry; put authored code outside convex/. If a file is stale generated output, delete it and run codegen again.\",\n );\n }\n return Match.value(error).pipe(\n Match.tag(\"SnapshotError\", ({ reason, relativePath, pathSegments }) =>\n singleLine(\n `Invalid generation metadata (${reason})`,\n relativePath === \"\" ? \"\" : ` for ${relativePath}`,\n pathSegments.length === 0 ? \".\" : ` at ${pathSegments.join(\"/\")}.`,\n ),\n ),\n Match.tag(\"MissingImplFileError\", renderMissingImplFileError),\n Match.tag(\"MissingSpecFileError\", renderMissingSpecFileError),\n Match.tag(\n \"SpecMissingDefaultGroupSpecError\",\n renderSpecMissingDefaultGroupSpecError,\n ),\n Match.tag(\"SpecImportsServerError\", renderSpecImportsServerError),\n Match.tag(\"InvalidMiddlewareAttachmentError\", (attachmentError) =>\n singleLine(\n \"Spec \",\n formatPath(attachmentError.specPath),\n `: ${attachmentError.message}`,\n ),\n ),\n Match.tag(\"ImplMissingSpecImportError\", renderImplMissingSpecImportError),\n Match.tag(\n \"ImplMissingDefaultLayerError\",\n renderImplMissingDefaultLayerError,\n ),\n Match.tag(\"ImplNotFinalizedError\", renderImplNotFinalizedError),\n Match.tag(\"ImplMissingFunctionsError\", renderImplMissingFunctionsError),\n Match.tag(\"ImplMissingMiddlewareError\", renderImplMissingMiddlewareError),\n Match.tag(\n \"ParentChildNameCollisionError\",\n renderParentChildNameCollisionError,\n ),\n Match.tag(\n \"InvalidTableDefaultExportError\",\n renderInvalidTableDefaultExportError,\n ),\n Match.tag(\"InvalidTableFilenameError\", renderInvalidTableFilenameError),\n Match.tag(\"DuplicateTableNameError\", renderDuplicateTableNameError),\n Match.tag(\"LegacySchemaFileError\", renderLegacySchemaFileError),\n Match.tag(\"ConflictingDocNameError\", renderConflictingDocNameError),\n Match.tag(\"InvalidConvexConfigError\", renderInvalidConvexConfigError),\n Match.exhaustive,\n );\n};\n\nexport const logCodegenError = (error: CodegenError) =>\n Console.error(renderCodegenError(error));\n\n// --- Effect combinators ---\n\n/**\n * Log any {@link CodegenError} thrown by `effect` and propagate the failure\n * unchanged so the caller's error channel is preserved.\n */\nexport const tapAndLog = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n): Effect.Effect<A, E, R> =>\n effect.pipe(\n Effect.tapError((error) =>\n isCodegenError(error) ? logCodegenError(error) : Effect.void,\n ),\n );\n\n/**\n * Catch any {@link CodegenError} thrown by `effect`, log it, and resolve to\n * `Option.none()`. Success resolves to `Option.some(value)`.\n */\n// oxlint-disable effecttsgo/unsafe-effect-type-assertion -- catchIf removes the error variant selected by this refinement.\nexport const catchAndLog = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n): Effect.Effect<Option.Option<A>, Exclude<E, CodegenError>, R> =>\n Effect.catchIf(Effect.map(effect, Option.some<A>), isCodegenError, (error) =>\n logCodegenError(error).pipe(Effect.as(Option.none<A>())),\n ) as Effect.Effect<Option.Option<A>, Exclude<E, CodegenError>, R>;\n// oxlint-enable effecttsgo/unsafe-effect-type-assertion\n"],"mappings":";;;;;;;;;;;;AAcA,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,UAAU,OAAO;CACjB,kBAAkB,OAAO;AAC3B,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,UAAU,OAAO;CACjB,kBAAkB,OAAO;AAC3B,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,mCAAb,cAAsD,OAAO,YAA8C,CAAC,CAC1G,oCACA,EACE,UAAU,OAAO,OACnB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,kBAAb,cAAqC,OAAO,YAA6B,CAAC,CACxE,mBACA;CAAE,MAAM,OAAO;CAAQ,UAAU,OAAO;CAAQ,OAAO,OAAO;AAAQ,CACxE,CAAC,CAAC,CAAC;AAEH,IAAa,0BAAb,cAA6C,OAAO,YAAqC,CAAC,CACxF,2BACA;CACE,UAAU,OAAO;CACjB,WAAW,OAAO;AACpB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,yBAAb,cAA4C,OAAO,YAAoC,CAAC,CACtF,0BACA;CACE,UAAU,OAAO;CACjB,eAAe,OAAO,MAAM,OAAO,MAAM;AAC3C,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,mCAAb,cAAsD,OAAO,YAA8C,CAAC,CAC1G,oCACA;CAAE,UAAU,OAAO;CAAQ,SAAS,OAAO;AAAO,CACpD,CAAC,CAAC,CAAC;AAEH,IAAa,6BAAb,cAAgD,OAAO,YAAwC,CAAC,CAC9F,8BACA;CACE,UAAU,OAAO;CACjB,kBAAkB,OAAO;AAC3B,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,+BAAb,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I,yBAAyB,2BAA2B,GAC9D,MAAM,IAAI,6BAA6B,+BAA+B,GACtE,MAAM,IAAI,8BAA8B,gCAAgC,GACxE,MAAM,IACJ,iCACA,mCACF,GACA,MAAM,IACJ,kCACA,oCACF,GACA,MAAM,IAAI,6BAA6B,+BAA+B,GACtE,MAAM,IAAI,2BAA2B,6BAA6B,GAClE,MAAM,IAAI,yBAAyB,2BAA2B,GAC9D,MAAM,IAAI,2BAA2B,6BAA6B,GAClE,MAAM,IAAI,4BAA4B,8BAA8B,GACpE,MAAM,UACR;AACF;AAEA,MAAa,mBAAmB,UAC9B,QAAQ,MAAM,mBAAmB,KAAK,CAAC;;;;;AAQzC,MAAa,aACX,WAEA,OAAO,KACL,OAAO,UAAU,UACf,eAAe,KAAK,IAAI,gBAAgB,KAAK,IAAI,OAAO,IAC1D,CACF"}
@@ -1,9 +1,12 @@
1
1
  import { fromGroupModulePath, modulePath } from "./GroupPath.mjs";
2
+ import { ProjectRoot } from "./ProjectRoot.mjs";
2
3
  import { logFileAdded, logFileModified, logFileRemoved } from "./log.mjs";
4
+ import { UnownedConvexEntrypointError } from "./CodegenError.mjs";
3
5
  import { ConvexDirectory } from "./ConvexDirectory.mjs";
4
6
  import { ConfectDirectory } from "./ConfectDirectory.mjs";
5
7
  import { CodeBlockWriter } from "./CodeBlockWriter.mjs";
6
- import { removePathIfExists, toModuleImportPath } from "./utils.mjs";
8
+ import { crons, declaredHttp, http } from "./templates.mjs";
9
+ import { removePathIfExists, toModuleImportPath, toPosixPath } from "./utils.mjs";
7
10
  import { GroupPaths } from "./GroupPaths.mjs";
8
11
  import { functionPaths, plan } from "./GenerationSnapshot.mjs";
9
12
  import * as Effect from "effect/Effect";
@@ -14,6 +17,80 @@ import { pipe } from "effect/Function";
14
17
  import * as HashSet from "effect/HashSet";
15
18
  import * as Match from "effect/Match";
16
19
  //#region src/FunctionModule.ts
20
+ const RESERVED_CONVEX_TS_FILE_NAMES = /* @__PURE__ */ new Set([
21
+ "schema.ts",
22
+ "http.ts",
23
+ "crons.ts",
24
+ "auth.config.ts",
25
+ "convex.config.ts"
26
+ ]);
27
+ const getEntrypoints = Effect.gen(function* () {
28
+ const fs = yield* FileSystem.FileSystem;
29
+ const path = yield* Path.Path;
30
+ const convex = yield* ConvexDirectory.get;
31
+ const files = yield* fs.readDirectory(convex, { recursive: true });
32
+ const components = files.filter((file) => path.basename(file) === "convex.config.ts" && path.dirname(file) !== ".").map((file) => path.dirname(file) + path.sep);
33
+ return files.filter((file) => {
34
+ const base = path.basename(file);
35
+ return !file.startsWith("_generated" + path.sep) && !components.some((component) => file.startsWith(component)) && /\.(?:js|mjs|cjs|ts|tsx|mts|cts|jsx)$/.test(base) && !base.startsWith(".") && !base.startsWith("#") && (base.match(/\./g)?.length ?? 0) === 1 && base !== "schema.ts" && base !== "schema.js" && !file.includes(" ");
36
+ });
37
+ });
38
+ const tokenize = (source, modulePath, path) => {
39
+ const token = /\s+|\/\/[^\r\n]*|\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|[$A-Z_a-z][$\w]*|[{}()[\].,:;=]/y;
40
+ const tokens = [];
41
+ while (token.lastIndex < source.length) {
42
+ const match = token.exec(source);
43
+ if (match === null) return void 0;
44
+ const value = match[0];
45
+ if (/^\s|^\//.test(value)) continue;
46
+ if (value.startsWith("\"") || value.startsWith("'")) {
47
+ const literal = value.slice(1, -1);
48
+ tokens.push(JSON.stringify(literal.startsWith(".") ? path.resolve(path.dirname(modulePath), literal.replace(/\.js$/, "")) : literal));
49
+ } else tokens.push(value);
50
+ }
51
+ return tokens;
52
+ };
53
+ const matchesShape = (actual, expected) => {
54
+ let index = 0;
55
+ for (const token of expected) {
56
+ if (token === ";" && actual[index] !== ";") continue;
57
+ if (actual[index] === "," && (token === "}" || token === ")")) index++;
58
+ if (actual[index++] !== token) return false;
59
+ }
60
+ return index === actual.length;
61
+ };
62
+ const assertOwnedEntrypoints = Effect.gen(function* () {
63
+ const fs = yield* FileSystem.FileSystem;
64
+ const path = yield* Path.Path;
65
+ const convex = yield* ConvexDirectory.get;
66
+ const confect = yield* ConfectDirectory.get;
67
+ const projectRoot = yield* ProjectRoot.get;
68
+ const importFromConvex = (file) => toModuleImportPath(path.relative(convex, path.join(confect, file)));
69
+ const optional = /* @__PURE__ */ new Map([["http.ts", [yield* http({ httpImportPath: yield* importFromConvex("http.ts") }), yield* declaredHttp({
70
+ schemaImportPath: yield* importFromConvex("_generated/schema.ts"),
71
+ httpImportPath: yield* importFromConvex("http.ts")
72
+ })]], ["crons.ts", [yield* crons({ cronsImportPath: yield* importFromConvex("crons.ts") })]]]);
73
+ const refused = [];
74
+ for (const relative of yield* getEntrypoints) {
75
+ const absolute = path.join(convex, relative);
76
+ const tokens = tokenize(yield* fs.readFileString(absolute), absolute, path);
77
+ if (tokens !== void 0) {
78
+ if (optional.get(relative)?.some((template) => matchesShape(tokens, tokenize(template, absolute, path)))) continue;
79
+ if (path.extname(relative) === ".ts") {
80
+ const names = tokens.flatMap((token, index) => token === "export" && tokens[index + 1] === "const" ? [tokens[index + 2]] : []);
81
+ const group = yield* fromGroupModulePath(relative);
82
+ const template = yield* render({
83
+ functionNames: names,
84
+ registeredFunctionsImportPath: yield* registeredFunctionsImportPathForGroup(group, absolute),
85
+ useNode: tokens[0] === "\"use node\""
86
+ });
87
+ if (names.length > 0 && new Set(names).size === names.length && matchesShape(tokens, tokenize(template, absolute, path))) continue;
88
+ }
89
+ }
90
+ refused.push(toPosixPath(path, path.relative(projectRoot, absolute)));
91
+ }
92
+ if (refused.length > 0) return yield* new UnownedConvexEntrypointError({ filePaths: refused.sort() });
93
+ });
17
94
  const render = ({ functionNames, registeredFunctionsImportPath, useNode = false }) => renderEffect({
18
95
  functionNames,
19
96
  registeredFunctionsImportPath,
@@ -92,18 +169,9 @@ const applyFunctionPlan = Effect.fnUntraced(function* (plan) {
92
169
  yield* writeGroups(plan.changed);
93
170
  });
94
171
  const getGroupPathsFromFs = Effect.gen(function* () {
95
- const fs = yield* FileSystem.FileSystem;
96
172
  const path = yield* Path.Path;
97
- const convexDirectory = yield* ConvexDirectory.get;
98
- const RESERVED_CONVEX_TS_FILE_NAMES = /* @__PURE__ */ new Set([
99
- "schema.ts",
100
- "http.ts",
101
- "crons.ts",
102
- "auth.config.ts",
103
- "convex.config.ts"
104
- ]);
105
- const allConvexPaths = yield* fs.readDirectory(convexDirectory, { recursive: true });
106
- const groupPathArray = yield* pipe(allConvexPaths, Array.filter((convexPath) => path.extname(convexPath) === ".ts" && !RESERVED_CONVEX_TS_FILE_NAMES.has(path.basename(convexPath)) && path.basename(path.dirname(convexPath)) !== "_generated"), Effect.forEach((groupModulePath) => fromGroupModulePath(groupModulePath)));
173
+ const allConvexPaths = yield* getEntrypoints;
174
+ const groupPathArray = yield* pipe(allConvexPaths, Array.filter((convexPath) => path.extname(convexPath) === ".ts" && !RESERVED_CONVEX_TS_FILE_NAMES.has(path.basename(convexPath))), Effect.forEach((groupModulePath) => fromGroupModulePath(groupModulePath)));
107
175
  return GroupPaths.make(HashSet.fromIterable(groupPathArray));
108
176
  });
109
177
  const removeGroups = Effect.fnUntraced(function* (groupPaths) {
@@ -132,6 +200,6 @@ const writeGroups = (groups) => Effect.forEach(groups, Effect.fnUntraced(functio
132
200
  yield* Match.value(change).pipe(Match.when("Added", () => logFileAdded(modulePath$1)), Match.when("Modified", () => logFileModified(modulePath$1)), Match.when("Unchanged", () => Effect.void), Match.exhaustive);
133
201
  }));
134
202
  //#endregion
135
- export { applyFunctionPlan, generateFunctions, generateGroupModule, registeredFunctionsImportPathForGroup, removeGroups, render, writeGroups };
203
+ export { applyFunctionPlan, assertOwnedEntrypoints, generateFunctions, generateGroupModule, registeredFunctionsImportPathForGroup, removeGroups, render, writeGroups };
136
204
 
137
205
  //# sourceMappingURL=FunctionModule.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionModule.mjs","names":["GroupPath.modulePath","modulePath","GenerationSnapshot.plan","GenerationSnapshot.functionPaths","GroupPath.fromGroupModulePath"],"sources":["../src/FunctionModule.ts"],"sourcesContent":["import * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Match from \"effect/Match\";\nimport * as GenerationSnapshot from \"./GenerationSnapshot.js\";\nimport * as GroupPath from \"./GroupPath.js\";\nimport * as GroupPaths from \"./GroupPaths.js\";\nimport { CodeBlockWriter } from \"./CodeBlockWriter.js\";\nimport { logFileAdded, logFileModified, logFileRemoved } from \"./log.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\nimport { ConvexDirectory } from \"./ConvexDirectory.js\";\nimport { removePathIfExists, toModuleImportPath } from \"./utils.js\";\n\nexport const render = ({\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: Parameters<typeof renderEffect>[0]) =>\n renderEffect({ functionNames, registeredFunctionsImportPath, useNode });\n\nconst renderEffect = Effect.fnUntraced(function* ({\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: {\n functionNames: ReadonlyArray<string>;\n registeredFunctionsImportPath: string;\n useNode?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n if (useNode) {\n yield* cbw.writeLine(`\"use node\";`);\n yield* cbw.blankLine();\n }\n\n yield* cbw.writeLine(\n `import registeredFunctions from \"${registeredFunctionsImportPath}\";`,\n );\n yield* cbw.newLine();\n yield* Effect.forEach(functionNames, (name) =>\n cbw.writeLine(`export const ${name} = registeredFunctions.${name};`),\n );\n\n return yield* cbw.toString();\n});\n\nexport const generateGroupModule = ({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: Parameters<typeof generateGroupModuleEffect>[0]) =>\n generateGroupModuleEffect({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n useNode,\n });\n\nconst generateGroupModuleEffect = Effect.fnUntraced(function* ({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: {\n groupPath: GroupPath.GroupPath;\n functionNames: ReadonlyArray<string>;\n registeredFunctionsImportPath: string;\n useNode?: boolean;\n}) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n\n const directoryPath = path.dirname(modulePath);\n if (!(yield* fs.exists(directoryPath))) {\n yield* fs.makeDirectory(directoryPath, { recursive: true });\n }\n\n const functionsContentsString = yield* render({\n functionNames,\n registeredFunctionsImportPath,\n useNode,\n });\n\n if (!(yield* fs.exists(modulePath))) {\n yield* fs.writeFileString(modulePath, functionsContentsString);\n return \"Added\" as const;\n }\n const existing = yield* fs.readFileString(modulePath);\n if (existing !== functionsContentsString) {\n yield* fs.writeFileString(modulePath, functionsContentsString);\n return \"Modified\" as const;\n }\n return \"Unchanged\" as const;\n});\n\n/**\n * Compute the module import specifier (relative to `modulePath`) for a group's\n * registry file under `confect/_generated/registeredFunctions/`. The registry\n * path mirrors the group's path one-to-one (see\n * `registeredFunctionsRelativePath` in `LeafModule.ts`) for both Convex and\n * Node groups.\n */\nexport const registeredFunctionsImportPathForGroup = Effect.fnUntraced(\n function* (groupPath: GroupPath.GroupPath, modulePath: string) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const registeredFunctionsPath =\n path.join(\n confectDirectory,\n \"_generated\",\n \"registeredFunctions\",\n ...groupPath.pathSegments,\n ) + \".ts\";\n\n return yield* toModuleImportPath(\n path.relative(path.dirname(modulePath), registeredFunctionsPath),\n );\n },\n);\n\nconst logGroupPaths = Effect.fnUntraced(function* <R>(\n groupPaths: GroupPaths.GroupPaths,\n logFn: (fullPath: string) => Effect.Effect<void, never, R>,\n): Effect.fn.Return<void, never, R | Path.Path | ConvexDirectory> {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.forEach(\n groupPaths,\n Effect.fnUntraced(function* (gp: GroupPath.GroupPath) {\n const relativeModulePath = yield* GroupPath.modulePath(gp);\n yield* logFn(path.join(convexDirectory, relativeModulePath));\n }),\n );\n});\n\nexport const generateFunctions = Effect.fnUntraced(function* (\n snapshot: GenerationSnapshot.GenerationSnapshot,\n) {\n const groupPathsFromFs = yield* getGroupPathsFromFs;\n yield* applyFunctionPlan(GenerationSnapshot.plan(snapshot, groupPathsFromFs));\n return GenerationSnapshot.functionPaths(snapshot);\n});\n\nexport const applyFunctionPlan = Effect.fnUntraced(function* (\n plan: GenerationSnapshot.ModulePlan,\n) {\n const removed = GroupPaths.GroupPaths.make(\n HashSet.fromIterable(plan.removed),\n );\n yield* removeGroups(removed);\n yield* logGroupPaths(removed, logFileRemoved);\n yield* writeGroups(plan.changed);\n});\n\nconst getGroupPathsFromFs = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const RESERVED_CONVEX_TS_FILE_NAMES = new Set([\n \"schema.ts\",\n \"http.ts\",\n \"crons.ts\",\n \"auth.config.ts\",\n \"convex.config.ts\",\n ]);\n\n const allConvexPaths = yield* fs.readDirectory(convexDirectory, {\n recursive: true,\n });\n const groupPathArray = yield* pipe(\n allConvexPaths,\n Array.filter(\n (convexPath) =>\n path.extname(convexPath) === \".ts\" &&\n !RESERVED_CONVEX_TS_FILE_NAMES.has(path.basename(convexPath)) &&\n path.basename(path.dirname(convexPath)) !== \"_generated\",\n ),\n Effect.forEach((groupModulePath) =>\n GroupPath.fromGroupModulePath(groupModulePath),\n ),\n );\n return GroupPaths.GroupPaths.make(HashSet.fromIterable(groupPathArray));\n});\n\nexport const removeGroups = Effect.fnUntraced(function* (\n groupPaths: GroupPaths.GroupPaths,\n) {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.all(\n HashSet.map(groupPaths, (groupPath) =>\n Effect.gen(function* () {\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n\n yield* Effect.logDebug(`Removing group '${relativeModulePath}'...`);\n\n yield* removePathIfExists(modulePath);\n yield* Effect.logDebug(`Group '${relativeModulePath}' removed`);\n }),\n ),\n { concurrency: \"unbounded\" },\n );\n});\n\nexport const writeGroups = (\n groups: ReadonlyArray<GenerationSnapshot.GroupSummary>,\n) =>\n Effect.forEach(\n groups,\n Effect.fnUntraced(function* (group: GenerationSnapshot.GroupSummary) {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const relativeModulePath = yield* GroupPath.modulePath(group.path);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n const registeredFunctionsImportPath =\n yield* registeredFunctionsImportPathForGroup(group.path, modulePath);\n const change = yield* generateGroupModule({\n groupPath: group.path,\n functionNames: group.functionNames,\n registeredFunctionsImportPath,\n useNode: group.runtime === \"Node\",\n });\n yield* Match.value(change).pipe(\n Match.when(\"Added\", () => logFileAdded(modulePath)),\n Match.when(\"Modified\", () => logFileModified(modulePath)),\n Match.when(\"Unchanged\", () => Effect.void),\n Match.exhaustive,\n );\n }),\n );\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAa,UAAU,EACrB,eACA,+BACA,UAAU,YAEV,aAAa;CAAE;CAAe;CAA+B;AAAQ,CAAC;AAExE,MAAM,eAAe,OAAO,WAAW,WAAW,EAChD,eACA,+BACA,UAAU,SAKT;CACD,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,EAAE,CAAC;CAE3D,IAAI,SAAS;EACX,OAAO,IAAI,UAAU,aAAa;EAClC,OAAO,IAAI,UAAU;CACvB;CAEA,OAAO,IAAI,UACT,oCAAoC,8BAA8B,GACpE;CACA,OAAO,IAAI,QAAQ;CACnB,OAAO,OAAO,QAAQ,gBAAgB,SACpC,IAAI,UAAU,gBAAgB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AAkB,OAAO,gBAAgB;CAE/C,OAAO,OAAO,IACZ,QAAQ,IAAI,aAAa,cACvB,OAAO,IAAI,aAAa;EACtB,MAAM,qBAAqB,OAAOJ,WAAqB,SAAS;EAChE,MAAMC,eAAa,KAAK,KAAK,iBAAiB,kBAAkB;EAEhE,OAAO,OAAO,SAAS,mBAAmB,mBAAmB,KAAK;EAElE,OAAO,mBAAmBA,YAAU;EACpC,OAAO,OAAO,SAAS,UAAU,mBAAmB,UAAU;CAChE,CAAC,CACH,GACA,EAAE,aAAa,YAAY,CAC7B;AACF,CAAC;AAED,MAAa,eACX,WAEA,OAAO,QACL,QACA,OAAO,WAAW,WAAW,OAAwC;CACnE,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,kBAAkB,OAAO,gBAAgB;CAC/C,MAAM,qBAAqB,OAAOD,WAAqB,MAAM,IAAI;CACjE,MAAMC,eAAa,KAAK,KAAK,iBAAiB,kBAAkB;CAChE,MAAM,gCACJ,OAAO,sCAAsC,MAAM,MAAMA,YAAU;CACrE,MAAM,SAAS,OAAO,oBAAoB;EACxC,WAAW,MAAM;EACjB,eAAe,MAAM;EACrB;EACA,SAAS,MAAM,YAAY;CAC7B,CAAC;CACD,OAAO,MAAM,MAAM,MAAM,CAAC,CAAC,KACzB,MAAM,KAAK,eAAe,aAAaA,YAAU,CAAC,GAClD,MAAM,KAAK,kBAAkB,gBAAgBA,YAAU,CAAC,GACxD,MAAM,KAAK,mBAAmB,OAAO,IAAI,GACzC,MAAM,UACR;AACF,CAAC,CACH"}
1
+ {"version":3,"file":"FunctionModule.mjs","names":["templates.http","templates.declaredHttp","templates.crons","GroupPath.fromGroupModulePath","GroupPath.modulePath","modulePath","GenerationSnapshot.plan","GenerationSnapshot.functionPaths"],"sources":["../src/FunctionModule.ts"],"sourcesContent":["import * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Match from \"effect/Match\";\nimport { UnownedConvexEntrypointError } from \"./CodegenError.js\";\nimport * as templates from \"./templates.js\";\nimport * as GenerationSnapshot from \"./GenerationSnapshot.js\";\nimport * as GroupPath from \"./GroupPath.js\";\nimport * as GroupPaths from \"./GroupPaths.js\";\nimport { CodeBlockWriter } from \"./CodeBlockWriter.js\";\nimport { logFileAdded, logFileModified, logFileRemoved } from \"./log.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\nimport { ConvexDirectory } from \"./ConvexDirectory.js\";\nimport {\n removePathIfExists,\n toModuleImportPath,\n toPosixPath,\n} from \"./utils.js\";\nimport { ProjectRoot } from \"./ProjectRoot.js\";\n\nconst RESERVED_CONVEX_TS_FILE_NAMES = new Set([\n \"schema.ts\",\n \"http.ts\",\n \"crons.ts\",\n \"auth.config.ts\",\n \"convex.config.ts\",\n]);\n\n// Keep ownership and removal aligned with Convex's bundler entryPoints filter.\nconst getEntrypoints = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convex = yield* ConvexDirectory.get;\n const files = yield* fs.readDirectory(convex, { recursive: true });\n const components = files\n .filter(\n (file) =>\n path.basename(file) === \"convex.config.ts\" &&\n path.dirname(file) !== \".\",\n )\n .map((file) => path.dirname(file) + path.sep);\n return files.filter((file) => {\n const base = path.basename(file);\n return (\n !file.startsWith(\"_generated\" + path.sep) &&\n !components.some((component) => file.startsWith(component)) &&\n /\\.(?:js|mjs|cjs|ts|tsx|mts|cts|jsx)$/.test(base) &&\n !base.startsWith(\".\") &&\n !base.startsWith(\"#\") &&\n (base.match(/\\./g)?.length ?? 0) === 1 &&\n base !== \"schema.ts\" &&\n base !== \"schema.js\" &&\n !file.includes(\" \")\n );\n });\n});\n\nconst tokenize = (\n source: string,\n modulePath: string,\n path: Path.Path,\n): string[] | undefined => {\n const token =\n /\\s+|\\/\\/[^\\r\\n]*|\\/\\*[\\s\\S]*?\\*\\/|\"(?:\\\\.|[^\"\\\\\\r\\n])*\"|'(?:\\\\.|[^'\\\\\\r\\n])*'|[$A-Z_a-z][$\\w]*|[{}()[\\].,:;=]/y;\n const tokens: string[] = [];\n while (token.lastIndex < source.length) {\n const match = token.exec(source);\n if (match === null) return undefined;\n const value = match[0];\n if (/^\\s|^\\//.test(value)) continue;\n if (value.startsWith('\"') || value.startsWith(\"'\")) {\n const literal = value.slice(1, -1);\n tokens.push(\n JSON.stringify(\n literal.startsWith(\".\")\n ? path.resolve(\n path.dirname(modulePath),\n literal.replace(/\\.js$/, \"\"),\n )\n : literal,\n ),\n );\n } else tokens.push(value);\n }\n return tokens;\n};\n\nconst matchesShape = (\n actual: readonly string[],\n expected: readonly string[],\n) => {\n let index = 0;\n for (const token of expected) {\n if (token === \";\" && actual[index] !== \";\") continue;\n if (actual[index] === \",\" && (token === \"}\" || token === \")\")) index++;\n if (actual[index++] !== token) return false;\n }\n return index === actual.length;\n};\n\nexport const assertOwnedEntrypoints = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convex = yield* ConvexDirectory.get;\n const confect = yield* ConfectDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n const importFromConvex = (file: string) =>\n toModuleImportPath(path.relative(convex, path.join(confect, file)));\n const optional = new Map([\n [\n \"http.ts\",\n [\n yield* templates.http({\n httpImportPath: yield* importFromConvex(\"http.ts\"),\n }),\n yield* templates.declaredHttp({\n schemaImportPath: yield* importFromConvex(\"_generated/schema.ts\"),\n httpImportPath: yield* importFromConvex(\"http.ts\"),\n }),\n ],\n ],\n [\n \"crons.ts\",\n [\n yield* templates.crons({\n cronsImportPath: yield* importFromConvex(\"crons.ts\"),\n }),\n ],\n ],\n ]);\n const refused: string[] = [];\n for (const relative of yield* getEntrypoints) {\n const absolute = path.join(convex, relative);\n const tokens = tokenize(yield* fs.readFileString(absolute), absolute, path);\n if (tokens !== undefined) {\n if (\n optional\n .get(relative)\n ?.some((template) =>\n matchesShape(tokens, tokenize(template, absolute, path)!),\n )\n )\n continue;\n if (path.extname(relative) === \".ts\") {\n const names = tokens.flatMap((token, index) =>\n token === \"export\" && tokens[index + 1] === \"const\"\n ? [tokens[index + 2]!]\n : [],\n );\n const group = yield* GroupPath.fromGroupModulePath(relative);\n const template = yield* render({\n functionNames: names,\n registeredFunctionsImportPath:\n yield* registeredFunctionsImportPathForGroup(group, absolute),\n useNode: tokens[0] === '\"use node\"',\n });\n if (\n names.length > 0 &&\n new Set(names).size === names.length &&\n matchesShape(tokens, tokenize(template, absolute, path)!)\n )\n continue;\n }\n }\n refused.push(toPosixPath(path, path.relative(projectRoot, absolute)));\n }\n if (refused.length > 0)\n return yield* new UnownedConvexEntrypointError({\n filePaths: refused.sort(),\n });\n});\n\nexport const render = ({\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: Parameters<typeof renderEffect>[0]) =>\n renderEffect({ functionNames, registeredFunctionsImportPath, useNode });\n\nconst renderEffect = Effect.fnUntraced(function* ({\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: {\n functionNames: ReadonlyArray<string>;\n registeredFunctionsImportPath: string;\n useNode?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n if (useNode) {\n yield* cbw.writeLine(`\"use node\";`);\n yield* cbw.blankLine();\n }\n\n yield* cbw.writeLine(\n `import registeredFunctions from \"${registeredFunctionsImportPath}\";`,\n );\n yield* cbw.newLine();\n yield* Effect.forEach(functionNames, (name) =>\n cbw.writeLine(`export const ${name} = registeredFunctions.${name};`),\n );\n\n return yield* cbw.toString();\n});\n\nexport const generateGroupModule = ({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: Parameters<typeof generateGroupModuleEffect>[0]) =>\n generateGroupModuleEffect({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n useNode,\n });\n\nconst generateGroupModuleEffect = Effect.fnUntraced(function* ({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: {\n groupPath: GroupPath.GroupPath;\n functionNames: ReadonlyArray<string>;\n registeredFunctionsImportPath: string;\n useNode?: boolean;\n}) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n\n const directoryPath = path.dirname(modulePath);\n if (!(yield* fs.exists(directoryPath))) {\n yield* fs.makeDirectory(directoryPath, { recursive: true });\n }\n\n const functionsContentsString = yield* render({\n functionNames,\n registeredFunctionsImportPath,\n useNode,\n });\n\n if (!(yield* fs.exists(modulePath))) {\n yield* fs.writeFileString(modulePath, functionsContentsString);\n return \"Added\" as const;\n }\n const existing = yield* fs.readFileString(modulePath);\n if (existing !== functionsContentsString) {\n yield* fs.writeFileString(modulePath, functionsContentsString);\n return \"Modified\" as const;\n }\n return \"Unchanged\" as const;\n});\n\n/**\n * Compute the module import specifier (relative to `modulePath`) for a group's\n * registry file under `confect/_generated/registeredFunctions/`. The registry\n * path mirrors the group's path one-to-one (see\n * `registeredFunctionsRelativePath` in `LeafModule.ts`) for both Convex and\n * Node groups.\n */\nexport const registeredFunctionsImportPathForGroup = Effect.fnUntraced(\n function* (groupPath: GroupPath.GroupPath, modulePath: string) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const registeredFunctionsPath =\n path.join(\n confectDirectory,\n \"_generated\",\n \"registeredFunctions\",\n ...groupPath.pathSegments,\n ) + \".ts\";\n\n return yield* toModuleImportPath(\n path.relative(path.dirname(modulePath), registeredFunctionsPath),\n );\n },\n);\n\nconst logGroupPaths = Effect.fnUntraced(function* <R>(\n groupPaths: GroupPaths.GroupPaths,\n logFn: (fullPath: string) => Effect.Effect<void, never, R>,\n): Effect.fn.Return<void, never, R | Path.Path | ConvexDirectory> {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.forEach(\n groupPaths,\n Effect.fnUntraced(function* (gp: GroupPath.GroupPath) {\n const relativeModulePath = yield* GroupPath.modulePath(gp);\n yield* logFn(path.join(convexDirectory, relativeModulePath));\n }),\n );\n});\n\nexport const generateFunctions = Effect.fnUntraced(function* (\n snapshot: GenerationSnapshot.GenerationSnapshot,\n) {\n const groupPathsFromFs = yield* getGroupPathsFromFs;\n yield* applyFunctionPlan(GenerationSnapshot.plan(snapshot, groupPathsFromFs));\n return GenerationSnapshot.functionPaths(snapshot);\n});\n\nexport const applyFunctionPlan = Effect.fnUntraced(function* (\n plan: GenerationSnapshot.ModulePlan,\n) {\n const removed = GroupPaths.GroupPaths.make(\n HashSet.fromIterable(plan.removed),\n );\n yield* removeGroups(removed);\n yield* logGroupPaths(removed, logFileRemoved);\n yield* writeGroups(plan.changed);\n});\n\nconst getGroupPathsFromFs = Effect.gen(function* () {\n const path = yield* Path.Path;\n const allConvexPaths = yield* getEntrypoints;\n const groupPathArray = yield* pipe(\n allConvexPaths,\n Array.filter(\n (convexPath) =>\n path.extname(convexPath) === \".ts\" &&\n !RESERVED_CONVEX_TS_FILE_NAMES.has(path.basename(convexPath)),\n ),\n Effect.forEach((groupModulePath) =>\n GroupPath.fromGroupModulePath(groupModulePath),\n ),\n );\n return GroupPaths.GroupPaths.make(HashSet.fromIterable(groupPathArray));\n});\n\nexport const removeGroups = Effect.fnUntraced(function* (\n groupPaths: GroupPaths.GroupPaths,\n) {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.all(\n HashSet.map(groupPaths, (groupPath) =>\n Effect.gen(function* () {\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n\n yield* Effect.logDebug(`Removing group '${relativeModulePath}'...`);\n\n yield* removePathIfExists(modulePath);\n yield* Effect.logDebug(`Group '${relativeModulePath}' removed`);\n }),\n ),\n { concurrency: \"unbounded\" },\n );\n});\n\nexport const writeGroups = (\n groups: ReadonlyArray<GenerationSnapshot.GroupSummary>,\n) =>\n Effect.forEach(\n groups,\n Effect.fnUntraced(function* (group: GenerationSnapshot.GroupSummary) {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const relativeModulePath = yield* GroupPath.modulePath(group.path);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n const registeredFunctionsImportPath =\n yield* registeredFunctionsImportPathForGroup(group.path, modulePath);\n const change = yield* generateGroupModule({\n groupPath: group.path,\n functionNames: group.functionNames,\n registeredFunctionsImportPath,\n useNode: group.runtime === \"Node\",\n });\n yield* Match.value(change).pipe(\n Match.when(\"Added\", () => logFileAdded(modulePath)),\n Match.when(\"Modified\", () => logFileModified(modulePath)),\n Match.when(\"Unchanged\", () => Effect.void),\n Match.exhaustive,\n );\n }),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,MAAM,gDAAgC,IAAI,IAAI;CAC5C;CACA;CACA;CACA;CACA;AACF,CAAC;AAGD,MAAM,iBAAiB,OAAO,IAAI,aAAa;CAC7C,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,SAAS,OAAO,gBAAgB;CACtC,MAAM,QAAQ,OAAO,GAAG,cAAc,QAAQ,EAAE,WAAW,KAAK,CAAC;CACjE,MAAM,aAAa,MAChB,QACE,SACC,KAAK,SAAS,IAAI,MAAM,sBACxB,KAAK,QAAQ,IAAI,MAAM,GAC3B,CAAC,CACA,KAAK,SAAS,KAAK,QAAQ,IAAI,IAAI,KAAK,GAAG;CAC9C,OAAO,MAAM,QAAQ,SAAS;EAC5B,MAAM,OAAO,KAAK,SAAS,IAAI;EAC/B,OACE,CAAC,KAAK,WAAW,eAAe,KAAK,GAAG,KACxC,CAAC,WAAW,MAAM,cAAc,KAAK,WAAW,SAAS,CAAC,KAC1D,uCAAuC,KAAK,IAAI,KAChD,CAAC,KAAK,WAAW,GAAG,KACpB,CAAC,KAAK,WAAW,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Name } from "../DocName.mjs";
14
14
  import { FunctionPaths, make } from "../FunctionPaths.mjs";
15
15
  import { diff, fromLoadedLeaves, update } from "../GenerationSnapshot.mjs";
16
- import { applyFunctionPlan, generateFunctions } from "../FunctionModule.mjs";
16
+ import { applyFunctionPlan, assertOwnedEntrypoints, generateFunctions } from "../FunctionModule.mjs";
17
17
  import { implPathForSpec, loadAll, registeredFunctionsRelativePath, validateAllImpls, withImplFiles } from "../LeafModule.mjs";
18
18
  import { TABLES_DIRNAME, discover, validate } from "../TableModule.mjs";
19
19
  import { planDeclarations } from "../EntryPoint.mjs";
@@ -59,6 +59,7 @@ const codegen = Command.make("codegen", flags, () => Effect.gen(function* () {
59
59
  yield* codegenHandler.pipe(Effect.asVoid, Effect.tap(() => logSuccess("Generated files are up-to-date")), tapAndLog);
60
60
  })).pipe(Command.provide(layer), Command.withDescription("Generate `confect/_generated` files and the contents of the `convex` directory (except `tsconfig.json`, and `convex.config.ts` unless `confect/app.ts` declares the backend)"));
61
61
  const generateWithSnapshot = Effect.gen(function* () {
62
+ yield* assertOwnedEntrypoints;
62
63
  yield* validateComponentConfiguration;
63
64
  yield* generateConfectGeneratedDirectory;
64
65
  const declared = yield* syncDeclaration;
@@ -1 +1 @@
1
- {"version":3,"file":"codegen.mjs","names":["DirectoryOptions.flags","CodegenError.tapAndLog","DirectoryOptions.layer","TableModule.discover","TableModule.validate","GenerationSnapshot.fromLoadedLeaves","FunctionModule.generateFunctions","EntryPoint.planDeclarations","GenerationSnapshot.update","FunctionModule.applyFunctionPlan","GenerationSnapshot.diff","CodegenError.ComponentNodeGroupError","ConvexConfig.componentName","ConvexConfig.CONVEX_CONFIG_FILENAME","Bundler.bundle","CodegenError.CallbackPrefixError","CodegenError.InvalidConvexConfigError","templates.componentContract","templates.assembledSpec","templates.registeredFunctionsForGroup","FunctionPaths.make","TableModule.TABLES_DIRNAME","templates.id","templates.tableWrapper","templates.runtimeSchema","templates.convexSchema","templates.schema","templates.services","DocName.fromTableName","CodegenError.ConflictingDocNameError","templates.docs","templates.refs","ConvexConfig.discoverInstalledComponents","templates.components","ConvexConfig.typeImportPath","CodegenError.InvalidDeclarationError","Bundler.resolveModule","Bundler.exportNames","ConvexConfig.resolveDefinition"],"sources":["../../src/confect/codegen.ts"],"sourcesContent":["import { App, Callback, Env, type GroupSpec, Spec } from \"@confect/core\";\nimport * as Command from \"effect/cli/Command\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as Result from \"effect/Result\";\nimport type * as PlatformError from \"effect/PlatformError\";\nimport type { BuildError } from \"../BuildError.js\";\nimport { pipe } from \"effect/Function\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Record from \"effect/Record\";\nimport type * as Scope from \"effect/Scope\";\nimport * as Bundler from \"../Bundler.js\";\nimport { fromBundlerError } from \"../BuildError.js\";\nimport * as CodegenError from \"../CodegenError.js\";\nimport { LegacySchemaFileError } from \"../CodegenError.js\";\nimport { ConfectDirectory } from \"../ConfectDirectory.js\";\nimport * as ConvexConfig from \"../ConvexConfig.js\";\nimport { ConvexDirectory } from \"../ConvexDirectory.js\";\nimport * as DirectoryOptions from \"../DirectoryOptions.js\";\nimport * as DocName from \"../DocName.js\";\nimport * as FunctionPaths from \"../FunctionPaths.js\";\nimport * as FunctionModule from \"../FunctionModule.js\";\nimport * as GenerationSnapshot from \"../GenerationSnapshot.js\";\nimport * as EntryPoint from \"../EntryPoint.js\";\nimport type { ImplModulePath } from \"../ImplModulePath.js\";\nimport {\n implPathForSpec,\n loadAll,\n registeredFunctionsRelativePath,\n validateAllImpls,\n withImplFiles,\n type LeafModule,\n type LoadedLeafModule,\n} from \"../LeafModule.js\";\nimport {\n logFileAdded,\n logFileModified,\n logFileRemoved,\n logPending,\n logSuccess,\n logWarn,\n} from \"../log.js\";\nimport { ProjectRoot } from \"../ProjectRoot.js\";\nimport { preserveComponentOutput } from \"../Rollback.js\";\nimport { assemblyNodesFromLeaves } from \"../SpecAssemblyNode.js\";\nimport * as TableModule from \"../TableModule.js\";\nimport * as templates from \"../templates.js\";\nimport {\n generateAuthConfig,\n generateCrons,\n generateHttp,\n removePathIfExists,\n toModuleImportPath,\n touchConvexSchema,\n writeFileStringAndLog,\n} from \"../utils.js\";\nimport { syncDeclaration, syncDeclaredHttp } from \"./declaration.js\";\n\nconst GENERATED_DIRNAME = \"_generated\";\n\nconst isComponent = Effect.map(\n ConvexDirectory.target,\n (target) => target.kind === \"component\",\n);\n\nconst GENERATED_SPEC_PATH = Effect.map(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"spec.ts\"),\n);\nconst GENERATED_SCHEMA_PATH = Effect.map(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"schema.ts\"),\n);\nconst GENERATED_CONVEX_SCHEMA_PATH = Effect.map(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"convexSchema.ts\"),\n);\nconst GENERATED_ID_PATH = Effect.map(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"id.ts\"),\n);\nconst GENERATED_COMPONENTS_PATH = Effect.map(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"components.ts\"),\n);\nconst GENERATED_TABLES_DIRNAME = Effect.map(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"tables\"),\n);\n\nconst LEGACY_PATHS = Effect.gen(function* () {\n const path = yield* Path.Path;\n\n return [\n \"spec.ts\",\n \"nodeSpec.ts\",\n \"impl.ts\",\n \"nodeImpl.ts\",\n path.join(GENERATED_DIRNAME, \"registeredFunctions.ts\"),\n path.join(GENERATED_DIRNAME, \"nodeRegisteredFunctions.ts\"),\n path.join(GENERATED_DIRNAME, \"impl.ts\"),\n path.join(GENERATED_DIRNAME, \"nodeImpl.ts\"),\n // `_generated/nodeSpec.ts` is not part of the generated output (all groups\n // live in `_generated/spec.ts`); delete any copy left by an older version.\n path.join(GENERATED_DIRNAME, \"nodeSpec.ts\"),\n ];\n});\n\nexport const codegen = Command.make(\"codegen\", DirectoryOptions.flags, () =>\n Effect.gen(function* () {\n yield* logPending(\"Performing initial sync…\");\n yield* codegenHandler.pipe(\n Effect.asVoid,\n Effect.tap(() => logSuccess(\"Generated files are up-to-date\")),\n CodegenError.tapAndLog,\n );\n }),\n).pipe(\n Command.provide(DirectoryOptions.layer),\n Command.withDescription(\n \"Generate `confect/_generated` files and the contents of the `convex` directory (except `tsconfig.json`, and `convex.config.ts` unless `confect/app.ts` declares the backend)\",\n ),\n);\n\nconst runCodegen = Effect.gen(function* () {\n yield* validateComponentConfiguration;\n yield* generateConfectGeneratedDirectory;\n // A declared backend's `convex.config.ts` and manifest come first: the\n // components registry below reads the config, and nothing may validate\n // against a manifest the current declaration did not produce.\n const declared = yield* syncDeclaration;\n // Reject a legacy `confect/schema.ts` up front so the user-facing\n // migration message surfaces before any bundler error from impl\n // validation (each impl imports `_generated/schema.ts`).\n yield* rejectLegacySchemaFile;\n // List `confect/tables/*.ts` (filename-only—no bundling yet) so the\n // `_generated/id.ts` constructor can be emitted *before* we bundle any\n // user-authored table module. Tables import from `_generated/id.ts` for\n // cross-table id refs, so it must exist on disk first.\n const tableModules = yield* TableModule.discover;\n yield* warnIfNoTables(tableModules);\n yield* generateIdConstructor(tableModules);\n // Tables and specs can use bound component IDs and schemas, so their\n // imports need the registry even on a project's first codegen run.\n yield* generateComponents;\n yield* validateCallbackPrefixes(declared);\n // Now that `_generated/id.ts` is on disk, bundle each table module and\n // check its default export is an `UnnamedTable`. Surface diagnostics\n // here (rather than later) so they appear before impl-validation noise.\n yield* TableModule.validate(tableModules);\n yield* validateNoDocNameCollisions(tableModules);\n yield* generateTableWrappers(tableModules);\n yield* removeObsoleteTableWrappers(tableModules);\n yield* generateRuntimeSchema(tableModules);\n const leaves = yield* loadAll;\n yield* rejectComponentNodeGroups(leaves);\n yield* removeLegacyFiles;\n const snapshot = yield* Effect.fromResult(\n GenerationSnapshot.fromLoadedLeaves(leaves),\n );\n yield* generateAssembledSpecs(leaves);\n // `_generated/api.ts`/`nodeApi.ts` are no longer imported by generated or\n // impl code (impls take the database schema from `_generated/schema`\n // directly), so remove any copies left over from earlier versions before\n // impl validation runs.\n yield* Effect.all(\n [\n removeGeneratedApi,\n generateRefs,\n generateComponentContract(tableModules),\n removeGeneratedNodeApi,\n generateDocs(tableModules),\n generateServices,\n generateConvexSchema(tableModules),\n ],\n { concurrency: \"unbounded\" },\n );\n yield* validateAllImpls(leaves);\n yield* generateGroupRegisteredFunctions(leaves);\n yield* removeObsoleteRegisteredFunctions(leaves);\n const [functionPaths] = yield* Effect.all(\n [\n FunctionModule.generateFunctions(snapshot),\n generateConvexSchemaReexport,\n logGenerated(\n Option.match(declared, {\n onNone: () => generateHttp,\n onSome: syncDeclaredHttp,\n }),\n ),\n logGenerated(generateCrons),\n Option.isNone(declared)\n ? logGenerated(generateAuthConfig)\n : Effect.succeedNone,\n ],\n { concurrency: \"unbounded\" },\n );\n if (Option.isSome(declared)) yield* generateTesting(declared.value);\n return {\n functionPaths,\n snapshot,\n };\n});\n\nexport const generateWithSnapshot = runCodegen.pipe(\n Effect.withSpan(\"Cli.codegen\"),\n);\n\nexport const makeCodegenHandler = (\n duringRestore?: Effect.Effect<void, never, Scope.Scope>,\n) =>\n preserveComponentOutput(generateWithSnapshot, duringRestore).pipe(\n Effect.tap(() => touchConvexSchema),\n Effect.map(({ functionPaths }) => ({ functionPaths })),\n );\n\nexport const codegenHandler = makeCodegenHandler();\n\nexport const updateDeclarations = Effect.fn(\"Cli.updateDeclarations\")(\n function* (\n snapshot: GenerationSnapshot.GenerationSnapshot,\n declarations: Array.NonEmptyReadonlyArray<EntryPoint.Declaration>,\n affectedImpls: ReadonlyArray<ImplModulePath>,\n ) {\n const path = yield* Path.Path;\n const { paths, tables } = EntryPoint.planDeclarations(\n declarations,\n affectedImpls,\n path,\n );\n yield* TableModule.validate(tables);\n return yield* withImplFiles(paths, (leaves) =>\n Effect.gen(function* () {\n yield* rejectComponentNodeGroups(leaves);\n const next = yield* Effect.fromResult(\n GenerationSnapshot.update(snapshot, leaves),\n );\n yield* validateAllImpls(leaves);\n yield* generateGroupRegisteredFunctions(leaves);\n yield* FunctionModule.applyFunctionPlan(\n GenerationSnapshot.diff(snapshot, next),\n );\n return next;\n }),\n );\n },\n);\n\n// Convex components cannot run Node.js functions, at any nesting depth.\nconst validateComponentGroupRuntime = (\n group: GroupSpec.AnyWithProps,\n groupPath: string,\n specPath: string,\n): Result.Result<void, CodegenError.ComponentNodeGroupError> =>\n Result.gen(function* () {\n if (group.runtime === \"Node\") {\n return yield* Result.fail(\n new CodegenError.ComponentNodeGroupError({ specPath, groupPath }),\n );\n }\n for (const [name, child] of Object.entries(group.groups)) {\n yield* validateComponentGroupRuntime(\n child,\n `${groupPath}.${name}`,\n specPath,\n );\n }\n });\n\nconst rejectComponentNodeGroups = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<LoadedLeafModule>,\n) {\n if ((yield* ConvexDirectory.target).kind === \"app\") return;\n yield* Effect.forEach(leaves, (leaf) =>\n Effect.fromResult(\n validateComponentGroupRuntime(\n leaf.spec,\n leaf.groupPathDot,\n leaf.relativePath,\n ),\n ),\n );\n});\n\nconst validateCallbackPrefixes = Effect.fnUntraced(function* (\n declared: Option.Option<App.Any>,\n) {\n if ((yield* ConvexDirectory.target).kind !== \"component\") return;\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const callbacksPath = path.join(yield* ConfectDirectory.get, \"callbacks.ts\");\n if (!(yield* fs.exists(callbacksPath))) return;\n const name = Option.isSome(declared)\n ? Env.name(App.env(declared.value))\n : yield* ConvexConfig.componentName(\n path.join(\n yield* ConvexDirectory.get,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n ),\n );\n const { module } = yield* Bundler.bundle(callbacksPath).pipe(\n Effect.mapError((error) => fromBundlerError(\"confect/callbacks.ts\", error)),\n );\n for (const contract of Object.values(module)) {\n if (Callback.isContract(contract) && !contract.id.startsWith(`${name}/`)) {\n return yield* new CodegenError.CallbackPrefixError({\n declarationPath: \"confect/callbacks.ts\",\n contractId: contract.id,\n componentName: name,\n });\n }\n }\n});\n\nconst validateComponentConfiguration = Effect.gen(function* () {\n return yield* Match.value((yield* ConvexDirectory.target).kind).pipe(\n Match.when(\"app\", () => Effect.void),\n Match.when(\"component\", () =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const authPath = path.join(confectDirectory, \"auth.ts\");\n if (yield* fs.exists(authPath)) {\n return yield* new CodegenError.InvalidConvexConfigError({\n configPath: authPath,\n reason:\n \"Components cannot configure application authentication. Pass identity explicitly through function arguments.\",\n });\n }\n }),\n ),\n Match.exhaustive,\n );\n});\n\nconst generateComponentContract = Effect.fnUntraced(function* (\n tables: ReadonlyArray<TableModule.TableModule>,\n) {\n return yield* Match.value((yield* ConvexDirectory.target).kind).pipe(\n Match.when(\"app\", () => Effect.void),\n Match.when(\"component\", () =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n const directory = yield* ConfectDirectory.get;\n const contents = yield* templates.componentContract({\n tableNames: Array.map(tables, (table) => table.tableName),\n });\n yield* writeFileStringAndLog(\n path.join(directory, GENERATED_DIRNAME, \"component.ts\"),\n contents,\n );\n }),\n ),\n Match.exhaustive,\n );\n});\n\nconst generateConfectGeneratedDirectory = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n if (!(yield* fs.exists(path.join(confectDirectory, \"_generated\")))) {\n yield* fs.makeDirectory(path.join(confectDirectory, \"_generated\"), {\n recursive: true,\n });\n yield* logFileAdded(path.join(confectDirectory, \"_generated\") + \"/\");\n }\n});\n\nconst removeLegacyFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const legacyPaths = yield* LEGACY_PATHS;\n\n yield* Effect.forEach(\n legacyPaths,\n Effect.fnUntraced(function* (relativePath: string) {\n const absolutePath = path.join(confectDirectory, relativePath);\n if (yield* fs.exists(absolutePath)) {\n yield* removePathIfExists(absolutePath);\n yield* logFileRemoved(absolutePath);\n }\n }),\n );\n});\n\nconst generateAssembledSpecs = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<LeafModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedSpecPath = yield* GENERATED_SPEC_PATH;\n\n // A single assembled spec holds every group regardless of runtime—a Node\n // group's `makeNode()` lives in its imported leaf spec, so the assembled\n // file is runtime-agnostic. Always emit it (even empty) so downstream\n // readers (`loadGeneratedSpec`, `generateRefs`) always find a spec module.\n const nodes = assemblyNodesFromLeaves(leaves);\n const specContents = yield* templates.assembledSpec({ nodes });\n yield* writeFileStringAndLog(\n path.join(confectDirectory, generatedSpecPath),\n specContents,\n );\n});\n\nconst generateGroupRegisteredFunctions = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<LoadedLeafModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n yield* Effect.forEach(\n leaves,\n Effect.fnUntraced(function* (leaf: LoadedLeafModule) {\n const registryRelativePath = yield* registeredFunctionsRelativePath(leaf);\n const registryPath = path.join(\n confectDirectory,\n \"_generated\",\n registryRelativePath,\n );\n const registryDir = path.dirname(registryPath);\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(registryDir))) {\n yield* fs.makeDirectory(registryDir, { recursive: true });\n }\n\n const implRelativePath = yield* implPathForSpec(leaf.relativePath);\n const schemaImportPath = yield* toModuleImportPath(\n path.relative(\n path.dirname(registryPath),\n path.join(confectDirectory, \"_generated\", \"schema.ts\"),\n ),\n );\n // The group's own leaf spec (sibling of its impl), referenced\n // type-only by the registry to shape its returned record.\n const specImportPath = yield* toModuleImportPath(\n path.relative(\n path.dirname(registryPath),\n path.join(confectDirectory, leaf.relativePath),\n ),\n );\n const implImportPath = yield* toModuleImportPath(\n path.relative(\n path.dirname(registryPath),\n path.join(confectDirectory, implRelativePath),\n ),\n );\n\n const contents = yield* templates.registeredFunctionsForGroup({\n spec: leaf.spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n });\n\n yield* writeFileStringAndLog(registryPath, contents);\n }),\n );\n});\n\nconst removeObsoleteRegisteredFunctions = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<LeafModule>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const registryRoot = path.join(\n confectDirectory,\n \"_generated\",\n \"registeredFunctions\",\n );\n\n if (!(yield* fs.exists(registryRoot))) {\n return;\n }\n\n const expected = new Set(\n yield* Effect.forEach(leaves, (leaf) =>\n registeredFunctionsRelativePath(leaf),\n ),\n );\n\n const existing = yield* fs.readDirectory(registryRoot, { recursive: true });\n yield* Effect.forEach(existing, (relativePath) => {\n if (path.extname(relativePath) !== \".ts\") {\n return Effect.void;\n }\n const normalized = path.join(\"registeredFunctions\", relativePath);\n if (!expected.has(normalized)) {\n return Effect.gen(function* () {\n const absolutePath = path.join(registryRoot, relativePath);\n if (yield* fs.exists(absolutePath)) {\n yield* removePathIfExists(absolutePath);\n yield* logFileRemoved(absolutePath);\n }\n });\n }\n return Effect.void;\n });\n});\n\nconst getGeneratedSpecPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedSpecPath = yield* GENERATED_SPEC_PATH;\n return path.join(confectDirectory, generatedSpecPath);\n});\n\nconst loadGeneratedSpec = Effect.gen(function* () {\n const specPath = yield* getGeneratedSpecPath;\n const { module: specModule } = yield* Bundler.bundle(specPath);\n const spec = specModule.default;\n\n if (!Spec.isSpec(spec)) {\n return yield* Effect.die(\n new Error(\"_generated/spec.ts does not export a valid Spec\"),\n );\n }\n\n return spec;\n});\n\nconst emptyFunctionPaths = FunctionPaths.FunctionPaths.make(HashSet.empty());\n\nexport const loadPreviousFunctionPaths = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const specPath = yield* getGeneratedSpecPath;\n\n if (!(yield* fs.exists(specPath))) {\n return emptyFunctionPaths;\n }\n\n const specResult = yield* loadGeneratedSpec.pipe(Effect.result);\n\n return Result.match(specResult, {\n onFailure: () => emptyFunctionPaths,\n onSuccess: (spec) => FunctionPaths.make(spec),\n });\n});\n\n/**\n * Remove a now-obsolete `_generated/<name>.ts` if present (and log it), for\n * projects upgrading from a version that still emitted it.\n */\nconst removeObsoleteGeneratedFile = Effect.fnUntraced(function* (\n fileName: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const filePath = path.join(confectDirectory, \"_generated\", fileName);\n\n if (yield* fs.exists(filePath)) {\n yield* removePathIfExists(filePath);\n yield* logFileRemoved(filePath);\n }\n});\n\n// `_generated/api.ts` is no longer imported by generated or impl code: impls\n// take the database schema (`_generated/schema`) directly, and per-group\n// registries reference the spec type-only. Remove any stale copy.\nconst removeGeneratedApi = removeObsoleteGeneratedFile(\"api.ts\");\n\n// `_generated/nodeApi.ts` is obsolete for the same reason.\nconst removeGeneratedNodeApi = removeObsoleteGeneratedFile(\"nodeApi.ts\");\n\n/**\n * The user-authored `confect/schema.ts` is no longer supported: codegen now\n * owns both `_generated/schema.ts` (runtime) and `_generated/convexSchema.ts`\n * (deploy), derived from a single scan of `confect/tables/*.ts`. Detect a stray\n * file and fail with a clear migration message—leaving it in place would\n * silently shadow the codegen-owned\n * `_generated/schema.ts`/`_generated/convexSchema.ts`.\n */\nconst rejectLegacySchemaFile = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const legacyPath = path.join(confectDirectory, \"schema.ts\");\n\n if (yield* fs.exists(legacyPath)) {\n return yield* new LegacySchemaFileError({ schemaPath: \"schema.ts\" });\n }\n});\n\n/**\n * Surface a yellow `⚠` warning when codegen sees no tables—either the\n * `confect/tables/` directory is missing or it contains no `.ts` files.\n * Generation still succeeds (emitting an empty `DatabaseSchema` and\n * `defineSchema({})`), since action-only/table-free Confect backends are\n * legal—but the warning catches the much more common case of a typoed directory\n * or files placed under the wrong root.\n */\nconst warnIfNoTables = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n tableModules.length === 0\n ? logWarn(\n `No tables discovered in \\`confect/${TableModule.TABLES_DIRNAME}/\\`. ` +\n `Generating an empty schema; add a \\`Table.make(...)\\` module under that ` +\n `directory unless this backend is intentionally tables-free.`,\n )\n : Effect.void;\n\nconst tableModuleBindings = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n generatedFilePath: string,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedDir = path.dirname(generatedFilePath);\n\n const generatedTablesDirname = yield* GENERATED_TABLES_DIRNAME;\n\n return yield* Effect.forEach(\n tableModules,\n Effect.fnUntraced(function* (tableModule: TableModule.TableModule) {\n const wrapperAbsolutePath = path.join(\n confectDirectory,\n generatedTablesDirname,\n `${tableModule.tableName}.ts`,\n );\n const importPath = yield* toModuleImportPath(\n path.relative(generatedDir, wrapperAbsolutePath),\n );\n return {\n importPath,\n tableName: tableModule.tableName,\n };\n }),\n );\n});\n\nconst generateIdConstructor = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedIdPath = yield* GENERATED_ID_PATH;\n const idPath = path.join(confectDirectory, generatedIdPath);\n\n const tableNames = Array.map(\n tableModules,\n (tableModule) => tableModule.tableName,\n );\n const contents = yield* Match.value(yield* ConvexDirectory.target).pipe(\n Match.when({ kind: \"app\" }, () => templates.id({ tableNames })),\n Match.when({ kind: \"component\" }, ({ scope }) =>\n templates.id({ tableNames, scope }),\n ),\n Match.exhaustive,\n );\n\n yield* writeFileStringAndLog(idPath, contents);\n});\n\nconst generateTableWrappers = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedTablesDirname = yield* GENERATED_TABLES_DIRNAME;\n const wrappersDir = path.join(confectDirectory, generatedTablesDirname);\n\n if (!(yield* fs.exists(wrappersDir))) {\n yield* fs.makeDirectory(wrappersDir, { recursive: true });\n }\n\n yield* Effect.forEach(\n tableModules,\n Effect.fnUntraced(function* (tableModule: TableModule.TableModule) {\n const wrapperPath = path.join(\n confectDirectory,\n generatedTablesDirname,\n `${tableModule.tableName}.ts`,\n );\n const unnamedAbsolutePath = path.join(\n confectDirectory,\n tableModule.relativePath,\n );\n const unnamedImportPath = yield* toModuleImportPath(\n path.relative(path.dirname(wrapperPath), unnamedAbsolutePath),\n );\n const contents = yield* templates.tableWrapper({\n tableName: tableModule.tableName,\n unnamedImportPath,\n component: yield* isComponent,\n });\n yield* writeFileStringAndLog(wrapperPath, contents);\n }),\n { concurrency: \"unbounded\" },\n );\n});\n\n/**\n * Remove any stale `_generated/tables/*.ts` wrapper whose source table has been\n * deleted or renamed. Mirrors `removeObsoleteRegisteredFunctions` for the\n * wrapper directory.\n */\nconst removeObsoleteTableWrappers = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedTablesDirname = yield* GENERATED_TABLES_DIRNAME;\n const wrappersDir = path.join(confectDirectory, generatedTablesDirname);\n\n if (!(yield* fs.exists(wrappersDir))) {\n return;\n }\n\n const expected = new Set(\n Array.map(tableModules, (tableModule) => `${tableModule.tableName}.ts`),\n );\n const existing = yield* fs.readDirectory(wrappersDir, { recursive: true });\n yield* Effect.forEach(existing, (entry) => {\n if (path.extname(entry) !== \".ts\") {\n return Effect.void;\n }\n if (!expected.has(entry)) {\n return Effect.gen(function* () {\n const absolutePath = path.join(wrappersDir, entry);\n if (yield* fs.exists(absolutePath)) {\n yield* removePathIfExists(absolutePath);\n yield* logFileRemoved(absolutePath);\n }\n });\n }\n return Effect.void;\n });\n});\n\nconst generateRuntimeSchema = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedSchemaPath = yield* GENERATED_SCHEMA_PATH;\n const schemaPath = path.join(confectDirectory, generatedSchemaPath);\n\n const bindings = yield* tableModuleBindings(tableModules, schemaPath);\n const contents = yield* templates.runtimeSchema({\n tableModules: bindings,\n component: yield* isComponent,\n });\n\n yield* writeFileStringAndLog(schemaPath, contents);\n});\n\nconst generateConvexSchema = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedConvexSchemaPath = yield* GENERATED_CONVEX_SCHEMA_PATH;\n const convexSchemaPath = path.join(\n confectDirectory,\n generatedConvexSchemaPath,\n );\n\n const bindings = yield* tableModuleBindings(tableModules, convexSchemaPath);\n const contents = yield* templates.convexSchema({ tableModules: bindings });\n\n yield* writeFileStringAndLog(convexSchemaPath, contents);\n});\n\nconst generateConvexSchemaReexport = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const convexDirectory = yield* ConvexDirectory.get;\n const generatedConvexSchemaRelativePath = yield* GENERATED_CONVEX_SCHEMA_PATH;\n\n const convexSchemaPath = path.join(convexDirectory, \"schema.ts\");\n const generatedConvexSchemaPath = path.join(\n confectDirectory,\n generatedConvexSchemaRelativePath,\n );\n\n const convexSchemaImportPath = yield* toModuleImportPath(\n path.relative(path.dirname(convexSchemaPath), generatedConvexSchemaPath),\n );\n\n const schemaContents = yield* templates.schema({\n convexSchemaImportPath,\n });\n\n yield* writeFileStringAndLog(convexSchemaPath, schemaContents);\n});\n\nconst generateServices = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const confectGeneratedDirectory = path.join(confectDirectory, \"_generated\");\n\n const servicesPath = path.join(confectGeneratedDirectory, \"services.ts\");\n const generatedSchemaPath = yield* GENERATED_SCHEMA_PATH;\n const schemaImportPath = yield* toModuleImportPath(\n path.relative(\n path.dirname(servicesPath),\n path.join(confectDirectory, generatedSchemaPath),\n ),\n );\n\n const servicesContentsString = yield* templates.services({\n schemaImportPath,\n component: yield* isComponent,\n });\n\n yield* writeFileStringAndLog(servicesPath, servicesContentsString);\n});\n\n/**\n * Two tables whose names fold to the same PascalCase document type name (e.g.\n * `user_profiles` and `userProfiles` → `UserProfilesDoc`) would emit duplicate\n * interfaces in `_generated/docs.ts`. Catch that up front with a clear error\n * rather than letting `tsc` report a duplicate-identifier later.\n */\nconst validateNoDocNameCollisions = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const collisions = pipe(\n tableModules,\n Array.groupBy((tableModule) =>\n DocName.fromTableName(tableModule.tableName),\n ),\n Record.toEntries,\n Array.filter(([, group]) => group.length > 1),\n Array.map(([docName, group]) => ({\n docName,\n tableNames: Array.map(group, (tableModule) => tableModule.tableName),\n })),\n );\n\n if (Array.isReadonlyArrayNonEmpty(collisions)) {\n return yield* new CodegenError.ConflictingDocNameError({ collisions });\n }\n});\n\nconst generateDocs = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const confectGeneratedDirectory = path.join(confectDirectory, \"_generated\");\n\n const docsPath = path.join(confectGeneratedDirectory, \"docs.ts\");\n const generatedSchemaPath = yield* GENERATED_SCHEMA_PATH;\n const schemaImportPath = yield* toModuleImportPath(\n path.relative(\n path.dirname(docsPath),\n path.join(confectDirectory, generatedSchemaPath),\n ),\n );\n\n const docsContentsString = yield* templates.docs({\n schemaImportPath,\n tables: Array.map(tableModules, (tableModule) => ({\n tableName: tableModule.tableName,\n docName: DocName.fromTableName(tableModule.tableName),\n })),\n });\n\n yield* writeFileStringAndLog(docsPath, docsContentsString);\n});\n\nconst generateRefs = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const confectGeneratedDirectory = path.join(confectDirectory, \"_generated\");\n const refsPath = path.join(confectGeneratedDirectory, \"refs.ts\");\n const refsDir = path.dirname(refsPath);\n const generatedSpecPath = yield* GENERATED_SPEC_PATH;\n\n const specImportPath = yield* toModuleImportPath(\n path.relative(refsDir, path.join(confectDirectory, generatedSpecPath)),\n );\n\n const refsContents = yield* templates.refs({ specImportPath });\n\n yield* writeFileStringAndLog(refsPath, refsContents);\n});\n\n/**\n * Generate `confect/_generated/components.ts`—the typed registry of Convex\n * components installed in `convex/convex.config.ts` (see\n * {@link templates.components}). The file is emitted even when there is no\n * `convex.config.ts` (as an empty registry) so the import surface stays stable.\n * It must exist before loading tables and specs because they may import bound\n * component IDs and schemas.\n */\nexport const generateComponents = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const convexDirectory = yield* ConvexDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n\n const confectGeneratedDirectory = path.join(\n confectDirectory,\n GENERATED_DIRNAME,\n );\n const generatedComponentsPath = yield* GENERATED_COMPONENTS_PATH;\n const componentsPath = path.join(confectDirectory, generatedComponentsPath);\n\n const convexConfigPath = path.join(\n convexDirectory,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n );\n\n const installedComponents = (yield* fs.exists(convexConfigPath))\n ? yield* ConvexConfig.discoverInstalledComponents(\n convexConfigPath,\n path.relative(projectRoot, convexConfigPath),\n (yield* ConvexDirectory.target).kind,\n )\n : [];\n\n const contents = yield* templates.components({\n components: Array.map(\n installedComponents,\n ({ name, componentDefinitionPath }) => ({\n name,\n typeImportPath: ConvexConfig.typeImportPath(\n path,\n componentDefinitionPath,\n confectGeneratedDirectory,\n ),\n }),\n ),\n });\n\n yield* writeFileStringAndLog(componentsPath, contents);\n});\n\nconst logGenerated = <E, R>(\n effect: Effect.Effect<\n Option.Option<{\n readonly change: \"Added\" | \"Modified\" | \"Unchanged\";\n readonly convexFilePath: string;\n }>,\n E,\n R\n >,\n) =>\n effect.pipe(\n Effect.tap(\n Option.match({\n onNone: () => Effect.void,\n onSome: ({ change, convexFilePath }) =>\n Match.value(change).pipe(\n Match.when(\"Added\", () => logFileAdded(convexFilePath)),\n Match.when(\"Modified\", () => logFileModified(convexFilePath)),\n Match.when(\"Unchanged\", () => Effect.void),\n Match.exhaustive,\n ),\n }),\n ),\n );\n\n/**\n * Test-only imports never enter the runtime schema or function wrappers.\n */\nconst quote = (value: string) => JSON.stringify(value);\n\n/**\n * A mount's `testing` kit must be a package specifier, so the generated\n * registry holds no machine-specific path, and must export `register`. A kit\n * whose exports cannot be listed without running it passes here, and\n * `TestConfect.layer` names the mount if it has no `register`.\n */\nconst checkTestKit = Effect.fnUntraced(function* (\n mount: string,\n specifier: string,\n config: string,\n configDisplay: string,\n) {\n const path = yield* Path.Path;\n const invalid = (problem: string) =>\n new CodegenError.InvalidDeclarationError({\n declarationPath: \"confect/app.ts\",\n reason: `the mount ${quote(mount)} names the test kit ${quote(specifier)}${problem}`,\n });\n if (specifier.startsWith(\".\") || path.isAbsolute(specifier)) {\n return yield* invalid(\n '; name it by a package specifier, such as \"<package>/testing\".',\n );\n }\n const resolved = Bundler.resolveModule(specifier, config);\n if (Option.isNone(resolved)) {\n return yield* invalid(`, which does not resolve from ${configDisplay}.`);\n }\n const exports = yield* Bundler.exportNames(resolved.value).pipe(\n Effect.mapError((error) => fromBundlerError(specifier, error)),\n );\n if (Option.isSome(exports) && !exports.value.includes(\"register\")) {\n return yield* invalid(\", which does not export `register(t, name)`.\");\n }\n});\n\nconst generateTesting = Effect.fnUntraced(function* (app: App.Any) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const convexDirectory = yield* ConvexDirectory.get;\n const generated = path.join(confectDirectory, \"_generated\");\n const configDisplay = path\n .relative(\n yield* ProjectRoot.get,\n path.join(convexDirectory, ConvexConfig.CONVEX_CONFIG_FILENAME),\n )\n .split(path.sep)\n .join(\"/\");\n const relative = (file: string) => {\n const value = path.relative(generated, file).split(path.sep).join(\"/\");\n return value.startsWith(\".\") ? value : `./${value}`;\n };\n const imports = [\n 'import schema from \"./schema.js\";',\n 'import convexSchema from \"./convexSchema.js\";',\n ];\n const moduleMap = Effect.fnUntraced(function* (directory: string) {\n const files = (yield* fs.readDirectory(directory, { recursive: true }))\n .filter(\n (file) =>\n /\\.[cm]?[jt]s$/.test(file) &&\n !file.endsWith(\".d.ts\") &&\n !file.split(path.sep).includes(\"_generated\") &&\n !file.includes(\".config.\"),\n )\n .sort();\n return `{ \"_generated/testing.ts\": () => Promise.resolve({}),\\n${files\n .map((file) => {\n const specifier = relative(path.join(directory, file));\n return `${quote(file.split(path.sep).join(\"/\"))}: () => import(${quote(specifier.replace(/\\.([cm]?)[jt]s$/, \".$1js\"))}),`;\n })\n .join(\"\\n\")}\\n}`;\n });\n const declarations: Array<string> = [];\n const identifiers = new Set([\"schema\", \"convexSchema\"]);\n const components: Array<string> = [];\n const httpMounts: Array<string> = [];\n const kits = new Map<string, string>();\n const visit = Effect.fnUntraced(function* (\n directory: string,\n prefix: string,\n kind: \"app\" | \"component\",\n parentHttpPrefix: string | undefined,\n registeredByKit: boolean,\n ): Effect.fn.Return<\n void,\n | PlatformError.PlatformError\n | BuildError\n | CodegenError.InvalidConvexConfigError\n | CodegenError.InvalidDeclarationError,\n FileSystem.FileSystem | Path.Path\n > {\n const config = path.join(directory, ConvexConfig.CONVEX_CONFIG_FILENAME);\n if (!(yield* fs.exists(config))) return;\n const installed = yield* ConvexConfig.discoverInstalledComponents(\n config,\n relative(config),\n kind,\n );\n for (const component of installed) {\n const name = prefix + component.name;\n const mount =\n prefix === \"\"\n ? App.mounts(app).find((declared) => declared.name === component.name)\n : undefined;\n // A bare definition belongs to another package. Its directory is read\n // here but never written out; tests reach it through `<package>/test`\n // or the kit its mount names.\n const fromPackage = !path.isAbsolute(component.componentDefinitionPath);\n const kitEntry =\n mount?.testing ??\n (fromPackage ? `${component.componentDefinitionPath}/test` : undefined);\n const resolved = fromPackage\n ? path.dirname(\n yield* ConvexConfig.resolveDefinition(\n `${component.componentDefinitionPath}/convex.config`,\n config,\n path,\n ).pipe(\n Effect.fromOption,\n Effect.mapError(\n () =>\n new CodegenError.InvalidConvexConfigError({\n configPath: relative(config),\n reason: `Cannot resolve component ${component.componentDefinitionPath} for testing.`,\n }),\n ),\n ),\n )\n : component.componentDefinitionPath;\n const localPrefix =\n prefix === \"\" ? mount?.httpPrefix : component.httpPrefix;\n const httpPrefix =\n parentHttpPrefix === undefined || localPrefix === undefined\n ? undefined\n : `${parentHttpPrefix.replace(/\\/+$/, \"\")}${localPrefix}`.replace(\n /\\/+$/,\n \"\",\n ) || \"/\";\n if (\n httpPrefix !== undefined &&\n ((yield* fs.exists(path.join(resolved, \"http.ts\"))) ||\n (yield* fs.exists(path.join(resolved, \"http.js\"))))\n ) {\n httpMounts.push(\n `{ componentPath: ${quote(name)}, httpPrefix: ${quote(httpPrefix)} }`,\n );\n }\n // A kit's `register` installs the mount's own children, so below it the\n // walk only collects HTTP mounts.\n if (!registeredByKit) {\n const kitKey = kitEntry ?? resolved;\n let identifier = kits.get(kitKey);\n if (identifier === undefined) {\n const cleaned = name.replaceAll(/[^A-Za-z0-9_$]/g, \"_\");\n const base = /^[A-Za-z_$]/.test(cleaned) ? cleaned : `_${cleaned}`;\n identifier = `${base}Kit`;\n let schemaIdentifier = `${base}Schema`;\n for (\n let n = 2;\n identifiers.has(identifier) || identifiers.has(schemaIdentifier);\n n++\n ) {\n identifier = `${base}Kit${n}`;\n schemaIdentifier = `${base}Schema${n}`;\n }\n identifiers.add(identifier);\n identifiers.add(schemaIdentifier);\n kits.set(kitKey, identifier);\n if (kitEntry === undefined) {\n imports.push(\n `import ${schemaIdentifier} from ${quote(relative(path.join(resolved, \"schema.js\")))};`,\n );\n declarations.push(\n `const ${identifier} = { schema: ${schemaIdentifier}, modules: ${yield* moduleMap(resolved)} };`,\n );\n } else {\n if (mount?.testing !== undefined) {\n yield* checkTestKit(\n mount.name,\n mount.testing,\n config,\n configDisplay,\n );\n } else if (Option.isNone(Bundler.resolveModule(kitEntry, config))) {\n return yield* new CodegenError.InvalidConvexConfigError({\n configPath: relative(config),\n reason: `the component package ${quote(component.componentDefinitionPath)} has no ${quote(kitEntry)} export. Tests register a component from another package through that entry's \\`register(t, name)\\`.`,\n });\n }\n imports.push(`import * as ${identifier} from ${quote(kitEntry)};`);\n }\n }\n components.push(`${quote(name)}: ${identifier},`);\n }\n // A package's own `register` installs its children.\n if (!fromPackage) {\n yield* visit(\n resolved,\n `${name}/`,\n \"component\",\n httpPrefix,\n registeredByKit || kitEntry !== undefined,\n );\n }\n }\n });\n yield* visit(\n convexDirectory,\n \"\",\n (yield* ConvexDirectory.target).kind,\n \"\",\n false,\n );\n yield* writeFileStringAndLog(\n path.join(generated, \"testing.ts\"),\n [\n \"// Generated by `confect codegen`. Test-only; do not import in backend functions.\",\n ...imports,\n ...declarations,\n `export default { httpMounts: [${httpMounts.join(\",\")}], schema, convexSchema, modules: ${yield* moduleMap(convexDirectory)}, components: {${components.join(\"\\n\")}} };`,\n ].join(\"\\n\"),\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,MAAM,oBAAoB;AAE1B,MAAM,cAAc,OAAO,IACzB,gBAAgB,SACf,WAAW,OAAO,SAAS,WAC9B;AAEA,MAAM,sBAAsB,OAAO,IAAI,KAAK,OAAO,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M,CAAC,GAC9D,OAAO,OAAO,IAAIpB,yBAAsC;OACtD,YAAY,SAAS,MAAM;OAC3B,QAAQ,yBAAyB,MAAM,UAAU,uBAAuB,EAAE,UAAU,MAAM,QAAQ,EAAE;MACtG,CAAC;MAEH,QAAQ,KAAK,eAAe,WAAW,QAAQ,MAAM,QAAQ,EAAE,EAAE;KACnE;IACF;IACA,WAAW,KAAK,GAAG,MAAM,IAAI,EAAE,IAAI,WAAW,EAAE;GAClD;GAEA,IAAI,CAAC,aACH,OAAO,MACL,UACA,GAAG,KAAK,IACR,aACA,YACA,mBAAmB,aAAa,KAAA,CAClC;EAEJ;CACF,CAAC;CACD,OAAO,MACL,iBACA,KACC,OAAO,gBAAgB,OAAA,CAAQ,MAChC,IACA,KACF;CACA,OAAO,sBACL,KAAK,KAAK,WAAW,YAAY,GACjC;EACE;EACA,GAAG;EACH,GAAG;EACH,iCAAiC,WAAW,KAAK,GAAG,EAAE,oCAAoC,OAAO,UAAU,eAAe,EAAE,iBAAiB,WAAW,KAAK,IAAI,EAAE;CACrK,CAAC,CAAC,KAAK,IAAI,CACb;AACF,CAAC"}
1
+ {"version":3,"file":"codegen.mjs","names":["DirectoryOptions.flags","CodegenError.tapAndLog","DirectoryOptions.layer","FunctionModule.assertOwnedEntrypoints","TableModule.discover","TableModule.validate","GenerationSnapshot.fromLoadedLeaves","FunctionModule.generateFunctions","EntryPoint.planDeclarations","GenerationSnapshot.update","FunctionModule.applyFunctionPlan","GenerationSnapshot.diff","CodegenError.ComponentNodeGroupError","ConvexConfig.componentName","ConvexConfig.CONVEX_CONFIG_FILENAME","Bundler.bundle","CodegenError.CallbackPrefixError","CodegenError.InvalidConvexConfigError","templates.componentContract","templates.assembledSpec","templates.registeredFunctionsForGroup","FunctionPaths.make","TableModule.TABLES_DIRNAME","templates.id","templates.tableWrapper","templates.runtimeSchema","templates.convexSchema","templates.schema","templates.services","DocName.fromTableName","CodegenError.ConflictingDocNameError","templates.docs","templates.refs","ConvexConfig.discoverInstalledComponents","templates.components","ConvexConfig.typeImportPath","CodegenError.InvalidDeclarationError","Bundler.resolveModule","Bundler.exportNames","ConvexConfig.resolveDefinition"],"sources":["../../src/confect/codegen.ts"],"sourcesContent":["import { App, Callback, Env, type GroupSpec, Spec } from \"@confect/core\";\nimport * as Command from \"effect/cli/Command\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as Result from \"effect/Result\";\nimport type * as PlatformError from \"effect/PlatformError\";\nimport type { BuildError } from \"../BuildError.js\";\nimport { pipe } from \"effect/Function\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Record from \"effect/Record\";\nimport type * as Scope from \"effect/Scope\";\nimport * as Bundler from \"../Bundler.js\";\nimport { fromBundlerError } from \"../BuildError.js\";\nimport * as CodegenError from \"../CodegenError.js\";\nimport { LegacySchemaFileError } from \"../CodegenError.js\";\nimport { ConfectDirectory } from \"../ConfectDirectory.js\";\nimport * as ConvexConfig from \"../ConvexConfig.js\";\nimport { ConvexDirectory } from \"../ConvexDirectory.js\";\nimport * as DirectoryOptions from \"../DirectoryOptions.js\";\nimport * as DocName from \"../DocName.js\";\nimport * as FunctionPaths from \"../FunctionPaths.js\";\nimport * as FunctionModule from \"../FunctionModule.js\";\nimport * as GenerationSnapshot from \"../GenerationSnapshot.js\";\nimport * as EntryPoint from \"../EntryPoint.js\";\nimport type { ImplModulePath } from \"../ImplModulePath.js\";\nimport {\n implPathForSpec,\n loadAll,\n registeredFunctionsRelativePath,\n validateAllImpls,\n withImplFiles,\n type LeafModule,\n type LoadedLeafModule,\n} from \"../LeafModule.js\";\nimport {\n logFileAdded,\n logFileModified,\n logFileRemoved,\n logPending,\n logSuccess,\n logWarn,\n} from \"../log.js\";\nimport { ProjectRoot } from \"../ProjectRoot.js\";\nimport { preserveComponentOutput } from \"../Rollback.js\";\nimport { assemblyNodesFromLeaves } from \"../SpecAssemblyNode.js\";\nimport * as TableModule from \"../TableModule.js\";\nimport * as templates from \"../templates.js\";\nimport {\n generateAuthConfig,\n generateCrons,\n generateHttp,\n removePathIfExists,\n toModuleImportPath,\n touchConvexSchema,\n writeFileStringAndLog,\n} from \"../utils.js\";\nimport { syncDeclaration, syncDeclaredHttp } from \"./declaration.js\";\n\nconst GENERATED_DIRNAME = \"_generated\";\n\nconst isComponent = Effect.map(\n ConvexDirectory.target,\n (target) => target.kind === \"component\",\n);\n\nconst GENERATED_SPEC_PATH = Effect.map(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"spec.ts\"),\n);\nconst GENERATED_SCHEMA_PATH = Effect.map(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"schema.ts\"),\n);\nconst GENERATED_CONVEX_SCHEMA_PATH = Effect.map(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"convexSchema.ts\"),\n);\nconst GENERATED_ID_PATH = Effect.map(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"id.ts\"),\n);\nconst GENERATED_COMPONENTS_PATH = Effect.map(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"components.ts\"),\n);\nconst GENERATED_TABLES_DIRNAME = Effect.map(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"tables\"),\n);\n\nconst LEGACY_PATHS = Effect.gen(function* () {\n const path = yield* Path.Path;\n\n return [\n \"spec.ts\",\n \"nodeSpec.ts\",\n \"impl.ts\",\n \"nodeImpl.ts\",\n path.join(GENERATED_DIRNAME, \"registeredFunctions.ts\"),\n path.join(GENERATED_DIRNAME, \"nodeRegisteredFunctions.ts\"),\n path.join(GENERATED_DIRNAME, \"impl.ts\"),\n path.join(GENERATED_DIRNAME, \"nodeImpl.ts\"),\n // `_generated/nodeSpec.ts` is not part of the generated output (all groups\n // live in `_generated/spec.ts`); delete any copy left by an older version.\n path.join(GENERATED_DIRNAME, \"nodeSpec.ts\"),\n ];\n});\n\nexport const codegen = Command.make(\"codegen\", DirectoryOptions.flags, () =>\n Effect.gen(function* () {\n yield* logPending(\"Performing initial sync…\");\n yield* codegenHandler.pipe(\n Effect.asVoid,\n Effect.tap(() => logSuccess(\"Generated files are up-to-date\")),\n CodegenError.tapAndLog,\n );\n }),\n).pipe(\n Command.provide(DirectoryOptions.layer),\n Command.withDescription(\n \"Generate `confect/_generated` files and the contents of the `convex` directory (except `tsconfig.json`, and `convex.config.ts` unless `confect/app.ts` declares the backend)\",\n ),\n);\n\nconst runCodegen = Effect.gen(function* () {\n yield* FunctionModule.assertOwnedEntrypoints;\n yield* validateComponentConfiguration;\n yield* generateConfectGeneratedDirectory;\n // A declared backend's `convex.config.ts` and manifest come first: the\n // components registry below reads the config, and nothing may validate\n // against a manifest the current declaration did not produce.\n const declared = yield* syncDeclaration;\n // Reject a legacy `confect/schema.ts` up front so the user-facing\n // migration message surfaces before any bundler error from impl\n // validation (each impl imports `_generated/schema.ts`).\n yield* rejectLegacySchemaFile;\n // List `confect/tables/*.ts` (filename-only—no bundling yet) so the\n // `_generated/id.ts` constructor can be emitted *before* we bundle any\n // user-authored table module. Tables import from `_generated/id.ts` for\n // cross-table id refs, so it must exist on disk first.\n const tableModules = yield* TableModule.discover;\n yield* warnIfNoTables(tableModules);\n yield* generateIdConstructor(tableModules);\n // Tables and specs can use bound component IDs and schemas, so their\n // imports need the registry even on a project's first codegen run.\n yield* generateComponents;\n yield* validateCallbackPrefixes(declared);\n // Now that `_generated/id.ts` is on disk, bundle each table module and\n // check its default export is an `UnnamedTable`. Surface diagnostics\n // here (rather than later) so they appear before impl-validation noise.\n yield* TableModule.validate(tableModules);\n yield* validateNoDocNameCollisions(tableModules);\n yield* generateTableWrappers(tableModules);\n yield* removeObsoleteTableWrappers(tableModules);\n yield* generateRuntimeSchema(tableModules);\n const leaves = yield* loadAll;\n yield* rejectComponentNodeGroups(leaves);\n yield* removeLegacyFiles;\n const snapshot = yield* Effect.fromResult(\n GenerationSnapshot.fromLoadedLeaves(leaves),\n );\n yield* generateAssembledSpecs(leaves);\n // `_generated/api.ts`/`nodeApi.ts` are no longer imported by generated or\n // impl code (impls take the database schema from `_generated/schema`\n // directly), so remove any copies left over from earlier versions before\n // impl validation runs.\n yield* Effect.all(\n [\n removeGeneratedApi,\n generateRefs,\n generateComponentContract(tableModules),\n removeGeneratedNodeApi,\n generateDocs(tableModules),\n generateServices,\n generateConvexSchema(tableModules),\n ],\n { concurrency: \"unbounded\" },\n );\n yield* validateAllImpls(leaves);\n yield* generateGroupRegisteredFunctions(leaves);\n yield* removeObsoleteRegisteredFunctions(leaves);\n const [functionPaths] = yield* Effect.all(\n [\n FunctionModule.generateFunctions(snapshot),\n generateConvexSchemaReexport,\n logGenerated(\n Option.match(declared, {\n onNone: () => generateHttp,\n onSome: syncDeclaredHttp,\n }),\n ),\n logGenerated(generateCrons),\n Option.isNone(declared)\n ? logGenerated(generateAuthConfig)\n : Effect.succeedNone,\n ],\n { concurrency: \"unbounded\" },\n );\n if (Option.isSome(declared)) yield* generateTesting(declared.value);\n return {\n functionPaths,\n snapshot,\n };\n});\n\nexport const generateWithSnapshot = runCodegen.pipe(\n Effect.withSpan(\"Cli.codegen\"),\n);\n\nexport const makeCodegenHandler = (\n duringRestore?: Effect.Effect<void, never, Scope.Scope>,\n) =>\n preserveComponentOutput(generateWithSnapshot, duringRestore).pipe(\n Effect.tap(() => touchConvexSchema),\n Effect.map(({ functionPaths }) => ({ functionPaths })),\n );\n\nexport const codegenHandler = makeCodegenHandler();\n\nexport const updateDeclarations = Effect.fn(\"Cli.updateDeclarations\")(\n function* (\n snapshot: GenerationSnapshot.GenerationSnapshot,\n declarations: Array.NonEmptyReadonlyArray<EntryPoint.Declaration>,\n affectedImpls: ReadonlyArray<ImplModulePath>,\n ) {\n const path = yield* Path.Path;\n const { paths, tables } = EntryPoint.planDeclarations(\n declarations,\n affectedImpls,\n path,\n );\n yield* TableModule.validate(tables);\n return yield* withImplFiles(paths, (leaves) =>\n Effect.gen(function* () {\n yield* rejectComponentNodeGroups(leaves);\n const next = yield* Effect.fromResult(\n GenerationSnapshot.update(snapshot, leaves),\n );\n yield* validateAllImpls(leaves);\n yield* generateGroupRegisteredFunctions(leaves);\n yield* FunctionModule.applyFunctionPlan(\n GenerationSnapshot.diff(snapshot, next),\n );\n return next;\n }),\n );\n },\n);\n\n// Convex components cannot run Node.js functions, at any nesting depth.\nconst validateComponentGroupRuntime = (\n group: GroupSpec.AnyWithProps,\n groupPath: string,\n specPath: string,\n): Result.Result<void, CodegenError.ComponentNodeGroupError> =>\n Result.gen(function* () {\n if (group.runtime === \"Node\") {\n return yield* Result.fail(\n new CodegenError.ComponentNodeGroupError({ specPath, groupPath }),\n );\n }\n for (const [name, child] of Object.entries(group.groups)) {\n yield* validateComponentGroupRuntime(\n child,\n `${groupPath}.${name}`,\n specPath,\n );\n }\n });\n\nconst rejectComponentNodeGroups = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<LoadedLeafModule>,\n) {\n if ((yield* ConvexDirectory.target).kind === \"app\") return;\n yield* Effect.forEach(leaves, (leaf) =>\n Effect.fromResult(\n validateComponentGroupRuntime(\n leaf.spec,\n leaf.groupPathDot,\n leaf.relativePath,\n ),\n ),\n );\n});\n\nconst validateCallbackPrefixes = Effect.fnUntraced(function* (\n declared: Option.Option<App.Any>,\n) {\n if ((yield* ConvexDirectory.target).kind !== \"component\") return;\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const callbacksPath = path.join(yield* ConfectDirectory.get, \"callbacks.ts\");\n if (!(yield* fs.exists(callbacksPath))) return;\n const name = Option.isSome(declared)\n ? Env.name(App.env(declared.value))\n : yield* ConvexConfig.componentName(\n path.join(\n yield* ConvexDirectory.get,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n ),\n );\n const { module } = yield* Bundler.bundle(callbacksPath).pipe(\n Effect.mapError((error) => fromBundlerError(\"confect/callbacks.ts\", error)),\n );\n for (const contract of Object.values(module)) {\n if (Callback.isContract(contract) && !contract.id.startsWith(`${name}/`)) {\n return yield* new CodegenError.CallbackPrefixError({\n declarationPath: \"confect/callbacks.ts\",\n contractId: contract.id,\n componentName: name,\n });\n }\n }\n});\n\nconst validateComponentConfiguration = Effect.gen(function* () {\n return yield* Match.value((yield* ConvexDirectory.target).kind).pipe(\n Match.when(\"app\", () => Effect.void),\n Match.when(\"component\", () =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const authPath = path.join(confectDirectory, \"auth.ts\");\n if (yield* fs.exists(authPath)) {\n return yield* new CodegenError.InvalidConvexConfigError({\n configPath: authPath,\n reason:\n \"Components cannot configure application authentication. Pass identity explicitly through function arguments.\",\n });\n }\n }),\n ),\n Match.exhaustive,\n );\n});\n\nconst generateComponentContract = Effect.fnUntraced(function* (\n tables: ReadonlyArray<TableModule.TableModule>,\n) {\n return yield* Match.value((yield* ConvexDirectory.target).kind).pipe(\n Match.when(\"app\", () => Effect.void),\n Match.when(\"component\", () =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n const directory = yield* ConfectDirectory.get;\n const contents = yield* templates.componentContract({\n tableNames: Array.map(tables, (table) => table.tableName),\n });\n yield* writeFileStringAndLog(\n path.join(directory, GENERATED_DIRNAME, \"component.ts\"),\n contents,\n );\n }),\n ),\n Match.exhaustive,\n );\n});\n\nconst generateConfectGeneratedDirectory = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n if (!(yield* fs.exists(path.join(confectDirectory, \"_generated\")))) {\n yield* fs.makeDirectory(path.join(confectDirectory, \"_generated\"), {\n recursive: true,\n });\n yield* logFileAdded(path.join(confectDirectory, \"_generated\") + \"/\");\n }\n});\n\nconst removeLegacyFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const legacyPaths = yield* LEGACY_PATHS;\n\n yield* Effect.forEach(\n legacyPaths,\n Effect.fnUntraced(function* (relativePath: string) {\n const absolutePath = path.join(confectDirectory, relativePath);\n if (yield* fs.exists(absolutePath)) {\n yield* removePathIfExists(absolutePath);\n yield* logFileRemoved(absolutePath);\n }\n }),\n );\n});\n\nconst generateAssembledSpecs = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<LeafModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedSpecPath = yield* GENERATED_SPEC_PATH;\n\n // A single assembled spec holds every group regardless of runtime—a Node\n // group's `makeNode()` lives in its imported leaf spec, so the assembled\n // file is runtime-agnostic. Always emit it (even empty) so downstream\n // readers (`loadGeneratedSpec`, `generateRefs`) always find a spec module.\n const nodes = assemblyNodesFromLeaves(leaves);\n const specContents = yield* templates.assembledSpec({ nodes });\n yield* writeFileStringAndLog(\n path.join(confectDirectory, generatedSpecPath),\n specContents,\n );\n});\n\nconst generateGroupRegisteredFunctions = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<LoadedLeafModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n yield* Effect.forEach(\n leaves,\n Effect.fnUntraced(function* (leaf: LoadedLeafModule) {\n const registryRelativePath = yield* registeredFunctionsRelativePath(leaf);\n const registryPath = path.join(\n confectDirectory,\n \"_generated\",\n registryRelativePath,\n );\n const registryDir = path.dirname(registryPath);\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(registryDir))) {\n yield* fs.makeDirectory(registryDir, { recursive: true });\n }\n\n const implRelativePath = yield* implPathForSpec(leaf.relativePath);\n const schemaImportPath = yield* toModuleImportPath(\n path.relative(\n path.dirname(registryPath),\n path.join(confectDirectory, \"_generated\", \"schema.ts\"),\n ),\n );\n // The group's own leaf spec (sibling of its impl), referenced\n // type-only by the registry to shape its returned record.\n const specImportPath = yield* toModuleImportPath(\n path.relative(\n path.dirname(registryPath),\n path.join(confectDirectory, leaf.relativePath),\n ),\n );\n const implImportPath = yield* toModuleImportPath(\n path.relative(\n path.dirname(registryPath),\n path.join(confectDirectory, implRelativePath),\n ),\n );\n\n const contents = yield* templates.registeredFunctionsForGroup({\n spec: leaf.spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n });\n\n yield* writeFileStringAndLog(registryPath, contents);\n }),\n );\n});\n\nconst removeObsoleteRegisteredFunctions = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<LeafModule>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const registryRoot = path.join(\n confectDirectory,\n \"_generated\",\n \"registeredFunctions\",\n );\n\n if (!(yield* fs.exists(registryRoot))) {\n return;\n }\n\n const expected = new Set(\n yield* Effect.forEach(leaves, (leaf) =>\n registeredFunctionsRelativePath(leaf),\n ),\n );\n\n const existing = yield* fs.readDirectory(registryRoot, { recursive: true });\n yield* Effect.forEach(existing, (relativePath) => {\n if (path.extname(relativePath) !== \".ts\") {\n return Effect.void;\n }\n const normalized = path.join(\"registeredFunctions\", relativePath);\n if (!expected.has(normalized)) {\n return Effect.gen(function* () {\n const absolutePath = path.join(registryRoot, relativePath);\n if (yield* fs.exists(absolutePath)) {\n yield* removePathIfExists(absolutePath);\n yield* logFileRemoved(absolutePath);\n }\n });\n }\n return Effect.void;\n });\n});\n\nconst getGeneratedSpecPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedSpecPath = yield* GENERATED_SPEC_PATH;\n return path.join(confectDirectory, generatedSpecPath);\n});\n\nconst loadGeneratedSpec = Effect.gen(function* () {\n const specPath = yield* getGeneratedSpecPath;\n const { module: specModule } = yield* Bundler.bundle(specPath);\n const spec = specModule.default;\n\n if (!Spec.isSpec(spec)) {\n return yield* Effect.die(\n new Error(\"_generated/spec.ts does not export a valid Spec\"),\n );\n }\n\n return spec;\n});\n\nconst emptyFunctionPaths = FunctionPaths.FunctionPaths.make(HashSet.empty());\n\nexport const loadPreviousFunctionPaths = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const specPath = yield* getGeneratedSpecPath;\n\n if (!(yield* fs.exists(specPath))) {\n return emptyFunctionPaths;\n }\n\n const specResult = yield* loadGeneratedSpec.pipe(Effect.result);\n\n return Result.match(specResult, {\n onFailure: () => emptyFunctionPaths,\n onSuccess: (spec) => FunctionPaths.make(spec),\n });\n});\n\n/**\n * Remove a now-obsolete `_generated/<name>.ts` if present (and log it), for\n * projects upgrading from a version that still emitted it.\n */\nconst removeObsoleteGeneratedFile = Effect.fnUntraced(function* (\n fileName: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const filePath = path.join(confectDirectory, \"_generated\", fileName);\n\n if (yield* fs.exists(filePath)) {\n yield* removePathIfExists(filePath);\n yield* logFileRemoved(filePath);\n }\n});\n\n// `_generated/api.ts` is no longer imported by generated or impl code: impls\n// take the database schema (`_generated/schema`) directly, and per-group\n// registries reference the spec type-only. Remove any stale copy.\nconst removeGeneratedApi = removeObsoleteGeneratedFile(\"api.ts\");\n\n// `_generated/nodeApi.ts` is obsolete for the same reason.\nconst removeGeneratedNodeApi = removeObsoleteGeneratedFile(\"nodeApi.ts\");\n\n/**\n * The user-authored `confect/schema.ts` is no longer supported: codegen now\n * owns both `_generated/schema.ts` (runtime) and `_generated/convexSchema.ts`\n * (deploy), derived from a single scan of `confect/tables/*.ts`. Detect a stray\n * file and fail with a clear migration message—leaving it in place would\n * silently shadow the codegen-owned\n * `_generated/schema.ts`/`_generated/convexSchema.ts`.\n */\nconst rejectLegacySchemaFile = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const legacyPath = path.join(confectDirectory, \"schema.ts\");\n\n if (yield* fs.exists(legacyPath)) {\n return yield* new LegacySchemaFileError({ schemaPath: \"schema.ts\" });\n }\n});\n\n/**\n * Surface a yellow `⚠` warning when codegen sees no tables—either the\n * `confect/tables/` directory is missing or it contains no `.ts` files.\n * Generation still succeeds (emitting an empty `DatabaseSchema` and\n * `defineSchema({})`), since action-only/table-free Confect backends are\n * legal—but the warning catches the much more common case of a typoed directory\n * or files placed under the wrong root.\n */\nconst warnIfNoTables = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n tableModules.length === 0\n ? logWarn(\n `No tables discovered in \\`confect/${TableModule.TABLES_DIRNAME}/\\`. ` +\n `Generating an empty schema; add a \\`Table.make(...)\\` module under that ` +\n `directory unless this backend is intentionally tables-free.`,\n )\n : Effect.void;\n\nconst tableModuleBindings = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n generatedFilePath: string,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedDir = path.dirname(generatedFilePath);\n\n const generatedTablesDirname = yield* GENERATED_TABLES_DIRNAME;\n\n return yield* Effect.forEach(\n tableModules,\n Effect.fnUntraced(function* (tableModule: TableModule.TableModule) {\n const wrapperAbsolutePath = path.join(\n confectDirectory,\n generatedTablesDirname,\n `${tableModule.tableName}.ts`,\n );\n const importPath = yield* toModuleImportPath(\n path.relative(generatedDir, wrapperAbsolutePath),\n );\n return {\n importPath,\n tableName: tableModule.tableName,\n };\n }),\n );\n});\n\nconst generateIdConstructor = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedIdPath = yield* GENERATED_ID_PATH;\n const idPath = path.join(confectDirectory, generatedIdPath);\n\n const tableNames = Array.map(\n tableModules,\n (tableModule) => tableModule.tableName,\n );\n const contents = yield* Match.value(yield* ConvexDirectory.target).pipe(\n Match.when({ kind: \"app\" }, () => templates.id({ tableNames })),\n Match.when({ kind: \"component\" }, ({ scope }) =>\n templates.id({ tableNames, scope }),\n ),\n Match.exhaustive,\n );\n\n yield* writeFileStringAndLog(idPath, contents);\n});\n\nconst generateTableWrappers = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedTablesDirname = yield* GENERATED_TABLES_DIRNAME;\n const wrappersDir = path.join(confectDirectory, generatedTablesDirname);\n\n if (!(yield* fs.exists(wrappersDir))) {\n yield* fs.makeDirectory(wrappersDir, { recursive: true });\n }\n\n yield* Effect.forEach(\n tableModules,\n Effect.fnUntraced(function* (tableModule: TableModule.TableModule) {\n const wrapperPath = path.join(\n confectDirectory,\n generatedTablesDirname,\n `${tableModule.tableName}.ts`,\n );\n const unnamedAbsolutePath = path.join(\n confectDirectory,\n tableModule.relativePath,\n );\n const unnamedImportPath = yield* toModuleImportPath(\n path.relative(path.dirname(wrapperPath), unnamedAbsolutePath),\n );\n const contents = yield* templates.tableWrapper({\n tableName: tableModule.tableName,\n unnamedImportPath,\n component: yield* isComponent,\n });\n yield* writeFileStringAndLog(wrapperPath, contents);\n }),\n { concurrency: \"unbounded\" },\n );\n});\n\n/**\n * Remove any stale `_generated/tables/*.ts` wrapper whose source table has been\n * deleted or renamed. Mirrors `removeObsoleteRegisteredFunctions` for the\n * wrapper directory.\n */\nconst removeObsoleteTableWrappers = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedTablesDirname = yield* GENERATED_TABLES_DIRNAME;\n const wrappersDir = path.join(confectDirectory, generatedTablesDirname);\n\n if (!(yield* fs.exists(wrappersDir))) {\n return;\n }\n\n const expected = new Set(\n Array.map(tableModules, (tableModule) => `${tableModule.tableName}.ts`),\n );\n const existing = yield* fs.readDirectory(wrappersDir, { recursive: true });\n yield* Effect.forEach(existing, (entry) => {\n if (path.extname(entry) !== \".ts\") {\n return Effect.void;\n }\n if (!expected.has(entry)) {\n return Effect.gen(function* () {\n const absolutePath = path.join(wrappersDir, entry);\n if (yield* fs.exists(absolutePath)) {\n yield* removePathIfExists(absolutePath);\n yield* logFileRemoved(absolutePath);\n }\n });\n }\n return Effect.void;\n });\n});\n\nconst generateRuntimeSchema = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedSchemaPath = yield* GENERATED_SCHEMA_PATH;\n const schemaPath = path.join(confectDirectory, generatedSchemaPath);\n\n const bindings = yield* tableModuleBindings(tableModules, schemaPath);\n const contents = yield* templates.runtimeSchema({\n tableModules: bindings,\n component: yield* isComponent,\n });\n\n yield* writeFileStringAndLog(schemaPath, contents);\n});\n\nconst generateConvexSchema = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const generatedConvexSchemaPath = yield* GENERATED_CONVEX_SCHEMA_PATH;\n const convexSchemaPath = path.join(\n confectDirectory,\n generatedConvexSchemaPath,\n );\n\n const bindings = yield* tableModuleBindings(tableModules, convexSchemaPath);\n const contents = yield* templates.convexSchema({ tableModules: bindings });\n\n yield* writeFileStringAndLog(convexSchemaPath, contents);\n});\n\nconst generateConvexSchemaReexport = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const convexDirectory = yield* ConvexDirectory.get;\n const generatedConvexSchemaRelativePath = yield* GENERATED_CONVEX_SCHEMA_PATH;\n\n const convexSchemaPath = path.join(convexDirectory, \"schema.ts\");\n const generatedConvexSchemaPath = path.join(\n confectDirectory,\n generatedConvexSchemaRelativePath,\n );\n\n const convexSchemaImportPath = yield* toModuleImportPath(\n path.relative(path.dirname(convexSchemaPath), generatedConvexSchemaPath),\n );\n\n const schemaContents = yield* templates.schema({\n convexSchemaImportPath,\n });\n\n yield* writeFileStringAndLog(convexSchemaPath, schemaContents);\n});\n\nconst generateServices = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const confectGeneratedDirectory = path.join(confectDirectory, \"_generated\");\n\n const servicesPath = path.join(confectGeneratedDirectory, \"services.ts\");\n const generatedSchemaPath = yield* GENERATED_SCHEMA_PATH;\n const schemaImportPath = yield* toModuleImportPath(\n path.relative(\n path.dirname(servicesPath),\n path.join(confectDirectory, generatedSchemaPath),\n ),\n );\n\n const servicesContentsString = yield* templates.services({\n schemaImportPath,\n component: yield* isComponent,\n });\n\n yield* writeFileStringAndLog(servicesPath, servicesContentsString);\n});\n\n/**\n * Two tables whose names fold to the same PascalCase document type name (e.g.\n * `user_profiles` and `userProfiles` → `UserProfilesDoc`) would emit duplicate\n * interfaces in `_generated/docs.ts`. Catch that up front with a clear error\n * rather than letting `tsc` report a duplicate-identifier later.\n */\nconst validateNoDocNameCollisions = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const collisions = pipe(\n tableModules,\n Array.groupBy((tableModule) =>\n DocName.fromTableName(tableModule.tableName),\n ),\n Record.toEntries,\n Array.filter(([, group]) => group.length > 1),\n Array.map(([docName, group]) => ({\n docName,\n tableNames: Array.map(group, (tableModule) => tableModule.tableName),\n })),\n );\n\n if (Array.isReadonlyArrayNonEmpty(collisions)) {\n return yield* new CodegenError.ConflictingDocNameError({ collisions });\n }\n});\n\nconst generateDocs = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const confectGeneratedDirectory = path.join(confectDirectory, \"_generated\");\n\n const docsPath = path.join(confectGeneratedDirectory, \"docs.ts\");\n const generatedSchemaPath = yield* GENERATED_SCHEMA_PATH;\n const schemaImportPath = yield* toModuleImportPath(\n path.relative(\n path.dirname(docsPath),\n path.join(confectDirectory, generatedSchemaPath),\n ),\n );\n\n const docsContentsString = yield* templates.docs({\n schemaImportPath,\n tables: Array.map(tableModules, (tableModule) => ({\n tableName: tableModule.tableName,\n docName: DocName.fromTableName(tableModule.tableName),\n })),\n });\n\n yield* writeFileStringAndLog(docsPath, docsContentsString);\n});\n\nconst generateRefs = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const confectGeneratedDirectory = path.join(confectDirectory, \"_generated\");\n const refsPath = path.join(confectGeneratedDirectory, \"refs.ts\");\n const refsDir = path.dirname(refsPath);\n const generatedSpecPath = yield* GENERATED_SPEC_PATH;\n\n const specImportPath = yield* toModuleImportPath(\n path.relative(refsDir, path.join(confectDirectory, generatedSpecPath)),\n );\n\n const refsContents = yield* templates.refs({ specImportPath });\n\n yield* writeFileStringAndLog(refsPath, refsContents);\n});\n\n/**\n * Generate `confect/_generated/components.ts`—the typed registry of Convex\n * components installed in `convex/convex.config.ts` (see\n * {@link templates.components}). The file is emitted even when there is no\n * `convex.config.ts` (as an empty registry) so the import surface stays stable.\n * It must exist before loading tables and specs because they may import bound\n * component IDs and schemas.\n */\nexport const generateComponents = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const convexDirectory = yield* ConvexDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n\n const confectGeneratedDirectory = path.join(\n confectDirectory,\n GENERATED_DIRNAME,\n );\n const generatedComponentsPath = yield* GENERATED_COMPONENTS_PATH;\n const componentsPath = path.join(confectDirectory, generatedComponentsPath);\n\n const convexConfigPath = path.join(\n convexDirectory,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n );\n\n const installedComponents = (yield* fs.exists(convexConfigPath))\n ? yield* ConvexConfig.discoverInstalledComponents(\n convexConfigPath,\n path.relative(projectRoot, convexConfigPath),\n (yield* ConvexDirectory.target).kind,\n )\n : [];\n\n const contents = yield* templates.components({\n components: Array.map(\n installedComponents,\n ({ name, componentDefinitionPath }) => ({\n name,\n typeImportPath: ConvexConfig.typeImportPath(\n path,\n componentDefinitionPath,\n confectGeneratedDirectory,\n ),\n }),\n ),\n });\n\n yield* writeFileStringAndLog(componentsPath, contents);\n});\n\nconst logGenerated = <E, R>(\n effect: Effect.Effect<\n Option.Option<{\n readonly change: \"Added\" | \"Modified\" | \"Unchanged\";\n readonly convexFilePath: string;\n }>,\n E,\n R\n >,\n) =>\n effect.pipe(\n Effect.tap(\n Option.match({\n onNone: () => Effect.void,\n onSome: ({ change, convexFilePath }) =>\n Match.value(change).pipe(\n Match.when(\"Added\", () => logFileAdded(convexFilePath)),\n Match.when(\"Modified\", () => logFileModified(convexFilePath)),\n Match.when(\"Unchanged\", () => Effect.void),\n Match.exhaustive,\n ),\n }),\n ),\n );\n\n/**\n * Test-only imports never enter the runtime schema or function wrappers.\n */\nconst quote = (value: string) => JSON.stringify(value);\n\n/**\n * A mount's `testing` kit must be a package specifier, so the generated\n * registry holds no machine-specific path, and must export `register`. A kit\n * whose exports cannot be listed without running it passes here, and\n * `TestConfect.layer` names the mount if it has no `register`.\n */\nconst checkTestKit = Effect.fnUntraced(function* (\n mount: string,\n specifier: string,\n config: string,\n configDisplay: string,\n) {\n const path = yield* Path.Path;\n const invalid = (problem: string) =>\n new CodegenError.InvalidDeclarationError({\n declarationPath: \"confect/app.ts\",\n reason: `the mount ${quote(mount)} names the test kit ${quote(specifier)}${problem}`,\n });\n if (specifier.startsWith(\".\") || path.isAbsolute(specifier)) {\n return yield* invalid(\n '; name it by a package specifier, such as \"<package>/testing\".',\n );\n }\n const resolved = Bundler.resolveModule(specifier, config);\n if (Option.isNone(resolved)) {\n return yield* invalid(`, which does not resolve from ${configDisplay}.`);\n }\n const exports = yield* Bundler.exportNames(resolved.value).pipe(\n Effect.mapError((error) => fromBundlerError(specifier, error)),\n );\n if (Option.isSome(exports) && !exports.value.includes(\"register\")) {\n return yield* invalid(\", which does not export `register(t, name)`.\");\n }\n});\n\nconst generateTesting = Effect.fnUntraced(function* (app: App.Any) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const convexDirectory = yield* ConvexDirectory.get;\n const generated = path.join(confectDirectory, \"_generated\");\n const configDisplay = path\n .relative(\n yield* ProjectRoot.get,\n path.join(convexDirectory, ConvexConfig.CONVEX_CONFIG_FILENAME),\n )\n .split(path.sep)\n .join(\"/\");\n const relative = (file: string) => {\n const value = path.relative(generated, file).split(path.sep).join(\"/\");\n return value.startsWith(\".\") ? value : `./${value}`;\n };\n const imports = [\n 'import schema from \"./schema.js\";',\n 'import convexSchema from \"./convexSchema.js\";',\n ];\n const moduleMap = Effect.fnUntraced(function* (directory: string) {\n const files = (yield* fs.readDirectory(directory, { recursive: true }))\n .filter(\n (file) =>\n /\\.[cm]?[jt]s$/.test(file) &&\n !file.endsWith(\".d.ts\") &&\n !file.split(path.sep).includes(\"_generated\") &&\n !file.includes(\".config.\"),\n )\n .sort();\n return `{ \"_generated/testing.ts\": () => Promise.resolve({}),\\n${files\n .map((file) => {\n const specifier = relative(path.join(directory, file));\n return `${quote(file.split(path.sep).join(\"/\"))}: () => import(${quote(specifier.replace(/\\.([cm]?)[jt]s$/, \".$1js\"))}),`;\n })\n .join(\"\\n\")}\\n}`;\n });\n const declarations: Array<string> = [];\n const identifiers = new Set([\"schema\", \"convexSchema\"]);\n const components: Array<string> = [];\n const httpMounts: Array<string> = [];\n const kits = new Map<string, string>();\n const visit = Effect.fnUntraced(function* (\n directory: string,\n prefix: string,\n kind: \"app\" | \"component\",\n parentHttpPrefix: string | undefined,\n registeredByKit: boolean,\n ): Effect.fn.Return<\n void,\n | PlatformError.PlatformError\n | BuildError\n | CodegenError.InvalidConvexConfigError\n | CodegenError.InvalidDeclarationError,\n FileSystem.FileSystem | Path.Path\n > {\n const config = path.join(directory, ConvexConfig.CONVEX_CONFIG_FILENAME);\n if (!(yield* fs.exists(config))) return;\n const installed = yield* ConvexConfig.discoverInstalledComponents(\n config,\n relative(config),\n kind,\n );\n for (const component of installed) {\n const name = prefix + component.name;\n const mount =\n prefix === \"\"\n ? App.mounts(app).find((declared) => declared.name === component.name)\n : undefined;\n // A bare definition belongs to another package. Its directory is read\n // here but never written out; tests reach it through `<package>/test`\n // or the kit its mount names.\n const fromPackage = !path.isAbsolute(component.componentDefinitionPath);\n const kitEntry =\n mount?.testing ??\n (fromPackage ? `${component.componentDefinitionPath}/test` : undefined);\n const resolved = fromPackage\n ? path.dirname(\n yield* ConvexConfig.resolveDefinition(\n `${component.componentDefinitionPath}/convex.config`,\n config,\n path,\n ).pipe(\n Effect.fromOption,\n Effect.mapError(\n () =>\n new CodegenError.InvalidConvexConfigError({\n configPath: relative(config),\n reason: `Cannot resolve component ${component.componentDefinitionPath} for testing.`,\n }),\n ),\n ),\n )\n : component.componentDefinitionPath;\n const localPrefix =\n prefix === \"\" ? mount?.httpPrefix : component.httpPrefix;\n const httpPrefix =\n parentHttpPrefix === undefined || localPrefix === undefined\n ? undefined\n : `${parentHttpPrefix.replace(/\\/+$/, \"\")}${localPrefix}`.replace(\n /\\/+$/,\n \"\",\n ) || \"/\";\n if (\n httpPrefix !== undefined &&\n ((yield* fs.exists(path.join(resolved, \"http.ts\"))) ||\n (yield* fs.exists(path.join(resolved, \"http.js\"))))\n ) {\n httpMounts.push(\n `{ componentPath: ${quote(name)}, httpPrefix: ${quote(httpPrefix)} }`,\n );\n }\n // A kit's `register` installs the mount's own children, so below it the\n // walk only collects HTTP mounts.\n if (!registeredByKit) {\n const kitKey = kitEntry ?? resolved;\n let identifier = kits.get(kitKey);\n if (identifier === undefined) {\n const cleaned = name.replaceAll(/[^A-Za-z0-9_$]/g, \"_\");\n const base = /^[A-Za-z_$]/.test(cleaned) ? cleaned : `_${cleaned}`;\n identifier = `${base}Kit`;\n let schemaIdentifier = `${base}Schema`;\n for (\n let n = 2;\n identifiers.has(identifier) || identifiers.has(schemaIdentifier);\n n++\n ) {\n identifier = `${base}Kit${n}`;\n schemaIdentifier = `${base}Schema${n}`;\n }\n identifiers.add(identifier);\n identifiers.add(schemaIdentifier);\n kits.set(kitKey, identifier);\n if (kitEntry === undefined) {\n imports.push(\n `import ${schemaIdentifier} from ${quote(relative(path.join(resolved, \"schema.js\")))};`,\n );\n declarations.push(\n `const ${identifier} = { schema: ${schemaIdentifier}, modules: ${yield* moduleMap(resolved)} };`,\n );\n } else {\n if (mount?.testing !== undefined) {\n yield* checkTestKit(\n mount.name,\n mount.testing,\n config,\n configDisplay,\n );\n } else if (Option.isNone(Bundler.resolveModule(kitEntry, config))) {\n return yield* new CodegenError.InvalidConvexConfigError({\n configPath: relative(config),\n reason: `the component package ${quote(component.componentDefinitionPath)} has no ${quote(kitEntry)} export. Tests register a component from another package through that entry's \\`register(t, name)\\`.`,\n });\n }\n imports.push(`import * as ${identifier} from ${quote(kitEntry)};`);\n }\n }\n components.push(`${quote(name)}: ${identifier},`);\n }\n // A package's own `register` installs its children.\n if (!fromPackage) {\n yield* visit(\n resolved,\n `${name}/`,\n \"component\",\n httpPrefix,\n registeredByKit || kitEntry !== undefined,\n );\n }\n }\n });\n yield* visit(\n convexDirectory,\n \"\",\n (yield* ConvexDirectory.target).kind,\n \"\",\n false,\n );\n yield* writeFileStringAndLog(\n path.join(generated, \"testing.ts\"),\n [\n \"// Generated by `confect codegen`. Test-only; do not import in backend functions.\",\n ...imports,\n ...declarations,\n `export default { httpMounts: [${httpMounts.join(\",\")}], schema, convexSchema, modules: ${yield* moduleMap(convexDirectory)}, components: {${components.join(\"\\n\")}} };`,\n ].join(\"\\n\"),\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,MAAM,oBAAoB;AAE1B,MAAM,cAAc,OAAO,IACzB,gBAAgB,SACf,WAAW,OAAO,SAAS,WAC9B;AAEA,MAAM,sBAAsB,OAAO,IAAI,KAAK,OAAO,SACjD,KAAK,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M,CAAC,GAC9D,OAAO,OAAO,IAAIpB,yBAAsC;OACtD,YAAY,SAAS,MAAM;OAC3B,QAAQ,yBAAyB,MAAM,UAAU,uBAAuB,EAAE,UAAU,MAAM,QAAQ,EAAE;MACtG,CAAC;MAEH,QAAQ,KAAK,eAAe,WAAW,QAAQ,MAAM,QAAQ,EAAE,EAAE;KACnE;IACF;IACA,WAAW,KAAK,GAAG,MAAM,IAAI,EAAE,IAAI,WAAW,EAAE;GAClD;GAEA,IAAI,CAAC,aACH,OAAO,MACL,UACA,GAAG,KAAK,IACR,aACA,YACA,mBAAmB,aAAa,KAAA,CAClC;EAEJ;CACF,CAAC;CACD,OAAO,MACL,iBACA,KACC,OAAO,gBAAgB,OAAA,CAAQ,MAChC,IACA,KACF;CACA,OAAO,sBACL,KAAK,KAAK,WAAW,YAAY,GACjC;EACE;EACA,GAAG;EACH,GAAG;EACH,iCAAiC,WAAW,KAAK,GAAG,EAAE,oCAAoC,OAAO,UAAU,eAAe,EAAE,iBAAiB,WAAW,KAAK,IAAI,EAAE;CACrK,CAAC,CAAC,KAAK,IAAI,CACb;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaganref/confect-cli",
3
- "version": "10.3.1-fork.17",
3
+ "version": "10.3.1-fork.18",
4
4
  "dependencies": {
5
5
  "@effect/platform-node": "^4.0.4",
6
6
  "bundle-require": "^5.1.0",
@@ -9,8 +9,8 @@
9
9
  "exsolve": "^1.1.3"
10
10
  },
11
11
  "peerDependencies": {
12
- "@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.17",
13
- "@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.17",
12
+ "@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.18",
13
+ "@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.18",
14
14
  "effect": "^4.0.4"
15
15
  },
16
16
  "description": "Developer tooling for codegen and sync",