Manta Developers
GitHub
Menu

@manta-eu/horns/rules

Reference for @manta-eu/horns/rules in @manta-eu/horns 0.2.3.

Type Aliases

RuleColumn

RuleColumn = object

Properties

name

name: string

type

type: RuleFieldType


RuleCoverage

RuleCoverage = object

Properties

covered

covered: number

entries

entries: RuleCoverageEntry[]

plans

plans: number

Rules that draft work rather than working a value out, counted apart: a different kind of page.

total

total: number


RuleCoverageEntry

RuleCoverageEntry = object

Properties

issues?

optional issues?: string[]

What refused it, in the words of whatever refused it.

rule

rule: GraphRule

spec?

optional spec?: RuleViewSpec

status

status: RuleCoverageStatus


RuleCoverageStatus

RuleCoverageStatus = "covered" | "unparsed" | "no-select"


RuleFieldType

RuleFieldType = "iri" | "string" | "number" | "date" | "boolean"


RuleViewProblem

RuleViewProblem = object

Why a rule has no view, in the words of whatever refused it.

Properties

issues

issues: string[]

reason

reason: "unparsed" | "no-select"


RuleViewResult

RuleViewResult = { ok: true; spec: RuleViewSpec; } | { ok: false; problem: RuleViewProblem; }


RuleViewSpec

RuleViewSpec = object

Properties

columns

columns: RuleColumn[]

conditions

conditions: string[]

What makes it fire, in the parser’s own words.

derives

derives: { column: RuleColumn; kind: "column"; } | { kind: "constant"; value: string; } | undefined

What the rule works out.

column when the value varies per row. constant when the head asserts a fixed value — :inGoodStanding[?s, true] derives nothing a row carries; being in the result is the derivation, and a card says so rather than showing a blank.

kind

kind: "derivation" | "plan"

derivation works a value out; plan drafts work into an ActionPlan_* graph.

rule

rule: string

sparql

sparql: string

The rule’s body as SPARQL, which is what the view binds to.

subject

subject: RuleColumn | undefined

The column holding the thing the rule is about, so a card can title and link it.

title

title: string

Variables

localName

const localName: (term) => string

Parameters

term

string

Returns

string


maxRuleColumns

const maxRuleColumns: 10 = 10


ruleViewLimit

const ruleViewLimit: 200 = 200

Functions

ruleCardSource()

ruleCardSource(spec): string

The TSX for a rule’s view, over the rows its own body selects.

Generated from the spec rather than stored, as a shape’s card is: the rule is the source of truth and the surface can change underneath it.

Parameters

spec

RuleViewSpec

Returns

string


ruleCoverage()

ruleCoverage(args): RuleCoverage

Parameters

args
realm

"hiremanta-com" | "journey-travel"

rules

readonly GraphRule[]

Returns

RuleCoverage


ruleHornView()

ruleHornView(spec): object

The rule’s view: its own body as the binding, drawn by source built from the same tree.

Parameters

spec

RuleViewSpec

Returns

object

binding

binding: { columns: object[]; derivations: string[]; kind: "select"; limit: number; params: string[]; sparql: string; } | { classIri: string; derivations: string[]; fields: object[]; kind: "lens"; limit: number; rows?: "entity" | "value"; } | { kind: "query"; limit: number; params: string[]; query: { hash: string; item: string; revision: string; }; }

emits?

optional emits?: object[]

id

id: string

render

render: { component: { hash: string; item: string; revision: string; }; kind: "component"; props: JSONType; } | { kind: "tsx"; reviewed?: { at: string; hash: string; }; source: string; }

title

title: string


ruleTitle()

ruleTitle(iri, derives): string

Rule_SubscriptionInGoodStanding → “Subscription in good standing”.

Parameters

iri

string

derives

string | undefined

Returns

string


ruleView()

ruleView(args): RuleViewResult

The view a rule describes.

Every rule the SDK can translate gets one, because its body is a query and the query is the view. What is refused is refused by the parser, not by a guess here: a body it cannot read, or one it will not translate (SKOLEM mints IRIs, which SPARQL has no way to ask for).

Parameters

args
body

string

iri

string

realm

"hiremanta-com" | "journey-travel"

Returns

RuleViewResult


ruleViewId()

ruleViewId(iri): string

Rule_PixelPurchaseEmq → rule-pixel-purchase-emq, a Horn’s local id.

Parameters

iri

string

Returns

string


ruleWorklist()

ruleWorklist(coverage, limit?): RuleCoverageEntry[]

What to look at next: the rules that describe a view, the ones that work a value out first.

A derivation is a number or a state on a thing, which is a page somebody reads; a plan rule is the queue of work it would draft, which the action-plan strip already shows under the views it affects.

Parameters

coverage

RuleCoverage

limit?

number

Returns

RuleCoverageEntry[]