diff --git a/Cargo.lock b/Cargo.lock index 63254397b..da500aa43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2872,7 +2872,6 @@ dependencies = [ "wasmflow-manifest", "wasmflow-mesh", "wasmflow-runtime", - "wasmflow-wascap", ] [[package]] @@ -4650,7 +4649,6 @@ dependencies = [ "async-trait", "http", "logger", - "nkeys 0.2.0", "once_cell", "parking_lot 0.12.1", "seeded-random", @@ -4976,7 +4974,6 @@ dependencies = [ "wasmflow-schematic-graph", "wasmflow-sdk", "wasmflow-stdlib", - "wasmflow-wascap", ] [[package]] diff --git a/codegen/templates/rust/partials/common/collection-signature.hbs b/codegen/templates/rust/partials/common/collection-signature.hbs index baf04d8e4..20bf33e75 100644 --- a/codegen/templates/rust/partials/common/collection-signature.hbs +++ b/codegen/templates/rust/partials/common/collection-signature.hbs @@ -10,6 +10,19 @@ wasmflow_sdk::v1::types::CollectionSignature { types: std::collections::HashMap::from([ {{#each types}} {{#switch type}} + {{#case "any"}} + ( + "{{@key}}".to_owned(), + wasmflow_sdk::v1::types::TypeDefinition::Struct(wasmflow_sdk::v1::types::StructSignature{ + name:"{{name}}".to_owned(), + fields: std::collections::HashMap::from([ + {{#each fields}} + ("{{@key}}".to_owned(),{{> type-signature .}}), + {{/each}} + ]).into() + }) + ), + {{/case}} {{#case "struct"}} ( "{{@key}}".to_owned(), diff --git a/codegen/templates/rust/partials/common/expand-type.hbs b/codegen/templates/rust/partials/common/expand-type.hbs index 4b980c96b..c9b09f47f 100644 --- a/codegen/templates/rust/partials/common/expand-type.hbs +++ b/codegen/templates/rust/partials/common/expand-type.hbs @@ -4,6 +4,7 @@ {{#case "string"}}String{{/case}} {{#case "bytes"}}Vec{{/case}} {{#case "raw"}}RawPacket{{/case}} + {{#case "any"}}serde_json::Value{{/case}} {{#case "struct"}}serde_json::Value{{/case}} {{#case "link"}}wasmflow_sdk::v1::CollectionLink{{/case}} {{#case "internal"}} diff --git a/crates/bins/wasmflow/src/utils.rs b/crates/bins/wasmflow/src/utils.rs index 57647fe7e..c9c203130 100644 --- a/crates/bins/wasmflow/src/utils.rs +++ b/crates/bins/wasmflow/src/utils.rs @@ -7,7 +7,6 @@ use wasmflow_manifest::WasmflowManifest; use crate::commands::FetchOptions; #[allow(clippy::too_many_lines)] -#[must_use] pub(crate) fn merge_config( def: &WasmflowManifest, local_cli_opts: &FetchOptions, diff --git a/crates/integration/test-cli-channel-component/schemas/main.apex b/crates/integration/test-cli-channel-component/schemas/main.apex index 3898127ab..661708128 100644 --- a/crates/integration/test-cli-channel-component/schemas/main.apex +++ b/crates/integration/test-cli-channel-component/schemas/main.apex @@ -1,9 +1,11 @@ namespace "main" +alias Link = string + type Inputs { args: [string] isInteractive: Interactive - program: link? + program: Link? } type Interactive { diff --git a/crates/integration/test-cli-channel-component/src/components/main.rs b/crates/integration/test-cli-channel-component/src/components/main.rs index dcfbf0ad9..715a82ea5 100644 --- a/crates/integration/test-cli-channel-component/src/components/main.rs +++ b/crates/integration/test-cli-channel-component/src/components/main.rs @@ -14,8 +14,10 @@ impl wasmflow_sdk::v1::ephemeral::BatchedComponent for Component { _config: Option, ) -> Result<(), Box> { let tty = input.is_interactive; - println!("args: {:?}, interactive: {{ stdin: {}, stdout: {}, stderr: {} }}", - input.args, tty.stdin, tty.stdout, tty.stderr); + println!( + "args: {:?}, interactive: {{ stdin: {}, stdout: {}, stderr: {} }}", + input.args, tty.stdin, tty.stdout, tty.stderr + ); let isatty = false; // input.is_interactive.stdin if !isatty { diff --git a/crates/integration/test-wasm-component/schemas/reverse_uppercase.apex b/crates/integration/test-wasm-component/schemas/reverse_uppercase.apex index 4e3a8edcb..d9dc06ef2 100644 --- a/crates/integration/test-wasm-component/schemas/reverse_uppercase.apex +++ b/crates/integration/test-wasm-component/schemas/reverse_uppercase.apex @@ -1,8 +1,10 @@ namespace "reverse-uppercase" +alias Link = string + type Inputs { input: string - link: link + link: Link } type Outputs { diff --git a/crates/wasmflow/wasmflow-collection-grpc/src/error.rs b/crates/wasmflow/wasmflow-collection-grpc/src/error.rs index 50a4c889c..100583b74 100644 --- a/crates/wasmflow/wasmflow-collection-grpc/src/error.rs +++ b/crates/wasmflow/wasmflow-collection-grpc/src/error.rs @@ -16,10 +16,7 @@ pub enum GrpcError { SendError, #[error("Internal Error : {0}")] Other(String), - #[error("Internal Error : {0}")] - InternalError(u32), - #[error("Could not create KeyPair from invalid seed")] - KeyPairFailed, + #[error("Component '{0}' not found. Valid components are: {}", .1.join(", "))] ComponentNotFound(String, Vec), } diff --git a/crates/wasmflow/wasmflow-collection-grpctar/src/error.rs b/crates/wasmflow/wasmflow-collection-grpctar/src/error.rs index 4a4847d02..8a19fd4d8 100644 --- a/crates/wasmflow/wasmflow-collection-grpctar/src/error.rs +++ b/crates/wasmflow/wasmflow-collection-grpctar/src/error.rs @@ -20,8 +20,7 @@ pub enum ParError { Other(String), #[error("Internal Error : {0}")] InternalError(u32), - #[error("Could not create KeyPair from invalid seed")] - KeyPairFailed, + #[error("Component '{0}' not found. Valid components are: {}", .1.join(", "))] ComponentNotFound(String, Vec), diff --git a/crates/wasmflow/wasmflow-collection-wasm/src/collection.rs b/crates/wasmflow/wasmflow-collection-wasm/src/collection.rs index 2f025f8d8..95436da87 100644 --- a/crates/wasmflow/wasmflow-collection-wasm/src/collection.rs +++ b/crates/wasmflow/wasmflow-collection-wasm/src/collection.rs @@ -2,7 +2,6 @@ use std::collections::HashMap; use std::sync::Arc; use async_trait::async_trait; -use tokio_stream::StreamExt; pub use wapc::WasiParams; use wasmflow_manifest::Permissions; use wasmflow_rpc::error::RpcError; @@ -11,7 +10,7 @@ use wasmflow_sdk::v1::codec::{json, messagepack}; use wasmflow_sdk::v1::packet::{PacketMap, PacketWrapper}; use wasmflow_sdk::v1::transport::{MessageTransport, Serialized, TransportMap, TransportStream}; use wasmflow_sdk::v1::types::HostedType; -use wasmflow_sdk::v1::{BoxedFuture, CollectionLink, Entity, Invocation}; +use wasmflow_sdk::v1::{BoxedFuture, Invocation}; use crate::error::LinkError; use crate::wapc_module::WapcModule; @@ -78,41 +77,6 @@ impl Collection { Ok(Self { pool: Arc::new(host) }) } - - pub async fn exec_main(&self, origin: Entity, argv: Vec) -> u32 { - let mut transport_map = TransportMap::default(); - transport_map.insert("argv", MessageTransport::success(&argv)); - let target = Entity::component(origin.namespace(), "main"); - let link = CollectionLink::new(origin.clone(), target.clone()); - - transport_map.insert("network", MessageTransport::success(&link)); - let invocation = Invocation::new(origin, target, transport_map, None); - let result = self.invoke(invocation).await; - if let Err(e) = result { - error!("main() died with fatal error: {}", e); - return 6; - } - let output = result.unwrap(); - let packets: Vec<_> = output.collect().await; - for packet in packets { - if packet.port == "code" { - return if let MessageTransport::Failure(err) = packet.payload { - error!("main() component returned error: {}", err.message()); - 1 - } else { - match packet.payload.deserialize::() { - Ok(code) => code, - Err(e) => { - error!("Could not get code from main() component: {}", e); - 2 - } - } - }; - } - } - error!("No exit code received"); - 3 - } } #[async_trait] diff --git a/crates/wasmflow/wasmflow-collection-wasm/src/error.rs b/crates/wasmflow/wasmflow-collection-wasm/src/error.rs index 939107974..592d11d82 100644 --- a/crates/wasmflow/wasmflow-collection-wasm/src/error.rs +++ b/crates/wasmflow/wasmflow-collection-wasm/src/error.rs @@ -45,9 +45,6 @@ pub enum WasmCollectionError { #[error("Internal Error : {0}")] InternalError(u32), - #[error("Could not create KeyPair from invalid seed")] - KeyPairFailed, - #[error("Component '{0}' not found. Valid components are: {}", .1.join(", "))] ComponentNotFound(String, Vec), } diff --git a/crates/wasmflow/wasmflow-host/Cargo.toml b/crates/wasmflow/wasmflow-host/Cargo.toml index 92919920e..41fce92e9 100644 --- a/crates/wasmflow/wasmflow-host/Cargo.toml +++ b/crates/wasmflow/wasmflow-host/Cargo.toml @@ -23,7 +23,6 @@ wasmflow-invocation-server = { path = "../wasmflow-invocation-server" } tracing = "0.1" thiserror = "1.0" -nkeys = "0.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" async-trait = "0.1" diff --git a/crates/wasmflow/wasmflow-host/src/error.rs b/crates/wasmflow/wasmflow-host/src/error.rs index 1d382d944..984f9d10a 100644 --- a/crates/wasmflow/wasmflow-host/src/error.rs +++ b/crates/wasmflow/wasmflow-host/src/error.rs @@ -34,8 +34,6 @@ pub enum HostError { ConfigurationDeserialization(String), #[error("Async error: {0}")] AsyncRT(String), - #[error(transparent)] - KeyPairError(#[from] nkeys::error::Error), #[error("General error : {0}")] Other(String), #[error("{0}")] diff --git a/crates/wasmflow/wasmflow-host/src/host.rs b/crates/wasmflow/wasmflow-host/src/host.rs index 5eb699b8d..aec3932fd 100644 --- a/crates/wasmflow/wasmflow-host/src/host.rs +++ b/crates/wasmflow/wasmflow-host/src/host.rs @@ -4,7 +4,6 @@ use std::net::SocketAddr; use std::path::PathBuf; use std::sync::Arc; -use nkeys::KeyPair; use once_cell::sync::Lazy; use parking_lot::Mutex; use seeded_random::Seed; @@ -37,7 +36,6 @@ fn from_registry(id: Uuid) -> Arc { #[derive(Debug)] pub struct Host { id: String, - kp: KeyPair, network: Option, mesh: Option>, manifest: WasmflowManifest, @@ -129,9 +127,8 @@ impl Host { self.network.is_none(), crate::Error::InvalidHostState("Host already has a network running".into()) ); - let kp_seed = self.kp.seed()?; - let mut network_builder = NetworkBuilder::from_definition(self.manifest.clone(), &kp_seed)?; + let mut network_builder = NetworkBuilder::from_definition(self.manifest.clone())?; if let Some(mesh) = &self.mesh { network_builder = network_builder.mesh(mesh.clone()); } @@ -205,13 +202,6 @@ impl Host { } } - pub async fn exec_main(&self, argv: Vec) -> Result { - match &self.network { - Some(network) => Ok(network.exec_main(argv).await), - None => Err(crate::Error::InvalidHostState("No network available".into())), - } - } - pub async fn invoke(&self, invocation: Invocation) -> Result { match &self.network { Some(network) => Ok(network.invoke(invocation).await?), @@ -270,11 +260,9 @@ impl HostBuilder { /// Constructs an instance of a Wasmflow host. pub fn build(self) -> Host { - let kp = KeyPair::new_server(); - let host_id = kp.public_key(); + let host_id = Uuid::new_v4().to_string(); Host { - kp, id: host_id, network: None, mesh: None, diff --git a/crates/wasmflow/wasmflow-loader/src/error.rs b/crates/wasmflow/wasmflow-loader/src/error.rs index a7e4aa886..2cfd2fbc4 100644 --- a/crates/wasmflow/wasmflow-loader/src/error.rs +++ b/crates/wasmflow/wasmflow-loader/src/error.rs @@ -18,8 +18,6 @@ pub enum LoadError { Other(String), #[error("Internal Error : {0}")] InternalError(u32), - #[error("Could not create KeyPair from invalid seed")] - KeyPairFailed, #[error("Component '{0}' not found. Valid components are: {}", .1.join(", "))] ComponentNotFound(String, Vec), } diff --git a/crates/wasmflow/wasmflow-manifest/definitions/v0/manifest.apex b/crates/wasmflow/wasmflow-manifest/definitions/v0/manifest.apex index c59a05e4a..3edf37d75 100644 --- a/crates/wasmflow/wasmflow-manifest/definitions/v0/manifest.apex +++ b/crates/wasmflow/wasmflow-manifest/definitions/v0/manifest.apex @@ -106,7 +106,7 @@ type EntrypointDefinition { component: string, "Data or configuration used to initialize the collection." - data: struct, + data: any, } "A collection definition." @@ -121,7 +121,7 @@ type CollectionDefinition { reference: string, "Data or configuration used to initialize the collection." - data: struct, + data: any, } "Kind of collection." @@ -166,7 +166,7 @@ type ComponentDefinition { id: string @required, "Data to associate with the reference." - data: struct?, + data: any?, } "A connection between components. This can be specified in short-form syntax (where applicable). See wasmflow.com for more information." @@ -188,5 +188,5 @@ type ConnectionTargetDefinition { "The component's port." port: string @required, "Data to associate with a connection." - data: struct?, + data: any?, } diff --git a/crates/wasmflow/wasmflow-manifest/definitions/v0/templates/json-schema/partials/expand-type.hbs b/crates/wasmflow/wasmflow-manifest/definitions/v0/templates/json-schema/partials/expand-type.hbs index 2aa6f71d7..2e1d31543 100644 --- a/crates/wasmflow/wasmflow-manifest/definitions/v0/templates/json-schema/partials/expand-type.hbs +++ b/crates/wasmflow/wasmflow-manifest/definitions/v0/templates/json-schema/partials/expand-type.hbs @@ -20,7 +20,7 @@ {{/case}} {{#case "Named"~}} {{#switch name.value~}} - {{#case "struct"}}"type":"object"{{/case}} + {{#case "any"}}"type":"object"{{/case}} {{#case "string"}}"type":"string"{{/case}} {{#case "i8"}}"type":"number"{{/case}} {{#case "u8"}}"type":"number"{{/case}} diff --git a/crates/wasmflow/wasmflow-manifest/definitions/v0/templates/rust/partials/expand-type.hbs b/crates/wasmflow/wasmflow-manifest/definitions/v0/templates/rust/partials/expand-type.hbs index 4fc10bf70..5ac3985dd 100644 --- a/crates/wasmflow/wasmflow-manifest/definitions/v0/templates/rust/partials/expand-type.hbs +++ b/crates/wasmflow/wasmflow-manifest/definitions/v0/templates/rust/partials/expand-type.hbs @@ -2,7 +2,7 @@ {{#switch kind ~}} {{#case "Named"}} {{#switch name.value}} - {{#case "struct"}}Value{{/case}} + {{#case "any"}}Value{{/case}} {{#case "string"}}String{{/case}} {{#default}}{{name.value}}{{/default}} {{/switch}} diff --git a/crates/wasmflow/wasmflow-manifest/definitions/v0/templates/rust/partials/type-definition.hbs b/crates/wasmflow/wasmflow-manifest/definitions/v0/templates/rust/partials/type-definition.hbs index ddd81cb1d..c34a8aab2 100644 --- a/crates/wasmflow/wasmflow-manifest/definitions/v0/templates/rust/partials/type-definition.hbs +++ b/crates/wasmflow/wasmflow-manifest/definitions/v0/templates/rust/partials/type-definition.hbs @@ -60,7 +60,7 @@ pub struct {{name.value}} { {{#case "f32"}}#[serde(deserialize_with="with_expand_envs")]{{/case}} {{#case "f64"}}#[serde(deserialize_with="with_expand_envs")]{{/case}} {{#case "bool"}}#[serde(deserialize_with="with_expand_envs")]{{/case}} - {{#case "struct"}}#[serde(deserialize_with = "crate::helpers::deserialize_json_env")]{{/case}} + {{#case "any"}}#[serde(deserialize_with = "crate::helpers::deserialize_json_env")]{{/case}} {{#case "ConnectionTargetDefinition"}}#[serde(deserialize_with = "connection_target_shortform")]{{/case}} {{/switch}} {{/case}} diff --git a/crates/wasmflow/wasmflow-manifest/definitions/v1/manifest.apex b/crates/wasmflow/wasmflow-manifest/definitions/v1/manifest.apex index b2e401514..b9f1e5cd0 100644 --- a/crates/wasmflow/wasmflow-manifest/definitions/v1/manifest.apex +++ b/crates/wasmflow/wasmflow-manifest/definitions/v1/manifest.apex @@ -17,9 +17,6 @@ type WasmflowManifest { "The labels and values that apply to this manifest." labels: {string: string}, - "The collection to use as the entrypoint when running as a standalone process." - unstable_triggers: EntrypointDefinition?, - "A map of namespace to external component collection." external: {string: CollectionDefinition}, @@ -90,21 +87,6 @@ type MeshConfig { token: string?, } -"A collection definition for the main entrypoint." -type EntrypointDefinition { - "The reference/location of the collection." - reference: string, - - "The component to use as the entrypoint." - component: string, - - "Data or configuration used to initialize the collection." - config: struct, - - "Permissions to give this collection" - permissions: Permissions -} - "A WebAssembly collection." type WasmCollection @internal_tag("kind", "Wasm") { "The URL (and optional tag) or local file path to find the .wasm module." @@ -114,7 +96,7 @@ type WasmCollection @internal_tag("kind", "Wasm") { permissions: Permissions "Per-collection configuration." - config: struct + config: any } "Per-collection permissions configuration." @@ -128,7 +110,7 @@ type GrpcUrlCollection @internal_tag("kind", "GrpcUrl") { "The GRPC URL to connect to." url: string, "Any configuration necessary for the collection." - config: struct + config: any } "A collection hosted somewhere on a connected mesh." @@ -136,7 +118,7 @@ type MeshCollection @internal_tag("kind", "Mesh") { "The ID of the collection." id: string, "Any configuration necessary for the collection." - config: struct + config: any } "A native collection that can be extracted and run as a microservice." @@ -144,7 +126,7 @@ type GrpcTarCollection @internal_tag("kind", "GrpcTar") { "The URL (and optional tag) or local file path to find the archive." reference: string, "Any configuration necessary for the collection." - config: struct + config: any } "A native collection that can be extracted and run as a microservice." @@ -152,7 +134,7 @@ type ManifestCollection @internal_tag("kind", "Manifest") { "The URL (and optional tag) or local file path to find the manifest." reference: string, "Any configuration necessary for the collection." - config: struct + config: any } "A definition for an single flow." @@ -173,7 +155,7 @@ type ComponentDefinition { id: string @required, "Data to associate with the reference." - config: struct?, + config: any?, } "A connection between components. This can be specified in short-form syntax (where applicable). See wasmflow.com for more information." @@ -197,5 +179,5 @@ type ConnectionTargetDefinition { port: string @required, "The default value to provide on this connection in the event of an error." - data: struct?, + data: any?, } diff --git a/crates/wasmflow/wasmflow-manifest/definitions/v1/templates/json-schema/partials/expand-type.hbs b/crates/wasmflow/wasmflow-manifest/definitions/v1/templates/json-schema/partials/expand-type.hbs index b47e0d29b..79c0260e1 100644 --- a/crates/wasmflow/wasmflow-manifest/definitions/v1/templates/json-schema/partials/expand-type.hbs +++ b/crates/wasmflow/wasmflow-manifest/definitions/v1/templates/json-schema/partials/expand-type.hbs @@ -20,7 +20,7 @@ {{/case}} {{#case "Named"~}} {{#switch name.value~}} - {{#case "struct"}}"type":"object"{{/case}} + {{#case "any"}}"type":"object"{{/case}} {{#case "string"}}"type":"string"{{/case}} {{#case "i8"}}"type":"number"{{/case}} {{#case "u8"}}"type":"number"{{/case}} diff --git a/crates/wasmflow/wasmflow-manifest/definitions/v1/templates/rust/partials/expand-type.hbs b/crates/wasmflow/wasmflow-manifest/definitions/v1/templates/rust/partials/expand-type.hbs index 4fc10bf70..5ac3985dd 100644 --- a/crates/wasmflow/wasmflow-manifest/definitions/v1/templates/rust/partials/expand-type.hbs +++ b/crates/wasmflow/wasmflow-manifest/definitions/v1/templates/rust/partials/expand-type.hbs @@ -2,7 +2,7 @@ {{#switch kind ~}} {{#case "Named"}} {{#switch name.value}} - {{#case "struct"}}Value{{/case}} + {{#case "any"}}Value{{/case}} {{#case "string"}}String{{/case}} {{#default}}{{name.value}}{{/default}} {{/switch}} diff --git a/crates/wasmflow/wasmflow-manifest/definitions/v1/templates/rust/partials/type-definition.hbs b/crates/wasmflow/wasmflow-manifest/definitions/v1/templates/rust/partials/type-definition.hbs index 095536c45..875457047 100644 --- a/crates/wasmflow/wasmflow-manifest/definitions/v1/templates/rust/partials/type-definition.hbs +++ b/crates/wasmflow/wasmflow-manifest/definitions/v1/templates/rust/partials/type-definition.hbs @@ -68,7 +68,7 @@ pub struct {{name.value}} { {{#case "f32"}}#[serde(deserialize_with="with_expand_envs")]{{/case}} {{#case "f64"}}#[serde(deserialize_with="with_expand_envs")]{{/case}} {{#case "bool"}}#[serde(deserialize_with="with_expand_envs")]{{/case}} - {{#case "struct"}}#[serde(deserialize_with = "crate::helpers::deserialize_json_env")]{{/case}} + {{#case "any"}}#[serde(deserialize_with = "crate::helpers::deserialize_json_env")]{{/case}} {{#case "ConnectionTargetDefinition"}}#[serde(deserialize_with = "crate::parse::v1::connection_target_shortform")]{{/case}} {{/switch}} {{/case}} diff --git a/crates/wasmflow/wasmflow-manifest/docs/v0.html b/crates/wasmflow/wasmflow-manifest/docs/v0.html index dd60cdd98..ac8c25cf7 100644 --- a/crates/wasmflow/wasmflow-manifest/docs/v0.html +++ b/crates/wasmflow/wasmflow-manifest/docs/v0.html @@ -456,7 +456,7 @@

@@ -519,7 +519,7 @@

@@ -729,7 +729,7 @@

    -
  • Type: struct(Optional)
  • +
  • Type: any(Optional)
@@ -827,7 +827,7 @@

    -
  • Type: struct(Optional)
  • +
  • Type: any(Optional)
diff --git a/crates/wasmflow/wasmflow-manifest/docs/v1.html b/crates/wasmflow/wasmflow-manifest/docs/v1.html index b2a5300bb..7dc42d42f 100644 --- a/crates/wasmflow/wasmflow-manifest/docs/v1.html +++ b/crates/wasmflow/wasmflow-manifest/docs/v1.html @@ -74,20 +74,6 @@

  • Type: Map
  • - -
    - -

    - unstable_triggers -

    - -The collection to use as the entrypoint when running as a standalone process. - - -
    @@ -376,69 +362,6 @@

  • Type: string(Optional)
  • - -

    -

    - EntrypointDefinition -

    - -A collection definition for the main entrypoint. -
    -
    - -

    - reference -

    - -The reference/location of the collection. - - -
      -
    • Type: string
    • - - -
    -
    - -

    - component -

    - -The component to use as the entrypoint. - - -
      -
    • Type: string
    • - - -
    -
    - -

    - config -

    - -Data or configuration used to initialize the collection. - - - -
    - -

    - permissions -

    - -Permissions to give this collection - - -

    @@ -485,7 +408,7 @@

    @@ -541,7 +464,7 @@

    @@ -576,7 +499,7 @@

    @@ -611,7 +534,7 @@

    @@ -646,7 +569,7 @@

    @@ -730,7 +653,7 @@

      -
    • Type: struct(Optional)
    • +
    • Type: any(Optional)
    @@ -828,7 +751,7 @@

      -
    • Type: struct(Optional)
    • +
    • Type: any(Optional)
    diff --git a/crates/wasmflow/wasmflow-manifest/json-schema/manifest.json b/crates/wasmflow/wasmflow-manifest/json-schema/manifest.json index c0070f05f..b0b410c03 100644 --- a/crates/wasmflow/wasmflow-manifest/json-schema/manifest.json +++ b/crates/wasmflow/wasmflow-manifest/json-schema/manifest.json @@ -372,11 +372,6 @@ } } }, - "unstable_triggers": { - "description": "The collection to use as the entrypoint when running as a standalone process.", - "required": false, - "$ref": "#/$defs/v1/EntrypointDefinition" - }, "external": { "description": "A map of namespace to external component collection.", "type": "object", @@ -522,29 +517,6 @@ }, "required": [] }, - "EntrypointDefinition": { - "$anchor": "#v1/EntrypointDefinition", - "additionalProperties": false, - "properties": { - "reference": { - "description": "The reference/location of the collection.", - "type": "string" - }, - "component": { - "description": "The component to use as the entrypoint.", - "type": "string" - }, - "config": { - "description": "Data or configuration used to initialize the collection.", - "type": "object" - }, - "permissions": { - "description": "Permissions to give this collection", - "$ref": "#/$defs/v1/Permissions" - } - }, - "required": [] - }, "WasmCollection": { "$anchor": "#v1/WasmCollection", "additionalProperties": false, diff --git a/crates/wasmflow/wasmflow-manifest/json-schema/v1/manifest.json b/crates/wasmflow/wasmflow-manifest/json-schema/v1/manifest.json index 4464dd85f..ef8fc9d36 100644 --- a/crates/wasmflow/wasmflow-manifest/json-schema/v1/manifest.json +++ b/crates/wasmflow/wasmflow-manifest/json-schema/v1/manifest.json @@ -35,12 +35,6 @@ } } }, - "unstable_triggers": { - "description": "The collection to use as the entrypoint when running as a standalone process.", - "required": false, - - "$ref": "#/$defs/v1/EntrypointDefinition" - }, "external": { "description": "A map of namespace to external component collection.", "type": "object", @@ -196,33 +190,6 @@ "required": [] }, - "EntrypointDefinition": { - "$anchor": "#v1/EntrypointDefinition", - "additionalProperties": false, - "properties": { - "reference": { - "description": "The reference/location of the collection.", - - "type": "string" - }, - "component": { - "description": "The component to use as the entrypoint.", - - "type": "string" - }, - "config": { - "description": "Data or configuration used to initialize the collection.", - "type": "object" - }, - "permissions": { - "description": "Permissions to give this collection", - - "$ref": "#/$defs/v1/Permissions" - } - }, - "required": [] - }, - "WasmCollection": { "$anchor": "#v1/WasmCollection", "additionalProperties": false, diff --git a/crates/wasmflow/wasmflow-manifest/src/collection_definition.rs b/crates/wasmflow/wasmflow-manifest/src/collection_definition.rs index d60a9ffde..eb4c8d2d1 100644 --- a/crates/wasmflow/wasmflow-manifest/src/collection_definition.rs +++ b/crates/wasmflow/wasmflow-manifest/src/collection_definition.rs @@ -28,18 +28,6 @@ impl TryFrom for EntrypointDefinition { } } -impl TryFrom for EntrypointDefinition { - type Error = crate::Error; - fn try_from(def: crate::v1::EntrypointDefinition) -> Result { - Ok(EntrypointDefinition { - reference: def.reference, - config: def.config, - permissions: def.permissions.into(), - component: def.component, - }) - } -} - #[derive(Debug, Clone)] /// A definition of a Wasmflow Collection with its namespace, how to retrieve or access it and its configuration. #[must_use] @@ -51,6 +39,14 @@ pub struct CollectionDefinition { } impl CollectionDefinition { + /// Create a new [CollectionDefinition] with specified name and type. + pub fn new(name: impl AsRef, kind: CollectionKind) -> Self { + Self { + namespace: name.as_ref().to_owned(), + kind, + } + } + /// Get the configuration object for the collection. #[must_use] pub fn config(&self) -> Option<&Value> { @@ -82,6 +78,49 @@ pub enum CollectionKind { Manifest(ManifestCollection), } +impl CollectionKind { + /// Create a new [CollectionKind::Wasm] variant. + pub fn wasm(reference: impl AsRef, config: Option, permissions: Option) -> Self { + Self::Wasm(WasmCollection { + reference: reference.as_ref().to_owned(), + config: config.unwrap_or_default(), + permissions: permissions.unwrap_or_default(), + }) + } + + /// Create a new [CollectionKind::GrpcUrl] variant. + pub fn grpc_url(url: impl AsRef, config: Option) -> Self { + Self::GrpcUrl(GrpcUrlCollection { + url: url.as_ref().to_owned(), + config: config.unwrap_or_default(), + }) + } + + /// Create a new [CollectionKind::GrpcTar] variant. + pub fn grpc_tar(reference: impl AsRef, config: Option) -> Self { + Self::GrpcTar(GrpcTarCollection { + reference: reference.as_ref().to_owned(), + config: config.unwrap_or_default(), + }) + } + + /// Create a new [CollectionKind::Manifest] variant. + pub fn manifest(reference: impl AsRef, config: Option) -> Self { + Self::Manifest(ManifestCollection { + reference: reference.as_ref().to_owned(), + config: config.unwrap_or_default(), + }) + } + + /// Create a new [CollectionKind::Mesh] variant. + pub fn mesh(id: impl AsRef, config: Option) -> Self { + Self::Mesh(MeshCollection { + config: config.unwrap_or_default(), + id: id.as_ref().to_owned(), + }) + } +} + /// A native collection compiled and built in to the runtime. #[derive(Debug, Clone)] #[allow(missing_copy_implementations)] @@ -231,29 +270,35 @@ impl From<(String, crate::v1::CollectionDefinition)> for CollectionDefinition { fn from(def: (String, crate::v1::CollectionDefinition)) -> Self { CollectionDefinition { namespace: def.0, - kind: match def.1 { - crate::v1::CollectionDefinition::WasmCollection(v) => CollectionKind::Wasm(WasmCollection { - reference: v.reference, - config: v.config, - permissions: v.permissions.into(), - }), - crate::v1::CollectionDefinition::GrpcUrlCollection(v) => CollectionKind::GrpcUrl(GrpcUrlCollection { - url: v.url, - config: v.config, - }), - crate::v1::CollectionDefinition::GrpcTarCollection(v) => CollectionKind::GrpcTar(GrpcTarCollection { - reference: v.reference, - config: v.config, - }), - crate::v1::CollectionDefinition::MeshCollection(v) => CollectionKind::Mesh(MeshCollection { - id: v.id, - config: v.config, - }), - crate::v1::CollectionDefinition::ManifestCollection(v) => CollectionKind::Manifest(ManifestCollection { - reference: v.reference, - config: v.config, - }), - }, + kind: def.1.into(), + } + } +} + +impl From for CollectionKind { + fn from(def: crate::v1::CollectionDefinition) -> Self { + match def { + crate::v1::CollectionDefinition::WasmCollection(v) => CollectionKind::Wasm(WasmCollection { + reference: v.reference, + config: v.config, + permissions: v.permissions.into(), + }), + crate::v1::CollectionDefinition::GrpcUrlCollection(v) => CollectionKind::GrpcUrl(GrpcUrlCollection { + url: v.url, + config: v.config, + }), + crate::v1::CollectionDefinition::GrpcTarCollection(v) => CollectionKind::GrpcTar(GrpcTarCollection { + reference: v.reference, + config: v.config, + }), + crate::v1::CollectionDefinition::MeshCollection(v) => CollectionKind::Mesh(MeshCollection { + id: v.id, + config: v.config, + }), + crate::v1::CollectionDefinition::ManifestCollection(v) => CollectionKind::Manifest(ManifestCollection { + reference: v.reference, + config: v.config, + }), } } } diff --git a/crates/wasmflow/wasmflow-manifest/src/lib.rs b/crates/wasmflow/wasmflow-manifest/src/lib.rs index 3f488a2b7..9e7b2d576 100644 --- a/crates/wasmflow/wasmflow-manifest/src/lib.rs +++ b/crates/wasmflow/wasmflow-manifest/src/lib.rs @@ -125,7 +125,6 @@ pub mod flow_definition; pub use flow_definition::{ComponentDefinition, ConnectionDefinition, ConnectionTargetDefinition, Flow}; pub use wasmflow_parser::parse::v0::parse_id; -use self::collection_definition::EntrypointDefinition; use self::host_definition::HostConfig; use crate::error::ManifestError; @@ -144,7 +143,6 @@ pub struct WasmflowManifest { default_flow: Option, name: Option, labels: HashMap, - triggers: Option, collections: HashMap, flows: HashMap, } @@ -165,7 +163,6 @@ impl TryFrom for WasmflowManifest { host: def.host.try_into()?, default_flow: def.default_schematic, name: def.network.name, - triggers: def.network.triggers.map(|v| v.try_into()).transpose()?, collections: def .network .collections @@ -188,7 +185,6 @@ impl TryFrom for WasmflowManifest { host: def.host.try_into()?, default_flow: def.default_flow, name: def.name, - triggers: def.unstable_triggers.map(|v| v.try_into()).transpose()?, collections: def .external .into_iter() @@ -321,12 +317,6 @@ impl WasmflowManifest { self.collections.iter().find(|(k, _)| *k == namespace).map(|(_, v)| v) } - #[must_use] - /// Get the name for this manifest. - pub fn triggers(&self) -> &Option { - &self.triggers - } - /// Get a schematic by name #[must_use] pub fn flow(&self, name: &str) -> Option<&Flow> { @@ -338,6 +328,7 @@ impl WasmflowManifest { #[derive(Default, Debug, Clone)] #[must_use] pub struct WasmflowManifestBuilder { + base: Option, collections: HashMap, flows: HashMap, } @@ -348,6 +339,14 @@ impl WasmflowManifestBuilder { Self::default() } + /// Create a builder with an existing manifest as a base. + pub fn with_base(definition: WasmflowManifest) -> Self { + Self { + base: Some(definition), + ..Default::default() + } + } + /// Add a [CollectionDefinition] to the builder. pub fn add_collection(mut self, name: impl AsRef, collection: CollectionDefinition) -> Self { self.collections.insert(name.as_ref().to_owned(), collection); @@ -362,10 +361,21 @@ impl WasmflowManifestBuilder { /// Consume the [WasmflowManifestBuilder] and return a [WasmflowManifest]. pub fn build(self) -> WasmflowManifest { - WasmflowManifest { - version: 1, - collections: self.collections, - ..Default::default() + if let Some(mut def) = self.base { + for (name, collection) in self.collections { + def.collections.insert(name, collection); + } + for (name, flow) in self.flows { + def.flows.insert(name, flow); + } + def + } else { + WasmflowManifest { + version: 1, + collections: self.collections, + flows: self.flows, + ..Default::default() + } } } } diff --git a/crates/wasmflow/wasmflow-manifest/src/v1.rs b/crates/wasmflow/wasmflow-manifest/src/v1.rs index bd902b6de..c6efb4512 100644 --- a/crates/wasmflow/wasmflow-manifest/src/v1.rs +++ b/crates/wasmflow/wasmflow-manifest/src/v1.rs @@ -49,9 +49,6 @@ pub struct WasmflowManifest { #[serde(skip_serializing_if = "HashMap::is_empty")] #[serde(deserialize_with = "crate::helpers::kv_deserializer")] pub labels: HashMap, - /// The collection to use as the entrypoint when running as a standalone process. - #[serde(default)] - pub unstable_triggers: Option, /// A map of namespace to external component collection. #[serde(default)] #[serde(skip_serializing_if = "HashMap::is_empty")] @@ -166,27 +163,6 @@ pub struct MeshConfig { pub token: Option, } -#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)] -#[serde(deny_unknown_fields)] -/// A collection definition for the main entrypoint. -pub struct EntrypointDefinition { - /// The reference/location of the collection. - #[serde(default)] - #[serde(deserialize_with = "with_expand_envs")] - pub reference: String, - /// The component to use as the entrypoint. - #[serde(default)] - #[serde(deserialize_with = "with_expand_envs")] - pub component: String, - /// Data or configuration used to initialize the collection. - #[serde(default)] - #[serde(deserialize_with = "crate::helpers::deserialize_json_env")] - pub config: Value, - /// Permissions to give this collection - #[serde(default)] - pub permissions: Permissions, -} - #[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)] #[serde(deny_unknown_fields)] /// A WebAssembly collection. diff --git a/crates/wasmflow/wasmflow-manifest/tests/v0_load_from_file.rs b/crates/wasmflow/wasmflow-manifest/tests/v0_load_from_file.rs index bde2ab133..d49d714af 100644 --- a/crates/wasmflow/wasmflow-manifest/tests/v0_load_from_file.rs +++ b/crates/wasmflow/wasmflow-manifest/tests/v0_load_from_file.rs @@ -94,21 +94,6 @@ fn load_env() -> Result<(), ManifestError> { Ok(()) } -#[test_logger::test] -fn load_json_env() -> Result<(), ManifestError> { - let path = PathBuf::from("./tests/manifests/v0/json-env.wafl"); - env::set_var("TEST_ENV_VAR_JSON", "load_json_env"); - let manifest = WasmflowManifest::load_from_file(&path)?; - // let expected: Permissions = from_value(json!({"json_key": "load_json_env"}))?; - - assert_eq!( - manifest.triggers().clone().unwrap().config, - json!({"json_key": "load_json_env"}) - ); - - Ok(()) -} - #[test_logger::test] fn load_sender_yaml() -> Result<(), ManifestError> { let path = PathBuf::from("./tests/manifests/v0/sender.wafl"); diff --git a/crates/wasmflow/wasmflow-runtime/Cargo.toml b/crates/wasmflow/wasmflow-runtime/Cargo.toml index 11c2439cd..a43e19762 100644 --- a/crates/wasmflow/wasmflow-runtime/Cargo.toml +++ b/crates/wasmflow/wasmflow-runtime/Cargo.toml @@ -20,7 +20,6 @@ wasmflow-collection-grpctar = { path = "../wasmflow-collection-grpctar" } wasmflow-collection-grpc = { path = "../wasmflow-collection-grpc" } wasmflow-mesh = { path = "../wasmflow-mesh" } wasmflow-stdlib = { path = "../wasmflow-stdlib" } -wasmflow-wascap = { path = "../wasmflow-wascap" } wasmflow-rpc = { path = "../wasmflow-rpc" } seeded-random = { path = "../../misc/seeded-random" } diff --git a/crates/wasmflow/wasmflow-runtime/src/cli.rs b/crates/wasmflow/wasmflow-runtime/src/cli.rs index 0f578301c..80811f237 100644 --- a/crates/wasmflow/wasmflow-runtime/src/cli.rs +++ b/crates/wasmflow/wasmflow-runtime/src/cli.rs @@ -24,7 +24,6 @@ use wasmflow_manifest::{ use wasmflow_rpc::RpcHandler; use wasmflow_sdk::v1::transport::{MessageTransport, Serialized, TransportMap}; use wasmflow_sdk::v1::{CollectionLink, Entity, InherentData, Invocation}; -use wasmflow_wascap::KeyPair; use {serde_value, serde_yaml}; use super::configuration::{ApplicationContext, Channel}; @@ -63,7 +62,6 @@ struct IsInteractive { } impl CLI { - #[allow(unused)] pub fn load(app: ApplicationContext, with: serde_value::Value) -> Result> { Ok(Box::new(CLI::load_impl(app, with)?)) } @@ -76,56 +74,25 @@ impl CLI { } async fn handle_command(&self, args: Vec, bytes: Vec) -> Result<()> { - let cli_collection = CollectionDefinition { - namespace: "cli".to_owned(), - kind: wasmflow_manifest::CollectionKind::Wasm(WasmCollection { - reference: self.config.location.clone(), - config: serde_json::Value::Null, - permissions: Permissions::default(), - }), - }; - let linked_collection: CollectionDefinition = ("linked".to_owned(), self.config.link.clone()).try_into()?; - let manifest = wasmflow_manifest::WasmflowManifestBuilder::new() - .add_collection("cli", cli_collection) - .add_collection("linked", linked_collection) - .add_flow( - "cli-component", - Flow { - name: "cli-component".to_owned(), - instances: HashMap::from([( - "cli-instance".to_owned(), - ComponentDefinition { - name: self.config.component.clone(), - namespace: "cli".to_owned(), - data: None, - }, - )]), - connections: vec![ - ConnectionDefinition { - from: ConnectionTargetDefinition::new("<>", "argv"), - to: ConnectionTargetDefinition::new("cli-instance", "argv"), - default: None, - }, - ConnectionDefinition { - from: ConnectionTargetDefinition::new("<>", "isInteractive"), - to: ConnectionTargetDefinition::new("cli-instance", "program"), - default: None, - }, - ConnectionDefinition { - from: ConnectionTargetDefinition::new("<>", "program"), - to: ConnectionTargetDefinition::new("cli-instance", "program"), - default: None, - }, - ], - ..Default::default() - }, - ) - .build(); - - let builder = crate::NetworkBuilder::from_definition(manifest, &KeyPair::new_user().seed()?)?; - let network = builder.build().await?; - - let link = CollectionLink::new(Entity::component("cli", "cli-instance"), Entity::collection(&"linked")); + let cli_namespace = "cli".to_owned(); + let linked_namespace = "linked".to_owned(); + + let cli_collection = CollectionDefinition::new( + &cli_namespace, + wasmflow_manifest::CollectionKind::wasm(&self.config.location, None, None), + ); + let linked_collection = CollectionDefinition::new(&linked_namespace, self.config.link.clone().into()); + + let network = crate::NetworkBuilder::new() + .add_collection(cli_collection) + .add_collection(linked_collection) + .build() + .await?; + + let link = CollectionLink::new( + Entity::component(&cli_namespace, &self.config.component), + Entity::collection(&linked_namespace), + ); let is_interactive = IsInteractive { stdin: atty::is(atty::Stream::Stdin), stdout: atty::is(atty::Stream::Stdout), @@ -149,7 +116,7 @@ impl CLI { let invocation = Invocation::new( Entity::client("cli_channel"), - Entity::component("cli", &self.config.component), + Entity::component(&cli_namespace, &self.config.component), inputs_map, self.app.inherent_data, ); diff --git a/crates/wasmflow/wasmflow-runtime/src/dev.rs b/crates/wasmflow/wasmflow-runtime/src/dev.rs index 26f3f9579..e4a95750d 100644 --- a/crates/wasmflow/wasmflow-runtime/src/dev.rs +++ b/crates/wasmflow/wasmflow-runtime/src/dev.rs @@ -5,7 +5,6 @@ pub(crate) mod prelude { pub(crate) use wasmflow_sdk::v1::transport::{TransportStream, TransportWrapper}; pub(crate) use wasmflow_sdk::v1::types::*; pub(crate) use wasmflow_sdk::v1::{Entity, Invocation}; - pub(crate) use wasmflow_wascap::KeyPair; pub(crate) use crate::collections::InvocationHandler; pub(crate) use crate::dispatch::InvocationResponse; diff --git a/crates/wasmflow/wasmflow-runtime/src/error.rs b/crates/wasmflow/wasmflow-runtime/src/error.rs index acf5677c3..9dca555d1 100644 --- a/crates/wasmflow/wasmflow-runtime/src/error.rs +++ b/crates/wasmflow/wasmflow-runtime/src/error.rs @@ -18,11 +18,6 @@ pub struct InvocationError(pub String); #[derive(Error, Debug)] pub enum RuntimeError { - #[error("Provided KeyPair has no associated seed")] - NoSeed, - #[error("Failed to create KeyPair from seed")] - KeyPairFailed, - #[error(transparent)] SchematicGraph(#[from] wasmflow_schematic_graph::error::Error), #[error(transparent)] diff --git a/crates/wasmflow/wasmflow-runtime/src/network.rs b/crates/wasmflow/wasmflow-runtime/src/network.rs index 95b45c05d..42a9fcc10 100644 --- a/crates/wasmflow/wasmflow-runtime/src/network.rs +++ b/crates/wasmflow/wasmflow-runtime/src/network.rs @@ -3,9 +3,8 @@ use std::time::Duration; use seeded_random::{Random, Seed}; use uuid::Uuid; -use wasmflow_manifest::WasmflowManifest; +use wasmflow_manifest::{Flow, WasmflowManifest, WasmflowManifestBuilder}; use wasmflow_mesh::Mesh; -use wasmflow_wascap::KeyPair; use crate::dev::prelude::*; use crate::network_service::Initialize; @@ -16,8 +15,6 @@ type Result = std::result::Result; pub struct Network { pub uid: Uuid, inner: Arc, - #[allow(unused)] - kp: KeyPair, timeout: Duration, } @@ -27,7 +24,6 @@ pub struct NetworkInit { definition: WasmflowManifest, allow_latest: bool, allowed_insecure: Vec, - kp: KeyPair, timeout: Duration, mesh: Option>, namespace: Option, @@ -35,10 +31,6 @@ pub struct NetworkInit { } impl Network { - pub async fn new_default(definition: WasmflowManifest, seed: &str) -> Result { - NetworkBuilder::from_definition(definition, seed)?.build().await - } - #[instrument(name = "network", skip_all)] pub async fn new(config: NetworkInit) -> Result { trace!(?config, "init"); @@ -61,7 +53,6 @@ impl Network { Ok(Self { uid: service.id, inner: service, - kp: config.kp, timeout: config.timeout, }) } @@ -78,16 +69,6 @@ impl Network { Ok(response.ok()?) } - pub async fn exec_main(&self, argv: Vec) -> u32 { - let time = std::time::SystemTime::now(); - trace!("executing main"); - - let code = self.inner.exec_main(argv).await; - trace!(duration_ms=%time.elapsed().unwrap().as_millis(),"main complete"); - - code - } - pub async fn shutdown(&self) -> Result<()> { trace!("network shutting down"); self.inner.shutdown().await?; @@ -103,13 +84,12 @@ impl Network { } /// The [NetworkBuilder] builds the configuration for a Wasmflow Network. -#[derive(Debug)] +#[derive(Debug, Default)] #[must_use] pub struct NetworkBuilder { allow_latest: bool, allowed_insecure: Vec, - definition: WasmflowManifest, - kp: KeyPair, + manifest_builder: WasmflowManifestBuilder, mesh: Option>, timeout: Duration, rng_seed: Option, @@ -117,21 +97,38 @@ pub struct NetworkBuilder { } impl NetworkBuilder { + pub fn new() -> Self { + Self { + timeout: Duration::from_secs(5), + ..Default::default() + } + } + /// Creates a new network builder from a [NetworkDefinition] - pub fn from_definition(definition: WasmflowManifest, seed: &str) -> Result { - let kp = keypair_from_seed(seed)?; + pub fn from_definition(definition: WasmflowManifest) -> Result { Ok(Self { allow_latest: definition.allow_latest(), allowed_insecure: definition.insecure_registries().clone(), - definition, + manifest_builder: WasmflowManifestBuilder::with_base(definition), timeout: Duration::from_secs(5), mesh: None, namespace: None, - kp, rng_seed: None, }) } + pub fn add_collection(mut self, collection: CollectionDefinition) -> Self { + self.manifest_builder = self + .manifest_builder + .add_collection(collection.namespace.clone(), collection); + self + } + + pub fn add_flow(mut self, flow: Flow) -> Self { + self.manifest_builder = self.manifest_builder.add_flow(flow.name.clone(), flow); + self + } + pub fn timeout(self, timeout: Duration) -> Self { Self { timeout, ..self } } @@ -170,11 +167,11 @@ impl NetworkBuilder { /// Constructs an instance of a Wasmflow host. pub async fn build(self) -> Result { + let definition = self.manifest_builder.build(); Network::new(NetworkInit { - definition: self.definition, + definition, allow_latest: self.allow_latest, allowed_insecure: self.allowed_insecure, - kp: self.kp, timeout: self.timeout, namespace: self.namespace, mesh: self.mesh, diff --git a/crates/wasmflow/wasmflow-runtime/src/network_service.rs b/crates/wasmflow/wasmflow-runtime/src/network_service.rs index dee604f74..45bbe2f6f 100644 --- a/crates/wasmflow/wasmflow-runtime/src/network_service.rs +++ b/crates/wasmflow/wasmflow-runtime/src/network_service.rs @@ -47,7 +47,6 @@ pub(crate) struct NetworkService { started_time: std::time::Instant, pub(crate) id: Uuid, interpreter: Arc, - entrypoint: Option, } type ServiceMap = HashMap>; @@ -90,16 +89,9 @@ impl NetworkService { None => interpreter.start(None, None).await, } - let entrypoint = if let Some(entry) = &msg.manifest.triggers() { - Some(initialize_wasm_entrypoint(entry, msg.id, msg.allow_latest, &msg.allowed_insecure).await?) - } else { - None - }; - let network = Arc::new(NetworkService { started_time: std::time::Instant::now(), id: msg.id, - entrypoint, interpreter: Arc::new(interpreter), }); @@ -109,17 +101,6 @@ impl NetworkService { Ok(network) } - pub(crate) async fn exec_main(&self, argv: Vec) -> u32 { - if let Some(entrypoint) = &self.entrypoint { - entrypoint - .exec_main(Entity::Collection(self.id.to_string()), argv) - .await - } else { - error!("no entrypoint defined for network {}", self.id); - 99 - } - } - pub(crate) fn new_from_manifest( uid: Uuid, location: &str, diff --git a/crates/wasmflow/wasmflow-runtime/src/test.rs b/crates/wasmflow/wasmflow-runtime/src/test.rs index 2694635ed..25c833bb7 100644 --- a/crates/wasmflow/wasmflow-runtime/src/test.rs +++ b/crates/wasmflow/wasmflow-runtime/src/test.rs @@ -6,18 +6,14 @@ pub(crate) mod prelude { } use wasmflow_manifest::WasmflowManifest; -use wasmflow_wascap::KeyPair; use crate::test::prelude::*; use crate::{Network, NetworkBuilder}; pub(crate) async fn init_network_from_yaml(path: &str) -> TestResult<(Network, uuid::Uuid)> { let def = WasmflowManifest::load_from_file(path)?; - let kp = KeyPair::new_server(); - let network = NetworkBuilder::from_definition(def, &kp.seed().map_err(|_| crate::Error::NoSeed)?)? - .build() - .await?; + let network = NetworkBuilder::from_definition(def)?.build().await?; let network_id = network.uid; trace!(network_id = %network_id, "network uid"); diff --git a/crates/wasmflow/wasmflow-runtime/src/utils/helpers.rs b/crates/wasmflow/wasmflow-runtime/src/utils/helpers.rs index 3e1c175b9..50ae886a5 100644 --- a/crates/wasmflow/wasmflow-runtime/src/utils/helpers.rs +++ b/crates/wasmflow/wasmflow-runtime/src/utils/helpers.rs @@ -2,10 +2,6 @@ use seeded_random::{Random, Seed}; use crate::dev::prelude::*; -pub(crate) fn keypair_from_seed(seed: &str) -> Result { - KeyPair::from_seed(seed).map_err(|_| crate::Error::KeyPairFailed) -} - #[must_use] pub(crate) fn new_seed() -> Seed { Random::new().seed() diff --git a/crates/wasmflow/wasmflow-runtime/tests/main.rs b/crates/wasmflow/wasmflow-runtime/tests/main.rs deleted file mode 100644 index abebd8f4d..000000000 --- a/crates/wasmflow/wasmflow-runtime/tests/main.rs +++ /dev/null @@ -1,52 +0,0 @@ -use std::time::{SystemTime, UNIX_EPOCH}; - -use runtime_testutils::*; -use tracing::debug; -type Result = anyhow::Result; -use pretty_assertions::assert_eq; - -#[ignore = "main implementation is changing. These may be reused or deleted."] -#[test_logger::test(tokio::test)] -async fn basic_main_impl() -> Result<()> { - let argv = vec!["test_file.txt".to_owned()]; - - let tempdir = std::env::temp_dir(); - let tempfile = tempdir.join("test_file.txt"); - let now = SystemTime::now(); - let time = now.duration_since(UNIX_EPOCH).unwrap().as_millis().to_string(); - debug!("Writing '{}' to test file {:?}", time, tempfile); - std::fs::write(&tempfile, &time).unwrap(); - std::env::set_var("TEST_TEMPDIR", tempdir); - - let (network, _) = init_network_from_yaml("./manifests/v0/main.wafl").await?; - let result = network.exec_main(argv).await; - - std::env::remove_var("TEST_TEMPDIR"); - - assert_eq!(result, 0); - - Ok(()) -} - -#[ignore = "main implementation is changing. These may be reused or deleted."] -#[test_logger::test(tokio::test)] -async fn main_impl_with_network_call() -> Result<()> { - let argv = vec!["test_file.txt".to_owned()]; - - let tempdir = std::env::temp_dir(); - let tempfile = tempdir.join("test_file.txt"); - let now = SystemTime::now(); - let time = now.duration_since(UNIX_EPOCH).unwrap().as_millis().to_string(); - debug!("Writing '{}' to test file {:?}", time, tempfile); - std::fs::write(&tempfile, &time).unwrap(); - std::env::set_var("TEST_TEMPDIR", tempdir); - - let (network, _) = init_network_from_yaml("./manifests/v0/main-with-network.wafl").await?; - let result = network.exec_main(argv).await; - - std::env::remove_var("TEST_TEMPDIR"); - - assert_eq!(result, 0); - - Ok(()) -} diff --git a/crates/wasmflow/wasmflow-runtime/tests/runtime_utils/Cargo.toml b/crates/wasmflow/wasmflow-runtime/tests/runtime_utils/Cargo.toml index 50eb1b55d..9c52f8182 100644 --- a/crates/wasmflow/wasmflow-runtime/tests/runtime_utils/Cargo.toml +++ b/crates/wasmflow/wasmflow-runtime/tests/runtime_utils/Cargo.toml @@ -10,7 +10,6 @@ license = "BSD-3-Clause" [dependencies] wasmflow-runtime = { path = "../../../wasmflow-runtime" } wasmflow-mesh = { path = "../../../wasmflow-mesh" } -wasmflow-wascap = { path = "../../../wasmflow-wascap" } wasmflow-manifest = { path = "../../../wasmflow-manifest" } tracing = "0.1" anyhow = "1.0" diff --git a/crates/wasmflow/wasmflow-runtime/tests/runtime_utils/src/lib.rs b/crates/wasmflow/wasmflow-runtime/tests/runtime_utils/src/lib.rs index 6863d082c..1a62031cc 100644 --- a/crates/wasmflow/wasmflow-runtime/tests/runtime_utils/src/lib.rs +++ b/crates/wasmflow/wasmflow-runtime/tests/runtime_utils/src/lib.rs @@ -87,16 +87,15 @@ use wasmflow_manifest::WasmflowManifest; use wasmflow_runtime::{Network, NetworkBuilder}; -use wasmflow_wascap::KeyPair; + #[macro_use] extern crate tracing; pub async fn init_network_from_yaml(path: &str) -> anyhow::Result<(Network, uuid::Uuid)> { let host_def = WasmflowManifest::load_from_file(path)?; debug!("Manifest loaded"); - let kp = KeyPair::new_server(); - let builder = NetworkBuilder::from_definition(host_def, &kp.seed()?)?; + let builder = NetworkBuilder::from_definition(host_def)?; let network = builder.build().await?;