@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.
Files changed (49) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/ActionRunner.d.ts +2 -2
  3. package/dist/ActionRunner.d.ts.map +1 -1
  4. package/dist/ActionRunner.js +9 -7
  5. package/dist/ActionRunner.js.map +1 -1
  6. package/dist/FunctionImpl.js +2 -2
  7. package/dist/FunctionImpl.js.map +1 -1
  8. package/dist/Handler.d.ts +18 -12
  9. package/dist/Handler.d.ts.map +1 -1
  10. package/dist/Handler.js.map +1 -1
  11. package/dist/MutationRunner.d.ts +2 -2
  12. package/dist/MutationRunner.d.ts.map +1 -1
  13. package/dist/MutationRunner.js +9 -7
  14. package/dist/MutationRunner.js.map +1 -1
  15. package/dist/QueryRunner.d.ts +2 -2
  16. package/dist/QueryRunner.d.ts.map +1 -1
  17. package/dist/QueryRunner.js +7 -5
  18. package/dist/QueryRunner.js.map +1 -1
  19. package/dist/RegisteredConvexFunction.d.ts +4 -4
  20. package/dist/RegisteredConvexFunction.d.ts.map +1 -1
  21. package/dist/RegisteredConvexFunction.js +21 -18
  22. package/dist/RegisteredConvexFunction.js.map +1 -1
  23. package/dist/RegisteredFunction.d.ts +16 -5
  24. package/dist/RegisteredFunction.d.ts.map +1 -1
  25. package/dist/RegisteredFunction.js.map +1 -1
  26. package/dist/RegisteredFunctions.d.ts +4 -4
  27. package/dist/RegisteredFunctions.d.ts.map +1 -1
  28. package/dist/RegisteredFunctions.js.map +1 -1
  29. package/dist/RegisteredNodeFunction.d.ts +3 -3
  30. package/dist/RegisteredNodeFunction.d.ts.map +1 -1
  31. package/dist/RegisteredNodeFunction.js +6 -5
  32. package/dist/RegisteredNodeFunction.js.map +1 -1
  33. package/dist/RegistryItem.d.ts +9 -9
  34. package/dist/RegistryItem.d.ts.map +1 -1
  35. package/dist/RegistryItem.js +2 -2
  36. package/dist/RegistryItem.js.map +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/package.json +4 -4
  39. package/src/ActionRunner.ts +27 -13
  40. package/src/FunctionImpl.ts +3 -3
  41. package/src/Handler.ts +39 -14
  42. package/src/MutationRunner.ts +27 -13
  43. package/src/QueryRunner.ts +22 -8
  44. package/src/RegisteredConvexFunction.ts +52 -41
  45. package/src/RegisteredFunction.ts +86 -1
  46. package/src/RegisteredFunctions.ts +10 -11
  47. package/src/RegisteredNodeFunction.ts +23 -13
  48. package/src/RegistryItem.ts +9 -12
  49. package/src/index.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @confect/server
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5fb6a61: Add support for plain Convex functions. Plain Convex queries, mutations, and actions can now be included in your Confect spec and impl tree using new `FunctionSpec.convexPublic*` and `FunctionSpec.convexInternal*` constructors. This enables interop with Convex components and libraries (such as Workpool, Workflow, Migrations, and Better Auth) that require user-defined or -provided Convex functions.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [5fb6a61]
12
+ - @confect/core@3.0.0
13
+
3
14
  ## 2.0.0
4
15
 
5
16
  ### Minor Changes
@@ -6,9 +6,9 @@ import { GenericActionCtx } from "convex/server";
6
6
  declare namespace ActionRunner_d_exports {
7
7
  export { ActionRunner, layer };
8
8
  }
9
- declare const ActionRunner: Context.Tag<(<Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>["Type"]) => Effect.Effect<Ref$1.Returns<Action>["Type"], ParseResult.ParseError>), <Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>["Type"]) => Effect.Effect<Ref$1.Returns<Action>["Type"], ParseResult.ParseError>>;
9
+ declare const ActionRunner: Context.Tag<(<Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>) => Effect.Effect<Ref$1.Returns<Action>, ParseResult.ParseError>), <Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>) => Effect.Effect<Ref$1.Returns<Action>, ParseResult.ParseError>>;
10
10
  type ActionRunner = typeof ActionRunner.Identifier;
11
- declare const layer: (runAction: GenericActionCtx<any>["runAction"]) => Layer.Layer<(<Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>["Type"]) => Effect.Effect<Ref$1.Returns<Action>["Type"], ParseResult.ParseError>), never, never>;
11
+ declare const layer: (runAction: GenericActionCtx<any>["runAction"]) => Layer.Layer<(<Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>) => Effect.Effect<Ref$1.Returns<Action>, ParseResult.ParseError>), never, never>;
12
12
  //#endregion
13
13
  export { ActionRunner, ActionRunner_d_exports, layer };
14
14
  //# sourceMappingURL=ActionRunner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActionRunner.d.ts","names":[],"sources":["../src/ActionRunner.ts"],"mappings":";;;;;;;;cAsBa,YAAA,EAAY,OAAA,CAAA,GAAA,kBAfP,KAAA,CAAI,SAAA,EAAS,MAAA,EACnB,MAAA,EAAM,IAAA,EACR,KAAA,CAAI,IAAA,CAAK,MAAA,cACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,MAAA,WAAiB,WAAA,CAAY,UAAA,oBAH1C,KAAA,CAAI,SAAA,EAAS,MAAA,EACnB,MAAA,EAAM,IAAA,EACR,KAAA,CAAI,IAAA,CAAK,MAAA,cACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,MAAA,WAAiB,WAAA,CAAY,UAAA;AAAA,KAehD,YAAA,UAAsB,YAAA,CAAa,UAAA;AAAA,cAElC,KAAA,GAAS,SAAA,EAAW,gBAAA,uBAAkC,KAAA,CAAA,KAAA,kBApBjD,KAAA,CAAI,SAAA,EAAS,MAAA,EACnB,MAAA,EAAM,IAAA,EACR,KAAA,CAAI,IAAA,CAAK,MAAA,cACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,MAAA,WAAiB,WAAA,CAAY,UAAA"}
1
+ {"version":3,"file":"ActionRunner.d.ts","names":[],"sources":["../src/ActionRunner.ts"],"mappings":";;;;;;;;cAoCa,YAAA,EAAY,OAAA,CAAA,GAAA,kBA7BP,KAAA,CAAI,SAAA,EAAS,MAAA,EACnB,MAAA,EAAM,IAAA,EACR,KAAA,CAAI,IAAA,CAAK,MAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,MAAA,GAAS,WAAA,CAAY,UAAA,oBAHlC,KAAA,CAAI,SAAA,EAAS,MAAA,EACnB,MAAA,EAAM,IAAA,EACR,KAAA,CAAI,IAAA,CAAK,MAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,MAAA,GAAS,WAAA,CAAY,UAAA;AAAA,KA6BxC,YAAA,UAAsB,YAAA,CAAa,UAAA;AAAA,cAElC,KAAA,GAAS,SAAA,EAAW,gBAAA,uBAAkC,KAAA,CAAA,KAAA,kBAlCjD,KAAA,CAAI,SAAA,EAAS,MAAA,EACnB,MAAA,EAAM,IAAA,EACR,KAAA,CAAI,IAAA,CAAK,MAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,MAAA,GAAS,WAAA,CAAY,UAAA"}
@@ -1,5 +1,5 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- import { Context, Effect, Layer, Schema } from "effect";
2
+ import { Context, Effect, Layer, Match, Schema } from "effect";
3
3
  import * as Ref$1 from "@confect/core/Ref";
4
4
  import "convex/server";
5
5
 
@@ -8,15 +8,17 @@ var ActionRunner_exports = /* @__PURE__ */ __exportAll({
8
8
  ActionRunner: () => ActionRunner,
9
9
  layer: () => layer
10
10
  });
11
- const makeActionRunner = (runAction) => (action, args) => Effect.gen(function* () {
12
- const function_ = Ref$1.getFunction(action);
11
+ const make = (runAction) => (action, args) => Effect.gen(function* () {
12
+ const functionSpec = Ref$1.getFunctionSpec(action);
13
13
  const functionName = Ref$1.getConvexFunctionName(action);
14
- const encodedArgs = yield* Schema.encode(function_.args)(args);
15
- const encodedReturns = yield* Effect.promise(() => runAction(functionName, encodedArgs));
16
- return yield* Schema.decode(function_.returns)(encodedReturns);
14
+ return yield* Match.value(functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionSpec) => Effect.gen(function* () {
15
+ const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(args);
16
+ const encodedReturns = yield* Effect.promise(() => runAction(functionName, encodedArgs));
17
+ return yield* Schema.decode(confectFunctionSpec.returns)(encodedReturns);
18
+ })), Match.tag("Convex", () => Effect.promise(() => runAction(functionName, args))), Match.exhaustive);
17
19
  });
18
20
  const ActionRunner = Context.GenericTag("@confect/server/ActionRunner");
19
- const layer = (runAction) => Layer.succeed(ActionRunner, makeActionRunner(runAction));
21
+ const layer = (runAction) => Layer.succeed(ActionRunner, make(runAction));
20
22
 
21
23
  //#endregion
22
24
  export { ActionRunner, ActionRunner_exports, layer };
