Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

atomisthq/datalog-schema

Repository files navigation

Usage

Use atomist.datalog.core/report to report on a datalog form that conforms to :atomist.datalog.schema/query.

(ns user
  (:require [atomist.datalog.core]
            [atomist.datalog.schema :as schema]
            [clojure.spec.alpha :as spec]))

(atomist.datalog.core/report
  (spec/conform ::schema/query '[:find (pull ?a [:git.commit/message])
                                 :in $ $b % ?ctx
                                 :where
                                 [?a :git.commit/sha "asdf"]]))

If the datalog is conformed, then atomist.datalog.core/report will walk the conformed data and extract attributes, rules and functions. In the above example, the return value would be the following.

{:attributes #{:git.commit/message :git.commit/sha},
 :rules #{},
 :functions #{}}

Notes

  • handles sub queries
  • extract attributes from data rules, and pull expressions
  • rejects functions that are not built-in or listed in the schema (atomist/older? atomist/indexpackage)
  • accepts all rule names but I'd like to restrict to the set that I know we support - current rules
  • I have run this against every subscription across all of our skills, and the dso queries that I know about. They all conform so this is a good starting point.
    • used this tool to check whether a particular rule or attribute was still being used anywhere

Unit tests

clj -X:test

Releasing

I've just been using this as a git dep in deps.edn so I haven't created a maven package. Do we need one?

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published