Resolves relative import paths between generated TypeScript files and generates namespace re-export content.
Used when generating namespace re-export files that need to import from the main generated file, or when any generated file needs to import from another.
Summary
Functions
Builds import and re-export lines for shared types.
Generates a namespace re-export file from a list of categorized exports.
The marker comment used to separate generated code from custom code in namespace files. Content below this marker is preserved when regenerating namespace files.
Resolves custom import paths from import_into_generated config entries
relative to a target output file.
Computes a relative TypeScript import path from one file to another.
Functions
Generates a namespace re-export file from a list of categorized exports.
This is the shared implementation used by both RPC and controller namespace generation.
Parameters
namespace- The namespace name (used in the header comment)exports- List of{name, kind}tuples where kind is:value,:type,:zod_value, or:valibot_valuenamespace_file- Full path of the namespace file being generated (for import resolution)main_file_path- Path to the main source file (RPC or routes)zod_file_path- Path to the Zod file (nil to import Zod from main file)valibot_file_path- Path to the Valibot file (nil to import Valibot from main file)
The marker comment used to separate generated code from custom code in namespace files. Content below this marker is preserved when regenerating namespace files.
Resolves custom import paths from import_into_generated config entries
relative to a target output file.
Each import config is a map with :import_name and :file keys, where :file
is a project-root-relative path (e.g., "assets/js/hooks.ts").
Parameters
target_output_file- The output file that will contain the import statementsimports- List of import config maps with:import_nameand:filekeys
Examples
iex> resolve_custom_imports("assets/js/ash_rpc.ts", [%{import_name: "Hooks", file: "assets/js/hooks.ts"}])
"import * as Hooks from \"./hooks\";"
Computes a relative TypeScript import path from one file to another.
Both paths should be relative to the project root (e.g., "assets/js/ash_rpc.ts").
Returns a relative path suitable for TypeScript import statements (without .ts extension).
Examples
iex> resolve_import_path("assets/js/namespace/todos.ts", "assets/js/ash_rpc.ts")
"../ash_rpc"
iex> resolve_import_path("assets/js/todos.ts", "assets/js/ash_rpc.ts")
"./ash_rpc"