@confect/cli 9.0.0-next.7 → 9.0.0-next.9

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 (69) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/BuildError.mjs +9 -2
  3. package/dist/BuildError.mjs.map +1 -1
  4. package/dist/Bundler.mjs +5 -2
  5. package/dist/Bundler.mjs.map +1 -1
  6. package/dist/CodeBlockWriter.mjs +1 -1
  7. package/dist/CodeBlockWriter.mjs.map +1 -1
  8. package/dist/CodegenError.mjs +10 -15
  9. package/dist/CodegenError.mjs.map +1 -1
  10. package/dist/ConfectDirectory.mjs +5 -2
  11. package/dist/ConfectDirectory.mjs.map +1 -1
  12. package/dist/ConvexDirectory.mjs +6 -2
  13. package/dist/ConvexDirectory.mjs.map +1 -1
  14. package/dist/FunctionPath.mjs +1 -1
  15. package/dist/FunctionPath.mjs.map +1 -1
  16. package/dist/FunctionPaths.mjs +5 -1
  17. package/dist/FunctionPaths.mjs.map +1 -1
  18. package/dist/GroupPath.mjs +9 -2
  19. package/dist/GroupPath.mjs.map +1 -1
  20. package/dist/GroupPaths.mjs +1 -1
  21. package/dist/GroupPaths.mjs.map +1 -1
  22. package/dist/LeafModule.mjs +17 -24
  23. package/dist/LeafModule.mjs.map +1 -1
  24. package/dist/ProjectRoot.mjs +8 -3
  25. package/dist/ProjectRoot.mjs.map +1 -1
  26. package/dist/SpecAssemblyNode.mjs +6 -9
  27. package/dist/SpecAssemblyNode.mjs.map +1 -1
  28. package/dist/TableModule.mjs +6 -2
  29. package/dist/TableModule.mjs.map +1 -1
  30. package/dist/cliApp.mjs +1 -1
  31. package/dist/cliApp.mjs.map +1 -1
  32. package/dist/confect/codegen.mjs +36 -72
  33. package/dist/confect/codegen.mjs.map +1 -1
  34. package/dist/confect/dev.mjs +24 -7
  35. package/dist/confect/dev.mjs.map +1 -1
  36. package/dist/confect.mjs +2 -2
  37. package/dist/confect.mjs.map +1 -1
  38. package/dist/index.mjs +3 -2
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/log.mjs +7 -3
  41. package/dist/log.mjs.map +1 -1
  42. package/dist/package.mjs +1 -1
  43. package/dist/templates.mjs +8 -15
  44. package/dist/templates.mjs.map +1 -1
  45. package/dist/utils.mjs +42 -22
  46. package/dist/utils.mjs.map +1 -1
  47. package/package.json +3 -3
  48. package/src/BuildError.ts +9 -2
  49. package/src/Bundler.ts +5 -2
  50. package/src/CodeBlockWriter.ts +1 -1
  51. package/src/CodegenError.ts +7 -38
  52. package/src/ConfectDirectory.ts +5 -2
  53. package/src/ConvexDirectory.ts +6 -2
  54. package/src/FunctionPath.ts +1 -1
  55. package/src/FunctionPaths.ts +5 -1
  56. package/src/GroupPath.ts +9 -11
  57. package/src/GroupPaths.ts +1 -1
  58. package/src/LeafModule.ts +24 -36
  59. package/src/ProjectRoot.ts +8 -3
  60. package/src/SpecAssemblyNode.ts +5 -14
  61. package/src/TableModule.ts +6 -2
  62. package/src/cliApp.ts +1 -1
  63. package/src/confect/codegen.ts +54 -108
  64. package/src/confect/dev.ts +24 -29
  65. package/src/confect.ts +2 -2
  66. package/src/index.ts +3 -2
  67. package/src/log.ts +7 -3
  68. package/src/templates.ts +11 -28
  69. package/src/utils.ts +47 -41
package/src/utils.ts CHANGED
@@ -1,18 +1,17 @@
1
1
  import type { FunctionSpec, Spec } from "@confect/core";
2
- import { FileSystem, Path } from "@effect/platform";
2
+ import * as FileSystem from "@effect/platform/FileSystem";
3
+ import * as Path from "@effect/platform/Path";
3
4
  import type { PlatformError } from "@effect/platform/Error";
4
- import {
5
- Array,
6
- Context,
7
- Effect,
8
- HashSet,
9
- Option,
10
- Order,
11
- pipe,
12
- Record,
13
- Ref,
14
- String,
15
- } from "effect";
5
+ import { pipe } from "effect/Function";
6
+ import * as Array from "effect/Array";
7
+ import * as Context from "effect/Context";
8
+ import * as Effect from "effect/Effect";
9
+ import * as HashSet from "effect/HashSet";
10
+ import * as Option from "effect/Option";
11
+ import * as Order from "effect/Order";
12
+ import * as Record from "effect/Record";
13
+ import * as Ref from "effect/Ref";
14
+ import * as String from "effect/String";
16
15
  import * as FunctionPaths from "./FunctionPaths";
17
16
  import * as GroupPath from "./GroupPath";
