AshTypescript.Rpc.Codegen (ash_typescript v0.17.2)

Copy Markdown View Source

Generates TypeScript code for interacting with Ash resources via Rpc.

Summary

Functions

Formats an endpoint configuration for TypeScript code generation.

Generates RPC-specific TypeScript content for the multi-file architecture.

Generates per-action schemas for all RPC actions using the given formatter.

The marker comment used to separate generated code from custom code in namespace files. Content below this marker is preserved when regenerating namespace files.

Functions

format_endpoint_for_typescript(value)

Formats an endpoint configuration for TypeScript code generation.

Delegates to AshTypescript.Helpers.format_ts_value/1.

generate_namespace_reexport_content(namespace, actions, main_file_path, zod_file_path \\ nil, valibot_file_path \\ nil)

Generates a namespace re-export file for the given namespace and actions.

Used by the Orchestrator to generate namespace files with proper import paths.

generate_rpc_content(resources_and_actions, opts, codegen_opts)

Generates RPC-specific TypeScript content for the multi-file architecture.

Contains hook types, helper functions, typed queries, and RPC functions. Types are imported from ash_types.ts via export type * from re-export and a local import type for types actually referenced in the body.

Parameters

  • resources_and_actions - List of {resource, action, rpc_action} tuples
  • opts - Hook configuration options (endpoint overrides, lifecycle hooks)
  • codegen_opts - Additional codegen options:
    • :import_paths - %{types: path} for import resolution
    • :otp_app - The OTP application name
    • :all_resources - All resources for typed query generation
    • :shared_type_names - List of type names exported by ash_types.ts (for local import)

generate_rpc_schemas(formatter, resources_and_actions)

Generates per-action schemas for all RPC actions using the given formatter.

Returns a list of schema strings (one per action that has arguments). These are meant to be passed to SharedSchemaGenerator as :additional_schemas.

namespace_custom_code_marker()

The marker comment used to separate generated code from custom code in namespace files. Content below this marker is preserved when regenerating namespace files.