mirror of
https://github.com/status-im/pluto.git
synced 2025-02-24 00:18:16 +00:00
Access host defined functions
This commit is contained in:
parent
95e44c9eee
commit
d4b625cc8e
@ -22,7 +22,8 @@
|
||||
::forbidden-write-path
|
||||
::query-not-exposed
|
||||
::invalid-event-handler
|
||||
::event-not-exposed})
|
||||
::event-not-exposed
|
||||
::function-not-exposed})
|
||||
|
||||
(spec/def ::value any?)
|
||||
|
||||
|
@ -60,6 +60,9 @@
|
||||
(defmethod resolve-property :query [def hook {:keys [capacities]} _]
|
||||
(resolve-capacities-value :queries ::errors/query-not-exposed capacities def hook))
|
||||
|
||||
(defmethod resolve-property :function [def hook {:keys [capacities]} _]
|
||||
(resolve-capacities-value :functions ::errors/function-not-exposed capacities def hook))
|
||||
|
||||
(defn- resolve-property-value [f {:keys [name optional?]} hook]
|
||||
(if-let [o (get hook name)]
|
||||
(if (f o)
|
||||
|
@ -94,6 +94,26 @@
|
||||
{:query :get-in}
|
||||
{:capacities {:queries #{:get-in}}}
|
||||
{}))))
|
||||
|
||||
(testing "Function"
|
||||
(is (= {:errors [{:pluto.reader.errors/type ::errors/invalid-property-name
|
||||
:pluto.reader.errors/value :function}]}
|
||||
(hooks/resolve-property {:type :function :name :function}
|
||||
{}
|
||||
{:capacities {}}
|
||||
{})))
|
||||
(is (= {:errors [{:pluto.reader.errors/type ::errors/function-not-exposed
|
||||
:pluto.reader.errors/value '+}]}
|
||||
(hooks/resolve-property {:type :function :name :function}
|
||||
{:function '+}
|
||||
{:capacities {:functions #{}}}
|
||||
{})))
|
||||
(is (= {:data +}
|
||||
(hooks/resolve-property {:type :function :name :function}
|
||||
{:function '+}
|
||||
{:capacities {:functions {'+ +}}}
|
||||
{}))))
|
||||
|
||||
(testing "Set"
|
||||
(is (= {:data :one} (hooks/resolve-property {:name :keyword :type {:one-of #{:one :two :three}}} {:keyword :one} {} {})))
|
||||
(is (= {:errors [{::errors/type ::errors/invalid-property-value
|
||||
|
Loading…
x
Reference in New Issue
Block a user