@cosmonic-labs/openapi2mcp 0.10.0 → 0.10.2

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.
Files changed (95) hide show
  1. package/dist/interfaces/wasi-cli-environment.d.ts +1 -1
  2. package/dist/interfaces/wasi-cli-exit.d.ts +1 -1
  3. package/dist/interfaces/wasi-cli-stderr.d.ts +1 -1
  4. package/dist/interfaces/wasi-cli-stdin.d.ts +1 -1
  5. package/dist/interfaces/wasi-cli-stdout.d.ts +1 -1
  6. package/dist/interfaces/wasi-cli-terminal-input.d.ts +1 -1
  7. package/dist/interfaces/wasi-cli-terminal-output.d.ts +1 -1
  8. package/dist/interfaces/wasi-cli-terminal-stderr.d.ts +1 -1
  9. package/dist/interfaces/wasi-cli-terminal-stdin.d.ts +1 -1
  10. package/dist/interfaces/wasi-cli-terminal-stdout.d.ts +1 -1
  11. package/dist/interfaces/wasi-clocks-monotonic-clock.d.ts +4 -0
  12. package/dist/interfaces/wasi-clocks-wall-clock.d.ts +1 -1
  13. package/dist/interfaces/wasi-filesystem-preopens.d.ts +1 -1
  14. package/dist/interfaces/wasi-filesystem-types.d.ts +1 -1
  15. package/dist/interfaces/wasi-io-error.d.ts +1 -1
  16. package/dist/interfaces/wasi-io-poll.d.ts +2 -1
  17. package/dist/interfaces/wasi-io-streams.d.ts +2 -2
  18. package/dist/interfaces/wasi-random-insecure-seed.d.ts +1 -1
  19. package/dist/openapi2mcp.core.wasm +0 -0
  20. package/dist/openapi2mcp.d.ts +18 -17
  21. package/dist/openapi2mcp.js +655 -359
  22. package/node_modules/@bytecodealliance/preview2-shim/LICENSE +220 -0
  23. package/node_modules/@bytecodealliance/preview2-shim/README.md +113 -0
  24. package/node_modules/@bytecodealliance/preview2-shim/lib/browser/cli.js +135 -0
  25. package/node_modules/@bytecodealliance/preview2-shim/lib/browser/clocks.js +39 -0
  26. package/node_modules/@bytecodealliance/preview2-shim/lib/browser/config.js +9 -0
  27. package/node_modules/@bytecodealliance/preview2-shim/lib/browser/environment.js +29 -0
  28. package/node_modules/@bytecodealliance/preview2-shim/lib/browser/filesystem.js +485 -0
  29. package/node_modules/@bytecodealliance/preview2-shim/lib/browser/http.js +707 -0
  30. package/node_modules/@bytecodealliance/preview2-shim/lib/browser/index.js +9 -0
  31. package/node_modules/@bytecodealliance/preview2-shim/lib/browser/io.js +262 -0
  32. package/node_modules/@bytecodealliance/preview2-shim/lib/browser/random.js +56 -0
  33. package/node_modules/@bytecodealliance/preview2-shim/lib/browser/sockets.js +88 -0
  34. package/node_modules/@bytecodealliance/preview2-shim/lib/common/instantiation.js +253 -0
  35. package/node_modules/@bytecodealliance/preview2-shim/lib/io/calls.js +128 -0
  36. package/node_modules/@bytecodealliance/preview2-shim/lib/io/worker-http.js +206 -0
  37. package/node_modules/@bytecodealliance/preview2-shim/lib/io/worker-io.js +468 -0
  38. package/node_modules/@bytecodealliance/preview2-shim/lib/io/worker-socket-tcp.js +331 -0
  39. package/node_modules/@bytecodealliance/preview2-shim/lib/io/worker-socket-udp.js +587 -0
  40. package/node_modules/@bytecodealliance/preview2-shim/lib/io/worker-sockets.js +364 -0
  41. package/node_modules/@bytecodealliance/preview2-shim/lib/io/worker-thread.js +1051 -0
  42. package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/cli.js +109 -0
  43. package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/clocks.js +67 -0
  44. package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/filesystem.js +829 -0
  45. package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/http.js +764 -0
  46. package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/index.js +9 -0
  47. package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/io.js +1 -0
  48. package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/random.js +49 -0
  49. package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/sockets.js +565 -0
  50. package/node_modules/@bytecodealliance/preview2-shim/lib/synckit/index.js +127 -0
  51. package/node_modules/@bytecodealliance/preview2-shim/package.json +65 -0
  52. package/node_modules/@bytecodealliance/preview2-shim/types/cli.d.ts +11 -0
  53. package/node_modules/@bytecodealliance/preview2-shim/types/clocks.d.ts +2 -0
  54. package/node_modules/@bytecodealliance/preview2-shim/types/filesystem.d.ts +29 -0
  55. package/node_modules/@bytecodealliance/preview2-shim/types/http.d.ts +3 -0
  56. package/node_modules/@bytecodealliance/preview2-shim/types/index.d.ts +6 -0
  57. package/node_modules/@bytecodealliance/preview2-shim/types/instantiation.d.ts +199 -0
  58. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-environment.d.ts +21 -0
  59. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-exit.d.ts +6 -0
  60. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-run.d.ts +5 -0
  61. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-stderr.d.ts +3 -0
  62. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-stdin.d.ts +3 -0
  63. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-stdout.d.ts +3 -0
  64. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-terminal-input.d.ts +8 -0
  65. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-terminal-output.d.ts +8 -0
  66. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-terminal-stderr.d.ts +7 -0
  67. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-terminal-stdin.d.ts +7 -0
  68. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-terminal-stdout.d.ts +7 -0
  69. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-clocks-monotonic-clock.d.ts +34 -0
  70. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-clocks-wall-clock.d.ts +30 -0
  71. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-filesystem-preopens.d.ts +6 -0
  72. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-filesystem-types.d.ts +669 -0
  73. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-http-incoming-handler.d.ts +16 -0
  74. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-http-outgoing-handler.d.ts +18 -0
  75. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-http-types.d.ts +748 -0
  76. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-io-error.d.ts +18 -0
  77. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-io-poll.d.ts +44 -0
  78. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-io-streams.d.ts +243 -0
  79. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-random-insecure-seed.d.ts +21 -0
  80. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-random-insecure.d.ts +19 -0
  81. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-random-random.d.ts +23 -0
  82. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-instance-network.d.ts +6 -0
  83. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-ip-name-lookup.d.ts +58 -0
  84. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-network.d.ts +164 -0
  85. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-tcp-create-socket.d.ts +28 -0
  86. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-tcp.d.ts +359 -0
  87. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-udp-create-socket.d.ts +28 -0
  88. package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-udp.d.ts +301 -0
  89. package/node_modules/@bytecodealliance/preview2-shim/types/io.d.ts +3 -0
  90. package/node_modules/@bytecodealliance/preview2-shim/types/random.d.ts +3 -0
  91. package/node_modules/@bytecodealliance/preview2-shim/types/sockets.d.ts +7 -0
  92. package/node_modules/@bytecodealliance/preview2-shim/types/wasi-cli-command.d.ts +29 -0
  93. package/node_modules/@bytecodealliance/preview2-shim/types/wasi-http-proxy.d.ts +13 -0
  94. package/package.json +9 -6
  95. package/patches/@bytecodealliance+preview2-shim+0.18.0.patch +13 -0
