diff --git a/_examples/http-client/gen/wasi/cli/environment/environment.wit.go b/_examples/http-client/gen/wasi/cli/environment/environment.wit.go index 48e066d..d338d5f 100644 --- a/_examples/http-client/gen/wasi/cli/environment/environment.wit.go +++ b/_examples/http-client/gen/wasi/cli/environment/environment.wit.go @@ -9,15 +9,6 @@ import ( // GetEnvironment represents the imported function "get-environment". // -// Get the POSIX-style environment variables. -// -// Each environment variable is provided as a pair of string variable names -// and string value. -// -// Morally, these are a value import, but until value imports are available -// in the component model, this import function should return the same -// values each time it is called. -// // get-environment: func() -> list> // //go:nosplit @@ -32,8 +23,6 @@ func wasmimport_GetEnvironment(result *cm.List[[2]string]) // GetArguments represents the imported function "get-arguments". // -// Get the POSIX-style arguments to the program. -// // get-arguments: func() -> list // //go:nosplit @@ -48,9 +37,6 @@ func wasmimport_GetArguments(result *cm.List[string]) // InitialCWD represents the imported function "initial-cwd". // -// Return a path that programs should use as their initial current working -// directory, interpreting `.` as shorthand for this. -// // initial-cwd: func() -> option // //go:nosplit diff --git a/_examples/http-client/gen/wasi/cli/exit/exit.wit.go b/_examples/http-client/gen/wasi/cli/exit/exit.wit.go index 3fccd93..f101203 100644 --- a/_examples/http-client/gen/wasi/cli/exit/exit.wit.go +++ b/_examples/http-client/gen/wasi/cli/exit/exit.wit.go @@ -9,8 +9,6 @@ import ( // Exit represents the imported function "exit". // -// Exit the current instance and any linked instances. -// // exit: func(status: result) // //go:nosplit diff --git a/_examples/http-client/gen/wasi/cli/terminal-input/terminal-input.wit.go b/_examples/http-client/gen/wasi/cli/terminal-input/terminal-input.wit.go index e0114e0..e0c9780 100644 --- a/_examples/http-client/gen/wasi/cli/terminal-input/terminal-input.wit.go +++ b/_examples/http-client/gen/wasi/cli/terminal-input/terminal-input.wit.go @@ -1,12 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminalinput represents the imported interface "wasi:cli/terminal-input@0.2.0". -// -// Terminal input. -// -// In the future, this may include functions for disabling echoing, -// disabling input buffering so that keyboard events are sent through -// immediately, querying supported features, and so on. package terminalinput import ( @@ -15,8 +9,6 @@ import ( // TerminalInput represents the imported resource "wasi:cli/terminal-input@0.2.0#terminal-input". // -// The input side of a terminal. -// // resource terminal-input type TerminalInput cm.Resource diff --git a/_examples/http-client/gen/wasi/cli/terminal-output/terminal-output.wit.go b/_examples/http-client/gen/wasi/cli/terminal-output/terminal-output.wit.go index a63b0e6..fc6492a 100644 --- a/_examples/http-client/gen/wasi/cli/terminal-output/terminal-output.wit.go +++ b/_examples/http-client/gen/wasi/cli/terminal-output/terminal-output.wit.go @@ -1,12 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminaloutput represents the imported interface "wasi:cli/terminal-output@0.2.0". -// -// Terminal output. -// -// In the future, this may include functions for querying the terminal -// size, being notified of terminal size changes, querying supported -// features, and so on. package terminaloutput import ( @@ -15,8 +9,6 @@ import ( // TerminalOutput represents the imported resource "wasi:cli/terminal-output@0.2.0#terminal-output". // -// The output side of a terminal. -// // resource terminal-output type TerminalOutput cm.Resource diff --git a/_examples/http-client/gen/wasi/cli/terminal-stderr/terminal-stderr.wit.go b/_examples/http-client/gen/wasi/cli/terminal-stderr/terminal-stderr.wit.go index b295731..bb1a9ed 100644 --- a/_examples/http-client/gen/wasi/cli/terminal-stderr/terminal-stderr.wit.go +++ b/_examples/http-client/gen/wasi/cli/terminal-stderr/terminal-stderr.wit.go @@ -1,9 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminalstderr represents the imported interface "wasi:cli/terminal-stderr@0.2.0". -// -// An interface providing an optional `terminal-output` for stderr as a -// link-time authority. package terminalstderr import ( @@ -13,9 +10,6 @@ import ( // GetTerminalStderr represents the imported function "get-terminal-stderr". // -// If stderr is connected to a terminal, return a `terminal-output` handle -// allowing further interaction with it. -// // get-terminal-stderr: func() -> option // //go:nosplit diff --git a/_examples/http-client/gen/wasi/cli/terminal-stdin/terminal-stdin.wit.go b/_examples/http-client/gen/wasi/cli/terminal-stdin/terminal-stdin.wit.go index fcbc8a1..e1ed5a4 100644 --- a/_examples/http-client/gen/wasi/cli/terminal-stdin/terminal-stdin.wit.go +++ b/_examples/http-client/gen/wasi/cli/terminal-stdin/terminal-stdin.wit.go @@ -1,9 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminalstdin represents the imported interface "wasi:cli/terminal-stdin@0.2.0". -// -// An interface providing an optional `terminal-input` for stdin as a -// link-time authority. package terminalstdin import ( @@ -13,9 +10,6 @@ import ( // GetTerminalStdin represents the imported function "get-terminal-stdin". // -// If stdin is connected to a terminal, return a `terminal-input` handle -// allowing further interaction with it. -// // get-terminal-stdin: func() -> option // //go:nosplit diff --git a/_examples/http-client/gen/wasi/cli/terminal-stdout/terminal-stdout.wit.go b/_examples/http-client/gen/wasi/cli/terminal-stdout/terminal-stdout.wit.go index b5caaa4..accb754 100644 --- a/_examples/http-client/gen/wasi/cli/terminal-stdout/terminal-stdout.wit.go +++ b/_examples/http-client/gen/wasi/cli/terminal-stdout/terminal-stdout.wit.go @@ -1,9 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminalstdout represents the imported interface "wasi:cli/terminal-stdout@0.2.0". -// -// An interface providing an optional `terminal-output` for stdout as a -// link-time authority. package terminalstdout import ( @@ -13,9 +10,6 @@ import ( // GetTerminalStdout represents the imported function "get-terminal-stdout". // -// If stdout is connected to a terminal, return a `terminal-output` handle -// allowing further interaction with it. -// // get-terminal-stdout: func() -> option // //go:nosplit diff --git a/_examples/http-client/gen/wasi/config/runtime/runtime.wit.go b/_examples/http-client/gen/wasi/config/runtime/runtime.wit.go index edf169f..65b7b41 100644 --- a/_examples/http-client/gen/wasi/config/runtime/runtime.wit.go +++ b/_examples/http-client/gen/wasi/config/runtime/runtime.wit.go @@ -9,8 +9,6 @@ import ( // ConfigError represents the variant "wasi:config/runtime@0.2.0-draft#config-error". // -// An error type that encapsulates the different errors that can occur fetching config -// // variant config-error { // upstream(string), // io(string), @@ -18,11 +16,6 @@ import ( type ConfigError cm.Variant[uint8, string, string] // ConfigErrorUpstream returns a [ConfigError] of case "upstream". -// -// This indicates an error from an "upstream" config source. -// As this could be almost _anything_ (such as Vault, Kubernetes ConfigMaps, KeyValue -// buckets, etc), -// the error message is a string. func ConfigErrorUpstream(data string) ConfigError { return cm.New[ConfigError](0, data) } @@ -33,14 +26,6 @@ func (self *ConfigError) Upstream() *string { } // ConfigErrorIO returns a [ConfigError] of case "io". -// -// This indicates an error from an I/O operation. -// As this could be almost _anything_ (such as a file read, network connection, etc), -// the error message is a string. -// Depending on how this ends up being consumed, -// we may consider moving this to use the `wasi:io/error` type instead. -// For simplicity right now in supporting multiple implementations, it is being left -// as a string. func ConfigErrorIO(data string) ConfigError { return cm.New[ConfigError](1, data) } @@ -52,8 +37,6 @@ func (self *ConfigError) IO() *string { // Get represents the imported function "get". // -// Gets a single opaque config value set at the given key if it exists -// // get: func(key: string) -> result, config-error> // //go:nosplit @@ -69,8 +52,6 @@ func wasmimport_Get(key0 *uint8, key1 uint32, result *cm.Result[OptionStringShap // GetAll represents the imported function "get-all". // -// Gets a list of all set config data -// // get-all: func() -> result>, config-error> // //go:nosplit diff --git a/_examples/http-client/gen/wasi/logging/logging/logging.wit.go b/_examples/http-client/gen/wasi/logging/logging/logging.wit.go index 15b6e95..0535dfa 100644 --- a/_examples/http-client/gen/wasi/logging/logging/logging.wit.go +++ b/_examples/http-client/gen/wasi/logging/logging/logging.wit.go @@ -1,18 +1,13 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. -// Package logging represents the imported interface "wasi:logging/logging". -// -// WASI Logging is a logging API intended to let users emit log messages with -// simple priority levels and context values. +// Package logging represents the imported interface "wasi:logging/logging@0.1.0-draft". package logging import ( "github.com/bytecodealliance/wasm-tools-go/cm" ) -// Level represents the enum "wasi:logging/logging#level". -// -// A log level, describing a kind of message. +// Level represents the enum "wasi:logging/logging@0.1.0-draft#level". // // enum level { // trace, @@ -25,25 +20,11 @@ import ( type Level uint8 const ( - // Describes messages about the values of variables and the flow of - // control within a program. LevelTrace Level = iota - - // Describes messages likely to be of interest to someone debugging a - // program. LevelDebug - - // Describes messages likely to be of interest to someone monitoring a - // program. LevelInfo - - // Describes messages indicating hazardous situations. LevelWarn - - // Describes messages indicating serious errors. LevelError - - // Describes messages indicating fatal errors. LevelCritical ) @@ -63,13 +44,6 @@ func (e Level) String() string { // Log represents the imported function "log". // -// Emit a log message. -// -// A log message has a `level` describing what kind of message is being -// sent, a context, which is an uninterpreted string meant to help -// consumers group similar messages, and a string containing the message -// text. -// // log: func(level: level, context: string, message: string) // //go:nosplit @@ -81,6 +55,6 @@ func Log(level Level, context string, message string) { return } -//go:wasmimport wasi:logging/logging log +//go:wasmimport wasi:logging/logging@0.1.0-draft log //go:noescape func wasmimport_Log(level0 uint32, context0 *uint8, context1 uint32, message0 *uint8, message1 uint32) diff --git a/_examples/http-client/gen/wasmcloud/bus/lattice/lattice.wit.go b/_examples/http-client/gen/wasmcloud/bus/lattice/lattice.wit.go index 9e04515..5239e79 100644 --- a/_examples/http-client/gen/wasmcloud/bus/lattice/lattice.wit.go +++ b/_examples/http-client/gen/wasmcloud/bus/lattice/lattice.wit.go @@ -9,8 +9,6 @@ import ( // CallTargetInterface represents the imported resource "wasmcloud:bus/lattice@1.0.0#call-target-interface". // -// Interface target. This represents an interface, which can be selected by `set-link-name`. -// // resource call-target-interface type CallTargetInterface cm.Resource @@ -49,12 +47,6 @@ func wasmimport_NewCallTargetInterface(namespace0 *uint8, namespace1 uint32, pac // SetLinkName represents the imported function "set-link-name". // -// Set an optional link name to use for all interfaces specified. This is advanced -// functionality only available within wasmcloud and, as such, is exposed here as -// part of the -// wasmcloud:bus package. This is used when you are linking multiple of the same interfaces -// (i.e. a keyvalue implementation for caching and another one for secrets) to a component -// // set-link-name: func(name: string, interfaces: list) // //go:nosplit diff --git a/_examples/http-client/gen/wasmcloud/messaging/consumer/abi.go b/_examples/http-client/gen/wasmcloud/messaging/consumer/abi.go deleted file mode 100644 index 1e44dea..0000000 --- a/_examples/http-client/gen/wasmcloud/messaging/consumer/abi.go +++ /dev/null @@ -1,32 +0,0 @@ -// Code generated by wit-bindgen-go. DO NOT EDIT. - -package consumer - -import ( - "github.com/bytecodealliance/wasm-tools-go/cm" - "github.com/wasmCloud/component-sdk-go/_examples/http-client/gen/wasmcloud/messaging/types" - "unsafe" -) - -// BrokerMessageShape is used for storage in variant or result types. -type BrokerMessageShape struct { - shape [unsafe.Sizeof(types.BrokerMessage{})]byte -} - -func lower_OptionString(v cm.Option[string]) (f0 uint32, f1 *uint8, f2 uint32) { - some := v.Some() - if some != nil { - f0 = 1 - v1, v2 := cm.LowerString(*some) - f1 = (*uint8)(v1) - f2 = (uint32)(v2) - } - return -} - -func lower_BrokerMessage(v types.BrokerMessage) (f0 *uint8, f1 uint32, f2 *uint8, f3 uint32, f4 uint32, f5 *uint8, f6 uint32) { - f0, f1 = cm.LowerString(v.Subject) - f2, f3 = cm.LowerList(v.Body) - f4, f5, f6 = lower_OptionString(v.ReplyTo) - return -} diff --git a/_examples/http-client/gen/wasmcloud/messaging/consumer/consumer.wit.go b/_examples/http-client/gen/wasmcloud/messaging/consumer/consumer.wit.go deleted file mode 100644 index ce8e6ef..0000000 --- a/_examples/http-client/gen/wasmcloud/messaging/consumer/consumer.wit.go +++ /dev/null @@ -1,46 +0,0 @@ -// Code generated by wit-bindgen-go. DO NOT EDIT. - -// Package consumer represents the imported interface "wasmcloud:messaging/consumer@0.2.0". -package consumer - -import ( - "github.com/bytecodealliance/wasm-tools-go/cm" - "github.com/wasmCloud/component-sdk-go/_examples/http-client/gen/wasmcloud/messaging/types" -) - -// Request represents the imported function "request". -// -// Perform a request operation on a subject -// -// request: func(subject: string, body: list, timeout-ms: u32) -> result -// -//go:nosplit -func Request(subject string, body cm.List[uint8], timeoutMs uint32) (result cm.Result[BrokerMessageShape, types.BrokerMessage, string]) { - subject0, subject1 := cm.LowerString(subject) - body0, body1 := cm.LowerList(body) - timeoutMs0 := (uint32)(timeoutMs) - wasmimport_Request((*uint8)(subject0), (uint32)(subject1), (*uint8)(body0), (uint32)(body1), (uint32)(timeoutMs0), &result) - return -} - -//go:wasmimport wasmcloud:messaging/consumer@0.2.0 request -//go:noescape -func wasmimport_Request(subject0 *uint8, subject1 uint32, body0 *uint8, body1 uint32, timeoutMs0 uint32, result *cm.Result[BrokerMessageShape, types.BrokerMessage, string]) - -// Publish represents the imported function "publish". -// -// Publish a message to a subject without awaiting a response -// -// publish: func(msg: broker-message) -> result<_, string> -// -//go:nosplit -func Publish(msg types.BrokerMessage) (result cm.Result[string, struct{}, string]) { - msg0, msg1, msg2, msg3, msg4, msg5, msg6 := lower_BrokerMessage(msg) - wasmimport_Publish((*uint8)(msg0), (uint32)(msg1), (*uint8)(msg2), (uint32)(msg3), (uint32)(msg4), (*uint8)(msg5), (uint32)(msg6), &result) - return -} - -//go:wasmimport wasmcloud:messaging/consumer@0.2.0 publish -//go:noescape -func wasmimport_Publish(msg0 *uint8, msg1 uint32, msg2 *uint8, msg3 uint32, msg4 uint32, msg5 *uint8, msg6 uint32, result *cm.Result[string, struct{}, string]) diff --git a/_examples/http-client/gen/wasmcloud/messaging/consumer/empty.s b/_examples/http-client/gen/wasmcloud/messaging/consumer/empty.s deleted file mode 100644 index 5444f20..0000000 --- a/_examples/http-client/gen/wasmcloud/messaging/consumer/empty.s +++ /dev/null @@ -1,3 +0,0 @@ -// This file exists for testing this package without WebAssembly, -// allowing empty function bodies with a //go:wasmimport directive. -// See https://pkg.go.dev/cmd/compile for more information. diff --git a/_examples/http-client/gen/wasmcloud/messaging/types/types.wit.go b/_examples/http-client/gen/wasmcloud/messaging/types/types.wit.go deleted file mode 100644 index d7cbb6b..0000000 --- a/_examples/http-client/gen/wasmcloud/messaging/types/types.wit.go +++ /dev/null @@ -1,26 +0,0 @@ -// Code generated by wit-bindgen-go. DO NOT EDIT. - -// Package types represents the imported interface "wasmcloud:messaging/types@0.2.0". -// -// Types common to message broker interactions -package types - -import ( - "github.com/bytecodealliance/wasm-tools-go/cm" -) - -// BrokerMessage represents the record "wasmcloud:messaging/types@0.2.0#broker-message". -// -// A message sent to or received from a broker -// -// record broker-message { -// subject: string, -// body: list, -// reply-to: option, -// } -type BrokerMessage struct { - _ cm.HostLayout - Subject string - Body cm.List[uint8] - ReplyTo cm.Option[string] -} diff --git a/_examples/http-client/gen/wasmcloud/secrets/reveal/reveal.wit.go b/_examples/http-client/gen/wasmcloud/secrets/reveal/reveal.wit.go index ac4c1b8..13febbe 100644 --- a/_examples/http-client/gen/wasmcloud/secrets/reveal/reveal.wit.go +++ b/_examples/http-client/gen/wasmcloud/secrets/reveal/reveal.wit.go @@ -10,9 +10,6 @@ import ( // Reveal represents the imported function "reveal". // -// Reveals the value of a secret to the caller. -// This lets you easily audit your code to discover where secrets are being used. -// // reveal: func(s: borrow) -> secret-value // //go:nosplit diff --git a/_examples/http-client/gen/wasmcloud/secrets/store/store.wit.go b/_examples/http-client/gen/wasmcloud/secrets/store/store.wit.go index 09dbab5..57ddee2 100644 --- a/_examples/http-client/gen/wasmcloud/secrets/store/store.wit.go +++ b/_examples/http-client/gen/wasmcloud/secrets/store/store.wit.go @@ -9,8 +9,6 @@ import ( // SecretsError represents the variant "wasmcloud:secrets/store@0.1.0-draft#secrets-error". // -// An error type that encapsulates the different errors that can occur fetching secrets -// // variant secrets-error { // upstream(string), // io(string), @@ -19,11 +17,6 @@ import ( type SecretsError cm.Variant[uint8, string, string] // SecretsErrorUpstream returns a [SecretsError] of case "upstream". -// -// This indicates an error from an "upstream" secrets source. -// As this could be almost _anything_ (such as Vault, Kubernetes Secrets, KeyValue -// buckets, etc), -// the error message is a string. func SecretsErrorUpstream(data string) SecretsError { return cm.New[SecretsError](0, data) } @@ -34,14 +27,6 @@ func (self *SecretsError) Upstream() *string { } // SecretsErrorIO returns a [SecretsError] of case "io". -// -// This indicates an error from an I/O operation. -// As this could be almost _anything_ (such as a file read, network connection, etc), -// the error message is a string. -// Depending on how this ends up being consumed, -// we may consider moving this to use the `wasi:io/error` type instead. -// For simplicity right now in supporting multiple implementations, it is being left -// as a string. func SecretsErrorIO(data string) SecretsError { return cm.New[SecretsError](1, data) } @@ -52,10 +37,6 @@ func (self *SecretsError) IO() *string { } // SecretsErrorNotFound returns a [SecretsError] of case "not-found". -// -// This indicates that the secret was not found. Generally "not found" errors will -// be handled by the upstream secrets backend, but there are cases where the host -// may need to return this error. func SecretsErrorNotFound() SecretsError { var data struct{} return cm.New[SecretsError](2, data) @@ -68,9 +49,6 @@ func (self *SecretsError) NotFound() bool { // SecretValue represents the variant "wasmcloud:secrets/store@0.1.0-draft#secret-value". // -// A secret value can be either a string or a byte array, which lets you -// store binary data as a secret. -// // variant secret-value { // %string(string), // bytes(list), @@ -78,8 +56,6 @@ func (self *SecretsError) NotFound() bool { type SecretValue cm.Variant[uint8, string, cm.List[uint8]] // SecretValueString returns a [SecretValue] of case "string". -// -// A string value func SecretValueString(data string) SecretValue { return cm.New[SecretValue](0, data) } @@ -90,8 +66,6 @@ func (self *SecretValue) String() *string { } // SecretValueBytes returns a [SecretValue] of case "bytes". -// -// A byte array value func SecretValueBytes(data cm.List[uint8]) SecretValue { return cm.New[SecretValue](1, data) } @@ -103,11 +77,6 @@ func (self *SecretValue) Bytes() *cm.List[uint8] { // Secret represents the imported resource "wasmcloud:secrets/store@0.1.0-draft#secret". // -// A secret is a resource that can only be borrowed. This allows you to -// pass around handles to secrets and not reveal the values until a -// component needs them. -// You need to use the reveal interface to get the value. -// // resource secret type Secret cm.Resource @@ -128,8 +97,6 @@ func wasmimport_SecretResourceDrop(self0 uint32) // Get represents the imported function "get". // -// Gets a single opaque secrets value set at the given key if it exists -// // get: func(key: string) -> result // //go:nosplit diff --git a/_examples/http-client/wasmcloud.toml b/_examples/http-client/wasmcloud.toml index c0b416f..969a6cf 100644 --- a/_examples/http-client/wasmcloud.toml +++ b/_examples/http-client/wasmcloud.toml @@ -1,9 +1,10 @@ name = "http_client" -language = "tinygo" +language = "other" type = "component" version = "0.1.0" [component] +build_command = "tinygo build -target=wasip2 --wit-package ./wit --wit-world example -o build/http_client.wasm main.go" wit_world = "example" wasm_target = "wasm32-wasi-preview2" destination = "build/http_client_s.wasm" diff --git a/_examples/http-client/wit/deps.lock b/_examples/http-client/wit/deps.lock deleted file mode 100644 index 22c6b1d..0000000 --- a/_examples/http-client/wit/deps.lock +++ /dev/null @@ -1,49 +0,0 @@ -["wasi-cli-0.2.0"] -sha256 = "13b041ec2314d48107929c335df3ca81b1bb0a35bfec38e206a59162a4c209cd" -sha512 = "725886b3244f4894a1121cd66e1bea0775964ca1b3811be3ae43a4c692cb7d5f27d851072637b8ec64bd5e71e85bb5e860f8331fe8f77353d9d7868ce1d72a8e" - -["wasi-clocks-0.2.0"] -sha256 = "daf7133b4f60ba73185449327dd48d2b324799db858ab463bcd32d954a9ff394" -sha512 = "5992296c504aebfad359ab1676bba63b5d22e33112c240a437ee733433aa50552144242f8998180ff36f0da56e5f65691dbb1898331ce878bd9fa439b8909742" - -["wasi-config-0.2.0-draft"] -sha256 = "5c6b4a10b21fbab2397d579c6f8bf8a484160dfdf20b6343080b0bad097849a3" -sha512 = "d3cf5fd1d12590aefd561330337870e2e468c84753c11e19bccd165c916a696722cc29af3572984e6256088b6e683763675d5b8cec3d195f9e2961fe405629b8" - -["wasi-filesystem-0.2.0"] -sha256 = "739d4fc43cd51421382e5d1a0cf643a2985691d480ae75600cdcd382665b3e55" -sha512 = "67f61ef46833060cc4d7a258da7a82024830762c4ecfd522d32bdc5e6bf4df26043f9a8c13ea38b191df180176826aa7b163816618a939015efff5987557dc16" - -["wasi-http-0.2.0"] -sha256 = "f22b6f3b3c12289e522041067b0a2db99a27c181e9ef3ed36930aa0286232d63" -sha512 = "f9b38ef4f58cb9e069b51ee45df52ce6ca9af0a9774c3d09dc99598f36afcd902557221be2f1a6bcccdecb880e4d7436b533e03f4b9250d5b0e1466afd3a62ce" - -["wasi-io-0.2.0"] -sha256 = "0bc0cc0d474a5c4f3c2e2092664c4e235a0390e5d206d3bdc4007488d9d5e00f" -sha512 = "497f37742a94ca32eaa77dce5d9144682e743b30c2d702d37726d43735a25fa9d421afbf5945da158c0e46a0adf941f607b0e0f5d26494af52f021265f78329c" - -["wasi-logging-0.1.0-draft"] -sha256 = "619c4d2336045bab9129e5af568decd5e963006291d496a23cddf796f3a61c2e" -sha512 = "c163aa6f4e566cb85d373f25e590e552fc2530fdf50946c38d305e9f2cd189d86ff8540d163e42acd2cebbe3cef98967cd1efb14ce196da132fcf6caf4f6155d" - -["wasi-random-0.2.0"] -sha256 = "efcdf344435591830f5fbed67a2c215bba112893518a8ef4c7234a4796b8dbcd" -sha512 = "c78a10e9b6401116eac703430609a849854a27a4ff3bc7737d514536a9c16a2fc206a35f8f96b7c40f254d6a66e6873361970754fa69b856025886cd462a2832" - -["wasi-sockets-0.2.0"] -sha256 = "aa3c13fee8c788c95de5a917a54d776d5adb2afd90a77224864941ce27c5d471" -sha512 = "4e3be65dd127ccd4bfa1af8f86fea556d6e22d25e4b637f9b9ebf66ae1f6331f904edff042adc9be16fec511e3295170e6c13516715d2cd3e5aaffbd96158fa9" - -["wasmcloud-bus-1.0.0"] -sha256 = "f823b5c8293cb585092107120139c34c405f57362761a133d543f5d68c65d591" -sha512 = "12e6aa4eac6139b60ea72cc7b6ded6ac9b144b15557be9f2329b6e84b5a161d8f6344674afd0526a883cb61e34c06fee9dbadbaee1d783cd957bc43dab4bfc2d" - -[wasmcloud-component-go] -path = "../../../wit" -sha256 = "995bd9ad8d0523f04480196b6746da80ddc5daf2e3be6b126c224d1fe9bda103" -sha512 = "e5af5fbb4242fc151d83ce86fa05d54274eb33a42b8856453659a1191d5142cd3792c914df8db330a9f692089974bbd1e6d3695142a8e5416d10b5b856839ce9" -deps = ["wasi-cli-0.2.0", "wasi-clocks-0.2.0", "wasi-config-0.2.0-draft", "wasi-filesystem-0.2.0", "wasi-http-0.2.0", "wasi-io-0.2.0", "wasi-logging-0.1.0-draft", "wasi-random-0.2.0", "wasi-sockets-0.2.0", "wasmcloud-bus-1.0.0", "wasmcloud-secrets-0.1.0-draft"] - -["wasmcloud-secrets-0.1.0-draft"] -sha256 = "8e0ec182ea30a420744887cdb42660bf703194eaf8ecf2f0dc0efc4159247ea4" -sha512 = "f0037028e47d307b1551068fcdb9249a0a1cd3d7d1e8d99f33713ec1ee22bc5242fe63155a9f7aaa0492640df2c79ea40ed0839e2add222c069787b59c09f1b3" diff --git a/_examples/http-client/wit/deps.toml b/_examples/http-client/wit/deps.toml deleted file mode 100644 index 4d1db6f..0000000 --- a/_examples/http-client/wit/deps.toml +++ /dev/null @@ -1 +0,0 @@ -wasmcloud-component-go = "../../../wit" diff --git a/_examples/http-client/wit/deps/wasi-cli-0.2.0/package.wit b/_examples/http-client/wit/deps/wasi-cli-0.2.0/package.wit index 0a2737b..f8f1976 100644 --- a/_examples/http-client/wit/deps/wasi-cli-0.2.0/package.wit +++ b/_examples/http-client/wit/deps/wasi-cli-0.2.0/package.wit @@ -1,32 +1,15 @@ package wasi:cli@0.2.0; -interface environment { - /// Get the POSIX-style environment variables. - /// - /// Each environment variable is provided as a pair of string variable names - /// and string value. - /// - /// Morally, these are a value import, but until value imports are available - /// in the component model, this import function should return the same - /// values each time it is called. - get-environment: func() -> list>; - - /// Get the POSIX-style arguments to the program. - get-arguments: func() -> list; +interface stdout { + use wasi:io/streams@0.2.0.{output-stream}; - /// Return a path that programs should use as their initial current working - /// directory, interpreting `.` as shorthand for this. - initial-cwd: func() -> option; + get-stdout: func() -> output-stream; } -interface exit { - /// Exit the current instance and any linked instances. - exit: func(status: result); -} +interface stderr { + use wasi:io/streams@0.2.0.{output-stream}; -interface run { - /// Run the program. - run: func() -> result; + get-stderr: func() -> output-stream; } interface stdin { @@ -35,125 +18,41 @@ interface stdin { get-stdin: func() -> input-stream; } -interface stdout { - use wasi:io/streams@0.2.0.{output-stream}; +interface environment { + get-environment: func() -> list>; - get-stdout: func() -> output-stream; -} + get-arguments: func() -> list; -interface stderr { - use wasi:io/streams@0.2.0.{output-stream}; + initial-cwd: func() -> option; +} - get-stderr: func() -> output-stream; +interface exit { + exit: func(status: result); } -/// Terminal input. -/// -/// In the future, this may include functions for disabling echoing, -/// disabling input buffering so that keyboard events are sent through -/// immediately, querying supported features, and so on. interface terminal-input { - /// The input side of a terminal. resource terminal-input; } -/// Terminal output. -/// -/// In the future, this may include functions for querying the terminal -/// size, being notified of terminal size changes, querying supported -/// features, and so on. interface terminal-output { - /// The output side of a terminal. resource terminal-output; } -/// An interface providing an optional `terminal-input` for stdin as a -/// link-time authority. interface terminal-stdin { use terminal-input.{terminal-input}; - /// If stdin is connected to a terminal, return a `terminal-input` handle - /// allowing further interaction with it. get-terminal-stdin: func() -> option; } -/// An interface providing an optional `terminal-output` for stdout as a -/// link-time authority. interface terminal-stdout { use terminal-output.{terminal-output}; - /// If stdout is connected to a terminal, return a `terminal-output` handle - /// allowing further interaction with it. get-terminal-stdout: func() -> option; } -/// An interface providing an optional `terminal-output` for stderr as a -/// link-time authority. interface terminal-stderr { use terminal-output.{terminal-output}; - /// If stderr is connected to a terminal, return a `terminal-output` handle - /// allowing further interaction with it. get-terminal-stderr: func() -> option; } -world imports { - import environment; - import exit; - import wasi:io/error@0.2.0; - import wasi:io/poll@0.2.0; - import wasi:io/streams@0.2.0; - import stdin; - import stdout; - import stderr; - import terminal-input; - import terminal-output; - import terminal-stdin; - import terminal-stdout; - import terminal-stderr; - import wasi:clocks/monotonic-clock@0.2.0; - import wasi:clocks/wall-clock@0.2.0; - import wasi:filesystem/types@0.2.0; - import wasi:filesystem/preopens@0.2.0; - import wasi:sockets/network@0.2.0; - import wasi:sockets/instance-network@0.2.0; - import wasi:sockets/udp@0.2.0; - import wasi:sockets/udp-create-socket@0.2.0; - import wasi:sockets/tcp@0.2.0; - import wasi:sockets/tcp-create-socket@0.2.0; - import wasi:sockets/ip-name-lookup@0.2.0; - import wasi:random/random@0.2.0; - import wasi:random/insecure@0.2.0; - import wasi:random/insecure-seed@0.2.0; -} -world command { - import environment; - import exit; - import wasi:io/error@0.2.0; - import wasi:io/poll@0.2.0; - import wasi:io/streams@0.2.0; - import stdin; - import stdout; - import stderr; - import terminal-input; - import terminal-output; - import terminal-stdin; - import terminal-stdout; - import terminal-stderr; - import wasi:clocks/monotonic-clock@0.2.0; - import wasi:clocks/wall-clock@0.2.0; - import wasi:filesystem/types@0.2.0; - import wasi:filesystem/preopens@0.2.0; - import wasi:sockets/network@0.2.0; - import wasi:sockets/instance-network@0.2.0; - import wasi:sockets/udp@0.2.0; - import wasi:sockets/udp-create-socket@0.2.0; - import wasi:sockets/tcp@0.2.0; - import wasi:sockets/tcp-create-socket@0.2.0; - import wasi:sockets/ip-name-lookup@0.2.0; - import wasi:random/random@0.2.0; - import wasi:random/insecure@0.2.0; - import wasi:random/insecure-seed@0.2.0; - - export run; -} diff --git a/_examples/http-client/wit/deps/wasi-config-0.2.0-draft/package.wit b/_examples/http-client/wit/deps/wasi-config-0.2.0-draft/package.wit index 7065b9b..d514554 100644 --- a/_examples/http-client/wit/deps/wasi-config-0.2.0-draft/package.wit +++ b/_examples/http-client/wit/deps/wasi-config-0.2.0-draft/package.wit @@ -1,28 +1,13 @@ package wasi:config@0.2.0-draft; interface runtime { - /// An error type that encapsulates the different errors that can occur fetching config variant config-error { - /// This indicates an error from an "upstream" config source. - /// As this could be almost _anything_ (such as Vault, Kubernetes ConfigMaps, KeyValue buckets, etc), - /// the error message is a string. upstream(string), - /// This indicates an error from an I/O operation. - /// As this could be almost _anything_ (such as a file read, network connection, etc), - /// the error message is a string. - /// Depending on how this ends up being consumed, - /// we may consider moving this to use the `wasi:io/error` type instead. - /// For simplicity right now in supporting multiple implementations, it is being left as a string. io(string), } - /// Gets a single opaque config value set at the given key if it exists get: func(key: string) -> result, config-error>; - /// Gets a list of all set config data get-all: func() -> result>, config-error>; } -world imports { - import runtime; -} diff --git a/_examples/http-client/wit/deps/wasi-io-0.2.0/package.wit b/_examples/http-client/wit/deps/wasi-io-0.2.0/package.wit index 1840029..962734d 100644 --- a/_examples/http-client/wit/deps/wasi-io-0.2.0/package.wit +++ b/_examples/http-client/wit/deps/wasi-io-0.2.0/package.wit @@ -1,11 +1,5 @@ package wasi:io@0.2.0; -interface error { - resource error { - to-debug-string: func() -> string; - } -} - interface poll { resource pollable { ready: func() -> bool; @@ -15,6 +9,12 @@ interface poll { poll: func(in: list>) -> list; } +interface error { + resource error { + to-debug-string: func() -> string; + } +} + interface streams { use error.{error}; use poll.{pollable}; diff --git a/_examples/http-client/wit/deps/wasi-logging-0.1.0-draft/package.wit b/_examples/http-client/wit/deps/wasi-logging-0.1.0-draft/package.wit index df4e8de..70349a7 100644 --- a/_examples/http-client/wit/deps/wasi-logging-0.1.0-draft/package.wit +++ b/_examples/http-client/wit/deps/wasi-logging-0.1.0-draft/package.wit @@ -1,36 +1,15 @@ -package wasi:logging; +package wasi:logging@0.1.0-draft; -/// WASI Logging is a logging API intended to let users emit log messages with -/// simple priority levels and context values. interface logging { - /// A log level, describing a kind of message. enum level { - /// Describes messages about the values of variables and the flow of - /// control within a program. trace, - /// Describes messages likely to be of interest to someone debugging a - /// program. debug, - /// Describes messages likely to be of interest to someone monitoring a - /// program. info, - /// Describes messages indicating hazardous situations. warn, - /// Describes messages indicating serious errors. error, - /// Describes messages indicating fatal errors. critical, } - /// Emit a log message. - /// - /// A log message has a `level` describing what kind of message is being - /// sent, a context, which is an uninterpreted string meant to help - /// consumers group similar messages, and a string containing the message - /// text. log: func(level: level, context: string, message: string); } -world imports { - import logging; -} diff --git a/_examples/http-client/wit/deps/wasmcloud-bus-1.0.0/package.wit b/_examples/http-client/wit/deps/wasmcloud-bus-1.0.0/package.wit index 1008a6f..2a7cd93 100644 --- a/_examples/http-client/wit/deps/wasmcloud-bus-1.0.0/package.wit +++ b/_examples/http-client/wit/deps/wasmcloud-bus-1.0.0/package.wit @@ -1,15 +1,10 @@ package wasmcloud:bus@1.0.0; interface lattice { - /// Interface target. This represents an interface, which can be selected by `set-link-name`. resource call-target-interface { constructor(namespace: string, %package: string, %interface: string); } - /// Set an optional link name to use for all interfaces specified. This is advanced - /// functionality only available within wasmcloud and, as such, is exposed here as part of the - /// wasmcloud:bus package. This is used when you are linking multiple of the same interfaces - /// (i.e. a keyvalue implementation for caching and another one for secrets) to a component set-link-name: func(name: string, interfaces: list); } diff --git a/_examples/http-client/wit/deps/wasmcloud-component-go-0.1.0/package.wit b/_examples/http-client/wit/deps/wasmcloud-component-go-0.1.0/package.wit new file mode 100644 index 0000000..75caf04 --- /dev/null +++ b/_examples/http-client/wit/deps/wasmcloud-component-go-0.1.0/package.wit @@ -0,0 +1,85 @@ +package wasmcloud:component-go@0.1.0; + +world exports { + import wasi:io/poll@0.2.0; + import wasi:clocks/monotonic-clock@0.2.0; + import wasi:io/error@0.2.0; + import wasi:io/streams@0.2.0; + import wasi:http/types@0.2.0; + + export wasi:http/incoming-handler@0.2.0; +} +world imports { + import wasi:logging/logging@0.1.0-draft; + import wasi:config/runtime@0.2.0-draft; + import wasi:io/poll@0.2.0; + import wasi:clocks/monotonic-clock@0.2.0; + import wasi:io/error@0.2.0; + import wasi:io/streams@0.2.0; + import wasi:http/types@0.2.0; + import wasi:http/outgoing-handler@0.2.0; + import wasmcloud:bus/lattice@1.0.0; + import wasmcloud:secrets/store@0.1.0-draft; + import wasmcloud:secrets/reveal@0.1.0-draft; + import wasi:cli/environment@0.2.0; + import wasi:cli/exit@0.2.0; + import wasi:cli/stdin@0.2.0; + import wasi:cli/stdout@0.2.0; + import wasi:cli/stderr@0.2.0; + import wasi:cli/terminal-input@0.2.0; + import wasi:cli/terminal-output@0.2.0; + import wasi:cli/terminal-stdin@0.2.0; + import wasi:cli/terminal-stdout@0.2.0; + import wasi:cli/terminal-stderr@0.2.0; + import wasi:clocks/wall-clock@0.2.0; + import wasi:filesystem/types@0.2.0; + import wasi:filesystem/preopens@0.2.0; + import wasi:sockets/network@0.2.0; + import wasi:sockets/instance-network@0.2.0; + import wasi:sockets/udp@0.2.0; + import wasi:sockets/udp-create-socket@0.2.0; + import wasi:sockets/tcp@0.2.0; + import wasi:sockets/tcp-create-socket@0.2.0; + import wasi:sockets/ip-name-lookup@0.2.0; + import wasi:random/random@0.2.0; + import wasi:random/insecure@0.2.0; + import wasi:random/insecure-seed@0.2.0; +} +world sdk { + import wasi:io/poll@0.2.0; + import wasi:clocks/monotonic-clock@0.2.0; + import wasi:io/error@0.2.0; + import wasi:io/streams@0.2.0; + import wasi:http/types@0.2.0; + import wasi:logging/logging@0.1.0-draft; + import wasi:config/runtime@0.2.0-draft; + import wasi:http/outgoing-handler@0.2.0; + import wasmcloud:bus/lattice@1.0.0; + import wasmcloud:secrets/store@0.1.0-draft; + import wasmcloud:secrets/reveal@0.1.0-draft; + import wasi:cli/environment@0.2.0; + import wasi:cli/exit@0.2.0; + import wasi:cli/stdin@0.2.0; + import wasi:cli/stdout@0.2.0; + import wasi:cli/stderr@0.2.0; + import wasi:cli/terminal-input@0.2.0; + import wasi:cli/terminal-output@0.2.0; + import wasi:cli/terminal-stdin@0.2.0; + import wasi:cli/terminal-stdout@0.2.0; + import wasi:cli/terminal-stderr@0.2.0; + import wasi:clocks/wall-clock@0.2.0; + import wasi:filesystem/types@0.2.0; + import wasi:filesystem/preopens@0.2.0; + import wasi:sockets/network@0.2.0; + import wasi:sockets/instance-network@0.2.0; + import wasi:sockets/udp@0.2.0; + import wasi:sockets/udp-create-socket@0.2.0; + import wasi:sockets/tcp@0.2.0; + import wasi:sockets/tcp-create-socket@0.2.0; + import wasi:sockets/ip-name-lookup@0.2.0; + import wasi:random/random@0.2.0; + import wasi:random/insecure@0.2.0; + import wasi:random/insecure-seed@0.2.0; + + export wasi:http/incoming-handler@0.2.0; +} diff --git a/_examples/http-client/wit/deps/wasmcloud-component-go/world.wit b/_examples/http-client/wit/deps/wasmcloud-component-go/world.wit deleted file mode 100644 index f881ff8..0000000 --- a/_examples/http-client/wit/deps/wasmcloud-component-go/world.wit +++ /dev/null @@ -1,26 +0,0 @@ -package wasmcloud:component-go@0.1.0; - -world exports { - // wasi - export wasi:http/incoming-handler@0.2.0; -} - -world imports { - // tinygo - include wasi:cli/imports@0.2.0; - - // wasi - import wasi:logging/logging; - import wasi:config/runtime@0.2.0-draft; - import wasi:http/outgoing-handler@0.2.0; - - // wasmcloud - import wasmcloud:bus/lattice@1.0.0; - import wasmcloud:secrets/store@0.1.0-draft; - import wasmcloud:secrets/reveal@0.1.0-draft; -} - -world sdk { - include exports; - include imports; -} diff --git a/_examples/http-client/wit/deps/wasmcloud-secrets-0.1.0-draft/package.wit b/_examples/http-client/wit/deps/wasmcloud-secrets-0.1.0-draft/package.wit index a431b95..3a93ea4 100644 --- a/_examples/http-client/wit/deps/wasmcloud-secrets-0.1.0-draft/package.wit +++ b/_examples/http-client/wit/deps/wasmcloud-secrets-0.1.0-draft/package.wit @@ -1,52 +1,25 @@ -/// This WIT interface powers secret support in wasmCloud -/// -/// See RFC #2190 https://github.com/wasmCloud/wasmCloud/issues/2190 package wasmcloud:secrets@0.1.0-draft; interface store { - /// An error type that encapsulates the different errors that can occur fetching secrets variant secrets-error { - /// This indicates an error from an "upstream" secrets source. - /// As this could be almost _anything_ (such as Vault, Kubernetes Secrets, KeyValue buckets, etc), - /// the error message is a string. upstream(string), - /// This indicates an error from an I/O operation. - /// As this could be almost _anything_ (such as a file read, network connection, etc), - /// the error message is a string. - /// Depending on how this ends up being consumed, - /// we may consider moving this to use the `wasi:io/error` type instead. - /// For simplicity right now in supporting multiple implementations, it is being left as a string. io(string), - /// This indicates that the secret was not found. Generally "not found" errors will - /// be handled by the upstream secrets backend, but there are cases where the host - /// may need to return this error. not-found, } - /// A secret value can be either a string or a byte array, which lets you - /// store binary data as a secret. variant secret-value { - /// A string value %string(string), - /// A byte array value bytes(list), } - /// A secret is a resource that can only be borrowed. This allows you to - /// pass around handles to secrets and not reveal the values until a - /// component needs them. - /// You need to use the reveal interface to get the value. resource secret; - /// Gets a single opaque secrets value set at the given key if it exists get: func(key: string) -> result; } interface reveal { use store.{secret, secret-value}; - /// Reveals the value of a secret to the caller. - /// This lets you easily audit your code to discover where secrets are being used. reveal: func(s: borrow) -> secret-value; } diff --git a/_examples/http-client/wkg.lock b/_examples/http-client/wkg.lock new file mode 100644 index 0000000..e830db8 --- /dev/null +++ b/_examples/http-client/wkg.lock @@ -0,0 +1,21 @@ +# This file is automatically generated. +# It is not intended for manual editing. +version = 1 + +[[packages]] +name = "wasi:http" +registry = "wasi.dev" + +[[packages.versions]] +requirement = "=0.2.0" +version = "0.2.0" +digest = "sha256:5a568e6e2d60c1ce51220e1833cdd5b88db9f615720edc762a9b4a6f36b383bd" + +[[packages]] +name = "wasmcloud:component-go" +registry = "wasmcloud.com" + +[[packages.versions]] +requirement = "=0.1.0" +version = "0.1.0" +digest = "sha256:de3e9af7dedd0d9e882f68f1bee533c7af9c6a1947eb40cbf1ef6163b7d41784" diff --git a/_examples/http-server/bindings.wadge_test.go b/_examples/http-server/bindings.wadge_test.go index ba67635..fa461b9 100644 --- a/_examples/http-server/bindings.wadge_test.go +++ b/_examples/http-server/bindings.wadge_test.go @@ -1989,7 +1989,7 @@ func wasmimport_Log(level0 uint32, context0 *uint8, context1 uint32, message0 *u var __p runtime.Pinner defer __p.Unpin() if __err := wadge.WithCurrentInstance(func(__instance *wadge.Instance) error { - return __instance.Call("wasi:logging/logging", "log", func() unsafe.Pointer { + return __instance.Call("wasi:logging/logging@0.1.0-draft", "log", func() unsafe.Pointer { ptr := unsafe.Pointer(&level0) __p.Pin(ptr) return ptr diff --git a/_examples/http-server/gen/wasi/cli/environment/environment.wit.go b/_examples/http-server/gen/wasi/cli/environment/environment.wit.go index 48e066d..d338d5f 100644 --- a/_examples/http-server/gen/wasi/cli/environment/environment.wit.go +++ b/_examples/http-server/gen/wasi/cli/environment/environment.wit.go @@ -9,15 +9,6 @@ import ( // GetEnvironment represents the imported function "get-environment". // -// Get the POSIX-style environment variables. -// -// Each environment variable is provided as a pair of string variable names -// and string value. -// -// Morally, these are a value import, but until value imports are available -// in the component model, this import function should return the same -// values each time it is called. -// // get-environment: func() -> list> // //go:nosplit @@ -32,8 +23,6 @@ func wasmimport_GetEnvironment(result *cm.List[[2]string]) // GetArguments represents the imported function "get-arguments". // -// Get the POSIX-style arguments to the program. -// // get-arguments: func() -> list // //go:nosplit @@ -48,9 +37,6 @@ func wasmimport_GetArguments(result *cm.List[string]) // InitialCWD represents the imported function "initial-cwd". // -// Return a path that programs should use as their initial current working -// directory, interpreting `.` as shorthand for this. -// // initial-cwd: func() -> option // //go:nosplit diff --git a/_examples/http-server/gen/wasi/cli/exit/exit.wit.go b/_examples/http-server/gen/wasi/cli/exit/exit.wit.go index 3fccd93..f101203 100644 --- a/_examples/http-server/gen/wasi/cli/exit/exit.wit.go +++ b/_examples/http-server/gen/wasi/cli/exit/exit.wit.go @@ -9,8 +9,6 @@ import ( // Exit represents the imported function "exit". // -// Exit the current instance and any linked instances. -// // exit: func(status: result) // //go:nosplit diff --git a/_examples/http-server/gen/wasi/cli/terminal-input/terminal-input.wit.go b/_examples/http-server/gen/wasi/cli/terminal-input/terminal-input.wit.go index e0114e0..e0c9780 100644 --- a/_examples/http-server/gen/wasi/cli/terminal-input/terminal-input.wit.go +++ b/_examples/http-server/gen/wasi/cli/terminal-input/terminal-input.wit.go @@ -1,12 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminalinput represents the imported interface "wasi:cli/terminal-input@0.2.0". -// -// Terminal input. -// -// In the future, this may include functions for disabling echoing, -// disabling input buffering so that keyboard events are sent through -// immediately, querying supported features, and so on. package terminalinput import ( @@ -15,8 +9,6 @@ import ( // TerminalInput represents the imported resource "wasi:cli/terminal-input@0.2.0#terminal-input". // -// The input side of a terminal. -// // resource terminal-input type TerminalInput cm.Resource diff --git a/_examples/http-server/gen/wasi/cli/terminal-output/terminal-output.wit.go b/_examples/http-server/gen/wasi/cli/terminal-output/terminal-output.wit.go index a63b0e6..fc6492a 100644 --- a/_examples/http-server/gen/wasi/cli/terminal-output/terminal-output.wit.go +++ b/_examples/http-server/gen/wasi/cli/terminal-output/terminal-output.wit.go @@ -1,12 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminaloutput represents the imported interface "wasi:cli/terminal-output@0.2.0". -// -// Terminal output. -// -// In the future, this may include functions for querying the terminal -// size, being notified of terminal size changes, querying supported -// features, and so on. package terminaloutput import ( @@ -15,8 +9,6 @@ import ( // TerminalOutput represents the imported resource "wasi:cli/terminal-output@0.2.0#terminal-output". // -// The output side of a terminal. -// // resource terminal-output type TerminalOutput cm.Resource diff --git a/_examples/http-server/gen/wasi/cli/terminal-stderr/terminal-stderr.wit.go b/_examples/http-server/gen/wasi/cli/terminal-stderr/terminal-stderr.wit.go index 4ca4137..4d9f0c7 100644 --- a/_examples/http-server/gen/wasi/cli/terminal-stderr/terminal-stderr.wit.go +++ b/_examples/http-server/gen/wasi/cli/terminal-stderr/terminal-stderr.wit.go @@ -1,9 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminalstderr represents the imported interface "wasi:cli/terminal-stderr@0.2.0". -// -// An interface providing an optional `terminal-output` for stderr as a -// link-time authority. package terminalstderr import ( @@ -13,9 +10,6 @@ import ( // GetTerminalStderr represents the imported function "get-terminal-stderr". // -// If stderr is connected to a terminal, return a `terminal-output` handle -// allowing further interaction with it. -// // get-terminal-stderr: func() -> option // //go:nosplit diff --git a/_examples/http-server/gen/wasi/cli/terminal-stdin/terminal-stdin.wit.go b/_examples/http-server/gen/wasi/cli/terminal-stdin/terminal-stdin.wit.go index e6f21cd..903ea32 100644 --- a/_examples/http-server/gen/wasi/cli/terminal-stdin/terminal-stdin.wit.go +++ b/_examples/http-server/gen/wasi/cli/terminal-stdin/terminal-stdin.wit.go @@ -1,9 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminalstdin represents the imported interface "wasi:cli/terminal-stdin@0.2.0". -// -// An interface providing an optional `terminal-input` for stdin as a -// link-time authority. package terminalstdin import ( @@ -13,9 +10,6 @@ import ( // GetTerminalStdin represents the imported function "get-terminal-stdin". // -// If stdin is connected to a terminal, return a `terminal-input` handle -// allowing further interaction with it. -// // get-terminal-stdin: func() -> option // //go:nosplit diff --git a/_examples/http-server/gen/wasi/cli/terminal-stdout/terminal-stdout.wit.go b/_examples/http-server/gen/wasi/cli/terminal-stdout/terminal-stdout.wit.go index 3f91695..a694bad 100644 --- a/_examples/http-server/gen/wasi/cli/terminal-stdout/terminal-stdout.wit.go +++ b/_examples/http-server/gen/wasi/cli/terminal-stdout/terminal-stdout.wit.go @@ -1,9 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminalstdout represents the imported interface "wasi:cli/terminal-stdout@0.2.0". -// -// An interface providing an optional `terminal-output` for stdout as a -// link-time authority. package terminalstdout import ( @@ -13,9 +10,6 @@ import ( // GetTerminalStdout represents the imported function "get-terminal-stdout". // -// If stdout is connected to a terminal, return a `terminal-output` handle -// allowing further interaction with it. -// // get-terminal-stdout: func() -> option // //go:nosplit diff --git a/_examples/http-server/gen/wasi/config/runtime/runtime.wit.go b/_examples/http-server/gen/wasi/config/runtime/runtime.wit.go index edf169f..65b7b41 100644 --- a/_examples/http-server/gen/wasi/config/runtime/runtime.wit.go +++ b/_examples/http-server/gen/wasi/config/runtime/runtime.wit.go @@ -9,8 +9,6 @@ import ( // ConfigError represents the variant "wasi:config/runtime@0.2.0-draft#config-error". // -// An error type that encapsulates the different errors that can occur fetching config -// // variant config-error { // upstream(string), // io(string), @@ -18,11 +16,6 @@ import ( type ConfigError cm.Variant[uint8, string, string] // ConfigErrorUpstream returns a [ConfigError] of case "upstream". -// -// This indicates an error from an "upstream" config source. -// As this could be almost _anything_ (such as Vault, Kubernetes ConfigMaps, KeyValue -// buckets, etc), -// the error message is a string. func ConfigErrorUpstream(data string) ConfigError { return cm.New[ConfigError](0, data) } @@ -33,14 +26,6 @@ func (self *ConfigError) Upstream() *string { } // ConfigErrorIO returns a [ConfigError] of case "io". -// -// This indicates an error from an I/O operation. -// As this could be almost _anything_ (such as a file read, network connection, etc), -// the error message is a string. -// Depending on how this ends up being consumed, -// we may consider moving this to use the `wasi:io/error` type instead. -// For simplicity right now in supporting multiple implementations, it is being left -// as a string. func ConfigErrorIO(data string) ConfigError { return cm.New[ConfigError](1, data) } @@ -52,8 +37,6 @@ func (self *ConfigError) IO() *string { // Get represents the imported function "get". // -// Gets a single opaque config value set at the given key if it exists -// // get: func(key: string) -> result, config-error> // //go:nosplit @@ -69,8 +52,6 @@ func wasmimport_Get(key0 *uint8, key1 uint32, result *cm.Result[OptionStringShap // GetAll represents the imported function "get-all". // -// Gets a list of all set config data -// // get-all: func() -> result>, config-error> // //go:nosplit diff --git a/_examples/http-server/gen/wasi/logging/logging/logging.wit.go b/_examples/http-server/gen/wasi/logging/logging/logging.wit.go index 15b6e95..0535dfa 100644 --- a/_examples/http-server/gen/wasi/logging/logging/logging.wit.go +++ b/_examples/http-server/gen/wasi/logging/logging/logging.wit.go @@ -1,18 +1,13 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. -// Package logging represents the imported interface "wasi:logging/logging". -// -// WASI Logging is a logging API intended to let users emit log messages with -// simple priority levels and context values. +// Package logging represents the imported interface "wasi:logging/logging@0.1.0-draft". package logging import ( "github.com/bytecodealliance/wasm-tools-go/cm" ) -// Level represents the enum "wasi:logging/logging#level". -// -// A log level, describing a kind of message. +// Level represents the enum "wasi:logging/logging@0.1.0-draft#level". // // enum level { // trace, @@ -25,25 +20,11 @@ import ( type Level uint8 const ( - // Describes messages about the values of variables and the flow of - // control within a program. LevelTrace Level = iota - - // Describes messages likely to be of interest to someone debugging a - // program. LevelDebug - - // Describes messages likely to be of interest to someone monitoring a - // program. LevelInfo - - // Describes messages indicating hazardous situations. LevelWarn - - // Describes messages indicating serious errors. LevelError - - // Describes messages indicating fatal errors. LevelCritical ) @@ -63,13 +44,6 @@ func (e Level) String() string { // Log represents the imported function "log". // -// Emit a log message. -// -// A log message has a `level` describing what kind of message is being -// sent, a context, which is an uninterpreted string meant to help -// consumers group similar messages, and a string containing the message -// text. -// // log: func(level: level, context: string, message: string) // //go:nosplit @@ -81,6 +55,6 @@ func Log(level Level, context string, message string) { return } -//go:wasmimport wasi:logging/logging log +//go:wasmimport wasi:logging/logging@0.1.0-draft log //go:noescape func wasmimport_Log(level0 uint32, context0 *uint8, context1 uint32, message0 *uint8, message1 uint32) diff --git a/_examples/http-server/gen/wasmcloud/bus/lattice/lattice.wit.go b/_examples/http-server/gen/wasmcloud/bus/lattice/lattice.wit.go index 9e04515..5239e79 100644 --- a/_examples/http-server/gen/wasmcloud/bus/lattice/lattice.wit.go +++ b/_examples/http-server/gen/wasmcloud/bus/lattice/lattice.wit.go @@ -9,8 +9,6 @@ import ( // CallTargetInterface represents the imported resource "wasmcloud:bus/lattice@1.0.0#call-target-interface". // -// Interface target. This represents an interface, which can be selected by `set-link-name`. -// // resource call-target-interface type CallTargetInterface cm.Resource @@ -49,12 +47,6 @@ func wasmimport_NewCallTargetInterface(namespace0 *uint8, namespace1 uint32, pac // SetLinkName represents the imported function "set-link-name". // -// Set an optional link name to use for all interfaces specified. This is advanced -// functionality only available within wasmcloud and, as such, is exposed here as -// part of the -// wasmcloud:bus package. This is used when you are linking multiple of the same interfaces -// (i.e. a keyvalue implementation for caching and another one for secrets) to a component -// // set-link-name: func(name: string, interfaces: list) // //go:nosplit diff --git a/_examples/http-server/gen/wasmcloud/messaging/consumer/abi.go b/_examples/http-server/gen/wasmcloud/messaging/consumer/abi.go deleted file mode 100644 index 70f60eb..0000000 --- a/_examples/http-server/gen/wasmcloud/messaging/consumer/abi.go +++ /dev/null @@ -1,32 +0,0 @@ -// Code generated by wit-bindgen-go. DO NOT EDIT. - -package consumer - -import ( - "github.com/bytecodealliance/wasm-tools-go/cm" - "github.com/wasmCloud/component-sdk-go/_examples/http-server/gen/wasmcloud/messaging/types" - "unsafe" -) - -// BrokerMessageShape is used for storage in variant or result types. -type BrokerMessageShape struct { - shape [unsafe.Sizeof(types.BrokerMessage{})]byte -} - -func lower_OptionString(v cm.Option[string]) (f0 uint32, f1 *uint8, f2 uint32) { - some := v.Some() - if some != nil { - f0 = 1 - v1, v2 := cm.LowerString(*some) - f1 = (*uint8)(v1) - f2 = (uint32)(v2) - } - return -} - -func lower_BrokerMessage(v types.BrokerMessage) (f0 *uint8, f1 uint32, f2 *uint8, f3 uint32, f4 uint32, f5 *uint8, f6 uint32) { - f0, f1 = cm.LowerString(v.Subject) - f2, f3 = cm.LowerList(v.Body) - f4, f5, f6 = lower_OptionString(v.ReplyTo) - return -} diff --git a/_examples/http-server/gen/wasmcloud/messaging/consumer/consumer.wit.go b/_examples/http-server/gen/wasmcloud/messaging/consumer/consumer.wit.go deleted file mode 100644 index 3d360f4..0000000 --- a/_examples/http-server/gen/wasmcloud/messaging/consumer/consumer.wit.go +++ /dev/null @@ -1,46 +0,0 @@ -// Code generated by wit-bindgen-go. DO NOT EDIT. - -// Package consumer represents the imported interface "wasmcloud:messaging/consumer@0.2.0". -package consumer - -import ( - "github.com/bytecodealliance/wasm-tools-go/cm" - "github.com/wasmCloud/component-sdk-go/_examples/http-server/gen/wasmcloud/messaging/types" -) - -// Request represents the imported function "request". -// -// Perform a request operation on a subject -// -// request: func(subject: string, body: list, timeout-ms: u32) -> result -// -//go:nosplit -func Request(subject string, body cm.List[uint8], timeoutMs uint32) (result cm.Result[BrokerMessageShape, types.BrokerMessage, string]) { - subject0, subject1 := cm.LowerString(subject) - body0, body1 := cm.LowerList(body) - timeoutMs0 := (uint32)(timeoutMs) - wasmimport_Request((*uint8)(subject0), (uint32)(subject1), (*uint8)(body0), (uint32)(body1), (uint32)(timeoutMs0), &result) - return -} - -//go:wasmimport wasmcloud:messaging/consumer@0.2.0 request -//go:noescape -func wasmimport_Request(subject0 *uint8, subject1 uint32, body0 *uint8, body1 uint32, timeoutMs0 uint32, result *cm.Result[BrokerMessageShape, types.BrokerMessage, string]) - -// Publish represents the imported function "publish". -// -// Publish a message to a subject without awaiting a response -// -// publish: func(msg: broker-message) -> result<_, string> -// -//go:nosplit -func Publish(msg types.BrokerMessage) (result cm.Result[string, struct{}, string]) { - msg0, msg1, msg2, msg3, msg4, msg5, msg6 := lower_BrokerMessage(msg) - wasmimport_Publish((*uint8)(msg0), (uint32)(msg1), (*uint8)(msg2), (uint32)(msg3), (uint32)(msg4), (*uint8)(msg5), (uint32)(msg6), &result) - return -} - -//go:wasmimport wasmcloud:messaging/consumer@0.2.0 publish -//go:noescape -func wasmimport_Publish(msg0 *uint8, msg1 uint32, msg2 *uint8, msg3 uint32, msg4 uint32, msg5 *uint8, msg6 uint32, result *cm.Result[string, struct{}, string]) diff --git a/_examples/http-server/gen/wasmcloud/messaging/consumer/empty.s b/_examples/http-server/gen/wasmcloud/messaging/consumer/empty.s deleted file mode 100644 index 5444f20..0000000 --- a/_examples/http-server/gen/wasmcloud/messaging/consumer/empty.s +++ /dev/null @@ -1,3 +0,0 @@ -// This file exists for testing this package without WebAssembly, -// allowing empty function bodies with a //go:wasmimport directive. -// See https://pkg.go.dev/cmd/compile for more information. diff --git a/_examples/http-server/gen/wasmcloud/messaging/types/types.wit.go b/_examples/http-server/gen/wasmcloud/messaging/types/types.wit.go deleted file mode 100644 index d7cbb6b..0000000 --- a/_examples/http-server/gen/wasmcloud/messaging/types/types.wit.go +++ /dev/null @@ -1,26 +0,0 @@ -// Code generated by wit-bindgen-go. DO NOT EDIT. - -// Package types represents the imported interface "wasmcloud:messaging/types@0.2.0". -// -// Types common to message broker interactions -package types - -import ( - "github.com/bytecodealliance/wasm-tools-go/cm" -) - -// BrokerMessage represents the record "wasmcloud:messaging/types@0.2.0#broker-message". -// -// A message sent to or received from a broker -// -// record broker-message { -// subject: string, -// body: list, -// reply-to: option, -// } -type BrokerMessage struct { - _ cm.HostLayout - Subject string - Body cm.List[uint8] - ReplyTo cm.Option[string] -} diff --git a/_examples/http-server/gen/wasmcloud/secrets/reveal/reveal.wit.go b/_examples/http-server/gen/wasmcloud/secrets/reveal/reveal.wit.go index b209d91..b944ad9 100644 --- a/_examples/http-server/gen/wasmcloud/secrets/reveal/reveal.wit.go +++ b/_examples/http-server/gen/wasmcloud/secrets/reveal/reveal.wit.go @@ -10,9 +10,6 @@ import ( // Reveal represents the imported function "reveal". // -// Reveals the value of a secret to the caller. -// This lets you easily audit your code to discover where secrets are being used. -// // reveal: func(s: borrow) -> secret-value // //go:nosplit diff --git a/_examples/http-server/gen/wasmcloud/secrets/store/store.wit.go b/_examples/http-server/gen/wasmcloud/secrets/store/store.wit.go index 09dbab5..57ddee2 100644 --- a/_examples/http-server/gen/wasmcloud/secrets/store/store.wit.go +++ b/_examples/http-server/gen/wasmcloud/secrets/store/store.wit.go @@ -9,8 +9,6 @@ import ( // SecretsError represents the variant "wasmcloud:secrets/store@0.1.0-draft#secrets-error". // -// An error type that encapsulates the different errors that can occur fetching secrets -// // variant secrets-error { // upstream(string), // io(string), @@ -19,11 +17,6 @@ import ( type SecretsError cm.Variant[uint8, string, string] // SecretsErrorUpstream returns a [SecretsError] of case "upstream". -// -// This indicates an error from an "upstream" secrets source. -// As this could be almost _anything_ (such as Vault, Kubernetes Secrets, KeyValue -// buckets, etc), -// the error message is a string. func SecretsErrorUpstream(data string) SecretsError { return cm.New[SecretsError](0, data) } @@ -34,14 +27,6 @@ func (self *SecretsError) Upstream() *string { } // SecretsErrorIO returns a [SecretsError] of case "io". -// -// This indicates an error from an I/O operation. -// As this could be almost _anything_ (such as a file read, network connection, etc), -// the error message is a string. -// Depending on how this ends up being consumed, -// we may consider moving this to use the `wasi:io/error` type instead. -// For simplicity right now in supporting multiple implementations, it is being left -// as a string. func SecretsErrorIO(data string) SecretsError { return cm.New[SecretsError](1, data) } @@ -52,10 +37,6 @@ func (self *SecretsError) IO() *string { } // SecretsErrorNotFound returns a [SecretsError] of case "not-found". -// -// This indicates that the secret was not found. Generally "not found" errors will -// be handled by the upstream secrets backend, but there are cases where the host -// may need to return this error. func SecretsErrorNotFound() SecretsError { var data struct{} return cm.New[SecretsError](2, data) @@ -68,9 +49,6 @@ func (self *SecretsError) NotFound() bool { // SecretValue represents the variant "wasmcloud:secrets/store@0.1.0-draft#secret-value". // -// A secret value can be either a string or a byte array, which lets you -// store binary data as a secret. -// // variant secret-value { // %string(string), // bytes(list), @@ -78,8 +56,6 @@ func (self *SecretsError) NotFound() bool { type SecretValue cm.Variant[uint8, string, cm.List[uint8]] // SecretValueString returns a [SecretValue] of case "string". -// -// A string value func SecretValueString(data string) SecretValue { return cm.New[SecretValue](0, data) } @@ -90,8 +66,6 @@ func (self *SecretValue) String() *string { } // SecretValueBytes returns a [SecretValue] of case "bytes". -// -// A byte array value func SecretValueBytes(data cm.List[uint8]) SecretValue { return cm.New[SecretValue](1, data) } @@ -103,11 +77,6 @@ func (self *SecretValue) Bytes() *cm.List[uint8] { // Secret represents the imported resource "wasmcloud:secrets/store@0.1.0-draft#secret". // -// A secret is a resource that can only be borrowed. This allows you to -// pass around handles to secrets and not reveal the values until a -// component needs them. -// You need to use the reveal interface to get the value. -// // resource secret type Secret cm.Resource @@ -128,8 +97,6 @@ func wasmimport_SecretResourceDrop(self0 uint32) // Get represents the imported function "get". // -// Gets a single opaque secrets value set at the given key if it exists -// // get: func(key: string) -> result // //go:nosplit diff --git a/_examples/http-server/wasmcloud.toml b/_examples/http-server/wasmcloud.toml index d8f1dd4..b6e70bc 100644 --- a/_examples/http-server/wasmcloud.toml +++ b/_examples/http-server/wasmcloud.toml @@ -1,9 +1,10 @@ name = "http_server" -language = "tinygo" +language = "other" type = "component" version = "0.1.0" [component] +build_command = "tinygo build -target=wasip2 --wit-package ./wit --wit-world example -o build/http_server.wasm main.go" wit_world = "example" wasm_target = "wasm32-wasi-preview2" destination = "build/http_server_s.wasm" diff --git a/_examples/http-server/wit/deps.lock b/_examples/http-server/wit/deps.lock deleted file mode 100644 index 22c6b1d..0000000 --- a/_examples/http-server/wit/deps.lock +++ /dev/null @@ -1,49 +0,0 @@ -["wasi-cli-0.2.0"] -sha256 = "13b041ec2314d48107929c335df3ca81b1bb0a35bfec38e206a59162a4c209cd" -sha512 = "725886b3244f4894a1121cd66e1bea0775964ca1b3811be3ae43a4c692cb7d5f27d851072637b8ec64bd5e71e85bb5e860f8331fe8f77353d9d7868ce1d72a8e" - -["wasi-clocks-0.2.0"] -sha256 = "daf7133b4f60ba73185449327dd48d2b324799db858ab463bcd32d954a9ff394" -sha512 = "5992296c504aebfad359ab1676bba63b5d22e33112c240a437ee733433aa50552144242f8998180ff36f0da56e5f65691dbb1898331ce878bd9fa439b8909742" - -["wasi-config-0.2.0-draft"] -sha256 = "5c6b4a10b21fbab2397d579c6f8bf8a484160dfdf20b6343080b0bad097849a3" -sha512 = "d3cf5fd1d12590aefd561330337870e2e468c84753c11e19bccd165c916a696722cc29af3572984e6256088b6e683763675d5b8cec3d195f9e2961fe405629b8" - -["wasi-filesystem-0.2.0"] -sha256 = "739d4fc43cd51421382e5d1a0cf643a2985691d480ae75600cdcd382665b3e55" -sha512 = "67f61ef46833060cc4d7a258da7a82024830762c4ecfd522d32bdc5e6bf4df26043f9a8c13ea38b191df180176826aa7b163816618a939015efff5987557dc16" - -["wasi-http-0.2.0"] -sha256 = "f22b6f3b3c12289e522041067b0a2db99a27c181e9ef3ed36930aa0286232d63" -sha512 = "f9b38ef4f58cb9e069b51ee45df52ce6ca9af0a9774c3d09dc99598f36afcd902557221be2f1a6bcccdecb880e4d7436b533e03f4b9250d5b0e1466afd3a62ce" - -["wasi-io-0.2.0"] -sha256 = "0bc0cc0d474a5c4f3c2e2092664c4e235a0390e5d206d3bdc4007488d9d5e00f" -sha512 = "497f37742a94ca32eaa77dce5d9144682e743b30c2d702d37726d43735a25fa9d421afbf5945da158c0e46a0adf941f607b0e0f5d26494af52f021265f78329c" - -["wasi-logging-0.1.0-draft"] -sha256 = "619c4d2336045bab9129e5af568decd5e963006291d496a23cddf796f3a61c2e" -sha512 = "c163aa6f4e566cb85d373f25e590e552fc2530fdf50946c38d305e9f2cd189d86ff8540d163e42acd2cebbe3cef98967cd1efb14ce196da132fcf6caf4f6155d" - -["wasi-random-0.2.0"] -sha256 = "efcdf344435591830f5fbed67a2c215bba112893518a8ef4c7234a4796b8dbcd" -sha512 = "c78a10e9b6401116eac703430609a849854a27a4ff3bc7737d514536a9c16a2fc206a35f8f96b7c40f254d6a66e6873361970754fa69b856025886cd462a2832" - -["wasi-sockets-0.2.0"] -sha256 = "aa3c13fee8c788c95de5a917a54d776d5adb2afd90a77224864941ce27c5d471" -sha512 = "4e3be65dd127ccd4bfa1af8f86fea556d6e22d25e4b637f9b9ebf66ae1f6331f904edff042adc9be16fec511e3295170e6c13516715d2cd3e5aaffbd96158fa9" - -["wasmcloud-bus-1.0.0"] -sha256 = "f823b5c8293cb585092107120139c34c405f57362761a133d543f5d68c65d591" -sha512 = "12e6aa4eac6139b60ea72cc7b6ded6ac9b144b15557be9f2329b6e84b5a161d8f6344674afd0526a883cb61e34c06fee9dbadbaee1d783cd957bc43dab4bfc2d" - -[wasmcloud-component-go] -path = "../../../wit" -sha256 = "995bd9ad8d0523f04480196b6746da80ddc5daf2e3be6b126c224d1fe9bda103" -sha512 = "e5af5fbb4242fc151d83ce86fa05d54274eb33a42b8856453659a1191d5142cd3792c914df8db330a9f692089974bbd1e6d3695142a8e5416d10b5b856839ce9" -deps = ["wasi-cli-0.2.0", "wasi-clocks-0.2.0", "wasi-config-0.2.0-draft", "wasi-filesystem-0.2.0", "wasi-http-0.2.0", "wasi-io-0.2.0", "wasi-logging-0.1.0-draft", "wasi-random-0.2.0", "wasi-sockets-0.2.0", "wasmcloud-bus-1.0.0", "wasmcloud-secrets-0.1.0-draft"] - -["wasmcloud-secrets-0.1.0-draft"] -sha256 = "8e0ec182ea30a420744887cdb42660bf703194eaf8ecf2f0dc0efc4159247ea4" -sha512 = "f0037028e47d307b1551068fcdb9249a0a1cd3d7d1e8d99f33713ec1ee22bc5242fe63155a9f7aaa0492640df2c79ea40ed0839e2add222c069787b59c09f1b3" diff --git a/_examples/http-server/wit/deps.toml b/_examples/http-server/wit/deps.toml deleted file mode 100644 index 4d1db6f..0000000 --- a/_examples/http-server/wit/deps.toml +++ /dev/null @@ -1 +0,0 @@ -wasmcloud-component-go = "../../../wit" diff --git a/_examples/http-server/wit/deps/wasi-cli-0.2.0/package.wit b/_examples/http-server/wit/deps/wasi-cli-0.2.0/package.wit index 0a2737b..f8f1976 100644 --- a/_examples/http-server/wit/deps/wasi-cli-0.2.0/package.wit +++ b/_examples/http-server/wit/deps/wasi-cli-0.2.0/package.wit @@ -1,32 +1,15 @@ package wasi:cli@0.2.0; -interface environment { - /// Get the POSIX-style environment variables. - /// - /// Each environment variable is provided as a pair of string variable names - /// and string value. - /// - /// Morally, these are a value import, but until value imports are available - /// in the component model, this import function should return the same - /// values each time it is called. - get-environment: func() -> list>; - - /// Get the POSIX-style arguments to the program. - get-arguments: func() -> list; +interface stdout { + use wasi:io/streams@0.2.0.{output-stream}; - /// Return a path that programs should use as their initial current working - /// directory, interpreting `.` as shorthand for this. - initial-cwd: func() -> option; + get-stdout: func() -> output-stream; } -interface exit { - /// Exit the current instance and any linked instances. - exit: func(status: result); -} +interface stderr { + use wasi:io/streams@0.2.0.{output-stream}; -interface run { - /// Run the program. - run: func() -> result; + get-stderr: func() -> output-stream; } interface stdin { @@ -35,125 +18,41 @@ interface stdin { get-stdin: func() -> input-stream; } -interface stdout { - use wasi:io/streams@0.2.0.{output-stream}; +interface environment { + get-environment: func() -> list>; - get-stdout: func() -> output-stream; -} + get-arguments: func() -> list; -interface stderr { - use wasi:io/streams@0.2.0.{output-stream}; + initial-cwd: func() -> option; +} - get-stderr: func() -> output-stream; +interface exit { + exit: func(status: result); } -/// Terminal input. -/// -/// In the future, this may include functions for disabling echoing, -/// disabling input buffering so that keyboard events are sent through -/// immediately, querying supported features, and so on. interface terminal-input { - /// The input side of a terminal. resource terminal-input; } -/// Terminal output. -/// -/// In the future, this may include functions for querying the terminal -/// size, being notified of terminal size changes, querying supported -/// features, and so on. interface terminal-output { - /// The output side of a terminal. resource terminal-output; } -/// An interface providing an optional `terminal-input` for stdin as a -/// link-time authority. interface terminal-stdin { use terminal-input.{terminal-input}; - /// If stdin is connected to a terminal, return a `terminal-input` handle - /// allowing further interaction with it. get-terminal-stdin: func() -> option; } -/// An interface providing an optional `terminal-output` for stdout as a -/// link-time authority. interface terminal-stdout { use terminal-output.{terminal-output}; - /// If stdout is connected to a terminal, return a `terminal-output` handle - /// allowing further interaction with it. get-terminal-stdout: func() -> option; } -/// An interface providing an optional `terminal-output` for stderr as a -/// link-time authority. interface terminal-stderr { use terminal-output.{terminal-output}; - /// If stderr is connected to a terminal, return a `terminal-output` handle - /// allowing further interaction with it. get-terminal-stderr: func() -> option; } -world imports { - import environment; - import exit; - import wasi:io/error@0.2.0; - import wasi:io/poll@0.2.0; - import wasi:io/streams@0.2.0; - import stdin; - import stdout; - import stderr; - import terminal-input; - import terminal-output; - import terminal-stdin; - import terminal-stdout; - import terminal-stderr; - import wasi:clocks/monotonic-clock@0.2.0; - import wasi:clocks/wall-clock@0.2.0; - import wasi:filesystem/types@0.2.0; - import wasi:filesystem/preopens@0.2.0; - import wasi:sockets/network@0.2.0; - import wasi:sockets/instance-network@0.2.0; - import wasi:sockets/udp@0.2.0; - import wasi:sockets/udp-create-socket@0.2.0; - import wasi:sockets/tcp@0.2.0; - import wasi:sockets/tcp-create-socket@0.2.0; - import wasi:sockets/ip-name-lookup@0.2.0; - import wasi:random/random@0.2.0; - import wasi:random/insecure@0.2.0; - import wasi:random/insecure-seed@0.2.0; -} -world command { - import environment; - import exit; - import wasi:io/error@0.2.0; - import wasi:io/poll@0.2.0; - import wasi:io/streams@0.2.0; - import stdin; - import stdout; - import stderr; - import terminal-input; - import terminal-output; - import terminal-stdin; - import terminal-stdout; - import terminal-stderr; - import wasi:clocks/monotonic-clock@0.2.0; - import wasi:clocks/wall-clock@0.2.0; - import wasi:filesystem/types@0.2.0; - import wasi:filesystem/preopens@0.2.0; - import wasi:sockets/network@0.2.0; - import wasi:sockets/instance-network@0.2.0; - import wasi:sockets/udp@0.2.0; - import wasi:sockets/udp-create-socket@0.2.0; - import wasi:sockets/tcp@0.2.0; - import wasi:sockets/tcp-create-socket@0.2.0; - import wasi:sockets/ip-name-lookup@0.2.0; - import wasi:random/random@0.2.0; - import wasi:random/insecure@0.2.0; - import wasi:random/insecure-seed@0.2.0; - - export run; -} diff --git a/_examples/http-server/wit/deps/wasi-config-0.2.0-draft/package.wit b/_examples/http-server/wit/deps/wasi-config-0.2.0-draft/package.wit index 7065b9b..d514554 100644 --- a/_examples/http-server/wit/deps/wasi-config-0.2.0-draft/package.wit +++ b/_examples/http-server/wit/deps/wasi-config-0.2.0-draft/package.wit @@ -1,28 +1,13 @@ package wasi:config@0.2.0-draft; interface runtime { - /// An error type that encapsulates the different errors that can occur fetching config variant config-error { - /// This indicates an error from an "upstream" config source. - /// As this could be almost _anything_ (such as Vault, Kubernetes ConfigMaps, KeyValue buckets, etc), - /// the error message is a string. upstream(string), - /// This indicates an error from an I/O operation. - /// As this could be almost _anything_ (such as a file read, network connection, etc), - /// the error message is a string. - /// Depending on how this ends up being consumed, - /// we may consider moving this to use the `wasi:io/error` type instead. - /// For simplicity right now in supporting multiple implementations, it is being left as a string. io(string), } - /// Gets a single opaque config value set at the given key if it exists get: func(key: string) -> result, config-error>; - /// Gets a list of all set config data get-all: func() -> result>, config-error>; } -world imports { - import runtime; -} diff --git a/_examples/http-server/wit/deps/wasi-io-0.2.0/package.wit b/_examples/http-server/wit/deps/wasi-io-0.2.0/package.wit index 1840029..962734d 100644 --- a/_examples/http-server/wit/deps/wasi-io-0.2.0/package.wit +++ b/_examples/http-server/wit/deps/wasi-io-0.2.0/package.wit @@ -1,11 +1,5 @@ package wasi:io@0.2.0; -interface error { - resource error { - to-debug-string: func() -> string; - } -} - interface poll { resource pollable { ready: func() -> bool; @@ -15,6 +9,12 @@ interface poll { poll: func(in: list>) -> list; } +interface error { + resource error { + to-debug-string: func() -> string; + } +} + interface streams { use error.{error}; use poll.{pollable}; diff --git a/_examples/http-server/wit/deps/wasi-logging-0.1.0-draft/package.wit b/_examples/http-server/wit/deps/wasi-logging-0.1.0-draft/package.wit index df4e8de..70349a7 100644 --- a/_examples/http-server/wit/deps/wasi-logging-0.1.0-draft/package.wit +++ b/_examples/http-server/wit/deps/wasi-logging-0.1.0-draft/package.wit @@ -1,36 +1,15 @@ -package wasi:logging; +package wasi:logging@0.1.0-draft; -/// WASI Logging is a logging API intended to let users emit log messages with -/// simple priority levels and context values. interface logging { - /// A log level, describing a kind of message. enum level { - /// Describes messages about the values of variables and the flow of - /// control within a program. trace, - /// Describes messages likely to be of interest to someone debugging a - /// program. debug, - /// Describes messages likely to be of interest to someone monitoring a - /// program. info, - /// Describes messages indicating hazardous situations. warn, - /// Describes messages indicating serious errors. error, - /// Describes messages indicating fatal errors. critical, } - /// Emit a log message. - /// - /// A log message has a `level` describing what kind of message is being - /// sent, a context, which is an uninterpreted string meant to help - /// consumers group similar messages, and a string containing the message - /// text. log: func(level: level, context: string, message: string); } -world imports { - import logging; -} diff --git a/_examples/http-server/wit/deps/wasmcloud-bus-1.0.0/package.wit b/_examples/http-server/wit/deps/wasmcloud-bus-1.0.0/package.wit index 1008a6f..2a7cd93 100644 --- a/_examples/http-server/wit/deps/wasmcloud-bus-1.0.0/package.wit +++ b/_examples/http-server/wit/deps/wasmcloud-bus-1.0.0/package.wit @@ -1,15 +1,10 @@ package wasmcloud:bus@1.0.0; interface lattice { - /// Interface target. This represents an interface, which can be selected by `set-link-name`. resource call-target-interface { constructor(namespace: string, %package: string, %interface: string); } - /// Set an optional link name to use for all interfaces specified. This is advanced - /// functionality only available within wasmcloud and, as such, is exposed here as part of the - /// wasmcloud:bus package. This is used when you are linking multiple of the same interfaces - /// (i.e. a keyvalue implementation for caching and another one for secrets) to a component set-link-name: func(name: string, interfaces: list); } diff --git a/_examples/http-server/wit/deps/wasmcloud-component-go-0.1.0/package.wit b/_examples/http-server/wit/deps/wasmcloud-component-go-0.1.0/package.wit new file mode 100644 index 0000000..75caf04 --- /dev/null +++ b/_examples/http-server/wit/deps/wasmcloud-component-go-0.1.0/package.wit @@ -0,0 +1,85 @@ +package wasmcloud:component-go@0.1.0; + +world exports { + import wasi:io/poll@0.2.0; + import wasi:clocks/monotonic-clock@0.2.0; + import wasi:io/error@0.2.0; + import wasi:io/streams@0.2.0; + import wasi:http/types@0.2.0; + + export wasi:http/incoming-handler@0.2.0; +} +world imports { + import wasi:logging/logging@0.1.0-draft; + import wasi:config/runtime@0.2.0-draft; + import wasi:io/poll@0.2.0; + import wasi:clocks/monotonic-clock@0.2.0; + import wasi:io/error@0.2.0; + import wasi:io/streams@0.2.0; + import wasi:http/types@0.2.0; + import wasi:http/outgoing-handler@0.2.0; + import wasmcloud:bus/lattice@1.0.0; + import wasmcloud:secrets/store@0.1.0-draft; + import wasmcloud:secrets/reveal@0.1.0-draft; + import wasi:cli/environment@0.2.0; + import wasi:cli/exit@0.2.0; + import wasi:cli/stdin@0.2.0; + import wasi:cli/stdout@0.2.0; + import wasi:cli/stderr@0.2.0; + import wasi:cli/terminal-input@0.2.0; + import wasi:cli/terminal-output@0.2.0; + import wasi:cli/terminal-stdin@0.2.0; + import wasi:cli/terminal-stdout@0.2.0; + import wasi:cli/terminal-stderr@0.2.0; + import wasi:clocks/wall-clock@0.2.0; + import wasi:filesystem/types@0.2.0; + import wasi:filesystem/preopens@0.2.0; + import wasi:sockets/network@0.2.0; + import wasi:sockets/instance-network@0.2.0; + import wasi:sockets/udp@0.2.0; + import wasi:sockets/udp-create-socket@0.2.0; + import wasi:sockets/tcp@0.2.0; + import wasi:sockets/tcp-create-socket@0.2.0; + import wasi:sockets/ip-name-lookup@0.2.0; + import wasi:random/random@0.2.0; + import wasi:random/insecure@0.2.0; + import wasi:random/insecure-seed@0.2.0; +} +world sdk { + import wasi:io/poll@0.2.0; + import wasi:clocks/monotonic-clock@0.2.0; + import wasi:io/error@0.2.0; + import wasi:io/streams@0.2.0; + import wasi:http/types@0.2.0; + import wasi:logging/logging@0.1.0-draft; + import wasi:config/runtime@0.2.0-draft; + import wasi:http/outgoing-handler@0.2.0; + import wasmcloud:bus/lattice@1.0.0; + import wasmcloud:secrets/store@0.1.0-draft; + import wasmcloud:secrets/reveal@0.1.0-draft; + import wasi:cli/environment@0.2.0; + import wasi:cli/exit@0.2.0; + import wasi:cli/stdin@0.2.0; + import wasi:cli/stdout@0.2.0; + import wasi:cli/stderr@0.2.0; + import wasi:cli/terminal-input@0.2.0; + import wasi:cli/terminal-output@0.2.0; + import wasi:cli/terminal-stdin@0.2.0; + import wasi:cli/terminal-stdout@0.2.0; + import wasi:cli/terminal-stderr@0.2.0; + import wasi:clocks/wall-clock@0.2.0; + import wasi:filesystem/types@0.2.0; + import wasi:filesystem/preopens@0.2.0; + import wasi:sockets/network@0.2.0; + import wasi:sockets/instance-network@0.2.0; + import wasi:sockets/udp@0.2.0; + import wasi:sockets/udp-create-socket@0.2.0; + import wasi:sockets/tcp@0.2.0; + import wasi:sockets/tcp-create-socket@0.2.0; + import wasi:sockets/ip-name-lookup@0.2.0; + import wasi:random/random@0.2.0; + import wasi:random/insecure@0.2.0; + import wasi:random/insecure-seed@0.2.0; + + export wasi:http/incoming-handler@0.2.0; +} diff --git a/_examples/http-server/wit/deps/wasmcloud-component-go/world.wit b/_examples/http-server/wit/deps/wasmcloud-component-go/world.wit deleted file mode 100644 index f881ff8..0000000 --- a/_examples/http-server/wit/deps/wasmcloud-component-go/world.wit +++ /dev/null @@ -1,26 +0,0 @@ -package wasmcloud:component-go@0.1.0; - -world exports { - // wasi - export wasi:http/incoming-handler@0.2.0; -} - -world imports { - // tinygo - include wasi:cli/imports@0.2.0; - - // wasi - import wasi:logging/logging; - import wasi:config/runtime@0.2.0-draft; - import wasi:http/outgoing-handler@0.2.0; - - // wasmcloud - import wasmcloud:bus/lattice@1.0.0; - import wasmcloud:secrets/store@0.1.0-draft; - import wasmcloud:secrets/reveal@0.1.0-draft; -} - -world sdk { - include exports; - include imports; -} diff --git a/_examples/http-server/wit/deps/wasmcloud-secrets-0.1.0-draft/package.wit b/_examples/http-server/wit/deps/wasmcloud-secrets-0.1.0-draft/package.wit index a431b95..3a93ea4 100644 --- a/_examples/http-server/wit/deps/wasmcloud-secrets-0.1.0-draft/package.wit +++ b/_examples/http-server/wit/deps/wasmcloud-secrets-0.1.0-draft/package.wit @@ -1,52 +1,25 @@ -/// This WIT interface powers secret support in wasmCloud -/// -/// See RFC #2190 https://github.com/wasmCloud/wasmCloud/issues/2190 package wasmcloud:secrets@0.1.0-draft; interface store { - /// An error type that encapsulates the different errors that can occur fetching secrets variant secrets-error { - /// This indicates an error from an "upstream" secrets source. - /// As this could be almost _anything_ (such as Vault, Kubernetes Secrets, KeyValue buckets, etc), - /// the error message is a string. upstream(string), - /// This indicates an error from an I/O operation. - /// As this could be almost _anything_ (such as a file read, network connection, etc), - /// the error message is a string. - /// Depending on how this ends up being consumed, - /// we may consider moving this to use the `wasi:io/error` type instead. - /// For simplicity right now in supporting multiple implementations, it is being left as a string. io(string), - /// This indicates that the secret was not found. Generally "not found" errors will - /// be handled by the upstream secrets backend, but there are cases where the host - /// may need to return this error. not-found, } - /// A secret value can be either a string or a byte array, which lets you - /// store binary data as a secret. variant secret-value { - /// A string value %string(string), - /// A byte array value bytes(list), } - /// A secret is a resource that can only be borrowed. This allows you to - /// pass around handles to secrets and not reveal the values until a - /// component needs them. - /// You need to use the reveal interface to get the value. resource secret; - /// Gets a single opaque secrets value set at the given key if it exists get: func(key: string) -> result; } interface reveal { use store.{secret, secret-value}; - /// Reveals the value of a secret to the caller. - /// This lets you easily audit your code to discover where secrets are being used. reveal: func(s: borrow) -> secret-value; } diff --git a/_examples/http-server/wkg.lock b/_examples/http-server/wkg.lock new file mode 100644 index 0000000..e830db8 --- /dev/null +++ b/_examples/http-server/wkg.lock @@ -0,0 +1,21 @@ +# This file is automatically generated. +# It is not intended for manual editing. +version = 1 + +[[packages]] +name = "wasi:http" +registry = "wasi.dev" + +[[packages.versions]] +requirement = "=0.2.0" +version = "0.2.0" +digest = "sha256:5a568e6e2d60c1ce51220e1833cdd5b88db9f615720edc762a9b4a6f36b383bd" + +[[packages]] +name = "wasmcloud:component-go" +registry = "wasmcloud.com" + +[[packages.versions]] +requirement = "=0.1.0" +version = "0.1.0" +digest = "sha256:de3e9af7dedd0d9e882f68f1bee533c7af9c6a1947eb40cbf1ef6163b7d41784" diff --git a/_examples/invoke/gen/wasi/cli/environment/environment.wit.go b/_examples/invoke/gen/wasi/cli/environment/environment.wit.go index 48e066d..d338d5f 100644 --- a/_examples/invoke/gen/wasi/cli/environment/environment.wit.go +++ b/_examples/invoke/gen/wasi/cli/environment/environment.wit.go @@ -9,15 +9,6 @@ import ( // GetEnvironment represents the imported function "get-environment". // -// Get the POSIX-style environment variables. -// -// Each environment variable is provided as a pair of string variable names -// and string value. -// -// Morally, these are a value import, but until value imports are available -// in the component model, this import function should return the same -// values each time it is called. -// // get-environment: func() -> list> // //go:nosplit @@ -32,8 +23,6 @@ func wasmimport_GetEnvironment(result *cm.List[[2]string]) // GetArguments represents the imported function "get-arguments". // -// Get the POSIX-style arguments to the program. -// // get-arguments: func() -> list // //go:nosplit @@ -48,9 +37,6 @@ func wasmimport_GetArguments(result *cm.List[string]) // InitialCWD represents the imported function "initial-cwd". // -// Return a path that programs should use as their initial current working -// directory, interpreting `.` as shorthand for this. -// // initial-cwd: func() -> option // //go:nosplit diff --git a/_examples/invoke/gen/wasi/cli/exit/exit.wit.go b/_examples/invoke/gen/wasi/cli/exit/exit.wit.go index 3fccd93..f101203 100644 --- a/_examples/invoke/gen/wasi/cli/exit/exit.wit.go +++ b/_examples/invoke/gen/wasi/cli/exit/exit.wit.go @@ -9,8 +9,6 @@ import ( // Exit represents the imported function "exit". // -// Exit the current instance and any linked instances. -// // exit: func(status: result) // //go:nosplit diff --git a/_examples/invoke/gen/wasi/cli/terminal-input/terminal-input.wit.go b/_examples/invoke/gen/wasi/cli/terminal-input/terminal-input.wit.go index e0114e0..e0c9780 100644 --- a/_examples/invoke/gen/wasi/cli/terminal-input/terminal-input.wit.go +++ b/_examples/invoke/gen/wasi/cli/terminal-input/terminal-input.wit.go @@ -1,12 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminalinput represents the imported interface "wasi:cli/terminal-input@0.2.0". -// -// Terminal input. -// -// In the future, this may include functions for disabling echoing, -// disabling input buffering so that keyboard events are sent through -// immediately, querying supported features, and so on. package terminalinput import ( @@ -15,8 +9,6 @@ import ( // TerminalInput represents the imported resource "wasi:cli/terminal-input@0.2.0#terminal-input". // -// The input side of a terminal. -// // resource terminal-input type TerminalInput cm.Resource diff --git a/_examples/invoke/gen/wasi/cli/terminal-output/terminal-output.wit.go b/_examples/invoke/gen/wasi/cli/terminal-output/terminal-output.wit.go index a63b0e6..fc6492a 100644 --- a/_examples/invoke/gen/wasi/cli/terminal-output/terminal-output.wit.go +++ b/_examples/invoke/gen/wasi/cli/terminal-output/terminal-output.wit.go @@ -1,12 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminaloutput represents the imported interface "wasi:cli/terminal-output@0.2.0". -// -// Terminal output. -// -// In the future, this may include functions for querying the terminal -// size, being notified of terminal size changes, querying supported -// features, and so on. package terminaloutput import ( @@ -15,8 +9,6 @@ import ( // TerminalOutput represents the imported resource "wasi:cli/terminal-output@0.2.0#terminal-output". // -// The output side of a terminal. -// // resource terminal-output type TerminalOutput cm.Resource diff --git a/_examples/invoke/gen/wasi/cli/terminal-stderr/terminal-stderr.wit.go b/_examples/invoke/gen/wasi/cli/terminal-stderr/terminal-stderr.wit.go index 575b0db..21c1188 100644 --- a/_examples/invoke/gen/wasi/cli/terminal-stderr/terminal-stderr.wit.go +++ b/_examples/invoke/gen/wasi/cli/terminal-stderr/terminal-stderr.wit.go @@ -1,9 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminalstderr represents the imported interface "wasi:cli/terminal-stderr@0.2.0". -// -// An interface providing an optional `terminal-output` for stderr as a -// link-time authority. package terminalstderr import ( @@ -13,9 +10,6 @@ import ( // GetTerminalStderr represents the imported function "get-terminal-stderr". // -// If stderr is connected to a terminal, return a `terminal-output` handle -// allowing further interaction with it. -// // get-terminal-stderr: func() -> option // //go:nosplit diff --git a/_examples/invoke/gen/wasi/cli/terminal-stdin/terminal-stdin.wit.go b/_examples/invoke/gen/wasi/cli/terminal-stdin/terminal-stdin.wit.go index 617cad1..1679530 100644 --- a/_examples/invoke/gen/wasi/cli/terminal-stdin/terminal-stdin.wit.go +++ b/_examples/invoke/gen/wasi/cli/terminal-stdin/terminal-stdin.wit.go @@ -1,9 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminalstdin represents the imported interface "wasi:cli/terminal-stdin@0.2.0". -// -// An interface providing an optional `terminal-input` for stdin as a -// link-time authority. package terminalstdin import ( @@ -13,9 +10,6 @@ import ( // GetTerminalStdin represents the imported function "get-terminal-stdin". // -// If stdin is connected to a terminal, return a `terminal-input` handle -// allowing further interaction with it. -// // get-terminal-stdin: func() -> option // //go:nosplit diff --git a/_examples/invoke/gen/wasi/cli/terminal-stdout/terminal-stdout.wit.go b/_examples/invoke/gen/wasi/cli/terminal-stdout/terminal-stdout.wit.go index 55bb868..4546e17 100644 --- a/_examples/invoke/gen/wasi/cli/terminal-stdout/terminal-stdout.wit.go +++ b/_examples/invoke/gen/wasi/cli/terminal-stdout/terminal-stdout.wit.go @@ -1,9 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package terminalstdout represents the imported interface "wasi:cli/terminal-stdout@0.2.0". -// -// An interface providing an optional `terminal-output` for stdout as a -// link-time authority. package terminalstdout import ( @@ -13,9 +10,6 @@ import ( // GetTerminalStdout represents the imported function "get-terminal-stdout". // -// If stdout is connected to a terminal, return a `terminal-output` handle -// allowing further interaction with it. -// // get-terminal-stdout: func() -> option // //go:nosplit diff --git a/_examples/invoke/gen/wasi/config/runtime/runtime.wit.go b/_examples/invoke/gen/wasi/config/runtime/runtime.wit.go index edf169f..65b7b41 100644 --- a/_examples/invoke/gen/wasi/config/runtime/runtime.wit.go +++ b/_examples/invoke/gen/wasi/config/runtime/runtime.wit.go @@ -9,8 +9,6 @@ import ( // ConfigError represents the variant "wasi:config/runtime@0.2.0-draft#config-error". // -// An error type that encapsulates the different errors that can occur fetching config -// // variant config-error { // upstream(string), // io(string), @@ -18,11 +16,6 @@ import ( type ConfigError cm.Variant[uint8, string, string] // ConfigErrorUpstream returns a [ConfigError] of case "upstream". -// -// This indicates an error from an "upstream" config source. -// As this could be almost _anything_ (such as Vault, Kubernetes ConfigMaps, KeyValue -// buckets, etc), -// the error message is a string. func ConfigErrorUpstream(data string) ConfigError { return cm.New[ConfigError](0, data) } @@ -33,14 +26,6 @@ func (self *ConfigError) Upstream() *string { } // ConfigErrorIO returns a [ConfigError] of case "io". -// -// This indicates an error from an I/O operation. -// As this could be almost _anything_ (such as a file read, network connection, etc), -// the error message is a string. -// Depending on how this ends up being consumed, -// we may consider moving this to use the `wasi:io/error` type instead. -// For simplicity right now in supporting multiple implementations, it is being left -// as a string. func ConfigErrorIO(data string) ConfigError { return cm.New[ConfigError](1, data) } @@ -52,8 +37,6 @@ func (self *ConfigError) IO() *string { // Get represents the imported function "get". // -// Gets a single opaque config value set at the given key if it exists -// // get: func(key: string) -> result, config-error> // //go:nosplit @@ -69,8 +52,6 @@ func wasmimport_Get(key0 *uint8, key1 uint32, result *cm.Result[OptionStringShap // GetAll represents the imported function "get-all". // -// Gets a list of all set config data -// // get-all: func() -> result>, config-error> // //go:nosplit diff --git a/_examples/invoke/gen/wasi/http/outgoing-handler/outgoing-handler.wit.go b/_examples/invoke/gen/wasi/http/outgoing-handler/outgoing-handler.wit.go index 703cfc2..3889a6a 100644 --- a/_examples/invoke/gen/wasi/http/outgoing-handler/outgoing-handler.wit.go +++ b/_examples/invoke/gen/wasi/http/outgoing-handler/outgoing-handler.wit.go @@ -1,9 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package outgoinghandler represents the imported interface "wasi:http/outgoing-handler@0.2.0". -// -// This interface defines a handler of outgoing HTTP Requests. It should be -// imported by components which wish to make HTTP Requests. package outgoinghandler import ( @@ -13,17 +10,6 @@ import ( // Handle represents the imported function "handle". // -// 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`. -// // handle: func(request: outgoing-request, options: option) -> result // diff --git a/_examples/invoke/gen/wasi/http/types/types.wit.go b/_examples/invoke/gen/wasi/http/types/types.wit.go index 24f0a7a..6114993 100644 --- a/_examples/invoke/gen/wasi/http/types/types.wit.go +++ b/_examples/invoke/gen/wasi/http/types/types.wit.go @@ -1,10 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. // Package types represents the imported interface "wasi:http/types@0.2.0". -// -// This interface defines all of the types and methods for implementing -// HTTP Requests and Responses, both incoming and outgoing, as well as -// their headers, trailers, and bodies. package types import ( @@ -17,8 +13,6 @@ import ( // Method represents the variant "wasi:http/types@0.2.0#method". // -// This type corresponds to HTTP standard Methods. -// // variant method { // get, // head, @@ -144,8 +138,6 @@ func (self *Method) Other() *string { // Scheme represents the variant "wasi:http/types@0.2.0#scheme". // -// This type corresponds to HTTP standard Related Schemes. -// // variant scheme { // HTTP, // HTTPS, @@ -187,8 +179,6 @@ func (self *Scheme) Other() *string { // DNSErrorPayload represents the record "wasi:http/types@0.2.0#DNS-error-payload". // -// Defines the case payload type for `DNS-error` above: -// // record DNS-error-payload { // rcode: option, // info-code: option, @@ -201,8 +191,6 @@ type DNSErrorPayload struct { // TLSAlertReceivedPayload represents the record "wasi:http/types@0.2.0#TLS-alert-received-payload". // -// Defines the case payload type for `TLS-alert-received` above: -// // record TLS-alert-received-payload { // alert-id: option, // alert-message: option, @@ -215,8 +203,6 @@ type TLSAlertReceivedPayload struct { // FieldSizePayload represents the record "wasi:http/types@0.2.0#field-size-payload". // -// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: -// // record field-size-payload { // field-name: option, // field-size: option, @@ -229,9 +215,6 @@ type FieldSizePayload struct { // ErrorCode represents the variant "wasi:http/types@0.2.0#error-code". // -// These cases are inspired by the IANA HTTP Proxy Error Types: -// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types -// // variant error-code { // DNS-timeout, // DNS-error(DNS-error-payload), @@ -680,12 +663,6 @@ func (self *ErrorCode) ConfigurationError() bool { } // ErrorCodeInternalError returns a [ErrorCode] of case "internal-error". -// -// This is a catch-all error for anything that doesn't fit cleanly into a -// more specific case. It also includes an optional string for an -// unstructured description of the error. Users should not depend on the -// string for diagnosing errors, as it's not required to be consistent -// between implementations. func ErrorCodeInternalError(data cm.Option[string]) ErrorCode { return cm.New[ErrorCode](38, data) } @@ -697,9 +674,6 @@ func (self *ErrorCode) InternalError() *cm.Option[string] { // HeaderError represents the variant "wasi:http/types@0.2.0#header-error". // -// This type enumerates the different kinds of errors that may occur when -// setting or appending to a `fields` resource. -// // variant header-error { // invalid-syntax, // forbidden, @@ -708,17 +682,8 @@ func (self *ErrorCode) InternalError() *cm.Option[string] { type HeaderError uint8 const ( - // This error indicates that a `field-key` or `field-value` was - // syntactically invalid when used with an operation that sets headers in a - // `fields`. HeaderErrorInvalidSyntax HeaderError = iota - - // This error indicates that a forbidden `field-key` was used when trying - // to set a header in a `fields`. HeaderErrorForbidden - - // This error indicates that the operation on the `fields` was not - // permitted because the fields are immutable. HeaderErrorImmutable ) @@ -735,33 +700,16 @@ func (e HeaderError) String() string { // FieldKey represents the string "wasi:http/types@0.2.0#field-key". // -// Field keys are always strings. -// // type field-key = string type FieldKey string // FieldValue represents the list "wasi:http/types@0.2.0#field-value". // -// Field values should always be ASCII strings. However, in -// reality, HTTP implementations often have to interpret malformed values, -// so they are provided as a list of bytes. -// // type field-value = list type FieldValue cm.List[uint8] // Fields represents the imported resource "wasi:http/types@0.2.0#fields". // -// This following block defines the `fields` resource which corresponds to -// HTTP standard Fields. Fields are a common representation used for both -// Headers and Trailers. -// -// A `fields` may be mutable or immutable. A `fields` created using the -// constructor, `from-list`, or `clone` will be mutable, but a `fields` -// resource given by other means (including, but not limited to, -// `incoming-request.headers`, `outgoing-request.headers`) might be be -// immutable. In an immutable fields, the `set`, `append`, and `delete` -// operations will fail with `header-error.immutable`. -// // resource fields type Fields cm.Resource @@ -782,10 +730,6 @@ func wasmimport_FieldsResourceDrop(self0 uint32) // NewFields represents the imported constructor for resource "fields". // -// Construct an empty HTTP Fields. -// -// The resulting `fields` is mutable. -// // constructor() // //go:nosplit @@ -801,22 +745,6 @@ func wasmimport_NewFields() (result0 uint32) // FieldsFromList represents the imported static function "from-list". // -// Construct an HTTP Fields. -// -// The resulting `fields` is mutable. -// -// The list represents each key-value pair in the Fields. Keys -// which have multiple values are represented by multiple entries in this -// list with the same key. -// -// The tuple is a pair of the field key, represented as a string, and -// Value, represented as a list of bytes. In a valid Fields, all keys -// and values are valid UTF-8 strings. However, values are not always -// well-formed, so they are represented as a raw list of bytes. -// -// An error result will be returned if any header or value was -// syntactically invalid, or if a header was forbidden. -// // from-list: static func(entries: list>) -> result // @@ -833,11 +761,6 @@ func wasmimport_FieldsFromList(entries0 *cm.Tuple[FieldKey, FieldValue], entries // Append represents the imported method "append". // -// Append a value for a key. Does not change or delete any existing -// values for that key. -// -// Fails with `header-error.immutable` if the `fields` are immutable. -// // append: func(name: field-key, value: field-value) -> result<_, header-error> // //go:nosplit @@ -855,10 +778,6 @@ func wasmimport_FieldsAppend(self0 uint32, name0 *uint8, name1 uint32, value0 *u // Clone represents the imported method "clone". // -// Make a deep copy of the Fields. Equivelant in behavior to calling the -// `fields` constructor on the return value of `entries`. The resulting -// `fields` is mutable. -// // clone: func() -> fields // //go:nosplit @@ -875,11 +794,6 @@ func wasmimport_FieldsClone(self0 uint32) (result0 uint32) // Delete represents the imported method "delete". // -// Delete all values for a key. Does nothing if no values for the key -// exist. -// -// Fails with `header-error.immutable` if the `fields` are immutable. -// // delete: func(name: field-key) -> result<_, header-error> // //go:nosplit @@ -896,13 +810,6 @@ func wasmimport_FieldsDelete(self0 uint32, name0 *uint8, name1 uint32, result *c // Entries represents the imported method "entries". // -// Retrieve the full set of keys and values in the Fields. Like the -// constructor, the list represents each key-value pair. -// -// The outer list represents each key-value pair in the Fields. Keys -// which have multiple values are represented by multiple entries in this -// list with the same key. -// // entries: func() -> list> // //go:nosplit @@ -918,11 +825,6 @@ func wasmimport_FieldsEntries(self0 uint32, result *cm.List[cm.Tuple[FieldKey, F // Get represents the imported method "get". // -// Get all of the values corresponding to a key. If the key is not present -// in this `fields`, an empty list is returned. However, if the key is -// present but empty, this is represented by a list with one or more -// empty field-values present. -// // get: func(name: field-key) -> list // //go:nosplit @@ -939,9 +841,6 @@ func wasmimport_FieldsGet(self0 uint32, name0 *uint8, name1 uint32, result *cm.L // Has represents the imported method "has". // -// Returns `true` when the key is present in this `fields`. If the key is -// syntactically invalid, `false` is returned. -// // has: func(name: field-key) -> bool // //go:nosplit @@ -959,11 +858,6 @@ func wasmimport_FieldsHas(self0 uint32, name0 *uint8, name1 uint32) (result0 uin // Set represents the imported method "set". // -// Set all of the values for a key. Clears any existing values for that -// key, if they have been set. -// -// Fails with `header-error.immutable` if the `fields` are immutable. -// // set: func(name: field-key, value: list) -> result<_, header-error> // //go:nosplit @@ -981,8 +875,6 @@ func wasmimport_FieldsSet(self0 uint32, name0 *uint8, name1 uint32, value0 *Fiel // IncomingRequest represents the imported resource "wasi:http/types@0.2.0#incoming-request". // -// Represents an incoming HTTP Request. -// // resource incoming-request type IncomingRequest cm.Resource @@ -1003,8 +895,6 @@ func wasmimport_IncomingRequestResourceDrop(self0 uint32) // Authority represents the imported method "authority". // -// Returns the authority from the request, if it was present. -// // authority: func() -> option // //go:nosplit @@ -1020,9 +910,6 @@ func wasmimport_IncomingRequestAuthority(self0 uint32, result *cm.Option[string] // Consume represents the imported method "consume". // -// Gives the `incoming-body` associated with this request. Will only -// return success at most once, and subsequent calls will return error. -// // consume: func() -> result // //go:nosplit @@ -1038,15 +925,6 @@ func wasmimport_IncomingRequestConsume(self0 uint32, result *cm.Result[IncomingB // Headers represents the imported method "headers". // -// Get the `headers` associated with the request. -// -// The returned `headers` resource is immutable: `set`, `append`, and -// `delete` operations will fail with `header-error.immutable`. -// -// The `headers` returned are a child resource: it must be dropped before -// the parent `incoming-request` is dropped. Dropping this -// `incoming-request` before all children are dropped will trap. -// // headers: func() -> headers // //go:nosplit @@ -1063,8 +941,6 @@ func wasmimport_IncomingRequestHeaders(self0 uint32) (result0 uint32) // Method represents the imported method "method". // -// Returns the method of the incoming request. -// // method: func() -> method // //go:nosplit @@ -1080,8 +956,6 @@ func wasmimport_IncomingRequestMethod(self0 uint32, result *Method) // PathWithQuery represents the imported method "path-with-query". // -// Returns the path with query parameters from the request, as a string. -// // path-with-query: func() -> option // //go:nosplit @@ -1097,8 +971,6 @@ func wasmimport_IncomingRequestPathWithQuery(self0 uint32, result *cm.Option[str // Scheme represents the imported method "scheme". // -// Returns the protocol scheme from the request. -// // scheme: func() -> option // //go:nosplit @@ -1114,8 +986,6 @@ func wasmimport_IncomingRequestScheme(self0 uint32, result *cm.Option[Scheme]) // OutgoingRequest represents the imported resource "wasi:http/types@0.2.0#outgoing-request". // -// Represents an outgoing HTTP Request. -// // resource outgoing-request type OutgoingRequest cm.Resource @@ -1136,17 +1006,6 @@ func wasmimport_OutgoingRequestResourceDrop(self0 uint32) // NewOutgoingRequest represents the imported constructor for resource "outgoing-request". // -// Construct a new `outgoing-request` with a default `method` of `GET`, and -// `none` values for `path-with-query`, `scheme`, and `authority`. -// -// * `headers` is the HTTP Headers for the Request. -// -// It is possible to construct, or manipulate with the accessor functions -// below, an `outgoing-request` with an invalid combination of `scheme` -// and `authority`, or `headers` which are not permitted to be sent. -// It is the obligation of the `outgoing-handler.handle` implementation -// to reject invalid constructions of `outgoing-request`. -// // constructor(headers: headers) // //go:nosplit @@ -1163,10 +1022,6 @@ func wasmimport_NewOutgoingRequest(headers0 uint32) (result0 uint32) // Authority represents the imported method "authority". // -// Get the HTTP Authority for the Request. A value of `none` may be used -// with Related Schemes which do not require an Authority. The HTTP and -// HTTPS schemes always require an authority. -// // authority: func() -> option // //go:nosplit @@ -1182,13 +1037,6 @@ func wasmimport_OutgoingRequestAuthority(self0 uint32, result *cm.Option[string] // Body represents the imported method "body". // -// Returns the resource corresponding to the outgoing Body for this -// Request. -// -// Returns success on the first call: the `outgoing-body` resource for -// this `outgoing-request` can be retrieved at most once. Subsequent -// calls will return error. -// // body: func() -> result // //go:nosplit @@ -1204,15 +1052,6 @@ func wasmimport_OutgoingRequestBody(self0 uint32, result *cm.Result[OutgoingBody // Headers represents the imported method "headers". // -// Get the headers associated with the Request. -// -// The returned `headers` resource is immutable: `set`, `append`, and -// `delete` operations will fail with `header-error.immutable`. -// -// This headers resource is a child: it must be dropped before the parent -// `outgoing-request` is dropped, or its ownership is transfered to -// another component by e.g. `outgoing-handler.handle`. -// // headers: func() -> headers // //go:nosplit @@ -1229,8 +1068,6 @@ func wasmimport_OutgoingRequestHeaders(self0 uint32) (result0 uint32) // Method represents the imported method "method". // -// Get the Method for the Request. -// // method: func() -> method // //go:nosplit @@ -1246,9 +1083,6 @@ func wasmimport_OutgoingRequestMethod(self0 uint32, result *Method) // PathWithQuery represents the imported method "path-with-query". // -// Get the combination of the HTTP Path and Query for the Request. -// When `none`, this represents an empty Path and empty Query. -// // path-with-query: func() -> option // //go:nosplit @@ -1264,9 +1098,6 @@ func wasmimport_OutgoingRequestPathWithQuery(self0 uint32, result *cm.Option[str // Scheme represents the imported method "scheme". // -// Get the HTTP Related Scheme for the Request. When `none`, the -// implementation may choose an appropriate default scheme. -// // scheme: func() -> option // //go:nosplit @@ -1282,11 +1113,6 @@ func wasmimport_OutgoingRequestScheme(self0 uint32, result *cm.Option[Scheme]) // SetAuthority represents the imported method "set-authority". // -// Set the HTTP Authority for the Request. A value of `none` may be used -// with Related Schemes which do not require an Authority. The HTTP and -// HTTPS schemes always require an authority. Fails if the string given is -// not a syntactically valid uri authority. -// // set-authority: func(authority: option) -> result // //go:nosplit @@ -1304,9 +1130,6 @@ func wasmimport_OutgoingRequestSetAuthority(self0 uint32, authority0 uint32, aut // SetMethod represents the imported method "set-method". // -// Set the Method for the Request. Fails if the string present in a -// `method.other` argument is not a syntactically valid method. -// // set-method: func(method: method) -> result // //go:nosplit @@ -1324,10 +1147,6 @@ func wasmimport_OutgoingRequestSetMethod(self0 uint32, method0 uint32, method1 * // SetPathWithQuery represents the imported method "set-path-with-query". // -// Set the combination of the HTTP Path and Query for the Request. -// When `none`, this represents an empty Path and empty Query. Fails is the -// string given is not a syntactically valid path and query uri component. -// // set-path-with-query: func(path-with-query: option) -> result // //go:nosplit @@ -1345,10 +1164,6 @@ func wasmimport_OutgoingRequestSetPathWithQuery(self0 uint32, pathWithQuery0 uin // SetScheme represents the imported method "set-scheme". // -// Set the HTTP Related Scheme for the Request. When `none`, the -// implementation may choose an appropriate default scheme. Fails if the -// string given is not a syntactically valid uri scheme. -// // set-scheme: func(scheme: option) -> result // //go:nosplit @@ -1366,13 +1181,6 @@ func wasmimport_OutgoingRequestSetScheme(self0 uint32, scheme0 uint32, scheme1 u // RequestOptions represents the imported resource "wasi:http/types@0.2.0#request-options". // -// Parameters for making an HTTP Request. Each of these parameters is -// currently an optional timeout applicable to the transport layer of the -// HTTP protocol. -// -// These timeouts are separate from any the user may use to bound a -// blocking call to `wasi:io/poll.poll`. -// // resource request-options type RequestOptions cm.Resource @@ -1393,8 +1201,6 @@ func wasmimport_RequestOptionsResourceDrop(self0 uint32) // NewRequestOptions represents the imported constructor for resource "request-options". // -// Construct a default `request-options` value. -// // constructor() // //go:nosplit @@ -1410,9 +1216,6 @@ func wasmimport_NewRequestOptions() (result0 uint32) // BetweenBytesTimeout represents the imported method "between-bytes-timeout". // -// The timeout for receiving subsequent chunks of bytes in the Response -// body stream. -// // between-bytes-timeout: func() -> option // //go:nosplit @@ -1428,8 +1231,6 @@ func wasmimport_RequestOptionsBetweenBytesTimeout(self0 uint32, result *cm.Optio // ConnectTimeout represents the imported method "connect-timeout". // -// The timeout for the initial connect to the HTTP Server. -// // connect-timeout: func() -> option // //go:nosplit @@ -1445,8 +1246,6 @@ func wasmimport_RequestOptionsConnectTimeout(self0 uint32, result *cm.Option[mon // FirstByteTimeout represents the imported method "first-byte-timeout". // -// The timeout for receiving the first byte of the Response body. -// // first-byte-timeout: func() -> option // //go:nosplit @@ -1462,10 +1261,6 @@ func wasmimport_RequestOptionsFirstByteTimeout(self0 uint32, result *cm.Option[m // SetBetweenBytesTimeout represents the imported method "set-between-bytes-timeout". // -// Set the timeout for receiving subsequent chunks of bytes in the Response -// body stream. An error return value indicates that this timeout is not -// supported. -// // set-between-bytes-timeout: func(duration: option) -> result // //go:nosplit @@ -1483,9 +1278,6 @@ func wasmimport_RequestOptionsSetBetweenBytesTimeout(self0 uint32, duration0 uin // SetConnectTimeout represents the imported method "set-connect-timeout". // -// Set the timeout for the initial connect to the HTTP Server. An error -// return value indicates that this timeout is not supported. -// // set-connect-timeout: func(duration: option) -> result // //go:nosplit @@ -1503,9 +1295,6 @@ func wasmimport_RequestOptionsSetConnectTimeout(self0 uint32, duration0 uint32, // SetFirstByteTimeout represents the imported method "set-first-byte-timeout". // -// Set the timeout for receiving the first byte of the Response body. An -// error return value indicates that this timeout is not supported. -// // set-first-byte-timeout: func(duration: option) -> result // //go:nosplit @@ -1523,12 +1312,6 @@ func wasmimport_RequestOptionsSetFirstByteTimeout(self0 uint32, duration0 uint32 // ResponseOutparam represents the imported resource "wasi:http/types@0.2.0#response-outparam". // -// Represents the ability to send an HTTP Response. -// -// This resource is used by the `wasi:http/incoming-handler` interface to -// allow a Response to be sent corresponding to the Request provided as the -// other argument to `incoming-handler.handle`. -// // resource response-outparam type ResponseOutparam cm.Resource @@ -1549,16 +1332,6 @@ func wasmimport_ResponseOutparamResourceDrop(self0 uint32) // ResponseOutparamSet represents the imported static function "set". // -// Set the value of the `response-outparam` to either send a response, -// or indicate an error. -// -// This method consumes the `response-outparam` to ensure that it is -// called at most once. If it is never called, the implementation -// will respond with an error. -// -// The user may provide an `error` to `response` to allow the -// implementation determine how to respond with an HTTP error response. -// // set: static func(param: response-outparam, response: result) // @@ -1576,15 +1349,11 @@ func wasmimport_ResponseOutparamSet(param0 uint32, response0 uint32, response1 u // StatusCode represents the u16 "wasi:http/types@0.2.0#status-code". // -// This type corresponds to the HTTP standard Status Code. -// // type status-code = u16 type StatusCode uint16 // IncomingResponse represents the imported resource "wasi:http/types@0.2.0#incoming-response". // -// Represents an incoming HTTP Response. -// // resource incoming-response type IncomingResponse cm.Resource @@ -1605,9 +1374,6 @@ func wasmimport_IncomingResponseResourceDrop(self0 uint32) // Consume represents the imported method "consume". // -// Returns the incoming body. May be called at most once. Returns error -// if called additional times. -// // consume: func() -> result // //go:nosplit @@ -1623,14 +1389,6 @@ func wasmimport_IncomingResponseConsume(self0 uint32, result *cm.Result[Incoming // Headers represents the imported method "headers". // -// Returns the headers from the incoming response. -// -// The returned `headers` resource is immutable: `set`, `append`, and -// `delete` operations will fail with `header-error.immutable`. -// -// This headers resource is a child: it must be dropped before the parent -// `incoming-response` is dropped. -// // headers: func() -> headers // //go:nosplit @@ -1647,8 +1405,6 @@ func wasmimport_IncomingResponseHeaders(self0 uint32) (result0 uint32) // Status represents the imported method "status". // -// Returns the status code from the incoming response. -// // status: func() -> status-code // //go:nosplit @@ -1665,15 +1421,6 @@ func wasmimport_IncomingResponseStatus(self0 uint32) (result0 uint32) // IncomingBody represents the imported resource "wasi:http/types@0.2.0#incoming-body". // -// Represents an incoming HTTP Request or Response's Body. -// -// A body has both its contents - a stream of bytes - and a (possibly -// empty) set of trailers, indicating that the full contents of the -// body have been received. This resource represents the contents as -// an `input-stream` and the delivery of trailers as a `future-trailers`, -// and ensures that the user of this interface may only be consuming either -// the body contents or waiting on trailers at any given time. -// // resource incoming-body type IncomingBody cm.Resource @@ -1694,9 +1441,6 @@ func wasmimport_IncomingBodyResourceDrop(self0 uint32) // IncomingBodyFinish represents the imported static function "finish". // -// Takes ownership of `incoming-body`, and returns a `future-trailers`. -// This function will trap if the `input-stream` child is still alive. -// // finish: static func(this: incoming-body) -> future-trailers // //go:nosplit @@ -1713,22 +1457,6 @@ func wasmimport_IncomingBodyFinish(this0 uint32) (result0 uint32) // Stream represents the imported method "stream". // -// Returns the contents of the body, as a stream of bytes. -// -// Returns success on first call: the stream representing the contents -// can be retrieved at most once. Subsequent calls will return error. -// -// The returned `input-stream` resource is a child: it must be dropped -// before the parent `incoming-body` is dropped, or consumed by -// `incoming-body.finish`. -// -// This invariant ensures that the implementation can determine whether -// the user is consuming the contents of the body, waiting on the -// `future-trailers` to be ready, or neither. This allows for network -// backpressure is to be applied when the user is consuming the body, -// and for that backpressure to not inhibit delivery of the trailers if -// the user does not read the entire body. -// // %stream: func() -> result // //go:nosplit @@ -1744,12 +1472,6 @@ func wasmimport_IncomingBodyStream(self0 uint32, result *cm.Result[streams.Input // FutureTrailers represents the imported resource "wasi:http/types@0.2.0#future-trailers". // -// Represents a future which may eventaully return trailers, or an error. -// -// In the case that the incoming HTTP Request or Response did not have any -// trailers, this future will resolve to the empty set of trailers once the -// complete Request or Response body has been received. -// // resource future-trailers type FutureTrailers cm.Resource @@ -1770,26 +1492,6 @@ func wasmimport_FutureTrailersResourceDrop(self0 uint32) // Get represents the imported method "get". // -// Returns the contents of the trailers, or an error which occured, -// once the future is ready. -// -// The outer `option` represents future readiness. Users can wait on this -// `option` to become `some` using the `subscribe` method. -// -// The outer `result` is used to retrieve the trailers or error at most -// once. It will be success on the first call in which the outer option -// is `some`, and error on subsequent calls. -// -// The inner `result` represents that either the HTTP Request or Response -// body, as well as any trailers, were received successfully, or that an -// error occured receiving them. The optional `trailers` indicates whether -// or not trailers were present in the body. -// -// When some `trailers` are returned by this method, the `trailers` -// resource is immutable, and a child. Use of the `set`, `append`, or -// `delete` methods will return an error, and the resource must be -// dropped before the parent `future-trailers` is dropped. -// // get: func() -> option, error-code>>> // //go:nosplit @@ -1805,10 +1507,6 @@ func wasmimport_FutureTrailersGet(self0 uint32, result *cm.Option[cm.Result[cm.R // Subscribe represents the imported method "subscribe". // -// Returns a pollable which becomes ready when either the trailers have -// been received, or an error has occured. When this pollable is ready, -// the `get` method will return `some`. -// // subscribe: func() -> pollable // //go:nosplit @@ -1825,8 +1523,6 @@ func wasmimport_FutureTrailersSubscribe(self0 uint32) (result0 uint32) // OutgoingResponse represents the imported resource "wasi:http/types@0.2.0#outgoing-response". // -// Represents an outgoing HTTP Response. -// // resource outgoing-response type OutgoingResponse cm.Resource @@ -1847,12 +1543,6 @@ func wasmimport_OutgoingResponseResourceDrop(self0 uint32) // NewOutgoingResponse represents the imported constructor for resource "outgoing-response". // -// Construct an `outgoing-response`, with a default `status-code` of `200`. -// If a different `status-code` is needed, it must be set via the -// `set-status-code` method. -// -// * `headers` is the HTTP Headers for the Response. -// // constructor(headers: headers) // //go:nosplit @@ -1869,12 +1559,6 @@ func wasmimport_NewOutgoingResponse(headers0 uint32) (result0 uint32) // Body represents the imported method "body". // -// Returns the resource corresponding to the outgoing Body for this Response. -// -// Returns success on the first call: the `outgoing-body` resource for -// this `outgoing-response` can be retrieved at most once. Subsequent -// calls will return error. -// // body: func() -> result // //go:nosplit @@ -1890,15 +1574,6 @@ func wasmimport_OutgoingResponseBody(self0 uint32, result *cm.Result[OutgoingBod // Headers represents the imported method "headers". // -// Get the headers associated with the Request. -// -// The returned `headers` resource is immutable: `set`, `append`, and -// `delete` operations will fail with `header-error.immutable`. -// -// This headers resource is a child: it must be dropped before the parent -// `outgoing-request` is dropped, or its ownership is transfered to -// another component by e.g. `outgoing-handler.handle`. -// // headers: func() -> headers // //go:nosplit @@ -1915,9 +1590,6 @@ func wasmimport_OutgoingResponseHeaders(self0 uint32) (result0 uint32) // SetStatusCode represents the imported method "set-status-code". // -// Set the HTTP Status Code for the Response. Fails if the status-code -// given is not a valid http status code. -// // set-status-code: func(status-code: status-code) -> result // //go:nosplit @@ -1935,8 +1607,6 @@ func wasmimport_OutgoingResponseSetStatusCode(self0 uint32, statusCode0 uint32) // StatusCode represents the imported method "status-code". // -// Get the HTTP Status Code for the Response. -// // status-code: func() -> status-code // //go:nosplit @@ -1953,23 +1623,6 @@ func wasmimport_OutgoingResponseStatusCode(self0 uint32) (result0 uint32) // OutgoingBody represents the imported resource "wasi:http/types@0.2.0#outgoing-body". // -// Represents an outgoing HTTP Request or Response's Body. -// -// A body has both its contents - a stream of bytes - and a (possibly -// empty) set of trailers, inducating the full contents of the body -// have been sent. This resource represents the contents as an -// `output-stream` child resource, and the completion of the body (with -// optional trailers) with a static function that consumes the -// `outgoing-body` resource, and ensures that the user of this interface -// may not write to the body contents after the body has been finished. -// -// If the user code drops this resource, as opposed to calling the static -// method `finish`, the implementation should treat the body as incomplete, -// and that an error has occured. The implementation should propogate this -// error to the HTTP protocol by whatever means it has available, -// including: corrupting the body on the wire, aborting the associated -// Request, or sending a late status code for the Response. -// // resource outgoing-body type OutgoingBody cm.Resource @@ -1990,16 +1643,6 @@ func wasmimport_OutgoingBodyResourceDrop(self0 uint32) // OutgoingBodyFinish represents the imported static function "finish". // -// Finalize an outgoing body, optionally providing trailers. This must be -// called to signal that the response is complete. If the `outgoing-body` -// is dropped without calling `outgoing-body.finalize`, the implementation -// should treat the body as corrupted. -// -// Fails if the body's `outgoing-request` or `outgoing-response` was -// constructed with a Content-Length header, and the contents written -// to the body (via `write`) does not match the value given in the -// Content-Length. -// // finish: static func(this: outgoing-body, trailers: option) -> result<_, // error-code> // @@ -2017,16 +1660,6 @@ func wasmimport_OutgoingBodyFinish(this0 uint32, trailers0 uint32, trailers1 uin // Write represents the imported method "write". // -// Returns a stream for writing the body contents. -// -// The returned `output-stream` is a child resource: it must be dropped -// before the parent `outgoing-body` resource is dropped (or finished), -// otherwise the `outgoing-body` drop or `finish` will trap. -// -// Returns success on the first call: the `output-stream` resource for -// this `outgoing-body` may be retrieved at most once. Subsequent calls -// will return error. -// // write: func() -> result // //go:nosplit @@ -2042,12 +1675,6 @@ func wasmimport_OutgoingBodyWrite(self0 uint32, result *cm.Result[streams.Output // FutureIncomingResponse represents the imported resource "wasi:http/types@0.2.0#future-incoming-response". // -// Represents a future which may eventaully return an incoming HTTP -// Response, or an error. -// -// This resource is returned by the `wasi:http/outgoing-handler` interface to -// provide the HTTP Response corresponding to the sent Request. -// // resource future-incoming-response type FutureIncomingResponse cm.Resource @@ -2068,21 +1695,6 @@ func wasmimport_FutureIncomingResponseResourceDrop(self0 uint32) // Get represents the imported method "get". // -// Returns the incoming HTTP Response, or an error, once one is ready. -// -// The outer `option` represents future readiness. Users can wait on this -// `option` to become `some` using the `subscribe` method. -// -// The outer `result` is used to retrieve the response or error at most -// once. It will be success on the first call in which the outer option -// is `some`, and error on subsequent calls. -// -// The inner `result` represents that either the incoming HTTP Response -// status and headers have recieved successfully, or that an error -// occured. Errors may also occur while consuming the response body, -// but those will be reported by the `incoming-body` and its -// `output-stream` child. -// // get: func() -> option>> // //go:nosplit @@ -2098,10 +1710,6 @@ func wasmimport_FutureIncomingResponseGet(self0 uint32, result *cm.Option[cm.Res // Subscribe represents the imported method "subscribe". // -// Returns a pollable which becomes ready when either the Response has -// been received, or an error has occured. When this pollable is ready, -// the `get` method will return `some`. -// // subscribe: func() -> pollable // //go:nosplit @@ -2118,18 +1726,6 @@ func wasmimport_FutureIncomingResponseSubscribe(self0 uint32) (result0 uint32) // HTTPErrorCode represents the imported function "http-error-code". // -// Attempts to extract a http-related `error` from the wasi:io `error` -// provided. -// -// Stream operations which return -// `wasi:io/stream/stream-error::last-operation-failed` have a payload of -// type `wasi:io/error/error` with more information about the operation -// that failed. This payload can be passed through to this function to see -// if there's http-related information about the error to return. -// -// Note that this function is fallible because not all io-errors are -// http-related errors. -// // http-error-code: func(err: borrow) -> option // //go:nosplit diff --git a/_examples/invoke/gen/wasi/logging/logging/logging.wit.go b/_examples/invoke/gen/wasi/logging/logging/logging.wit.go index 15b6e95..0535dfa 100644 --- a/_examples/invoke/gen/wasi/logging/logging/logging.wit.go +++ b/_examples/invoke/gen/wasi/logging/logging/logging.wit.go @@ -1,18 +1,13 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. -// Package logging represents the imported interface "wasi:logging/logging". -// -// WASI Logging is a logging API intended to let users emit log messages with -// simple priority levels and context values. +// Package logging represents the imported interface "wasi:logging/logging@0.1.0-draft". package logging import ( "github.com/bytecodealliance/wasm-tools-go/cm" ) -// Level represents the enum "wasi:logging/logging#level". -// -// A log level, describing a kind of message. +// Level represents the enum "wasi:logging/logging@0.1.0-draft#level". // // enum level { // trace, @@ -25,25 +20,11 @@ import ( type Level uint8 const ( - // Describes messages about the values of variables and the flow of - // control within a program. LevelTrace Level = iota - - // Describes messages likely to be of interest to someone debugging a - // program. LevelDebug - - // Describes messages likely to be of interest to someone monitoring a - // program. LevelInfo - - // Describes messages indicating hazardous situations. LevelWarn - - // Describes messages indicating serious errors. LevelError - - // Describes messages indicating fatal errors. LevelCritical ) @@ -63,13 +44,6 @@ func (e Level) String() string { // Log represents the imported function "log". // -// Emit a log message. -// -// A log message has a `level` describing what kind of message is being -// sent, a context, which is an uninterpreted string meant to help -// consumers group similar messages, and a string containing the message -// text. -// // log: func(level: level, context: string, message: string) // //go:nosplit @@ -81,6 +55,6 @@ func Log(level Level, context string, message string) { return } -//go:wasmimport wasi:logging/logging log +//go:wasmimport wasi:logging/logging@0.1.0-draft log //go:noescape func wasmimport_Log(level0 uint32, context0 *uint8, context1 uint32, message0 *uint8, message1 uint32) diff --git a/_examples/invoke/gen/wasmcloud/bus/lattice/lattice.wit.go b/_examples/invoke/gen/wasmcloud/bus/lattice/lattice.wit.go index 9e04515..5239e79 100644 --- a/_examples/invoke/gen/wasmcloud/bus/lattice/lattice.wit.go +++ b/_examples/invoke/gen/wasmcloud/bus/lattice/lattice.wit.go @@ -9,8 +9,6 @@ import ( // CallTargetInterface represents the imported resource "wasmcloud:bus/lattice@1.0.0#call-target-interface". // -// Interface target. This represents an interface, which can be selected by `set-link-name`. -// // resource call-target-interface type CallTargetInterface cm.Resource @@ -49,12 +47,6 @@ func wasmimport_NewCallTargetInterface(namespace0 *uint8, namespace1 uint32, pac // SetLinkName represents the imported function "set-link-name". // -// Set an optional link name to use for all interfaces specified. This is advanced -// functionality only available within wasmcloud and, as such, is exposed here as -// part of the -// wasmcloud:bus package. This is used when you are linking multiple of the same interfaces -// (i.e. a keyvalue implementation for caching and another one for secrets) to a component -// // set-link-name: func(name: string, interfaces: list) // //go:nosplit diff --git a/_examples/invoke/gen/wasmcloud/messaging/consumer/abi.go b/_examples/invoke/gen/wasmcloud/messaging/consumer/abi.go deleted file mode 100644 index 1bd06fe..0000000 --- a/_examples/invoke/gen/wasmcloud/messaging/consumer/abi.go +++ /dev/null @@ -1,32 +0,0 @@ -// Code generated by wit-bindgen-go. DO NOT EDIT. - -package consumer - -import ( - "github.com/bytecodealliance/wasm-tools-go/cm" - "github.com/wasmCloud/component-sdk-go/_examples/invoke/gen/wasmcloud/messaging/types" - "unsafe" -) - -// BrokerMessageShape is used for storage in variant or result types. -type BrokerMessageShape struct { - shape [unsafe.Sizeof(types.BrokerMessage{})]byte -} - -func lower_OptionString(v cm.Option[string]) (f0 uint32, f1 *uint8, f2 uint32) { - some := v.Some() - if some != nil { - f0 = 1 - v1, v2 := cm.LowerString(*some) - f1 = (*uint8)(v1) - f2 = (uint32)(v2) - } - return -} - -func lower_BrokerMessage(v types.BrokerMessage) (f0 *uint8, f1 uint32, f2 *uint8, f3 uint32, f4 uint32, f5 *uint8, f6 uint32) { - f0, f1 = cm.LowerString(v.Subject) - f2, f3 = cm.LowerList(v.Body) - f4, f5, f6 = lower_OptionString(v.ReplyTo) - return -} diff --git a/_examples/invoke/gen/wasmcloud/messaging/consumer/consumer.wit.go b/_examples/invoke/gen/wasmcloud/messaging/consumer/consumer.wit.go deleted file mode 100644 index 83e798a..0000000 --- a/_examples/invoke/gen/wasmcloud/messaging/consumer/consumer.wit.go +++ /dev/null @@ -1,46 +0,0 @@ -// Code generated by wit-bindgen-go. DO NOT EDIT. - -// Package consumer represents the imported interface "wasmcloud:messaging/consumer@0.2.0". -package consumer - -import ( - "github.com/bytecodealliance/wasm-tools-go/cm" - "github.com/wasmCloud/component-sdk-go/_examples/invoke/gen/wasmcloud/messaging/types" -) - -// Request represents the imported function "request". -// -// Perform a request operation on a subject -// -// request: func(subject: string, body: list, timeout-ms: u32) -> result -// -//go:nosplit -func Request(subject string, body cm.List[uint8], timeoutMs uint32) (result cm.Result[BrokerMessageShape, types.BrokerMessage, string]) { - subject0, subject1 := cm.LowerString(subject) - body0, body1 := cm.LowerList(body) - timeoutMs0 := (uint32)(timeoutMs) - wasmimport_Request((*uint8)(subject0), (uint32)(subject1), (*uint8)(body0), (uint32)(body1), (uint32)(timeoutMs0), &result) - return -} - -//go:wasmimport wasmcloud:messaging/consumer@0.2.0 request -//go:noescape -func wasmimport_Request(subject0 *uint8, subject1 uint32, body0 *uint8, body1 uint32, timeoutMs0 uint32, result *cm.Result[BrokerMessageShape, types.BrokerMessage, string]) - -// Publish represents the imported function "publish". -// -// Publish a message to a subject without awaiting a response -// -// publish: func(msg: broker-message) -> result<_, string> -// -//go:nosplit -func Publish(msg types.BrokerMessage) (result cm.Result[string, struct{}, string]) { - msg0, msg1, msg2, msg3, msg4, msg5, msg6 := lower_BrokerMessage(msg) - wasmimport_Publish((*uint8)(msg0), (uint32)(msg1), (*uint8)(msg2), (uint32)(msg3), (uint32)(msg4), (*uint8)(msg5), (uint32)(msg6), &result) - return -} - -//go:wasmimport wasmcloud:messaging/consumer@0.2.0 publish -//go:noescape -func wasmimport_Publish(msg0 *uint8, msg1 uint32, msg2 *uint8, msg3 uint32, msg4 uint32, msg5 *uint8, msg6 uint32, result *cm.Result[string, struct{}, string]) diff --git a/_examples/invoke/gen/wasmcloud/messaging/consumer/empty.s b/_examples/invoke/gen/wasmcloud/messaging/consumer/empty.s deleted file mode 100644 index 5444f20..0000000 --- a/_examples/invoke/gen/wasmcloud/messaging/consumer/empty.s +++ /dev/null @@ -1,3 +0,0 @@ -// This file exists for testing this package without WebAssembly, -// allowing empty function bodies with a //go:wasmimport directive. -// See https://pkg.go.dev/cmd/compile for more information. diff --git a/_examples/invoke/gen/wasmcloud/messaging/types/types.wit.go b/_examples/invoke/gen/wasmcloud/messaging/types/types.wit.go deleted file mode 100644 index 6fbc9e9..0000000 --- a/_examples/invoke/gen/wasmcloud/messaging/types/types.wit.go +++ /dev/null @@ -1,25 +0,0 @@ -// Code generated by wit-bindgen-go. DO NOT EDIT. - -// Package types represents the imported interface "wasmcloud:messaging/types@0.2.0". -// -// Types common to message broker interactions -package types - -import ( - "github.com/bytecodealliance/wasm-tools-go/cm" -) - -// BrokerMessage represents the record "wasmcloud:messaging/types@0.2.0#broker-message". -// -// A message sent to or received from a broker -// -// record broker-message { -// subject: string, -// body: list, -// reply-to: option, -// } -type BrokerMessage struct { - Subject string - Body cm.List[uint8] - ReplyTo cm.Option[string] -} diff --git a/_examples/invoke/gen/wasmcloud/secrets/reveal/reveal.wit.go b/_examples/invoke/gen/wasmcloud/secrets/reveal/reveal.wit.go index 1c33cb2..150a62d 100644 --- a/_examples/invoke/gen/wasmcloud/secrets/reveal/reveal.wit.go +++ b/_examples/invoke/gen/wasmcloud/secrets/reveal/reveal.wit.go @@ -10,9 +10,6 @@ import ( // Reveal represents the imported function "reveal". // -// Reveals the value of a secret to the caller. -// This lets you easily audit your code to discover where secrets are being used. -// // reveal: func(s: borrow) -> secret-value // //go:nosplit diff --git a/_examples/invoke/gen/wasmcloud/secrets/store/store.wit.go b/_examples/invoke/gen/wasmcloud/secrets/store/store.wit.go index 09dbab5..57ddee2 100644 --- a/_examples/invoke/gen/wasmcloud/secrets/store/store.wit.go +++ b/_examples/invoke/gen/wasmcloud/secrets/store/store.wit.go @@ -9,8 +9,6 @@ import ( // SecretsError represents the variant "wasmcloud:secrets/store@0.1.0-draft#secrets-error". // -// An error type that encapsulates the different errors that can occur fetching secrets -// // variant secrets-error { // upstream(string), // io(string), @@ -19,11 +17,6 @@ import ( type SecretsError cm.Variant[uint8, string, string] // SecretsErrorUpstream returns a [SecretsError] of case "upstream". -// -// This indicates an error from an "upstream" secrets source. -// As this could be almost _anything_ (such as Vault, Kubernetes Secrets, KeyValue -// buckets, etc), -// the error message is a string. func SecretsErrorUpstream(data string) SecretsError { return cm.New[SecretsError](0, data) } @@ -34,14 +27,6 @@ func (self *SecretsError) Upstream() *string { } // SecretsErrorIO returns a [SecretsError] of case "io". -// -// This indicates an error from an I/O operation. -// As this could be almost _anything_ (such as a file read, network connection, etc), -// the error message is a string. -// Depending on how this ends up being consumed, -// we may consider moving this to use the `wasi:io/error` type instead. -// For simplicity right now in supporting multiple implementations, it is being left -// as a string. func SecretsErrorIO(data string) SecretsError { return cm.New[SecretsError](1, data) } @@ -52,10 +37,6 @@ func (self *SecretsError) IO() *string { } // SecretsErrorNotFound returns a [SecretsError] of case "not-found". -// -// This indicates that the secret was not found. Generally "not found" errors will -// be handled by the upstream secrets backend, but there are cases where the host -// may need to return this error. func SecretsErrorNotFound() SecretsError { var data struct{} return cm.New[SecretsError](2, data) @@ -68,9 +49,6 @@ func (self *SecretsError) NotFound() bool { // SecretValue represents the variant "wasmcloud:secrets/store@0.1.0-draft#secret-value". // -// A secret value can be either a string or a byte array, which lets you -// store binary data as a secret. -// // variant secret-value { // %string(string), // bytes(list), @@ -78,8 +56,6 @@ func (self *SecretsError) NotFound() bool { type SecretValue cm.Variant[uint8, string, cm.List[uint8]] // SecretValueString returns a [SecretValue] of case "string". -// -// A string value func SecretValueString(data string) SecretValue { return cm.New[SecretValue](0, data) } @@ -90,8 +66,6 @@ func (self *SecretValue) String() *string { } // SecretValueBytes returns a [SecretValue] of case "bytes". -// -// A byte array value func SecretValueBytes(data cm.List[uint8]) SecretValue { return cm.New[SecretValue](1, data) } @@ -103,11 +77,6 @@ func (self *SecretValue) Bytes() *cm.List[uint8] { // Secret represents the imported resource "wasmcloud:secrets/store@0.1.0-draft#secret". // -// A secret is a resource that can only be borrowed. This allows you to -// pass around handles to secrets and not reveal the values until a -// component needs them. -// You need to use the reveal interface to get the value. -// // resource secret type Secret cm.Resource @@ -128,8 +97,6 @@ func wasmimport_SecretResourceDrop(self0 uint32) // Get represents the imported function "get". // -// Gets a single opaque secrets value set at the given key if it exists -// // get: func(key: string) -> result // //go:nosplit diff --git a/_examples/invoke/wadge_bindings_test.go b/_examples/invoke/wadge_bindings_test.go index 566930d..a8bdfcf 100644 --- a/_examples/invoke/wadge_bindings_test.go +++ b/_examples/invoke/wadge_bindings_test.go @@ -17,7 +17,7 @@ func wasmimport_Log(level0 uint32, context0 *uint8, context1 uint32, message0 *u var __p runtime.Pinner defer __p.Unpin() if __err := wadge.WithCurrentInstance(func(__instance *wadge.Instance) error { - return __instance.Call("wasi:logging/logging", "log", func() unsafe.Pointer { + return __instance.Call("wasi:logging/logging@0.1.0-draft", "log", func() unsafe.Pointer { ptr := unsafe.Pointer(&level0) __p.Pin(ptr) return ptr diff --git a/_examples/invoke/wasmcloud.toml b/_examples/invoke/wasmcloud.toml index 47baf15..05e875d 100644 --- a/_examples/invoke/wasmcloud.toml +++ b/_examples/invoke/wasmcloud.toml @@ -1,9 +1,10 @@ name = "invoke" -language = "tinygo" +language = "other" type = "component" version = "0.1.0" [component] +build_command = "tinygo build -target=wasip2 --wit-package ./wit --wit-world example -o build/invoke.wasm main.go" wit_world = "example" wasm_target = "wasm32-wasi-preview2" destination = "build/invoke_s.wasm" diff --git a/_examples/invoke/wit/deps.lock b/_examples/invoke/wit/deps.lock deleted file mode 100644 index 22c6b1d..0000000 --- a/_examples/invoke/wit/deps.lock +++ /dev/null @@ -1,49 +0,0 @@ -["wasi-cli-0.2.0"] -sha256 = "13b041ec2314d48107929c335df3ca81b1bb0a35bfec38e206a59162a4c209cd" -sha512 = "725886b3244f4894a1121cd66e1bea0775964ca1b3811be3ae43a4c692cb7d5f27d851072637b8ec64bd5e71e85bb5e860f8331fe8f77353d9d7868ce1d72a8e" - -["wasi-clocks-0.2.0"] -sha256 = "daf7133b4f60ba73185449327dd48d2b324799db858ab463bcd32d954a9ff394" -sha512 = "5992296c504aebfad359ab1676bba63b5d22e33112c240a437ee733433aa50552144242f8998180ff36f0da56e5f65691dbb1898331ce878bd9fa439b8909742" - -["wasi-config-0.2.0-draft"] -sha256 = "5c6b4a10b21fbab2397d579c6f8bf8a484160dfdf20b6343080b0bad097849a3" -sha512 = "d3cf5fd1d12590aefd561330337870e2e468c84753c11e19bccd165c916a696722cc29af3572984e6256088b6e683763675d5b8cec3d195f9e2961fe405629b8" - -["wasi-filesystem-0.2.0"] -sha256 = "739d4fc43cd51421382e5d1a0cf643a2985691d480ae75600cdcd382665b3e55" -sha512 = "67f61ef46833060cc4d7a258da7a82024830762c4ecfd522d32bdc5e6bf4df26043f9a8c13ea38b191df180176826aa7b163816618a939015efff5987557dc16" - -["wasi-http-0.2.0"] -sha256 = "f22b6f3b3c12289e522041067b0a2db99a27c181e9ef3ed36930aa0286232d63" -sha512 = "f9b38ef4f58cb9e069b51ee45df52ce6ca9af0a9774c3d09dc99598f36afcd902557221be2f1a6bcccdecb880e4d7436b533e03f4b9250d5b0e1466afd3a62ce" - -["wasi-io-0.2.0"] -sha256 = "0bc0cc0d474a5c4f3c2e2092664c4e235a0390e5d206d3bdc4007488d9d5e00f" -sha512 = "497f37742a94ca32eaa77dce5d9144682e743b30c2d702d37726d43735a25fa9d421afbf5945da158c0e46a0adf941f607b0e0f5d26494af52f021265f78329c" - -["wasi-logging-0.1.0-draft"] -sha256 = "619c4d2336045bab9129e5af568decd5e963006291d496a23cddf796f3a61c2e" -sha512 = "c163aa6f4e566cb85d373f25e590e552fc2530fdf50946c38d305e9f2cd189d86ff8540d163e42acd2cebbe3cef98967cd1efb14ce196da132fcf6caf4f6155d" - -["wasi-random-0.2.0"] -sha256 = "efcdf344435591830f5fbed67a2c215bba112893518a8ef4c7234a4796b8dbcd" -sha512 = "c78a10e9b6401116eac703430609a849854a27a4ff3bc7737d514536a9c16a2fc206a35f8f96b7c40f254d6a66e6873361970754fa69b856025886cd462a2832" - -["wasi-sockets-0.2.0"] -sha256 = "aa3c13fee8c788c95de5a917a54d776d5adb2afd90a77224864941ce27c5d471" -sha512 = "4e3be65dd127ccd4bfa1af8f86fea556d6e22d25e4b637f9b9ebf66ae1f6331f904edff042adc9be16fec511e3295170e6c13516715d2cd3e5aaffbd96158fa9" - -["wasmcloud-bus-1.0.0"] -sha256 = "f823b5c8293cb585092107120139c34c405f57362761a133d543f5d68c65d591" -sha512 = "12e6aa4eac6139b60ea72cc7b6ded6ac9b144b15557be9f2329b6e84b5a161d8f6344674afd0526a883cb61e34c06fee9dbadbaee1d783cd957bc43dab4bfc2d" - -[wasmcloud-component-go] -path = "../../../wit" -sha256 = "995bd9ad8d0523f04480196b6746da80ddc5daf2e3be6b126c224d1fe9bda103" -sha512 = "e5af5fbb4242fc151d83ce86fa05d54274eb33a42b8856453659a1191d5142cd3792c914df8db330a9f692089974bbd1e6d3695142a8e5416d10b5b856839ce9" -deps = ["wasi-cli-0.2.0", "wasi-clocks-0.2.0", "wasi-config-0.2.0-draft", "wasi-filesystem-0.2.0", "wasi-http-0.2.0", "wasi-io-0.2.0", "wasi-logging-0.1.0-draft", "wasi-random-0.2.0", "wasi-sockets-0.2.0", "wasmcloud-bus-1.0.0", "wasmcloud-secrets-0.1.0-draft"] - -["wasmcloud-secrets-0.1.0-draft"] -sha256 = "8e0ec182ea30a420744887cdb42660bf703194eaf8ecf2f0dc0efc4159247ea4" -sha512 = "f0037028e47d307b1551068fcdb9249a0a1cd3d7d1e8d99f33713ec1ee22bc5242fe63155a9f7aaa0492640df2c79ea40ed0839e2add222c069787b59c09f1b3" diff --git a/_examples/invoke/wit/deps.toml b/_examples/invoke/wit/deps.toml deleted file mode 100644 index 4d1db6f..0000000 --- a/_examples/invoke/wit/deps.toml +++ /dev/null @@ -1 +0,0 @@ -wasmcloud-component-go = "../../../wit" diff --git a/_examples/invoke/wit/deps/wasi-cli-0.2.0/package.wit b/_examples/invoke/wit/deps/wasi-cli-0.2.0/package.wit index 0a2737b..20147d0 100644 --- a/_examples/invoke/wit/deps/wasi-cli-0.2.0/package.wit +++ b/_examples/invoke/wit/deps/wasi-cli-0.2.0/package.wit @@ -1,34 +1,17 @@ package wasi:cli@0.2.0; interface environment { - /// Get the POSIX-style environment variables. - /// - /// Each environment variable is provided as a pair of string variable names - /// and string value. - /// - /// Morally, these are a value import, but until value imports are available - /// in the component model, this import function should return the same - /// values each time it is called. get-environment: func() -> list>; - /// Get the POSIX-style arguments to the program. get-arguments: func() -> list; - /// Return a path that programs should use as their initial current working - /// directory, interpreting `.` as shorthand for this. initial-cwd: func() -> option; } interface exit { - /// Exit the current instance and any linked instances. exit: func(status: result); } -interface run { - /// Run the program. - run: func() -> result; -} - interface stdin { use wasi:io/streams@0.2.0.{input-stream}; @@ -47,113 +30,29 @@ interface stderr { get-stderr: func() -> output-stream; } -/// Terminal input. -/// -/// In the future, this may include functions for disabling echoing, -/// disabling input buffering so that keyboard events are sent through -/// immediately, querying supported features, and so on. interface terminal-input { - /// The input side of a terminal. resource terminal-input; } -/// Terminal output. -/// -/// In the future, this may include functions for querying the terminal -/// size, being notified of terminal size changes, querying supported -/// features, and so on. interface terminal-output { - /// The output side of a terminal. resource terminal-output; } -/// An interface providing an optional `terminal-input` for stdin as a -/// link-time authority. interface terminal-stdin { use terminal-input.{terminal-input}; - /// If stdin is connected to a terminal, return a `terminal-input` handle - /// allowing further interaction with it. get-terminal-stdin: func() -> option; } -/// An interface providing an optional `terminal-output` for stdout as a -/// link-time authority. interface terminal-stdout { use terminal-output.{terminal-output}; - /// If stdout is connected to a terminal, return a `terminal-output` handle - /// allowing further interaction with it. get-terminal-stdout: func() -> option; } -/// An interface providing an optional `terminal-output` for stderr as a -/// link-time authority. interface terminal-stderr { use terminal-output.{terminal-output}; - /// If stderr is connected to a terminal, return a `terminal-output` handle - /// allowing further interaction with it. get-terminal-stderr: func() -> option; } -world imports { - import environment; - import exit; - import wasi:io/error@0.2.0; - import wasi:io/poll@0.2.0; - import wasi:io/streams@0.2.0; - import stdin; - import stdout; - import stderr; - import terminal-input; - import terminal-output; - import terminal-stdin; - import terminal-stdout; - import terminal-stderr; - import wasi:clocks/monotonic-clock@0.2.0; - import wasi:clocks/wall-clock@0.2.0; - import wasi:filesystem/types@0.2.0; - import wasi:filesystem/preopens@0.2.0; - import wasi:sockets/network@0.2.0; - import wasi:sockets/instance-network@0.2.0; - import wasi:sockets/udp@0.2.0; - import wasi:sockets/udp-create-socket@0.2.0; - import wasi:sockets/tcp@0.2.0; - import wasi:sockets/tcp-create-socket@0.2.0; - import wasi:sockets/ip-name-lookup@0.2.0; - import wasi:random/random@0.2.0; - import wasi:random/insecure@0.2.0; - import wasi:random/insecure-seed@0.2.0; -} -world command { - import environment; - import exit; - import wasi:io/error@0.2.0; - import wasi:io/poll@0.2.0; - import wasi:io/streams@0.2.0; - import stdin; - import stdout; - import stderr; - import terminal-input; - import terminal-output; - import terminal-stdin; - import terminal-stdout; - import terminal-stderr; - import wasi:clocks/monotonic-clock@0.2.0; - import wasi:clocks/wall-clock@0.2.0; - import wasi:filesystem/types@0.2.0; - import wasi:filesystem/preopens@0.2.0; - import wasi:sockets/network@0.2.0; - import wasi:sockets/instance-network@0.2.0; - import wasi:sockets/udp@0.2.0; - import wasi:sockets/udp-create-socket@0.2.0; - import wasi:sockets/tcp@0.2.0; - import wasi:sockets/tcp-create-socket@0.2.0; - import wasi:sockets/ip-name-lookup@0.2.0; - import wasi:random/random@0.2.0; - import wasi:random/insecure@0.2.0; - import wasi:random/insecure-seed@0.2.0; - - export run; -} diff --git a/_examples/invoke/wit/deps/wasi-config-0.2.0-draft/package.wit b/_examples/invoke/wit/deps/wasi-config-0.2.0-draft/package.wit index 7065b9b..d514554 100644 --- a/_examples/invoke/wit/deps/wasi-config-0.2.0-draft/package.wit +++ b/_examples/invoke/wit/deps/wasi-config-0.2.0-draft/package.wit @@ -1,28 +1,13 @@ package wasi:config@0.2.0-draft; interface runtime { - /// An error type that encapsulates the different errors that can occur fetching config variant config-error { - /// This indicates an error from an "upstream" config source. - /// As this could be almost _anything_ (such as Vault, Kubernetes ConfigMaps, KeyValue buckets, etc), - /// the error message is a string. upstream(string), - /// This indicates an error from an I/O operation. - /// As this could be almost _anything_ (such as a file read, network connection, etc), - /// the error message is a string. - /// Depending on how this ends up being consumed, - /// we may consider moving this to use the `wasi:io/error` type instead. - /// For simplicity right now in supporting multiple implementations, it is being left as a string. io(string), } - /// Gets a single opaque config value set at the given key if it exists get: func(key: string) -> result, config-error>; - /// Gets a list of all set config data get-all: func() -> result>, config-error>; } -world imports { - import runtime; -} diff --git a/_examples/invoke/wit/deps/wasi-http-0.2.0/package.wit b/_examples/invoke/wit/deps/wasi-http-0.2.0/package.wit index 11f7ff4..63031a8 100644 --- a/_examples/invoke/wit/deps/wasi-http-0.2.0/package.wit +++ b/_examples/invoke/wit/deps/wasi-http-0.2.0/package.wit @@ -1,15 +1,11 @@ package wasi:http@0.2.0; -/// This interface defines all of the types and methods for implementing -/// HTTP Requests and Responses, both incoming and outgoing, as well as -/// their headers, trailers, and bodies. interface types { use wasi:clocks/monotonic-clock@0.2.0.{duration}; use wasi:io/streams@0.2.0.{input-stream, output-stream}; use wasi:io/error@0.2.0.{error as io-error}; use wasi:io/poll@0.2.0.{pollable}; - /// This type corresponds to HTTP standard Methods. variant method { get, head, @@ -23,33 +19,27 @@ interface types { other(string), } - /// This type corresponds to HTTP standard Related Schemes. variant scheme { HTTP, HTTPS, other(string), } - /// Defines the case payload type for `DNS-error` above: record DNS-error-payload { rcode: option, info-code: option, } - /// Defines the case payload type for `TLS-alert-received` above: record TLS-alert-received-payload { alert-id: option, alert-message: option, } - /// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: record field-size-payload { field-name: option, field-size: option, } - /// These cases are inspired by the IANA HTTP Proxy Error Types: - /// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types variant error-code { DNS-timeout, DNS-error(DNS-error-payload), @@ -89,483 +79,120 @@ interface types { HTTP-protocol-error, loop-detected, configuration-error, - /// This is a catch-all error for anything that doesn't fit cleanly into a - /// more specific case. It also includes an optional string for an - /// unstructured description of the error. Users should not depend on the - /// string for diagnosing errors, as it's not required to be consistent - /// between implementations. internal-error(option), } - /// This type enumerates the different kinds of errors that may occur when - /// setting or appending to a `fields` resource. variant header-error { - /// This error indicates that a `field-key` or `field-value` was - /// syntactically invalid when used with an operation that sets headers in a - /// `fields`. invalid-syntax, - /// This error indicates that a forbidden `field-key` was used when trying - /// to set a header in a `fields`. forbidden, - /// This error indicates that the operation on the `fields` was not - /// permitted because the fields are immutable. immutable, } - /// Field keys are always strings. type field-key = string; - /// Field values should always be ASCII strings. However, in - /// reality, HTTP implementations often have to interpret malformed values, - /// so they are provided as a list of bytes. type field-value = list; - /// This following block defines the `fields` resource which corresponds to - /// HTTP standard Fields. Fields are a common representation used for both - /// Headers and Trailers. - /// - /// A `fields` may be mutable or immutable. A `fields` created using the - /// constructor, `from-list`, or `clone` will be mutable, but a `fields` - /// resource given by other means (including, but not limited to, - /// `incoming-request.headers`, `outgoing-request.headers`) might be be - /// immutable. In an immutable fields, the `set`, `append`, and `delete` - /// operations will fail with `header-error.immutable`. resource fields { - /// Construct an empty HTTP Fields. - /// - /// The resulting `fields` is mutable. constructor(); - /// Construct an HTTP Fields. - /// - /// The resulting `fields` is mutable. - /// - /// The list represents each key-value pair in the Fields. Keys - /// which have multiple values are represented by multiple entries in this - /// list with the same key. - /// - /// The tuple is a pair of the field key, represented as a string, and - /// Value, represented as a list of bytes. In a valid Fields, all keys - /// and values are valid UTF-8 strings. However, values are not always - /// well-formed, so they are represented as a raw list of bytes. - /// - /// An error result will be returned if any header or value was - /// syntactically invalid, or if a header was forbidden. from-list: static func(entries: list>) -> result; - /// Get all of the values corresponding to a key. If the key is not present - /// in this `fields`, an empty list is returned. However, if the key is - /// present but empty, this is represented by a list with one or more - /// empty field-values present. get: func(name: field-key) -> list; - /// Returns `true` when the key is present in this `fields`. If the key is - /// syntactically invalid, `false` is returned. has: func(name: field-key) -> bool; - /// Set all of the values for a key. Clears any existing values for that - /// key, if they have been set. - /// - /// Fails with `header-error.immutable` if the `fields` are immutable. set: func(name: field-key, value: list) -> result<_, header-error>; - /// Delete all values for a key. Does nothing if no values for the key - /// exist. - /// - /// Fails with `header-error.immutable` if the `fields` are immutable. delete: func(name: field-key) -> result<_, header-error>; - /// Append a value for a key. Does not change or delete any existing - /// values for that key. - /// - /// Fails with `header-error.immutable` if the `fields` are immutable. append: func(name: field-key, value: field-value) -> result<_, header-error>; - /// Retrieve the full set of keys and values in the Fields. Like the - /// constructor, the list represents each key-value pair. - /// - /// The outer list represents each key-value pair in the Fields. Keys - /// which have multiple values are represented by multiple entries in this - /// list with the same key. entries: func() -> list>; - /// Make a deep copy of the Fields. Equivelant in behavior to calling the - /// `fields` constructor on the return value of `entries`. The resulting - /// `fields` is mutable. clone: func() -> fields; } - /// Headers is an alias for Fields. type headers = fields; - /// Trailers is an alias for Fields. type trailers = fields; - /// Represents an incoming HTTP Request. resource incoming-request { - /// Returns the method of the incoming request. method: func() -> method; - /// Returns the path with query parameters from the request, as a string. path-with-query: func() -> option; - /// Returns the protocol scheme from the request. scheme: func() -> option; - /// Returns the authority from the request, if it was present. authority: func() -> option; - /// Get the `headers` associated with the request. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// The `headers` returned are a child resource: it must be dropped before - /// the parent `incoming-request` is dropped. Dropping this - /// `incoming-request` before all children are dropped will trap. headers: func() -> headers; - /// Gives the `incoming-body` associated with this request. Will only - /// return success at most once, and subsequent calls will return error. consume: func() -> result; } - /// Represents an outgoing HTTP Request. resource outgoing-request { - /// Construct a new `outgoing-request` with a default `method` of `GET`, and - /// `none` values for `path-with-query`, `scheme`, and `authority`. - /// - /// * `headers` is the HTTP Headers for the Request. - /// - /// It is possible to construct, or manipulate with the accessor functions - /// below, an `outgoing-request` with an invalid combination of `scheme` - /// and `authority`, or `headers` which are not permitted to be sent. - /// It is the obligation of the `outgoing-handler.handle` implementation - /// to reject invalid constructions of `outgoing-request`. constructor(headers: headers); - /// Returns the resource corresponding to the outgoing Body for this - /// Request. - /// - /// Returns success on the first call: the `outgoing-body` resource for - /// this `outgoing-request` can be retrieved at most once. Subsequent - /// calls will return error. body: func() -> result; - /// Get the Method for the Request. method: func() -> method; - /// Set the Method for the Request. Fails if the string present in a - /// `method.other` argument is not a syntactically valid method. set-method: func(method: method) -> result; - /// Get the combination of the HTTP Path and Query for the Request. - /// When `none`, this represents an empty Path and empty Query. path-with-query: func() -> option; - /// Set the combination of the HTTP Path and Query for the Request. - /// When `none`, this represents an empty Path and empty Query. Fails is the - /// string given is not a syntactically valid path and query uri component. set-path-with-query: func(path-with-query: option) -> result; - /// Get the HTTP Related Scheme for the Request. When `none`, the - /// implementation may choose an appropriate default scheme. scheme: func() -> option; - /// Set the HTTP Related Scheme for the Request. When `none`, the - /// implementation may choose an appropriate default scheme. Fails if the - /// string given is not a syntactically valid uri scheme. set-scheme: func(scheme: option) -> result; - /// Get the HTTP Authority for the Request. A value of `none` may be used - /// with Related Schemes which do not require an Authority. The HTTP and - /// HTTPS schemes always require an authority. authority: func() -> option; - /// Set the HTTP Authority for the Request. A value of `none` may be used - /// with Related Schemes which do not require an Authority. The HTTP and - /// HTTPS schemes always require an authority. Fails if the string given is - /// not a syntactically valid uri authority. set-authority: func(authority: option) -> result; - /// Get the headers associated with the Request. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// This headers resource is a child: it must be dropped before the parent - /// `outgoing-request` is dropped, or its ownership is transfered to - /// another component by e.g. `outgoing-handler.handle`. headers: func() -> headers; } - /// Parameters for making an HTTP Request. Each of these parameters is - /// currently an optional timeout applicable to the transport layer of the - /// HTTP protocol. - /// - /// These timeouts are separate from any the user may use to bound a - /// blocking call to `wasi:io/poll.poll`. resource request-options { - /// Construct a default `request-options` value. constructor(); - /// The timeout for the initial connect to the HTTP Server. connect-timeout: func() -> option; - /// Set the timeout for the initial connect to the HTTP Server. An error - /// return value indicates that this timeout is not supported. set-connect-timeout: func(duration: option) -> result; - /// The timeout for receiving the first byte of the Response body. first-byte-timeout: func() -> option; - /// Set the timeout for receiving the first byte of the Response body. An - /// error return value indicates that this timeout is not supported. set-first-byte-timeout: func(duration: option) -> result; - /// The timeout for receiving subsequent chunks of bytes in the Response - /// body stream. between-bytes-timeout: func() -> option; - /// Set the timeout for receiving subsequent chunks of bytes in the Response - /// body stream. An error return value indicates that this timeout is not - /// supported. set-between-bytes-timeout: func(duration: option) -> result; } - /// Represents the ability to send an HTTP Response. - /// - /// This resource is used by the `wasi:http/incoming-handler` interface to - /// allow a Response to be sent corresponding to the Request provided as the - /// other argument to `incoming-handler.handle`. resource response-outparam { - /// Set the value of the `response-outparam` to either send a response, - /// or indicate an error. - /// - /// This method consumes the `response-outparam` to ensure that it is - /// called at most once. If it is never called, the implementation - /// will respond with an error. - /// - /// The user may provide an `error` to `response` to allow the - /// implementation determine how to respond with an HTTP error response. set: static func(param: response-outparam, response: result); } - /// This type corresponds to the HTTP standard Status Code. type status-code = u16; - /// Represents an incoming HTTP Response. resource incoming-response { - /// Returns the status code from the incoming response. status: func() -> status-code; - /// Returns the headers from the incoming response. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// This headers resource is a child: it must be dropped before the parent - /// `incoming-response` is dropped. headers: func() -> headers; - /// Returns the incoming body. May be called at most once. Returns error - /// if called additional times. consume: func() -> result; } - /// Represents an incoming HTTP Request or Response's Body. - /// - /// A body has both its contents - a stream of bytes - and a (possibly - /// empty) set of trailers, indicating that the full contents of the - /// body have been received. This resource represents the contents as - /// an `input-stream` and the delivery of trailers as a `future-trailers`, - /// and ensures that the user of this interface may only be consuming either - /// the body contents or waiting on trailers at any given time. resource incoming-body { - /// Returns the contents of the body, as a stream of bytes. - /// - /// Returns success on first call: the stream representing the contents - /// can be retrieved at most once. Subsequent calls will return error. - /// - /// The returned `input-stream` resource is a child: it must be dropped - /// before the parent `incoming-body` is dropped, or consumed by - /// `incoming-body.finish`. - /// - /// This invariant ensures that the implementation can determine whether - /// the user is consuming the contents of the body, waiting on the - /// `future-trailers` to be ready, or neither. This allows for network - /// backpressure is to be applied when the user is consuming the body, - /// and for that backpressure to not inhibit delivery of the trailers if - /// the user does not read the entire body. %stream: func() -> result; - /// Takes ownership of `incoming-body`, and returns a `future-trailers`. - /// This function will trap if the `input-stream` child is still alive. finish: static func(this: incoming-body) -> future-trailers; } - /// Represents a future which may eventaully return trailers, or an error. - /// - /// In the case that the incoming HTTP Request or Response did not have any - /// trailers, this future will resolve to the empty set of trailers once the - /// complete Request or Response body has been received. resource future-trailers { - /// Returns a pollable which becomes ready when either the trailers have - /// been received, or an error has occured. When this pollable is ready, - /// the `get` method will return `some`. subscribe: func() -> pollable; - /// Returns the contents of the trailers, or an error which occured, - /// once the future is ready. - /// - /// The outer `option` represents future readiness. Users can wait on this - /// `option` to become `some` using the `subscribe` method. - /// - /// The outer `result` is used to retrieve the trailers or error at most - /// once. It will be success on the first call in which the outer option - /// is `some`, and error on subsequent calls. - /// - /// The inner `result` represents that either the HTTP Request or Response - /// body, as well as any trailers, were received successfully, or that an - /// error occured receiving them. The optional `trailers` indicates whether - /// or not trailers were present in the body. - /// - /// When some `trailers` are returned by this method, the `trailers` - /// resource is immutable, and a child. Use of the `set`, `append`, or - /// `delete` methods will return an error, and the resource must be - /// dropped before the parent `future-trailers` is dropped. get: func() -> option, error-code>>>; } - /// Represents an outgoing HTTP Response. resource outgoing-response { - /// Construct an `outgoing-response`, with a default `status-code` of `200`. - /// If a different `status-code` is needed, it must be set via the - /// `set-status-code` method. - /// - /// * `headers` is the HTTP Headers for the Response. constructor(headers: headers); - /// Get the HTTP Status Code for the Response. status-code: func() -> status-code; - /// Set the HTTP Status Code for the Response. Fails if the status-code - /// given is not a valid http status code. set-status-code: func(status-code: status-code) -> result; - /// Get the headers associated with the Request. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// This headers resource is a child: it must be dropped before the parent - /// `outgoing-request` is dropped, or its ownership is transfered to - /// another component by e.g. `outgoing-handler.handle`. headers: func() -> headers; - /// Returns the resource corresponding to the outgoing Body for this Response. - /// - /// Returns success on the first call: the `outgoing-body` resource for - /// this `outgoing-response` can be retrieved at most once. Subsequent - /// calls will return error. body: func() -> result; } - /// Represents an outgoing HTTP Request or Response's Body. - /// - /// A body has both its contents - a stream of bytes - and a (possibly - /// empty) set of trailers, inducating the full contents of the body - /// have been sent. This resource represents the contents as an - /// `output-stream` child resource, and the completion of the body (with - /// optional trailers) with a static function that consumes the - /// `outgoing-body` resource, and ensures that the user of this interface - /// may not write to the body contents after the body has been finished. - /// - /// If the user code drops this resource, as opposed to calling the static - /// method `finish`, the implementation should treat the body as incomplete, - /// and that an error has occured. The implementation should propogate this - /// error to the HTTP protocol by whatever means it has available, - /// including: corrupting the body on the wire, aborting the associated - /// Request, or sending a late status code for the Response. resource outgoing-body { - /// Returns a stream for writing the body contents. - /// - /// The returned `output-stream` is a child resource: it must be dropped - /// before the parent `outgoing-body` resource is dropped (or finished), - /// otherwise the `outgoing-body` drop or `finish` will trap. - /// - /// Returns success on the first call: the `output-stream` resource for - /// this `outgoing-body` may be retrieved at most once. Subsequent calls - /// will return error. write: func() -> result; - /// Finalize an outgoing body, optionally providing trailers. This must be - /// called to signal that the response is complete. If the `outgoing-body` - /// is dropped without calling `outgoing-body.finalize`, the implementation - /// should treat the body as corrupted. - /// - /// Fails if the body's `outgoing-request` or `outgoing-response` was - /// constructed with a Content-Length header, and the contents written - /// to the body (via `write`) does not match the value given in the - /// Content-Length. finish: static func(this: outgoing-body, trailers: option) -> result<_, error-code>; } - /// Represents a future which may eventaully return an incoming HTTP - /// Response, or an error. - /// - /// This resource is returned by the `wasi:http/outgoing-handler` interface to - /// provide the HTTP Response corresponding to the sent Request. resource future-incoming-response { - /// Returns a pollable which becomes ready when either the Response has - /// been received, or an error has occured. When this pollable is ready, - /// the `get` method will return `some`. subscribe: func() -> pollable; - /// Returns the incoming HTTP Response, or an error, once one is ready. - /// - /// The outer `option` represents future readiness. Users can wait on this - /// `option` to become `some` using the `subscribe` method. - /// - /// The outer `result` is used to retrieve the response or error at most - /// once. It will be success on the first call in which the outer option - /// is `some`, and error on subsequent calls. - /// - /// The inner `result` represents that either the incoming HTTP Response - /// status and headers have recieved successfully, or that an error - /// occured. Errors may also occur while consuming the response body, - /// but those will be reported by the `incoming-body` and its - /// `output-stream` child. get: func() -> option>>; } - /// Attempts to extract a http-related `error` from the wasi:io `error` - /// provided. - /// - /// Stream operations which return - /// `wasi:io/stream/stream-error::last-operation-failed` have a payload of - /// type `wasi:io/error/error` with more information about the operation - /// that failed. This payload can be passed through to this function to see - /// if there's http-related information about the error to return. - /// - /// Note that this function is fallible because not all io-errors are - /// http-related errors. http-error-code: func(err: borrow) -> option; } -/// This interface defines a handler of incoming HTTP Requests. It should -/// be exported by components which can respond to HTTP Requests. interface incoming-handler { use types.{incoming-request, response-outparam}; - /// 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. handle: func(request: incoming-request, response-out: response-outparam); } -/// This interface defines a handler of outgoing HTTP Requests. It should be -/// imported by components which wish to make HTTP Requests. interface outgoing-handler { use types.{outgoing-request, request-options, future-incoming-response, error-code}; - /// 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`. handle: func(request: outgoing-request, options: option) -> result; } -/// The `wasi:http/proxy` world captures a widely-implementable intersection of -/// hosts that includes HTTP forward and reverse proxies. Components targeting -/// this world may concurrently stream in and out any number of incoming and -/// outgoing HTTP requests. -world proxy { - import wasi:random/random@0.2.0; - import wasi:io/error@0.2.0; - import wasi:io/poll@0.2.0; - import wasi:io/streams@0.2.0; - import wasi:cli/stdout@0.2.0; - import wasi:cli/stderr@0.2.0; - import wasi:cli/stdin@0.2.0; - import wasi:clocks/monotonic-clock@0.2.0; - import types; - import outgoing-handler; - import wasi:clocks/wall-clock@0.2.0; - - export incoming-handler; -} diff --git a/_examples/invoke/wit/deps/wasi-io-0.2.0/package.wit b/_examples/invoke/wit/deps/wasi-io-0.2.0/package.wit index 1840029..962734d 100644 --- a/_examples/invoke/wit/deps/wasi-io-0.2.0/package.wit +++ b/_examples/invoke/wit/deps/wasi-io-0.2.0/package.wit @@ -1,11 +1,5 @@ package wasi:io@0.2.0; -interface error { - resource error { - to-debug-string: func() -> string; - } -} - interface poll { resource pollable { ready: func() -> bool; @@ -15,6 +9,12 @@ interface poll { poll: func(in: list>) -> list; } +interface error { + resource error { + to-debug-string: func() -> string; + } +} + interface streams { use error.{error}; use poll.{pollable}; diff --git a/_examples/invoke/wit/deps/wasi-logging-0.1.0-draft/package.wit b/_examples/invoke/wit/deps/wasi-logging-0.1.0-draft/package.wit index df4e8de..70349a7 100644 --- a/_examples/invoke/wit/deps/wasi-logging-0.1.0-draft/package.wit +++ b/_examples/invoke/wit/deps/wasi-logging-0.1.0-draft/package.wit @@ -1,36 +1,15 @@ -package wasi:logging; +package wasi:logging@0.1.0-draft; -/// WASI Logging is a logging API intended to let users emit log messages with -/// simple priority levels and context values. interface logging { - /// A log level, describing a kind of message. enum level { - /// Describes messages about the values of variables and the flow of - /// control within a program. trace, - /// Describes messages likely to be of interest to someone debugging a - /// program. debug, - /// Describes messages likely to be of interest to someone monitoring a - /// program. info, - /// Describes messages indicating hazardous situations. warn, - /// Describes messages indicating serious errors. error, - /// Describes messages indicating fatal errors. critical, } - /// Emit a log message. - /// - /// A log message has a `level` describing what kind of message is being - /// sent, a context, which is an uninterpreted string meant to help - /// consumers group similar messages, and a string containing the message - /// text. log: func(level: level, context: string, message: string); } -world imports { - import logging; -} diff --git a/_examples/invoke/wit/deps/wasmcloud-bus-1.0.0/package.wit b/_examples/invoke/wit/deps/wasmcloud-bus-1.0.0/package.wit index 1008a6f..2a7cd93 100644 --- a/_examples/invoke/wit/deps/wasmcloud-bus-1.0.0/package.wit +++ b/_examples/invoke/wit/deps/wasmcloud-bus-1.0.0/package.wit @@ -1,15 +1,10 @@ package wasmcloud:bus@1.0.0; interface lattice { - /// Interface target. This represents an interface, which can be selected by `set-link-name`. resource call-target-interface { constructor(namespace: string, %package: string, %interface: string); } - /// Set an optional link name to use for all interfaces specified. This is advanced - /// functionality only available within wasmcloud and, as such, is exposed here as part of the - /// wasmcloud:bus package. This is used when you are linking multiple of the same interfaces - /// (i.e. a keyvalue implementation for caching and another one for secrets) to a component set-link-name: func(name: string, interfaces: list); } diff --git a/_examples/invoke/wit/deps/wasmcloud-component-go-0.1.0/package.wit b/_examples/invoke/wit/deps/wasmcloud-component-go-0.1.0/package.wit new file mode 100644 index 0000000..75caf04 --- /dev/null +++ b/_examples/invoke/wit/deps/wasmcloud-component-go-0.1.0/package.wit @@ -0,0 +1,85 @@ +package wasmcloud:component-go@0.1.0; + +world exports { + import wasi:io/poll@0.2.0; + import wasi:clocks/monotonic-clock@0.2.0; + import wasi:io/error@0.2.0; + import wasi:io/streams@0.2.0; + import wasi:http/types@0.2.0; + + export wasi:http/incoming-handler@0.2.0; +} +world imports { + import wasi:logging/logging@0.1.0-draft; + import wasi:config/runtime@0.2.0-draft; + import wasi:io/poll@0.2.0; + import wasi:clocks/monotonic-clock@0.2.0; + import wasi:io/error@0.2.0; + import wasi:io/streams@0.2.0; + import wasi:http/types@0.2.0; + import wasi:http/outgoing-handler@0.2.0; + import wasmcloud:bus/lattice@1.0.0; + import wasmcloud:secrets/store@0.1.0-draft; + import wasmcloud:secrets/reveal@0.1.0-draft; + import wasi:cli/environment@0.2.0; + import wasi:cli/exit@0.2.0; + import wasi:cli/stdin@0.2.0; + import wasi:cli/stdout@0.2.0; + import wasi:cli/stderr@0.2.0; + import wasi:cli/terminal-input@0.2.0; + import wasi:cli/terminal-output@0.2.0; + import wasi:cli/terminal-stdin@0.2.0; + import wasi:cli/terminal-stdout@0.2.0; + import wasi:cli/terminal-stderr@0.2.0; + import wasi:clocks/wall-clock@0.2.0; + import wasi:filesystem/types@0.2.0; + import wasi:filesystem/preopens@0.2.0; + import wasi:sockets/network@0.2.0; + import wasi:sockets/instance-network@0.2.0; + import wasi:sockets/udp@0.2.0; + import wasi:sockets/udp-create-socket@0.2.0; + import wasi:sockets/tcp@0.2.0; + import wasi:sockets/tcp-create-socket@0.2.0; + import wasi:sockets/ip-name-lookup@0.2.0; + import wasi:random/random@0.2.0; + import wasi:random/insecure@0.2.0; + import wasi:random/insecure-seed@0.2.0; +} +world sdk { + import wasi:io/poll@0.2.0; + import wasi:clocks/monotonic-clock@0.2.0; + import wasi:io/error@0.2.0; + import wasi:io/streams@0.2.0; + import wasi:http/types@0.2.0; + import wasi:logging/logging@0.1.0-draft; + import wasi:config/runtime@0.2.0-draft; + import wasi:http/outgoing-handler@0.2.0; + import wasmcloud:bus/lattice@1.0.0; + import wasmcloud:secrets/store@0.1.0-draft; + import wasmcloud:secrets/reveal@0.1.0-draft; + import wasi:cli/environment@0.2.0; + import wasi:cli/exit@0.2.0; + import wasi:cli/stdin@0.2.0; + import wasi:cli/stdout@0.2.0; + import wasi:cli/stderr@0.2.0; + import wasi:cli/terminal-input@0.2.0; + import wasi:cli/terminal-output@0.2.0; + import wasi:cli/terminal-stdin@0.2.0; + import wasi:cli/terminal-stdout@0.2.0; + import wasi:cli/terminal-stderr@0.2.0; + import wasi:clocks/wall-clock@0.2.0; + import wasi:filesystem/types@0.2.0; + import wasi:filesystem/preopens@0.2.0; + import wasi:sockets/network@0.2.0; + import wasi:sockets/instance-network@0.2.0; + import wasi:sockets/udp@0.2.0; + import wasi:sockets/udp-create-socket@0.2.0; + import wasi:sockets/tcp@0.2.0; + import wasi:sockets/tcp-create-socket@0.2.0; + import wasi:sockets/ip-name-lookup@0.2.0; + import wasi:random/random@0.2.0; + import wasi:random/insecure@0.2.0; + import wasi:random/insecure-seed@0.2.0; + + export wasi:http/incoming-handler@0.2.0; +} diff --git a/_examples/invoke/wit/deps/wasmcloud-component-go/world.wit b/_examples/invoke/wit/deps/wasmcloud-component-go/world.wit deleted file mode 100644 index f881ff8..0000000 --- a/_examples/invoke/wit/deps/wasmcloud-component-go/world.wit +++ /dev/null @@ -1,26 +0,0 @@ -package wasmcloud:component-go@0.1.0; - -world exports { - // wasi - export wasi:http/incoming-handler@0.2.0; -} - -world imports { - // tinygo - include wasi:cli/imports@0.2.0; - - // wasi - import wasi:logging/logging; - import wasi:config/runtime@0.2.0-draft; - import wasi:http/outgoing-handler@0.2.0; - - // wasmcloud - import wasmcloud:bus/lattice@1.0.0; - import wasmcloud:secrets/store@0.1.0-draft; - import wasmcloud:secrets/reveal@0.1.0-draft; -} - -world sdk { - include exports; - include imports; -} diff --git a/_examples/invoke/wit/deps/wasmcloud-secrets-0.1.0-draft/package.wit b/_examples/invoke/wit/deps/wasmcloud-secrets-0.1.0-draft/package.wit index a431b95..3a93ea4 100644 --- a/_examples/invoke/wit/deps/wasmcloud-secrets-0.1.0-draft/package.wit +++ b/_examples/invoke/wit/deps/wasmcloud-secrets-0.1.0-draft/package.wit @@ -1,52 +1,25 @@ -/// This WIT interface powers secret support in wasmCloud -/// -/// See RFC #2190 https://github.com/wasmCloud/wasmCloud/issues/2190 package wasmcloud:secrets@0.1.0-draft; interface store { - /// An error type that encapsulates the different errors that can occur fetching secrets variant secrets-error { - /// This indicates an error from an "upstream" secrets source. - /// As this could be almost _anything_ (such as Vault, Kubernetes Secrets, KeyValue buckets, etc), - /// the error message is a string. upstream(string), - /// This indicates an error from an I/O operation. - /// As this could be almost _anything_ (such as a file read, network connection, etc), - /// the error message is a string. - /// Depending on how this ends up being consumed, - /// we may consider moving this to use the `wasi:io/error` type instead. - /// For simplicity right now in supporting multiple implementations, it is being left as a string. io(string), - /// This indicates that the secret was not found. Generally "not found" errors will - /// be handled by the upstream secrets backend, but there are cases where the host - /// may need to return this error. not-found, } - /// A secret value can be either a string or a byte array, which lets you - /// store binary data as a secret. variant secret-value { - /// A string value %string(string), - /// A byte array value bytes(list), } - /// A secret is a resource that can only be borrowed. This allows you to - /// pass around handles to secrets and not reveal the values until a - /// component needs them. - /// You need to use the reveal interface to get the value. resource secret; - /// Gets a single opaque secrets value set at the given key if it exists get: func(key: string) -> result; } interface reveal { use store.{secret, secret-value}; - /// Reveals the value of a secret to the caller. - /// This lets you easily audit your code to discover where secrets are being used. reveal: func(s: borrow) -> secret-value; } diff --git a/_examples/invoke/wkg.lock b/_examples/invoke/wkg.lock new file mode 100644 index 0000000..5e100f7 --- /dev/null +++ b/_examples/invoke/wkg.lock @@ -0,0 +1,12 @@ +# This file is automatically generated. +# It is not intended for manual editing. +version = 1 + +[[packages]] +name = "wasmcloud:component-go" +registry = "wasmcloud.com" + +[[packages.versions]] +requirement = "=0.1.0" +version = "0.1.0" +digest = "sha256:de3e9af7dedd0d9e882f68f1bee533c7af9c6a1947eb40cbf1ef6163b7d41784" diff --git a/gen/wasi/logging/logging/logging.wit.go b/gen/wasi/logging/logging/logging.wit.go index 15b6e95..c9d2655 100644 --- a/gen/wasi/logging/logging/logging.wit.go +++ b/gen/wasi/logging/logging/logging.wit.go @@ -1,6 +1,6 @@ // Code generated by wit-bindgen-go. DO NOT EDIT. -// Package logging represents the imported interface "wasi:logging/logging". +// Package logging represents the imported interface "wasi:logging/logging@0.1.0-draft". // // WASI Logging is a logging API intended to let users emit log messages with // simple priority levels and context values. @@ -10,7 +10,7 @@ import ( "github.com/bytecodealliance/wasm-tools-go/cm" ) -// Level represents the enum "wasi:logging/logging#level". +// Level represents the enum "wasi:logging/logging@0.1.0-draft#level". // // A log level, describing a kind of message. // @@ -81,6 +81,6 @@ func Log(level Level, context string, message string) { return } -//go:wasmimport wasi:logging/logging log +//go:wasmimport wasi:logging/logging@0.1.0-draft log //go:noescape func wasmimport_Log(level0 uint32, context0 *uint8, context1 uint32, message0 *uint8, message1 uint32) diff --git a/wit/deps/wasi-logging-0.1.0-draft/package.wit b/wit/deps/wasi-logging-0.1.0-draft/package.wit index df4e8de..164cb5b 100644 --- a/wit/deps/wasi-logging-0.1.0-draft/package.wit +++ b/wit/deps/wasi-logging-0.1.0-draft/package.wit @@ -1,4 +1,4 @@ -package wasi:logging; +package wasi:logging@0.1.0-draft; /// WASI Logging is a logging API intended to let users emit log messages with /// simple priority levels and context values. diff --git a/wit/world.wit b/wit/world.wit index f881ff8..89b8e3c 100644 --- a/wit/world.wit +++ b/wit/world.wit @@ -10,7 +10,7 @@ world imports { include wasi:cli/imports@0.2.0; // wasi - import wasi:logging/logging; + import wasi:logging/logging@0.1.0-draft; import wasi:config/runtime@0.2.0-draft; import wasi:http/outgoing-handler@0.2.0;