Liking cljdoc? Tell your friends :D

reifyhealth.specmonstah.core


add-edge-with-idclj/s

(add-edge-with-id g ent-name related-ent-name id)

When indicating :ent-a references :ent-b, include a :relation-attrs graph attribute that includes the attributes via which :ent-a references :ent-b.

For example, if the :project named :p0 has an :owner-id and :updated-by-id that both reference the :user named :u0, then the edge from :p0 to :u0 will if a :relation-attrs attribute with value #{:owner-id :updated-by-id}.

This can be used e.g. to set the values for :owner-id and :updated-by-id.

When indicating :ent-a references :ent-b, include a
`:relation-attrs` graph attribute that includes the attributes via
which `:ent-a` references `:ent-b`. 

For example, if the `:project` named `:p0` has an `:owner-id` and
`:updated-by-id` that both reference the `:user` named `:u0`, then
the edge from `:p0` to `:u0` will if a `:relation-attrs` attribute
with value `#{:owner-id :updated-by-id}`.

This can be used e.g. to set the values for `:owner-id` and
`:updated-by-id`.
sourceraw docstring

add-entclj/s

(add-ent {:keys [data] :as db} ent-name ent-type query-term)

Add an ent, and its related ents, to the ent-db

Add an ent, and its related ents, to the ent-db
sourceraw docstring

add-ent-type-queryclj/s

(add-ent-type-query db ent-type-query ent-type)

A query is composed of ent-type-queries, where each ent-type-query specifies the ents that should be created for that type. This function adds the ents for an ent-type-query.

A query is composed of ent-type-queries, where each ent-type-query
specifies the ents that should be created for that type. This
function adds the ents for an ent-type-query.
sourceraw docstring

add-n-entsclj/s

(add-n-ents db ent-type num-ents query-term)

Used when a query is something like [3]

Used when a query is something like [3]
sourceraw docstring

add-ref-entsclj/s

(add-ref-ents db)

Ents are added in two stages: first, all ents that are declared in the query are added. During that process, we keep track of ref-ents, ents which are automatically generated in order to satisfy relations. This function adds those ref ents if an ent of the same name doesn't exist already.

Ents are added in two stages: first, all ents that are declared in
the query are added. During that process, we keep track of ref-ents,
ents which are automatically generated in order to satisfy
relations. This function adds those ref ents if an ent of the same
name doesn't exist already.
sourceraw docstring

(add-related-ents {:keys [data] :as db} ent-name ent-type query-term)
source

all-ent-relationsclj/s

(all-ent-relations db)
(all-ent-relations db ents)

Given a db, returns a map of ent-type to map of entity relations.

An example return value is: {:patient {:p0 {:created-by :u0 :updated-by :u1} :p1 {:created-by :u0 :updated-by :u2}} :user {:u0 {:friends-with :u0}}}

Given a db, returns a map of ent-type to map of entity relations.

An example return value is:
{:patient {:p0 {:created-by :u0
                :updated-by :u1}
           :p1 {:created-by :u0
                :updated-by :u2}}
 :user {:u0 {:friends-with :u0}}}
sourceraw docstring

attr-mapclj/s

(attr-map db attr)
(attr-map {:keys [data] :as db} attr ents)

Produce a map where each key is a node and its value is a graph attr on that node

Produce a map where each key is a node and its value is a graph
attr on that node
sourceraw docstring

bound-descendants?clj/s

(bound-descendants? {:keys [types schema relation-graph]}
                    query-bindings
                    related-ent-type)

Check whether query-relations contains bindings that apply to any descendants of related-ent-type

Check whether `query-relations` contains bindings that apply to any
descendants of `related-ent-type`
sourceraw docstring

bound-relation-attr-nameclj/s

(bound-relation-attr-name {:keys [schema]} ent-name related-ent-type index)

Template for when a binding necessitates you add a new entity

Template for when a binding necessitates you add a new entity
sourceraw docstring

bound-relation-attr-name-sourceclj/s

(bound-relation-attr-name-source ent-name)
source

build-ent-dbclj/s

(build-ent-db {:keys [schema] :as db} query)

Produce a new db that contains all ents specified by query

Produce a new db that contains all ents specified by query
sourceraw docstring

coll-relation-attr?clj/s

(coll-relation-attr? db ent relation-attr)

