( runtime, options, )
| 145 | const POLL_INTERVAL_MS = 300; |
| 146 | |
| 147 | export const findCommand: RuntimeCommand<FindReadCommandOptions, FindReadCommandResult> = async ( |
| 148 | runtime, |
| 149 | options, |
| 150 | ): Promise<FindReadCommandResult> => { |
| 151 | const locator = options.locator ?? 'any'; |
| 152 | if (!options.query) { |
| 153 | throw new AppError('INVALID_ARGS', 'find requires a value'); |
| 154 | } |
| 155 | if (options.action === 'wait') { |
| 156 | return await waitForFindMatch(runtime, options, locator); |
| 157 | } |
| 158 | |
| 159 | const { capture, match } = await findFirstLocatorMatch(runtime, options, locator); |
| 160 | if (!match) { |
| 161 | throw new AppError('COMMAND_FAILED', 'find did not match any element'); |
| 162 | } |
| 163 | |
| 164 | if (options.action === 'exists') return { kind: 'found', found: true }; |
| 165 | const ref = `@${match.ref}`; |
| 166 | if (options.action === 'get_attrs') return { kind: 'attrs', ref, node: match }; |
| 167 | const text = await readText(runtime, capture, match); |
| 168 | return { kind: 'text', ref, text, node: match }; |
| 169 | }; |
| 170 | |
| 171 | export const getCommand: RuntimeCommand<GetCommandOptions, GetCommandResult> = async ( |
| 172 | runtime, |
nothing calls this directly
no test coverage detected