@confect/test 9.0.0-next.5 → 9.0.0-next.6

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,109 @@
1
1
  # @confect/test
2
2
 
3
+ ## 9.0.0-next.6
4
+
5
+ ### Major Changes
6
+
7
+ - 762f7eb: Split the deploy-time Convex schema from the runtime `DatabaseSchema`, make `confect/tables/` the single source of truth — including the table name, which is now derived from the filename — and make per-table schema construction lazy.
8
+
9
+ Previously, `confect/schema.ts` was user-authored and `DatabaseSchema` carried a `convexSchemaDefinition` field that was eagerly rebuilt on every `.addTable(...)`. That field was an `O(n²)` allocation for `n` tables, and it forced both the deploy CLI (which only needs `defineSchema(...)`) and the runtime (which only needs the table codec lookup) through the same module — so any runtime function bundle dragged in `convex/server`'s `defineSchema`. Issue 1.
10
+
11
+ Codegen now scans `confect/tables/*.ts` (every file must default-export a `Table`) and emits two siblings:
12
+ - `confect/_generated/schema.ts` — the runtime `DatabaseSchema`, consumed by `_generated/api.ts`. Imports `@confect/server` but never `convex/server`.
13
+ - `confect/_generated/convexSchema.ts` — the Convex deploy `SchemaDefinition`, re-exported one-line from `convex/schema.ts`. Imports `convex/server` but never `@confect/server`.
14
+
15
+ The `convexSchemaDefinition` field is removed from `DatabaseSchema` and `Api`. `TestConfect.layer` now takes the Convex schema definition as a separate argument so it can stay aligned with the deploy artifact without bringing the runtime schema along for the ride.
16
+
17
+ ### Filename-derived table names
18
+
19
+ The table name is now derived from the file's basename — `confect/tables/notes.ts` defines a table called `notes`. `Table.make` no longer accepts a name argument and returns an _unnamed_ `Table` value; codegen invokes that value with the filename to produce the bound table.
20
+
21
+ This eliminates a class of subtle infelicities: the file basename and the table name can never drift out of sync, cross-table `_id` references are type-constrained against the actual set of declared tables (catching typos at compile time), and ESM cycle hazards for mutual cross-table `Id` references are gone because authoring files no longer transitively import each other.
22
+
23
+ Codegen now emits two new sets of files alongside `_generated/schema.ts` and `_generated/convexSchema.ts`:
24
+ - `confect/_generated/id.ts` — a single `Id` constructor whose argument is type-constrained to the union of your table names. Use `Id("notes")` everywhere you previously wrote `GenericId.GenericId("notes")`.
25
+ - `confect/_generated/tables/<name>.ts` — one thin wrapper per table that binds the unnamed value from `confect/tables/<name>.ts` to its filename. This is what other modules (specs, impls, HTTP handlers) default-import to reach a table's `Doc`, `Fields`, and `tableName`.
26
+
27
+ Table filenames must be valid JS identifiers, may not start with `_` (Convex reserves underscore-prefixed names for system tables), and may not collide with reserved JS keywords like `import.ts`. Pick a casing convention you like — Confect's example code uses `snake_case` (`notes.ts`, `user_profiles.ts`).
28
+
29
+ The bound `Table`'s `name` property has been renamed to `tableName`. This avoids a silent collision with the built-in `Function.prototype.name` that JavaScript carries on every function value (including the new unnamed-callable `UnnamedTable`).
30
+
31
+ ### Lazy per-table schema construction
32
+
33
+ `Table.make` takes a `() => Schema.Struct({...})` callback rather than a bare struct, and a bound `Table`'s `Fields`, `Doc`, and `tableDefinition` are lazy memoised getters that only invoke that callback on first access.
34
+
35
+ Previously, every `confect/tables/<name>.ts` module ran `Schema.Struct({...})` (and the corresponding `compileTableSchema` / `defineTable` work) at module-load time. Because the codegen-emitted `_generated/schema.ts` is imported transitively from every per-group function bundle, loading any one function eagerly built _every_ table's schema graph — paying a cold-start cost proportional to the whole project, not just the function being invoked.
36
+
37
+ The bound `Table` now exposes `Fields` / `Doc` / `tableDefinition` as lazy getters that compute their value on first access, then replace themselves with a plain non-writable data property so second-and-subsequent accesses are observably indistinguishable from a plain property (and skip all function-call overhead). The result: a function bundle only pays the schema-construction cost for tables it actually touches via `db.table(name)` (which reaches `Fields` through `Document.decode`). The `UnnamedTable` callable no longer exposes `Fields` or `tableDefinition` — read these off the bound `Table` (the generated `_generated/tables/<name>.ts` wrapper already binds the name).
38
+
39
+ ### Migration
40
+ 1. Delete your `confect/schema.ts`. Codegen will refuse to run while a stray copy is present.
41
+ 2. Rename each `confect/tables/<Name>.ts` to a valid JS identifier in your chosen casing convention (e.g. `confect/tables/notes.ts`). The basename becomes the table name; you no longer pass it as an argument.
42
+ 3. Convert each table file to a **default-export-only** unnamed module: drop the name argument from `Table.make`, wrap the field-schema struct in a `() => ...` callback, and switch any `GenericId.GenericId("users")` references to `Id("users")` imported from `../_generated/id`:
43
+
44
+ ```diff
45
+ - import { GenericId } from "@confect/core";
46
+ import { Table } from "@confect/server";
47
+ import { Schema } from "effect";
48
+ + import { Id } from "../_generated/id";
49
+
50
+ - export default Table.make(
51
+ - "notes",
52
+ - Schema.Struct({
53
+ - userId: Schema.optional(GenericId.GenericId("users")),
54
+ - text: Schema.String,
55
+ - }),
56
+ - );
57
+ + export default Table.make(() =>
58
+ + Schema.Struct({
59
+ + userId: Schema.optional(Id("users")),
60
+ + text: Schema.String,
61
+ + }),
62
+ + );
63
+ ```
64
+
65
+ 4. Rewire every consumer site (specs, impls, integration tests, HTTP handlers, etc.) to import from the generated wrapper rather than directly from `tables/`. The wrapper is also where you now read `Doc` / `Fields` / `tableDefinition` (the unnamed `Table.make(...)` callable no longer exposes them):
66
+
67
+ ```diff
68
+ - import Notes from "../tables/Notes";
69
+ + import notes from "../_generated/tables/notes";
70
+
71
+ - returns: Schema.Array(Notes.Doc),
72
+ + returns: Schema.Array(notes.Doc),
73
+ ```
74
+
75
+ 5. Replace every remaining `GenericId.GenericId("x")` call site with `Id("x")` from `_generated/id` (in spec `args`/`returns`, in `TaggedError` schemas, in `TestConfect.run`, etc.).
76
+ 6. If you read `table.name` anywhere off a bound `Table`, rename it to `table.tableName`.
77
+ 7. Re-run `confect codegen`. It will create `confect/_generated/schema.ts`, `confect/_generated/convexSchema.ts`, `confect/_generated/id.ts`, and one `confect/_generated/tables/<name>.ts` wrapper per table; and it will rewrite `convex/schema.ts` to a one-line re-export.
78
+ 8. If you use `@confect/test`, pass the generated Convex schema definition to `TestConfect.layer`:
79
+
80
+ ```diff
81
+ - import confectSchema from "./confect/schema";
82
+ + import confectSchema from "./confect/_generated/schema";
83
+ + import convexSchema from "./confect/_generated/convexSchema";
84
+
85
+ export const layer = TestConfect_.layer(
86
+ confectSchema,
87
+ + convexSchema,
88
+ import.meta.glob("./convex/**/!(*.*.*)*.*s"),
89
+ );
90
+ ```
91
+
92
+ ### New warning: no tables discovered
93
+
94
+ If a Confect project has no tables — either `confect/tables/` is missing entirely or it exists but contains no `.ts` files — codegen now emits a yellow `⚠` warning and continues, producing an empty `DatabaseSchema.make()` / `defineSchema({})`. Table-free backends (e.g. action-only proxies, webhook bridges) are still legal; the warning just catches the much more common case of a typoed directory name or files placed at the wrong path. To silence it, add at least one `Table.make(...)` module under `confect/tables/`.
95
+
96
+ ### New error: invalid table filename
97
+
98
+ Codegen now rejects table files whose basename is not a valid JS identifier (e.g. `user-profiles.ts`), starts with `_` (reserved for Convex system tables), or shadows a reserved JS keyword (e.g. `import.ts`). Rename the offending file to fix it — for example, `user-profiles.ts` → `user_profiles.ts` or `userProfiles.ts`.
99
+
100
+ ### Patch Changes
101
+
102
+ - Updated dependencies [46045a9]
103
+ - Updated dependencies [762f7eb]
104
+ - @confect/core@9.0.0-next.6
105
+ - @confect/server@9.0.0-next.6
106
+
3
107
  ## 9.0.0-next.5
