@crvouga/mockingbird-service-firstpromoter 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,15 +1,27 @@
1
1
  # Changelog — @crvouga/mockingbird-service-firstpromoter
2
2
 
3
- ## 3.1.0 (2026-10-08)
3
+ ## 3.3.0 (2026-10-12)
4
4
 
5
5
  ### Features
6
6
 
7
- - redesign emulator experience ([d6038c2](https://github.com/crvouga/mockingbird/commit/d6038c27eebbaa1751f02bc9305002a5b1304779))
7
+ - unify the emulator control plane ([2068547](https://github.com/crvouga/mockingbird/commit/2068547bedde4e2e2331c1657c1a78120e84428b))
8
8
 
9
9
  ### Dependencies
10
10
 
11
11
  - `@crvouga/mockingbird-service-sqlite`
12
12
 
13
+ ## 3.2.0 (2026-10-08)
14
+
15
+ ### Features
16
+
17
+ - match Emulate provider coverage ([16b65ce](https://github.com/crvouga/mockingbird/commit/16b65ce791fa216f28ec1521df636f57771d9c5e))
18
+
19
+ ## 3.1.0 (2026-10-08)
20
+
21
+ ### Features
22
+
23
+ - redesign emulator experience ([d6038c2](https://github.com/crvouga/mockingbird/commit/d6038c27eebbaa1751f02bc9305002a5b1304779))
24
+
13
25
  ## 3.0.0 (2026-10-07)
14
26
 
15
27
  ### ⚠️ Breaking changes
package/DISCOVERY.md CHANGED
@@ -35,6 +35,7 @@ repository; live parity is an additional oracle check, not a substitute for the
35
35
 
36
36
  - `GET /__admin/health`
37
37
  - `GET /__admin`
38
+ - `GET /__admin/controls`
38
39
  - `GET /__admin/state`
39
40
  - `GET /__admin/requests`
40
41
  - `GET /__admin/metrics`
@@ -45,6 +46,28 @@ For HTTP services, use `x-mockingbird-namespace` (or the documented credential/p
45
46
  parallel tests do not share state. Admin state, journal, metrics and fault-preset endpoints are
46
47
  designed for assertions and diagnosis by consuming test suites.
47
48
 
49
+ ## Admin controls
50
+
51
+ Every HTTP emulator takes the same controls, and each means the same thing at boot
52
+ (`createRuntime({ adminControls })`, `serve --admin-controls`), over `/__admin`, and in a request header:
53
+
54
+ | Control | Admin API | Request header | Interface |
55
+ | --- | --- | --- | --- |
56
+ | Isolate state by key | `GET /__admin/namespaces` | `x-mockingbird-namespace: <key>` | [Namespaces](https://mockingbird.chrisvouga.dev/docs/admin-controls/namespaces) |
57
+ | Reset to boot | `POST /__admin/reset` | `x-mockingbird-reset: true` | [Reset](https://mockingbird.chrisvouga.dev/docs/admin-controls/reset) |
58
+ | Snapshot and restore | `POST /__admin/snapshots`, `POST /__admin/snapshots/<id>/restore` | `x-mockingbird-snapshot: <name>`, `x-mockingbird-restore: <name>` | [Snapshot and restore](https://mockingbird.chrisvouga.dev/docs/admin-controls/snapshot-and-restore) |
59
+ | Move the clock | `POST /__admin/clock` | `x-mockingbird-time: <instant>`, `x-mockingbird-advance: <duration>` | [Clock](https://mockingbird.chrisvouga.dev/docs/admin-controls/clock) |
60
+ | Read or branch from old state | `GET /__admin/timeline` | `x-mockingbird-at: <checkpoint>`, `x-mockingbird-branch: <name>` | [Checkpoints and branches](https://mockingbird.chrisvouga.dev/docs/admin-controls/checkpoints-and-branches) |
61
+ | Inject a fault | `POST /__admin/faults` | `x-mockingbird-fault: <fault>` | [Faults](https://mockingbird.chrisvouga.dev/docs/admin-controls/faults) |
62
+ | Latency and timeouts | `PUT /__admin/latency` | `x-mockingbird-delay: <duration>`, `x-mockingbird-timeout: <duration>` | [Latency and timeouts](https://mockingbird.chrisvouga.dev/docs/admin-controls/latency-and-timeouts) |
63
+ | Replay from a seed | `PUT /__admin/controls` | `x-mockingbird-seed: <seed>` | [Seed and determinism](https://mockingbird.chrisvouga.dev/docs/admin-controls/seed-and-determinism) |
64
+ | See what happened | `GET /__admin/requests`, `GET /__admin/state` | | [Journal, metrics and state](https://mockingbird.chrisvouga.dev/docs/admin-controls/journal-and-state) |
65
+
66
+ `GET /__admin` lists every route and header with a one-line summary, and `GET /__admin/controls`
67
+ is the namespace's current control document. The same seed and the same requests give the same
68
+ bytes. Setting controls as an emulator starts is [Boot](https://mockingbird.chrisvouga.dev/docs/admin-controls/boot); every route and header is in
69
+ the [Reference](https://mockingbird.chrisvouga.dev/docs/admin-controls/reference). The full guide: <https://mockingbird.chrisvouga.dev/docs/admin-controls>.
70
+
48
71
  ## Report a mismatch or missing capability
49
72
 
50
73
  Follow the [agent reporting contract](https://github.com/crvouga/mockingbird/blob/main/docs/REPORTING_ISSUES.md). Include package version,
package/README.md CHANGED
@@ -36,25 +36,36 @@ npx mockingbird-firstpromoter serve --port 8812 \
36
36
  ```
37
37
 
38
38
  ```ts
39
- import { createRuntime } from "@crvouga/mockingbird-service-firstpromoter"
39
+ import { createServer } from "@crvouga/mockingbird-service-firstpromoter/server"
40
40
 
41
- const fp = createRuntime({
41
+ // Test setup: the emulator, an existing affiliate, and a click on their link.
42
+ const server = await createServer({
42
43
  webhooks: { url: "http://127.0.0.1:3000/users/webhooks/first-promoter", secret: "user:pass" },
43
44
  })
44
45
  const admin = (path: string, body: unknown) =>
45
- fp.fetch(
46
- new Request(`http://fp.test/__admin${path}`, {
47
- method: "POST",
48
- headers: { "content-type": "application/json" },
49
- body: JSON.stringify(body),
50
- }),
51
- )
52
-
53
- // An existing affiliate, and a click on their link: the tid checkout stores as fp_tid.
46
+ fetch(`${server.url}/__admin${path}`, {
47
+ method: "POST",
48
+ headers: { "content-type": "application/json" },
49
+ body: JSON.stringify(body),
50
+ })
54
51
  await admin("/promoters", { email: "nate@example.com", ref_token: "nate91" })
52
+ // The tid checkout stores as fp_tid.
55
53
  const { tid } = (await (await admin("/clicks", { ref_token: "nate91" })).json()) as { tid: string }
56
- // …the app's invoice handler posts POST /v2/track/signup {email, tid}; the emulator converts the
57
- // referral and posts lead_becomes_referral to the backend with Authorization: Basic…
54
+
55
+ // Application code: FIRST_PROMOTER_API_URL is server.url. The invoice handler tracks the signup.
56
+ const baseUrl = server.url
57
+ const tracked = await fetch(`${baseUrl}/v2/track/signup`, {
58
+ method: "POST",
59
+ headers: {
60
+ authorization: "Bearer fp-api-key",
61
+ "Account-ID": "acct_1",
62
+ "content-type": "application/json",
63
+ },
64
+ body: JSON.stringify({ email: "customer@example.com", tid }),
65
+ })
66
+ // The emulator converts the referral and posts lead_becomes_referral to the backend with
67
+ // Authorization: Basic…
68
+ await server.close()
58
69
  ```
59
70
 
60
71
  ### Routes