Liking cljdoc? Tell your friends :D

hara.data.pipeline


normaliseclj

(normalise data {:keys [pipeline] :as datasource})
(normalise data datasource wrappers)

base normalise function for testing purposes

(normalise {:account/name "Chris" :account/age 10} {:schema (schema/schema examples/account-name-age-sex)} {}) => {:account {:age 10, :name "Chris"}}

(normalise {:link/value "hello" :link {:next/value "world" :next/next {:value "!"}}} {:schema (schema/schema examples/link-value-next)} {})

=> {:link {:next {:next {:value "!"} :value "world"} :value "hello"}}

base normalise function for testing purposes

(normalise {:account/name "Chris"
            :account/age 10}
           {:schema (schema/schema examples/account-name-age-sex)}
           {})
=> {:account {:age 10, :name "Chris"}}

(normalise {:link/value "hello"
            :link {:next/value "world"
                   :next/next {:value "!"}}}
           {:schema (schema/schema examples/link-value-next)}
           {})

=> {:link {:next {:next {:value "!"}
                  :value "world"}
           :value "hello"}}
raw docstring

normalise-attrclj

(normalise-attr subdata [attr] nsv interim fns datasource)

base function for treating attributes

(normalise-attr "Chris" [{:type :string, :cardinality :one, :ident :account/name}] [:account :name] {} {:normalise-single normalise-single} {}) => "Chris"

base function for treating attributes

(normalise-attr "Chris"
                [{:type :string, :cardinality :one, :ident :account/name}]
                [:account :name]
                {}
                {:normalise-single normalise-single}
                {})
=> "Chris"
raw docstring

normalise-baseclj

(normalise-base tdata datasource wrappers)

normalise-expressionclj

(normalise-expression subdata [attr] nsv interim datasource)

normalises an expression

normalises an expression
raw docstring

normalise-loopclj

(normalise-loop tdata tsch nsv interim fns datasource)

base loop for the normalise function

