@base44-preview/sdk 0.8.49-pr.289.78ea614 → 0.8.49-pr.289.92846f0
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/modules/actors.types.d.ts +24 -33
- package/package.json +1 -1
|
@@ -30,7 +30,7 @@ export interface ActorRegistry {
|
|
|
30
30
|
* with [`types generate`](/developers/references/cli/commands/types-generate).
|
|
31
31
|
*
|
|
32
32
|
* The generated names provide autocomplete for deployed actors. To define
|
|
33
|
-
* incoming and outgoing message types manually, augment
|
|
33
|
+
* incoming and outgoing message types manually, augment [ActorRegistry](#actorregistry).
|
|
34
34
|
*/
|
|
35
35
|
export interface ActorNameRegistry {
|
|
36
36
|
}
|
|
@@ -42,7 +42,7 @@ type ToServerFor<N extends string> = N extends keyof ActorRegistry ? ActorRegist
|
|
|
42
42
|
toServer: infer O;
|
|
43
43
|
} ? O : unknown : unknown;
|
|
44
44
|
/**
|
|
45
|
-
* Options for
|
|
45
|
+
* Options for [ActorRef.connect](#connect).
|
|
46
46
|
*/
|
|
47
47
|
export interface ActorConnectOptions {
|
|
48
48
|
/**
|
|
@@ -58,7 +58,7 @@ export interface ActorConnectOptions {
|
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Represents an outgoing-message listener registered with
|
|
61
|
-
*
|
|
61
|
+
* [Connection.subscribe](#subscribe).
|
|
62
62
|
*/
|
|
63
63
|
export interface ActorSubscription {
|
|
64
64
|
/**
|
|
@@ -69,7 +69,7 @@ export interface ActorSubscription {
|
|
|
69
69
|
/**
|
|
70
70
|
* Represents a client's WebSocket connection to an actor session.
|
|
71
71
|
*
|
|
72
|
-
*
|
|
72
|
+
* [ActorRef.connect](#connect) returns this object while the socket connects.
|
|
73
73
|
* The socket buffers messages sent during connection setup until it opens.
|
|
74
74
|
*/
|
|
75
75
|
export interface Connection<N extends string = string> {
|
|
@@ -87,28 +87,28 @@ export interface Connection<N extends string = string> {
|
|
|
87
87
|
/**
|
|
88
88
|
* Sends an incoming message to the actor.
|
|
89
89
|
*
|
|
90
|
-
* The socket buffers messages until it opens. After
|
|
90
|
+
* The socket buffers messages until it opens. After [close](#close), the socket
|
|
91
91
|
* drops further sends.
|
|
92
92
|
*
|
|
93
|
-
* @param data - Incoming message to send. Typed through
|
|
93
|
+
* @param data - Incoming message to send. Typed through [ActorRegistry](#actorregistry) when configured.
|
|
94
94
|
*/
|
|
95
95
|
send(data: ToServerFor<N>): void;
|
|
96
96
|
/**
|
|
97
97
|
* Closes the connection and removes all listeners.
|
|
98
98
|
*
|
|
99
99
|
* Safe to call more than once. A connection also closes itself when it fails
|
|
100
|
-
* permanently. See
|
|
100
|
+
* permanently. See [ActorRef.connect](#connect) for how to open a fresh connection.
|
|
101
101
|
*/
|
|
102
102
|
close(): void;
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* Represents an actor session selected by actor name and session ID.
|
|
106
106
|
*
|
|
107
|
-
* Call
|
|
107
|
+
* Call [connect](#connect) to open the WebSocket and get a [Connection](#connection).
|
|
108
108
|
*/
|
|
109
109
|
export interface ActorRef<N extends string = string> {
|
|
110
110
|
/**
|
|
111
|
-
* Creates or returns the
|
|
111
|
+
* Creates or returns the [Connection](#connection) for this session.
|
|
112
112
|
*
|
|
113
113
|
* Repeated calls return the same connection until it closes. After a permanent
|
|
114
114
|
* failure, such as a missing actor or denied connection, fix the cause and call
|
|
@@ -118,15 +118,15 @@ export interface ActorRef<N extends string = string> {
|
|
|
118
118
|
* for a sample flow.
|
|
119
119
|
*
|
|
120
120
|
* @param options - Optional connection settings, such as a stable connection ID.
|
|
121
|
-
* @returns The
|
|
121
|
+
* @returns The [Connection](#connection) for this actor session.
|
|
122
122
|
*/
|
|
123
123
|
connect(options?: ActorConnectOptions): Connection<N>;
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* Selects a session for a named actor.
|
|
127
127
|
*
|
|
128
|
-
* Typed automatically when the actor is registered in
|
|
129
|
-
*
|
|
128
|
+
* Typed automatically when the actor is registered in [ActorRegistry](#actorregistry) or
|
|
129
|
+
* [ActorNameRegistry](#actornameregistry).
|
|
130
130
|
*/
|
|
131
131
|
export interface ActorClient<N extends string = string> {
|
|
132
132
|
/**
|
|
@@ -140,36 +140,27 @@ export interface ActorClient<N extends string = string> {
|
|
|
140
140
|
(instanceId: string): ActorRef<N>;
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* Select an actor by name and session ID, then connect a client to the
|
|
146
|
-
* session. Clients in the same session can exchange realtime messages through the
|
|
147
|
-
* actor. The client works in the browser and in Node.
|
|
148
|
-
*
|
|
149
|
-
* ## Connection flow
|
|
143
|
+
* Use `base44.actors` to connect your frontend to [actor sessions](/developers/backend/resources/actors/overview),
|
|
144
|
+
* shared live backend processes where clients exchange messages in realtime.
|
|
150
145
|
*
|
|
151
146
|
* - Connect to a session with `base44.actors.<ActorName>(sessionId).connect()`.
|
|
152
|
-
* - Subscribe to
|
|
153
|
-
*
|
|
154
|
-
* -
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* for common patterns.
|
|
160
|
-
*
|
|
161
|
-
* ## See also
|
|
147
|
+
* - Subscribe to messages the actor sends using [Connection.subscribe](#subscribe),
|
|
148
|
+
* either broadcast to all clients or sent directly to your client.
|
|
149
|
+
* - Send messages to the actor with [Connection.send](#send).
|
|
150
|
+
* - Share a session across multiple clients: any clients with the same actor
|
|
151
|
+
* name and session ID connect to the same session.
|
|
152
|
+
* - Type your messages using [ActorRegistry](#actorregistry) for autocomplete
|
|
153
|
+
* and compile-time safety.
|
|
162
154
|
*
|
|
163
|
-
*
|
|
164
|
-
* - [Actor Class Reference](/developers/backend/resources/actors/reference) — Backend class API
|
|
165
|
-
* - [Sample Flows](/developers/backend/resources/actors/samples) — Connect a client, run ticks, schedule wakes, and persist data
|
|
166
|
-
* - [`types generate`](/developers/references/cli/commands/types-generate) — Generate TypeScript types from deployed actors
|
|
155
|
+
* Learn more about [actors](/developers/backend/resources/actors/overview).
|
|
167
156
|
*
|
|
168
157
|
* ## Authentication modes
|
|
169
158
|
*
|
|
170
159
|
* This module is available in anonymous or user authentication mode
|
|
171
160
|
* (`base44.actors`). It isn't available with service role authentication. Apps that
|
|
172
161
|
* require login can reject anonymous connections in the actor's `handleConnect()` method.
|
|
162
|
+
* See [Manage client connections](/developers/backend/resources/actors/samples#manage-client-connections)
|
|
163
|
+
* for a sample flow.
|
|
173
164
|
*
|
|
174
165
|
* @example
|
|
175
166
|
* ```typescript
|