@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
|
@@ -12,11 +12,15 @@
|
|
|
12
12
|
import { type DatabaseSchema, type Order, type TableMeta } from '../shared/schema.js';
|
|
13
13
|
import type { CompiledColumn, CompiledJoin, ViewDef } from '../shared/view.js';
|
|
14
14
|
import type { BreakdownDef, CompiledMeasure } from '../shared/breakdown.js';
|
|
15
|
+
import type { AggregateRequest, AggregateResult } from '../shared/aggregate.js';
|
|
15
16
|
import type { RowScope } from '../shared/rowScope.js';
|
|
16
17
|
import type { QueryResult } from '../shared/reads.js';
|
|
17
18
|
import { type Filter, type SqlFragment, type SqlStyle } from '../shared/filter.js';
|
|
18
19
|
import type { PoolRoleStats } from './poolMetrics.js';
|
|
20
|
+
import type { ScopeTrigger } from './scoped/scopeTriggers.js';
|
|
21
|
+
import type { TriggerKeyFacts } from './scoped/triggerEffects.js';
|
|
19
22
|
export { ANSI_STYLE, OPS, POSTGRES_STYLE, buildWhere, type Condition, type Filter, type Op, type SqlFragment, type SqlStyle, } from '../shared/filter.js';
|
|
23
|
+
export type { AggregateMeasure, AggregateRequest, AggregateResult } from '../shared/aggregate.js';
|
|
20
24
|
export { DEFAULT_LIMIT, ESTIMATE_ABOVE, MAX_LIMIT, clampLimit, clampOffset, countStatement, countEachStatement, countEachRows, type CountResult, type QueryResult, } from '../shared/reads.js';
|
|
21
25
|
/** One count of `Adapter.countEach`: a table, and the rows of it to count. */
|
|
22
26
|
export interface CountItem {
|
|
@@ -67,6 +71,11 @@ export interface QueryRequest {
|
|
|
67
71
|
offset: number;
|
|
68
72
|
/** Binary columns come back as their bytes, not the `<n bytes>` label: a file download's read, never a grid's. */
|
|
69
73
|
binary?: true;
|
|
74
|
+
/**
|
|
75
|
+
* A PostgreSQL scoped read also selects the stored text of the table's reference columns, which a scoped write's
|
|
76
|
+
* parent check binds rather than the driver's reading of them (scoped/storedText.ts). Ignored elsewhere.
|
|
77
|
+
*/
|
|
78
|
+
storedText?: true;
|
|
70
79
|
}
|
|
71
80
|
/**
|
|
72
81
|
* What running a view returns.
|
|
@@ -389,6 +398,10 @@ export interface WriteTransaction {
|
|
|
389
398
|
lockRecord?(request: DeleteRequest): Promise<void>;
|
|
390
399
|
query(request: QueryRequest): Promise<QueryResult>;
|
|
391
400
|
count(table: string, filter?: Filter): Promise<number>;
|
|
401
|
+
/** A command's sums, counts and groups over one table's own columns (shared/aggregate.ts), read as `count` reads:
|
|
402
|
+
* through the same scope, footprint and table names. Optional, and never approximated where absent: a facade that
|
|
403
|
+
* cannot bound it as it bounds `count` leaves it out, and the command's `db` refuses the call. */
|
|
404
|
+
aggregate?(request: AggregateRequest): Promise<AggregateResult>;
|
|
392
405
|
/** Non-replacing creation, including restoration: enforce InsertRequest's
|
|
393
406
|
* conflict contract in this transaction. A prior absent-key lock/read is not
|
|
394
407
|
* an absence reservation; uniqueness conflicts must still reject the insert. */
|
|
@@ -459,6 +472,8 @@ export interface ScopedReads {
|
|
|
459
472
|
runBreakdown(breakdown: BreakdownDef, offset?: number): Promise<BreakdownResult>;
|
|
460
473
|
/** With `limit`, stops after that many groups, as `count` does. */
|
|
461
474
|
countBreakdown(breakdown: BreakdownDef, limit?: number): Promise<number>;
|
|
475
|
+
/** An aggregate over one table, under the scope (WriteTransaction.aggregate). */
|
|
476
|
+
aggregate?(request: AggregateRequest): Promise<AggregateResult>;
|
|
462
477
|
/** Several `count`s in one statement, each under the scope and its own filter
|
|
463
478
|
* (a menu's badges); absent on a reader that counts one at a time. */
|
|
464
479
|
countEach?(items: readonly CountItem[], limit?: number): Promise<number[]>;
|
|
@@ -490,6 +505,20 @@ export interface Adapter {
|
|
|
490
505
|
* the boundary that always holds. Absent where there is no role (SQLite).
|
|
491
506
|
*/
|
|
492
507
|
privileges?(): Promise<RolePrivileges>;
|
|
508
|
+
/**
|
|
509
|
+
* Each table's triggers, keyed by table id, read as a row-scoped write reads
|
|
510
|
+
* them (scoped/scopeTriggers.ts): which writes fire each, and whether it only
|
|
511
|
+
* checks the row it fires on. For `mistri check`, which names the commands a
|
|
512
|
+
* trigger blocks; a write never trusts this, and reads them again on its
|
|
513
|
+
* writer, under its own lock.
|
|
514
|
+
*/
|
|
515
|
+
triggers?(): Promise<ReadonlyMap<string, readonly ScopeTrigger[]>>;
|
|
516
|
+
/**
|
|
517
|
+
* The keys of `tables` a trigger's effect may name, and how each column compares, read by the rules a scoped
|
|
518
|
+
* write judges effects by (triggerEffects.ts), so `mistri check` refuses the keys a write would refuse. As with
|
|
519
|
+
* `triggers`, a write never trusts this and reads them again on its writer.
|
|
520
|
+
*/
|
|
521
|
+
triggerKeys?(tables: readonly string[]): Promise<TriggerKeyFacts>;
|
|
493
522
|
/**
|
|
494
523
|
* The connection pools' meters (poolMetrics.ts): checkouts, the wait for a
|
|
495
524
|
* connection, how long each was held, how many are in use and queued now.
|
|
@@ -578,6 +607,10 @@ export interface Adapter {
|
|
|
578
607
|
runBreakdown?(breakdown: BreakdownDef, offset?: number): Promise<BreakdownResult>;
|
|
579
608
|
/** How many groups there are, ignoring the page. With `limit`, stops after that many. */
|
|
580
609
|
countBreakdown?(breakdown: BreakdownDef, limit?: number): Promise<number>;
|
|
610
|
+
/** A command's sums and groups over one table's own columns (shared/aggregate.ts), as `count` reads the table:
|
|
611
|
+
what a row policy's `db`, a page loader and a command's availability read through. Optional, and never
|
|
612
|
+
approximated where absent: a reader that cannot bound it as it bounds `count` leaves it out, and the `db` refuses. */
|
|
613
|
+
aggregate?(request: AggregateRequest): Promise<AggregateResult>;
|
|
581
614
|
/**
|
|
582
615
|
* Count matching rows, for pagination and the "how many point here" badge.
|
|
583
616
|
* With `limit`, stop after that many matching rows (countStatement): the
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { type Adapter, type Filter, type QueryRequest, type QueryResult, type ScopedReads, type SqlRequest, type SqlResult, type ViewResult, type BreakdownResult, type ExplainRequest, type ExplainResult, type ProfileResult, TransactionOperations, type WriteTransaction, type DeleteRequest, type DeleteResult, type InsertRequest, type InsertResult, type UpdateRequest, type UpdateResult, type CountItem, type RolePrivileges, type SqlStyle } from './adapter.js';
|
|
1
|
+
import { type Adapter, type Filter, type QueryRequest, type QueryResult, type ScopedReads, type SqlRequest, type SqlResult, type ViewResult, type BreakdownResult, type ExplainRequest, type ExplainResult, type ProfileResult, TransactionOperations, type WriteTransaction, type DeleteRequest, type DeleteResult, type InsertRequest, type InsertResult, type UpdateRequest, type UpdateResult, type CountItem, type RolePrivileges, type SqlStyle, type AggregateRequest, type AggregateResult } from './adapter.js';
|
|
2
|
+
import type { TriggerAcceptance } from './scoped/triggerProof.js';
|
|
2
3
|
import { type PostgresScopeCatalog } from './scoped/postgresScopeCatalog.js';
|
|
4
|
+
import type { ScopeTrigger } from './scoped/scopeTriggers.js';
|
|
5
|
+
import type { TriggerKeyFacts } from './scoped/triggerEffects.js';
|
|
3
6
|
import { type PinnedPostgresReadOwner, type PostgresReadDependency } from './postgresReadCatalog.js';
|
|
4
7
|
import type { DatabaseSchema } from '../shared/schema.js';
|
|
5
8
|
import { type ViewDef } from '../shared/view.js';
|
|
@@ -113,6 +116,20 @@ export declare class PostgresAdapter implements Adapter {
|
|
|
113
116
|
scopeStyle(): Promise<SqlStyle>;
|
|
114
117
|
/** The role's reach, asked of the catalog on the reader (rolePrivileges.ts). */
|
|
115
118
|
privileges(): Promise<RolePrivileges>;
|
|
119
|
+
/**
|
|
120
|
+
* Each table's triggers, read as a scoped write reads them on its writer. On
|
|
121
|
+
* a writer, inside a transaction rolled back: the proof has PostgreSQL parse
|
|
122
|
+
* each condition into a temporary view (postgresTriggers.ts), which a
|
|
123
|
+
* read-only transaction may not make. Without a writer nothing with a
|
|
124
|
+
* condition is proven, and such a trigger is then said to block.
|
|
125
|
+
*/
|
|
126
|
+
triggers(): Promise<ReadonlyMap<string, readonly ScopeTrigger[]>>;
|
|
127
|
+
/**
|
|
128
|
+
* What a write reads of `tables` to judge a trigger's effects (postgresScopeCatalog.ts effectCatalogFacts): their
|
|
129
|
+
* keys, which are in a partition or inheritance hierarchy, and which a scoped write cannot target. On a writer where there is one,
|
|
130
|
+
* inside a transaction rolled back, so the privileges read are the writer's, as `triggers` reads.
|
|
131
|
+
*/
|
|
132
|
+
triggerKeys(tables: readonly string[]): Promise<TriggerKeyFacts>;
|
|
116
133
|
/** The catalog as one handle sees it, read by postgresCatalog.ts: the
|
|
117
134
|
* reader on connect, or the leased writer inside a scoped transaction,
|
|
118
135
|
* where the same description is the evidence the deployed permissions are
|
|
@@ -209,8 +226,10 @@ export declare class PostgresAdapter implements Adapter {
|
|
|
209
226
|
*/
|
|
210
227
|
estimateCount(table: string): Promise<number | undefined>;
|
|
211
228
|
count(table: string, filter?: Filter, limit?: number): Promise<number>;
|
|
229
|
+
aggregate(request: AggregateRequest): Promise<AggregateResult>;
|
|
212
230
|
countEach(items: readonly CountItem[], limit?: number): Promise<number[]>;
|
|
213
231
|
private countOn;
|
|
232
|
+
private aggregateOn;
|
|
214
233
|
private columnsOf;
|
|
215
234
|
/**
|
|
216
235
|
* Update one row, having proved it is one row.
|
|
@@ -281,8 +300,6 @@ export declare class PostgresAdapter implements Adapter {
|
|
|
281
300
|
* reader: by key from the kept rows where they answer, else in its turn.
|
|
282
301
|
*/
|
|
283
302
|
private openPlain;
|
|
284
|
-
/** The statements openPlain sends behind the BEGIN; each exactly what the transaction sends in its turn (lockRecordNow, queryOn). */
|
|
285
|
-
private sendPlainAhead;
|
|
286
303
|
/**
|
|
287
304
|
* Same-source records and a durable journal in one transaction, the
|
|
288
305
|
* journal lent by the App framework (storeHost.ts TransactionJournal): the
|
|
@@ -333,7 +350,7 @@ export declare class PostgresAdapter implements Adapter {
|
|
|
333
350
|
* rollback that was not acknowledged, is unknown, and the client is
|
|
334
351
|
* discarded rather than reused. Everything else did not commit.
|
|
335
352
|
*/
|
|
336
|
-
scopeTransaction<T>(input: RowScope, run: (tx: WriteTransaction, catalog: DatabaseSchema) => Promise<T
|
|
353
|
+
scopeTransaction<T>(input: RowScope, run: (tx: WriteTransaction, catalog: DatabaseSchema) => Promise<T>, triggers?: TriggerAcceptance): Promise<T>;
|
|
337
354
|
/**
|
|
338
355
|
* Private source-owner boundary, deliberately absent from Adapter: the
|
|
339
356
|
* PostgreSQL counterpart of `SqliteAdapter.scopeVerifiedTransaction`. The
|
|
@@ -366,18 +383,6 @@ export declare class PostgresAdapter implements Adapter {
|
|
|
366
383
|
* capability. Only this actual adapter's native snapshot runner is used. */
|
|
367
384
|
capturePinnedReadSnapshot(dependencies: readonly PostgresReadDependency[], assertCurrent: () => void): Promise<PinnedPostgresReadOwner>;
|
|
368
385
|
private scopedTransact;
|
|
369
|
-
/**
|
|
370
|
-
* The statements a scoped transaction opens with, sent behind its BEGIN
|
|
371
|
-
* (openWrite's `sent`), from what it was told (writeAhead.ts) and the scope
|
|
372
|
-
* catalog read last time: the verifier's own (its fence), the journal's
|
|
373
|
-
* receipt lookup, and for each target its row lock, its row read in full
|
|
374
|
-
* through the scope (kept to answer its reads by key, keyRows.ts), and,
|
|
375
|
-
* where the write is captured for history, the capture's own lock and read
|
|
376
|
-
* (historyWrites). Each is exactly the statement the transaction sends in
|
|
377
|
-
* its turn, built by the same rules; one it never sends is left, counted,
|
|
378
|
-
* and changes nothing. None where the client does not pipeline.
|
|
379
|
-
*/
|
|
380
|
-
private sendWriteAhead;
|
|
381
386
|
/**
|
|
382
387
|
* Internal runtime-owner composition, deliberately absent from Adapter: the
|
|
383
388
|
* PostgreSQL counterpart of `SqliteAdapter.runtimeMaintenanceTransaction`,
|