(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"}}
(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"
(normalise-base tdata datasource wrappers)
(normalise-expression subdata [attr] nsv interim datasource)
normalises an expression
normalises an expression
(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}
(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
(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"}
(normalise-wrap fns wrappers)
helper function for normalise-wrappers
helper function for normalise-wrappers
(normalise-wrappers datasource)
(normalise-wrappers {:keys [pipeline options]} additions fns)
adds function wrappers to the normalise functions
adds function wrappers to the normalise functions
(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}
(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]})
(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"}}}}}
(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"}}]})
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close