Skip to content

Commit

Permalink
Updated entity node datatypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Paula Gearon committed Mar 9, 2021
1 parent 358371c commit 15b3f7e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

## [0.4.4] - 2021-03-09
### Changed
- Datatype testing with schema now allows various datatypes as entity nodes.

## [0.4.3] - 2021-03-09
### Added
- Whitelist for function resolution.
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject org.clojars.quoll/zuko "0.4.4-SNAPSHOT"
(defproject org.clojars.quoll/zuko "0.4.4"
:description "Threatgrid library for common graph database functionality"
:url "https://github.com/threatgrid/zuko"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
Expand Down
10 changes: 6 additions & 4 deletions src/zuko/entity/reader.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

(def MapOrList (s/cond-pre EntityMap [s/Any]))

(def NodeType s/Any) ;; No checking, but indicates a node in a graph

(defn get-tg-first
"Finds the tg/first property in a map, and gets the value."
[struct]
Expand Down Expand Up @@ -45,7 +47,7 @@
"Takes property/value pairs and if they represent a list node, returns the list.
else, nil."
[graph :- GraphType
seen :- #{s/Any}
seen :- #{NodeType}
pairs :- [KeyValue]]
;; convert the data to a map
(let [st (into {} pairs)]
Expand All @@ -64,7 +66,7 @@
(s/defn vbuild-list :- [s/Any]
"Calls build-list, converting to a vector as the final step"
[graph :- GraphType
seen :- #{s/Any}
seen :- #{NodeType}
pairs :- [KeyValue]]
(let [l (build-list graph seen pairs)]
(if (seq? l) (vec l) l)))
Expand All @@ -75,7 +77,7 @@
"Determines if the val of a map entry is a node to be recursed on, and loads if necessary.
If referring directly to a top level node, then short circuit and return the ID"
[graph :- GraphType
seen :- #{s/Keyword}
seen :- #{NodeType}
[prop v :as prop-val] :- KeyValue]
(if-let [pairs (check-structure graph prop v)]
(if (and (not *nested-structs*) (some #(= :tg/entity (first %)) pairs))
Expand Down Expand Up @@ -114,7 +116,7 @@
prop-vals :- [KeyValue]] (pairs->struct graph prop-vals #{}))
([graph :- GraphType
prop-vals :- [KeyValue]
seen :- #{s/Keyword}]
seen :- #{NodeType}]
(if (some (fn [[k _]] (= :tg/first k)) prop-vals)
(vbuild-list graph seen prop-vals)
(do
Expand Down

0 comments on commit 15b3f7e

Please sign in to comment.