@confect/cli 9.0.2 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/BuildError.mjs +1 -1
- package/dist/Bundler.mjs +1 -1
- package/dist/CodegenError.mjs +13 -4
- package/dist/CodegenError.mjs.map +1 -1
- package/dist/DocName.mjs +26 -0
- package/dist/DocName.mjs.map +1 -0
- package/dist/FunctionPaths.mjs +2 -2
- package/dist/GroupPath.mjs +2 -2
- package/dist/SpecAssemblyNode.mjs +1 -1
- package/dist/confect/codegen.mjs +44 -11
- package/dist/confect/codegen.mjs.map +1 -1
- package/dist/confect/dev.mjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/templates.mjs +59 -25
- package/dist/templates.mjs.map +1 -1
- package/dist/utils.mjs +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @confect/cli
|
|
2
2
|
|
|
3
|
+
## 9.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8bbde87: Make Confect's public types declaration-emittable, fixing `TS7056` under `tsc --build` with `composite`/`declaration` (e.g. consuming a Confect backend as a referenced TypeScript project).
|
|
8
|
+
|
|
9
|
+
The schema-generic service tags (`DatabaseReader`, `DatabaseWriter`, `VectorSearch`, `QueryCtx`/`MutationCtx`/`ActionCtx`) now back their `Context.GenericTag` with named generic interfaces, and codegen annotates the `_generated/services.ts` exports with the corresponding tag aliases — so declaration emit prints the names by reference instead of re-expanding the whole data model (the example backend's `services.d.ts` drops from ~307 KB to ~5.6 KB).
|
|
10
|
+
|
|
11
|
+
Codegen also emits `_generated/docs.ts` — a nominal `interface` per table plus a `Docs` registry — threaded into the reader/writer tags via the `Document.Document<Schema, Table>` helper, so query/mutation helpers print named document types (e.g. `NotesDoc`) with no added annotations. Runtime behaviour is unchanged.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [8bbde87]
|
|
16
|
+
- Updated dependencies [4d8a568]
|
|
17
|
+
- @confect/server@9.1.0
|
|
18
|
+
- @confect/core@9.1.0
|
|
19
|
+
|
|
3
20
|
## 9.0.2
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/BuildError.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { formatPathDoc } from "./log.mjs";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Array from "effect/Array";
|
|
4
|
+
import { pipe } from "effect/Function";
|
|
4
5
|
import * as Match from "effect/Match";
|
|
5
6
|
import * as Option from "effect/Option";
|
|
6
|
-
import { pipe } from "effect/Function";
|
|
7
7
|
import * as Ansi from "@effect/printer-ansi/Ansi";
|
|
8
8
|
import * as AnsiDoc from "@effect/printer-ansi/AnsiDoc";
|
|
9
9
|
import * as Schema from "effect/Schema";
|
package/dist/Bundler.mjs
CHANGED
|
@@ -2,10 +2,10 @@ import { BundlerError } from "./BuildError.mjs";
|
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Path from "@effect/platform/Path";
|
|
4
4
|
import * as Array from "effect/Array";
|
|
5
|
+
import { pipe } from "effect/Function";
|
|
5
6
|
import * as Option from "effect/Option";
|
|
6
7
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
7
8
|
import { bundleRequire } from "bundle-require";
|
|
8
|
-
import { pipe } from "effect/Function";
|
|
9
9
|
|
|
10
10
|
//#region src/Bundler.ts
|
|
11
11
|
/**
|
package/dist/CodegenError.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { formatPathDoc } from "./log.mjs";
|
|
2
2
|
import { BuildError, isBuildError, renderBuildError } from "./BuildError.mjs";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Array from "effect/Array";
|
|
5
|
+
import { pipe } from "effect/Function";
|
|
4
6
|
import * as Match from "effect/Match";
|
|
5
7
|
import * as Option from "effect/Option";
|
|
6
|
-
import { pipe } from "effect/Function";
|
|
7
8
|
import * as Ansi from "@effect/printer-ansi/Ansi";
|
|
8
9
|
import * as AnsiDoc from "@effect/printer-ansi/AnsiDoc";
|
|
9
10
|
import * as Schema from "effect/Schema";
|
|
@@ -45,7 +46,11 @@ var DuplicateTableNameError = class extends Schema.TaggedError()("DuplicateTable
|
|
|
45
46
|
tablePaths: Schema.Array(Schema.String)
|
|
46
47
|
})) }) {};
|
|
47
48
|
var LegacySchemaFileError = class extends Schema.TaggedError()("LegacySchemaFileError", { schemaPath: Schema.String }) {};
|
|
48
|
-
|
|
49
|
+
var ConflictingDocNameError = class extends Schema.TaggedError()("ConflictingDocNameError", { collisions: Schema.Array(Schema.Struct({
|
|
50
|
+
docName: Schema.String,
|
|
51
|
+
tableNames: Schema.Array(Schema.String)
|
|
52
|
+
})) }) {};
|
|
53
|
+
const CodegenError = Schema.Union(BuildError, MissingImplFileError, MissingSpecFileError, SpecMissingDefaultGroupSpecError, ImplMissingSpecImportError, ImplMissingDefaultLayerError, ImplNotFinalizedError, ImplMissingFunctionsError, ParentChildNameCollisionError, InvalidTableDefaultExportError, InvalidTableFilenameError, DuplicateTableNameError, LegacySchemaFileError, ConflictingDocNameError);
|
|
49
54
|
const isCodegenError = (error) => {
|
|
50
55
|
if (isBuildError(error)) return true;
|
|
51
56
|
return Schema.is(CodegenError)(error);
|
|
@@ -76,6 +81,10 @@ const renderDuplicateTableNameError = (error) => {
|
|
|
76
81
|
const conflicts = error.collisions.map(({ tableName, tablePaths }) => `\`${tableName}\` (${tablePaths.join(", ")})`).join("; ");
|
|
77
82
|
return singleLine(AnsiDoc.text(`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}.`));
|
|
78
83
|
};
|
|
84
|
+
const renderConflictingDocNameError = (error) => {
|
|
85
|
+
const conflicts = pipe(error.collisions, Array.map(({ docName, tableNames }) => `\`${docName}\` (${Array.join(tableNames, ", ")})`), Array.join("; "));
|
|
86
|
+
return singleLine(AnsiDoc.text(`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}.`));
|
|
87
|
+
};
|
|
79
88
|
const renderLegacySchemaFileError = (error) => singleLine(AnsiDoc.text("Found a legacy "), formatPathDoc(error.schemaPath), AnsiDoc.text(". 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`."));
|
|
80
89
|
const renderParentChildNameCollisionError = (error) => singleLine(AnsiDoc.text("Spec "), formatPathDoc(error.parentSpecPath), AnsiDoc.text(` declares a ${error.collisionKind} \`${error.collisionName}\` whose name collides with the sibling subdirectory spec `), formatPathDoc(error.childSpecPath), AnsiDoc.text(`. Rename one of them so the assembled spec has a unique key at this path.`));
|
|
81
90
|
/**
|
|
@@ -86,7 +95,7 @@ const renderParentChildNameCollisionError = (error) => singleLine(AnsiDoc.text("
|
|
|
86
95
|
*/
|
|
87
96
|
const renderCodegenError = (error) => {
|
|
88
97
|
if (isBuildError(error)) return renderBuildError(error);
|
|
89
|
-
return Match.value(error).pipe(Match.tag("MissingImplFileError", (e) => pipe(renderMissingImplFileError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("MissingSpecFileError", (e) => pipe(renderMissingSpecFileError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("SpecMissingDefaultGroupSpecError", (e) => pipe(renderSpecMissingDefaultGroupSpecError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("ImplMissingSpecImportError", (e) => pipe(renderImplMissingSpecImportError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("ImplMissingDefaultLayerError", (e) => pipe(renderImplMissingDefaultLayerError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("ImplNotFinalizedError", (e) => pipe(renderImplNotFinalizedError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("ImplMissingFunctionsError", (e) => pipe(renderImplMissingFunctionsError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("ParentChildNameCollisionError", (e) => pipe(renderParentChildNameCollisionError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("InvalidTableDefaultExportError", (e) => pipe(renderInvalidTableDefaultExportError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("InvalidTableFilenameError", (e) => pipe(renderInvalidTableFilenameError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("DuplicateTableNameError", (e) => pipe(renderDuplicateTableNameError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("LegacySchemaFileError", (e) => pipe(renderLegacySchemaFileError(e), AnsiDoc.render({ style: "pretty" }))), Match.exhaustive);
|
|
98
|
+
return Match.value(error).pipe(Match.tag("MissingImplFileError", (e) => pipe(renderMissingImplFileError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("MissingSpecFileError", (e) => pipe(renderMissingSpecFileError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("SpecMissingDefaultGroupSpecError", (e) => pipe(renderSpecMissingDefaultGroupSpecError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("ImplMissingSpecImportError", (e) => pipe(renderImplMissingSpecImportError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("ImplMissingDefaultLayerError", (e) => pipe(renderImplMissingDefaultLayerError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("ImplNotFinalizedError", (e) => pipe(renderImplNotFinalizedError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("ImplMissingFunctionsError", (e) => pipe(renderImplMissingFunctionsError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("ParentChildNameCollisionError", (e) => pipe(renderParentChildNameCollisionError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("InvalidTableDefaultExportError", (e) => pipe(renderInvalidTableDefaultExportError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("InvalidTableFilenameError", (e) => pipe(renderInvalidTableFilenameError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("DuplicateTableNameError", (e) => pipe(renderDuplicateTableNameError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("LegacySchemaFileError", (e) => pipe(renderLegacySchemaFileError(e), AnsiDoc.render({ style: "pretty" }))), Match.tag("ConflictingDocNameError", (e) => pipe(renderConflictingDocNameError(e), AnsiDoc.render({ style: "pretty" }))), Match.exhaustive);
|
|
90
99
|
};
|
|
91
100
|
const logCodegenError = (error) => Effect.sync(() => console.error(renderCodegenError(error)));
|
|
92
101
|
/**
|
|
@@ -105,5 +114,5 @@ const tapAndLog = (effect) => effect.pipe(Effect.tapError((error) => isCodegenEr
|
|
|
105
114
|
const catchAndLog = (effect) => Effect.catchIf(Effect.map(effect, Option.some), isCodegenError, (error) => logCodegenError(error).pipe(Effect.as(Option.none())));
|
|
106
115
|
|
|
107
116
|
//#endregion
|
|
108
|
-
export { DuplicateTableNameError, ImplMissingDefaultLayerError, ImplMissingFunctionsError, ImplMissingSpecImportError, ImplNotFinalizedError, InvalidTableDefaultExportError, InvalidTableFilenameError, LegacySchemaFileError, MissingImplFileError, MissingSpecFileError, ParentChildNameCollisionError, SpecMissingDefaultGroupSpecError, catchAndLog, tapAndLog };
|
|
117
|
+
export { ConflictingDocNameError, DuplicateTableNameError, ImplMissingDefaultLayerError, ImplMissingFunctionsError, ImplMissingSpecImportError, ImplNotFinalizedError, InvalidTableDefaultExportError, InvalidTableFilenameError, LegacySchemaFileError, MissingImplFileError, MissingSpecFileError, ParentChildNameCollisionError, SpecMissingDefaultGroupSpecError, catchAndLog, tapAndLog };
|
|
109
118
|
//# sourceMappingURL=CodegenError.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodegenError.mjs","names":[],"sources":["../src/CodegenError.ts"],"sourcesContent":["import * as Ansi from \"@effect/printer-ansi/Ansi\";\nimport * as AnsiDoc from \"@effect/printer-ansi/AnsiDoc\";\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, renderBuildError } from \"./BuildError\";\nimport { formatPathDoc } from \"./log\";\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 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 ParentChildNameCollisionError extends Schema.TaggedError<ParentChildNameCollisionError>()(\n \"ParentChildNameCollisionError\",\n {\n parentSpecPath: Schema.String,\n childSpecPath: Schema.String,\n collisionName: Schema.String,\n collisionKind: Schema.Literal(\"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 const CodegenError = Schema.Union(\n BuildError,\n MissingImplFileError,\n MissingSpecFileError,\n SpecMissingDefaultGroupSpecError,\n ImplMissingSpecImportError,\n ImplMissingDefaultLayerError,\n ImplNotFinalizedError,\n ImplMissingFunctionsError,\n ParentChildNameCollisionError,\n InvalidTableDefaultExportError,\n InvalidTableFilenameError,\n DuplicateTableNameError,\n LegacySchemaFileError,\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 = pipe(AnsiDoc.char(\"✘\"), AnsiDoc.annotate(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 = (\n ...parts: ReadonlyArray<AnsiDoc.AnsiDoc>\n): AnsiDoc.AnsiDoc => pipe(cross, AnsiDoc.catWithSpace(AnsiDoc.hcat(parts)));\n\nconst renderMissingImplFileError = (\n error: MissingImplFileError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Spec \"),\n formatPathDoc(error.specPath),\n AnsiDoc.text(\" has no sibling impl; create \"),\n formatPathDoc(error.expectedImplPath),\n AnsiDoc.text(\" and default-export a GroupImpl layer from it.\"),\n );\n\nconst renderMissingSpecFileError = (\n error: MissingSpecFileError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Impl \"),\n formatPathDoc(error.implPath),\n AnsiDoc.text(\" has no sibling spec; create \"),\n formatPathDoc(error.expectedSpecPath),\n AnsiDoc.text(\n \" and default-export a GroupSpec from it, or remove the impl.\",\n ),\n );\n\nconst renderSpecMissingDefaultGroupSpecError = (\n error: SpecMissingDefaultGroupSpecError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Spec \"),\n formatPathDoc(error.specPath),\n AnsiDoc.text(\n \" must default-export a GroupSpec; build it with GroupSpec.make() or GroupSpec.makeNode().\",\n ),\n );\n\nconst renderImplMissingSpecImportError = (\n error: ImplMissingSpecImportError,\n): AnsiDoc.AnsiDoc => {\n const stem = stemFromSpecPath(error.expectedSpecPath);\n return singleLine(\n AnsiDoc.text(\"Impl \"),\n formatPathDoc(error.implPath),\n AnsiDoc.text(\n ` does not import its sibling spec; add \\`import ${stem} from \"./${stem}.spec\"\\` and pass it to FunctionImpl.make / GroupImpl.make.`,\n ),\n );\n};\n\nconst renderImplMissingDefaultLayerError = (\n error: ImplMissingDefaultLayerError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Impl \"),\n formatPathDoc(error.implPath),\n AnsiDoc.text(\n \" must default-export a GroupImpl layer; wrap your handlers with `GroupImpl.make(databaseSchema, groupSpec).pipe(Layer.provide(...))` and `export default` it.\",\n ),\n );\n\nconst renderImplNotFinalizedError = (\n error: ImplNotFinalizedError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Impl \"),\n formatPathDoc(error.implPath),\n AnsiDoc.text(\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 );\n\nconst renderImplMissingFunctionsError = (\n error: ImplMissingFunctionsError,\n): AnsiDoc.AnsiDoc => {\n const names = error.missingFunctionNames.join(\", \");\n return singleLine(\n AnsiDoc.text(\"Impl \"),\n formatPathDoc(error.implPath),\n AnsiDoc.text(\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};\n\nconst renderInvalidTableDefaultExportError = (\n error: InvalidTableDefaultExportError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Table \"),\n formatPathDoc(error.tablePath),\n AnsiDoc.text(\n \" must default-export a Table (e.g. `export default Table.make({ ... })`); convert any named export to a default export.\",\n ),\n );\n\nconst renderInvalidTableFilenameError = (\n error: InvalidTableFilenameError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Table \"),\n formatPathDoc(error.tablePath),\n AnsiDoc.text(\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 );\n\nconst renderDuplicateTableNameError = (\n error: DuplicateTableNameError,\n): AnsiDoc.AnsiDoc => {\n const conflicts = error.collisions\n .map(\n ({ tableName, tablePaths }) =>\n `\\`${tableName}\\` (${tablePaths.join(\", \")})`,\n )\n .join(\"; \");\n return singleLine(\n AnsiDoc.text(\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};\n\nconst renderLegacySchemaFileError = (\n error: LegacySchemaFileError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Found a legacy \"),\n formatPathDoc(error.schemaPath),\n AnsiDoc.text(\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 );\n\nconst renderParentChildNameCollisionError = (\n error: ParentChildNameCollisionError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Spec \"),\n formatPathDoc(error.parentSpecPath),\n AnsiDoc.text(\n ` declares a ${error.collisionKind} \\`${error.collisionName}\\` whose name collides with the sibling subdirectory spec `,\n ),\n formatPathDoc(error.childSpecPath),\n AnsiDoc.text(\n `. Rename one of them so the assembled spec has a unique key at this path.`,\n ),\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\n * plus an esbuild diagnostic block.\n */\nexport const renderCodegenError = (error: CodegenError): string => {\n if (isBuildError(error)) return renderBuildError(error);\n return Match.value(error).pipe(\n Match.tag(\"MissingImplFileError\", (e) =>\n pipe(renderMissingImplFileError(e), AnsiDoc.render({ style: \"pretty\" })),\n ),\n Match.tag(\"MissingSpecFileError\", (e) =>\n pipe(renderMissingSpecFileError(e), AnsiDoc.render({ style: \"pretty\" })),\n ),\n Match.tag(\"SpecMissingDefaultGroupSpecError\", (e) =>\n pipe(\n renderSpecMissingDefaultGroupSpecError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"ImplMissingSpecImportError\", (e) =>\n pipe(\n renderImplMissingSpecImportError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"ImplMissingDefaultLayerError\", (e) =>\n pipe(\n renderImplMissingDefaultLayerError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"ImplNotFinalizedError\", (e) =>\n pipe(renderImplNotFinalizedError(e), AnsiDoc.render({ style: \"pretty\" })),\n ),\n Match.tag(\"ImplMissingFunctionsError\", (e) =>\n pipe(\n renderImplMissingFunctionsError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"ParentChildNameCollisionError\", (e) =>\n pipe(\n renderParentChildNameCollisionError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"InvalidTableDefaultExportError\", (e) =>\n pipe(\n renderInvalidTableDefaultExportError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"InvalidTableFilenameError\", (e) =>\n pipe(\n renderInvalidTableFilenameError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"DuplicateTableNameError\", (e) =>\n pipe(\n renderDuplicateTableNameError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"LegacySchemaFileError\", (e) =>\n pipe(renderLegacySchemaFileError(e), AnsiDoc.render({ style: \"pretty\" })),\n ),\n Match.exhaustive,\n );\n};\n\nexport const logCodegenError = (error: CodegenError) =>\n Effect.sync(() => 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 (used by the\n * `codegen` command, which needs the failure to surface as a non-zero exit\n * code).\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()` (used by the `dev` command's sync loop, which continues\n * after a failed sync rather than exiting). Success resolves to\n * `Option.some(value)`.\n */\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"],"mappings":";;;;;;;;;;;AAYA,IAAa,uBAAb,cAA0C,OAAO,aAAmC,CAClF,wBACA;CACE,UAAU,OAAO;CACjB,kBAAkB,OAAO;CAC1B,CACF,CAAC;AAEF,IAAa,uBAAb,cAA0C,OAAO,aAAmC,CAClF,wBACA;CACE,UAAU,OAAO;CACjB,kBAAkB,OAAO;CAC1B,CACF,CAAC;AAEF,IAAa,mCAAb,cAAsD,OAAO,aAA+C,CAC1G,oCACA,EACE,UAAU,OAAO,QAClB,CACF,CAAC;AAEF,IAAa,6BAAb,cAAgD,OAAO,aAAyC,CAC9F,8BACA;CACE,UAAU,OAAO;CACjB,kBAAkB,OAAO;CAC1B,CACF,CAAC;AAEF,IAAa,+BAAb,cAAkD,OAAO,aAA2C,CAClG,gCACA,EACE,UAAU,OAAO,QAClB,CACF,CAAC;AAEF,IAAa,wBAAb,cAA2C,OAAO,aAAoC,CACpF,yBACA,EACE,UAAU,OAAO,QAClB,CACF,CAAC;AAEF,IAAa,4BAAb,cAA+C,OAAO,aAAwC,CAC5F,6BACA;CACE,UAAU,OAAO;CACjB,WAAW,OAAO;CAClB,sBAAsB,OAAO,MAAM,OAAO,OAAO;CAClD,CACF,CAAC;AAEF,IAAa,gCAAb,cAAmD,OAAO,aAA4C,CACpG,iCACA;CACE,gBAAgB,OAAO;CACvB,eAAe,OAAO;CACtB,eAAe,OAAO;CACtB,eAAe,OAAO,QAAQ,YAAY,QAAQ;CACnD,CACF,CAAC;AAEF,IAAa,iCAAb,cAAoD,OAAO,aAA6C,CACtG,kCACA,EACE,WAAW,OAAO,QACnB,CACF,CAAC;AAEF,IAAa,4BAAb,cAA+C,OAAO,aAAwC,CAC5F,6BACA;CACE,WAAW,OAAO;CAClB,QAAQ,OAAO;CAChB,CACF,CAAC;AAE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C,CACF,EACD,MAAM,IAAI,8BAA8B,MACtC,KACE,gCAAgC,EAAE,EAClC,QAAQ,OAAO,EAAE,OAAO,UAAU,CAAC,CACpC,CACF,EACD,MAAM,IAAI,4BAA4B,MACpC,KACE,8BAA8B,EAAE,EAChC,QAAQ,OAAO,EAAE,OAAO,UAAU,CAAC,CACpC,CACF,EACD,MAAM,IAAI,0BAA0B,MAClC,KAAK,4BAA4B,EAAE,EAAE,QAAQ,OAAO,EAAE,OAAO,UAAU,CAAC,CAAC,CAC1E,EACD,MAAM,WACP;;AAGH,MAAa,mBAAmB,UAC9B,OAAO,WAAW,QAAQ,MAAM,mBAAmB,MAAM,CAAC,CAAC;;;;;;;AAU7D,MAAa,aACX,WAEA,OAAO,KACL,OAAO,UAAU,UACf,eAAe,MAAM,GAAG,gBAAgB,MAAM,GAAG,OAAO,KACzD,CACF;;;;;;;AAQH,MAAa,eACX,WAEA,OAAO,QAAQ,OAAO,IAAI,QAAQ,OAAO,KAAQ,EAAE,iBAAiB,UAClE,gBAAgB,MAAM,CAAC,KAAK,OAAO,GAAG,OAAO,MAAS,CAAC,CAAC,CACzD"}
|
|
1
|
+
{"version":3,"file":"CodegenError.mjs","names":[],"sources":["../src/CodegenError.ts"],"sourcesContent":["import * as Ansi from \"@effect/printer-ansi/Ansi\";\nimport * as AnsiDoc from \"@effect/printer-ansi/AnsiDoc\";\nimport * as Array from \"effect/Array\";\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, renderBuildError } from \"./BuildError\";\nimport { formatPathDoc } from \"./log\";\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 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 ParentChildNameCollisionError extends Schema.TaggedError<ParentChildNameCollisionError>()(\n \"ParentChildNameCollisionError\",\n {\n parentSpecPath: Schema.String,\n childSpecPath: Schema.String,\n collisionName: Schema.String,\n collisionKind: Schema.Literal(\"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 const CodegenError = Schema.Union(\n BuildError,\n MissingImplFileError,\n MissingSpecFileError,\n SpecMissingDefaultGroupSpecError,\n ImplMissingSpecImportError,\n ImplMissingDefaultLayerError,\n ImplNotFinalizedError,\n ImplMissingFunctionsError,\n ParentChildNameCollisionError,\n InvalidTableDefaultExportError,\n InvalidTableFilenameError,\n DuplicateTableNameError,\n LegacySchemaFileError,\n ConflictingDocNameError,\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 = pipe(AnsiDoc.char(\"✘\"), AnsiDoc.annotate(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 = (\n ...parts: ReadonlyArray<AnsiDoc.AnsiDoc>\n): AnsiDoc.AnsiDoc => pipe(cross, AnsiDoc.catWithSpace(AnsiDoc.hcat(parts)));\n\nconst renderMissingImplFileError = (\n error: MissingImplFileError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Spec \"),\n formatPathDoc(error.specPath),\n AnsiDoc.text(\" has no sibling impl; create \"),\n formatPathDoc(error.expectedImplPath),\n AnsiDoc.text(\" and default-export a GroupImpl layer from it.\"),\n );\n\nconst renderMissingSpecFileError = (\n error: MissingSpecFileError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Impl \"),\n formatPathDoc(error.implPath),\n AnsiDoc.text(\" has no sibling spec; create \"),\n formatPathDoc(error.expectedSpecPath),\n AnsiDoc.text(\n \" and default-export a GroupSpec from it, or remove the impl.\",\n ),\n );\n\nconst renderSpecMissingDefaultGroupSpecError = (\n error: SpecMissingDefaultGroupSpecError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Spec \"),\n formatPathDoc(error.specPath),\n AnsiDoc.text(\n \" must default-export a GroupSpec; build it with GroupSpec.make() or GroupSpec.makeNode().\",\n ),\n );\n\nconst renderImplMissingSpecImportError = (\n error: ImplMissingSpecImportError,\n): AnsiDoc.AnsiDoc => {\n const stem = stemFromSpecPath(error.expectedSpecPath);\n return singleLine(\n AnsiDoc.text(\"Impl \"),\n formatPathDoc(error.implPath),\n AnsiDoc.text(\n ` does not import its sibling spec; add \\`import ${stem} from \"./${stem}.spec\"\\` and pass it to FunctionImpl.make / GroupImpl.make.`,\n ),\n );\n};\n\nconst renderImplMissingDefaultLayerError = (\n error: ImplMissingDefaultLayerError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Impl \"),\n formatPathDoc(error.implPath),\n AnsiDoc.text(\n \" must default-export a GroupImpl layer; wrap your handlers with `GroupImpl.make(databaseSchema, groupSpec).pipe(Layer.provide(...))` and `export default` it.\",\n ),\n );\n\nconst renderImplNotFinalizedError = (\n error: ImplNotFinalizedError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Impl \"),\n formatPathDoc(error.implPath),\n AnsiDoc.text(\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 );\n\nconst renderImplMissingFunctionsError = (\n error: ImplMissingFunctionsError,\n): AnsiDoc.AnsiDoc => {\n const names = error.missingFunctionNames.join(\", \");\n return singleLine(\n AnsiDoc.text(\"Impl \"),\n formatPathDoc(error.implPath),\n AnsiDoc.text(\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};\n\nconst renderInvalidTableDefaultExportError = (\n error: InvalidTableDefaultExportError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Table \"),\n formatPathDoc(error.tablePath),\n AnsiDoc.text(\n \" must default-export a Table (e.g. `export default Table.make({ ... })`); convert any named export to a default export.\",\n ),\n );\n\nconst renderInvalidTableFilenameError = (\n error: InvalidTableFilenameError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Table \"),\n formatPathDoc(error.tablePath),\n AnsiDoc.text(\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 );\n\nconst renderDuplicateTableNameError = (\n error: DuplicateTableNameError,\n): AnsiDoc.AnsiDoc => {\n const conflicts = error.collisions\n .map(\n ({ tableName, tablePaths }) =>\n `\\`${tableName}\\` (${tablePaths.join(\", \")})`,\n )\n .join(\"; \");\n return singleLine(\n AnsiDoc.text(\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};\n\nconst renderConflictingDocNameError = (\n error: ConflictingDocNameError,\n): AnsiDoc.AnsiDoc => {\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 AnsiDoc.text(\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};\n\nconst renderLegacySchemaFileError = (\n error: LegacySchemaFileError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Found a legacy \"),\n formatPathDoc(error.schemaPath),\n AnsiDoc.text(\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 );\n\nconst renderParentChildNameCollisionError = (\n error: ParentChildNameCollisionError,\n): AnsiDoc.AnsiDoc =>\n singleLine(\n AnsiDoc.text(\"Spec \"),\n formatPathDoc(error.parentSpecPath),\n AnsiDoc.text(\n ` declares a ${error.collisionKind} \\`${error.collisionName}\\` whose name collides with the sibling subdirectory spec `,\n ),\n formatPathDoc(error.childSpecPath),\n AnsiDoc.text(\n `. Rename one of them so the assembled spec has a unique key at this path.`,\n ),\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\n * plus an esbuild diagnostic block.\n */\nexport const renderCodegenError = (error: CodegenError): string => {\n if (isBuildError(error)) return renderBuildError(error);\n return Match.value(error).pipe(\n Match.tag(\"MissingImplFileError\", (e) =>\n pipe(renderMissingImplFileError(e), AnsiDoc.render({ style: \"pretty\" })),\n ),\n Match.tag(\"MissingSpecFileError\", (e) =>\n pipe(renderMissingSpecFileError(e), AnsiDoc.render({ style: \"pretty\" })),\n ),\n Match.tag(\"SpecMissingDefaultGroupSpecError\", (e) =>\n pipe(\n renderSpecMissingDefaultGroupSpecError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"ImplMissingSpecImportError\", (e) =>\n pipe(\n renderImplMissingSpecImportError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"ImplMissingDefaultLayerError\", (e) =>\n pipe(\n renderImplMissingDefaultLayerError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"ImplNotFinalizedError\", (e) =>\n pipe(renderImplNotFinalizedError(e), AnsiDoc.render({ style: \"pretty\" })),\n ),\n Match.tag(\"ImplMissingFunctionsError\", (e) =>\n pipe(\n renderImplMissingFunctionsError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"ParentChildNameCollisionError\", (e) =>\n pipe(\n renderParentChildNameCollisionError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"InvalidTableDefaultExportError\", (e) =>\n pipe(\n renderInvalidTableDefaultExportError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"InvalidTableFilenameError\", (e) =>\n pipe(\n renderInvalidTableFilenameError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"DuplicateTableNameError\", (e) =>\n pipe(\n renderDuplicateTableNameError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.tag(\"LegacySchemaFileError\", (e) =>\n pipe(renderLegacySchemaFileError(e), AnsiDoc.render({ style: \"pretty\" })),\n ),\n Match.tag(\"ConflictingDocNameError\", (e) =>\n pipe(\n renderConflictingDocNameError(e),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n ),\n Match.exhaustive,\n );\n};\n\nexport const logCodegenError = (error: CodegenError) =>\n Effect.sync(() => 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 (used by the\n * `codegen` command, which needs the failure to surface as a non-zero exit\n * code).\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()` (used by the `dev` command's sync loop, which continues\n * after a failed sync rather than exiting). Success resolves to\n * `Option.some(value)`.\n */\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"],"mappings":";;;;;;;;;;;;AAaA,IAAa,uBAAb,cAA0C,OAAO,aAAmC,CAClF,wBACA;CACE,UAAU,OAAO;CACjB,kBAAkB,OAAO;CAC1B,CACF,CAAC;AAEF,IAAa,uBAAb,cAA0C,OAAO,aAAmC,CAClF,wBACA;CACE,UAAU,OAAO;CACjB,kBAAkB,OAAO;CAC1B,CACF,CAAC;AAEF,IAAa,mCAAb,cAAsD,OAAO,aAA+C,CAC1G,oCACA,EACE,UAAU,OAAO,QAClB,CACF,CAAC;AAEF,IAAa,6BAAb,cAAgD,OAAO,aAAyC,CAC9F,8BACA;CACE,UAAU,OAAO;CACjB,kBAAkB,OAAO;CAC1B,CACF,CAAC;AAEF,IAAa,+BAAb,cAAkD,OAAO,aAA2C,CAClG,gCACA,EACE,UAAU,OAAO,QAClB,CACF,CAAC;AAEF,IAAa,wBAAb,cAA2C,OAAO,aAAoC,CACpF,yBACA,EACE,UAAU,OAAO,QAClB,CACF,CAAC;AAEF,IAAa,4BAAb,cAA+C,OAAO,aAAwC,CAC5F,6BACA;CACE,UAAU,OAAO;CACjB,WAAW,OAAO;CAClB,sBAAsB,OAAO,MAAM,OAAO,OAAO;CAClD,CACF,CAAC;AAEF,IAAa,gCAAb,cAAmD,OAAO,aAA4C,CACpG,iCACA;CACE,gBAAgB,OAAO;CACvB,eAAe,OAAO;CACtB,eAAe,OAAO;CACtB,eAAe,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Ae,MAAM,GAAG,gBAAgB,MAAM,GAAG,OAAO,KACzD,CACF;;;;;;;AAQH,MAAa,eACX,WAEA,OAAO,QAAQ,OAAO,IAAI,QAAQ,OAAO,KAAQ,EAAE,iBAAiB,UAClE,gBAAgB,MAAM,CAAC,KAAK,OAAO,GAAG,OAAO,MAAS,CAAC,CAAC,CACzD"}
|
package/dist/DocName.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as Array from "effect/Array";
|
|
2
|
+
import { pipe } from "effect/Function";
|
|
3
|
+
import * as String from "effect/String";
|
|
4
|
+
import * as Brand from "effect/Brand";
|
|
5
|
+
|
|
6
|
+
//#region src/DocName.ts
|
|
7
|
+
const DocName = Brand.nominal();
|
|
8
|
+
/**
|
|
9
|
+
* Convert a Convex table name to the name of its generated document interface
|
|
10
|
+
* in `confect/_generated/docs.ts`.
|
|
11
|
+
*
|
|
12
|
+
* The table name is split on underscores and the first letter of each segment
|
|
13
|
+
* is upper-cased, then a `Doc` suffix is appended — so both `snake_case` and
|
|
14
|
+
* `camelCase` spellings of a table fold to the same idiomatic PascalCase type
|
|
15
|
+
* name (`user_profiles` and `userProfiles` both become `UserProfilesDoc`).
|
|
16
|
+
* That folding can make two distinct tables map to the same document name;
|
|
17
|
+
* codegen guards against it (see `validateNoDocNameCollisions`).
|
|
18
|
+
*
|
|
19
|
+
* Note this name is purely cosmetic: the `Docs` registry is keyed by the
|
|
20
|
+
* verbatim table name, which is what document lookups index through.
|
|
21
|
+
*/
|
|
22
|
+
const fromTableName = (tableName) => DocName(pipe(tableName, String.split("_"), Array.filter(String.isNonEmpty), Array.map(String.capitalize), Array.join(""), String.concat("Doc")));
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { fromTableName };
|
|
26
|
+
//# sourceMappingURL=DocName.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocName.mjs","names":[],"sources":["../src/DocName.ts"],"sourcesContent":["import * as Array from \"effect/Array\";\nimport * as Brand from \"effect/Brand\";\nimport { pipe } from \"effect/Function\";\nimport * as String from \"effect/String\";\n\n/**\n * The name of a table's generated document interface in\n * `confect/_generated/docs.ts` (e.g. `UserProfilesDoc`). Branded so it can't be\n * confused with an arbitrary string — construct it with {@link fromTableName}.\n */\nexport type DocName = string & Brand.Brand<\"DocName\">;\n\nconst DocName = Brand.nominal<DocName>();\n\n/**\n * Convert a Convex table name to the name of its generated document interface\n * in `confect/_generated/docs.ts`.\n *\n * The table name is split on underscores and the first letter of each segment\n * is upper-cased, then a `Doc` suffix is appended — so both `snake_case` and\n * `camelCase` spellings of a table fold to the same idiomatic PascalCase type\n * name (`user_profiles` and `userProfiles` both become `UserProfilesDoc`).\n * That folding can make two distinct tables map to the same document name;\n * codegen guards against it (see `validateNoDocNameCollisions`).\n *\n * Note this name is purely cosmetic: the `Docs` registry is keyed by the\n * verbatim table name, which is what document lookups index through.\n */\nexport const fromTableName = (tableName: string): DocName =>\n DocName(\n pipe(\n tableName,\n String.split(\"_\"),\n Array.filter(String.isNonEmpty),\n Array.map(String.capitalize),\n Array.join(\"\"),\n String.concat(\"Doc\"),\n ),\n );\n"],"mappings":";;;;;;AAYA,MAAM,UAAU,MAAM,SAAkB;;;;;;;;;;;;;;;AAgBxC,MAAa,iBAAiB,cAC5B,QACE,KACE,WACA,OAAO,MAAM,IAAI,EACjB,MAAM,OAAO,OAAO,WAAW,EAC/B,MAAM,IAAI,OAAO,WAAW,EAC5B,MAAM,KAAK,GAAG,EACd,OAAO,OAAO,MAAM,CACrB,CACF"}
|
package/dist/FunctionPaths.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { append, make as make$1 } from "./GroupPath.mjs";
|
|
2
2
|
import { FunctionPath, groupPath } from "./FunctionPath.mjs";
|
|
3
3
|
import { GroupPaths } from "./GroupPaths.mjs";
|
|
4
|
+
import { pipe } from "effect/Function";
|
|
4
5
|
import * as HashSet from "effect/HashSet";
|
|
5
6
|
import * as Option from "effect/Option";
|
|
6
|
-
import { pipe } from "effect/Function";
|
|
7
|
-
import * as Schema from "effect/Schema";
|
|
8
7
|
import * as Record from "effect/Record";
|
|
8
|
+
import * as Schema from "effect/Schema";
|
|
9
9
|
|
|
10
10
|
//#region src/FunctionPaths.ts
|
|
11
11
|
const FunctionPaths = Schema.HashSetFromSelf(FunctionPath).pipe(Schema.brand("@confect/cli/FunctionPaths"));
|
package/dist/GroupPath.mjs
CHANGED
|
@@ -2,12 +2,12 @@ import * as Effect from "effect/Effect";
|
|
|
2
2
|
import "@confect/core";
|
|
3
3
|
import * as Path from "@effect/platform/Path";
|
|
4
4
|
import * as Array from "effect/Array";
|
|
5
|
-
import * as Option from "effect/Option";
|
|
6
5
|
import { pipe } from "effect/Function";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
import * as Record from "effect/Record";
|
|
7
8
|
import * as Schema from "effect/Schema";
|
|
8
9
|
import * as String from "effect/String";
|
|
9
10
|
import * as Data from "effect/Data";
|
|
10
|
-
import * as Record from "effect/Record";
|
|
11
11
|
|
|
12
12
|
//#region src/GroupPath.ts
|
|
13
13
|
/**
|
package/dist/confect/codegen.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { logFileAdded, logFileModified, logFileRemoved, logPending, logSuccess, logWarn } from "../log.mjs";
|
|
2
2
|
import { bundle } from "../Bundler.mjs";
|
|
3
|
-
import { LegacySchemaFileError, MissingImplFileError, MissingSpecFileError, ParentChildNameCollisionError, tapAndLog } from "../CodegenError.mjs";
|
|
3
|
+
import { ConflictingDocNameError, LegacySchemaFileError, MissingImplFileError, MissingSpecFileError, ParentChildNameCollisionError, tapAndLog } from "../CodegenError.mjs";
|
|
4
4
|
import { ConvexDirectory } from "../ConvexDirectory.mjs";
|
|
5
5
|
import { ConfectDirectory } from "../ConfectDirectory.mjs";
|
|
6
|
+
import { fromTableName } from "../DocName.mjs";
|
|
6
7
|
import { FunctionPaths, make } from "../FunctionPaths.mjs";
|
|
7
8
|
import { assemblyNodesFromLeaves } from "../SpecAssemblyNode.mjs";
|
|
8
|
-
import { assembledSpec, convexSchema, id, refs, registeredFunctionsForGroup, runtimeSchema, schema, services, tableWrapper } from "../templates.mjs";
|
|
9
|
+
import { assembledSpec, convexSchema, docs, id, refs, registeredFunctionsForGroup, runtimeSchema, schema, services, tableWrapper } from "../templates.mjs";
|
|
9
10
|
import { WriteTracker, generateAuthConfig, generateCrons, generateFunctions, generateHttp, removePathIfExists, toModuleImportPath, touchConvexSchema, writeFileStringAndLog } from "../utils.mjs";
|
|
10
11
|
import { discoverLeafImplFiles, discoverLeafSpecFiles, implPathForSpec, registeredFunctionsRelativePath, specPathForImpl, toLeafModule, validateImpl, validateSpec } from "../LeafModule.mjs";
|
|
11
12
|
import { TABLES_DIRNAME, discover, validate } from "../TableModule.mjs";
|
|
@@ -16,9 +17,11 @@ import * as FileSystem from "@effect/platform/FileSystem";
|
|
|
16
17
|
import * as Path from "@effect/platform/Path";
|
|
17
18
|
import * as Array from "effect/Array";
|
|
18
19
|
import * as Either from "effect/Either";
|
|
20
|
+
import { pipe } from "effect/Function";
|
|
19
21
|
import * as HashSet from "effect/HashSet";
|
|
20
22
|
import * as Match from "effect/Match";
|
|
21
23
|
import * as Option from "effect/Option";
|
|
24
|
+
import * as Record from "effect/Record";
|
|
22
25
|
import * as Ref from "effect/Ref";
|
|
23
26
|
|
|
24
27
|
//#region src/confect/codegen.ts
|
|
@@ -60,6 +63,7 @@ const runCodegen = Effect.gen(function* () {
|
|
|
60
63
|
yield* warnIfNoTables(tableModules);
|
|
61
64
|
yield* generateIdConstructor(tableModules);
|
|
62
65
|
yield* validate(tableModules);
|
|
66
|
+
yield* validateNoDocNameCollisions(tableModules);
|
|
63
67
|
yield* generateTableWrappers(tableModules);
|
|
64
68
|
yield* removeObsoleteTableWrappers(tableModules);
|
|
65
69
|
yield* generateRuntimeSchema(tableModules);
|
|
@@ -71,6 +75,7 @@ const runCodegen = Effect.gen(function* () {
|
|
|
71
75
|
removeGeneratedApi,
|
|
72
76
|
generateRefs,
|
|
73
77
|
removeGeneratedNodeApi,
|
|
78
|
+
generateDocs(tableModules),
|
|
74
79
|
generateServices,
|
|
75
80
|
generateConvexSchema(tableModules)
|
|
76
81
|
], { concurrency: "unbounded" });
|
|
@@ -342,11 +347,11 @@ const tableModuleBindings = (tableModules, generatedFilePath) => Effect.gen(func
|
|
|
342
347
|
const confectDirectory = yield* ConfectDirectory.get;
|
|
343
348
|
const generatedDir = path.dirname(generatedFilePath);
|
|
344
349
|
const generatedTablesDirname = yield* GENERATED_TABLES_DIRNAME;
|
|
345
|
-
return yield* Effect.forEach(tableModules, (
|
|
346
|
-
const wrapperAbsolutePath = path.join(confectDirectory, generatedTablesDirname, `${
|
|
350
|
+
return yield* Effect.forEach(tableModules, (tableModule) => Effect.gen(function* () {
|
|
351
|
+
const wrapperAbsolutePath = path.join(confectDirectory, generatedTablesDirname, `${tableModule.tableName}.ts`);
|
|
347
352
|
return {
|
|
348
353
|
importPath: yield* toModuleImportPath(path.relative(generatedDir, wrapperAbsolutePath)),
|
|
349
|
-
tableName:
|
|
354
|
+
tableName: tableModule.tableName
|
|
350
355
|
};
|
|
351
356
|
}));
|
|
352
357
|
});
|
|
@@ -355,7 +360,7 @@ const generateIdConstructor = (tableModules) => Effect.gen(function* () {
|
|
|
355
360
|
const confectDirectory = yield* ConfectDirectory.get;
|
|
356
361
|
const generatedIdPath = yield* GENERATED_ID_PATH;
|
|
357
362
|
const idPath = path.join(confectDirectory, generatedIdPath);
|
|
358
|
-
const tableNames =
|
|
363
|
+
const tableNames = Array.map(tableModules, (tableModule) => tableModule.tableName);
|
|
359
364
|
yield* writeFileStringAndLog(idPath, yield* id({ tableNames }));
|
|
360
365
|
});
|
|
361
366
|
const generateTableWrappers = (tableModules) => Effect.gen(function* () {
|
|
@@ -365,12 +370,12 @@ const generateTableWrappers = (tableModules) => Effect.gen(function* () {
|
|
|
365
370
|
const generatedTablesDirname = yield* GENERATED_TABLES_DIRNAME;
|
|
366
371
|
const wrappersDir = path.join(confectDirectory, generatedTablesDirname);
|
|
367
372
|
if (!(yield* fs.exists(wrappersDir))) yield* fs.makeDirectory(wrappersDir, { recursive: true });
|
|
368
|
-
yield* Effect.forEach(tableModules, (
|
|
369
|
-
const wrapperPath = path.join(confectDirectory, generatedTablesDirname, `${
|
|
370
|
-
const unnamedAbsolutePath = path.join(confectDirectory,
|
|
373
|
+
yield* Effect.forEach(tableModules, (tableModule) => Effect.gen(function* () {
|
|
374
|
+
const wrapperPath = path.join(confectDirectory, generatedTablesDirname, `${tableModule.tableName}.ts`);
|
|
375
|
+
const unnamedAbsolutePath = path.join(confectDirectory, tableModule.relativePath);
|
|
371
376
|
const unnamedImportPath = yield* toModuleImportPath(path.relative(path.dirname(wrapperPath), unnamedAbsolutePath));
|
|
372
377
|
yield* writeFileStringAndLog(wrapperPath, yield* tableWrapper({
|
|
373
|
-
tableName:
|
|
378
|
+
tableName: tableModule.tableName,
|
|
374
379
|
unnamedImportPath
|
|
375
380
|
}));
|
|
376
381
|
}), { concurrency: "unbounded" });
|
|
@@ -387,7 +392,7 @@ const removeObsoleteTableWrappers = (tableModules) => Effect.gen(function* () {
|
|
|
387
392
|
const generatedTablesDirname = yield* GENERATED_TABLES_DIRNAME;
|
|
388
393
|
const wrappersDir = path.join(confectDirectory, generatedTablesDirname);
|
|
389
394
|
if (!(yield* fs.exists(wrappersDir))) return;
|
|
390
|
-
const expected = new Set(
|
|
395
|
+
const expected = new Set(Array.map(tableModules, (tableModule) => `${tableModule.tableName}.ts`));
|
|
391
396
|
const existing = yield* fs.readDirectory(wrappersDir, { recursive: true });
|
|
392
397
|
yield* Effect.forEach(existing, (entry) => {
|
|
393
398
|
if (path.extname(entry) !== ".ts") return Effect.void;
|
|
@@ -436,6 +441,34 @@ const generateServices = Effect.gen(function* () {
|
|
|
436
441
|
const schemaImportPath = yield* toModuleImportPath(path.relative(path.dirname(servicesPath), path.join(confectDirectory, generatedSchemaPath)));
|
|
437
442
|
yield* writeFileStringAndLog(servicesPath, yield* services({ schemaImportPath }));
|
|
438
443
|
});
|
|
444
|
+
/**
|
|
445
|
+
* Two tables whose names fold to the same PascalCase document type name (e.g.
|
|
446
|
+
* `user_profiles` and `userProfiles` → `UserProfilesDoc`) would emit duplicate
|
|
447
|
+
* interfaces in `_generated/docs.ts`. Catch that up front with a clear error
|
|
448
|
+
* rather than letting `tsc` report a duplicate-identifier later.
|
|
449
|
+
*/
|
|
450
|
+
const validateNoDocNameCollisions = (tableModules) => Effect.gen(function* () {
|
|
451
|
+
const collisions = pipe(tableModules, Array.groupBy((tableModule) => fromTableName(tableModule.tableName)), Record.toEntries, Array.filter(([, group]) => group.length > 1), Array.map(([docName, group]) => ({
|
|
452
|
+
docName,
|
|
453
|
+
tableNames: Array.map(group, (tableModule) => tableModule.tableName)
|
|
454
|
+
})));
|
|
455
|
+
if (Array.isNonEmptyReadonlyArray(collisions)) return yield* new ConflictingDocNameError({ collisions });
|
|
456
|
+
});
|
|
457
|
+
const generateDocs = (tableModules) => Effect.gen(function* () {
|
|
458
|
+
const path = yield* Path.Path;
|
|
459
|
+
const confectDirectory = yield* ConfectDirectory.get;
|
|
460
|
+
const confectGeneratedDirectory = path.join(confectDirectory, "_generated");
|
|
461
|
+
const docsPath = path.join(confectGeneratedDirectory, "docs.ts");
|
|
462
|
+
const generatedSchemaPath = yield* GENERATED_SCHEMA_PATH;
|
|
463
|
+
const schemaImportPath = yield* toModuleImportPath(path.relative(path.dirname(docsPath), path.join(confectDirectory, generatedSchemaPath)));
|
|
464
|
+
yield* writeFileStringAndLog(docsPath, yield* docs({
|
|
465
|
+
schemaImportPath,
|
|
466
|
+
tables: Array.map(tableModules, (tableModule) => ({
|
|
467
|
+
tableName: tableModule.tableName,
|
|
468
|
+
docName: fromTableName(tableModule.tableName)
|
|
469
|
+
}))
|
|
470
|
+
}));
|
|
471
|
+
});
|
|
439
472
|
const generateRefs = Effect.gen(function* () {
|
|
440
473
|
const path = yield* Path.Path;
|
|
441
474
|
const confectDirectory = yield* ConfectDirectory.get;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.mjs","names":["CodegenError.tapAndLog","TableModule.discover","TableModule.validate","templates.assembledSpec","templates.registeredFunctionsForGroup","Bundler.bundle","FunctionPaths.make","TableModule.TABLES_DIRNAME","templates.id","templates.tableWrapper","templates.runtimeSchema","templates.convexSchema","templates.schema","templates.services","templates.refs"],"sources":["../../src/confect/codegen.ts"],"sourcesContent":["import { Spec, type GroupSpec } from \"@confect/core\";\nimport * as Command from \"@effect/cli/Command\";\nimport * as FileSystem from \"@effect/platform/FileSystem\";\nimport * as Path from \"@effect/platform/Path\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as Either from \"effect/Either\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Ref from \"effect/Ref\";\nimport * as Bundler from \"../Bundler\";\nimport * as CodegenError from \"../CodegenError\";\nimport {\n LegacySchemaFileError,\n MissingImplFileError,\n MissingSpecFileError,\n ParentChildNameCollisionError,\n} from \"../CodegenError\";\nimport { ConfectDirectory } from \"../ConfectDirectory\";\nimport { ConvexDirectory } from \"../ConvexDirectory\";\nimport * as FunctionPaths from \"../FunctionPaths\";\nimport {\n discoverLeafImplFiles,\n discoverLeafSpecFiles,\n implPathForSpec,\n registeredFunctionsRelativePath,\n specPathForImpl,\n toLeafModule,\n validateImpl,\n validateSpec,\n type LeafModule,\n} from \"../LeafModule\";\nimport {\n logFileAdded,\n logFileModified,\n logFileRemoved,\n logPending,\n logSuccess,\n logWarn,\n} from \"../log\";\nimport {\n assemblyNodesFromLeaves,\n type SpecAssemblyNode,\n} from \"../SpecAssemblyNode\";\nimport * as TableModule from \"../TableModule\";\nimport * as templates from \"../templates\";\nimport {\n generateAuthConfig,\n generateCrons,\n generateFunctions,\n generateHttp,\n removePathIfExists,\n toModuleImportPath,\n touchConvexSchema,\n writeFileStringAndLog,\n WriteTracker,\n} from \"../utils\";\n\nconst GENERATED_DIRNAME = \"_generated\";\n\nconst GENERATED_SPEC_PATH = Effect.andThen(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"spec.ts\"),\n);\nconst GENERATED_SCHEMA_PATH = Effect.andThen(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"schema.ts\"),\n);\nconst GENERATED_CONVEX_SCHEMA_PATH = Effect.andThen(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"convexSchema.ts\"),\n);\nconst GENERATED_ID_PATH = Effect.andThen(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"id.ts\"),\n);\nconst GENERATED_TABLES_DIRNAME = Effect.andThen(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\", {}, () =>\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.withDescription(\n \"Generate `confect/_generated` files and the contents of the `convex` directory (except `convex.config.ts` and `tsconfig.json`)\",\n ),\n);\n\nexport const codegenHandler = Effect.gen(function* () {\n const tracker = yield* Ref.make(false);\n\n const functionPaths = yield* runCodegen.pipe(\n Effect.provideService(WriteTracker, tracker),\n );\n\n const anyWritesHappened = yield* Ref.get(tracker);\n return { functionPaths, anyWritesHappened };\n});\n\nconst runCodegen = Effect.gen(function* () {\n yield* generateConfectGeneratedDirectory;\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 // 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* generateTableWrappers(tableModules);\n yield* removeObsoleteTableWrappers(tableModules);\n yield* generateRuntimeSchema(tableModules);\n const { leaves, groupSpecsByRelativePath } =\n yield* loadAndValidateLeafModules;\n yield* removeLegacyFiles;\n yield* validateNoParentChildNameCollisions(leaves, groupSpecsByRelativePath);\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 removeGeneratedNodeApi,\n generateServices,\n generateConvexSchema(tableModules),\n ],\n { concurrency: \"unbounded\" },\n );\n yield* validateImplModules(leaves);\n yield* generateGroupRegisteredFunctions(leaves);\n yield* removeObsoleteRegisteredFunctions(leaves);\n const [functionPaths] = yield* Effect.all(\n [\n generateFunctionModules,\n generateConvexSchemaReexport,\n logGenerated(generateHttp),\n logGenerated(generateCrons),\n logGenerated(generateAuthConfig),\n ],\n { concurrency: \"unbounded\" },\n );\n yield* touchConvexSchema;\n return functionPaths;\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 loadAndValidateLeafModules = 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* Effect.forEach(specFiles, (specRelativePath) =>\n Effect.gen(function* () {\n const discovered = yield* toLeafModule(specRelativePath);\n const groupSpec = yield* validateSpec(discovered);\n // Fill in the runtime now that the spec is bundled; discovery left it `None`.\n const leaf = {\n ...discovered,\n runtime: Option.some(groupSpec.runtime),\n };\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, groupSpec };\n }),\n );\n\n yield* validateOrphanImpls(specFiles);\n\n const leaves = Array.map(results, ({ leaf }) => leaf);\n const groupSpecsByRelativePath = new Map(\n Array.map(results, ({ leaf, groupSpec }) => [leaf.relativePath, groupSpec]),\n );\n\n return { leaves, groupSpecsByRelativePath };\n});\n\n/**\n * Walk the assembly tree and fail with a {@link ParentChildNameCollisionError}\n * when a parent leaf declares a function or subgroup whose name matches a\n * sibling subdirectory spec's segment. Without this check the colliding\n * descendant would overwrite the parent's entry in the assembled\n * `GroupSpec.groups` map at runtime, surfacing as a confusing\n * `Refs.make` error rather than a codegen-time diagnostic.\n */\nexport const validateNoParentChildNameCollisions = (\n leaves: ReadonlyArray<LeafModule>,\n groupSpecsByRelativePath: ReadonlyMap<string, GroupSpec.AnyWithProps>,\n) =>\n Effect.gen(function* () {\n // Convex and Node groups share one namespace, so they assemble into a\n // single tree. A Node group nested under a Convex parent (or vice versa) is\n // caught here by the parent/child collision check.\n const nodes = assemblyNodesFromLeaves(leaves);\n yield* Effect.forEach(nodes, (n) =>\n checkAssemblyNodeForCollisions(n, groupSpecsByRelativePath),\n );\n });\n\nconst checkAssemblyNodeForCollisions = (\n node: SpecAssemblyNode,\n groupSpecsByRelativePath: ReadonlyMap<string, GroupSpec.AnyWithProps>,\n): Effect.Effect<void, ParentChildNameCollisionError> =>\n Effect.gen(function* () {\n yield* Option.match(node.importBinding, {\n onNone: () => Effect.void,\n onSome: (binding) =>\n Effect.gen(function* () {\n if (node.children.length === 0) return;\n const parentRelativePath = bindingToRelativeSpecPath(\n binding.importPath,\n );\n const parentGroupSpec =\n groupSpecsByRelativePath.get(parentRelativePath);\n if (parentGroupSpec === undefined) return;\n yield* Effect.forEach(node.children, (child) => {\n if (\n Object.prototype.hasOwnProperty.call(\n parentGroupSpec.functions,\n child.segment,\n )\n ) {\n return Effect.fail(\n new ParentChildNameCollisionError({\n parentSpecPath: parentRelativePath,\n childSpecPath: childRepresentativeSpecPath(child),\n collisionName: child.segment,\n collisionKind: \"function\",\n }),\n );\n }\n if (\n Object.prototype.hasOwnProperty.call(\n parentGroupSpec.groups,\n child.segment,\n )\n ) {\n return Effect.fail(\n new ParentChildNameCollisionError({\n parentSpecPath: parentRelativePath,\n childSpecPath: childRepresentativeSpecPath(child),\n collisionName: child.segment,\n collisionKind: \"group\",\n }),\n );\n }\n return Effect.void;\n });\n }),\n });\n yield* Effect.forEach(node.children, (child) =>\n checkAssemblyNodeForCollisions(child, groupSpecsByRelativePath),\n );\n });\n\n/**\n * `LeafModule.specImportPath` is the import path used from inside the\n * generated `_generated/spec.ts` (e.g. `\"../notes.spec\"`). Strip the\n * `../` prefix and re-add the `.ts` extension to recover the leaf's\n * confect-relative spec path used as the key in\n * `groupSpecsByRelativePath`.\n */\nconst bindingToRelativeSpecPath = (importPath: string): string => {\n const withoutDotDot = importPath.startsWith(\"../\")\n ? importPath.slice(3)\n : importPath;\n return `${withoutDotDot}.ts`;\n};\n\n/**\n * A child assembly node may itself be a parent without a leaf (when the\n * actual leaves live only in deeper subdirectories). In that case we\n * surface the first descendant leaf as a representative path so the\n * error message points at something the user actually wrote.\n */\nconst childRepresentativeSpecPath = (node: SpecAssemblyNode): string => {\n if (Option.isSome(node.importBinding)) {\n return bindingToRelativeSpecPath(node.importBinding.value.importPath);\n }\n for (const child of node.children) {\n return childRepresentativeSpecPath(child);\n }\n return node.segment;\n};\n\nconst validateOrphanImpls = (specFiles: ReadonlyArray<string>) =>\n Effect.gen(function* () {\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 = new Set(specFiles);\n\n yield* Effect.forEach(implFiles, (implRelativePath) =>\n Effect.gen(function* () {\n const specRelativePath = yield* specPathForImpl(implRelativePath);\n if (specPaths.has(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\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(legacyPaths, (relativePath) =>\n Effect.gen(function* () {\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 = (leaves: ReadonlyArray<LeafModule>) =>\n Effect.gen(function* () {\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 validateImplModules = (leaves: ReadonlyArray<LeafModule>) =>\n Effect.forEach(leaves, validateImpl);\n\nconst generateGroupRegisteredFunctions = (leaves: ReadonlyArray<LeafModule>) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n yield* Effect.forEach(leaves, (leaf) =>\n Effect.gen(function* () {\n const registryRelativePath =\n 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 // Every leaf reaching this point came through\n // `loadAndValidateLeafModules`, which stamps the runtime from the\n // validated spec — so `None` here means that invariant was broken.\n const runtime = yield* Option.match(leaf.runtime, {\n onNone: () =>\n Effect.dieMessage(\n `Runtime for '${leaf.relativePath}' was not resolved before registry generation.`,\n ),\n onSome: Effect.succeed,\n });\n\n const contents = yield* templates.registeredFunctionsForGroup({\n schemaImportPath,\n specImportPath,\n implImportPath,\n layerExportName: leaf.exportName,\n useNode: runtime === \"Node\",\n });\n\n yield* writeFileStringAndLog(registryPath, contents);\n }),\n );\n });\n\nconst removeObsoleteRegisteredFunctions = (leaves: ReadonlyArray<LeafModule>) =>\n Effect.gen(function* () {\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.dieMessage(\n \"_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 specEither = yield* loadGeneratedSpec.pipe(Effect.either);\n\n return Either.match(specEither, {\n onLeft: () => emptyFunctionPaths,\n onRight: (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 = (fileName: string) =>\n Effect.gen(function* () {\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\nconst generateFunctionModules = Effect.gen(function* () {\n const spec = yield* loadGeneratedSpec;\n return yield* generateFunctions(spec);\n});\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\n * stray file and fail with a clear migration message — leaving it in place\n * would silently shadow the codegen-owned `_generated/schema.ts` /\n * `_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\n * are legal — but the warning catches the much more common case of a\n * typoed directory or files placed under the wrong root.\n */\nconst warnIfNoTables = (tableModules: ReadonlyArray<TableModule.TableModule>) =>\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 = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n generatedFilePath: string,\n) =>\n Effect.gen(function* () {\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(tableModules, (tm) =>\n Effect.gen(function* () {\n const wrapperAbsolutePath = path.join(\n confectDirectory,\n generatedTablesDirname,\n `${tm.tableName}.ts`,\n );\n const importPath = yield* toModuleImportPath(\n path.relative(generatedDir, wrapperAbsolutePath),\n );\n return {\n importPath,\n tableName: tm.tableName,\n };\n }),\n );\n });\n\nconst generateIdConstructor = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n Effect.gen(function* () {\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 = tableModules.map((tm) => tm.tableName);\n const contents = yield* templates.id({ tableNames });\n\n yield* writeFileStringAndLog(idPath, contents);\n });\n\nconst generateTableWrappers = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n Effect.gen(function* () {\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 (tm) =>\n Effect.gen(function* () {\n const wrapperPath = path.join(\n confectDirectory,\n generatedTablesDirname,\n `${tm.tableName}.ts`,\n );\n const unnamedAbsolutePath = path.join(\n confectDirectory,\n tm.relativePath,\n );\n const unnamedImportPath = yield* toModuleImportPath(\n path.relative(path.dirname(wrapperPath), unnamedAbsolutePath),\n );\n const contents = yield* templates.tableWrapper({\n tableName: tm.tableName,\n unnamedImportPath,\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\n * has been deleted or renamed. Mirrors `removeObsoleteRegisteredFunctions`\n * for the wrapper directory.\n */\nconst removeObsoleteTableWrappers = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n Effect.gen(function* () {\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(tableModules.map((tm) => `${tm.tableName}.ts`));\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 = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n Effect.gen(function* () {\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({ tableModules: bindings });\n\n yield* writeFileStringAndLog(schemaPath, contents);\n });\n\nconst generateConvexSchema = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n Effect.gen(function* () {\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 });\n\n yield* writeFileStringAndLog(servicesPath, servicesContentsString);\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\nconst logGenerated = (effect: typeof generateHttp) =>\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAM,oBAAoB;AAE1B,MAAM,sBAAsB,OAAO,QAAQ,KAAK,OAAO,SACrD,KAAK,KAAK,mBAAmB,UAAU,CACxC;AACD,MAAM,wBAAwB,OAAO,QAAQ,KAAK,OAAO,SACvD,KAAK,KAAK,mBAAmB,YAAY,CAC1C;AACD,MAAM,+BAA+B,OAAO,QAAQ,KAAK,OAAO,SAC9D,KAAK,KAAK,mBAAmB,kBAAkB,CAChD;AACD,MAAM,oBAAoB,OAAO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;EAClE;AAEF,MAAM,eAAe,OAAO,IAAI,aAAa;CAC3C,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,mBAAmB,OAAO,iBAAiB;CAEjD,MAAM,4BAA4B,KAAK,KAAK,kBAAkB,aAAa;CAC3E,MAAM,WAAW,KAAK,KAAK,2BAA2B,UAAU;CAChE,MAAM,UAAU,KAAK,QAAQ,SAAS;CACtC,MAAM,oBAAoB,OAAO;CAEjC,MAAM,iBAAiB,OAAO,mBAC5B,KAAK,SAAS,SAAS,KAAK,KAAK,kBAAkB,kBAAkB,CAAC,CACvE;AAID,QAAO,sBAAsB,UAFR,OAAOC,KAAe,EAAE,gBAAgB,CAAC,CAEV;EACpD;AAEF,MAAM,gBAAgB,WACpB,OAAO,KACL,OAAO,IACL,OAAO,MAAM;CACX,cAAc,OAAO;CACrB,SAAS,EAAE,QAAQ,qBACjB,MAAM,MAAM,OAAO,CAAC,KAClB,MAAM,KAAK,eAAe,aAAa,eAAe,CAAC,EACvD,MAAM,KAAK,kBAAkB,gBAAgB,eAAe,CAAC,EAC7D,MAAM,KAAK,mBAAmB,OAAO,KAAK,EAC1C,MAAM,WACP;CACJ,CAAC,CACH,CACF"}
|
|
1
|
+
{"version":3,"file":"codegen.mjs","names":["CodegenError.tapAndLog","TableModule.discover","TableModule.validate","templates.assembledSpec","templates.registeredFunctionsForGroup","Bundler.bundle","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"],"sources":["../../src/confect/codegen.ts"],"sourcesContent":["import { Spec, type GroupSpec } from \"@confect/core\";\nimport * as Command from \"@effect/cli/Command\";\nimport * as FileSystem from \"@effect/platform/FileSystem\";\nimport * as Path from \"@effect/platform/Path\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as Either from \"effect/Either\";\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 * as Ref from \"effect/Ref\";\nimport * as Bundler from \"../Bundler\";\nimport * as CodegenError from \"../CodegenError\";\nimport {\n LegacySchemaFileError,\n MissingImplFileError,\n MissingSpecFileError,\n ParentChildNameCollisionError,\n} from \"../CodegenError\";\nimport { ConfectDirectory } from \"../ConfectDirectory\";\nimport { ConvexDirectory } from \"../ConvexDirectory\";\nimport * as DocName from \"../DocName\";\nimport * as FunctionPaths from \"../FunctionPaths\";\nimport {\n discoverLeafImplFiles,\n discoverLeafSpecFiles,\n implPathForSpec,\n registeredFunctionsRelativePath,\n specPathForImpl,\n toLeafModule,\n validateImpl,\n validateSpec,\n type LeafModule,\n} from \"../LeafModule\";\nimport {\n logFileAdded,\n logFileModified,\n logFileRemoved,\n logPending,\n logSuccess,\n logWarn,\n} from \"../log\";\nimport {\n assemblyNodesFromLeaves,\n type SpecAssemblyNode,\n} from \"../SpecAssemblyNode\";\nimport * as TableModule from \"../TableModule\";\nimport * as templates from \"../templates\";\nimport {\n generateAuthConfig,\n generateCrons,\n generateFunctions,\n generateHttp,\n removePathIfExists,\n toModuleImportPath,\n touchConvexSchema,\n writeFileStringAndLog,\n WriteTracker,\n} from \"../utils\";\n\nconst GENERATED_DIRNAME = \"_generated\";\n\nconst GENERATED_SPEC_PATH = Effect.andThen(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"spec.ts\"),\n);\nconst GENERATED_SCHEMA_PATH = Effect.andThen(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"schema.ts\"),\n);\nconst GENERATED_CONVEX_SCHEMA_PATH = Effect.andThen(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"convexSchema.ts\"),\n);\nconst GENERATED_ID_PATH = Effect.andThen(Path.Path, (path) =>\n path.join(GENERATED_DIRNAME, \"id.ts\"),\n);\nconst GENERATED_TABLES_DIRNAME = Effect.andThen(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\", {}, () =>\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.withDescription(\n \"Generate `confect/_generated` files and the contents of the `convex` directory (except `convex.config.ts` and `tsconfig.json`)\",\n ),\n);\n\nexport const codegenHandler = Effect.gen(function* () {\n const tracker = yield* Ref.make(false);\n\n const functionPaths = yield* runCodegen.pipe(\n Effect.provideService(WriteTracker, tracker),\n );\n\n const anyWritesHappened = yield* Ref.get(tracker);\n return { functionPaths, anyWritesHappened };\n});\n\nconst runCodegen = Effect.gen(function* () {\n yield* generateConfectGeneratedDirectory;\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 // 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, groupSpecsByRelativePath } =\n yield* loadAndValidateLeafModules;\n yield* removeLegacyFiles;\n yield* validateNoParentChildNameCollisions(leaves, groupSpecsByRelativePath);\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 removeGeneratedNodeApi,\n generateDocs(tableModules),\n generateServices,\n generateConvexSchema(tableModules),\n ],\n { concurrency: \"unbounded\" },\n );\n yield* validateImplModules(leaves);\n yield* generateGroupRegisteredFunctions(leaves);\n yield* removeObsoleteRegisteredFunctions(leaves);\n const [functionPaths] = yield* Effect.all(\n [\n generateFunctionModules,\n generateConvexSchemaReexport,\n logGenerated(generateHttp),\n logGenerated(generateCrons),\n logGenerated(generateAuthConfig),\n ],\n { concurrency: \"unbounded\" },\n );\n yield* touchConvexSchema;\n return functionPaths;\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 loadAndValidateLeafModules = 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* Effect.forEach(specFiles, (specRelativePath) =>\n Effect.gen(function* () {\n const discovered = yield* toLeafModule(specRelativePath);\n const groupSpec = yield* validateSpec(discovered);\n // Fill in the runtime now that the spec is bundled; discovery left it `None`.\n const leaf = {\n ...discovered,\n runtime: Option.some(groupSpec.runtime),\n };\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, groupSpec };\n }),\n );\n\n yield* validateOrphanImpls(specFiles);\n\n const leaves = Array.map(results, ({ leaf }) => leaf);\n const groupSpecsByRelativePath = new Map(\n Array.map(results, ({ leaf, groupSpec }) => [leaf.relativePath, groupSpec]),\n );\n\n return { leaves, groupSpecsByRelativePath };\n});\n\n/**\n * Walk the assembly tree and fail with a {@link ParentChildNameCollisionError}\n * when a parent leaf declares a function or subgroup whose name matches a\n * sibling subdirectory spec's segment. Without this check the colliding\n * descendant would overwrite the parent's entry in the assembled\n * `GroupSpec.groups` map at runtime, surfacing as a confusing\n * `Refs.make` error rather than a codegen-time diagnostic.\n */\nexport const validateNoParentChildNameCollisions = (\n leaves: ReadonlyArray<LeafModule>,\n groupSpecsByRelativePath: ReadonlyMap<string, GroupSpec.AnyWithProps>,\n) =>\n Effect.gen(function* () {\n // Convex and Node groups share one namespace, so they assemble into a\n // single tree. A Node group nested under a Convex parent (or vice versa) is\n // caught here by the parent/child collision check.\n const nodes = assemblyNodesFromLeaves(leaves);\n yield* Effect.forEach(nodes, (n) =>\n checkAssemblyNodeForCollisions(n, groupSpecsByRelativePath),\n );\n });\n\nconst checkAssemblyNodeForCollisions = (\n node: SpecAssemblyNode,\n groupSpecsByRelativePath: ReadonlyMap<string, GroupSpec.AnyWithProps>,\n): Effect.Effect<void, ParentChildNameCollisionError> =>\n Effect.gen(function* () {\n yield* Option.match(node.importBinding, {\n onNone: () => Effect.void,\n onSome: (binding) =>\n Effect.gen(function* () {\n if (node.children.length === 0) return;\n const parentRelativePath = bindingToRelativeSpecPath(\n binding.importPath,\n );\n const parentGroupSpec =\n groupSpecsByRelativePath.get(parentRelativePath);\n if (parentGroupSpec === undefined) return;\n yield* Effect.forEach(node.children, (child) => {\n if (\n Object.prototype.hasOwnProperty.call(\n parentGroupSpec.functions,\n child.segment,\n )\n ) {\n return Effect.fail(\n new ParentChildNameCollisionError({\n parentSpecPath: parentRelativePath,\n childSpecPath: childRepresentativeSpecPath(child),\n collisionName: child.segment,\n collisionKind: \"function\",\n }),\n );\n }\n if (\n Object.prototype.hasOwnProperty.call(\n parentGroupSpec.groups,\n child.segment,\n )\n ) {\n return Effect.fail(\n new ParentChildNameCollisionError({\n parentSpecPath: parentRelativePath,\n childSpecPath: childRepresentativeSpecPath(child),\n collisionName: child.segment,\n collisionKind: \"group\",\n }),\n );\n }\n return Effect.void;\n });\n }),\n });\n yield* Effect.forEach(node.children, (child) =>\n checkAssemblyNodeForCollisions(child, groupSpecsByRelativePath),\n );\n });\n\n/**\n * `LeafModule.specImportPath` is the import path used from inside the\n * generated `_generated/spec.ts` (e.g. `\"../notes.spec\"`). Strip the\n * `../` prefix and re-add the `.ts` extension to recover the leaf's\n * confect-relative spec path used as the key in\n * `groupSpecsByRelativePath`.\n */\nconst bindingToRelativeSpecPath = (importPath: string): string => {\n const withoutDotDot = importPath.startsWith(\"../\")\n ? importPath.slice(3)\n : importPath;\n return `${withoutDotDot}.ts`;\n};\n\n/**\n * A child assembly node may itself be a parent without a leaf (when the\n * actual leaves live only in deeper subdirectories). In that case we\n * surface the first descendant leaf as a representative path so the\n * error message points at something the user actually wrote.\n */\nconst childRepresentativeSpecPath = (node: SpecAssemblyNode): string => {\n if (Option.isSome(node.importBinding)) {\n return bindingToRelativeSpecPath(node.importBinding.value.importPath);\n }\n for (const child of node.children) {\n return childRepresentativeSpecPath(child);\n }\n return node.segment;\n};\n\nconst validateOrphanImpls = (specFiles: ReadonlyArray<string>) =>\n Effect.gen(function* () {\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 = new Set(specFiles);\n\n yield* Effect.forEach(implFiles, (implRelativePath) =>\n Effect.gen(function* () {\n const specRelativePath = yield* specPathForImpl(implRelativePath);\n if (specPaths.has(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\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(legacyPaths, (relativePath) =>\n Effect.gen(function* () {\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 = (leaves: ReadonlyArray<LeafModule>) =>\n Effect.gen(function* () {\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 validateImplModules = (leaves: ReadonlyArray<LeafModule>) =>\n Effect.forEach(leaves, validateImpl);\n\nconst generateGroupRegisteredFunctions = (leaves: ReadonlyArray<LeafModule>) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n yield* Effect.forEach(leaves, (leaf) =>\n Effect.gen(function* () {\n const registryRelativePath =\n 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 // Every leaf reaching this point came through\n // `loadAndValidateLeafModules`, which stamps the runtime from the\n // validated spec — so `None` here means that invariant was broken.\n const runtime = yield* Option.match(leaf.runtime, {\n onNone: () =>\n Effect.dieMessage(\n `Runtime for '${leaf.relativePath}' was not resolved before registry generation.`,\n ),\n onSome: Effect.succeed,\n });\n\n const contents = yield* templates.registeredFunctionsForGroup({\n schemaImportPath,\n specImportPath,\n implImportPath,\n layerExportName: leaf.exportName,\n useNode: runtime === \"Node\",\n });\n\n yield* writeFileStringAndLog(registryPath, contents);\n }),\n );\n });\n\nconst removeObsoleteRegisteredFunctions = (leaves: ReadonlyArray<LeafModule>) =>\n Effect.gen(function* () {\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.dieMessage(\n \"_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 specEither = yield* loadGeneratedSpec.pipe(Effect.either);\n\n return Either.match(specEither, {\n onLeft: () => emptyFunctionPaths,\n onRight: (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 = (fileName: string) =>\n Effect.gen(function* () {\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\nconst generateFunctionModules = Effect.gen(function* () {\n const spec = yield* loadGeneratedSpec;\n return yield* generateFunctions(spec);\n});\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\n * stray file and fail with a clear migration message — leaving it in place\n * would silently shadow the codegen-owned `_generated/schema.ts` /\n * `_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\n * are legal — but the warning catches the much more common case of a\n * typoed directory or files placed under the wrong root.\n */\nconst warnIfNoTables = (tableModules: ReadonlyArray<TableModule.TableModule>) =>\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 = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n generatedFilePath: string,\n) =>\n Effect.gen(function* () {\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(tableModules, (tableModule) =>\n Effect.gen(function* () {\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 = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n Effect.gen(function* () {\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* templates.id({ tableNames });\n\n yield* writeFileStringAndLog(idPath, contents);\n });\n\nconst generateTableWrappers = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n Effect.gen(function* () {\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 (tableModule) =>\n Effect.gen(function* () {\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 });\n yield* writeFileStringAndLog(wrapperPath, contents);\n }),\n { concurrency: \"unbounded\" },\n );\n });\n\n/**\n * Remove any stale `_generated/tables/*.ts` wrapper whose source table\n * has been deleted or renamed. Mirrors `removeObsoleteRegisteredFunctions`\n * for the wrapper directory.\n */\nconst removeObsoleteTableWrappers = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n Effect.gen(function* () {\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 = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n Effect.gen(function* () {\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({ tableModules: bindings });\n\n yield* writeFileStringAndLog(schemaPath, contents);\n });\n\nconst generateConvexSchema = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n Effect.gen(function* () {\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 });\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 = (\n tableModules: ReadonlyArray<TableModule.TableModule>,\n) =>\n Effect.gen(function* () {\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.isNonEmptyReadonlyArray(collisions)) {\n return yield* new CodegenError.ConflictingDocNameError({ collisions });\n }\n });\n\nconst generateDocs = (tableModules: ReadonlyArray<TableModule.TableModule>) =>\n 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 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\nconst logGenerated = (effect: typeof generateHttp) =>\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,MAAM,oBAAoB;AAE1B,MAAM,sBAAsB,OAAO,QAAQ,KAAK,OAAO,SACrD,KAAK,KAAK,mBAAmB,UAAU,CACxC;AACD,MAAM,wBAAwB,OAAO,QAAQ,KAAK,OAAO,SACvD,KAAK,KAAK,mBAAmB,YAAY,CAC1C;AACD,MAAM,+BAA+B,OAAO,QAAQ,KAAK,OAAO,SAC9D,KAAK,KAAK,mBAAmB,kBAAkB,CAChD;AACD,MAAM,oBAAoB,OAAO,QAAQ,KAAK,OAAO,SACnD,KAAK,KAAK,mBAAmB,QAAQ,CACtC;AACD,MAAM,2BAA2B,OAAO,QAAQ,KAAK,OAAO,SAC1D,KAAK,KAAK,mBAAmB,SAAS,CACvC;AAED,MAAM,eAAe,OAAO,IAAI,aAAa;CAC3C,MAAM,OAAO,OAAO,KAAK;AAEzB,QAAO;EACL;EACA;EACA;EACA;EACA,KAAK,KAAK,mBAAmB,yBAAyB;EACtD,KAAK,KAAK,mBAAmB,6BAA6B;EAC1D,KAAK,KAAK,mBAAmB,UAAU;EACvC,KAAK,KAAK,mBAAmB,cAAc;EAG3C,KAAK,KAAK,mBAAmB,cAAc;EAC5C;EACD;AAEF,MAAa,UAAU,QAAQ,KAAK,WAAW,EAAE,QAC/C,OAAO,IAAI,aAAa;AACtB,QAAO,WAAW,2BAA2B;AAC7C,QAAO,eAAe,KACpB,OAAO,QACP,OAAO,UAAU,WAAW,iCAAiC,CAAC,EAC9DA,UACD;EACD,CACH,CAAC,KACA,QAAQ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3E,MAAM,WAAW,KAAK,KAAK,2BAA2B,UAAU;CAChE,MAAM,sBAAsB,OAAO;CACnC,MAAM,mBAAmB,OAAO,mBAC9B,KAAK,SACH,KAAK,QAAQ,SAAS,EACtB,KAAK,KAAK,kBAAkB,oBAAoB,CACjD,CACF;AAUD,QAAO,sBAAsB,UARF,OAAOC,KAAe;EAC/C;EACA,QAAQ,MAAM,IAAI,eAAe,iBAAiB;GAChD,WAAW,YAAY;GACvB,SAASF,cAAsB,YAAY,UAAU;GACtD,EAAE;EACJ,CAAC,CAEwD;EAC1D;AAEJ,MAAM,eAAe,OAAO,IAAI,aAAa;CAC3C,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,mBAAmB,OAAO,iBAAiB;CAEjD,MAAM,4BAA4B,KAAK,KAAK,kBAAkB,aAAa;CAC3E,MAAM,WAAW,KAAK,KAAK,2BAA2B,UAAU;CAChE,MAAM,UAAU,KAAK,QAAQ,SAAS;CACtC,MAAM,oBAAoB,OAAO;CAEjC,MAAM,iBAAiB,OAAO,mBAC5B,KAAK,SAAS,SAAS,KAAK,KAAK,kBAAkB,kBAAkB,CAAC,CACvE;AAID,QAAO,sBAAsB,UAFR,OAAOG,KAAe,EAAE,gBAAgB,CAAC,CAEV;EACpD;AAEF,MAAM,gBAAgB,WACpB,OAAO,KACL,OAAO,IACL,OAAO,MAAM;CACX,cAAc,OAAO;CACrB,SAAS,EAAE,QAAQ,qBACjB,MAAM,MAAM,OAAO,CAAC,KAClB,MAAM,KAAK,eAAe,aAAa,eAAe,CAAC,EACvD,MAAM,KAAK,kBAAkB,gBAAgB,eAAe,CAAC,EAC7D,MAAM,KAAK,mBAAmB,OAAO,KAAK,EAC1C,MAAM,WACP;CACJ,CAAC,CACH,CACF"}
|
package/dist/confect/dev.mjs
CHANGED
|
@@ -13,12 +13,12 @@ import * as Command from "@effect/cli/Command";
|
|
|
13
13
|
import * as FileSystem from "@effect/platform/FileSystem";
|
|
14
14
|
import * as Path from "@effect/platform/Path";
|
|
15
15
|
import * as Array from "effect/Array";
|
|
16
|
+
import { pipe } from "effect/Function";
|
|
16
17
|
import * as HashSet from "effect/HashSet";
|
|
17
18
|
import * as Match from "effect/Match";
|
|
18
19
|
import * as Option from "effect/Option";
|
|
19
20
|
import * as Ref from "effect/Ref";
|
|
20
21
|
import { externalPlugin, loadTsConfig, tsconfigPathsToRegExp } from "bundle-require";
|
|
21
|
-
import { pipe } from "effect/Function";
|
|
22
22
|
import * as Ansi from "@effect/printer-ansi/Ansi";
|
|
23
23
|
import * as AnsiDoc from "@effect/printer-ansi/AnsiDoc";
|
|
24
24
|
import * as String from "effect/String";
|
package/dist/package.mjs
CHANGED
package/dist/templates.mjs
CHANGED
|
@@ -164,6 +164,33 @@ const refs = ({ specImportPath }) => Effect.gen(function* () {
|
|
|
164
164
|
yield* cbw.writeLine(`export default Refs.make(spec);`);
|
|
165
165
|
return yield* cbw.toString();
|
|
166
166
|
});
|
|
167
|
+
/**
|
|
168
|
+
* Emit `_generated/docs.ts`: one nominal `interface <table>` per table plus a
|
|
169
|
+
* `Docs` registry. Each interface `extends Document.Document<typeof
|
|
170
|
+
* schemaDefinition, "<table>">`, so it stays structurally exact while giving
|
|
171
|
+
* the document a *name* — declaration emit then prints e.g. `NotesDoc` instead
|
|
172
|
+
* of expanding the row structure. The registry is threaded into the generated
|
|
173
|
+
* `DatabaseReader`/`DatabaseWriter` tags so query/mutation helpers print named
|
|
174
|
+
* documents with no user annotations.
|
|
175
|
+
*/
|
|
176
|
+
const docs = ({ schemaImportPath, tables }) => Effect.gen(function* () {
|
|
177
|
+
const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });
|
|
178
|
+
if (tables.length === 0) {
|
|
179
|
+
yield* cbw.writeLine(`export interface Docs {}`);
|
|
180
|
+
return yield* cbw.toString();
|
|
181
|
+
}
|
|
182
|
+
yield* cbw.writeLine(`import type { Document } from "@confect/server";`);
|
|
183
|
+
yield* cbw.writeLine(`import type schemaDefinition from "${schemaImportPath}";`);
|
|
184
|
+
yield* cbw.blankLine();
|
|
185
|
+
for (const { tableName, docName } of tables) yield* cbw.writeLine(`export interface ${docName} extends Document.Document<typeof schemaDefinition, "${tableName}"> {}`);
|
|
186
|
+
yield* cbw.blankLine();
|
|
187
|
+
yield* cbw.writeLine(`export interface Docs {`);
|
|
188
|
+
yield* cbw.indent(Effect.gen(function* () {
|
|
189
|
+
for (const { tableName, docName } of tables) yield* cbw.writeLine(`${tableName}: ${docName};`);
|
|
190
|
+
}));
|
|
191
|
+
yield* cbw.writeLine(`}`);
|
|
192
|
+
return yield* cbw.toString();
|
|
193
|
+
});
|
|
167
194
|
const registeredFunctionsForGroup = ({ schemaImportPath, specImportPath, implImportPath, layerExportName, useNode = false }) => Effect.gen(function* () {
|
|
168
195
|
const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });
|
|
169
196
|
if (useNode) {
|
|
@@ -200,6 +227,7 @@ const services = ({ schemaImportPath }) => Effect.gen(function* () {
|
|
|
200
227
|
}));
|
|
201
228
|
yield* cbw.writeLine(`} from "@confect/server";`);
|
|
202
229
|
yield* cbw.writeLine(`import type schemaDefinition from "${schemaImportPath}";`);
|
|
230
|
+
yield* cbw.writeLine(`import type { Docs } from "./docs";`);
|
|
203
231
|
yield* cbw.blankLine();
|
|
204
232
|
yield* cbw.writeLine("export const Auth = Auth_.Auth;");
|
|
205
233
|
yield* cbw.writeLine("export type Auth = typeof Auth.Identifier;");
|
|
@@ -216,16 +244,25 @@ const services = ({ schemaImportPath }) => Effect.gen(function* () {
|
|
|
216
244
|
yield* cbw.writeLine("export const StorageActionWriter = StorageActionWriter_.StorageActionWriter;");
|
|
217
245
|
yield* cbw.writeLine("export type StorageActionWriter = typeof StorageActionWriter.Identifier;");
|
|
218
246
|
yield* cbw.blankLine();
|
|
219
|
-
yield* cbw.writeLine("export const VectorSearch
|
|
220
|
-
yield* cbw.indent(cbw.writeLine("
|
|
247
|
+
yield* cbw.writeLine("export const VectorSearch: VectorSearch_.VectorSearchTag<");
|
|
248
|
+
yield* cbw.indent(cbw.writeLine("DataModel.FromSchema<typeof schemaDefinition>"));
|
|
249
|
+
yield* cbw.writeLine("> = VectorSearch_.VectorSearch<DataModel.FromSchema<typeof schemaDefinition>>();");
|
|
221
250
|
yield* cbw.writeLine("export type VectorSearch = typeof VectorSearch.Identifier;");
|
|
222
251
|
yield* cbw.blankLine();
|
|
223
|
-
yield* cbw.writeLine("export const DatabaseReader
|
|
224
|
-
yield* cbw.indent(
|
|
252
|
+
yield* cbw.writeLine("export const DatabaseReader: DatabaseReader_.DatabaseReaderTag<");
|
|
253
|
+
yield* cbw.indent(Effect.gen(function* () {
|
|
254
|
+
yield* cbw.writeLine("typeof schemaDefinition,");
|
|
255
|
+
yield* cbw.writeLine("Docs");
|
|
256
|
+
}));
|
|
257
|
+
yield* cbw.writeLine("> = DatabaseReader_.DatabaseReader<typeof schemaDefinition, Docs>();");
|
|
225
258
|
yield* cbw.writeLine("export type DatabaseReader = typeof DatabaseReader.Identifier;");
|
|
226
259
|
yield* cbw.blankLine();
|
|
227
|
-
yield* cbw.writeLine("export const DatabaseWriter
|
|
228
|
-
yield* cbw.indent(
|
|
260
|
+
yield* cbw.writeLine("export const DatabaseWriter: DatabaseWriter_.DatabaseWriterTag<");
|
|
261
|
+
yield* cbw.indent(Effect.gen(function* () {
|
|
262
|
+
yield* cbw.writeLine("typeof schemaDefinition,");
|
|
263
|
+
yield* cbw.writeLine("Docs");
|
|
264
|
+
}));
|
|
265
|
+
yield* cbw.writeLine("> = DatabaseWriter_.DatabaseWriter<typeof schemaDefinition, Docs>();");
|
|
229
266
|
yield* cbw.writeLine("export type DatabaseWriter = typeof DatabaseWriter.Identifier;");
|
|
230
267
|
yield* cbw.blankLine();
|
|
231
268
|
yield* cbw.writeLine("export const QueryRunner = QueryRunner_.QueryRunner;");
|
|
@@ -237,28 +274,25 @@ const services = ({ schemaImportPath }) => Effect.gen(function* () {
|
|
|
237
274
|
yield* cbw.writeLine("export const ActionRunner = ActionRunner_.ActionRunner;");
|
|
238
275
|
yield* cbw.writeLine("export type ActionRunner = typeof ActionRunner.Identifier;");
|
|
239
276
|
yield* cbw.blankLine();
|
|
240
|
-
yield* cbw.writeLine("export const QueryCtx
|
|
241
|
-
yield* cbw.indent(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}));
|
|
277
|
+
yield* cbw.writeLine("export const QueryCtx: QueryCtx_.QueryCtxTag<");
|
|
278
|
+
yield* cbw.indent(cbw.writeLine("DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>"));
|
|
279
|
+
yield* cbw.writeLine("> = QueryCtx_.QueryCtx<");
|
|
280
|
+
yield* cbw.indent(cbw.writeLine("DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>"));
|
|
281
|
+
yield* cbw.writeLine(">();");
|
|
246
282
|
yield* cbw.writeLine("export type QueryCtx = typeof QueryCtx.Identifier;");
|
|
247
283
|
yield* cbw.blankLine();
|
|
248
|
-
yield* cbw.writeLine("export const MutationCtx
|
|
249
|
-
yield* cbw.indent(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}));
|
|
284
|
+
yield* cbw.writeLine("export const MutationCtx: MutationCtx_.MutationCtxTag<");
|
|
285
|
+
yield* cbw.indent(cbw.writeLine("DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>"));
|
|
286
|
+
yield* cbw.writeLine("> = MutationCtx_.MutationCtx<");
|
|
287
|
+
yield* cbw.indent(cbw.writeLine("DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>"));
|
|
288
|
+
yield* cbw.writeLine(">();");
|
|
254
289
|
yield* cbw.writeLine("export type MutationCtx = typeof MutationCtx.Identifier;");
|
|
255
290
|
yield* cbw.blankLine();
|
|
256
|
-
yield* cbw.writeLine("export const ActionCtx
|
|
257
|
-
yield* cbw.indent(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}));
|
|
291
|
+
yield* cbw.writeLine("export const ActionCtx: ActionCtx_.ActionCtxTag<");
|
|
292
|
+
yield* cbw.indent(cbw.writeLine("DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>"));
|
|
293
|
+
yield* cbw.writeLine("> = ActionCtx_.ActionCtx<");
|
|
294
|
+
yield* cbw.indent(cbw.writeLine("DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>"));
|
|
295
|
+
yield* cbw.writeLine(">();");
|
|
262
296
|
yield* cbw.writeLine("export type ActionCtx = typeof ActionCtx.Identifier;");
|
|
263
297
|
return yield* cbw.toString();
|
|
264
298
|
});
|
|
@@ -305,5 +339,5 @@ const assembledSpec = ({ nodes }) => Effect.gen(function* () {
|
|
|
305
339
|
});
|
|
306
340
|
|
|
307
341
|
//#endregion
|
|
308
|
-
export { assembledSpec, authConfig, convexSchema, crons, functions, http, id, refs, registeredFunctionsForGroup, runtimeSchema, schema, services, tableWrapper };
|
|
342
|
+
export { assembledSpec, authConfig, convexSchema, crons, docs, functions, http, id, refs, registeredFunctionsForGroup, runtimeSchema, schema, services, tableWrapper };
|
|
309
343
|
//# sourceMappingURL=templates.mjs.map
|
package/dist/templates.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.mjs","names":[],"sources":["../src/templates.ts"],"sourcesContent":["import * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport { CodeBlockWriter } from \"./CodeBlockWriter\";\nimport {\n collectImportBindings,\n type SpecAssemblyNode,\n} from \"./SpecAssemblyNode\";\n\nexport const functions = ({\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: {\n functionNames: string[];\n registeredFunctionsImportPath: string;\n useNode?: boolean;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n if (useNode) {\n yield* cbw.writeLine(`\"use node\";`);\n yield* cbw.blankLine();\n }\n\n yield* cbw.writeLine(\n `import registeredFunctions from \"${registeredFunctionsImportPath}\";`,\n );\n yield* cbw.newLine();\n yield* Effect.forEach(functionNames, (functionName) =>\n cbw.writeLine(\n `export const ${functionName} = registeredFunctions.${functionName};`,\n ),\n );\n\n return yield* cbw.toString();\n });\n\n/**\n * Emit `convex/schema.ts` as a one-line re-export of the codegen-emitted\n * deploy schema in `confect/_generated/convexSchema.ts`. Deploy-time\n * consumers (the Convex CLI, `convex-test`) keep reading\n * `convex/schema.ts`; the runtime `DatabaseSchema` in\n * `confect/_generated/schema.ts` is untouched by this file.\n */\nexport const schema = ({\n convexSchemaImportPath,\n}: {\n convexSchemaImportPath: string;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `export { default } from \"${convexSchemaImportPath}\";`,\n );\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\n * by impls and the per-group registries (and downstream by per-function\n * bundles for codec lookup). Every table wrapper at\n * `confect/_generated/tables/<name>.ts` is imported statically and\n * registered as a value entry on the `DatabaseSchema.make({...})` call.\n * Per-table laziness lives inside each `Table`: its `Fields`, `Doc`, and\n * `tableDefinition` are lazy memoised getters that only evaluate the\n * user-supplied field-schema callback on first access, so unused tables in\n * a function bundle never pay schema-construction cost despite the\n * 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\n * a 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\n * can ever shadow it.\n */\nexport const runtimeSchema = ({\n tableModules,\n}: {\n tableModules: ReadonlyArray<TableModuleBinding>;\n}) =>\n Effect.gen(function* () {\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 (tableModules.length === 0) {\n yield* cbw.writeLine(`export default $DatabaseSchema.make({});`);\n } else {\n yield* cbw.writeLine(`export default $DatabaseSchema.make({`);\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(`});`);\n }\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 * The file deliberately avoids any `@confect/server` import so that the\n * deploy artifact's import graph stays decoupled from the runtime\n * `DatabaseSchema` machinery.\n *\n * The `defineSchema` import is aliased to `$defineSchema` because each table\n * is imported under its own (filename-derived) name; a table named\n * `defineSchema` 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\n * can ever shadow it.\n */\nexport const convexSchema = ({\n tableModules,\n}: {\n tableModules: ReadonlyArray<TableModuleBinding>;\n}) =>\n Effect.gen(function* () {\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.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(`${tableName}: ${tableName}.tableDefinition,`);\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\n * a `TableNames` union derived from the user's `confect/tables/*.ts`\n * filenames. User-authored table modules import `Id` from this file to\n * declare cross-table id references without typing the destination name as\n * a free string (and without ever importing each other transitively).\n *\n * When the table directory is empty the `TableNames` union resolves to\n * `never`, which still lets the file typecheck against an empty workspace.\n */\nexport const id = ({ tableNames }: { tableNames: ReadonlyArray<string> }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { GenericId } from \"@confect/core\";`);\n yield* cbw.blankLine();\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 const Id = <const TableName extends TableNames>(`,\n );\n yield* cbw.indent(cbw.writeLine(`tableName: TableName,`));\n yield* cbw.writeLine(`) => GenericId.GenericId(tableName);`);\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\n * it, producing the fully-named `Table` value that downstream consumers\n * (schema, specs, impls) read.\n */\nexport const tableWrapper = ({\n tableName,\n unnamedImportPath,\n}: {\n tableName: string;\n unnamedImportPath: string;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import unnamed from \"${unnamedImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default unnamed(\"${tableName}\");`);\n\n return yield* cbw.toString();\n });\n\nexport const http = ({ httpImportPath }: { httpImportPath: string }) =>\n Effect.gen(function* () {\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\nexport const crons = ({ cronsImportPath }: { cronsImportPath: string }) =>\n Effect.gen(function* () {\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 = ({ authImportPath }: { authImportPath: string }) =>\n Effect.gen(function* () {\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\nexport const refs = ({ specImportPath }: { specImportPath: string }) =>\n Effect.gen(function* () {\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(`export default Refs.make(spec);`);\n\n return yield* cbw.toString();\n });\n\nexport const registeredFunctionsForGroup = ({\n schemaImportPath,\n specImportPath,\n implImportPath,\n layerExportName,\n useNode = false,\n}: {\n schemaImportPath: string;\n specImportPath: string;\n implImportPath: string;\n layerExportName: string;\n useNode?: boolean;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n if (useNode) {\n yield* cbw.writeLine(\n `import { RegisteredFunctions } from \"@confect/server\";`,\n );\n yield* cbw.writeLine(\n `import { RegisteredNodeFunction } from \"@confect/server/node\";`,\n );\n } else {\n yield* cbw.writeLine(\n `import { RegisteredConvexFunction, RegisteredFunctions } from \"@confect/server\";`,\n );\n }\n\n yield* cbw.writeLine(`import databaseSchema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import ${layerExportName} 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 const makeFn = useNode\n ? \"RegisteredNodeFunction.make\"\n : \"RegisteredConvexFunction.make\";\n yield* cbw.writeLine(\n `export default RegisteredFunctions.buildForGroup<${specType}>(databaseSchema, ${layerExportName}, ${makeFn});`,\n );\n\n return yield* cbw.toString();\n });\n\nexport const services = ({ schemaImportPath }: { schemaImportPath: string }) =>\n Effect.gen(function* () {\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 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(\"MutationCtx as MutationCtx_,\");\n yield* cbw.writeLine(\"MutationRunner as MutationRunner_,\");\n yield* cbw.writeLine(\"QueryCtx as QueryCtx_,\");\n yield* cbw.writeLine(\"QueryRunner as QueryRunner_,\");\n yield* cbw.writeLine(\"Scheduler as Scheduler_,\");\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(\"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.blankLine();\n\n // Auth\n yield* cbw.writeLine(\"export const Auth = Auth_.Auth;\");\n yield* cbw.writeLine(\"export type Auth = typeof Auth.Identifier;\");\n yield* cbw.blankLine();\n\n // Scheduler\n yield* cbw.writeLine(\"export const Scheduler = Scheduler_.Scheduler;\");\n yield* cbw.writeLine(\n \"export type Scheduler = typeof Scheduler.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageReader\n yield* cbw.writeLine(\n \"export const StorageReader = StorageReader_.StorageReader;\",\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;\",\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;\",\n );\n yield* cbw.writeLine(\n \"export type StorageActionWriter = typeof StorageActionWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // VectorSearch\n yield* cbw.writeLine(\"export const VectorSearch =\");\n yield* cbw.indent(\n cbw.writeLine(\n \"VectorSearch_.VectorSearch<DataModel.FromSchema<typeof schemaDefinition>>();\",\n ),\n );\n yield* cbw.writeLine(\n \"export type VectorSearch = typeof VectorSearch.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseReader\n yield* cbw.writeLine(\"export const DatabaseReader =\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DatabaseReader_.DatabaseReader<typeof schemaDefinition>();\",\n ),\n );\n yield* cbw.writeLine(\n \"export type DatabaseReader = typeof DatabaseReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseWriter\n yield* cbw.writeLine(\"export const DatabaseWriter =\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DatabaseWriter_.DatabaseWriter<typeof schemaDefinition>();\",\n ),\n );\n yield* cbw.writeLine(\n \"export type DatabaseWriter = typeof DatabaseWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryRunner\n yield* cbw.writeLine(\n \"export const QueryRunner = QueryRunner_.QueryRunner;\",\n );\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 =\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"QueryCtx_.QueryCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>\",\n ),\n );\n yield* cbw.writeLine(\">();\");\n }),\n );\n yield* cbw.writeLine(\"export type QueryCtx = typeof QueryCtx.Identifier;\");\n yield* cbw.blankLine();\n\n // MutationCtx\n yield* cbw.writeLine(\"export const MutationCtx =\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"MutationCtx_.MutationCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>\",\n ),\n );\n yield* cbw.writeLine(\">();\");\n }),\n );\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 =\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"ActionCtx_.ActionCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>\",\n ),\n );\n yield* cbw.writeLine(\">();\");\n }),\n );\n yield* cbw.writeLine(\n \"export type ActionCtx = typeof ActionCtx.Identifier;\",\n );\n\n return yield* cbw.toString();\n });\n\nconst writeChildAddGroupAt = (\n cbw: CodeBlockWriter,\n child: SpecAssemblyNode,\n groupFactory: string,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n yield* cbw.write(\".addGroupAt(\");\n yield* cbw.quote(child.segment);\n yield* cbw.write(\", \");\n yield* writeGroupAssembly(cbw, child, groupFactory);\n yield* cbw.write(\")\");\n });\n\nconst writeGroupFactoryCall = (\n cbw: CodeBlockWriter,\n node: SpecAssemblyNode,\n groupFactory: string,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n yield* cbw.write(groupFactory);\n yield* cbw.write(\"(\");\n yield* cbw.quote(node.segment);\n yield* cbw.write(\")\");\n\n yield* Effect.forEach(node.children, (child) =>\n writeChildAddGroupAt(cbw, child, groupFactory),\n );\n });\n\nconst writeGroupAssembly: (\n cbw: CodeBlockWriter,\n node: SpecAssemblyNode,\n groupFactory: string,\n) => Effect.Effect<void> = (cbw, node, groupFactory) =>\n Option.match(node.importBinding, {\n onNone: () => writeGroupFactoryCall(cbw, node, groupFactory),\n onSome: (binding) =>\n Effect.gen(function* () {\n yield* cbw.write(binding.localName);\n yield* Effect.forEach(node.children, (child) =>\n writeChildAddGroupAt(cbw, child, groupFactory),\n );\n }),\n });\n\nconst writeRootAddAt = (\n cbw: CodeBlockWriter,\n node: SpecAssemblyNode,\n groupFactory: string,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n yield* cbw.write(\".addAt(\");\n yield* cbw.quote(node.segment);\n yield* cbw.write(\", \");\n\n yield* writeGroupAssembly(cbw, node, groupFactory);\n\n yield* cbw.write(\")\");\n });\n\nexport const assembledSpec = ({\n nodes,\n}: {\n nodes: ReadonlyArray<SpecAssemblyNode>;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n const nodeRequiresGroupFactory = (node: SpecAssemblyNode): boolean =>\n Option.isNone(node.importBinding) ||\n Array.some(node.children, nodeRequiresGroupFactory);\n\n const needsGroupSpec = Array.some(nodes, nodeRequiresGroupFactory);\n yield* cbw.writeLine(\n needsGroupSpec\n ? `import { GroupSpec, Spec } from \"@confect/core\";`\n : `import { Spec } from \"@confect/core\";`,\n );\n\n yield* Effect.forEach(collectImportBindings(nodes), (binding) =>\n cbw.writeLine(\n `import ${binding.localName} from \"${binding.importPath}\";`,\n ),\n );\n\n yield* cbw.blankLine();\n\n // The assembled spec is runtime-agnostic: a Node group's `makeNode()` is\n // already baked into its imported leaf spec, so the root is always\n // `Spec.make()` and binding-less container groups always use\n // `GroupSpec.makeAt` (containers register no functions and carry no runtime).\n yield* cbw.write(`export default Spec.make()`);\n yield* Effect.forEach(nodes, (node) =>\n writeRootAddAt(cbw, node, \"GroupSpec.makeAt\"),\n );\n yield* cbw.write(\";\");\n yield* cbw.newLine();\n\n return yield* cbw.toString();\n });\n"],"mappings":";;;;;;;AASA,MAAa,aAAa,EACxB,eACA,+BACA,UAAU,YAMV,OAAO,IAAI,aAAa;CACtB,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,GAAG,CAAC;AAE5D,KAAI,SAAS;AACX,SAAO,IAAI,UAAU,cAAc;AACnC,SAAO,IAAI,WAAW;;AAGxB,QAAO,IAAI,UACT,oCAAoC,8BAA8B,IACnE;AACD,QAAO,IAAI,SAAS;AACpB,QAAO,OAAO,QAAQ,gBAAgB,iBACpC,IAAI,UACF,gBAAgB,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;AAC9B,QAAO,IAAI,MAAM,KAAK;AAEtB,QAAO,mBAAmB,KAAK,MAAM,aAAa;AAElD,QAAO,IAAI,MAAM,IAAI;EACrB;AAEJ,MAAa,iBAAiB,EAC5B,YAIA,OAAO,IAAI,aAAa;CACtB,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,GAAG,CAAC;CAE5D,MAAM,4BAA4B,SAChC,OAAO,OAAO,KAAK,cAAc,IACjC,MAAM,KAAK,KAAK,UAAU,yBAAyB;CAErD,MAAM,iBAAiB,MAAM,KAAK,OAAO,yBAAyB;AAClE,QAAO,IAAI,UACT,iBACI,qDACA,wCACL;AAED,QAAO,OAAO,QAAQ,sBAAsB,MAAM,GAAG,YACnD,IAAI,UACF,UAAU,QAAQ,UAAU,SAAS,QAAQ,WAAW,IACzD,CACF;AAED,QAAO,IAAI,WAAW;AAMtB,QAAO,IAAI,MAAM,6BAA6B;AAC9C,QAAO,OAAO,QAAQ,QAAQ,SAC5B,eAAe,KAAK,MAAM,mBAAmB,CAC9C;AACD,QAAO,IAAI,MAAM,IAAI;AACrB,QAAO,IAAI,SAAS;AAEpB,QAAO,OAAO,IAAI,UAAU;EAC5B"}
|
|
1
|
+
{"version":3,"file":"templates.mjs","names":[],"sources":["../src/templates.ts"],"sourcesContent":["import * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport { CodeBlockWriter } from \"./CodeBlockWriter\";\nimport {\n collectImportBindings,\n type SpecAssemblyNode,\n} from \"./SpecAssemblyNode\";\n\nexport const functions = ({\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: {\n functionNames: string[];\n registeredFunctionsImportPath: string;\n useNode?: boolean;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n if (useNode) {\n yield* cbw.writeLine(`\"use node\";`);\n yield* cbw.blankLine();\n }\n\n yield* cbw.writeLine(\n `import registeredFunctions from \"${registeredFunctionsImportPath}\";`,\n );\n yield* cbw.newLine();\n yield* Effect.forEach(functionNames, (functionName) =>\n cbw.writeLine(\n `export const ${functionName} = registeredFunctions.${functionName};`,\n ),\n );\n\n return yield* cbw.toString();\n });\n\n/**\n * Emit `convex/schema.ts` as a one-line re-export of the codegen-emitted\n * deploy schema in `confect/_generated/convexSchema.ts`. Deploy-time\n * consumers (the Convex CLI, `convex-test`) keep reading\n * `convex/schema.ts`; the runtime `DatabaseSchema` in\n * `confect/_generated/schema.ts` is untouched by this file.\n */\nexport const schema = ({\n convexSchemaImportPath,\n}: {\n convexSchemaImportPath: string;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `export { default } from \"${convexSchemaImportPath}\";`,\n );\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\n * by impls and the per-group registries (and downstream by per-function\n * bundles for codec lookup). Every table wrapper at\n * `confect/_generated/tables/<name>.ts` is imported statically and\n * registered as a value entry on the `DatabaseSchema.make({...})` call.\n * Per-table laziness lives inside each `Table`: its `Fields`, `Doc`, and\n * `tableDefinition` are lazy memoised getters that only evaluate the\n * user-supplied field-schema callback on first access, so unused tables in\n * a function bundle never pay schema-construction cost despite the\n * 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\n * a 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\n * can ever shadow it.\n */\nexport const runtimeSchema = ({\n tableModules,\n}: {\n tableModules: ReadonlyArray<TableModuleBinding>;\n}) =>\n Effect.gen(function* () {\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 (tableModules.length === 0) {\n yield* cbw.writeLine(`export default $DatabaseSchema.make({});`);\n } else {\n yield* cbw.writeLine(`export default $DatabaseSchema.make({`);\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(`});`);\n }\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 * The file deliberately avoids any `@confect/server` import so that the\n * deploy artifact's import graph stays decoupled from the runtime\n * `DatabaseSchema` machinery.\n *\n * The `defineSchema` import is aliased to `$defineSchema` because each table\n * is imported under its own (filename-derived) name; a table named\n * `defineSchema` 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\n * can ever shadow it.\n */\nexport const convexSchema = ({\n tableModules,\n}: {\n tableModules: ReadonlyArray<TableModuleBinding>;\n}) =>\n Effect.gen(function* () {\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.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(`${tableName}: ${tableName}.tableDefinition,`);\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\n * a `TableNames` union derived from the user's `confect/tables/*.ts`\n * filenames. User-authored table modules import `Id` from this file to\n * declare cross-table id references without typing the destination name as\n * a free string (and without ever importing each other transitively).\n *\n * When the table directory is empty the `TableNames` union resolves to\n * `never`, which still lets the file typecheck against an empty workspace.\n */\nexport const id = ({ tableNames }: { tableNames: ReadonlyArray<string> }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { GenericId } from \"@confect/core\";`);\n yield* cbw.blankLine();\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 const Id = <const TableName extends TableNames>(`,\n );\n yield* cbw.indent(cbw.writeLine(`tableName: TableName,`));\n yield* cbw.writeLine(`) => GenericId.GenericId(tableName);`);\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\n * it, producing the fully-named `Table` value that downstream consumers\n * (schema, specs, impls) read.\n */\nexport const tableWrapper = ({\n tableName,\n unnamedImportPath,\n}: {\n tableName: string;\n unnamedImportPath: string;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import unnamed from \"${unnamedImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default unnamed(\"${tableName}\");`);\n\n return yield* cbw.toString();\n });\n\nexport const http = ({ httpImportPath }: { httpImportPath: string }) =>\n Effect.gen(function* () {\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\nexport const crons = ({ cronsImportPath }: { cronsImportPath: string }) =>\n Effect.gen(function* () {\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 = ({ authImportPath }: { authImportPath: string }) =>\n Effect.gen(function* () {\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\nexport const refs = ({ specImportPath }: { specImportPath: string }) =>\n Effect.gen(function* () {\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(`export default Refs.make(spec);`);\n\n return yield* cbw.toString();\n });\n\n/**\n * Emit `_generated/docs.ts`: one nominal `interface <table>` per table plus a\n * `Docs` registry. Each interface `extends Document.Document<typeof\n * schemaDefinition, \"<table>\">`, so it stays structurally exact while giving\n * the document a *name* — declaration emit then prints e.g. `NotesDoc` instead\n * of expanding the row structure. The registry is threaded into the generated\n * `DatabaseReader`/`DatabaseWriter` tags so query/mutation helpers print named\n * documents with no user annotations.\n */\nexport const docs = ({\n schemaImportPath,\n tables,\n}: {\n schemaImportPath: string;\n tables: ReadonlyArray<{ tableName: string; docName: string }>;\n}) =>\n Effect.gen(function* () {\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 interface ${docName} extends 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 schemaImportPath,\n specImportPath,\n implImportPath,\n layerExportName,\n useNode = false,\n}: {\n schemaImportPath: string;\n specImportPath: string;\n implImportPath: string;\n layerExportName: string;\n useNode?: boolean;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n if (useNode) {\n yield* cbw.writeLine(\n `import { RegisteredFunctions } from \"@confect/server\";`,\n );\n yield* cbw.writeLine(\n `import { RegisteredNodeFunction } from \"@confect/server/node\";`,\n );\n } else {\n yield* cbw.writeLine(\n `import { RegisteredConvexFunction, RegisteredFunctions } from \"@confect/server\";`,\n );\n }\n\n yield* cbw.writeLine(`import databaseSchema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import ${layerExportName} 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 const makeFn = useNode\n ? \"RegisteredNodeFunction.make\"\n : \"RegisteredConvexFunction.make\";\n yield* cbw.writeLine(\n `export default RegisteredFunctions.buildForGroup<${specType}>(databaseSchema, ${layerExportName}, ${makeFn});`,\n );\n\n return yield* cbw.toString();\n });\n\nexport const services = ({ schemaImportPath }: { schemaImportPath: string }) =>\n Effect.gen(function* () {\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 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(\"MutationCtx as MutationCtx_,\");\n yield* cbw.writeLine(\"MutationRunner as MutationRunner_,\");\n yield* cbw.writeLine(\"QueryCtx as QueryCtx_,\");\n yield* cbw.writeLine(\"QueryRunner as QueryRunner_,\");\n yield* cbw.writeLine(\"Scheduler as Scheduler_,\");\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(\"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 yield* cbw.blankLine();\n\n // Auth\n yield* cbw.writeLine(\"export const Auth = Auth_.Auth;\");\n yield* cbw.writeLine(\"export type Auth = typeof Auth.Identifier;\");\n yield* cbw.blankLine();\n\n // Scheduler\n yield* cbw.writeLine(\"export const Scheduler = Scheduler_.Scheduler;\");\n yield* cbw.writeLine(\n \"export type Scheduler = typeof Scheduler.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageReader\n yield* cbw.writeLine(\n \"export const StorageReader = StorageReader_.StorageReader;\",\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;\",\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;\",\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 // QueryRunner\n yield* cbw.writeLine(\n \"export const QueryRunner = QueryRunner_.QueryRunner;\",\n );\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>>\",\n ),\n );\n yield* cbw.writeLine(\"> = QueryCtx_.QueryCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>\",\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>>\",\n ),\n );\n yield* cbw.writeLine(\"> = MutationCtx_.MutationCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>\",\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>>\",\n ),\n );\n yield* cbw.writeLine(\"> = ActionCtx_.ActionCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>\",\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\n \"export type ActionCtx = typeof ActionCtx.Identifier;\",\n );\n\n return yield* cbw.toString();\n });\n\nconst writeChildAddGroupAt = (\n cbw: CodeBlockWriter,\n child: SpecAssemblyNode,\n groupFactory: string,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n yield* cbw.write(\".addGroupAt(\");\n yield* cbw.quote(child.segment);\n yield* cbw.write(\", \");\n yield* writeGroupAssembly(cbw, child, groupFactory);\n yield* cbw.write(\")\");\n });\n\nconst writeGroupFactoryCall = (\n cbw: CodeBlockWriter,\n node: SpecAssemblyNode,\n groupFactory: string,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n yield* cbw.write(groupFactory);\n yield* cbw.write(\"(\");\n yield* cbw.quote(node.segment);\n yield* cbw.write(\")\");\n\n yield* Effect.forEach(node.children, (child) =>\n writeChildAddGroupAt(cbw, child, groupFactory),\n );\n });\n\nconst writeGroupAssembly: (\n cbw: CodeBlockWriter,\n node: SpecAssemblyNode,\n groupFactory: string,\n) => Effect.Effect<void> = (cbw, node, groupFactory) =>\n Option.match(node.importBinding, {\n onNone: () => writeGroupFactoryCall(cbw, node, groupFactory),\n onSome: (binding) =>\n Effect.gen(function* () {\n yield* cbw.write(binding.localName);\n yield* Effect.forEach(node.children, (child) =>\n writeChildAddGroupAt(cbw, child, groupFactory),\n );\n }),\n });\n\nconst writeRootAddAt = (\n cbw: CodeBlockWriter,\n node: SpecAssemblyNode,\n groupFactory: string,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n yield* cbw.write(\".addAt(\");\n yield* cbw.quote(node.segment);\n yield* cbw.write(\", \");\n\n yield* writeGroupAssembly(cbw, node, groupFactory);\n\n yield* cbw.write(\")\");\n });\n\nexport const assembledSpec = ({\n nodes,\n}: {\n nodes: ReadonlyArray<SpecAssemblyNode>;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n const nodeRequiresGroupFactory = (node: SpecAssemblyNode): boolean =>\n Option.isNone(node.importBinding) ||\n Array.some(node.children, nodeRequiresGroupFactory);\n\n const needsGroupSpec = Array.some(nodes, nodeRequiresGroupFactory);\n yield* cbw.writeLine(\n needsGroupSpec\n ? `import { GroupSpec, Spec } from \"@confect/core\";`\n : `import { Spec } from \"@confect/core\";`,\n );\n\n yield* Effect.forEach(collectImportBindings(nodes), (binding) =>\n cbw.writeLine(\n `import ${binding.localName} from \"${binding.importPath}\";`,\n ),\n );\n\n yield* cbw.blankLine();\n\n // The assembled spec is runtime-agnostic: a Node group's `makeNode()` is\n // already baked into its imported leaf spec, so the root is always\n // `Spec.make()` and binding-less container groups always use\n // `GroupSpec.makeAt` (containers register no functions and carry no runtime).\n yield* cbw.write(`export default Spec.make()`);\n yield* Effect.forEach(nodes, (node) =>\n writeRootAddAt(cbw, node, \"GroupSpec.makeAt\"),\n );\n yield* cbw.write(\";\");\n yield* cbw.newLine();\n\n return yield* cbw.toString();\n });\n"],"mappings":";;;;;;;AASA,MAAa,aAAa,EACxB,eACA,+BACA,UAAU,YAMV,OAAO,IAAI,aAAa;CACtB,MAAM,MAAM,IAAI,gBAAgB,EA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MAAM,IAAI;EACrB;AAEJ,MAAa,iBAAiB,EAC5B,YAIA,OAAO,IAAI,aAAa;CACtB,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,GAAG,CAAC;CAE5D,MAAM,4BAA4B,SAChC,OAAO,OAAO,KAAK,cAAc,IACjC,MAAM,KAAK,KAAK,UAAU,yBAAyB;CAErD,MAAM,iBAAiB,MAAM,KAAK,OAAO,yBAAyB;AAClE,QAAO,IAAI,UACT,iBACI,qDACA,wCACL;AAED,QAAO,OAAO,QAAQ,sBAAsB,MAAM,GAAG,YACnD,IAAI,UACF,UAAU,QAAQ,UAAU,SAAS,QAAQ,WAAW,IACzD,CACF;AAED,QAAO,IAAI,WAAW;AAMtB,QAAO,IAAI,MAAM,6BAA6B;AAC9C,QAAO,OAAO,QAAQ,QAAQ,SAC5B,eAAe,KAAK,MAAM,mBAAmB,CAC9C;AACD,QAAO,IAAI,MAAM,IAAI;AACrB,QAAO,IAAI,SAAS;AAEpB,QAAO,OAAO,IAAI,UAAU;EAC5B"}
|
package/dist/utils.mjs
CHANGED
|
@@ -9,12 +9,12 @@ import * as Effect from "effect/Effect";
|
|
|
9
9
|
import * as FileSystem from "@effect/platform/FileSystem";
|
|
10
10
|
import * as Path from "@effect/platform/Path";
|
|
11
11
|
import * as Array from "effect/Array";
|
|
12
|
+
import { pipe } from "effect/Function";
|
|
12
13
|
import * as HashSet from "effect/HashSet";
|
|
13
14
|
import * as Option from "effect/Option";
|
|
15
|
+
import * as Record from "effect/Record";
|
|
14
16
|
import * as Ref from "effect/Ref";
|
|
15
|
-
import { pipe } from "effect/Function";
|
|
16
17
|
import * as String from "effect/String";
|
|
17
|
-
import * as Record from "effect/Record";
|
|
18
18
|
import * as Context from "effect/Context";
|
|
19
19
|
import * as Order from "effect/Order";
|
|
20
20
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@confect/cli",
|
|
3
3
|
"description": "Developer tooling for codegen and sync",
|
|
4
|
-
"version": "9.0
|
|
4
|
+
"version": "9.1.0",
|
|
5
5
|
"author": "RJ Dellecese",
|
|
6
6
|
"bin": {
|
|
7
7
|
"confect": "./dist/index.mjs"
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"license": "ISC",
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"effect": "^3.21.2",
|
|
56
|
-
"@confect/core": "^9.0
|
|
57
|
-
"@confect/server": "^9.0
|
|
56
|
+
"@confect/core": "^9.1.0",
|
|
57
|
+
"@confect/server": "^9.1.0"
|
|
58
58
|
},
|
|
59
59
|
"repository": {
|
|
60
60
|
"type": "git",
|