@superfaceai/one-sdk
Advanced tools
Comparing version 3.0.0-beta.14 to 3.0.0-beta.15
import type { SecurityValuesMap } from './security.js'; | ||
import type { AppContext, FileSystem, Network, Persistence, TextCoder, Timers, WasiContext } from './interfaces.js'; | ||
export declare class App implements AppContext { | ||
import { AppContext, FileSystem, Network, Persistence, TextCoder, Timers, WasiContext } from './interfaces.js'; | ||
export declare class App extends AppContext { | ||
private readonly textCoder; | ||
@@ -28,5 +28,3 @@ private readonly network; | ||
loadCoreModule(module: WebAssembly.Module): Promise<void>; | ||
private get memory(); | ||
get memoryBytes(): Uint8Array; | ||
get memoryView(): DataView; | ||
get memory(): WebAssembly.Memory; | ||
init(wasi: WasiContext): Promise<void>; | ||
@@ -33,0 +31,0 @@ destroy(): Promise<void>; |
@@ -0,4 +1,4 @@ | ||
import { AppContext } from './interfaces.js'; | ||
import { PerformError, UnexpectedError, UninitializedError, ValidationError, WasiErrno, WasiError } from './error.js'; | ||
import { AsyncMutex, Asyncify, HandleMap, ReadableStreamAdapter } from './lib/index.js'; | ||
import * as sf_host from './sf_host.js'; | ||
import { AsyncMutex, Asyncify, HandleMap, ReadableStreamAdapter, sf_host } from './lib/index.js'; | ||
function headersToMultimap(headers) { | ||
@@ -15,4 +15,5 @@ const result = {}; | ||
} | ||
export class App { | ||
export class App extends AppContext { | ||
constructor(dependencies, options) { | ||
super(); | ||
this.module = undefined; | ||
@@ -46,8 +47,2 @@ this.core = undefined; | ||
} | ||
get memoryBytes() { | ||
return new Uint8Array(this.memory.buffer); | ||
} | ||
get memoryView() { | ||
return new DataView(this.memory.buffer); | ||
} | ||
async init(wasi) { | ||
@@ -54,0 +49,0 @@ if (this.module === undefined) { |
@@ -0,1 +1,2 @@ | ||
export * from './lib/error.js'; | ||
export declare abstract class BaseError extends Error { | ||
@@ -17,85 +18,2 @@ constructor(name: string, message: string); | ||
} | ||
export declare class WasiError extends Error { | ||
readonly errno: WasiErrno; | ||
constructor(errno: WasiErrno); | ||
} | ||
export declare enum WasiErrno { | ||
SUCCESS = 0, | ||
E2BIG = 1, | ||
EACCES = 2, | ||
EADDRINUSE = 3, | ||
EADDRNOTAVAIL = 4, | ||
EAFNOSUPPORT = 5, | ||
EAGAIN = 6, | ||
EALREADY = 7, | ||
EBADF = 8, | ||
EBADMSG = 9, | ||
EBUSY = 10, | ||
ECANCELED = 11, | ||
ECHILD = 12, | ||
ECONNABORTED = 13, | ||
ECONNREFUSED = 14, | ||
ECONNRESET = 15, | ||
EDEADLK = 16, | ||
EDESTADDRREQ = 17, | ||
EDOM = 18, | ||
EDQUOT = 19, | ||
EEXIST = 20, | ||
EFAULT = 21, | ||
EFBIG = 22, | ||
EHOSTUNREACH = 23, | ||
EIDRM = 24, | ||
EILSEQ = 25, | ||
EINPROGRESS = 26, | ||
EINTR = 27, | ||
EINVAL = 28, | ||
EIO = 29, | ||
EISCONN = 30, | ||
EISDIR = 31, | ||
ELOOP = 32, | ||
EMFILE = 33, | ||
EMLINK = 34, | ||
EMSGSIZE = 35, | ||
EMULTIHOP = 36, | ||
ENAMETOOLONG = 37, | ||
ENETDOWN = 38, | ||
ENETRESET = 39, | ||
ENETUNREACH = 40, | ||
ENFILE = 41, | ||
ENOBUFS = 42, | ||
ENODEV = 43, | ||
ENOENT = 44, | ||
ENOEXEC = 45, | ||
ENOLCK = 46, | ||
ENOLINK = 47, | ||
ENOMEM = 48, | ||
ENOMSG = 49, | ||
ENOPROTOOPT = 50, | ||
ENOSPC = 51, | ||
ENOSYS = 52, | ||
ENOTCONN = 53, | ||
ENOTDIR = 54, | ||
ENOTEMPTY = 55, | ||
ENOTRECOVERABLE = 56, | ||
ENOTSOCK = 57, | ||
ENOTSUP = 58, | ||
ENOTTY = 59, | ||
ENXIO = 60, | ||
EOVERFLOW = 61, | ||
EOWNERDEAD = 62, | ||
EPERM = 63, | ||
EPIPE = 64, | ||
EPROTO = 65, | ||
EPROTONOSUPPORT = 66, | ||
EPROTOTYPE = 67, | ||
ERANGE = 68, | ||
EROFS = 69, | ||
ESPIPE = 70, | ||
ESRCH = 71, | ||
ESTALE = 72, | ||
ETIMEDOUT = 73, | ||
ETXTBSY = 74, | ||
EXDEV = 75, | ||
ENOTCAPABLE = 76 | ||
} | ||
export declare class HostError extends Error { | ||
@@ -102,0 +20,0 @@ readonly code: ErrorCode; |
@@ -0,1 +1,2 @@ | ||
export * from './lib/error.js'; | ||
export class BaseError extends Error { | ||
@@ -28,88 +29,2 @@ constructor(name, message) { | ||
} | ||
export class WasiError extends Error { | ||
constructor(errno) { | ||
super(`WASI error: ${WasiErrno[errno]}`); | ||
this.errno = errno; | ||
} | ||
} | ||
export var WasiErrno; | ||
(function (WasiErrno) { | ||
WasiErrno[WasiErrno["SUCCESS"] = 0] = "SUCCESS"; | ||
WasiErrno[WasiErrno["E2BIG"] = 1] = "E2BIG"; | ||
WasiErrno[WasiErrno["EACCES"] = 2] = "EACCES"; | ||
WasiErrno[WasiErrno["EADDRINUSE"] = 3] = "EADDRINUSE"; | ||
WasiErrno[WasiErrno["EADDRNOTAVAIL"] = 4] = "EADDRNOTAVAIL"; | ||
WasiErrno[WasiErrno["EAFNOSUPPORT"] = 5] = "EAFNOSUPPORT"; | ||
WasiErrno[WasiErrno["EAGAIN"] = 6] = "EAGAIN"; | ||
WasiErrno[WasiErrno["EALREADY"] = 7] = "EALREADY"; | ||
WasiErrno[WasiErrno["EBADF"] = 8] = "EBADF"; | ||
WasiErrno[WasiErrno["EBADMSG"] = 9] = "EBADMSG"; | ||
WasiErrno[WasiErrno["EBUSY"] = 10] = "EBUSY"; | ||
WasiErrno[WasiErrno["ECANCELED"] = 11] = "ECANCELED"; | ||
WasiErrno[WasiErrno["ECHILD"] = 12] = "ECHILD"; | ||
WasiErrno[WasiErrno["ECONNABORTED"] = 13] = "ECONNABORTED"; | ||
WasiErrno[WasiErrno["ECONNREFUSED"] = 14] = "ECONNREFUSED"; | ||
WasiErrno[WasiErrno["ECONNRESET"] = 15] = "ECONNRESET"; | ||
WasiErrno[WasiErrno["EDEADLK"] = 16] = "EDEADLK"; | ||
WasiErrno[WasiErrno["EDESTADDRREQ"] = 17] = "EDESTADDRREQ"; | ||
WasiErrno[WasiErrno["EDOM"] = 18] = "EDOM"; | ||
WasiErrno[WasiErrno["EDQUOT"] = 19] = "EDQUOT"; | ||
WasiErrno[WasiErrno["EEXIST"] = 20] = "EEXIST"; | ||
WasiErrno[WasiErrno["EFAULT"] = 21] = "EFAULT"; | ||
WasiErrno[WasiErrno["EFBIG"] = 22] = "EFBIG"; | ||
WasiErrno[WasiErrno["EHOSTUNREACH"] = 23] = "EHOSTUNREACH"; | ||
WasiErrno[WasiErrno["EIDRM"] = 24] = "EIDRM"; | ||
WasiErrno[WasiErrno["EILSEQ"] = 25] = "EILSEQ"; | ||
WasiErrno[WasiErrno["EINPROGRESS"] = 26] = "EINPROGRESS"; | ||
WasiErrno[WasiErrno["EINTR"] = 27] = "EINTR"; | ||
WasiErrno[WasiErrno["EINVAL"] = 28] = "EINVAL"; | ||
WasiErrno[WasiErrno["EIO"] = 29] = "EIO"; | ||
WasiErrno[WasiErrno["EISCONN"] = 30] = "EISCONN"; | ||
WasiErrno[WasiErrno["EISDIR"] = 31] = "EISDIR"; | ||
WasiErrno[WasiErrno["ELOOP"] = 32] = "ELOOP"; | ||
WasiErrno[WasiErrno["EMFILE"] = 33] = "EMFILE"; | ||
WasiErrno[WasiErrno["EMLINK"] = 34] = "EMLINK"; | ||
WasiErrno[WasiErrno["EMSGSIZE"] = 35] = "EMSGSIZE"; | ||
WasiErrno[WasiErrno["EMULTIHOP"] = 36] = "EMULTIHOP"; | ||
WasiErrno[WasiErrno["ENAMETOOLONG"] = 37] = "ENAMETOOLONG"; | ||
WasiErrno[WasiErrno["ENETDOWN"] = 38] = "ENETDOWN"; | ||
WasiErrno[WasiErrno["ENETRESET"] = 39] = "ENETRESET"; | ||
WasiErrno[WasiErrno["ENETUNREACH"] = 40] = "ENETUNREACH"; | ||
WasiErrno[WasiErrno["ENFILE"] = 41] = "ENFILE"; | ||
WasiErrno[WasiErrno["ENOBUFS"] = 42] = "ENOBUFS"; | ||
WasiErrno[WasiErrno["ENODEV"] = 43] = "ENODEV"; | ||
WasiErrno[WasiErrno["ENOENT"] = 44] = "ENOENT"; | ||
WasiErrno[WasiErrno["ENOEXEC"] = 45] = "ENOEXEC"; | ||
WasiErrno[WasiErrno["ENOLCK"] = 46] = "ENOLCK"; | ||
WasiErrno[WasiErrno["ENOLINK"] = 47] = "ENOLINK"; | ||
WasiErrno[WasiErrno["ENOMEM"] = 48] = "ENOMEM"; | ||
WasiErrno[WasiErrno["ENOMSG"] = 49] = "ENOMSG"; | ||
WasiErrno[WasiErrno["ENOPROTOOPT"] = 50] = "ENOPROTOOPT"; | ||
WasiErrno[WasiErrno["ENOSPC"] = 51] = "ENOSPC"; | ||
WasiErrno[WasiErrno["ENOSYS"] = 52] = "ENOSYS"; | ||
WasiErrno[WasiErrno["ENOTCONN"] = 53] = "ENOTCONN"; | ||
WasiErrno[WasiErrno["ENOTDIR"] = 54] = "ENOTDIR"; | ||
WasiErrno[WasiErrno["ENOTEMPTY"] = 55] = "ENOTEMPTY"; | ||
WasiErrno[WasiErrno["ENOTRECOVERABLE"] = 56] = "ENOTRECOVERABLE"; | ||
WasiErrno[WasiErrno["ENOTSOCK"] = 57] = "ENOTSOCK"; | ||
WasiErrno[WasiErrno["ENOTSUP"] = 58] = "ENOTSUP"; | ||
WasiErrno[WasiErrno["ENOTTY"] = 59] = "ENOTTY"; | ||
WasiErrno[WasiErrno["ENXIO"] = 60] = "ENXIO"; | ||
WasiErrno[WasiErrno["EOVERFLOW"] = 61] = "EOVERFLOW"; | ||
WasiErrno[WasiErrno["EOWNERDEAD"] = 62] = "EOWNERDEAD"; | ||
WasiErrno[WasiErrno["EPERM"] = 63] = "EPERM"; | ||
WasiErrno[WasiErrno["EPIPE"] = 64] = "EPIPE"; | ||
WasiErrno[WasiErrno["EPROTO"] = 65] = "EPROTO"; | ||
WasiErrno[WasiErrno["EPROTONOSUPPORT"] = 66] = "EPROTONOSUPPORT"; | ||
WasiErrno[WasiErrno["EPROTOTYPE"] = 67] = "EPROTOTYPE"; | ||
WasiErrno[WasiErrno["ERANGE"] = 68] = "ERANGE"; | ||
WasiErrno[WasiErrno["EROFS"] = 69] = "EROFS"; | ||
WasiErrno[WasiErrno["ESPIPE"] = 70] = "ESPIPE"; | ||
WasiErrno[WasiErrno["ESRCH"] = 71] = "ESRCH"; | ||
WasiErrno[WasiErrno["ESTALE"] = 72] = "ESTALE"; | ||
WasiErrno[WasiErrno["ETIMEDOUT"] = 73] = "ETIMEDOUT"; | ||
WasiErrno[WasiErrno["ETXTBSY"] = 74] = "ETXTBSY"; | ||
WasiErrno[WasiErrno["EXDEV"] = 75] = "EXDEV"; | ||
WasiErrno[WasiErrno["ENOTCAPABLE"] = 76] = "ENOTCAPABLE"; | ||
})(WasiErrno || (WasiErrno = {})); | ||
export class HostError extends Error { | ||
@@ -116,0 +31,0 @@ constructor(code, message) { |
@@ -5,2 +5,2 @@ export { App } from './app.js'; | ||
export type { SecurityValuesMap } from './security.js'; | ||
export { HandleMap, AsyncMutex, corePathURL } from './lib/index.js'; | ||
export { HandleMap, AsyncMutex } from './lib/index.js'; |
export { App } from './app.js'; | ||
export * from './error.js'; | ||
export { HandleMap, AsyncMutex, corePathURL } from './lib/index.js'; | ||
export { HandleMap, AsyncMutex } from './lib/index.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,9 +0,2 @@ | ||
export interface AppContext { | ||
memoryBytes: Uint8Array; | ||
memoryView: DataView; | ||
handleMessage(message: any): Promise<any>; | ||
readStream(handle: number, out: Uint8Array): Promise<number>; | ||
writeStream(handle: number, data: Uint8Array): Promise<number>; | ||
closeStream(handle: number): Promise<void>; | ||
} | ||
export * from './lib/interfaces.js'; | ||
export interface FileSystem { | ||
@@ -29,6 +22,2 @@ /** Return true if the file exists (can be `stat`ed). */ | ||
} | ||
export interface TextCoder { | ||
decodeUtf8(buffer: ArrayBufferLike): string; | ||
encodeUtf8(string: string): ArrayBuffer; | ||
} | ||
export interface Timers { | ||
@@ -35,0 +24,0 @@ setTimeout(callback: () => void, ms: number): number; |
@@ -1,2 +0,2 @@ | ||
export {}; | ||
export * from './lib/interfaces.js'; | ||
//# sourceMappingURL=interfaces.js.map |
@@ -0,1 +1,2 @@ | ||
export * from './interfaces.js'; | ||
export * from './asyncify.js'; | ||
@@ -5,2 +6,2 @@ export * from './async_mutex.js'; | ||
export * from './stream.js'; | ||
export * from './wasm.js'; | ||
export * as sf_host from './sf_host.js'; |
@@ -0,1 +1,2 @@ | ||
export * from './interfaces.js'; | ||
export * from './asyncify.js'; | ||
@@ -5,3 +6,3 @@ export * from './async_mutex.js'; | ||
export * from './stream.js'; | ||
export * from './wasm.js'; | ||
export * as sf_host from './sf_host.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -14,4 +14,4 @@ export type Stream = { | ||
read(out: Uint8Array): Promise<number>; | ||
write(data: Uint8Array): Promise<number>; | ||
write(_data: Uint8Array): Promise<number>; | ||
close(): Promise<void>; | ||
} |
@@ -30,3 +30,3 @@ export class ReadableStreamAdapter { | ||
} | ||
async write(data) { | ||
async write(_data) { | ||
throw new Error('not implemented'); | ||
@@ -33,0 +33,0 @@ } |
@@ -37,2 +37,3 @@ import { SecurityValuesMap } from './common/index.js'; | ||
private readonly fileSystem; | ||
private readonly pkg; | ||
constructor(options?: ClientOptions); | ||
@@ -39,0 +40,0 @@ init(): Promise<void>; |
import fs from 'node:fs/promises'; | ||
import { createRequire } from 'node:module'; | ||
import { readFileSync } from 'node:fs'; | ||
import { resolve as resolvePath } from 'node:path'; | ||
import process from 'node:process'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { WASI } from 'node:wasi'; | ||
import { AsyncMutex } from './common/lib/index.js'; | ||
import { App, HandleMap, UnexpectedError, WasiErrno, WasiError, corePathURL } from './common/index.js'; | ||
import { App, HandleMap, UnexpectedError, WasiErrno, WasiError } from './common/index.js'; | ||
import { fetchErrorToHostError, systemErrorToWasiError } from './error.js'; | ||
const pkg = createRequire(import.meta.url)('../package.json'); | ||
function corePathURL() { | ||
return new URL('../assets/core-async.wasm', import.meta.url); | ||
} | ||
export { PerformError, UnexpectedError, ValidationError } from './common/index.js'; | ||
@@ -172,2 +173,3 @@ export { fetchErrorToHostError, systemErrorToWasiError } from './error.js'; | ||
} | ||
this.pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), { encoding: 'utf8' })); | ||
this.readyState = new AsyncMutex({ ready: false }); | ||
@@ -193,3 +195,3 @@ this.fileSystem = new NodeFileSystem(); | ||
} | ||
await this.app.loadCore(await fs.readFile(process.env.CORE_PATH ?? fileURLToPath(corePathURL()))); | ||
await this.app.loadCore(await fs.readFile(process.env.CORE_PATH ?? corePathURL().pathname)); | ||
await this.app.init(new WASI({ | ||
@@ -256,3 +258,3 @@ env: { | ||
const nodeVersion = process.version; | ||
const version = pkg.version; | ||
const version = this.pkg.version; | ||
return `one-sdk-nodejs/${version} (${platform} ${arch}) node.js/${nodeVersion}`; | ||
@@ -259,0 +261,0 @@ } |
{ | ||
"name": "@superfaceai/one-sdk", | ||
"version": "3.0.0-beta.14", | ||
"version": "3.0.0-beta.15", | ||
"exports": { | ||
@@ -5,0 +5,0 @@ ".": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5326160
50
1572