@unicity-astrid/sdk 0.1.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/README.md +120 -0
- package/dist/approval.d.ts +23 -0
- package/dist/approval.d.ts.map +1 -0
- package/dist/approval.js +29 -0
- package/dist/approval.js.map +1 -0
- package/dist/capabilities.d.ts +14 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +19 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/capsule.d.ts +39 -0
- package/dist/capsule.d.ts.map +1 -0
- package/dist/capsule.js +67 -0
- package/dist/capsule.js.map +1 -0
- package/dist/contracts.d.ts +1104 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +4 -0
- package/dist/contracts.js.map +1 -0
- package/dist/elicit.d.ts +30 -0
- package/dist/elicit.d.ts.map +1 -0
- package/dist/elicit.js +103 -0
- package/dist/elicit.js.map +1 -0
- package/dist/env.d.ts +19 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +27 -0
- package/dist/env.js.map +1 -0
- package/dist/errors.d.ts +46 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +108 -0
- package/dist/errors.js.map +1 -0
- package/dist/fs.d.ts +135 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +257 -0
- package/dist/fs.js.map +1 -0
- package/dist/http.d.ts +90 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +276 -0
- package/dist/http.js.map +1 -0
- package/dist/identity.d.ts +46 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +69 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors.d.ts +21 -0
- package/dist/interceptors.d.ts.map +1 -0
- package/dist/interceptors.js +22 -0
- package/dist/interceptors.js.map +1 -0
- package/dist/ipc.d.ts +143 -0
- package/dist/ipc.d.ts.map +1 -0
- package/dist/ipc.js +261 -0
- package/dist/ipc.js.map +1 -0
- package/dist/kv.d.ts +45 -0
- package/dist/kv.d.ts.map +1 -0
- package/dist/kv.js +91 -0
- package/dist/kv.js.map +1 -0
- package/dist/log.d.ts +17 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +40 -0
- package/dist/log.js.map +1 -0
- package/dist/net.d.ts +154 -0
- package/dist/net.d.ts.map +1 -0
- package/dist/net.js +421 -0
- package/dist/net.js.map +1 -0
- package/dist/process.d.ts +77 -0
- package/dist/process.d.ts.map +1 -0
- package/dist/process.js +128 -0
- package/dist/process.js.map +1 -0
- package/dist/runtime/bridge.d.ts +34 -0
- package/dist/runtime/bridge.d.ts.map +1 -0
- package/dist/runtime/bridge.js +326 -0
- package/dist/runtime/bridge.js.map +1 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/registry.d.ts +58 -0
- package/dist/runtime/registry.d.ts.map +1 -0
- package/dist/runtime/registry.js +129 -0
- package/dist/runtime/registry.js.map +1 -0
- package/dist/runtime.d.ts +36 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +50 -0
- package/dist/runtime.js.map +1 -0
- package/dist/time.d.ts +29 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +43 -0
- package/dist/time.js.map +1 -0
- package/dist/tool.d.ts +48 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +86 -0
- package/dist/tool.js.map +1 -0
- package/dist/uplink.d.ts +27 -0
- package/dist/uplink.d.ts.map +1 -0
- package/dist/uplink.js +36 -0
- package/dist/uplink.js.map +1 -0
- package/package.json +38 -0
- package/src/approval.ts +38 -0
- package/src/capabilities.ts +22 -0
- package/src/capsule.ts +90 -0
- package/src/contracts.ts +1189 -0
- package/src/elicit.ts +136 -0
- package/src/env.ts +31 -0
- package/src/errors.ts +122 -0
- package/src/fs.ts +357 -0
- package/src/http.ts +345 -0
- package/src/identity.ts +101 -0
- package/src/index.ts +83 -0
- package/src/interceptors.ts +25 -0
- package/src/ipc.ts +354 -0
- package/src/kv.ts +123 -0
- package/src/log.ts +43 -0
- package/src/net.ts +545 -0
- package/src/process.ts +205 -0
- package/src/runtime/bridge.ts +374 -0
- package/src/runtime/index.ts +11 -0
- package/src/runtime/registry.ts +178 -0
- package/src/runtime.ts +70 -0
- package/src/time.ts +48 -0
- package/src/tool.ts +125 -0
- package/src/uplink.ts +49 -0
- package/src/wit-imports.d.ts +689 -0
- package/wit-contracts/astrid-contracts.wit +1266 -0
package/dist/fs.js
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual filesystem — shape-compatible with `node:fs/promises` where it
|
|
3
|
+
* makes sense, including a `Stats`-like object with `isFile()` /
|
|
4
|
+
* `isDirectory()` methods.
|
|
5
|
+
*
|
|
6
|
+
* Path schemes follow VFS conventions (`workspace://`, `home://`, `tmp://`).
|
|
7
|
+
* The kernel re-resolves and re-validates every path on every call;
|
|
8
|
+
* {@link canonicalize} is for display / equality only, NOT a security check
|
|
9
|
+
* that subsequent calls can rely on.
|
|
10
|
+
*
|
|
11
|
+
* The Rust SDK's surface is sync (`std::fs`); we expose async (`await`) to
|
|
12
|
+
* match Node idioms even though the underlying host calls are synchronous.
|
|
13
|
+
* StarlingMonkey syncifies awaits at the WASM boundary.
|
|
14
|
+
*/
|
|
15
|
+
import { fsOpen as hostOpen, fsExists as hostExists, fsMkdir as hostMkdir, fsMkdirAll as hostMkdirAll, fsReaddir as hostReaddir, fsStat as hostStat, fsStatSymlink as hostStatSymlink, fsUnlink as hostUnlink, readFile as hostReadFile, writeFile as hostWriteFile, fsAppend as hostAppend, fsCopy as hostCopy, fsRename as hostRename, fsRemoveDirAll as hostRemoveDirAll, fsCanonicalize as hostCanonicalize, fsReadLink as hostReadLink, fsHardLink as hostHardLink, } from "astrid:fs/host@1.0.0";
|
|
16
|
+
import { SysError, callHost } from "./errors.js";
|
|
17
|
+
const decoder = new TextDecoder();
|
|
18
|
+
const encoder = new TextEncoder();
|
|
19
|
+
/**
|
|
20
|
+
* Stat result. Shaped like Node's `fs.Stats` for the fields the Astrid VFS
|
|
21
|
+
* surfaces. `size` is `bigint` (WIT `u64`); use `Number(size)` if you need a
|
|
22
|
+
* regular number and you're sure it fits.
|
|
23
|
+
*/
|
|
24
|
+
export class Stats {
|
|
25
|
+
size;
|
|
26
|
+
mode;
|
|
27
|
+
kind;
|
|
28
|
+
mtimeMs;
|
|
29
|
+
birthtimeMs;
|
|
30
|
+
atimeMs;
|
|
31
|
+
constructor(stat) {
|
|
32
|
+
this.size = stat.size;
|
|
33
|
+
this.mode = stat.mode;
|
|
34
|
+
this.kind = stat.kind;
|
|
35
|
+
this.mtimeMs = datetimeToMs(stat.modified);
|
|
36
|
+
this.birthtimeMs = datetimeToMs(stat.created);
|
|
37
|
+
this.atimeMs = datetimeToMs(stat.accessed);
|
|
38
|
+
}
|
|
39
|
+
isFile() {
|
|
40
|
+
return this.kind === "regular";
|
|
41
|
+
}
|
|
42
|
+
isDirectory() {
|
|
43
|
+
return this.kind === "directory";
|
|
44
|
+
}
|
|
45
|
+
isSymbolicLink() {
|
|
46
|
+
return this.kind === "symlink";
|
|
47
|
+
}
|
|
48
|
+
isEmpty() {
|
|
49
|
+
return this.size === 0n;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Directory entry returned by `readdir({ withFileTypes: true })`. */
|
|
53
|
+
export class Dirent {
|
|
54
|
+
name;
|
|
55
|
+
path;
|
|
56
|
+
parentPath;
|
|
57
|
+
constructor(parentPath, name) {
|
|
58
|
+
this.name = name;
|
|
59
|
+
this.parentPath = parentPath;
|
|
60
|
+
this.path = parentPath.endsWith("/") ? parentPath + name : `${parentPath}/${name}`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Open file handle. Returned from {@link open}. The host releases the
|
|
65
|
+
* underlying file descriptor automatically when the handle is dropped via
|
|
66
|
+
* `Symbol.dispose` or `.close()`. Per-capsule cap: 16 open file handles.
|
|
67
|
+
*
|
|
68
|
+
* ```ts
|
|
69
|
+
* using f = await fs.open("workspace://data.bin", "read-write");
|
|
70
|
+
* await f.writeAt(0n, new TextEncoder().encode("hello"));
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export class FileHandle {
|
|
74
|
+
#inner;
|
|
75
|
+
path;
|
|
76
|
+
constructor(inner, path) {
|
|
77
|
+
this.#inner = inner;
|
|
78
|
+
this.path = path;
|
|
79
|
+
}
|
|
80
|
+
/** Read up to `maxBytes` from `offset`. Empty result signals EOF at that offset. */
|
|
81
|
+
async readAt(offset, maxBytes) {
|
|
82
|
+
return callHost(`fs.FileHandle.readAt(${quote(this.path)})`, () => this.#requireInner().readAt(offset, maxBytes));
|
|
83
|
+
}
|
|
84
|
+
/** Write `data` at `offset`. Returns bytes actually written. */
|
|
85
|
+
async writeAt(offset, data) {
|
|
86
|
+
return callHost(`fs.FileHandle.writeAt(${quote(this.path)})`, () => this.#requireInner().writeAt(offset, data));
|
|
87
|
+
}
|
|
88
|
+
/** Flush buffered data (only) to disk — `fdatasync(2)`. */
|
|
89
|
+
async syncData() {
|
|
90
|
+
callHost(`fs.FileHandle.syncData(${quote(this.path)})`, () => this.#requireInner().syncData());
|
|
91
|
+
}
|
|
92
|
+
/** Flush both data and metadata to disk — `fsync(2)`. */
|
|
93
|
+
async syncAll() {
|
|
94
|
+
callHost(`fs.FileHandle.syncAll(${quote(this.path)})`, () => this.#requireInner().syncAll());
|
|
95
|
+
}
|
|
96
|
+
/** Race-free counterpart to {@link stat} on the path. */
|
|
97
|
+
async stat() {
|
|
98
|
+
const raw = callHost(`fs.FileHandle.stat(${quote(this.path)})`, () => this.#requireInner().stat());
|
|
99
|
+
return new Stats(raw);
|
|
100
|
+
}
|
|
101
|
+
/** Truncate or extend the file to `size` bytes. Extending past end fills with zeros. */
|
|
102
|
+
async setLen(size) {
|
|
103
|
+
callHost(`fs.FileHandle.setLen(${quote(this.path)})`, () => this.#requireInner().setLen(size));
|
|
104
|
+
}
|
|
105
|
+
close() {
|
|
106
|
+
if (this.#inner === undefined)
|
|
107
|
+
return;
|
|
108
|
+
const inner = this.#inner;
|
|
109
|
+
this.#inner = undefined;
|
|
110
|
+
try {
|
|
111
|
+
inner[Symbol.dispose]();
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// Already disposed by the runtime; safe to ignore.
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
[Symbol.dispose]() {
|
|
118
|
+
this.close();
|
|
119
|
+
}
|
|
120
|
+
#requireInner() {
|
|
121
|
+
if (this.#inner === undefined) {
|
|
122
|
+
throw SysError.api(`FileHandle ${quote(this.path)} is closed`);
|
|
123
|
+
}
|
|
124
|
+
return this.#inner;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/** Open a file by path. Required capability depends on `mode`. */
|
|
128
|
+
export async function open(path, mode) {
|
|
129
|
+
const inner = callHost(`fs.open(${quote(path)})`, () => hostOpen(path, mode));
|
|
130
|
+
return new FileHandle(inner, path);
|
|
131
|
+
}
|
|
132
|
+
export async function exists(path) {
|
|
133
|
+
return callHost(`fs.exists(${quote(path)})`, () => hostExists(path));
|
|
134
|
+
}
|
|
135
|
+
export async function stat(path) {
|
|
136
|
+
const raw = callHost(`fs.stat(${quote(path)})`, () => hostStat(path));
|
|
137
|
+
return new Stats(raw);
|
|
138
|
+
}
|
|
139
|
+
/** Stat without following symlinks — `lstat(2)`. */
|
|
140
|
+
export async function lstat(path) {
|
|
141
|
+
const raw = callHost(`fs.lstat(${quote(path)})`, () => hostStatSymlink(path));
|
|
142
|
+
return new Stats(raw);
|
|
143
|
+
}
|
|
144
|
+
export async function readFile(path, options) {
|
|
145
|
+
const bytes = callHost(`fs.readFile(${quote(path)})`, () => hostReadFile(path));
|
|
146
|
+
if (options?.encoding === "utf8")
|
|
147
|
+
return decoder.decode(bytes);
|
|
148
|
+
return bytes;
|
|
149
|
+
}
|
|
150
|
+
/** Read a file as UTF-8 text. */
|
|
151
|
+
export async function readTextFile(path) {
|
|
152
|
+
const bytes = callHost(`fs.readTextFile(${quote(path)})`, () => hostReadFile(path));
|
|
153
|
+
try {
|
|
154
|
+
return decoder.decode(bytes);
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
throw SysError.api(`fs.readTextFile(${quote(path)}): ${err.message}`, err);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export async function writeFile(path, data) {
|
|
161
|
+
const bytes = typeof data === "string" ? encoder.encode(data) : data;
|
|
162
|
+
callHost(`fs.writeFile(${quote(path)})`, () => hostWriteFile(path, bytes));
|
|
163
|
+
}
|
|
164
|
+
/** Append `data` to a file, creating it if absent. */
|
|
165
|
+
export async function appendFile(path, data) {
|
|
166
|
+
const bytes = typeof data === "string" ? encoder.encode(data) : data;
|
|
167
|
+
callHost(`fs.appendFile(${quote(path)})`, () => hostAppend(path, bytes));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Create a directory. Mirrors `std::fs::create_dir` / `mkdir(2)` — strict.
|
|
171
|
+
* Fails with `already-exists` if the path exists. Use {@link mkdirAll} for
|
|
172
|
+
* idempotent "ensure-exists" semantics.
|
|
173
|
+
*/
|
|
174
|
+
export async function mkdir(path) {
|
|
175
|
+
callHost(`fs.mkdir(${quote(path)})`, () => hostMkdir(path));
|
|
176
|
+
}
|
|
177
|
+
/** Create a directory and all missing parents. Idempotent. */
|
|
178
|
+
export async function mkdirAll(path) {
|
|
179
|
+
callHost(`fs.mkdirAll(${quote(path)})`, () => hostMkdirAll(path));
|
|
180
|
+
}
|
|
181
|
+
/** Remove a file. Mirrors `fs.unlink` / `fs.rm` (file-only). */
|
|
182
|
+
export async function rm(path) {
|
|
183
|
+
callHost(`fs.rm(${quote(path)})`, () => hostUnlink(path));
|
|
184
|
+
}
|
|
185
|
+
/** Alias for {@link rm} matching Node's `fs.unlink`. */
|
|
186
|
+
export const unlink = rm;
|
|
187
|
+
/**
|
|
188
|
+
* Remove a directory and all its contents recursively. Refuses to traverse
|
|
189
|
+
* symlinks to prevent sandbox escapes. Returns the count of removed entries.
|
|
190
|
+
*/
|
|
191
|
+
export async function removeDirAll(path) {
|
|
192
|
+
return callHost(`fs.removeDirAll(${quote(path)})`, () => hostRemoveDirAll(path));
|
|
193
|
+
}
|
|
194
|
+
/** Copy a file from `src` to `dst`. Overwrites `dst`. */
|
|
195
|
+
export async function copy(src, dst) {
|
|
196
|
+
callHost(`fs.copy(${quote(src)} -> ${quote(dst)})`, () => hostCopy(src, dst));
|
|
197
|
+
}
|
|
198
|
+
/** Rename (move) within the same VFS scheme. Cross-scheme returns `cross-vfs`. */
|
|
199
|
+
export async function rename(src, dst) {
|
|
200
|
+
callHost(`fs.rename(${quote(src)} -> ${quote(dst)})`, () => hostRename(src, dst));
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Resolve a path to its canonical form, following symlinks. Returns a
|
|
204
|
+
* VFS-scheme path, never a host real-path. NOT a TOCTOU-safe security check.
|
|
205
|
+
*/
|
|
206
|
+
export async function canonicalize(path) {
|
|
207
|
+
return callHost(`fs.canonicalize(${quote(path)})`, () => hostCanonicalize(path));
|
|
208
|
+
}
|
|
209
|
+
/** Read a symlink target without following it. */
|
|
210
|
+
export async function readLink(path) {
|
|
211
|
+
return callHost(`fs.readLink(${quote(path)})`, () => hostReadLink(path));
|
|
212
|
+
}
|
|
213
|
+
/** Create a hard link. Both endpoints must be in the same VFS scheme. */
|
|
214
|
+
export async function hardLink(src, linkPath) {
|
|
215
|
+
callHost(`fs.hardLink(${quote(src)} -> ${quote(linkPath)})`, () => hostHardLink(src, linkPath));
|
|
216
|
+
}
|
|
217
|
+
export async function readdir(path, options) {
|
|
218
|
+
const names = callHost(`fs.readdir(${quote(path)})`, () => hostReaddir(path));
|
|
219
|
+
if (options?.withFileTypes) {
|
|
220
|
+
return names.map((n) => new Dirent(path, n));
|
|
221
|
+
}
|
|
222
|
+
return names;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Stream-style directory iteration. Mirrors `fs.opendir` / `Dir`. The VFS
|
|
226
|
+
* resolves all entries in one host call, so the async-iterator is fully
|
|
227
|
+
* populated up-front; the shape matches Node for compatibility.
|
|
228
|
+
*/
|
|
229
|
+
export async function opendir(path) {
|
|
230
|
+
const entries = await readdir(path, { withFileTypes: true });
|
|
231
|
+
let i = 0;
|
|
232
|
+
const iter = {
|
|
233
|
+
[Symbol.asyncIterator]() {
|
|
234
|
+
return iter;
|
|
235
|
+
},
|
|
236
|
+
async next() {
|
|
237
|
+
if (i >= entries.length) {
|
|
238
|
+
return { value: undefined, done: true };
|
|
239
|
+
}
|
|
240
|
+
return { value: entries[i++], done: false };
|
|
241
|
+
},
|
|
242
|
+
async return() {
|
|
243
|
+
i = entries.length;
|
|
244
|
+
return { value: undefined, done: true };
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
return iter;
|
|
248
|
+
}
|
|
249
|
+
function datetimeToMs(dt) {
|
|
250
|
+
if (dt === undefined)
|
|
251
|
+
return undefined;
|
|
252
|
+
return Number(dt.seconds) * 1000 + dt.nanoseconds / 1_000_000;
|
|
253
|
+
}
|
|
254
|
+
function quote(s) {
|
|
255
|
+
return `"${s.replace(/"/g, '\\"')}"`;
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=fs.js.map
|
package/dist/fs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,MAAM,IAAI,QAAQ,EAClB,QAAQ,IAAI,UAAU,EACtB,OAAO,IAAI,SAAS,EACpB,UAAU,IAAI,YAAY,EAC1B,SAAS,IAAI,WAAW,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DED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound HTTP. Two public shapes:
|
|
3
|
+
*
|
|
4
|
+
* 1. A builder-style {@link Request} / {@link Response} mirroring the Rust
|
|
5
|
+
* SDK's reqwest-like API (`http.get(url)`, `http.send(req)`).
|
|
6
|
+
* 2. A WHATWG `fetch(url, init)` polyfill registered onto `globalThis`
|
|
7
|
+
* at SDK init via {@link installFetchPolyfill}. Routes through the same
|
|
8
|
+
* capability-gated host imports so users can't bypass the per-capsule
|
|
9
|
+
* net allow-list by reaching for the platform fetch.
|
|
10
|
+
*
|
|
11
|
+
* Streaming: {@link streamStart} returns an {@link HttpStream} resource
|
|
12
|
+
* handle with `read-chunk` for explicit per-chunk pulls, an `async-iterator`
|
|
13
|
+
* convenience, and access to the body as an `astrid:io/streams` `InputStream`
|
|
14
|
+
* for capsules forwarding the body into another sink.
|
|
15
|
+
*/
|
|
16
|
+
import { type HttpRequestData, type HttpResponseData, type HttpStream as WitHttpStream } from "astrid:http/host@1.0.0";
|
|
17
|
+
export type HttpMethod = "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "PATCH" | string;
|
|
18
|
+
export declare class Request {
|
|
19
|
+
url: string;
|
|
20
|
+
method: string;
|
|
21
|
+
headers: Map<string, string>;
|
|
22
|
+
body: Uint8Array | undefined;
|
|
23
|
+
constructor(method: string, url: string);
|
|
24
|
+
static get(url: string): Request;
|
|
25
|
+
static post(url: string): Request;
|
|
26
|
+
static put(url: string): Request;
|
|
27
|
+
static delete(url: string): Request;
|
|
28
|
+
static patch(url: string): Request;
|
|
29
|
+
static head(url: string): Request;
|
|
30
|
+
header(key: string, value: string): this;
|
|
31
|
+
setBody(body: string | Uint8Array): this;
|
|
32
|
+
json<T>(value: T): this;
|
|
33
|
+
toWit(): HttpRequestData;
|
|
34
|
+
}
|
|
35
|
+
export declare class Response {
|
|
36
|
+
#private;
|
|
37
|
+
readonly status: number;
|
|
38
|
+
readonly headers: Map<string, string>;
|
|
39
|
+
constructor(raw: HttpResponseData);
|
|
40
|
+
bytes(): Uint8Array;
|
|
41
|
+
text(): string;
|
|
42
|
+
json<T = unknown>(): T;
|
|
43
|
+
ok(): boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare function send(req: Request): Response;
|
|
46
|
+
/**
|
|
47
|
+
* Streaming HTTP response. The kernel buffers chunks server-side; the
|
|
48
|
+
* capsule reads them via `.read()` (or the async iterator) until EOF. Drop
|
|
49
|
+
* (via `using` or `.close()`) releases the host-side resource.
|
|
50
|
+
*/
|
|
51
|
+
export declare class HttpStreamHandle {
|
|
52
|
+
#private;
|
|
53
|
+
readonly status: number;
|
|
54
|
+
readonly headers: Map<string, string>;
|
|
55
|
+
constructor(inner: WitHttpStream);
|
|
56
|
+
/** Read the next chunk. Returns `undefined` at EOF. */
|
|
57
|
+
read(): Uint8Array | undefined;
|
|
58
|
+
close(): void;
|
|
59
|
+
[Symbol.dispose](): void;
|
|
60
|
+
/** Async iterator that yields each chunk until EOF. Auto-closes on completion. */
|
|
61
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<Uint8Array>;
|
|
62
|
+
}
|
|
63
|
+
export interface StreamStart {
|
|
64
|
+
handle: HttpStreamHandle;
|
|
65
|
+
status: number;
|
|
66
|
+
headers: Map<string, string>;
|
|
67
|
+
}
|
|
68
|
+
export declare function streamStart(req: Request): StreamStart;
|
|
69
|
+
export interface FetchInit {
|
|
70
|
+
method?: string;
|
|
71
|
+
headers?: Record<string, string> | Map<string, string> | [string, string][];
|
|
72
|
+
body?: string | Uint8Array | Record<string, unknown>;
|
|
73
|
+
}
|
|
74
|
+
export declare class FetchResponse {
|
|
75
|
+
#private;
|
|
76
|
+
readonly status: number;
|
|
77
|
+
readonly statusText: string;
|
|
78
|
+
readonly headers: Headers;
|
|
79
|
+
readonly url: string;
|
|
80
|
+
readonly ok: boolean;
|
|
81
|
+
constructor(url: string, status: number, headerEntries: [string, string][], body: Uint8Array);
|
|
82
|
+
text(): Promise<string>;
|
|
83
|
+
json<T = unknown>(): Promise<T>;
|
|
84
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
85
|
+
bytes(): Promise<Uint8Array>;
|
|
86
|
+
}
|
|
87
|
+
export declare function fetchPolyfill(url: string, init?: FetchInit): Promise<FetchResponse>;
|
|
88
|
+
/** Install the polyfill on `globalThis.fetch`. */
|
|
89
|
+
export declare function installFetchPolyfill(): void;
|
|
90
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,UAAU,IAAI,aAAa,EAGjC,MAAM,wBAAwB,CAAC;AAOhC,MAAM,MAAM,UAAU,GAClB,KAAK,GACL,MAAM,GACN,MAAM,GACN,KAAK,GACL,QAAQ,GACR,SAAS,GACT,SAAS,GACT,OAAO,GACP,OAAO,GACP,MAAM,CAAC;AAgCX,qBAAa,OAAO;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;gBAEjB,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAOvC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAGhC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAGjC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAGhC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAGnC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAA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Rust
|
|
5
|
+
* SDK's reqwest-like API (`http.get(url)`, `http.send(req)`).
|
|
6
|
+
* 2. A WHATWG `fetch(url, init)` polyfill registered onto `globalThis`
|
|
7
|
+
* at SDK init via {@link installFetchPolyfill}. Routes through the same
|
|
8
|
+
* capability-gated host imports so users can't bypass the per-capsule
|
|
9
|
+
* net allow-list by reaching for the platform fetch.
|
|
10
|
+
*
|
|
11
|
+
* Streaming: {@link streamStart} returns an {@link HttpStream} resource
|
|
12
|
+
* handle with `read-chunk` for explicit per-chunk pulls, an `async-iterator`
|
|
13
|
+
* convenience, and access to the body as an `astrid:io/streams` `InputStream`
|
|
14
|
+
* for capsules forwarding the body into another sink.
|
|
15
|
+
*/
|
|
16
|
+
import { httpRequest as hostRequest, httpStreamStart as hostStreamStart, } from "astrid:http/host@1.0.0";
|
|
17
|
+
import { SysError, callHost } from "./errors.js";
|
|
18
|
+
/** Convert a string method name into the WIT variant the host expects. */
|
|
19
|
+
function methodToWit(method) {
|
|
20
|
+
switch (method.toUpperCase()) {
|
|
21
|
+
case "GET":
|
|
22
|
+
return { tag: "get" };
|
|
23
|
+
case "HEAD":
|
|
24
|
+
return { tag: "head" };
|
|
25
|
+
case "POST":
|
|
26
|
+
return { tag: "post" };
|
|
27
|
+
case "PUT":
|
|
28
|
+
return { tag: "put" };
|
|
29
|
+
case "DELETE":
|
|
30
|
+
return { tag: "delete" };
|
|
31
|
+
case "CONNECT":
|
|
32
|
+
return { tag: "connect" };
|
|
33
|
+
case "OPTIONS":
|
|
34
|
+
return { tag: "options" };
|
|
35
|
+
case "TRACE":
|
|
36
|
+
return { tag: "trace" };
|
|
37
|
+
case "PATCH":
|
|
38
|
+
return { tag: "patch" };
|
|
39
|
+
default:
|
|
40
|
+
return { tag: "other", val: method };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// Builder API (reqwest shape)
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
export class Request {
|
|
47
|
+
url;
|
|
48
|
+
method;
|
|
49
|
+
headers;
|
|
50
|
+
body;
|
|
51
|
+
constructor(method, url) {
|
|
52
|
+
this.method = method;
|
|
53
|
+
this.url = url;
|
|
54
|
+
this.headers = new Map();
|
|
55
|
+
this.body = undefined;
|
|
56
|
+
}
|
|
57
|
+
static get(url) {
|
|
58
|
+
return new Request("GET", url);
|
|
59
|
+
}
|
|
60
|
+
static post(url) {
|
|
61
|
+
return new Request("POST", url);
|
|
62
|
+
}
|
|
63
|
+
static put(url) {
|
|
64
|
+
return new Request("PUT", url);
|
|
65
|
+
}
|
|
66
|
+
static delete(url) {
|
|
67
|
+
return new Request("DELETE", url);
|
|
68
|
+
}
|
|
69
|
+
static patch(url) {
|
|
70
|
+
return new Request("PATCH", url);
|
|
71
|
+
}
|
|
72
|
+
static head(url) {
|
|
73
|
+
return new Request("HEAD", url);
|
|
74
|
+
}
|
|
75
|
+
header(key, value) {
|
|
76
|
+
this.headers.set(key, value);
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
setBody(body) {
|
|
80
|
+
this.body = typeof body === "string" ? new TextEncoder().encode(body) : body;
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
json(value) {
|
|
84
|
+
this.headers.set("Content-Type", "application/json");
|
|
85
|
+
let s;
|
|
86
|
+
try {
|
|
87
|
+
s = JSON.stringify(value);
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
throw SysError.json(`http.Request.json: ${err.message}`, err);
|
|
91
|
+
}
|
|
92
|
+
this.body = new TextEncoder().encode(s);
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
toWit() {
|
|
96
|
+
return {
|
|
97
|
+
url: this.url,
|
|
98
|
+
method: methodToWit(this.method),
|
|
99
|
+
headers: Array.from(this.headers, ([key, value]) => ({ key, value })),
|
|
100
|
+
body: this.body,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export class Response {
|
|
105
|
+
status;
|
|
106
|
+
headers;
|
|
107
|
+
#body;
|
|
108
|
+
constructor(raw) {
|
|
109
|
+
this.status = raw.status;
|
|
110
|
+
this.headers = new Map(raw.headers.map((h) => [h.key, h.value]));
|
|
111
|
+
this.#body = raw.body;
|
|
112
|
+
}
|
|
113
|
+
bytes() {
|
|
114
|
+
return this.#body;
|
|
115
|
+
}
|
|
116
|
+
text() {
|
|
117
|
+
return new TextDecoder().decode(this.#body);
|
|
118
|
+
}
|
|
119
|
+
json() {
|
|
120
|
+
try {
|
|
121
|
+
return JSON.parse(this.text());
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
throw SysError.json(`http.Response.json: ${err.message}`, err);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
ok() {
|
|
128
|
+
return this.status >= 200 && this.status < 300;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export function send(req) {
|
|
132
|
+
const wit = req.toWit();
|
|
133
|
+
const raw = callHost(`http.send ${req.method} ${req.url}`, () => hostRequest(wit));
|
|
134
|
+
return new Response(raw);
|
|
135
|
+
}
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
// Streaming
|
|
138
|
+
// ---------------------------------------------------------------------------
|
|
139
|
+
/**
|
|
140
|
+
* Streaming HTTP response. The kernel buffers chunks server-side; the
|
|
141
|
+
* capsule reads them via `.read()` (or the async iterator) until EOF. Drop
|
|
142
|
+
* (via `using` or `.close()`) releases the host-side resource.
|
|
143
|
+
*/
|
|
144
|
+
export class HttpStreamHandle {
|
|
145
|
+
#inner;
|
|
146
|
+
status;
|
|
147
|
+
headers;
|
|
148
|
+
constructor(inner) {
|
|
149
|
+
this.#inner = inner;
|
|
150
|
+
this.status = inner.status();
|
|
151
|
+
this.headers = new Map(inner.headers().map((h) => [h.key, h.value]));
|
|
152
|
+
}
|
|
153
|
+
/** Read the next chunk. Returns `undefined` at EOF. */
|
|
154
|
+
read() {
|
|
155
|
+
if (this.#inner === undefined)
|
|
156
|
+
return undefined;
|
|
157
|
+
const chunk = callHost("http.HttpStream.readChunk", () => this.#inner.readChunk());
|
|
158
|
+
if (chunk.length === 0)
|
|
159
|
+
return undefined;
|
|
160
|
+
return chunk;
|
|
161
|
+
}
|
|
162
|
+
close() {
|
|
163
|
+
if (this.#inner === undefined)
|
|
164
|
+
return;
|
|
165
|
+
const inner = this.#inner;
|
|
166
|
+
this.#inner = undefined;
|
|
167
|
+
try {
|
|
168
|
+
// Explicit close mirrors the WIT-defined `.close()`; the Drop step still
|
|
169
|
+
// runs on resource release regardless.
|
|
170
|
+
inner.close();
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
// idempotent close — host may have already released it.
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
inner[Symbol.dispose]();
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
// already released
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
[Symbol.dispose]() {
|
|
183
|
+
this.close();
|
|
184
|
+
}
|
|
185
|
+
/** Async iterator that yields each chunk until EOF. Auto-closes on completion. */
|
|
186
|
+
async *[Symbol.asyncIterator]() {
|
|
187
|
+
try {
|
|
188
|
+
while (true) {
|
|
189
|
+
const chunk = this.read();
|
|
190
|
+
if (chunk === undefined)
|
|
191
|
+
return;
|
|
192
|
+
yield chunk;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
finally {
|
|
196
|
+
this.close();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
export function streamStart(req) {
|
|
201
|
+
const wit = req.toWit();
|
|
202
|
+
const inner = callHost(`http.streamStart ${req.method} ${req.url}`, () => hostStreamStart(wit));
|
|
203
|
+
const handle = new HttpStreamHandle(inner);
|
|
204
|
+
return { handle, status: handle.status, headers: handle.headers };
|
|
205
|
+
}
|
|
206
|
+
export class FetchResponse {
|
|
207
|
+
status;
|
|
208
|
+
statusText;
|
|
209
|
+
headers;
|
|
210
|
+
url;
|
|
211
|
+
ok;
|
|
212
|
+
#body;
|
|
213
|
+
constructor(url, status, headerEntries, body) {
|
|
214
|
+
this.url = url;
|
|
215
|
+
this.status = status;
|
|
216
|
+
this.statusText = httpStatusText(status);
|
|
217
|
+
this.headers = new Headers(headerEntries);
|
|
218
|
+
this.ok = status >= 200 && status < 300;
|
|
219
|
+
this.#body = body;
|
|
220
|
+
}
|
|
221
|
+
async text() {
|
|
222
|
+
return new TextDecoder().decode(this.#body);
|
|
223
|
+
}
|
|
224
|
+
async json() {
|
|
225
|
+
return JSON.parse(await this.text());
|
|
226
|
+
}
|
|
227
|
+
async arrayBuffer() {
|
|
228
|
+
return this.#body.buffer.slice(this.#body.byteOffset, this.#body.byteOffset + this.#body.byteLength);
|
|
229
|
+
}
|
|
230
|
+
async bytes() {
|
|
231
|
+
return this.#body;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
export async function fetchPolyfill(url, init = {}) {
|
|
235
|
+
const req = new Request(init.method ?? "GET", url);
|
|
236
|
+
if (init.headers) {
|
|
237
|
+
for (const [k, v] of normalizeHeaders(init.headers)) {
|
|
238
|
+
req.header(k, v);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (init.body !== undefined) {
|
|
242
|
+
if (typeof init.body === "string") {
|
|
243
|
+
req.setBody(init.body);
|
|
244
|
+
}
|
|
245
|
+
else if (init.body instanceof Uint8Array) {
|
|
246
|
+
req.setBody(init.body);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
req.json(init.body);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const raw = callHost(`fetch ${req.method} ${url}`, () => hostRequest(req.toWit()));
|
|
253
|
+
return new FetchResponse(url, raw.status, raw.headers.map((h) => [h.key, h.value]), raw.body);
|
|
254
|
+
}
|
|
255
|
+
/** Install the polyfill on `globalThis.fetch`. */
|
|
256
|
+
export function installFetchPolyfill() {
|
|
257
|
+
globalThis.fetch = fetchPolyfill;
|
|
258
|
+
}
|
|
259
|
+
function normalizeHeaders(input) {
|
|
260
|
+
if (input instanceof Map)
|
|
261
|
+
return input.entries();
|
|
262
|
+
if (Array.isArray(input))
|
|
263
|
+
return input;
|
|
264
|
+
return Object.entries(input);
|
|
265
|
+
}
|
|
266
|
+
function httpStatusText(code) {
|
|
267
|
+
const map = {
|
|
268
|
+
200: "OK", 201: "Created", 202: "Accepted", 204: "No Content",
|
|
269
|
+
301: "Moved Permanently", 302: "Found", 304: "Not Modified",
|
|
270
|
+
400: "Bad Request", 401: "Unauthorized", 403: "Forbidden", 404: "Not Found",
|
|
271
|
+
409: "Conflict", 422: "Unprocessable Entity", 429: "Too Many Requests",
|
|
272
|
+
500: "Internal Server Error", 502: "Bad Gateway", 503: "Service Unavailable",
|
|
273
|
+
};
|
|
274
|
+
return map[code] ?? "";
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,WAAW,IAAI,WAAW,EAC1B,eAAe,IAAI,eAAe,GAMnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAkBjD,0EAA0E;AAC1E,SAAS,WAAW,CAAC,MAAc;IACjC,QAAQ,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;QAC7B,KAAK,KAAK;YACR,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;QACxB,KAAK,MAAM;YACT,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;QACzB,KAAK,MAAM;YACT,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;QACzB,KAAK,KAAK;YACR,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;QACxB,KAAK,QAAQ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