AshLua.Surface (ash_lua v0.2.0)

Copy Markdown View Source

Annotates %Ash.Info.Manifest{} entrypoints with AshLua public surface data.

The manifest remains the API specification. AshLua stores extension-specific callable path metadata under each entrypoint's config[:ash_lua].

Summary

Functions

Returns the resource/action tuples represented by the annotated manifest.

Clears the eval manifest cache populated by preload_eval_manifests!/1.

Returns the AshLua config for an annotated entrypoint.

Returns the annotated entrypoint matching a dotted Lua callable path.

Generates the scoped Lua manifest for an AshLua.EvalActions resource.

Attaches AshLua surface metadata to an existing manifest.

Generates a manifest for an OTP app with AshLua surface metadata attached.

Deprecated compatibility alias for for_manifest/1.

Returns the Lua path segments for an annotated entrypoint.

Returns the dotted Lua path for an annotated entrypoint.

Preloads and caches scoped Lua manifests for every AshLua.EvalActions resource in an OTP app.

Types

surface_config()

@type surface_config() :: %{
  domain: module(),
  labels: [atom()],
  lua_action: String.t(),
  path: [String.t()],
  path_string: String.t(),
  path_source: :explicit | :derived
}

Functions

action_entrypoints(manifest)

@spec action_entrypoints(Ash.Info.Manifest.t()) :: [{module(), atom()}]

Returns the resource/action tuples represented by the annotated manifest.

clear_eval_manifest_cache!()

@spec clear_eval_manifest_cache!() :: :ok

Clears the eval manifest cache populated by preload_eval_manifests!/1.

config(entrypoint)

@spec config(Ash.Info.Manifest.Entrypoint.t()) :: surface_config() | nil

Returns the AshLua config for an annotated entrypoint.

find_action(manifest, path)

@spec find_action(Ash.Info.Manifest.t(), String.t()) ::
  {:ok, Ash.Info.Manifest.Entrypoint.t()} | :error

Compatibility alias for find_entrypoint/2.

find_entrypoint(manifest, path)

@spec find_entrypoint(Ash.Info.Manifest.t(), String.t()) ::
  {:ok, Ash.Info.Manifest.Entrypoint.t()} | :error

Returns the annotated entrypoint matching a dotted Lua callable path.

for_eval_resource(resource, opts \\ [])

@spec for_eval_resource(
  module(),
  keyword()
) :: {:ok, Ash.Info.Manifest.t()}

Generates the scoped Lua manifest for an AshLua.EvalActions resource.

for_manifest(manifest)

@spec for_manifest(Ash.Info.Manifest.t()) :: Ash.Info.Manifest.t()

Attaches AshLua surface metadata to an existing manifest.

Domains with explicit lua do namespace ... end actions expose only those configured actions. Domains without explicit surface actions retain the legacy derived shape: <domain>.<resource>.<action>.

Each entrypoint is annotated from its own resource's domain, so manifests may span domains owned by different OTP apps. Entrypoints that are not exposed on their domain's Lua surface are dropped with a logged warning.

for_otp_app(otp_app, opts \\ [])

@spec for_otp_app(
  atom(),
  keyword()
) :: {:ok, Ash.Info.Manifest.t()}

Generates a manifest for an OTP app with AshLua surface metadata attached.

from_manifest(manifest)

@spec from_manifest(Ash.Info.Manifest.t()) :: Ash.Info.Manifest.t()

Deprecated compatibility alias for for_manifest/1.

path(entrypoint)

Returns the Lua path segments for an annotated entrypoint.

path_string(entrypoint)

@spec path_string(Ash.Info.Manifest.Entrypoint.t()) :: String.t()

Returns the dotted Lua path for an annotated entrypoint.

preload_eval_manifests!(otp_app)

@spec preload_eval_manifests!(atom()) :: [module()]

Preloads and caches scoped Lua manifests for every AshLua.EvalActions resource in an OTP app.

The cache stores only immutable manifest data. Each eval invocation still builds a fresh Lua VM with its caller-specific actor, tenant, and context. Generated AshLua.EvalActions use this cache by default; direct runtime calls can opt in with cache?: true.