@confect/server 9.0.0-next.0 → 9.0.0-next.10

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 (190) hide show
  1. package/CHANGELOG.md +299 -4
  2. package/dist/ActionCtx.d.ts +4 -11
  3. package/dist/ActionCtx.d.ts.map +1 -1
  4. package/dist/ActionCtx.js +1 -1
  5. package/dist/ActionCtx.js.map +1 -1
  6. package/dist/ActionRunner.d.ts +8 -13
  7. package/dist/ActionRunner.d.ts.map +1 -1
  8. package/dist/ActionRunner.js +4 -3
  9. package/dist/ActionRunner.js.map +1 -1
  10. package/dist/Auth.d.ts +17 -23
  11. package/dist/Auth.d.ts.map +1 -1
  12. package/dist/Auth.js +5 -1
  13. package/dist/Auth.js.map +1 -1
  14. package/dist/BlobNotFoundError.d.ts +6 -12
  15. package/dist/BlobNotFoundError.d.ts.map +1 -1
  16. package/dist/BlobNotFoundError.js +1 -1
  17. package/dist/BlobNotFoundError.js.map +1 -1
  18. package/dist/ConvexConfigProvider.d.ts +2 -9
  19. package/dist/ConvexConfigProvider.d.ts.map +1 -1
  20. package/dist/ConvexConfigProvider.js +6 -1
  21. package/dist/ConvexConfigProvider.js.map +1 -1
  22. package/dist/CronJob.d.ts +12 -19
  23. package/dist/CronJob.d.ts.map +1 -1
  24. package/dist/CronJob.js +1 -1
  25. package/dist/CronJob.js.map +1 -1
  26. package/dist/CronJobs.d.ts +11 -18
  27. package/dist/CronJobs.d.ts.map +1 -1
  28. package/dist/CronJobs.js +11 -4
  29. package/dist/CronJobs.js.map +1 -1
  30. package/dist/DataModel.d.ts +24 -29
  31. package/dist/DataModel.d.ts.map +1 -1
  32. package/dist/DatabaseReader.d.ts +4323 -64
  33. package/dist/DatabaseReader.d.ts.map +1 -1
  34. package/dist/DatabaseReader.js +6 -6
  35. package/dist/DatabaseReader.js.map +1 -1
  36. package/dist/DatabaseSchema.d.ts +38 -130
  37. package/dist/DatabaseSchema.d.ts.map +1 -1
  38. package/dist/DatabaseSchema.js +20 -30
  39. package/dist/DatabaseSchema.js.map +1 -1
  40. package/dist/DatabaseWriter.d.ts +38 -42
  41. package/dist/DatabaseWriter.d.ts.map +1 -1
  42. package/dist/DatabaseWriter.js +8 -5
  43. package/dist/DatabaseWriter.js.map +1 -1
  44. package/dist/Document.d.ts +28 -37
  45. package/dist/Document.d.ts.map +1 -1
  46. package/dist/Document.js +5 -1
  47. package/dist/Document.js.map +1 -1
  48. package/dist/FunctionImpl.d.ts +30 -29
  49. package/dist/FunctionImpl.d.ts.map +1 -1
  50. package/dist/FunctionImpl.js +25 -14
  51. package/dist/FunctionImpl.js.map +1 -1
  52. package/dist/GroupImpl.d.ts +45 -41
  53. package/dist/GroupImpl.d.ts.map +1 -1
  54. package/dist/GroupImpl.js +42 -35
  55. package/dist/GroupImpl.js.map +1 -1
  56. package/dist/Handler.d.ts +34 -40
  57. package/dist/Handler.d.ts.map +1 -1
  58. package/dist/HttpApi.d.ts +21 -25
  59. package/dist/HttpApi.d.ts.map +1 -1
  60. package/dist/HttpApi.js +11 -6
  61. package/dist/HttpApi.js.map +1 -1
  62. package/dist/MutationCtx.d.ts +4 -11
  63. package/dist/MutationCtx.d.ts.map +1 -1
  64. package/dist/MutationCtx.js +1 -1
  65. package/dist/MutationCtx.js.map +1 -1
  66. package/dist/MutationRunner.d.ts +8 -13
  67. package/dist/MutationRunner.d.ts.map +1 -1
  68. package/dist/MutationRunner.js +4 -3
  69. package/dist/MutationRunner.js.map +1 -1
  70. package/dist/OrderedQuery.d.ts +16 -21
  71. package/dist/OrderedQuery.d.ts.map +1 -1
  72. package/dist/OrderedQuery.js +4 -1
  73. package/dist/OrderedQuery.js.map +1 -1
  74. package/dist/QueryCtx.d.ts +4 -11
  75. package/dist/QueryCtx.d.ts.map +1 -1
  76. package/dist/QueryCtx.js +1 -1
  77. package/dist/QueryCtx.js.map +1 -1
  78. package/dist/QueryInitializer.d.ts +34 -39
  79. package/dist/QueryInitializer.d.ts.map +1 -1
  80. package/dist/QueryInitializer.js +5 -1
  81. package/dist/QueryInitializer.js.map +1 -1
  82. package/dist/QueryRunner.d.ts +8 -13
  83. package/dist/QueryRunner.d.ts.map +1 -1
  84. package/dist/QueryRunner.js +4 -3
  85. package/dist/QueryRunner.js.map +1 -1
  86. package/dist/RegisteredConvexFunction.d.ts +1107 -60
  87. package/dist/RegisteredConvexFunction.d.ts.map +1 -1
  88. package/dist/RegisteredConvexFunction.js +14 -9
  89. package/dist/RegisteredConvexFunction.js.map +1 -1
  90. package/dist/RegisteredFunction.d.ts +48 -64
  91. package/dist/RegisteredFunction.d.ts.map +1 -1
  92. package/dist/RegisteredFunction.js +9 -5
  93. package/dist/RegisteredFunction.js.map +1 -1
  94. package/dist/RegisteredFunctions.d.ts +48 -26
  95. package/dist/RegisteredFunctions.d.ts.map +1 -1
  96. package/dist/RegisteredFunctions.js +22 -9
  97. package/dist/RegisteredFunctions.js.map +1 -1
  98. package/dist/RegisteredNodeFunction.d.ts +4 -14
  99. package/dist/RegisteredNodeFunction.d.ts.map +1 -1
  100. package/dist/RegisteredNodeFunction.js +5 -4
  101. package/dist/RegisteredNodeFunction.js.map +1 -1
  102. package/dist/RegistryItem.d.ts +17 -27
  103. package/dist/RegistryItem.d.ts.map +1 -1
  104. package/dist/RegistryItem.js +1 -1
  105. package/dist/RegistryItem.js.map +1 -1
  106. package/dist/Scheduler.d.ts +16 -20
  107. package/dist/Scheduler.d.ts.map +1 -1
  108. package/dist/Scheduler.js +10 -6
  109. package/dist/Scheduler.js.map +1 -1
  110. package/dist/SchemaToValidator.d.ts +71 -64
  111. package/dist/SchemaToValidator.d.ts.map +1 -1
  112. package/dist/SchemaToValidator.js +15 -3
  113. package/dist/SchemaToValidator.js.map +1 -1
  114. package/dist/StorageActionWriter.d.ts +21 -28
  115. package/dist/StorageActionWriter.d.ts.map +1 -1
  116. package/dist/StorageActionWriter.js +4 -1
  117. package/dist/StorageActionWriter.js.map +1 -1
  118. package/dist/StorageReader.d.ts +14 -21
  119. package/dist/StorageReader.d.ts.map +1 -1
  120. package/dist/StorageReader.js +5 -1
  121. package/dist/StorageReader.js.map +1 -1
  122. package/dist/StorageWriter.d.ts +16 -23
  123. package/dist/StorageWriter.d.ts.map +1 -1
  124. package/dist/StorageWriter.js +4 -1
  125. package/dist/StorageWriter.js.map +1 -1
  126. package/dist/Table.d.ts +204 -197
  127. package/dist/Table.d.ts.map +1 -1
  128. package/dist/Table.js +72 -62
  129. package/dist/Table.js.map +1 -1
  130. package/dist/TableInfo.d.ts +35 -41
  131. package/dist/TableInfo.d.ts.map +1 -1
  132. package/dist/VectorSearch.d.ts +30 -35
  133. package/dist/VectorSearch.d.ts.map +1 -1
  134. package/dist/VectorSearch.js +3 -1
  135. package/dist/VectorSearch.js.map +1 -1
  136. package/dist/index.d.ts +35 -36
  137. package/dist/index.d.ts.map +1 -0
  138. package/dist/index.js +4 -5
  139. package/dist/internal/utils.d.ts +9 -11
  140. package/dist/internal/utils.d.ts.map +1 -1
  141. package/dist/internal/utils.js +3 -1
  142. package/dist/internal/utils.js.map +1 -1
  143. package/dist/node.d.ts +2 -2
  144. package/dist/node.d.ts.map +1 -0
  145. package/dist/tsconfig.src.tsbuildinfo +1 -0
  146. package/package.json +50 -59
  147. package/src/ActionCtx.ts +1 -1
  148. package/src/ActionRunner.ts +2 -1
  149. package/src/Auth.ts +5 -1
  150. package/src/BlobNotFoundError.ts +1 -1
  151. package/src/ConvexConfigProvider.ts +6 -8
  152. package/src/CronJob.ts +1 -1
  153. package/src/CronJobs.ts +8 -10
  154. package/src/DatabaseReader.ts +18 -21
  155. package/src/DatabaseSchema.ts +38 -98
  156. package/src/DatabaseWriter.ts +13 -6
  157. package/src/Document.ts +5 -1
  158. package/src/FunctionImpl.ts +36 -44
  159. package/src/GroupImpl.ts +54 -81
  160. package/src/HttpApi.ts +8 -9
  161. package/src/MutationCtx.ts +1 -1
  162. package/src/MutationRunner.ts +2 -1
  163. package/src/OrderedQuery.ts +5 -1
  164. package/src/QueryCtx.ts +1 -1
  165. package/src/QueryInitializer.ts +15 -3
  166. package/src/QueryRunner.ts +2 -1
  167. package/src/RegisteredConvexFunction.ts +11 -7
  168. package/src/RegisteredFunction.ts +5 -1
  169. package/src/RegisteredFunctions.ts +69 -93
  170. package/src/RegisteredNodeFunction.ts +7 -6
  171. package/src/RegistryItem.ts +1 -1
  172. package/src/Scheduler.ts +5 -1
  173. package/src/SchemaToValidator.ts +14 -16
  174. package/src/StorageActionWriter.ts +4 -1
  175. package/src/StorageReader.ts +5 -1
  176. package/src/StorageWriter.ts +4 -1
  177. package/src/Table.ts +253 -132
  178. package/src/VectorSearch.ts +3 -1
  179. package/src/index.ts +0 -1
  180. package/src/internal/utils.ts +3 -1
  181. package/dist/Api.d.ts +0 -30
  182. package/dist/Api.d.ts.map +0 -1
  183. package/dist/Api.js +0 -26
  184. package/dist/Api.js.map +0 -1
  185. package/dist/GroupPath.d.ts +0 -8
  186. package/dist/GroupPath.d.ts.map +0 -1
  187. package/dist/GroupPath.js +0 -10
  188. package/dist/GroupPath.js.map +0 -1
  189. package/src/Api.ts +0 -75
  190. package/src/GroupPath.ts +0 -43
