@confect/server 9.0.0-next.1 → 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 +293 -4
- package/dist/ActionCtx.d.ts +4 -11
- package/dist/ActionCtx.d.ts.map +1 -1
- package/dist/ActionCtx.js +1 -1
- package/dist/ActionCtx.js.map +1 -1
- package/dist/ActionRunner.d.ts +8 -13
- package/dist/ActionRunner.d.ts.map +1 -1
- package/dist/ActionRunner.js +4 -3
- package/dist/ActionRunner.js.map +1 -1
- package/dist/Auth.d.ts +17 -23
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js +5 -1
- package/dist/Auth.js.map +1 -1
- package/dist/BlobNotFoundError.d.ts +6 -12
- package/dist/BlobNotFoundError.d.ts.map +1 -1
- package/dist/BlobNotFoundError.js +1 -1
- package/dist/BlobNotFoundError.js.map +1 -1
- package/dist/ConvexConfigProvider.d.ts +2 -9
- package/dist/ConvexConfigProvider.d.ts.map +1 -1
- package/dist/ConvexConfigProvider.js +6 -1
- package/dist/ConvexConfigProvider.js.map +1 -1
- package/dist/CronJob.d.ts +12 -19
- package/dist/CronJob.d.ts.map +1 -1
- package/dist/CronJob.js +1 -1
- package/dist/CronJob.js.map +1 -1
- package/dist/CronJobs.d.ts +11 -18
- package/dist/CronJobs.d.ts.map +1 -1
- package/dist/CronJobs.js +11 -4
- package/dist/CronJobs.js.map +1 -1
- package/dist/DataModel.d.ts +24 -29
- package/dist/DataModel.d.ts.map +1 -1
- package/dist/DatabaseReader.d.ts +4323 -64
- package/dist/DatabaseReader.d.ts.map +1 -1
- package/dist/DatabaseReader.js +6 -6
- package/dist/DatabaseReader.js.map +1 -1
- package/dist/DatabaseSchema.d.ts +38 -130
- package/dist/DatabaseSchema.d.ts.map +1 -1
- package/dist/DatabaseSchema.js +20 -30
- package/dist/DatabaseSchema.js.map +1 -1
- package/dist/DatabaseWriter.d.ts +38 -42
- package/dist/DatabaseWriter.d.ts.map +1 -1
- package/dist/DatabaseWriter.js +8 -5
- package/dist/DatabaseWriter.js.map +1 -1
- package/dist/Document.d.ts +28 -37
- package/dist/Document.d.ts.map +1 -1
- package/dist/Document.js +5 -1
- package/dist/Document.js.map +1 -1
- package/dist/FunctionImpl.d.ts +30 -29
- package/dist/FunctionImpl.d.ts.map +1 -1
- package/dist/FunctionImpl.js +25 -14
- package/dist/FunctionImpl.js.map +1 -1
- package/dist/GroupImpl.d.ts +45 -41
- package/dist/GroupImpl.d.ts.map +1 -1
- package/dist/GroupImpl.js +42 -35
- package/dist/GroupImpl.js.map +1 -1
- package/dist/Handler.d.ts +34 -40
- package/dist/Handler.d.ts.map +1 -1
- package/dist/HttpApi.d.ts +21 -25
- package/dist/HttpApi.d.ts.map +1 -1
- package/dist/HttpApi.js +11 -6
- package/dist/HttpApi.js.map +1 -1
- package/dist/MutationCtx.d.ts +4 -11
- package/dist/MutationCtx.d.ts.map +1 -1
- package/dist/MutationCtx.js +1 -1
- package/dist/MutationCtx.js.map +1 -1
- package/dist/MutationRunner.d.ts +8 -13
- package/dist/MutationRunner.d.ts.map +1 -1
- package/dist/MutationRunner.js +4 -3
- package/dist/MutationRunner.js.map +1 -1
- package/dist/OrderedQuery.d.ts +16 -21
- package/dist/OrderedQuery.d.ts.map +1 -1
- package/dist/OrderedQuery.js +4 -1
- package/dist/OrderedQuery.js.map +1 -1
- package/dist/QueryCtx.d.ts +4 -11
- package/dist/QueryCtx.d.ts.map +1 -1
- package/dist/QueryCtx.js +1 -1
- package/dist/QueryCtx.js.map +1 -1
- package/dist/QueryInitializer.d.ts +34 -39
- package/dist/QueryInitializer.d.ts.map +1 -1
- package/dist/QueryInitializer.js +5 -1
- package/dist/QueryInitializer.js.map +1 -1
- package/dist/QueryRunner.d.ts +8 -13
- package/dist/QueryRunner.d.ts.map +1 -1
- package/dist/QueryRunner.js +4 -3
- package/dist/QueryRunner.js.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +1107 -60
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js +14 -9
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +48 -64
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js +9 -5
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/RegisteredFunctions.d.ts +48 -26
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js +22 -9
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/RegisteredNodeFunction.d.ts +4 -14
- package/dist/RegisteredNodeFunction.d.ts.map +1 -1
- package/dist/RegisteredNodeFunction.js +5 -4
- package/dist/RegisteredNodeFunction.js.map +1 -1
- package/dist/RegistryItem.d.ts +17 -27
- package/dist/RegistryItem.d.ts.map +1 -1
- package/dist/RegistryItem.js +1 -1
- package/dist/RegistryItem.js.map +1 -1
- package/dist/Scheduler.d.ts +16 -20
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +10 -6
- package/dist/Scheduler.js.map +1 -1
- package/dist/SchemaToValidator.d.ts +71 -64
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js +15 -3
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/StorageActionWriter.d.ts +21 -28
- package/dist/StorageActionWriter.d.ts.map +1 -1
- package/dist/StorageActionWriter.js +4 -1
- package/dist/StorageActionWriter.js.map +1 -1
- package/dist/StorageReader.d.ts +14 -21
- package/dist/StorageReader.d.ts.map +1 -1
- package/dist/StorageReader.js +5 -1
- package/dist/StorageReader.js.map +1 -1
- package/dist/StorageWriter.d.ts +16 -23
- package/dist/StorageWriter.d.ts.map +1 -1
- package/dist/StorageWriter.js +4 -1
- package/dist/StorageWriter.js.map +1 -1
- package/dist/Table.d.ts +204 -197
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +72 -62
- package/dist/Table.js.map +1 -1
- package/dist/TableInfo.d.ts +35 -41
- package/dist/TableInfo.d.ts.map +1 -1
- package/dist/VectorSearch.d.ts +30 -35
- package/dist/VectorSearch.d.ts.map +1 -1
- package/dist/VectorSearch.js +3 -1
- package/dist/VectorSearch.js.map +1 -1
- package/dist/index.d.ts +35 -36
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -5
- package/dist/internal/utils.d.ts +9 -11
- package/dist/internal/utils.d.ts.map +1 -1
- package/dist/internal/utils.js +3 -1
- package/dist/internal/utils.js.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.d.ts.map +1 -0
- package/dist/tsconfig.src.tsbuildinfo +1 -0
- package/package.json +50 -59
- package/src/ActionCtx.ts +1 -1
- package/src/ActionRunner.ts +2 -1
- package/src/Auth.ts +5 -1
- package/src/BlobNotFoundError.ts +1 -1
- package/src/ConvexConfigProvider.ts +6 -8
- package/src/CronJob.ts +1 -1
- package/src/CronJobs.ts +8 -10
- package/src/DatabaseReader.ts +18 -21
- package/src/DatabaseSchema.ts +38 -98
- package/src/DatabaseWriter.ts +13 -6
- package/src/Document.ts +5 -1
- package/src/FunctionImpl.ts +36 -44
- package/src/GroupImpl.ts +54 -81
- package/src/HttpApi.ts +8 -9
- package/src/MutationCtx.ts +1 -1
- package/src/MutationRunner.ts +2 -1
- package/src/OrderedQuery.ts +5 -1
- package/src/QueryCtx.ts +1 -1
- package/src/QueryInitializer.ts +15 -3
- package/src/QueryRunner.ts +2 -1
- package/src/RegisteredConvexFunction.ts +11 -7
- package/src/RegisteredFunction.ts +5 -1
- package/src/RegisteredFunctions.ts +69 -93
- package/src/RegisteredNodeFunction.ts +7 -6
- package/src/RegistryItem.ts +1 -1
- package/src/Scheduler.ts +5 -1
- package/src/SchemaToValidator.ts +14 -16
- package/src/StorageActionWriter.ts +4 -1
- package/src/StorageReader.ts +5 -1
- package/src/StorageWriter.ts +4 -1
- package/src/Table.ts +253 -132
- package/src/VectorSearch.ts +3 -1
- package/src/index.ts +0 -1
- package/src/internal/utils.ts +3 -1
- package/dist/Api.d.ts +0 -30
- package/dist/Api.d.ts.map +0 -1
- package/dist/Api.js +0 -26
- package/dist/Api.js.map +0 -1
- package/dist/GroupPath.d.ts +0 -8
- package/dist/GroupPath.d.ts.map +0 -1
- package/dist/GroupPath.js +0 -10
- package/dist/GroupPath.js.map +0 -1
- package/src/Api.ts +0 -75
- package/src/GroupPath.ts +0 -43
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,291 @@
|
|
|
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
|
+
|
|
3
289
|
## 9.0.0-next.1
|
|
4
290
|
|
|
5
291
|
### Patch Changes
|
|
@@ -21,6 +307,7 @@
|
|
|
21
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.
|
|
22
308
|
|
|
23
309
|
### Breaking changes
|
|
310
|
+
|
|
24
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/`.
|
|
25
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.
|
|
26
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.
|
|
@@ -29,6 +316,7 @@
|
|
|
29
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.
|
|
30
317
|
|
|
31
318
|
### Migration
|
|
319
|
+
|
|
32
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).
|
|
33
321
|
- In each spec, call `GroupSpec.make()` (or `GroupSpec.makeNode()`) without a name and `export default` the result.
|
|
34
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:
|
|
@@ -36,7 +324,7 @@
|
|
|
36
324
|
export default GroupImpl.make(api, notes).pipe(
|
|
37
325
|
Layer.provide(list),
|
|
38
326
|
Layer.provide(insert),
|
|
39
|
-
GroupImpl.finalize
|
|
327
|
+
GroupImpl.finalize
|
|
40
328
|
);
|
|
41
329
|
```
|
|
42
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.)
|
|
@@ -94,7 +382,7 @@
|
|
|
94
382
|
|
|
95
383
|
export class NoteNotFound extends Schema.TaggedError<NoteNotFound>()(
|
|
96
384
|
"NoteNotFound",
|
|
97
|
-
{ noteId: GenericId.GenericId("notes") }
|
|
385
|
+
{ noteId: GenericId.GenericId("notes") }
|
|
98
386
|
) {}
|
|
99
387
|
|
|
100
388
|
export const notes = GroupSpec.make("notes").addFunction(
|
|
@@ -103,7 +391,7 @@
|
|
|
103
391
|
args: Schema.Struct({ noteId: GenericId.GenericId("notes") }),
|
|
104
392
|
returns: Notes.Doc,
|
|
105
393
|
error: NoteNotFound,
|
|
106
|
-
})
|
|
394
|
+
})
|
|
107
395
|
);
|
|
108
396
|
```
|
|
109
397
|
|
|
@@ -123,7 +411,7 @@
|
|
|
123
411
|
.table("notes")
|
|
124
412
|
.get(noteId)
|
|
125
413
|
.pipe(Effect.mapError(() => new NoteNotFound({ noteId })));
|
|
126
|
-
})
|
|
414
|
+
})
|
|
127
415
|
);
|
|
128
416
|
```
|
|
129
417
|
|
|
@@ -195,6 +483,7 @@
|
|
|
195
483
|
Unspecified failures continue to reject the promise.
|
|
196
484
|
|
|
197
485
|
### Migration
|
|
486
|
+
|
|
198
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).
|
|
199
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.
|
|
200
489
|
|
package/dist/ActionCtx.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
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
|
package/dist/ActionCtx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionCtx.d.ts","
|
|
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
package/dist/ActionCtx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionCtx.js","names":[],"sources":["../src/ActionCtx.ts"],"sourcesContent":["import type { GenericActionCtx, GenericDataModel } from \"convex/server\";\nimport
|
|
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"}
|
package/dist/ActionRunner.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare
|
|
7
|
-
|
|
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","
|
|
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"}
|
package/dist/ActionRunner.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import
|
|
3
|
-
import * as 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
|
|
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
|
|
package/dist/ActionRunner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionRunner.js","names":[
|
|
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 {
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
5
|
-
|
|
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
|
-
|
|
8
|
+
getUserIdentity: Effect.Effect<import("convex/server").UserIdentity, NoUserIdentityFoundError, never>;
|
|
15
9
|
}> & {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
-
|
|
18
|
+
readonly _tag: Schema.tag<"NoUserIdentityFoundError">;
|
|
24
19
|
}>;
|
|
25
|
-
declare class NoUserIdentityFoundError extends NoUserIdentityFoundError_base {
|
|
26
|
-
|
|
20
|
+
export declare class NoUserIdentityFoundError extends NoUserIdentityFoundError_base {
|
|
21
|
+
get message(): string;
|
|
27
22
|
}
|
|
28
|
-
|
|
29
|
-
export { Auth, Auth_d_exports, NoUserIdentityFoundError, layer };
|
|
23
|
+
export {};
|
|
30
24
|
//# sourceMappingURL=Auth.d.ts.map
|
package/dist/Auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Auth.d.ts","
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
3
|
+
readonly _tag: Schema.tag<"BlobNotFoundError">;
|
|
9
4
|
} & {
|
|
10
|
-
|
|
5
|
+
id: typeof Schema.String;
|
|
11
6
|
}>;
|
|
12
|
-
declare class BlobNotFoundError extends BlobNotFoundError_base {
|
|
13
|
-
|
|
7
|
+
export declare class BlobNotFoundError extends BlobNotFoundError_base {
|
|
8
|
+
get message(): string;
|
|
14
9
|
}
|
|
15
|
-
|
|
16
|
-
export { BlobNotFoundError, BlobNotFoundError_d_exports };
|
|
10
|
+
export {};
|
|
17
11
|
//# sourceMappingURL=BlobNotFoundError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlobNotFoundError.d.ts","
|
|
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
|
|
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
|
|
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
|
|
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","
|
|
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"}
|