@gaganref/confect-cli 10.3.1-fork.5 → 10.3.1-fork.7

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.
@@ -141,7 +141,7 @@ const renderSpecImportsServerError = (error) => {
141
141
  };
142
142
  const renderImplMissingSpecImportError = (error) => {
143
143
  const stem = stemFromSpecPath(error.expectedSpecPath);
144
- return singleLine("Impl ", formatPath(error.implPath), ` does not import its sibling spec; add \`import ${stem} from "./${stem}.spec"\` and pass it to FunctionImpl.make/GroupImpl.make.`);
144
+ return singleLine("Impl ", formatPath(error.implPath), ` does not import its sibling spec; add \`import ${stem} from "./${stem}.spec.js"\` and pass it to FunctionImpl.make/GroupImpl.make.`);
145
145
  };
146
146
  const renderImplMissingDefaultLayerError = (error) => singleLine("Impl ", formatPath(error.implPath), " must default-export a GroupImpl layer; wrap your handlers with `GroupImpl.make(databaseSchema, groupSpec).pipe(Layer.provide(...))` and `export default` it.");
147
147
  const renderImplNotFinalizedError = (error) => singleLine("Impl ", formatPath(error.implPath), " is not finalized; append `GroupImpl.finalize` to the end of the pipeline (e.g. `GroupImpl.make(databaseSchema, group).pipe(Layer.provide(...), GroupImpl.finalize)`).");
@@ -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\"\\` 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,CA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,MAAM,KAAK,CAAC,CAAC,KACxB,MAAM,IAAI,kBAAkB,EAAE,QAAQ,cAAc,mBAClD,WACE,gCAAgC,OAAO,IACvC,iBAAiB,KAAK,KAAK,QAAQ,gBACnC,aAAa,WAAW,IAAI,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 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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AAO,UAAU,UACf,eAAe,KAAK,IAAI,gBAAgB,KAAK,IAAI,OAAO,IAC1D,CACF"}
@@ -49,7 +49,7 @@ const groupPathFromRelativeModulePath = Effect.fnUntraced(function* (relativePat
49
49
  });
50
50
  const specImportPathFromGenerated = Effect.fnUntraced(function* (specRelativePath) {
51
51
  const path = yield* Path.Path;
52
- return `../${toPosixPath(path, yield* removePathExtension(specRelativePath))}`;
52
+ return `../${toPosixPath(path, yield* removePathExtension(specRelativePath))}.js`;
53
53
  });
54
54
  const specPathForImpl = (implRelativePath) => swapModuleSuffix(implRelativePath, IMPL_SUFFIX, SPEC_SUFFIX);
55
55
  const implPathForSpec = (specRelativePath) => swapModuleSuffix(specRelativePath, SPEC_SUFFIX, IMPL_SUFFIX);
