@venturekit/data 0.0.0-dev.20260427225816 → 0.0.0-dev.20260429113801
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/README.md +9 -5
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/migrations/dispatcher.d.ts +35 -0
- package/dist/migrations/dispatcher.d.ts.map +1 -0
- package/dist/migrations/dispatcher.js +71 -0
- package/dist/migrations/dispatcher.js.map +1 -0
- package/dist/migrations/env.d.ts +12 -0
- package/dist/migrations/env.d.ts.map +1 -0
- package/dist/migrations/env.js +12 -0
- package/dist/migrations/env.js.map +1 -0
- package/dist/migrations/errors.d.ts +33 -0
- package/dist/migrations/errors.d.ts.map +1 -0
- package/dist/migrations/errors.js +48 -0
- package/dist/migrations/errors.js.map +1 -0
- package/dist/migrations/index.d.ts +31 -10
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +33 -11
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/runners/custom.d.ts +72 -0
- package/dist/migrations/runners/custom.d.ts.map +1 -0
- package/dist/migrations/runners/custom.js +167 -0
- package/dist/migrations/runners/custom.js.map +1 -0
- package/dist/migrations/runners/drizzle.d.ts +12 -0
- package/dist/migrations/runners/drizzle.d.ts.map +1 -0
- package/dist/migrations/runners/drizzle.js +17 -0
- package/dist/migrations/runners/drizzle.js.map +1 -0
- package/dist/migrations/runners/flyway.d.ts +14 -0
- package/dist/migrations/runners/flyway.d.ts.map +1 -0
- package/dist/migrations/runners/flyway.js +20 -0
- package/dist/migrations/runners/flyway.js.map +1 -0
- package/dist/migrations/runners/golang-migrate.d.ts +8 -0
- package/dist/migrations/runners/golang-migrate.d.ts.map +1 -0
- package/dist/migrations/runners/golang-migrate.js +13 -0
- package/dist/migrations/runners/golang-migrate.js.map +1 -0
- package/dist/migrations/runners/prisma.d.ts +10 -0
- package/dist/migrations/runners/prisma.d.ts.map +1 -0
- package/dist/migrations/runners/prisma.js +15 -0
- package/dist/migrations/runners/prisma.js.map +1 -0
- package/dist/migrations/seeds.d.ts +39 -0
- package/dist/migrations/seeds.d.ts.map +1 -0
- package/dist/migrations/seeds.js +50 -0
- package/dist/migrations/seeds.js.map +1 -0
- package/dist/migrations/types.d.ts +48 -0
- package/dist/migrations/types.d.ts.map +1 -0
- package/dist/migrations/types.js +9 -0
- package/dist/migrations/types.js.map +1 -0
- package/dist/query/index.d.ts +6 -4
- package/dist/query/index.d.ts.map +1 -1
- package/dist/query/index.js +4 -4
- package/dist/query/index.js.map +1 -1
- package/dist/query/mapper.d.ts +63 -11
- package/dist/query/mapper.d.ts.map +1 -1
- package/dist/query/mapper.js +76 -16
- package/dist/query/mapper.js.map +1 -1
- package/dist/query/pool.d.ts +15 -2
- package/dist/query/pool.d.ts.map +1 -1
- package/dist/query/pool.js +52 -2
- package/dist/query/pool.js.map +1 -1
- package/dist/query/transaction.d.ts +17 -1
- package/dist/query/transaction.d.ts.map +1 -1
- package/dist/query/transaction.js +2 -2
- package/dist/query/transaction.js.map +1 -1
- package/dist/types/migration.d.ts +11 -6
- package/dist/types/migration.d.ts.map +1 -1
- package/dist/types/migration.js +11 -6
- package/dist/types/migration.js.map +1 -1
- package/package.json +2 -2
package/dist/query/mapper.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Result Mapper
|
|
3
3
|
*
|
|
4
|
-
* Maps flat database rows with dot-notation column aliases
|
|
5
|
-
*
|
|
4
|
+
* Maps flat database rows with dot-notation column aliases into nested
|
|
5
|
+
* objects, and optionally transforms snake_case keys into camelCase.
|
|
6
6
|
*
|
|
7
|
-
* ##
|
|
7
|
+
* ## Dot-notation nesting (always on)
|
|
8
8
|
*
|
|
9
9
|
* Column aliases containing dots are split and turned into nested objects:
|
|
10
10
|
*
|
|
@@ -14,15 +14,30 @@
|
|
|
14
14
|
* { id: 1, author: { id: 5, name: "Alice" } }
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* Deeper nesting is also supported
|
|
17
|
+
* Deeper nesting is also supported (`"author.address.city"` →
|
|
18
|
+
* `{ author: { address: { city: ... } } }`).
|
|
19
|
+
*
|
|
20
|
+
* ## camelCase transform (default ON)
|
|
21
|
+
*
|
|
22
|
+
* Top-level snake_case keys are transformed to camelCase by default.
|
|
23
|
+
* Opt out per-call with `mapRow(row, { camelCase: false })` /
|
|
24
|
+
* `mapResults(rows, { camelCase: false })`, or globally with
|
|
25
|
+
* `configureMapper({ camelCase: false })` (e.g. for a service whose row
|
|
26
|
+
* shapes are already camelCase or where the consumer wants raw pg keys).
|
|
27
|
+
*
|
|
28
|
+
* The transform is **shallow** — only top-level row keys (and each segment
|
|
29
|
+
* of a dot-notation alias) are camelCased. Nested values from `jsonb`
|
|
30
|
+
* columns pass through unchanged so application-controlled shapes inside
|
|
31
|
+
* jsonb are preserved verbatim. Leading underscores (`_internal`) are
|
|
32
|
+
* preserved.
|
|
18
33
|
*
|
|
19
34
|
* ```
|
|
20
|
-
* {
|
|
21
|
-
* //
|
|
22
|
-
* { author: { address: { city: "Paris" } } }
|
|
23
|
-
* ```
|
|
35
|
+
* mapRow({ tenant_id: 'a', 'author.user_name': 'Alice', meta: { kept_as_is: 1 } });
|
|
36
|
+
* // => { tenantId: 'a', author: { userName: 'Alice' }, meta: { kept_as_is: 1 } }
|
|
24
37
|
*
|
|
25
|
-
*
|
|
38
|
+
* mapRow({ tenant_id: 'a' }, { camelCase: false });
|
|
39
|
+
* // => { tenant_id: 'a' }
|
|
40
|
+
* ```
|
|
26
41
|
*
|
|
27
42
|
* ## Important notes
|
|
28
43
|
*
|
|
@@ -32,6 +47,39 @@
|
|
|
32
47
|
* and `author.id` exist), the nested object wins and the plain value
|
|
33
48
|
* is overwritten. Use unambiguous aliases to avoid this.
|
|
34
49
|
*/
|
|
50
|
+
/** Per-call options accepted by `mapRow` / `mapResults`. */
|
|
51
|
+
export interface MapperOptions {
|
|
52
|
+
/**
|
|
53
|
+
* Transform top-level snake_case keys (and dot-notation segments) into
|
|
54
|
+
* camelCase. Shallow — nested objects/arrays inside values pass through.
|
|
55
|
+
* Defaults to whatever `configureMapper` set, otherwise `true` (the
|
|
56
|
+
* package default).
|
|
57
|
+
*/
|
|
58
|
+
camelCase?: boolean;
|
|
59
|
+
}
|
|
60
|
+
interface MapperConfig {
|
|
61
|
+
camelCase: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Set package-wide defaults for `mapRow` / `mapResults` (and therefore
|
|
65
|
+
* every `query()` result). Call once at app boot, before any DB I/O.
|
|
66
|
+
*
|
|
67
|
+
* Per-call options on `mapRow` / `mapResults` always override the global
|
|
68
|
+
* setting for that call.
|
|
69
|
+
*
|
|
70
|
+
* camelCase is ON by default — you only need this helper to OPT OUT
|
|
71
|
+
* (e.g. for a service that wants raw pg snake_case keys, or a one-off
|
|
72
|
+
* tool whose row contracts predate the new default).
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* import { configureMapper } from '@venturekit/data';
|
|
77
|
+
* configureMapper({ camelCase: false }); // snake_case row keys, package-wide
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function configureMapper(config: MapperOptions): void;
|
|
81
|
+
/** Read the current global mapper config (test/debug helper). */
|
|
82
|
+
export declare function getMapperConfig(): Readonly<MapperConfig>;
|
|
35
83
|
/**
|
|
36
84
|
* Map a single flat row with dot-notation keys into a nested object.
|
|
37
85
|
*
|
|
@@ -39,9 +87,12 @@
|
|
|
39
87
|
* ```typescript
|
|
40
88
|
* mapRow({ id: 1, 'author.id': 5, 'author.name': 'Alice' });
|
|
41
89
|
* // => { id: 1, author: { id: 5, name: 'Alice' } }
|
|
90
|
+
*
|
|
91
|
+
* mapRow({ tenant_id: 'a', created_at: new Date() }, { camelCase: true });
|
|
92
|
+
* // => { tenantId: 'a', createdAt: <Date> }
|
|
42
93
|
* ```
|
|
43
94
|
*/
|
|
44
|
-
export declare function mapRow(row: Record<string, unknown
|
|
95
|
+
export declare function mapRow(row: Record<string, unknown>, opts?: MapperOptions): Record<string, unknown>;
|
|
45
96
|
/**
|
|
46
97
|
* Map an array of flat database rows into nested objects.
|
|
47
98
|
*
|
|
@@ -58,5 +109,6 @@ export declare function mapRow(row: Record<string, unknown>): Record<string, unk
|
|
|
58
109
|
* // => [{ id: 1, author: { name: 'Alice' } }, ...]
|
|
59
110
|
* ```
|
|
60
111
|
*/
|
|
61
|
-
export declare function mapResults(rows: Record<string, unknown>[]): Record<string, unknown>[];
|
|
112
|
+
export declare function mapResults(rows: Record<string, unknown>[], opts?: MapperOptions): Record<string, unknown>[];
|
|
113
|
+
export {};
|
|
62
114
|
//# sourceMappingURL=mapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../src/query/mapper.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../src/query/mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,4DAA4D;AAC5D,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,YAAY;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAE3D;AAED,iEAAiE;AACjE,wBAAgB,eAAe,IAAI,QAAQ,CAAC,YAAY,CAAC,CAExD;AAmBD;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CACpB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,CAAC,EAAE,aAAa,GACnB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAyBzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,IAAI,CAAC,EAAE,aAAa,GACnB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAG3B"}
|
package/dist/query/mapper.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Result Mapper
|
|
3
3
|
*
|
|
4
|
-
* Maps flat database rows with dot-notation column aliases
|
|
5
|
-
*
|
|
4
|
+
* Maps flat database rows with dot-notation column aliases into nested
|
|
5
|
+
* objects, and optionally transforms snake_case keys into camelCase.
|
|
6
6
|
*
|
|
7
|
-
* ##
|
|
7
|
+
* ## Dot-notation nesting (always on)
|
|
8
8
|
*
|
|
9
9
|
* Column aliases containing dots are split and turned into nested objects:
|
|
10
10
|
*
|
|
@@ -14,15 +14,30 @@
|
|
|
14
14
|
* { id: 1, author: { id: 5, name: "Alice" } }
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* Deeper nesting is also supported
|
|
17
|
+
* Deeper nesting is also supported (`"author.address.city"` →
|
|
18
|
+
* `{ author: { address: { city: ... } } }`).
|
|
19
|
+
*
|
|
20
|
+
* ## camelCase transform (default ON)
|
|
21
|
+
*
|
|
22
|
+
* Top-level snake_case keys are transformed to camelCase by default.
|
|
23
|
+
* Opt out per-call with `mapRow(row, { camelCase: false })` /
|
|
24
|
+
* `mapResults(rows, { camelCase: false })`, or globally with
|
|
25
|
+
* `configureMapper({ camelCase: false })` (e.g. for a service whose row
|
|
26
|
+
* shapes are already camelCase or where the consumer wants raw pg keys).
|
|
27
|
+
*
|
|
28
|
+
* The transform is **shallow** — only top-level row keys (and each segment
|
|
29
|
+
* of a dot-notation alias) are camelCased. Nested values from `jsonb`
|
|
30
|
+
* columns pass through unchanged so application-controlled shapes inside
|
|
31
|
+
* jsonb are preserved verbatim. Leading underscores (`_internal`) are
|
|
32
|
+
* preserved.
|
|
18
33
|
*
|
|
19
34
|
* ```
|
|
20
|
-
* {
|
|
21
|
-
* //
|
|
22
|
-
* { author: { address: { city: "Paris" } } }
|
|
23
|
-
* ```
|
|
35
|
+
* mapRow({ tenant_id: 'a', 'author.user_name': 'Alice', meta: { kept_as_is: 1 } });
|
|
36
|
+
* // => { tenantId: 'a', author: { userName: 'Alice' }, meta: { kept_as_is: 1 } }
|
|
24
37
|
*
|
|
25
|
-
*
|
|
38
|
+
* mapRow({ tenant_id: 'a' }, { camelCase: false });
|
|
39
|
+
* // => { tenant_id: 'a' }
|
|
40
|
+
* ```
|
|
26
41
|
*
|
|
27
42
|
* ## Important notes
|
|
28
43
|
*
|
|
@@ -32,6 +47,47 @@
|
|
|
32
47
|
* and `author.id` exist), the nested object wins and the plain value
|
|
33
48
|
* is overwritten. Use unambiguous aliases to avoid this.
|
|
34
49
|
*/
|
|
50
|
+
const mapperConfig = { camelCase: true };
|
|
51
|
+
/**
|
|
52
|
+
* Set package-wide defaults for `mapRow` / `mapResults` (and therefore
|
|
53
|
+
* every `query()` result). Call once at app boot, before any DB I/O.
|
|
54
|
+
*
|
|
55
|
+
* Per-call options on `mapRow` / `mapResults` always override the global
|
|
56
|
+
* setting for that call.
|
|
57
|
+
*
|
|
58
|
+
* camelCase is ON by default — you only need this helper to OPT OUT
|
|
59
|
+
* (e.g. for a service that wants raw pg snake_case keys, or a one-off
|
|
60
|
+
* tool whose row contracts predate the new default).
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* import { configureMapper } from '@venturekit/data';
|
|
65
|
+
* configureMapper({ camelCase: false }); // snake_case row keys, package-wide
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export function configureMapper(config) {
|
|
69
|
+
if (config.camelCase !== undefined)
|
|
70
|
+
mapperConfig.camelCase = config.camelCase;
|
|
71
|
+
}
|
|
72
|
+
/** Read the current global mapper config (test/debug helper). */
|
|
73
|
+
export function getMapperConfig() {
|
|
74
|
+
return mapperConfig;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* snake_case → camelCase for a single segment.
|
|
78
|
+
*
|
|
79
|
+
* - Leading underscores are preserved (`_internal` stays `_internal`).
|
|
80
|
+
* - Multiple consecutive underscores collapse (`a__b` → `aB`).
|
|
81
|
+
* - Already-camelCase / already-flat keys pass through unchanged.
|
|
82
|
+
*/
|
|
83
|
+
function toCamelCase(segment) {
|
|
84
|
+
return segment.replace(/([A-Za-z0-9])_+([A-Za-z])/g, (_match, before, after) => {
|
|
85
|
+
return `${before}${after.toUpperCase()}`;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function resolveCamelCase(opts) {
|
|
89
|
+
return opts?.camelCase ?? mapperConfig.camelCase;
|
|
90
|
+
}
|
|
35
91
|
/**
|
|
36
92
|
* Map a single flat row with dot-notation keys into a nested object.
|
|
37
93
|
*
|
|
@@ -39,13 +95,17 @@
|
|
|
39
95
|
* ```typescript
|
|
40
96
|
* mapRow({ id: 1, 'author.id': 5, 'author.name': 'Alice' });
|
|
41
97
|
* // => { id: 1, author: { id: 5, name: 'Alice' } }
|
|
98
|
+
*
|
|
99
|
+
* mapRow({ tenant_id: 'a', created_at: new Date() }, { camelCase: true });
|
|
100
|
+
* // => { tenantId: 'a', createdAt: <Date> }
|
|
42
101
|
* ```
|
|
43
102
|
*/
|
|
44
|
-
export function mapRow(row) {
|
|
103
|
+
export function mapRow(row, opts) {
|
|
104
|
+
const camelCase = resolveCamelCase(opts);
|
|
45
105
|
const mapped = {};
|
|
46
|
-
for (const [
|
|
47
|
-
if (
|
|
48
|
-
const parts =
|
|
106
|
+
for (const [rawKey, value] of Object.entries(row)) {
|
|
107
|
+
if (rawKey.indexOf('.') > 0) {
|
|
108
|
+
const parts = rawKey.split('.').map((p) => (camelCase ? toCamelCase(p) : p));
|
|
49
109
|
let current = mapped;
|
|
50
110
|
let part = parts.shift();
|
|
51
111
|
while (parts.length > 0) {
|
|
@@ -58,7 +118,7 @@ export function mapRow(row) {
|
|
|
58
118
|
current[part] = value;
|
|
59
119
|
}
|
|
60
120
|
else {
|
|
61
|
-
mapped[
|
|
121
|
+
mapped[camelCase ? toCamelCase(rawKey) : rawKey] = value;
|
|
62
122
|
}
|
|
63
123
|
}
|
|
64
124
|
return mapped;
|
|
@@ -79,9 +139,9 @@ export function mapRow(row) {
|
|
|
79
139
|
* // => [{ id: 1, author: { name: 'Alice' } }, ...]
|
|
80
140
|
* ```
|
|
81
141
|
*/
|
|
82
|
-
export function mapResults(rows) {
|
|
142
|
+
export function mapResults(rows, opts) {
|
|
83
143
|
if (!rows || rows.length === 0)
|
|
84
144
|
return [];
|
|
85
|
-
return rows.map(mapRow);
|
|
145
|
+
return rows.map((row) => mapRow(row, opts));
|
|
86
146
|
}
|
|
87
147
|
//# sourceMappingURL=mapper.js.map
|
package/dist/query/mapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.js","sourceRoot":"","sources":["../../src/query/mapper.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mapper.js","sourceRoot":"","sources":["../../src/query/mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAiBH,MAAM,YAAY,GAAiB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,eAAe,CAAC,MAAqB;IACnD,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS;QAAE,YAAY,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;AAChF,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,eAAe;IAC7B,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,OAAe;IA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;YAED,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,UAAU,CACxB,IAA+B,EAC/B,IAAoB;IAEpB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAC9C,CAAC"}
|
package/dist/query/pool.d.ts
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
* Creates a pg connection pool from environment variables.
|
|
5
5
|
* All credentials are loaded from env — never hardcoded.
|
|
6
6
|
*
|
|
7
|
-
* Required env vars
|
|
8
|
-
*
|
|
7
|
+
* Required env vars (either form works — `DATABASE_URL` is parsed into the
|
|
8
|
+
* granular slots automatically on first `getPool()` call):
|
|
9
|
+
* - DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD, **or**
|
|
10
|
+
* - DATABASE_URL = `postgres://user:pass@host:5432/db?sslmode=require`
|
|
11
|
+
*
|
|
9
12
|
* Optional:
|
|
10
13
|
* - DB_SSL ("true" to enable TLS — verifies the server certificate by default)
|
|
11
14
|
* - DB_SSL_CA (PEM-encoded CA bundle to trust, e.g. the RDS global bundle)
|
|
@@ -13,5 +16,15 @@
|
|
|
13
16
|
* - DB_POOL_MAX (default 10)
|
|
14
17
|
*/
|
|
15
18
|
import { Pool } from 'pg';
|
|
19
|
+
/**
|
|
20
|
+
* Bridge `DATABASE_URL` into the granular `DB_*` slots `getPool()` reads.
|
|
21
|
+
* Idempotent — only fills slots that aren't already set, so the granular
|
|
22
|
+
* form always wins. No-op if `DATABASE_URL` is unset or doesn't parse.
|
|
23
|
+
*
|
|
24
|
+
* Called automatically on first `getPool()` invocation so consumers using
|
|
25
|
+
* `DATABASE_URL` (Twelve-Factor, RDS console copy/paste, etc.) work
|
|
26
|
+
* without wiring their own bridge.
|
|
27
|
+
*/
|
|
28
|
+
export declare function applyDatabaseUrlToEnv(): void;
|
|
16
29
|
export declare function getPool(): Pool;
|
|
17
30
|
//# sourceMappingURL=pool.d.ts.map
|
package/dist/query/pool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/query/pool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/query/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,IAAI,EAAmB,MAAM,IAAI,CAAC;AAI3C;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAoC5C;AAwBD,wBAAgB,OAAO,IAAI,IAAI,CAc9B"}
|
package/dist/query/pool.js
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
* Creates a pg connection pool from environment variables.
|
|
5
5
|
* All credentials are loaded from env — never hardcoded.
|
|
6
6
|
*
|
|
7
|
-
* Required env vars
|
|
8
|
-
*
|
|
7
|
+
* Required env vars (either form works — `DATABASE_URL` is parsed into the
|
|
8
|
+
* granular slots automatically on first `getPool()` call):
|
|
9
|
+
* - DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD, **or**
|
|
10
|
+
* - DATABASE_URL = `postgres://user:pass@host:5432/db?sslmode=require`
|
|
11
|
+
*
|
|
9
12
|
* Optional:
|
|
10
13
|
* - DB_SSL ("true" to enable TLS — verifies the server certificate by default)
|
|
11
14
|
* - DB_SSL_CA (PEM-encoded CA bundle to trust, e.g. the RDS global bundle)
|
|
@@ -14,6 +17,52 @@
|
|
|
14
17
|
*/
|
|
15
18
|
import { Pool } from 'pg';
|
|
16
19
|
let pool = null;
|
|
20
|
+
/**
|
|
21
|
+
* Bridge `DATABASE_URL` into the granular `DB_*` slots `getPool()` reads.
|
|
22
|
+
* Idempotent — only fills slots that aren't already set, so the granular
|
|
23
|
+
* form always wins. No-op if `DATABASE_URL` is unset or doesn't parse.
|
|
24
|
+
*
|
|
25
|
+
* Called automatically on first `getPool()` invocation so consumers using
|
|
26
|
+
* `DATABASE_URL` (Twelve-Factor, RDS console copy/paste, etc.) work
|
|
27
|
+
* without wiring their own bridge.
|
|
28
|
+
*/
|
|
29
|
+
export function applyDatabaseUrlToEnv() {
|
|
30
|
+
const url = process.env.DATABASE_URL;
|
|
31
|
+
if (!url)
|
|
32
|
+
return;
|
|
33
|
+
let parsed;
|
|
34
|
+
try {
|
|
35
|
+
parsed = new URL(url);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!process.env.DB_HOST)
|
|
41
|
+
process.env.DB_HOST = parsed.hostname;
|
|
42
|
+
if (!process.env.DB_PORT)
|
|
43
|
+
process.env.DB_PORT = parsed.port || '5432';
|
|
44
|
+
if (!process.env.DB_USER && parsed.username) {
|
|
45
|
+
process.env.DB_USER = decodeURIComponent(parsed.username);
|
|
46
|
+
}
|
|
47
|
+
if (!process.env.DB_PASSWORD && parsed.password) {
|
|
48
|
+
process.env.DB_PASSWORD = decodeURIComponent(parsed.password);
|
|
49
|
+
}
|
|
50
|
+
if (!process.env.DB_NAME) {
|
|
51
|
+
const name = parsed.pathname.replace(/^\//, '');
|
|
52
|
+
if (name)
|
|
53
|
+
process.env.DB_NAME = name;
|
|
54
|
+
}
|
|
55
|
+
// Postgres URLs commonly use `sslmode=require` or `ssl=true`.
|
|
56
|
+
const sslMode = parsed.searchParams.get('sslmode');
|
|
57
|
+
const sslFlag = parsed.searchParams.get('ssl');
|
|
58
|
+
if (!process.env.DB_SSL &&
|
|
59
|
+
(sslMode === 'require' ||
|
|
60
|
+
sslMode === 'verify-ca' ||
|
|
61
|
+
sslMode === 'verify-full' ||
|
|
62
|
+
sslFlag === 'true')) {
|
|
63
|
+
process.env.DB_SSL = 'true';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
17
66
|
/** Build the `ssl` field for PoolConfig based on env vars. */
|
|
18
67
|
function resolveSsl() {
|
|
19
68
|
if (process.env.DB_SSL !== 'true')
|
|
@@ -34,6 +83,7 @@ function resolveSsl() {
|
|
|
34
83
|
}
|
|
35
84
|
export function getPool() {
|
|
36
85
|
if (!pool) {
|
|
86
|
+
applyDatabaseUrlToEnv();
|
|
37
87
|
pool = new Pool({
|
|
38
88
|
host: process.env.DB_HOST,
|
|
39
89
|
port: Number(process.env.DB_PORT ?? 5432),
|
package/dist/query/pool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/query/pool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/query/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,IAAI,EAAmB,MAAM,IAAI,CAAC;AAE3C,IAAI,IAAI,GAAgB,IAAI,CAAC;AAE7B;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IACrC,IAAI,CAAC,GAAG;QAAE,OAAO;IAEjB,IAAI,MAAW,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;IACT,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO;QAAE,OAAO,CAAC,GAAG,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|
10
|
+
import { type MapperOptions } from './mapper.js';
|
|
10
11
|
export type ResultsMapper<T> = (rows: Record<string, unknown>[]) => T;
|
|
11
12
|
/**
|
|
12
13
|
* A transaction handle providing query, commit, and rollback.
|
|
13
14
|
*/
|
|
14
15
|
export interface Transaction {
|
|
15
16
|
/** Execute a query within the transaction */
|
|
16
|
-
query<T = Record<string, unknown>[]>(sqlQuery: string, queryParams?: unknown[], resultsMapper?: ResultsMapper<T
|
|
17
|
+
query<T = Record<string, unknown>[]>(sqlQuery: string, queryParams?: unknown[], resultsMapper?: ResultsMapper<T>, mapperOptions?: MapperOptions): Promise<T>;
|
|
17
18
|
/** Commit the transaction */
|
|
18
19
|
commit(): Promise<void>;
|
|
19
20
|
/** Roll back the transaction */
|
|
20
21
|
rollback(): Promise<void>;
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Function reference for `Transaction.query`. Same signature as the
|
|
25
|
+
* top-level `query`, so this type unifies "use the pool" and "use this
|
|
26
|
+
* transaction" code paths in helpers that want to accept either.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { query, type Querier } from '@venturekit/data';
|
|
31
|
+
*
|
|
32
|
+
* async function findById(id: string, q: Querier = query) {
|
|
33
|
+
* return q('SELECT * FROM things WHERE id = $1', [id]);
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export type Querier = Transaction['query'];
|
|
22
38
|
/**
|
|
23
39
|
* Options for {@link beginTransaction} / {@link withTransaction}.
|
|
24
40
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/query/transaction.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/query/transaction.ts"],"names":[],"mapp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GAC3B,OAAO,CAAC,CAAC,CAAC,CAAC;AACd,wBAAsB,eAAe,CAAC,CAAC,EACrC,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,EAAE,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACnC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,CAAC,CAAC,CAAC;AAkDd;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,CA6BhE"}
|
|
@@ -118,9 +118,9 @@ export async function withTransaction(fnOrOuter, fnOrOptions, maybeOptions) {
|
|
|
118
118
|
*/
|
|
119
119
|
export function buildTransaction(client) {
|
|
120
120
|
return {
|
|
121
|
-
async query(sqlQuery, queryParams, resultsMapper) {
|
|
121
|
+
async query(sqlQuery, queryParams, resultsMapper, mapperOptions) {
|
|
122
122
|
const res = await client.query(sqlQuery, queryParams);
|
|
123
|
-
const mapped = mapResults(res.rows);
|
|
123
|
+
const mapped = mapResults(res.rows, mapperOptions);
|
|
124
124
|
return resultsMapper ? resultsMapper(mapped) : mapped;
|
|
125
125
|
},
|
|
126
126
|
async commit() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/query/transaction.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/query/transaction.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAsB,MAAM,aAAa,CAAC;AAwD7D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC;AAEnD,SAAS,uBAAuB,CAAC,OAA4B;IAC3D,IA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C,KAAK,CACT,QAAgB,EAChB,WAAuB,EACvB,aAAgC,EAChC,aAA6B;YAE7B,MAAM,GAAG,GAAgB,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YACnE,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;YACnD,OAAO,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAsB,CAAC;QACxE,CAAC;QAED,KAAK,CAAC,MAAM;YACV,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC/B,CAAC;oBAAS,CAAC;gBACT,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;QAED,KAAK,CAAC,QAAQ;YACZ,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YACjC,CAAC;oBAAS,CAAC;gBACT,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Migration Types
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* - Prisma Migrate (https://www.prisma.io/migrate) - If using Prisma ORM
|
|
8
|
-
* - Drizzle Kit (https://orm.drizzle.team/kit-docs/overview) - If using Drizzle ORM
|
|
4
|
+
* `tool: 'custom'` is the bundled pure-SQL runner (`runMigrations`,
|
|
5
|
+
* `runSeeds`) — applies `.sql` files from the migrations dir, tracked in
|
|
6
|
+
* `__vk_migrations` / `__vk_seeds`.
|
|
9
7
|
*
|
|
10
|
-
*
|
|
8
|
+
* The other tool values are reserved for future opt-in runners. Today
|
|
9
|
+
* they throw `MigrationToolNotImplementedError`; consumers integrate
|
|
10
|
+
* with these tools by shelling out to their CLI directly:
|
|
11
|
+
*
|
|
12
|
+
* - Flyway (https://flywaydb.org) — Java-based, widely used
|
|
13
|
+
* - golang-migrate (https://github.com/golang-migrate/migrate) — Lightweight CLI
|
|
14
|
+
* - Prisma Migrate (https://www.prisma.io/migrate) — If using Prisma ORM
|
|
15
|
+
* - Drizzle Kit (https://orm.drizzle.team/kit-docs/overview) — If using Drizzle ORM
|
|
11
16
|
*/
|
|
12
17
|
/**
|
|
13
18
|
* Migration tool configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../src/types/migration.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../src/types/migration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,4BAA4B;IAC5B,IAAI,EAAE,QAAQ,GAAG,gBAAgB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IAEpE,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAC;IAEtB,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,gDAAgD;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,QAAQ,GAAG,gBAAgB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACrE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
|
package/dist/types/migration.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Migration Types
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* - Prisma Migrate (https://www.prisma.io/migrate) - If using Prisma ORM
|
|
8
|
-
* - Drizzle Kit (https://orm.drizzle.team/kit-docs/overview) - If using Drizzle ORM
|
|
4
|
+
* `tool: 'custom'` is the bundled pure-SQL runner (`runMigrations`,
|
|
5
|
+
* `runSeeds`) — applies `.sql` files from the migrations dir, tracked in
|
|
6
|
+
* `__vk_migrations` / `__vk_seeds`.
|
|
9
7
|
*
|
|
10
|
-
*
|
|
8
|
+
* The other tool values are reserved for future opt-in runners. Today
|
|
9
|
+
* they throw `MigrationToolNotImplementedError`; consumers integrate
|
|
10
|
+
* with these tools by shelling out to their CLI directly:
|
|
11
|
+
*
|
|
12
|
+
* - Flyway (https://flywaydb.org) — Java-based, widely used
|
|
13
|
+
* - golang-migrate (https://github.com/golang-migrate/migrate) — Lightweight CLI
|
|
14
|
+
* - Prisma Migrate (https://www.prisma.io/migrate) — If using Prisma ORM
|
|
15
|
+
* - Drizzle Kit (https://orm.drizzle.team/kit-docs/overview) — If using Drizzle ORM
|
|
11
16
|
*/
|
|
12
17
|
export {};
|
|
13
18
|
//# sourceMappingURL=migration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.js","sourceRoot":"","sources":["../../src/types/migration.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"migration.js","sourceRoot":"","sources":["../../src/types/migration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venturekit/data",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.20260429113801",
|
|
4
4
|
"description": "Database and data layer for VentureKit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@venturekit/core": "0.0.0-dev.
|
|
28
|
+
"@venturekit/core": "0.0.0-dev.20260429113801",
|
|
29
29
|
"pg": "^8.12.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|