@confect/server 8.0.0 → 9.0.0-next.1

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 (50) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/Auth.d.ts +1 -1
  3. package/dist/DatabaseReader.d.ts +4 -4
  4. package/dist/DatabaseSchema.d.ts +9 -4
  5. package/dist/DatabaseSchema.d.ts.map +1 -1
  6. package/dist/DatabaseSchema.js +4 -3
  7. package/dist/DatabaseSchema.js.map +1 -1
  8. package/dist/DatabaseWriter.d.ts +4 -4
  9. package/dist/DatabaseWriter.d.ts.map +1 -1
  10. package/dist/FunctionImpl.d.ts +10 -7
  11. package/dist/FunctionImpl.d.ts.map +1 -1
  12. package/dist/FunctionImpl.js +8 -8
  13. package/dist/FunctionImpl.js.map +1 -1
  14. package/dist/GroupImpl.d.ts +51 -12
  15. package/dist/GroupImpl.d.ts.map +1 -1
  16. package/dist/GroupImpl.js +72 -4
  17. package/dist/GroupImpl.js.map +1 -1
  18. package/dist/GroupPath.d.ts +8 -0
  19. package/dist/GroupPath.d.ts.map +1 -0
  20. package/dist/GroupPath.js +10 -0
  21. package/dist/GroupPath.js.map +1 -0
  22. package/dist/QueryInitializer.d.ts +1 -1
  23. package/dist/QueryInitializer.d.ts.map +1 -1
  24. package/dist/RegisteredConvexFunction.d.ts +8 -8
  25. package/dist/RegisteredConvexFunction.d.ts.map +1 -1
  26. package/dist/RegisteredFunction.d.ts +3 -3
  27. package/dist/RegisteredFunction.d.ts.map +1 -1
  28. package/dist/RegisteredFunctions.d.ts +15 -4
  29. package/dist/RegisteredFunctions.d.ts.map +1 -1
  30. package/dist/RegisteredFunctions.js +20 -11
  31. package/dist/RegisteredFunctions.js.map +1 -1
  32. package/dist/index.d.ts +1 -3
  33. package/dist/index.js +1 -3
  34. package/package.json +4 -6
  35. package/src/DatabaseSchema.ts +10 -7
  36. package/src/FunctionImpl.ts +27 -36
  37. package/src/GroupImpl.ts +168 -32
  38. package/src/GroupPath.ts +43 -0
  39. package/src/RegisteredFunctions.ts +78 -28
  40. package/src/index.ts +0 -2
  41. package/dist/Impl.d.ts +0 -24
  42. package/dist/Impl.d.ts.map +0 -1
  43. package/dist/Impl.js +0 -28
  44. package/dist/Impl.js.map +0 -1
  45. package/dist/Registry.d.ts +0 -15
  46. package/dist/Registry.d.ts.map +0 -1
  47. package/dist/Registry.js +0 -10
  48. package/dist/Registry.js.map +0 -1
  49. package/src/Impl.ts +0 -59
  50. package/src/Registry.ts +0 -13
@@ -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"}
@@ -24,7 +24,7 @@ type QueryInitializer<DataModel_ extends AnyWithProps$2, TableName extends Table
24
24
  readonly search: <IndexName extends keyof SearchIndexes<_ConvexTableInfo>>(indexName: IndexName, searchFilter: (q: SearchFilterBuilder<DocumentByInfo<_ConvexTableInfo>, NamedSearchIndex<_ConvexTableInfo, IndexName>>) => SearchFilter) => OrderedQuery$1<_TableInfo, TableName>;
25
25
  };
26
26
  declare const make: <Tables extends AnyWithProps, TableName extends Name<Tables>>(tableName: TableName, convexDatabaseReader: BaseDatabaseReader<ToConvex<FromTables<Tables>>>, table: WithName<Tables, TableName>) => QueryInitializer<DataModel<Tables>, TableName, TableInfoWithName<DataModel<Tables>, TableName>, TableInfoWithName_<DataModel<Tables>, TableName>>;
