@vllnt/convex-experiments 0.1.1-canary.eb332c6 → 0.2.0-canary.e620507
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 +8 -4
- package/docs/API.md +4 -2
- package/package.json +1 -1
- package/src/test.ts +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,7 @@ All notable changes to this project are documented here. The format is based on
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
|
|
5
5
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
-
## [0.
|
|
7
|
+
## [0.2.0] - Unreleased
|
|
8
8
|
|
|
9
9
|
### Added
|
|
10
10
|
|
|
@@ -21,11 +21,15 @@ All notable changes to this project are documented here. The format is based on
|
|
|
21
21
|
- Correct shipped doc comments: `results` returns a zeroed row per defined variant (not `[]`) for an
|
|
22
22
|
experiment with no enrollment, `weight` is never `0`, and `setStatus` returns `true` whenever the
|
|
23
23
|
experiment exists.
|
|
24
|
-
- Reject empty `scope`, `key`, and `subjectRef` identifiers in `define`, `setStatus`,
|
|
25
|
-
`logExposure`, `forgetSubject`, and `deleteExperiment` with
|
|
26
|
-
and an empty variant key in `define` with
|
|
24
|
+
- **Breaking:** Reject empty `scope`, `key`, and `subjectRef` identifiers in `define`, `setStatus`,
|
|
25
|
+
`assign`, `logExposure`, `forgetSubject`, and `deleteExperiment` with
|
|
26
|
+
`ConvexError({ code: "INVALID_ARGUMENT" })`, and an empty variant key in `define` with
|
|
27
|
+
`INVALID_VARIANTS` (`reason: "empty_key"`). Callers passing an empty `scope`, `key`, `subjectRef`
|
|
28
|
+
or variant key now get a `ConvexError` instead of success.
|
|
27
29
|
- Make the `/test` entry type-check for consumers using `moduleResolution: nodenext`: relative imports
|
|
28
30
|
in `src/` use explicit `.js` extensions and `src/test.ts` references `vite/client` types.
|
|
31
|
+
- `register()` from `/test` accepts a host app's `convexTest(hostSchema, modules)` instance. It was
|
|
32
|
+
typed against the component's own schema, so any host schema with other tables failed with TS2345.
|
|
29
33
|
|
|
30
34
|
### Changed
|
|
31
35
|
|
package/docs/API.md
CHANGED
|
@@ -165,8 +165,10 @@ is an optional peer dependency.
|
|
|
165
165
|
### Test helper
|
|
166
166
|
|
|
167
167
|
`register(t, name = "experiments")` calls `t.registerComponent` with the
|
|
168
|
-
component schema and modules.
|
|
169
|
-
`
|
|
168
|
+
component schema and modules. `t` is the host app's own
|
|
169
|
+
`convexTest(hostSchema, modules)` instance, whatever its tables. The consuming
|
|
170
|
+
app needs `convex-test` and Vite's `import.meta.glob` (for example through
|
|
171
|
+
`vitest`).
|
|
170
172
|
|
|
171
173
|
## Error codes
|
|
172
174
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vllnt/convex-experiments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-canary.e620507",
|
|
4
4
|
"description": "Deterministic A/B experimentation — sticky variant assignment and deduped exposure tracking, as a Convex component",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/test.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="vite/client" />
|
|
2
|
+
import type { GenericSchema, SchemaDefinition } from "convex/server";
|
|
2
3
|
import type { TestConvex } from "convex-test";
|
|
3
4
|
import schema from "./component/schema.js";
|
|
4
5
|
|
|
@@ -7,7 +8,16 @@ const modules = import.meta.glob("./component/**/*.ts");
|
|
|
7
8
|
/**
|
|
8
9
|
* Register this component with a `convex-test` instance so consuming apps can test
|
|
9
10
|
* integration: `import { register } from "@vllnt/convex-experiments/test"`.
|
|
11
|
+
*
|
|
12
|
+
* @param t - The host app's `convexTest(hostSchema, modules)` instance, for any host schema.
|
|
13
|
+
* @param name - The component name the host mounts it under (`app.use(experiments, { name })`).
|
|
14
|
+
* @example
|
|
15
|
+
* const t = convexTest(schema, modules);
|
|
16
|
+
* register(t);
|
|
10
17
|
*/
|
|
11
|
-
export function register
|
|
18
|
+
export function register<TSchema extends GenericSchema>(
|
|
19
|
+
t: TestConvex<SchemaDefinition<TSchema, boolean>>,
|
|
20
|
+
name = "experiments",
|
|
21
|
+
): void {
|
|
12
22
|
t.registerComponent(name, schema, modules);
|
|
13
23
|
}
|