4
108
 
5
109
  ### Patch Changes
@@ -1,7 +1,7 @@
1
1
  import { Ref } from "@confect/core";
2
2
  import { DatabaseSchema, RegisteredConvexFunction } from "@confect/server";
3
3
  import { Context, Effect, Layer, ParseResult, Schema } from "effect";
4
- import { UserIdentity } from "convex/server";
4
+ import { GenericSchema, SchemaDefinition, UserIdentity } from "convex/server";
5
5
  import { Value } from "convex/values";
6
6
 
7
7
  //#region src/TestConfect.d.ts
@@ -24,7 +24,7 @@ type TestConfect<ConfectSchema extends DatabaseSchema.AnyWithProps> = {
24
24
  withIdentity: (userIdentity: Partial<UserIdentity>) => TestConfectWithoutIdentity<ConfectSchema>;
25
25
  } & TestConfectWithoutIdentity<ConfectSchema>;
26
26
  declare const TestConfect: <ConfectSchema extends DatabaseSchema.AnyWithProps>() => Context.Tag<TestConfect<ConfectSchema>, TestConfect<ConfectSchema>>;
27
- declare const layer: <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(databaseSchema: DatabaseSchema_, modules: Record<string, () => Promise<any>>) => () => Layer.Layer<TestConfect<DatabaseSchema_>>;
27
+ declare const layer: <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(databaseSchema: DatabaseSchema_, convexSchemaDefinition: SchemaDefinition<GenericSchema, true>, modules: Record<string, () => Promise<any>>) => () => Layer.Layer<TestConfect<DatabaseSchema_>>;
28
28
  //#endregion
