@base44-preview/sdk 0.8.46-pr.273.f546cdd → 0.8.46-pr.275.00d1266

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.
@@ -7,7 +7,6 @@
7
7
  *
8
8
  * @example
9
9
  * ```typescript
10
- * // Declare message types for a deployed actor
11
10
  * declare module "@base44/sdk" {
12
11
  * interface ActorRegistry {
13
12
  * ChatRoom: {
@@ -36,26 +35,15 @@ type ToServerFor<N extends string> = N extends keyof ActorRegistry ? ActorRegist
36
35
  /** Options for {@link ActorRef.connect}. */
37
36
  export interface ActorConnectOptions {
38
37
  /**
39
- * The connection id, used as the actor's `conn.id`. Supply a stable value,
40
- * such as one persisted per tab, so a reconnect reuses the same server-side
41
- * identity. Omit it for an auto-generated per-connection id.
38
+ * The connection id, used as 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.
42
41
  */
43
42
  id?: string;
44
43
  }
45
44
  /** Handle for one listener registered via {@link Connection.subscribe}. */
46
45
  export interface ActorSubscription {
47
- /**
48
- * Removes this listener. Other listeners on the same connection, and the
49
- * connection itself, stay live. To close the connection as well, call
50
- * {@link Connection.close}.
51
- *
52
- * @example
53
- * ```typescript
54
- * // Stop listening without closing the connection
55
- * const sub = conn.subscribe((msg) => console.log(msg));
56
- * sub.unsubscribe();
57
- * ```
58
- */
46
+ /** Remove this listener; other listeners and the socket stay live. */
59
47
  unsubscribe(): void;
60
48
  }
61
49
  /**
@@ -64,62 +52,17 @@ export interface ActorSubscription {
64
52
  * socket has been opened, so there's no pre-connect state to guard against.
65
53
  */
66
54
  export interface Connection<N extends string = string> {
67
- /** The connection id, which is the value the actor sees as `conn.id`. */
55
+ /** The connection id (the value the actor sees as `conn.id`). */
68
56
  readonly id: string;
69
- /**
70
- * Registers a listener for messages sent by the actor. Any number of
71
- * listeners can be registered on one connection, and each receives every
72
- * message.
73
- *
74
- * The callback payload is typed when the actor is declared in
75
- * {@link ActorRegistry}, and is `unknown` otherwise.
76
- *
77
- * @param callback - Called with each message the actor sends to this client.
78
- * @returns An {@link ActorSubscription} that removes this one listener.
79
- *
80
- * @example
81
- * ```typescript
82
- * // Listen for messages from the actor
83
- * const sub = conn.subscribe((msg) => {
84
- * if (msg.type === "message") console.log(msg.text);
85
- * });
86
- * ```
87
- */
57
+ /** Register a message listener. Multiple are allowed; returns a per-listener unsubscribe. */
88
58
  subscribe(callback: (data: ToClientFor<N>) => void): ActorSubscription;
89
- /**
90
- * Sends a message to the actor.
91
- *
92
- * Messages sent before the socket finishes opening are buffered and flushed
93
- * on open. Messages sent after {@link close} are dropped silently.
94
- *
95
- * The payload is typed when the actor is declared in {@link ActorRegistry},
96
- * and is `unknown` otherwise.
97
- *
98
- * @param data - The message to send to the actor.
99
- *
100
- * @example
101
- * ```typescript
102
- * // Send a message to the actor
103
- * conn.send({ type: "message", text: "hi" });
104
- * ```
105
- */
59
+ /** Send a message. Buffered by the socket until it's open; dropped after
60
+ * {@link close}. */
106
61
  send(data: ToServerFor<N>): void;
107
62
  /**
108
- * Closes the connection, tearing down the socket, the heartbeat, and every
109
- * listener registered on it. Safe to call more than once.
110
- *
111
- * A connection also closes itself when it fails permanently. See
112
- * {@link ActorRef.connect} for how to recover from that.
113
- *
114
- * @example
115
- * ```typescript
116
- * // Close when the view that opened the connection goes away.
117
- * useEffect(() => {
118
- * const conn = base44.actors.ChatRoom(roomId).connect();
119
- * conn.subscribe(setMessage);
120
- * return () => conn.close();
121
- * }, [roomId]);
122
- * ```
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}.
123
66
  */
124
67
  close(): void;
125
68
  }
@@ -129,38 +72,13 @@ export interface Connection<N extends string = string> {
129
72
  */
130
73
  export interface ActorRef<N extends string = string> {
131
74
  /**
132
- * Opens the WebSocket to this actor instance and returns the
133
- * {@link Connection}. Idempotent while the connection is open, so calling it
134
- * again returns the same connection rather than opening a second socket.
135
- *
136
- * The returned connection is usable straight away. Messages passed to
137
- * {@link Connection.send} before the socket finishes opening are buffered and
138
- * flushed on open.
139
- *
140
- * A connection that fails permanently, for example because the actor doesn't
141
- * exist or the caller isn't allowed to connect, closes itself and reports the
142
- * error to the client's `onError` handler. Call `connect()` again once the
143
- * cause is fixed to get a fresh {@link Connection}, then re-subscribe, as
144
- * listeners do not carry over.
145
- *
146
- * @param options - Connection options. See {@link ActorConnectOptions}.
147
- * @returns A live {@link Connection} to this actor instance.
148
- *
149
- * @example
150
- * ```typescript
151
- * // Connect to an actor instance
152
- * const conn = base44.actors.ChatRoom("room-1").connect();
153
- * ```
154
- *
155
- * @example
156
- * ```typescript
157
- * // Reuse a stable connection id so a reconnect keeps the same
158
- * // server-side identity.
159
- * let id = sessionStorage.getItem("chat-conn-id") ?? crypto.randomUUID();
160
- * sessionStorage.setItem("chat-conn-id", id);
75
+ * Open the WebSocket and return the {@link Connection}. Idempotent while the
76
+ * connection is open.
161
77
  *
