@confect/cli 1.0.0-next.3 → 1.0.0-next.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"dev.mjs","names":["GroupPath.toString","FunctionPaths.make","FunctionPaths.diff","GroupPath.modulePath"],"sources":["../../src/confect/dev.ts"],"sourcesContent":["import { Spec } from \"@confect/core\";\nimport { Command } from \"@effect/cli\";\nimport { FileSystem, Path } from \"@effect/platform\";\nimport { Ansi, AnsiDoc } from \"@effect/printer-ansi\";\nimport {\n Array,\n Console,\n Data,\n Duration,\n Effect,\n Equal,\n HashSet,\n Match,\n Option,\n pipe,\n Queue,\n Ref,\n Schema,\n Stream,\n String,\n} from \"effect\";\nimport type { ReadonlyRecord } from \"effect/Record\";\nimport * as esbuild from \"esbuild\";\nimport * as tsx from \"tsx/esm/api\";\nimport type * as FunctionPath from \"../FunctionPath\";\nimport * as FunctionPaths from \"../FunctionPaths\";\nimport * as GroupPath from \"../GroupPath\";\nimport { logCompleted, logFailed } from \"../log\";\nimport { ConfectDirectory } from \"../services/ConfectDirectory\";\nimport { ConvexDirectory } from \"../services/ConvexDirectory\";\nimport { ProjectRoot } from \"../services/ProjectRoot\";\nimport {\n generateAuthConfig,\n generateConvexConfig,\n generateCrons,\n generateHttp,\n removeGroups,\n writeGroups,\n} from \"../utils\";\nimport { codegenHandler } from \"./codegen\";\n\ntype Pending = {\n readonly specDirty: boolean;\n readonly httpDirty: boolean;\n readonly appDirty: boolean;\n readonly cronsDirty: boolean;\n readonly authDirty: boolean;\n};\n\nconst pendingInit: Pending = {\n specDirty: false,\n httpDirty: false,\n appDirty: false,\n cronsDirty: false,\n authDirty: false,\n};\n\ntype FileChange = Data.TaggedEnum<{\n OptionalFile: {\n readonly change: \"Added\" | \"Removed\" | \"Modified\";\n readonly filePath: string;\n };\n GroupModule: {\n readonly change: \"Added\" | \"Removed\" | \"Modified\";\n readonly filePath: string;\n readonly functionsAdded: ReadonlyArray<FunctionPath.FunctionPath>;\n readonly functionsRemoved: ReadonlyArray<FunctionPath.FunctionPath>;\n };\n}>;\n\nconst FileChange = Data.taggedEnum<FileChange>();\n\nconst logChangeReport = (changes: ReadonlyArray<FileChange>) =>\n Effect.gen(function* () {\n yield* logCompleted(\"Generated files are up-to-date\");\n\n yield* Effect.when(\n Effect.forEach(changes, (change) =>\n FileChange.$match(change, {\n OptionalFile: ({ change: c, filePath }) =>\n logFileChangeIndented(c, filePath),\n GroupModule: ({\n change: c,\n filePath,\n functionsAdded,\n functionsRemoved,\n }) =>\n Effect.gen(function* () {\n yield* logFileChangeIndented(c, filePath);\n yield* Effect.forEach(functionsAdded, logFunctionAddedIndented);\n yield* Effect.forEach(\n functionsRemoved,\n logFunctionRemovedIndented,\n );\n }),\n }),\n ),\n () => Array.isNonEmptyReadonlyArray(changes),\n );\n });\n\nconst changeChar = (change: \"Added\" | \"Removed\" | \"Modified\") =>\n Match.value(change).pipe(\n Match.when(\"Added\", () => ({ char: \"+\", color: Ansi.green })),\n Match.when(\"Removed\", () => ({ char: \"-\", color: Ansi.red })),\n Match.when(\"Modified\", () => ({ char: \"~\", color: Ansi.yellow })),\n Match.exhaustive,\n );\n\nconst logFileChangeIndented = (\n change: \"Added\" | \"Removed\" | \"Modified\",\n fullPath: string,\n) =>\n Effect.gen(function* () {\n const projectRoot = yield* ProjectRoot.get;\n const path = yield* Path.Path;\n\n const prefix = projectRoot + path.sep;\n const suffix = pipe(fullPath, String.startsWith(prefix))\n ? pipe(fullPath, String.slice(prefix.length))\n : fullPath;\n\n const { char, color } = changeChar(change);\n\n yield* Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(char), AnsiDoc.annotate(color))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(AnsiDoc.text(prefix), AnsiDoc.annotate(Ansi.blackBright)),\n pipe(AnsiDoc.text(suffix), AnsiDoc.annotate(color)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n });\n\nconst logFunctionAddedIndented = (functionPath: FunctionPath.FunctionPath) =>\n Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(\"+\"), AnsiDoc.annotate(Ansi.green))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(\n AnsiDoc.text(GroupPath.toString(functionPath.groupPath) + \".\"),\n AnsiDoc.annotate(Ansi.blackBright),\n ),\n pipe(AnsiDoc.text(functionPath.name), AnsiDoc.annotate(Ansi.green)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n\nconst logFunctionRemovedIndented = (functionPath: FunctionPath.FunctionPath) =>\n Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(\"-\"), AnsiDoc.annotate(Ansi.red))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(\n AnsiDoc.text(GroupPath.toString(functionPath.groupPath) + \".\"),\n AnsiDoc.annotate(Ansi.blackBright),\n ),\n pipe(AnsiDoc.text(functionPath.name), AnsiDoc.annotate(Ansi.red)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n\nexport const dev = Command.make(\"dev\", {}, () =>\n Effect.gen(function* () {\n const initialFunctionPaths = yield* codegenHandler;\n\n const pendingRef = yield* Ref.make<Pending>(pendingInit);\n const signal = yield* Queue.sliding<void>(1);\n\n yield* Effect.all(\n [\n specFileWatcher(signal, pendingRef),\n confectDirectoryWatcher(signal, pendingRef),\n syncLoop(signal, pendingRef, initialFunctionPaths),\n ],\n { concurrency: \"unbounded\" },\n );\n }),\n).pipe(Command.withDescription(\"Start the Confect development server\"));\n\nconst syncLoop = (\n signal: Queue.Queue<void>,\n pendingRef: Ref.Ref<Pending>,\n initialFunctionPaths: FunctionPaths.FunctionPaths,\n) =>\n Effect.gen(function* () {\n const functionPathsRef = yield* Ref.make(initialFunctionPaths);\n const changesRef = yield* Ref.make<ReadonlyArray<FileChange>>([]);\n\n return yield* Effect.forever(\n Effect.gen(function* () {\n yield* Effect.logDebug(\"Running sync loop...\");\n yield* Queue.take(signal);\n\n const pending = yield* Ref.getAndSet(pendingRef, pendingInit);\n\n const specResult: Option.Option<ReadonlyArray<FileChange>> =\n yield* Effect.if(pending.specDirty, {\n onTrue: () =>\n loadSpec.pipe(\n Effect.andThen(\n Effect.fn(function* (spec) {\n yield* Effect.logDebug(\"Spec loaded\");\n\n const previous = yield* Ref.get(functionPathsRef);\n\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const current = FunctionPaths.make(spec);\n const {\n functionsAdded,\n functionsRemoved,\n groupsRemoved,\n groupsAdded,\n groupsChanged,\n } = FunctionPaths.diff(previous, current);\n\n // Removed groups\n yield* removeGroups(groupsRemoved);\n const removedChanges = yield* Effect.forEach(\n groupsRemoved,\n (gp) =>\n Effect.gen(function* () {\n const relativeModulePath =\n yield* GroupPath.modulePath(gp);\n return FileChange.GroupModule({\n change: \"Removed\",\n filePath: path.join(\n convexDirectory,\n relativeModulePath,\n ),\n functionsAdded: [],\n functionsRemoved: Array.fromIterable(\n HashSet.filter(functionsRemoved, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n });\n }),\n );\n\n // Added groups\n yield* writeGroups(spec, groupsAdded);\n const addedChanges = yield* Effect.forEach(\n groupsAdded,\n (gp) =>\n Effect.gen(function* () {\n const relativeModulePath =\n yield* GroupPath.modulePath(gp);\n return FileChange.GroupModule({\n change: \"Added\",\n filePath: path.join(\n convexDirectory,\n relativeModulePath,\n ),\n functionsAdded: Array.fromIterable(\n HashSet.filter(functionsAdded, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n functionsRemoved: [],\n });\n }),\n );\n\n // Changed groups\n yield* writeGroups(spec, groupsChanged);\n const changedChanges = yield* Effect.forEach(\n groupsChanged,\n (gp) =>\n Effect.gen(function* () {\n const relativeModulePath =\n yield* GroupPath.modulePath(gp);\n return FileChange.GroupModule({\n change: \"Modified\",\n filePath: path.join(\n convexDirectory,\n relativeModulePath,\n ),\n functionsAdded: Array.fromIterable(\n HashSet.filter(functionsAdded, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n functionsRemoved: Array.fromIterable(\n HashSet.filter(functionsRemoved, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n });\n }),\n );\n\n yield* Ref.set(functionPathsRef, current);\n\n return Option.some([\n ...removedChanges,\n ...addedChanges,\n ...changedChanges,\n ]);\n }),\n ),\n Effect.catchTag(\"SpecImportFailedError\", () =>\n logFailed(\"Spec import failed\").pipe(\n Effect.as(Option.none()),\n ),\n ),\n Effect.catchTag(\"SpecFileDoesNotExportSpecError\", () =>\n logFailed(\"Spec file does not default export a spec\").pipe(\n Effect.as(Option.none()),\n ),\n ),\n ),\n onFalse: () => Effect.succeed(Option.some([])),\n });\n\n const specChanges = Option.getOrElse(specResult, () => []);\n\n const dirtyOptionalFiles = [\n ...(pending.httpDirty\n ? [syncOptionalFile(generateHttp, \"http.ts\")]\n : []),\n ...(pending.appDirty\n ? [syncOptionalFile(generateConvexConfig, \"convex.config.ts\")]\n : []),\n ...(pending.cronsDirty\n ? [syncOptionalFile(generateCrons, \"crons.ts\")]\n : []),\n ...(pending.authDirty\n ? [syncOptionalFile(generateAuthConfig, \"auth.config.ts\")]\n : []),\n ];\n\n const optionalChanges: ReadonlyArray<FileChange> =\n Array.isNonEmptyReadonlyArray(dirtyOptionalFiles)\n ? yield* pipe(\n Effect.all(dirtyOptionalFiles, {\n concurrency: \"unbounded\",\n }),\n Effect.map(Array.getSomes),\n )\n : [];\n\n yield* Ref.update(changesRef, (prev) => [\n ...prev,\n ...specChanges,\n ...optionalChanges,\n ]);\n\n yield* Option.match(specResult, {\n onSome: () =>\n Effect.gen(function* () {\n const pendingSize = yield* Queue.size(signal);\n yield* Effect.when(\n Effect.gen(function* () {\n const allChanges = yield* Ref.getAndSet(changesRef, []);\n yield* logChangeReport(allChanges);\n }),\n () => pendingSize === 0,\n );\n }),\n onNone: () => Ref.set(changesRef, []),\n });\n }),\n );\n });\n\nconst loadSpec = Effect.gen(function* () {\n const path = yield* Path.Path;\n const specPathUrl = yield* path.toFileUrl(yield* getSpecPath);\n const specModule = yield* Effect.tryPromise({\n try: () => tsx.tsImport(specPathUrl.href, import.meta.url),\n catch: (error) => new SpecImportFailedError({ error }),\n });\n const spec = specModule.default;\n\n if (Spec.isSpec(spec)) {\n return spec;\n } else {\n return yield* Effect.fail(new SpecFileDoesNotExportSpecError());\n }\n});\n\nconst getSpecPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n return path.join(confectDirectory, \"spec.ts\");\n});\n\nconst specFileWatcher = (\n signal: Queue.Queue<void>,\n pendingRef: Ref.Ref<Pending>,\n) =>\n Effect.gen(function* () {\n const specPath = yield* getSpecPath;\n\n const specChanges: Stream.Stream<void> = Stream.asyncPush(\n (emit) =>\n Effect.acquireRelease(\n Effect.promise(async () => {\n const ctx = await esbuild.context({\n entryPoints: [specPath],\n bundle: true,\n write: false,\n metafile: true,\n platform: \"node\",\n format: \"esm\",\n logLevel: \"silent\",\n external: [\n \"@confect/core\",\n \"@confect/server\",\n \"effect\",\n \"@effect/*\",\n ],\n plugins: [\n {\n name: \"notify-rebuild\",\n setup(build) {\n build.onEnd((result) => {\n if (result.errors.length === 0) {\n emit.single();\n } else {\n Effect.runPromise(\n Effect.gen(function* () {\n yield* logFailed(\"Build errors\");\n const formattedMessages = yield* Effect.promise(\n () =>\n esbuild.formatMessages(result.errors, {\n kind: \"error\",\n color: true,\n terminalWidth: 80,\n }),\n );\n const output = formatBuildErrors(\n result.errors,\n formattedMessages,\n );\n yield* Console.error(\"\\n\" + output + \"\\n\");\n }),\n );\n }\n });\n },\n },\n ],\n });\n\n await ctx.watch();\n\n return ctx;\n }),\n (ctx) =>\n Effect.promise(() => ctx.dispose()).pipe(\n Effect.tap(() => Effect.logDebug(\"esbuild watcher disposed\")),\n ),\n ),\n { bufferSize: 1, strategy: \"sliding\" },\n );\n\n yield* pipe(\n specChanges,\n Stream.debounce(Duration.millis(200)),\n Stream.runForEach(() =>\n Ref.update(pendingRef, (pending) => ({\n ...pending,\n specDirty: true,\n })).pipe(Effect.andThen(Queue.offer(signal, undefined))),\n ),\n );\n });\n\nconst formatBuildError = (\n error: esbuild.Message | undefined,\n formattedMessage: string,\n): string => {\n const lines = String.split(formattedMessage, \"\\n\");\n const redErrorText = pipe(\n AnsiDoc.text(error?.text ?? \"\"),\n AnsiDoc.annotate(Ansi.red),\n AnsiDoc.render({ style: \"pretty\" }),\n );\n const replaced = pipe(\n Array.findFirstIndex(lines, (l) => pipe(l, String.trim, String.isNonEmpty)),\n Option.match({\n onNone: () => lines,\n onSome: (idx) => Array.modify(lines, idx, () => redErrorText),\n }),\n );\n return pipe(\n replaced,\n Array.map((l) => (pipe(l, String.trim, String.isNonEmpty) ? ` ${l}` : l)),\n Array.join(\"\\n\"),\n );\n};\n\nconst formatBuildErrors = (\n errors: readonly esbuild.Message[],\n formattedMessages: readonly string[],\n): string =>\n pipe(\n formattedMessages,\n Array.map((message, i) => formatBuildError(errors[i], message)),\n Array.join(\"\"),\n String.trimEnd,\n );\n\nexport class SpecFileDoesNotExportSpecError extends Schema.TaggedError<SpecFileDoesNotExportSpecError>(\n \"SpecFileDoesNotExportSpecError\",\n)(\"SpecFileDoesNotExportSpecError\", {}) {}\n\nexport class SpecImportFailedError extends Schema.TaggedError<SpecImportFailedError>(\n \"SpecImportFailedError\",\n)(\"SpecImportFailedError\", {\n error: Schema.Unknown,\n}) {}\n\nconst syncOptionalFile = (generate: typeof generateHttp, convexFile: string) =>\n pipe(\n generate,\n Effect.andThen(\n Option.match({\n onSome: ({ change, convexFilePath }) =>\n Match.value(change).pipe(\n Match.when(\"Unchanged\", () => Effect.succeed(Option.none())),\n Match.whenOr(\"Added\", \"Modified\", (addedOrModified) =>\n Effect.succeed(\n Option.some(\n FileChange.OptionalFile({\n change: addedOrModified,\n filePath: convexFilePath,\n }),\n ),\n ),\n ),\n Match.exhaustive,\n ),\n onNone: () =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const convexFilePath = path.join(convexDirectory, convexFile);\n\n if (yield* fs.exists(convexFilePath)) {\n yield* fs.remove(convexFilePath);\n\n return Option.some(\n FileChange.OptionalFile({\n change: \"Removed\",\n filePath: convexFilePath,\n }),\n );\n } else {\n return Option.none();\n }\n }),\n }),\n ),\n );\n\nconst optionalConfectFiles: ReadonlyRecord<string, keyof Pending> = {\n \"http.ts\": \"httpDirty\",\n \"app.ts\": \"appDirty\",\n \"crons.ts\": \"cronsDirty\",\n \"auth.ts\": \"authDirty\",\n};\n\nconst confectDirectoryWatcher = (\n signal: Queue.Queue<void>,\n pendingRef: Ref.Ref<Pending>,\n) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const confectDirectory = yield* ConfectDirectory.get;\n\n yield* pipe(\n fs.watch(confectDirectory),\n Stream.runForEach((event) =>\n pipe(\n Option.fromNullable(optionalConfectFiles[event.path]),\n Option.match({\n onNone: () => Effect.void,\n onSome: (pendingKey) =>\n pipe(\n pendingRef,\n Ref.update((pending) => ({\n ...pending,\n [pendingKey]: true,\n })),\n Effect.andThen(Queue.offer(signal, undefined)),\n ),\n }),\n ),\n ),\n );\n });\n"],"mappings":";;;;;;;;;;;;;;;;;AAiDA,MAAM,cAAuB;CAC3B,WAAW;CACX,WAAW;CACX,UAAU;CACV,YAAY;CACZ,WAAW;CACZ;AAeD,MAAM,aAAa,KAAK,YAAwB;AAEhD,MAAM,mBAAmB,YACvB,OAAO,IAAI,aAAa;AACtB,QAAO,aAAa,iCAAiC;AAErD,QAAO,OAAO,KACZ,OAAO,QAAQ,UAAU,WACvB,WAAW,OAAO,QAAQ;EAC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AAW;CACX,UAAU;CACV,YAAY;CACZ,WAAW;CACZ;AAED,MAAM,2BACJ,QACA,eAEA,OAAO,IAAI,aAAa;CACtB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,mBAAmB,OAAO,iBAAiB;AAEjD,QAAO,KACL,GAAG,MAAM,iBAAiB,EAC1B,OAAO,YAAY,UACjB,KACE,OAAO,aAAa,qBAAqB,MAAM,MAAM,EACrD,OAAO,MAAM;EACX,cAAc,OAAO;EACrB,SAAS,eACP,KACE,YACA,IAAI,QAAQ,aAAa;GACvB,GAAG;IACF,aAAa;GACf,EAAE,EACH,OAAO,QAAQ,MAAM,MAAM,QAAQ,OAAU,CAAC,CAC/C;EACJ,CAAC,CACH,CACF,CACF;EACD"}
1
+ {"version":3,"file":"dev.mjs","names":["GroupPath.toString","FunctionPaths.make","FunctionPaths.diff","GroupPath.modulePath"],"sources":["../../src/confect/dev.ts"],"sourcesContent":["import { Spec } from \"@confect/core\";\nimport { Command } from \"@effect/cli\";\nimport { FileSystem, Path } from \"@effect/platform\";\nimport { Ansi, AnsiDoc } from \"@effect/printer-ansi\";\nimport {\n Array,\n Console,\n Deferred,\n Duration,\n Effect,\n Equal,\n HashSet,\n Match,\n Option,\n pipe,\n Queue,\n Ref,\n Schema,\n Stream,\n String,\n} from \"effect\";\nimport type { ReadonlyRecord } from \"effect/Record\";\nimport * as esbuild from \"esbuild\";\nimport * as tsx from \"tsx/esm/api\";\nimport type * as FunctionPath from \"../FunctionPath\";\nimport * as FunctionPaths from \"../FunctionPaths\";\nimport * as GroupPath from \"../GroupPath\";\nimport { logFailure, logPending, logSuccess } from \"../log\";\nimport { ConfectDirectory } from \"../services/ConfectDirectory\";\nimport { ConvexDirectory } from \"../services/ConvexDirectory\";\nimport { ProjectRoot } from \"../services/ProjectRoot\";\nimport {\n generateAuthConfig,\n generateConvexConfig,\n generateCrons,\n generateHttp,\n removeGroups,\n writeGroups,\n} from \"../utils\";\nimport {\n codegenHandler,\n generateNodeApi,\n generateNodeRegisteredFunctions,\n} from \"./codegen\";\n\ntype Pending = {\n readonly specDirty: boolean;\n readonly nodeImplDirty: boolean;\n readonly httpDirty: boolean;\n readonly appDirty: boolean;\n readonly cronsDirty: boolean;\n readonly authDirty: boolean;\n};\n\nconst pendingInit: Pending = {\n specDirty: false,\n nodeImplDirty: false,\n httpDirty: false,\n appDirty: false,\n cronsDirty: false,\n authDirty: false,\n};\n\nconst changeChar = (change: \"Added\" | \"Removed\" | \"Modified\") =>\n Match.value(change).pipe(\n Match.when(\"Added\", () => ({ char: \"+\", color: Ansi.green })),\n Match.when(\"Removed\", () => ({ char: \"-\", color: Ansi.red })),\n Match.when(\"Modified\", () => ({ char: \"~\", color: Ansi.yellow })),\n Match.exhaustive,\n );\n\nconst logFileChangeIndented = (\n change: \"Added\" | \"Removed\" | \"Modified\",\n fullPath: string,\n) =>\n Effect.gen(function* () {\n const projectRoot = yield* ProjectRoot.get;\n const path = yield* Path.Path;\n\n const prefix = projectRoot + path.sep;\n const suffix = pipe(fullPath, String.startsWith(prefix))\n ? pipe(fullPath, String.slice(prefix.length))\n : fullPath;\n\n const { char, color } = changeChar(change);\n\n yield* Console.log(\n pipe(\n AnsiDoc.char(char),\n AnsiDoc.annotate(color),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(AnsiDoc.text(prefix), AnsiDoc.annotate(Ansi.blackBright)),\n pipe(AnsiDoc.text(suffix), AnsiDoc.annotate(color)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n });\n\nconst logFunctionAddedIndented = (functionPath: FunctionPath.FunctionPath) =>\n Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(\"+\"), AnsiDoc.annotate(Ansi.green))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(\n AnsiDoc.text(GroupPath.toString(functionPath.groupPath) + \".\"),\n AnsiDoc.annotate(Ansi.blackBright),\n ),\n pipe(AnsiDoc.text(functionPath.name), AnsiDoc.annotate(Ansi.green)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n\nconst logFunctionRemovedIndented = (functionPath: FunctionPath.FunctionPath) =>\n Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(\"-\"), AnsiDoc.annotate(Ansi.red))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(\n AnsiDoc.text(GroupPath.toString(functionPath.groupPath) + \".\"),\n AnsiDoc.annotate(Ansi.blackBright),\n ),\n pipe(AnsiDoc.text(functionPath.name), AnsiDoc.annotate(Ansi.red)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n\nexport const dev = Command.make(\"dev\", {}, () =>\n Effect.gen(function* () {\n yield* logPending(\"Performing initial sync…\");\n const initialFunctionPaths = yield* codegenHandler;\n\n const pendingRef = yield* Ref.make<Pending>(pendingInit);\n const signal = yield* Queue.sliding<void>(1);\n const specWatcherRestartQueue = yield* Queue.sliding<void>(1);\n\n yield* Effect.all(\n [\n specFileWatcher(signal, pendingRef, specWatcherRestartQueue),\n confectDirectoryWatcher(signal, pendingRef, specWatcherRestartQueue),\n syncLoop(signal, pendingRef, initialFunctionPaths),\n ],\n { concurrency: \"unbounded\" },\n );\n }),\n).pipe(Command.withDescription(\"Start the Confect development server\"));\n\nconst syncLoop = (\n signal: Queue.Queue<void>,\n pendingRef: Ref.Ref<Pending>,\n initialFunctionPaths: FunctionPaths.FunctionPaths,\n) =>\n Effect.gen(function* () {\n const functionPathsRef = yield* Ref.make(initialFunctionPaths);\n const initialSyncDone = yield* Deferred.make<void>();\n\n return yield* Effect.forever(\n Effect.gen(function* () {\n yield* Effect.logDebug(\"Running sync loop...\");\n yield* Queue.take(signal);\n\n const isDone = yield* Deferred.isDone(initialSyncDone);\n yield* Effect.when(\n logPending(\"Dependencies changed, reloading…\"),\n () => isDone,\n );\n yield* Deferred.succeed(initialSyncDone, undefined);\n\n const pending = yield* Ref.getAndSet(pendingRef, pendingInit);\n\n if (pending.specDirty || pending.nodeImplDirty) {\n yield* generateNodeApi;\n yield* generateNodeRegisteredFunctions;\n }\n\n const specResult: Option.Option<void> = yield* Effect.if(\n pending.specDirty,\n {\n onTrue: () =>\n loadSpec.pipe(\n Effect.andThen(\n Effect.fn(function* (spec) {\n yield* Effect.logDebug(\"Spec loaded\");\n\n const previous = yield* Ref.get(functionPathsRef);\n\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const current = FunctionPaths.make(spec);\n const {\n functionsAdded,\n functionsRemoved,\n groupsRemoved,\n groupsAdded,\n groupsChanged,\n } = FunctionPaths.diff(previous, current);\n\n // Removed groups\n yield* removeGroups(groupsRemoved);\n yield* Effect.forEach(groupsRemoved, (gp) =>\n Effect.gen(function* () {\n const relativeModulePath =\n yield* GroupPath.modulePath(gp);\n const filePath = path.join(\n convexDirectory,\n relativeModulePath,\n );\n yield* logFileChangeIndented(\"Removed\", filePath);\n yield* Effect.forEach(\n Array.fromIterable(\n HashSet.filter(functionsRemoved, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n logFunctionRemovedIndented,\n );\n }),\n );\n\n // Added groups\n yield* writeGroups(spec, groupsAdded);\n yield* Effect.forEach(groupsAdded, (gp) =>\n Effect.gen(function* () {\n const relativeModulePath =\n yield* GroupPath.modulePath(gp);\n const filePath = path.join(\n convexDirectory,\n relativeModulePath,\n );\n yield* logFileChangeIndented(\"Added\", filePath);\n yield* Effect.forEach(\n Array.fromIterable(\n HashSet.filter(functionsAdded, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n logFunctionAddedIndented,\n );\n }),\n );\n\n // Changed groups\n yield* writeGroups(spec, groupsChanged);\n yield* Effect.forEach(groupsChanged, (gp) =>\n Effect.gen(function* () {\n const relativeModulePath =\n yield* GroupPath.modulePath(gp);\n const filePath = path.join(\n convexDirectory,\n relativeModulePath,\n );\n yield* logFileChangeIndented(\"Modified\", filePath);\n yield* Effect.forEach(\n Array.fromIterable(\n HashSet.filter(functionsAdded, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n logFunctionAddedIndented,\n );\n yield* Effect.forEach(\n Array.fromIterable(\n HashSet.filter(functionsRemoved, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n logFunctionRemovedIndented,\n );\n }),\n );\n\n yield* Ref.set(functionPathsRef, current);\n\n return Option.some(undefined);\n }),\n ),\n Effect.catchTag(\"SpecImportFailedError\", () =>\n logFailure(\"Spec import failed\").pipe(\n Effect.as(Option.none()),\n ),\n ),\n Effect.catchTag(\"SpecFileDoesNotExportSpecError\", () =>\n logFailure(\n \"Spec file does not default export a Convex spec\",\n ).pipe(Effect.as(Option.none())),\n ),\n Effect.catchTag(\"NodeSpecFileDoesNotExportSpecError\", () =>\n logFailure(\n \"Node spec file does not default export a Node spec\",\n ).pipe(Effect.as(Option.none())),\n ),\n ),\n onFalse: () => Effect.succeed(Option.some(undefined)),\n },\n );\n\n const dirtyOptionalFiles = [\n ...(pending.httpDirty\n ? [syncOptionalFile(generateHttp, \"http.ts\")]\n : []),\n ...(pending.appDirty\n ? [syncOptionalFile(generateConvexConfig, \"convex.config.ts\")]\n : []),\n ...(pending.cronsDirty\n ? [syncOptionalFile(generateCrons, \"crons.ts\")]\n : []),\n ...(pending.authDirty\n ? [syncOptionalFile(generateAuthConfig, \"auth.config.ts\")]\n : []),\n ];\n\n yield* Array.isNonEmptyReadonlyArray(dirtyOptionalFiles)\n ? Effect.all(dirtyOptionalFiles, { concurrency: \"unbounded\" })\n : Effect.void;\n\n yield* Option.match(specResult, {\n onSome: () => logSuccess(\"Generated files are up-to-date\"),\n onNone: () => Effect.void,\n });\n }),\n );\n });\n\nconst loadSpec = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const specPathUrl = yield* path.toFileUrl(yield* getSpecPath);\n const specModule = yield* Effect.tryPromise({\n try: () => tsx.tsImport(specPathUrl.href, import.meta.url),\n catch: (error) => new SpecImportFailedError({ error }),\n });\n const spec = specModule.default;\n\n if (!Spec.isConvexSpec(spec)) {\n return yield* new SpecFileDoesNotExportSpecError();\n }\n\n const nodeImplPath = path.join(confectDirectory, \"nodeImpl.ts\");\n const nodeImplExists = yield* fs.exists(nodeImplPath);\n const nodeSpecOption = yield* loadNodeSpec;\n const mergedSpec = Option.match(nodeSpecOption, {\n onNone: () => spec,\n onSome: (nodeSpec) => (nodeImplExists ? Spec.merge(spec, nodeSpec) : spec),\n });\n\n return mergedSpec;\n});\n\nconst getSpecPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n return path.join(confectDirectory, \"spec.ts\");\n});\n\nconst getNodeSpecPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n return path.join(confectDirectory, \"nodeSpec.ts\");\n});\n\nconst loadNodeSpec = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const nodeSpecPath = yield* getNodeSpecPath;\n\n if (!(yield* fs.exists(nodeSpecPath))) {\n return Option.none();\n }\n\n const nodeSpecPathUrl = yield* path.toFileUrl(nodeSpecPath);\n const nodeSpecModule = yield* Effect.tryPromise({\n try: () => tsx.tsImport(nodeSpecPathUrl.href, import.meta.url),\n catch: (error) => new SpecImportFailedError({ error }),\n });\n const nodeSpec = nodeSpecModule.default;\n\n if (!Spec.isNodeSpec(nodeSpec)) {\n return yield* new NodeSpecFileDoesNotExportSpecError();\n }\n\n return Option.some(nodeSpec);\n});\n\nconst esbuildOptions = (entryPoint: string) => ({\n entryPoints: [entryPoint],\n bundle: true,\n write: false,\n metafile: true,\n platform: \"node\" as const,\n format: \"esm\" as const,\n logLevel: \"silent\" as const,\n external: [\"@confect/core\", \"@confect/server\", \"effect\", \"@effect/*\"],\n plugins: [\n {\n name: \"notify-rebuild\",\n setup(build: esbuild.PluginBuild) {\n build.onEnd((result) => {\n if (result.errors.length === 0) {\n (build as { _emit?: (v: void) => void })._emit?.();\n } else {\n Effect.runPromise(\n Effect.gen(function* () {\n const formattedMessages = yield* Effect.promise(() =>\n esbuild.formatMessages(result.errors, {\n kind: \"error\",\n color: true,\n terminalWidth: 80,\n }),\n );\n const output = formatBuildErrors(\n result.errors,\n formattedMessages,\n );\n yield* Console.error(\"\\n\" + output + \"\\n\");\n yield* logFailure(\"Build errors found\");\n }),\n );\n }\n });\n },\n },\n ],\n});\n\nconst createSpecWatcher = (entryPoint: string) =>\n Stream.asyncPush<void>(\n (emit) =>\n Effect.acquireRelease(\n Effect.promise(async () => {\n const opts = esbuildOptions(entryPoint);\n const plugin = opts.plugins[0];\n const originalSetup = plugin!.setup!;\n (plugin as { setup: (build: esbuild.PluginBuild) => void }).setup = (\n build,\n ) => {\n (build as { _emit?: (v: void) => void })._emit = () =>\n emit.single();\n return originalSetup(build);\n };\n\n const ctx = await esbuild.context({\n ...opts,\n plugins: [plugin],\n });\n\n await ctx.watch();\n return ctx;\n }),\n (ctx) =>\n Effect.promise(() => ctx.dispose()).pipe(\n Effect.tap(() => Effect.logDebug(\"esbuild watcher disposed\")),\n ),\n ),\n { bufferSize: 1, strategy: \"sliding\" },\n );\n\ntype SpecWatcherEvent = \"change\" | \"restart\";\n\nconst specFileWatcher = (\n signal: Queue.Queue<void>,\n pendingRef: Ref.Ref<Pending>,\n specWatcherRestartQueue: Queue.Queue<void>,\n) =>\n Effect.forever(\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const specPath = yield* getSpecPath;\n const nodeSpecPath = yield* getNodeSpecPath;\n const nodeSpecExists = yield* fs.exists(nodeSpecPath);\n\n const specWatcher = createSpecWatcher(specPath);\n const nodeSpecWatcher = nodeSpecExists\n ? createSpecWatcher(nodeSpecPath)\n : Stream.empty;\n\n const specChanges = pipe(\n Stream.merge(specWatcher, nodeSpecWatcher),\n Stream.map((): SpecWatcherEvent => \"change\"),\n );\n const restartStream = pipe(\n Stream.fromQueue(specWatcherRestartQueue),\n Stream.map((): SpecWatcherEvent => \"restart\"),\n );\n\n yield* pipe(\n Stream.merge(specChanges, restartStream),\n Stream.debounce(Duration.millis(200)),\n Stream.takeUntil((event): event is \"restart\" => event === \"restart\"),\n Stream.runForEach((event) =>\n event === \"change\"\n ? Ref.update(pendingRef, (pending) => ({\n ...pending,\n specDirty: true,\n })).pipe(Effect.andThen(Queue.offer(signal, undefined)))\n : Effect.void,\n ),\n );\n }),\n );\n\nconst formatBuildError = (\n error: esbuild.Message | undefined,\n formattedMessage: string,\n): string => {\n const lines = String.split(formattedMessage, \"\\n\");\n const redErrorText = pipe(\n AnsiDoc.text(error?.text ?? \"\"),\n AnsiDoc.annotate(Ansi.red),\n AnsiDoc.render({ style: \"pretty\" }),\n );\n const replaced = pipe(\n Array.findFirstIndex(lines, (l) => pipe(l, String.trim, String.isNonEmpty)),\n Option.match({\n onNone: () => lines,\n onSome: (index) => Array.modify(lines, index, () => redErrorText),\n }),\n );\n return pipe(replaced, Array.join(\"\\n\"));\n};\n\nconst formatBuildErrors = (\n errors: readonly esbuild.Message[],\n formattedMessages: readonly string[],\n): string =>\n pipe(\n formattedMessages,\n Array.map((message, i) => formatBuildError(errors[i], message)),\n Array.join(\"\"),\n String.trimEnd,\n );\n\nexport class SpecFileDoesNotExportSpecError extends Schema.TaggedError<SpecFileDoesNotExportSpecError>()(\n \"SpecFileDoesNotExportSpecError\",\n {},\n) {}\n\nexport class NodeSpecFileDoesNotExportSpecError extends Schema.TaggedError<NodeSpecFileDoesNotExportSpecError>()(\n \"NodeSpecFileDoesNotExportSpecError\",\n {},\n) {}\n\nexport class SpecImportFailedError extends Schema.TaggedError<SpecImportFailedError>()(\n \"SpecImportFailedError\",\n {\n error: Schema.Unknown,\n },\n) {}\n\nconst syncOptionalFile = (generate: typeof generateHttp, convexFile: string) =>\n pipe(\n generate,\n Effect.andThen(\n Option.match({\n onSome: ({ change, convexFilePath }) =>\n Match.value(change).pipe(\n Match.when(\"Unchanged\", () => Effect.void),\n Match.whenOr(\"Added\", \"Modified\", (addedOrModified) =>\n logFileChangeIndented(addedOrModified, convexFilePath),\n ),\n Match.exhaustive,\n ),\n onNone: () =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const convexFilePath = path.join(convexDirectory, convexFile);\n\n if (yield* fs.exists(convexFilePath)) {\n yield* fs.remove(convexFilePath);\n yield* logFileChangeIndented(\"Removed\", convexFilePath);\n }\n }),\n }),\n ),\n );\n\nconst optionalConfectFiles: ReadonlyRecord<string, keyof Pending> = {\n \"http.ts\": \"httpDirty\",\n \"app.ts\": \"appDirty\",\n \"crons.ts\": \"cronsDirty\",\n \"auth.ts\": \"authDirty\",\n \"nodeSpec.ts\": \"specDirty\",\n \"nodeImpl.ts\": \"nodeImplDirty\",\n};\n\nconst confectDirectoryWatcher = (\n signal: Queue.Queue<void>,\n pendingRef: Ref.Ref<Pending>,\n specWatcherRestartQueue: Queue.Queue<void>,\n) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n yield* pipe(\n fs.watch(confectDirectory),\n Stream.runForEach((event) => {\n const basename = path.basename(event.path);\n const pendingKey = optionalConfectFiles[basename];\n\n if (pendingKey !== undefined) {\n return pipe(\n pendingRef,\n Ref.update((pending) => {\n const next = { ...pending, [pendingKey]: true };\n if (basename === \"nodeImpl.ts\") {\n return { ...next, specDirty: true };\n }\n return next;\n }),\n Effect.andThen(Queue.offer(signal, undefined)),\n Effect.andThen(\n basename === \"nodeSpec.ts\"\n ? Queue.offer(specWatcherRestartQueue, undefined)\n : Effect.void,\n ),\n );\n }\n return Effect.void;\n }),\n );\n });\n"],"mappings":";;;;;;;;;;;;;;;;;AAsDA,MAAM,cAAuB;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,IAAI,aAAa;CACtB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,mBAAmB,OAAO,iBAAiB;AAEjD,QAAO,KACL,GAAG,MAAM,iBAAiB,EAC1B,OAAO,YAAY,UAAU;EAC3B,MAAM,WAAW,KAAK,SAAS,MAAM,KAAK;EAC1C,MAAM,aAAa,qBAAqB;AAExC,MAAI,eAAe,OACjB,QAAO,KACL,YACA,IAAI,QAAQ,YAAY;GACtB,MAAM,OAAO;IAAE,GAAG;KAAU,aAAa;IAAM;AAC/C,OAAI,aAAa,cACf,QAAO;IAAE,GAAG;IAAM,WAAW;IAAM;AAErC,UAAO;IACP,EACF,OAAO,QAAQ,MAAM,MAAM,QAAQ,OAAU,CAAC,EAC9C,OAAO,QACL,aAAa,gBACT,MAAM,MAAM,yBAAyB,OAAU,GAC/C,OAAO,KACZ,CACF;AAEH,SAAO,OAAO;GACd,CACH;EACD"}
package/dist/log.mjs CHANGED
@@ -16,10 +16,11 @@ const logFileModified = logFile("~", Ansi.yellow);
16
16
  const logFunction = (char, color) => (functionPath) => Console.log(pipe(AnsiDoc.text(" "), AnsiDoc.cat(pipe(AnsiDoc.char(char), AnsiDoc.annotate(color))), AnsiDoc.catWithSpace(AnsiDoc.hcat([pipe(AnsiDoc.text(toString(functionPath.groupPath) + "."), AnsiDoc.annotate(Ansi.blackBright)), pipe(AnsiDoc.text(functionPath.name), AnsiDoc.annotate(color))])), AnsiDoc.render({ style: "pretty" })));
