mirror of
https://github.com/penpot/penpot.git
synced 2025-05-21 06:36:11 +02:00
🎉 Add malli based validation and coersion subsystem
This commit is contained in:
parent
dbc08ba80f
commit
5ca3d01ea1
125 changed files with 4984 additions and 2762 deletions
|
@ -7,12 +7,13 @@
|
|||
(ns app.main.data.workspace.changes
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.logging :as log]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.changes :as cpc]
|
||||
[app.common.pages.changes-builder :as pcb]
|
||||
[app.common.pages.changes-spec :as pcs]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec :as us]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.types.shape-tree :as ctst]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
|
@ -20,15 +21,11 @@
|
|||
[app.main.store :as st]
|
||||
[app.main.worker :as uw]
|
||||
[beicon.core :as rx]
|
||||
[cljs.spec.alpha :as s]
|
||||
[potok.core :as ptk]))
|
||||
|
||||
;; Change this to :info :debug or :trace to debug this module
|
||||
(log/set-level! :warn)
|
||||
|
||||
(s/def ::coll-of-uuid
|
||||
(s/every ::us/uuid))
|
||||
|
||||
(defonce page-change? #{:add-page :mod-page :del-page :mov-page})
|
||||
(defonce update-layout-attr? #{:hidden})
|
||||
|
||||
|
@ -56,8 +53,8 @@
|
|||
([ids update-fn] (update-shapes ids update-fn nil))
|
||||
([ids update-fn {:keys [reg-objects? save-undo? stack-undo? attrs ignore-tree page-id ignore-remote?]
|
||||
:or {reg-objects? false save-undo? true stack-undo? false ignore-remote? false}}]
|
||||
(us/assert ::coll-of-uuid ids)
|
||||
(us/assert fn? update-fn)
|
||||
(dm/assert! (sm/coll-of-uuid? ids))
|
||||
(dm/assert! (fn? update-fn))
|
||||
|
||||
(ptk/reify ::update-shapes
|
||||
ptk/WatchEvent
|
||||
|
@ -75,7 +72,7 @@
|
|||
changes (reduce
|
||||
(fn [changes id]
|
||||
(let [opts {:attrs attrs :ignore-geometry? (get ignore-tree id)}]
|
||||
(pcb/update-shapes changes [id] update-fn opts)))
|
||||
(pcb/update-shapes changes [id] update-fn (d/without-nils opts))))
|
||||
(-> (pcb/empty-changes it page-id)
|
||||
(pcb/set-save-undo? save-undo?)
|
||||
(pcb/set-stack-undo? stack-undo?)
|
||||
|
@ -204,8 +201,10 @@
|
|||
[:workspace-data]
|
||||
[:workspace-libraries file-id :data])]
|
||||
(try
|
||||
(us/assert ::pcs/changes redo-changes)
|
||||
(us/assert ::pcs/changes undo-changes)
|
||||
(dm/assert!
|
||||
"expect valid vector of changes"
|
||||
(and (cpc/changes? redo-changes)
|
||||
(cpc/changes? undo-changes)))
|
||||
|
||||
(update-in state path (fn [file]
|
||||
(-> file
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue