@base44-preview/sdk 0.8.53-pr.289.e840a51 → 0.8.53-pr.310.48fbad6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/actor.d.ts CHANGED
@@ -25,8 +25,8 @@ export interface Storage {
25
25
  get<T>(key: string): Promise<T | undefined>;
26
26
  put(key: string, value: unknown): Promise<void>;
27
27
  delete(key: string): Promise<boolean>;
28
- /** Deletes all persisted storage for the session. A later connection starts
29
- * with empty storage, the same as a new session. */
28
+ /** Wipe the room's entire persisted storage (match-end cleanup). Safe: a
29
+ * later rejoin re-bootstraps exactly like a brand-new room. */
30
30
  deleteAll(): Promise<void>;
31
31
  }
32
32
  /**
@@ -1,23 +1,15 @@
1
1
  /**
2
- * Maps actor names to their incoming and outgoing message types.
2
+ * Extend this interface to add typed `subscribe` callbacks and `send` payloads
3
+ * for your deployed Actors.
3
4
  *
4
- * Extend this interface when you want typed actor
5
- * messages without generating types with the CLI:
6
- * - `toServer`: Defines incoming messages that a client sends to the actor.
7
- * - `toClient`: Defines outgoing messages that the actor sends to connected clients.
8
- *
9
- * To generate types from deployed actors, use the
10
- * [`types generate`](/developers/references/cli/commands/types-generate) CLI command.
11
- *
12
- * To learn how incoming and outgoing messages work, see
13
- * [message types](/developers/backend/resources/actors/overview#message-types).
5
+ * This is separate from {@link ActorNameRegistry} (which is auto-generated
6
+ * by `base44 types generate`), so there are no conflicts.
14
7
  *
15
8
  * @example
16
9
  * ```typescript
17
- * // Type messages for an actor
18
10
  * declare module "@base44/sdk" {
19
11
  * interface ActorRegistry {
20
- * chatRoom: {
12
+ * ChatRoom: {
21
13
  * toClient: { type: "joined" | "left" | "message"; userId?: string; from?: string; text?: string };
22
14
  * toServer: { type: "message"; text: string };
23
15
  * };
@@ -28,11 +20,8 @@
28
20
  export interface ActorRegistry {
29
21
  }
30
22
  /**
31
- * Lists actor names when your project includes types generated by the CLI
32
- * with [`types generate`](/developers/references/cli/commands/types-generate).
33
- *
34
- * The generated names provide autocomplete for deployed actors. To define
35
- * incoming and outgoing message types manually, augment {@linkcode ActorRegistry}.
23
+ * Auto-populated by `base44 types generate` with the names of your deployed actors.
24
+ * Do not edit this interface manually — use {@link ActorRegistry} for message types.
36
25
  */
37
26
  export interface ActorNameRegistry {
38
27
  }
@@ -43,171 +32,75 @@ type ToClientFor<N extends string> = N extends keyof ActorRegistry ? ActorRegist
43
32
  type ToServerFor<N extends string> = N extends keyof ActorRegistry ? ActorRegistry[N] extends {
44
33
  toServer: infer O;
45
34
  } ? O : unknown : unknown;
46
- /**
47
- * Configures the connection that {@linkcode ActorRef.connect | connect()} opens.
48
- */
35
+ /** Options for {@link ActorRef.connect}. */
49
36
  export interface ActorConnectOptions {
50
37
  /**
51
- * Connection ID that the actor receives as `conn.id`.
52
- *
53
- * To let the actor recognize a client when it reconnects, use a stable
54
- * value, such as an ID stored per browser tab. If you omit this property, the
55
- * SDK generates a new connection ID.
38
+ * The connection id — becomes the actor's `conn.id`. Supply a stable value
39
+ * (e.g. persisted per tab) so a reconnect reuses the same server-side
40
+ * identity; omit for an auto-generated per-connection id.
56
41
  */
57
42
  id?: string;
58
43
  }
59
- /**
60
- * Represents a listener for messages from the actor, registered with
61
- * {@linkcode Connection.subscribe | subscribe()}.
62
- */
44
+ /** Handle for one listener registered via {@link Connection.subscribe}. */
63
45
  export interface ActorSubscription {
64
- /**
65
- * Removes this listener. Other listeners and the socket stay open.
66
- *
67
- * @example
68
- * ```typescript
69
- * // Remove a listener
70
- * sub.unsubscribe();
71
- * ```
72
- */
46
+ /** Remove this listener; other listeners and the socket stay live. */
73
47
  unsubscribe(): void;
74
48
  }
75
49
  /**
76
- * Represents a client's WebSocket connection to an actor session, returned after calling
77
- * [`connect()`](#connect). The socket queues messages you send before it opens.
78
- *
79
- * Learn more about
80
- * [connections](/developers/backend/resources/actors/reference#connections).
50
+ * A live connection to an actor instance, returned by {@link ActorRef.connect}.
51
+ * `subscribe`/`send` are always valid — you only get a `Connection` once the
52
+ * socket has been opened, so there's no pre-connect state to guard against.
81
53
  */
