@@ -348,57 +348,61 @@ export const findSimilarNodesUsingHyde = async ({
348348} ;
349349
350350export const getAllPageByUidAsync = async ( ) : Promise < [ string , string ] [ ] > => {
351- // @ts -ignore - backend to be added to roamjs-components
352- const pages = ( await window . roamAlphaAPI . data . async . q (
353- "[:find ?pageName ?pageUid :where [?e :node/title ?pageName] [?e :block/uid ?pageUid]]" ,
351+ const pages = ( await Promise . resolve (
352+ window . roamAlphaAPI . data . backend . q (
353+ "[:find ?pageName ?pageUid :where [?e :node/title ?pageName] [?e :block/uid ?pageUid]]" ,
354+ ) ,
354355 ) ) as [ string , string ] [ ] ;
355356 return pages ;
356357} ;
357358
358- const extractPagesFromChildBlock = async (
359+ export const extractPagesFromChildBlock = async (
359360 tag : string ,
360361) : Promise < { uid : string ; text : string } [ ] > => {
361- // @ts -ignore - backend to be added to roamjs-components
362- const results = ( await window . roamAlphaAPI . data . async . q (
363- `[:find ?uid ?title
362+ const results = ( await Promise . resolve (
363+ window . roamAlphaAPI . data . backend . q (
364+ `[:find ?uid ?title
364365 :where [?b :node/title "${ normalizePageTitle ( tag ) } "]
365366 [?a :block/refs ?b]
366367 [?p :block/children ?a]
367368 [?p :block/refs ?rf]
368369 [?rf :block/uid ?uid]
369370 [?rf :node/title ?title]]]` ,
371+ ) ,
370372 ) ) as Array < [ string , string ] > ;
371373 return results . map ( ( [ uid , title ] ) => ( { uid, text : title } ) ) ;
372374} ;
373375
374- const extractPagesFromParentBlock = async (
376+ export const extractPagesFromParentBlock = async (
375377 tag : string ,
376378) : Promise < { uid : string ; text : string } [ ] > => {
377- // @ts -ignore - backend to be added to roamjs-components
378- const results = ( await window . roamAlphaAPI . data . async . q (
379- `[:find ?uid ?title
379+ const results = ( await Promise . resolve (
380+ window . roamAlphaAPI . data . backend . q (
381+ `[:find ?uid ?title
380382 :where [?b :node/title "${ normalizePageTitle ( tag ) } "]
381383 [?a :block/refs ?b]
382384 [?p :block/parents ?a]
383385 [?p :block/refs ?rf]
384386 [?rf :block/uid ?uid]
385387 [?rf :node/title ?title]]]` ,
388+ ) ,
386389 ) ) as Array < [ string , string ] > ;
387390 return results . map ( ( [ uid , title ] ) => ( { uid, text : title } ) ) ;
388391} ;
389392
390- const getAllReferencesOnPage = async (
393+ export const getAllReferencesOnPage = async (
391394 pageTitle : string ,
392395) : Promise < { uid : string ; text : string } [ ] > => {
393- // @ts -ignore - backend to be added to roamjs-components
394- const referencedPages = ( await window . roamAlphaAPI . data . async . q (
395- `[:find ?uid ?text
396+ const referencedPages = ( await Promise . resolve (
397+ window . roamAlphaAPI . data . backend . q (
398+ `[:find ?uid ?text
396399 :where
397400 [?page :node/title "${ normalizePageTitle ( pageTitle ) } "]
398401 [?b :block/page ?page]
399402 [?b :block/refs ?refPage]
400403 [?refPage :block/uid ?uid]
401404 [?refPage :node/title ?text]]` ,
405+ ) ,
402406 ) ) as Array < [ string , string ] > ;
403407 return referencedPages . map ( ( [ uid , text ] ) => ( { uid, text } ) ) ;
404408} ;
0 commit comments