@confect/core 10.0.0-next.1 → 10.0.0-next.11
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 +144 -0
- package/dist/FunctionProvenance.d.ts +74 -3
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/FunctionProvenance.js +44 -4
- package/dist/FunctionProvenance.js.map +1 -1
- package/dist/FunctionSpec.d.ts +42 -9
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +17 -4
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GenericId.js +2 -3
- package/dist/GenericId.js.map +1 -1
- package/dist/GroupPath.js +1 -2
- package/dist/GroupSpec.js +1 -2
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Identifier.js +3 -4
- package/dist/Identifier.js.map +1 -1
- package/dist/Lazy.js +1 -2
- package/dist/Lazy.js.map +1 -1
- package/dist/PaginationOptions.d.ts +23 -0
- package/dist/PaginationOptions.d.ts.map +1 -0
- package/dist/PaginationOptions.js +29 -0
- package/dist/PaginationOptions.js.map +1 -0
- package/dist/PaginationResult.d.ts +1 -0
- package/dist/PaginationResult.d.ts.map +1 -1
- package/dist/PaginationResult.js +1 -2
- package/dist/PaginationResult.js.map +1 -1
- package/dist/Ref.d.ts +34 -5
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +51 -13
- package/dist/Ref.js.map +1 -1
- package/dist/Refs.js +1 -2
- package/dist/Refs.js.map +1 -1
- package/dist/Registry.js +1 -2
- package/dist/Registry.js.map +1 -1
- package/dist/RuntimeAndFunctionType.js +1 -2
- package/dist/RuntimeAndFunctionType.js.map +1 -1
- package/dist/Spec.js +1 -2
- package/dist/Spec.js.map +1 -1
- package/dist/SystemFields.d.ts.map +1 -1
- package/dist/SystemFields.js +2 -3
- package/dist/SystemFields.js.map +1 -1
- package/dist/Types.d.ts +1 -1
- package/dist/Types.d.ts.map +1 -1
- package/dist/Types.js +1 -2
- package/dist/Types.js.map +1 -1
- package/dist/UserIdentity.js +1 -2
- package/dist/UserIdentity.js.map +1 -1
- package/dist/_virtual/_rolldown/runtime.js +6 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/tsconfig.src.tsbuildinfo +1 -1
- package/package.json +12 -11
- package/src/FunctionProvenance.ts +147 -4
- package/src/FunctionSpec.ts +67 -1
- package/src/PaginationOptions.ts +23 -0
- package/src/PaginationResult.ts +4 -0
- package/src/Ref.ts +90 -25
- package/src/SystemFields.ts +2 -5
- package/src/Types.ts +5 -1
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,90 @@
|
|
|
1
1
|
# @confect/core
|
|
2
2
|
|
|
3
|
+
## 10.0.0-next.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f782cdd: Raise the required `effect` peer version to `^4.0.0-beta.105` (from `^4.0.0-beta.102`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
|
|
8
|
+
|
|
9
|
+
`beta.103` separates wall-clock time from monotonic elapsed time: `Clock.Clock` now also requires `monotonicTimeNanos` and `monotonicTimeNanosUnsafe`, so a custom `Clock` provided to a Confect function has to supply both. Effects that measure elapsed time — `Effect.timed`, duration metrics, `Sink.withDuration` — read the monotonic accessors instead of the wall clock, and continue to report a zero duration inside queries and mutations, where Confect pins the unsafe accessors to constants to keep Convex's query cache from evicting on every logged span.
|
|
10
|
+
|
|
11
|
+
`beta.103` also moves synchronous Effect runs off `setImmediate`/`setTimeout` and onto the microtask queue, which Convex's query and mutation isolate permits. Confect no longer suppresses cooperative fiber yielding for the synchronous work it performs while your modules load — registration and schema-to-validator compilation — and relies on that scheduling instead. Neither the "Can't use `setTimeout` in queries and mutations" crash nor any other consumer-visible behavior changes, but this is the area to look at if module loading starts misbehaving.
|
|
12
|
+
|
|
13
|
+
`beta.104` renames Effect's schema error constructors to match their `Data` counterparts, which affects any error schema you declare for a Confect function:
|
|
14
|
+
|
|
15
|
+
**Before:**
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
export class NoteNotFound extends Schema.TaggedErrorClass<NoteNotFound>()(
|
|
19
|
+
"NoteNotFound",
|
|
20
|
+
{ noteId: Id("notes") },
|
|
21
|
+
) {}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**After:**
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
export class NoteNotFound extends Schema.TaggedError<NoteNotFound>()(
|
|
28
|
+
"NoteNotFound",
|
|
29
|
+
{ noteId: Id("notes") },
|
|
30
|
+
) {}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`Schema.ErrorClass` is likewise now `Schema.Error`; the schema for JavaScript `Error` instances that previously went by `Schema.Error` is now `Schema.ErrorInstance`, and `Schema.ErrorReviver` is now `Schema.ErrorInstanceReviver`. Confect's own error types — `DocumentDecodeError`, `BlobNotFoundError`, and the rest — are unchanged in name, shape, and message.
|
|
34
|
+
|
|
35
|
+
`beta.105` restructures how schema validation failures are reported, but not on the path Confect puts you on: decode and encode failures still surface as `Schema.SchemaError` with a formatted `message`, so error text from `@confect/js`, `@confect/react`, and document decoding is unchanged.
|
|
36
|
+
|
|
37
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0 — see that version's changelog entries.
|
|
38
|
+
|
|
39
|
+
The `@effect/platform` and `@effect/cli` peer and dependency floors that 9.4.0 raises do not apply here: this line runs on Effect v4, where those packages are not dependencies at all.
|
|
40
|
+
|
|
41
|
+
## 10.0.0-next.10
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0 — see that version's changelog entries.
|
|
46
|
+
|
|
47
|
+
## 10.0.0-next.9
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- 0dcc0fb: Raise the required `effect` peer version to `^4.0.0-beta.102` (from `^4.0.0-beta.101`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
|
|
52
|
+
- 25e8d19: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5 — see that version's changelog entries.
|
|
53
|
+
|
|
54
|
+
## 10.0.0-next.8
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- 913d0e5: Raise the required `effect` peer version to `^4.0.0-beta.101` (from `^4.0.0-beta.100`).
|
|
59
|
+
|
|
60
|
+
This is a peer-range-only change with no consumer-visible API consequences. The `beta.101` release only touches fiber/concurrency internals (interrupt handling in concurrent traversal, stack frame annotations, `awaitAllChildren` linearization, `interruptibleMask` interrupt delivery), a `MutableList.filter` fix for empty buckets, a `Schema.Struct` required-readonly-field type display simplification, and an `HttpRouter.toWebHandler` middleware type-inference tightening that Confect doesn't need to accommodate.
|
|
61
|
+
|
|
62
|
+
## 10.0.0-next.7
|
|
63
|
+
|
|
64
|
+
## 10.0.0-next.6
|
|
65
|
+
|
|
66
|
+
## 10.0.0-next.5
|
|
67
|
+
|
|
68
|
+
## 10.0.0-next.4
|
|
69
|
+
|
|
70
|
+
## 10.0.0-next.3
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- 5b63546: Raise the required `effect` peer version to `^4.0.0-beta.100` (from `^4.0.0-beta.99`).
|
|
75
|
+
|
|
76
|
+
This is a peer-range-only change with no consumer-visible API consequences. The `beta.100` release only touches `Cron` internals (month/weekday alias normalization, day/weekday rollover, and equality/hashing), CLI error message formatting (`InvalidValue` prefixes), and `Schema.toTaggedUnion` discriminants that Confect doesn't use.
|
|
77
|
+
|
|
78
|
+
## 10.0.0-next.2
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- 35f7515: Raise the required `effect` peer version to `^4.0.0-beta.99` (from `^4.0.0-beta.98`).
|
|
83
|
+
|
|
84
|
+
This is a peer-range-only change with no consumer-visible API consequences. The `beta.99` release only touches `Graph`, CLI (`Command`/`CliConfig`/wizard mode), `Tool` cloning, Redis script eval, and multipart parser internals that Confect doesn't use.
|
|
85
|
+
|
|
86
|
+
- 2aa7541: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4 — see those versions' changelog entries.
|
|
87
|
+
|
|
3
88
|
## 10.0.0-next.1
|
|
4
89
|
|
|
5
90
|
### Patch Changes
|
|
@@ -25,6 +110,65 @@
|
|
|
25
110
|
- **CLI**: a malformed `convex.json` now fails codegen with a descriptive error instead of being silently ignored.
|
|
26
111
|
- Confect queries no longer stub the global `Date.now`. Queries run with a `Clock` whose unsafe accessors return constants, so Effect-internal reads (log timestamps, spans) never evict a query from Convex's cache; explicit time reads — `Clock.currentTimeMillis`/`currentTimeNanos` or a raw `Date.now()` call — opt the query out and evict as they honestly should.
|
|
27
112
|
|
|
113
|
+
## 9.4.0
|
|
114
|
+
|
|
115
|
+
## 9.3.0
|
|
116
|
+
|
|
117
|
+
### Minor Changes
|
|
118
|
+
|
|
119
|
+
- 16b5ad6: Add first-class paginated queries: declare one with `FunctionSpec.publicPaginatedQuery` (or `internalPaginatedQuery`) and read it with the new `usePaginatedQuery` hook from `@confect/react`.
|
|
120
|
+
|
|
121
|
+
Pass an `item` schema — the type of one element in a page — in place of `returns`, plus an optional `args` struct for your own arguments. The handler receives `paginationOpts` alongside them and forwards it to `paginate`.
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
// confect/notes.spec.ts
|
|
125
|
+
FunctionSpec.publicPaginatedQuery({
|
|
126
|
+
name: "listByAuthor",
|
|
127
|
+
args: () => Schema.Struct({ author: Schema.String }),
|
|
128
|
+
item: () => notes.Doc,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// confect/notes.impl.ts
|
|
132
|
+
({ author, paginationOpts }) =>
|
|
133
|
+
Effect.gen(function* () {
|
|
134
|
+
const reader = yield* DatabaseReader;
|
|
135
|
+
|
|
136
|
+
return yield* reader
|
|
137
|
+
.table("notes")
|
|
138
|
+
.index("by_creation_time", "desc")
|
|
139
|
+
.paginate(paginationOpts, (q) => q.eq(q.field("author"), author));
|
|
140
|
+
}).pipe(Effect.orDie);
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Declaring `paginationOpts` in `args` yourself is a type and runtime error.
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import { PaginatedQueryResult, usePaginatedQuery } from "@confect/react";
|
|
147
|
+
|
|
148
|
+
const notes = usePaginatedQuery(
|
|
149
|
+
refs.public.notes.listByAuthor,
|
|
150
|
+
{ author },
|
|
151
|
+
{ initialNumItems: 10 },
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
// `notes.results` holds the pages decoded through `item`.
|
|
155
|
+
if (PaginatedQueryResult.isCanLoadMore(notes)) {
|
|
156
|
+
notes.loadMore(10);
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The hook returns a `PaginatedQueryResult<Item, E>`. `LoadingFirstPage`, `LoadingMore`, `CanLoadMore`, and `Exhausted` all carry `results` and `isLoading`; `loadMore` lives only on `CanLoadMore`, the one state it can make progress from. A declared `error` schema surfaces as a `Failure` variant carrying the decoded error instead of throwing during render, and `Failure` carries `results` too, so the pages loaded before it can still be rendered. Without an `error` schema, `Failure` is absent from the type entirely.
|
|
161
|
+
|
|
162
|
+
`paginate` in `@confect/server` now accepts Convex's full `PaginationOptions`, so a handler's `paginationOpts` passes straight through. `@confect/react` now requires `convex` >= 1.36.0.
|
|
163
|
+
|
|
164
|
+
## 9.2.5
|
|
165
|
+
|
|
166
|
+
## 9.2.4
|
|
167
|
+
|
|
168
|
+
## 9.2.3
|
|
169
|
+
|
|
170
|
+
## 9.2.2
|
|
171
|
+
|
|
28
172
|
## 9.2.1
|
|
29
173
|
|
|
30
174
|
## 9.2.0
|
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
import type { DefaultFunctionArgs } from "convex/server";
|
|
2
|
-
import type { Schema } from "effect";
|
|
3
2
|
import * as Data from "effect/Data";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import * as PaginationOptions from "./PaginationOptions";
|
|
5
|
+
import * as PaginationResult from "./PaginationResult";
|
|
4
6
|
export type FunctionProvenance = Data.TaggedEnum<{
|
|
5
7
|
Confect: {
|
|
6
8
|
args: Schema.Codec<any, any>;
|
|
7
9
|
returns: Schema.Codec<any, any>;
|
|
8
10
|
error?: Schema.Codec<any, any>;
|
|
11
|
+
kind: ConfectKind;
|
|
9
12
|
};
|
|
10
13
|
Convex: {};
|
|
11
14
|
}>;
|
|
12
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The declaration shape of a Confect function — orthogonal to both the
|
|
17
|
+
* provenance origin (Confect vs Convex) and the function type
|
|
18
|
+
* (query/mutation/action). A `Standard` function declares its `args` and
|
|
19
|
+
* `returns` schemas directly; a `Paginated` function declares `userArgs` and
|
|
20
|
+
* `item` schemas from which the Convex-facing `args`/`returns` are composed.
|
|
21
|
+
*/
|
|
22
|
+
export type ConfectKind = Standard | Paginated;
|
|
23
|
+
export interface Standard {
|
|
24
|
+
readonly _tag: "Standard";
|
|
25
|
+
}
|
|
26
|
+
export interface Paginated<UserArgs extends AnyUserArgs = AnyUserArgs, Item extends Schema.Codec<any, any> = Schema.Codec<any, any>> {
|
|
27
|
+
readonly _tag: "Paginated";
|
|
28
|
+
/** User-declared args — no `paginationOpts`. */
|
|
29
|
+
readonly userArgs: UserArgs;
|
|
30
|
+
/** Page element schema. */
|
|
31
|
+
readonly item: Item;
|
|
32
|
+
/** Mutable array of items — the page decode target. */
|
|
33
|
+
readonly page: Schema.Codec<any, any>;
|
|
34
|
+
}
|
|
35
|
+
export interface Confect<Args extends Schema.Codec<any, any>, Returns extends Schema.Codec<any, any>, Error extends Schema.Codec<any, any> = never, Kind extends ConfectKind = ConfectKind> {
|
|
13
36
|
readonly _tag: "Confect";
|
|
14
37
|
readonly args: Args;
|
|
15
38
|
readonly returns: Returns;
|
|
16
39
|
readonly error?: Error;
|
|
40
|
+
readonly kind: Kind;
|
|
17
41
|
}
|
|
18
42
|
export interface AnyConfect extends Confect<Schema.Codec<any, any>, Schema.Codec<any, any>, Schema.Codec<any, any>> {
|
|
19
43
|
}
|
|
@@ -30,6 +54,7 @@ export declare const FunctionProvenance: {
|
|
|
30
54
|
readonly args: Schema.Codec<any, any>;
|
|
31
55
|
readonly returns: Schema.Codec<any, any>;
|
|
32
56
|
readonly error?: Schema.Codec<any, any>;
|
|
57
|
+
readonly kind: ConfectKind;
|
|
33
58
|
}, "_tag">;
|
|
34
59
|
readonly Convex: Data.TaggedEnum.ConstructorFrom<{
|
|
35
60
|
readonly _tag: "Convex";
|
|
@@ -41,6 +66,7 @@ export declare const FunctionProvenance: {
|
|
|
41
66
|
readonly args: Schema.Codec<any, any>;
|
|
42
67
|
readonly returns: Schema.Codec<any, any>;
|
|
43
68
|
readonly error?: Schema.Codec<any, any>;
|
|
69
|
+
readonly kind: ConfectKind;
|
|
44
70
|
}, {
|
|
45
71
|
readonly _tag: Tag;
|
|
46
72
|
}> | Extract<{
|
|
@@ -57,6 +83,7 @@ export declare const FunctionProvenance: {
|
|
|
57
83
|
readonly args: Schema.Codec<any, any>;
|
|
58
84
|
readonly returns: Schema.Codec<any, any>;
|
|
59
85
|
readonly error?: Schema.Codec<any, any>;
|
|
86
|
+
readonly kind: ConfectKind;
|
|
60
87
|
}) => any;
|
|
61
88
|
readonly Convex: (args: {
|
|
62
89
|
readonly _tag: "Convex";
|
|
@@ -68,6 +95,7 @@ export declare const FunctionProvenance: {
|
|
|
68
95
|
readonly args: Schema.Codec<any, any>;
|
|
69
96
|
readonly returns: Schema.Codec<any, any>;
|
|
70
97
|
readonly error?: Schema.Codec<any, any>;
|
|
98
|
+
readonly kind: ConfectKind;
|
|
71
99
|
} | {
|
|
72
100
|
readonly _tag: "Convex";
|
|
73
101
|
readonly _args: DefaultFunctionArgs;
|
|
@@ -79,6 +107,7 @@ export declare const FunctionProvenance: {
|
|
|
79
107
|
readonly args: Schema.Codec<any, any>;
|
|
80
108
|
readonly returns: Schema.Codec<any, any>;
|
|
81
109
|
readonly error?: Schema.Codec<any, any>;
|
|
110
|
+
readonly kind: ConfectKind;
|
|
82
111
|
}) => any;
|
|
83
112
|
readonly Convex: (args: {
|
|
84
113
|
readonly _tag: "Convex";
|
|
@@ -90,6 +119,7 @@ export declare const FunctionProvenance: {
|
|
|
90
119
|
readonly args: Schema.Codec<any, any>;
|
|
91
120
|
readonly returns: Schema.Codec<any, any>;
|
|
92
121
|
readonly error?: Schema.Codec<any, any>;
|
|
122
|
+
readonly kind: ConfectKind;
|
|
93
123
|
} | {
|
|
94
124
|
readonly _tag: "Convex";
|
|
95
125
|
readonly _args: DefaultFunctionArgs;
|
|
@@ -113,7 +143,48 @@ export declare const FunctionProvenance: {
|
|
|
113
143
|
* is observable via `"error" in provenance` without forcing anything; nothing
|
|
114
144
|
* relies on `Data`'s structural `Equal`/`Hash` for provenance values.
|
|
115
145
|
*/
|
|
116
|
-
export declare const Confect: <Args extends Schema.Codec<any, any>, Returns extends Schema.Codec<any, any>, Error extends Schema.Codec<any, any> = never>(args: () => Args, returns: () => Returns, error?: () => Error) => Confect<Args, Returns, Error>;
|
|
146
|
+
export declare const Confect: <Args extends Schema.Codec<any, any>, Returns extends Schema.Codec<any, any>, Error extends Schema.Codec<any, any> = never>(args: () => Args, returns: () => Returns, error?: () => Error) => Confect<Args, Returns, Error, Standard>;
|
|
147
|
+
/**
|
|
148
|
+
* Any struct-shaped, context-free schema usable as a paginated query's user
|
|
149
|
+
* args. A structural bound rather than `Schema.Struct<Schema.Struct.Fields>`
|
|
150
|
+
* because `Schema.Struct` is not covariant in its fields parameter — concrete
|
|
151
|
+
* structs do not extend `Schema.Struct<Schema.Struct.Fields>`.
|
|
152
|
+
*/
|
|
153
|
+
export interface AnyUserArgs extends Schema.Codec<any, any> {
|
|
154
|
+
readonly fields: Schema.Struct.Fields;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The composed args schema of a paginated query: the user-declared fields
|
|
158
|
+
* plus the `paginationOpts` field managed by Convex's pagination protocol.
|
|
159
|
+
*
|
|
160
|
+
* The `extends infer ... extends` conditional lets TypeScript accept the
|
|
161
|
+
* composed struct where `Schema.Codec<any, any>` is required even while
|
|
162
|
+
* `UserArgs` is an unresolved type parameter; for concrete user args it
|
|
163
|
+
* evaluates away entirely.
|
|
164
|
+
*/
|
|
165
|
+
export type PaginatedArgs<UserArgs extends AnyUserArgs> = Schema.Struct<UserArgs["fields"] & {
|
|
166
|
+
paginationOpts: typeof PaginationOptions.PaginationOptions;
|
|
167
|
+
}> extends infer ComposedArgs extends Schema.Codec<any, any> ? ComposedArgs : never;
|
|
168
|
+
/**
|
|
169
|
+
* The composed returns schema of a paginated query: a `PaginationResult` of
|
|
170
|
+
* the item schema. Same deferred-conditional device as {@link PaginatedArgs}.
|
|
171
|
+
*/
|
|
172
|
+
export type PaginatedReturns<Item extends Schema.Codec<any, any>> = PaginationResult.PaginationResult<Item> extends infer ComposedReturns extends Schema.Codec<any, any> ? ComposedReturns : never;
|
|
173
|
+
export interface ConfectPaginated<UserArgs extends AnyUserArgs, Item extends Schema.Codec<any, any>, Error extends Schema.Codec<any, any> = never> extends Confect<PaginatedArgs<UserArgs>, PaginatedReturns<Item>, Error, Paginated<UserArgs, Item>> {
|
|
174
|
+
}
|
|
175
|
+
export interface AnyConfectPaginated extends ConfectPaginated<AnyUserArgs, Schema.Codec<any, any>, Schema.Codec<any, any>> {
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Build the provenance of a paginated query from lazy schema thunks, with the
|
|
179
|
+
* same laziness contract as {@link Confect}. The user-facing schemas live on
|
|
180
|
+
* the `Paginated` kind (`kind.userArgs`, `kind.item`, `kind.page`) — the kind
|
|
181
|
+
* container is built eagerly (it is cheap) while the schemas inside it stay
|
|
182
|
+
* lazy. The composed Convex-facing `args`/`returns` are derived lazily from
|
|
183
|
+
* them: `args` spreads the user fields plus `paginationOpts`, and `returns`
|
|
184
|
+
* wraps the item in `PaginationResult`. Composition living here means the
|
|
185
|
+
* composed schemas can never drift from the stored user schemas.
|
|
186
|
+
*/
|
|
187
|
+
export declare const ConfectPaginated: <UserArgs extends AnyUserArgs, Item extends Schema.Codec<any, any>, Error extends Schema.Codec<any, any> = never>(userArgs: () => UserArgs, item: () => Item, error?: () => Error) => ConfectPaginated<UserArgs, Item, Error>;
|
|
117
188
|
export declare const Convex: <_Args extends DefaultFunctionArgs, _Returns>() => {
|
|
118
189
|
readonly _tag: "Convex";
|
|
119
190
|
readonly _args: DefaultFunctionArgs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionProvenance.d.ts","sourceRoot":"","sources":["../src/FunctionProvenance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"FunctionProvenance.d.ts","sourceRoot":"","sources":["../src/FunctionProvenance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,iBAAiB,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,UAAU,CAAC;IAC/C,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC7B,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAChC,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC/B,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B,MAAM,MAAM,IAAI,EAChB,QAAQ,MAAM,KAAK,KAClB,gBAAgB,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAkCxC,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,KAAK,SAAS,mBAAmB,EAAE,QAAQ;;oBAjNvD,mBAAmB;uBAEhB,GAAG;CAqNd,CAAC"}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { defineProperty } from "./Lazy.js";
|
|
3
|
+
import { PaginationOptions } from "./PaginationOptions.js";
|
|
4
|
+
import { PaginationResult } from "./PaginationResult.js";
|
|
3
5
|
import * as Data from "effect/Data";
|
|
4
|
-
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
5
7
|
//#region src/FunctionProvenance.ts
|
|
6
8
|
var FunctionProvenance_exports = /* @__PURE__ */ __exportAll({
|
|
7
9
|
Confect: () => Confect,
|
|
10
|
+
ConfectPaginated: () => ConfectPaginated,
|
|
8
11
|
Convex: () => Convex,
|
|
9
12
|
FunctionProvenance: () => FunctionProvenance
|
|
10
13
|
});
|
|
11
14
|
const FunctionProvenance = Data.taggedEnum();
|
|
15
|
+
const Standard = { _tag: "Standard" };
|
|
12
16
|
/**
|
|
13
17
|
* Build a `Confect` provenance from lazy schema thunks. `args`, `returns`,
|
|
14
18
|
* and `error` are exposed as sync lazy memoised getters (via {@link Lazy.defineProperty})
|
|
@@ -26,14 +30,50 @@ const FunctionProvenance = Data.taggedEnum();
|
|
|
26
30
|
* relies on `Data`'s structural `Equal`/`Hash` for provenance values.
|
|
27
31
|
*/
|
|
28
32
|
const Confect = (args, returns, error) => {
|
|
29
|
-
const provenance = {
|
|
33
|
+
const provenance = {
|
|
34
|
+
_tag: "Confect",
|
|
35
|
+
kind: Standard
|
|
36
|
+
};
|
|
30
37
|
defineProperty(provenance, "args", args);
|
|
31
38
|
defineProperty(provenance, "returns", returns);
|
|
32
39
|
if (error !== void 0) defineProperty(provenance, "error", error);
|
|
33
40
|
return provenance;
|
|
34
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Build the provenance of a paginated query from lazy schema thunks, with the
|
|
44
|
+
* same laziness contract as {@link Confect}. The user-facing schemas live on
|
|
45
|
+
* the `Paginated` kind (`kind.userArgs`, `kind.item`, `kind.page`) — the kind
|
|
46
|
+
* container is built eagerly (it is cheap) while the schemas inside it stay
|
|
47
|
+
* lazy. The composed Convex-facing `args`/`returns` are derived lazily from
|
|
48
|
+
* them: `args` spreads the user fields plus `paginationOpts`, and `returns`
|
|
49
|
+
* wraps the item in `PaginationResult`. Composition living here means the
|
|
50
|
+
* composed schemas can never drift from the stored user schemas.
|
|
51
|
+
*/
|
|
52
|
+
const ConfectPaginated = (userArgs, item, error) => {
|
|
53
|
+
const kind = { _tag: "Paginated" };
|
|
54
|
+
const paginatedKind = kind;
|
|
55
|
+
defineProperty(kind, "userArgs", userArgs);
|
|
56
|
+
defineProperty(kind, "item", item);
|
|
57
|
+
defineProperty(kind, "page", () => Schema.mutable(Schema.Array(paginatedKind.item)));
|
|
58
|
+
const provenance = {
|
|
59
|
+
_tag: "Confect",
|
|
60
|
+
kind: paginatedKind
|
|
61
|
+
};
|
|
62
|
+
const self = provenance;
|
|
63
|
+
defineProperty(provenance, "args", () => {
|
|
64
|
+
const fields = paginatedKind.userArgs.fields;
|
|
65
|
+
if ("paginationOpts" in fields) throw new globalThis.Error("A paginated query's args schema must not declare `paginationOpts` — it is added automatically from the `PaginationOptions` schema");
|
|
66
|
+
return Schema.Struct({
|
|
67
|
+
...fields,
|
|
68
|
+
paginationOpts: PaginationOptions
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
defineProperty(provenance, "returns", () => PaginationResult(paginatedKind.item));
|
|
72
|
+
if (error !== void 0) defineProperty(provenance, "error", error);
|
|
73
|
+
return self;
|
|
74
|
+
};
|
|
35
75
|
const Convex = () => FunctionProvenance.Convex({});
|
|
36
|
-
|
|
37
76
|
//#endregion
|
|
38
|
-
export { Confect, Convex, FunctionProvenance, FunctionProvenance_exports };
|
|
77
|
+
export { Confect, ConfectPaginated, Convex, FunctionProvenance, FunctionProvenance_exports };
|
|
78
|
+
|
|
39
79
|
//# sourceMappingURL=FunctionProvenance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionProvenance.js","names":[],"sources":["../src/FunctionProvenance.ts"],"sourcesContent":["import type { DefaultFunctionArgs } from \"convex/server\";\nimport
|
|
1
|
+
{"version":3,"file":"FunctionProvenance.js","names":["PaginationOptions.PaginationOptions","PaginationResult.PaginationResult"],"sources":["../src/FunctionProvenance.ts"],"sourcesContent":["import type { DefaultFunctionArgs } from \"convex/server\";\nimport * as Data from \"effect/Data\";\nimport * as Schema from \"effect/Schema\";\nimport * as Lazy from \"./Lazy\";\nimport * as PaginationOptions from \"./PaginationOptions\";\nimport * as PaginationResult from \"./PaginationResult\";\n\nexport type FunctionProvenance = Data.TaggedEnum<{\n Confect: {\n args: Schema.Codec<any, any>;\n returns: Schema.Codec<any, any>;\n error?: Schema.Codec<any, any>;\n kind: ConfectKind;\n };\n Convex: {\n /** @internal */\n _args: DefaultFunctionArgs;\n /** @internal */\n _returns: any;\n };\n}>;\n\n/**\n * The declaration shape of a Confect function — orthogonal to both the\n * provenance origin (Confect vs Convex) and the function type\n * (query/mutation/action). A `Standard` function declares its `args` and\n * `returns` schemas directly; a `Paginated` function declares `userArgs` and\n * `item` schemas from which the Convex-facing `args`/`returns` are composed.\n */\nexport type ConfectKind = Standard | Paginated;\n\nexport interface Standard {\n readonly _tag: \"Standard\";\n}\n\nexport interface Paginated<\n UserArgs extends AnyUserArgs = AnyUserArgs,\n Item extends Schema.Codec<any, any> = Schema.Codec<any, any>,\n> {\n readonly _tag: \"Paginated\";\n /** User-declared args — no `paginationOpts`. */\n readonly userArgs: UserArgs;\n /** Page element schema. */\n readonly item: Item;\n /** Mutable array of items — the page decode target. */\n readonly page: Schema.Codec<any, any>;\n}\n\nexport interface Confect<\n Args extends Schema.Codec<any, any>,\n Returns extends Schema.Codec<any, any>,\n Error extends Schema.Codec<any, any> = never,\n Kind extends ConfectKind = ConfectKind,\n> {\n readonly _tag: \"Confect\";\n readonly args: Args;\n readonly returns: Returns;\n readonly error?: Error;\n readonly kind: Kind;\n}\n\nexport interface AnyConfect extends Confect<\n Schema.Codec<any, any>,\n Schema.Codec<any, any>,\n Schema.Codec<any, any>\n> {}\n\nexport interface Convex<Args extends DefaultFunctionArgs, Returns> {\n readonly _tag: \"Convex\";\n readonly _args: Args;\n readonly _returns: Returns;\n}\n\nexport interface AnyConvex extends Convex<DefaultFunctionArgs, any> {}\n\nexport const FunctionProvenance = Data.taggedEnum<FunctionProvenance>();\n\nconst Standard: Standard = { _tag: \"Standard\" };\n\n/**\n * Build a `Confect` provenance from lazy schema thunks. `args`, `returns`,\n * and `error` are exposed as sync lazy memoised getters (via {@link Lazy.defineProperty})\n * that only evaluate their thunk on first access, mirroring how `Table`\n * defers `Fields`/`Doc`/`tableDefinition`. This keeps importing the assembled\n * `_generated/spec.ts` cheap — no `Schema.Struct(...)` / `Schema.Array(...)`\n * work runs at module load; it is deferred to the first invocation that\n * actually compiles validators or runs a codec.\n *\n * The object is built by hand rather than through `FunctionProvenance.Confect`\n * because the `Data` constructor copies its input with `Object.assign`, which\n * would force the getters at construction time and defeat the laziness.\n * `error` is only installed when an `errorThunk` is provided, so its absence\n * is observable via `\"error\" in provenance` without forcing anything; nothing\n * relies on `Data`'s structural `Equal`/`Hash` for provenance values.\n */\nexport const Confect = <\n Args extends Schema.Codec<any, any>,\n Returns extends Schema.Codec<any, any>,\n Error extends Schema.Codec<any, any> = never,\n>(\n args: () => Args,\n returns: () => Returns,\n error?: () => Error,\n): Confect<Args, Returns, Error, Standard> => {\n const provenance = { _tag: \"Confect\" as const, kind: Standard };\n\n Lazy.defineProperty(provenance, \"args\", args);\n Lazy.defineProperty(provenance, \"returns\", returns);\n if (error !== undefined) {\n Lazy.defineProperty(provenance, \"error\", error);\n }\n\n return provenance as Confect<Args, Returns, Error, Standard>;\n};\n\n/**\n * Any struct-shaped, context-free schema usable as a paginated query's user\n * args. A structural bound rather than `Schema.Struct<Schema.Struct.Fields>`\n * because `Schema.Struct` is not covariant in its fields parameter — concrete\n * structs do not extend `Schema.Struct<Schema.Struct.Fields>`.\n */\n// eslint-disable-next-line import/namespace -- oxlint's namespace resolution misses type-only exports, and `Schema` is an interface/namespace\nexport interface AnyUserArgs extends Schema.Codec<any, any> {\n readonly fields: Schema.Struct.Fields;\n}\n\n/**\n * The composed args schema of a paginated query: the user-declared fields\n * plus the `paginationOpts` field managed by Convex's pagination protocol.\n *\n * The `extends infer ... extends` conditional lets TypeScript accept the\n * composed struct where `Schema.Codec<any, any>` is required even while\n * `UserArgs` is an unresolved type parameter; for concrete user args it\n * evaluates away entirely.\n */\nexport type PaginatedArgs<UserArgs extends AnyUserArgs> =\n Schema.Struct<\n UserArgs[\"fields\"] & {\n paginationOpts: typeof PaginationOptions.PaginationOptions;\n }\n > extends infer ComposedArgs extends Schema.Codec<any, any>\n ? ComposedArgs\n : never;\n\n/**\n * The composed returns schema of a paginated query: a `PaginationResult` of\n * the item schema. Same deferred-conditional device as {@link PaginatedArgs}.\n */\nexport type PaginatedReturns<Item extends Schema.Codec<any, any>> =\n PaginationResult.PaginationResult<Item> extends infer ComposedReturns extends\n Schema.Codec<any, any>\n ? ComposedReturns\n : never;\n\nexport interface ConfectPaginated<\n UserArgs extends AnyUserArgs,\n Item extends Schema.Codec<any, any>,\n Error extends Schema.Codec<any, any> = never,\n> extends Confect<\n PaginatedArgs<UserArgs>,\n PaginatedReturns<Item>,\n Error,\n Paginated<UserArgs, Item>\n> {}\n\nexport interface AnyConfectPaginated extends ConfectPaginated<\n AnyUserArgs,\n Schema.Codec<any, any>,\n Schema.Codec<any, any>\n> {}\n\n/**\n * Build the provenance of a paginated query from lazy schema thunks, with the\n * same laziness contract as {@link Confect}. The user-facing schemas live on\n * the `Paginated` kind (`kind.userArgs`, `kind.item`, `kind.page`) — the kind\n * container is built eagerly (it is cheap) while the schemas inside it stay\n * lazy. The composed Convex-facing `args`/`returns` are derived lazily from\n * them: `args` spreads the user fields plus `paginationOpts`, and `returns`\n * wraps the item in `PaginationResult`. Composition living here means the\n * composed schemas can never drift from the stored user schemas.\n */\nexport const ConfectPaginated = <\n UserArgs extends AnyUserArgs,\n Item extends Schema.Codec<any, any>,\n Error extends Schema.Codec<any, any> = never,\n>(\n userArgs: () => UserArgs,\n item: () => Item,\n error?: () => Error,\n): ConfectPaginated<UserArgs, Item, Error> => {\n const kind = { _tag: \"Paginated\" as const };\n const paginatedKind = kind as Paginated<UserArgs, Item>;\n\n Lazy.defineProperty(kind, \"userArgs\", userArgs);\n Lazy.defineProperty(kind, \"item\", item);\n Lazy.defineProperty(kind, \"page\", () =>\n Schema.mutable(Schema.Array(paginatedKind.item)),\n );\n\n const provenance = { _tag: \"Confect\" as const, kind: paginatedKind };\n const self = provenance as ConfectPaginated<UserArgs, Item, Error>;\n\n Lazy.defineProperty(provenance, \"args\", () => {\n const fields = paginatedKind.userArgs.fields;\n if (\"paginationOpts\" in fields) {\n throw new globalThis.Error(\n \"A paginated query's args schema must not declare `paginationOpts` — \" +\n \"it is added automatically from the `PaginationOptions` schema\",\n );\n }\n return Schema.Struct({\n ...fields,\n paginationOpts: PaginationOptions.PaginationOptions,\n });\n });\n Lazy.defineProperty(provenance, \"returns\", () =>\n PaginationResult.PaginationResult(paginatedKind.item),\n );\n if (error !== undefined) {\n Lazy.defineProperty(provenance, \"error\", error);\n }\n\n return self;\n};\n\nexport const Convex = <_Args extends DefaultFunctionArgs, _Returns>() =>\n FunctionProvenance.Convex(\n {} as {\n _args: _Args;\n _returns: _Returns;\n },\n );\n"],"mappings":";;;;;;;;;;;;;AA2EA,MAAa,qBAAqB,KAAK,WAA+B;AAEtE,MAAM,WAAqB,EAAE,MAAM,WAAW;;;;;;;;;;;;;;;;;AAkB9C,MAAa,WAKX,MACA,SACA,UAC4C;CAC5C,MAAM,aAAa;EAAE,MAAM;EAAoB,MAAM;CAAS;CAE9D,eAAoB,YAAY,QAAQ,IAAI;CAC5C,eAAoB,YAAY,WAAW,OAAO;CAClD,IAAI,UAAU,KAAA,GACZ,eAAoB,YAAY,SAAS,KAAK;CAGhD,OAAO;AACT;;;;;;;;;;;AAoEA,MAAa,oBAKX,UACA,MACA,UAC4C;CAC5C,MAAM,OAAO,EAAE,MAAM,YAAqB;CAC1C,MAAM,gBAAgB;CAEtB,eAAoB,MAAM,YAAY,QAAQ;CAC9C,eAAoB,MAAM,QAAQ,IAAI;CACtC,eAAoB,MAAM,cACxB,OAAO,QAAQ,OAAO,MAAM,cAAc,IAAI,CAAC,CACjD;CAEA,MAAM,aAAa;EAAE,MAAM;EAAoB,MAAM;CAAc;CACnE,MAAM,OAAO;CAEb,eAAoB,YAAY,cAAc;EAC5C,MAAM,SAAS,cAAc,SAAS;EACtC,IAAI,oBAAoB,QACtB,MAAM,IAAI,WAAW,MACnB,mIAEF;EAEF,OAAO,OAAO,OAAO;GACnB,GAAG;GACH,gBAAgBA;EAClB,CAAC;CACH,CAAC;CACD,eAAoB,YAAY,iBAC9BC,iBAAkC,cAAc,IAAI,CACtD;CACA,IAAI,UAAU,KAAA,GACZ,eAAoB,YAAY,SAAS,KAAK;CAGhD,OAAO;AACT;AAEA,MAAa,eACX,mBAAmB,OACjB,CAAC,CAIH"}
|
package/dist/FunctionSpec.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FunctionType, FunctionVisibility, RegisteredAction, RegisteredMutation, RegisteredQuery } from "convex/server";
|
|
2
|
-
import
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
3
|
import * as FunctionProvenance from "./FunctionProvenance";
|
|
4
4
|
import * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
5
5
|
export declare const TypeId = "@confect/core/FunctionSpec";
|
|
@@ -97,6 +97,17 @@ export type WithFunctionProvenance<FunctionSpec_ extends AnyWithProps, FunctionP
|
|
|
97
97
|
export type WithoutName<FunctionSpec_ extends AnyWithProps, Name_ extends Name<FunctionSpec_>> = Exclude<FunctionSpec_, {
|
|
98
98
|
readonly name: Name_;
|
|
99
99
|
}>;
|
|
100
|
+
/**
|
|
101
|
+
* `Schema.Struct` fields that must not declare `paginationOpts`. Used to
|
|
102
|
+
* reject a user args schema that redeclares the field the paginated
|
|
103
|
+
* constructors add themselves; the check reports at the `args` thunk with an
|
|
104
|
+
* unsatisfiable type when violated.
|
|
105
|
+
*/
|
|
106
|
+
type ForbidPaginationOpts<UserArgs extends FunctionProvenance.AnyUserArgs> = "paginationOpts" extends keyof UserArgs["fields"] ? {
|
|
107
|
+
readonly fields: {
|
|
108
|
+
readonly paginationOpts: never;
|
|
109
|
+
};
|
|
110
|
+
} : unknown;
|
|
100
111
|
export declare const publicQuery: <const Name_ extends string, Args_ extends Schema.Codec<any, any>, Returns_ extends Schema.Codec<any, any>, Error_ extends Schema.Codec<any, any> = never>({ name, args, returns, error, }: {
|
|
101
112
|
name: Name_;
|
|
102
113
|
args: () => Args_;
|
|
@@ -105,7 +116,7 @@ export declare const publicQuery: <const Name_ extends string, Args_ extends Sch
|
|
|
105
116
|
}) => FunctionSpec<{
|
|
106
117
|
readonly runtime: "Convex";
|
|
107
118
|
readonly functionType: "query";
|
|
108
|
-
}, "public", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_>>;
|
|
119
|
+
}, "public", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_, FunctionProvenance.ConfectKind>>;
|
|
109
120
|
export declare const internalQuery: <const Name_ extends string, Args_ extends Schema.Codec<any, any>, Returns_ extends Schema.Codec<any, any>, Error_ extends Schema.Codec<any, any> = never>({ name, args, returns, error, }: {
|
|
110
121
|
name: Name_;
|
|
111
122
|
args: () => Args_;
|
|
@@ -114,7 +125,29 @@ export declare const internalQuery: <const Name_ extends string, Args_ extends S
|
|
|
114
125
|
}) => FunctionSpec<{
|
|
115
126
|
readonly runtime: "Convex";
|
|
116
127
|
readonly functionType: "query";
|
|
117
|
-
}, "internal", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_>>;
|
|
128
|
+
}, "internal", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_, FunctionProvenance.ConfectKind>>;
|
|
129
|
+
export declare const publicPaginatedQuery: <const Name_ extends string, Item_ extends Schema.Codec<any, any>, UserArgs_ extends FunctionProvenance.AnyUserArgs = Schema.Struct<{}>, Error_ extends Schema.Codec<any, any> = never>({ name, args, item, error, }: {
|
|
130
|
+
name: Name_;
|
|
131
|
+
/** User-declared args, without `paginationOpts` — it is added automatically. */
|
|
132
|
+
args?: (() => UserArgs_) & ForbidPaginationOpts<UserArgs_>;
|
|
133
|
+
/** The page element schema. */
|
|
134
|
+
item: () => Item_;
|
|
135
|
+
error?: () => Error_;
|
|
136
|
+
}) => FunctionSpec<{
|
|
137
|
+
readonly runtime: "Convex";
|
|
138
|
+
readonly functionType: "query";
|
|
139
|
+
}, "public", Name_, FunctionProvenance.ConfectPaginated<UserArgs_, Item_, Error_>>;
|
|
140
|
+
export declare const internalPaginatedQuery: <const Name_ extends string, Item_ extends Schema.Codec<any, any>, UserArgs_ extends FunctionProvenance.AnyUserArgs = Schema.Struct<{}>, Error_ extends Schema.Codec<any, any> = never>({ name, args, item, error, }: {
|
|
141
|
+
name: Name_;
|
|
142
|
+
/** User-declared args, without `paginationOpts` — it is added automatically. */
|
|
143
|
+
args?: (() => UserArgs_) & ForbidPaginationOpts<UserArgs_>;
|
|
144
|
+
/** The page element schema. */
|
|
145
|
+
item: () => Item_;
|
|
146
|
+
error?: () => Error_;
|
|
147
|
+
}) => FunctionSpec<{
|
|
148
|
+
readonly runtime: "Convex";
|
|
149
|
+
readonly functionType: "query";
|
|
150
|
+
}, "internal", Name_, FunctionProvenance.ConfectPaginated<UserArgs_, Item_, Error_>>;
|
|
118
151
|
export declare const publicMutation: <const Name_ extends string, Args_ extends Schema.Codec<any, any>, Returns_ extends Schema.Codec<any, any>, Error_ extends Schema.Codec<any, any> = never>({ name, args, returns, error, }: {
|
|
119
152
|
name: Name_;
|
|
120
153
|
args: () => Args_;
|
|
@@ -123,7 +156,7 @@ export declare const publicMutation: <const Name_ extends string, Args_ extends
|
|
|
123
156
|
}) => FunctionSpec<{
|
|
124
157
|
readonly runtime: "Convex";
|
|
125
158
|
readonly functionType: "mutation";
|
|
126
|
-
}, "public", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_>>;
|
|
159
|
+
}, "public", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_, FunctionProvenance.ConfectKind>>;
|
|
127
160
|
export declare const internalMutation: <const Name_ extends string, Args_ extends Schema.Codec<any, any>, Returns_ extends Schema.Codec<any, any>, Error_ extends Schema.Codec<any, any> = never>({ name, args, returns, error, }: {
|
|
128
161
|
name: Name_;
|
|
129
162
|
args: () => Args_;
|
|
@@ -132,7 +165,7 @@ export declare const internalMutation: <const Name_ extends string, Args_ extend
|
|
|
132
165
|
}) => FunctionSpec<{
|
|
133
166
|
readonly runtime: "Convex";
|
|
134
167
|
readonly functionType: "mutation";
|
|
135
|
-
}, "internal", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_>>;
|
|
168
|
+
}, "internal", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_, FunctionProvenance.ConfectKind>>;
|
|
136
169
|
export declare const publicAction: <const Name_ extends string, Args_ extends Schema.Codec<any, any>, Returns_ extends Schema.Codec<any, any>, Error_ extends Schema.Codec<any, any> = never>({ name, args, returns, error, }: {
|
|
137
170
|
name: Name_;
|
|
138
171
|
args: () => Args_;
|
|
@@ -141,7 +174,7 @@ export declare const publicAction: <const Name_ extends string, Args_ extends Sc
|
|
|
141
174
|
}) => FunctionSpec<{
|
|
142
175
|
readonly runtime: "Convex";
|
|
143
176
|
readonly functionType: "action";
|
|
144
|
-
}, "public", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_>>;
|
|
177
|
+
}, "public", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_, FunctionProvenance.ConfectKind>>;
|
|
145
178
|
export declare const internalAction: <const Name_ extends string, Args_ extends Schema.Codec<any, any>, Returns_ extends Schema.Codec<any, any>, Error_ extends Schema.Codec<any, any> = never>({ name, args, returns, error, }: {
|
|
146
179
|
name: Name_;
|
|
147
180
|
args: () => Args_;
|
|
@@ -150,7 +183,7 @@ export declare const internalAction: <const Name_ extends string, Args_ extends
|
|
|
150
183
|
}) => FunctionSpec<{
|
|
151
184
|
readonly runtime: "Convex";
|
|
152
185
|
readonly functionType: "action";
|
|
153
|
-
}, "internal", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_>>;
|
|
186
|
+
}, "internal", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_, FunctionProvenance.ConfectKind>>;
|
|
154
187
|
export declare const publicNodeAction: <const Name_ extends string, Args_ extends Schema.Codec<any, any>, Returns_ extends Schema.Codec<any, any>, Error_ extends Schema.Codec<any, any> = never>({ name, args, returns, error, }: {
|
|
155
188
|
name: Name_;
|
|
156
189
|
args: () => Args_;
|
|
@@ -159,7 +192,7 @@ export declare const publicNodeAction: <const Name_ extends string, Args_ extend
|
|
|
159
192
|
}) => FunctionSpec<{
|
|
160
193
|
readonly runtime: "Node";
|
|
161
194
|
readonly functionType: "action";
|
|
162
|
-
}, "public", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_>>;
|
|
195
|
+
}, "public", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_, FunctionProvenance.ConfectKind>>;
|
|
163
196
|
export declare const internalNodeAction: <const Name_ extends string, Args_ extends Schema.Codec<any, any>, Returns_ extends Schema.Codec<any, any>, Error_ extends Schema.Codec<any, any> = never>({ name, args, returns, error, }: {
|
|
164
197
|
name: Name_;
|
|
165
198
|
args: () => Args_;
|
|
@@ -168,7 +201,7 @@ export declare const internalNodeAction: <const Name_ extends string, Args_ exte
|
|
|
168
201
|
}) => FunctionSpec<{
|
|
169
202
|
readonly runtime: "Node";
|
|
170
203
|
readonly functionType: "action";
|
|
171
|
-
}, "internal", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_>>;
|
|
204
|
+
}, "internal", Name_, FunctionProvenance.Confect<Args_, Returns_, Error_, FunctionProvenance.ConfectKind>>;
|
|
172
205
|
type ExtractArgs<F> = F extends RegisteredQuery<any, infer A, any> ? A : F extends RegisteredMutation<any, infer A, any> ? A : F extends RegisteredAction<any, infer A, any> ? A : never;
|
|
173
206
|
type ExtractReturns<F> = F extends RegisteredQuery<any, any, infer R> ? R : F extends RegisteredMutation<any, any, infer R> ? R : F extends RegisteredAction<any, any, infer R> ? R : never;
|
|
174
207
|
export declare const convexPublicQuery: <F extends RegisteredQuery<"public", any, any>>() => <const Name_ extends string>(name: Name_) => FunctionSpec<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionSpec.d.ts","sourceRoot":"","sources":["../src/FunctionSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"FunctionSpec.d.ts","sourceRoot":"","sources":["../src/FunctionSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AAEnE,eAAO,MAAM,MAAM,+BAA+B,CAAC;AACnD,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAEnC,eAAO,MAAM,cAAc,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,YACf,CAAC;AAEnC,MAAM,WAAW,YAAY,CAC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AAM,EACzB,MAAM,KAAK;;;mFA2Bd,CAAC;AACF,eAAO,MAAM,oBAAoB,GAlC7B,CAAC,uDAKF,KAAK,CAAC,KAAK,SAAS,MAAM,EACzB,MAAM,KAAK;;;iFA+Bd,CAAC;AACF,eAAO,MAAM,sBAAsB,GAtC/B,CAAC,yDAKF,KAAK,CAAC,KAAK,SAAS,MAAM,EACzB,MAAM,KAAK;;;mFAmCd,CAAC;AACF,eAAO,MAAM,kBAAkB,GA1C3B,CAAC,qDAKF,KAAK,CAAC,KAAK,SAAS,MAAM,EACzB,MAAM,KAAK;;;iFAuCd,CAAC;AACF,eAAO,MAAM,oBAAoB,GA9C7B,CAAC,uDAKF,KAAK,CAAC,KAAK,SAAS,MAAM,EACzB,MAAM,KAAK;;;mFA2Cd,CAAC;AACF,eAAO,MAAM,sBAAsB,GAlD/B,CAAC,qDAKF,KAAK,CAAC,KAAK,SAAS,MAAM,EACzB,MAAM,KAAK;;;iFA+Cd,CAAC;AACF,eAAO,MAAM,wBAAwB,GAtDjC,CAAC,uDAKF,KAAK,CAAC,KAAK,SAAS,MAAM,EACzB,MAAM,KAAK;;;mFAmDd,CAAC"}
|
package/dist/FunctionSpec.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { Confect, Convex } from "./FunctionProvenance.js";
|
|
2
|
+
import { Confect, ConfectPaginated, Convex } from "./FunctionProvenance.js";
|
|
3
3
|
import { validateConfectFunctionIdentifier } from "./Identifier.js";
|
|
4
4
|
import { ConvexAction, ConvexMutation, ConvexQuery, NodeAction } from "./RuntimeAndFunctionType.js";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
5
6
|
import * as Predicate from "effect/Predicate";
|
|
6
|
-
|
|
7
7
|
//#region src/FunctionSpec.ts
|
|
8
8
|
var FunctionSpec_exports = /* @__PURE__ */ __exportAll({
|
|
9
9
|
TypeId: () => TypeId,
|
|
@@ -18,11 +18,13 @@ var FunctionSpec_exports = /* @__PURE__ */ __exportAll({
|
|
|
18
18
|
internalAction: () => internalAction,
|
|
19
19
|
internalMutation: () => internalMutation,
|
|
20
20
|
internalNodeAction: () => internalNodeAction,
|
|
21
|
+
internalPaginatedQuery: () => internalPaginatedQuery,
|
|
21
22
|
internalQuery: () => internalQuery,
|
|
22
23
|
isFunctionSpec: () => isFunctionSpec,
|
|
23
24
|
publicAction: () => publicAction,
|
|
24
25
|
publicMutation: () => publicMutation,
|
|
25
26
|
publicNodeAction: () => publicNodeAction,
|
|
27
|
+
publicPaginatedQuery: () => publicPaginatedQuery,
|
|
26
28
|
publicQuery: () => publicQuery
|
|
27
29
|
});
|
|
28
30
|
const TypeId = "@confect/core/FunctionSpec";
|
|
@@ -37,8 +39,19 @@ const make = (runtimeAndFunctionType, functionVisibility) => ({ name, args, retu
|
|
|
37
39
|
functionProvenance: Confect(args, returns, error)
|
|
38
40
|
});
|
|
39
41
|
};
|
|
42
|
+
const makePaginated = (runtimeAndFunctionType, functionVisibility) => ({ name, args, item, error }) => {
|
|
43
|
+
validateConfectFunctionIdentifier(name);
|
|
44
|
+
return Object.assign(Object.create(Proto), {
|
|
45
|
+
runtimeAndFunctionType,
|
|
46
|
+
functionVisibility,
|
|
47
|
+
name,
|
|
48
|
+
functionProvenance: ConfectPaginated(args ?? (() => Schema.Struct({})), item, error)
|
|
49
|
+
});
|
|
50
|
+
};
|
|
40
51
|
const publicQuery = make(ConvexQuery, "public");
|
|
41
52
|
const internalQuery = make(ConvexQuery, "internal");
|
|
53
|
+
const publicPaginatedQuery = makePaginated(ConvexQuery, "public");
|
|
54
|
+
const internalPaginatedQuery = makePaginated(ConvexQuery, "internal");
|
|
42
55
|
const publicMutation = make(ConvexMutation, "public");
|
|
43
56
|
const internalMutation = make(ConvexMutation, "internal");
|
|
44
57
|
const publicAction = make(ConvexAction, "public");
|
|
@@ -62,7 +75,7 @@ const convexPublicAction = makeConvex(ConvexAction, "public");
|
|
|
62
75
|
const convexInternalAction = makeConvex(ConvexAction, "internal");
|
|
63
76
|
const convexPublicNodeAction = makeConvex(NodeAction, "public");
|
|
64
77
|
const convexInternalNodeAction = makeConvex(NodeAction, "internal");
|
|
65
|
-
|
|
66
78
|
//#endregion
|
|
67
|
-
export { FunctionSpec_exports, TypeId, convexInternalAction, convexInternalMutation, convexInternalNodeAction, convexInternalQuery, convexPublicAction, convexPublicMutation, convexPublicNodeAction, convexPublicQuery, internalAction, internalMutation, internalNodeAction, internalQuery, isFunctionSpec, publicAction, publicMutation, publicNodeAction, publicQuery };
|
|
79
|
+
export { FunctionSpec_exports, TypeId, convexInternalAction, convexInternalMutation, convexInternalNodeAction, convexInternalQuery, convexPublicAction, convexPublicMutation, convexPublicNodeAction, convexPublicQuery, internalAction, internalMutation, internalNodeAction, internalPaginatedQuery, internalQuery, isFunctionSpec, publicAction, publicMutation, publicNodeAction, publicPaginatedQuery, publicQuery };
|
|
80
|
+
|
|
68
81
|
//# sourceMappingURL=FunctionSpec.js.map
|