@confect/server 9.0.0-next.0 → 9.0.0-next.10

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 (190) hide show
  1. package/CHANGELOG.md +299 -4
  2. package/dist/ActionCtx.d.ts +4 -11
  3. package/dist/ActionCtx.d.ts.map +1 -1
  4. package/dist/ActionCtx.js +1 -1
  5. package/dist/ActionCtx.js.map +1 -1
  6. package/dist/ActionRunner.d.ts +8 -13
  7. package/dist/ActionRunner.d.ts.map +1 -1
  8. package/dist/ActionRunner.js +4 -3
  9. package/dist/ActionRunner.js.map +1 -1
  10. package/dist/Auth.d.ts +17 -23
  11. package/dist/Auth.d.ts.map +1 -1
  12. package/dist/Auth.js +5 -1
  13. package/dist/Auth.js.map +1 -1
  14. package/dist/BlobNotFoundError.d.ts +6 -12
  15. package/dist/BlobNotFoundError.d.ts.map +1 -1
  16. package/dist/BlobNotFoundError.js +1 -1
  17. package/dist/BlobNotFoundError.js.map +1 -1
  18. package/dist/ConvexConfigProvider.d.ts +2 -9
  19. package/dist/ConvexConfigProvider.d.ts.map +1 -1
  20. package/dist/ConvexConfigProvider.js +6 -1
  21. package/dist/ConvexConfigProvider.js.map +1 -1
  22. package/dist/CronJob.d.ts +12 -19
  23. package/dist/CronJob.d.ts.map +1 -1
  24. package/dist/CronJob.js +1 -1
  25. package/dist/CronJob.js.map +1 -1
  26. package/dist/CronJobs.d.ts +11 -18
  27. package/dist/CronJobs.d.ts.map +1 -1
  28. package/dist/CronJobs.js +11 -4
  29. package/dist/CronJobs.js.map +1 -1
  30. package/dist/DataModel.d.ts +24 -29
  31. package/dist/DataModel.d.ts.map +1 -1
  32. package/dist/DatabaseReader.d.ts +4323 -64
  33. package/dist/DatabaseReader.d.ts.map +1 -1
  34. package/dist/DatabaseReader.js +6 -6
  35. package/dist/DatabaseReader.js.map +1 -1
  36. package/dist/DatabaseSchema.d.ts +38 -130
  37. package/dist/DatabaseSchema.d.ts.map +1 -1
  38. package/dist/DatabaseSchema.js +20 -30
  39. package/dist/DatabaseSchema.js.map +1 -1
  40. package/dist/DatabaseWriter.d.ts +38 -42
  41. package/dist/DatabaseWriter.d.ts.map +1 -1
  42. package/dist/DatabaseWriter.js +8 -5
  43. package/dist/DatabaseWriter.js.map +1 -1
  44. package/dist/Document.d.ts +28 -37
  45. package/dist/Document.d.ts.map +1 -1
  46. package/dist/Document.js +5 -1
  47. package/dist/Document.js.map +1 -1
  48. package/dist/FunctionImpl.d.ts +30 -29
  49. package/dist/FunctionImpl.d.ts.map +1 -1
  50. package/dist/FunctionImpl.js +25 -14
  51. package/dist/FunctionImpl.js.map +1 -1
  52. package/dist/GroupImpl.d.ts +45 -41
  53. package/dist/GroupImpl.d.ts.map +1 -1
  54. package/dist/GroupImpl.js +42 -35
  55. package/dist/GroupImpl.js.map +1 -1
  56. package/dist/Handler.d.ts +34 -40
  57. package/dist/Handler.d.ts.map +1 -1
  58. package/dist/HttpApi.d.ts +21 -25
  59. package/dist/HttpApi.d.ts.map +1 -1
  60. package/dist/HttpApi.js +11 -6
  61. package/dist/HttpApi.js.map +1 -1
  62. package/dist/MutationCtx.d.ts +4 -11
  63. package/dist/MutationCtx.d.ts.map +1 -1
  64. package/dist/MutationCtx.js +1 -1
  65. package/dist/MutationCtx.js.map +1 -1
  66. package/dist/MutationRunner.d.ts +8 -13
  67. package/dist/MutationRunner.d.ts.map +1 -1
  68. package/dist/MutationRunner.js +4 -3
  69. package/dist/MutationRunner.js.map +1 -1
  70. package/dist/OrderedQuery.d.ts +16 -21
  71. package/dist/OrderedQuery.d.ts.map +1 -1
  72. package/dist/OrderedQuery.js +4 -1
  73. package/dist/OrderedQuery.js.map +1 -1
  74. package/dist/QueryCtx.d.ts +4 -11
  75. package/dist/QueryCtx.d.ts.map +1 -1
  76. package/dist/QueryCtx.js +1 -1
  77. package/dist/QueryCtx.js.map +1 -1
  78. package/dist/QueryInitializer.d.ts +34 -39
  79. package/dist/QueryInitializer.d.ts.map +1 -1
  80. package/dist/QueryInitializer.js +5 -1
  81. package/dist/QueryInitializer.js.map +1 -1
  82. package/dist/QueryRunner.d.ts +8 -13
  83. package/dist/QueryRunner.d.ts.map +1 -1
  84. package/dist/QueryRunner.js +4 -3
  85. package/dist/QueryRunner.js.map +1 -1
  86. package/dist/RegisteredConvexFunction.d.ts +1107 -60
  87. package/dist/RegisteredConvexFunction.d.ts.map +1 -1
  88. package/dist/RegisteredConvexFunction.js +14 -9
  89. package/dist/RegisteredConvexFunction.js.map +1 -1
  90. package/dist/RegisteredFunction.d.ts +48 -64
  91. package/dist/RegisteredFunction.d.ts.map +1 -1
  92. package/dist/RegisteredFunction.js +9 -5
  93. package/dist/RegisteredFunction.js.map +1 -1
  94. package/dist/RegisteredFunctions.d.ts +48 -26
  95. package/dist/RegisteredFunctions.d.ts.map +1 -1
  96. package/dist/RegisteredFunctions.js +22 -9
  97. package/dist/RegisteredFunctions.js.map +1 -1
  98. package/dist/RegisteredNodeFunction.d.ts +4 -14
  99. package/dist/RegisteredNodeFunction.d.ts.map +1 -1
  100. package/dist/RegisteredNodeFunction.js +5 -4
  101. package/dist/RegisteredNodeFunction.js.map +1 -1
  102. package/dist/RegistryItem.d.ts +17 -27
  103. package/dist/RegistryItem.d.ts.map +1 -1
  104. package/dist/RegistryItem.js +1 -1
  105. package/dist/RegistryItem.js.map +1 -1
  106. package/dist/Scheduler.d.ts +16 -20
  107. package/dist/Scheduler.d.ts.map +1 -1
  108. package/dist/Scheduler.js +10 -6
  109. package/dist/Scheduler.js.map +1 -1
  110. package/dist/SchemaToValidator.d.ts +71 -64
  111. package/dist/SchemaToValidator.d.ts.map +1 -1
  112. package/dist/SchemaToValidator.js +15 -3
  113. package/dist/SchemaToValidator.js.map +1 -1
  114. package/dist/StorageActionWriter.d.ts +21 -28
  115. package/dist/StorageActionWriter.d.ts.map +1 -1
  116. package/dist/StorageActionWriter.js +4 -1
  117. package/dist/StorageActionWriter.js.map +1 -1
  118. package/dist/StorageReader.d.ts +14 -21
  119. package/dist/StorageReader.d.ts.map +1 -1
  120. package/dist/StorageReader.js +5 -1
  121. package/dist/StorageReader.js.map +1 -1
  122. package/dist/StorageWriter.d.ts +16 -23
  123. package/dist/StorageWriter.d.ts.map +1 -1
  124. package/dist/StorageWriter.js +4 -1
  125. package/dist/StorageWriter.js.map +1 -1
  126. package/dist/Table.d.ts +204 -197
  127. package/dist/Table.d.ts.map +1 -1
  128. package/dist/Table.js +72 -62
  129. package/dist/Table.js.map +1 -1
  130. package/dist/TableInfo.d.ts +35 -41
  131. package/dist/TableInfo.d.ts.map +1 -1
  132. package/dist/VectorSearch.d.ts +30 -35
  133. package/dist/VectorSearch.d.ts.map +1 -1
  134. package/dist/VectorSearch.js +3 -1
  135. package/dist/VectorSearch.js.map +1 -1
  136. package/dist/index.d.ts +35 -36
  137. package/dist/index.d.ts.map +1 -0
  138. package/dist/index.js +4 -5
  139. package/dist/internal/utils.d.ts +9 -11
  140. package/dist/internal/utils.d.ts.map +1 -1
  141. package/dist/internal/utils.js +3 -1
  142. package/dist/internal/utils.js.map +1 -1
  143. package/dist/node.d.ts +2 -2
  144. package/dist/node.d.ts.map +1 -0
  145. package/dist/tsconfig.src.tsbuildinfo +1 -0
  146. package/package.json +50 -59
  147. package/src/ActionCtx.ts +1 -1
  148. package/src/ActionRunner.ts +2 -1
  149. package/src/Auth.ts +5 -1
  150. package/src/BlobNotFoundError.ts +1 -1
  151. package/src/ConvexConfigProvider.ts +6 -8
  152. package/src/CronJob.ts +1 -1
  153. package/src/CronJobs.ts +8 -10
  154. package/src/DatabaseReader.ts +18 -21
  155. package/src/DatabaseSchema.ts +38 -98
  156. package/src/DatabaseWriter.ts +13 -6
  157. package/src/Document.ts +5 -1
  158. package/src/FunctionImpl.ts +36 -44
  159. package/src/GroupImpl.ts +54 -81
  160. package/src/HttpApi.ts +8 -9
  161. package/src/MutationCtx.ts +1 -1
  162. package/src/MutationRunner.ts +2 -1
  163. package/src/OrderedQuery.ts +5 -1
  164. package/src/QueryCtx.ts +1 -1
  165. package/src/QueryInitializer.ts +15 -3
  166. package/src/QueryRunner.ts +2 -1
  167. package/src/RegisteredConvexFunction.ts +11 -7
  168. package/src/RegisteredFunction.ts +5 -1
  169. package/src/RegisteredFunctions.ts +69 -93
  170. package/src/RegisteredNodeFunction.ts +7 -6
  171. package/src/RegistryItem.ts +1 -1
  172. package/src/Scheduler.ts +5 -1
  173. package/src/SchemaToValidator.ts +14 -16
  174. package/src/StorageActionWriter.ts +4 -1
  175. package/src/StorageReader.ts +5 -1
  176. package/src/StorageWriter.ts +4 -1
  177. package/src/Table.ts +253 -132
  178. package/src/VectorSearch.ts +3 -1
  179. package/src/index.ts +0 -1
  180. package/src/internal/utils.ts +3 -1
  181. package/dist/Api.d.ts +0 -30
  182. package/dist/Api.d.ts.map +0 -1
  183. package/dist/Api.js +0 -26
  184. package/dist/Api.js.map +0 -1
  185. package/dist/GroupPath.d.ts +0 -8
  186. package/dist/GroupPath.d.ts.map +0 -1
  187. package/dist/GroupPath.js +0 -10
  188. package/dist/GroupPath.js.map +0 -1
  189. package/src/Api.ts +0 -75
  190. package/src/GroupPath.ts +0 -43
