@gaganref/confect-test 0.0.0-stage → 10.3.1-fork.2
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 +1501 -0
- package/LICENSE +7 -0
- package/README.md +16 -2
- package/dist/TestConfect.d.ts +76 -0
- package/dist/TestConfect.d.ts.map +1 -0
- package/dist/TestConfect.js +91 -0
- package/dist/TestConfect.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/MountedHttp.d.ts +8 -0
- package/dist/internal/MountedHttp.d.ts.map +1 -0
- package/dist/internal/MountedHttp.js +151 -0
- package/dist/internal/MountedHttp.js.map +1 -0
- package/package.json +57 -3
- package/src/TestConfect.ts +422 -0
- package/src/index.ts +1 -0
- package/src/internal/MountedHttp.ts +266 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright 2024 RJ Dellecese
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Confect 🧁
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This is a fork of [Confect](https://github.com/rjdellecese/confect). See [FORK.md](FORK.md) for builds, installation, and maintenance, and [CHANGES.md](CHANGES.md) for the fork additions.
|
|
4
|
+
|
|
5
|
+
## About Confect
|
|
6
|
+
|
|
7
|
+
Confect is a framework that deeply integrates Effect with Convex. It's more than just Effect bindings! Confect allows you to:
|
|
8
|
+
|
|
9
|
+
- Define your Convex database schema using Effect schemas.
|
|
10
|
+
- Write Convex function args and returns validators using Effect's schema library.
|
|
11
|
+
- Use Confect functions to automatically decode and encode your data according to your Effect schema definitions for end-to-end rich types, from client to function to database (and back).
|
|
12
|
+
- Add reusable, type-safe middleware to function groups or individual functions to provide Effect services and run logic around handlers.
|
|
13
|
+
- Declare typed errors on functions and middleware using Effect schemas, then handle the decoded errors at every call site.
|
|
14
|
+
- Use Effect's native HTTP API modules to define your HTTP API.
|
|
15
|
+
- Access Convex platform capabilities via Effect services.
|
|
16
|
+
|
|
17
|
+
Want to learn more? Read the [docs](https://confect.dev)!
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { App, Ref } from "@confect/core";
|
|
2
|
+
import type { DatabaseSchema } from "@confect/server";
|
|
3
|
+
import { RegisteredConvexFunction } from "@confect/server";
|
|
4
|
+
import type { TestConvexForDataModelAndIdentity } from "convex-test";
|
|
5
|
+
import type { GenericDataModel, GenericSchema, SchemaDefinition, UserIdentity } from "convex/server";
|
|
6
|
+
import type { Value } from "convex/values";
|
|
7
|
+
import * as Context from "effect/Context";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Layer from "effect/Layer";
|
|
10
|
+
import * as Schema from "effect/Schema";
|
|
11
|
+
/**
|
|
12
|
+
* Register a component's Convex schema and modules at its installation path.
|
|
13
|
+
*/
|
|
14
|
+
export type RegisterComponent = TestConvexForDataModelAndIdentity<GenericDataModel>["registerComponent"];
|
|
15
|
+
/**
|
|
16
|
+
* An installed component path and the HTTP prefix exposed by its host.
|
|
17
|
+
*/
|
|
18
|
+
export type HttpMount = {
|
|
19
|
+
readonly componentPath: string;
|
|
20
|
+
readonly httpPrefix: string;
|
|
21
|
+
};
|
|
22
|
+
export type LayerOptions = {
|
|
23
|
+
/**
|
|
24
|
+
* Register component kits synchronously before the test service is available.
|
|
25
|
+
*/
|
|
26
|
+
readonly register?: (registerComponent: RegisterComponent) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Explicit HTTP mounts. The test layer does not evaluate convex.config.ts.
|
|
29
|
+
*/
|
|
30
|
+
readonly httpMounts?: ReadonlyArray<HttpMount>;
|
|
31
|
+
};
|
|
32
|
+
export type TestConfectWithoutIdentity<ConfectSchema extends DatabaseSchema.AnyWithProps> = {
|
|
33
|
+
query: <QueryRef extends Ref.AnyQuery>(queryRef: QueryRef, ...args: Ref.OptionalArgs<QueryRef>) => Effect.Effect<Ref.Returns<QueryRef>, Ref.Error<QueryRef> | Schema.SchemaError>;
|
|
34
|
+
mutation: <MutationRef extends Ref.AnyMutation>(mutationRef: MutationRef, ...args: Ref.OptionalArgs<MutationRef>) => Effect.Effect<Ref.Returns<MutationRef>, Ref.Error<MutationRef> | Schema.SchemaError>;
|
|
35
|
+
action: <ActionRef extends Ref.AnyAction>(actionRef: ActionRef, ...args: Ref.OptionalArgs<ActionRef>) => Effect.Effect<Ref.Returns<ActionRef>, Ref.Error<ActionRef> | Schema.SchemaError>;
|
|
36
|
+
run: {
|
|
37
|
+
<E>(handler: Effect.Effect<void, E, RegisteredConvexFunction.MutationServices<ConfectSchema>>): Effect.Effect<void>;
|
|
38
|
+
<A, B extends Value, E>(handler: Effect.Effect<A, E, RegisteredConvexFunction.MutationServices<ConfectSchema>>, returns: Schema.Codec<A, B>): Effect.Effect<A, Schema.SchemaError>;
|
|
39
|
+
};
|
|
40
|
+
fetch: (pathQueryFragment: string, init?: RequestInit) => Effect.Effect<Response>;
|
|
41
|
+
finishInProgressScheduledFunctions: () => Effect.Effect<void>;
|
|
42
|
+
finishAllScheduledFunctions: (advanceTimers: () => void) => Effect.Effect<void>;
|
|
43
|
+
};
|
|
44
|
+
export type TestConfect<ConfectSchema extends DatabaseSchema.AnyWithProps> = {
|
|
45
|
+
registerComponent: (componentPath: string, schema: SchemaDefinition<GenericSchema, boolean>, modules: Record<string, () => Promise<any>>) => Effect.Effect<void>;
|
|
46
|
+
withIdentity: (userIdentity: Partial<UserIdentity>) => TestConfectWithoutIdentity<ConfectSchema>;
|
|
47
|
+
} & TestConfectWithoutIdentity<ConfectSchema>;
|
|
48
|
+
export declare const TestConfect: <ConfectSchema extends DatabaseSchema.AnyWithProps>() => Context.Service<TestConfect<ConfectSchema>, TestConfect<ConfectSchema>>;
|
|
49
|
+
/**
|
|
50
|
+
* Codegen's test-only schema and module registry.
|
|
51
|
+
*/
|
|
52
|
+
export type Registry<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> = {
|
|
53
|
+
readonly schema: DatabaseSchema_;
|
|
54
|
+
readonly convexSchema: SchemaDefinition<GenericSchema, true>;
|
|
55
|
+
readonly modules: Record<string, () => Promise<any>>;
|
|
56
|
+
readonly components: Readonly<Record<string, {
|
|
57
|
+
readonly schema: SchemaDefinition<GenericSchema, boolean>;
|
|
58
|
+
readonly modules: Record<string, () => Promise<any>>;
|
|
59
|
+
}>>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The declared app's generated, test-only representation.
|
|
63
|
+
*/
|
|
64
|
+
export type DeclaredApp<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> = Registry<DatabaseSchema_> & {
|
|
65
|
+
readonly httpMounts: ReadonlyArray<HttpMount>;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Build a fresh test backend from a declaration and its generated
|
|
69
|
+
* `confect/_generated/testing` registry, without restating component mounts.
|
|
70
|
+
*/
|
|
71
|
+
export declare function layer<DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(app: DeclaredApp<DatabaseSchema_>): Layer.Layer<TestConfect<DatabaseSchema_>>;
|
|
72
|
+
export declare function layer<A extends App.Any, DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(app: A, registry: Registry<DatabaseSchema_> & {
|
|
73
|
+
readonly components: Readonly<Record<keyof NoInfer<A>["mounts"], Registry<DatabaseSchema_>["components"][string]>>;
|
|
74
|
+
}): Layer.Layer<TestConfect<DatabaseSchema_>>;
|
|
75
|
+
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_>>;
|
|
76
|
+
//# sourceMappingURL=TestConfect.d.ts.map
|
|
@@ -0,0 +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,CAAC;AAC3D,OAAO,KAAK,EAEV,iCAAiC,EAClC,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EACV,gBAAgB,EAEhB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAC3B,iCAAiC,CAAC,gBAAgB,CAAC,CAAC,mB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,QAAQ,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG;IACpC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAC3B,MAAM,CACJ,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAC1B,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"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { make } from "./internal/MountedHttp.js";
|
|
3
|
+
import { App, Ref } from "@confect/core";
|
|
4
|
+
import { RegisteredConvexFunction } from "@confect/server";
|
|
5
|
+
import { convexTest } from "convex-test";
|
|
6
|
+
import * as Context from "effect/Context";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Layer from "effect/Layer";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
//#region src/TestConfect.ts
|
|
11
|
+
var TestConfect_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
TestConfect: () => TestConfect,
|
|
13
|
+
layer: () => layer
|
|
14
|
+
});
|
|
15
|
+
const TestConfect = () => Context.Service("@confect/test/TestConfect");
|
|
16
|
+
var TestConfectImplWithoutIdentity = class {
|
|
17
|
+
confectSchema;
|
|
18
|
+
testConvex;
|
|
19
|
+
mountedHttp;
|
|
20
|
+
constructor(confectSchema, testConvex, mountedHttp) {
|
|
21
|
+
this.confectSchema = confectSchema;
|
|
22
|
+
this.testConvex = testConvex;
|
|
23
|
+
this.mountedHttp = mountedHttp;
|
|
24
|
+
}
|
|
25
|
+
query = (queryRef, ...args) => Ref.runWithCodec(queryRef, args[0] ?? {}, (functionReference, encodedArgs) => this.testConvex.query(functionReference, encodedArgs));
|
|
26
|
+
mutation = (mutationRef, ...args) => Ref.runWithCodec(mutationRef, args[0] ?? {}, (functionReference, encodedArgs) => this.testConvex.mutation(functionReference, encodedArgs));
|
|
27
|
+
action = (actionRef, ...args) => Ref.runWithCodec(actionRef, args[0] ?? {}, (functionReference, encodedArgs) => this.testConvex.action(functionReference, encodedArgs));
|
|
28
|
+
run = ((handler, returns) => {
|
|
29
|
+
const makeMutationLayer = (mutationCtx) => RegisteredConvexFunction.mutationLayer(this.confectSchema, mutationCtx);
|
|
30
|
+
return returns === void 0 ? Effect.promise(() => this.testConvex.run((mutationCtx) => Effect.runPromise(handler.pipe(Effect.asVoid, Effect.provide(makeMutationLayer(mutationCtx)))))) : Effect.promise(() => this.testConvex.run((mutationCtx) => Effect.runPromise(handler.pipe(Effect.andThen(Schema.encodeEffect(returns)), Effect.provide(makeMutationLayer(mutationCtx)))))).pipe(Effect.andThen(Schema.decodeEffect(returns)));
|
|
31
|
+
});
|
|
32
|
+
fetch = (pathQueryFragment, init) => Effect.promise(() => this.mountedHttp.fetch(this.testConvex, pathQueryFragment, init));
|
|
33
|
+
finishInProgressScheduledFunctions = () => Effect.promise(() => this.testConvex.finishInProgressScheduledFunctions());
|
|
34
|
+
finishAllScheduledFunctions = (advanceTimers) => Effect.promise(() => this.testConvex.finishAllScheduledFunctions(advanceTimers));
|
|
35
|
+
};
|
|
36
|
+
var TestConfectImpl = class {
|
|
37
|
+
confectSchema;
|
|
38
|
+
testConvex;
|
|
39
|
+
mountedHttp;
|
|
40
|
+
testConfectImplWithoutIdentity;
|
|
41
|
+
constructor(confectSchema, testConvex, mountedHttp) {
|
|
42
|
+
this.confectSchema = confectSchema;
|
|
43
|
+
this.testConvex = testConvex;
|
|
44
|
+
this.mountedHttp = mountedHttp;
|
|
45
|
+
this.testConfectImplWithoutIdentity = new TestConfectImplWithoutIdentity(confectSchema, testConvex, mountedHttp);
|
|
46
|
+
}
|
|
47
|
+
withIdentity = (userIdentity) => new TestConfectImplWithoutIdentity(this.confectSchema, this.testConvex.withIdentity(userIdentity), this.mountedHttp);
|
|
48
|
+
registerComponent = Effect.fn("TestConfect.registerComponent")((componentPath, schema, modules) => Effect.sync(() => this.mountedHttp.register(componentPath, schema, modules)));
|
|
49
|
+
query = (queryRef, ...args) => this.testConfectImplWithoutIdentity.query(queryRef, ...args);
|
|
50
|
+
mutation = (mutationRef, ...args) => this.testConfectImplWithoutIdentity.mutation(mutationRef, ...args);
|
|
51
|
+
action = (actionRef, ...args) => this.testConfectImplWithoutIdentity.action(actionRef, ...args);
|
|
52
|
+
run = ((handler, returns) => this.testConfectImplWithoutIdentity.run(handler, returns));
|
|
53
|
+
fetch = (pathQueryFragment, init) => this.testConfectImplWithoutIdentity.fetch(pathQueryFragment, init);
|
|
54
|
+
finishInProgressScheduledFunctions = () => this.testConfectImplWithoutIdentity.finishInProgressScheduledFunctions();
|
|
55
|
+
finishAllScheduledFunctions = (advanceTimers) => this.testConfectImplWithoutIdentity.finishAllScheduledFunctions(advanceTimers);
|
|
56
|
+
};
|
|
57
|
+
function layer(appOrSchema, registryOrSchema, modules, options = {}) {
|
|
58
|
+
if (App.isApp(appOrSchema)) {
|
|
59
|
+
const registry = registryOrSchema;
|
|
60
|
+
const mounts = App.mounts(appOrSchema);
|
|
61
|
+
return schemaLayer(registry.schema, registry.convexSchema, registry.modules, {
|
|
62
|
+
httpMounts: mounts.flatMap(({ name, httpPrefix }) => httpPrefix === void 0 ? [] : [{
|
|
63
|
+
componentPath: name,
|
|
64
|
+
httpPrefix
|
|
65
|
+
}]),
|
|
66
|
+
register: (registerComponent) => {
|
|
67
|
+
for (const [name, component] of Object.entries(registry.components)) if (mounts.some((mount) => name === mount.name || name.startsWith(`${mount.name}/`))) registerComponent(name, component.schema, component.modules);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if ("httpMounts" in appOrSchema) {
|
|
72
|
+
const app = appOrSchema;
|
|
73
|
+
return schemaLayer(app.schema, app.convexSchema, app.modules, {
|
|
74
|
+
httpMounts: app.httpMounts,
|
|
75
|
+
register: (registerComponent) => {
|
|
76
|
+
for (const [name, component] of Object.entries(app.components)) registerComponent(name, component.schema, component.modules);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return schemaLayer(appOrSchema, registryOrSchema, modules, options);
|
|
81
|
+
}
|
|
82
|
+
const schemaLayer = (databaseSchema, convexSchemaDefinition, modules, options = {}) => Layer.sync(TestConfect(), () => {
|
|
83
|
+
const testConvex = convexTest(convexSchemaDefinition, modules);
|
|
84
|
+
const mountedHttp = make(options.httpMounts ?? [], (...args) => testConvex.registerComponent(...args));
|
|
85
|
+
options.register?.(mountedHttp.register);
|
|
86
|
+
return new TestConfectImpl(databaseSchema, testConvex, mountedHttp);
|
|
87
|
+
});
|
|
88
|
+
//#endregion
|
|
89
|
+
export { TestConfect, TestConfect_exports, layer };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=TestConfect.js.map
|
|
@@ -0,0 +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\";\n\n/**\n * Register a component's Convex schema and modules at its installation path.\n */\nexport type RegisterComponent =\n TestConvexForDataModelAndIdentity<GenericDataModel>[\"registerComponent\"];\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 * 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<\n Record<\n string,\n {\n readonly schema: SchemaDefinition<GenericSchema, boolean>;\n readonly modules: Record<string, () => Promise<any>>;\n }\n >\n >;\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 registerComponent(name, component.schema, component.modules);\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 registerComponent(name, component.schema, component.modules);\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 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":";;;;;;;;;;;;;;AA6GA,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,aAAa,OAAO,CAAC,GAC3C,OAAO,QAAQ,kBAAkB,WAAW,CAAC,CAC/C,CACF,CACF,CACF,CAAC,CAAC,KAAK,OAAO,QAAQ,OAAO,aAAa,OAAO,CAAC,CAAC;CACzD;CAEA,SACE,mBACA,SAEA,OAAO,cACL,KAAK,YAAY,MAAM,KAAK,YAA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AAW,CAAC,CACtE;GACA,WAAW,sBAAsB;IAC/B,KAAK,MAAM,CAAC,MAAM,cAAc,OAAO,QAAQ,SAAS,UAAU,GAChE,IACE,OAAO,MACJ,UACC,SAAS,MAAM,QAAQ,KAAK,WAAW,GAAG,MAAM,KAAK,EAAE,CAC3D,GAEA,kBAAkB,MAAM,UAAU,QAAQ,UAAU,OAAO;GAGjE;EACF,CACF;CACF;CACA,IAAI,gBAAgB,aAAa;EAC/B,MAAM,MAAM;EACZ,OAAO,YAAY,IAAI,QAAQ,IAAI,cAAc,IAAI,SAAS;GAC5D,YAAY,IAAI;GAChB,WAAW,sBAAsB;IAC/B,KAAK,MAAM,CAAC,MAAM,cAAc,OAAO,QAAQ,IAAI,UAAU,GAC3D,kBAAkB,MAAM,UAAU,QAAQ,UAAU,OAAO;GAE/D;EACF,CAAC;CACH;CACA,OAAO,YACL,aACA,kBACA,SACA,OACF;AACF;AAEA,MAAM,eACJ,gBACA,wBACA,SACA,UAAwB,CAAC,MAEzB,MAAM,KAAK,YAA6B,SAAS;CAC/C,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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TestConfect_exports as TestConfect } from "./TestConfect.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TestConvexForDataModel } from "convex-test";
|
|
2
|
+
import type { GenericDataModel } from "convex/server";
|
|
3
|
+
import type { HttpMount, RegisterComponent } from "../TestConfect";
|
|
4
|
+
export declare const make: (mounts: ReadonlyArray<HttpMount>, registerComponent: RegisterComponent) => {
|
|
5
|
+
register: (componentPath: string, schema: import("convex/server").SchemaDefinition<import("convex/server").GenericSchema, boolean>, glob: Record<string, () => Promise<any>>) => void;
|
|
6
|
+
fetch: <DataModel extends GenericDataModel>(accessor: TestConvexForDataModel<DataModel>, path: string, init?: RequestInit) => Promise<Response>;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=MountedHttp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MountedHttp.d.ts","sourceRoot":"","sources":["../../src/internal/MountedHttp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EACV,gBAAgB,EAKjB,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAmFnE,eAAO,MAAM,IAAI,WACP,aAAa,CAAC,SAAS,CAAC,qBACb,iBAAiB;;YAoGrB,SAAS,SAAS,gBAAgB,YACrC,sBAAsB,CAAC,SAAS,CAAC,QACrC,MAAM,SACL,WAAW,KACjB,OAAO,CAAC,QAAQ,CAAC;CAgErB,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import { actionGeneric } from "convex/server";
|
|
3
|
+
import * as Result from "effect/Result";
|
|
4
|
+
//#region src/internal/MountedHttp.ts
|
|
5
|
+
var InvalidHttpMount = class extends Schema.TaggedError()("InvalidHttpMount", {
|
|
6
|
+
componentPath: Schema.String,
|
|
7
|
+
httpPrefix: Schema.String,
|
|
8
|
+
message: Schema.String
|
|
9
|
+
}) {};
|
|
10
|
+
var ComponentHttpError = class extends Schema.TaggedError()("ComponentHttpError", {
|
|
11
|
+
componentPath: Schema.String,
|
|
12
|
+
message: Schema.String
|
|
13
|
+
}) {};
|
|
14
|
+
var InvalidFetchPath = class extends Schema.TaggedError()("InvalidFetchPath", {
|
|
15
|
+
path: Schema.String,
|
|
16
|
+
message: Schema.String
|
|
17
|
+
}) {};
|
|
18
|
+
const normalizeMounts = (mounts) => {
|
|
19
|
+
const normalized = [];
|
|
20
|
+
for (const mount of mounts) {
|
|
21
|
+
if (!mount.httpPrefix.startsWith("/") || /[?#]/.test(mount.httpPrefix)) return Result.fail(new InvalidHttpMount({
|
|
22
|
+
...mount,
|
|
23
|
+
message: "httpPrefix must be an absolute path without a query or fragment."
|
|
24
|
+
}));
|
|
25
|
+
const prefix = mount.httpPrefix.replace(/\/+$/, "");
|
|
26
|
+
if (normalized.some((previous) => previous.prefix === prefix)) return Result.fail(new InvalidHttpMount({
|
|
27
|
+
...mount,
|
|
28
|
+
message: "Each httpPrefix must select one component installation."
|
|
29
|
+
}));
|
|
30
|
+
normalized.push({
|
|
31
|
+
componentPath: mount.componentPath,
|
|
32
|
+
prefix
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return Result.succeed(normalized.sort((a, b) => b.prefix.length - a.prefix.length));
|
|
36
|
+
};
|
|
37
|
+
const isInvokable = (action) => "invokeHttpAction" in action && typeof action.invokeHttpAction === "function";
|
|
38
|
+
const bridgeModule = "__confect_test_http";
|
|
39
|
+
const defaultSiteUrl = "https://some.convex.site";
|
|
40
|
+
const make = (mounts, registerComponent) => {
|
|
41
|
+
const normalized = normalizeMounts(mounts);
|
|
42
|
+
if (Result.isFailure(normalized)) throw normalized.failure;
|
|
43
|
+
const registered = /* @__PURE__ */ new Set();
|
|
44
|
+
let tail = Promise.resolve();
|
|
45
|
+
const register = (componentPath, schema, modules) => {
|
|
46
|
+
if (!normalized.success.some((mount) => mount.componentPath === componentPath)) {
|
|
47
|
+
registerComponent(componentPath, schema, modules);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const root = Object.keys(modules).find((key) => key.includes("_generated"))?.split("_generated", 2)[0];
|
|
51
|
+
const moduleLoaders = Object.fromEntries(Object.entries(modules).map(([path, load]) => [path.replace(/\.[^.]+$/, ""), load]));
|
|
52
|
+
const loadHttp = root === void 0 ? void 0 : moduleLoaders[`${root}http`];
|
|
53
|
+
if (root === void 0 || loadHttp === void 0) throw new ComponentHttpError({
|
|
54
|
+
componentPath,
|
|
55
|
+
message: "Mounted components need an HTTP module and Convex _generated modules."
|
|
56
|
+
});
|
|
57
|
+
const bridgePath = `${root}${bridgeModule}.ts`;
|
|
58
|
+
if (`${root}${bridgeModule}` in moduleLoaders) throw new ComponentHttpError({
|
|
59
|
+
componentPath,
|
|
60
|
+
message: `${bridgeModule} is reserved for mounted HTTP tests.`
|
|
61
|
+
});
|
|
62
|
+
const routers = /* @__PURE__ */ new Map();
|
|
63
|
+
const invoke = actionGeneric({ handler: async (_ctx, args) => {
|
|
64
|
+
const previousSiteUrl = process.env.CONVEX_SITE_URL;
|
|
65
|
+
try {
|
|
66
|
+
process.env.CONVEX_SITE_URL = args.siteUrl;
|
|
67
|
+
let router = routers.get(args.siteUrl);
|
|
68
|
+
if (router === void 0) {
|
|
69
|
+
router = loadHttp().then((module) => module.default);
|
|
70
|
+
routers.set(args.siteUrl, router);
|
|
71
|
+
}
|
|
72
|
+
const route = (await router).lookup(args.pathname, args.method);
|
|
73
|
+
let response;
|
|
74
|
+
if (route === null) response = new Response(`No HttpAction routed for ${args.pathname}`, { status: 404 });
|
|
75
|
+
else {
|
|
76
|
+
const action = route[0];
|
|
77
|
+
if (!isInvokable(action)) throw new ComponentHttpError({
|
|
78
|
+
componentPath,
|
|
79
|
+
message: "This Convex version does not expose invokeHttpAction for HTTP tests."
|
|
80
|
+
});
|
|
81
|
+
response = await action.invokeHttpAction(new Request(args.url, {
|
|
82
|
+
method: args.method,
|
|
83
|
+
headers: args.headers,
|
|
84
|
+
...args.body === null ? {} : { body: args.body }
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
status: response.status,
|
|
89
|
+
statusText: response.statusText,
|
|
90
|
+
headers: [...response.headers],
|
|
91
|
+
body: await response.arrayBuffer()
|
|
92
|
+
};
|
|
93
|
+
} finally {
|
|
94
|
+
if (previousSiteUrl === void 0) delete process.env.CONVEX_SITE_URL;
|
|
95
|
+
else process.env.CONVEX_SITE_URL = previousSiteUrl;
|
|
96
|
+
}
|
|
97
|
+
} });
|
|
98
|
+
registerComponent(componentPath, schema, {
|
|
99
|
+
...modules,
|
|
100
|
+
[bridgePath]: () => Promise.resolve({ invoke })
|
|
101
|
+
});
|
|
102
|
+
registered.add(componentPath);
|
|
103
|
+
};
|
|
104
|
+
const fetch = (accessor, path, init) => {
|
|
105
|
+
if (normalized.success.length === 0) return accessor.fetch(path, init);
|
|
106
|
+
const run = async () => {
|
|
107
|
+
if (!path.startsWith("/")) throw new InvalidFetchPath({
|
|
108
|
+
path,
|
|
109
|
+
message: "Path given to fetch must start with a \"/\"."
|
|
110
|
+
});
|
|
111
|
+
const pathname = new URL(`${defaultSiteUrl}${path}`).pathname;
|
|
112
|
+
const mount = normalized.success.find(({ prefix }) => pathname === prefix || pathname.startsWith(`${prefix}/`));
|
|
113
|
+
if (mount === void 0) return accessor.fetch(path, init);
|
|
114
|
+
if (!registered.has(mount.componentPath)) throw new ComponentHttpError({
|
|
115
|
+
componentPath: mount.componentPath,
|
|
116
|
+
message: "Register the mounted component before calling fetch."
|
|
117
|
+
});
|
|
118
|
+
const appSiteUrl = (process.env.CONVEX_SITE_URL || defaultSiteUrl).replace(/\/$/, "");
|
|
119
|
+
const request = new Request(new URL(`${appSiteUrl}${path}`), init);
|
|
120
|
+
const reference = `function://${mount.componentPath};${bridgeModule}:invoke`;
|
|
121
|
+
const response = await accessor.action(reference, {
|
|
122
|
+
siteUrl: `${appSiteUrl}${mount.prefix}`,
|
|
123
|
+
url: request.url,
|
|
124
|
+
pathname: pathname.slice(mount.prefix.length) || "/",
|
|
125
|
+
method: request.method,
|
|
126
|
+
headers: [...request.headers],
|
|
127
|
+
body: request.method === "GET" || request.method === "HEAD" ? null : await request.arrayBuffer()
|
|
128
|
+
});
|
|
129
|
+
return new Response(request.method === "HEAD" || [
|
|
130
|
+
204,
|
|
131
|
+
205,
|
|
132
|
+
304
|
|
133
|
+
].includes(response.status) ? null : response.body, {
|
|
134
|
+
status: response.status,
|
|
135
|
+
statusText: response.statusText,
|
|
136
|
+
headers: response.headers
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
const result = tail.then(run);
|
|
140
|
+
tail = result.then(() => void 0, () => void 0);
|
|
141
|
+
return result;
|
|
142
|
+
};
|
|
143
|
+
return {
|
|
144
|
+
register,
|
|
145
|
+
fetch
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
//#endregion
|
|
149
|
+
export { make };
|
|
150
|
+
|
|
151
|
+
//# sourceMappingURL=MountedHttp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MountedHttp.js","names":[],"sources":["../../src/internal/MountedHttp.ts"],"sourcesContent":["/* oxlint-disable effecttsgo/async-function -- This convex-test adapter uses Promise callbacks and temporarily overrides the real process environment consumed by HTTP module construction. */\nimport type { TestConvexForDataModel } from \"convex-test\";\nimport type {\n GenericDataModel,\n HttpRouter,\n FunctionReference,\n RoutableMethod,\n PublicHttpAction,\n} from \"convex/server\";\nimport { actionGeneric } from \"convex/server\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport type { HttpMount, RegisterComponent } from \"../TestConfect\";\n\ndeclare const process: { env: Record<string, string | undefined> };\n\nclass InvalidHttpMount extends Schema.TaggedError<InvalidHttpMount>()(\n \"InvalidHttpMount\",\n {\n componentPath: Schema.String,\n httpPrefix: Schema.String,\n message: Schema.String,\n },\n) {}\n\nclass ComponentHttpError extends Schema.TaggedError<ComponentHttpError>()(\n \"ComponentHttpError\",\n { componentPath: Schema.String, message: Schema.String },\n) {}\n\nclass InvalidFetchPath extends Schema.TaggedError<InvalidFetchPath>()(\n \"InvalidFetchPath\",\n { path: Schema.String, message: Schema.String },\n) {}\n\ntype NormalizedMount = {\n readonly componentPath: string;\n readonly prefix: string;\n};\n\nconst normalizeMounts = (mounts: ReadonlyArray<HttpMount>) => {\n const normalized: Array<NormalizedMount> = [];\n for (const mount of mounts) {\n if (!mount.httpPrefix.startsWith(\"/\") || /[?#]/.test(mount.httpPrefix)) {\n return Result.fail(\n new InvalidHttpMount({\n ...mount,\n message:\n \"httpPrefix must be an absolute path without a query or fragment.\",\n }),\n );\n }\n const prefix = mount.httpPrefix.replace(/\\/+$/, \"\");\n if (normalized.some((previous) => previous.prefix === prefix)) {\n return Result.fail(\n new InvalidHttpMount({\n ...mount,\n message: \"Each httpPrefix must select one component installation.\",\n }),\n );\n }\n normalized.push({ componentPath: mount.componentPath, prefix });\n }\n return Result.succeed(\n normalized.sort((a, b) => b.prefix.length - a.prefix.length),\n );\n};\n\ntype HttpRequest = {\n siteUrl: string;\n url: string;\n pathname: string;\n method: string;\n headers: Array<[string, string]>;\n body: ArrayBuffer | null;\n};\n\ntype HttpResponse = {\n status: number;\n statusText: string;\n headers: Array<[string, string]>;\n body: ArrayBuffer;\n};\n\n// Convex omits this runtime entry point from its published declarations.\nconst isInvokable = (\n action: PublicHttpAction,\n): action is PublicHttpAction & {\n invokeHttpAction(request: Request): Promise<Response>;\n} =>\n \"invokeHttpAction\" in action && typeof action.invokeHttpAction === \"function\";\n\nconst bridgeModule = \"__confect_test_http\";\nconst defaultSiteUrl = \"https://some.convex.site\";\n\nexport const make = (\n mounts: ReadonlyArray<HttpMount>,\n registerComponent: RegisterComponent,\n) => {\n const normalized = normalizeMounts(mounts);\n if (Result.isFailure(normalized)) throw normalized.failure;\n const registered = new Set<string>();\n let tail = Promise.resolve();\n\n const register: RegisterComponent = (componentPath, schema, modules) => {\n if (\n !normalized.success.some((mount) => mount.componentPath === componentPath)\n ) {\n registerComponent(componentPath, schema, modules);\n return;\n }\n const generated = Object.keys(modules).find((key) =>\n key.includes(\"_generated\"),\n );\n const root = generated?.split(\"_generated\", 2)[0];\n const moduleLoaders = Object.fromEntries(\n Object.entries(modules).map(([path, load]) => [\n path.replace(/\\.[^.]+$/, \"\"),\n load,\n ]),\n );\n const loadHttp =\n root === undefined ? undefined : moduleLoaders[`${root}http`];\n if (root === undefined || loadHttp === undefined) {\n throw new ComponentHttpError({\n componentPath,\n message:\n \"Mounted components need an HTTP module and Convex _generated modules.\",\n });\n }\n const bridgePath = `${root}${bridgeModule}.ts`;\n if (`${root}${bridgeModule}` in moduleLoaders) {\n throw new ComponentHttpError({\n componentPath,\n message: `${bridgeModule} is reserved for mounted HTTP tests.`,\n });\n }\n const routers = new Map<string, Promise<HttpRouter>>();\n const invoke = actionGeneric({\n handler: async (_ctx, args: HttpRequest): Promise<HttpResponse> => {\n const previousSiteUrl = process.env.CONVEX_SITE_URL;\n try {\n process.env.CONVEX_SITE_URL = args.siteUrl;\n let router = routers.get(args.siteUrl);\n if (router === undefined) {\n router = loadHttp().then(\n (module: { default: HttpRouter }) => module.default,\n );\n routers.set(args.siteUrl, router);\n }\n const route = (await router).lookup(\n args.pathname,\n args.method as RoutableMethod,\n );\n let response: Response;\n if (route === null) {\n response = new Response(\n `No HttpAction routed for ${args.pathname}`,\n { status: 404 },\n );\n } else {\n const action = route[0];\n if (!isInvokable(action)) {\n throw new ComponentHttpError({\n componentPath,\n message:\n \"This Convex version does not expose invokeHttpAction for HTTP tests.\",\n });\n }\n // Convex selects on the relative path and passes the full URL to the handler.\n response = await action.invokeHttpAction(\n new Request(args.url, {\n method: args.method,\n headers: args.headers,\n ...(args.body === null ? {} : { body: args.body }),\n }),\n );\n }\n return {\n status: response.status,\n statusText: response.statusText,\n headers: [...response.headers],\n body: await response.arrayBuffer(),\n };\n } finally {\n if (previousSiteUrl === undefined) delete process.env.CONVEX_SITE_URL;\n else process.env.CONVEX_SITE_URL = previousSiteUrl;\n }\n },\n });\n registerComponent(componentPath, schema, {\n ...modules,\n [bridgePath]: () => Promise.resolve({ invoke }),\n });\n registered.add(componentPath);\n };\n\n const fetch = <DataModel extends GenericDataModel>(\n accessor: TestConvexForDataModel<DataModel>,\n path: string,\n init?: RequestInit,\n ): Promise<Response> => {\n if (normalized.success.length === 0) return accessor.fetch(path, init);\n const run = async () => {\n if (!path.startsWith(\"/\")) {\n throw new InvalidFetchPath({\n path,\n message: 'Path given to fetch must start with a \"/\".',\n });\n }\n const pathname = new URL(`${defaultSiteUrl}${path}`).pathname;\n const mount = normalized.success.find(\n ({ prefix }) =>\n pathname === prefix || pathname.startsWith(`${prefix}/`),\n );\n if (mount === undefined) return accessor.fetch(path, init);\n if (!registered.has(mount.componentPath)) {\n throw new ComponentHttpError({\n componentPath: mount.componentPath,\n message: \"Register the mounted component before calling fetch.\",\n });\n }\n const appSiteUrl = (\n process.env.CONVEX_SITE_URL || defaultSiteUrl\n ).replace(/\\/$/, \"\");\n const request = new Request(new URL(`${appSiteUrl}${path}`), init);\n // convex-test encodes exact component paths in test-only function handles.\n const reference =\n `function://${mount.componentPath};${bridgeModule}:invoke` as unknown as FunctionReference<\n \"action\",\n \"public\",\n HttpRequest,\n HttpResponse\n >;\n const response = await accessor.action(reference, {\n siteUrl: `${appSiteUrl}${mount.prefix}`,\n url: request.url,\n pathname: pathname.slice(mount.prefix.length) || \"/\",\n method: request.method,\n headers: [...request.headers],\n body:\n request.method === \"GET\" || request.method === \"HEAD\"\n ? null\n : await request.arrayBuffer(),\n });\n return new Response(\n request.method === \"HEAD\" || [204, 205, 304].includes(response.status)\n ? null\n : response.body,\n {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n },\n );\n };\n const result = tail.then(run);\n tail = result.then(\n () => undefined,\n () => undefined,\n );\n return result;\n };\n\n return { register, fetch };\n};\n"],"mappings":";;;;AAgBA,IAAM,mBAAN,cAA+B,OAAO,YAA8B,CAAC,CACnE,oBACA;CACE,eAAe,OAAO;CACtB,YAAY,OAAO;CACnB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAM,qBAAN,cAAiC,OAAO,YAAgC,CAAC,CACvE,sBACA;CAAE,eAAe,OAAO;CAAQ,SAAS,OAAO;AAAO,CACzD,CAAC,CAAC,CAAC;AAEH,IAAM,mBAAN,cAA+B,OAAO,YAA8B,CAAC,CACnE,oBACA;CAAE,MAAM,OAAO;CAAQ,SAAS,OAAO;AAAO,CAChD,CAAC,CAAC,CAAC;AAOH,MAAM,mBAAmB,WAAqC;CAC5D,MAAM,aAAqC,CAAC;CAC5C,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,CAAC,MAAM,WAAW,WAAW,GAAG,KAAK,OAAO,KAAK,MAAM,UAAU,GACnE,OAAO,OAAO,KACZ,IAAI,iBAAiB;GACnB,GAAG;GACH,SACE;EACJ,CAAC,CACH;EAEF,MAAM,SAAS,MAAM,WAAW,QAAQ,QAAQ,EAAE;EAClD,IAAI,WAAW,MAAM,aAAa,SAAS,WAAW,MAAM,GAC1D,OAAO,OAAO,KACZ,IAAI,iBAAiB;GACnB,GAAG;GACH,SAAS;EACX,CAAC,CACH;EAEF,WAAW,KAAK;GAAE,eAAe,MAAM;GAAe;EAAO,CAAC;CAChE;CACA,OAAO,OAAO,QACZ,WAAW,MAAM,GAAG,MAAM,EAAE,OAAO,SAAS,EAAE,OAAO,MAAM,CAC7D;AACF;AAmBA,MAAM,eACJ,WAI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/confect-core@10.3.1-fork.2",
|
|
6
|
+
"@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.2",
|
|
7
|
+
"convex": "^1.32.0",
|
|
8
|
+
"convex-test": ">=0.0.50 <0.1.0",
|
|
9
|
+
"effect": "^4.0.0"
|
|
10
|
+
},
|
|
11
|
+
"description": "Utilities for testing Confect apps without a live Convex backend",
|
|
12
|
+
"author": "RJ Dellecese",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/gaganref/confect"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=24"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./*": {
|
|
25
|
+
"types": "./dist/*.d.ts",
|
|
26
|
+
"default": "./dist/*.js"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
"./internal/*": null
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"CHANGELOG.md",
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"README.md",
|
|
35
|
+
"dist",
|
|
36
|
+
"!dist/*.tsbuildinfo",
|
|
37
|
+
"package.json",
|
|
38
|
+
"src"
|
|
39
|
+
],
|
|
40
|
+
"homepage": "https://confect.dev",
|
|
41
|
+
"keywords": [
|
|
42
|
+
"convex",
|
|
43
|
+
"effect",
|
|
44
|
+
"testing"
|
|
45
|
+
],
|
|
46
|
+
"license": "ISC",
|
|
47
|
+
"main": "./dist/index.js",
|
|
48
|
+
"module": "./dist/index.js",
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/gaganref/confect.git"
|
|
52
|
+
},
|
|
53
|
+
"sideEffects": false,
|
|
54
|
+
"type": "module",
|
|
55
|
+
"types": "./dist/index.d.ts",
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"registry": "https://registry.npmjs.org",
|
|
58
|
+
"access": "public"
|
|
59
|
+
}
|
|
6
60
|
}
|