@@ -1 +1 @@
1
- {"version":3,"file":"LeafModule.mjs","names":["Bundler.importersOfPackage","Bundler.bundle","Bundler.directlyImports","Bundler.withBatch"],"sources":["../src/LeafModule.ts"],"sourcesContent":["import { GroupSpec, MiddlewareAttachment } from \"@confect/core\";\nimport { Registry, type RegistryItems } from \"@confect/server\";\nimport * as GroupImpl from \"@confect/server/GroupImpl\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport type { Context } from \"effect\";\nimport * as Array from \"effect/Array\";\nimport * as Brand from \"effect/Brand\";\nimport * as Effect from \"effect/Effect\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Layer from \"effect/Layer\";\nimport * as Option from \"effect/Option\";\nimport * as Ref from \"effect/Ref\";\nimport * as Schema from \"effect/Schema\";\nimport * as String from \"effect/String\";\nimport { fromBundlerError } from \"./BuildError.js\";\nimport * as Bundler from \"./Bundler.js\";\nimport {\n MissingImplFileError,\n MissingSpecFileError,\n ImplMissingDefaultLayerError,\n ImplMissingFunctionsError,\n ImplMissingMiddlewareError,\n ImplMissingSpecImportError,\n ImplNotFinalizedError,\n InvalidMiddlewareAttachmentError,\n SpecImportsServerError,\n SpecMissingDefaultGroupSpecError,\n} from \"./CodegenError.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\nimport { ImplModulePath } from \"./ImplModulePath.js\";\nimport { removePathExtension, toPosixPath } from \"./utils.js\";\n\nexport interface LeafModule {\n readonly relativePath: string;\n readonly pathSegments: readonly [string, ...string[]];\n readonly groupPathDot: string;\n readonly exportName: string;\n readonly specImportPath: string;\n}\n\nexport type LoadedLeafModule = LeafModule & {\n readonly spec: GroupSpec.AnyWithProps;\n} & Brand.Brand<\"@confect/cli/LoadedLeafModule\">;\n\nconst LoadedLeafModule = Brand.nominal<LoadedLeafModule>();\n\nconst VALIDATION_CONCURRENCY = 4;\n\nexport const SPEC_SUFFIX = \".spec.ts\";\nexport const IMPL_SUFFIX = \".impl.ts\";\n\nconst swapModuleSuffix = Effect.fnUntraced(function* (\n relativePath: string,\n fromSuffix: string,\n toSuffix: string,\n) {\n const path = yield* Path.Path;\n const { dir, name, ext } = path.parse(relativePath);\n if (ext !== \".ts\" || !name.endsWith(fromSuffix.slice(0, -\".ts\".length))) {\n return relativePath;\n }\n\n const stem = name.slice(0, -fromSuffix.slice(0, -\".ts\".length).length);\n const nextName = `${stem}${toSuffix.slice(0, -\".ts\".length)}`;\n return dir.length > 0\n ? path.join(dir, `${nextName}${ext}`)\n : `${nextName}${ext}`;\n});\n\nexport const isLeafSpecPath = (relativePath: string) =>\n relativePath.endsWith(SPEC_SUFFIX);\n\nexport const exportNameFromModulePath = Effect.fnUntraced(function* (\n relativePath: string,\n) {\n const path = yield* Path.Path;\n const { name, ext } = path.parse(relativePath);\n if (ext !== \".ts\") {\n return name;\n }\n return name.endsWith(\".spec\") ? name.slice(0, -\".spec\".length) : name;\n});\n\nexport const groupPathFromRelativeModulePath = Effect.fnUntraced(function* (\n relativePath: string,\n) {\n const path = yield* Path.Path;\n const { dir, name, ext } = path.parse(relativePath);\n const stem =\n ext === \".ts\" && name.endsWith(\".spec\")\n ? name.slice(0, -\".spec\".length)\n : name;\n const dirSegments = Array.filter(\n String.split(dir, path.sep),\n String.isNonEmpty,\n );\n const pathSegments = Array.append(dirSegments, stem) as [string, ...string[]];\n return {\n pathSegments,\n groupPathDot: Array.join(pathSegments, \".\"),\n };\n});\n\nexport const specImportPathFromGenerated = Effect.fnUntraced(function* (\n specRelativePath: string,\n) {\n const path = yield* Path.Path;\n const withoutExt = toPosixPath(\n path,\n yield* removePathExtension(specRelativePath),\n );\n return `../${withoutExt}`;\n});\n\nexport const specPathForImpl = (implRelativePath: string) =>\n swapModuleSuffix(implRelativePath, IMPL_SUFFIX, SPEC_SUFFIX);\n\nexport const implPathForSpec = (specRelativePath: string) =>\n swapModuleSuffix(specRelativePath, SPEC_SUFFIX, IMPL_SUFFIX);\n\nexport const registeredFunctionsRelativePath = Effect.fnUntraced(function* (\n leaf: LeafModule,\n) {\n const path = yield* Path.Path;\n return path.join(\"registeredFunctions\", ...leaf.pathSegments) + \".ts\";\n});\n\nexport const discoverLeafSpecFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const excludedDirs = HashSet.make(\"_generated\", \"tables\", \"middleware\");\n const excludedFiles = HashSet.make(\"nodeSpec.ts\", \"spec.ts\");\n\n const allPaths = yield* fs.readDirectory(confectDirectory, {\n recursive: true,\n });\n\n return Array.filter(allPaths, (relativePath) => {\n if (!isLeafSpecPath(relativePath)) {\n return false;\n }\n\n if (HashSet.has(excludedFiles, relativePath)) {\n return false;\n }\n\n const segments = String.split(relativePath, path.sep);\n return !Array.some(segments, (segment) =>\n HashSet.has(excludedDirs, segment),\n );\n });\n});\n\nexport const discoverLeafImplFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const excludedDirs = HashSet.make(\"_generated\", \"tables\", \"middleware\");\n\n const allPaths = yield* fs.readDirectory(confectDirectory, {\n recursive: true,\n });\n\n return Array.filter(\n Array.filterMap(allPaths, (relativePath) =>\n Schema.decodeResult(ImplModulePath)(relativePath),\n ),\n (relativePath) => {\n const segments = String.split(relativePath, path.sep);\n return !Array.some(segments, (segment) =>\n HashSet.has(excludedDirs, segment),\n );\n },\n );\n});\n\nexport const toLeafModule = Effect.fnUntraced(function* (\n specRelativePath: string,\n) {\n const exportName = yield* exportNameFromModulePath(specRelativePath);\n const { pathSegments, groupPathDot } =\n yield* groupPathFromRelativeModulePath(specRelativePath);\n const specImportPath = yield* specImportPathFromGenerated(specRelativePath);\n\n return {\n relativePath: specRelativePath,\n pathSegments,\n groupPathDot,\n exportName,\n specImportPath,\n } satisfies LeafModule;\n});\n\nconst absoluteModulePath = Effect.fnUntraced(function* (relativePath: string) {\n const confectDirectory = yield* ConfectDirectory.get;\n const path = yield* Path.Path;\n return path.resolve(confectDirectory, relativePath);\n});\n\n/**\n * Every `*.spec.ts` is reachable from `_generated/spec.ts`, which the client\n * imports through `_generated/refs.ts`—so a spec's whole import graph is\n * bundled into the browser whether or not the client calls those functions.\n * Server logic co-located with a declaration therefore ships to users,\n * silently.\n *\n * `@confect/server` is a sound proxy for \"server logic lives here\": an\n * implementation can't be written without `FunctionImpl`/`MiddlewareImpl`, both\n * of which live there. Table `Doc`/`Fields` schemas live in `@confect/core`, so\n * the documented `notes.Doc` pattern in a spec must not reach `@confect/server`\n * even through `tables/` or `_generated/`. The check runs over the spec\n * bundle's transitive inputs rather than the spec module alone, so it also\n * covers middleware declarations under `confect/middleware/` (which codegen\n * otherwise never visits) and any shared helper a spec pulls in—while only ever\n * flagging modules that genuinely reach the client.\n */\nconst validateClientSafety = Effect.fnUntraced(function* (\n leaf: LeafModule,\n bundled: Bundler.Bundled,\n) {\n const path = yield* Path.Path;\n const confectDirectory = path.resolve(yield* ConfectDirectory.get);\n\n const isCheckedUserModule = (absolutePath: string) => {\n const relative = path.relative(confectDirectory, absolutePath);\n return !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n };\n\n const importers = Bundler.importersOfPackage(\n bundled,\n \"@confect/server\",\n isCheckedUserModule,\n );\n\n if (importers.length > 0) {\n return yield* new SpecImportsServerError({\n specPath: leaf.relativePath,\n importerPaths: Array.map(importers, (absolutePath) =>\n toPosixPath(path, path.relative(confectDirectory, absolutePath)),\n ),\n });\n }\n});\n\n/**\n * Validate that the leaf's spec file default-exports a `GroupSpec`, and that\n * nothing it reaches drags server code into the client (see\n * {@link validateClientSafety}). Returns the leaf paired with its validated\n * spec, so subsequent operations reuse that association without re-bundling.\n * The runtime is declared by the spec, not its file location.\n */\nexport const loadSpec = Effect.fn(\"LeafModule.loadSpec\")(function* (\n leaf: LeafModule,\n) {\n const absolutePath = yield* absoluteModulePath(leaf.relativePath);\n const bundled = yield* Bundler.bundle(absolutePath).pipe(\n Effect.mapError((error) => fromBundlerError(leaf.relativePath, error)),\n );\n\n const groupSpec = bundled.module.default;\n\n if (!GroupSpec.isGroupSpec(groupSpec)) {\n return yield* new SpecMissingDefaultGroupSpecError({\n specPath: leaf.relativePath,\n });\n }\n\n yield* validateClientSafety(leaf, bundled);\n\n yield* Effect.fromResult(GroupSpec.validateMiddleware(groupSpec)).pipe(\n Effect.mapError(\n (error) =>\n new InvalidMiddlewareAttachmentError({\n specPath: leaf.relativePath,\n message: MiddlewareAttachment.formatValidationError(error),\n }),\n ),\n );\n\n return LoadedLeafModule({\n ...leaf,\n spec: groupSpec,\n });\n});\n\n/**\n * Walk the built `Context` for a `Finalized` `GroupImpl` service value. The\n * lookup is value-shaped (via `GroupImpl.isFinalizedGroupImpl`) so we don't\n * need to know the group's path up front to construct a typed tag for it.\n */\nconst findFinalizedGroupImpl = <S>(\n context: Context.Context<S>,\n): Option.Option<GroupImpl.AnyFinalized> =>\n Array.findFirst(context.mapUnsafe.values(), GroupImpl.isFinalizedGroupImpl);\n\n/**\n * Build the impl layer with a fresh `Registry` so each validation is isolated\n * from prior validations' `FunctionImpl.make` writes. The CLI no longer reads\n * the registry directly—`GroupImpl.finalize` snapshots the registered function\n * names onto the produced `Finalized` `GroupImpl` service value—but a fresh\n * `Ref` is still required because the default `Context.Reference` is cached\n * globally and would otherwise accumulate items across impls.\n */\nconst buildImplLayer = Effect.fnUntraced(function* (\n implLayer: Layer.Layer<unknown>,\n) {\n const registry = Ref.makeUnsafe<RegistryItems.RegistryItems>({});\n return yield* Layer.build(\n implLayer as Layer.Layer<unknown, never, never>,\n ).pipe(Effect.provideService(Registry.Registry, registry));\n}, Effect.scoped);\n\n/**\n * Validate that the leaf's sibling impl file imports the spec, default-exports\n * a finalized `GroupImpl` layer, and provides a `FunctionImpl` for every\n * function declared by the spec.\n */\nexport const validateImpl = Effect.fn(\"LeafModule.validateImpl\")(function* (\n leaf: LoadedLeafModule,\n) {\n const implRelativePath = yield* implPathForSpec(leaf.relativePath);\n const implAbsolutePath = yield* absoluteModulePath(implRelativePath);\n const specAbsolutePath = yield* absoluteModulePath(leaf.relativePath);\n\n const bundled = yield* Bundler.bundle(implAbsolutePath).pipe(\n Effect.mapError((error) => fromBundlerError(implRelativePath, error)),\n );\n\n if (\n !(yield* Bundler.directlyImports(\n bundled,\n implAbsolutePath,\n specAbsolutePath,\n ))\n ) {\n return yield* new ImplMissingSpecImportError({\n implPath: implRelativePath,\n expectedSpecPath: leaf.relativePath,\n });\n }\n\n if (!Layer.isLayer(bundled.module.default)) {\n return yield* new ImplMissingDefaultLayerError({\n implPath: implRelativePath,\n });\n }\n\n const groupSpec = leaf.spec;\n const expectedFunctionNames = Object.keys(groupSpec.functions);\n\n const context = yield* buildImplLayer(\n bundled.module.default as Layer.Layer<unknown>,\n );\n const finalizedGroupImpl = yield* Option.match(\n findFinalizedGroupImpl(context),\n {\n onNone: () => new ImplNotFinalizedError({ implPath: implRelativePath }),\n onSome: Effect.succeed,\n },\n );\n\n const registeredSet = HashSet.fromIterable(\n finalizedGroupImpl.registeredFunctionNames,\n );\n const missing = expectedFunctionNames.filter(\n (name) => !HashSet.has(registeredSet, name),\n );\n\n if (missing.length > 0) {\n return yield* new ImplMissingFunctionsError({\n implPath: implRelativePath,\n groupPath: leaf.groupPathDot,\n missingFunctionNames: missing,\n });\n }\n\n const expectedMiddlewareKeys = Array.dedupe([\n ...(groupSpec.middlewareSpecs ?? []).map(\n (middlewareSpec) => middlewareSpec.key,\n ),\n ...Object.values(groupSpec.functions).flatMap((function_) =>\n (function_.middlewareSpecs ?? []).map(\n (middlewareSpec) => middlewareSpec.key,\n ),\n ),\n ]);\n const registeredMiddlewareKeys = HashSet.fromIterable(\n finalizedGroupImpl.registeredMiddlewareKeys ?? [],\n );\n const missingMiddleware = Array.filter(\n expectedMiddlewareKeys,\n (key) => !HashSet.has(registeredMiddlewareKeys, key),\n );\n\n if (missingMiddleware.length > 0) {\n return yield* new ImplMissingMiddlewareError({\n implPath: implRelativePath,\n groupPath: leaf.groupPathDot,\n missingMiddlewareKeys: missingMiddleware,\n });\n }\n});\n\nexport const withImplFiles = Effect.fnUntraced(function* <A, E, R>(\n relativePaths: ReadonlyArray<ImplModulePath>,\n use: (leaves: ReadonlyArray<LoadedLeafModule>) => Effect.Effect<A, E, R>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const pairs = yield* Effect.forEach(relativePaths, (implRelativePath) =>\n specPathForImpl(implRelativePath).pipe(\n Effect.map((specRelativePath) => ({\n implRelativePath,\n specRelativePath,\n })),\n ),\n );\n\n return yield* Bundler.withBatch(\n pairs.flatMap(({ implRelativePath, specRelativePath }) => [\n path.resolve(confectDirectory, implRelativePath),\n path.resolve(confectDirectory, specRelativePath),\n ]),\n Effect.gen(function* () {\n const leaves = yield* Effect.forEach(\n pairs,\n Effect.fnUntraced(function* ({ implRelativePath, specRelativePath }) {\n if (\n !(yield* fs.exists(path.join(confectDirectory, specRelativePath)))\n ) {\n return yield* new MissingSpecFileError({\n implPath: implRelativePath,\n expectedSpecPath: specRelativePath,\n });\n }\n if (\n !(yield* fs.exists(path.join(confectDirectory, implRelativePath)))\n ) {\n return yield* new MissingImplFileError({\n specPath: specRelativePath,\n expectedImplPath: implRelativePath,\n });\n }\n const leaf = yield* loadSpec(yield* toLeafModule(specRelativePath));\n return leaf;\n }),\n { concurrency: VALIDATION_CONCURRENCY },\n );\n return yield* use(leaves);\n }),\n );\n});\n\nexport const validateImplFiles = Effect.fn(\"LeafModule.validateImplFiles\")(\n (relativePaths: ReadonlyArray<ImplModulePath>) =>\n withImplFiles(relativePaths, validateAllImpls),\n);\n\nexport const validateAllImpls = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<LoadedLeafModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const implementationPaths = yield* Effect.forEach(\n leaves,\n ({ relativePath }) =>\n implPathForSpec(relativePath).pipe(\n Effect.map((implPath) => path.resolve(confectDirectory, implPath)),\n ),\n );\n yield* Bundler.withBatch(\n implementationPaths,\n Effect.forEach(leaves, validateImpl, {\n concurrency: VALIDATION_CONCURRENCY,\n discard: true,\n }),\n );\n});\n\nexport const loadAll = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const specFiles = yield* discoverLeafSpecFiles;\n\n const results = yield* Bundler.withBatch(\n specFiles.map((relativePath) =>\n path.resolve(confectDirectory, relativePath),\n ),\n Effect.forEach(\n specFiles,\n Effect.fnUntraced(function* (specRelativePath: string) {\n const discovered = yield* toLeafModule(specRelativePath);\n const leaf = yield* loadSpec(discovered);\n\n const implRelativePath = yield* implPathForSpec(specRelativePath);\n const implAbsolutePath = path.join(confectDirectory, implRelativePath);\n if (!(yield* fs.exists(implAbsolutePath))) {\n return yield* new MissingImplFileError({\n specPath: specRelativePath,\n expectedImplPath: implRelativePath,\n });\n }\n\n return leaf;\n }),\n { concurrency: VALIDATION_CONCURRENCY },\n ),\n );\n\n yield* validateOrphanImpls(specFiles);\n\n return results;\n});\n\n/**\n * Walk leaf ancestors and fail with a {@link ParentChildNameCollisionError} when\n * a parent leaf declares a function or subgroup whose name matches a sibling\n * subdirectory spec's segment. Without this check the colliding descendant\n * would overwrite the parent's entry in the assembled `GroupSpec.groups` map at\n * runtime, surfacing as a confusing `Refs.make` error rather than a\n * codegen-time diagnostic.\n */\nconst validateOrphanImpls = Effect.fnUntraced(function* (\n specFiles: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const implFiles = yield* discoverLeafImplFiles;\n const specPaths = HashSet.fromIterable(specFiles);\n\n yield* Effect.forEach(\n implFiles,\n Effect.fnUntraced(function* (implRelativePath: string) {\n const specRelativePath = yield* specPathForImpl(implRelativePath);\n if (HashSet.has(specPaths, specRelativePath)) {\n return;\n }\n\n const specAbsolutePath = path.join(confectDirectory, specRelativePath);\n if (!(yield* fs.exists(specAbsolutePath))) {\n return yield* new MissingSpecFileError({\n implPath: implRelativePath,\n expectedSpecPath: specRelativePath,\n });\n }\n }),\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,mBAAmB,MAAM,QAA0B;AAEzD,MAAM,yBAAyB;AAE/B,MAAa,cAAc;AAC3B,MAAa,cAAc;AAE3B,MAAM,mBAAmB,OAAO,WAAW,WACzC,cACA,YACA,UACA;CACA,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,EAAE,KAAK,MAAM,QAAQ,KAAK,MAAM,YAAY;CAClD,IAAI,QAAQ,SAAS,CAAC,KAAK,SAAS,WAAW,MAAM,GAAG,EAAa,CAAC,GACpE,OAAO;CAIT,MAAM,WAAW,GADJ,KAAK,MAAM,GAAG,CAAC,WAAW,MAAM,GAAG,EAAa,CAAC,CAAC,MACxC,IAAI,SAAS,MAAM,GAAG,EAAa;CAC1D,OAAO,IAAI,SAAS,IAChB,KAAK,KAAK,KAAK,GAAG,WAAW,KAAK,IAClC,GAAG,WAAW;AACpB,CAAC;AAED,MAAa,kBAAkB,iBAC7B,aAAa,SAAS,W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,IACrC,OAAO,OAAO,IAAI,qBAAqB;GACrC,UAAU;GACV,kBAAkB;EACpB,CAAC;EAGH,OAAO;CACT,CAAC,GACD,EAAE,aAAa,uBAAuB,CACxC,CACF;CAEA,OAAO,oBAAoB,SAAS;CAEpC,OAAO;AACT,CAAC;;;;;;;;;AAUD,MAAM,sBAAsB,OAAO,WAAW,WAC5C,WACA;CACA,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,mBAAmB,OAAO,iBAAiB;CACjD,MAAM,YAAY,OAAO;CACzB,MAAM,YAAY,QAAQ,aAAa,SAAS;CAEhD,OAAO,OAAO,QACZ,WACA,OAAO,WAAW,WAAW,kBAA0B;EACrD,MAAM,mBAAmB,OAAO,gBAAgB,gBAAgB;EAChE,IAAI,QAAQ,IAAI,WAAW,gBAAgB,GACzC;EAGF,MAAM,mBAAmB,KAAK,KAAK,kBAAkB,gBAAgB;EACrE,IAAI,EAAE,OAAO,GAAG,OAAO,gBAAgB,IACrC,OAAO,OAAO,IAAI,qBAAqB;GACrC,UAAU;GACV,kBAAkB;EACpB,CAAC;CAEL,CAAC,CACH;AACF,CAAC"}
1
+ {"version":3,"file":"LeafModule.mjs","names":["Bundler.importersOfPackage","Bundler.bundle","Bundler.directlyImports","Bundler.withBatch"],"sources":["../src/LeafModule.ts"],"sourcesContent":["import { GroupSpec, MiddlewareAttachment } from \"@confect/core\";\nimport { Registry, type RegistryItems } from \"@confect/server\";\nimport * as GroupImpl from \"@confect/server/GroupImpl\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport type { Context } from \"effect\";\nimport * as Array from \"effect/Array\";\nimport * as Brand from \"effect/Brand\";\nimport * as Effect from \"effect/Effect\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Layer from \"effect/Layer\";\nimport * as Option from \"effect/Option\";\nimport * as Ref from \"effect/Ref\";\nimport * as Schema from \"effect/Schema\";\nimport * as String from \"effect/String\";\nimport { fromBundlerError } from \"./BuildError.js\";\nimport * as Bundler from \"./Bundler.js\";\nimport {\n MissingImplFileError,\n MissingSpecFileError,\n ImplMissingDefaultLayerError,\n ImplMissingFunctionsError,\n ImplMissingMiddlewareError,\n ImplMissingSpecImportError,\n ImplNotFinalizedError,\n InvalidMiddlewareAttachmentError,\n SpecImportsServerError,\n SpecMissingDefaultGroupSpecError,\n} from \"./CodegenError.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\nimport { ImplModulePath } from \"./ImplModulePath.js\";\nimport { removePathExtension, toPosixPath } from \"./utils.js\";\n\nexport interface LeafModule {\n readonly relativePath: string;\n readonly pathSegments: readonly [string, ...string[]];\n readonly groupPathDot: string;\n readonly exportName: string;\n readonly specImportPath: string;\n}\n\nexport type LoadedLeafModule = LeafModule & {\n readonly spec: GroupSpec.AnyWithProps;\n} & Brand.Brand<\"@confect/cli/LoadedLeafModule\">;\n\nconst LoadedLeafModule = Brand.nominal<LoadedLeafModule>();\n\nconst VALIDATION_CONCURRENCY = 4;\n\nexport const SPEC_SUFFIX = \".spec.ts\";\nexport const IMPL_SUFFIX = \".impl.ts\";\n\nconst swapModuleSuffix = Effect.fnUntraced(function* (\n relativePath: string,\n fromSuffix: string,\n toSuffix: string,\n) {\n const path = yield* Path.Path;\n const { dir, name, ext } = path.parse(relativePath);\n if (ext !== \".ts\" || !name.endsWith(fromSuffix.slice(0, -\".ts\".length))) {\n return relativePath;\n }\n\n const stem = name.slice(0, -fromSuffix.slice(0, -\".ts\".length).length);\n const nextName = `${stem}${toSuffix.slice(0, -\".ts\".length)}`;\n return dir.length > 0\n ? path.join(dir, `${nextName}${ext}`)\n : `${nextName}${ext}`;\n});\n\nexport const isLeafSpecPath = (relativePath: string) =>\n relativePath.endsWith(SPEC_SUFFIX);\n\nexport const exportNameFromModulePath = Effect.fnUntraced(function* (\n relativePath: string,\n) {\n const path = yield* Path.Path;\n const { name, ext } = path.parse(relativePath);\n if (ext !== \".ts\") {\n return name;\n }\n return name.endsWith(\".spec\") ? name.slice(0, -\".spec\".length) : name;\n});\n\nexport const groupPathFromRelativeModulePath = Effect.fnUntraced(function* (\n relativePath: string,\n) {\n const path = yield* Path.Path;\n const { dir, name, ext } = path.parse(relativePath);\n const stem =\n ext === \".ts\" && name.endsWith(\".spec\")\n ? name.slice(0, -\".spec\".length)\n : name;\n const dirSegments = Array.filter(\n String.split(dir, path.sep),\n String.isNonEmpty,\n );\n const pathSegments = Array.append(dirSegments, stem) as [string, ...string[]];\n return {\n pathSegments,\n groupPathDot: Array.join(pathSegments, \".\"),\n };\n});\n\nexport const specImportPathFromGenerated = Effect.fnUntraced(function* (\n specRelativePath: string,\n) {\n const path = yield* Path.Path;\n const withoutExt = toPosixPath(\n path,\n yield* removePathExtension(specRelativePath),\n );\n return `../${withoutExt}.js`;\n});\n\nexport const specPathForImpl = (implRelativePath: string) =>\n swapModuleSuffix(implRelativePath, IMPL_SUFFIX, SPEC_SUFFIX);\n\nexport const implPathForSpec = (specRelativePath: string) =>\n swapModuleSuffix(specRelativePath, SPEC_SUFFIX, IMPL_SUFFIX);\n\nexport const registeredFunctionsRelativePath = Effect.fnUntraced(function* (\n leaf: LeafModule,\n) {\n const path = yield* Path.Path;\n return path.join(\"registeredFunctions\", ...leaf.pathSegments) + \".ts\";\n});\n\nexport const discoverLeafSpecFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const excludedDirs = HashSet.make(\"_generated\", \"tables\", \"middleware\");\n const excludedFiles = HashSet.make(\"nodeSpec.ts\", \"spec.ts\");\n\n const allPaths = yield* fs.readDirectory(confectDirectory, {\n recursive: true,\n });\n\n return Array.filter(allPaths, (relativePath) => {\n if (!isLeafSpecPath(relativePath)) {\n return false;\n }\n\n if (HashSet.has(excludedFiles, relativePath)) {\n return false;\n }\n\n const segments = String.split(relativePath, path.sep);\n return !Array.some(segments, (segment) =>\n HashSet.has(excludedDirs, segment),\n );\n });\n});\n\nexport const discoverLeafImplFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const excludedDirs = HashSet.make(\"_generated\", \"tables\", \"middleware\");\n\n const allPaths = yield* fs.readDirectory(confectDirectory, {\n recursive: true,\n });\n\n return Array.filter(\n Array.filterMap(allPaths, (relativePath) =>\n Schema.decodeResult(ImplModulePath)(relativePath),\n ),\n (relativePath) => {\n const segments = String.split(relativePath, path.sep);\n return !Array.some(segments, (segment) =>\n HashSet.has(excludedDirs, segment),\n );\n },\n );\n});\n\nexport const toLeafModule = Effect.fnUntraced(function* (\n specRelativePath: string,\n) {\n const exportName = yield* exportNameFromModulePath(specRelativePath);\n const { pathSegments, groupPathDot } =\n yield* groupPathFromRelativeModulePath(specRelativePath);\n const specImportPath = yield* specImportPathFromGenerated(specRelativePath);\n\n return {\n relativePath: specRelativePath,\n pathSegments,\n groupPathDot,\n exportName,\n specImportPath,\n } satisfies LeafModule;\n});\n\nconst absoluteModulePath = Effect.fnUntraced(function* (relativePath: string) {\n const confectDirectory = yield* ConfectDirectory.get;\n const path = yield* Path.Path;\n return path.resolve(confectDirectory, relativePath);\n});\n\n/**\n * Every `*.spec.ts` is reachable from `_generated/spec.ts`, which the client\n * imports through `_generated/refs.ts`—so a spec's whole import graph is\n * bundled into the browser whether or not the client calls those functions.\n * Server logic co-located with a declaration therefore ships to users,\n * silently.\n *\n * `@confect/server` is a sound proxy for \"server logic lives here\": an\n * implementation can't be written without `FunctionImpl`/`MiddlewareImpl`, both\n * of which live there. Table `Doc`/`Fields` schemas live in `@confect/core`, so\n * the documented `notes.Doc` pattern in a spec must not reach `@confect/server`\n * even through `tables/` or `_generated/`. The check runs over the spec\n * bundle's transitive inputs rather than the spec module alone, so it also\n * covers middleware declarations under `confect/middleware/` (which codegen\n * otherwise never visits) and any shared helper a spec pulls in—while only ever\n * flagging modules that genuinely reach the client.\n */\nconst validateClientSafety = Effect.fnUntraced(function* (\n leaf: LeafModule,\n bundled: Bundler.Bundled,\n) {\n const path = yield* Path.Path;\n const confectDirectory = path.resolve(yield* ConfectDirectory.get);\n\n const isCheckedUserModule = (absolutePath: string) => {\n const relative = path.relative(confectDirectory, absolutePath);\n return !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n };\n\n const importers = Bundler.importersOfPackage(\n bundled,\n \"@confect/server\",\n isCheckedUserModule,\n );\n\n if (importers.length > 0) {\n return yield* new SpecImportsServerError({\n specPath: leaf.relativePath,\n importerPaths: Array.map(importers, (absolutePath) =>\n toPosixPath(path, path.relative(confectDirectory, absolutePath)),\n ),\n });\n }\n});\n\n/**\n * Validate that the leaf's spec file default-exports a `GroupSpec`, and that\n * nothing it reaches drags server code into the client (see\n * {@link validateClientSafety}). Returns the leaf paired with its validated\n * spec, so subsequent operations reuse that association without re-bundling.\n * The runtime is declared by the spec, not its file location.\n */\nexport const loadSpec = Effect.fn(\"LeafModule.loadSpec\")(function* (\n leaf: LeafModule,\n) {\n const absolutePath = yield* absoluteModulePath(leaf.relativePath);\n const bundled = yield* Bundler.bundle(absolutePath).pipe(\n Effect.mapError((error) => fromBundlerError(leaf.relativePath, error)),\n );\n\n const groupSpec = bundled.module.default;\n\n if (!GroupSpec.isGroupSpec(groupSpec)) {\n return yield* new SpecMissingDefaultGroupSpecError({\n specPath: leaf.relativePath,\n });\n }\n\n yield* validateClientSafety(leaf, bundled);\n\n yield* Effect.fromResult(GroupSpec.validateMiddleware(groupSpec)).pipe(\n Effect.mapError(\n (error) =>\n new InvalidMiddlewareAttachmentError({\n specPath: leaf.relativePath,\n message: MiddlewareAttachment.formatValidationError(error),\n }),\n ),\n );\n\n return LoadedLeafModule({\n ...leaf,\n spec: groupSpec,\n });\n});\n\n/**\n * Walk the built `Context` for a `Finalized` `GroupImpl` service value. The\n * lookup is value-shaped (via `GroupImpl.isFinalizedGroupImpl`) so we don't\n * need to know the group's path up front to construct a typed tag for it.\n */\nconst findFinalizedGroupImpl = <S>(\n context: Context.Context<S>,\n): Option.Option<GroupImpl.AnyFinalized> =>\n Array.findFirst(context.mapUnsafe.values(), GroupImpl.isFinalizedGroupImpl);\n\n/**\n * Build the impl layer with a fresh `Registry` so each validation is isolated\n * from prior validations' `FunctionImpl.make` writes. The CLI no longer reads\n * the registry directly—`GroupImpl.finalize` snapshots the registered function\n * names onto the produced `Finalized` `GroupImpl` service value—but a fresh\n * `Ref` is still required because the default `Context.Reference` is cached\n * globally and would otherwise accumulate items across impls.\n */\nconst buildImplLayer = Effect.fnUntraced(function* (\n implLayer: Layer.Layer<unknown>,\n) {\n const registry = Ref.makeUnsafe<RegistryItems.RegistryItems>({});\n return yield* Layer.build(\n implLayer as Layer.Layer<unknown, never, never>,\n ).pipe(Effect.provideService(Registry.Registry, registry));\n}, Effect.scoped);\n\n/**\n * Validate that the leaf's sibling impl file imports the spec, default-exports\n * a finalized `GroupImpl` layer, and provides a `FunctionImpl` for every\n * function declared by the spec.\n */\nexport const validateImpl = Effect.fn(\"LeafModule.validateImpl\")(function* (\n leaf: LoadedLeafModule,\n) {\n const implRelativePath = yield* implPathForSpec(leaf.relativePath);\n const implAbsolutePath = yield* absoluteModulePath(implRelativePath);\n const specAbsolutePath = yield* absoluteModulePath(leaf.relativePath);\n\n const bundled = yield* Bundler.bundle(implAbsolutePath).pipe(\n Effect.mapError((error) => fromBundlerError(implRelativePath, error)),\n );\n\n if (\n !(yield* Bundler.directlyImports(\n bundled,\n implAbsolutePath,\n specAbsolutePath,\n ))\n ) {\n return yield* new ImplMissingSpecImportError({\n implPath: implRelativePath,\n expectedSpecPath: leaf.relativePath,\n });\n }\n\n if (!Layer.isLayer(bundled.module.default)) {\n return yield* new ImplMissingDefaultLayerError({\n implPath: implRelativePath,\n });\n }\n\n const groupSpec = leaf.spec;\n const expectedFunctionNames = Object.keys(groupSpec.functions);\n\n const context = yield* buildImplLayer(\n bundled.module.default as Layer.Layer<unknown>,\n );\n const finalizedGroupImpl = yield* Option.match(\n findFinalizedGroupImpl(context),\n {\n onNone: () => new ImplNotFinalizedError({ implPath: implRelativePath }),\n onSome: Effect.succeed,\n },\n );\n\n const registeredSet = HashSet.fromIterable(\n finalizedGroupImpl.registeredFunctionNames,\n );\n const missing = expectedFunctionNames.filter(\n (name) => !HashSet.has(registeredSet, name),\n );\n\n if (missing.length > 0) {\n return yield* new ImplMissingFunctionsError({\n implPath: implRelativePath,\n groupPath: leaf.groupPathDot,\n missingFunctionNames: missing,\n });\n }\n\n const expectedMiddlewareKeys = Array.dedupe([\n ...(groupSpec.middlewareSpecs ?? []).map(\n (middlewareSpec) => middlewareSpec.key,\n ),\n ...Object.values(groupSpec.functions).flatMap((function_) =>\n (function_.middlewareSpecs ?? []).map(\n (middlewareSpec) => middlewareSpec.key,\n ),\n ),\n ]);\n const registeredMiddlewareKeys = HashSet.fromIterable(\n finalizedGroupImpl.registeredMiddlewareKeys ?? [],\n );\n const missingMiddleware = Array.filter(\n expectedMiddlewareKeys,\n (key) => !HashSet.has(registeredMiddlewareKeys, key),\n );\n\n if (missingMiddleware.length > 0) {\n return yield* new ImplMissingMiddlewareError({\n implPath: implRelativePath,\n groupPath: leaf.groupPathDot,\n missingMiddlewareKeys: missingMiddleware,\n });\n }\n});\n\nexport const withImplFiles = Effect.fnUntraced(function* <A, E, R>(\n relativePaths: ReadonlyArray<ImplModulePath>,\n use: (leaves: ReadonlyArray<LoadedLeafModule>) => Effect.Effect<A, E, R>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const pairs = yield* Effect.forEach(relativePaths, (implRelativePath) =>\n specPathForImpl(implRelativePath).pipe(\n Effect.map((specRelativePath) => ({\n implRelativePath,\n specRelativePath,\n })),\n ),\n );\n\n return yield* Bundler.withBatch(\n pairs.flatMap(({ implRelativePath, specRelativePath }) => [\n path.resolve(confectDirectory, implRelativePath),\n path.resolve(confectDirectory, specRelativePath),\n ]),\n Effect.gen(function* () {\n const leaves = yield* Effect.forEach(\n pairs,\n Effect.fnUntraced(function* ({ implRelativePath, specRelativePath }) {\n if (\n !(yield* fs.exists(path.join(confectDirectory, specRelativePath)))\n ) {\n return yield* new MissingSpecFileError({\n implPath: implRelativePath,\n expectedSpecPath: specRelativePath,\n });\n }\n if (\n !(yield* fs.exists(path.join(confectDirectory, implRelativePath)))\n ) {\n return yield* new MissingImplFileError({\n specPath: specRelativePath,\n expectedImplPath: implRelativePath,\n });\n }\n const leaf = yield* loadSpec(yield* toLeafModule(specRelativePath));\n return leaf;\n }),\n { concurrency: VALIDATION_CONCURRENCY },\n );\n return yield* use(leaves);\n }),\n );\n});\n\nexport const validateImplFiles = Effect.fn(\"LeafModule.validateImplFiles\")(\n (relativePaths: ReadonlyArray<ImplModulePath>) =>\n withImplFiles(relativePaths, validateAllImpls),\n);\n\nexport const validateAllImpls = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<LoadedLeafModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const implementationPaths = yield* Effect.forEach(\n leaves,\n ({ relativePath }) =>\n implPathForSpec(relativePath).pipe(\n Effect.map((implPath) => path.resolve(confectDirectory, implPath)),\n ),\n );\n yield* Bundler.withBatch(\n implementationPaths,\n Effect.forEach(leaves, validateImpl, {\n concurrency: VALIDATION_CONCURRENCY,\n discard: true,\n }),\n );\n});\n\nexport const loadAll = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const specFiles = yield* discoverLeafSpecFiles;\n\n const results = yield* Bundler.withBatch(\n specFiles.map((relativePath) =>\n path.resolve(confectDirectory, relativePath),\n ),\n Effect.forEach(\n specFiles,\n Effect.fnUntraced(function* (specRelativePath: string) {\n const discovered = yield* toLeafModule(specRelativePath);\n const leaf = yield* loadSpec(discovered);\n\n const implRelativePath = yield* implPathForSpec(specRelativePath);\n const implAbsolutePath = path.join(confectDirectory, implRelativePath);\n if (!(yield* fs.exists(implAbsolutePath))) {\n return yield* new MissingImplFileError({\n specPath: specRelativePath,\n expectedImplPath: implRelativePath,\n });\n }\n\n return leaf;\n }),\n { concurrency: VALIDATION_CONCURRENCY },\n ),\n );\n\n yield* validateOrphanImpls(specFiles);\n\n return results;\n});\n\n/**\n * Walk leaf ancestors and fail with a {@link ParentChildNameCollisionError} when\n * a parent leaf declares a function or subgroup whose name matches a sibling\n * subdirectory spec's segment. Without this check the colliding descendant\n * would overwrite the parent's entry in the assembled `GroupSpec.groups` map at\n * runtime, surfacing as a confusing `Refs.make` error rather than a\n * codegen-time diagnostic.\n */\nconst validateOrphanImpls = Effect.fnUntraced(function* (\n specFiles: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const implFiles = yield* discoverLeafImplFiles;\n const specPaths = HashSet.fromIterable(specFiles);\n\n yield* Effect.forEach(\n implFiles,\n Effect.fnUntraced(function* (implRelativePath: string) {\n const specRelativePath = yield* specPathForImpl(implRelativePath);\n if (HashSet.has(specPaths, specRelativePath)) {\n return;\n }\n\n const specAbsolutePath = path.join(confectDirectory, specRelativePath);\n if (!(yield* fs.exists(specAbsolutePath))) {\n return yield* new MissingSpecFileError({\n implPath: implRelativePath,\n expectedSpecPath: specRelativePath,\n });\n }\n }),\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,mBAAmB,MAAM,QAA0B;AAEzD,MAAM,yBAAyB;AAE/B,MAAa,cAAc;AAC3B,MAAa,cAAc;AAE3B,MAAM,mBAAmB,OAAO,WAAW,WACzC,cACA,YACA,UACA;CACA,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,EAAE,KAAK,MAAM,QAAQ,KAAK,MAAM,YAAY;CAClD,IAAI,QAAQ,SAAS,CAAC,KAAK,SAAS,WAAW,MAAM,GAAG,EAAa,CAAC,GACpE,OAAO;CAIT,MAAM,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OAAO,QACL,WACA,OAAO,WAAW,WAAW,kBAA0B;EACrD,MAAM,aAAa,OAAO,aAAa,gBAAgB;EACvD,MAAM,OAAO,OAAO,SAAS,UAAU;EAEvC,MAAM,mBAAmB,OAAO,gBAAgB,gBAAgB;EAChE,MAAM,mBAAmB,KAAK,KAAK,kBAAkB,gBAAgB;EACrE,IAAI,EAAE,OAAO,GAAG,OAAO,gBAAgB,IACrC,OAAO,OAAO,IAAI,qBAAqB;GACrC,UAAU;GACV,kBAAkB;EACpB,CAAC;EAGH,OAAO;CACT,CAAC,GACD,EAAE,aAAa,uBAAuB,CACxC,CACF;CAEA,OAAO,oBAAoB,SAAS;CAEpC,OAAO;AACT,CAAC;;;;;;;;;AAUD,MAAM,sBAAsB,OAAO,WAAW,WAC5C,WACA;CACA,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,mBAAmB,OAAO,iBAAiB;CACjD,MAAM,YAAY,OAAO;CACzB,MAAM,YAAY,QAAQ,aAAa,SAAS;CAEhD,OAAO,OAAO,QACZ,WACA,OAAO,WAAW,WAAW,kBAA0B;EACrD,MAAM,mBAAmB,OAAO,gBAAgB,gBAAgB;EAChE,IAAI,QAAQ,IAAI,WAAW,gBAAgB,GACzC;EAGF,MAAM,mBAAmB,KAAK,KAAK,kBAAkB,gBAAgB;EACrE,IAAI,EAAE,OAAO,GAAG,OAAO,gBAAgB,IACrC,OAAO,OAAO,IAAI,qBAAqB;GACrC,UAAU;GACV,kBAAkB;EACpB,CAAC;CAEL,CAAC,CACH;AACF,CAAC"}
@@ -501,13 +501,15 @@ const generateTesting = Effect.fnUntraced(function* (app) {
501
501
  const value = path.relative(generated, file).split(path.sep).join("/");
502
502
  return value.startsWith(".") ? value : `./${value}`;
503
503
  };
504
- const imports = ["import schema from \"./schema\";", "import convexSchema from \"./convexSchema\";"];
504
+ const imports = ["import schema from \"./schema.js\";", "import convexSchema from \"./convexSchema.js\";"];
505
505
  const moduleMap = Effect.fnUntraced(function* (directory) {
506
506
  return `{ "_generated/testing.ts": () => Promise.resolve({}),\n${(yield* fs.readDirectory(directory, { recursive: true })).filter((file) => /\.[cm]?[jt]s$/.test(file) && !file.endsWith(".d.ts") && !file.split(path.sep).includes("_generated") && !file.includes(".config.")).sort().map((file) => {
507
507
  const specifier = relative(path.join(directory, file));
508
- return `${quote(file.split(path.sep).join("/"))}: () => import(${quote(specifier.replace(/\.[cm]?[jt]s$/, ""))}),`;
508
+ return `${quote(file.split(path.sep).join("/"))}: () => import(${quote(specifier.replace(/\.([cm]?)[jt]s$/, ".$1js"))}),`;
509
509
  }).join("\n")}\n}`;
510
510
  });
511
+ const declarations = [];
512
+ const identifiers = /* @__PURE__ */ new Set(["schema", "convexSchema"]);
511
513
  const components = [];
512
514
  const httpMounts = [];
513
515
  const kits = /* @__PURE__ */ new Map();
@@ -527,7 +529,16 @@ const generateTesting = Effect.fnUntraced(function* (app) {
527
529
  if (httpPrefix !== void 0 && ((yield* fs.exists(path.join(resolved, "http.ts"))) || (yield* fs.exists(path.join(resolved, "http.js"))))) httpMounts.push(`{ componentPath: ${quote(name)}, httpPrefix: ${quote(httpPrefix)} }`);
528
530
  let identifier = kits.get(resolved);
529
531
  if (identifier === void 0) {
530
- identifier = `component${kits.size}`;
532
+ const cleaned = name.replaceAll(/[^A-Za-z0-9_$]/g, "_");
533
+ const base = /^[A-Za-z_$]/.test(cleaned) ? cleaned : `_${cleaned}`;
534
+ identifier = `${base}Kit`;
535
+ let schemaIdentifier = `${base}Schema`;
536
+ for (let n = 2; identifiers.has(identifier) || identifiers.has(schemaIdentifier); n++) {
537
+ identifier = `${base}Kit${n}`;
538
+ schemaIdentifier = `${base}Schema${n}`;
539
+ }
540
+ identifiers.add(identifier);
541
+ identifiers.add(schemaIdentifier);
531
542
  kits.set(resolved, identifier);
532
543
  if (fromPackage) {
533
544
  const testEntry = `${component.componentDefinitionPath}/test`;
@@ -535,11 +546,10 @@ const generateTesting = Effect.fnUntraced(function* (app) {
535
546
  configPath: relative(config),
536
547
  reason: `the component package ${quote(component.componentDefinitionPath)} has no ${quote(testEntry)} export. Tests register a component from another package through that entry's \`register(t, name)\`.`
537
548
  });
538
- imports.push(`import { register as ${identifier}Register } from ${quote(testEntry)};`);
539
- imports.push(`const ${identifier} = { register: ${identifier}Register };`);
549
+ imports.push(`import * as ${identifier} from ${quote(testEntry)};`);
540
550
  } else {
541
- imports.push(`import ${identifier}Schema from ${quote(relative(path.join(resolved, "schema")))};`);
542
- imports.push(`const ${identifier} = { schema: ${identifier}Schema, modules: ${yield* moduleMap(resolved)} };`);
551
+ imports.push(`import ${schemaIdentifier} from ${quote(relative(path.join(resolved, "schema.js")))};`);
552
+ declarations.push(`const ${identifier} = { schema: ${schemaIdentifier}, modules: ${yield* moduleMap(resolved)} };`);
543
553
  }
544
554
  }
545
555
  components.push(`${quote(name)}: ${identifier},`);
@@ -550,6 +560,7 @@ const generateTesting = Effect.fnUntraced(function* (app) {
550
560
  yield* writeFileStringAndLog(path.join(generated, "testing.ts"), [
551
561
  "// Generated by `confect codegen`. Test-only; do not import in backend functions.",
552
562
  ...imports,
563
+ ...declarations,
553
564
  `export default { httpMounts: [${httpMounts.join(",")}], schema, convexSchema, modules: ${yield* moduleMap(convexDirectory)}, components: {${components.join("\n")}} };`
554
565
  ].join("\n"));
555
566
  });
@@ -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","ConvexConfig.resolveDefinition","Bundler.resolveModule"],"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\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 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\";',\n 'import convexSchema from \"./convexSchema\";',\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$/, \"\"))}),`;\n })\n .join(\"\\n\")}\\n}`;\n });\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 ): Effect.fn.Return<\n void,\n | PlatformError.PlatformError\n | BuildError\n | CodegenError.InvalidConvexConfigError,\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 // A bare definition belongs to another package. Its directory is read\n // here but never written out; tests reach it through `<package>/test`.\n const fromPackage = !path.isAbsolute(component.componentDefinitionPath);\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 === \"\"\n ? App.mounts(app).find((mount) => mount.name === component.name)\n ?.httpPrefix\n : 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 let identifier = kits.get(resolved);\n if (identifier === undefined) {\n identifier = `component${kits.size}`;\n kits.set(resolved, identifier);\n if (fromPackage) {\n const testEntry = `${component.componentDefinitionPath}/test`;\n if (Option.isNone(Bundler.resolveModule(testEntry, config))) {\n return yield* new CodegenError.InvalidConvexConfigError({\n configPath: relative(config),\n reason: `the component package ${quote(component.componentDefinitionPath)} has no ${quote(testEntry)} export. Tests register a component from another package through that entry's \\`register(t, name)\\`.`,\n });\n }\n imports.push(\n `import { register as ${identifier}Register } from ${quote(testEntry)};`,\n );\n imports.push(\n `const ${identifier} = { register: ${identifier}Register };`,\n );\n } else {\n imports.push(\n `import ${identifier}Schema from ${quote(relative(path.join(resolved, \"schema\")))};`,\n );\n imports.push(\n `const ${identifier} = { schema: ${identifier}Schema, modules: ${yield* moduleMap(resolved)} };`,\n );\n }\n }\n components.push(`${quote(name)}: ${identifier},`);\n // A package's `register` installs its own children.\n if (!fromPackage) {\n yield* visit(resolved, `${name}/`, \"component\", httpPrefix);\n }\n }\n });\n yield* visit(convexDirectory, \"\", (yield* ConvexDirectory.target).kind, \"\");\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 `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,KAAK,mBAAmB,SAAS,CACxC;AACA,MAAM,wBAAwB,OAAO,IAAI,KAAK,OAAO,SACnD,KAAK,KAAK,mBAAmB,WAAW,CAC1C;AACA,MA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EAAE,IAAI,WAAW,EAAE;GAEhD,IAAI,CAAC,aACH,OAAO,MAAM,UAAU,GAAG,KAAK,IAAI,aAAa,UAAU;EAE9D;CACF,CAAC;CACD,OAAO,MAAM,iBAAiB,KAAK,OAAO,gBAAgB,OAAA,CAAQ,MAAM,EAAE;CAC1E,OAAO,sBACL,KAAK,KAAK,WAAW,YAAY,GACjC;EACE;EACA,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","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","ConvexConfig.resolveDefinition","Bundler.resolveModule"],"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\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 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 ): Effect.fn.Return<\n void,\n | PlatformError.PlatformError\n | BuildError\n | CodegenError.InvalidConvexConfigError,\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 // A bare definition belongs to another package. Its directory is read\n // here but never written out; tests reach it through `<package>/test`.\n const fromPackage = !path.isAbsolute(component.componentDefinitionPath);\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 === \"\"\n ? App.mounts(app).find((mount) => mount.name === component.name)\n ?.httpPrefix\n : 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 let identifier = kits.get(resolved);\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(resolved, identifier);\n if (fromPackage) {\n const testEntry = `${component.componentDefinitionPath}/test`;\n if (Option.isNone(Bundler.resolveModule(testEntry, config))) {\n return yield* new CodegenError.InvalidConvexConfigError({\n configPath: relative(config),\n reason: `the component package ${quote(component.componentDefinitionPath)} has no ${quote(testEntry)} 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(testEntry)};`);\n } else {\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 }\n }\n components.push(`${quote(name)}: ${identifier},`);\n // A package's `register` installs its own children.\n if (!fromPackage) {\n yield* visit(resolved, `${name}/`, \"component\", httpPrefix);\n }\n }\n });\n yield* visit(convexDirectory, \"\", (yield* ConvexDirectory.target).kind, \"\");\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,KAAK,mBAAmB,SAAS,CACxC;AACA,MAAM,wBAAwB,OAAO,IAAI,KAAK,OAAO,SACnD,KAAK,KAAK,mBAAmB,WAAW,CAC1C;AACA,MAAM,+BAA+B,OAAO,IAAI,KAAK,OAAO,SAC1D,KAAK,KAAK,mBAAmB,iBAAiB,CAChD;AACA,MAAM,oBAAoB,OAAO,IAAI,KAAK,OAAO,SAC/C,KAAK,KAAK,mBA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ACL,QAAQ,KACN,UAAU,iBAAiB,QAAQ,MAAM,SAAS,KAAK,KAAK,UAAU,WAAW,CAAC,CAAC,EAAE,EACvF;KACA,aAAa,KACX,SAAS,WAAW,eAAe,iBAAiB,aAAa,OAAO,UAAU,QAAQ,EAAE,IAC9F;IACF;GACF;GACA,WAAW,KAAK,GAAG,MAAM,IAAI,EAAE,IAAI,WAAW,EAAE;GAEhD,IAAI,CAAC,aACH,OAAO,MAAM,UAAU,GAAG,KAAK,IAAI,aAAa,UAAU;EAE9D;CACF,CAAC;CACD,OAAO,MAAM,iBAAiB,KAAK,OAAO,gBAAgB,OAAA,CAAQ,MAAM,EAAE;CAC1E,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"}
@@ -94,7 +94,7 @@ const componentImport = Effect.fnUntraced(function* () {
94
94
  const convexDirectory = yield* ConvexDirectory.get;
95
95
  return (definition) => Option.map(componentImportOf(definition), (recorded) => {
96
96
  const bare = !recorded.specifier.startsWith(".") && !path.isAbsolute(recorded.specifier);
97
- const relative = toPosixPath(path, path.relative(convexDirectory, recorded.path)).replace(/\.[cm]?[jt]s$/, "");
97
+ const relative = toPosixPath(path, path.relative(convexDirectory, recorded.path)).replace(/\.([cm]?)[jt]s$/, ".$1js");
98
98
  return {
99
99
  importPath: bare ? recorded.specifier : relative.startsWith(".") ? relative : `./${relative}`,
100
100
  componentName: Predicate.hasProperty(definition, "defaultName") && Predicate.isString(definition.defaultName) ? definition.defaultName : "component"
@@ -143,9 +143,10 @@ const writeDeclaration = Effect.gen(function* () {
143
143
  })), Effect.fromResult);
144
144
  const convexConfigPath = path.join(convexDirectory, CONVEX_CONFIG_FILENAME);
145
145
  const authConfigPath = path.join(convexDirectory, "auth.config.ts");
146
- const legacyAuthConfig = yield* authConfig({ authImportPath: yield* toModuleImportPath(path.relative(convexDirectory, authPath)) });
146
+ const authImportPath = yield* toModuleImportPath(path.relative(convexDirectory, authPath));
147
+ const legacyAuthConfigs = yield* Effect.forEach([authImportPath, authImportPath.replace(/\.js$/, "")], (importPath) => authConfig({ authImportPath: importPath }));
147
148
  yield* assertOwned(convexConfigPath, "app.ts", []);
148
- yield* assertOwned(authConfigPath, "auth.ts", [legacyAuthConfig]);
149
+ yield* assertOwned(authConfigPath, "auth.ts", legacyAuthConfigs);
149
150
  if (target === "app") {
150
151
  const digest$1 = digest({
151
152
  files: yield* declarationInputs([app, ...Option.toArray(auth)]),
@@ -1 +1 @@
1
- {"version":3,"file":"declaration.mjs","names":["Bundler.bundle","ConvexConfig.componentConfigPlugin","Declaration.isGenerated","Bundler.resolveModule","ConvexConfig.componentImportOf","Declaration.parse","Declaration.fileOf","ConvexConfig.CONVEX_CONFIG_FILENAME","templates.authConfig","digest","Declaration.digest","Declaration.manifest","Declaration.convexConfig","Declaration.authConfig","templates.http","http","templates.declaredHttp"],"sources":["../../src/confect/declaration.ts"],"sourcesContent":["import { App, Http } from \"@confect/core\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Option from \"effect/Option\";\nimport * as Path from \"effect/Path\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport { fromBundlerError } from \"../BuildError.js\";\nimport * as Bundler from \"../Bundler.js\";\nimport {\n HandWrittenConvexFileError,\n DeclarationKindMismatchError,\n InvalidDeclarationError,\n} from \"../CodegenError.js\";\nimport { ConfectDirectory } from \"../ConfectDirectory.js\";\nimport * as ConvexConfig from \"../ConvexConfig.js\";\nimport { ConvexDirectory } from \"../ConvexDirectory.js\";\nimport * as Declaration from \"../Declaration.js\";\nimport { logFileRemoved } from \"../log.js\";\nimport { ProjectRoot } from \"../ProjectRoot.js\";\nimport * as templates from \"../templates.js\";\nimport {\n removePathIfExists,\n toModuleImportPath,\n toPosixPath,\n writeFileString,\n writeFileStringAndLog,\n} from \"../utils.js\";\n\n/**\n * Bumped when the generated files change shape, so a manifest written by an\n * older generator never matches a current one.\n */\nconst GENERATOR_FORMAT = \"1\";\n\nconst confectPath = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, file);\n});\n\n/**\n * A backend opts in to the declaration by writing `confect/app.ts`.\n */\nexport const isDeclared = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n return yield* fs.exists(yield* confectPath(\"app.ts\"));\n});\n\nconst displayPath = Effect.fnUntraced(function* (absolutePath: string) {\n const path = yield* Path.Path;\n return toPosixPath(path, path.relative(yield* ProjectRoot.get, absolutePath));\n});\n\nconst bundleDeclaration = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n const absolutePath = yield* confectPath(file);\n return yield* Bundler.bundle(absolutePath, {\n plugins: [ConvexConfig.componentConfigPlugin(path)],\n }).pipe(\n Effect.mapError((error) => fromBundlerError(`confect/${file}`, error)),\n );\n});\n\nconst invalid = (file: string) => (error: { readonly message: string }) =>\n new InvalidDeclarationError({\n declarationPath: `confect/${file}`,\n reason: error.message,\n });\n\n/**\n * Fail instead of overwriting a Convex file someone wrote by hand. A file with\n * the generated header, or one of the exact files an earlier codegen wrote\n * there, is ours to replace.\n */\nconst assertOwned = Effect.fnUntraced(function* (\n convexPath: string,\n declarationFile: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(convexPath))) return;\n if (Declaration.isGenerated(yield* fs.readFileString(convexPath), legacy)) {\n return;\n }\n return yield* new HandWrittenConvexFileError({\n convexPath: yield* displayPath(convexPath),\n declarationPath: `confect/${declarationFile}`,\n });\n});\n\nconst decodeVersion = Schema.decodeUnknownOption(\n Schema.fromJsonString(Schema.Struct({ version: Schema.String })),\n);\n\nconst packageVersion = Effect.fnUntraced(function* (\n name: string,\n from: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n return yield* Option.match(\n Bundler.resolveModule(`${name}/package.json`, path.join(from, \"_\")),\n {\n onNone: () => Effect.succeed(\"unresolved\"),\n onSome: (packageJson) =>\n fs.readFileString(packageJson).pipe(\n Effect.map((contents) =>\n Option.match(decodeVersion(contents), {\n onNone: () => \"unknown\",\n onSome: ({ version }) => version,\n }),\n ),\n ),\n },\n );\n});\n\n/**\n * Every first-party file the declaration modules import, by project-relative\n * path and contents. Files under `node_modules` and outside the project count\n * through package versions instead, so rebuilding a dependency does not change\n * the digest.\n */\nconst declarationInputs = Effect.fnUntraced(function* (\n bundles: ReadonlyArray<Bundler.Bundled>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const projectRoot = yield* ProjectRoot.get;\n const files = new Set<string>();\n for (const { metafile } of bundles) {\n for (const input of Object.keys(metafile.inputs)) {\n const relative = path.relative(projectRoot, input);\n if (\n path.isAbsolute(input) &&\n !relative.startsWith(\"..\") &&\n !relative.split(path.sep).includes(\"node_modules\")\n ) {\n files.add(input);\n }\n }\n }\n // Plugin namespaces (component config wrappers) appear as inputs too;\n // only real files count.\n const real = yield* Effect.filter([...files], (file) => fs.exists(file));\n return yield* Effect.forEach(real, (file) =>\n fs\n .readFileString(file)\n .pipe(\n Effect.map(\n (contents) =>\n [\n toPosixPath(path, path.relative(projectRoot, file)),\n contents,\n ] as const,\n ),\n ),\n );\n});\n\nconst componentImport = Effect.fnUntraced(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n return (definition: unknown): Option.Option<Declaration.ComponentImport> =>\n Option.map(ConvexConfig.componentImportOf(definition), (recorded) => {\n const bare =\n !recorded.specifier.startsWith(\".\") &&\n !path.isAbsolute(recorded.specifier);\n const relative = toPosixPath(\n path,\n path.relative(convexDirectory, recorded.path),\n ).replace(/\\.[cm]?[jt]s$/, \"\");\n return {\n importPath: bare\n ? recorded.specifier\n : relative.startsWith(\".\")\n ? relative\n : `./${relative}`,\n componentName:\n Predicate.hasProperty(definition, \"defaultName\") &&\n Predicate.isString(definition.defaultName)\n ? definition.defaultName\n : \"component\",\n };\n });\n});\n\nconst manifestPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, \"_generated\", \"manifest.ts\");\n});\n\n/**\n * Remove a file codegen wrote whose source is gone; leave anything else.\n */\nconst removeGenerated = Effect.fnUntraced(function* (\n filePath: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) return;\n if (!Declaration.isGenerated(yield* fs.readFileString(filePath), legacy)) {\n return;\n }\n yield* removePathIfExists(filePath);\n yield* logFileRemoved(filePath);\n});\n\nconst removeManifest = Effect.gen(function* () {\n yield* removeGenerated(yield* manifestPath, []);\n});\n\nconst writeDeclaration = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n const target = (yield* ConvexDirectory.target).kind;\n\n const app = yield* bundleDeclaration(\"app.ts\");\n const appValue: unknown = app.module.default;\n if (App.isApp(appValue) && appValue.kind !== target) {\n return yield* new DeclarationKindMismatchError({\n declarationPath: \"confect/app.ts\",\n declaredKind: appValue.kind,\n targetKind: target,\n });\n }\n const authPath = yield* confectPath(\"auth.ts\");\n const auth = (yield* fs.exists(authPath))\n ? Option.some(yield* bundleDeclaration(\"auth.ts\"))\n : Option.none();\n\n const declaration = yield* Declaration.parse({\n target,\n app: app.module.default,\n auth: Option.map(auth, ({ module }) => module.default),\n componentImport: yield* componentImport(),\n }).pipe(\n Result.mapError(\n (error) =>\n new InvalidDeclarationError({\n declarationPath: Declaration.fileOf(error),\n reason: error.message,\n }),\n ),\n Effect.fromResult,\n );\n\n const convexConfigPath = path.join(\n convexDirectory,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n );\n const authConfigPath = path.join(convexDirectory, \"auth.config.ts\");\n const legacyAuthConfig = yield* templates.authConfig({\n authImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, authPath),\n ),\n });\n yield* assertOwned(convexConfigPath, \"app.ts\", []);\n yield* assertOwned(authConfigPath, \"auth.ts\", [legacyAuthConfig]);\n\n if (target === \"app\") {\n const digest = Declaration.digest({\n files: yield* declarationInputs([app, ...Option.toArray(auth)]),\n versions: [\n [\"convex\", yield* packageVersion(\"convex\", projectRoot)],\n [\"@confect/cli generator format\", GENERATOR_FORMAT],\n ],\n });\n yield* writeFileStringAndLog(\n yield* manifestPath,\n Declaration.manifest(declaration, digest),\n );\n }\n yield* writeFileStringAndLog(\n convexConfigPath,\n Declaration.convexConfig(declaration),\n );\n yield* Option.match(declaration.providers, {\n onNone: () =>\n Effect.gen(function* () {\n if (yield* fs.exists(authConfigPath)) {\n yield* removePathIfExists(authConfigPath);\n yield* logFileRemoved(authConfigPath);\n }\n }),\n onSome: (providers) =>\n writeFileStringAndLog(authConfigPath, Declaration.authConfig(providers)),\n });\n return App.isApp(appValue) ? Option.some(appValue) : Option.none<App.Any>();\n});\n\n/**\n * Write the declaration's Convex files and manifest from `confect/app.ts`,\n * `confect/env.ts` and `confect/auth.ts`, before anything else is validated. On\n * any failure the previous manifest is removed, so a stale manifest never\n * outlives a declaration that no longer produces it.\n */\nexport const syncDeclaration = Effect.gen(function* () {\n if (!(yield* isDeclared)) {\n yield* removeManifest;\n return Option.none<App.Any>();\n }\n return yield* writeDeclaration.pipe(Effect.tapError(() => removeManifest));\n});\n\n/**\n * Check every HTTP route the backend serves and write `convex/http.ts` from\n * `confect/http.ts`. Runs after generation, because `http.ts` imports its\n * handlers, which import generated services.\n */\nexport const syncDeclaredHttp = (app: App.Any) =>\n checkAndWriteHttp(app).pipe(Effect.tapError(() => removeManifest));\n\nconst checkAndWriteHttp = Effect.fnUntraced(function* (app: App.Any) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const confectDirectory = yield* ConfectDirectory.get;\n const httpPath = yield* confectPath(\"http.ts\");\n\n const convexHttpPath = path.join(convexDirectory, \"http.ts\");\n if (!(yield* fs.exists(httpPath))) {\n yield* Http.routes(app).pipe(\n Result.mapError(invalid(\"app.ts\")),\n Effect.fromResult,\n );\n yield* removeGenerated(convexHttpPath, [\n yield* templates.http({\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n }),\n ]);\n return Option.none();\n }\n\n const http = (yield* bundleDeclaration(\"http.ts\")).module.default;\n if (!Http.isHttp(http)) {\n return yield* new InvalidDeclarationError({\n declarationPath: \"confect/http.ts\",\n reason: \"it must default-export Http.make(...).\",\n });\n }\n yield* Http.routes(app, http).pipe(\n Result.mapError(invalid(\"http.ts\")),\n Effect.fromResult,\n );\n\n const contents = yield* templates.declaredHttp({\n schemaImportPath: yield* toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"_generated\", \"schema.ts\"),\n ),\n ),\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n });\n const change = yield* writeFileString(convexHttpPath, contents);\n return Option.some({ change, convexFilePath: convexHttpPath });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,mBAAmB;AAEzB,MAAM,cAAc,OAAO,WAAW,WAAW,MAAc;CAE7D,QAAO,OADa,KAAK,KAAA,CACb,KAAK,OAAO,iBAAiB,KAAK,IAAI;AACpD,CAAC;;;;AAKD,MAAa,aAAa,OAAO,IAAI,aAAa;CAEhD,OAAO,QAAO,OADI,WAAW,WAAA,CACZ,OAAO,OAAO,YAAY,QAAQ,CAAC;AACtD,CAAC;AAED,MAAM,cAAc,OAAO,WAAW,WAAW,cAAsB;CACrE,MAAM,OAAO,OAAO,KAAK;CACzB,OAAO,YAAY,MAAM,KAAK,SAAS,OAA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,OAAO,OAAO,KAAK;EAAE;EAAQ,gBAAgB;CAAe,CAAC;AAC/D,CAAC"}
1
+ {"version":3,"file":"declaration.mjs","names":["Bundler.bundle","ConvexConfig.componentConfigPlugin","Declaration.isGenerated","Bundler.resolveModule","ConvexConfig.componentImportOf","Declaration.parse","Declaration.fileOf","ConvexConfig.CONVEX_CONFIG_FILENAME","templates.authConfig","digest","Declaration.digest","Declaration.manifest","Declaration.convexConfig","Declaration.authConfig","templates.http","http","templates.declaredHttp"],"sources":["../../src/confect/declaration.ts"],"sourcesContent":["import { App, Http } from \"@confect/core\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Option from \"effect/Option\";\nimport * as Path from \"effect/Path\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport { fromBundlerError } from \"../BuildError.js\";\nimport * as Bundler from \"../Bundler.js\";\nimport {\n HandWrittenConvexFileError,\n DeclarationKindMismatchError,\n InvalidDeclarationError,\n} from \"../CodegenError.js\";\nimport { ConfectDirectory } from \"../ConfectDirectory.js\";\nimport * as ConvexConfig from \"../ConvexConfig.js\";\nimport { ConvexDirectory } from \"../ConvexDirectory.js\";\nimport * as Declaration from \"../Declaration.js\";\nimport { logFileRemoved } from \"../log.js\";\nimport { ProjectRoot } from \"../ProjectRoot.js\";\nimport * as templates from \"../templates.js\";\nimport {\n removePathIfExists,\n toModuleImportPath,\n toPosixPath,\n writeFileString,\n writeFileStringAndLog,\n} from \"../utils.js\";\n\n/**\n * Bumped when the generated files change shape, so a manifest written by an\n * older generator never matches a current one.\n */\nconst GENERATOR_FORMAT = \"1\";\n\nconst confectPath = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, file);\n});\n\n/**\n * A backend opts in to the declaration by writing `confect/app.ts`.\n */\nexport const isDeclared = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n return yield* fs.exists(yield* confectPath(\"app.ts\"));\n});\n\nconst displayPath = Effect.fnUntraced(function* (absolutePath: string) {\n const path = yield* Path.Path;\n return toPosixPath(path, path.relative(yield* ProjectRoot.get, absolutePath));\n});\n\nconst bundleDeclaration = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n const absolutePath = yield* confectPath(file);\n return yield* Bundler.bundle(absolutePath, {\n plugins: [ConvexConfig.componentConfigPlugin(path)],\n }).pipe(\n Effect.mapError((error) => fromBundlerError(`confect/${file}`, error)),\n );\n});\n\nconst invalid = (file: string) => (error: { readonly message: string }) =>\n new InvalidDeclarationError({\n declarationPath: `confect/${file}`,\n reason: error.message,\n });\n\n/**\n * Fail instead of overwriting a Convex file someone wrote by hand. A file with\n * the generated header, or one of the exact files an earlier codegen wrote\n * there, is ours to replace.\n */\nconst assertOwned = Effect.fnUntraced(function* (\n convexPath: string,\n declarationFile: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(convexPath))) return;\n if (Declaration.isGenerated(yield* fs.readFileString(convexPath), legacy)) {\n return;\n }\n return yield* new HandWrittenConvexFileError({\n convexPath: yield* displayPath(convexPath),\n declarationPath: `confect/${declarationFile}`,\n });\n});\n\nconst decodeVersion = Schema.decodeUnknownOption(\n Schema.fromJsonString(Schema.Struct({ version: Schema.String })),\n);\n\nconst packageVersion = Effect.fnUntraced(function* (\n name: string,\n from: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n return yield* Option.match(\n Bundler.resolveModule(`${name}/package.json`, path.join(from, \"_\")),\n {\n onNone: () => Effect.succeed(\"unresolved\"),\n onSome: (packageJson) =>\n fs.readFileString(packageJson).pipe(\n Effect.map((contents) =>\n Option.match(decodeVersion(contents), {\n onNone: () => \"unknown\",\n onSome: ({ version }) => version,\n }),\n ),\n ),\n },\n );\n});\n\n/**\n * Every first-party file the declaration modules import, by project-relative\n * path and contents. Files under `node_modules` and outside the project count\n * through package versions instead, so rebuilding a dependency does not change\n * the digest.\n */\nconst declarationInputs = Effect.fnUntraced(function* (\n bundles: ReadonlyArray<Bundler.Bundled>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const projectRoot = yield* ProjectRoot.get;\n const files = new Set<string>();\n for (const { metafile } of bundles) {\n for (const input of Object.keys(metafile.inputs)) {\n const relative = path.relative(projectRoot, input);\n if (\n path.isAbsolute(input) &&\n !relative.startsWith(\"..\") &&\n !relative.split(path.sep).includes(\"node_modules\")\n ) {\n files.add(input);\n }\n }\n }\n // Plugin namespaces (component config wrappers) appear as inputs too;\n // only real files count.\n const real = yield* Effect.filter([...files], (file) => fs.exists(file));\n return yield* Effect.forEach(real, (file) =>\n fs\n .readFileString(file)\n .pipe(\n Effect.map(\n (contents) =>\n [\n toPosixPath(path, path.relative(projectRoot, file)),\n contents,\n ] as const,\n ),\n ),\n );\n});\n\nconst componentImport = Effect.fnUntraced(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n return (definition: unknown): Option.Option<Declaration.ComponentImport> =>\n Option.map(ConvexConfig.componentImportOf(definition), (recorded) => {\n const bare =\n !recorded.specifier.startsWith(\".\") &&\n !path.isAbsolute(recorded.specifier);\n const relative = toPosixPath(\n path,\n path.relative(convexDirectory, recorded.path),\n ).replace(/\\.([cm]?)[jt]s$/, \".$1js\");\n return {\n importPath: bare\n ? recorded.specifier\n : relative.startsWith(\".\")\n ? relative\n : `./${relative}`,\n componentName:\n Predicate.hasProperty(definition, \"defaultName\") &&\n Predicate.isString(definition.defaultName)\n ? definition.defaultName\n : \"component\",\n };\n });\n});\n\nconst manifestPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, \"_generated\", \"manifest.ts\");\n});\n\n/**\n * Remove a file codegen wrote whose source is gone; leave anything else.\n */\nconst removeGenerated = Effect.fnUntraced(function* (\n filePath: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) return;\n if (!Declaration.isGenerated(yield* fs.readFileString(filePath), legacy)) {\n return;\n }\n yield* removePathIfExists(filePath);\n yield* logFileRemoved(filePath);\n});\n\nconst removeManifest = Effect.gen(function* () {\n yield* removeGenerated(yield* manifestPath, []);\n});\n\nconst writeDeclaration = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n const target = (yield* ConvexDirectory.target).kind;\n\n const app = yield* bundleDeclaration(\"app.ts\");\n const appValue: unknown = app.module.default;\n if (App.isApp(appValue) && appValue.kind !== target) {\n return yield* new DeclarationKindMismatchError({\n declarationPath: \"confect/app.ts\",\n declaredKind: appValue.kind,\n targetKind: target,\n });\n }\n const authPath = yield* confectPath(\"auth.ts\");\n const auth = (yield* fs.exists(authPath))\n ? Option.some(yield* bundleDeclaration(\"auth.ts\"))\n : Option.none();\n\n const declaration = yield* Declaration.parse({\n target,\n app: app.module.default,\n auth: Option.map(auth, ({ module }) => module.default),\n componentImport: yield* componentImport(),\n }).pipe(\n Result.mapError(\n (error) =>\n new InvalidDeclarationError({\n declarationPath: Declaration.fileOf(error),\n reason: error.message,\n }),\n ),\n Effect.fromResult,\n );\n\n const convexConfigPath = path.join(\n convexDirectory,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n );\n const authConfigPath = path.join(convexDirectory, \"auth.config.ts\");\n const authImportPath = yield* toModuleImportPath(\n path.relative(convexDirectory, authPath),\n );\n const legacyAuthConfigs = yield* Effect.forEach(\n [authImportPath, authImportPath.replace(/\\.js$/, \"\")],\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n );\n yield* assertOwned(convexConfigPath, \"app.ts\", []);\n yield* assertOwned(authConfigPath, \"auth.ts\", legacyAuthConfigs);\n\n if (target === \"app\") {\n const digest = Declaration.digest({\n files: yield* declarationInputs([app, ...Option.toArray(auth)]),\n versions: [\n [\"convex\", yield* packageVersion(\"convex\", projectRoot)],\n [\"@confect/cli generator format\", GENERATOR_FORMAT],\n ],\n });\n yield* writeFileStringAndLog(\n yield* manifestPath,\n Declaration.manifest(declaration, digest),\n );\n }\n yield* writeFileStringAndLog(\n convexConfigPath,\n Declaration.convexConfig(declaration),\n );\n yield* Option.match(declaration.providers, {\n onNone: () =>\n Effect.gen(function* () {\n if (yield* fs.exists(authConfigPath)) {\n yield* removePathIfExists(authConfigPath);\n yield* logFileRemoved(authConfigPath);\n }\n }),\n onSome: (providers) =>\n writeFileStringAndLog(authConfigPath, Declaration.authConfig(providers)),\n });\n return App.isApp(appValue) ? Option.some(appValue) : Option.none<App.Any>();\n});\n\n/**\n * Write the declaration's Convex files and manifest from `confect/app.ts`,\n * `confect/env.ts` and `confect/auth.ts`, before anything else is validated. On\n * any failure the previous manifest is removed, so a stale manifest never\n * outlives a declaration that no longer produces it.\n */\nexport const syncDeclaration = Effect.gen(function* () {\n if (!(yield* isDeclared)) {\n yield* removeManifest;\n return Option.none<App.Any>();\n }\n return yield* writeDeclaration.pipe(Effect.tapError(() => removeManifest));\n});\n\n/**\n * Check every HTTP route the backend serves and write `convex/http.ts` from\n * `confect/http.ts`. Runs after generation, because `http.ts` imports its\n * handlers, which import generated services.\n */\nexport const syncDeclaredHttp = (app: App.Any) =>\n checkAndWriteHttp(app).pipe(Effect.tapError(() => removeManifest));\n\nconst checkAndWriteHttp = Effect.fnUntraced(function* (app: App.Any) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const confectDirectory = yield* ConfectDirectory.get;\n const httpPath = yield* confectPath(\"http.ts\");\n\n const convexHttpPath = path.join(convexDirectory, \"http.ts\");\n if (!(yield* fs.exists(httpPath))) {\n yield* Http.routes(app).pipe(\n Result.mapError(invalid(\"app.ts\")),\n Effect.fromResult,\n );\n yield* removeGenerated(convexHttpPath, [\n yield* templates.http({\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n }),\n ]);\n return Option.none();\n }\n\n const http = (yield* bundleDeclaration(\"http.ts\")).module.default;\n if (!Http.isHttp(http)) {\n return yield* new InvalidDeclarationError({\n declarationPath: \"confect/http.ts\",\n reason: \"it must default-export Http.make(...).\",\n });\n }\n yield* Http.routes(app, http).pipe(\n Result.mapError(invalid(\"http.ts\")),\n Effect.fromResult,\n );\n\n const contents = yield* templates.declaredHttp({\n schemaImportPath: yield* toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"_generated\", \"schema.ts\"),\n ),\n ),\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n });\n const change = yield* writeFileString(convexHttpPath, contents);\n return Option.some({ change, convexFilePath: convexHttpPath });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,mBAAmB;AAEzB,MAAM,cAAc,OAAO,WAAW,WAAW,MAAc;CAE7D,QAAO,OADa,KAAK,KAAA,CACb,KAAK,OAAO,iBAAiB,KAAK,IAAI;AACpD,CAAC;;;;AAKD,MAAa,aAAa,OAAO,IAAI,aAAa;CAEhD,OAAO,QAAO,OADI,WAAW,WAAA,CACZ,OAAO,OAAO,YAAY,QAAQ,CAAC;AACtD,CAAC;AAED,MAAM,cAAc,OAAO,WAAW,WAAW,cAAsB;CACrE,MAAM,OAAO,OAAO,KAAK;CACzB,OAAO,YAAY,MAAM,KAAK,SAAS,OAAO,YAAY,KAAK,YAAY,CAAC;AAC9E,CAAC;AAED,MAAM,oBAAoB,OAAO,WAAW,WAAW,MAAc;CACnE,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,eAAe,OAAO,YAAY,IAAI;CAC5C,OAAO,OAAOA,OAAe,cAAc,EACzC,SAAS,CAACC,sBAAmC,IAAI,CAAC,EACpD,CAAC,CAAC,CAAC,KACD,OAAO,UAAU,UAAU,iBAAiB,WAAW,QAAQ,KAAK,CAAC,CACv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CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,kBAAkB,OAAO,gBAAgB;CAC/C,MAAM,mBAAmB,OAAO,iBAAiB;CACjD,MAAM,WAAW,OAAO,YAAY,SAAS;CAE7C,MAAM,iBAAiB,KAAK,KAAK,iBAAiB,SAAS;CAC3D,IAAI,EAAE,OAAO,GAAG,OAAO,QAAQ,IAAI;EACjC,OAAO,KAAK,OAAO,GAAG,CAAC,CAAC,KACtB,OAAO,SAAS,QAAQ,QAAQ,CAAC,GACjC,OAAO,UACT;EACA,OAAO,gBAAgB,gBAAgB,CACrC,OAAOC,KAAe,EACpB,gBAAgB,OAAO,mBACrB,KAAK,SAAS,iBAAiB,QAAQ,CACzC,EACF,CAAC,CACH,CAAC;EACD,OAAO,OAAO,KAAK;CACrB;CAEA,MAAMC,UAAQ,OAAO,kBAAkB,SAAS,EAAA,CAAG,OAAO;CAC1D,IAAI,CAAC,KAAK,OAAOA,MAAI,GACnB,OAAO,OAAO,IAAI,wBAAwB;EACxC,iBAAiB;EACjB,QAAQ;CACV,CAAC;CAEH,OAAO,KAAK,OAAO,KAAKA,MAAI,CAAC,CAAC,KAC5B,OAAO,SAAS,QAAQ,SAAS,CAAC,GAClC,OAAO,UACT;CAEA,MAAM,WAAW,OAAOC,aAAuB;EAC7C,kBAAkB,OAAO,mBACvB,KAAK,SACH,iBACA,KAAK,KAAK,kBAAkB,cAAc,WAAW,CACvD,CACF;EACA,gBAAgB,OAAO,mBACrB,KAAK,SAAS,iBAAiB,QAAQ,CACzC;CACF,CAAC;CACD,MAAM,SAAS,OAAO,gBAAgB,gBAAgB,QAAQ;CAC9D,OAAO,OAAO,KAAK;EAAE;EAAQ,gBAAgB;CAAe,CAAC;AAC/D,CAAC"}
@@ -47,7 +47,7 @@ const runtimeSchemaEffect = Effect.fnUntraced(function* ({ tableModules, compone
47
47
  yield* Effect.forEach(tableModules, ({ tableName, importPath }) => cbw.writeLine(`import ${tableName} from "${importPath}";`));
48
48
  }
49
49
  yield* cbw.blankLine();
50
- if (component) yield* cbw.writeLine(`import { target as $target } from "./id";`);
50
+ if (component) yield* cbw.writeLine(`import { target as $target } from "./id.js";`);
51
51
  if (tableModules.length === 0) yield* cbw.writeLine(`const databaseSchema: $DatabaseSchema.DatabaseSchema${component ? "<{}, typeof $target>" : ""} = $DatabaseSchema.make({}${component ? ", $target" : ""});`);
52
52
  else {
53
53
  yield* cbw.writeLine(`const databaseSchema: $DatabaseSchema.DatabaseSchema<{`);
@@ -145,7 +145,7 @@ const tableWrapper = ({ tableName, unnamedImportPath, component = false }) => ta
145
145
  const tableWrapperEffect = Effect.fnUntraced(function* ({ tableName, unnamedImportPath, component = false }) {
146
146
  const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });
147
147
  yield* cbw.writeLine(`import unnamed from "${unnamedImportPath}";`);
148
- if (component) yield* cbw.writeLine(`import { scope } from "../id";`);
148
+ if (component) yield* cbw.writeLine(`import { scope } from "../id.js";`);
149
149
  yield* cbw.blankLine();
150
150
  yield* cbw.writeLine(`export default unnamed("${tableName}"${component ? ", scope" : ""});`);
151
151
  return yield* cbw.toString();
@@ -232,8 +232,8 @@ const refsEffect = Effect.fnUntraced(function* ({ specImportPath }) {
232
232
  const componentContract = Effect.fnUntraced(function* ({ tableNames }) {
233
233
  const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });
234
234
  yield* cbw.writeLine("import { Component } from \"@confect/core\";");
235
- yield* cbw.writeLine("import spec from \"./spec\";");
236
- yield* cbw.writeLine("import { scope } from \"./id\";");
235
+ yield* cbw.writeLine("import spec from \"./spec.js\";");
236
+ yield* cbw.writeLine("import { scope } from \"./id.js\";");
237
237
  yield* cbw.blankLine();
238
238
  const names = Array.map([
239
239
  ...tableNames,
@@ -349,8 +349,8 @@ const servicesEffect = Effect.fnUntraced(function* ({ schemaImportPath, componen
349
349
  }));
350
350
  yield* cbw.writeLine(`} from "@confect/server";`);
351
351
  yield* cbw.writeLine(`import type schemaDefinition from "${schemaImportPath}";`);
352
- yield* cbw.writeLine(`import type { Docs } from "./docs";`);
353
- if (component) yield* cbw.writeLine(`import type { scope } from "./id";`);
352
+ yield* cbw.writeLine(`import type { Docs } from "./docs.js";`);
353
+ if (component) yield* cbw.writeLine(`import type { scope } from "./id.js";`);
354
354
  yield* cbw.blankLine();
355
355
  if (!component) {
356
356
  yield* cbw.writeLine("export const Auth = Auth_.Auth;");
@@ -1 +1 @@
1
- {"version":3,"file":"templates.mjs","names":["renderSpecAssembly"],"sources":["../src/templates.ts"],"sourcesContent":["import type * as IdScope from \"@confect/core/IdScope\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport { CodeBlockWriter } from \"./CodeBlockWriter.js\";\nimport {\n render as renderSpecAssembly,\n type SpecAssemblyNode,\n} from \"./SpecAssemblyNode.js\";\n\n/**\n * Emit `convex/schema.ts` as a one-line re-export of the codegen-emitted deploy\n * schema in `confect/_generated/convexSchema.ts`. Deploy-time consumers (the\n * Convex CLI, `convex-test`) keep reading `convex/schema.ts`; the runtime\n * `DatabaseSchema` in `confect/_generated/schema.ts` is untouched by this\n * file.\n */\nexport const schema = ({\n convexSchemaImportPath,\n}: Parameters<typeof schemaEffect>[0]) =>\n schemaEffect({ convexSchemaImportPath });\n\nconst schemaEffect = Effect.fnUntraced(function* ({\n convexSchemaImportPath,\n}: {\n convexSchemaImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`export { default } from \"${convexSchemaImportPath}\";`);\n\n return yield* cbw.toString();\n});\n\ninterface TableModuleBinding {\n readonly importPath: string;\n readonly tableName: string;\n}\n\n/**\n * Emit `confect/_generated/schema.ts`—the runtime `DatabaseSchema` used by\n * impls and the per-group registries (and downstream by per-function bundles\n * for codec lookup). Every table wrapper at\n * `confect/_generated/tables/<name>.ts` is imported statically and registered\n * as a value entry on the `DatabaseSchema.make({...})` call. Per-table laziness\n * lives inside each `Table`: its `Fields` and `Doc` are lazy memoised getters\n * that only evaluate the user-supplied field-schema callback on first access,\n * so unused tables in a function bundle never pay schema-construction cost\n * despite the static import.\n *\n * The `DatabaseSchema` import is aliased to `$DatabaseSchema` because each\n * table is imported under its own (filename-derived) name; a table named\n * `DatabaseSchema` would otherwise collide with the library import and emit a\n * duplicate-binding file. The leading `$` makes the alias collision-proof:\n * `validateConfectTableIdentifier` requires names to match\n * `/^[a-zA-Z][a-zA-Z0-9_]*$/`, which forbids `$`, so no valid table import can\n * ever shadow it.\n */\nexport const runtimeSchema = ({\n tableModules,\n component = false,\n}: Parameters<typeof runtimeSchemaEffect>[0]) =>\n runtimeSchemaEffect({ tableModules, component });\n\nconst runtimeSchemaEffect = Effect.fnUntraced(function* ({\n tableModules,\n component = false,\n}: {\n tableModules: ReadonlyArray<TableModuleBinding>;\n component?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { DatabaseSchema as $DatabaseSchema } from \"@confect/server\";`,\n );\n\n if (tableModules.length > 0) {\n yield* cbw.blankLine();\n yield* Effect.forEach(tableModules, ({ tableName, importPath }) =>\n cbw.writeLine(`import ${tableName} from \"${importPath}\";`),\n );\n }\n\n yield* cbw.blankLine();\n\n if (component) {\n yield* cbw.writeLine(`import { target as $target } from \"./id\";`);\n }\n\n if (tableModules.length === 0) {\n yield* cbw.writeLine(\n `const databaseSchema: $DatabaseSchema.DatabaseSchema${component ? \"<{}, typeof $target>\" : \"\"} = $DatabaseSchema.make({}${component ? \", $target\" : \"\"});`,\n );\n } else {\n yield* cbw.writeLine(\n `const databaseSchema: $DatabaseSchema.DatabaseSchema<{`,\n );\n yield* cbw.indent(\n Effect.forEach(\n tableModules,\n ({ tableName }) =>\n cbw.writeLine(`readonly ${tableName}: typeof ${tableName};`),\n { discard: true },\n ),\n );\n yield* cbw.writeLine(\n `}${component ? \", typeof $target\" : \"\"}> = $DatabaseSchema.make({`,\n );\n yield* cbw.indent(\n Effect.gen(function* () {\n for (const { tableName } of tableModules) {\n yield* cbw.writeLine(`${tableName},`);\n }\n }),\n );\n yield* cbw.writeLine(`}${component ? \", $target\" : \"\"});`);\n }\n\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default databaseSchema;`);\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/convexSchema.ts`—the Convex deploy-time\n * `SchemaDefinition`. Imports every table from its generated wrapper at\n * `_generated/tables/<name>` and calls `defineSchema({...})` exactly once.\n * `Table.tableDefinition` lives in `@confect/server` because it is the\n * `defineTable` binding; the generated table wrappers themselves stay\n * client-safe (`Fields`/`Doc` from `@confect/core`).\n *\n * The `defineSchema` and `Table` imports are aliased with a leading `$` because\n * each table is imported under its own (filename-derived) name; a table named\n * `defineSchema` or `Table` would otherwise collide with the library import and\n * emit a duplicate-binding file. `validateConfectTableIdentifier` requires\n * names to match `/^[a-zA-Z][a-zA-Z0-9_]*$/`, which forbids `$`, so no valid\n * table import can ever shadow them.\n */\nexport const convexSchema = ({\n tableModules,\n}: Parameters<typeof convexSchemaEffect>[0]) =>\n convexSchemaEffect({ tableModules });\n\nconst convexSchemaEffect = Effect.fnUntraced(function* ({\n tableModules,\n}: {\n tableModules: ReadonlyArray<TableModuleBinding>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { defineSchema as $defineSchema } from \"convex/server\";`,\n );\n\n if (tableModules.length > 0) {\n yield* cbw.writeLine(`import { Table as $Table } from \"@confect/server\";`);\n yield* cbw.blankLine();\n yield* Effect.forEach(tableModules, ({ tableName, importPath }) =>\n cbw.writeLine(`import ${tableName} from \"${importPath}\";`),\n );\n }\n\n yield* cbw.blankLine();\n\n if (tableModules.length === 0) {\n yield* cbw.writeLine(`export default $defineSchema({});`);\n } else {\n yield* cbw.writeLine(`export default $defineSchema({`);\n yield* cbw.indent(\n Effect.gen(function* () {\n for (const { tableName } of tableModules) {\n yield* cbw.writeLine(\n `${tableName}: $Table.tableDefinition(${tableName}),`,\n );\n }\n }),\n );\n yield* cbw.writeLine(`});`);\n }\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/id.ts`—a type-constrained `Id` constructor and a\n * `TableNames` union derived from the user's `confect/tables/*.ts` filenames.\n * User-authored table modules import `Id` from this file to declare cross-table\n * id references without typing the destination name as a free string (and\n * without ever importing each other transitively).\n *\n * `Id` also accepts Convex system tables, with the component scope when\n * present. `TableNames` includes only user tables and resolves to `never` for\n * an empty table directory.\n */\nexport const id = ({ tableNames, scope }: Parameters<typeof idEffect>[0]) =>\n idEffect({ tableNames, scope });\n\nconst idEffect = Effect.fnUntraced(function* ({\n tableNames,\n scope,\n}: {\n tableNames: ReadonlyArray<string>;\n scope?: IdScope.Component<string> | undefined;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { GenericId${scope === undefined ? \"\" : \", IdScope\"} } from \"@confect/core\";`,\n );\n yield* cbw.writeLine(\n `import type { SystemTableNames } from \"convex/server\";`,\n );\n yield* cbw.blankLine();\n if (scope !== undefined) {\n yield* cbw.writeLine(\n // oxlint-disable-next-line effecttsgo/prefer-schema-over-json -- Emit an escaped TypeScript string literal, not a JSON payload.\n `export const scope = IdScope.component(${JSON.stringify(scope.slice(\"component:\".length))});`,\n );\n yield* cbw.writeLine(\n `export const target = { kind: \"component\", scope } as const;`,\n );\n }\n\n const union =\n tableNames.length === 0\n ? \"never\"\n : tableNames.map((n) => `\"${n}\"`).join(\" | \");\n yield* cbw.writeLine(`export type TableNames = ${union};`);\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n `export type Id<TableName extends TableNames | SystemTableNames> = GenericId.GenericId<TableName${scope === undefined ? \"\" : \", typeof scope\"}>;`,\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n `export const Id = <const TableName extends TableNames | SystemTableNames>(`,\n );\n yield* cbw.indent(cbw.writeLine(`tableName: TableName,`));\n yield* cbw.writeLine(\n `) => GenericId.GenericId(tableName${scope === undefined ? \"\" : \", scope\"});`,\n );\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/tables/<tableName>.ts`—a two-line wrapper that\n * imports the user-authored `UnnamedTable` and binds the file basename to it,\n * producing the fully-named `Table` value that downstream consumers (schema,\n * specs, impls) read.\n */\nexport const tableWrapper = ({\n tableName,\n unnamedImportPath,\n component = false,\n}: Parameters<typeof tableWrapperEffect>[0]) =>\n tableWrapperEffect({ tableName, unnamedImportPath, component });\n\nconst tableWrapperEffect = Effect.fnUntraced(function* ({\n tableName,\n unnamedImportPath,\n component = false,\n}: {\n tableName: string;\n unnamedImportPath: string;\n component?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import unnamed from \"${unnamedImportPath}\";`);\n if (component) yield* cbw.writeLine(`import { scope } from \"../id\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n `export default unnamed(\"${tableName}\"${component ? \", scope\" : \"\"});`,\n );\n\n return yield* cbw.toString();\n});\n\nexport const http = ({ httpImportPath }: Parameters<typeof httpEffect>[0]) =>\n httpEffect({ httpImportPath });\n\nconst httpEffect = Effect.fnUntraced(function* ({\n httpImportPath,\n}: {\n httpImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import http from \"${httpImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default http;`);\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `convex/http.ts` for a declared backend: the Convex router serving\n * `confect/http.ts`'s routes, typed by the generated database schema.\n */\nexport const declaredHttp = Effect.fnUntraced(function* ({\n schemaImportPath,\n httpImportPath,\n}: {\n schemaImportPath: string;\n httpImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n \"// Generated by `confect codegen` from confect/http.ts. Do not edit.\",\n );\n yield* cbw.writeLine(`import { HttpRouter } from \"@confect/server\";`);\n yield* cbw.writeLine(`import schema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import http from \"${httpImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(\n `export default HttpRouter.forSchema(schema)(http.routes, { api: http.api });`,\n );\n\n return yield* cbw.toString();\n});\n\nexport const crons = ({ cronsImportPath }: Parameters<typeof cronsEffect>[0]) =>\n cronsEffect({ cronsImportPath });\n\nconst cronsEffect = Effect.fnUntraced(function* ({\n cronsImportPath,\n}: {\n cronsImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import crons from \"${cronsImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default crons.convexCronJobs;`);\n\n return yield* cbw.toString();\n});\n\nexport const authConfig = ({\n authImportPath,\n}: Parameters<typeof authConfigEffect>[0]) =>\n authConfigEffect({ authImportPath });\n\nconst authConfigEffect = Effect.fnUntraced(function* ({\n authImportPath,\n}: {\n authImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import auth from \"${authImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default auth;`);\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/components.ts`—a typed registry of the Convex\n * components installed via `app.use(...)` in `convex/convex.config.ts`. Mirrors\n * the `components` export of Convex's generated `convex/_generated/api`: the\n * runtime value is `componentsGeneric()` (a name-preserving proxy), and each\n * entry is typed with the `ComponentApi` that component packages export from\n * `_generated/component.js`. Unlike `convex/_generated/api`, this file exists\n * before `convex codegen` ever runs, so impl modules can import it\n * safely—`confect codegen` bundles and evaluates each impl's import graph, and\n * `convex/_generated/api` doesn't exist yet at that point.\n *\n * The `as any` cast is confined here: `componentsGeneric()` is typed\n * `AnyChildComponents`, which deliberately doesn't overlap the precise registry\n * type; the `Components` annotation on the const supplies the real type.\n */\nexport const components = ({\n components: installedComponents,\n}: Parameters<typeof componentsEffect>[0]) =>\n componentsEffect({ components: installedComponents });\n\nconst componentsEffect = Effect.fnUntraced(function* ({\n components: installedComponents,\n}: {\n components: ReadonlyArray<{ name: string; typeImportPath: string }>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { componentsGeneric } from \"convex/server\";`);\n yield* cbw.blankLine();\n\n if (installedComponents.length === 0) {\n yield* cbw.writeLine(`export type Components = {};`);\n } else {\n yield* cbw.writeLine(`export type Components = {`);\n yield* cbw.indent(\n Effect.forEach(\n installedComponents,\n ({ name, typeImportPath }) =>\n cbw.writeLine(\n `\"${name}\": import(\"${typeImportPath}/_generated/component.js\").ComponentApi<\"${name}\">;`,\n ),\n { discard: true },\n ),\n );\n yield* cbw.writeLine(`};`);\n }\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n `export const components: Components = componentsGeneric() as any;`,\n );\n\n return yield* cbw.toString();\n});\n\nexport const refs = ({ specImportPath }: Parameters<typeof refsEffect>[0]) =>\n refsEffect({ specImportPath });\n\nconst refsEffect = Effect.fnUntraced(function* ({\n specImportPath,\n}: {\n specImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { Refs } from \"@confect/core\";`);\n yield* cbw.writeLine(`import spec from \"${specImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n `const refs: Refs.FromSpec<typeof spec> = Refs.make(spec);`,\n );\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default refs;`);\n\n return yield* cbw.toString();\n});\n\nexport const componentContract = Effect.fnUntraced(function* ({\n tableNames,\n}: {\n tableNames: ReadonlyArray<string>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n yield* cbw.writeLine('import { Component } from \"@confect/core\";');\n yield* cbw.writeLine('import spec from \"./spec\";');\n yield* cbw.writeLine('import { scope } from \"./id\";');\n yield* cbw.blankLine();\n const names = Array.map(\n [...tableNames, \"_storage\", \"_scheduled_functions\"],\n (name) => `\"${name}\"`,\n );\n yield* cbw.writeLine(\n `const component: Component.Component<typeof spec, typeof scope, ${names.join(\" | \")}> = Component.make(spec, scope, [${names.join(\", \")}]);`,\n );\n yield* cbw.writeLine(\"export default component;\");\n return yield* cbw.toString();\n});\n\n/**\n * Emit `_generated/docs.ts`: one named `type <table>` alias per table plus a\n * `Docs` registry. Each alias is `Document.Document<typeof schemaDefinition,\n * \"<table>\">`, so it stays structurally exact while giving the document a\n * _name_—declaration emit then prints e.g. `NotesDoc` instead of expanding the\n * row structure. A `type` alias (rather than an extending `interface`) is used\n * so it works for every document shape: object tables, but also union schemas\n * (`Schema.Union`) and other non-object documents, which an `interface …\n * extends` cannot represent (TS2312). The registry is threaded into the\n * generated `DatabaseReader`/`DatabaseWriter` tags so query/mutation helpers\n * print named documents with no user annotations.\n */\nexport const docs = ({\n schemaImportPath,\n tables,\n}: Parameters<typeof docsEffect>[0]) =>\n docsEffect({ schemaImportPath, tables });\n\nconst docsEffect = Effect.fnUntraced(function* ({\n schemaImportPath,\n tables,\n}: {\n schemaImportPath: string;\n tables: ReadonlyArray<{ tableName: string; docName: string }>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n // With no tables there is nothing to import—emitting the (unused) imports\n // would trip `noUnusedLocals`.\n if (tables.length === 0) {\n yield* cbw.writeLine(`export interface Docs {}`);\n return yield* cbw.toString();\n }\n\n yield* cbw.writeLine(`import type { Document } from \"@confect/server\";`);\n yield* cbw.writeLine(\n `import type schemaDefinition from \"${schemaImportPath}\";`,\n );\n yield* cbw.blankLine();\n\n for (const { tableName, docName } of tables) {\n yield* cbw.writeLine(\n `export type ${docName} = Document.Document<typeof schemaDefinition, \"${tableName}\">;`,\n );\n }\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(`export interface Docs {`);\n yield* cbw.indent(\n Effect.gen(function* () {\n for (const { tableName, docName } of tables) {\n yield* cbw.writeLine(`${tableName}: ${docName};`);\n }\n }),\n );\n yield* cbw.writeLine(`}`);\n\n return yield* cbw.toString();\n});\n\nexport const registeredFunctionsForGroup = ({\n spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n}: Parameters<typeof registeredFunctionsForGroupEffect>[0]) =>\n registeredFunctionsForGroupEffect({\n spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n });\n\nconst registeredFunctionsForGroupEffect = Effect.fnUntraced(function* ({\n spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n}: {\n spec: GroupSpec.AnyWithProps;\n schemaImportPath: string;\n specImportPath: string;\n implImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n const useNode = spec.runtime === \"Node\";\n\n const hasConfectFunctions = (group: GroupSpec.AnyWithProps): boolean =>\n Object.values(group.functions).some(\n (functionSpec) => functionSpec.functionProvenance._tag === \"Confect\",\n ) || Object.values(group.groups).some(hasConfectFunctions);\n const forwarding = !useNode && hasConfectFunctions(spec);\n\n if (useNode) {\n yield* cbw.writeLine(\n `import { RegisteredNodeFunction } from \"@confect/server/node\";`,\n );\n } else if (!forwarding) {\n yield* cbw.writeLine(\n `import { RegisteredFunctions } from \"@confect/server\";`,\n );\n } else {\n yield* cbw.writeLine(\n `import { ConvexFunctionDefinitions, RegisteredConvexFunction, type RegisteredFunctions } from \"@confect/server\";`,\n );\n }\n\n yield* cbw.writeLine(`import databaseSchema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import groupLayer from \"${implImportPath}\";`);\n yield* cbw.blankLine();\n // The group's own leaf spec is referenced type-only (`typeof import(...)`),\n // so the spec module is erased at transpile time and never enters the\n // per-function bundle; only `databaseSchema` and the impl are runtime\n // imports. Typing from the leaf spec (not the project-wide assembled spec)\n // keeps the registry's type dependent solely on its own group.\n const specType = `typeof import(\"${specImportPath}\")[\"default\"]`;\n if (useNode) {\n yield* cbw.writeLine(\n `export default RegisteredNodeFunction.buildForGroup<${specType}>(databaseSchema, groupLayer);`,\n );\n } else if (!forwarding) {\n yield* cbw.writeLine(\n `export default RegisteredFunctions.buildForGroup<${specType}>(databaseSchema, groupLayer);`,\n );\n } else {\n const bindings = (group: GroupSpec.AnyWithProps, path: string): string =>\n `{\n${[\n ...Object.entries(group.functions).map(([name, functionSpec]) => {\n const key = JSON.stringify(name);\n const definition = `${path}[${key}]`;\n return `[${key}]: ${\n functionSpec.functionProvenance._tag === \"Convex\"\n ? `${definition}.handler`\n : `RegisteredConvexFunction.register({ ...${definition}, handler: forward(${definition}.handler) })`\n },`;\n }),\n ...Object.entries(group.groups).map(([name, child]) => {\n const key = JSON.stringify(name);\n return `[${key}]: ${bindings(child, `${path}[${key}]`)},`;\n }),\n].join(\"\\n\")}\n}`;\n yield* cbw.writeLine(`const forward = <Ctx, Args, Returns>(handler: (ctx: Ctx, args: Args) => Promise<Returns>) => (ctx: Ctx, args: Args) => handler(ctx, args);\n\nconst definitions = ConvexFunctionDefinitions.buildForGroup<${specType}>(databaseSchema, groupLayer);\n\nexport default ${bindings(spec, \"definitions\")} as RegisteredFunctions.RegisteredFunctionsForGroupSpec<${specType}>;`);\n }\n\n return yield* cbw.toString();\n});\n\nexport const services = ({\n schemaImportPath,\n component = false,\n}: Parameters<typeof servicesEffect>[0]) =>\n servicesEffect({ schemaImportPath, component });\n\nconst servicesEffect = Effect.fnUntraced(function* ({\n schemaImportPath,\n component = false,\n}: {\n schemaImportPath: string;\n component?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n // Imports\n yield* cbw.writeLine(\"import {\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"ActionCtx as ActionCtx_,\");\n yield* cbw.writeLine(\"ActionRunner as ActionRunner_,\");\n if (!component) yield* cbw.writeLine(\"Auth as Auth_,\");\n yield* cbw.writeLine(\"type DataModel,\");\n yield* cbw.writeLine(\"DatabaseReader as DatabaseReader_,\");\n yield* cbw.writeLine(\"DatabaseWriter as DatabaseWriter_,\");\n yield* cbw.writeLine(\"ExecutionMetadata as ExecutionMetadata_,\");\n yield* cbw.writeLine(\"MutationCtx as MutationCtx_,\");\n yield* cbw.writeLine(\"MutationRunner as MutationRunner_,\");\n yield* cbw.writeLine(\n \"MutationTransactionContext as MutationTransactionContext_,\",\n );\n yield* cbw.writeLine(\"QueryCtx as QueryCtx_,\");\n yield* cbw.writeLine(\"QueryRunner as QueryRunner_,\");\n yield* cbw.writeLine(\n \"QueryTransactionContext as QueryTransactionContext_,\",\n );\n yield* cbw.writeLine(\"RequestMetadata as RequestMetadata_,\");\n yield* cbw.writeLine(\"Scheduler as Scheduler_,\");\n if (!component) yield* cbw.writeLine(\"Storage as Storage_,\");\n yield* cbw.writeLine(\"StorageActionWriter as StorageActionWriter_,\");\n yield* cbw.writeLine(\"StorageReader as StorageReader_,\");\n yield* cbw.writeLine(\"StorageWriter as StorageWriter_,\");\n yield* cbw.writeLine(\"TransactionMetadata as TransactionMetadata_,\");\n yield* cbw.writeLine(\"VectorSearch as VectorSearch_,\");\n }),\n );\n yield* cbw.writeLine(`} from \"@confect/server\";`);\n yield* cbw.writeLine(\n `import type schemaDefinition from \"${schemaImportPath}\";`,\n );\n yield* cbw.writeLine(`import type { Docs } from \"./docs\";`);\n if (component) yield* cbw.writeLine(`import type { scope } from \"./id\";`);\n yield* cbw.blankLine();\n\n // Auth\n if (!component) {\n yield* cbw.writeLine(\"export const Auth = Auth_.Auth;\");\n yield* cbw.writeLine(\"export type Auth = typeof Auth.Identifier;\");\n }\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const ExecutionMetadata = ExecutionMetadata_.ExecutionMetadata;\",\n );\n yield* cbw.writeLine(\n \"export type ExecutionMetadata = typeof ExecutionMetadata.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const RequestMetadata = RequestMetadata_.RequestMetadata;\",\n );\n yield* cbw.writeLine(\n \"export type RequestMetadata = typeof RequestMetadata.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const TransactionMetadata = TransactionMetadata_.TransactionMetadata;\",\n );\n yield* cbw.writeLine(\n \"export type TransactionMetadata = typeof TransactionMetadata.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // Scheduler\n yield* cbw.writeLine(\n component\n ? \"export const Scheduler = Scheduler_.forScope<typeof scope>();\"\n : \"export const Scheduler = Scheduler_.Scheduler;\",\n );\n yield* cbw.writeLine(\"export type Scheduler = typeof Scheduler.Identifier;\");\n yield* cbw.blankLine();\n\n if (!component) {\n yield* cbw.writeLine(\"export const Storage = Storage_.Storage;\");\n yield* cbw.writeLine(\"export type Storage = typeof Storage.Identifier;\");\n yield* cbw.blankLine();\n }\n\n // StorageReader\n yield* cbw.writeLine(\n `export const StorageReader = StorageReader_.StorageReader${component ? \".forScope<typeof scope>()\" : \"\"};`,\n );\n yield* cbw.writeLine(\n \"export type StorageReader = typeof StorageReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageWriter\n yield* cbw.writeLine(\n `export const StorageWriter = StorageWriter_.StorageWriter${component ? \".forScope<typeof scope>()\" : \"\"};`,\n );\n yield* cbw.writeLine(\n \"export type StorageWriter = typeof StorageWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageActionWriter\n yield* cbw.writeLine(\n `export const StorageActionWriter = StorageActionWriter_.StorageActionWriter${component ? \".forScope<typeof scope>()\" : \"\"};`,\n );\n yield* cbw.writeLine(\n \"export type StorageActionWriter = typeof StorageActionWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // VectorSearch\n yield* cbw.writeLine(\n \"export const VectorSearch: VectorSearch_.VectorSearchTag<\",\n );\n yield* cbw.indent(\n cbw.writeLine(\"DataModel.FromSchema<typeof schemaDefinition>\"),\n );\n yield* cbw.writeLine(\n \"> = VectorSearch_.VectorSearch<DataModel.FromSchema<typeof schemaDefinition>>();\",\n );\n yield* cbw.writeLine(\n \"export type VectorSearch = typeof VectorSearch.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseReader\n yield* cbw.writeLine(\n \"export const DatabaseReader: DatabaseReader_.DatabaseReaderTag<\",\n );\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"typeof schemaDefinition,\");\n yield* cbw.writeLine(\"Docs\");\n }),\n );\n yield* cbw.writeLine(\n \"> = DatabaseReader_.DatabaseReader<typeof schemaDefinition, Docs>();\",\n );\n yield* cbw.writeLine(\n \"export type DatabaseReader = typeof DatabaseReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseWriter\n yield* cbw.writeLine(\n \"export const DatabaseWriter: DatabaseWriter_.DatabaseWriterTag<\",\n );\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"typeof schemaDefinition,\");\n yield* cbw.writeLine(\"Docs\");\n }),\n );\n yield* cbw.writeLine(\n \"> = DatabaseWriter_.DatabaseWriter<typeof schemaDefinition, Docs>();\",\n );\n yield* cbw.writeLine(\n \"export type DatabaseWriter = typeof DatabaseWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const QueryTransactionContext = QueryTransactionContext_.QueryTransactionContext;\",\n );\n yield* cbw.writeLine(\n \"export type QueryTransactionContext = typeof QueryTransactionContext.Identifier;\",\n );\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n \"export const MutationTransactionContext = MutationTransactionContext_.MutationTransactionContext;\",\n );\n yield* cbw.writeLine(\n \"export type MutationTransactionContext = typeof MutationTransactionContext.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryRunner\n yield* cbw.writeLine(\"export const QueryRunner = QueryRunner_.QueryRunner;\");\n yield* cbw.writeLine(\n \"export type QueryRunner = typeof QueryRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // MutationRunner\n yield* cbw.writeLine(\n \"export const MutationRunner = MutationRunner_.MutationRunner;\",\n );\n yield* cbw.writeLine(\n \"export type MutationRunner = typeof MutationRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // ActionRunner\n yield* cbw.writeLine(\n \"export const ActionRunner = ActionRunner_.ActionRunner;\",\n );\n yield* cbw.writeLine(\n \"export type ActionRunner = typeof ActionRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryCtx\n yield* cbw.writeLine(\"export const QueryCtx: QueryCtx_.QueryCtxTag<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\"> = QueryCtx_.QueryCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\"export type QueryCtx = typeof QueryCtx.Identifier;\");\n yield* cbw.blankLine();\n\n // MutationCtx\n yield* cbw.writeLine(\n \"export const MutationCtx: MutationCtx_.MutationCtxTag<\",\n );\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\"> = MutationCtx_.MutationCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\n \"export type MutationCtx = typeof MutationCtx.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // ActionCtx\n yield* cbw.writeLine(\"export const ActionCtx: ActionCtx_.ActionCtxTag<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\"> = ActionCtx_.ActionCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\"export type ActionCtx = typeof ActionCtx.Identifier;\");\n\n return yield* cbw.toString();\n});\n\nexport const assembledSpec = ({\n nodes,\n}: {\n nodes: ReadonlyArray<SpecAssemblyNode>;\n}) => renderSpecAssembly(nodes);\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,UAAU,EACrB,6BAEA,aAAa,EAAE,uBAAuB,CAAC;AAEzC,MAAM,eAAe,OAAO,WAAW,WAAW,EAChD,0BAGC;CACD,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,EAAE,CAAC;CAE3D,OAAO,IAAI,UAAU,4BAA4B,uBAAuB,GAAG;CAE3E,OAAO,OAAO,IAAI,SAAS;AAC7B,CAAC;;;;;;;;;;;;;;;;;;;;AA0BD,MAAa,iBAAiB,EAC5B,cACA,YAAY,YAEZ,oBAAoB;CAAE;CAAc;AAAU,CAAC;AAEjD,MAAM,sBAAsB,OAAO,WAAW,WAAW,EACvD,cACA,YAAY,SAIX;CACD,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,EAAE,CAAC;CAE3D,OAAO,IAAI,UACT,sEACF;CAEA,IAAI,aAAa,SAAS,GAAG;EAC3B,OAAO,IAAI,UAAU;EACrB,OAAO,OAAO,QAAQ,eAAe,EAAE,WAAW,iBAChD,IAAI,UAAU,UAAU,UAAU,SAAS,WAAW,GAAG,CAC3D;CACF;CAEA,OAAO,IAAI,UAAU;CAErB,IAAI,WACF,OAAO,IAAI,UAAU,2CAA2C;CAGlE,IAAI,aAAa,WAAW,GAC1B,OAAO,IAAI,UACT,uDAAuD,YAAY,yBAAyB,GAAG,4BAA4B,YAAY,cAAc,GAAG,GA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rG,CACF;CACA,OAAO,IAAI,UAAU,MAAM;CAC3B,OAAO,IAAI,UAAU,oDAAoD;CACzE,OAAO,IAAI,UAAU;CAGrB,OAAO,IAAI,UACT,wDACF;CACA,OAAO,IAAI,OACT,IAAI,UACF,oEAAoE,YAAY,mBAAmB,IACrG,CACF;CACA,OAAO,IAAI,UAAU,+BAA+B;CACpD,OAAO,IAAI,OACT,IAAI,UACF,oEAAoE,YAAY,mBAAmB,IACrG,CACF;CACA,OAAO,IAAI,UAAU,MAAM;CAC3B,OAAO,IAAI,UACT,0DACF;CACA,OAAO,IAAI,UAAU;CAGrB,OAAO,IAAI,UAAU,kDAAkD;CACvE,OAAO,IAAI,OACT,IAAI,UACF,oEAAoE,YAAY,mBAAmB,IACrG,CACF;CACA,OAAO,IAAI,UAAU,2BAA2B;CAChD,OAAO,IAAI,OACT,IAAI,UACF,oEAAoE,YAAY,mBAAmB,IACrG,CACF;CACA,OAAO,IAAI,UAAU,MAAM;CAC3B,OAAO,IAAI,UAAU,sDAAsD;CAE3E,OAAO,OAAO,IAAI,SAAS;AAC7B,CAAC;AAED,MAAa,iBAAiB,EAC5B,YAGIA,OAAmB,KAAK"}
1
+ {"version":3,"file":"templates.mjs","names":["renderSpecAssembly"],"sources":["../src/templates.ts"],"sourcesContent":["import type * as IdScope from \"@confect/core/IdScope\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport { CodeBlockWriter } from \"./CodeBlockWriter.js\";\nimport {\n render as renderSpecAssembly,\n type SpecAssemblyNode,\n} from \"./SpecAssemblyNode.js\";\n\n/**\n * Emit `convex/schema.ts` as a one-line re-export of the codegen-emitted deploy\n * schema in `confect/_generated/convexSchema.ts`. Deploy-time consumers (the\n * Convex CLI, `convex-test`) keep reading `convex/schema.ts`; the runtime\n * `DatabaseSchema` in `confect/_generated/schema.ts` is untouched by this\n * file.\n */\nexport const schema = ({\n convexSchemaImportPath,\n}: Parameters<typeof schemaEffect>[0]) =>\n schemaEffect({ convexSchemaImportPath });\n\nconst schemaEffect = Effect.fnUntraced(function* ({\n convexSchemaImportPath,\n}: {\n convexSchemaImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`export { default } from \"${convexSchemaImportPath}\";`);\n\n return yield* cbw.toString();\n});\n\ninterface TableModuleBinding {\n readonly importPath: string;\n readonly tableName: string;\n}\n\n/**\n * Emit `confect/_generated/schema.ts`—the runtime `DatabaseSchema` used by\n * impls and the per-group registries (and downstream by per-function bundles\n * for codec lookup). Every table wrapper at\n * `confect/_generated/tables/<name>.ts` is imported statically and registered\n * as a value entry on the `DatabaseSchema.make({...})` call. Per-table laziness\n * lives inside each `Table`: its `Fields` and `Doc` are lazy memoised getters\n * that only evaluate the user-supplied field-schema callback on first access,\n * so unused tables in a function bundle never pay schema-construction cost\n * despite the static import.\n *\n * The `DatabaseSchema` import is aliased to `$DatabaseSchema` because each\n * table is imported under its own (filename-derived) name; a table named\n * `DatabaseSchema` would otherwise collide with the library import and emit a\n * duplicate-binding file. The leading `$` makes the alias collision-proof:\n * `validateConfectTableIdentifier` requires names to match\n * `/^[a-zA-Z][a-zA-Z0-9_]*$/`, which forbids `$`, so no valid table import can\n * ever shadow it.\n */\nexport const runtimeSchema = ({\n tableModules,\n component = false,\n}: Parameters<typeof runtimeSchemaEffect>[0]) =>\n runtimeSchemaEffect({ tableModules, component });\n\nconst runtimeSchemaEffect = Effect.fnUntraced(function* ({\n tableModules,\n component = false,\n}: {\n tableModules: ReadonlyArray<TableModuleBinding>;\n component?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { DatabaseSchema as $DatabaseSchema } from \"@confect/server\";`,\n );\n\n if (tableModules.length > 0) {\n yield* cbw.blankLine();\n yield* Effect.forEach(tableModules, ({ tableName, importPath }) =>\n cbw.writeLine(`import ${tableName} from \"${importPath}\";`),\n );\n }\n\n yield* cbw.blankLine();\n\n if (component) {\n yield* cbw.writeLine(`import { target as $target } from \"./id.js\";`);\n }\n\n if (tableModules.length === 0) {\n yield* cbw.writeLine(\n `const databaseSchema: $DatabaseSchema.DatabaseSchema${component ? \"<{}, typeof $target>\" : \"\"} = $DatabaseSchema.make({}${component ? \", $target\" : \"\"});`,\n );\n } else {\n yield* cbw.writeLine(\n `const databaseSchema: $DatabaseSchema.DatabaseSchema<{`,\n );\n yield* cbw.indent(\n Effect.forEach(\n tableModules,\n ({ tableName }) =>\n cbw.writeLine(`readonly ${tableName}: typeof ${tableName};`),\n { discard: true },\n ),\n );\n yield* cbw.writeLine(\n `}${component ? \", typeof $target\" : \"\"}> = $DatabaseSchema.make({`,\n );\n yield* cbw.indent(\n Effect.gen(function* () {\n for (const { tableName } of tableModules) {\n yield* cbw.writeLine(`${tableName},`);\n }\n }),\n );\n yield* cbw.writeLine(`}${component ? \", $target\" : \"\"});`);\n }\n\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default databaseSchema;`);\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/convexSchema.ts`—the Convex deploy-time\n * `SchemaDefinition`. Imports every table from its generated wrapper at\n * `_generated/tables/<name>` and calls `defineSchema({...})` exactly once.\n * `Table.tableDefinition` lives in `@confect/server` because it is the\n * `defineTable` binding; the generated table wrappers themselves stay\n * client-safe (`Fields`/`Doc` from `@confect/core`).\n *\n * The `defineSchema` and `Table` imports are aliased with a leading `$` because\n * each table is imported under its own (filename-derived) name; a table named\n * `defineSchema` or `Table` would otherwise collide with the library import and\n * emit a duplicate-binding file. `validateConfectTableIdentifier` requires\n * names to match `/^[a-zA-Z][a-zA-Z0-9_]*$/`, which forbids `$`, so no valid\n * table import can ever shadow them.\n */\nexport const convexSchema = ({\n tableModules,\n}: Parameters<typeof convexSchemaEffect>[0]) =>\n convexSchemaEffect({ tableModules });\n\nconst convexSchemaEffect = Effect.fnUntraced(function* ({\n tableModules,\n}: {\n tableModules: ReadonlyArray<TableModuleBinding>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { defineSchema as $defineSchema } from \"convex/server\";`,\n );\n\n if (tableModules.length > 0) {\n yield* cbw.writeLine(`import { Table as $Table } from \"@confect/server\";`);\n yield* cbw.blankLine();\n yield* Effect.forEach(tableModules, ({ tableName, importPath }) =>\n cbw.writeLine(`import ${tableName} from \"${importPath}\";`),\n );\n }\n\n yield* cbw.blankLine();\n\n if (tableModules.length === 0) {\n yield* cbw.writeLine(`export default $defineSchema({});`);\n } else {\n yield* cbw.writeLine(`export default $defineSchema({`);\n yield* cbw.indent(\n Effect.gen(function* () {\n for (const { tableName } of tableModules) {\n yield* cbw.writeLine(\n `${tableName}: $Table.tableDefinition(${tableName}),`,\n );\n }\n }),\n );\n yield* cbw.writeLine(`});`);\n }\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/id.ts`—a type-constrained `Id` constructor and a\n * `TableNames` union derived from the user's `confect/tables/*.ts` filenames.\n * User-authored table modules import `Id` from this file to declare cross-table\n * id references without typing the destination name as a free string (and\n * without ever importing each other transitively).\n *\n * `Id` also accepts Convex system tables, with the component scope when\n * present. `TableNames` includes only user tables and resolves to `never` for\n * an empty table directory.\n */\nexport const id = ({ tableNames, scope }: Parameters<typeof idEffect>[0]) =>\n idEffect({ tableNames, scope });\n\nconst idEffect = Effect.fnUntraced(function* ({\n tableNames,\n scope,\n}: {\n tableNames: ReadonlyArray<string>;\n scope?: IdScope.Component<string> | undefined;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { GenericId${scope === undefined ? \"\" : \", IdScope\"} } from \"@confect/core\";`,\n );\n yield* cbw.writeLine(\n `import type { SystemTableNames } from \"convex/server\";`,\n );\n yield* cbw.blankLine();\n if (scope !== undefined) {\n yield* cbw.writeLine(\n // oxlint-disable-next-line effecttsgo/prefer-schema-over-json -- Emit an escaped TypeScript string literal, not a JSON payload.\n `export const scope = IdScope.component(${JSON.stringify(scope.slice(\"component:\".length))});`,\n );\n yield* cbw.writeLine(\n `export const target = { kind: \"component\", scope } as const;`,\n );\n }\n\n const union =\n tableNames.length === 0\n ? \"never\"\n : tableNames.map((n) => `\"${n}\"`).join(\" | \");\n yield* cbw.writeLine(`export type TableNames = ${union};`);\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n `export type Id<TableName extends TableNames | SystemTableNames> = GenericId.GenericId<TableName${scope === undefined ? \"\" : \", typeof scope\"}>;`,\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n `export const Id = <const TableName extends TableNames | SystemTableNames>(`,\n );\n yield* cbw.indent(cbw.writeLine(`tableName: TableName,`));\n yield* cbw.writeLine(\n `) => GenericId.GenericId(tableName${scope === undefined ? \"\" : \", scope\"});`,\n );\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/tables/<tableName>.ts`—a two-line wrapper that\n * imports the user-authored `UnnamedTable` and binds the file basename to it,\n * producing the fully-named `Table` value that downstream consumers (schema,\n * specs, impls) read.\n */\nexport const tableWrapper = ({\n tableName,\n unnamedImportPath,\n component = false,\n}: Parameters<typeof tableWrapperEffect>[0]) =>\n tableWrapperEffect({ tableName, unnamedImportPath, component });\n\nconst tableWrapperEffect = Effect.fnUntraced(function* ({\n tableName,\n unnamedImportPath,\n component = false,\n}: {\n tableName: string;\n unnamedImportPath: string;\n component?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import unnamed from \"${unnamedImportPath}\";`);\n if (component) yield* cbw.writeLine(`import { scope } from \"../id.js\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n `export default unnamed(\"${tableName}\"${component ? \", scope\" : \"\"});`,\n );\n\n return yield* cbw.toString();\n});\n\nexport const http = ({ httpImportPath }: Parameters<typeof httpEffect>[0]) =>\n httpEffect({ httpImportPath });\n\nconst httpEffect = Effect.fnUntraced(function* ({\n httpImportPath,\n}: {\n httpImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import http from \"${httpImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default http;`);\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `convex/http.ts` for a declared backend: the Convex router serving\n * `confect/http.ts`'s routes, typed by the generated database schema.\n */\nexport const declaredHttp = Effect.fnUntraced(function* ({\n schemaImportPath,\n httpImportPath,\n}: {\n schemaImportPath: string;\n httpImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n \"// Generated by `confect codegen` from confect/http.ts. Do not edit.\",\n );\n yield* cbw.writeLine(`import { HttpRouter } from \"@confect/server\";`);\n yield* cbw.writeLine(`import schema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import http from \"${httpImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(\n `export default HttpRouter.forSchema(schema)(http.routes, { api: http.api });`,\n );\n\n return yield* cbw.toString();\n});\n\nexport const crons = ({ cronsImportPath }: Parameters<typeof cronsEffect>[0]) =>\n cronsEffect({ cronsImportPath });\n\nconst cronsEffect = Effect.fnUntraced(function* ({\n cronsImportPath,\n}: {\n cronsImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import crons from \"${cronsImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default crons.convexCronJobs;`);\n\n return yield* cbw.toString();\n});\n\nexport const authConfig = ({\n authImportPath,\n}: Parameters<typeof authConfigEffect>[0]) =>\n authConfigEffect({ authImportPath });\n\nconst authConfigEffect = Effect.fnUntraced(function* ({\n authImportPath,\n}: {\n authImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import auth from \"${authImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default auth;`);\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/components.ts`—a typed registry of the Convex\n * components installed via `app.use(...)` in `convex/convex.config.ts`. Mirrors\n * the `components` export of Convex's generated `convex/_generated/api`: the\n * runtime value is `componentsGeneric()` (a name-preserving proxy), and each\n * entry is typed with the `ComponentApi` that component packages export from\n * `_generated/component.js`. Unlike `convex/_generated/api`, this file exists\n * before `convex codegen` ever runs, so impl modules can import it\n * safely—`confect codegen` bundles and evaluates each impl's import graph, and\n * `convex/_generated/api` doesn't exist yet at that point.\n *\n * The `as any` cast is confined here: `componentsGeneric()` is typed\n * `AnyChildComponents`, which deliberately doesn't overlap the precise registry\n * type; the `Components` annotation on the const supplies the real type.\n */\nexport const components = ({\n components: installedComponents,\n}: Parameters<typeof componentsEffect>[0]) =>\n componentsEffect({ components: installedComponents });\n\nconst componentsEffect = Effect.fnUntraced(function* ({\n components: installedComponents,\n}: {\n components: ReadonlyArray<{ name: string; typeImportPath: string }>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { componentsGeneric } from \"convex/server\";`);\n yield* cbw.blankLine();\n\n if (installedComponents.length === 0) {\n yield* cbw.writeLine(`export type Components = {};`);\n } else {\n yield* cbw.writeLine(`export type Components = {`);\n yield* cbw.indent(\n Effect.forEach(\n installedComponents,\n ({ name, typeImportPath }) =>\n cbw.writeLine(\n `\"${name}\": import(\"${typeImportPath}/_generated/component.js\").ComponentApi<\"${name}\">;`,\n ),\n { discard: true },\n ),\n );\n yield* cbw.writeLine(`};`);\n }\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n `export const components: Components = componentsGeneric() as any;`,\n );\n\n return yield* cbw.toString();\n});\n\nexport const refs = ({ specImportPath }: Parameters<typeof refsEffect>[0]) =>\n refsEffect({ specImportPath });\n\nconst refsEffect = Effect.fnUntraced(function* ({\n specImportPath,\n}: {\n specImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { Refs } from \"@confect/core\";`);\n yield* cbw.writeLine(`import spec from \"${specImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n `const refs: Refs.FromSpec<typeof spec> = Refs.make(spec);`,\n );\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default refs;`);\n\n return yield* cbw.toString();\n});\n\nexport const componentContract = Effect.fnUntraced(function* ({\n tableNames,\n}: {\n tableNames: ReadonlyArray<string>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n yield* cbw.writeLine('import { Component } from \"@confect/core\";');\n yield* cbw.writeLine('import spec from \"./spec.js\";');\n yield* cbw.writeLine('import { scope } from \"./id.js\";');\n yield* cbw.blankLine();\n const names = Array.map(\n [...tableNames, \"_storage\", \"_scheduled_functions\"],\n (name) => `\"${name}\"`,\n );\n yield* cbw.writeLine(\n `const component: Component.Component<typeof spec, typeof scope, ${names.join(\" | \")}> = Component.make(spec, scope, [${names.join(\", \")}]);`,\n );\n yield* cbw.writeLine(\"export default component;\");\n return yield* cbw.toString();\n});\n\n/**\n * Emit `_generated/docs.ts`: one named `type <table>` alias per table plus a\n * `Docs` registry. Each alias is `Document.Document<typeof schemaDefinition,\n * \"<table>\">`, so it stays structurally exact while giving the document a\n * _name_—declaration emit then prints e.g. `NotesDoc` instead of expanding the\n * row structure. A `type` alias (rather than an extending `interface`) is used\n * so it works for every document shape: object tables, but also union schemas\n * (`Schema.Union`) and other non-object documents, which an `interface …\n * extends` cannot represent (TS2312). The registry is threaded into the\n * generated `DatabaseReader`/`DatabaseWriter` tags so query/mutation helpers\n * print named documents with no user annotations.\n */\nexport const docs = ({\n schemaImportPath,\n tables,\n}: Parameters<typeof docsEffect>[0]) =>\n docsEffect({ schemaImportPath, tables });\n\nconst docsEffect = Effect.fnUntraced(function* ({\n schemaImportPath,\n tables,\n}: {\n schemaImportPath: string;\n tables: ReadonlyArray<{ tableName: string; docName: string }>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n // With no tables there is nothing to import—emitting the (unused) imports\n // would trip `noUnusedLocals`.\n if (tables.length === 0) {\n yield* cbw.writeLine(`export interface Docs {}`);\n return yield* cbw.toString();\n }\n\n yield* cbw.writeLine(`import type { Document } from \"@confect/server\";`);\n yield* cbw.writeLine(\n `import type schemaDefinition from \"${schemaImportPath}\";`,\n );\n yield* cbw.blankLine();\n\n for (const { tableName, docName } of tables) {\n yield* cbw.writeLine(\n `export type ${docName} = Document.Document<typeof schemaDefinition, \"${tableName}\">;`,\n );\n }\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(`export interface Docs {`);\n yield* cbw.indent(\n Effect.gen(function* () {\n for (const { tableName, docName } of tables) {\n yield* cbw.writeLine(`${tableName}: ${docName};`);\n }\n }),\n );\n yield* cbw.writeLine(`}`);\n\n return yield* cbw.toString();\n});\n\nexport const registeredFunctionsForGroup = ({\n spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n}: Parameters<typeof registeredFunctionsForGroupEffect>[0]) =>\n registeredFunctionsForGroupEffect({\n spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n });\n\nconst registeredFunctionsForGroupEffect = Effect.fnUntraced(function* ({\n spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n}: {\n spec: GroupSpec.AnyWithProps;\n schemaImportPath: string;\n specImportPath: string;\n implImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n const useNode = spec.runtime === \"Node\";\n\n const hasConfectFunctions = (group: GroupSpec.AnyWithProps): boolean =>\n Object.values(group.functions).some(\n (functionSpec) => functionSpec.functionProvenance._tag === \"Confect\",\n ) || Object.values(group.groups).some(hasConfectFunctions);\n const forwarding = !useNode && hasConfectFunctions(spec);\n\n if (useNode) {\n yield* cbw.writeLine(\n `import { RegisteredNodeFunction } from \"@confect/server/node\";`,\n );\n } else if (!forwarding) {\n yield* cbw.writeLine(\n `import { RegisteredFunctions } from \"@confect/server\";`,\n );\n } else {\n yield* cbw.writeLine(\n `import { ConvexFunctionDefinitions, RegisteredConvexFunction, type RegisteredFunctions } from \"@confect/server\";`,\n );\n }\n\n yield* cbw.writeLine(`import databaseSchema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import groupLayer from \"${implImportPath}\";`);\n yield* cbw.blankLine();\n // The group's own leaf spec is referenced type-only (`typeof import(...)`),\n // so the spec module is erased at transpile time and never enters the\n // per-function bundle; only `databaseSchema` and the impl are runtime\n // imports. Typing from the leaf spec (not the project-wide assembled spec)\n // keeps the registry's type dependent solely on its own group.\n const specType = `typeof import(\"${specImportPath}\")[\"default\"]`;\n if (useNode) {\n yield* cbw.writeLine(\n `export default RegisteredNodeFunction.buildForGroup<${specType}>(databaseSchema, groupLayer);`,\n );\n } else if (!forwarding) {\n yield* cbw.writeLine(\n `export default RegisteredFunctions.buildForGroup<${specType}>(databaseSchema, groupLayer);`,\n );\n } else {\n const bindings = (group: GroupSpec.AnyWithProps, path: string): string =>\n `{\n${[\n ...Object.entries(group.functions).map(([name, functionSpec]) => {\n const key = JSON.stringify(name);\n const definition = `${path}[${key}]`;\n return `[${key}]: ${\n functionSpec.functionProvenance._tag === \"Convex\"\n ? `${definition}.handler`\n : `RegisteredConvexFunction.register({ ...${definition}, handler: forward(${definition}.handler) })`\n },`;\n }),\n ...Object.entries(group.groups).map(([name, child]) => {\n const key = JSON.stringify(name);\n return `[${key}]: ${bindings(child, `${path}[${key}]`)},`;\n }),\n].join(\"\\n\")}\n}`;\n yield* cbw.writeLine(`const forward = <Ctx, Args, Returns>(handler: (ctx: Ctx, args: Args) => Promise<Returns>) => (ctx: Ctx, args: Args) => handler(ctx, args);\n\nconst definitions = ConvexFunctionDefinitions.buildForGroup<${specType}>(databaseSchema, groupLayer);\n\nexport default ${bindings(spec, \"definitions\")} as RegisteredFunctions.RegisteredFunctionsForGroupSpec<${specType}>;`);\n }\n\n return yield* cbw.toString();\n});\n\nexport const services = ({\n schemaImportPath,\n component = false,\n}: Parameters<typeof servicesEffect>[0]) =>\n servicesEffect({ schemaImportPath, component });\n\nconst servicesEffect = Effect.fnUntraced(function* ({\n schemaImportPath,\n component = false,\n}: {\n schemaImportPath: string;\n component?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n // Imports\n yield* cbw.writeLine(\"import {\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"ActionCtx as ActionCtx_,\");\n yield* cbw.writeLine(\"ActionRunner as ActionRunner_,\");\n if (!component) yield* cbw.writeLine(\"Auth as Auth_,\");\n yield* cbw.writeLine(\"type DataModel,\");\n yield* cbw.writeLine(\"DatabaseReader as DatabaseReader_,\");\n yield* cbw.writeLine(\"DatabaseWriter as DatabaseWriter_,\");\n yield* cbw.writeLine(\"ExecutionMetadata as ExecutionMetadata_,\");\n yield* cbw.writeLine(\"MutationCtx as MutationCtx_,\");\n yield* cbw.writeLine(\"MutationRunner as MutationRunner_,\");\n yield* cbw.writeLine(\n \"MutationTransactionContext as MutationTransactionContext_,\",\n );\n yield* cbw.writeLine(\"QueryCtx as QueryCtx_,\");\n yield* cbw.writeLine(\"QueryRunner as QueryRunner_,\");\n yield* cbw.writeLine(\n \"QueryTransactionContext as QueryTransactionContext_,\",\n );\n yield* cbw.writeLine(\"RequestMetadata as RequestMetadata_,\");\n yield* cbw.writeLine(\"Scheduler as Scheduler_,\");\n if (!component) yield* cbw.writeLine(\"Storage as Storage_,\");\n yield* cbw.writeLine(\"StorageActionWriter as StorageActionWriter_,\");\n yield* cbw.writeLine(\"StorageReader as StorageReader_,\");\n yield* cbw.writeLine(\"StorageWriter as StorageWriter_,\");\n yield* cbw.writeLine(\"TransactionMetadata as TransactionMetadata_,\");\n yield* cbw.writeLine(\"VectorSearch as VectorSearch_,\");\n }),\n );\n yield* cbw.writeLine(`} from \"@confect/server\";`);\n yield* cbw.writeLine(\n `import type schemaDefinition from \"${schemaImportPath}\";`,\n );\n yield* cbw.writeLine(`import type { Docs } from \"./docs.js\";`);\n if (component) yield* cbw.writeLine(`import type { scope } from \"./id.js\";`);\n yield* cbw.blankLine();\n\n // Auth\n if (!component) {\n yield* cbw.writeLine(\"export const Auth = Auth_.Auth;\");\n yield* cbw.writeLine(\"export type Auth = typeof Auth.Identifier;\");\n }\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const ExecutionMetadata = ExecutionMetadata_.ExecutionMetadata;\",\n );\n yield* cbw.writeLine(\n \"export type ExecutionMetadata = typeof ExecutionMetadata.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const RequestMetadata = RequestMetadata_.RequestMetadata;\",\n );\n yield* cbw.writeLine(\n \"export type RequestMetadata = typeof RequestMetadata.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const TransactionMetadata = TransactionMetadata_.TransactionMetadata;\",\n );\n yield* cbw.writeLine(\n \"export type TransactionMetadata = typeof TransactionMetadata.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // Scheduler\n yield* cbw.writeLine(\n component\n ? \"export const Scheduler = Scheduler_.forScope<typeof scope>();\"\n : \"export const Scheduler = Scheduler_.Scheduler;\",\n );\n yield* cbw.writeLine(\"export type Scheduler = typeof Scheduler.Identifier;\");\n yield* cbw.blankLine();\n\n if (!component) {\n yield* cbw.writeLine(\"export const Storage = Storage_.Storage;\");\n yield* cbw.writeLine(\"export type Storage = typeof Storage.Identifier;\");\n yield* cbw.blankLine();\n }\n\n // StorageReader\n yield* cbw.writeLine(\n `export const StorageReader = StorageReader_.StorageReader${component ? \".forScope<typeof scope>()\" : \"\"};`,\n );\n yield* cbw.writeLine(\n \"export type StorageReader = typeof StorageReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageWriter\n yield* cbw.writeLine(\n `export const StorageWriter = StorageWriter_.StorageWriter${component ? \".forScope<typeof scope>()\" : \"\"};`,\n );\n yield* cbw.writeLine(\n \"export type StorageWriter = typeof StorageWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageActionWriter\n yield* cbw.writeLine(\n `export const StorageActionWriter = StorageActionWriter_.StorageActionWriter${component ? \".forScope<typeof scope>()\" : \"\"};`,\n );\n yield* cbw.writeLine(\n \"export type StorageActionWriter = typeof StorageActionWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // VectorSearch\n yield* cbw.writeLine(\n \"export const VectorSearch: VectorSearch_.VectorSearchTag<\",\n );\n yield* cbw.indent(\n cbw.writeLine(\"DataModel.FromSchema<typeof schemaDefinition>\"),\n );\n yield* cbw.writeLine(\n \"> = VectorSearch_.VectorSearch<DataModel.FromSchema<typeof schemaDefinition>>();\",\n );\n yield* cbw.writeLine(\n \"export type VectorSearch = typeof VectorSearch.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseReader\n yield* cbw.writeLine(\n \"export const DatabaseReader: DatabaseReader_.DatabaseReaderTag<\",\n );\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"typeof schemaDefinition,\");\n yield* cbw.writeLine(\"Docs\");\n }),\n );\n yield* cbw.writeLine(\n \"> = DatabaseReader_.DatabaseReader<typeof schemaDefinition, Docs>();\",\n );\n yield* cbw.writeLine(\n \"export type DatabaseReader = typeof DatabaseReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseWriter\n yield* cbw.writeLine(\n \"export const DatabaseWriter: DatabaseWriter_.DatabaseWriterTag<\",\n );\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"typeof schemaDefinition,\");\n yield* cbw.writeLine(\"Docs\");\n }),\n );\n yield* cbw.writeLine(\n \"> = DatabaseWriter_.DatabaseWriter<typeof schemaDefinition, Docs>();\",\n );\n yield* cbw.writeLine(\n \"export type DatabaseWriter = typeof DatabaseWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const QueryTransactionContext = QueryTransactionContext_.QueryTransactionContext;\",\n );\n yield* cbw.writeLine(\n \"export type QueryTransactionContext = typeof QueryTransactionContext.Identifier;\",\n );\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n \"export const MutationTransactionContext = MutationTransactionContext_.MutationTransactionContext;\",\n );\n yield* cbw.writeLine(\n \"export type MutationTransactionContext = typeof MutationTransactionContext.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryRunner\n yield* cbw.writeLine(\"export const QueryRunner = QueryRunner_.QueryRunner;\");\n yield* cbw.writeLine(\n \"export type QueryRunner = typeof QueryRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // MutationRunner\n yield* cbw.writeLine(\n \"export const MutationRunner = MutationRunner_.MutationRunner;\",\n );\n yield* cbw.writeLine(\n \"export type MutationRunner = typeof MutationRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // ActionRunner\n yield* cbw.writeLine(\n \"export const ActionRunner = ActionRunner_.ActionRunner;\",\n );\n yield* cbw.writeLine(\n \"export type ActionRunner = typeof ActionRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryCtx\n yield* cbw.writeLine(\"export const QueryCtx: QueryCtx_.QueryCtxTag<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\"> = QueryCtx_.QueryCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\"export type QueryCtx = typeof QueryCtx.Identifier;\");\n yield* cbw.blankLine();\n\n // MutationCtx\n yield* cbw.writeLine(\n \"export const MutationCtx: MutationCtx_.MutationCtxTag<\",\n );\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\"> = MutationCtx_.MutationCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\n \"export type MutationCtx = typeof MutationCtx.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // ActionCtx\n yield* cbw.writeLine(\"export const ActionCtx: ActionCtx_.ActionCtxTag<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\"> = ActionCtx_.ActionCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\"export type ActionCtx = typeof ActionCtx.Identifier;\");\n\n return yield* cbw.toString();\n});\n\nexport const assembledSpec = ({\n nodes,\n}: {\n nodes: ReadonlyArray<SpecAssemblyNode>;\n}) => renderSpecAssembly(nodes);\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,UAAU,EACrB,6BAEA,aAAa,EAAE,uBAAuB,CAAC;AAEzC,MAAM,eAAe,OAAO,WAAW,WAAW,EAChD,0BAGC;CACD,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,EAAE,CAAC;CAE3D,OAAO,IAAI,UAAU,4BAA4B,uBAAuB,GAAG;CAE3E,OAAO,OAAO,IAAI,SAAS;AAC7B,CAAC;;;;;;;;;;;;;;;;;;;;AA0BD,MAAa,iBAAiB,EAC5B,cACA,YAAY,YAEZ,oBAAoB;CAAE;CAAc;AAAU,CAAC;AAEjD,M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,7 +23,7 @@ const toPosixPath = (path, pathStr) => pipe(String.split(pathStr, path.sep), Arr
23
23
  const toModuleImportPath = Effect.fnUntraced(function* (relativePath) {
24
24
  const path = yield* Path.Path;
25
25
  const withoutExt = toPosixPath(path, yield* removePathExtension(relativePath));
26
- return String.startsWith(".")(withoutExt) ? withoutExt : `./${withoutExt}`;
26
+ return String.startsWith(".")(withoutExt) ? `${withoutExt}.js` : `./${withoutExt}.js`;
27
27
  });
28
28
  const writeFileStringAndLog = Effect.fnUntraced(function* (filePath, contents) {
29
29
  const fs = yield* FileSystem.FileSystem;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":["templates.http","templates.crons","templates.authConfig"],"sources":["../src/utils.ts"],"sourcesContent":["import * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as DateTime from \"effect/DateTime\";\nimport * as Option from \"effect/Option\";\nimport * as String from \"effect/String\";\nimport { logFileAdded, logFileModified } from \"./log.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\nimport { ConvexDirectory } from \"./ConvexDirectory.js\";\nimport * as templates from \"./templates.js\";\n\nexport const removePathExtension = Effect.fnUntraced(function* (\n pathStr: string,\n) {\n const path = yield* Path.Path;\n\n return String.slice(0, -path.extname(pathStr).length)(pathStr);\n});\n\nexport const toPosixPath = (path: Path.Path, pathStr: string): string =>\n pipe(String.split(pathStr, path.sep), Array.join(\"/\"));\n\n/**\n * Ensures a relative path is a valid ESM/TS module specifier (e.g. `spec` →\n * `./spec`).\n */\nexport const toModuleImportPath = Effect.fnUntraced(function* (\n relativePath: string,\n) {\n const path = yield* Path.Path;\n const withoutExt = toPosixPath(\n path,\n yield* removePathExtension(relativePath),\n );\n return String.startsWith(\".\")(withoutExt) ? withoutExt : `./${withoutExt}`;\n});\n\nexport const writeFileStringAndLog = Effect.fnUntraced(function* (\n filePath: string,\n contents: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) {\n yield* fs.writeFileString(filePath, contents);\n yield* logFileAdded(filePath);\n return;\n }\n const existing = yield* fs.readFileString(filePath);\n if (existing !== contents) {\n yield* fs.writeFileString(filePath, contents);\n yield* logFileModified(filePath);\n }\n});\n\nexport const findProjectRoot = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n\n const startDir = path.resolve(\".\");\n const root = path.parse(startDir).root;\n\n const directories = Array.unfold(startDir, (dir) =>\n dir === root\n ? Option.none()\n : Option.some([dir, path.dirname(dir)] as const),\n );\n\n const projectRoot = yield* Effect.findFirst(directories, (dir) =>\n fs.exists(path.join(dir, \"package.json\")),\n );\n\n return Option.getOrElse(projectRoot, () => startDir);\n});\n\nexport type WriteChange = \"Added\" | \"Modified\" | \"Unchanged\";\n\nexport const writeFileString = Effect.fnUntraced(function* (\n filePath: string,\n contents: string,\n): Effect.fn.Return<WriteChange, PlatformError, FileSystem.FileSystem> {\n const fs = yield* FileSystem.FileSystem;\n\n if (!(yield* fs.exists(filePath))) {\n yield* fs.writeFileString(filePath, contents);\n return \"Added\";\n }\n const existing = yield* fs.readFileString(filePath);\n if (existing !== contents) {\n yield* fs.writeFileString(filePath, contents);\n return \"Modified\";\n }\n return \"Unchanged\";\n});\n\nexport const removePathIfExists = Effect.fnUntraced(function* (\n filePath: string,\n): Effect.fn.Return<void, PlatformError, FileSystem.FileSystem> {\n const fs = yield* FileSystem.FileSystem;\n\n if (!(yield* fs.exists(filePath))) {\n return;\n }\n\n yield* fs\n .remove(filePath)\n .pipe(\n Effect.catchTag(\"PlatformError\", (error) =>\n error.reason._tag === \"NotFound\" ? Effect.void : Effect.fail(error),\n ),\n );\n});\n\n/**\n * Bump the mtime of `convex/schema.ts` so the Convex CLI's chokidar watcher\n * emits a `change` event after explicit codegen, bootstrap, or recovery.\n * Recovery can leave generated contents unchanged, so it needs an explicit\n * notification to release Convex from a previous error. Ordinary successful\n * watch updates rely on their source/output changes instead of invalidating a\n * Convex push that may already be processing those changes.\n */\nexport const touchConvexSchema = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const schemaPath = path.join(convexDirectory, \"schema.ts\");\n\n if (!(yield* fs.exists(schemaPath))) {\n return;\n }\n\n const now = yield* DateTime.nowAsDate;\n yield* fs.utimes(schemaPath, now, now);\n});\n\nconst generateOptionalFile = Effect.fnUntraced(function* (\n confectFile: string,\n convexFile: string,\n generateContents: (importPath: string) => Effect.Effect<string>,\n) {\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\n const confectFilePath = path.join(confectDirectory, confectFile);\n\n if (!(yield* fs.exists(confectFilePath))) {\n return Option.none();\n }\n\n const convexFilePath = path.join(convexDirectory, convexFile);\n const relativeImportPath = path.relative(\n path.dirname(convexFilePath),\n confectFilePath,\n );\n const contents = yield* generateContents(\n yield* toModuleImportPath(relativeImportPath),\n );\n const change = yield* writeFileString(convexFilePath, contents);\n return Option.some({ change, convexFilePath });\n});\n\nexport const generateHttp = generateOptionalFile(\n \"http.ts\",\n \"http.ts\",\n (importPath) => templates.http({ httpImportPath: importPath }),\n);\n\nexport const generateCrons = generateOptionalFile(\n \"crons.ts\",\n \"crons.ts\",\n (importPath) => templates.crons({ cronsImportPath: importPath }),\n);\n\nexport const generateAuthConfig = generateOptionalFile(\n \"auth.ts\",\n \"auth.config.ts\",\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n);\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,sBAAsB,OAAO,WAAW,WACnD,SACA;CACA,MAAM,OAAO,OAAO,KAAK;CAEzB,OAAO,OAAO,MAAM,GAAG,CAAC,KAAK,QAAQ,OAAO,CAAC,CAAC,MAAM,C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3B,eACF;CACA,MAAM,WAAW,OAAO,iBACtB,OAAO,mBAAmB,kBAAkB,CAC9C;CACA,MAAM,SAAS,OAAO,gBAAgB,gBAAgB,QAAQ;CAC9D,OAAO,OAAO,KAAK;EAAE;EAAQ;CAAe,CAAC;AAC/C,CAAC;AAED,MAAa,eAAe,qBAC1B,WACA,YACC,eAAeA,KAAe,EAAE,gBAAgB,WAAW,CAAC,CAC/D;AAEA,MAAa,gBAAgB,qBAC3B,YACA,aACC,eAAeC,MAAgB,EAAE,iBAAiB,WAAW,CAAC,CACjE;AAEA,MAAa,qBAAqB,qBAChC,WACA,mBACC,eAAeC,WAAqB,EAAE,gBAAgB,WAAW,CAAC,CACrE"}
1
+ {"version":3,"file":"utils.mjs","names":["templates.http","templates.crons","templates.authConfig"],"sources":["../src/utils.ts"],"sourcesContent":["import * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as DateTime from \"effect/DateTime\";\nimport * as Option from \"effect/Option\";\nimport * as String from \"effect/String\";\nimport { logFileAdded, logFileModified } from \"./log.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\nimport { ConvexDirectory } from \"./ConvexDirectory.js\";\nimport * as templates from \"./templates.js\";\n\nexport const removePathExtension = Effect.fnUntraced(function* (\n pathStr: string,\n) {\n const path = yield* Path.Path;\n\n return String.slice(0, -path.extname(pathStr).length)(pathStr);\n});\n\nexport const toPosixPath = (path: Path.Path, pathStr: string): string =>\n pipe(String.split(pathStr, path.sep), Array.join(\"/\"));\n\n/**\n * Ensures a relative path is a valid ESM/TS module specifier (e.g. `spec` →\n * `./spec`).\n */\nexport const toModuleImportPath = Effect.fnUntraced(function* (\n relativePath: string,\n) {\n const path = yield* Path.Path;\n const withoutExt = toPosixPath(\n path,\n yield* removePathExtension(relativePath),\n );\n return String.startsWith(\".\")(withoutExt)\n ? `${withoutExt}.js`\n : `./${withoutExt}.js`;\n});\n\nexport const writeFileStringAndLog = Effect.fnUntraced(function* (\n filePath: string,\n contents: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) {\n yield* fs.writeFileString(filePath, contents);\n yield* logFileAdded(filePath);\n return;\n }\n const existing = yield* fs.readFileString(filePath);\n if (existing !== contents) {\n yield* fs.writeFileString(filePath, contents);\n yield* logFileModified(filePath);\n }\n});\n\nexport const findProjectRoot = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n\n const startDir = path.resolve(\".\");\n const root = path.parse(startDir).root;\n\n const directories = Array.unfold(startDir, (dir) =>\n dir === root\n ? Option.none()\n : Option.some([dir, path.dirname(dir)] as const),\n );\n\n const projectRoot = yield* Effect.findFirst(directories, (dir) =>\n fs.exists(path.join(dir, \"package.json\")),\n );\n\n return Option.getOrElse(projectRoot, () => startDir);\n});\n\nexport type WriteChange = \"Added\" | \"Modified\" | \"Unchanged\";\n\nexport const writeFileString = Effect.fnUntraced(function* (\n filePath: string,\n contents: string,\n): Effect.fn.Return<WriteChange, PlatformError, FileSystem.FileSystem> {\n const fs = yield* FileSystem.FileSystem;\n\n if (!(yield* fs.exists(filePath))) {\n yield* fs.writeFileString(filePath, contents);\n return \"Added\";\n }\n const existing = yield* fs.readFileString(filePath);\n if (existing !== contents) {\n yield* fs.writeFileString(filePath, contents);\n return \"Modified\";\n }\n return \"Unchanged\";\n});\n\nexport const removePathIfExists = Effect.fnUntraced(function* (\n filePath: string,\n): Effect.fn.Return<void, PlatformError, FileSystem.FileSystem> {\n const fs = yield* FileSystem.FileSystem;\n\n if (!(yield* fs.exists(filePath))) {\n return;\n }\n\n yield* fs\n .remove(filePath)\n .pipe(\n Effect.catchTag(\"PlatformError\", (error) =>\n error.reason._tag === \"NotFound\" ? Effect.void : Effect.fail(error),\n ),\n );\n});\n\n/**\n * Bump the mtime of `convex/schema.ts` so the Convex CLI's chokidar watcher\n * emits a `change` event after explicit codegen, bootstrap, or recovery.\n * Recovery can leave generated contents unchanged, so it needs an explicit\n * notification to release Convex from a previous error. Ordinary successful\n * watch updates rely on their source/output changes instead of invalidating a\n * Convex push that may already be processing those changes.\n */\nexport const touchConvexSchema = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const schemaPath = path.join(convexDirectory, \"schema.ts\");\n\n if (!(yield* fs.exists(schemaPath))) {\n return;\n }\n\n const now = yield* DateTime.nowAsDate;\n yield* fs.utimes(schemaPath, now, now);\n});\n\nconst generateOptionalFile = Effect.fnUntraced(function* (\n confectFile: string,\n convexFile: string,\n generateContents: (importPath: string) => Effect.Effect<string>,\n) {\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\n const confectFilePath = path.join(confectDirectory, confectFile);\n\n if (!(yield* fs.exists(confectFilePath))) {\n return Option.none();\n }\n\n const convexFilePath = path.join(convexDirectory, convexFile);\n const relativeImportPath = path.relative(\n path.dirname(convexFilePath),\n confectFilePath,\n );\n const contents = yield* generateContents(\n yield* toModuleImportPath(relativeImportPath),\n );\n const change = yield* writeFileString(convexFilePath, contents);\n return Option.some({ change, convexFilePath });\n});\n\nexport const generateHttp = generateOptionalFile(\n \"http.ts\",\n \"http.ts\",\n (importPath) => templates.http({ httpImportPath: importPath }),\n);\n\nexport const generateCrons = generateOptionalFile(\n \"crons.ts\",\n \"crons.ts\",\n (importPath) => templates.crons({ cronsImportPath: importPath }),\n);\n\nexport const generateAuthConfig = generateOptionalFile(\n \"auth.ts\",\n \"auth.config.ts\",\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n);\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,sBAAsB,OAAO,WAAW,WACnD,SACA;CACA,MAAM,OAAO,OAAO,KAAK;CAE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AiB,KAAK,KAAK,iBAAiB,UAAU;CAC5D,MAAM,qBAAqB,KAAK,SAC9B,KAAK,QAAQ,cAAc,GAC3B,eACF;CACA,MAAM,WAAW,OAAO,iBACtB,OAAO,mBAAmB,kBAAkB,CAC9C;CACA,MAAM,SAAS,OAAO,gBAAgB,gBAAgB,QAAQ;CAC9D,OAAO,OAAO,KAAK;EAAE;EAAQ;CAAe,CAAC;AAC/C,CAAC;AAED,MAAa,eAAe,qBAC1B,WACA,YACC,eAAeA,KAAe,EAAE,gBAAgB,WAAW,CAAC,CAC/D;AAEA,MAAa,gBAAgB,qBAC3B,YACA,aACC,eAAeC,MAAgB,EAAE,iBAAiB,WAAW,CAAC,CACjE;AAEA,MAAa,qBAAqB,qBAChC,WACA,mBACC,eAAeC,WAAqB,EAAE,gBAAgB,WAAW,CAAC,CACrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaganref/confect-cli",
3
- "version": "10.3.1-fork.5",
3
+ "version": "10.3.1-fork.7",
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.5",
13
- "@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.5",
12
+ "@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.7",
13
+ "@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.7",
14
14
  "effect": "^4.0.4"
15
15
  },
16
16
  "description": "Developer tooling for codegen and sync",