joist-orm 2.3.0-next.41 → 2.3.0-next.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/_virtual/_rolldown/runtime.cjs +23 -0
- package/build/_virtual/_rolldown/runtime.js +5 -0
- package/build/codegen.cjs +19 -0
- package/build/codegen.cjs.map +1 -0
- package/build/codegen.d.cts +1 -0
- package/build/codegen.d.mts +1 -0
- package/build/codegen.js +11 -28
- package/build/codegen.js.map +1 -1
- package/build/drivers/PostgresDriver.cjs +290 -0
- package/build/drivers/PostgresDriver.cjs.map +1 -0
- package/build/drivers/PostgresDriver.d.cts +77 -0
- package/build/drivers/PostgresDriver.d.cts.map +1 -0
- package/build/drivers/PostgresDriver.d.mts +77 -0
- package/build/drivers/PostgresDriver.d.mts.map +1 -0
- package/build/drivers/PostgresDriver.js +249 -325
- package/build/drivers/PostgresDriver.js.map +1 -1
- package/build/drivers/WireRowData.cjs +374 -0
- package/build/drivers/WireRowData.cjs.map +1 -0
- package/build/drivers/WireRowData.d.cts +111 -0
- package/build/drivers/WireRowData.d.cts.map +1 -0
- package/build/drivers/WireRowData.d.mts +111 -0
- package/build/drivers/WireRowData.d.mts.map +1 -0
- package/build/drivers/WireRowData.js +352 -412
- package/build/drivers/WireRowData.js.map +1 -1
- package/build/drivers/binaryParsers.cjs +422 -0
- package/build/drivers/binaryParsers.cjs.map +1 -0
- package/build/drivers/{binaryParsers.d.ts → binaryParsers.d.cts} +18 -14
- package/build/drivers/binaryParsers.d.cts.map +1 -0
- package/build/drivers/binaryParsers.d.mts +80 -0
- package/build/drivers/binaryParsers.d.mts.map +1 -0
- package/build/drivers/binaryParsers.js +315 -385
- package/build/drivers/binaryParsers.js.map +1 -1
- package/build/drivers/patchPgProtocol.cjs +255 -0
- package/build/drivers/patchPgProtocol.cjs.map +1 -0
- package/build/drivers/{patchPgProtocol.d.ts → patchPgProtocol.d.cts} +18 -14
- package/build/drivers/patchPgProtocol.d.cts.map +1 -0
- package/build/drivers/patchPgProtocol.d.mts +47 -0
- package/build/drivers/patchPgProtocol.d.mts.map +1 -0
- package/build/drivers/patchPgProtocol.js +211 -232
- package/build/drivers/patchPgProtocol.js.map +1 -1
- package/build/graphql-codegen-export.cjs +10 -0
- package/build/graphql-codegen-export.d.cts +1 -0
- package/build/graphql-codegen-export.d.mts +1 -0
- package/build/graphql-codegen-export.js +2 -19
- package/build/graphql-export.cjs +10 -0
- package/build/graphql-export.d.cts +1 -0
- package/build/graphql-export.d.mts +1 -0
- package/build/graphql-export.js +2 -19
- package/build/index.cjs +41 -0
- package/build/index.d.cts +3 -0
- package/build/index.d.mts +3 -0
- package/build/index.js +3 -27
- package/build/knex-export.cjs +10 -0
- package/build/knex-export.d.cts +1 -0
- package/build/knex-export.d.mts +1 -0
- package/build/knex-export.js +2 -19
- package/build/pg-export.cjs +13 -0
- package/build/pg-export.d.cts +4 -0
- package/build/pg-export.d.mts +4 -0
- package/build/pg-export.js +4 -20
- package/build/pg-migrate.cjs +22 -0
- package/build/pg-migrate.cjs.map +1 -0
- package/build/pg-migrate.d.cts +1 -0
- package/build/pg-migrate.d.mts +1 -0
- package/build/pg-migrate.js +13 -28
- package/build/pg-migrate.js.map +1 -1
- package/build/seed.cjs +49 -0
- package/build/seed.cjs.map +1 -0
- package/build/{seed.d.ts → seed.d.cts} +5 -1
- package/build/seed.d.cts.map +1 -0
- package/build/seed.d.mts +24 -0
- package/build/seed.d.mts.map +1 -0
- package/build/seed.js +39 -45
- package/build/seed.js.map +1 -1
- package/build/tests-export.cjs +10 -0
- package/build/tests-export.d.cts +1 -0
- package/build/tests-export.d.mts +1 -0
- package/build/tests-export.js +2 -19
- package/package.json +150 -28
- package/build/codegen.d.ts +0 -2
- package/build/drivers/PostgresDriver.d.ts +0 -73
- package/build/drivers/WireRowData.d.ts +0 -107
- package/build/graphql-codegen-export.d.ts +0 -1
- package/build/graphql-codegen-export.js.map +0 -1
- package/build/graphql-export.d.ts +0 -1
- package/build/graphql-export.js.map +0 -1
- package/build/index.d.ts +0 -3
- package/build/index.js.map +0 -1
- package/build/knex-export.d.ts +0 -1
- package/build/knex-export.js.map +0 -1
- package/build/pg-export.d.ts +0 -3
- package/build/pg-export.js.map +0 -1
- package/build/pg-migrate.d.ts +0 -2
- package/build/tests-export.d.ts +0 -1
- package/build/tests-export.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WireRowData.d.cts","names":[],"sources":["../../src/drivers/WireRowData.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkFa,uBAAuB;;MAa9B;;MAKA;;MAKA;EAMJ,IAAI,kBAAkB;;EAWtB,MAAM;;EAsBN;;;;;;;;;;;EAgBA,kBACE,QAAQ;IAAQ;IAAc;IAAoB;MAClD,iBAAiB,wBAAwB;;;;;;;;;EA+B3C,OAAO,OAAO,QAAQ,gBAAgB;;EAwBtC,OAAO;;;;;;;;;;;;;;;;;EAoBP;;iBAoIc,oBACd,QAAQ,GAAG,YACX,aACA,0BACA;EAAS;IACR,QAAQ;;iBAkBK,uBAAuB,kBAAkB,UAAU,GAAG"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { RowData } from "joist-core";
|
|
2
|
+
import pg from "pg";
|
|
3
|
+
//#region src/drivers/WireRowData.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A lazy wire-row {@link RowData} over raw Postgres `DataRow` payload bytes.
|
|
6
|
+
*
|
|
7
|
+
* Each query produces its own `WireRowData` — one query, one result; results are never combined
|
|
8
|
+
* or appended across queries, and the payload is read-only after the query completes (entity
|
|
9
|
+
* mutations go into `InstanceData.data`, never back into the row bytes).
|
|
10
|
+
*
|
|
11
|
+
* Rows are kept in their row-major wire format (`int16 fieldCount` + length-prefixed cells) as
|
|
12
|
+
* zero-copy views over the parser's own immutable buffers: `addRow` records each DataRow's
|
|
13
|
+
* `(bytes, offset, length)` by reference, deduping the socket chunk that consecutive rows
|
|
14
|
+
* share. (Our pg-protocol patch guarantees message bytes are never rewritten — chunks parse in
|
|
15
|
+
* place and straddling messages get a buffer of their own; see `patchPgProtocol.ts`.) A
|
|
16
|
+
* `row × column` cell is decoded on first field access by scanning the row's length-prefixed
|
|
17
|
+
* cells to the column's ordinal ("row-lazy" decode, see JS-ROW-STORE-DESIGN.md §3/C2). This is
|
|
18
|
+
* deferred decoding of row-major data, not a columnar layout.
|
|
19
|
+
*
|
|
20
|
+
* Because chunks are whole socket reads, retaining any row pins its ~64KiB chunk (plus whatever
|
|
21
|
+
* protocol frames share it); `finalize`'s compaction copies retained rows out into an
|
|
22
|
+
* exact-size owned buffer when enough of the payload was dropped.
|
|
23
|
+
*
|
|
24
|
+
* Text-format cells go through the same active text parsers node-postgres would resolve for
|
|
25
|
+
* the query (i.e. honoring pool/client `TypeOverrides`), so they parse identically to classic
|
|
26
|
+
* rows. Binary-format cells decode via `wireBinaryParser`: wire bytes -> value directly for
|
|
27
|
+
* default-parsed scalar types (no intermediate string), else rendered to pg's canonical text
|
|
28
|
+
* and fed through the active text parser for parity. (Classic node-postgres cannot do binary
|
|
29
|
+
* at all — it round-trips cells through a UTF-8 string, corrupting bytes >= 0x80.)
|
|
30
|
+
*
|
|
31
|
+
* Because decoding is deferred, a custom parser that throws will do so on first field access
|
|
32
|
+
* (or `toRow`/`toRows`), not while awaiting the query; `id` and inheritance-discriminator cells
|
|
33
|
+
* still decode during hydration.
|
|
34
|
+
*
|
|
35
|
+
* After hydration, `finalize` trims unused capacity and, when some rows were not retained (i.e.
|
|
36
|
+
* their entities were already in the identity map), compacts the payload down to only the
|
|
37
|
+
* retained rows, so retained memory tracks live entities rather than query history.
|
|
38
|
+
*
|
|
39
|
+
* Small results deliberately stay lazy — there is NO row-count threshold below which we
|
|
40
|
+
* materialize to a `PojoRowData` instead. Measured (benchmark-rowdata-small.ts, 40-col rows):
|
|
41
|
+
* for the typical sparse access pattern (~6 of 40 columns read), keeping the lazy result wins at
|
|
42
|
+
* every size including a single row (n=1: 4.3µs vs 7.6µs; n=1000: 0.76ms vs 3.0ms), because
|
|
43
|
+
* materialization eagerly decodes every column while lazy faults only what is read. Even full
|
|
44
|
+
* column coverage no longer flips the winner: with binary decode and `#readCell`'s adaptive
|
|
45
|
+
* scan cursor, reading all ~36 columns of every row measures ~parity with classic end-to-end
|
|
46
|
+
* (benchmark-lazy-parsing.ts), and small finds (n <= 10) are statistically identical.
|
|
47
|
+
*/
|
|
48
|
+
declare class WireRowData implements RowData {
|
|
49
|
+
#private;
|
|
50
|
+
get rowCount(): number;
|
|
51
|
+
/** The DataRow payload bytes currently indexed; drops when compaction discards rows. */
|
|
52
|
+
get payloadBytes(): number;
|
|
53
|
+
/** The bytes currently held by payload chunks + the row-slice table, i.e. for benchmarks. */
|
|
54
|
+
get memoryBytes(): number;
|
|
55
|
+
get(rowIndex: number, columnName: string): any;
|
|
56
|
+
/** Materializes one row as a POJO, i.e. for debugging and differential tests; values are not cached. */
|
|
57
|
+
toRow(rowIndex: number): any;
|
|
58
|
+
/** Materializes classic POJO rows, i.e. for `afterFind` observation or debugging; not cached. */
|
|
59
|
+
toRows(): any[];
|
|
60
|
+
/**
|
|
61
|
+
* Resolves each column's decoder from the query's RowDescription.
|
|
62
|
+
*
|
|
63
|
+
* Binary-format fields decode through Joist's own binary registry only (see
|
|
64
|
+
* `setBinaryTypeParser`) — `pg.types`/`TypeOverrides` are never consulted, and a column whose
|
|
65
|
+
* oid has no registered binary parser fails the query here, before any rows arrive, rather
|
|
66
|
+
* than guessing at a lossy decoding. Text-format fields (the `binary: false` escape hatch)
|
|
67
|
+
* decode by utf8-slicing the cell into the active text parser, resolved via `getTypeParser`
|
|
68
|
+
* (i.e. the pool/client `TypeOverrides` chain) or the global registry.
|
|
69
|
+
*/
|
|
70
|
+
setRowDescription(fields: Array<{
|
|
71
|
+
name: string;
|
|
72
|
+
dataTypeID: number;
|
|
73
|
+
format?: string;
|
|
74
|
+
}>, getTypeParser?: (dataTypeID: number) => (value: any) => any): void;
|
|
75
|
+
/**
|
|
76
|
+
* Records one DataRow payload *by reference* (zero-copy); called synchronously from the wire
|
|
77
|
+
* parser, whose patched buffer management guarantees the bytes are never rewritten.
|
|
78
|
+
*
|
|
79
|
+
* Consecutive rows usually share one socket chunk, so `bytes` is deduped against the last
|
|
80
|
+
* chunk ref; retaining any row of a chunk pins the whole chunk, which `finalize`'s compaction
|
|
81
|
+
* resolves by copying retained rows out when enough of the payload was dropped.
|
|
82
|
+
*/
|
|
83
|
+
addRow(bytes: Buffer, offset: number, payloadLength: number): void;
|
|
84
|
+
/** Marks `rowIndex` as retained by a hydrated entity; unmarked rows can be compacted away. */
|
|
85
|
+
retain(rowIndex: number): void;
|
|
86
|
+
/**
|
|
87
|
+
* Trims unused capacity, and compacts down to only `retain`-ed rows when enough rows were not
|
|
88
|
+
* retained to be worth the copy.
|
|
89
|
+
*
|
|
90
|
+
* Compaction exists to release pinned socket buffers to the GC: rows are zero-copy views into
|
|
91
|
+
* whole ~64KiB chunks, so keeping any row alive pins its entire chunk — and unretained rows
|
|
92
|
+
* are typically duplicates whose entities were *already in memory* (identity-map hits that
|
|
93
|
+
* keep their original `rowData`), making the newly-arrived bytes dead weight. Copying the
|
|
94
|
+
* retained rows into one exact-size owned buffer lets every chunk reference drop.
|
|
95
|
+
*
|
|
96
|
+
* The copy re-copies every retained byte, so it only pays off when it buys back a meaningful
|
|
97
|
+
* fraction of the payload: we compact when the dropped rows hold more than 20% of the payload
|
|
98
|
+
* bytes, and otherwise just trim, accepting the (bounded) leftover bytes. Called once after
|
|
99
|
+
* hydration + sidecar reads (`_tags`, preload aggregates) are complete; retained entities keep
|
|
100
|
+
* their original `rowIndex`, and un-compacted unretained rows simply remain readable-but-unused.
|
|
101
|
+
*/
|
|
102
|
+
finalize(): void;
|
|
103
|
+
}
|
|
104
|
+
declare function executeRowDataQuery(client: pg.PoolClient, sql: string, bindings: readonly any[], opts?: {
|
|
105
|
+
binary?: boolean;
|
|
106
|
+
}): Promise<RowData>;
|
|
107
|
+
/** Returns whether `client` supports the lazy row-data query path, before submitting anything. */
|
|
108
|
+
declare function isRowDataCapableClient(client: unknown): client is pg.PoolClient;
|
|
109
|
+
//#endregion
|
|
110
|
+
export { WireRowData, executeRowDataQuery, isRowDataCapableClient };
|
|
111
|
+
//# sourceMappingURL=WireRowData.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WireRowData.d.mts","names":[],"sources":["../../src/drivers/WireRowData.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkFa,uBAAuB;;MAa9B;;MAKA;;MAKA;EAMJ,IAAI,kBAAkB;;EAWtB,MAAM;;EAsBN;;;;;;;;;;;EAgBA,kBACE,QAAQ;IAAQ;IAAc;IAAoB;MAClD,iBAAiB,wBAAwB;;;;;;;;;EA+B3C,OAAO,OAAO,QAAQ,gBAAgB;;EAwBtC,OAAO;;;;;;;;;;;;;;;;;EAoBP;;iBAoIc,oBACd,QAAQ,GAAG,YACX,aACA,0BACA;EAAS;IACR,QAAQ;;iBAkBK,uBAAuB,kBAAkB,UAAU,GAAG"}
|