@gaganref/confect-test 10.3.1-fork.71 → 10.3.1-fork.73

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.
@@ -1,4 +1,4 @@
1
- import { App, Ref } from "@confect/core";
1
+ import { App, type Mount, Ref } from "@confect/core";
2
2
  import type { DatabaseSchema } from "@confect/server";
3
3
  import { RegisteredConvexFunction } from "@confect/server";
4
4
  import type { TestConvexForDataModelAndIdentity } from "convex-test";
@@ -80,7 +80,7 @@ export type DeclaredApp<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> = R
80
80
  */
81
81
  export declare function layer<DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(app: DeclaredApp<DatabaseSchema_>): Layer.Layer<TestConfect<DatabaseSchema_>>;
82
82
  export declare function layer<A extends App.Any, DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(app: A, registry: Registry<DatabaseSchema_> & {
83
- readonly components: Readonly<Record<keyof NoInfer<A>["mounts"], Registry<DatabaseSchema_>["components"][string]>>;
83
+ readonly components: Readonly<Record<Mount.NameOf<NoInfer<A>["mounts"][number]>, Registry<DatabaseSchema_>["components"][string]>>;
84
84
  }): Layer.Layer<TestConfect<DatabaseSchema_>>;
85
85
  export declare function layer<DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(databaseSchema: DatabaseSchema_, convexSchemaDefinition: SchemaDefinition<GenericSchema, true>, modules: Record<string, () => Promise<any>>, options?: LayerOptions): Layer.Layer<TestConfect<DatabaseSchema_>>;
