OptionalbuildAdds the contribution of the extension to the payload. Build phase, run in the order of the keys and completed before any item is read.
Payload built by the previous extensions.
Optionalsignal: AbortSignal
Signal of the read, aborted when the read is superseded.
the payload for the next extension.
Releases the held resource. Implementations should be safe to call more than once.
a promise that settles once the resource has been released.
Registers a handler for an event.
Name of the event to listen to.
a subscription; dispose it to remove this single handler.
OptionalreadWraps the reading of the items. Read phase: the extension is a layer of
the onion around the reader, next the layers inside it (the inner
extensions, then the reader of the data source). The payload is the
whole query, whatever the position of the extension.
next may be called zero times (e.g. a cache hit: the reader is never
invoked), once, with this or another payload, or several times (e.g. a
payload split into several reads whose results are merged); every call
runs the inner layers and the reader again, so the hooks and the events
of the inner extensions may fire as many times. The result may be
transformed before being returned, and flows outward: the outermost
extension transforms last.
The whole query, built by the build phase.
Reads the items through the inner layers and the reader; the signal of the read is bound already.
Optionalsignal: AbortSignal
Signal of the read, aborted when the read is superseded, for the reads of the extension itself.
the items for the outer extension, or the data source.
Hooks of the read cycle of an IDataSource, both optional. The cycle has two phases, each one over every extension in the order of the keys of the record they are given with:
next(payload)hands the payload to the next layer in. An extension without the hook is skipped.The order of the keys is up to the consumer and it matters: e.g. the
filteringkey must precede thepaginationone for the count reader to receive the filters. In the read phase it also sets the order of the transformations: the result ofnextflows outward, so the outermost extension transforms last.Both hooks receive the
AbortSignalof the read, aborted when a newer read supersedes it, for the reads of their own (a hook that reads something hands it to its reader, the others ignore it).nexthas the signal bound already: nothing to forward. Once the signal is aborted the data source stops the cycle: the remaining hooks and the reader are not invoked, and anextcalled after the abort rejects with theAbortedExceptionof ts-core. An implementer declaring fewer parameters still type-checks.Example
Example