@agoric/network 0.1.1-dev-7ffae88.0 → 0.1.1-orchestration-dev-096c4e8.0

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/src/types.js CHANGED
@@ -1,3 +1,10 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @template T
5
+ * @typedef {Promise<T | import('@agoric/vow').Vow<T>>} PromiseVow
6
+ */
7
+
1
8
  /**
2
9
  * @typedef {string | Buffer | ArrayBuffer} Data
3
10
  *
@@ -11,12 +18,12 @@
11
18
 
12
19
  /**
13
20
  * @typedef {object} Closable A closable object
14
- * @property {() => Promise<void>} close Terminate the object
21
+ * @property {() => PromiseVow<void>} close Terminate the object
15
22
  */
16
23
 
17
24
  /**
18
25
  * @typedef {object} Protocol The network Protocol
19
- * @property {(prefix: Endpoint) => Promise<Port>} bind Claim a port, or if
26
+ * @property {(prefix: Endpoint) => PromiseVow<Port>} bind Claim a port, or if
20
27
  * ending in ENDPOINT_SEPARATOR, a fresh name
21
28
  */
22
29
 
@@ -24,14 +31,14 @@
24
31
  * @typedef {object} Port A port that has been bound to a protocol
25
32
  * @property {() => Endpoint} getLocalAddress Get the locally bound name of this
26
33
  * port
27
- * @property {(acceptHandler: ListenHandler) => Promise<void>} addListener
34
+ * @property {(acceptHandler: ListenHandler) => PromiseVow<void>} addListener
28
35
  * Begin accepting incoming connections
29
36
  * @property {(
30
37
  * remote: Endpoint,
31
38
  * connectionHandler?: ConnectionHandler,
32
- * ) => Promise<Connection>} connect
39
+ * ) => PromiseVow<Connection>} connect
33
40
  * Make an outbound connection
34
- * @property {(acceptHandler: ListenHandler) => Promise<void>} removeListener
41
+ * @property {(acceptHandler: ListenHandler) => PromiseVow<void>} removeListener
35
42
  * Remove the currently-bound listener
36
43
  * @property {() => void} revoke Deallocate the port entirely, removing all
37
44
  * listeners and closing all active connections
@@ -39,25 +46,25 @@
39
46
 
40
47
  /**
41
48
  * @typedef {object} ListenHandler A handler for incoming connections
42
- * @property {(port: Port, l: ListenHandler) => Promise<void>} [onListen] The
49
+ * @property {(port: Port, l: ListenHandler) => PromiseVow<void>} [onListen] The
43
50
  * listener has been registered
44
51
  * @property {(
45
52
  * port: Port,
46
53
  * localAddr: Endpoint,
47
54
  * remoteAddr: Endpoint,
48
55
  * l: ListenHandler,
49
- * ) => Promise<ConnectionHandler>} onAccept
56
+ * ) => PromiseVow<ConnectionHandler>} onAccept
50
57
  * A new connection is incoming
51
58
  * @property {(
52
59
  * port: Port,
53
60
  * localAddr: Endpoint,
54
61
  * remoteAddr: Endpoint,
55
62
  * l: ListenHandler,
56
- * ) => Promise<void>} [onReject]
63
+ * ) => PromiseVow<void>} [onReject]
57
64
  * The connection was rejected
58
- * @property {(port: Port, rej: any, l: ListenHandler) => Promise<void>} [onError]
65
+ * @property {(port: Port, rej: any, l: ListenHandler) => PromiseVow<void>} [onError]
59
66
  * There was an error while listening
60
- * @property {(port: Port, l: ListenHandler) => Promise<void>} [onRemove] The
67
+ * @property {(port: Port, l: ListenHandler) => PromiseVow<void>} [onRemove] The
61
68
  * listener has been removed
62
69
  */
63
70
 
@@ -66,9 +73,9 @@
66
73
  * @property {(
67
74
  * packetBytes: Data,
68
75
  * opts?: Record<string, any>,
69
- * ) => Promise<Bytes>} send
76
+ * ) => PromiseVow<Bytes>} send
70
77
  * Send a packet on the connection
71
- * @property {() => Promise<void>} close Close both ends of the connection
78
+ * @property {() => PromiseVow<void>} close Close both ends of the connection
72
79
  * @property {() => Endpoint} getLocalAddress Get the locally bound name of this
73
80
  * connection
74
81
  * @property {() => Endpoint} getRemoteAddress Get the name of the counterparty
@@ -81,20 +88,20 @@
81
88
  * localAddr: Endpoint,
82
89
  * remoteAddr: Endpoint,
83
90
  * c: ConnectionHandler,
84
- * ) => void} [onOpen]
91
+ * ) => PromiseVow<void>} [onOpen]
85
92
  * The connection has been opened
86
93
  * @property {(
87
94
  * connection: Connection,
88
- * packetBytes: Bytes,
95
+ * ack: Bytes,
89
96
  * c: ConnectionHandler,
90
97
  * opts?: Record<string, any>,
91
- * ) => Promise<Data>} [onReceive]
98
+ * ) => PromiseVow<Data>} [onReceive]
92
99
  * The connection received a packet
