Skip to content

Commit

Permalink
fix: validation for core package
Browse files Browse the repository at this point in the history
  • Loading branch information
krvital committed Jul 30, 2024
1 parent 0c18866 commit b632323
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/aidbox_sdk/schema/verify.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,23 @@
(defn simplify-package-meta [package]
(select-keys package [:name :version]))


;; FIXME: is it reliable to use first element of the list?
;; ! seems like it's not for original packages (without Aidbox processing).
(defn extract-meta-from-package
"Extracts meta information from the package."
[package]
(first package))

(defn core-package? [package]
(or
(= "Core" (:type package))
(= "fhir.core" (:type package))))

(defn find-core-package
"Finds core package in the list of packages.
Throws an exception if there are more then one core package."
[packages]
(let [cores (filter #(= "fhir.core" (:type %)) packages)
(let [cores (filter core-package? packages)
core (first cores)]
(cond
(= (count cores) 0)
Expand All @@ -49,7 +53,7 @@
"Finds extra packages in the list of packages.
Throws an exception if there are a few packages with same name."
[packages]
(let [extra (remove #(= "fhir.core" (:type %)) packages)
(let [extra (remove core-package? packages)

duplicates (reduce (fn [duplicates [k v]]
(if (= (count v) 1)
Expand All @@ -64,7 +68,7 @@
:else
extra))

(remove #(= "fhir.core" (:type %)) packages))
(remove core-package? packages))

(defn find-core-package-mismatch
"Finds packages which do not support a core package version."
Expand Down

0 comments on commit b632323

Please sign in to comment.