@confect/test 1.0.0-next.1 → 1.0.0-next.3

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,24 @@
1
1
  # @confect/test
2
2
 
3
+ ## 1.0.0-next.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9cd3cda]
8
+ - Updated dependencies [186c130]
9
+ - @confect/server@1.0.0-next.3
10
+ - @confect/core@1.0.0-next.3
11
+
12
+ ## 1.0.0-next.2
13
+
14
+ ### Patch Changes
15
+
16
+ - 071b6ed: Upgrade deps
17
+ - Updated dependencies [071b6ed]
18
+ - Updated dependencies [afc9fb4]
19
+ - @confect/server@1.0.0-next.2
20
+ - @confect/core@1.0.0-next.2
21
+
3
22
  ## 1.0.0-next.1
4
23
 
5
24
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"TestConfect.d.ts","names":[],"sources":["../src/TestConfect.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KAaY,iDACY,cAAA,CAAe;2BAEZ,GAAA,CAAI,oBACjB,gBACJ,GAAA,CAAI,KAAK,sBACZ,MAAA,CAAO,OAAO,GAAA,CAAI,QAAQ,mBAAmB,WAAA,CAAY;iCAC/B,GAAA,CAAI,0BACpB,mBACP,GAAA,CAAI,KAAK,yBACZ,MAAA,CAAO,OAAO,GAAA,CAAI,QAAQ,sBAAsB,WAAA,CAAY;6BACtC,GAAA,CAAI,sBAClB,iBACL,GAAA,CAAI,KAAK,uBACZ,MAAA,CAAO,OAAO,GAAA,CAAI,QAAQ,oBAAoB,WAAA,CAAY;;iBAGlD,MAAA,CAAO,aAEd,GACA,mBAAA,CAAoB,iBAAiB,kBAEtC,MAAA,CAAO;IAtBF,CAAA,CAAA,EAAA,UAuBM,KAvBN,EAAA,CAAA,CAAA,CAAA,OAA0B,EAwBvB,MAAA,CAAO,MAxBgB,CAyB9B,CAzB8B,EA0B9B,CA1B8B,EA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ACG,MAAA,CAAO,MAAA;AAAA;AAAA,KAGF,WAAA,uBAAkC,cAAA,CAAe,YAAA;EAC3D,YAAA,GACE,YAAA,EAAc,OAAA,CAAQ,YAAA,MACnB,0BAAA,CAA2B,aAAA;AAAA,IAC9B,0BAAA,CAA2B,aAAA;AAAA,cAElB,WAAA,yBACW,cAAA,CAAe,YAAA,OAAY,OAAA,CAAA,GAAA,CAAA,WAAA,CAAA,aAAA,GAAA,WAAA,CAAA,aAAA;AAAA,cA0LtC,KAAA,2BACc,cAAA,CAAe,YAAA,EACtC,cAAA,EAAgB,eAAA,EAChB,OAAA,EAAS,MAAA,eAAqB,OAAA,iBAE5B,KAAA,CAAM,KAAA,CAAM,WAAA,CAAY,eAAA"}
@@ -1,11 +1,11 @@
1
- import { __export } from "./_virtual/rolldown_runtime.js";
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  import { Ref } from "@confect/core";
3
3
  import { RegisteredFunctions } from "@confect/server";
4
4
  import { convexTest } from "convex-test";
5
5
  import { Context, Effect, Layer, Schema } from "effect";
6
6
 
7
7
  //#region src/TestConfect.ts
