Jidoka.Import (Jidoka v0.8.0-beta.1)

Copy Markdown View Source

JSON/YAML import runtime for data-authored Jidoka agents.

Imports compile into the same Jidoka.Agent.Spec contract as the Spark DSL. JSON/YAML cannot safely encode executable Elixir values, so action modules and context schemas are resolved through caller-provided registries.

Summary

Functions

Imports a JSON or YAML agent document string.

Imports a JSON or YAML agent document string and raises on failure.

Compiles decoded import data into Jidoka.Agent.Spec.

Compiles decoded import data and raises on failure.

Types

format()

@type format() :: :json | :yaml

option()

@type option() ::
  {:format, format()}
  | {:registries, registry()}
  | {:actions, registry()}
  | {:action_registry, registry()}
  | {:ash_resources, registry()}
  | {:ash_resource_registry, registry()}
  | {:controls, registry()}
  | {:control_registry, registry()}
  | {:context_schemas, registry()}
  | {:context_schema_registry, registry()}
  | {:result_schemas, registry()}
  | {:result_schema_registry, registry()}

registry()

@type registry() :: keyword() | map()

Functions

import(contents, opts \\ [])

@spec import(String.t(), [option()]) ::
  {:ok, Jidoka.Agent.Spec.t()} | {:error, term()}

Imports a JSON or YAML agent document string.

Pass format: :json or format: :yaml to force a parser. Without a format, strings beginning with { or [ are treated as JSON; all others are treated as YAML.

import!(contents, opts \\ [])

@spec import!(String.t(), [option()]) :: Jidoka.Agent.Spec.t()

Imports a JSON or YAML agent document string and raises on failure.

load(attrs, opts \\ [])

@spec load(map(), [option()]) :: {:ok, Jidoka.Agent.Spec.t()} | {:error, term()}

Compiles decoded import data into Jidoka.Agent.Spec.

load!(attrs, opts \\ [])

@spec load!(map(), [option()]) :: Jidoka.Agent.Spec.t()

Compiles decoded import data and raises on failure.