mirror of
https://github.com/gorules/zen.git
synced 2026-10-04 16:02:18 +00:00
feat: policy dictionary (#479)
* feat: policy dictionary * remove enum references * improve tests * reset index.js and package.json
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user