PhoenixKit.API.FlowConfig (phoenix_kit v2.63.0)

Copy Markdown View Source

Settings of the dangerous-operation flow of the shop API: when an operation needs a confirmation, how long a code, an approval and a stored idempotent answer live.

SettingDefaultAllowed
api_confirm_batch_over501 to 500
api_confirm_ttl_seconds12010 to 600
api_approval_ttl_hours721 to 720
api_approval_pending_max201 to 1000
api_idempotency_ttl_hours241 to 720
api_idempotency_lease_seconds1205 to 3600

(api_confirm_price_change_pct belongs to the e-commerce module.)

A stored value that does not parse or is below its minimum reads as the default; one above its maximum reads as the maximum. A Settings read error reads as the default (PhoenixKit.API.Config.int/2).

The same table drives the form on Settings -> API: fields/0, current/0, validate/1 and save/2. The form is all or nothing: one invalid field saves nothing, and only the values that changed are written (each as a permanent setting.changed Activity entry through Settings.update_setting_with_module/4).

Summary

Functions

Pending approvals one key may hold (api_approval_pending_max).

Hours a pending approval lives (api_approval_ttl_hours).

Rows above which an admin write is dangerous (api_confirm_batch_over).

Seconds a confirmation code lives (api_confirm_ttl_seconds, at most 600).

The current value of every form field, as the text the field shows.

The six fields of the form, in the order the page shows them.

Seconds an in_progress idempotency claim holds before a retry may take over.

Hours a stored idempotent answer lives (api_idempotency_ttl_hours).

Validates and writes a form. Returns the settings that changed. opts are the history options of Settings.update_setting_with_module/4 (actor_uuid:, source:).

Checks a submitted form. {:ok, [{setting, integer}]} when every field is a whole number inside its range; otherwise {:error, fields} naming every bad field (a missing field is bad, never the default).

Functions

approval_pending_max()

@spec approval_pending_max() :: pos_integer()

Pending approvals one key may hold (api_approval_pending_max).

approval_ttl_hours()

@spec approval_ttl_hours() :: pos_integer()

Hours a pending approval lives (api_approval_ttl_hours).

confirm_batch_over()

@spec confirm_batch_over() :: pos_integer()

Rows above which an admin write is dangerous (api_confirm_batch_over).

confirm_ttl_seconds()

@spec confirm_ttl_seconds() :: pos_integer()

Seconds a confirmation code lives (api_confirm_ttl_seconds, at most 600).

current()

@spec current() :: %{required(String.t()) => String.t()}

The current value of every form field, as the text the field shows.

fields()

@spec fields() :: [map()]

The six fields of the form, in the order the page shows them.

idempotency_lease_seconds()

@spec idempotency_lease_seconds() :: pos_integer()

Seconds an in_progress idempotency claim holds before a retry may take over.

idempotency_ttl_hours()

@spec idempotency_ttl_hours() :: pos_integer()

Hours a stored idempotent answer lives (api_idempotency_ttl_hours).

save(params, opts)

@spec save(map(), keyword()) ::
  {:ok, [String.t()]} | {:error, [String.t()] | :save_failed}

Validates and writes a form. Returns the settings that changed. opts are the history options of Settings.update_setting_with_module/4 (actor_uuid:, source:).

validate(params)

@spec validate(map()) :: {:ok, [{String.t(), integer()}]} | {:error, [String.t()]}

Checks a submitted form. {:ok, [{setting, integer}]} when every field is a whole number inside its range; otherwise {:error, fields} naming every bad field (a missing field is bad, never the default).