package/CHANGELOG.md CHANGED
@@ -1,5 +1,297 @@
1
1
  # @confect/server
2
2
 
3
+ ## 9.0.0-next.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 9eec71c: Generate the published `.d.ts` declarations with the TypeScript compiler instead of tsdown's declaration bundler. tsdown now emits JavaScript only (`dts: false`); each package has a composite `tsconfig.src.json`, and `tsc -b` emits the declarations into `dist/` as part of the build. (`@confect/cli` is the exception: it ships only a binary, so it emits no declarations at all.)
8
+
9
+ The emitted types are equivalent to before—same exported surface, same inferred shapes—so no consumer-facing type changes. One incidental improvement comes with the switch: declaration maps (`.d.ts.map`) now ship alongside the types (with `src/` included in the published files, so "go to definition" lands on the original source).
10
+
11
+ - Updated dependencies [9eec71c]
12
+ - @confect/core@9.0.0-next.10
13
+
14
+ ## 9.0.0-next.9
15
+
16
+ ### Major Changes
17
+
18
+ - 4894959: Make Node-runtime functions first-class and remove the separate `node` namespace.
19
+
20
+ A function group's runtime is now declared solely by its spec — `GroupSpec.makeNode()` for a Node action group, `GroupSpec.make()` for a Convex group — exactly like vanilla Convex's per-file `"use node"` directive. The `confect/node/` directory is no longer special: Node specs/impls are ordinary colocated `.spec.ts`/`.impl.ts` pairs that can live anywhere in `confect/`, and codegen emits the `"use node"` directive into the generated `convex/` module based on the spec. This is safe because v9's per-group registries already isolate each Convex function's bundle from every other group's impl, so Node-only code can no longer leak into a Convex-runtime bundle regardless of namespace.
21
+
22
+ ### Why
23
+
24
+ The `node` namespace existed only because the pre-v9 architecture aggregated every function's impl into one module that all generated `convex/` modules imported; Node functions had to be quarantined into a separate spec/impl/registry tree so Convex-runtime functions wouldn't transitively import Node-only code. v9's per-group isolation removed that constraint, so the namespace was no longer load-bearing — only ergonomic overhead that diverged from vanilla Convex (which identifies Node modules per-file, with no directory requirement).
25
+
26
+ ### Breaking changes
27
+
28
+ - **API namespace removed.** A Node group at `confect/email.spec.ts` is now referenced as `refs.public.email.send` instead of `refs.public.node.email.send`. Node groups are ordinary groups in the refs tree, nesting preserved like any other group.
29
+ - **Generated layout changed.** Node modules are emitted at `convex/<path>.ts` (carrying `"use node"`) instead of `convex/node/<path>.ts`, and their registries at `confect/_generated/registeredFunctions/<path>.ts`. The single assembled `confect/_generated/spec.ts` now contains every group regardless of runtime; `confect/_generated/nodeSpec.ts` is no longer generated (codegen deletes any stale copy on upgrade).
30
+ - **`@confect/core` API.** Removed `Spec.makeNode`, `Spec.merge`, and `Spec.isConvexSpec`/`Spec.isNodeSpec`. `Spec` is now a single mixed-runtime container (`Spec.make()` accepts groups of any runtime). `Refs.make(spec)` takes a single argument (the unified spec) instead of `(convexSpec, nodeSpec)`. `GroupSpec.makeNode()`/`makeNodeAt()` and `FunctionSpec.publicNodeAction()`/`internalNodeAction()` are unchanged; `GroupSpec` subgroups may now be of any runtime (a group is just a namespace for its children).
31
+
32
+ ### Migration
33
+
34
+ 1. Move any `confect/node/<path>.spec.ts`/`.impl.ts` files to wherever you want them under `confect/` (e.g. `confect/<path>.spec.ts`); the `node/` directory has no special meaning anymore. Their specs already use `GroupSpec.makeNode()`, so no spec-body change is needed — only fix the impl's relative import of `_generated/schema` if its depth changed.
35
+ 2. Update call sites to drop the `node` segment: `refs.public.node.<group>.<fn>` → `refs.public.<group>.<fn>`.
36
+ 3. Replace `Refs.make(spec, nodeSpec)` with `Refs.make(spec)` (codegen does this for `_generated/refs.ts` automatically).
37
+ 4. Run `confect codegen`. The `convex/` tree and `confect/_generated/` are re-emitted; the stale `_generated/nodeSpec.ts` is removed.
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies [4894959]
42
+ - @confect/core@9.0.0-next.9
43
+
44
+ ## 9.0.0-next.8
45
+
46
+ ### Patch Changes
47
+
48
+ - 3fec285: Import Effect from its submodule paths internally to shrink per-function cold-start bundles.
49
+
50
+ Confect's packages now import Effect modules from their submodule paths (`import * as Schema from "effect/Schema"`) instead of the `"effect"` barrel (`import { Schema } from "effect"`).
51
+
52
+ ### Why
53
+
54
+ A barrel import of a namespace re-export defeats esbuild's tree-shaking: accessing `Schema.X` from `import { Schema } from "effect"` retains the _entire_ `Schema` namespace, because the bundler can't prune property access on the barrel's `export * as Schema`. So every Convex function's cold-start bundle was pulling all of `effect/Schema` and `effect/Stream` — and, transitively through Schema's `Arbitrary`, `fast-check` — whether the function used them or not.
55
+
56
+ Importing from the submodule path tree-shakes normally. On a minimal function this cut the bundle esbuild produces by ~54% (the `effect/Schema` module alone by ~75%) and its cold-start module-evaluation time by ~35%, with `fast-check` dropped entirely. This is also the import style Effect v4 recommends, so it's forward-compatible. A `no-restricted-imports` ESLint rule now enforces it across the codebase (type-only imports and `@effect/vitest` are exempt).
57
+
58
+ No API changes — your existing code keeps working.
59
+
60
+ ### Getting the full win in your own code
61
+
62
+ This change shrinks the Confect code in every function bundle, but a function's bundle also includes your own `confect/tables/*` and `*.spec.ts` files. esbuild retains the union across all importers, so a single barrel import anywhere in a function's module graph re-pins the whole `effect/Schema` namespace and undoes the reduction. To get the full bundle/cold-start savings, import Effect from its submodule paths in your own Confect files too:
63
+
64
+ ```diff
65
+ - import { Schema } from "effect";
66
+ + import * as Schema from "effect/Schema";
67
+ ```
68
+
69
+ Bare helpers (`pipe`, `flow`, `identity`) come from `"effect/Function"`.
70
+
71
+ - Updated dependencies [3fec285]
72
+ - @confect/core@9.0.0-next.8
73
+
74
+ ## 9.0.0-next.7
75
+
76
+ ### Patch Changes
77
+
78
+ - Updated dependencies [5d19484]
79
+ - @confect/core@9.0.0-next.7
80
+
81
+ ## 9.0.0-next.6
82
+
83
+ ### Major Changes
84
+
85
+ - 46045a9: Reduce per-function cold-start cost: make `FunctionSpec` schemas lazy and keep each Convex function's bundle scoped to its own group.
86
+
87
+ Previously, loading a single Convex function still paid for the whole project — importing the codegen-assembled `_generated/spec.ts` ran `Schema.Struct(...)` / `Schema.Array(...)` for every function at module load, and each per-function bundle transitively imported `_generated/api.ts` → `_generated/spec.ts` (every spec). A function's cold-start cost now scales with its own group rather than the size of the project.
88
+
89
+ ### Lazy `FunctionSpec` schemas
90
+
91
+ `FunctionSpec.*` (`publicQuery` / `internalQuery` / `publicMutation` / `internalMutation` / `publicAction` / `internalAction` / `publicNodeAction` / `internalNodeAction`) takes `args`, `returns`, and (optional) `error` as `() => Schema` thunks instead of bare schemas. The resulting provenance exposes them as sync lazy memoised getters (the same pattern `Table.make` uses), so importing `_generated/spec.ts` builds no schemas — construction is deferred to the first invocation that compiles validators or runs a codec.
92
+
93
+ Migration — wrap each schema in `() =>`:
94
+
95
+ ```diff
96
+ FunctionSpec.publicQuery({
97
+ name: "list",
98
+ - args: Schema.Struct({}),
99
+ - returns: Schema.Array(notes.Doc),
100
+ + args: () => Schema.Struct({}),
101
+ + returns: () => Schema.Array(notes.Doc),
102
+ })
103
+ ```
104
+
105
+ ### Impls take the `DatabaseSchema`, and group paths resolve impl-side
106
+
107
+ `FunctionImpl.make` and `GroupImpl.make` now take the runtime `DatabaseSchema` (the default export of `_generated/schema.ts`) as their first argument instead of the whole `Api`. The handler's ctx-service types only ever depended on the database schema, and switching impls to import `_generated/schema` instead of `_generated/api` removes `_generated/spec.ts` (and the function specs it transitively imports) from every per-function bundle.
108
+
109
+ Each function also registers under a flat, single-segment key into a fresh, isolated `Registry` provided per group by `RegisteredFunctions.buildForGroup` (and the CLI's impl validation), so no group-path lookup against `api.spec` is needed. As a result `Spec#addPath`, `Spec#paths`, and `Api.resolveGroupPathUnsafe` are removed; `GroupImpl` / `FunctionImpl` drop their group-path type parameter; and the codegen-emitted `_generated/spec.ts` / `nodeSpec.ts` no longer contain a `.addPath(...)` chain (the `.addAt(...)` / `.addGroupAt(...)` assembly tree that `Refs.make` consumes is unchanged).
110
+
111
+ Migration — in each `*.impl.ts`, import the database schema and pass it where you passed `api` / `nodeApi`:
112
+
113
+ ```diff
114
+ - import api from "../_generated/api"; // (or nodeApi from "../_generated/nodeApi")
115
+ + import databaseSchema from "../_generated/schema";
116
+
117
+ - const insert = FunctionImpl.make(api, notes, "insert", handler);
118
+ + const insert = FunctionImpl.make(databaseSchema, notes, "insert", handler);
119
+
120
+ - export default GroupImpl.make(api, notes).pipe(Layer.provide(insert), GroupImpl.finalize);
121
+ + export default GroupImpl.make(databaseSchema, notes).pipe(Layer.provide(insert), GroupImpl.finalize);
122
+ ```
123
+
124
+ Node impls migrate identically (from `nodeApi` to the same `_generated/schema`); only their specs differ (`GroupSpec.makeNode()`). Hand-rolled tests that built a `Spec` via `.addPath(group, "dot.path")` should drop those calls.
125
+
126
+ ### `buildForGroup` and the generated registries
127
+
128
+ `RegisteredFunctions.buildForGroup` takes the `DatabaseSchema` value plus the group's own `GroupSpec` as a single type argument (`buildForGroup<typeof groupSpec>(…)`, returning `RegisteredFunctionsForGroupSpec<Group>`); the `api` / `groupPath` parameters and the `ForGroupPath` dot-path navigation are gone. `RegisteredConvexFunction.make` / `RegisteredNodeFunction.make` take the `DatabaseSchema` rather than the `Api`. Each `_generated/registeredFunctions/{path}.ts` imports the runtime schema and references its group's leaf spec **type-only** (`typeof import("…/{group}.spec")["default"]`), so it never imports a spec module at runtime.
129
+
130
+ ### `_generated/api.ts` / `nodeApi.ts` are no longer emitted, and `Api` is removed
131
+
132
+ Nothing imports them anymore, so `confect codegen` no longer emits `_generated/api.ts` / `_generated/nodeApi.ts` and deletes any copies left over from earlier versions. The `Api` module itself (`@confect/server/Api` — `Api.make`, the `Api` type, `Api.resolveGroupPathUnsafe`, etc.) is **removed entirely**: impls and the generated registries take the `DatabaseSchema` value and the spec directly, so the combined database-schema-plus-spec `Api` is no longer used anywhere.
133
+
134
+ ### Net effect
135
+
136
+ A function's `convex/{path}.ts` bundle now imports only its own group's registry → its own `.impl` + `_generated/schema` (table schemas, built lazily) + its own group's spec. No `_generated/api.ts`, no project-wide `_generated/spec.ts`, and no sibling-group impls/specs. Re-run `confect codegen` after upgrading.
137
+
138
+ - 762f7eb: Split the deploy-time Convex schema from the runtime `DatabaseSchema`, make `confect/tables/` the single source of truth — including the table name, which is now derived from the filename — and make per-table schema construction lazy.
139
+
140
+ Previously, `confect/schema.ts` was user-authored and `DatabaseSchema` carried a `convexSchemaDefinition` field that was eagerly rebuilt on every `.addTable(...)`. That field was an `O(n²)` allocation for `n` tables, and it forced both the deploy CLI (which only needs `defineSchema(...)`) and the runtime (which only needs the table codec lookup) through the same module — so any runtime function bundle dragged in `convex/server`'s `defineSchema`. Issue 1.
141
+
142
+ Codegen now scans `confect/tables/*.ts` (every file must default-export a `Table`) and emits two siblings:
143
+
144
+ - `confect/_generated/schema.ts` — the runtime `DatabaseSchema`, consumed by `_generated/api.ts`. Imports `@confect/server` but never `convex/server`.
145
+ - `confect/_generated/convexSchema.ts` — the Convex deploy `SchemaDefinition`, re-exported one-line from `convex/schema.ts`. Imports `convex/server` but never `@confect/server`.
146
+
147
+ The `convexSchemaDefinition` field is removed from `DatabaseSchema` and `Api`. `TestConfect.layer` now takes the Convex schema definition as a separate argument so it can stay aligned with the deploy artifact without bringing the runtime schema along for the ride.
148
+
149
+ ### Filename-derived table names
150
+
151
+ The table name is now derived from the file's basename — `confect/tables/notes.ts` defines a table called `notes`. `Table.make` no longer accepts a name argument and returns an _unnamed_ `Table` value; codegen invokes that value with the filename to produce the bound table.
152
+
153
+ This eliminates a class of subtle infelicities: the file basename and the table name can never drift out of sync, cross-table `_id` references are type-constrained against the actual set of declared tables (catching typos at compile time), and ESM cycle hazards for mutual cross-table `Id` references are gone because authoring files no longer transitively import each other.
154
+
155
+ Codegen now emits two new sets of files alongside `_generated/schema.ts` and `_generated/convexSchema.ts`:
156
+
157
+ - `confect/_generated/id.ts` — a single `Id` constructor whose argument is type-constrained to the union of your table names. Use `Id("notes")` everywhere you previously wrote `GenericId.GenericId("notes")`.
158
+ - `confect/_generated/tables/<name>.ts` — one thin wrapper per table that binds the unnamed value from `confect/tables/<name>.ts` to its filename. This is what other modules (specs, impls, HTTP handlers) default-import to reach a table's `Doc`, `Fields`, and `tableName`.
159
+
160
+ Table filenames must be valid JS identifiers, may not start with `_` (Convex reserves underscore-prefixed names for system tables), and may not collide with reserved JS keywords like `import.ts`. Pick a casing convention you like — Confect's example code uses `snake_case` (`notes.ts`, `user_profiles.ts`).
161
+
162
+ The bound `Table`'s `name` property has been renamed to `tableName`. This avoids a silent collision with the built-in `Function.prototype.name` that JavaScript carries on every function value (including the new unnamed-callable `UnnamedTable`).
163
+
164
+ ### Lazy per-table schema construction
165
+
166
+ `Table.make` takes a `() => Schema.Struct({...})` callback rather than a bare struct, and a bound `Table`'s `Fields`, `Doc`, and `tableDefinition` are lazy memoised getters that only invoke that callback on first access.
167
+
168
+ Previously, every `confect/tables/<name>.ts` module ran `Schema.Struct({...})` (and the corresponding `compileTableSchema` / `defineTable` work) at module-load time. Because the codegen-emitted `_generated/schema.ts` is imported transitively from every per-group function bundle, loading any one function eagerly built _every_ table's schema graph — paying a cold-start cost proportional to the whole project, not just the function being invoked.
169
+
170
+ The bound `Table` now exposes `Fields` / `Doc` / `tableDefinition` as lazy getters that compute their value on first access, then replace themselves with a plain non-writable data property so second-and-subsequent accesses are observably indistinguishable from a plain property (and skip all function-call overhead). The result: a function bundle only pays the schema-construction cost for tables it actually touches via `db.table(name)` (which reaches `Fields` through `Document.decode`). The `UnnamedTable` callable no longer exposes `Fields` or `tableDefinition` — read these off the bound `Table` (the generated `_generated/tables/<name>.ts` wrapper already binds the name).
171
+
172
+ ### Migration
173
+
174
+ 1. Delete your `confect/schema.ts`. Codegen will refuse to run while a stray copy is present.
175
+ 2. Rename each `confect/tables/<Name>.ts` to a valid JS identifier in your chosen casing convention (e.g. `confect/tables/notes.ts`). The basename becomes the table name; you no longer pass it as an argument.
176
+ 3. Convert each table file to a **default-export-only** unnamed module: drop the name argument from `Table.make`, wrap the field-schema struct in a `() => ...` callback, and switch any `GenericId.GenericId("users")` references to `Id("users")` imported from `../_generated/id`:
177
+
178
+ ```diff
179
+ - import { GenericId } from "@confect/core";
180
+ import { Table } from "@confect/server";
181
+ import { Schema } from "effect";
182
+ + import { Id } from "../_generated/id";
183
+
184
+ - export default Table.make(
185
+ - "notes",
186
+ - Schema.Struct({
187
+ - userId: Schema.optional(GenericId.GenericId("users")),
188
+ - text: Schema.String,
189
+ - }),
190
+ - );
191
+ + export default Table.make(() =>
192
+ + Schema.Struct({
193
+ + userId: Schema.optional(Id("users")),
194
+ + text: Schema.String,
195
+ + }),
196
+ + );
197
+ ```
198
+
199
+ 4. Rewire every consumer site (specs, impls, integration tests, HTTP handlers, etc.) to import from the generated wrapper rather than directly from `tables/`. The wrapper is also where you now read `Doc` / `Fields` / `tableDefinition` (the unnamed `Table.make(...)` callable no longer exposes them):
200
+
201
+ ```diff
202
+ - import Notes from "../tables/Notes";
203
+ + import notes from "../_generated/tables/notes";
204
+
205
+ - returns: Schema.Array(Notes.Doc),
206
+ + returns: Schema.Array(notes.Doc),
207
+ ```
208
+
209
+ 5. Replace every remaining `GenericId.GenericId("x")` call site with `Id("x")` from `_generated/id` (in spec `args`/`returns`, in `TaggedError` schemas, in `TestConfect.run`, etc.).
210
+ 6. If you read `table.name` anywhere off a bound `Table`, rename it to `table.tableName`.
211
+ 7. Re-run `confect codegen`. It will create `confect/_generated/schema.ts`, `confect/_generated/convexSchema.ts`, `confect/_generated/id.ts`, and one `confect/_generated/tables/<name>.ts` wrapper per table; and it will rewrite `convex/schema.ts` to a one-line re-export.
212
+ 8. If you use `@confect/test`, pass the generated Convex schema definition to `TestConfect.layer`:
213
+
214
+ ```diff
215
+ - import confectSchema from "./confect/schema";
216
+ + import confectSchema from "./confect/_generated/schema";
217
+ + import convexSchema from "./confect/_generated/convexSchema";
218
+
219
+ export const layer = TestConfect_.layer(
220
+ confectSchema,
221
+ + convexSchema,
222
+ import.meta.glob("./convex/**/!(*.*.*)*.*s"),
223
+ );
224
+ ```
225
+
226
+ ### New warning: no tables discovered
227
+
228
+ If a Confect project has no tables — either `confect/tables/` is missing entirely or it exists but contains no `.ts` files — codegen now emits a yellow `⚠` warning and continues, producing an empty `DatabaseSchema.make()` / `defineSchema({})`. Table-free backends (e.g. action-only proxies, webhook bridges) are still legal; the warning just catches the much more common case of a typoed directory name or files placed at the wrong path. To silence it, add at least one `Table.make(...)` module under `confect/tables/`.
229
+
230
+ ### New error: invalid table filename
231
+
232
+ Codegen now rejects table files whose basename is not a valid JS identifier (e.g. `user-profiles.ts`), starts with `_` (reserved for Convex system tables), or shadows a reserved JS keyword (e.g. `import.ts`). Rename the offending file to fix it — for example, `user-profiles.ts` → `user_profiles.ts` or `userProfiles.ts`.
233
+
234
+ ### Patch Changes
235
+
236
+ - Updated dependencies [46045a9]
237
+ - Updated dependencies [762f7eb]
238
+ - @confect/core@9.0.0-next.6
239
+
240
+ ## 9.0.0-next.5
241
+
242
+ ### Patch Changes
243
+
244
+ - @confect/core@9.0.0-next.5
245
+
246
+ ## 9.0.0-next.4
247
+
248
+ ### Patch Changes
249
+
250
+ - @confect/core@9.0.0-next.4
251
+
252
+ ## 9.0.0-next.3
253
+
254
+ ### Patch Changes
255
+
256
+ - 6d85210: Resolve `FunctionImpl` / `GroupImpl` group paths via an immutable `paths` map on `Spec` instead of identity-walking the assembled tree.
257
+
258
+ ### Why
259
+
260
+ Since `9.0.0-next.1`, codegen has wrapped every parent leaf that has sibling subdirectory specs in `<parent>.addGroupAt("child", <child>)`. Because `GroupSpec.addGroupAt` is immutable, that produced a fresh object in the assembled tree, while the parent's `*.impl.ts` continued to hold a reference to the original imported leaf. The runtime resolver compared by `===`, so every such impl failed `validateImpl` with "Could not resolve group path for the provided GroupSpec." Child impls happened to work only because `GroupSpec.withName` was secretly mutating its argument in place to keep the child's identity stable — an asymmetry that was load-bearing for one half of the API and broken for the other.
261
+
262
+ ### What changed
263
+
264
+ - `@confect/core/Spec` carries a new `readonly paths: ReadonlyMap<GroupSpec.AnyWithProps, string>` field and exposes a chainable `Spec#addPath(group, path)` builder. `add` / `addAt` / `merge` propagate `paths` unchanged; `merge` re-prefixes a node spec's entries with `"node."` to match the merged tree.
265
+ - `@confect/core/GroupSpec.withName` is now pure: it returns a fresh copy when the name differs and no longer rewrites the input in place. No new identity-tracking machinery is introduced.
266
+ - `@confect/server/FunctionImpl.make` and `GroupImpl.make` resolve their group path via `api.spec.paths.get(group)` — an O(1) map lookup instead of a tree walk — and throw a clearer error pointing at `Spec.addPath` when the spec hasn't been registered.
267
+ - `@confect/server/GroupPath` (the old identity-based resolver) is deleted.
268
+ - `@confect/cli` codegen emits one `.addPath(<binding>, "<dot.path>")` call per leaf in `_generated/spec.ts` (and `_generated/nodeSpec.ts`) so the imported leaves carry their full paths into the assembled spec value.
269
+
270
+ ### User-facing impact
271
+
272
+ - Spec authoring (`*.spec.ts`) and impl authoring (`*.impl.ts`) APIs are unchanged. `FunctionImpl.make(api, spec, name, handler)` and `GroupImpl.make(api, spec)` keep their exact signatures.
273
+ - Generated `_generated/spec.ts` (and `_generated/nodeSpec.ts`) pick up one `.addPath(...)` chain entry per leaf on the next `confect codegen` run. The shape is fully immutable — no module-load mutation, no hidden side effects.
274
+ - Hand-rolled tests that construct a `Spec` and pass it to `Api.make` must now also call `.addPath(spec, "dot.path")` for any group they intend to look up.
275
+
276
+ ### Fixes
277
+
278
+ This eliminates the runtime regression introduced in `9.0.0-next.1` for any project layout where a `confect/{path}.spec.ts` declares functions alongside a sibling `confect/{path}/` subdirectory of further specs.
279
+
280
+ - Updated dependencies [6d85210]
281
+ - @confect/core@9.0.0-next.3
282
+
283
+ ## 9.0.0-next.2
284
+
285
+ ### Patch Changes
286
+
287
+ - @confect/core@9.0.0-next.2
288
+
289
+ ## 9.0.0-next.1
290
+
291
+ ### Patch Changes
292
+
293
+ - @confect/core@9.0.0-next.1
294
+
3
295
  ## 9.0.0-next.0
4
296
 
5
297
  ### Major Changes
@@ -15,6 +307,7 @@
15
307
  Splitting impl across colocated `*.impl.ts` files is the vehicle for fixing that. With this change, `confect codegen` emits one `_generated/registeredFunctions/{path}.ts` per group, and each generated `convex/` module imports only its own group's per-group registry — which in turn imports only its own sibling `.impl.ts`. A Convex function's cold-start bundle now scales with its own group's impl rather than with the size of the whole project.
16
308
 
17
309
  ### Breaking changes
310
+
18
311
  - `GroupSpec.make()` and `GroupSpec.makeNode()` no longer take a name argument; the group name is derived from the spec file's path within `confect/`.
19
312
  - `FunctionImpl.make(api, groupSpec, fn, handler)` and `GroupImpl.make(api, groupSpec)` now take the imported sibling spec object as their second argument instead of a dot-path string.
20
313
  - Every `GroupImpl` pipeline must end with `GroupImpl.finalize`, which only typechecks once every function declared by the spec has a corresponding `FunctionImpl` provided to the group layer. `GroupImpl.finalize` snapshots the names of every registered function onto the produced `Finalized` `GroupImpl` service value, and `confect codegen` reads those names to verify per-function coverage against the spec at runtime.
@@ -23,6 +316,7 @@
23
316
  - Every module under `convex/` is re-emitted to import from `_generated/registeredFunctions/{path}` instead of the previous aggregate file. Users who commit `convex/` to source control should expect a full rewrite of that directory on first codegen.
24
317
 
25
318
  ### Migration
319
+
26
320
  1. For each existing group, create a colocated `confect/{path}.spec.ts` and `confect/{path}.impl.ts` pair (under a subdirectory for nested groups).
27
321
  - In each spec, call `GroupSpec.make()` (or `GroupSpec.makeNode()`) without a name and `export default` the result.
28
322
  - In each impl, default-import the sibling spec (e.g. `import notes from "./notes.spec"`), pass it to `FunctionImpl.make`/`GroupImpl.make` in place of the previous dot-path string, append `GroupImpl.finalize` to the pipeline, and `export default` the resulting `GroupImpl` layer:
@@ -30,7 +324,7 @@
30
324
  export default GroupImpl.make(api, notes).pipe(
31
325
  Layer.provide(list),
32
326
  Layer.provide(insert),
33
- GroupImpl.finalize,
327
+ GroupImpl.finalize
34
328
  );
35
329
  ```
36
330
  2. Delete root `confect/spec.ts`, `confect/impl.ts`, `confect/nodeSpec.ts`, `confect/nodeImpl.ts`, and any parent aggregator spec/impl files. (`confect codegen` will also delete any of these it finds, plus the stale `_generated/registeredFunctions.ts` and `_generated/nodeRegisteredFunctions.ts`, so this step can be skipped.)
@@ -88,7 +382,7 @@
88
382
 
89
383
  export class NoteNotFound extends Schema.TaggedError<NoteNotFound>()(
90
384
  "NoteNotFound",
91
- { noteId: GenericId.GenericId("notes") },
385
+ { noteId: GenericId.GenericId("notes") }
92
386
  ) {}
93
387
 
94
388
  export const notes = GroupSpec.make("notes").addFunction(
@@ -97,7 +391,7 @@
97
391
  args: Schema.Struct({ noteId: GenericId.GenericId("notes") }),
98
392
  returns: Notes.Doc,
99
393
  error: NoteNotFound,
100
- }),
394
+ })
101
395
  );
102
396
  ```
103
397
 
@@ -117,7 +411,7 @@
117
411
  .table("notes")
118
412
  .get(noteId)
119
413
  .pipe(Effect.mapError(() => new NoteNotFound({ noteId })));
120
- }),
414
+ })
121
415
  );
