@crvouga/mockingbird-service-fcm 2.1.0 → 2.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/DISCOVERY.md +23 -0
- package/README.md +23 -23
- package/dist/admin.js +1 -1
- package/dist/chunk-5RVPNZ5C.js +5952 -0
- package/dist/chunk-5RVPNZ5C.js.map +7 -0
- package/dist/{chunk-ZR2JECE4.js → chunk-W7FKZHGW.js} +139 -26
- package/dist/chunk-W7FKZHGW.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +435 -121
- package/dist/index.js +1 -1
- package/dist/server.d.ts +819 -188
- package/dist/server.js +2 -2
- package/package.json +3 -2
- package/dist/chunk-K7GBD2SV.js +0 -4072
- package/dist/chunk-K7GBD2SV.js.map +0 -7
- package/dist/chunk-ZR2JECE4.js.map +0 -7
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
|
@@ -20,36 +20,36 @@ ESM only. Node >= 22 or Bun >= 1.2. No native dependencies. Serve it with `npx m
|
|
|
20
20
|
`firebase-admin` hardcodes `https://fcm.googleapis.com`. Point it at the emulator with `createAdminTransport` (an `https.Agent` that dials the emulator) and call `enableLegacyHttpTransport()` so multicast sends honor that agent. `send` is already HTTP/1.1. The fixture project is `demo-project`, the fixture device token is `fixture-device-token`, and any bearer is accepted until you turn on `strict`.
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
|
+
import { deleteApp, initializeApp } from "firebase-admin/app"
|
|
24
|
+
import { getMessaging } from "firebase-admin/messaging"
|
|
23
25
|
import { createServer } from "@crvouga/mockingbird-service-fcm/server"
|
|
24
26
|
import { createAdminTransport } from "@crvouga/mockingbird-service-fcm/admin"
|
|
25
27
|
|
|
28
|
+
// Test setup: the emulator, plus a credential and an agent that reach it.
|
|
26
29
|
const fcm = await createServer()
|
|
27
30
|
const transport = await createAdminTransport({ origin: fcm.url, token: "fixture-token" })
|
|
28
|
-
// initializeApp({ projectId: "demo-project", credential: transport.credential, httpAgent: transport.agent })
|
|
29
|
-
// getMessaging(app).enableLegacyHttpTransport()
|
|
30
|
-
await transport.close()
|
|
31
|
-
await fcm.close()
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Without the SDK, `POST` the wire body and read the outbox:
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
32
|
+
// The application's firebase-admin app. Only its credential and httpAgent change.
|
|
33
|
+
const app = initializeApp({
|
|
34
|
+
projectId: "demo-project",
|
|
35
|
+
credential: transport.credential,
|
|
36
|
+
httpAgent: transport.agent,
|
|
37
|
+
})
|
|
38
|
+
const messaging = getMessaging(app)
|
|
39
|
+
messaging.enableLegacyHttpTransport()
|
|
40
|
+
const name = await messaging.send({
|
|
41
|
+
token: "fixture-device-token",
|
|
42
|
+
notification: { title: "Hello", body: "World" },
|
|
43
|
+
})
|
|
44
|
+
// name → "projects/demo-project/messages/<id>"
|
|
45
|
+
|
|
46
|
+
// Test control: every message the emulator accepted.
|
|
47
|
+
const outbox = await (await fetch(`${fcm.url}/__admin/outbox`)).json()
|
|
52
48
|
void outbox
|
|
49
|
+
|
|
50
|
+
await deleteApp(app)
|
|
51
|
+
await transport.close()
|
|
52
|
+
await fcm.close()
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
### Routes
|