@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/dist/Ref.js
CHANGED
|
@@ -3,18 +3,18 @@ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
|
3
3
|
//#region src/Ref.ts
|
|
4
4
|
var Ref_exports = /* @__PURE__ */ __exportAll({
|
|
5
5
|
getConvexFunctionName: () => getConvexFunctionName,
|
|
6
|
-
|
|
6
|
+
getFunctionSpec: () => getFunctionSpec,
|
|
7
7
|
make: () => make
|
|
8
8
|
});
|
|
9
|
-
const make = (convexFunctionName,
|
|
10
|
-
[
|
|
9
|
+
const make = (convexFunctionName, functionSpec) => ({
|
|
10
|
+
[HiddenFunctionSpecKey]: functionSpec,
|
|
11
11
|
[HiddenConvexFunctionNameKey]: convexFunctionName
|
|
12
12
|
});
|
|
13
|
-
const
|
|
14
|
-
const
|
|
13
|
+
const HiddenFunctionSpecKey = "@confect/core/api/HiddenFunctionSpecKey";
|
|
14
|
+
const getFunctionSpec = (ref) => ref[HiddenFunctionSpecKey];
|
|
15
15
|
const HiddenConvexFunctionNameKey = "@confect/core/api/HiddenConvexFunctionNameKey";
|
|
16
16
|
const getConvexFunctionName = (ref) => ref[HiddenConvexFunctionNameKey];
|
|
17
17
|
|
|
18
18
|
//#endregion
|
|
19
|
-
export { Ref_exports, getConvexFunctionName,
|
|
19
|
+
export { Ref_exports, getConvexFunctionName, getFunctionSpec, make };
|
|
20
20
|
//# sourceMappingURL=Ref.js.map
|
package/dist/Ref.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ref.js","names":[],"sources":["../src/Ref.ts"],"sourcesContent":["import type { FunctionVisibility } from \"convex/server\";\nimport type
|
|
1
|
+
{"version":3,"file":"Ref.js","names":[],"sources":["../src/Ref.ts"],"sourcesContent":["import type { FunctionVisibility } from \"convex/server\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\n\nexport interface Ref<\n _RuntimeAndFunctionType extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n _FunctionVisibility extends FunctionVisibility,\n _Args,\n _Returns,\n> {\n readonly _RuntimeAndFunctionType?: _RuntimeAndFunctionType;\n readonly _FunctionVisibility?: _FunctionVisibility;\n readonly _Args?: _Args;\n readonly _Returns?: _Returns;\n}\n\nexport interface Any extends Ref<any, any, any, any> {}\n\nexport interface AnyInternal extends Ref<any, \"internal\", any, any> {}\n\nexport interface AnyPublic extends Ref<any, \"public\", any, any> {}\n\nexport interface AnyQuery extends Ref<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n any,\n any\n> {}\n\nexport interface AnyMutation extends Ref<\n RuntimeAndFunctionType.AnyMutation,\n FunctionVisibility,\n any,\n any\n> {}\n\nexport interface AnyAction extends Ref<\n RuntimeAndFunctionType.AnyAction,\n FunctionVisibility,\n any,\n any\n> {}\n\nexport interface AnyPublicQuery extends Ref<\n RuntimeAndFunctionType.AnyQuery,\n \"public\",\n any,\n any\n> {}\n\nexport interface AnyPublicMutation extends Ref<\n RuntimeAndFunctionType.AnyMutation,\n \"public\",\n any,\n any\n> {}\n\nexport interface AnyPublicAction extends Ref<\n RuntimeAndFunctionType.AnyAction,\n \"public\",\n any,\n any\n> {}\n\nexport type GetRuntimeAndFunctionType<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns\n >\n ? RuntimeAndFunctionType_\n : never;\n\nexport type GetRuntime<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns\n >\n ? RuntimeAndFunctionType.GetRuntime<RuntimeAndFunctionType_>\n : never;\n\nexport type GetFunctionType<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns\n >\n ? RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_>\n : never;\n\nexport type GetFunctionVisibility<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer FunctionVisibility_,\n infer _Args,\n infer _Returns\n >\n ? FunctionVisibility_\n : never;\n\nexport type Args<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer Args_,\n infer _Returns\n >\n ? Args_\n : never;\n\nexport type Returns<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer _Args,\n infer Returns_\n >\n ? Returns_\n : never;\n\nexport type FromFunctionSpec<F extends FunctionSpec.AnyWithProps> = Ref<\n FunctionSpec.GetRuntimeAndFunctionType<F>,\n FunctionSpec.GetFunctionVisibility<F>,\n FunctionSpec.Args<F>,\n FunctionSpec.Returns<F>\n>;\n\nexport const make = <FunctionSpec_ extends FunctionSpec.AnyWithProps>(\n /**\n * This is a Convex \"function name\" of the format `myGroupDir/myGroupMod:myFunc`.\n */\n convexFunctionName: string,\n functionSpec: FunctionSpec_,\n): FromFunctionSpec<FunctionSpec_> =>\n ({\n [HiddenFunctionSpecKey]: functionSpec,\n [HiddenConvexFunctionNameKey]: convexFunctionName,\n }) as FromFunctionSpec<FunctionSpec_>;\n\nconst HiddenFunctionSpecKey = \"@confect/core/api/HiddenFunctionSpecKey\";\n\nexport const getFunctionSpec = (ref: Any): FunctionSpec.AnyWithProps =>\n (ref as any)[HiddenFunctionSpecKey];\n\nconst HiddenConvexFunctionNameKey =\n \"@confect/core/api/HiddenConvexFunctionNameKey\";\n\nexport const getConvexFunctionName = (ref: Any): string =>\n (ref as any)[HiddenConvexFunctionNameKey];\n"],"mappings":";;;;;;;;AAmIA,MAAa,QAIX,oBACA,kBAEC;EACE,wBAAwB;EACxB,8BAA8B;CAChC;AAEH,MAAM,wBAAwB;AAE9B,MAAa,mBAAmB,QAC7B,IAAY;AAEf,MAAM,8BACJ;AAEF,MAAa,yBAAyB,QACnC,IAAY"}
|
package/dist/Refs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AnyWithProps, Name as Name$1, WithName } from "./FunctionSpec.js";
|
|
1
|
+
import { AnyWithProps, GetFunctionVisibility, GetRuntimeAndFunctionType, Name as Name$1, WithName } from "./FunctionSpec.js";
|
|
2
2
|
import { AnyWithProps as AnyWithProps$1, Functions, GroupSpec, Groups, Name as Name$2, WithName as WithName$1 } from "./GroupSpec.js";
|
|
3
|
-
import { Any, AnyInternal, AnyPublic, FromFunctionSpec } from "./Ref.js";
|
|
3
|
+
import { Any, AnyInternal, AnyPublic, FromFunctionSpec, Ref } from "./Ref.js";
|
|
4
4
|
import { AnyWithPropsWithRuntime, Groups as Groups$1 } from "./Spec.js";
|
|
5
5
|
import { Types } from "effect";
|
|
6
6
|
|
|
@@ -11,7 +11,8 @@ declare namespace Refs_d_exports {
|
|
|
11
11
|
type Refs<ConvexSpec extends AnyWithPropsWithRuntime<"Convex">, NodeSpec extends AnyWithPropsWithRuntime<"Node"> = never, Predicate extends Any = Any> = Types.Simplify<OmitEmpty<Helper<Groups$1<ConvexSpec> | (NodeSpec extends never ? never : GroupSpec<"Node", "node", never, NodeSpec["groups"][keyof NodeSpec["groups"]]>), Predicate>>>;
|
|
12
12
|
type GroupRefs<Group extends AnyWithProps$1, Predicate extends Any> = Types.Simplify<OmitEmpty<Helper<Groups<Group>, Predicate>> & FilteredFunctions<Functions<Group>, Predicate>>;
|
|
13
13
|
type OmitEmpty<T> = { [K in keyof T as keyof T[K] extends never ? never : K]: T[K] };
|
|
14
|
-
type
|
|
14
|
+
type FunctionSpecMatchesPredicate<FunctionSpec_ extends AnyWithProps, Predicate extends Any> = Ref<GetRuntimeAndFunctionType<FunctionSpec_>, GetFunctionVisibility<FunctionSpec_>, any, any> extends Predicate ? true : false;
|
|
15
|
+
type FilteredFunctions<FunctionSpecs extends AnyWithProps, Predicate extends Any> = { [Name in Name$1<FunctionSpecs> as WithName<FunctionSpecs, Name> extends infer FunctionSpec_ extends AnyWithProps ? FunctionSpecMatchesPredicate<FunctionSpec_, Predicate> extends true ? Name : never : never]: WithName<FunctionSpecs, Name> extends infer F extends AnyWithProps ? FromFunctionSpec<F> : never };
|
|
15
16
|
type Helper<Groups extends AnyWithProps$1, Predicate extends Any> = { [GroupName in Name$2<Groups>]: WithName$1<Groups, GroupName> extends infer Group extends AnyWithProps$1 ? GroupRefs<Group, Predicate> : never };
|
|
16
17
|
declare const make: <ConvexSpec extends AnyWithPropsWithRuntime<"Convex">, NodeSpec extends AnyWithPropsWithRuntime<"Node"> = never>(convexSpec: ConvexSpec, nodeSpec?: NodeSpec) => {
|
|
17
18
|
public: Refs<ConvexSpec, NodeSpec, AnyPublic>;
|
package/dist/Refs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Refs.d.ts","names":[],"sources":["../src/Refs.ts"],"mappings":";;;;;;;;;;KAOY,IAAA,oBACS,uBAAA,6BACF,uBAAA,oCACC,GAAA,GAAU,GAAA,IAC1B,KAAA,CAAM,QAAA,CACR,SAAA,CACE,MAAA,CACI,QAAA,CAAY,UAAA,KACX,QAAA,yBAEG,SAAA,wBAIE,QAAA,iBAAyB,QAAA,eAEjC,SAAA;AAAA,KAKD,SAAA,eACW,cAAA,oBACI,GAAA,IAChB,KAAA,CAAM,QAAA,CACR,SAAA,CAAU,MAAA,CAAO,MAAA,CAAiB,KAAA,GAAQ,SAAA,KACxC,iBAAA,CAAkB,SAAA,CAAoB,KAAA,GAAQ,SAAA;AAAA,KAG7C,SAAA,oBACS,CAAA,UAAW,CAAA,CAAE,CAAA,0BAA2B,CAAA,GAAI,CAAA,CAAE,CAAA;AAAA,KAGvD,iBAAA,
|
|
1
|
+
{"version":3,"file":"Refs.d.ts","names":[],"sources":["../src/Refs.ts"],"mappings":";;;;;;;;;;KAOY,IAAA,oBACS,uBAAA,6BACF,uBAAA,oCACC,GAAA,GAAU,GAAA,IAC1B,KAAA,CAAM,QAAA,CACR,SAAA,CACE,MAAA,CACI,QAAA,CAAY,UAAA,KACX,QAAA,yBAEG,SAAA,wBAIE,QAAA,iBAAyB,QAAA,eAEjC,SAAA;AAAA,KAKD,SAAA,eACW,cAAA,oBACI,GAAA,IAChB,KAAA,CAAM,QAAA,CACR,SAAA,CAAU,MAAA,CAAO,MAAA,CAAiB,KAAA,GAAQ,SAAA,KACxC,iBAAA,CAAkB,SAAA,CAAoB,KAAA,GAAQ,SAAA;AAAA,KAG7C,SAAA,oBACS,CAAA,UAAW,CAAA,CAAE,CAAA,0BAA2B,CAAA,GAAI,CAAA,CAAE,CAAA;AAAA,KAGvD,4BAAA,uBACmB,YAAA,oBACJ,GAAA,IAElB,GAAA,CACE,yBAAA,CAAuC,aAAA,GACvC,qBAAA,CAAmC,aAAA,qBAG3B,SAAA;AAAA,KAIP,iBAAA,uBACmB,YAAA,oBACJ,GAAA,eAET,MAAA,CAAkB,aAAA,KAAkB,QAAA,CAC3C,aAAA,EACA,IAAA,sCACoC,YAAA,GAClC,4BAAA,CAA6B,aAAA,EAAe,SAAA,iBAC1C,IAAA,mBAEM,QAAA,CAAsB,aAAA,EAAe,IAAA,0BAC/C,YAAA,GACE,gBAAA,CAAqB,CAAA;AAAA,KAItB,MAAA,gBACY,cAAA,oBACG,GAAA,oBAEJ,MAAA,CAAe,MAAA,IAAU,UAAA,CACrC,MAAA,EACA,SAAA,8BAC4B,cAAA,GAC1B,SAAA,CAAU,KAAA,EAAO,SAAA;AAAA,cAUV,IAAA,sBACQ,uBAAA,6BACF,uBAAA,kBAEjB,UAAA,EAAY,UAAA,EACZ,QAAA,GAAW,QAAA;EAEX,MAAA,EAAQ,IAAA,CAAK,UAAA,EAAY,QAAA,EAAU,SAAA;EACnC,QAAA,EAAU,IAAA,CAAK,UAAA,EAAY,QAAA,EAAU,WAAA;AAAA"}
|
package/dist/Refs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Refs.js","names":["GroupSpec.makeNode","Ref.make","Ref.getConvexFunctionName"],"sources":["../src/Refs.ts"],"sourcesContent":["import type { Types } from \"effect\";\nimport { Array, pipe, Record } from \"effect\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport * as GroupSpec from \"./GroupSpec\";\nimport * as Ref from \"./Ref\";\nimport type * as Spec from \"./Spec\";\n\nexport type Refs<\n ConvexSpec extends Spec.AnyWithPropsWithRuntime<\"Convex\">,\n NodeSpec extends Spec.AnyWithPropsWithRuntime<\"Node\"> = never,\n Predicate extends Ref.Any = Ref.Any,\n> = Types.Simplify<\n OmitEmpty<\n Helper<\n | Spec.Groups<ConvexSpec>\n | (NodeSpec extends never\n ? never\n : GroupSpec.GroupSpec<\n \"Node\",\n \"node\",\n never,\n NodeSpec[\"groups\"][keyof NodeSpec[\"groups\"]]\n >),\n Predicate\n >\n >\n>;\n\ntype GroupRefs<\n Group extends GroupSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = Types.Simplify<\n OmitEmpty<Helper<GroupSpec.Groups<Group>, Predicate>> &\n FilteredFunctions<GroupSpec.Functions<Group>, Predicate>\n>;\n\ntype OmitEmpty<T> = {\n [K in keyof T as keyof T[K] extends never ? never : K]: T[K];\n};\n\ntype FilteredFunctions<\n
|
|
1
|
+
{"version":3,"file":"Refs.js","names":["GroupSpec.makeNode","Ref.make","Ref.getConvexFunctionName"],"sources":["../src/Refs.ts"],"sourcesContent":["import type { Types } from \"effect\";\nimport { Array, pipe, Record } from \"effect\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport * as GroupSpec from \"./GroupSpec\";\nimport * as Ref from \"./Ref\";\nimport type * as Spec from \"./Spec\";\n\nexport type Refs<\n ConvexSpec extends Spec.AnyWithPropsWithRuntime<\"Convex\">,\n NodeSpec extends Spec.AnyWithPropsWithRuntime<\"Node\"> = never,\n Predicate extends Ref.Any = Ref.Any,\n> = Types.Simplify<\n OmitEmpty<\n Helper<\n | Spec.Groups<ConvexSpec>\n | (NodeSpec extends never\n ? never\n : GroupSpec.GroupSpec<\n \"Node\",\n \"node\",\n never,\n NodeSpec[\"groups\"][keyof NodeSpec[\"groups\"]]\n >),\n Predicate\n >\n >\n>;\n\ntype GroupRefs<\n Group extends GroupSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = Types.Simplify<\n OmitEmpty<Helper<GroupSpec.Groups<Group>, Predicate>> &\n FilteredFunctions<GroupSpec.Functions<Group>, Predicate>\n>;\n\ntype OmitEmpty<T> = {\n [K in keyof T as keyof T[K] extends never ? never : K]: T[K];\n};\n\ntype FunctionSpecMatchesPredicate<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> =\n Ref.Ref<\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n any,\n any\n > extends Predicate\n ? true\n : false;\n\ntype FilteredFunctions<\n FunctionSpecs extends FunctionSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = {\n [Name in FunctionSpec.Name<FunctionSpecs> as FunctionSpec.WithName<\n FunctionSpecs,\n Name\n > extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps\n ? FunctionSpecMatchesPredicate<FunctionSpec_, Predicate> extends true\n ? Name\n : never\n : never]: FunctionSpec.WithName<FunctionSpecs, Name> extends infer F extends\n FunctionSpec.AnyWithProps\n ? Ref.FromFunctionSpec<F>\n : never;\n};\n\ntype Helper<\n Groups extends GroupSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = {\n [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<\n Groups,\n GroupName\n > extends infer Group extends GroupSpec.AnyWithProps\n ? GroupRefs<Group, Predicate>\n : never;\n};\n\ntype Any =\n | {\n readonly [key: string]: Any;\n }\n | Ref.Any;\n\nexport const make = <\n ConvexSpec extends Spec.AnyWithPropsWithRuntime<\"Convex\">,\n NodeSpec extends Spec.AnyWithPropsWithRuntime<\"Node\"> = never,\n>(\n convexSpec: ConvexSpec,\n nodeSpec?: NodeSpec,\n): {\n public: Refs<ConvexSpec, NodeSpec, Ref.AnyPublic>;\n internal: Refs<ConvexSpec, NodeSpec, Ref.AnyInternal>;\n} => {\n const nodeGroup = nodeSpec\n ? Array.reduce(\n Record.values(nodeSpec.groups),\n GroupSpec.makeNode(\"node\"),\n (nodeGroupSpec, group) => nodeGroupSpec.addGroup(group),\n )\n : null;\n\n const groups = nodeGroup\n ? { ...convexSpec.groups, node: nodeGroup }\n : convexSpec.groups;\n const refs = makeHelper(groups);\n return {\n public: refs as Refs<ConvexSpec, NodeSpec, Ref.AnyPublic>,\n internal: refs as Refs<ConvexSpec, NodeSpec, Ref.AnyInternal>,\n };\n};\n\nconst makeHelper = (\n groups: Record.ReadonlyRecord<string, GroupSpec.Any>,\n groupPath: string | null = null,\n): Any =>\n pipe(\n groups as Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>,\n Record.map((group) => {\n const currentGroupPath = groupPath\n ? `${groupPath}/${group.name}`\n : group.name;\n\n return Record.union(\n makeHelper(group.groups, currentGroupPath),\n Record.map(group.functions, (function_) =>\n Ref.make(`${currentGroupPath}:${function_.name}`, function_),\n ),\n (_subGroup, _function) => {\n throw new Error(\n `Group and function at same level have same name ('${Ref.getConvexFunctionName(_function)}')`,\n );\n },\n );\n }),\n );\n"],"mappings":";;;;;;;AAwFA,MAAa,QAIX,YACA,aAIG;CACH,MAAM,YAAY,WACd,MAAM,OACJ,OAAO,OAAO,SAAS,OAAO,EAC9BA,SAAmB,OAAO,GACzB,eAAe,UAAU,cAAc,SAAS,MAAM,CACxD,GACD;CAKJ,MAAM,OAAO,WAHE,YACX;EAAE,GAAG,WAAW;EAAQ,MAAM;EAAW,GACzC,WAAW,OACgB;AAC/B,QAAO;EACL,QAAQ;EACR,UAAU;EACX;;AAGH,MAAM,cACJ,QACA,YAA2B,SAE3B,KACE,QACA,OAAO,KAAK,UAAU;CACpB,MAAM,mBAAmB,YACrB,GAAG,UAAU,GAAG,MAAM,SACtB,MAAM;AAEV,QAAO,OAAO,MACZ,WAAW,MAAM,QAAQ,iBAAiB,EAC1C,OAAO,IAAI,MAAM,YAAY,cAC3BC,OAAS,GAAG,iBAAiB,GAAG,UAAU,QAAQ,UAAU,CAC7D,GACA,WAAW,cAAc;AACxB,QAAM,IAAI,MACR,qDAAqDC,sBAA0B,UAAU,CAAC,IAC3F;GAEJ;EACD,CACH"}
|
package/dist/Spec.d.ts
CHANGED
|
@@ -10,17 +10,17 @@ type TypeId = typeof TypeId;
|
|
|
10
10
|
declare const isSpec: (u: unknown) => u is AnyWithProps;
|
|
11
11
|
declare const isConvexSpec: (u: unknown) => u is AnyWithPropsWithRuntime<"Convex">;
|
|
12
12
|
declare const isNodeSpec: (u: unknown) => u is AnyWithPropsWithRuntime<"Node">;
|
|
13
|
-
interface Spec<Runtime$
|
|
13
|
+
interface Spec<Runtime$2 extends Runtime, Groups_ extends AnyWithPropsWithRuntime$1<Runtime$2> = never> {
|
|
14
14
|
readonly [TypeId]: TypeId;
|
|
15
|
-
readonly runtime: Runtime$
|
|
15
|
+
readonly runtime: Runtime$2;
|
|
16
16
|
readonly groups: { [GroupName in Name<Groups_>]: WithName<Groups_, GroupName> };
|
|
17
|
-
add<Group extends AnyWithPropsWithRuntime$1<Runtime$
|
|
17
|
+
add<Group extends AnyWithPropsWithRuntime$1<Runtime$2>>(group: Group): Spec<Runtime$2, Groups_ | Group>;
|
|
18
18
|
}
|
|
19
19
|
interface Any {
|
|
20
20
|
readonly [TypeId]: TypeId;
|
|
21
21
|
}
|
|
22
22
|
interface AnyWithProps extends Spec<Runtime, AnyWithProps$1> {}
|
|
23
|
-
interface AnyWithPropsWithRuntime<Runtime$
|
|
23
|
+
interface AnyWithPropsWithRuntime<Runtime$1 extends Runtime> extends Spec<Runtime$1, AnyWithPropsWithRuntime$1<Runtime$1>> {}
|
|
24
24
|
type Groups<Spec_ extends AnyWithProps> = Spec_["groups"][keyof Spec_["groups"]];
|
|
25
25
|
declare const make: () => Spec<"Convex">;
|
|
26
26
|
declare const makeNode: () => Spec<"Node">;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FunctionProvenance_d_exports } from "./FunctionProvenance.js";
|
|
1
2
|
import { RuntimeAndFunctionType_d_exports } from "./RuntimeAndFunctionType.js";
|
|
2
3
|
import { FunctionSpec_d_exports } from "./FunctionSpec.js";
|
|
3
4
|
import { GenericId_d_exports } from "./GenericId.js";
|
|
@@ -10,4 +11,4 @@ import { Refs_d_exports } from "./Refs.js";
|
|
|
10
11
|
import { SystemFields_d_exports } from "./SystemFields.js";
|
|
11
12
|
import { Types_d_exports } from "./Types.js";
|
|
12
13
|
import { UserIdentity_d_exports } from "./UserIdentity.js";
|
|
13
|
-
export { FunctionSpec_d_exports as FunctionSpec, GenericId_d_exports as GenericId, GroupPath_d_exports as GroupPath, GroupSpec_d_exports as GroupSpec, PaginationResult_d_exports as PaginationResult, Ref_d_exports as Ref, Refs_d_exports as Refs, RuntimeAndFunctionType_d_exports as RuntimeAndFunctionType, Spec_d_exports as Spec, SystemFields_d_exports as SystemFields, Types_d_exports as Types, UserIdentity_d_exports as UserIdentity };
|
|
14
|
+
export { FunctionProvenance_d_exports as FunctionProvenance, FunctionSpec_d_exports as FunctionSpec, GenericId_d_exports as GenericId, GroupPath_d_exports as GroupPath, GroupSpec_d_exports as GroupSpec, PaginationResult_d_exports as PaginationResult, Ref_d_exports as Ref, Refs_d_exports as Refs, RuntimeAndFunctionType_d_exports as RuntimeAndFunctionType, Spec_d_exports as Spec, SystemFields_d_exports as SystemFields, Types_d_exports as Types, UserIdentity_d_exports as UserIdentity };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FunctionProvenance_exports } from "./FunctionProvenance.js";
|
|
1
2
|
import { RuntimeAndFunctionType_exports } from "./RuntimeAndFunctionType.js";
|
|
2
3
|
import { FunctionSpec_exports } from "./FunctionSpec.js";
|
|
3
4
|
import { GenericId_exports } from "./GenericId.js";
|
|
@@ -11,4 +12,4 @@ import { SystemFields_exports } from "./SystemFields.js";
|
|
|
11
12
|
import { Types_exports } from "./Types.js";
|
|
12
13
|
import { UserIdentity_exports } from "./UserIdentity.js";
|
|
13
14
|
|
|
14
|
-
export { FunctionSpec_exports as FunctionSpec, GenericId_exports as GenericId, GroupPath_exports as GroupPath, GroupSpec_exports as GroupSpec, PaginationResult_exports as PaginationResult, Ref_exports as Ref, Refs_exports as Refs, RuntimeAndFunctionType_exports as RuntimeAndFunctionType, Spec_exports as Spec, SystemFields_exports as SystemFields, Types_exports as Types, UserIdentity_exports as UserIdentity };
|
|
15
|
+
export { FunctionProvenance_exports as FunctionProvenance, FunctionSpec_exports as FunctionSpec, GenericId_exports as GenericId, GroupPath_exports as GroupPath, GroupSpec_exports as GroupSpec, PaginationResult_exports as PaginationResult, Ref_exports as Ref, Refs_exports as Refs, RuntimeAndFunctionType_exports as RuntimeAndFunctionType, Spec_exports as Spec, SystemFields_exports as SystemFields, Types_exports as Types, UserIdentity_exports as UserIdentity };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@confect/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Shared specs and schemas used by all Confect packages",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,17 +40,16 @@
|
|
|
40
40
|
"license": "ISC",
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@ark/attest": "0.56.0",
|
|
43
|
-
"@effect/language-service": "0.73.1",
|
|
44
43
|
"@effect/vitest": "0.27.0",
|
|
45
|
-
"@eslint/js": "
|
|
46
|
-
"@types/node": "25.
|
|
47
|
-
"effect": "3.19.
|
|
48
|
-
"eslint": "
|
|
44
|
+
"@eslint/js": "10.0.1",
|
|
45
|
+
"@types/node": "25.3.3",
|
|
46
|
+
"effect": "3.19.19",
|
|
47
|
+
"eslint": "10.0.2",
|
|
49
48
|
"prettier": "3.8.1",
|
|
50
49
|
"tsdown": "0.20.3",
|
|
51
50
|
"tsx": "^4.21.0",
|
|
52
51
|
"typescript": "5.9.3",
|
|
53
|
-
"typescript-eslint": "8.
|
|
52
|
+
"typescript-eslint": "8.56.1",
|
|
54
53
|
"vitest": "3.2.4"
|
|
55
54
|
},
|
|
56
55
|
"peerDependencies": {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { DefaultFunctionArgs } from "convex/server";
|
|
2
|
+
import type { Schema } from "effect";
|
|
3
|
+
import { Data } from "effect";
|
|
4
|
+
|
|
5
|
+
export type FunctionProvenance = Data.TaggedEnum<{
|
|
6
|
+
Confect: {
|
|
7
|
+
args: Schema.Schema.AnyNoContext;
|
|
8
|
+
returns: Schema.Schema.AnyNoContext;
|
|
9
|
+
};
|
|
10
|
+
Convex: {
|
|
11
|
+
/** @internal */
|
|
12
|
+
_args: DefaultFunctionArgs;
|
|
13
|
+
/** @internal */
|
|
14
|
+
_returns: any;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
17
|
+
|
|
18
|
+
export interface Confect<
|
|
19
|
+
Args extends Schema.Schema.AnyNoContext,
|
|
20
|
+
Returns extends Schema.Schema.AnyNoContext,
|
|
21
|
+
> {
|
|
22
|
+
readonly _tag: "Confect";
|
|
23
|
+
readonly args: Args;
|
|
24
|
+
readonly returns: Returns;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface AnyConfect extends Confect<
|
|
28
|
+
Schema.Schema.AnyNoContext,
|
|
29
|
+
Schema.Schema.AnyNoContext
|
|
30
|
+
> {}
|
|
31
|
+
|
|
32
|
+
export interface Convex<Args extends DefaultFunctionArgs, Returns> {
|
|
33
|
+
readonly _tag: "Convex";
|
|
34
|
+
readonly _args: Args;
|
|
35
|
+
readonly _returns: Returns;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface AnyConvex extends Convex<DefaultFunctionArgs, any> {}
|
|
39
|
+
|
|
40
|
+
export const FunctionProvenance = Data.taggedEnum<FunctionProvenance>();
|
|
41
|
+
|
|
42
|
+
export const Confect = <
|
|
43
|
+
Args extends Schema.Schema.AnyNoContext,
|
|
44
|
+
Returns extends Schema.Schema.AnyNoContext,
|
|
45
|
+
>(
|
|
46
|
+
args: Args,
|
|
47
|
+
returns: Returns,
|
|
48
|
+
) =>
|
|
49
|
+
FunctionProvenance.Confect({
|
|
50
|
+
args,
|
|
51
|
+
returns,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const Convex = <_Args extends DefaultFunctionArgs, _Returns>() =>
|
|
55
|
+
FunctionProvenance.Convex(
|
|
56
|
+
{} as {
|
|
57
|
+
_args: _Args;
|
|
58
|
+
_returns: _Returns;
|
|
59
|
+
},
|
|
60
|
+
);
|
package/src/FunctionSpec.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
} from "convex/server";
|
|
8
8
|
import type { Schema } from "effect";
|
|
9
9
|
import { Predicate } from "effect";
|
|
10
|
+
import * as FunctionProvenance from "./FunctionProvenance";
|
|
10
11
|
import { validateConfectFunctionIdentifier } from "./internal/utils";
|
|
11
12
|
import * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
12
13
|
|
|
@@ -20,15 +21,13 @@ export interface FunctionSpec<
|
|
|
20
21
|
RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
21
22
|
FunctionVisibility_ extends FunctionVisibility,
|
|
22
23
|
Name_ extends string,
|
|
23
|
-
|
|
24
|
-
Returns_ extends Schema.Schema.AnyNoContext,
|
|
24
|
+
FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,
|
|
25
25
|
> {
|
|
26
26
|
readonly [TypeId]: TypeId;
|
|
27
27
|
readonly runtimeAndFunctionType: RuntimeAndFunctionType_;
|
|
28
28
|
readonly functionVisibility: FunctionVisibility_;
|
|
29
29
|
readonly name: Name_;
|
|
30
|
-
readonly
|
|
31
|
-
readonly returns: Returns_;
|
|
30
|
+
readonly functionProvenance: FunctionProvenance_;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
export interface Any {
|
|
@@ -39,8 +38,21 @@ export interface AnyWithProps extends FunctionSpec<
|
|
|
39
38
|
RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
40
39
|
FunctionVisibility,
|
|
41
40
|
string,
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
FunctionProvenance.FunctionProvenance
|
|
42
|
+
> {}
|
|
43
|
+
|
|
44
|
+
export interface AnyConfect extends FunctionSpec<
|
|
45
|
+
RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
46
|
+
FunctionVisibility,
|
|
47
|
+
string,
|
|
48
|
+
FunctionProvenance.AnyConfect
|
|
49
|
+
> {}
|
|
50
|
+
|
|
51
|
+
export interface AnyConvex extends FunctionSpec<
|
|
52
|
+
RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
53
|
+
FunctionVisibility,
|
|
54
|
+
string,
|
|
55
|
+
FunctionProvenance.AnyConvex
|
|
44
56
|
> {}
|
|
45
57
|
|
|
46
58
|
export interface AnyWithPropsWithRuntime<
|
|
@@ -49,8 +61,7 @@ export interface AnyWithPropsWithRuntime<
|
|
|
49
61
|
RuntimeAndFunctionType.WithRuntime<Runtime>,
|
|
50
62
|
FunctionVisibility,
|
|
51
63
|
string,
|
|
52
|
-
|
|
53
|
-
Schema.Schema.AnyNoContext
|
|
64
|
+
FunctionProvenance.FunctionProvenance
|
|
54
65
|
> {}
|
|
55
66
|
|
|
56
67
|
export interface AnyWithPropsWithFunctionType<
|
|
@@ -59,74 +70,114 @@ export interface AnyWithPropsWithFunctionType<
|
|
|
59
70
|
RuntimeAndFunctionType_,
|
|
60
71
|
FunctionVisibility,
|
|
61
72
|
string,
|
|
62
|
-
|
|
63
|
-
Schema.Schema.AnyNoContext
|
|
73
|
+
FunctionProvenance.FunctionProvenance
|
|
64
74
|
> {}
|
|
65
75
|
|
|
66
|
-
export
|
|
67
|
-
|
|
76
|
+
export interface AnyWithPropsWithFunctionProvenance<
|
|
77
|
+
FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,
|
|
78
|
+
> extends FunctionSpec<
|
|
79
|
+
RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
80
|
+
FunctionVisibility,
|
|
81
|
+
string,
|
|
82
|
+
FunctionProvenance_
|
|
83
|
+
> {}
|
|
68
84
|
|
|
69
|
-
export type
|
|
70
|
-
|
|
85
|
+
export type GetRuntimeAndFunctionType<FunctionSpec_ extends AnyWithProps> =
|
|
86
|
+
FunctionSpec_["runtimeAndFunctionType"];
|
|
87
|
+
|
|
88
|
+
export type GetFunctionVisibility<FunctionSpec_ extends AnyWithProps> =
|
|
89
|
+
FunctionSpec_["functionVisibility"];
|
|
90
|
+
|
|
91
|
+
export type Name<FunctionSpec_ extends AnyWithProps> = FunctionSpec_["name"];
|
|
92
|
+
|
|
93
|
+
export type Args<FunctionSpec_ extends AnyWithProps> = FunctionSpec_ extends {
|
|
94
|
+
functionProvenance: {
|
|
95
|
+
_tag: "Confect";
|
|
96
|
+
args: infer ArgsSchema_ extends Schema.Schema.AnyNoContext;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
? ArgsSchema_["Type"]
|
|
100
|
+
: FunctionSpec_ extends {
|
|
101
|
+
functionProvenance: { _tag: "Convex"; _args: infer Args_ };
|
|
102
|
+
}
|
|
103
|
+
? Args_
|
|
104
|
+
: never;
|
|
71
105
|
|
|
72
|
-
export type
|
|
106
|
+
export type Returns<FunctionSpec_ extends AnyWithProps> =
|
|
107
|
+
FunctionSpec_ extends {
|
|
108
|
+
functionProvenance: {
|
|
109
|
+
_tag: "Confect";
|
|
110
|
+
returns: infer ReturnsSchema_ extends Schema.Schema.AnyNoContext;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
? ReturnsSchema_["Type"]
|
|
114
|
+
: FunctionSpec_ extends {
|
|
115
|
+
functionProvenance: { _tag: "Convex"; _returns: infer Returns_ };
|
|
116
|
+
}
|
|
117
|
+
? Awaited<Returns_>
|
|
118
|
+
: never;
|
|
73
119
|
|
|
74
|
-
export type
|
|
120
|
+
export type EncodedArgs<FunctionSpec_ extends AnyWithProps> =
|
|
121
|
+
FunctionSpec_ extends {
|
|
122
|
+
functionProvenance: {
|
|
123
|
+
_tag: "Confect";
|
|
124
|
+
args: infer ArgsSchema_ extends Schema.Schema.AnyNoContext;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
? ArgsSchema_["Encoded"]
|
|
128
|
+
: FunctionSpec_ extends {
|
|
129
|
+
functionProvenance: { _tag: "Convex"; _args: infer Args_ };
|
|
130
|
+
}
|
|
131
|
+
? Args_
|
|
132
|
+
: never;
|
|
75
133
|
|
|
76
|
-
export type
|
|
134
|
+
export type EncodedReturns<FunctionSpec_ extends AnyWithProps> =
|
|
135
|
+
FunctionSpec_ extends {
|
|
136
|
+
functionProvenance: {
|
|
137
|
+
_tag: "Confect";
|
|
138
|
+
returns: infer ReturnsSchema_ extends Schema.Schema.AnyNoContext;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
? ReturnsSchema_["Encoded"]
|
|
142
|
+
: FunctionSpec_ extends {
|
|
143
|
+
functionProvenance: { _tag: "Convex"; _returns: infer Returns_ };
|
|
144
|
+
}
|
|
145
|
+
? Returns_
|
|
146
|
+
: never;
|
|
77
147
|
|
|
78
148
|
export type WithName<
|
|
79
|
-
|
|
149
|
+
FunctionSpec_ extends AnyWithProps,
|
|
80
150
|
Name_ extends string,
|
|
81
|
-
> = Extract<
|
|
151
|
+
> = Extract<FunctionSpec_, { readonly name: Name_ }>;
|
|
82
152
|
|
|
83
153
|
export type WithRuntimeAndFunctionType<
|
|
84
|
-
|
|
154
|
+
FunctionSpec_ extends AnyWithProps,
|
|
85
155
|
RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
86
156
|
> = Extract<
|
|
87
|
-
|
|
157
|
+
FunctionSpec_,
|
|
88
158
|
{ readonly runtimeAndFunctionType: RuntimeAndFunctionType_ }
|
|
89
159
|
>;
|
|
90
160
|
|
|
91
161
|
export type WithFunctionType<
|
|
92
|
-
|
|
162
|
+
FunctionSpec_ extends AnyWithProps,
|
|
93
163
|
FunctionType_ extends FunctionType,
|
|
94
164
|
> = Extract<
|
|
95
|
-
|
|
165
|
+
FunctionSpec_,
|
|
96
166
|
{ readonly runtimeAndFunctionType: { readonly functionType: FunctionType_ } }
|
|
97
167
|
>;
|
|
98
168
|
|
|
169
|
+
export type WithFunctionProvenance<
|
|
170
|
+
FunctionSpec_ extends AnyWithProps,
|
|
171
|
+
FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,
|
|
172
|
+
> = Extract<
|
|
173
|
+
FunctionSpec_,
|
|
174
|
+
{ readonly functionProvenance: FunctionProvenance_ }
|
|
175
|
+
>;
|
|
176
|
+
|
|
99
177
|
export type WithoutName<
|
|
100
|
-
|
|
101
|
-
Name_ extends Name<
|
|
102
|
-
> = Exclude<
|
|
103
|
-
|
|
104
|
-
export type RegisteredFunction<Function extends AnyWithProps> =
|
|
105
|
-
RuntimeAndFunctionType.GetFunctionType<
|
|
106
|
-
Function["runtimeAndFunctionType"]
|
|
107
|
-
> extends "query"
|
|
108
|
-
? RegisteredQuery<
|
|
109
|
-
GetFunctionVisibility<Function>,
|
|
110
|
-
Args<Function>["Encoded"],
|
|
111
|
-
Promise<Returns<Function>["Encoded"]>
|
|
112
|
-
>
|
|
113
|
-
: RuntimeAndFunctionType.GetFunctionType<
|
|
114
|
-
Function["runtimeAndFunctionType"]
|
|
115
|
-
> extends "mutation"
|
|
116
|
-
? RegisteredMutation<
|
|
117
|
-
GetFunctionVisibility<Function>,
|
|
118
|
-
Args<Function>["Encoded"],
|
|
119
|
-
Promise<Returns<Function>["Encoded"]>
|
|
120
|
-
>
|
|
121
|
-
: RuntimeAndFunctionType.GetFunctionType<
|
|
122
|
-
Function["runtimeAndFunctionType"]
|
|
123
|
-
> extends "action"
|
|
124
|
-
? RegisteredAction<
|
|
125
|
-
GetFunctionVisibility<Function>,
|
|
126
|
-
Args<Function>["Encoded"],
|
|
127
|
-
Promise<Returns<Function>["Encoded"]>
|
|
128
|
-
>
|
|
129
|
-
: never;
|
|
178
|
+
FunctionSpec_ extends AnyWithProps,
|
|
179
|
+
Name_ extends Name<FunctionSpec_>,
|
|
180
|
+
> = Exclude<FunctionSpec_, { readonly name: Name_ }>;
|
|
130
181
|
|
|
131
182
|
const Proto = {
|
|
132
183
|
[TypeId]: TypeId,
|
|
@@ -157,8 +208,7 @@ const make =
|
|
|
157
208
|
RuntimeAndFunctionType_,
|
|
158
209
|
FunctionVisibility_,
|
|
159
210
|
Name_,
|
|
160
|
-
Args_,
|
|
161
|
-
Returns_
|
|
211
|
+
FunctionProvenance.Confect<Args_, Returns_>
|
|
162
212
|
> => {
|
|
163
213
|
validateConfectFunctionIdentifier(name);
|
|
164
214
|
|
|
@@ -166,8 +216,7 @@ const make =
|
|
|
166
216
|
runtimeAndFunctionType,
|
|
167
217
|
functionVisibility,
|
|
168
218
|
name,
|
|
169
|
-
args,
|
|
170
|
-
returns,
|
|
219
|
+
functionProvenance: FunctionProvenance.Confect(args, returns),
|
|
171
220
|
});
|
|
172
221
|
};
|
|
173
222
|
|
|
@@ -198,3 +247,99 @@ export const internalNodeAction = make(
|
|
|
198
247
|
RuntimeAndFunctionType.NodeAction,
|
|
199
248
|
"internal",
|
|
200
249
|
);
|
|
250
|
+
|
|
251
|
+
type MatchingRegisteredFunction<
|
|
252
|
+
RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
253
|
+
FunctionVisibility_ extends FunctionVisibility,
|
|
254
|
+
> =
|
|
255
|
+
RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_> extends "query"
|
|
256
|
+
? RegisteredQuery<FunctionVisibility_, any, any>
|
|
257
|
+
: RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_> extends "mutation"
|
|
258
|
+
? RegisteredMutation<FunctionVisibility_, any, any>
|
|
259
|
+
: RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_> extends "action"
|
|
260
|
+
? RegisteredAction<FunctionVisibility_, any, any>
|
|
261
|
+
: never;
|
|
262
|
+
|
|
263
|
+
type ExtractArgs<F> =
|
|
264
|
+
F extends RegisteredQuery<any, infer A, any>
|
|
265
|
+
? A
|
|
266
|
+
: F extends RegisteredMutation<any, infer A, any>
|
|
267
|
+
? A
|
|
268
|
+
: F extends RegisteredAction<any, infer A, any>
|
|
269
|
+
? A
|
|
270
|
+
: never;
|
|
271
|
+
|
|
272
|
+
type ExtractReturns<F> =
|
|
273
|
+
F extends RegisteredQuery<any, any, infer R>
|
|
274
|
+
? R
|
|
275
|
+
: F extends RegisteredMutation<any, any, infer R>
|
|
276
|
+
? R
|
|
277
|
+
: F extends RegisteredAction<any, any, infer R>
|
|
278
|
+
? R
|
|
279
|
+
: never;
|
|
280
|
+
|
|
281
|
+
const makeConvex =
|
|
282
|
+
<
|
|
283
|
+
RuntimeAndFunctionType_ extends
|
|
284
|
+
RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
285
|
+
FunctionVisibility_ extends FunctionVisibility,
|
|
286
|
+
>(
|
|
287
|
+
runtimeAndFunctionType: RuntimeAndFunctionType_,
|
|
288
|
+
functionVisibility: FunctionVisibility_,
|
|
289
|
+
) =>
|
|
290
|
+
<
|
|
291
|
+
F extends MatchingRegisteredFunction<
|
|
292
|
+
RuntimeAndFunctionType_,
|
|
293
|
+
FunctionVisibility_
|
|
294
|
+
>,
|
|
295
|
+
>() =>
|
|
296
|
+
<const Name_ extends string>(
|
|
297
|
+
name: Name_,
|
|
298
|
+
): FunctionSpec<
|
|
299
|
+
RuntimeAndFunctionType_,
|
|
300
|
+
FunctionVisibility_,
|
|
301
|
+
Name_,
|
|
302
|
+
FunctionProvenance.Convex<ExtractArgs<F>, ExtractReturns<F>>
|
|
303
|
+
> => {
|
|
304
|
+
validateConfectFunctionIdentifier(name);
|
|
305
|
+
|
|
306
|
+
return Object.assign(Object.create(Proto), {
|
|
307
|
+
runtimeAndFunctionType,
|
|
308
|
+
functionVisibility,
|
|
309
|
+
name,
|
|
310
|
+
functionProvenance: FunctionProvenance.Convex(),
|
|
311
|
+
}) as any;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export const convexPublicQuery = makeConvex(
|
|
315
|
+
RuntimeAndFunctionType.ConvexQuery,
|
|
316
|
+
"public",
|
|
317
|
+
);
|
|
318
|
+
export const convexInternalQuery = makeConvex(
|
|
319
|
+
RuntimeAndFunctionType.ConvexQuery,
|
|
320
|
+
"internal",
|
|
321
|
+
);
|
|
322
|
+
export const convexPublicMutation = makeConvex(
|
|
323
|
+
RuntimeAndFunctionType.ConvexMutation,
|
|
324
|
+
"public",
|
|
325
|
+
);
|
|
326
|
+
export const convexInternalMutation = makeConvex(
|
|
327
|
+
RuntimeAndFunctionType.ConvexMutation,
|
|
328
|
+
"internal",
|
|
329
|
+
);
|
|
330
|
+
export const convexPublicAction = makeConvex(
|
|
331
|
+
RuntimeAndFunctionType.ConvexAction,
|
|
332
|
+
"public",
|
|
333
|
+
);
|
|
334
|
+
export const convexInternalAction = makeConvex(
|
|
335
|
+
RuntimeAndFunctionType.ConvexAction,
|
|
336
|
+
"internal",
|
|
337
|
+
);
|
|
338
|
+
export const convexPublicNodeAction = makeConvex(
|
|
339
|
+
RuntimeAndFunctionType.NodeAction,
|
|
340
|
+
"public",
|
|
341
|
+
);
|
|
342
|
+
export const convexInternalNodeAction = makeConvex(
|
|
343
|
+
RuntimeAndFunctionType.NodeAction,
|
|
344
|
+
"internal",
|
|
345
|
+
);
|