import { GNHashtable } from "./../common/GNData"; /** * Low-level request envelope sent to the GearN backend. * * Carries the operation code, the optional parameter bag, the * client-assigned request id used to correlate the response, and a * per-request timeout. Most application code never instantiates * this class directly — the typed `*Api` wrappers and * `CustomOperationRequest` subclasses build it for you. Reach for * the raw class only when issuing custom operations through * {@link GNNetwork.sendViaSocket} / {@link GNNetwork.sendViaHttp}. * * Request id semantics: * - The default constructor leaves the id unassigned. The peer * later sets a unique id during {@link PeerBase.enqueue} so the * response can be matched to the right callback. * - Set the id to `-1` explicitly when you want a fire-and-forget * request: the peer sees the sentinel and skips both the id * assignment and the in-flight tracking, so no response will * ever resolve through the SDK callback path. */ export declare class OperationRequest { /** * Sentinel used by the SDK in two unrelated places: * * - As the **default timeout in seconds** when application code * does not pass an explicit timeout — the transport replaces * it with `GNServerSettings.getDefaultTimeoutInSeconds()` at * send time. * - As the magic value `20` shared with the same default in * {@link GNServerSettings} so the two places agree by * construction. */ static readonly defaultTimeOut: number; /** * Operation code carried in every wire frame. Values come from * {@link OperationCode}. */ private operationCode; /** * Client-assigned request id used to correlate the response. * Stays `undefined` until {@link PeerBase.enqueue} assigns one * (or remains `-1` for fire-and-forget calls). */ private requestId; /** Optional parameter bag, lazily allocated on first {@link setParameter}. */ private parameters; /** * Timeout in **seconds**. The {@link defaultTimeOut} sentinel * is replaced with the configured default at send time. */ private timeout; /** * @param operationCode Operation code from * {@link OperationCode}. * @param timeout Optional per-request timeout in seconds. * Defaults to {@link defaultTimeOut} so * the transport can substitute the * configured value. */ constructor(operationCode: string, timeout?: number); /** * Returns the operation code embedded in the request. */ getOperationCode(): string; /** * Returns the request id used for response correlation. * * @returns Numeric id (assigned by the peer), or `-1` for * fire-and-forget requests, or `undefined` before * {@link PeerBase.enqueue} runs. */ getRequestId(): number; /** * Returns the parameter bag that will be serialised onto the * wire, or `null` when no parameters have been added. */ getParameters(): GNHashtable; /** * Returns the timeout in **seconds** that will apply to the * request. */ getTimeout(): number; /** * Replaces the request id and returns the current request for * chaining. * * @param requestId New id. Use `-1` to opt into the * fire-and-forget path. */ setRequestId(requestId: number): OperationRequest; /** * Adds or replaces a single parameter and returns the request * for chaining. * * Lazily allocates the underlying {@link GNHashtable} on the * first call so empty requests do not pay for the container. * * @param key Wire-level parameter key — usually a constant * from {@link ParameterCode}. * @param value Any value accepted by * {@link GNHashtable.add} (primitives, plain * objects, arrays, nested containers). */ setParameter(key: string, value: any): OperationRequest; /** * Replaces the entire parameter bag and returns the request for * chaining. */ setParameters(parameters: GNHashtable): OperationRequest; /** * Replaces the timeout (in seconds) and returns the request for * chaining. */ setTimeout(timeout: number): OperationRequest; /** * Returns a debug-friendly summary of the request. * * Used by `[GN Socket SEND]` / `[GN Http SEND]` log lines. The * parameters are dumped via * `JSON.stringify(parameters?.toData())` so nested * {@link GNHashtable} / {@link GNArray} containers are * expanded into plain objects / arrays. */ toString(): string; }