@base44-preview/sdk 0.8.49-pr.289.cceffb2 → 0.8.49-pr.289.dd3fb8f
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 +18 -27
- 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 {@link 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 {@link ActorRef.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
|
+
* {@link Connection.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
|
+
* {@link ActorRef.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 {@link 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 {@link 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 {@link ActorRef.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 {@link connect} to open the WebSocket and get a {@link Connection}.
|
|
108
108
|
*/
|
|
109
109
|
export interface ActorRef<N extends string = string> {
|
|
110
110
|
/**
|
|
111
|
-
* Creates or returns the
|
|
111
|
+
* Creates or returns the {@link 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 {@link 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 {@link ActorRegistry} or
|
|
129
|
+
* {@link ActorNameRegistry}.
|
|
130
130
|
*/
|
|
131
131
|
export interface ActorClient<N extends string = string> {
|
|
132
132
|
/**
|
|
@@ -142,25 +142,16 @@ 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
|
-
*
|
|
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.
|
|
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.
|
|
157
148
|
*
|
|
158
149
|
* ## Connection flow
|
|
159
150
|
*
|
|
160
151
|
* - Connect to a session with `base44.actors.<ActorName>(sessionId).connect()`.
|
|
161
|
-
* - Subscribe to outgoing messages with
|
|
162
|
-
* - Send incoming messages with
|
|
163
|
-
* - Close the connection with
|
|
152
|
+
* - Subscribe to outgoing messages with {@link Connection.subscribe}.
|
|
153
|
+
* - Send incoming messages with {@link Connection.send}.
|
|
154
|
+
* - Close the connection with {@link Connection.close}.
|
|
164
155
|
*
|
|
165
156
|
* See [Actors Overview](/developers/backend/resources/actors/overview)
|
|
166
157
|
* for actor concepts and terminology, [Actor Class Reference](/developers/backend/resources/actors/reference)
|