import '../types'; import { SetUiAjaxConfigurationType } from '../types'; /** * Retry policy configuration for AJAX requests. */ export type RetryPolicy = { /** Maximum number of retry attempts (default: 0 — no retries). */ maxRetries?: number; /** Base delay in ms between retries (default: 1000). Doubled on each attempt. */ baseDelay?: number; /** HTTP status codes that should trigger a retry (default: [502, 503, 504]). Timeouts and network errors always retry regardless of this list. */ retryOn?: number[]; }; /** * Options for {@link getAjaxSubmit}. Passed explicitly so that the helper can * stay a plain function — callers forward the values they already obtained * from {@link usePieConfig} instead of the helper calling hooks on its own. */ export type GetAjaxSubmitOptions = { /** Base URL of the PieUI API server (must end with `/`). */ apiServer?: string | null; /** When `true`, the helper will log registration and error details. */ renderingLogEnabled?: boolean; /** Request timeout in milliseconds. No timeout if omitted. */ timeout?: number; /** Retry policy for failed requests. No retries if omitted. */ retryPolicy?: RetryPolicy; }; /** * Builds an async "submit" function that issues an AJAX request to * `api/ajax_content{pathname}` and streams (or JSON-decodes) the response * into a `setUiAjaxConfiguration` callback supplied by an Ajax container. * * The returned function collects form data from: * 1. the static `kwargs` object, * 2. any `extraKwargs` passed at call time, * 3. named inputs from the DOM listed in `depsNames` (including `sid`, * which is resolved via {@link waitForSidAvailable}), and * 4. file inputs (multiple files supported). * * If the server streams NDJSON, each line is parsed as a `UIEventType` and * applied incrementally; otherwise the full JSON body replaces the current * Ajax configuration. * * On missing `apiServer`, `pathname` or `setUiAjaxConfiguration` the helper * returns a no-op function so call sites do not need to null-check. * * @param setUiAjaxConfiguration Setter provided by the enclosing Ajax card. * @param kwargs Static key/value pairs appended to the request. * @param depsNames Names of DOM inputs whose current values should * also be sent. * @param pathname Path segment appended to `api/ajax_content`. * @param options See {@link GetAjaxSubmitOptions}. * @returns An `async (extraKwargs?) => Promise` submit function. */ export declare const getAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigurationType, kwargs?: Record, depsNames?: Array, pathname?: string, options?: GetAjaxSubmitOptions) => (extraKwargs?: Record) => Promise; /** * React hook wrapper around {@link getAjaxSubmit}. Reads `apiServer` and * `enableRenderingLog` from {@link usePieConfig} and memoizes the submit * function so that stable inline literals from server-driven UIConfig don't * cause a new function identity on every render — memoization is keyed on * the stringified `kwargs`/`depsNames` rather than their reference. * * @param setUiAjaxConfiguration Setter provided by the enclosing Ajax card. * @param kwargs Static key/value pairs appended to the request. * @param depsNames Names of DOM inputs whose current values should * be sent alongside the request. * @param pathname Path segment appended to `api/ajax_content`. * @param options Optional `timeout` (ms) and `retryPolicy`. * @returns A memoized submit function; see {@link getAjaxSubmit}. */ export declare const useAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigurationType, kwargs?: Record, depsNames?: Array, pathname?: string, options?: { timeout?: number; retryPolicy?: RetryPolicy; }) => (extraKwargs?: Record) => Promise; //# sourceMappingURL=ajaxCommonUtils.d.ts.map