162
- * const conn = base44.actors.ChatRoom("room-1").connect({ id });
163
- * ```
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.
164
82
  */
165
83
  connect(options?: ActorConnectOptions): Connection<N>;
166
84
  }
@@ -173,62 +91,16 @@ export interface ActorClient<N extends string = string> {
173
91
  (instanceId: string): ActorRef<N>;
174
92
  }
175
93
  /**
176
- * Actors module for real-time messaging with Cloudflare Durable Object-backed
94
+ * The actors module provides access to Cloudflare Durable Object-backed
177
95
  * Actors deployed by the Base44 platform.
178
96
  *
179
- * An Actor is a named server-side object with persistent state. Each instance
180
- * is addressed by an id, so `base44.actors.ChatRoom("room-1")` and
181
- * `base44.actors.ChatRoom("room-2")` are separate instances with separate
182
- * state. Clients open a WebSocket to an instance and exchange messages with it.
183
- *
184
- * This module provides:
185
- * - Per-instance WebSocket connections, opened with {@link ActorRef.connect}
186
- * - Message listeners, registered with {@link Connection.subscribe}
187
- * - Message sending, with {@link Connection.send}
188
- * - Automatic reconnection with backoff, including recovery from half-open
189
- * sockets that stop delivering messages without emitting a close event
190
- * - End-to-end typing of message payloads through {@link ActorRegistry}
191
- *
192
- * This module is available to use with a client in anonymous and user
193
- * authentication modes. Connecting anonymously requires a browser environment.
194
- *
195
- * Connections stay open until you call {@link Connection.close}, so close them
196
- * when the view that opened them goes away.
197
- *
198
- * @example
199
97
  * ```typescript
200
- * // Open a connection to one instance of the ChatRoom actor.
201
- * const conn = base44.actors.ChatRoom("room-1").connect();
202
- *
203
- * const sub = conn.subscribe((msg) => {
204
- * console.log(msg);
205
- * });
206
- *
98
+ * const conn = base44.actors.MyActor("room-1").connect();
99
+ * const sub = conn.subscribe((msg) => console.log(msg)); // typed via ActorRegistry
207
100
  * conn.send({ type: "message", text: "hi" });
208
- *
209
- * // Later, when the view goes away.
210
101
  * sub.unsubscribe();
211
102
  * conn.close();