17
17
  const logFunctionAdded = logFunction("+", Ansi.green);
18
18
  const logFunctionRemoved = logFunction("-", Ansi.red);
19
- const logStatus = (char, charColor, messageText, messageColor) => (message) => Console.log(pipe(AnsiDoc.char(char), AnsiDoc.annotate(charColor), AnsiDoc.catWithSpace(pipe(AnsiDoc.char(" "), AnsiDoc.cat(AnsiDoc.text(messageText)), AnsiDoc.cat(AnsiDoc.char(" ")), AnsiDoc.annotate(messageColor))), AnsiDoc.catWithSpace(AnsiDoc.text(message)), AnsiDoc.render({ style: "pretty" })));
20
- const logCompleted = logStatus("✔︎", Ansi.green, "SUCCESS", Ansi.combine(Ansi.green, Ansi.bgGreenBright));
21
- const logFailed = logStatus("✘", Ansi.red, "FAILURE", Ansi.combine(Ansi.red, Ansi.bgRedBright));
19
+ const logStatus = (char, charColor) => (message) => Console.log(pipe(AnsiDoc.char(char), AnsiDoc.annotate(charColor), AnsiDoc.catWithSpace(AnsiDoc.text(message)), AnsiDoc.render({ style: "pretty" })));
20
+ const logSuccess = logStatus("✔︎", Ansi.green);
21
+ const logFailure = logStatus("✘", Ansi.red);
22
+ const logPending = logStatus("⭘", Ansi.yellow);
22
23
 
