@confect/server 7.0.0 → 9.0.0-next.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 (52) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/DatabaseSchema.d.ts +6 -6
  3. package/dist/DatabaseSchema.d.ts.map +1 -1
  4. package/dist/DatabaseSchema.js +3 -3
  5. package/dist/DatabaseSchema.js.map +1 -1
  6. package/dist/Document.d.ts.map +1 -1
  7. package/dist/Document.js +35 -23
  8. package/dist/Document.js.map +1 -1
  9. package/dist/FunctionImpl.d.ts +10 -7
  10. package/dist/FunctionImpl.d.ts.map +1 -1
  11. package/dist/FunctionImpl.js +8 -8
  12. package/dist/FunctionImpl.js.map +1 -1
  13. package/dist/GroupImpl.d.ts +51 -12
  14. package/dist/GroupImpl.d.ts.map +1 -1
  15. package/dist/GroupImpl.js +72 -4
  16. package/dist/GroupImpl.js.map +1 -1
  17. package/dist/GroupPath.d.ts +8 -0
  18. package/dist/GroupPath.d.ts.map +1 -0
  19. package/dist/GroupPath.js +10 -0
  20. package/dist/GroupPath.js.map +1 -0
  21. package/dist/RegisteredConvexFunction.d.ts +6 -6
  22. package/dist/RegisteredConvexFunction.d.ts.map +1 -1
  23. package/dist/RegisteredConvexFunction.js +18 -7
  24. package/dist/RegisteredConvexFunction.js.map +1 -1
  25. package/dist/RegisteredFunction.d.ts +3 -3
  26. package/dist/RegisteredFunction.d.ts.map +1 -1
  27. package/dist/RegisteredFunctions.d.ts +15 -4
  28. package/dist/RegisteredFunctions.d.ts.map +1 -1
  29. package/dist/RegisteredFunctions.js +20 -11
  30. package/dist/RegisteredFunctions.js.map +1 -1
  31. package/dist/SchemaToValidator.d.ts +8 -8
  32. package/dist/index.d.ts +1 -3
  33. package/dist/index.js +1 -3
  34. package/package.json +21 -19
  35. package/src/DatabaseSchema.ts +5 -5
  36. package/src/Document.ts +90 -58
  37. package/src/FunctionImpl.ts +27 -36
  38. package/src/GroupImpl.ts +168 -32
  39. package/src/GroupPath.ts +43 -0
  40. package/src/RegisteredConvexFunction.ts +18 -17
  41. package/src/RegisteredFunctions.ts +78 -28
  42. package/src/index.ts +0 -2
  43. package/dist/Impl.d.ts +0 -24
  44. package/dist/Impl.d.ts.map +0 -1
  45. package/dist/Impl.js +0 -28
  46. package/dist/Impl.js.map +0 -1
  47. package/dist/Registry.d.ts +0 -15
  48. package/dist/Registry.d.ts.map +0 -1
  49. package/dist/Registry.js +0 -10
  50. package/dist/Registry.js.map +0 -1
  51. package/src/Impl.ts +0 -59
  52. package/src/Registry.ts +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"GroupImpl.js","names":[],"sources":["../src/GroupImpl.ts"],"sourcesContent":["import type * as GroupPath from \"@confect/core/GroupPath\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport { Context, Layer } from \"effect\";\nimport type * as Api from \"./Api\";\nimport type * as FunctionImpl from \"./FunctionImpl\";\n\nexport interface GroupImpl<GroupPath_ extends string> {\n readonly groupPath: GroupPath_;\n}\n\nexport const GroupImpl = <GroupPath_ extends string>({\n groupPath,\n}: {\n groupPath: GroupPath_;\n}) =>\n Context.GenericTag<GroupImpl<GroupPath_>>(\n `@confect/server/GroupImpl/${groupPath}`,\n );\n\nexport const make = <\n Api_ extends Api.AnyWithProps,\n const GroupPath_ extends GroupPath.All<Api.Groups<Api_>>,\n>(\n _api: Api_,\n groupPath: GroupPath_,\n): Layer.Layer<\n GroupImpl<GroupPath_>,\n never,\n | FromGroupWithPath<GroupPath_, Api.Groups<Api_>>\n | FunctionImpl.FromGroupAtPath<GroupPath_, Api.Groups<Api_>>\n> =>\n Layer.succeed(\n GroupImpl<GroupPath_>({\n groupPath,\n }),\n {\n groupPath,\n },\n ) as Layer.Layer<\n GroupImpl<GroupPath_>,\n never,\n | FromGroupWithPath<GroupPath_, Api.Groups<Api_>>\n | FunctionImpl.FromGroupAtPath<GroupPath_, Api.Groups<Api_>>\n >;\n\nexport type FromGroups<Groups extends GroupSpec.Any> = Groups extends never\n ? never\n : Groups extends GroupSpec.AnyWithProps\n ? GroupImpl<GroupSpec.Name<Groups>>\n : never;\n\nexport type FromGroupWithPath<\n GroupPath_ extends string,\n Group extends GroupSpec.AnyWithProps,\n> =\n GroupPath.SubGroupsAt<Group, GroupPath_> extends infer SubGroupPaths\n ? SubGroupPaths extends string\n ? GroupImpl<SubGroupPaths>\n : never\n : never;\n"],"mappings":";;;;;;;;AAUA,MAAa,aAAwC,EACnD,gBAIA,QAAQ,WACN,6BAA6B,YAC9B;AAEH,MAAa,QAIX,MACA,cAOA,MAAM,QACJ,UAAsB,EACpB,WACD,CAAC,EACF,EACE,WACD,CACF"}
