// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import { APIPromise } from '../../core/api-promise';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
export class BaseAccessibilityTree extends APIResource {
static override readonly _key: readonly ['browserRendering', 'accessibilityTree'] = Object.freeze([
'browserRendering',
'accessibilityTree',
] as const);
/**
* Returns the page's accessibility tree. Use `interestingOnly` to only return
* semantically meaningful nodes; use `root` to scope the tree to a
* CSS-selector-anchored subtree. Control page loading with `gotoOptions` and
* `waitFor*` options.
*
* @example
* ```ts
* const accessibilityTree =
* await client.browserRendering.accessibilityTree.create({
* account_id: 'account_id',
* html: '
Hello World!
',
* });
* ```
*/
create(
params: AccessibilityTreeCreateParams,
options?: RequestOptions,
): APIPromise {
const { account_id, cacheTTL, ...body } = params;
return (
this._client.post(path`/accounts/${account_id}/browser-rendering/accessibilityTree`, {
query: { cacheTTL },
body,
...options,
}) as APIPromise<{ result: AccessibilityTreeCreateResponse }>
)._thenUnwrap((obj) => obj.result);
}
}
export class AccessibilityTree extends BaseAccessibilityTree {}
export interface AccessibilityTreeCreateResponse {
/**
* Accessibility tree node
*/
accessibilityTree: AccessibilityTreeCreateResponse.AccessibilityTree | null;
}
export namespace AccessibilityTreeCreateResponse {
/**
* Accessibility tree node
*/
export interface AccessibilityTree {
role: string;
autocomplete?: string;
checked?: boolean | 'mixed';
children?: Array;
description?: string;
disabled?: boolean;
expanded?: boolean;
focused?: boolean;
haspopup?: string;
invalid?: string;
keyshortcuts?: string;
level?: number;
modal?: boolean;
multiline?: boolean;
multiselectable?: boolean;
name?: string;
orientation?: string;
pressed?: boolean | 'mixed';
readonly?: boolean;
required?: boolean;
roledescription?: string;
selected?: boolean;
value?: string | number;
valuemax?: number;
valuemin?: number;
valuetext?: string;
}
}
export type AccessibilityTreeCreateParams =
| AccessibilityTreeCreateParams.Variant0
| AccessibilityTreeCreateParams.Variant1;
export declare namespace AccessibilityTreeCreateParams {
export interface Variant0 {
/**
* Path param: Account ID.
*/
account_id: string;
/**
* Body param: Set the content of the page, eg: `Hello World!!
`. Either
* `html` or `url` must be set.
*/
html: string;
/**
* Query param: Cache TTL default is 5s. Set to 0 to disable.
*/
cacheTTL?: number;
/**
* Body param: The maximum duration allowed for the browser action to complete
* after the page has loaded (such as taking screenshots, extracting content, or
* generating PDFs). If this time limit is exceeded, the action stops and returns a
* timeout error.
*/
actionTimeout?: number;
/**
* Body param: Adds a `