86
86
  //# sourceMappingURL=TestConfect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TestConfect.d.ts","sourceRoot":"","sources":["../src/TestConfect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,C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CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,EAC1C,QAAQ,CAAC,eAAe,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAChD,CACF,CAAC;CACH,GACA,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC;AAC7C,wBAAgB,KAAK,CAAC,eAAe,SAAS,cAAc,CAAC,YAAY,EACvE,cAAc,EAAE,eAAe,EAC/B,sBAAsB,EAAE,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,EAC7D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,EAC3C,OAAO,CAAC,EAAE,YAAY,GACrB,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"TestConfect.js","names":["MountedHttp.make"],"sources":["../src/TestConfect.ts"],"sourcesContent":["import { App, 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 GenericDataModel,\n GenericMutationCtx,\n GenericSchema,\n SchemaDefinition,\n UserIdentity,\n} from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport * as MountedHttp from \"./internal/MountedHttp.js\";\n\ndeclare const process: { env: Record<string, string | undefined> };\n\n/**\n * Register a component's Convex schema and modules at its installation path.\n */\nexport type RegisterComponent = (\n ...args: Parameters<\n TestConvexForDataModelAndIdentity<GenericDataModel>[\"registerComponent\"]\n >\n) => void;\n\n/**\n * An installed component path and the HTTP prefix exposed by its host.\n */\nexport type HttpMount = {\n readonly componentPath: string;\n readonly httpPrefix: string;\n};\n\nexport type LayerOptions = {\n /**\n * Register component kits synchronously before the test service is available.\n */\n readonly register?: (registerComponent: RegisterComponent) => void;\n /**\n * Explicit HTTP mounts. The test layer does not evaluate convex.config.ts.\n */\n readonly httpMounts?: ReadonlyArray<HttpMount>;\n};\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> | Schema.SchemaError\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> | Schema.SchemaError\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> | Schema.SchemaError\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.Codec<A, B>,\n ): Effect.Effect<A, Schema.SchemaError>;\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 registerComponent: (\n componentPath: string,\n schema: SchemaDefinition<GenericSchema, boolean>,\n modules: Record<string, () => Promise<any>>,\n ) => Effect.Effect<void>;\n withIdentity: (\n userIdentity: Partial<UserIdentity>,\n ) => TestConfectWithoutIdentity<ConfectSchema>;\n} & TestConfectWithoutIdentity<ConfectSchema>;\n\nexport const TestConfect = <\n ConfectSchema extends DatabaseSchema.AnyWithProps,\n>() => Context.Service<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 private mountedHttp: ReturnType<typeof MountedHttp.make>,\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> | Schema.SchemaError\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> | Schema.SchemaError\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> | Schema.SchemaError\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.Codec<A, B>,\n ): Effect.Effect<void> | Effect.Effect<A, Schema.SchemaError> => {\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.encodeEffect(returns)),\n Effect.provide(makeMutationLayer(mutationCtx)),\n ),\n ),\n ),\n ).pipe(Effect.andThen(Schema.decodeEffect(returns)));\n }) as TestConfectWithoutIdentity<ConfectSchema>[\"run\"];\n\n readonly fetch = <PathQueryFragment extends string>(\n pathQueryFragment: PathQueryFragment,\n init?: RequestInit,\n ) =>\n Effect.promise(() =>\n this.mountedHttp.fetch(this.testConvex, pathQueryFragment, init),\n );\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 private mountedHttp: ReturnType<typeof MountedHttp.make>,\n ) {\n this.testConfectImplWithoutIdentity = new TestConfectImplWithoutIdentity(\n confectSchema,\n testConvex,\n mountedHttp,\n );\n }\n\n readonly withIdentity = (userIdentity: Partial<UserIdentity>) =>\n new TestConfectImplWithoutIdentity(\n this.confectSchema,\n this.testConvex.withIdentity(userIdentity),\n this.mountedHttp,\n );\n\n readonly registerComponent: TestConfect<ConfectSchema>[\"registerComponent\"] =\n Effect.fn(\"TestConfect.registerComponent\")(\n (componentPath, schema, modules) =>\n Effect.sync(() =>\n this.mountedHttp.register(componentPath, schema, modules),\n ),\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\n/**\n * How a test registers one installed component: its own schema and modules, or\n * the `register(t, name)` a component package exports from `<package>/testing`\n * or `<package>/test`, which also registers the package's own children.\n */\nexport type ComponentKit =\n | {\n readonly schema: SchemaDefinition<GenericSchema, boolean>;\n readonly modules: Record<string, () => Promise<any>>;\n }\n | {\n register(\n t: { readonly registerComponent: RegisterComponent },\n name: string,\n ): unknown;\n };\n\nclass InvalidComponentKit extends Schema.TaggedError<InvalidComponentKit>()(\n \"InvalidComponentKit\",\n { componentPath: Schema.String, message: Schema.String },\n) {}\n\nconst registerKit = (\n registerComponent: RegisterComponent,\n name: string,\n kit: ComponentKit,\n) => {\n if (\"register\" in kit) {\n kit.register({ registerComponent }, name);\n } else if (\"schema\" in kit && \"modules\" in kit) {\n registerComponent(name, kit.schema, kit.modules);\n } else {\n // Codegen accepts a kit whose exports it cannot list, such as CommonJS.\n throw new InvalidComponentKit({\n componentPath: name,\n message: `The test kit for ${JSON.stringify(name)} must export register(t, name), or schema and modules.`,\n });\n }\n};\n\n/**\n * Codegen's test-only schema and module registry.\n */\nexport type Registry<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> = {\n readonly schema: DatabaseSchema_;\n readonly convexSchema: SchemaDefinition<GenericSchema, true>;\n readonly modules: Record<string, () => Promise<any>>;\n readonly components: Readonly<Record<string, ComponentKit>>;\n};\n\n/**\n * The declared app's generated, test-only representation.\n */\nexport type DeclaredApp<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> =\n Registry<DatabaseSchema_> & {\n readonly httpMounts: ReadonlyArray<HttpMount>;\n };\n\n/**\n * Build a fresh test backend from a declaration and its generated\n * `confect/_generated/testing` registry, without restating component mounts.\n */\nexport function layer<DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n app: DeclaredApp<DatabaseSchema_>,\n): Layer.Layer<TestConfect<DatabaseSchema_>>;\nexport function layer<\n A extends App.Any,\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n>(\n app: A,\n registry: Registry<DatabaseSchema_> & {\n readonly components: Readonly<\n Record<\n keyof NoInfer<A>[\"mounts\"],\n Registry<DatabaseSchema_>[\"components\"][string]\n >\n >;\n },\n): Layer.Layer<TestConfect<DatabaseSchema_>>;\nexport function layer<DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n databaseSchema: DatabaseSchema_,\n convexSchemaDefinition: SchemaDefinition<GenericSchema, true>,\n modules: Record<string, () => Promise<any>>,\n options?: LayerOptions,\n): Layer.Layer<TestConfect<DatabaseSchema_>>;\nexport function layer<DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n appOrSchema: App.Any | DeclaredApp<DatabaseSchema_> | DatabaseSchema_,\n registryOrSchema?:\n | Registry<DatabaseSchema_>\n | SchemaDefinition<GenericSchema, true>,\n modules?: Record<string, () => Promise<any>>,\n options: LayerOptions = {},\n): Layer.Layer<TestConfect<DatabaseSchema_>> {\n if (App.isApp(appOrSchema)) {\n const registry = registryOrSchema as Registry<DatabaseSchema_>;\n const mounts = App.mounts(appOrSchema);\n return schemaLayer(\n registry.schema,\n registry.convexSchema,\n registry.modules,\n {\n httpMounts: mounts.flatMap(({ name, httpPrefix }) =>\n httpPrefix === undefined ? [] : [{ componentPath: name, httpPrefix }],\n ),\n register: (registerComponent) => {\n for (const [name, component] of Object.entries(registry.components)) {\n if (\n mounts.some(\n (mount) =>\n name === mount.name || name.startsWith(`${mount.name}/`),\n )\n ) {\n registerKit(registerComponent, name, component);\n }\n }\n },\n },\n );\n }\n if (\"httpMounts\" in appOrSchema) {\n const app = appOrSchema as DeclaredApp<DatabaseSchema_>;\n return schemaLayer(app.schema, app.convexSchema, app.modules, {\n httpMounts: app.httpMounts,\n register: (registerComponent) => {\n for (const [name, component] of Object.entries(app.components)) {\n registerKit(registerComponent, name, component);\n }\n },\n });\n }\n return schemaLayer(\n appOrSchema as DatabaseSchema_,\n registryOrSchema as SchemaDefinition<GenericSchema, true>,\n modules!,\n options,\n );\n}\n\nconst schemaLayer = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n databaseSchema: DatabaseSchema_,\n convexSchemaDefinition: SchemaDefinition<GenericSchema, true>,\n modules: Record<string, () => Promise<any>>,\n options: LayerOptions = {},\n): Layer.Layer<TestConfect<DatabaseSchema_>> =>\n Layer.sync(TestConfect<DatabaseSchema_>(), () => {\n process.env.CONVEX_CLOUD_URL ??= \"https://some-deployment.convex.cloud\";\n process.env.CONVEX_SITE_URL ??= \"https://some.convex.site\";\n const testConvex = convexTest(convexSchemaDefinition, modules);\n const mountedHttp = MountedHttp.make(options.httpMounts ?? [], (...args) =>\n testConvex.registerComponent(...args),\n );\n options.register?.(mountedHttp.register);\n return new TestConfectImpl(databaseSchema, testConvex as any, mountedHttp);\n });\n"],"mappings":";;;;;;;;;;;;;;AAkHA,MAAa,oBAEN,QAAQ,QAAoC,2BAA2B;AAE9E,IAAM,iCAAN,MAEuD;CAE3C;CACA;CAGA;CALV,YACE,eACA,YAGA,aACA;EALQ,KAAA,gBAAA;EACA,KAAA,aAAA;EAGA,KAAA,cAAA;CACP;CAEH,SACE,UACA,GAAG,SAKH,IAAI,aACF,UACC,KAAK,MAAM,CAAC,IACZ,mBAAmB,gBAClB,KAAK,WAAW,MAAM,mBAA0B,WAAW,CAC/D;CAEF,YACE,aACA,GAAG,SAKH,IAAI,aACF,aACC,KAAK,MAAM,CAAC,IACZ,mBAAmB,gBAClB,KAAK,WAAW,SAAS,mBAA0B,WAAW,CAClE;CAEF,UACE,WACA,GAAG,SAKH,IAAI,aACF,WACC,KAAK,MAAM,CAAC,IACZ,mBAAmB,gBAClB,KAAK,WAAW,OAAO,mBAA0B,WAAW,CAChE;CAEF,QAKE,SAKA,YAC+D;EAC/D,MAAM,qBACJ,gBAIA,yBAAyB,cACvB,KAAK,eACL,WACF;EAIF,OAAO,YAAY,KAAA,IACf,OAAO,cACL,KAAK,WAAW,KAAK,gBACnB,OAAO,WACL,QAAQ,KACN,OAAO,QACP,OAAO,QAAQ,kBAAkB,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AAO,YACL,aACA,kBACA,SACA,OACF;AACF;AAEA,MAAM,eACJ,gBACA,wBACA,SACA,UAAwB,CAAC,MAEzB,MAAM,KAAK,YAA6B,SAAS;CAC/C,QAAQ,IAAI,qBAAqB;CACjC,QAAQ,IAAI,oBAAoB;CAChC,MAAM,aAAa,WAAW,wBAAwB,OAAO;CAC7D,MAAM,cAAcA,KAAiB,QAAQ,cAAc,CAAC,IAAI,GAAG,SACjE,WAAW,kBAAkB,GAAG,IAAI,CACtC;CACA,QAAQ,WAAW,YAAY,QAAQ;CACvC,OAAO,IAAI,gBAAgB,gBAAgB,YAAmB,WAAW;AAC3E,CAAC"}
