@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,669 @@
1
+ /** @module Interface wasi:filesystem/types@0.2.3 **/
2
+ /**
3
+ * Attempts to extract a filesystem-related `error-code` from the stream
4
+ * `error` provided.
5
+ *
6
+ * Stream operations which return `stream-error::last-operation-failed`
7
+ * have a payload with more information about the operation that failed.
8
+ * This payload can be passed through to this function to see if there's
9
+ * filesystem-related information about the error to return.
10
+ *
11
+ * Note that this function is fallible because not all stream-related
12
+ * errors are filesystem-related errors.
13
+ */
14
+ export function filesystemErrorCode(err: Error): ErrorCode | undefined;
15
+ export type InputStream = import('./wasi-io-streams.js').InputStream;
16
+ export type OutputStream = import('./wasi-io-streams.js').OutputStream;
17
+ export type Error = import('./wasi-io-streams.js').Error;
18
+ export type Datetime = import('./wasi-clocks-wall-clock.js').Datetime;
19
+ /**
20
+ * File size or length of a region within a file.
21
+ */
22
+ export type Filesize = bigint;
23
+ /**
24
+ * The type of a filesystem object referenced by a descriptor.
25
+ *
26
+ * Note: This was called `filetype` in earlier versions of WASI.
27
+ * # Variants
28
+ *
29
+ * ## `"unknown"`
30
+ *
31
+ * The type of the descriptor or file is unknown or is different from
32
+ * any of the other types specified.
33
+ * ## `"block-device"`
34
+ *
35
+ * The descriptor refers to a block device inode.
36
+ * ## `"character-device"`
37
+ *
38
+ * The descriptor refers to a character device inode.
39
+ * ## `"directory"`
40
+ *
41
+ * The descriptor refers to a directory inode.
42
+ * ## `"fifo"`
43
+ *
44
+ * The descriptor refers to a named pipe.
45
+ * ## `"symbolic-link"`
46
+ *
47
+ * The file refers to a symbolic link inode.
48
+ * ## `"regular-file"`
49
+ *
50
+ * The descriptor refers to a regular file inode.
51
+ * ## `"socket"`
52
+ *
53
+ * The descriptor refers to a socket.
54
+ */
55
+ export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | 'directory' | 'fifo' | 'symbolic-link' | 'regular-file' | 'socket';
56
+ /**
57
+ * Descriptor flags.
58
+ *
59
+ * Note: This was called `fdflags` in earlier versions of WASI.
60
+ */
61
+ export interface DescriptorFlags {
62
+ /**
63
+ * Read mode: Data can be read.
64
+ */
65
+ read?: boolean,
66
+ /**
67
+ * Write mode: Data can be written to.
68
+ */
69
+ write?: boolean,
70
+ /**
71
+ * Request that writes be performed according to synchronized I/O file
72
+ * integrity completion. The data stored in the file and the file's
73
+ * metadata are synchronized. This is similar to `O_SYNC` in POSIX.
74
+ *
75
+ * The precise semantics of this operation have not yet been defined for
76
+ * WASI. At this time, it should be interpreted as a request, and not a
77
+ * requirement.
78
+ */
79
+ fileIntegritySync?: boolean,
80
+ /**
81
+ * Request that writes be performed according to synchronized I/O data
82
+ * integrity completion. Only the data stored in the file is
83
+ * synchronized. This is similar to `O_DSYNC` in POSIX.
84
+ *
85
+ * The precise semantics of this operation have not yet been defined for
86
+ * WASI. At this time, it should be interpreted as a request, and not a
87
+ * requirement.
88
+ */
89
+ dataIntegritySync?: boolean,
90
+ /**
91
+ * Requests that reads be performed at the same level of integrity
92
+ * requested for writes. This is similar to `O_RSYNC` in POSIX.
93
+ *
94
+ * The precise semantics of this operation have not yet been defined for
95
+ * WASI. At this time, it should be interpreted as a request, and not a
96
+ * requirement.
97
+ */
98
+ requestedWriteSync?: boolean,
99
+ /**
100
+ * Mutating directories mode: Directory contents may be mutated.
101
+ *
102
+ * When this flag is unset on a descriptor, operations using the
103
+ * descriptor which would create, rename, delete, modify the data or
104
+ * metadata of filesystem objects, or obtain another handle which
105
+ * would permit any of those, shall fail with `error-code::read-only` if
106
+ * they would otherwise succeed.
107
+ *
108
+ * This may only be set on directories.
109
+ */
110
+ mutateDirectory?: boolean,
111
+ }
112
+ /**
113
+ * Flags determining the method of how paths are resolved.
114
+ */
115
+ export interface PathFlags {
116
+ /**
117
+ * As long as the resolved path corresponds to a symbolic link, it is
118
+ * expanded.
119
+ */
120
+ symlinkFollow?: boolean,
121
+ }
122
+ /**
123
+ * Open flags used by `open-at`.
124
+ */
125
+ export interface OpenFlags {
126
+ /**
127
+ * Create file if it does not exist, similar to `O_CREAT` in POSIX.
128
+ */
129
+ create?: boolean,
130
+ /**
131
+ * Fail if not a directory, similar to `O_DIRECTORY` in POSIX.
132
+ */
133
+ directory?: boolean,
134
+ /**
135
+ * Fail if file already exists, similar to `O_EXCL` in POSIX.
136
+ */
137
+ exclusive?: boolean,
138
+ /**
139
+ * Truncate file to size 0, similar to `O_TRUNC` in POSIX.
140
+ */
141
+ truncate?: boolean,
142
+ }
143
+ /**
144
+ * Number of hard links to an inode.
145
+ */
146
+ export type LinkCount = bigint;
147
+ /**
148
+ * File attributes.
149
+ *
150
+ * Note: This was called `filestat` in earlier versions of WASI.
151
+ */
152
+ export interface DescriptorStat {
153
+ /**
154
+ * File type.
155
+ */
156
+ type: DescriptorType,
157
+ /**
158
+ * Number of hard links to the file.
159
+ */
160
+ linkCount: LinkCount,
161
+ /**
162
+ * For regular files, the file size in bytes. For symbolic links, the
163
+ * length in bytes of the pathname contained in the symbolic link.
164
+ */
165
+ size: Filesize,
166
+ /**
167
+ * Last data access timestamp.
168
+ *
169
+ * If the `option` is none, the platform doesn't maintain an access
170
+ * timestamp for this file.
171
+ */
172
+ dataAccessTimestamp?: Datetime,
173
+ /**
174
+ * Last data modification timestamp.
175
+ *
176
+ * If the `option` is none, the platform doesn't maintain a
177
+ * modification timestamp for this file.
178
+ */
179
+ dataModificationTimestamp?: Datetime,
180
+ /**
181
+ * Last file status-change timestamp.
182
+ *
183
+ * If the `option` is none, the platform doesn't maintain a
184
+ * status-change timestamp for this file.
185
+ */
186
+ statusChangeTimestamp?: Datetime,
187
+ }
188
+ /**
189
+ * When setting a timestamp, this gives the value to set it to.
190
+ */
191
+ export type NewTimestamp = NewTimestampNoChange | NewTimestampNow | NewTimestampTimestamp;
192
+ /**
193
+ * Leave the timestamp set to its previous value.
194
+ */
195
+ export interface NewTimestampNoChange {
196
+ tag: 'no-change',
197
+ }
198
+ /**
199
+ * Set the timestamp to the current time of the system clock associated
200
+ * with the filesystem.
201
+ */
202
+ export interface NewTimestampNow {
203
+ tag: 'now',
204
+ }
205
+ /**
206
+ * Set the timestamp to the given value.
207
+ */
208
+ export interface NewTimestampTimestamp {
209
+ tag: 'timestamp',
210
+ val: Datetime,
211
+ }
212
+ /**
213
+ * A directory entry.
214
+ */
215
+ export interface DirectoryEntry {
216
+ /**
217
+ * The type of the file referred to by this directory entry.
218
+ */
219
+ type: DescriptorType,
220
+ /**
221
+ * The name of the object.
222
+ */
223
+ name: string,
224
+ }
225
+ /**
226
+ * Error codes returned by functions, similar to `errno` in POSIX.
227
+ * Not all of these error codes are returned by the functions provided by this
228
+ * API; some are used in higher-level library layers, and others are provided
229
+ * merely for alignment with POSIX.
230
+ * # Variants
231
+ *
232
+ * ## `"access"`
233
+ *
234
+ * Permission denied, similar to `EACCES` in POSIX.
235
+ * ## `"would-block"`
236
+ *
237
+ * Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.
238
+ * ## `"already"`
239
+ *
240
+ * Connection already in progress, similar to `EALREADY` in POSIX.
241
+ * ## `"bad-descriptor"`
242
+ *
243
+ * Bad descriptor, similar to `EBADF` in POSIX.
244
+ * ## `"busy"`
245
+ *
246
+ * Device or resource busy, similar to `EBUSY` in POSIX.
247
+ * ## `"deadlock"`
248
+ *
249
+ * Resource deadlock would occur, similar to `EDEADLK` in POSIX.
250
+ * ## `"quota"`
251
+ *
252
+ * Storage quota exceeded, similar to `EDQUOT` in POSIX.
253
+ * ## `"exist"`
254
+ *
255
+ * File exists, similar to `EEXIST` in POSIX.
256
+ * ## `"file-too-large"`
257
+ *
258
+ * File too large, similar to `EFBIG` in POSIX.
259
+ * ## `"illegal-byte-sequence"`
260
+ *
261
+ * Illegal byte sequence, similar to `EILSEQ` in POSIX.
262
+ * ## `"in-progress"`
263
+ *
264
+ * Operation in progress, similar to `EINPROGRESS` in POSIX.
265
+ * ## `"interrupted"`
266
+ *
267
+ * Interrupted function, similar to `EINTR` in POSIX.
268
+ * ## `"invalid"`
269
+ *
270
+ * Invalid argument, similar to `EINVAL` in POSIX.
271
+ * ## `"io"`
272
+ *
273
+ * I/O error, similar to `EIO` in POSIX.
274
+ * ## `"is-directory"`
275
+ *
276
+ * Is a directory, similar to `EISDIR` in POSIX.
277
+ * ## `"loop"`
278
+ *
279
+ * Too many levels of symbolic links, similar to `ELOOP` in POSIX.
280
+ * ## `"too-many-links"`
281
+ *
282
+ * Too many links, similar to `EMLINK` in POSIX.
283
+ * ## `"message-size"`
284
+ *
285
+ * Message too large, similar to `EMSGSIZE` in POSIX.
286
+ * ## `"name-too-long"`
287
+ *
288
+ * Filename too long, similar to `ENAMETOOLONG` in POSIX.
289
+ * ## `"no-device"`
290
+ *
291
+ * No such device, similar to `ENODEV` in POSIX.
292
+ * ## `"no-entry"`
293
+ *
294
+ * No such file or directory, similar to `ENOENT` in POSIX.
295
+ * ## `"no-lock"`
296
+ *
297
+ * No locks available, similar to `ENOLCK` in POSIX.
298
+ * ## `"insufficient-memory"`
299
+ *
300
+ * Not enough space, similar to `ENOMEM` in POSIX.
301
+ * ## `"insufficient-space"`
302
+ *
303
+ * No space left on device, similar to `ENOSPC` in POSIX.
304
+ * ## `"not-directory"`
305
+ *
306
+ * Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.
307
+ * ## `"not-empty"`
308
+ *
309
+ * Directory not empty, similar to `ENOTEMPTY` in POSIX.
310
+ * ## `"not-recoverable"`
311
+ *
312
+ * State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.
313
+ * ## `"unsupported"`
314
+ *
315
+ * Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.
316
+ * ## `"no-tty"`
317
+ *
318
+ * Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.
319
+ * ## `"no-such-device"`
320
+ *
321
+ * No such device or address, similar to `ENXIO` in POSIX.
322
+ * ## `"overflow"`
323
+ *
324
+ * Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.
325
+ * ## `"not-permitted"`
326
+ *
327
+ * Operation not permitted, similar to `EPERM` in POSIX.
328
+ * ## `"pipe"`
329
+ *
330
+ * Broken pipe, similar to `EPIPE` in POSIX.
331
+ * ## `"read-only"`
332
+ *
333
+ * Read-only file system, similar to `EROFS` in POSIX.
334
+ * ## `"invalid-seek"`
335
+ *
336
+ * Invalid seek, similar to `ESPIPE` in POSIX.
337
+ * ## `"text-file-busy"`
338
+ *
339
+ * Text file busy, similar to `ETXTBSY` in POSIX.
340
+ * ## `"cross-device"`
341
+ *
342
+ * Cross-device link, similar to `EXDEV` in POSIX.
343
+ */
344
+ export type ErrorCode = 'access' | 'would-block' | 'already' | 'bad-descriptor' | 'busy' | 'deadlock' | 'quota' | 'exist' | 'file-too-large' | 'illegal-byte-sequence' | 'in-progress' | 'interrupted' | 'invalid' | 'io' | 'is-directory' | 'loop' | 'too-many-links' | 'message-size' | 'name-too-long' | 'no-device' | 'no-entry' | 'no-lock' | 'insufficient-memory' | 'insufficient-space' | 'not-directory' | 'not-empty' | 'not-recoverable' | 'unsupported' | 'no-tty' | 'no-such-device' | 'overflow' | 'not-permitted' | 'pipe' | 'read-only' | 'invalid-seek' | 'text-file-busy' | 'cross-device';
345
+ /**
346
+ * File or memory access pattern advisory information.
347
+ * # Variants
348
+ *
349
+ * ## `"normal"`
350
+ *
351
+ * The application has no advice to give on its behavior with respect
352
+ * to the specified data.
353
+ * ## `"sequential"`
354
+ *
355
+ * The application expects to access the specified data sequentially
356
+ * from lower offsets to higher offsets.
357
+ * ## `"random"`
358
+ *
359
+ * The application expects to access the specified data in a random
360
+ * order.
361
+ * ## `"will-need"`
362
+ *
363
+ * The application expects to access the specified data in the near
364
+ * future.
365
+ * ## `"dont-need"`
366
+ *
367
+ * The application expects that it will not access the specified data
368
+ * in the near future.
369
+ * ## `"no-reuse"`
370
+ *
371
+ * The application expects to access the specified data once and then
372
+ * not reuse it thereafter.
373
+ */
374
+ export type Advice = 'normal' | 'sequential' | 'random' | 'will-need' | 'dont-need' | 'no-reuse';
375
+ /**
376
+ * A 128-bit hash value, split into parts because wasm doesn't have a
377
+ * 128-bit integer type.
378
+ */
379
+ export interface MetadataHashValue {
380
+ /**
381
+ * 64 bits of a 128-bit hash value.
382
+ */
383
+ lower: bigint,
384
+ /**
385
+ * Another 64 bits of a 128-bit hash value.
386
+ */
387
+ upper: bigint,
388
+ }
389
+
390
+ export class Descriptor {
391
+ /**
392
+ * This type does not have a public constructor.
393
+ */
394
+ private constructor();
395
+ /**
396
+ * Return a stream for reading from a file, if available.
397
+ *
398
+ * May fail with an error-code describing why the file cannot be read.
399
+ *
400
+ * Multiple read, write, and append streams may be active on the same open
401
+ * file and they do not interfere with each other.
402
+ *
403
+ * Note: This allows using `read-stream`, which is similar to `read` in POSIX.
404
+ */
405
+ readViaStream(offset: Filesize): InputStream;
406
+ /**
407
+ * Return a stream for writing to a file, if available.
408
+ *
409
+ * May fail with an error-code describing why the file cannot be written.
410
+ *
411
+ * Note: This allows using `write-stream`, which is similar to `write` in
412
+ * POSIX.
413
+ */
414
+ writeViaStream(offset: Filesize): OutputStream;
415
+ /**
416
+ * Return a stream for appending to a file, if available.
417
+ *
418
+ * May fail with an error-code describing why the file cannot be appended.
419
+ *
420
+ * Note: This allows using `write-stream`, which is similar to `write` with
421
+ * `O_APPEND` in POSIX.
422
+ */
423
+ appendViaStream(): OutputStream;
424
+ /**
425
+ * Provide file advisory information on a descriptor.
426
+ *
427
+ * This is similar to `posix_fadvise` in POSIX.
428
+ */
429
+ advise(offset: Filesize, length: Filesize, advice: Advice): void;
430
+ /**
431
+ * Synchronize the data of a file to disk.
432
+ *
433
+ * This function succeeds with no effect if the file descriptor is not
434
+ * opened for writing.
435
+ *
436
+ * Note: This is similar to `fdatasync` in POSIX.
437
+ */
438
+ syncData(): void;
439
+ /**
440
+ * Get flags associated with a descriptor.
441
+ *
442
+ * Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX.
443
+ *
444
+ * Note: This returns the value that was the `fs_flags` value returned
445
+ * from `fdstat_get` in earlier versions of WASI.
446
+ */
447
+ getFlags(): DescriptorFlags;
448
+ /**
449
+ * Get the dynamic type of a descriptor.
450
+ *
451
+ * Note: This returns the same value as the `type` field of the `fd-stat`
452
+ * returned by `stat`, `stat-at` and similar.
453
+ *
454
+ * Note: This returns similar flags to the `st_mode & S_IFMT` value provided
455
+ * by `fstat` in POSIX.
456
+ *
457
+ * Note: This returns the value that was the `fs_filetype` value returned
458
+ * from `fdstat_get` in earlier versions of WASI.
459
+ */
460
+ getType(): DescriptorType;
461
+ /**
462
+ * Adjust the size of an open file. If this increases the file's size, the
463
+ * extra bytes are filled with zeros.
464
+ *
465
+ * Note: This was called `fd_filestat_set_size` in earlier versions of WASI.
466
+ */
467
+ setSize(size: Filesize): void;
468
+ /**
469
+ * Adjust the timestamps of an open file or directory.
470
+ *
471
+ * Note: This is similar to `futimens` in POSIX.
472
+ *
473
+ * Note: This was called `fd_filestat_set_times` in earlier versions of WASI.
474
+ */
475
+ setTimes(dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
476
+ /**
477
+ * Read from a descriptor, without using and updating the descriptor's offset.
478
+ *
479
+ * This function returns a list of bytes containing the data that was
480
+ * read, along with a bool which, when true, indicates that the end of the
481
+ * file was reached. The returned list will contain up to `length` bytes; it
482
+ * may return fewer than requested, if the end of the file is reached or
483
+ * if the I/O operation is interrupted.
484
+ *
485
+ * In the future, this may change to return a `stream<u8, error-code>`.
486
+ *
487
+ * Note: This is similar to `pread` in POSIX.
488
+ */
489
+ read(length: Filesize, offset: Filesize): [Uint8Array, boolean];
490
+ /**
491
+ * Write to a descriptor, without using and updating the descriptor's offset.
492
+ *
493
+ * It is valid to write past the end of a file; the file is extended to the
494
+ * extent of the write, with bytes between the previous end and the start of
495
+ * the write set to zero.
496
+ *
497
+ * In the future, this may change to take a `stream<u8, error-code>`.
498
+ *
499
+ * Note: This is similar to `pwrite` in POSIX.
500
+ */
501
+ write(buffer: Uint8Array, offset: Filesize): Filesize;
502
+ /**
503
+ * Read directory entries from a directory.
504
+ *
505
+ * On filesystems where directories contain entries referring to themselves
506
+ * and their parents, often named `.` and `..` respectively, these entries
507
+ * are omitted.
508
+ *
509
+ * This always returns a new stream which starts at the beginning of the
510
+ * directory. Multiple streams may be active on the same directory, and they
511
+ * do not interfere with each other.
512
+ */
513
+ readDirectory(): DirectoryEntryStream;
514
+ /**
515
+ * Synchronize the data and metadata of a file to disk.
516
+ *
517
+ * This function succeeds with no effect if the file descriptor is not
518
+ * opened for writing.
519
+ *
520
+ * Note: This is similar to `fsync` in POSIX.
521
+ */
522
+ sync(): void;
523
+ /**
524
+ * Create a directory.
525
+ *
526
+ * Note: This is similar to `mkdirat` in POSIX.
527
+ */
528
+ createDirectoryAt(path: string): void;
529
+ /**
530
+ * Return the attributes of an open file or directory.
531
+ *
532
+ * Note: This is similar to `fstat` in POSIX, except that it does not return
533
+ * device and inode information. For testing whether two descriptors refer to
534
+ * the same underlying filesystem object, use `is-same-object`. To obtain
535
+ * additional data that can be used do determine whether a file has been
536
+ * modified, use `metadata-hash`.
537
+ *
538
+ * Note: This was called `fd_filestat_get` in earlier versions of WASI.
539
+ */
540
+ stat(): DescriptorStat;
541
+ /**
542
+ * Return the attributes of a file or directory.
543
+ *
544
+ * Note: This is similar to `fstatat` in POSIX, except that it does not
545
+ * return device and inode information. See the `stat` description for a
546
+ * discussion of alternatives.
547
+ *
548
+ * Note: This was called `path_filestat_get` in earlier versions of WASI.
549
+ */
550
+ statAt(pathFlags: PathFlags, path: string): DescriptorStat;
551
+ /**
552
+ * Adjust the timestamps of a file or directory.
553
+ *
554
+ * Note: This is similar to `utimensat` in POSIX.
555
+ *
556
+ * Note: This was called `path_filestat_set_times` in earlier versions of
557
+ * WASI.
558
+ */
559
+ setTimesAt(pathFlags: PathFlags, path: string, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
560
+ /**
561
+ * Create a hard link.
562
+ *
563
+ * Note: This is similar to `linkat` in POSIX.
564
+ */
565
+ linkAt(oldPathFlags: PathFlags, oldPath: string, newDescriptor: Descriptor, newPath: string): void;
566
+ /**
567
+ * Open a file or directory.
568
+ *
569
+ * If `flags` contains `descriptor-flags::mutate-directory`, and the base
570
+ * descriptor doesn't have `descriptor-flags::mutate-directory` set,
571
+ * `open-at` fails with `error-code::read-only`.
572
+ *
573
+ * If `flags` contains `write` or `mutate-directory`, or `open-flags`
574
+ * contains `truncate` or `create`, and the base descriptor doesn't have
575
+ * `descriptor-flags::mutate-directory` set, `open-at` fails with
576
+ * `error-code::read-only`.
577
+ *
578
+ * Note: This is similar to `openat` in POSIX.
579
+ */
580
+ openAt(pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags): Descriptor;
581
+ /**
582
+ * Read the contents of a symbolic link.
583
+ *
584
+ * If the contents contain an absolute or rooted path in the underlying
585
+ * filesystem, this function fails with `error-code::not-permitted`.
586
+ *
587
+ * Note: This is similar to `readlinkat` in POSIX.
588
+ */
589
+ readlinkAt(path: string): string;
590
+ /**
591
+ * Remove a directory.
592
+ *
593
+ * Return `error-code::not-empty` if the directory is not empty.
594
+ *
595
+ * Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
596
+ */
597
+ removeDirectoryAt(path: string): void;
598
+ /**
599
+ * Rename a filesystem object.
600
+ *
601
+ * Note: This is similar to `renameat` in POSIX.
602
+ */
603
+ renameAt(oldPath: string, newDescriptor: Descriptor, newPath: string): void;
604
+ /**
605
+ * Create a symbolic link (also known as a "symlink").
606
+ *
607
+ * If `old-path` starts with `/`, the function fails with
608
+ * `error-code::not-permitted`.
609
+ *
610
+ * Note: This is similar to `symlinkat` in POSIX.
611
+ */
612
+ symlinkAt(oldPath: string, newPath: string): void;
613
+ /**
614
+ * Unlink a filesystem object that is not a directory.
615
+ *
616
+ * Return `error-code::is-directory` if the path refers to a directory.
617
+ * Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
618
+ */
619
+ unlinkFileAt(path: string): void;
620
+ /**
621
+ * Test whether two descriptors refer to the same filesystem object.
622
+ *
623
+ * In POSIX, this corresponds to testing whether the two descriptors have the
624
+ * same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers.
625
+ * wasi-filesystem does not expose device and inode numbers, so this function
626
+ * may be used instead.
627
+ */
628
+ isSameObject(other: Descriptor): boolean;
629
+ /**
630
+ * Return a hash of the metadata associated with a filesystem object referred
631
+ * to by a descriptor.
632
+ *
633
+ * This returns a hash of the last-modification timestamp and file size, and
634
+ * may also include the inode number, device number, birth timestamp, and
635
+ * other metadata fields that may change when the file is modified or
636
+ * replaced. It may also include a secret value chosen by the
637
+ * implementation and not otherwise exposed.
638
+ *
639
+ * Implementations are encouraged to provide the following properties:
640
+ *
641
+ * - If the file is not modified or replaced, the computed hash value should
642
+ * usually not change.
643
+ * - If the object is modified or replaced, the computed hash value should
644
+ * usually change.
645
+ * - The inputs to the hash should not be easily computable from the
646
+ * computed hash.
647
+ *
648
+ * However, none of these is required.
649
+ */
650
+ metadataHash(): MetadataHashValue;
651
+ /**
652
+ * Return a hash of the metadata associated with a filesystem object referred
653
+ * to by a directory descriptor and a relative path.
654
+ *
655
+ * This performs the same hash computation as `metadata-hash`.
656
+ */
657
+ metadataHashAt(pathFlags: PathFlags, path: string): MetadataHashValue;
658
+ }
659
+
660
+ export class DirectoryEntryStream {
661
+ /**
662
+ * This type does not have a public constructor.
663
+ */
664
+ private constructor();
665
+ /**
666
+ * Read a single directory entry from a `directory-entry-stream`.
667
+ */
668
+ readDirectoryEntry(): DirectoryEntry | undefined;
669
+ }
@@ -0,0 +1,16 @@
1
+ /** @module Interface wasi:http/incoming-handler@0.2.3 **/
2
+ /**
3
+ * This function is invoked with an incoming HTTP Request, and a resource
4
+ * `response-outparam` which provides the capability to reply with an HTTP
5
+ * Response. The response is sent by calling the `response-outparam.set`
6
+ * method, which allows execution to continue after the response has been
7
+ * sent. This enables both streaming to the response body, and performing other
8
+ * work.
9
+ *
10
+ * The implementor of this function must write a response to the
11
+ * `response-outparam` before returning, or else the caller will respond
12
+ * with an error on its behalf.
13
+ */
14
+ export function handle(request: IncomingRequest, responseOut: ResponseOutparam): void;
15
+ export type IncomingRequest = import('./wasi-http-types.js').IncomingRequest;
16
+ export type ResponseOutparam = import('./wasi-http-types.js').ResponseOutparam;
@@ -0,0 +1,18 @@
1
+ /** @module Interface wasi:http/outgoing-handler@0.2.3 **/
2
+ /**
3
+ * This function is invoked with an outgoing HTTP Request, and it returns
4
+ * a resource `future-incoming-response` which represents an HTTP Response
5
+ * which may arrive in the future.
6
+ *
7
+ * The `options` argument accepts optional parameters for the HTTP
8
+ * protocol's transport layer.
9
+ *
10
+ * This function may return an error if the `outgoing-request` is invalid
11
+ * or not allowed to be made. Otherwise, protocol errors are reported
12
+ * through the `future-incoming-response`.
13
+ */
14
+ export function handle(request: OutgoingRequest, options: RequestOptions | undefined): FutureIncomingResponse;
15
+ export type OutgoingRequest = import('./wasi-http-types.js').OutgoingRequest;
16
+ export type RequestOptions = import('./wasi-http-types.js').RequestOptions;
17
+ export type FutureIncomingResponse = import('./wasi-http-types.js').FutureIncomingResponse;
18
+ export type ErrorCode = import('./wasi-http-types.js').ErrorCode;