PhoenixKit.API.Legacy (phoenix_kit v2.64.1)

Copy Markdown View Source

Every name the machine API had before it was made module-neutral, in one place. The rest of PhoenixKit.API knows no module (a guard test fails when it spells one), so the day the deprecation window closes this file is deleted and only its callers are touched: PhoenixKit.API.Paths, the fallback in PhoenixKit.API.Config.rate_limits/0 (with rate_limits_without_fallback/0, which exists only for it), the Settings -> API form's write_limits, PhoenixKit.API.Problem (the four error codes of the shop), PhoenixKit.API.Executor (the client token of a tool that declares none) and PhoenixKit.API.Idempotency (the credential names and markers of the old checkout links).

This module is deleted in 3.0.0. A client, a settings row or a module that still uses a name below has until then to move to the canonical one.

What it holds:

  • the deprecated public paths, /api/shop/v1 and /mcp/shop (alias_paths/0): PhoenixKit.API.Paths forwards them to the same plugs as the canonical /api/public/v1 and /mcp/public, and the plugs mark every answer with deprecation/0 and a Link to the canonical path;
  • the deprecated settings keys (setting_fallback/1): PhoenixKit.API.Config reads a limit from its new key and, when that holds no valid number, from the old one. Nothing deletes or migrates the old rows; the first save of Settings -> API writes the values in effect under the new keys;
  • the client token of a public tool that declares none (legacy_client_token/1): a module written before PhoenixKit.API.Tool had a client_token field named its anonymous caller's token cart_token, and the executor still reads it so such a module keeps its rate limit, its idempotency scope and its danger gate;
  • the four error codes the shop API answered with before modules could declare their own (problems/0): PhoenixKit.API.Problem (and, through it, the MCP advice) uses them for as long as no enabled module declares the same code (PhoenixKit.Module.api_problems/0);
  • the names a module's answers carried secrets under before Tool.credentials existed (credential_keys/0, credential_markers/0), which PhoenixKit.API.Idempotency still redacts and never stores for replay.

Summary

Functions

The deprecated public API paths, as lists of segments (the REST one, then the MCP one). Each is served by the plug of the canonical public path of its transport, and nothing publishes them: documents and headers name the canonical path only.

The output field names PhoenixKit.API.Idempotency treats as credentials besides the ones core's rule covers.

The substrings that make any string value of an answer a credential (compared without regard to case).

The value of the Deprecation response header (RFC 9745) that every answer on a deprecated path carries.

The input field a public tool that declares no client_token is read through, or nil: "cart_token" when the tool's input schema has a property of that name.

The error codes the shop answered with before modules declared their own, as %{code => %{status, title, advice}}. They apply to a code only while no enabled module declares it.

The deprecated settings key that key replaces, or nil when key replaced none. PhoenixKit.API.Config.int/3 reads it when key holds no valid number.

Functions

alias_paths()

@spec alias_paths() :: [[String.t()]]

The deprecated public API paths, as lists of segments (the REST one, then the MCP one). Each is served by the plug of the canonical public path of its transport, and nothing publishes them: documents and headers name the canonical path only.

credential_keys()

@spec credential_keys() :: [String.t()]

The output field names PhoenixKit.API.Idempotency treats as credentials besides the ones core's rule covers.

credential_markers()

@spec credential_markers() :: [String.t()]

The substrings that make any string value of an answer a credential (compared without regard to case).

deprecation()

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

The value of the Deprecation response header (RFC 9745) that every answer on a deprecated path carries.

legacy_client_token(tool)

@spec legacy_client_token(PhoenixKit.API.Tool.t()) :: String.t() | nil

The input field a public tool that declares no client_token is read through, or nil: "cart_token" when the tool's input schema has a property of that name.

problems()

@spec problems() :: %{
  required(atom()) => %{
    status: pos_integer(),
    title: String.t(),
    advice: String.t()
  }
}

The error codes the shop answered with before modules declared their own, as %{code => %{status, title, advice}}. They apply to a code only while no enabled module declares it.

setting_fallback(key)

@spec setting_fallback(String.t()) :: String.t() | nil

The deprecated settings key that key replaces, or nil when key replaced none. PhoenixKit.API.Config.int/3 reads it when key holds no valid number.