|
|
@ -6,6 +6,9 @@
|
|
|
|
[shadow.resource :as rc]
|
|
|
|
[shadow.resource :as rc]
|
|
|
|
[dda.c4k-common.predicate :as cp]))
|
|
|
|
[dda.c4k-common.predicate :as cp]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn string-or-keyword? [input]
|
|
|
|
|
|
|
|
(or (string? input) (keyword? input)))
|
|
|
|
|
|
|
|
|
|
|
|
(defn-spec from-string cp/map-or-seq?
|
|
|
|
(defn-spec from-string cp/map-or-seq?
|
|
|
|
[input string?]
|
|
|
|
[input string?]
|
|
|
|
(js->clj (yaml/load input)
|
|
|
|
(js->clj (yaml/load input)
|
|
|
@ -16,22 +19,23 @@
|
|
|
|
(yaml/dump (clj->js edn)))
|
|
|
|
(yaml/dump (clj->js edn)))
|
|
|
|
|
|
|
|
|
|
|
|
(defn-spec dispatch-by-resource-name keyword?
|
|
|
|
(defn-spec dispatch-by-resource-name keyword?
|
|
|
|
[resource string?]
|
|
|
|
[resource string-or-keyword?]
|
|
|
|
:cljs)
|
|
|
|
(keyword (first (st/split resource #"/"))))
|
|
|
|
|
|
|
|
|
|
|
|
(defmulti load-resource dispatch-by-resource-name)
|
|
|
|
(defmulti load-resource dispatch-by-resource-name)
|
|
|
|
|
|
|
|
|
|
|
|
(defmethod load-resource :cljs [allowed-resources resource-name]
|
|
|
|
(defmethod load-resource :default [allowed-resources resource-name]
|
|
|
|
(if (some #(= % resource-name) allowed-resources)
|
|
|
|
(if (some #(= % resource-name) allowed-resources)
|
|
|
|
(rc/inline resource-name)
|
|
|
|
(rc/inline resource-name)
|
|
|
|
(throw (js/Error. "Undefined Resource!"))))
|
|
|
|
(throw (js/Error. "Undefined Resource!"))))
|
|
|
|
|
|
|
|
|
|
|
|
(defmulti load-as-edn dispatch-by-resource-name)
|
|
|
|
(defmulti load-as-edn dispatch-by-resource-name)
|
|
|
|
|
|
|
|
|
|
|
|
(defmethod load-as-edn :cljs [allowed-resource resource-name]
|
|
|
|
(defmethod load-as-edn :default [resource-name]
|
|
|
|
(from-string (load-resource (allowed-resource) resource-name)))
|
|
|
|
(let [allowed-resources (allowed-resources)]
|
|
|
|
|
|
|
|
(from-string (load-resource allowed-resources resource-name))))
|
|
|
|
|
|
|
|
|
|
|
|
(defmulti allowed-resources dispatch-by-resource-name)
|
|
|
|
(defmulti allowed-resources dispatch-by-resource-name)
|
|
|
|
|
|
|
|
|
|
|
|
(defmethod allowed-resources :cljs []
|
|
|
|
(defmethod allowed-resources :default []
|
|
|
|
[])
|
|
|
|
[])
|
|
|
|