Given a db, ent, and relation-attr, determines whether the relation is a coll attr.

Given a db, ent, and relation-attr, determines whether the relation is
a coll attr.
sourceraw docstring

conformed-query-optsclj/s

(conformed-query-opts query-term relation-attr)

These conformed query opts allow us to 1) validate the query term and 2) dispatch on what kind of query was supplied.

This is one of the most complicated parts of SM because users can supply different types of values for the :refs key of a query:

  1. an ent-name for unary relations (type: :ent-name)
  2. a vector of ent-names for coll relations (type: :ent-names)
  3. a number for coll relations (type: :ent-count)

These types are captured by the ::refs specs, and the specs it composes. The type for the supplied query-term is returned as :qr-type.

Each of these qr-types corresponds to a constraint of either :coll or :unary. The constraint is returned as :qr-constraint.

Conforming the query opts provides the qr-type and qr-constraint so that dependent functions can dispatch on these values.

These conformed query opts allow us to 1) validate the query term and
2) dispatch on what kind of query was supplied.

This is one of the most complicated parts of SM because users can
supply different types of values for the `:refs` key of a query:

1. an ent-name for unary relations          (type: `:ent-name`)
2. a vector of ent-names for coll relations (type: `:ent-names`)
3. a number for coll relations              (type: `:ent-count`)

These types are captured by the `::refs` specs, and the specs it
composes. The type for the supplied query-term is returned as
`:qr-type`.

Each of these qr-types corresponds to a constraint of either `:coll`
or `:unary`. The constraint is returned as `:qr-constraint`.

Conforming the query opts provides the `qr-type` and `qr-constraint`
so that dependent functions can dispatch on these values.
sourceraw docstring

default-node-nameclj/s

(default-node-name {:keys [schema]} ent-type)

Whenever specmonstah needs to create a node that's not manually named, it uses this to generate the default name.

Whenever specmonstah needs to create a node that's not manually
named, it uses this to generate the default name.
sourceraw docstring

ent-attrsclj/s

(ent-attrs {:keys [data]} ent-name)
source

ent-indexclj/s

(ent-index g ent-type)

Used to keep track of entity's insertion order in graph relative to other entities of the same type.

Used to keep track of entity's insertion order in graph relative to
other entities of the same type.
sourceraw docstring

(ent-related-by-attr? db ent-name related-ent relation-attr)

Is ent A related to ent B by the given relation-attr?

Is ent A related to ent B by the given relation-attr?
sourceraw docstring

ent-relation-constraintsclj/s

(ent-relation-constraints db ent relation-attr)
source

ent-relationsclj/s

(ent-relations db ent)

Given a db and an ent, returns a map of relation attr to ent-name.

Given a db and an ent, returns a map of relation attr to ent-name.
sourceraw docstring

ent-schemaclj/s

(ent-schema {:keys [schema data]} ent-name)

Given an ent name, return the schema of its corresponding type

Given an ent name, return the schema of its corresponding type
sourceraw docstring

entsclj/s

(ents {:keys [data]})
source

ents-by-typeclj/s

(ents-by-type db)
(ents-by-type db ents)

Given a db, returns a map of ent-type to a set of entities of that type. Optionally pass in a seq of the ents that should be included.

Given a db, returns a map of ent-type to a set of entities of that
type. Optionally pass in a seq of the ents that should be included.
sourceraw docstring

identical-prefixesclj/s

(identical-prefixes schema)

Schemas are invalid if two types have the same prefix. This checks that.

Schemas are invalid if two types have the same prefix. This checks
that.
sourceraw docstring

incrementing-node-nameclj/s

(incrementing-node-name {:keys [data schema]} ent-type)

A template for creating distinct node names.

A template for creating distinct node names.
sourceraw docstring

init-dbclj/s

(init-db {:keys [schema] :as db} query)
source

invalid-constraintsclj/s

(invalid-constraints schema)

Constraints that reference nonexistent relation attrs

Constraints that reference nonexistent relation attrs
sourceraw docstring

invalid-schema-relationsclj/s

(invalid-schema-relations schema)

Relations that reference nonexistent types

Relations that reference nonexistent types
sourceraw docstring

numeric-node-nameclj/s

(numeric-node-name schema ent-type index)

Template for generating a node name

