Skip to content

feat(platform): forward events the SDK doesn't know to onEvent - #329

Merged
amitbardos merged 1 commit into
amitb/platform-asyncapi-syncfrom
amitb/platform-forward-unknown-events
Oct 14, 2026
Merged

amitbardos merged 1 commit into
amitb/platform-asyncapi-syncfrom
amitb/platform-forward-unknown-events

Conversation

@amitbardos

Copy link
Copy Markdown
Contributor

Stacked on #313 (base amitb/platform-asyncapi-sync).

This changes the original event filtering Oz (@ozsay) wrote, so it needs his agreement before merging.

What

Today the builder session registers a Socket.IO handler only for the event names generated into the SDK, so a new backend event is dropped until a partner upgrades. Now:

  • Known app events keep their own handlers, unchanged.
  • socket.onAny forwards any other name to onEvent, except session events (app.snapshot, session.ended) and room.* notices (a new notice has no error code, so it's still dropped).
  • Same {room, data} envelope validation, per-app routing and protocol_error handling as known events. discard() now also calls offAny().
  • Unknown events arrive as a new PlatformEvent member: { type: "unknown"; name: string; appId: string; data: Record<string, unknown> }.

Why type: "unknown" and not type: string

The original plan was an OtherToolCall-style member with type: string & {}. In TypeScript 5.9 that breaks narrowing for every known event: with string & {}, event.type === "message.updated" doesn't narrow at all. With plain string it narrows to that event plus the catch-all, so event.data.message becomes unknown. Either way existing partner code like event.data.message.content stops compiling. A literal "unknown" discriminant keeps known types narrowing exactly. It can't clash with a real event because backend event names are always dotted (noun.verb). The name goes in name. Once a partner upgrades, the event arrives under its own type.

This is a type-level breaking change (an exhaustive switch needs case "unknown"), so it should ship in 0.2.0. It's noted in the CHANGELOG.

Tests

New unit tests: an unknown event reaches only its app's onEvent, known, session and room.* names aren't double-delivered through onAny, a malformed unknown frame fails only its app, and close() calls offAny. New type tests: an unknown event's data needs a check before use, and known types still narrow.

npm test   (packages/platform)
  test:types  tsc --noEmit -p tsconfig.type-tests.json   ✓
  test:unit   Test Files 2 passed (2)   Tests 44 passed (44)
  docs        typedoc   markdown generated at ./docs
  test:package  tests 5  pass 5  fail 0
npm run check:events   builder.events.generated.ts is up to date.
npm run create-docs    ✓ Post-processing complete!
npm run lint (root)    eslint .   clean

🤖 Generated with Claude Code

A new backend event now reaches partners when the service deploys it, as
{ type: "unknown", name, appId, data }, instead of being dropped until they
upgrade. Session events and room.* notices are still not forwarded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/sdk@0.8.53-pr.329.cce6621

Prefer not to change any import paths? Install using npm alias so your code still imports @base44/sdk:

npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.53-pr.329.cce6621"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/sdk": "npm:@base44-preview/sdk@0.8.53-pr.329.cce6621"
  }
}

Preview published to npm registry — try new features instantly!

@github-actions

Copy link
Copy Markdown

🚀 Package Preview Available! (@base44/platform)


Install this PR's preview build with npm:

npm i @base44-preview/platform@0.2.0-pr.329.cce6621

Prefer not to change any import paths? Install using npm alias so your code still imports @base44/platform:

npm i "@base44/platform@npm:@base44-preview/platform@0.2.0-pr.329.cce6621"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/platform": "npm:@base44-preview/platform@0.2.0-pr.329.cce6621"
  }
}

Preview published to npm registry — try new features instantly!

@amitbardos
amitbardos merged commit 04e627a into amitb/platform-asyncapi-sync Oct 14, 2026
4 checks passed
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.

1 participant