mirror of
https://github.com/trailbaseio/trailbase.git
synced 2026-05-19 07:49:57 -05:00
Use jco guest-types for WASM guest type generation.
This commit is contained in:
@@ -5,7 +5,7 @@ export default [
|
||||
pluginJs.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
ignores: ["dist/", "node_modules/"],
|
||||
ignores: ["dist/", "node_modules/", "generated/types"],
|
||||
},
|
||||
{
|
||||
files: ["src/**/*.{js,mjs,cjs,mts,ts,tsx,jsx}"],
|
||||
@@ -13,8 +13,6 @@ export default [
|
||||
// https://typescript-eslint.io/rules/no-explicit-any/
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
"@typescript-eslint/no-wrapper-object-types": "warn",
|
||||
"@typescript-eslint/no-namespace": "off",
|
||||
"no-var": "off",
|
||||
// http://eslint.org/docs/rules/no-unused-vars
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
|
||||
+40
-20
@@ -1,20 +1,40 @@
|
||||
// WIT world: trailbase:component/interfaces@0.1.0.
|
||||
export type * as TrailbaseDatabaseSqlite010 from 'trailbase:database/sqlite@0.1.0'; // import trailbase:database/sqlite@0.1.0
|
||||
export type * as WasiClocksMonotonicClock023 from 'wasi:clocks/monotonic-clock@0.2.3'; // import wasi:clocks/monotonic-clock@0.2.3
|
||||
export type * as WasiClocksWallClock023 from 'wasi:clocks/wall-clock@0.2.3'; // import wasi:clocks/wall-clock@0.2.3
|
||||
export type * as WasiFilesystemPreopens023 from 'wasi:filesystem/preopens@0.2.3'; // import wasi:filesystem/preopens@0.2.3
|
||||
export type * as WasiFilesystemTypes023 from 'wasi:filesystem/types@0.2.3'; // import wasi:filesystem/types@0.2.3
|
||||
export type * as WasiHttpOutgoingHandler023 from 'wasi:http/outgoing-handler@0.2.3'; // import wasi:http/outgoing-handler@0.2.3
|
||||
export type * as WasiHttpTypes023 from 'wasi:http/types@0.2.3'; // import wasi:http/types@0.2.3
|
||||
export type * as WasiIoError023 from 'wasi:io/error@0.2.3'; // import wasi:io/error@0.2.3
|
||||
export type * as WasiIoPoll023 from 'wasi:io/poll@0.2.3'; // import wasi:io/poll@0.2.3
|
||||
export type * as WasiIoStreams023 from 'wasi:io/streams@0.2.3'; // import wasi:io/streams@0.2.3
|
||||
export type * as WasiKeyvalueAtomics020Draft from 'wasi:keyvalue/atomics@0.2.0-draft'; // import wasi:keyvalue/atomics@0.2.0-draft
|
||||
export type * as WasiKeyvalueBatch020Draft from 'wasi:keyvalue/batch@0.2.0-draft'; // import wasi:keyvalue/batch@0.2.0-draft
|
||||
export type * as WasiKeyvalueStore020Draft from 'wasi:keyvalue/store@0.2.0-draft'; // import wasi:keyvalue/store@0.2.0-draft
|
||||
export type * as WasiRandomInsecureSeed023 from 'wasi:random/insecure-seed@0.2.3'; // import wasi:random/insecure-seed@0.2.3
|
||||
export type * as WasiRandomInsecure023 from 'wasi:random/insecure@0.2.3'; // import wasi:random/insecure@0.2.3
|
||||
export type * as WasiRandomRandom023 from 'wasi:random/random@0.2.3'; // import wasi:random/random@0.2.3
|
||||
export * as incomingHandler from 'wasi:http/incoming-handler@0.2.3'; // export wasi:http/incoming-handler@0.2.3
|
||||
export * as initEndpoint from 'trailbase:component/init-endpoint@0.1.0'; // export trailbase:component/init-endpiont@0.1.0
|
||||
export * as sqliteFunctionEndpoint from 'trailbase:component/sqlite-function-endpoint@0.1.0'; // export trailbase:component/sqlite-function-endpoint@0.1.0
|
||||
/// <reference path="./interfaces/trailbase-component-init-endpoint.d.ts" />
|
||||
/// <reference path="./interfaces/trailbase-component-sqlite-function-endpoint.d.ts" />
|
||||
/// <reference path="./interfaces/trailbase-database-sqlite.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-clocks-monotonic-clock.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-clocks-wall-clock.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-filesystem-preopens.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-filesystem-types.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-http-incoming-handler.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-http-outgoing-handler.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-http-types.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-io-error.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-io-poll.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-io-streams.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-keyvalue-atomics.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-keyvalue-batch.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-keyvalue-store.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-random-insecure-seed.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-random-insecure.d.ts" />
|
||||
/// <reference path="./interfaces/wasi-random-random.d.ts" />
|
||||
declare module "trailbase:component/interfaces@0.1.0" {
|
||||
export type * as TrailbaseDatabaseSqlite010 from "trailbase:database/sqlite@0.1.0"; // import trailbase:database/sqlite@0.1.0
|
||||
export type * as WasiClocksMonotonicClock023 from "wasi:clocks/monotonic-clock@0.2.3"; // import wasi:clocks/monotonic-clock@0.2.3
|
||||
export type * as WasiClocksWallClock023 from "wasi:clocks/wall-clock@0.2.3"; // import wasi:clocks/wall-clock@0.2.3
|
||||
export type * as WasiFilesystemPreopens023 from "wasi:filesystem/preopens@0.2.3"; // import wasi:filesystem/preopens@0.2.3
|
||||
export type * as WasiFilesystemTypes023 from "wasi:filesystem/types@0.2.3"; // import wasi:filesystem/types@0.2.3
|
||||
export type * as WasiHttpOutgoingHandler023 from "wasi:http/outgoing-handler@0.2.3"; // import wasi:http/outgoing-handler@0.2.3
|
||||
export type * as WasiHttpTypes023 from "wasi:http/types@0.2.3"; // import wasi:http/types@0.2.3
|
||||
export type * as WasiIoError023 from "wasi:io/error@0.2.3"; // import wasi:io/error@0.2.3
|
||||
export type * as WasiIoPoll023 from "wasi:io/poll@0.2.3"; // import wasi:io/poll@0.2.3
|
||||
export type * as WasiIoStreams023 from "wasi:io/streams@0.2.3"; // import wasi:io/streams@0.2.3
|
||||
export type * as WasiKeyvalueAtomics020Draft from "wasi:keyvalue/atomics@0.2.0-draft"; // import wasi:keyvalue/atomics@0.2.0-draft
|
||||
export type * as WasiKeyvalueBatch020Draft from "wasi:keyvalue/batch@0.2.0-draft"; // import wasi:keyvalue/batch@0.2.0-draft
|
||||
export type * as WasiKeyvalueStore020Draft from "wasi:keyvalue/store@0.2.0-draft"; // import wasi:keyvalue/store@0.2.0-draft
|
||||
export type * as WasiRandomInsecureSeed023 from "wasi:random/insecure-seed@0.2.3"; // import wasi:random/insecure-seed@0.2.3
|
||||
export type * as WasiRandomInsecure023 from "wasi:random/insecure@0.2.3"; // import wasi:random/insecure@0.2.3
|
||||
export type * as WasiRandomRandom023 from "wasi:random/random@0.2.3"; // import wasi:random/random@0.2.3
|
||||
export * as incomingHandler from "wasi:http/incoming-handler@0.2.3"; // export wasi:http/incoming-handler@0.2.3
|
||||
export * as initEndpoint from "trailbase:component/init-endpoint@0.1.0"; // export trailbase:component/init-endpoint@0.1.0
|
||||
export * as sqliteFunctionEndpoint from "trailbase:component/sqlite-function-endpoint@0.1.0"; // export trailbase:component/sqlite-function-endpoint@0.1.0
|
||||
}
|
||||
|
||||
+29
-10
@@ -1,9 +1,9 @@
|
||||
declare module 'trailbase:component/init-endpoint@0.1.0' {
|
||||
declare module "trailbase:component/init-endpoint@0.1.0" {
|
||||
export function initHttpHandlers(args: Arguments): HttpHandlers;
|
||||
export function initJobHandlers(args: Arguments): JobHandlers;
|
||||
export function initSqliteFunctions(args: Arguments): SqliteFunctions;
|
||||
export interface Arguments {
|
||||
version?: string,
|
||||
version?: string;
|
||||
}
|
||||
/**
|
||||
* # Variants
|
||||
@@ -26,18 +26,27 @@ declare module 'trailbase:component/init-endpoint@0.1.0' {
|
||||
*
|
||||
* ## `"connect"`
|
||||
*/
|
||||
export type HttpMethodType = 'get' | 'post' | 'head' | 'options' | 'patch' | 'delete' | 'put' | 'trace' | 'connect';
|
||||
export type HttpMethodType =
|
||||
| "get"
|
||||
| "post"
|
||||
| "head"
|
||||
| "options"
|
||||
| "patch"
|
||||
| "delete"
|
||||
| "put"
|
||||
| "trace"
|
||||
| "connect";
|
||||
export interface HttpHandlers {
|
||||
/**
|
||||
* Registered http handlers (method, path)[].
|
||||
*/
|
||||
handlers: Array<[HttpMethodType, string]>,
|
||||
handlers: Array<[HttpMethodType, string]>;
|
||||
}
|
||||
export interface JobHandlers {
|
||||
/**
|
||||
* Registered jobs (name, spec)[].
|
||||
*/
|
||||
handlers: Array<[string, string]>,
|
||||
handlers: Array<[string, string]>;
|
||||
}
|
||||
/**
|
||||
* # Variants
|
||||
@@ -73,13 +82,23 @@ declare module 'trailbase:component/init-endpoint@0.1.0' {
|
||||
*
|
||||
* Indicates that the function is an aggregate that internally orders the values provided to the first argument.
|
||||
*/
|
||||
export type SqliteFunctionFlags = 'utf8' | 'utf16le' | 'utf16be' | 'utf16' | 'deterministic' | 'direct-only' | 'subtype' | 'innocuous' | 'result-subtype' | 'selforder1';
|
||||
export type SqliteFunctionFlags =
|
||||
| "utf8"
|
||||
| "utf16le"
|
||||
| "utf16be"
|
||||
| "utf16"
|
||||
| "deterministic"
|
||||
| "direct-only"
|
||||
| "subtype"
|
||||
| "innocuous"
|
||||
| "result-subtype"
|
||||
| "selforder1";
|
||||
export interface SqliteScalarFunction {
|
||||
name: string,
|
||||
numArgs: number,
|
||||
functionFlags: Array<SqliteFunctionFlags>,
|
||||
name: string;
|
||||
numArgs: number;
|
||||
functionFlags: Array<SqliteFunctionFlags>;
|
||||
}
|
||||
export interface SqliteFunctions {
|
||||
scalarFunctions: Array<SqliteScalarFunction>,
|
||||
scalarFunctions: Array<SqliteScalarFunction>;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+20
-15
@@ -1,4 +1,4 @@
|
||||
declare module 'trailbase:component/sqlite-function-endpoint@0.1.0' {
|
||||
declare module "trailbase:component/sqlite-function-endpoint@0.1.0" {
|
||||
export function dispatchScalarFunction(args: Arguments): Value;
|
||||
/**
|
||||
* WARNING: Evolving a variant currently breaks the ABI:
|
||||
@@ -6,31 +6,36 @@ declare module 'trailbase:component/sqlite-function-endpoint@0.1.0' {
|
||||
*/
|
||||
export type Error = ErrorOther;
|
||||
export interface ErrorOther {
|
||||
tag: 'other',
|
||||
val: string,
|
||||
tag: "other";
|
||||
val: string;
|
||||
}
|
||||
export type Value = ValueNull | ValueText | ValueBlob | ValueInteger | ValueReal;
|
||||
export type Value =
|
||||
| ValueNull
|
||||
| ValueText
|
||||
| ValueBlob
|
||||
| ValueInteger
|
||||
| ValueReal;
|
||||
export interface ValueNull {
|
||||
tag: 'null',
|
||||
tag: "null";
|
||||
}
|
||||
export interface ValueText {
|
||||
tag: 'text',
|
||||
val: string,
|
||||
tag: "text";
|
||||
val: string;
|
||||
}
|
||||
export interface ValueBlob {
|
||||
tag: 'blob',
|
||||
val: Uint8Array,
|
||||
tag: "blob";
|
||||
val: Uint8Array;
|
||||
}
|
||||
export interface ValueInteger {
|
||||
tag: 'integer',
|
||||
val: bigint,
|
||||
tag: "integer";
|
||||
val: bigint;
|
||||
}
|
||||
export interface ValueReal {
|
||||
tag: 'real',
|
||||
val: number,
|
||||
tag: "real";
|
||||
val: number;
|
||||
}
|
||||
export interface Arguments {
|
||||
functionName: string,
|
||||
arguments: Array<Value>,
|
||||
functionName: string;
|
||||
arguments: Array<Value>;
|
||||
}
|
||||
}
|
||||
|
||||
+31
-14
@@ -1,36 +1,53 @@
|
||||
declare module 'trailbase:database/sqlite@0.1.0' {
|
||||
declare module "trailbase:database/sqlite@0.1.0" {
|
||||
/**
|
||||
* NOTE: Ideally, we'd use these but they can currently block guests, w/o a
|
||||
* better non-blocking event loop.
|
||||
* @since(version = 0.1.0)
|
||||
* execute: func(query: string, params: list<value>) -> result<u64, tx-error>;
|
||||
* @since(version = 0.1.0)
|
||||
* query: func(query: string, params: list<value>) -> result<list<list<value>>, tx-error>;
|
||||
* However, transactions have to be sync.
|
||||
*/
|
||||
export function txBegin(): void;
|
||||
export function txCommit(): void;
|
||||
export function txRollback(): void;
|
||||
export function txExecute(query: string, params: Array<Value>): bigint;
|
||||
export function txQuery(query: string, params: Array<Value>): Array<Array<Value>>;
|
||||
export function txQuery(
|
||||
query: string,
|
||||
params: Array<Value>,
|
||||
): Array<Array<Value>>;
|
||||
/**
|
||||
* WARNING: Evolving a variant currently breaks the ABI:
|
||||
* https://github.com/WebAssembly/component-model/issues/454
|
||||
*/
|
||||
export type TxError = TxErrorOther;
|
||||
export interface TxErrorOther {
|
||||
tag: 'other',
|
||||
val: string,
|
||||
tag: "other";
|
||||
val: string;
|
||||
}
|
||||
export type Value = ValueNull | ValueText | ValueBlob | ValueInteger | ValueReal;
|
||||
export type Value =
|
||||
| ValueNull
|
||||
| ValueText
|
||||
| ValueBlob
|
||||
| ValueInteger
|
||||
| ValueReal;
|
||||
export interface ValueNull {
|
||||
tag: 'null',
|
||||
tag: "null";
|
||||
}
|
||||
export interface ValueText {
|
||||
tag: 'text',
|
||||
val: string,
|
||||
tag: "text";
|
||||
val: string;
|
||||
}
|
||||
export interface ValueBlob {
|
||||
tag: 'blob',
|
||||
val: Uint8Array,
|
||||
tag: "blob";
|
||||
val: Uint8Array;
|
||||
}
|
||||
export interface ValueInteger {
|
||||
tag: 'integer',
|
||||
val: bigint,
|
||||
tag: "integer";
|
||||
val: bigint;
|
||||
}
|
||||
export interface ValueReal {
|
||||
tag: 'real',
|
||||
val: number,
|
||||
tag: "real";
|
||||
val: number;
|
||||
}
|
||||
}
|
||||
|
||||
+36
-34
@@ -1,34 +1,36 @@
|
||||
/** @module Interface wasi:clocks/monotonic-clock@0.2.3 **/
|
||||
/**
|
||||
* Read the current value of the clock.
|
||||
*
|
||||
* The clock is monotonic, therefore calling this function repeatedly will
|
||||
* produce a sequence of non-decreasing values.
|
||||
*/
|
||||
export function now(): Instant;
|
||||
/**
|
||||
* Query the resolution of the clock. Returns the duration of time
|
||||
* corresponding to a clock tick.
|
||||
*/
|
||||
export function resolution(): Duration;
|
||||
/**
|
||||
* Create a `pollable` which will resolve once the specified instant
|
||||
* has occurred.
|
||||
*/
|
||||
export function subscribeInstant(when: Instant): Pollable;
|
||||
/**
|
||||
* Create a `pollable` that will resolve after the specified duration has
|
||||
* elapsed from the time this function is invoked.
|
||||
*/
|
||||
export function subscribeDuration(when: Duration): Pollable;
|
||||
export type Pollable = import('./wasi-io-poll.js').Pollable;
|
||||
/**
|
||||
* An instant in time, in nanoseconds. An instant is relative to an
|
||||
* unspecified initial value, and can only be compared to instances from
|
||||
* the same monotonic-clock.
|
||||
*/
|
||||
export type Instant = bigint;
|
||||
/**
|
||||
* A duration of time, in nanoseconds.
|
||||
*/
|
||||
export type Duration = bigint;
|
||||
/// <reference path="./wasi-io-poll.d.ts" />
|
||||
declare module "wasi:clocks/monotonic-clock@0.2.3" {
|
||||
/**
|
||||
* Read the current value of the clock.
|
||||
*
|
||||
* The clock is monotonic, therefore calling this function repeatedly will
|
||||
* produce a sequence of non-decreasing values.
|
||||
*/
|
||||
export function now(): Instant;
|
||||
/**
|
||||
* Query the resolution of the clock. Returns the duration of time
|
||||
* corresponding to a clock tick.
|
||||
*/
|
||||
export function resolution(): Duration;
|
||||
/**
|
||||
* Create a `pollable` which will resolve once the specified instant
|
||||
* has occurred.
|
||||
*/
|
||||
export function subscribeInstant(when: Instant): Pollable;
|
||||
/**
|
||||
* Create a `pollable` that will resolve after the specified duration has
|
||||
* elapsed from the time this function is invoked.
|
||||
*/
|
||||
export function subscribeDuration(when: Duration): Pollable;
|
||||
export type Pollable = import("wasi:io/poll@0.2.3").Pollable;
|
||||
/**
|
||||
* An instant in time, in nanoseconds. An instant is relative to an
|
||||
* unspecified initial value, and can only be compared to instances from
|
||||
* the same monotonic-clock.
|
||||
*/
|
||||
export type Instant = bigint;
|
||||
/**
|
||||
* A duration of time, in nanoseconds.
|
||||
*/
|
||||
export type Duration = bigint;
|
||||
}
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
/** @module Interface wasi:clocks/wall-clock@0.2.3 **/
|
||||
/**
|
||||
* Read the current value of the clock.
|
||||
*
|
||||
* This clock is not monotonic, therefore calling this function repeatedly
|
||||
* will not necessarily produce a sequence of non-decreasing values.
|
||||
*
|
||||
* The returned timestamps represent the number of seconds since
|
||||
* 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch],
|
||||
* also known as [Unix Time].
|
||||
*
|
||||
* The nanoseconds field of the output is always less than 1000000000.
|
||||
*
|
||||
* [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16
|
||||
* [Unix Time]: https://en.wikipedia.org/wiki/Unix_time
|
||||
*/
|
||||
export function now(): Datetime;
|
||||
/**
|
||||
* Query the resolution of the clock.
|
||||
*
|
||||
* The nanoseconds field of the output is always less than 1000000000.
|
||||
*/
|
||||
export function resolution(): Datetime;
|
||||
/**
|
||||
* A time and date in seconds plus nanoseconds.
|
||||
*/
|
||||
export interface Datetime {
|
||||
seconds: bigint,
|
||||
nanoseconds: number,
|
||||
declare module "wasi:clocks/wall-clock@0.2.3" {
|
||||
/**
|
||||
* Read the current value of the clock.
|
||||
*
|
||||
* This clock is not monotonic, therefore calling this function repeatedly
|
||||
* will not necessarily produce a sequence of non-decreasing values.
|
||||
*
|
||||
* The returned timestamps represent the number of seconds since
|
||||
* 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch],
|
||||
* also known as [Unix Time].
|
||||
*
|
||||
* The nanoseconds field of the output is always less than 1000000000.
|
||||
*
|
||||
* [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16
|
||||
* [Unix Time]: https://en.wikipedia.org/wiki/Unix_time
|
||||
*/
|
||||
export function now(): Datetime;
|
||||
/**
|
||||
* Query the resolution of the clock.
|
||||
*
|
||||
* The nanoseconds field of the output is always less than 1000000000.
|
||||
*/
|
||||
export function resolution(): Datetime;
|
||||
/**
|
||||
* A time and date in seconds plus nanoseconds.
|
||||
*/
|
||||
export interface Datetime {
|
||||
seconds: bigint;
|
||||
nanoseconds: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/** @module Interface wasi:filesystem/preopens@0.2.3 **/
|
||||
/**
|
||||
* Return the set of preopened directories, and their paths.
|
||||
*/
|
||||
export function getDirectories(): Array<[Descriptor, string]>;
|
||||
export type Descriptor = import('./wasi-filesystem-types.js').Descriptor;
|
||||
/// <reference path="./wasi-filesystem-types.d.ts" />
|
||||
declare module "wasi:filesystem/preopens@0.2.3" {
|
||||
/**
|
||||
* Return the set of preopened directories, and their paths.
|
||||
*/
|
||||
export function getDirectories(): Array<[Descriptor, string]>;
|
||||
export type Descriptor = import("wasi:filesystem/types@0.2.3").Descriptor;
|
||||
}
|
||||
|
||||
+723
-648
File diff suppressed because it is too large
Load Diff
+22
-16
@@ -1,16 +1,22 @@
|
||||
/** @module Interface wasi:http/incoming-handler@0.2.3 **/
|
||||
/**
|
||||
* This function is invoked with an incoming HTTP Request, and a resource
|
||||
* `response-outparam` which provides the capability to reply with an HTTP
|
||||
* Response. The response is sent by calling the `response-outparam.set`
|
||||
* method, which allows execution to continue after the response has been
|
||||
* sent. This enables both streaming to the response body, and performing other
|
||||
* work.
|
||||
*
|
||||
* The implementor of this function must write a response to the
|
||||
* `response-outparam` before returning, or else the caller will respond
|
||||
* with an error on its behalf.
|
||||
*/
|
||||
export function handle(request: IncomingRequest, responseOut: ResponseOutparam): void;
|
||||
export type IncomingRequest = import('./wasi-http-types.js').IncomingRequest;
|
||||
export type ResponseOutparam = import('./wasi-http-types.js').ResponseOutparam;
|
||||
/// <reference path="./wasi-http-types.d.ts" />
|
||||
declare module "wasi:http/incoming-handler@0.2.3" {
|
||||
/**
|
||||
* This function is invoked with an incoming HTTP Request, and a resource
|
||||
* `response-outparam` which provides the capability to reply with an HTTP
|
||||
* Response. The response is sent by calling the `response-outparam.set`
|
||||
* method, which allows execution to continue after the response has been
|
||||
* sent. This enables both streaming to the response body, and performing other
|
||||
* work.
|
||||
*
|
||||
* The implementor of this function must write a response to the
|
||||
* `response-outparam` before returning, or else the caller will respond
|
||||
* with an error on its behalf.
|
||||
*/
|
||||
export function handle(
|
||||
request: IncomingRequest,
|
||||
responseOut: ResponseOutparam,
|
||||
): void;
|
||||
export type IncomingRequest = import("wasi:http/types@0.2.3").IncomingRequest;
|
||||
export type ResponseOutparam =
|
||||
import("wasi:http/types@0.2.3").ResponseOutparam;
|
||||
}
|
||||
|
||||
+24
-18
@@ -1,18 +1,24 @@
|
||||
/** @module Interface wasi:http/outgoing-handler@0.2.3 **/
|
||||
/**
|
||||
* This function is invoked with an outgoing HTTP Request, and it returns
|
||||
* a resource `future-incoming-response` which represents an HTTP Response
|
||||
* which may arrive in the future.
|
||||
*
|
||||
* The `options` argument accepts optional parameters for the HTTP
|
||||
* protocol's transport layer.
|
||||
*
|
||||
* This function may return an error if the `outgoing-request` is invalid
|
||||
* or not allowed to be made. Otherwise, protocol errors are reported
|
||||
* through the `future-incoming-response`.
|
||||
*/
|
||||
export function handle(request: OutgoingRequest, options: RequestOptions | undefined): FutureIncomingResponse;
|
||||
export type OutgoingRequest = import('./wasi-http-types.js').OutgoingRequest;
|
||||
export type RequestOptions = import('./wasi-http-types.js').RequestOptions;
|
||||
export type FutureIncomingResponse = import('./wasi-http-types.js').FutureIncomingResponse;
|
||||
export type ErrorCode = import('./wasi-http-types.js').ErrorCode;
|
||||
/// <reference path="./wasi-http-types.d.ts" />
|
||||
declare module "wasi:http/outgoing-handler@0.2.3" {
|
||||
/**
|
||||
* This function is invoked with an outgoing HTTP Request, and it returns
|
||||
* a resource `future-incoming-response` which represents an HTTP Response
|
||||
* which may arrive in the future.
|
||||
*
|
||||
* The `options` argument accepts optional parameters for the HTTP
|
||||
* protocol's transport layer.
|
||||
*
|
||||
* This function may return an error if the `outgoing-request` is invalid
|
||||
* or not allowed to be made. Otherwise, protocol errors are reported
|
||||
* through the `future-incoming-response`.
|
||||
*/
|
||||
export function handle(
|
||||
request: OutgoingRequest,
|
||||
options: RequestOptions | undefined,
|
||||
): FutureIncomingResponse;
|
||||
export type OutgoingRequest = import("wasi:http/types@0.2.3").OutgoingRequest;
|
||||
export type RequestOptions = import("wasi:http/types@0.2.3").RequestOptions;
|
||||
export type FutureIncomingResponse =
|
||||
import("wasi:http/types@0.2.3").FutureIncomingResponse;
|
||||
export type ErrorCode = import("wasi:http/types@0.2.3").ErrorCode;
|
||||
}
|
||||
|
||||
+803
-743
File diff suppressed because it is too large
Load Diff
+18
-18
@@ -1,19 +1,19 @@
|
||||
/** @module Interface wasi:io/error@0.2.3 **/
|
||||
|
||||
export class Error implements Partial<Disposable> {
|
||||
/**
|
||||
* This type does not have a public constructor.
|
||||
*/
|
||||
private constructor();
|
||||
/**
|
||||
* Returns a string that is suitable to assist humans in debugging
|
||||
* this error.
|
||||
*
|
||||
* WARNING: The returned string should not be consumed mechanically!
|
||||
* It may change across platforms, hosts, or other implementation
|
||||
* details. Parsing this string is a major platform-compatibility
|
||||
* hazard.
|
||||
*/
|
||||
toDebugString(): string;
|
||||
[Symbol.dispose]?: () => void;
|
||||
declare module "wasi:io/error@0.2.3" {
|
||||
export class Error implements Disposable {
|
||||
/**
|
||||
* This type does not have a public constructor.
|
||||
*/
|
||||
private constructor();
|
||||
/**
|
||||
* Returns a string that is suitable to assist humans in debugging
|
||||
* this error.
|
||||
*
|
||||
* WARNING: The returned string should not be consumed mechanically!
|
||||
* It may change across platforms, hosts, or other implementation
|
||||
* details. Parsing this string is a major platform-compatibility
|
||||
* hazard.
|
||||
*/
|
||||
toDebugString(): string;
|
||||
[Symbol.dispose](): void;
|
||||
}
|
||||
}
|
||||
|
||||
+43
-42
@@ -1,45 +1,46 @@
|
||||
/** @module Interface wasi:io/poll@0.2.3 **/
|
||||
/**
|
||||
* Poll for completion on a set of pollables.
|
||||
*
|
||||
* This function takes a list of pollables, which identify I/O sources of
|
||||
* interest, and waits until one or more of the events is ready for I/O.
|
||||
*
|
||||
* The result `list<u32>` contains one or more indices of handles in the
|
||||
* argument list that is ready for I/O.
|
||||
*
|
||||
* This function traps if either:
|
||||
* - the list is empty, or:
|
||||
* - the list contains more elements than can be indexed with a `u32` value.
|
||||
*
|
||||
* A timeout can be implemented by adding a pollable from the
|
||||
* wasi-clocks API to the list.
|
||||
*
|
||||
* This function does not return a `result`; polling in itself does not
|
||||
* do any I/O so it doesn't fail. If any of the I/O sources identified by
|
||||
* the pollables has an error, it is indicated by marking the source as
|
||||
* being ready for I/O.
|
||||
*/
|
||||
export function poll(in_: Array<Pollable>): Uint32Array;
|
||||
|
||||
export class Pollable implements Partial<Disposable> {
|
||||
declare module "wasi:io/poll@0.2.3" {
|
||||
/**
|
||||
* This type does not have a public constructor.
|
||||
* Poll for completion on a set of pollables.
|
||||
*
|
||||
* This function takes a list of pollables, which identify I/O sources of
|
||||
* interest, and waits until one or more of the events is ready for I/O.
|
||||
*
|
||||
* The result `list<u32>` contains one or more indices of handles in the
|
||||
* argument list that is ready for I/O.
|
||||
*
|
||||
* This function traps if either:
|
||||
* - the list is empty, or:
|
||||
* - the list contains more elements than can be indexed with a `u32` value.
|
||||
*
|
||||
* A timeout can be implemented by adding a pollable from the
|
||||
* wasi-clocks API to the list.
|
||||
*
|
||||
* This function does not return a `result`; polling in itself does not
|
||||
* do any I/O so it doesn't fail. If any of the I/O sources identified by
|
||||
* the pollables has an error, it is indicated by marking the source as
|
||||
* being ready for I/O.
|
||||
*/
|
||||
private constructor();
|
||||
/**
|
||||
* Return the readiness of a pollable. This function never blocks.
|
||||
*
|
||||
* Returns `true` when the pollable is ready, and `false` otherwise.
|
||||
*/
|
||||
ready(): boolean;
|
||||
/**
|
||||
* `block` returns immediately if the pollable is ready, and otherwise
|
||||
* blocks until ready.
|
||||
*
|
||||
* This function is equivalent to calling `poll.poll` on a list
|
||||
* containing only this pollable.
|
||||
*/
|
||||
block(): void;
|
||||
[Symbol.dispose]?: () => void;
|
||||
export function poll(in_: Array<Pollable>): Uint32Array;
|
||||
|
||||
export class Pollable implements Disposable {
|
||||
/**
|
||||
* This type does not have a public constructor.
|
||||
*/
|
||||
private constructor();
|
||||
/**
|
||||
* Return the readiness of a pollable. This function never blocks.
|
||||
*
|
||||
* Returns `true` when the pollable is ready, and `false` otherwise.
|
||||
*/
|
||||
ready(): boolean;
|
||||
/**
|
||||
* `block` returns immediately if the pollable is ready, and otherwise
|
||||
* blocks until ready.
|
||||
*
|
||||
* This function is equivalent to calling `poll.poll` on a list
|
||||
* containing only this pollable.
|
||||
*/
|
||||
block(): void;
|
||||
[Symbol.dispose](): void;
|
||||
}
|
||||
}
|
||||
|
||||
+232
-229
@@ -1,244 +1,247 @@
|
||||
/** @module Interface wasi:io/streams@0.2.3 **/
|
||||
export type Error = import('./wasi-io-error.js').Error;
|
||||
export type Pollable = import('./wasi-io-poll.js').Pollable;
|
||||
/**
|
||||
* An error for input-stream and output-stream operations.
|
||||
*/
|
||||
export type StreamError = StreamErrorLastOperationFailed | StreamErrorClosed;
|
||||
/**
|
||||
* The last operation (a write or flush) failed before completion.
|
||||
*
|
||||
* More information is available in the `error` payload.
|
||||
*
|
||||
* After this, the stream will be closed. All future operations return
|
||||
* `stream-error::closed`.
|
||||
*/
|
||||
export interface StreamErrorLastOperationFailed {
|
||||
tag: 'last-operation-failed',
|
||||
val: Error,
|
||||
}
|
||||
/**
|
||||
* The stream is closed: no more input will be accepted by the
|
||||
* stream. A closed output-stream will return this error on all
|
||||
* future operations.
|
||||
*/
|
||||
export interface StreamErrorClosed {
|
||||
tag: 'closed',
|
||||
}
|
||||
|
||||
export class InputStream implements Partial<Disposable> {
|
||||
/// <reference path="./wasi-io-error.d.ts" />
|
||||
/// <reference path="./wasi-io-poll.d.ts" />
|
||||
declare module "wasi:io/streams@0.2.3" {
|
||||
export type Error = import("wasi:io/error@0.2.3").Error;
|
||||
export type Pollable = import("wasi:io/poll@0.2.3").Pollable;
|
||||
/**
|
||||
* This type does not have a public constructor.
|
||||
* An error for input-stream and output-stream operations.
|
||||
*/
|
||||
private constructor();
|
||||
export type StreamError = StreamErrorLastOperationFailed | StreamErrorClosed;
|
||||
/**
|
||||
* Perform a non-blocking read from the stream.
|
||||
*
|
||||
* When the source of a `read` is binary data, the bytes from the source
|
||||
* are returned verbatim. When the source of a `read` is known to the
|
||||
* implementation to be text, bytes containing the UTF-8 encoding of the
|
||||
* text are returned.
|
||||
*
|
||||
* This function returns a list of bytes containing the read data,
|
||||
* when successful. The returned list will contain up to `len` bytes;
|
||||
* it may return fewer than requested, but not more. The list is
|
||||
* empty when no bytes are available for reading at this time. The
|
||||
* pollable given by `subscribe` will be ready when more bytes are
|
||||
* available.
|
||||
*
|
||||
* This function fails with a `stream-error` when the operation
|
||||
* encounters an error, giving `last-operation-failed`, or when the
|
||||
* stream is closed, giving `closed`.
|
||||
*
|
||||
* When the caller gives a `len` of 0, it represents a request to
|
||||
* read 0 bytes. If the stream is still open, this call should
|
||||
* succeed and return an empty list, or otherwise fail with `closed`.
|
||||
*
|
||||
* The `len` parameter is a `u64`, which could represent a list of u8 which
|
||||
* is not possible to allocate in wasm32, or not desirable to allocate as
|
||||
* as a return value by the callee. The callee may return a list of bytes
|
||||
* less than `len` in size while more bytes are available for reading.
|
||||
*/
|
||||
read(len: bigint): Uint8Array;
|
||||
/**
|
||||
* Read bytes from a stream, after blocking until at least one byte can
|
||||
* be read. Except for blocking, behavior is identical to `read`.
|
||||
*/
|
||||
blockingRead(len: bigint): Uint8Array;
|
||||
/**
|
||||
* Skip bytes from a stream. Returns number of bytes skipped.
|
||||
*
|
||||
* Behaves identical to `read`, except instead of returning a list
|
||||
* of bytes, returns the number of bytes consumed from the stream.
|
||||
*/
|
||||
skip(len: bigint): bigint;
|
||||
/**
|
||||
* Skip bytes from a stream, after blocking until at least one byte
|
||||
* can be skipped. Except for blocking behavior, identical to `skip`.
|
||||
*/
|
||||
blockingSkip(len: bigint): bigint;
|
||||
/**
|
||||
* Create a `pollable` which will resolve once either the specified stream
|
||||
* has bytes available to read or the other end of the stream has been
|
||||
* closed.
|
||||
* The created `pollable` is a child resource of the `input-stream`.
|
||||
* Implementations may trap if the `input-stream` is dropped before
|
||||
* all derived `pollable`s created with this function are dropped.
|
||||
*/
|
||||
subscribe(): Pollable;
|
||||
[Symbol.dispose]?: () => void;
|
||||
}
|
||||
|
||||
export class OutputStream implements Partial<Disposable> {
|
||||
/**
|
||||
* This type does not have a public constructor.
|
||||
* The last operation (a write or flush) failed before completion.
|
||||
*
|
||||
* More information is available in the `error` payload.
|
||||
*
|
||||
* After this, the stream will be closed. All future operations return
|
||||
* `stream-error::closed`.
|
||||
*/
|
||||
private constructor();
|
||||
export interface StreamErrorLastOperationFailed {
|
||||
tag: "last-operation-failed";
|
||||
val: Error;
|
||||
}
|
||||
/**
|
||||
* Check readiness for writing. This function never blocks.
|
||||
*
|
||||
* Returns the number of bytes permitted for the next call to `write`,
|
||||
* or an error. Calling `write` with more bytes than this function has
|
||||
* permitted will trap.
|
||||
*
|
||||
* When this function returns 0 bytes, the `subscribe` pollable will
|
||||
* become ready when this function will report at least 1 byte, or an
|
||||
* error.
|
||||
*/
|
||||
checkWrite(): bigint;
|
||||
/**
|
||||
* Perform a write. This function never blocks.
|
||||
*
|
||||
* When the destination of a `write` is binary data, the bytes from
|
||||
* `contents` are written verbatim. When the destination of a `write` is
|
||||
* known to the implementation to be text, the bytes of `contents` are
|
||||
* transcoded from UTF-8 into the encoding of the destination and then
|
||||
* written.
|
||||
*
|
||||
* Precondition: check-write gave permit of Ok(n) and contents has a
|
||||
* length of less than or equal to n. Otherwise, this function will trap.
|
||||
*
|
||||
* returns Err(closed) without writing if the stream has closed since
|
||||
* the last call to check-write provided a permit.
|
||||
*/
|
||||
write(contents: Uint8Array): void;
|
||||
/**
|
||||
* Perform a write of up to 4096 bytes, and then flush the stream. Block
|
||||
* until all of these operations are complete, or an error occurs.
|
||||
*
|
||||
* This is a convenience wrapper around the use of `check-write`,
|
||||
* `subscribe`, `write`, and `flush`, and is implemented with the
|
||||
* following pseudo-code:
|
||||
*
|
||||
* ```text
|
||||
* let pollable = this.subscribe();
|
||||
* while !contents.is_empty() {
|
||||
* // Wait for the stream to become writable
|
||||
* pollable.block();
|
||||
* let Ok(n) = this.check-write(); // eliding error handling
|
||||
* let len = min(n, contents.len());
|
||||
* let (chunk, rest) = contents.split_at(len);
|
||||
* this.write(chunk ); // eliding error handling
|
||||
* contents = rest;
|
||||
* }
|
||||
* this.flush();
|
||||
* // Wait for completion of `flush`
|
||||
* pollable.block();
|
||||
* // Check for any errors that arose during `flush`
|
||||
* let _ = this.check-write(); // eliding error handling
|
||||
* ```
|
||||
*/
|
||||
* The stream is closed: no more input will be accepted by the
|
||||
* stream. A closed output-stream will return this error on all
|
||||
* future operations.
|
||||
*/
|
||||
export interface StreamErrorClosed {
|
||||
tag: "closed";
|
||||
}
|
||||
|
||||
export class InputStream implements Disposable {
|
||||
/**
|
||||
* This type does not have a public constructor.
|
||||
*/
|
||||
private constructor();
|
||||
/**
|
||||
* Perform a non-blocking read from the stream.
|
||||
*
|
||||
* When the source of a `read` is binary data, the bytes from the source
|
||||
* are returned verbatim. When the source of a `read` is known to the
|
||||
* implementation to be text, bytes containing the UTF-8 encoding of the
|
||||
* text are returned.
|
||||
*
|
||||
* This function returns a list of bytes containing the read data,
|
||||
* when successful. The returned list will contain up to `len` bytes;
|
||||
* it may return fewer than requested, but not more. The list is
|
||||
* empty when no bytes are available for reading at this time. The
|
||||
* pollable given by `subscribe` will be ready when more bytes are
|
||||
* available.
|
||||
*
|
||||
* This function fails with a `stream-error` when the operation
|
||||
* encounters an error, giving `last-operation-failed`, or when the
|
||||
* stream is closed, giving `closed`.
|
||||
*
|
||||
* When the caller gives a `len` of 0, it represents a request to
|
||||
* read 0 bytes. If the stream is still open, this call should
|
||||
* succeed and return an empty list, or otherwise fail with `closed`.
|
||||
*
|
||||
* The `len` parameter is a `u64`, which could represent a list of u8 which
|
||||
* is not possible to allocate in wasm32, or not desirable to allocate as
|
||||
* as a return value by the callee. The callee may return a list of bytes
|
||||
* less than `len` in size while more bytes are available for reading.
|
||||
*/
|
||||
read(len: bigint): Uint8Array;
|
||||
/**
|
||||
* Read bytes from a stream, after blocking until at least one byte can
|
||||
* be read. Except for blocking, behavior is identical to `read`.
|
||||
*/
|
||||
blockingRead(len: bigint): Uint8Array;
|
||||
/**
|
||||
* Skip bytes from a stream. Returns number of bytes skipped.
|
||||
*
|
||||
* Behaves identical to `read`, except instead of returning a list
|
||||
* of bytes, returns the number of bytes consumed from the stream.
|
||||
*/
|
||||
skip(len: bigint): bigint;
|
||||
/**
|
||||
* Skip bytes from a stream, after blocking until at least one byte
|
||||
* can be skipped. Except for blocking behavior, identical to `skip`.
|
||||
*/
|
||||
blockingSkip(len: bigint): bigint;
|
||||
/**
|
||||
* Create a `pollable` which will resolve once either the specified stream
|
||||
* has bytes available to read or the other end of the stream has been
|
||||
* closed.
|
||||
* The created `pollable` is a child resource of the `input-stream`.
|
||||
* Implementations may trap if the `input-stream` is dropped before
|
||||
* all derived `pollable`s created with this function are dropped.
|
||||
*/
|
||||
subscribe(): Pollable;
|
||||
[Symbol.dispose](): void;
|
||||
}
|
||||
|
||||
export class OutputStream implements Disposable {
|
||||
/**
|
||||
* This type does not have a public constructor.
|
||||
*/
|
||||
private constructor();
|
||||
/**
|
||||
* Check readiness for writing. This function never blocks.
|
||||
*
|
||||
* Returns the number of bytes permitted for the next call to `write`,
|
||||
* or an error. Calling `write` with more bytes than this function has
|
||||
* permitted will trap.
|
||||
*
|
||||
* When this function returns 0 bytes, the `subscribe` pollable will
|
||||
* become ready when this function will report at least 1 byte, or an
|
||||
* error.
|
||||
*/
|
||||
checkWrite(): bigint;
|
||||
/**
|
||||
* Perform a write. This function never blocks.
|
||||
*
|
||||
* When the destination of a `write` is binary data, the bytes from
|
||||
* `contents` are written verbatim. When the destination of a `write` is
|
||||
* known to the implementation to be text, the bytes of `contents` are
|
||||
* transcoded from UTF-8 into the encoding of the destination and then
|
||||
* written.
|
||||
*
|
||||
* Precondition: check-write gave permit of Ok(n) and contents has a
|
||||
* length of less than or equal to n. Otherwise, this function will trap.
|
||||
*
|
||||
* returns Err(closed) without writing if the stream has closed since
|
||||
* the last call to check-write provided a permit.
|
||||
*/
|
||||
write(contents: Uint8Array): void;
|
||||
/**
|
||||
* Perform a write of up to 4096 bytes, and then flush the stream. Block
|
||||
* until all of these operations are complete, or an error occurs.
|
||||
*
|
||||
* This is a convenience wrapper around the use of `check-write`,
|
||||
* `subscribe`, `write`, and `flush`, and is implemented with the
|
||||
* following pseudo-code:
|
||||
*
|
||||
* ```text
|
||||
* let pollable = this.subscribe();
|
||||
* while !contents.is_empty() {
|
||||
* // Wait for the stream to become writable
|
||||
* pollable.block();
|
||||
* let Ok(n) = this.check-write(); // eliding error handling
|
||||
* let len = min(n, contents.len());
|
||||
* let (chunk, rest) = contents.split_at(len);
|
||||
* this.write(chunk ); // eliding error handling
|
||||
* contents = rest;
|
||||
* }
|
||||
* this.flush();
|
||||
* // Wait for completion of `flush`
|
||||
* pollable.block();
|
||||
* // Check for any errors that arose during `flush`
|
||||
* let _ = this.check-write(); // eliding error handling
|
||||
* ```
|
||||
*/
|
||||
blockingWriteAndFlush(contents: Uint8Array): void;
|
||||
/**
|
||||
* Request to flush buffered output. This function never blocks.
|
||||
*
|
||||
* This tells the output-stream that the caller intends any buffered
|
||||
* output to be flushed. the output which is expected to be flushed
|
||||
* is all that has been passed to `write` prior to this call.
|
||||
*
|
||||
* Upon calling this function, the `output-stream` will not accept any
|
||||
* writes (`check-write` will return `ok(0)`) until the flush has
|
||||
* completed. The `subscribe` pollable will become ready when the
|
||||
* flush has completed and the stream can accept more writes.
|
||||
*/
|
||||
* Request to flush buffered output. This function never blocks.
|
||||
*
|
||||
* This tells the output-stream that the caller intends any buffered
|
||||
* output to be flushed. the output which is expected to be flushed
|
||||
* is all that has been passed to `write` prior to this call.
|
||||
*
|
||||
* Upon calling this function, the `output-stream` will not accept any
|
||||
* writes (`check-write` will return `ok(0)`) until the flush has
|
||||
* completed. The `subscribe` pollable will become ready when the
|
||||
* flush has completed and the stream can accept more writes.
|
||||
*/
|
||||
flush(): void;
|
||||
/**
|
||||
* Request to flush buffered output, and block until flush completes
|
||||
* and stream is ready for writing again.
|
||||
*/
|
||||
* Request to flush buffered output, and block until flush completes
|
||||
* and stream is ready for writing again.
|
||||
*/
|
||||
blockingFlush(): void;
|
||||
/**
|
||||
* Create a `pollable` which will resolve once the output-stream
|
||||
* is ready for more writing, or an error has occurred. When this
|
||||
* pollable is ready, `check-write` will return `ok(n)` with n>0, or an
|
||||
* error.
|
||||
*
|
||||
* If the stream is closed, this pollable is always ready immediately.
|
||||
*
|
||||
* The created `pollable` is a child resource of the `output-stream`.
|
||||
* Implementations may trap if the `output-stream` is dropped before
|
||||
* all derived `pollable`s created with this function are dropped.
|
||||
*/
|
||||
* Create a `pollable` which will resolve once the output-stream
|
||||
* is ready for more writing, or an error has occurred. When this
|
||||
* pollable is ready, `check-write` will return `ok(n)` with n>0, or an
|
||||
* error.
|
||||
*
|
||||
* If the stream is closed, this pollable is always ready immediately.
|
||||
*
|
||||
* The created `pollable` is a child resource of the `output-stream`.
|
||||
* Implementations may trap if the `output-stream` is dropped before
|
||||
* all derived `pollable`s created with this function are dropped.
|
||||
*/
|
||||
subscribe(): Pollable;
|
||||
/**
|
||||
* Write zeroes to a stream.
|
||||
*
|
||||
* This should be used precisely like `write` with the exact same
|
||||
* preconditions (must use check-write first), but instead of
|
||||
* passing a list of bytes, you simply pass the number of zero-bytes
|
||||
* that should be written.
|
||||
*/
|
||||
* Write zeroes to a stream.
|
||||
*
|
||||
* This should be used precisely like `write` with the exact same
|
||||
* preconditions (must use check-write first), but instead of
|
||||
* passing a list of bytes, you simply pass the number of zero-bytes
|
||||
* that should be written.
|
||||
*/
|
||||
writeZeroes(len: bigint): void;
|
||||
/**
|
||||
* Perform a write of up to 4096 zeroes, and then flush the stream.
|
||||
* Block until all of these operations are complete, or an error
|
||||
* occurs.
|
||||
*
|
||||
* This is a convenience wrapper around the use of `check-write`,
|
||||
* `subscribe`, `write-zeroes`, and `flush`, and is implemented with
|
||||
* the following pseudo-code:
|
||||
*
|
||||
* ```text
|
||||
* let pollable = this.subscribe();
|
||||
* while num_zeroes != 0 {
|
||||
* // Wait for the stream to become writable
|
||||
* pollable.block();
|
||||
* let Ok(n) = this.check-write(); // eliding error handling
|
||||
* let len = min(n, num_zeroes);
|
||||
* this.write-zeroes(len); // eliding error handling
|
||||
* num_zeroes -= len;
|
||||
* }
|
||||
* this.flush();
|
||||
* // Wait for completion of `flush`
|
||||
* pollable.block();
|
||||
* // Check for any errors that arose during `flush`
|
||||
* let _ = this.check-write(); // eliding error handling
|
||||
* ```
|
||||
*/
|
||||
blockingWriteZeroesAndFlush(len: bigint): void;
|
||||
/**
|
||||
* Read from one stream and write to another.
|
||||
*
|
||||
* The behavior of splice is equivalent to:
|
||||
* 1. calling `check-write` on the `output-stream`
|
||||
* 2. calling `read` on the `input-stream` with the smaller of the
|
||||
* `check-write` permitted length and the `len` provided to `splice`
|
||||
* 3. calling `write` on the `output-stream` with that read data.
|
||||
*
|
||||
* Any error reported by the call to `check-write`, `read`, or
|
||||
* `write` ends the splice and reports that error.
|
||||
*
|
||||
* This function returns the number of bytes transferred; it may be less
|
||||
* than `len`.
|
||||
*/
|
||||
splice(src: InputStream, len: bigint): bigint;
|
||||
/**
|
||||
* Read from one stream and write to another, with blocking.
|
||||
*
|
||||
* This is similar to `splice`, except that it blocks until the
|
||||
* `output-stream` is ready for writing, and the `input-stream`
|
||||
* is ready for reading, before performing the `splice`.
|
||||
*/
|
||||
blockingSplice(src: InputStream, len: bigint): bigint;
|
||||
[Symbol.dispose]?: () => void;
|
||||
}
|
||||
* Perform a write of up to 4096 zeroes, and then flush the stream.
|
||||
* Block until all of these operations are complete, or an error
|
||||
* occurs.
|
||||
*
|
||||
* This is a convenience wrapper around the use of `check-write`,
|
||||
* `subscribe`, `write-zeroes`, and `flush`, and is implemented with
|
||||
* the following pseudo-code:
|
||||
*
|
||||
* ```text
|
||||
* let pollable = this.subscribe();
|
||||
* while num_zeroes != 0 {
|
||||
* // Wait for the stream to become writable
|
||||
* pollable.block();
|
||||
* let Ok(n) = this.check-write(); // eliding error handling
|
||||
* let len = min(n, num_zeroes);
|
||||
* this.write-zeroes(len); // eliding error handling
|
||||
* num_zeroes -= len;
|
||||
* }
|
||||
* this.flush();
|
||||
* // Wait for completion of `flush`
|
||||
* pollable.block();
|
||||
* // Check for any errors that arose during `flush`
|
||||
* let _ = this.check-write(); // eliding error handling
|
||||
* ```
|
||||
*/
|
||||
blockingWriteZeroesAndFlush(len: bigint): void;
|
||||
/**
|
||||
* Read from one stream and write to another.
|
||||
*
|
||||
* The behavior of splice is equivalent to:
|
||||
* 1. calling `check-write` on the `output-stream`
|
||||
* 2. calling `read` on the `input-stream` with the smaller of the
|
||||
* `check-write` permitted length and the `len` provided to `splice`
|
||||
* 3. calling `write` on the `output-stream` with that read data.
|
||||
*
|
||||
* Any error reported by the call to `check-write`, `read`, or
|
||||
* `write` ends the splice and reports that error.
|
||||
*
|
||||
* This function returns the number of bytes transferred; it may be less
|
||||
* than `len`.
|
||||
*/
|
||||
splice(src: InputStream, len: bigint): bigint;
|
||||
/**
|
||||
* Read from one stream and write to another, with blocking.
|
||||
*
|
||||
* This is similar to `splice`, except that it blocks until the
|
||||
* `output-stream` is ready for writing, and the `input-stream`
|
||||
* is ready for reading, before performing the `splice`.
|
||||
*/
|
||||
blockingSplice(src: InputStream, len: bigint): bigint;
|
||||
[Symbol.dispose](): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
/** @module Interface wasi:keyvalue/atomics@0.2.0-draft **/
|
||||
/**
|
||||
* Atomically increment the value associated with the key in the store by the given delta. It
|
||||
* returns the new value.
|
||||
*
|
||||
* If the key does not exist in the store, it creates a new key-value pair with the value set
|
||||
* to the given delta.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
export function increment(bucket: Bucket, key: string, delta: bigint): bigint;
|
||||
export type Bucket = import('./wasi-keyvalue-store.js').Bucket;
|
||||
export type Error = import('./wasi-keyvalue-store.js').Error;
|
||||
/// <reference path="./wasi-keyvalue-store.d.ts" />
|
||||
declare module "wasi:keyvalue/atomics@0.2.0-draft" {
|
||||
/**
|
||||
* Atomically increment the value associated with the key in the store by the given delta. It
|
||||
* returns the new value.
|
||||
*
|
||||
* If the key does not exist in the store, it creates a new key-value pair with the value set
|
||||
* to the given delta.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
export function increment(bucket: Bucket, key: string, delta: bigint): bigint;
|
||||
export type Bucket = import("wasi:keyvalue/store@0.2.0-draft").Bucket;
|
||||
export type Error = import("wasi:keyvalue/store@0.2.0-draft").Error;
|
||||
}
|
||||
|
||||
@@ -1,47 +1,55 @@
|
||||
/** @module Interface wasi:keyvalue/batch@0.2.0-draft **/
|
||||
/**
|
||||
* Get the key-value pairs associated with the keys in the store. It returns a list of
|
||||
* key-value pairs.
|
||||
*
|
||||
* If any of the keys do not exist in the store, it returns a `none` value for that pair in the
|
||||
* list.
|
||||
*
|
||||
* MAY show an out-of-date value if there are concurrent writes to the store.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
export function getMany(bucket: Bucket, keys: Array<string>): Array<[string, Uint8Array] | undefined>;
|
||||
/**
|
||||
* Set the values associated with the keys in the store. If the key already exists in the
|
||||
* store, it overwrites the value.
|
||||
*
|
||||
* Note that the key-value pairs are not guaranteed to be set in the order they are provided.
|
||||
*
|
||||
* If any of the keys do not exist in the store, it creates a new key-value pair.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`. When an error occurs, it does not
|
||||
* rollback the key-value pairs that were already set. Thus, this batch operation does not
|
||||
* guarantee atomicity, implying that some key-value pairs could be set while others might
|
||||
* fail.
|
||||
*
|
||||
* Other concurrent operations may also be able to see the partial results.
|
||||
*/
|
||||
export function setMany(bucket: Bucket, keyValues: Array<[string, Uint8Array]>): void;
|
||||
/**
|
||||
* Delete the key-value pairs associated with the keys in the store.
|
||||
*
|
||||
* Note that the key-value pairs are not guaranteed to be deleted in the order they are
|
||||
* provided.
|
||||
*
|
||||
* If any of the keys do not exist in the store, it skips the key.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`. When an error occurs, it does not
|
||||
* rollback the key-value pairs that were already deleted. Thus, this batch operation does not
|
||||
* guarantee atomicity, implying that some key-value pairs could be deleted while others might
|
||||
* fail.
|
||||
*
|
||||
* Other concurrent operations may also be able to see the partial results.
|
||||
*/
|
||||
export function deleteMany(bucket: Bucket, keys: Array<string>): void;
|
||||
export type Bucket = import('./wasi-keyvalue-store.js').Bucket;
|
||||
export type Error = import('./wasi-keyvalue-store.js').Error;
|
||||
/// <reference path="./wasi-keyvalue-store.d.ts" />
|
||||
declare module "wasi:keyvalue/batch@0.2.0-draft" {
|
||||
/**
|
||||
* Get the key-value pairs associated with the keys in the store. It returns a list of
|
||||
* key-value pairs.
|
||||
*
|
||||
* If any of the keys do not exist in the store, it returns a `none` value for that pair in the
|
||||
* list.
|
||||
*
|
||||
* MAY show an out-of-date value if there are concurrent writes to the store.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
export function getMany(
|
||||
bucket: Bucket,
|
||||
keys: Array<string>,
|
||||
): Array<[string, Uint8Array] | undefined>;
|
||||
/**
|
||||
* Set the values associated with the keys in the store. If the key already exists in the
|
||||
* store, it overwrites the value.
|
||||
*
|
||||
* Note that the key-value pairs are not guaranteed to be set in the order they are provided.
|
||||
*
|
||||
* If any of the keys do not exist in the store, it creates a new key-value pair.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`. When an error occurs, it does not
|
||||
* rollback the key-value pairs that were already set. Thus, this batch operation does not
|
||||
* guarantee atomicity, implying that some key-value pairs could be set while others might
|
||||
* fail.
|
||||
*
|
||||
* Other concurrent operations may also be able to see the partial results.
|
||||
*/
|
||||
export function setMany(
|
||||
bucket: Bucket,
|
||||
keyValues: Array<[string, Uint8Array]>,
|
||||
): void;
|
||||
/**
|
||||
* Delete the key-value pairs associated with the keys in the store.
|
||||
*
|
||||
* Note that the key-value pairs are not guaranteed to be deleted in the order they are
|
||||
* provided.
|
||||
*
|
||||
* If any of the keys do not exist in the store, it skips the key.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`. When an error occurs, it does not
|
||||
* rollback the key-value pairs that were already deleted. Thus, this batch operation does not
|
||||
* guarantee atomicity, implying that some key-value pairs could be deleted while others might
|
||||
* fail.
|
||||
*
|
||||
* Other concurrent operations may also be able to see the partial results.
|
||||
*/
|
||||
export function deleteMany(bucket: Bucket, keys: Array<string>): void;
|
||||
export type Bucket = import("wasi:keyvalue/store@0.2.0-draft").Bucket;
|
||||
export type Error = import("wasi:keyvalue/store@0.2.0-draft").Error;
|
||||
}
|
||||
|
||||
+105
-104
@@ -1,110 +1,111 @@
|
||||
/** @module Interface wasi:keyvalue/store@0.2.0-draft **/
|
||||
/**
|
||||
* Get the bucket with the specified identifier.
|
||||
*
|
||||
* `identifier` must refer to a bucket provided by the host.
|
||||
*
|
||||
* `error::no-such-store` will be raised if the `identifier` is not recognized.
|
||||
*/
|
||||
export function open(identifier: string): Bucket;
|
||||
/**
|
||||
* The set of errors which may be raised by functions in this package
|
||||
*/
|
||||
export type Error = ErrorNoSuchStore | ErrorAccessDenied | ErrorOther;
|
||||
/**
|
||||
* The host does not recognize the store identifier requested.
|
||||
*/
|
||||
export interface ErrorNoSuchStore {
|
||||
tag: 'no-such-store',
|
||||
}
|
||||
/**
|
||||
* The requesting component does not have access to the specified store
|
||||
* (which may or may not exist).
|
||||
*/
|
||||
export interface ErrorAccessDenied {
|
||||
tag: 'access-denied',
|
||||
}
|
||||
/**
|
||||
* Some implementation-specific error has occurred (e.g. I/O)
|
||||
*/
|
||||
export interface ErrorOther {
|
||||
tag: 'other',
|
||||
val: string,
|
||||
}
|
||||
/**
|
||||
* A response to a `list-keys` operation.
|
||||
*/
|
||||
export interface KeyResponse {
|
||||
declare module "wasi:keyvalue/store@0.2.0-draft" {
|
||||
/**
|
||||
* The list of keys returned by the query.
|
||||
* Get the bucket with the specified identifier.
|
||||
*
|
||||
* `identifier` must refer to a bucket provided by the host.
|
||||
*
|
||||
* `error::no-such-store` will be raised if the `identifier` is not recognized.
|
||||
*/
|
||||
keys: Array<string>,
|
||||
export function open(identifier: string): Bucket;
|
||||
/**
|
||||
* The continuation token to use to fetch the next page of keys. If this is `null`, then
|
||||
* there are no more keys to fetch.
|
||||
* The set of errors which may be raised by functions in this package
|
||||
*/
|
||||
cursor?: bigint,
|
||||
}
|
||||
export type Error = ErrorNoSuchStore | ErrorAccessDenied | ErrorOther;
|
||||
/**
|
||||
* The host does not recognize the store identifier requested.
|
||||
*/
|
||||
export interface ErrorNoSuchStore {
|
||||
tag: "no-such-store";
|
||||
}
|
||||
/**
|
||||
* The requesting component does not have access to the specified store
|
||||
* (which may or may not exist).
|
||||
*/
|
||||
export interface ErrorAccessDenied {
|
||||
tag: "access-denied";
|
||||
}
|
||||
/**
|
||||
* Some implementation-specific error has occurred (e.g. I/O)
|
||||
*/
|
||||
export interface ErrorOther {
|
||||
tag: "other";
|
||||
val: string;
|
||||
}
|
||||
/**
|
||||
* A response to a `list-keys` operation.
|
||||
*/
|
||||
export interface KeyResponse {
|
||||
/**
|
||||
* The list of keys returned by the query.
|
||||
*/
|
||||
keys: Array<string>;
|
||||
/**
|
||||
* The continuation token to use to fetch the next page of keys. If this is `null`, then
|
||||
* there are no more keys to fetch.
|
||||
*/
|
||||
cursor?: bigint;
|
||||
}
|
||||
|
||||
export class Bucket implements Partial<Disposable> {
|
||||
/**
|
||||
* This type does not have a public constructor.
|
||||
*/
|
||||
private constructor();
|
||||
/**
|
||||
* Get the value associated with the specified `key`
|
||||
*
|
||||
* The value is returned as an option. If the key-value pair exists in the
|
||||
* store, it returns `Ok(value)`. If the key does not exist in the
|
||||
* store, it returns `Ok(none)`.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
get(key: string): Uint8Array | undefined;
|
||||
/**
|
||||
* Set the value associated with the key in the store. If the key already
|
||||
* exists in the store, it overwrites the value.
|
||||
*
|
||||
* If the key does not exist in the store, it creates a new key-value pair.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
set(key: string, value: Uint8Array): void;
|
||||
/**
|
||||
* Delete the key-value pair associated with the key in the store.
|
||||
*
|
||||
* If the key does not exist in the store, it does nothing.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
'delete'(key: string): void;
|
||||
/**
|
||||
* Check if the key exists in the store.
|
||||
*
|
||||
* If the key exists in the store, it returns `Ok(true)`. If the key does
|
||||
* not exist in the store, it returns `Ok(false)`.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
exists(key: string): boolean;
|
||||
/**
|
||||
* Get all the keys in the store with an optional cursor (for use in pagination). It
|
||||
* returns a list of keys. Please note that for most KeyValue implementations, this is a
|
||||
* can be a very expensive operation and so it should be used judiciously. Implementations
|
||||
* can return any number of keys in a single response, but they should never attempt to
|
||||
* send more data than is reasonable (i.e. on a small edge device, this may only be a few
|
||||
* KB, while on a large machine this could be several MB). Any response should also return
|
||||
* a cursor that can be used to fetch the next page of keys. See the `key-response` record
|
||||
* for more information.
|
||||
*
|
||||
* Note that the keys are not guaranteed to be returned in any particular order.
|
||||
*
|
||||
* If the store is empty, it returns an empty list.
|
||||
*
|
||||
* MAY show an out-of-date list of keys if there are concurrent writes to the store.
|
||||
*
|
||||
* If any error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
listKeys(cursor: bigint | undefined): KeyResponse;
|
||||
[Symbol.dispose]?: () => void;
|
||||
export class Bucket implements Disposable {
|
||||
/**
|
||||
* This type does not have a public constructor.
|
||||
*/
|
||||
private constructor();
|
||||
/**
|
||||
* Get the value associated with the specified `key`
|
||||
*
|
||||
* The value is returned as an option. If the key-value pair exists in the
|
||||
* store, it returns `Ok(value)`. If the key does not exist in the
|
||||
* store, it returns `Ok(none)`.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
get(key: string): Uint8Array | undefined;
|
||||
/**
|
||||
* Set the value associated with the key in the store. If the key already
|
||||
* exists in the store, it overwrites the value.
|
||||
*
|
||||
* If the key does not exist in the store, it creates a new key-value pair.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
set(key: string, value: Uint8Array): void;
|
||||
/**
|
||||
* Delete the key-value pair associated with the key in the store.
|
||||
*
|
||||
* If the key does not exist in the store, it does nothing.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
delete(key: string): void;
|
||||
/**
|
||||
* Check if the key exists in the store.
|
||||
*
|
||||
* If the key exists in the store, it returns `Ok(true)`. If the key does
|
||||
* not exist in the store, it returns `Ok(false)`.
|
||||
*
|
||||
* If any other error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
exists(key: string): boolean;
|
||||
/**
|
||||
* Get all the keys in the store with an optional cursor (for use in pagination). It
|
||||
* returns a list of keys. Please note that for most KeyValue implementations, this is a
|
||||
* can be a very expensive operation and so it should be used judiciously. Implementations
|
||||
* can return any number of keys in a single response, but they should never attempt to
|
||||
* send more data than is reasonable (i.e. on a small edge device, this may only be a few
|
||||
* KB, while on a large machine this could be several MB). Any response should also return
|
||||
* a cursor that can be used to fetch the next page of keys. See the `key-response` record
|
||||
* for more information.
|
||||
*
|
||||
* Note that the keys are not guaranteed to be returned in any particular order.
|
||||
*
|
||||
* If the store is empty, it returns an empty list.
|
||||
*
|
||||
* MAY show an out-of-date list of keys if there are concurrent writes to the store.
|
||||
*
|
||||
* If any error occurs, it returns an `Err(error)`.
|
||||
*/
|
||||
listKeys(cursor: bigint | undefined): KeyResponse;
|
||||
[Symbol.dispose](): void;
|
||||
}
|
||||
}
|
||||
|
||||
+22
-21
@@ -1,21 +1,22 @@
|
||||
/** @module Interface wasi:random/insecure-seed@0.2.3 **/
|
||||
/**
|
||||
* Return a 128-bit value that may contain a pseudo-random value.
|
||||
*
|
||||
* The returned value is not required to be computed from a CSPRNG, and may
|
||||
* even be entirely deterministic. Host implementations are encouraged to
|
||||
* provide pseudo-random values to any program exposed to
|
||||
* attacker-controlled content, to enable DoS protection built into many
|
||||
* languages' hash-map implementations.
|
||||
*
|
||||
* This function is intended to only be called once, by a source language
|
||||
* to initialize Denial Of Service (DoS) protection in its hash-map
|
||||
* implementation.
|
||||
*
|
||||
* # Expected future evolution
|
||||
*
|
||||
* This will likely be changed to a value import, to prevent it from being
|
||||
* called multiple times and potentially used for purposes other than DoS
|
||||
* protection.
|
||||
*/
|
||||
export function insecureSeed(): [bigint, bigint];
|
||||
declare module "wasi:random/insecure-seed@0.2.3" {
|
||||
/**
|
||||
* Return a 128-bit value that may contain a pseudo-random value.
|
||||
*
|
||||
* The returned value is not required to be computed from a CSPRNG, and may
|
||||
* even be entirely deterministic. Host implementations are encouraged to
|
||||
* provide pseudo-random values to any program exposed to
|
||||
* attacker-controlled content, to enable DoS protection built into many
|
||||
* languages' hash-map implementations.
|
||||
*
|
||||
* This function is intended to only be called once, by a source language
|
||||
* to initialize Denial Of Service (DoS) protection in its hash-map
|
||||
* implementation.
|
||||
*
|
||||
* # Expected future evolution
|
||||
*
|
||||
* This will likely be changed to a value import, to prevent it from being
|
||||
* called multiple times and potentially used for purposes other than DoS
|
||||
* protection.
|
||||
*/
|
||||
export function insecureSeed(): [bigint, bigint];
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
/** @module Interface wasi:random/insecure@0.2.3 **/
|
||||
/**
|
||||
* Return `len` insecure pseudo-random bytes.
|
||||
*
|
||||
* This function is not cryptographically secure. Do not use it for
|
||||
* anything related to security.
|
||||
*
|
||||
* There are no requirements on the values of the returned bytes, however
|
||||
* implementations are encouraged to return evenly distributed values with
|
||||
* a long period.
|
||||
*/
|
||||
export function getInsecureRandomBytes(len: bigint): Uint8Array;
|
||||
/**
|
||||
* Return an insecure pseudo-random `u64` value.
|
||||
*
|
||||
* This function returns the same type of pseudo-random data as
|
||||
* `get-insecure-random-bytes`, represented as a `u64`.
|
||||
*/
|
||||
export function getInsecureRandomU64(): bigint;
|
||||
declare module "wasi:random/insecure@0.2.3" {
|
||||
/**
|
||||
* Return `len` insecure pseudo-random bytes.
|
||||
*
|
||||
* This function is not cryptographically secure. Do not use it for
|
||||
* anything related to security.
|
||||
*
|
||||
* There are no requirements on the values of the returned bytes, however
|
||||
* implementations are encouraged to return evenly distributed values with
|
||||
* a long period.
|
||||
*/
|
||||
export function getInsecureRandomBytes(len: bigint): Uint8Array;
|
||||
/**
|
||||
* Return an insecure pseudo-random `u64` value.
|
||||
*
|
||||
* This function returns the same type of pseudo-random data as
|
||||
* `get-insecure-random-bytes`, represented as a `u64`.
|
||||
*/
|
||||
export function getInsecureRandomU64(): bigint;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
/** @module Interface wasi:random/random@0.2.3 **/
|
||||
/**
|
||||
* Return `len` cryptographically-secure random or pseudo-random bytes.
|
||||
*
|
||||
* This function must produce data at least as cryptographically secure and
|
||||
* fast as an adequately seeded cryptographically-secure pseudo-random
|
||||
* number generator (CSPRNG). It must not block, from the perspective of
|
||||
* the calling program, under any circumstances, including on the first
|
||||
* request and on requests for numbers of bytes. The returned data must
|
||||
* always be unpredictable.
|
||||
*
|
||||
* This function must always return fresh data. Deterministic environments
|
||||
* must omit this function, rather than implementing it with deterministic
|
||||
* data.
|
||||
*/
|
||||
export function getRandomBytes(len: bigint): Uint8Array;
|
||||
/**
|
||||
* Return a cryptographically-secure random or pseudo-random `u64` value.
|
||||
*
|
||||
* This function returns the same type of data as `get-random-bytes`,
|
||||
* represented as a `u64`.
|
||||
*/
|
||||
export function getRandomU64(): bigint;
|
||||
declare module "wasi:random/random@0.2.3" {
|
||||
/**
|
||||
* Return `len` cryptographically-secure random or pseudo-random bytes.
|
||||
*
|
||||
* This function must produce data at least as cryptographically secure and
|
||||
* fast as an adequately seeded cryptographically-secure pseudo-random
|
||||
* number generator (CSPRNG). It must not block, from the perspective of
|
||||
* the calling program, under any circumstances, including on the first
|
||||
* request and on requests for numbers of bytes. The returned data must
|
||||
* always be unpredictable.
|
||||
*
|
||||
* This function must always return fresh data. Deterministic environments
|
||||
* must omit this function, rather than implementing it with deterministic
|
||||
* data.
|
||||
*/
|
||||
export function getRandomBytes(len: bigint): Uint8Array;
|
||||
/**
|
||||
* Return a cryptographically-secure random or pseudo-random `u64` value.
|
||||
*
|
||||
* This function returns the same type of data as `get-random-bytes`,
|
||||
* represented as a `u64`.
|
||||
*/
|
||||
export function getRandomU64(): bigint;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
"build": "vite build",
|
||||
"check": "tsc --noEmit --skipLibCheck && vite build && eslint",
|
||||
"format": "prettier -w src tests",
|
||||
"generate:types": "jco types -n trailbase:component/interfaces wit/ -o generated/types",
|
||||
"generate:types": "jco guest-types -n trailbase:component/interfaces wit/ -o generated/types && prettier -w generated/types",
|
||||
"prepack": "rm -rf ./dist && pnpm build && test -e ./dist/index.js",
|
||||
"test": "vitest run"
|
||||
},
|
||||
|
||||
@@ -28,13 +28,13 @@
|
||||
"wasi:keyvalue/store@0.2.0-draft": [
|
||||
"./generated/types/interfaces/wasi-keyvalue-store.d.ts",
|
||||
],
|
||||
"trailbase:database/sqlite": [
|
||||
"trailbase:database/sqlite@0.1.0": [
|
||||
"./generated/types/interfaces/trailbase-database-sqlite.d.ts"
|
||||
],
|
||||
"trailbase:component/init-endpoint": [
|
||||
"trailbase:component/init-endpoint@0.1.0": [
|
||||
"./generated/types/interfaces/trailbase-component-init-endpoint.d.ts"
|
||||
],
|
||||
"trailbase:component/sqlite-function-endpoint": [
|
||||
"trailbase:component/sqlite-function-endpoint@0.1.0": [
|
||||
"./generated/types/interfaces/trailbase-component-sqlite-function-endpoint.d.ts"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -11,11 +11,6 @@ const entryPoints = {
|
||||
"kv": resolve(__dirname, 'src/kv/index.ts'),
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
function external(source: string, _importer: string | undefined, _isResolved: boolean): boolean {
|
||||
return source.startsWith("wasi:") || source.startsWith("trailbase:");
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: "./dist",
|
||||
@@ -44,7 +39,10 @@ export default defineConfig({
|
||||
output: {
|
||||
entryFileNames: "[name].js",
|
||||
},
|
||||
external: external,
|
||||
external: [
|
||||
/^wasi:.*/,
|
||||
/^trailbase:.*/,
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user