@mistriwork/engine 1.0.0-rc.45 → 1.0.0-rc.47
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 +1 -0
- package/dist/adapters/writeCapture.d.ts +3 -1
- package/dist/shared/computed.d.ts +2 -1
- package/dist/shared/computed.js +4 -1
- package/dist/shared/rollups.d.ts +4 -1
- package/dist/shared/rollups.js +5 -1
- package/dist/shared/schema.d.ts +5 -0
- package/dist/shared/servedApp.d.ts +5 -1
- package/dist/shared/servedApp.js +4 -2
- package/dist/shared/theme.js +4 -3
- 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
|
@@ -1621,6 +1621,7 @@ export class SqliteAdapter {
|
|
|
1621
1621
|
: {}),
|
|
1622
1622
|
// Beneath the row scope: the flows' command tells only of its own target, which it read through the scope.
|
|
1623
1623
|
...(history ? { tell: (r) => invoke(r, (r) => history.tell(r)) } : {}),
|
|
1624
|
+
...(history?.noted ? { noted: (r) => invoke(r, (r) => history.noted(r)) } : {}),
|
|
1624
1625
|
}), journal?.open(handle, operations, verify ? verifiedStep : undefined), evidence);
|
|
1625
1626
|
await operations.finish();
|
|
1626
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
|
|
@@ -117,7 +117,8 @@ export interface ComputedColumn {
|
|
|
117
117
|
export interface ComputedPath extends ComputedColumn {
|
|
118
118
|
on: string;
|
|
119
119
|
}
|
|
120
|
-
/** What a computed column is to anything that reads columns: typed, never written, never a key.
|
|
120
|
+
/** What a computed column is to anything that reads columns: typed, never written, never a key. A number is said to
|
|
121
|
+
DERIVED_PLACES, as an average is: `minutes / 60` read 1.3333333. */
|
|
121
122
|
export declare function computedColumnMeta(name: string, computed: Pick<ComputedColumn, 'type'>): ColumnMeta;
|
|
122
123
|
/**
|
|
123
124
|
* The catalog with each table's computed columns among its columns, typed and never written (`computed` by table id):
|
package/dist/shared/computed.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { noteRead } from './query.js';
|
|
2
|
+
import { DERIVED_PLACES } from './rollups.js';
|
|
2
3
|
export const COMPUTED_TYPES = ['boolean', 'number', 'date', 'text'];
|
|
3
|
-
/** What a computed column is to anything that reads columns: typed, never written, never a key.
|
|
4
|
+
/** What a computed column is to anything that reads columns: typed, never written, never a key. A number is said to
|
|
5
|
+
DERIVED_PLACES, as an average is: `minutes / 60` read 1.3333333. */
|
|
4
6
|
export function computedColumnMeta(name, computed) {
|
|
5
7
|
return {
|
|
6
8
|
name,
|
|
@@ -8,6 +10,7 @@ export function computedColumnMeta(name, computed) {
|
|
|
8
10
|
nullable: computed.type !== 'boolean',
|
|
9
11
|
primaryKey: false,
|
|
10
12
|
writable: false,
|
|
13
|
+
...(computed.type === 'number' ? { places: DERIVED_PLACES } : {}),
|
|
11
14
|
};
|
|
12
15
|
}
|
|
13
16
|
/**
|
package/dist/shared/rollups.d.ts
CHANGED
|
@@ -124,7 +124,10 @@ export interface Rollup {
|
|
|
124
124
|
export interface ComputedPath extends Rollup {
|
|
125
125
|
on: string;
|
|
126
126
|
}
|
|
127
|
-
/**
|
|
127
|
+
/** The most places a worked-out figure is said with: an average's, a computed number's. Two, as money reads. */
|
|
128
|
+
export declare const DERIVED_PLACES = 2;
|
|
129
|
+
/** A rollup read as a column: never written, null only where there are no rows to read (a count is 0). An average
|
|
130
|
+
is said to DERIVED_PLACES: of whole numbers it read "3.333" (a field report). */
|
|
128
131
|
export declare function rollupColumnMeta(name: string, rollup: Pick<Rollup, 'fn' | 'type' | 'allowed' | 'references'>): ColumnMeta;
|
|
129
132
|
/** A view's or a breakdown's `computed` with every child table renamed. */
|
|
130
133
|
export declare function renamedComputed<T extends {
|
package/dist/shared/rollups.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export const ROLLUP_FNS = ['count', 'sum', 'avg', 'min', 'max', 'latest'];
|
|
2
|
-
/**
|
|
2
|
+
/** The most places a worked-out figure is said with: an average's, a computed number's. Two, as money reads. */
|
|
3
|
+
export const DERIVED_PLACES = 2;
|
|
4
|
+
/** A rollup read as a column: never written, null only where there are no rows to read (a count is 0). An average
|
|
5
|
+
is said to DERIVED_PLACES: of whole numbers it read "3.333" (a field report). */
|
|
3
6
|
export function rollupColumnMeta(name, rollup) {
|
|
4
7
|
return {
|
|
5
8
|
name,
|
|
@@ -7,6 +10,7 @@ export function rollupColumnMeta(name, rollup) {
|
|
|
7
10
|
nullable: rollup.fn !== 'count',
|
|
8
11
|
primaryKey: false,
|
|
9
12
|
writable: false,
|
|
13
|
+
...(rollup.fn === 'avg' ? { places: DERIVED_PLACES } : {}),
|
|
10
14
|
...(rollup.allowed ? { allowed: rollup.allowed } : {}),
|
|
11
15
|
...(rollup.references ? { references: rollup.references } : {}),
|
|
12
16
|
};
|
package/dist/shared/schema.d.ts
CHANGED
|
@@ -41,6 +41,11 @@ export interface ColumnMeta {
|
|
|
41
41
|
* string carries its own (`decimals.ts` declaredScale).
|
|
42
42
|
*/
|
|
43
43
|
scale?: number;
|
|
44
|
+
/**
|
|
45
|
+
* The most places a worked-out figure is said with — an average, a computed number — whose value carries more
|
|
46
|
+
* than anyone reads (an average of 3, 3 and 4 is 3.333…). Said only: the value read, filtered and sorted is whole.
|
|
47
|
+
*/
|
|
48
|
+
places?: number;
|
|
44
49
|
/** Public presence hint when a private schema projection omits the SQL default. */
|
|
45
50
|
hasDefault?: boolean;
|
|
46
51
|
/** Catalog-confirmed automatic identity assignment; absent is not a type-based guess. */
|
|
@@ -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[]>;
|
|
@@ -718,7 +720,9 @@ export declare function navViewKeys(nav: readonly ServedNavNode[]): string[];
|
|
|
718
720
|
* Every view key in the order rooms are listed: the menu's, then the views
|
|
719
721
|
* nav does not reference (a home nav does not list, and a list view only a
|
|
720
722
|
* dashboard embeds). Never the keys'
|
|
721
|
-
* own order — an object puts a key like "2024" before every other.
|
|
723
|
+
* own order — an object puts a key like "2024" before every other. Each key
|
|
724
|
+
* once: a view or page standing in two workspaces is one room, and listed
|
|
725
|
+
* twice it would claim its own address a second time (appAddress.ts).
|
|
722
726
|
*/
|
|
723
727
|
export declare function viewOrder(app: {
|
|
724
728
|
views: Readonly<Record<string, unknown>>;
|
package/dist/shared/servedApp.js
CHANGED
|
@@ -36,10 +36,12 @@ export function navViewKeys(nav) {
|
|
|
36
36
|
* Every view key in the order rooms are listed: the menu's, then the views
|
|
37
37
|
* nav does not reference (a home nav does not list, and a list view only a
|
|
38
38
|
* dashboard embeds). Never the keys'
|
|
39
|
-
* own order — an object puts a key like "2024" before every other.
|
|
39
|
+
* own order — an object puts a key like "2024" before every other. Each key
|
|
40
|
+
* once: a view or page standing in two workspaces is one room, and listed
|
|
41
|
+
* twice it would claim its own address a second time (appAddress.ts).
|
|
40
42
|
*/
|
|
41
43
|
export function viewOrder(app) {
|
|
42
|
-
const keys = navViewKeys(app.nav).filter((key) => Object.hasOwn(app.views, key));
|
|
44
|
+
const keys = [...new Set(navViewKeys(app.nav))].filter((key) => Object.hasOwn(app.views, key));
|
|
43
45
|
return [...keys, ...Object.keys(app.views).filter((key) => !keys.includes(key))];
|
|
44
46
|
}
|
|
45
47
|
/** The assistant's own room, where its App gives it a page (`placement: 'page'`, appAssistant.ts): its word in
|
package/dist/shared/theme.js
CHANGED
|
@@ -420,7 +420,8 @@ const CONTRAST_PAIRS = [
|
|
|
420
420
|
['inkSubtle', 'ground', 4.5, 'a faint caption on the page'],
|
|
421
421
|
['link', 'ground', 4.5],
|
|
422
422
|
['link', 'raised', 4.5],
|
|
423
|
-
|
|
423
|
+
// The same accent underlines the current workspace and room on the bar (visualThemes.css), so one pair measures both.
|
|
424
|
+
['navAccent', 'navGround', 4.5, "the menu's current entry and the underline marking the current workspace"],
|
|
424
425
|
/* The accent is a fill, and is read as text in its ink (`accentInk`, the accent itself where a theme names none and
|
|
425
426
|
it reads); the words drawn on a fill are `onAccent`. A bright brand accent can be a good fill and a poor text. */
|
|
426
427
|
['accentInk', 'surface', 4.5],
|
|
@@ -430,8 +431,8 @@ const CONTRAST_PAIRS = [
|
|
|
430
431
|
['onAccent', 'accent', 4.5, 'the words on an accent fill'],
|
|
431
432
|
['onPrimary', 'primary', 4.5, "the words on a form's primary action"],
|
|
432
433
|
['link', 'surface', 4.5],
|
|
433
|
-
['navInk', 'navGround', 4.5, "the menu's entries"],
|
|
434
|
-
['navMuted', 'navGround', 4.5, "the menu's group headings, counts and icons"],
|
|
434
|
+
['navInk', 'navGround', 4.5, "the menu's entries and the current workspace"],
|
|
435
|
+
['navMuted', 'navGround', 4.5, "the menu's group headings, counts and icons, and the other workspaces"],
|
|
435
436
|
...['statusGood', 'statusWarning', 'statusCritical', 'statusInfo'].flatMap((role) => [
|
|
436
437
|
[role, 'surface', 4.5],
|
|
437
438
|
[role, 'ground', 4.5],
|
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.47",
|
|
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": {
|