Find page of metadata marker in pdf

As I understand it, you are merging compiled PDFs, is that correct? Presumably, you are then inserting entire pages into your document, so would it be possible for you to offset the query values by the number of pages already inserted?

What I mean is, suppose you have your main document main.pdf and wish to insert 3 pages from both documents a.pdf and b.pdf. If the query command tells you you should insert them at pages 4 and 8 of main.pdf, you would insert a.pdf onto page 4 and b.pdf onto page 8 + 3 = 11.

Otherwise, typst allows you to insert PDFs into your document natively via the image function

#let insert-pdf(document-name, pages) = context {
  for i in pages {
    move(
      image(
        document-name, 
        page: i, 
        width: page.width,
        height: page.height
      ),
      dx: -here().position().x,
      dy: -here().position().y,
    )
  }
}


#insert-pdf("insertme.pdf", (1,2,3))