Compare commits

...

3 Commits

Author SHA1 Message Date
6444b300b3 version: 1.0.63 2026-03-15 23:03:15 -04:00
c529c8b8ea added jspg_schemas for mixer 2026-03-15 23:03:03 -04:00
2f15ae3d41 version: 1.0.62 2026-03-15 10:10:19 -04:00
3 changed files with 34 additions and 1 deletions

View File

@ -110,6 +110,23 @@ pub fn jspg_validate(schema_id: &str, instance: JsonB) -> JsonB {
}
}
#[cfg_attr(not(test), pg_extern)]
pub fn jspg_schemas() -> JsonB {
let engine_opt = {
let lock = GLOBAL_JSPG.read().unwrap();
lock.clone()
};
match engine_opt {
Some(engine) => {
let schemas_json = serde_json::to_value(&engine.database.schemas)
.unwrap_or(serde_json::Value::Object(serde_json::Map::new()));
JsonB(schemas_json)
}
None => JsonB(serde_json::Value::Object(serde_json::Map::new())),
}
}
#[cfg_attr(not(test), pg_extern)]
pub fn jspg_stems() -> JsonB {
let engine_opt = {

View File

@ -49,6 +49,22 @@ fn test_library_api() {
})
);
// 3. Validate jspg_schemas
let schemas_drop = jspg_schemas();
assert_eq!(
schemas_drop.0,
json!({
"test_schema": {
"$id": "test_schema",
"type": "object",
"properties": {
"name": { "type": "string" }
},
"required": ["name"]
}
})
);
// 4. Validate Happy Path
let happy_drop = jspg_validate("test_schema", JsonB(json!({"name": "Neo"})));
assert_eq!(

View File

@ -1 +1 @@
1.0.61
1.0.63