feat(realtime): add realtime command and handler scaffolding#555
Draft
ImriKochWix wants to merge 11 commits into
Draft
feat(realtime): add realtime command and handler scaffolding#555ImriKochWix wants to merge 11 commits into
ImriKochWix wants to merge 11 commits into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.1.1-pr.555.77b65cbPrefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.1.1-pr.555.77b65cb"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.1.1-pr.555.77b65cb"
}
}
Preview published to npm registry — try new features instantly! |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
new.ts used project.root but readAllRealtimeHandlers uses dirname(configPath), causing handlers to be created at realtime/ instead of base44/realtime/. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
'base44' is the CLI package name and has no exported types. @base44/sdk now exports RealtimeHandler and Conn for type-checking, and the bundler rewrites the import to the CF shim at deploy time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- base44 types generate now includes realtime handlers in types.d.ts - RealtimeHandlerNameRegistry: auto-registers handler names (no manual declare needed) - RealtimeHandlerRegistry: compiled from schema.jsonc inbound/outbound JSON schemas - Add schema.jsonc support to realtime-handler resource reader - Update test fixture with ChatRoom schema and assertions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Detect @base44/sdk vs @base44-preview/sdk from project's package.json
so declare module targets the correct package name
- Add export {} to generated types.d.ts to ensure module context,
preventing ambient module from shadowing the SDK package types
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove unused RealtimeHandlerConfig type alias - Replace [^]* regex with [\s\S]* (Biome noEmptyCharacterClassInRegex) - Auto-format long lines per Biome formatter rules Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The dedicated endpoint calls ensure_cfw_backend and uses force_per_function so the bundler runs applyRealtimeCompat instead of the per-app path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
schema.jsonc is now a catalog of named messages (inbound/outbound maps of
message-name -> full JSON Schema, like entities) plus optional shared `types`.
compileRealtimeHandler emits one named interface per message (direction- and
handler-prefixed to avoid collisions) + shared types, and composes the
inbound/outbound unions in the registry.
Removes the /\{([\s\S]*)\}/ body-scrape, which produced invalid TS whenever
json-schema-to-typescript emitted more than one declaration (unions with
$defs). Because every message is a single flat object, that multi-declaration
case can no longer arise.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…lient/toServer The old names were written from the client's perspective, so handler code read backwards (InMsg = Reg["outbound"]) and every reader had to do the double-negative. toClient/toServer read correctly from both sides: Reg["toServer"] is what the handler receives, Reg["toClient"] is what it sends. Generated interface prefixes follow (GameRoomToClientInit). Breaking for schema.jsonc files and the generated registry shape; done now while there are zero external users. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Description
Adds first-class support for realtime handlers to the Base44 CLI. Introduces a new
realtimeresource (scaffold, config discovery, deploy) plus abase44 realtimecommand group (new,deploy), wires realtime handlers into the unifiedbase44 deployflow, and extends TypeScript type generation to emit strongly-typed message catalogs (RealtimeHandlerRegistry,RealtimeHandlerNameRegistry) from each handler'sschema.jsonc.Related Issue
None
Type of Change
Changes Made
realtime-handlercore resource (src/core/resources/realtime-handler/):schema.ts(Zod schemas for config, message catalog, and deploy response),config.ts(discoversentry.tshandlers in named subfolders, reads optionalschema.jsonc, guards against duplicate/misplaced handlers),api.ts(PUT to/realtime-handlers/{name}),deploy.ts(sequential deploy with per-handler status reporting), andresource.ts(unifiedResourcebinding).base44 realtimecommand group (src/cli/commands/realtime/):new <HandlerName>scaffolds aRealtimeHandlerclass extending@base44/sdk, anddeploy [names...]deploys selected or all handlers with progress output and non-zero exit on failure.realtimeDir(default\"realtime\") to the project config schema,realtimeHandlerstoProjectData, and read/deploy wiring inconfig.ts,deploy.ts, and the top-leveldeploycommand summary.types/toClient/toServer) in a single pass into named interfaces and discriminated unions, injecting thetypediscriminant per message and rewriting#/types/Xrefs; emitsRealtimeHandlerRegistryandRealtimeHandlerNameRegistry. Also detects the SDK package name (@base44/sdkvs@base44-preview/sdk) and addsexport {};so the generatedtypes.d.tsaugments rather than replaces the SDK module.tests/core/types-realtime.spec.ts, updatedtests/cli/types_generate.spec.ts, and added aChatRoomrealtime fixture (entry.ts+schema.jsonc).Testing
Checklist
Additional Notes
The realtime resource mirrors the existing
functionresource conventions (multi-file payloads, sequential deploy,Resource<T>interface) for consistency. Handler message schemas use atoClient/toServernaming convention (renamed from an earlierinbound/outboundwithin this PR). Consider adding adocs/topic guide and updating AGENTS.md to document the new resource before release.🤖 Generated by Claude | 2026-07-05 21:30 UTC | 77b65cb