Repository navigation
feat(platform)!: one getSession pass-through, and the socket path from the session - #317
Closed
amitbardos wants to merge 1 commit into
Closed
amitbardos wants to merge 1 commit into
amitbardos wants to merge 1 commit into
Conversation
…ough builder.init() takes getSession, which returns the Create socket session body unchanged. The socket opens at the session's socket_url and socket_path on the first connect(), and moves when a renewed session has a different address. createPlatformClient() takes no options; socketUrl, getSessionToken and PlatformClientOptions are gone. An invalid session rejects connect() with session_unavailable. Version 0.2.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/sdk@0.8.53-pr.317.4163f48Prefer not to change any import paths? Install using npm alias so your code still imports npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.53-pr.317.4163f48"Or add it to your {
"dependencies": {
"@base44/sdk": "npm:@base44-preview/sdk@0.8.53-pr.317.4163f48"
}
}
Preview published to npm registry — try new features instantly! |
Contributor
Author
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.
Stacked on #313. Merge that first.
The browser now passes one function,
getSession, instead ofsocketUrlandgetSessionToken. The socket path comes from the session instead of the hard-coded/ws/socket.io/.What changed
getSessiononbuilder.init(), next toonError:() => Promise<SocketSession>, whereSocketSessionis{ session_token, socket_url, socket_path }. The SDK reads those three keys and ignores the others (session_id,expires_in).getSessionis called everywheregetSessionTokenwas called before: the first connect, renewal aftersession.endedwith reasonexpired, and the single renewal after aconnection_deniedon a cached token (tokenFresh/retryDeniedare unchanged). The 20-second timeout and the cancellation inauthenticate()are unchanged.connect().init()no longer creates one, because the address is known only after the first session. Transport reconnects keep using the cached session.socket_urlorsocket_path, the SDK doesn't call the old socket's auth callback. It removes the old socket's listeners, disconnects it, opens a socket at the new address, and theconnecthandler rejoins every active subscription, each with a fresh snapshot. An address that hasn't changed reuses the socket.socket_urlis checked as before (an HTTP(S) origin with no credentials, path, query or fragment).socket_pathmust be an absolute path with no query or fragment, and can't start with//. The token must be a non-empty string.CHANGELOG.mdis new: the package had nowhere to keep release notes, and the publish workflow's GitHub Release body is generic. It has the breaking change and a before/after snippet.README.md, unit, type and package tests are updated.SocketSessionis listed on the builder reference page (types-to-expose.json,appended-articles.json), so its fields are documented.Decisions
createPlatformClient()takes no arguments. WithsocketUrlandgetSessionTokengone, there are no options left, and an empty options object would only be noise. TypeScript callers that still pass{ socketUrl, getSessionToken }get a compile error ("Expected 0 arguments") instead of having the values silently ignored. If an option is needed later, an optional parameter can be added without a breaking change.PlatformClientOptionsis removed.session_unavailable, whether the token is missing, thesocket_urlis invalid or thesocket_pathis invalid.connect()rejects with it andonErrorreceives it. The code already meant that "your session endpoint gave the SDK nothing usable", and a new code would be one more case for partners to handle. The JSDoc says it's retryable, except that an invalid field has to be fixed on the server first. NoTypeErroris thrown any more.Tests
PATH=/opt/homebrew/bin:$PATH npm testinpackages/platform:npm run check:events:npm run create-docs(run afternpm test):npm run lintat the root is clean.New unit tests: the path is taken from the session, extra keys in the body are ignored, renewal at a new address moves the socket and rejoins both subscriptions, a failed renewal stops the socket without authenticating it, a late session after
close()opens nothing, and 11 invalid bodies (bad token, URL or path) aresession_unavailablewith no socket created. The real-handshake test (socket.test.js) connects on/live/socket.io/from the session body.Needs attention
package.jsonis already at 0.2.0. Ifmanual-publish.ymlis run withversion: 0.2.0,npm version 0.2.0fails with "Version not changed", and withminorit would publish 0.3.0. I didn't touch the workflow. Before publishing, either add--allow-same-versionto the workflow or setpackage.jsonback to 0.1.0 and publish withminor.🤖 Generated with Claude Code