@confect/test 2.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @confect/test
2
2
 
3
+ ## 4.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [60be7e6]
8
+ - Updated dependencies [641fd99]
9
+ - Updated dependencies [8ae4d51]
10
+ - @confect/server@4.0.0
11
+ - @confect/core@4.0.0
12
+
13
+ ## 3.0.0
14
+
15
+ ### Minor Changes
16
+
17
+ - 5fb6a61: Add support for plain Convex functions. Plain Convex queries, mutations, and actions can now be included in your Confect spec and impl tree using new `FunctionSpec.convexPublic*` and `FunctionSpec.convexInternal*` constructors. This enables interop with Convex components and libraries (such as Workpool, Workflow, Migrations, and Better Auth) that require user-defined or -provided Convex functions.
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [5fb6a61]
22
+ - @confect/core@3.0.0
23
+ - @confect/server@3.0.0
24
+
3
25
  ## 2.0.0
4
26
 
5
27
  ### Patch Changes
@@ -9,9 +9,9 @@ declare namespace TestConfect_d_exports {
9
9
  export { TestConfect, TestConfectWithoutIdentity, layer };
10
10
  }
11
11
  type TestConfectWithoutIdentity<ConfectSchema extends DatabaseSchema.AnyWithProps> = {
12
- query: <QueryRef extends Ref.AnyQuery>(queryRef: QueryRef, args: Ref.Args<QueryRef>["Type"]) => Effect.Effect<Ref.Returns<QueryRef>["Type"], ParseResult.ParseError>;
13
- mutation: <MutationRef extends Ref.AnyMutation>(mutationRef: MutationRef, args: Ref.Args<MutationRef>["Type"]) => Effect.Effect<Ref.Returns<MutationRef>["Type"], ParseResult.ParseError>;
14
- action: <ActionRef extends Ref.AnyAction>(actionRef: ActionRef, args: Ref.Args<ActionRef>["Type"]) => Effect.Effect<Ref.Returns<ActionRef>["Type"], ParseResult.ParseError>;
12
+ query: <QueryRef extends Ref.AnyQuery>(queryRef: QueryRef, args: Ref.Args<QueryRef>) => Effect.Effect<Ref.Returns<QueryRef>, ParseResult.ParseError>;
13
+ mutation: <MutationRef extends Ref.AnyMutation>(mutationRef: MutationRef, args: Ref.Args<MutationRef>) => Effect.Effect<Ref.Returns<MutationRef>, ParseResult.ParseError>;
14
+ action: <ActionRef extends Ref.AnyAction>(actionRef: ActionRef, args: Ref.Args<ActionRef>) => Effect.Effect<Ref.Returns<ActionRef>, ParseResult.ParseError>;
15
15
  run: {
16
16
  <E>(handler: Effect.Effect<void, E, RegisteredConvexFunction.MutationServices<ConfectSchema>>): Effect.Effect<void>;
17
17
  <A, B extends Value, E>(handler: Effect.Effect<A, E, RegisteredConvexFunction.MutationServices<ConfectSchema>>, returns: Schema.Schema<A, B>): Effect.Effect<A, ParseResult.ParseError>;
@@ -1 +1 @@
1
- {"version":3,"file":"TestConfect.d.ts","names":[],"sources":["../src/TestConfect.ts"],"mappings":";;;;;;;;;;KAaY,0BAAA,uBACY,cAAA,CAAe,YAAA;EAErC,KAAA,oBAAyB,GAAA,CAAI,QAAA,EAC3B,QAAA,EAAU,QAAA,EACV,IAAA,EAAM,GAAA,CAAI,IAAA,CAAK,QAAA,cACZ,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,OAAA,CAAQ,QAAA,WAAmB,WAAA,CAAY,UAAA;EAC9D,QAAA,uBAA+B,GAAA,CAAI,WAAA,EACjC,WAAA,EAAa,WAAA,EACb,IAAA,EAAM,GAAA,CAAI,IAAA,CAAK,WAAA,cACZ,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,OAAA,CAAQ,WAAA,WAAsB,WAAA,CAAY,UAAA;EACjE,MAAA,qBAA2B,GAAA,CAAI,SAAA,EAC7B,SAAA,EAAW,SAAA,EACX,IAAA,EAAM,GAAA,CAAI,IAAA,CAAK,SAAA,cACZ,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,OAAA,CAAQ,SAAA,WAAoB,WAAA,CAAY,UAAA;EAC/D,GAAA;IAAA,IAEI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aAAA;AAAA,cA0NtC,KAAA,2BACc,cAAA,CAAe,YAAA,EACtC,cAAA,EAAgB,eAAA,EAChB,OAAA,EAAS,MAAA,eAAqB,OAAA,iBAE5B,KAAA,CAAM,KAAA,CAAM,WAAA,CAAY,eAAA"}
@@ -2,7 +2,7 @@ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  import { Ref } from "@confect/core";
3
3
  import { RegisteredConvexFunction } from "@confect/server";
4
4
  import { convexTest } from "convex-test";
5
- import { Context, Effect, Layer, Schema } from "effect";
5
+ import { Context, Effect, Layer, Match, Schema } from "effect";
6
6
 
7
7
  //#region src/TestConfect.ts
8
8
  var TestConfect_exports = /* @__PURE__ */ __exportAll({
@@ -16,25 +16,31 @@ var TestConfectImplWithoutIdentity = class {
16
16
  this.testConvex = testConvex;
17
17
  }
18
18
  query = (queryRef, args) => Effect.gen(this, function* () {
19
- const query = Ref.getFunction(queryRef);
19
+ const querySpec = Ref.getFunctionSpec(queryRef);
20
20
  const queryName = Ref.getConvexFunctionName(queryRef);
21
- const encodedArgs = yield* Schema.encode(query.args)(args);
22
- const encodedReturns = yield* Effect.promise(() => this.testConvex.query(queryName, encodedArgs));
23
- return yield* Schema.decode(query.returns)(encodedReturns);
21
+ return yield* Match.value(querySpec.functionProvenance).pipe(Match.tag("Confect", (confect) => Effect.gen(this, function* () {
22
+ const encodedArgs = yield* Schema.encode(confect.args)(args);
23
+ const encodedReturns = yield* Effect.promise(() => this.testConvex.query(queryName, encodedArgs));
24
+ return yield* Schema.decode(confect.returns)(encodedReturns);
25
+ })), Match.tag("Convex", () => Effect.promise(() => this.testConvex.query(queryName, args))), Match.exhaustive);
24
26
  });
25
27
  mutation = (mutationRef, args) => Effect.gen(this, function* () {
26
- const mutation = Ref.getFunction(mutationRef);
28
+ const mutationSpec = Ref.getFunctionSpec(mutationRef);
27
29
  const mutationName = Ref.getConvexFunctionName(mutationRef);
28
- const encodedArgs = yield* Schema.encode(mutation.args)(args);
29
- const encodedReturns = yield* Effect.promise(() => this.testConvex.mutation(mutationName, encodedArgs));
30
- return yield* Schema.decode(mutation.returns)(encodedReturns);
30
+ return yield* Match.value(mutationSpec.functionProvenance).pipe(Match.tag("Confect", (confect) => Effect.gen(this, function* () {
31
+ const encodedArgs = yield* Schema.encode(confect.args)(args);
32
+ const encodedReturns = yield* Effect.promise(() => this.testConvex.mutation(mutationName, encodedArgs));
33
+ return yield* Schema.decode(confect.returns)(encodedReturns);
34
+ })), Match.tag("Convex", () => Effect.promise(() => this.testConvex.mutation(mutationName, args))), Match.exhaustive);
31
35
  });
32
36
  action = (actionRef, args) => Effect.gen(this, function* () {
33
- const action = Ref.getFunction(actionRef);
37
+ const actionSpec = Ref.getFunctionSpec(actionRef);
34
38
  const actionName = Ref.getConvexFunctionName(actionRef);
35
- const encodedArgs = yield* Schema.encode(action.args)(args);
36
- const encodedReturns = yield* Effect.promise(() => this.testConvex.action(actionName, encodedArgs));
37
- return yield* Schema.decode(action.returns)(encodedReturns);
39
+ return yield* Match.value(actionSpec.functionProvenance).pipe(Match.tag("Confect", (confect) => Effect.gen(this, function* () {
40
+ const encodedArgs = yield* Schema.encode(confect.args)(args);
41
+ const encodedReturns = yield* Effect.promise(() => this.testConvex.action(actionName, encodedArgs));
42
+ return yield* Schema.decode(confect.returns)(encodedReturns);
43
+ })), Match.tag("Convex", () => Effect.promise(() => this.testConvex.action(actionName, args))), Match.exhaustive);
38
44
  });
39
45
  run = ((handler, returns) => {
40
46
  const makeMutationLayer = (mutationCtx) => RegisteredConvexFunction.mutationLayer(this.confectSchema, mutationCtx);
@@ -1 +1 @@
1
- {"version":3,"file":"TestConfect.js","names":[],"sources":["../src/TestConfect.ts"],"sourcesContent":["import { Ref } from \"@confect/core\";\nimport type { DatabaseSchema, DataModel } from \"@confect/server\";\nimport { RegisteredConvexFunction } from \"@confect/server\";\nimport type {\n TestConvexForDataModel,\n TestConvexForDataModelAndIdentity,\n} from \"convex-test\";\nimport { convexTest } from \"convex-test\";\nimport type { GenericMutationCtx, UserIdentity } from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Schema } from \"effect\";\n\nexport type TestConfectWithoutIdentity<\n ConfectSchema extends DatabaseSchema.AnyWithProps,\n> = {\n query: <QueryRef extends Ref.AnyQuery>(\n queryRef: QueryRef,\n args: Ref.Args<QueryRef>[\"Type\"],\n ) => Effect.Effect<Ref.Returns<QueryRef>[\"Type\"], ParseResult.ParseError>;\n mutation: <MutationRef extends Ref.AnyMutation>(\n mutationRef: MutationRef,\n args: Ref.Args<MutationRef>[\"Type\"],\n ) => Effect.Effect<Ref.Returns<MutationRef>[\"Type\"], ParseResult.ParseError>;\n action: <ActionRef extends Ref.AnyAction>(\n actionRef: ActionRef,\n args: Ref.Args<ActionRef>[\"Type\"],\n ) => Effect.Effect<Ref.Returns<ActionRef>[\"Type\"], ParseResult.ParseError>;\n run: {\n <E>(\n handler: Effect.Effect<\n void,\n E,\n RegisteredConvexFunction.MutationServices<ConfectSchema>\n >,\n ): Effect.Effect<void>;\n <A, B extends Value, E>(\n handler: Effect.Effect<\n A,\n E,\n RegisteredConvexFunction.MutationServices<ConfectSchema>\n >,\n returns: Schema.Schema<A, B>,\n ): Effect.Effect<A, ParseResult.ParseError>;\n };\n fetch: (\n pathQueryFragment: string,\n init?: RequestInit,\n ) => Effect.Effect<Response>;\n finishInProgressScheduledFunctions: () => Effect.Effect<void>;\n finishAllScheduledFunctions: (\n advanceTimers: () => void,\n ) => Effect.Effect<void>;\n};\n\nexport type TestConfect<ConfectSchema extends DatabaseSchema.AnyWithProps> = {\n withIdentity: (\n userIdentity: Partial<UserIdentity>,\n ) => TestConfectWithoutIdentity<ConfectSchema>;\n} & TestConfectWithoutIdentity<ConfectSchema>;\n\nexport const TestConfect = <\n ConfectSchema extends DatabaseSchema.AnyWithProps,\n>() =>\n Context.GenericTag<TestConfect<ConfectSchema>>(\"@confect/test/TestConfect\");\n\nclass TestConfectImplWithoutIdentity<\n ConfectSchema extends DatabaseSchema.AnyWithProps,\n> implements TestConfectWithoutIdentity<ConfectSchema> {\n constructor(\n private confectSchema: ConfectSchema,\n private testConvex: TestConvexForDataModel<\n DataModel.ToConvex<DataModel.FromSchema<ConfectSchema>>\n >,\n ) {}\n\n readonly query = <QueryRef extends Ref.AnyQuery>(\n queryRef: QueryRef,\n args: Ref.Args<QueryRef>[\"Type\"],\n ): Effect.Effect<Ref.Returns<QueryRef>[\"Type\"], ParseResult.ParseError> =>\n Effect.gen(this, function* () {\n const query = Ref.getFunction(queryRef);\n const queryName = Ref.getConvexFunctionName(queryRef);\n\n const encodedArgs = yield* Schema.encode(query.args)(args);\n\n const encodedReturns = yield* Effect.promise(() =>\n this.testConvex.query(queryName as any, encodedArgs),\n );\n\n return yield* Schema.decode(query.returns)(encodedReturns);\n });\n\n readonly mutation = <MutationRef extends Ref.AnyMutation>(\n mutationRef: MutationRef,\n args: Ref.Args<MutationRef>[\"Type\"],\n ): Effect.Effect<Ref.Returns<MutationRef>[\"Type\"], ParseResult.ParseError> =>\n Effect.gen(this, function* () {\n const mutation = Ref.getFunction(mutationRef);\n const mutationName = Ref.getConvexFunctionName(mutationRef);\n\n const encodedArgs = yield* Schema.encode(mutation.args)(args);\n\n const encodedReturns = yield* Effect.promise(() =>\n this.testConvex.mutation(mutationName as any, encodedArgs),\n );\n\n return yield* Schema.decode(mutation.returns)(encodedReturns);\n });\n\n readonly action = <ActionRef extends Ref.AnyAction>(\n actionRef: ActionRef,\n args: Ref.Args<ActionRef>[\"Type\"],\n ): Effect.Effect<Ref.Returns<ActionRef>[\"Type\"], ParseResult.ParseError> =>\n Effect.gen(this, function* () {\n const action = Ref.getFunction(actionRef);\n const actionName = Ref.getConvexFunctionName(actionRef);\n\n const encodedArgs = yield* Schema.encode(action.args)(args);\n\n const encodedReturns = yield* Effect.promise(() =>\n this.testConvex.action(actionName as any, encodedArgs),\n );\n\n return yield* Schema.decode(action.returns)(encodedReturns);\n });\n\n readonly run: TestConfectWithoutIdentity<ConfectSchema>[\"run\"] = (<\n A,\n B extends Value,\n E,\n >(\n handler: Effect.Effect<\n A,\n E,\n RegisteredConvexFunction.MutationServices<ConfectSchema>\n >,\n returns?: Schema.Schema<A, B>,\n ): Effect.Effect<void> | Effect.Effect<A, ParseResult.ParseError> => {\n const makeMutationLayer = (\n mutationCtx: GenericMutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<ConfectSchema>>\n >,\n ): Layer.Layer<RegisteredConvexFunction.MutationServices<ConfectSchema>> =>\n RegisteredConvexFunction.mutationLayer(\n this.confectSchema,\n mutationCtx,\n ) as Layer.Layer<\n RegisteredConvexFunction.MutationServices<ConfectSchema>\n >;\n\n return returns === undefined\n ? Effect.promise(() =>\n this.testConvex.run((mutationCtx) =>\n Effect.runPromise(\n handler.pipe(\n Effect.asVoid,\n Effect.provide(makeMutationLayer(mutationCtx)),\n ),\n ),\n ),\n )\n : Effect.promise(() =>\n this.testConvex.run((mutationCtx) =>\n Effect.runPromise(\n handler.pipe(\n Effect.andThen(Schema.encode(returns)),\n Effect.provide(makeMutationLayer(mutationCtx)),\n ),\n ),\n ),\n ).pipe(Effect.andThen(Schema.decode(returns)));\n }) as TestConfectWithoutIdentity<ConfectSchema>[\"run\"];\n\n readonly fetch = <PathQueryFragment extends string>(\n pathQueryFragment: PathQueryFragment,\n init?: RequestInit,\n ) => Effect.promise(() => this.testConvex.fetch(pathQueryFragment, init));\n\n readonly finishInProgressScheduledFunctions = () =>\n Effect.promise(() => this.testConvex.finishInProgressScheduledFunctions());\n\n readonly finishAllScheduledFunctions = (advanceTimers: () => void) =>\n Effect.promise(() =>\n this.testConvex.finishAllScheduledFunctions(advanceTimers),\n );\n}\n\nclass TestConfectImpl<\n ConfectSchema extends DatabaseSchema.AnyWithProps,\n> implements TestConfect<ConfectSchema> {\n private readonly testConfectImplWithoutIdentity: TestConfectImplWithoutIdentity<ConfectSchema>;\n\n constructor(\n private confectSchema: ConfectSchema,\n private testConvex: TestConvexForDataModelAndIdentity<\n DataModel.ToConvex<DataModel.FromSchema<ConfectSchema>>\n >,\n ) {\n this.testConvex = testConvex;\n this.testConfectImplWithoutIdentity = new TestConfectImplWithoutIdentity(\n confectSchema,\n testConvex,\n );\n }\n\n readonly withIdentity = (userIdentity: Partial<UserIdentity>) =>\n new TestConfectImplWithoutIdentity(\n this.confectSchema,\n this.testConvex.withIdentity(userIdentity),\n );\n\n readonly query = <QueryRef extends Ref.AnyQuery>(\n queryRef: QueryRef,\n args: Ref.Args<QueryRef>[\"Type\"],\n ) => this.testConfectImplWithoutIdentity.query(queryRef, args);\n\n readonly mutation = <MutationRef extends Ref.AnyMutation>(\n mutationRef: MutationRef,\n args: Ref.Args<MutationRef>[\"Type\"],\n ) => this.testConfectImplWithoutIdentity.mutation(mutationRef, args);\n\n readonly action = <ActionRef extends Ref.AnyAction>(\n actionRef: ActionRef,\n args: Ref.Args<ActionRef>[\"Type\"],\n ) => this.testConfectImplWithoutIdentity.action(actionRef, args);\n\n readonly run: TestConfect<ConfectSchema>[\"run\"] = ((\n handler: any,\n returns?: any,\n ) =>\n this.testConfectImplWithoutIdentity.run(\n handler,\n returns,\n )) as TestConfect<ConfectSchema>[\"run\"];\n\n readonly fetch = <PathQueryFragment extends string>(\n pathQueryFragment: PathQueryFragment,\n init?: RequestInit,\n ) => this.testConfectImplWithoutIdentity.fetch(pathQueryFragment, init);\n\n readonly finishInProgressScheduledFunctions = () =>\n this.testConfectImplWithoutIdentity.finishInProgressScheduledFunctions();\n\n readonly finishAllScheduledFunctions = (advanceTimers: () => void) =>\n this.testConfectImplWithoutIdentity.finishAllScheduledFunctions(\n advanceTimers,\n );\n}\n\nexport const layer =\n <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n databaseSchema: DatabaseSchema_,\n modules: Record<string, () => Promise<any>>,\n ) =>\n (): Layer.Layer<TestConfect<DatabaseSchema_>> =>\n Layer.sync(\n TestConfect<DatabaseSchema_>(),\n () =>\n new TestConfectImpl(\n databaseSchema,\n convexTest(\n databaseSchema.convexSchemaDefinition,\n modules,\n ) as unknown as TestConvexForDataModelAndIdentity<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n ),\n );\n"],"mappings":";;;;;;;;;;;AA6DA,MAAa,oBAGX,QAAQ,WAAuC,4BAA4B;AAE7E,IAAM,iCAAN,MAEuD;CACrD,YACE,AAAQ,eACR,AAAQ,YAGR;EAJQ;EACA;;CAKV,AAAS,SACP,UACA,SAEA,OAAO,IAAI,MAAM,aAAa;EAC5B,MAAM,QAAQ,IAAI,YAAY,SAAS;EACvC,MAAM,YAAY,IAAI,sBAAsB,SAAS;EAErD,MAAM,cAAc,OAAO,OAAO,OAAO,MAAM,KAAK,CAAC,KAAK;EAE1D,MAAM,iBAAiB,OAAO,OAAO,cACnC,KAAK,WAAW,MAAM,WAAkB,YAAY,CACrD;AAED,SAAO,OAAO,OAAO,OAAO,MAAM,QAAQ,CAAC,eAAe;GAC1D;CAEJ,AAAS,YACP,aACA,SAEA,OAAO,IAAI,MAAM,aAAa;EAC5B,MAAM,WAAW,IAAI,YAAY,YAAY;EAC7C,MAAM,eAAe,IAAI,sBAAsB,YAAY;EAE3D,MAAM,cAAc,OAAO,OAAO,OAAO,SAAS,KAAK,CAAC,KAAK;EAE7D,MAAM,iBAAiB,OAAO,OAAO,cACnC,KAAK,WAAW,SAAS,cAAqB,YAAY,CAC3D;AAED,SAAO,OAAO,OAAO,OAAO,SAAS,QAAQ,CAAC,eAAe;GAC7D;CAEJ,AAAS,UACP,WACA,SAEA,OAAO,IAAI,MAAM,aAAa;EAC5B,MAAM,SAAS,IAAI,YAAY,UAAU;EACzC,MAAM,aAAa,IAAI,sBAAsB,UAAU;EAEvD,MAAM,cAAc,OAAO,OAAO,OAAO,OAAO,KAAK,CAAC,KAAK;EAE3D,MAAM,iBAAiB,OAAO,OAAO,cACnC,KAAK,WAAW,OAAO,YAAmB,YAAY,CACvD;AAED,SAAO,OAAO,OAAO,OAA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KAAK;CAEvE,AAAS,2CACP,KAAK,+BAA+B,oCAAoC;CAE1E,AAAS,+BAA+B,kBACtC,KAAK,+BAA+B,4BAClC,cACD;;AAGL,MAAa,SAET,gBACA,kBAGA,MAAM,KACJ,aAA8B,QAE5B,IAAI,gBACF,gBACA,WACE,eAAe,wBACf,QACD,CAGF,CACJ"}
1
+ {"version":3,"file":"TestConfect.js","names":[],"sources":["../src/TestConfect.ts"],"sourcesContent":["import { Ref } from \"@confect/core\";\nimport type { DatabaseSchema, DataModel } from \"@confect/server\";\nimport { RegisteredConvexFunction } from \"@confect/server\";\nimport type {\n TestConvexForDataModel,\n TestConvexForDataModelAndIdentity,\n} from \"convex-test\";\nimport { convexTest } from \"convex-test\";\nimport type { GenericMutationCtx, UserIdentity } from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Match, Schema } from \"effect\";\n\nexport type TestConfectWithoutIdentity<\n ConfectSchema extends DatabaseSchema.AnyWithProps,\n> = {\n query: <QueryRef extends Ref.AnyQuery>(\n queryRef: QueryRef,\n args: Ref.Args<QueryRef>,\n ) => Effect.Effect<Ref.Returns<QueryRef>, ParseResult.ParseError>;\n mutation: <MutationRef extends Ref.AnyMutation>(\n mutationRef: MutationRef,\n args: Ref.Args<MutationRef>,\n ) => Effect.Effect<Ref.Returns<MutationRef>, ParseResult.ParseError>;\n action: <ActionRef extends Ref.AnyAction>(\n actionRef: ActionRef,\n args: Ref.Args<ActionRef>,\n ) => Effect.Effect<Ref.Returns<ActionRef>, ParseResult.ParseError>;\n run: {\n <E>(\n handler: Effect.Effect<\n void,\n E,\n RegisteredConvexFunction.MutationServices<ConfectSchema>\n >,\n ): Effect.Effect<void>;\n <A, B extends Value, E>(\n handler: Effect.Effect<\n A,\n E,\n RegisteredConvexFunction.MutationServices<ConfectSchema>\n >,\n returns: Schema.Schema<A, B>,\n ): Effect.Effect<A, ParseResult.ParseError>;\n };\n fetch: (\n pathQueryFragment: string,\n init?: RequestInit,\n ) => Effect.Effect<Response>;\n finishInProgressScheduledFunctions: () => Effect.Effect<void>;\n finishAllScheduledFunctions: (\n advanceTimers: () => void,\n ) => Effect.Effect<void>;\n};\n\nexport type TestConfect<ConfectSchema extends DatabaseSchema.AnyWithProps> = {\n withIdentity: (\n userIdentity: Partial<UserIdentity>,\n ) => TestConfectWithoutIdentity<ConfectSchema>;\n} & TestConfectWithoutIdentity<ConfectSchema>;\n\nexport const TestConfect = <\n ConfectSchema extends DatabaseSchema.AnyWithProps,\n>() =>\n Context.GenericTag<TestConfect<ConfectSchema>>(\"@confect/test/TestConfect\");\n\nclass TestConfectImplWithoutIdentity<\n ConfectSchema extends DatabaseSchema.AnyWithProps,\n> implements TestConfectWithoutIdentity<ConfectSchema> {\n constructor(\n private confectSchema: ConfectSchema,\n private testConvex: TestConvexForDataModel<\n DataModel.ToConvex<DataModel.FromSchema<ConfectSchema>>\n >,\n ) {}\n\n readonly query = <QueryRef extends Ref.AnyQuery>(\n queryRef: QueryRef,\n args: Ref.Args<QueryRef>,\n ): Effect.Effect<Ref.Returns<QueryRef>, ParseResult.ParseError> =>\n Effect.gen(this, function* () {\n const querySpec = Ref.getFunctionSpec(queryRef);\n const queryName = Ref.getConvexFunctionName(queryRef);\n\n return yield* Match.value(querySpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confect) =>\n Effect.gen(this, function* () {\n const encodedArgs = yield* Schema.encode(confect.args)(args);\n const encodedReturns = yield* Effect.promise(() =>\n this.testConvex.query(queryName as any, encodedArgs),\n );\n return yield* Schema.decode(confect.returns)(encodedReturns);\n }),\n ),\n Match.tag(\"Convex\", () =>\n Effect.promise(() =>\n this.testConvex.query(queryName as any, args as any),\n ),\n ),\n Match.exhaustive,\n );\n });\n\n readonly mutation = <MutationRef extends Ref.AnyMutation>(\n mutationRef: MutationRef,\n args: Ref.Args<MutationRef>,\n ): Effect.Effect<Ref.Returns<MutationRef>, ParseResult.ParseError> =>\n Effect.gen(this, function* () {\n const mutationSpec = Ref.getFunctionSpec(mutationRef);\n const mutationName = Ref.getConvexFunctionName(mutationRef);\n\n return yield* Match.value(mutationSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confect) =>\n Effect.gen(this, function* () {\n const encodedArgs = yield* Schema.encode(confect.args)(args);\n const encodedReturns = yield* Effect.promise(() =>\n this.testConvex.mutation(mutationName as any, encodedArgs),\n );\n return yield* Schema.decode(confect.returns)(encodedReturns);\n }),\n ),\n Match.tag(\"Convex\", () =>\n Effect.promise(() =>\n this.testConvex.mutation(mutationName as any, args as any),\n ),\n ),\n Match.exhaustive,\n );\n });\n\n readonly action = <ActionRef extends Ref.AnyAction>(\n actionRef: ActionRef,\n args: Ref.Args<ActionRef>,\n ): Effect.Effect<Ref.Returns<ActionRef>, ParseResult.ParseError> =>\n Effect.gen(this, function* () {\n const actionSpec = Ref.getFunctionSpec(actionRef);\n const actionName = Ref.getConvexFunctionName(actionRef);\n\n return yield* Match.value(actionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confect) =>\n Effect.gen(this, function* () {\n const encodedArgs = yield* Schema.encode(confect.args)(args);\n const encodedReturns = yield* Effect.promise(() =>\n this.testConvex.action(actionName as any, encodedArgs),\n );\n return yield* Schema.decode(confect.returns)(encodedReturns);\n }),\n ),\n Match.tag(\"Convex\", () =>\n Effect.promise(() =>\n this.testConvex.action(actionName as any, args as any),\n ),\n ),\n Match.exhaustive,\n );\n });\n\n readonly run: TestConfectWithoutIdentity<ConfectSchema>[\"run\"] = (<\n A,\n B extends Value,\n E,\n >(\n handler: Effect.Effect<\n A,\n E,\n RegisteredConvexFunction.MutationServices<ConfectSchema>\n >,\n returns?: Schema.Schema<A, B>,\n ): Effect.Effect<void> | Effect.Effect<A, ParseResult.ParseError> => {\n const makeMutationLayer = (\n mutationCtx: GenericMutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<ConfectSchema>>\n >,\n ): Layer.Layer<RegisteredConvexFunction.MutationServices<ConfectSchema>> =>\n RegisteredConvexFunction.mutationLayer(\n this.confectSchema,\n mutationCtx,\n ) as Layer.Layer<\n RegisteredConvexFunction.MutationServices<ConfectSchema>\n >;\n\n return returns === undefined\n ? Effect.promise(() =>\n this.testConvex.run((mutationCtx) =>\n Effect.runPromise(\n handler.pipe(\n Effect.asVoid,\n Effect.provide(makeMutationLayer(mutationCtx)),\n ),\n ),\n ),\n )\n : Effect.promise(() =>\n this.testConvex.run((mutationCtx) =>\n Effect.runPromise(\n handler.pipe(\n Effect.andThen(Schema.encode(returns)),\n Effect.provide(makeMutationLayer(mutationCtx)),\n ),\n ),\n ),\n ).pipe(Effect.andThen(Schema.decode(returns)));\n }) as TestConfectWithoutIdentity<ConfectSchema>[\"run\"];\n\n readonly fetch = <PathQueryFragment extends string>(\n pathQueryFragment: PathQueryFragment,\n init?: RequestInit,\n ) => Effect.promise(() => this.testConvex.fetch(pathQueryFragment, init));\n\n readonly finishInProgressScheduledFunctions = () =>\n Effect.promise(() => this.testConvex.finishInProgressScheduledFunctions());\n\n readonly finishAllScheduledFunctions = (advanceTimers: () => void) =>\n Effect.promise(() =>\n this.testConvex.finishAllScheduledFunctions(advanceTimers),\n );\n}\n\nclass TestConfectImpl<\n ConfectSchema extends DatabaseSchema.AnyWithProps,\n> implements TestConfect<ConfectSchema> {\n private readonly testConfectImplWithoutIdentity: TestConfectImplWithoutIdentity<ConfectSchema>;\n\n constructor(\n private confectSchema: ConfectSchema,\n private testConvex: TestConvexForDataModelAndIdentity<\n DataModel.ToConvex<DataModel.FromSchema<ConfectSchema>>\n >,\n ) {\n this.testConvex = testConvex;\n this.testConfectImplWithoutIdentity = new TestConfectImplWithoutIdentity(\n confectSchema,\n testConvex,\n );\n }\n\n readonly withIdentity = (userIdentity: Partial<UserIdentity>) =>\n new TestConfectImplWithoutIdentity(\n this.confectSchema,\n this.testConvex.withIdentity(userIdentity),\n );\n\n readonly query = <QueryRef extends Ref.AnyQuery>(\n queryRef: QueryRef,\n args: Ref.Args<QueryRef>,\n ) => this.testConfectImplWithoutIdentity.query(queryRef, args);\n\n readonly mutation = <MutationRef extends Ref.AnyMutation>(\n mutationRef: MutationRef,\n args: Ref.Args<MutationRef>,\n ) => this.testConfectImplWithoutIdentity.mutation(mutationRef, args);\n\n readonly action = <ActionRef extends Ref.AnyAction>(\n actionRef: ActionRef,\n args: Ref.Args<ActionRef>,\n ) => this.testConfectImplWithoutIdentity.action(actionRef, args);\n\n readonly run: TestConfect<ConfectSchema>[\"run\"] = ((\n handler: any,\n returns?: any,\n ) =>\n this.testConfectImplWithoutIdentity.run(\n handler,\n returns,\n )) as TestConfect<ConfectSchema>[\"run\"];\n\n readonly fetch = <PathQueryFragment extends string>(\n pathQueryFragment: PathQueryFragment,\n init?: RequestInit,\n ) => this.testConfectImplWithoutIdentity.fetch(pathQueryFragment, init);\n\n readonly finishInProgressScheduledFunctions = () =>\n this.testConfectImplWithoutIdentity.finishInProgressScheduledFunctions();\n\n readonly finishAllScheduledFunctions = (advanceTimers: () => void) =>\n this.testConfectImplWithoutIdentity.finishAllScheduledFunctions(\n advanceTimers,\n );\n}\n\nexport const layer =\n <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n databaseSchema: DatabaseSchema_,\n modules: Record<string, () => Promise<any>>,\n ) =>\n (): Layer.Layer<TestConfect<DatabaseSchema_>> =>\n Layer.sync(\n TestConfect<DatabaseSchema_>(),\n () =>\n new TestConfectImpl(\n databaseSchema,\n convexTest(\n databaseSchema.convexSchemaDefinition,\n modules,\n ) as unknown as TestConvexForDataModelAndIdentity<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n ),\n );\n"],"mappings":";;;;;;;;;;;AA6DA,MAAa,oBAGX,QAAQ,WAAuC,4BAA4B;AAE7E,IAAM,iCAAN,MAEuD;CACrD,YACE,AAAQ,eACR,AAAQ,YAGR;EAJQ;EACA;;CAKV,AAAS,SACP,UACA,SAEA,OAAO,IAAI,MAAM,aAAa;EAC5B,MAAM,YAAY,IAAI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,UACA,SACG,KAAK,+BAA+B,MAAM,UAAU,KAAK;CAE9D,AAAS,YACP,aACA,SACG,KAAK,+BAA+B,SAAS,aAAa,KAAK;CAEpE,AAAS,UACP,WACA,SACG,KAAK,+BAA+B,OAAO,WAAW,KAAK;CAEhE,AAAS,QACP,SACA,YAEA,KAAK,+BAA+B,IAClC,SACA,QACD;CAEH,AAAS,SACP,mBACA,SACG,KAAK,+BAA+B,MAAM,mBAAmB,KAAK;CAEvE,AAAS,2CACP,KAAK,+BAA+B,oCAAoC;CAE1E,AAAS,+BAA+B,kBACtC,KAAK,+BAA+B,4BAClC,cACD;;AAGL,MAAa,SAET,gBACA,kBAGA,MAAM,KACJ,aAA8B,QAE5B,IAAI,gBACF,gBACA,WACE,eAAe,wBACf,QACD,CAGF,CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@confect/test",
3
- "version": "2.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "Utilities for testing Confect apps without a live Convex backend",
5
5
  "repository": {
6
6
  "type": "git",
@@ -53,8 +53,8 @@
53
53
  "convex": "^1.30.0",
54
54
  "convex-test": "^0.0.38",
55
55
  "effect": "^3.19.16",
56
- "@confect/core": "2.0.0",
57
- "@confect/server": "2.0.0"
56
+ "@confect/core": "4.0.0",
57
+ "@confect/server": "4.0.0"
58
58
  },
59
59
  "engines": {
60
60
  "node": ">=22",
@@ -9,23 +9,23 @@ import { convexTest } from "convex-test";
9
9
  import type { GenericMutationCtx, UserIdentity } from "convex/server";
10
10
  import type { Value } from "convex/values";
11
11
  import type { ParseResult } from "effect";
12
- import { Context, Effect, Layer, Schema } from "effect";
12
+ import { Context, Effect, Layer, Match, Schema } from "effect";
13
13
 
14
14
  export type TestConfectWithoutIdentity<
15
15
  ConfectSchema extends DatabaseSchema.AnyWithProps,
16
16
  > = {
17
17
  query: <QueryRef extends Ref.AnyQuery>(
18
18
  queryRef: QueryRef,
19
- args: Ref.Args<QueryRef>["Type"],
20
- ) => Effect.Effect<Ref.Returns<QueryRef>["Type"], ParseResult.ParseError>;
19
+ args: Ref.Args<QueryRef>,
20
+ ) => Effect.Effect<Ref.Returns<QueryRef>, ParseResult.ParseError>;
21
21
  mutation: <MutationRef extends Ref.AnyMutation>(
22
22
  mutationRef: MutationRef,
23
- args: Ref.Args<MutationRef>["Type"],
24
- ) => Effect.Effect<Ref.Returns<MutationRef>["Type"], ParseResult.ParseError>;
23
+ args: Ref.Args<MutationRef>,
24
+ ) => Effect.Effect<Ref.Returns<MutationRef>, ParseResult.ParseError>;
25
25
  action: <ActionRef extends Ref.AnyAction>(
26
26
  actionRef: ActionRef,
27
- args: Ref.Args<ActionRef>["Type"],
28
- ) => Effect.Effect<Ref.Returns<ActionRef>["Type"], ParseResult.ParseError>;
27
+ args: Ref.Args<ActionRef>,
28
+ ) => Effect.Effect<Ref.Returns<ActionRef>, ParseResult.ParseError>;
29
29
  run: {
30
30
  <E>(
31
31
  handler: Effect.Effect<
@@ -76,53 +76,83 @@ class TestConfectImplWithoutIdentity<
76
76
 
77
77
  readonly query = <QueryRef extends Ref.AnyQuery>(
78
78
  queryRef: QueryRef,
79
- args: Ref.Args<QueryRef>["Type"],
80
- ): Effect.Effect<Ref.Returns<QueryRef>["Type"], ParseResult.ParseError> =>
79
+ args: Ref.Args<QueryRef>,
80
+ ): Effect.Effect<Ref.Returns<QueryRef>, ParseResult.ParseError> =>
81
81
  Effect.gen(this, function* () {
82
- const query = Ref.getFunction(queryRef);
82
+ const querySpec = Ref.getFunctionSpec(queryRef);
83
83
  const queryName = Ref.getConvexFunctionName(queryRef);
84
84
 
85
- const encodedArgs = yield* Schema.encode(query.args)(args);
86
-
87
- const encodedReturns = yield* Effect.promise(() =>
88
- this.testConvex.query(queryName as any, encodedArgs),
85
+ return yield* Match.value(querySpec.functionProvenance).pipe(
86
+ Match.tag("Confect", (confect) =>
87
+ Effect.gen(this, function* () {
88
+ const encodedArgs = yield* Schema.encode(confect.args)(args);
89
+ const encodedReturns = yield* Effect.promise(() =>
90
+ this.testConvex.query(queryName as any, encodedArgs),
91
+ );
92
+ return yield* Schema.decode(confect.returns)(encodedReturns);
93
+ }),
94
+ ),
95
+ Match.tag("Convex", () =>
96
+ Effect.promise(() =>
97
+ this.testConvex.query(queryName as any, args as any),
98
+ ),
99
+ ),
100
+ Match.exhaustive,
89
101
  );
90
-
91
- return yield* Schema.decode(query.returns)(encodedReturns);
92
102
  });
93
103
 
94
104
  readonly mutation = <MutationRef extends Ref.AnyMutation>(
95
105
  mutationRef: MutationRef,
96
- args: Ref.Args<MutationRef>["Type"],
97
- ): Effect.Effect<Ref.Returns<MutationRef>["Type"], ParseResult.ParseError> =>
106
+ args: Ref.Args<MutationRef>,
107
+ ): Effect.Effect<Ref.Returns<MutationRef>, ParseResult.ParseError> =>
98
108
  Effect.gen(this, function* () {
99
- const mutation = Ref.getFunction(mutationRef);
109
+ const mutationSpec = Ref.getFunctionSpec(mutationRef);
100
110
  const mutationName = Ref.getConvexFunctionName(mutationRef);
101
111
 
102
- const encodedArgs = yield* Schema.encode(mutation.args)(args);
103
-
104
- const encodedReturns = yield* Effect.promise(() =>
105
- this.testConvex.mutation(mutationName as any, encodedArgs),
112
+ return yield* Match.value(mutationSpec.functionProvenance).pipe(
113
+ Match.tag("Confect", (confect) =>
114
+ Effect.gen(this, function* () {
115
+ const encodedArgs = yield* Schema.encode(confect.args)(args);
116
+ const encodedReturns = yield* Effect.promise(() =>
117
+ this.testConvex.mutation(mutationName as any, encodedArgs),
118
+ );
119
+ return yield* Schema.decode(confect.returns)(encodedReturns);
120
+ }),
121
+ ),
122
+ Match.tag("Convex", () =>
123
+ Effect.promise(() =>
124
+ this.testConvex.mutation(mutationName as any, args as any),
125
+ ),
126
+ ),
127
+ Match.exhaustive,
106
128
  );
107
-
108
- return yield* Schema.decode(mutation.returns)(encodedReturns);
109
129
  });
110
130
 
111
131
  readonly action = <ActionRef extends Ref.AnyAction>(
112
132
  actionRef: ActionRef,
113
- args: Ref.Args<ActionRef>["Type"],
114
- ): Effect.Effect<Ref.Returns<ActionRef>["Type"], ParseResult.ParseError> =>
133
+ args: Ref.Args<ActionRef>,
134
+ ): Effect.Effect<Ref.Returns<ActionRef>, ParseResult.ParseError> =>
115
135
  Effect.gen(this, function* () {
116
- const action = Ref.getFunction(actionRef);
136
+ const actionSpec = Ref.getFunctionSpec(actionRef);
117
137
  const actionName = Ref.getConvexFunctionName(actionRef);
118
138
 
119
- const encodedArgs = yield* Schema.encode(action.args)(args);
120
-
121
- const encodedReturns = yield* Effect.promise(() =>
122
- this.testConvex.action(actionName as any, encodedArgs),
139
+ return yield* Match.value(actionSpec.functionProvenance).pipe(
140
+ Match.tag("Confect", (confect) =>
141
+ Effect.gen(this, function* () {
142
+ const encodedArgs = yield* Schema.encode(confect.args)(args);
143
+ const encodedReturns = yield* Effect.promise(() =>
144
+ this.testConvex.action(actionName as any, encodedArgs),
145
+ );
146
+ return yield* Schema.decode(confect.returns)(encodedReturns);
147
+ }),
148
+ ),
149
+ Match.tag("Convex", () =>
150
+ Effect.promise(() =>
151
+ this.testConvex.action(actionName as any, args as any),
152
+ ),
153
+ ),
154
+ Match.exhaustive,
123
155
  );
124
-
125
- return yield* Schema.decode(action.returns)(encodedReturns);
126
156
  });
127
157
 
128
158
  readonly run: TestConfectWithoutIdentity<ConfectSchema>["run"] = (<
@@ -212,17 +242,17 @@ class TestConfectImpl<
212
242
 
213
243
  readonly query = <QueryRef extends Ref.AnyQuery>(
214
244
  queryRef: QueryRef,
215
- args: Ref.Args<QueryRef>["Type"],
245
+ args: Ref.Args<QueryRef>,
216
246
  ) => this.testConfectImplWithoutIdentity.query(queryRef, args);
217
247
 
218
248
  readonly mutation = <MutationRef extends Ref.AnyMutation>(
219
249
  mutationRef: MutationRef,
220
- args: Ref.Args<MutationRef>["Type"],
250
+ args: Ref.Args<MutationRef>,
221
251
  ) => this.testConfectImplWithoutIdentity.mutation(mutationRef, args);
222
252
 
223
253
  readonly action = <ActionRef extends Ref.AnyAction>(
224
254
  actionRef: ActionRef,
225
- args: Ref.Args<ActionRef>["Type"],
255
+ args: Ref.Args<ActionRef>,
226
256
  ) => this.testConfectImplWithoutIdentity.action(actionRef, args);
227
257
 
228
258
  readonly run: TestConfect<ConfectSchema>["run"] = ((