diff --git a/backend/deps.edn b/backend/deps.edn index c93092fd4..cd5d6eb2e 100644 --- a/backend/deps.edn +++ b/backend/deps.edn @@ -7,7 +7,6 @@ org.clojure/core.async {:mvn/version "1.6.673"} com.github.luben/zstd-jni {:mvn/version "1.5.2-5"} - org.clojure/data.fressian {:mvn/version "1.0.0"} io.prometheus/simpleclient {:mvn/version "0.16.0"} io.prometheus/simpleclient_hotspot {:mvn/version "0.16.0"} diff --git a/backend/dev/user.clj b/backend/dev/user.clj index d86d4fc07..1b02c6ea0 100644 --- a/backend/dev/user.clj +++ b/backend/dev/user.clj @@ -8,30 +8,23 @@ (:require [app.common.data :as d] [app.common.exceptions :as ex] + [app.common.fressian :as fres] [app.common.geom.matrix :as gmt] [app.common.logging :as l] [app.common.perf :as perf] [app.common.pprint :as pp] + [app.common.schema :as sm] + [app.common.schema.desc-js-like :as smdj] + [app.common.schema.desc-native :as smdn] + [app.common.schema.generators :as sg] [app.common.spec :as us] [app.common.transit :as t] [app.common.uuid :as uuid] - [app.common.schema :as sm] - [app.common.schema.generators :as sg] - [app.common.schema.desc-native :as smdn] - [app.common.schema.desc-js-like :as smdj] [app.config :as cfg] [app.main :as main] - [malli.core :as m] - [malli.error :as me] - [malli.dev.pretty :as mdp] - [malli.transform :as mt] - [malli.util :as mu] - [malli.registry :as mr] - [malli.generator :as mg] [app.srepl.helpers] [app.srepl.main :as srepl] [app.util.blob :as blob] - [app.util.fressian :as fres] [app.util.json :as json] [app.util.time :as dt] [clj-async-profiler.core :as prof] @@ -48,7 +41,14 @@ [criterium.core :as crit] [cuerdas.core :as str] [datoteka.core] - [integrant.core :as ig])) + [integrant.core :as ig] + [malli.core :as m] + [malli.dev.pretty :as mdp] + [malli.error :as me] + [malli.generator :as mg] + [malli.registry :as mr] + [malli.transform :as mt] + [malli.util :as mu])) (repl/disable-reload! (find-ns 'integrant.core)) (set! *warn-on-reflection* true) diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index 8b9095756..c962bc2f5 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -8,8 +8,10 @@ (:refer-clojure :exclude [assert]) (:require [app.common.data :as d] + [app.common.data.macros :as dm] [app.common.exceptions :as ex] [app.common.files.features :as ffeat] + [app.common.fressian :as fres] [app.common.logging :as l] [app.common.pages.migrations :as pmg] [app.common.spec :as us] @@ -28,7 +30,6 @@ [app.storage.tmp :as tmp] [app.tasks.file-gc] [app.util.blob :as blob] - [app.util.fressian :as fres] [app.util.objects-map :as omap] [app.util.pointer-map :as pmap] [app.util.services :as sv] @@ -45,8 +46,7 @@ java.io.DataInputStream java.io.DataOutputStream java.io.InputStream - java.io.OutputStream - java.lang.AutoCloseable)) + java.io.OutputStream)) (set! *warn-on-reflection* true) @@ -296,7 +296,7 @@ (defn- retrieve-file [pool file-id] - (with-open [^AutoCloseable conn (db/open pool)] + (dm/with-open [conn (db/open pool)] (binding [pmap/*load-fn* (partial files/load-pointer conn file-id)] (some-> (db/get* conn :file {:id file-id}) (files/decode-row) @@ -307,7 +307,7 @@ (defn- retrieve-file-media [pool {:keys [data id] :as file}] - (with-open [^AutoCloseable conn (db/open pool)] + (dm/with-open [conn (db/open pool)] (let [ids (app.tasks.file-gc/collect-used-media data) ids (db/create-array conn "uuid" ids)] @@ -341,7 +341,7 @@ (defn- retrieve-libraries [pool ids] - (with-open [^AutoCloseable conn (db/open pool)] + (dm/with-open [conn (db/open pool)] (let [ids (db/create-array conn "uuid" ids)] (map :id (db/exec! pool [sql:file-libraries ids]))))) @@ -351,7 +351,7 @@ (defn- retrieve-library-relations [pool ids] - (with-open [^AutoCloseable conn (db/open pool)] + (dm/with-open [conn (db/open pool)] (db/exec! conn [sql:file-library-rels (db/create-array conn "uuid" ids)]))) (defn- create-or-update-file @@ -616,7 +616,7 @@ (-> data (update :pages-index update-vals #(update % :objects omap-wrap)) (update :pages-index update-vals pmap-wrap) - (update :components update-vals #(update % :objects omap-wrap)) + (update :components update-vals #(d/update-when % :objects omap-wrap)) (update :components pmap-wrap)))) (defmethod read-section :v1/files @@ -834,7 +834,7 @@ cs (volatile! nil)] (try (l/info :hint "start exportation" :export-id id) - (with-open [^AutoCloseable output (io/output-stream output)] + (dm/with-open [output (io/output-stream output)] (binding [*position* (atom 0)] (write-export! (assoc cfg ::output output)))) @@ -857,7 +857,7 @@ (defn export-to-tmpfile! [cfg] (let [path (tmp/tempfile :prefix "penpot.export.")] - (with-open [^AutoCloseable output (io/output-stream path)] + (dm/with-open [output (io/output-stream path)] (export! cfg output) path))) @@ -869,7 +869,7 @@ (l/info :hint "import: started" :import-id id) (try (binding [*position* (atom 0)] - (with-open [^AutoCloseable input (io/input-stream input)] + (dm/with-open [input (io/input-stream input)] (read-import! (assoc cfg ::input input)))) (catch Throwable cause diff --git a/backend/src/app/util/blob.clj b/backend/src/app/util/blob.clj index 9fe030e74..6263e8e87 100644 --- a/backend/src/app/util/blob.clj +++ b/backend/src/app/util/blob.clj @@ -8,9 +8,9 @@ "A generic blob storage encoding. Mainly used for page data, page options and txlog payload storage." (:require + [app.common.fressian :as fres] [app.common.transit :as t] - [app.config :as cf] - [app.util.fressian :as fres]) + [app.config :as cf]) (:import com.github.luben.zstd.Zstd java.io.ByteArrayInputStream diff --git a/backend/src/app/util/objects_map.clj b/backend/src/app/util/objects_map.clj index 8d053a693..eecd395e3 100644 --- a/backend/src/app/util/objects_map.clj +++ b/backend/src/app/util/objects_map.clj @@ -16,10 +16,9 @@ properly from each value." (:require - ;; [app.common.logging :as l] + [app.common.fressian :as fres] [app.common.transit :as t] [app.common.uuid :as uuid] - [app.util.fressian :as fres] [clojure.core :as c]) (:import clojure.lang.Counted diff --git a/backend/src/app/util/pointer_map.clj b/backend/src/app/util/pointer_map.clj index 70da3dc8a..cfe79cd3a 100644 --- a/backend/src/app/util/pointer_map.clj +++ b/backend/src/app/util/pointer_map.clj @@ -36,10 +36,10 @@ " (:require + [app.common.fressian :as fres] [app.common.logging :as l] [app.common.transit :as t] [app.common.uuid :as uuid] - [app.util.fressian :as fres] [app.util.time :as dt] [clojure.core :as c]) (:import diff --git a/backend/test/backend_tests/util_objects_map_test.clj b/backend/test/backend_tests/util_objects_map_test.clj index 7d75191e7..b85c841c6 100644 --- a/backend/test/backend_tests/util_objects_map_test.clj +++ b/backend/test/backend_tests/util_objects_map_test.clj @@ -6,11 +6,11 @@ (ns backend-tests.util-objects-map-test (:require + [app.common.fressian :as fres] [app.common.schema.generators :as sg] [app.common.transit :as transit] [app.common.types.shape :as cts] [app.common.uuid :as uuid] - [app.util.fressian :as fres] [app.util.objects-map :as omap] [backend-tests.helpers :as th] [clojure.pprint :refer [pprint]] diff --git a/backend/test/backend_tests/util_pointer_map_test.clj b/backend/test/backend_tests/util_pointer_map_test.clj index f496a5738..85715dc95 100644 --- a/backend/test/backend_tests/util_pointer_map_test.clj +++ b/backend/test/backend_tests/util_pointer_map_test.clj @@ -6,13 +6,13 @@ (ns backend-tests.util-pointer-map-test (:require - [backend-tests.helpers :as th] + [app.common.fressian :as fres] [app.common.spec :as us] [app.common.transit :as transit] [app.common.types.shape :as cts] [app.common.uuid :as uuid] - [app.util.fressian :as fres] [app.util.pointer-map :as pmap] + [backend-tests.helpers :as th] [clojure.pprint :refer [pprint]] [clojure.spec.alpha :as s] [clojure.test :as t] diff --git a/common/deps.edn b/common/deps.edn index e70f6c454..5ff183c57 100644 --- a/common/deps.edn +++ b/common/deps.edn @@ -2,9 +2,9 @@ {org.clojure/clojure {:mvn/version "1.11.1"} org.clojure/data.json {:mvn/version "2.4.0"} org.clojure/tools.cli {:mvn/version "1.0.214"} - metosin/jsonista {:mvn/version "0.3.7"} org.clojure/clojurescript {:mvn/version "1.11.60"} org.clojure/test.check {:mvn/version "1.1.1"} + org.clojure/data.fressian {:mvn/version "1.0.0"} ;; Logging org.apache.logging.log4j/log4j-api {:mvn/version "2.19.0"} @@ -18,6 +18,7 @@ selmer/selmer {:mvn/version "1.12.55"} criterium/criterium {:mvn/version "0.4.6"} + metosin/jsonista {:mvn/version "0.3.7"} metosin/malli {:mvn/version "0.11.0"} expound/expound {:mvn/version "0.9.0"} @@ -30,14 +31,14 @@ {:git/tag "11.0-alpha13" :git/sha "f6cab38" :git/url "https://github.com/funcool/promesa.git"} + funcool/datoteka {:mvn/version "3.0.66" + :exclusions [funcool/promesa]} lambdaisland/uri {:mvn/version "1.13.95" :exclusions [org.clojure/data.json]} frankiesardo/linked {:mvn/version "1.3.0"} - funcool/datoteka {:mvn/version "3.0.66" - :exclusions [funcool/promesa]} com.sun.mail/jakarta.mail {:mvn/version "2.0.1"} org.la4j/la4j {:mvn/version "0.6.0"} diff --git a/backend/src/app/util/fressian.clj b/common/src/app/common/fressian.clj similarity index 99% rename from backend/src/app/util/fressian.clj rename to common/src/app/common/fressian.clj index 82e364ccb..1b78fbcb8 100644 --- a/backend/src/app/util/fressian.clj +++ b/common/src/app/common/fressian.clj @@ -4,7 +4,7 @@ ;; ;; Copyright (c) KALEIDOS INC -(ns app.util.fressian +(ns app.common.fressian (:require [app.common.data :as d] [app.common.geom.matrix :as gmt]