27
- declare const getById: <Tables extends AnyWithProps, TableName extends Name<Tables>>(tableName: TableName, convexDatabaseReader: BaseDatabaseReader<ToConvex<FromTables<Tables>>>, table: WithName<Tables, TableName>) => (id: GenericId<TableName>) => Effect.Effect<any, DocumentDecodeError | GetByIdFailure, never>;
27
+ declare const getById: <Tables extends AnyWithProps, TableName extends Name<Tables>>(tableName: TableName, convexDatabaseReader: BaseDatabaseReader<ToConvex<FromTables<Tables>>>, table: WithName<Tables, TableName>) => (id: GenericId<TableName>) => Effect.Effect<any, GetByIdFailure | DocumentDecodeError, never>;
28
28
  declare const GetByIdFailure_base: Schema.TaggedErrorClass<GetByIdFailure, "GetByIdFailure", {
29
29
  readonly _tag: Schema.tag<"GetByIdFailure">;
30
30
  } & {
@@ -1 +1 @@
1
- {"version":3,"file":"QueryInitializer.d.ts","names":[],"sources":["../src/QueryInitializer.ts"],"mappings":";;;;;;;;;;;;;;KA6BK,gBAAA,oBACgB,cAAA,oBACD,UAAA,CAAqB,UAAA,4BACd,gBAAA,qBACN,cAAA;EAAA,SAEV,GAAA;IAAA,CAEL,EAAA,EAAI,SAAA,CAAU,SAAA,IACb,MAAA,CAAO,MAAA,CACR,UAAA,cACA,mBAAA,GAA+B,cAAA;IAAA,yBAER,OAAA,CAAQ,gBAAA,GAC/B,SAAA,EAAW,SAAA,KACR,gBAAA,EAAkB,oBAAA,CACnB,QAAA,CAAmB,UAAA,GACnB,SAAA,EACA,OAAA,CAAQ,gBAAA,EAAkB,SAAA,KAE3B,MAAA,CAAO,MAAA,CACR,UAAA,cACA,mBAAA,GAA+B,iBAAA;EAAA;EAAA,SAG1B,KAAA;IAAA,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A,GAE7B,SAAA,EAAW,SAAA,EACX,oBAAA,EAAsB,kBAAA,CACpB,QAAA,CAAmB,UAAA,CAAqB,MAAA,KAE1C,KAAA,EAAO,QAAA,CAAe,MAAA,EAAQ,SAAA,MAC7B,gBAAA,CACD,SAAA,CAAoB,MAAA,GACpB,SAAA,EACA,iBAAA,CAA4B,SAAA,CAAoB,MAAA,GAAS,SAAA,GACzD,kBAAA,CAA6B,SAAA,CAAoB,MAAA,GAAS,SAAA;AAAA,cA2K/C,OAAA,kBACK,YAAA,oBAAsC,IAAA,CAAW,MAAA,GAC/D,SAAA,EAAW,SAAA,EACX,oBAAA,EAAsB,kBAAA,CACpB,QAAA,CAAmB,UAAA,CAAqB,MAAA,KAE1C,KAAA,EAAO,QAAA,CAAe,MAAA,EAAQ,SAAA,OAE/B,EAAA,EAAI,SAAA,CAAU,SAAA,MAAU,MAAA,CAAA,MAAA,MAAA,cAAA,GAAA,mBAAA;AAAA,cAOrB,mBAAA;;;;;;cAEO,cAAA,SAAuB,mBAAA;EAAA,IAOrB,OAAA,CAAA;AAAA;AAAA,cAOd,sBAAA;;;;;;;cAEY,iBAAA,SAA0B,sBAAA;EAAA,IAQxB,OAAA,CAAA;AAAA"}
@@ -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,10 +35,13 @@ 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<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<StorageWriter$1 | StorageReader$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
+ } | Auth$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
- (id: convex_values0.GenericId<TableName>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["document"], DocumentDecodeError | GetByIdFailure, never>;
44
+ (id: convex_values0.GenericId<TableName>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["document"], GetByIdFailure | DocumentDecodeError, never>;
42
45
  <IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["indexes"]>(indexName: IndexName, ...indexFieldValues: _confect_core_Types0.IndexFieldTypesForEq<ToConvex<DataModel<IncludeSystemTables<Tables<Schema>>>>, TableName, TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["indexes"][IndexName]>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["document"], DocumentDecodeError | GetByIndexFailure, never>;
43
46
  };
44
47
  readonly index: {
@@ -50,14 +53,11 @@ declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx:
50
53
  } | {
51
54
  table: <const TableName extends TableNames<FromSchema<Schema>>>(tableName: TableName) => {
52
55
  insert: (document: WithoutSystemFields$1<DocumentByName<FromSchema<Schema>, TableName>>) => Effect.Effect<convex_values0.GenericId<TableName>, DocumentEncodeError, never>;
53
- patch: (id: convex_values0.GenericId<TableName>, patchedValues: Partial<convex_server0.Expand<convex_server0.BetterOmit<DocumentByName<FromSchema<Schema>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentDecodeError | GetByIdFailure | DocumentEncodeError, never>;
56
+ patch: (id: convex_values0.GenericId<TableName>, patchedValues: Partial<convex_server0.Expand<convex_server0.BetterOmit<DocumentByName<FromSchema<Schema>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, GetByIdFailure | DocumentDecodeError | DocumentEncodeError, never>;
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
- } | Auth$1 | {
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,cAkLU,aAAA,kBAAgC,YAAA,EAC3C,MAAA,EAAQ,MAAA,EACR,GAAA,EAAK,kBAAA,CAAmB,QAAA,CAAmB,UAAA,CAAqB,MAAA,QAAS,KAAA,CAAA,KAAA,CAAA,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,eAAA,GAAA,eAAA;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"}
@@ -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<StorageActionWriter$1 | StorageReader$1 | StorageWriter$1 | (<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>) | (<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>) | Auth$1 | {
73
+ declare const actionLayer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, ctx: GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<StorageActionWriter$1 | StorageWriter$1 | StorageReader$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_>>> | (<TableName extends TableNames<FromSchema<DatabaseSchema_>>, IndexName extends keyof convex_server0.VectorIndexes<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>>>(tableName: TableName, indexName: IndexName, query: {
76
+ } | Auth$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,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,aAAA,GACnC,KAAA,EACA,OAAA,CAAQ,YAAA,CAAa,cAAA,CAAe,aAAA,MAEtC,sBAAA,CAAuB,eAAA,CACnB,aAAA,iDAEF,kBAAA,CACE,YAAA,CAAa,qBAAA,CAAsB,aAAA,GACnC,KAAA,EACA,OAAA,CAAQ,YAAA,CAAa,cAAA,CAAe,aAAA,MAEtC,sBAAA,CAAuB,eAAA,CACnB,aAAA,+CAEF,gBAAA,CACE,YAAA,CAAa,qBAAA,CAAsB,aAAA,GACnC,KAAA,EACA,OAAA,CAAQ,YAAA,CAAa,cAAA,CAAe,aAAA;AAAA,KAKtC,wBAAA,uBACY,YAAA,CAAa,YAAA,IACjC,aAAA;EACF,kBAAA;IACE,IAAA;IACA,KAAA,sBAA2B,mBAAA;IAC3B,QAAA;EAAA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AA,CAAqB,eAAA,QACzC,KAAA,CAAA,KAAA,CAAA,qBAAA,GAAA,eAAA,GAAA,eAAA,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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portAll } 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"}
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": "8.0.0",
3
+ "version": "9.0.0-next.1",
4
4
  "description": "Backend bindings to the Convex platform",
5
5
  "repository": {
6
6
  "type": "git",
@@ -66,16 +66,14 @@
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": "8.0.0",
71
- "@confect/test": "8.0.0"
69
+ "vitest": "3.2.4"
72
70
  },
73
71
  "peerDependencies": {
74
72
  "@effect/platform": "^0.96.1",
75
73
  "@effect/platform-node": "^0.106.0",
76
- "convex": "^1.30.0",
74
+ "convex": "1.39.1",
77
75
  "effect": "^3.21.2",
78
- "@confect/core": "^8.0.0"
76
+ "@confect/core": "^9.0.0-next.1"
79
77
  },
80
78
  "engines": {
81
79
  "node": ">=22",
@@ -3,15 +3,18 @@ import {
3
3
  defineSchema as defineConvexSchema,
4
4
  type SchemaDefinition,
5
5
  } from "convex/server";
6
- import { Array, pipe, Record } from "effect";
6
+ import { Array, pipe, Predicate, Record } from "effect";
7
7
  import * as Table from "./Table";
8
- import { TypeId } from "@confect/core/DatabaseSchema";
9
8
 
10
- export {
11
- type Any,
12
- isDatabaseSchema,
13
- TypeId,
14
- } from "@confect/core/DatabaseSchema";
9
+ export const TypeId = "@confect/server/DatabaseSchema";
10
+ export type TypeId = typeof TypeId;
11
+
12
+ export interface Any {
13
+ readonly [TypeId]: TypeId;
14
+ }
15
+
16
+ export const isDatabaseSchema = (u: unknown): u is Any =>
17
+ Predicate.hasProperty(u, TypeId);
15
18
 
16
19
  /**
17
20
  * A schema definition tracks the schema and its Convex schema definition.
@@ -1,11 +1,11 @@
1
1
  import type * as FunctionSpec from "@confect/core/FunctionSpec";
2
- import type * as GroupPath from "@confect/core/GroupPath";
3
2
  import type * as GroupSpec from "@confect/core/GroupSpec";
4
- import { Array, Context, Effect, Layer, Ref, String } from "effect";
3
+ import * as Registry from "@confect/core/Registry";
4
+ import { Context, Effect, Layer, Ref, String } from "effect";
5
5
  import type * as Api from "./Api";
6
+ import { resolveGroupPathUnsafe } from "./GroupPath";
6
7
  import type * as Handler from "./Handler";
7
8
  import { setNestedProperty } from "./internal/utils";
8
- import * as Registry from "./Registry";
9
9
  import * as RegistryItem from "./RegistryItem";
10
10
 
11
11
  export interface FunctionImpl<
@@ -32,34 +32,23 @@ export const FunctionImpl = <
32
32
 
33
33
  export const make = <
34
34
  Api_ extends Api.AnyWithProps,
35
- const GroupPath_ extends GroupPath.All<Api.Groups<Api_>>,
36
- const FunctionName extends FunctionSpec.Name<
37
- GroupSpec.Functions<GroupPath.GroupAt<Api.Groups<Api_>, GroupPath_>>
38
- >,
35
+ Group extends GroupSpec.AnyWithProps,
36
+ const FunctionName extends FunctionSpec.Name<GroupSpec.Functions<Group>>,
39
37
  >(
40
38
  api: Api_,
41
- groupPath: GroupPath_,
39
+ group: Group,
42
40
  functionName: FunctionName,
43
41
  handler: Handler.WithName<
44
42
  Api.Schema<Api_>,
45
- GroupSpec.Functions<GroupPath.GroupAt<Api.Groups<Api_>, GroupPath_>>,
43
+ GroupSpec.Functions<Group>,
46
44
  FunctionName
47
45
  >,
48
- ): Layer.Layer<FunctionImpl<GroupPath_, FunctionName>> => {
49
- const groupPathParts = String.split(groupPath, ".");
50
- const [firstGroupPathPart, ...restGroupPathParts] = groupPathParts;
51
-
52
- const group_: GroupSpec.AnyWithProps = Array.reduce(
53
- restGroupPathParts,
54
- (api as any).spec.groups[firstGroupPathPart as any]!,
55
- (currentGroup: any, groupPathPart: any) =>
56
- currentGroup.groups[groupPathPart],
57
- );
58
-
59
- const functionSpec = group_.functions[functionName]!;
46
+ ): Layer.Layer<FunctionImpl<string, FunctionName>> => {
47
+ const groupPath = resolveGroupPathUnsafe(api.spec, group);
48
+ const functionSpec = group.functions[functionName]!;
60
49
 
61
50
  return Layer.effect(
62
- FunctionImpl<GroupPath_, FunctionName>({
51
+ FunctionImpl<string, FunctionName>({
63
52
  groupPath,
64
53
  functionName,
65
54
  }),
@@ -69,7 +58,7 @@ export const make = <
69
58
  yield* Ref.update(registry, (registryItems) =>
70
59
  setNestedProperty(
71
60
  registryItems,
72
- [...groupPathParts, functionName],
61
+ [...String.split(groupPath, "."), functionName],
73
62
  RegistryItem.make({
74
63
  functionSpec,
75
64
  handler,
@@ -94,19 +83,21 @@ export type ForGroupPathAndFunction<
94
83
  > = FunctionImpl<GroupPath_, FunctionName>;
95
84
 
96
85
  /**
97
- * Get all function implementation services required for a group at a given path.
86
+ * Get all function implementation services required for a group spec.
98
87
  */
99
- export type FromGroupAtPath<
100
- GroupPath_ extends string,
101
- Group extends GroupSpec.AnyWithProps,
102
- > =
103
- GroupPath.GroupAt<Group, GroupPath_> extends infer GroupAtPath extends
104
- GroupSpec.AnyWithProps
105
- ? FunctionSpec.Name<
106
- GroupSpec.Functions<GroupAtPath>
107
- > extends infer FunctionNames extends string
108
- ? FunctionNames extends string
109
- ? FunctionImpl<GroupPath_, FunctionNames>
110
- : never
88
+ export type FromGroupSpec<Group extends GroupSpec.AnyWithProps> =
89
+ FunctionSpec.Name<
90
+ GroupSpec.Functions<Group>
91
+ > extends infer FunctionNames extends string
92
+ ? FunctionNames extends string
93
+ ? FunctionImpl<string, FunctionNames>
111
94
  : never
112
95
  : never;
96
+
97
+ /**
98
+ * @deprecated Use {@link FromGroupSpec} instead.
99
+ */
100
+ export type FromGroupAtPath<
101
+ _GroupPath extends string,
102
+ Group extends GroupSpec.AnyWithProps,
103
+ > = FromGroupSpec<Group>;