23
24
  //#endregion
24
- export { logCompleted, logFailed, logFileAdded, logFileModified, logFileRemoved };
25
+ export { logFailure, logFileAdded, logFileModified, logFileRemoved, logPending, logSuccess };
25
26
  //# sourceMappingURL=log.mjs.map
package/dist/log.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"log.mjs","names":["GroupPath.toString"],"sources":["../src/log.ts"],"sourcesContent":["import { Path } from \"@effect/platform\";\nimport { Ansi, AnsiDoc } from \"@effect/printer-ansi\";\nimport { Console, Effect, pipe, String } from \"effect\";\nimport type * as FunctionPath from \"./FunctionPath\";\nimport * as GroupPath from \"./GroupPath\";\nimport { ProjectRoot } from \"./services/ProjectRoot\";\n\n// --- File operation logs ---\n\nconst logFile = (char: string, color: Ansi.Ansi) => (fullPath: string) =>\n Effect.gen(function* () {\n const projectRoot = yield* ProjectRoot.get;\n const path = yield* Path.Path;\n\n const prefix = projectRoot + path.sep;\n const suffix = pipe(fullPath, String.startsWith(prefix))\n ? pipe(fullPath, String.slice(prefix.length))\n : fullPath;\n\n yield* Console.log(\n pipe(\n AnsiDoc.char(char),\n AnsiDoc.annotate(color),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(AnsiDoc.text(prefix), AnsiDoc.annotate(Ansi.blackBright)),\n pipe(AnsiDoc.text(suffix), AnsiDoc.annotate(color)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n });\n\nexport const logFileAdded = logFile(\"+\", Ansi.green);\n\nexport const logFileRemoved = logFile(\"-\", Ansi.red);\n\nexport const logFileModified = logFile(\"~\", Ansi.yellow);\n\n// --- Function subline logs ---\n\nconst logFunction =\n (char: string, color: Ansi.Ansi) =>\n (functionPath: FunctionPath.FunctionPath) =>\n Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(char), AnsiDoc.annotate(color))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(\n AnsiDoc.text(GroupPath.toString(functionPath.groupPath) + \".\"),\n AnsiDoc.annotate(Ansi.blackBright),\n ),\n pipe(AnsiDoc.text(functionPath.name), AnsiDoc.annotate(color)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n\nexport const logFunctionAdded = logFunction(\"+\", Ansi.green);\n\nexport const logFunctionRemoved = logFunction(\"-\", Ansi.red);\n\n// --- Process status logs ---\n\nconst logStatus =\n (\n char: string,\n charColor: Ansi.Ansi,\n messageText: string,\n messageColor: Ansi.Ansi,\n ) =>\n (message: string) =>\n Console.log(\n pipe(\n AnsiDoc.char(char),\n AnsiDoc.annotate(charColor),\n AnsiDoc.catWithSpace(\n pipe(\n AnsiDoc.char(\" \"),\n AnsiDoc.cat(AnsiDoc.text(messageText)),\n AnsiDoc.cat(AnsiDoc.char(\" \")),\n AnsiDoc.annotate(messageColor),\n ),\n ),\n AnsiDoc.catWithSpace(AnsiDoc.text(message)),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n\nexport const logCompleted = logStatus(\n \"✔︎\",\n Ansi.green,\n \"SUCCESS\",\n Ansi.combine(Ansi.green, Ansi.bgGreenBright),\n);\n\nexport const logFailed = logStatus(\n \"✘\",\n Ansi.red,\n \"FAILURE\",\n Ansi.combine(Ansi.red, Ansi.bgRedBright),\n);\n"],"mapp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AAQ,IACN,KACE,QAAQ,KAAK,KAAK,EAClB,QAAQ,SAAS,UAAU,EAC3B,QAAQ,aACN,KACE,QAAQ,KAAK,IAAI,EACjB,QAAQ,IAAI,QAAQ,KAAK,YAAY,CAAC,EACtC,QAAQ,IAAI,QAAQ,KAAK,IAAI,CAAC,EAC9B,QAAQ,SAAS,aAAa,CAC/B,CACF,EACD,QAAQ,aAAa,QAAQ,KAAK,QAAQ,CAAC,EAC3C,QAAQ,OAAO,EAAE,OAAO,UAAU,CAAC,CACpC,CACF;AAEL,MAAa,eAAe,UAC1B,MACA,KAAK,OACL,WACA,KAAK,QAAQ,KAAK,OAAO,KAAK,cAAc,CAC7C;AAED,MAAa,YAAY,UACvB,KACA,KAAK,KACL,WACA,KAAK,QAAQ,KAAK,KAAK,KAAK,YAAY,CACzC"}
1
+ {"version":3,"file":"log.mjs","names":["GroupPath.toString"],"sources":["../src/log.ts"],"sourcesContent":["import { Path } from \"@effect/platform\";\nimport { Ansi, AnsiDoc } from \"@effect/printer-ansi\";\nimport { Console, Effect, pipe, String } from \"effect\";\nimport type * as FunctionPath from \"./FunctionPath\";\nimport * as GroupPath from \"./GroupPath\";\nimport { ProjectRoot } from \"./services/ProjectRoot\";\n\n// --- File operation logs ---\n\nconst logFile = (char: string, color: Ansi.Ansi) => (fullPath: string) =>\n Effect.gen(function* () {\n const projectRoot = yield* ProjectRoot.get;\n const path = yield* Path.Path;\n\n const prefix = projectRoot + path.sep;\n const suffix = pipe(fullPath, String.startsWith(prefix))\n ? pipe(fullPath, String.slice(prefix.length))\n : fullPath;\n\n yield* Console.log(\n pipe(\n AnsiDoc.char(char),\n AnsiDoc.annotate(color),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(AnsiDoc.text(prefix), AnsiDoc.annotate(Ansi.blackBright)),\n pipe(AnsiDoc.text(suffix), AnsiDoc.annotate(color)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n });\n\nexport const logFileAdded = logFile(\"+\", Ansi.green);\n\nexport const logFileRemoved = logFile(\"-\", Ansi.red);\n\nexport const logFileModified = logFile(\"~\", Ansi.yellow);\n\n// --- Function subline logs ---\n\nconst logFunction =\n (char: string, color: Ansi.Ansi) =>\n (functionPath: FunctionPath.FunctionPath) =>\n Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(char), AnsiDoc.annotate(color))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(\n AnsiDoc.text(GroupPath.toString(functionPath.groupPath) + \".\"),\n AnsiDoc.annotate(Ansi.blackBright),\n ),\n pipe(AnsiDoc.text(functionPath.name), AnsiDoc.annotate(color)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n\nexport const logFunctionAdded = logFunction(\"+\", Ansi.green);\n\nexport const logFunctionRemoved = logFunction(\"-\", Ansi.red);\n\n// --- Process status logs ---\n\nconst logStatus = (char: string, charColor: Ansi.Ansi) => (message: string) =>\n Console.log(\n pipe(\n AnsiDoc.char(char),\n AnsiDoc.annotate(charColor),\n AnsiDoc.catWithSpace(AnsiDoc.text(message)),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n\nexport const logSuccess = logStatus(\"✔︎\", Ansi.green);\n\nexport const logFailure = logStatus(\"✘\", Ansi.red);\n\nexport const logPending = logStatus(\"⭘\", Ansi.yellow);\n"],"mappings":";;;;;;;AASA,MAAM,WAAW,MAAc,WAAsB,aACnD,OAAO,IAAI,aAAa;CAItB,MAAM,UAHc,OAAO,YAAY,QAC1B,OAAO,KAAK,MAES;CAClC,MAAM,SAAS,KAAK,UAAU,OAAO,WAAW,OAAO,CAAC,GACpD,KAAK,UAAU,OAAO,MAAM,OAAO,OAAO,CAAC,GAC3C;AAEJ,QAAO,QAAQ,IACb,KACE,QAAQ,KAAK,KAAK,EAClB,QAAQ,SAAS,MAAM,EACvB,QAAQ,aACN,QAAQ,KAAK,CACX,KAAK,QAAQ,KA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.3";
2
+ var version = "1.0.0-next.4";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -2,11 +2,16 @@ import { Array, Effect } from "effect";
2
2
  import CodeBlockWriter_ from "code-block-writer";
3
3
 
4
4
  //#region src/templates.ts
5
- const functions = ({ groupPath, functionNames, registeredFunctionsImportPath }) => Effect.gen(function* () {
5
+ const functions = ({ groupPath, functionNames, registeredFunctionsImportPath, registeredFunctionsVariableName = "registeredFunctions", registeredFunctionsLookupPath, useNode = false }) => Effect.gen(function* () {
6
6
  const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });
7
- yield* cbw.writeLine(`import registeredFunctions from "${registeredFunctionsImportPath}";`);
7
+ const lookupPath = registeredFunctionsLookupPath ?? groupPath.pathSegments;
8
+ if (useNode) {
9
+ yield* cbw.writeLine(`"use node";`);
10
+ yield* cbw.blankLine();
11
+ }
12
+ yield* cbw.writeLine(`import ${registeredFunctionsVariableName} from "${registeredFunctionsImportPath}";`);
8
13
  yield* cbw.newLine();
9
- for (const functionName of functionNames) yield* cbw.writeLine(`export const ${functionName} = registeredFunctions.${Array.join([...groupPath.pathSegments, functionName], ".")};`);
14
+ for (const functionName of functionNames) yield* cbw.writeLine(`export const ${functionName} = ${registeredFunctionsVariableName}.${Array.join([...lookupPath, functionName], ".")};`);
10
15
  return yield* cbw.toString();
11
16
  });
12
17
  const schema = ({ schemaImportPath }) => Effect.gen(function* () {
@@ -44,12 +49,13 @@ const authConfig = ({ authImportPath }) => Effect.gen(function* () {
44
49
  yield* cbw.writeLine(`export default auth;`);
45
50
  return yield* cbw.toString();
46
51
  });
47
- const refs = ({ specImportPath }) => Effect.gen(function* () {
52
+ const refs = ({ specImportPath, nodeSpecImportPath }) => Effect.gen(function* () {
48
53
  const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });
49
54
  yield* cbw.writeLine(`import { Refs } from "@confect/core";`);
50
55
  yield* cbw.writeLine(`import spec from "${specImportPath}";`);
56
+ if (nodeSpecImportPath !== void 0) yield* cbw.writeLine(`import nodeSpec from "${nodeSpecImportPath}";`);
51
57
  yield* cbw.blankLine();
52
- yield* cbw.writeLine(`export default Refs.make(spec);`);
58
+ yield* cbw.writeLine(nodeSpecImportPath !== void 0 ? `export default Refs.make(spec, nodeSpec);` : `export default Refs.make(spec);`);
53
59
  return yield* cbw.toString();
54
60
  });
55
61
  const api = ({ schemaImportPath, specImportPath }) => Effect.gen(function* () {
@@ -61,12 +67,32 @@ const api = ({ schemaImportPath, specImportPath }) => Effect.gen(function* () {
61
67
  yield* cbw.writeLine(`export default Api.make(schema, spec);`);
62
68
  return yield* cbw.toString();
63
69
  });
70
+ const nodeApi = ({ schemaImportPath, nodeSpecImportPath }) => Effect.gen(function* () {
71
+ const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });
72
+ yield* cbw.writeLine(`import { Api } from "@confect/server";`);
73
+ yield* cbw.blankLine();
74
+ yield* cbw.writeLine(`import schema from "${schemaImportPath}";`);
75
+ yield* cbw.writeLine(`import nodeSpec from "${nodeSpecImportPath}";`);
76
+ yield* cbw.blankLine();
77
+ yield* cbw.writeLine(`export default Api.make(schema, nodeSpec);`);
78
+ return yield* cbw.toString();
79
+ });
64
80
  const registeredFunctions = ({ implImportPath }) => Effect.gen(function* () {
65
81
  const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });
66
- yield* cbw.writeLine(`import { RegisteredFunctions } from "@confect/server";`);
82
+ yield* cbw.writeLine(`import { RegisteredConvexFunction, RegisteredFunctions } from "@confect/server";`);
67
83
  yield* cbw.writeLine(`import impl from "${implImportPath}";`);
68
84
  yield* cbw.blankLine();
69
- yield* cbw.writeLine(`export default RegisteredFunctions.make(impl);`);
85
+ yield* cbw.writeLine(`export default RegisteredFunctions.make(impl, RegisteredConvexFunction.make);`);
86
+ return yield* cbw.toString();
87
+ });
88
+ const nodeRegisteredFunctions = ({ nodeImplImportPath }) => Effect.gen(function* () {
89
+ const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });
90
+ yield* cbw.writeLine(`import { RegisteredFunctions } from "@confect/server";`);
91
+ yield* cbw.writeLine(`import { RegisteredNodeFunction } from "@confect/server/node";`);
92
+ yield* cbw.blankLine();
93
+ yield* cbw.writeLine(`import nodeImpl from "${nodeImplImportPath}";`);
94
+ yield* cbw.blankLine();
95
+ yield* cbw.writeLine(`export default RegisteredFunctions.make(nodeImpl, RegisteredNodeFunction.make);`);
70
96
  return yield* cbw.toString();
71
97
  });