212
103
  * ```
213
- *
214
- * @example
215
- * ```typescript
216
- * // Register the actor to type both directions of the conversation.
217
- * declare module "@base44/sdk" {
218
- * interface ActorRegistry {
219
- * ChatRoom: {
220
- * toClient: { type: "joined" | "message"; from?: string; text?: string };
221
- * toServer: { type: "message"; text: string };
222
- * };
223
- * }
224
- * }
225
- *
226
- * const conn = base44.actors.ChatRoom("room-1").connect();
227
- * conn.subscribe((msg) => {
228
- * // msg is typed as the toClient union.
229
- * if (msg.type === "message") console.log(msg.text);
230
- * });
231
- * ```
232
104
  */
233
105
  export type ActorsModule = {
234
106
  [K in AllActorNames]: K extends keyof ActorRegistry ? ActorClient<string & K> : ActorClient;
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export type AppPublicSettings = "private_with_login" | "public_with_login" | "public_without_login" | "workspace_with_login" | string;
6
6
  /**
7
- * The app's public configuration, as returned by {@link AppModule.getPublicSettings}.
7
+ * The app's public configuration, as returned by `getPublicSettings()`.
8
8
  */
9
9
  export interface AppPublicSettingsResponse {
10
10
  /** The app's ID. */
@@ -334,6 +334,7 @@ export interface AuthModule {
334
334
  *
335
335
  * @example
336
336
  * ```typescript
337
+ * // Invite a user and handle failure
337
338
  * try {
338
339
  * await base44.auth.inviteUser('newuser@example.com', 'user');
339
340
  * console.log('Invitation sent successfully!');
@@ -464,6 +465,7 @@ export interface AuthModule {
464
465
  *
465
466
  * @example
466
467
  * ```typescript
468
+ * // Request a password reset email
467
469
  * try {
468
470
  * await base44.auth.resetPasswordRequest('user@example.com');
469
471
  * console.log('Password reset email sent!');
@@ -485,6 +487,7 @@ export interface AuthModule {
485
487
  *
486
488
  * @example
487
489
  * ```typescript
490
+ * // Complete a password reset with the emailed token
488
491
  * try {
489
492
  * await base44.auth.resetPassword({
490
493
  * resetToken: 'token-from-email',
@@ -509,6 +512,7 @@ export interface AuthModule {
509
512
  *
510
513
  * @example
511
514
  * ```typescript
515
+ * // Change the password for a signed-in user
512
516
  * try {
513
517
  * await base44.auth.changePassword({
514
518
  * userId: 'user-123',
@@ -52,6 +52,8 @@ export type ConnectorApiResponsePhase = "not_sent" | "responded" | "timed_out" |
52
52
  /**
53
53
  * A request to forward to a metered connector's API through the Base44 proxy.
54
54
  */
55
+ /** A value acceptable as a query parameter on {@link ConnectorApiRequest.query}. */
56
+ export type ConnectorApiQueryValue = string | number | boolean | Array<string | number>;
55
57
  export interface ConnectorApiRequest {
56
58
  /** HTTP method for the upstream request. Defaults to `'GET'`. */
57
59
  method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD";
@@ -69,7 +71,7 @@ export interface ConnectorApiRequest {
69
71
  */
70
72
  path: string;
71
73
  /** Query parameters. Merged into the request URL alongside any already present in {@link path}. */
72
- query?: Record<string, string | number | boolean | Array<string | number>>;
74
+ query?: Record<string, ConnectorApiQueryValue>;
73
75
  /** Extra request headers. Only headers the connector explicitly allows are forwarded; the rest are dropped. */
74
76
  headers?: Record<string, string>;
75
77
  /** JSON request body. Ignored for `GET` and `HEAD`. */
@@ -370,6 +370,7 @@ export type IntegrationsModule = {
370
370
  *
371
371
  * @example
372
372
  * ```typescript
373
+ * // Summarise text with an LLM
373
374
  * const response = await base44.integrations.Core.InvokeLLM({
374
375
  * prompt: 'Explain quantum computing',
375
376
  * model: 'gpt_5'
@@ -382,6 +383,7 @@ export type IntegrationsModule = {
382
383
  *
383
384
  * @example
384
385
  * ```typescript
386
+ * // Call a custom integration endpoint
385
387
  * const result = await base44.integrations.custom.call(
386
388
  * 'github',
387
389
  * 'get:/repos/{owner}/{repo}',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.46-pr.273.f546cdd",
3
+ "version": "0.8.46-pr.275.00d1266",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",