@mistriwork/engine 1.0.0-rc.44 → 1.0.0-rc.46
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 +10 -0
- package/dist/adapters/postgres.js +4 -0
- package/dist/adapters/sqlite.js +3 -0
- package/dist/adapters/writeCapture.d.ts +3 -1
- package/dist/shared/schema.d.ts +6 -0
- package/dist/shared/scopeCatalog.js +3 -0
- package/dist/shared/servedApp.d.ts +2 -0
- package/package.json +1 -1
|
@@ -467,6 +467,10 @@ export interface WriteTransaction {
|
|
|
467
467
|
* in this transaction, as a write's rules do, with the step's words. Writes nothing to the record. Only the flows'
|
|
468
468
|
* own command reaches it, about its own target; a facade that cannot carry it omits it. */
|
|
469
469
|
tell?(request: TellRequest): Promise<void>;
|
|
470
|
+
/** Internal: something done to a record that changed none of its fields, written to its history in this
|
|
471
|
+
* transaction (a link's revoke, http/recordLinkRoutes.ts). Nothing is written where the record keeps no history; a
|
|
472
|
+
* facade that cannot carry it omits it. */
|
|
473
|
+
noted?(request: NoteRequest): Promise<void>;
|
|
470
474
|
}
|
|
471
475
|
/** Several inserts of one table: one statement where the transaction carries a batch, else one at a time, in order. */
|
|
472
476
|
export declare function insertAll(tx: WriteTransaction, requests: readonly InsertRequest[]): Promise<InsertResult[]>;
|
|
@@ -505,6 +509,12 @@ export declare function chunked<T>(rows: readonly T[], weight: (row: T) => numbe
|
|
|
505
509
|
export declare function batchedRows(applied: ReadonlyArray<Record<string, unknown>>, stored: ReadonlyArray<Record<string, unknown>>): Record<string, unknown>[];
|
|
506
510
|
/** A key that matched no row, or more than one: a guarded update's miss is a conflict, any other a refusal. */
|
|
507
511
|
export declare function refuseUpdateMatches(request: UpdateRequest, count: number): never;
|
|
512
|
+
/** What a record's history is told that no field shows: which record, and what was done, in the words its history says. */
|
|
513
|
+
export interface NoteRequest {
|
|
514
|
+
table: string;
|
|
515
|
+
key: Record<string, string | number>;
|
|
516
|
+
action: string;
|
|
517
|
+
}
|
|
508
518
|
/** What a flow's notify step tells: whom (an audience a `notify` rule names `on: { flow }`), about which record, and its words. */
|
|
509
519
|
export interface TellRequest {
|
|
510
520
|
table: string;
|
|
@@ -904,6 +904,7 @@ export class PostgresAdapter {
|
|
|
904
904
|
remove: (r) => history.remove(r, base.remove),
|
|
905
905
|
...gatheredBatches(base, history),
|
|
906
906
|
tell: (r) => history.tell(r),
|
|
907
|
+
...(history.noted ? { noted: (r) => history.noted(r) } : {}),
|
|
907
908
|
finish: () => finishWriteCapture(history),
|
|
908
909
|
committed: () => committedWriteCapture(history),
|
|
909
910
|
triggered: async (change) => history.triggered?.(change),
|
|
@@ -997,6 +998,7 @@ export class PostgresAdapter {
|
|
|
997
998
|
update: (r) => operations.run(() => writes.update(r)),
|
|
998
999
|
...batchesThrough(writes, (work) => operations.run(work)),
|
|
999
1000
|
...(writes.tell ? { tell: (r) => operations.run(() => writes.tell(r)) } : {}),
|
|
1001
|
+
...(writes.noted ? { noted: (r) => operations.run(() => writes.noted(r)) } : {}),
|
|
1000
1002
|
})));
|
|
1001
1003
|
await operations.finish();
|
|
1002
1004
|
await writes.finish();
|
|
@@ -1160,6 +1162,7 @@ export class PostgresAdapter {
|
|
|
1160
1162
|
update: (r) => operations.run(() => writes.update(r)),
|
|
1161
1163
|
...batchesThrough(writes, (work) => operations.run(work)),
|
|
1162
1164
|
...(writes.tell ? { tell: (r) => operations.run(() => writes.tell(r)) } : {}),
|
|
1165
|
+
...(writes.noted ? { noted: (r) => operations.run(() => writes.noted(r)) } : {}),
|
|
1163
1166
|
};
|
|
1164
1167
|
// The transaction's own work runs without the hint: a transaction it opens is not this one.
|
|
1165
1168
|
const out = await withoutWriteAhead(() => withoutSnapshotRead(() => run(Object.freeze(records), journal.open(write, operations))));
|
|
@@ -1520,6 +1523,7 @@ export class PostgresAdapter {
|
|
|
1520
1523
|
update: (r) => invoke(r, (r) => records.update(r)),
|
|
1521
1524
|
// Beneath the row scope: the flows' command tells only of its own target, which it read through the scope.
|
|
1522
1525
|
...(writes.tell ? { tell: (r) => invoke(r, (r) => writes.tell(r)) } : {}),
|
|
1526
|
+
...(writes.noted ? { noted: (r) => invoke(r, (r) => writes.noted(r)) } : {}),
|
|
1523
1527
|
}), journal?.open(write, operations), evidence)));
|
|
1524
1528
|
await operations.finish();
|
|
1525
1529
|
await writes.finish();
|
package/dist/adapters/sqlite.js
CHANGED
|
@@ -356,6 +356,8 @@ export class SqliteAdapter {
|
|
|
356
356
|
columns,
|
|
357
357
|
approxRows: approxRowsOf(t.name, t.type),
|
|
358
358
|
isView: t.type === 'view',
|
|
359
|
+
/* AUTOINCREMENT is only in the statement: the catalog says nothing else about it. */
|
|
360
|
+
...(identity && !/\bAUTOINCREMENT\b/i.test(t.sql ?? '') ? { reusesKeys: true } : {}),
|
|
359
361
|
indexed: t.type === 'view' ? [] : this.leadingIndexColumns(columns, indexes),
|
|
360
362
|
...(() => {
|
|
361
363
|
const unique = t.type === 'view' ? [] : this.uniqueColumns(indexes);
|
|
@@ -1619,6 +1621,7 @@ export class SqliteAdapter {
|
|
|
1619
1621
|
: {}),
|
|
1620
1622
|
// Beneath the row scope: the flows' command tells only of its own target, which it read through the scope.
|
|
1621
1623
|
...(history ? { tell: (r) => invoke(r, (r) => history.tell(r)) } : {}),
|
|
1624
|
+
...(history?.noted ? { noted: (r) => invoke(r, (r) => history.noted(r)) } : {}),
|
|
1622
1625
|
}), journal?.open(handle, operations, verify ? verifiedStep : undefined), evidence);
|
|
1623
1626
|
await operations.finish();
|
|
1624
1627
|
witness?.settle();
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* as in the database browser, no write is captured.
|
|
14
14
|
*/
|
|
15
15
|
import type { DatabaseSync } from 'node:sqlite';
|
|
16
|
-
import type { DeleteRequest, DeleteResult, InsertRequest, InsertResult, TellRequest, UpdateRequest, UpdateResult } from './adapter.js';
|
|
16
|
+
import type { DeleteRequest, DeleteResult, InsertRequest, InsertResult, NoteRequest, TellRequest, UpdateRequest, UpdateResult } from './adapter.js';
|
|
17
17
|
import type { PgQuery } from './postgresPool.js';
|
|
18
18
|
import type { TriggerChange } from './scoped/triggerProof.js';
|
|
19
19
|
/** The transaction's writer, by dialect: a capture's own rows join it. */
|
|
@@ -47,6 +47,8 @@ interface WriteCapture {
|
|
|
47
47
|
remove(request: DeleteRequest, write: (request: DeleteRequest) => Promise<DeleteResult>): Promise<DeleteResult>;
|
|
48
48
|
/** A flow's notify step (WriteTransaction.tell). */
|
|
49
49
|
tell(request: TellRequest): Promise<void>;
|
|
50
|
+
/** A record's history told of what changed none of its fields (WriteTransaction.noted); absent where nothing keeps one. */
|
|
51
|
+
noted?(request: NoteRequest): Promise<void>;
|
|
50
52
|
/**
|
|
51
53
|
* A row a trigger the App accepts changed, once the proof reached it (scoped/triggerProof.ts): the database wrote
|
|
52
54
|
* it, not a statement of the transaction, so nothing above passes through the three writes. Kept and announced as
|
package/dist/shared/schema.d.ts
CHANGED
|
@@ -198,6 +198,12 @@ export interface TableMeta {
|
|
|
198
198
|
sortable?: string[];
|
|
199
199
|
/** `false` when the source reports no totals (an API): lists page without one, and nothing asks for a count. */
|
|
200
200
|
countable?: false;
|
|
201
|
+
/**
|
|
202
|
+
* Set on a SQLite table whose key is a rowid alias declared without AUTOINCREMENT: SQLite may hand a deleted row's
|
|
203
|
+
* key to the next insert, so whatever outlives the row and names it by key (a capability link) may come to name a
|
|
204
|
+
* new one. Absent elsewhere, AUTOINCREMENT and every other engine included.
|
|
205
|
+
*/
|
|
206
|
+
reusesKeys?: true;
|
|
201
207
|
/** True for views — read-only, and worth saying so rather than surprising. */
|
|
202
208
|
isView: boolean;
|
|
203
209
|
/** An App's union (appUnions.ts): read by asking each branch it holds, never as a table. */
|
|
@@ -178,6 +178,7 @@ export function captureScopeCatalog(schema) {
|
|
|
178
178
|
'filterIn',
|
|
179
179
|
'sortable',
|
|
180
180
|
'countable',
|
|
181
|
+
'reusesKeys',
|
|
181
182
|
]);
|
|
182
183
|
if (!identifier(table.id) ||
|
|
183
184
|
/* A catalog of several connections says which engine reads each table
|
|
@@ -256,6 +257,8 @@ export function captureScopeCatalog(schema) {
|
|
|
256
257
|
return refuse();
|
|
257
258
|
if (table.countable !== undefined && table.countable !== false)
|
|
258
259
|
return refuse();
|
|
260
|
+
if (table.reusesKeys !== undefined && table.reusesKeys !== true)
|
|
261
|
+
return refuse();
|
|
259
262
|
// Index advice, as `unique` is address evidence: only columns this table has.
|
|
260
263
|
if (table.trigram !== undefined &&
|
|
261
264
|
(!Array.isArray(table.trigram) ||
|
|
@@ -690,6 +690,8 @@ export interface ServedApp<View extends object = ServedDashboardView | ServedFor
|
|
|
690
690
|
ui: ServedAppUi;
|
|
691
691
|
writableTables?: string[] | false;
|
|
692
692
|
exportableTables?: string[];
|
|
693
|
+
/** The tables whose records' capability links this reader may revoke from the record page (appPayload.ts). */
|
|
694
|
+
revokesLinks?: string[];
|
|
693
695
|
viewerRoles?: string[];
|
|
694
696
|
grantedCommands?: string[];
|
|
695
697
|
grantedActions?: Record<string, string[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mistriwork/engine",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.46",
|
|
4
4
|
"description": "The engine both products stand on: the adapters (SQLite, Postgres), the catalog, the query language, keyset pages, the HTTP kit and the shared rules. No React.",
|
|
5
5
|
"homepage": "https://mistriwork.dev",
|
|
6
6
|
"bugs": {
|