93
100
  * @property {(
94
101
  * connection: Connection,
95
102
  * reason?: CloseReason,
96
103
  * c?: ConnectionHandler,
97
- * ) => Promise<void>} [onClose]
104
+ * ) => PromiseVow<void>} [onClose]
98
105
  * The connection has been closed
99
106
  *
100
107
  * @typedef {any | null} CloseReason The reason a connection was closed
@@ -110,36 +117,36 @@
110
117
  /**
111
118
  * @typedef {object} ProtocolHandler A handler for things the protocol
112
119
  * implementation will invoke
113
- * @property {(protocol: ProtocolImpl, p: ProtocolHandler) => Promise<void>} onCreate
120
+ * @property {(protocol: ProtocolImpl, p: ProtocolHandler) => PromiseVow<void>} onCreate
114
121
  * This protocol is created
115
- * @property {(localAddr: Endpoint, p: ProtocolHandler) => Promise<string>} generatePortID
122
+ * @property {(localAddr: Endpoint, p: ProtocolHandler) => PromiseVow<string>} generatePortID
116
123
  * Create a fresh port identifier for this protocol
117
124
  * @property {(
118
125
  * port: Port,
119
126
  * localAddr: Endpoint,
120
127
  * p: ProtocolHandler,
121
- * ) => Promise<void>} onBind
128
+ * ) => PromiseVow<void>} onBind
122
129
  * A port will be bound
123
130
  * @property {(
124
131
  * port: Port,
125
132
  * localAddr: Endpoint,
126
133
  * listenHandler: ListenHandler,
127
134
  * p: ProtocolHandler,
128
- * ) => Promise<void>} onListen
135
+ * ) => PromiseVow<void>} onListen
129
136
  * A port was listening
130
137
  * @property {(
131
138
  * port: Port,
132
139
  * localAddr: Endpoint,
133
140
  * listenHandler: ListenHandler,
134
141
  * p: ProtocolHandler,
135
- * ) => Promise<void>} onListenRemove
142
+ * ) => PromiseVow<void>} onListenRemove
136
143
  * A port listener has been reset
137
144
  * @property {(
138
145
  * port: Port,
139
146
  * localAddr: Endpoint,
140
147
  * remote: Endpoint,
141
148
  * p: ProtocolHandler,
142
- * ) => Promise<Endpoint>} [onInstantiate]
149
+ * ) => PromiseVow<Endpoint>} [onInstantiate]
143
150
  * Return unique suffix for local address
144
151
  * @property {(
145
152
  * port: Port,
@@ -147,36 +154,36 @@
147
154
  * remote: Endpoint,
148
155
  * c: ConnectionHandler,
149
156
  * p: ProtocolHandler,
150
- * ) => Promise<AttemptDescription>} onConnect
157
+ * ) => PromiseVow<AttemptDescription>} onConnect
151
158
  * A port initiates an outbound connection
152
159
  * @property {(
153
160
  * port: Port,
154
161
  * localAddr: Endpoint,
155
162
  * p: ProtocolHandler,
156
- * ) => Promise<void>} onRevoke
163
+ * ) => PromiseVow<void>} onRevoke
157
164
  * The port is being completely destroyed
158
165
  *
159
166
  * @typedef {object} InboundAttempt An inbound connection attempt
160
- * @property {(desc: AttemptDescription) => Promise<Connection>} accept
167
+ * @property {(desc: AttemptDescription) => PromiseVow<Connection>} accept
161
168
  * Establish the connection
162
169
  * @property {() => Endpoint} getLocalAddress Return the local address for this
163
170
  * attempt
164
171
  * @property {() => Endpoint} getRemoteAddress Return the remote address for
165
172
  * this attempt
166
- * @property {() => Promise<void>} close Abort the attempt
173
+ * @property {() => PromiseVow<void>} close Abort the attempt
167
174
  *
168
175
  * @typedef {object} ProtocolImpl Things the protocol can do for us
169
- * @property {(prefix: Endpoint) => Promise<Port>} bind Claim a port, or if
176
+ * @property {(prefix: Endpoint) => PromiseVow<Port>} bind Claim a port, or if
170
177
  * ending in ENDPOINT_SEPARATOR, a fresh name
171
178
  * @property {(
172
179
  * listenAddr: Endpoint,
173
180
  * remoteAddr: Endpoint,
174
- * ) => Promise<InboundAttempt>} inbound
181
+ * ) => PromiseVow<InboundAttempt>} inbound
175
182
  * Make an attempt to connect into this protocol
176
183
  * @property {(
177
184
  * port: Port,
178
185
  * remoteAddr: Endpoint,
179
186
  * connectionHandler: ConnectionHandler,
180
- * ) => Promise<Connection>} outbound
187
+ * ) => PromiseVow<Connection>} outbound
181
188
  * Create an outbound connection
182
189
  */
package/tsconfig.json CHANGED
@@ -2,6 +2,7 @@
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "checkJs": false,
5
+ "maxNodeModuleJsDepth": 1,
5
6
  },
6
7
  "include": [
7
8
  "*.js",
package/typedoc.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": [
3
+ "../../typedoc.base.json"
4
+ ],
5
+ "entryPoints": [
6
+ "./src/index.js",
7
+ "./src/types.js",
8
+ ]
9
+ }