72
98
  const services = ({ schemaImportPath }) => Effect.gen(function* () {
@@ -200,5 +226,5 @@ var CodeBlockWriter = class {
200
226
  };
201
227
 
202
228
  //#endregion
203
- export { api, authConfig, convexConfig, crons, functions, http, refs, registeredFunctions, schema, services };
229
+ export { api, authConfig, convexConfig, crons, functions, http, nodeApi, nodeRegisteredFunctions, refs, registeredFunctions, schema, services };
204
230
  //# sourceMappingURL=templates.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.mjs","names":[],"sources":["../src/templates.ts"],"sourcesContent":["import type { Options as CodeBlockWriterOptions } from \"code-block-writer\";\nimport CodeBlockWriter_ from \"code-block-writer\";\nimport { Array, Effect } from \"effect\";\nimport type * as GroupPath from \"./GroupPath\";\n\nexport const functions = ({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n}: {\n groupPath: GroupPath.GroupPath;\n functionNames: string[];\n registeredFunctionsImportPath: string;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import registeredFunctions from \"${registeredFunctionsImportPath}\";`,\n );\n yield* cbw.newLine();\n for (const functionName of functionNames) {\n yield* cbw.writeLine(\n `export const ${functionName} = registeredFunctions.${Array.join([...groupPath.pathSegments, functionName], \".\")};`,\n );\n }\n\n return yield* cbw.toString();\n });\n\nexport const schema = ({ schemaImportPath }: { schemaImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import schemaDefinition from \"${schemaImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(\n `export default schemaDefinition.convexSchemaDefinition;`,\n );\n\n return yield* cbw.toString();\n });\n\nexport const http = ({ httpImportPath }: { httpImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import http from \"${httpImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default http;`);\n\n return yield* cbw.toString();\n });\n\nexport const convexConfig = ({ appImportPath }: { appImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import app from \"${appImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default app;`);\n\n return yield* cbw.toString();\n });\n\nexport const crons = ({ cronsImportPath }: { cronsImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import crons from \"${cronsImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default crons;`);\n\n return yield* cbw.toString();\n });\n\nexport const authConfig = ({ authImportPath }: { authImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import auth from \"${authImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default auth;`);\n\n return yield* cbw.toString();\n });\n\nexport const refs = ({ specImportPath }: { specImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { Refs } from \"@confect/core\";`);\n yield* cbw.writeLine(`import spec from \"${specImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default Refs.make(spec);`);\n\n return yield* cbw.toString();\n });\n\nexport const api = ({\n schemaImportPath,\n specImportPath,\n}: {\n schemaImportPath: string;\n specImportPath: string;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { Api } from \"@confect/server\";`);\n yield* cbw.writeLine(`import schema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import spec from \"${specImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default Api.make(schema, spec);`);\n\n return yield* cbw.toString();\n });\n\nexport const registeredFunctions = ({\n implImportPath,\n}: {\n implImportPath: string;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { RegisteredFunctions } from \"@confect/server\";`,\n );\n yield* cbw.writeLine(`import impl from \"${implImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default RegisteredFunctions.make(impl);`);\n\n return yield* cbw.toString();\n });\n\nexport const services = ({ schemaImportPath }: { schemaImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n // Imports\n yield* cbw.writeLine(\"import {\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"ActionCtx as ActionCtx_,\");\n yield* cbw.writeLine(\"ActionRunner as ActionRunner_,\");\n yield* cbw.writeLine(\"Auth as Auth_,\");\n yield* cbw.writeLine(\"type DataModel,\");\n yield* cbw.writeLine(\"DatabaseReader as DatabaseReader_,\");\n yield* cbw.writeLine(\"DatabaseWriter as DatabaseWriter_,\");\n yield* cbw.writeLine(\"MutationCtx as MutationCtx_,\");\n yield* cbw.writeLine(\"MutationRunner as MutationRunner_,\");\n yield* cbw.writeLine(\"QueryCtx as QueryCtx_,\");\n yield* cbw.writeLine(\"QueryRunner as QueryRunner_,\");\n yield* cbw.writeLine(\"Scheduler as Scheduler_,\");\n yield* cbw.writeLine(\"Storage,\");\n yield* cbw.writeLine(\"VectorSearch as VectorSearch_,\");\n }),\n );\n yield* cbw.writeLine(`} from \"@confect/server\";`);\n yield* cbw.writeLine(\n `import type schemaDefinition from \"${schemaImportPath}\";`,\n );\n yield* cbw.blankLine();\n\n // Auth\n yield* cbw.writeLine(\"export const Auth = Auth_.Auth;\");\n yield* cbw.writeLine(\"export type Auth = typeof Auth.Identifier;\");\n yield* cbw.blankLine();\n\n // Scheduler\n yield* cbw.writeLine(\"export const Scheduler = Scheduler_.Scheduler;\");\n yield* cbw.writeLine(\n \"export type Scheduler = typeof Scheduler.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageReader\n yield* cbw.writeLine(\"export const StorageReader = Storage.StorageReader;\");\n yield* cbw.writeLine(\n \"export type StorageReader = typeof StorageReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageWriter\n yield* cbw.writeLine(\"export const StorageWriter = Storage.StorageWriter;\");\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 = Storage.StorageActionWriter;\",\n );\n yield* cbw.writeLine(\n \"export type StorageActionWriter = typeof StorageActionWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // VectorSearch\n yield* cbw.writeLine(\"export const VectorSearch =\");\n yield* cbw.indent(\n cbw.writeLine(\n \"VectorSearch_.VectorSearch<DataModel.FromSchema<typeof schemaDefinition>>();\",\n ),\n );\n yield* cbw.writeLine(\n \"export type VectorSearch = typeof VectorSearch.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseReader\n yield* cbw.writeLine(\"export const DatabaseReader =\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DatabaseReader_.DatabaseReader<typeof schemaDefinition>();\",\n ),\n );\n yield* cbw.writeLine(\n \"export type DatabaseReader = typeof DatabaseReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseWriter\n yield* cbw.writeLine(\"export const DatabaseWriter =\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DatabaseWriter_.DatabaseWriter<typeof schemaDefinition>();\",\n ),\n );\n yield* cbw.writeLine(\n \"export type DatabaseWriter = typeof DatabaseWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryRunner\n yield* cbw.writeLine(\n \"export const QueryRunner = QueryRunner_.QueryRunner;\",\n );\n yield* cbw.writeLine(\n \"export type QueryRunner = typeof QueryRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // MutationRunner\n yield* cbw.writeLine(\n \"export const MutationRunner = MutationRunner_.MutationRunner;\",\n );\n yield* cbw.writeLine(\n \"export type MutationRunner = typeof MutationRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // ActionRunner\n yield* cbw.writeLine(\n \"export const ActionRunner = ActionRunner_.ActionRunner;\",\n );\n yield* cbw.writeLine(\n \"export type ActionRunner = typeof ActionRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryCtx\n yield* cbw.writeLine(\"export const QueryCtx =\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"QueryCtx_.QueryCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>\",\n ),\n );\n yield* cbw.writeLine(\">();\");\n }),\n );\n yield* cbw.writeLine(\"export type QueryCtx = typeof QueryCtx.Identifier;\");\n yield* cbw.blankLine();\n\n // MutationCtx\n yield* cbw.writeLine(\"export const MutationCtx =\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"MutationCtx_.MutationCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>\",\n ),\n );\n yield* cbw.writeLine(\">();\");\n }),\n );\n yield* cbw.writeLine(\n \"export type MutationCtx = typeof MutationCtx.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // ActionCtx\n yield* cbw.writeLine(\"export const ActionCtx =\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"ActionCtx_.ActionCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>\",\n ),\n );\n yield* cbw.writeLine(\">();\");\n }),\n );\n yield* cbw.writeLine(\n \"export type ActionCtx = typeof ActionCtx.Identifier;\",\n );\n\n return yield* cbw.toString();\n });\n\nclass CodeBlockWriter {\n private readonly writer: CodeBlockWriter_;\n\n constructor(opts?: Partial<CodeBlockWriterOptions>) {\n this.writer = new CodeBlockWriter_(opts);\n }\n\n indent<E = never, R = never>(\n eff: Effect.Effect<void, E, R>,\n ): Effect.Effect<void, E, R> {\n return Effect.gen(this, function* () {\n const indentationLevel = this.writer.getIndentationLevel();\n this.writer.setIndentationLevel(indentationLevel + 1);\n yield* eff;\n this.writer.setIndentationLevel(indentationLevel);\n });\n }\n\n writeLine<E = never, R = never>(line: string): Effect.Effect<void, E, R> {\n return Effect.sync(() => {\n this.writer.writeLine(line);\n });\n }\n\n write<E = never, R = never>(text: string): Effect.Effect<void, E, R> {\n return Effect.sync(() => {\n this.writer.write(text);\n });\n }\n\n quote<E = never, R = never>(text: string): Effect.Effect<void, E, R> {\n return Effect.sync(() => {\n this.writer.quote(text);\n });\n }\n\n conditionalWriteLine<E = never, R = never>(\n condition: boolean,\n text: string,\n ): Effect.Effect<void, E, R> {\n return Effect.sync(() => {\n this.writer.conditionalWriteLine(condition, text);\n });\n }\n\n newLine<E = never, R = never>(): Effect.Effect<void, E, R> {\n return Effect.sync(() => {\n this.writer.newLine();\n });\n }\n\n blankLine<E = never, R = never>(): Effect.Effect<void, E, R> {\n return Effect.sync(() => {\n this.writer.blankLine();\n });\n }\n\n toString<E = never, R = never>(): Effect.Effect<string, E, R> {\n return Effect.sync(() => this.writer.toString());\n }\n}\n"],"mappings":";;;;AAKA,MAAa,aAAa,EACxB,WACA,eACA,oCAMA,OAAO,IAAI,aAAa;CACtB,MAAM,MAAM,IAAI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,UACT,uDACD;AAED,QAAO,OAAO,IAAI,UAAU;EAC5B;AAEJ,IAAM,kBAAN,MAAsB;CACpB,AAAiB;CAEjB,YAAY,MAAwC;AAClD,OAAK,SAAS,IAAI,iBAAiB,KAAK;;CAG1C,OACE,KAC2B;AAC3B,SAAO,OAAO,IAAI,MAAM,aAAa;GACnC,MAAM,mBAAmB,KAAK,OAAO,qBAAqB;AAC1D,QAAK,OAAO,oBAAoB,mBAAmB,EAAE;AACrD,UAAO;AACP,QAAK,OAAO,oBAAoB,iBAAiB;IACjD;;CAGJ,UAAgC,MAAyC;AACvE,SAAO,OAAO,WAAW;AACvB,QAAK,OAAO,UAAU,KAAK;IAC3B;;CAGJ,MAA4B,MAAyC;AACnE,SAAO,OAAO,WAAW;AACvB,QAAK,OAAO,MAAM,KAAK;IACvB;;CAGJ,MAA4B,MAAyC;AACnE,SAAO,OAAO,WAAW;AACvB,QAAK,OAAO,MAAM,KAAK;IACvB;;CAGJ,qBACE,WACA,MAC2B;AAC3B,SAAO,OAAO,WAAW;AACvB,QAAK,OAAO,qBAAqB,WAAW,KAAK;IACjD;;CAGJ,UAA2D;AACzD,SAAO,OAAO,WAAW;AACvB,QAAK,OAAO,SAAS;IACrB;;CAGJ,YAA6D;AAC3D,SAAO,OAAO,WAAW;AACvB,QAAK,OAAO,WAAW;IACvB;;CAGJ,WAA8D;AAC5D,SAAO,OAAO,WAAW,KAAK,OAAO,UAAU,CAAC"}
1
+ {"version":3,"file":"templates.mjs","names":[],"sources":["../src/templates.ts"],"sourcesContent":["import type { Options as CodeBlockWriterOptions } from \"code-block-writer\";\nimport CodeBlockWriter_ from \"code-block-writer\";\nimport { Array, Effect } from \"effect\";\nimport type * as GroupPath from \"./GroupPath\";\n\nexport const functions = ({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n registeredFunctionsVariableName = \"registeredFunctions\",\n registeredFunctionsLookupPath,\n useNode = false,\n}: {\n groupPath: GroupPath.GroupPath;\n functionNames: string[];\n registeredFunctionsImportPath: string;\n registeredFunctionsVariableName?: string;\n registeredFunctionsLookupPath?: readonly string[];\n useNode?: boolean;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n const lookupPath = registeredFunctionsLookupPath ?? groupPath.pathSegments;\n\n if (useNode) {\n yield* cbw.writeLine(`\"use node\";`);\n yield* cbw.blankLine();\n }\n\n yield* cbw.writeLine(\n `import ${registeredFunctionsVariableName} from \"${registeredFunctionsImportPath}\";`,\n );\n yield* cbw.newLine();\n for (const functionName of functionNames) {\n yield* cbw.writeLine(\n `export const ${functionName} = ${registeredFunctionsVariableName}.${Array.join([...lookupPath, functionName], \".\")};`,\n );\n }\n\n return yield* cbw.toString();\n });\n\nexport const schema = ({ schemaImportPath }: { schemaImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import schemaDefinition from \"${schemaImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(\n `export default schemaDefinition.convexSchemaDefinition;`,\n );\n\n return yield* cbw.toString();\n });\n\nexport const http = ({ httpImportPath }: { httpImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import http from \"${httpImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default http;`);\n\n return yield* cbw.toString();\n });\n\nexport const convexConfig = ({ appImportPath }: { appImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import app from \"${appImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default app;`);\n\n return yield* cbw.toString();\n });\n\nexport const crons = ({ cronsImportPath }: { cronsImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import crons from \"${cronsImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default crons;`);\n\n return yield* cbw.toString();\n });\n\nexport const authConfig = ({ authImportPath }: { authImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import auth from \"${authImportPath}\";`);\n yield* cbw.newLine();\n yield* cbw.writeLine(`export default auth;`);\n\n return yield* cbw.toString();\n });\n\nexport const refs = ({\n specImportPath,\n nodeSpecImportPath,\n}: {\n specImportPath: string;\n nodeSpecImportPath?: string;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { Refs } from \"@confect/core\";`);\n yield* cbw.writeLine(`import spec from \"${specImportPath}\";`);\n if (nodeSpecImportPath !== undefined) {\n yield* cbw.writeLine(`import nodeSpec from \"${nodeSpecImportPath}\";`);\n }\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n nodeSpecImportPath !== undefined\n ? `export default Refs.make(spec, nodeSpec);`\n : `export default Refs.make(spec);`,\n );\n\n return yield* cbw.toString();\n });\n\nexport const api = ({\n schemaImportPath,\n specImportPath,\n}: {\n schemaImportPath: string;\n specImportPath: string;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { Api } from \"@confect/server\";`);\n yield* cbw.writeLine(`import schema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import spec from \"${specImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default Api.make(schema, spec);`);\n\n return yield* cbw.toString();\n });\n\nexport const nodeApi = ({\n schemaImportPath,\n nodeSpecImportPath,\n}: {\n schemaImportPath: string;\n nodeSpecImportPath: string;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(`import { Api } from \"@confect/server\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(`import schema from \"${schemaImportPath}\";`);\n yield* cbw.writeLine(`import nodeSpec from \"${nodeSpecImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default Api.make(schema, nodeSpec);`);\n\n return yield* cbw.toString();\n });\n\nexport const registeredFunctions = ({\n implImportPath,\n}: {\n implImportPath: string;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { RegisteredConvexFunction, RegisteredFunctions } from \"@confect/server\";`,\n );\n yield* cbw.writeLine(`import impl from \"${implImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n `export default RegisteredFunctions.make(impl, RegisteredConvexFunction.make);`,\n );\n\n return yield* cbw.toString();\n });\n\nexport const nodeRegisteredFunctions = ({\n nodeImplImportPath,\n}: {\n nodeImplImportPath: string;\n}) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n `import { RegisteredFunctions } from \"@confect/server\";`,\n );\n yield* cbw.writeLine(\n `import { RegisteredNodeFunction } from \"@confect/server/node\";`,\n );\n yield* cbw.blankLine();\n yield* cbw.writeLine(`import nodeImpl from \"${nodeImplImportPath}\";`);\n yield* cbw.blankLine();\n yield* cbw.writeLine(\n `export default RegisteredFunctions.make(nodeImpl, RegisteredNodeFunction.make);`,\n );\n\n return yield* cbw.toString();\n });\n\nexport const services = ({ schemaImportPath }: { schemaImportPath: string }) =>\n Effect.gen(function* () {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n // Imports\n yield* cbw.writeLine(\"import {\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"ActionCtx as ActionCtx_,\");\n yield* cbw.writeLine(\"ActionRunner as ActionRunner_,\");\n yield* cbw.writeLine(\"Auth as Auth_,\");\n yield* cbw.writeLine(\"type DataModel,\");\n yield* cbw.writeLine(\"DatabaseReader as DatabaseReader_,\");\n yield* cbw.writeLine(\"DatabaseWriter as DatabaseWriter_,\");\n yield* cbw.writeLine(\"MutationCtx as MutationCtx_,\");\n yield* cbw.writeLine(\"MutationRunner as MutationRunner_,\");\n yield* cbw.writeLine(\"QueryCtx as QueryCtx_,\");\n yield* cbw.writeLine(\"QueryRunner as QueryRunner_,\");\n yield* cbw.writeLine(\"Scheduler as Scheduler_,\");\n yield* cbw.writeLine(\"Storage,\");\n yield* cbw.writeLine(\"VectorSearch as VectorSearch_,\");\n }),\n );\n yield* cbw.writeLine(`} from \"@confect/server\";`);\n yield* cbw.writeLine(\n `import type schemaDefinition from \"${schemaImportPath}\";`,\n );\n yield* cbw.blankLine();\n\n // Auth\n yield* cbw.writeLine(\"export const Auth = Auth_.Auth;\");\n yield* cbw.writeLine(\"export type Auth = typeof Auth.Identifier;\");\n yield* cbw.blankLine();\n\n // Scheduler\n yield* cbw.writeLine(\"export const Scheduler = Scheduler_.Scheduler;\");\n yield* cbw.writeLine(\n \"export type Scheduler = typeof Scheduler.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageReader\n yield* cbw.writeLine(\"export const StorageReader = Storage.StorageReader;\");\n yield* cbw.writeLine(\n \"export type StorageReader = typeof StorageReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // StorageWriter\n yield* cbw.writeLine(\"export const StorageWriter = Storage.StorageWriter;\");\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 = Storage.StorageActionWriter;\",\n );\n yield* cbw.writeLine(\n \"export type StorageActionWriter = typeof StorageActionWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // VectorSearch\n yield* cbw.writeLine(\"export const VectorSearch =\");\n yield* cbw.indent(\n cbw.writeLine(\n \"VectorSearch_.VectorSearch<DataModel.FromSchema<typeof schemaDefinition>>();\",\n ),\n );\n yield* cbw.writeLine(\n \"export type VectorSearch = typeof VectorSearch.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseReader\n yield* cbw.writeLine(\"export const DatabaseReader =\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DatabaseReader_.DatabaseReader<typeof schemaDefinition>();\",\n ),\n );\n yield* cbw.writeLine(\n \"export type DatabaseReader = typeof DatabaseReader.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // DatabaseWriter\n yield* cbw.writeLine(\"export const DatabaseWriter =\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DatabaseWriter_.DatabaseWriter<typeof schemaDefinition>();\",\n ),\n );\n yield* cbw.writeLine(\n \"export type DatabaseWriter = typeof DatabaseWriter.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryRunner\n yield* cbw.writeLine(\n \"export const QueryRunner = QueryRunner_.QueryRunner;\",\n );\n yield* cbw.writeLine(\n \"export type QueryRunner = typeof QueryRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // MutationRunner\n yield* cbw.writeLine(\n \"export const MutationRunner = MutationRunner_.MutationRunner;\",\n );\n yield* cbw.writeLine(\n \"export type MutationRunner = typeof MutationRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // ActionRunner\n yield* cbw.writeLine(\n \"export const ActionRunner = ActionRunner_.ActionRunner;\",\n );\n yield* cbw.writeLine(\n \"export type ActionRunner = typeof ActionRunner.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // QueryCtx\n yield* cbw.writeLine(\"export const QueryCtx =\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"QueryCtx_.QueryCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>\",\n ),\n );\n yield* cbw.writeLine(\">();\");\n }),\n );\n yield* cbw.writeLine(\"export type QueryCtx = typeof QueryCtx.Identifier;\");\n yield* cbw.blankLine();\n\n // MutationCtx\n yield* cbw.writeLine(\"export const MutationCtx =\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"MutationCtx_.MutationCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>\",\n ),\n );\n yield* cbw.writeLine(\">();\");\n }),\n );\n yield* cbw.writeLine(\n \"export type MutationCtx = typeof MutationCtx.Identifier;\",\n );\n yield* cbw.blankLine();\n\n // ActionCtx\n yield* cbw.writeLine(\"export const ActionCtx =\");\n yield* cbw.indent(\n Effect.gen(function* () {\n yield* cbw.writeLine(\"ActionCtx_.ActionCtx<\");\n yield* cbw.indent(\n cbw.writeLine(\n \"DataModel.ToConvex<DataModel.FromSchema<typeof schemaDefinition>>\",\n ),\n );\n yield* cbw.writeLine(\">();\");\n }),\n );\n yield* cbw.writeLine(\n \"export type ActionCtx = typeof ActionCtx.Identifier;\",\n );\n\n return yield* cbw.toString();\n });\n\nclass CodeBlockWriter {\n private readonly writer: CodeBlockWriter_;\n\n constructor(opts?: Partial<CodeBlockWriterOptions>) {\n this.writer = new CodeBlockWriter_(opts);\n }\n\n indent<E = never, R = never>(\n eff: Effect.Effect<void, E, R>,\n ): Effect.Effect<void, E, R> {\n return Effect.gen(this, function* () {\n const indentationLevel = this.writer.getIndentationLevel();\n this.writer.setIndentationLevel(indentationLevel + 1);\n yield* eff;\n this.writer.setIndentationLevel(indentationLevel);\n });\n }\n\n writeLine<E = never, R = never>(line: string): Effect.Effect<void, E, R> {\n return Effect.sync(() => {\n this.writer.writeLine(line);\n });\n }\n\n write<E = never, R = never>(text: string): Effect.Effect<void, E, R> {\n return Effect.sync(() => {\n this.writer.write(text);\n });\n }\n\n quote<E = never, R = never>(text: string): Effect.Effect<void, E, R> {\n return Effect.sync(() => {\n this.writer.quote(text);\n });\n }\n\n conditionalWriteLine<E = never, R = never>(\n condition: boolean,\n text: string,\n ): Effect.Effect<void, E, R> {\n return Effect.sync(() => {\n this.writer.conditionalWriteLine(condition, text);\n });\n }\n\n newLine<E = never, R = never>(): Effect.Effect<void, E, R> {\n return Effect.sync(() => {\n this.writer.newLine();\n });\n }\n\n blankLine<E = never, R = never>(): Effect.Effect<void, E, R> {\n return Effect.sync(() => {\n this.writer.blankLine();\n });\n }\n\n toString<E = never, R = never>(): Effect.Effect<string, E, R> {\n return Effect.sync(() => this.writer.toString());\n }\n}\n"],"mappings":";;;;AAKA,MAAa,aAAa,EACxB,WACA,eACA,+BACA,kCAAkC,uBAClC,+BACA,UAAU,YASV,OAAO,IAAI,aAAa;CACtB,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,GAAG,CAAC;CAE5D,MAAM,aAAa,iCAAiC,UAAU;AAE9D,KAAI,SAAS;AACX,SAAO,IAAI,UAAU,cAAc;AACnC,SAAO,IAAI,WAAW;;AAGxB,QAAO,IAAI,UACT,UAAU,gCAAgC,SAAS,8BAA8B,IAClF;AACD,QAAO,IAAI,SAAS;AACpB,MAAK,MAAM,gBAAgB,cACzB,QAAO,IAAI,UACT,gBAAgB,aAAa,KAAK,gCAAgC,GAAG,MAAM,KAAK,CAAC,GAAG,YAAY,aAAa,EAAE,IAAI,CAAC,GACrH;AAGH,QAAO,OAAO,IAAI,UAAU;EAC5B;AAEJ,MAAa,UAAU,EAAE,uBACvB,OAAO,IAAI,aAAa;CACtB,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,GAAG,CAAC;AAE5D,QAAO,IAAI,UAAU,iCAAiC,iBAAiB,IAAI;AAC3E,QAAO,IAAI,SAAS;AACpB,QAAO,IAAI,UACT,0DACD;AAED,QAAO,OAAO,IAAI,UAAU;EAC5B;AAEJ,MAAa,QAAQ,EAAE,qBACrB,OAAO,IAAI,aAAa;CACtB,MAAM,MAAM,IAAI,gBAAgB,EAAE,sBAAsB,GAAG,CAAC;AAE5D,QAAO,IAAI,UAAU,qBAAqB,eAAe,IAAI;AAC7D,QAAO,IAAI,SAAS;AACpB,QAAO,IAA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,IAAI,UAAU,OAAO;GAC5B,CACH;AACD,QAAO,IAAI,UACT,uDACD;AAED,QAAO,OAAO,IAAI,UAAU;EAC5B;AAEJ,IAAM,kBAAN,MAAsB;CACpB,AAAiB;CAEjB,YAAY,MAAwC;AAClD,OAAK,SAAS,IAAI,iBAAiB,KAAK;;CAG1C,OACE,KAC2B;AAC3B,SAAO,OAAO,IAAI,MAAM,aAAa;GACnC,MAAM,mBAAmB,KAAK,OAAO,qBAAqB;AAC1D,QAAK,OAAO,oBAAoB,mBAAmB,EAAE;AACrD,UAAO;AACP,QAAK,OAAO,oBAAoB,iBAAiB;IACjD;;CAGJ,UAAgC,MAAyC;AACvE,SAAO,OAAO,WAAW;AACvB,QAAK,OAAO,UAAU,KAAK;IAC3B;;CAGJ,MAA4B,MAAyC;AACnE,SAAO,OAAO,WAAW;AACvB,QAAK,OAAO,MAAM,KAAK;IACvB;;CAGJ,MAA4B,MAAyC;AACnE,SAAO,OAAO,WAAW;AACvB,QAAK,OAAO,MAAM,KAAK;IACvB;;CAGJ,qBACE,WACA,MAC2B;AAC3B,SAAO,OAAO,WAAW;AACvB,QAAK,OAAO,qBAAqB,WAAW,KAAK;IACjD;;CAGJ,UAA2D;AACzD,SAAO,OAAO,WAAW;AACvB,QAAK,OAAO,SAAS;IACrB;;CAGJ,YAA6D;AAC3D,SAAO,OAAO,WAAW;AACvB,QAAK,OAAO,WAAW;IACvB;;CAGJ,WAA8D;AAC5D,SAAO,OAAO,WAAW,KAAK,OAAO,UAAU,CAAC"}
package/dist/utils.mjs CHANGED
@@ -52,22 +52,28 @@ const generateGroupModule = ({ groupPath, functionNames }) => Effect.gen(functio
52
52
  const convexDirectory = yield* ConvexDirectory.get;
53
53
  const confectDirectory = yield* ConfectDirectory.get;
54
54
  const relativeModulePath = yield* modulePath(groupPath);
55
- const modulePath$1 = path.join(convexDirectory, relativeModulePath);
56
- const directoryPath = path.dirname(modulePath$1);
55
+ const modulePath$2 = path.join(convexDirectory, relativeModulePath);
56
+ const directoryPath = path.dirname(modulePath$2);
57
57
  if (!(yield* fs.exists(directoryPath))) yield* fs.makeDirectory(directoryPath, { recursive: true });
58
- const registeredFunctionsPath = path.join(confectDirectory, "_generated", "registeredFunctions.ts");
59
- const registeredFunctionsImportPath = yield* removePathExtension(path.relative(path.dirname(modulePath$1), registeredFunctionsPath));
58
+ const isNodeGroup = groupPath.pathSegments[0] === "node";
59
+ const registeredFunctionsFileName = isNodeGroup ? "nodeRegisteredFunctions.ts" : "registeredFunctions.ts";
60
+ const registeredFunctionsPath = path.join(confectDirectory, "_generated", registeredFunctionsFileName);
61
+ const registeredFunctionsImportPath = yield* removePathExtension(path.relative(path.dirname(modulePath$2), registeredFunctionsPath));
62
+ const registeredFunctionsVariableName = isNodeGroup ? "nodeRegisteredFunctions" : "registeredFunctions";
60
63
  const functionsContentsString = yield* functions({
61
64
  groupPath,
62
65
  functionNames,
63
- registeredFunctionsImportPath
66
+ registeredFunctionsImportPath,
67
+ registeredFunctionsVariableName,
68
+ useNode: isNodeGroup,
69
+ ...isNodeGroup ? { registeredFunctionsLookupPath: groupPath.pathSegments.slice(1) } : {}
64
70
  });
65
- if (!(yield* fs.exists(modulePath$1))) {
66
- yield* fs.writeFileString(modulePath$1, functionsContentsString);
71
+ if (!(yield* fs.exists(modulePath$2))) {
72
+ yield* fs.writeFileString(modulePath$2, functionsContentsString);
67
73
  return "Added";
68
74
  }
69
- if ((yield* fs.readFileString(modulePath$1)) !== functionsContentsString) {
70
- yield* fs.writeFileString(modulePath$1, functionsContentsString);
75
+ if ((yield* fs.readFileString(modulePath$2)) !== functionsContentsString) {
76
+ yield* fs.writeFileString(modulePath$2, functionsContentsString);
71
77
  return "Modified";
72
78
  }
73
79
  return "Unchanged";
@@ -123,9 +129,9 @@ const removeGroups = (groupPaths) => Effect.gen(function* () {
123
129
  const convexDirectory = yield* ConvexDirectory.get;
124
130
  yield* Effect.all(HashSet.map(groupPaths, (groupPath) => Effect.gen(function* () {
125
131
  const relativeModulePath = yield* modulePath(groupPath);
126
- const modulePath$2 = path.join(convexDirectory, relativeModulePath);
132
+ const modulePath$1 = path.join(convexDirectory, relativeModulePath);
127
133
  yield* Effect.logDebug(`Removing group '${relativeModulePath}'...`);
128
- yield* fs.remove(modulePath$2);
134
+ yield* fs.remove(modulePath$1);
129
135
  yield* Effect.logDebug(`Group '${relativeModulePath}' removed`);
130
136
  })), { concurrency: "unbounded" });
131
137
  });
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":["GroupPath.modulePath","modulePath","templates.functions","FunctionPaths.make","FunctionPaths.groupPaths","GroupPath.getGroupSpec","GroupPath.fromGroupModulePath","templates.http","templates.convexConfig","templates.crons","templates.authConfig"],"sources":["../src/utils.ts"],"sourcesContent":["import type { FunctionSpec, Spec } from \"@confect/core\";\nimport { FileSystem, Path } from \"@effect/platform\";\nimport type { PlatformError } from \"@effect/platform/Error\";\nimport {\n Array,\n Effect,\n HashSet,\n Option,\n Order,\n pipe,\n Record,\n String,\n} from \"effect\";\nimport * as FunctionPaths from \"./FunctionPaths\";\nimport * as GroupPath from \"./GroupPath\";\nimport * as GroupPaths from \"./GroupPaths\";\nimport { logFileAdded, logFileModified, logFileRemoved } from \"./log\";\nimport { ConfectDirectory } from \"./services/ConfectDirectory\";\nimport { ConvexDirectory } from \"./services/ConvexDirectory\";\nimport * as templates from \"./templates\";\n\nexport const removePathExtension = (pathStr: string) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n\n return String.slice(0, -path.extname(pathStr).length)(pathStr);\n });\n\nexport const writeFileStringAndLog = (filePath: string, contents: string) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) {\n yield* fs.writeFileString(filePath, contents);\n yield* logFileAdded(filePath);\n return;\n }\n const existing = yield* fs.readFileString(filePath);\n if (existing !== contents) {\n yield* fs.writeFileString(filePath, contents);\n yield* logFileModified(filePath);\n }\n });\n\nexport const findProjectRoot = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n\n const startDir = path.resolve(\".\");\n const root = path.parse(startDir).root;\n\n const directories = Array.unfold(startDir, (dir) =>\n dir === root\n ? Option.none()\n : Option.some([dir, path.dirname(dir)] as const),\n );\n\n const projectRoot = yield* Effect.findFirst(directories, (dir) =>\n fs.exists(path.join(dir, \"package.json\")),\n );\n\n return Option.getOrElse(projectRoot, () => startDir);\n});\n\nexport type WriteChange = \"Added\" | \"Modified\" | \"Unchanged\";\n\nexport const writeFileString = (\n filePath: string,\n contents: string,\n): Effect.Effect<WriteChange, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n\n if (!(yield* fs.exists(filePath))) {\n yield* fs.writeFileString(filePath, contents);\n return \"Added\";\n }\n const existing = yield* fs.readFileString(filePath);\n if (existing !== contents) {\n yield* fs.writeFileString(filePath, contents);\n return \"Modified\";\n }\n return \"Unchanged\";\n });\n\nexport const generateGroupModule = ({\n groupPath,\n functionNames,\n}: {\n groupPath: GroupPath.GroupPath;\n functionNames: string[];\n}) =>\n Effect.gen(function* () {\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\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 registeredFunctionsPath = path.join(\n confectDirectory,\n \"_generated\",\n \"registeredFunctions.ts\",\n );\n const registeredFunctionsImportPath = yield* removePathExtension(\n path.relative(path.dirname(modulePath), registeredFunctionsPath),\n );\n\n const functionsContentsString = yield* templates.functions({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\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\nconst logGroupPaths = <R>(\n groupPaths: GroupPaths.GroupPaths,\n logFn: (fullPath: string) => Effect.Effect<void, never, R>,\n) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.forEach(groupPaths, (gp) =>\n Effect.gen(function* () {\n const relativeModulePath = yield* GroupPath.modulePath(gp);\n yield* logFn(path.join(convexDirectory, relativeModulePath));\n }),\n );\n });\n\nexport const generateFunctions = (spec: Spec.AnyWithProps) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const groupPathsFromFs = yield* getGroupPathsFromFs;\n const functionPaths = FunctionPaths.make(spec);\n const groupPathsFromSpec = FunctionPaths.groupPaths(functionPaths);\n\n const overlappingGroupPaths = GroupPaths.GroupPaths.make(\n HashSet.intersection(groupPathsFromFs, groupPathsFromSpec),\n );\n yield* Effect.forEach(overlappingGroupPaths, (groupPath) =>\n Effect.gen(function* () {\n const group = yield* GroupPath.getGroupSpec(spec, groupPath);\n const functionNames = pipe(\n group.functions,\n Record.values,\n Array.sortBy(\n Order.mapInput(\n Order.string,\n (fn: FunctionSpec.AnyWithProps) => fn.name,\n ),\n ),\n Array.map((fn) => fn.name),\n );\n const result = yield* generateGroupModule({ groupPath, functionNames });\n if (result === \"Modified\") {\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n yield* logFileModified(\n path.join(convexDirectory, relativeModulePath),\n );\n }\n }),\n );\n\n const extinctGroupPaths = GroupPaths.GroupPaths.make(\n HashSet.difference(groupPathsFromFs, groupPathsFromSpec),\n );\n yield* removeGroups(extinctGroupPaths);\n yield* logGroupPaths(extinctGroupPaths, logFileRemoved);\n\n const newGroupPaths = GroupPaths.GroupPaths.make(\n HashSet.difference(groupPathsFromSpec, groupPathsFromFs),\n );\n yield* writeGroups(spec, newGroupPaths);\n yield* logGroupPaths(newGroupPaths, logFileAdded);\n\n return functionPaths;\n });\n\nconst getGroupPathsFromFs = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const RESERVED_CONVEX_TS_FILE_NAMES = new Set([\n \"schema.ts\",\n \"http.ts\",\n \"crons.ts\",\n \"auth.config.ts\",\n \"convex.config.ts\",\n ]);\n\n const allConvexPaths = yield* fs.readDirectory(convexDirectory, {\n recursive: true,\n });\n const groupPathArray = yield* pipe(\n allConvexPaths,\n Array.filter(\n (convexPath) =>\n path.extname(convexPath) === \".ts\" &&\n !RESERVED_CONVEX_TS_FILE_NAMES.has(path.basename(convexPath)) &&\n path.basename(path.dirname(convexPath)) !== \"_generated\",\n ),\n Effect.forEach((groupModulePath) =>\n GroupPath.fromGroupModulePath(groupModulePath),\n ),\n );\n return pipe(groupPathArray, HashSet.fromIterable, GroupPaths.GroupPaths.make);\n});\n\nexport const removeGroups = (groupPaths: GroupPaths.GroupPaths) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\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* fs.remove(modulePath);\n yield* Effect.logDebug(`Group '${relativeModulePath}' removed`);\n }),\n ),\n { concurrency: \"unbounded\" },\n );\n });\n\nexport const writeGroups = (\n spec: Spec.AnyWithProps,\n groupPaths: GroupPaths.GroupPaths,\n) =>\n Effect.forEach(groupPaths, (groupPath) =>\n Effect.gen(function* () {\n const group = yield* GroupPath.getGroupSpec(spec, groupPath);\n\n const functionNames = pipe(\n group.functions,\n Record.values,\n Array.sortBy(\n Order.mapInput(\n Order.string,\n (fn: FunctionSpec.AnyWithProps) => fn.name,\n ),\n ),\n Array.map((fn) => fn.name),\n );\n\n yield* Effect.logDebug(`Generating group ${groupPath}...`);\n yield* generateGroupModule({\n groupPath,\n functionNames,\n });\n yield* Effect.logDebug(`Group ${groupPath} generated`);\n }),\n );\n\nconst generateOptionalFile = (\n confectFile: string,\n convexFile: string,\n generateContents: (importPath: string) => Effect.Effect<string>,\n) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const confectFilePath = path.join(confectDirectory, confectFile);\n\n if (!(yield* fs.exists(confectFilePath))) {\n return Option.none();\n }\n\n const convexFilePath = path.join(convexDirectory, convexFile);\n const relativeImportPath = path.relative(\n path.dirname(convexFilePath),\n confectFilePath,\n );\n const importPathWithoutExt = yield* removePathExtension(relativeImportPath);\n const contents = yield* generateContents(importPathWithoutExt);\n const change = yield* writeFileString(convexFilePath, contents);\n return Option.some({ change, convexFilePath });\n });\n\nexport const generateHttp = generateOptionalFile(\n \"http.ts\",\n \"http.ts\",\n (importPath) => templates.http({ httpImportPath: importPath }),\n);\n\nexport const generateConvexConfig = generateOptionalFile(\n \"app.ts\",\n \"convex.config.ts\",\n (importPath) => templates.convexConfig({ appImportPath: importPath }),\n);\n\nexport const generateCrons = generateOptionalFile(\n \"crons.ts\",\n \"crons.ts\",\n (importPath) => templates.crons({ cronsImportPath: importPath }),\n);\n\nexport const generateAuthConfig = generateOptionalFile(\n \"auth.ts\",\n \"auth.config.ts\",\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n);\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,uBAAuB,YAClC,OAAO,IAAI,aAAa;CACtB,MAAM,OAAO,OAAO,KAAK;AAEzB,QAAO,OAAO,MAAM,GAAG,CAAC,KAAK,QAAQ,QA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SAAS,OAAO,gBAAgB,gBADrB,OAAO,iBADK,OAAO,oBAJT,KAAK,SAC9B,KAAK,QAAQ,eAAe,EAC5B,gBACD,CAC0E,CACb,CACC;AAC/D,QAAO,OAAO,KAAK;EAAE;EAAQ;EAAgB,CAAC;EAC9C;AAEJ,MAAa,eAAe,qBAC1B,WACA,YACC,eAAeE,KAAe,EAAE,gBAAgB,YAAY,CAAC,CAC/D;AAED,MAAa,uBAAuB,qBAClC,UACA,qBACC,eAAeC,aAAuB,EAAE,eAAe,YAAY,CAAC,CACtE;AAED,MAAa,gBAAgB,qBAC3B,YACA,aACC,eAAeC,MAAgB,EAAE,iBAAiB,YAAY,CAAC,CACjE;AAED,MAAa,qBAAqB,qBAChC,WACA,mBACC,eAAeC,WAAqB,EAAE,gBAAgB,YAAY,CAAC,CACrE"}
1
+ {"version":3,"file":"utils.mjs","names":["GroupPath.modulePath","modulePath","templates.functions","FunctionPaths.make","FunctionPaths.groupPaths","GroupPath.getGroupSpec","GroupPath.fromGroupModulePath","templates.http","templates.convexConfig","templates.crons","templates.authConfig"],"sources":["../src/utils.ts"],"sourcesContent":["import type { FunctionSpec, Spec } from \"@confect/core\";\nimport { FileSystem, Path } from \"@effect/platform\";\nimport type { PlatformError } from \"@effect/platform/Error\";\nimport {\n Array,\n Effect,\n HashSet,\n Option,\n Order,\n pipe,\n Record,\n String,\n} from \"effect\";\nimport * as FunctionPaths from \"./FunctionPaths\";\nimport * as GroupPath from \"./GroupPath\";\nimport * as GroupPaths from \"./GroupPaths\";\nimport { logFileAdded, logFileModified, logFileRemoved } from \"./log\";\nimport { ConfectDirectory } from \"./services/ConfectDirectory\";\nimport { ConvexDirectory } from \"./services/ConvexDirectory\";\nimport * as templates from \"./templates\";\n\nexport const removePathExtension = (pathStr: string) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n\n return String.slice(0, -path.extname(pathStr).length)(pathStr);\n });\n\nexport const writeFileStringAndLog = (filePath: string, contents: string) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) {\n yield* fs.writeFileString(filePath, contents);\n yield* logFileAdded(filePath);\n return;\n }\n const existing = yield* fs.readFileString(filePath);\n if (existing !== contents) {\n yield* fs.writeFileString(filePath, contents);\n yield* logFileModified(filePath);\n }\n });\n\nexport const findProjectRoot = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n\n const startDir = path.resolve(\".\");\n const root = path.parse(startDir).root;\n\n const directories = Array.unfold(startDir, (dir) =>\n dir === root\n ? Option.none()\n : Option.some([dir, path.dirname(dir)] as const),\n );\n\n const projectRoot = yield* Effect.findFirst(directories, (dir) =>\n fs.exists(path.join(dir, \"package.json\")),\n );\n\n return Option.getOrElse(projectRoot, () => startDir);\n});\n\nexport type WriteChange = \"Added\" | \"Modified\" | \"Unchanged\";\n\nexport const writeFileString = (\n filePath: string,\n contents: string,\n): Effect.Effect<WriteChange, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n\n if (!(yield* fs.exists(filePath))) {\n yield* fs.writeFileString(filePath, contents);\n return \"Added\";\n }\n const existing = yield* fs.readFileString(filePath);\n if (existing !== contents) {\n yield* fs.writeFileString(filePath, contents);\n return \"Modified\";\n }\n return \"Unchanged\";\n });\n\nexport const generateGroupModule = ({\n groupPath,\n functionNames,\n}: {\n groupPath: GroupPath.GroupPath;\n functionNames: string[];\n}) =>\n Effect.gen(function* () {\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\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 isNodeGroup = groupPath.pathSegments[0] === \"node\";\n const registeredFunctionsFileName = isNodeGroup\n ? \"nodeRegisteredFunctions.ts\"\n : \"registeredFunctions.ts\";\n const registeredFunctionsPath = path.join(\n confectDirectory,\n \"_generated\",\n registeredFunctionsFileName,\n );\n const registeredFunctionsImportPath = yield* removePathExtension(\n path.relative(path.dirname(modulePath), registeredFunctionsPath),\n );\n const registeredFunctionsVariableName = isNodeGroup\n ? \"nodeRegisteredFunctions\"\n : \"registeredFunctions\";\n\n const functionsContentsString = yield* templates.functions({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n registeredFunctionsVariableName,\n useNode: isNodeGroup,\n ...(isNodeGroup\n ? {\n registeredFunctionsLookupPath: groupPath.pathSegments.slice(1),\n }\n : {}),\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\nconst logGroupPaths = <R>(\n groupPaths: GroupPaths.GroupPaths,\n logFn: (fullPath: string) => Effect.Effect<void, never, R>,\n) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.forEach(groupPaths, (gp) =>\n Effect.gen(function* () {\n const relativeModulePath = yield* GroupPath.modulePath(gp);\n yield* logFn(path.join(convexDirectory, relativeModulePath));\n }),\n );\n });\n\nexport const generateFunctions = (spec: Spec.AnyWithProps) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const groupPathsFromFs = yield* getGroupPathsFromFs;\n const functionPaths = FunctionPaths.make(spec);\n const groupPathsFromSpec = FunctionPaths.groupPaths(functionPaths);\n\n const overlappingGroupPaths = GroupPaths.GroupPaths.make(\n HashSet.intersection(groupPathsFromFs, groupPathsFromSpec),\n );\n yield* Effect.forEach(overlappingGroupPaths, (groupPath) =>\n Effect.gen(function* () {\n const group = yield* GroupPath.getGroupSpec(spec, groupPath);\n const functionNames = pipe(\n group.functions,\n Record.values,\n Array.sortBy(\n Order.mapInput(\n Order.string,\n (fn: FunctionSpec.AnyWithProps) => fn.name,\n ),\n ),\n Array.map((fn) => fn.name),\n );\n const result = yield* generateGroupModule({ groupPath, functionNames });\n if (result === \"Modified\") {\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n yield* logFileModified(\n path.join(convexDirectory, relativeModulePath),\n );\n }\n }),\n );\n\n const extinctGroupPaths = GroupPaths.GroupPaths.make(\n HashSet.difference(groupPathsFromFs, groupPathsFromSpec),\n );\n yield* removeGroups(extinctGroupPaths);\n yield* logGroupPaths(extinctGroupPaths, logFileRemoved);\n\n const newGroupPaths = GroupPaths.GroupPaths.make(\n HashSet.difference(groupPathsFromSpec, groupPathsFromFs),\n );\n yield* writeGroups(spec, newGroupPaths);\n yield* logGroupPaths(newGroupPaths, logFileAdded);\n\n return functionPaths;\n });\n\nconst getGroupPathsFromFs = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const RESERVED_CONVEX_TS_FILE_NAMES = new Set([\n \"schema.ts\",\n \"http.ts\",\n \"crons.ts\",\n \"auth.config.ts\",\n \"convex.config.ts\",\n ]);\n\n const allConvexPaths = yield* fs.readDirectory(convexDirectory, {\n recursive: true,\n });\n const groupPathArray = yield* pipe(\n allConvexPaths,\n Array.filter(\n (convexPath) =>\n path.extname(convexPath) === \".ts\" &&\n !RESERVED_CONVEX_TS_FILE_NAMES.has(path.basename(convexPath)) &&\n path.basename(path.dirname(convexPath)) !== \"_generated\",\n ),\n Effect.forEach((groupModulePath) =>\n GroupPath.fromGroupModulePath(groupModulePath),\n ),\n );\n return pipe(groupPathArray, HashSet.fromIterable, GroupPaths.GroupPaths.make);\n});\n\nexport const removeGroups = (groupPaths: GroupPaths.GroupPaths) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\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* fs.remove(modulePath);\n yield* Effect.logDebug(`Group '${relativeModulePath}' removed`);\n }),\n ),\n { concurrency: \"unbounded\" },\n );\n });\n\nexport const writeGroups = (\n spec: Spec.AnyWithProps,\n groupPaths: GroupPaths.GroupPaths,\n) =>\n Effect.forEach(groupPaths, (groupPath) =>\n Effect.gen(function* () {\n const group = yield* GroupPath.getGroupSpec(spec, groupPath);\n\n const functionNames = pipe(\n group.functions,\n Record.values,\n Array.sortBy(\n Order.mapInput(\n Order.string,\n (fn: FunctionSpec.AnyWithProps) => fn.name,\n ),\n ),\n Array.map((fn) => fn.name),\n );\n\n yield* Effect.logDebug(`Generating group ${groupPath}...`);\n yield* generateGroupModule({\n groupPath,\n functionNames,\n });\n yield* Effect.logDebug(`Group ${groupPath} generated`);\n }),\n );\n\nconst generateOptionalFile = (\n confectFile: string,\n convexFile: string,\n generateContents: (importPath: string) => Effect.Effect<string>,\n) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const confectFilePath = path.join(confectDirectory, confectFile);\n\n if (!(yield* fs.exists(confectFilePath))) {\n return Option.none();\n }\n\n const convexFilePath = path.join(convexDirectory, convexFile);\n const relativeImportPath = path.relative(\n path.dirname(convexFilePath),\n confectFilePath,\n );\n const importPathWithoutExt = yield* removePathExtension(relativeImportPath);\n const contents = yield* generateContents(importPathWithoutExt);\n const change = yield* writeFileString(convexFilePath, contents);\n return Option.some({ change, convexFilePath });\n });\n\nexport const generateHttp = generateOptionalFile(\n \"http.ts\",\n \"http.ts\",\n (importPath) => templates.http({ httpImportPath: importPath }),\n);\n\nexport const generateConvexConfig = generateOptionalFile(\n \"app.ts\",\n \"convex.config.ts\",\n (importPath) => templates.convexConfig({ appImportPath: importPath }),\n);\n\nexport const generateCrons = generateOptionalFile(\n \"crons.ts\",\n \"crons.ts\",\n (importPath) => templates.crons({ cronsImportPath: importPath }),\n);\n\nexport const generateAuthConfig = generateOptionalFile(\n \"auth.ts\",\n \"auth.config.ts\",\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n);\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,uBAAuB,YAClC,OAAO,IAAI,aAAa;CACtB,MAAM,OAAO,OAAO,KAAK;AAEzB,QAAO,OAAO,MAAM,GAAG,CAAC,KAAK,QAAQ,QAAQ,CAAC,OAAO,CAAC,QAAQ;EAC9D;AAEJ,MAAa,yBAAyB,UAAkB,aACtD,OAAO,IAAI,aAAa;CACtB,MAAM,KAAK,OAAO,WAAW;AAC7B,KAAI,EAAE,OAAO,GAAG,OAAO,SAAS,GAAG;AACjC,SAAO,GAAG,gBAAgB,UAAU,SAAS;AAC7C,SAAO,aAAa,SAAS;AAC7B;;AAGF,MADiB,OAAO,GAAG,eAAe,SAAS,MAClC,UAAU;AACzB,SAAO,GAAG,gBAAgB,UAAU,SAAS;AAC7C,SAAO,gBAAgB,SAAS;;EAElC;AAEJ,MAAa,kBAAkB,OAAO,IAAI,aAAa;CACrD,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CAEzB,MAAM,WAAW,KAAK,QAAQ,IAAI;CAClC,MAAM,OAAO,KAAK,MAAM,SAAS,CAAC;CAElC,MAAM,cAAc,MAAM,OAAO,WAAW,QAC1C,QAAQ,OACJ,OAAO,MAAM,GACb,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAU,CACnD;CAED,MAAM,cAAc,OAAO,OAAO,UAAU,cAAc,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6 +1,6 @@
1
1
  {
2
2
  "name": "@confect/cli",
3
- "version": "1.0.0-next.3",
3
+ "version": "1.0.0-next.4",
4
4
  "description": "Developer tooling for codegen and sync",
5
5
  "repository": {
6
6
  "type": "git",
@@ -67,8 +67,8 @@
67
67
  "peerDependencies": {
68
68
  "@effect/platform": "^0.94.4",
69
69
  "effect": "^3.19.16",
70
- "@confect/server": "1.0.0-next.3",
71
- "@confect/core": "1.0.0-next.3"
70
+ "@confect/core": "1.0.0-next.4",
71
+ "@confect/server": "1.0.0-next.4"
72
72
  },
73
73
  "engines": {
74
74
  "node": ">=22",