Fetch only the exported roots in the wasm exporter

This commit is contained in:
Elena Torro 2026-08-05 10:47:53 +02:00
parent 4971cb9667
commit 25a470bf64

View File

@ -132,20 +132,22 @@
;; --- shape bundle fetch (backend RPC) ;; --- shape bundle fetch (backend RPC)
(defn- fetch-objects (defn- fetch-objects
"Fetches the page's `objects` map from the backend via the `get-page` RPC, "Fetches the exported roots and their children from the backend via the
using the same auth the exporter uses elsewhere (management key + bearer)." `get-page` RPC (`:object-id`, as the browser render path does), using the
[{:keys [file-id page-id share-id token]}] same auth the exporter uses elsewhere (management key + bearer)."
[{:keys [file-id page-id share-id token objects]}]
(let [headers (rpc-headers token) (let [headers (rpc-headers token)
;; share-id is an OPTIONAL uuid on the backend; it must be omitted when root-ids (into #{} (map :id) objects)
;; absent, not sent as nil (nil fails the uuid schema).
body (t/encode-str (cond-> {:file-id file-id body (t/encode-str (cond-> {:file-id file-id
:page-id page-id} :page-id page-id}
share-id (assoc :share-id share-id))) (seq root-ids) (assoc :object-id root-ids)
share-id (assoc :share-id share-id)))
uri (internal-uri "api/rpc/command/get-page")] uri (internal-uri "api/rpc/command/get-page")]
(l/dbg :hint "wasm render: get-page" (l/dbg :hint "wasm render: get-page"
:uri uri :uri uri
:file-id (str file-id) :file-id (str file-id)
:page-id (str page-id)) :page-id (str page-id)
:roots (count root-ids))
(->> (fetch! uri #js {:method "POST" :headers headers :body body}) (->> (fetch! uri #js {:method "POST" :headers headers :body body})
(p/mcat (fn [^js resp] (p/mcat (fn [^js resp]
(if (= 200 (.-status resp)) (if (= 200 (.-status resp))