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,71 @@
1
+ /**
2
+ * Identifier rules and deterministic constraint and index names.
3
+ *
4
+ * Postgres stores 63 bytes (`NAMEDATALEN` minus the trailing NUL). A generated
5
+ * name that would be longer keeps a hash suffix so two long names stay distinct.
6
+ * The name is a function of a stable key, not of the field's current name, so
7
+ * renaming a field does not rename the constraint.
8
+ */
9
+ import { utf8ByteLength } from "../utf8.js";
10
+ /** Maximum Postgres identifier size in bytes. `NAMEDATALEN - 1`. */
11
+ export declare const POSTGRES_IDENTIFIER_MAX_BYTES = 63;
12
+ /** Why a constraint or index name is being generated. */
13
+ export type NamePurpose = "primaryKey" | "unique" | "foreignKey" | "check" | "index";
14
+ export { utf8ByteLength };
15
+ /**
16
+ * Reports whether a name is an unquoted reserved word.
17
+ *
18
+ * Comparison is case-insensitive.
19
+ *
20
+ * @param name - Candidate identifier
21
+ * @returns `true` when Postgres would reject the unquoted word
22
+ */
23
+ export declare function isReservedIdentifier(name: string): boolean;
24
+ /**
25
+ * Rejects a name that fails the identifier rules.
26
+ *
27
+ * The rules are empty, NUL, other control characters, byte length, and an
28
+ * unquoted reserved word (OKM1122).
29
+ *
30
+ * @param name - Candidate identifier
31
+ * @param role - What the name refers to, used in the error
32
+ * @param limit - Dialect byte limit. Defaults to the Postgres limit
33
+ */
34
+ export declare function assertIdentifier(name: string, role: string, limit?: number): void;
35
+ /**
36
+ * Returns a name the dialect can store without truncating it.
37
+ *
38
+ * Names that already fit are unchanged, including reserved words (those are
39
+ * rejected by {@link assertIdentifier} before a name is stored). Longer names
40
+ * become a UTF-8 prefix, an underscore, and the first 8 hex characters of the
41
+ * SHA-256 of the original name.
42
+ *
43
+ * @param name - Requested identifier
44
+ * @param limit - Dialect byte limit. Defaults to the Postgres limit
45
+ * @returns The name to store
46
+ */
47
+ export declare function fitIdentifier(name: string, limit?: number): string;
48
+ /**
49
+ * Generates a constraint or index name.
50
+ *
51
+ * Primary keys are `{parent}_pkey`, so the column name is not part of the
52
+ * name. Other purposes are `{parent}_{nameKey}_{tag}`. `nameKey` is chosen
53
+ * once and kept; a later field rename must pass the same key. A result that
54
+ * exceeds `limit` is fitted with a hash suffix.
55
+ *
56
+ * @param input - Parent, purpose, stable key, and dialect limit
57
+ * @returns The name to store on the object
58
+ */
59
+ export declare function deterministicName(input: {
60
+ readonly parent: string;
61
+ readonly purpose: NamePurpose;
62
+ readonly nameKey?: string;
63
+ readonly limit?: number;
64
+ }): string;
65
+ /**
66
+ * Rejects NUL and other control characters in text that is not an identifier.
67
+ *
68
+ * @param value - Text stored in a definition
69
+ * @param role - What the text refers to
70
+ */
71
+ export declare function assertStoredText(value: string, role: string): void;
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Namespaces, identity keys, and tenant resolution.
3
+ *
4
+ * The identity key is canonical JSON, so key order and runtime do not change it.
5
+ * Resolving a template never rewrites the identity.
6
+ */
7
+ import { type Json } from "./json.js";
8
+ import type { Namespace, ObjectIdentity, ObjectKind, ObjectRef } from "./types.js";
9
+ /**
10
+ * A concrete schema name.
11
+ *
12
+ * @param name - Schema name stored in the catalog
13
+ * @returns A namespace that is not a template
14
+ */
15
+ export declare function staticNamespace(name: string): Namespace;
16
+ /**
17
+ * A namespace template such as `tenant_{id}`.
18
+ *
19
+ * The pattern must contain `{id}`. Every other character is an identifier
20
+ * character. The pattern is stored as written.
21
+ *
22
+ * @param pattern - Pattern containing the `{id}` placeholder
23
+ * @returns A template namespace
24
+ */
25
+ export declare function templateNamespace(pattern: string): Namespace;
26
+ /**
27
+ * Rejects a namespace that cannot be stored.
28
+ *
29
+ * Static names follow the identifier rules. Templates must contain `{id}`.
30
+ *
31
+ * @param namespace - Namespace to check
32
+ */
33
+ export declare function assertNamespace(namespace: Namespace): void;
34
+ /**
35
+ * Resolves a namespace for one tenant id.
36
+ *
37
+ * Static namespaces return their name. Templates substitute `{id}`. A
38
+ * hyphenated UUID is written as 32 lowercase hex digits so the result can
39
+ * enter an identifier. The id must be that UUID or `[a-z0-9_]`.
40
+ *
41
+ * @param namespace - Logical namespace
42
+ * @param tenantId - Tenant id. Ignored for a static namespace
43
+ * @returns The schema name to use at execution time
44
+ */
45
+ export declare function resolveNamespace(namespace: Namespace, tenantId?: string): string;
46
+ /**
47
+ * Stable identity key.
48
+ *
49
+ * @param identity - Object identity
50
+ * @returns Canonical JSON of the identity
51
+ */
52
+ export declare function identityKey(identity: ObjectIdentity): string;
53
+ /**
54
+ * Reports whether the dialect length limit applies to a kind.
55
+ *
56
+ * Grants and default privileges use a structured key and are exempt (D119).
57
+ *
58
+ * @param kind - Object kind
59
+ * @returns `false` for grants and default privileges
60
+ */
61
+ export declare function identifierLimitApplies(kind: ObjectKind): boolean;
62
+ /**
63
+ * Short label for an identity, used in error messages.
64
+ *
65
+ * @param identity - Object identity
66
+ * @returns Kind and name
67
+ */
68
+ export declare function identityLabel(identity: ObjectIdentity): string;
69
+ /**
70
+ * Reports whether two parent refs are the same logical object.
71
+ *
72
+ * @param left - First ref
73
+ * @param right - Second ref
74
+ * @returns `true` when namespace and name match
75
+ */
76
+ export declare function sameRef(left: ObjectRef, right: ObjectRef): boolean;
77
+ /**
78
+ * Reports whether two namespaces are the same logical namespace.
79
+ *
80
+ * @param left - First namespace
81
+ * @param right - Second namespace
82
+ * @returns `true` when form and text match
83
+ */
84
+ export declare function sameNamespace(left: Namespace, right: Namespace): boolean;
85
+ /**
86
+ * Canonical JSON for an identity.
87
+ *
88
+ * @param identity - Object identity
89
+ * @returns JSON object
90
+ */
91
+ export declare function identityToJson(identity: ObjectIdentity): Json;
92
+ /**
93
+ * Canonical JSON for a namespace.
94
+ *
95
+ * @param namespace - Static or template namespace
96
+ * @returns JSON object
97
+ */
98
+ export declare function namespaceToJson(namespace: Namespace): Json;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Catalog contract for the runtime entry: envelope, identity, and names.
3
+ *
4
+ * Document checks, serialisation, parsing, hashing, and dependency order live
5
+ * in `document.ts` and `order.ts`. They are tooling and are not re-exported
6
+ * from the package entry.
7
+ */
8
+ export { BUILT_KINDS, CATALOG_VERSION, KIND_OPERATIONS, OBJECT_KINDS, OBJECT_OPERATIONS, OWNERS, type AnchoredIdentity, type BuiltKind, type Catalog, type CatalogEnvelope, type CatalogObject, type ColumnDefinition, type ColumnObject, type ConstraintDefinition, type ConstraintKind, type ConstraintObject, type DefaultPrivilegeIdentity, type DependencyEdge, type ExtensionIdentity, type FunctionIdentity, type GrantIdentity, type GrantObjectRef, type IndexDefinition, type IndexObject, type Namespace, type NamespaceIdentity, type ObjectIdentity, type ObjectKind, type ObjectOperation, type ObjectRef, type Owner, type PartitionMethod, type Provenance, type ReferentialAction, type RoleIdentity, type SequenceDefinition, type SequenceObject, type TableDefinition, type TableObject, type TypeDefinition, type TypeObject, } from "./types.js";
9
+ export { assertNamespace, identityKey, identityLabel, identifierLimitApplies, resolveNamespace, sameNamespace, sameRef, staticNamespace, templateNamespace, } from "./identity.js";
10
+ export { POSTGRES_IDENTIFIER_MAX_BYTES, assertIdentifier, deterministicName, fitIdentifier, isReservedIdentifier, utf8ByteLength, type NamePurpose, } from "./identifier.js";
11
+ export { column, constraint, index, sequence, table, type ColumnInput, type ConstraintInput, type IndexInput, type SequenceInput, type TableInput, } from "./object.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Canonical JSON.
3
+ *
4
+ * Object keys are sorted. Strings are ASCII-only escapes, so the same value
5
+ * produces the same bytes on every runtime. Arrays keep their order.
6
+ */
7
+ /** JSON values the canonical encoder accepts. Numbers are safe integers. */
8
+ export type Json = null | boolean | number | string | readonly Json[] | {
9
+ readonly [key: string]: Json | undefined;
10
+ };
11
+ /**
12
+ * Encodes a value with object keys sorted at every level.
13
+ *
14
+ * @param value - JSON value
15
+ * @returns Canonical text
16
+ */
17
+ export declare function canonicalJson(value: Json): string;
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Factories for the built catalog kinds.
3
+ *
4
+ * Each factory stores ownership, a normalised definition, and dependency
5
+ * edges. Constraint and index names are generated from a stable key and then
6
+ * left alone.
7
+ */
8
+ import { type ColumnObject, type ConstraintKind, type ConstraintObject, type DependencyEdge, type IndexObject, type Namespace, type ObjectIdentity, type ObjectRef, type Owner, type Provenance, type ReferentialAction, type SequenceDefinition, type SequenceObject, type TableDefinition, type TableObject } from "./types.js";
9
+ /** Fields every factory accepts. */
10
+ type CommonInput = {
11
+ readonly owner?: Owner;
12
+ readonly provenance: Provenance;
13
+ readonly dependencies?: readonly ObjectIdentity[];
14
+ };
15
+ /** Input for {@link table}. */
16
+ export type TableInput = CommonInput & {
17
+ readonly namespace: Namespace;
18
+ readonly name: string;
19
+ readonly partition?: TableDefinition["partition"];
20
+ };
21
+ /** Input for {@link column}. */
22
+ export type ColumnInput = CommonInput & {
23
+ readonly parent: ObjectRef;
24
+ readonly name: string;
25
+ readonly dataType: string;
26
+ readonly nullable: boolean;
27
+ readonly defaultExpression?: string;
28
+ readonly identity?: {
29
+ readonly always: boolean;
30
+ };
31
+ readonly generated?: {
32
+ readonly stored: boolean;
33
+ readonly expression: string;
34
+ };
35
+ };
36
+ /** Input for {@link index}. */
37
+ export type IndexInput = CommonInput & {
38
+ readonly parent: ObjectRef;
39
+ readonly name?: string;
40
+ readonly nameKey?: string;
41
+ readonly columns?: readonly string[];
42
+ readonly unique?: boolean;
43
+ readonly predicate?: string;
44
+ readonly expression?: string;
45
+ };
46
+ /** Input for {@link constraint}. */
47
+ export type ConstraintInput = CommonInput & {
48
+ readonly parent: ObjectRef;
49
+ readonly constraintKind: ConstraintKind;
50
+ readonly name?: string;
51
+ readonly nameKey?: string;
52
+ readonly columns?: readonly string[];
53
+ readonly expression?: string;
54
+ readonly references?: {
55
+ readonly parent: ObjectRef;
56
+ readonly columns: readonly string[];
57
+ readonly onDelete?: ReferentialAction;
58
+ readonly onUpdate?: ReferentialAction;
59
+ };
60
+ readonly deferrable?: boolean;
61
+ readonly initially?: "immediate" | "deferred";
62
+ readonly nullsNotDistinct?: boolean;
63
+ };
64
+ /** Input for {@link sequence}. */
65
+ export type SequenceInput = CommonInput & {
66
+ readonly namespace: Namespace;
67
+ readonly name: string;
68
+ readonly dataType?: SequenceDefinition["dataType"];
69
+ readonly start?: string;
70
+ readonly increment?: string;
71
+ readonly cycle?: boolean;
72
+ };
73
+ /**
74
+ * Builds a table object.
75
+ *
76
+ * A partitioned table sets `partition`. Copied partition primary keys and
77
+ * inherited indexes are not created; they are not catalog objects.
78
+ *
79
+ * @param input - Name, namespace, ownership, and optional partition
80
+ * @returns A table envelope
81
+ */
82
+ export declare function table(input: TableInput): TableObject;
83
+ /**
84
+ * Builds a column object.
85
+ *
86
+ * The column depends on its parent table. Extra dependencies (a sequence, for
87
+ * example) are kept.
88
+ *
89
+ * @param input - Parent, name, type, and nullability
90
+ * @returns A column envelope
91
+ */
92
+ export declare function column(input: ColumnInput): ColumnObject;
93
+ /**
94
+ * Builds an index object.
95
+ *
96
+ * The stored name comes from {@link deterministicName} unless `name` is set.
97
+ * Either way a name past the dialect limit is fitted. `nameKey` is what a
98
+ * later rename must keep passing.
99
+ *
100
+ * @param input - Parent, columns, and the stable name key
101
+ * @returns An index envelope
102
+ */
103
+ export declare function index(input: IndexInput): IndexObject;
104
+ /**
105
+ * Builds a constraint object.
106
+ *
107
+ * Primary key names are `{parent}_pkey` and do not include column names.
108
+ * Other names use `nameKey`, which stays fixed when a field is renamed.
109
+ *
110
+ * @param input - Parent, kind, columns, and the stable name key
111
+ * @returns A constraint envelope
112
+ */
113
+ export declare function constraint(input: ConstraintInput): ConstraintObject;
114
+ /**
115
+ * Builds a sequence object.
116
+ *
117
+ * @param input - Namespace, name, and sequence counters
118
+ * @returns A sequence envelope
119
+ */
120
+ export declare function sequence(input: SequenceInput): SequenceObject;
121
+ /**
122
+ * Sorts and dedupes dependency targets.
123
+ *
124
+ * @param targets - Identity targets, structural ones first
125
+ * @returns Edges in identity-key order
126
+ */
127
+ export declare function normaliseEdges(targets: readonly ObjectIdentity[]): readonly DependencyEdge[];
128
+ /**
129
+ * Compares two strings by UTF-16 code unit, which is stable across runtimes.
130
+ *
131
+ * @param left - First string
132
+ * @param right - Second string
133
+ * @returns A negative, zero, or positive number
134
+ */
135
+ export declare function compareText(left: string, right: string): number;
136
+ /**
137
+ * Rejects a provenance that cannot be stored.
138
+ *
139
+ * @param provenance - Origin and name
140
+ */
141
+ export declare function assertProvenance(provenance: Provenance): void;
142
+ export {};
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Dependency order.
3
+ *
4
+ * Create order is a topological order: dependencies first, ties broken by
5
+ * identity key. The comparison is UTF-16 code unit order, not a locale.
6
+ * Each object's identity key is computed once per pass.
7
+ */
8
+ import type { CatalogObject } from "./types.js";
9
+ /** One catalog object and the identity key computed for it. */
10
+ export type IndexedObject = {
11
+ readonly key: string;
12
+ readonly object: CatalogObject;
13
+ };
14
+ /**
15
+ * Computes each object's identity key once.
16
+ *
17
+ * A duplicate identity is OKM1023.
18
+ *
19
+ * @param objects - Catalog objects
20
+ * @returns Objects paired with their keys, in input order
21
+ */
22
+ export declare function indexObjects(objects: readonly CatalogObject[]): readonly IndexedObject[];
23
+ /**
24
+ * Orders objects so each dependency appears before the object that needs it.
25
+ *
26
+ * A cycle is OKM1026. A self-edge, or a target that is not in `objects`, is
27
+ * OKM1020. A duplicate identity is OKM1023.
28
+ *
29
+ * @param objects - Catalog objects to order
30
+ * @returns Create order
31
+ */
32
+ export declare function dependencyOrder(objects: readonly CatalogObject[]): readonly CatalogObject[];
33
+ /**
34
+ * Topological order of objects whose identity keys are already known.
35
+ *
36
+ * A cycle is OKM1026. A self-edge, or a target that is not in `indexed`, is
37
+ * OKM1020.
38
+ * `indexed` must not contain duplicate keys.
39
+ *
40
+ * @param indexed - Objects paired with identity keys
41
+ * @returns Create order
42
+ */
43
+ export declare function orderIndexed(indexed: readonly IndexedObject[]): readonly CatalogObject[];
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Rewrites an identifier inside stored expression text.
3
+ *
4
+ * Check expressions and index predicates are text (D128). A declared rename
5
+ * updates references in that text and leaves string literals alone.
6
+ */
7
+ /**
8
+ * Replaces `from` with `to` outside single-quoted strings.
9
+ *
10
+ * Quoted identifiers (`"from"`) and bare words both change. A word inside a
11
+ * SQL string does not.
12
+ *
13
+ * @param text - Expression text
14
+ * @param from - Identifier to replace
15
+ * @param to - Replacement identifier
16
+ * @returns The expression, or the same string when nothing changed
17
+ */
18
+ export declare function replaceIdentifier(text: string, from: string, to: string): string;