@confect/server 2.0.0 → 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 +11 -0
- package/dist/ActionRunner.d.ts +2 -2
- package/dist/ActionRunner.d.ts.map +1 -1
- package/dist/ActionRunner.js +9 -7
- package/dist/ActionRunner.js.map +1 -1
- package/dist/FunctionImpl.js +2 -2
- package/dist/FunctionImpl.js.map +1 -1
- package/dist/Handler.d.ts +18 -12
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js.map +1 -1
- package/dist/MutationRunner.d.ts +2 -2
- package/dist/MutationRunner.d.ts.map +1 -1
- package/dist/MutationRunner.js +9 -7
- package/dist/MutationRunner.js.map +1 -1
- package/dist/QueryRunner.d.ts +2 -2
- package/dist/QueryRunner.d.ts.map +1 -1
- package/dist/QueryRunner.js +7 -5
- package/dist/QueryRunner.js.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +4 -4
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js +21 -18
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +16 -5
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/RegisteredFunctions.d.ts +4 -4
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/RegisteredNodeFunction.d.ts +3 -3
- package/dist/RegisteredNodeFunction.d.ts.map +1 -1
- package/dist/RegisteredNodeFunction.js +6 -5
- package/dist/RegisteredNodeFunction.js.map +1 -1
- package/dist/RegistryItem.d.ts +9 -9
- package/dist/RegistryItem.d.ts.map +1 -1
- package/dist/RegistryItem.js +2 -2
- package/dist/RegistryItem.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +4 -4
- package/src/ActionRunner.ts +27 -13
- package/src/FunctionImpl.ts +3 -3
- package/src/Handler.ts +39 -14
- package/src/MutationRunner.ts +27 -13
- package/src/QueryRunner.ts +22 -8
- package/src/RegisteredConvexFunction.ts +52 -41
- package/src/RegisteredFunction.ts +86 -1
- package/src/RegisteredFunctions.ts +10 -11
- package/src/RegisteredNodeFunction.ts +23 -13
- package/src/RegistryItem.ts +9 -12
- package/src/index.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunction.d.ts","names":[],"sources":["../src/RegisteredFunction.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"RegisteredFunction.d.ts","names":[],"sources":["../src/RegisteredFunction.ts"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","Scheduler.layer","Auth.layer","StorageReader","StorageWriter","StorageActionWriter","QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","VectorSearch.layer","ActionCtx.ActionCtx"],"sources":["../src/RegisteredFunction.ts"],"sourcesContent":["import {\n type DefaultFunctionArgs,\n type FunctionVisibility,\n type GenericActionCtx,\n type RegisteredAction,\n type RegisteredMutation,\n type RegisteredQuery,\n} from \"convex/server\";\nimport { Effect, Layer, pipe, Schema } from \"effect\";\nimport * as ActionCtx from \"./ActionCtx\";\nimport * as ActionRunner from \"./ActionRunner\";\nimport * as Auth from \"./Auth\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DataModel from \"./DataModel\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as Scheduler from \"./Scheduler\";\nimport * as SchemaToValidator from \"./SchemaToValidator\";\nimport { StorageActionWriter, StorageReader, StorageWriter } from \"./Storage\";\nimport * as VectorSearch from \"./VectorSearch\";\n\nexport type
|
|
1
|
+
{"version":3,"file":"RegisteredFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","Scheduler.layer","Auth.layer","StorageReader","StorageWriter","StorageActionWriter","QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","VectorSearch.layer","ActionCtx.ActionCtx"],"sources":["../src/RegisteredFunction.ts"],"sourcesContent":["import type { FunctionSpec, RuntimeAndFunctionType } from \"@confect/core\";\nimport type * as FunctionProvenance from \"@confect/core/FunctionProvenance\";\nimport {\n type DefaultFunctionArgs,\n type FunctionVisibility,\n type GenericActionCtx,\n type RegisteredAction,\n type RegisteredMutation,\n type RegisteredQuery,\n} from \"convex/server\";\nimport { Effect, Layer, pipe, Schema } from \"effect\";\nimport * as ActionCtx from \"./ActionCtx\";\nimport * as ActionRunner from \"./ActionRunner\";\nimport * as Auth from \"./Auth\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DataModel from \"./DataModel\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as Scheduler from \"./Scheduler\";\nimport * as SchemaToValidator from \"./SchemaToValidator\";\nimport { StorageActionWriter, StorageReader, StorageWriter } from \"./Storage\";\nimport * as VectorSearch from \"./VectorSearch\";\n\nexport type Any =\n | RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;\n\ntype ConfectRegisteredFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec.EncodedArgs<FunctionSpec_> extends infer Args_ extends\n DefaultFunctionArgs\n ? RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"query\"\n ? RegisteredQuery<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"mutation\"\n ? RegisteredMutation<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"action\"\n ? RegisteredAction<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>\n >\n : never\n : never;\n\nexport type ConvexRegisteredFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> = FunctionSpec_ extends {\n functionProvenance: {\n _tag: \"Convex\";\n _args: infer Args_ extends DefaultFunctionArgs;\n _returns: infer Returns_;\n };\n}\n ? RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"query\"\n ? RegisteredQuery<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Returns_\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"mutation\"\n ? RegisteredMutation<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Returns_\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"action\"\n ? RegisteredAction<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Returns_\n >\n : never\n : never;\n\nexport type RegisteredFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConvex\n >\n ? ConvexRegisteredFunction<FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConfect\n >\n ? ConfectRegisteredFunction<FunctionSpec_>\n : never;\n\nexport const actionFunctionBase = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n R,\n>({\n args,\n returns,\n handler,\n createLayer,\n}: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (a: Args) => Effect.Effect<Returns, E, R>;\n createLayer: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n ) => Layer.Layer<R>;\n}) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n Effect.andThen((decodedArgs) =>\n handler(decodedArgs).pipe(Effect.provide(createLayer(ctx))),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n\nexport type ActionServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n> =\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | VectorSearch.VectorSearch<DataModel.FromSchema<DatabaseSchema_>>\n | ActionCtx.ActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >;\n\nexport const actionLayer = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n>(\n databaseSchema: DatabaseSchema_,\n ctx: GenericActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n) =>\n Layer.mergeAll(\n Scheduler.layer(ctx.scheduler),\n Auth.layer(ctx.auth),\n StorageReader.layer(ctx.storage),\n StorageWriter.layer(ctx.storage),\n StorageActionWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n ActionRunner.layer(ctx.runAction),\n VectorSearch.layer(ctx.vectorSearch),\n Layer.succeed(\n ActionCtx.ActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >(),\n ctx,\n ),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+GA,MAAa,sBAQX,EACA,MACA,SACA,SACA,mBAQK;CACL,MAAMA,kBAAoC,KAAK;CAC/C,SAASC,qBAAuC,QAAQ;CACxD,UACE,KACA,eAEA,KACE,YACA,OAAO,OAAO,KAAK,EACnB,OAAO,OACP,OAAO,SAAS,gBACd,QAAQ,YAAY,CAAC,KAAK,OAAO,QAAQ,YAAY,IAAI,CAAC,CAAC,CAC5D,EACD,OAAO,SAAS,kBACd,OAAO,cAAc,QAAQ,CAAC,cAAc,CAC7C,EACD,OAAO,WACR;CACJ;AAkBD,MAAa,eAGX,gBACA,QAIA,MAAM,SACJC,QAAgB,IAAI,UAAU,EAC9BC,QAAW,IAAI,KAAK,EACpBC,gBAAc,MAAM,IAAI,QAAQ,EAChCC,gBAAc,MAAM,IAAI,QAAQ,EAChCC,sBAAoB,MAAM,IAAI,QAAQ,EACtCC,QAAkB,IAAI,SAAS,EAC/BC,QAAqB,IAAI,YAAY,EACrCC,MAAmB,IAAI,UAAU,EACjCC,QAAmB,IAAI,aAAa,EACpC,MAAM,QACJC,WAEG,EACH,IACD,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyWithProps as AnyWithProps$1 } from "./Api.js";
|
|
2
|
+
import { Any, RegisteredFunction } from "./RegisteredFunction.js";
|
|
2
3
|
import { Impl } from "./Impl.js";
|
|
3
|
-
import { RegisteredFunction } from "./RegisteredFunction.js";
|
|
4
4
|
import { AnyWithProps as AnyWithProps$2 } from "./RegistryItem.js";
|
|
5
5
|
import { Layer, Types } from "effect";
|
|
6
6
|
import * as Spec from "@confect/core/Spec";
|
|
@@ -12,11 +12,11 @@ declare namespace RegisteredFunctions_d_exports {
|
|
|
12
12
|
export { AnyWithProps, RegisteredFunctions, make };
|
|
13
13
|
}
|
|
14
14
|
type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> = Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;
|
|
15
|
-
type RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = { [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<Groups, GroupName> extends infer Group extends GroupSpec.AnyWithProps ? GroupSpec.Groups<Group> extends infer SubGroups extends GroupSpec.AnyWithProps ? Types.Simplify<RegisteredFunctionsHelper<SubGroups> & { [FunctionName in FunctionSpec.Name<GroupSpec.Functions<Group>>]: FunctionSpec.WithName<GroupSpec.Functions<Group>, FunctionName> extends infer
|
|
15
|
+
type RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = { [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<Groups, GroupName> extends infer Group extends GroupSpec.AnyWithProps ? GroupSpec.Groups<Group> extends infer SubGroups extends GroupSpec.AnyWithProps ? Types.Simplify<RegisteredFunctionsHelper<SubGroups> & { [FunctionName in FunctionSpec.Name<GroupSpec.Functions<Group>>]: FunctionSpec.WithName<GroupSpec.Functions<Group>, FunctionName> extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps ? RegisteredFunction<FunctionSpec_> : never }> : { [FunctionName in FunctionSpec.Name<GroupSpec.Functions<Group>>]: FunctionSpec.WithName<GroupSpec.Functions<Group>, FunctionName> extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps ? RegisteredFunction<FunctionSpec_> : never } : never };
|
|
16
16
|
interface AnyWithProps {
|
|
17
|
-
readonly [key: string]:
|
|
17
|
+
readonly [key: string]: Any | AnyWithProps;
|
|
18
18
|
}
|
|
19
|
-
declare const make: <Api_ extends AnyWithProps$1>(impl: Layer.Layer<Impl<Api_, "Finalized">>, makeRegisteredFunction: (api: Api_, registryItem: AnyWithProps$2) =>
|
|
19
|
+
declare const make: <Api_ extends AnyWithProps$1>(impl: Layer.Layer<Impl<Api_, "Finalized">>, makeRegisteredFunction: (api: Api_, registryItem: AnyWithProps$2) => Any) => Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Api_["spec"]>>>;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { AnyWithProps, RegisteredFunctions, RegisteredFunctions_d_exports, make };
|
|
22
22
|
//# sourceMappingURL=RegisteredFunctions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunctions.d.ts","names":[],"sources":["../src/RegisteredFunctions.ts"],"mappings":";;;;;;;;;;;;;KAYY,mBAAA,eAAkC,IAAA,CAAK,YAAA,IACjD,KAAA,CAAM,QAAA,CAAS,yBAAA,CAA0B,IAAA,CAAK,MAAA,CAAO,KAAA;AAAA,KAElD,yBAAA,gBAAyC,SAAA,CAAU,YAAA,oBACxC,SAAA,CAAU,IAAA,CAAK,MAAA,IAAU,SAAA,CAAU,QAAA,CAC/C,MAAA,EACA,SAAA,8BAC4B,SAAA,CAAU,YAAA,GACpC,SAAA,CAAU,MAAA,CAAO,KAAA,kCACf,SAAA,CAAU,YAAA,GACV,KAAA,CAAM,QAAA,CACJ,yBAAA,CAA0B,SAAA,uBACP,YAAA,CAAa,IAAA,CAC5B,SAAA,CAAU,SAAA,CAAU,KAAA,KAClB,YAAA,CAAa,QAAA,CACf,SAAA,CAAU,SAAA,CAAU,KAAA,GACpB,YAAA,
|
|
1
|
+
{"version":3,"file":"RegisteredFunctions.d.ts","names":[],"sources":["../src/RegisteredFunctions.ts"],"mappings":";;;;;;;;;;;;;KAYY,mBAAA,eAAkC,IAAA,CAAK,YAAA,IACjD,KAAA,CAAM,QAAA,CAAS,yBAAA,CAA0B,IAAA,CAAK,MAAA,CAAO,KAAA;AAAA,KAElD,yBAAA,gBAAyC,SAAA,CAAU,YAAA,oBACxC,SAAA,CAAU,IAAA,CAAK,MAAA,IAAU,SAAA,CAAU,QAAA,CAC/C,MAAA,EACA,SAAA,8BAC4B,SAAA,CAAU,YAAA,GACpC,SAAA,CAAU,MAAA,CAAO,KAAA,kCACf,SAAA,CAAU,YAAA,GACV,KAAA,CAAM,QAAA,CACJ,yBAAA,CAA0B,SAAA,uBACP,YAAA,CAAa,IAAA,CAC5B,SAAA,CAAU,SAAA,CAAU,KAAA,KAClB,YAAA,CAAa,QAAA,CACf,SAAA,CAAU,SAAA,CAAU,KAAA,GACpB,YAAA,sCACoC,YAAA,CAAa,YAAA,GAC/C,kBAAA,CAAsC,aAAA,kCAK3B,YAAA,CAAa,IAAA,CAC5B,SAAA,CAAU,SAAA,CAAU,KAAA,KAClB,YAAA,CAAa,QAAA,CACf,SAAA,CAAU,SAAA,CAAU,KAAA,GACpB,YAAA,sCACoC,YAAA,CAAa,YAAA,GAC/C,kBAAA,CAAsC,aAAA;AAAA,UAMnC,YAAA;EAAA,UACL,GAAA,WAAc,GAAA,GAAyB,YAAA;AAAA;AAAA,cAGtC,IAAA,gBAAqB,cAAA,EAChC,IAAA,EAAM,KAAA,CAAM,KAAA,CAAM,IAAA,CAAU,IAAA,iBAC5B,sBAAA,GACE,GAAA,EAAK,IAAA,EACL,YAAA,EAAc,cAAA,KACX,GAAA,KAAsB,KAAA,CAAA,QAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,MAAA,CAAA,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunctions.js","names":["Registry.Registry","Impl.Impl","RegistryItem.isRegistryItem"],"sources":["../src/RegisteredFunctions.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport type { Layer } from \"effect\";\nimport { Effect, Match, Ref, type Types } from \"effect\";\nimport type * as Api from \"./Api\";\nimport * as Impl from \"./Impl\";\nimport { mapLeaves } from \"./internal/utils\";\nimport type * as RegisteredFunction from \"./RegisteredFunction\";\nimport * as Registry from \"./Registry\";\nimport * as RegistryItem from \"./RegistryItem\";\n\nexport type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> =\n Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;\n\ntype RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = {\n [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<\n Groups,\n GroupName\n > extends infer Group extends GroupSpec.AnyWithProps\n ? GroupSpec.Groups<Group> extends infer SubGroups extends\n GroupSpec.AnyWithProps\n ? Types.Simplify<\n RegisteredFunctionsHelper<SubGroups> & {\n [FunctionName in FunctionSpec.Name<\n GroupSpec.Functions<Group>\n >]: FunctionSpec.WithName<\n GroupSpec.Functions<Group>,\n FunctionName\n > extends infer
|
|
1
|
+
{"version":3,"file":"RegisteredFunctions.js","names":["Registry.Registry","Impl.Impl","RegistryItem.isRegistryItem"],"sources":["../src/RegisteredFunctions.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport type { Layer } from \"effect\";\nimport { Effect, Match, Ref, type Types } from \"effect\";\nimport type * as Api from \"./Api\";\nimport * as Impl from \"./Impl\";\nimport { mapLeaves } from \"./internal/utils\";\nimport type * as RegisteredFunction from \"./RegisteredFunction\";\nimport * as Registry from \"./Registry\";\nimport * as RegistryItem from \"./RegistryItem\";\n\nexport type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> =\n Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;\n\ntype RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = {\n [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<\n Groups,\n GroupName\n > extends infer Group extends GroupSpec.AnyWithProps\n ? GroupSpec.Groups<Group> extends infer SubGroups extends\n GroupSpec.AnyWithProps\n ? Types.Simplify<\n RegisteredFunctionsHelper<SubGroups> & {\n [FunctionName in FunctionSpec.Name<\n GroupSpec.Functions<Group>\n >]: FunctionSpec.WithName<\n GroupSpec.Functions<Group>,\n FunctionName\n > extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps\n ? RegisteredFunction.RegisteredFunction<FunctionSpec_>\n : never;\n }\n >\n : {\n [FunctionName in FunctionSpec.Name<\n GroupSpec.Functions<Group>\n >]: FunctionSpec.WithName<\n GroupSpec.Functions<Group>,\n FunctionName\n > extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps\n ? RegisteredFunction.RegisteredFunction<FunctionSpec_>\n : never;\n }\n : never;\n};\n\nexport interface AnyWithProps {\n readonly [key: string]: RegisteredFunction.Any | AnyWithProps;\n}\n\nexport const make = <Api_ extends Api.AnyWithProps>(\n impl: Layer.Layer<Impl.Impl<Api_, \"Finalized\">>,\n makeRegisteredFunction: (\n api: Api_,\n registryItem: RegistryItem.AnyWithProps,\n ) => RegisteredFunction.Any,\n) =>\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n const functionImplItems = yield* Ref.get(registry);\n const { api, finalizationStatus } = yield* Impl.Impl<Api_, \"Finalized\">();\n\n return yield* Match.value(\n finalizationStatus as Impl.FinalizationStatus,\n ).pipe(\n Match.withReturnType<Effect.Effect<RegisteredFunctions<Api_[\"spec\"]>>>(),\n Match.when(\"Unfinalized\", () =>\n Effect.dieMessage(\"Impl is not finalized\"),\n ),\n Match.when(\"Finalized\", () =>\n Effect.succeed(\n mapLeaves<RegistryItem.AnyWithProps, RegisteredFunction.Any>(\n functionImplItems,\n RegistryItem.isRegistryItem,\n (registryItem) => makeRegisteredFunction(api, registryItem),\n ) as RegisteredFunctions<Api_[\"spec\"]>,\n ),\n ),\n Match.exhaustive,\n );\n }).pipe(Effect.provide(impl), Effect.runSync);\n"],"mappings":";;;;;;;;;AAmDA,MAAa,QACX,MACA,2BAKA,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,OAAOA;CACxB,MAAM,oBAAoB,OAAO,IAAI,IAAI,SAAS;CAClD,MAAM,EAAE,KAAK,uBAAuB,OAAOC,MAA8B;AAEzE,QAAO,OAAO,MAAM,MAClB,mBACD,CAAC,KACA,MAAM,gBAAkE,EACxE,MAAM,KAAK,qBACT,OAAO,WAAW,wBAAwB,CAC3C,EACD,MAAM,KAAK,mBACT,OAAO,QACL,UACE,mBACAC,iBACC,iBAAiB,uBAAuB,KAAK,aAAa,CAC5D,CACF,CACF,EACD,MAAM,WACP;EACD,CAAC,KAAK,OAAO,QAAQ,KAAK,EAAE,OAAO,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyWithPropsWithRuntime } from "./Api.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Any } from "./RegisteredFunction.js";
|
|
3
3
|
import { AnyWithProps } from "./RegistryItem.js";
|
|
4
4
|
|
|
5
5
|
//#region src/RegisteredNodeFunction.d.ts
|
|
@@ -7,9 +7,9 @@ declare namespace RegisteredNodeFunction_d_exports {
|
|
|
7
7
|
export { make };
|
|
8
8
|
}
|
|
9
9
|
declare const make: <Api_ extends AnyWithPropsWithRuntime<"Node">>(api: Api_, {
|
|
10
|
-
|
|
10
|
+
functionSpec,
|
|
11
11
|
handler
|
|
12
|
-
}: AnyWithProps) =>
|
|
12
|
+
}: AnyWithProps) => Any;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { RegisteredNodeFunction_d_exports, make };
|
|
15
15
|
//# sourceMappingURL=RegisteredNodeFunction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredNodeFunction.d.ts","names":[],"sources":["../src/RegisteredNodeFunction.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"RegisteredNodeFunction.d.ts","names":[],"sources":["../src/RegisteredNodeFunction.ts"],"mappings":";;;;;;;;cAea,IAAA,gBAAqB,uBAAA,UAChC,GAAA,EAAK,IAAA;EACL,YAAA;EAAA;AAAA,GAA2B,YAAA,KAC1B,GAAA"}
|
|
@@ -6,13 +6,14 @@ import { NodeContext } from "@effect/platform-node";
|
|
|
6
6
|
|
|
7
7
|
//#region src/RegisteredNodeFunction.ts
|
|
8
8
|
var RegisteredNodeFunction_exports = /* @__PURE__ */ __exportAll({ make: () => make });
|
|
9
|
-
const make = (api, {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const make = (api, { functionSpec, handler }) => Match.value(functionSpec.functionProvenance).pipe(Match.tag("Convex", () => handler), Match.tag("Confect", () => {
|
|
10
|
+
const { functionVisibility, functionProvenance } = functionSpec;
|
|
11
|
+
return Match.value(functionVisibility).pipe(Match.when("public", () => actionGeneric), Match.when("internal", () => internalActionGeneric), Match.exhaustive)(nodeActionFunction(api.databaseSchema, {
|
|
12
|
+
args: functionProvenance.args,
|
|
13
|
+
returns: functionProvenance.returns,
|
|
13
14
|
handler
|
|
14
15
|
}));
|
|
15
|
-
};
|
|
16
|
+
}), Match.exhaustive);
|
|
16
17
|
const nodeActionFunction = (databaseSchema, { args, returns, handler }) => actionFunctionBase({
|
|
17
18
|
args,
|
|
18
19
|
returns,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredNodeFunction.js","names":["RegisteredFunction.actionFunctionBase","RegisteredFunction.actionLayer"],"sources":["../src/RegisteredNodeFunction.ts"],"sourcesContent":["import { NodeContext } from \"@effect/platform-node\";\nimport {\n actionGeneric,\n type DefaultFunctionArgs,\n internalActionGeneric,\n} from \"convex/server\";\nimport type { Effect } from \"effect\";\nimport { Layer, Match, type Schema } from \"effect\";\nimport type * as Api from \"./Api\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport * as RegisteredFunction from \"./RegisteredFunction\";\nimport type * as RegistryItem from \"./RegistryItem\";\n\nexport const make = <Api_ extends Api.AnyWithPropsWithRuntime<\"Node\">>(\n api: Api_,\n {
|
|
1
|
+
{"version":3,"file":"RegisteredNodeFunction.js","names":["RegisteredFunction.actionFunctionBase","RegisteredFunction.actionLayer"],"sources":["../src/RegisteredNodeFunction.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport { NodeContext } from \"@effect/platform-node\";\nimport {\n actionGeneric,\n type DefaultFunctionArgs,\n internalActionGeneric,\n} from \"convex/server\";\nimport type { Effect } from \"effect\";\nimport { Layer, Match, type Schema } from \"effect\";\nimport type * as Api from \"./Api\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as Handler from \"./Handler\";\nimport * as RegisteredFunction from \"./RegisteredFunction\";\nimport type * as RegistryItem from \"./RegistryItem\";\n\nexport const make = <Api_ extends Api.AnyWithPropsWithRuntime<\"Node\">>(\n api: Api_,\n { functionSpec, handler }: RegistryItem.AnyWithProps,\n): RegisteredFunction.Any =>\n Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\"Convex\", () => handler as RegisteredFunction.Any),\n Match.tag(\"Confect\", () => {\n const { functionVisibility, functionProvenance } =\n functionSpec as FunctionSpec.AnyConfect;\n\n const genericFunction = Match.value(functionVisibility).pipe(\n Match.when(\"public\", () => actionGeneric),\n Match.when(\"internal\", () => internalActionGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n nodeActionFunction(api.databaseSchema, {\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.exhaustive,\n );\n\nconst nodeActionFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n databaseSchema: DatabaseSchema_,\n {\n args,\n returns,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (\n a: Args,\n ) => Effect.Effect<\n Returns,\n E,\n | RegisteredFunction.ActionServices<DatabaseSchema_>\n | NodeContext.NodeContext\n >;\n },\n) =>\n RegisteredFunction.actionFunctionBase({\n args,\n returns,\n handler,\n createLayer: (ctx) =>\n Layer.mergeAll(\n RegisteredFunction.actionLayer(databaseSchema, ctx),\n NodeContext.layer,\n ),\n });\n"],"mappings":";;;;;;;;AAeA,MAAa,QACX,KACA,EAAE,cAAc,cAEhB,MAAM,MAAM,aAAa,mBAAmB,CAAC,KAC3C,MAAM,IAAI,gBAAgB,QAAkC,EAC5D,MAAM,IAAI,iBAAiB;CACzB,MAAM,EAAE,oBAAoB,uBAC1B;AAQF,QANwB,MAAM,MAAM,mBAAmB,CAAC,KACtD,MAAM,KAAK,gBAAgB,cAAc,EACzC,MAAM,KAAK,kBAAkB,sBAAsB,EACnD,MAAM,WACP,CAGC,mBAAmB,IAAI,gBAAgB;EACrC,MAAM,mBAAmB;EACzB,SAAS,mBAAmB;EACnB;EACV,CAAC,CACH;EACD,EACF,MAAM,WACP;AAEH,MAAM,sBAQJ,gBACA,EACE,MACA,SACA,cAcFA,mBAAsC;CACpC;CACA;CACA;CACA,cAAc,QACZ,MAAM,SACJC,YAA+B,gBAAgB,IAAI,EACnD,YAAY,MACb;CACJ,CAAC"}
|
package/dist/RegistryItem.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyWithProps as AnyWithProps$1 } from "./DatabaseSchema.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Any, Handler } from "./Handler.js";
|
|
3
3
|
import * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
4
4
|
|
|
5
5
|
//#region src/RegistryItem.d.ts
|
|
@@ -11,21 +11,21 @@ type TypeId = typeof TypeId;
|
|
|
11
11
|
declare const isRegistryItem: (value: unknown) => value is AnyWithProps;
|
|
12
12
|
interface RegistryItem<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithProps> {
|
|
13
13
|
readonly [TypeId]: TypeId;
|
|
14
|
-
readonly
|
|
14
|
+
readonly functionSpec: FunctionSpec_;
|
|
15
15
|
readonly handler: Handler<DatabaseSchema_, FunctionSpec_>;
|
|
16
16
|
}
|
|
17
17
|
interface AnyWithProps {
|
|
18
18
|
readonly [TypeId]: TypeId;
|
|
19
|
-
readonly
|
|
20
|
-
readonly handler:
|
|
19
|
+
readonly functionSpec: FunctionSpec.AnyWithProps;
|
|
20
|
+
readonly handler: Any;
|
|
21
21
|
}
|
|
22
|
-
declare const make:
|
|
23
|
-
|
|
22
|
+
declare const make: ({
|
|
23
|
+
functionSpec,
|
|
24
24
|
handler
|
|
25
25
|
}: {
|
|
26
|
-
|
|
27
|
-
handler:
|
|
28
|
-
}) =>
|
|
26
|
+
functionSpec: FunctionSpec.AnyWithProps;
|
|
27
|
+
handler: AnyWithProps["handler"];
|
|
28
|
+
}) => AnyWithProps;
|
|
29
29
|
//#endregion
|
|
30
30
|
export { AnyWithProps, RegistryItem, RegistryItem_d_exports, TypeId, isRegistryItem, make };
|
|
31
31
|
//# sourceMappingURL=RegistryItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegistryItem.d.ts","names":[],"sources":["../src/RegistryItem.ts"],"mappings":";;;;;;;;cAKa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,cAEf,cAAA,GAAkB,KAAA,cAAiB,KAAA,IAAS,YAAA;AAAA,UAOxC,YAAA,yBACS,cAAA,wBACF,YAAA,CAAa,YAAA;EAAA,UAEzB,MAAA,GAAS,MAAA;EAAA,SACV,
|
|
1
|
+
{"version":3,"file":"RegistryItem.d.ts","names":[],"sources":["../src/RegistryItem.ts"],"mappings":";;;;;;;;cAKa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,cAEf,cAAA,GAAkB,KAAA,cAAiB,KAAA,IAAS,YAAA;AAAA,UAOxC,YAAA,yBACS,cAAA,wBACF,YAAA,CAAa,YAAA;EAAA,UAEzB,MAAA,GAAS,MAAA;EAAA,SACV,YAAA,EAAc,aAAA;EAAA,SACd,OAAA,EAAS,OAAA,CAAgB,eAAA,EAAiB,aAAA;AAAA;AAAA,UAGpC,YAAA;EAAA,UACL,MAAA,GAAS,MAAA;EAAA,SACV,YAAA,EAAc,YAAA,CAAa,YAAA;EAAA,SAC3B,OAAA,EAAS,GAAA;AAAA;AAAA,cAGP,IAAA;EAAQ,YAAA;EAAA;AAAA;EAInB,YAAA,EAAc,YAAA,CAAa,YAAA;EAC3B,OAAA,EAAS,YAAA;AAAA,MACP,YAAA"}
|
package/dist/RegistryItem.js
CHANGED
|
@@ -10,8 +10,8 @@ var RegistryItem_exports = /* @__PURE__ */ __exportAll({
|
|
|
10
10
|
const TypeId = "@confect/server/RegistryItem";
|
|
11
11
|
const isRegistryItem = (value) => Predicate.hasProperty(value, TypeId);
|
|
12
12
|
const RegistryItemProto = { [TypeId]: TypeId };
|
|
13
|
-
const make = ({
|
|
14
|
-
|
|
13
|
+
const make = ({ functionSpec, handler }) => Object.assign(Object.create(RegistryItemProto), {
|
|
14
|
+
functionSpec,
|
|
15
15
|
handler
|
|
16
16
|
});
|
|
17
17
|
|
package/dist/RegistryItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegistryItem.js","names":[],"sources":["../src/RegistryItem.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport { Predicate } from \"effect\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as Handler from \"./Handler\";\n\nexport const TypeId = \"@confect/server/RegistryItem\";\nexport type TypeId = typeof TypeId;\n\nexport const isRegistryItem = (value: unknown): value is AnyWithProps =>\n Predicate.hasProperty(value, TypeId);\n\nconst RegistryItemProto = {\n [TypeId]: TypeId,\n};\n\nexport interface RegistryItem<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> {\n readonly [TypeId]: TypeId;\n readonly
|
|
1
|
+
{"version":3,"file":"RegistryItem.js","names":[],"sources":["../src/RegistryItem.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport { Predicate } from \"effect\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as Handler from \"./Handler\";\n\nexport const TypeId = \"@confect/server/RegistryItem\";\nexport type TypeId = typeof TypeId;\n\nexport const isRegistryItem = (value: unknown): value is AnyWithProps =>\n Predicate.hasProperty(value, TypeId);\n\nconst RegistryItemProto = {\n [TypeId]: TypeId,\n};\n\nexport interface RegistryItem<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> {\n readonly [TypeId]: TypeId;\n readonly functionSpec: FunctionSpec_;\n readonly handler: Handler.Handler<DatabaseSchema_, FunctionSpec_>;\n}\n\nexport interface AnyWithProps {\n readonly [TypeId]: TypeId;\n readonly functionSpec: FunctionSpec.AnyWithProps;\n readonly handler: Handler.Any;\n}\n\nexport const make = ({\n functionSpec,\n handler,\n}: {\n functionSpec: FunctionSpec.AnyWithProps;\n handler: AnyWithProps[\"handler\"];\n}): AnyWithProps =>\n Object.assign(Object.create(RegistryItemProto), {\n functionSpec,\n handler,\n });\n"],"mappings":";;;;;;;;;AAKA,MAAa,SAAS;AAGtB,MAAa,kBAAkB,UAC7B,UAAU,YAAY,OAAO,OAAO;AAEtC,MAAM,oBAAoB,GACvB,SAAS,QACX;AAiBD,MAAa,QAAQ,EACnB,cACA,cAKA,OAAO,OAAO,OAAO,OAAO,kBAAkB,EAAE;CAC9C;CACA;CACD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -20,12 +20,12 @@ import { QueryRunner_d_exports } from "./QueryRunner.js";
|
|
|
20
20
|
import { Scheduler_d_exports } from "./Scheduler.js";
|
|
21
21
|
import { Storage_d_exports } from "./Storage.js";
|
|
22
22
|
import { VectorSearch_d_exports } from "./VectorSearch.js";
|
|
23
|
+
import { RegisteredFunction_d_exports } from "./RegisteredFunction.js";
|
|
23
24
|
import { Handler_d_exports } from "./Handler.js";
|
|
24
25
|
import { FunctionImpl_d_exports } from "./FunctionImpl.js";
|
|
25
26
|
import { GroupImpl_d_exports } from "./GroupImpl.js";
|
|
26
27
|
import { HttpApi_d_exports } from "./HttpApi.js";
|
|
27
28
|
import { Impl_d_exports } from "./Impl.js";
|
|
28
|
-
import { RegisteredFunction_d_exports } from "./RegisteredFunction.js";
|
|
29
29
|
import { RegistryItem_d_exports } from "./RegistryItem.js";
|
|
30
30
|
import { RegisteredConvexFunction_d_exports } from "./RegisteredConvexFunction.js";
|
|
31
31
|
import { RegisteredFunctions_d_exports } from "./RegisteredFunctions.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@confect/server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Backend bindings to the Convex platform",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -67,15 +67,15 @@
|
|
|
67
67
|
"vite": "7.3.1",
|
|
68
68
|
"vite-tsconfig-paths": "6.1.1",
|
|
69
69
|
"vitest": "3.2.4",
|
|
70
|
-
"@confect/cli": "
|
|
71
|
-
"@confect/test": "
|
|
70
|
+
"@confect/cli": "3.0.0",
|
|
71
|
+
"@confect/test": "3.0.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@effect/platform": "^0.94.5",
|
|
75
75
|
"@effect/platform-node": "^0.104.1",
|
|
76
76
|
"convex": "^1.30.0",
|
|
77
77
|
"effect": "^3.19.16",
|
|
78
|
-
"@confect/core": "
|
|
78
|
+
"@confect/core": "3.0.0"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=22",
|
package/src/ActionRunner.ts
CHANGED
|
@@ -1,29 +1,43 @@
|
|
|
1
1
|
import * as Ref from "@confect/core/Ref";
|
|
2
2
|
import { type GenericActionCtx } from "convex/server";
|
|
3
3
|
import type { ParseResult } from "effect";
|
|
4
|
-
import { Context, Effect, Layer, Schema } from "effect";
|
|
4
|
+
import { Context, Effect, Layer, Match, Schema } from "effect";
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const make =
|
|
7
7
|
(runAction: GenericActionCtx<any>["runAction"]) =>
|
|
8
8
|
<Action extends Ref.AnyAction>(
|
|
9
9
|
action: Action,
|
|
10
|
-
args: Ref.Args<Action
|
|
11
|
-
): Effect.Effect<Ref.Returns<Action
|
|
10
|
+
args: Ref.Args<Action>,
|
|
11
|
+
): Effect.Effect<Ref.Returns<Action>, ParseResult.ParseError> =>
|
|
12
12
|
Effect.gen(function* () {
|
|
13
|
-
const
|
|
13
|
+
const functionSpec = Ref.getFunctionSpec(action);
|
|
14
14
|
const functionName = Ref.getConvexFunctionName(action);
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
return yield* Match.value(functionSpec.functionProvenance).pipe(
|
|
17
|
+
Match.tag("Confect", (confectFunctionSpec) =>
|
|
18
|
+
Effect.gen(function* () {
|
|
19
|
+
const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(
|
|
20
|
+
args,
|
|
21
|
+
);
|
|
22
|
+
const encodedReturns = yield* Effect.promise(() =>
|
|
23
|
+
runAction(functionName as any, encodedArgs),
|
|
24
|
+
);
|
|
25
|
+
return yield* Schema.decode(confectFunctionSpec.returns)(
|
|
26
|
+
encodedReturns,
|
|
27
|
+
);
|
|
28
|
+
}),
|
|
29
|
+
),
|
|
30
|
+
Match.tag("Convex", () =>
|
|
31
|
+
Effect.promise(() => runAction(functionName as any, args as any)),
|
|
32
|
+
),
|
|
33
|
+
Match.exhaustive,
|
|
19
34
|
);
|
|
20
|
-
return yield* Schema.decode(function_.returns)(encodedReturns);
|
|
21
35
|
});
|
|
22
36
|
|
|
23
|
-
export const ActionRunner = Context.GenericTag<
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
export const ActionRunner = Context.GenericTag<ReturnType<typeof make>>(
|
|
38
|
+
"@confect/server/ActionRunner",
|
|
39
|
+
);
|
|
26
40
|
export type ActionRunner = typeof ActionRunner.Identifier;
|
|
27
41
|
|
|
28
42
|
export const layer = (runAction: GenericActionCtx<any>["runAction"]) =>
|
|
29
|
-
Layer.succeed(ActionRunner,
|
|
43
|
+
Layer.succeed(ActionRunner, make(runAction));
|
package/src/FunctionImpl.ts
CHANGED
|
@@ -56,7 +56,7 @@ export const make = <
|
|
|
56
56
|
currentGroup.groups[groupPathPart],
|
|
57
57
|
);
|
|
58
58
|
|
|
59
|
-
const
|
|
59
|
+
const functionSpec = group_.functions[functionName]!;
|
|
60
60
|
|
|
61
61
|
return Layer.effect(
|
|
62
62
|
FunctionImpl<GroupPath_, FunctionName>({
|
|
@@ -71,8 +71,8 @@ export const make = <
|
|
|
71
71
|
registryItems,
|
|
72
72
|
[...groupPathParts, functionName],
|
|
73
73
|
RegistryItem.make({
|
|
74
|
-
|
|
75
|
-
handler
|
|
74
|
+
functionSpec,
|
|
75
|
+
handler,
|
|
76
76
|
}),
|
|
77
77
|
),
|
|
78
78
|
);
|
package/src/Handler.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
|
|
2
|
+
import type * as FunctionProvenance from "@confect/core/FunctionProvenance";
|
|
2
3
|
import type { NodeContext } from "@effect/platform-node";
|
|
3
4
|
import type { Effect } from "effect";
|
|
4
5
|
import type * as ActionCtx from "./ActionCtx";
|
|
@@ -12,6 +13,7 @@ import type * as MutationCtx from "./MutationCtx";
|
|
|
12
13
|
import type * as MutationRunner from "./MutationRunner";
|
|
13
14
|
import type * as QueryCtx from "./QueryCtx";
|
|
14
15
|
import type * as QueryRunner from "./QueryRunner";
|
|
16
|
+
import type * as RegisteredFunction from "./RegisteredFunction";
|
|
15
17
|
import type * as Scheduler from "./Scheduler";
|
|
16
18
|
import type {
|
|
17
19
|
StorageActionWriter,
|
|
@@ -23,27 +25,49 @@ import type * as VectorSearch from "./VectorSearch";
|
|
|
23
25
|
export type Handler<
|
|
24
26
|
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
25
27
|
FunctionSpec_ extends FunctionSpec.AnyWithProps,
|
|
28
|
+
> =
|
|
29
|
+
FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<
|
|
30
|
+
FunctionSpec_,
|
|
31
|
+
FunctionProvenance.AnyConvex
|
|
32
|
+
>
|
|
33
|
+
? ConvexProvenanceHandler<FunctionSpec_>
|
|
34
|
+
: FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<
|
|
35
|
+
FunctionSpec_,
|
|
36
|
+
FunctionProvenance.AnyConfect
|
|
37
|
+
>
|
|
38
|
+
? ConfectProvenanceHandler<DatabaseSchema_, FunctionSpec_>
|
|
39
|
+
: never;
|
|
40
|
+
|
|
41
|
+
type ConvexProvenanceHandler<
|
|
42
|
+
FunctionSpec_ extends
|
|
43
|
+
FunctionSpec.AnyWithPropsWithFunctionProvenance<FunctionProvenance.AnyConvex>,
|
|
44
|
+
> = RegisteredFunction.ConvexRegisteredFunction<FunctionSpec_>;
|
|
45
|
+
|
|
46
|
+
type ConfectProvenanceHandler<
|
|
47
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
48
|
+
FunctionSpec_ extends
|
|
49
|
+
FunctionSpec.AnyWithPropsWithFunctionProvenance<FunctionProvenance.AnyConfect>,
|
|
26
50
|
> =
|
|
27
51
|
FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "query">
|
|
28
|
-
?
|
|
52
|
+
? ConfectProvenanceQuery<DatabaseSchema_, FunctionSpec_>
|
|
29
53
|
: FunctionSpec_ extends FunctionSpec.WithFunctionType<
|
|
30
54
|
FunctionSpec_,
|
|
31
55
|
"mutation"
|
|
32
56
|
>
|
|
33
|
-
?
|
|
57
|
+
? ConfectProvenanceMutation<DatabaseSchema_, FunctionSpec_>
|
|
34
58
|
: FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<
|
|
35
59
|
FunctionSpec_,
|
|
36
60
|
RuntimeAndFunctionType.ConvexAction
|
|
37
61
|
>
|
|
38
|
-
?
|
|
62
|
+
? ConvexRuntimeAction<DatabaseSchema_, FunctionSpec_>
|
|
39
63
|
: FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<
|
|
40
64
|
FunctionSpec_,
|
|
41
65
|
RuntimeAndFunctionType.NodeAction
|
|
42
66
|
>
|
|
43
|
-
?
|
|
67
|
+
? NodeRuntimeAction<DatabaseSchema_, FunctionSpec_>
|
|
44
68
|
: never;
|
|
45
69
|
|
|
46
|
-
export type
|
|
70
|
+
export type ConfectProvenanceQuery<
|
|
47
71
|
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
48
72
|
FunctionSpec_ extends
|
|
49
73
|
FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyQuery>,
|
|
@@ -56,7 +80,7 @@ export type Query<
|
|
|
56
80
|
| QueryCtx.QueryCtx<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>>
|
|
57
81
|
>;
|
|
58
82
|
|
|
59
|
-
export type
|
|
83
|
+
export type ConfectProvenanceMutation<
|
|
60
84
|
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
61
85
|
FunctionSpec_ extends
|
|
62
86
|
FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyMutation>,
|
|
@@ -89,13 +113,13 @@ type ActionServices<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> =
|
|
|
89
113
|
DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>
|
|
90
114
|
>;
|
|
91
115
|
|
|
92
|
-
export type
|
|
116
|
+
export type ConvexRuntimeAction<
|
|
93
117
|
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
94
118
|
FunctionSpec_ extends
|
|
95
119
|
FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyAction>,
|
|
96
120
|
> = Base<FunctionSpec_, ActionServices<DatabaseSchema_>>;
|
|
97
121
|
|
|
98
|
-
export type
|
|
122
|
+
export type NodeRuntimeAction<
|
|
99
123
|
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
100
124
|
FunctionSpec_ extends
|
|
101
125
|
FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.NodeAction>,
|
|
@@ -105,13 +129,14 @@ export type NodeAction<
|
|
|
105
129
|
>;
|
|
106
130
|
|
|
107
131
|
type Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (
|
|
108
|
-
args: FunctionSpec.Args<FunctionSpec_
|
|
109
|
-
) => Effect.Effect<FunctionSpec.Returns<FunctionSpec_
|
|
132
|
+
args: FunctionSpec.Args<FunctionSpec_>,
|
|
133
|
+
) => Effect.Effect<FunctionSpec.Returns<FunctionSpec_>, never, R>;
|
|
110
134
|
|
|
111
|
-
export type
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
135
|
+
export type Any = AnyConfectProvenance | AnyConvexProvenance;
|
|
136
|
+
|
|
137
|
+
export type AnyConfectProvenance = Base<FunctionSpec.AnyConfect, any>;
|
|
138
|
+
|
|
139
|
+
export type AnyConvexProvenance = RegisteredFunction.Any;
|
|
115
140
|
|
|
116
141
|
export type WithName<
|
|
117
142
|
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
package/src/MutationRunner.ts
CHANGED
|
@@ -1,32 +1,46 @@
|
|
|
1
1
|
import * as Ref from "@confect/core/Ref";
|
|
2
2
|
import { type GenericMutationCtx } from "convex/server";
|
|
3
3
|
import type { ParseResult } from "effect";
|
|
4
|
-
import { Context, Effect, Layer, Schema } from "effect";
|
|
4
|
+
import { Context, Effect, Layer, Match, Schema } from "effect";
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const make =
|
|
7
7
|
(runMutation: GenericMutationCtx<any>["runMutation"]) =>
|
|
8
8
|
<Mutation extends Ref.AnyMutation>(
|
|
9
9
|
mutation: Mutation,
|
|
10
|
-
args: Ref.Args<Mutation
|
|
11
|
-
): Effect.Effect<Ref.Returns<Mutation
|
|
10
|
+
args: Ref.Args<Mutation>,
|
|
11
|
+
): Effect.Effect<Ref.Returns<Mutation>, ParseResult.ParseError> =>
|
|
12
12
|
Effect.gen(function* () {
|
|
13
|
-
const
|
|
13
|
+
const functionSpec = Ref.getFunctionSpec(mutation);
|
|
14
14
|
const functionName = Ref.getConvexFunctionName(mutation);
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
return yield* Match.value(functionSpec.functionProvenance).pipe(
|
|
17
|
+
Match.tag("Confect", (confectFunctionSpec) =>
|
|
18
|
+
Effect.gen(function* () {
|
|
19
|
+
const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(
|
|
20
|
+
args,
|
|
21
|
+
);
|
|
22
|
+
const encodedReturns = yield* Effect.promise(() =>
|
|
23
|
+
runMutation(functionName as any, encodedArgs),
|
|
24
|
+
);
|
|
25
|
+
return yield* Schema.decode(confectFunctionSpec.returns)(
|
|
26
|
+
encodedReturns,
|
|
27
|
+
);
|
|
28
|
+
}),
|
|
29
|
+
),
|
|
30
|
+
Match.tag("Convex", () =>
|
|
31
|
+
Effect.promise(() => runMutation(functionName as any, args as any)),
|
|
32
|
+
),
|
|
33
|
+
Match.exhaustive,
|
|
19
34
|
);
|
|
20
|
-
return yield* Schema.decode(function_.returns)(encodedReturns);
|
|
21
35
|
});
|
|
22
36
|
|
|
23
|
-
export const MutationRunner = Context.GenericTag<
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
export const MutationRunner = Context.GenericTag<ReturnType<typeof make>>(
|
|
38
|
+
"@confect/server/MutationRunner",
|
|
39
|
+
);
|
|
26
40
|
export type MutationRunner = typeof MutationRunner.Identifier;
|
|
27
41
|
|
|
28
42
|
export const layer = (runMutation: GenericMutationCtx<any>["runMutation"]) =>
|
|
29
|
-
Layer.succeed(MutationRunner,
|
|
43
|
+
Layer.succeed(MutationRunner, make(runMutation));
|
|
30
44
|
|
|
31
45
|
export class MutationRollback extends Schema.TaggedError<MutationRollback>()(
|
|
32
46
|
"MutationRollback",
|
package/src/QueryRunner.ts
CHANGED
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
import * as Ref from "@confect/core/Ref";
|
|
2
2
|
import { type GenericQueryCtx } from "convex/server";
|
|
3
3
|
import type { ParseResult } from "effect";
|
|
4
|
-
import { Context, Effect, Layer, Schema } from "effect";
|
|
4
|
+
import { Context, Effect, Layer, Match, Schema } from "effect";
|
|
5
5
|
|
|
6
6
|
const make =
|
|
7
7
|
(runQuery: GenericQueryCtx<any>["runQuery"]) =>
|
|
8
8
|
<Query extends Ref.AnyQuery>(
|
|
9
9
|
query: Query,
|
|
10
|
-
args: Ref.Args<Query
|
|
11
|
-
): Effect.Effect<Ref.Returns<Query
|
|
10
|
+
args: Ref.Args<Query>,
|
|
11
|
+
): Effect.Effect<Ref.Returns<Query>, ParseResult.ParseError> =>
|
|
12
12
|
Effect.gen(function* () {
|
|
13
|
-
const
|
|
13
|
+
const functionSpec = Ref.getFunctionSpec(query);
|
|
14
14
|
const functionName = Ref.getConvexFunctionName(query);
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
return yield* Match.value(functionSpec.functionProvenance).pipe(
|
|
17
|
+
Match.tag("Confect", (confectFunctionSpec) =>
|
|
18
|
+
Effect.gen(function* () {
|
|
19
|
+
const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(
|
|
20
|
+
args,
|
|
21
|
+
);
|
|
22
|
+
const encodedReturns = yield* Effect.promise(() =>
|
|
23
|
+
runQuery(functionName as any, encodedArgs),
|
|
24
|
+
);
|
|
25
|
+
return yield* Schema.decode(confectFunctionSpec.returns)(
|
|
26
|
+
encodedReturns,
|
|
27
|
+
);
|
|
28
|
+
}),
|
|
29
|
+
),
|
|
30
|
+
Match.tag("Convex", () =>
|
|
31
|
+
Effect.promise(() => runQuery(functionName as any, args as any)),
|
|
32
|
+
),
|
|
33
|
+
Match.exhaustive,
|
|
19
34
|
);
|
|
20
|
-
return yield* Schema.decode(function_.returns)(encodedReturns);
|
|
21
35
|
});
|
|
22
36
|
|
|
23
37
|
export const QueryRunner = Context.GenericTag<ReturnType<typeof make>>(
|