AshTypescript.Manifest (ash_typescript v0.18.2)

Copy Markdown View Source

Standalone Spark DSL module for building a unified app-wide Ash.Info.Manifest.

When the same resource appears in multiple domains' typescript_rpc blocks with different RPC actions, this module ensures all actions are merged into a single unified spec rather than each domain overwriting the previous one.

Usage

defmodule MyApp.AshTypescriptManifest do
  use AshTypescript.Manifest, otp_app: :my_app
end

Scoped manifests (testing)

When :domains is supplied, the manifest is built from exactly those domains instead of walking Ash.Info.domains(otp_app). This lets tests build an inline manifest from a freshly-defined domain without touching global state.

defmodule TestManifest do
  use AshTypescript.Manifest,
    otp_app: :ash_typescript,
    domains: [MyTest.InlineDomain]
end

Options

  • :domains - Explicit list of domain modules to build the manifest from. When nil, walks Ash.Info.domains(otp_app). The default value is nil.

  • :extensions (list of module that adopts Spark.Dsl.Extension) - A list of DSL extensions to add to the Spark.Dsl

  • :otp_app (atom/0) - The otp_app to use for any application configurable options

  • :fragments (list of module/0) - Fragments to include in the Spark.Dsl. See the fragments guide for more.

Summary

Functions

Runs every manifest verifier against manifest_module's persisted DSL state.

Convenience wrapper for tests: compiles a one-shot inline manifest module scoped to domains, then runs all manifest verifiers against it.

Functions

run_verifiers(manifest_module)

Runs every manifest verifier against manifest_module's persisted DSL state.

Returns :ok when all verifiers pass, or {:error, formatted_message} aggregating every failure.

Used by tests to drive the same verifier code path that compile-time runs.

verify_for_domains(domains, opts \\ [])

Convenience wrapper for tests: compiles a one-shot inline manifest module scoped to domains, then runs all manifest verifiers against it.

Returns :ok or {:error, formatted_message} — same shape as run_verifiers/1.

The generated module name is deterministic from the domains list (via :erlang.phash2/1), so repeated calls with the same arguments reuse the same compiled module instead of triggering a redefinition warning. Each unique call creates one real AshTypescript.Manifest-using module at runtime — which means field-selector reads (Spark.Dsl.Extension.get_persisted/3) resolve against that module's persisted state, exactly like the production path does.