AshTypescript.Rpc.Codegen.TypeGenerators.RestrictedSchema (ash_typescript v0.17.2)

Copy Markdown View Source

Generates restricted resource schemas based on allowed_loads/denied_loads options.

When an RPC action has load restrictions, this module generates action-specific TypeScript schema types that only expose allowed fields, providing compile-time type safety for field selection.

Supports nested restrictions on:

  • Relationships (e.g., denied_loads: [user: [:todos]])
  • Embedded resources (e.g., denied_loads: [metadata: [:related_user]])
  • Union attributes (e.g., denied_loads: [content: [:author]])

Summary

Functions

Returns the schema reference and optional schema definition for an RPC action.

Functions

get_schema_and_reference(resource, rpc_action, rpc_action_name_pascal)

Returns the schema reference and optional schema definition for an RPC action.

If the action has load restrictions, returns {schema_definition, schema_name}. If no restrictions, returns {nil, base_resource_schema_name}.

Parameters

  • resource - The Ash resource module
  • rpc_action - The RPC action configuration struct
  • rpc_action_name_pascal - The PascalCase name of the RPC action

Returns

  • {schema_definition, schema_reference} where:
    • schema_definition is a string with TypeScript type def or nil if using base schema
    • schema_reference is the TypeScript type name to use in Fields type