AshTypescript.Codegen.TypeDiscovery (ash_typescript v0.18.1)

Copy Markdown View Source

Discovers RPC-configured resources and builds configuration warnings.

Type discovery and reachability analysis are handled by Ash.Info.Manifest.Generator.Reachability. This module provides AshTypescript-specific functionality:

Summary

Functions

Builds a formatted warning message for resources that may be misconfigured.

Discovers embedded resources from RPC resources by scanning reachable resources.

Finds resources with the AshTypescript.Resource extension that are not configured in any typescript_rpc block.

Finds all Ash resources used as struct arguments in RPC actions.

Gets all RPC resources configured in the given OTP application.

Functions

build_rpc_warnings(otp_app)

Builds a formatted warning message for resources that may be misconfigured.

The 1-arity version generates its own spec for resource discovery. The 3-arity version accepts pre-computed resource_lookup and rpc_resources to avoid redundant spec generation.

Returns a formatted warning string, or nil if no warnings are needed.

build_rpc_warnings(otp_app, resource_lookup, rpc_resources)

find_embedded_resources(otp_app)

Discovers embedded resources from RPC resources by scanning reachable resources.

Parameters

  • otp_app - The OTP application name

Returns

A list of embedded resource modules referenced by RPC resources.

find_resources_missing_from_rpc_config(otp_app, resource_lookup \\ nil)

Finds resources with the AshTypescript.Resource extension that are not configured in any typescript_rpc block.

Parameters

  • otp_app - The OTP application name

Returns

A list of non-embedded resource modules with the extension but not configured for RPC.

find_struct_argument_resources(otp_app)

Finds all Ash resources used as struct arguments in RPC actions.

Scans all RPC actions for arguments whose resolved type points to an embedded resource or struct with instance_of pointing to an Ash resource.

Parameters

  • otp_app - The OTP application name

Returns

A list of unique Ash resource modules used as struct arguments in RPC actions.

get_rpc_resources(otp_app)

Gets all RPC resources configured in the given OTP application.

Parameters

  • otp_app - The OTP application name

Returns

A list of unique resource modules that are configured as RPC resources in any domain.