okmodel 0.1.1 → 0.3.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 +727 -37
- package/dist/adapters/capabilities.d.ts +34 -0
- package/dist/adapters/pg/bunsql-extra.d.ts +17 -0
- package/dist/adapters/pg/bunsql.d.ts +60 -0
- package/dist/adapters/pg/call.d.ts +2 -12
- package/dist/adapters/pg/nodepostgres-extra.d.ts +18 -0
- package/dist/adapters/pg/nodepostgres.d.ts +57 -0
- package/dist/adapters/pg/postgres-extra.d.ts +50 -1
- package/dist/adapters/pg/postgresjs.d.ts +0 -4
- package/dist/adapters/pg/session.d.ts +94 -0
- package/dist/adapters/pg/watch.d.ts +18 -0
- package/dist/contracts/catalog/enum.d.ts +31 -4
- package/dist/contracts/catalog/extension.d.ts +61 -0
- package/dist/contracts/catalog/object.d.ts +1 -0
- package/dist/contracts/catalog/privilege.d.ts +64 -0
- package/dist/contracts/catalog/routine.d.ts +56 -0
- package/dist/contracts/catalog/types.d.ts +179 -18
- package/dist/contracts/catalog/view.d.ts +73 -0
- package/dist/contracts/connection.d.ts +13 -0
- package/dist/contracts/driver.d.ts +18 -5
- package/dist/contracts/error.d.ts +17 -1
- package/dist/contracts/generator.d.ts +63 -0
- package/dist/contracts/index.d.ts +2 -2
- package/dist/contracts/index.js +1 -1
- package/dist/contracts/internal.js +11 -9
- package/dist/contracts/location.d.ts +24 -0
- package/dist/contracts/rows.d.ts +15 -0
- package/dist/dialects/pg/archive-bind.d.ts +22 -0
- package/dist/dialects/pg/column.d.ts +129 -10
- package/dist/dialects/pg/compile.d.ts +1 -0
- package/dist/dialects/pg/custom.d.ts +6 -0
- package/dist/dialects/pg/ddl.d.ts +65 -1
- package/dist/dialects/pg/enum.d.ts +10 -8
- package/dist/dialects/pg/ext/citext.d.ts +14 -0
- package/dist/dialects/pg/ext/citext.js +11 -0
- package/dist/dialects/pg/ext/index.d.ts +52 -0
- package/dist/dialects/pg/ext/index.js +6 -0
- package/dist/dialects/pg/ext/pg-trgm.d.ts +53 -0
- package/dist/dialects/pg/ext/pg-trgm.js +42 -0
- package/dist/dialects/pg/filter-parse.d.ts +19 -0
- package/dist/dialects/pg/filters.d.ts +19 -0
- package/dist/dialects/pg/fn/index.d.ts +107 -0
- package/dist/dialects/pg/fn/index.js +175 -0
- package/dist/dialects/pg/fn/touch.d.ts +14 -0
- package/dist/dialects/pg/index.d.ts +11 -2
- package/dist/dialects/pg/index.js +243 -1062
- package/dist/dialects/pg/introspect.d.ts +10 -1
- package/dist/dialects/pg/keys.d.ts +19 -3
- package/dist/dialects/pg/model.d.ts +223 -2
- package/dist/dialects/pg/operator-fit.d.ts +86 -0
- package/dist/dialects/pg/operators.d.ts +46 -1
- package/dist/dialects/pg/ops/arr-append.d.ts +9 -0
- package/dist/dialects/pg/ops/arr-ns.d.ts +7 -0
- package/dist/dialects/pg/ops/arr-remove.d.ts +9 -0
- package/dist/dialects/pg/ops/containedBy.d.ts +9 -0
- package/dist/dialects/pg/ops/contains.d.ts +8 -4
- package/dist/dialects/pg/ops/hasAnyKey.d.ts +8 -0
- package/dist/dialects/pg/ops/hasKey.d.ts +8 -0
- package/dist/dialects/pg/ops/json-ns.d.ts +6 -0
- package/dist/dialects/pg/ops/json-set.d.ts +12 -0
- package/dist/dialects/pg/ops/matches.d.ts +16 -0
- package/dist/dialects/pg/ops/overlaps.d.ts +9 -0
- package/dist/dialects/pg/ops/path.d.ts +13 -0
- package/dist/dialects/pg/preset.d.ts +76 -0
- package/dist/dialects/pg/relations.d.ts +59 -2
- package/dist/dialects/pg/role/check.d.ts +45 -0
- package/dist/dialects/pg/role/index.d.ts +50 -0
- package/dist/dialects/pg/role/sql.d.ts +44 -0
- package/dist/dialects/pg/schema.d.ts +109 -5
- package/dist/dialects/pg/table.d.ts +137 -11
- package/dist/dialects/pg/temporal.d.ts +9 -7
- package/dist/dialects/pg/tenancy.d.ts +103 -0
- package/dist/dialects/pg/through.d.ts +21 -0
- package/dist/dialects/pg/trait.d.ts +141 -0
- package/dist/dialects/pg/view/client.d.ts +30 -0
- package/dist/dialects/pg/view/depend.d.ts +35 -0
- package/dist/dialects/pg/view/index.d.ts +114 -0
- package/dist/dialects/pg/view/index.js +289 -0
- package/dist/dialects/pg/view/scratch.d.ts +21 -0
- package/dist/dialects/pg/where.d.ts +37 -0
- package/dist/runtime/aggregate.d.ts +25 -0
- package/dist/runtime/archive-handle.d.ts +18 -0
- package/dist/runtime/archive-rules.d.ts +12 -0
- package/dist/runtime/archive.d.ts +73 -0
- package/dist/runtime/batch.d.ts +20 -0
- package/dist/runtime/client.d.ts +114 -5
- package/dist/runtime/conflict.d.ts +2 -1
- package/dist/runtime/exposure.d.ts +27 -0
- package/dist/runtime/hookm.d.ts +39 -0
- package/dist/runtime/ids/index.d.ts +11 -0
- package/dist/runtime/ids/index.js +193 -0
- package/dist/runtime/ids/okid-extended.d.ts +19 -0
- package/dist/runtime/ids/okid-generator.d.ts +21 -0
- package/dist/runtime/ids/okid-shared.d.ts +89 -0
- package/dist/runtime/ids/okid.d.ts +24 -0
- package/dist/runtime/ids/uuid.d.ts +21 -0
- package/dist/runtime/lock.d.ts +22 -0
- package/dist/runtime/operator-sql.d.ts +8 -0
- package/dist/runtime/page.d.ts +25 -0
- package/dist/runtime/pg/bun.d.ts +30 -0
- package/dist/runtime/pg/bun.js +52 -0
- package/dist/runtime/pg/pg.d.ts +29 -0
- package/dist/runtime/pg/pg.js +52 -0
- package/dist/runtime/pg/pglite.js +16 -17
- package/dist/runtime/pg/postgresjs.js +14 -24
- package/dist/runtime/plan.d.ts +146 -7
- package/dist/runtime/preset-stack.d.ts +17 -0
- package/dist/runtime/presets.d.ts +48 -0
- package/dist/runtime/read-stream.d.ts +26 -0
- package/dist/runtime/safety/index.d.ts +159 -0
- package/dist/runtime/safety/index.js +294 -0
- package/dist/runtime/safety-hook.d.ts +42 -0
- package/dist/runtime/server-check.d.ts +34 -0
- package/dist/runtime/tenancy/index.d.ts +37 -0
- package/dist/runtime/tenancy/index.js +368 -0
- package/dist/runtime/trait-read.d.ts +30 -0
- package/dist/runtime/traits/index.d.ts +133 -0
- package/dist/runtime/traits/index.js +646 -0
- package/dist/runtime/transaction.d.ts +19 -0
- package/dist/runtime/tx.d.ts +22 -7
- package/dist/runtime/types.d.ts +376 -27
- package/dist/runtime/validate/bind.d.ts +11 -0
- package/dist/runtime/validate/closed.d.ts +16 -0
- package/dist/runtime/validate/engine.d.ts +41 -0
- package/dist/runtime/validate/hook.d.ts +17 -0
- package/dist/runtime/validate/index.d.ts +21 -0
- package/dist/runtime/validate/index.js +175 -0
- package/dist/runtime/validate/load.d.ts +13 -0
- package/dist/runtime/validate/places.d.ts +41 -0
- package/dist/runtime/validate/rules.d.ts +108 -0
- package/dist/runtime/validate/surface.d.ts +102 -0
- package/dist/runtime/write.d.ts +30 -5
- package/dist/shared/01yr20s5.js +149 -0
- package/dist/shared/0jc3ffzf.js +154 -0
- package/dist/shared/0v1g424p.js +26 -0
- package/dist/shared/1g0drakv.js +225 -0
- package/dist/shared/{kprcwaha.js → 1tfdfvhh.js} +5 -3
- package/dist/shared/{05w44d8g.js → 2ssqrv66.js} +767 -715
- package/dist/shared/3ekj9x92.js +210 -0
- package/dist/shared/49ypnfwt.js +1122 -0
- package/dist/shared/4e4c6vq2.js +62 -0
- package/dist/shared/4m9fn52z.js +70 -0
- package/dist/shared/{ycwz42az.js → 52szzakm.js} +6 -26
- package/dist/shared/5nmdenb6.js +1229 -0
- package/dist/shared/672t5vym.js +12 -0
- package/dist/shared/6bazvqwm.js +86 -0
- package/dist/shared/6w5j844a.js +201 -0
- package/dist/shared/{fgqgsb5z.js → 75xkjv0t.js} +2 -2
- package/dist/shared/7fvtrkwr.js +84 -0
- package/dist/shared/7m88x3e9.js +45 -0
- package/dist/shared/{mtkwv8wx.js → 7p2wbz7f.js} +1 -1
- package/dist/shared/83eaefwr.js +10 -0
- package/dist/shared/94ez8kzh.js +19 -0
- package/dist/shared/96ps4g1z.js +32 -0
- package/dist/shared/{xqbhg6cn.js → 999ade2q.js} +95 -10
- package/dist/shared/9m80mkac.js +158 -0
- package/dist/shared/9x25fxhc.js +150 -0
- package/dist/shared/a5sxz52y.js +13 -0
- package/dist/shared/axhk06q1.js +156 -0
- package/dist/shared/{dynq16vb.js → b066g80h.js} +8 -6
- package/dist/shared/bqha5cg6.js +229 -0
- package/dist/shared/bryqk9k9.js +31 -0
- package/dist/shared/c8aghh05.js +442 -0
- package/dist/shared/c9z5g0fm.js +309 -0
- package/dist/shared/{m3ypagh5.js → dbjej1tw.js} +124 -15
- package/dist/shared/dyj86cmj.js +69 -0
- package/dist/shared/e6wg00wd.js +164 -0
- package/dist/shared/{hadrfb9h.js → edwqqryd.js} +17 -14
- package/dist/shared/{qk3hxfja.js → fptpmvxp.js} +5 -5
- package/dist/shared/fs0ex00p.js +76 -0
- package/dist/shared/{jjb7yht9.js → g4f5kcx9.js} +3 -3
- package/dist/shared/gjthds9j.js +48 -0
- package/dist/shared/hcmdtwgh.js +102 -0
- package/dist/shared/{g5fhqmwe.js → jkc6ws1p.js} +6 -56
- package/dist/shared/{yd1kzwn2.js → jns2wx4t.js} +55 -12
- package/dist/shared/k34e0xf2.js +450 -0
- package/dist/shared/k3ted12y.js +33 -0
- package/dist/shared/k7dwkhvq.js +31 -0
- package/dist/shared/{8b04d28c.js → kgnc8grt.js} +2 -2
- package/dist/shared/{hd293j9g.js → kyxb62mc.js} +14 -2
- package/dist/shared/m78s7898.js +376 -0
- package/dist/shared/m9tv7xn7.js +404 -0
- package/dist/shared/meck53jv.js +99 -0
- package/dist/shared/mt5wswjz.js +90 -0
- package/dist/shared/n0dgs0pb.js +75 -0
- package/dist/shared/n442h54c.js +14 -0
- package/dist/shared/n4jqhpqz.js +27 -0
- package/dist/shared/n7mcc1gk.js +132 -0
- package/dist/shared/ne02ng5c.js +68 -0
- package/dist/shared/{mkjmqjv4.js → nfzc5z0w.js} +2 -104
- package/dist/shared/nsva2a6b.js +42 -0
- package/dist/shared/p24x2334.js +195 -0
- package/dist/shared/qbxzvwwc.js +88 -0
- package/dist/shared/{w8samvk1.js → qybh48nd.js} +1 -1
- package/dist/shared/r6nwkxnt.js +86 -0
- package/dist/shared/{xy79j5hq.js → rrstp3kb.js} +25 -36
- package/dist/shared/rwmrejjz.js +26 -0
- package/dist/shared/{zhc5vmgf.js → s6gqfn5j.js} +2 -2
- package/dist/shared/{523ft3e8.js → scwxrpx2.js} +7 -5
- package/dist/shared/{j5cn2963.js → t4tbsy9h.js} +13 -64
- package/dist/shared/{y9m15dfv.js → t616ynfn.js} +544 -32
- package/dist/shared/{ngk8gj61.js → tbszx8mz.js} +15 -1
- package/dist/shared/th14ygv2.js +69 -0
- package/dist/shared/tmbdywx0.js +178 -0
- package/dist/shared/ty3v3hfk.js +64 -0
- package/dist/shared/wekze34d.js +246 -0
- package/dist/shared/x6wysh83.js +1132 -0
- package/dist/shared/{rgs0st28.js → xrfnq5k8.js} +237 -434
- package/dist/shared/{x5x59srr.js → xva8v7qk.js} +416 -83
- package/dist/shared/{dkn3y60a.js → xw1d69vd.js} +76 -112
- package/dist/shared/y005b761.js +112 -0
- package/dist/shared/ydaz1sv3.js +55 -0
- package/dist/shared/{p0cbr3g2.js → zwmqxb0g.js} +1 -1
- package/dist/tooling/cli.js +40 -12
- package/dist/tooling/migrate/apply.d.ts +16 -0
- package/dist/tooling/migrate/commands.d.ts +12 -1
- package/dist/tooling/migrate/config.d.ts +8 -0
- package/dist/tooling/migrate/doctor.d.ts +25 -0
- package/dist/tooling/migrate/drift.d.ts +19 -0
- package/dist/tooling/migrate/engine.d.ts +36 -0
- package/dist/tooling/migrate/ext.d.ts +17 -0
- package/dist/tooling/migrate/extensions.d.ts +51 -0
- package/dist/tooling/migrate/managed.d.ts +17 -0
- package/dist/tooling/migrate/plan.d.ts +14 -1
- package/dist/tooling/migrate/project.d.ts +25 -1
- package/dist/tooling/migrate/type-name.d.ts +19 -0
- package/package.json +61 -4
- package/dist/shared/gk7cs7sp.js +0 -566
|
@@ -14,7 +14,7 @@ export type Owner = (typeof OWNERS)[number];
|
|
|
14
14
|
* Object kinds from spec section 5.7.
|
|
15
15
|
*
|
|
16
16
|
* Built in this layer: table, column, index, constraint, sequence, and type.
|
|
17
|
-
* A type object is an enum
|
|
17
|
+
* A type object is an enum (ordered labels) or a domain (base type and check).
|
|
18
18
|
*/
|
|
19
19
|
export declare const OBJECT_KINDS: readonly ["table", "column", "index", "constraint", "sequence", "view", "materializedView", "type", "function", "trigger", "policy", "extension", "role", "grant", "defaultPrivilege"];
|
|
20
20
|
/** A catalog object kind. */
|
|
@@ -100,9 +100,15 @@ export type GrantIdentity = {
|
|
|
100
100
|
readonly object: GrantObjectRef;
|
|
101
101
|
readonly privilege: string;
|
|
102
102
|
};
|
|
103
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* What a grant attaches to.
|
|
105
|
+
*
|
|
106
|
+
* `namespace` is the schema itself. A function's `name` is `name(argTypes)`
|
|
107
|
+
* so overloads stay distinct without a second field. The key is not a stored
|
|
108
|
+
* identifier (D119).
|
|
109
|
+
*/
|
|
104
110
|
export type GrantObjectRef = {
|
|
105
|
-
readonly kind: "table" | "sequence" | "namespace";
|
|
111
|
+
readonly kind: "table" | "view" | "materializedView" | "sequence" | "function" | "namespace";
|
|
106
112
|
readonly namespace: Namespace;
|
|
107
113
|
readonly name: string;
|
|
108
114
|
};
|
|
@@ -130,18 +136,31 @@ export type ExtensionIdentity = {
|
|
|
130
136
|
readonly kind: "extension";
|
|
131
137
|
readonly name: string;
|
|
132
138
|
};
|
|
139
|
+
/**
|
|
140
|
+
* Canonical extension record.
|
|
141
|
+
*
|
|
142
|
+
* `version` is an exact pin (`1.6`) or a floor (`>=0.7`). Absent means
|
|
143
|
+
* unpinned: the installed version is information and drift ignores it.
|
|
144
|
+
*/
|
|
145
|
+
export type ExtensionDefinition = {
|
|
146
|
+
/** Schema the extension is installed in. */
|
|
147
|
+
readonly schema: string;
|
|
148
|
+
/** Whether `ALTER EXTENSION … SET SCHEMA` is allowed. */
|
|
149
|
+
readonly relocatable: boolean;
|
|
150
|
+
readonly version?: string;
|
|
151
|
+
};
|
|
133
152
|
/** Stable identity. The variant depends on the kind. */
|
|
134
153
|
export type ObjectIdentity = NamespaceIdentity | AnchoredIdentity | FunctionIdentity | GrantIdentity | DefaultPrivilegeIdentity | RoleIdentity | ExtensionIdentity;
|
|
135
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Where an object, a query, or a rule came from.
|
|
156
|
+
*
|
|
157
|
+
* `source` is the authoring location (`schema.ts:12`). It is recorded when
|
|
158
|
+
* the object is defined and is not part of the catalog hash.
|
|
159
|
+
*/
|
|
136
160
|
export type Provenance = {
|
|
137
|
-
readonly origin: "file";
|
|
138
|
-
readonly name: string;
|
|
139
|
-
} | {
|
|
140
|
-
readonly origin: "trait";
|
|
141
|
-
readonly name: string;
|
|
142
|
-
} | {
|
|
143
|
-
readonly origin: "extension";
|
|
161
|
+
readonly origin: "file" | "trait" | "extension";
|
|
144
162
|
readonly name: string;
|
|
163
|
+
readonly source?: string;
|
|
145
164
|
};
|
|
146
165
|
/**
|
|
147
166
|
* An edge to another object.
|
|
@@ -179,6 +198,13 @@ export type ColumnDefinition = {
|
|
|
179
198
|
readonly stored: boolean;
|
|
180
199
|
readonly expression: string;
|
|
181
200
|
};
|
|
201
|
+
/**
|
|
202
|
+
* Collation name, such as `C`.
|
|
203
|
+
*
|
|
204
|
+
* Absent when the column uses the type's default collation. A client
|
|
205
|
+
* generator is not stored here.
|
|
206
|
+
*/
|
|
207
|
+
readonly collation?: string;
|
|
182
208
|
};
|
|
183
209
|
/**
|
|
184
210
|
* Index definition.
|
|
@@ -230,11 +256,22 @@ export type ConstraintDefinition = {
|
|
|
230
256
|
* Enum definition.
|
|
231
257
|
*
|
|
232
258
|
* `labels` is the stored order. That order is part of the catalog hash.
|
|
233
|
-
* Domains are not represented here.
|
|
234
259
|
*/
|
|
235
|
-
export type
|
|
260
|
+
export type EnumDefinition = {
|
|
236
261
|
readonly labels: readonly string[];
|
|
237
262
|
};
|
|
263
|
+
/**
|
|
264
|
+
* Domain definition.
|
|
265
|
+
*
|
|
266
|
+
* `base` is the Postgres type the domain is created over. `check` is the
|
|
267
|
+
* domain check, stored as written. A later base type is refused (OKM1020).
|
|
268
|
+
*/
|
|
269
|
+
export type DomainDefinition = {
|
|
270
|
+
readonly base: string;
|
|
271
|
+
readonly check: string;
|
|
272
|
+
};
|
|
273
|
+
/** A catalog type: an enum or a domain. */
|
|
274
|
+
export type TypeDefinition = EnumDefinition | DomainDefinition;
|
|
238
275
|
/** Sequence definition. Start and increment are decimal integers. */
|
|
239
276
|
export type SequenceDefinition = {
|
|
240
277
|
readonly dataType: "smallint" | "integer" | "bigint";
|
|
@@ -276,13 +313,137 @@ export type TypeObject = CatalogEnvelope<"type", NamespaceIdentity & {
|
|
|
276
313
|
readonly kind: "type";
|
|
277
314
|
}, TypeDefinition>;
|
|
278
315
|
/**
|
|
279
|
-
*
|
|
316
|
+
* An extension.
|
|
317
|
+
*
|
|
318
|
+
* The record is identity, schema, relocatable, and version. Core stores it
|
|
319
|
+
* and does not interpret it. The extension object produces it.
|
|
320
|
+
*/
|
|
321
|
+
export type ExtensionObject = CatalogEnvelope<"extension", ExtensionIdentity, ExtensionDefinition>;
|
|
322
|
+
/** One function language. */
|
|
323
|
+
export type FunctionLanguage = "sql" | "plpgsql";
|
|
324
|
+
/** One volatility. */
|
|
325
|
+
export type FunctionVolatility = "volatile" | "stable" | "immutable";
|
|
326
|
+
/** `SECURITY INVOKER` or `SECURITY DEFINER`. */
|
|
327
|
+
export type FunctionSecurity = "invoker" | "definer";
|
|
328
|
+
/** One argument. The name is not part of the identity. */
|
|
329
|
+
export type FunctionArgument = {
|
|
330
|
+
readonly name: string;
|
|
331
|
+
readonly type: string;
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Function definition.
|
|
280
335
|
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
336
|
+
* The body of a plpgsql or plain SQL function is the source Postgres stores
|
|
337
|
+
* (`prosrc`). A `LANGUAGE sql` body that starts with `BEGIN ATOMIC` is marked
|
|
338
|
+
* `atomic`: Postgres reprints that body and leaves `prosrc` empty.
|
|
339
|
+
*/
|
|
340
|
+
export type FunctionDefinition = {
|
|
341
|
+
readonly arguments: readonly FunctionArgument[];
|
|
342
|
+
readonly returns: string;
|
|
343
|
+
readonly language: FunctionLanguage;
|
|
344
|
+
readonly volatility: FunctionVolatility;
|
|
345
|
+
readonly security: FunctionSecurity;
|
|
346
|
+
readonly body: string;
|
|
347
|
+
readonly searchPath?: string;
|
|
348
|
+
readonly atomic?: true;
|
|
349
|
+
};
|
|
350
|
+
/** One trigger timing. */
|
|
351
|
+
export type TriggerTiming = "before" | "after" | "instead";
|
|
352
|
+
/** One trigger event. Stored order is insert, update, delete, truncate. */
|
|
353
|
+
export type TriggerEvent = "insert" | "update" | "delete" | "truncate";
|
|
354
|
+
/** One trigger level. */
|
|
355
|
+
export type TriggerLevel = "row" | "statement";
|
|
356
|
+
/** The function a trigger calls. Argument types keep an overload distinct. */
|
|
357
|
+
export type TriggerCall = {
|
|
358
|
+
readonly namespace: Namespace;
|
|
359
|
+
readonly name: string;
|
|
360
|
+
readonly argTypes: readonly string[];
|
|
361
|
+
};
|
|
362
|
+
/**
|
|
363
|
+
* Trigger definition.
|
|
364
|
+
*
|
|
365
|
+
* `updateOf` lists SQL column names for `UPDATE OF`. `when` is the predicate
|
|
366
|
+
* text. The table and the function are dependency edges.
|
|
367
|
+
*/
|
|
368
|
+
export type TriggerDefinition = {
|
|
369
|
+
readonly timing: TriggerTiming;
|
|
370
|
+
readonly events: readonly TriggerEvent[];
|
|
371
|
+
readonly level: TriggerLevel;
|
|
372
|
+
readonly calls: TriggerCall;
|
|
373
|
+
readonly updateOf?: readonly string[];
|
|
374
|
+
readonly when?: string;
|
|
375
|
+
};
|
|
376
|
+
/** A function. Identity is `(schema, name, argTypes[])`. */
|
|
377
|
+
export type FunctionObject = CatalogEnvelope<"function", FunctionIdentity, FunctionDefinition>;
|
|
378
|
+
/** A trigger. Identity is `(table, name)`. */
|
|
379
|
+
export type TriggerObject = CatalogEnvelope<"trigger", AnchoredIdentity & {
|
|
380
|
+
readonly kind: "trigger";
|
|
381
|
+
}, TriggerDefinition>;
|
|
382
|
+
/** One output column of a view or materialized view. */
|
|
383
|
+
export type ViewColumn = {
|
|
384
|
+
readonly name: string;
|
|
385
|
+
readonly dataType: string;
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* View definition.
|
|
389
|
+
*
|
|
390
|
+
* `query` is the server reprint when one has been read (`pg_get_viewdef`),
|
|
391
|
+
* and the author's SQL until then. Column dependencies are separate edges.
|
|
392
|
+
*/
|
|
393
|
+
export type ViewDefinition = {
|
|
394
|
+
readonly columns: readonly ViewColumn[];
|
|
395
|
+
readonly query: string;
|
|
396
|
+
};
|
|
397
|
+
/**
|
|
398
|
+
* Materialized view definition.
|
|
399
|
+
*
|
|
400
|
+
* There is no replace. `refresh` is the populate mode. Postgres does not
|
|
401
|
+
* store it; introspection leaves it unset.
|
|
402
|
+
*/
|
|
403
|
+
export type MaterializedViewDefinition = {
|
|
404
|
+
readonly columns: readonly ViewColumn[];
|
|
405
|
+
readonly query: string;
|
|
406
|
+
readonly refresh?: "concurrently";
|
|
407
|
+
};
|
|
408
|
+
/** A view. Identity is `(namespace, name)`. */
|
|
409
|
+
export type ViewObject = CatalogEnvelope<"view", NamespaceIdentity & {
|
|
410
|
+
readonly kind: "view";
|
|
411
|
+
}, ViewDefinition>;
|
|
412
|
+
/** A materialized view. Identity is `(namespace, name)`. */
|
|
413
|
+
export type MaterializedViewObject = CatalogEnvelope<"materializedView", NamespaceIdentity & {
|
|
414
|
+
readonly kind: "materializedView";
|
|
415
|
+
}, MaterializedViewDefinition>;
|
|
416
|
+
/**
|
|
417
|
+
* Role definition.
|
|
418
|
+
*
|
|
419
|
+
* Only `login` and `inherit` are altered in place. A password is not stored.
|
|
420
|
+
*/
|
|
421
|
+
export type RoleDefinition = {
|
|
422
|
+
readonly login: boolean;
|
|
423
|
+
readonly inherit: boolean;
|
|
424
|
+
};
|
|
425
|
+
/**
|
|
426
|
+
* Grant definition.
|
|
427
|
+
*
|
|
428
|
+
* The privilege is the identity. `GRANT OPTION` is not in this version.
|
|
429
|
+
*/
|
|
430
|
+
export type GrantDefinition = Record<string, never>;
|
|
431
|
+
/**
|
|
432
|
+
* Default-privilege definition.
|
|
433
|
+
*
|
|
434
|
+
* The key is the identity. The statement is `ALTER DEFAULT PRIVILEGES`.
|
|
435
|
+
*/
|
|
436
|
+
export type DefaultPrivilegeDefinition = Record<string, never>;
|
|
437
|
+
/** A role. Identity is the name. Roles are never dropped (D119). */
|
|
438
|
+
export type RoleObject = CatalogEnvelope<"role", RoleIdentity, RoleDefinition>;
|
|
439
|
+
/** A grant. Identity is `(role, object, privilege)`. */
|
|
440
|
+
export type GrantObject = CatalogEnvelope<"grant", GrantIdentity, GrantDefinition>;
|
|
441
|
+
/** A default privilege. Identity is `(forRole, namespace, objectKind, grantee, privilege)`. */
|
|
442
|
+
export type DefaultPrivilegeObject = CatalogEnvelope<"defaultPrivilege", DefaultPrivilegeIdentity, DefaultPrivilegeDefinition>;
|
|
443
|
+
/**
|
|
444
|
+
* One built catalog object.
|
|
284
445
|
*/
|
|
285
|
-
export type CatalogObject = TableObject | ColumnObject | IndexObject | ConstraintObject | SequenceObject | TypeObject;
|
|
446
|
+
export type CatalogObject = TableObject | ColumnObject | IndexObject | ConstraintObject | SequenceObject | TypeObject | ExtensionObject | FunctionObject | TriggerObject | ViewObject | MaterializedViewObject | RoleObject | GrantObject | DefaultPrivilegeObject;
|
|
286
447
|
/** Format version stored in the serialized catalog. */
|
|
287
448
|
export declare const CATALOG_VERSION = 1;
|
|
288
449
|
/** A catalog document. Object order is identity-key order. */
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* View and materialized view catalog objects.
|
|
3
|
+
*
|
|
4
|
+
* The factories store the record. They do not plan SQL. DDL stays in the
|
|
5
|
+
* dialect, and `view()` / `materializedView()` stay on `okmodel/view`.
|
|
6
|
+
*/
|
|
7
|
+
import type { IndexObject, MaterializedViewObject, Namespace, ObjectIdentity, ObjectRef, Owner, Provenance, ViewColumn, ViewObject } from "./types.js";
|
|
8
|
+
/** Input for {@link viewObject}. */
|
|
9
|
+
export type ViewInput = {
|
|
10
|
+
readonly namespace?: Namespace;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly columns: readonly ViewColumn[];
|
|
13
|
+
readonly query: string;
|
|
14
|
+
readonly owner?: Owner;
|
|
15
|
+
readonly provenance: Provenance;
|
|
16
|
+
readonly dependencies?: readonly ObjectIdentity[];
|
|
17
|
+
};
|
|
18
|
+
/** Input for {@link materializedViewObject}. */
|
|
19
|
+
export type MaterializedViewInput = ViewInput & {
|
|
20
|
+
readonly refresh?: "concurrently";
|
|
21
|
+
};
|
|
22
|
+
/** Input for {@link materializedViewIndex}. */
|
|
23
|
+
export type MaterializedViewIndexInput = {
|
|
24
|
+
readonly parent: ObjectRef;
|
|
25
|
+
readonly name?: string;
|
|
26
|
+
readonly columns: readonly string[];
|
|
27
|
+
readonly unique?: boolean;
|
|
28
|
+
readonly nameKey?: string;
|
|
29
|
+
readonly expression?: string;
|
|
30
|
+
readonly predicate?: string;
|
|
31
|
+
readonly owner?: Owner;
|
|
32
|
+
readonly provenance: Provenance;
|
|
33
|
+
/** Retargeted edges. Omitted edges depend on the materialized view. */
|
|
34
|
+
readonly dependencies?: readonly ObjectIdentity[];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Trims a view query and drops one trailing semicolon.
|
|
38
|
+
*
|
|
39
|
+
* `pg_get_viewdef` and the author's SQL both go through this before they are
|
|
40
|
+
* stored, so two reads of the same reprint compare equal.
|
|
41
|
+
*
|
|
42
|
+
* @param query - Author SQL or a server reprint
|
|
43
|
+
* @returns The stored query text
|
|
44
|
+
*/
|
|
45
|
+
export declare function normaliseViewQuery(query: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Builds a view record.
|
|
48
|
+
*
|
|
49
|
+
* Identity is `(namespace, name)`. Columns stay in declaration order.
|
|
50
|
+
*
|
|
51
|
+
* @param input - Columns, query, and dependency edges
|
|
52
|
+
* @returns The catalog object
|
|
53
|
+
*/
|
|
54
|
+
export declare function viewObject(input: ViewInput): ViewObject;
|
|
55
|
+
/**
|
|
56
|
+
* Builds a materialized view record.
|
|
57
|
+
*
|
|
58
|
+
* `refresh` is stored only for `"concurrently"`. The object has no replace.
|
|
59
|
+
*
|
|
60
|
+
* @param input - Columns, query, populate mode, and dependency edges
|
|
61
|
+
* @returns The catalog object
|
|
62
|
+
*/
|
|
63
|
+
export declare function materializedViewObject(input: MaterializedViewInput): MaterializedViewObject;
|
|
64
|
+
/**
|
|
65
|
+
* Builds an index owned by a materialized view.
|
|
66
|
+
*
|
|
67
|
+
* The edge points at the view, not at a table. View output columns are not
|
|
68
|
+
* catalog objects, so the index does not depend on column identities.
|
|
69
|
+
*
|
|
70
|
+
* @param input - Parent view, columns, and uniqueness
|
|
71
|
+
* @returns An index envelope
|
|
72
|
+
*/
|
|
73
|
+
export declare function materializedViewIndex(input: MaterializedViewIndexInput): IndexObject;
|
|
@@ -31,3 +31,16 @@ export declare function isConnectionErrno(code: string): boolean;
|
|
|
31
31
|
* @returns `true` when no session remains
|
|
32
32
|
*/
|
|
33
33
|
export declare function isConnectionFailure(error: unknown): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Reports whether the connection is gone after `error`, or the outcome of a
|
|
36
|
+
* statement on it is unknown (`outcome_unknown`).
|
|
37
|
+
*
|
|
38
|
+
* It reads what {@link isConnectionFailure} reads, plus the messages node-postgres
|
|
39
|
+
* ("Connection terminated unexpectedly") and Bun.sql (`ERR_POSTGRES_CONNECTION_CLOSED`)
|
|
40
|
+
* give, and the error's `cause`. Nothing more should be sent to such a connection:
|
|
41
|
+
* not a rollback, not a reset. Loaded with the code that reserves a connection.
|
|
42
|
+
*
|
|
43
|
+
* @param error - Caught value
|
|
44
|
+
* @returns `true` when the session cannot be used again
|
|
45
|
+
*/
|
|
46
|
+
export declare function isConnectionLost(error: unknown): boolean;
|
|
@@ -154,10 +154,23 @@ export type DriverPoolConfig = {
|
|
|
154
154
|
/** Connections in the pool. PGlite is always one. */
|
|
155
155
|
readonly max?: number;
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
158
|
-
* OKM1846. Omitted means wait
|
|
157
|
+
* Ceilings in milliseconds. An adapter reads `acquire`: it waits for a
|
|
158
|
+
* connection up to that long, then fails with OKM1846. Omitted means wait
|
|
159
|
+
* without a deadline. The other keys belong to the runtime.
|
|
159
160
|
*/
|
|
160
|
-
readonly timeouts?:
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
readonly timeouts?: DriverTimeouts;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Ceilings from `connect({ timeouts })`, in milliseconds (spec §15).
|
|
165
|
+
*
|
|
166
|
+
* `acquire` bounds the wait for a connection (OKM1846). `statement` is the
|
|
167
|
+
* default `timeout` of a call that sets none. `transaction` bounds a whole
|
|
168
|
+
* `tx()`. `idleInTransaction` bounds the time a `tx()` waits between
|
|
169
|
+
* statements. Every one but `acquire` fails as kind `timeout`.
|
|
170
|
+
*/
|
|
171
|
+
export type DriverTimeouts = {
|
|
172
|
+
readonly acquire?: number;
|
|
173
|
+
readonly statement?: number;
|
|
174
|
+
readonly transaction?: number;
|
|
175
|
+
readonly idleInTransaction?: number;
|
|
163
176
|
};
|
|
@@ -31,7 +31,7 @@ export type ColumnCode = (typeof COLUMN_CODES)[number];
|
|
|
31
31
|
* These are spec §21 codes. They are a type only, so the runtime entry does
|
|
32
32
|
* not gain a second registry.
|
|
33
33
|
*/
|
|
34
|
-
export type QueryCode = "OKM1101" | "OKM1102" | "OKM1104" | "OKM1105" | "OKM1111" | "OKM1120" | "OKM1121" | "OKM1190" | "OKM1801" | "OKM1802" | "OKM1843";
|
|
34
|
+
export type QueryCode = "OKM1101" | "OKM1102" | "OKM1104" | "OKM1105" | "OKM1111" | "OKM1120" | "OKM1121" | "OKM1124" | "OKM1130" | "OKM1190" | "OKM1701" | "OKM1704" | "OKM1801" | "OKM1802" | "OKM1803" | "OKM1843";
|
|
35
35
|
/** Kinds from spec §14, in category order. */
|
|
36
36
|
export declare const ERROR_KINDS: readonly ["invalid", "not_null", "check", "foreign_key", "unique", "exclusion", "conflict", "not_found", "not_unique", "forbidden", "serialization", "deadlock", "lock_timeout", "timeout", "cancelled", "unavailable", "schema_drift", "driver", "read_only", "outcome_unknown"];
|
|
37
37
|
/** One spec §14 kind. */
|
|
@@ -51,6 +51,16 @@ export type ErrorFix = {
|
|
|
51
51
|
/** Accepted name to use instead, when one is close. */
|
|
52
52
|
readonly suggestion?: string;
|
|
53
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* One failed validation check.
|
|
56
|
+
*
|
|
57
|
+
* `message` is a key, never prose and never a row value. `path` walks the
|
|
58
|
+
* value: a field name, or a row index then a field name.
|
|
59
|
+
*/
|
|
60
|
+
export type ValidationIssue = {
|
|
61
|
+
readonly path: readonly (string | number)[];
|
|
62
|
+
readonly message: string;
|
|
63
|
+
};
|
|
54
64
|
/** Column name to constraint reason. Row values are not included. */
|
|
55
65
|
export type ErrorFields = Readonly<Record<string, string>>;
|
|
56
66
|
/** Body of {@link OkmError.toHttp}. */
|
|
@@ -80,6 +90,8 @@ export type ErrorLog = {
|
|
|
80
90
|
readonly batchIndex: number | null;
|
|
81
91
|
readonly fix: ErrorFix;
|
|
82
92
|
readonly fields: ErrorFields;
|
|
93
|
+
/** Validation checks, when the failure is OKM1200. */
|
|
94
|
+
readonly issues?: readonly ValidationIssue[];
|
|
83
95
|
readonly table?: string;
|
|
84
96
|
readonly columns?: readonly string[];
|
|
85
97
|
readonly constraint?: string;
|
|
@@ -105,6 +117,8 @@ export type OkmErrorOptions = {
|
|
|
105
117
|
*/
|
|
106
118
|
readonly includeValues?: boolean;
|
|
107
119
|
readonly values?: Readonly<Record<string, string>>;
|
|
120
|
+
/** Checks from a failed validation. Omitted on every other error. */
|
|
121
|
+
readonly issues?: readonly ValidationIssue[];
|
|
108
122
|
/**
|
|
109
123
|
* Category overrides from `connect({ errors })`.
|
|
110
124
|
*
|
|
@@ -164,6 +178,8 @@ export declare class OkmError extends Error {
|
|
|
164
178
|
readonly batchIndex: number | null;
|
|
165
179
|
/** Constraint reason used by {@link fields}. */
|
|
166
180
|
readonly fieldReason: string;
|
|
181
|
+
/** Validation checks. Absent when this error is not a failed check. */
|
|
182
|
+
readonly issues?: readonly ValidationIssue[];
|
|
167
183
|
/**
|
|
168
184
|
* Same text as `message`.
|
|
169
185
|
*
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client generators.
|
|
3
|
+
*
|
|
4
|
+
* A generator fills a column on insert. It is not a database default, so it
|
|
5
|
+
* stays off the catalog and its hash. Built-ins are marked by name so
|
|
6
|
+
* `connect({ generators })` can replace them.
|
|
7
|
+
*/
|
|
8
|
+
/** Property that marks a function as a client generator. */
|
|
9
|
+
export declare const CLIENT_DEFAULT: unique symbol;
|
|
10
|
+
/** Built-in generator names, plus a caller-supplied function. */
|
|
11
|
+
export type GeneratorName = "uuidv4" | "uuidv7" | "okid" | "function";
|
|
12
|
+
/** Scalar options stored with a named generator. OKID uses these. */
|
|
13
|
+
export type GeneratorOptions = Readonly<Record<string, string | number | boolean>>;
|
|
14
|
+
/**
|
|
15
|
+
* What insert calls when a column was omitted.
|
|
16
|
+
*
|
|
17
|
+
* `label` is the catalog-output word for a client default. The catalog
|
|
18
|
+
* document itself does not store it.
|
|
19
|
+
*/
|
|
20
|
+
export type ClientFill = {
|
|
21
|
+
readonly label: "client";
|
|
22
|
+
readonly name: GeneratorName;
|
|
23
|
+
readonly options?: GeneratorOptions;
|
|
24
|
+
readonly call: () => unknown;
|
|
25
|
+
};
|
|
26
|
+
/** A function `.default()` and `schema({ defaults: { id } })` accept. */
|
|
27
|
+
export type ClientGenerator<T = string> = (() => T) & {
|
|
28
|
+
readonly [CLIENT_DEFAULT]: {
|
|
29
|
+
readonly label: "client";
|
|
30
|
+
readonly name: Exclude<GeneratorName, "function">;
|
|
31
|
+
readonly options?: GeneratorOptions;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Replacements for the built-in generators, keyed by name.
|
|
36
|
+
*
|
|
37
|
+
* A test passes fixed functions here. A custom function with no name is left
|
|
38
|
+
* alone.
|
|
39
|
+
*/
|
|
40
|
+
export type IdGenerators = {
|
|
41
|
+
readonly uuidv4?: () => string;
|
|
42
|
+
readonly uuidv7?: () => string;
|
|
43
|
+
readonly okid?: () => string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Marks `call` as a named client generator.
|
|
47
|
+
*
|
|
48
|
+
* @typeParam T - Value the generator returns
|
|
49
|
+
* @param call - Function that produces one value
|
|
50
|
+
* @param name - Built-in name `connect({ generators })` can replace
|
|
51
|
+
* @param options - Scalar options stored beside the name
|
|
52
|
+
* @returns The same function, marked
|
|
53
|
+
*/
|
|
54
|
+
export declare function clientGenerator<T>(call: () => T, name: Exclude<GeneratorName, "function">, options?: GeneratorOptions): ClientGenerator<T>;
|
|
55
|
+
/**
|
|
56
|
+
* Reads a client generator from a `.default()` argument.
|
|
57
|
+
*
|
|
58
|
+
* A marked built-in keeps its name. Any other function is a custom generator.
|
|
59
|
+
*
|
|
60
|
+
* @param value - Argument passed to `.default()` or `defaults.id`
|
|
61
|
+
* @returns The fill insert should call, or `undefined` when `value` is a literal
|
|
62
|
+
*/
|
|
63
|
+
export declare function readClientGenerator(value: unknown): ClientFill | undefined;
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* live on `okmodel/internal`, so `table` and `index` on this entry are not a
|
|
7
7
|
* second schema API.
|
|
8
8
|
*/
|
|
9
|
-
export { CATALOG_CODES, COLUMN_CODES, ERROR_CATEGORIES, ERROR_KINDS, OkmError, safe, type CatalogCode, type ColumnCode, type QueryCode, type ErrorCategory, type ErrorColumns, type ErrorFields, type ErrorFix, type ErrorKind, type ErrorLog, type ErrorStatuses, type HttpError, type HttpErrorBody, type OkmErrorOptions, type SafeResult, } from "./error.js";
|
|
10
|
-
export type { AnySchema, AnyTableShape, Insert, Register, Row, SchemaOf, TableName, Update, } from "./rows.js";
|
|
9
|
+
export { CATALOG_CODES, COLUMN_CODES, ERROR_CATEGORIES, ERROR_KINDS, OkmError, safe, type CatalogCode, type ColumnCode, type QueryCode, type ErrorCategory, type ErrorColumns, type ErrorFields, type ErrorFix, type ErrorKind, type ErrorLog, type ErrorStatuses, type HttpError, type HttpErrorBody, type OkmErrorOptions, type SafeResult, type ValidationIssue, } from "./error.js";
|
|
10
|
+
export type { AnySchema, AnyTableShape, Input, Insert, Register, Row, SchemaOf, TableName, Update, } from "./rows.js";
|
|
11
11
|
export type { DescribeResult, DriverCapabilities, DriverConnection, DriverErrorFields, DriverFailureKind, DriverPool, DriverPoolConfig, DriverStats, ExecuteOptions, ExecuteResult, Notice, PreparedMode, Statement, TransactionMode, WireValue, } from "./driver.js";
|
package/dist/contracts/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
OWNERS2,
|
|
3
|
-
OBJECT_KINDS2,
|
|
4
|
-
BUILT_KINDS2,
|
|
5
|
-
OBJECT_OPERATIONS2,
|
|
6
|
-
KIND_OPERATIONS2,
|
|
7
|
-
CATALOG_VERSION2,
|
|
8
2
|
staticNamespace2,
|
|
9
3
|
templateNamespace2,
|
|
10
4
|
assertNamespace2,
|
|
@@ -19,7 +13,15 @@ import {
|
|
|
19
13
|
index3,
|
|
20
14
|
constraint2,
|
|
21
15
|
sequence2
|
|
22
|
-
} from "../shared/
|
|
16
|
+
} from "../shared/t4tbsy9h.js";
|
|
17
|
+
import {
|
|
18
|
+
OWNERS2,
|
|
19
|
+
OBJECT_KINDS2,
|
|
20
|
+
BUILT_KINDS2,
|
|
21
|
+
OBJECT_OPERATIONS2,
|
|
22
|
+
KIND_OPERATIONS2,
|
|
23
|
+
CATALOG_VERSION2
|
|
24
|
+
} from "../shared/4e4c6vq2.js";
|
|
23
25
|
import {
|
|
24
26
|
utf8ByteLength2,
|
|
25
27
|
sha2562,
|
|
@@ -28,12 +30,12 @@ import {
|
|
|
28
30
|
assertIdentifier2,
|
|
29
31
|
fitIdentifier2,
|
|
30
32
|
deterministicName2
|
|
31
|
-
} from "../shared/
|
|
33
|
+
} from "../shared/nfzc5z0w.js";
|
|
32
34
|
import {
|
|
33
35
|
nearestName2,
|
|
34
36
|
catalogError2,
|
|
35
37
|
throwNamed2
|
|
36
|
-
} from "../shared/
|
|
38
|
+
} from "../shared/52szzakm.js";
|
|
37
39
|
export {
|
|
38
40
|
BUILT_KINDS2 as BUILT_KINDS,
|
|
39
41
|
CATALOG_VERSION2 as CATALOG_VERSION,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authoring location for provenance.
|
|
3
|
+
*
|
|
4
|
+
* `source` is recorded when a table or a rule is defined. The catalog hash
|
|
5
|
+
* does not include it.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* File and line of the caller `skip` frames above this function.
|
|
9
|
+
*
|
|
10
|
+
* Frames in this file are ignored. `skip` 1 is the direct caller, so a
|
|
11
|
+
* `table()` call records the schema line, not `table` itself.
|
|
12
|
+
*
|
|
13
|
+
* @param skip - Callers to pass before the frame that is recorded
|
|
14
|
+
* @returns `file.ts:line`, or `undefined` when the runtime has no stack
|
|
15
|
+
*/
|
|
16
|
+
export declare function callerLocation(skip: number): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Appends a source location to an error message.
|
|
19
|
+
*
|
|
20
|
+
* @param message - What failed
|
|
21
|
+
* @param source - `file.ts:line`, when one was recorded
|
|
22
|
+
* @returns The message `okm` prints
|
|
23
|
+
*/
|
|
24
|
+
export declare function withLocation(message: string, source: string | undefined): string;
|
package/dist/contracts/rows.d.ts
CHANGED
|
@@ -70,6 +70,21 @@ export type Insert<N extends TableName<S>, S extends AnySchema | undefined = und
|
|
|
70
70
|
* @typeParam S - Explicit schema. Omit it to use {@link Register}
|
|
71
71
|
*/
|
|
72
72
|
export type Update<N extends TableName<S>, S extends AnySchema | undefined = undefined> = ShapeOf<S, N, "~update">;
|
|
73
|
+
/**
|
|
74
|
+
* Insert shape used when validation is on.
|
|
75
|
+
*
|
|
76
|
+
* The fields match {@link Insert}. The optional mark makes the two types
|
|
77
|
+
* distinct, so a checked call can require this shape only while validation
|
|
78
|
+
* is enabled. Guarded fields and the tenant key are already absent.
|
|
79
|
+
*
|
|
80
|
+
* @typeParam N - Table name
|
|
81
|
+
* @typeParam S - Explicit schema. Omit it to use {@link Register}
|
|
82
|
+
*/
|
|
83
|
+
export type Input<N extends TableName<S>, S extends AnySchema | undefined = undefined> = Insert<N, S> & InputMark;
|
|
84
|
+
/** Optional mark that distinguishes {@link Input} from {@link Insert}. */
|
|
85
|
+
export type InputMark = {
|
|
86
|
+
readonly "~input"?: true;
|
|
87
|
+
};
|
|
73
88
|
/**
|
|
74
89
|
* One phantom on the table named `N`.
|
|
75
90
|
*
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cascade checks and partial uniques for `archivable()`.
|
|
3
|
+
*
|
|
4
|
+
* The trait calls this from the schema rewrite, after tenancy widens uniques.
|
|
5
|
+
* `schema()` does not import it.
|
|
6
|
+
*/
|
|
7
|
+
import { type AnyTable } from "./table.js";
|
|
8
|
+
/**
|
|
9
|
+
* Makes an archivable table's uniques partial and checks its cascade.
|
|
10
|
+
*
|
|
11
|
+
* Tenancy has already widened uniques. This pass turns those lists into
|
|
12
|
+
* unique indexes filtered on `archived_at is null`, and stores the cascade
|
|
13
|
+
* links the planner reads.
|
|
14
|
+
*
|
|
15
|
+
* @param self - The trait object on the table or the schema
|
|
16
|
+
* @param tables - Tables after the tenancy rewrite
|
|
17
|
+
* @param casing - Schema casing
|
|
18
|
+
* @param schemaTraits - Traits from `schema()`, when any were passed
|
|
19
|
+
* @param cascade - Child tables named on this trait
|
|
20
|
+
* @returns Tables with partial uniques and an archive model where this trait applies
|
|
21
|
+
*/
|
|
22
|
+
export declare function rewriteArchivable(self: object, tables: readonly AnyTable[], casing: "snake" | undefined, schemaTraits: readonly object[] | undefined, cascade: readonly string[]): readonly AnyTable[];
|