An in-memory OKF knowledge bundle — the unit of distribution (OKF §3).
Holds concepts, reserved index/log documents, parse diagnostics, and an optional graph index built from internal links.
Fields
| Field | Type | Description |
|---|---|---|
root | String.t() | Absolute filesystem path to the bundle directory. |
okf_version | String.t() | nil | Declared version from root index.md frontmatter, e.g. "0.1". |
concepts | %{optional(String.t()) => ExOKF.Concept.t()} | Map of concept id → concept. |
indexes | %{optional(String.t()) => ExOKF.Index.t()} | Map of relative path → index doc. |
logs | %{optional(String.t()) => ExOKF.Log.t()} | Map of relative path → log doc. |
diagnostics | ExOKF.Diagnostics.t() | Parse/load diagnostics accumulated while reading. |
graph | map() | nil | Opaque graph handle %{backend: module(), data: term()} after indexing. |
Example
%ExOKF.Bundle{
root: "/data/acme-knowledge",
okf_version: "0.1",
concepts: %{"tables/orders" => %ExOKF.Concept{id: "tables/orders", path: "tables/orders.md", type: "BigQuery Table"}},
indexes: %{"index.md" => %ExOKF.Index{path: "index.md", directory: ""}},
logs: %{"log.md" => %ExOKF.Log{path: "log.md", directory: ""}},
diagnostics: %ExOKF.Diagnostics{entries: []},
graph: %{backend: ExOKF.Graph.Adjacency, data: %ExOKF.Graph.Adjacency{}}
}
Summary
Functions
Returns all concept ids present in the bundle, sorted.
Lists all concepts sorted by id.
Returns the concept with the given id, or nil if absent.
Returns true when the concept id exists in the bundle.
Merges additional diagnostics into the bundle.
Attaches or replaces the graph index on the bundle.
Returns the number of concepts in the bundle.
Types
@type t() :: %ExOKF.Bundle{ concepts: %{optional(String.t()) => ExOKF.Concept.t()}, diagnostics: ExOKF.Diagnostics.t(), graph: map() | nil, indexes: %{optional(String.t()) => ExOKF.Index.t()}, logs: %{optional(String.t()) => ExOKF.Log.t()}, okf_version: String.t() | nil, root: String.t() }
An loaded OKF bundle.
See the module documentation for field meanings and a structural example.
Functions
Returns all concept ids present in the bundle, sorted.
Parameters
bundle(t/0) — loaded bundle
Examples
iex> bundle = ExOKF.TestSupport.minimal_bundle()
iex> ExOKF.Bundle.concept_ids(bundle)
["hello"]
@spec concepts(t()) :: [ExOKF.Concept.t()]
Lists all concepts sorted by id.
Parameters
bundle(t/0) — loaded bundle
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> ExOKF.Bundle.concepts(bundle) |> Enum.map(& &1.id)
["datasets/sales", "tables/customers", "tables/orders"]
@spec get_concept(t(), String.t()) :: ExOKF.Concept.t() | nil
Returns the concept with the given id, or nil if absent.
Parameters
bundle(t/0) — loaded bundleid(String.t()) — concept id, e.g."tables/orders"
Examples
iex> bundle = ExOKF.TestSupport.minimal_bundle()
iex> ExOKF.Bundle.get_concept(bundle, "hello").type
"Reference"
iex> bundle = ExOKF.TestSupport.minimal_bundle()
iex> ExOKF.Bundle.get_concept(bundle, "missing")
nil
Returns true when the concept id exists in the bundle.
Parameters
bundle(t/0) — loaded bundleid(String.t()) — concept id
Examples
iex> bundle = ExOKF.TestSupport.minimal_bundle()
iex> ExOKF.Bundle.has_concept?(bundle, "hello")
true
@spec put_diagnostics(t(), ExOKF.Diagnostics.t()) :: t()
Merges additional diagnostics into the bundle.
Parameters
bundle(t/0) — loaded bundlediags(ExOKF.Diagnostics.t()) — diagnostics to append
Examples
iex> bundle = ExOKF.TestSupport.minimal_bundle()
iex> extra = ExOKF.Diagnostics.new([
...> %ExOKF.Diagnostic{severity: :info, code: :note, message: "hello"}
...> ])
iex> updated = ExOKF.Bundle.put_diagnostics(bundle, extra)
iex> Enum.any?(updated.diagnostics.entries, &(&1.code == :note))
true
Attaches or replaces the graph index on the bundle.
Prefer ExOKF.Graph.index/2, which builds the graph and calls this.
Parameters
bundle(t/0) — loaded bundlegraph(term()) — opaque graph handle, typically%{backend: module(), data: term()}
Examples
iex> bundle = ExOKF.TestSupport.minimal_bundle()
iex> indexed = ExOKF.Bundle.put_graph(bundle, %{backend: ExOKF.Graph.Adjacency, data: %{}})
iex> match?(%{backend: _, data: _}, indexed.graph)
true
@spec size(t()) :: non_neg_integer()
Returns the number of concepts in the bundle.
Parameters
bundle(t/0) — loaded bundle
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> ExOKF.Bundle.size(bundle)
3