29
29
  export { TestConfect, TestConfectWithoutIdentity, TestConfect_d_exports, layer };
30
30
  //# sourceMappingURL=TestConfect.d.ts.map
@@ -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,KACP,IAAA,EAAM,GAAA,CAAI,YAAA,CAAa,QAAA,MACvB,MAAA,CAAO,MAAA,CACV,GAAA,CAAI,OAAA,CAAQ,QAAA,GACZ,GAAA,CAAI,KAAA,CAAM,QAAA,IAAY,WAAA,CAAY,UAAA;EAEpC,QAAA,uBAA+B,GAAA,CAAI,WAAA,EACjC,WAAA,EAAa,WAAA,KACV,IAAA,EAAM,GAAA,CAAI,YAAA,CAAa,WAAA,MACvB,MAAA,CAAO,MAAA,CACV,GAAA,CAAI,OAAA,CAAQ,WAAA,GACZ,GAAA,CAAI,KAAA,CAAM,WAAA,IAAe,WAAA,CAAY,UAAA;EAEvC,MAAA,qBAA2B,GAAA,CAAI,SAAA,EAC7B,SAAA,EAAW,SAAA,KACR,IAAA,EAAM,GAAA,CAAI,YAAA,CAAa,SAAA,MACvB,MAAA,CAAO,MAAA,CACV,GAAA,CAAI,OAAA,CAAQ,SAAA,GACZ,GAAA,CAAI,KAAA,CAAM,S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AAA,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,cAmLtC,KAAA,2BACc,cAAA,CAAe,YAAA,EACtC,cAAA,EAAgB,eAAA,EAChB,sBAAA,EAAwB,gBAAA,CAAiB,aAAA,SACzC,OAAA,EAAS,MAAA,eAAqB,OAAA,iBAE5B,KAAA,CAAM,KAAA,CAAM,WAAA,CAAY,eAAA"}
@@ -43,7 +43,7 @@ var TestConfectImpl = class {
43
43
  finishInProgressScheduledFunctions = () => this.testConfectImplWithoutIdentity.finishInProgressScheduledFunctions();
44
44
  finishAllScheduledFunctions = (advanceTimers) => this.testConfectImplWithoutIdentity.finishAllScheduledFunctions(advanceTimers);
45
45
  };
