@forinda/kickjs-db 8.7.1 → 8.9.0
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/dist/cli.d.mts +2 -2
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +3 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/create-vlNsemtQ.mjs +31 -0
- package/dist/create-vlNsemtQ.mjs.map +1 -0
- package/dist/custom-type-BSqxHyIa.mjs +12 -0
- package/dist/custom-type-BSqxHyIa.mjs.map +1 -0
- package/dist/devtools-events.d.mts +1 -1
- package/dist/devtools-events.mjs +1 -1
- package/dist/{index-DH4qiCqU.d.mts → index-CV7dszi7.d.mts} +76 -13
- package/dist/index-CV7dszi7.d.mts.map +1 -0
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +2 -2
- package/dist/mysql.d.mts +2 -2
- package/dist/mysql.mjs +2 -2
- package/dist/{pg-BjNaBIHW.mjs → pg-DqVxnk3O.mjs} +3 -3
- package/dist/{pg-BjNaBIHW.mjs.map → pg-DqVxnk3O.mjs.map} +1 -1
- package/dist/pg.d.mts +3 -3
- package/dist/pg.mjs +2 -2
- package/dist/{schema-BIPOM1xj.d.mts → schema-Cl1eDPkD.d.mts} +3 -3
- package/dist/{schema-BIPOM1xj.d.mts.map → schema-Cl1eDPkD.d.mts.map} +1 -1
- package/dist/{schema-types-DIccweFR.d.mts → schema-types-BMUMDpUC.d.mts} +3 -3
- package/dist/{schema-types-DIccweFR.d.mts.map → schema-types-BMUMDpUC.d.mts.map} +1 -1
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +2 -2
- package/dist/{split-statements-DbK3GeXD.mjs → split-statements-CJIglzao.mjs} +2 -2
- package/dist/{split-statements-DbK3GeXD.mjs.map → split-statements-CJIglzao.mjs.map} +1 -1
- package/dist/sqlite.d.mts +1 -1
- package/dist/sqlite.d.mts.map +1 -1
- package/dist/sqlite.mjs +6 -5
- package/dist/sqlite.mjs.map +1 -1
- package/dist/{src-9T0BuJCO.mjs → src-CvN0zCJi.mjs} +11 -8
- package/dist/src-CvN0zCJi.mjs.map +1 -0
- package/dist/{table-B_TVt7EC.d.mts → table-xb127l8S.d.mts} +2 -2
- package/dist/{table-B_TVt7EC.d.mts.map → table-xb127l8S.d.mts.map} +1 -1
- package/dist/testing.d.mts +2 -2
- package/dist/testing.mjs +2 -2
- package/dist/{types-p2E6CrKO.d.mts → types-BosmVkt_.d.mts} +117 -9
- package/dist/types-BosmVkt_.d.mts.map +1 -0
- package/dist/{types-DtX5fIbn.d.mts → types-CBoxFMRg.d.mts} +34 -1
- package/dist/types-CBoxFMRg.d.mts.map +1 -0
- package/package.json +2 -2
- package/dist/create-C_rIYE5P.mjs +0 -29
- package/dist/create-C_rIYE5P.mjs.map +0 -1
- package/dist/custom-type-C0Am_FkE.mjs +0 -12
- package/dist/custom-type-C0Am_FkE.mjs.map +0 -1
- package/dist/index-DH4qiCqU.d.mts.map +0 -1
- package/dist/src-9T0BuJCO.mjs.map +0 -1
- package/dist/types-DtX5fIbn.d.mts.map +0 -1
- package/dist/types-p2E6CrKO.d.mts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { d as TypedColumnRefs, t as ColumnBuilder, v as IndexSnapshot, x as RoleSnapshot, y as PolicySnapshot } from "./types-
|
|
2
|
+
import { d as TypedColumnRefs, t as ColumnBuilder, v as IndexSnapshot, x as RoleSnapshot, y as PolicySnapshot } from "./types-CBoxFMRg.mjs";
|
|
3
3
|
//#region src/dsl/rls.d.ts
|
|
4
4
|
/** A database role, for `policy().to(...)` — created by migrations unless `.existing()`. */
|
|
5
5
|
declare class RoleDecl {
|
|
@@ -218,4 +218,4 @@ declare function buildTable<TName extends string, C extends Record<string, Colum
|
|
|
218
218
|
declare function unwrapTable(value: unknown): TableDecl | undefined;
|
|
219
219
|
//#endregion
|
|
220
220
|
export { PolicyDecl as _, qualifiedTableName as a, pgRole as b, CheckDecl as c, PrimaryKeyDecl as d, TableConstraint as f, unique as g, primaryKey as h, buildTable as i, IndexDecl as l, index as m, TableDecl as n, table as o, check as p, TableOptions as r, unwrapTable as s, QualifiedName as t, IndexKey as u, RoleDecl as v, policy as x, isRole as y };
|
|
221
|
-
//# sourceMappingURL=table-
|
|
221
|
+
//# sourceMappingURL=table-xb127l8S.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-
|
|
1
|
+
{"version":3,"file":"table-xb127l8S.d.mts","names":[],"sources":["../src/dsl/rls.ts","../src/dsl/constraints.ts","../src/dsl/table.ts"],"mappings":";;;;cAGa;WACF;WACA,QAAQ;;EAEjB;EAEA,YAAY,cAAc,UAAS,KAAK;;EAKxC;;;;;;;;;;;iBAec,OAAO,cAAc,UAAS,KAAK,wBAA6B;iBAIhE,OAAO,iBAAiB,SAAS;KAI5C,UAAU;;cAGF;WACF;WACA,UAAU;EAEnB,YAAY;;EAKZ,IAAI,SAAS;;EAMb,MAAM,OAAO,eAAe;;;;;EAS5B,GAAG;;EAMH,MAAM;;EAMN,UAAU;;;;;;;;;;;;;;;;;iBAqBI,OAAO,eAAe;;;UC9F5B;EACR;;;KAIU,WAAW;;;;;;;;;;cAeV;;WAEF,SAAS;EAElB,YAAY,cAAc,MAAM,YAAY;;EAK5C,MAAM;;EAMN,MAAM;;EAMN,WAAW,MAAM;;EAMjB,GAAG,KAAK,UAAU;;;;;;EAclB;;iBAMc,MAAM;EAElB,MAAE,MAAU,aAAa;;iBAMb,OAAO;EAEnB,MAAE,MAAU,aAAa;;;UAOZ;EACf;;EAEA;EACA;;;UAIe;EACf;EACA;;EAEA;;;KAIU,kBAAkB,YAAY,iBAAiB,YAAY;;;;;;;;;;iBAWvD,WAAW;EAEvB,MAAE,MAAU,WAAW;;;;;;iBAYX,MAAM,cAAc,qBAAqB;;;UCxHxC,UACf,+BACA,UAAU,eAAe,iBAAiB,eAAe,gBACzD;EAEA;EACA,QAAQ;EACR,WAAW;EACX,WAAW;;EAEX,eAAe;EACf,WAAW;;EAEX;;EAEA;IAAU;;EACV,aAAa;;;;;;;;;EASb,WAAW;;;;;WAKF,UAAU,SAAS;;;;;;;;;;KAWlB,cACV,sBACA,sCACE,4BAA4B,WAAW,UAAU;;iBAGrC,mBAAmB;EACjC;EACA;;KAKG,UACH,sBACA,UAAU,eAAe,gBACzB,kDACE,UAAU,OAAO,GAAG,WAAW,gBAAgB;KAE9C,kBAAkB,UAAU,eAAe,mBAC9C,MAAM,gBAAgB,OACnB,eAAe;;;;;KAMR,aAAa,UAAU,eAAe,kBAC9C,kBAAkB;EAEhB,cAAc,kBAAkB;EAChC;;;;;;;EAOA;IAAkB;;;;;;;;;iBASR,MAAM,sBAAsB,UAAU,eAAe,gBACnE,MAAM,OACN,SAAS,GACT,UAAU,aAAa,KACtB,UAAU,OAAO;;;;;iBAQJ,WACd,sBACA,UAAU,eAAe,gBACzB,oCAEA,MAAM,OACN,UAAU,GACV,SAAS,aAAa,gBACtB,QAAQ,UACP,UAAU,OAAO,GAAG;;;;;;;iBA6EP,YAAY,iBAAiB"}
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import { t as SchemaToTypes } from "./schema-types-
|
|
2
|
+
import { r as KickDbClient, s as QueryEvent } from "./types-BosmVkt_.mjs";
|
|
3
|
+
import { t as SchemaToTypes } from "./schema-types-BMUMDpUC.mjs";
|
|
4
4
|
//#region src/testing.d.ts
|
|
5
5
|
export interface TestDbOptions<S> {
|
|
6
6
|
schema: S;
|
package/dist/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-db v8.
|
|
2
|
+
* @forinda/kickjs-db v8.9.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{D as emitPg,
|
|
11
|
+
import{D as emitPg,J as diff,R as EVENTS_ENABLED,Z as extractSnapshot,d as migrateLatest,t as createDbClient,y as emitSqlite}from"./create-vlNsemtQ.mjs";import{randomBytes}from"node:crypto";async function createTestDb(opts){let{default:Database}=await import(`better-sqlite3`),{sqliteAdapter,sqliteDialect}=await import(`./sqlite.mjs`),database=new Database(`:memory:`);if(database.pragma(`foreign_keys = ON`),opts.migrationsDir)await migrateLatest({adapter:sqliteAdapter({database}),migrationsDir:opts.migrationsDir,requireReviewed:!1,driftCheck:`ignore`});else{let empty={version:1,dialect:`sqlite`,tables:{}},target=extractSnapshot(opts.schema,`sqlite`,{casing:opts.casing});database.exec(emitSqlite(diff(empty,target),{from:empty,to:target}))}return createDbClient({schema:opts.schema,dialect:sqliteDialect({database}),casing:opts.casing,events:!0})}async function createPgTestDb(opts){let{default:pg}=await import(`pg`),{pgAdapter,pgDialect}=await import(`./pg.mjs`),name=`kick_test_${randomBytes(6).toString(`hex`)}`,admin=new pg.Client({connectionString:opts.connectionString});await admin.connect();try{await admin.query(`CREATE DATABASE "${name}"`)}finally{await admin.end()}let url=new URL(opts.connectionString);url.pathname=`/${name}`;let connectionString=url.toString(),pool=new pg.Pool({connectionString});pool.on(`error`,()=>{}),pool.on(`connect`,client=>client.on(`error`,()=>{})),opts.migrationsDir?await migrateLatest({adapter:pgAdapter({pool}),migrationsDir:opts.migrationsDir,requireReviewed:!1,driftCheck:`ignore`}):await pool.query(emitPg(diff({version:1,dialect:`postgres`,tables:{}},extractSnapshot(opts.schema,`postgres`,{casing:opts.casing}))));let db=createDbClient({schema:opts.schema,dialect:pgDialect({pool}),casing:opts.casing,events:!0});return{db,connectionString,async drop(){await db.destroy();let admin=new pg.Client({connectionString:opts.connectionString});await admin.connect();try{await admin.query(`DROP DATABASE IF EXISTS "${name}" WITH (FORCE)`)}finally{await admin.end()}}}}const ROLLBACK=Symbol(`kickjs-db rolled back`);async function rolledBack(db,fn){let result;return await db.transaction(async()=>{throw result=await fn(),ROLLBACK}).catch(err=>{if(err!==ROLLBACK)throw err}),result}async function captureQueries(db,fn){if(db[EVENTS_ENABLED]===!1)throw Error("captureQueries: this client was created without events, so no query is reported and every count would be 0. Create it with `events: true`.");let queries=[],listener=event=>void queries.push(event);db.on(`query`,listener);try{return{result:await fn(),queries}}finally{db.off(`query`,listener)}}async function expectQueries(db,count,fn){let{result,queries}=await captureQueries(db,fn);if(queries.length!==count){let list=queries.map((q,i)=>` ${i+1}. ${q.sql}`).join(`
|
|
12
12
|
`);throw Error(`Expected ${count} quer${count===1?`y`:`ies`}, ran ${queries.length}:\n${list||` (none)`}`)}return result}export{captureQueries,createPgTestDb,createTestDb,expectQueries,rolledBack};
|
|
13
13
|
//# sourceMappingURL=testing.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { l as NotNullBrand, o as GeneratedBrand, t as ColumnBuilder } from "./types-
|
|
2
|
+
import { l as NotNullBrand, o as GeneratedBrand, t as ColumnBuilder } from "./types-CBoxFMRg.mjs";
|
|
3
3
|
import { CommonTableExpression, Dialect, Expression, ExpressionBuilder, Insertable, Kysely, KyselyPlugin, SelectQueryBuilder, SelectType, Selectable, SqlBool, UpdateObject } from "kysely";
|
|
4
4
|
//#region src/client/insert-many.d.ts
|
|
5
5
|
interface InsertManyOptions {
|
|
@@ -33,8 +33,10 @@ interface UpsertOptions<DB, T extends keyof DB & string> extends InsertManyOptio
|
|
|
33
33
|
* What to update on a conflict: column names take the incoming row's value
|
|
34
34
|
* (the default is every inserted column outside `target`); an object sets
|
|
35
35
|
* values or expressions — ``{ views: sql`page_views.views + 1` }``.
|
|
36
|
+
* `false` leaves a conflicting row as it is (`ON CONFLICT DO NOTHING`) and
|
|
37
|
+
* returns it as stored.
|
|
36
38
|
*/
|
|
37
|
-
update?: ReadonlyArray<keyof DB[T] & string> | UpdateObject<DB, T
|
|
39
|
+
update?: ReadonlyArray<keyof DB[T] & string> | UpdateObject<DB, T> | false;
|
|
38
40
|
/**
|
|
39
41
|
* The predicate of a partial unique index `target` refers to (Postgres,
|
|
40
42
|
* SQLite). Write it as the index does, with literals — ``() => sql`active = 1` ``:
|
|
@@ -321,6 +323,12 @@ interface RelationMapEntry {
|
|
|
321
323
|
kind: 'one' | 'many';
|
|
322
324
|
target: string;
|
|
323
325
|
relationName?: string;
|
|
326
|
+
/**
|
|
327
|
+
* A `morphTo`: `target` is the union of its tables. The typegen records each
|
|
328
|
+
* type value's table (`{ post: 'posts', podcast: 'podcasts' }`), which types
|
|
329
|
+
* the subject's `__type`; a hand-written `true` types it as `string`.
|
|
330
|
+
*/
|
|
331
|
+
morphTo?: true | Record<string, string>;
|
|
324
332
|
}
|
|
325
333
|
/**
|
|
326
334
|
* The full registered relation graph. Falls back to an open-shaped
|
|
@@ -391,9 +399,10 @@ interface FindManyOptions<DB = RegisteredDB, Table extends keyof DB & string = k
|
|
|
391
399
|
with?: WithClause<DB, TableRelations<Table>>;
|
|
392
400
|
/**
|
|
393
401
|
* Cancellation handle. When the signal aborts, the in-flight
|
|
394
|
-
* query is cancelled
|
|
395
|
-
*
|
|
396
|
-
* rejects with
|
|
402
|
+
* query is cancelled on the server (Postgres `pg_cancel_backend`,
|
|
403
|
+
* MySQL `KILL QUERY`; better-sqlite3 runs synchronously, so there is
|
|
404
|
+
* nothing in flight) and the promise rejects with
|
|
405
|
+
* `RelationalQueryCancelledError`.
|
|
397
406
|
*
|
|
398
407
|
* Bind to `RequestContext.signal` from kickjs-http to short-circuit
|
|
399
408
|
* the query when the client disconnects or the request times out.
|
|
@@ -403,6 +412,12 @@ interface FindManyOptions<DB = RegisteredDB, Table extends keyof DB & string = k
|
|
|
403
412
|
* nested LATERAL/correlated subqueries inherit the parent signal.
|
|
404
413
|
*/
|
|
405
414
|
signal?: AbortSignal;
|
|
415
|
+
/**
|
|
416
|
+
* Cancel the read on the server once it has run this long, and reject with
|
|
417
|
+
* `RelationalQueryCancelledError` (whose `cause` is a `TimeoutError`).
|
|
418
|
+
* Combines with `signal`: whichever fires first.
|
|
419
|
+
*/
|
|
420
|
+
timeoutMs?: number;
|
|
406
421
|
}
|
|
407
422
|
/**
|
|
408
423
|
* Per-relation shape inside `with`. `true` for boolean shorthand;
|
|
@@ -410,7 +425,27 @@ interface FindManyOptions<DB = RegisteredDB, Table extends keyof DB & string = k
|
|
|
410
425
|
* whose `target` is also a key of the local `DB` are accepted —
|
|
411
426
|
* cross-DB relations are unrepresentable at the call site.
|
|
412
427
|
*/
|
|
413
|
-
type WithClause<DB, Rels extends Record<string, RelationMapEntry>> = { [K in keyof Rels]?: Rels[K]['target'] extends keyof DB & string ? true |
|
|
428
|
+
type WithClause<DB, Rels extends Record<string, RelationMapEntry>> = { [K in keyof Rels]?: Rels[K]['target'] extends keyof DB & string ? true | WithOptions<DB, Rels[K], Rels[K]['target']> : never; };
|
|
429
|
+
/**
|
|
430
|
+
* A `morphTo`'s rows come from several tables, so only `withDeleted`
|
|
431
|
+
* applies. `never` (an untyped client) would match the check, so it keeps
|
|
432
|
+
* the full options.
|
|
433
|
+
*/
|
|
434
|
+
type WithOptions<DB, E, Target extends keyof DB & string> = [E] extends [never] ? NestedOptions<DB, Target> : E extends {
|
|
435
|
+
morphTo: infer M;
|
|
436
|
+
} ? M extends Record<string, string> ? MorphToOptions<DB, M> : {
|
|
437
|
+
withDeleted?: boolean;
|
|
438
|
+
} : NestedOptions<DB, Target>;
|
|
439
|
+
/**
|
|
440
|
+
* A `morphTo` level: `withDeleted` for every target, and each target's own
|
|
441
|
+
* options under its type value — one row each, so no order, limit or offset.
|
|
442
|
+
*/
|
|
443
|
+
type MorphToOptions<DB, M extends Record<string, string>> = {
|
|
444
|
+
withDeleted?: boolean;
|
|
445
|
+
targets?: { [V in keyof M & string]?: M[V] extends keyof DB & string ? true | Omit<NestedOptions<DB, M[V]>, 'orderBy' | 'limit' | 'offset'> : never; };
|
|
446
|
+
};
|
|
447
|
+
/** A nested level runs inside its parent's query: cancelling and the depth limit are the parent's. */
|
|
448
|
+
type NestedOptions<DB, Target extends keyof DB & string> = Omit<FindManyOptions<DB, Target>, 'signal' | 'timeoutMs' | 'maxDepth'>;
|
|
414
449
|
/**
|
|
415
450
|
* Resolved row shape returned by `findMany`. Base table columns
|
|
416
451
|
* intersected with the per-relation slot map produced by `with`.
|
|
@@ -438,7 +473,24 @@ type WithSlots<DB, Table extends keyof DB & string, W> = W extends Record<string
|
|
|
438
473
|
* Resolve one slot. `one` returns `Related | null`; `many` returns
|
|
439
474
|
* `Related[]`. Nested options recurse through `FindManyRow`.
|
|
440
475
|
*/
|
|
441
|
-
type ResolveRelationSlot<DB, R extends RelationMapEntry, V> = R['target'] extends keyof DB & string ?
|
|
476
|
+
type ResolveRelationSlot<DB, R extends RelationMapEntry, V> = R['target'] extends keyof DB & string ? R extends {
|
|
477
|
+
morphTo: infer M;
|
|
478
|
+
} ? M extends Record<string, string> ? MorphToSubject<DB, M, V> | null : (DB[R['target']] & {
|
|
479
|
+
__type: string;
|
|
480
|
+
}) | null : V extends true ? R['kind'] extends 'one' ? DB[R['target']] | null : DB[R['target']][] : V extends FindManyOptions<DB, R['target']> ? R['kind'] extends 'one' ? FindManyRow<DB, R['target'], V> | null : FindManyRow<DB, R['target'], V>[] : never : never;
|
|
481
|
+
/**
|
|
482
|
+
* A `morphTo` subject: its table's row, tagged with the type value it was
|
|
483
|
+
* found by — `subject.__type === 'post'` narrows it to a post.
|
|
484
|
+
*/
|
|
485
|
+
type MorphToSubject<DB, M, W> = M extends Record<string, string> ? { [V in keyof M & string]: M[V] extends keyof DB & string ? TargetRow<DB, M[V], TargetOptions<W, V>> & {
|
|
486
|
+
__type: V;
|
|
487
|
+
} : never; }[keyof M & string] : never;
|
|
488
|
+
/** A target's own options from `with: { subject: { targets: { <type>: … } } }`, or `true`. */
|
|
489
|
+
type TargetOptions<W, V extends string> = W extends {
|
|
490
|
+
targets?: infer T;
|
|
491
|
+
} ? V extends keyof T ? T[V] : true : true;
|
|
492
|
+
/** A target's row: the plain row, or shaped by its options. */
|
|
493
|
+
type TargetRow<DB, Table extends keyof DB & string, O> = [O] extends [true | undefined] ? DB[Table] : O extends FindManyOptions<DB, Table> ? FindManyRow<DB, Table, O> : DB[Table];
|
|
442
494
|
/**
|
|
443
495
|
* Per-table query namespace exposed as `db.query.X`. v1 ships read
|
|
444
496
|
* methods only — writes route through layers 1 + 2 (`selectFrom`,
|
|
@@ -471,16 +523,26 @@ interface QueryEvent {
|
|
|
471
523
|
sql: string;
|
|
472
524
|
parameters: readonly unknown[];
|
|
473
525
|
durationMs: number;
|
|
526
|
+
/** Kysely's id for this query: pairs `beforeQuery`, `query` and `queryError`. */
|
|
527
|
+
queryId?: string;
|
|
528
|
+
/** The transaction it ran in, when it ran in one (a savepoint shares its transaction's). */
|
|
529
|
+
txId?: string;
|
|
474
530
|
}
|
|
475
531
|
interface QueryErrorEvent {
|
|
476
532
|
sql: string;
|
|
477
533
|
parameters: readonly unknown[];
|
|
478
534
|
error: unknown;
|
|
535
|
+
/** Kysely's id for this query: pairs `beforeQuery`, `query` and `queryError`. */
|
|
536
|
+
queryId?: string;
|
|
537
|
+
/** The transaction it ran in, when it ran in one (a savepoint shares its transaction's). */
|
|
538
|
+
txId?: string;
|
|
479
539
|
}
|
|
480
540
|
interface BeforeQueryEvent {
|
|
481
541
|
/** Mutable — listeners may rewrite sql / parameters before execution. */
|
|
482
542
|
sql: string;
|
|
483
543
|
parameters: unknown[];
|
|
544
|
+
/** Kysely's id for this query, as `query` / `queryError` report it. Absent for statements kick/db sends itself. */
|
|
545
|
+
readonly queryId?: string;
|
|
484
546
|
}
|
|
485
547
|
interface TransactionEvent {
|
|
486
548
|
isolation?: 'serializable' | 'repeatable read' | 'read committed' | 'read uncommitted';
|
|
@@ -497,6 +559,12 @@ interface TransactionRetryEvent extends TransactionEvent {
|
|
|
497
559
|
delayMs: number;
|
|
498
560
|
}
|
|
499
561
|
/** Options for `transaction(opts, fn)`. */
|
|
562
|
+
/** A transaction from `startTransaction()`: a client, and the way to finish it. */
|
|
563
|
+
type ManualTransaction<DB> = KickDbClient<DB> & {
|
|
564
|
+
/** Commit, then run its `afterCommit` hooks. */
|
|
565
|
+
commit(): Promise<void>;
|
|
566
|
+
rollback(): Promise<void>;
|
|
567
|
+
};
|
|
500
568
|
interface TransactionOptions extends TransactionEvent {
|
|
501
569
|
/**
|
|
502
570
|
* What to do when a transaction is already open on this call chain:
|
|
@@ -632,6 +700,22 @@ interface KickDbClient<DB = RegisteredDB> {
|
|
|
632
700
|
readonly query: QueryNamespace<DB>;
|
|
633
701
|
on<E extends keyof KickDbClientEvents>(event: E, listener: (e: KickDbClientEvents[E]) => void | Promise<void>): this;
|
|
634
702
|
off<E extends keyof KickDbClientEvents>(event: E, listener: (e: KickDbClientEvents[E]) => void | Promise<void>): this;
|
|
703
|
+
/**
|
|
704
|
+
* Execute options that cancel a query on the server once it has run `ms`
|
|
705
|
+
* (Postgres `pg_cancel_backend`, MySQL `KILL QUERY`), or when `signal`
|
|
706
|
+
* aborts first. The query rejects with the signal's reason — a
|
|
707
|
+
* `DOMException` named `TimeoutError` for the timeout. Inside a
|
|
708
|
+
* transaction the query is abandoned, not cancelled: a cancel would abort
|
|
709
|
+
* the transaction.
|
|
710
|
+
*
|
|
711
|
+
* await db.selectFrom('reports').selectAll().execute(db.timeout(5_000))
|
|
712
|
+
*/
|
|
713
|
+
timeout(ms: number, opts?: {
|
|
714
|
+
signal?: AbortSignal;
|
|
715
|
+
}): {
|
|
716
|
+
signal: AbortSignal;
|
|
717
|
+
inflightQueryAbortStrategy: 'cancel query' | 'ignore query';
|
|
718
|
+
};
|
|
635
719
|
/**
|
|
636
720
|
* Insert, or update the rows whose `target` key already exists — one
|
|
637
721
|
* statement (`ON CONFLICT … DO UPDATE` / `ON DUPLICATE KEY UPDATE`), or
|
|
@@ -661,6 +745,11 @@ interface KickDbClient<DB = RegisteredDB> {
|
|
|
661
745
|
}): Promise<number>;
|
|
662
746
|
insertMany<T extends keyof DB & string>(table: T, rows: ReadonlyArray<Insertable<DB[T]>>, options: InsertManyOptions & {
|
|
663
747
|
returning: true;
|
|
748
|
+
/**
|
|
749
|
+
* MySQL, which has no RETURNING: a unique key every row gives, to read
|
|
750
|
+
* the inserted rows back by. Required there; ignored elsewhere.
|
|
751
|
+
*/
|
|
752
|
+
readBack?: ReadonlyArray<keyof DB[T] & string>;
|
|
664
753
|
}): Promise<Selectable<DB[T]>[]>;
|
|
665
754
|
/**
|
|
666
755
|
* The row matching `where`, or a new one from `where` + `create`;
|
|
@@ -692,6 +781,18 @@ interface KickDbClient<DB = RegisteredDB> {
|
|
|
692
781
|
* stays committed.
|
|
693
782
|
*/
|
|
694
783
|
afterCommit(fn: () => unknown): Promise<void>;
|
|
784
|
+
/**
|
|
785
|
+
* Open a transaction you finish yourself — for a test that rolls back what
|
|
786
|
+
* it wrote, or a transaction handed across layers:
|
|
787
|
+
*
|
|
788
|
+
* const tx = await db.startTransaction()
|
|
789
|
+
* try { await tx.insertInto('orders').values(o).execute(); await tx.commit() }
|
|
790
|
+
* catch (err) { await tx.rollback(); throw err }
|
|
791
|
+
*
|
|
792
|
+
* Prefer `transaction(fn)`, which can't leave one open. Takes its options
|
|
793
|
+
* but `retry`; its query events carry no `txId`.
|
|
794
|
+
*/
|
|
795
|
+
startTransaction(opts?: Omit<TransactionOptions, 'retry'>): Promise<ManualTransaction<DB>>;
|
|
695
796
|
/** Whether this call chain is inside a transaction. */
|
|
696
797
|
readonly inTransaction: boolean;
|
|
697
798
|
/**
|
|
@@ -776,6 +877,13 @@ interface CreateDbClientOptions<TSchema, _DB = unknown> {
|
|
|
776
877
|
* surface is attached.
|
|
777
878
|
*/
|
|
778
879
|
slowQueryThresholdMs?: number | null;
|
|
880
|
+
/**
|
|
881
|
+
* Add where each query was built to its error's stack — the line that
|
|
882
|
+
* called `.execute()` or `findMany()`, which a driver error otherwise
|
|
883
|
+
* loses across the await. Records a stack per query, so it's for
|
|
884
|
+
* development. Default `false`.
|
|
885
|
+
*/
|
|
886
|
+
asyncStackTraces?: boolean;
|
|
779
887
|
/**
|
|
780
888
|
* Optional KickEventBus instance the client republishes lifecycle
|
|
781
889
|
* events to. When set, the bus receives:
|
|
@@ -846,5 +954,5 @@ interface CreateDbClientOptions<TSchema, _DB = unknown> {
|
|
|
846
954
|
casing?: 'snake_case';
|
|
847
955
|
}
|
|
848
956
|
//#endregion
|
|
849
|
-
export {
|
|
850
|
-
//# sourceMappingURL=types-
|
|
957
|
+
export { TenancyStrategy as A, WithClause as C, BypassOptions as D, BypassInfo as E, ExtensionDefinition as F, ModelExtensions as I, FindOrCreateOptions as L, defineTenancy as M, tenantKey as N, Tenancy as O, ExtendedClient as P, UpsertOptions as R, TableRelations as S, RegisteredDB as T, KickDbRelationsRegister as _, ManualTransaction as a, RelationMapEntry as b, ReadRoute as c, TransactionEvent as d, TransactionOptions as f, FindManyRow as g, FindManyOptions as h, KickDbClientEvents as i, TenantRequiredError as j, TenancyOptions as k, ReadRouter as l, TransactionRollbackEvent as m, CreateDbClientOptions as n, QueryErrorEvent as o, TransactionRetryEvent as p, KickDbClient as r, QueryEvent as s, BeforeQueryEvent as t, SlowQueryEvent as u, QueryNamespace as v, KickDbRegister as w, TableQueryNamespace as x, RegisteredRelations as y, InsertManyOptions as z };
|
|
958
|
+
//# sourceMappingURL=types-BosmVkt_.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BosmVkt_.d.mts","names":["_$__upsert0.UpsertOptions","_$__insert_many0.InsertManyOptions","_$__upsert0.FindOrCreateOptions","_$___extend_types0.ExtensionDefinition","_$___extend_types0.ExtendedClient","KyselyDialect","_$___tenancy0.Tenancy"],"sources":["../src/client/insert-many.ts","../src/client/upsert.ts","../src/extend/types.ts","../src/tenancy.ts","../src/client/register.ts","../src/query/types.ts","../src/client/types.ts"],"mappings":";;;;UAiBiB;;;;;EAKf;;;;;;EAMA;;;;UCTe,cAAc,IAAI,gBA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AW,gBAAgB,aACzB,OAAO,GACP,MAAM,cAAc,WAAW,GAAG,MAClC,SADMA;IAEJ;;;;;IAKA,WAAW,oBAAoB,GAAG;MAEnC,QAAQ,WAAW,GAAG;;;;;;;EAQzB,aAAa,gBAAgB,aAAa,UAAU,QAAQ,WAAW,GAAG,MACxE,OAAO,GACP,MAAoDC,oBAAP,IAAI,GAAG,KACnD;IAAU,KAAK,WAAW,GAAG;IAAK;;;;;;;EAOrC,wBACE,YAAY,aACZ;IAAY;MACX;EAEH,YAAY,GAAG,KAAK,IAAI,aAAa,QAAQ,QAAQ,KAAK,QAAQ;EAClE,YAAY,GAAG,MAAM,oBAAoB,KAAK,IAAI,aAAa,QAAQ,QAAQ,KAAK,QAAQ;EAE5F,UAAU,GAAG,KAAK,IAAI,aAAa,QAAQ,QAAQ,KAAK,QAAQ;;;;;;;;;EAUhE,YAAY,oBAAoB;;;;;;;;;;;;EAahC,iBAAiB,OAAO,KAAK,+BAA+B,QAAQ,kBAAkB;;WAG7E;;;;;WAMA,SAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;EAyB/B,SAAS,UAAwDC,oBAAA,KAC/D,KAAK,IACyCC,eAAJ,IAAI;EAEhD,WAAW;;UAGI,sBAAsB,SAAS;;EAE9C,QAAQ;;;;;EAKR,SAASC;;;;;;EAMT;;;;;EAKA,UAXSC;;;;;;;EAkBT,UAAUD,mBAAyBA;;;;;;;;;;;EAWnC,QAAQ;;;;;;;EAOR;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BA,iDAAiD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCjD,UAAU;;;;;;EAMV"}
|
|
@@ -7,6 +7,8 @@ interface ColumnSnapshot {
|
|
|
7
7
|
type: string;
|
|
8
8
|
nullable: boolean;
|
|
9
9
|
default: string | null;
|
|
10
|
+
/** `default` is SQL to evaluate (`.defaultSql()`), not a value. Absent means a value. */
|
|
11
|
+
defaultSql?: true;
|
|
10
12
|
primaryKey: boolean;
|
|
11
13
|
/** A column the database computes from others: `GENERATED ALWAYS AS (expression)`. */
|
|
12
14
|
generated?: {
|
|
@@ -131,6 +133,27 @@ interface RelationSnapshot {
|
|
|
131
133
|
sourceColumns: readonly string[];
|
|
132
134
|
targetColumns: readonly string[];
|
|
133
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* For a `morphMany` / `morphOne`: the target's type column and the value it must hold
|
|
138
|
+
* (bound as a parameter). There's no foreign key behind the join.
|
|
139
|
+
*/
|
|
140
|
+
morph?: {
|
|
141
|
+
column: string;
|
|
142
|
+
value: string;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* For a `morphTo`: the source's type column, and per type value the table
|
|
146
|
+
* and key column the source's id column (`sourceColumns[0]`) points at.
|
|
147
|
+
* `target` holds the first of those tables.
|
|
148
|
+
*/
|
|
149
|
+
morphTo?: {
|
|
150
|
+
column: string;
|
|
151
|
+
targets: ReadonlyArray<{
|
|
152
|
+
value: string;
|
|
153
|
+
table: string;
|
|
154
|
+
key: string;
|
|
155
|
+
}>;
|
|
156
|
+
};
|
|
134
157
|
}
|
|
135
158
|
/** A row-level security policy (Postgres). */
|
|
136
159
|
interface PolicySnapshot {
|
|
@@ -265,6 +288,8 @@ interface ColumnState {
|
|
|
265
288
|
type: string;
|
|
266
289
|
nullable: boolean;
|
|
267
290
|
default: string | null;
|
|
291
|
+
/** `default` is SQL to evaluate (`.defaultSql()`), not a value. */
|
|
292
|
+
defaultSql?: boolean;
|
|
268
293
|
primaryKey: boolean;
|
|
269
294
|
unique: boolean;
|
|
270
295
|
references: FkSpec | null;
|
|
@@ -382,6 +407,14 @@ declare class ColumnBuilder<T = unknown> {
|
|
|
382
407
|
* itself (`'active'`); booleans/numbers emit bare (`false`, `0`).
|
|
383
408
|
*/
|
|
384
409
|
default(value: string | number | boolean): this & GeneratedBrand;
|
|
410
|
+
/**
|
|
411
|
+
* A default that is SQL, evaluated by the database for each new row —
|
|
412
|
+
* `id: text().primaryKey().defaultSql('gen_random_uuid()::text')`,
|
|
413
|
+
* `slug: text().defaultSql("lower(hex(randomblob(8)))")`. `.default()` is a
|
|
414
|
+
* value: on a text column `.default('now()')` stores the string `now()`.
|
|
415
|
+
* Written as given, so it's your dialect's SQL.
|
|
416
|
+
*/
|
|
417
|
+
defaultSql(expression: string): this & GeneratedBrand;
|
|
385
418
|
/**
|
|
386
419
|
* A default computed in JS for each inserted row that doesn't set this
|
|
387
420
|
* column — an id generator, a slug, a value from config:
|
|
@@ -441,4 +474,4 @@ declare class ColumnBuilder<T = unknown> {
|
|
|
441
474
|
}
|
|
442
475
|
//#endregion
|
|
443
476
|
export { TableSnapshot as C, SchemaSnapshot as S, ForeignKeySnapshot as _, GeneratedAlwaysBrand as a, RelationSnapshot as b, KICK_NOT_NULL as c, TypedColumnRefs as d, CheckSnapshot as f, FkAction as g, EnumSnapshot as h, FkSpec as i, NotNullBrand as l, Dialect as m, ColumnRef as n, GeneratedBrand as o, ColumnSnapshot as p, ColumnState as r, KICK_GENERATED as s, ColumnBuilder as t, TypedColumnRef as u, IndexSnapshot as v, ViewSnapshot as w, RoleSnapshot as x, PolicySnapshot as y };
|
|
444
|
-
//# sourceMappingURL=types-
|
|
477
|
+
//# sourceMappingURL=types-CBoxFMRg.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CBoxFMRg.d.mts","names":[],"sources":["../src/snapshot/types.ts","../src/dsl/columns/types.ts"],"mappings":";;KAAY;KAEA;UAEK;EACf;EACA;EACA;EACA;;EAEA;EACA;;EAEA;IAAc;IAAoB;;;EAElC;;EAEA;;;;;EAKA;;UAGe;EACf;;EAEA;EACA;;EAEA;;EAEA;;EAEA;;EAEA,YAAY;;EAEZ;;UAGe;EACf;EACA;EACA;EACA;EACA,UAAU;EACV,UAAU;;UAGK;EACf;EACA;;UAGe;;;;;;EAMf;;;;;;EAMA;EACA,SAAS,eAAe;EACxB,SAAS;EACT,a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AAc,WAAU,QAAQ;EAY5C,kBAAkB;EAKlB,qBAAqB;EAMrB;EAKA,SAAS,qBAAqB,cAAc;EAK5C,WACE,cAAc,WACd;IAAQ,WAAW;IAAU,WAAW;IAAU;;;;;;;;;;;;;;EA4BpD,QAAQ,0CAA0C;;;;;;;;EAalD,WAAW,4BAA4B;;;;;;;EAYvC,WAAW,UAAU,WAAW;;;;;;EAUhC,UAAU,UAAU;;;;;EASpB;;;;;;EAUA;;;;;;;;EAYA,kBACE,oBACA;IAAW;aACH;;;;;EASV,oCAAoC,eAAe;;EAOnD,uCAAuC,eAAe;;;;;EAUtD,QAAQ;;;;;;EAUR,QAAQ;;EAMR,aAAa;EAIb,OAAO,eAAe;EAgBtB,WAAW,SAAS"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forinda/kickjs-db",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.0",
|
|
4
4
|
"description": "KickJS-native ORM — code-first schema, reversible migrations, multi-dialect SQL builder",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kickjs",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"pg": "^8.23.1",
|
|
105
105
|
"pg-cursor": "^2.22.1",
|
|
106
106
|
"typescript": "^7.0.2",
|
|
107
|
-
"@forinda/kickjs": "10.
|
|
107
|
+
"@forinda/kickjs": "10.5.0",
|
|
108
108
|
"@forinda/kickjs-devtools-kit": "7.3.0",
|
|
109
109
|
"@forinda/kickjs-schema": "0.2.4"
|
|
110
110
|
},
|