okmodel 0.5.1 → 0.6.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 +29 -14
- package/dist/adapters/pg/no-inflight-timeout.d.ts +17 -0
- package/dist/adapters/pg/postgres-extra.d.ts +22 -0
- package/dist/contracts/catalog/document.d.ts +19 -5
- package/dist/contracts/catalog/object.d.ts +2 -1
- package/dist/contracts/catalog/policy.d.ts +48 -0
- package/dist/contracts/catalog/types.d.ts +25 -1
- package/dist/contracts/catalog/view.d.ts +2 -0
- package/dist/contracts/internal.js +1 -1
- package/dist/contracts/location.d.ts +10 -0
- package/dist/dialects/pg/column.d.ts +13 -2
- package/dist/dialects/pg/ddl.d.ts +37 -1
- package/dist/dialects/pg/emit.d.ts +19 -1
- package/dist/dialects/pg/errors.d.ts +32 -1
- package/dist/dialects/pg/ext/citext.js +1 -1
- package/dist/dialects/pg/ext/index.js +1 -1
- package/dist/dialects/pg/ext/pg-trgm.js +1 -1
- package/dist/dialects/pg/filter-parse.d.ts +5 -4
- package/dist/dialects/pg/fn/index.js +2 -2
- package/dist/dialects/pg/index.d.ts +2 -1
- package/dist/dialects/pg/index.js +23 -17
- package/dist/dialects/pg/introspect.d.ts +7 -0
- package/dist/dialects/pg/model.d.ts +7 -2
- package/dist/dialects/pg/owner.d.ts +42 -0
- package/dist/dialects/pg/path-endpoint.d.ts +20 -0
- package/dist/dialects/pg/role/check.d.ts +3 -0
- package/dist/dialects/pg/role/index.d.ts +71 -6
- package/dist/dialects/pg/role/sql.d.ts +11 -0
- package/dist/dialects/pg/schema.d.ts +2 -0
- package/dist/dialects/pg/table.d.ts +25 -3
- package/dist/dialects/pg/tenancy.d.ts +45 -3
- package/dist/dialects/pg/view/client.d.ts +19 -1
- package/dist/dialects/pg/view/index.d.ts +4 -0
- package/dist/dialects/pg/view/index.js +21 -178
- package/dist/dialects/pg/view/refresh.d.ts +24 -0
- package/dist/runtime/batch.d.ts +1 -1
- package/dist/runtime/conflict.d.ts +2 -2
- package/dist/runtime/drift.d.ts +9 -0
- package/dist/runtime/inflight.d.ts +14 -0
- package/dist/runtime/pg/bun.js +4 -3
- package/dist/runtime/pg/pg.js +3 -3
- package/dist/runtime/pg/pglite.js +4 -3
- package/dist/runtime/pg/postgresjs.js +3 -3
- package/dist/runtime/plan.d.ts +18 -10
- package/dist/runtime/predicate.d.ts +19 -0
- package/dist/runtime/safety/index.js +1 -1
- package/dist/runtime/tenancy/composite.d.ts +26 -0
- package/dist/runtime/tenancy/context.d.ts +16 -0
- package/dist/runtime/tenancy/index.d.ts +9 -5
- package/dist/runtime/tenancy/index.js +1508 -37
- package/dist/runtime/tenancy/path.d.ts +87 -0
- package/dist/runtime/tenancy/rls.d.ts +67 -0
- package/dist/runtime/tenancy/via.d.ts +22 -0
- package/dist/runtime/traits/index.js +17 -11
- package/dist/runtime/types.d.ts +13 -1
- package/dist/runtime/validate/index.js +4 -4
- package/dist/runtime/write.d.ts +1 -1
- package/dist/shared/09p049xa.js +702 -0
- package/dist/shared/{6qd27mx0.js → 1f0xa3cb.js} +5 -5
- package/dist/shared/1nw1f3vs.js +23 -0
- package/dist/shared/{96qcj21c.js → 1z04fa85.js} +19 -9
- package/dist/shared/{qm7cdtvr.js → 2cg3wnxc.js} +296 -60
- package/dist/shared/{dyj86cmj.js → 2jd1sn0e.js} +2 -2
- package/dist/shared/{gbtcc2d7.js → 2z7wv5tj.js} +10 -35
- package/dist/shared/{k8v5v5wj.js → 32cnm7kn.js} +6 -1
- package/dist/shared/{t4tbsy9h.js → 358zsv4r.js} +1 -1
- package/dist/shared/{2pqx26h8.js → 3fqwmr09.js} +31 -22
- package/dist/shared/{zqrnhwsq.js → 3qnhc7w5.js} +16 -9
- package/dist/shared/{r2sp8hrc.js → 5d8t84hg.js} +12 -3
- package/dist/shared/{87jvvhnt.js → 5j36z8dn.js} +16 -5
- package/dist/shared/{1g0drakv.js → 5yv4k6a6.js} +1 -1
- package/dist/shared/8dqhth8c.js +12 -0
- package/dist/shared/8etn7d8w.js +62 -0
- package/dist/shared/{v36c5g6p.js → 8x72s86k.js} +400 -13
- package/dist/shared/{nxdp2ze3.js → 929h19xp.js} +107 -5
- package/dist/shared/{gjthds9j.js → 9628a9xt.js} +1 -1
- package/dist/shared/{8xsbagad.js → 9s0ypp87.js} +88 -7
- package/dist/shared/{efmy2gcg.js → ag4c7516.js} +1 -1
- package/dist/shared/b3awxn7h.js +45 -0
- package/dist/shared/b4v57v3x.js +9 -0
- package/dist/shared/bdk4sty6.js +58 -0
- package/dist/shared/{51mvgj8w.js → c58secgj.js} +100 -7
- package/dist/shared/d5azex6s.js +6 -0
- package/dist/shared/{5fqx9yh4.js → dk8v79p3.js} +3 -1
- package/dist/shared/{4m9fn52z.js → ed0b8k4s.js} +1 -1
- package/dist/shared/{z2rnngj4.js → ek2wt2dz.js} +8 -5
- package/dist/shared/{sycnx8gt.js → f0f1n281.js} +18 -8
- package/dist/shared/{f5cw5q5r.js → g90m9b0g.js} +2 -1
- package/dist/shared/{pf0d8f77.js → gwn6v667.js} +1 -1
- package/dist/shared/{8rsy3hxz.js → h15jx9bc.js} +1 -1
- package/dist/shared/{5enne4ma.js → hazqqecq.js} +17 -93
- package/dist/shared/{jwtxdj06.js → j3rkk835.js} +32 -9
- package/dist/shared/{hf22e0wt.js → j60w0dvr.js} +19 -18
- package/dist/shared/{ycatkxmq.js → jgqj11w4.js} +1 -1
- package/dist/shared/k68eedmy.js +85 -0
- package/dist/shared/{szm0cksa.js → knmes2kh.js} +34 -6
- package/dist/shared/{0t22wwh1.js → mb2ycs1p.js} +4 -2
- package/dist/shared/{cr74e96e.js → n076ydsc.js} +1 -1
- package/dist/shared/{cctw17hj.js → nx9hh281.js} +31 -28
- package/dist/shared/{gde73es6.js → p248q79y.js} +56 -55
- package/dist/shared/{janx09m5.js → p6bjzq9q.js} +11 -7
- package/dist/shared/{6rk2gen5.js → pjr6xrm5.js} +2 -2
- package/dist/shared/{wq9n6pwr.js → pz6rj8ay.js} +82 -9
- package/dist/shared/{caw8b9d8.js → q3j1tq7a.js} +35 -22
- package/dist/shared/{8bwbwy8h.js → qq3899ht.js} +128 -18
- package/dist/shared/{tm5ab8we.js → r11n8grd.js} +2 -2
- package/dist/shared/r1fdd0f6.js +19 -0
- package/dist/shared/{8ktwd3rh.js → r3j8s5y0.js} +1 -1
- package/dist/shared/rhs3xe4k.js +7 -0
- package/dist/shared/{ntneex2a.js → rpycarcr.js} +6 -6
- package/dist/shared/{aj2qxyhj.js → sbdme3vy.js} +14 -2
- package/dist/shared/{qv2ydck9.js → t3g0k88x.js} +638 -67
- package/dist/shared/{ga3sfy93.js → ttmg09vd.js} +535 -200
- package/dist/shared/{kfjp0gck.js → venqrjna.js} +8 -4
- package/dist/shared/{fancm5pt.js → vjpnzwjz.js} +138 -15
- package/dist/shared/{32zqc1dw.js → vmfkhszw.js} +31 -7
- package/dist/shared/{krxx77g0.js → wkme6tep.js} +10 -8
- package/dist/shared/{ps7a6h14.js → wt5rzv1h.js} +12 -8
- package/dist/shared/wxr8cwns.js +6 -0
- package/dist/shared/{6mnp99hx.js → wynzeggs.js} +16 -12
- package/dist/shared/x3jc53kg.js +220 -0
- package/dist/shared/{sdc7r2ww.js → xq0mvhts.js} +8 -8
- package/dist/shared/xqve9598.js +53 -0
- package/dist/shared/{47x8x9ze.js → y2t3jktd.js} +2 -2
- package/dist/shared/{9x25fxhc.js → y34a8714.js} +1 -1
- package/dist/shared/{k7dwkhvq.js → y6jdds7g.js} +4 -1
- package/dist/shared/{nkaxvt9q.js → ys0xzyaj.js} +1 -1
- package/dist/shared/{c9z5g0fm.js → ywr8hmey.js} +5 -2
- package/dist/shared/{g7ez901n.js → ywspezzx.js} +1 -1
- package/dist/shared/{9m80mkac.js → ze4hxsmy.js} +1 -1
- package/dist/shared/{r8x5qhd7.js → zm0mafk4.js} +10 -4
- package/dist/shared/{y005b761.js → zy8r7qvz.js} +6 -2
- package/dist/tooling/cli.js +41 -15
- package/dist/tooling/migrate/apply.d.ts +14 -0
- package/dist/tooling/migrate/check.d.ts +3 -4
- package/dist/tooling/migrate/classify.d.ts +4 -0
- package/dist/tooling/migrate/config.d.ts +3 -2
- package/dist/tooling/migrate/files.d.ts +11 -1
- package/dist/tooling/migrate/index.js +14 -14
- package/dist/tooling/migrate/lint.d.ts +1 -1
- package/dist/tooling/migrate/lost.d.ts +28 -0
- package/dist/tooling/migrate/paths.d.ts +14 -0
- package/dist/tooling/migrate/plan.d.ts +6 -3
- package/dist/tooling/migrate/runner.d.ts +25 -0
- package/dist/tooling/migrate/sandbox.d.ts +57 -0
- package/dist/tooling/migrate/sql-lex.d.ts +20 -3
- package/dist/tooling/migrate/text.d.ts +42 -0
- package/dist/tooling/node-version.d.ts +21 -0
- package/dist/tooling/testing/facts.d.ts +33 -5
- package/dist/tooling/testing/index.d.ts +1 -1
- package/dist/tooling/testing/index.js +3 -3
- package/dist/tooling/testing/isolation.d.ts +11 -5
- package/package.json +5 -2
- package/dist/shared/7zwwyh0v.js +0 -448
- package/dist/shared/q58y17hy.js +0 -21
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path tenancy.
|
|
3
|
+
*
|
|
4
|
+
* A table with `tenancy: via("project.organization")` has no tenant column.
|
|
5
|
+
* Reads and writes add `EXISTS` along that relation path. An insert checks the
|
|
6
|
+
* parent in the same statement. The featureless app does not import this file.
|
|
7
|
+
*/
|
|
8
|
+
import { type AnyTable } from "../../dialects/pg/table.js";
|
|
9
|
+
import type { TenancyText, TenantCall } from "../../dialects/pg/tenancy.js";
|
|
10
|
+
/** How `columnTenancy()` classified a table before the rewrite. */
|
|
11
|
+
export type TableKind = "tenant" | "global" | "path";
|
|
12
|
+
/** One step from a path table toward the tenant table. */
|
|
13
|
+
export type PathHop = {
|
|
14
|
+
/** Table that declares this step. */
|
|
15
|
+
readonly child: string;
|
|
16
|
+
/** Table this step points at. */
|
|
17
|
+
readonly parent: string;
|
|
18
|
+
/** Foreign-key field on `child`. */
|
|
19
|
+
readonly localField: string;
|
|
20
|
+
/** Field on `parent` that the foreign key matches. */
|
|
21
|
+
readonly remoteField: string;
|
|
22
|
+
/** SQL name stored on the local column, when the builder set one. */
|
|
23
|
+
readonly localSql: string | undefined;
|
|
24
|
+
/** SQL name stored on the remote column, when the builder set one. */
|
|
25
|
+
readonly remoteSql: string | undefined;
|
|
26
|
+
/** SQL name stored on the parent table, when the table set one. */
|
|
27
|
+
readonly parentSql: string | undefined;
|
|
28
|
+
/** Encodes the local field when an update points it at a new parent. */
|
|
29
|
+
readonly encode: (value: string) => string;
|
|
30
|
+
};
|
|
31
|
+
/** A resolved `via` path. */
|
|
32
|
+
export type PathChain = {
|
|
33
|
+
/** The `via` text, unchanged. */
|
|
34
|
+
readonly via: string;
|
|
35
|
+
/** Steps from the path table to the tenant table. At most three. */
|
|
36
|
+
readonly hops: readonly PathHop[];
|
|
37
|
+
};
|
|
38
|
+
/** What the column strategy asks of a resolved path. */
|
|
39
|
+
export type PathPlan = {
|
|
40
|
+
/** Tenant tables a path ends on, and the declared key that must stay unique. */
|
|
41
|
+
readonly endpoints: ReadonlyMap<string, readonly string[]>;
|
|
42
|
+
/** Path table, when `name` was resolved. */
|
|
43
|
+
isPath(name: string): boolean;
|
|
44
|
+
/** Steps from `name` to the tenant table. */
|
|
45
|
+
hops(name: string): readonly PathHop[] | undefined;
|
|
46
|
+
/** Rewrites one path table: foreign key into the tenant table, and the index. */
|
|
47
|
+
adjust(item: AnyTable): AnyTable;
|
|
48
|
+
/**
|
|
49
|
+
* Writes `EXISTS` for a path table.
|
|
50
|
+
*
|
|
51
|
+
* @returns `true` when `table` is a path table and the predicate was written
|
|
52
|
+
*/
|
|
53
|
+
writeExists(input: ExistsInput): boolean;
|
|
54
|
+
};
|
|
55
|
+
type ExistsInput = {
|
|
56
|
+
readonly table: string;
|
|
57
|
+
readonly alias: string;
|
|
58
|
+
readonly fieldSql: (field: string) => string | undefined;
|
|
59
|
+
readonly scope: TenantCall | undefined;
|
|
60
|
+
readonly sink: TenancyText;
|
|
61
|
+
readonly appended: boolean;
|
|
62
|
+
readonly lock: boolean;
|
|
63
|
+
readonly keys: readonly string[];
|
|
64
|
+
readonly encodeKey: (key: string, value: string) => string;
|
|
65
|
+
/** New parent values, keyed by the path table's foreign-key field. */
|
|
66
|
+
readonly assigned?: Readonly<Record<string, string>>;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Resolves every `via()` table.
|
|
70
|
+
*
|
|
71
|
+
* A path that does not end at a tenant table, a missing relation, a cycle, or
|
|
72
|
+
* more than three hops is OKM1705. The caller rewrites tenant tables after this
|
|
73
|
+
* and adds a unique on each endpoint's declared key.
|
|
74
|
+
*
|
|
75
|
+
* @param tables - Tables passed to `schema()`
|
|
76
|
+
* @param kind - Classification, including `"path"`
|
|
77
|
+
* @returns The plan the predicate and the rewrite share
|
|
78
|
+
*/
|
|
79
|
+
export declare function compilePaths(tables: readonly AnyTable[], kind: ReadonlyMap<string, TableKind>): PathPlan;
|
|
80
|
+
/**
|
|
81
|
+
* Declared primary key, before tenancy adds its columns.
|
|
82
|
+
*
|
|
83
|
+
* @param item - Table as passed to `schema()`
|
|
84
|
+
* @returns Field names, in declaration order
|
|
85
|
+
*/
|
|
86
|
+
export declare function declaredPrimary(item: AnyTable): readonly string[];
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Row-level security tenancy (`rlsTenancy()`).
|
|
3
|
+
*
|
|
4
|
+
* The column predicate stays on every statement. Policies are the backstop.
|
|
5
|
+
* A column-only import does not load this file.
|
|
6
|
+
*/
|
|
7
|
+
import { OkmError } from "../../contracts/error.js";
|
|
8
|
+
import type { DriverConnection, ExecuteOptions, ExecuteResult, Statement, WireValue } from "../../contracts/driver.js";
|
|
9
|
+
import type { ColumnTenancy } from "../../dialects/pg/tenancy.js";
|
|
10
|
+
/** Why {@link RlsRoleError} refused the role. */
|
|
11
|
+
export type RlsRoleReason = "owner" | "superuser" | "bypassrls";
|
|
12
|
+
/**
|
|
13
|
+
* OKM1707. The role would not be subject to the policies.
|
|
14
|
+
*
|
|
15
|
+
* `reason` says which check failed. Superuser wins over `BYPASSRLS`, which
|
|
16
|
+
* wins over table owner.
|
|
17
|
+
*/
|
|
18
|
+
export declare class RlsRoleError extends OkmError {
|
|
19
|
+
readonly reason: RlsRoleReason;
|
|
20
|
+
/**
|
|
21
|
+
* @param reason - Which privilege bypassed row-level security
|
|
22
|
+
* @param endpoint - Endpoint that answered the check. The message names it
|
|
23
|
+
*/
|
|
24
|
+
constructor(reason: RlsRoleReason, endpoint?: string);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Row-level security for `schema({ tenancy })`.
|
|
28
|
+
*
|
|
29
|
+
* One uuid key. The column predicate matches `columnTenancy`. Policies,
|
|
30
|
+
* `set_config`, and the role check load with this import. Combining it with
|
|
31
|
+
* `via()` or `compositeTenancy()` is a definition error.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam Key - Field name of the tenant key
|
|
34
|
+
* @param input - Field name and `uuid`
|
|
35
|
+
* @returns The object `schema()` applies
|
|
36
|
+
*/
|
|
37
|
+
export declare function rlsTenancy<const Key>(input: {
|
|
38
|
+
readonly key: Key extends readonly unknown[] ? "rlsTenancy() takes one key. Combining it with compositeTenancy or via() is not supported yet." : Key extends string ? Key : "rlsTenancy() key must be a field name.";
|
|
39
|
+
readonly type: "uuid";
|
|
40
|
+
}): ColumnTenancy & {
|
|
41
|
+
readonly key: Key extends string ? Key : string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Runs one statement inside `BEGIN READ ONLY` after the tenant setting.
|
|
45
|
+
*
|
|
46
|
+
* The caller releases the connection. A failure rolls the transaction back.
|
|
47
|
+
*
|
|
48
|
+
* @param conn - Reserved connection
|
|
49
|
+
* @param text - User statement
|
|
50
|
+
* @param params - Wire parameters
|
|
51
|
+
* @param prelude - `set_config` statement
|
|
52
|
+
* @param options - Deadline and cancellation, without a route hint
|
|
53
|
+
* @returns The user statement's result
|
|
54
|
+
*/
|
|
55
|
+
export declare function runReadOnly(conn: DriverConnection, text: string, params: readonly WireValue[] | undefined, prelude: Statement, options: ExecuteOptions | undefined): Promise<ExecuteResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Streams one query inside `BEGIN READ ONLY` after the tenant setting.
|
|
58
|
+
*
|
|
59
|
+
* Rows come back in chunks of 64. The caller releases the connection.
|
|
60
|
+
*
|
|
61
|
+
* @param conn - Reserved connection
|
|
62
|
+
* @param text - User query
|
|
63
|
+
* @param params - Wire parameters
|
|
64
|
+
* @param prelude - `set_config` statement
|
|
65
|
+
* @returns Row chunks
|
|
66
|
+
*/
|
|
67
|
+
export declare function streamHeld(conn: DriverConnection, text: string, params: readonly WireValue[] | undefined, prelude: Statement): AsyncGenerator<readonly (readonly WireValue[])[]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path tenancy (`via()`).
|
|
3
|
+
*
|
|
4
|
+
* A table passes `tenancy: via("project.organization")`. This file owns the
|
|
5
|
+
* path compiler. A column-only app does not import it.
|
|
6
|
+
*/
|
|
7
|
+
import type { AnyTable } from "../../dialects/pg/table.js";
|
|
8
|
+
import type { TableRewriteContext } from "./context.js";
|
|
9
|
+
/**
|
|
10
|
+
* Isolates a table through relations instead of a tenant column.
|
|
11
|
+
*
|
|
12
|
+
* The path is at most three to-one steps and must end at a tenant table.
|
|
13
|
+
* `schema()` resolves it while it rewrites. A bad path is OKM1705.
|
|
14
|
+
*
|
|
15
|
+
* @typeParam Path - Relation path, such as `"project.organization"`
|
|
16
|
+
* @param path - Steps from this table to the tenant table, separated by `.`
|
|
17
|
+
* @returns The marker `table({ tenancy })` stores
|
|
18
|
+
*/
|
|
19
|
+
export declare function via<const Path extends string>(path: Path): {
|
|
20
|
+
readonly via: Path;
|
|
21
|
+
rewrite(table: AnyTable, ctx: TableRewriteContext): AnyTable;
|
|
22
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../../shared/
|
|
1
|
+
import"../../shared/qq3899ht.js";
|
|
2
2
|
import {
|
|
3
3
|
checkPresetNames,
|
|
4
4
|
duplicatePreset
|
|
@@ -8,24 +8,27 @@ import {
|
|
|
8
8
|
} from "../../shared/n0dgs0pb.js";
|
|
9
9
|
import {
|
|
10
10
|
quoteIdent
|
|
11
|
-
} from "../../shared/
|
|
11
|
+
} from "../../shared/9s0ypp87.js";
|
|
12
|
+
import {
|
|
13
|
+
pathEndpoint
|
|
14
|
+
} from "../../shared/rhs3xe4k.js";
|
|
12
15
|
import {
|
|
13
16
|
functionObject,
|
|
14
17
|
triggerObject
|
|
15
|
-
} from "../../shared/
|
|
18
|
+
} from "../../shared/y34a8714.js";
|
|
16
19
|
import {
|
|
17
20
|
timestamptz2
|
|
18
|
-
} from "../../shared/
|
|
21
|
+
} from "../../shared/5yv4k6a6.js";
|
|
19
22
|
import {
|
|
20
23
|
uuid2
|
|
21
|
-
} from "../../shared/
|
|
24
|
+
} from "../../shared/2jd1sn0e.js";
|
|
22
25
|
import {
|
|
23
26
|
snakeCase
|
|
24
|
-
} from "../../shared/
|
|
27
|
+
} from "../../shared/rpycarcr.js";
|
|
25
28
|
import {
|
|
26
29
|
ColumnBuilder2,
|
|
27
30
|
retarget
|
|
28
|
-
} from "../../shared/
|
|
31
|
+
} from "../../shared/ywr8hmey.js";
|
|
29
32
|
import {
|
|
30
33
|
definition,
|
|
31
34
|
unavailable
|
|
@@ -33,15 +36,15 @@ import {
|
|
|
33
36
|
import {
|
|
34
37
|
staticNamespace2,
|
|
35
38
|
compareText
|
|
36
|
-
} from "../../shared/
|
|
39
|
+
} from "../../shared/358zsv4r.js";
|
|
37
40
|
import {
|
|
38
41
|
queryHandle,
|
|
39
42
|
attachHttp,
|
|
40
43
|
settleCall
|
|
41
|
-
} from "../../shared/
|
|
44
|
+
} from "../../shared/j60w0dvr.js";
|
|
42
45
|
import {
|
|
43
46
|
installArchiveInspect
|
|
44
|
-
} from "../../shared/
|
|
47
|
+
} from "../../shared/2z7wv5tj.js";
|
|
45
48
|
import {
|
|
46
49
|
fitIdentifier2
|
|
47
50
|
} from "../../shared/nfzc5z0w.js";
|
|
@@ -66,6 +69,9 @@ function rewriteArchivable(self, tables, casing, schemaTraits, cascade) {
|
|
|
66
69
|
});
|
|
67
70
|
}
|
|
68
71
|
function rewriteOne(item, cascade, byName, accepted, edges, casing, schemaTraits, archiveSql, idSql, predicate) {
|
|
72
|
+
if (Object.hasOwn(item, pathEndpoint)) {
|
|
73
|
+
throw new OkmError2("OKM1705", `Table ${item.name} is the end of a path and cannot be archivable().`, { fix: { summary: `Leave ${item.name} out of archivable().` } });
|
|
74
|
+
}
|
|
69
75
|
const links = childLinks(item, cascade, byName, accepted, edges, casing, schemaTraits, archiveSql, idSql);
|
|
70
76
|
const parents = parentLinks(item, byName, edges, casing, schemaTraits, archiveSql, idSql);
|
|
71
77
|
const primary = primaryFields(item);
|
|
@@ -459,7 +465,7 @@ function refuse(host, table) {
|
|
|
459
465
|
}
|
|
460
466
|
var archiveMod;
|
|
461
467
|
function loadArchive() {
|
|
462
|
-
archiveMod ??= import("../../shared/
|
|
468
|
+
archiveMod ??= import("../../shared/mb2ycs1p.js");
|
|
463
469
|
return archiveMod;
|
|
464
470
|
}
|
|
465
471
|
async function settle(host, table, mods) {
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -647,6 +647,16 @@ type ViewApi<Row> = {
|
|
|
647
647
|
readonly where?: FieldWhere<Row>;
|
|
648
648
|
}): Read<boolean>;
|
|
649
649
|
};
|
|
650
|
+
/**
|
|
651
|
+
* `refresh()` on a materialized view.
|
|
652
|
+
*
|
|
653
|
+
* No arguments. It runs `REFRESH MATERIALIZED VIEW`, with `CONCURRENTLY` when
|
|
654
|
+
* the view declares `refresh: "concurrently"`. It is a write, so it uses the
|
|
655
|
+
* primary. It is not tenant-scoped: a scoped client still refreshes the whole view.
|
|
656
|
+
*/
|
|
657
|
+
type MaterializedViewApi<Row> = ViewApi<Row> & {
|
|
658
|
+
refresh(): Promise<void>;
|
|
659
|
+
};
|
|
650
660
|
/** `db.views`, typed from `schema({ views })`. Absent when the schema declares none. */
|
|
651
661
|
type ViewsClient<S> = S extends {
|
|
652
662
|
readonly "~views": infer V extends readonly unknown[];
|
|
@@ -654,7 +664,9 @@ type ViewsClient<S> = S extends {
|
|
|
654
664
|
readonly views: {
|
|
655
665
|
readonly [D in V[number] as D extends {
|
|
656
666
|
readonly name: infer N extends string;
|
|
657
|
-
} ? CamelName<N> : never]:
|
|
667
|
+
} ? CamelName<N> : never]: D extends {
|
|
668
|
+
readonly "~kind": "materialized";
|
|
669
|
+
} ? MaterializedViewApi<Show<ViewRow<D>>> : ViewApi<Show<ViewRow<D>>>;
|
|
658
670
|
};
|
|
659
671
|
} : unknown;
|
|
660
672
|
/** A client whose tables are already inside one tenant or an unscoped reason. */
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
validationGate
|
|
3
|
-
} from "../../shared/
|
|
3
|
+
} from "../../shared/ze4hxsmy.js";
|
|
4
4
|
import {
|
|
5
5
|
addSchemaHook
|
|
6
|
-
} from "../../shared/
|
|
6
|
+
} from "../../shared/hazqqecq.js";
|
|
7
7
|
import {
|
|
8
8
|
queryHandle
|
|
9
|
-
} from "../../shared/
|
|
9
|
+
} from "../../shared/j60w0dvr.js";
|
|
10
10
|
import {
|
|
11
11
|
OkmError2
|
|
12
12
|
} from "../../shared/52szzakm.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
// src/runtime/validate/load.ts
|
|
15
15
|
var engine;
|
|
16
16
|
function loadEngine() {
|
|
17
|
-
engine ??= import("../../shared/
|
|
17
|
+
engine ??= import("../../shared/h15jx9bc.js");
|
|
18
18
|
return engine;
|
|
19
19
|
}
|
|
20
20
|
|
package/dist/runtime/write.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export type PreparedWrite = {
|
|
|
39
39
|
readonly statements: readonly Statement[];
|
|
40
40
|
readonly options: ExecuteOptions | undefined;
|
|
41
41
|
/** Set when `finish` can refuse a statement that already ran. `batch` refuses such a write (D183). */
|
|
42
|
-
readonly checked?: "restore" | "expect";
|
|
42
|
+
readonly checked?: "restore" | "expect" | "parent";
|
|
43
43
|
finish(results: readonly ExecuteResult[]): unknown;
|
|
44
44
|
};
|
|
45
45
|
/**
|