122
416
  ```
123
417
 
@@ -189,6 +483,7 @@
189
483
  Unspecified failures continue to reject the promise.
190
484
 
191
485
  ### Migration
486
+
192
487
  - For each `useQuery` call site, replace `result === undefined` checks and direct property access with `QueryResult.match` (or the lower-level `QueryResult.isLoading`/`isSuccess`/`isFailure` predicates).
193
488
  - For each `useMutation`/`useAction` call site whose ref now declares an `error` schema, unwrap the resolved `Either` (e.g. with `Either.match`); call sites against refs without an `error` schema need no change.
194
489
 
@@ -1,12 +1,5 @@
1
- import { Context } from "effect";
2
- import { GenericActionCtx, GenericDataModel } from "convex/server";
3
-
4
- //#region src/ActionCtx.d.ts
5
- declare namespace ActionCtx_d_exports {
6
- export { ActionCtx };
7
- }
8
- declare const ActionCtx: <DataModel extends GenericDataModel>() => Context.Tag<GenericActionCtx<DataModel>, GenericActionCtx<DataModel>>;
9
- type ActionCtx<DataModel extends GenericDataModel> = ReturnType<typeof ActionCtx<DataModel>>["Identifier"];
10
- //#endregion
11
- export { ActionCtx, ActionCtx_d_exports };
1
+ import type { GenericActionCtx, GenericDataModel } from "convex/server";
2
+ import * as Context from "effect/Context";
3
+ export declare const ActionCtx: <DataModel extends GenericDataModel>() => Context.Tag<GenericActionCtx<DataModel>, GenericActionCtx<DataModel>>;
4
+ export type ActionCtx<DataModel extends GenericDataModel> = ReturnType<typeof ActionCtx<DataModel>>["Identifier"];
12
5
  //# sourceMappingURL=ActionCtx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActionCtx.d.ts","names":[],"sources":["../src/ActionCtx.ts"],"mappings":";;;;;;;cAGa,SAAA,qBAA+B,gBAAA,OAAgB,OAAA,CAAA,GAAA,CAAA,gBAAA,CAAA,SAAA,GAAA,gBAAA,CAAA,SAAA;AAAA,KAGhD,SAAA,mBAA4B,gBAAA,IAAoB,UAAA,QACnD,SAAA,CAAU,SAAA"}
1
+ {"version":3,"file":"ActionCtx.d.ts","sourceRoot":"","sources":["../src/ActionCtx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,eAAO,MAAM,SAAS,GAAI,SAAS,SAAS,gBAAgB,4EACkB,CAAC;AAE/E,MAAM,MAAM,SAAS,CAAC,SAAS,SAAS,gBAAgB,IAAI,UAAU,CACpE,OAAO,SAAS,CAAC,SAAS,CAAC,CAC5B,CAAC,YAAY,CAAC,CAAC"}
package/dist/ActionCtx.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- import { Context } from "effect";
2
+ import * as Context from "effect/Context";
3
3
 
4
4
  //#region src/ActionCtx.ts
5
5
  var ActionCtx_exports = /* @__PURE__ */ __exportAll({ ActionCtx: () => ActionCtx });
@@ -1 +1 @@
1
- {"version":3,"file":"ActionCtx.js","names":[],"sources":["../src/ActionCtx.ts"],"sourcesContent":["import type { GenericActionCtx, GenericDataModel } from \"convex/server\";\nimport { Context } from \"effect\";\n\nexport const ActionCtx = <DataModel extends GenericDataModel>() =>\n Context.GenericTag<GenericActionCtx<DataModel>>(\"@confect/server/ActionCtx\");\n\nexport type ActionCtx<DataModel extends GenericDataModel> = ReturnType<\n typeof ActionCtx<DataModel>\n>[\"Identifier\"];\n"],"mappings":";;;;;AAGA,MAAa,kBACX,QAAQ,WAAwC,4BAA4B"}
1
+ {"version":3,"file":"ActionCtx.js","names":[],"sources":["../src/ActionCtx.ts"],"sourcesContent":["import type { GenericActionCtx, GenericDataModel } from \"convex/server\";\nimport * as Context from \"effect/Context\";\n\nexport const ActionCtx = <DataModel extends GenericDataModel>() =>\n Context.GenericTag<GenericActionCtx<DataModel>>(\"@confect/server/ActionCtx\");\n\nexport type ActionCtx<DataModel extends GenericDataModel> = ReturnType<\n typeof ActionCtx<DataModel>\n>[\"Identifier\"];\n"],"mappings":";;;;;AAGA,MAAa,kBACX,QAAQ,WAAwC,4BAA4B"}
@@ -1,14 +1,9 @@
1
- import { Context, Effect, Layer, ParseResult } from "effect";
2
- import * as Ref$1 from "@confect/core/Ref";
3
- import { GenericActionCtx } from "convex/server";
4
-
5
- //#region src/ActionRunner.d.ts
6
- declare namespace ActionRunner_d_exports {
7
- export { ActionRunner, layer };
8
- }
9
- declare const ActionRunner: Context.Tag<(<Action extends Ref$1.AnyAction>(action: Action, ...args: Ref$1.OptionalArgs<Action>) => Effect.Effect<Ref$1.Returns<Action>, Ref$1.Error<Action> | ParseResult.ParseError>), <Action extends Ref$1.AnyAction>(action: Action, ...args: Ref$1.OptionalArgs<Action>) => Effect.Effect<Ref$1.Returns<Action>, Ref$1.Error<Action> | ParseResult.ParseError>>;
10
- type ActionRunner = typeof ActionRunner.Identifier;
11
- declare const layer: (runAction: GenericActionCtx<any>["runAction"]) => Layer.Layer<(<Action extends Ref$1.AnyAction>(action: Action, ...args: Ref$1.OptionalArgs<Action>) => Effect.Effect<Ref$1.Returns<Action>, Ref$1.Error<Action> | ParseResult.ParseError>), never, never>;
12
- //#endregion
13
- export { ActionRunner, ActionRunner_d_exports, layer };
1
+ import * as Ref from "@confect/core/Ref";
2
+ import { type GenericActionCtx } from "convex/server";
3
+ import type { ParseResult, Effect } from "effect";
4
+ import * as Context from "effect/Context";
5
+ import * as Layer from "effect/Layer";
6
+ export declare const ActionRunner: Context.Tag<(<Action extends Ref.AnyAction>(action: Action, ...args: Ref.OptionalArgs<Action>) => Effect.Effect<Ref.Returns<Action>, Ref.Error<Action> | ParseResult.ParseError>), <Action extends Ref.AnyAction>(action: Action, ...args: Ref.OptionalArgs<Action>) => Effect.Effect<Ref.Returns<Action>, Ref.Error<Action> | ParseResult.ParseError>>;
7
+ export type ActionRunner = typeof ActionRunner.Identifier;
8
+ export declare const layer: (runAction: GenericActionCtx<any>["runAction"]) => Layer.Layer<(<Action extends Ref.AnyAction>(action: Action, ...args: Ref.OptionalArgs<Action>) => Effect.Effect<Ref.Returns<Action>, Ref.Error<Action> | ParseResult.ParseError>), never, never>;
14
9
  //# sourceMappingURL=ActionRunner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActionRunner.d.ts","names":[],"sources":["../src/ActionRunner.ts"],"mappings":";;;;;;;;cAqBa,YAAA,EAAY,OAAA,CAAA,GAAA,kBAdP,KAAA,CAAI,SAAA,EAAS,MAAA,EACnB,MAAA,KAAM,IAAA,EACL,KAAA,CAAI,YAAA,CAAa,MAAA,MACzB,MAAA,CAAO,MAAA,CACR,KAAA,CAAI,OAAA,CAAQ,MAAA,GACZ,KAAA,CAAI,KAAA,CAAM,MAAA,IAAU,WAAA,CAAY,UAAA,oBALlB,KAAA,CAAI,SAAA,EAAS,MAAA,EACnB,MAAA,KAAM,IAAA,EACL,KAAA,CAAI,YAAA,CAAa,MAAA,MACzB,MAAA,CAAO,MAAA,CACR,KAAA,CAAI,OAAA,CAAQ,MAAA,GACZ,KAAA,CAAI,KAAA,CAAM,MAAA,IAAU,WAAA,CAAY,UAAA;AAAA,KAYxB,YAAA,UAAsB,YAAA,CAAa,UAAA;AAAA,cAElC,KAAA,GAAS,SAAA,EAAW,gBAAA,uBAAkC,KAAA,CAAA,KAAA,kBAnBjD,KAAA,CAAI,SAAA,EAAS,MAAA,EACnB,MAAA,KAAM,IAAA,EACL,KAAA,CAAI,YAAA,CAAa,MAAA,MACzB,MAAA,CAAO,MAAA,CACR,KAAA,CAAI,OAAA,CAAQ,MAAA,GACZ,KAAA,CAAI,KAAA,CAAM,MAAA,IAAU,WAAA,CAAY,UAAA"}
1
+ {"version":3,"file":"ActionRunner.d.ts","sourceRoot":"","sources":["../src/ActionRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAkBtC,eAAO,MAAM,YAAY,gBAdtB,MAAM,SAAS,GAAG,CAAC,SAAS,UACnB,MAAM,WACL,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAChC,MAAM,CAAC,MAAM,CACd,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EACnB,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,UAAU,CAC3C,IANA,MAAM,SAAS,GAAG,CAAC,SAAS,UACnB,MAAM,WACL,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAChC,MAAM,CAAC,MAAM,CACd,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EACnB,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,UAAU,CAC3C,CAUF,CAAC;AACF,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,UAAU,CAAC;AAE1D,eAAO,MAAM,KAAK,GAAI,WAAW,gBAAgB,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,mBAnBhE,MAAM,SAAS,GAAG,CAAC,SAAS,UACnB,MAAM,WACL,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAChC,MAAM,CAAC,MAAM,CACd,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EACnB,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,UAAU,CAC3C,gBAc2C,CAAC"}
@@ -1,14 +1,15 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- import { Context, Layer } from "effect";
3
- import * as Ref$1 from "@confect/core/Ref";
2
+ import * as Context from "effect/Context";
3
+ import * as Ref from "@confect/core/Ref";
4
4
  import "convex/server";
5
+ import * as Layer from "effect/Layer";
5
6
 
6
7
  //#region src/ActionRunner.ts
7
8
  var ActionRunner_exports = /* @__PURE__ */ __exportAll({
8
9
  ActionRunner: () => ActionRunner,
9
10
  layer: () => layer
10
11
  });
11
- const make = (runAction) => (action, ...args) => Ref$1.runWithCodec(action, args[0] ?? {}, (functionReference, encodedArgs) => runAction(functionReference, encodedArgs));
12
+ const make = (runAction) => (action, ...args) => Ref.runWithCodec(action, args[0] ?? {}, (functionReference, encodedArgs) => runAction(functionReference, encodedArgs));
12
13
  const ActionRunner = Context.GenericTag("@confect/server/ActionRunner");
13
14
  const layer = (runAction) => Layer.succeed(ActionRunner, make(runAction));
14
15
 
@@ -1 +1 @@
1
- {"version":3,"file":"ActionRunner.js","names":["Ref"],"sources":["../src/ActionRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericActionCtx } from \"convex/server\";\nimport type { ParseResult, Effect } from \"effect\";\nimport { Context, Layer } from \"effect\";\n\nconst make =\n (runAction: GenericActionCtx<any>[\"runAction\"]) =>\n <Action extends Ref.AnyAction>(\n action: Action,\n ...args: Ref.OptionalArgs<Action>\n ): Effect.Effect<\n Ref.Returns<Action>,\n Ref.Error<Action> | ParseResult.ParseError\n > =>\n Ref.runWithCodec(\n action,\n (args[0] ?? {}) as Ref.Args<Action>,\n (functionReference, encodedArgs) =>\n runAction(functionReference, encodedArgs),\n );\n\nexport const ActionRunner = Context.GenericTag<ReturnType<typeof make>>(\n \"@confect/server/ActionRunner\",\n);\nexport type ActionRunner = typeof ActionRunner.Identifier;\n\nexport const layer = (runAction: GenericActionCtx<any>[\"runAction\"]) =>\n Layer.succeed(ActionRunner, make(runAction));\n"],"mappings":";;;;;;;;;;AAKA,MAAM,QACH,eAEC,QACA,GAAG,SAKHA,MAAI,aACF,QACC,KAAK,MAAM,EAAE,GACb,mBAAmB,gBAClB,UAAU,mBAAmB,YAAY,CAC5C;AAEL,MAAa,eAAe,QAAQ,WAClC,+BACD;AAGD,MAAa,SAAS,cACpB,MAAM,QAAQ,cAAc,KAAK,UAAU,CAAC"}
1
+ {"version":3,"file":"ActionRunner.js","names":[],"sources":["../src/ActionRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericActionCtx } from \"convex/server\";\nimport type { ParseResult, Effect } from \"effect\";\nimport * as Context from \"effect/Context\";\nimport * as Layer from \"effect/Layer\";\n\nconst make =\n (runAction: GenericActionCtx<any>[\"runAction\"]) =>\n <Action extends Ref.AnyAction>(\n action: Action,\n ...args: Ref.OptionalArgs<Action>\n ): Effect.Effect<\n Ref.Returns<Action>,\n Ref.Error<Action> | ParseResult.ParseError\n > =>\n Ref.runWithCodec(\n action,\n (args[0] ?? {}) as Ref.Args<Action>,\n (functionReference, encodedArgs) =>\n runAction(functionReference, encodedArgs),\n );\n\nexport const ActionRunner = Context.GenericTag<ReturnType<typeof make>>(\n \"@confect/server/ActionRunner\",\n);\nexport type ActionRunner = typeof ActionRunner.Identifier;\n\nexport const layer = (runAction: GenericActionCtx<any>[\"runAction\"]) =>\n Layer.succeed(ActionRunner, make(runAction));\n"],"mappings":";;;;;;;;;;;AAMA,MAAM,QACH,eAEC,QACA,GAAG,SAKH,IAAI,aACF,QACC,KAAK,MAAM,EAAE,GACb,mBAAmB,gBAClB,UAAU,mBAAmB,YAAY,CAC5C;AAEL,MAAa,eAAe,QAAQ,WAClC,+BACD;AAGD,MAAa,SAAS,cACpB,MAAM,QAAQ,cAAc,KAAK,UAAU,CAAC"}
package/dist/Auth.d.ts CHANGED
@@ -1,30 +1,24 @@
1
- import { Effect, Layer, Schema } from "effect";
2
- import * as convex_server0 from "convex/server";
3
- import { Auth as Auth$1 } from "convex/server";
4
- import * as effect_Context0 from "effect/Context";
5
- import * as effect_Cause0 from "effect/Cause";
6
-
7
- //#region src/Auth.d.ts
8
- declare namespace Auth_d_exports {
9
- export { Auth, NoUserIdentityFoundError, layer };
10
- }
11
- declare const Auth_base: effect_Context0.TagClass<Auth, "@confect/server/Auth", {
12
- getUserIdentity: Effect.Effect<convex_server0.UserIdentity, NoUserIdentityFoundError, never>;
1
+ import type { Auth as ConvexAuth } from "convex/server";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import * as Schema from "effect/Schema";
5
+ declare const Auth_base: import("effect/Context").TagClass<Auth, "@confect/server/Auth", {
6
+ getUserIdentity: Effect.Effect<import("convex/server").UserIdentity, NoUserIdentityFoundError, never>;
13
7
  }> & Effect.Tag.Proxy<Auth, {
14
- getUserIdentity: Effect.Effect<convex_server0.UserIdentity, NoUserIdentityFoundError, never>;
8
+ getUserIdentity: Effect.Effect<import("convex/server").UserIdentity, NoUserIdentityFoundError, never>;
15
9
  }> & {
16
- use: <X>(body: (_: {
17
- getUserIdentity: Effect.Effect<convex_server0.UserIdentity, NoUserIdentityFoundError, never>;
18
- }) => X) => [X] extends [Effect.Effect<infer A, infer E, infer R>] ? Effect.Effect<A, E, Auth | R> : [X] extends [PromiseLike<infer A_1>] ? Effect.Effect<A_1, effect_Cause0.UnknownException, Auth> : Effect.Effect<X, never, Auth>;
10
+ use: <X>(body: (_: {
11
+ getUserIdentity: Effect.Effect<import("convex/server").UserIdentity, NoUserIdentityFoundError, never>;
12
+ }) => X) => [X] extends [Effect.Effect<infer A, infer E, infer R>] ? Effect.Effect<A, E, Auth | R> : [X] extends [PromiseLike<infer A_1>] ? Effect.Effect<A_1, import("effect/Cause").UnknownException, Auth> : Effect.Effect<X, never, Auth>;
19
13
  };
20
- declare class Auth extends Auth_base {}
21
- declare const layer: (auth: Auth$1) => Layer.Layer<Auth, never, never>;
14
+ export declare class Auth extends Auth_base {
15
+ }
16
+ export declare const layer: (auth: ConvexAuth) => Layer.Layer<Auth, never, never>;
22
17
  declare const NoUserIdentityFoundError_base: Schema.TaggedErrorClass<NoUserIdentityFoundError, "NoUserIdentityFoundError", {
23
- readonly _tag: Schema.tag<"NoUserIdentityFoundError">;
18
+ readonly _tag: Schema.tag<"NoUserIdentityFoundError">;
24
19
  }>;
25
- declare class NoUserIdentityFoundError extends NoUserIdentityFoundError_base {
26
- get message(): string;
20
+ export declare class NoUserIdentityFoundError extends NoUserIdentityFoundError_base {
21
+ get message(): string;
27
22
  }
28
- //#endregion
29
- export { Auth, Auth_d_exports, NoUserIdentityFoundError, layer };
23
+ export {};
30
24
  //# sourceMappingURL=Auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Auth.d.ts","names":[],"sources":["../src/Auth.ts"],"mappings":";;;;;;;;;;cAC6D,SAAA;;;;;;;;;cAgBhD,IAAA,SAAa,SAAA;AAAA,cAKb,KAAA,GAAS,IAAA,EAAM,MAAA,KAAU,KAAA,CAAA,KAAA,CAAA,IAAA;AAAA,cAAqC,6BAAA;;;cAE9D,wBAAA,SAAiC,6BAAA;EAAA,IAI/B,OAAA,CAAA;AAAA"}
1
+ {"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../src/Auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;;;;;;;AAgBxC,qBAAa,IAAK,SAAQ,SAGvB;CAAG;AAEN,eAAO,MAAM,KAAK,GAAI,MAAM,UAAU,oCAAoC,CAAC;;;;AAE3E,qBAAa,wBAAyB,SAAQ,6BAG7C;IACC,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF"}
package/dist/Auth.js CHANGED
@@ -1,5 +1,9 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- import { Effect, Layer, Option, Schema, flow } from "effect";
2
+ import * as Layer from "effect/Layer";
3
+ import { flow } from "effect/Function";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Option from "effect/Option";
6
+ import * as Schema from "effect/Schema";
3
7
 
4
8
  //#region src/Auth.ts
5
9
  var Auth_exports = /* @__PURE__ */ __exportAll({
package/dist/Auth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Auth.js","names":[],"sources":["../src/Auth.ts"],"sourcesContent":["import type { Auth as ConvexAuth } from \"convex/server\";\nimport { Effect, flow, Layer, Option, Schema } from \"effect\";\n\nconst make = (auth: ConvexAuth) => ({\n getUserIdentity: Effect.promise(() => auth.getUserIdentity()).pipe(\n Effect.andThen(\n flow(\n Option.fromNullable,\n Option.match({\n onNone: () => Effect.fail(new NoUserIdentityFoundError()),\n onSome: Effect.succeed,\n }),\n ),\n ),\n ),\n});\n\nexport class Auth extends Effect.Tag(\"@confect/server/Auth\")<\n Auth,\n ReturnType<typeof make>\n>() {}\n\nexport const layer = (auth: ConvexAuth) => Layer.succeed(Auth, make(auth));\n\nexport class NoUserIdentityFoundError extends Schema.TaggedError<NoUserIdentityFoundError>()(\n \"NoUserIdentityFoundError\",\n {},\n) {\n override get message(): string {\n return \"No user identity found\";\n }\n}\n"],"mappings":";;;;;;;;;AAGA,MAAM,QAAQ,UAAsB,EAClC,iBAAiB,OAAO,cAAc,KAAK,iBAAiB,CAAC,CAAC,KAC5D,OAAO,QACL,KACE,OAAO,cACP,OAAO,MAAM;CACX,cAAc,OAAO,KAAK,IAAI,0BAA0B,CAAC;CACzD,QAAQ,OAAO;CAChB,CAAC,CACH,CACF,CACF,EACF;AAED,IAAa,OAAb,cAA0B,OAAO,IAAI,uBAAuB,EAGzD,CAAC;AAEJ,MAAa,SAAS,SAAqB,MAAM,QAAQ,MAAM,KAAK,KAAK,CAAC;AAE1E,IAAa,2BAAb,cAA8C,OAAO,aAAuC,CAC1F,4BACA,EAAE,CACH,CAAC;CACA,IAAa,UAAkB;AAC7B,SAAO"}
1
+ {"version":3,"file":"Auth.js","names":[],"sources":["../src/Auth.ts"],"sourcesContent":["import type { Auth as ConvexAuth } from \"convex/server\";\nimport { flow } from \"effect/Function\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\n\nconst make = (auth: ConvexAuth) => ({\n getUserIdentity: Effect.promise(() => auth.getUserIdentity()).pipe(\n Effect.andThen(\n flow(\n Option.fromNullable,\n Option.match({\n onNone: () => Effect.fail(new NoUserIdentityFoundError()),\n onSome: Effect.succeed,\n }),\n ),\n ),\n ),\n});\n\nexport class Auth extends Effect.Tag(\"@confect/server/Auth\")<\n Auth,\n ReturnType<typeof make>\n>() {}\n\nexport const layer = (auth: ConvexAuth) => Layer.succeed(Auth, make(auth));\n\nexport class NoUserIdentityFoundError extends Schema.TaggedError<NoUserIdentityFoundError>()(\n \"NoUserIdentityFoundError\",\n {},\n) {\n override get message(): string {\n return \"No user identity found\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,MAAM,QAAQ,UAAsB,EAClC,iBAAiB,OAAO,cAAc,KAAK,iBAAiB,CAAC,CAAC,KAC5D,OAAO,QACL,KACE,OAAO,cACP,OAAO,MAAM;CACX,cAAc,OAAO,KAAK,IAAI,0BAA0B,CAAC;CACzD,QAAQ,OAAO;CAChB,CAAC,CACH,CACF,CACF,EACF;AAED,IAAa,OAAb,cAA0B,OAAO,IAAI,uBAAuB,EAGzD,CAAC;AAEJ,MAAa,SAAS,SAAqB,MAAM,QAAQ,MAAM,KAAK,KAAK,CAAC;AAE1E,IAAa,2BAAb,cAA8C,OAAO,aAAuC,CAC1F,4BACA,EAAE,CACH,CAAC;CACA,IAAa,UAAkB;AAC7B,SAAO"}
@@ -1,17 +1,11 @@
1
- import { Schema } from "effect";
2
-
3
- //#region src/BlobNotFoundError.d.ts
4
- declare namespace BlobNotFoundError_d_exports {
5
- export { BlobNotFoundError };
6
- }
1
+ import * as Schema from "effect/Schema";
7
2
  declare const BlobNotFoundError_base: Schema.TaggedErrorClass<BlobNotFoundError, "BlobNotFoundError", {
8
- readonly _tag: Schema.tag<"BlobNotFoundError">;
3
+ readonly _tag: Schema.tag<"BlobNotFoundError">;
9
4
  } & {
10
- id: typeof Schema.String;
5
+ id: typeof Schema.String;
11
6
  }>;
12
- declare class BlobNotFoundError extends BlobNotFoundError_base {
13
- get message(): string;
7
+ export declare class BlobNotFoundError extends BlobNotFoundError_base {
8
+ get message(): string;
14
9
  }
15
- //#endregion
16
- export { BlobNotFoundError, BlobNotFoundError_d_exports };
10
+ export {};
17
11
  //# sourceMappingURL=BlobNotFoundError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BlobNotFoundError.d.ts","names":[],"sources":["../src/BlobNotFoundError.ts"],"mappings":";;;;;;cAAgC,sBAAA;;;;;cAEnB,iBAAA,SAA0B,sBAAA;EAAA,IAMxB,OAAA,CAAA;AAAA"}
1
+ {"version":3,"file":"BlobNotFoundError.d.ts","sourceRoot":"","sources":["../src/BlobNotFoundError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;;;AAExC,qBAAa,iBAAkB,SAAQ,sBAKtC;IACC,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF"}
@@ -1,5 +1,5 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- import { Schema } from "effect";
2
+ import * as Schema from "effect/Schema";
3
3
 
4
4
  //#region src/BlobNotFoundError.ts
5
5
  var BlobNotFoundError_exports = /* @__PURE__ */ __exportAll({ BlobNotFoundError: () => BlobNotFoundError });
@@ -1 +1 @@
1
- {"version":3,"file":"BlobNotFoundError.js","names":[],"sources":["../src/BlobNotFoundError.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nexport class BlobNotFoundError extends Schema.TaggedError<BlobNotFoundError>()(\n \"BlobNotFoundError\",\n {\n id: Schema.String,\n },\n) {\n override get message(): string {\n return `File with ID '${this.id}' not found`;\n }\n}\n"],"mappings":";;;;;AAEA,IAAa,oBAAb,cAAuC,OAAO,aAAgC,CAC5E,qBACA,EACE,IAAI,OAAO,QACZ,CACF,CAAC;CACA,IAAa,UAAkB;AAC7B,SAAO,iBAAiB,KAAK,GAAG"}
1
+ {"version":3,"file":"BlobNotFoundError.js","names":[],"sources":["../src/BlobNotFoundError.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nexport class BlobNotFoundError extends Schema.TaggedError<BlobNotFoundError>()(\n \"BlobNotFoundError\",\n {\n id: Schema.String,\n },\n) {\n override get message(): string {\n return `File with ID '${this.id}' not found`;\n }\n}\n"],"mappings":";;;;;AAEA,IAAa,oBAAb,cAAuC,OAAO,aAAgC,CAC5E,qBACA,EACE,IAAI,OAAO,QACZ,CACF,CAAC;CACA,IAAa,UAAkB;AAC7B,SAAO,iBAAiB,KAAK,GAAG"}
@@ -1,10 +1,3 @@
1
- import { ConfigProvider } from "effect";
2
-
3
- //#region src/ConvexConfigProvider.d.ts
4
- declare namespace ConvexConfigProvider_d_exports {
5
- export { make };
6
- }
7
- declare const make: (options?: Partial<ConfigProvider.ConfigProvider.FromEnvConfig>) => ConfigProvider.ConfigProvider;
8
- //#endregion
9
- export { ConvexConfigProvider_d_exports, make };
1
+ import * as ConfigProvider from "effect/ConfigProvider";
2
+ export declare const make: (options?: Partial<ConfigProvider.ConfigProvider.FromEnvConfig>) => ConfigProvider.ConfigProvider;
10
3
  //# sourceMappingURL=ConvexConfigProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConvexConfigProvider.d.ts","names":[],"sources":["../src/ConvexConfigProvider.ts"],"mappings":";;;;;;cAWa,IAAA,GACX,OAAA,GAAU,OAAA,CAAQ,cAAA,CAAe,cAAA,CAAe,aAAA,MAC/C,cAAA,CAAe,cAAA"}
1
+ {"version":3,"file":"ConvexConfigProvider.d.ts","sourceRoot":"","sources":["../src/ConvexConfigProvider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAC;AAMxD,eAAO,MAAM,IAAI,GACf,UAAU,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,aAAa,CAAC,KAC7D,cAAc,CAAC,cA4CjB,CAAC"}