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.
Files changed (147) hide show
  1. package/README.md +246 -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 +385 -0
  100. package/dist/runtime/write.d.ts +48 -0
  101. package/dist/shared/05w44d8g.js +1524 -0
  102. package/dist/shared/523ft3e8.js +171 -0
  103. package/dist/shared/8b04d28c.js +14 -0
  104. package/dist/shared/cn0n68ft.js +16 -0
  105. package/dist/shared/dkn3y60a.js +374 -0
  106. package/dist/shared/dynq16vb.js +81 -0
  107. package/dist/shared/fgqgsb5z.js +281 -0
  108. package/dist/shared/g5fhqmwe.js +188 -0
  109. package/dist/shared/gk7cs7sp.js +566 -0
  110. package/dist/shared/hadrfb9h.js +398 -0
  111. package/dist/shared/hd293j9g.js +98 -0
  112. package/dist/shared/j5cn2963.js +701 -0
  113. package/dist/shared/jjb7yht9.js +37 -0
  114. package/dist/shared/kprcwaha.js +30 -0
  115. package/dist/shared/m3ypagh5.js +347 -0
  116. package/dist/shared/mkjmqjv4.js +456 -0
  117. package/dist/shared/mtkwv8wx.js +18 -0
  118. package/dist/shared/ngk8gj61.js +40 -0
  119. package/dist/shared/p0cbr3g2.js +79 -0
  120. package/dist/shared/qk3hxfja.js +83 -0
  121. package/dist/shared/rgs0st28.js +1066 -0
  122. package/dist/shared/w8samvk1.js +18 -0
  123. package/dist/shared/x5x59srr.js +566 -0
  124. package/dist/shared/xqbhg6cn.js +119 -0
  125. package/dist/shared/xy79j5hq.js +177 -0
  126. package/dist/shared/y9m15dfv.js +888 -0
  127. package/dist/shared/ycwz42az.js +412 -0
  128. package/dist/shared/yd1kzwn2.js +148 -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 +109 -7
  147. 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";