@base44-preview/sdk 0.8.63-pr.388.2dbcc27 → 0.8.63-pr.389.0df9331

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,14 +1,12 @@
1
1
  /**
2
- * Type definitions for the actor base class.
2
+ * Type-only base class for Actors.
3
3
  *
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 { ... }
4
+ * Import and extend this in your actor files:
5
+ * import { Actor } from "@base44/sdk";
6
+ * export class MyActor extends Actor { ... }
8
7
  *
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.
8
+ * At deploy time the bundler replaces this import with the compiled
9
+ * Cloudflare Durable Object implementation — this file provides types only.
12
10
  */
13
11
  import type { Base44Client } from "./client";
14
12
  /** Who a client is, verified by the platform: a logged-in user or an anonymous visitor. */
package/dist/actor.js CHANGED
@@ -1,14 +1,12 @@
1
1
  /**
2
- * Type definitions for the actor base class.
2
+ * Type-only base class for Actors.
3
3
  *
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 { ... }
4
+ * Import and extend this in your actor files:
5
+ * import { Actor } from "@base44/sdk";
6
+ * export class MyActor extends Actor { ... }
8
7
  *
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.
8
+ * At deploy time the bundler replaces this import with the compiled
9
+ * Cloudflare Durable Object implementation — this file provides types only.
12
10
  */
13
11
  /** Throw from a callable method to refuse the call with a 4xx status. */
14
12
  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, exchanging messages, and calling an actor's methods. */
135
+ /** {@link ActorsModule | Actors module} for connecting to actor sessions and exchanging messages with actors. */
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
- /** [Actors module](/developers/references/sdk/docs/type-aliases/actors) for calling an actor's methods as the app's server code. */
232
+ /** {@link ServiceRoleActorsModule | Actors module} for sending requests to actor sessions as the app's server code. */
233
233
  actors: ServiceRoleActorsModule;
234
234
  /** {@link AgentsModule | Agents module} with elevated permissions. */
235
235
  agents: AgentsModule;
@@ -1,12 +1,10 @@
1
1
  /**
2
- * Maps actor names to their message types and method types.
2
+ * Maps actor names to their incoming and outgoing message types.
3
3
  *
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).
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.
10
8
  *
11
9
  * To generate types from deployed actors, use the
12
10
  * [`types generate`](/developers/references/cli/commands/types-generate) CLI command.
@@ -149,38 +147,22 @@ export interface Connection<N extends string = string> {
149
147
  /**
150
148
  * Represents a reference to an actor session, identified by actor name and session ID.
151
149
  *
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.
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`).
155
155
  *
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
- * ```
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.
179
161
  *
180
162
  * @example
181
163
  * ```typescript
182
164
  * // Call a method on a session
183
- * const { kicked } = await base44.actors.chatRoom("session-1").kick({ userId: "user-123" });
165
+ * const { kicked } = await base44.actors.chatRoom("session-1").kick({ userId });
184
166
  * ```
185
167
  */
186
168
  export interface ActorConnectable<N extends string = string> {
@@ -208,13 +190,13 @@ export type ActorRef<N extends string = string> = ActorConnectable<N> & ActorMet
208
190
  /**
209
191
  * Represents a reference to an actor session for server code running with the
210
192
  * [service role](/developers/references/sdk/getting-started/client#service-role).
211
- * Server code can't hold a connection, so it can only call the actor's methods. The actor
212
- * receives the `service` identity.
193
+ * Server code can't hold a connection, so it only calls methods; the actor sees the
194
+ * `service` identity.
213
195
  *
214
196
  * @example
215
197
  * ```typescript
216
- * // Remove a user from a chat room from server code
217
- * await base44.asServiceRole.actors.chatRoom("session-1").kick({ userId: "user-123" });
198
+ * // Tell a user's session that their video is ready
199
+ * await base44.asServiceRole.actors.VideoRoom(userId).videoReady({ id });
218
200
  * ```
219
201
  */
220
202
  export type ServiceRoleActorRef<N extends string = string> = ActorMethods<N>;
@@ -227,7 +209,7 @@ export type ServiceRoleActorsModule = {
227
209
  /**
228
210
  * Selects a session for a named actor.
229
211
  *
230
- * TypeScript infers message types and method types when you register the actor in
212
+ * TypeScript infers message types when you register the actor in
231
213
  * {@linkcode ActorRegistry}. {@linkcode ActorNameRegistry}
232
214
  * provides autocomplete for actor names only.
233
215
  */
@@ -238,7 +220,7 @@ export interface ActorClient<N extends string = string> {
238
220
  * Clients that specify the same actor name and session ID join the same session.
239
221
  *
240
222
  * @param instanceId - Session ID that identifies which session to connect to.
241
- * @returns A [reference to the actor session](#session-methods).
223
+ * @returns A reference to the actor session.
242
224
  *
243
225
  * @example
244
226
  * ```typescript
@@ -260,20 +242,17 @@ export interface ActorClient<N extends string = string> {
260
242
  * - Manage connections: {@link ActorConnectable.connect | Open} and {@link Connection.close | close} a WebSocket connection to a session.
261
243
  * - Exchange messages: {@link Connection.send | Send} and {@link Connection.subscribe | listen} for messages to and from an actor.
262
244
  * - Manage subscriptions: {@link Connection.subscribe | Subscribe} and {@link ActorSubscription.unsubscribe | unsubscribe} from actor messages without closing the connection.
263
- * - Call methods: {@link ActorConnectable | Run} a method you wrote in the actor on a session, without connecting to it.
245
+ * - Call methods: run one of an actor's callable methods on a session, without connecting.
264
246
  *
265
247
  * For a sample flow, see
266
248
  * [connect a client to a session](/developers/backend/resources/actors/sample-flows#connect-a-client-to-a-session).
267
249
  *
268
250
  * ## Authentication modes
269
251
  *
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.
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.
277
256
  *
278
257
  * The actor receives each client's [identity](/developers/backend/resources/actors/reference#connections)
279
258
  * when the client connects or calls a method. A client that hasn't logged in is anonymous, a client that
@@ -398,8 +398,6 @@ 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
- *
403
401
  * - **Anonymous or user authentication** (`base44.payments`): Preloads and mounts embedded checkouts, completes PayPal checkouts, and lists the current user's own purchases.
404
402
  * - **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.
405
403
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.63-pr.388.2dbcc27",
3
+ "version": "0.8.63-pr.389.0df9331",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",