//#region src/drivers/binaryParsers.d.ts /** * Joist's registry of PostgreSQL *binary-format* cell parsers, used by `WireRowData` for lazy * `em.find`/`em.load` results (which request binary output; see `executeRowDataQuery`). * * This registry is deliberately **separate from `pg.types`**: `pg.types.setTypeParser` and * pool/client `TypeOverrides` continue to govern classic *text* results (knex, `pool.query`, * non-lazy drivers), while binary cells decode wire-bytes -> values directly — ints via * `readInt32BE`, timestamps via µs arithmetic, Temporal values constructed without ever * materializing a string. There is no fallback from one registry to the other: * * - Built-in parsers cover the standard scalar/array types below; `setupLatestPgTypes` * registers the date/time parsers appropriate to Date-vs-Temporal mode. * - Custom/extension types (native enums, citext, domains, hstore, ...) must be registered * explicitly with {@link setBinaryTypeParser} — text-like types can use * {@link binaryTextParser}, arrays of registered elements can use {@link binaryArrayParser}. * - A query selecting a column whose oid has no registered parser **fails** with a descriptive * error (see `WireRowData.setRowDescription`), rather than guessing at a lossy decoding. * * Values produced here should match what the classic text path produces for the same column * (i.e. `numeric` stays a string, `int8` stays a string, Date-mode timestamps become `Date`s), * so entities hydrate identically in either mode; Temporal-mode parsers construct * `Temporal.PlainDate`/`ZonedDateTime`/etc. directly, and the temporal mappers pass * already-constructed instances through. */ declare function setBinaryTypeParser(oid: number, parse: BinaryParse): void; /** Returns the registered binary parser for `oid`, i.e. for tests to save/restore. */ declare function getBinaryTypeParser(oid: number): BinaryParse | undefined; /** Decodes one binary cell directly from the payload chunk; `length` is the cell's byte length. */ type BinaryParse = (chunk: Buffer, start: number, length: number) => any; /** * Auto-registers binary parsers for the database's text-like dynamic-oid types — native enums * and citext, plus their array types — so apps get those for free. * * `PostgresDriver` calls this lazily before its first lazy query; apps can also call it * directly (i.e. at boot) if they want the registrations eagerly. Explicit * `setBinaryTypeParser` registrations are never overwritten. */ declare function registerDatabaseBinaryParsers(pool: { query(sql: string): Promise<{ rows: any[]; }>; }): Promise; /** * Sets the session `TimeZone` used to zone temporal-mode `timestamptz` loads; normally captured * automatically by {@link registerDatabaseBinaryParsers}. One zone per process — pools with * differing session TimeZones are not supported by the binary path. */ declare function setSessionTimeZone(timeZone: string): void; /** Decodes a cell's bytes as utf8 text, i.e. for text-like custom types (enums, citext, domains). */ declare function binaryTextParser(chunk: Buffer, start: number, length: number): string; /** * Decodes a binary array cell into a JS array of element values. * * The element oid is embedded in the wire format, and each element decodes through this * registry — so arrays of any registered type (including custom-registered oids and the * mode-appropriate temporal types) work without separate element wiring. Registered for the * standard `_type` oids below; register it for custom array oids as needed. */ declare function binaryArrayParser(chunk: Buffer, start: number, length: number): any[]; /** Decodes binary `date` cells to `Date`s, matching postgres-date's text semantics; Date mode. */ declare function binaryDateToDate(chunk: Buffer, start: number): any; /** Decodes binary `timestamp` (without zone) cells to local-time `Date`s; Date mode. */ declare function binaryTimestampToDate(chunk: Buffer, start: number): any; /** Decodes binary `timestamptz` cells to `Date`s (µs floor to ms, like the text parse); Date mode. */ declare function binaryTimestamptzToDate(chunk: Buffer, start: number): any; /** * Registers the Temporal-mode binary parsers: date/time/timestamp/timestamptz cells construct * `Temporal` values *directly* from the wire µs/days — no intermediate strings, no * `temporalMappers.fromDb` parsing (the mappers pass already-constructed instances through). * * `timestamptz` matches the text path's zoning exactly: classic parsing zones the value by the * offset the session's `TimeZone` rendered (normalizing `+00` to `UTC`), so we compute the * session zone's offset at each instant (see `setSessionTimeZone`; the configured * `temporal.timeZone` only governs `now`-conversions, not loads). */ declare function registerTemporalBinaryParsers(): void; //#endregion export { BinaryParse, binaryArrayParser, binaryDateToDate, binaryTextParser, binaryTimestampToDate, binaryTimestamptzToDate, getBinaryTypeParser, registerDatabaseBinaryParsers, registerTemporalBinaryParsers, setBinaryTypeParser, setSessionTimeZone }; //# sourceMappingURL=binaryParsers.d.cts.map