@confect/core 10.0.0-next.2 → 10.0.0-next.21
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 +531 -0
- package/README.md +3 -1
- package/dist/FunctionProvenance.d.ts +155 -65
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/FunctionProvenance.js +51 -10
- package/dist/FunctionProvenance.js.map +1 -1
- package/dist/FunctionSpec.d.ts +314 -138
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +50 -13
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GenericId.d.ts.map +1 -1
- package/dist/GenericId.js +1 -1
- package/dist/GroupPath.d.ts +1 -4
- package/dist/GroupPath.d.ts.map +1 -1
- package/dist/GroupPath.js.map +1 -1
- package/dist/GroupSpec.d.ts +16 -10
- package/dist/GroupSpec.d.ts.map +1 -1
- package/dist/GroupSpec.js +34 -11
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Identifier.d.ts.map +1 -1
- package/dist/Lazy.d.ts +2 -3
- package/dist/Lazy.d.ts.map +1 -1
- package/dist/Lazy.js +2 -3
- package/dist/Lazy.js.map +1 -1
- package/dist/MiddlewareSpec.d.ts +184 -0
- package/dist/MiddlewareSpec.d.ts.map +1 -0
- package/dist/MiddlewareSpec.js +55 -0
- package/dist/MiddlewareSpec.js.map +1 -0
- package/dist/PaginationError.d.ts +14 -0
- package/dist/PaginationError.d.ts.map +1 -0
- package/dist/PaginationError.js +25 -0
- package/dist/PaginationError.js.map +1 -0
- 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.map +1 -1
- package/dist/Ref.d.ts +120 -39
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +94 -38
- package/dist/Ref.js.map +1 -1
- package/dist/Refs.d.ts +9 -4
- package/dist/Refs.d.ts.map +1 -1
- package/dist/Refs.js +3 -3
- package/dist/Refs.js.map +1 -1
- package/dist/SchemaToValidator.d.ts +99 -0
- package/dist/SchemaToValidator.d.ts.map +1 -0
- package/dist/SchemaToValidator.js +156 -0
- package/dist/SchemaToValidator.js.map +1 -0
- package/dist/Spec.d.ts +3 -2
- package/dist/Spec.d.ts.map +1 -1
- package/dist/Spec.js +1 -1
- package/dist/Spec.js.map +1 -1
- package/dist/SystemFields.d.ts +1 -1
- package/dist/SystemFields.d.ts.map +1 -1
- package/dist/SystemFields.js +2 -2
- package/dist/SystemFields.js.map +1 -1
- package/dist/Table.d.ts +74 -0
- package/dist/Table.d.ts.map +1 -0
- package/dist/Table.js +77 -0
- package/dist/Table.js.map +1 -0
- package/dist/Types.d.ts +8 -2
- package/dist/Types.d.ts.map +1 -1
- package/dist/Types.js.map +1 -1
- package/dist/UserIdentity.d.ts.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/package.json +15 -14
- package/src/FunctionProvenance.ts +186 -31
- package/src/FunctionSpec.ts +313 -85
- package/src/GroupPath.ts +1 -6
- package/src/GroupSpec.ts +125 -18
- package/src/Lazy.ts +2 -3
- package/src/MiddlewareSpec.ts +356 -0
- package/src/PaginationError.ts +72 -0
- package/src/PaginationOptions.ts +23 -0
- package/src/PaginationResult.ts +4 -0
- package/src/Ref.ts +429 -208
- package/src/Refs.ts +41 -16
- package/src/SchemaToValidator.ts +603 -0
- package/src/Spec.ts +4 -4
- package/src/SystemFields.ts +6 -9
- package/src/Table.ts +426 -0
- package/src/Types.ts +9 -3
- package/src/index.ts +5 -1
- package/dist/Registry.d.ts +0 -24
- package/dist/Registry.d.ts.map +0 -1
- package/dist/Registry.js +0 -19
- package/dist/Registry.js.map +0 -1
- package/dist/tsconfig.src.tsbuildinfo +0 -1
- package/src/Registry.ts +0 -30
|
@@ -1,110 +1,168 @@
|
|
|
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";
|
|
6
|
+
/**
|
|
7
|
+
* A field map accepted as Confect function args. Restricting each field to a
|
|
8
|
+
* context-free codec means the struct assembled from the fields can always be
|
|
9
|
+
* encoded and decoded synchronously at a Convex boundary.
|
|
10
|
+
*/
|
|
11
|
+
export type ArgsFields = {
|
|
12
|
+
readonly [key: PropertyKey]: Schema.ConstraintCodec<any, any>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A struct-shaped Confect args schema that keeps its exact field map while
|
|
16
|
+
* erasing the rest of `Schema.Struct`'s large implementation type. Decoded and
|
|
17
|
+
* encoded args are derived directly from `ArgsFields_`; keeping the runtime
|
|
18
|
+
* codec structural prevents every ref lookup from expanding the full Effect
|
|
19
|
+
* schema type.
|
|
20
|
+
*/
|
|
21
|
+
export interface ArgsSchema<ArgsFields_ extends ArgsFields> extends Schema.Codec<any, any> {
|
|
22
|
+
readonly fields: ArgsFields_;
|
|
23
|
+
}
|
|
24
|
+
/** Erased structural view used after the exact field map is no longer needed. */
|
|
25
|
+
export type AnyArgsSchema = ArgsSchema<ArgsFields>;
|
|
4
26
|
export type FunctionProvenance = Data.TaggedEnum<{
|
|
5
27
|
Confect: {
|
|
6
|
-
args:
|
|
28
|
+
args: AnyArgsSchema;
|
|
7
29
|
returns: Schema.Codec<any, any>;
|
|
8
30
|
error?: Schema.Codec<any, any>;
|
|
31
|
+
kind: ConfectKind;
|
|
32
|
+
};
|
|
33
|
+
Convex: {
|
|
34
|
+
"~args": DefaultFunctionArgs;
|
|
35
|
+
"~returns": any;
|
|
9
36
|
};
|
|
10
|
-
Convex: {};
|
|
11
37
|
}>;
|
|
12
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The declaration shape of a Confect function — orthogonal to both the
|
|
40
|
+
* provenance origin (Confect vs Convex) and the function type
|
|
41
|
+
* (query/mutation/action). A `Standard` function declares its args fields and
|
|
42
|
+
* returns schema directly; a `Paginated` function declares user-args fields
|
|
43
|
+
* and an item schema from which the Convex-facing `args`/`returns` are
|
|
44
|
+
* composed.
|
|
45
|
+
*/
|
|
46
|
+
export type ConfectKind = Standard | Paginated;
|
|
47
|
+
export interface Standard {
|
|
48
|
+
readonly _tag: "Standard";
|
|
49
|
+
}
|
|
50
|
+
export interface Paginated<UserArgsFields_ extends ArgsFields = ArgsFields, Item extends Schema.Codec<any, any> = Schema.Codec<any, any>> {
|
|
51
|
+
readonly _tag: "Paginated";
|
|
52
|
+
/** User-declared args — no `paginationOpts`. */
|
|
53
|
+
readonly userArgs: ArgsSchema<UserArgsFields_>;
|
|
54
|
+
/** Page element schema. */
|
|
55
|
+
readonly item: Item;
|
|
56
|
+
/** Mutable array of items — the page decode target. */
|
|
57
|
+
readonly page: Schema.Codec<any, any>;
|
|
58
|
+
}
|
|
59
|
+
export interface Confect<ArgsFields_ extends ArgsFields, Returns extends Schema.Codec<any, any>, Error extends Schema.Codec<any, any> = never, Kind extends ConfectKind = ConfectKind> {
|
|
13
60
|
readonly _tag: "Confect";
|
|
14
|
-
readonly
|
|
61
|
+
readonly "~ArgsFields": ArgsFields_;
|
|
62
|
+
readonly args: ArgsSchema<ArgsFields_>;
|
|
15
63
|
readonly returns: Returns;
|
|
16
64
|
readonly error?: Error;
|
|
65
|
+
readonly kind: Kind;
|
|
17
66
|
}
|
|
18
|
-
export interface AnyConfect
|
|
67
|
+
export interface AnyConfect {
|
|
68
|
+
readonly _tag: "Confect";
|
|
69
|
+
readonly args: AnyArgsSchema;
|
|
70
|
+
readonly returns: Schema.Codec<any, any>;
|
|
71
|
+
readonly error?: Schema.Codec<any, any>;
|
|
72
|
+
readonly kind: ConfectKind;
|
|
19
73
|
}
|
|
20
74
|
export interface Convex<Args extends DefaultFunctionArgs, Returns> {
|
|
21
75
|
readonly _tag: "Convex";
|
|
22
|
-
readonly
|
|
23
|
-
readonly
|
|
76
|
+
readonly "~args": Args;
|
|
77
|
+
readonly "~returns": Returns;
|
|
24
78
|
}
|
|
25
79
|
export interface AnyConvex extends Convex<DefaultFunctionArgs, any> {
|
|
26
80
|
}
|
|
27
81
|
export declare const FunctionProvenance: {
|
|
28
|
-
readonly Confect: Data.TaggedEnum.ConstructorFrom<{
|
|
29
|
-
readonly _tag: "Confect";
|
|
30
|
-
readonly args: Schema.Codec<any, any>;
|
|
31
|
-
readonly returns: Schema.Codec<any, any>;
|
|
32
|
-
readonly error?: Schema.Codec<any, any>;
|
|
33
|
-
}, "_tag">;
|
|
34
|
-
readonly Convex: Data.TaggedEnum.ConstructorFrom<{
|
|
35
|
-
readonly _tag: "Convex";
|
|
36
|
-
readonly _args: DefaultFunctionArgs;
|
|
37
|
-
readonly _returns: any;
|
|
38
|
-
}, "_tag">;
|
|
39
82
|
readonly $is: <Tag extends "Confect" | "Convex">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
40
83
|
readonly _tag: "Confect";
|
|
41
|
-
readonly args:
|
|
84
|
+
readonly args: AnyArgsSchema;
|
|
42
85
|
readonly returns: Schema.Codec<any, any>;
|
|
43
86
|
readonly error?: Schema.Codec<any, any>;
|
|
87
|
+
readonly kind: ConfectKind;
|
|
44
88
|
}, {
|
|
45
89
|
readonly _tag: Tag;
|
|
46
90
|
}> | Extract<{
|
|
47
91
|
readonly _tag: "Convex";
|
|
48
|
-
readonly
|
|
49
|
-
readonly
|
|
92
|
+
readonly "~args": DefaultFunctionArgs;
|
|
93
|
+
readonly "~returns": any;
|
|
50
94
|
}, {
|
|
51
95
|
readonly _tag: Tag;
|
|
52
96
|
}>;
|
|
53
97
|
readonly $match: {
|
|
54
|
-
<Cases extends {
|
|
55
|
-
readonly
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
readonly
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}>(cases: Cases): (value: {
|
|
98
|
+
<Cases extends { readonly [Tag in "Confect" | "Convex"]: (args: Extract<{
|
|
99
|
+
readonly _tag: "Confect";
|
|
100
|
+
readonly args: AnyArgsSchema;
|
|
101
|
+
readonly returns: Schema.Codec<any, any>;
|
|
102
|
+
readonly error?: Schema.Codec<any, any>;
|
|
103
|
+
readonly kind: ConfectKind;
|
|
104
|
+
} | {
|
|
105
|
+
readonly _tag: "Convex";
|
|
106
|
+
readonly "~args": DefaultFunctionArgs;
|
|
107
|
+
readonly "~returns": any;
|
|
108
|
+
}, {
|
|
109
|
+
readonly _tag: Tag;
|
|
110
|
+
}>) => any; }>(cases: Cases): (value: {
|
|
67
111
|
readonly _tag: "Confect";
|
|
68
|
-
readonly args:
|
|
112
|
+
readonly args: AnyArgsSchema;
|
|
69
113
|
readonly returns: Schema.Codec<any, any>;
|
|
70
114
|
readonly error?: Schema.Codec<any, any>;
|
|
115
|
+
readonly kind: ConfectKind;
|
|
71
116
|
} | {
|
|
72
117
|
readonly _tag: "Convex";
|
|
73
|
-
readonly
|
|
74
|
-
readonly
|
|
118
|
+
readonly "~args": DefaultFunctionArgs;
|
|
119
|
+
readonly "~returns": any;
|
|
75
120
|
}) => import("effect/Unify").Unify<ReturnType<Cases["Confect" | "Convex"]>>;
|
|
76
|
-
<Cases extends {
|
|
77
|
-
readonly
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
readonly
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}>(value: {
|
|
121
|
+
<Cases extends { readonly [Tag in "Confect" | "Convex"]: (args: Extract<{
|
|
122
|
+
readonly _tag: "Confect";
|
|
123
|
+
readonly args: AnyArgsSchema;
|
|
124
|
+
readonly returns: Schema.Codec<any, any>;
|
|
125
|
+
readonly error?: Schema.Codec<any, any>;
|
|
126
|
+
readonly kind: ConfectKind;
|
|
127
|
+
} | {
|
|
128
|
+
readonly _tag: "Convex";
|
|
129
|
+
readonly "~args": DefaultFunctionArgs;
|
|
130
|
+
readonly "~returns": any;
|
|
131
|
+
}, {
|
|
132
|
+
readonly _tag: Tag;
|
|
133
|
+
}>) => any; }>(value: {
|
|
89
134
|
readonly _tag: "Confect";
|
|
90
|
-
readonly args:
|
|
135
|
+
readonly args: AnyArgsSchema;
|
|
91
136
|
readonly returns: Schema.Codec<any, any>;
|
|
92
137
|
readonly error?: Schema.Codec<any, any>;
|
|
138
|
+
readonly kind: ConfectKind;
|
|
93
139
|
} | {
|
|
94
140
|
readonly _tag: "Convex";
|
|
95
|
-
readonly
|
|
96
|
-
readonly
|
|
141
|
+
readonly "~args": DefaultFunctionArgs;
|
|
142
|
+
readonly "~returns": any;
|
|
97
143
|
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Confect" | "Convex"]>>;
|
|
98
144
|
};
|
|
145
|
+
readonly Confect: Data.TaggedEnum.ConstructorFrom<{
|
|
146
|
+
readonly _tag: "Confect";
|
|
147
|
+
readonly args: AnyArgsSchema;
|
|
148
|
+
readonly returns: Schema.Codec<any, any>;
|
|
149
|
+
readonly error?: Schema.Codec<any, any>;
|
|
150
|
+
readonly kind: ConfectKind;
|
|
151
|
+
}, "_tag">;
|
|
152
|
+
readonly Convex: Data.TaggedEnum.ConstructorFrom<{
|
|
153
|
+
readonly _tag: "Convex";
|
|
154
|
+
readonly "~args": DefaultFunctionArgs;
|
|
155
|
+
readonly "~returns": any;
|
|
156
|
+
}, "_tag">;
|
|
99
157
|
};
|
|
100
158
|
/**
|
|
101
|
-
* Build a `Confect` provenance from lazy schema thunks.
|
|
102
|
-
* and `error` are exposed as sync lazy memoised getters
|
|
103
|
-
* that only evaluate their thunk on first
|
|
104
|
-
* defers `Fields`/`Doc
|
|
105
|
-
* `_generated/spec.ts` cheap — no `Schema.Struct(...)` /
|
|
106
|
-
* work runs at module load; it is deferred to the first
|
|
107
|
-
* actually compiles validators or runs a codec.
|
|
159
|
+
* Build a `Confect` provenance from lazy args-fields and schema thunks.
|
|
160
|
+
* `args`, `returns`, and `error` are exposed as sync lazy memoised getters
|
|
161
|
+
* (via {@link Lazy.defineProperty}) that only evaluate their thunk on first
|
|
162
|
+
* access, mirroring how `Table` defers `Fields`/`Doc`. This keeps importing the
|
|
163
|
+
* assembled `_generated/spec.ts` cheap — no `Schema.Struct(...)` /
|
|
164
|
+
* `Schema.Array(...)` work runs at module load; it is deferred to the first
|
|
165
|
+
* invocation that actually compiles validators or runs a codec.
|
|
108
166
|
*
|
|
109
167
|
* The object is built by hand rather than through `FunctionProvenance.Confect`
|
|
110
168
|
* because the `Data` constructor copies its input with `Object.assign`, which
|
|
@@ -113,10 +171,42 @@ export declare const FunctionProvenance: {
|
|
|
113
171
|
* is observable via `"error" in provenance` without forcing anything; nothing
|
|
114
172
|
* relies on `Data`'s structural `Equal`/`Hash` for provenance values.
|
|
115
173
|
*/
|
|
116
|
-
export declare const Confect: <
|
|
117
|
-
|
|
174
|
+
export declare const Confect: <const ArgsFields_ extends ArgsFields, Returns extends Schema.Codec<any, any>, Error extends Schema.Codec<any, any> = never>(args: () => ArgsFields_, returns: () => Returns, error?: () => Error) => Confect<ArgsFields_, Returns, Error, Standard>;
|
|
175
|
+
/**
|
|
176
|
+
* The composed args schema of a paginated query: the user-declared fields
|
|
177
|
+
* plus the `paginationOpts` field managed by Convex's pagination protocol.
|
|
178
|
+
*
|
|
179
|
+
* The fields-first representation keeps the user-declared map available for
|
|
180
|
+
* type-level composition without reconstructing it from an erased schema.
|
|
181
|
+
*/
|
|
182
|
+
export type PaginatedArgsFields<UserArgsFields extends ArgsFields> = UserArgsFields & {
|
|
183
|
+
readonly paginationOpts: typeof PaginationOptions.PaginationOptions;
|
|
184
|
+
};
|
|
185
|
+
export type PaginatedArgs<UserArgsFields extends ArgsFields> = Schema.Struct<PaginatedArgsFields<UserArgsFields>>;
|
|
186
|
+
/**
|
|
187
|
+
* The composed returns schema of a paginated query: a `PaginationResult` of
|
|
188
|
+
* the item schema. Same deferred-conditional device as {@link PaginatedArgs}.
|
|
189
|
+
*/
|
|
190
|
+
export type PaginatedReturns<Item extends Schema.Codec<any, any>> = PaginationResult.PaginationResult<Item> extends infer ComposedReturns extends Schema.Codec<any, any> ? ComposedReturns : never;
|
|
191
|
+
export interface ConfectPaginated<UserArgsFields extends ArgsFields, Item extends Schema.Codec<any, any>, Error extends Schema.Codec<any, any> = never> extends Confect<PaginatedArgsFields<UserArgsFields>, PaginatedReturns<Item>, Error, Paginated<UserArgsFields, Item>> {
|
|
192
|
+
}
|
|
193
|
+
export interface AnyConfectPaginated extends AnyConfect {
|
|
194
|
+
readonly kind: Paginated;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Build the provenance of a paginated query from lazy schema thunks, with the
|
|
198
|
+
* same laziness contract as {@link Confect}. The user-facing schemas live on
|
|
199
|
+
* the `Paginated` kind (`kind.userArgs`, `kind.item`, `kind.page`) — the kind
|
|
200
|
+
* container is built eagerly (it is cheap) while the schemas inside it stay
|
|
201
|
+
* lazy. The composed Convex-facing `args`/`returns` are derived lazily from
|
|
202
|
+
* them: `args` spreads the user fields plus `paginationOpts`, and `returns`
|
|
203
|
+
* wraps the item in `PaginationResult`. Composition living here means the
|
|
204
|
+
* composed schemas can never drift from the stored user schemas.
|
|
205
|
+
*/
|
|
206
|
+
export declare const ConfectPaginated: <const UserArgsFields_ extends ArgsFields, Item extends Schema.Codec<any, any>, Error extends Schema.Codec<any, any> = never>(userArgs: () => UserArgsFields_, item: () => Item, error?: () => Error) => ConfectPaginated<UserArgsFields_, Item, Error>;
|
|
207
|
+
export declare const Convex: <Args extends DefaultFunctionArgs, Returns>() => {
|
|
118
208
|
readonly _tag: "Convex";
|
|
119
|
-
readonly
|
|
120
|
-
readonly
|
|
209
|
+
readonly "~args": DefaultFunctionArgs;
|
|
210
|
+
readonly "~returns": any;
|
|
121
211
|
};
|
|
122
212
|
//# sourceMappingURL=FunctionProvenance.d.ts.map
|
|
@@ -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;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;CAC/D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CACzB,WAAW,SAAS,UAAU,CAC9B,SAAQ,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;CAC9B;AAED,iFAAiF;AACjF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;AAEnD,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,UAAU,CAAC;IAC/C,OAAO,EAAE;QACP,IAAI,EAAE,aAAa,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAChC,KAAK,CAAC,EAAE,MAAM,CAAC,KA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,CAAC,GAAG,EAAE,GAAG,CAAC,EACnC,KAAK,SAAS,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAC5C,SAAQ,OAAO,CACf,mBAAmB,CAAC,cAAc,CAAC,EACnC,gBAAgB,CAAC,IAAI,CAAC,EACtB,KAAK,EACL,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,CAChC;CAAG;AAEJ,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,GAC3B,KAAK,CAAC,eAAe,SAAS,UAAU,EACxC,IAAI,SAAS,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,EACnC,KAAK,SAAS,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,YAElC,MAAM,eAAe,QACzB,MAAM,IAAI,UACR,MAAM,KAAK,KAClB,gBAAgB,CAAC,eAAe,EAAE,IAAI,EAAE,KAAK,CAkC/C,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,IAAI,SAAS,mBAAmB,EAAE,OAAO;;sBArMnD,mBAAmB;yBAChB,GAAG;CA0MhB,CAAC"}
|
|
@@ -1,21 +1,26 @@
|
|
|
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";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
4
7
|
//#region src/FunctionProvenance.ts
|
|
5
8
|
var FunctionProvenance_exports = /* @__PURE__ */ __exportAll({
|
|
6
9
|
Confect: () => Confect,
|
|
10
|
+
ConfectPaginated: () => ConfectPaginated,
|
|
7
11
|
Convex: () => Convex,
|
|
8
12
|
FunctionProvenance: () => FunctionProvenance
|
|
9
13
|
});
|
|
10
14
|
const FunctionProvenance = Data.taggedEnum();
|
|
15
|
+
const Standard = { _tag: "Standard" };
|
|
11
16
|
/**
|
|
12
|
-
* Build a `Confect` provenance from lazy schema thunks.
|
|
13
|
-
* and `error` are exposed as sync lazy memoised getters
|
|
14
|
-
* that only evaluate their thunk on first
|
|
15
|
-
* defers `Fields`/`Doc
|
|
16
|
-
* `_generated/spec.ts` cheap — no `Schema.Struct(...)` /
|
|
17
|
-
* work runs at module load; it is deferred to the first
|
|
18
|
-
* actually compiles validators or runs a codec.
|
|
17
|
+
* Build a `Confect` provenance from lazy args-fields and schema thunks.
|
|
18
|
+
* `args`, `returns`, and `error` are exposed as sync lazy memoised getters
|
|
19
|
+
* (via {@link Lazy.defineProperty}) that only evaluate their thunk on first
|
|
20
|
+
* access, mirroring how `Table` defers `Fields`/`Doc`. This keeps importing the
|
|
21
|
+
* assembled `_generated/spec.ts` cheap — no `Schema.Struct(...)` /
|
|
22
|
+
* `Schema.Array(...)` work runs at module load; it is deferred to the first
|
|
23
|
+
* invocation that actually compiles validators or runs a codec.
|
|
19
24
|
*
|
|
20
25
|
* The object is built by hand rather than through `FunctionProvenance.Confect`
|
|
21
26
|
* because the `Data` constructor copies its input with `Object.assign`, which
|
|
@@ -25,14 +30,50 @@ const FunctionProvenance = Data.taggedEnum();
|
|
|
25
30
|
* relies on `Data`'s structural `Equal`/`Hash` for provenance values.
|
|
26
31
|
*/
|
|
27
32
|
const Confect = (args, returns, error) => {
|
|
28
|
-
const provenance = {
|
|
29
|
-
|
|
33
|
+
const provenance = {
|
|
34
|
+
_tag: "Confect",
|
|
35
|
+
kind: Standard
|
|
36
|
+
};
|
|
37
|
+
defineProperty(provenance, "args", () => Schema.Struct(args()));
|
|
30
38
|
defineProperty(provenance, "returns", returns);
|
|
31
39
|
if (error !== void 0) defineProperty(provenance, "error", error);
|
|
32
40
|
return provenance;
|
|
33
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", () => Schema.Struct(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
|
+
};
|
|
34
75
|
const Convex = () => FunctionProvenance.Convex({});
|
|
35
76
|
//#endregion
|
|
36
|
-
export { Confect, Convex, FunctionProvenance, FunctionProvenance_exports };
|
|
77
|
+
export { Confect, ConfectPaginated, Convex, FunctionProvenance, FunctionProvenance_exports };
|
|
37
78
|
|
|
38
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 type { Schema } from \"effect\";\nimport * as Data from \"effect/Data\";\nimport * as Lazy from \"./Lazy\";\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 };\n Convex: {\n /** @internal */\n _args: DefaultFunctionArgs;\n /** @internal */\n _returns: any;\n };\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> {\n readonly _tag: \"Confect\";\n readonly args: Args;\n readonly returns: Returns;\n readonly error?: Error;\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\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> => {\n const provenance = { _tag: \"Confect\" as const };\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>;\n};\n\nexport const Convex = <_Args extends DefaultFunctionArgs, _Returns>() =>\n FunctionProvenance.Convex(\n {} as {\n _args: _Args;\n _returns: _Returns;\n },\n );\n"],"mappings":";;;;;;;;;AA4CA,MAAa,qBAAqB,KAAK,WAA+B;;;;;;;;;;;;;;;;;AAkBtE,MAAa,WAKX,MACA,SACA,UACkC;CAClC,MAAM,aAAa,EAAE,MAAM,UAAmB;CAE9C,eAAoB,YAAY,QAAQ,IAAI;CAC5C,eAAoB,YAAY,WAAW,OAAO;CAClD,IAAI,UAAU,KAAA,GACZ,eAAoB,YAAY,SAAS,KAAK;CAGhD,OAAO;AACT;AAEA,MAAa,eACX,mBAAmB,OACjB,CAAC,CAIH"}
|
|
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\n/**\n * A field map accepted as Confect function args. Restricting each field to a\n * context-free codec means the struct assembled from the fields can always be\n * encoded and decoded synchronously at a Convex boundary.\n */\nexport type ArgsFields = {\n readonly [key: PropertyKey]: Schema.ConstraintCodec<any, any>;\n};\n\n/**\n * A struct-shaped Confect args schema that keeps its exact field map while\n * erasing the rest of `Schema.Struct`'s large implementation type. Decoded and\n * encoded args are derived directly from `ArgsFields_`; keeping the runtime\n * codec structural prevents every ref lookup from expanding the full Effect\n * schema type.\n */\nexport interface ArgsSchema<\n ArgsFields_ extends ArgsFields,\n> extends Schema.Codec<any, any> {\n readonly fields: ArgsFields_;\n}\n\n/** Erased structural view used after the exact field map is no longer needed. */\nexport type AnyArgsSchema = ArgsSchema<ArgsFields>;\n\nexport type FunctionProvenance = Data.TaggedEnum<{\n Confect: {\n args: AnyArgsSchema;\n returns: Schema.Codec<any, any>;\n error?: Schema.Codec<any, any>;\n kind: ConfectKind;\n };\n Convex: {\n \"~args\": DefaultFunctionArgs;\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 fields and\n * returns schema directly; a `Paginated` function declares user-args fields\n * and an item schema from which the Convex-facing `args`/`returns` are\n * composed.\n */\nexport type ConfectKind = Standard | Paginated;\n\nexport interface Standard {\n readonly _tag: \"Standard\";\n}\n\nexport interface Paginated<\n UserArgsFields_ extends ArgsFields = ArgsFields,\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: ArgsSchema<UserArgsFields_>;\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 ArgsFields_ extends ArgsFields,\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 \"~ArgsFields\": ArgsFields_;\n readonly args: ArgsSchema<ArgsFields_>;\n readonly returns: Returns;\n readonly error?: Error;\n readonly kind: Kind;\n}\n\nexport interface AnyConfect {\n readonly _tag: \"Confect\";\n readonly args: AnyArgsSchema;\n readonly returns: Schema.Codec<any, any>;\n readonly error?: Schema.Codec<any, any>;\n readonly kind: ConfectKind;\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 args-fields and schema thunks.\n * `args`, `returns`, and `error` are exposed as sync lazy memoised getters\n * (via {@link Lazy.defineProperty}) that only evaluate their thunk on first\n * access, mirroring how `Table` defers `Fields`/`Doc`. This keeps importing the\n * assembled `_generated/spec.ts` cheap — no `Schema.Struct(...)` /\n * `Schema.Array(...)` work runs at module load; it is deferred to the first\n * invocation that 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 const ArgsFields_ extends ArgsFields,\n Returns extends Schema.Codec<any, any>,\n Error extends Schema.Codec<any, any> = never,\n>(\n args: () => ArgsFields_,\n returns: () => Returns,\n error?: () => Error,\n): Confect<ArgsFields_, Returns, Error, Standard> => {\n const provenance = { _tag: \"Confect\" as const, kind: Standard };\n\n Lazy.defineProperty(provenance, \"args\", () => Schema.Struct(args()));\n Lazy.defineProperty(provenance, \"returns\", returns);\n if (error !== undefined) {\n Lazy.defineProperty(provenance, \"error\", error);\n }\n\n return provenance as Confect<ArgsFields_, Returns, Error, Standard>;\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 fields-first representation keeps the user-declared map available for\n * type-level composition without reconstructing it from an erased schema.\n */\nexport type PaginatedArgsFields<UserArgsFields extends ArgsFields> =\n UserArgsFields & {\n readonly paginationOpts: typeof PaginationOptions.PaginationOptions;\n };\n\nexport type PaginatedArgs<UserArgsFields extends ArgsFields> = Schema.Struct<\n PaginatedArgsFields<UserArgsFields>\n>;\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 UserArgsFields extends ArgsFields,\n Item extends Schema.Codec<any, any>,\n Error extends Schema.Codec<any, any> = never,\n> extends Confect<\n PaginatedArgsFields<UserArgsFields>,\n PaginatedReturns<Item>,\n Error,\n Paginated<UserArgsFields, Item>\n> {}\n\nexport interface AnyConfectPaginated extends AnyConfect {\n readonly kind: Paginated;\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 const UserArgsFields_ extends ArgsFields,\n Item extends Schema.Codec<any, any>,\n Error extends Schema.Codec<any, any> = never,\n>(\n userArgs: () => UserArgsFields_,\n item: () => Item,\n error?: () => Error,\n): ConfectPaginated<UserArgsFields_, Item, Error> => {\n const kind = { _tag: \"Paginated\" as const };\n const paginatedKind = kind as Paginated<UserArgsFields_, Item>;\n\n Lazy.defineProperty(kind, \"userArgs\", () => Schema.Struct(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<UserArgsFields_, 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":";;;;;;;;;;;;;AAsGA,MAAa,qBAAqB,KAAK,WAA+B;AAEtE,MAAM,WAAqB,EAAE,MAAM,WAAW;;;;;;;;;;;;;;;;;AAkB9C,MAAa,WAKX,MACA,SACA,UACmD;CACnD,MAAM,aAAa;EAAE,MAAM;EAAoB,MAAM;CAAS;CAE9D,eAAoB,YAAY,cAAc,OAAO,OAAO,KAAK,CAAC,CAAC;CACnE,eAAoB,YAAY,WAAW,OAAO;CAClD,IAAI,UAAU,KAAA,GACZ,eAAoB,YAAY,SAAS,KAAK;CAGhD,OAAO;AACT;;;;;;;;;;;AAqDA,MAAa,oBAKX,UACA,MACA,UACmD;CACnD,MAAM,OAAO,EAAE,MAAM,YAAqB;CAC1C,MAAM,gBAAgB;CAEtB,eAAoB,MAAM,kBAAkB,OAAO,OAAO,SAAS,CAAC,CAAC;CACrE,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"}
|