okmodel 0.1.1 → 0.3.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 +727 -37
- package/dist/adapters/capabilities.d.ts +34 -0
- package/dist/adapters/pg/bunsql-extra.d.ts +17 -0
- package/dist/adapters/pg/bunsql.d.ts +60 -0
- package/dist/adapters/pg/call.d.ts +2 -12
- package/dist/adapters/pg/nodepostgres-extra.d.ts +18 -0
- package/dist/adapters/pg/nodepostgres.d.ts +57 -0
- package/dist/adapters/pg/postgres-extra.d.ts +50 -1
- package/dist/adapters/pg/postgresjs.d.ts +0 -4
- package/dist/adapters/pg/session.d.ts +94 -0
- package/dist/adapters/pg/watch.d.ts +18 -0
- package/dist/contracts/catalog/enum.d.ts +31 -4
- package/dist/contracts/catalog/extension.d.ts +61 -0
- package/dist/contracts/catalog/object.d.ts +1 -0
- package/dist/contracts/catalog/privilege.d.ts +64 -0
- package/dist/contracts/catalog/routine.d.ts +56 -0
- package/dist/contracts/catalog/types.d.ts +179 -18
- package/dist/contracts/catalog/view.d.ts +73 -0
- package/dist/contracts/connection.d.ts +13 -0
- package/dist/contracts/driver.d.ts +18 -5
- package/dist/contracts/error.d.ts +17 -1
- package/dist/contracts/generator.d.ts +63 -0
- package/dist/contracts/index.d.ts +2 -2
- package/dist/contracts/index.js +1 -1
- package/dist/contracts/internal.js +11 -9
- package/dist/contracts/location.d.ts +24 -0
- package/dist/contracts/rows.d.ts +15 -0
- package/dist/dialects/pg/archive-bind.d.ts +22 -0
- package/dist/dialects/pg/column.d.ts +129 -10
- package/dist/dialects/pg/compile.d.ts +1 -0
- package/dist/dialects/pg/custom.d.ts +6 -0
- package/dist/dialects/pg/ddl.d.ts +65 -1
- package/dist/dialects/pg/enum.d.ts +10 -8
- package/dist/dialects/pg/ext/citext.d.ts +14 -0
- package/dist/dialects/pg/ext/citext.js +11 -0
- package/dist/dialects/pg/ext/index.d.ts +52 -0
- package/dist/dialects/pg/ext/index.js +6 -0
- package/dist/dialects/pg/ext/pg-trgm.d.ts +53 -0
- package/dist/dialects/pg/ext/pg-trgm.js +42 -0
- package/dist/dialects/pg/filter-parse.d.ts +19 -0
- package/dist/dialects/pg/filters.d.ts +19 -0
- package/dist/dialects/pg/fn/index.d.ts +107 -0
- package/dist/dialects/pg/fn/index.js +175 -0
- package/dist/dialects/pg/fn/touch.d.ts +14 -0
- package/dist/dialects/pg/index.d.ts +11 -2
- package/dist/dialects/pg/index.js +243 -1062
- package/dist/dialects/pg/introspect.d.ts +10 -1
- package/dist/dialects/pg/keys.d.ts +19 -3
- package/dist/dialects/pg/model.d.ts +223 -2
- package/dist/dialects/pg/operator-fit.d.ts +86 -0
- package/dist/dialects/pg/operators.d.ts +46 -1
- package/dist/dialects/pg/ops/arr-append.d.ts +9 -0
- package/dist/dialects/pg/ops/arr-ns.d.ts +7 -0
- package/dist/dialects/pg/ops/arr-remove.d.ts +9 -0
- package/dist/dialects/pg/ops/containedBy.d.ts +9 -0
- package/dist/dialects/pg/ops/contains.d.ts +8 -4
- package/dist/dialects/pg/ops/hasAnyKey.d.ts +8 -0
- package/dist/dialects/pg/ops/hasKey.d.ts +8 -0
- package/dist/dialects/pg/ops/json-ns.d.ts +6 -0
- package/dist/dialects/pg/ops/json-set.d.ts +12 -0
- package/dist/dialects/pg/ops/matches.d.ts +16 -0
- package/dist/dialects/pg/ops/overlaps.d.ts +9 -0
- package/dist/dialects/pg/ops/path.d.ts +13 -0
- package/dist/dialects/pg/preset.d.ts +76 -0
- package/dist/dialects/pg/relations.d.ts +59 -2
- package/dist/dialects/pg/role/check.d.ts +45 -0
- package/dist/dialects/pg/role/index.d.ts +50 -0
- package/dist/dialects/pg/role/sql.d.ts +44 -0
- package/dist/dialects/pg/schema.d.ts +109 -5
- package/dist/dialects/pg/table.d.ts +137 -11
- package/dist/dialects/pg/temporal.d.ts +9 -7
- package/dist/dialects/pg/tenancy.d.ts +103 -0
- package/dist/dialects/pg/through.d.ts +21 -0
- package/dist/dialects/pg/trait.d.ts +141 -0
- package/dist/dialects/pg/view/client.d.ts +30 -0
- package/dist/dialects/pg/view/depend.d.ts +35 -0
- package/dist/dialects/pg/view/index.d.ts +114 -0
- package/dist/dialects/pg/view/index.js +289 -0
- package/dist/dialects/pg/view/scratch.d.ts +21 -0
- package/dist/dialects/pg/where.d.ts +37 -0
- package/dist/runtime/aggregate.d.ts +25 -0
- package/dist/runtime/archive-handle.d.ts +18 -0
- package/dist/runtime/archive-rules.d.ts +12 -0
- package/dist/runtime/archive.d.ts +73 -0
- package/dist/runtime/batch.d.ts +20 -0
- package/dist/runtime/client.d.ts +114 -5
- package/dist/runtime/conflict.d.ts +2 -1
- package/dist/runtime/exposure.d.ts +27 -0
- package/dist/runtime/hookm.d.ts +39 -0
- package/dist/runtime/ids/index.d.ts +11 -0
- package/dist/runtime/ids/index.js +193 -0
- package/dist/runtime/ids/okid-extended.d.ts +19 -0
- package/dist/runtime/ids/okid-generator.d.ts +21 -0
- package/dist/runtime/ids/okid-shared.d.ts +89 -0
- package/dist/runtime/ids/okid.d.ts +24 -0
- package/dist/runtime/ids/uuid.d.ts +21 -0
- package/dist/runtime/lock.d.ts +22 -0
- package/dist/runtime/operator-sql.d.ts +8 -0
- package/dist/runtime/page.d.ts +25 -0
- package/dist/runtime/pg/bun.d.ts +30 -0
- package/dist/runtime/pg/bun.js +52 -0
- package/dist/runtime/pg/pg.d.ts +29 -0
- package/dist/runtime/pg/pg.js +52 -0
- package/dist/runtime/pg/pglite.js +16 -17
- package/dist/runtime/pg/postgresjs.js +14 -24
- package/dist/runtime/plan.d.ts +146 -7
- package/dist/runtime/preset-stack.d.ts +17 -0
- package/dist/runtime/presets.d.ts +48 -0
- package/dist/runtime/read-stream.d.ts +26 -0
- package/dist/runtime/safety/index.d.ts +159 -0
- package/dist/runtime/safety/index.js +294 -0
- package/dist/runtime/safety-hook.d.ts +42 -0
- package/dist/runtime/server-check.d.ts +34 -0
- package/dist/runtime/tenancy/index.d.ts +37 -0
- package/dist/runtime/tenancy/index.js +368 -0
- package/dist/runtime/trait-read.d.ts +30 -0
- package/dist/runtime/traits/index.d.ts +133 -0
- package/dist/runtime/traits/index.js +646 -0
- package/dist/runtime/transaction.d.ts +19 -0
- package/dist/runtime/tx.d.ts +22 -7
- package/dist/runtime/types.d.ts +376 -27
- package/dist/runtime/validate/bind.d.ts +11 -0
- package/dist/runtime/validate/closed.d.ts +16 -0
- package/dist/runtime/validate/engine.d.ts +41 -0
- package/dist/runtime/validate/hook.d.ts +17 -0
- package/dist/runtime/validate/index.d.ts +21 -0
- package/dist/runtime/validate/index.js +175 -0
- package/dist/runtime/validate/load.d.ts +13 -0
- package/dist/runtime/validate/places.d.ts +41 -0
- package/dist/runtime/validate/rules.d.ts +108 -0
- package/dist/runtime/validate/surface.d.ts +102 -0
- package/dist/runtime/write.d.ts +30 -5
- package/dist/shared/01yr20s5.js +149 -0
- package/dist/shared/0jc3ffzf.js +154 -0
- package/dist/shared/0v1g424p.js +26 -0
- package/dist/shared/1g0drakv.js +225 -0
- package/dist/shared/{kprcwaha.js → 1tfdfvhh.js} +5 -3
- package/dist/shared/{05w44d8g.js → 2ssqrv66.js} +767 -715
- package/dist/shared/3ekj9x92.js +210 -0
- package/dist/shared/49ypnfwt.js +1122 -0
- package/dist/shared/4e4c6vq2.js +62 -0
- package/dist/shared/4m9fn52z.js +70 -0
- package/dist/shared/{ycwz42az.js → 52szzakm.js} +6 -26
- package/dist/shared/5nmdenb6.js +1229 -0
- package/dist/shared/672t5vym.js +12 -0
- package/dist/shared/6bazvqwm.js +86 -0
- package/dist/shared/6w5j844a.js +201 -0
- package/dist/shared/{fgqgsb5z.js → 75xkjv0t.js} +2 -2
- package/dist/shared/7fvtrkwr.js +84 -0
- package/dist/shared/7m88x3e9.js +45 -0
- package/dist/shared/{mtkwv8wx.js → 7p2wbz7f.js} +1 -1
- package/dist/shared/83eaefwr.js +10 -0
- package/dist/shared/94ez8kzh.js +19 -0
- package/dist/shared/96ps4g1z.js +32 -0
- package/dist/shared/{xqbhg6cn.js → 999ade2q.js} +95 -10
- package/dist/shared/9m80mkac.js +158 -0
- package/dist/shared/9x25fxhc.js +150 -0
- package/dist/shared/a5sxz52y.js +13 -0
- package/dist/shared/axhk06q1.js +156 -0
- package/dist/shared/{dynq16vb.js → b066g80h.js} +8 -6
- package/dist/shared/bqha5cg6.js +229 -0
- package/dist/shared/bryqk9k9.js +31 -0
- package/dist/shared/c8aghh05.js +442 -0
- package/dist/shared/c9z5g0fm.js +309 -0
- package/dist/shared/{m3ypagh5.js → dbjej1tw.js} +124 -15
- package/dist/shared/dyj86cmj.js +69 -0
- package/dist/shared/e6wg00wd.js +164 -0
- package/dist/shared/{hadrfb9h.js → edwqqryd.js} +17 -14
- package/dist/shared/{qk3hxfja.js → fptpmvxp.js} +5 -5
- package/dist/shared/fs0ex00p.js +76 -0
- package/dist/shared/{jjb7yht9.js → g4f5kcx9.js} +3 -3
- package/dist/shared/gjthds9j.js +48 -0
- package/dist/shared/hcmdtwgh.js +102 -0
- package/dist/shared/{g5fhqmwe.js → jkc6ws1p.js} +6 -56
- package/dist/shared/{yd1kzwn2.js → jns2wx4t.js} +55 -12
- package/dist/shared/k34e0xf2.js +450 -0
- package/dist/shared/k3ted12y.js +33 -0
- package/dist/shared/k7dwkhvq.js +31 -0
- package/dist/shared/{8b04d28c.js → kgnc8grt.js} +2 -2
- package/dist/shared/{hd293j9g.js → kyxb62mc.js} +14 -2
- package/dist/shared/m78s7898.js +376 -0
- package/dist/shared/m9tv7xn7.js +404 -0
- package/dist/shared/meck53jv.js +99 -0
- package/dist/shared/mt5wswjz.js +90 -0
- package/dist/shared/n0dgs0pb.js +75 -0
- package/dist/shared/n442h54c.js +14 -0
- package/dist/shared/n4jqhpqz.js +27 -0
- package/dist/shared/n7mcc1gk.js +132 -0
- package/dist/shared/ne02ng5c.js +68 -0
- package/dist/shared/{mkjmqjv4.js → nfzc5z0w.js} +2 -104
- package/dist/shared/nsva2a6b.js +42 -0
- package/dist/shared/p24x2334.js +195 -0
- package/dist/shared/qbxzvwwc.js +88 -0
- package/dist/shared/{w8samvk1.js → qybh48nd.js} +1 -1
- package/dist/shared/r6nwkxnt.js +86 -0
- package/dist/shared/{xy79j5hq.js → rrstp3kb.js} +25 -36
- package/dist/shared/rwmrejjz.js +26 -0
- package/dist/shared/{zhc5vmgf.js → s6gqfn5j.js} +2 -2
- package/dist/shared/{523ft3e8.js → scwxrpx2.js} +7 -5
- package/dist/shared/{j5cn2963.js → t4tbsy9h.js} +13 -64
- package/dist/shared/{y9m15dfv.js → t616ynfn.js} +544 -32
- package/dist/shared/{ngk8gj61.js → tbszx8mz.js} +15 -1
- package/dist/shared/th14ygv2.js +69 -0
- package/dist/shared/tmbdywx0.js +178 -0
- package/dist/shared/ty3v3hfk.js +64 -0
- package/dist/shared/wekze34d.js +246 -0
- package/dist/shared/x6wysh83.js +1132 -0
- package/dist/shared/{rgs0st28.js → xrfnq5k8.js} +237 -434
- package/dist/shared/{x5x59srr.js → xva8v7qk.js} +416 -83
- package/dist/shared/{dkn3y60a.js → xw1d69vd.js} +76 -112
- package/dist/shared/y005b761.js +112 -0
- package/dist/shared/ydaz1sv3.js +55 -0
- package/dist/shared/{p0cbr3g2.js → zwmqxb0g.js} +1 -1
- package/dist/tooling/cli.js +40 -12
- package/dist/tooling/migrate/apply.d.ts +16 -0
- package/dist/tooling/migrate/commands.d.ts +12 -1
- package/dist/tooling/migrate/config.d.ts +8 -0
- package/dist/tooling/migrate/doctor.d.ts +25 -0
- package/dist/tooling/migrate/drift.d.ts +19 -0
- package/dist/tooling/migrate/engine.d.ts +36 -0
- package/dist/tooling/migrate/ext.d.ts +17 -0
- package/dist/tooling/migrate/extensions.d.ts +51 -0
- package/dist/tooling/migrate/managed.d.ts +17 -0
- package/dist/tooling/migrate/plan.d.ts +14 -1
- package/dist/tooling/migrate/project.d.ts +25 -1
- package/dist/tooling/migrate/type-name.d.ts +19 -0
- package/package.json +61 -4
- package/dist/shared/gk7cs7sp.js +0 -566
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine-version checks `okm migrate apply` runs before the first statement.
|
|
3
|
+
*
|
|
4
|
+
* The only engine-dependent feature in 0.2 is a `uuidv7()` database default,
|
|
5
|
+
* which Postgres has from 18. Nothing here is reachable from `connect()`.
|
|
6
|
+
*/
|
|
7
|
+
import type { DriverConnection } from "../../contracts/driver.js";
|
|
8
|
+
import type { StoredMigration } from "./files.js";
|
|
9
|
+
/** Where a migration sets a `uuidv7()` default. */
|
|
10
|
+
export type UuidV7Default = {
|
|
11
|
+
readonly migrationId: string;
|
|
12
|
+
readonly stepIndex: number;
|
|
13
|
+
/** `table.column`, or `undefined` when the statement does not name both. */
|
|
14
|
+
readonly column: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Finds the first pending step that sets a `uuidv7()` database default.
|
|
18
|
+
*
|
|
19
|
+
* Only `default uuidv7()` counts, so a string in a data step is not a hit.
|
|
20
|
+
*
|
|
21
|
+
* @param migrations - Migrations in apply order
|
|
22
|
+
* @returns The first hit, or `undefined`
|
|
23
|
+
*/
|
|
24
|
+
export declare function findUuidV7Default(migrations: readonly StoredMigration[]): UuidV7Default | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Refuses a run that would set a `uuidv7()` default on a server that has none.
|
|
27
|
+
*
|
|
28
|
+
* The server is asked only when a step needs it, so a schema without the
|
|
29
|
+
* default costs no round trip. A server below 18 that already has a
|
|
30
|
+
* `uuidv7()` function, such as one the application defined, is accepted.
|
|
31
|
+
*
|
|
32
|
+
* @param connection - The reserved apply connection
|
|
33
|
+
* @param migrations - Migrations in apply order
|
|
34
|
+
* @throws OkmError OKM1812, before any statement of the plan runs
|
|
35
|
+
*/
|
|
36
|
+
export declare function assertUuidV7Available(connection: DriverConnection, migrations: readonly StoredMigration[]): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `okm ext list` and `okm ext check`.
|
|
3
|
+
*
|
|
4
|
+
* Both talk to the selected target. List prints every extension the server
|
|
5
|
+
* can install, and the installed version when one is present. Check compares
|
|
6
|
+
* the schema's declarations with what is installed.
|
|
7
|
+
*/
|
|
8
|
+
import { type InvokeFlags } from "./policy.js";
|
|
9
|
+
/**
|
|
10
|
+
* Runs `list` or `check` against the selected target.
|
|
11
|
+
*
|
|
12
|
+
* @param cwd - Project directory
|
|
13
|
+
* @param command - `list` or `check`
|
|
14
|
+
* @param flags - Target and protection flags
|
|
15
|
+
* @returns Text for stdout, including the trailing newline
|
|
16
|
+
*/
|
|
17
|
+
export declare function extProject(cwd: string, command: "list" | "check", flags: InvokeFlags): Promise<string>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension alters and the apply preflight.
|
|
3
|
+
*
|
|
4
|
+
* Create and drop SQL come from the dialect. An upgrade is `ALTER EXTENSION
|
|
5
|
+
* … UPDATE`, marked `path-unverified` until apply checks
|
|
6
|
+
* `pg_extension_update_paths`. A move is `SET SCHEMA` and only when the
|
|
7
|
+
* declaration is relocatable.
|
|
8
|
+
*/
|
|
9
|
+
import type { CatalogObject } from "../../contracts/catalog/types.js";
|
|
10
|
+
import type { DriverConnection } from "../../contracts/driver.js";
|
|
11
|
+
/** One extension alter. The planner stores it as a plan step. */
|
|
12
|
+
export type ExtensionStep = {
|
|
13
|
+
readonly sql: string;
|
|
14
|
+
readonly class: "expand" | "contract";
|
|
15
|
+
readonly action: "ddl";
|
|
16
|
+
readonly lock: string;
|
|
17
|
+
readonly transactional: boolean;
|
|
18
|
+
readonly path?: "unverified";
|
|
19
|
+
};
|
|
20
|
+
/** Migrations the preflight reads. Only the statement text is used. */
|
|
21
|
+
type MigrationSql = {
|
|
22
|
+
readonly steps: readonly {
|
|
23
|
+
readonly sql: string;
|
|
24
|
+
}[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Upgrade and move steps for extensions whose definition changed.
|
|
28
|
+
*
|
|
29
|
+
* Exact downgrades and moves of a non-relocatable extension are OKM1814.
|
|
30
|
+
* Dropping an extension that an object in the next catalog still uses is
|
|
31
|
+
* OKM1814. `DROP` is never `CASCADE`.
|
|
32
|
+
*
|
|
33
|
+
* @param beforeBy - Previous objects, keyed by identity
|
|
34
|
+
* @param afterBy - Next objects, keyed by identity
|
|
35
|
+
* @param dropKeys - Identities the plan drops
|
|
36
|
+
* @returns Alter steps. Creates and drops stay in the main planner
|
|
37
|
+
*/
|
|
38
|
+
export declare function extensionAlterSteps(beforeBy: ReadonlyMap<string, CatalogObject>, afterBy: ReadonlyMap<string, CatalogObject>, dropKeys: ReadonlySet<string>): ExtensionStep[];
|
|
39
|
+
/**
|
|
40
|
+
* Refuses a migration that names an extension the server cannot install,
|
|
41
|
+
* or an upgrade with no path.
|
|
42
|
+
*
|
|
43
|
+
* The server is asked only when a step creates or upgrades an extension.
|
|
44
|
+
* The check runs before any statement.
|
|
45
|
+
*
|
|
46
|
+
* @param connection - The reserved apply connection
|
|
47
|
+
* @param migrations - Migrations in apply order
|
|
48
|
+
* @throws OkmError OKM1811 when the extension is not available, OKM1814 when the update path is missing
|
|
49
|
+
*/
|
|
50
|
+
export declare function assertExtensionsAvailable(connection: DriverConnection, migrations: readonly MigrationSql[]): Promise<void>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tables OKModel owns: `okm_meta` and `okm_history`.
|
|
3
|
+
*
|
|
4
|
+
* Apply creates them. They are not part of the author schema. Plan, push,
|
|
5
|
+
* check, and doctor omit them on both sides, so a diff neither drops them
|
|
6
|
+
* nor creates them.
|
|
7
|
+
*/
|
|
8
|
+
import type { Catalog } from "../../contracts/catalog/types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Removes the migration history tables and the objects that belong to them.
|
|
11
|
+
*
|
|
12
|
+
* A catalog that has neither is returned as itself.
|
|
13
|
+
*
|
|
14
|
+
* @param source - Catalog about to be diffed or diagnosed
|
|
15
|
+
* @returns The catalog without OKModel's own tables
|
|
16
|
+
*/
|
|
17
|
+
export declare function omitManagedObjects(source: Catalog): Catalog;
|
|
@@ -26,6 +26,19 @@ export type PlanStep = {
|
|
|
26
26
|
readonly action: "ddl" | "backfill";
|
|
27
27
|
readonly lock: string;
|
|
28
28
|
readonly transactional: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Set on an extension upgrade the planner could not check.
|
|
31
|
+
*
|
|
32
|
+
* Apply reads `pg_extension_update_paths` before any statement and refuses
|
|
33
|
+
* a missing path. Offline `okm migrate plan` leaves this unverified.
|
|
34
|
+
*/
|
|
35
|
+
readonly path?: "unverified";
|
|
36
|
+
/**
|
|
37
|
+
* Set on `CREATE OR REPLACE` of a function whose signature did not change.
|
|
38
|
+
*
|
|
39
|
+
* The statement is expand. The flag says the body or the settings changed.
|
|
40
|
+
*/
|
|
41
|
+
readonly behavior?: "change";
|
|
29
42
|
};
|
|
30
43
|
/** A named plan and the class of its strictest step. */
|
|
31
44
|
export type MigrationPlan = {
|
|
@@ -49,7 +62,7 @@ export type PlanRequest = {
|
|
|
49
62
|
* @param request - Catalogs, declared renames, and `--replace` flags
|
|
50
63
|
* @returns Steps in apply order, with one class for the plan
|
|
51
64
|
*/
|
|
52
|
-
export declare function planMigration(
|
|
65
|
+
export declare function planMigration(input: PlanRequest): MigrationPlan;
|
|
53
66
|
/**
|
|
54
67
|
* Prints a plan. The text is SQL plus class comments, never TypeScript.
|
|
55
68
|
*
|
|
@@ -5,9 +5,13 @@
|
|
|
5
5
|
* `.catalog`, which runs that validation. Generate writes SQL only.
|
|
6
6
|
*/
|
|
7
7
|
import { type DeclaredRename } from "../../dialects/pg/declarations.js";
|
|
8
|
+
import type { BuiltSchema } from "../../dialects/pg/schema.js";
|
|
9
|
+
import type { AnyTable } from "../../dialects/pg/table.js";
|
|
8
10
|
import type { Catalog } from "../../contracts/catalog/types.js";
|
|
9
11
|
import { type MigrateConfig } from "./config.js";
|
|
12
|
+
import { type InvokeFlags } from "./policy.js";
|
|
10
13
|
import { type MigrationPlan } from "./plan.js";
|
|
14
|
+
type Built = BuiltSchema<readonly AnyTable[]>;
|
|
11
15
|
/**
|
|
12
16
|
* Validates the schema and writes `.okm/`.
|
|
13
17
|
*
|
|
@@ -38,9 +42,14 @@ export declare function planProject(cwd: string, name: string, flags: readonly s
|
|
|
38
42
|
/**
|
|
39
43
|
* Validates the schema, then reports stale renames and unlisted table files.
|
|
40
44
|
*
|
|
45
|
+
* When exactly one target is configured, or `--target` names one, a database
|
|
46
|
+
* that already has `okm_meta` is compared with the schema. A difference is
|
|
47
|
+
* OKM1520. Several targets and no `--target` skip that comparison.
|
|
48
|
+
*
|
|
41
49
|
* @param cwd - Project directory
|
|
50
|
+
* @param flags - `--target`, when the caller passed one
|
|
42
51
|
*/
|
|
43
|
-
export declare function checkProject(cwd: string): Promise<void>;
|
|
52
|
+
export declare function checkProject(cwd: string, flags?: InvokeFlags): Promise<void>;
|
|
44
53
|
/**
|
|
45
54
|
* Table files whose names do not appear in the schema module.
|
|
46
55
|
*
|
|
@@ -60,6 +69,20 @@ export declare function projectHead(cwd: string): Promise<{
|
|
|
60
69
|
readonly catalog: Catalog;
|
|
61
70
|
readonly renames: readonly DeclaredRename[];
|
|
62
71
|
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Loads the config, the schema, and the previous catalog snapshot.
|
|
74
|
+
*
|
|
75
|
+
* A `renamedFrom` that the previous catalog does not contain is OKM1020.
|
|
76
|
+
*
|
|
77
|
+
* @param cwd - Project directory
|
|
78
|
+
* @returns The loaded project
|
|
79
|
+
*/
|
|
80
|
+
export declare function openProject(cwd: string): Promise<{
|
|
81
|
+
readonly config: MigrateConfig;
|
|
82
|
+
readonly built: Built;
|
|
83
|
+
readonly previous: Catalog;
|
|
84
|
+
readonly renames: readonly DeclaredRename[];
|
|
85
|
+
}>;
|
|
63
86
|
/**
|
|
64
87
|
* Loads `okmodel.config.ts`.
|
|
65
88
|
*
|
|
@@ -67,3 +90,4 @@ export declare function projectHead(cwd: string): Promise<{
|
|
|
67
90
|
* @returns The config object
|
|
68
91
|
*/
|
|
69
92
|
export declare function loadConfig(cwd: string): Promise<MigrateConfig>;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One spelling for a SQL type name in a diff (D191).
|
|
3
|
+
*
|
|
4
|
+
* The catalog keeps the spelling the schema wrote. Introspection keeps
|
|
5
|
+
* `format_type`. Both sides of a comparison pass through here, so
|
|
6
|
+
* `timestamptz` and `timestamp with time zone` are one type. A different
|
|
7
|
+
* length, precision, or type stays different. An unknown name is returned
|
|
8
|
+
* as written.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Maps a schema spelling or a `format_type` spelling to the long form.
|
|
12
|
+
*
|
|
13
|
+
* Modifiers and array ranks stay. `varchar(20)[]` becomes
|
|
14
|
+
* `character varying(20)[]`.
|
|
15
|
+
*
|
|
16
|
+
* @param typeName - Type name from a catalog definition
|
|
17
|
+
* @returns The Postgres long spelling
|
|
18
|
+
*/
|
|
19
|
+
export declare function canonicalTypeName(typeName: string): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "okmodel",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "okmodel is a catalog-first TypeScript ORM, PostgreSQL first.
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "okmodel is a catalog-first TypeScript ORM, PostgreSQL first.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"migrations",
|
|
7
7
|
"orm",
|
|
@@ -57,10 +57,58 @@
|
|
|
57
57
|
"./pg/pglite": {
|
|
58
58
|
"types": "./dist/runtime/pg/pglite.d.ts",
|
|
59
59
|
"import": "./dist/runtime/pg/pglite.js"
|
|
60
|
+
},
|
|
61
|
+
"./pg/pg": {
|
|
62
|
+
"types": "./dist/runtime/pg/pg.d.ts",
|
|
63
|
+
"import": "./dist/runtime/pg/pg.js"
|
|
64
|
+
},
|
|
65
|
+
"./pg/bun": {
|
|
66
|
+
"types": "./dist/runtime/pg/bun.d.ts",
|
|
67
|
+
"import": "./dist/runtime/pg/bun.js"
|
|
68
|
+
},
|
|
69
|
+
"./ids": {
|
|
70
|
+
"types": "./dist/runtime/ids/index.d.ts",
|
|
71
|
+
"import": "./dist/runtime/ids/index.js"
|
|
72
|
+
},
|
|
73
|
+
"./safety": {
|
|
74
|
+
"types": "./dist/runtime/safety/index.d.ts",
|
|
75
|
+
"import": "./dist/runtime/safety/index.js"
|
|
76
|
+
},
|
|
77
|
+
"./traits": {
|
|
78
|
+
"types": "./dist/runtime/traits/index.d.ts",
|
|
79
|
+
"import": "./dist/runtime/traits/index.js"
|
|
80
|
+
},
|
|
81
|
+
"./tenancy": {
|
|
82
|
+
"types": "./dist/runtime/tenancy/index.d.ts",
|
|
83
|
+
"import": "./dist/runtime/tenancy/index.js"
|
|
84
|
+
},
|
|
85
|
+
"./validate": {
|
|
86
|
+
"types": "./dist/runtime/validate/index.d.ts",
|
|
87
|
+
"import": "./dist/runtime/validate/index.js"
|
|
88
|
+
},
|
|
89
|
+
"./ext": {
|
|
90
|
+
"types": "./dist/dialects/pg/ext/index.d.ts",
|
|
91
|
+
"import": "./dist/dialects/pg/ext/index.js"
|
|
92
|
+
},
|
|
93
|
+
"./fn": {
|
|
94
|
+
"types": "./dist/dialects/pg/fn/index.d.ts",
|
|
95
|
+
"import": "./dist/dialects/pg/fn/index.js"
|
|
96
|
+
},
|
|
97
|
+
"./view": {
|
|
98
|
+
"types": "./dist/dialects/pg/view/index.d.ts",
|
|
99
|
+
"import": "./dist/dialects/pg/view/index.js"
|
|
100
|
+
},
|
|
101
|
+
"./pg/citext": {
|
|
102
|
+
"types": "./dist/dialects/pg/ext/citext.d.ts",
|
|
103
|
+
"import": "./dist/dialects/pg/ext/citext.js"
|
|
104
|
+
},
|
|
105
|
+
"./pg/pg_trgm": {
|
|
106
|
+
"types": "./dist/dialects/pg/ext/pg-trgm.d.ts",
|
|
107
|
+
"import": "./dist/dialects/pg/ext/pg-trgm.js"
|
|
60
108
|
}
|
|
61
109
|
},
|
|
62
110
|
"scripts": {
|
|
63
|
-
"build": "rm -rf dist && bun build ./src/contracts/index.ts ./src/contracts/internal.ts ./src/dialects/pg/index.ts ./src/runtime/pg/postgresjs.ts ./src/runtime/pg/pglite.ts ./src/tooling/migrate/index.ts ./src/tooling/cli.ts --outdir ./dist --root ./src --format esm --target node --splitting --chunk-naming=shared/[hash].js --external postgres --external @electric-sql/pglite && bunx tsc -p tsconfig.build.json && bun ./scripts/write-bin-wrappers.ts",
|
|
111
|
+
"build": "rm -rf dist && bun build ./src/contracts/index.ts ./src/contracts/internal.ts ./src/dialects/pg/index.ts ./src/runtime/pg/postgresjs.ts ./src/runtime/pg/pglite.ts ./src/runtime/pg/pg.ts ./src/runtime/pg/bun.ts ./src/runtime/ids/index.ts ./src/runtime/safety/index.ts ./src/runtime/traits/index.ts ./src/runtime/tenancy/index.ts ./src/runtime/validate/index.ts ./src/dialects/pg/ext/index.ts ./src/dialects/pg/fn/index.ts ./src/dialects/pg/view/index.ts ./src/dialects/pg/ext/citext.ts ./src/dialects/pg/ext/pg-trgm.ts ./src/tooling/migrate/index.ts ./src/tooling/cli.ts --outdir ./dist --root ./src --format esm --target node --splitting --chunk-naming=shared/[hash].js --external postgres --external @electric-sql/pglite --external pg --external bun && bunx tsc -p tsconfig.build.json && bun ./scripts/write-bin-wrappers.ts",
|
|
64
112
|
"driver-bench": "bun ./scripts/driver-bench.ts",
|
|
65
113
|
"typecheck": "bunx tsc --noEmit -p tsconfig.json",
|
|
66
114
|
"editor-check": "bun ./scripts/editor-check.ts",
|
|
@@ -70,6 +118,8 @@
|
|
|
70
118
|
"format:check": "oxfmt --check",
|
|
71
119
|
"layers-check": "bun ./scripts/layers-check.ts",
|
|
72
120
|
"core-purity": "bun ./scripts/core-purity.ts",
|
|
121
|
+
"okid-drift": "bun ./scripts/okid-drift.ts",
|
|
122
|
+
"test:runtimes": "bun ./scripts/runtimes.ts",
|
|
73
123
|
"docs:check": "bun ./scripts/docs-check.ts",
|
|
74
124
|
"readme:check": "bun ./scripts/readme-check.ts",
|
|
75
125
|
"compiler-api": "bun ./scripts/compiler-api.ts",
|
|
@@ -81,7 +131,7 @@
|
|
|
81
131
|
"test:postgres": "bun ./scripts/postgres-suite.ts",
|
|
82
132
|
"test:tarball": "bun ./scripts/tarball-smoke.ts",
|
|
83
133
|
"verify": "bun ./scripts/verify.ts",
|
|
84
|
-
"check": "bun run format:check && bun run lint && bun run typecheck && bun run editor-check && bun run type-cost && bun run layers-check && bun run core-purity && bun run docs:check && bun run readme:check && bun run compiler-api && bun run bundle-purity && bun run build && bun test && bun run publint && bun run attw && bun run size",
|
|
134
|
+
"check": "bun run format:check && bun run lint && bun run typecheck && bun run editor-check && bun run type-cost && bun run layers-check && bun run core-purity && bun run okid-drift && bun run docs:check && bun run readme:check && bun run compiler-api && bun run bundle-purity && bun run build && bun test && bun run test:runtimes && bun run publint && bun run attw && bun run size",
|
|
85
135
|
"bump": "bun ./scripts/bump-version.ts",
|
|
86
136
|
"release-check": "bun ./scripts/release-check.ts",
|
|
87
137
|
"db:up": "bun ./packages/harness/src/docker-cli.ts up",
|
|
@@ -108,14 +158,21 @@
|
|
|
108
158
|
},
|
|
109
159
|
"peerDependencies": {
|
|
110
160
|
"@electric-sql/pglite": "^0.5.8",
|
|
161
|
+
"pg": "^8.16.0",
|
|
111
162
|
"postgres": "^3.4.9"
|
|
112
163
|
},
|
|
113
164
|
"peerDependenciesMeta": {
|
|
114
165
|
"@electric-sql/pglite": {
|
|
115
166
|
"optional": true
|
|
116
167
|
},
|
|
168
|
+
"pg": {
|
|
169
|
+
"optional": true
|
|
170
|
+
},
|
|
117
171
|
"postgres": {
|
|
118
172
|
"optional": true
|
|
119
173
|
}
|
|
174
|
+
},
|
|
175
|
+
"engines": {
|
|
176
|
+
"node": ">=22"
|
|
120
177
|
}
|
|
121
178
|
}
|