LightningWeb.ChannelRequestLive.Helpers (Lightning v2.19.0-pre)

View Source

Shared helper functions for the channel request detail page.

Pure functions only — no templates. Provides error humanization, formatting utilities, and data extraction used across multiple component modules.

Summary

Functions

Classifies an error code as :transport, :credential, or nil (unknown).

Formats the client auth method used for a channel request for display.

Formats the destination credential used for a channel request for display.

Converts a classified error code into a human-readable description. Unknown codes pass through unchanged.

Extracts the primary event from a channel request's events list. Prefers :destination_response, falls back to :error.

Functions

error_category(code)

@spec error_category(String.t()) :: :transport | :credential | nil

Classifies an error code as :transport, :credential, or nil (unknown).

extract_content_type(headers)

format_auth_type(type)

format_bytes(bytes)

format_client_auth(channel_request)

Formats the client auth method used for a channel request for display.

Returns "<name> (<auth type>)" when the matched method is present, "(deleted) (<auth type>)" when the id is set but the association is nil after preload (method deleted after the request ran), and the raw auth type / "None" when no client auth was configured for the request.

format_content_type_label(ct)

format_destination_auth(arg1)

Formats the destination credential used for a channel request for display.

Returns the credential name when present, "(deleted)" when the id is still set but the credential has been deleted, and "None" when no destination credential was configured.

format_us(us)

humanize_error(code)

@spec humanize_error(String.t()) :: String.t()

Converts a classified error code into a human-readable description. Unknown codes pass through unchanged.

primary_event(channel_request)

Extracts the primary event from a channel request's events list. Prefers :destination_response, falls back to :error.

text_content_type?(ct)