@@ -1 +1 @@
1
- {"version":3,"file":"ActionRunner.js","names":["Ref"],"sources":["../src/ActionRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericActionCtx } from \"convex/server\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Schema } from \"effect\";\n\nconst makeActionRunner =\n (runAction: GenericActionCtx<any>[\"runAction\"]) =>\n <Action extends Ref.AnyAction>(\n action: Action,\n args: Ref.Args<Action>[\"Type\"],\n ): Effect.Effect<Ref.Returns<Action>[\"Type\"], ParseResult.ParseError> =>\n Effect.gen(function* () {\n const function_ = Ref.getFunction(action);\n const functionName = Ref.getConvexFunctionName(action);\n\n const encodedArgs = yield* Schema.encode(function_.args)(args);\n const encodedReturns = yield* Effect.promise(() =>\n runAction(functionName as any, encodedArgs),\n );\n return yield* Schema.decode(function_.returns)(encodedReturns);\n });\n\nexport const ActionRunner = Context.GenericTag<\n ReturnType<typeof makeActionRunner>\n>(\"@confect/server/ActionRunner\");\nexport type ActionRunner = typeof ActionRunner.Identifier;\n\nexport const layer = (runAction: GenericActionCtx<any>[\"runAction\"]) =>\n Layer.succeed(ActionRunner, makeActionRunner(runAction));\n"],"mappings":";;;;;;;;;;AAKA,MAAM,oBACH,eAEC,QACA,SAEA,OAAO,IAAI,aAAa;CACtB,MAAM,YAAYA,MAAI,YAAY,OAAO;CACzC,MAAM,eAAeA,MAAI,sBAAsB,OAAO;CAEtD,MAAM,cAAc,OAAO,OAAO,OAAO,UAAU,KAAK,CAAC,KAAK;CAC9D,MAAM,iBAAiB,OAAO,OAAO,cACnC,UAAU,cAAqB,YAAY,CAC5C;AACD,QAAO,OAAO,OAAO,OAAO,UAAU,QAAQ,CAAC,eAAe;EAC9D;AAEN,MAAa,eAAe,QAAQ,WAElC,+BAA+B;AAGjC,MAAa,SAAS,cACpB,MAAM,QAAQ,cAAc,iBAAiB,UAAU,CAAC"}
1
+ {"version":3,"file":"ActionRunner.js","names":["Ref"],"sources":["../src/ActionRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericActionCtx } from \"convex/server\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Match, Schema } from \"effect\";\n\nconst make =\n (runAction: GenericActionCtx<any>[\"runAction\"]) =>\n <Action extends Ref.AnyAction>(\n action: Action,\n args: Ref.Args<Action>,\n ): Effect.Effect<Ref.Returns<Action>, ParseResult.ParseError> =>\n Effect.gen(function* () {\n const functionSpec = Ref.getFunctionSpec(action);\n const functionName = Ref.getConvexFunctionName(action);\n\n return yield* Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionSpec) =>\n Effect.gen(function* () {\n const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(\n args,\n );\n const encodedReturns = yield* Effect.promise(() =>\n runAction(functionName as any, encodedArgs),\n );\n return yield* Schema.decode(confectFunctionSpec.returns)(\n encodedReturns,\n );\n }),\n ),\n Match.tag(\"Convex\", () =>\n Effect.promise(() => runAction(functionName as any, args as any)),\n ),\n Match.exhaustive,\n );\n });\n\nexport const ActionRunner = Context.GenericTag<ReturnType<typeof make>>(\n \"@confect/server/ActionRunner\",\n);\nexport type ActionRunner = typeof ActionRunner.Identifier;\n\nexport const layer = (runAction: GenericActionCtx<any>[\"runAction\"]) =>\n Layer.succeed(ActionRunner, make(runAction));\n"],"mappings":";;;;;;;;;;AAKA,MAAM,QACH,eAEC,QACA,SAEA,OAAO,IAAI,aAAa;CACtB,MAAM,eAAeA,MAAI,gBAAgB,OAAO;CAChD,MAAM,eAAeA,MAAI,sBAAsB,OAAO;AAEtD,QAAO,OAAO,MAAM,MAAM,aAAa,mBAAmB,CAAC,KACzD,MAAM,IAAI,YAAY,wBACpB,OAAO,IAAI,aAAa;EACtB,MAAM,cAAc,OAAO,OAAO,OAAO,oBAAoB,KAAK,CAChE,KACD;EACD,MAAM,iBAAiB,OAAO,OAAO,cACnC,UAAU,cAAqB,YAAY,CAC5C;AACD,SAAO,OAAO,OAAO,OAAO,oBAAoB,QAAQ,CACtD,eACD;GACD,CACH,EACD,MAAM,IAAI,gBACR,OAAO,cAAc,UAAU,cAAqB,KAAY,CAAC,CAClE,EACD,MAAM,WACP;EACD;AAEN,MAAa,eAAe,QAAQ,WAClC,+BACD;AAGD,MAAa,SAAS,cACpB,MAAM,QAAQ,cAAc,KAAK,UAAU,CAAC"}
@@ -13,14 +13,14 @@ const FunctionImpl = ({ groupPath, functionName }) => Context.GenericTag(`@confe
13
13
  const make = (api, groupPath, functionName, handler) => {
14
14
  const groupPathParts = String.split(groupPath, ".");
15
15
  const [firstGroupPathPart, ...restGroupPathParts] = groupPathParts;
16
- const function_ = Array.reduce(restGroupPathParts, api.spec.groups[firstGroupPathPart], (currentGroup, groupPathPart) => currentGroup.groups[groupPathPart]).functions[functionName];
16
+ const functionSpec = Array.reduce(restGroupPathParts, api.spec.groups[firstGroupPathPart], (currentGroup, groupPathPart) => currentGroup.groups[groupPathPart]).functions[functionName];
17
17
  return Layer.effect(FunctionImpl({
18
18
  groupPath,
19
19
  functionName
20
20
  }), Effect.gen(function* () {
21
21
  const registry = yield* Registry;
22
22
  yield* Ref.update(registry, (registryItems) => setNestedProperty(registryItems, [...groupPathParts, functionName], make$1({
23
- function_,
23
+ functionSpec,
24
24
  handler
25
25
  })));
26
26
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionImpl.js","names":["Registry.Registry","RegistryItem.make"],"sources":["../src/FunctionImpl.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupPath from \"@confect/core/GroupPath\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport { Array, Context, Effect, Layer, Ref, String } from \"effect\";\nimport type * as Api from \"./Api\";\nimport type * as Handler from \"./Handler\";\nimport { setNestedProperty } from \"./internal/utils\";\nimport * as Registry from \"./Registry\";\nimport * as RegistryItem from \"./RegistryItem\";\n\nexport interface FunctionImpl<\n GroupPath_ extends string,\n FunctionName extends string,\n> {\n readonly groupPath: GroupPath_;\n readonly functionName: FunctionName;\n}\n\nexport const FunctionImpl = <\n GroupPath_ extends string,\n FunctionName extends string,\n>({\n groupPath,\n functionName,\n}: {\n groupPath: GroupPath_;\n functionName: FunctionName;\n}) =>\n Context.GenericTag<FunctionImpl<GroupPath_, FunctionName>>(\n `@confect/server/FunctionImpl/${groupPath}/${functionName}`,\n );\n\nexport const make = <\n Api_ extends Api.AnyWithProps,\n const GroupPath_ extends GroupPath.All<Api.Groups<Api_>>,\n const FunctionName extends FunctionSpec.Name<\n GroupSpec.Functions<GroupPath.GroupAt<Api.Groups<Api_>, GroupPath_>>\n >,\n>(\n api: Api_,\n groupPath: GroupPath_,\n functionName: FunctionName,\n handler: Handler.WithName<\n Api.Schema<Api_>,\n GroupSpec.Functions<GroupPath.GroupAt<Api.Groups<Api_>, GroupPath_>>,\n FunctionName\n >,\n): Layer.Layer<FunctionImpl<GroupPath_, FunctionName>> => {\n const groupPathParts = String.split(groupPath, \".\");\n const [firstGroupPathPart, ...restGroupPathParts] = groupPathParts;\n\n const group_: GroupSpec.AnyWithProps = Array.reduce(\n restGroupPathParts,\n (api as any).spec.groups[firstGroupPathPart as any]!,\n (currentGroup: any, groupPathPart: any) =>\n currentGroup.groups[groupPathPart],\n );\n\n const function_ = group_.functions[functionName]!;\n\n return Layer.effect(\n FunctionImpl<GroupPath_, FunctionName>({\n groupPath,\n functionName,\n }),\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n\n yield* Ref.update(registry, (registryItems) =>\n setNestedProperty(\n registryItems,\n [...groupPathParts, functionName],\n RegistryItem.make({\n function_,\n handler: handler as Handler.AnyWithProps,\n }),\n ),\n );\n\n return {\n groupPath,\n functionName,\n };\n }),\n );\n};\n\n/**\n * Get the function implementation service type for a specific group path and function name.\n */\nexport type ForGroupPathAndFunction<\n GroupPath_ extends string,\n FunctionName extends string,\n> = FunctionImpl<GroupPath_, FunctionName>;\n\n/**\n * Get all function implementation services required for a group at a given path.\n */\nexport type FromGroupAtPath<\n GroupPath_ extends string,\n Group extends GroupSpec.AnyWithProps,\n> =\n GroupPath.GroupAt<Group, GroupPath_> extends infer GroupAtPath extends\n GroupSpec.AnyWithProps\n ? FunctionSpec.Name<\n GroupSpec.Functions<GroupAtPath>\n > extends infer FunctionNames extends string\n ? FunctionNames extends string\n ? FunctionImpl<GroupPath_, FunctionNames>\n : never\n : never\n : never;\n"],"mappings":";;;;;;;;;;;AAkBA,MAAa,gBAGX,EACA,WACA,mBAKA,QAAQ,WACN,gCAAgC,UAAU,GAAG,eAC9C;AAEH,MAAa,QAOX,KACA,WACA,cACA,YAKwD;CACxD,MAAM,iBAAiB,OAAO,MAAM,WAAW,IAAI;CACnD,MAAM,CAAC,oBAAoB,GAAG,sBAAsB;CASpD,MAAM,YAPiC,MAAM,OAC3C,oBACC,IAAY,KAAK,OAAO,sBACxB,cAAmB,kBAClB,aAAa,OAAO,eACvB,CAEwB,UAAU;AAEnC,QAAO,MAAM,OACX,aAAuC;EACrC;EACA;EACD,CAAC,EACF,OAAO,IAAI,aAAa;EACtB,MAAM,WAAW,OAAOA;AAExB,SAAO,IAAI,OAAO,WAAW,kBAC3B,kBACE,eACA,CAAC,GAAG,gBAAgB,aAAa,EACjCC,OAAkB;GAChB;GACS;GACV,CAAC,CACH,CACF;AAED,SAAO;GACL;GACA;GACD;GACD,CACH"}
1
+ {"version":3,"file":"FunctionImpl.js","names":["Registry.Registry","RegistryItem.make"],"sources":["../src/FunctionImpl.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupPath from \"@confect/core/GroupPath\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport { Array, Context, Effect, Layer, Ref, String } from \"effect\";\nimport type * as Api from \"./Api\";\nimport type * as Handler from \"./Handler\";\nimport { setNestedProperty } from \"./internal/utils\";\nimport * as Registry from \"./Registry\";\nimport * as RegistryItem from \"./RegistryItem\";\n\nexport interface FunctionImpl<\n GroupPath_ extends string,\n FunctionName extends string,\n> {\n readonly groupPath: GroupPath_;\n readonly functionName: FunctionName;\n}\n\nexport const FunctionImpl = <\n GroupPath_ extends string,\n FunctionName extends string,\n>({\n groupPath,\n functionName,\n}: {\n groupPath: GroupPath_;\n functionName: FunctionName;\n}) =>\n Context.GenericTag<FunctionImpl<GroupPath_, FunctionName>>(\n `@confect/server/FunctionImpl/${groupPath}/${functionName}`,\n );\n\nexport const make = <\n Api_ extends Api.AnyWithProps,\n const GroupPath_ extends GroupPath.All<Api.Groups<Api_>>,\n const FunctionName extends FunctionSpec.Name<\n GroupSpec.Functions<GroupPath.GroupAt<Api.Groups<Api_>, GroupPath_>>\n >,\n>(\n api: Api_,\n groupPath: GroupPath_,\n functionName: FunctionName,\n handler: Handler.WithName<\n Api.Schema<Api_>,\n GroupSpec.Functions<GroupPath.GroupAt<Api.Groups<Api_>, GroupPath_>>,\n FunctionName\n >,\n): Layer.Layer<FunctionImpl<GroupPath_, FunctionName>> => {\n const groupPathParts = String.split(groupPath, \".\");\n const [firstGroupPathPart, ...restGroupPathParts] = groupPathParts;\n\n const group_: GroupSpec.AnyWithProps = Array.reduce(\n restGroupPathParts,\n (api as any).spec.groups[firstGroupPathPart as any]!,\n (currentGroup: any, groupPathPart: any) =>\n currentGroup.groups[groupPathPart],\n );\n\n const functionSpec = group_.functions[functionName]!;\n\n return Layer.effect(\n FunctionImpl<GroupPath_, FunctionName>({\n groupPath,\n functionName,\n }),\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n\n yield* Ref.update(registry, (registryItems) =>\n setNestedProperty(\n registryItems,\n [...groupPathParts, functionName],\n RegistryItem.make({\n functionSpec,\n handler,\n }),\n ),\n );\n\n return {\n groupPath,\n functionName,\n };\n }),\n );\n};\n\n/**\n * Get the function implementation service type for a specific group path and function name.\n */\nexport type ForGroupPathAndFunction<\n GroupPath_ extends string,\n FunctionName extends string,\n> = FunctionImpl<GroupPath_, FunctionName>;\n\n/**\n * Get all function implementation services required for a group at a given path.\n */\nexport type FromGroupAtPath<\n GroupPath_ extends string,\n Group extends GroupSpec.AnyWithProps,\n> =\n GroupPath.GroupAt<Group, GroupPath_> extends infer GroupAtPath extends\n GroupSpec.AnyWithProps\n ? FunctionSpec.Name<\n GroupSpec.Functions<GroupAtPath>\n > extends infer FunctionNames extends string\n ? FunctionNames extends string\n ? FunctionImpl<GroupPath_, FunctionNames>\n : never\n : never\n : never;\n"],"mappings":";;;;;;;;;;;AAkBA,MAAa,gBAGX,EACA,WACA,mBAKA,QAAQ,WACN,gCAAgC,UAAU,GAAG,eAC9C;AAEH,MAAa,QAOX,KACA,WACA,cACA,YAKwD;CACxD,MAAM,iBAAiB,OAAO,MAAM,WAAW,IAAI;CACnD,MAAM,CAAC,oBAAoB,GAAG,sBAAsB;CASpD,MAAM,eAPiC,MAAM,OAC3C,oBACC,IAAY,KAAK,OAAO,sBACxB,cAAmB,kBAClB,aAAa,OAAO,eACvB,CAE2B,UAAU;AAEtC,QAAO,MAAM,OACX,aAAuC;EACrC;EACA;EACD,CAAC,EACF,OAAO,IAAI,aAAa;EACtB,MAAM,WAAW,OAAOA;AAExB,SAAO,IAAI,OAAO,WAAW,kBAC3B,kBACE,eACA,CAAC,GAAG,gBAAgB,aAAa,EACjCC,OAAkB;GAChB;GACA;GACD,CAAC,CACH,CACF;AAED,SAAO;GACL;GACA;GACD;GACD,CACH"}
package/dist/Handler.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ActionCtx } from "./ActionCtx.js";
2
2
  import { ActionRunner } from "./ActionRunner.js";
3
- import { AnyWithProps as AnyWithProps$1 } from "./DatabaseSchema.js";
3
+ import { AnyWithProps } from "./DatabaseSchema.js";
4
4
  import { Auth } from "./Auth.js";
5
5
  import { FromSchema, ToConvex } from "./DataModel.js";
6
6
  import { DatabaseReader } from "./DatabaseReader.js";
@@ -12,23 +12,29 @@ import { QueryRunner } from "./QueryRunner.js";
12
12
  import { Scheduler } from "./Scheduler.js";
13
13
  import { StorageActionWriter, StorageReader, StorageWriter } from "./Storage.js";
14
14
  import { VectorSearch } from "./VectorSearch.js";
15
+ import { Any as Any$1, ConvexRegisteredFunction } from "./RegisteredFunction.js";
15
16
  import { Effect } from "effect";
16
17
  import { NodeContext } from "@effect/platform-node";
17
18
  import { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
19
+ import * as FunctionProvenance from "@confect/core/FunctionProvenance";
18
20
 
19
21
  //#region src/Handler.d.ts
20
22
  declare namespace Handler_d_exports {
21
- export { AnyWithProps, ConvexAction, Handler, Mutation, NodeAction, Query, WithName };
23
+ export { Any, AnyConfectProvenance, AnyConvexProvenance, ConfectProvenanceMutation, ConfectProvenanceQuery, ConvexRuntimeAction, Handler, NodeRuntimeAction, WithName };
22
24
  }
23
- type Handler<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "query"> ? Query<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "mutation"> ? Mutation<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<FunctionSpec_, RuntimeAndFunctionType.ConvexAction> ? ConvexAction<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<FunctionSpec_, RuntimeAndFunctionType.NodeAction> ? NodeAction<DatabaseSchema_, FunctionSpec_> : never;
24
- type Query<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyQuery>> = Base<FunctionSpec_, DatabaseReader<DatabaseSchema_> | Auth | StorageReader | QueryRunner | QueryCtx<ToConvex<FromSchema<DatabaseSchema_>>>>;
25
- type Mutation<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyMutation>> = Base<FunctionSpec_, DatabaseReader<DatabaseSchema_> | DatabaseWriter<DatabaseSchema_> | Auth | Scheduler | StorageReader | StorageWriter | QueryRunner | MutationRunner | MutationCtx<ToConvex<FromSchema<DatabaseSchema_>>>>;
26
- type ActionServices<DatabaseSchema_ extends AnyWithProps$1> = Scheduler | Auth | StorageReader | StorageWriter | StorageActionWriter | QueryRunner | MutationRunner | ActionRunner | VectorSearch<FromSchema<DatabaseSchema_>> | ActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>;
27
- type ConvexAction<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyAction>> = Base<FunctionSpec_, ActionServices<DatabaseSchema_>>;
28
- type NodeAction<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.NodeAction>> = Base<FunctionSpec_, ActionServices<DatabaseSchema_> | NodeContext.NodeContext>;
29
- type Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (args: FunctionSpec.Args<FunctionSpec_>["Type"]) => Effect.Effect<FunctionSpec.Returns<FunctionSpec_>["Type"], never, R>;
30
- type AnyWithProps = Handler<AnyWithProps$1, FunctionSpec.AnyWithProps>;
31
- type WithName<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithProps, FunctionName extends string> = Handler<DatabaseSchema_, FunctionSpec.WithName<FunctionSpec_, FunctionName>>;
25
+ type Handler<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<FunctionSpec_, FunctionProvenance.AnyConvex> ? ConvexProvenanceHandler<FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<FunctionSpec_, FunctionProvenance.AnyConfect> ? ConfectProvenanceHandler<DatabaseSchema_, FunctionSpec_> : never;
26
+ type ConvexProvenanceHandler<FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionProvenance<FunctionProvenance.AnyConvex>> = ConvexRegisteredFunction<FunctionSpec_>;
27
+ type ConfectProvenanceHandler<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionProvenance<FunctionProvenance.AnyConfect>> = FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "query"> ? ConfectProvenanceQuery<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "mutation"> ? ConfectProvenanceMutation<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<FunctionSpec_, RuntimeAndFunctionType.ConvexAction> ? ConvexRuntimeAction<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<FunctionSpec_, RuntimeAndFunctionType.NodeAction> ? NodeRuntimeAction<DatabaseSchema_, FunctionSpec_> : never;
28
+ type ConfectProvenanceQuery<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyQuery>> = Base<FunctionSpec_, DatabaseReader<DatabaseSchema_> | Auth | StorageReader | QueryRunner | QueryCtx<ToConvex<FromSchema<DatabaseSchema_>>>>;
29
+ type ConfectProvenanceMutation<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyMutation>> = Base<FunctionSpec_, DatabaseReader<DatabaseSchema_> | DatabaseWriter<DatabaseSchema_> | Auth | Scheduler | StorageReader | StorageWriter | QueryRunner | MutationRunner | MutationCtx<ToConvex<FromSchema<DatabaseSchema_>>>>;
30
+ type ActionServices<DatabaseSchema_ extends AnyWithProps> = Scheduler | Auth | StorageReader | StorageWriter | StorageActionWriter | QueryRunner | MutationRunner | ActionRunner | VectorSearch<FromSchema<DatabaseSchema_>> | ActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>;
31
+ type ConvexRuntimeAction<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyAction>> = Base<FunctionSpec_, ActionServices<DatabaseSchema_>>;
32
+ type NodeRuntimeAction<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.NodeAction>> = Base<FunctionSpec_, ActionServices<DatabaseSchema_> | NodeContext.NodeContext>;
33
+ type Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (args: FunctionSpec.Args<FunctionSpec_>) => Effect.Effect<FunctionSpec.Returns<FunctionSpec_>, never, R>;
34
+ type Any = AnyConfectProvenance | AnyConvexProvenance;
35
+ type AnyConfectProvenance = Base<FunctionSpec.AnyConfect, any>;
36
+ type AnyConvexProvenance = Any$1;
37
+ type WithName<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithProps, FunctionName extends string> = Handler<DatabaseSchema_, FunctionSpec.WithName<FunctionSpec_, FunctionName>>;
32
38
  //#endregion
33
- export { AnyWithProps, ConvexAction, Handler, Handler_d_exports, Mutation, NodeAction, Query, WithName };
39
+ export { Any, AnyConfectProvenance, AnyConvexProvenance, ConfectProvenanceMutation, ConfectProvenanceQuery, ConvexRuntimeAction, Handler, Handler_d_exports, NodeRuntimeAction, WithName };
34
40
  //# sourceMappingURL=Handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Handler.d.ts","names":[],"sources":["../src/Handler.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;KAsBY,OAAA,yBACc,cAAA,wBACF,YAAA,CAAa,YAAA,IAEnC,aAAA,SAAsB,YAAA,CAAa,gBAAA,CAAiB,aAAA,aAChD,KAAA,CAAM,eAAA,EAAiB,aAAA,IACvB,aAAA,SAAsB,YAAA,CAAa,gBAAA,CAC/B,aAAA,gBAGF,QAAA,CAAS,eAAA,EAAiB,aAAA,IAC1B,aAAA,SAAsB,YAAA,CAAa,0BAAA,CAC/B,aAAA,EACA,sBAAA,CAAuB,YAAA,IAEzB,YAAA,CAAa,eAAA,EAAiB,aAAA,IAC9B,aAAA,SAAsB,YAAA,CAAa,0BAAA,CAC/B,aAAA,EACA,sBAAA,CAAuB,UAAA,IAEzB,UAAA,CAAW,eAAA,EAAiB,aAAA;AAAA,KAG5B,KAAA,yBACc,cAAA,wBAEtB,YAAA,CAAa,4BAAA,CAA6B,sBAAA,CAAuB,QAAA,KACjE,IAAA,CACF,aAAA,EACE,cAAA,CAA8B,eAAA,IAC9B,IAAA,GACA,aAAA,GACA,WAAA,GACA,QAAA,CAAkB,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,KAGlD,QAAA,yBACc,cAAA,wBAEtB,YAAA,CAAa,4BAAA,CAA6B,sBAAA,CAAuB,WAAA,KACjE,IAAA,CACF,aAA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CACE,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,KAIzC,cAAA,yBAAuC,YAAA,IACxC,SAAA,GACA,IAAA,GACA,aAAA,GACA,aAAA,GACA,mBAAA,GACA,WAAA,GACA,cAAA,GACA,YAAA,GACA,YAAA,CAA0B,UAAA,CAAqB,eAAA,KAC/C,SAAA,CACE,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,KAGlC,mBAAA,yBACc,YAAA,wBAEtB,YAAA,CAAa,4BAAA,CAA6B,sBAAA,CAAuB,SAAA,KACjE,IAAA,CAAK,aAAA,EAAe,cAAA,CAAe,eAAA;AAAA,KAE3B,iBAAA,yBACc,YAAA,wBAEtB,YAAA,CAAa,4BAAA,CAA6B,sBAAA,CAAuB,UAAA,KACjE,IAAA,CACF,aAAA,EACA,cAAA,CAAe,eAAA,IAAmB,WAAA,CAAY,WAAA;AAAA,KAG3C,IAAA,uBAA2B,YAAA,CAAa,YAAA,QAC3C,IAAA,EAAM,YAAA,CAAa,IAAA,CAAK,aAAA,MACrB,MAAA,CAAO,MAAA,CAAO,YAAA,CAAa,OAAA,CAAQ,aAAA,UAAuB,CAAA;AAAA,KAEnD,GAAA,GAAM,oBAAA,GAAuB,mBAAA;AAAA,KAE7B,oBAAA,GAAuB,IAAA,CAAK,YAAA,CAAa,UAAA;AAAA,KAEzC,mBAAA,GAAsB,KAAA;AAAA,KAEtB,QAAA,yBACc,YAAA,wBACF,YAAA,CAAa,YAAA,iCAEjC,OAAA,CACF,eAAA,EACA,YAAA,CAAa,QAAA,CAAS,aAAA,EAAe,YAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Handler.js","names":[],"sources":["../src/Handler.ts"],"sourcesContent":["import type { FunctionSpec, RuntimeAndFunctionType } from \"@confect/core\";\nimport type { NodeContext } from \"@effect/platform-node\";\nimport type { Effect } from \"effect\";\nimport type * as ActionCtx from \"./ActionCtx\";\nimport type * as ActionRunner from \"./ActionRunner\";\nimport type * as Auth from \"./Auth\";\nimport type * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport type * as MutationCtx from \"./MutationCtx\";\nimport type * as MutationRunner from \"./MutationRunner\";\nimport type * as QueryCtx from \"./QueryCtx\";\nimport type * as QueryRunner from \"./QueryRunner\";\nimport type * as Scheduler from \"./Scheduler\";\nimport type {\n StorageActionWriter,\n StorageReader,\n StorageWriter,\n} from \"./Storage\";\nimport type * as VectorSearch from \"./VectorSearch\";\n\nexport type Handler<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, \"query\">\n ? Query<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionType<\n FunctionSpec_,\n \"mutation\"\n >\n ? Mutation<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<\n FunctionSpec_,\n RuntimeAndFunctionType.ConvexAction\n >\n ? ConvexAction<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<\n FunctionSpec_,\n RuntimeAndFunctionType.NodeAction\n >\n ? NodeAction<DatabaseSchema_, FunctionSpec_>\n : never;\n\nexport type Query<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyQuery>,\n> = Base<\n FunctionSpec_,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | Auth.Auth\n | StorageReader\n | QueryRunner.QueryRunner\n | QueryCtx.QueryCtx<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>>\n>;\n\nexport type Mutation<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyMutation>,\n> = Base<\n FunctionSpec_,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | DatabaseWriter.DatabaseWriter<DatabaseSchema_>\n | Auth.Auth\n | Scheduler.Scheduler\n | StorageReader\n | StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | MutationCtx.MutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >\n>;\n\ntype ActionServices<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> =\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 type ConvexAction<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyAction>,\n> = Base<FunctionSpec_, ActionServices<DatabaseSchema_>>;\n\nexport type NodeAction<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.NodeAction>,\n> = Base<\n FunctionSpec_,\n ActionServices<DatabaseSchema_> | NodeContext.NodeContext\n>;\n\ntype Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (\n args: FunctionSpec.Args<FunctionSpec_>[\"Type\"],\n) => Effect.Effect<FunctionSpec.Returns<FunctionSpec_>[\"Type\"], never, R>;\n\nexport type AnyWithProps = Handler<\n DatabaseSchema.AnyWithProps,\n FunctionSpec.AnyWithProps\n>;\n\nexport type WithName<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n FunctionName extends string,\n> = Handler<\n DatabaseSchema_,\n FunctionSpec.WithName<FunctionSpec_, FunctionName>\n>;\n"],"mappings":""}
1
+ {"version":3,"file":"Handler.js","names":[],"sources":["../src/Handler.ts"],"sourcesContent":["import type { FunctionSpec, RuntimeAndFunctionType } from \"@confect/core\";\nimport type * as FunctionProvenance from \"@confect/core/FunctionProvenance\";\nimport type { NodeContext } from \"@effect/platform-node\";\nimport type { Effect } from \"effect\";\nimport type * as ActionCtx from \"./ActionCtx\";\nimport type * as ActionRunner from \"./ActionRunner\";\nimport type * as Auth from \"./Auth\";\nimport type * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport type * as MutationCtx from \"./MutationCtx\";\nimport type * as MutationRunner from \"./MutationRunner\";\nimport type * as QueryCtx from \"./QueryCtx\";\nimport type * as QueryRunner from \"./QueryRunner\";\nimport type * as RegisteredFunction from \"./RegisteredFunction\";\nimport type * as Scheduler from \"./Scheduler\";\nimport type {\n StorageActionWriter,\n StorageReader,\n StorageWriter,\n} from \"./Storage\";\nimport type * as VectorSearch from \"./VectorSearch\";\n\nexport type Handler<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConvex\n >\n ? ConvexProvenanceHandler<FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConfect\n >\n ? ConfectProvenanceHandler<DatabaseSchema_, FunctionSpec_>\n : never;\n\ntype ConvexProvenanceHandler<\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionProvenance<FunctionProvenance.AnyConvex>,\n> = RegisteredFunction.ConvexRegisteredFunction<FunctionSpec_>;\n\ntype ConfectProvenanceHandler<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionProvenance<FunctionProvenance.AnyConfect>,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, \"query\">\n ? ConfectProvenanceQuery<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionType<\n FunctionSpec_,\n \"mutation\"\n >\n ? ConfectProvenanceMutation<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<\n FunctionSpec_,\n RuntimeAndFunctionType.ConvexAction\n >\n ? ConvexRuntimeAction<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<\n FunctionSpec_,\n RuntimeAndFunctionType.NodeAction\n >\n ? NodeRuntimeAction<DatabaseSchema_, FunctionSpec_>\n : never;\n\nexport type ConfectProvenanceQuery<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyQuery>,\n> = Base<\n FunctionSpec_,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | Auth.Auth\n | StorageReader\n | QueryRunner.QueryRunner\n | QueryCtx.QueryCtx<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>>\n>;\n\nexport type ConfectProvenanceMutation<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyMutation>,\n> = Base<\n FunctionSpec_,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | DatabaseWriter.DatabaseWriter<DatabaseSchema_>\n | Auth.Auth\n | Scheduler.Scheduler\n | StorageReader\n | StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | MutationCtx.MutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >\n>;\n\ntype ActionServices<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> =\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 type ConvexRuntimeAction<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyAction>,\n> = Base<FunctionSpec_, ActionServices<DatabaseSchema_>>;\n\nexport type NodeRuntimeAction<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.NodeAction>,\n> = Base<\n FunctionSpec_,\n ActionServices<DatabaseSchema_> | NodeContext.NodeContext\n>;\n\ntype Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (\n args: FunctionSpec.Args<FunctionSpec_>,\n) => Effect.Effect<FunctionSpec.Returns<FunctionSpec_>, never, R>;\n\nexport type Any = AnyConfectProvenance | AnyConvexProvenance;\n\nexport type AnyConfectProvenance = Base<FunctionSpec.AnyConfect, any>;\n\nexport type AnyConvexProvenance = RegisteredFunction.Any;\n\nexport type WithName<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n FunctionName extends string,\n> = Handler<\n DatabaseSchema_,\n FunctionSpec.WithName<FunctionSpec_, FunctionName>\n>;\n"],"mappings":""}
@@ -6,9 +6,9 @@ import { GenericMutationCtx } from "convex/server";
6
6
  declare namespace MutationRunner_d_exports {
7
7
  export { MutationRollback, MutationRunner, layer };
8
8
  }
9
- declare const MutationRunner: Context.Tag<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>["Type"]) => Effect.Effect<Ref$1.Returns<Mutation>["Type"], ParseResult.ParseError>), <Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>["Type"]) => Effect.Effect<Ref$1.Returns<Mutation>["Type"], ParseResult.ParseError>>;
9
+ declare const MutationRunner: Context.Tag<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>) => Effect.Effect<Ref$1.Returns<Mutation>, ParseResult.ParseError>), <Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>) => Effect.Effect<Ref$1.Returns<Mutation>, ParseResult.ParseError>>;
10
10
  type MutationRunner = typeof MutationRunner.Identifier;
11
- declare const layer: (runMutation: GenericMutationCtx<any>["runMutation"]) => Layer.Layer<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>["Type"]) => Effect.Effect<Ref$1.Returns<Mutation>["Type"], ParseResult.ParseError>), never, never>;
11
+ declare const layer: (runMutation: GenericMutationCtx<any>["runMutation"]) => Layer.Layer<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>) => Effect.Effect<Ref$1.Returns<Mutation>, ParseResult.ParseError>), never, never>;
12
12
  declare const MutationRollback_base: Schema.TaggedErrorClass<MutationRollback, "MutationRollback", {
13
13
  readonly _tag: Schema.tag<"MutationRollback">;
14
14
  } & {
@@ -1 +1 @@
1
- {"version":3,"file":"MutationRunner.d.ts","names":[],"sources":["../src/MutationRunner.ts"],"mappings":";;;;;;;;cAsBa,cAAA,EAAc,OAAA,CAAA,GAAA,oBAfP,KAAA,CAAI,WAAA,EAAW,QAAA,EACrB,QAAA,EAAQ,IAAA,EACZ,KAAA,CAAI,IAAA,CAAK,QAAA,cACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CA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A,EAAW,QAAA,EACrB,QAAA,EAAQ,IAAA,EACZ,KAAA,CAAI,IAAA,CAAK,QAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,QAAA,GAAW,WAAA,CAAY,UAAA;AAAA,cAgCH,qBAAA;;;;;;cAEtC,gBAAA,SAAyB,qBAAA;EAAA,IAQvB,OAAA,CAAA;AAAA"}
@@ -1,5 +1,5 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- import { Context, Effect, Layer, Schema } from "effect";
2
+ import { Context, Effect, Layer, Match, Schema } from "effect";
3
3
  import * as Ref$1 from "@confect/core/Ref";
4
4
  import "convex/server";
5
5
 
@@ -9,15 +9,17 @@ var MutationRunner_exports = /* @__PURE__ */ __exportAll({
9
9
  MutationRunner: () => MutationRunner,
10
10
  layer: () => layer
11
11
  });
12
- const makeMutationRunner = (runMutation) => (mutation, args) => Effect.gen(function* () {
13
- const function_ = Ref$1.getFunction(mutation);
12
+ const make = (runMutation) => (mutation, args) => Effect.gen(function* () {
13
+ const functionSpec = Ref$1.getFunctionSpec(mutation);
14
14
  const functionName = Ref$1.getConvexFunctionName(mutation);
15
- const encodedArgs = yield* Schema.encode(function_.args)(args);
16
- const encodedReturns = yield* Effect.promise(() => runMutation(functionName, encodedArgs));
17
- return yield* Schema.decode(function_.returns)(encodedReturns);
15
+ return yield* Match.value(functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionSpec) => Effect.gen(function* () {
16
+ const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(args);
17
+ const encodedReturns = yield* Effect.promise(() => runMutation(functionName, encodedArgs));
18
+ return yield* Schema.decode(confectFunctionSpec.returns)(encodedReturns);
19
+ })), Match.tag("Convex", () => Effect.promise(() => runMutation(functionName, args))), Match.exhaustive);
18
20
  });
19
21
  const MutationRunner = Context.GenericTag("@confect/server/MutationRunner");
20
- const layer = (runMutation) => Layer.succeed(MutationRunner, makeMutationRunner(runMutation));
22
+ const layer = (runMutation) => Layer.succeed(MutationRunner, make(runMutation));
21
23
  var MutationRollback = class extends Schema.TaggedError()("MutationRollback", {
22
24
  mutationName: Schema.String,
23
25
  error: Schema.Unknown
@@ -1 +1 @@
1
- {"version":3,"file":"MutationRunner.js","names":["Ref"],"sources":["../src/MutationRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericMutationCtx } from \"convex/server\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Schema } from \"effect\";\n\nconst makeMutationRunner =\n (runMutation: GenericMutationCtx<any>[\"runMutation\"]) =>\n <Mutation extends Ref.AnyMutation>(\n mutation: Mutation,\n args: Ref.Args<Mutation>[\"Type\"],\n ): Effect.Effect<Ref.Returns<Mutation>[\"Type\"], ParseResult.ParseError> =>\n Effect.gen(function* () {\n const function_ = Ref.getFunction(mutation);\n const functionName = Ref.getConvexFunctionName(mutation);\n\n const encodedArgs = yield* Schema.encode(function_.args)(args);\n const encodedReturns = yield* Effect.promise(() =>\n runMutation(functionName as any, encodedArgs),\n );\n return yield* Schema.decode(function_.returns)(encodedReturns);\n });\n\nexport const MutationRunner = Context.GenericTag<\n ReturnType<typeof makeMutationRunner>\n>(\"@confect/server/MutationRunner\");\nexport type MutationRunner = typeof MutationRunner.Identifier;\n\nexport const layer = (runMutation: GenericMutationCtx<any>[\"runMutation\"]) =>\n Layer.succeed(MutationRunner, makeMutationRunner(runMutation));\n\nexport class MutationRollback extends Schema.TaggedError<MutationRollback>()(\n \"MutationRollback\",\n {\n mutationName: Schema.String,\n error: Schema.Unknown,\n },\n) {\n /* v8 ignore start */\n override get message(): string {\n return `Mutation ${this.mutationName} failed and was rolled back.\\n\\n${this.error}`;\n }\n /* v8 ignore stop */\n}\n"],"mappings":";;;;;;;;;;;AAKA,MAAM,sBACH,iBAEC,UACA,SAEA,OAAO,IAAI,aAAa;CACtB,MAAM,YAAYA,MAAI,YAAY,SAAS;CAC3C,MAAM,eAAeA,MAAI,sBAAsB,SAAS;CAExD,MAAM,cAAc,OAAO,OAAO,OAAO,UAAU,KAAK,CAAC,KAAK;CAC9D,MAAM,iBAAiB,OAAO,OAAO,cACnC,YAAY,cAAqB,YAAY,CAC9C;AACD,QAAO,OAAO,OAAO,OAAO,UAAU,QAAQ,CAAC,eAAe;EAC9D;AAEN,MAAa,iBAAiB,QAAQ,WAEpC,iCAAiC;AAGnC,MAAa,SAAS,gBACpB,MAAM,QAAQ,gBAAgB,mBAAmB,YAAY,CAAC;AAEhE,IAAa,mBAAb,cAAsC,OAAO,aAA+B,CAC1E,oBACA;CACE,cAAc,OAAO;CACrB,OAAO,OAAO;CACf,CACF,CAAC;;CAEA,IAAa,UAAkB;AAC7B,SAAO,YAAY,KAAK,aAAa,kCAAkC,KAAK"}
1
+ {"version":3,"file":"MutationRunner.js","names":["Ref"],"sources":["../src/MutationRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericMutationCtx } from \"convex/server\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Match, Schema } from \"effect\";\n\nconst make =\n (runMutation: GenericMutationCtx<any>[\"runMutation\"]) =>\n <Mutation extends Ref.AnyMutation>(\n mutation: Mutation,\n args: Ref.Args<Mutation>,\n ): Effect.Effect<Ref.Returns<Mutation>, ParseResult.ParseError> =>\n Effect.gen(function* () {\n const functionSpec = Ref.getFunctionSpec(mutation);\n const functionName = Ref.getConvexFunctionName(mutation);\n\n return yield* Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionSpec) =>\n Effect.gen(function* () {\n const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(\n args,\n );\n const encodedReturns = yield* Effect.promise(() =>\n runMutation(functionName as any, encodedArgs),\n );\n return yield* Schema.decode(confectFunctionSpec.returns)(\n encodedReturns,\n );\n }),\n ),\n Match.tag(\"Convex\", () =>\n Effect.promise(() => runMutation(functionName as any, args as any)),\n ),\n Match.exhaustive,\n );\n });\n\nexport const MutationRunner = Context.GenericTag<ReturnType<typeof make>>(\n \"@confect/server/MutationRunner\",\n);\nexport type MutationRunner = typeof MutationRunner.Identifier;\n\nexport const layer = (runMutation: GenericMutationCtx<any>[\"runMutation\"]) =>\n Layer.succeed(MutationRunner, make(runMutation));\n\nexport class MutationRollback extends Schema.TaggedError<MutationRollback>()(\n \"MutationRollback\",\n {\n mutationName: Schema.String,\n error: Schema.Unknown,\n },\n) {\n /* v8 ignore start */\n override get message(): string {\n return `Mutation ${this.mutationName} failed and was rolled back.\\n\\n${this.error}`;\n }\n /* v8 ignore stop */\n}\n"],"mappings":";;;;;;;;;;;AAKA,MAAM,QACH,iBAEC,UACA,SAEA,OAAO,IAAI,aAAa;CACtB,MAAM,eAAeA,MAAI,gBAAgB,SAAS;CAClD,MAAM,eAAeA,MAAI,sBAAsB,SAAS;AAExD,QAAO,OAAO,MAAM,MAAM,aAAa,mBAAmB,CAAC,KACzD,MAAM,IAAI,YAAY,wBACpB,OAAO,IAAI,aAAa;EACtB,MAAM,cAAc,OAAO,OAAO,OAAO,oBAAoB,KAAK,CAChE,KACD;EACD,MAAM,iBAAiB,OAAO,OAAO,cACnC,YAAY,cAAqB,YAAY,CAC9C;AACD,SAAO,OAAO,OAAO,OAAO,oBAAoB,QAAQ,CACtD,eACD;GACD,CACH,EACD,MAAM,IAAI,gBACR,OAAO,cAAc,YAAY,cAAqB,KAAY,CAAC,CACpE,EACD,MAAM,WACP;EACD;AAEN,MAAa,iBAAiB,QAAQ,WACpC,iCACD;AAGD,MAAa,SAAS,gBACpB,MAAM,QAAQ,gBAAgB,KAAK,YAAY,CAAC;AAElD,IAAa,mBAAb,cAAsC,OAAO,aAA+B,CAC1E,oBACA;CACE,cAAc,OAAO;CACrB,OAAO,OAAO;CACf,CACF,CAAC;;CAEA,IAAa,UAAkB;AAC7B,SAAO,YAAY,KAAK,aAAa,kCAAkC,KAAK"}
@@ -6,9 +6,9 @@ import { GenericQueryCtx } from "convex/server";
6
6
  declare namespace QueryRunner_d_exports {
7
7
  export { QueryRunner, layer };
8
8
  }
9
- declare const QueryRunner: Context.Tag<(<Query extends Ref$1.AnyQuery>(query: Query, args: Ref$1.Args<Query>["Type"]) => Effect.Effect<Ref$1.Returns<Query>["Type"], ParseResult.ParseError>), <Query extends Ref$1.AnyQuery>(query: Query, args: Ref$1.Args<Query>["Type"]) => Effect.Effect<Ref$1.Returns<Query>["Type"], ParseResult.ParseError>>;
9
+ declare const QueryRunner: Context.Tag<(<Query extends Ref$1.AnyQuery>(query: Query, args: Ref$1.Args<Query>) => Effect.Effect<Ref$1.Returns<Query>, ParseResult.ParseError>), <Query extends Ref$1.AnyQuery>(query: Query, args: Ref$1.Args<Query>) => Effect.Effect<Ref$1.Returns<Query>, ParseResult.ParseError>>;
10
10
  type QueryRunner = typeof QueryRunner.Identifier;
11
- declare const layer: (runQuery: GenericQueryCtx<any>["runQuery"]) => Layer.Layer<(<Query extends Ref$1.AnyQuery>(query: Query, args: Ref$1.Args<Query>["Type"]) => Effect.Effect<Ref$1.Returns<Query>["Type"], ParseResult.ParseError>), never, never>;
11
+ declare const layer: (runQuery: GenericQueryCtx<any>["runQuery"]) => Layer.Layer<(<Query extends Ref$1.AnyQuery>(query: Query, args: Ref$1.Args<Query>) => Effect.Effect<Ref$1.Returns<Query>, ParseResult.ParseError>), never, never>;
12
12
  //#endregion
13
13
  export { QueryRunner, QueryRunner_d_exports, layer };
14
14
  //# sourceMappingURL=QueryRunner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"QueryRunner.d.ts","names":[],"sources":["../src/QueryRunner.ts"],"mappings":";;;;;;;;cAsBa,WAAA,EAAW,OAAA,CAAA,GAAA,iBAfP,KAAA,CAAI,QAAA,EAAQ,KAAA,EAClB,KAAA,EAAK,IAAA,EACN,KAAA,CAAI,IAAA,CAAK,KAAA,cACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,KAAA,WAAgB,WAAA,CAAY,UAAA,mBAH1C,KAAA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,WAAA,CAAY,UAAA"}
@@ -1,5 +1,5 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- import { Context, Effect, Layer, Schema } from "effect";
2
+ import { Context, Effect, Layer, Match, Schema } from "effect";
3
3
  import * as Ref$1 from "@confect/core/Ref";
4
4
  import "convex/server";
5
5
 
@@ -9,11 +9,13 @@ var QueryRunner_exports = /* @__PURE__ */ __exportAll({
9
9
  layer: () => layer
10
10
  });
11
11
  const make = (runQuery) => (query, args) => Effect.gen(function* () {
12
- const function_ = Ref$1.getFunction(query);
12
+ const functionSpec = Ref$1.getFunctionSpec(query);
13
13
  const functionName = Ref$1.getConvexFunctionName(query);
14
- const encodedArgs = yield* Schema.encode(function_.args)(args);
15
- const encodedReturns = yield* Effect.promise(() => runQuery(functionName, encodedArgs));
16
- return yield* Schema.decode(function_.returns)(encodedReturns);
14
+ return yield* Match.value(functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionSpec) => Effect.gen(function* () {
15
+ const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(args);
16
+ const encodedReturns = yield* Effect.promise(() => runQuery(functionName, encodedArgs));
17
+ return yield* Schema.decode(confectFunctionSpec.returns)(encodedReturns);
18
+ })), Match.tag("Convex", () => Effect.promise(() => runQuery(functionName, args))), Match.exhaustive);
17
19
  });
18
20
  const QueryRunner = Context.GenericTag("@confect/server/QueryRunner");
19
21
  const layer = (runQuery) => Layer.succeed(QueryRunner, make(runQuery));
@@ -1 +1 @@
1
- {"version":3,"file":"QueryRunner.js","names":["Ref"],"sources":["../src/QueryRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericQueryCtx } from \"convex/server\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Schema } from \"effect\";\n\nconst make =\n (runQuery: GenericQueryCtx<any>[\"runQuery\"]) =>\n <Query extends Ref.AnyQuery>(\n query: Query,\n args: Ref.Args<Query>[\"Type\"],\n ): Effect.Effect<Ref.Returns<Query>[\"Type\"], ParseResult.ParseError> =>\n Effect.gen(function* () {\n const function_ = Ref.getFunction(query);\n const functionName = Ref.getConvexFunctionName(query);\n\n const encodedArgs = yield* Schema.encode(function_.args)(args);\n const encodedReturns = yield* Effect.promise(() =>\n runQuery(functionName as any, encodedArgs),\n );\n return yield* Schema.decode(function_.returns)(encodedReturns);\n });\n\nexport const QueryRunner = Context.GenericTag<ReturnType<typeof make>>(\n \"@confect/server/QueryRunner\",\n);\nexport type QueryRunner = typeof QueryRunner.Identifier;\n\nexport const layer = (runQuery: GenericQueryCtx<any>[\"runQuery\"]) =>\n Layer.succeed(QueryRunner, make(runQuery));\n"],"mappings":";;;;;;;;;;AAKA,MAAM,QACH,cAEC,OACA,SAEA,OAAO,IAAI,aAAa;CACtB,MAAM,YAAYA,MAAI,YAAY,MAAM;CACxC,MAAM,eAAeA,MAAI,sBAAsB,MAAM;CAErD,MAAM,cAAc,OAAO,OAAO,OAAO,UAAU,KAAK,CAAC,KAAK;CAC9D,MAAM,iBAAiB,OAAO,OAAO,cACnC,SAAS,cAAqB,YAAY,CAC3C;AACD,QAAO,OAAO,OAAO,OAAO,UAAU,QAAQ,CAAC,eAAe;EAC9D;AAEN,MAAa,cAAc,QAAQ,WACjC,8BACD;AAGD,MAAa,SAAS,aACpB,MAAM,QAAQ,aAAa,KAAK,SAAS,CAAC"}
1
+ {"version":3,"file":"QueryRunner.js","names":["Ref"],"sources":["../src/QueryRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericQueryCtx } from \"convex/server\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Match, Schema } from \"effect\";\n\nconst make =\n (runQuery: GenericQueryCtx<any>[\"runQuery\"]) =>\n <Query extends Ref.AnyQuery>(\n query: Query,\n args: Ref.Args<Query>,\n ): Effect.Effect<Ref.Returns<Query>, ParseResult.ParseError> =>\n Effect.gen(function* () {\n const functionSpec = Ref.getFunctionSpec(query);\n const functionName = Ref.getConvexFunctionName(query);\n\n return yield* Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionSpec) =>\n Effect.gen(function* () {\n const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(\n args,\n );\n const encodedReturns = yield* Effect.promise(() =>\n runQuery(functionName as any, encodedArgs),\n );\n return yield* Schema.decode(confectFunctionSpec.returns)(\n encodedReturns,\n );\n }),\n ),\n Match.tag(\"Convex\", () =>\n Effect.promise(() => runQuery(functionName as any, args as any)),\n ),\n Match.exhaustive,\n );\n });\n\nexport const QueryRunner = Context.GenericTag<ReturnType<typeof make>>(\n \"@confect/server/QueryRunner\",\n);\nexport type QueryRunner = typeof QueryRunner.Identifier;\n\nexport const layer = (runQuery: GenericQueryCtx<any>[\"runQuery\"]) =>\n Layer.succeed(QueryRunner, make(runQuery));\n"],"mappings":";;;;;;;;;;AAKA,MAAM,QACH,cAEC,OACA,SAEA,OAAO,IAAI,aAAa;CACtB,MAAM,eAAeA,MAAI,gBAAgB,MAAM;CAC/C,MAAM,eAAeA,MAAI,sBAAsB,MAAM;AAErD,QAAO,OAAO,MAAM,MAAM,aAAa,mBAAmB,CAAC,KACzD,MAAM,IAAI,YAAY,wBACpB,OAAO,IAAI,aAAa;EACtB,MAAM,cAAc,OAAO,OAAO,OAAO,oBAAoB,KAAK,CAChE,KACD;EACD,MAAM,iBAAiB,OAAO,OAAO,cACnC,SAAS,cAAqB,YAAY,CAC3C;AACD,SAAO,OAAO,OAAO,OAAO,oBAAoB,QAAQ,CACtD,eACD;GACD,CACH,EACD,MAAM,IAAI,gBACR,OAAO,cAAc,SAAS,cAAqB,KAAY,CAAC,CACjE,EACD,MAAM,WACP;EACD;AAEN,MAAa,cAAc,QAAQ,WACjC,8BACD;AAGD,MAAa,SAAS,aACpB,MAAM,QAAQ,aAAa,KAAK,SAAS,CAAC"}
@@ -14,7 +14,7 @@ import { MutationRunner } from "./MutationRunner.js";
14
14
  import { QueryRunner } from "./QueryRunner.js";
15
15
  import { Scheduler as Scheduler$1 } from "./Scheduler.js";
16
16
  import { StorageReader as StorageReader$1, StorageWriter as StorageWriter$1 } from "./Storage.js";
17
- import { RegisteredFunction } from "./RegisteredFunction.js";
17
+ import { Any } from "./RegisteredFunction.js";
18
18
  import { AnyWithProps as AnyWithProps$1 } from "./RegistryItem.js";
19
19
  import { Effect, Layer } from "effect";
20
20
  import * as _confect_core_Ref0 from "@confect/core/Ref";
@@ -31,9 +31,9 @@ declare namespace RegisteredConvexFunction_d_exports {
31
31
  export { MutationServices, make, mutationLayer };
32
32
  }
33
33
  declare const make: <Api_ extends AnyWithPropsWithRuntime<"Convex">>(api: Api_, {
34
- function_,
34
+ functionSpec,
35
35
  handler
36
- }: AnyWithProps$1) => RegisteredFunction;
36
+ }: AnyWithProps$1) => Any;
37
37
  declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx: GenericMutationCtx<ToConvex<FromSchema<Schema>>>) => Layer.Layer<GenericMutationCtx<ToConvex<FromSchema<Schema>>> | {
38
38
  table: <const TableName extends Name<IncludeSystemTables<Tables<Schema>>>>(tableName: TableName) => {
39
39
  readonly get: {
@@ -56,7 +56,7 @@ declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx:
56
56
  } | Auth$1 | {
57
57
  runAfter: <FuncRef extends convex_server0.SchedulableFunctionReference>(delay: effect_Duration0.Duration, functionReference: FuncRef, ...args: convex_server0.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
58
58
  runAt: <FuncRef extends convex_server0.SchedulableFunctionReference>(dateTime: effect_DateTime0.DateTime, functionReference: FuncRef, ...args: convex_server0.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
59
- } | StorageReader$1 | StorageWriter$1 | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, args: _confect_core_Ref0.Args<Query>["Type"]) => Effect.Effect<_confect_core_Ref0.Returns<Query>["Type"], effect_ParseResult0.ParseError>) | (<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, args: _confect_core_Ref0.Args<Mutation>["Type"]) => Effect.Effect<_confect_core_Ref0.Returns<Mutation>["Type"], effect_ParseResult0.ParseError>), never, never>;
59
+ } | StorageReader$1 | StorageWriter$1 | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, args: _confect_core_Ref0.Args<Query>) => Effect.Effect<_confect_core_Ref0.Returns<Query>, effect_ParseResult0.ParseError>) | (<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, args: _confect_core_Ref0.Args<Mutation>) => Effect.Effect<_confect_core_Ref0.Returns<Mutation>, effect_ParseResult0.ParseError>), never, never>;
60
60
  type MutationServices<Schema extends AnyWithProps> = DatabaseReader<Schema> | DatabaseWriter<Schema> | Auth$1 | Scheduler$1 | StorageReader$1 | StorageWriter$1 | QueryRunner | MutationRunner | MutationCtx<ToConvex<FromSchema<Schema>>>;
61
61
  //#endregion
62
62
  export { MutationServices, RegisteredConvexFunction_d_exports, make, mutationLayer };
@@ -1 +1 @@
1
- {"version":3,"file":"RegisteredConvexFunction.d.ts","names":[],"sources":["../src/RegisteredConvexFunction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA6Ba,IAAA,gBAAqB,uBAAA,YAChC,GAAA,EAAK,IAAA;EACL,SAAA;EAAA;AAAA,GAAwB,cAAA,KACvB,kBAAA;AAAA,cAwHU,aAAA,kBAAgC,YAAA,EAC3C,MAAA,EAAQ,MAAA,EACR,GAAA,EAAK,kBAAA,CAAmB,QAAA,CAAmB,UAAA,CAAqB,MAAA,QAAS,KAAA,CAAA,KAAA,CAAA,kBAAA,CAAA,QAAA,CAAA,UAAA,CAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;KAoB/D,gBAAA,gBAAgC,YAAA,IACxC,cAAA,CAA8B,MAAA,IAC9B,cAAA,CAA8B,MAAA,IAC9B,MAAA,GACA,WAAA,GACA,eAAA,GACA,eAAA,GACA,WAAA,GACA,cAAA,GACA,WAAA,CAAwB,QAAA,CAAmB,UAAA,CAAqB,MAAA"}
1
+ {"version":3,"file":"RegisteredConvexFunction.d.ts","names":[],"sources":["../src/RegisteredConvexFunction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+Ba,IAAA,gBAAqB,uBAAA,YAChC,GAAA,EAAK,IAAA;EACL,YAAA;EAAA;AAAA,GAA2B,cAAA,KAC1B,GAAA;AAAA,cAiIU,aAAA,kBAAgC,YAAA,EAC3C,MAAA,EAAQ,MAAA,EACR,GAAA,EAAK,kBAAA,CAAmB,QAAA,CAAmB,UAAA,CAAqB,MAAA,QAAS,KAAA,CAAA,KAAA,CAAA,kBAAA,CAAA,QAAA,CAAA,UAAA,CAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;KAoB/D,gBAAA,gBAAgC,YAAA,IACxC,cAAA,CAA8B,MAAA,IAC9B,cAAA,CAA8B,MAAA,IAC9B,MAAA,GACA,WAAA,GACA,eAAA,GACA,eAAA,GACA,WAAA,GACA,cAAA,GACA,WAAA,CAAwB,QAAA,CAAmB,UAAA,CAAqB,MAAA"}
@@ -19,24 +19,27 @@ var RegisteredConvexFunction_exports = /* @__PURE__ */ __exportAll({
19
19
  make: () => make,
20
20
  mutationLayer: () => mutationLayer
21
21
  });
22
- const make = (api, { function_, handler }) => Match.value(function_.runtimeAndFunctionType.functionType).pipe(Match.when("query", () => {
23
- return Match.value(function_.functionVisibility).pipe(Match.when("public", () => queryGeneric), Match.when("internal", () => internalQueryGeneric), Match.exhaustive)(queryFunction(api.databaseSchema, {
24
- args: function_.args,
25
- returns: function_.returns,
26
- handler
27
- }));
28
- }), Match.when("mutation", () => {
29
- return Match.value(function_.functionVisibility).pipe(Match.when("public", () => mutationGeneric), Match.when("internal", () => internalMutationGeneric), Match.exhaustive)(mutationFunction(api.databaseSchema, {
30
- args: function_.args,
31
- returns: function_.returns,
32
- handler
33
- }));
34
- }), Match.when("action", () => {
35
- return Match.value(function_.functionVisibility).pipe(Match.when("public", () => actionGeneric), Match.when("internal", () => internalActionGeneric), Match.exhaustive)(convexActionFunction(api.databaseSchema, {
36
- args: function_.args,
37
- returns: function_.returns,
38
- handler
39
- }));
22
+ const make = (api, { functionSpec, handler }) => Match.value(functionSpec.functionProvenance).pipe(Match.tag("Convex", () => handler), Match.tag("Confect", () => {
23
+ const { functionVisibility, functionProvenance } = functionSpec;
24
+ return Match.value(functionSpec.runtimeAndFunctionType.functionType).pipe(Match.when("query", () => {
25
+ return Match.value(functionVisibility).pipe(Match.when("public", () => queryGeneric), Match.when("internal", () => internalQueryGeneric), Match.exhaustive)(queryFunction(api.databaseSchema, {
26
+ args: functionProvenance.args,
27
+ returns: functionProvenance.returns,
28
+ handler
29
+ }));
30
+ }), Match.when("mutation", () => {
31
+ return Match.value(functionVisibility).pipe(Match.when("public", () => mutationGeneric), Match.when("internal", () => internalMutationGeneric), Match.exhaustive)(mutationFunction(api.databaseSchema, {
32
+ args: functionProvenance.args,
33
+ returns: functionProvenance.returns,
34
+ handler
35
+ }));
36
+ }), Match.when("action", () => {
37
+ return Match.value(functionVisibility).pipe(Match.when("public", () => actionGeneric), Match.when("internal", () => internalActionGeneric), Match.exhaustive)(convexActionFunction(api.databaseSchema, {
38
+ args: functionProvenance.args,
39
+ returns: functionProvenance.returns,
40
+ handler
41
+ }));
42
+ }), Match.exhaustive);
40
43
  }), Match.exhaustive);
41
44
  const queryFunction = (databaseSchema, { args, returns, handler }) => ({
42
45
  args: compileArgsSchema(args),
@@ -1 +1 @@
1
- {"version":3,"file":"RegisteredConvexFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","DatabaseReader.layer","Auth.layer","StorageReader","QueryRunner.layer","QueryCtx.QueryCtx","ConvexConfigProvider.make","DatabaseWriter.layer","Scheduler.layer","StorageWriter","MutationRunner.layer","MutationCtx.MutationCtx","RegisteredFunction.actionFunctionBase","RegisteredFunction.actionLayer"],"sources":["../src/RegisteredConvexFunction.ts"],"sourcesContent":["import {\n actionGeneric,\n type DefaultFunctionArgs,\n type GenericMutationCtx,\n type GenericQueryCtx,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n mutationGeneric,\n queryGeneric,\n} from \"convex/server\";\nimport { Effect, Layer, Match, pipe, Schema } from \"effect\";\nimport type * as Api from \"./Api\";\nimport * as Auth from \"./Auth\";\nimport * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport * as MutationCtx from \"./MutationCtx\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryCtx from \"./QueryCtx\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as RegisteredFunction from \"./RegisteredFunction\";\nimport type * as RegistryItem from \"./RegistryItem\";\nimport * as Scheduler from \"./Scheduler\";\nimport * as SchemaToValidator from \"./SchemaToValidator\";\nimport * as ConvexConfigProvider from \"./ConvexConfigProvider\";\nimport { StorageReader, StorageWriter } from \"./Storage\";\n\nexport const make = <Api_ extends Api.AnyWithPropsWithRuntime<\"Convex\">>(\n api: Api_,\n { function_, handler }: RegistryItem.AnyWithProps,\n): RegisteredFunction.RegisteredFunction =>\n Match.value(function_.runtimeAndFunctionType.functionType).pipe(\n Match.when(\"query\", () => {\n const genericFunction = Match.value(function_.functionVisibility).pipe(\n Match.when(\"public\", () => queryGeneric),\n Match.when(\"internal\", () => internalQueryGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n queryFunction(api.databaseSchema, {\n args: function_.args,\n returns: function_.returns,\n handler,\n }),\n );\n }),\n Match.when(\"mutation\", () => {\n const genericFunction = Match.value(function_.functionVisibility).pipe(\n Match.when(\"public\", () => mutationGeneric),\n Match.when(\"internal\", () => internalMutationGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n mutationFunction(api.databaseSchema, {\n args: function_.args,\n returns: function_.returns,\n handler,\n }),\n );\n }),\n Match.when(\"action\", () => {\n const genericFunction = Match.value(function_.functionVisibility).pipe(\n Match.when(\"public\", () => actionGeneric),\n Match.when(\"internal\", () => internalActionGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n convexActionFunction(api.databaseSchema, {\n args: function_.args,\n returns: function_.returns,\n handler,\n }),\n );\n }),\n Match.exhaustive,\n );\n\nconst queryFunction = <\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 | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | Auth.Auth\n | StorageReader\n | QueryRunner.QueryRunner\n | QueryCtx.QueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >\n >;\n },\n) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericQueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n Effect.andThen((decodedArgs) =>\n pipe(\n handler(decodedArgs),\n Effect.provide(\n Layer.mergeAll(\n DatabaseReader.layer(databaseSchema, ctx.db),\n Auth.layer(ctx.auth),\n StorageReader.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n Layer.succeed(\n QueryCtx.QueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >(),\n ctx,\n ),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n ),\n ),\n ),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n\nexport const mutationLayer = <Schema extends DatabaseSchema.AnyWithProps>(\n schema: Schema,\n ctx: GenericMutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n) =>\n Layer.mergeAll(\n DatabaseReader.layer(schema, ctx.db),\n DatabaseWriter.layer(schema, ctx.db),\n Auth.layer(ctx.auth),\n Scheduler.layer(ctx.scheduler),\n StorageReader.layer(ctx.storage),\n StorageWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n Layer.succeed(\n MutationCtx.MutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<Schema>>\n >(),\n ctx,\n ),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n );\n\nexport type MutationServices<Schema extends DatabaseSchema.AnyWithProps> =\n | DatabaseReader.DatabaseReader<Schema>\n | DatabaseWriter.DatabaseWriter<Schema>\n | Auth.Auth\n | Scheduler.Scheduler\n | StorageReader\n | StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | MutationCtx.MutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>;\n\nconst mutationFunction = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n schema: Schema,\n {\n args,\n returns,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (a: Args) => Effect.Effect<Returns, E, MutationServices<Schema>>;\n },\n) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericMutationCtx<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(mutationLayer(schema, ctx))),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n\nconst convexActionFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n schema: 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 >;\n },\n) =>\n RegisteredFunction.actionFunctionBase({\n args,\n returns,\n handler,\n createLayer: (ctx) =>\n Layer.mergeAll(\n RegisteredFunction.actionLayer(schema, ctx),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n ),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,QACX,KACA,EAAE,WAAW,cAEb,MAAM,MAAM,UAAU,uBAAuB,aAAa,CAAC,KACzD,MAAM,KAAK,eAAe;AAOxB,QANwB,MAAM,MAAM,UAAU,mBAAmB,CAAC,KAChE,MAAM,KAAK,gBAAgB,aAAa,EACxC,MAAM,KAAK,kBAAkB,qBAAqB,EAClD,MAAM,WACP,CAGC,cAAc,IAAI,gBAAgB;EAChC,MAAM,UAAU;EAChB,SAAS,UAAU;EACnB;EACD,CAAC,CACH;EACD,EACF,MAAM,KAAK,kBAAkB;AAO3B,QANwB,MAAM,MAAM,UAAU,mBAAmB,CAAC,KAChE,MAAM,KAAK,gBAAgB,gBAAgB,EAC3C,MAAM,KAAK,kBAAkB,wBAAwB,EACrD,MAAM,WACP,CAGC,iBAAiB,IAAI,gBAAgB;EACnC,MAAM,UAAU;EAChB,SAAS,UAAU;EACnB;EACD,CAAC,CACH;EACD,EACF,MAAM,KAAK,gBAAgB;AAOzB,QANwB,MAA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AO,KAAK,EACnB,OAAO,OACP,OAAO,SAAS,gBACd,QAAQ,YAAY,CAAC,KAAK,OAAO,QAAQ,cAAc,QAAQ,IAAI,CAAC,CAAC,CACtE,EACD,OAAO,SAAS,kBACd,OAAO,cAAc,QAAQ,CAAC,cAAc,CAC7C,EACD,OAAO,WACR;CACJ;AAED,MAAM,wBAQJ,QACA,EACE,MACA,SACA,cAaFY,mBAAsC;CACpC;CACA;CACA;CACA,cAAc,QACZ,MAAM,SACJC,YAA+B,QAAQ,IAAI,EAC3C,MAAM,kBAAkBP,QAA2B,CAAC,CACrD;CACJ,CAAC"}
1
+ {"version":3,"file":"RegisteredConvexFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","DatabaseReader.layer","Auth.layer","StorageReader","QueryRunner.layer","QueryCtx.QueryCtx","ConvexConfigProvider.make","DatabaseWriter.layer","Scheduler.layer","StorageWriter","MutationRunner.layer","MutationCtx.MutationCtx","RegisteredFunction.actionFunctionBase","RegisteredFunction.actionLayer"],"sources":["../src/RegisteredConvexFunction.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport {\n actionGeneric,\n type DefaultFunctionArgs,\n type GenericMutationCtx,\n type GenericQueryCtx,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n mutationGeneric,\n queryGeneric,\n} from \"convex/server\";\nimport { Effect, Layer, Match, pipe, Schema } from \"effect\";\nimport type * as Api from \"./Api\";\nimport * as Auth from \"./Auth\";\nimport * as ConvexConfigProvider from \"./ConvexConfigProvider\";\nimport * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport type * as Handler from \"./Handler\";\nimport * as MutationCtx from \"./MutationCtx\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryCtx from \"./QueryCtx\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as RegisteredFunction from \"./RegisteredFunction\";\nimport type * as RegistryItem from \"./RegistryItem\";\nimport * as Scheduler from \"./Scheduler\";\nimport * as SchemaToValidator from \"./SchemaToValidator\";\nimport { StorageReader, StorageWriter } from \"./Storage\";\n\nexport const make = <Api_ extends Api.AnyWithPropsWithRuntime<\"Convex\">>(\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 return Match.value(functionSpec.runtimeAndFunctionType.functionType).pipe(\n Match.when(\"query\", () => {\n const genericFunction = Match.value(functionVisibility).pipe(\n Match.when(\"public\", () => queryGeneric),\n Match.when(\"internal\", () => internalQueryGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n queryFunction(api.databaseSchema, {\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.when(\"mutation\", () => {\n const genericFunction = Match.value(functionVisibility).pipe(\n Match.when(\"public\", () => mutationGeneric),\n Match.when(\"internal\", () => internalMutationGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n mutationFunction(api.databaseSchema, {\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.when(\"action\", () => {\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 convexActionFunction(api.databaseSchema, {\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.exhaustive,\n );\n }),\n Match.exhaustive,\n );\n\nconst queryFunction = <\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 | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | Auth.Auth\n | StorageReader\n | QueryRunner.QueryRunner\n | QueryCtx.QueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >\n >;\n },\n) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericQueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n Effect.andThen((decodedArgs) =>\n pipe(\n handler(decodedArgs),\n Effect.provide(\n Layer.mergeAll(\n DatabaseReader.layer(databaseSchema, ctx.db),\n Auth.layer(ctx.auth),\n StorageReader.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n Layer.succeed(\n QueryCtx.QueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >(),\n ctx,\n ),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n ),\n ),\n ),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n\nexport const mutationLayer = <Schema extends DatabaseSchema.AnyWithProps>(\n schema: Schema,\n ctx: GenericMutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n) =>\n Layer.mergeAll(\n DatabaseReader.layer(schema, ctx.db),\n DatabaseWriter.layer(schema, ctx.db),\n Auth.layer(ctx.auth),\n Scheduler.layer(ctx.scheduler),\n StorageReader.layer(ctx.storage),\n StorageWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n Layer.succeed(\n MutationCtx.MutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<Schema>>\n >(),\n ctx,\n ),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n );\n\nexport type MutationServices<Schema extends DatabaseSchema.AnyWithProps> =\n | DatabaseReader.DatabaseReader<Schema>\n | DatabaseWriter.DatabaseWriter<Schema>\n | Auth.Auth\n | Scheduler.Scheduler\n | StorageReader\n | StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | MutationCtx.MutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>;\n\nconst mutationFunction = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n schema: Schema,\n {\n args,\n returns,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (a: Args) => Effect.Effect<Returns, E, MutationServices<Schema>>;\n },\n) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericMutationCtx<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(mutationLayer(schema, ctx))),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n\nconst convexActionFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n schema: 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 >;\n },\n) =>\n RegisteredFunction.actionFunctionBase({\n args,\n returns,\n handler,\n createLayer: (ctx) =>\n Layer.mergeAll(\n RegisteredFunction.actionLayer(schema, ctx),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n ),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+BA,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;AAEF,QAAO,MAAM,MAAM,aAAa,uBAAuB,aAAa,CAAC,KACnE,MAAM,KAAK,eAAe;AAOxB,SANwB,MAAM,MAAM,mBAAmB,CAAC,KACtD,MAAM,KAAK,gBAAgB,aAAa,EACxC,MAAM,KAAK,kBAAkB,qBAAqB,EAClD,MAAM,WACP,CAGC,cAAc,IAAI,gBAAgB;GAChC,MAAM,mBAAmB;GACzB,SAAS,mBAAmB;GACnB;GACV,CAAC,CACH;GACD,EACF,MAAM,KAAK,kBAAkB;AAO3B,SANwB,MAAM,MAAM,mBAAmB,CAAC,KACtD,MAAM,KAAK,gBAAgB,gBAAgB,EAC3C,MAAM,KAAK,kBAAkB,wBAAwB,EACrD,MAAM,WACP,CAGC,iBAAiB,IAAI,gBAAgB;GACnC,MAAM,mBAAmB;GACzB,SAAS,mBAAmB;GACnB;GACV,CAAC,CACH;GACD,EACF,MAAM,KAAK,gBAAgB;AAOzB,SANwB,MAAM,MAAM,mBAAmB,CAAC,KACtD,MAAM,KAAK,gBAAgB,cAAc,EACzC,MAAM,KAAK,kBAAkB,sBAAsB,EACnD,MAAM,WACP,CAGC,qBAAqB,IAAI,gBAAgB;GACvC,MAA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AAO,SAAS,kBACd,OAAO,cAAc,QAAQ,CAAC,cAAc,CAC7C,EACD,OAAO,WACR;CACJ;AAED,MAAM,wBAQJ,QACA,EACE,MACA,SACA,cAaFY,mBAAsC;CACpC;CACA;CACA;CACA,cAAc,QACZ,MAAM,SACJC,YAA+B,QAAQ,IAAI,EAC3C,MAAM,kBAAkBP,QAA2B,CAAC,CACrD;CACJ,CAAC"}
@@ -13,15 +13,26 @@ import * as _confect_core_Ref0 from "@confect/core/Ref";
13
13
  import * as convex_server0 from "convex/server";
14
14
  import { DefaultFunctionArgs, FunctionVisibility, GenericActionCtx, RegisteredAction, RegisteredMutation, RegisteredQuery } from "convex/server";
15
15
  import * as convex_values0 from "convex/values";
16
+ import { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
17
+ import * as FunctionProvenance from "@confect/core/FunctionProvenance";
16
18
  import * as effect_Duration0 from "effect/Duration";
17
19
  import * as effect_DateTime0 from "effect/DateTime";
18
20
  import * as effect_ParseResult0 from "effect/ParseResult";
19
21
 
20
22
  //#region src/RegisteredFunction.d.ts
21
23
  declare namespace RegisteredFunction_d_exports {
22
- export { ActionServices, RegisteredFunction, actionFunctionBase, actionLayer };
24
+ export { ActionServices, Any, ConvexRegisteredFunction, RegisteredFunction, actionFunctionBase, actionLayer };
23
25
  }
24
- type RegisteredFunction = RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;
26
+ type Any = RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;
27
+ type ConfectRegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec.EncodedArgs<FunctionSpec_> extends infer Args_ extends DefaultFunctionArgs ? RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "query" ? RegisteredQuery<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>> : RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "mutation" ? RegisteredMutation<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>> : RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "action" ? RegisteredAction<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>> : never : never;
28
+ type ConvexRegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends {
29
+ functionProvenance: {
30
+ _tag: "Convex";
31
+ _args: infer Args_ extends DefaultFunctionArgs;
32
+ _returns: infer Returns_;
33
+ };
34
+ } ? RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "query" ? RegisteredQuery<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Returns_> : RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "mutation" ? RegisteredMutation<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Returns_> : RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "action" ? RegisteredAction<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Returns_> : never : never;
35
+ type RegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<FunctionSpec_, FunctionProvenance.AnyConvex> ? ConvexRegisteredFunction<FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<FunctionSpec_, FunctionProvenance.AnyConfect> ? ConfectRegisteredFunction<FunctionSpec_> : never;
25
36
  declare const actionFunctionBase: <Schema extends AnyWithProps, Args, ConvexArgs extends DefaultFunctionArgs, Returns, ConvexReturns, E, R>({
26
37
  args,
27
38
  returns,
@@ -38,10 +49,10 @@ declare const actionFunctionBase: <Schema extends AnyWithProps, Args, ConvexArgs
38
49
  handler: (ctx: GenericActionCtx<ToConvex<FromSchema<Schema>>>, actualArgs: ConvexArgs) => Promise<ConvexReturns>;
39
50
  };
40
51
  type ActionServices<DatabaseSchema_ extends AnyWithProps> = Scheduler$1 | Auth$1 | StorageReader$1 | StorageWriter$1 | StorageActionWriter$1 | QueryRunner | MutationRunner | ActionRunner | VectorSearch<FromSchema<DatabaseSchema_>> | ActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>;
41
- declare const actionLayer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, ctx: GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<(<Action extends _confect_core_Ref0.AnyAction>(action: Action, args: _confect_core_Ref0.Args<Action>["Type"]) => Effect.Effect<_confect_core_Ref0.Returns<Action>["Type"], effect_ParseResult0.ParseError>) | Auth$1 | {
52
+ declare const actionLayer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, ctx: GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<Auth$1 | {
42
53
  runAfter: <FuncRef extends convex_server0.SchedulableFunctionReference>(delay: effect_Duration0.Duration, functionReference: FuncRef, ...args: convex_server0.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
43
54
  runAt: <FuncRef extends convex_server0.SchedulableFunctionReference>(dateTime: effect_DateTime0.DateTime, functionReference: FuncRef, ...args: convex_server0.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
44
- } | StorageReader$1 | StorageWriter$1 | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, args: _confect_core_Ref0.Args<Query>["Type"]) => Effect.Effect<_confect_core_Ref0.Returns<Query>["Type"], effect_ParseResult0.ParseError>) | (<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, args: _confect_core_Ref0.Args<Mutation>["Type"]) => Effect.Effect<_confect_core_Ref0.Returns<Mutation>["Type"], effect_ParseResult0.ParseError>) | StorageActionWriter$1 | GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>> | (<TableName extends TableNames<FromSchema<DatabaseSchema_>>, IndexName extends keyof convex_server0.VectorIndexes<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>>>(tableName: TableName, indexName: IndexName, query: {
55
+ } | StorageReader$1 | StorageWriter$1 | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, args: _confect_core_Ref0.Args<Query>) => Effect.Effect<_confect_core_Ref0.Returns<Query>, effect_ParseResult0.ParseError>) | (<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, args: _confect_core_Ref0.Args<Mutation>) => Effect.Effect<_confect_core_Ref0.Returns<Mutation>, effect_ParseResult0.ParseError>) | GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>> | StorageActionWriter$1 | (<Action extends _confect_core_Ref0.AnyAction>(action: Action, args: _confect_core_Ref0.Args<Action>) => Effect.Effect<_confect_core_Ref0.Returns<Action>, effect_ParseResult0.ParseError>) | (<TableName extends TableNames<FromSchema<DatabaseSchema_>>, IndexName extends keyof convex_server0.VectorIndexes<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>>>(tableName: TableName, indexName: IndexName, query: {
45
56
  vector: number[];
46
57
  limit?: number;
47
58
  filter?: (q: convex_server0.VectorFilterBuilder<convex_server0.DocumentByInfo<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>>, convex_server0.NamedVectorIndex<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>, IndexName>>) => convex_server0.FilterExpression<boolean>;
@@ -50,5 +61,5 @@ declare const actionLayer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema
50
61
  _score: number;
51
62
  }[], never, never>), never, never>;
52
63
  //#endregion
53
- export { ActionServices, RegisteredFunction, RegisteredFunction_d_exports, actionFunctionBase, actionLayer };
64
+ export { ActionServices, Any, ConvexRegisteredFunction, RegisteredFunction, RegisteredFunction_d_exports, actionFunctionBase, actionLayer };
54
65
  //# sourceMappingURL=RegisteredFunction.d.ts.map