@gaganref/confect-cli 10.3.1-fork.96 → 10.6.0-fork.2

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.
Files changed (98) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/dist/Ansi.mjs +1 -2
  3. package/dist/BuildError.mjs +5 -5
  4. package/dist/BuildError.mjs.map +1 -1
  5. package/dist/Bundler.mjs +103 -76
  6. package/dist/Bundler.mjs.map +1 -1
  7. package/dist/CodeBlockWriter.mjs +1 -2
  8. package/dist/CodegenError.mjs +27 -17
  9. package/dist/CodegenError.mjs.map +1 -1
  10. package/dist/ConfectDirectory.mjs +8 -3
  11. package/dist/ConfectDirectory.mjs.map +1 -1
  12. package/dist/ConvexConfig.mjs +23 -15
  13. package/dist/ConvexConfig.mjs.map +1 -1
  14. package/dist/ConvexDirectory.mjs +6 -4
  15. package/dist/ConvexDirectory.mjs.map +1 -1
  16. package/dist/Declaration.mjs +92 -56
  17. package/dist/Declaration.mjs.map +1 -1
  18. package/dist/DirectoryOptions.mjs +13 -8
  19. package/dist/DirectoryOptions.mjs.map +1 -1
  20. package/dist/DocName.mjs +1 -2
  21. package/dist/EntryPoint.mjs +17 -15
  22. package/dist/EntryPoint.mjs.map +1 -1
  23. package/dist/Evaluation.mjs +24 -13
  24. package/dist/Evaluation.mjs.map +1 -1
  25. package/dist/EvaluationWorker.mjs +5 -6
  26. package/dist/EvaluationWorker.mjs.map +1 -1
  27. package/dist/FunctionModule.mjs +85 -47
  28. package/dist/FunctionModule.mjs.map +1 -1
  29. package/dist/FunctionPath.mjs +1 -2
  30. package/dist/FunctionPath.mjs.map +1 -1
  31. package/dist/FunctionPaths.mjs +2 -3
  32. package/dist/GenerationSnapshot.mjs +30 -22
  33. package/dist/GenerationSnapshot.mjs.map +1 -1
  34. package/dist/GroupPath.mjs +6 -3
  35. package/dist/GroupPath.mjs.map +1 -1
  36. package/dist/GroupPaths.mjs +1 -2
  37. package/dist/ImplModulePath.mjs +1 -2
  38. package/dist/Json.mjs +13 -0
  39. package/dist/Json.mjs.map +1 -0
  40. package/dist/LeafModule.mjs +121 -41
  41. package/dist/LeafModule.mjs.map +1 -1
  42. package/dist/ManifestSections.mjs +23 -19
  43. package/dist/ManifestSections.mjs.map +1 -1
  44. package/dist/PackageSelfReference.mjs +32 -0
  45. package/dist/PackageSelfReference.mjs.map +1 -0
  46. package/dist/ProjectRoot.mjs +11 -3
  47. package/dist/ProjectRoot.mjs.map +1 -1
  48. package/dist/RelativeModulePath.mjs +1 -2
  49. package/dist/Remove.mjs +2 -3
  50. package/dist/Remove.mjs.map +1 -1
  51. package/dist/RestoreWatcher.mjs +1 -2
  52. package/dist/Rollback.mjs +7 -6
  53. package/dist/Rollback.mjs.map +1 -1
  54. package/dist/SectionFiles.mjs +77 -48
  55. package/dist/SectionFiles.mjs.map +1 -1
  56. package/dist/SnapshotError.mjs +3 -3
  57. package/dist/SnapshotError.mjs.map +1 -1
  58. package/dist/SpecAssemblyNode.mjs +1 -2
  59. package/dist/SpecModulePath.mjs +4 -4
  60. package/dist/SpecModulePath.mjs.map +1 -1
  61. package/dist/SyncState.mjs +3 -4
  62. package/dist/SyncState.mjs.map +1 -1
  63. package/dist/TableModule.mjs +18 -10
  64. package/dist/TableModule.mjs.map +1 -1
  65. package/dist/TableModulePath.mjs +3 -3
  66. package/dist/TableModulePath.mjs.map +1 -1
  67. package/dist/TypeScriptConfig.mjs +135 -0
  68. package/dist/TypeScriptConfig.mjs.map +1 -0
  69. package/dist/WatchBuild.mjs +107 -32
  70. package/dist/WatchBuild.mjs.map +1 -1
  71. package/dist/WatchGraph.mjs +4 -4
  72. package/dist/WatchGraph.mjs.map +1 -1
  73. package/dist/WatchTopology.mjs +5 -4
  74. package/dist/WatchTopology.mjs.map +1 -1
  75. package/dist/Watcher.mjs +179 -108
  76. package/dist/Watcher.mjs.map +1 -1
  77. package/dist/cliApp.mjs +5 -3
  78. package/dist/cliApp.mjs.map +1 -1
  79. package/dist/confect/codegen.mjs +95 -53
  80. package/dist/confect/codegen.mjs.map +1 -1
  81. package/dist/confect/declaration.mjs +76 -42
  82. package/dist/confect/declaration.mjs.map +1 -1
  83. package/dist/confect/dev.mjs +18 -12
  84. package/dist/confect/dev.mjs.map +1 -1
  85. package/dist/confect.mjs +4 -2
  86. package/dist/confect.mjs.map +1 -1
  87. package/dist/index.mjs +1 -2
  88. package/dist/log.mjs +13 -5
  89. package/dist/log.mjs.map +1 -1
  90. package/dist/package.json.mjs +5 -0
  91. package/dist/package.json.mjs.map +1 -0
  92. package/dist/templates.mjs +34 -22
  93. package/dist/templates.mjs.map +1 -1
  94. package/dist/utils.mjs +36 -5
  95. package/dist/utils.mjs.map +1 -1
  96. package/package.json +10 -10
  97. package/dist/package.mjs +0 -6
  98. package/dist/package.mjs.map +0 -1
@@ -1,48 +1,59 @@
1
1
  import { fromBundlerError } from "../BuildError.mjs";
2
- import { ProjectRoot } from "../ProjectRoot.mjs";
3
- import { logFileRemoved, logWarn } from "../log.mjs";
4
2
  import { bundle, resolveModule } from "../Bundler.mjs";
5
3
  import { DeclarationKindMismatchError, HandWrittenConvexFileError, InvalidDeclarationError, logCodegenError } from "../CodegenError.mjs";
6
- import { ConvexDirectory } from "../ConvexDirectory.mjs";
7
4
  import { ConfectDirectory } from "../ConfectDirectory.mjs";
8
- import { authConfig, declaredHttp, http } from "../templates.mjs";
9
- import { removePathIfExists, toModuleImportPath, toPosixPath, writeFileString, writeFileStringAndLog } from "../utils.mjs";
10
5
  import { CONVEX_CONFIG_FILENAME, componentConfigPlugin, componentImportOf, discoverInstalledComponents, resolveDefinition } from "../ConvexConfig.mjs";
11
- import { authConfig as authConfig$1, authProviders, convexConfig, digest, fileOf, isGenerated, manifest, parse, renderManifest } from "../Declaration.mjs";
6
+ import { ConvexDirectory } from "../ConvexDirectory.mjs";
7
+ import { authConfig, authProviders, convexConfig, digest, fileOf, isGenerated, manifest, parse, renderManifest } from "../Declaration.mjs";
12
8
  import { check, collect, declared, sections, summarize } from "../ManifestSections.mjs";
9
+ import { logFileRemoved, logWarn } from "../log.mjs";
10
+ import { ProjectRoot } from "../ProjectRoot.mjs";
11
+ import { authConfig as authConfig$1, declaredHttp, http } from "../templates.mjs";
12
+ import { removePathIfExists, toModuleImportPath, toPosixPath, writeFileString, writeFileStringAndLog } from "../utils.mjs";
13
13
  import * as Effect from "effect/Effect";
14
14
  import { App, Http, Mount } from "@confect/core";
15
15
  import * as FileSystem from "effect/FileSystem";
16
16
  import * as Path from "effect/Path";
17
+ import * as Arr from "effect/Array";
17
18
  import * as Result from "effect/Result";
19
+ import { pipe } from "effect/Function";
18
20
  import * as Option from "effect/Option";
21
+ import * as Rec from "effect/Record";
19
22
  import * as Schema from "effect/Schema";
23
+ import * as String from "effect/String";
20
24
  import * as Predicate from "effect/Predicate";
21
- //#region src/confect/declaration.ts
25
+ // src/confect/declaration.ts
22
26
  /**
23
27
  * Bumped when the generated files change shape, so a manifest written by an
24
28
  * older generator never matches a current one.
25
29
  */
26
30
  const GENERATOR_FORMAT = "2";
27
31
  const confectPath = Effect.fnUntraced(function* (file) {
28
- return (yield* Path.Path).join(yield* ConfectDirectory.get, file);
32
+ const path = yield* Path.Path;
33
+ const confectDirectory = yield* ConfectDirectory.get;
34
+ return path.join(confectDirectory, file);
29
35
  });
30
36
  /**
31
37
  * A backend opts in to the declaration by writing `confect/app.ts`.
38
+ *
39
+ * @internal
32
40
  */
33
41
  const isDeclared = Effect.gen(function* () {
34
- return yield* (yield* FileSystem.FileSystem).exists(yield* confectPath("app.ts"));
42
+ const fs = yield* FileSystem.FileSystem;
43
+ const confectPathResult = yield* confectPath("app.ts");
44
+ return yield* fs.exists(confectPathResult);
35
45
  });
36
46
  const displayPath = Effect.fnUntraced(function* (absolutePath) {
37
47
  const path = yield* Path.Path;
38
- return toPosixPath(path, path.relative(yield* ProjectRoot.get, absolutePath));
48
+ const projectRoot = yield* ProjectRoot.get;
49
+ return toPosixPath(path, path.relative(projectRoot, absolutePath));
39
50
  });
40
51
  const bundleDeclaration = Effect.fnUntraced(function* (file) {
41
52
  const path = yield* Path.Path;
42
53
  const absolutePath = yield* confectPath(file);
43
54
  return yield* bundle(absolutePath, { plugins: [componentConfigPlugin(path)] }).pipe(Effect.mapError((error) => fromBundlerError(`confect/${file}`, error)));
44
55
  });
