@mistriwork/engine 1.0.0-rc.10 → 1.0.0-rc.12
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/dist/adapters/adapter.d.ts +33 -0
- package/dist/adapters/postgres.d.ts +21 -16
- package/dist/adapters/postgres.js +199 -223
- package/dist/adapters/postgresCatalog.d.ts +12 -1
- package/dist/adapters/postgresCatalog.js +57 -23
- package/dist/adapters/postgresCatalogDigest.js +40 -34
- package/dist/adapters/postgresCatalogRows.d.ts +2 -0
- package/dist/adapters/postgresWriteAhead.d.ts +47 -0
- package/dist/adapters/postgresWriteAhead.js +209 -0
- package/dist/adapters/scoped/keyRows.js +9 -3
- package/dist/adapters/scoped/keyTypes.d.ts +34 -0
- package/dist/adapters/scoped/keyTypes.js +66 -0
- package/dist/adapters/scoped/postgresScopeCatalog.d.ts +40 -1
- package/dist/adapters/scoped/postgresScopeCatalog.js +417 -13
- package/dist/adapters/scoped/postgresTriggers.d.ts +137 -0
- package/dist/adapters/scoped/postgresTriggers.js +1545 -0
- package/dist/adapters/scoped/scopeTriggers.d.ts +122 -0
- package/dist/adapters/scoped/scopeTriggers.js +131 -0
- package/dist/adapters/scoped/scopedReads.d.ts +3 -1
- package/dist/adapters/scoped/scopedReads.js +28 -8
- package/dist/adapters/scoped/scopedTransaction.d.ts +95 -6
- package/dist/adapters/scoped/scopedTransaction.js +308 -34
- package/dist/adapters/scoped/sqliteScopeCatalog.d.ts +17 -1
- package/dist/adapters/scoped/sqliteScopeCatalog.js +197 -18
- package/dist/adapters/scoped/sqliteTriggerSession.d.ts +64 -0
- package/dist/adapters/scoped/sqliteTriggerSession.js +245 -0
- package/dist/adapters/scoped/sqliteTriggers.d.ts +20 -0
- package/dist/adapters/scoped/sqliteTriggers.js +822 -0
- package/dist/adapters/scoped/storedText.d.ts +45 -0
- package/dist/adapters/scoped/storedText.js +61 -0
- package/dist/adapters/scoped/triggerEffects.d.ts +98 -0
- package/dist/adapters/scoped/triggerEffects.js +189 -0
- package/dist/adapters/scoped/triggerProof.d.ts +124 -0
- package/dist/adapters/scoped/triggerProof.js +366 -0
- package/dist/adapters/snapshotRead.d.ts +8 -0
- package/dist/adapters/snapshotRead.js +37 -0
- package/dist/adapters/sqlite.d.ts +13 -2
- package/dist/adapters/sqlite.js +139 -16
- package/dist/adapters/sqliteDecimals.d.ts +2 -2
- package/dist/adapters/sqliteDecimals.js +2 -8
- package/dist/adapters/storeHost.d.ts +4 -1
- package/dist/adapters/writeCapture.d.ts +7 -0
- package/dist/server/cli/args.d.ts +6 -0
- package/dist/server/cli/args.js +6 -0
- package/dist/server/columnGrants.d.ts +3 -0
- package/dist/server/columnGrants.js +12 -1
- package/dist/server/config/profile.d.ts +123 -0
- package/dist/server/config/profile.js +236 -0
- package/dist/server/connections.d.ts +5 -0
- package/dist/server/connections.js +11 -1
- package/dist/server/hiddenColumns.js +6 -0
- package/dist/server/http/refusalReport.js +16 -4
- package/dist/server/http/router.d.ts +11 -22
- package/dist/server/http/router.js +0 -15
- package/dist/server/migrate/cli.d.ts +50 -3
- package/dist/server/migrate/cli.js +199 -14
- package/dist/server/migrate/runner.js +5 -1
- package/dist/server/shapeonly.js +5 -0
- package/dist/shared/addressParams.d.ts +2 -0
- package/dist/shared/addressParams.js +2 -0
- package/dist/shared/aggregate.d.ts +49 -0
- package/dist/shared/aggregate.js +107 -0
- package/dist/shared/breakdown.js +19 -6
- package/dist/shared/decimals.d.ts +37 -0
- package/dist/shared/decimals.js +148 -0
- package/dist/shared/displayDefaults.js +15 -1
- package/dist/shared/filter.d.ts +39 -1
- package/dist/shared/filter.js +96 -15
- package/dist/shared/listPresentations.d.ts +2 -0
- package/dist/shared/listQuestion.d.ts +3 -1
- package/dist/shared/money.d.ts +9 -0
- package/dist/shared/money.js +17 -0
- package/dist/shared/moneyEntry.d.ts +6 -3
- package/dist/shared/moneyEntry.js +14 -7
- package/dist/shared/pageModel.d.ts +1 -1
- package/dist/shared/recordview.d.ts +1 -1
- package/dist/shared/refusal.d.ts +16 -0
- package/dist/shared/refusal.js +40 -0
- package/dist/shared/rowScope.js +12 -4
- package/dist/shared/schema.d.ts +6 -0
- package/dist/shared/schematext.d.ts +22 -6
- package/dist/shared/schematext.js +18 -2
- package/dist/shared/scopeCatalog.js +4 -0
- package/dist/shared/servedApp.d.ts +15 -4
- package/dist/shared/view.js +4 -4
- package/dist/shared/viewLabels.d.ts +1 -0
- package/dist/shared/viewLabels.js +8 -2
- package/dist/shared/viewPaths.d.ts +3 -0
- package/dist/shared/viewPaths.js +8 -0
- package/package.json +5 -2
- package/schema/model.d.ts +1 -1
- package/dist/shared/order.d.ts +0 -59
- package/dist/shared/order.js +0 -133
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { PgQuery } from '../postgresPool.js';
|
|
2
|
+
import { type ScopeTrigger } from './scopeTriggers.js';
|
|
3
|
+
export declare const CATALOG_OPERATORS: {
|
|
4
|
+
readonly EQ: "OPERATOR(pg_catalog.=)";
|
|
5
|
+
readonly NE: "OPERATOR(pg_catalog.<>)";
|
|
6
|
+
readonly LT: "OPERATOR(pg_catalog.<)";
|
|
7
|
+
readonly GT: "OPERATOR(pg_catalog.>)";
|
|
8
|
+
readonly PLUS: "OPERATOR(pg_catalog.+)";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A type with its domains unwrapped, and the type modifier of the last one that has one (a domain over varchar(3)
|
|
12
|
+
* compares as varchar(3)), as a subquery of `(type, typmod)` over the type and modifier expressions given.
|
|
13
|
+
*/
|
|
14
|
+
export declare const baseType: (type: string, typmod: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* The default B-tree operator class of a (base) type, as a scalar subquery: its own, or the one class a binary cast
|
|
17
|
+
* from it (varchar to text), an enum or an array reaches; NULL where there is none or more than one. What an index
|
|
18
|
+
* of the type is built with unless it says otherwise, and so what its equality means.
|
|
19
|
+
*/
|
|
20
|
+
export declare const defaultBtreeClass: (type: string) => string;
|
|
21
|
+
/** One row of {@link postgresTriggerStatement}. */
|
|
22
|
+
export interface PostgresTriggerRow {
|
|
23
|
+
schema: string;
|
|
24
|
+
table: string;
|
|
25
|
+
/** The trigger's own relation, quoted for SQL: where its conditions are parsed. */
|
|
26
|
+
relation: string;
|
|
27
|
+
name: string;
|
|
28
|
+
type: number;
|
|
29
|
+
columns: string[];
|
|
30
|
+
listed: number;
|
|
31
|
+
generated: boolean;
|
|
32
|
+
constraint: boolean;
|
|
33
|
+
transition: boolean;
|
|
34
|
+
qual: string;
|
|
35
|
+
language: string;
|
|
36
|
+
kind: string;
|
|
37
|
+
definer: boolean;
|
|
38
|
+
configured: boolean;
|
|
39
|
+
arguments: number;
|
|
40
|
+
source: string;
|
|
41
|
+
version: string;
|
|
42
|
+
around: string;
|
|
43
|
+
}
|
|
44
|
+
/** The names of the triggers a write to `root` (an oid expression) may fire, sorted: what the scope catalog's facts count. */
|
|
45
|
+
export declare const postgresTreeTriggerNames: (root: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Every user trigger a write to a table may fire, with what the proof reads: the table's own and each of its
|
|
48
|
+
* partitions' and children's, keyed by the table written. `wanted` reads those of the tables named by `$1`
|
|
49
|
+
* (schemas) and `$2` (names); otherwise every ordinary or partitioned table outside the system's schemas, with no
|
|
50
|
+
* parameters (for `mistri check`).
|
|
51
|
+
*/
|
|
52
|
+
export declare function postgresTriggerStatement(wanted: boolean): string;
|
|
53
|
+
/** What a stored tree (`pg_node_tree` as text) holds, read as PostgreSQL's own reader reads it (nodes/read.c). */
|
|
54
|
+
interface PostgresTree {
|
|
55
|
+
nodes: ReadonlyMap<string, number>;
|
|
56
|
+
functions: ReadonlySet<number>;
|
|
57
|
+
operators: ReadonlySet<number>;
|
|
58
|
+
/** Each OPEXPR's operator, in the order the tree holds them: a key's equalities, one each, in the order parsed. */
|
|
59
|
+
opexprs: readonly number[];
|
|
60
|
+
/** The domains it coerces to (CoerceToDomain), whose constraints run when it does. */
|
|
61
|
+
domains: ReadonlySet<number>;
|
|
62
|
+
/** The types of its constants: what a literal in its place is read as. */
|
|
63
|
+
constants: ReadonlySet<number>;
|
|
64
|
+
}
|
|
65
|
+
/** A stored tree, read structurally: every node, and the functions and operators it names. Undefined when it is not one this reader knows. */
|
|
66
|
+
export declare function readPostgresTree(text: string): PostgresTree | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Whether a trigger function's body is in the grammar, and if it is, its
|
|
69
|
+
* conditions, each as the SQL PostgreSQL is to parse in its place (a literal
|
|
70
|
+
* as NULL, TG_OP as a NULL text, NEW and OLD as the view's `"new"` and
|
|
71
|
+
* `"old"`). `returns` is what its RETURN may give back.
|
|
72
|
+
*/
|
|
73
|
+
export declare function plpgsqlConditions(source: string, returns: ReadonlySet<string>): readonly string[] | undefined;
|
|
74
|
+
/** What PostgreSQL said of one trigger's conditions (postgresTriggerAnalyzer). */
|
|
75
|
+
export interface PostgresConditions {
|
|
76
|
+
/** The stored tree of a view selecting them, every one in its place. */
|
|
77
|
+
tree: string;
|
|
78
|
+
/** Whether every one is a boolean, as PL/pgSQL's IF takes it without a cast. */
|
|
79
|
+
boolean: boolean;
|
|
80
|
+
/** The type of each value selected after them, when there are any (a keyed write's). */
|
|
81
|
+
types?: readonly number[];
|
|
82
|
+
}
|
|
83
|
+
/** A value a keyed write assigns, by its type, to `column` of `relation` (SQL, schema-qualified). */
|
|
84
|
+
export interface PostgresAssignment {
|
|
85
|
+
from: number;
|
|
86
|
+
relation: string;
|
|
87
|
+
column: string;
|
|
88
|
+
}
|
|
89
|
+
/** PostgreSQL, asked about triggers on the session that will fire them. */
|
|
90
|
+
export interface PostgresTriggerAnalyzer {
|
|
91
|
+
/** `conditions`, then `values`, parsed over `relation` as NEW and OLD; undefined when PostgreSQL would not parse them. */
|
|
92
|
+
conditions(relation: string, conditions: readonly string[], values?: readonly string[]): Promise<PostgresConditions | undefined>;
|
|
93
|
+
/**
|
|
94
|
+
* Of these functions and operators, each one not proven pure (`f<oid>` or `o<oid>`); of these types, each a literal
|
|
95
|
+
* of which is read through a domain's input, which runs the domain's checks (`t<oid>`); of these assignments, each
|
|
96
|
+
* one that would run a cast's function not proven pure, or reaches no column (`c<index>`); of these key
|
|
97
|
+
* equalities, each whose operator is not its column's own equality, or whose column is not there (`k<index>`).
|
|
98
|
+
*/
|
|
99
|
+
impure(functions: readonly number[], operators: readonly number[], types: readonly number[], assignments?: readonly PostgresAssignment[], keys?: readonly PostgresKeyOperator[]): Promise<ReadonlySet<string>>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* One equality of a trigger's key as PostgreSQL resolved it: its operator, and the key column it compares. It
|
|
103
|
+
* must be the equality (strategy 3) of the default B-tree operator class of the column's type, unwrapped of its
|
|
104
|
+
* domains: the equality a unique index of the column is unique by, and the one the proof reads the row with.
|
|
105
|
+
*/
|
|
106
|
+
interface PostgresKeyOperator {
|
|
107
|
+
readonly operator: number;
|
|
108
|
+
readonly relation: string;
|
|
109
|
+
readonly column: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The analyzer on `client`, which must be inside a transaction that may write
|
|
113
|
+
* (a read-only one cannot make even a temporary view). Each parse is made and
|
|
114
|
+
* undone inside a savepoint, so the transaction is left as it was, and a
|
|
115
|
+
* condition PostgreSQL rejects only fails its own proof.
|
|
116
|
+
*/
|
|
117
|
+
export declare function postgresTriggerAnalyzer(client: PgQuery): PostgresTriggerAnalyzer;
|
|
118
|
+
/**
|
|
119
|
+
* Each table's triggers, keyed `schema.name`, from the statement's rows, and
|
|
120
|
+
* what each table's proof was read from. Throws on a row of an unknown shape.
|
|
121
|
+
*/
|
|
122
|
+
export declare function postgresTriggersByTable(rows: readonly unknown[], analyzer: PostgresTriggerAnalyzer | undefined): Promise<Map<string, {
|
|
123
|
+
triggers: ScopeTrigger[];
|
|
124
|
+
version: string;
|
|
125
|
+
}>>;
|
|
126
|
+
/** What each table's proof was read from, keyed `schema.name`, without proving anything again: what an attestation compares. */
|
|
127
|
+
export declare function postgresTriggerVersions(rows: readonly unknown[]): Map<string, string>;
|
|
128
|
+
/**
|
|
129
|
+
* The code each wanted table's writes may run that calls a function the
|
|
130
|
+
* database made, as the triggers a write is judged by (never validation-only),
|
|
131
|
+
* keyed `schema.name`. `client` answers on the writer.
|
|
132
|
+
*/
|
|
133
|
+
export declare function readPostgresTableCode(client: PgQuery, tables: ReadonlyArray<{
|
|
134
|
+
schema: string;
|
|
135
|
+
name: string;
|
|
136
|
+
}>): Promise<Map<string, ScopeTrigger[]>>;
|
|
137
|
+
export {};
|