1
+ {"version":3,"file":"TestConfect.js","names":["MountedHttp.make"],"sources":["../src/TestConfect.ts"],"sourcesContent":["import { App, type Mount, 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 GenericDataModel,\n GenericMutationCtx,\n GenericSchema,\n SchemaDefinition,\n UserIdentity,\n} from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport * as MountedHttp from \"./internal/MountedHttp.js\";\n\ndeclare const process: { env: Record<string, string | undefined> };\n\n/**\n * Register a component's Convex schema and modules at its installation path.\n */\nexport type RegisterComponent = (\n ...args: Parameters<\n TestConvexForDataModelAndIdentity<GenericDataModel>[\"registerComponent\"]\n >\n) => void;\n\n/**\n * An installed component path and the HTTP prefix exposed by its host.\n */\nexport type HttpMount = {\n readonly componentPath: string;\n readonly httpPrefix: string;\n};\n\nexport type LayerOptions = {\n /**\n * Register component kits synchronously before the test service is available.\n */\n readonly register?: (registerComponent: RegisterComponent) => void;\n /**\n * Explicit HTTP mounts. The test layer does not evaluate convex.config.ts.\n */\n readonly httpMounts?: ReadonlyArray<HttpMount>;\n};\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> | Schema.SchemaError\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> | Schema.SchemaError\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> | Schema.SchemaError\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.Codec<A, B>,\n ): Effect.Effect<A, Schema.SchemaError>;\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 registerComponent: (\n componentPath: string,\n schema: SchemaDefinition<GenericSchema, boolean>,\n modules: Record<string, () => Promise<any>>,\n ) => Effect.Effect<void>;\n withIdentity: (\n userIdentity: Partial<UserIdentity>,\n ) => TestConfectWithoutIdentity<ConfectSchema>;\n} & TestConfectWithoutIdentity<ConfectSchema>;\n\nexport const TestConfect = <\n ConfectSchema extends DatabaseSchema.AnyWithProps,\n>() => Context.Service<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 private mountedHttp: ReturnType<typeof MountedHttp.make>,\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> | Schema.SchemaError\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> | Schema.SchemaError\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> | Schema.SchemaError\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.Codec<A, B>,\n ): Effect.Effect<void> | Effect.Effect<A, Schema.SchemaError> => {\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.encodeEffect(returns)),\n Effect.provide(makeMutationLayer(mutationCtx)),\n ),\n ),\n ),\n ).pipe(Effect.andThen(Schema.decodeEffect(returns)));\n }) as TestConfectWithoutIdentity<ConfectSchema>[\"run\"];\n\n readonly fetch = <PathQueryFragment extends string>(\n pathQueryFragment: PathQueryFragment,\n init?: RequestInit,\n ) =>\n Effect.promise(() =>\n this.mountedHttp.fetch(this.testConvex, pathQueryFragment, init),\n );\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 private mountedHttp: ReturnType<typeof MountedHttp.make>,\n ) {\n this.testConfectImplWithoutIdentity = new TestConfectImplWithoutIdentity(\n confectSchema,\n testConvex,\n mountedHttp,\n );\n }\n\n readonly withIdentity = (userIdentity: Partial<UserIdentity>) =>\n new TestConfectImplWithoutIdentity(\n this.confectSchema,\n this.testConvex.withIdentity(userIdentity),\n this.mountedHttp,\n );\n\n readonly registerComponent: TestConfect<ConfectSchema>[\"registerComponent\"] =\n Effect.fn(\"TestConfect.registerComponent\")(\n (componentPath, schema, modules) =>\n Effect.sync(() =>\n this.mountedHttp.register(componentPath, schema, modules),\n ),\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\n/**\n * How a test registers one installed component: its own schema and modules, or\n * the `register(t, name)` a component package exports from `<package>/testing`\n * or `<package>/test`, which also registers the package's own children.\n */\nexport type ComponentKit =\n | {\n readonly schema: SchemaDefinition<GenericSchema, boolean>;\n readonly modules: Record<string, () => Promise<any>>;\n }\n | {\n register(\n t: { readonly registerComponent: RegisterComponent },\n name: string,\n ): unknown;\n };\n\nclass InvalidComponentKit extends Schema.TaggedError<InvalidComponentKit>()(\n \"InvalidComponentKit\",\n { componentPath: Schema.String, message: Schema.String },\n) {}\n\nconst registerKit = (\n registerComponent: RegisterComponent,\n name: string,\n kit: ComponentKit,\n) => {\n if (\"register\" in kit) {\n kit.register({ registerComponent }, name);\n } else if (\"schema\" in kit && \"modules\" in kit) {\n registerComponent(name, kit.schema, kit.modules);\n } else {\n // Codegen accepts a kit whose exports it cannot list, such as CommonJS.\n throw new InvalidComponentKit({\n componentPath: name,\n message: `The test kit for ${JSON.stringify(name)} must export register(t, name), or schema and modules.`,\n });\n }\n};\n\n/**\n * Codegen's test-only schema and module registry.\n */\nexport type Registry<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> = {\n readonly schema: DatabaseSchema_;\n readonly convexSchema: SchemaDefinition<GenericSchema, true>;\n readonly modules: Record<string, () => Promise<any>>;\n readonly components: Readonly<Record<string, ComponentKit>>;\n};\n\n/**\n * The declared app's generated, test-only representation.\n */\nexport type DeclaredApp<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> =\n Registry<DatabaseSchema_> & {\n readonly httpMounts: ReadonlyArray<HttpMount>;\n };\n\n/**\n * Build a fresh test backend from a declaration and its generated\n * `confect/_generated/testing` registry, without restating component mounts.\n */\nexport function layer<DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n app: DeclaredApp<DatabaseSchema_>,\n): Layer.Layer<TestConfect<DatabaseSchema_>>;\nexport function layer<\n A extends App.Any,\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n>(\n app: A,\n registry: Registry<DatabaseSchema_> & {\n readonly components: Readonly<\n Record<\n Mount.NameOf<NoInfer<A>[\"mounts\"][number]>,\n Registry<DatabaseSchema_>[\"components\"][string]\n >\n >;\n },\n): Layer.Layer<TestConfect<DatabaseSchema_>>;\nexport function layer<DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n databaseSchema: DatabaseSchema_,\n convexSchemaDefinition: SchemaDefinition<GenericSchema, true>,\n modules: Record<string, () => Promise<any>>,\n options?: LayerOptions,\n): Layer.Layer<TestConfect<DatabaseSchema_>>;\nexport function layer<DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n appOrSchema: App.Any | DeclaredApp<DatabaseSchema_> | DatabaseSchema_,\n registryOrSchema?:\n | Registry<DatabaseSchema_>\n | SchemaDefinition<GenericSchema, true>,\n modules?: Record<string, () => Promise<any>>,\n options: LayerOptions = {},\n): Layer.Layer<TestConfect<DatabaseSchema_>> {\n if (App.isApp(appOrSchema)) {\n const registry = registryOrSchema as Registry<DatabaseSchema_>;\n const mounts = App.mounts(appOrSchema);\n return schemaLayer(\n registry.schema,\n registry.convexSchema,\n registry.modules,\n {\n httpMounts: mounts.flatMap(({ name, httpPrefix }) =>\n httpPrefix === undefined ? [] : [{ componentPath: name, httpPrefix }],\n ),\n register: (registerComponent) => {\n for (const [name, component] of Object.entries(registry.components)) {\n if (\n mounts.some(\n (mount) =>\n name === mount.name || name.startsWith(`${mount.name}/`),\n )\n ) {\n registerKit(registerComponent, name, component);\n }\n }\n },\n },\n );\n }\n if (\"httpMounts\" in appOrSchema) {\n const app = appOrSchema as DeclaredApp<DatabaseSchema_>;\n return schemaLayer(app.schema, app.convexSchema, app.modules, {\n httpMounts: app.httpMounts,\n register: (registerComponent) => {\n for (const [name, component] of Object.entries(app.components)) {\n registerKit(registerComponent, name, component);\n }\n },\n });\n }\n return schemaLayer(\n appOrSchema as DatabaseSchema_,\n registryOrSchema as SchemaDefinition<GenericSchema, true>,\n modules!,\n options,\n );\n}\n\nconst schemaLayer = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n databaseSchema: DatabaseSchema_,\n convexSchemaDefinition: SchemaDefinition<GenericSchema, true>,\n modules: Record<string, () => Promise<any>>,\n options: LayerOptions = {},\n): Layer.Layer<TestConfect<DatabaseSchema_>> =>\n Layer.sync(TestConfect<DatabaseSchema_>(), () => {\n process.env.CONVEX_CLOUD_URL ??= \"https://some-deployment.convex.cloud\";\n process.env.CONVEX_SITE_URL ??= \"https://some.convex.site\";\n const testConvex = convexTest(convexSchemaDefinition, modules);\n const mountedHttp = MountedHttp.make(options.httpMounts ?? [], (...args) =>\n testConvex.registerComponent(...args),\n );\n options.register?.(mountedHttp.register);\n return new TestConfectImpl(databaseSchema, testConvex as any, mountedHttp);\n });\n"],"mappings":";;;;;;;;;;;;;;AAkHA,MAAa,oBAEN,QAAQ,QAAoC,2BAA2B;AAE9E,IAAM,iCAAN,MAEuD;CAE3C;CACA;CAGA;CALV,YACE,eACA,YAGA,aACA;EALQ,KAAA,gBAAA;EACA,KAAA,aAAA;EAGA,KAAA,cAAA;CACP;CAEH,SACE,UACA,GAAG,SAKH,IAAI,aACF,UACC,KAAK,MAAM,CAAC,IACZ,mBAAmB,gBAClB,KAAK,WAAW,MAAM,mBAA0B,WAAW,CAC/D;CAEF,YACE,aACA,GAAG,SAKH,IAAI,aACF,aACC,KAAK,MAAM,CAAC,IACZ,mBAAmB,gBAClB,KAAK,WAAW,SAAS,mBAA0B,WAAW,CAClE;CAEF,UACE,WACA,GAAG,SAKH,IAAI,aACF,WACC,KAAK,MAAM,CAAC,IACZ,mBAAmB,gBAClB,KAAK,WAAW,OAAO,mBAA0B,WAAW,CAChE;CAEF,QAKE,SAKA,YAC+D;EAC/D,MAAM,qBACJ,gBAIA,yBAAyB,cACvB,KAAK,eACL,WACF;EAIF,OAAO,YAAY,KAAA,IACf,OAAO,cACL,KAAK,WAAW,KAAK,gBACnB,OAAO,WACL,QAAQ,KACN,OAAO,QACP,OAAO,QAAQ,kBAAkB,WAAW,CAAC,CAC/C,CACF,CACF,CACF,IACA,OAAO,cACL,KAAK,WAAW,KAAK,gBACnB,OAAO,WACL,QAAQ,KACN,OAAO,QAAQ,OAAO,a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C/C,QAAQ,IAAI,qBAAqB;CACjC,QAAQ,IAAI,oBAAoB;CAChC,MAAM,aAAa,WAAW,wBAAwB,OAAO;CAC7D,MAAM,cAAcA,KAAiB,QAAQ,cAAc,CAAC,IAAI,GAAG,SACjE,WAAW,kBAAkB,GAAG,IAAI,CACtC;CACA,QAAQ,WAAW,YAAY,QAAQ;CACvC,OAAO,IAAI,gBAAgB,gBAAgB,YAAmB,WAAW;AAC3E,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@gaganref/confect-test",
3
- "version": "10.3.1-fork.71",
3
+ "version": "10.3.1-fork.73",
4
4
  "peerDependencies": {
5
- "@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.71",
6
- "@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.71",
5
+ "@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.73",
6
+ "@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.73",
7
7
  "convex": "^1.32.0",
8
8
  "convex-test": ">=0.0.65 <0.1.0",
9
9
  "effect": ">=4.0.0 <4.1.0"
@@ -1,4 +1,4 @@
1
- import { App, Ref } from "@confect/core";
1
+ import { App, type Mount, Ref } from "@confect/core";
2
2
  import type { DatabaseSchema, DataModel } from "@confect/server";
3
3
  import { RegisteredConvexFunction } from "@confect/server";
4
4
  import type {
@@ -378,7 +378,7 @@ export function layer<
378
378
  registry: Registry<DatabaseSchema_> & {
379
379
  readonly components: Readonly<
380
380
  Record<
381
- keyof NoInfer<A>["mounts"],
381
+ Mount.NameOf<NoInfer<A>["mounts"][number]>,
382
382
  Registry<DatabaseSchema_>["components"][string]
383
383
  >
384
384
  >;