[SPIKE option C] EventDevice | EventEdge union (INTER-2457) - #279
[SPIKE option C] EventDevice | EventEdge union (INTER-2457)#279JuroUhlar wants to merge 10 commits into
Conversation
INTER-2457 option C. Node Event is EventDevice | EventEdge.
🦋 Changeset detectedLatest commit: a6d3efa The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Coverage report
Show new covered files 🐣
Test suite run success101 tests passing in 29 suites. Report generated by 🧪jest coverage report action from a6d3efa Show full coverage report
|
There was a problem hiding this comment.
Pull request overview
Spike PR updating the Node SDK’s generated OpenAPI types to model Event as a source-discriminated union (EventDevice | EventEdge) and adding support for the new Automation Intelligence endpoint (POST /v4/edge) via a new makeEdgeEvent() client method.
Changes:
- Add
makeEdgeEvent()API client method plus publicEdgeRequest/EventEdgeexports. - Regenerate OpenAPI schema/types to include
/edgeand to modelEventas a discriminated union (source: device | edge). - Update/add tests, examples, and webhook mock payloads for the new typing and endpoint.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit-tests/urlUtilsTests.spec.ts | Adds URL construction test for POST /edge. |
| tests/unit-tests/serverApiClientTests.spec.ts | Adds runtime-guard test for makeEdgeEvent missing body. |
| tests/mocked-responses-tests/mocked-responses-data/webhook/webhook_event.json | Adds source discriminator to webhook mock. |
| tests/mocked-responses-tests/makeEdgeEventTests.spec.ts | Adds mocked-response coverage for makeEdgeEvent success and error cases. |
| sync.sh | Notes that Node consumes the union schema when syncing OpenAPI. |
| src/types.ts | Exposes EventEdge/EdgeRequest types and extends FingerprintApi with makeEdgeEvent. |
| src/serverApiClient.ts | Implements makeEdgeEvent() and documents Automation Intelligence usage. |
| src/index.ts | Re-exports EdgeRequest and EventEdge from the public entrypoint. |
| src/generatedApiTypes.ts | Regenerated API types: adds /edge, introduces EventDevice/EventEdge, and makes Event a union. |
| resources/fingerprint-server-api.yaml | Updates embedded OpenAPI schema for /edge and Event discriminator. |
| readme.md | Adds README example for makeEdgeEvent(). |
| example/makeEdgeEvent.mjs | Adds runnable example for makeEdgeEvent(). |
| example/getEvent.mjs | Narrows on event.source before accessing device-only fields. |
| .changeset/add-make-edge-event.md | Adds changeset entry for the new API surface. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| --- | ||
| "@fingerprint/node-sdk": minor | ||
| --- | ||
|
|
||
| Add `makeEdgeEvent()` to collect Automation Intelligence via `POST /v4/edge` |
| // Collect Automation Intelligence for a request intercepted at the edge | ||
| client | ||
| .makeEdgeEvent({ | ||
| method: 'GET', |
|
@copilot review |
🚀 Following releases will be created using changesets from this PR:@fingerprint/node-sdk@7.8.0Minor Changes
|
SPIKE. Do not merge. Option C: Node keeps a
sourcediscriminated union. Generated from openapi#465. Not the earlier all-SDK union spike (#278).EventisEventDevice | EventEdge.getEvent/ search / unseal / webhook need asourcenarrow beforeidentification.hydrateEvent()insertssource: devicewhen the key is absent (stored JSON / sealed payloads that predatesource). Never rewritesedge.POST /edge,EventEdge,EdgeRequest."source": "device".sync.shstill downloadsfingerprint-server-api-v4.yaml(the union schema).Discussion point: types break is intentional
This is the only SDK where Event is not flat. Existing
event.identificationcall sites fail typecheck until narrowed. Runtime JSON is unchanged. UsehydrateEventwhen replaying stored events that omitsource.Known: property order
Node object keys are named. Reorder in the schema does not affect callers.