Clean frontend and backend features on exportation

This commit is contained in:
Andrey Antukh 2024-11-15 15:54:57 +01:00
parent b7573c0b72
commit 47d28758d7
3 changed files with 20 additions and 14 deletions

View file

@ -134,6 +134,16 @@
(update :data feat.fdata/process-pointers deref) (update :data feat.fdata/process-pointers deref)
(update :data feat.fdata/process-objects (partial into {})))))))) (update :data feat.fdata/process-objects (partial into {}))))))))
(defn clean-file-features
[file]
(update file :features (fn [features]
(if (set? features)
(-> features
(cfeat/migrate-legacy-features)
(set/difference cfeat/frontend-only-features)
(set/difference cfeat/backend-only-features))
#{}))))
(defn get-project (defn get-project
[cfg project-id] [cfg project-id]
(db/get cfg :project {:id project-id})) (db/get cfg :project {:id project-id}))

View file

@ -508,16 +508,6 @@
(update :object-id #(str/replace-first % #"^(.*?)/" (str file-id "/"))))) (update :object-id #(str/replace-first % #"^(.*?)/" (str file-id "/")))))
thumbnails)) thumbnails))
(defn- clean-features
[file]
(update file :features (fn [features]
(if (set? features)
(-> features
(cfeat/migrate-legacy-features)
(set/difference cfeat/frontend-only-features)
(set/difference cfeat/backend-only-features))
#{}))))
(defmethod read-section :v1/files (defmethod read-section :v1/files
[{:keys [::db/conn ::input ::project-id ::bfc/overwrite ::name] :as system}] [{:keys [::db/conn ::input ::project-id ::bfc/overwrite ::name] :as system}]
@ -528,7 +518,7 @@
file-id (:id file) file-id (:id file)
file-id' (bfc/lookup-index file-id) file-id' (bfc/lookup-index file-id)
file (clean-features file) file (bfc/clean-file-features file)
thumbnails (:thumbnails file)] thumbnails (:thumbnails file)]
(when (not= file-id expected-file-id) (when (not= file-id expected-file-id)

View file

@ -12,6 +12,7 @@
[app.common.data :as d] [app.common.data :as d]
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.exceptions :as ex] [app.common.exceptions :as ex]
[app.common.features :as cfeat]
[app.common.json :as json] [app.common.json :as json]
[app.common.logging :as l] [app.common.logging :as l]
[app.common.schema :as sm] [app.common.schema :as sm]
@ -55,7 +56,8 @@
[:map [:map
[:id ::sm/uuid] [:id ::sm/uuid]
[:name :string] [:name :string]
[:project-id ::sm/uuid]]]] [:project-id ::sm/uuid]
[:features ::cfeat/features]]]]
[:relations {:optional true} [:relations {:optional true}
[:vector [:vector
@ -203,7 +205,10 @@
(dissoc :libraries)) (dissoc :libraries))
embed-assets embed-assets
(update :data #(bfc/embed-assets cfg % file-id))))) (update :data #(bfc/embed-assets cfg % file-id))
:always
(bfc/clean-file-features))))
(defn- resolve-extension (defn- resolve-extension
[mtype] [mtype]
@ -259,7 +264,8 @@
(vswap! bfc/*state* update :files assoc file-id (vswap! bfc/*state* update :files assoc file-id
{:id file-id {:id file-id
:project-id (:project-id file) :project-id (:project-id file)
:name (:name file)}) :name (:name file)
:features (:features file)})
(let [file (cond-> (dissoc file :data) (let [file (cond-> (dissoc file :data)
(:options data) (:options data)