45
- const invalid = (file) => (error) => new InvalidDeclarationError({
56
+ const invalid = (file) => (error) => InvalidDeclarationError.make({
46
57
  declarationPath: `confect/${file}`,
47
58
  reason: error.message
48
59
  });
@@ -54,8 +65,9 @@ const invalid = (file) => (error) => new InvalidDeclarationError({
54
65
  const assertOwned = Effect.fnUntraced(function* (convexPath, declarationFile, legacy) {
55
66
  const fs = yield* FileSystem.FileSystem;
56
67
  if (!(yield* fs.exists(convexPath))) return;
57
- if (isGenerated(yield* fs.readFileString(convexPath), legacy)) return;
58
- return yield* new HandWrittenConvexFileError({
68
+ const convexPathContents = yield* fs.readFileString(convexPath);
69
+ if (isGenerated(convexPathContents, legacy)) return;
70
+ return yield* HandWrittenConvexFileError.make({
59
71
  convexPath: yield* displayPath(convexPath),
60
72
  declarationPath: `confect/${declarationFile}`
61
73
  });
@@ -84,11 +96,12 @@ const declarationInputs = Effect.fnUntraced(function* (bundles) {
84
96
  const fs = yield* FileSystem.FileSystem;
85
97
  const path = yield* Path.Path;
86
98
  const projectRoot = yield* ProjectRoot.get;
87
- const registry = path.join(yield* ConfectDirectory.get, "_generated", "components.ts");
99
+ const confectDirectory = yield* ConfectDirectory.get;
100
+ const registry = path.join(confectDirectory, "_generated", "components.ts");
88
101
  const files = /* @__PURE__ */ new Set();
89
- for (const { metafile } of bundles) for (const input of Object.keys(metafile.inputs)) {
102
+ for (const { metafile } of bundles) for (const input of Rec.keys(metafile.inputs)) {
90
103
  const relative = path.relative(projectRoot, input);
91
- if (path.isAbsolute(input) && !relative.startsWith("..") && !relative.split(path.sep).includes("node_modules") && path.resolve(input) !== registry) files.add(input);
104
+ if (path.isAbsolute(input) && !pipe(relative, String.startsWith("..")) && !pipe(relative, String.split(path.sep)).includes("node_modules") && path.resolve(input) !== registry) files.add(input);
92
105
  }
93
106
  const real = yield* Effect.filter([...files], (file) => fs.exists(file));
94
107
  return yield* Effect.forEach(real, (file) => fs.readFileString(file).pipe(Effect.map((contents) => [toPosixPath(path, path.relative(projectRoot, file)), contents])));
@@ -97,16 +110,18 @@ const componentImport = Effect.fnUntraced(function* () {
97
110
  const path = yield* Path.Path;
98
111
  const convexDirectory = yield* ConvexDirectory.get;
99
112
  return (definition) => Option.map(componentImportOf(definition), (recorded) => {
100
- const bare = !recorded.specifier.startsWith(".") && !path.isAbsolute(recorded.specifier);
101
- const relative = toPosixPath(path, path.relative(convexDirectory, recorded.path)).replace(/\.([cm]?)[jt]s$/, ".$1js");
113
+ const bare = !pipe(recorded.specifier, String.startsWith(".")) && !path.isAbsolute(recorded.specifier);
114
+ const relative = pipe(toPosixPath(path, path.relative(convexDirectory, recorded.path)), String.replace(/\.([cm]?)[jt]s$/, ".$1js"));
102
115
  return {
103
- importPath: bare ? recorded.specifier : relative.startsWith(".") ? relative : `./${relative}`,
116
+ importPath: bare ? recorded.specifier : pipe(relative, String.startsWith(".")) ? relative : `./${relative}`,
104
117
  componentName: Predicate.hasProperty(definition, "defaultName") && Predicate.isString(definition.defaultName) ? definition.defaultName : "component"
105
118
  };
106
119
  });
107
120
  });
108
121
  const manifestPath = Effect.gen(function* () {
109
- return (yield* Path.Path).join(yield* ConfectDirectory.get, "_generated", "manifest.ts");
122
+ const path = yield* Path.Path;
123
+ const confectDirectory = yield* ConfectDirectory.get;
124
+ return path.join(confectDirectory, "_generated", "manifest.ts");
110
125
  });
111
126
  /**
112
127
  * Remove a file codegen wrote whose source is gone; leave anything else.
@@ -114,12 +129,14 @@ const manifestPath = Effect.gen(function* () {
114
129
  const removeGenerated = Effect.fnUntraced(function* (filePath, legacy) {
115
130
  const fs = yield* FileSystem.FileSystem;
116
131
  if (!(yield* fs.exists(filePath))) return;
117
- if (!isGenerated(yield* fs.readFileString(filePath), legacy)) return;
132
+ const filePathContents = yield* fs.readFileString(filePath);
133
+ if (!isGenerated(filePathContents, legacy)) return;
118
134
  yield* removePathIfExists(filePath);
119
135
  yield* logFileRemoved(filePath);
120
136
  });
121
137
  const removeManifest = Effect.gen(function* () {
122
- yield* removeGenerated(yield* manifestPath, []);
138
+ const manifestPathValue = yield* manifestPath;
139
+ yield* removeGenerated(manifestPathValue, []);
123
140
  });
124
141
  const readManifest = Effect.gen(function* () {
125
142
  const fs = yield* FileSystem.FileSystem;
@@ -128,12 +145,18 @@ const readManifest = Effect.gen(function* () {
128
145
  const data = (yield* bundle(file).pipe(Effect.mapError((error) => fromBundlerError("confect/_generated/manifest.ts", error)))).module.default;
129
146
  return Predicate.isObject(data) ? data : {};
130
147
  });
148
+ /**
149
+ * @internal
150
+ */
131
151
  const readPrevious = readManifest.pipe(Effect.orElseSucceed(() => ({})));
132
- const sectionDigest = (base, sections) => Object.keys(sections).length === 0 ? base : digest({
152
+ const sectionDigest = (base, sections) => Rec.keys(sections).length === 0 ? base : digest({
133
153
  files: [["declaration", base]],
134
154
  versions: [],
135
155
  sections
136
156
  });
157
+ /**
158
+ * @internal
159
+ */
137
160
  const syncManifestSections = Effect.fnUntraced(function* (declared, leaves, previous, baseDigest, modules) {
138
161
  if (baseDigest === void 0) return;
139
162
  const current = yield* readManifest;
@@ -143,10 +166,11 @@ const syncManifestSections = Effect.fnUntraced(function* (declared, leaves, prev
143
166
  const [error, ...more] = checked.errors;
144
167
  for (const other of more) yield* logCodegenError(other);
145
168
  if (error !== void 0) return yield* error;
146
- const sections = Object.fromEntries([...registry].map(([key, { data }]) => [key, data]));
169
+ const sections = Rec.fromEntries(Arr.map([...registry], ([key, { data }]) => [key, data]));
147
170
  const { name, env, http } = current;
148
171
  const digest = sectionDigest(baseDigest, sections);
149
- yield* writeFileStringAndLog(yield* manifestPath, renderManifest({
172
+ const manifestPathValue = yield* manifestPath;
173
+ yield* writeFileStringAndLog(manifestPathValue, renderManifest({
150
174
  name,
151
175
  env,
152
176
  http,
@@ -155,10 +179,13 @@ const syncManifestSections = Effect.fnUntraced(function* (declared, leaves, prev
155
179
  }));
156
180
  }, Effect.tapError(() => removeManifest));
157
181
  const authProvidersPath = Effect.gen(function* () {
158
- return (yield* Path.Path).join(yield* ConfectDirectory.get, "_generated", "auth.providers.ts");
182
+ const path = yield* Path.Path;
183
+ const confectDirectory = yield* ConfectDirectory.get;
184
+ return path.join(confectDirectory, "_generated", "auth.providers.ts");
159
185
  });
160
186
  const removeAuthProviders = Effect.gen(function* () {
161
- yield* removeGenerated(yield* authProvidersPath, []);
187
+ const authProvidersPathValue = yield* authProvidersPath;
188
+ yield* removeGenerated(authProvidersPathValue, []);
162
189
  });
163
190
  const writeDeclaration = Effect.fnUntraced(function* (previous) {
164
191
  const fs = yield* FileSystem.FileSystem;
@@ -168,19 +195,19 @@ const writeDeclaration = Effect.fnUntraced(function* (previous) {
168
195
  const target = (yield* ConvexDirectory.target).kind;
169
196
  const app = yield* bundleDeclaration("app.ts");
170
197
  const appValue = app.module.default;
171
- if (App.isApp(appValue) && appValue.kind !== target) return yield* new DeclarationKindMismatchError({
198
+ if (App.isApp(appValue) && appValue.kind !== target) return yield* DeclarationKindMismatchError.make({
172
199
  declarationPath: "confect/app.ts",
173
200
  declaredKind: appValue.kind,
174
201
  targetKind: target
175
202
  });
176
203
  const authPath = yield* confectPath("auth.ts");
177
- const auth = (yield* fs.exists(authPath)) ? Option.some(yield* bundleDeclaration("auth.ts")) : Option.none();
204
+ const auth = (yield* fs.exists(authPath)) ? yield* Effect.asSome(bundleDeclaration("auth.ts")) : Option.none();
178
205
  const declaration = yield* parse({
179
206
  target,
180
207
  app: app.module.default,
181
208
  auth: Option.map(auth, ({ module }) => module.default),
182
209
  componentImport: yield* componentImport()
183
- }).pipe(Result.mapError((error) => new InvalidDeclarationError({
210
+ }).pipe(Result.mapError((error) => InvalidDeclarationError.make({
184
211
  declarationPath: fileOf(error),
185
212
  reason: error.message
186
213
  })), Effect.fromResult);
@@ -189,7 +216,7 @@ const writeDeclaration = Effect.fnUntraced(function* (previous) {
189
216
  const convexConfigPath = path.join(convexDirectory, CONVEX_CONFIG_FILENAME);
190
217
  const authConfigPath = path.join(convexDirectory, "auth.config.ts");
191
218
  const authImportPath = yield* toModuleImportPath(path.relative(convexDirectory, authPath));
192
- const legacyAuthConfigs = yield* Effect.forEach([authImportPath, authImportPath.replace(/\.js$/, "")], (importPath) => authConfig({ authImportPath: importPath }));
219
+ const legacyAuthConfigs = yield* Effect.forEach([authImportPath, pipe(authImportPath, String.replace(/\.js$/, ""))], (importPath) => authConfig$1({ authImportPath: importPath }));
193
220
  yield* assertOwned(convexConfigPath, "app.ts", []);
194
221
  yield* assertOwned(authConfigPath, "auth.ts", legacyAuthConfigs);
195
222
  let digest$1;
@@ -199,7 +226,8 @@ const writeDeclaration = Effect.fnUntraced(function* (previous) {
199
226
  versions: [["convex", yield* packageVersion("convex", projectRoot)], ["@confect/cli generator format", GENERATOR_FORMAT]]
200
227
  });
201
228
  const sections$1 = sections(previous);
202
- yield* writeFileStringAndLog(yield* manifestPath, manifest(declaration, sectionDigest(digest$1, sections$1), sections$1));
229
+ const manifestPathValue = yield* manifestPath;
230
+ yield* writeFileStringAndLog(manifestPathValue, manifest(declaration, sectionDigest(digest$1, sections$1), sections$1));
203
231
  }
204
232
  yield* writeFileStringAndLog(convexConfigPath, convexConfig(declaration));
205
233
  yield* Option.match(declaration.providers, {
@@ -211,8 +239,9 @@ const writeDeclaration = Effect.fnUntraced(function* (previous) {
211
239
  }
212
240
  }),
213
241
  onSome: (providers) => Effect.gen(function* () {
214
- yield* writeFileStringAndLog(authConfigPath, authConfig$1(providers));
215
- yield* writeFileStringAndLog(yield* authProvidersPath, authProviders(providers));
242
+ yield* writeFileStringAndLog(authConfigPath, authConfig(providers));
243
+ const authProvidersPathValue = yield* authProvidersPath;
244
+ yield* writeFileStringAndLog(authProvidersPathValue, authProviders(providers));
216
245
  })
217
246
  });
218
247
  const sectionTarget = target === "app" ? { kind: "app" } : {
@@ -233,6 +262,8 @@ const writeDeclaration = Effect.fnUntraced(function* (previous) {
233
262
  * `confect/env.ts` and `confect/auth.ts`, before anything else is validated. On
234
263
  * any failure the previous manifest is removed, so a stale manifest never
235
264
  * outlives a declaration that no longer produces it.
265
+ *
266
+ * @internal
236
267
  */
237
268
  const syncDeclaration = Effect.fnUntraced(function* (previous) {
238
269
  if (!(yield* isDeclared)) {
@@ -250,6 +281,8 @@ const syncDeclaration = Effect.fnUntraced(function* (previous) {
250
281
  * Check every HTTP route the backend serves and write `convex/http.ts` from
251
282
  * `confect/http.ts`. Runs after generation, because `http.ts` imports its
252
283
  * handlers, which import generated services.
284
+ *
285
+ * @internal
253
286
  */
254
287
  const syncDeclaredHttp = (app, sectionFiles) => checkAndWriteHttp(app, sectionFiles).pipe(Effect.tapError(() => removeManifest));
255
288
  const checkAndWriteHttp = Effect.fnUntraced(function* (app, sectionFiles) {
@@ -265,7 +298,7 @@ const checkAndWriteHttp = Effect.fnUntraced(function* (app, sectionFiles) {
265
298
  return Option.none();
266
299
  }
267
300
  const http$1 = (yield* bundleDeclaration("http.ts")).module.default;
268
- if (!Http.isHttp(http$1)) return yield* new InvalidDeclarationError({
301
+ if (!Http.isHttp(http$1)) return yield* InvalidDeclarationError.make({
269
302
  declarationPath: "confect/http.ts",
270
303
  reason: "it must default-export Http.make(...)."
271
304
  });
@@ -301,13 +334,13 @@ const hasDeployModule = Effect.fnUntraced(function* (component, config) {
301
334
  const mountExport = Effect.fnUntraced(function* (name) {
302
335
  const fs = yield* FileSystem.FileSystem;
303
336
  const file = yield* confectPath(`${name}.ts`);
304
- const missing = new InvalidDeclarationError({
337
+ const missing = InvalidDeclarationError.make({
305
338
  declarationPath: "confect/app.ts",
306
339
  reason: `the mount ${name} runs at every push, so export it from confect/${name}.ts.`
307
340
  });
308
341
  if (!(yield* fs.exists(file))) return yield* missing;
309
342
  const exports = (yield* bundleDeclaration(`${name}.ts`)).module;
310
- const found = Object.entries(exports).find(([, value]) => Predicate.hasProperty(value, "~@confect/core/Mount") && Mount.data(value).name === name);
343
+ const found = Option.getOrUndefined(Arr.findFirst(Rec.toEntries(exports), ([, value]) => Predicate.hasProperty(value, "~@confect/core/Mount") && Mount.data(value).name === name));
311
344
  if (found === void 0) return yield* missing;
312
345
  return {
313
346
  file,
@@ -319,6 +352,8 @@ const mountExport = Effect.fnUntraced(function* (name) {
319
352
  * steps it runs at each mount: every mount whose component declares `init` or
320
353
  * has a deploy module of its own, in declaration order. Remove it when there
321
354
  * are none.
355
+ *
356
+ * @internal
322
357
  */
323
358
  const syncDeployModule = Effect.fnUntraced(function* (app) {
324
359
  const fs = yield* FileSystem.FileSystem;
@@ -326,14 +361,14 @@ const syncDeployModule = Effect.fnUntraced(function* (app) {
326
361
  const convexDirectory = yield* ConvexDirectory.get;
327
362
  const deployPath = path.join(convexDirectory, DEPLOY_MODULE);
328
363
  const config = path.join(convexDirectory, CONVEX_CONFIG_FILENAME);
329
- const installed = Option.isSome(app) && (yield* fs.exists(config)) ? yield* discoverInstalledComponents(config, yield* displayPath(config), (yield* ConvexDirectory.target).kind) : [];
364
+ const installed = Option.isSome(app) && (yield* fs.exists(config)) ? yield* Effect.flatMap(Effect.all([displayPath(config), ConvexDirectory.target]), ([shown, target]) => discoverInstalledComponents(config, shown, target.kind)) : [];
330
365
  const entries = [];
331
366
  const imports = [];
332
367
  for (const mount of Option.match(app, {
333
368
  onNone: () => [],
334
369
  onSome: App.mounts
335
370
  })) {
336
- const component = installed.find(({ name }) => name === mount.name);
371
+ const component = Option.getOrUndefined(Arr.findFirst(installed, ({ name }) => name === mount.name));
337
372
  const nested = component !== void 0 && (yield* hasDeployModule(component, config));
338
373
  if (mount.component.init === void 0 && !nested) continue;
339
374
  const { file, exportName } = yield* mountExport(mount.name);
@@ -342,7 +377,7 @@ const syncDeployModule = Effect.fnUntraced(function* (app) {
342
377
  entries.push(` { mount: ${local}, nested: ${nested} },`);
343
378
  }
344
379
  if (entries.length === 0) return yield* removeGenerated(deployPath, []);
345
- yield* writeFileStringAndLog(deployPath, [
380
+ yield* writeFileStringAndLog(deployPath, Arr.join([
346
381
  "// Generated by `confect codegen` from confect/app.ts. Do not edit.",
347
382
  "import { MountInit } from \"@confect/server\";",
348
383
  ...imports,
@@ -351,9 +386,8 @@ const syncDeployModule = Effect.fnUntraced(function* (app) {
351
386
  ...entries,
352
387
  "]);",
353
388
  ""
354
- ].join("\n"));
389
+ ], "\n"));
355
390
  });
356
- //#endregion
357
391
  export { isDeclared, readPrevious, syncDeclaration, syncDeclaredHttp, syncDeployModule, syncManifestSections };
358
392
 
359
393
  //# sourceMappingURL=declaration.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"declaration.mjs","names":["Bundler.bundle","ConvexConfig.componentConfigPlugin","Declaration.isGenerated","Bundler.resolveModule","ConvexConfig.componentImportOf","Declaration.digest","ManifestSections.collect","ManifestSections.summarize","ManifestSections.check","Declaration.renderManifest","Declaration.parse","Declaration.fileOf","ManifestSections.declared","ConvexConfig.CONVEX_CONFIG_FILENAME","templates.authConfig","digest","sections","ManifestSections.sections","Declaration.manifest","Declaration.convexConfig","Declaration.authConfig","Declaration.authProviders","templates.http","http","templates.declaredHttp","ConvexConfig.resolveDefinition","ConvexConfig.discoverInstalledComponents"],"sources":["../../src/confect/declaration.ts"],"sourcesContent":["import { App, Http, Mount, type ManifestSection } from \"@confect/core\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Option from \"effect/Option\";\nimport * as Path from \"effect/Path\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport { fromBundlerError } from \"../BuildError.js\";\nimport * as Bundler from \"../Bundler.js\";\nimport {\n HandWrittenConvexFileError,\n DeclarationKindMismatchError,\n InvalidDeclarationError,\n logCodegenError,\n} from \"../CodegenError.js\";\nimport { ConfectDirectory } from \"../ConfectDirectory.js\";\nimport * as ConvexConfig from \"../ConvexConfig.js\";\nimport { ConvexDirectory } from \"../ConvexDirectory.js\";\nimport * as Declaration from \"../Declaration.js\";\nimport * as ManifestSections from \"../ManifestSections.js\";\nimport type { LoadedLeafModule } from \"../LeafModule.js\";\nimport type * as SectionFiles from \"../SectionFiles.js\";\nimport { logWarn, logFileRemoved } from \"../log.js\";\nimport { ProjectRoot } from \"../ProjectRoot.js\";\nimport * as templates from \"../templates.js\";\nimport {\n removePathIfExists,\n toModuleImportPath,\n toPosixPath,\n writeFileString,\n writeFileStringAndLog,\n} from \"../utils.js\";\n\n/**\n * Bumped when the generated files change shape, so a manifest written by an\n * older generator never matches a current one.\n */\nconst GENERATOR_FORMAT = \"2\";\n\nconst confectPath = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, file);\n});\n\n/**\n * A backend opts in to the declaration by writing `confect/app.ts`.\n */\nexport const isDeclared = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n return yield* fs.exists(yield* confectPath(\"app.ts\"));\n});\n\nconst displayPath = Effect.fnUntraced(function* (absolutePath: string) {\n const path = yield* Path.Path;\n return toPosixPath(path, path.relative(yield* ProjectRoot.get, absolutePath));\n});\n\nconst bundleDeclaration = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n const absolutePath = yield* confectPath(file);\n return yield* Bundler.bundle(absolutePath, {\n plugins: [ConvexConfig.componentConfigPlugin(path)],\n }).pipe(\n Effect.mapError((error) => fromBundlerError(`confect/${file}`, error)),\n );\n});\n\nconst invalid = (file: string) => (error: { readonly message: string }) =>\n new InvalidDeclarationError({\n declarationPath: `confect/${file}`,\n reason: error.message,\n });\n\n/**\n * Fail instead of overwriting a Convex file someone wrote by hand. A file with\n * the generated header, or one of the exact files an earlier codegen wrote\n * there, is ours to replace.\n */\nconst assertOwned = Effect.fnUntraced(function* (\n convexPath: string,\n declarationFile: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(convexPath))) return;\n if (Declaration.isGenerated(yield* fs.readFileString(convexPath), legacy)) {\n return;\n }\n return yield* new HandWrittenConvexFileError({\n convexPath: yield* displayPath(convexPath),\n declarationPath: `confect/${declarationFile}`,\n });\n});\n\nconst decodeVersion = Schema.decodeUnknownOption(\n Schema.fromJsonString(Schema.Struct({ version: Schema.String })),\n);\n\nconst packageVersion = Effect.fnUntraced(function* (\n name: string,\n from: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n return yield* Option.match(\n Bundler.resolveModule(`${name}/package.json`, path.join(from, \"_\")),\n {\n onNone: () => Effect.succeed(\"unresolved\"),\n onSome: (packageJson) =>\n fs.readFileString(packageJson).pipe(\n Effect.map((contents) =>\n Option.match(decodeVersion(contents), {\n onNone: () => \"unknown\",\n onSome: ({ version }) => version,\n }),\n ),\n ),\n },\n );\n});\n\n/**\n * Every first-party file the declaration modules import, by project-relative\n * path and contents. Files under `node_modules` and outside the project count\n * through package versions instead, so rebuilding a dependency does not change\n * the digest. The components registry is left out: codegen derives it from the\n * `convex.config.ts` this declaration writes, so its inputs are already here,\n * and a first run bundles a provisional registry that the real one replaces.\n */\nconst declarationInputs = Effect.fnUntraced(function* (\n bundles: ReadonlyArray<Bundler.Bundled>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const projectRoot = yield* ProjectRoot.get;\n const registry = path.join(\n yield* ConfectDirectory.get,\n \"_generated\",\n \"components.ts\",\n );\n const files = new Set<string>();\n for (const { metafile } of bundles) {\n for (const input of Object.keys(metafile.inputs)) {\n const relative = path.relative(projectRoot, input);\n if (\n path.isAbsolute(input) &&\n !relative.startsWith(\"..\") &&\n !relative.split(path.sep).includes(\"node_modules\") &&\n path.resolve(input) !== registry\n ) {\n files.add(input);\n }\n }\n }\n // Plugin namespaces (component config wrappers) appear as inputs too;\n // only real files count.\n const real = yield* Effect.filter([...files], (file) => fs.exists(file));\n return yield* Effect.forEach(real, (file) =>\n fs\n .readFileString(file)\n .pipe(\n Effect.map(\n (contents) =>\n [\n toPosixPath(path, path.relative(projectRoot, file)),\n contents,\n ] as const,\n ),\n ),\n );\n});\n\nconst componentImport = Effect.fnUntraced(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n return (definition: unknown): Option.Option<Declaration.ComponentImport> =>\n Option.map(ConvexConfig.componentImportOf(definition), (recorded) => {\n const bare =\n !recorded.specifier.startsWith(\".\") &&\n !path.isAbsolute(recorded.specifier);\n const relative = toPosixPath(\n path,\n path.relative(convexDirectory, recorded.path),\n ).replace(/\\.([cm]?)[jt]s$/, \".$1js\");\n return {\n importPath: bare\n ? recorded.specifier\n : relative.startsWith(\".\")\n ? relative\n : `./${relative}`,\n componentName:\n Predicate.hasProperty(definition, \"defaultName\") &&\n Predicate.isString(definition.defaultName)\n ? definition.defaultName\n : \"component\",\n };\n });\n});\n\nconst manifestPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, \"_generated\", \"manifest.ts\");\n});\n\n/**\n * Remove a file codegen wrote whose source is gone; leave anything else.\n */\nconst removeGenerated = Effect.fnUntraced(function* (\n filePath: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) return;\n if (!Declaration.isGenerated(yield* fs.readFileString(filePath), legacy)) {\n return;\n }\n yield* removePathIfExists(filePath);\n yield* logFileRemoved(filePath);\n});\n\nconst removeManifest = Effect.gen(function* () {\n yield* removeGenerated(yield* manifestPath, []);\n});\n\nconst readManifest = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const file = yield* manifestPath;\n if (!(yield* fs.exists(file))) return {} as Record<string, unknown>;\n const data: unknown = (yield* Bundler.bundle(file).pipe(\n Effect.mapError((error) =>\n fromBundlerError(\"confect/_generated/manifest.ts\", error),\n ),\n )).module.default;\n return Predicate.isObject(data) ? data : {};\n});\n\nexport const readPrevious = readManifest.pipe(\n Effect.orElseSucceed(() => ({}) as Record<string, unknown>),\n);\n\nconst sectionDigest = (\n base: string,\n sections: Readonly<Record<string, unknown>>,\n) =>\n Object.keys(sections).length === 0\n ? base\n : Declaration.digest({\n files: [[\"declaration\", base]],\n versions: [],\n sections,\n });\n\nexport const syncManifestSections = Effect.fnUntraced(\n function* (\n declared: ReadonlyArray<ManifestSection.Entry>,\n leaves: ReadonlyArray<LoadedLeafModule>,\n previous: Readonly<Record<string, unknown>>,\n baseDigest: string | undefined,\n modules: ReadonlyMap<string, ManifestSection.GenerateInput[\"modules\"]>,\n ) {\n if (baseDigest === undefined) return;\n const current = yield* readManifest;\n const registry = yield* Effect.fromResult(\n ManifestSections.collect(declared, leaves).pipe(\n Result.flatMap((described) =>\n ManifestSections.summarize(described, modules),\n ),\n ),\n );\n const checked = ManifestSections.check(registry, previous);\n for (const note of checked.notes) yield* logWarn(note);\n const [error, ...more] = checked.errors;\n for (const other of more) yield* logCodegenError(other);\n if (error !== undefined) return yield* error;\n const sections = Object.fromEntries(\n [...registry].map(([key, { data }]) => [key, data]),\n );\n const { name, env, http } = current;\n const digest = sectionDigest(baseDigest, sections);\n yield* writeFileStringAndLog(\n yield* manifestPath,\n Declaration.renderManifest({ name, env, http, digest, ...sections }),\n );\n },\n Effect.tapError(() => removeManifest),\n);\n\nconst authProvidersPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n return path.join(\n yield* ConfectDirectory.get,\n \"_generated\",\n \"auth.providers.ts\",\n );\n});\n\nconst removeAuthProviders = Effect.gen(function* () {\n yield* removeGenerated(yield* authProvidersPath, []);\n});\n\nconst writeDeclaration = Effect.fnUntraced(function* (\n previous: Readonly<Record<string, unknown>>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n const target = (yield* ConvexDirectory.target).kind;\n\n const app = yield* bundleDeclaration(\"app.ts\");\n const appValue: unknown = app.module.default;\n if (App.isApp(appValue) && appValue.kind !== target) {\n return yield* new DeclarationKindMismatchError({\n declarationPath: \"confect/app.ts\",\n declaredKind: appValue.kind,\n targetKind: target,\n });\n }\n const authPath = yield* confectPath(\"auth.ts\");\n const auth = (yield* fs.exists(authPath))\n ? Option.some(yield* bundleDeclaration(\"auth.ts\"))\n : Option.none();\n\n const declaration = yield* Declaration.parse({\n target,\n app: app.module.default,\n auth: Option.map(auth, ({ module }) => module.default),\n componentImport: yield* componentImport(),\n }).pipe(\n Result.mapError(\n (error) =>\n new InvalidDeclarationError({\n declarationPath: Declaration.fileOf(error),\n reason: error.message,\n }),\n ),\n Effect.fromResult,\n );\n const manifestSections = App.isApp(appValue) ? appValue.manifestSections : [];\n yield* Effect.fromResult(ManifestSections.declared(manifestSections));\n\n const convexConfigPath = path.join(\n convexDirectory,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n );\n const authConfigPath = path.join(convexDirectory, \"auth.config.ts\");\n const authImportPath = yield* toModuleImportPath(\n path.relative(convexDirectory, authPath),\n );\n const legacyAuthConfigs = yield* Effect.forEach(\n [authImportPath, authImportPath.replace(/\\.js$/, \"\")],\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n );\n yield* assertOwned(convexConfigPath, \"app.ts\", []);\n yield* assertOwned(authConfigPath, \"auth.ts\", legacyAuthConfigs);\n\n let digest: string | undefined;\n if (target === \"app\") {\n digest = Declaration.digest({\n files: yield* declarationInputs([app, ...Option.toArray(auth)]),\n versions: [\n [\"convex\", yield* packageVersion(\"convex\", projectRoot)],\n [\"@confect/cli generator format\", GENERATOR_FORMAT],\n ],\n });\n const sections = ManifestSections.sections(previous);\n yield* writeFileStringAndLog(\n yield* manifestPath,\n Declaration.manifest(\n declaration,\n sectionDigest(digest, sections),\n sections,\n ),\n );\n }\n yield* writeFileStringAndLog(\n convexConfigPath,\n Declaration.convexConfig(declaration),\n );\n yield* Option.match(declaration.providers, {\n onNone: () =>\n Effect.gen(function* () {\n yield* removeAuthProviders;\n if (yield* fs.exists(authConfigPath)) {\n yield* removePathIfExists(authConfigPath);\n yield* logFileRemoved(authConfigPath);\n }\n }),\n onSome: (providers) =>\n Effect.gen(function* () {\n yield* writeFileStringAndLog(\n authConfigPath,\n Declaration.authConfig(providers),\n );\n yield* writeFileStringAndLog(\n yield* authProvidersPath,\n Declaration.authProviders(providers),\n );\n }),\n });\n const sectionTarget: ManifestSection.Target =\n target === \"app\"\n ? { kind: \"app\" }\n : { kind: \"component\", name: declaration.name };\n return {\n app: App.isApp(appValue) ? Option.some(appValue) : Option.none<App.Any>(),\n digest,\n backend: Option.some<SectionFiles.Backend>({\n target: sectionTarget,\n sections: manifestSections,\n }),\n };\n});\n\n/**\n * Write the declaration's Convex files and manifest from `confect/app.ts`,\n * `confect/env.ts` and `confect/auth.ts`, before anything else is validated. On\n * any failure the previous manifest is removed, so a stale manifest never\n * outlives a declaration that no longer produces it.\n */\nexport const syncDeclaration = Effect.fnUntraced(function* (\n previous: Readonly<Record<string, unknown>>,\n) {\n if (!(yield* isDeclared)) {\n yield* removeManifest;\n yield* removeAuthProviders;\n return {\n app: Option.none<App.Any>(),\n digest: undefined,\n backend: Option.none<SectionFiles.Backend>(),\n };\n }\n return yield* writeDeclaration(previous).pipe(\n Effect.tapError(() =>\n removeManifest.pipe(Effect.andThen(removeAuthProviders)),\n ),\n );\n});\n\n/**\n * Check every HTTP route the backend serves and write `convex/http.ts` from\n * `confect/http.ts`. Runs after generation, because `http.ts` imports its\n * handlers, which import generated services.\n */\nexport const syncDeclaredHttp = (\n app: App.Any,\n sectionFiles: ReadonlyArray<string>,\n) =>\n checkAndWriteHttp(app, sectionFiles).pipe(\n Effect.tapError(() => removeManifest),\n );\n\nconst checkAndWriteHttp = Effect.fnUntraced(function* (\n app: App.Any,\n sectionFiles: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const confectDirectory = yield* ConfectDirectory.get;\n const httpPath = yield* confectPath(\"http.ts\");\n\n const convexHttpPath = path.join(convexDirectory, \"http.ts\");\n if (!(yield* fs.exists(httpPath))) {\n yield* Http.routes(app).pipe(\n Result.mapError(invalid(\"app.ts\")),\n Effect.fromResult,\n );\n yield* removeGenerated(convexHttpPath, [\n yield* templates.http({\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n }),\n ]);\n return Option.none();\n }\n\n const http = (yield* bundleDeclaration(\"http.ts\")).module.default;\n if (!Http.isHttp(http)) {\n return yield* new InvalidDeclarationError({\n declarationPath: \"confect/http.ts\",\n reason: \"it must default-export Http.make(...).\",\n });\n }\n yield* Http.routes(app, http).pipe(\n Result.mapError(invalid(\"http.ts\")),\n Effect.fromResult,\n );\n\n const contents = yield* templates.declaredHttp({\n runtimeImportPath: (yield* fs.exists(\n path.join(confectDirectory, \"runtime.ts\"),\n ))\n ? yield* toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"runtime.ts\"),\n ),\n )\n : undefined,\n schemaImportPath: yield* toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"_generated\", \"schema.ts\"),\n ),\n ),\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n sectionImportPaths: yield* Effect.forEach(sectionFiles, (file) =>\n toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"_generated\", file),\n ),\n ),\n ),\n });\n const change = yield* writeFileString(convexHttpPath, contents);\n return Option.some({ change, convexFilePath: convexHttpPath });\n});\n\nconst DEPLOY_MODULE = \"confectDeploy.ts\";\n\n/**\n * Whether a mounted component's own codegen wrote a deploy module, so a push\n * visits its mounts after its `init`.\n */\nconst hasDeployModule = Effect.fnUntraced(function* (\n component: ConvexConfig.InstalledComponent,\n config: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const directory = path.isAbsolute(component.componentDefinitionPath)\n ? Option.some(component.componentDefinitionPath)\n : Option.map(\n ConvexConfig.resolveDefinition(\n `${component.componentDefinitionPath}/convex.config`,\n config,\n path,\n ),\n path.dirname,\n );\n if (Option.isNone(directory)) return false;\n for (const file of [DEPLOY_MODULE, \"confectDeploy.js\"]) {\n if (yield* fs.exists(path.join(directory.value, file))) return true;\n }\n return false;\n});\n\n/**\n * The export of `confect/<name>.ts` that is the mount named `name`.\n */\nconst mountExport = Effect.fnUntraced(function* (name: string) {\n const fs = yield* FileSystem.FileSystem;\n const file = yield* confectPath(`${name}.ts`);\n const missing = new InvalidDeclarationError({\n declarationPath: \"confect/app.ts\",\n reason: `the mount ${name} runs at every push, so export it from confect/${name}.ts.`,\n });\n if (!(yield* fs.exists(file))) return yield* missing;\n const exports: Record<string, unknown> = (yield* bundleDeclaration(\n `${name}.ts`,\n )).module;\n const found = Object.entries(exports).find(\n ([, value]) =>\n Predicate.hasProperty(value, \"~@confect/core/Mount\") &&\n Mount.data(value as Mount.Any).name === name,\n );\n if (found === undefined) return yield* missing;\n return { file, exportName: found[0] };\n});\n\n/**\n * Write `convex/confectDeploy.ts`, the internal mutation a push calls for the\n * steps it runs at each mount: every mount whose component declares `init` or\n * has a deploy module of its own, in declaration order. Remove it when there\n * are none.\n */\nexport const syncDeployModule = Effect.fnUntraced(function* (\n app: Option.Option<App.Any>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const deployPath = path.join(convexDirectory, DEPLOY_MODULE);\n const config = path.join(\n convexDirectory,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n );\n const installed =\n Option.isSome(app) && (yield* fs.exists(config))\n ? yield* ConvexConfig.discoverInstalledComponents(\n config,\n yield* displayPath(config),\n (yield* ConvexDirectory.target).kind,\n )\n : [];\n const entries: Array<string> = [];\n const imports: Array<string> = [];\n for (const mount of Option.match(app, {\n onNone: () => [],\n onSome: App.mounts,\n })) {\n const component = installed.find(({ name }) => name === mount.name);\n const nested =\n component !== undefined && (yield* hasDeployModule(component, config));\n if (mount.component.init === undefined && !nested) continue;\n const { file, exportName } = yield* mountExport(mount.name);\n const local = `mount${entries.length}`;\n imports.push(\n `import { ${exportName} as ${local} } from \"${yield* toModuleImportPath(path.relative(convexDirectory, file))}\";`,\n );\n entries.push(` { mount: ${local}, nested: ${nested} },`);\n }\n if (entries.length === 0) return yield* removeGenerated(deployPath, []);\n yield* writeFileStringAndLog(\n deployPath,\n [\n \"// Generated by `confect codegen` from confect/app.ts. Do not edit.\",\n 'import { MountInit } from \"@confect/server\";',\n ...imports,\n \"\",\n \"export const steps = MountInit.mutation([\",\n ...entries,\n \"]);\",\n \"\",\n ].join(\"\\n\"),\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,mBAAmB;AAEzB,MAAM,cAAc,OAAO,WAAW,WAAW,MAAc;CAE7D,QAAO,OADa,KAAK,KAAA,CACb,KAAK,OAAO,iBAAiB,KAAK,IAAI;AACpD,CAAC;;;;AAKD,MAAa,aAAa,OAAO,IAAI,aAAa;CAEhD,OAAO,QAAO,OADI,WAAW,WAAA,CACZ,OAAO,OAAO,YAAY,QAAQ,CAAC;AACtD,CAAC;AAED,MAAM,cAAc,OAAO,WAAW,WAAW,cAAsB;CACrE,MAAM,OAAO,OAAO,KAAK;CACzB,OAAO,YAAY,MAAM,KAAK,SAAS,OAAO,YAAY,KAAK,YAAY,CAAC;AAC9E,CAAC;AAED,MAAM,oBAAoB,OAAO,WAAW,WAAW,MAAc;CACnE,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,eAAe,OAAO,YAAY,IAAI;CAC5C,OAAO,OAAOA,OAAe,cAAc,EACzC,SAAS,CAACC,sBAAmC,IAAI,CAAC,EACpD,CAAC,CAAC,CAAC,KACD,OAAO,UAAU,UAAU,iBAAiB,WAAW,QAAQ,KAAK,CAAC,CACvE;AACF,CAAC;AAED,MAAM,WAAW,UAAkB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G,OAAO,MAAM,KAC1C,OAAOa,4BACL,QACA,OAAO,YAAY,MAAM,IACxB,OAAO,gBAAgB,OAAA,CAAQ,IAClC,IACA,CAAC;CACP,MAAM,UAAyB,CAAC;CAChC,MAAM,UAAyB,CAAC;CAChC,KAAK,MAAM,SAAS,OAAO,MAAM,KAAK;EACpC,cAAc,CAAC;EACf,QAAQ,IAAI;CACd,CAAC,GAAG;EACF,MAAM,YAAY,UAAU,MAAM,EAAE,WAAW,SAAS,MAAM,IAAI;EAClE,MAAM,SACJ,cAAc,KAAA,MAAc,OAAO,gBAAgB,WAAW,MAAM;EACtE,IAAI,MAAM,UAAU,SAAS,KAAA,KAAa,CAAC,QAAQ;EACnD,MAAM,EAAE,MAAM,eAAe,OAAO,YAAY,MAAM,IAAI;EAC1D,MAAM,QAAQ,QAAQ,QAAQ;EAC9B,QAAQ,KACN,YAAY,WAAW,MAAM,MAAM,WAAW,OAAO,mBAAmB,KAAK,SAAS,iBAAiB,IAAI,CAAC,EAAE,GAChH;EACA,QAAQ,KAAK,cAAc,MAAM,YAAY,OAAO,IAAI;CAC1D;CACA,IAAI,QAAQ,WAAW,GAAG,OAAO,OAAO,gBAAgB,YAAY,CAAC,CAAC;CACtE,OAAO,sBACL,YACA;EACE;EACA;EACA,GAAG;EACH;EACA;EACA,GAAG;EACH;EACA;CACF,CAAC,CAAC,KAAK,IAAI,CACb;AACF,CAAC"}
1
+ {"version":3,"file":"declaration.mjs","names":["Bundler.bundle","ConvexConfig.componentConfigPlugin","Declaration.isGenerated","Bundler.resolveModule","ConvexConfig.componentImportOf","Declaration.digest","ManifestSections.collect","ManifestSections.summarize","ManifestSections.check","Declaration.renderManifest","Declaration.parse","Declaration.fileOf","ManifestSections.declared","ConvexConfig.CONVEX_CONFIG_FILENAME","templates.authConfig","digest","sections","ManifestSections.sections","Declaration.manifest","Declaration.convexConfig","Declaration.authConfig","Declaration.authProviders","templates.http","http","templates.declaredHttp","ConvexConfig.resolveDefinition","ConvexConfig.discoverInstalledComponents"],"sources":["../../src/confect/declaration.ts"],"sourcesContent":["import { App, Http, Mount, type ManifestSection } from \"@confect/core\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Option from \"effect/Option\";\nimport * as Path from \"effect/Path\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport { fromBundlerError } from \"../BuildError.js\";\nimport * as Bundler from \"../Bundler.js\";\nimport {\n HandWrittenConvexFileError,\n DeclarationKindMismatchError,\n InvalidDeclarationError,\n logCodegenError,\n} from \"../CodegenError.js\";\nimport { ConfectDirectory } from \"../ConfectDirectory.js\";\nimport * as ConvexConfig from \"../ConvexConfig.js\";\nimport { ConvexDirectory } from \"../ConvexDirectory.js\";\nimport * as Declaration from \"../Declaration.js\";\nimport * as ManifestSections from \"../ManifestSections.js\";\nimport type { LoadedLeafModule } from \"../LeafModule.js\";\nimport type * as SectionFiles from \"../SectionFiles.js\";\nimport { logWarn, logFileRemoved } from \"../log.js\";\nimport { ProjectRoot } from \"../ProjectRoot.js\";\nimport * as templates from \"../templates.js\";\nimport {\n removePathIfExists,\n toModuleImportPath,\n toPosixPath,\n writeFileString,\n writeFileStringAndLog,\n} from \"../utils.js\";\nimport * as String from \"effect/String\";\nimport { pipe } from \"effect/Function\";\nimport * as Arr from \"effect/Array\";\nimport * as Rec from \"effect/Record\";\n\n/**\n * Bumped when the generated files change shape, so a manifest written by an\n * older generator never matches a current one.\n */\nconst GENERATOR_FORMAT = \"2\";\n\nconst confectPath = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n return path.join(confectDirectory, file);\n});\n\n/**\n * A backend opts in to the declaration by writing `confect/app.ts`.\n *\n * @internal\n */\nexport const isDeclared = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const confectPathResult = yield* confectPath(\"app.ts\");\n return yield* fs.exists(confectPathResult);\n});\n\nconst displayPath = Effect.fnUntraced(function* (absolutePath: string) {\n const path = yield* Path.Path;\n const projectRoot = yield* ProjectRoot.get;\n return toPosixPath(path, path.relative(projectRoot, absolutePath));\n});\n\nconst bundleDeclaration = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n const absolutePath = yield* confectPath(file);\n return yield* Bundler.bundle(absolutePath, {\n plugins: [ConvexConfig.componentConfigPlugin(path)],\n }).pipe(\n Effect.mapError((error) => fromBundlerError(`confect/${file}`, error)),\n );\n});\n\nconst invalid = (file: string) => (error: { readonly message: string }) =>\n InvalidDeclarationError.make({\n declarationPath: `confect/${file}`,\n reason: error.message,\n });\n\n/**\n * Fail instead of overwriting a Convex file someone wrote by hand. A file with\n * the generated header, or one of the exact files an earlier codegen wrote\n * there, is ours to replace.\n */\nconst assertOwned = Effect.fnUntraced(function* (\n convexPath: string,\n declarationFile: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(convexPath))) return;\n const convexPathContents = yield* fs.readFileString(convexPath);\n if (Declaration.isGenerated(convexPathContents, legacy)) {\n return;\n }\n return yield* HandWrittenConvexFileError.make({\n convexPath: yield* displayPath(convexPath),\n declarationPath: `confect/${declarationFile}`,\n });\n});\n\nconst decodeVersion = Schema.decodeUnknownOption(\n Schema.fromJsonString(Schema.Struct({ version: Schema.String })),\n);\n\nconst packageVersion = Effect.fnUntraced(function* (\n name: string,\n from: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n return yield* Option.match(\n Bundler.resolveModule(`${name}/package.json`, path.join(from, \"_\")),\n {\n onNone: () => Effect.succeed(\"unresolved\"),\n onSome: (packageJson) =>\n fs.readFileString(packageJson).pipe(\n Effect.map((contents) =>\n Option.match(decodeVersion(contents), {\n onNone: () => \"unknown\",\n onSome: ({ version }) => version,\n }),\n ),\n ),\n },\n );\n});\n\n/**\n * Every first-party file the declaration modules import, by project-relative\n * path and contents. Files under `node_modules` and outside the project count\n * through package versions instead, so rebuilding a dependency does not change\n * the digest. The components registry is left out: codegen derives it from the\n * `convex.config.ts` this declaration writes, so its inputs are already here,\n * and a first run bundles a provisional registry that the real one replaces.\n */\nconst declarationInputs = Effect.fnUntraced(function* (\n bundles: ReadonlyArray<Bundler.Bundled>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const projectRoot = yield* ProjectRoot.get;\n const confectDirectory = yield* ConfectDirectory.get;\n const registry = path.join(confectDirectory, \"_generated\", \"components.ts\");\n const files = new Set<string>();\n for (const { metafile } of bundles) {\n for (const input of Rec.keys(metafile.inputs)) {\n const relative = path.relative(projectRoot, input);\n if (\n path.isAbsolute(input) &&\n !pipe(relative, String.startsWith(\"..\")) &&\n !pipe(relative, String.split(path.sep)).includes(\"node_modules\") &&\n path.resolve(input) !== registry\n ) {\n files.add(input);\n }\n }\n }\n // Plugin namespaces (component config wrappers) appear as inputs too;\n // only real files count.\n const real = yield* Effect.filter([...files], (file) => fs.exists(file));\n return yield* Effect.forEach(real, (file) =>\n fs\n .readFileString(file)\n .pipe(\n Effect.map(\n (contents) =>\n [\n toPosixPath(path, path.relative(projectRoot, file)),\n contents,\n ] as const,\n ),\n ),\n );\n});\n\nconst componentImport = Effect.fnUntraced(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n return (definition: unknown): Option.Option<Declaration.ComponentImport> =>\n Option.map(ConvexConfig.componentImportOf(definition), (recorded) => {\n const bare =\n !pipe(recorded.specifier, String.startsWith(\".\")) &&\n !path.isAbsolute(recorded.specifier);\n const relative = pipe(\n toPosixPath(path, path.relative(convexDirectory, recorded.path)),\n String.replace(/\\.([cm]?)[jt]s$/, \".$1js\"),\n );\n return {\n importPath: bare\n ? recorded.specifier\n : pipe(relative, String.startsWith(\".\"))\n ? relative\n : `./${relative}`,\n componentName:\n Predicate.hasProperty(definition, \"defaultName\") &&\n Predicate.isString(definition.defaultName)\n ? definition.defaultName\n : \"component\",\n };\n });\n});\n\nconst manifestPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n return path.join(confectDirectory, \"_generated\", \"manifest.ts\");\n});\n\n/**\n * Remove a file codegen wrote whose source is gone; leave anything else.\n */\nconst removeGenerated = Effect.fnUntraced(function* (\n filePath: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) return;\n const filePathContents = yield* fs.readFileString(filePath);\n if (!Declaration.isGenerated(filePathContents, legacy)) {\n return;\n }\n yield* removePathIfExists(filePath);\n yield* logFileRemoved(filePath);\n});\n\nconst removeManifest = Effect.gen(function* () {\n const manifestPathValue = yield* manifestPath;\n yield* removeGenerated(manifestPathValue, []);\n});\n\nconst readManifest = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const file = yield* manifestPath;\n if (!(yield* fs.exists(file))) return {} as Record<string, unknown>;\n const data: unknown = (yield* Bundler.bundle(file).pipe(\n Effect.mapError((error) =>\n fromBundlerError(\"confect/_generated/manifest.ts\", error),\n ),\n )).module.default;\n return Predicate.isObject(data) ? data : {};\n});\n\n/**\n * @internal\n */\nexport const readPrevious = readManifest.pipe(\n Effect.orElseSucceed(() => ({}) as Record<string, unknown>),\n);\n\nconst sectionDigest = (\n base: string,\n sections: Readonly<Record<string, unknown>>,\n) =>\n Rec.keys(sections).length === 0\n ? base\n : Declaration.digest({\n files: [[\"declaration\", base]],\n versions: [],\n sections,\n });\n\n/**\n * @internal\n */\nexport const syncManifestSections = Effect.fnUntraced(\n function* (\n declared: ReadonlyArray<ManifestSection.Entry>,\n leaves: ReadonlyArray<LoadedLeafModule>,\n previous: Readonly<Record<string, unknown>>,\n baseDigest: string | undefined,\n modules: ReadonlyMap<string, ManifestSection.GenerateInput[\"modules\"]>,\n ) {\n if (baseDigest === undefined) return;\n const current = yield* readManifest;\n const registry = yield* Effect.fromResult(\n ManifestSections.collect(declared, leaves).pipe(\n Result.flatMap((described) =>\n ManifestSections.summarize(described, modules),\n ),\n ),\n );\n const checked = ManifestSections.check(registry, previous);\n for (const note of checked.notes) yield* logWarn(note);\n const [error, ...more] = checked.errors;\n for (const other of more) yield* logCodegenError(other);\n if (error !== undefined) return yield* error;\n const sections = Rec.fromEntries(\n Arr.map([...registry], ([key, { data }]) => [key, data]),\n );\n const { name, env, http } = current;\n const digest = sectionDigest(baseDigest, sections);\n const manifestPathValue = yield* manifestPath;\n yield* writeFileStringAndLog(\n manifestPathValue,\n Declaration.renderManifest({ name, env, http, digest, ...sections }),\n );\n },\n Effect.tapError(() => removeManifest),\n);\n\nconst authProvidersPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n return path.join(confectDirectory, \"_generated\", \"auth.providers.ts\");\n});\n\nconst removeAuthProviders = Effect.gen(function* () {\n const authProvidersPathValue = yield* authProvidersPath;\n yield* removeGenerated(authProvidersPathValue, []);\n});\n\nconst writeDeclaration = Effect.fnUntraced(function* (\n previous: Readonly<Record<string, unknown>>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n const target = (yield* ConvexDirectory.target).kind;\n\n const app = yield* bundleDeclaration(\"app.ts\");\n const appValue: unknown = app.module.default;\n if (App.isApp(appValue) && appValue.kind !== target) {\n return yield* DeclarationKindMismatchError.make({\n declarationPath: \"confect/app.ts\",\n declaredKind: appValue.kind,\n targetKind: target,\n });\n }\n const authPath = yield* confectPath(\"auth.ts\");\n const auth = (yield* fs.exists(authPath))\n ? yield* Effect.asSome(bundleDeclaration(\"auth.ts\"))\n : Option.none();\n\n const declaration = yield* Declaration.parse({\n target,\n app: app.module.default,\n auth: Option.map(auth, ({ module }) => module.default),\n componentImport: yield* componentImport(),\n }).pipe(\n Result.mapError((error) =>\n InvalidDeclarationError.make({\n declarationPath: Declaration.fileOf(error),\n reason: error.message,\n }),\n ),\n Effect.fromResult,\n );\n const manifestSections = App.isApp(appValue) ? appValue.manifestSections : [];\n yield* Effect.fromResult(ManifestSections.declared(manifestSections));\n\n const convexConfigPath = path.join(\n convexDirectory,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n );\n const authConfigPath = path.join(convexDirectory, \"auth.config.ts\");\n const authImportPath = yield* toModuleImportPath(\n path.relative(convexDirectory, authPath),\n );\n const legacyAuthConfigs = yield* Effect.forEach(\n [authImportPath, pipe(authImportPath, String.replace(/\\.js$/, \"\"))],\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n );\n yield* assertOwned(convexConfigPath, \"app.ts\", []);\n yield* assertOwned(authConfigPath, \"auth.ts\", legacyAuthConfigs);\n\n let digest: string | undefined;\n if (target === \"app\") {\n digest = Declaration.digest({\n files: yield* declarationInputs([app, ...Option.toArray(auth)]),\n versions: [\n [\"convex\", yield* packageVersion(\"convex\", projectRoot)],\n [\"@confect/cli generator format\", GENERATOR_FORMAT],\n ],\n });\n const sections = ManifestSections.sections(previous);\n const manifestPathValue = yield* manifestPath;\n yield* writeFileStringAndLog(\n manifestPathValue,\n Declaration.manifest(\n declaration,\n sectionDigest(digest, sections),\n sections,\n ),\n );\n }\n yield* writeFileStringAndLog(\n convexConfigPath,\n Declaration.convexConfig(declaration),\n );\n yield* Option.match(declaration.providers, {\n onNone: () =>\n Effect.gen(function* () {\n yield* removeAuthProviders;\n if (yield* fs.exists(authConfigPath)) {\n yield* removePathIfExists(authConfigPath);\n yield* logFileRemoved(authConfigPath);\n }\n }),\n onSome: (providers) =>\n Effect.gen(function* () {\n yield* writeFileStringAndLog(\n authConfigPath,\n Declaration.authConfig(providers),\n );\n const authProvidersPathValue = yield* authProvidersPath;\n yield* writeFileStringAndLog(\n authProvidersPathValue,\n Declaration.authProviders(providers),\n );\n }),\n });\n const sectionTarget: ManifestSection.Target =\n target === \"app\"\n ? { kind: \"app\" }\n : { kind: \"component\", name: declaration.name };\n return {\n app: App.isApp(appValue) ? Option.some(appValue) : Option.none<App.Any>(),\n digest,\n backend: Option.some<SectionFiles.Backend>({\n target: sectionTarget,\n sections: manifestSections,\n }),\n };\n});\n\n/**\n * Write the declaration's Convex files and manifest from `confect/app.ts`,\n * `confect/env.ts` and `confect/auth.ts`, before anything else is validated. On\n * any failure the previous manifest is removed, so a stale manifest never\n * outlives a declaration that no longer produces it.\n *\n * @internal\n */\nexport const syncDeclaration = Effect.fnUntraced(function* (\n previous: Readonly<Record<string, unknown>>,\n) {\n if (!(yield* isDeclared)) {\n yield* removeManifest;\n yield* removeAuthProviders;\n return {\n app: Option.none<App.Any>(),\n digest: undefined,\n backend: Option.none<SectionFiles.Backend>(),\n };\n }\n return yield* writeDeclaration(previous).pipe(\n Effect.tapError(() =>\n removeManifest.pipe(Effect.andThen(removeAuthProviders)),\n ),\n );\n});\n\n/**\n * Check every HTTP route the backend serves and write `convex/http.ts` from\n * `confect/http.ts`. Runs after generation, because `http.ts` imports its\n * handlers, which import generated services.\n *\n * @internal\n */\nexport const syncDeclaredHttp = (\n app: App.Any,\n sectionFiles: ReadonlyArray<string>,\n) =>\n checkAndWriteHttp(app, sectionFiles).pipe(\n Effect.tapError(() => removeManifest),\n );\n\nconst checkAndWriteHttp = Effect.fnUntraced(function* (\n app: App.Any,\n sectionFiles: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const confectDirectory = yield* ConfectDirectory.get;\n const httpPath = yield* confectPath(\"http.ts\");\n\n const convexHttpPath = path.join(convexDirectory, \"http.ts\");\n if (!(yield* fs.exists(httpPath))) {\n yield* Http.routes(app).pipe(\n Result.mapError(invalid(\"app.ts\")),\n Effect.fromResult,\n );\n yield* removeGenerated(convexHttpPath, [\n yield* templates.http({\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n }),\n ]);\n return Option.none();\n }\n\n const http = (yield* bundleDeclaration(\"http.ts\")).module.default;\n if (!Http.isHttp(http)) {\n return yield* InvalidDeclarationError.make({\n declarationPath: \"confect/http.ts\",\n reason: \"it must default-export Http.make(...).\",\n });\n }\n yield* Http.routes(app, http).pipe(\n Result.mapError(invalid(\"http.ts\")),\n Effect.fromResult,\n );\n\n const contents = yield* templates.declaredHttp({\n runtimeImportPath: (yield* fs.exists(\n path.join(confectDirectory, \"runtime.ts\"),\n ))\n ? yield* toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"runtime.ts\"),\n ),\n )\n : undefined,\n schemaImportPath: yield* toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"_generated\", \"schema.ts\"),\n ),\n ),\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n sectionImportPaths: yield* Effect.forEach(sectionFiles, (file) =>\n toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"_generated\", file),\n ),\n ),\n ),\n });\n const change = yield* writeFileString(convexHttpPath, contents);\n return Option.some({ change, convexFilePath: convexHttpPath });\n});\n\nconst DEPLOY_MODULE = \"confectDeploy.ts\";\n\n/**\n * Whether a mounted component's own codegen wrote a deploy module, so a push\n * visits its mounts after its `init`.\n */\nconst hasDeployModule = Effect.fnUntraced(function* (\n component: ConvexConfig.InstalledComponent,\n config: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const directory = path.isAbsolute(component.componentDefinitionPath)\n ? Option.some(component.componentDefinitionPath)\n : Option.map(\n ConvexConfig.resolveDefinition(\n `${component.componentDefinitionPath}/convex.config`,\n config,\n path,\n ),\n path.dirname,\n );\n if (Option.isNone(directory)) return false;\n for (const file of [DEPLOY_MODULE, \"confectDeploy.js\"]) {\n if (yield* fs.exists(path.join(directory.value, file))) return true;\n }\n return false;\n});\n\n/**\n * The export of `confect/<name>.ts` that is the mount named `name`.\n */\nconst mountExport = Effect.fnUntraced(function* (name: string) {\n const fs = yield* FileSystem.FileSystem;\n const file = yield* confectPath(`${name}.ts`);\n const missing = InvalidDeclarationError.make({\n declarationPath: \"confect/app.ts\",\n reason: `the mount ${name} runs at every push, so export it from confect/${name}.ts.`,\n });\n if (!(yield* fs.exists(file))) return yield* missing;\n const exports: Record<string, unknown> = (yield* bundleDeclaration(\n `${name}.ts`,\n )).module;\n const found = Option.getOrUndefined(\n Arr.findFirst(\n Rec.toEntries(exports),\n ([, value]) =>\n Predicate.hasProperty(value, \"~@confect/core/Mount\") &&\n Mount.data(value as Mount.Any).name === name,\n ),\n );\n if (found === undefined) return yield* missing;\n return { file, exportName: found[0] };\n});\n\n/**\n * Write `convex/confectDeploy.ts`, the internal mutation a push calls for the\n * steps it runs at each mount: every mount whose component declares `init` or\n * has a deploy module of its own, in declaration order. Remove it when there\n * are none.\n *\n * @internal\n */\nexport const syncDeployModule = Effect.fnUntraced(function* (\n app: Option.Option<App.Any>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const deployPath = path.join(convexDirectory, DEPLOY_MODULE);\n const config = path.join(\n convexDirectory,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n );\n const installed =\n Option.isSome(app) && (yield* fs.exists(config))\n ? yield* Effect.flatMap(\n Effect.all([displayPath(config), ConvexDirectory.target]),\n ([shown, target]) =>\n ConvexConfig.discoverInstalledComponents(\n config,\n shown,\n target.kind,\n ),\n )\n : [];\n const entries: Array<string> = [];\n const imports: Array<string> = [];\n for (const mount of Option.match(app, {\n onNone: () => [],\n onSome: App.mounts,\n })) {\n const component = Option.getOrUndefined(\n Arr.findFirst(installed, ({ name }) => name === mount.name),\n );\n const nested =\n component !== undefined && (yield* hasDeployModule(component, config));\n if (mount.component.init === undefined && !nested) continue;\n const { file, exportName } = yield* mountExport(mount.name);\n const local = `mount${entries.length}`;\n imports.push(\n `import { ${exportName} as ${local} } from \"${yield* toModuleImportPath(path.relative(convexDirectory, file))}\";`,\n );\n entries.push(` { mount: ${local}, nested: ${nested} },`);\n }\n if (entries.length === 0) return yield* removeGenerated(deployPath, []);\n yield* writeFileStringAndLog(\n deployPath,\n Arr.join(\n [\n \"// Generated by `confect codegen` from confect/app.ts. Do not edit.\",\n 'import { MountInit } from \"@confect/server\";',\n ...imports,\n \"\",\n \"export const steps = MountInit.mutation([\",\n ...entries,\n \"]);\",\n \"\",\n ],\n \"\\n\",\n ),\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,mBAAmB;AAEzB,MAAM,cAAc,OAAO,WAAW,WAAW,MAAc;CAC7D,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,mBAAmB,OAAO,iBAAiB;CACjD,OAAO,KAAK,KAAK,kBAAkB,IAAI;AACzC,CAAC;;;;;;AAOD,MAAa,aAAa,OAAO,IAAI,aAAa;CAChD,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,oBAAoB,OAAO,YAAY,QAAQ;CACrD,OAAO,OAAO,GAAG,OAAO,iBAAiB;AAC3C,CAAC;AAED,MAAM,cAAc,OAAO,WAAW,WAAW,cAAsB;CACrE,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,cAAc,OAAO,YAAY;CACvC,OAAO,YAAY,MAAM,KAAK,SAAS,aAAa,YAAY,CAAC;AACnE,CAAC;AAED,MAAM,oBAAoB,OAAO,WAAW,WAAW,MAAc;CACnE,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,eAAe,OAAO,YAAY,IAAI;CAC5C,OAAO,OAAOA,OAAe,cAAc,EACzC,SAAS,CAACC,sBAAmC,IAAI,CAAC,EACpD,CAAC,CAAC,CAAC,KACD,OAAO,UAAU,UAAU,iBAAiB,WAAW,QAAQ,KAAK,CAAC,CACvE;AACF,CAAC;AAED,MAAM,WAAW,UAAkB,UACjC,wBAAwB,KAAK;CAC3B,iBAAiB,WAAW;CAC5B,QAAQ,MAAM;AAChB,CAAC;;;;;;AAOH,MAAM,cAAc,OAAO,WAAW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}
@@ -1,17 +1,17 @@
1
1
  import { blackBright, green, magenta, red } from "../Ansi.mjs";
2
- import { ProjectRoot } from "../ProjectRoot.mjs";
3
- import { logCoalescedBuildErrors, logCoalescedBuildWarnings, logFunctionAdded, logFunctionRemoved, logPending, logSuccess } from "../log.mjs";
4
2
  import { renderCodegenError } from "../CodegenError.mjs";
3
+ import { Operation, Outcome, Phase, forBackend, isDirty, needsDeploymentNotification, plan, shouldRetry, transition } from "../SyncState.mjs";
4
+ import { CoalesceQuiescence, isRefreshSuccessful, make } from "../Watcher.mjs";
5
+ import { EvaluationError, catchAndLog, generateSnapshot, loadPreviousFunctionPaths, prewarmedLayer, updateDeclarations, validate } from "../Evaluation.mjs";
5
6
  import { ConvexDirectory } from "../ConvexDirectory.mjs";
6
- import { generateAuthConfig, generateCrons, generateHttp, touchConvexSchema } from "../utils.mjs";
7
7
  import { flags, layer } from "../DirectoryOptions.mjs";
8
8
  import { diff } from "../FunctionPaths.mjs";
9
9
  import { functionPaths } from "../GenerationSnapshot.mjs";
10
+ import { logCoalescedBuildErrors, logCoalescedBuildWarnings, logFunctionAdded, logFunctionRemoved, logPending, logSuccess } from "../log.mjs";
11
+ import { ProjectRoot } from "../ProjectRoot.mjs";
10
12
  import { preserveComponentOutput } from "../Rollback.mjs";
13
+ import { generateAuthConfig, generateCrons, generateHttp, touchConvexSchema } from "../utils.mjs";
11
14
  import { isDeclared } from "./declaration.mjs";
12
- import { Operation, Outcome, Phase, forBackend, isDirty, needsDeploymentNotification, plan, shouldRetry, transition } from "../SyncState.mjs";
13
- import { CoalesceQuiescence, isRefreshSuccessful, make } from "../Watcher.mjs";
14
- import { EvaluationError, catchAndLog, generateSnapshot, loadPreviousFunctionPaths, prewarmedLayer, updateDeclarations, validate } from "../Evaluation.mjs";
15
15
  import * as Effect from "effect/Effect";
16
16
  import * as Command from "effect/cli/Command";
17
17
  import * as FileSystem from "effect/FileSystem";
@@ -29,7 +29,7 @@ import * as Order from "effect/Order";
29
29
  import * as Flag from "effect/cli/Flag";
30
30
  import * as Duration from "effect/Duration";
31
31
  import * as Equal from "effect/Equal";
32
- //#region src/confect/dev.ts
32
+ // src/confect/dev.ts
33
33
  const changeChar = (change) => Match.value(change).pipe(Match.when("Added", () => ({
34
34
  char: "+",
35
35
  color: green
@@ -56,12 +56,18 @@ const logFunctionPathDiff = Effect.fnUntraced(function* (previous, current) {
56
56
  yield* Effect.forEach(Array.fromIterable(HashSet.filter(functionsRemoved, (fp) => Equal.equals(fp.groupPath, gp))), logFunctionRemoved);
57
57
  }));
58
58
  });
59
+ /**
60
+ * @internal
61
+ */
59
62
  const devHandler = Effect.gen(function* () {
60
63
  yield* logPending("Performing initial sync…");
61
64
  const previousFunctionPaths = yield* loadPreviousFunctionPaths;
62
65
  const watcher = yield* make();
63
66
  yield* Effect.all([watcher.run, syncLoop(previousFunctionPaths, watcher)], { concurrency: "unbounded" });
64
67
  }).pipe(Effect.provide(prewarmedLayer));
68
+ /**
69
+ * @internal
70
+ */
65
71
  const dev = Command.make("dev", {
66
72
  ...flags,
67
73
  coalesceMs: Flag.Int("coalesce-ms").pipe(Flag.filter((ms) => ms >= 0 && ms <= 5e3, () => "Set --coalesce-ms to an integer between 0 and 5000 milliseconds."), Flag.withDefault(Duration.toMillis(CoalesceQuiescence.defaultValue())), Flag.withDescription("Quiet period before processing saved files, in milliseconds."))
@@ -136,7 +142,7 @@ const syncLoop = Effect.fnUntraced(function* (initialFunctionPaths, watcher) {
136
142
  return Outcome.Succeeded({ snapshot: current.value });
137
143
  });
138
144
  const preserved = (generation) => preserveComponentOutput(generation, watcher.duringRestore).pipe(Effect.tapErrorTag("ComponentNodeGroupError", () => watcher.discardRestoreEchoes), Effect.catchTags({
139
- RemoveBusyError: (error) => Effect.fail(new EvaluationError({ diagnostic: renderCodegenError(error) })),
145
+ RemoveBusyError: (error) => Effect.fail(EvaluationError.make({ diagnostic: renderCodegenError(error) })),
140
146
  PlatformError: Effect.die
141
147
  }));
142
148
  const validate$1 = (paths, snapshot) => Effect.gen(function* () {
@@ -150,9 +156,9 @@ const syncLoop = Effect.fnUntraced(function* (initialFunctionPaths, watcher) {
150
156
  return Outcome.Succeeded({ snapshot });
151
157
  });
152
158
  const outcome = yield* Operation.$match(operation, {
153
- Generate: () => regenerate(preserved(generateSnapshot)),
159
+ Generate: () => generateSnapshot.pipe(preserved, regenerate),
154
160
  Validate: ({ paths, snapshot }) => validate$1(paths, snapshot),
155
- Update: ({ snapshot, declarations, paths }) => regenerate(preserved(updateDeclarations(snapshot, declarations, paths)))
161
+ Update: ({ snapshot, declarations, paths }) => updateDeclarations(snapshot, declarations, paths).pipe(preserved, regenerate)
156
162
  });
157
163
  yield* Ref.set(phaseRef, transition(outcome));
158
164
  if (shouldRetry(phase, outcome)) yield* watcher.requestRetry;
@@ -165,7 +171,8 @@ const syncLoop = Effect.fnUntraced(function* (initialFunctionPaths, watcher) {
165
171
  yield* Array.isReadonlyArrayNonEmpty(dirtyOptionalFiles) ? Effect.all(dirtyOptionalFiles, { concurrency: "unbounded" }) : Effect.void;
166
172
  yield* Ref.set(optionalPendingRef, HashSet.empty());
167
173
  if (needsDeploymentNotification(phase)) yield* touchConvexSchema;
168
- if (!isDirty(yield* watcher.pending)) yield* logSuccess("Generated files are up-to-date");
174
+ const remaining = yield* watcher.pending;
175
+ if (!isDirty(remaining)) yield* logSuccess("Generated files are up-to-date");
169
176
  }));
170
177
  });
171
178
  const syncOptionalFile = (generate, convexFile) => pipe(generate, Effect.andThen(Option.match({
@@ -181,7 +188,6 @@ const syncOptionalFile = (generate, convexFile) => pipe(generate, Effect.andThen
181
188
  }
182
189
  })
183
190
  })));
184
- //#endregion
185
191
  export { dev, devHandler };
186
192
 
187
193
  //# sourceMappingURL=dev.mjs.map