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.
Files changed (147) hide show
  1. package/README.md +44 -1
  2. package/dist/adapters/capabilities.d.ts +62 -0
  3. package/dist/adapters/error.d.ts +91 -0
  4. package/dist/adapters/failure.d.ts +39 -0
  5. package/dist/adapters/pg/batch.d.ts +36 -0
  6. package/dist/adapters/pg/call.d.ts +59 -0
  7. package/dist/adapters/pg/pglite.d.ts +21 -0
  8. package/dist/adapters/pg/postgres-extra.d.ts +43 -0
  9. package/dist/adapters/pg/postgresjs.d.ts +95 -0
  10. package/dist/adapters/pg/result.d.ts +30 -0
  11. package/dist/contracts/catalog/build.d.ts +18 -0
  12. package/dist/contracts/catalog/document.d.ts +79 -0
  13. package/dist/contracts/catalog/enum.d.ts +35 -0
  14. package/dist/contracts/catalog/identifier.d.ts +71 -0
  15. package/dist/contracts/catalog/identity.d.ts +98 -0
  16. package/dist/contracts/catalog/index.d.ts +11 -0
  17. package/dist/contracts/catalog/json.d.ts +17 -0
  18. package/dist/contracts/catalog/object.d.ts +142 -0
  19. package/dist/contracts/catalog/order.d.ts +43 -0
  20. package/dist/contracts/catalog/rewrite.d.ts +18 -0
  21. package/dist/contracts/catalog/types.d.ts +292 -0
  22. package/dist/contracts/catalog/words.d.ts +13 -0
  23. package/dist/contracts/connection.d.ts +33 -0
  24. package/dist/contracts/driver.d.ts +163 -0
  25. package/dist/contracts/error.d.ts +298 -0
  26. package/dist/contracts/index.d.ts +11 -0
  27. package/dist/contracts/index.js +16 -0
  28. package/dist/contracts/internal.d.ts +15 -0
  29. package/dist/contracts/internal.js +68 -0
  30. package/dist/contracts/nearest.d.ts +15 -0
  31. package/dist/contracts/rows.d.ts +84 -0
  32. package/dist/contracts/sha256.d.ts +14 -0
  33. package/dist/contracts/utf8.d.ts +33 -0
  34. package/dist/dialects/pg/array-literal.d.ts +25 -0
  35. package/dist/dialects/pg/bool.d.ts +46 -0
  36. package/dist/dialects/pg/column.d.ts +386 -0
  37. package/dist/dialects/pg/compile.d.ts +81 -0
  38. package/dist/dialects/pg/custom.d.ts +21 -0
  39. package/dist/dialects/pg/ddl.d.ts +70 -0
  40. package/dist/dialects/pg/decimal.d.ts +62 -0
  41. package/dist/dialects/pg/declarations.d.ts +34 -0
  42. package/dist/dialects/pg/emit.d.ts +18 -0
  43. package/dist/dialects/pg/enum.d.ts +30 -0
  44. package/dist/dialects/pg/errors.d.ts +30 -0
  45. package/dist/dialects/pg/finite.d.ts +15 -0
  46. package/dist/dialects/pg/geometry.d.ts +55 -0
  47. package/dist/dialects/pg/index.d.ts +45 -0
  48. package/dist/dialects/pg/index.js +1821 -0
  49. package/dist/dialects/pg/integer.d.ts +96 -0
  50. package/dist/dialects/pg/introspect.d.ts +43 -0
  51. package/dist/dialects/pg/json.d.ts +43 -0
  52. package/dist/dialects/pg/keys.d.ts +32 -0
  53. package/dist/dialects/pg/misuse.d.ts +31 -0
  54. package/dist/dialects/pg/model.d.ts +71 -0
  55. package/dist/dialects/pg/namespace.d.ts +63 -0
  56. package/dist/dialects/pg/network.d.ts +28 -0
  57. package/dist/dialects/pg/operators.d.ts +71 -0
  58. package/dist/dialects/pg/ops/between.d.ts +10 -0
  59. package/dist/dialects/pg/ops/contains.d.ts +8 -0
  60. package/dist/dialects/pg/ops/endsWith.d.ts +8 -0
  61. package/dist/dialects/pg/ops/eq.d.ts +9 -0
  62. package/dist/dialects/pg/ops/every.d.ts +9 -0
  63. package/dist/dialects/pg/ops/gt.d.ts +9 -0
  64. package/dist/dialects/pg/ops/gte.d.ts +9 -0
  65. package/dist/dialects/pg/ops/has.d.ts +9 -0
  66. package/dist/dialects/pg/ops/ilike.d.ts +8 -0
  67. package/dist/dialects/pg/ops/inList.d.ts +9 -0
  68. package/dist/dialects/pg/ops/inc.d.ts +13 -0
  69. package/dist/dialects/pg/ops/like.d.ts +8 -0
  70. package/dist/dialects/pg/ops/lt.d.ts +9 -0
  71. package/dist/dialects/pg/ops/lte.d.ts +9 -0
  72. package/dist/dialects/pg/ops/none.d.ts +9 -0
  73. package/dist/dialects/pg/ops/not.d.ts +9 -0
  74. package/dist/dialects/pg/ops/notIn.d.ts +9 -0
  75. package/dist/dialects/pg/ops/or.d.ts +9 -0
  76. package/dist/dialects/pg/ops/startsWith.d.ts +8 -0
  77. package/dist/dialects/pg/quote.d.ts +24 -0
  78. package/dist/dialects/pg/range.d.ts +50 -0
  79. package/dist/dialects/pg/relations.d.ts +45 -0
  80. package/dist/dialects/pg/schema.d.ts +77 -0
  81. package/dist/dialects/pg/search.d.ts +23 -0
  82. package/dist/dialects/pg/table.d.ts +201 -0
  83. package/dist/dialects/pg/temporal.d.ts +211 -0
  84. package/dist/dialects/pg/text.d.ts +44 -0
  85. package/dist/dialects/pg/time.d.ts +46 -0
  86. package/dist/okm.js +2 -0
  87. package/dist/okmodel.js +2 -0
  88. package/dist/runtime/client.d.ts +47 -0
  89. package/dist/runtime/conflict.d.ts +38 -0
  90. package/dist/runtime/drift-detail.d.ts +32 -0
  91. package/dist/runtime/drift.d.ts +29 -0
  92. package/dist/runtime/include.d.ts +15 -0
  93. package/dist/runtime/pg/pglite.d.ts +25 -0
  94. package/dist/runtime/pg/pglite.js +48 -0
  95. package/dist/runtime/pg/postgresjs.d.ts +29 -0
  96. package/dist/runtime/pg/postgresjs.js +62 -0
  97. package/dist/runtime/plan.d.ts +167 -0
  98. package/dist/runtime/tx.d.ts +29 -0
  99. package/dist/runtime/types.d.ts +369 -0
  100. package/dist/runtime/write.d.ts +48 -0
  101. package/dist/shared/4j72449d.js +37 -0
  102. package/dist/shared/79ggp945.js +148 -0
  103. package/dist/shared/7ck0dtry.js +259 -0
  104. package/dist/shared/8b04d28c.js +14 -0
  105. package/dist/shared/ax16zpvm.js +171 -0
  106. package/dist/shared/ckb1p0a4.js +566 -0
  107. package/dist/shared/cn0n68ft.js +16 -0
  108. package/dist/shared/dynq16vb.js +81 -0
  109. package/dist/shared/f5thc1s0.js +1050 -0
  110. package/dist/shared/fgqgsb5z.js +281 -0
  111. package/dist/shared/g2v6gnc8.js +347 -0
  112. package/dist/shared/g5fhqmwe.js +188 -0
  113. package/dist/shared/gk7cs7sp.js +566 -0
  114. package/dist/shared/hd293j9g.js +98 -0
  115. package/dist/shared/j5cn2963.js +701 -0
  116. package/dist/shared/kynx7vbm.js +1490 -0
  117. package/dist/shared/mkjmqjv4.js +456 -0
  118. package/dist/shared/mtkwv8wx.js +18 -0
  119. package/dist/shared/ngk8gj61.js +40 -0
  120. package/dist/shared/p0cbr3g2.js +79 -0
  121. package/dist/shared/px90pf9p.js +396 -0
  122. package/dist/shared/qk3hxfja.js +83 -0
  123. package/dist/shared/tb4ze1tr.js +119 -0
  124. package/dist/shared/vkm3q4x1.js +30 -0
  125. package/dist/shared/w8samvk1.js +18 -0
  126. package/dist/shared/xy79j5hq.js +177 -0
  127. package/dist/shared/y9m15dfv.js +888 -0
  128. package/dist/shared/ycwz42az.js +412 -0
  129. package/dist/shared/zhc5vmgf.js +257 -0
  130. package/dist/tooling/cli.d.ts +1 -0
  131. package/dist/tooling/cli.js +193 -0
  132. package/dist/tooling/errors/registry.d.ts +33 -0
  133. package/dist/tooling/migrate/apply.d.ts +86 -0
  134. package/dist/tooling/migrate/commands.d.ts +21 -0
  135. package/dist/tooling/migrate/config.d.ts +48 -0
  136. package/dist/tooling/migrate/dev.d.ts +16 -0
  137. package/dist/tooling/migrate/equal.d.ts +15 -0
  138. package/dist/tooling/migrate/files.d.ts +19 -0
  139. package/dist/tooling/migrate/index.d.ts +7 -0
  140. package/dist/tooling/migrate/index.js +7 -0
  141. package/dist/tooling/migrate/plan.d.ts +76 -0
  142. package/dist/tooling/migrate/policy.d.ts +78 -0
  143. package/dist/tooling/migrate/project.d.ts +69 -0
  144. package/dist/tooling/migrate/status.d.ts +74 -0
  145. package/dist/tooling/migrate/values.d.ts +29 -0
  146. package/package.json +94 -7
  147. package/dist/index.js +0 -0
