enhance(rtc): move rtc api schema to logseq/logseq-schema repo

This commit is contained in:
rcmerci
2026-01-08 22:06:58 +08:00
parent c8148f66ef
commit 562a68e0e4
8 changed files with 30 additions and 440 deletions

View File

@@ -49,7 +49,10 @@
:git/url "https://github.com/open-spaced-repetition/cljc-fsrs"}
tick/tick {:mvn/version "0.7.5"}
io.github.rcmerci/cljs-http-missionary {:git/url "https://github.com/RCmerci/cljs-http-missionary"
:git/sha "d61ce7e29186de021a2a453a8cee68efb5a88440"}}
:git/sha "d61ce7e29186de021a2a453a8cee68efb5a88440"}
logseq/logseq-schema {:git/url "https://github.com/logseq/logseq-schema"
:git/sha "6eeb51cd6d80bbffa0873c1e79790dc1f4ff68cf"}}
:aliases {:cljs {:extra-paths ["src/dev-cljs/" "src/test/" "src/electron/"]
:extra-deps {org.clojure/tools.namespace {:mvn/version "0.2.11"}

View File

@@ -11,13 +11,13 @@
[frontend.worker.rtc.exception :as r.ex]
[frontend.worker.rtc.gen-client-op :as gen-client-op]
[frontend.worker.rtc.log-and-state :as rtc-log-and-state]
[frontend.worker.rtc.malli-schema :as rtc-schema]
[frontend.worker.rtc.remote-update :as r.remote-update]
[frontend.worker.rtc.skeleton :as r.skeleton]
[frontend.worker.rtc.throttle :as r.throttle]
[frontend.worker.rtc.ws :as ws]
[frontend.worker.rtc.ws-util :as ws-util]
[lambdaisland.glogi :as log]
[logseq-schema.rtc-api-schema :as rtc-api-schema]
[logseq.db :as ldb]
[logseq.db.frontend.schema :as db-schema]
[missionary.core :as m]
@@ -532,7 +532,7 @@
rename-db-ident-remote-ops
(when block-uuid->remote-ops (sort-remote-ops block-uuid->remote-ops))
other-remote-ops)]
(when-let [ops-for-remote (rtc-schema/to-ws-ops-decoder remote-ops)]
(when-let [ops-for-remote (rtc-api-schema/to-ws-ops-decoder remote-ops)]
(let [local-tx (client-op/get-local-tx repo)
ops-for-remote* (if aes-key
(m/? (task--encrypt-remote-ops aes-key ops-for-remote))

View File

@@ -2,9 +2,9 @@
"Store client-ops in a persisted datascript"
(:require [datascript.core :as d]
[frontend.common.missionary :as c.m]
[frontend.worker.rtc.malli-schema :as rtc-schema]
[frontend.worker.state :as worker-state]
[lambdaisland.glogi :as log]
[logseq-schema.rtc-api-schema :as rtc-api-schema]
[logseq.db :as ldb]
[malli.core :as ma]
[malli.transform :as mt]
@@ -57,14 +57,14 @@
[:t :int]
[:value [:map
[:block-uuid :uuid]
[:av-coll [:sequential rtc-schema/av-schema]]]]]]
[:av-coll [:sequential rtc-api-schema/av-schema]]]]]]
[:add
[:catn
[:op :keyword]
[:t :int]
[:value [:map
[:block-uuid :uuid]
[:av-coll [:sequential rtc-schema/av-schema]]]]]]
[:av-coll [:sequential rtc-api-schema/av-schema]]]]]]
[:update-asset
[:catn

View File

@@ -1,413 +0,0 @@
(ns frontend.worker.rtc.malli-schema
"Malli schema for rtc"
(:require [lambdaisland.glogi :as log]
[logseq.db.frontend.malli-schema :as db-malli-schema]
[logseq.db.frontend.schema :as db-schema]
[malli.core :as m]
[malli.transform :as mt]
[malli.util :as mu]))
(def block-pos-schema
[:catn
[:parent-uuid [:maybe :uuid]]
[:order [:maybe db-malli-schema/block-order]]])
(def av-schema
[:cat
:keyword
[:or
:uuid ;; reference type
:string ;; all other type value convert to string by transit
]
:int ;; t
:boolean ;; add(true) or retract
])
(def to-ws-op-schema
[:schema {:registry {::block-map
[:map
[:block-uuid :uuid]
[:db/ident {:optional true} :keyword]
[:pos block-pos-schema]
[:av-coll [:sequential av-schema]]
[:card-one-attrs {:optional true} [:sequential :keyword]]]}}
[:multi {:dispatch first :decode/string #(update % 0 keyword)}
[:update-kv-value
[:cat :keyword
[:map
[:db-ident :keyword]
[:value :string]]]]
[:rename-db-ident
[:cat :keyword
[:map
[:db-ident-or-block-uuid [:or :keyword :uuid]]
[:new-db-ident :keyword]]]]
[:add ;; new added block
[:cat :keyword ::block-map]]
[:move
[:cat :keyword
[:map
[:block-uuid :uuid]
[:pos block-pos-schema]]]]
[:remove
[:cat :keyword
[:map
[:block-uuids [:sequential :uuid]]]]]
[:update-page
[:cat :keyword
[:map
[:block-uuid :uuid]
[:db/ident {:optional true} :keyword]
[:page-name :string]
[:block/title :string]]]]
[:remove-page
[:cat :keyword
[:map
[:block-uuid :uuid]]]]
[:update
[:cat :keyword ::block-map]]
[:update-schema
[:cat :keyword
[:map
[:block-uuid :uuid]
[:db/ident :keyword]
[:db/valueType :keyword]
[:db/cardinality {:optional true} :keyword]
[:db/index {:optional true} :boolean]]]]]])
(comment
(def to-ws-ops-validator (m/validator [:sequential to-ws-op-schema])))
(def to-ws-ops-decoder (m/decoder [:sequential to-ws-op-schema] mt/string-transformer))
(defn- with-shared-schema-attrs
[shared-map-keys malli-schema]
(let [[head api-schema-seq] (split-at 2 malli-schema)]
(vec
(concat
head
(map
(fn [api-schema]
(let [[api-name [type']] api-schema]
(if (and (some? api-name) (= :map type'))
[api-name (vec (concat (second api-schema) shared-map-keys))]
api-schema)))
api-schema-seq)))))
(def ^:private extra-attr-map-schema
[:map-of
:keyword
[:or
[:or :uuid :string]
[:sequential [:or :uuid :string]]]])
(def data-from-ws-schema-fallback
"TODO: split this mix schema to multiple ones"
[:map
[:req-id :string]
[:profile {:optional true} :map]
[:t {:optional true} :int]
[:t-before {:optional true} :int]
[:s3-presign-url {:optional true} :string]
[:server-builtin-db-idents {:optional true} [:set :keyword]]
[:server-only-db-ident-blocks {:optional true} [:maybe :string] ;;transit
]
[:users {:optional true} [:sequential
[:map {:closed true}
[:user/uuid :uuid]
[:user/name :string]
[:user/email :string]
[:user/online? :boolean]
[:user/avatar {:optional true} :string]
[:graph<->user/user-type :keyword]]]]
[:online-users {:optional true} [:sequential
[:map {:closed true}
[:user/uuid :uuid]
[:user/name :string]
[:user/email :string]
[:user/avatar {:optional true} :string]]]]
[:asset-uuid->url {:optional true} [:map-of :uuid :string]]
[:uploaded-assets {:optional true} [:map-of :uuid :map]]
[:ex-data {:optional true} [:map [:type :keyword]]]
[:ex-message {:optional true} :string]])
(def ^:private apply-ops-response-schema
[:map
[:t :int]
[:t-before :int]
[:t-query-end {:optional true} :int] ;TODO: remove 'optional' later, be compatible with old-clients for now
[:affected-blocks
[:map-of :uuid
[:multi {:dispatch :op :decode/string #(update % :op keyword)}
[:move
[:map {:closed true}
[:op :keyword]
[:self :uuid]
[:parents [:sequential :uuid]]
[:block/order {:optional true} db-malli-schema/block-order]
[:hash {:optional true} :int]
[:db/ident {:optional true} :keyword]]]
[:remove
[:map
[:op :keyword]
[:block-uuid :uuid]]]
[:update-attrs
[:map
[:op :keyword]
[:self :uuid]
[:parents {:optional true} [:sequential :uuid]]
[:block/order {:optional true} db-malli-schema/block-order]
[:hash {:optional true} :int]
[:db/ident {:optional true} :keyword]
[::m/default extra-attr-map-schema]]]
[:move+update-attrs
[:map
[:op :keyword]
[:self :uuid]
[:parents {:optional true} [:sequential :uuid]]
[:block/order {:optional true} db-malli-schema/block-order]
[:hash {:optional true} :int]
[:db/ident {:optional true} :keyword]
[::m/default extra-attr-map-schema]]]
[:update-page
[:map
[:op :keyword]
[:self :uuid]
[:block/title :string]
[:db/ident {:optional true} :keyword]
[:block/order {:optional true} db-malli-schema/block-order]
[::m/default extra-attr-map-schema]]]
[:remove-page
[:map
[:op :keyword]
[:block-uuid :uuid]]]]]]
[:refed-blocks
[:maybe
[:sequential
[:map
[:block/uuid :uuid]
[:db/ident {:optional true} :keyword]
[:block/order {:optional true} db-malli-schema/block-order]
[:block/parent {:optional true} :uuid]
[::m/default extra-attr-map-schema]]]]]
[:failed-ops {:optional true} ;DEPRECATED
[:maybe [:sequential to-ws-op-schema]]]
[:not-found-target-ops {:optional true}
[:maybe [:sequential to-ws-op-schema]]]])
(def data-from-ws-schema
(with-shared-schema-attrs
[[:req-id :string]]
[:multi {:dispatch #(or (when (:ex-data %) :exception) (:action %))}
[:exception
[:map
[:ex-message :string]
[:ex-data [:map [:type :keyword]]]]]
["init-request"
(concat [:map
[:max-remote-schema-version {:optional true} :string]
[:server-schema-version {:optional true} :string]
[:server-builtin-db-idents {:optional true} [:set :keyword]]]
(m/children apply-ops-response-schema))]
["register-graph-updates"
[:map
[:t :int]
[:max-remote-schema-version {:optional true} :string]]]
["apply-ops" apply-ops-response-schema]
["push-asset-block-updates" apply-ops-response-schema]
["branch-graph"
[:map
[:graph-uuid :uuid]
[:schema-version db-schema/major-schema-version-string-schema]]]
["delete-graph" [:map]]
["download-graph"
[:map
[:graph-uuid :uuid]
[:schema-version db-schema/major-schema-version-string-schema]
[:download-info-uuid :string]]]
["upload-graph"
[:map
[:graph-uuid :uuid]
[:schema-version db-schema/major-schema-version-string-schema]]]
["download-info-list"
[:map
[:download-info-list [:sequential :any]]]]
["grant-access" [:map]]
["get-graph-skeleton"
[:map
[:server-schema-version :string]
[:server-builtin-db-idents [:set :keyword]]]]
["presign-put-temp-s3-obj" [:map]]
["get-users-info"
[:map
[:users
[:sequential [:map
[:user/uuid :uuid]
[:user/name :string]
[:user/email :string]
[:user/avatar {:optional true} :string]
[:graph<->user/user-type :keyword]
[:user/online? :boolean]]]]]]
["inject-users-info" [:map]]
;; keys manage
["fetch-user-rsa-key-pair"
[:map
[:public-key [:maybe :string]]
[:encrypted-private-key [:maybe :string]]]]
["fetch-graph-encrypted-aes-key"
[:map
[:encrypted-aes-key [:maybe :string]]]]
["fetch-user-rsa-public-key"
[:map
[:public-key [:maybe :string]]]]
["upload-user-rsa-key-pair"
[:map
[:public-key :string]
[:encrypted-private-key :string]]]
["reset-user-rsa-key-pair"
[:map
[:public-key :string]
[:encrypted-private-key :string]]]
[nil data-from-ws-schema-fallback]]))
(def data-from-ws-coercer (m/coercer data-from-ws-schema mt/string-transformer nil
#(m/-fail! ::data-from-ws-schema (select-keys % [:value]))))
(def data-from-ws-validator (m/validator data-from-ws-schema))
(def ^:large-vars/data-var data-to-ws-schema
(mu/closed-schema
(with-shared-schema-attrs
[[:req-id :string]
[:action :string]
[:profile {:optional true} :boolean]]
[:multi {:dispatch :action}
["list-graphs"
[:map]]
["init-request"
[:map
[:graph-uuid :uuid]
[:api-version :string]
[:schema-version db-schema/major-schema-version-string-schema]
[:t-before :int]
[:get-graph-skeleton :boolean]]]
["register-graph-updates"
[:map
[:graph-uuid :uuid]
[:schema-version db-schema/major-schema-version-string-schema]]]
["apply-ops"
[:or
[:map
[:req-id :string]
[:action :string]
[:api-version :string]
[:profile {:optional true} :boolean]
[:graph-uuid :uuid]
[:schema-version db-schema/major-schema-version-string-schema]
[:ops [:sequential to-ws-op-schema]]
[:t-before :int]]
[:map
[:req-id :string]
[:action :string]
[:profile {:optional true} :boolean]
[:s3-key :string]]]]
["presign-put-temp-s3-obj"
[:map]]
["upload-graph"
[:map
[:s3-key :string]
[:graph-name :string]
[:schema-version db-schema/major-schema-version-string-schema]
[:encrypted-aes-key {:optional true} :string]]]
["branch-graph"
[:map
[:s3-key :string]
[:graph-uuid :uuid]
[:schema-version db-schema/major-schema-version-string-schema]]]
["download-graph"
[:map
[:graph-uuid :uuid]
[:schema-version db-schema/major-schema-version-string-schema]]]
["download-info-list"
[:map
[:graph-uuid :uuid]
[:schema-version db-schema/major-schema-version-string-schema]]]
["grant-access"
[:map
[:graph-uuid :uuid]
[:target-user-email+encrypted-aes-key-coll
[:sequential
[:map
[:user/email :string]
[:encrypted-aes-key [:maybe :string]]]]]]]
["get-users-info"
[:map
[:graph-uuid :uuid]]]
["inject-users-info"
[:map
[:graph-uuid :uuid]
[:schema-version db-schema/major-schema-version-string-schema]]]
["delete-graph"
[:map
[:graph-uuid :uuid]
[:schema-version db-schema/major-schema-version-string-schema]]]
["query-block-content-versions"
[:map
[:graph-uuid :uuid]
[:block-uuids [:sequential :uuid]]]]
["calibrate-graph-skeleton"
[:map
[:graph-uuid :uuid]
[:t :int]
[:schema-version :int]
[:db-ident-blocks [:sequential
[:map
[:db/ident :keyword]
[::m/default extra-attr-map-schema]]]]]]
["get-graph-skeleton"
[:map
[:graph-uuid :uuid]
[:schema-version db-schema/major-schema-version-string-schema]]]
["get-assets-upload-urls"
[:map
[:graph-uuid :uuid]
[:asset-uuid->metadata [:map-of :uuid [:map-of :string :string]]]]]
["get-assets-download-urls"
[:map
[:graph-uuid :uuid]
[:asset-uuids [:sequential :uuid]]]]
["delete-assets"
[:map
[:graph-uuid :uuid]
[:schema-version db-schema/major-schema-version-string-schema]
[:asset-uuids [:sequential :uuid]]]]
;; ================================================================
["upload-user-rsa-key-pair"
[:map
[:user-uuid :uuid]
[:public-key {:optional true} :string]
[:encrypted-private-key :string]
[:reset-private-key {:optional true} :boolean]]]
["reset-user-rsa-key-pair"
[:map
[:user-uuid :uuid]
[:public-key :string]
[:encrypted-private-key :string]]]
["fetch-user-rsa-key-pair"
[:map
[:user-uuid :uuid]]]
["fetch-graph-encrypted-aes-key"
[:map
[:graph-uuid :uuid]]]
["fetch-user-rsa-public-key"
[:map
[:user/email :string]]]])))
(def data-to-ws-encoder (m/encoder data-to-ws-schema (mt/transformer
mt/string-transformer
(mt/key-transformer {:encode m/-keyword->string}))))
(def data-to-ws-coercer (m/coercer data-to-ws-schema mt/string-transformer nil
#(do
(log/error ::data-to-ws-schema %)
(m/-fail! ::data-to-ws-schema (select-keys % [:value])))))

View File

@@ -12,9 +12,9 @@
[frontend.worker.rtc.client-op :as client-op]
[frontend.worker.rtc.const :as rtc-const]
[frontend.worker.rtc.log-and-state :as rtc-log-and-state]
[frontend.worker.rtc.malli-schema :as rtc-schema]
[frontend.worker.state :as worker-state]
[lambdaisland.glogi :as log]
[logseq-schema.rtc-api-schema :as rtc-api-schema]
[logseq.clj-fractional-indexing :as index]
[logseq.common.util :as common-util]
[logseq.db :as ldb]
@@ -598,7 +598,7 @@
"If the check passes, return true"
[repo remote-update-event add-log-fn]
(let [remote-update-data (:value remote-update-event)]
(assert (rtc-schema/data-from-ws-validator remote-update-data) remote-update-data)
(assert (rtc-api-schema/data-from-ws-validator remote-update-data) remote-update-data)
(let [{remote-latest-t :t
remote-t-before :t-before
remote-t :t-query-end} remote-update-data

View File

@@ -7,7 +7,7 @@
[frontend.worker.flows :as worker-flows]
[frontend.worker.rtc.debug-log :as rtc-debug-log]
[frontend.worker.rtc.exception :as r.ex]
[frontend.worker.rtc.malli-schema :as rtc-schema]
[logseq-schema.rtc-api-schema :as rtc-api-schema]
[missionary.core :as m]))
(defn- get-state
@@ -136,8 +136,8 @@
"Returns a task: send message"
[mws message]
(m/sp
(let [decoded-message (rtc-schema/data-to-ws-coercer message)
message-str (js/JSON.stringify (clj->js (rtc-schema/data-to-ws-encoder decoded-message)))]
(let [decoded-message (rtc-api-schema/data-to-ws-coercer message)
message-str (js/JSON.stringify (clj->js (rtc-api-schema/data-to-ws-encoder decoded-message)))]
(rtc-debug-log/log-ws-message! :send message-str)
(m/? ((:send mws) message-str)))))
@@ -157,7 +157,7 @@
(:message m))
(throw r.ex/ex-unknown-server-error)
m)))
(map rtc-schema/data-from-ws-coercer)
(map rtc-api-schema/data-from-ws-coercer)
(:recv-flow m-ws)))
(defn recv-flow
@@ -170,7 +170,7 @@
(if-let [s3-presign-url (:s3-presign-url resp)]
(let [{:keys [status body]} (m/? (http/get s3-presign-url {:with-credentials? false}))]
(if (http/unexceptional-status? status)
(rtc-schema/data-from-ws-coercer (js->clj (js/JSON.parse body) :keywordize-keys true))
(rtc-api-schema/data-from-ws-coercer (js->clj (js/JSON.parse body) :keywordize-keys true))
{:req-id (:req-id resp)
:ex-message "get s3 object failed"
:ex-data {:type :rtc.exception/get-s3-object-failed :status status :body body}}))
@@ -206,7 +206,7 @@
(instance? ExceptionInfo r) r
(http/unexceptional-status? status)
(rtc-schema/data-from-ws-coercer (js->clj (js/JSON.parse body) :keywordize-keys true))
(rtc-api-schema/data-from-ws-coercer (js->clj (js/JSON.parse body) :keywordize-keys true))
:else
{:req-id (:req-id ws-message-result)

View File

@@ -3,10 +3,10 @@
(:require [cljs-http-missionary.client :as http]
[frontend.worker-common.util :as worker-util]
[frontend.worker.rtc.db :as rtc-db]
[frontend.worker.rtc.malli-schema :as rtc-schema]
[frontend.worker.rtc.ws :as ws]
[frontend.worker.state :as worker-state]
[goog.string :as gstring]
[logseq-schema.rtc-api-schema :as rtc-api-schema]
[logseq.graph-parser.utf8 :as utf8]
[missionary.core :as m]))
@@ -38,9 +38,9 @@
[ws message]
{:pre [(= "apply-ops" (:action message))]}
(m/sp
(let [decoded-message (rtc-schema/data-to-ws-coercer (assoc message :req-id "temp-id"))
(let [decoded-message (rtc-api-schema/data-to-ws-coercer (assoc message :req-id "temp-id"))
message-str (js/JSON.stringify
(clj->js (select-keys (rtc-schema/data-to-ws-encoder decoded-message)
(clj->js (select-keys (rtc-api-schema/data-to-ws-encoder decoded-message)
["graph-uuid" "ops" "t-before" "schema-version" "api-version"])))
len (.-length (utf8/encode message-str))]
(when (< 100000 len)

View File

@@ -5,8 +5,8 @@
[frontend.state :as state]
[frontend.test.helper :as test-helper]
[frontend.worker.fixtures :as worker-fixtures]
[frontend.worker.rtc.malli-schema :as rtc-schema]
[frontend.worker.rtc.remote-update :as r.remote]
[logseq-schema.rtc-api-schema :as rtc-api-schema]
[logseq.db :as ldb]
[logseq.outliner.core :as outliner-core]
[logseq.outliner.transaction :as outliner-tx]))
@@ -204,7 +204,7 @@
(:move-ops-map
(#'r.remote/affected-blocks->diff-type-ops
repo (:affected-blocks data-from-ws))))]
(is (rtc-schema/data-from-ws-validator data-from-ws) data-from-ws)
(is (rtc-api-schema/data-from-ws-validator data-from-ws) data-from-ws)
(apply-move-ops! conn move-ops)
(let [page-blocks (ldb/get-page-blocks @conn (:db/id (ldb/get-page @conn page-name)) {})]
(is (= #{uuid1-remote uuid1-client uuid2-client} (set (map :block/uuid page-blocks)))
@@ -234,7 +234,7 @@
(:move-ops-map
(#'r.remote/affected-blocks->diff-type-ops
repo (:affected-blocks data-from-ws))))]
(is (rtc-schema/data-from-ws-validator data-from-ws))
(is (rtc-api-schema/data-from-ws-validator data-from-ws))
(apply-move-ops! conn move-ops)
(let [page-blocks (ldb/get-page-blocks @conn (:db/id (ldb/get-page @conn page-name)) {})]
(is (= #{uuid1-remote uuid2-remote uuid1-client uuid2-client} (set (map :block/uuid page-blocks))))
@@ -274,7 +274,7 @@
(vals
(:remove-ops-map
(#'r.remote/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws))))]
(is (rtc-schema/data-from-ws-validator data-from-ws))
(is (rtc-api-schema/data-from-ws-validator data-from-ws))
(#'r.remote/apply-remote-remove-ops conn remove-ops)
(let [page-blocks (ldb/get-page-blocks @conn (:db/id (ldb/get-page @conn page-name)) {})]
(is (= #{uuid1-client uuid2-client} (set (map :block/uuid page-blocks)))))))
@@ -286,7 +286,7 @@
remove-ops (vals
(:remove-ops-map
(#'r.remote/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws))))]
(is (rtc-schema/data-from-ws-validator data-from-ws))
(is (rtc-api-schema/data-from-ws-validator data-from-ws))
(#'r.remote/apply-remote-remove-ops conn remove-ops)
(let [page-blocks (ldb/get-page-blocks @conn (:db/id (ldb/get-page @conn page-name)) {})]
(is (= #{uuid2-client} (set (map :block/uuid page-blocks)))))))))
@@ -342,7 +342,7 @@ result:
(vals
(:remove-ops-map
(#'r.remote/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws))))]
(is (rtc-schema/data-from-ws-validator data-from-ws))
(is (rtc-api-schema/data-from-ws-validator data-from-ws))
(#'r.remote/apply-remote-remove-ops conn remove-ops)
(let [page-blocks (ldb/get-page-blocks @conn (:db/id (ldb/get-page @conn page-name)))]
(is (= [uuid3 uuid1] (map :block/uuid (sort-by :block/order page-blocks)))))))))
@@ -366,7 +366,7 @@ result:
update-page-ops (vals
(:update-page-ops-map
(#'r.remote/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws))))]
(is (rtc-schema/data-from-ws-validator data-from-ws))
(is (rtc-api-schema/data-from-ws-validator data-from-ws))
(#'r.remote/apply-remote-update-page-ops repo conn update-page-ops)
(is (= page1-uuid (:block/uuid (d/entity @conn [:block/uuid page1-uuid]))))))
@@ -383,7 +383,7 @@ result:
update-page-ops (vals
(:update-page-ops-map
(#'r.remote/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws))))]
(is (rtc-schema/data-from-ws-validator data-from-ws))
(is (rtc-api-schema/data-from-ws-validator data-from-ws))
(#'r.remote/apply-remote-update-page-ops repo conn update-page-ops)
(is (= (str page1-uuid "-rename") (:block/name (d/entity @conn [:block/uuid page1-uuid]))))))
@@ -395,7 +395,7 @@ result:
remove-page-ops (vals
(:remove-page-ops-map
(#'r.remote/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws))))]
(is (rtc-schema/data-from-ws-validator data-from-ws))
(is (rtc-api-schema/data-from-ws-validator data-from-ws))
(#'r.remote/apply-remote-remove-page-ops conn remove-page-ops)
(is (nil? (d/entity @conn [:block/uuid page1-uuid])))))))
@@ -447,7 +447,7 @@ result:
all-ops (#'r.remote/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws))
update-page-ops (vals (:update-page-ops-map all-ops))
move-ops (#'r.remote/move-ops-map->sorted-move-ops (:move-ops-map all-ops))]
(is (rtc-schema/data-from-ws-validator data-from-ws))
(is (rtc-api-schema/data-from-ws-validator data-from-ws))
(#'r.remote/apply-remote-update-page-ops repo conn date-formatter update-page-ops)
(#'r.remote/apply-remote-move-ops repo conn date-formatter move-ops)
(let [page (ldb/get-page @conn page-name)]