82
54
  export interface Connection<N extends string = string> {
83
- /** Connection ID that the actor receives as `conn.id`. */
55
+ /** The connection id (the value the actor sees as `conn.id`). */
84
56
  readonly id: string;
85
- /**
86
- * Registers a listener for messages from the actor.
87
- *
88
- * You can register multiple listeners on the same connection.
89
- *
90
- * @param callback - Callback that runs for each message the actor sends to this connection.
91
- * @returns A subscription handle. Call `unsubscribe()` on it to remove this listener without closing the socket.
92
- *
93
- * @example
94
- * ```typescript
95
- * // Listen for messages from the actor
96
- * const sub = conn.subscribe((msg) => {
97
- * console.log(msg);
98
- * });
99
- *
100
- * // Stop listening without closing the socket.
101
- * sub.unsubscribe();
102
- * ```
103
- */
57
+ /** Register a message listener. Multiple are allowed; returns a per-listener unsubscribe. */
104
58
  subscribe(callback: (data: ToClientFor<N>) => void): ActorSubscription;
105
- /**
106
- * Sends a message to the actor.
107
- *
108
- * The socket queues messages until it opens. When you call {@linkcode Connection.close | close()},
109
- * the socket drops any further sent messages.
110
- *
111
- * @param data - Message to send to the actor. The type comes from {@linkcode ActorRegistry} when you register the actor there.
112
- *
113
- * @example
114
- * ```typescript
115
- * // Send a message to the actor
116
- * conn.send({ type: "message", text: "Hello" });
117
- * ```
118
- */
59
+ /** Send a message. Buffered by the socket until it's open; dropped after
60
+ * {@link close}. */
119
61
  send(data: ToServerFor<N>): void;
120
62
  /**
121
- * Closes the connection and removes all listeners.
122
- *
123
- * You can call this method more than once. A connection also closes itself
124
- * when it fails permanently.
125
- *
126
- * @example
127
- * ```typescript
128
- * // Close the connection
129
- * conn.close();
130
- * ```
63
+ * Tear down the socket, heartbeat, and all listeners. Safe to call more
64
+ * than once. A connection also closes itself when it fails permanently —
65
+ * see {@link ActorRef.connect}.
131
66
  */
132
67
  close(): void;
133
68
  }
134
69
  /**
135
- * Represents a reference to an actor session, identified by actor name and session ID.
136
- *
137
- * Call {@linkcode ActorRef.connect | connect()} to open the WebSocket and get a [Connection](#returns).
70
+ * A handle to one actor instance — `base44.actors.MyActor(id)`. Call
71
+ * {@link connect} to open the socket and get a {@link Connection}.
138
72
  */
139
73
  export interface ActorRef<N extends string = string> {
140
74
  /**
141
- * Creates or returns the [Connection](#returns) for this session.
142
- *
143
- * Calling `connect()` again on the same session reference returns the same
144
- * connection until it closes.
145
- *
146
- * For a sample flow, see
147
- * [connect a client to a session](/developers/backend/resources/actors/sample-flows#connect-a-client-to-a-session).
75
+ * Open the WebSocket and return the {@link Connection}. Idempotent while the
76
+ * connection is open.
148
77
  *
149
- * @param options - Optional connection settings, such as a stable connection ID.
150
- * @returns The [Connection](#returns) for this actor session.
151
- *
152
- * @example
153
- * ```typescript
154
- * // Connect to a session
155
- * const conn = base44.actors.chatRoom("session-1").connect({ id: "tab-1" });
156
- * ```
78
+ * A connection that fails permanently (for example, the actor doesn't exist
79
+ * or the caller isn't allowed to connect) closes itself and reports the
80
+ * error to the client's `onError` handler. Call `connect()` again after
81
+ * fixing the cause to get a fresh {@link Connection}, and re-subscribe.
157
82
  */
158
83
  connect(options?: ActorConnectOptions): Connection<N>;
159
84
  }
160
85
  /**
161
- * Selects a session for a named actor.
162
- *
163
- * TypeScript infers message types when you register the actor in
164
- * {@linkcode ActorRegistry}. {@linkcode ActorNameRegistry}
165
- * provides autocomplete for actor names only.
86
+ * Client for a single named Actor — call it with an instance id to get an
87
+ * {@link ActorRef}. Typed automatically when the actor is registered in
88
+ * {@link ActorRegistry}.
166
89
  */
167
90
  export interface ActorClient<N extends string = string> {
168
- /**
169
- * Gets a reference to an actor session.
170
- *
171
- * Clients that specify the same actor name and session ID join the same session.
172
- *
173
- * @param instanceId - Session ID that identifies which session to connect to.
174
- * @returns A reference to the actor session.
175
- *
176
- * @example
177
- * ```typescript
178
- * // Select a session
179
- * const session = base44.actors.chatRoom("session-1");
180
- * ```
181
- */
182
91
  (instanceId: string): ActorRef<N>;
183
92
  }