@@ -0,0 +1,96 @@
1
+ /**
2
+ * smallint, integer, and bigint.
3
+ *
4
+ * Bigint defaults to a decimal string. `as` selects number or bigint.
5
+ */
6
+ import { type ColumnBuilder, type IdentityFlags, type PlainFlags } from "./column.js";
7
+ /** How a bigint value is represented in TypeScript. */
8
+ export type BigintAs = "string" | "number" | "bigint";
9
+ /**
10
+ * 16-bit integer.
11
+ *
12
+ * @returns A smallint column
13
+ */
14
+ export declare function smallint(): ColumnBuilder<number, PlainFlags>;
15
+ /**
16
+ * 32-bit integer.
17
+ *
18
+ * @returns An integer column
19
+ */
20
+ export declare function integer(): ColumnBuilder<number, PlainFlags>;
21
+ /** TypeScript value for a bigint codec mode. */
22
+ export type BigintValue<TAs extends BigintAs> = TAs extends "number" ? number : TAs extends "bigint" ? bigint : string;
23
+ /**
24
+ * 64-bit integer. The default codec is a decimal string.
25
+ *
26
+ * @typeParam TAs - `string`, `number`, or `bigint`
27
+ * @param options - `as` overrides the TypeScript representation
28
+ * @returns A bigint column
29
+ */
30
+ export declare function bigint<const TAs extends BigintAs = "string">(options?: {
31
+ readonly as?: TAs;
32
+ }): ColumnBuilder<BigintValue<TAs>, PlainFlags>;
33
+ /**
34
+ * `bigint` identity column, `GENERATED ALWAYS AS IDENTITY`.
35
+ *
36
+ * Insert and update omit it. The codec follows the same `as` modes as {@link bigint}.
37
+ *
38
+ * @typeParam TAs - `string`, `number`, or `bigint`
39
+ * @param options - Codec selection
40
+ * @returns An identity column
41
+ */
42
+ export declare function identity<const TAs extends BigintAs = "string">(options?: {
43
+ readonly as?: TAs;
44
+ }): ColumnBuilder<BigintValue<TAs>, IdentityFlags>;
45
+ /**
46
+ * Encodes a bigint decimal string.
47
+ *
48
+ * @param value - Decimal integer
49
+ * @returns The same spelling when it is a canonical integer
50
+ */
51
+ export declare function encodeBigintString(value: string): string;
52
+ /**
53
+ * Decodes a bigint decimal string.
54
+ *
55
+ * @param wire - Decimal integer
56
+ * @returns The same spelling
57
+ */
58
+ export declare function decodeBigintString(wire: string): string;
59
+ /**
60
+ * Encodes a safe integer as a bigint literal.
61
+ *
62
+ * @param value - Safe integer
63
+ * @returns Decimal text
64
+ */
65
+ export declare function encodeBigintNumber(value: number): string;
66
+ /**
67
+ * Decodes a bigint literal that fits in a safe integer.
68
+ *
69
+ * @param wire - Decimal integer
70
+ * @returns A safe integer
71
+ */
72
+ export declare function decodeBigintNumber(wire: string): number;
73
+ /**
74
+ * Encodes a native bigint.
75
+ *
76
+ * @param value - Bigint
77
+ * @returns Decimal text
78
+ */
79
+ export declare function encodeBigintValue(value: bigint): string;
80
+ /**
81
+ * Decodes a bigint literal to a native bigint.
82
+ *
83
+ * @param wire - Decimal integer
84
+ * @returns A bigint
85
+ */
86
+ export declare function decodeBigintValue(wire: string): bigint;
87
+ /**
88
+ * Encodes an integer that must lie in a closed range.
89
+ *
90
+ * @param value - Integer
91
+ * @param min - Inclusive lower bound
92
+ * @param max - Inclusive upper bound
93
+ * @param role - Type name used in the error
94
+ * @returns Decimal text
95
+ */
96
+ export declare function integerToken(value: number, min: number, max: number, role: string): string;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Reads a Postgres schema into a catalog.
3
+ *
4
+ * Copied partition primary keys and inherited indexes are not objects: a
5
+ * relation that is a child in `pg_inherits` is skipped, and so is an index
6
+ * that is itself inherited (M0-06). Expressions come back from `pg_get_expr`
7
+ * and `pg_get_constraintdef`, which is the database's normalised text (D128).
8
+ */
9
+ import type { Catalog } from "../../contracts/catalog/types.js";
10
+ /** A connection that can run one query. Parameters are `$1`, `$2`, … */
11
+ export type CatalogQuery = {
12
+ /**
13
+ * Runs one query.
14
+ *
15
+ * @param text - SQL
16
+ * @param params - Bound parameters
17
+ * @returns Rows as objects keyed by the select aliases
18
+ */
19
+ query(text: string, params?: readonly string[]): Promise<readonly Record<string, unknown>[]>;
20
+ };
21
+ /**
22
+ * Introspects one concrete schema.
23
+ *
24
+ * Identities use `logical`, not the concrete schema name, so two scratch
25
+ * schemas compare. The default logical namespace is `public`.
26
+ *
27
+ * @param runner - Database connection
28
+ * @param concrete - Schema to read
29
+ * @param logical - Namespace stored on the catalog identities
30
+ * @returns A checked catalog
31
+ */
32
+ export declare function introspectSchema(runner: CatalogQuery, concrete: string, logical?: string): Promise<Catalog>;
33
+ /**
34
+ * Applies one expression as a check and reads Postgres's reprint.
35
+ *
36
+ * Two authoring spellings of the same predicate compare equal after this.
37
+ * A different predicate does not.
38
+ *
39
+ * @param runner - Database connection
40
+ * @param expression - Check expression without the `CHECK` keyword
41
+ * @returns The reprinted expression, without the `CHECK` keyword
42
+ */
43
+ export declare function reprintCheck(runner: CatalogQuery, expression: string): Promise<string>;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * json, jsonb, and the bigint JSON replacer.
3
+ */
4
+ import { type ColumnBuilder, type PlainFlags } from "./column.js";
5
+ /**
6
+ * `JSON.stringify` replacer that writes bigint as a decimal string.
7
+ *
8
+ * `JSON.stringify` throws on a bigint. Projects that choose `bigint: "bigint"`
9
+ * pass this to `JSON.stringify`.
10
+ *
11
+ * @param _key - Property name. Unused
12
+ * @param value - Value about to be serialised
13
+ * @returns A string for bigint, otherwise the value
14
+ */
15
+ export declare function jsonReplacer(_key: string, value: unknown): unknown;
16
+ /**
17
+ * JSON text. `T` is the TypeScript shape; the codec does not check it.
18
+ *
19
+ * @typeParam T - JSON value type
20
+ * @returns A json column
21
+ */
22
+ export declare function json<T = unknown>(): ColumnBuilder<T, PlainFlags>;
23
+ /**
24
+ * Binary JSON. `T` is the TypeScript shape; the codec does not check it.
25
+ *
26
+ * @typeParam T - JSON value type
27
+ * @returns A jsonb column
28
+ */
29
+ export declare function jsonb<T = unknown>(): ColumnBuilder<T, PlainFlags>;
30
+ /**
31
+ * Encodes JSON. Bigint values become decimal strings.
32
+ *
33
+ * @param value - JSON value
34
+ * @returns JSON text
35
+ */
36
+ export declare function encodeJson(value: unknown): string;
37
+ /**
38
+ * Decodes JSON text.
39
+ *
40
+ * @param wire - JSON text
41
+ * @returns The parsed value
42
+ */
43
+ export declare function decodeJson(wire: string): unknown;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * UUID keys.
3
+ */
4
+ import { type ColumnBuilder, type IdFlags, type PlainFlags } from "./column.js";
5
+ /**
6
+ * UUID primary key with default `uuidv7()`.
7
+ *
8
+ * Insert and update omit it, and it is guarded.
9
+ *
10
+ * @returns An id column
11
+ */
12
+ export declare function id(): ColumnBuilder<string, IdFlags>;
13
+ /**
14
+ * UUID text, with no default.
15
+ *
16
+ * @returns A uuid column
17
+ */
18
+ export declare function uuid(): ColumnBuilder<string, PlainFlags>;
19
+ /**
20
+ * Encodes a UUID as lowercase hex with hyphens.
21
+ *
22
+ * @param value - UUID text
23
+ * @returns Canonical UUID
24
+ */
25
+ export declare function encodeUuid(value: string): string;
26
+ /**
27
+ * Decodes UUID text.
28
+ *
29
+ * @param wire - UUID text
30
+ * @returns Canonical UUID
31
+ */
32
+ export declare function decodeUuid(wire: string): string;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Column and codec failures from spec section 21 (D130).
3
+ *
4
+ * OKM1060 is an invalid column definition. OKM1061 is a reserved option this
5
+ * version does not implement. OKM1210 is a value a codec rejects.
6
+ * Messages name the accepted values.
7
+ */
8
+ /** Invalid length, precision, scale, rank, qualifier, or value list. */
9
+ export declare const COLUMN_DEFINITION_CODE = "OKM1060";
10
+ /** A table or schema option reserved for a later prompt. */
11
+ export declare const RESERVED_OPTION_CODE = "OKM1061";
12
+ /** A codec rejected a value. */
13
+ export declare const CODEC_VALUE_CODE = "OKM1210";
14
+ /**
15
+ * Throws OKM1060.
16
+ *
17
+ * @param message - What is wrong with the column definition, including accepted values
18
+ */
19
+ export declare function definition(message: string): never;
20
+ /**
21
+ * Throws OKM1061.
22
+ *
23
+ * @param message - Which option is reserved, and the prompt or milestone that adds it
24
+ */
25
+ export declare function unavailable(message: string): never;
26
+ /**
27
+ * Throws OKM1210.
28
+ *
29
+ * @param message - What the codec refused, including accepted values
30
+ */
31
+ export declare function rejected(message: string): never;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Runtime table model the read path compiles against.
3
+ *
4
+ * `schema()` fills it once. Query planning does not walk column builders again.
5
+ */
6
+ /** One column the planner can filter, select, decode, and write. */
7
+ export type ColumnModel = {
8
+ /** Field name. */
9
+ readonly field: string;
10
+ /** SQL name, already checked as an identifier. */
11
+ readonly sql: string;
12
+ /** Catalog type, used when a value is projected through JSON. */
13
+ readonly dataType: string;
14
+ /** Codec encode. Identity text still returns the same string. */
15
+ readonly encode: (value: unknown) => string;
16
+ /**
17
+ * Codec decode.
18
+ *
19
+ * Omitted when the wire text is the TypeScript value, so a row does not
20
+ * call a codec it does not need.
21
+ */
22
+ readonly decode: ((wire: string) => unknown) | undefined;
23
+ /** Excluded from a default select. Named selects still return it. */
24
+ readonly hidden: boolean;
25
+ /** Refused when present in insert or update input. */
26
+ readonly guarded: boolean;
27
+ /** Included in insert and update. Guarded, generated, and omitted columns are not. */
28
+ readonly writable: boolean;
29
+ };
30
+ /**
31
+ * A resolved relation.
32
+ *
33
+ * The join is always `related.{remote} = this.{local}`.
34
+ */
35
+ export type RelationModel = {
36
+ readonly name: string;
37
+ readonly kind: "one" | "many";
38
+ /** Related table's TypeScript name. */
39
+ readonly table: string;
40
+ /** SQL names on this table. */
41
+ readonly local: readonly string[];
42
+ /** SQL names on the related table. */
43
+ readonly remote: readonly string[];
44
+ };
45
+ /** One table, keyed by its TypeScript name on the schema. */
46
+ export type TableModel = {
47
+ readonly name: string;
48
+ readonly sql: string;
49
+ /** Primary-key field names, in catalog order. */
50
+ readonly primary: readonly string[];
51
+ /**
52
+ * Field lists that `onConflict.on` may name.
53
+ *
54
+ * Each list is a primary key or a unique constraint. Order is the catalog order.
55
+ */
56
+ readonly uniques: readonly (readonly string[])[];
57
+ readonly columns: readonly ColumnModel[];
58
+ readonly relations: readonly RelationModel[];
59
+ };
60
+ /** Schema fields the read path and `connect()` read. */
61
+ export type QuerySchema = {
62
+ readonly "~byName": {
63
+ readonly [name: string]: {
64
+ readonly "~row": unknown;
65
+ };
66
+ };
67
+ readonly model: Readonly<Record<string, TableModel>>;
68
+ readonly requires?: {
69
+ readonly postgres?: string;
70
+ } | undefined;
71
+ };
@@ -0,0 +1,63 @@
1
+ /**
2
+ * `t` namespace from spec section 6.4.
3
+ *
4
+ * Importing `t` pulls every builder. Import one builder when an application
5
+ * uses only that type.
6
+ */
7
+ import { boolean, bytea } from "./bool.js";
8
+ import { custom } from "./custom.js";
9
+ import { double, numeric, real } from "./decimal.js";
10
+ import { domain, enumColumn } from "./enum.js";
11
+ import { line, point } from "./geometry.js";
12
+ import { bigint, identity, integer, smallint } from "./integer.js";
13
+ import { json, jsonb } from "./json.js";
14
+ import { id, uuid } from "./keys.js";
15
+ import { cidr, inet, macaddr, macaddr8 } from "./network.js";
16
+ import { daterange, int4range, int8range, numrange, tstzrange } from "./range.js";
17
+ import { ltree, tsvector } from "./search.js";
18
+ import { char, citext, text, varchar } from "./text.js";
19
+ import { date, interval, time, timestamp, timestamptz, timetz } from "./time.js";
20
+ /**
21
+ * Postgres column builders.
22
+ */
23
+ export declare const t: {
24
+ id: typeof id;
25
+ identity: typeof identity;
26
+ uuid: typeof uuid;
27
+ smallint: typeof smallint;
28
+ integer: typeof integer;
29
+ bigint: typeof bigint;
30
+ numeric: typeof numeric;
31
+ real: typeof real;
32
+ double: typeof double;
33
+ text: typeof text;
34
+ varchar: typeof varchar;
35
+ char: typeof char;
36
+ citext: typeof citext;
37
+ boolean: typeof boolean;
38
+ bytea: typeof bytea;
39
+ json: typeof json;
40
+ jsonb: typeof jsonb;
41
+ timestamptz: typeof timestamptz;
42
+ timestamp: typeof timestamp;
43
+ date: typeof date;
44
+ time: typeof time;
45
+ timetz: typeof timetz;
46
+ interval: typeof interval;
47
+ tstzrange: typeof tstzrange;
48
+ daterange: typeof daterange;
49
+ int4range: typeof int4range;
50
+ int8range: typeof int8range;
51
+ numrange: typeof numrange;
52
+ inet: typeof inet;
53
+ cidr: typeof cidr;
54
+ macaddr: typeof macaddr;
55
+ macaddr8: typeof macaddr8;
56
+ point: typeof point;
57
+ line: typeof line;
58
+ tsvector: typeof tsvector;
59
+ ltree: typeof ltree;
60
+ enum: typeof enumColumn;
61
+ domain: typeof domain;
62
+ custom: typeof custom;
63
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Network address columns. Values are canonical text.
3
+ */
4
+ import { type ColumnBuilder, type PlainFlags } from "./column.js";
5
+ /**
6
+ * IPv4 or IPv6 host, with an optional prefix.
7
+ *
8
+ * @returns An inet column
9
+ */
10
+ export declare function inet(): ColumnBuilder<string, PlainFlags>;
11
+ /**
12
+ * IPv4 or IPv6 network. A prefix is required.
13
+ *
14
+ * @returns A cidr column
15
+ */
16
+ export declare function cidr(): ColumnBuilder<string, PlainFlags>;
17
+ /**
18
+ * 48-bit MAC address, lowercase.
19
+ *
20
+ * @returns A macaddr column
21
+ */
22
+ export declare function macaddr(): ColumnBuilder<string, PlainFlags>;
23
+ /**
24
+ * 64-bit MAC address, lowercase.
25
+ *
26
+ * @returns A macaddr8 column
27
+ */
28
+ export declare function macaddr8(): ColumnBuilder<string, PlainFlags>;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Tagged filter operators (spec §10.1, D125).
3
+ *
4
+ * The brand is a symbol. JSON cannot create one, so request data cannot add
5
+ * an operator or traverse a relation. A plain object stays OKM1121.
6
+ */
7
+ declare const brand: unique symbol;
8
+ declare const RUNTIME: unique symbol;
9
+ /** Operator names the read path compiles. */
10
+ export type OperatorName = "eq" | "lt" | "lte" | "gt" | "gte" | "between" | "startsWith" | "contains" | "endsWith" | "like" | "ilike" | "inList" | "notIn" | "not" | "or" | "has" | "none" | "every" | "inc";
11
+ /** A tagged operator. `value` is the operand the helper stored. */
12
+ export type Tagged<Name extends OperatorName, V> = {
13
+ readonly [brand]: Name;
14
+ readonly value: V;
15
+ };
16
+ /** Equality, including json and jsonb (D125). */
17
+ export type Eq<V> = Tagged<"eq", V>;
18
+ /** One-sided comparison. */
19
+ export type Compare<Name extends "lt" | "lte" | "gt" | "gte", V> = Tagged<Name, V>;
20
+ /** Inclusive range. */
21
+ export type Between<V> = Tagged<"between", readonly [V, V]>;
22
+ /** A literal pattern. `%`, `_`, and `\` in the value are escaped. */
23
+ export type Pattern<Name extends "startsWith" | "contains" | "endsWith"> = Tagged<Name, string>;
24
+ /** A raw `LIKE` or `ILIKE` pattern. The caller owns the wildcards. */
25
+ export type RawPattern<Name extends "like" | "ilike"> = Tagged<Name, string>;
26
+ /** Membership. An empty list matches nothing. */
27
+ export type InList<V> = Tagged<"inList", readonly V[]>;
28
+ /** The complement of {@link InList}. An empty list matches everything. */
29
+ export type NotIn<V> = Tagged<"notIn", readonly V[]>;
30
+ /** Negation of null, a value, or another operator. */
31
+ export type Not<V> = Tagged<"not", V>;
32
+ /** Disjunction. Each branch is a where object. */
33
+ export type Or<V> = Tagged<"or", readonly V[]>;
34
+ /** A relation filter. The value is the related table's where. */
35
+ export type RelationFilter<Name extends "has" | "none" | "every", V> = Tagged<Name, V>;
36
+ type AnyTagged = {
37
+ readonly [RUNTIME]: OperatorName;
38
+ readonly value: unknown;
39
+ };
40
+ /**
41
+ * Reports whether `value` is a tagged operator.
42
+ *
43
+ * @param value - A where operand
44
+ * @returns `true` when a helper created it
45
+ */
46
+ export declare function isOperator(value: unknown): value is AnyTagged;
47
+ /**
48
+ * Reads the operator name.
49
+ *
50
+ * @param value - A value {@link isOperator} accepted
51
+ * @returns The helper that created it
52
+ */
53
+ export declare function operatorName(value: AnyTagged): OperatorName;
54
+ /**
55
+ * Reads the operand.
56
+ *
57
+ * @param value - A value {@link isOperator} accepted
58
+ * @returns The operand the helper stored
59
+ */
60
+ export declare function operatorValue(value: AnyTagged): unknown;
61
+ /**
62
+ * Tags an operator. Each helper lives in its own module so unused ones drop out.
63
+ *
64
+ * @typeParam Name - Operator name
65
+ * @typeParam V - Operand
66
+ * @param name - Operator name
67
+ * @param value - Operand
68
+ * @returns A tagged operator
69
+ */
70
+ export declare function tag<Name extends OperatorName, V>(name: Name, value: V): Tagged<Name, V>;
71
+ export {};
@@ -0,0 +1,10 @@
1
+ import { type Between } from "../operators.js";
2
+ /**
3
+ * Inclusive range.
4
+ *
5
+ * @typeParam V - Operand
6
+ * @param from - Lower bound
7
+ * @param to - Upper bound
8
+ * @returns A tagged operator
9
+ */
10
+ export declare function between<const V>(from: V, to: V): Between<V>;
@@ -0,0 +1,8 @@
1
+ import { type Pattern } from "../operators.js";
2
+ /**
3
+ * Case-sensitive substring. `%`, `_`, and `\` in `value` are escaped.
4
+ *
5
+ * @param value - Literal substring
6
+ * @returns A tagged operator
7
+ */
8
+ export declare function contains(value: string): Pattern<"contains">;
@@ -0,0 +1,8 @@
1
+ import { type Pattern } from "../operators.js";
2
+ /**
3
+ * Case-sensitive suffix. `%`, `_`, and `\` in `value` are escaped.
4
+ *
5
+ * @param value - Literal suffix
6
+ * @returns A tagged operator
7
+ */
8
+ export declare function endsWith(value: string): Pattern<"endsWith">;
@@ -0,0 +1,9 @@
1
+ import { type Eq } from "../operators.js";
2
+ /**
3
+ * Equality. This is the form for json and jsonb (D125).
4
+ *
5
+ * @typeParam V - Operand
6
+ * @param value - Value to compare
7
+ * @returns A tagged operator
8
+ */
9
+ export declare function eq<const V>(value: V): Eq<V>;
@@ -0,0 +1,9 @@
1
+ import { type RelationFilter } from "../operators.js";
2
+ /**
3
+ * Every related row matches. True when there are no related rows.
4
+ *
5
+ * @typeParam V - Related where
6
+ * @param where - Filter on the related table
7
+ * @returns A relation filter
8
+ */
9
+ export declare function every<const V>(where: V): RelationFilter<"every", V>;
@@ -0,0 +1,9 @@
1
+ import { type Compare } from "../operators.js";
2
+ /**
3
+ * Greater than.
4
+ *
5
+ * @typeParam V - Operand
6
+ * @param value - Lower bound, exclusive
7
+ * @returns A tagged operator
8
+ */
9
+ export declare function gt<const V>(value: V): Compare<"gt", V>;
@@ -0,0 +1,9 @@
1
+ import { type Compare } from "../operators.js";
2
+ /**
3
+ * Greater than or equal.
4
+ *
5
+ * @typeParam V - Operand
6
+ * @param value - Lower bound, inclusive
7
+ * @returns A tagged operator
8
+ */
9
+ export declare function gte<const V>(value: V): Compare<"gte", V>;
@@ -0,0 +1,9 @@
1
+ import { type RelationFilter } from "../operators.js";
2
+ /**
3
+ * Related rows exist.
4
+ *
5
+ * @typeParam V - Related where
6
+ * @param where - Filter on the related table
7
+ * @returns A relation filter
8
+ */
9
+ export declare function has<const V>(where: V): RelationFilter<"has", V>;
@@ -0,0 +1,8 @@
1
+ import { type RawPattern } from "../operators.js";
2
+ /**
3
+ * Raw `ILIKE` pattern. Wildcards are not escaped.
4
+ *
5
+ * @param pattern - Pattern the caller wrote
6
+ * @returns A tagged operator
7
+ */
8
+ export declare function ilike(pattern: string): RawPattern<"ilike">;
@@ -0,0 +1,9 @@
1
+ import { type InList } from "../operators.js";
2
+ /**
3
+ * Membership. An empty list matches nothing and does not become `IN ()`.
4
+ *
5
+ * @typeParam V - Element
6
+ * @param values - Accepted values
7
+ * @returns A tagged operator
8
+ */
9
+ export declare function inList<const V>(values: readonly V[]): InList<V>;
@@ -0,0 +1,13 @@
1
+ import { type Tagged } from "../operators.js";
2
+ /** Adds to the stored number. `undefined` in `set` still leaves the field unchanged. */
3
+ export type Inc<V> = Tagged<"inc", V>;
4
+ /**
5
+ * Atomic increment used in `update` `set` (spec §11).
6
+ *
7
+ * JSON and array operators are not this helper.
8
+ *
9
+ * @typeParam V - Amount
10
+ * @param value - Amount to add
11
+ * @returns A tagged operator
12
+ */
13
+ export declare function inc<const V>(value: V): Inc<V>;
@@ -0,0 +1,8 @@
1
+ import { type RawPattern } from "../operators.js";
2
+ /**
3
+ * Raw `LIKE` pattern. Wildcards are not escaped.
4
+ *
5
+ * @param pattern - Pattern the caller wrote
6
+ * @returns A tagged operator
7
+ */
8
+ export declare function like(pattern: string): RawPattern<"like">;
@@ -0,0 +1,9 @@
1
+ import { type Compare } from "../operators.js";
2
+ /**
3
+ * Less than.
4
+ *
5
+ * @typeParam V - Operand
6
+ * @param value - Upper bound, exclusive
7
+ * @returns A tagged operator
8
+ */
9
+ export declare function lt<const V>(value: V): Compare<"lt", V>;
@@ -0,0 +1,9 @@
1
+ import { type Compare } from "../operators.js";
2
+ /**
3
+ * Less than or equal.
4
+ *
5
+ * @typeParam V - Operand
6
+ * @param value - Upper bound, inclusive
7
+ * @returns A tagged operator
8
+ */
9
+ export declare function lte<const V>(value: V): Compare<"lte", V>;
@@ -0,0 +1,9 @@
1
+ import { type RelationFilter } from "../operators.js";
2
+ /**
3
+ * No related row matches.
4
+ *
5
+ * @typeParam V - Related where
6
+ * @param where - Filter on the related table
7
+ * @returns A relation filter
8
+ */
9
+ export declare function none<const V>(where: V): RelationFilter<"none", V>;
@@ -0,0 +1,9 @@
1
+ import { type Not } from "../operators.js";
2
+ /**
3
+ * Negation. `not(null)` is `IS NOT NULL`.
4
+ *
5
+ * @typeParam V - Operand
6
+ * @param value - Null, a value, or another operator
7
+ * @returns A tagged operator
8
+ */
9
+ export declare function not<const V>(value: V): Not<V>;
@@ -0,0 +1,9 @@
1
+ import { type NotIn } from "../operators.js";
2
+ /**
3
+ * Complement of {@link inList}. An empty list matches everything.
4
+ *
5
+ * @typeParam V - Element
6
+ * @param values - Rejected values
7
+ * @returns A tagged operator
8
+ */
9
+ export declare function notIn<const V>(values: readonly V[]): NotIn<V>;