std.lib.transform
normalise
added in 3.0
(normalise data {:keys [pipeline], :as datasource})(normalise data datasource wrappers)base normalise function
(normalise {:account/name “Chris” :account/age 10} {:schema (schema/schema examples/account-name-age-sex)} {}) => {:account {:age 10, :name “Chris”}}
(normalise {:link/value “hello”} {:schema (schema/schema examples/link-value-next)} {}) => {:link {:value “hello”}}
(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”}}
normalise-attr
added in 3.0
(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”
normalise-base
added in 3.0
(normalise-base tdata datasource wrappers)base normalise function
normalise-expression
added in 3.0
(normalise-expression subdata [attr] nsv interim datasource)normalises an expression
normalise-loop
added in 3.0
(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}
normalise-nil
added in 3.0
(normalise-nil subdata _ nsv interim datasource)base function for treating nil values
(normalise-nil nil :user :password {} {} nil) => (throws)
normalise-single
added in 3.0
(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”}
normalise-wrap
added in 3.0
(normalise-wrap fns wrappers)helper function for normalise-wrappers
normalise-wrappers
added in 3.0
(normalise-wrappers datasource)(normalise-wrappers {:keys [pipeline options]} additions fns)adds function wrappers to the normalise functions
submaps
added in 3.0
(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}
wrap-key-path
added in 3.0
(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})
wrap-plus
added in 3.0
(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”}}}}}
wrap-ref-path
added in 3.0
(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”}}})