Provides introspection functions for AshTypescript.Resource configuration.
This module generates helper functions to access TypeScript configuration defined on resources using the AshTypescript.Resource DSL extension.
Summary
Functions
Gets the pre-computed formatted client name for a field under a built-in formatter.
Gets the mapped name for an argument, or returns the original name if no mapping exists.
Gets the mapped TypeScript client name for a field, or returns nil if no mapping exists.
Gets the original invalid argument name for a mapped argument name. Returns the argument name that was mapped to the given valid name, or the same name if no mapping exists.
Gets the original Elixir field name for a TypeScript client field name.
A keyword list mapping Elixir argument names to TypeScript client names per action. Use strings for the client names - no additional formatting is applied. (e.g., [read_action: [is_active?: "isActive"]])
A keyword list mapping Elixir argument names to TypeScript client names per action. Use strings for the client names - no additional formatting is applied. (e.g., [read_action: [is_active?: "isActive"]])
A keyword list mapping Elixir field names to TypeScript client names. Use strings for the client names - no additional formatting is applied. (e.g., [is_active?: "isActive", address_line_1: "addressLine1"])
A keyword list mapping Elixir field names to TypeScript client names. Use strings for the client names - no additional formatting is applied. (e.g., [is_active?: "isActive", address_line_1: "addressLine1"])
typescript DSL options
Whether or not a given module is a resource module using the AshTypescript.Resource extension
The name of the TypeScript type for the resource
The name of the TypeScript type for the resource
Functions
Gets the pre-computed formatted client name for a field under a built-in formatter.
Backed by Spark.Dsl.Transformer.persist/3 populated at compile time by
AshTypescript.Resource.Transformers.PersistFormattedFields. Returns the
formatted string, or nil if the resource is not an AshTypescript.Resource,
the field is not a public attribute/relationship/calculation/aggregate, or the
formatter is not one of the built-in atoms (:camel_case, :snake_case,
:pascal_case).
Examples
iex> AshTypescript.Resource.Info.get_formatted_field(MyApp.User, :first_name, :camel_case)
"firstName"
iex> AshTypescript.Resource.Info.get_formatted_field(MyApp.User, :is_active?, :camel_case)
"isActive"
Gets the mapped name for an argument, or returns the original name if no mapping exists.
Examples
iex> AshTypescript.Resource.Info.get_mapped_argument_name(MyApp.User, :read_with_invalid_arg, :is_active?)
:is_active
Gets the mapped TypeScript client name for a field, or returns nil if no mapping exists.
The mapped value is always a string representing the exact TypeScript client name.
Examples
iex> AshTypescript.Resource.Info.get_mapped_field_name(MyApp.User, :is_active?)
"isActive"
iex> AshTypescript.Resource.Info.get_mapped_field_name(MyApp.User, :normal_field)
nil
Gets the original invalid argument name for a mapped argument name. Returns the argument name that was mapped to the given valid name, or the same name if no mapping exists.
Examples
iex> AshTypescript.Resource.Info.get_original_argument_name(MyApp.User, :read_with_invalid_arg, :is_active)
:is_active?
Gets the original Elixir field name for a TypeScript client field name.
The client_field_name should be a string like "isActive". Returns the original Elixir atom like :is_active?, or the input if no mapping exists.
Examples
iex> AshTypescript.Resource.Info.get_original_field_name(MyApp.User, "isActive")
:is_active?
iex> AshTypescript.Resource.Info.get_original_field_name(MyApp.User, "normalField")
"normalField"
A keyword list mapping Elixir argument names to TypeScript client names per action. Use strings for the client names - no additional formatting is applied. (e.g., [read_action: [is_active?: "isActive"]])
A keyword list mapping Elixir argument names to TypeScript client names per action. Use strings for the client names - no additional formatting is applied. (e.g., [read_action: [is_active?: "isActive"]])
A keyword list mapping Elixir field names to TypeScript client names. Use strings for the client names - no additional formatting is applied. (e.g., [is_active?: "isActive", address_line_1: "addressLine1"])
A keyword list mapping Elixir field names to TypeScript client names. Use strings for the client names - no additional formatting is applied. (e.g., [is_active?: "isActive", address_line_1: "addressLine1"])
typescript DSL options
Returns a map containing the and any configured or default values.
Whether or not a given module is a resource module using the AshTypescript.Resource extension
The name of the TypeScript type for the resource
The name of the TypeScript type for the resource