46
- const layer = (databaseSchema, modules) => () => Layer.sync(TestConfect(), () => new TestConfectImpl(databaseSchema, convexTest(databaseSchema.convexSchemaDefinition, modules)));
46
+ const layer = (databaseSchema, convexSchemaDefinition, modules) => () => Layer.sync(TestConfect(), () => new TestConfectImpl(databaseSchema, convexTest(convexSchemaDefinition, modules)));
47
47
 
48
48
  //#endregion
49
49
  export { TestConfect, TestConfect_exports, layer };
@@ -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.OptionalArgs<QueryRef>\n ) => Effect.Effect<\n Ref.Returns<QueryRef>,\n Ref.Error<QueryRef> | ParseResult.ParseError\n >;\n mutation: <MutationRef extends Ref.AnyMutation>(\n mutationRef: MutationRef,\n ...args: Ref.OptionalArgs<MutationRef>\n ) => Effect.Effect<\n Ref.Returns<MutationRef>,\n Ref.Error<MutationRef> | ParseResult.ParseError\n >;\n action: <ActionRef extends Ref.AnyAction>(\n actionRef: ActionRef,\n ...args: Ref.OptionalArgs<ActionRef>\n ) => Effect.Effect<\n Ref.Returns<ActionRef>,\n Ref.Error<ActionRef> | ParseResult.ParseError\n >;\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.OptionalArgs<QueryRef>\n ): Effect.Effect<\n Ref.Returns<QueryRef>,\n Ref.Error<QueryRef> | ParseResult.ParseError\n > =>\n Ref.runWithCodec(\n queryRef,\n (args[0] ?? {}) as Ref.Args<QueryRef>,\n (functionReference, encodedArgs) =>\n this.testConvex.query(functionReference as any, encodedArgs),\n );\n\n readonly mutation = <MutationRef extends Ref.AnyMutation>(\n mutationRef: MutationRef,\n ...args: Ref.OptionalArgs<MutationRef>\n ): Effect.Effect<\n Ref.Returns<MutationRef>,\n Ref.Error<MutationRef> | ParseResult.ParseError\n > =>\n Ref.runWithCodec(\n mutationRef,\n (args[0] ?? {}) as Ref.Args<MutationRef>,\n (functionReference, encodedArgs) =>\n this.testConvex.mutation(functionReference as any, encodedArgs),\n );\n\n readonly action = <ActionRef extends Ref.AnyAction>(\n actionRef: ActionRef,\n ...args: Ref.OptionalArgs<ActionRef>\n ): Effect.Effect<\n Ref.Returns<ActionRef>,\n Ref.Error<ActionRef> | ParseResult.ParseError\n > =>\n Ref.runWithCodec(\n actionRef,\n (args[0] ?? {}) as Ref.Args<ActionRef>,\n (functionReference, encodedArgs) =>\n this.testConvex.action(functionReference as any, encodedArgs),\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.OptionalArgs<QueryRef>\n ) => this.testConfectImplWithoutIdentity.query(queryRef, ...args);\n\n readonly mutation = <MutationRef extends Ref.AnyMutation>(\n mutationRef: MutationRef,\n ...args: Ref.OptionalArgs<MutationRef>\n ) => this.testConfectImplWithoutIdentity.mutation(mutationRef, ...args);\n\n readonly action = <ActionRef extends Ref.AnyAction>(\n actionRef: ActionRef,\n ...args: Ref.OptionalArgs<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(databaseSchema.convexSchemaDefinition, modules) as any,\n ),\n );\n"],"mappings":";;;;;;;;;;;AAsEA,MAAa,oBAGX,QAAQ,WAAuC,4BAA4B;AAE7E,IAAM,iCAAN,MAEuD;CACrD,YACE,AAAQ,eACR,AAAQ,YAGR;EAJQ;EACA;;CAKV,AAAS,SACP,UACA,GAAG,SAKH,IAAI,aACF,UACC,KAAK,MAAM,EAAE,GACb,mBAAmB,gBAClB,KAAK,WAAW,MAAM,mBAA0B,YAAY,CAC/D;CAEH,AAAS,YACP,aACA,GAAG,SAKH,IAAI,aACF,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S,aAAa,GAAG,KAAK;CAEvE,AAAS,UACP,WACA,GAAG,SACA,KAAK,+BAA+B,OAAO,WAAW,GAAG,KAAK;CAEnE,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,WAAW,eAAe,wBAAwB,QAAQ,CAC3D,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 {\n GenericMutationCtx,\n GenericSchema,\n SchemaDefinition,\n UserIdentity,\n} 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.OptionalArgs<QueryRef>\n ) => Effect.Effect<\n Ref.Returns<QueryRef>,\n Ref.Error<QueryRef> | ParseResult.ParseError\n >;\n mutation: <MutationRef extends Ref.AnyMutation>(\n mutationRef: MutationRef,\n ...args: Ref.OptionalArgs<MutationRef>\n ) => Effect.Effect<\n Ref.Returns<MutationRef>,\n Ref.Error<MutationRef> | ParseResult.ParseError\n >;\n action: <ActionRef extends Ref.AnyAction>(\n actionRef: ActionRef,\n ...args: Ref.OptionalArgs<ActionRef>\n ) => Effect.Effect<\n Ref.Returns<ActionRef>,\n Ref.Error<ActionRef> | ParseResult.ParseError\n >;\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.OptionalArgs<QueryRef>\n ): Effect.Effect<\n Ref.Returns<QueryRef>,\n Ref.Error<QueryRef> | ParseResult.ParseError\n > =>\n Ref.runWithCodec(\n queryRef,\n (args[0] ?? {}) as Ref.Args<QueryRef>,\n (functionReference, encodedArgs) =>\n this.testConvex.query(functionReference as any, encodedArgs),\n );\n\n readonly mutation = <MutationRef extends Ref.AnyMutation>(\n mutationRef: MutationRef,\n ...args: Ref.OptionalArgs<MutationRef>\n ): Effect.Effect<\n Ref.Returns<MutationRef>,\n Ref.Error<MutationRef> | ParseResult.ParseError\n > =>\n Ref.runWithCodec(\n mutationRef,\n (args[0] ?? {}) as Ref.Args<MutationRef>,\n (functionReference, encodedArgs) =>\n this.testConvex.mutation(functionReference as any, encodedArgs),\n );\n\n readonly action = <ActionRef extends Ref.AnyAction>(\n actionRef: ActionRef,\n ...args: Ref.OptionalArgs<ActionRef>\n ): Effect.Effect<\n Ref.Returns<ActionRef>,\n Ref.Error<ActionRef> | ParseResult.ParseError\n > =>\n Ref.runWithCodec(\n actionRef,\n (args[0] ?? {}) as Ref.Args<ActionRef>,\n (functionReference, encodedArgs) =>\n this.testConvex.action(functionReference as any, encodedArgs),\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.OptionalArgs<QueryRef>\n ) => this.testConfectImplWithoutIdentity.query(queryRef, ...args);\n\n readonly mutation = <MutationRef extends Ref.AnyMutation>(\n mutationRef: MutationRef,\n ...args: Ref.OptionalArgs<MutationRef>\n ) => this.testConfectImplWithoutIdentity.mutation(mutationRef, ...args);\n\n readonly action = <ActionRef extends Ref.AnyAction>(\n actionRef: ActionRef,\n ...args: Ref.OptionalArgs<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 convexSchemaDefinition: SchemaDefinition<GenericSchema, true>,\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(convexSchemaDefinition, modules) as any,\n ),\n );\n"],"mappings":";;;;;;;;;;;AA2EA,MAAa,oBAGX,QAAQ,WAAuC,4BAA4B;AAE7E,IAAM,iCAAN,MAEuD;CACrD,YACE,AAAQ,eACR,AAAQ,YAGR;EAJQ;EACA;;CAKV,AAAS,SACP,UACA,GAAG,SAKH,IAAI,aACF,UACC,KAAK,MAAM,EAAE,GACb,mBAAmB,gBAClB,KAAK,WAAW,MAAM,mBAA0B,YAAY,CAC/D;CAEH,AAAS,YACP,aACA,GAAG,SAKH,IAAI,aACF,aACC,KAAK,MAAM,EAAE,GACb,mBAAmB,gBAClB,KAAK,WAAW,SAAS,mBAA0B,YAAY,CAClE;CAEH,AAAS,UACP,WACA,GAAG,SAKH,IAAI,aACF,WACC,KAAK,MAAM,EAAE,GACb,mBAAmB,gBAClB,KAAK,WAAW,OAAO,mBAA0B,YAAY,CAChE;CAEH,AAAS,QAKP,SAKA,YACmE;EACnE,MAAM,qBACJ,gBAIA,yBAAyB,cACvB,KAAK,eACL,YACD;AAIH,SAAO,YAAY,SACf,OAAO,cACL,K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gBACA,wBACA,kBAGA,MAAM,KACJ,aAA8B,QAE5B,IAAI,gBACF,gBACA,WAAW,wBAAwB,QAAQ,CAC5C,CACJ"}
package/package.json CHANGED
@@ -1,25 +1,24 @@
1
1
  {
2
2
  "name": "@confect/test",
3
- "version": "9.0.0-next.5",
4
3
  "description": "Utilities for testing Confect apps without a live Convex backend",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/rjdellecese/confect.git"
8
- },
4
+ "version": "9.0.0-next.6",
5
+ "author": "RJ Dellecese",
9
6
  "bugs": {
10
7
  "url": "https://github.com/rjdellecese/confect/issues"
11
8
  },