1
+ {"version":3,"file":"GroupImpl.js","names":[],"sources":["../src/GroupImpl.ts"],"sourcesContent":["import type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as Registry from \"@confect/core/Registry\";\nimport {\n Array,\n Context,\n Effect,\n Layer,\n Option,\n pipe,\n Predicate,\n Record,\n Ref,\n String,\n} from \"effect\";\nimport type * as Api from \"./Api\";\nimport type * as FunctionImpl from \"./FunctionImpl\";\nimport { resolveGroupPathUnsafe } from \"./GroupPath\";\n\nexport const TypeId = \"@confect/server/GroupImpl\";\nexport type TypeId = typeof TypeId;\n\nexport type FinalizationStatus = \"Unfinalized\" | \"Finalized\";\n\nexport interface GroupImpl<\n GroupPath_ extends string,\n FinalizationStatus_ extends FinalizationStatus = \"Unfinalized\",\n> {\n readonly [TypeId]: TypeId;\n readonly groupPath: GroupPath_;\n readonly finalizationStatus: FinalizationStatus_;\n /**\n * Names of every function registered into this group's layer scope by\n * `FunctionImpl.make`. Authoritative only when `finalizationStatus` is\n * `\"Finalized\"`; the `\"Unfinalized\"` value is set to `[]` at `make`-time\n * since the list is only known once `finalize` snapshots the registry.\n */\n readonly registeredFunctionNames: ReadonlyArray<string>;\n}\n\nexport interface Any extends GroupImpl<string, FinalizationStatus> {}\n\nexport const isGroupImpl = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface AnyFinalized extends GroupImpl<string, \"Finalized\"> {}\nexport interface AnyUnfinalized extends GroupImpl<string, \"Unfinalized\"> {}\n\nexport const isFinalizedGroupImpl = (u: unknown): u is AnyFinalized =>\n isGroupImpl(u) && u.finalizationStatus === \"Finalized\";\n\nexport const isUnfinalizedGroupImpl = (u: unknown): u is AnyUnfinalized =>\n isGroupImpl(u) && u.finalizationStatus === \"Unfinalized\";\n\n/**\n * Build the runtime tag for a `GroupImpl` service. The finalization status is\n * embedded in the tag string so that `Unfinalized` and `Finalized` are distinct\n * services at runtime; consumers of a finalized layer (the server's\n * `RegisteredFunctions.buildForGroup` and the CLI's `implValidation`) retrieve\n * the typed `Finalized` service directly rather than scanning the context.\n */\nexport const GroupImpl = <\n GroupPath_ extends string,\n FinalizationStatus_ extends FinalizationStatus,\n>({\n groupPath,\n finalizationStatus,\n}: {\n groupPath: GroupPath_;\n finalizationStatus: FinalizationStatus_;\n}) =>\n Context.GenericTag<GroupImpl<GroupPath_, FinalizationStatus_>>(\n `@confect/server/GroupImpl/${finalizationStatus}/${groupPath}`,\n );\n\nexport const make = <\n Api_ extends Api.AnyWithProps,\n Group extends GroupSpec.AnyWithProps,\n>(\n api: Api_,\n group: Group,\n): Layer.Layer<\n GroupImpl<string, \"Unfinalized\">,\n never,\n FunctionImpl.FromGroupSpec<Group>\n> => {\n const groupPath = resolveGroupPathUnsafe(api.spec, group);\n\n return Layer.succeed(\n GroupImpl<string, \"Unfinalized\">({\n groupPath,\n finalizationStatus: \"Unfinalized\",\n }),\n {\n [TypeId]: TypeId,\n groupPath,\n finalizationStatus: \"Unfinalized\" as const,\n registeredFunctionNames: [],\n },\n ) as Layer.Layer<\n GroupImpl<string, \"Unfinalized\">,\n never,\n FunctionImpl.FromGroupSpec<Group>\n >;\n};\n\nconst isFunctionShaped = (value: unknown): boolean =>\n Predicate.isRecord(value) && \"functionSpec\" in value;\n\n/**\n * Walk a `RegistryItems` tree to the entries at `groupPath` and return the\n * names of the function-shaped leaves directly underneath.\n */\nconst collectFunctionNamesAtPath = (\n items: Registry.RegistryItems,\n groupPath: string,\n): ReadonlyArray<string> =>\n pipe(\n String.split(groupPath, \".\"),\n Array.reduce(Option.some<unknown>(items), (acc, segment) =>\n acc.pipe(\n Option.filter(Predicate.isRecord),\n Option.flatMap((node) =>\n segment in node ? Option.some(node[segment]) : Option.none(),\n ),\n ),\n ),\n Option.filter(Predicate.isRecord),\n Option.map(Record.toEntries),\n Option.map(\n Array.filterMap(([name, value]) =>\n isFunctionShaped(value) ? Option.some(name) : Option.none(),\n ),\n ),\n Option.getOrElse((): ReadonlyArray<string> => []),\n );\n\nconst findUnfinalizedGroupImpl = <S>(\n context: Context.Context<S>,\n): Option.Option<AnyUnfinalized> =>\n Array.findFirst(context.unsafeMap.values(), isUnfinalizedGroupImpl);\n\n/**\n * Mark a `GroupImpl` layer as fully implemented. The parameter type defaults\n * `RIn = never`, so passing a layer that still requires any `FunctionImpl`\n * service produces a type error at the impl author's site. The codegen\n * boundary requires the resulting `\"Finalized\"` brand, so omitting this call\n * is also rejected downstream.\n *\n * As a side effect of finalization, the names of every `FunctionImpl` that\n * registered into this group's scope are snapshotted onto the produced\n * service value's `registeredFunctionNames` field, so consumers can verify\n * impl completeness against a `GroupSpec`'s expected functions without\n * having to inspect the `Registry` themselves.\n */\nexport const finalize = <GroupPath_ extends string>(\n group: Layer.Layer<GroupImpl<GroupPath_, \"Unfinalized\">>,\n): Layer.Layer<GroupImpl<GroupPath_, \"Finalized\">> =>\n Layer.flatMap(\n group,\n (context): Layer.Layer<GroupImpl<GroupPath_, \"Finalized\">> =>\n findUnfinalizedGroupImpl(context).pipe(\n Option.match({\n onNone: () =>\n Layer.die(\n new Error(\n \"GroupImpl.finalize: no Unfinalized GroupImpl service was found in the layer's context.\",\n ),\n ),\n onSome: (unfinalized) => {\n const groupPath = unfinalized.groupPath as GroupPath_;\n return Layer.effect(\n GroupImpl<GroupPath_, \"Finalized\">({\n groupPath,\n finalizationStatus: \"Finalized\",\n }),\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n const items = yield* Ref.get(registry);\n return {\n [TypeId]: TypeId,\n groupPath,\n finalizationStatus: \"Finalized\" as const,\n registeredFunctionNames: collectFunctionNamesAtPath(\n items,\n groupPath,\n ),\n };\n }),\n );\n },\n }),\n ),\n );\n\nexport type FromGroupSpec<Group extends GroupSpec.AnyWithProps> =\n FunctionImpl.FromGroupSpec<Group>;\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAa,SAAS;AAuBtB,MAAa,eAAe,MAC1B,UAAU,YAAY,GAAG,OAAO;AAKlC,MAAa,wBAAwB,MACnC,YAAY,EAAE,IAAI,EAAE,uBAAuB;AAE7C,MAAa,0BAA0B,MACrC,YAAY,EAAE,IAAI,EAAE,uBAAuB;;;;;;;;AAS7C,MAAa,aAGX,EACA,WACA,yBAKA,QAAQ,WACN,6BAA6B,mBAAmB,GAAG,YACpD;AAEH,MAAa,QAIX,KACA,UAKG;CACH,MAAM,YAAY,uBAAuB,IAAI,MAAM,MAAM;AAEzD,QAAO,MAAM,QACX,UAAiC;EAC/B;EACA,oBAAoB;EACrB,CAAC,EACF;GACG,SAAS;EACV;EACA,oBAAoB;EACpB,yBAAyB,EAAE;EAC5B,CACF;;AAOH,MAAM,oBAAoB,UACxB,UAAU,SAAS,MAAM,IAAI,kBAAkB;;;;;AAMjD,MAAM,8BACJ,OACA,cAEA,KACE,OAAO,MAAM,WAAW,IAAI,EAC5B,MAAM,OAAO,OAAO,KAAc,MAAM,GAAG,KAAK,YAC9C,IAAI,KACF,OAAO,OAAO,UAAU,SAAS,EACjC,OAAO,SAAS,SACd,WAAW,OAAO,OAAO,KAAK,KAAK,SAAS,GAAG,OAAO,MAAM,CAC7D,CACF,CACF,EACD,OAAO,OAAO,UAAU,SAAS,EACjC,OAAO,IAAI,OAAO,UAAU,EAC5B,OAAO,IACL,MAAM,WAAW,CAAC,MAAM,WACtB,iBAAiB,MAAM,GAAG,OAAO,KAAK,KAAK,GAAG,OAAO,MAAM,CAC5D,CACF,EACD,OAAO,gBAAuC,EAAE,CAAC,CAClD;AAEH,MAAM,4BACJ,YAEA,MAAM,UAAU,QAAQ,UAAU,QAAQ,EAAE,uBAAuB;;;;;;;;;;;;;;AAerE,MAAa,YACX,UAEA,MAAM,QACJ,QACC,YACC,yBAAyB,QAAQ,CAAC,KAChC,OAAO,MAAM;CACX,cACE,MAAM,oBACJ,IAAI,MACF,yFACD,CACF;CACH,SAAS,gBAAgB;EACvB,MAAM,YAAY,YAAY;AAC9B,SAAO,MAAM,OACX,UAAmC;GACjC;GACA,oBAAoB;GACrB,CAAC,EACF,OAAO,IAAI,aAAa;GACtB,MAAM,WAAW,OAAO,SAAS;GACjC,MAAM,QAAQ,OAAO,IAAI,IAAI,SAAS;AACtC,UAAO;KACJ,SAAS;IACV;IACA,oBAAoB;IACpB,yBAAyB,2BACvB,OACA,UACD;IACF;IACD,CACH;;CAEJ,CAAC,CACH,CACJ"}
@@ -0,0 +1,8 @@
1
+ import * as Spec from "@confect/core/Spec";
2
+ import * as GroupSpec from "@confect/core/GroupSpec";
3
+
4
+ //#region src/GroupPath.d.ts
5
+ declare const resolveGroupPathUnsafe: (spec: Spec.AnyWithProps, target: GroupSpec.AnyWithProps) => string;
6
+ //#endregion
7
+ export { resolveGroupPathUnsafe };
8
+ //# sourceMappingURL=GroupPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupPath.d.ts","names":[],"sources":["../src/GroupPath.ts"],"mappings":";;;;cA+Ba,sBAAA,GACX,IAAA,EAAM,IAAA,CAAK,YAAA,EACX,MAAA,EAAQ,SAAA,CAAU,YAAA"}
@@ -0,0 +1,10 @@
1
+ import { Array, Option, Record, pipe } from "effect";
2
+
3
+ //#region src/GroupPath.ts
4
+ const resolveGroupPathInGroup = (group, target, pathSegments) => pipe(Record.toEntries(group.groups), Array.findFirst(([name, child]) => child === target ? Option.some(Array.join([...pathSegments, name], ".")) : resolveGroupPathInGroup(child, target, [...pathSegments, name])));
5
+ const resolveGroupPath = (spec, target) => pipe(Record.toEntries(spec.groups), Array.findFirst(([name, group]) => group === target ? Option.some(name) : resolveGroupPathInGroup(group, target, [name])));
6
+ const resolveGroupPathUnsafe = (spec, target) => resolveGroupPath(spec, target).pipe(Option.getOrThrowWith(() => /* @__PURE__ */ new Error("Could not resolve group path for the provided GroupSpec. Ensure the spec is part of the assembled API spec tree.")));
7
+
8
+ //#endregion
9
+ export { resolveGroupPathUnsafe };
10
+ //# sourceMappingURL=GroupPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupPath.js","names":[],"sources":["../src/GroupPath.ts"],"sourcesContent":["import type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport { Array, Option, pipe, Record } from \"effect\";\n\nconst resolveGroupPathInGroup = (\n group: GroupSpec.AnyWithProps,\n target: GroupSpec.AnyWithProps,\n pathSegments: ReadonlyArray<string>,\n): Option.Option<string> =>\n pipe(\n Record.toEntries(group.groups),\n Array.findFirst(([name, child]) =>\n child === target\n ? Option.some(Array.join([...pathSegments, name], \".\"))\n : resolveGroupPathInGroup(child, target, [...pathSegments, name]),\n ),\n );\n\nconst resolveGroupPath = (\n spec: Spec.AnyWithProps,\n target: GroupSpec.AnyWithProps,\n): Option.Option<string> =>\n pipe(\n Record.toEntries(spec.groups),\n Array.findFirst(([name, group]) =>\n group === target\n ? Option.some(name)\n : resolveGroupPathInGroup(group, target, [name]),\n ),\n );\n\nexport const resolveGroupPathUnsafe = (\n spec: Spec.AnyWithProps,\n target: GroupSpec.AnyWithProps,\n): string =>\n resolveGroupPath(spec, target).pipe(\n Option.getOrThrowWith(\n () =>\n new Error(\n \"Could not resolve group path for the provided GroupSpec. Ensure the spec is part of the assembled API spec tree.\",\n ),\n ),\n );\n"],"mappings":";;;AAIA,MAAM,2BACJ,OACA,QACA,iBAEA,KACE,OAAO,UAAU,MAAM,OAAO,EAC9B,MAAM,WAAW,CAAC,MAAM,WACtB,UAAU,SACN,OAAO,KAAK,MAAM,KAAK,CAAC,GAAG,cAAc,KAAK,EAAE,IAAI,CAAC,GACrD,wBAAwB,OAAO,QAAQ,CAAC,GAAG,cAAc,KAAK,CAAC,CACpE,CACF;AAEH,MAAM,oBACJ,MACA,WAEA,KACE,OAAO,UAAU,KAAK,OAAO,EAC7B,MAAM,WAAW,CAAC,MAAM,WACtB,UAAU,SACN,OAAO,KAAK,KAAK,GACjB,wBAAwB,OAAO,QAAQ,CAAC,KAAK,CAAC,CACnD,CACF;AAEH,MAAa,0BACX,MACA,WAEA,iBAAiB,MAAM,OAAO,CAAC,KAC7B,OAAO,qCAEH,IAAI,MACF,mHACD,CACJ,CACF"}
@@ -23,9 +23,9 @@ import * as convex_server0 from "convex/server";
23
23
  import { GenericMutationCtx } from "convex/server";
24
24
  import * as convex_values0 from "convex/values";
25
25
  import * as _confect_core_Types0 from "@confect/core/Types";
26
- import * as effect_ParseResult0 from "effect/ParseResult";
27
26
  import * as effect_Duration0 from "effect/Duration";
28
27
  import * as effect_DateTime0 from "effect/DateTime";
28
+ import * as effect_ParseResult0 from "effect/ParseResult";
29
29
 
30
30
  //#region src/RegisteredConvexFunction.d.ts
31
31
  declare namespace RegisteredConvexFunction_d_exports {
@@ -35,7 +35,10 @@ declare const make: <Api_ extends AnyWithPropsWithRuntime<"Convex">>(api: Api_,
35
35
  functionSpec,
36
36
  handler
37
37
  }: AnyWithProps$1) => Any;
38
- declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx: GenericMutationCtx<ToConvex<FromSchema<Schema>>>) => Layer.Layer<Auth$1 | StorageReader$1 | StorageWriter$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>) | GenericMutationCtx<ToConvex<FromSchema<Schema>>> | {
38
+ declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx: GenericMutationCtx<ToConvex<FromSchema<Schema>>>) => Layer.Layer<Auth$1 | {
39
+ 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>;
40
+ 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>;
41
+ } | StorageReader$1 | StorageWriter$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>) | GenericMutationCtx<ToConvex<FromSchema<Schema>>> | {
39
42
  table: <const TableName extends Name<IncludeSystemTables<Tables<Schema>>>>(tableName: TableName) => {
40
43
  readonly get: {
41
44
  (id: convex_values0.GenericId<TableName>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["document"], DocumentDecodeError | GetByIdFailure, never>;
@@ -54,10 +57,7 @@ declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx:
54
57
  replace: (id: convex_values0.GenericId<TableName>, value: convex_server0.Expand<convex_server0.BetterOmit<DocumentByName<FromSchema<Schema>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
55
58
  delete: (id: convex_values0.GenericId<TableName>) => Effect.Effect<void, never, never>;
56
59
  };
57
- } | {
58
- 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>;
59
- 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>;
60
- } | (<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>), never, never>;
60
+ }, never, never>;
61
61
  type MutationServices<Schema extends AnyWithProps> = DatabaseReader<Schema> | DatabaseWriter<Schema> | Auth$1 | Scheduler$1 | StorageReader$1 | StorageWriter$1 | QueryRunner | MutationRunner | MutationCtx<ToConvex<FromSchema<Schema>>>;
62
62
  //#endregion
63
63
  export { MutationServices, RegisteredConvexFunction_d_exports, make, mutationLayer };
@@ -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,cAiLU,aAAA,kBAAgC,YAAA,EAC3C,MAAA,EAAQ,MAAA,EACR,GAAA,EAAK,kBAAA,CAAmB,QAAA,CAAmB,UAAA,CAAqB,MAAA,QAAS,KAAA,CAAA,KAAA,CAAA,MAAA,GAAA,eAAA,GAAA,eAAA,mBAAA,kBAAA,CAAA,QAAA,EAAA,KAAA,EAAA,KAAA,KAAA,IAAA,EAAA,kBAAA,CAAA,YAAA,CAAA,KAAA,MAAA,MAAA,CAAA,MAAA,CAAA,kBAAA,CAAA,OAAA,CAAA,KAAA,GAAA,kBAAA,CAAA,KAAA,CAAA,KAAA,IAAA,mBAAA,CAAA,UAAA,KAAA,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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAA8B,MAAA,IAC9B,MAAA,GACA,WAAA,GACA,eAAA,GACA,eAAA,GACA,WAAA,GACA,cAAA,GACA,WAAA,CAAwB,QAAA,CAAmB,UAAA,CAAqB,MAAA"}
@@ -47,16 +47,27 @@ const make = (api, { functionSpec, handler }) => Match.value(functionSpec.functi
47
47
  }));
