orm wasm binding progress

feat/orm
Laurin Weger 4 weeks ago
parent 83e07344a1
commit b8f70f0c47
No known key found for this signature in database
GPG Key ID: 9B372BB0B792770F
  1. 59
      ng-net/src/app_protocol.rs
  2. 23
      ng-net/src/orm.rs
  3. 60
      ng-verifier/src/orm.rs
  4. 191
      pnpm-lock.yaml
  5. 10
      sdk/ng-sdk-js/examples/multi-framework-signals/astro.config.mjs
  6. 3
      sdk/ng-sdk-js/examples/multi-framework-signals/package.json
  7. 9
      sdk/ng-sdk-js/examples/multi-framework-signals/src/ng-mock/wasm-land/shapeHandler.ts
  8. 14
      sdk/ng-sdk-js/ng-signals/src/connector/applyDiff.ts
  9. 119
      sdk/ng-sdk-js/src/lib.rs

@ -222,12 +222,14 @@ impl NuriV0 {
pub fn get_first_commit_ref(&self) -> Result<ObjectRef, NgError> { pub fn get_first_commit_ref(&self) -> Result<ObjectRef, NgError> {
let commit_id = match &self.branch { let commit_id = match &self.branch {
Some(TargetBranchV0::Commits(commits)) => commits.get(0).ok_or(NgError::CommitNotFound)?, Some(TargetBranchV0::Commits(commits)) => {
_ => return Err(NgError::InvalidNuri) commits.get(0).ok_or(NgError::CommitNotFound)?
}
_ => return Err(NgError::InvalidNuri),
}; };
let commit_key = match self.access.get(0) { let commit_key = match self.access.get(0) {
Some(NgAccessV0::Key(key)) => key, Some(NgAccessV0::Key(key)) => key,
_ => return Err(NgError::InvalidNuri) _ => return Err(NgError::InvalidNuri),
}; };
Ok(ObjectRef::from_id_key(*commit_id, commit_key.clone())) Ok(ObjectRef::from_id_key(*commit_id, commit_key.clone()))
} }
@ -335,7 +337,7 @@ impl NuriV0 {
StoreRepoV0::ProtectedStore(id) => NuriV0::protected_profile(id), StoreRepoV0::ProtectedStore(id) => NuriV0::protected_profile(id),
StoreRepoV0::PrivateStore(id) => NuriV0::private_store(id), StoreRepoV0::PrivateStore(id) => NuriV0::private_store(id),
StoreRepoV0::Group(id) => NuriV0::group_store(id), StoreRepoV0::Group(id) => NuriV0::group_store(id),
StoreRepoV0::Dialog((id,_)) => NuriV0::dialog_store(id), StoreRepoV0::Dialog((id, _)) => NuriV0::dialog_store(id),
}, },
} }
} }
@ -514,11 +516,9 @@ impl NuriV0 {
} }
} }
pub fn from_inbox_into_id(from: &String) -> Result<PubKey,NgError> { pub fn from_inbox_into_id(from: &String) -> Result<PubKey, NgError> {
let c = RE_INBOX.captures(&from); let c = RE_INBOX.captures(&from);
if c.is_some() if c.is_some() && c.as_ref().unwrap().get(1).is_some() {
&& c.as_ref().unwrap().get(1).is_some()
{
let cap = c.unwrap(); let cap = c.unwrap();
let d = cap.get(1).unwrap().as_str(); let d = cap.get(1).unwrap().as_str();
let to_inbox = decode_key(d)?; let to_inbox = decode_key(d)?;
@ -529,9 +529,7 @@ impl NuriV0 {
pub fn from_profile_into_overlay_id(from: &String) -> Result<OverlayId, NgError> { pub fn from_profile_into_overlay_id(from: &String) -> Result<OverlayId, NgError> {
let c = RE_PROFILE.captures(&from); let c = RE_PROFILE.captures(&from);
if c.is_some() if c.is_some() && c.as_ref().unwrap().get(1).is_some() {
&& c.as_ref().unwrap().get(1).is_some()
{
let cap = c.unwrap(); let cap = c.unwrap();
let o = cap.get(1).unwrap().as_str(); let o = cap.get(1).unwrap().as_str();
let to_profile_id = decode_key(o)?; let to_profile_id = decode_key(o)?;
@ -562,7 +560,6 @@ impl NuriV0 {
Err(NgError::InvalidNuri) Err(NgError::InvalidNuri)
} }
pub fn new_from_repo_nuri(from: &String) -> Result<Self, NgError> { pub fn new_from_repo_nuri(from: &String) -> Result<Self, NgError> {
let repo_id = Self::from_repo_nuri_to_id(from)?; let repo_id = Self::from_repo_nuri_to_id(from)?;
let mut n = Self::new_empty(); let mut n = Self::new_empty();
@ -570,9 +567,7 @@ impl NuriV0 {
return Ok(n); return Ok(n);
} }
pub fn new_from_commit(from: &String) -> Result<Self, NgError> { pub fn new_from_commit(from: &String) -> Result<Self, NgError> {
let c = RE_COMMIT.captures(&from); let c = RE_COMMIT.captures(&from);
if c.is_some() if c.is_some()
&& c.as_ref().unwrap().get(1).is_some() && c.as_ref().unwrap().get(1).is_some()
@ -659,7 +654,6 @@ impl NuriV0 {
locator: None, locator: None,
}) })
} else { } else {
if let Ok(n) = NuriV0::new_from_repo_graph(from) { if let Ok(n) = NuriV0::new_from_repo_graph(from) {
Ok(n) Ok(n)
} else { } else {
@ -815,7 +809,9 @@ impl AppRequest {
AppRequest::new( AppRequest::new(
AppRequestCommandV0::OrmStart, AppRequestCommandV0::OrmStart,
scope, scope,
Some(AppRequestPayload::V0(AppRequestPayloadV0::OrmStart(shape_type))), Some(AppRequestPayload::V0(AppRequestPayloadV0::OrmStart(
shape_type,
))),
) )
} }
@ -823,12 +819,13 @@ impl AppRequest {
AppRequest::new( AppRequest::new(
AppRequestCommandV0::OrmUpdate, AppRequestCommandV0::OrmUpdate,
scope, scope,
Some(AppRequestPayload::V0(AppRequestPayloadV0::OrmUpdate((diff,shape_type_name)))), Some(AppRequestPayload::V0(AppRequestPayloadV0::OrmUpdate((
diff,
shape_type_name,
)))),
) )
} }
pub fn inbox_post(post: InboxPost) -> Self { pub fn inbox_post(post: InboxPost) -> Self {
AppRequest::new( AppRequest::new(
AppRequestCommandV0::InboxPost, AppRequestCommandV0::InboxPost,
@ -846,22 +843,18 @@ impl AppRequest {
AppRequest::new( AppRequest::new(
AppRequestCommandV0::SocialQueryStart, AppRequestCommandV0::SocialQueryStart,
query, query,
Some(AppRequestPayload::V0(AppRequestPayloadV0::SocialQueryStart{ Some(AppRequestPayload::V0(
from_profile, AppRequestPayloadV0::SocialQueryStart {
contacts, from_profile,
degree contacts,
})), degree,
},
)),
) )
} }
pub fn social_query_cancel( pub fn social_query_cancel(query: NuriV0) -> Self {
query: NuriV0, AppRequest::new(AppRequestCommandV0::SocialQueryCancel, query, None)
) -> Self {
AppRequest::new(
AppRequestCommandV0::SocialQueryCancel,
query,
None
)
} }
pub fn doc_fetch_repo_subscribe(repo_o: String) -> Result<Self, NgError> { pub fn doc_fetch_repo_subscribe(repo_o: String) -> Result<Self, NgError> {
@ -1064,7 +1057,7 @@ pub enum AppRequestPayloadV0 {
QrCodeProfileImport(String), QrCodeProfileImport(String),
OrmStart(OrmShapeType), OrmStart(OrmShapeType),
OrmUpdate((OrmDiff, String)), // ShapeID OrmUpdate((OrmDiff, String)), // ShapeID
OrmStop(String), //ShapeID OrmStop(String), //ShapeID
} }
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]

@ -9,6 +9,8 @@
* according to those terms. * according to those terms.
*/ */
#![allow(non_snake_case)]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::Value; use serde_json::Value;
@ -19,6 +21,25 @@ pub struct OrmShapeType {
} }
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct OrmDiff { #[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<OrmDiffType>,
pub path: String,
pub value: Option<Value>,
}
pub type OrmDiff = Vec<OrmDiffOp>;

@ -12,25 +12,24 @@ use std::collections::HashMap;
use futures::channel::mpsc; use futures::channel::mpsc;
use futures::SinkExt; use futures::SinkExt;
pub use ng_net::orm::OrmShapeType;
pub use ng_net::orm::OrmDiff;
use ng_oxigraph::oxigraph::sparql::{results::*, Query, QueryResults};
use ng_oxigraph::oxrdf::Term;
use ng_oxigraph::oxrdf::Triple;
use ng_repo::log::*;
use ng_net::app_protocol::*; use ng_net::app_protocol::*;
pub use ng_net::orm::OrmDiff;
pub use ng_net::orm::OrmShapeType;
use ng_net::{ use ng_net::{
connection::NoiseFSM, connection::NoiseFSM,
types::*, types::*,
utils::{Receiver, Sender}, utils::{Receiver, Sender},
}; };
use ng_oxigraph::oxigraph::sparql::{results::*, Query, QueryResults};
use ng_oxigraph::oxrdf::Term;
use ng_oxigraph::oxrdf::Triple;
use ng_repo::errors::NgError; use ng_repo::errors::NgError;
use ng_repo::log::*;
use crate::types::*; use crate::types::*;
use crate::verifier::*; use crate::verifier::*;
impl Verifier { impl Verifier {
fn sparql_construct(&self, query: String) -> Result<Vec<Triple>, NgError> { fn sparql_construct(&self, query: String) -> Result<Vec<Triple>, NgError> {
let oxistore = self.graph_dataset.as_ref().unwrap(); let oxistore = self.graph_dataset.as_ref().unwrap();
@ -40,7 +39,8 @@ impl Verifier {
// ); // );
//let base = NuriV0::repo_id(&repo.id); //let base = NuriV0::repo_id(&repo.id);
let parsed = Query::parse(&query, None).map_err(|e| NgError::OxiGraphError(e.to_string()))?; let parsed =
Query::parse(&query, None).map_err(|e| NgError::OxiGraphError(e.to_string()))?;
let results = oxistore let results = oxistore
.query(parsed, None) .query(parsed, None)
.map_err(|e| NgError::OxiGraphError(e.to_string()))?; .map_err(|e| NgError::OxiGraphError(e.to_string()))?;
@ -49,7 +49,10 @@ impl Verifier {
let mut results = vec![]; let mut results = vec![];
for t in triples { for t in triples {
match t { match t {
Err(e) => { log_err!("{}",e.to_string()); return Err(NgError::SparqlError(e.to_string()))}, Err(e) => {
log_err!("{}", e.to_string());
return Err(NgError::SparqlError(e.to_string()));
}
Ok(triple) => results.push(triple), Ok(triple) => results.push(triple),
} }
} }
@ -68,7 +71,8 @@ impl Verifier {
// ); // );
//let base = NuriV0::repo_id(&repo.id); //let base = NuriV0::repo_id(&repo.id);
let parsed = Query::parse(&query, None).map_err(|e| NgError::OxiGraphError(e.to_string()))?; let parsed =
Query::parse(&query, None).map_err(|e| NgError::OxiGraphError(e.to_string()))?;
let results = oxistore let results = oxistore
.query(parsed, None) .query(parsed, None)
.map_err(|e| NgError::OxiGraphError(e.to_string()))?; .map_err(|e| NgError::OxiGraphError(e.to_string()))?;
@ -77,7 +81,10 @@ impl Verifier {
let mut results = vec![]; let mut results = vec![];
for t in sols { for t in sols {
match t { match t {
Err(e) => { log_err!("{}",e.to_string()); return Err(NgError::SparqlError(e.to_string()))}, Err(e) => {
log_err!("{}", e.to_string());
return Err(NgError::SparqlError(e.to_string()));
}
Ok(querysol) => results.push(querysol.values().to_vec()), Ok(querysol) => results.push(querysol.values().to_vec()),
} }
} }
@ -87,15 +94,23 @@ impl Verifier {
} }
} }
pub(crate) async fn orm_update(&mut self, scope: &NuriV0, patch: GraphQuadsPatch) { pub(crate) async fn orm_update(&mut self, scope: &NuriV0, patch: GraphQuadsPatch) {}
}
pub(crate) async fn frontend_update_orm(&mut self, scope: &NuriV0, shape_id: String, diff: OrmDiff) {
pub(crate) async fn frontend_update_orm(
&mut self,
scope: &NuriV0,
shape_id: String,
diff: OrmDiff,
) {
log_info!("frontend_update_orm {:?} {} {:?}", scope, shape_id, diff);
} }
pub(crate) async fn push_orm_response(&mut self, scope: &NuriV0, schema_iri: &String, response: AppResponse) { pub(crate) async fn push_orm_response(
&mut self,
scope: &NuriV0,
schema_iri: &String,
response: AppResponse,
) {
log_info!( log_info!(
"push_orm_response {:?} {} {:?}", "push_orm_response {:?} {} {:?}",
scope, scope,
@ -104,7 +119,7 @@ impl Verifier {
); );
if let Some(shapes) = self.orm_subscriptions.get_mut(scope) { if let Some(shapes) = self.orm_subscriptions.get_mut(scope) {
if let Some(sessions) = shapes.get_mut(schema_iri) { if let Some(sessions) = shapes.get_mut(schema_iri) {
let mut sessions_to_close : Vec<u64> = vec![]; let mut sessions_to_close: Vec<u64> = vec![];
for (session_id, sender) in sessions.iter_mut() { for (session_id, sender) in sessions.iter_mut() {
if sender.is_closed() { if sender.is_closed() {
log_debug!("closed so removing session {}", session_id); log_debug!("closed so removing session {}", session_id);
@ -126,10 +141,15 @@ impl Verifier {
schema: &OrmShapeType, schema: &OrmShapeType,
session_id: u64, session_id: u64,
) -> Result<(Receiver<AppResponse>, CancelFn), NgError> { ) -> Result<(Receiver<AppResponse>, CancelFn), NgError> {
let (tx, rx) = mpsc::unbounded::<AppResponse>(); let (tx, rx) = mpsc::unbounded::<AppResponse>();
self.orm_subscriptions.insert(nuri.clone(), HashMap::from([(schema.iri.clone(), HashMap::from([(session_id, tx.clone())]))])); self.orm_subscriptions.insert(
nuri.clone(),
HashMap::from([(
schema.iri.clone(),
HashMap::from([(session_id, tx.clone())]),
)]),
);
//self.push_orm_response().await; //self.push_orm_response().await;

@ -41,6 +41,9 @@ importers:
'@nextgraph-monorepo/ng-alien-deepsignals': '@nextgraph-monorepo/ng-alien-deepsignals':
specifier: workspace:* specifier: workspace:*
version: link:../../ng-alien-deepsignals version: link:../../ng-alien-deepsignals
'@nextgraph-monorepo/ng-sdk-js':
specifier: workspace:*
version: link:../../pkg
'@nextgraph-monorepo/ng-shex-orm': '@nextgraph-monorepo/ng-shex-orm':
specifier: workspace:* specifier: workspace:*
version: link:../../ng-shex-orm version: link:../../ng-shex-orm
@ -80,6 +83,12 @@ importers:
svelte: svelte:
specifier: 5.38.2 specifier: 5.38.2
version: 5.38.2 version: 5.38.2
vite-plugin-top-level-await:
specifier: ^1.6.0
version: 1.6.0(@swc/helpers@0.5.17)(rollup@4.50.2)(vite@7.1.3(@types/node@24.3.0)(jiti@2.5.1))
vite-plugin-wasm:
specifier: ^3.5.0
version: 3.5.0(vite@7.1.3(@types/node@24.3.0)(jiti@2.5.1))
vue: vue:
specifier: 3.5.19 specifier: 3.5.19
version: 3.5.19(typescript@5.9.2) version: 3.5.19(typescript@5.9.2)
@ -114,7 +123,7 @@ importers:
version: 9.11.1(magicast@0.3.5) version: 9.11.1(magicast@0.3.5)
tsup: tsup:
specifier: ^8.3.5 specifier: ^8.3.5
version: 8.5.0(jiti@2.5.1)(postcss@8.5.6)(typescript@5.9.2) version: 8.5.0(@swc/core@1.13.5(@swc/helpers@0.5.17))(jiti@2.5.1)(postcss@8.5.6)(typescript@5.9.2)
typescript: typescript:
specifier: ^5.4.3 specifier: ^5.4.3
version: 5.9.2 version: 5.9.2
@ -1055,6 +1064,15 @@ packages:
'@rolldown/pluginutils@1.0.0-beta.38': '@rolldown/pluginutils@1.0.0-beta.38':
resolution: {integrity: sha512-N/ICGKleNhA5nc9XXQG/kkKHJ7S55u0x0XUJbbkmdCnFuoRkM1Il12q9q0eX19+M7KKUEPw/daUPIRnxhcxAIw==} resolution: {integrity: sha512-N/ICGKleNhA5nc9XXQG/kkKHJ7S55u0x0XUJbbkmdCnFuoRkM1Il12q9q0eX19+M7KKUEPw/daUPIRnxhcxAIw==}
'@rollup/plugin-virtual@3.0.2':
resolution: {integrity: sha512-10monEYsBp3scM4/ND4LNH5Rxvh3e/cVeL3jWTgZ2SrQ+BmUoQcopVQvnaMcOnykb1VkxUFuDAN+0FnpTFRy2A==}
engines: {node: '>=14.0.0'}
peerDependencies:
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
peerDependenciesMeta:
rollup:
optional: true
'@rollup/pluginutils@5.3.0': '@rollup/pluginutils@5.3.0':
resolution: {integrity: sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==} resolution: {integrity: sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==}
engines: {node: '>=14.0.0'} engines: {node: '>=14.0.0'}
@ -1268,9 +1286,87 @@ packages:
svelte: ^5.0.0 svelte: ^5.0.0
vite: ^6.0.0 vite: ^6.0.0
'@swc/core-darwin-arm64@1.13.5':
resolution: {integrity: sha512-lKNv7SujeXvKn16gvQqUQI5DdyY8v7xcoO3k06/FJbHJS90zEwZdQiMNRiqpYw/orU543tPaWgz7cIYWhbopiQ==}
engines: {node: '>=10'}
cpu: [arm64]
os: [darwin]
'@swc/core-darwin-x64@1.13.5':
resolution: {integrity: sha512-ILd38Fg/w23vHb0yVjlWvQBoE37ZJTdlLHa8LRCFDdX4WKfnVBiblsCU9ar4QTMNdeTBEX9iUF4IrbNWhaF1Ng==}
engines: {node: '>=10'}
cpu: [x64]
os: [darwin]
'@swc/core-linux-arm-gnueabihf@1.13.5':
resolution: {integrity: sha512-Q6eS3Pt8GLkXxqz9TAw+AUk9HpVJt8Uzm54MvPsqp2yuGmY0/sNaPPNVqctCX9fu/Nu8eaWUen0si6iEiCsazQ==}
engines: {node: '>=10'}
cpu: [arm]
os: [linux]
'@swc/core-linux-arm64-gnu@1.13.5':
resolution: {integrity: sha512-aNDfeN+9af+y+M2MYfxCzCy/VDq7Z5YIbMqRI739o8Ganz6ST+27kjQFd8Y/57JN/hcnUEa9xqdS3XY7WaVtSw==}
engines: {node: '>=10'}
cpu: [arm64]
os: [linux]
'@swc/core-linux-arm64-musl@1.13.5':
resolution: {integrity: sha512-9+ZxFN5GJag4CnYnq6apKTnnezpfJhCumyz0504/JbHLo+Ue+ZtJnf3RhyA9W9TINtLE0bC4hKpWi8ZKoETyOQ==}
engines: {node: '>=10'}
cpu: [arm64]
os: [linux]
'@swc/core-linux-x64-gnu@1.13.5':
resolution: {integrity: sha512-WD530qvHrki8Ywt/PloKUjaRKgstQqNGvmZl54g06kA+hqtSE2FTG9gngXr3UJxYu/cNAjJYiBifm7+w4nbHbA==}
engines: {node: '>=10'}
cpu: [x64]
os: [linux]
'@swc/core-linux-x64-musl@1.13.5':
resolution: {integrity: sha512-Luj8y4OFYx4DHNQTWjdIuKTq2f5k6uSXICqx+FSabnXptaOBAbJHNbHT/06JZh6NRUouaf0mYXN0mcsqvkhd7Q==}
engines: {node: '>=10'}
cpu: [x64]
os: [linux]
'@swc/core-win32-arm64-msvc@1.13.5':
resolution: {integrity: sha512-cZ6UpumhF9SDJvv4DA2fo9WIzlNFuKSkZpZmPG1c+4PFSEMy5DFOjBSllCvnqihCabzXzpn6ykCwBmHpy31vQw==}
engines: {node: '>=10'}
cpu: [arm64]
os: [win32]
'@swc/core-win32-ia32-msvc@1.13.5':
resolution: {integrity: sha512-C5Yi/xIikrFUzZcyGj9L3RpKljFvKiDMtyDzPKzlsDrKIw2EYY+bF88gB6oGY5RGmv4DAX8dbnpRAqgFD0FMEw==}
engines: {node: '>=10'}
cpu: [ia32]
os: [win32]
'@swc/core-win32-x64-msvc@1.13.5':
resolution: {integrity: sha512-YrKdMVxbYmlfybCSbRtrilc6UA8GF5aPmGKBdPvjrarvsmf4i7ZHGCEnLtfOMd3Lwbs2WUZq3WdMbozYeLU93Q==}
engines: {node: '>=10'}
cpu: [x64]
os: [win32]
'@swc/core@1.13.5':
resolution: {integrity: sha512-WezcBo8a0Dg2rnR82zhwoR6aRNxeTGfK5QCD6TQ+kg3xx/zNT02s/0o+81h/3zhvFSB24NtqEr8FTw88O5W/JQ==}
engines: {node: '>=10'}
peerDependencies:
'@swc/helpers': '>=0.5.17'
peerDependenciesMeta:
'@swc/helpers':
optional: true
'@swc/counter@0.1.3':
resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==}
'@swc/helpers@0.5.17': '@swc/helpers@0.5.17':
resolution: {integrity: sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A==} resolution: {integrity: sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A==}
'@swc/types@0.1.25':
resolution: {integrity: sha512-iAoY/qRhNH8a/hBvm3zKj9qQ4oc2+3w1unPJa2XvTK3XjeLXtzcCingVPw/9e5mn1+0yPqxcBGp9Jf0pkfMb1g==}
'@swc/wasm@1.13.5':
resolution: {integrity: sha512-ZBZcxieydxNwgEU9eFAXGMaDb1Xoh+ZkZcUQ27LNJzc2lPSByoL6CSVqnYiaVo+n9JgqbYyHlMq+i7z0wRNTfA==}
'@ts-jison/common@0.4.1-alpha.1': '@ts-jison/common@0.4.1-alpha.1':
resolution: {integrity: sha512-SDbHzq+UMD+V3ciKVBHwCEgVqSeyQPTCjOsd/ZNTGySUVg4x3EauR9ZcEfdVFAsYRR38XWgDI+spq5LDY46KvQ==} resolution: {integrity: sha512-SDbHzq+UMD+V3ciKVBHwCEgVqSeyQPTCjOsd/ZNTGySUVg4x3EauR9ZcEfdVFAsYRR38XWgDI+spq5LDY46KvQ==}
@ -4024,6 +4120,10 @@ packages:
util-deprecate@1.0.2: util-deprecate@1.0.2:
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
uuid@10.0.0:
resolution: {integrity: sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==}
hasBin: true
uuid@8.3.2: uuid@8.3.2:
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
hasBin: true hasBin: true
@ -4060,6 +4160,11 @@ packages:
'@nuxt/kit': '@nuxt/kit':
optional: true optional: true
vite-plugin-top-level-await@1.6.0:
resolution: {integrity: sha512-bNhUreLamTIkoulCR9aDXbTbhLk6n1YE8NJUTTxl5RYskNRtzOR0ASzSjBVRtNdjIfngDXo11qOsybGLNsrdww==}
peerDependencies:
vite: '>=2.8'
vite-plugin-vue-devtools@7.7.7: vite-plugin-vue-devtools@7.7.7:
resolution: {integrity: sha512-d0fIh3wRcgSlr4Vz7bAk4va1MkdqhQgj9ANE/rBhsAjOnRfTLs2ocjFMvSUOsv6SRRXU9G+VM7yMgqDb6yI4iQ==} resolution: {integrity: sha512-d0fIh3wRcgSlr4Vz7bAk4va1MkdqhQgj9ANE/rBhsAjOnRfTLs2ocjFMvSUOsv6SRRXU9G+VM7yMgqDb6yI4iQ==}
engines: {node: '>=v14.21.3'} engines: {node: '>=v14.21.3'}
@ -4071,6 +4176,11 @@ packages:
peerDependencies: peerDependencies:
vite: ^3.0.0-0 || ^4.0.0-0 || ^5.0.0-0 || ^6.0.0-0 || ^7.0.0-0 vite: ^3.0.0-0 || ^4.0.0-0 || ^5.0.0-0 || ^6.0.0-0 || ^7.0.0-0
vite-plugin-wasm@3.5.0:
resolution: {integrity: sha512-X5VWgCnqiQEGb+omhlBVsvTfxikKtoOgAzQ95+BZ8gQ+VfMHIjSHr0wyvXFQCa0eKQ0fKyaL0kWcEnYqBac4lQ==}
peerDependencies:
vite: ^2 || ^3 || ^4 || ^5 || ^6 || ^7
vite@6.3.6: vite@6.3.6:
resolution: {integrity: sha512-0msEVHJEScQbhkbVTb/4iHZdJ6SXp/AvxL2sjwYQFfBqleHtnCqv1J3sa9zbWz/6kW1m9Tfzn92vW+kZ1WV6QA==} resolution: {integrity: sha512-0msEVHJEScQbhkbVTb/4iHZdJ6SXp/AvxL2sjwYQFfBqleHtnCqv1J3sa9zbWz/6kW1m9Tfzn92vW+kZ1WV6QA==}
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
@ -5334,6 +5444,10 @@ snapshots:
'@rolldown/pluginutils@1.0.0-beta.38': {} '@rolldown/pluginutils@1.0.0-beta.38': {}
'@rollup/plugin-virtual@3.0.2(rollup@4.50.2)':
optionalDependencies:
rollup: 4.50.2
'@rollup/pluginutils@5.3.0(rollup@4.50.2)': '@rollup/pluginutils@5.3.0(rollup@4.50.2)':
dependencies: dependencies:
'@types/estree': 1.0.8 '@types/estree': 1.0.8
@ -5534,10 +5648,65 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
'@swc/core-darwin-arm64@1.13.5':
optional: true
'@swc/core-darwin-x64@1.13.5':
optional: true
'@swc/core-linux-arm-gnueabihf@1.13.5':
optional: true
'@swc/core-linux-arm64-gnu@1.13.5':
optional: true
'@swc/core-linux-arm64-musl@1.13.5':
optional: true
'@swc/core-linux-x64-gnu@1.13.5':
optional: true
'@swc/core-linux-x64-musl@1.13.5':
optional: true
'@swc/core-win32-arm64-msvc@1.13.5':
optional: true
'@swc/core-win32-ia32-msvc@1.13.5':
optional: true
'@swc/core-win32-x64-msvc@1.13.5':
optional: true
'@swc/core@1.13.5(@swc/helpers@0.5.17)':
dependencies:
'@swc/counter': 0.1.3
'@swc/types': 0.1.25
optionalDependencies:
'@swc/core-darwin-arm64': 1.13.5
'@swc/core-darwin-x64': 1.13.5
'@swc/core-linux-arm-gnueabihf': 1.13.5
'@swc/core-linux-arm64-gnu': 1.13.5
'@swc/core-linux-arm64-musl': 1.13.5
'@swc/core-linux-x64-gnu': 1.13.5
'@swc/core-linux-x64-musl': 1.13.5
'@swc/core-win32-arm64-msvc': 1.13.5
'@swc/core-win32-ia32-msvc': 1.13.5
'@swc/core-win32-x64-msvc': 1.13.5
'@swc/helpers': 0.5.17
'@swc/counter@0.1.3': {}
'@swc/helpers@0.5.17': '@swc/helpers@0.5.17':
dependencies: dependencies:
tslib: 2.8.1 tslib: 2.8.1
'@swc/types@0.1.25':
dependencies:
'@swc/counter': 0.1.3
'@swc/wasm@1.13.5': {}
'@ts-jison/common@0.4.1-alpha.1': {} '@ts-jison/common@0.4.1-alpha.1': {}
'@ts-jison/lexer@0.4.1-alpha.1': '@ts-jison/lexer@0.4.1-alpha.1':
@ -8761,7 +8930,7 @@ snapshots:
tslib@2.8.1: {} tslib@2.8.1: {}
tsup@8.5.0(jiti@2.5.1)(postcss@8.5.6)(typescript@5.9.2): tsup@8.5.0(@swc/core@1.13.5(@swc/helpers@0.5.17))(jiti@2.5.1)(postcss@8.5.6)(typescript@5.9.2):
dependencies: dependencies:
bundle-require: 5.1.0(esbuild@0.25.9) bundle-require: 5.1.0(esbuild@0.25.9)
cac: 6.7.14 cac: 6.7.14
@ -8781,6 +8950,7 @@ snapshots:
tinyglobby: 0.2.15 tinyglobby: 0.2.15
tree-kill: 1.2.2 tree-kill: 1.2.2
optionalDependencies: optionalDependencies:
'@swc/core': 1.13.5(@swc/helpers@0.5.17)
postcss: 8.5.6 postcss: 8.5.6
typescript: 5.9.2 typescript: 5.9.2
transitivePeerDependencies: transitivePeerDependencies:
@ -8910,6 +9080,8 @@ snapshots:
util-deprecate@1.0.2: {} util-deprecate@1.0.2: {}
uuid@10.0.0: {}
uuid@8.3.2: {} uuid@8.3.2: {}
validate-iri@1.0.1: {} validate-iri@1.0.1: {}
@ -8991,6 +9163,17 @@ snapshots:
- rollup - rollup
- supports-color - supports-color
vite-plugin-top-level-await@1.6.0(@swc/helpers@0.5.17)(rollup@4.50.2)(vite@7.1.3(@types/node@24.3.0)(jiti@2.5.1)):
dependencies:
'@rollup/plugin-virtual': 3.0.2(rollup@4.50.2)
'@swc/core': 1.13.5(@swc/helpers@0.5.17)
'@swc/wasm': 1.13.5
uuid: 10.0.0
vite: 7.1.3(@types/node@24.3.0)(jiti@2.5.1)
transitivePeerDependencies:
- '@swc/helpers'
- rollup
vite-plugin-vue-devtools@7.7.7(rollup@4.50.2)(vite@6.3.6(@types/node@24.3.0)(jiti@2.5.1))(vue@3.5.19(typescript@5.9.2)): vite-plugin-vue-devtools@7.7.7(rollup@4.50.2)(vite@6.3.6(@types/node@24.3.0)(jiti@2.5.1))(vue@3.5.19(typescript@5.9.2)):
dependencies: dependencies:
'@vue/devtools-core': 7.7.7(vite@6.3.6(@types/node@24.3.0)(jiti@2.5.1))(vue@3.5.19(typescript@5.9.2)) '@vue/devtools-core': 7.7.7(vite@6.3.6(@types/node@24.3.0)(jiti@2.5.1))(vue@3.5.19(typescript@5.9.2))
@ -9022,6 +9205,10 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
vite-plugin-wasm@3.5.0(vite@7.1.3(@types/node@24.3.0)(jiti@2.5.1)):
dependencies:
vite: 7.1.3(@types/node@24.3.0)(jiti@2.5.1)
vite@6.3.6(@types/node@24.3.0)(jiti@2.5.1): vite@6.3.6(@types/node@24.3.0)(jiti@2.5.1):
dependencies: dependencies:
esbuild: 0.25.9 esbuild: 0.25.9

@ -4,8 +4,14 @@ import react from "@astrojs/react";
import vue from "@astrojs/vue"; import vue from "@astrojs/vue";
import svelte from "@astrojs/svelte"; import svelte from "@astrojs/svelte";
import wasm from "vite-plugin-wasm";
import topLevelAwait from "vite-plugin-top-level-await";
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({
integrations: [react(), vue(), svelte()], integrations: [react(), vue(), svelte()],
srcDir: "./src/app", srcDir: "./src/app",
vite: {
plugins: [topLevelAwait(), wasm()],
},
}); });

@ -15,7 +15,10 @@
}, },
"dependencies": { "dependencies": {
"@nextgraph-monorepo/ng-signals": "workspace:*", "@nextgraph-monorepo/ng-signals": "workspace:*",
"@nextgraph-monorepo/ng-sdk-js": "workspace:*",
"@astrojs/react": "4.3.0", "@astrojs/react": "4.3.0",
"vite-plugin-wasm": "^3.5.0",
"vite-plugin-top-level-await": "^1.6.0",
"@astrojs/svelte": "7.1.0", "@astrojs/svelte": "7.1.0",
"@astrojs/vue": "^5.1.0", "@astrojs/vue": "^5.1.0",
"@gn8/alien-signals-react": "^0.1.1", "@gn8/alien-signals-react": "^0.1.1",

@ -99,7 +99,7 @@ communicationChannel.addEventListener(
const { type, connectionId, shapeType } = event.data; const { type, connectionId, shapeType } = event.data;
if (type === "Request") { if (type === "Request") {
ng.orm_update("", "", {}, 1);
/* unsub = await ng.orm_start(scope, shapeType, session_id, /* unsub = await ng.orm_start(scope, shapeType, session_id,
async (response) => { async (response) => {
//console.log("GOT APP RESPONSE", response); //console.log("GOT APP RESPONSE", response);
@ -164,3 +164,10 @@ communicationChannel.addEventListener(
); );
} }
); );
ng.orm_update(
"",
"",
[{ op: "add", valType: "set", value: 1, path: "/foo/bar" }],
1
).catch((err) => console.error(err));

@ -3,7 +3,7 @@ import { batch } from "@nextgraph-monorepo/ng-alien-deepsignals";
export type Patch = { export type Patch = {
/** Property path (array indices, object keys, synthetic Set entry ids) from the root to the mutated location. */ /** Property path (array indices, object keys, synthetic Set entry ids) from the root to the mutated location. */
path: string; path: string;
type?: string & {}; valType?: string & {};
value?: unknown; value?: unknown;
} & ( } & (
| SetAddPatch | SetAddPatch
@ -16,7 +16,7 @@ export type Patch = {
export interface SetAddPatch { export interface SetAddPatch {
/** Mutation kind applied at the resolved `path`. */ /** Mutation kind applied at the resolved `path`. */
op: "add"; op: "add";
type: "set"; valType: "set";
/** /**
* New value for set mutations: * New value for set mutations:
* - A single primitive * - A single primitive
@ -34,7 +34,7 @@ export interface SetAddPatch {
export interface SetRemovePatch { export interface SetRemovePatch {
/** Mutation kind applied at the resolved `path`. */ /** Mutation kind applied at the resolved `path`. */
op: "remove"; op: "remove";
type: "set"; valType: "set";
/** /**
* The value(s) to be removed from the set. Either: * The value(s) to be removed from the set. Either:
* - A single primitive / id * - A single primitive / id
@ -46,7 +46,7 @@ export interface SetRemovePatch {
export interface ObjectAddPatch { export interface ObjectAddPatch {
/** Mutation kind applied at the resolved `path`. */ /** Mutation kind applied at the resolved `path`. */
op: "add"; op: "add";
type: "object"; valType: "object";
} }
export interface RemovePatch { export interface RemovePatch {
@ -158,7 +158,7 @@ export function applyDiff(
if (parentVal == null || typeof parentVal !== "object") continue; if (parentVal == null || typeof parentVal !== "object") continue;
// Handle set additions // Handle set additions
if (patch.op === "add" && patch.type === "set") { if (patch.op === "add" && patch.valType === "set") {
const existing = parentVal[key]; const existing = parentVal[key];
// Normalize value // Normalize value
@ -212,7 +212,7 @@ export function applyDiff(
} }
// Handle set removals // Handle set removals
if (patch.op === "remove" && patch.type === "set") { if (patch.op === "remove" && patch.valType === "set") {
const existing = parentVal[key]; const existing = parentVal[key];
const raw = (patch as SetRemovePatch).value; const raw = (patch as SetRemovePatch).value;
if (raw == null) continue; if (raw == null) continue;
@ -229,7 +229,7 @@ export function applyDiff(
} }
// Add object (ensure object exists) // Add object (ensure object exists)
if (patch.op === "add" && patch.type === "object") { if (patch.op === "add" && patch.valType === "object") {
const cur = parentVal[key]; const cur = parentVal[key];
if ( if (
cur === undefined || cur === undefined ||

@ -41,7 +41,10 @@ use ng_repo::utils::{decode_key, decode_priv_key};
use ng_net::app_protocol::*; use ng_net::app_protocol::*;
use ng_net::broker::*; use ng_net::broker::*;
use ng_net::types::{BindAddress, ClientInfo, ClientInfoV0, ClientType, CreateAccountBSP, IP, BootstrapContentV0, InboxPost}; use ng_net::types::{
BindAddress, BootstrapContentV0, ClientInfo, ClientInfoV0, ClientType, CreateAccountBSP,
InboxPost, IP,
};
use ng_net::utils::{ use ng_net::utils::{
decode_invitation_string, parse_ip_and_port_for, retrieve_local_bootstrap, retrieve_local_url, decode_invitation_string, parse_ip_and_port_for, retrieve_local_bootstrap, retrieve_local_url,
spawn_and_log_error, Receiver, ResultSend, Sender, spawn_and_log_error, Receiver, ResultSend, Sender,
@ -55,9 +58,8 @@ use ng_wallet::types::*;
use ng_wallet::*; use ng_wallet::*;
use nextgraph::local_broker::*; use nextgraph::local_broker::*;
use nextgraph::verifier::orm::{OrmDiff, OrmShapeType};
use nextgraph::verifier::CancelFn; use nextgraph::verifier::CancelFn;
use nextgraph::verifier::orm::{OrmShapeType, OrmDiff};
use crate::model::*; use crate::model::*;
@ -73,8 +75,9 @@ pub async fn get_device_name() -> Result<JsValue, JsValue> {
#[wasm_bindgen] #[wasm_bindgen]
pub async fn bootstrap_to_iframe_msgs(bootstrap: JsValue) -> Result<JsValue, JsValue> { pub async fn bootstrap_to_iframe_msgs(bootstrap: JsValue) -> Result<JsValue, JsValue> {
let content: BootstrapContentV0 = serde_wasm_bindgen::from_value::<BootstrapContentV0>(bootstrap) let content: BootstrapContentV0 =
.map_err(|_| "Invalid BootstrapContentV0".to_string())?; serde_wasm_bindgen::from_value::<BootstrapContentV0>(bootstrap)
.map_err(|_| "Invalid BootstrapContentV0".to_string())?;
let iframe_msg = content.to_iframe_msgs(); let iframe_msg = content.to_iframe_msgs();
Ok(serde_wasm_bindgen::to_value(&iframe_msg).unwrap()) Ok(serde_wasm_bindgen::to_value(&iframe_msg).unwrap())
} }
@ -453,8 +456,10 @@ pub async fn sparql_update(
.map_err(|e: NgError| e.to_string())?; .map_err(|e: NgError| e.to_string())?;
match res { match res {
AppResponse::V0(AppResponseV0::Error(e)) => Err(e), AppResponse::V0(AppResponseV0::Error(e)) => Err(e),
AppResponse::V0(AppResponseV0::Commits(commits)) => Ok(serde_wasm_bindgen::to_value(&commits).unwrap()), AppResponse::V0(AppResponseV0::Commits(commits)) => {
_ => Err(NgError::InvalidResponse.to_string()) Ok(serde_wasm_bindgen::to_value(&commits).unwrap())
}
_ => Err(NgError::InvalidResponse.to_string()),
} }
} }
@ -610,26 +615,29 @@ pub async fn rdf_dump(session_id: JsValue) -> Result<String, String> {
/// contacts = did:ng:d:c or a sparql query /// contacts = did:ng:d:c or a sparql query
#[wasm_bindgen] #[wasm_bindgen]
pub async fn social_query_start( pub async fn social_query_start(
session_id: JsValue, session_id: JsValue,
from_profile_nuri: String, from_profile_nuri: String,
query_nuri: String, query_nuri: String,
contacts: String, contacts: String,
degree: JsValue, degree: JsValue,
) -> Result<(), String> { ) -> Result<(), String> {
let session_id: u64 = serde_wasm_bindgen::from_value::<u64>(session_id) let session_id: u64 = serde_wasm_bindgen::from_value::<u64>(session_id)
.map_err(|_| "Invalid session_id".to_string())?; .map_err(|_| "Invalid session_id".to_string())?;
let degree: u16 = serde_wasm_bindgen::from_value::<u16>(degree) let degree: u16 =
.map_err(|_| "Invalid degree".to_string())?; serde_wasm_bindgen::from_value::<u16>(degree).map_err(|_| "Invalid degree".to_string())?;
let query = NuriV0::new_from_commit(&query_nuri).map_err(|e| format!("Invalid query_nuri {e}"))?; let query =
NuriV0::new_from_commit(&query_nuri).map_err(|e| format!("Invalid query_nuri {e}"))?;
let from_profile = match from_profile_nuri.as_str() { let from_profile = match from_profile_nuri.as_str() {
"did:ng:a" => NuriV0::new_public_store_target(), "did:ng:a" => NuriV0::new_public_store_target(),
"did:ng:b" => NuriV0::new_protected_store_target(), "did:ng:b" => NuriV0::new_protected_store_target(),
_ => return Err("Invalid from_profile_nuri".to_string()) _ => return Err("Invalid from_profile_nuri".to_string()),
}; };
if ! (contacts == "did:ng:d:c" || contacts.starts_with("SELECT")) { return Err("Invalid contacts".to_string()); } if !(contacts == "did:ng:d:c" || contacts.starts_with("SELECT")) {
return Err("Invalid contacts".to_string());
}
let mut request = AppRequest::social_query_start(from_profile, query, contacts, degree); let mut request = AppRequest::social_query_start(from_profile, query, contacts, degree);
request.set_session_id(session_id); request.set_session_id(session_id);
@ -1054,21 +1062,21 @@ pub async fn wallet_import(
Ok(serde_wasm_bindgen::to_value(&client).unwrap()) Ok(serde_wasm_bindgen::to_value(&client).unwrap())
} }
#[wasm_bindgen] #[wasm_bindgen]
pub async fn import_contact_from_qrcode( pub async fn import_contact_from_qrcode(
session_id: JsValue, session_id: JsValue,
doc_nuri: String, doc_nuri: String,
qrcode: String, qrcode: String,
) -> Result<(), String> { ) -> Result<(), String> {
let session_id: u64 = serde_wasm_bindgen::from_value::<u64>(session_id) let session_id: u64 = serde_wasm_bindgen::from_value::<u64>(session_id)
.map_err(|_| "Deserialization error of session_id".to_string())?; .map_err(|_| "Deserialization error of session_id".to_string())?;
let mut request = AppRequest::new( let mut request = AppRequest::new(
AppRequestCommandV0::QrCodeProfileImport, AppRequestCommandV0::QrCodeProfileImport,
NuriV0::new_from_repo_nuri(&doc_nuri).map_err(|e| e.to_string())?, NuriV0::new_from_repo_nuri(&doc_nuri).map_err(|e| e.to_string())?,
Some(AppRequestPayload::V0(AppRequestPayloadV0::QrCodeProfileImport(qrcode))), Some(AppRequestPayload::V0(
AppRequestPayloadV0::QrCodeProfileImport(qrcode),
)),
); );
request.set_session_id(session_id); request.set_session_id(session_id);
@ -1103,7 +1111,9 @@ pub async fn get_qrcode_for_profile(
let mut request = AppRequest::new( let mut request = AppRequest::new(
AppRequestCommandV0::QrCodeProfile, AppRequestCommandV0::QrCodeProfile,
nuri, nuri,
Some(AppRequestPayload::V0(AppRequestPayloadV0::QrCodeProfile(size))), Some(AppRequestPayload::V0(AppRequestPayloadV0::QrCodeProfile(
size,
))),
); );
request.set_session_id(session_id); request.set_session_id(session_id);
@ -1455,9 +1465,16 @@ pub async fn doc_create(
let store_repo = serde_wasm_bindgen::from_value::<Option<StoreRepo>>(store_repo) let store_repo = serde_wasm_bindgen::from_value::<Option<StoreRepo>>(store_repo)
.map_err(|_| "Deserialization error of store_repo".to_string())?; .map_err(|_| "Deserialization error of store_repo".to_string())?;
nextgraph::local_broker::doc_create_with_store_repo(session_id, crdt, class_name, destination, store_repo) nextgraph::local_broker::doc_create_with_store_repo(
.await session_id,
.map_err(|e| e.to_string()).map(|nuri| serde_wasm_bindgen::to_value(&nuri).unwrap()) crdt,
class_name,
destination,
store_repo,
)
.await
.map_err(|e| e.to_string())
.map(|nuri| serde_wasm_bindgen::to_value(&nuri).unwrap())
} }
#[cfg(wasmpack_target = "nodejs")] #[cfg(wasmpack_target = "nodejs")]
@ -1479,9 +1496,17 @@ pub async fn doc_create(
let store_repo = serde_wasm_bindgen::from_value::<Option<String>>(store_repo) let store_repo = serde_wasm_bindgen::from_value::<Option<String>>(store_repo)
.map_err(|_| "Deserialization error of store_repo".to_string())?; .map_err(|_| "Deserialization error of store_repo".to_string())?;
nextgraph::local_broker::doc_create(session_id, crdt, class_name, destination, store_type, store_repo) nextgraph::local_broker::doc_create(
.await session_id,
.map_err(|e| e.to_string()).map(|nuri| serde_wasm_bindgen::to_value(&nuri).unwrap()) crdt,
class_name,
destination,
store_type,
store_repo,
)
.await
.map_err(|e| e.to_string())
.map(|nuri| serde_wasm_bindgen::to_value(&nuri).unwrap())
} }
#[wasm_bindgen] #[wasm_bindgen]
@ -1808,13 +1833,15 @@ pub async fn orm_update(
diff: JsValue, diff: JsValue,
session_id: JsValue, session_id: JsValue,
) -> Result<(), String> { ) -> Result<(), String> {
let session_id: u64 = serde_wasm_bindgen::from_value::<u64>(session_id)
.map_err(|_| "Deserialization error of session_id".to_string())?;
let diff: OrmDiff = serde_wasm_bindgen::from_value::<OrmDiff>(diff) let diff: OrmDiff = serde_wasm_bindgen::from_value::<OrmDiff>(diff)
.map_err(|e| format!("Deserialization error of diff {e}"))?; .map_err(|e| format!("Deserialization error of diff {e}"))?;
log_info!("frontend_update_orm {:?}", diff);
let scope: NuriV0 = serde_wasm_bindgen::from_value::<NuriV0>(scope) let scope: NuriV0 = serde_wasm_bindgen::from_value::<NuriV0>(scope)
.map_err(|_| "Deserialization error of scope".to_string())?; .map_err(|_| "Deserialization error of scope".to_string())?;
let mut request = AppRequest::new_orm_update(scope, shapeTypeName, diff); let mut request = AppRequest::new_orm_update(scope, shapeTypeName, diff);
let session_id: u64 = serde_wasm_bindgen::from_value::<u64>(session_id)
.map_err(|_| "Deserialization error of session_id".to_string())?;
request.set_session_id(session_id); request.set_session_id(session_id);
let response = nextgraph::local_broker::app_request(request) let response = nextgraph::local_broker::app_request(request)
.await .await
@ -2074,10 +2101,31 @@ pub async fn user_connect(
.unwrap()) .unwrap())
} }
const EMPTY_IMG: [u8;437] = [137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 150, 0, 0, 0, 150, 8, 6, 0, 0, 0, 60, 1, 113, 226, 0, 0, 0, 4, 103, 65, 77, 65, 0, 0, 177, 143, 11, 252, 97, 5, 0, 0, 0, 1, 115, 82, 71, 66, 1, 217, 201, 44, 127, 0, 0, 0, 32, 99, 72, 82, 77, 0, 0, 122, 38, 0, 0, 128, 132, 0, 0, 250, 0, 0, 0, 128, 232, 0, 0, 117, 48, 0, 0, 234, 96, 0, 0, 58, 152, 0, 0, 23, 112, 156, 186, 81, 60, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 3, 0, 0, 0, 3, 0, 1, 217, 203, 178, 96, 0, 0, 1, 30, 73, 68, 65, 84, 120, 218, 237, 210, 49, 17, 0, 0, 8, 196, 48, 192, 191, 231, 199, 0, 35, 99, 34, 161, 215, 78, 146, 130, 103, 35, 1, 198, 194, 88, 24, 11, 140, 133, 177, 48, 22, 24, 11, 99, 97, 44, 48, 22, 198, 194, 88, 96, 44, 140, 133, 177, 192, 88, 24, 11, 99, 129, 177, 48, 22, 198, 2, 99, 97, 44, 140, 5, 198, 194, 88, 24, 11, 140, 133, 177, 48, 22, 24, 11, 99, 97, 44, 48, 22, 198, 194, 88, 96, 44, 140, 133, 177, 192, 88, 24, 11, 99, 129, 177, 48, 22, 198, 2, 99, 97, 44, 140, 5, 198, 194, 88, 24, 11, 140, 133, 177, 48, 22, 24, 11, 99, 97, 44, 48, 22, 198, 194, 88, 96, 44, 140, 133, 177, 192, 88, 24, 11, 99, 129, 177, 48, 22, 198, 2, 99, 97, 44, 140, 5, 198, 194, 88, 24, 11, 140, 133, 177, 48, 22, 24, 11, 99, 97, 44, 48, 22, 198, 194, 88, 96, 44, 140, 133, 177, 48, 22, 24, 11, 99, 97, 44, 48, 22, 198, 194, 88, 96, 44, 140, 133, 177, 192, 88, 24, 11, 99, 129, 177, 48, 22, 198, 2, 99, 97, 44, 140, 5, 198, 194, 88, 24, 11, 140, 133, 177, 48, 22, 24, 11, 99, 97, 44, 48, 22, 198, 194, 88, 96, 44, 140, 133, 177, 192, 88, 24, 11, 99, 129, 177, 48, 22, 198, 2, 99, 97, 44, 140, 5, 198, 194, 88, 24, 11, 140, 133, 177, 48, 22, 24, 11, 99, 97, 44, 48, 22, 198, 194, 88, 96, 44, 140, 133, 177, 192, 88, 24, 11, 99, 193, 109, 1, 34, 65, 5, 40, 46, 151, 166, 52, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130]; const EMPTY_IMG: [u8; 437] = [
137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 150, 0, 0, 0, 150, 8, 6,
#[wasm_bindgen] 0, 0, 0, 60, 1, 113, 226, 0, 0, 0, 4, 103, 65, 77, 65, 0, 0, 177, 143, 11, 252, 97, 5, 0, 0, 0,
pub async fn gen_wallet_for_test(ngd_peer_id: String)-> Result<JsValue, String> { 1, 115, 82, 71, 66, 1, 217, 201, 44, 127, 0, 0, 0, 32, 99, 72, 82, 77, 0, 0, 122, 38, 0, 0,
128, 132, 0, 0, 250, 0, 0, 0, 128, 232, 0, 0, 117, 48, 0, 0, 234, 96, 0, 0, 58, 152, 0, 0, 23,
112, 156, 186, 81, 60, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 3, 0, 0, 0, 3, 0, 1, 217, 203, 178,
96, 0, 0, 1, 30, 73, 68, 65, 84, 120, 218, 237, 210, 49, 17, 0, 0, 8, 196, 48, 192, 191, 231,
199, 0, 35, 99, 34, 161, 215, 78, 146, 130, 103, 35, 1, 198, 194, 88, 24, 11, 140, 133, 177,
48, 22, 24, 11, 99, 97, 44, 48, 22, 198, 194, 88, 96, 44, 140, 133, 177, 192, 88, 24, 11, 99,
129, 177, 48, 22, 198, 2, 99, 97, 44, 140, 5, 198, 194, 88, 24, 11, 140, 133, 177, 48, 22, 24,
11, 99, 97, 44, 48, 22, 198, 194, 88, 96, 44, 140, 133, 177, 192, 88, 24, 11, 99, 129, 177, 48,
22, 198, 2, 99, 97, 44, 140, 5, 198, 194, 88, 24, 11, 140, 133, 177, 48, 22, 24, 11, 99, 97,
44, 48, 22, 198, 194, 88, 96, 44, 140, 133, 177, 192, 88, 24, 11, 99, 129, 177, 48, 22, 198, 2,
99, 97, 44, 140, 5, 198, 194, 88, 24, 11, 140, 133, 177, 48, 22, 24, 11, 99, 97, 44, 48, 22,
198, 194, 88, 96, 44, 140, 133, 177, 48, 22, 24, 11, 99, 97, 44, 48, 22, 198, 194, 88, 96, 44,
140, 133, 177, 192, 88, 24, 11, 99, 129, 177, 48, 22, 198, 2, 99, 97, 44, 140, 5, 198, 194, 88,
24, 11, 140, 133, 177, 48, 22, 24, 11, 99, 97, 44, 48, 22, 198, 194, 88, 96, 44, 140, 133, 177,
192, 88, 24, 11, 99, 129, 177, 48, 22, 198, 2, 99, 97, 44, 140, 5, 198, 194, 88, 24, 11, 140,
133, 177, 48, 22, 24, 11, 99, 97, 44, 48, 22, 198, 194, 88, 96, 44, 140, 133, 177, 192, 88, 24,
11, 99, 193, 109, 1, 34, 65, 5, 40, 46, 151, 166, 52, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96,
130,
];
#[wasm_bindgen]
pub async fn gen_wallet_for_test(ngd_peer_id: String) -> Result<JsValue, String> {
init_local_broker_with_lazy(&INIT_LOCAL_BROKER).await; init_local_broker_with_lazy(&INIT_LOCAL_BROKER).await;
//init_local_broker(Box::new(|| LocalBrokerConfig::InMemory)).await; //init_local_broker(Box::new(|| LocalBrokerConfig::InMemory)).await;
@ -2108,9 +2156,8 @@ pub async fn gen_wallet_for_test(ngd_peer_id: String)-> Result<JsValue, String>
mnemonic_words.push(word.clone()); mnemonic_words.push(word.clone());
}); });
let res = (wallet_result,mnemonic_words); let res = (wallet_result, mnemonic_words);
Ok(serde_wasm_bindgen::to_value(&res).unwrap()) Ok(serde_wasm_bindgen::to_value(&res).unwrap())
} }
#[cfg(test)] #[cfg(test)]

Loading…
Cancel
Save