mirror of
https://github.com/penpot/penpot.git
synced 2025-08-06 12:38:33 +02:00
✨ Improve file data type constructor
This commit is contained in:
parent
a77edc5aa2
commit
6c7fef29a8
1 changed files with 44 additions and 27 deletions
|
@ -16,6 +16,7 @@
|
||||||
[app.common.geom.shapes.tree-seq :as gsts]
|
[app.common.geom.shapes.tree-seq :as gsts]
|
||||||
[app.common.logging :as l]
|
[app.common.logging :as l]
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
|
[app.common.time :as dt]
|
||||||
[app.common.types.color :as ctc]
|
[app.common.types.color :as ctc]
|
||||||
[app.common.types.component :as ctk]
|
[app.common.types.component :as ctk]
|
||||||
[app.common.types.components-list :as ctkl]
|
[app.common.types.components-list :as ctkl]
|
||||||
|
@ -93,12 +94,13 @@
|
||||||
[:map {:title "file"}
|
[:map {:title "file"}
|
||||||
[:id ::sm/uuid]
|
[:id ::sm/uuid]
|
||||||
[:name :string]
|
[:name :string]
|
||||||
[:revn {:optional true} :int]
|
[:revn :int]
|
||||||
[:vern {:optional true} :int]
|
[:vern {:optional true} :int]
|
||||||
[:created-at {:optional true} ::sm/inst]
|
[:created-at ::sm/inst]
|
||||||
[:modified-at {:optional true} ::sm/inst]
|
[:modified-at ::sm/inst]
|
||||||
[:deleted-at {:optional true} ::sm/inst]
|
[:deleted-at {:optional true} ::sm/inst]
|
||||||
[:project-id {:optional true} ::sm/uuid]
|
[:project-id {:optional true} ::sm/uuid]
|
||||||
|
[:team-id {:optional true} ::sm/uuid]
|
||||||
[:is-shared {:optional true} ::sm/boolean]
|
[:is-shared {:optional true} ::sm/boolean]
|
||||||
[:data {:optional true} schema:data]
|
[:data {:optional true} schema:data]
|
||||||
[:version :int]
|
[:version :int]
|
||||||
|
@ -145,35 +147,50 @@
|
||||||
(update :options merge {:components-v2 true
|
(update :options merge {:components-v2 true
|
||||||
:base-font-size BASE-FONT-SIZE})))))
|
:base-font-size BASE-FONT-SIZE})))))
|
||||||
|
|
||||||
|
;; FIXME: we can't handle the "default" migrations for avoid providing
|
||||||
|
;; them all the time the file is created because we can't import file
|
||||||
|
;; migrations because of circular import issue; We need to split the
|
||||||
|
;; list of migrations and impl of migrations in separate namespaces
|
||||||
|
|
||||||
|
;; FIXME: refactor
|
||||||
|
|
||||||
(defn make-file
|
(defn make-file
|
||||||
[{:keys [id project-id name revn is-shared features migrations
|
[{:keys [id project-id name revn is-shared features migrations
|
||||||
ignore-sync-until modified-at deleted-at]
|
ignore-sync-until created-at modified-at deleted-at]
|
||||||
:or {is-shared false revn 0}}
|
:as params}
|
||||||
|
|
||||||
& {:keys [create-page page-id]
|
& {:keys [create-page with-data page-id]
|
||||||
:or {create-page true}}]
|
:or {create-page true with-data true}}]
|
||||||
|
|
||||||
(let [id (or id (uuid/next))
|
(let [id (or id (uuid/next))
|
||||||
data (if create-page
|
created-at (or created-at (dt/now))
|
||||||
(if page-id
|
modified-at (or modified-at created-at)
|
||||||
(make-file-data id page-id)
|
features (d/nilv features #{})
|
||||||
(make-file-data id))
|
|
||||||
(make-file-data id nil))
|
|
||||||
|
|
||||||
file (d/without-nils
|
data
|
||||||
{:id id
|
(when with-data
|
||||||
:project-id project-id
|
(if create-page
|
||||||
:name name
|
(if page-id
|
||||||
:revn revn
|
(make-file-data id page-id)
|
||||||
:vern 0
|
(make-file-data id))
|
||||||
:is-shared is-shared
|
(make-file-data id nil)))
|
||||||
:version version
|
|
||||||
:data data
|
file
|
||||||
:features features
|
(d/without-nils
|
||||||
:migrations migrations
|
{:id id
|
||||||
:ignore-sync-until ignore-sync-until
|
:project-id project-id
|
||||||
:modified-at modified-at
|
:name name
|
||||||
:deleted-at deleted-at})]
|
:revn (d/nilv revn 0)
|
||||||
|
:vern 0
|
||||||
|
:is-shared (d/nilv is-shared false)
|
||||||
|
:version (:version params version)
|
||||||
|
:data data
|
||||||
|
:features features
|
||||||
|
:migrations migrations
|
||||||
|
:ignore-sync-until ignore-sync-until
|
||||||
|
:created-at created-at
|
||||||
|
:modified-at modified-at
|
||||||
|
:deleted-at deleted-at})]
|
||||||
|
|
||||||
(check-file file)))
|
(check-file file)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue