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 Sep 1, 2023
2 parents 2d466fa + 6b996e8 commit eb4d81f
Show file tree
Hide file tree
Showing 47 changed files with 1,192 additions and 694 deletions.
4 changes: 4 additions & 0 deletions lib/dal/src/builtins/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ pub async fn migrate_for_tests(
ctx.blocking_commit().await?;
}
} else if migrate_test_exclusive {
// We migrate generic frame to get "si:resourceToPayloadValue" cheaply. This function
// should be converted to an intrinsic (or removed?)
migrate_pkg(ctx, super::SI_GENERIC_FRAME_PKG, None).await?;
for test_schema in [BuiltinSchema::Starfield, BuiltinSchema::Fallout] {
migrate_schema(ctx, test_schema, &driver).await?;
ctx.blocking_commit().await?;
Expand All @@ -120,6 +123,7 @@ pub async fn migrate_for_tests(
migrate_pkg(ctx, super::SI_AWS_EC2_PKG, Some(schemas.to_owned())).await?;
migrate_pkg(ctx, super::SI_COREOS_PKG, Some(schemas.to_owned())).await?;
migrate_pkg(ctx, super::SI_DOCKER_IMAGE_PKG, Some(schemas.to_owned())).await?;
migrate_pkg(ctx, super::SI_GENERIC_FRAME_PKG, Some(schemas.to_owned())).await?;
for test_schema in [BuiltinSchema::Starfield, BuiltinSchema::Fallout] {
if specific_builtin_schemas.contains(test_schema.real_schema_name()) {
migrate_schema(ctx, test_schema, &driver).await?;
Expand Down
81 changes: 55 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,19 @@ 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()
.name(fn_name)
.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 +61,56 @@ 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()
.name(fn_name)
.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()
.name(fn_name)
.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()
.name(fn_name)
.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 +127,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 +177,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 +191,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 +204,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
121 changes: 82 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,40 @@ 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()
.name(fn_name)
.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()
.name(fn_name)
.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 +121,19 @@ 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()
.name(fn_name)
.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 +146,38 @@ 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()
.name(fn_name)
.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()
.name(fn_name)
.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 +194,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 +226,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 +245,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 +291,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 eb4d81f

Please sign in to comment.