@gaganref/confect-cli 10.3.1-fork.39 → 10.3.1-fork.40

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.
@@ -66,10 +66,18 @@ const assertOwnedEntrypoints = Effect.gen(function* () {
66
66
  const confect = yield* ConfectDirectory.get;
67
67
  const projectRoot = yield* ProjectRoot.get;
68
68
  const importFromConvex = (file) => toModuleImportPath(path.relative(convex, path.join(confect, file)));
69
- const optional = /* @__PURE__ */ new Map([["http.ts", [yield* http({ httpImportPath: yield* importFromConvex("http.ts") }), yield* declaredHttp({
70
- schemaImportPath: yield* importFromConvex("_generated/schema.ts"),
71
- httpImportPath: yield* importFromConvex("http.ts")
72
- })]], ["crons.ts", [yield* crons({ cronsImportPath: yield* importFromConvex("crons.ts") })]]]);
69
+ const optional = /* @__PURE__ */ new Map([["http.ts", [
70
+ yield* http({ httpImportPath: yield* importFromConvex("http.ts") }),
71
+ yield* declaredHttp({
72
+ schemaImportPath: yield* importFromConvex("_generated/schema.ts"),
73
+ httpImportPath: yield* importFromConvex("http.ts")
74
+ }),
75
+ yield* declaredHttp({
76
+ schemaImportPath: yield* importFromConvex("_generated/schema.ts"),
77
+ httpImportPath: yield* importFromConvex("http.ts"),
78
+ runtimeImportPath: yield* importFromConvex("runtime.ts")
79
+ })
80
+ ]], ["crons.ts", [yield* crons({ cronsImportPath: yield* importFromConvex("crons.ts") })]]]);
73
81
  const refused = [];
74
82
  for (const relative of yield* getEntrypoints) {
75
83
  const absolute = path.join(convex, relative);
@@ -118,20 +126,20 @@ const generateGroupModuleEffect = Effect.fnUntraced(function* ({ groupPath, func
118
126
  const path = yield* Path.Path;
119
127
  const convexDirectory = yield* ConvexDirectory.get;
120
128
  const relativeModulePath = yield* modulePath(groupPath);
121
- const modulePath$3 = path.join(convexDirectory, relativeModulePath);
122
- const directoryPath = path.dirname(modulePath$3);
129
+ const modulePath$2 = path.join(convexDirectory, relativeModulePath);
130
+ const directoryPath = path.dirname(modulePath$2);
123
131
  if (!(yield* fs.exists(directoryPath))) yield* fs.makeDirectory(directoryPath, { recursive: true });
124
132
  const functionsContentsString = yield* render({
125
133
  functionNames,
126
134
  registeredFunctionsImportPath,
127
135
  useNode
128
136
  });
129
- if (!(yield* fs.exists(modulePath$3))) {
130
- yield* fs.writeFileString(modulePath$3, functionsContentsString);
137
+ if (!(yield* fs.exists(modulePath$2))) {
138
+ yield* fs.writeFileString(modulePath$2, functionsContentsString);
131
139
  return "Added";
132
140
  }
133
- if ((yield* fs.readFileString(modulePath$3)) !== functionsContentsString) {
134
- yield* fs.writeFileString(modulePath$3, functionsContentsString);
141
+ if ((yield* fs.readFileString(modulePath$2)) !== functionsContentsString) {
142
+ yield* fs.writeFileString(modulePath$2, functionsContentsString);
135
143
  return "Modified";
136
144
  }
137
145
  return "Unchanged";
@@ -179,9 +187,9 @@ const removeGroups = Effect.fnUntraced(function* (groupPaths) {
179
187
  const convexDirectory = yield* ConvexDirectory.get;
180
188
  yield* Effect.all(HashSet.map(groupPaths, (groupPath) => Effect.gen(function* () {
181
189
  const relativeModulePath = yield* modulePath(groupPath);
182
- const modulePath$2 = path.join(convexDirectory, relativeModulePath);
190
+ const modulePath$1 = path.join(convexDirectory, relativeModulePath);
183
191
  yield* Effect.logDebug(`Removing group '${relativeModulePath}'...`);
184
- yield* removePathIfExists(modulePath$2);
192
+ yield* removePathIfExists(modulePath$1);
185
193
  yield* Effect.logDebug(`Group '${relativeModulePath}' removed`);
186
194
  })), { concurrency: "unbounded" });
187
195
  });
@@ -189,15 +197,15 @@ const writeGroups = (groups) => Effect.forEach(groups, Effect.fnUntraced(functio
189
197
  const path = yield* Path.Path;
190
198
  const convexDirectory = yield* ConvexDirectory.get;
191
199
  const relativeModulePath = yield* modulePath(group.path);
192
- const modulePath$1 = path.join(convexDirectory, relativeModulePath);
193
- const registeredFunctionsImportPath = yield* registeredFunctionsImportPathForGroup(group.path, modulePath$1);
200
+ const modulePath$3 = path.join(convexDirectory, relativeModulePath);
201
+ const registeredFunctionsImportPath = yield* registeredFunctionsImportPathForGroup(group.path, modulePath$3);
194
202
  const change = yield* generateGroupModule({
195
203
  groupPath: group.path,
196
204
  functionNames: group.functionNames,
197
205
  registeredFunctionsImportPath,
198
206
  useNode: group.runtime === "Node"
199
207
  });
200
- yield* Match.value(change).pipe(Match.when("Added", () => logFileAdded(modulePath$1)), Match.when("Modified", () => logFileModified(modulePath$1)), Match.when("Unchanged", () => Effect.void), Match.exhaustive);
208
+ yield* Match.value(change).pipe(Match.when("Added", () => logFileAdded(modulePath$3)), Match.when("Modified", () => logFileModified(modulePath$3)), Match.when("Unchanged", () => Effect.void), Match.exhaustive);
201
209
  }));
202
210
  //#endregion
203
211
  export { applyFunctionPlan, assertOwnedEntrypoints, generateFunctions, generateGroupModule, registeredFunctionsImportPathForGroup, removeGroups, render, writeGroups };
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionModule.mjs","names":["templates.http","templates.declaredHttp","templates.crons","GroupPath.fromGroupModulePath","GroupPath.modulePath","modulePath","GenerationSnapshot.plan","GenerationSnapshot.functionPaths"],"sources":["../src/FunctionModule.ts"],"sourcesContent":["import * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Match from \"effect/Match\";\nimport { UnownedConvexEntrypointError } from \"./CodegenError.js\";\nimport * as templates from \"./templates.js\";\nimport * as GenerationSnapshot from \"./GenerationSnapshot.js\";\nimport * as GroupPath from \"./GroupPath.js\";\nimport * as GroupPaths from \"./GroupPaths.js\";\nimport { CodeBlockWriter } from \"./CodeBlockWriter.js\";\nimport { logFileAdded, logFileModified, logFileRemoved } from \"./log.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\nimport { ConvexDirectory } from \"./ConvexDirectory.js\";\nimport {\n removePathIfExists,\n toModuleImportPath,\n toPosixPath,\n} from \"./utils.js\";\nimport { ProjectRoot } from \"./ProjectRoot.js\";\n\nconst RESERVED_CONVEX_TS_FILE_NAMES = new Set([\n \"schema.ts\",\n \"http.ts\",\n \"crons.ts\",\n \"auth.config.ts\",\n \"convex.config.ts\",\n]);\n\n// Keep ownership and removal aligned with Convex's bundler entryPoints filter.\nconst getEntrypoints = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convex = yield* ConvexDirectory.get;\n const files = yield* fs.readDirectory(convex, { recursive: true });\n const components = files\n .filter(\n (file) =>\n path.basename(file) === \"convex.config.ts\" &&\n path.dirname(file) !== \".\",\n )\n .map((file) => path.dirname(file) + path.sep);\n return files.filter((file) => {\n const base = path.basename(file);\n return (\n !file.startsWith(\"_generated\" + path.sep) &&\n !components.some((component) => file.startsWith(component)) &&\n /\\.(?:js|mjs|cjs|ts|tsx|mts|cts|jsx)$/.test(base) &&\n !base.startsWith(\".\") &&\n !base.startsWith(\"#\") &&\n (base.match(/\\./g)?.length ?? 0) === 1 &&\n base !== \"schema.ts\" &&\n base !== \"schema.js\" &&\n !file.includes(\" \")\n );\n });\n});\n\nconst tokenize = (\n source: string,\n modulePath: string,\n path: Path.Path,\n): string[] | undefined => {\n const token =\n /\\s+|\\/\\/[^\\r\\n]*|\\/\\*[\\s\\S]*?\\*\\/|\"(?:\\\\.|[^\"\\\\\\r\\n])*\"|'(?:\\\\.|[^'\\\\\\r\\n])*'|[$A-Z_a-z][$\\w]*|[{}()[\\].,:;=]/y;\n const tokens: string[] = [];\n while (token.lastIndex < source.length) {\n const match = token.exec(source);\n if (match === null) return undefined;\n const value = match[0];\n if (/^\\s|^\\//.test(value)) continue;\n if (value.startsWith('\"') || value.startsWith(\"'\")) {\n const literal = value.slice(1, -1);\n tokens.push(\n JSON.stringify(\n literal.startsWith(\".\")\n ? path.resolve(\n path.dirname(modulePath),\n literal.replace(/\\.js$/, \"\"),\n )\n : literal,\n ),\n );\n } else tokens.push(value);\n }\n return tokens;\n};\n\nconst matchesShape = (\n actual: readonly string[],\n expected: readonly string[],\n) => {\n let index = 0;\n for (const token of expected) {\n if (token === \";\" && actual[index] !== \";\") continue;\n if (actual[index] === \",\" && (token === \"}\" || token === \")\")) index++;\n if (actual[index++] !== token) return false;\n }\n return index === actual.length;\n};\n\nexport const assertOwnedEntrypoints = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convex = yield* ConvexDirectory.get;\n const confect = yield* ConfectDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n const importFromConvex = (file: string) =>\n toModuleImportPath(path.relative(convex, path.join(confect, file)));\n const optional = new Map([\n [\n \"http.ts\",\n [\n yield* templates.http({\n httpImportPath: yield* importFromConvex(\"http.ts\"),\n }),\n yield* templates.declaredHttp({\n schemaImportPath: yield* importFromConvex(\"_generated/schema.ts\"),\n httpImportPath: yield* importFromConvex(\"http.ts\"),\n }),\n ],\n ],\n [\n \"crons.ts\",\n [\n yield* templates.crons({\n cronsImportPath: yield* importFromConvex(\"crons.ts\"),\n }),\n ],\n ],\n ]);\n const refused: string[] = [];\n for (const relative of yield* getEntrypoints) {\n const absolute = path.join(convex, relative);\n const tokens = tokenize(yield* fs.readFileString(absolute), absolute, path);\n if (tokens !== undefined) {\n if (\n optional\n .get(relative)\n ?.some((template) =>\n matchesShape(tokens, tokenize(template, absolute, path)!),\n )\n )\n continue;\n if (path.extname(relative) === \".ts\") {\n const names = tokens.flatMap((token, index) =>\n token === \"export\" && tokens[index + 1] === \"const\"\n ? [tokens[index + 2]!]\n : [],\n );\n const group = yield* GroupPath.fromGroupModulePath(relative);\n const template = yield* render({\n functionNames: names,\n registeredFunctionsImportPath:\n yield* registeredFunctionsImportPathForGroup(group, absolute),\n useNode: tokens[0] === '\"use node\"',\n });\n if (\n names.length > 0 &&\n new Set(names).size === names.length &&\n matchesShape(tokens, tokenize(template, absolute, path)!)\n )\n continue;\n }\n }\n refused.push(toPosixPath(path, path.relative(projectRoot, absolute)));\n }\n if (refused.length > 0)\n return yield* new UnownedConvexEntrypointError({\n filePaths: refused.sort(),\n });\n});\n\nexport const render = ({\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: Parameters<typeof renderEffect>[0]) =>\n renderEffect({ functionNames, registeredFunctionsImportPath, useNode });\n\nconst renderEffect = Effect.fnUntraced(function* ({\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: {\n functionNames: ReadonlyArray<string>;\n registeredFunctionsImportPath: string;\n useNode?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n if (useNode) {\n yield* cbw.writeLine(`\"use node\";`);\n yield* cbw.blankLine();\n }\n\n yield* cbw.writeLine(\n `import registeredFunctions from \"${registeredFunctionsImportPath}\";`,\n );\n yield* cbw.newLine();\n yield* Effect.forEach(functionNames, (name) =>\n cbw.writeLine(`export const ${name} = registeredFunctions.${name};`),\n );\n\n return yield* cbw.toString();\n});\n\nexport const generateGroupModule = ({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: Parameters<typeof generateGroupModuleEffect>[0]) =>\n generateGroupModuleEffect({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n useNode,\n });\n\nconst generateGroupModuleEffect = Effect.fnUntraced(function* ({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: {\n groupPath: GroupPath.GroupPath;\n functionNames: ReadonlyArray<string>;\n registeredFunctionsImportPath: string;\n useNode?: boolean;\n}) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n\n const directoryPath = path.dirname(modulePath);\n if (!(yield* fs.exists(directoryPath))) {\n yield* fs.makeDirectory(directoryPath, { recursive: true });\n }\n\n const functionsContentsString = yield* render({\n functionNames,\n registeredFunctionsImportPath,\n useNode,\n });\n\n if (!(yield* fs.exists(modulePath))) {\n yield* fs.writeFileString(modulePath, functionsContentsString);\n return \"Added\" as const;\n }\n const existing = yield* fs.readFileString(modulePath);\n if (existing !== functionsContentsString) {\n yield* fs.writeFileString(modulePath, functionsContentsString);\n return \"Modified\" as const;\n }\n return \"Unchanged\" as const;\n});\n\n/**\n * Compute the module import specifier (relative to `modulePath`) for a group's\n * registry file under `confect/_generated/registeredFunctions/`. The registry\n * path mirrors the group's path one-to-one (see\n * `registeredFunctionsRelativePath` in `LeafModule.ts`) for both Convex and\n * Node groups.\n */\nexport const registeredFunctionsImportPathForGroup = Effect.fnUntraced(\n function* (groupPath: GroupPath.GroupPath, modulePath: string) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const registeredFunctionsPath =\n path.join(\n confectDirectory,\n \"_generated\",\n \"registeredFunctions\",\n ...groupPath.pathSegments,\n ) + \".ts\";\n\n return yield* toModuleImportPath(\n path.relative(path.dirname(modulePath), registeredFunctionsPath),\n );\n },\n);\n\nconst logGroupPaths = Effect.fnUntraced(function* <R>(\n groupPaths: GroupPaths.GroupPaths,\n logFn: (fullPath: string) => Effect.Effect<void, never, R>,\n): Effect.fn.Return<void, never, R | Path.Path | ConvexDirectory> {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.forEach(\n groupPaths,\n Effect.fnUntraced(function* (gp: GroupPath.GroupPath) {\n const relativeModulePath = yield* GroupPath.modulePath(gp);\n yield* logFn(path.join(convexDirectory, relativeModulePath));\n }),\n );\n});\n\nexport const generateFunctions = Effect.fnUntraced(function* (\n snapshot: GenerationSnapshot.GenerationSnapshot,\n) {\n const groupPathsFromFs = yield* getGroupPathsFromFs;\n yield* applyFunctionPlan(GenerationSnapshot.plan(snapshot, groupPathsFromFs));\n return GenerationSnapshot.functionPaths(snapshot);\n});\n\nexport const applyFunctionPlan = Effect.fnUntraced(function* (\n plan: GenerationSnapshot.ModulePlan,\n) {\n const removed = GroupPaths.GroupPaths.make(\n HashSet.fromIterable(plan.removed),\n );\n yield* removeGroups(removed);\n yield* logGroupPaths(removed, logFileRemoved);\n yield* writeGroups(plan.changed);\n});\n\nconst getGroupPathsFromFs = Effect.gen(function* () {\n const path = yield* Path.Path;\n const allConvexPaths = yield* getEntrypoints;\n const groupPathArray = yield* pipe(\n allConvexPaths,\n Array.filter(\n (convexPath) =>\n path.extname(convexPath) === \".ts\" &&\n !RESERVED_CONVEX_TS_FILE_NAMES.has(path.basename(convexPath)),\n ),\n Effect.forEach((groupModulePath) =>\n GroupPath.fromGroupModulePath(groupModulePath),\n ),\n );\n return GroupPaths.GroupPaths.make(HashSet.fromIterable(groupPathArray));\n});\n\nexport const removeGroups = Effect.fnUntraced(function* (\n groupPaths: GroupPaths.GroupPaths,\n) {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.all(\n HashSet.map(groupPaths, (groupPath) =>\n Effect.gen(function* () {\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n\n yield* Effect.logDebug(`Removing group '${relativeModulePath}'...`);\n\n yield* removePathIfExists(modulePath);\n yield* Effect.logDebug(`Group '${relativeModulePath}' removed`);\n }),\n ),\n { concurrency: \"unbounded\" },\n );\n});\n\nexport const writeGroups = (\n groups: ReadonlyArray<GenerationSnapshot.GroupSummary>,\n) =>\n Effect.forEach(\n groups,\n Effect.fnUntraced(function* (group: GenerationSnapshot.GroupSummary) {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const relativeModulePath = yield* GroupPath.modulePath(group.path);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n const registeredFunctionsImportPath =\n yield* registeredFunctionsImportPathForGroup(group.path, modulePath);\n const change = yield* generateGroupModule({\n groupPath: group.path,\n functionNames: group.functionNames,\n registeredFunctionsImportPath,\n useNode: group.runtime === \"Node\",\n });\n yield* Match.value(change).pipe(\n Match.when(\"Added\", () => logFileAdded(modulePath)),\n Match.when(\"Modified\", () => logFileModified(modulePath)),\n Match.when(\"Unchanged\", () => Effect.void),\n Match.exhaustive,\n );\n }),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,MAAM,gDAAgC,IAAI,IAAI;CAC5C;CACA;CACA;CACA;CACA;AACF,CAAC;AAGD,MAAM,iBAAiB,OAAO,IAAI,aAAa;CAC7C,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,SAAS,OAAO,gBAAgB;CACtC,MAAM,QAAQ,OAAO,GAAG,cAAc,QAAQ,EAAE,WAAW,KAAK,CAAC;CACjE,MAAM,aAAa,MAChB,QACE,SACC,KAAK,SAAS,IAAI,MAAM,sBACxB,KAAK,QAAQ,IAAI,MAAM,GAC3B,CAAC,CACA,KAAK,SAAS,KAAK,QAAQ,IAAI,IAAI,KAAK,GAAG;CAC9C,OAAO,MAAM,QAAQ,SAAS;EAC5B,MAAM,OAAO,KAAK,SAAS,IAAI;EAC/B,OACE,CAAC,KAAK,WAAW,eAAe,KAAK,GAAG,KACxC,CAAC,WAAW,MAAM,cAAc,KAAK,WAAW,SAAS,CAAC,KAC1D,uCAAuC,KAAK,IAAI,KAChD,CAAC,KAAK,WAAW,GAAG,KACpB,CAAC,KAAK,WAAW,GAAG,MACnB,KAAK,MAAM,KAAK,CAAC,EAAE,UAAU,OAAO,KACrC,SAAS,eACT,SAAS,eACT,CAAC,KAAK,SAAS,GAAG;CAEtB,CAAC;AACH,CAAC;AAED,MAAM,YACJ,QACA,YACA,SACyB;CACzB,MAAM,QACJ;CACF,MAAM,SAAmB,CAAC;CAC1B,OAAO,MAAM,YAAY,OAAO,QAAQ;EACtC,MAAM,QAAQ,MAAM,KAAK,MAAM;EAC/B,IAAI,UAAU,MAAM,OAAO,KAAA;EAC3B,MAAM,QAAQ,MAAM;EACpB,IAAI,UAAU,KAAK,KAAK,GAAG;EAC3B,IAAI,MAAM,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AEhE,OAAO,OAAO,SAAS,mBAAmB,mBAAmB,KAAK;EAElE,OAAO,mBAAmBA,YAAU;EACpC,OAAO,OAAO,SAAS,UAAU,mBAAmB,UAAU;CAChE,CAAC,CACH,GACA,EAAE,aAAa,YAAY,CAC7B;AACF,CAAC;AAED,MAAa,eACX,WAEA,OAAO,QACL,QACA,OAAO,WAAW,WAAW,OAAwC;CACnE,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,kBAAkB,OAAO,gBAAgB;CAC/C,MAAM,qBAAqB,OAAOD,WAAqB,MAAM,IAAI;CACjE,MAAMC,eAAa,KAAK,KAAK,iBAAiB,kBAAkB;CAChE,MAAM,gCACJ,OAAO,sCAAsC,MAAM,MAAMA,YAAU;CACrE,MAAM,SAAS,OAAO,oBAAoB;EACxC,WAAW,MAAM;EACjB,eAAe,MAAM;EACrB;EACA,SAAS,MAAM,YAAY;CAC7B,CAAC;CACD,OAAO,MAAM,MAAM,MAAM,CAAC,CAAC,KACzB,MAAM,KAAK,eAAe,aAAaA,YAAU,CAAC,GAClD,MAAM,KAAK,kBAAkB,gBAAgBA,YAAU,CAAC,GACxD,MAAM,KAAK,mBAAmB,OAAO,IAAI,GACzC,MAAM,UACR;AACF,CAAC,CACH"}
1
+ {"version":3,"file":"FunctionModule.mjs","names":["templates.http","templates.declaredHttp","templates.crons","GroupPath.fromGroupModulePath","GroupPath.modulePath","modulePath","GenerationSnapshot.plan","GenerationSnapshot.functionPaths"],"sources":["../src/FunctionModule.ts"],"sourcesContent":["import * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Match from \"effect/Match\";\nimport { UnownedConvexEntrypointError } from \"./CodegenError.js\";\nimport * as templates from \"./templates.js\";\nimport * as GenerationSnapshot from \"./GenerationSnapshot.js\";\nimport * as GroupPath from \"./GroupPath.js\";\nimport * as GroupPaths from \"./GroupPaths.js\";\nimport { CodeBlockWriter } from \"./CodeBlockWriter.js\";\nimport { logFileAdded, logFileModified, logFileRemoved } from \"./log.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\nimport { ConvexDirectory } from \"./ConvexDirectory.js\";\nimport {\n removePathIfExists,\n toModuleImportPath,\n toPosixPath,\n} from \"./utils.js\";\nimport { ProjectRoot } from \"./ProjectRoot.js\";\n\nconst RESERVED_CONVEX_TS_FILE_NAMES = new Set([\n \"schema.ts\",\n \"http.ts\",\n \"crons.ts\",\n \"auth.config.ts\",\n \"convex.config.ts\",\n]);\n\n// Keep ownership and removal aligned with Convex's bundler entryPoints filter.\nconst getEntrypoints = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convex = yield* ConvexDirectory.get;\n const files = yield* fs.readDirectory(convex, { recursive: true });\n const components = files\n .filter(\n (file) =>\n path.basename(file) === \"convex.config.ts\" &&\n path.dirname(file) !== \".\",\n )\n .map((file) => path.dirname(file) + path.sep);\n return files.filter((file) => {\n const base = path.basename(file);\n return (\n !file.startsWith(\"_generated\" + path.sep) &&\n !components.some((component) => file.startsWith(component)) &&\n /\\.(?:js|mjs|cjs|ts|tsx|mts|cts|jsx)$/.test(base) &&\n !base.startsWith(\".\") &&\n !base.startsWith(\"#\") &&\n (base.match(/\\./g)?.length ?? 0) === 1 &&\n base !== \"schema.ts\" &&\n base !== \"schema.js\" &&\n !file.includes(\" \")\n );\n });\n});\n\nconst tokenize = (\n source: string,\n modulePath: string,\n path: Path.Path,\n): string[] | undefined => {\n const token =\n /\\s+|\\/\\/[^\\r\\n]*|\\/\\*[\\s\\S]*?\\*\\/|\"(?:\\\\.|[^\"\\\\\\r\\n])*\"|'(?:\\\\.|[^'\\\\\\r\\n])*'|[$A-Z_a-z][$\\w]*|[{}()[\\].,:;=]/y;\n const tokens: string[] = [];\n while (token.lastIndex < source.length) {\n const match = token.exec(source);\n if (match === null) return undefined;\n const value = match[0];\n if (/^\\s|^\\//.test(value)) continue;\n if (value.startsWith('\"') || value.startsWith(\"'\")) {\n const literal = value.slice(1, -1);\n tokens.push(\n JSON.stringify(\n literal.startsWith(\".\")\n ? path.resolve(\n path.dirname(modulePath),\n literal.replace(/\\.js$/, \"\"),\n )\n : literal,\n ),\n );\n } else tokens.push(value);\n }\n return tokens;\n};\n\nconst matchesShape = (\n actual: readonly string[],\n expected: readonly string[],\n) => {\n let index = 0;\n for (const token of expected) {\n if (token === \";\" && actual[index] !== \";\") continue;\n if (actual[index] === \",\" && (token === \"}\" || token === \")\")) index++;\n if (actual[index++] !== token) return false;\n }\n return index === actual.length;\n};\n\nexport const assertOwnedEntrypoints = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convex = yield* ConvexDirectory.get;\n const confect = yield* ConfectDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n const importFromConvex = (file: string) =>\n toModuleImportPath(path.relative(convex, path.join(confect, file)));\n const optional = new Map([\n [\n \"http.ts\",\n [\n yield* templates.http({\n httpImportPath: yield* importFromConvex(\"http.ts\"),\n }),\n yield* templates.declaredHttp({\n schemaImportPath: yield* importFromConvex(\"_generated/schema.ts\"),\n httpImportPath: yield* importFromConvex(\"http.ts\"),\n }),\n yield* templates.declaredHttp({\n schemaImportPath: yield* importFromConvex(\"_generated/schema.ts\"),\n httpImportPath: yield* importFromConvex(\"http.ts\"),\n runtimeImportPath: yield* importFromConvex(\"runtime.ts\"),\n }),\n ],\n ],\n [\n \"crons.ts\",\n [\n yield* templates.crons({\n cronsImportPath: yield* importFromConvex(\"crons.ts\"),\n }),\n ],\n ],\n ]);\n const refused: string[] = [];\n for (const relative of yield* getEntrypoints) {\n const absolute = path.join(convex, relative);\n const tokens = tokenize(yield* fs.readFileString(absolute), absolute, path);\n if (tokens !== undefined) {\n if (\n optional\n .get(relative)\n ?.some((template) =>\n matchesShape(tokens, tokenize(template, absolute, path)!),\n )\n )\n continue;\n if (path.extname(relative) === \".ts\") {\n const names = tokens.flatMap((token, index) =>\n token === \"export\" && tokens[index + 1] === \"const\"\n ? [tokens[index + 2]!]\n : [],\n );\n const group = yield* GroupPath.fromGroupModulePath(relative);\n const template = yield* render({\n functionNames: names,\n registeredFunctionsImportPath:\n yield* registeredFunctionsImportPathForGroup(group, absolute),\n useNode: tokens[0] === '\"use node\"',\n });\n if (\n names.length > 0 &&\n new Set(names).size === names.length &&\n matchesShape(tokens, tokenize(template, absolute, path)!)\n )\n continue;\n }\n }\n refused.push(toPosixPath(path, path.relative(projectRoot, absolute)));\n }\n if (refused.length > 0)\n return yield* new UnownedConvexEntrypointError({\n filePaths: refused.sort(),\n });\n});\n\nexport const render = ({\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: Parameters<typeof renderEffect>[0]) =>\n renderEffect({ functionNames, registeredFunctionsImportPath, useNode });\n\nconst renderEffect = Effect.fnUntraced(function* ({\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: {\n functionNames: ReadonlyArray<string>;\n registeredFunctionsImportPath: string;\n useNode?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n if (useNode) {\n yield* cbw.writeLine(`\"use node\";`);\n yield* cbw.blankLine();\n }\n\n yield* cbw.writeLine(\n `import registeredFunctions from \"${registeredFunctionsImportPath}\";`,\n );\n yield* cbw.newLine();\n yield* Effect.forEach(functionNames, (name) =>\n cbw.writeLine(`export const ${name} = registeredFunctions.${name};`),\n );\n\n return yield* cbw.toString();\n});\n\nexport const generateGroupModule = ({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: Parameters<typeof generateGroupModuleEffect>[0]) =>\n generateGroupModuleEffect({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n useNode,\n });\n\nconst generateGroupModuleEffect = Effect.fnUntraced(function* ({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n useNode = false,\n}: {\n groupPath: GroupPath.GroupPath;\n functionNames: ReadonlyArray<string>;\n registeredFunctionsImportPath: string;\n useNode?: boolean;\n}) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n\n const directoryPath = path.dirname(modulePath);\n if (!(yield* fs.exists(directoryPath))) {\n yield* fs.makeDirectory(directoryPath, { recursive: true });\n }\n\n const functionsContentsString = yield* render({\n functionNames,\n registeredFunctionsImportPath,\n useNode,\n });\n\n if (!(yield* fs.exists(modulePath))) {\n yield* fs.writeFileString(modulePath, functionsContentsString);\n return \"Added\" as const;\n }\n const existing = yield* fs.readFileString(modulePath);\n if (existing !== functionsContentsString) {\n yield* fs.writeFileString(modulePath, functionsContentsString);\n return \"Modified\" as const;\n }\n return \"Unchanged\" as const;\n});\n\n/**\n * Compute the module import specifier (relative to `modulePath`) for a group's\n * registry file under `confect/_generated/registeredFunctions/`. The registry\n * path mirrors the group's path one-to-one (see\n * `registeredFunctionsRelativePath` in `LeafModule.ts`) for both Convex and\n * Node groups.\n */\nexport const registeredFunctionsImportPathForGroup = Effect.fnUntraced(\n function* (groupPath: GroupPath.GroupPath, modulePath: string) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const registeredFunctionsPath =\n path.join(\n confectDirectory,\n \"_generated\",\n \"registeredFunctions\",\n ...groupPath.pathSegments,\n ) + \".ts\";\n\n return yield* toModuleImportPath(\n path.relative(path.dirname(modulePath), registeredFunctionsPath),\n );\n },\n);\n\nconst logGroupPaths = Effect.fnUntraced(function* <R>(\n groupPaths: GroupPaths.GroupPaths,\n logFn: (fullPath: string) => Effect.Effect<void, never, R>,\n): Effect.fn.Return<void, never, R | Path.Path | ConvexDirectory> {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.forEach(\n groupPaths,\n Effect.fnUntraced(function* (gp: GroupPath.GroupPath) {\n const relativeModulePath = yield* GroupPath.modulePath(gp);\n yield* logFn(path.join(convexDirectory, relativeModulePath));\n }),\n );\n});\n\nexport const generateFunctions = Effect.fnUntraced(function* (\n snapshot: GenerationSnapshot.GenerationSnapshot,\n) {\n const groupPathsFromFs = yield* getGroupPathsFromFs;\n yield* applyFunctionPlan(GenerationSnapshot.plan(snapshot, groupPathsFromFs));\n return GenerationSnapshot.functionPaths(snapshot);\n});\n\nexport const applyFunctionPlan = Effect.fnUntraced(function* (\n plan: GenerationSnapshot.ModulePlan,\n) {\n const removed = GroupPaths.GroupPaths.make(\n HashSet.fromIterable(plan.removed),\n );\n yield* removeGroups(removed);\n yield* logGroupPaths(removed, logFileRemoved);\n yield* writeGroups(plan.changed);\n});\n\nconst getGroupPathsFromFs = Effect.gen(function* () {\n const path = yield* Path.Path;\n const allConvexPaths = yield* getEntrypoints;\n const groupPathArray = yield* pipe(\n allConvexPaths,\n Array.filter(\n (convexPath) =>\n path.extname(convexPath) === \".ts\" &&\n !RESERVED_CONVEX_TS_FILE_NAMES.has(path.basename(convexPath)),\n ),\n Effect.forEach((groupModulePath) =>\n GroupPath.fromGroupModulePath(groupModulePath),\n ),\n );\n return GroupPaths.GroupPaths.make(HashSet.fromIterable(groupPathArray));\n});\n\nexport const removeGroups = Effect.fnUntraced(function* (\n groupPaths: GroupPaths.GroupPaths,\n) {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.all(\n HashSet.map(groupPaths, (groupPath) =>\n Effect.gen(function* () {\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n\n yield* Effect.logDebug(`Removing group '${relativeModulePath}'...`);\n\n yield* removePathIfExists(modulePath);\n yield* Effect.logDebug(`Group '${relativeModulePath}' removed`);\n }),\n ),\n { concurrency: \"unbounded\" },\n );\n});\n\nexport const writeGroups = (\n groups: ReadonlyArray<GenerationSnapshot.GroupSummary>,\n) =>\n Effect.forEach(\n groups,\n Effect.fnUntraced(function* (group: GenerationSnapshot.GroupSummary) {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const relativeModulePath = yield* GroupPath.modulePath(group.path);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n const registeredFunctionsImportPath =\n yield* registeredFunctionsImportPathForGroup(group.path, modulePath);\n const change = yield* generateGroupModule({\n groupPath: group.path,\n functionNames: group.functionNames,\n registeredFunctionsImportPath,\n useNode: group.runtime === \"Node\",\n });\n yield* Match.value(change).pipe(\n Match.when(\"Added\", () => logFileAdded(modulePath)),\n Match.when(\"Modified\", () => logFileModified(modulePath)),\n Match.when(\"Unchanged\", () => Effect.void),\n Match.exhaustive,\n );\n }),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,MAAM,gDAAgC,IAAI,IAAI;CAC5C;CACA;CACA;CACA;CACA;AACF,CAAC;AAGD,MAAM,iBAAiB,OAAO,IAAI,aAAa;CAC7C,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,SAAS,OAAO,gBAAgB;CACtC,MAAM,QAAQ,OAAO,GAAG,cAAc,QAAQ,EAAE,WAAW,KAAK,CAAC;CACjE,MAAM,aAAa,MAChB,QACE,SACC,KAAK,SAAS,IAAI,MAAM,sBACxB,KAAK,QAAQ,IAAI,MAAM,GAC3B,CAAC,CACA,KAAK,SAAS,KAAK,QAAQ,IAAI,IAAI,KAAK,GAAG;CAC9C,OAAO,MAAM,QAAQ,SAAS;EAC5B,MAAM,OAAO,KAAK,SAAS,IAAI;EAC/B,OACE,CAAC,KAAK,WAAW,eAAe,KAAK,GAAG,KACxC,CAAC,WAAW,MAAM,cAAc,KAAK,WAAW,SAAS,CAAC,KAC1D,uCAAuC,KAAK,IAAI,KAChD,CAAC,KAAK,WAAW,GAAG,KACpB,CAAC,KAAK,WAAW,GAAG,MACnB,KAAK,MAAM,KAAK,CAAC,EAAE,UA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zC,MAAM,UACR;AACF,CAAC,CACH"}
@@ -215,6 +215,7 @@ const checkAndWriteHttp = Effect.fnUntraced(function* (app) {
215
215
  });
216
216
  yield* Http.routes(app, http$1).pipe(Result.mapError(invalid("http.ts")), Effect.fromResult);
217
217
  const contents = yield* declaredHttp({
218
+ runtimeImportPath: (yield* fs.exists(path.join(confectDirectory, "runtime.ts"))) ? yield* toModuleImportPath(path.relative(convexDirectory, path.join(confectDirectory, "runtime.ts"))) : void 0,
218
219
  schemaImportPath: yield* toModuleImportPath(path.relative(convexDirectory, path.join(confectDirectory, "_generated", "schema.ts"))),
219
220
  httpImportPath: yield* toModuleImportPath(path.relative(convexDirectory, httpPath))
220
221
  });
@@ -1 +1 @@
1
- {"version":3,"file":"declaration.mjs","names":["Bundler.bundle","ConvexConfig.componentConfigPlugin","Declaration.isGenerated","Bundler.resolveModule","ConvexConfig.componentImportOf","Declaration.parse","Declaration.fileOf","ConvexConfig.CONVEX_CONFIG_FILENAME","templates.authConfig","digest","Declaration.digest","Declaration.manifest","Declaration.convexConfig","Declaration.authConfig","Declaration.authProviders","templates.http","http","templates.declaredHttp"],"sources":["../../src/confect/declaration.ts"],"sourcesContent":["import { App, Http } from \"@confect/core\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Option from \"effect/Option\";\nimport * as Path from \"effect/Path\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport { fromBundlerError } from \"../BuildError.js\";\nimport * as Bundler from \"../Bundler.js\";\nimport {\n HandWrittenConvexFileError,\n DeclarationKindMismatchError,\n InvalidDeclarationError,\n} from \"../CodegenError.js\";\nimport { ConfectDirectory } from \"../ConfectDirectory.js\";\nimport * as ConvexConfig from \"../ConvexConfig.js\";\nimport { ConvexDirectory } from \"../ConvexDirectory.js\";\nimport * as Declaration from \"../Declaration.js\";\nimport { logFileRemoved } from \"../log.js\";\nimport { ProjectRoot } from \"../ProjectRoot.js\";\nimport * as templates from \"../templates.js\";\nimport {\n removePathIfExists,\n toModuleImportPath,\n toPosixPath,\n writeFileString,\n writeFileStringAndLog,\n} from \"../utils.js\";\n\n/**\n * Bumped when the generated files change shape, so a manifest written by an\n * older generator never matches a current one.\n */\nconst GENERATOR_FORMAT = \"2\";\n\nconst confectPath = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, file);\n});\n\n/**\n * A backend opts in to the declaration by writing `confect/app.ts`.\n */\nexport const isDeclared = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n return yield* fs.exists(yield* confectPath(\"app.ts\"));\n});\n\nconst displayPath = Effect.fnUntraced(function* (absolutePath: string) {\n const path = yield* Path.Path;\n return toPosixPath(path, path.relative(yield* ProjectRoot.get, absolutePath));\n});\n\nconst bundleDeclaration = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n const absolutePath = yield* confectPath(file);\n return yield* Bundler.bundle(absolutePath, {\n plugins: [ConvexConfig.componentConfigPlugin(path)],\n }).pipe(\n Effect.mapError((error) => fromBundlerError(`confect/${file}`, error)),\n );\n});\n\nconst invalid = (file: string) => (error: { readonly message: string }) =>\n new InvalidDeclarationError({\n declarationPath: `confect/${file}`,\n reason: error.message,\n });\n\n/**\n * Fail instead of overwriting a Convex file someone wrote by hand. A file with\n * the generated header, or one of the exact files an earlier codegen wrote\n * there, is ours to replace.\n */\nconst assertOwned = Effect.fnUntraced(function* (\n convexPath: string,\n declarationFile: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(convexPath))) return;\n if (Declaration.isGenerated(yield* fs.readFileString(convexPath), legacy)) {\n return;\n }\n return yield* new HandWrittenConvexFileError({\n convexPath: yield* displayPath(convexPath),\n declarationPath: `confect/${declarationFile}`,\n });\n});\n\nconst decodeVersion = Schema.decodeUnknownOption(\n Schema.fromJsonString(Schema.Struct({ version: Schema.String })),\n);\n\nconst packageVersion = Effect.fnUntraced(function* (\n name: string,\n from: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n return yield* Option.match(\n Bundler.resolveModule(`${name}/package.json`, path.join(from, \"_\")),\n {\n onNone: () => Effect.succeed(\"unresolved\"),\n onSome: (packageJson) =>\n fs.readFileString(packageJson).pipe(\n Effect.map((contents) =>\n Option.match(decodeVersion(contents), {\n onNone: () => \"unknown\",\n onSome: ({ version }) => version,\n }),\n ),\n ),\n },\n );\n});\n\n/**\n * Every first-party file the declaration modules import, by project-relative\n * path and contents. Files under `node_modules` and outside the project count\n * through package versions instead, so rebuilding a dependency does not change\n * the digest.\n */\nconst declarationInputs = Effect.fnUntraced(function* (\n bundles: ReadonlyArray<Bundler.Bundled>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const projectRoot = yield* ProjectRoot.get;\n const files = new Set<string>();\n for (const { metafile } of bundles) {\n for (const input of Object.keys(metafile.inputs)) {\n const relative = path.relative(projectRoot, input);\n if (\n path.isAbsolute(input) &&\n !relative.startsWith(\"..\") &&\n !relative.split(path.sep).includes(\"node_modules\")\n ) {\n files.add(input);\n }\n }\n }\n // Plugin namespaces (component config wrappers) appear as inputs too;\n // only real files count.\n const real = yield* Effect.filter([...files], (file) => fs.exists(file));\n return yield* Effect.forEach(real, (file) =>\n fs\n .readFileString(file)\n .pipe(\n Effect.map(\n (contents) =>\n [\n toPosixPath(path, path.relative(projectRoot, file)),\n contents,\n ] as const,\n ),\n ),\n );\n});\n\nconst componentImport = Effect.fnUntraced(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n return (definition: unknown): Option.Option<Declaration.ComponentImport> =>\n Option.map(ConvexConfig.componentImportOf(definition), (recorded) => {\n const bare =\n !recorded.specifier.startsWith(\".\") &&\n !path.isAbsolute(recorded.specifier);\n const relative = toPosixPath(\n path,\n path.relative(convexDirectory, recorded.path),\n ).replace(/\\.([cm]?)[jt]s$/, \".$1js\");\n return {\n importPath: bare\n ? recorded.specifier\n : relative.startsWith(\".\")\n ? relative\n : `./${relative}`,\n componentName:\n Predicate.hasProperty(definition, \"defaultName\") &&\n Predicate.isString(definition.defaultName)\n ? definition.defaultName\n : \"component\",\n };\n });\n});\n\nconst manifestPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, \"_generated\", \"manifest.ts\");\n});\n\n/**\n * Remove a file codegen wrote whose source is gone; leave anything else.\n */\nconst removeGenerated = Effect.fnUntraced(function* (\n filePath: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) return;\n if (!Declaration.isGenerated(yield* fs.readFileString(filePath), legacy)) {\n return;\n }\n yield* removePathIfExists(filePath);\n yield* logFileRemoved(filePath);\n});\n\nconst removeManifest = Effect.gen(function* () {\n yield* removeGenerated(yield* manifestPath, []);\n});\n\nconst authProvidersPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n return path.join(\n yield* ConfectDirectory.get,\n \"_generated\",\n \"auth.providers.ts\",\n );\n});\n\nconst removeAuthProviders = Effect.gen(function* () {\n yield* removeGenerated(yield* authProvidersPath, []);\n});\n\nconst writeDeclaration = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n const target = (yield* ConvexDirectory.target).kind;\n\n const app = yield* bundleDeclaration(\"app.ts\");\n const appValue: unknown = app.module.default;\n if (App.isApp(appValue) && appValue.kind !== target) {\n return yield* new DeclarationKindMismatchError({\n declarationPath: \"confect/app.ts\",\n declaredKind: appValue.kind,\n targetKind: target,\n });\n }\n const authPath = yield* confectPath(\"auth.ts\");\n const auth = (yield* fs.exists(authPath))\n ? Option.some(yield* bundleDeclaration(\"auth.ts\"))\n : Option.none();\n\n const declaration = yield* Declaration.parse({\n target,\n app: app.module.default,\n auth: Option.map(auth, ({ module }) => module.default),\n componentImport: yield* componentImport(),\n }).pipe(\n Result.mapError(\n (error) =>\n new InvalidDeclarationError({\n declarationPath: Declaration.fileOf(error),\n reason: error.message,\n }),\n ),\n Effect.fromResult,\n );\n\n const convexConfigPath = path.join(\n convexDirectory,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n );\n const authConfigPath = path.join(convexDirectory, \"auth.config.ts\");\n const authImportPath = yield* toModuleImportPath(\n path.relative(convexDirectory, authPath),\n );\n const legacyAuthConfigs = yield* Effect.forEach(\n [authImportPath, authImportPath.replace(/\\.js$/, \"\")],\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n );\n yield* assertOwned(convexConfigPath, \"app.ts\", []);\n yield* assertOwned(authConfigPath, \"auth.ts\", legacyAuthConfigs);\n\n if (target === \"app\") {\n const digest = Declaration.digest({\n files: yield* declarationInputs([app, ...Option.toArray(auth)]),\n versions: [\n [\"convex\", yield* packageVersion(\"convex\", projectRoot)],\n [\"@confect/cli generator format\", GENERATOR_FORMAT],\n ],\n });\n yield* writeFileStringAndLog(\n yield* manifestPath,\n Declaration.manifest(declaration, digest),\n );\n }\n yield* writeFileStringAndLog(\n convexConfigPath,\n Declaration.convexConfig(declaration),\n );\n yield* Option.match(declaration.providers, {\n onNone: () =>\n Effect.gen(function* () {\n yield* removeAuthProviders;\n if (yield* fs.exists(authConfigPath)) {\n yield* removePathIfExists(authConfigPath);\n yield* logFileRemoved(authConfigPath);\n }\n }),\n onSome: (providers) =>\n Effect.gen(function* () {\n yield* writeFileStringAndLog(\n authConfigPath,\n Declaration.authConfig(providers),\n );\n yield* writeFileStringAndLog(\n yield* authProvidersPath,\n Declaration.authProviders(providers),\n );\n }),\n });\n return App.isApp(appValue) ? Option.some(appValue) : Option.none<App.Any>();\n});\n\n/**\n * Write the declaration's Convex files and manifest from `confect/app.ts`,\n * `confect/env.ts` and `confect/auth.ts`, before anything else is validated. On\n * any failure the previous manifest is removed, so a stale manifest never\n * outlives a declaration that no longer produces it.\n */\nexport const syncDeclaration = Effect.gen(function* () {\n if (!(yield* isDeclared)) {\n yield* removeManifest;\n yield* removeAuthProviders;\n return Option.none<App.Any>();\n }\n return yield* writeDeclaration.pipe(\n Effect.tapError(() =>\n removeManifest.pipe(Effect.andThen(removeAuthProviders)),\n ),\n );\n});\n\n/**\n * Check every HTTP route the backend serves and write `convex/http.ts` from\n * `confect/http.ts`. Runs after generation, because `http.ts` imports its\n * handlers, which import generated services.\n */\nexport const syncDeclaredHttp = (app: App.Any) =>\n checkAndWriteHttp(app).pipe(Effect.tapError(() => removeManifest));\n\nconst checkAndWriteHttp = Effect.fnUntraced(function* (app: App.Any) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const confectDirectory = yield* ConfectDirectory.get;\n const httpPath = yield* confectPath(\"http.ts\");\n\n const convexHttpPath = path.join(convexDirectory, \"http.ts\");\n if (!(yield* fs.exists(httpPath))) {\n yield* Http.routes(app).pipe(\n Result.mapError(invalid(\"app.ts\")),\n Effect.fromResult,\n );\n yield* removeGenerated(convexHttpPath, [\n yield* templates.http({\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n }),\n ]);\n return Option.none();\n }\n\n const http = (yield* bundleDeclaration(\"http.ts\")).module.default;\n if (!Http.isHttp(http)) {\n return yield* new InvalidDeclarationError({\n declarationPath: \"confect/http.ts\",\n reason: \"it must default-export Http.make(...).\",\n });\n }\n yield* Http.routes(app, http).pipe(\n Result.mapError(invalid(\"http.ts\")),\n Effect.fromResult,\n );\n\n const contents = yield* templates.declaredHttp({\n schemaImportPath: yield* toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"_generated\", \"schema.ts\"),\n ),\n ),\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n });\n const change = yield* writeFileString(convexHttpPath, contents);\n return Option.some({ change, convexFilePath: convexHttpPath });\n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M,iBAAiB,KAAK,KAAK,iBAAiB,SAAS;CAC3D,IAAI,EAAE,OAAO,GAAG,OAAO,QAAQ,IAAI;EACjC,OAAO,KAAK,OAAO,GAAG,CAAC,CAAC,KACtB,OAAO,SAAS,QAAQ,QAAQ,CAAC,GACjC,OAAO,UACT;EACA,OAAO,gBAAgB,gBAAgB,CACrC,OAAOC,KAAe,EACpB,gBAAgB,OAAO,mBACrB,KAAK,SAAS,iBAAiB,QAAQ,CACzC,EACF,CAAC,CACH,CAAC;EACD,OAAO,OAAO,KAAK;CACrB;CAEA,MAAMC,UAAQ,OAAO,kBAAkB,SAAS,EAAA,CAAG,OAAO;CAC1D,IAAI,CAAC,KAAK,OAAOA,MAAI,GACnB,OAAO,OAAO,IAAI,wBAAwB;EACxC,iBAAiB;EACjB,QAAQ;CACV,CAAC;CAEH,OAAO,KAAK,OAAO,KAAKA,MAAI,CAAC,CAAC,KAC5B,OAAO,SAAS,QAAQ,SAAS,CAAC,GAClC,OAAO,UACT;CAEA,MAAM,WAAW,OAAOC,aAAuB;EAC7C,kBAAkB,OAAO,mBACvB,KAAK,SACH,iBACA,KAAK,KAAK,kBAAkB,cAAc,WAAW,CACvD,CACF;EACA,gBAAgB,OAAO,mBACrB,KAAK,SAAS,iBAAiB,QAAQ,CACzC;CACF,CAAC;CACD,MAAM,SAAS,OAAO,gBAAgB,gBAAgB,QAAQ;CAC9D,OAAO,OAAO,KAAK;EAAE;EAAQ,gBAAgB;CAAe,CAAC;AAC/D,CAAC"}
1
+ {"version":3,"file":"declaration.mjs","names":["Bundler.bundle","ConvexConfig.componentConfigPlugin","Declaration.isGenerated","Bundler.resolveModule","ConvexConfig.componentImportOf","Declaration.parse","Declaration.fileOf","ConvexConfig.CONVEX_CONFIG_FILENAME","templates.authConfig","digest","Declaration.digest","Declaration.manifest","Declaration.convexConfig","Declaration.authConfig","Declaration.authProviders","templates.http","http","templates.declaredHttp"],"sources":["../../src/confect/declaration.ts"],"sourcesContent":["import { App, Http } from \"@confect/core\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Option from \"effect/Option\";\nimport * as Path from \"effect/Path\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport { fromBundlerError } from \"../BuildError.js\";\nimport * as Bundler from \"../Bundler.js\";\nimport {\n HandWrittenConvexFileError,\n DeclarationKindMismatchError,\n InvalidDeclarationError,\n} from \"../CodegenError.js\";\nimport { ConfectDirectory } from \"../ConfectDirectory.js\";\nimport * as ConvexConfig from \"../ConvexConfig.js\";\nimport { ConvexDirectory } from \"../ConvexDirectory.js\";\nimport * as Declaration from \"../Declaration.js\";\nimport { logFileRemoved } from \"../log.js\";\nimport { ProjectRoot } from \"../ProjectRoot.js\";\nimport * as templates from \"../templates.js\";\nimport {\n removePathIfExists,\n toModuleImportPath,\n toPosixPath,\n writeFileString,\n writeFileStringAndLog,\n} from \"../utils.js\";\n\n/**\n * Bumped when the generated files change shape, so a manifest written by an\n * older generator never matches a current one.\n */\nconst GENERATOR_FORMAT = \"2\";\n\nconst confectPath = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, file);\n});\n\n/**\n * A backend opts in to the declaration by writing `confect/app.ts`.\n */\nexport const isDeclared = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n return yield* fs.exists(yield* confectPath(\"app.ts\"));\n});\n\nconst displayPath = Effect.fnUntraced(function* (absolutePath: string) {\n const path = yield* Path.Path;\n return toPosixPath(path, path.relative(yield* ProjectRoot.get, absolutePath));\n});\n\nconst bundleDeclaration = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n const absolutePath = yield* confectPath(file);\n return yield* Bundler.bundle(absolutePath, {\n plugins: [ConvexConfig.componentConfigPlugin(path)],\n }).pipe(\n Effect.mapError((error) => fromBundlerError(`confect/${file}`, error)),\n );\n});\n\nconst invalid = (file: string) => (error: { readonly message: string }) =>\n new InvalidDeclarationError({\n declarationPath: `confect/${file}`,\n reason: error.message,\n });\n\n/**\n * Fail instead of overwriting a Convex file someone wrote by hand. A file with\n * the generated header, or one of the exact files an earlier codegen wrote\n * there, is ours to replace.\n */\nconst assertOwned = Effect.fnUntraced(function* (\n convexPath: string,\n declarationFile: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(convexPath))) return;\n if (Declaration.isGenerated(yield* fs.readFileString(convexPath), legacy)) {\n return;\n }\n return yield* new HandWrittenConvexFileError({\n convexPath: yield* displayPath(convexPath),\n declarationPath: `confect/${declarationFile}`,\n });\n});\n\nconst decodeVersion = Schema.decodeUnknownOption(\n Schema.fromJsonString(Schema.Struct({ version: Schema.String })),\n);\n\nconst packageVersion = Effect.fnUntraced(function* (\n name: string,\n from: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n return yield* Option.match(\n Bundler.resolveModule(`${name}/package.json`, path.join(from, \"_\")),\n {\n onNone: () => Effect.succeed(\"unresolved\"),\n onSome: (packageJson) =>\n fs.readFileString(packageJson).pipe(\n Effect.map((contents) =>\n Option.match(decodeVersion(contents), {\n onNone: () => \"unknown\",\n onSome: ({ version }) => version,\n }),\n ),\n ),\n },\n );\n});\n\n/**\n * Every first-party file the declaration modules import, by project-relative\n * path and contents. Files under `node_modules` and outside the project count\n * through package versions instead, so rebuilding a dependency does not change\n * the digest.\n */\nconst declarationInputs = Effect.fnUntraced(function* (\n bundles: ReadonlyArray<Bundler.Bundled>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const projectRoot = yield* ProjectRoot.get;\n const files = new Set<string>();\n for (const { metafile } of bundles) {\n for (const input of Object.keys(metafile.inputs)) {\n const relative = path.relative(projectRoot, input);\n if (\n path.isAbsolute(input) &&\n !relative.startsWith(\"..\") &&\n !relative.split(path.sep).includes(\"node_modules\")\n ) {\n files.add(input);\n }\n }\n }\n // Plugin namespaces (component config wrappers) appear as inputs too;\n // only real files count.\n const real = yield* Effect.filter([...files], (file) => fs.exists(file));\n return yield* Effect.forEach(real, (file) =>\n fs\n .readFileString(file)\n .pipe(\n Effect.map(\n (contents) =>\n [\n toPosixPath(path, path.relative(projectRoot, file)),\n contents,\n ] as const,\n ),\n ),\n );\n});\n\nconst componentImport = Effect.fnUntraced(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n return (definition: unknown): Option.Option<Declaration.ComponentImport> =>\n Option.map(ConvexConfig.componentImportOf(definition), (recorded) => {\n const bare =\n !recorded.specifier.startsWith(\".\") &&\n !path.isAbsolute(recorded.specifier);\n const relative = toPosixPath(\n path,\n path.relative(convexDirectory, recorded.path),\n ).replace(/\\.([cm]?)[jt]s$/, \".$1js\");\n return {\n importPath: bare\n ? recorded.specifier\n : relative.startsWith(\".\")\n ? relative\n : `./${relative}`,\n componentName:\n Predicate.hasProperty(definition, \"defaultName\") &&\n Predicate.isString(definition.defaultName)\n ? definition.defaultName\n : \"component\",\n };\n });\n});\n\nconst manifestPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, \"_generated\", \"manifest.ts\");\n});\n\n/**\n * Remove a file codegen wrote whose source is gone; leave anything else.\n */\nconst removeGenerated = Effect.fnUntraced(function* (\n filePath: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) return;\n if (!Declaration.isGenerated(yield* fs.readFileString(filePath), legacy)) {\n return;\n }\n yield* removePathIfExists(filePath);\n yield* logFileRemoved(filePath);\n});\n\nconst removeManifest = Effect.gen(function* () {\n yield* removeGenerated(yield* manifestPath, []);\n});\n\nconst authProvidersPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n return path.join(\n yield* ConfectDirectory.get,\n \"_generated\",\n \"auth.providers.ts\",\n );\n});\n\nconst removeAuthProviders = Effect.gen(function* () {\n yield* removeGenerated(yield* authProvidersPath, []);\n});\n\nconst writeDeclaration = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n const target = (yield* ConvexDirectory.target).kind;\n\n const app = yield* bundleDeclaration(\"app.ts\");\n const appValue: unknown = app.module.default;\n if (App.isApp(appValue) && appValue.kind !== target) {\n return yield* new DeclarationKindMismatchError({\n declarationPath: \"confect/app.ts\",\n declaredKind: appValue.kind,\n targetKind: target,\n });\n }\n const authPath = yield* confectPath(\"auth.ts\");\n const auth = (yield* fs.exists(authPath))\n ? Option.some(yield* bundleDeclaration(\"auth.ts\"))\n : Option.none();\n\n const declaration = yield* Declaration.parse({\n target,\n app: app.module.default,\n auth: Option.map(auth, ({ module }) => module.default),\n componentImport: yield* componentImport(),\n }).pipe(\n Result.mapError(\n (error) =>\n new InvalidDeclarationError({\n declarationPath: Declaration.fileOf(error),\n reason: error.message,\n }),\n ),\n Effect.fromResult,\n );\n\n const convexConfigPath = path.join(\n convexDirectory,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n );\n const authConfigPath = path.join(convexDirectory, \"auth.config.ts\");\n const authImportPath = yield* toModuleImportPath(\n path.relative(convexDirectory, authPath),\n );\n const legacyAuthConfigs = yield* Effect.forEach(\n [authImportPath, authImportPath.replace(/\\.js$/, \"\")],\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n );\n yield* assertOwned(convexConfigPath, \"app.ts\", []);\n yield* assertOwned(authConfigPath, \"auth.ts\", legacyAuthConfigs);\n\n if (target === \"app\") {\n const digest = Declaration.digest({\n files: yield* declarationInputs([app, ...Option.toArray(auth)]),\n versions: [\n [\"convex\", yield* packageVersion(\"convex\", projectRoot)],\n [\"@confect/cli generator format\", GENERATOR_FORMAT],\n ],\n });\n yield* writeFileStringAndLog(\n yield* manifestPath,\n Declaration.manifest(declaration, digest),\n );\n }\n yield* writeFileStringAndLog(\n convexConfigPath,\n Declaration.convexConfig(declaration),\n );\n yield* Option.match(declaration.providers, {\n onNone: () =>\n Effect.gen(function* () {\n yield* removeAuthProviders;\n if (yield* fs.exists(authConfigPath)) {\n yield* removePathIfExists(authConfigPath);\n yield* logFileRemoved(authConfigPath);\n }\n }),\n onSome: (providers) =>\n Effect.gen(function* () {\n yield* writeFileStringAndLog(\n authConfigPath,\n Declaration.authConfig(providers),\n );\n yield* writeFileStringAndLog(\n yield* authProvidersPath,\n Declaration.authProviders(providers),\n );\n }),\n });\n return App.isApp(appValue) ? Option.some(appValue) : Option.none<App.Any>();\n});\n\n/**\n * Write the declaration's Convex files and manifest from `confect/app.ts`,\n * `confect/env.ts` and `confect/auth.ts`, before anything else is validated. On\n * any failure the previous manifest is removed, so a stale manifest never\n * outlives a declaration that no longer produces it.\n */\nexport const syncDeclaration = Effect.gen(function* () {\n if (!(yield* isDeclared)) {\n yield* removeManifest;\n yield* removeAuthProviders;\n return Option.none<App.Any>();\n }\n return yield* writeDeclaration.pipe(\n Effect.tapError(() =>\n removeManifest.pipe(Effect.andThen(removeAuthProviders)),\n ),\n );\n});\n\n/**\n * Check every HTTP route the backend serves and write `convex/http.ts` from\n * `confect/http.ts`. Runs after generation, because `http.ts` imports its\n * handlers, which import generated services.\n */\nexport const syncDeclaredHttp = (app: App.Any) =>\n checkAndWriteHttp(app).pipe(Effect.tapError(() => removeManifest));\n\nconst checkAndWriteHttp = Effect.fnUntraced(function* (app: App.Any) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const confectDirectory = yield* ConfectDirectory.get;\n const httpPath = yield* confectPath(\"http.ts\");\n\n const convexHttpPath = path.join(convexDirectory, \"http.ts\");\n if (!(yield* fs.exists(httpPath))) {\n yield* Http.routes(app).pipe(\n Result.mapError(invalid(\"app.ts\")),\n Effect.fromResult,\n );\n yield* removeGenerated(convexHttpPath, [\n yield* templates.http({\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n }),\n ]);\n return Option.none();\n }\n\n const http = (yield* bundleDeclaration(\"http.ts\")).module.default;\n if (!Http.isHttp(http)) {\n return yield* new InvalidDeclarationError({\n declarationPath: \"confect/http.ts\",\n reason: \"it must default-export Http.make(...).\",\n });\n }\n yield* Http.routes(app, http).pipe(\n Result.mapError(invalid(\"http.ts\")),\n Effect.fromResult,\n );\n\n const contents = yield* templates.declaredHttp({\n runtimeImportPath: (yield* fs.exists(\n path.join(confectDirectory, \"runtime.ts\"),\n ))\n ? yield* toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"runtime.ts\"),\n ),\n )\n : undefined,\n schemaImportPath: yield* toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"_generated\", \"schema.ts\"),\n ),\n ),\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n });\n const change = yield* writeFileString(convexHttpPath, contents);\n return Option.some({ change, convexFilePath: convexHttpPath });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,mBAAmB;AAEzB,MAAM,cAAc,OAAO,WAAW,WAAW,MAAc;CAE7D,QAAO,OADa,KAAK,KAAA,CACb,KAAK,OAAO,iBAAiB,KAAK,IAAI;AACpD,CAAC;;;;AAKD,MAAa,aAAa,OAAO,IAAI,aAAa;CAEhD,OAAO,QAAO,OADI,WAAW,WAAA,CACZ,OAAO,OAAO,YAAY,QAAQ,CAAC;AACtD,CAAC;AAED,MAAM,cAAc,OAAO,WAAW,WAAW,cAAsB;CACrE,MAAM,OAAO,OAAO,KAAK;CACzB,OAAO,YAAY,MAAM,KAAK,SAAS,OAAO,YAAY,KAAK,YAAY,CAAC;AAC9E,CAAC;AAED,MAAM,oBAAoB,OAAO,WAAW,WAAW,MAAc;CACnE,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,eAAe,OAAO,YAAY,IAAI;CAC5C,OAAO,OAAOA,OAAe,cAAc,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C,OAAO,UACT;CAEA,MAAM,WAAW,OAAOC,aAAuB;EAC7C,oBAAoB,OAAO,GAAG,OAC5B,KAAK,KAAK,kBAAkB,YAAY,CAC1C,KACI,OAAO,mBACL,KAAK,SACH,iBACA,KAAK,KAAK,kBAAkB,YAAY,CAC1C,CACF,IACA,KAAA;EACJ,kBAAkB,OAAO,mBACvB,KAAK,SACH,iBACA,KAAK,KAAK,kBAAkB,cAAc,WAAW,CACvD,CACF;EACA,gBAAgB,OAAO,mBACrB,KAAK,SAAS,iBAAiB,QAAQ,CACzC;CACF,CAAC;CACD,MAAM,SAAS,OAAO,gBAAgB,gBAAgB,QAAQ;CAC9D,OAAO,OAAO,KAAK;EAAE;EAAQ,gBAAgB;CAAe,CAAC;AAC/D,CAAC"}
@@ -162,14 +162,15 @@ const httpEffect = Effect.fnUntraced(function* ({ httpImportPath }) {
162
162
  * Emit `convex/http.ts` for a declared backend: the Convex router serving
163
163
  * `confect/http.ts`'s routes, typed by the generated database schema.
164
164
  */
165
- const declaredHttp = Effect.fnUntraced(function* ({ schemaImportPath, httpImportPath }) {
165
+ const declaredHttp = Effect.fnUntraced(function* ({ schemaImportPath, httpImportPath, runtimeImportPath }) {
166
166
  const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });
167
167
  yield* cbw.writeLine("// Generated by `confect codegen` from confect/http.ts. Do not edit.");
168
168
  yield* cbw.writeLine(`import { HttpRouter } from "@confect/server";`);
169
169
  yield* cbw.writeLine(`import schema from "${schemaImportPath}";`);
170
170
  yield* cbw.writeLine(`import http from "${httpImportPath}";`);
171
+ if (runtimeImportPath !== void 0) yield* cbw.writeLine(`import observability from "${runtimeImportPath}";`);
171
172
  yield* cbw.newLine();
172
- yield* cbw.writeLine(`export default HttpRouter.forSchema(schema)(http.routes, { api: http.api });`);
173
+ yield* cbw.writeLine(`export default HttpRouter.forSchema(schema)(http.routes, { api: http.api${runtimeImportPath === void 0 ? "" : ", observability"} });`);
173
174
  return yield* cbw.toString();
174
175
  });
175
176
  const crons = ({ cronsImportPath }) => cronsEffect({ cronsImportPath });
@@ -1 +1 @@
1
- {"version":3,"file":"templates.mjs","names":["renderSpecAssembly"],"sources":["../src/templates.ts"],"sourcesContent":["import type * as IdScope from \"@confect/core/IdScope\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport { CodeBlockWriter } from \"./CodeBlockWriter.js\";\nimport {\n render as renderSpecAssembly,\n type SpecAssemblyNode,\n} from \"./SpecAssemblyNode.js\";\n\n/**\n * Emit `convex/schema.ts` as a one-line re-export of the codegen-emitted deploy\n * schema in `confect/_generated/convexSchema.ts`. Deploy-time consumers (the\n * Convex CLI, `convex-test`) keep reading `convex/schema.ts`; the runtime\n * `DatabaseSchema` in `confect/_generated/schema.ts` is untouched by this\n * file.\n */\nexport const schema = ({\n convexSchemaImportPath,\n}: Parameters<typeof schemaEffect>[0]) =>\n schemaEffect({ convexSchemaImportPath });\n\nconst schemaEffect = Effect.fnUntraced(function* ({\n convexSchemaImportPath,\n}: {\n convexSchemaImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`export { default } from \"${convexSchemaImportPath}\";`);\n\n return yield* cbw.toString();\n});\n\ninterface TableModuleBinding {\n readonly importPath: string;\n readonly tableName: string;\n}\n\n/**\n * Emit `confect/_generated/schema.ts`—the runtime `DatabaseSchema` used by\n * impls and the per-group registries (and downstream by per-function bundles\n * for codec lookup). Every table wrapper at\n * `confect/_generated/tables/<name>.ts` is imported statically and registered\n * as a value entry on the `DatabaseSchema.make({...})` call. Per-table laziness\n * lives inside each `Table`: its `Fields` and `Doc` are lazy memoised getters\n * that only evaluate the user-supplied field-schema callback on first access,\n * so unused tables in a function bundle never pay schema-construction cost\n * despite the static import.\n *\n * The `DatabaseSchema` import is aliased to `$DatabaseSchema` because each\n * table is imported under its own (filename-derived) name; a table named\n * `DatabaseSchema` would otherwise collide with the library import and emit a\n * duplicate-binding file. The leading `$` makes the alias collision-proof:\n * `validateConfectTableIdentifier` requires names to match\n * `/^[a-zA-Z][a-zA-Z0-9_]*$/`, which forbids `$`, so no valid table import can\n * ever shadow it.\n */\nexport const runtimeSchema = ({\n tableModules,\n component = false,\n}: Parameters<typeof runtimeSchemaEffect>[0]) =>\n runtimeSchemaEffect({ tableModules, component });\n\nconst runtimeSchemaEffect = Effect.fnUntraced(function* ({\n tableModules,\n component = false,\n}: {\n tableModules: ReadonlyArray<TableModuleBinding>;\n component?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { DatabaseSchema as $DatabaseSchema } from \"@confect/server\";`,\n );\n\n if (tableModules.length > 0) {\n yield* cbw.blankLine();\n yield* Effect.forEach(tableModules, ({ tableName, importPath }) =>\n cbw.writeLine(`import ${tableName} from \"${importPath}\";`),\n );\n }\n\n yield* cbw.blankLine();\n\n if (component) {\n yield* cbw.writeLine(`import { target as $target } from \"./id.js\";`);\n }\n\n if (tableModules.length === 0) {\n yield* cbw.writeLine(\n `const databaseSchema: $DatabaseSchema.DatabaseSchema${component ? \"<{}, typeof $target>\" : \"\"} = $DatabaseSchema.make({}${component ? \", $target\" : \"\"});`,\n );\n } else {\n yield* cbw.writeLine(\n `const databaseSchema: $DatabaseSchema.DatabaseSchema<{`,\n );\n yield* cbw.indent(\n Effect.forEach(\n tableModules,\n ({ tableName }) =>\n cbw.writeLine(`readonly ${tableName}: typeof ${tableName};`),\n { discard: true },\n ),\n );\n yield* cbw.writeLine(\n `}${component ? \", typeof $target\" : \"\"}> = $DatabaseSchema.make({`,\n );\n yield* cbw.indent(\n Effect.gen(function* () {\n for (const { tableName } of tableModules) {\n yield* cbw.writeLine(`${tableName},`);\n }\n }),\n );\n yield* cbw.writeLine(`}${component ? \", $target\" : \"\"});`);\n }\n\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default databaseSchema;`);\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/convexSchema.ts`—the Convex deploy-time\n * `SchemaDefinition`. Imports every table from its generated wrapper at\n * `_generated/tables/<name>` and calls `defineSchema({...})` exactly once.\n * `Table.tableDefinition` lives in `@confect/server` because it is the\n * `defineTable` binding; the generated table wrappers themselves stay\n * client-safe (`Fields`/`Doc` from `@confect/core`).\n *\n * The `defineSchema` and `Table` imports are aliased with a leading `$` because\n * each table is imported under its own (filename-derived) name; a table named\n * `defineSchema` or `Table` would otherwise collide with the library import and\n * emit a duplicate-binding file. `validateConfectTableIdentifier` requires\n * names to match `/^[a-zA-Z][a-zA-Z0-9_]*$/`, which forbids `$`, so no valid\n * table import can ever shadow them.\n */\nexport const convexSchema = ({\n tableModules,\n}: Parameters<typeof convexSchemaEffect>[0]) =>\n convexSchemaEffect({ tableModules });\n\nconst convexSchemaEffect = Effect.fnUntraced(function* ({\n tableModules,\n}: {\n tableModules: ReadonlyArray<TableModuleBinding>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { defineSchema as $defineSchema } from \"convex/server\";`,\n );\n\n if (tableModules.length > 0) {\n yield* cbw.writeLine(`import { Table as $Table } from \"@confect/server\";`);\n yield* cbw.blankLine();\n yield* Effect.forEach(tableModules, ({ tableName, importPath }) =>\n cbw.writeLine(`import ${tableName} from \"${importPath}\";`),\n );\n }\n\n yield* cbw.blankLine();\n\n if (tableModules.length === 0) {\n yield* cbw.writeLine(`export default $defineSchema({});`);\n } else {\n yield* cbw.writeLine(`export default $defineSchema({`);\n yield* cbw.indent(\n Effect.gen(function* () {\n for (const { tableName } of tableModules) {\n yield* cbw.writeLine(\n `${tableName}: $Table.tableDefinition(${tableName}),`,\n );\n }\n }),\n );\n yield* cbw.writeLine(`});`);\n }\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/id.ts`—a type-constrained `Id` constructor and a\n * `TableNames` union derived from the user's `confect/tables/*.ts` filenames.\n * User-authored table modules import `Id` from this file to declare cross-table\n * id references without typing the destination name as a free string (and\n * without ever importing each other transitively).\n *\n * `Id` also accepts Convex system tables, with the component scope when\n * present. `TableNames` includes only user tables and resolves to `never` for\n * an empty table directory.\n */\nexport const id = ({ tableNames, scope }: Parameters<typeof idEffect>[0]) =>\n idEffect({ tableNames, scope });\n\nconst idEffect = Effect.fnUntraced(function* ({\n tableNames,\n scope,\n}: {\n tableNames: ReadonlyArray<string>;\n scope?: IdScope.Component<string> | undefined;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { GenericId${scope === undefined ? \"\" : \", IdScope\"} } from \"@confect/core\";`,\n );\n yield* cbw.writeLine(\n `import type { SystemTableNames } from \"convex/server\";`,\n );\n yield* cbw.blankLine();\n if (scope !== undefined) {\n yield* cbw.writeLine(\n // oxlint-disable-next-line effecttsgo/prefer-schema-over-json -- Emit an escaped TypeScript string literal, not a JSON payload.\n `export const scope = IdScope.component(${JSON.stringify(scope.slice(\"component:\".length))});`,\n );\n yield* cbw.writeLine(\n `export const target = { kind: \"component\", scope } as const;`,\n );\n }\n\n const union =\n tableNames.length === 0\n ? \"never\"\n : tableNames.map((n) => `\"${n}\"`).join(\" | \");\n yield* cbw.writeLine(`export type TableNames = ${union};`);\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n `export type Id<TableName extends TableNames | SystemTableNames> = GenericId.GenericId<TableName${scope === undefined ? \"\" : \", typeof scope\"}>;`,\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n `export const Id = <const TableName extends TableNames | SystemTableNames>(`,\n );\n yield* cbw.indent(cbw.writeLine(`tableName: TableName,`));\n yield* cbw.writeLine(\n `) => GenericId.GenericId(tableName${scope === undefined ? \"\" : \", scope\"});`,\n );\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/tables/<tableName>.ts`—a two-line wrapper that\n * imports the user-authored `UnnamedTable` and binds the file basename to it,\n * producing the fully-named `Table` value that downstream consumers (schema,\n * specs, impls) read.\n */\nexport const tableWrapper = ({\n tableName,\n unnamedImportPath,\n component = false,\n}: Parameters<typeof tableWrapperEffect>[0]) =>\n tableWrapperEffect({ tableName, unnamedImportPath, component });\n\nconst tableWrapperEffect = Effect.fnUntraced(function* ({\n tableName,\n unnamedImportPath,\n component = false,\n}: {\n tableName: string;\n unnamedImportPath: string;\n component?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import unnamed from \"${unnamedImportPath}\";`);\n if (component) yield* cbw.writeLine(`import { scope } from \"../id.js\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n `export default unnamed(\"${tableName}\"${component ? \", scope\" : \"\"});`,\n );\n\n return yield* cbw.toString();\n});\n\nexport const http = ({ httpImportPath }: Parameters<typeof httpEffect>[0]) =>\n httpEffect({ httpImportPath });\n\nconst httpEffect = Effect.fnUntraced(function* ({\n httpImportPath,\n}: {\n httpImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import http from \"${httpImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default http;`);\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `convex/http.ts` for a declared backend: the Convex router serving\n * `confect/http.ts`'s routes, typed by the generated database schema.\n */\nexport const declaredHttp = Effect.fnUntraced(function* ({\n schemaImportPath,\n httpImportPath,\n}: {\n schemaImportPath: string;\n httpImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n \"// Generated by `confect codegen` from confect/http.ts. Do not edit.\",\n );\n yield* cbw.writeLine(`import { HttpRouter } from \"@confect/server\";`);\n yield* cbw.writeLine(`import schema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import http from \"${httpImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(\n `export default HttpRouter.forSchema(schema)(http.routes, { api: http.api });`,\n );\n\n return yield* cbw.toString();\n});\n\nexport const crons = ({ cronsImportPath }: Parameters<typeof cronsEffect>[0]) =>\n cronsEffect({ cronsImportPath });\n\nconst cronsEffect = Effect.fnUntraced(function* ({\n cronsImportPath,\n}: {\n cronsImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import crons from \"${cronsImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default crons.convexCronJobs;`);\n\n return yield* cbw.toString();\n});\n\nexport const authConfig = ({\n authImportPath,\n}: Parameters<typeof authConfigEffect>[0]) =>\n authConfigEffect({ authImportPath });\n\nconst authConfigEffect = Effect.fnUntraced(function* ({\n authImportPath,\n}: {\n authImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import auth from \"${authImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default auth;`);\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/components.ts`—a typed registry of the Convex\n * components installed via `app.use(...)` in `convex/convex.config.ts`. Mirrors\n * the `components` export of Convex's generated `convex/_generated/api`: the\n * runtime value is `componentsGeneric()` (a name-preserving proxy), and each\n * entry is typed with the `ComponentApi` that component packages export from\n * `_generated/component.js`. Unlike `convex/_generated/api`, this file exists\n * before `convex codegen` ever runs, so impl modules can import it\n * safely—`confect codegen` bundles and evaluates each impl's import graph, and\n * `convex/_generated/api` doesn't exist yet at that point.\n *\n * The `as any` cast is confined here: `componentsGeneric()` is typed\n * `AnyChildComponents`, which deliberately doesn't overlap the precise registry\n * type; the `Components` annotation on the const supplies the real type.\n */\nexport const components = ({\n components: installedComponents,\n}: Parameters<typeof componentsEffect>[0]) =>\n componentsEffect({ components: installedComponents });\n\nconst componentsEffect = Effect.fnUntraced(function* ({\n components: installedComponents,\n}: {\n components: ReadonlyArray<{ name: string; typeImportPath: string }>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { componentsGeneric } from \"convex/server\";`);\n yield* cbw.blankLine();\n\n if (installedComponents.length === 0) {\n yield* cbw.writeLine(`export type Components = {};`);\n } else {\n yield* cbw.writeLine(`export type Components = {`);\n yield* cbw.indent(\n Effect.forEach(\n installedComponents,\n ({ name, typeImportPath }) =>\n cbw.writeLine(\n `\"${name}\": import(\"${typeImportPath}/_generated/component.js\").ComponentApi<\"${name}\">;`,\n ),\n { discard: true },\n ),\n );\n yield* cbw.writeLine(`};`);\n }\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n `export const components: Components = componentsGeneric() as any;`,\n );\n\n return yield* cbw.toString();\n});\n\nexport const refs = ({ specImportPath }: Parameters<typeof refsEffect>[0]) =>\n refsEffect({ specImportPath });\n\nconst refsEffect = Effect.fnUntraced(function* ({\n specImportPath,\n}: {\n specImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { Refs } from \"@confect/core\";`);\n yield* cbw.writeLine(`import spec from \"${specImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n `const refs: Refs.FromSpec<typeof spec> = Refs.make(spec);`,\n );\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default refs;`);\n\n return yield* cbw.toString();\n});\n\nexport const componentContract = Effect.fnUntraced(function* ({\n tableNames,\n}: {\n tableNames: ReadonlyArray<string>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n yield* cbw.writeLine('import { Component } from \"@confect/core\";');\n yield* cbw.writeLine('import spec from \"./spec.js\";');\n yield* cbw.writeLine('import { scope } from \"./id.js\";');\n yield* cbw.blankLine();\n const names = Array.map(\n [...tableNames, \"_storage\", \"_scheduled_functions\"],\n (name) => `\"${name}\"`,\n );\n yield* cbw.writeLine(\n `const component: Component.Component<typeof spec, typeof scope, ${names.join(\" | \")}> = Component.make(spec, scope, [${names.join(\", \")}]);`,\n );\n yield* cbw.writeLine(\"export default component;\");\n return yield* cbw.toString();\n});\n\n/**\n * Emit `_generated/docs.ts`: one named `type <table>` alias per table plus a\n * `Docs` registry. Each alias is `Document.Document<typeof schemaDefinition,\n * \"<table>\">`, so it stays structurally exact while giving the document a\n * _name_—declaration emit then prints e.g. `NotesDoc` instead of expanding the\n * row structure. A `type` alias (rather than an extending `interface`) is used\n * so it works for every document shape: object tables, but also union schemas\n * (`Schema.Union`) and other non-object documents, which an `interface …\n * extends` cannot represent (TS2312). The registry is threaded into the\n * generated `DatabaseReader`/`DatabaseWriter` tags so query/mutation helpers\n * print named documents with no user annotations.\n */\nexport const docs = ({\n schemaImportPath,\n tables,\n}: Parameters<typeof docsEffect>[0]) =>\n docsEffect({ schemaImportPath, tables });\n\nconst docsEffect = Effect.fnUntraced(function* ({\n schemaImportPath,\n tables,\n}: {\n schemaImportPath: string;\n tables: ReadonlyArray<{ tableName: string; docName: string }>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n // With no tables there is nothing to import—emitting the (unused) imports\n // would trip `noUnusedLocals`.\n if (tables.length === 0) {\n yield* cbw.writeLine(`export interface Docs {}`);\n return yield* cbw.toString();\n }\n\n yield* cbw.writeLine(`import type { Document } from \"@confect/server\";`);\n yield* cbw.writeLine(\n `import type schemaDefinition from \"${schemaImportPath}\";`,\n );\n yield* cbw.blankLine();\n\n for (const { tableName, docName } of tables) {\n yield* cbw.writeLine(\n `export type ${docName} = Document.Document<typeof schemaDefinition, \"${tableName}\">;`,\n );\n }\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(`export interface Docs {`);\n yield* cbw.indent(\n Effect.gen(function* () {\n for (const { tableName, docName } of tables) {\n yield* cbw.writeLine(`${tableName}: ${docName};`);\n }\n }),\n );\n yield* cbw.writeLine(`}`);\n\n return yield* cbw.toString();\n});\n\nexport const registeredFunctionsForGroup = ({\n spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n groupPath = \"\",\n required = [],\n runtimeImportPath,\n}: Parameters<typeof registeredFunctionsForGroupEffect>[0]) =>\n registeredFunctionsForGroupEffect({\n spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n groupPath,\n required,\n runtimeImportPath,\n });\n\nconst registeredFunctionsForGroupEffect = Effect.fnUntraced(function* ({\n spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n groupPath = \"\",\n required = [],\n runtimeImportPath,\n}: {\n spec: GroupSpec.AnyWithProps;\n schemaImportPath: string;\n specImportPath: string;\n implImportPath: string;\n groupPath?: string;\n runtimeImportPath?: string | undefined;\n required?: ReadonlyArray<{ readonly key: string }>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n if (runtimeImportPath !== undefined) {\n yield* cbw.writeLine(\n 'import * as RegisteredFunction from \"@confect/server/RegisteredFunction\";',\n );\n yield* cbw.writeLine('import * as Layer from \"effect/Layer\";');\n yield* cbw.writeLine(`import observability from \"${runtimeImportPath}\";`);\n }\n const useNode = spec.runtime === \"Node\";\n\n const hasConfectFunctions = (group: GroupSpec.AnyWithProps): boolean =>\n Object.values(group.functions).some(\n (functionSpec) => functionSpec.functionProvenance._tag === \"Confect\",\n ) || Object.values(group.groups).some(hasConfectFunctions);\n const forwarding = !useNode && hasConfectFunctions(spec);\n\n if (useNode) {\n yield* cbw.writeLine(\n `import { RegisteredNodeFunction } from \"@confect/server/node\";`,\n );\n } else if (!forwarding) {\n yield* cbw.writeLine(\n `import { RegisteredFunctions } from \"@confect/server\";`,\n );\n } else {\n yield* cbw.writeLine(\n `import { ConvexFunctionDefinitions, RegisteredConvexFunction, type RegisteredFunctions } from \"@confect/server\";`,\n );\n }\n\n if (required.length > 0) {\n yield* cbw.writeLine(`import { GroupImpl } from \"@confect/server\";`);\n }\n yield* cbw.writeLine(`import databaseSchema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import groupLayer from \"${implImportPath}\";`);\n yield* cbw.blankLine();\n // The group's own leaf spec is referenced type-only (`typeof import(...)`),\n // so the spec module is erased at transpile time and never enters the\n // per-function bundle; only `databaseSchema` and the impl are runtime\n // imports. Typing from the leaf spec (not the project-wide assembled spec)\n // keeps the registry's type dependent solely on its own group.\n const finalizedLayer =\n required.length === 0\n ? \"groupLayer\"\n : // oxlint-disable-next-line effecttsgo/prefer-schema-over-json -- Emit escaped TypeScript string literals, not JSON payloads.\n `groupLayer.pipe(GroupImpl.finalize({ required: [${required.map(({ key }) => `{ key: ${JSON.stringify(key)} }`).join(\", \")}], groupPath: ${JSON.stringify(groupPath)} }))`;\n const groupLayer =\n runtimeImportPath === undefined\n ? finalizedLayer\n : `${finalizedLayer}.pipe(Layer.merge(Layer.succeed(RegisteredFunction.Observability, observability)))`;\n const specType = `typeof import(\"${specImportPath}\")[\"default\"]`;\n if (useNode) {\n yield* cbw.writeLine(\n `export default RegisteredNodeFunction.buildForGroup<${specType}>(databaseSchema, ${groupLayer});`,\n );\n } else if (!forwarding) {\n yield* cbw.writeLine(\n `export default RegisteredFunctions.buildForGroup<${specType}>(databaseSchema, ${groupLayer});`,\n );\n } else {\n const bindings = (group: GroupSpec.AnyWithProps, path: string): string =>\n `{\n${[\n ...Object.entries(group.functions).map(([name, functionSpec]) => {\n const key = JSON.stringify(name);\n const definition = `${path}[${key}]`;\n return `[${key}]: ${\n functionSpec.functionProvenance._tag === \"Convex\"\n ? `${definition}.handler`\n : `RegisteredConvexFunction.register({ ...${definition}, handler: forward(${definition}.handler) })`\n },`;\n }),\n ...Object.entries(group.groups).map(([name, child]) => {\n const key = JSON.stringify(name);\n return `[${key}]: ${bindings(child, `${path}[${key}]`)},`;\n }),\n].join(\"\\n\")}\n}`;\n yield* cbw.writeLine(`const forward = <Ctx, Args, Returns>(handler: (ctx: Ctx, args: Args) => Promise<Returns>) => (ctx: Ctx, args: Args) => handler(ctx, args);\n\nconst definitions = ConvexFunctionDefinitions.buildForGroup<${specType}>(databaseSchema, ${groupLayer});\n\nexport default ${bindings(spec, \"definitions\")} as RegisteredFunctions.RegisteredFunctionsForGroupSpec<${specType}>;`);\n }\n\n return yield* cbw.toString();\n});\n\nexport const services = ({\n schemaImportPath,\n component = false,\n}: Parameters<typeof servicesEffect>[0]) =>\n servicesEffect({ schemaImportPath, component });\n\nconst servicesEffect = Effect.fnUntraced(function* ({\n schemaImportPath,\n component = false,\n}: {\n schemaImportPath: string;\n component?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n // Imports\n yield* cbw.writeLine(\"import {\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"ActionCtx as ActionCtx_,\");\n yield* cbw.writeLine(\"ActionRunner as ActionRunner_,\");\n yield* cbw.writeLine(\"Auth as Auth_,\");\n yield* cbw.writeLine(\"type DataModel,\");\n yield* cbw.writeLine(\"DatabaseReader as DatabaseReader_,\");\n yield* cbw.writeLine(\"DatabaseWriter as DatabaseWriter_,\");\n yield* cbw.writeLine(\"ExecutionMetadata as ExecutionMetadata_,\");\n yield* cbw.writeLine(\"MutationCtx as MutationCtx_,\");\n yield* cbw.writeLine(\"MutationRunner as MutationRunner_,\");\n yield* cbw.writeLine(\n \"MutationTransactionContext as MutationTransactionContext_,\",\n );\n yield* cbw.writeLine(\"QueryCtx as QueryCtx_,\");\n yield* cbw.writeLine(\"QueryRunner as QueryRunner_,\");\n yield* cbw.writeLine(\n \"QueryTransactionContext as QueryTransactionContext_,\",\n );\n yield* cbw.writeLine(\"RequestMetadata as RequestMetadata_,\");\n yield* cbw.writeLine(\"Scheduler as Scheduler_,\");\n if (!component) yield* cbw.writeLine(\"Storage as Storage_,\");\n yield* cbw.writeLine(\"StorageActionWriter as StorageActionWriter_,\");\n yield* cbw.writeLine(\"StorageReader as StorageReader_,\");\n yield* cbw.writeLine(\"StorageWriter as StorageWriter_,\");\n yield* cbw.writeLine(\"TransactionMetadata as TransactionMetadata_,\");\n yield* cbw.writeLine(\"VectorSearch as VectorSearch_,\");\n }),\n );\n yield* cbw.writeLine(`} from \"@confect/server\";`);\n yield* cbw.writeLine(\n `import type schemaDefinition from \"${schemaImportPath}\";`,\n );\n yield* cbw.writeLine(`import type { Docs } from \"./docs.js\";`);\n if (component) yield* cbw.writeLine(`import type { scope } from \"./id.js\";`);\n yield* cbw.blankLine();\n\n // Auth\n if (!component) {\n yield* cbw.writeLine(\"export const Auth = Auth_.Auth;\");\n yield* cbw.writeLine(\"export type Auth = typeof Auth.Identifier;\");\n }\n yield* cbw.writeLine(\"export const MutationAuth = Auth_.MutationAuth;\");\n yield* cbw.writeLine(\n \"export type MutationAuth = typeof MutationAuth.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const ExecutionMetadata = ExecutionMetadata_.ExecutionMetadata;\",\n );\n yield* cbw.writeLine(\n \"export type ExecutionMetadata = typeof ExecutionMetadata.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const RequestMetadata = RequestMetadata_.RequestMetadata;\",\n );\n yield* cbw.writeLine(\n \"export type RequestMetadata = typeof RequestMetadata.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const TransactionMetadata = TransactionMetadata_.TransactionMetadata;\",\n );\n yield* cbw.writeLine(\n \"export type TransactionMetadata = typeof TransactionMetadata.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // Scheduler\n yield* cbw.writeLine(\n component\n ? \"export const Scheduler = Scheduler_.forScope<typeof scope>();\"\n : \"export const Scheduler = Scheduler_.Scheduler;\",\n );\n yield* cbw.writeLine(\"export type Scheduler = typeof Scheduler.Identifier;\");\n yield* cbw.blankLine();\n\n if (!component) {\n yield* cbw.writeLine(\"export const Storage = Storage_.Storage;\");\n yield* cbw.writeLine(\"export type Storage = typeof Storage.Identifier;\");\n yield* cbw.blankLine();\n }\n\n // StorageReader\n yield* cbw.writeLine(\n `export const StorageReader = StorageReader_.StorageReader${component ? \".forScope<typeof scope>()\" : \"\"};`,\n );\n yield* cbw.writeLine(\n \"export type StorageReader = typeof StorageReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageWriter\n yield* cbw.writeLine(\n `export const StorageWriter = StorageWriter_.StorageWriter${component ? \".forScope<typeof scope>()\" : \"\"};`,\n );\n yield* cbw.writeLine(\n \"export type StorageWriter = typeof StorageWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageActionWriter\n yield* cbw.writeLine(\n `export const StorageActionWriter = StorageActionWriter_.StorageActionWriter${component ? \".forScope<typeof scope>()\" : \"\"};`,\n );\n yield* cbw.writeLine(\n \"export type StorageActionWriter = typeof StorageActionWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // VectorSearch\n yield* cbw.writeLine(\n \"export const VectorSearch: VectorSearch_.VectorSearchTag<\",\n );\n yield* cbw.indent(\n cbw.writeLine(\"DataModel.FromSchema<typeof schemaDefinition>\"),\n );\n yield* cbw.writeLine(\n \"> = VectorSearch_.VectorSearch<DataModel.FromSchema<typeof schemaDefinition>>();\",\n );\n yield* cbw.writeLine(\n \"export type VectorSearch = typeof VectorSearch.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseReader\n yield* cbw.writeLine(\n \"export const DatabaseReader: DatabaseReader_.DatabaseReaderTag<\",\n );\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"typeof schemaDefinition,\");\n yield* cbw.writeLine(\"Docs\");\n }),\n );\n yield* cbw.writeLine(\n \"> = DatabaseReader_.DatabaseReader<typeof schemaDefinition, Docs>();\",\n );\n yield* cbw.writeLine(\n \"export type DatabaseReader = typeof DatabaseReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseWriter\n yield* cbw.writeLine(\n \"export const DatabaseWriter: DatabaseWriter_.DatabaseWriterTag<\",\n );\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"typeof schemaDefinition,\");\n yield* cbw.writeLine(\"Docs\");\n }),\n );\n yield* cbw.writeLine(\n \"> = DatabaseWriter_.DatabaseWriter<typeof schemaDefinition, Docs>();\",\n );\n yield* cbw.writeLine(\n \"export type DatabaseWriter = typeof DatabaseWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const QueryTransactionContext = QueryTransactionContext_.QueryTransactionContext;\",\n );\n yield* cbw.writeLine(\n \"export type QueryTransactionContext = typeof QueryTransactionContext.Identifier;\",\n );\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n \"export const MutationTransactionContext = MutationTransactionContext_.MutationTransactionContext;\",\n );\n yield* cbw.writeLine(\n \"export type MutationTransactionContext = typeof MutationTransactionContext.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryRunner\n yield* cbw.writeLine(\"export const QueryRunner = QueryRunner_.QueryRunner;\");\n yield* cbw.writeLine(\n \"export type QueryRunner = typeof QueryRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // MutationRunner\n yield* cbw.writeLine(\n \"export const MutationRunner = MutationRunner_.MutationRunner;\",\n );\n yield* cbw.writeLine(\n \"export type MutationRunner = typeof MutationRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // ActionRunner\n yield* cbw.writeLine(\n \"export const ActionRunner = ActionRunner_.ActionRunner;\",\n );\n yield* cbw.writeLine(\n \"export type ActionRunner = typeof ActionRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryCtx\n yield* cbw.writeLine(\"export const QueryCtx: QueryCtx_.QueryCtxTag<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\"> = QueryCtx_.QueryCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\"export type QueryCtx = typeof QueryCtx.Identifier;\");\n yield* cbw.blankLine();\n\n // MutationCtx\n yield* cbw.writeLine(\n \"export const MutationCtx: MutationCtx_.MutationCtxTag<\",\n );\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\"> = MutationCtx_.MutationCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\n \"export type MutationCtx = typeof MutationCtx.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // ActionCtx\n yield* cbw.writeLine(\"export const ActionCtx: ActionCtx_.ActionCtxTag<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\"> = ActionCtx_.ActionCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\"export type ActionCtx = typeof ActionCtx.Identifier;\");\n\n return yield* cbw.toString();\n});\n\nexport const assembledSpec = ({\n nodes,\n}: {\n nodes: ReadonlyArray<SpecAssemblyNode>;\n}) => renderSpecAssembly(nodes);\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,UAAU,EACrB,6BAEA,aAAa,EAAE,uBAAuB,CAAC;AAEzC,MAAM,eAAe,OAAO,WAAW,WAAW,EAChD,0BAGC;CACD,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,EAAE,CAAC;CAE3D,OAAO,IAAI,UAAU,4BAA4B,uBAAuB,GAAG;CAE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rG,CACF;CACA,OAAO,IAAI,UAAU,MAAM;CAC3B,OAAO,IAAI,UAAU,oDAAoD;CACzE,OAAO,IAAI,UAAU;CAGrB,OAAO,IAAI,UACT,wDACF;CACA,OAAO,IAAI,OACT,IAAI,UACF,oEAAoE,YAAY,mBAAmB,IACrG,CACF;CACA,OAAO,IAAI,UAAU,+BAA+B;CACpD,OAAO,IAAI,OACT,IAAI,UACF,oEAAoE,YAAY,mBAAmB,IACrG,CACF;CACA,OAAO,IAAI,UAAU,MAAM;CAC3B,OAAO,IAAI,UACT,0DACF;CACA,OAAO,IAAI,UAAU;CAGrB,OAAO,IAAI,UAAU,kDAAkD;CACvE,OAAO,IAAI,OACT,IAAI,UACF,oEAAoE,YAAY,mBAAmB,IACrG,CACF;CACA,OAAO,IAAI,UAAU,2BAA2B;CAChD,OAAO,IAAI,OACT,IAAI,UACF,oEAAoE,YAAY,mBAAmB,IACrG,CACF;CACA,OAAO,IAAI,UAAU,MAAM;CAC3B,OAAO,IAAI,UAAU,sDAAsD;CAE3E,OAAO,OAAO,IAAI,SAAS;AAC7B,CAAC;AAED,MAAa,iBAAiB,EAC5B,YAGIA,OAAmB,KAAK"}
1
+ {"version":3,"file":"templates.mjs","names":["renderSpecAssembly"],"sources":["../src/templates.ts"],"sourcesContent":["import type * as IdScope from \"@confect/core/IdScope\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport { CodeBlockWriter } from \"./CodeBlockWriter.js\";\nimport {\n render as renderSpecAssembly,\n type SpecAssemblyNode,\n} from \"./SpecAssemblyNode.js\";\n\n/**\n * Emit `convex/schema.ts` as a one-line re-export of the codegen-emitted deploy\n * schema in `confect/_generated/convexSchema.ts`. Deploy-time consumers (the\n * Convex CLI, `convex-test`) keep reading `convex/schema.ts`; the runtime\n * `DatabaseSchema` in `confect/_generated/schema.ts` is untouched by this\n * file.\n */\nexport const schema = ({\n convexSchemaImportPath,\n}: Parameters<typeof schemaEffect>[0]) =>\n schemaEffect({ convexSchemaImportPath });\n\nconst schemaEffect = Effect.fnUntraced(function* ({\n convexSchemaImportPath,\n}: {\n convexSchemaImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`export { default } from \"${convexSchemaImportPath}\";`);\n\n return yield* cbw.toString();\n});\n\ninterface TableModuleBinding {\n readonly importPath: string;\n readonly tableName: string;\n}\n\n/**\n * Emit `confect/_generated/schema.ts`—the runtime `DatabaseSchema` used by\n * impls and the per-group registries (and downstream by per-function bundles\n * for codec lookup). Every table wrapper at\n * `confect/_generated/tables/<name>.ts` is imported statically and registered\n * as a value entry on the `DatabaseSchema.make({...})` call. Per-table laziness\n * lives inside each `Table`: its `Fields` and `Doc` are lazy memoised getters\n * that only evaluate the user-supplied field-schema callback on first access,\n * so unused tables in a function bundle never pay schema-construction cost\n * despite the static import.\n *\n * The `DatabaseSchema` import is aliased to `$DatabaseSchema` because each\n * table is imported under its own (filename-derived) name; a table named\n * `DatabaseSchema` would otherwise collide with the library import and emit a\n * duplicate-binding file. The leading `$` makes the alias collision-proof:\n * `validateConfectTableIdentifier` requires names to match\n * `/^[a-zA-Z][a-zA-Z0-9_]*$/`, which forbids `$`, so no valid table import can\n * ever shadow it.\n */\nexport const runtimeSchema = ({\n tableModules,\n component = false,\n}: Parameters<typeof runtimeSchemaEffect>[0]) =>\n runtimeSchemaEffect({ tableModules, component });\n\nconst runtimeSchemaEffect = Effect.fnUntraced(function* ({\n tableModules,\n component = false,\n}: {\n tableModules: ReadonlyArray<TableModuleBinding>;\n component?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { DatabaseSchema as $DatabaseSchema } from \"@confect/server\";`,\n );\n\n if (tableModules.length > 0) {\n yield* cbw.blankLine();\n yield* Effect.forEach(tableModules, ({ tableName, importPath }) =>\n cbw.writeLine(`import ${tableName} from \"${importPath}\";`),\n );\n }\n\n yield* cbw.blankLine();\n\n if (component) {\n yield* cbw.writeLine(`import { target as $target } from \"./id.js\";`);\n }\n\n if (tableModules.length === 0) {\n yield* cbw.writeLine(\n `const databaseSchema: $DatabaseSchema.DatabaseSchema${component ? \"<{}, typeof $target>\" : \"\"} = $DatabaseSchema.make({}${component ? \", $target\" : \"\"});`,\n );\n } else {\n yield* cbw.writeLine(\n `const databaseSchema: $DatabaseSchema.DatabaseSchema<{`,\n );\n yield* cbw.indent(\n Effect.forEach(\n tableModules,\n ({ tableName }) =>\n cbw.writeLine(`readonly ${tableName}: typeof ${tableName};`),\n { discard: true },\n ),\n );\n yield* cbw.writeLine(\n `}${component ? \", typeof $target\" : \"\"}> = $DatabaseSchema.make({`,\n );\n yield* cbw.indent(\n Effect.gen(function* () {\n for (const { tableName } of tableModules) {\n yield* cbw.writeLine(`${tableName},`);\n }\n }),\n );\n yield* cbw.writeLine(`}${component ? \", $target\" : \"\"});`);\n }\n\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default databaseSchema;`);\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/convexSchema.ts`—the Convex deploy-time\n * `SchemaDefinition`. Imports every table from its generated wrapper at\n * `_generated/tables/<name>` and calls `defineSchema({...})` exactly once.\n * `Table.tableDefinition` lives in `@confect/server` because it is the\n * `defineTable` binding; the generated table wrappers themselves stay\n * client-safe (`Fields`/`Doc` from `@confect/core`).\n *\n * The `defineSchema` and `Table` imports are aliased with a leading `$` because\n * each table is imported under its own (filename-derived) name; a table named\n * `defineSchema` or `Table` would otherwise collide with the library import and\n * emit a duplicate-binding file. `validateConfectTableIdentifier` requires\n * names to match `/^[a-zA-Z][a-zA-Z0-9_]*$/`, which forbids `$`, so no valid\n * table import can ever shadow them.\n */\nexport const convexSchema = ({\n tableModules,\n}: Parameters<typeof convexSchemaEffect>[0]) =>\n convexSchemaEffect({ tableModules });\n\nconst convexSchemaEffect = Effect.fnUntraced(function* ({\n tableModules,\n}: {\n tableModules: ReadonlyArray<TableModuleBinding>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { defineSchema as $defineSchema } from \"convex/server\";`,\n );\n\n if (tableModules.length > 0) {\n yield* cbw.writeLine(`import { Table as $Table } from \"@confect/server\";`);\n yield* cbw.blankLine();\n yield* Effect.forEach(tableModules, ({ tableName, importPath }) =>\n cbw.writeLine(`import ${tableName} from \"${importPath}\";`),\n );\n }\n\n yield* cbw.blankLine();\n\n if (tableModules.length === 0) {\n yield* cbw.writeLine(`export default $defineSchema({});`);\n } else {\n yield* cbw.writeLine(`export default $defineSchema({`);\n yield* cbw.indent(\n Effect.gen(function* () {\n for (const { tableName } of tableModules) {\n yield* cbw.writeLine(\n `${tableName}: $Table.tableDefinition(${tableName}),`,\n );\n }\n }),\n );\n yield* cbw.writeLine(`});`);\n }\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/id.ts`—a type-constrained `Id` constructor and a\n * `TableNames` union derived from the user's `confect/tables/*.ts` filenames.\n * User-authored table modules import `Id` from this file to declare cross-table\n * id references without typing the destination name as a free string (and\n * without ever importing each other transitively).\n *\n * `Id` also accepts Convex system tables, with the component scope when\n * present. `TableNames` includes only user tables and resolves to `never` for\n * an empty table directory.\n */\nexport const id = ({ tableNames, scope }: Parameters<typeof idEffect>[0]) =>\n idEffect({ tableNames, scope });\n\nconst idEffect = Effect.fnUntraced(function* ({\n tableNames,\n scope,\n}: {\n tableNames: ReadonlyArray<string>;\n scope?: IdScope.Component<string> | undefined;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { GenericId${scope === undefined ? \"\" : \", IdScope\"} } from \"@confect/core\";`,\n );\n yield* cbw.writeLine(\n `import type { SystemTableNames } from \"convex/server\";`,\n );\n yield* cbw.blankLine();\n if (scope !== undefined) {\n yield* cbw.writeLine(\n // oxlint-disable-next-line effecttsgo/prefer-schema-over-json -- Emit an escaped TypeScript string literal, not a JSON payload.\n `export const scope = IdScope.component(${JSON.stringify(scope.slice(\"component:\".length))});`,\n );\n yield* cbw.writeLine(\n `export const target = { kind: \"component\", scope } as const;`,\n );\n }\n\n const union =\n tableNames.length === 0\n ? \"never\"\n : tableNames.map((n) => `\"${n}\"`).join(\" | \");\n yield* cbw.writeLine(`export type TableNames = ${union};`);\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n `export type Id<TableName extends TableNames | SystemTableNames> = GenericId.GenericId<TableName${scope === undefined ? \"\" : \", typeof scope\"}>;`,\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n `export const Id = <const TableName extends TableNames | SystemTableNames>(`,\n );\n yield* cbw.indent(cbw.writeLine(`tableName: TableName,`));\n yield* cbw.writeLine(\n `) => GenericId.GenericId(tableName${scope === undefined ? \"\" : \", scope\"});`,\n );\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/tables/<tableName>.ts`—a two-line wrapper that\n * imports the user-authored `UnnamedTable` and binds the file basename to it,\n * producing the fully-named `Table` value that downstream consumers (schema,\n * specs, impls) read.\n */\nexport const tableWrapper = ({\n tableName,\n unnamedImportPath,\n component = false,\n}: Parameters<typeof tableWrapperEffect>[0]) =>\n tableWrapperEffect({ tableName, unnamedImportPath, component });\n\nconst tableWrapperEffect = Effect.fnUntraced(function* ({\n tableName,\n unnamedImportPath,\n component = false,\n}: {\n tableName: string;\n unnamedImportPath: string;\n component?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import unnamed from \"${unnamedImportPath}\";`);\n if (component) yield* cbw.writeLine(`import { scope } from \"../id.js\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n `export default unnamed(\"${tableName}\"${component ? \", scope\" : \"\"});`,\n );\n\n return yield* cbw.toString();\n});\n\nexport const http = ({ httpImportPath }: Parameters<typeof httpEffect>[0]) =>\n httpEffect({ httpImportPath });\n\nconst httpEffect = Effect.fnUntraced(function* ({\n httpImportPath,\n}: {\n httpImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import http from \"${httpImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default http;`);\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `convex/http.ts` for a declared backend: the Convex router serving\n * `confect/http.ts`'s routes, typed by the generated database schema.\n */\nexport const declaredHttp = Effect.fnUntraced(function* ({\n schemaImportPath,\n httpImportPath,\n runtimeImportPath,\n}: {\n schemaImportPath: string;\n httpImportPath: string;\n runtimeImportPath?: string | undefined;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n \"// Generated by `confect codegen` from confect/http.ts. Do not edit.\",\n );\n yield* cbw.writeLine(`import { HttpRouter } from \"@confect/server\";`);\n yield* cbw.writeLine(`import schema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import http from \"${httpImportPath}\";`);\n if (runtimeImportPath !== undefined)\n yield* cbw.writeLine(`import observability from \"${runtimeImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(\n `export default HttpRouter.forSchema(schema)(http.routes, { api: http.api${runtimeImportPath === undefined ? \"\" : \", observability\"} });`,\n );\n\n return yield* cbw.toString();\n});\n\nexport const crons = ({ cronsImportPath }: Parameters<typeof cronsEffect>[0]) =>\n cronsEffect({ cronsImportPath });\n\nconst cronsEffect = Effect.fnUntraced(function* ({\n cronsImportPath,\n}: {\n cronsImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import crons from \"${cronsImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default crons.convexCronJobs;`);\n\n return yield* cbw.toString();\n});\n\nexport const authConfig = ({\n authImportPath,\n}: Parameters<typeof authConfigEffect>[0]) =>\n authConfigEffect({ authImportPath });\n\nconst authConfigEffect = Effect.fnUntraced(function* ({\n authImportPath,\n}: {\n authImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import auth from \"${authImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default auth;`);\n\n return yield* cbw.toString();\n});\n\n/**\n * Emit `confect/_generated/components.ts`—a typed registry of the Convex\n * components installed via `app.use(...)` in `convex/convex.config.ts`. Mirrors\n * the `components` export of Convex's generated `convex/_generated/api`: the\n * runtime value is `componentsGeneric()` (a name-preserving proxy), and each\n * entry is typed with the `ComponentApi` that component packages export from\n * `_generated/component.js`. Unlike `convex/_generated/api`, this file exists\n * before `convex codegen` ever runs, so impl modules can import it\n * safely—`confect codegen` bundles and evaluates each impl's import graph, and\n * `convex/_generated/api` doesn't exist yet at that point.\n *\n * The `as any` cast is confined here: `componentsGeneric()` is typed\n * `AnyChildComponents`, which deliberately doesn't overlap the precise registry\n * type; the `Components` annotation on the const supplies the real type.\n */\nexport const components = ({\n components: installedComponents,\n}: Parameters<typeof componentsEffect>[0]) =>\n componentsEffect({ components: installedComponents });\n\nconst componentsEffect = Effect.fnUntraced(function* ({\n components: installedComponents,\n}: {\n components: ReadonlyArray<{ name: string; typeImportPath: string }>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { componentsGeneric } from \"convex/server\";`);\n yield* cbw.blankLine();\n\n if (installedComponents.length === 0) {\n yield* cbw.writeLine(`export type Components = {};`);\n } else {\n yield* cbw.writeLine(`export type Components = {`);\n yield* cbw.indent(\n Effect.forEach(\n installedComponents,\n ({ name, typeImportPath }) =>\n cbw.writeLine(\n `\"${name}\": import(\"${typeImportPath}/_generated/component.js\").ComponentApi<\"${name}\">;`,\n ),\n { discard: true },\n ),\n );\n yield* cbw.writeLine(`};`);\n }\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n `export const components: Components = componentsGeneric() as any;`,\n );\n\n return yield* cbw.toString();\n});\n\nexport const refs = ({ specImportPath }: Parameters<typeof refsEffect>[0]) =>\n refsEffect({ specImportPath });\n\nconst refsEffect = Effect.fnUntraced(function* ({\n specImportPath,\n}: {\n specImportPath: string;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { Refs } from \"@confect/core\";`);\n yield* cbw.writeLine(`import spec from \"${specImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n `const refs: Refs.FromSpec<typeof spec> = Refs.make(spec);`,\n );\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default refs;`);\n\n return yield* cbw.toString();\n});\n\nexport const componentContract = Effect.fnUntraced(function* ({\n tableNames,\n}: {\n tableNames: ReadonlyArray<string>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n yield* cbw.writeLine('import { Component } from \"@confect/core\";');\n yield* cbw.writeLine('import spec from \"./spec.js\";');\n yield* cbw.writeLine('import { scope } from \"./id.js\";');\n yield* cbw.blankLine();\n const names = Array.map(\n [...tableNames, \"_storage\", \"_scheduled_functions\"],\n (name) => `\"${name}\"`,\n );\n yield* cbw.writeLine(\n `const component: Component.Component<typeof spec, typeof scope, ${names.join(\" | \")}> = Component.make(spec, scope, [${names.join(\", \")}]);`,\n );\n yield* cbw.writeLine(\"export default component;\");\n return yield* cbw.toString();\n});\n\n/**\n * Emit `_generated/docs.ts`: one named `type <table>` alias per table plus a\n * `Docs` registry. Each alias is `Document.Document<typeof schemaDefinition,\n * \"<table>\">`, so it stays structurally exact while giving the document a\n * _name_—declaration emit then prints e.g. `NotesDoc` instead of expanding the\n * row structure. A `type` alias (rather than an extending `interface`) is used\n * so it works for every document shape: object tables, but also union schemas\n * (`Schema.Union`) and other non-object documents, which an `interface …\n * extends` cannot represent (TS2312). The registry is threaded into the\n * generated `DatabaseReader`/`DatabaseWriter` tags so query/mutation helpers\n * print named documents with no user annotations.\n */\nexport const docs = ({\n schemaImportPath,\n tables,\n}: Parameters<typeof docsEffect>[0]) =>\n docsEffect({ schemaImportPath, tables });\n\nconst docsEffect = Effect.fnUntraced(function* ({\n schemaImportPath,\n tables,\n}: {\n schemaImportPath: string;\n tables: ReadonlyArray<{ tableName: string; docName: string }>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n // With no tables there is nothing to import—emitting the (unused) imports\n // would trip `noUnusedLocals`.\n if (tables.length === 0) {\n yield* cbw.writeLine(`export interface Docs {}`);\n return yield* cbw.toString();\n }\n\n yield* cbw.writeLine(`import type { Document } from \"@confect/server\";`);\n yield* cbw.writeLine(\n `import type schemaDefinition from \"${schemaImportPath}\";`,\n );\n yield* cbw.blankLine();\n\n for (const { tableName, docName } of tables) {\n yield* cbw.writeLine(\n `export type ${docName} = Document.Document<typeof schemaDefinition, \"${tableName}\">;`,\n );\n }\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(`export interface Docs {`);\n yield* cbw.indent(\n Effect.gen(function* () {\n for (const { tableName, docName } of tables) {\n yield* cbw.writeLine(`${tableName}: ${docName};`);\n }\n }),\n );\n yield* cbw.writeLine(`}`);\n\n return yield* cbw.toString();\n});\n\nexport const registeredFunctionsForGroup = ({\n spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n groupPath = \"\",\n required = [],\n runtimeImportPath,\n}: Parameters<typeof registeredFunctionsForGroupEffect>[0]) =>\n registeredFunctionsForGroupEffect({\n spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n groupPath,\n required,\n runtimeImportPath,\n });\n\nconst registeredFunctionsForGroupEffect = Effect.fnUntraced(function* ({\n spec,\n schemaImportPath,\n specImportPath,\n implImportPath,\n groupPath = \"\",\n required = [],\n runtimeImportPath,\n}: {\n spec: GroupSpec.AnyWithProps;\n schemaImportPath: string;\n specImportPath: string;\n implImportPath: string;\n groupPath?: string;\n runtimeImportPath?: string | undefined;\n required?: ReadonlyArray<{ readonly key: string }>;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n if (runtimeImportPath !== undefined) {\n yield* cbw.writeLine(\n 'import * as RegisteredFunction from \"@confect/server/RegisteredFunction\";',\n );\n yield* cbw.writeLine('import * as Layer from \"effect/Layer\";');\n yield* cbw.writeLine(`import observability from \"${runtimeImportPath}\";`);\n }\n const useNode = spec.runtime === \"Node\";\n\n const hasConfectFunctions = (group: GroupSpec.AnyWithProps): boolean =>\n Object.values(group.functions).some(\n (functionSpec) => functionSpec.functionProvenance._tag === \"Confect\",\n ) || Object.values(group.groups).some(hasConfectFunctions);\n const forwarding = !useNode && hasConfectFunctions(spec);\n\n if (useNode) {\n yield* cbw.writeLine(\n `import { RegisteredNodeFunction } from \"@confect/server/node\";`,\n );\n } else if (!forwarding) {\n yield* cbw.writeLine(\n `import { RegisteredFunctions } from \"@confect/server\";`,\n );\n } else {\n yield* cbw.writeLine(\n `import { ConvexFunctionDefinitions, RegisteredConvexFunction, type RegisteredFunctions } from \"@confect/server\";`,\n );\n }\n\n if (required.length > 0) {\n yield* cbw.writeLine(`import { GroupImpl } from \"@confect/server\";`);\n }\n yield* cbw.writeLine(`import databaseSchema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import groupLayer from \"${implImportPath}\";`);\n yield* cbw.blankLine();\n // The group's own leaf spec is referenced type-only (`typeof import(...)`),\n // so the spec module is erased at transpile time and never enters the\n // per-function bundle; only `databaseSchema` and the impl are runtime\n // imports. Typing from the leaf spec (not the project-wide assembled spec)\n // keeps the registry's type dependent solely on its own group.\n const finalizedLayer =\n required.length === 0\n ? \"groupLayer\"\n : // oxlint-disable-next-line effecttsgo/prefer-schema-over-json -- Emit escaped TypeScript string literals, not JSON payloads.\n `groupLayer.pipe(GroupImpl.finalize({ required: [${required.map(({ key }) => `{ key: ${JSON.stringify(key)} }`).join(\", \")}], groupPath: ${JSON.stringify(groupPath)} }))`;\n const groupLayer =\n runtimeImportPath === undefined\n ? finalizedLayer\n : `${finalizedLayer}.pipe(Layer.merge(Layer.succeed(RegisteredFunction.Observability, observability)))`;\n const specType = `typeof import(\"${specImportPath}\")[\"default\"]`;\n if (useNode) {\n yield* cbw.writeLine(\n `export default RegisteredNodeFunction.buildForGroup<${specType}>(databaseSchema, ${groupLayer});`,\n );\n } else if (!forwarding) {\n yield* cbw.writeLine(\n `export default RegisteredFunctions.buildForGroup<${specType}>(databaseSchema, ${groupLayer});`,\n );\n } else {\n const bindings = (group: GroupSpec.AnyWithProps, path: string): string =>\n `{\n${[\n ...Object.entries(group.functions).map(([name, functionSpec]) => {\n const key = JSON.stringify(name);\n const definition = `${path}[${key}]`;\n return `[${key}]: ${\n functionSpec.functionProvenance._tag === \"Convex\"\n ? `${definition}.handler`\n : `RegisteredConvexFunction.register({ ...${definition}, handler: forward(${definition}.handler) })`\n },`;\n }),\n ...Object.entries(group.groups).map(([name, child]) => {\n const key = JSON.stringify(name);\n return `[${key}]: ${bindings(child, `${path}[${key}]`)},`;\n }),\n].join(\"\\n\")}\n}`;\n yield* cbw.writeLine(`const forward = <Ctx, Args, Returns>(handler: (ctx: Ctx, args: Args) => Promise<Returns>) => (ctx: Ctx, args: Args) => handler(ctx, args);\n\nconst definitions = ConvexFunctionDefinitions.buildForGroup<${specType}>(databaseSchema, ${groupLayer});\n\nexport default ${bindings(spec, \"definitions\")} as RegisteredFunctions.RegisteredFunctionsForGroupSpec<${specType}>;`);\n }\n\n return yield* cbw.toString();\n});\n\nexport const services = ({\n schemaImportPath,\n component = false,\n}: Parameters<typeof servicesEffect>[0]) =>\n servicesEffect({ schemaImportPath, component });\n\nconst servicesEffect = Effect.fnUntraced(function* ({\n schemaImportPath,\n component = false,\n}: {\n schemaImportPath: string;\n component?: boolean;\n}) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n // Imports\n yield* cbw.writeLine(\"import {\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"ActionCtx as ActionCtx_,\");\n yield* cbw.writeLine(\"ActionRunner as ActionRunner_,\");\n yield* cbw.writeLine(\"Auth as Auth_,\");\n yield* cbw.writeLine(\"type DataModel,\");\n yield* cbw.writeLine(\"DatabaseReader as DatabaseReader_,\");\n yield* cbw.writeLine(\"DatabaseWriter as DatabaseWriter_,\");\n yield* cbw.writeLine(\"ExecutionMetadata as ExecutionMetadata_,\");\n yield* cbw.writeLine(\"MutationCtx as MutationCtx_,\");\n yield* cbw.writeLine(\"MutationRunner as MutationRunner_,\");\n yield* cbw.writeLine(\n \"MutationTransactionContext as MutationTransactionContext_,\",\n );\n yield* cbw.writeLine(\"QueryCtx as QueryCtx_,\");\n yield* cbw.writeLine(\"QueryRunner as QueryRunner_,\");\n yield* cbw.writeLine(\n \"QueryTransactionContext as QueryTransactionContext_,\",\n );\n yield* cbw.writeLine(\"RequestMetadata as RequestMetadata_,\");\n yield* cbw.writeLine(\"Scheduler as Scheduler_,\");\n if (!component) yield* cbw.writeLine(\"Storage as Storage_,\");\n yield* cbw.writeLine(\"StorageActionWriter as StorageActionWriter_,\");\n yield* cbw.writeLine(\"StorageReader as StorageReader_,\");\n yield* cbw.writeLine(\"StorageWriter as StorageWriter_,\");\n yield* cbw.writeLine(\"TransactionMetadata as TransactionMetadata_,\");\n yield* cbw.writeLine(\"VectorSearch as VectorSearch_,\");\n }),\n );\n yield* cbw.writeLine(`} from \"@confect/server\";`);\n yield* cbw.writeLine(\n `import type schemaDefinition from \"${schemaImportPath}\";`,\n );\n yield* cbw.writeLine(`import type { Docs } from \"./docs.js\";`);\n if (component) yield* cbw.writeLine(`import type { scope } from \"./id.js\";`);\n yield* cbw.blankLine();\n\n // Auth\n if (!component) {\n yield* cbw.writeLine(\"export const Auth = Auth_.Auth;\");\n yield* cbw.writeLine(\"export type Auth = typeof Auth.Identifier;\");\n }\n yield* cbw.writeLine(\"export const MutationAuth = Auth_.MutationAuth;\");\n yield* cbw.writeLine(\n \"export type MutationAuth = typeof MutationAuth.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const ExecutionMetadata = ExecutionMetadata_.ExecutionMetadata;\",\n );\n yield* cbw.writeLine(\n \"export type ExecutionMetadata = typeof ExecutionMetadata.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const RequestMetadata = RequestMetadata_.RequestMetadata;\",\n );\n yield* cbw.writeLine(\n \"export type RequestMetadata = typeof RequestMetadata.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const TransactionMetadata = TransactionMetadata_.TransactionMetadata;\",\n );\n yield* cbw.writeLine(\n \"export type TransactionMetadata = typeof TransactionMetadata.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // Scheduler\n yield* cbw.writeLine(\n component\n ? \"export const Scheduler = Scheduler_.forScope<typeof scope>();\"\n : \"export const Scheduler = Scheduler_.Scheduler;\",\n );\n yield* cbw.writeLine(\"export type Scheduler = typeof Scheduler.Identifier;\");\n yield* cbw.blankLine();\n\n if (!component) {\n yield* cbw.writeLine(\"export const Storage = Storage_.Storage;\");\n yield* cbw.writeLine(\"export type Storage = typeof Storage.Identifier;\");\n yield* cbw.blankLine();\n }\n\n // StorageReader\n yield* cbw.writeLine(\n `export const StorageReader = StorageReader_.StorageReader${component ? \".forScope<typeof scope>()\" : \"\"};`,\n );\n yield* cbw.writeLine(\n \"export type StorageReader = typeof StorageReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageWriter\n yield* cbw.writeLine(\n `export const StorageWriter = StorageWriter_.StorageWriter${component ? \".forScope<typeof scope>()\" : \"\"};`,\n );\n yield* cbw.writeLine(\n \"export type StorageWriter = typeof StorageWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageActionWriter\n yield* cbw.writeLine(\n `export const StorageActionWriter = StorageActionWriter_.StorageActionWriter${component ? \".forScope<typeof scope>()\" : \"\"};`,\n );\n yield* cbw.writeLine(\n \"export type StorageActionWriter = typeof StorageActionWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // VectorSearch\n yield* cbw.writeLine(\n \"export const VectorSearch: VectorSearch_.VectorSearchTag<\",\n );\n yield* cbw.indent(\n cbw.writeLine(\"DataModel.FromSchema<typeof schemaDefinition>\"),\n );\n yield* cbw.writeLine(\n \"> = VectorSearch_.VectorSearch<DataModel.FromSchema<typeof schemaDefinition>>();\",\n );\n yield* cbw.writeLine(\n \"export type VectorSearch = typeof VectorSearch.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseReader\n yield* cbw.writeLine(\n \"export const DatabaseReader: DatabaseReader_.DatabaseReaderTag<\",\n );\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"typeof schemaDefinition,\");\n yield* cbw.writeLine(\"Docs\");\n }),\n );\n yield* cbw.writeLine(\n \"> = DatabaseReader_.DatabaseReader<typeof schemaDefinition, Docs>();\",\n );\n yield* cbw.writeLine(\n \"export type DatabaseReader = typeof DatabaseReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseWriter\n yield* cbw.writeLine(\n \"export const DatabaseWriter: DatabaseWriter_.DatabaseWriterTag<\",\n );\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"typeof schemaDefinition,\");\n yield* cbw.writeLine(\"Docs\");\n }),\n );\n yield* cbw.writeLine(\n \"> = DatabaseWriter_.DatabaseWriter<typeof schemaDefinition, Docs>();\",\n );\n yield* cbw.writeLine(\n \"export type DatabaseWriter = typeof DatabaseWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n yield* cbw.writeLine(\n \"export const QueryTransactionContext = QueryTransactionContext_.QueryTransactionContext;\",\n );\n yield* cbw.writeLine(\n \"export type QueryTransactionContext = typeof QueryTransactionContext.Identifier;\",\n );\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n \"export const MutationTransactionContext = MutationTransactionContext_.MutationTransactionContext;\",\n );\n yield* cbw.writeLine(\n \"export type MutationTransactionContext = typeof MutationTransactionContext.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryRunner\n yield* cbw.writeLine(\"export const QueryRunner = QueryRunner_.QueryRunner;\");\n yield* cbw.writeLine(\n \"export type QueryRunner = typeof QueryRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // MutationRunner\n yield* cbw.writeLine(\n \"export const MutationRunner = MutationRunner_.MutationRunner;\",\n );\n yield* cbw.writeLine(\n \"export type MutationRunner = typeof MutationRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // ActionRunner\n yield* cbw.writeLine(\n \"export const ActionRunner = ActionRunner_.ActionRunner;\",\n );\n yield* cbw.writeLine(\n \"export type ActionRunner = typeof ActionRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryCtx\n yield* cbw.writeLine(\"export const QueryCtx: QueryCtx_.QueryCtxTag<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\"> = QueryCtx_.QueryCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\"export type QueryCtx = typeof QueryCtx.Identifier;\");\n yield* cbw.blankLine();\n\n // MutationCtx\n yield* cbw.writeLine(\n \"export const MutationCtx: MutationCtx_.MutationCtxTag<\",\n );\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\"> = MutationCtx_.MutationCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\n \"export type MutationCtx = typeof MutationCtx.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // ActionCtx\n yield* cbw.writeLine(\"export const ActionCtx: ActionCtx_.ActionCtxTag<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\"> = ActionCtx_.ActionCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n `DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>${component ? \", typeof scope\" : \"\"}`,\n ),\n );\n yield* cbw.writeLine(\">();\");\n yield* cbw.writeLine(\"export type ActionCtx = typeof ActionCtx.Identifier;\");\n\n return yield* cbw.toString();\n});\n\nexport const assembledSpec = ({\n nodes,\n}: {\n nodes: ReadonlyArray<SpecAssemblyNode>;\n}) => renderSpecAssembly(nodes);\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,UAAU,EACrB,6BAEA,aAAa,EAAE,uBAAuB,CAAC;AAEzC,MAAM,eAAe,OAAO,WAAW,WAAW,EAChD,0BAGC;CACD,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,EAAE,CAAC;CAE3D,OAAO,IAAI,UAAU,4BAA4B,uBAAuB,GAAG;CAE3E,OAAO,OAAO,IAAI,SAAS;AAC7B,CAAC;;;;;;;;;;;;;;;;;;;;AA0BD,MAAa,iBAAiB,EAC5B,cACA,YAAY,YAEZ,oBAAoB;CAAE;CAAc;AAAU,CAAC;AAEjD,MAAM,sBAAsB,OAAO,WAAW,WAAW,EACvD,cACA,YAAY,SAIX;CACD,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,EAAE,CAAC;CAE3D,OAAO,IAAI,UACT,sEACF;CAEA,IAAI,aAAa,SAAS,GAAG;EAC3B,OAAO,IAAI,UAAU;EACrB,OAAO,OAAO,QAAQ,eAAe,EAAE,WAAW,iBAChD,IAAI,UAAU,UAAU,UAAU,SAAS,WAAW,G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MAAM;CAC3B,OAAO,IAAI,UACT,0DACF;CACA,OAAO,IAAI,UAAU;CAGrB,OAAO,IAAI,UAAU,kDAAkD;CACvE,OAAO,IAAI,OACT,IAAI,UACF,oEAAoE,YAAY,mBAAmB,IACrG,CACF;CACA,OAAO,IAAI,UAAU,2BAA2B;CAChD,OAAO,IAAI,OACT,IAAI,UACF,oEAAoE,YAAY,mBAAmB,IACrG,CACF;CACA,OAAO,IAAI,UAAU,MAAM;CAC3B,OAAO,IAAI,UAAU,sDAAsD;CAE3E,OAAO,OAAO,IAAI,SAAS;AAC7B,CAAC;AAED,MAAa,iBAAiB,EAC5B,YAGIA,OAAmB,KAAK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaganref/confect-cli",
3
- "version": "10.3.1-fork.39",
3
+ "version": "10.3.1-fork.40",
4
4
  "dependencies": {
5
5
  "@effect/platform-node": ">=4.0.4 <4.1.0",
6
6
  "bundle-require": "^5.1.0",
@@ -9,8 +9,8 @@
9
9
  "exsolve": "^1.1.3"
10
10
  },
11
11
  "peerDependencies": {
12
- "@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.39",
13
- "@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.39",
12
+ "@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.40",
13
+ "@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.40",
14
14
  "@effect/platform-node-shared": ">=4.0.4 <4.1.0",
15
15
  "effect": ">=4.0.4 <4.1.0"
16
16
  },