@base44-preview/sdk 0.8.49-pr.289.926db51 → 0.8.49-pr.289.cceffb2
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 +29 -18
- 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
|
/**
|
|
@@ -142,16 +142,25 @@ export interface ActorClient<N extends string = string> {
|
|
|
142
142
|
/**
|
|
143
143
|
* Provides access to actors and their shared, live sessions.
|
|
144
144
|
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
145
|
+
* Use `base44.actors` to connect clients to a running actor session. The actors
|
|
146
|
+
* client lets you:
|
|
147
|
+
*
|
|
148
|
+
* - Subscribe to messages the actor sends — either broadcast to all connected
|
|
149
|
+
* clients or sent to your client directly.
|
|
150
|
+
* - Send messages to the actor from the client.
|
|
151
|
+
* - Share a session across multiple clients: any clients with the same actor
|
|
152
|
+
* name and session ID connect to the same session.
|
|
153
|
+
* - Type your messages using [ActorRegistry](#actorregistry) for autocomplete
|
|
154
|
+
* and compile-time safety.
|
|
155
|
+
*
|
|
156
|
+
* The client works in the browser and in Node.js.
|
|
148
157
|
*
|
|
149
158
|
* ## Connection flow
|
|
150
159
|
*
|
|
151
160
|
* - Connect to a session with `base44.actors.<ActorName>(sessionId).connect()`.
|
|
152
|
-
* - Subscribe to outgoing messages with
|
|
153
|
-
* - Send incoming messages with
|
|
154
|
-
* - Close the connection with
|
|
161
|
+
* - Subscribe to outgoing messages with [Connection.subscribe](#subscribe).
|
|
162
|
+
* - Send incoming messages with [Connection.send](#send).
|
|
163
|
+
* - Close the connection with [Connection.close](#close).
|
|
155
164
|
*
|
|
156
165
|
* See [Actors Overview](/developers/backend/resources/actors/overview)
|
|
157
166
|
* for actor concepts and terminology, [Actor Class Reference](/developers/backend/resources/actors/reference)
|
|
@@ -163,6 +172,8 @@ export interface ActorClient<N extends string = string> {
|
|
|
163
172
|
* This module is available in anonymous or user authentication mode
|
|
164
173
|
* (`base44.actors`). It isn't available with service role authentication. Apps that
|
|
165
174
|
* require login can reject anonymous connections in the actor's `handleConnect()` method.
|
|
175
|
+
* See [Manage client connections](/developers/backend/resources/actors/samples#manage-client-connections)
|
|
176
|
+
* for a sample flow.
|
|
166
177
|
*
|
|
167
178
|
* @example
|
|
168
179
|
* ```typescript
|