Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rust/contracts/application-boundary.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ verification scripts are the executable source of boundary checks.

## Source-backed plugin settings

Source-backed plugin settings use `sourceSettings: 0` and the three
Source-backed plugin settings use `sourceSettings: 0` (version 1 adds module
sidebars, field sections and typed entry lists) and the three
`plugins.settings.source*` commands. Plugins supply only allowlisted non-sensitive
fields from their upstream configuration; Core validates and projects the form,
inheritance and confirmed edits. Native adapters capture workspace identity,
Expand Down
46 changes: 46 additions & 0 deletions rust/crates/core/src/tests/plugin_source_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,49 @@ fn source_editor_actions_require_explicit_host_capability_and_keep_their_binding
assert_eq!(plan["data"]["plan"]["function"], "compiler.settings");
assert_eq!(plan["data"]["plan"]["params"], json!({}));
}

#[test]
fn module_structure_editors_need_source_settings_version_one() {
let fixture: Value = serde_json::from_str(include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../fixtures/plugins/settings-sources-modules.json"
)))
.unwrap();
let run = |command: &str, payload: Value| -> Value {
serde_json::from_str(&crate::execute_json(
&json!({"command":command,"payload":payload}).to_string(),
))
.unwrap()
};
let state = run(
"plugins.settings.sourceState",
json!({"result":fixture["snapshot"]}),
);
assert_eq!(state["data"]["status"], "ok", "{state}");
assert_eq!(
state["data"]["state"]["inputs"]["app"]["roots"]["entries"][1]["attributes"]["test"],
true
);
// A plugin that projects sidebars, sections or entry lists requires
// version 1; a host that only offers version 0 refuses to install it.
let mut manifest: Value = serde_json::from_str(include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../../shared/plugins/contract/v1/fixtures/settings/source-editor.plugin.json"
)))
.unwrap();
manifest["requires"]["sourceSettings"] = json!(1);
let host = |versions: Value| json!({"backend":[0],"languages":[0],"settings":[0],"sourceSettings":versions});
let refused = run(
"plugins.declarative.validate",
json!({"manifest":manifest,"hostCapabilities":host(json!([0]))}),
);
assert_eq!(
refused["data"]["error"]["code"], "plugin.api.unsupported",
"{refused}"
);
let accepted = run(
"plugins.declarative.validate",
json!({"manifest":manifest,"hostCapabilities":host(json!([0, 1]))}),
);
assert_eq!(accepted["data"]["status"], "ok", "{accepted}");
}
2 changes: 1 addition & 1 deletion rust/crates/plugin-model/src/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub const SUPPORTED_CAPABILITIES: &[(&str, &[u32])] = &[
(PLUGIN_FUNCTIONS, &[0]),
(PROJECT_GENERATORS, &[0]),
(SETTINGS, &[0]),
(SOURCE_SETTINGS, &[0]),
(SOURCE_SETTINGS, &[0, 1]),
(TOOL_DEFINITIONS, &[0]),
(TOOLCHAIN_PROVIDERS, &[0]),
(UI, &[0]),
Expand Down
Loading
Loading