/* * Copyright (c) 2022-2025 Niko Bonnieure, Par le Peuple, NextGraph.org developers * All rights reserved. * Licensed under the Apache License, Version 2.0 * * or the MIT license , * at your option. All files in the project carrying such * notice may not be copied, modified, or distributed except * according to those terms. */ #![allow(non_snake_case)] use std::{collections::HashMap, sync::Arc}; use serde::{Deserialize, Serialize}; use serde_json::Value; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct OrmShapeType { pub schema: OrmSchema, pub shape: String, } /* == Diff Types == */ #[derive(Clone, Debug, Serialize, Deserialize)] #[allow(non_camel_case_types)] pub enum OrmDiffOpType { add, remove, } #[derive(Clone, Debug, Serialize, Deserialize)] #[allow(non_camel_case_types)] pub enum OrmDiffType { set, object, } #[derive(Clone, Debug, Serialize, Deserialize)] pub struct OrmDiffOp { pub op: OrmDiffOpType, pub valType: Option, pub path: String, pub value: Option, // TODO: Improve type } pub type OrmDiff = Vec; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct OrmUpdateBlankNodeId { pub path: String, pub nuri: String, } pub type OrmUpdateBlankNodeIds = Vec; pub type OrmSchema = HashMap>; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct OrmSchemaShape { pub iri: String, pub predicates: Vec>, } #[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)] #[allow(non_camel_case_types)] pub enum OrmSchemaLiteralType { number, string, boolean, iri, literal, shape, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(untagged)] pub enum BasicType { Bool(bool), Num(f64), Str(String), } #[derive(Clone, Debug, Serialize, Deserialize)] pub struct OrmSchemaDataType { pub valType: OrmSchemaLiteralType, pub literals: Option>, pub shape: Option, } #[derive(Clone, Debug, Serialize, Deserialize)] pub struct OrmSchemaPredicate { pub dataTypes: Vec, pub iri: String, pub readablePredicate: String, /// `-1` for infinity pub maxCardinality: i32, pub minCardinality: i32, pub extra: Option, } impl Default for OrmSchemaDataType { fn default() -> Self { Self { literals: None, shape: None, valType: OrmSchemaLiteralType::string, } } } impl Default for OrmSchemaPredicate { fn default() -> Self { Self { dataTypes: Vec::new(), iri: String::new(), readablePredicate: String::new(), maxCardinality: -1, minCardinality: 0, extra: None, } } }