@authhero/kysely-adapter 12.9.0 → 12.10.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/README.md +9 -1
- package/dist/kysely-adapter.cjs +2 -1
- package/dist/kysely-adapter.d.ts +44 -2
- package/dist/kysely-adapter.mjs +1182 -1088
- package/dist/types/migrate/plan.d.ts +43 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Kysely } from "kysely";
|
|
2
|
+
import { Database } from "../src/db";
|
|
3
|
+
export interface PlannedStatement {
|
|
4
|
+
sql: string;
|
|
5
|
+
parameters: readonly unknown[];
|
|
6
|
+
}
|
|
7
|
+
export interface PlannedMigration {
|
|
8
|
+
name: string;
|
|
9
|
+
/** Writes (DDL and DML) the migration would execute, in order. */
|
|
10
|
+
statements: PlannedStatement[];
|
|
11
|
+
/**
|
|
12
|
+
* Set when the migration threw during planning. The statements captured
|
|
13
|
+
* before the failure are still listed. This can be a dry-run artifact: a
|
|
14
|
+
* migration that reads a column an earlier pending migration adds will fail
|
|
15
|
+
* here because the earlier migration was never applied.
|
|
16
|
+
*/
|
|
17
|
+
error?: string;
|
|
18
|
+
/** True when planning stopped at MAX_STATEMENTS_PER_MIGRATION. */
|
|
19
|
+
truncated?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface MigrationPlan {
|
|
22
|
+
/** Migrations already recorded as executed, in order. */
|
|
23
|
+
executed: string[];
|
|
24
|
+
/** Migrations `migrateToLatest` would run, in order. */
|
|
25
|
+
pending: PlannedMigration[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Dry run of `migrateToLatest`: lists the pending migrations and the SQL each
|
|
29
|
+
* would execute, without changing the database.
|
|
30
|
+
*
|
|
31
|
+
* Each pending migration's `up` runs against a wrapper around `db` that
|
|
32
|
+
* passes reads through and captures writes. Nothing is written — including
|
|
33
|
+
* the `kysely_migration` bookkeeping tables, which are only read if present.
|
|
34
|
+
*
|
|
35
|
+
* Because captured writes are never applied, the plan can diverge from a real
|
|
36
|
+
* run where a migration depends on its own or an earlier migration's writes:
|
|
37
|
+
* "tolerate duplicate column" guards never fire (so an already-present column
|
|
38
|
+
* still shows up as an ALTER), and reads of not-yet-created columns fail (see
|
|
39
|
+
* `PlannedMigration.error`).
|
|
40
|
+
*/
|
|
41
|
+
export declare function planMigrations(db: Kysely<Database>): Promise<MigrationPlan>;
|
|
42
|
+
/** Renders a plan as an SQL-ish script for printing. */
|
|
43
|
+
export declare function formatMigrationPlan(plan: MigrationPlan): string;
|
|
@@ -2,6 +2,8 @@ import { Kysely } from "kysely";
|
|
|
2
2
|
import { Database } from "./db";
|
|
3
3
|
import { DataAdapters } from "@authhero/adapter-interfaces";
|
|
4
4
|
export { migrateToLatest, migrateDown } from "../migrate/migrate";
|
|
5
|
+
export { planMigrations, formatMigrationPlan } from "../migrate/plan";
|
|
6
|
+
export type { MigrationPlan, PlannedMigration, PlannedStatement, } from "../migrate/plan";
|
|
5
7
|
export type { Database } from "./db";
|
|
6
8
|
export { createProxyRoutesAdapter, createProxyDataAdapter, } from "./proxyRoutes";
|
|
7
9
|
export default function createAdapters(db: Kysely<Database>, databaseOptions?: {
|