@forinda/kickjs-db 7.3.0 → 7.4.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 +10 -10
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +3 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/custom-type-j8k__3sL.mjs +12 -0
- package/dist/custom-type-j8k__3sL.mjs.map +1 -0
- package/dist/devtools-events.d.mts +2 -1
- package/dist/devtools-events.mjs +1 -1
- package/dist/{index-BJipaUa3.d.mts → index-DF69HndC.d.mts} +13 -325
- package/dist/index-DF69HndC.d.mts.map +1 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +2 -2
- package/dist/mysql.d.mts +11 -12
- package/dist/mysql.d.mts.map +1 -1
- package/dist/mysql.mjs +2 -2
- package/dist/mysql.mjs.map +1 -1
- package/dist/pg-BJmYKLhI.mjs +12 -0
- package/dist/pg-BJmYKLhI.mjs.map +1 -0
- package/dist/pg.d.mts +21 -21
- package/dist/pg.d.mts.map +1 -1
- package/dist/pg.mjs +2 -2
- package/dist/pg.mjs.map +1 -1
- package/dist/schema.d.mts +88 -0
- package/dist/schema.d.mts.map +1 -0
- package/dist/schema.mjs +12 -0
- package/dist/schema.mjs.map +1 -0
- package/dist/sqlite.d.mts +7 -8
- package/dist/sqlite.d.mts.map +1 -1
- package/dist/sqlite.mjs +2 -2
- package/dist/{src-DVdBmsLe.mjs → src-BnHTLx5l.mjs} +9 -9
- package/dist/src-BnHTLx5l.mjs.map +1 -0
- package/dist/table-Bl5SbKRg.d.mts +309 -0
- package/dist/table-Bl5SbKRg.d.mts.map +1 -0
- package/dist/{types-NkfgZHEN.d.mts → types-DtvYnaXL.d.mts} +3 -4
- package/dist/types-DtvYnaXL.d.mts.map +1 -0
- package/package.json +12 -7
- package/dist/index-BJipaUa3.d.mts.map +0 -1
- package/dist/src-DVdBmsLe.mjs.map +0 -1
- package/dist/types-NkfgZHEN.d.mts.map +0 -1
|
@@ -1,118 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { C as IndexSnapshot, E as TableSnapshot, S as ForeignKeySnapshot, T as SchemaSnapshot, b as EnumSnapshot, g as NotNullBrand, l as ColumnBuilder, n as TableDecl, p as GeneratedBrand, u as ColumnRef, v as ColumnSnapshot, w as RelationSnapshot, y as Dialect$1 } from "./table-Bl5SbKRg.mjs";
|
|
3
|
+
import { h as RelationMapEntry, n as CreateDbClientOptions, r as KickDbClient } from "./types-DtvYnaXL.mjs";
|
|
3
4
|
import { InjectionToken } from "@forinda/kickjs";
|
|
4
5
|
import { Generated, KyselyPlugin } from "kysely";
|
|
5
6
|
import { ReadonlyKysely } from "kysely/readonly";
|
|
6
|
-
//#region src/snapshot/types.d.ts
|
|
7
|
-
type Dialect$1 = 'postgres' | 'sqlite' | 'mysql';
|
|
8
|
-
type FkAction = 'cascade' | 'restrict' | 'set_null' | 'set_default' | 'no_action';
|
|
9
|
-
interface ColumnSnapshot {
|
|
10
|
-
name: string;
|
|
11
|
-
type: string;
|
|
12
|
-
nullable: boolean;
|
|
13
|
-
default: string | null;
|
|
14
|
-
primaryKey: boolean;
|
|
15
|
-
}
|
|
16
|
-
interface IndexSnapshot {
|
|
17
|
-
name: string;
|
|
18
|
-
columns: string[];
|
|
19
|
-
unique: boolean;
|
|
20
|
-
}
|
|
21
|
-
interface ForeignKeySnapshot {
|
|
22
|
-
name: string;
|
|
23
|
-
columns: string[];
|
|
24
|
-
refTable: string;
|
|
25
|
-
refColumns: string[];
|
|
26
|
-
onDelete: FkAction;
|
|
27
|
-
onUpdate: FkAction;
|
|
28
|
-
}
|
|
29
|
-
interface CheckSnapshot {
|
|
30
|
-
name: string;
|
|
31
|
-
expression: string;
|
|
32
|
-
}
|
|
33
|
-
interface TableSnapshot {
|
|
34
|
-
/**
|
|
35
|
-
* Bare table name, unqualified. The schema (when any) lives in
|
|
36
|
-
* {@link TableSnapshot.schema}; the map key on `SchemaSnapshot.tables` is
|
|
37
|
-
* the qualified form (`billing.invoices`).
|
|
38
|
-
*/
|
|
39
|
-
name: string;
|
|
40
|
-
/**
|
|
41
|
-
* Named SQL schema, from `pgSchema('x').table(...)`. Absent for tables in
|
|
42
|
-
* the connection's default search_path, which keeps pre-schema snapshots
|
|
43
|
-
* byte-identical (and their migration hashes valid).
|
|
44
|
-
*/
|
|
45
|
-
schema?: string;
|
|
46
|
-
columns: Record<string, ColumnSnapshot>;
|
|
47
|
-
indexes: IndexSnapshot[];
|
|
48
|
-
foreignKeys: ForeignKeySnapshot[];
|
|
49
|
-
checks: CheckSnapshot[];
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* PostgreSQL ENUM type declaration. Currently PG-only; the field is
|
|
53
|
-
* optional on `SchemaSnapshot` so other dialects don't have to carry
|
|
54
|
-
* a phantom `enums: {}`.
|
|
55
|
-
*/
|
|
56
|
-
interface EnumSnapshot {
|
|
57
|
-
name: string;
|
|
58
|
-
/** Allowed values, in declaration order. PG preserves the order. */
|
|
59
|
-
values: readonly string[];
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Resolved relation graph attached as a sidecar on the snapshot.
|
|
63
|
-
* Lives on `SchemaSnapshot.relations` (optional). Keyed
|
|
64
|
-
* sourceTable → relationName → resolved entry. Consumed by the
|
|
65
|
-
* relational-query compiler in `packages/db/src/query/`. The
|
|
66
|
-
* migration pipeline does not read this field — relations are
|
|
67
|
-
* query-time sugar, not DDL.
|
|
68
|
-
*
|
|
69
|
-
* Shaped this way (rather than re-using the runtime `RelationsDecl`)
|
|
70
|
-
* so the snapshot stays JSON-serializable: no function thunks, no
|
|
71
|
-
* back-references to table objects.
|
|
72
|
-
*/
|
|
73
|
-
interface RelationSnapshot {
|
|
74
|
-
kind: 'one' | 'many';
|
|
75
|
-
/** Target table name. */
|
|
76
|
-
target: string;
|
|
77
|
-
/** Columns on the source table that participate in the join. */
|
|
78
|
-
sourceColumns: readonly string[];
|
|
79
|
-
/** Columns on the target table that participate in the join. */
|
|
80
|
-
targetColumns: readonly string[];
|
|
81
|
-
/**
|
|
82
|
-
* Optional pairing tag from `relationName: 'foo'` on both sides of
|
|
83
|
-
* the relation. Disambiguates multi-FK schemas. See
|
|
84
|
-
* docs/db/spec-relation-name.md (M4.B).
|
|
85
|
-
*/
|
|
86
|
-
relationName?: string;
|
|
87
|
-
}
|
|
88
|
-
interface SchemaSnapshot {
|
|
89
|
-
version: 1;
|
|
90
|
-
dialect: Dialect$1;
|
|
91
|
-
/**
|
|
92
|
-
* Keyed by QUALIFIED name — `billing.invoices` for a table declared through
|
|
93
|
-
* `pgSchema('billing')`, the bare name otherwise. Qualifying the key is what
|
|
94
|
-
* lets two schemas hold same-named tables without colliding, and it makes
|
|
95
|
-
* every `table: string` field on a diff `Change` already schema-correct:
|
|
96
|
-
* `quoteIdent` splits on `.`, rendering `"billing"."invoices"`.
|
|
97
|
-
*/
|
|
98
|
-
tables: Record<string, TableSnapshot>;
|
|
99
|
-
/**
|
|
100
|
-
* Named schemas the tables in this snapshot live in, sorted. Drives
|
|
101
|
-
* `CREATE SCHEMA IF NOT EXISTS` emission. PG-only; absent when no table
|
|
102
|
-
* declares a schema, so existing snapshots keep their exact shape.
|
|
103
|
-
*/
|
|
104
|
-
schemas?: readonly string[];
|
|
105
|
-
/** ENUM types declared via `pgEnum()`. PG-only; absent on other dialects. */
|
|
106
|
-
enums?: Record<string, EnumSnapshot>;
|
|
107
|
-
/**
|
|
108
|
-
* Optional relation sidecar populated when the schema includes
|
|
109
|
-
* `relations()` declarations. Absent when no relations are
|
|
110
|
-
* declared so M0/M1 callers see the same snapshot shape they
|
|
111
|
-
* always did.
|
|
112
|
-
*/
|
|
113
|
-
relations?: Record<string, Record<string, RelationSnapshot>>;
|
|
114
|
-
}
|
|
115
|
-
//#endregion
|
|
116
7
|
//#region src/snapshot/extract.d.ts
|
|
117
8
|
declare function extractSnapshot(schema: Record<string, unknown>, dialect: Dialect$1): SchemaSnapshot;
|
|
118
9
|
//#endregion
|
|
@@ -262,8 +153,6 @@ interface AddEnumValue {
|
|
|
262
153
|
* `-- KICK ENUM REMOVE` header. The runner refuses to apply such a
|
|
263
154
|
* migration without `confirmEnumDrop: true` on `RunnerOptions` (or
|
|
264
155
|
* `--confirm-enum-drop` from the CLI).
|
|
265
|
-
*
|
|
266
|
-
* Spec: docs/db/spec-enum-value-removal.md.
|
|
267
156
|
*/
|
|
268
157
|
interface RemoveEnumValue {
|
|
269
158
|
kind: 'removeEnumValue';
|
|
@@ -286,7 +175,7 @@ interface RemoveEnumValue {
|
|
|
286
175
|
* declared on the prior snapshot, or `null` when the column has no
|
|
287
176
|
* default. The emitter wraps the type swap in
|
|
288
177
|
* `DROP DEFAULT` / `SET DEFAULT … ::"<enum>"` brackets only when
|
|
289
|
-
* this is non-null.
|
|
178
|
+
* this is non-null.
|
|
290
179
|
*/
|
|
291
180
|
affectedColumns: readonly {
|
|
292
181
|
table: string;
|
|
@@ -334,8 +223,6 @@ declare class KickDbError extends Error {
|
|
|
334
223
|
*
|
|
335
224
|
* The operator's options: change the column's default in the schema
|
|
336
225
|
* to a value that survives the removal, or drop the default entirely.
|
|
337
|
-
*
|
|
338
|
-
* Spec: docs/db/spec-default-preservation.md.
|
|
339
226
|
*/
|
|
340
227
|
declare class RemovedValueAsDefaultError extends KickDbError {
|
|
341
228
|
readonly enum: string;
|
|
@@ -424,8 +311,7 @@ declare class UnreviewedMigrationError extends MigrationError {
|
|
|
424
311
|
/**
|
|
425
312
|
* Thrown by the runner when a migration carries the `-- KICK ENUM
|
|
426
313
|
* REMOVE` header and the operator hasn't passed `confirmEnumDrop:
|
|
427
|
-
* true` (CLI: `--confirm-enum-drop`).
|
|
428
|
-
* docs/db/spec-enum-value-removal.md §4.
|
|
314
|
+
* true` (CLI: `--confirm-enum-drop`).
|
|
429
315
|
*/
|
|
430
316
|
declare class MigrationEnumDropError extends MigrationError {
|
|
431
317
|
readonly id: string;
|
|
@@ -445,7 +331,11 @@ declare class MigrationEnumDropError extends MigrationError {
|
|
|
445
331
|
* `MigrationEnumDropError` when the header is present and
|
|
446
332
|
* `confirmEnumDrop` is falsy.
|
|
447
333
|
*
|
|
448
|
-
*
|
|
334
|
+
* Why a gate: PostgreSQL has no `ALTER TYPE … DROP VALUE`, so removing
|
|
335
|
+
* a value means renaming and recreating the type and casting every
|
|
336
|
+
* column with `USING`. That cast fails on any row still holding the
|
|
337
|
+
* removed value, so the operator should review the migration before it
|
|
338
|
+
* runs rather than find out mid-deploy.
|
|
449
339
|
*/
|
|
450
340
|
/**
|
|
451
341
|
* Parsed payload from the header block. Empty arrays for keys not
|
|
@@ -694,203 +584,6 @@ declare const DB_REPLICA: InjectionToken<KickDbClient>;
|
|
|
694
584
|
*/
|
|
695
585
|
declare const DB_CLIENT: InjectionToken<KickDbClient<unknown>>;
|
|
696
586
|
//#endregion
|
|
697
|
-
//#region src/dsl/columns/types.d.ts
|
|
698
|
-
/**
|
|
699
|
-
* Runtime + type representation of a column reference (e.g. `users.id`).
|
|
700
|
-
* Carries the parent table name, the column's own name, plus runtime
|
|
701
|
-
* accessors used by FK thunks and constraint builders.
|
|
702
|
-
*
|
|
703
|
-
* Exported so adopters can annotate self-referencing thunks without
|
|
704
|
-
* spelling the shape inline:
|
|
705
|
-
*
|
|
706
|
-
* parentId: uuid().references((): ColumnRef => categories.id)
|
|
707
|
-
*
|
|
708
|
-
* Without the annotation the initializer of a self-referencing const
|
|
709
|
-
* trips TS7022 — TS needs to infer the const while the initializer
|
|
710
|
-
* already references it.
|
|
711
|
-
*/
|
|
712
|
-
interface ColumnRef {
|
|
713
|
-
__tableName: string;
|
|
714
|
-
__name: string;
|
|
715
|
-
__builder: ColumnBuilder;
|
|
716
|
-
__state: () => ReturnType<ColumnBuilder['__state']>;
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* Resolved FK spec — `table` / `column` are pulled by invoking `thunk()`
|
|
720
|
-
* lazily. The thunk pattern lets self-referencing tables work:
|
|
721
|
-
*
|
|
722
|
-
* const categories = table('categories', {
|
|
723
|
-
* id: uuid().primaryKey().defaultRandom(),
|
|
724
|
-
* parentId: uuid().references((): ColumnRef => categories.id),
|
|
725
|
-
* })
|
|
726
|
-
*
|
|
727
|
-
* If we resolved at `.references()` call time, `categories` would TDZ-fail
|
|
728
|
-
* inside its own initializer. Storing the thunk and resolving on read
|
|
729
|
-
* (extract / render / emit) defers until after the const binding lands.
|
|
730
|
-
*/
|
|
731
|
-
interface FkSpec {
|
|
732
|
-
thunk: () => ColumnRef;
|
|
733
|
-
onDelete: FkAction;
|
|
734
|
-
onUpdate: FkAction;
|
|
735
|
-
/**
|
|
736
|
-
* The constraint's name in the database.
|
|
737
|
-
*
|
|
738
|
-
* Omitted for schemas written by hand — the name is then derived as
|
|
739
|
-
* `<table>_<column>_fk`. It is set when the schema was generated by
|
|
740
|
-
* `kick db introspect`, because a database names its constraints itself:
|
|
741
|
-
* Postgres' own default is `<table>_<column>_fkey`, and a DBA may have
|
|
742
|
-
* chosen anything. Dropping the real name would make the next diff want to
|
|
743
|
-
* rename every foreign key in the schema.
|
|
744
|
-
*/
|
|
745
|
-
name?: string;
|
|
746
|
-
}
|
|
747
|
-
interface ColumnState {
|
|
748
|
-
type: string;
|
|
749
|
-
nullable: boolean;
|
|
750
|
-
default: string | null;
|
|
751
|
-
primaryKey: boolean;
|
|
752
|
-
unique: boolean;
|
|
753
|
-
references: FkSpec | null;
|
|
754
|
-
}
|
|
755
|
-
/**
|
|
756
|
-
* Type-only brand attached to a column when it's auto-assigned by the
|
|
757
|
-
* database (serial / bigserial / smallserial), has a runtime default
|
|
758
|
-
* (`.default(...)`), or carries an expression default
|
|
759
|
-
* (`uuid().defaultRandom()`, `timestamp().defaultNow()`). `SchemaToTypes<S>`
|
|
760
|
-
* reads this marker and wraps the column type in Kysely's `Generated<T>` so
|
|
761
|
-
* adopters can omit the column on insert.
|
|
762
|
-
*
|
|
763
|
-
* Runtime is a no-op — the symbol never reaches a value.
|
|
764
|
-
*/
|
|
765
|
-
declare const KICK_GENERATED: unique symbol;
|
|
766
|
-
type GeneratedBrand = {
|
|
767
|
-
readonly [KICK_GENERATED]?: true;
|
|
768
|
-
};
|
|
769
|
-
/**
|
|
770
|
-
* Type-only brand attached to a column when `.notNull()` or `.primaryKey()`
|
|
771
|
-
* is called. `SchemaToTypes<S>` reads this brand to decide whether the
|
|
772
|
-
* column type is `T` (NOT NULL) or `T | null` (default nullable).
|
|
773
|
-
*
|
|
774
|
-
* Why a brand instead of a class generic: chained methods (notNull,
|
|
775
|
-
* primaryKey) can return `this & NotNullBrand` to narrow nullability while
|
|
776
|
-
* preserving the subclass identity — so `uuid().primaryKey().defaultRandom()`
|
|
777
|
-
* still resolves `defaultRandom()` on `UuidBuilder`. A class generic
|
|
778
|
-
* `<TNullable>` would collapse the subclass back to the parent.
|
|
779
|
-
*/
|
|
780
|
-
declare const KICK_NOT_NULL: unique symbol;
|
|
781
|
-
type NotNullBrand = {
|
|
782
|
-
readonly [KICK_NOT_NULL]?: true;
|
|
783
|
-
};
|
|
784
|
-
/**
|
|
785
|
-
* Re-attach the nullability / generated brands after a transform that
|
|
786
|
-
* must return a *new* builder type (e.g. `.array()` widening `T` to
|
|
787
|
-
* `T[]`). Without this, `integer().notNull().array()` silently dropped
|
|
788
|
-
* `NotNullBrand` and the row type regressed to `number[] | null`.
|
|
789
|
-
*
|
|
790
|
-
* Uses the same `extends` checks as `SchemaToTypes` (client/schema-types.ts)
|
|
791
|
-
* so detection stays consistent in both directions.
|
|
792
|
-
*/
|
|
793
|
-
type PreserveBrands<Self, Out> = Out & (Self extends NotNullBrand ? NotNullBrand : unknown) & (Self extends GeneratedBrand ? GeneratedBrand : unknown);
|
|
794
|
-
/**
|
|
795
|
-
* Phantom-typed column builder. The `T` generic carries the column's TS
|
|
796
|
-
* value type (number / string / Date / etc.); nullability is tracked via
|
|
797
|
-
* the `NotNullBrand` intersection rather than a class generic so chain
|
|
798
|
-
* methods preserve subclass identity.
|
|
799
|
-
*
|
|
800
|
-
* Both `T` and the brand are erased at runtime; they exist purely so
|
|
801
|
-
* `SchemaToTypes<S>` can pull them out per column.
|
|
802
|
-
*/
|
|
803
|
-
declare class ColumnBuilder<T = unknown> {
|
|
804
|
-
readonly __t?: T;
|
|
805
|
-
protected state: ColumnState;
|
|
806
|
-
constructor(type: string, defaults?: Partial<ColumnState>);
|
|
807
|
-
notNull(): this & NotNullBrand;
|
|
808
|
-
primaryKey(): this & NotNullBrand;
|
|
809
|
-
unique(): this;
|
|
810
|
-
array(): PreserveBrands<this, ColumnBuilder<T[]>>;
|
|
811
|
-
references(target: () => ColumnRef, opts?: {
|
|
812
|
-
onDelete?: FkAction;
|
|
813
|
-
onUpdate?: FkAction;
|
|
814
|
-
name?: string;
|
|
815
|
-
}): this;
|
|
816
|
-
/**
|
|
817
|
-
* Mark the column as having a runtime / DB-assigned default. The
|
|
818
|
-
* `GeneratedBrand` flows into `SchemaToTypes<S>` so the column wraps
|
|
819
|
-
* in `Generated<T>` — adopters can `INSERT` without specifying it.
|
|
820
|
-
*
|
|
821
|
-
* Accepts the natural literal for the column type — `boolean().default(false)`,
|
|
822
|
-
* `integer().default(0)`, `varchar().default('active')`. Non-string
|
|
823
|
-
* literals are normalised to their SQL-literal text so the snapshot
|
|
824
|
-
* (`ColumnSnapshot.default: string | null`) and migration emitter stay
|
|
825
|
-
* string-only. For a quoted string default the text is the value
|
|
826
|
-
* itself (`'active'`); booleans/numbers emit bare (`false`, `0`).
|
|
827
|
-
*/
|
|
828
|
-
default(value: string | number | boolean): this & GeneratedBrand;
|
|
829
|
-
toJSON(name: string): ColumnSnapshot;
|
|
830
|
-
__state(): Readonly<ColumnState>;
|
|
831
|
-
}
|
|
832
|
-
//#endregion
|
|
833
|
-
//#region src/dsl/constraints.d.ts
|
|
834
|
-
interface IndexDecl {
|
|
835
|
-
name: string;
|
|
836
|
-
columns: string[];
|
|
837
|
-
unique: boolean;
|
|
838
|
-
}
|
|
839
|
-
interface ColRef {
|
|
840
|
-
__name: string;
|
|
841
|
-
}
|
|
842
|
-
declare function index(name: string): {
|
|
843
|
-
on(...cols: ColRef[]): IndexDecl;
|
|
844
|
-
};
|
|
845
|
-
declare function unique(name: string): {
|
|
846
|
-
on(...cols: ColRef[]): IndexDecl;
|
|
847
|
-
};
|
|
848
|
-
//#endregion
|
|
849
|
-
//#region src/dsl/table.d.ts
|
|
850
|
-
interface TableDecl<TName extends string = string, C extends Record<string, ColumnBuilder> = Record<string, ColumnBuilder>, TSchema extends string | undefined = string | undefined> {
|
|
851
|
-
__isTable: true;
|
|
852
|
-
__name: TName;
|
|
853
|
-
__columns: C;
|
|
854
|
-
__indexes: IndexDecl[];
|
|
855
|
-
/**
|
|
856
|
-
* Named SQL schema this table lives in, from `pgSchema('x').table(...)`.
|
|
857
|
-
* `undefined` means the connection's default search_path (`public` on PG),
|
|
858
|
-
* which is every table declared through the bare `table()` factory.
|
|
859
|
-
*
|
|
860
|
-
* PostgreSQL only — `assertSchemasSupported()` rejects a declared schema
|
|
861
|
-
* on MySQL/SQLite at snapshot time rather than emitting subtly wrong DDL.
|
|
862
|
-
*/
|
|
863
|
-
__schema?: TSchema;
|
|
864
|
-
}
|
|
865
|
-
/**
|
|
866
|
-
* Fully-qualified name used as the snapshot key, the Kysely table key, and
|
|
867
|
-
* the emitted identifier. `quoteIdent` splits on `.`, so `billing.invoices`
|
|
868
|
-
* renders as `"billing"."invoices"` with no further work.
|
|
869
|
-
*
|
|
870
|
-
* Unqualified tables keep their bare name, so every pre-schema snapshot,
|
|
871
|
-
* migration hash, and `KickDbSchema` key is byte-identical to before.
|
|
872
|
-
*/
|
|
873
|
-
type QualifiedName<TName extends string, TSchema extends string | undefined> = TSchema extends string ? `${TSchema}.${TName}` : TName;
|
|
874
|
-
/** Runtime counterpart of {@link QualifiedName}. */
|
|
875
|
-
declare function qualifiedTableName(decl: {
|
|
876
|
-
__name: string;
|
|
877
|
-
__schema?: string | undefined;
|
|
878
|
-
}): string;
|
|
879
|
-
type TableRefs<TName extends string, C extends Record<string, ColumnBuilder>, TSchema extends string | undefined = undefined> = TableDecl<TName, C, TSchema> & { [K in keyof C]: ColumnRef; };
|
|
880
|
-
type ConstraintBuilder<C extends Record<string, ColumnBuilder>> = (refs: { [K in keyof C]: ColumnRef; }) => Record<string, IndexDecl>;
|
|
881
|
-
/**
|
|
882
|
-
* Declare a typed table. The `TName extends string` generic narrows to the
|
|
883
|
-
* literal table name so `SchemaToTypes<S>` can index by it without losing
|
|
884
|
-
* the constant — `table('users', …)` widens to `TableDecl<'users', …>`,
|
|
885
|
-
* not `TableDecl<string, …>`.
|
|
886
|
-
*/
|
|
887
|
-
declare function table<TName extends string, C extends Record<string, ColumnBuilder>>(name: TName, columns: C, constraints?: ConstraintBuilder<C>): TableRefs<TName, C>;
|
|
888
|
-
/**
|
|
889
|
-
* Shared table constructor. `table()` passes `schema: undefined`;
|
|
890
|
-
* `pgSchema('x').table()` passes the schema name through.
|
|
891
|
-
*/
|
|
892
|
-
declare function buildTable<TName extends string, C extends Record<string, ColumnBuilder>, TSchema extends string | undefined>(name: TName, columns: C, constraints: ConstraintBuilder<C> | undefined, schema: TSchema): TableRefs<TName, C, TSchema>;
|
|
893
|
-
//#endregion
|
|
894
587
|
//#region src/client/schema-types.d.ts
|
|
895
588
|
/**
|
|
896
589
|
* Pull each column's TS type and nullability into the row shape Kysely
|
|
@@ -988,7 +681,6 @@ interface RunnerOptions {
|
|
|
988
681
|
/**
|
|
989
682
|
* Allow migrations carrying the `-- KICK ENUM REMOVE` header to
|
|
990
683
|
* apply. Default `false`. CLI exposes via `--confirm-enum-drop`.
|
|
991
|
-
* Spec: docs/db/spec-enum-value-removal.md.
|
|
992
684
|
*/
|
|
993
685
|
confirmEnumDrop?: boolean;
|
|
994
686
|
}
|
|
@@ -1227,8 +919,7 @@ interface RelationOne<TTarget extends TableDecl<string, Record<string, ColumnBui
|
|
|
1227
919
|
/**
|
|
1228
920
|
* Disambiguates this relation from sibling `one` relations on the
|
|
1229
921
|
* same source table that point at the same target. Pair with the
|
|
1230
|
-
* matching `relationName` on the inverse `many` side.
|
|
1231
|
-
* docs/db/spec-relation-name.md.
|
|
922
|
+
* matching `relationName` on the inverse `many` side.
|
|
1232
923
|
*/
|
|
1233
924
|
relationName?: string;
|
|
1234
925
|
}
|
|
@@ -1409,8 +1100,6 @@ declare class RelationalQueryAliasCollisionError extends KickDbError {
|
|
|
1409
1100
|
* `AbortController.abort(reason)` — on the `cause` field for adopter
|
|
1410
1101
|
* inspection (e.g. distinguishing HTTP timeout from explicit
|
|
1411
1102
|
* cancellation from user-disconnect).
|
|
1412
|
-
*
|
|
1413
|
-
* Spec: docs/db/spec-abortsignal-threading.md.
|
|
1414
1103
|
*/
|
|
1415
1104
|
declare class RelationalQueryCancelledError extends KickDbError {
|
|
1416
1105
|
readonly cause?: unknown;
|
|
@@ -1430,8 +1119,7 @@ declare class RelationalQueryNotSupportedError extends KickDbError {
|
|
|
1430
1119
|
* on the **target** table shares the same `relationName` AND points
|
|
1431
1120
|
* back at the same source — the actual ambiguity case for resolver
|
|
1432
1121
|
* step 1. Scope is per `(sourceTable, targetTable, relationName)`:
|
|
1433
|
-
* the same tag can be reused across unrelated table pairs.
|
|
1434
|
-
* docs/db/spec-relation-name.md §7 R-2.
|
|
1122
|
+
* the same tag can be reused across unrelated table pairs.
|
|
1435
1123
|
*/
|
|
1436
1124
|
declare class RelationalQueryAmbiguousRelationNameError extends KickDbError {
|
|
1437
1125
|
readonly sourceTable: string;
|
|
@@ -1528,5 +1216,5 @@ declare function markDialect<T extends object>(dialect: T, tag: DialectTag): T;
|
|
|
1528
1216
|
*/
|
|
1529
1217
|
declare function readDialectMark(dialect: object): DialectTag | undefined;
|
|
1530
1218
|
//#endregion
|
|
1531
|
-
export { GenerateOptions as $,
|
|
1532
|
-
//# sourceMappingURL=index-
|
|
1219
|
+
export { GenerateOptions as $, readJournal as $t, bigSerial as A, DropColumn as An, DriftBehavior as At, json as B, extractSnapshot as Bn, IntrospectPgOptions as Bt, Relation as C, AddIndex as Cn, SchemaToTypes as Ct, relations as D, CreateEnum as Dn, KickDbAdapterConfig as Dt, RelationsDecl as E, ChangeSet as En, DB_REPLICA as Et, date as F, RemoveEnumValue as Fn, introspectMysql as Ft, smallSerial as G, lockTableDdl as Gt, numeric as H, MemoryMigrationAdapter as Ht, decimal as I, RenameColumn as In, IntrospectSqliteOptions as It, time as J, MigrationRow as Jt, smallint as K, migrationsTableDdl as Kt, doublePrecision as L, RenameTable as Ln, SqliteIntrospectDb as Lt, boolean as M, DropForeignKey as Mn, checkDrift as Mt, bytea as N, DropIndex as Nn, IntrospectMysqlOptions as Nt, TimestampBuilder as O, CreateSchema as On, MigrationsOnBoot as Ot, char as P, DropTable as Pn, MysqlIntrospectDb as Pt, varchar as Q, computeMigrationHash as Qt, integer as R, renderSchemaSource as Rn, introspectSqlite as Rt, customType as S, AddForeignKey as Sn, createDbClient as St, RelationOne as T, Change as Tn, DB_PRIMARY as Tt, real as U, KICK_LOCK_TABLE as Ut, jsonb as V, PgQueryRunner as Vt, serial as W, KICK_MIGRATIONS_TABLE as Wt, timestamptz as X, JournalEntry as Xt, timestamp as Y, Journal as Yt, uuid as Z, appendJournalEntry as Zt, SchemaToRelationsRegister as _, hasAmbiguousReverse as _n, migrateLatest as _t, markDialect as a, MigrationEnumDropError as an, emitMysql as at, CustomColumnBuilder as b, AddColumn as bn, migrateUp as bt, escapeLike as c, MigrationLockError as cn, emitPg as ct, RelationalQueryAmbiguousRelationNameError as d, CompositeEnumReferenceError as dn, AppliedSummary as dt, verifyMigrationHash as en, GenerateResult as et, RelationalQueryCancelledError as f, CompositeQueryRunner as fn, ReversedSummary as ft, RelationalQueryUnknownRelationError as g, RemovedValueAsDefaultError as gn, migrateDown as gt, RelationalQueryNotSupportedError as h, KickDbError as hn, StatusEntry as ht, isDialectTag as i, MigrationDriftError as in, resolveDbConfig as it, bigint as j, DropEnum as jn, DriftLogger as jt, UuidBuilder as k, CreateTable as kn, kickDbAdapter as kt, likePattern as l, SchemaDiffSummary as ln, ReviewResult as lt, RelationalQueryMissingInverseError as m, detectCompositeReferences as mn, RunnerOptions as mt, DialectTag as n, enforceEnumDropGate as nn, DbConfig as nt, readDialectMark as o, MigrationError as on, SqliteRebuildRequiredError as ot, RelationalQueryDepthError as p, CompositeRef as pn, RollbackSummary as pt, text as q, MigrationAdapter as qt, KICK_DIALECT as r, parseEnumDropHeader as rn, MigrationAdapterFactory as rt, LikeMatchMode as s, MigrationHashError as sn, emitSqlite as st, ReadonlyKysely as t, EnumDropHeader as tn, generate as tt, RelationalQueryAliasCollisionError as u, UnreviewedMigrationError as un, reviewMigration as ut, ResolvedRelation as v, invertChanges as vn, migrateRollback as vt, RelationMany as w, AlterColumn as wn, DB_CLIENT as wt, CustomTypeOptions as x, AddEnumValue as xn, safeNullComparison as xt, ResolvedRelations as y, diff as yn, migrateStatus as yt, interval as z, fitIdentifier as zn, introspectPg as zt };
|
|
1220
|
+
//# sourceMappingURL=index-DF69HndC.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DF69HndC.d.mts","names":[],"sources":["../src/snapshot/extract.ts","../src/snapshot/name.ts","../src/snapshot/render.ts","../src/diff/types.ts","../src/diff/engine.ts","../src/diff/invert.ts","../src/errors.ts","../src/diff/composite-detect.ts","../src/migrate/errors.ts","../src/migrate/enum-drop-gate.ts","../src/migrate/journal.ts","../src/migrate/adapter.ts","../src/migrate/schema.ts","../src/migrate/memory-adapter.ts","../src/migrate/introspect-types.ts","../src/migrate/introspect-pg.ts","../src/migrate/introspect-sqlite.ts","../src/migrate/introspect-mysql.ts","../src/migrate/drift.ts","../src/adapter.ts","../src/tokens.ts","../src/client/schema-types.ts","../src/client/create.ts","../src/client/plugins.ts","../src/migrate/runner.ts","../src/migrate/review.ts","../src/emit/pg.ts","../src/emit/sqlite.ts","../src/emit/mysql.ts","../src/cli/config.ts","../src/cli/generate.ts","../src/dsl/columns/builders.ts","../src/dsl/relations.ts","../src/custom-type.ts","../src/query/relations.ts","../src/query/schema-relations-types.ts","../src/query/errors.ts","../src/query/like.ts","../src/dialect-marker.ts"],"mappings":";;;;;;;iBAiEgB,gBAAgB,QAAQ,yBAAyB,SAAS,YAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCfpE,cAAc;;;;;;;;;;;;;;;;;;;iBCxBd,mBAAmB,UAAU;;;;;;;;;;;;UCT5B;EACf;EACA;;UAGe;EACf;EACA,OAAO;;UAGQ;EACf;EACA,OAAO;;UAGQ;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA,QAAQ;;UAGO;EACf;EACA;EACA,QAAQ;;UAGO;EACf;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,QAAQ;EACR,OAAO;;UAGQ;EACf;EACA;EACA,OAAO;;UAGQ;EACf;EACA;EACA,OAAO;;UAGQ;EACf;EACA;EACA,IAAI;;UAGW;EACf;EACA;EACA,IAAI;;UAGW;EACf;EACA,MAAM;;UAGS;EACf;EACA,MAAM;;;;;;;;;;UAWS;EACf;EACA;EACA;;EAEA;;;;;;;;;;UAWe;EACf;;EAEA;;EAEA;;;;;;EAMA;;;;;;;;;;;;EAYA;IAA4B;IAAe;IAAgB;;;KAGjD,SACR,eACA,cACA,YACA,cACA,YACA,aACA,eACA,cACA,WACA,YACA,gBACA,iBACA,aACA,WACA,eACA;KAEQ,YAAY;;;iBClKR,KAAK,MAAM,gBAAgB,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;iBCalD,cAAc,SAAS,YAAY;iBA+GnC,oBAAoB,SAAS;;;cCjIhC,oBAAoB;WACtB;EAET,YAAY,cAAc;;;;;;;;;;;;;cAkBf,mCAAmC;WACrC;WACA;WACA;WACA;EAET,YAAY,kBAAkB,eAAe,gBAAgB;;;;;;;;;;UCE9C;;EAEf;;EAEA;;EAEA;;;;;;;UAQe;EACf,MAAM,aAAa,aAAa,8BAA8B;IAAU,MAAM;;;;;;;;;;;;;;iBA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as SchemaSnapshot, _ as CheckSnapshot, a as table, b as EnumSnapshot, c as unique, d as ColumnState, f as FkSpec, g as NotNullBrand, h as KICK_NOT_NULL, i as qualifiedTableName, l as ColumnBuilder, m as KICK_GENERATED, n as TableDecl, o as IndexDecl, p as GeneratedBrand, r as buildTable, s as index, t as QualifiedName, u as ColumnRef, v as ColumnSnapshot, w as RelationSnapshot, x as FkAction, y as Dialect } from "./table-Bl5SbKRg.mjs";
|
|
3
|
+
import { $ as GenerateOptions, $t as readJournal, A as bigSerial, An as DropColumn, At as DriftBehavior, B as json, Bn as extractSnapshot, Bt as IntrospectPgOptions, C as Relation, Cn as AddIndex, Ct as SchemaToTypes, D as relations, Dn as CreateEnum, Dt as KickDbAdapterConfig, E as RelationsDecl, En as ChangeSet, Et as DB_REPLICA, F as date, Fn as RemoveEnumValue, Ft as introspectMysql, G as smallSerial, Gt as lockTableDdl, H as numeric, Ht as MemoryMigrationAdapter, I as decimal, In as RenameColumn, It as IntrospectSqliteOptions, J as time, Jt as MigrationRow, K as smallint, Kt as migrationsTableDdl, L as doublePrecision, Ln as RenameTable, Lt as SqliteIntrospectDb, M as boolean, Mn as DropForeignKey, Mt as checkDrift, N as bytea, Nn as DropIndex, Nt as IntrospectMysqlOptions, O as TimestampBuilder, On as CreateSchema, Ot as MigrationsOnBoot, P as char, Pn as DropTable, Pt as MysqlIntrospectDb, Q as varchar, Qt as computeMigrationHash, R as integer, Rn as renderSchemaSource, Rt as introspectSqlite, S as customType, Sn as AddForeignKey, St as createDbClient, T as RelationOne, Tn as Change, Tt as DB_PRIMARY, U as real, Ut as KICK_LOCK_TABLE, V as jsonb, Vt as PgQueryRunner, W as serial, Wt as KICK_MIGRATIONS_TABLE, X as timestamptz, Xt as JournalEntry, Y as timestamp, Yt as Journal, Z as uuid, Zt as appendJournalEntry, _ as SchemaToRelationsRegister, _n as hasAmbiguousReverse, _t as migrateLatest, a as markDialect, an as MigrationEnumDropError, at as emitMysql, b as CustomColumnBuilder, bn as AddColumn, bt as migrateUp, c as escapeLike, cn as MigrationLockError, ct as emitPg, d as RelationalQueryAmbiguousRelationNameError, dn as CompositeEnumReferenceError, dt as AppliedSummary, en as verifyMigrationHash, et as GenerateResult, f as RelationalQueryCancelledError, fn as CompositeQueryRunner, ft as ReversedSummary, g as RelationalQueryUnknownRelationError, gn as RemovedValueAsDefaultError, gt as migrateDown, h as RelationalQueryNotSupportedError, hn as KickDbError, ht as StatusEntry, i as isDialectTag, in as MigrationDriftError, it as resolveDbConfig, j as bigint, jn as DropEnum, jt as DriftLogger, k as UuidBuilder, kn as CreateTable, kt as kickDbAdapter, l as likePattern, ln as SchemaDiffSummary, lt as ReviewResult, m as RelationalQueryMissingInverseError, mn as detectCompositeReferences, mt as RunnerOptions, n as DialectTag, nn as enforceEnumDropGate, nt as DbConfig, o as readDialectMark, on as MigrationError, ot as SqliteRebuildRequiredError, p as RelationalQueryDepthError, pn as CompositeRef, pt as RollbackSummary, q as text, qt as MigrationAdapter, r as KICK_DIALECT, rn as parseEnumDropHeader, s as LikeMatchMode, sn as MigrationHashError, st as emitSqlite, t as ReadonlyKysely, tn as EnumDropHeader, tt as generate, u as RelationalQueryAliasCollisionError, un as UnreviewedMigrationError, ut as reviewMigration, v as ResolvedRelation, vn as invertChanges, vt as migrateRollback, w as RelationMany, wn as AlterColumn, wt as DB_CLIENT, x as CustomTypeOptions, xn as AddEnumValue, xt as safeNullComparison, y as ResolvedRelations, yn as diff, yt as migrateStatus, z as interval, zn as fitIdentifier, zt as introspectPg } from "./index-DF69HndC.mjs";
|
|
4
|
+
import { C as ModelExtensions, S as ExtensionDefinition, _ as TableRelations, a as QueryErrorEvent, b as RegisteredDB, c as TransactionEvent, d as FindManyRow, f as KickDbRelationsRegister, g as TableQueryNamespace, h as RelationMapEntry, i as KickDbClientEvents, l as TransactionRollbackEvent, m as RegisteredRelations, n as CreateDbClientOptions, o as QueryEvent, p as QueryNamespace, r as KickDbClient, t as BeforeQueryEvent, u as FindManyOptions, v as WithClause, x as ExtendedClient, y as KickDbRegister } from "./types-DtvYnaXL.mjs";
|
|
4
5
|
export { type AddColumn, type AddEnumValue, type AddForeignKey, type AddIndex, type AlterColumn, type AppliedSummary, type BeforeQueryEvent, type Change, type ChangeSet, type CheckSnapshot, ColumnBuilder, type ColumnRef, type ColumnSnapshot, type ColumnState, CompositeEnumReferenceError, type CompositeQueryRunner, type CompositeRef, type CreateDbClientOptions, type CreateEnum, type CreateSchema, type CreateTable, CustomColumnBuilder, type CustomTypeOptions, DB_CLIENT, DB_PRIMARY, DB_REPLICA, type DbConfig, type Dialect, type DialectTag, type DriftBehavior, type DriftLogger, type DropColumn, type DropEnum, type DropForeignKey, type DropIndex, type DropTable, type EnumDropHeader, type EnumSnapshot, type ExtendedClient, type ExtensionDefinition, type FindManyOptions, type FindManyRow, type FkAction, type FkSpec, type ForeignKeySnapshot, type GenerateOptions, type GenerateResult, type GeneratedBrand, IndexDecl, type IndexSnapshot, type IntrospectMysqlOptions, type IntrospectPgOptions, type IntrospectSqliteOptions, type Journal, type JournalEntry, KICK_DIALECT, KICK_GENERATED, KICK_LOCK_TABLE, KICK_MIGRATIONS_TABLE, KICK_NOT_NULL, type KickDbAdapterConfig, type KickDbClient, type KickDbClientEvents, KickDbError, type KickDbRegister, type KickDbRelationsRegister, type LikeMatchMode, MemoryMigrationAdapter, type MigrationAdapter, MigrationDriftError, MigrationEnumDropError, MigrationError, MigrationHashError, MigrationLockError, type MigrationRow, type MigrationsOnBoot, type ModelExtensions, type MysqlIntrospectDb, type NotNullBrand, type PgQueryRunner, QualifiedName, type QueryErrorEvent, type QueryEvent, type QueryNamespace, type ReadonlyKysely, type RegisteredDB, type RegisteredRelations, Relation, RelationMany, type RelationMapEntry, RelationOne, type RelationSnapshot, RelationalQueryAliasCollisionError, RelationalQueryAmbiguousRelationNameError, RelationalQueryCancelledError, RelationalQueryDepthError, RelationalQueryMissingInverseError, RelationalQueryNotSupportedError, RelationalQueryUnknownRelationError, RelationsDecl, type RemoveEnumValue, RemovedValueAsDefaultError, type RenameColumn, type RenameTable, type ResolvedRelation, type ResolvedRelations, type ReversedSummary, type ReviewResult, type RollbackSummary, type RunnerOptions, type SchemaDiffSummary, type SchemaSnapshot, type SchemaToRelationsRegister, type SchemaToTypes, type SqliteIntrospectDb, SqliteRebuildRequiredError, type StatusEntry, TableDecl, type TableQueryNamespace, type TableRelations, type TableSnapshot, TimestampBuilder, type TransactionEvent, type TransactionRollbackEvent, UnreviewedMigrationError, UuidBuilder, type WithClause, appendJournalEntry, bigSerial, bigint, boolean, buildTable, bytea, char, checkDrift, computeMigrationHash, createDbClient, customType, date, decimal, detectCompositeReferences, diff, doublePrecision, emitMysql, emitPg, emitSqlite, enforceEnumDropGate, escapeLike, extractSnapshot, fitIdentifier, generate, hasAmbiguousReverse, index, integer, interval, introspectMysql, introspectPg, introspectSqlite, invertChanges, isDialectTag, json, jsonb, kickDbAdapter, likePattern, lockTableDdl, markDialect, migrateDown, migrateLatest, migrateRollback, migrateStatus, migrateUp, migrationsTableDdl, numeric, parseEnumDropHeader, qualifiedTableName, readDialectMark, readJournal, real, relations, renderSchemaSource, resolveDbConfig, reviewMigration, safeNullComparison, serial, smallSerial, smallint, table, text, time, timestamp, timestamptz, unique, uuid, varchar, verifyMigrationHash };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-db v7.
|
|
2
|
+
* @forinda/kickjs-db v7.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{$ as
|
|
11
|
+
import{$ as introspectMysql,A as varchar,At as RelationalQueryDepthError,B as DB_CLIENT,C as smallSerial,Ct as invertChanges,D as timestamp,Dt as RelationalQueryAliasCollisionError,E as time,Et as extractSnapshot,F as createDbClient,Ft as RemovedValueAsDefaultError,G as migrateLatest,H as DB_REPLICA,I as KICK_DIALECT,It as buildTable,J as migrateUp,K as migrateRollback,L as isDialectTag,Lt as qualifiedTableName,M as resolveDbConfig,Mt as RelationalQueryNotSupportedError,N as reviewMigration,Nt as RelationalQueryUnknownRelationError,O as timestamptz,Ot as RelationalQueryAmbiguousRelationNameError,P as safeNullComparison,Pt as KickDbError,Q as emitSqlite,R as markDialect,Rt as table,S as serial,St as hasAmbiguousReverse,T as text,Tt as renderSchemaSource,U as kickDbAdapter,V as DB_PRIMARY,W as migrateDown,X as emitMysql,Y as checkDrift,Z as SqliteRebuildRequiredError,_ as interval,_t as MigrationHashError,a as unique,at as lockTableDdl,b as numeric,bt as CompositeEnumReferenceError,c as bigSerial,ct as computeMigrationHash,d as bytea,dt as enforceEnumDropGate,et as introspectSqlite,f as char,ft as parseEnumDropHeader,g as integer,gt as MigrationError,h as doublePrecision,ht as MigrationEnumDropError,i as index,it as KICK_MIGRATIONS_TABLE,j as generate,jt as RelationalQueryMissingInverseError,k as uuid,kt as RelationalQueryCancelledError,l as bigint,lt as readJournal,m as decimal,mt as MigrationDriftError,n as likePattern,nt as MemoryMigrationAdapter,o as TimestampBuilder,ot as migrationsTableDdl,p as date,pt as emitPg,q as migrateStatus,r as relations,rt as KICK_LOCK_TABLE,s as UuidBuilder,st as appendJournalEntry,t as escapeLike,tt as introspectPg,u as boolean,ut as verifyMigrationHash,v as json,vt as MigrationLockError,w as smallint,wt as diff,x as real,xt as detectCompositeReferences,y as jsonb,yt as UnreviewedMigrationError,z as readDialectMark,zt as fitIdentifier}from"./src-BnHTLx5l.mjs";import{a as KICK_NOT_NULL,i as KICK_GENERATED,n as customType,r as ColumnBuilder,t as CustomColumnBuilder}from"./custom-type-j8k__3sL.mjs";export{ColumnBuilder,CompositeEnumReferenceError,CustomColumnBuilder,DB_CLIENT,DB_PRIMARY,DB_REPLICA,KICK_DIALECT,KICK_GENERATED,KICK_LOCK_TABLE,KICK_MIGRATIONS_TABLE,KICK_NOT_NULL,KickDbError,MemoryMigrationAdapter,MigrationDriftError,MigrationEnumDropError,MigrationError,MigrationHashError,MigrationLockError,RelationalQueryAliasCollisionError,RelationalQueryAmbiguousRelationNameError,RelationalQueryCancelledError,RelationalQueryDepthError,RelationalQueryMissingInverseError,RelationalQueryNotSupportedError,RelationalQueryUnknownRelationError,RemovedValueAsDefaultError,SqliteRebuildRequiredError,TimestampBuilder,UnreviewedMigrationError,UuidBuilder,appendJournalEntry,bigSerial,bigint,boolean,buildTable,bytea,char,checkDrift,computeMigrationHash,createDbClient,customType,date,decimal,detectCompositeReferences,diff,doublePrecision,emitMysql,emitPg,emitSqlite,enforceEnumDropGate,escapeLike,extractSnapshot,fitIdentifier,generate,hasAmbiguousReverse,index,integer,interval,introspectMysql,introspectPg,introspectSqlite,invertChanges,isDialectTag,json,jsonb,kickDbAdapter,likePattern,lockTableDdl,markDialect,migrateDown,migrateLatest,migrateRollback,migrateStatus,migrateUp,migrationsTableDdl,numeric,parseEnumDropHeader,qualifiedTableName,readDialectMark,readJournal,real,relations,renderSchemaSource,resolveDbConfig,reviewMigration,safeNullComparison,serial,smallSerial,smallint,table,text,time,timestamp,timestamptz,unique,uuid,varchar,verifyMigrationHash};
|
package/dist/mysql.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { qt as MigrationAdapter } from "./index-DF69HndC.mjs";
|
|
3
3
|
import { Dialect } from "kysely";
|
|
4
4
|
//#region src/adapters/mysql/adapter.d.ts
|
|
5
5
|
/**
|
|
@@ -15,15 +15,15 @@ import { Dialect } from "kysely";
|
|
|
15
15
|
* callers pass `R = ResultSetHeader`). Each adapter call site picks
|
|
16
16
|
* the row shape it expects via the type parameter.
|
|
17
17
|
*/
|
|
18
|
-
interface MysqlConnectionLike {
|
|
18
|
+
export interface MysqlConnectionLike {
|
|
19
19
|
query<R = unknown>(sql: string, params?: readonly unknown[]): Promise<[R, unknown]>;
|
|
20
20
|
release(): void;
|
|
21
21
|
}
|
|
22
|
-
interface MysqlPoolLike {
|
|
22
|
+
export interface MysqlPoolLike {
|
|
23
23
|
query<R = unknown>(sql: string, params?: readonly unknown[]): Promise<[R, unknown]>;
|
|
24
24
|
getConnection(): Promise<MysqlConnectionLike>;
|
|
25
25
|
}
|
|
26
|
-
interface MysqlAdapterOptions {
|
|
26
|
+
export interface MysqlAdapterOptions {
|
|
27
27
|
/**
|
|
28
28
|
* mysql2-compatible Pool. Caller-owned — `close()` on the adapter
|
|
29
29
|
* does NOT end the pool because adopters typically share a single
|
|
@@ -36,7 +36,7 @@ interface MysqlAdapterOptions {
|
|
|
36
36
|
* adopters distinguish MySQL from MariaDB without re-grepping the
|
|
37
37
|
* raw string.
|
|
38
38
|
*/
|
|
39
|
-
interface ParsedMysqlVersion {
|
|
39
|
+
export interface ParsedMysqlVersion {
|
|
40
40
|
flavor: 'mysql' | 'mariadb';
|
|
41
41
|
major: number;
|
|
42
42
|
minor: number;
|
|
@@ -54,7 +54,7 @@ interface ParsedMysqlVersion {
|
|
|
54
54
|
*
|
|
55
55
|
* Returns `null` on unparseable input.
|
|
56
56
|
*/
|
|
57
|
-
declare function parseMysqlVersion(version: string): ParsedMysqlVersion | null;
|
|
57
|
+
export declare function parseMysqlVersion(version: string): ParsedMysqlVersion | null;
|
|
58
58
|
/**
|
|
59
59
|
* Back-compat shim — pre-existing API surface that returned the
|
|
60
60
|
* major version only. Kept exported so adopters depending on it
|
|
@@ -62,7 +62,7 @@ declare function parseMysqlVersion(version: string): ParsedMysqlVersion | null;
|
|
|
62
62
|
*
|
|
63
63
|
* @deprecated Use `parseMysqlVersion` for full version + flavor info.
|
|
64
64
|
*/
|
|
65
|
-
declare function parseMysqlMajorVersion(version: string): number | null;
|
|
65
|
+
export declare function parseMysqlMajorVersion(version: string): number | null;
|
|
66
66
|
/**
|
|
67
67
|
* Split a SQL blob into individual statements at the top-level `;`
|
|
68
68
|
* boundary. Respects single-quote / double-quote / backtick string
|
|
@@ -94,7 +94,7 @@ declare function parseMysqlMajorVersion(version: string): number | null;
|
|
|
94
94
|
* Documented in the README; turn on `multipleStatements: true` on
|
|
95
95
|
* the pool if you hit it.
|
|
96
96
|
*/
|
|
97
|
-
declare function splitMysqlStatements(sql: string): string[];
|
|
97
|
+
export declare function splitMysqlStatements(sql: string): string[];
|
|
98
98
|
/**
|
|
99
99
|
* MigrationAdapter implementation backed by mysql2.
|
|
100
100
|
*
|
|
@@ -121,10 +121,10 @@ declare function splitMysqlStatements(sql: string): string[];
|
|
|
121
121
|
* code `KICK_DB_INTROSPECT_NOT_SUPPORTED`. Drift detection lands
|
|
122
122
|
* in a follow-up that walks `information_schema`.
|
|
123
123
|
*/
|
|
124
|
-
declare function mysqlAdapter(opts: MysqlAdapterOptions): MigrationAdapter;
|
|
124
|
+
export declare function mysqlAdapter(opts: MysqlAdapterOptions): MigrationAdapter;
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region src/adapters/mysql/dialect.d.ts
|
|
127
|
-
interface MysqlDialectOptions {
|
|
127
|
+
export interface MysqlDialectOptions {
|
|
128
128
|
/**
|
|
129
129
|
* mysql2-compatible pool. Both `mysql.createPool(...)` from
|
|
130
130
|
* `mysql2/promise` and `mysql2.createPool(...)` (callback API
|
|
@@ -158,7 +158,6 @@ interface MysqlDialectOptions {
|
|
|
158
158
|
* export const migrationAdapter = mysqlAdapter({ pool })
|
|
159
159
|
* ```
|
|
160
160
|
*/
|
|
161
|
-
declare function mysqlDialect(opts: MysqlDialectOptions): Dialect;
|
|
161
|
+
export declare function mysqlDialect(opts: MysqlDialectOptions): Dialect;
|
|
162
162
|
//#endregion
|
|
163
|
-
export { MysqlAdapterOptions, MysqlConnectionLike, MysqlDialectOptions, MysqlPoolLike, ParsedMysqlVersion, mysqlAdapter, mysqlDialect, parseMysqlMajorVersion, parseMysqlVersion, splitMysqlStatements };
|
|
164
163
|
//# sourceMappingURL=mysql.d.mts.map
|
package/dist/mysql.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mysql.d.mts","names":[],"sources":["../src/adapters/mysql/adapter.ts","../src/adapters/mysql/dialect.ts"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"mysql.d.mts","names":[],"sources":["../src/adapters/mysql/adapter.ts","../src/adapters/mysql/dialect.ts"],"mappings":";;;;;;;;;;;;;;;;;iBAwBiB;EACf,MAAM,aAAa,aAAa,8BAA8B,SAAS;EACvE;;iBAGe;EACf,MAAM,aAAa,aAAa,8BAA8B,SAAS;EACvE,iBAAiB,QAAQ;;iBAGV;;;;;;EAMf,MAAM;;;;;;;iBAiBS;EACf;EACA;EACA;;;;;;;;;;;;;;;wBAgBc,kBAAkB,kBAAkB;;;;;;;;wBA4CpC,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA6DvB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2IrB,aAAa,MAAM,sBAAsB;;;iBCtTxC;;;;;;EAMf,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA6BQ,aAAa,MAAM,sBAAsB"}
|
package/dist/mysql.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-db v7.
|
|
2
|
+
* @forinda/kickjs-db v7.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{
|
|
11
|
+
import{$ as introspectMysql,Pt as KickDbError,R as markDialect,at as lockTableDdl,ot as migrationsTableDdl}from"./src-BnHTLx5l.mjs";import{MysqlDialect}from"kysely";function parseMysqlVersion(version){let trimmed=version.trim();if(/MariaDB/i.test(trimmed)){let m=/(\d+)\.(\d+)(?:\.\d+)?-MariaDB/i.exec(trimmed);if(m){let major=Number(m[1]),minor=Number(m[2]);if(Number.isFinite(major)&&Number.isFinite(minor))return{flavor:`mariadb`,major,minor}}let fallback=/^(\d+)\.(\d+)/.exec(trimmed);if(!fallback)return null;let major=Number(fallback[1]),minor=Number(fallback[2]);return!Number.isFinite(major)||!Number.isFinite(minor)?null:{flavor:`mariadb`,major,minor}}let m=/^(\d+)\.(\d+)/.exec(trimmed);if(!m)return null;let major=Number(m[1]),minor=Number(m[2]);return!Number.isFinite(major)||!Number.isFinite(minor)?null:{flavor:`mysql`,major,minor}}function parseMysqlMajorVersion(version){return parseMysqlVersion(version)?.major??null}function checkVersionSupport(parsed,raw){return parsed==null?`unparseable version string: ${raw||`<empty>`}`:parsed.flavor===`mariadb`?parsed.major>10?null:parsed.major<10||parsed.minor<5?`MariaDB 10.5+ required (detected: ${raw})`:null:parsed.major<8?`MySQL 8.0+ required (detected: ${raw})`:null}function splitMysqlStatements(sql){let out=[],buf=``,inSingle=!1,inDouble=!1,inBacktick=!1,inLineComment=!1,inBlockComment=!1,isCommentWhitespace=c=>c===` `||c===` `||c===`
|
|
12
12
|
`||c===`\r`||c===`\f`||c===`\v`;for(let i=0;i<sql.length;i++){let ch=sql[i],next=i+1<sql.length?sql[i+1]:``,after=i+2<sql.length?sql[i+2]:``;if(inLineComment){buf+=ch,ch===`
|
|
13
13
|
`&&(inLineComment=!1);continue}if(inBlockComment){buf+=ch,ch===`*`&&next===`/`&&(buf+=next,i++,inBlockComment=!1);continue}if(inSingle){if(ch===`'`&&next===`'`){buf+=ch,buf+=next,i++;continue}if(buf+=ch,ch===`\\`&&next!==``){buf+=next,i++;continue}ch===`'`&&(inSingle=!1);continue}if(inDouble){if(ch===`"`&&next===`"`){buf+=ch,buf+=next,i++;continue}if(buf+=ch,ch===`\\`&&next!==``){buf+=next,i++;continue}ch===`"`&&(inDouble=!1);continue}if(inBacktick){buf+=ch,ch==="`"&&(inBacktick=!1);continue}if(ch===`-`&&next===`-`&&(after===``||isCommentWhitespace(after))){buf+=ch,inLineComment=!0;continue}if(ch===`/`&&next===`*`){buf+=ch,inBlockComment=!0;continue}if(ch===`'`){buf+=ch,inSingle=!0;continue}if(ch===`"`){buf+=ch,inDouble=!0;continue}if(ch==="`"){buf+=ch,inBacktick=!0;continue}if(ch===`;`){let trimmed=buf.trim();trimmed.length>0&&out.push(trimmed),buf=``;continue}buf+=ch}let tail=buf.trim();return tail.length>0&&out.push(tail),out}function mysqlAdapter(opts){let dialect=`mysql`,{pool}=opts,versionVerified=!1;async function assertVersion(){if(versionVerified)return;let[rows]=await pool.query("SELECT VERSION() AS `version`"),versionString=rows[0]?.version??``,failure=checkVersionSupport(parseMysqlVersion(versionString),versionString);if(failure)throw new KickDbError(`KICK_DB_RELATIONAL_NOT_SUPPORTED`,`${failure}. JSON_ARRAYAGG (required by the relational query layer) shipped in MySQL 8.0 and MariaDB 10.5. Use layer-1/layer-2 queries (selectFrom / selectAll) on older versions.`);versionVerified=!0}async function runStatements(sql){for(let stmt of splitMysqlStatements(sql))await pool.query(stmt)}async function runStatementsOnConn(conn,sql){for(let stmt of splitMysqlStatements(sql))await conn.query(stmt)}return{dialect,async ensureMigrationTables(){await assertVersion(),await runStatements(migrationsTableDdl(dialect)),await runStatements(lockTableDdl(dialect))},async listApplied(){let[rows]=await pool.query(`SELECT id, name, hash, batch, applied_at, direction
|
|
14
14
|
FROM \`kick_migrations\`
|