AshTypescript.Rpc.Codegen.TypescriptStatic (ash_typescript v0.17.3)

Copy Markdown View Source

Generates static TypeScript code that doesn't depend on specific resources.

This includes:

  • Import statements (Zod, Phoenix Channel, custom imports)
  • Hook context type definitions
  • Utility types (TypedSchema, InferResult, pagination helpers, etc.)
  • Helper functions (CSRF token, RPC request executors)

Summary

Functions

Generates TypeScript helper functions and configuration interfaces.

Generates TypeScript type definitions for hook context types.

Generates TypeScript import statements based on configuration.

Functions

generate_helper_functions(hook_config, endpoint_process, endpoint_validate)

Generates TypeScript helper functions and configuration interfaces.

Includes:

  • Configuration interfaces (ActionConfig, ValidationConfig, etc.)
  • CSRF token helpers
  • RPC request execution functions
  • Channel push execution functions

generate_hook_context_types(hook_config)

Generates TypeScript type definitions for hook context types.

Hook context types are conditionally generated based on:

  • Whether hooks are enabled for each category
  • Whether a context type is configured

generate_imports(opts \\ [])

Generates TypeScript import statements based on configuration.

Includes:

  • Zod import (if zod schemas enabled and not skipped)
  • Phoenix Channel import (if channel RPC actions enabled)
  • Custom imports from application config

Options

  • :skip_zod - When true, omits the Zod import (for split-file mode where Zod is in ash_zod.ts)
  • :output_file - The target output file path, for resolving custom import paths