12
- "homepage": "https://confect.dev",
13
- "sideEffects": false,
14
- "type": "module",
15
- "files": [
16
- "CHANGELOG.md",
17
- "LICENSE",
18
- "README.md",
19
- "dist",
20
- "package.json",
21
- "src"
22
- ],
9
+ "devDependencies": {
10
+ "@eslint/js": "10.0.1",
11
+ "@types/node": "25.3.3",
12
+ "effect": "3.21.2",
13
+ "eslint": "10.0.2",
14
+ "prettier": "3.8.1",
15
+ "tsdown": "0.20.3",
16
+ "typescript": "5.9.3",
17
+ "typescript-eslint": "8.56.1"
18
+ },
19
+ "engines": {
20
+ "node": ">=22"
21
+ },
23
22
  "exports": {
24
23
  ".": {
25
24
  "types": "./dist/index.d.ts",
@@ -32,44 +31,44 @@
32
31
  "./package.json": "./package.json",
33
32
  "./internal/*": null
34
33
  },
34
+ "files": [
35
+ "CHANGELOG.md",
36
+ "LICENSE",
37
+ "README.md",
38
+ "dist",
39
+ "package.json",
40
+ "src"
41
+ ],
42
+ "homepage": "https://confect.dev",
35
43
  "keywords": [
36
- "effect",
37
44
  "convex",
45
+ "effect",
38
46
  "testing"
39
47
  ],
40
- "author": "RJ Dellecese",
41
48
  "license": "ISC",
42
- "devDependencies": {
43
- "@eslint/js": "10.0.1",
44
- "@types/node": "25.3.3",
45
- "eslint": "10.0.2",
46
- "prettier": "3.8.1",
47
- "tsdown": "0.20.3",
48
- "typescript": "5.9.3",
49
- "typescript-eslint": "8.56.1",
50
- "effect": "3.21.2"
51
- },
49
+ "main": "./dist/index.js",
50
+ "module": "./dist/index.js",
52
51
  "peerDependencies": {
53
52
  "convex": "1.39.1",
54
53
  "convex-test": "^0.0.50",
55
54
  "effect": "^3.21.2",
56
- "@confect/core": "^9.0.0-next.5",
57
- "@confect/server": "^9.0.0-next.5"
55
+ "@confect/core": "^9.0.0-next.6",
56
+ "@confect/server": "^9.0.0-next.6"
58
57
  },
59
- "engines": {
60
- "node": ">=22",
61
- "pnpm": ">=10"
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "https://github.com/rjdellecese/confect.git"
62
61
  },
63
- "main": "./dist/index.js",
64
- "module": "./dist/index.js",
62
+ "sideEffects": false,
63
+ "type": "module",
65
64
  "types": "./dist/index.d.ts",
66
65
  "scripts": {
67
66
  "build": "tsdown --config-loader unrun",
67
+ "clean": "rm -rf dist coverage node_modules",
68
68
  "dev": "tsdown --watch",
69
- "typecheck": "tsc --noEmit --project tsconfig.json",
70
69
  "fix": "prettier --write . && eslint --fix . --max-warnings=0",
71
70
  "format": "prettier --check .",
72
71
  "lint": "eslint . --max-warnings=0",
73
- "clean": "rm -rf dist coverage node_modules"
72
+ "typecheck": "tsc --noEmit --project tsconfig.json"
74
73
  }
75
74
  }