Template for generating a node name
sourceraw docstring

omit?clj/s

(omit? x)
source

query-entsclj/s

(query-ents {:keys [data queries] :as db})

Get seq of nodes that are explicitly defined in the query

Get seq of nodes that are explicitly defined in the query
sourceraw docstring

query-optsclj/s

(query-opts {:keys [data]} ent-name)
source

query-relationclj/s

(query-relation db ent-name relation-attr)

Returns the conformed relation for an ent's relation-attr. Handles polymorphic relations.

Returns the conformed relation for an ent's relation-attr. Handles
polymorphic relations.
sourceraw docstring

referenced-ent-attrsclj/s

(referenced-ent-attrs {:keys [data] :as db} ent-name)

seq of [referenced-ent relation-attr]

seq of [referenced-ent relation-attr]
sourceraw docstring

(related-ents {:keys [schema data] :as db}
              ent-name
              relation-attr
              related-ent-type
              query-term)

Returns all related ents for an ent's relation-attr

Returns all related ents for an ent's relation-attr
sourceraw docstring

(related-ents-by-attr {:keys [data] :as db} ent-name relation-attr)

All ents related to ent via relation-attr

All ents related to ent via relation-attr
sourceraw docstring

relation-attrsclj/s

(relation-attrs {:keys [data]} ent-name referenced-ent)

Given an ent A and an ent it references B, return the set of attrs by which A references B

Given an ent A and an ent it references B, return the set of attrs
by which A references B
sourceraw docstring

relation-attrs-with-constraintclj/s

(relation-attrs-with-constraint db ent-name constraint)

Given an ent name, return all relation attributes which include the constraint.

Given an ent name, return all relation attributes which include the constraint.
sourceraw docstring

relation-graphclj/s

(relation-graph schema)

A graph of the type dependencies in a schema. If entities of type :project reference an entity of type :user via :owner-id, then this will return a graph where the :project node connects to the :user node

A graph of the type dependencies in a schema. If entities of type
`:project` reference an entity of type `:user` via `:owner-id`, then
this will return a graph where the `:project` node connects to the
`:user` node
sourceraw docstring

required-entsclj/s

(required-ents db ent-name)

For ent A, returns all the referenced ents that ent A requires as specified in the schema's constraints. Used to order ent sequences; ensures that required ents are positioned before the ents that require them.

For ent A, returns all the referenced ents that ent A requires as
specified in the schema's constraints. Used to order ent sequences;
ensures that required ents are positioned before the ents that
require them.
sourceraw docstring

sort-by-requiredclj/s

(sort-by-required {:keys [schema data] :as db} ents)

If :a0 depends on :b0, returns the vector [:b0 :a0]

If :a0 depends on :b0, returns the vector [:b0 :a0]
sourceraw docstring

throw-invalid-specclj/s

(throw-invalid-spec arg-name spec data)
source

topsort-entsclj/s

(topsort-ents {:keys [data]})
source

uniq-relation-attr?clj/s

(uniq-relation-attr? db ent relation-attr)

Given a db, ent, and relation-attr, determines whether the relation is a uniq attr.

Given a db, ent, and relation-attr, determines whether the relation is
a uniq attr.
sourceraw docstring

(validate-related-ents-query {:keys [schema data] :as db}
                             ent-name
                             relation-attr
                             query-term)

Check that the refs value supplied in a query is a collection if the relation type is collection, or a keyword if the relation type is unary. If the reference is omit, no further validation is required.

Check that the refs value supplied in a query is a collection if the
relation type is collection, or a keyword if the relation type is
unary. If the reference is omit, no further validation is required.
sourceraw docstring

visit-entsclj/s

(visit-ents db visit-key visit-fns)
(visit-ents db visit-key visit-fns ents)

Perform visit-fns on ents, storing return value as a graph attribute under visit-key

Perform `visit-fns` on ents, storing return value as a graph
attribute under `visit-key`
sourceraw docstring

visit-ents-onceclj/s

(visit-ents-once db visit-key visit-fns)
(visit-ents-once db visit-key visit-fns ents)

Like visit-ents but doesn't call visit-fn if the ent already has a visit-key attribute

Like `visit-ents` but doesn't call `visit-fn` if the ent already
has a `visit-key` attribute
sourceraw docstring

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

× close