okmodel 0.0.0 → 0.1.1
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 +246 -1
- package/dist/adapters/capabilities.d.ts +62 -0
- package/dist/adapters/error.d.ts +91 -0
- package/dist/adapters/failure.d.ts +39 -0
- package/dist/adapters/pg/batch.d.ts +36 -0
- package/dist/adapters/pg/call.d.ts +59 -0
- package/dist/adapters/pg/pglite.d.ts +21 -0
- package/dist/adapters/pg/postgres-extra.d.ts +43 -0
- package/dist/adapters/pg/postgresjs.d.ts +95 -0
- package/dist/adapters/pg/result.d.ts +30 -0
- package/dist/contracts/catalog/build.d.ts +18 -0
- package/dist/contracts/catalog/document.d.ts +79 -0
- package/dist/contracts/catalog/enum.d.ts +35 -0
- package/dist/contracts/catalog/identifier.d.ts +71 -0
- package/dist/contracts/catalog/identity.d.ts +98 -0
- package/dist/contracts/catalog/index.d.ts +11 -0
- package/dist/contracts/catalog/json.d.ts +17 -0
- package/dist/contracts/catalog/object.d.ts +142 -0
- package/dist/contracts/catalog/order.d.ts +43 -0
- package/dist/contracts/catalog/rewrite.d.ts +18 -0
- package/dist/contracts/catalog/types.d.ts +292 -0
- package/dist/contracts/catalog/words.d.ts +13 -0
- package/dist/contracts/connection.d.ts +33 -0
- package/dist/contracts/driver.d.ts +163 -0
- package/dist/contracts/error.d.ts +298 -0
- package/dist/contracts/index.d.ts +11 -0
- package/dist/contracts/index.js +16 -0
- package/dist/contracts/internal.d.ts +15 -0
- package/dist/contracts/internal.js +68 -0
- package/dist/contracts/nearest.d.ts +15 -0
- package/dist/contracts/rows.d.ts +84 -0
- package/dist/contracts/sha256.d.ts +14 -0
- package/dist/contracts/utf8.d.ts +33 -0
- package/dist/dialects/pg/array-literal.d.ts +25 -0
- package/dist/dialects/pg/bool.d.ts +46 -0
- package/dist/dialects/pg/column.d.ts +386 -0
- package/dist/dialects/pg/compile.d.ts +81 -0
- package/dist/dialects/pg/custom.d.ts +21 -0
- package/dist/dialects/pg/ddl.d.ts +70 -0
- package/dist/dialects/pg/decimal.d.ts +62 -0
- package/dist/dialects/pg/declarations.d.ts +34 -0
- package/dist/dialects/pg/emit.d.ts +18 -0
- package/dist/dialects/pg/enum.d.ts +30 -0
- package/dist/dialects/pg/errors.d.ts +30 -0
- package/dist/dialects/pg/finite.d.ts +15 -0
- package/dist/dialects/pg/geometry.d.ts +55 -0
- package/dist/dialects/pg/index.d.ts +45 -0
- package/dist/dialects/pg/index.js +1821 -0
- package/dist/dialects/pg/integer.d.ts +96 -0
- package/dist/dialects/pg/introspect.d.ts +43 -0
- package/dist/dialects/pg/json.d.ts +43 -0
- package/dist/dialects/pg/keys.d.ts +32 -0
- package/dist/dialects/pg/misuse.d.ts +31 -0
- package/dist/dialects/pg/model.d.ts +71 -0
- package/dist/dialects/pg/namespace.d.ts +63 -0
- package/dist/dialects/pg/network.d.ts +28 -0
- package/dist/dialects/pg/operators.d.ts +71 -0
- package/dist/dialects/pg/ops/between.d.ts +10 -0
- package/dist/dialects/pg/ops/contains.d.ts +8 -0
- package/dist/dialects/pg/ops/endsWith.d.ts +8 -0
- package/dist/dialects/pg/ops/eq.d.ts +9 -0
- package/dist/dialects/pg/ops/every.d.ts +9 -0
- package/dist/dialects/pg/ops/gt.d.ts +9 -0
- package/dist/dialects/pg/ops/gte.d.ts +9 -0
- package/dist/dialects/pg/ops/has.d.ts +9 -0
- package/dist/dialects/pg/ops/ilike.d.ts +8 -0
- package/dist/dialects/pg/ops/inList.d.ts +9 -0
- package/dist/dialects/pg/ops/inc.d.ts +13 -0
- package/dist/dialects/pg/ops/like.d.ts +8 -0
- package/dist/dialects/pg/ops/lt.d.ts +9 -0
- package/dist/dialects/pg/ops/lte.d.ts +9 -0
- package/dist/dialects/pg/ops/none.d.ts +9 -0
- package/dist/dialects/pg/ops/not.d.ts +9 -0
- package/dist/dialects/pg/ops/notIn.d.ts +9 -0
- package/dist/dialects/pg/ops/or.d.ts +9 -0
- package/dist/dialects/pg/ops/startsWith.d.ts +8 -0
- package/dist/dialects/pg/quote.d.ts +24 -0
- package/dist/dialects/pg/range.d.ts +50 -0
- package/dist/dialects/pg/relations.d.ts +45 -0
- package/dist/dialects/pg/schema.d.ts +77 -0
- package/dist/dialects/pg/search.d.ts +23 -0
- package/dist/dialects/pg/table.d.ts +201 -0
- package/dist/dialects/pg/temporal.d.ts +211 -0
- package/dist/dialects/pg/text.d.ts +44 -0
- package/dist/dialects/pg/time.d.ts +46 -0
- package/dist/okm.js +2 -0
- package/dist/okmodel.js +2 -0
- package/dist/runtime/client.d.ts +47 -0
- package/dist/runtime/conflict.d.ts +38 -0
- package/dist/runtime/drift-detail.d.ts +32 -0
- package/dist/runtime/drift.d.ts +29 -0
- package/dist/runtime/include.d.ts +15 -0
- package/dist/runtime/pg/pglite.d.ts +25 -0
- package/dist/runtime/pg/pglite.js +48 -0
- package/dist/runtime/pg/postgresjs.d.ts +29 -0
- package/dist/runtime/pg/postgresjs.js +62 -0
- package/dist/runtime/plan.d.ts +167 -0
- package/dist/runtime/tx.d.ts +29 -0
- package/dist/runtime/types.d.ts +385 -0
- package/dist/runtime/write.d.ts +48 -0
- package/dist/shared/05w44d8g.js +1524 -0
- package/dist/shared/523ft3e8.js +171 -0
- package/dist/shared/8b04d28c.js +14 -0
- package/dist/shared/cn0n68ft.js +16 -0
- package/dist/shared/dkn3y60a.js +374 -0
- package/dist/shared/dynq16vb.js +81 -0
- package/dist/shared/fgqgsb5z.js +281 -0
- package/dist/shared/g5fhqmwe.js +188 -0
- package/dist/shared/gk7cs7sp.js +566 -0
- package/dist/shared/hadrfb9h.js +398 -0
- package/dist/shared/hd293j9g.js +98 -0
- package/dist/shared/j5cn2963.js +701 -0
- package/dist/shared/jjb7yht9.js +37 -0
- package/dist/shared/kprcwaha.js +30 -0
- package/dist/shared/m3ypagh5.js +347 -0
- package/dist/shared/mkjmqjv4.js +456 -0
- package/dist/shared/mtkwv8wx.js +18 -0
- package/dist/shared/ngk8gj61.js +40 -0
- package/dist/shared/p0cbr3g2.js +79 -0
- package/dist/shared/qk3hxfja.js +83 -0
- package/dist/shared/rgs0st28.js +1066 -0
- package/dist/shared/w8samvk1.js +18 -0
- package/dist/shared/x5x59srr.js +566 -0
- package/dist/shared/xqbhg6cn.js +119 -0
- package/dist/shared/xy79j5hq.js +177 -0
- package/dist/shared/y9m15dfv.js +888 -0
- package/dist/shared/ycwz42az.js +412 -0
- package/dist/shared/yd1kzwn2.js +148 -0
- package/dist/shared/zhc5vmgf.js +257 -0
- package/dist/tooling/cli.d.ts +1 -0
- package/dist/tooling/cli.js +193 -0
- package/dist/tooling/errors/registry.d.ts +33 -0
- package/dist/tooling/migrate/apply.d.ts +86 -0
- package/dist/tooling/migrate/commands.d.ts +21 -0
- package/dist/tooling/migrate/config.d.ts +48 -0
- package/dist/tooling/migrate/dev.d.ts +16 -0
- package/dist/tooling/migrate/equal.d.ts +15 -0
- package/dist/tooling/migrate/files.d.ts +19 -0
- package/dist/tooling/migrate/index.d.ts +7 -0
- package/dist/tooling/migrate/index.js +7 -0
- package/dist/tooling/migrate/plan.d.ts +76 -0
- package/dist/tooling/migrate/policy.d.ts +78 -0
- package/dist/tooling/migrate/project.d.ts +69 -0
- package/dist/tooling/migrate/status.d.ts +74 -0
- package/dist/tooling/migrate/values.d.ts +29 -0
- package/package.json +109 -7
- package/dist/index.js +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry for `okmodel/migrate`.
|
|
3
|
+
*
|
|
4
|
+
* `defineConfig` and its types. The CLI imports planning and apply helpers
|
|
5
|
+
* from their modules, so those names are not exported.
|
|
6
|
+
*/
|
|
7
|
+
export { defineConfig, type MigrateConfig, type TargetInput } from "./config.js";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diffs two catalogs into an ordered, classified plan.
|
|
3
|
+
*
|
|
4
|
+
* Renames are applied to a copy of the previous catalog before the diff, so
|
|
5
|
+
* a declared rename is not a drop and an add. An unexplained drop-and-add is
|
|
6
|
+
* OKM1530. The planner never prompts.
|
|
7
|
+
*
|
|
8
|
+
* Picklist and enum removals are expand `UPDATE`s plus a contract swap
|
|
9
|
+
* (D131). Those data steps are plain statements here. Batching them is P52.
|
|
10
|
+
*/
|
|
11
|
+
import type { Catalog } from "../../contracts/catalog/types.js";
|
|
12
|
+
import type { DeclaredRename } from "../../dialects/pg/declarations.js";
|
|
13
|
+
import { type Replacement } from "./values.js";
|
|
14
|
+
/** Expand, contract, or a step that is neither. */
|
|
15
|
+
export type MigrationClass = "expand" | "contract" | "unclassified";
|
|
16
|
+
/**
|
|
17
|
+
* One statement in a plan.
|
|
18
|
+
*
|
|
19
|
+
* `backfill` is data; P16B runs it as written. `transactional: false` marks a
|
|
20
|
+
* step that cannot share a transaction with a later use (`ALTER TYPE … ADD
|
|
21
|
+
* VALUE`, spec 19.2).
|
|
22
|
+
*/
|
|
23
|
+
export type PlanStep = {
|
|
24
|
+
readonly sql: string;
|
|
25
|
+
readonly class: MigrationClass;
|
|
26
|
+
readonly action: "ddl" | "backfill";
|
|
27
|
+
readonly lock: string;
|
|
28
|
+
readonly transactional: boolean;
|
|
29
|
+
};
|
|
30
|
+
/** A named plan and the class of its strictest step. */
|
|
31
|
+
export type MigrationPlan = {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly class: MigrationClass;
|
|
34
|
+
readonly steps: readonly PlanStep[];
|
|
35
|
+
};
|
|
36
|
+
/** What the planner needs besides the two catalogs. */
|
|
37
|
+
export type PlanRequest = {
|
|
38
|
+
readonly before: Catalog;
|
|
39
|
+
readonly after: Catalog;
|
|
40
|
+
readonly renames?: readonly DeclaredRename[];
|
|
41
|
+
readonly replacements?: readonly Replacement[];
|
|
42
|
+
readonly schema?: string;
|
|
43
|
+
/** Concrete schema written into the SQL. Identities stay logical. */
|
|
44
|
+
readonly name?: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Builds a plan from catalog `before` to catalog `after`.
|
|
48
|
+
*
|
|
49
|
+
* @param request - Catalogs, declared renames, and `--replace` flags
|
|
50
|
+
* @returns Steps in apply order, with one class for the plan
|
|
51
|
+
*/
|
|
52
|
+
export declare function planMigration(request: PlanRequest): MigrationPlan;
|
|
53
|
+
/**
|
|
54
|
+
* Prints a plan. The text is SQL plus class comments, never TypeScript.
|
|
55
|
+
*
|
|
56
|
+
* @param plan - Plan from {@link planMigration}
|
|
57
|
+
* @returns The text `okm generate` writes and `okm migrate plan` prints
|
|
58
|
+
*/
|
|
59
|
+
export declare function formatPlan(plan: MigrationPlan): string;
|
|
60
|
+
/**
|
|
61
|
+
* Reads a plan written by {@link formatPlan}.
|
|
62
|
+
*
|
|
63
|
+
* @param text - SQL file text
|
|
64
|
+
* @returns The plan. The header class is kept when the file has no steps
|
|
65
|
+
*/
|
|
66
|
+
export declare function parsePlan(text: string): MigrationPlan;
|
|
67
|
+
/**
|
|
68
|
+
* Renames whose previous name is absent from the last snapshot.
|
|
69
|
+
*
|
|
70
|
+
* No snapshot means nothing is stale: there is no history to disagree with.
|
|
71
|
+
*
|
|
72
|
+
* @param previous - Last migration catalog, or `undefined` when there is none
|
|
73
|
+
* @param renames - Declarations on the current schema
|
|
74
|
+
* @returns Messages, empty when every rename still matches
|
|
75
|
+
*/
|
|
76
|
+
export declare function staleRenames(previous: Catalog | undefined, renames: readonly DeclaredRename[]): readonly string[];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Target names, the aliasing guard, pooler refusal, and the protection policy.
|
|
3
|
+
*
|
|
4
|
+
* One function, {@link assertTargetPolicy}, is what every entry point calls.
|
|
5
|
+
* Protection is a property of the target. It is not read from `NODE_ENV`.
|
|
6
|
+
*/
|
|
7
|
+
import type { MigrateConfig } from "./config.js";
|
|
8
|
+
/** An operation the policy table allows or blocks. */
|
|
9
|
+
export type PolicyOperation = "plan" | "status" | "check" | "drift" | "verify" | "pull" | "catalog-export" | "inspect" | "expand" | "reference" | "provision" | "contract" | "unclassified" | "push" | "backfill" | "seed" | "history-repair" | "drop" | "rollback";
|
|
10
|
+
/** Flags shared by commands that touch a target. */
|
|
11
|
+
export type InvokeFlags = {
|
|
12
|
+
readonly target?: string;
|
|
13
|
+
readonly allowProtected: boolean;
|
|
14
|
+
readonly allowPooler: boolean;
|
|
15
|
+
readonly lockTimeoutMs?: number;
|
|
16
|
+
readonly statementTimeoutMs?: number;
|
|
17
|
+
};
|
|
18
|
+
/** A resolved migration target. The plan stores the name, not the URL. */
|
|
19
|
+
export type TargetRecord = {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly url: string;
|
|
22
|
+
readonly protected: boolean;
|
|
23
|
+
readonly host: string;
|
|
24
|
+
readonly port: string;
|
|
25
|
+
readonly database: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Refuses an operation the target's protection does not allow.
|
|
29
|
+
*
|
|
30
|
+
* `--allow-protected` is per invocation. It does not lift `drop` or `rollback`.
|
|
31
|
+
* `provision` is allowed here; the caller still refuses a target that is not empty.
|
|
32
|
+
*
|
|
33
|
+
* @param target - Name and protection flag
|
|
34
|
+
* @param operation - What the entry point is about to do
|
|
35
|
+
* @param allowProtected - The invocation passed `--allow-protected`
|
|
36
|
+
*/
|
|
37
|
+
export declare function assertTargetPolicy(target: {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly protected: boolean;
|
|
40
|
+
}, operation: PolicyOperation, allowProtected?: boolean): void;
|
|
41
|
+
/**
|
|
42
|
+
* Fails when targets on one host, port, and database disagree about protection.
|
|
43
|
+
*
|
|
44
|
+
* Two unprotected targets may share a database. The comparison ignores schema.
|
|
45
|
+
*
|
|
46
|
+
* @param targets - Resolved targets
|
|
47
|
+
*/
|
|
48
|
+
export declare function assertTargetAlias(targets: readonly TargetRecord[]): void;
|
|
49
|
+
/**
|
|
50
|
+
* Refuses a known pooler URL.
|
|
51
|
+
*
|
|
52
|
+
* Apply needs one session for the advisory lock. A transaction-mode pooler
|
|
53
|
+
* does not keep that session. `--allow-pooler` is the override.
|
|
54
|
+
*
|
|
55
|
+
* @param url - Target URL
|
|
56
|
+
* @param allowPooler - The invocation opted in
|
|
57
|
+
*/
|
|
58
|
+
export declare function assertDirectConnection(url: string, allowPooler: boolean): void;
|
|
59
|
+
/**
|
|
60
|
+
* Lists configured targets.
|
|
61
|
+
*
|
|
62
|
+
* `database` is the target named `default`. `targets` replaces it. Setting
|
|
63
|
+
* both is refused.
|
|
64
|
+
*
|
|
65
|
+
* @param config - Project config
|
|
66
|
+
* @returns Targets in name order
|
|
67
|
+
*/
|
|
68
|
+
export declare function listTargets(config: MigrateConfig): readonly TargetRecord[];
|
|
69
|
+
/**
|
|
70
|
+
* Picks the target a command that must not guess will use.
|
|
71
|
+
*
|
|
72
|
+
* One configured target is that target. Several require `name` (OKM1853).
|
|
73
|
+
*
|
|
74
|
+
* @param config - Project config
|
|
75
|
+
* @param name - `--target`, when the command passed one
|
|
76
|
+
* @returns The target
|
|
77
|
+
*/
|
|
78
|
+
export declare function selectTarget(config: MigrateConfig, name: string | undefined): TargetRecord;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `okm build`, `okm generate`, `okm check`, and `okm migrate plan`.
|
|
3
|
+
*
|
|
4
|
+
* Build writes the catalog it already validated. Check and dev read
|
|
5
|
+
* `.catalog`, which runs that validation. Generate writes SQL only.
|
|
6
|
+
*/
|
|
7
|
+
import { type DeclaredRename } from "../../dialects/pg/declarations.js";
|
|
8
|
+
import type { Catalog } from "../../contracts/catalog/types.js";
|
|
9
|
+
import { type MigrateConfig } from "./config.js";
|
|
10
|
+
import { type MigrationPlan } from "./plan.js";
|
|
11
|
+
/**
|
|
12
|
+
* Validates the schema and writes `.okm/`.
|
|
13
|
+
*
|
|
14
|
+
* @param cwd - Project directory
|
|
15
|
+
* @returns The output directory
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildProject(cwd: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Plans the current schema against the latest snapshot and writes SQL.
|
|
20
|
+
*
|
|
21
|
+
* An empty plan writes nothing. The file is SQL, not TypeScript.
|
|
22
|
+
*
|
|
23
|
+
* @param cwd - Project directory
|
|
24
|
+
* @param name - Migration name
|
|
25
|
+
* @param flags - `--replace` values
|
|
26
|
+
* @returns The SQL path, or `undefined` when nothing changed
|
|
27
|
+
*/
|
|
28
|
+
export declare function generateProject(cwd: string, name: string, flags: readonly string[]): Promise<string | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* Plans and returns the text. Nothing is written.
|
|
31
|
+
*
|
|
32
|
+
* @param cwd - Project directory
|
|
33
|
+
* @param name - Plan name
|
|
34
|
+
* @param flags - `--replace` values
|
|
35
|
+
* @returns The plan
|
|
36
|
+
*/
|
|
37
|
+
export declare function planProject(cwd: string, name: string, flags: readonly string[]): Promise<MigrationPlan>;
|
|
38
|
+
/**
|
|
39
|
+
* Validates the schema, then reports stale renames and unlisted table files.
|
|
40
|
+
*
|
|
41
|
+
* @param cwd - Project directory
|
|
42
|
+
*/
|
|
43
|
+
export declare function checkProject(cwd: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Table files whose names do not appear in the schema module.
|
|
46
|
+
*
|
|
47
|
+
* @param schemaSource - Source text of the schema module
|
|
48
|
+
* @param fileNames - File names in the tables directory
|
|
49
|
+
* @returns Files `okm check` reports as OKM1024
|
|
50
|
+
*/
|
|
51
|
+
export declare function unlistedTableFiles(schemaSource: string, fileNames: readonly string[]): readonly string[];
|
|
52
|
+
/**
|
|
53
|
+
* The catalogs `okm push` diffs, after stale renames are refused.
|
|
54
|
+
*
|
|
55
|
+
* @param cwd - Project directory
|
|
56
|
+
* @returns The previous snapshot, the current catalog, and declared renames
|
|
57
|
+
*/
|
|
58
|
+
export declare function projectHead(cwd: string): Promise<{
|
|
59
|
+
readonly previous: Catalog;
|
|
60
|
+
readonly catalog: Catalog;
|
|
61
|
+
readonly renames: readonly DeclaredRename[];
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Loads `okmodel.config.ts`.
|
|
65
|
+
*
|
|
66
|
+
* @param cwd - Project directory
|
|
67
|
+
* @returns The config object
|
|
68
|
+
*/
|
|
69
|
+
export declare function loadConfig(cwd: string): Promise<MigrateConfig>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `okm migrate status`.
|
|
3
|
+
*
|
|
4
|
+
* One row per target: version, catalog hash, state, and a separate protected
|
|
5
|
+
* column. The state is current, behind by expand, behind by contract, ahead,
|
|
6
|
+
* or failed at a step.
|
|
7
|
+
*/
|
|
8
|
+
import type { MigrationClass } from "./plan.js";
|
|
9
|
+
import type { StoredMigration } from "./files.js";
|
|
10
|
+
import { type InvokeFlags } from "./policy.js";
|
|
11
|
+
/** One status row. `protected` is its own column, not a state. */
|
|
12
|
+
export type TargetStatus = {
|
|
13
|
+
readonly target: string;
|
|
14
|
+
readonly version: string;
|
|
15
|
+
readonly catalogHash: string;
|
|
16
|
+
readonly state: string;
|
|
17
|
+
readonly protected: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** A checkpoint row the state function reads. */
|
|
20
|
+
export type StatusHistory = {
|
|
21
|
+
readonly migrationId: string;
|
|
22
|
+
readonly stepIndex: number;
|
|
23
|
+
readonly class: MigrationClass;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Decides the status state from files and history.
|
|
27
|
+
*
|
|
28
|
+
* A partial migration is `failed at step`. History the files do not contain
|
|
29
|
+
* is `ahead`. Pending files are behind by expand, or by contract when any
|
|
30
|
+
* pending step is not expand.
|
|
31
|
+
*
|
|
32
|
+
* @param migrations - Files in apply order
|
|
33
|
+
* @param history - Checkpoint rows
|
|
34
|
+
* @param recorded - Head row in `okm_meta`, when the target has one
|
|
35
|
+
* @returns Version, catalog hash, and state
|
|
36
|
+
*/
|
|
37
|
+
export declare function describeStatus(migrations: readonly StoredMigration[], history: readonly StatusHistory[], recorded: {
|
|
38
|
+
readonly hash: string;
|
|
39
|
+
readonly version: string;
|
|
40
|
+
} | undefined): {
|
|
41
|
+
readonly version: string;
|
|
42
|
+
readonly catalogHash: string;
|
|
43
|
+
readonly state: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Reads one target and returns its status row.
|
|
47
|
+
*
|
|
48
|
+
* @param input - URL, name, protection, and the local migrations
|
|
49
|
+
* @returns The row
|
|
50
|
+
*/
|
|
51
|
+
export declare function readTargetStatus(input: {
|
|
52
|
+
readonly url: string;
|
|
53
|
+
readonly target: string;
|
|
54
|
+
readonly protected: boolean;
|
|
55
|
+
readonly searchPath?: string;
|
|
56
|
+
readonly migrations: readonly StoredMigration[];
|
|
57
|
+
}): Promise<TargetStatus>;
|
|
58
|
+
/**
|
|
59
|
+
* Prints status for every target, or for `--target` when it is passed.
|
|
60
|
+
*
|
|
61
|
+
* Several targets do not require `--target` here: the command lists them.
|
|
62
|
+
*
|
|
63
|
+
* @param cwd - Project directory
|
|
64
|
+
* @param flags - Optional target name
|
|
65
|
+
* @returns Tab-separated text, with a header
|
|
66
|
+
*/
|
|
67
|
+
export declare function statusProject(cwd: string, flags: InvokeFlags): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Prints status rows.
|
|
70
|
+
*
|
|
71
|
+
* @param rows - One per target
|
|
72
|
+
* @returns Header plus one line per target
|
|
73
|
+
*/
|
|
74
|
+
export declare function formatStatus(rows: readonly TargetStatus[]): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--replace` flags for a removed picklist or enum value (D131).
|
|
3
|
+
*
|
|
4
|
+
* The schema never stores the replacement. The flag is the only place it
|
|
5
|
+
* exists, and a chain (a value replaced by another removed value) is rejected.
|
|
6
|
+
*/
|
|
7
|
+
/** One replacement. `to` is `null` when the flag says `=null`. */
|
|
8
|
+
export type Replacement = {
|
|
9
|
+
readonly table: string;
|
|
10
|
+
readonly column: string;
|
|
11
|
+
readonly from: string;
|
|
12
|
+
readonly to: string | null;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Parses `table.column.old=new`.
|
|
16
|
+
*
|
|
17
|
+
* The split is the first `=` and the first two dots, so the old value may
|
|
18
|
+
* contain dots. `=null` is the null replacement.
|
|
19
|
+
*
|
|
20
|
+
* @param flag - One `--replace` value
|
|
21
|
+
* @returns The replacement
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseReplace(flag: string): Replacement;
|
|
24
|
+
/**
|
|
25
|
+
* Rejects a chain: a replacement whose new value is itself removed.
|
|
26
|
+
*
|
|
27
|
+
* @param replacements - Flags for one generate
|
|
28
|
+
*/
|
|
29
|
+
export declare function assertNoChains(replacements: readonly Replacement[]): void;
|
package/package.json
CHANGED
|
@@ -1,19 +1,121 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "okmodel",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "okmodel is a catalog-first TypeScript ORM, PostgreSQL first. Other SQL databases are the direction. Version 0.1 supports PostgreSQL only. The schema is the single source. Migrations and queries come from it.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"migrations",
|
|
7
|
+
"orm",
|
|
8
|
+
"postgres",
|
|
9
|
+
"postgresql",
|
|
10
|
+
"typescript"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/omqkhafi/okmodel",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/omqkhafi/okmodel/issues"
|
|
15
|
+
},
|
|
6
16
|
"license": "Apache-2.0",
|
|
7
17
|
"author": "Omq Khafi",
|
|
8
|
-
"repository":
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/omqkhafi/okmodel.git"
|
|
21
|
+
},
|
|
22
|
+
"bin": {
|
|
23
|
+
"okm": "./dist/okm.js",
|
|
24
|
+
"okmodel": "./dist/okmodel.js"
|
|
25
|
+
},
|
|
26
|
+
"workspaces": [
|
|
27
|
+
"packages/*"
|
|
28
|
+
],
|
|
9
29
|
"files": [
|
|
10
30
|
"dist",
|
|
11
31
|
"README.md",
|
|
12
32
|
"LICENSE"
|
|
13
33
|
],
|
|
14
|
-
"
|
|
34
|
+
"type": "module",
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/contracts/index.d.ts",
|
|
39
|
+
"import": "./dist/contracts/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./pg": {
|
|
42
|
+
"types": "./dist/dialects/pg/index.d.ts",
|
|
43
|
+
"import": "./dist/dialects/pg/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./internal": {
|
|
46
|
+
"types": "./dist/contracts/internal.d.ts",
|
|
47
|
+
"import": "./dist/contracts/internal.js"
|
|
48
|
+
},
|
|
49
|
+
"./migrate": {
|
|
50
|
+
"types": "./dist/tooling/migrate/index.d.ts",
|
|
51
|
+
"import": "./dist/tooling/migrate/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./pg/postgresjs": {
|
|
54
|
+
"types": "./dist/runtime/pg/postgresjs.d.ts",
|
|
55
|
+
"import": "./dist/runtime/pg/postgresjs.js"
|
|
56
|
+
},
|
|
57
|
+
"./pg/pglite": {
|
|
58
|
+
"types": "./dist/runtime/pg/pglite.d.ts",
|
|
59
|
+
"import": "./dist/runtime/pg/pglite.js"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
15
62
|
"scripts": {
|
|
16
|
-
"build": "bun build ./src/index.ts --outdir ./dist --format esm --target node",
|
|
17
|
-
"
|
|
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",
|
|
64
|
+
"driver-bench": "bun ./scripts/driver-bench.ts",
|
|
65
|
+
"typecheck": "bunx tsc --noEmit -p tsconfig.json",
|
|
66
|
+
"editor-check": "bun ./scripts/editor-check.ts",
|
|
67
|
+
"type-cost": "bun ./scripts/type-cost.ts",
|
|
68
|
+
"lint": "oxlint",
|
|
69
|
+
"format": "oxfmt",
|
|
70
|
+
"format:check": "oxfmt --check",
|
|
71
|
+
"layers-check": "bun ./scripts/layers-check.ts",
|
|
72
|
+
"core-purity": "bun ./scripts/core-purity.ts",
|
|
73
|
+
"docs:check": "bun ./scripts/docs-check.ts",
|
|
74
|
+
"readme:check": "bun ./scripts/readme-check.ts",
|
|
75
|
+
"compiler-api": "bun ./scripts/compiler-api.ts",
|
|
76
|
+
"publint": "publint run . --strict --pack bun",
|
|
77
|
+
"attw": "bun ./scripts/attw.ts",
|
|
78
|
+
"size": "bun ./scripts/size.ts",
|
|
79
|
+
"bundle-purity": "bun ./scripts/bundle-purity.ts",
|
|
80
|
+
"test": "bun test",
|
|
81
|
+
"test:postgres": "bun ./scripts/postgres-suite.ts",
|
|
82
|
+
"test:tarball": "bun ./scripts/tarball-smoke.ts",
|
|
83
|
+
"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",
|
|
85
|
+
"bump": "bun ./scripts/bump-version.ts",
|
|
86
|
+
"release-check": "bun ./scripts/release-check.ts",
|
|
87
|
+
"db:up": "bun ./packages/harness/src/docker-cli.ts up",
|
|
88
|
+
"db:down": "bun ./packages/harness/src/docker-cli.ts down",
|
|
89
|
+
"bench": "bun ./packages/bench/src/run.ts",
|
|
90
|
+
"catalog-bench": "bun ./scripts/catalog-bench.ts",
|
|
91
|
+
"attest": "ATTEST_shouldFormat=0 ATTEST_updateSnapshots=0 bun ./packages/attest/src/measure.bench.ts",
|
|
92
|
+
"publish:dry": "bun publish --dry-run",
|
|
93
|
+
"prepublishOnly": "bun run build"
|
|
94
|
+
},
|
|
95
|
+
"devDependencies": {
|
|
96
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
97
|
+
"@electric-sql/pglite-socket": "^0.2.11",
|
|
98
|
+
"@types/bun": "^1.4.2",
|
|
99
|
+
"expect-type": "^1.4.0",
|
|
100
|
+
"fast-check": "^4.10.2",
|
|
101
|
+
"oxc-parser": "^0.152.0",
|
|
102
|
+
"oxfmt": "0.71.0",
|
|
103
|
+
"oxlint": "^1.86.0",
|
|
104
|
+
"oxlint-tsgolint": "^7.0.2003",
|
|
105
|
+
"publint": "^0.3.24",
|
|
106
|
+
"typescript": "7",
|
|
107
|
+
"typescript-editor": "npm:typescript@6.0.3"
|
|
108
|
+
},
|
|
109
|
+
"peerDependencies": {
|
|
110
|
+
"@electric-sql/pglite": "^0.5.8",
|
|
111
|
+
"postgres": "^3.4.9"
|
|
112
|
+
},
|
|
113
|
+
"peerDependenciesMeta": {
|
|
114
|
+
"@electric-sql/pglite": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
"postgres": {
|
|
118
|
+
"optional": true
|
|
119
|
+
}
|
|
18
120
|
}
|
|
19
121
|
}
|
package/dist/index.js
DELETED
|
File without changes
|