@@ -6,7 +6,12 @@ import type {
6
6
  TestConvexForDataModelAndIdentity,
7
7
  } from "convex-test";
8
8
  import { convexTest } from "convex-test";
9
- import type { GenericMutationCtx, UserIdentity } from "convex/server";
9
+ import type {
10
+ GenericMutationCtx,
11
+ GenericSchema,
12
+ SchemaDefinition,
13
+ UserIdentity,
14
+ } from "convex/server";
10
15
  import type { Value } from "convex/values";
11
16
  import type { ParseResult } from "effect";
12
17
  import { Context, Effect, Layer, Schema } from "effect";
@@ -251,6 +256,7 @@ class TestConfectImpl<
251
256
  export const layer =
252
257
  <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(
253
258
  databaseSchema: DatabaseSchema_,
259
+ convexSchemaDefinition: SchemaDefinition<GenericSchema, true>,
254
260
  modules: Record<string, () => Promise<any>>,
255
261
  ) =>
256
262
  (): Layer.Layer<TestConfect<DatabaseSchema_>> =>
@@ -259,6 +265,6 @@ export const layer =
259
265
  () =>
260
266
  new TestConfectImpl(
261
267
  databaseSchema,
262
- convexTest(databaseSchema.convexSchemaDefinition, modules) as any,
268
+ convexTest(convexSchemaDefinition, modules) as any,
263
269
  ),
264
270
  );