chore: JSPG Engine tuple decoupling and core routing optimizations

This commit is contained in:
2026-04-13 22:41:32 -04:00
parent 665a821bf9
commit 0017c598e1
57 changed files with 5510 additions and 5166 deletions

View File

@ -142,11 +142,21 @@ impl Merger {
if let Some(disc) = schema.obj.compiled_discriminator.get() {
let val = map.get(disc).and_then(|v| v.as_str());
if let Some(v) = val {
if let Some(target_id) = options.get(v) {
if let Some(target_schema) = self.db.schemas.get(target_id) {
schema = Arc::clone(target_schema);
if let Some((idx_opt, target_id_opt)) = options.get(v) {
if let Some(target_id) = target_id_opt {
if let Some(target_schema) = self.db.schemas.get(target_id) {
schema = Arc::clone(target_schema);
} else {
return Err(format!("Polymorphic mapped target '{}' not found in database registry", target_id));
}
} else if let Some(idx) = idx_opt {
if let Some(target_schema) = schema.obj.one_of.as_ref().and_then(|options| options.get(*idx)) {
schema = Arc::clone(target_schema);
} else {
return Err(format!("Polymorphic index target '{}' not found in local oneOf array", idx));
}
} else {
return Err(format!("Polymorphic mapped target '{}' not found in database registry", target_id));
return Err(format!("Polymorphic mapped target has no path"));
}
} else {
return Err(format!("Polymorphic discriminator {}='{}' matched no compiled options", disc, v));
@ -215,7 +225,7 @@ impl Merger {
for (k, v) in obj {
// Always retain system and unmapped core fields natively implicitly mapped to the Postgres tables
if k == "id" || k == "type" || k == "created" {
entity_fields.insert(k.clone(), v.clone());
entity_fields.insert(k, v);
continue;
}
@ -234,18 +244,18 @@ impl Merger {
_ => "field", // Malformed edge data?
};
if typeof_v == "object" {
entity_objects.insert(k.clone(), (v.clone(), prop_schema.clone()));
entity_objects.insert(k, (v, prop_schema.clone()));
} else if typeof_v == "array" {
entity_arrays.insert(k.clone(), (v.clone(), prop_schema.clone()));
entity_arrays.insert(k, (v, prop_schema.clone()));
} else {
entity_fields.insert(k.clone(), v.clone());
entity_fields.insert(k, v);
}
} else {
// Not an edge! It's a raw Postgres column (e.g., JSONB, text[])
entity_fields.insert(k.clone(), v.clone());
entity_fields.insert(k, v);
}
} else if type_def.fields.contains(&k) {
entity_fields.insert(k.clone(), v.clone());
entity_fields.insert(k, v);
}
}
@ -524,7 +534,7 @@ impl Merger {
entity_change_kind = Some("create".to_string());
let mut new_fields = changes.clone();
let mut new_fields = changes;
new_fields.insert("id".to_string(), id_val);
new_fields.insert("type".to_string(), Value::String(type_name.to_string()));
new_fields.insert("created_by".to_string(), Value::String(user_id.to_string()));
@ -564,7 +574,7 @@ impl Merger {
Some("update".to_string())
};
let mut new_fields = changes.clone();
let mut new_fields = changes;
new_fields.insert(
"id".to_string(),
entity_fetched.as_ref().unwrap().get("id").unwrap().clone(),