waygraph / PageReaders
Interface: PageReaders
Defined in: src/engine/read/readers.ts:67
The readers a Read Block reads the page with.
Methods
api()
api<
T>(path,pick):Reader<T>
Defined in: src/engine/read/readers.ts:99
What the app's API says (GET, as the page's own session; new Engine({ api }) says where it is and how a request is signed): for what the page only shows after a reload. pick takes the JSON to the value; an API that answers "not ok" reads as missing. path can be made from the page's address.
Type Parameters
T
T
Parameters
path
string | ((url) => string)
pick
(json) => T
Returns
Reader<T>
Example
ctx.page.api((url) => `/signature-requests/${url.pathname.split("/").pop()}`, (r) => (r as { requestStatus: string }).requestStatus)attr()
attr(
selector,name):Reader<string>
Defined in: src/engine/read/readers.ts:74
Parameters
selector
string
name
string
Returns
Reader<string>
count()
count(
selector):Reader<number>
Defined in: src/engine/read/readers.ts:79
Parameters
selector
string
Returns
Reader<number>
fn()
fn<
T>(read):Reader<Awaited<T>>
Defined in: src/engine/read/readers.ts:92
Anything the helpers don't cover; null or undefined is reported as missing.
Type Parameters
T
T
Parameters
read
(page, mem) => T | Promise<T>
Returns
Reader<Awaited<T>>
list()
list<
R>(rowSelector,row):Reader<R[]>
Defined in: src/engine/read/readers.ts:84
One object per row, each field read inside its row, in one round trip for the whole list.
Type Parameters
R
R
Parameters
rowSelector
string
row
(row) => { readonly [K in string | number | symbol]: Reader<R[K]> }
Returns
Reader<R[]>
Example
ctx.page.list(".comment", (row) => ({ author: row.text(".author"), body: row.text(".body") }))number()
number(
selector):Reader<number>
Defined in: src/engine/read/readers.ts:73
The first number in the first match's text ("$1,299.00" -> 1299, "41 likes" -> 41).
Parameters
selector
string
Returns
Reader<number>
table()
table<
C>(selector,columns):Reader<Record<C,string>[]>
Defined in: src/engine/read/readers.ts:90
One object per table row, each field the cell under the column with that header text (<th> or role=columnheader), in one round trip. A header that isn't there is reported as missing.
Type Parameters
C
C extends string
Parameters
selector
string
columns
Readonly<Record<C, string>>
Returns
Reader<Record<C, string>[]>
Example
ctx.page.table("#orders", { id: "Order #", total: "Total" })text()
text(
selector):Reader<string>
Defined in: src/engine/read/readers.ts:69
Text of the first match (textContent, whitespace collapsed).
Parameters
selector
string
Returns
Reader<string>
texts()
texts(
selector):Reader<string[]>
Defined in: src/engine/read/readers.ts:71
Text of every match (textContent, whitespace collapsed).
Parameters
selector
string
Returns
Reader<string[]>
value()
value(
selector):Reader<string>
Defined in: src/engine/read/readers.ts:76
A form field's current value.
Parameters
selector
string
Returns
Reader<string>
visible()
visible(
selector):Reader<boolean>
Defined in: src/engine/read/readers.ts:78
Whether any match is visible (false, not missing, when nothing matches).
Parameters
selector
string
Returns
Reader<boolean>