@@ -0,0 +1,359 @@
1
+ /** @module Interface wasi:sockets/tcp@0.2.3 **/
2
+ export type InputStream = import('./wasi-io-streams.js').InputStream;
3
+ export type OutputStream = import('./wasi-io-streams.js').OutputStream;
4
+ export type Pollable = import('./wasi-io-poll.js').Pollable;
5
+ export type Duration = import('./wasi-clocks-monotonic-clock.js').Duration;
6
+ export type Network = import('./wasi-sockets-network.js').Network;
7
+ export type ErrorCode = import('./wasi-sockets-network.js').ErrorCode;
8
+ export type IpSocketAddress = import('./wasi-sockets-network.js').IpSocketAddress;
9
+ export type IpAddressFamily = import('./wasi-sockets-network.js').IpAddressFamily;
10
+ /**
11
+ * # Variants
12
+ *
13
+ * ## `"receive"`
14
+ *
15
+ * Similar to `SHUT_RD` in POSIX.
16
+ * ## `"send"`
17
+ *
18
+ * Similar to `SHUT_WR` in POSIX.
19
+ * ## `"both"`
20
+ *
21
+ * Similar to `SHUT_RDWR` in POSIX.
22
+ */
23
+ export type ShutdownType = 'receive' | 'send' | 'both';
24
+
25
+ export class TcpSocket {
26
+ /**
27
+ * This type does not have a public constructor.
28
+ */
29
+ private constructor();
30
+ /**
31
+ * Bind the socket to a specific network on the provided IP address and port.
32
+ *
33
+ * If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the implementation to decide which
34
+ * network interface(s) to bind to.
35
+ * If the TCP/UDP port is zero, the socket will be bound to a random free port.
36
+ *
37
+ * Bind can be attempted multiple times on the same socket, even with
38
+ * different arguments on each iteration. But never concurrently and
39
+ * only as long as the previous bind failed. Once a bind succeeds, the
40
+ * binding can't be changed anymore.
41
+ *
42
+ * # Typical errors
43
+ * - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows)
44
+ * - `invalid-argument`: `local-address` is not a unicast address. (EINVAL)
45
+ * - `invalid-argument`: `local-address` is an IPv4-mapped IPv6 address. (EINVAL)
46
+ * - `invalid-state`: The socket is already bound. (EINVAL)
47
+ * - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows)
48
+ * - `address-in-use`: Address is already in use. (EADDRINUSE)
49
+ * - `address-not-bindable`: `local-address` is not an address that the `network` can bind to. (EADDRNOTAVAIL)
50
+ * - `not-in-progress`: A `bind` operation is not in progress.
51
+ * - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN)
52
+ *
53
+ * # Implementors note
54
+ * When binding to a non-zero port, this bind operation shouldn't be affected by the TIME_WAIT
55
+ * state of a recently closed socket on the same local address. In practice this means that the SO_REUSEADDR
56
+ * socket option should be set implicitly on all platforms, except on Windows where this is the default behavior
57
+ * and SO_REUSEADDR performs something different entirely.
58
+ *
59
+ * Unlike in POSIX, in WASI the bind operation is async. This enables
60
+ * interactive WASI hosts to inject permission prompts. Runtimes that
61
+ * don't want to make use of this ability can simply call the native
62
+ * `bind` as part of either `start-bind` or `finish-bind`.
63
+ *
64
+ * # References
65
+ * - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html>
66
+ * - <https://man7.org/linux/man-pages/man2/bind.2.html>
67
+ * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind>
68
+ * - <https://man.freebsd.org/cgi/man.cgi?query=bind&sektion=2&format=html>
69
+ */
70
+ startBind(network: Network, localAddress: IpSocketAddress): void;
71
+ finishBind(): void;
72
+ /**
73
+ * Connect to a remote endpoint.
74
+ *
75
+ * On success:
76
+ * - the socket is transitioned into the `connected` state.
77
+ * - a pair of streams is returned that can be used to read & write to the connection
78
+ *
79
+ * After a failed connection attempt, the socket will be in the `closed`
80
+ * state and the only valid action left is to `drop` the socket. A single
81
+ * socket can not be used to connect more than once.
82
+ *
83
+ * # Typical errors
84
+ * - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT)
85
+ * - `invalid-argument`: `remote-address` is not a unicast address. (EINVAL, ENETUNREACH on Linux, EAFNOSUPPORT on MacOS)
86
+ * - `invalid-argument`: `remote-address` is an IPv4-mapped IPv6 address. (EINVAL, EADDRNOTAVAIL on Illumos)
87
+ * - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EADDRNOTAVAIL on Windows)
88
+ * - `invalid-argument`: The port in `remote-address` is set to 0. (EADDRNOTAVAIL on Windows)
89
+ * - `invalid-argument`: The socket is already attached to a different network. The `network` passed to `connect` must be identical to the one passed to `bind`.
90
+ * - `invalid-state`: The socket is already in the `connected` state. (EISCONN)
91
+ * - `invalid-state`: The socket is already in the `listening` state. (EOPNOTSUPP, EINVAL on Windows)
92
+ * - `timeout`: Connection timed out. (ETIMEDOUT)
93
+ * - `connection-refused`: The connection was forcefully rejected. (ECONNREFUSED)
94
+ * - `connection-reset`: The connection was reset. (ECONNRESET)
95
+ * - `connection-aborted`: The connection was aborted. (ECONNABORTED)
96
+ * - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)
97
+ * - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD)
98
+ * - `not-in-progress`: A connect operation is not in progress.
99
+ * - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN)
100
+ *
101
+ * # Implementors note
102
+ * The POSIX equivalent of `start-connect` is the regular `connect` syscall.
103
+ * Because all WASI sockets are non-blocking this is expected to return
104
+ * EINPROGRESS, which should be translated to `ok()` in WASI.
105
+ *
106
+ * The POSIX equivalent of `finish-connect` is a `poll` for event `POLLOUT`
107
+ * with a timeout of 0 on the socket descriptor. Followed by a check for
108
+ * the `SO_ERROR` socket option, in case the poll signaled readiness.
109
+ *
110
+ * # References
111
+ * - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html>
112
+ * - <https://man7.org/linux/man-pages/man2/connect.2.html>
113
+ * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect>
114
+ * - <https://man.freebsd.org/cgi/man.cgi?connect>
115
+ */
116
+ startConnect(network: Network, remoteAddress: IpSocketAddress): void;
117
+ finishConnect(): [InputStream, OutputStream];
118
+ /**
119
+ * Start listening for new connections.
120
+ *
121
+ * Transitions the socket into the `listening` state.
122
+ *
123
+ * Unlike POSIX, the socket must already be explicitly bound.
124
+ *
125
+ * # Typical errors
126
+ * - `invalid-state`: The socket is not bound to any local address. (EDESTADDRREQ)
127
+ * - `invalid-state`: The socket is already in the `connected` state. (EISCONN, EINVAL on BSD)
128
+ * - `invalid-state`: The socket is already in the `listening` state.
129
+ * - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE)
130
+ * - `not-in-progress`: A listen operation is not in progress.
131
+ * - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN)
132
+ *
133
+ * # Implementors note
134
+ * Unlike in POSIX, in WASI the listen operation is async. This enables
135
+ * interactive WASI hosts to inject permission prompts. Runtimes that
136
+ * don't want to make use of this ability can simply call the native
137
+ * `listen` as part of either `start-listen` or `finish-listen`.
138
+ *
139
+ * # References
140
+ * - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html>
141
+ * - <https://man7.org/linux/man-pages/man2/listen.2.html>
142
+ * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen>
143
+ * - <https://man.freebsd.org/cgi/man.cgi?query=listen&sektion=2>
144
+ */
145
+ startListen(): void;
146
+ finishListen(): void;
147
+ /**
148
+ * Accept a new client socket.
149
+ *
150
+ * The returned socket is bound and in the `connected` state. The following properties are inherited from the listener socket:
151
+ * - `address-family`
152
+ * - `keep-alive-enabled`
153
+ * - `keep-alive-idle-time`
154
+ * - `keep-alive-interval`
155
+ * - `keep-alive-count`
156
+ * - `hop-limit`
157
+ * - `receive-buffer-size`
158
+ * - `send-buffer-size`
159
+ *
160
+ * On success, this function returns the newly accepted client socket along with
161
+ * a pair of streams that can be used to read & write to the connection.
162
+ *
163
+ * # Typical errors
164
+ * - `invalid-state`: Socket is not in the `listening` state. (EINVAL)
165
+ * - `would-block`: No pending connections at the moment. (EWOULDBLOCK, EAGAIN)
166
+ * - `connection-aborted`: An incoming connection was pending, but was terminated by the client before this listener could accept it. (ECONNABORTED)
167
+ * - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE)
168
+ *
169
+ * # References
170
+ * - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html>
171
+ * - <https://man7.org/linux/man-pages/man2/accept.2.html>
172
+ * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept>
173
+ * - <https://man.freebsd.org/cgi/man.cgi?query=accept&sektion=2>
174
+ */
175
+ accept(): [TcpSocket, InputStream, OutputStream];
176
+ /**
177
+ * Get the bound local address.
178
+ *
179
+ * POSIX mentions:
180
+ * > If the socket has not been bound to a local name, the value
181
+ * > stored in the object pointed to by `address` is unspecified.
182
+ *
183
+ * WASI is stricter and requires `local-address` to return `invalid-state` when the socket hasn't been bound yet.
184
+ *
185
+ * # Typical errors
186
+ * - `invalid-state`: The socket is not bound to any local address.
187
+ *
188
+ * # References
189
+ * - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockname.html>
190
+ * - <https://man7.org/linux/man-pages/man2/getsockname.2.html>
191
+ * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getsockname>
192
+ * - <https://man.freebsd.org/cgi/man.cgi?getsockname>
193
+ */
194
+ localAddress(): IpSocketAddress;
195
+ /**
196
+ * Get the remote address.
197
+ *
198
+ * # Typical errors
199
+ * - `invalid-state`: The socket is not connected to a remote address. (ENOTCONN)
200
+ *
201
+ * # References
202
+ * - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpeername.html>
203
+ * - <https://man7.org/linux/man-pages/man2/getpeername.2.html>
204
+ * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getpeername>
205
+ * - <https://man.freebsd.org/cgi/man.cgi?query=getpeername&sektion=2&n=1>
206
+ */
207
+ remoteAddress(): IpSocketAddress;
208
+ /**
209
+ * Whether the socket is in the `listening` state.
210
+ *
211
+ * Equivalent to the SO_ACCEPTCONN socket option.
212
+ */
213
+ isListening(): boolean;
214
+ /**
215
+ * Whether this is a IPv4 or IPv6 socket.
216
+ *
217
+ * Equivalent to the SO_DOMAIN socket option.
218
+ */
219
+ addressFamily(): IpAddressFamily;
220
+ /**
221
+ * Hints the desired listen queue size. Implementations are free to ignore this.
222
+ *
223
+ * If the provided value is 0, an `invalid-argument` error is returned.
224
+ * Any other value will never cause an error, but it might be silently clamped and/or rounded.
225
+ *
226
+ * # Typical errors
227
+ * - `not-supported`: (set) The platform does not support changing the backlog size after the initial listen.
228
+ * - `invalid-argument`: (set) The provided value was 0.
229
+ * - `invalid-state`: (set) The socket is in the `connect-in-progress` or `connected` state.
230
+ */
231
+ setListenBacklogSize(value: bigint): void;
232
+ /**
233
+ * Enables or disables keepalive.
234
+ *
235
+ * The keepalive behavior can be adjusted using:
236
+ * - `keep-alive-idle-time`
237
+ * - `keep-alive-interval`
238
+ * - `keep-alive-count`
239
+ * These properties can be configured while `keep-alive-enabled` is false, but only come into effect when `keep-alive-enabled` is true.
240
+ *
241
+ * Equivalent to the SO_KEEPALIVE socket option.
242
+ */
243
+ keepAliveEnabled(): boolean;
244
+ setKeepAliveEnabled(value: boolean): void;
245
+ /**
246
+ * Amount of time the connection has to be idle before TCP starts sending keepalive packets.
247
+ *
248
+ * If the provided value is 0, an `invalid-argument` error is returned.
249
+ * Any other value will never cause an error, but it might be silently clamped and/or rounded.
250
+ * I.e. after setting a value, reading the same setting back may return a different value.
251
+ *
252
+ * Equivalent to the TCP_KEEPIDLE socket option. (TCP_KEEPALIVE on MacOS)
253
+ *
254
+ * # Typical errors
255
+ * - `invalid-argument`: (set) The provided value was 0.
256
+ */
257
+ keepAliveIdleTime(): Duration;
258
+ setKeepAliveIdleTime(value: Duration): void;
259
+ /**
260
+ * The time between keepalive packets.
261
+ *
262
+ * If the provided value is 0, an `invalid-argument` error is returned.
263
+ * Any other value will never cause an error, but it might be silently clamped and/or rounded.
264
+ * I.e. after setting a value, reading the same setting back may return a different value.
265
+ *
266
+ * Equivalent to the TCP_KEEPINTVL socket option.
267
+ *
268
+ * # Typical errors
269
+ * - `invalid-argument`: (set) The provided value was 0.
270
+ */
271
+ keepAliveInterval(): Duration;
272
+ setKeepAliveInterval(value: Duration): void;
273
+ /**
274
+ * The maximum amount of keepalive packets TCP should send before aborting the connection.
275
+ *
276
+ * If the provided value is 0, an `invalid-argument` error is returned.
277
+ * Any other value will never cause an error, but it might be silently clamped and/or rounded.
278
+ * I.e. after setting a value, reading the same setting back may return a different value.
279
+ *
280
+ * Equivalent to the TCP_KEEPCNT socket option.
281
+ *
282
+ * # Typical errors
283
+ * - `invalid-argument`: (set) The provided value was 0.
284
+ */
285
+ keepAliveCount(): number;
286
+ setKeepAliveCount(value: number): void;
287
+ /**
288
+ * Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
289
+ *
290
+ * If the provided value is 0, an `invalid-argument` error is returned.
291
+ *
292
+ * # Typical errors
293
+ * - `invalid-argument`: (set) The TTL value must be 1 or higher.
294
+ */
295
+ hopLimit(): number;
296
+ setHopLimit(value: number): void;
297
+ /**
298
+ * The kernel buffer space reserved for sends/receives on this socket.
299
+ *
300
+ * If the provided value is 0, an `invalid-argument` error is returned.
301
+ * Any other value will never cause an error, but it might be silently clamped and/or rounded.
302
+ * I.e. after setting a value, reading the same setting back may return a different value.
303
+ *
304
+ * Equivalent to the SO_RCVBUF and SO_SNDBUF socket options.
305
+ *
306
+ * # Typical errors
307
+ * - `invalid-argument`: (set) The provided value was 0.
308
+ */
309
+ receiveBufferSize(): bigint;
310
+ setReceiveBufferSize(value: bigint): void;
311
+ sendBufferSize(): bigint;
312
+ setSendBufferSize(value: bigint): void;
313
+ /**
314
+ * Create a `pollable` which can be used to poll for, or block on,
315
+ * completion of any of the asynchronous operations of this socket.
316
+ *
317
+ * When `finish-bind`, `finish-listen`, `finish-connect` or `accept`
318
+ * return `error(would-block)`, this pollable can be used to wait for
319
+ * their success or failure, after which the method can be retried.
320
+ *
321
+ * The pollable is not limited to the async operation that happens to be
322
+ * in progress at the time of calling `subscribe` (if any). Theoretically,
323
+ * `subscribe` only has to be called once per socket and can then be
324
+ * (re)used for the remainder of the socket's lifetime.
325
+ *
326
+ * See <https://github.com/WebAssembly/wasi-sockets/blob/main/TcpSocketOperationalSemantics.md#pollable-readiness>
327
+ * for more information.
328
+ *
329
+ * Note: this function is here for WASI 0.2 only.
330
+ * It's planned to be removed when `future` is natively supported in Preview3.
331
+ */
332
+ subscribe(): Pollable;
333
+ /**
334
+ * Initiate a graceful shutdown.
335
+ *
336
+ * - `receive`: The socket is not expecting to receive any data from
337
+ * the peer. The `input-stream` associated with this socket will be
338
+ * closed. Any data still in the receive queue at time of calling
339
+ * this method will be discarded.
340
+ * - `send`: The socket has no more data to send to the peer. The `output-stream`
341
+ * associated with this socket will be closed and a FIN packet will be sent.
342
+ * - `both`: Same effect as `receive` & `send` combined.
343
+ *
344
+ * This function is idempotent; shutting down a direction more than once
345
+ * has no effect and returns `ok`.
346
+ *
347
+ * The shutdown function does not close (drop) the socket.
348
+ *
349
+ * # Typical errors
350
+ * - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN)
351
+ *
352
+ * # References
353
+ * - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/shutdown.html>
354
+ * - <https://man7.org/linux/man-pages/man2/shutdown.2.html>
355
+ * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-shutdown>
356
+ * - <https://man.freebsd.org/cgi/man.cgi?query=shutdown&sektion=2>
357
+ */
358
+ shutdown(shutdownType: ShutdownType): void;
359
+ }
@@ -0,0 +1,28 @@
1
+ /** @module Interface wasi:sockets/udp-create-socket@0.2.3 **/
2
+ /**
3
+ * Create a new UDP socket.
4
+ *
5
+ * Similar to `socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP)` in POSIX.
6
+ * On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.
7
+ *
8
+ * This function does not require a network capability handle. This is considered to be safe because
9
+ * at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind` is called,
10
+ * the socket is effectively an in-memory configuration object, unable to communicate with the outside world.
11
+ *
12
+ * All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous operations.
13
+ *
14
+ * # Typical errors
15
+ * - `not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT)
16
+ * - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE)
17
+ *
18
+ * # References:
19
+ * - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html>
20
+ * - <https://man7.org/linux/man-pages/man2/socket.2.html>
21
+ * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw>
22
+ * - <https://man.freebsd.org/cgi/man.cgi?query=socket&sektion=2>
23
+ */
24
+ export function createUdpSocket(addressFamily: IpAddressFamily): UdpSocket;
25
+ export type Network = import('./wasi-sockets-network.js').Network;
26
+ export type ErrorCode = import('./wasi-sockets-network.js').ErrorCode;
27
+ export type IpAddressFamily = import('./wasi-sockets-network.js').IpAddressFamily;
28
+ export type UdpSocket = import('./wasi-sockets-udp.js').UdpSocket;