@@ -465,6 +465,58 @@ export class DbService {
465465 } ) ;
466466 }
467467
468+ /**
469+ * Finds all meta-envelopes by ontology across every eName (no tenant isolation).
470+ * Temporary helper — use with care; intended for the token-gated cross-eVault read endpoint.
471+ */
472+ async findMetaEnvelopesByOntologyAcrossAllENames <
473+ T extends Record < string , any > = Record < string , any > ,
474+ > (
475+ ontology : string ,
476+ ) : Promise < ( MetaEnvelopeResult < T > & { eName : string } ) [ ] > {
477+ const result = await this . runQueryInternal (
478+ `
479+ MATCH (m:MetaEnvelope { ontology: $ontology })-[:LINKS_TO]->(e:Envelope)
480+ RETURN m.id AS id, m.ontology AS ontology, m.acl AS acl, m.eName AS eName, collect(e) AS envelopes
481+ ` ,
482+ { ontology } ,
483+ ) ;
484+
485+ return result . records . map ( ( record ) => {
486+ const envelopes = record
487+ . get ( "envelopes" )
488+ . map ( ( node : any ) : Envelope < T [ keyof T ] > => {
489+ const properties = node . properties ;
490+ return {
491+ id : properties . id ,
492+ ontology : properties . ontology ,
493+ value : deserializeValue (
494+ properties . value ,
495+ properties . valueType ,
496+ ) as T [ keyof T ] ,
497+ valueType : properties . valueType ,
498+ } ;
499+ } ) ;
500+
501+ const parsed = envelopes . reduce (
502+ ( acc : T , envelope : Envelope < T [ keyof T ] > ) => {
503+ ( acc as any ) [ envelope . ontology ] = envelope . value ;
504+ return acc ;
505+ } ,
506+ { } as T ,
507+ ) ;
508+
509+ return {
510+ id : record . get ( "id" ) ,
511+ ontology : record . get ( "ontology" ) ,
512+ acl : record . get ( "acl" ) ,
513+ eName : record . get ( "eName" ) ,
514+ envelopes,
515+ parsed,
516+ } ;
517+ } ) ;
518+ }
519+
468520 /**
469521 * Deletes a meta-envelope and all its associated envelopes.
470522 * @param id - The ID of the meta-envelope to delete
0 commit comments