@@ -1 +1 @@
1
- {"version":3,"file":"RegisteredConvexFunction.d.ts","names":[],"sources":["../src/RegisteredConvexFunction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCa,IAAA,gBAAqB,uBAAA,YAChC,GAAA,EAAK,IAAA;EACL,YAAA;EAAA;AAAA,GAA2B,cAAA,KAC1B,GAAA;AAAA,cAkLU,aAAA,kBAAgC,YAAA,EAC3C,MAAA,EAAQ,MAAA,EACR,GAAA,EAAK,kBAAA,CAAmB,QAAA,CAAmB,UAAA,CAAqB,MAAA,QAAS,KAAA,CAAA,KAAA,CAAA,MAAA;0BAAA,kBAAA,CAAA,WAAA;;;;;;;;;;;;;;;;;;;;;;KAoB/D,gBAAA,gBAAgC,YAAA,IACxC,cAAA,CAA8B,MAAA,IAC9B,cAAA,CAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAkBxE,CAAC;AAEJ,MAAM,MAAM,gBAAgB,CAAC,MAAM,SAAS,cAAc,CAAC,YAAY,IACnE,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,GACrC,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,GACrC,IAAI,CAAC,IAAI,GACT,SAAS,CAAC,SAAS,GACnB,aAAa,GACb,aAAa,GACb,WAAW,CAAC,WAAW,GACvB,cAAc,CAAC,cAAc,GAC7B,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC"}
@@ -7,24 +7,29 @@ import { layer as layer$2 } from "./DatabaseWriter.js";
7
7
  import { layer as layer$3 } from "./MutationRunner.js";
8
8
  import { layer as layer$4 } from "./QueryRunner.js";
9
9
  import { layer as layer$5 } from "./Scheduler.js";
10
- import { StorageReader as StorageReader$1 } from "./StorageReader.js";
11
- import { StorageWriter as StorageWriter$1 } from "./StorageWriter.js";
10
+ import { StorageReader } from "./StorageReader.js";
11
+ import { StorageWriter } from "./StorageWriter.js";
12
12
  import { MutationCtx } from "./MutationCtx.js";
13
13
  import { QueryCtx } from "./QueryCtx.js";
14
14
  import { actionFunctionBase, actionLayer, runHandlerPromise } from "./RegisteredFunction.js";
15
- import { Clock, Effect, Layer, Match, Schema, pipe } from "effect";
16
15
  import { actionGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, mutationGeneric, queryGeneric } from "convex/server";
16
+ import * as Layer from "effect/Layer";
17
+ import { pipe } from "effect/Function";
18
+ import * as Effect from "effect/Effect";
19
+ import * as Schema from "effect/Schema";
20
+ import * as Match from "effect/Match";
21
+ import * as Clock from "effect/Clock";
17
22
 
18
23
  //#region src/RegisteredConvexFunction.ts
19
24
  var RegisteredConvexFunction_exports = /* @__PURE__ */ __exportAll({
20
25
  make: () => make,
21
26
  mutationLayer: () => mutationLayer
22
27
  });
23
- const make = (api, { functionSpec, handler }) => Match.value(functionSpec.functionProvenance).pipe(Match.tag("Convex", () => handler), Match.tag("Confect", () => {
28
+ const make = (databaseSchema, { functionSpec, handler }) => Match.value(functionSpec.functionProvenance).pipe(Match.tag("Convex", () => handler), Match.tag("Confect", () => {
24
29
  const { functionVisibility, functionProvenance } = functionSpec;
25
30
  return Match.value(functionSpec.runtimeAndFunctionType.functionType).pipe(Match.when("query", () => {
26
31
  return Match.value(functionVisibility).pipe(Match.when("public", () => queryGeneric), Match.when("internal", () => internalQueryGeneric), Match.exhaustive)(queryFunction({
27
- databaseSchema: api.databaseSchema,
32
+ databaseSchema,
28
33
  args: functionProvenance.args,
29
34
  returns: functionProvenance.returns,
30
35
  error: functionProvenance.error,
@@ -32,14 +37,14 @@ const make = (api, { functionSpec, handler }) => Match.value(functionSpec.functi
32
37
  }));
33
38
  }), Match.when("mutation", () => {
34
39
  return Match.value(functionVisibility).pipe(Match.when("public", () => mutationGeneric), Match.when("internal", () => internalMutationGeneric), Match.exhaustive)(mutationFunction({
35
- databaseSchema: api.databaseSchema,
40
+ databaseSchema,
36
41
  args: functionProvenance.args,
37
42
  returns: functionProvenance.returns,
38
43
  error: functionProvenance.error,
39
44
  handler
40
45
  }));
41
46
  }), Match.when("action", () => {
42
- return Match.value(functionVisibility).pipe(Match.when("public", () => actionGeneric), Match.when("internal", () => internalActionGeneric), Match.exhaustive)(convexActionFunction(api.databaseSchema, {
47
+ return Match.value(functionVisibility).pipe(Match.when("public", () => actionGeneric), Match.when("internal", () => internalActionGeneric), Match.exhaustive)(convexActionFunction(databaseSchema, {
43
48
  args: functionProvenance.args,
44
49
  returns: functionProvenance.returns,
45
50
  error: functionProvenance.error,
@@ -84,10 +89,10 @@ const queryFunction = ({ databaseSchema, args, returns, error, handler }) => ({
84
89
  args: compileArgsSchema(args),
85
90
  returns: compileReturnsSchema(returns),
86
91
  handler: (ctx, actualArgs) => withStubbedDateNow((clock) => Effect.gen(function* () {
87
- return yield* pipe(yield* handler(yield* pipe(actualArgs, Schema.decode(args), Effect.orDie)).pipe(Effect.provide(Layer.mergeAll(layer$1(databaseSchema, ctx.db), layer(ctx.auth), StorageReader$1.layer(ctx.storage), layer$4(ctx.runQuery), Layer.succeed(QueryCtx(), ctx), Layer.setConfigProvider(make$1())))), Schema.encode(returns), Effect.orDie);
92
+ return yield* pipe(yield* handler(yield* pipe(actualArgs, Schema.decode(args), Effect.orDie)).pipe(Effect.provide(Layer.mergeAll(layer$1(databaseSchema, ctx.db), layer(ctx.auth), StorageReader.layer(ctx.storage), layer$4(ctx.runQuery), Layer.succeed(QueryCtx(), ctx), Layer.setConfigProvider(make$1())))), Schema.encode(returns), Effect.orDie);
88
93
  }).pipe(Effect.withClock(clock), runHandlerPromise(error)))
89
94
  });
90
- const mutationLayer = (schema, ctx) => Layer.mergeAll(layer$1(schema, ctx.db), layer$2(schema, ctx.db), layer(ctx.auth), layer$5(ctx.scheduler), StorageReader$1.layer(ctx.storage), StorageWriter$1.layer(ctx.storage), layer$4(ctx.runQuery), layer$3(ctx.runMutation), Layer.succeed(MutationCtx(), ctx), Layer.setConfigProvider(make$1()));
95
+ const mutationLayer = (schema, ctx) => Layer.mergeAll(layer$1(schema, ctx.db), layer$2(schema, ctx.db), layer(ctx.auth), layer$5(ctx.scheduler), StorageReader.layer(ctx.storage), StorageWriter.layer(ctx.storage), layer$4(ctx.runQuery), layer$3(ctx.runMutation), Layer.succeed(MutationCtx(), ctx), Layer.setConfigProvider(make$1()));
91
96
  const mutationFunction = ({ databaseSchema, args, returns, error, handler }) => ({
92
97
  args: compileArgsSchema(args),
93
98
  returns: compileReturnsSchema(returns),
@@ -1 +1 @@
1
- {"version":3,"file":"RegisteredConvexFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","DatabaseReader.layer","Auth.layer","StorageReader","QueryRunner.layer","QueryCtx.QueryCtx","ConvexConfigProvider.make","RegisteredFunction.runHandlerPromise","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 type { Value } from \"convex/values\";\nimport { Clock, 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 } from \"./StorageReader\";\nimport { StorageWriter } from \"./StorageWriter\";\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({\n databaseSchema: api.databaseSchema,\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n error: functionProvenance.error,\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({\n databaseSchema: api.databaseSchema,\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n error: functionProvenance.error,\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 error: functionProvenance.error,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.exhaustive,\n );\n }),\n Match.exhaustive,\n );\n\n/**\n * Convex's query cache is invalidated by any Date.now() call during handler\n * execution. Effect's unsafeFork calls Date.now() when constructing a\n * FiberId.Runtime, which trips the cache for every confect-wrapped query. We\n * stub Date.now to 0 for the span of the handler; queries are forbidden from\n * relying on real time for correctness anyway.\n *\n * Users who explicitly want the real timestamp can still reach it via Effect's\n * Clock service (Clock.currentTimeMillis/Clock.currentTimeNanos). We provide a\n * Clock whose user-facing Effects call realDateNow (Convex's tracker) directly,\n * making Clock an explicit opt-in to cache invalidation. The unsafe methods\n * used internally by Effect (logging, span events, scheduler) return constants\n * so they never touch the tracker—caching is not broken by default.\n */\nconst unpatchedClock = (realDateNow: () => number): Clock.Clock => {\n const defaultClock = Clock.make();\n return {\n ...defaultClock,\n unsafeCurrentTimeMillis: () => 0,\n unsafeCurrentTimeNanos: () => 0n,\n currentTimeMillis: Effect.sync(() => realDateNow()),\n currentTimeNanos: Effect.sync(() => BigInt(realDateNow()) * 1_000_000n),\n };\n};\n\nconst withStubbedDateNow = async <T>(\n queryHandler: (clock: Clock.Clock) => Promise<T>,\n): Promise<T> => {\n const realDateNow = Date.now;\n const clock = unpatchedClock(realDateNow);\n Date.now = () => 0;\n try {\n return await queryHandler(clock);\n } finally {\n Date.now = realDateNow;\n }\n};\n\nconst queryFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>({\n databaseSchema,\n args,\n returns,\n error,\n handler,\n}: {\n databaseSchema: DatabaseSchema_;\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema<Error, Value> | undefined;\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 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 withStubbedDateNow((clock) =>\n Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n );\n const decodedReturns = yield* handler(decodedArgs).pipe(\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 return yield* pipe(\n decodedReturns,\n Schema.encode(returns),\n Effect.orDie,\n );\n }).pipe(\n Effect.withClock(clock),\n RegisteredFunction.runHandlerPromise(error),\n ),\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 DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>({\n databaseSchema,\n args,\n returns,\n error,\n handler,\n}: {\n databaseSchema: DatabaseSchema_;\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema<Error, Value> | undefined;\n handler: (\n a: Args,\n ) => Effect.Effect<Returns, E, MutationServices<DatabaseSchema_>>;\n}) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericMutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n );\n const decodedReturns = yield* handler(decodedArgs).pipe(\n Effect.provide(mutationLayer(databaseSchema, ctx)),\n );\n return yield* pipe(decodedReturns, Schema.encode(returns), Effect.orDie);\n }).pipe(RegisteredFunction.runHandlerPromise(error)),\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 error,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema.AnyNoContext | undefined;\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 error,\n handler,\n createLayer: (ctx) =>\n Layer.mergeAll(\n RegisteredFunction.actionLayer(schema, ctx),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n ),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,QACX,KACA,EAAE,cAAc,cAEhB,MAAM,MAAM,aAAa,mBAAmB,CAAC,KAC3C,MAAM,IAAI,gBAAgB,QAAkC,EAC5D,MAAM,IAAI,iBAAiB;CACzB,MAAM,EAAE,oBAA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AO,KAAK,EACnB,OAAO,MACR,CACiD,CAAC,KACjD,OAAO,QAAQ,cAAc,gBAAgB,IAAI,CAAC,CACnD,EACkC,OAAO,OAAO,QAAQ,EAAE,OAAO,MAAM;GACxE,CAAC,KAAKO,kBAAqC,MAAM,CAAC;CACvD;AAED,MAAM,wBAQJ,QACA,EACE,MACA,SACA,OACA,cAcFM,mBAAsC;CACpC;CACA;CACA;CACA;CACA,cAAc,QACZ,MAAM,SACJC,YAA+B,QAAQ,IAAI,EAC3C,MAAM,kBAAkBR,QAA2B,CAAC,CACrD;CACJ,CAAC"}
1
+ {"version":3,"file":"RegisteredConvexFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","DatabaseReader.layer","Auth.layer","QueryRunner.layer","QueryCtx.QueryCtx","ConvexConfigProvider.make","RegisteredFunction.runHandlerPromise","DatabaseWriter.layer","Scheduler.layer","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 type { Value } from \"convex/values\";\nimport { pipe } from \"effect/Function\";\nimport * as Clock from \"effect/Clock\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Match from \"effect/Match\";\nimport * as Schema from \"effect/Schema\";\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 } from \"./StorageReader\";\nimport { StorageWriter } from \"./StorageWriter\";\n\nexport const make = (\n databaseSchema: DatabaseSchema.AnyWithProps,\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({\n databaseSchema,\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n error: functionProvenance.error,\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({\n databaseSchema,\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n error: functionProvenance.error,\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(databaseSchema, {\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n error: functionProvenance.error,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.exhaustive,\n );\n }),\n Match.exhaustive,\n );\n\n/**\n * Convex's query cache is invalidated by any Date.now() call during handler\n * execution. Effect's unsafeFork calls Date.now() when constructing a\n * FiberId.Runtime, which trips the cache for every confect-wrapped query. We\n * stub Date.now to 0 for the span of the handler; queries are forbidden from\n * relying on real time for correctness anyway.\n *\n * Users who explicitly want the real timestamp can still reach it via Effect's\n * Clock service (Clock.currentTimeMillis/Clock.currentTimeNanos). We provide a\n * Clock whose user-facing Effects call realDateNow (Convex's tracker) directly,\n * making Clock an explicit opt-in to cache invalidation. The unsafe methods\n * used internally by Effect (logging, span events, scheduler) return constants\n * so they never touch the tracker—caching is not broken by default.\n */\nconst unpatchedClock = (realDateNow: () => number): Clock.Clock => {\n const defaultClock = Clock.make();\n return {\n ...defaultClock,\n unsafeCurrentTimeMillis: () => 0,\n unsafeCurrentTimeNanos: () => 0n,\n currentTimeMillis: Effect.sync(() => realDateNow()),\n currentTimeNanos: Effect.sync(() => BigInt(realDateNow()) * 1_000_000n),\n };\n};\n\nconst withStubbedDateNow = async <T>(\n queryHandler: (clock: Clock.Clock) => Promise<T>,\n): Promise<T> => {\n const realDateNow = Date.now;\n const clock = unpatchedClock(realDateNow);\n Date.now = () => 0;\n try {\n return await queryHandler(clock);\n } finally {\n Date.now = realDateNow;\n }\n};\n\nconst queryFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>({\n databaseSchema,\n args,\n returns,\n error,\n handler,\n}: {\n databaseSchema: DatabaseSchema_;\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema<Error, Value> | undefined;\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 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 withStubbedDateNow((clock) =>\n Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n );\n const decodedReturns = yield* handler(decodedArgs).pipe(\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 return yield* pipe(\n decodedReturns,\n Schema.encode(returns),\n Effect.orDie,\n );\n }).pipe(\n Effect.withClock(clock),\n RegisteredFunction.runHandlerPromise(error),\n ),\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 DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>({\n databaseSchema,\n args,\n returns,\n error,\n handler,\n}: {\n databaseSchema: DatabaseSchema_;\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema<Error, Value> | undefined;\n handler: (\n a: Args,\n ) => Effect.Effect<Returns, E, MutationServices<DatabaseSchema_>>;\n}) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericMutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n );\n const decodedReturns = yield* handler(decodedArgs).pipe(\n Effect.provide(mutationLayer(databaseSchema, ctx)),\n );\n return yield* pipe(decodedReturns, Schema.encode(returns), Effect.orDie);\n }).pipe(RegisteredFunction.runHandlerPromise(error)),\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 error,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema.AnyNoContext | undefined;\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 error,\n handler,\n createLayer: (ctx) =>\n Layer.mergeAll(\n RegisteredFunction.actionLayer(schema, ctx),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n ),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,QACX,gBACA,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;GACZ;GACA,MAAM,mBAAmB;GACzB,SAAS,mBAAmB;GAC5B,OAAO,mBAAmB;GACjB;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;GACf;GACA,MAAM,mBAAmB;GACzB,SAAS,mBAAmB;GAC5B,OAAO,mBAAmB;GACjB;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,gBAAgB;GACnC,MAAM,mBAAmB;GACzB,SA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IAAI,UAAU,EAC9B,cAAc,MAAM,IAAI,QAAQ,EAChC,cAAc,MAAM,IAAI,QAAQ,EAChCL,QAAkB,IAAI,SAAS,EAC/BM,QAAqB,IAAI,YAAY,EACrC,MAAM,QACJC,aAEG,EACH,IACD,EACD,MAAM,kBAAkBL,QAA2B,CAAC,CACrD;AAaH,MAAM,oBAOJ,EACA,gBACA,MACA,SACA,OACA,eASK;CACL,MAAMN,kBAAoC,KAAK;CAC/C,SAASC,qBAAuC,QAAQ;CACxD,UACE,KAGA,eAEA,OAAO,IAAI,aAAa;AAStB,SAAO,OAAO,KAHS,OAAO,QALV,OAAO,KACzB,YACA,OAAO,OAAO,KAAK,EACnB,OAAO,MACR,CACiD,CAAC,KACjD,OAAO,QAAQ,cAAc,gBAAgB,IAAI,CAAC,CACnD,EACkC,OAAO,OAAO,QAAQ,EAAE,OAAO,MAAM;GACxE,CAAC,KAAKM,kBAAqC,MAAM,CAAC;CACvD;AAED,MAAM,wBAQJ,QACA,EACE,MACA,SACA,OACA,cAcFK,mBAAsC;CACpC;CACA;CACA;CACA;CACA,cAAc,QACZ,MAAM,SACJC,YAA+B,QAAQ,IAAI,EAC3C,MAAM,kBAAkBP,QAA2B,CAAC,CACrD;CACJ,CAAC"}
@@ -1,41 +1,32 @@
1
- import { ActionCtx } from "./ActionCtx.js";
2
- import { ActionRunner } from "./ActionRunner.js";
3
- import { AnyWithProps } from "./DatabaseSchema.js";
4
- import { Auth as Auth$1 } from "./Auth.js";
5
- import { FromSchema, TableNames, ToConvex } from "./DataModel.js";
6
- import { MutationRunner } from "./MutationRunner.js";
7
- import { QueryRunner } from "./QueryRunner.js";
8
- import { Scheduler as Scheduler$1 } from "./Scheduler.js";
9
- import { StorageActionWriter as StorageActionWriter$1 } from "./StorageActionWriter.js";
10
- import { StorageReader as StorageReader$1 } from "./StorageReader.js";
11
- import { StorageWriter as StorageWriter$1 } from "./StorageWriter.js";
12
- import { VectorSearch } from "./VectorSearch.js";
13
- import { Effect, Layer, Schema } from "effect";
14
- import * as _confect_core_Ref0 from "@confect/core/Ref";
15
- import * as convex_server0 from "convex/server";
16
- import { DefaultFunctionArgs, FunctionVisibility, GenericActionCtx, RegisteredAction, RegisteredMutation, RegisteredQuery } from "convex/server";
17
- import { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
18
- import * as convex_values0 from "convex/values";
19
- import { Value } from "convex/values";
20
- import * as FunctionProvenance from "@confect/core/FunctionProvenance";
21
- import * as effect_Duration0 from "effect/Duration";
22
- import * as effect_DateTime0 from "effect/DateTime";
23
- import * as effect_ParseResult0 from "effect/ParseResult";
24
-
25
- //#region src/RegisteredFunction.d.ts
26
- declare namespace RegisteredFunction_d_exports {
27
- export { ActionServices, Any, ConvexRegisteredFunction, RegisteredFunction, actionFunctionBase, actionLayer, runHandlerPromise };
28
- }
29
- type Any = RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;
1
+ import type { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
2
+ import type * as FunctionProvenance from "@confect/core/FunctionProvenance";
3
+ import { type DefaultFunctionArgs, type FunctionVisibility, type GenericActionCtx, type RegisteredAction, type RegisteredMutation, type RegisteredQuery } from "convex/server";
4
+ import type { Value } from "convex/values";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Layer from "effect/Layer";
7
+ import * as Schema from "effect/Schema";
8
+ import * as ActionCtx from "./ActionCtx";
9
+ import * as ActionRunner from "./ActionRunner";
10
+ import * as Auth from "./Auth";
11
+ import type * as DatabaseSchema from "./DatabaseSchema";
12
+ import type * as DataModel from "./DataModel";
13
+ import * as MutationRunner from "./MutationRunner";
14
+ import * as QueryRunner from "./QueryRunner";
15
+ import * as Scheduler from "./Scheduler";
16
+ import * as StorageActionWriter from "./StorageActionWriter";
17
+ import * as StorageReader from "./StorageReader";
18
+ import * as StorageWriter from "./StorageWriter";
19
+ import * as VectorSearch from "./VectorSearch";
20
+ export type Any = RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;
30
21
  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;
31
- type ConvexRegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends {
32
- functionProvenance: {
33
- _tag: "Convex";
34
- _args: infer Args_ extends DefaultFunctionArgs;
35
- _returns: infer Returns_;
36
- };
22
+ export type ConvexRegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends {
23
+ functionProvenance: {
24
+ _tag: "Convex";
25
+ _args: infer Args_ extends DefaultFunctionArgs;
26
+ _returns: infer Returns_;
27
+ };
37
28
  } ? 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;
38
- 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;
29
+ export 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;
39
30
  /**
40
31
  * Run the `Effect` as a `Promise`. The error schema acts as an allowlist of
41
32
  * failures that may be surfaced to the client as a `ConvexError`:
@@ -51,36 +42,29 @@ type RegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = Funct
51
42
  * error channel—reaches the client as a `ConvexError`. The fiber dies and
52
43
  * `runPromise` rejects with a generic failure.
53
44
  */
54
- declare const runHandlerPromise: (errorSchema: Schema.Schema.AnyNoContext | undefined) => <A, E>(effect: Effect.Effect<A, E>) => Promise<A>;
55
- declare const actionFunctionBase: <Schema extends AnyWithProps, Args, ConvexArgs extends DefaultFunctionArgs, Returns, ConvexReturns, E, R>({
56
- args,
57
- returns,
58
- error,
59
- handler,
60
- createLayer
61
- }: {
62
- args: Schema.Schema<Args, ConvexArgs>;
63
- returns: Schema.Schema<Returns, ConvexReturns>;
64
- error: Schema.Schema<Error, Value> | undefined;
65
- handler: (a: Args) => Effect.Effect<Returns, E, R>;
66
- createLayer: (ctx: GenericActionCtx<ToConvex<FromSchema<Schema>>>) => Layer.Layer<R>;
45
+ export declare const runHandlerPromise: (errorSchema: Schema.Schema.AnyNoContext | undefined) => <A, E>(effect: Effect.Effect<A, E>) => Promise<A>;
46
+ export declare const actionFunctionBase: <Schema extends DatabaseSchema.AnyWithProps, Args, ConvexArgs extends DefaultFunctionArgs, Returns, ConvexReturns, E, R>({ args, returns, error, handler, createLayer, }: {
47
+ args: Schema.Schema<Args, ConvexArgs>;
48
+ returns: Schema.Schema<Returns, ConvexReturns>;
49
+ error: Schema.Schema<Error, Value> | undefined;
50
+ handler: (a: Args) => Effect.Effect<Returns, E, R>;
51
+ createLayer: (ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>) => Layer.Layer<R>;
67
52
  }) => {
68
- args: convex_values0.PropertyValidators;
69
- returns: convex_values0.Validator<any, any, any>;
70
- handler: (ctx: GenericActionCtx<ToConvex<FromSchema<Schema>>>, actualArgs: ConvexArgs) => Promise<ConvexReturns>;
53
+ args: import("convex/values").PropertyValidators;
54
+ returns: import("convex/values").Validator<any, any, any>;
55
+ handler: (ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>, actualArgs: ConvexArgs) => Promise<ConvexReturns>;
71
56
  };
72
- 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_>>>;
73
- declare const actionLayer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, ctx: GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<Auth$1 | GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>> | {
74
- runAfter: <Ref_ extends _confect_core_Ref0.AnyMutation | _confect_core_Ref0.AnyAction>(delay: effect_Duration0.Duration, ref: Ref_, ...args: _confect_core_Ref0.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
75
- runAt: <Ref_ extends _confect_core_Ref0.AnyMutation | _confect_core_Ref0.AnyAction>(dateTime: effect_DateTime0.DateTime, ref: Ref_, ...args: _confect_core_Ref0.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
76
- } | StorageReader$1 | StorageWriter$1 | StorageActionWriter$1 | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, ...args: _confect_core_Ref0.OptionalArgs<Query>) => Effect.Effect<_confect_core_Ref0.Returns<Query>, _confect_core_Ref0.Error<Query> | effect_ParseResult0.ParseError>) | (<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, ...args: _confect_core_Ref0.OptionalArgs<Mutation>) => Effect.Effect<_confect_core_Ref0.Returns<Mutation>, _confect_core_Ref0.Error<Mutation> | effect_ParseResult0.ParseError>) | (<Action extends _confect_core_Ref0.AnyAction>(action: Action, ...args: _confect_core_Ref0.OptionalArgs<Action>) => Effect.Effect<_confect_core_Ref0.Returns<Action>, _confect_core_Ref0.Error<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: {
77
- vector: number[];
78
- limit?: number;
79
- 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>;
57
+ export type ActionServices<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> = Scheduler.Scheduler | Auth.Auth | StorageReader.StorageReader | StorageWriter.StorageWriter | StorageActionWriter.StorageActionWriter | QueryRunner.QueryRunner | MutationRunner.MutationRunner | ActionRunner.ActionRunner | VectorSearch.VectorSearch<DataModel.FromSchema<DatabaseSchema_>> | ActionCtx.ActionCtx<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>>;
58
+ export declare const actionLayer: <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(databaseSchema: DatabaseSchema_, ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>>) => Layer.Layer<(<Action extends import("@confect/core/Ref").AnyAction>(action: Action, ...args: import("@confect/core/Ref").OptionalArgs<Action>) => Effect.Effect<import("@confect/core/Ref").Returns<Action>, import("@confect/core/Ref").Error<Action> | import("effect/ParseResult").ParseError>) | Auth.Auth | (<Mutation extends import("@confect/core/Ref").AnyMutation>(mutation: Mutation, ...args: import("@confect/core/Ref").OptionalArgs<Mutation>) => Effect.Effect<import("@confect/core/Ref").Returns<Mutation>, import("@confect/core/Ref").Error<Mutation> | import("effect/ParseResult").ParseError>) | (<Query extends import("@confect/core/Ref").AnyQuery>(query: Query, ...args: import("@confect/core/Ref").OptionalArgs<Query>) => Effect.Effect<import("@confect/core/Ref").Returns<Query>, import("@confect/core/Ref").Error<Query> | import("effect/ParseResult").ParseError>) | {
59
+ runAfter: <Ref_ extends import("@confect/core/Ref").AnyMutation | import("@confect/core/Ref").AnyAction>(delay: import("effect/Duration").Duration, ref: Ref_, ...args: import("@confect/core/Ref").OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
60
+ runAt: <Ref_ extends import("@confect/core/Ref").AnyMutation | import("@confect/core/Ref").AnyAction>(dateTime: import("effect/DateTime").DateTime, ref: Ref_, ...args: import("@confect/core/Ref").OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
61
+ } | StorageActionWriter.StorageActionWriter | StorageReader.StorageReader | StorageWriter.StorageWriter | GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>> | (<TableName extends DataModel.TableNames<DataModel.FromSchema<DatabaseSchema_>>, IndexName extends keyof import("convex/server").VectorIndexes<import("convex/server").NamedTableInfo<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>, TableName>>>(tableName: TableName, indexName: IndexName, query: {
62
+ vector: number[];
63
+ limit?: number;
64
+ filter?: (q: import("convex/server").VectorFilterBuilder<import("convex/server").DocumentByInfo<import("convex/server").NamedTableInfo<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>, TableName>>, import("convex/server").NamedVectorIndex<import("convex/server").NamedTableInfo<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>, TableName>, IndexName>>) => import("convex/server").FilterExpression<boolean>;
80
65
  }) => Effect.Effect<{
81
- _id: convex_values0.GenericId<TableName>;
82
- _score: number;
66
+ _id: import("convex/values").GenericId<TableName>;
67
+ _score: number;
83
68
  }[], never, never>), never, never>;
84
- //#endregion
85
- export { ActionServices, Any, ConvexRegisteredFunction, RegisteredFunction, RegisteredFunction_d_exports, actionFunctionBase, actionLayer, runHandlerPromise };
69
+ export {};
86
70
  //# sourceMappingURL=RegisteredFunction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RegisteredFunction.d.ts","names":[],"sources":["../src/RegisteredFunction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BY,GAAA,GACR,eAAA,CAAgB,kBAAA,EAAoB,mBAAA,SACpC,kBAAA,CAAmB,kBAAA,EAAoB,mBAAA,SACvC,gBAAA,CAAiB,kBAAA,EAAoB,mBAAA;AAAA,KAEpC,yBAAA,uBACmB,YAAA,CAAa,YAAA,IAEnC,YAAA,CAAa,WAAA,CAAY,aAAA,8BACvB,mBAAA,GACE,sBAAA,CAAuB,eAAA,CACrB,aAAA,8CAEA,eAAA,CACE,YAAA,CAAa,qBAAA,CAAsB,a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C,EAAE,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD,WAAW,EAAE,CACX,GAAG,EAAE,gBAAgB,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,KACpE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CACrB;;;mBAIQ,gBAAgB,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,cAC3D,UAAU,KACrB,OAAO,CAAC,aAAa,CAAC;CAYzB,CAAC;AAEH,MAAM,MAAM,cAAc,CACxB,eAAe,SAAS,cAAc,CAAC,YAAY,IAEjD,SAAS,CAAC,SAAS,GACnB,IAAI,CAAC,IAAI,GACT,aAAa,CAAC,aAAa,GAC3B,aAAa,CAAC,aAAa,GAC3B,mBAAmB,CAAC,mBAAmB,GACvC,WAAW,CAAC,WAAW,GACvB,cAAc,CAAC,cAAc,GAC7B,YAAY,CAAC,YAAY,GACzB,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,GAChE,SAAS,CAAC,SAAS,CACjB,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAC1D,CAAC;AAEN,eAAO,MAAM,WAAW,GACtB,eAAe,SAAS,cAAc,CAAC,YAAY,EAEnD,gBAAgB,eAAe,EAC/B,KAAK,gBAAgB,CACnB,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAC1D;;;;;;;;;;kCAkBA,CAAC"}
@@ -6,12 +6,16 @@ import { compileArgsSchema, compileReturnsSchema } from "./SchemaToValidator.js"
6
6
  import { layer as layer$2 } from "./MutationRunner.js";
7
7
  import { layer as layer$3 } from "./QueryRunner.js";
8
8
  import { layer as layer$4 } from "./Scheduler.js";
9
- import { StorageActionWriter as StorageActionWriter$1 } from "./StorageActionWriter.js";
10
- import { StorageReader as StorageReader$1 } from "./StorageReader.js";
11
- import { StorageWriter as StorageWriter$1 } from "./StorageWriter.js";
9
+ import { StorageActionWriter } from "./StorageActionWriter.js";
10
+ import { StorageReader } from "./StorageReader.js";
11
+ import { StorageWriter } from "./StorageWriter.js";
12
12
  import { layer as layer$5 } from "./VectorSearch.js";
13
- import { Effect, Either, Layer, Schema, pipe } from "effect";
14
13
  import "convex/server";
14
+ import * as Layer from "effect/Layer";
15
+ import { pipe } from "effect/Function";
16
+ import * as Effect from "effect/Effect";
17
+ import * as Schema from "effect/Schema";
18
+ import * as Either from "effect/Either";
15
19
  import { ConvexError } from "convex/values";
16
20
 
17
21
  //#region src/RegisteredFunction.ts
@@ -52,7 +56,7 @@ const actionFunctionBase = ({ args, returns, error, handler, createLayer }) => (
52
56
  return yield* pipe(yield* handler(yield* pipe(actualArgs, Schema.decode(args), Effect.orDie)).pipe(Effect.provide(createLayer(ctx))), Schema.encode(returns), Effect.orDie);
53
57
  }).pipe(runHandlerPromise(error))
54
58
  });
55
- const actionLayer = (databaseSchema, ctx) => Layer.mergeAll(layer$4(ctx.scheduler), layer$1(ctx.auth), StorageReader$1.layer(ctx.storage), StorageWriter$1.layer(ctx.storage), StorageActionWriter$1.layer(ctx.storage), layer$3(ctx.runQuery), layer$2(ctx.runMutation), layer(ctx.runAction), layer$5(ctx.vectorSearch), Layer.succeed(ActionCtx(), ctx));
59
+ const actionLayer = (databaseSchema, ctx) => Layer.mergeAll(layer$4(ctx.scheduler), layer$1(ctx.auth), StorageReader.layer(ctx.storage), StorageWriter.layer(ctx.storage), StorageActionWriter.layer(ctx.storage), layer$3(ctx.runQuery), layer$2(ctx.runMutation), layer(ctx.runAction), layer$5(ctx.vectorSearch), Layer.succeed(ActionCtx(), ctx));
56
60
 
57
61
  //#endregion
58
62
  export { RegisteredFunction_exports, actionFunctionBase, actionLayer, runHandlerPromise };
@@ -1 +1 @@
1
- {"version":3,"file":"RegisteredFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","Scheduler.layer","Auth.layer","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 type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport { Effect, Either, 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 * as StorageActionWriter from \"./StorageActionWriter\";\nimport * as StorageReader from \"./StorageReader\";\nimport * as StorageWriter from \"./StorageWriter\";\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\n/**\n * Run the `Effect` as a `Promise`. The error schema acts as an allowlist of\n * failures that may be surfaced to the client as a `ConvexError`:\n *\n * - With a schema: typed errors are schema-encoded and wrapped in a\n * `ConvexError`, then thrown so Convex surfaces the data to the client.\n * `Effect.either` escapes the failure channel before `runPromise` so the thrown\n * `ConvexError` retains its `Symbol.for(\"ConvexError\")` identity instead of\n * being wrapped in Effect's `FiberFailure`.\n *\n * - Without a schema: every failure is converted to a defect via\n * `Effect.orDie`, so nothing—not even a `ConvexError` the handler placed in its\n * error channel—reaches the client as a `ConvexError`. The fiber dies and\n * `runPromise` rejects with a generic failure.\n */\nexport const runHandlerPromise =\n (errorSchema: Schema.Schema.AnyNoContext | undefined) =>\n <A, E>(effect: Effect.Effect<A, E>): Promise<A> => {\n if (errorSchema === undefined) {\n return Effect.runPromise(Effect.orDie(effect));\n }\n const withConvexError = effect.pipe(\n Effect.catchAll((typedError) =>\n pipe(\n Schema.encode(errorSchema)(typedError),\n Effect.orDie,\n Effect.andThen((encodedError) =>\n Effect.fail(new ConvexError(encodedError)),\n ),\n ),\n ),\n );\n return Effect.runPromise(Effect.either(withConvexError)).then(\n Either.match({\n onLeft: (error) => {\n throw error;\n },\n onRight: (value) => value,\n }),\n );\n };\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 error,\n handler,\n createLayer,\n}: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema<Error, Value> | undefined;\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 Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n );\n const decodedReturns = yield* handler(decodedArgs).pipe(\n Effect.provide(createLayer(ctx)),\n );\n return yield* pipe(decodedReturns, Schema.encode(returns), Effect.orDie);\n }).pipe(runHandlerPromise(error)),\n});\n\nexport type ActionServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n> =\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader.StorageReader\n | StorageWriter.StorageWriter\n | StorageActionWriter.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.StorageReader.layer(ctx.storage),\n StorageWriter.StorageWriter.layer(ctx.storage),\n StorageActionWriter.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkIA,MAAa,qBACV,iBACM,WAA4C;AACjD,KAAI,gBAAgB,OAClB,QAAO,OAAO,WAAW,OAAO,MAAM,OAAO,CAAC;CAEhD,MAAM,kBAAkB,OAAO,KAC7B,OAAO,UAAU,eACf,KACE,OAAO,OAAO,YAAY,CAAC,WAAW,EACtC,OAAO,OACP,OAAO,SAAS,iBACd,OAAO,KAAK,IAAI,YAAY,aAAa,CAAC,CAC3C,CACF,CACF,CACF;AACD,QAAO,OAAO,WAAW,OAAO,OAAO,gBAAgB,CAAC,CAAC,KACvD,OAAO,MAAM;EACX,SAAS,UAAU;AACjB,SAAM;;EAER,UAAU,UAAU;EACrB,CAAC,CACH;;AAGL,MAAa,sBAQX,EACA,MACA,SACA,OACA,SACA,mBASK;CACL,MAAMA,kBAAoC,KAAK;CAC/C,SAASC,qBAAuC,QAAQ;CACxD,UACE,KACA,eAEA,OAAO,IAAI,aAAa;AAStB,SAAO,OAAO,KAHS,OAAO,QALV,OAAO,KACzB,YACA,OAAO,OAAO,KAAK,EACnB,OAAO,MACR,CACiD,CAAC,KACjD,OAAO,QAAQ,YAAY,IAAI,CAAC,CACjC,EACkC,OAAO,OAAO,QAAQ,EAAE,OAAO,MAAM;GACxE,CAAC,KAAK,kBAAkB,MAAM,CAAC;CACpC;AAkBD,MAAa,eAGX,gBACA,QAIA,MAAM,SACJC,QAAgB,IAAI,UAAU,EAC9BC,QAAW,IAAI,KAAK,kBACQ,MAAM,IAAI,QAAQ,kBAClB,MAAM,IAAI,QAAQ,wBACN,MAAM,IAAI,QAAQ,EAC1DC,QAAkB,IAAI,SAAS,EAC/BC,QAAqB,IAAI,YAAY,EACrCC,MAAmB,IAAI,UAAU,EACjCC,QAAmB,IAAI,aAAa,EACpC,MAAM,QACJC,WAEG,EACH,IACD,CACF"}
1
+ {"version":3,"file":"RegisteredFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","Scheduler.layer","Auth.layer","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 type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport { pipe } from \"effect/Function\";\nimport * as Effect from \"effect/Effect\";\nimport * as Either from \"effect/Either\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\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 * as StorageActionWriter from \"./StorageActionWriter\";\nimport * as StorageReader from \"./StorageReader\";\nimport * as StorageWriter from \"./StorageWriter\";\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\n/**\n * Run the `Effect` as a `Promise`. The error schema acts as an allowlist of\n * failures that may be surfaced to the client as a `ConvexError`:\n *\n * - With a schema: typed errors are schema-encoded and wrapped in a\n * `ConvexError`, then thrown so Convex surfaces the data to the client.\n * `Effect.either` escapes the failure channel before `runPromise` so the thrown\n * `ConvexError` retains its `Symbol.for(\"ConvexError\")` identity instead of\n * being wrapped in Effect's `FiberFailure`.\n *\n * - Without a schema: every failure is converted to a defect via\n * `Effect.orDie`, so nothing—not even a `ConvexError` the handler placed in its\n * error channel—reaches the client as a `ConvexError`. The fiber dies and\n * `runPromise` rejects with a generic failure.\n */\nexport const runHandlerPromise =\n (errorSchema: Schema.Schema.AnyNoContext | undefined) =>\n <A, E>(effect: Effect.Effect<A, E>): Promise<A> => {\n if (errorSchema === undefined) {\n return Effect.runPromise(Effect.orDie(effect));\n }\n const withConvexError = effect.pipe(\n Effect.catchAll((typedError) =>\n pipe(\n Schema.encode(errorSchema)(typedError),\n Effect.orDie,\n Effect.andThen((encodedError) =>\n Effect.fail(new ConvexError(encodedError)),\n ),\n ),\n ),\n );\n return Effect.runPromise(Effect.either(withConvexError)).then(\n Either.match({\n onLeft: (error) => {\n throw error;\n },\n onRight: (value) => value,\n }),\n );\n };\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 error,\n handler,\n createLayer,\n}: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema<Error, Value> | undefined;\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 Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n );\n const decodedReturns = yield* handler(decodedArgs).pipe(\n Effect.provide(createLayer(ctx)),\n );\n return yield* pipe(decodedReturns, Schema.encode(returns), Effect.orDie);\n }).pipe(runHandlerPromise(error)),\n});\n\nexport type ActionServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n> =\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader.StorageReader\n | StorageWriter.StorageWriter\n | StorageActionWriter.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.StorageReader.layer(ctx.storage),\n StorageWriter.StorageWriter.layer(ctx.storage),\n StorageActionWriter.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsIA,MAAa,qBACV,iBACM,WAA4C;AACjD,KAAI,gBAAgB,OAClB,QAAO,OAAO,WAAW,OAAO,MAAM,OAAO,CAAC;CAEhD,MAAM,kBAAkB,OAAO,KAC7B,OAAO,UAAU,eACf,KACE,OAAO,OAAO,YAAY,CAAC,WAAW,EACtC,OAAO,OACP,OAAO,SAAS,iBACd,OAAO,KAAK,IAAI,YAAY,aAAa,CAAC,CAC3C,CACF,CACF,CACF;AACD,QAAO,OAAO,WAAW,OAAO,OAAO,gBAAgB,CAAC,CAAC,KACvD,OAAO,MAAM;EACX,SAAS,UAAU;AACjB,SAAM;;EAER,UAAU,UAAU;EACrB,CAAC,CACH;;AAGL,MAAa,sBAQX,EACA,MACA,SACA,OACA,SACA,mBASK;CACL,MAAMA,kBAAoC,KAAK;CAC/C,SAASC,qBAAuC,QAAQ;CACxD,UACE,KACA,eAEA,OAAO,IAAI,aAAa;AAStB,SAAO,OAAO,KAHS,OAAO,QALV,OAAO,KACzB,YACA,OAAO,OAAO,KAAK,EACnB,OAAO,MACR,CACiD,CAAC,KACjD,OAAO,QAAQ,YAAY,IAAI,CAAC,CACjC,EACkC,OAAO,OAAO,QAAQ,EAAE,OAAO,MAAM;GACxE,CAAC,KAAK,kBAAkB,MAAM,CAAC;CACpC;AAkBD,MAAa,eAGX,gBACA,QAIA,MAAM,SACJC,QAAgB,IAAI,UAAU,EAC9BC,QAAW,IAAI,KAAK,gBACQ,MAAM,IAAI,QAAQ,gBAClB,MAAM,IAAI,QAAQ,sBACN,MAAM,IAAI,QAAQ,EAC1DC,QAAkB,IAAI,SAAS,EAC/BC,QAAqB,IAAI,YAAY,EACrCC,MAAmB,IAAI,UAAU,EACjCC,QAAmB,IAAI,aAAa,EACpC,MAAM,QACJC,WAEG,EACH,IACD,CACF"}
@@ -1,33 +1,55 @@
1
- import { AnyWithProps as AnyWithProps$1 } from "./Api.js";
2
- import { Any, RegisteredFunction } from "./RegisteredFunction.js";
3
- import { GroupImpl } from "./GroupImpl.js";
4
- import { AnyWithProps as AnyWithProps$2 } from "./RegistryItem.js";
5
- import { Layer, Types } from "effect";
6
- import * as Spec from "@confect/core/Spec";
7
- import * as FunctionSpec from "@confect/core/FunctionSpec";
8
- import * as GroupSpec from "@confect/core/GroupSpec";
9
-
10
- //#region src/RegisteredFunctions.d.ts
11
- declare namespace RegisteredFunctions_d_exports {
12
- export { AnyWithProps, ForGroupPath, RegisteredFunctions, buildForGroup };
13
- }
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 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
- interface AnyWithProps {
17
- readonly [key: string]: Any | AnyWithProps;
1
+ import type * as FunctionSpec from "@confect/core/FunctionSpec";
2
+ import type * as GroupSpec from "@confect/core/GroupSpec";
3
+ import type * as Spec from "@confect/core/Spec";
4
+ import type { Layer, Types } from "effect";
5
+ import type * as DatabaseSchema from "./DatabaseSchema";
6
+ import type * as GroupImpl from "./GroupImpl";
7
+ import type * as RegisteredFunction from "./RegisteredFunction";
8
+ import * as RegistryItem from "./RegistryItem";
9
+ export type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> = Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;
10
+ type RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = {
11
+ [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<Groups, GroupName> extends infer Group extends GroupSpec.AnyWithProps ? RegisteredFunctionsForGroupSpec<Group> : never;
12
+ };
13
+ /** The `RegisteredFunction` record for a group's own declared functions. */
14
+ type RegisteredFunctionsOf<Group extends GroupSpec.AnyWithProps> = {
15
+ [FunctionName in FunctionSpec.Name<GroupSpec.Functions<Group>>]: FunctionSpec.WithName<GroupSpec.Functions<Group>, FunctionName> extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps ? RegisteredFunction.RegisteredFunction<FunctionSpec_> : never;
16
+ };
17
+ /**
18
+ * The registered-functions record for a single group, derived from the group's
19
+ * own `GroupSpec`: its declared functions, plus any nested subgroups it carries
20
+ * directly. This is the node that `buildForGroup` returns — computed from the
21
+ * leaf `GroupSpec` itself rather than by navigating the project-wide assembled
22
+ * `Spec` to a dot-path, so the per-group registry's type depends only on its
23
+ * own leaf. For the filesystem layout a leaf `GroupSpec` carries no subgroups
24
+ * (subdirectory children are assembled separately into `_generated/spec.ts`),
25
+ * so this resolves to just the leaf's functions.
26
+ */
27
+ export type RegisteredFunctionsForGroupSpec<Group extends GroupSpec.AnyWithProps> = GroupSpec.Groups<Group> extends infer SubGroups extends GroupSpec.AnyWithProps ? Types.Simplify<RegisteredFunctionsHelper<SubGroups> & RegisteredFunctionsOf<Group>> : RegisteredFunctionsOf<Group>;
28
+ export interface AnyWithProps {
29
+ readonly [key: string]: RegisteredFunction.Any | AnyWithProps;
18
30
  }
19
- type RegisteredFunctionsAtPath<Tree, Path extends string> = Path extends `${infer Head}.${infer Tail}` ? Head extends keyof Tree ? Tree[Head] extends AnyWithProps ? RegisteredFunctionsAtPath<Tree[Head], Tail> : never : never : Path extends keyof Tree ? Tree[Path] : never;
20
- type ForGroupPath<Spec_ extends Spec.AnyWithProps, Path extends string> = RegisteredFunctionsAtPath<RegisteredFunctions<Spec_>, Path>;
21
31
  /**
22
32
  * Build the registered Convex functions for a single group from its finalized
23
33
  * `GroupImpl` layer.
24
34
  *
25
- * The `groupLayer` parameter requires `GroupImpl<string, "Finalized">`, so
26
- * impls that were never piped through `GroupImpl.finalize` (and impls with
27
- * unmet `FunctionImpl` requirements, which cannot be finalized) are rejected
28
- * at the codegen boundary, not just deep inside Convex at runtime.
35
+ * The `groupLayer` parameter requires `GroupImpl<"Finalized">`, so impls that
36
+ * were never piped through `GroupImpl.finalize` (and impls with unmet
37
+ * `FunctionImpl` requirements, which cannot be finalized) are rejected at the
38
+ * codegen boundary, not just deep inside Convex at runtime.
39
+ *
40
+ * The group layer is built with a fresh, isolated `Registry` (rather than the
41
+ * globally-cached default `Context.Reference`), so each `FunctionImpl.make`
42
+ * registers under its flat, single-segment function-name key without colliding
43
+ * with any other group built in the same process — the built registry holds
44
+ * exactly this group's functions at the top level.
45
+ *
46
+ * Only the runtime `databaseSchema` value is needed at runtime (it is forwarded
47
+ * to `makeRegisteredFunction` to build each function's ctx services); the
48
+ * group's `GroupSpec` is supplied purely as the `Group` type parameter to shape
49
+ * the returned record. The generated caller passes it explicitly and imports
50
+ * the leaf spec type-only (`typeof import("…/<group>.spec")["default"]`), so a
51
+ * function's bundle never imports a spec module at runtime.
29
52
  */
30
- declare const buildForGroup: <Api_ extends AnyWithProps$1, const GroupPath_ extends string>(api: Api_, groupPath: GroupPath_, groupLayer: Layer.Layer<GroupImpl<string, "Finalized">>, makeRegisteredFunction: (api: Api_, registryItem: AnyWithProps$2) => Any) => ForGroupPath<Api_["spec"], GroupPath_>;
31
- //#endregion
32
- export { AnyWithProps, ForGroupPath, RegisteredFunctions, RegisteredFunctions_d_exports, buildForGroup };
53
+ export declare const buildForGroup: <Group extends GroupSpec.AnyWithProps>(databaseSchema: DatabaseSchema.AnyWithProps, groupLayer: Layer.Layer<GroupImpl.GroupImpl<"Finalized">>, makeRegisteredFunction: (databaseSchema: DatabaseSchema.AnyWithProps, registryItem: RegistryItem.AnyWithProps) => RegisteredFunction.Any) => RegisteredFunctionsForGroupSpec<Group>;
54
+ export {};
33
55
  //# sourceMappingURL=RegisteredFunctions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RegisteredFunctions.d.ts","names":[],"sources":["../src/RegisteredFunctions.ts"],"mappings":";;;;;;;;;;;;;KAqBY,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,KAG9C,yBAAA,8BAGD,IAAA,yCACA,IAAA,eAAmB,IAAA,GACjB,IAAA,CAAK,IAAA,UAAc,YAAA,GACjB,yBAAA,CAA0B,IAAA,CAAK,IAAA,GAAO,IAAA,oBAG1C,IAAA,eAAmB,IAAA,GACjB,IAAA,CAAK,IAAA;AAAA,KAGC,YAAA,eACI,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{ mapLeaves } from "./internal/utils.js";
3
3
  import { isRegistryItem } from "./RegistryItem.js";
4
- import { Array, Effect, Option, Predicate, Ref, String, pipe } from "effect";
4
+ import * as Effect from "effect/Effect";
5
5
  import * as Registry from "@confect/core/Registry";
6
+ import * as Ref from "effect/Ref";
6
7
 
7
8
  //#region src/RegisteredFunctions.ts
8
9
  var RegisteredFunctions_exports = /* @__PURE__ */ __exportAll({ buildForGroup: () => buildForGroup });
@@ -10,17 +11,29 @@ var RegisteredFunctions_exports = /* @__PURE__ */ __exportAll({ buildForGroup: (
10
11
  * Build the registered Convex functions for a single group from its finalized
11
12
  * `GroupImpl` layer.
12
13
  *
13
- * The `groupLayer` parameter requires `GroupImpl<string, "Finalized">`, so
14
- * impls that were never piped through `GroupImpl.finalize` (and impls with
15
- * unmet `FunctionImpl` requirements, which cannot be finalized) are rejected
16
- * at the codegen boundary, not just deep inside Convex at runtime.
14
+ * The `groupLayer` parameter requires `GroupImpl<"Finalized">`, so impls that
15
+ * were never piped through `GroupImpl.finalize` (and impls with unmet
16
+ * `FunctionImpl` requirements, which cannot be finalized) are rejected at the
17
+ * codegen boundary, not just deep inside Convex at runtime.
18
+ *
19
+ * The group layer is built with a fresh, isolated `Registry` (rather than the
20
+ * globally-cached default `Context.Reference`), so each `FunctionImpl.make`
21
+ * registers under its flat, single-segment function-name key without colliding
22
+ * with any other group built in the same process — the built registry holds
23
+ * exactly this group's functions at the top level.
24
+ *
25
+ * Only the runtime `databaseSchema` value is needed at runtime (it is forwarded
26
+ * to `makeRegisteredFunction` to build each function's ctx services); the
27
+ * group's `GroupSpec` is supplied purely as the `Group` type parameter to shape
28
+ * the returned record. The generated caller passes it explicitly and imports
29
+ * the leaf spec type-only (`typeof import("…/<group>.spec")["default"]`), so a
30
+ * function's bundle never imports a spec module at runtime.
17
31
  */
18
- const buildForGroup = (api, groupPath, groupLayer, makeRegisteredFunction) => {
19
- const registeredFunctions = mapLeaves(Effect.gen(function* () {
32
+ const buildForGroup = (databaseSchema, groupLayer, makeRegisteredFunction) => {
33
+ return mapLeaves(Effect.gen(function* () {
20
34
  const registry = yield* Registry.Registry;
21
35
  return yield* Ref.get(registry);
22
- }).pipe(Effect.provide(groupLayer), Effect.runSync), isRegistryItem, (registryItem) => makeRegisteredFunction(api, registryItem));
23
- return pipe(String.split(groupPath, "."), Array.reduce(Option.some(registeredFunctions), (currentNode, segment) => currentNode.pipe(Option.filter(Predicate.isRecord), Option.flatMap((nodeRecord) => segment in nodeRecord ? Option.some(nodeRecord[segment]) : Option.none()))), Option.getOrThrowWith(() => /* @__PURE__ */ new Error(`No functions registered for group path "${groupPath}"`)));
36
+ }).pipe(Effect.provide(groupLayer), Effect.provideService(Registry.Registry, Ref.unsafeMake({})), Effect.runSync), isRegistryItem, (registryItem) => makeRegisteredFunction(databaseSchema, registryItem));
24
37
  };
25
38
 
26
39
  //#endregion