184
93
  /**
185
- * Actors module for connecting a client to an [actor](/developers/backend/resources/actors/overview) session and exchanging messages.
186
- *
187
- * An actor is a long-running backend process that multiple clients connect to simultaneously. A session
188
- * is a running instance of an actor, identified by the actor name and a session ID. Each
189
- * session manages its own state, storage, and client connections independently.
190
- *
191
- * The actors module supports the following functionality:
192
- *
193
- * - {@linkcode ActorRef.connect | connect()}: Open a WebSocket connection to a session.
194
- * - {@linkcode Connection.subscribe | subscribe()}: Receive messages from the actor.
195
- * - {@linkcode ActorSubscription.unsubscribe | unsubscribe()}: Stop receiving messages from the actor without closing the connection.
196
- * - {@linkcode Connection.send | send()}: Send messages to the actor.
197
- * - {@linkcode Connection.close | close()}: Close the WebSocket connection to the actor.
94
+ * The actors module provides access to Cloudflare Durable Object-backed
95
+ * Actors deployed by the Base44 platform.
198
96
  *
199
- * For a sample flow, see
200
- * [connect a client to a session](/developers/backend/resources/actors/sample-flows#connect-a-client-to-a-session).
201
- *
202
- * ## Authentication modes
203
- *
204
- * This module is available to use with a client in anonymous or user authentication mode. Access it
205
- * through `base44.actors`. It isn't available in
206
- * [service role authentication mode](/developers/references/sdk/getting-started/client#service-role).
207
- *
208
- * The actor receives each client's [identity](/developers/backend/resources/actors/reference#connections)
209
- * when the client connects. A client that hasn't logged in connects as anonymous, and a client that
210
- * has [logged in](/developers/references/sdk/docs/interfaces/auth) connects as authenticated.
97
+ * ```typescript
98
+ * const conn = base44.actors.MyActor("room-1").connect();
99
+ * const sub = conn.subscribe((msg) => console.log(msg)); // typed via ActorRegistry
100
+ * conn.send({ type: "message", text: "hi" });
101
+ * sub.unsubscribe();
102
+ * conn.close();
103
+ * ```
211
104
  */
212
105
  export type ActorsModule = {
213
106
  [K in AllActorNames]: K extends keyof ActorRegistry ? ActorClient<string & K> : ActorClient;
@@ -19,7 +19,7 @@ export type IntegrationEndpointFunction = (data: Record<string, any>) => Promise
19
19
  * ```typescript
20
20
  * await base44.integrations.Core.InvokeLLM({
21
21
  * prompt: 'Explain quantum computing',
22
- * model: 'gpt_5'
22
+ * model: 'gemini_3_8_flash'
23
23
  * });
24
24
  * ```
25
25
  *
@@ -43,9 +43,9 @@ export interface InvokeLLMParams {
43
43
  prompt: string;
44
44
  /** Optionally specify a model to override the app-level model setting for this specific call.
45
45
  *
46
- * Options: `"gpt_5_mini"`, `"gemini_3_flash"`, `"gpt_5_4"`, `"gpt_5_6_sol"`, `"gpt_5_6_luna"`, `"gemini_3_1_pro"`, `"claude_sonnet_4_6"`, `"claude_opus_4_6"`, `"claude_opus_4_7"`, `"claude_opus_4_8"`, `"claude-sonnet-5"`
46
+ * Options: `"gemini_3_8_flash"`, `"gpt_6_luna"`, `"claude-sonnet-5"`, `"claude_opus_5_5"`, `"gpt_6_sol"`, `"gpt_6_astra"`, `"claude_fable_5_1"`, `"glm_5_2"`, `"gemini_3_1_pro"`, `"gpt_5_4"`, `"claude_sonnet_4_6"`, `"claude_opus_4_6"`, `"claude_opus_4_7"`, `"claude_opus_4_8"`, `"claude_opus_5"`, `"gpt_5_6_terra"`, `"gpt_5_6_sol"`, `"gpt_5_6_luna"`
47
47
  */
48
- model?: 'gpt_5_mini' | 'gemini_3_flash' | 'gpt_5_4' | 'gpt_5_6_sol' | 'gpt_5_6_luna' | 'gemini_3_1_pro' | 'claude_sonnet_4_6' | 'claude_opus_4_6' | 'claude_opus_4_7' | 'claude_opus_4_8' | 'claude-sonnet-5';
48
+ model?: 'gemini_3_8_flash' | 'gpt_6_luna' | 'claude-sonnet-5' | 'claude_opus_5_5' | 'gpt_6_sol' | 'gpt_6_astra' | 'claude_fable_5_1' | 'glm_5_2' | 'gemini_3_1_pro' | 'gpt_5_4' | 'claude_sonnet_4_6' | 'claude_opus_4_6' | 'claude_opus_4_7' | 'claude_opus_4_8' | 'claude_opus_5' | 'gpt_5_6_terra' | 'gpt_5_6_sol' | 'gpt_5_6_luna';
49
49
  /** If set to `true`, the LLM will use Google Search, Maps, and News to gather real-time context before answering.
50
50
  * @default false
51
51
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.53-pr.289.e840a51",
3
+ "version": "0.8.53-pr.310.48fbad6",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",