48
48
  }), Match.exhaustive);
49
49
  }), Match.exhaustive);
50
+ /**
51
+ * Convex's query cache is invalidated by any Date.now() call during handler
52
+ * execution. Effect's unsafeFork calls Date.now() when constructing a
53
+ * FiberId.Runtime, which trips the cache for every confect-wrapped query. We
54
+ * stub Date.now to 0 for the span of the handler; queries are forbidden from
55
+ * relying on real time for correctness anyway.
56
+ *
57
+ * Users who explicitly want the real timestamp can still reach it via Effect's
58
+ * Clock service (Clock.currentTimeMillis/Clock.currentTimeNanos). We provide a
59
+ * Clock whose user-facing Effects call realDateNow (Convex's tracker) directly,
60
+ * making Clock an explicit opt-in to cache invalidation. The unsafe methods
61
+ * used internally by Effect (logging, span events, scheduler) return constants
62
+ * so they never touch the tracker—caching is not broken by default.
63
+ */
50
64
  const unpatchedClock = (realDateNow) => {
51
- const bigint1e6 = BigInt(1e6);
52
- const unsafeCurrentTimeMillis = () => realDateNow();
53
- const unsafeCurrentTimeNanos = () => BigInt(realDateNow()) * bigint1e6;
54
65
  return {
55
66
  ...Clock.make(),
56
- unsafeCurrentTimeMillis,
57
- unsafeCurrentTimeNanos,
58
- currentTimeMillis: Effect.sync(unsafeCurrentTimeMillis),
59
- currentTimeNanos: Effect.sync(unsafeCurrentTimeNanos)
67
+ unsafeCurrentTimeMillis: () => 0,
68
+ unsafeCurrentTimeNanos: () => 0n,
69
+ currentTimeMillis: Effect.sync(() => realDateNow()),
70
+ currentTimeNanos: Effect.sync(() => BigInt(realDateNow()) * 1000000n)
60
71
  };
61
72
  };
