@confect/core 1.0.3 → 3.0.0
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 +8 -0
- package/dist/FunctionProvenance.d.ts +110 -0
- package/dist/FunctionProvenance.d.ts.map +1 -0
- package/dist/FunctionProvenance.js +19 -0
- package/dist/FunctionProvenance.js.map +1 -0
- package/dist/FunctionSpec.d.ts +108 -27
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +28 -3
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GroupSpec.d.ts +6 -6
- package/dist/Ref.d.ts +15 -18
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +6 -6
- package/dist/Ref.js.map +1 -1
- package/dist/Refs.d.ts +4 -3
- package/dist/Refs.d.ts.map +1 -1
- package/dist/Refs.js.map +1 -1
- package/dist/Spec.d.ts +4 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +6 -7
- package/src/FunctionProvenance.ts +60 -0
- package/src/FunctionSpec.ts +202 -57
- package/src/Ref.ts +27 -67
- package/src/Refs.ts +19 -6
- package/src/index.ts +1 -0
package/src/Ref.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { FunctionVisibility } from "convex/server";
|
|
2
|
-
import type { Schema } from "effect";
|
|
3
2
|
import type * as FunctionSpec from "./FunctionSpec";
|
|
4
3
|
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
5
4
|
|
|
6
5
|
export interface Ref<
|
|
7
6
|
_RuntimeAndFunctionType extends RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
8
7
|
_FunctionVisibility extends FunctionVisibility,
|
|
9
|
-
_Args
|
|
10
|
-
_Returns
|
|
8
|
+
_Args,
|
|
9
|
+
_Returns,
|
|
11
10
|
> {
|
|
12
11
|
readonly _RuntimeAndFunctionType?: _RuntimeAndFunctionType;
|
|
13
12
|
readonly _FunctionVisibility?: _FunctionVisibility;
|
|
@@ -24,43 +23,43 @@ export interface AnyPublic extends Ref<any, "public", any, any> {}
|
|
|
24
23
|
export interface AnyQuery extends Ref<
|
|
25
24
|
RuntimeAndFunctionType.AnyQuery,
|
|
26
25
|
FunctionVisibility,
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
any,
|
|
27
|
+
any
|
|
29
28
|
> {}
|
|
30
29
|
|
|
31
30
|
export interface AnyMutation extends Ref<
|
|
32
31
|
RuntimeAndFunctionType.AnyMutation,
|
|
33
32
|
FunctionVisibility,
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
any,
|
|
34
|
+
any
|
|
36
35
|
> {}
|
|
37
36
|
|
|
38
37
|
export interface AnyAction extends Ref<
|
|
39
38
|
RuntimeAndFunctionType.AnyAction,
|
|
40
39
|
FunctionVisibility,
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
any,
|
|
41
|
+
any
|
|
43
42
|
> {}
|
|
44
43
|
|
|
45
44
|
export interface AnyPublicQuery extends Ref<
|
|
46
45
|
RuntimeAndFunctionType.AnyQuery,
|
|
47
46
|
"public",
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
any,
|
|
48
|
+
any
|
|
50
49
|
> {}
|
|
51
50
|
|
|
52
51
|
export interface AnyPublicMutation extends Ref<
|
|
53
52
|
RuntimeAndFunctionType.AnyMutation,
|
|
54
53
|
"public",
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
any,
|
|
55
|
+
any
|
|
57
56
|
> {}
|
|
58
57
|
|
|
59
58
|
export interface AnyPublicAction extends Ref<
|
|
60
59
|
RuntimeAndFunctionType.AnyAction,
|
|
61
60
|
"public",
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
any,
|
|
62
|
+
any
|
|
64
63
|
> {}
|
|
65
64
|
|
|
66
65
|
export type GetRuntimeAndFunctionType<Ref_> =
|
|
@@ -130,64 +129,25 @@ export type FromFunctionSpec<F extends FunctionSpec.AnyWithProps> = Ref<
|
|
|
130
129
|
FunctionSpec.Returns<F>
|
|
131
130
|
>;
|
|
132
131
|
|
|
133
|
-
export const make = <
|
|
134
|
-
RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
135
|
-
FunctionVisibility_ extends FunctionVisibility,
|
|
136
|
-
Args_ extends Schema.Schema.AnyNoContext,
|
|
137
|
-
Returns_ extends Schema.Schema.AnyNoContext,
|
|
138
|
-
>(
|
|
132
|
+
export const make = <FunctionSpec_ extends FunctionSpec.AnyWithProps>(
|
|
139
133
|
/**
|
|
140
|
-
* This is a Convex "function name" of the format
|
|
134
|
+
* This is a Convex "function name" of the format `myGroupDir/myGroupMod:myFunc`.
|
|
141
135
|
*/
|
|
142
136
|
convexFunctionName: string,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
FunctionVisibility_,
|
|
146
|
-
string,
|
|
147
|
-
Args_,
|
|
148
|
-
Returns_
|
|
149
|
-
>,
|
|
150
|
-
): Ref<RuntimeAndFunctionType_, FunctionVisibility_, Args_, Returns_> =>
|
|
137
|
+
functionSpec: FunctionSpec_,
|
|
138
|
+
): FromFunctionSpec<FunctionSpec_> =>
|
|
151
139
|
({
|
|
152
|
-
[
|
|
140
|
+
[HiddenFunctionSpecKey]: functionSpec,
|
|
153
141
|
[HiddenConvexFunctionNameKey]: convexFunctionName,
|
|
154
|
-
}) as
|
|
155
|
-
|
|
156
|
-
const HiddenFunctionKey = "@confect/core/api/HiddenFunctionKey";
|
|
157
|
-
type HiddenFunctionKey = typeof HiddenFunctionKey;
|
|
158
|
-
type HiddenFunction<Ref_ extends Any> = FunctionSpec.FunctionSpec<
|
|
159
|
-
GetRuntimeAndFunctionType<Ref_>,
|
|
160
|
-
GetFunctionVisibility<Ref_>,
|
|
161
|
-
string,
|
|
162
|
-
Args<Ref_>,
|
|
163
|
-
Returns<Ref_>
|
|
164
|
-
>;
|
|
142
|
+
}) as FromFunctionSpec<FunctionSpec_>;
|
|
165
143
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
Returns_ extends Schema.Schema.AnyNoContext,
|
|
171
|
-
Ref_ extends Ref<
|
|
172
|
-
RuntimeAndFunctionType_,
|
|
173
|
-
FunctionVisibility_,
|
|
174
|
-
Args_,
|
|
175
|
-
Returns_
|
|
176
|
-
>,
|
|
177
|
-
>(
|
|
178
|
-
ref: Ref_,
|
|
179
|
-
): HiddenFunction<Ref_> => (ref as any)[HiddenFunctionKey];
|
|
144
|
+
const HiddenFunctionSpecKey = "@confect/core/api/HiddenFunctionSpecKey";
|
|
145
|
+
|
|
146
|
+
export const getFunctionSpec = (ref: Any): FunctionSpec.AnyWithProps =>
|
|
147
|
+
(ref as any)[HiddenFunctionSpecKey];
|
|
180
148
|
|
|
181
149
|
const HiddenConvexFunctionNameKey =
|
|
182
150
|
"@confect/core/api/HiddenConvexFunctionNameKey";
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
export const getConvexFunctionName = <
|
|
187
|
-
RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
188
|
-
FunctionVisibility_ extends FunctionVisibility,
|
|
189
|
-
Args_ extends Schema.Schema.AnyNoContext,
|
|
190
|
-
Returns_ extends Schema.Schema.AnyNoContext,
|
|
191
|
-
>(
|
|
192
|
-
ref: Ref<RuntimeAndFunctionType_, FunctionVisibility_, Args_, Returns_>,
|
|
193
|
-
): HiddenConvexFunctionName => (ref as any)[HiddenConvexFunctionNameKey];
|
|
151
|
+
|
|
152
|
+
export const getConvexFunctionName = (ref: Any): string =>
|
|
153
|
+
(ref as any)[HiddenConvexFunctionNameKey];
|
package/src/Refs.ts
CHANGED
|
@@ -38,18 +38,31 @@ type OmitEmpty<T> = {
|
|
|
38
38
|
[K in keyof T as keyof T[K] extends never ? never : K]: T[K];
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
type FunctionSpecMatchesPredicate<
|
|
42
|
+
FunctionSpec_ extends FunctionSpec.AnyWithProps,
|
|
43
|
+
Predicate extends Ref.Any,
|
|
44
|
+
> =
|
|
45
|
+
Ref.Ref<
|
|
46
|
+
FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,
|
|
47
|
+
FunctionSpec.GetFunctionVisibility<FunctionSpec_>,
|
|
48
|
+
any,
|
|
49
|
+
any
|
|
50
|
+
> extends Predicate
|
|
51
|
+
? true
|
|
52
|
+
: false;
|
|
53
|
+
|
|
41
54
|
type FilteredFunctions<
|
|
42
|
-
|
|
55
|
+
FunctionSpecs extends FunctionSpec.AnyWithProps,
|
|
43
56
|
Predicate extends Ref.Any,
|
|
44
57
|
> = {
|
|
45
|
-
[Name in FunctionSpec.Name<
|
|
46
|
-
|
|
58
|
+
[Name in FunctionSpec.Name<FunctionSpecs> as FunctionSpec.WithName<
|
|
59
|
+
FunctionSpecs,
|
|
47
60
|
Name
|
|
48
|
-
> extends infer
|
|
49
|
-
?
|
|
61
|
+
> extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps
|
|
62
|
+
? FunctionSpecMatchesPredicate<FunctionSpec_, Predicate> extends true
|
|
50
63
|
? Name
|
|
51
64
|
: never
|
|
52
|
-
: never]: FunctionSpec.WithName<
|
|
65
|
+
: never]: FunctionSpec.WithName<FunctionSpecs, Name> extends infer F extends
|
|
53
66
|
FunctionSpec.AnyWithProps
|
|
54
67
|
? Ref.FromFunctionSpec<F>
|
|
55
68
|
: never;
|
package/src/index.ts
CHANGED