(normalise-loop {:name "Chris", :age 10} {:name [{:type :string, :cardinality :one, :ident :account/name}], :age [{:type :long, :cardinality :one, :ident :account/age}], :sex [{:type :enum, :cardinality :one, :enum {:ns :account.sex, :values #{:m :f}}, :ident :account/sex}]} [:account] {} {:normalise normalise-loop :normalise-single normalise-single :normalise-attr normalise-attr} {:schema (schema/schema examples/account-name-age-sex)}) => {:name "Chris", :age 10}

base loop for the normalise function

(normalise-loop {:name "Chris", :age 10}
                {:name [{:type :string,
                         :cardinality :one,
                         :ident :account/name}],
                 :age [{:type :long,
                        :cardinality :one,
                        :ident :account/age}],
                 :sex [{:type :enum,
                       :cardinality :one,
                        :enum {:ns :account.sex, :values #{:m :f}},
                        :ident :account/sex}]}
                [:account]
                {}
                {:normalise normalise-loop
                 :normalise-single normalise-single
                 :normalise-attr normalise-attr}
                {:schema (schema/schema examples/account-name-age-sex)})
=> {:name "Chris", :age 10}
raw docstring

normalise-nilclj

(normalise-nil subdata _ nsv interim datasource)

base function for treating nil values

(normalise-nil nil [:user :password] {} {} nil) => throws

base function for treating nil values

(normalise-nil nil [:user :password] {} {} nil)
=> throws
raw docstring

normalise-singleclj

(normalise-single subdata [attr] nsv interim fns datasource)

verifies and constructs a ref value

(normalise-single {:value "world"} [{:type :ref, :ident :link/next :cardinality :one, :ref {:ns :link, :rval :prev, :type :forward, :key :link/next, :val :next, :rkey :link/_next, :rident :link/prev},}]

              [:link :next]
              {}
              {:normalise-attr normalise-attr
               :normalise normalise-loop
               :normalise-single normalise-single}
              {:schema (schema/schema examples/link-value-next)})

=> {:value "world"}

verifies and constructs a ref value

(normalise-single {:value "world"}
                  [{:type :ref,
                    :ident :link/next
                    :cardinality :one,
                    :ref {:ns :link,
                          :rval :prev,
                          :type :forward,
                          :key :link/next,
                         :val :next,
                          :rkey :link/_next,
                          :rident :link/prev},}]
                  
                  [:link :next]
                  {}
                  {:normalise-attr normalise-attr
                   :normalise normalise-loop
                   :normalise-single normalise-single}
                  {:schema (schema/schema examples/link-value-next)})
=> {:value "world"}
raw docstring

normalise-wrapclj

(normalise-wrap fns wrappers)

helper function for normalise-wrappers

helper function for normalise-wrappers
raw docstring

normalise-wrapper-fnsclj


normalise-wrappersclj

(normalise-wrappers datasource)
(normalise-wrappers {:keys [pipeline options]} additions fns)

adds function wrappers to the normalise functions

adds function wrappers to the normalise functions
raw docstring

submapsclj

(submaps m options subk)

creates a submap based upon a lookup subkey (submaps {:allow {:account :check} :ignore {:account :check}} #{:allow :ignore} :account) => {:allow :check, :ignore :check}

creates a submap based upon a lookup subkey
(submaps {:allow  {:account :check}
          :ignore {:account :check}} #{:allow :ignore} :account)
=> {:allow :check, :ignore :check}
raw docstring

tree-directivesclj


wrap-key-pathclj

(wrap-key-path f)

Used for tracing the keys through normalise (normalise {:account {:orders {:+ {:account {:WRONG "Chris"}}}}} {:schema (schema/schema examples/account-orders-items-image)} {:normalise [wrap-plus] :normalise-branch [wrap-key-path] :normalise-attr [wrap-key-path]})

=> (throws-info {:key-path [:account :orders :+ :account]})

Used for tracing the keys through `normalise`
(normalise {:account {:orders {:+ {:account {:WRONG "Chris"}}}}}
           {:schema (schema/schema examples/account-orders-items-image)}
           {:normalise [wrap-plus]
            :normalise-branch [wrap-key-path]
            :normalise-attr [wrap-key-path]})

=>  (throws-info {:key-path [:account :orders :+ :account]})
raw docstring

wrap-plusclj

(wrap-plus f)

Allows additional attributes (besides the link :ns) to be added to the entity (normalise {:account {:orders {:+ {:account {:user "Chris"}}}}} {:schema (schema/schema examples/account-orders-items-image)} {:normalise [wrap-plus]}) => {:account {:orders {:+ {:account {:user "Chris"}}}}}

Allows additional attributes (besides the link :ns) to be added to the entity
(normalise {:account {:orders {:+ {:account {:user "Chris"}}}}}
           {:schema (schema/schema examples/account-orders-items-image)}
           {:normalise [wrap-plus]})
=> {:account {:orders {:+ {:account {:user "Chris"}}}}}
raw docstring

wrap-ref-pathclj

(wrap-ref-path f)

Used for tracing the entities through normalise (normalise {:account {:orders {:+ {:account {:WRONG "Chris"}}}}} {:schema (schema/schema examples/account-orders-items-image)} {:normalise [wrap-ref-path wrap-plus]})

=> (throws-info {:ref-path [{:account {:orders {:+ {:account {:WRONG "Chris"}}}}} {:account {:WRONG "Chris"}}]})

Used for tracing the entities through `normalise`
(normalise {:account {:orders {:+ {:account {:WRONG "Chris"}}}}}
           {:schema (schema/schema examples/account-orders-items-image)}
           {:normalise [wrap-ref-path wrap-plus]})

=> (throws-info {:ref-path
                  [{:account {:orders {:+ {:account {:WRONG "Chris"}}}}}
                   {:account {:WRONG "Chris"}}]})
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close