18
17
  import * as GroupPaths from "./GroupPaths";
@@ -197,6 +196,35 @@ export const generateGroupModule = ({
197
196
  return "Unchanged" as const;
198
197
  });
199
198
 
199
+ /**
200
+ * Compute the module import specifier (relative to `modulePath`) for a group's
201
+ * registry file under `confect/_generated/registeredFunctions/`. The registry
202
+ * path mirrors the group's path one-to-one (see `registeredFunctionsRelativePath`
203
+ * in `LeafModule.ts`) for both Convex and Node groups. Centralizing this here
204
+ * keeps the "overlapping" and "new" group branches of `generateFunctions` from
205
+ * drifting apart.
206
+ */
207
+ const registeredFunctionsImportPathForGroup = (
208
+ groupPath: GroupPath.GroupPath,
209
+ modulePath: string,
210
+ ) =>
211
+ Effect.gen(function* () {
212
+ const path = yield* Path.Path;
213
+ const confectDirectory = yield* ConfectDirectory.get;
214
+
215
+ const registeredFunctionsPath =
216
+ path.join(
217
+ confectDirectory,
218
+ "_generated",
219
+ "registeredFunctions",
220
+ ...groupPath.pathSegments,
221
+ ) + ".ts";
222
+
223
+ return yield* toModuleImportPath(
224
+ path.relative(path.dirname(modulePath), registeredFunctionsPath),
225
+ );
226
+ });
227
+
200
228
  const logGroupPaths = <R>(
201
229
  groupPaths: GroupPaths.GroupPaths,
202
230
  logFn: (fullPath: string) => Effect.Effect<void, never, R>,
@@ -217,7 +245,6 @@ export const generateFunctions = (spec: Spec.AnyWithProps) =>
217
245
  Effect.gen(function* () {
218
246
  const path = yield* Path.Path;
219
247
  const convexDirectory = yield* ConvexDirectory.get;
220
- const confectDirectory = yield* ConfectDirectory.get;
221
248
 
222
249
  const groupPathsFromFs = yield* getGroupPathsFromFs;
223
250
  const functionPaths = FunctionPaths.make(spec);
@@ -242,25 +269,13 @@ export const generateFunctions = (spec: Spec.AnyWithProps) =>
242
269
  );
243
270
  const relativeModulePath = yield* GroupPath.modulePath(groupPath);
244
271
  const modulePath = path.join(convexDirectory, relativeModulePath);
245
- const registrySegments =
246
- groupPath.pathSegments[0] === "node"
247
- ? groupPath.pathSegments.slice(1)
248
- : groupPath.pathSegments;
249
- const registeredFunctionsPath =
250
- path.join(
251
- confectDirectory,
252
- "_generated",
253
- "registeredFunctions",
254
- ...registrySegments,
255
- ) + ".ts";
256
- const registeredFunctionsImportPath = yield* toModuleImportPath(
257
- path.relative(path.dirname(modulePath), registeredFunctionsPath),
258
- );
272
+ const registeredFunctionsImportPath =
273
+ yield* registeredFunctionsImportPathForGroup(groupPath, modulePath);
259
274
  const result = yield* generateGroupModule({
260
275
  groupPath,
261
276
  functionNames,
262
277
  registeredFunctionsImportPath,
263
- useNode: groupPath.pathSegments[0] === "node",
278
+ useNode: group.runtime === "Node",
264
279
  });
265
280
  if (result === "Modified") {
266
281
  yield* logFileModified(modulePath);
@@ -343,7 +358,6 @@ export const writeGroups = (
343
358
  Effect.gen(function* () {
344
359
  const path = yield* Path.Path;
345
360
  const convexDirectory = yield* ConvexDirectory.get;
346
- const confectDirectory = yield* ConfectDirectory.get;
347
361
  const group = yield* GroupPath.getGroupSpec(spec, groupPath);
348
362
 
349
363
  const functionNames = pipe(
@@ -360,23 +374,15 @@ export const writeGroups = (
360
374
 
361
375
  const relativeModulePath = yield* GroupPath.modulePath(groupPath);
362
376
  const modulePath = path.join(convexDirectory, relativeModulePath);
363
- const registeredFunctionsPath =
364
- path.join(
365
- confectDirectory,
366
- "_generated",
367
- "registeredFunctions",
368
- ...groupPath.pathSegments,
369
- ) + ".ts";
370
- const registeredFunctionsImportPath = yield* toModuleImportPath(
371
- path.relative(path.dirname(modulePath), registeredFunctionsPath),
372
- );
377
+ const registeredFunctionsImportPath =
378
+ yield* registeredFunctionsImportPathForGroup(groupPath, modulePath);
373
379
 
374
380
  yield* Effect.logDebug(`Generating group ${groupPath}...`);
375
381
  yield* generateGroupModule({
376
382
  groupPath,
377
383
  functionNames,
378
384
  registeredFunctionsImportPath,
379
- useNode: groupPath.pathSegments[0] === "node",
385
+ useNode: group.runtime === "Node",
380
386
  });
381
387
  yield* Effect.logDebug(`Group ${groupPath} generated`);
382
388
  }),