@base44-preview/sdk 0.8.53-pr.289.762dbd5 → 0.8.53-pr.289.e840a51
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 +30 -34
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Maps actor names to their incoming and outgoing message types.
|
|
3
3
|
*
|
|
4
|
-
* Extend this interface
|
|
5
|
-
* messages without generating types with the CLI
|
|
6
|
-
*
|
|
7
|
-
* outgoing messages that the actor sends to connected clients.
|
|
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.
|
|
8
8
|
*
|
|
9
|
-
* To generate types from deployed actors
|
|
9
|
+
* To generate types from deployed actors, use the
|
|
10
10
|
* [`types generate`](/developers/references/cli/commands/types-generate) CLI command.
|
|
11
|
+
*
|
|
11
12
|
* To learn how incoming and outgoing messages work, see
|
|
12
13
|
* [message types](/developers/backend/resources/actors/overview#message-types).
|
|
13
14
|
*
|
|
@@ -31,7 +32,7 @@ export interface ActorRegistry {
|
|
|
31
32
|
* with [`types generate`](/developers/references/cli/commands/types-generate).
|
|
32
33
|
*
|
|
33
34
|
* The generated names provide autocomplete for deployed actors. To define
|
|
34
|
-
* incoming and outgoing message types manually, augment
|
|
35
|
+
* incoming and outgoing message types manually, augment {@linkcode ActorRegistry}.
|
|
35
36
|
*/
|
|
36
37
|
export interface ActorNameRegistry {
|
|
37
38
|
}
|
|
@@ -43,24 +44,21 @@ type ToServerFor<N extends string> = N extends keyof ActorRegistry ? ActorRegist
|
|
|
43
44
|
toServer: infer O;
|
|
44
45
|
} ? O : unknown : unknown;
|
|
45
46
|
/**
|
|
46
|
-
* Configures the connection that
|
|
47
|
+
* Configures the connection that {@linkcode ActorRef.connect | connect()} opens.
|
|
47
48
|
*/
|
|
48
49
|
export interface ActorConnectOptions {
|
|
49
50
|
/**
|
|
50
51
|
* Connection ID that the actor receives as `conn.id`.
|
|
51
52
|
*
|
|
52
|
-
* To let the actor recognize
|
|
53
|
+
* To let the actor recognize a client when it reconnects, use a stable
|
|
53
54
|
* value, such as an ID stored per browser tab. If you omit this property, the
|
|
54
|
-
* SDK generates a connection ID.
|
|
55
|
-
*
|
|
56
|
-
* For more about connection IDs, see
|
|
57
|
-
* [connections](/developers/backend/resources/actors/reference#connections).
|
|
55
|
+
* SDK generates a new connection ID.
|
|
58
56
|
*/
|
|
59
57
|
id?: string;
|
|
60
58
|
}
|
|
61
59
|
/**
|
|
62
60
|
* Represents a listener for messages from the actor, registered with
|
|
63
|
-
*
|
|
61
|
+
* {@linkcode Connection.subscribe | subscribe()}.
|
|
64
62
|
*/
|
|
65
63
|
export interface ActorSubscription {
|
|
66
64
|
/**
|
|
@@ -75,10 +73,11 @@ export interface ActorSubscription {
|
|
|
75
73
|
unsubscribe(): void;
|
|
76
74
|
}
|
|
77
75
|
/**
|
|
78
|
-
* Represents a client's WebSocket connection to an actor session
|
|
76
|
+
* Represents a client's WebSocket connection to an actor session, returned after calling
|
|
77
|
+
* [`connect()`](#connect). The socket queues messages you send before it opens.
|
|
79
78
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
79
|
+
* Learn more about
|
|
80
|
+
* [connections](/developers/backend/resources/actors/reference#connections).
|
|
82
81
|
*/
|
|
83
82
|
export interface Connection<N extends string = string> {
|
|
84
83
|
/** Connection ID that the actor receives as `conn.id`. */
|
|
@@ -106,10 +105,10 @@ export interface Connection<N extends string = string> {
|
|
|
106
105
|
/**
|
|
107
106
|
* Sends a message to the actor.
|
|
108
107
|
*
|
|
109
|
-
* The socket
|
|
110
|
-
* the socket drops further
|
|
108
|
+
* The socket queues messages until it opens. When you call {@linkcode Connection.close | close()},
|
|
109
|
+
* the socket drops any further sent messages.
|
|
111
110
|
*
|
|
112
|
-
* @param data - Message to send to the actor. The type comes from
|
|
111
|
+
* @param data - Message to send to the actor. The type comes from {@linkcode ActorRegistry} when you register the actor there.
|
|
113
112
|
*
|
|
114
113
|
* @example
|
|
115
114
|
* ```typescript
|
|
@@ -122,8 +121,7 @@ export interface Connection<N extends string = string> {
|
|
|
122
121
|
* Closes the connection and removes all listeners.
|
|
123
122
|
*
|
|
124
123
|
* You can call this method more than once. A connection also closes itself
|
|
125
|
-
* when it fails permanently.
|
|
126
|
-
* [ActorRef.connect](#connect) again.
|
|
124
|
+
* when it fails permanently.
|
|
127
125
|
*
|
|
128
126
|
* @example
|
|
129
127
|
* ```typescript
|
|
@@ -136,22 +134,20 @@ export interface Connection<N extends string = string> {
|
|
|
136
134
|
/**
|
|
137
135
|
* Represents a reference to an actor session, identified by actor name and session ID.
|
|
138
136
|
*
|
|
139
|
-
* Call
|
|
137
|
+
* Call {@linkcode ActorRef.connect | connect()} to open the WebSocket and get a [Connection](#returns).
|
|
140
138
|
*/
|
|
141
139
|
export interface ActorRef<N extends string = string> {
|
|
142
140
|
/**
|
|
143
|
-
* Creates or returns the [Connection](#
|
|
141
|
+
* Creates or returns the [Connection](#returns) for this session.
|
|
144
142
|
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* denies the connection, fix the cause and call `connect()` again. Then
|
|
148
|
-
* subscribe again on the new connection.
|
|
143
|
+
* Calling `connect()` again on the same session reference returns the same
|
|
144
|
+
* connection until it closes.
|
|
149
145
|
*
|
|
150
146
|
* For a sample flow, see
|
|
151
147
|
* [connect a client to a session](/developers/backend/resources/actors/sample-flows#connect-a-client-to-a-session).
|
|
152
148
|
*
|
|
153
149
|
* @param options - Optional connection settings, such as a stable connection ID.
|
|
154
|
-
* @returns The [Connection](#
|
|
150
|
+
* @returns The [Connection](#returns) for this actor session.
|
|
155
151
|
*
|
|
156
152
|
* @example
|
|
157
153
|
* ```typescript
|
|
@@ -165,7 +161,7 @@ export interface ActorRef<N extends string = string> {
|
|
|
165
161
|
* Selects a session for a named actor.
|
|
166
162
|
*
|
|
167
163
|
* TypeScript infers message types when you register the actor in
|
|
168
|
-
*
|
|
164
|
+
* {@linkcode ActorRegistry}. {@linkcode ActorNameRegistry}
|
|
169
165
|
* provides autocomplete for actor names only.
|
|
170
166
|
*/
|
|
171
167
|
export interface ActorClient<N extends string = string> {
|
|
@@ -194,11 +190,11 @@ export interface ActorClient<N extends string = string> {
|
|
|
194
190
|
*
|
|
195
191
|
* The actors module supports the following functionality:
|
|
196
192
|
*
|
|
197
|
-
* -
|
|
198
|
-
* -
|
|
199
|
-
* -
|
|
200
|
-
* -
|
|
201
|
-
* -
|
|
193
|
+
* - {@linkcode ActorRef.connect | connect()}: Open a WebSocket connection to a session.
|
|
194
|
+
* - {@linkcode Connection.subscribe | subscribe()}: Receive messages from the actor.
|
|
195
|
+
* - {@linkcode ActorSubscription.unsubscribe | unsubscribe()}: Stop receiving messages from the actor without closing the connection.
|
|
196
|
+
* - {@linkcode Connection.send | send()}: Send messages to the actor.
|
|
197
|
+
* - {@linkcode Connection.close | close()}: Close the WebSocket connection to the actor.
|
|
202
198
|
*
|
|
203
199
|
* For a sample flow, see
|
|
204
200
|
* [connect a client to a session](/developers/backend/resources/actors/sample-flows#connect-a-client-to-a-session).
|