8
- var TestConfect_exports = /* @__PURE__ */ __export({
8
+ var TestConfect_exports = /* @__PURE__ */ __exportAll({
9
9
  TestConfect: () => TestConfect,
10
10
  layer: () => layer
11
11
  });
@@ -1 +1 @@
1
- {"version":3,"file":"TestConfect.js","names":["confectSchema: ConfectSchema","testConvex: TestConvexForDataModel<\n DataModel.ToConvex<DataModel.FromSchema<ConfectSchema>>\n >","testConvex: TestConvexForDataModelAndIdentity<\n DataModel.ToConvex<DataModel.FromSchema<ConfectSchema>>\n >"],"sources":["../src/TestConfect.ts"],"sourcesContent":["import { Ref } from \"@confect/core\";\nimport type { DatabaseSchema, DataModel } from \"@confect/server\";\nimport { RegisteredFunctions } 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 RegisteredFunctions.MutationServices<ConfectSchema>\n >,\n ): Effect.Effect<void>;\n <A, B extends Value, E>(\n handler: Effect.Effect<\n A,\n E,\n RegisteredFunctions.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{\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 RegisteredFunctions.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<RegisteredFunctions.MutationServices<ConfectSchema>> =>\n RegisteredFunctions.mutationLayer(\n this.confectSchema,\n mutationCtx,\n ) as Layer.Layer<RegisteredFunctions.MutationServices<ConfectSchema>>;\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<ConfectSchema extends DatabaseSchema.AnyWithProps>\n implements TestConfect<ConfectSchema>\n{\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.convexS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,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 { RegisteredFunctions } 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 RegisteredFunctions.MutationServices<ConfectSchema>\n >,\n ): Effect.Effect<void>;\n <A, B extends Value, E>(\n handler: Effect.Effect<\n A,\n E,\n RegisteredFunctions.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 RegisteredFunctions.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<RegisteredFunctions.MutationServices<ConfectSchema>> =>\n RegisteredFunctions.mutationLayer(\n this.confectSchema,\n mutationCtx,\n ) as Layer.Layer<RegisteredFunctions.MutationServices<ConfectSchema>>;\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,cAC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I,+BACxC,eACA,WACD;;CAGH,AAAS,gBAAgB,iBACvB,IAAI,+BACF,KAAK,eACL,KAAK,WAAW,aAAa,aAAa,CAC3C;CAEH,AAAS,SACP,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"}
@@ -0,0 +1,18 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (!no_symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+ export { __exportAll };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@confect/test",
3
- "version": "1.0.0-next.1",
3
+ "version": "1.0.0-next.3",
4
4
  "description": "Utilities for testing Confect apps without a live Convex backend",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,21 +40,22 @@
40
40
  "author": "RJ Dellecese",
41
41
  "license": "ISC",
42
42
  "devDependencies": {
43
- "@effect/language-service": "0.56.0",
44
- "@eslint/js": "9.39.1",
45
- "@types/node": "24.10.1",
46
- "eslint": "9.39.1",
47
- "prettier": "3.6.2",
48
- "tsdown": "0.16.4",
43
+ "@effect/language-service": "0.73.1",
44
+ "@eslint/js": "9.39.2",
45
+ "@types/node": "25.2.3",
46
+ "eslint": "9.39.2",
47
+ "prettier": "3.8.1",
48
+ "tsdown": "0.20.3",
49
49
  "typescript": "5.9.3",
50
- "typescript-eslint": "8.46.4"
50
+ "typescript-eslint": "8.55.0",
51
+ "effect": "3.19.16"
51
52
  },
52
53
  "peerDependencies": {
53
54
  "convex": "^1.30.0",
54
55
  "convex-test": "^0.0.38",
55
- "effect": "^3.19.3",
56
- "@confect/core": "1.0.0-next.1",
57
- "@confect/server": "1.0.0-next.1"
56
+ "effect": "^3.19.16",
57
+ "@confect/core": "1.0.0-next.3",
58
+ "@confect/server": "1.0.0-next.3"
58
59
  },
59
60
  "engines": {
60
61
  "node": ">=22",
@@ -66,8 +66,7 @@ export const TestConfect = <
66
66
 
67
67
  class TestConfectImplWithoutIdentity<
68
68
  ConfectSchema extends DatabaseSchema.AnyWithProps,
69
- > implements TestConfectWithoutIdentity<ConfectSchema>
70
- {
69
+ > implements TestConfectWithoutIdentity<ConfectSchema> {
71
70
  constructor(
72
71
  private confectSchema: ConfectSchema,
73
72
  private testConvex: TestConvexForDataModel<
@@ -185,9 +184,9 @@ class TestConfectImplWithoutIdentity<
185
184
  );
186
185
  }
187
186
 
188
- class TestConfectImpl<ConfectSchema extends DatabaseSchema.AnyWithProps>
189
- implements TestConfect<ConfectSchema>
190
- {
187
+ class TestConfectImpl<
188
+ ConfectSchema extends DatabaseSchema.AnyWithProps,
189
+ > implements TestConfect<ConfectSchema> {
191
190
  private readonly testConfectImplWithoutIdentity: TestConfectImplWithoutIdentity<ConfectSchema>;
192
191
 
193
192
  constructor(
@@ -1,13 +0,0 @@
1
- //#region rolldown:runtime
2
- var __defProp = Object.defineProperty;
3
- var __export = (all) => {
4
- let target = {};
5
- for (var name in all) __defProp(target, name, {
6
- get: all[name],
7
- enumerable: true
8
- });
9
- return target;
10
- };
11
-
12
- //#endregion
13
- export { __export };