Skip to content

Commit

Permalink
Try #2719:
Browse files Browse the repository at this point in the history
  • Loading branch information
si-bors-ng[bot] authored Aug 31, 2023
2 parents d7b5432 + e675ad3 commit 54e82f0
Show file tree
Hide file tree
Showing 42 changed files with 702 additions and 564 deletions.
77 changes: 51 additions & 26 deletions lib/dal/src/builtins/schema/test_exclusive_fallout.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use si_pkg::FuncSpecData;
use si_pkg::{
ActionFuncSpec, AttrFuncInputSpec, AttrFuncInputSpecKind, FuncArgumentSpec, FuncSpec,
FuncSpecBackendKind, FuncSpecBackendResponseType, LeafFunctionSpec, PkgSpec, PropSpec,
Expand Down Expand Up @@ -36,12 +37,18 @@ impl MigrationDriver {
recommendedActions: [],
}
}";
let fn_name = "test:confirmationFallout";
let fallout_confirmation_func = FuncSpec::builder()
.name("test:confirmationFallout")
.code_plaintext(fallout_confirmation_code)
.backend_kind(FuncSpecBackendKind::JsAttribute)
.response_type(FuncSpecBackendResponseType::Confirmation)
.handler("exists")
.name(fn_name)
.unique_id(fn_name)
.data(
FuncSpecData::builder()
.code_plaintext(fallout_confirmation_code)
.backend_kind(FuncSpecBackendKind::JsAttribute)
.response_type(FuncSpecBackendResponseType::Confirmation)
.handler("exists")
.build()?,
)
.argument(
FuncArgumentSpec::builder()
.name("resource")
Expand All @@ -53,35 +60,53 @@ impl MigrationDriver {
let fallout_create_action_code = "async function create() {
return { payload: { \"poop\": true }, status: \"ok\" };
}";
let fn_name = "test:createActionFallout";
let fallout_create_action_func = FuncSpec::builder()
.name("test:createActionFallout")
.code_plaintext(fallout_create_action_code)
.handler("create")
.backend_kind(FuncSpecBackendKind::JsAction)
.response_type(FuncSpecBackendResponseType::Action)
.name(fn_name)
.unique_id(fn_name)
.data(
FuncSpecData::builder()
.code_plaintext(fallout_create_action_code)
.handler("create")
.backend_kind(FuncSpecBackendKind::JsAction)
.response_type(FuncSpecBackendResponseType::Action)
.build()?,
)
.build()?;

let fallout_scaffold_func = "function createAsset() {\
return new AssetBuilder().build();
}";
let fn_name = "test:scaffoldFalloutAsset";
let fallout_authoring_schema_func = FuncSpec::builder()
.name("test:scaffoldFalloutAsset")
.code_plaintext(fallout_scaffold_func)
.handler("createAsset")
.backend_kind(FuncSpecBackendKind::JsSchemaVariantDefinition)
.response_type(FuncSpecBackendResponseType::SchemaVariantDefinition)
.name(fn_name)
.unique_id(fn_name)
.data(
FuncSpecData::builder()
.code_plaintext(fallout_scaffold_func)
.handler("createAsset")
.backend_kind(FuncSpecBackendKind::JsSchemaVariantDefinition)
.response_type(FuncSpecBackendResponseType::SchemaVariantDefinition)
.build()?,
)
.build()?;

let fallout_resource_payload_to_value_func_code =
"async function translate(arg: Input): Promise<Output> {\
return arg.payload ?? {};
}";
let fn_name = "test:resourcePayloadToValue";
let fallout_resource_payload_to_value_func = FuncSpec::builder()
.name("test:resourcePayloadToValue")
.code_plaintext(fallout_resource_payload_to_value_func_code)
.handler("translate")
.backend_kind(FuncSpecBackendKind::JsAttribute)
.response_type(FuncSpecBackendResponseType::Json)
.name(fn_name)
.unique_id(fn_name)
.data(
FuncSpecData::builder()
.code_plaintext(fallout_resource_payload_to_value_func_code)
.handler("translate")
.backend_kind(FuncSpecBackendKind::JsAttribute)
.response_type(FuncSpecBackendResponseType::Json)
.build()?,
)
.argument(
FuncArgumentSpec::builder()
.name("payload")
Expand All @@ -98,12 +123,12 @@ impl MigrationDriver {
SchemaVariantSpec::builder()
.color("#ffffff")
.name("v0")
.func_unique_id(fallout_authoring_schema_func.unique_id)
.func_unique_id(&fallout_authoring_schema_func.unique_id)
.domain_prop(
PropSpec::builder()
.name("name")
.kind(PropKind::String)
.func_unique_id(identity_func_spec.unique_id)
.func_unique_id(&identity_func_spec.unique_id)
.input(
AttrFuncInputSpec::builder()
.kind(AttrFuncInputSpecKind::Prop)
Expand Down Expand Up @@ -148,7 +173,7 @@ impl MigrationDriver {
SocketSpec::builder()
.name("bethesda")
.kind(SocketSpecKind::Output)
.func_unique_id(identity_func_spec.unique_id)
.func_unique_id(&identity_func_spec.unique_id)
.input(
AttrFuncInputSpec::builder()
.name("identity")
Expand All @@ -162,7 +187,7 @@ impl MigrationDriver {
SocketSpec::builder()
.name("fallout")
.kind(SocketSpecKind::Output)
.func_unique_id(identity_func_spec.unique_id)
.func_unique_id(&identity_func_spec.unique_id)
.input(
AttrFuncInputSpec::builder()
.name("identity")
Expand All @@ -175,14 +200,14 @@ impl MigrationDriver {
.leaf_function(
LeafFunctionSpec::builder()
.leaf_kind(LeafKind::Confirmation)
.func_unique_id(fallout_confirmation_func.unique_id)
.func_unique_id(&fallout_confirmation_func.unique_id)
.inputs(vec![LeafInputLocation::Resource.into()])
.build()?,
)
.action_func(
ActionFuncSpec::builder()
.kind(&ActionKind::Create)
.func_unique_id(fallout_create_action_func.unique_id)
.func_unique_id(&fallout_create_action_func.unique_id)
.build()?,
)
.build()?,
Expand Down
116 changes: 77 additions & 39 deletions lib/dal/src/builtins/schema/test_exclusive_starfield.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use si_pkg::{
ActionFuncSpec, AttrFuncInputSpec, AttrFuncInputSpecKind, FuncArgumentSpec, FuncSpec,
FuncSpecBackendKind, FuncSpecBackendResponseType, LeafFunctionSpec, PkgSpec, PropSpec,
SchemaSpec, SchemaVariantSpec, SiPkg, SocketSpec, SocketSpecKind,
FuncSpecBackendKind, FuncSpecBackendResponseType, FuncSpecData, LeafFunctionSpec, PkgSpec,
PropSpec, SchemaSpec, SchemaVariantSpec, SiPkg, SocketSpec, SocketSpecKind,
};

use crate::func::argument::FuncArgumentKind;
Expand Down Expand Up @@ -37,12 +37,19 @@ impl MigrationDriver {
}
}";

let fn_name = "test:confirmationStarfield";
let starfield_confirmation_func = FuncSpec::builder()
.name("test:confirmationStarfield")
.code_plaintext(starfield_confirmation_code)
.backend_kind(FuncSpecBackendKind::JsAttribute)
.response_type(FuncSpecBackendResponseType::Confirmation)
.handler("exists")
.name(fn_name)
.unique_id(fn_name)
.data(
FuncSpecData::builder()
.name(fn_name)
.code_plaintext(starfield_confirmation_code)
.backend_kind(FuncSpecBackendKind::JsAttribute)
.response_type(FuncSpecBackendResponseType::Confirmation)
.handler("exists")
.build()?,
)
.argument(
FuncArgumentSpec::builder()
.name("resource")
Expand All @@ -54,25 +61,38 @@ impl MigrationDriver {
let starfield_create_action_code = "async function create() {
return { payload: { \"poop\": true }, status: \"ok\" };
}";

let fn_name = "test:createActionStarfield";
let starfield_create_action_func = FuncSpec::builder()
.name("test:createActionStarfield")
.code_plaintext(starfield_create_action_code)
.handler("create")
.backend_kind(FuncSpecBackendKind::JsAction)
.response_type(FuncSpecBackendResponseType::Action)
.name(fn_name)
.unique_id(fn_name)
.data(
FuncSpecData::builder()
.code_plaintext(starfield_create_action_code)
.handler("create")
.backend_kind(FuncSpecBackendKind::JsAction)
.response_type(FuncSpecBackendResponseType::Action)
.build()?,
)
.build()?;

let starfield_refresh_action_code =
"async function refresh(component: Input): Promise<Output> {
return { payload: { \"poop\": true }, status: \"ok\" };
}";

let fn_name = "test:refreshActionStarfield";
let starfield_refresh_action_func = FuncSpec::builder()
.name("test:refreshActionStarfield")
.handler("refresh")
.code_plaintext(starfield_refresh_action_code)
.backend_kind(FuncSpecBackendKind::JsAction)
.response_type(FuncSpecBackendResponseType::Action)
.name(fn_name)
.unique_id(fn_name)
.data(
FuncSpecData::builder()
.handler("refresh")
.code_plaintext(starfield_refresh_action_code)
.backend_kind(FuncSpecBackendKind::JsAction)
.response_type(FuncSpecBackendResponseType::Action)
.build()?,
)
.build()?;

let fallout_entries_to_galaxies_transform_code =
Expand All @@ -99,12 +119,18 @@ impl MigrationDriver {
return galaxies;
}";
let fn_name = "test:falloutEntriesToGalaxies";
let fallout_entries_to_galaxies_transform_func = FuncSpec::builder()
.name("test:falloutEntriesToGalaxies")
.code_plaintext(fallout_entries_to_galaxies_transform_code)
.handler("falloutEntriesToGalaxies")
.backend_kind(FuncSpecBackendKind::JsAttribute)
.response_type(FuncSpecBackendResponseType::Array)
.name(fn_name)
.unique_id(fn_name)
.data(
FuncSpecData::builder()
.code_plaintext(fallout_entries_to_galaxies_transform_code)
.handler("falloutEntriesToGalaxies")
.backend_kind(FuncSpecBackendKind::JsAttribute)
.response_type(FuncSpecBackendResponseType::Array)
.build()?,
)
.argument(
FuncArgumentSpec::builder()
.name("entries")
Expand All @@ -117,24 +143,36 @@ impl MigrationDriver {
let starfield_scaffold_func = "function createAsset() {\
return new AssetBuilder().build();
}";
let fn_name = "test:scaffoldStarfieldAsset";
let starfield_authoring_schema_func = FuncSpec::builder()
.name("test:scaffoldStarfieldAsset")
.code_plaintext(starfield_scaffold_func)
.handler("createAsset")
.backend_kind(FuncSpecBackendKind::JsSchemaVariantDefinition)
.response_type(FuncSpecBackendResponseType::SchemaVariantDefinition)
.name(fn_name)
.unique_id(fn_name)
.data(
FuncSpecData::builder()
.code_plaintext(starfield_scaffold_func)
.handler("createAsset")
.backend_kind(FuncSpecBackendKind::JsSchemaVariantDefinition)
.response_type(FuncSpecBackendResponseType::SchemaVariantDefinition)
.build()?,
)
.build()?;

let starfield_resource_payload_to_value_func_code =
"async function translate(arg: Input): Promise<Output> {\
return arg.payload ?? {};
}";
let fn_name = "test:resourcePayloadToValue";
let starfield_resource_payload_to_value_func = FuncSpec::builder()
.name("test:resourcePayloadToValue")
.code_plaintext(starfield_resource_payload_to_value_func_code)
.handler("translate")
.backend_kind(FuncSpecBackendKind::JsAttribute)
.response_type(FuncSpecBackendResponseType::Json)
.name(fn_name)
.unique_id(fn_name)
.data(
FuncSpecData::builder()
.code_plaintext(starfield_resource_payload_to_value_func_code)
.handler("translate")
.backend_kind(FuncSpecBackendKind::JsAttribute)
.response_type(FuncSpecBackendResponseType::Json)
.build()?,
)
.argument(
FuncArgumentSpec::builder()
.name("payload")
Expand All @@ -151,12 +189,12 @@ impl MigrationDriver {
SchemaVariantSpec::builder()
.color("#ffffff")
.name("v0")
.func_unique_id(starfield_authoring_schema_func.unique_id)
.func_unique_id(&starfield_authoring_schema_func.unique_id)
.domain_prop(
PropSpec::builder()
.name("name")
.kind(PropKind::String)
.func_unique_id(identity_func_spec.unique_id)
.func_unique_id(&identity_func_spec.unique_id)
.input(
AttrFuncInputSpec::builder()
.kind(AttrFuncInputSpecKind::Prop)
Expand All @@ -183,7 +221,7 @@ impl MigrationDriver {
PropSpec::builder()
.name("attributes")
.kind(PropKind::String)
.func_unique_id(identity_func_spec.unique_id)
.func_unique_id(&identity_func_spec.unique_id)
.input(
AttrFuncInputSpec::builder()
.kind(AttrFuncInputSpecKind::InputSocket)
Expand All @@ -202,7 +240,7 @@ impl MigrationDriver {
.name("galaxies")
.kind(PropKind::Array)
.func_unique_id(
fallout_entries_to_galaxies_transform_func.unique_id,
&fallout_entries_to_galaxies_transform_func.unique_id,
)
.input(
AttrFuncInputSpec::builder()
Expand Down Expand Up @@ -248,20 +286,20 @@ impl MigrationDriver {
.leaf_function(
LeafFunctionSpec::builder()
.leaf_kind(LeafKind::Confirmation)
.func_unique_id(starfield_confirmation_func.unique_id)
.func_unique_id(&starfield_confirmation_func.unique_id)
.inputs(vec![LeafInputLocation::Resource.into()])
.build()?,
)
.action_func(
ActionFuncSpec::builder()
.kind(&ActionKind::Create)
.func_unique_id(starfield_create_action_func.unique_id)
.func_unique_id(&starfield_create_action_func.unique_id)
.build()?,
)
.action_func(
ActionFuncSpec::builder()
.kind(&ActionKind::Refresh)
.func_unique_id(starfield_refresh_action_func.unique_id)
.func_unique_id(&starfield_refresh_action_func.unique_id)
.build()?,
)
.build()?,
Expand Down
Loading

0 comments on commit 54e82f0

Please sign in to comment.