62
73
  const withStubbedDateNow = async (queryHandler) => {
@@ -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// 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\n// a Clock layer whose methods close over the *original* Date.now, so opting in\n// to Clock is an opt-in to worse caching—but caching is not broken by default.\nconst unpatchedClock = (realDateNow: () => number): Clock.Clock => {\n const bigint1e6 = BigInt(1_000_000);\n const unsafeCurrentTimeMillis = () => realDateNow();\n const unsafeCurrentTimeNanos = () => BigInt(realDateNow()) * bigint1e6;\n const defaultClock = Clock.make();\n return {\n ...defaultClock,\n unsafeCurrentTimeMillis,\n unsafeCurrentTimeNanos,\n currentTimeMillis: Effect.sync(unsafeCurrentTimeMillis),\n currentTimeNanos: Effect.sync(unsafeCurrentTimeNanos),\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,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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AAM,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","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, ct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MAAM,kBAAkBN,QAA2B,CAAC,CACrD;AAaH,MAAM,oBAOJ,EACA,gBACA,MACA,SACA,OACA,eASK;CACL,MAAMP,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,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"}
@@ -18,9 +18,9 @@ import { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
18
18
  import * as convex_values0 from "convex/values";
19
19
  import { Value } from "convex/values";
20
20
  import * as FunctionProvenance from "@confect/core/FunctionProvenance";
21
- import * as effect_ParseResult0 from "effect/ParseResult";
22
21
  import * as effect_Duration0 from "effect/Duration";
23
22
  import * as effect_DateTime0 from "effect/DateTime";
23
+ import * as effect_ParseResult0 from "effect/ParseResult";
24
24
 
25
25
  //#region src/RegisteredFunction.d.ts
26
26
  declare namespace RegisteredFunction_d_exports {
@@ -70,10 +70,10 @@ declare const actionFunctionBase: <Schema extends AnyWithProps, Args, ConvexArgs
70
70
  handler: (ctx: GenericActionCtx<ToConvex<FromSchema<Schema>>>, actualArgs: ConvexArgs) => Promise<ConvexReturns>;
71
71
  };
72
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<(<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>) | Auth$1 | StorageReader$1 | StorageWriter$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>) | {
73
+ declare const actionLayer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, ctx: GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<Auth$1 | GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>> | {
74
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
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
- } | (<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>) | GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>> | StorageActionWriter$1 | (<TableName extends TableNames<FromSchema<DatabaseSchema_>>, IndexName extends keyof convex_server0.VectorIndexes<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>>>(tableName: TableName, indexName: IndexName, query: {
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
77
  vector: number[];
78
78
  limit?: number;
79
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>;
@@ -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,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,KAAA,EAAO,MAAA,CAAO,MAAA,CAAO,KAAA,EAAO,KAAA;EAC5B,OAAA,GAAU,CAAA,EAAG,IAAA,KAAS,MAAA,CAAO,MAAA,CAAO,OAAA,EAAS,CAAA,EAAG,CAAA;EAChD,WAAA,GACE,GAAA,EAAK,gBAAA,CAAiB,QAAA,CAAmB,UAAA,CAAqB,MAAA,QAC3D,KAAA,CAAM,KAAA,CAAM,CAAA;AAAA;QAAD,cAAA,CAAA,kBAAA;;iBAKT,gBAAA,CAAiB,QAAA,CAAmB,UAAA,CAAqB,MAAA,KAAS,UAAA,EAC3D,UAAA,KACX,OAAA,CAAQ,aAAA;AAAA;AAAA,KAcD,cAAA,yBACc,YAAA,IAEtB,WAAA,GACA,MAAA,GACA,eAAA,GACA,eAAA,GACA,qBAAA,GACA,WAAA,GACA,cAAA,GACA,YAAA,GACA,YAAA,CAA0B,UAAA,CAAqB,eAAA,KAC/C,SAAA,CACE,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,cAGjC,WAAA,2BACa,YAAA,EAExB,cAAA,EAAgB,eAAA,EAChB,GAAA,EAAK,gBAAA,CACH,QAAA,CAAmB,UAAA,CAAqB,eAAA,QACzC,KAAA,CAAA,KAAA,CAAA,MAAA,GAAA,gBAAA,CAAA,QAAA,CAAA,UAAA,CAAA,eAAA;0BAAA,kBAAA,CAAA,WAAA"}
@@ -1,6 +1,6 @@
1
1
  import { AnyWithProps as AnyWithProps$1 } from "./Api.js";
2
2
  import { Any, RegisteredFunction } from "./RegisteredFunction.js";
3
- import { Impl } from "./Impl.js";
3
+ import { GroupImpl } from "./GroupImpl.js";
4
4
  import { AnyWithProps as AnyWithProps$2 } from "./RegistryItem.js";
5
5
  import { Layer, Types } from "effect";
6
6
  import * as Spec from "@confect/core/Spec";
@@ -9,14 +9,25 @@ import * as GroupSpec from "@confect/core/GroupSpec";
9
9
 
10
10
  //#region src/RegisteredFunctions.d.ts
11
11
  declare namespace RegisteredFunctions_d_exports {
12
- export { AnyWithProps, RegisteredFunctions, make };
12
+ export { AnyWithProps, ForGroupPath, RegisteredFunctions, buildForGroup };
13
13
  }
14
14
  type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> = Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;
15
15
  type RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = { [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<Groups, GroupName> extends infer Group extends GroupSpec.AnyWithProps ? GroupSpec.Groups<Group> extends infer SubGroups extends GroupSpec.AnyWithProps ? Types.Simplify<RegisteredFunctionsHelper<SubGroups> & { [FunctionName in FunctionSpec.Name<GroupSpec.Functions<Group>>]: FunctionSpec.WithName<GroupSpec.Functions<Group>, FunctionName> extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps ? RegisteredFunction<FunctionSpec_> : never }> : { [FunctionName in FunctionSpec.Name<GroupSpec.Functions<Group>>]: FunctionSpec.WithName<GroupSpec.Functions<Group>, FunctionName> extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps ? RegisteredFunction<FunctionSpec_> : never } : never };
16
16
  interface AnyWithProps {
17
17
  readonly [key: string]: Any | AnyWithProps;
18
18
  }
19
- declare const make: <Api_ extends AnyWithProps$1>(impl: Layer.Layer<Impl<Api_, "Finalized">>, makeRegisteredFunction: (api: Api_, registryItem: AnyWithProps$2) => Any) => Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Api_["spec"]>>>;
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
+ /**
22
+ * Build the registered Convex functions for a single group from its finalized
23
+ * `GroupImpl` layer.
24
+ *
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.
29
+ */
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_>;
20
31
  //#endregion
21
- export { AnyWithProps, RegisteredFunctions, RegisteredFunctions_d_exports, make };
32
+ export { AnyWithProps, ForGroupPath, RegisteredFunctions, RegisteredFunctions_d_exports, buildForGroup };
22
33
  //# sourceMappingURL=RegisteredFunctions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RegisteredFunctions.d.ts","names":[],"sources":["../src/RegisteredFunctions.ts"],"mappings":";;;;;;;;;;;;;KAYY,mBAAA,eAAkC,IAAA,CAAK,YAAA,IACjD,KAAA,CAAM,QAAA,CAAS,yBAAA,CAA0B,IAAA,CAAK,MAAA,CAAO,KAAA;AAAA,KAElD,yBAAA,gBAAyC,SAAA,CAAU,YAAA,oBACxC,SAAA,CAAU,IAAA,CAAK,MAAA,IAAU,SAAA,CAAU,QAAA,CAC/C,MAAA,EACA,SAAA,8BAC4B,SAAA,CAAU,YAAA,GACpC,SAAA,CAAU,MAAA,CAAO,KAAA,kCACf,SAAA,CAAU,YAAA,GACV,KAAA,CAAM,QAAA,CACJ,yBAAA,CAA0B,SAAA,uBACP,YAAA,CAAa,IAAA,CAC5B,SAAA,CAAU,SAAA,CAAU,KAAA,KAClB,YAAA,CAAa,QAAA,CACf,SAAA,CAAU,SAAA,CAAU,KAAA,GACpB,YAAA,sCACoC,YAAA,CAAa,YAAA,GAC/C,kBAAA,CAAsC,aAAA,kCAK3B,YAAA,CAAa,IAAA,CAC5B,SAAA,CAAU,SA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,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,IAAA,CAAK,YAAA,yBAEjB,yBAAA,CAA0B,mBAAA,CAAoB,KAAA,GAAQ,IAAA;;;;;;;;;;cAW7C,aAAA,gBACE,cAAA,mCAGb,GAAA,EAAK,IAAA,EACL,SAAA,EAAW,UAAA,EACX,UAAA,EAAY,KAAA,CAAM,KAAA,CAAM,SAAA,wBACxB,sBAAA,GACE,GAAA,EAAK,IAAA,EACL,YAAA,EAAc,cAAA,KACX,GAAA,KACJ,YAAA,CAAa,IAAA,UAAc,UAAA"}
@@ -1,19 +1,28 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  import { mapLeaves } from "./internal/utils.js";
3
- import { Registry } from "./Registry.js";
4
3
  import { isRegistryItem } from "./RegistryItem.js";
5
- import { Impl } from "./Impl.js";
6
- import { Effect, Match, Ref } from "effect";
4
+ import { Array, Effect, Option, Predicate, Ref, String, pipe } from "effect";
5
+ import * as Registry from "@confect/core/Registry";
7
6
 
8
7
  //#region src/RegisteredFunctions.ts
9
- var RegisteredFunctions_exports = /* @__PURE__ */ __exportAll({ make: () => make });
10
- const make = (impl, makeRegisteredFunction) => Effect.gen(function* () {
11
- const registry = yield* Registry;
12
- const functionImplItems = yield* Ref.get(registry);
13
- const { api, finalizationStatus } = yield* Impl();
14
- return yield* Match.value(finalizationStatus).pipe(Match.withReturnType(), Match.when("Unfinalized", () => Effect.dieMessage("Impl is not finalized")), Match.when("Finalized", () => Effect.succeed(mapLeaves(functionImplItems, isRegistryItem, (registryItem) => makeRegisteredFunction(api, registryItem)))), Match.exhaustive);
15
- }).pipe(Effect.provide(impl), Effect.runSync);
8
+ var RegisteredFunctions_exports = /* @__PURE__ */ __exportAll({ buildForGroup: () => buildForGroup });
9
+ /**
10
+ * Build the registered Convex functions for a single group from its finalized
11
+ * `GroupImpl` layer.
12
+ *
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.
17
+ */
18
+ const buildForGroup = (api, groupPath, groupLayer, makeRegisteredFunction) => {
19
+ const registeredFunctions = mapLeaves(Effect.gen(function* () {
20
+ const registry = yield* Registry.Registry;
21
+ 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}"`)));
24
+ };
16
25
 
17
26
  //#endregion
18
- export { RegisteredFunctions_exports, make };
27
+ export { RegisteredFunctions_exports, buildForGroup };
19
28
  //# sourceMappingURL=RegisteredFunctions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RegisteredFunctions.js","names":["Registry.Registry","Impl.Impl","RegistryItem.isRegistryItem"],"sources":["../src/RegisteredFunctions.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport type { Layer } from \"effect\";\nimport { Effect, Match, Ref, type Types } from \"effect\";\nimport type * as Api from \"./Api\";\nimport * as Impl from \"./Impl\";\nimport { mapLeaves } from \"./internal/utils\";\nimport type * as RegisteredFunction from \"./RegisteredFunction\";\nimport * as Registry from \"./Registry\";\nimport * as RegistryItem from \"./RegistryItem\";\n\nexport type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> =\n Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;\n\ntype RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = {\n [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<\n Groups,\n GroupName\n > extends infer Group extends GroupSpec.AnyWithProps\n ? GroupSpec.Groups<Group> extends infer SubGroups extends\n GroupSpec.AnyWithProps\n ? Types.Simplify<\n RegisteredFunctionsHelper<SubGroups> & {\n [FunctionName in FunctionSpec.Name<\n GroupSpec.Functions<Group>\n >]: FunctionSpec.WithName<\n GroupSpec.Functions<Group>,\n FunctionName\n > extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps\n ? RegisteredFunction.RegisteredFunction<FunctionSpec_>\n : never;\n }\n >\n : {\n [FunctionName in FunctionSpec.Name<\n GroupSpec.Functions<Group>\n >]: FunctionSpec.WithName<\n GroupSpec.Functions<Group>,\n FunctionName\n > extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps\n ? RegisteredFunction.RegisteredFunction<FunctionSpec_>\n : never;\n }\n : never;\n};\n\nexport interface AnyWithProps {\n readonly [key: string]: RegisteredFunction.Any | AnyWithProps;\n}\n\nexport const make = <Api_ extends Api.AnyWithProps>(\n impl: Layer.Layer<Impl.Impl<Api_, \"Finalized\">>,\n makeRegisteredFunction: (\n api: Api_,\n registryItem: RegistryItem.AnyWithProps,\n ) => RegisteredFunction.Any,\n) =>\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n const functionImplItems = yield* Ref.get(registry);\n const { api, finalizationStatus } = yield* Impl.Impl<Api_, \"Finalized\">();\n\n return yield* Match.value(\n finalizationStatus as Impl.FinalizationStatus,\n ).pipe(\n Match.withReturnType<Effect.Effect<RegisteredFunctions<Api_[\"spec\"]>>>(),\n Match.when(\"Unfinalized\", () =>\n Effect.dieMessage(\"Impl is not finalized\"),\n ),\n Match.when(\"Finalized\", () =>\n Effect.succeed(\n mapLeaves<RegistryItem.AnyWithProps, RegisteredFunction.Any>(\n functionImplItems,\n RegistryItem.isRegistryItem,\n (registryItem) => makeRegisteredFunction(api, registryItem),\n ) as RegisteredFunctions<Api_[\"spec\"]>,\n ),\n ),\n Match.exhaustive,\n );\n }).pipe(Effect.provide(impl), Effect.runSync);\n"],"mappings":";;;;;;;;;AAmDA,MAAa,QACX,MACA,2BAKA,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,OAAOA;CACxB,MAAM,oBAAoB,OAAO,IAAI,IAAI,SAAS;CAClD,MAAM,EAAE,KAAK,uBAAuB,OAAOC,MAA8B;AAEzE,QAAO,OAAO,MAAM,MAClB,mBACD,CAAC,KACA,MAAM,gBAAkE,EACxE,MAAM,KAAK,qBACT,OAAO,WAAW,wBAAwB,CAC3C,EACD,MAAM,KAAK,mBACT,OAAO,QACL,UACE,mBACAC,iBACC,iBAAiB,uBAAuB,KAAK,aAAa,CAC5D,CACF,CACF,EACD,MAAM,WACP;EACD,CAAC,KAAK,OAAO,QAAQ,KAAK,EAAE,OAAO,QAAQ"}
1
+ {"version":3,"file":"RegisteredFunctions.js","names":["RegistryItem.isRegistryItem"],"sources":["../src/RegisteredFunctions.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as Registry from \"@confect/core/Registry\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport {\n Array,\n Effect,\n type Layer,\n Option,\n pipe,\n Predicate,\n Ref,\n String,\n type Types,\n} from \"effect\";\nimport type * as Api from \"./Api\";\nimport type * as GroupImpl from \"./GroupImpl\";\nimport { mapLeaves } from \"./internal/utils\";\nimport type * as RegisteredFunction from \"./RegisteredFunction\";\nimport * as RegistryItem from \"./RegistryItem\";\n\nexport type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> =\n Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;\n\ntype RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = {\n [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<\n Groups,\n GroupName\n > extends infer Group extends GroupSpec.AnyWithProps\n ? GroupSpec.Groups<Group> extends infer SubGroups extends\n GroupSpec.AnyWithProps\n ? Types.Simplify<\n RegisteredFunctionsHelper<SubGroups> & {\n [FunctionName in FunctionSpec.Name<\n GroupSpec.Functions<Group>\n >]: FunctionSpec.WithName<\n GroupSpec.Functions<Group>,\n FunctionName\n > extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps\n ? RegisteredFunction.RegisteredFunction<FunctionSpec_>\n : never;\n }\n >\n : {\n [FunctionName in FunctionSpec.Name<\n GroupSpec.Functions<Group>\n >]: FunctionSpec.WithName<\n GroupSpec.Functions<Group>,\n FunctionName\n > extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps\n ? RegisteredFunction.RegisteredFunction<FunctionSpec_>\n : never;\n }\n : never;\n};\n\nexport interface AnyWithProps {\n readonly [key: string]: RegisteredFunction.Any | AnyWithProps;\n}\n\ntype RegisteredFunctionsAtPath<\n Tree,\n Path extends string,\n> = Path extends `${infer Head}.${infer Tail}`\n ? Head extends keyof Tree\n ? Tree[Head] extends AnyWithProps\n ? RegisteredFunctionsAtPath<Tree[Head], Tail>\n : never\n : never\n : Path extends keyof Tree\n ? Tree[Path]\n : never;\n\nexport type ForGroupPath<\n Spec_ extends Spec.AnyWithProps,\n Path extends string,\n> = RegisteredFunctionsAtPath<RegisteredFunctions<Spec_>, Path>;\n\n/**\n * Build the registered Convex functions for a single group from its finalized\n * `GroupImpl` layer.\n *\n * The `groupLayer` parameter requires `GroupImpl<string, \"Finalized\">`, so\n * impls that were never piped through `GroupImpl.finalize` (and impls with\n * unmet `FunctionImpl` requirements, which cannot be finalized) are rejected\n * at the codegen boundary, not just deep inside Convex at runtime.\n */\nexport const buildForGroup = <\n Api_ extends Api.AnyWithProps,\n const GroupPath_ extends string,\n>(\n api: Api_,\n groupPath: GroupPath_,\n groupLayer: Layer.Layer<GroupImpl.GroupImpl<string, \"Finalized\">>,\n makeRegisteredFunction: (\n api: Api_,\n registryItem: RegistryItem.AnyWithProps,\n ) => RegisteredFunction.Any,\n): ForGroupPath<Api_[\"spec\"], GroupPath_> => {\n const registryItems = Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n return yield* Ref.get(registry);\n }).pipe(Effect.provide(groupLayer), Effect.runSync);\n\n const registeredFunctions = mapLeaves<\n RegistryItem.AnyWithProps,\n RegisteredFunction.Any\n >(\n registryItems as { [key: string]: RegistryItem.AnyWithProps },\n RegistryItem.isRegistryItem,\n (registryItem) => makeRegisteredFunction(api, registryItem),\n );\n\n return pipe(\n String.split(groupPath, \".\"),\n Array.reduce(\n Option.some<unknown>(registeredFunctions),\n (currentNode, segment) =>\n currentNode.pipe(\n Option.filter(Predicate.isRecord),\n Option.flatMap((nodeRecord) =>\n segment in nodeRecord\n ? Option.some(nodeRecord[segment])\n : Option.none(),\n ),\n ),\n ),\n Option.getOrThrowWith(\n () => new Error(`No functions registered for group path \"${groupPath}\"`),\n ),\n ) as ForGroupPath<Api_[\"spec\"], GroupPath_>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAuFA,MAAa,iBAIX,KACA,WACA,YACA,2BAI2C;CAM3C,MAAM,sBAAsB,UALN,OAAO,IAAI,aAAa;EAC5C,MAAM,WAAW,OAAO,SAAS;AACjC,SAAO,OAAO,IAAI,IAAI,SAAS;GAC/B,CAAC,KAAK,OAAO,QAAQ,WAAW,EAAE,OAAO,QAAQ,EAOjDA,iBACC,iBAAiB,uBAAuB,KAAK,aAAa,CAC5D;AAED,QAAO,KACL,OAAO,MAAM,WAAW,IAAI,EAC5B,MAAM,OACJ,OAAO,KAAc,oBAAoB,GACxC,aAAa,YACZ,YAAY,KACV,OAAO,OAAO,UAAU,SAAS,EACjC,OAAO,SAAS,eACd,WAAW,aACP,OAAO,KAAK,WAAW,SAAS,GAChC,OAAO,MAAM,CAClB,CACF,CACJ,EACD,OAAO,qCACC,IAAI,MAAM,2CAA2C,UAAU,GAAG,CACzE,CACF"}
@@ -32,19 +32,19 @@ type ValueTupleToValidatorTuple<VlTuple extends ReadonlyArray<ReadonlyValue>> =
32
32
  declare const compileSchema: <T, E>(schema: Schema.Schema<T, E>) => ValueToValidator<(typeof schema)["Encoded"]>;
33
33
  declare const isRecursive: (ast: SchemaAST.AST) => boolean;
34
34
  declare const compileAst: (ast: SchemaAST.AST, isOptionalPropertyOfTypeLiteral?: boolean) => Effect.Effect<Validator<any, any, any>, UnsupportedSchemaTypeError | UnsupportedPropertySignatureKeyTypeError | IndexSignaturesAreNotSupportedError | MixedIndexAndPropertySignaturesAreNotSupportedError | OptionalTupleElementsAreNotSupportedError | EmptyTupleIsNotSupportedError>;
35
- declare const TopLevelMustBeObjectError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Cause.YieldableError & {
35
+ declare const TopLevelMustBeObjectError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
36
36
  readonly _tag: "TopLevelMustBeObjectError";
37
37
  } & Readonly<A>;
38
38
  declare class TopLevelMustBeObjectError extends TopLevelMustBeObjectError_base {
39
39
  get message(): string;
40
40
  }
41
- declare const TopLevelMustBeObjectOrUnionError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Cause.YieldableError & {
41
+ declare const TopLevelMustBeObjectOrUnionError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
42
42
  readonly _tag: "TopLevelMustBeObjectOrUnionError";
43
43
  } & Readonly<A>;
44
44
  declare class TopLevelMustBeObjectOrUnionError extends TopLevelMustBeObjectOrUnionError_base {
45
45
  get message(): string;
46
46
  }
47
- declare const UnsupportedPropertySignatureKeyTypeError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Cause.YieldableError & {
47
+ declare const UnsupportedPropertySignatureKeyTypeError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
48
48
  readonly _tag: "UnsupportedPropertySignatureKeyTypeError";
49
49
  } & Readonly<A>;
50
50
  declare class UnsupportedPropertySignatureKeyTypeError extends UnsupportedPropertySignatureKeyTypeError_base<{
@@ -52,13 +52,13 @@ declare class UnsupportedPropertySignatureKeyTypeError extends UnsupportedProper
52
52
  }> {
53
53
  get message(): string;
54
54
  }
55
- declare const EmptyTupleIsNotSupportedError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Cause.YieldableError & {
55
+ declare const EmptyTupleIsNotSupportedError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
56
56
  readonly _tag: "EmptyTupleIsNotSupportedError";
57
57
  } & Readonly<A>;
58
58
  declare class EmptyTupleIsNotSupportedError extends EmptyTupleIsNotSupportedError_base {
59
59
  get message(): string;
60
60
  }
61
- declare const UnsupportedSchemaTypeError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Cause.YieldableError & {
61
+ declare const UnsupportedSchemaTypeError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
62
62
  readonly _tag: "UnsupportedSchemaTypeError";
63
63
  } & Readonly<A>;
64
64
  declare class UnsupportedSchemaTypeError extends UnsupportedSchemaTypeError_base<{
@@ -66,19 +66,19 @@ declare class UnsupportedSchemaTypeError extends UnsupportedSchemaTypeError_base
66
66
  }> {
67
67
  get message(): string;
68
68
  }
69
- declare const IndexSignaturesAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Cause.YieldableError & {
69
+ declare const IndexSignaturesAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
70
70
  readonly _tag: "IndexSignaturesAreNotSupportedError";
71
71
  } & Readonly<A>;
72
72
  declare class IndexSignaturesAreNotSupportedError extends IndexSignaturesAreNotSupportedError_base {
73
73
  get message(): string;
74
74
  }
75
- declare const MixedIndexAndPropertySignaturesAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Cause.YieldableError & {
75
+ declare const MixedIndexAndPropertySignaturesAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
76
76
  readonly _tag: "MixedIndexAndPropertySignaturesAreNotSupportedError";
77
77
  } & Readonly<A>;
78
78
  declare class MixedIndexAndPropertySignaturesAreNotSupportedError extends MixedIndexAndPropertySignaturesAreNotSupportedError_base {
79
79
  get message(): string;
80
80
  }
81
- declare const OptionalTupleElementsAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Cause.YieldableError & {
81
+ declare const OptionalTupleElementsAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
82
82
  readonly _tag: "OptionalTupleElementsAreNotSupportedError";
83
83
  } & Readonly<A>;
84
84
  declare class OptionalTupleElementsAreNotSupportedError extends OptionalTupleElementsAreNotSupportedError_base {
package/dist/index.d.ts CHANGED
@@ -30,9 +30,7 @@ import { Handler_d_exports } from "./Handler.js";
30
30
  import { FunctionImpl_d_exports } from "./FunctionImpl.js";
31
31
  import { GroupImpl_d_exports } from "./GroupImpl.js";
32
32
  import { HttpApi_d_exports } from "./HttpApi.js";
33
- import { Impl_d_exports } from "./Impl.js";
34
33
  import { RegistryItem_d_exports } from "./RegistryItem.js";
35
34
  import { RegisteredConvexFunction_d_exports } from "./RegisteredConvexFunction.js";
36
35
  import { RegisteredFunctions_d_exports } from "./RegisteredFunctions.js";
37
- import { Registry_d_exports } from "./Registry.js";
38
- export { ActionCtx_d_exports as ActionCtx, ActionRunner_d_exports as ActionRunner, Api_d_exports as Api, Auth_d_exports as Auth, BlobNotFoundError_d_exports as BlobNotFoundError, ConvexConfigProvider_d_exports as ConvexConfigProvider, CronJob_d_exports as CronJob, CronJobs_d_exports as CronJobs, DataModel_d_exports as DataModel, DatabaseReader_d_exports as DatabaseReader, DatabaseSchema_d_exports as DatabaseSchema, DatabaseWriter_d_exports as DatabaseWriter, Document_d_exports as Document, FunctionImpl_d_exports as FunctionImpl, GroupImpl_d_exports as GroupImpl, Handler_d_exports as Handler, HttpApi_d_exports as HttpApi, Impl_d_exports as Impl, MutationCtx_d_exports as MutationCtx, MutationRunner_d_exports as MutationRunner, OrderedQuery_d_exports as OrderedQuery, QueryCtx_d_exports as QueryCtx, QueryInitializer_d_exports as QueryInitializer, QueryRunner_d_exports as QueryRunner, RegisteredConvexFunction_d_exports as RegisteredConvexFunction, RegisteredFunction_d_exports as RegisteredFunction, RegisteredFunctions_d_exports as RegisteredFunctions, Registry_d_exports as Registry, RegistryItem_d_exports as RegistryItem, Scheduler_d_exports as Scheduler, SchemaToValidator_d_exports as SchemaToValidator, StorageActionWriter_d_exports as StorageActionWriter, StorageReader_d_exports as StorageReader, StorageWriter_d_exports as StorageWriter, Table_d_exports as Table, TableInfo_d_exports as TableInfo, VectorSearch_d_exports as VectorSearch };
36
+ export { ActionCtx_d_exports as ActionCtx, ActionRunner_d_exports as ActionRunner, Api_d_exports as Api, Auth_d_exports as Auth, BlobNotFoundError_d_exports as BlobNotFoundError, ConvexConfigProvider_d_exports as ConvexConfigProvider, CronJob_d_exports as CronJob, CronJobs_d_exports as CronJobs, DataModel_d_exports as DataModel, DatabaseReader_d_exports as DatabaseReader, DatabaseSchema_d_exports as DatabaseSchema, DatabaseWriter_d_exports as DatabaseWriter, Document_d_exports as Document, FunctionImpl_d_exports as FunctionImpl, GroupImpl_d_exports as GroupImpl, Handler_d_exports as Handler, HttpApi_d_exports as HttpApi, MutationCtx_d_exports as MutationCtx, MutationRunner_d_exports as MutationRunner, OrderedQuery_d_exports as OrderedQuery, QueryCtx_d_exports as QueryCtx, QueryInitializer_d_exports as QueryInitializer, QueryRunner_d_exports as QueryRunner, RegisteredConvexFunction_d_exports as RegisteredConvexFunction, RegisteredFunction_d_exports as RegisteredFunction, RegisteredFunctions_d_exports as RegisteredFunctions, RegistryItem_d_exports as RegistryItem, Scheduler_d_exports as Scheduler, SchemaToValidator_d_exports as SchemaToValidator, StorageActionWriter_d_exports as StorageActionWriter, StorageReader_d_exports as StorageReader, StorageWriter_d_exports as StorageWriter, Table_d_exports as Table, TableInfo_d_exports as TableInfo, VectorSearch_d_exports as VectorSearch };
package/dist/index.js CHANGED
@@ -15,7 +15,6 @@ import { OrderedQuery_exports } from "./OrderedQuery.js";
15
15
  import { QueryInitializer_exports } from "./QueryInitializer.js";
16
16
  import { DatabaseReader_exports } from "./DatabaseReader.js";
17
17
  import { DatabaseWriter_exports } from "./DatabaseWriter.js";
18
- import { Registry_exports } from "./Registry.js";
19
18
  import { RegistryItem_exports } from "./RegistryItem.js";
20
19
  import { FunctionImpl_exports } from "./FunctionImpl.js";
21
20
  import { GroupImpl_exports } from "./GroupImpl.js";
@@ -27,7 +26,6 @@ import { StorageActionWriter_exports } from "./StorageActionWriter.js";
27
26
  import { StorageReader_exports } from "./StorageReader.js";
28
27
  import { StorageWriter_exports } from "./StorageWriter.js";
29
28
  import { HttpApi_exports } from "./HttpApi.js";
30
- import { Impl_exports } from "./Impl.js";
31
29
  import { MutationCtx_exports } from "./MutationCtx.js";
32
30
  import { QueryCtx_exports } from "./QueryCtx.js";
33
31
  import { VectorSearch_exports } from "./VectorSearch.js";
@@ -36,4 +34,4 @@ import { RegisteredConvexFunction_exports } from "./RegisteredConvexFunction.js"
36
34
  import { RegisteredFunctions_exports } from "./RegisteredFunctions.js";
37
35
  import { TableInfo_exports } from "./TableInfo.js";
38
36
 
39
- export { ActionCtx_exports as ActionCtx, ActionRunner_exports as ActionRunner, Api_exports as Api, Auth_exports as Auth, BlobNotFoundError_exports as BlobNotFoundError, ConvexConfigProvider_exports as ConvexConfigProvider, CronJob_exports as CronJob, CronJobs_exports as CronJobs, DataModel_exports as DataModel, DatabaseReader_exports as DatabaseReader, DatabaseSchema_exports as DatabaseSchema, DatabaseWriter_exports as DatabaseWriter, Document_exports as Document, FunctionImpl_exports as FunctionImpl, GroupImpl_exports as GroupImpl, Handler_exports as Handler, HttpApi_exports as HttpApi, Impl_exports as Impl, MutationCtx_exports as MutationCtx, MutationRunner_exports as MutationRunner, OrderedQuery_exports as OrderedQuery, QueryCtx_exports as QueryCtx, QueryInitializer_exports as QueryInitializer, QueryRunner_exports as QueryRunner, RegisteredConvexFunction_exports as RegisteredConvexFunction, RegisteredFunction_exports as RegisteredFunction, RegisteredFunctions_exports as RegisteredFunctions, Registry_exports as Registry, RegistryItem_exports as RegistryItem, Scheduler_exports as Scheduler, SchemaToValidator_exports as SchemaToValidator, StorageActionWriter_exports as StorageActionWriter, StorageReader_exports as StorageReader, StorageWriter_exports as StorageWriter, Table_exports as Table, TableInfo_exports as TableInfo, VectorSearch_exports as VectorSearch };
37
+ export { ActionCtx_exports as ActionCtx, ActionRunner_exports as ActionRunner, Api_exports as Api, Auth_exports as Auth, BlobNotFoundError_exports as BlobNotFoundError, ConvexConfigProvider_exports as ConvexConfigProvider, CronJob_exports as CronJob, CronJobs_exports as CronJobs, DataModel_exports as DataModel, DatabaseReader_exports as DatabaseReader, DatabaseSchema_exports as DatabaseSchema, DatabaseWriter_exports as DatabaseWriter, Document_exports as Document, FunctionImpl_exports as FunctionImpl, GroupImpl_exports as GroupImpl, Handler_exports as Handler, HttpApi_exports as HttpApi, MutationCtx_exports as MutationCtx, MutationRunner_exports as MutationRunner, OrderedQuery_exports as OrderedQuery, QueryCtx_exports as QueryCtx, QueryInitializer_exports as QueryInitializer, QueryRunner_exports as QueryRunner, RegisteredConvexFunction_exports as RegisteredConvexFunction, RegisteredFunction_exports as RegisteredFunction, RegisteredFunctions_exports as RegisteredFunctions, RegistryItem_exports as RegistryItem, Scheduler_exports as Scheduler, SchemaToValidator_exports as SchemaToValidator, StorageActionWriter_exports as StorageActionWriter, StorageReader_exports as StorageReader, StorageWriter_exports as StorageWriter, Table_exports as Table, TableInfo_exports as TableInfo, VectorSearch_exports as VectorSearch };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@confect/server",
3
- "version": "7.0.0",
3
+ "version": "9.0.0-next.0",
4
4
  "description": "Backend bindings to the Convex platform",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,38 +44,36 @@
44
44
  "license": "ISC",
45
45
  "devDependencies": {
46
46
  "@ark/attest": "0.56.0",
47
- "@effect/cluster": "0.56.4",
48
- "@effect/experimental": "0.58.0",
49
- "@effect/platform": "0.94.5",
50
- "@effect/rpc": "0.73.2",
51
- "@effect/sql": "0.49.0",
52
- "@effect/vitest": "0.27.0",
53
- "@effect/workflow": "0.16.0",
47
+ "@effect/cluster": "0.58.2",
48
+ "@effect/experimental": "0.60.0",
49
+ "@effect/platform": "0.96.1",
50
+ "@effect/rpc": "0.75.1",
51
+ "@effect/sql": "0.51.1",
52
+ "@effect/vitest": "0.29.0",
53
+ "@effect/workflow": "0.18.1",
54
54
  "@eslint/js": "10.0.1",
55
55
  "@swc/jest": "0.2.39",
56
56
  "@types/node": "25.3.3",
57
57
  "@vitest/coverage-v8": "3.2.4",
58
58
  "convex-test": "0.0.50",
59
59
  "dotenv": "17.3.1",
60
- "effect": "3.19.19",
60
+ "effect": "3.21.2",
61
61
  "eslint": "10.0.2",
62
62
  "prettier": "3.8.1",
63
63
  "tsdown": "0.20.3",
64
- "tsx": "^4.21.0",
64
+ "tsx": "4.21.0",
65
65
  "typescript": "5.9.3",
66
66
  "typescript-eslint": "8.56.1",
67
67
  "vite": "7.3.1",
68
68
  "vite-tsconfig-paths": "6.1.1",
69
- "vitest": "3.2.4",
70
- "@confect/cli": "7.0.0",
71
- "@confect/test": "7.0.0"
69
+ "vitest": "3.2.4"
72
70
  },
73
71
  "peerDependencies": {
74
- "@effect/platform": "^0.94.5",
75
- "@effect/platform-node": "^0.104.1",
76
- "convex": "^1.30.0",
77
- "effect": "^3.19.16",
78
- "@confect/core": "7.0.0"
72
+ "@effect/platform": "^0.96.1",
73
+ "@effect/platform-node": "^0.106.0",
74
+ "convex": "1.39.1",
75
+ "effect": "^3.21.2",
76
+ "@confect/core": "^9.0.0-next.0"
79
77
  },
80
78
  "engines": {
81
79
  "node": ">=22",
@@ -88,11 +86,15 @@
88
86
  "build": "tsdown --config-loader unrun",
89
87
  "dev": "tsdown --watch",
90
88
  "test": "vitest run",
89
+ "test:mock-backend": "vitest run --config vitest.mock-backend.config.ts",
90
+ "test:local-backend": "vitest run --config vitest.local-backend.config.ts",
91
+ "codegen:mock-backend": "cd test/mock-backend/fixtures && pnpm confect codegen && CONVEX_AGENT_MODE=anonymous pnpm convex dev --once --typecheck=disable --tail-logs=disable",
92
+ "codegen:local-backend": "cd test/local-backend/fixtures && pnpm confect codegen && CONVEX_AGENT_MODE=anonymous pnpm convex dev --once --typecheck=disable --tail-logs=disable",
91
93
  "typecheck": "tsc --noEmit --project tsconfig.json",
92
94
  "fix": "prettier --write . && eslint --fix . --max-warnings=0",
93
95
  "format": "prettier --check .",
94
96
  "lint": "eslint . --max-warnings=0",
95
- "bench": "tsx test/SchemaToValidator.bench.ts",
97
+ "bench": "tsx test/SchemaToValidator.bench.ts && tsx test/Document.bench.ts",
96
98
  "clean": "rm -rf dist coverage node_modules"
97
99
  }
98
100
  }