feat: policy dictionary (#479)

* feat: policy dictionary

* remove enum references

* improve tests

* reset index.js and package.json
This commit is contained in:
stefan-gorules
2026-07-08 13:21:03 +02:00
committed by GitHub
parent d3cd7ccad9
commit b4b59eb7c5
23 changed files with 2112 additions and 1145 deletions
+33
View File
@@ -103,6 +103,19 @@ pub struct PolicyGlobalInfo {
pub origin: Value,
}
#[napi(object)]
pub struct PolicyDictionaryInfo {
pub name: String,
pub source: String,
pub entries: Vec<PolicyDictionaryEntryInfo>,
}
#[napi(object)]
pub struct PolicyDictionaryEntryInfo {
pub value: String,
pub label: String,
}
#[napi(object)]
pub struct PolicyInputProperty {
pub path: String,
@@ -540,6 +553,26 @@ impl PolicyWorkspace {
.collect()
}
#[napi]
pub fn dictionaries(&self, req: PolicyScopeRequest) -> Vec<PolicyDictionaryInfo> {
self.inner
.dictionaries(&req.into())
.into_iter()
.map(|d| PolicyDictionaryInfo {
name: d.name.to_string(),
source: d.source.to_string(),
entries: d
.entries
.iter()
.map(|e| PolicyDictionaryEntryInfo {
value: e.value.to_string(),
label: e.label.to_string(),
})
.collect(),
})
.collect()
}
#[napi]
pub fn inputs(&self, req: PolicyScopeRequest) -> Vec<PolicyInputProperty> {
self.inner