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,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum and domain columns.
|
|
3
|
+
*
|
|
4
|
+
* The catalog column type is the type name. Compile records a dependency on
|
|
5
|
+
* the enum, and `schema()` stores that enum as a catalog type.
|
|
6
|
+
*/
|
|
7
|
+
import { type ColumnBuilder, type ColumnFlags, type PlainFlags } from "./column.js";
|
|
8
|
+
/**
|
|
9
|
+
* A named enum. The TypeScript type is the literal union.
|
|
10
|
+
*
|
|
11
|
+
* `okmodel/pg` exports this function as `enum`. The declaration stays
|
|
12
|
+
* `enumColumn` because `enum` is reserved in a function declaration.
|
|
13
|
+
*
|
|
14
|
+
* @param name - Postgres type name
|
|
15
|
+
* @param values - Labels, in stored order
|
|
16
|
+
* @returns An enum column
|
|
17
|
+
*/
|
|
18
|
+
export declare function enumColumn<const TValues extends readonly string[]>(name: string, values: TValues): ColumnBuilder<TValues[number], PlainFlags>;
|
|
19
|
+
/**
|
|
20
|
+
* A named domain over a scalar column.
|
|
21
|
+
*
|
|
22
|
+
* Domains are not catalog objects in this version. Calling the builder fails
|
|
23
|
+
* with OKM1061 until 0.3, when a domain becomes a `type` subkind (D141).
|
|
24
|
+
*
|
|
25
|
+
* @param name - Domain name
|
|
26
|
+
* @param base - Scalar column the domain is based on
|
|
27
|
+
* @param check - Domain check expression
|
|
28
|
+
* @returns A domain column with the base codec, once 0.3 supports it
|
|
29
|
+
*/
|
|
30
|
+
export declare function domain<TValue, TFlags extends ColumnFlags>(_name: string, _base: ColumnBuilder<TValue, TFlags>, _check: string): ColumnBuilder<TValue, PlainFlags>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a Postgres {@link DriverError} to an {@link OkmError} (spec §4.2, §14).
|
|
3
|
+
*
|
|
4
|
+
* Adapters normalise the driver into `DriverError`. They do not construct
|
|
5
|
+
* `OkmError`. Constraint names follow the catalog: `{table}_{nameKey}_{tag}`.
|
|
6
|
+
*/
|
|
7
|
+
import { OkmError, type ErrorStatuses } from "../../contracts/error.js";
|
|
8
|
+
/** Options for {@link mapPostgresError}. */
|
|
9
|
+
export type MapPostgresErrorOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* Keep row values on the error. Development only.
|
|
12
|
+
*
|
|
13
|
+
* The summary, the log, and {@link OkmError.fields} still omit them.
|
|
14
|
+
*/
|
|
15
|
+
readonly includeValues?: boolean;
|
|
16
|
+
/** Category overrides from `connect({ errors })`. */
|
|
17
|
+
readonly http?: ErrorStatuses;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Maps a thrown driver error into an {@link OkmError}.
|
|
21
|
+
*
|
|
22
|
+
* An {@link OkmError} passes through. `timeout`, `cancelled`, and
|
|
23
|
+
* `outcome_unknown` follow the driver kind (D124). `57014` without that kind
|
|
24
|
+
* is `timeout`, because `cancelled` comes only from the caller's signal.
|
|
25
|
+
*
|
|
26
|
+
* @param error - Caught value, usually a `DriverError`
|
|
27
|
+
* @param options - `includeValues` keeps row values off the log
|
|
28
|
+
* @returns A categorised error
|
|
29
|
+
*/
|
|
30
|
+
export declare function mapPostgresError(error: unknown, options?: MapPostgresErrorOptions): OkmError;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decimal text for finite numbers.
|
|
3
|
+
*
|
|
4
|
+
* Shared by numeric, real, double, and geometry so the spelling stays one place.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Spells a finite number as a canonical decimal literal.
|
|
8
|
+
*
|
|
9
|
+
* Negative zero becomes `0`.
|
|
10
|
+
*
|
|
11
|
+
* @param value - Finite number
|
|
12
|
+
* @param role - Type name used when the value is not finite
|
|
13
|
+
* @returns Decimal text
|
|
14
|
+
*/
|
|
15
|
+
export declare function decimalText(value: number, role: string): string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in geometric columns. PostGIS stays in an extension package.
|
|
3
|
+
*/
|
|
4
|
+
import { type ColumnBuilder, type PlainFlags } from "./column.js";
|
|
5
|
+
/** A point on a plane. */
|
|
6
|
+
export type Point = {
|
|
7
|
+
readonly x: number;
|
|
8
|
+
readonly y: number;
|
|
9
|
+
};
|
|
10
|
+
/** An infinite line `ax + by + c = 0`. */
|
|
11
|
+
export type Line = {
|
|
12
|
+
readonly a: number;
|
|
13
|
+
readonly b: number;
|
|
14
|
+
readonly c: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Point. Wire text is `(x,y)`.
|
|
18
|
+
*
|
|
19
|
+
* @returns A point column
|
|
20
|
+
*/
|
|
21
|
+
export declare function point(): ColumnBuilder<Point, PlainFlags>;
|
|
22
|
+
/**
|
|
23
|
+
* Infinite line. Wire text is `{a,b,c}`.
|
|
24
|
+
*
|
|
25
|
+
* @returns A line column
|
|
26
|
+
*/
|
|
27
|
+
export declare function line(): ColumnBuilder<Line, PlainFlags>;
|
|
28
|
+
/**
|
|
29
|
+
* Encodes a point.
|
|
30
|
+
*
|
|
31
|
+
* @param value - Coordinates
|
|
32
|
+
* @returns `(x,y)`
|
|
33
|
+
*/
|
|
34
|
+
export declare function encodePoint(value: Point): string;
|
|
35
|
+
/**
|
|
36
|
+
* Decodes `(x,y)`.
|
|
37
|
+
*
|
|
38
|
+
* @param wire - Point text
|
|
39
|
+
* @returns Coordinates
|
|
40
|
+
*/
|
|
41
|
+
export declare function decodePoint(wire: string): Point;
|
|
42
|
+
/**
|
|
43
|
+
* Encodes a line.
|
|
44
|
+
*
|
|
45
|
+
* @param value - Line coefficients
|
|
46
|
+
* @returns `{a,b,c}`
|
|
47
|
+
*/
|
|
48
|
+
export declare function encodeLine(value: Line): string;
|
|
49
|
+
/**
|
|
50
|
+
* Decodes `{a,b,c}`.
|
|
51
|
+
*
|
|
52
|
+
* @param wire - Line text
|
|
53
|
+
* @returns Coefficients
|
|
54
|
+
*/
|
|
55
|
+
export declare function decodeLine(wire: string): Line;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry for `okmodel/pg`.
|
|
3
|
+
*
|
|
4
|
+
* Column types, codecs, picklists, `table()`, and `schema()`.
|
|
5
|
+
* Each builder is a separate export so a bundle can keep only the ones it calls.
|
|
6
|
+
*/
|
|
7
|
+
export { schema, type BuiltSchema, type SchemaCodecs, type SchemaInput, type SchemaRequires, } from "./schema.js";
|
|
8
|
+
export { index, sql, table, type AnyTable, type ColumnHandle, type IndexCall, type SqlText, type SqlValue, type Table, type TableOptions, } from "./table.js";
|
|
9
|
+
export { custom } from "./custom.js";
|
|
10
|
+
export { ColumnBuilder } from "./column.js";
|
|
11
|
+
export type { ArrayOf, ColumnFlags, ColumnInsert, ColumnInsertOf, ColumnRow, ColumnRowOf, ColumnUpdate, ColumnUpdateOf, FlagTrue, IdFlags, IdentityFlags, PlainFlags, ReferenceModifier, ReferenceOptions, SqlForm, ValidateModifier, WithGenerated, } from "./column.js";
|
|
12
|
+
export { bigint, identity, integer, smallint, type BigintAs, type BigintValue } from "./integer.js";
|
|
13
|
+
export { double, numeric, real, type NumericAs, type NumericValue } from "./decimal.js";
|
|
14
|
+
export { boolean, bytea } from "./bool.js";
|
|
15
|
+
export { json, jsonb, jsonReplacer } from "./json.js";
|
|
16
|
+
export { id, uuid } from "./keys.js";
|
|
17
|
+
export { char, citext, text, varchar } from "./text.js";
|
|
18
|
+
export { date, interval, time, timestamp, timestamptz, timetz } from "./time.js";
|
|
19
|
+
export { type TimeWithOffset } from "./temporal.js";
|
|
20
|
+
export { daterange, int4range, int8range, numrange, tstzrange, type Range } from "./range.js";
|
|
21
|
+
export { cidr, inet, macaddr, macaddr8 } from "./network.js";
|
|
22
|
+
export { line, point, type Line, type Point } from "./geometry.js";
|
|
23
|
+
export { ltree, tsvector } from "./search.js";
|
|
24
|
+
export { domain, enumColumn as enum } from "./enum.js";
|
|
25
|
+
export { t } from "./namespace.js";
|
|
26
|
+
export { between } from "./ops/between.js";
|
|
27
|
+
export { contains } from "./ops/contains.js";
|
|
28
|
+
export { endsWith } from "./ops/endsWith.js";
|
|
29
|
+
export { eq } from "./ops/eq.js";
|
|
30
|
+
export { every } from "./ops/every.js";
|
|
31
|
+
export { gt } from "./ops/gt.js";
|
|
32
|
+
export { inc } from "./ops/inc.js";
|
|
33
|
+
export { gte } from "./ops/gte.js";
|
|
34
|
+
export { has } from "./ops/has.js";
|
|
35
|
+
export { ilike } from "./ops/ilike.js";
|
|
36
|
+
export { inList } from "./ops/inList.js";
|
|
37
|
+
export { like } from "./ops/like.js";
|
|
38
|
+
export { lt } from "./ops/lt.js";
|
|
39
|
+
export { lte } from "./ops/lte.js";
|
|
40
|
+
export { none } from "./ops/none.js";
|
|
41
|
+
export { not } from "./ops/not.js";
|
|
42
|
+
export { notIn } from "./ops/notIn.js";
|
|
43
|
+
export { or } from "./ops/or.js";
|
|
44
|
+
export { startsWith } from "./ops/startsWith.js";
|
|
45
|
+
export { many, one, type ManyRelation, type OneRelation, type RelationCall } from "./relations.js";
|