@crvouga/mockingbird-service-meta 0.0.0-stage → 1.0.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 ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog — @crvouga/mockingbird-service-meta
2
+
3
+ ## 1.0.0 (2026-10-07)
4
+
5
+ ### ⚠️ Breaking changes
6
+
7
+ - point the repo at crvouga/mockingbird ([1bf35a4](https://github.com/crvouga/mockingbird/commit/1bf35a422b84a85b50b09b72bd7cc7093082a86e))
8
+ - point the repo at crvouga/emulates ([cdb5e53](https://github.com/crvouga/mockingbird/commit/cdb5e536ed8c1f52345e3984f089001c25fdb08a))
9
+ - rename Emulators to Emulates ([2e10d9c](https://github.com/crvouga/mockingbird/commit/2e10d9cff84c54ac37768fc9a19d1aefd3943744))
10
+ - rebrand Mockingbird to Emulators ([1adca65](https://github.com/crvouga/mockingbird/commit/1adca65ce28242f11cff98eac05d2be88f680cbe))
11
+
12
+ ### Fixes and improvements
13
+
14
+ - typecheck the brand gate before builds ([fc36095](https://github.com/crvouga/mockingbird/commit/fc3609514de70ffe3170a5d216fb8a49f9ce7cbb))
15
+ - format the emulates records query ([8698872](https://github.com/crvouga/mockingbird/commit/8698872509d06002be5a8fcdc85d79f8462320c3))
16
+
17
+ ## 0.1.0 (2026-10-05)
18
+
19
+ Initial release.
package/DISCOVERY.md ADDED
@@ -0,0 +1,55 @@
1
+ # @crvouga/mockingbird-service-meta discovery
2
+
3
+ This is the installed-package index for coding agents and tooling. All relative links resolve
4
+ inside `node_modules/@crvouga/mockingbird-service-meta/`; no repository checkout is needed to discover the mock's
5
+ supported surface or documented behavior.
6
+
7
+ ## Capability and behavior sources
8
+
9
+ | Question | Authoritative file | What it contains |
10
+ | --- | --- | --- |
11
+ | Behaviour and integration | [`README.md`](README.md) | Routes, state transitions, auth, webhooks, controls, presets and deliberate omissions. |
12
+ | Exact capabilities | [`SUPPORT.md`](SUPPORT.md) | Supported, unsupported and parity-covered operations or commands, including reasons for gaps. |
13
+ | Wire contract | [`openapi.yaml`](openapi.yaml) | Machine-readable paths, methods, schemas, responses and parity annotations. |
14
+ | Public API | [`dist/index.d.ts`](dist/index.d.ts) | The installed package's exact TypeScript exports and signatures. |
15
+ | Package metadata | [`package.json`](package.json) | Runtime/entry-point claims, vendor links, parity scope/tier and `mockingbird.discovery`. |
16
+
17
+ Read these together: the contract/capability matrix says *what* is available, while the README
18
+ defines stateful behavior, lifecycle rules, test controls, and intentional oracle differences.
19
+ If prose and an executable surface disagree, report a parity mismatch instead of adding a
20
+ consumer-side workaround.
21
+
22
+ ## Parity and oracle
23
+
24
+ - Declared parity surface: **Conversions events and marketing insights**.
25
+ - Parity tier: **cold** (the repository controls when live checks run).
26
+ - Oracle: **Live vendor API or sandbox**.
27
+ - Repository command: `bun run parity:service -- meta`.
28
+ - Evidence model: Run from a Mockingbird checkout; credentials come only from .env.local or GitHub Actions secrets. Missing credentials exit 2.
29
+
30
+ The npm package contains evidence summaries and the exact contract, not credentials or the
31
+ repository-only parity harness. Self-parity/property and acceptance tests run in the Mockingbird
32
+ repository; live parity is an additional oracle check, not a substitute for the packaged matrix.
33
+
34
+ ## Runtime introspection
35
+
36
+ - `GET /__admin/health`
37
+ - `GET /__admin`
38
+ - `GET /__admin/state`
39
+ - `GET /__admin/requests`
40
+ - `GET /__admin/metrics`
41
+ - `GET /__admin/faults/presets`
42
+ - `GET /__admin/ui`
43
+
44
+ For HTTP services, use `x-mockingbird-namespace` (or the documented credential/path carrier) so
45
+ parallel tests do not share state. Admin state, journal, metrics and fault-preset endpoints are
46
+ designed for assertions and diagnosis by consuming test suites.
47
+
48
+ ## Report a mismatch or missing capability
49
+
50
+ Follow the [agent reporting contract](https://github.com/crvouga/mockingbird/blob/main/docs/REPORTING_ISSUES.md). Include package version,
51
+ operation/command, a minimal redacted request, actual mock result, expected oracle result or vendor
52
+ documentation, and whether the mismatch appears in the matrix. Never include keys, tokens,
53
+ customer data, prompts, PHI, card data, or unredacted recordings.
54
+
55
+ Service key: `meta`.
package/README.md CHANGED
@@ -1,3 +1,79 @@
1
- # Temporary Holding Version
1
+ # @crvouga/mockingbird-service-meta
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > Familiar calls. Faithful echoes. Part of [Mockingbird](https://github.com/crvouga/mockingbird).
4
+
5
+ Stateful Meta Graph v26 mock for server-side Conversions API events and marketing reporting. It
6
+ preserves privacy-safe hashed user fields, event deduplication, ambiguous writes, Graph errors,
7
+ campaign objects, dated insights, breakdowns, and cursor pagination without contacting Meta.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install -D @crvouga/mockingbird-service-meta
13
+ ```
14
+
15
+ ESM only. Node >= 22 or Bun >= 1.2. Serve with `npx mockingbird-meta serve`, `createServer` from
16
+ `./server`, or mount `createRuntime()` in any Fetch-compatible process.
17
+
18
+ ## Usage
19
+
20
+ Make the Graph origin injectable and point it at the mock. Any non-empty synthetic Bearer token or
21
+ `access_token` query value authenticates unless `/__admin/settings` restricts tokens.
22
+
23
+ ```ts
24
+ import { createRuntime } from "@crvouga/mockingbird-service-meta"
25
+
26
+ const meta = createRuntime()
27
+ const response = await meta.fetch(new Request("http://meta.test/v26.0/pixel_test/events", {
28
+ method: "POST",
29
+ headers: { authorization: "Bearer meta_test", "content-type": "application/json" },
30
+ body: JSON.stringify({ data: [{
31
+ event_name: "Purchase",
32
+ event_time: Math.floor(Date.now() / 1000),
33
+ event_id: "order_42",
34
+ action_source: "website",
35
+ user_data: { em: ["a".repeat(64)] },
36
+ custom_data: { currency: "USD", value: 42 },
37
+ }] }),
38
+ }))
39
+ // → {events_received: 1, messages: [], fbtrace_id: "trace_…"}
40
+ ```
41
+
42
+ ### Routes
43
+
44
+ | Route | Behaviour |
45
+ | --- | --- |
46
+ | `POST /v26.0/:pixelId/events` | Accepts CAPI `data[]` and `test_event_code`; keeps event name/time/id, action source, source URL, hashed user data and custom data. Repeated `event_id` values are acknowledged without a second stored event. Events older than seven days, future events, malformed hashes and invalid bodies receive Graph error envelopes. |
47
+ | `GET /v26.0/:accountId/insights` | Filters seeded or admin-inserted insight rows by inclusive JSON `time_range`, paginates with `limit`/`after`, and includes `country` when requested as a breakdown. |
48
+ | `GET /v26.0/:objectId` | Reads seeded/admin-inserted campaign, ad-set, or ad records. |
49
+
50
+ Seed fixtures are `act_mockingbird`, `cmp_mockingbird`, `set_mockingbird`, and `ad_mockingbird`,
51
+ with three dated insight rows from 2026-01-01 through 2026-01-03.
52
+
53
+ ### Admin and faults
54
+
55
+ `GET /__admin/events` returns the namespace's privacy-safe stored requests. `GET/PUT
56
+ /__admin/settings` controls `accessTokens` and `maxEventAgeSeconds`. Standard `/__admin/state`
57
+ routes seed or edit `events`, `objects`, and `insights` directly.
58
+
59
+ Presets: `expired_token`, `rate_limited`, `server_error`, `partial_event_acceptance`,
60
+ `accepted_then_drop`, and `slow`. The ambiguous-write preset persists the event before dropping the
61
+ connection; retrying the same `event_id` remains deduplicated.
62
+
63
+ Namespaces use `x-mockingbird-namespace`, `/__admin/ns/<name>/…`, or credential mapping through
64
+ `PUT /__admin/credentials`.
65
+
66
+ ## API
67
+
68
+ The main entry exports `MetaAPI`, `MetaState`, `createRuntime`, `META_NAMESPACE`, `META_PRESETS`,
69
+ `DEFAULT_SETTINGS`, `accessTokenCredential`, the generated `document`, `operationIds`,
70
+ `supportedOperationIds`, and their public option/state/event/insight types.
71
+ `@crvouga/mockingbird-service-meta/server` exports
72
+ `createServer`, `serveTarget`, `DEFAULT_PORT`, and server option/result types.
73
+
74
+ ## Deliberately not modelled
75
+
76
+ - Real ad delivery, attribution calculation, hashing of plaintext PII, app-secret proof, or OAuth.
77
+ - Campaign/ad-set/ad mutation, creatives, audiences, pixels configuration, dashboards, or billing.
78
+ - The complete Insights fields/breakdowns matrix and asynchronous report jobs.
79
+ - Meta-side probabilistic matching: the mock records only the supplied synthetic hashed fields.
package/SUPPORT.md ADDED
@@ -0,0 +1,13 @@
1
+ # Meta Marketing and Conversions APIs (Mockingbird subset) — operation support
2
+
3
+ Generated from `openapi.yaml`; do not edit by hand.
4
+
5
+ - operations in spec: **3**
6
+ - supported by the mock: **3**
7
+ - parity enabled: **2**
8
+
9
+ | operationId | route | mock | parity | notes |
10
+ | --- | --- | --- | --- | --- |
11
+ | `PostPixelEvents` | `POST /v26.0/{pixel_id}/events` | ✅ supported | ❌ disabled | Sends conversion events to a real pixel |
12
+ | `GetInsights` | `GET /v26.0/{account_id}/insights` | ✅ supported | ✅ | |
13
+ | `GetMarketingObject` | `GET /v26.0/{object_id}` | ✅ supported | ✅ | |