@gaganref/confect-test 10.3.1-fork.89 → 10.3.1-fork.90
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/dist/TestConfect.d.ts +33 -7
- package/dist/TestConfect.d.ts.map +1 -1
- package/dist/TestConfect.js +11 -6
- package/dist/TestConfect.js.map +1 -1
- package/dist/internal/Attempt.js.map +1 -1
- package/dist/internal/Clock.d.ts +29 -0
- package/dist/internal/Clock.d.ts.map +1 -0
- package/dist/internal/Clock.js +66 -0
- package/dist/internal/Clock.js.map +1 -0
- package/dist/internal/ConvexTest.d.ts +33 -1
- package/dist/internal/ConvexTest.d.ts.map +1 -1
- package/dist/internal/ConvexTest.js +8 -5
- package/dist/internal/ConvexTest.js.map +1 -1
- package/dist/internal/Execution.d.ts +85 -5
- package/dist/internal/Execution.d.ts.map +1 -1
- package/dist/internal/Execution.js +285 -51
- package/dist/internal/Execution.js.map +1 -1
- package/dist/internal/Globals.d.ts.map +1 -1
- package/dist/internal/Globals.js +12 -0
- package/dist/internal/Globals.js.map +1 -1
- package/dist/internal/Invocation.d.ts +11 -0
- package/dist/internal/Invocation.d.ts.map +1 -1
- package/dist/internal/Invocation.js +34 -21
- package/dist/internal/Invocation.js.map +1 -1
- package/dist/internal/Kernel.d.ts +3 -1
- package/dist/internal/Kernel.d.ts.map +1 -1
- package/dist/internal/Kernel.js +2 -2
- package/dist/internal/Kernel.js.map +1 -1
- package/dist/internal/KernelRefusal.d.ts +25 -0
- package/dist/internal/KernelRefusal.d.ts.map +1 -1
- package/dist/internal/KernelRefusal.js +22 -1
- package/dist/internal/KernelRefusal.js.map +1 -1
- package/dist/internal/KernelValues.d.ts +6 -4
- package/dist/internal/KernelValues.d.ts.map +1 -1
- package/dist/internal/KernelValues.js +20 -5
- package/dist/internal/KernelValues.js.map +1 -1
- package/dist/internal/MountedHttp.d.ts.map +1 -1
- package/dist/internal/MountedHttp.js +3 -3
- package/dist/internal/MountedHttp.js.map +1 -1
- package/dist/internal/Scheduling.d.ts +71 -0
- package/dist/internal/Scheduling.d.ts.map +1 -0
- package/dist/internal/Scheduling.js +60 -0
- package/dist/internal/Scheduling.js.map +1 -0
- package/package.json +3 -3
- package/src/TestConfect.ts +62 -15
- package/src/internal/Attempt.ts +1 -1
- package/src/internal/Clock.ts +95 -0
- package/src/internal/ConvexTest.ts +51 -6
- package/src/internal/Execution.ts +415 -50
- package/src/internal/Globals.ts +20 -0
- package/src/internal/Invocation.ts +38 -13
- package/src/internal/Kernel.ts +5 -5
- package/src/internal/KernelRefusal.ts +24 -0
- package/src/internal/KernelValues.ts +44 -4
- package/src/internal/MountedHttp.ts +13 -6
- package/src/internal/Scheduling.ts +126 -0
package/dist/TestConfect.d.ts
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
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
|
-
import type {
|
|
5
|
-
import type { GenericDataModel, GenericSchema, SchemaDefinition, UserIdentity } from "convex/server";
|
|
4
|
+
import type { GenericSchema, SchemaDefinition, UserIdentity } from "convex/server";
|
|
6
5
|
import type { Value } from "convex/values";
|
|
7
6
|
import * as Context from "effect/Context";
|
|
8
7
|
import * as Effect from "effect/Effect";
|
|
9
8
|
import * as Layer from "effect/Layer";
|
|
10
9
|
import * as Schema from "effect/Schema";
|
|
10
|
+
/**
|
|
11
|
+
* How a kit registers a component beyond its schema and modules.
|
|
12
|
+
*/
|
|
13
|
+
export type RegisterOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* The component's functions, as `module:export`, that schedule their own next
|
|
16
|
+
* run, such as the crons component's `public:rescheduler`. The test kernel
|
|
17
|
+
* never treats a job that runs one, or that one schedules, as work
|
|
18
|
+
* `finishAllScheduledFunctions` must finish. convex-test ignores it.
|
|
19
|
+
*/
|
|
20
|
+
readonly standing?: ReadonlyArray<string>;
|
|
21
|
+
};
|
|
11
22
|
/**
|
|
12
23
|
* Register a component's Convex schema and modules at its installation path.
|
|
13
24
|
*/
|
|
14
|
-
export type RegisterComponent = (
|
|
25
|
+
export type RegisterComponent = (componentPath: string, schema: SchemaDefinition<GenericSchema, boolean>, modules: Record<string, () => Promise<any>>, options?: RegisterOptions) => void;
|
|
15
26
|
/**
|
|
16
27
|
* An installed component path and the HTTP prefix exposed by its host.
|
|
17
28
|
*/
|
|
@@ -19,7 +30,20 @@ export type HttpMount = {
|
|
|
19
30
|
readonly componentPath: string;
|
|
20
31
|
readonly httpPrefix: string;
|
|
21
32
|
};
|
|
22
|
-
|
|
33
|
+
/**
|
|
34
|
+
* The in-process backend a test layer runs on.
|
|
35
|
+
*/
|
|
36
|
+
export type Target = "convex-test" | "kernel";
|
|
37
|
+
export type TargetOptions = {
|
|
38
|
+
/**
|
|
39
|
+
* `"kernel"` runs every function and component the layer registers on
|
|
40
|
+
* Confect's test kernel, which runs scheduled functions on its own clock and
|
|
41
|
+
* reads `registerComponent`'s `standing`. Defaults to `"convex-test"`. The
|
|
42
|
+
* option goes once the kernel replaces convex-test.
|
|
43
|
+
*/
|
|
44
|
+
readonly target?: Target;
|
|
45
|
+
};
|
|
46
|
+
export type LayerOptions = TargetOptions & {
|
|
23
47
|
/**
|
|
24
48
|
* Register component kits synchronously before the test service is available.
|
|
25
49
|
*/
|
|
@@ -42,7 +66,7 @@ export type TestConfectWithoutIdentity<ConfectSchema extends DatabaseSchema.AnyW
|
|
|
42
66
|
finishAllScheduledFunctions: (advanceTimers: () => void) => Effect.Effect<void>;
|
|
43
67
|
};
|
|
44
68
|
export type TestConfect<ConfectSchema extends DatabaseSchema.AnyWithProps> = {
|
|
45
|
-
registerComponent: (componentPath: string, schema: SchemaDefinition<GenericSchema, boolean>, modules: Record<string, () => Promise<any
|
|
69
|
+
registerComponent: (componentPath: string, schema: SchemaDefinition<GenericSchema, boolean>, modules: Record<string, () => Promise<any>>, options?: RegisterOptions) => Effect.Effect<void>;
|
|
46
70
|
withIdentity: (userIdentity: Partial<UserIdentity>) => TestConfectWithoutIdentity<ConfectSchema>;
|
|
47
71
|
} & TestConfectWithoutIdentity<ConfectSchema>;
|
|
48
72
|
export declare const TestConfect: <ConfectSchema extends DatabaseSchema.AnyWithProps>() => Context.Service<TestConfect<ConfectSchema>, TestConfect<ConfectSchema>>;
|
|
@@ -77,10 +101,12 @@ export type DeclaredApp<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> = R
|
|
|
77
101
|
/**
|
|
78
102
|
* Build a fresh test backend from a declaration and its generated
|
|
79
103
|
* `confect/_generated/testing` registry, without restating component mounts.
|
|
104
|
+
* Pass `{ target: "kernel" }` to run it on Confect's test kernel instead of
|
|
105
|
+
* convex-test.
|
|
80
106
|
*/
|
|
81
|
-
export declare function layer<DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(app: DeclaredApp<DatabaseSchema_
|
|
107
|
+
export declare function layer<DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(app: DeclaredApp<DatabaseSchema_>, options?: TargetOptions): Layer.Layer<TestConfect<DatabaseSchema_>>;
|
|
82
108
|
export declare function layer<A extends App.Any, DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(app: A, registry: Registry<DatabaseSchema_> & {
|
|
83
109
|
readonly components: Readonly<Record<Mount.NameOf<NoInfer<A>["mounts"][number]>, Registry<DatabaseSchema_>["components"][string]>>;
|
|
84
|
-
}): Layer.Layer<TestConfect<DatabaseSchema_>>;
|
|
110
|
+
}, options?: TargetOptions): Layer.Layer<TestConfect<DatabaseSchema_>>;
|
|
85
111
|
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
112
|
//# 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,KAAK,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"TestConfect.d.ts","sourceRoot":"","sources":["../src/TestConfect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAM3D,OAAO,KAAK,EAEV,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;AAMxC;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,EAChD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,EAC3C,OAAO,CAAC,EAAE,eAAe,KACtB,IAAI,CAAC;A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
2
|
+
import { convexTest as convexTest$1 } from "./internal/ConvexTest.js";
|
|
2
3
|
import { make } from "./internal/MountedHttp.js";
|
|
3
4
|
import { App, Ref } from "@confect/core";
|
|
4
5
|
import { RegisteredConvexFunction } from "@confect/server";
|
|
@@ -45,7 +46,7 @@ var TestConfectImpl = class {
|
|
|
45
46
|
this.testConfectImplWithoutIdentity = new TestConfectImplWithoutIdentity(confectSchema, testConvex, mountedHttp);
|
|
46
47
|
}
|
|
47
48
|
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
|
+
registerComponent = Effect.fn("TestConfect.registerComponent")((componentPath, schema, modules, options) => Effect.sync(() => this.mountedHttp.register(componentPath, schema, modules, options)));
|
|
49
50
|
query = (queryRef, ...args) => this.testConfectImplWithoutIdentity.query(queryRef, ...args);
|
|
50
51
|
mutation = (mutationRef, ...args) => this.testConfectImplWithoutIdentity.mutation(mutationRef, ...args);
|
|
51
52
|
action = (actionRef, ...args) => this.testConfectImplWithoutIdentity.action(actionRef, ...args);
|
|
@@ -66,11 +67,12 @@ const registerKit = (registerComponent, name, kit) => {
|
|
|
66
67
|
message: `The test kit for ${JSON.stringify(name)} must export register(t, name), or schema and modules.`
|
|
67
68
|
});
|
|
68
69
|
};
|
|
69
|
-
function layer(appOrSchema,
|
|
70
|
+
function layer(appOrSchema, second, third, options = {}) {
|
|
70
71
|
if (App.isApp(appOrSchema)) {
|
|
71
|
-
const registry =
|
|
72
|
+
const registry = second;
|
|
72
73
|
const mounts = App.mounts(appOrSchema);
|
|
73
74
|
return schemaLayer(registry.schema, registry.convexSchema, registry.modules, {
|
|
75
|
+
...targetOf(third),
|
|
74
76
|
httpMounts: mounts.flatMap(({ name, httpPrefix }) => httpPrefix === void 0 ? [] : [{
|
|
75
77
|
componentPath: name,
|
|
76
78
|
httpPrefix
|
|
@@ -83,19 +85,22 @@ function layer(appOrSchema, registryOrSchema, modules, options = {}) {
|
|
|
83
85
|
if ("httpMounts" in appOrSchema) {
|
|
84
86
|
const app = appOrSchema;
|
|
85
87
|
return schemaLayer(app.schema, app.convexSchema, app.modules, {
|
|
88
|
+
...targetOf(second),
|
|
86
89
|
httpMounts: app.httpMounts,
|
|
87
90
|
register: (registerComponent) => {
|
|
88
91
|
for (const [name, component] of Object.entries(app.components)) registerKit(registerComponent, name, component);
|
|
89
92
|
}
|
|
90
93
|
});
|
|
91
94
|
}
|
|
92
|
-
return schemaLayer(appOrSchema,
|
|
95
|
+
return schemaLayer(appOrSchema, second, third, options);
|
|
93
96
|
}
|
|
97
|
+
const targetOf = (options) => options?.target === void 0 ? {} : { target: options.target };
|
|
94
98
|
const schemaLayer = (databaseSchema, convexSchemaDefinition, modules, options = {}) => Layer.sync(TestConfect(), () => {
|
|
95
99
|
process.env.CONVEX_CLOUD_URL ??= "https://some-deployment.convex.cloud";
|
|
96
100
|
process.env.CONVEX_SITE_URL ??= "https://some.convex.site";
|
|
97
|
-
const testConvex = convexTest(convexSchemaDefinition, modules);
|
|
98
|
-
const
|
|
101
|
+
const testConvex = (options.target === "kernel" ? convexTest$1 : convexTest)(convexSchemaDefinition, modules);
|
|
102
|
+
const registerComponent = testConvex.registerComponent;
|
|
103
|
+
const mountedHttp = make(options.httpMounts ?? [], (...args) => registerComponent(...args));
|
|
99
104
|
options.register?.(mountedHttp.register);
|
|
100
105
|
return new TestConfectImpl(databaseSchema, testConvex, mountedHttp);
|
|
101
106
|
});
|
package/dist/TestConfect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,SA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,CAAC,IAAI,CAAC;IAAE,eAAe;IAAM;GAAW,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,YAAY,mBAAmB,MAAM,SAAS;GAGpD;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,YAAY,mBAAmB,MAAM,SAAS;GAElD;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,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":["kernelTest","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 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 { convexTest as kernelTest } from \"./internal/ConvexTest.js\";\nimport * as MountedHttp from \"./internal/MountedHttp.js\";\n\ndeclare const process: { env: Record<string, string | undefined> };\n\n/**\n * How a kit registers a component beyond its schema and modules.\n */\nexport type RegisterOptions = {\n /**\n * The component's functions, as `module:export`, that schedule their own next\n * run, such as the crons component's `public:rescheduler`. The test kernel\n * never treats a job that runs one, or that one schedules, as work\n * `finishAllScheduledFunctions` must finish. convex-test ignores it.\n */\n readonly standing?: ReadonlyArray<string>;\n};\n\n/**\n * Register a component's Convex schema and modules at its installation path.\n */\nexport type RegisterComponent = (\n componentPath: string,\n schema: SchemaDefinition<GenericSchema, boolean>,\n modules: Record<string, () => Promise<any>>,\n options?: RegisterOptions,\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\n/**\n * The in-process backend a test layer runs on.\n */\nexport type Target = \"convex-test\" | \"kernel\";\n\nexport type TargetOptions = {\n /**\n * `\"kernel\"` runs every function and component the layer registers on\n * Confect's test kernel, which runs scheduled functions on its own clock and\n * reads `registerComponent`'s `standing`. Defaults to `\"convex-test\"`. The\n * option goes once the kernel replaces convex-test.\n */\n readonly target?: Target;\n};\n\nexport type LayerOptions = TargetOptions & {\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 options?: RegisterOptions,\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, options) =>\n Effect.sync(() =>\n this.mountedHttp.register(componentPath, schema, modules, options),\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 * Pass `{ target: \"kernel\" }` to run it on Confect's test kernel instead of\n * convex-test.\n */\nexport function layer<DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n app: DeclaredApp<DatabaseSchema_>,\n options?: TargetOptions,\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 options?: TargetOptions,\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 second?:\n | Registry<DatabaseSchema_>\n | SchemaDefinition<GenericSchema, true>\n | TargetOptions,\n third?: Record<string, () => Promise<any>> | TargetOptions,\n options: LayerOptions = {},\n): Layer.Layer<TestConfect<DatabaseSchema_>> {\n if (App.isApp(appOrSchema)) {\n const registry = second as Registry<DatabaseSchema_>;\n const mounts = App.mounts(appOrSchema);\n return schemaLayer(\n registry.schema,\n registry.convexSchema,\n registry.modules,\n {\n ...targetOf(third as TargetOptions | undefined),\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 ...targetOf(second as TargetOptions | undefined),\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 second as SchemaDefinition<GenericSchema, true>,\n third as Record<string, () => Promise<any>>,\n options,\n );\n}\n\nconst targetOf = (options: TargetOptions | undefined): TargetOptions =>\n options?.target === undefined ? {} : { target: options.target };\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 = (options.target === \"kernel\" ? kernelTest : convexTest)(\n convexSchemaDefinition,\n modules,\n );\n // convex-test takes three arguments and ignores the options. The kernel\n // reads `standing`.\n const registerComponent =\n testConvex.registerComponent as unknown as RegisterComponent;\n const mountedHttp = MountedHttp.make(options.httpMounts ?? [], (...args) =>\n registerComponent(...args),\n );\n options.register?.(mountedHttp.register);\n return new TestConfectImpl(databaseSchema, testConvex as any, mountedHttp);\n });\n"],"mappings":";;;;;;;;;;;;;;;AAgJA,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,OAA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AAK,MAAM,CAAC,MAAM,cAAc,OAAO,QAAQ,IAAI,UAAU,GAC3D,YAAY,mBAAmB,MAAM,SAAS;GAElD;EACF,CAAC;CACH;CACA,OAAO,YACL,aACA,QACA,OACA,OACF;AACF;AAEA,MAAM,YAAY,YAChB,SAAS,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,QAAQ,OAAO;AAEhE,MAAM,eACJ,gBACA,wBACA,SACA,UAAwB,CAAC,MAEzB,MAAM,KAAK,YAA6B,SAAS;CAC/C,QAAQ,IAAI,qBAAqB;CACjC,QAAQ,IAAI,oBAAoB;CAChC,MAAM,cAAc,QAAQ,WAAW,WAAWA,eAAa,WAAA,CAC7D,wBACA,OACF;CAGA,MAAM,oBACJ,WAAW;CACb,MAAM,cAAcC,KAAiB,QAAQ,cAAc,CAAC,IAAI,GAAG,SACjE,kBAAkB,GAAG,IAAI,CAC3B;CACA,QAAQ,WAAW,YAAY,QAAQ;CACvC,OAAO,IAAI,gBAAgB,gBAAgB,YAAmB,WAAW;AAC3E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Attempt.js","names":["Kernel.get","Kernel.rows"],"sources":["../../src/internal/Attempt.ts"],"sourcesContent":["// oxlint-disable-next-line effecttsgo/node-builtin-import --
|
|
1
|
+
{"version":3,"file":"Attempt.js","names":["Kernel.get","Kernel.rows"],"sources":["../../src/internal/Attempt.ts"],"sourcesContent":["// oxlint-disable-next-line effecttsgo/node-builtin-import, no-restricted-imports -- An attempt's drain waits one real turn of the event loop, which is no deadline. Fake timers in a test replace the global `setImmediate`, not this one.\nimport { setImmediate } from \"node:timers/promises\";\nimport type { Attempt as AttemptNumber } from \"./Invocation.js\";\nimport * as Kernel from \"./Kernel.js\";\nimport type { DocumentId, StoredDocument } from \"./KernelValues.js\";\nimport { tableNameFromId } from \"./KernelValues.js\";\nimport type * as ReadSet from \"./ReadSet.js\";\n\n/**\n * Pending writes, keyed by component path, then document ID. `null` deletes.\n */\ntype Overlay = Map<string, Map<DocumentId, StoredDocument | null>>;\n\n/**\n * How long one frame takes syscalls: those it has running, those it has\n * started, and whether it still takes them.\n */\ninterface Life {\n running: number;\n started: number;\n open: boolean;\n}\n\n/**\n * One frame of an attempt at a query or mutation: the committed state the\n * attempt started from, its caller's frame and its own pending writes. The\n * outermost frame belongs to the top-level function. Each nested mutation opens\n * a child frame, which merges into its caller's frame when it returns and is\n * dropped when it fails. Reads belong to the whole attempt and are never\n * dropped: a failed nested mutation's reads stay in the attempt.\n *\n * Each frame has its own lifetime. A frame takes reads and writes until it is\n * closed. A mutation's frame closes once its function has returned and no\n * syscall it started is still running, so a write a detached fiber makes after\n * the handler settled still lands in it, as on the binary. A nested mutation's\n * frame closes before it merges into its caller's, so no write reaches it after\n * its writes became its caller's.\n *\n * A frame belongs to one invocation, which alone writes to it, so a caller's\n * write made while its nested mutation is in flight stays the caller's.\n * `Kernel.apply` publishes the outermost frame's writes.\n */\nexport class KernelAttempt {\n private readonly overlay: Overlay = new Map();\n private readonly life: Life = { running: 0, started: 0, open: true };\n private readonly allReads: Array<ReadSet.Read>;\n\n constructor(\n readonly snapshot: Kernel.State,\n readonly number: AttemptNumber = 1,\n private readonly parent?: KernelAttempt,\n ) {\n this.allReads = parent?.allReads ?? [];\n }\n\n get reads(): ReadonlyArray<ReadSet.Read> {\n return this.allReads;\n }\n\n get closed(): boolean {\n return !this.life.open;\n }\n\n readDocument(componentPath: string, id: DocumentId) {\n this.allReads.push({ kind: \"document\", componentPath, id });\n }\n\n /**\n * Record a read of an interval. The returned function advances how far the\n * query examined it.\n */\n readInterval(\n read: Omit<ReadSet.IntervalRead, \"through\">,\n ): (through: ReadSet.Key | \"end\") => void {\n const interval: ReadSet.IntervalRead = { ...read, through: null };\n this.allReads.push(interval);\n return (through) => {\n interval.through = through;\n };\n }\n\n /**\n * A syscall began. `end` runs when it settles.\n */\n begin(): () => void {\n const life = this.life;\n life.running++;\n life.started++;\n return () => {\n life.running--;\n };\n }\n\n /**\n * Resolves once a whole turn of the event loop passes with no syscall of this\n * frame running or started. A nested call is a syscall of its caller's frame\n * until it has drained.\n */\n drained(): Promise<void> {\n const before = this.life.started;\n return setImmediate().then(() =>\n this.life.running === 0 && this.life.started === before\n ? undefined\n : this.drained(),\n );\n }\n\n close() {\n this.life.open = false;\n }\n\n /**\n * The pending writes this frame sees, from the outermost frame to this one.\n */\n private overlays(): Array<Overlay> {\n return this.parent === undefined\n ? [this.overlay]\n : [...this.parent.overlays(), this.overlay];\n }\n\n get(componentPath: string, id: DocumentId): StoredDocument | null {\n for (const overlay of this.overlays().toReversed()) {\n const write = overlay.get(componentPath)?.get(id);\n if (write !== undefined) return write;\n }\n return Kernel.get(this.snapshot, componentPath, id)?.doc ?? null;\n }\n\n /**\n * The table as this frame sees it, committed rows under every pending write\n * from the outermost frame to this one.\n */\n scan(componentPath: string, tableName: string): Array<StoredDocument> {\n const ids = new Set<DocumentId>();\n for (const row of Kernel.rows(this.snapshot, componentPath, tableName))\n ids.add(row.doc._id);\n for (const overlay of this.overlays())\n for (const id of overlay.get(componentPath)?.keys() ?? [])\n if (tableNameFromId(id) === tableName) ids.add(id);\n const docs: Array<StoredDocument> = [];\n for (const id of ids) {\n const doc = this.get(componentPath, id);\n if (doc !== null) docs.push(doc);\n }\n return docs;\n }\n\n write(componentPath: string, id: DocumentId, doc: StoredDocument | null) {\n const writes = this.overlay.get(componentPath) ?? new Map();\n this.overlay.set(componentPath, writes);\n writes.set(id, doc);\n }\n\n /**\n * A nested mutation begins, in a frame of its own. Dropping a failed one is\n * forgetting it.\n */\n child(): KernelAttempt {\n return new KernelAttempt(this.snapshot, this.number, this);\n }\n\n /**\n * A nested mutation returned and its frame closed. Its writes become its\n * caller's.\n */\n merge() {\n if (this.parent === undefined) {\n throw new Error(\"The outermost frame of an attempt has no caller.\");\n }\n if (this.life.open) {\n throw new Error(\"A nested mutation's frame merges only once closed.\");\n }\n for (const [componentPath, writes] of this.overlay)\n for (const [id, doc] of writes) this.parent.write(componentPath, id, doc);\n }\n\n /**\n * The outermost frame's writes, for `Kernel.apply`.\n */\n writes(): Array<Kernel.Write> {\n return Array.from(this.overlay, ([componentPath, writes]) =>\n Array.from(writes, ([id, doc]) => ({ componentPath, id, doc })),\n ).flat();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAa,gBAAb,MAAa,cAAc;CAMd;CACA;CACQ;CAPnB,0BAAoC,IAAI,IAAI;CAC5C,OAA8B;EAAE,SAAS;EAAG,SAAS;EAAG,MAAM;CAAK;CACnE;CAEA,YACE,UACA,SAAiC,GACjC,QACA;EAHS,KAAA,WAAA;EACA,KAAA,SAAA;EACQ,KAAA,SAAA;EAEjB,KAAK,WAAW,QAAQ,YAAY,CAAC;CACvC;CAEA,IAAI,QAAqC;EACvC,OAAO,KAAK;CACd;CAEA,IAAI,SAAkB;EACpB,OAAO,CAAC,KAAK,KAAK;CACpB;CAEA,aAAa,eAAuB,IAAgB;EAClD,KAAK,SAAS,KAAK;GAAE,MAAM;GAAY;GAAe;EAAG,CAAC;CAC5D;;;;;CAMA,aACE,MACwC;EACxC,MAAM,WAAiC;GAAE,GAAG;GAAM,SAAS;EAAK;EAChE,KAAK,SAAS,KAAK,QAAQ;EAC3B,QAAQ,YAAY;GAClB,SAAS,UAAU;EACrB;CACF;;;;CAKA,QAAoB;EAClB,MAAM,OAAO,KAAK;EAClB,KAAK;EACL,KAAK;EACL,aAAa;GACX,KAAK;EACP;CACF;;;;;;CAOA,UAAyB;EACvB,MAAM,SAAS,KAAK,KAAK;EACzB,OAAO,aAAa,CAAC,CAAC,WACpB,KAAK,KAAK,YAAY,KAAK,KAAK,KAAK,YAAY,SAC7C,KAAA,IACA,KAAK,QAAQ,CACnB;CACF;CAEA,QAAQ;EACN,KAAK,KAAK,OAAO;CACnB;;;;CAKA,WAAmC;EACjC,OAAO,KAAK,WAAW,KAAA,IACnB,CAAC,KAAK,OAAO,IACb,CAAC,GAAG,KAAK,OAAO,S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I,QAAQ,QAAQ,KAAK,OAAO,MAAM,eAAe,IAAI,GAAG;CAC5E;;;;CAKA,SAA8B;EAC5B,OAAO,MAAM,KAAK,KAAK,UAAU,CAAC,eAAe,YAC/C,MAAM,KAAK,SAAS,CAAC,IAAI,UAAU;GAAE;GAAe;GAAI;EAAI,EAAE,CAChE,CAAC,CAAC,KAAK;CACT;AACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convex pins `Date` inside a query or mutation to the time it started, and its
|
|
3
|
+
* scheduler reads `Date.now()` for `runAfter`. The kernel wraps the realm's
|
|
4
|
+
* `Date` so it answers a kernel invocation's time inside one and the host's
|
|
5
|
+
* everywhere else. It sets no host timer.
|
|
6
|
+
*/
|
|
7
|
+
type DateConstructor = typeof globalThis.Date;
|
|
8
|
+
/**
|
|
9
|
+
* Wrap the realm's current `Date`, unless the kernel already did. `pinned`
|
|
10
|
+
* answers the running invocation's time, or `undefined` outside one, and
|
|
11
|
+
* `inside` says whether one is running. The first install's callbacks answer
|
|
12
|
+
* for every later one, as with `globalThis.Convex`. A test that fakes `Date`
|
|
13
|
+
* replaces the wrapper while the fake is installed, and the next install wraps
|
|
14
|
+
* the `Date` the test restores.
|
|
15
|
+
*/
|
|
16
|
+
export declare const install: (pinned: () => number | undefined, inside: () => boolean) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Whether `date` is the kernel's wrapper inside a running kernel invocation, so
|
|
19
|
+
* it already answers that invocation's time on the kernel's clock.
|
|
20
|
+
*/
|
|
21
|
+
export declare const answersInvocation: (date: DateConstructor) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The host's time in milliseconds, never a kernel invocation's: the real clock,
|
|
24
|
+
* or a test's fake one while it is installed. It reads the test environment's
|
|
25
|
+
* `Date`, never the copy a bound handler pinned.
|
|
26
|
+
*/
|
|
27
|
+
export declare const hostNow: () => number;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=Clock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Clock.d.ts","sourceRoot":"","sources":["../../src/internal/Clock.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,KAAK,eAAe,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;AA6C9C;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,WACV,MAAM,MAAM,GAAG,SAAS,UACxB,MAAM,OAAO,SAStB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,SAAU,eAAe,KAAG,OAGzD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,OAAO,QAAO,MAKvB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { host } from "./Globals.js";
|
|
2
|
+
//#region src/internal/Clock.ts
|
|
3
|
+
/**
|
|
4
|
+
* Convex pins `Date` inside a query or mutation to the time it started, and its
|
|
5
|
+
* scheduler reads `Date.now()` for `runAfter`. The kernel wraps the realm's
|
|
6
|
+
* `Date` so it answers a kernel invocation's time inside one and the host's
|
|
7
|
+
* everywhere else. It sets no host timer.
|
|
8
|
+
*/
|
|
9
|
+
const key = Symbol.for("@confect/test/Clock");
|
|
10
|
+
const wrap = (base, pinned) => {
|
|
11
|
+
const proxy = new Proxy(base, {
|
|
12
|
+
get: (target, property) => property === "now" ? () => pinned() ?? target.now() : Reflect.get(target, property, target),
|
|
13
|
+
construct: (target, args, newTarget) => {
|
|
14
|
+
const at = args.length === 0 ? pinned() : void 0;
|
|
15
|
+
return Reflect.construct(target, at === void 0 ? args : [at], newTarget === proxy ? target : newTarget);
|
|
16
|
+
},
|
|
17
|
+
apply: (target, self, args) => {
|
|
18
|
+
const at = pinned();
|
|
19
|
+
return at === void 0 ? Reflect.apply(target, self, args) : new target(at).toString();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return proxy;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Wrap the realm's current `Date`, unless the kernel already did. `pinned`
|
|
26
|
+
* answers the running invocation's time, or `undefined` outside one, and
|
|
27
|
+
* `inside` says whether one is running. The first install's callbacks answer
|
|
28
|
+
* for every later one, as with `globalThis.Convex`. A test that fakes `Date`
|
|
29
|
+
* replaces the wrapper while the fake is installed, and the next install wraps
|
|
30
|
+
* the `Date` the test restores.
|
|
31
|
+
*/
|
|
32
|
+
const install = (pinned, inside) => {
|
|
33
|
+
const global = globalThis;
|
|
34
|
+
const state = global[key] ??= {
|
|
35
|
+
bases: /* @__PURE__ */ new WeakMap(),
|
|
36
|
+
pinned,
|
|
37
|
+
inside
|
|
38
|
+
};
|
|
39
|
+
const current = global.Date;
|
|
40
|
+
if (state.bases.has(current)) return;
|
|
41
|
+
const wrapper = wrap(current, () => state.pinned());
|
|
42
|
+
state.bases.set(wrapper, current);
|
|
43
|
+
global.Date = wrapper;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Whether `date` is the kernel's wrapper inside a running kernel invocation, so
|
|
47
|
+
* it already answers that invocation's time on the kernel's clock.
|
|
48
|
+
*/
|
|
49
|
+
const answersInvocation = (date) => {
|
|
50
|
+
const state = globalThis[key];
|
|
51
|
+
return state !== void 0 && state.bases.has(date) && state.inside();
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The host's time in milliseconds, never a kernel invocation's: the real clock,
|
|
55
|
+
* or a test's fake one while it is installed. It reads the test environment's
|
|
56
|
+
* `Date`, never the copy a bound handler pinned.
|
|
57
|
+
*/
|
|
58
|
+
const hostNow = () => host(() => {
|
|
59
|
+
const global = globalThis;
|
|
60
|
+
const current = global.Date;
|
|
61
|
+
return (global[key]?.bases.get(current) ?? current).now();
|
|
62
|
+
});
|
|
63
|
+
//#endregion
|
|
64
|
+
export { answersInvocation, hostNow, install };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=Clock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Clock.js","names":["Globals.host"],"sources":["../../src/internal/Clock.ts"],"sourcesContent":["/**\n * Convex pins `Date` inside a query or mutation to the time it started, and its\n * scheduler reads `Date.now()` for `runAfter`. The kernel wraps the realm's\n * `Date` so it answers a kernel invocation's time inside one and the host's\n * everywhere else. It sets no host timer.\n */\n\nimport * as Globals from \"./Globals.js\";\n\ntype DateConstructor = typeof globalThis.Date;\n\ninterface State {\n /**\n * Each wrapper the kernel installed, and the `Date` it wraps.\n */\n readonly bases: WeakMap<DateConstructor, DateConstructor>;\n readonly pinned: () => number | undefined;\n /**\n * Whether a kernel invocation is running, without reading its time.\n */\n readonly inside: () => boolean;\n}\n\nconst key = Symbol.for(\"@confect/test/Clock\");\n\ntype Global = { [key]?: State; Date: DateConstructor };\n\nconst wrap = (\n base: DateConstructor,\n pinned: () => number | undefined,\n): DateConstructor => {\n const proxy: DateConstructor = new Proxy(base, {\n get: (target, property) =>\n property === \"now\"\n ? () => pinned() ?? target.now()\n : Reflect.get(target, property, target),\n construct: (target, args, newTarget) => {\n const at = args.length === 0 ? pinned() : undefined;\n return Reflect.construct(\n target,\n at === undefined ? args : [at],\n newTarget === proxy ? target : newTarget,\n );\n },\n apply: (target, self, args) => {\n const at = pinned();\n return at === undefined\n ? Reflect.apply(target, self, args)\n : new target(at).toString();\n },\n });\n return proxy;\n};\n\n/**\n * Wrap the realm's current `Date`, unless the kernel already did. `pinned`\n * answers the running invocation's time, or `undefined` outside one, and\n * `inside` says whether one is running. The first install's callbacks answer\n * for every later one, as with `globalThis.Convex`. A test that fakes `Date`\n * replaces the wrapper while the fake is installed, and the next install wraps\n * the `Date` the test restores.\n */\nexport const install = (\n pinned: () => number | undefined,\n inside: () => boolean,\n) => {\n const global = globalThis as Global;\n const state = (global[key] ??= { bases: new WeakMap(), pinned, inside });\n const current = global.Date;\n if (state.bases.has(current)) return;\n const wrapper = wrap(current, () => state.pinned());\n state.bases.set(wrapper, current);\n global.Date = wrapper;\n};\n\n/**\n * Whether `date` is the kernel's wrapper inside a running kernel invocation, so\n * it already answers that invocation's time on the kernel's clock.\n */\nexport const answersInvocation = (date: DateConstructor): boolean => {\n const state = (globalThis as Global)[key];\n return state !== undefined && state.bases.has(date) && state.inside();\n};\n\n/**\n * The host's time in milliseconds, never a kernel invocation's: the real clock,\n * or a test's fake one while it is installed. It reads the test environment's\n * `Date`, never the copy a bound handler pinned.\n */\nexport const hostNow = (): number =>\n Globals.host(() => {\n const global = globalThis as Global;\n const current = global.Date;\n return (global[key]?.bases.get(current) ?? current).now();\n });\n"],"mappings":";;;;;;;;AAuBA,MAAM,MAAM,OAAO,IAAI,qBAAqB;AAI5C,MAAM,QACJ,MACA,WACoB;CACpB,MAAM,QAAyB,IAAI,MAAM,MAAM;EAC7C,MAAM,QAAQ,aACZ,aAAa,cACH,OAAO,KAAK,OAAO,IAAI,IAC7B,QAAQ,IAAI,QAAQ,UAAU,MAAM;EAC1C,YAAY,QAAQ,MAAM,cAAc;GACtC,MAAM,KAAK,KAAK,WAAW,IAAI,OAAO,IAAI,KAAA;GAC1C,OAAO,QAAQ,UACb,QACA,OAAO,KAAA,IAAY,OAAO,CAAC,EAAE,GAC7B,cAAc,QAAQ,SAAS,SACjC;EACF;EACA,QAAQ,QAAQ,MAAM,SAAS;GAC7B,MAAM,KAAK,OAAO;GAClB,OAAO,OAAO,KAAA,IACV,QAAQ,MAAM,QAAQ,MAAM,IAAI,IAChC,IAAI,OAAO,EAAE,CAAC,CAAC,SAAS;EAC9B;CACF,CAAC;CACD,OAAO;AACT;;;;;;;;;AAUA,MAAa,WACX,QACA,WACG;CACH,MAAM,SAAS;CACf,MAAM,QAAS,OAAO,SAAS;EAAE,uBAAO,IAAI,QAAQ;EAAG;EAAQ;CAAO;CACtE,MAAM,UAAU,OAAO;CACvB,IAAI,MAAM,MAAM,IAAI,OAAO,GAAG;CAC9B,MAAM,UAAU,KAAK,eAAe,MAAM,OAAO,CAAC;CAClD,MAAM,MAAM,IAAI,SAAS,OAAO;CAChC,OAAO,OAAO;AAChB;;;;;AAMA,MAAa,qBAAqB,SAAmC;CACnE,MAAM,QAAS,WAAsB;CACrC,OAAO,UAAU,KAAA,KAAa,MAAM,MAAM,IAAI,IAAI,KAAK,MAAM,OAAO;AACtE;;;;;;AAOA,MAAa,gBACXA,WAAmB;CACjB,MAAM,SAAS;CACf,MAAM,UAAU,OAAO;CACvB,QAAQ,OAAO,IAAI,EAAE,MAAM,IAAI,OAAO,KAAK,QAAA,CAAS,IAAI;AAC1D,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { GenericSchema, SchemaDefinition } from "convex/server";
|
|
2
2
|
import * as Execution from "./Execution.js";
|
|
3
3
|
import type * as Kernel from "./Kernel.js";
|
|
4
|
+
import type * as Scheduling from "./Scheduling.js";
|
|
4
5
|
type Modules = Record<string, () => Promise<any>>;
|
|
5
6
|
/**
|
|
6
7
|
* What the kernel adds to convex-test's surface, typed. The shim itself returns
|
|
@@ -13,6 +14,36 @@ export interface KernelControls {
|
|
|
13
14
|
readonly prepare: (reference: any, args?: any) => Promise<Execution.HeldAttempt>;
|
|
14
15
|
readonly apply: (id: string) => Promise<Execution.KernelApply>;
|
|
15
16
|
readonly held: () => ReadonlyArray<Execution.HeldAttempt>;
|
|
17
|
+
/**
|
|
18
|
+
* Move the kernel's clock forward, running each job due on the way at its
|
|
19
|
+
* deadline.
|
|
20
|
+
*/
|
|
21
|
+
readonly advance: (ms: number) => Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* The pending jobs, earliest deadline first.
|
|
24
|
+
*/
|
|
25
|
+
readonly jobs: () => ReadonlyArray<Scheduling.Job>;
|
|
26
|
+
/**
|
|
27
|
+
* Run the jobs due now. No future deadline is crossed.
|
|
28
|
+
*/
|
|
29
|
+
readonly finishInProgressScheduledFunctions: () => Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Run jobs at their deadlines until only standing jobs remain, or fail with
|
|
32
|
+
* `DrainBudgetExceeded` after `maxIterations` jobs. The kernel keeps its own
|
|
33
|
+
* clock, so it never calls `advanceTimers`.
|
|
34
|
+
*/
|
|
35
|
+
readonly finishAllScheduledFunctions: (advanceTimers?: () => void, maxIterations?: number) => Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* How a kit registers a component beyond its schema and modules.
|
|
39
|
+
*/
|
|
40
|
+
export interface RegisterOptions {
|
|
41
|
+
/**
|
|
42
|
+
* The component's functions, as `module:export`, that schedule their own next
|
|
43
|
+
* run, such as the crons component's `public:rescheduler`. A job that runs
|
|
44
|
+
* one, or that one schedules, is never drain work.
|
|
45
|
+
*/
|
|
46
|
+
readonly standing?: ReadonlyArray<string>;
|
|
16
47
|
}
|
|
17
48
|
/**
|
|
18
49
|
* The test kernel under convex-test's `convexTest` signature. The fork's kernel
|
|
@@ -22,7 +53,8 @@ export interface KernelControls {
|
|
|
22
53
|
* Beyond convex-test, `prepare` runs a mutation to its commit point and holds
|
|
23
54
|
* it, and `apply` validates and publishes a held attempt. `mutation` applies
|
|
24
55
|
* each attempt it prepares at once and prepares the next on a conflict, up to
|
|
25
|
-
* attempt 5. `runtime` supplies the clock and commit timestamps.
|
|
56
|
+
* attempt 5. `runtime` supplies the clock and commit timestamps. Scheduled
|
|
57
|
+
* functions run on the kernel's clock, never on a host timer.
|
|
26
58
|
*/
|
|
27
59
|
export declare function convexTest(schemaOrOptions?: SchemaDefinition<GenericSchema, boolean> | {
|
|
28
60
|
readonly schema?: SchemaDefinition<GenericSchema, boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConvexTest.d.ts","sourceRoot":"","sources":["../../src/internal/ConvexTest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAEjB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ConvexTest.d.ts","sourceRoot":"","sources":["../../src/internal/ConvexT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,CAAC,CAAC;IACnD;;OAEG;IACH,QAAQ,CAAC,kCAAkC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE;;;;OAIG;IACH,QAAQ,CAAC,2BAA2B,EAAE,CACpC,aAAa,CAAC,EAAE,MAAM,IAAI,EAC1B,aAAa,CAAC,EAAE,MAAM,KACnB,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC3C;AA4CD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACxB,eAAe,CAAC,EACZ,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,GACxC;IACE,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,aAAa,CAAC;CACzC,EACL,OAAO,CAAC,EAAE,OAAO,GAChB,GAAG,CAoCL"}
|
|
@@ -20,8 +20,10 @@ const accessor = (world, caller) => ({
|
|
|
20
20
|
}),
|
|
21
21
|
fetch: () => Promise.reject(rowPending("HTTP routes", 6)),
|
|
22
22
|
jwks: () => Promise.reject(rowPending("JWT verification", 6)),
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
advance: (ms) => world.advance(ms),
|
|
24
|
+
jobs: () => world.jobs(),
|
|
25
|
+
finishInProgressScheduledFunctions: () => world.advance(0),
|
|
26
|
+
finishAllScheduledFunctions: (_advanceTimers, maxIterations) => world.drain(maxIterations)
|
|
25
27
|
});
|
|
26
28
|
/**
|
|
27
29
|
* The test kernel under convex-test's `convexTest` signature. The fork's kernel
|
|
@@ -31,7 +33,8 @@ const accessor = (world, caller) => ({
|
|
|
31
33
|
* Beyond convex-test, `prepare` runs a mutation to its commit point and holds
|
|
32
34
|
* it, and `apply` validates and publishes a held attempt. `mutation` applies
|
|
33
35
|
* each attempt it prepares at once and prepares the next on a conflict, up to
|
|
34
|
-
* attempt 5. `runtime` supplies the clock and commit timestamps.
|
|
36
|
+
* attempt 5. `runtime` supplies the clock and commit timestamps. Scheduled
|
|
37
|
+
* functions run on the kernel's clock, never on a host timer.
|
|
35
38
|
*/
|
|
36
39
|
function convexTest(schemaOrOptions, modules) {
|
|
37
40
|
let schema;
|
|
@@ -47,8 +50,8 @@ function convexTest(schemaOrOptions, modules) {
|
|
|
47
50
|
const world = new World(schema, modules, runtime);
|
|
48
51
|
return {
|
|
49
52
|
...accessor(world, anonymous),
|
|
50
|
-
registerComponent: (componentPath, componentSchema, componentModules) => {
|
|
51
|
-
world.register(componentPath, componentSchema, componentModules);
|
|
53
|
+
registerComponent: (componentPath, componentSchema, componentModules, options) => {
|
|
54
|
+
world.register(componentPath, componentSchema, componentModules, options?.standing);
|
|
52
55
|
return componentsGeneric()[componentPath];
|
|
53
56
|
}
|
|
54
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConvexTest.js","names":["Execution.withIdentity","KernelRefusal.rowPending","Execution.World","Execution.anonymous"],"sources":["../../src/internal/ConvexTest.ts"],"sourcesContent":["import type {\n GenericSchema,\n SchemaDefinition,\n UserIdentity,\n} from \"convex/server\";\nimport { componentsGeneric } from \"convex/server\";\nimport * as Execution from \"./Execution.js\";\nimport type * as Kernel from \"./Kernel.js\";\nimport * as KernelRefusal from \"./KernelRefusal.js\";\n\ntype Modules = Record<string, () => Promise<any>>;\n\n/**\n * What the kernel adds to convex-test's surface, typed. The shim itself returns\n * `any`, as convex-test's callers expect.\n */\nexport interface KernelControls {\n readonly query: (reference: any, args?: any) => Promise<any>;\n readonly mutation: (reference: any, args?: any) => Promise<any>;\n readonly action: (reference: any, args?: any) => Promise<any>;\n readonly prepare: (\n reference: any,\n args?: any,\n ) => Promise<Execution.HeldAttempt>;\n readonly apply: (id: string) => Promise<Execution.KernelApply>;\n readonly held: () => ReadonlyArray<Execution.HeldAttempt>;\n}\n\nconst isSchemaDefinition = (\n value: unknown,\n): value is SchemaDefinition<GenericSchema, boolean> =>\n value !== null &&\n typeof value === \"object\" &&\n \"tables\" in value &&\n typeof (value as { tables: unknown }).tables === \"object\";\n\nconst accessor = (world: Execution.World, caller: Execution.Caller): any => ({\n query: (reference: any, args?: any) => world.query(caller, reference, args),\n mutation: (reference: any, args?: any) =>\n world.mutation(caller, reference, args),\n action: (reference: any, args?: any) => world.action(caller, reference, args),\n prepare: (reference: any, args?: any) =>\n world.prepare(caller, reference, args),\n apply: (id: string) => world.apply(id),\n held: () => world.held(),\n run: (handler: (ctx: any) => any) => world.run(caller, \"\", handler),\n runInComponent: (componentPath: string, handler: (ctx: any) => any) =>\n world.run(caller, componentPath, handler),\n withIdentity: (identity: Partial<UserIdentity>) =>\n accessor(world, Execution.withIdentity(caller, identity)),\n withRequestMetadata: (metadata: {\n readonly ip?: string | null;\n readonly userAgent?: string | null;\n }) =>\n accessor(world, {\n ...caller,\n ip: metadata.ip ?? null,\n userAgent: metadata.userAgent ?? null,\n }),\n fetch: () => Promise.reject(KernelRefusal.rowPending(\"HTTP routes\", 6)),\n jwks: () => Promise.reject(KernelRefusal.rowPending(\"JWT verification\", 6)),\n
|
|
1
|
+
{"version":3,"file":"ConvexTest.js","names":["Execution.withIdentity","KernelRefusal.rowPending","Execution.World","Execution.anonymous"],"sources":["../../src/internal/ConvexTest.ts"],"sourcesContent":["import type {\n GenericSchema,\n SchemaDefinition,\n UserIdentity,\n} from \"convex/server\";\nimport { componentsGeneric } from \"convex/server\";\nimport * as Execution from \"./Execution.js\";\nimport type * as Kernel from \"./Kernel.js\";\nimport * as KernelRefusal from \"./KernelRefusal.js\";\nimport type * as Scheduling from \"./Scheduling.js\";\n\ntype Modules = Record<string, () => Promise<any>>;\n\n/**\n * What the kernel adds to convex-test's surface, typed. The shim itself returns\n * `any`, as convex-test's callers expect.\n */\nexport interface KernelControls {\n readonly query: (reference: any, args?: any) => Promise<any>;\n readonly mutation: (reference: any, args?: any) => Promise<any>;\n readonly action: (reference: any, args?: any) => Promise<any>;\n readonly prepare: (\n reference: any,\n args?: any,\n ) => Promise<Execution.HeldAttempt>;\n readonly apply: (id: string) => Promise<Execution.KernelApply>;\n readonly held: () => ReadonlyArray<Execution.HeldAttempt>;\n /**\n * Move the kernel's clock forward, running each job due on the way at its\n * deadline.\n */\n readonly advance: (ms: number) => Promise<void>;\n /**\n * The pending jobs, earliest deadline first.\n */\n readonly jobs: () => ReadonlyArray<Scheduling.Job>;\n /**\n * Run the jobs due now. No future deadline is crossed.\n */\n readonly finishInProgressScheduledFunctions: () => Promise<void>;\n /**\n * Run jobs at their deadlines until only standing jobs remain, or fail with\n * `DrainBudgetExceeded` after `maxIterations` jobs. The kernel keeps its own\n * clock, so it never calls `advanceTimers`.\n */\n readonly finishAllScheduledFunctions: (\n advanceTimers?: () => void,\n maxIterations?: number,\n ) => Promise<void>;\n}\n\n/**\n * How a kit registers a component beyond its schema and modules.\n */\nexport interface RegisterOptions {\n /**\n * The component's functions, as `module:export`, that schedule their own next\n * run, such as the crons component's `public:rescheduler`. A job that runs\n * one, or that one schedules, is never drain work.\n */\n readonly standing?: ReadonlyArray<string>;\n}\n\nconst isSchemaDefinition = (\n value: unknown,\n): value is SchemaDefinition<GenericSchema, boolean> =>\n value !== null &&\n typeof value === \"object\" &&\n \"tables\" in value &&\n typeof (value as { tables: unknown }).tables === \"object\";\n\nconst accessor = (world: Execution.World, caller: Execution.Caller): any => ({\n query: (reference: any, args?: any) => world.query(caller, reference, args),\n mutation: (reference: any, args?: any) =>\n world.mutation(caller, reference, args),\n action: (reference: any, args?: any) => world.action(caller, reference, args),\n prepare: (reference: any, args?: any) =>\n world.prepare(caller, reference, args),\n apply: (id: string) => world.apply(id),\n held: () => world.held(),\n run: (handler: (ctx: any) => any) => world.run(caller, \"\", handler),\n runInComponent: (componentPath: string, handler: (ctx: any) => any) =>\n world.run(caller, componentPath, handler),\n withIdentity: (identity: Partial<UserIdentity>) =>\n accessor(world, Execution.withIdentity(caller, identity)),\n withRequestMetadata: (metadata: {\n readonly ip?: string | null;\n readonly userAgent?: string | null;\n }) =>\n accessor(world, {\n ...caller,\n ip: metadata.ip ?? null,\n userAgent: metadata.userAgent ?? null,\n }),\n fetch: () => Promise.reject(KernelRefusal.rowPending(\"HTTP routes\", 6)),\n jwks: () => Promise.reject(KernelRefusal.rowPending(\"JWT verification\", 6)),\n advance: (ms: number) => world.advance(ms),\n jobs: () => world.jobs(),\n finishInProgressScheduledFunctions: () => world.advance(0),\n finishAllScheduledFunctions: (\n _advanceTimers?: () => void,\n maxIterations?: number,\n ) => world.drain(maxIterations),\n});\n\n/**\n * The test kernel under convex-test's `convexTest` signature. The fork's kernel\n * lane aliases `convex-test` to this module, so every suite that calls\n * `convexTest` directly, and `TestConfect` itself, runs on the kernel.\n *\n * Beyond convex-test, `prepare` runs a mutation to its commit point and holds\n * it, and `apply` validates and publishes a held attempt. `mutation` applies\n * each attempt it prepares at once and prepares the next on a conflict, up to\n * attempt 5. `runtime` supplies the clock and commit timestamps. Scheduled\n * functions run on the kernel's clock, never on a host timer.\n */\nexport function convexTest(\n schemaOrOptions?:\n | SchemaDefinition<GenericSchema, boolean>\n | {\n readonly schema?: SchemaDefinition<GenericSchema, boolean>;\n readonly modules?: Modules;\n readonly transactionLimits?: unknown;\n readonly runtime?: Kernel.KernelRuntime;\n },\n modules?: Modules,\n): any {\n let schema: SchemaDefinition<GenericSchema, boolean> | undefined;\n let runtime: Kernel.KernelRuntime | undefined;\n if (isSchemaDefinition(schemaOrOptions)) {\n schema = schemaOrOptions;\n } else if (schemaOrOptions !== undefined) {\n if (schemaOrOptions.transactionLimits !== undefined) {\n throw KernelRefusal.rowPending(\"transaction limits\", 6);\n }\n schema = schemaOrOptions.schema;\n modules = schemaOrOptions.modules;\n runtime = schemaOrOptions.runtime;\n }\n if (modules === undefined) {\n throw new Error(\n \"The test kernel needs the modules map: pass `import.meta.glob(...)` as the second argument.\",\n );\n }\n const world = new Execution.World(schema, modules, runtime);\n return {\n ...accessor(world, Execution.anonymous),\n registerComponent: (\n componentPath: string,\n componentSchema: SchemaDefinition<GenericSchema, boolean>,\n componentModules: Modules,\n options?: RegisterOptions,\n ) => {\n world.register(\n componentPath,\n componentSchema,\n componentModules,\n options?.standing,\n );\n return (componentsGeneric() as any)[componentPath];\n },\n };\n}\n"],"mappings":";;;;AA+DA,MAAM,sBACJ,UAEA,UAAU,QACV,OAAO,UAAU,YACjB,YAAY,SACZ,OAAQ,MAA8B,WAAW;AAEnD,MAAM,YAAY,OAAwB,YAAmC;CAC3E,QAAQ,WAAgB,SAAe,MAAM,MAAM,QAAQ,WAAW,IAAI;CAC1E,WAAW,WAAgB,SACzB,MAAM,SAAS,QAAQ,WAAW,IAAI;CACxC,SAAS,WAAgB,SAAe,MAAM,OAAO,QAAQ,WAAW,IAAI;CAC5E,UAAU,WAAgB,SACxB,MAAM,QAAQ,QAAQ,WAAW,IAAI;CACvC,QAAQ,OAAe,MAAM,MAAM,EAAE;CACrC,YAAY,MAAM,KAAK;CACvB,MAAM,YAA+B,MAAM,IAAI,QAAQ,IAAI,OAAO;CAClE,iBAAiB,eAAuB,YACtC,MAAM,IAAI,QAAQ,eAAe,OAAO;CAC1C,eAAe,aACb,SAAS,OAAOA,aAAuB,QAAQ,QAAQ,CAAC;CAC1D,sBAAsB,aAIpB,SAAS,OAAO;EACd,GAAG;EACH,IAAI,SAAS,MAAM;EACnB,WAAW,SAAS,aAAa;CACnC,CAAC;CACH,aAAa,QAAQ,OAAOC,WAAyB,eAAe,CAAC,CAAC;CACtE,YAAY,QAAQ,OAAOA,WAAyB,oBAAoB,CAAC,CAAC;CAC1E,UAAU,OAAe,MAAM,QAAQ,EAAE;CACzC,YAAY,MAAM,KAAK;C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