okmodel 0.0.0 → 0.1.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 +44 -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 +369 -0
- package/dist/runtime/write.d.ts +48 -0
- package/dist/shared/4j72449d.js +37 -0
- package/dist/shared/79ggp945.js +148 -0
- package/dist/shared/7ck0dtry.js +259 -0
- package/dist/shared/8b04d28c.js +14 -0
- package/dist/shared/ax16zpvm.js +171 -0
- package/dist/shared/ckb1p0a4.js +566 -0
- package/dist/shared/cn0n68ft.js +16 -0
- package/dist/shared/dynq16vb.js +81 -0
- package/dist/shared/f5thc1s0.js +1050 -0
- package/dist/shared/fgqgsb5z.js +281 -0
- package/dist/shared/g2v6gnc8.js +347 -0
- package/dist/shared/g5fhqmwe.js +188 -0
- package/dist/shared/gk7cs7sp.js +566 -0
- package/dist/shared/hd293j9g.js +98 -0
- package/dist/shared/j5cn2963.js +701 -0
- package/dist/shared/kynx7vbm.js +1490 -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/px90pf9p.js +396 -0
- package/dist/shared/qk3hxfja.js +83 -0
- package/dist/shared/tb4ze1tr.js +119 -0
- package/dist/shared/vkm3q4x1.js +30 -0
- package/dist/shared/w8samvk1.js +18 -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/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 +94 -7
- package/dist/index.js +0 -0
|
@@ -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,106 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "okmodel",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"type": "module",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Catalog-first TypeScript ORM: typed queries, safe migrations and replica-aware routing. PostgreSQL first, zero runtime dependencies.",
|
|
6
5
|
"license": "Apache-2.0",
|
|
7
6
|
"author": "Omq Khafi",
|
|
8
|
-
"repository":
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/omqkhafi/okmodel.git"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"okm": "./dist/okm.js",
|
|
13
|
+
"okmodel": "./dist/okmodel.js"
|
|
14
|
+
},
|
|
15
|
+
"workspaces": [
|
|
16
|
+
"packages/*"
|
|
17
|
+
],
|
|
9
18
|
"files": [
|
|
10
19
|
"dist",
|
|
11
20
|
"README.md",
|
|
12
21
|
"LICENSE"
|
|
13
22
|
],
|
|
14
|
-
"
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/contracts/index.d.ts",
|
|
28
|
+
"import": "./dist/contracts/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./pg": {
|
|
31
|
+
"types": "./dist/dialects/pg/index.d.ts",
|
|
32
|
+
"import": "./dist/dialects/pg/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./internal": {
|
|
35
|
+
"types": "./dist/contracts/internal.d.ts",
|
|
36
|
+
"import": "./dist/contracts/internal.js"
|
|
37
|
+
},
|
|
38
|
+
"./migrate": {
|
|
39
|
+
"types": "./dist/tooling/migrate/index.d.ts",
|
|
40
|
+
"import": "./dist/tooling/migrate/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./pg/postgresjs": {
|
|
43
|
+
"types": "./dist/runtime/pg/postgresjs.d.ts",
|
|
44
|
+
"import": "./dist/runtime/pg/postgresjs.js"
|
|
45
|
+
},
|
|
46
|
+
"./pg/pglite": {
|
|
47
|
+
"types": "./dist/runtime/pg/pglite.d.ts",
|
|
48
|
+
"import": "./dist/runtime/pg/pglite.js"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
15
51
|
"scripts": {
|
|
16
|
-
"build": "bun build ./src/index.ts --outdir ./dist --format esm --target node",
|
|
17
|
-
"
|
|
52
|
+
"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",
|
|
53
|
+
"driver-bench": "bun ./scripts/driver-bench.ts",
|
|
54
|
+
"typecheck": "bunx tsc --noEmit -p tsconfig.json",
|
|
55
|
+
"editor-check": "bun ./scripts/editor-check.ts",
|
|
56
|
+
"type-cost": "bun ./scripts/type-cost.ts",
|
|
57
|
+
"lint": "oxlint",
|
|
58
|
+
"format": "oxfmt",
|
|
59
|
+
"format:check": "oxfmt --check",
|
|
60
|
+
"layers-check": "bun ./scripts/layers-check.ts",
|
|
61
|
+
"core-purity": "bun ./scripts/core-purity.ts",
|
|
62
|
+
"docs:check": "bun ./scripts/docs-check.ts",
|
|
63
|
+
"compiler-api": "bun ./scripts/compiler-api.ts",
|
|
64
|
+
"publint": "publint run . --strict --pack bun",
|
|
65
|
+
"attw": "bun ./scripts/attw.ts",
|
|
66
|
+
"size": "bun ./scripts/size.ts",
|
|
67
|
+
"bundle-purity": "bun ./scripts/bundle-purity.ts",
|
|
68
|
+
"test": "bun test",
|
|
69
|
+
"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 compiler-api && bun run bundle-purity && bun run build && bun test && bun run publint && bun run attw && bun run size",
|
|
70
|
+
"bump": "bun ./scripts/bump-version.ts",
|
|
71
|
+
"release-check": "bun ./scripts/release-check.ts",
|
|
72
|
+
"db:up": "bun ./packages/harness/src/docker-cli.ts up",
|
|
73
|
+
"db:down": "bun ./packages/harness/src/docker-cli.ts down",
|
|
74
|
+
"bench": "bun ./packages/bench/src/run.ts",
|
|
75
|
+
"catalog-bench": "bun ./scripts/catalog-bench.ts",
|
|
76
|
+
"attest": "ATTEST_shouldFormat=0 ATTEST_updateSnapshots=0 bun ./packages/attest/src/measure.bench.ts",
|
|
77
|
+
"publish:dry": "bun publish --dry-run",
|
|
78
|
+
"prepublishOnly": "bun run build"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
82
|
+
"@electric-sql/pglite-socket": "^0.2.11",
|
|
83
|
+
"@types/bun": "^1.4.2",
|
|
84
|
+
"expect-type": "^1.4.0",
|
|
85
|
+
"fast-check": "^4.10.2",
|
|
86
|
+
"oxc-parser": "^0.152.0",
|
|
87
|
+
"oxfmt": "0.71.0",
|
|
88
|
+
"oxlint": "^1.86.0",
|
|
89
|
+
"oxlint-tsgolint": "^7.0.2003",
|
|
90
|
+
"publint": "^0.3.24",
|
|
91
|
+
"typescript": "7",
|
|
92
|
+
"typescript-editor": "npm:typescript@6.0.3"
|
|
93
|
+
},
|
|
94
|
+
"peerDependencies": {
|
|
95
|
+
"@electric-sql/pglite": "^0.5.8",
|
|
96
|
+
"postgres": "^3.4.9"
|
|
97
|
+
},
|
|
98
|
+
"peerDependenciesMeta": {
|
|
99
|
+
"@electric-sql/pglite": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
102
|
+
"postgres": {
|
|
103
|
+
"optional": true
|
|
104
|
+
}
|
|
18
105
|
}
|
|
19
106
|
}
|
package/dist/index.js
DELETED
|
File without changes
|