Skip to content

[SPIKE option C] EventDevice | EventEdge union (INTER-2457) - #279

Draft
JuroUhlar wants to merge 10 commits into
mainfrom
spike/INTER-2457-option-c
Draft

[SPIKE option C] EventDevice | EventEdge union (INTER-2457)#279
JuroUhlar wants to merge 10 commits into
mainfrom
spike/INTER-2457-option-c

Conversation

@JuroUhlar

@JuroUhlar JuroUhlar commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

SPIKE. Do not merge. Option C: Node keeps a source discriminated union. Generated from openapi#465. Not the earlier all-SDK union spike (#278).

  • Event is EventDevice | EventEdge. getEvent / search / unseal / webhook need a source narrow before identification.
  • hydrateEvent() inserts source: device when the key is absent (stored JSON / sealed payloads that predate source). Never rewrites edge.
  • Additive POST /edge, EventEdge, EdgeRequest.
  • Webhook mock includes "source": "device".
  • sync.sh still downloads fingerprint-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.identification call sites fail typecheck until narrowed. Runtime JSON is unchanged. Use hydrateEvent when replaying stored events that omit source.

Known: property order

Node object keys are named. Reorder in the schema does not affect callers.

@changeset-bot

changeset-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest 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

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
98.31% (+0.16% 🔼)
174/177
🟢 Branches
97.3% (+0.46% 🔼)
108/111
🟢 Functions 100% 38/38
🟢 Lines
98.28% (+0.16% 🔼)
171/174
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢 hydrateEvent.ts 100% 100% 100% 100%

Test suite run success

101 tests passing in 29 suites.

Report generated by 🧪jest coverage report action from a6d3efa

Show full coverage report
St File % Stmts % Branch % Funcs % Lines Uncovered Line #s
🟢 All files 98.3 97.29 100 98.27
🟢  src 98.6 98.9 100 98.58
🔴   ...edApiTypes.ts 0 0 0 0
🟢   hydrateEvent.ts 100 100 100 100
🔴   index.ts 0 0 0 0
🟢   sealedResults.ts 100 100 100 100
🟢   ...rApiClient.ts 96.36 97.36 100 96.36 412,416
🟢   types.ts 100 100 100 100
🟢   urlUtils.ts 100 100 100 100
🟢   webhook.ts 100 100 100 100
🟢  src/errors 97.05 90 100 96.96
🟢   apiErrors.ts 100 100 100 100
🟢   ...orResponse.ts 100 100 100 100
🟢   toError.ts 87.5 88.88 100 87.5 21
🟢   unsealError.ts 100 50 100 100 10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 public EdgeRequest / EventEdge exports.
  • Regenerate OpenAPI schema/types to include /edge and to model Event as 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.

Comment thread src/generatedApiTypes.ts Outdated
Comment thread resources/fingerprint-server-api.yaml Outdated
Comment on lines +1 to +5
---
"@fingerprint/node-sdk": minor
---

Add `makeEdgeEvent()` to collect Automation Intelligence via `POST /v4/edge`
Comment thread readme.md
Comment on lines +111 to +114
// Collect Automation Intelligence for a request intercepted at the edge
client
.makeEdgeEvent({
method: 'GET',
@JuroUhlar

Copy link
Copy Markdown
Contributor Author

@copilot review

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Following releases will be created using changesets from this PR:

@fingerprint/node-sdk@7.8.0

Minor Changes

  • Add makeEdgeEvent() to collect Automation Intelligence via POST /v4/edge (0c41131)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants