@base44-preview/sdk 0.8.63-pr.385.da33077 → 0.8.63-pr.388.2dbcc27

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
@@ -1,12 +1,14 @@
1
1
  /**
2
- * Type-only base class for Actors.
2
+ * Type definitions for the actor base class.
3
3
  *
4
- * Import and extend this in your actor files:
5
- * import { Actor } from "@base44/sdk";
6
- * export class MyActor extends Actor { ... }
4
+ * Actor files don't import `Actor` from this package. They import it from the
5
+ * actor runtime instead:
6
+ * import { Actor } from "base44:runtime/actors";
7
+ * export default class MyActor extends Actor { ... }
7
8
  *
8
- * At deploy time the bundler replaces this import with the compiled
9
- * Cloudflare Durable Object implementation — this file provides types only.
9
+ * This class's runtime methods, such as `broadcast()` and `schedule()`, throw. An
10
+ * actor that imports `Actor` from `npm:@base44/sdk` bundles this class instead of
11
+ * the runtime's, and a bare `@base44/sdk` import fails to bundle.
10
12
  */
11
13
  import type { Base44Client } from "./client";
12
14
  /** Who a client is, verified by the platform: a logged-in user or an anonymous visitor. */
package/dist/actor.js CHANGED
@@ -1,12 +1,14 @@
1
1
  /**
2
- * Type-only base class for Actors.
2
+ * Type definitions for the actor base class.
3
3
  *
4
- * Import and extend this in your actor files:
5
- * import { Actor } from "@base44/sdk";
6
- * export class MyActor extends Actor { ... }
4
+ * Actor files don't import `Actor` from this package. They import it from the
5
+ * actor runtime instead:
6
+ * import { Actor } from "base44:runtime/actors";
7
+ * export default class MyActor extends Actor { ... }
7
8
  *
8
- * At deploy time the bundler replaces this import with the compiled
9
- * Cloudflare Durable Object implementation — this file provides types only.
9
+ * This class's runtime methods, such as `broadcast()` and `schedule()`, throw. An
10
+ * actor that imports `Actor` from `npm:@base44/sdk` bundles this class instead of
11
+ * the runtime's, and a bare `@base44/sdk` import fails to bundle.
10
12
  */
11
13
  /** Throw from a callable method to refuse the call with a 4xx status. */
12
14
  export class ActorError extends Error {
@@ -132,7 +132,7 @@ export interface Base44Client {
132
132
  appLogs: AppLogsModule;
133
133
  /** {@link AppModule | App module} for reading the app's own public configuration. */
134
134
  app: AppModule;
135
- /** {@link ActorsModule | Actors module} for connecting to actor sessions and exchanging messages with actors. */
135
+ /** {@link ActorsModule | Actors module} for connecting to actor sessions, exchanging messages, and calling an actor's methods. */
136
136
  actors: ActorsModule;
137
137
  /** {@link AuthModule | Auth module} for user authentication and management. */
138
138
  auth: AuthModule;
@@ -229,7 +229,7 @@ export interface Base44Client {
229
229
  * @throws {Error} When accessed without providing a serviceToken during client creation
230
230
  */
231
231
  readonly asServiceRole: {
232
- /** {@link ServiceRoleActorsModule | Actors module} for sending requests to actor sessions as the app's server code. */
232
+ /** [Actors module](/developers/references/sdk/docs/type-aliases/actors) for calling an actor's methods as the app's server code. */
233
233
  actors: ServiceRoleActorsModule;
234
234
  /** {@link AgentsModule | Agents module} with elevated permissions. */
235
235
  agents: AgentsModule;
@@ -1,10 +1,12 @@
1
1
  /**
2
- * Maps actor names to their incoming and outgoing message types.
2
+ * Maps actor names to their message types and method types.
3
3
  *
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.
4
+ * Extend this interface when you want typed actor messages and method calls without generating
5
+ * 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
+ * - `methods`: Defines the actor's methods that you can call on a session. Each entry's argument
9
+ * and return types become the types of the matching [method call](#session-methods).
8
10
  *
9
11
  * To generate types from deployed actors, use the
10
12
  * [`types generate`](/developers/references/cli/commands/types-generate) CLI command.
@@ -147,22 +149,38 @@ export interface Connection<N extends string = string> {
147
149
  /**
148
150
  * Represents a reference to an actor session, identified by actor name and session ID.
149
151
  *
150
- * Call {@linkcode ActorConnectable.connect | connect()} to open the WebSocket and get a [connection](/developers/backend/resources/actors/overview#connections),
151
- * or call one of the actor's callable methods by name, such as `ref.kick({ userId })`: it runs
152
- * the actor's method with your identity, even when no client is connected, and resolves to
153
- * its return value. A refusal rejects with a `Base44Error` carrying the actor's status (404 for
154
- * a method the actor doesn't list in `static callable`).
152
+ * Call {@linkcode ActorConnectable.connect | connect()} to open a WebSocket and get a
153
+ * [connection](/developers/backend/resources/actors/overview#connections) that sends and receives
154
+ * messages.
155
155
  *
156
- * A call takes one argument, any JSON value: pass several values as an object, such as
157
- * `ref.videoReady({ id, url })`, or an array. Further arguments are dropped, so `ref.m(a, b)`
158
- * sends only `a`. Arguments and the reply are JSON-encoded: a `Date` arrives as a string,
159
- * `undefined` is dropped (`null` inside an array), and functions, `Map` and `Set` values don't
160
- * survive. A request is at most 64 KB and calls are rate-limited per caller.
156
+ * You can also call a method you wrote in the actor by name, such as a `kick()` method that
157
+ * removes a user from a chat room. The method runs on the session even when no client is
158
+ * connected, and the call resolves to its return value.
159
+ *
160
+ * A method call takes one argument, which can be any JSON value. To pass several values, wrap
161
+ * them in an object. The actor receives the caller's identity, which is the current user, or an
162
+ * anonymous visitor when the client uses anonymous authentication. If the actor refuses the call,
163
+ * the promise rejects with a
164
+ * [`Base44Error`](/developers/references/sdk/getting-started/work-with-sdk#error-handling).
165
+ *
166
+ * To type a method's argument and return value, add the actor's `methods` to
167
+ * {@linkcode ActorRegistry}. To learn which methods an actor accepts, how arguments are
168
+ * encoded, and the size and rate limits, see
169
+ * [callable methods](/developers/backend/resources/actors/reference#callable-methods).
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * // Connect to a session and listen for messages
174
+ * const conn = base44.actors.chatRoom("session-1").connect();
175
+ * conn.subscribe((msg) => {
176
+ * console.log(msg);
177
+ * });
178
+ * ```
161
179
  *
162
180
  * @example
163
181
  * ```typescript
164
182
  * // Call a method on a session
165
- * const { kicked } = await base44.actors.chatRoom("session-1").kick({ userId });
183
+ * const { kicked } = await base44.actors.chatRoom("session-1").kick({ userId: "user-123" });
166
184
  * ```
167
185
  */
168
186
  export interface ActorConnectable<N extends string = string> {
@@ -190,13 +208,13 @@ export type ActorRef<N extends string = string> = ActorConnectable<N> & ActorMet
190
208
  /**
191
209
  * Represents a reference to an actor session for server code running with the
192
210
  * [service role](/developers/references/sdk/getting-started/client#service-role).
193
- * Server code can't hold a connection, so it only calls methods; the actor sees the
194
- * `service` identity.
211
+ * Server code can't hold a connection, so it can only call the actor's methods. The actor
212
+ * receives the `service` identity.
195
213
  *
196
214
  * @example
197
215
  * ```typescript
198
- * // Tell a user's session that their video is ready
199
- * await base44.asServiceRole.actors.VideoRoom(userId).videoReady({ id });
216
+ * // Remove a user from a chat room from server code
217
+ * await base44.asServiceRole.actors.chatRoom("session-1").kick({ userId: "user-123" });
200
218
  * ```
201
219
  */
202
220
  export type ServiceRoleActorRef<N extends string = string> = ActorMethods<N>;
@@ -209,7 +227,7 @@ export type ServiceRoleActorsModule = {
209
227
  /**
210
228
  * Selects a session for a named actor.
211
229
  *
212
- * TypeScript infers message types when you register the actor in
230
+ * TypeScript infers message types and method types when you register the actor in
213
231
  * {@linkcode ActorRegistry}. {@linkcode ActorNameRegistry}
214
232
  * provides autocomplete for actor names only.
215
233
  */
@@ -220,7 +238,7 @@ export interface ActorClient<N extends string = string> {
220
238
  * Clients that specify the same actor name and session ID join the same session.
221
239
  *
222
240
  * @param instanceId - Session ID that identifies which session to connect to.
223
- * @returns A reference to the actor session.
241
+ * @returns A [reference to the actor session](#session-methods).
224
242
  *
225
243
  * @example
226
244
  * ```typescript
@@ -242,17 +260,20 @@ export interface ActorClient<N extends string = string> {
242
260
  * - Manage connections: {@link ActorConnectable.connect | Open} and {@link Connection.close | close} a WebSocket connection to a session.
243
261
  * - Exchange messages: {@link Connection.send | Send} and {@link Connection.subscribe | listen} for messages to and from an actor.
244
262
  * - Manage subscriptions: {@link Connection.subscribe | Subscribe} and {@link ActorSubscription.unsubscribe | unsubscribe} from actor messages without closing the connection.
245
- * - Call methods: run one of an actor's callable methods on a session, without connecting.
263
+ * - Call methods: {@link ActorConnectable | Run} a method you wrote in the actor on a session, without connecting to it.
246
264
  *
247
265
  * For a sample flow, see
248
266
  * [connect a client to a session](/developers/backend/resources/actors/sample-flows#connect-a-client-to-a-session).
249
267
  *
250
268
  * ## Authentication modes
251
269
  *
252
- * This module is available to use with a client in anonymous or user authentication mode. Access it
253
- * through `base44.actors`. In
254
- * [service role authentication mode](/developers/references/sdk/getting-started/client#service-role),
255
- * `base44.asServiceRole.actors` only calls methods.
270
+ * This module is available to use with a client in all authentication modes:
271
+ *
272
+ * - **Anonymous or user authentication** (`base44.actors`): Opens connections to sessions,
273
+ * exchanges messages, and calls an actor's methods.
274
+ * - **[Service role authentication](/developers/references/sdk/getting-started/client#service-role)**
275
+ * (`base44.asServiceRole.actors`): Calls an actor's methods. Server code can't hold a
276
+ * connection, so it can't connect to a session.
256
277
  *
257
278
  * The actor receives each client's [identity](/developers/backend/resources/actors/reference#connections)
258
279
  * when the client connects or calls a method. A client that hasn't logged in is anonymous, a client that
@@ -398,6 +398,8 @@ export interface CheckoutMount {
398
398
  *
399
399
  * ## Authentication modes
400
400
  *
401
+ * This module is available to use with a client in all authentication modes:
402
+ *
401
403
  * - **Anonymous or user authentication** (`base44.payments`): Preloads and mounts embedded checkouts, completes PayPal checkouts, and lists the current user's own purchases.
402
404
  * - **Service role authentication** (`base44.asServiceRole.payments`): Creates checkouts, lists any purchase, refunds payments, and changes subscriptions. Use the [service role methods](#service-role-methods) in backend functions.
403
405
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.63-pr.385.da33077",
3
+ "version": "0.8.63-pr.388.2dbcc27",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",