♻️ Use direct schemas instead of references

Only a very common use, basic types schemas should be used as
reference (with namespaced keywords)
This commit is contained in:
Andrey Antukh
2025-08-20 09:36:49 +02:00
parent d7c19325cc
commit 575342b3bb
38 changed files with 182 additions and 258 deletions

View File

@@ -7,7 +7,6 @@
(ns app.main.data.changes
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.changes :as cpc]
[app.common.logging :as log]
[app.common.time :as ct]
@@ -106,13 +105,11 @@
[{:keys [commit-id redo-changes undo-changes origin save-undo? features
file-id file-revn file-vern undo-group tags stack-undo? source]}]
(dm/assert!
"expect valid vector of changes for redo-changes"
(cpc/check-changes! redo-changes))
(assert (cpc/check-changes redo-changes)
"expect valid vector of changes for redo-changes")
(dm/assert!
"expect valid vector of changes for undo-changes"
(cpc/check-changes! undo-changes))
(assert (cpc/check-changes undo-changes)
"expect valid vector of changes for undo-changes")
(let [commit-id (or commit-id (uuid/next))
source (d/nilv source :local)

View File

@@ -760,13 +760,11 @@
(defn ext-library-changed
[library-id modified-at revn changes]
(dm/assert!
"expected valid uuid for library-id"
(uuid? library-id))
(assert (uuid? library-id)
"expected valid uuid for library-id")
(dm/assert!
"expected valid changes vector"
(ch/check-changes! changes))
(assert (ch/check-changes changes)
"expected valid changes vector")
(ptk/reify ::ext-library-changed
ptk/UpdateEvent

View File

@@ -236,7 +236,7 @@
[:session-id ::sm/uuid]
[:revn :int]
[:vern :int]
[:changes ::cpc/changes]])
[:changes cpc/schema:changes]])
(def ^:private check-file-change-params!
(sm/check-fn schema:handle-file-change))
@@ -279,9 +279,8 @@
(defn handle-file-restore
[{:keys [file-id vern] :as msg}]
(dm/assert!
"expected valid parameters"
(check-file-restore-params msg))
(assert (check-file-restore-params msg)
"expected valid parameters")
(ptk/reify ::handle-file-restore
ptk/WatchEvent
@@ -302,16 +301,15 @@
[:session-id ::sm/uuid]
[:revn :int]
[:modified-at ::ct/inst]
[:changes ::cpc/changes]])
[:changes cpc/schema:changes]])
(def ^:private check-library-change-params!
(def ^:private check-library-change-params
(sm/check-fn schema:handle-library-change))
(defn handle-library-change
[{:keys [file-id modified-at changes revn] :as msg}]
(dm/assert!
"expected valid arguments"
(check-library-change-params! msg))
(assert (check-library-change-params msg)
"expected valid arguments")
(ptk/reify ::handle-library-change
ptk/WatchEvent

View File

@@ -57,8 +57,8 @@
(def ^:private
schema:undo-entry
[:map {:title "undo-entry"}
[:undo-changes [:vector ::cpc/change]]
[:redo-changes [:vector ::cpc/change]]
[:undo-changes [:vector cpc/schema:change]]
[:redo-changes [:vector cpc/schema:change]]
[:undo-group ::sm/uuid]
[:tags [:set :keyword]]])

View File

@@ -119,7 +119,7 @@
(-> (u/proxy->interaction self)
(d/patch-object params))]
(cond
(not (sm/validate ::ctsi/interaction interaction))
(not (sm/validate ctsi/schema:interaction interaction))
(u/display-not-valid :action interaction)
:else
@@ -453,7 +453,7 @@
(let [id (obj/get self "$id")
value (blur-defaults (parser/parse-blur value))]
(cond
(not (sm/validate ::ctsb/blur value))
(not (sm/validate ctsb/schema:blur value))
(u/display-not-valid :blur value)
(not (r/check-permission plugin-id "content:write"))
@@ -470,7 +470,7 @@
(let [id (obj/get self "$id")
value (parser/parse-exports value)]
(cond
(not (sm/validate [:vector ::ctse/export] value))
(not (sm/validate [:vector ctse/schema:export] value))
(u/display-not-valid :exports value)
(not (r/check-permission plugin-id "content:write"))
@@ -1129,7 +1129,7 @@
(fn [value]
(let [value (parser/parse-export value)]
(cond
(not (sm/validate ::ctse/export value))
(not (sm/validate ctse/schema:export value))
(u/display-not-valid :export value)
:else
@@ -1161,7 +1161,7 @@
(-> ctsi/default-interaction
(d/patch-object (parser/parse-interaction trigger action delay)))]
(cond
(not (sm/validate ::ctsi/interaction interaction))
(not (sm/validate ctsi/schema:interaction interaction))
(u/display-not-valid :addInteraction interaction)
:else