import { a as HttpRequest, f as Result, m as OpenCloudError, o as HttpResponse, p as SleepFunc, s as OpenCloudClientOptions, u as RequestOptions } from "./types-C3Egi37J.mjs"; import { i as RetryResolvable, n as MethodKind } from "./retry-DXEklFrt.mjs"; //#region src/internal/http/rate-limit-queue.d.ts /** * Identifies and bounds a single Roblox Open Cloud operation for rate * limiting, e.g. `{ operationKey: "game-passes.create", maxPerSecond: 5 }`. */ interface OperationLimit { /** * How many requests may be issued back to back before pacing begins, * as a whole number of requests. Defaults to `max(1, maxPerSecond)`, * which leaves operations at or above 1/s paced exactly as their * sustained rate allows while still granting a slower operation one * request after it has idled. Set this to the allowance the schema * documents (e.g. 5 per minute) to grant the burst the server permits. */ readonly burstCapacity?: number; /** Maximum sustained request rate in requests per second. */ readonly maxPerSecond: number; /** * Stable identifier for the operation (e.g. "game-passes.create"). Not * consumed by the queue itself; callers use it to key per-operation * queues in a registry (see GamePassesClient). */ readonly operationKey: string; } //#endregion //#region src/internal/resource-client.d.ts /** * Describes a single resource method's shape for dispatch through * `ResourceClient.execute`. Each resource client declares one module-level * constant per public method; that constant binds the four resource-specific * values (request builder, response parser, retry-policy method kind, * operation-level rate limit) and flows through `execute` uniformly. * * @template P - The resource-specific parameter shape the builder * accepts. * @template T - The resource-specific parsed success type the parser * produces. */ interface ResourceMethodSpec
{
/**
* Builds the pure {@link HttpRequest} for a single call. Returns a
* {@link Result} so a builder can short-circuit with a local error
* (typically a {@link OpenCloudError} subclass such as `ValidationError`)
* before any HTTP, queue, or retry work happens. Builders that cannot
* fail wrap their return as `{ data: request, success: true }`.
*/
readonly buildRequest: (parameters: P) => Result {
/** Optional per-request config overrides. */
readonly options?: RequestOptions | undefined;
/** Resource-specific request parameters. */
readonly parameters: P;
/** Optionally refines a transport error with resource-specific evidence. */
readonly refineError?: ((error: OpenCloudError) => OpenCloudError) | undefined;
/**
* Per-method binding of builder, parser, method kind, and operation limit.
*/
readonly spec: ResourceMethodSpec ;
}
/**
* Wraps an infallible request build as a {@link Result}-returning
* `buildRequest` callback compatible with {@link ResourceMethodSpec}.
* Use from a resource client whose builder cannot fail; resource clients
* with local validation should construct the {@link Result} directly.
*
* @param request - The pre-built {@link HttpRequest}.
* @returns A success Result wrapping the request.
*/
/**
* Internal orchestrator shared by every Open Cloud resource client. Holds
* the frozen client config, observability hooks, injected HTTP client and
* sleep, and the per-effective-key rate-limit queue registry. Resource
* classes compose one instance and dispatch every public method through
* {@link ResourceClient.executeAsync} with a per-method {@link ResourceMethodSpec}.
* Not exported from any package subpath; reachable only via sibling
* `src/resources/**` modules in this package.
*/
declare class ResourceClient {
#private;
/**
* Creates a new {@link ResourceClient}. Resolves the injected HTTP
* client and sleep (defaulting to fetch + `setTimeout`) and freezes the
* merged client config so subsequent calls cannot mutate it.
*
* @param options - Client-level configuration including the API key
* and optional construction-time test seams.
*/
constructor({
apiKey,
hooks,
httpClient,
sleep,
...overrides
}: OpenCloudClientOptions);
/**
* Dispatches a single resource-method call. Merges the frozen client
* config with the method's `methodDefaults` and the caller's optional
* per-request `options`, routes through the effective-apiKey rate-limit
* queue, runs the retry loop, and finally parses the response with the
* spec's parser.
*
* @param call - The per-method spec, resource-specific parameters, and
* optional per-request overrides.
* @returns The parsed success payload or the {@link OpenCloudError} that
* caused the request to fail. Never throws.
* @rejects An unexpected collaborator failure unrelated to caller cancellation.
*/
executeAsync ({
options,
parameters,
refineError,
spec
}: ExecuteCall ): Promise