@confect/core 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.
- package/CHANGELOG.md +268 -4
- package/dist/FunctionProvenance.d.ts +101 -95
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/FunctionProvenance.js +25 -6
- package/dist/FunctionProvenance.js.map +1 -1
- package/dist/FunctionSpec.d.ts +178 -218
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +2 -2
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GenericId.d.ts +7 -12
- package/dist/GenericId.d.ts.map +1 -1
- package/dist/GenericId.js +2 -1
- package/dist/GenericId.js.map +1 -1
- package/dist/GroupPath.d.ts +10 -16
- package/dist/GroupPath.d.ts.map +1 -1
- package/dist/GroupSpec.d.ts +38 -37
- package/dist/GroupSpec.d.ts.map +1 -1
- package/dist/GroupSpec.js +9 -3
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Identifier.d.ts +14 -0
- package/dist/Identifier.d.ts.map +1 -0
- package/dist/{internal/utils.js → Identifier.js} +26 -3
- package/dist/Identifier.js.map +1 -0
- package/dist/Lazy.d.ts +22 -0
- package/dist/Lazy.d.ts.map +1 -0
- package/dist/Lazy.js +44 -0
- package/dist/Lazy.js.map +1 -0
- package/dist/PaginationResult.d.ts +11 -18
- package/dist/PaginationResult.d.ts.map +1 -1
- package/dist/PaginationResult.js +1 -1
- package/dist/PaginationResult.js.map +1 -1
- package/dist/Ref.d.ts +55 -51
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +17 -6
- package/dist/Ref.js.map +1 -1
- package/dist/Refs.d.ts +21 -21
- package/dist/Refs.d.ts.map +1 -1
- package/dist/Refs.js +5 -10
- package/dist/Refs.js.map +1 -1
- package/dist/Registry.d.ts +7 -11
- package/dist/Registry.d.ts.map +1 -1
- package/dist/Registry.js +2 -1
- package/dist/Registry.js.map +1 -1
- package/dist/RuntimeAndFunctionType.d.ts +36 -41
- package/dist/RuntimeAndFunctionType.d.ts.map +1 -1
- package/dist/Spec.d.ts +23 -32
- package/dist/Spec.d.ts.map +1 -1
- package/dist/Spec.js +9 -48
- package/dist/Spec.js.map +1 -1
- package/dist/SystemFields.d.ts +10 -16
- package/dist/SystemFields.d.ts.map +1 -1
- package/dist/SystemFields.js +1 -1
- package/dist/SystemFields.js.map +1 -1
- package/dist/Types.d.ts +27 -27
- package/dist/Types.d.ts.map +1 -1
- package/dist/UserIdentity.d.ts +56 -63
- package/dist/UserIdentity.d.ts.map +1 -1
- package/dist/UserIdentity.js +1 -1
- package/dist/UserIdentity.js.map +1 -1
- package/dist/index.d.ts +17 -15
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -1
- package/dist/tsconfig.src.tsbuildinfo +1 -0
- package/package.json +37 -46
- package/src/FunctionProvenance.ts +32 -10
- package/src/FunctionSpec.ts +5 -5
- package/src/GenericId.ts +3 -1
- package/src/GroupSpec.ts +16 -11
- package/src/{internal/utils.ts → Identifier.ts} +34 -0
- package/src/Lazy.ts +40 -0
- package/src/PaginationResult.ts +1 -1
- package/src/Ref.ts +23 -8
- package/src/Refs.ts +13 -44
- package/src/Registry.ts +2 -1
- package/src/Spec.ts +18 -81
- package/src/SystemFields.ts +1 -1
- package/src/UserIdentity.ts +1 -1
- package/src/index.ts +2 -0
- package/dist/internal/utils.d.ts +0 -5
- package/dist/internal/utils.d.ts.map +0 -1
- package/dist/internal/utils.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,266 @@
|
|
|
1
1
|
# @confect/core
|
|
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
|
+
## 9.0.0-next.9
|
|
12
|
+
|
|
13
|
+
### Major Changes
|
|
14
|
+
|
|
15
|
+
- 4894959: Make Node-runtime functions first-class and remove the separate `node` namespace.
|
|
16
|
+
|
|
17
|
+
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.
|
|
18
|
+
|
|
19
|
+
### Why
|
|
20
|
+
|
|
21
|
+
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).
|
|
22
|
+
|
|
23
|
+
### Breaking changes
|
|
24
|
+
|
|
25
|
+
- **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.
|
|
26
|
+
- **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).
|
|
27
|
+
- **`@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).
|
|
28
|
+
|
|
29
|
+
### Migration
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
2. Update call sites to drop the `node` segment: `refs.public.node.<group>.<fn>` → `refs.public.<group>.<fn>`.
|
|
33
|
+
3. Replace `Refs.make(spec, nodeSpec)` with `Refs.make(spec)` (codegen does this for `_generated/refs.ts` automatically).
|
|
34
|
+
4. Run `confect codegen`. The `convex/` tree and `confect/_generated/` are re-emitted; the stale `_generated/nodeSpec.ts` is removed.
|
|
35
|
+
|
|
36
|
+
## 9.0.0-next.8
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 3fec285: Import Effect from its submodule paths internally to shrink per-function cold-start bundles.
|
|
41
|
+
|
|
42
|
+
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"`).
|
|
43
|
+
|
|
44
|
+
### Why
|
|
45
|
+
|
|
46
|
+
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.
|
|
47
|
+
|
|
48
|
+
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).
|
|
49
|
+
|
|
50
|
+
No API changes — your existing code keeps working.
|
|
51
|
+
|
|
52
|
+
### Getting the full win in your own code
|
|
53
|
+
|
|
54
|
+
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:
|
|
55
|
+
|
|
56
|
+
```diff
|
|
57
|
+
- import { Schema } from "effect";
|
|
58
|
+
+ import * as Schema from "effect/Schema";
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Bare helpers (`pipe`, `flow`, `identity`) come from `"effect/Function"`.
|
|
62
|
+
|
|
63
|
+
## 9.0.0-next.7
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- 5d19484: Stabilize the identity of `@confect/react` hook results across renders.
|
|
68
|
+
|
|
69
|
+
`useQuery` previously decoded and wrapped the Convex result on every render, handing consumers a brand new `QueryResult` even when the underlying Convex data was unchanged. Effects and memoization that depend on the result's identity (e.g. `useEffect(..., [user])` derived via `QueryResult.match`) would re-run on every render, which could escalate into `Maximum update depth exceeded`. The decoded `QueryResult` is now memoized by the (referentially stable) Convex result, so unchanged data keeps a stable identity.
|
|
70
|
+
|
|
71
|
+
`useMutation` and `useAction` now return a stable callback via `useCallback`, matching the identity contract of Convex's own hooks, instead of allocating a fresh function each render.
|
|
72
|
+
|
|
73
|
+
`Ref.getFunctionReference` now caches the Convex function reference by function name, so repeated calls for the same ref return the same reference.
|
|
74
|
+
|
|
75
|
+
## 9.0.0-next.6
|
|
76
|
+
|
|
77
|
+
### Major Changes
|
|
78
|
+
|
|
79
|
+
- 46045a9: Reduce per-function cold-start cost: make `FunctionSpec` schemas lazy and keep each Convex function's bundle scoped to its own group.
|
|
80
|
+
|
|
81
|
+
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.
|
|
82
|
+
|
|
83
|
+
### Lazy `FunctionSpec` schemas
|
|
84
|
+
|
|
85
|
+
`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.
|
|
86
|
+
|
|
87
|
+
Migration — wrap each schema in `() =>`:
|
|
88
|
+
|
|
89
|
+
```diff
|
|
90
|
+
FunctionSpec.publicQuery({
|
|
91
|
+
name: "list",
|
|
92
|
+
- args: Schema.Struct({}),
|
|
93
|
+
- returns: Schema.Array(notes.Doc),
|
|
94
|
+
+ args: () => Schema.Struct({}),
|
|
95
|
+
+ returns: () => Schema.Array(notes.Doc),
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Impls take the `DatabaseSchema`, and group paths resolve impl-side
|
|
100
|
+
|
|
101
|
+
`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.
|
|
102
|
+
|
|
103
|
+
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).
|
|
104
|
+
|
|
105
|
+
Migration — in each `*.impl.ts`, import the database schema and pass it where you passed `api` / `nodeApi`:
|
|
106
|
+
|
|
107
|
+
```diff
|
|
108
|
+
- import api from "../_generated/api"; // (or nodeApi from "../_generated/nodeApi")
|
|
109
|
+
+ import databaseSchema from "../_generated/schema";
|
|
110
|
+
|
|
111
|
+
- const insert = FunctionImpl.make(api, notes, "insert", handler);
|
|
112
|
+
+ const insert = FunctionImpl.make(databaseSchema, notes, "insert", handler);
|
|
113
|
+
|
|
114
|
+
- export default GroupImpl.make(api, notes).pipe(Layer.provide(insert), GroupImpl.finalize);
|
|
115
|
+
+ export default GroupImpl.make(databaseSchema, notes).pipe(Layer.provide(insert), GroupImpl.finalize);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
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.
|
|
119
|
+
|
|
120
|
+
### `buildForGroup` and the generated registries
|
|
121
|
+
|
|
122
|
+
`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.
|
|
123
|
+
|
|
124
|
+
### `_generated/api.ts` / `nodeApi.ts` are no longer emitted, and `Api` is removed
|
|
125
|
+
|
|
126
|
+
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.
|
|
127
|
+
|
|
128
|
+
### Net effect
|
|
129
|
+
|
|
130
|
+
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.
|
|
131
|
+
|
|
132
|
+
- 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.
|
|
133
|
+
|
|
134
|
+
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.
|
|
135
|
+
|
|
136
|
+
Codegen now scans `confect/tables/*.ts` (every file must default-export a `Table`) and emits two siblings:
|
|
137
|
+
|
|
138
|
+
- `confect/_generated/schema.ts` — the runtime `DatabaseSchema`, consumed by `_generated/api.ts`. Imports `@confect/server` but never `convex/server`.
|
|
139
|
+
- `confect/_generated/convexSchema.ts` — the Convex deploy `SchemaDefinition`, re-exported one-line from `convex/schema.ts`. Imports `convex/server` but never `@confect/server`.
|
|
140
|
+
|
|
141
|
+
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.
|
|
142
|
+
|
|
143
|
+
### Filename-derived table names
|
|
144
|
+
|
|
145
|
+
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.
|
|
146
|
+
|
|
147
|
+
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.
|
|
148
|
+
|
|
149
|
+
Codegen now emits two new sets of files alongside `_generated/schema.ts` and `_generated/convexSchema.ts`:
|
|
150
|
+
|
|
151
|
+
- `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")`.
|
|
152
|
+
- `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`.
|
|
153
|
+
|
|
154
|
+
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`).
|
|
155
|
+
|
|
156
|
+
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`).
|
|
157
|
+
|
|
158
|
+
### Lazy per-table schema construction
|
|
159
|
+
|
|
160
|
+
`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.
|
|
161
|
+
|
|
162
|
+
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.
|
|
163
|
+
|
|
164
|
+
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).
|
|
165
|
+
|
|
166
|
+
### Migration
|
|
167
|
+
|
|
168
|
+
1. Delete your `confect/schema.ts`. Codegen will refuse to run while a stray copy is present.
|
|
169
|
+
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.
|
|
170
|
+
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`:
|
|
171
|
+
|
|
172
|
+
```diff
|
|
173
|
+
- import { GenericId } from "@confect/core";
|
|
174
|
+
import { Table } from "@confect/server";
|
|
175
|
+
import { Schema } from "effect";
|
|
176
|
+
+ import { Id } from "../_generated/id";
|
|
177
|
+
|
|
178
|
+
- export default Table.make(
|
|
179
|
+
- "notes",
|
|
180
|
+
- Schema.Struct({
|
|
181
|
+
- userId: Schema.optional(GenericId.GenericId("users")),
|
|
182
|
+
- text: Schema.String,
|
|
183
|
+
- }),
|
|
184
|
+
- );
|
|
185
|
+
+ export default Table.make(() =>
|
|
186
|
+
+ Schema.Struct({
|
|
187
|
+
+ userId: Schema.optional(Id("users")),
|
|
188
|
+
+ text: Schema.String,
|
|
189
|
+
+ }),
|
|
190
|
+
+ );
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
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):
|
|
194
|
+
|
|
195
|
+
```diff
|
|
196
|
+
- import Notes from "../tables/Notes";
|
|
197
|
+
+ import notes from "../_generated/tables/notes";
|
|
198
|
+
|
|
199
|
+
- returns: Schema.Array(Notes.Doc),
|
|
200
|
+
+ returns: Schema.Array(notes.Doc),
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
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.).
|
|
204
|
+
6. If you read `table.name` anywhere off a bound `Table`, rename it to `table.tableName`.
|
|
205
|
+
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.
|
|
206
|
+
8. If you use `@confect/test`, pass the generated Convex schema definition to `TestConfect.layer`:
|
|
207
|
+
|
|
208
|
+
```diff
|
|
209
|
+
- import confectSchema from "./confect/schema";
|
|
210
|
+
+ import confectSchema from "./confect/_generated/schema";
|
|
211
|
+
+ import convexSchema from "./confect/_generated/convexSchema";
|
|
212
|
+
|
|
213
|
+
export const layer = TestConfect_.layer(
|
|
214
|
+
confectSchema,
|
|
215
|
+
+ convexSchema,
|
|
216
|
+
import.meta.glob("./convex/**/!(*.*.*)*.*s"),
|
|
217
|
+
);
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### New warning: no tables discovered
|
|
221
|
+
|
|
222
|
+
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/`.
|
|
223
|
+
|
|
224
|
+
### New error: invalid table filename
|
|
225
|
+
|
|
226
|
+
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`.
|
|
227
|
+
|
|
228
|
+
## 9.0.0-next.5
|
|
229
|
+
|
|
230
|
+
## 9.0.0-next.4
|
|
231
|
+
|
|
232
|
+
## 9.0.0-next.3
|
|
233
|
+
|
|
234
|
+
### Patch Changes
|
|
235
|
+
|
|
236
|
+
- 6d85210: Resolve `FunctionImpl` / `GroupImpl` group paths via an immutable `paths` map on `Spec` instead of identity-walking the assembled tree.
|
|
237
|
+
|
|
238
|
+
### Why
|
|
239
|
+
|
|
240
|
+
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.
|
|
241
|
+
|
|
242
|
+
### What changed
|
|
243
|
+
|
|
244
|
+
- `@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.
|
|
245
|
+
- `@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.
|
|
246
|
+
- `@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.
|
|
247
|
+
- `@confect/server/GroupPath` (the old identity-based resolver) is deleted.
|
|
248
|
+
- `@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.
|
|
249
|
+
|
|
250
|
+
### User-facing impact
|
|
251
|
+
|
|
252
|
+
- 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.
|
|
253
|
+
- 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.
|
|
254
|
+
- 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.
|
|
255
|
+
|
|
256
|
+
### Fixes
|
|
257
|
+
|
|
258
|
+
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.
|
|
259
|
+
|
|
260
|
+
## 9.0.0-next.2
|
|
261
|
+
|
|
262
|
+
## 9.0.0-next.1
|
|
263
|
+
|
|
3
264
|
## 9.0.0-next.0
|
|
4
265
|
|
|
5
266
|
### Major Changes
|
|
@@ -15,6 +276,7 @@
|
|
|
15
276
|
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
277
|
|
|
17
278
|
### Breaking changes
|
|
279
|
+
|
|
18
280
|
- `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
281
|
- `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
282
|
- 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 +285,7 @@
|
|
|
23
285
|
- 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
286
|
|
|
25
287
|
### Migration
|
|
288
|
+
|
|
26
289
|
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
290
|
- In each spec, call `GroupSpec.make()` (or `GroupSpec.makeNode()`) without a name and `export default` the result.
|
|
28
291
|
- 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 +293,7 @@
|
|
|
30
293
|
export default GroupImpl.make(api, notes).pipe(
|
|
31
294
|
Layer.provide(list),
|
|
32
295
|
Layer.provide(insert),
|
|
33
|
-
GroupImpl.finalize
|
|
296
|
+
GroupImpl.finalize
|
|
34
297
|
);
|
|
35
298
|
```
|
|
36
299
|
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.)
|
|
@@ -68,7 +331,7 @@
|
|
|
68
331
|
|
|
69
332
|
export class NoteNotFound extends Schema.TaggedError<NoteNotFound>()(
|
|
70
333
|
"NoteNotFound",
|
|
71
|
-
{ noteId: GenericId.GenericId("notes") }
|
|
334
|
+
{ noteId: GenericId.GenericId("notes") }
|
|
72
335
|
) {}
|
|
73
336
|
|
|
74
337
|
export const notes = GroupSpec.make("notes").addFunction(
|
|
@@ -77,7 +340,7 @@
|
|
|
77
340
|
args: Schema.Struct({ noteId: GenericId.GenericId("notes") }),
|
|
78
341
|
returns: Notes.Doc,
|
|
79
342
|
error: NoteNotFound,
|
|
80
|
-
})
|
|
343
|
+
})
|
|
81
344
|
);
|
|
82
345
|
```
|
|
83
346
|
|
|
@@ -97,7 +360,7 @@
|
|
|
97
360
|
.table("notes")
|
|
98
361
|
.get(noteId)
|
|
99
362
|
.pipe(Effect.mapError(() => new NoteNotFound({ noteId })));
|
|
100
|
-
})
|
|
363
|
+
})
|
|
101
364
|
);
|
|
102
365
|
```
|
|
103
366
|
|
|
@@ -169,6 +432,7 @@
|
|
|
169
432
|
Unspecified failures continue to reject the promise.
|
|
170
433
|
|
|
171
434
|
### Migration
|
|
435
|
+
|
|
172
436
|
- 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).
|
|
173
437
|
- 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.
|
|
174
438
|
|
|
@@ -1,116 +1,122 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import * as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
args: Schema.Schema.AnyNoContext;
|
|
12
|
-
returns: Schema.Schema.AnyNoContext;
|
|
13
|
-
error?: Schema.Schema.AnyNoContext;
|
|
14
|
-
};
|
|
15
|
-
Convex: {};
|
|
1
|
+
import type { DefaultFunctionArgs } from "convex/server";
|
|
2
|
+
import type { Schema } from "effect";
|
|
3
|
+
import * as Data from "effect/Data";
|
|
4
|
+
export type FunctionProvenance = Data.TaggedEnum<{
|
|
5
|
+
Confect: {
|
|
6
|
+
args: Schema.Schema.AnyNoContext;
|
|
7
|
+
returns: Schema.Schema.AnyNoContext;
|
|
8
|
+
error?: Schema.Schema.AnyNoContext;
|
|
9
|
+
};
|
|
10
|
+
Convex: {};
|
|
16
11
|
}>;
|
|
17
|
-
interface Confect<Args extends Schema.Schema.AnyNoContext, Returns extends Schema.Schema.AnyNoContext, Error extends Schema.Schema.AnyNoContext = never> {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
export interface Confect<Args extends Schema.Schema.AnyNoContext, Returns extends Schema.Schema.AnyNoContext, Error extends Schema.Schema.AnyNoContext = never> {
|
|
13
|
+
readonly _tag: "Confect";
|
|
14
|
+
readonly args: Args;
|
|
15
|
+
readonly returns: Returns;
|
|
16
|
+
readonly error?: Error;
|
|
22
17
|
}
|
|
23
|
-
interface AnyConfect extends Confect<Schema.Schema.AnyNoContext, Schema.Schema.AnyNoContext, Schema.Schema.AnyNoContext> {
|
|
24
|
-
interface Convex<Args extends DefaultFunctionArgs, Returns> {
|
|
25
|
-
readonly _tag: "Convex";
|
|
26
|
-
readonly _args: Args;
|
|
27
|
-
readonly _returns: Returns;
|
|
18
|
+
export interface AnyConfect extends Confect<Schema.Schema.AnyNoContext, Schema.Schema.AnyNoContext, Schema.Schema.AnyNoContext> {
|
|
28
19
|
}
|
|
29
|
-
interface
|
|
30
|
-
declare const FunctionProvenance: {
|
|
31
|
-
readonly Confect: Data.Case.Constructor<{
|
|
32
|
-
readonly _tag: "Confect";
|
|
33
|
-
readonly args: Schema.Schema.AnyNoContext;
|
|
34
|
-
readonly returns: Schema.Schema.AnyNoContext;
|
|
35
|
-
readonly error?: Schema.Schema.AnyNoContext;
|
|
36
|
-
}, "_tag">;
|
|
37
|
-
readonly Convex: Data.Case.Constructor<{
|
|
38
|
-
readonly _tag: "Convex";
|
|
39
|
-
readonly _args: DefaultFunctionArgs;
|
|
40
|
-
readonly _returns: any;
|
|
41
|
-
}, "_tag">;
|
|
42
|
-
readonly $is: <Tag extends "Confect" | "Convex">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
43
|
-
readonly _tag: "Confect";
|
|
44
|
-
readonly args: Schema.Schema.AnyNoContext;
|
|
45
|
-
readonly returns: Schema.Schema.AnyNoContext;
|
|
46
|
-
readonly error?: Schema.Schema.AnyNoContext;
|
|
47
|
-
}, {
|
|
48
|
-
readonly _tag: Tag;
|
|
49
|
-
}> | Extract<{
|
|
20
|
+
export interface Convex<Args extends DefaultFunctionArgs, Returns> {
|
|
50
21
|
readonly _tag: "Convex";
|
|
51
|
-
readonly _args:
|
|
52
|
-
readonly _returns:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
readonly Confect: (args: {
|
|
22
|
+
readonly _args: Args;
|
|
23
|
+
readonly _returns: Returns;
|
|
24
|
+
}
|
|
25
|
+
export interface AnyConvex extends Convex<DefaultFunctionArgs, any> {
|
|
26
|
+
}
|
|
27
|
+
export declare const FunctionProvenance: {
|
|
28
|
+
readonly Confect: Data.Case.Constructor<{
|
|
59
29
|
readonly _tag: "Confect";
|
|
60
30
|
readonly args: Schema.Schema.AnyNoContext;
|
|
61
31
|
readonly returns: Schema.Schema.AnyNoContext;
|
|
62
32
|
readonly error?: Schema.Schema.AnyNoContext;
|
|
63
|
-
|
|
64
|
-
|
|
33
|
+
}, "_tag">;
|
|
34
|
+
readonly Convex: Data.Case.Constructor<{
|
|
65
35
|
readonly _tag: "Convex";
|
|
66
36
|
readonly _args: DefaultFunctionArgs;
|
|
67
37
|
readonly _returns: any;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
readonly _tag: "Confect";
|
|
71
|
-
readonly args: Schema.Schema.AnyNoContext;
|
|
72
|
-
readonly returns: Schema.Schema.AnyNoContext;
|
|
73
|
-
readonly error?: Schema.Schema.AnyNoContext;
|
|
74
|
-
} | {
|
|
75
|
-
readonly _tag: "Convex";
|
|
76
|
-
readonly _args: DefaultFunctionArgs;
|
|
77
|
-
readonly _returns: any;
|
|
78
|
-
}) => effect_Unify0.Unify<ReturnType<Cases["Confect" | "Convex"]>>;
|
|
79
|
-
<const Cases extends {
|
|
80
|
-
readonly Confect: (args: {
|
|
38
|
+
}, "_tag">;
|
|
39
|
+
readonly $is: <Tag extends "Confect" | "Convex">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
81
40
|
readonly _tag: "Confect";
|
|
82
41
|
readonly args: Schema.Schema.AnyNoContext;
|
|
83
42
|
readonly returns: Schema.Schema.AnyNoContext;
|
|
84
43
|
readonly error?: Schema.Schema.AnyNoContext;
|
|
85
|
-
|
|
86
|
-
|
|
44
|
+
}, {
|
|
45
|
+
readonly _tag: Tag;
|
|
46
|
+
}> | Extract<{
|
|
87
47
|
readonly _tag: "Convex";
|
|
88
48
|
readonly _args: DefaultFunctionArgs;
|
|
89
49
|
readonly _returns: any;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
50
|
+
}, {
|
|
51
|
+
readonly _tag: Tag;
|
|
52
|
+
}>;
|
|
53
|
+
readonly $match: {
|
|
54
|
+
<const Cases extends {
|
|
55
|
+
readonly Confect: (args: {
|
|
56
|
+
readonly _tag: "Confect";
|
|
57
|
+
readonly args: Schema.Schema.AnyNoContext;
|
|
58
|
+
readonly returns: Schema.Schema.AnyNoContext;
|
|
59
|
+
readonly error?: Schema.Schema.AnyNoContext;
|
|
60
|
+
}) => any;
|
|
61
|
+
readonly Convex: (args: {
|
|
62
|
+
readonly _tag: "Convex";
|
|
63
|
+
readonly _args: DefaultFunctionArgs;
|
|
64
|
+
readonly _returns: any;
|
|
65
|
+
}) => any;
|
|
66
|
+
}>(cases: Cases & { [K in Exclude<keyof Cases, "Confect" | "Convex">]: never; }): (value: {
|
|
67
|
+
readonly _tag: "Confect";
|
|
68
|
+
readonly args: Schema.Schema.AnyNoContext;
|
|
69
|
+
readonly returns: Schema.Schema.AnyNoContext;
|
|
70
|
+
readonly error?: Schema.Schema.AnyNoContext;
|
|
71
|
+
} | {
|
|
72
|
+
readonly _tag: "Convex";
|
|
73
|
+
readonly _args: DefaultFunctionArgs;
|
|
74
|
+
readonly _returns: any;
|
|
75
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["Confect" | "Convex"]>>;
|
|
76
|
+
<const Cases extends {
|
|
77
|
+
readonly Confect: (args: {
|
|
78
|
+
readonly _tag: "Confect";
|
|
79
|
+
readonly args: Schema.Schema.AnyNoContext;
|
|
80
|
+
readonly returns: Schema.Schema.AnyNoContext;
|
|
81
|
+
readonly error?: Schema.Schema.AnyNoContext;
|
|
82
|
+
}) => any;
|
|
83
|
+
readonly Convex: (args: {
|
|
84
|
+
readonly _tag: "Convex";
|
|
85
|
+
readonly _args: DefaultFunctionArgs;
|
|
86
|
+
readonly _returns: any;
|
|
87
|
+
}) => any;
|
|
88
|
+
}>(value: {
|
|
89
|
+
readonly _tag: "Confect";
|
|
90
|
+
readonly args: Schema.Schema.AnyNoContext;
|
|
91
|
+
readonly returns: Schema.Schema.AnyNoContext;
|
|
92
|
+
readonly error?: Schema.Schema.AnyNoContext;
|
|
93
|
+
} | {
|
|
94
|
+
readonly _tag: "Convex";
|
|
95
|
+
readonly _args: DefaultFunctionArgs;
|
|
96
|
+
readonly _returns: any;
|
|
97
|
+
}, cases: Cases & { [K in Exclude<keyof Cases, "Confect" | "Convex">]: never; }): import("effect/Unify").Unify<ReturnType<Cases["Confect" | "Convex"]>>;
|
|
98
|
+
};
|
|
108
99
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Build a `Confect` provenance from lazy schema thunks. `args`, `returns`,
|
|
102
|
+
* and `error` are exposed as sync lazy memoised getters (via {@link Lazy.defineProperty})
|
|
103
|
+
* that only evaluate their thunk on first access, mirroring how `Table`
|
|
104
|
+
* defers `Fields`/`Doc`/`tableDefinition`. This keeps importing the assembled
|
|
105
|
+
* `_generated/spec.ts` cheap — no `Schema.Struct(...)` / `Schema.Array(...)`
|
|
106
|
+
* work runs at module load; it is deferred to the first invocation that
|
|
107
|
+
* actually compiles validators or runs a codec.
|
|
108
|
+
*
|
|
109
|
+
* The object is built by hand rather than through `FunctionProvenance.Confect`
|
|
110
|
+
* because the `Data` constructor copies its input with `Object.assign`, which
|
|
111
|
+
* would force the getters at construction time and defeat the laziness.
|
|
112
|
+
* `error` is only installed when an `errorThunk` is provided, so its absence
|
|
113
|
+
* is observable via `"error" in provenance` without forcing anything; nothing
|
|
114
|
+
* relies on `Data`'s structural `Equal`/`Hash` for provenance values.
|
|
115
|
+
*/
|
|
116
|
+
export declare const Confect: <Args extends Schema.Schema.AnyNoContext, Returns extends Schema.Schema.AnyNoContext, Error extends Schema.Schema.AnyNoContext = never>(args: () => Args, returns: () => Returns, error?: () => Error) => Confect<Args, Returns, Error>;
|
|
117
|
+
export declare const Convex: <_Args extends DefaultFunctionArgs, _Returns>() => {
|
|
118
|
+
readonly _tag: "Convex";
|
|
119
|
+
readonly _args: DefaultFunctionArgs;
|
|
120
|
+
readonly _returns: any;
|
|
113
121
|
};
|
|
114
|
-
//#endregion
|
|
115
|
-
export { AnyConfect, AnyConvex, Confect, Convex, FunctionProvenance, FunctionProvenance_d_exports };
|
|
116
122
|
//# sourceMappingURL=FunctionProvenance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionProvenance.d.ts","
|
|
1
|
+
{"version":3,"file":"FunctionProvenance.d.ts","sourceRoot":"","sources":["../src/FunctionProvenance.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import {
|
|
2
|
+
import { defineProperty } from "./Lazy.js";
|
|
3
|
+
import * as Data from "effect/Data";
|
|
3
4
|
|
|
4
5
|
//#region src/FunctionProvenance.ts
|
|
5
6
|
var FunctionProvenance_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -8,11 +9,29 @@ var FunctionProvenance_exports = /* @__PURE__ */ __exportAll({
|
|
|
8
9
|
FunctionProvenance: () => FunctionProvenance
|
|
9
10
|
});
|
|
10
11
|
const FunctionProvenance = Data.taggedEnum();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Build a `Confect` provenance from lazy schema thunks. `args`, `returns`,
|
|
14
|
+
* and `error` are exposed as sync lazy memoised getters (via {@link Lazy.defineProperty})
|
|
15
|
+
* that only evaluate their thunk on first access, mirroring how `Table`
|
|
16
|
+
* defers `Fields`/`Doc`/`tableDefinition`. This keeps importing the assembled
|
|
17
|
+
* `_generated/spec.ts` cheap — no `Schema.Struct(...)` / `Schema.Array(...)`
|
|
18
|
+
* work runs at module load; it is deferred to the first invocation that
|
|
19
|
+
* actually compiles validators or runs a codec.
|
|
20
|
+
*
|
|
21
|
+
* The object is built by hand rather than through `FunctionProvenance.Confect`
|
|
22
|
+
* because the `Data` constructor copies its input with `Object.assign`, which
|
|
23
|
+
* would force the getters at construction time and defeat the laziness.
|
|
24
|
+
* `error` is only installed when an `errorThunk` is provided, so its absence
|
|
25
|
+
* is observable via `"error" in provenance` without forcing anything; nothing
|
|
26
|
+
* relies on `Data`'s structural `Equal`/`Hash` for provenance values.
|
|
27
|
+
*/
|
|
28
|
+
const Confect = (args, returns, error) => {
|
|
29
|
+
const provenance = { _tag: "Confect" };
|
|
30
|
+
defineProperty(provenance, "args", args);
|
|
31
|
+
defineProperty(provenance, "returns", returns);
|
|
32
|
+
if (error !== void 0) defineProperty(provenance, "error", error);
|
|
33
|
+
return provenance;
|
|
34
|
+
};
|
|
16
35
|
const Convex = () => FunctionProvenance.Convex({});
|
|
17
36
|
|
|
18
37
|
//#endregion
|