Repository navigation
Conversation
|
Contributor
Coverage report
Test suite run success140 tests passing in 33 suites. Report generated by 🧪jest coverage report action from d780992 Show full coverage report
|
Events stored before `source` was added (sealed results, webhook bodies) don't have it. Check `source === 'edge'`; anything else is a device event.
The API always returns `source`, so `Event` keeps it required on device events. `Webhook` makes it optional: webhook bodies stored before `source` existed don't have it, and resent webhooks deliver the stored body as-is.
Contributor
pnpm exec changesetto create a changeset. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Schema review prototype, do not merge. This is to test the schema
Eventsplit (EventDevice | EventEdge) as part of reviewing koala#18895.INTER-2457 | koala#18895 | schema from openapi#494 @
78d51f2Why
This checks that the Node SDK can take the
EventDevice | EventEdgeunion from openapi#494 with only type changes and no runtime change, so users can see from the types that edge events never haveidentification.Things to note
dist/index.mjsanddist/index.cjsare byte-identical to amainbuild, andWebhookis a type-only export. 140 tests, lint, all typechecks andtest:dtspass.Eventkeepssourcerequired; the newWebhookmakes it optional on device events. The API always returnssource. Stored webhook bodies from beforesourceexisted don't have it, and koala's resend delivers the stored body as-is. There's no runtime hydration, matching the Slack idea of keepingsourceoptional only on the webhook type.unsealEventsResponse/parseEventsResponsereturn the strictEvent, but a sealed result saved beforesourceexisted has none. Accepted, because sealed results are normally unsealed right away.Change outline
Public types (
src/types.ts,src/index.ts):What users write now:
const event = await client.getEvent(id, { ruleset_id }) - console.log(event.rule_action?.type) + if (event.source !== 'edge') console.log(event.rule_action?.type) - const event = webhookBody as Event + const webhook = webhookBody as Webhook + if (webhook.source !== 'edge') console.log(webhook.identification?.visitor_id)Files: