Skip to content

feat(sdk-generator): emit PlatformClient.forApp for durable app sessions - #53

Merged
calvin-archastro merged 2 commits into
mainfrom
feat/sdk-forApp-factory
Jul 13, 2026
Merged

feat(sdk-generator): emit PlatformClient.forApp for durable app sessions#53
calvin-archastro merged 2 commits into
mainfrom
feat/sdk-forApp-factory

Conversation

@calvin-archastro

Copy link
Copy Markdown
Contributor

Summary

Updates the TypeScript SDK generator so durable client-side sessions are a first-class PlatformClient.forApp factory, not hand-edits to generated index.ts.

Generator changes

client-emitter.ts (when publishable_key scheme exists):

  • Import forApp + types from hand-maintained ./user-session.js
  • Emit static forApp(options: ForAppOptions): AppPlatformClient { return forApp(options); }
  • Re-export only app-needed types: AppPlatformClient, ForAppOptions, SessionStorage, StoredSession

index.ts / generateMainIndex:

  • Re-export those session types from ./client.js
  • Does not export PasswordlessAuth, free forApp, sockets, or other internals

Companion SDK PR

ArchAstro/archastro-js#40 — hand-maintained user-session.ts, pure generated barrel, ArchAgent-facing forApp API.

Public surface (apps)

PlatformClient.forApp({ publishableKey, storage, baseUrl })
// + types: SessionStorage, StoredSession, AppPlatformClient, ForAppOptions

Everything else (OTP implementation, refresh wiring, createPlatformSocket) stays behind forApp.

Testing

  • npm test -- __tests__/backends/typescript.test.ts (80 passed)

Scope

packages/sdk-generator only (TypeScript backend).

Wire generated PlatformClient.forApp to hand-maintained user-session.ts
so mobile/SPA durable session (storage, passwordless, auto-refresh) stays
behind one factory. Re-export only the session types apps need; keep
PasswordlessAuth and free forApp off the public barrel.
Match SDK rename: hand-maintained module is app-session.ts; re-export
AppSession type instead of StoredSession.
@calvin-archastro
calvin-archastro merged commit 12cbfef into main Jul 13, 2026
2 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