@mistriwork/engine 1.0.0-rc.42 → 1.0.0-rc.44
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/scoped/scopedReads.d.ts +7 -2
- package/dist/adapters/scoped/scopedReads.js +12 -6
- package/dist/adapters/scoped/scopedTransaction.js +4 -2
- package/dist/server/clientSurface.d.ts +5 -5
- package/dist/server/clientSurface.js +28 -19
- package/dist/server/http/refusalReport.d.ts +2 -0
- package/dist/server/http/refusalReport.js +9 -2
- package/dist/shared/appComponents.d.ts +12 -3
- package/dist/shared/appComponents.js +31 -5
- package/dist/shared/appDocuments.d.ts +4 -3
- package/dist/shared/appDocuments.js +10 -5
- package/dist/shared/formValues.d.ts +5 -0
- package/dist/shared/formValues.js +16 -0
- package/dist/shared/page.js +9 -3
- package/dist/shared/pageConfig.js +9 -22
- package/dist/shared/renamedSectionWords.d.ts +21 -0
- package/dist/shared/renamedSectionWords.js +48 -0
- package/dist/shared/servedApp.d.ts +1 -0
- package/dist/shared/themeFaces.d.ts +7 -1
- package/dist/shared/themeFaces.js +16 -1
- package/dist/shared/themeLooks.d.ts +8 -0
- package/dist/shared/themeLooks.js +5 -5
- package/dist/shared/themeRecipes.js +16 -0
- package/package.json +2 -1
- package/schema/model.d.ts +4 -4
|
@@ -3,8 +3,13 @@ import { type DatabaseSchema } from '../../shared/schema.js';
|
|
|
3
3
|
import { type RowScope } from '../../shared/rowScope.js';
|
|
4
4
|
/** Structured read arguments must not retain mutable values across driver
|
|
5
5
|
* waits. This is deliberately separate from stricter nonempty policy filters:
|
|
6
|
-
* an empty user filter is fine, because it never replaces the bound policy.
|
|
7
|
-
|
|
6
|
+
* an empty user filter is fine, because it never replaces the bound policy.
|
|
7
|
+
* A caller whose input has a larger bound of its own (the command journal's
|
|
8
|
+
* receipt) names it, and the refusal past it, in `limits`. */
|
|
9
|
+
export declare function snapshotScopedData<T>(input: T, limits?: {
|
|
10
|
+
readonly characters: number;
|
|
11
|
+
readonly overflow: string;
|
|
12
|
+
}): T;
|
|
8
13
|
/** Dialect-independent policy binding. The driver only executes compiler output
|
|
9
14
|
* on its existing read handle; consumers never receive that execute function.
|
|
10
15
|
* Snapshot the trusted catalog too, so a later refresh cannot change the
|
|
@@ -12,14 +12,20 @@ import { RequestFault } from '../../shared/refusal.js';
|
|
|
12
12
|
import { storedTextOf, storedTextSelect } from './storedText.js';
|
|
13
13
|
/** Structured read arguments must not retain mutable values across driver
|
|
14
14
|
* waits. This is deliberately separate from stricter nonempty policy filters:
|
|
15
|
-
* an empty user filter is fine, because it never replaces the bound policy.
|
|
16
|
-
|
|
15
|
+
* an empty user filter is fine, because it never replaces the bound policy.
|
|
16
|
+
* A caller whose input has a larger bound of its own (the command journal's
|
|
17
|
+
* receipt) names it, and the refusal past it, in `limits`. */
|
|
18
|
+
export function snapshotScopedData(input, limits) {
|
|
17
19
|
let nodes = 0;
|
|
18
20
|
let characters = 0;
|
|
19
21
|
let bytes = 0;
|
|
22
|
+
const most = limits?.characters ?? 1_048_576;
|
|
20
23
|
const fail = () => {
|
|
21
24
|
throw new Refusal('Invalid structured operation.');
|
|
22
25
|
};
|
|
26
|
+
const tooLong = () => {
|
|
27
|
+
throw new Refusal(limits?.overflow ?? 'Invalid structured operation.');
|
|
28
|
+
};
|
|
23
29
|
const copy = (value, depth = 0) => {
|
|
24
30
|
if (++nodes > 32_768 || depth > 16)
|
|
25
31
|
return fail();
|
|
@@ -27,8 +33,8 @@ export function snapshotScopedData(input) {
|
|
|
27
33
|
return value;
|
|
28
34
|
if (typeof value === 'string') {
|
|
29
35
|
characters += value.length;
|
|
30
|
-
if (characters >
|
|
31
|
-
return
|
|
36
|
+
if (characters > most)
|
|
37
|
+
return tooLong();
|
|
32
38
|
return value;
|
|
33
39
|
}
|
|
34
40
|
if (typeof value === 'number' && Number.isFinite(value))
|
|
@@ -68,8 +74,8 @@ export function snapshotScopedData(input) {
|
|
|
68
74
|
if (typeof key !== 'string' || !descriptor.enumerable || !('value' in descriptor))
|
|
69
75
|
return fail();
|
|
70
76
|
characters += key.length;
|
|
71
|
-
if (characters >
|
|
72
|
-
return
|
|
77
|
+
if (characters > most)
|
|
78
|
+
return tooLong();
|
|
73
79
|
result[key] = copy(descriptor.value, depth + 1);
|
|
74
80
|
}
|
|
75
81
|
return result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Refusal } from '../adapter.js';
|
|
2
2
|
import { buildWhere } from '../../shared/filter.js';
|
|
3
|
-
import { recordRefusalCause } from '../../shared/refusal.js';
|
|
3
|
+
import { authorFault, recordRefusalCause } from '../../shared/refusal.js';
|
|
4
4
|
import { coerceForColumn, columnKind } from '../../shared/schema.js';
|
|
5
5
|
import { blockingTriggers, firedBy, sayRuns, sayTriggers, sayWrite } from './scopeTriggers.js';
|
|
6
6
|
import { detachStoredText, overlaid, storedText, storedTextOf } from './storedText.js';
|
|
@@ -215,8 +215,10 @@ referencesOf) {
|
|
|
215
215
|
const blocking = blockingTriggers(triggers, write, foldCase)
|
|
216
216
|
.filter((trigger) => !proof?.accepts(id, trigger))
|
|
217
217
|
.map((trigger) => ({ ...trigger, why: proof?.unaccepted(id, trigger) ?? trigger.why }));
|
|
218
|
+
/* The schema's choice, not the person's: the operator's terminal leads with the trigger's name rather than a
|
|
219
|
+
`because:` beneath an opaque line (a field report). The caller's sentence stays value-free. */
|
|
218
220
|
if (blocking.length)
|
|
219
|
-
|
|
221
|
+
throw authorFault(new ScopeRefusal('This operation is not available in the current row scope.'), `"${id}" cannot be written under a row policy: ${sayWrite(write)} ${sayRuns(blocking)} ${sayTriggers(blocking)}, whose effects the policy cannot bound. ` +
|
|
220
222
|
`A trigger that only checks NEW and OLD and raises does not block a write; mistri check names each command one blocks.`);
|
|
221
223
|
if (firedBy(triggers, write, foldCase).length)
|
|
222
224
|
locks?.relied?.(table);
|
|
@@ -47,7 +47,7 @@ export declare function surfaceFor(pathname: string): Exclude<ClientSurface, 'wo
|
|
|
47
47
|
* that, and the guess costs one sheet fetched and not used. It stays out of
|
|
48
48
|
* the first-paint bundle — a preload is a request, not bytes in the entry.
|
|
49
49
|
*/
|
|
50
|
-
export declare function lookSheetsFor(ui: LookChoice | undefined, audience?: Audience): readonly string[];
|
|
50
|
+
export declare function lookSheetsFor(ui: LookChoice | undefined, audience?: Audience, branded?: ThemeDefinition): readonly string[];
|
|
51
51
|
/**
|
|
52
52
|
* The density the App's look starts at, so the page zooms to it before its
|
|
53
53
|
* first paint (client density.js). Guessed like the sheets: a reader who
|
|
@@ -83,13 +83,13 @@ export interface Audience {
|
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* The sheets whose face the App's look is set in, so its page can ask for
|
|
86
|
-
* the face beside the sheet. A
|
|
87
|
-
* Sage that borrows one of Lumen's wears Lumen's sheet
|
|
86
|
+
* the face beside the sheet. A face is a sheet of its own (interFace.css, barlowFace.css), worn where a stack
|
|
87
|
+
* names it, so a theme on Sage that borrows one of Lumen's recipes wears Lumen's sheet and not Inter's:
|
|
88
88
|
* the face is preloaded only where the interface or its headings begin with it
|
|
89
89
|
* (and, for a sheet whose face is the data's own, as Ledger's monospace figures are, where the data does), never
|
|
90
90
|
* fetched for a page that would not draw a line in it.
|
|
91
91
|
*/
|
|
92
|
-
export declare function lookFacesFor(ui: LookChoice | undefined, audience?: Audience): readonly string[];
|
|
92
|
+
export declare function lookFacesFor(ui: LookChoice | undefined, audience?: Audience, branded?: ThemeDefinition): readonly string[];
|
|
93
93
|
/**
|
|
94
94
|
* The App's own faces in its page's head (`type.faces`, server/app/appFonts.ts):
|
|
95
95
|
* their `@font-face` rules, so a line is drawn in its face as soon as the face
|
|
@@ -102,7 +102,7 @@ export declare function lookFacesFor(ui: LookChoice | undefined, audience?: Audi
|
|
|
102
102
|
* stands outside the first-paint budgets (scripts/bundle-budget.mjs). `shown`
|
|
103
103
|
* says an inside address the way the browser asks for it (shared/mount.ts).
|
|
104
104
|
*/
|
|
105
|
-
export declare function appFaceHead(ui: LookChoice | undefined, shown: (href: string) => string, audience?: Audience): string;
|
|
105
|
+
export declare function appFaceHead(ui: LookChoice | undefined, shown: (href: string) => string, audience?: Audience, branded?: ThemeDefinition): string;
|
|
106
106
|
/**
|
|
107
107
|
* The chrome's words for a reader who does not read English, preloaded beside
|
|
108
108
|
* the entry: the client asks for them before it draws its first words
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { recipeAttributes } from '../shared/themeRecipes.js';
|
|
2
2
|
import { effectiveThemeDefinition, themePreset } from '../shared/themePresets.js';
|
|
3
3
|
import { resolveTheme } from '../shared/themeResolve.js';
|
|
4
|
-
import { faceRules, headingFace } from '../shared/themeFaces.js';
|
|
4
|
+
import { faceRules, headingFace, uiFace } from '../shared/themeFaces.js';
|
|
5
5
|
/** The page the build writes for each surface, under dist/client. */
|
|
6
6
|
export const SURFACE_PAGES = {
|
|
7
7
|
shell: 'index.html',
|
|
@@ -22,9 +22,9 @@ export function surfaceFor(pathname) {
|
|
|
22
22
|
* that, and the guess costs one sheet fetched and not used. It stays out of
|
|
23
23
|
* the first-paint bundle — a preload is a request, not bytes in the entry.
|
|
24
24
|
*/
|
|
25
|
-
export function lookSheetsFor(ui, audience) {
|
|
25
|
+
export function lookSheetsFor(ui, audience, branded) {
|
|
26
26
|
const theme = wornTheme(ui, audience);
|
|
27
|
-
return theme ? recipeAttributes(theme).sheets : [];
|
|
27
|
+
return [...new Set([...(theme ? recipeAttributes(theme).sheets : []), ...(branded ? recipeAttributes(branded).sheets : [])])];
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* The density the App's look starts at, so the page zooms to it before its
|
|
@@ -67,24 +67,27 @@ function wornTheme(ui, audience = {}) {
|
|
|
67
67
|
const { id } = resolveTheme({ ...audience, for: ui.theme?.for, preset: ui.theme?.preset, offered });
|
|
68
68
|
return ui.customThemes?.find((item) => item.id === id) ?? themePreset(id) ?? themePreset('workshop');
|
|
69
69
|
}
|
|
70
|
-
/** The faces each
|
|
71
|
-
|
|
72
|
-
its semibold comes when a line asks for it. */
|
|
70
|
+
/** The faces each sheet declares, by the families a stack begins with to be set in them (interFace.css, barlowFace.css,
|
|
71
|
+
ledgerLook.css), and the files preloaded: Barlow's regular and its condensed bold, which every Workshop page
|
|
72
|
+
draws; its semibold comes when a line asks for it. */
|
|
73
73
|
const SHEET_FACES = {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
barlow: { families: ['Barlow', 'Barlow Semi Condensed'], file: /^assets\/barlow-(?:400|semi-condensed-700)-[\w-]+\.woff2$/ },
|
|
75
|
+
inter: { families: ['Inter'], file: /^assets\/inter-latin-[\w-]+\.woff2$/ },
|
|
76
76
|
ledger: { families: ['IBM Plex Mono'], data: true, file: /^assets\/ibm-plex-mono-400-[\w-]+\.woff2$/ },
|
|
77
77
|
};
|
|
78
78
|
/**
|
|
79
79
|
* The sheets whose face the App's look is set in, so its page can ask for
|
|
80
|
-
* the face beside the sheet. A
|
|
81
|
-
* Sage that borrows one of Lumen's wears Lumen's sheet
|
|
80
|
+
* the face beside the sheet. A face is a sheet of its own (interFace.css, barlowFace.css), worn where a stack
|
|
81
|
+
* names it, so a theme on Sage that borrows one of Lumen's recipes wears Lumen's sheet and not Inter's:
|
|
82
82
|
* the face is preloaded only where the interface or its headings begin with it
|
|
83
83
|
* (and, for a sheet whose face is the data's own, as Ledger's monospace figures are, where the data does), never
|
|
84
84
|
* fetched for a page that would not draw a line in it.
|
|
85
85
|
*/
|
|
86
|
-
export function lookFacesFor(ui, audience) {
|
|
87
|
-
|
|
86
|
+
export function lookFacesFor(ui, audience, branded) {
|
|
87
|
+
/* The branded theme a request wears (a tenant's, with the face it picked) as well as the App's own guess. */
|
|
88
|
+
return [...new Set([...kitFaces(wornTheme(ui, audience)), ...kitFaces(branded)])];
|
|
89
|
+
}
|
|
90
|
+
function kitFaces(theme) {
|
|
88
91
|
if (!theme)
|
|
89
92
|
return [];
|
|
90
93
|
const first = (stack) => stack
|
|
@@ -107,19 +110,25 @@ export function lookFacesFor(ui, audience) {
|
|
|
107
110
|
* stands outside the first-paint budgets (scripts/bundle-budget.mjs). `shown`
|
|
108
111
|
* says an inside address the way the browser asks for it (shared/mount.ts).
|
|
109
112
|
*/
|
|
110
|
-
export function appFaceHead(ui, shown, audience) {
|
|
111
|
-
|
|
113
|
+
export function appFaceHead(ui, shown, audience, branded) {
|
|
114
|
+
/* A request's branded theme that ships faces is the one the client will wear (visualTheme.ts wearFaces replaces the
|
|
115
|
+
first paint's rules with its own), so it is the one declared here; a tenant's pick of a face (`font`) is the
|
|
116
|
+
interface's, drawn on every line, so that face is preloaded as the heading's is. */
|
|
117
|
+
const picked = Boolean(branded?.faces?.length);
|
|
118
|
+
const theme = picked ? branded : wornTheme(ui, audience);
|
|
112
119
|
const rules = faceRules(theme, shown);
|
|
113
120
|
if (!rules)
|
|
114
121
|
return '';
|
|
122
|
+
const preload = (face) => face?.href
|
|
123
|
+
? ` <link rel="preload" as="font" type="${face.href.endsWith('.woff') ? 'font/woff' : 'font/woff2'}" crossorigin href="${shown(face.href)}">\n`
|
|
124
|
+
: '';
|
|
115
125
|
const heading = theme && headingFace(theme);
|
|
116
|
-
const
|
|
126
|
+
const body = picked && theme ? uiFace(theme) : undefined;
|
|
117
127
|
return (
|
|
118
128
|
/* A face is fetched in CORS mode, so its preload says `crossorigin`, or it is fetched twice (lookPreloads). */
|
|
119
|
-
(heading
|
|
120
|
-
` <style id="mistri-theme-faces">${rules}</style>\n`);
|
|
129
|
+
preload(heading) + (body && body !== heading ? preload(body) : '') + ` <style id="mistri-theme-faces">${rules}</style>\n`);
|
|
121
130
|
}
|
|
122
|
-
/** A built look sheet's file, `assets/lumenLook-<hash>.css`, by the sheet's name. */
|
|
131
|
+
/** A built look sheet's file, `assets/lumenLook-<hash>.css`, or a face's, `assets/interFace-<hash>.css`, by the sheet's name. */
|
|
123
132
|
/** The chrome's words in one language (vite.config.ts LOCALE_GROUP): `assets/copy.es-<hash>.js`. */
|
|
124
133
|
const WORDS_FILE = /^assets\/copy\.([a-z]{2,3})-[\w-]+\.js$/;
|
|
125
134
|
/**
|
|
@@ -157,7 +166,7 @@ export function tenantPreloads(files) {
|
|
|
157
166
|
}
|
|
158
167
|
return links;
|
|
159
168
|
}
|
|
160
|
-
const LOOK_FILE = /^assets\/([a-z]+)Look-[\w-]+\.css$/;
|
|
169
|
+
const LOOK_FILE = /^assets\/([a-z]+)(?:Look|Face)-[\w-]+\.css$/;
|
|
161
170
|
/**
|
|
162
171
|
* The preload links for the look sheets a page will wear, and the faces they
|
|
163
172
|
* declare, from the files the build wrote (none under the dev server). A face
|
|
@@ -29,6 +29,8 @@ export declare function noteAuthorRequest(req: IncomingMessage, bound: Bound, ad
|
|
|
29
29
|
path: string;
|
|
30
30
|
build?: unknown;
|
|
31
31
|
}>): void;
|
|
32
|
+
/** A text with every link token and link session cut down to its id. */
|
|
33
|
+
export declare const redactLinkTokens: (text: string) => string;
|
|
32
34
|
/**
|
|
33
35
|
* Say a refused request to the operator, and return the sentence its author
|
|
34
36
|
* may read, if this request is the author's. Quiet for an ordinary refusal
|
|
@@ -26,11 +26,18 @@ export function noteAuthorRequest(req, bound, administrator, apps) {
|
|
|
26
26
|
!bound.trustedProxies?.length)
|
|
27
27
|
authors.add(req);
|
|
28
28
|
}
|
|
29
|
+
/* A capability link's token (`mstl1.<id>.<mac>`, mistri's links/linkToken.ts) is a bearer credential in a path: a log
|
|
30
|
+
keeps the id, which names the stored row an operator can look up and revoke, and never the MAC that opens it. */
|
|
31
|
+
const LINK_TOKEN = /\b(mstls?1\.[A-Za-z0-9_-]{22})\.[A-Za-z0-9_.-]+/g;
|
|
32
|
+
const LINK_TOKEN_REDACTED = '[redacted]';
|
|
33
|
+
/** A text with every link token and link session cut down to its id. */
|
|
34
|
+
export const redactLinkTokens = (text) => text.includes('mstl') ? text.replace(LINK_TOKEN, `$1.${LINK_TOKEN_REDACTED}`) : text;
|
|
29
35
|
/** What the operator is told: the error's own words when it is no refusal at
|
|
30
36
|
all (a driver's, a bug), then each reason recorded beneath it. */
|
|
31
37
|
function reasonsFor(error, heard) {
|
|
32
38
|
const own = error instanceof Error && error.message && error.message !== heard ? [error.message] : [];
|
|
33
|
-
|
|
39
|
+
/* A reason can quote a request's path or a stored value that carries a link token: every sink here is a log. */
|
|
40
|
+
return [...new Set([...own, ...recorded(error)].map(redactLinkTokens))].filter((reason) => reason !== heard && !OPAQUE.has(reason));
|
|
34
41
|
}
|
|
35
42
|
const recorded = (error) => refusalReasons(error).filter((reason) => !OPAQUE.has(reason));
|
|
36
43
|
/**
|
|
@@ -54,7 +61,7 @@ export function reportRefusal(req, status, code, heard, error, always = false) {
|
|
|
54
61
|
what its author meant it to allow is found here, not first with diagnostics on (field report TR7). */
|
|
55
62
|
if (status < 500 && !recorded(error).length && !refusalSaid(error) && !always)
|
|
56
63
|
return undefined;
|
|
57
|
-
const path = (req.url ?? '').split('?')[0];
|
|
64
|
+
const path = redactLinkTokens((req.url ?? '').split('?')[0]);
|
|
58
65
|
const refused = `${product()}: ${req.method ?? 'GET'} ${path} refused (${status}${code ? ` ${code}` : ''})`;
|
|
59
66
|
/* The author's own mistake leads with what to fix; the sentence its caller was told follows, as what it was. */
|
|
60
67
|
const fault = isAuthorFault(error) ? reasons.at(-1) : undefined;
|
|
@@ -43,7 +43,10 @@ export declare const MAX_CUSTOM_FIGURES = 8;
|
|
|
43
43
|
/** The keys a declared read of rows takes, on a page and on a dashboard. */
|
|
44
44
|
export declare const PAGE_READ_KEYS: readonly ['from', 'whose', 'query', 'show', 'sort', 'limit'];
|
|
45
45
|
export declare const DASH_READ_KEYS: readonly ['from', 'query', 'show', 'sort', 'limit', 'over'];
|
|
46
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* What a total measures: the breakdown grammar's aggregates over one column of the resource (count takes none, and
|
|
48
|
+
* `count distinct` takes the column whose different values it counts: "N across M people").
|
|
49
|
+
*/
|
|
47
50
|
declare const TOTAL_FUNCTIONS: readonly ['count', 'sum', 'avg', 'min', 'max'];
|
|
48
51
|
type TotalFunction = (typeof TOTAL_FUNCTIONS)[number];
|
|
49
52
|
/** Whether a value is a component declaration: what a display rule or a section names in place of its own words. */
|
|
@@ -93,8 +96,10 @@ export declare function parseDashReads(raw: unknown, at: string): Record<string,
|
|
|
93
96
|
export interface PageCustomTotal {
|
|
94
97
|
from: string;
|
|
95
98
|
fn: TotalFunction;
|
|
96
|
-
/** The column measured; absent for a count. */
|
|
99
|
+
/** The column measured; absent for a count of rows. */
|
|
97
100
|
column?: string;
|
|
101
|
+
/** A count of the column's different values (`count distinct patient_id`), not of rows. */
|
|
102
|
+
distinct?: true;
|
|
98
103
|
/** What the figure is grouped by, in the breakdown grammar ("status", "month opened_on"); absent, one figure. */
|
|
99
104
|
by?: string;
|
|
100
105
|
/** Config `whose`: the path from `from` back to the page's record. Absent, the resource's own rows. */
|
|
@@ -114,6 +119,8 @@ export interface DashCustomTotal {
|
|
|
114
119
|
/** Served, never authored: the query without its own window, as a rows section's. */
|
|
115
120
|
windowBase?: string;
|
|
116
121
|
}
|
|
122
|
+
/** A page figure's measure as it is written: "count", "count distinct patient_id", "sum amount". */
|
|
123
|
+
export declare function totalMeasureText(total: Pick<PageCustomTotal, 'fn' | 'column' | 'distinct'>): string;
|
|
117
124
|
export declare function parsePageTotals(raw: unknown, at: string): Record<string, PageCustomTotal> | undefined;
|
|
118
125
|
export declare function parseDashTotals(raw: unknown, at: string): Record<string, DashCustomTotal> | undefined;
|
|
119
126
|
/** How many groups a total with a `by` returns when it says no limit. */
|
|
@@ -146,8 +153,10 @@ interface PageDecl {
|
|
|
146
153
|
actions: string[];
|
|
147
154
|
/** The address parameters the page keeps its place in: `/{app}/pick-walk?list=12`. */
|
|
148
155
|
params: string[];
|
|
149
|
-
/** The loader that reads for it on the server, by its name in the commands module (`defineLoaders`)
|
|
156
|
+
/** The loader that reads for it on the server, by its name in the commands module (`defineLoaders`); its result is the page's `data`. */
|
|
150
157
|
loader?: string;
|
|
158
|
+
/** More loaders the page runs by name (`useLoader`), each with a cache entry and a loading state of its own. */
|
|
159
|
+
loaders?: string[];
|
|
151
160
|
props: Record<string, unknown>;
|
|
152
161
|
}
|
|
153
162
|
/**
|
|
@@ -51,9 +51,12 @@ export const DASH_READ_KEYS = ['from', 'query', 'show', 'sort', 'limit', 'over']
|
|
|
51
51
|
/** The keys a declared aggregate read takes, on a page and on a dashboard. */
|
|
52
52
|
const PAGE_TOTAL_KEYS = ['from', 'measure', 'by', 'whose', 'query', 'limit'];
|
|
53
53
|
const DASH_TOTAL_KEYS = ['from', 'measure', 'by', 'query', 'over', 'limit'];
|
|
54
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* What a total measures: the breakdown grammar's aggregates over one column of the resource (count takes none, and
|
|
56
|
+
* `count distinct` takes the column whose different values it counts: "N across M people").
|
|
57
|
+
*/
|
|
55
58
|
const TOTAL_FUNCTIONS = ['count', 'sum', 'avg', 'min', 'max'];
|
|
56
|
-
const TOTAL_MEASURE = /^(count|(?:sum|avg|min|max)
|
|
59
|
+
const TOTAL_MEASURE = /^(count|count distinct [A-Za-z_][A-Za-z0-9_]*|(?:sum|avg|min|max) [A-Za-z_][A-Za-z0-9_]*)$/;
|
|
57
60
|
/** The most groups one total returns, and what it returns when it says none. */
|
|
58
61
|
const MAX_TOTAL_GROUPS = 500;
|
|
59
62
|
const DEFAULT_TOTAL_GROUPS = 100;
|
|
@@ -272,7 +275,7 @@ function totalShape(raw, at, keys) {
|
|
|
272
275
|
if (typeof raw.from !== 'string' || !raw.from.trim())
|
|
273
276
|
throw new Error(`${at} has no "from": the resource it measures.`);
|
|
274
277
|
if (typeof raw.measure !== 'string' || !TOTAL_MEASURE.test(raw.measure.trim().replace(/\s+/g, ' '))) {
|
|
275
|
-
throw new Error(`${at} has no "measure": "count", or ${TOTAL_FUNCTIONS.slice(1).join(', ')} and a column — 'sum amount'.`);
|
|
278
|
+
throw new Error(`${at} has no "measure": "count", "count distinct" and a column, or ${TOTAL_FUNCTIONS.slice(1).join(', ')} and a column — 'sum amount'.`);
|
|
276
279
|
}
|
|
277
280
|
for (const key of ['by', 'query', 'whose', 'over']) {
|
|
278
281
|
if (raw[key] !== undefined && (typeof raw[key] !== 'string' || !raw[key].trim()))
|
|
@@ -287,14 +290,24 @@ function totalShape(raw, at, keys) {
|
|
|
287
290
|
return { ...raw, measure: raw.measure.trim().replace(/\s+/g, ' ') };
|
|
288
291
|
}
|
|
289
292
|
const totalReads = { key: 'figures', most: MAX_CUSTOM_FIGURES, noun: 'figures' };
|
|
293
|
+
/** A page figure's measure as it is written: "count", "count distinct patient_id", "sum amount". */
|
|
294
|
+
export function totalMeasureText(total) {
|
|
295
|
+
if (total.column === undefined)
|
|
296
|
+
return total.fn;
|
|
297
|
+
return total.distinct ? `${total.fn} distinct ${total.column}` : `${total.fn} ${total.column}`;
|
|
298
|
+
}
|
|
290
299
|
export function parsePageTotals(raw, at) {
|
|
291
300
|
return reads(raw, at, (entry, here) => {
|
|
292
301
|
const r = totalShape(entry, here, PAGE_TOTAL_KEYS);
|
|
293
|
-
const
|
|
302
|
+
const words = r.measure.split(' ');
|
|
303
|
+
const distinct = words[1] === 'distinct';
|
|
304
|
+
const fn = words[0];
|
|
305
|
+
const column = distinct ? words[2] : words[1];
|
|
294
306
|
return {
|
|
295
307
|
from: r.from.trim(),
|
|
296
308
|
fn,
|
|
297
309
|
...(column === undefined ? {} : { column }),
|
|
310
|
+
...(distinct ? { distinct: true } : {}),
|
|
298
311
|
...(r.by === undefined ? {} : { by: r.by.trim() }),
|
|
299
312
|
...(r.whose === undefined ? {} : { path: r.whose.trim() }),
|
|
300
313
|
...(r.query === undefined ? {} : { filter: r.query.trim() }),
|
|
@@ -348,8 +361,9 @@ export function parseCustomList(raw, at) {
|
|
|
348
361
|
throw new Error(`${at} names one column twice in "show".`);
|
|
349
362
|
return { kind: 'custom', component, show: columns, props: componentPropValues(component, raw.props, at) };
|
|
350
363
|
}
|
|
351
|
-
/** The most address parameters one page keeps. */
|
|
364
|
+
/** The most address parameters one page keeps, and the most loaders it names. */
|
|
352
365
|
const MAX_PAGE_PARAMS = 8;
|
|
366
|
+
const MAX_PAGE_LOADERS = 8;
|
|
353
367
|
const PARAM = /^[a-z][a-z0-9_]{0,31}$/;
|
|
354
368
|
const LOADER = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
355
369
|
/* A parameter's kind is how the page reads its text back (sdk/page.tsx): the address always holds text. */
|
|
@@ -405,6 +419,17 @@ export function parsePage(raw, at) {
|
|
|
405
419
|
if (raw.loader !== undefined && (typeof raw.loader !== 'string' || !LOADER.test(raw.loader))) {
|
|
406
420
|
throw new Error(`[page-loader] ${at} has a "loader" that is not a loader's name, as the commands module's defineLoaders() registers it.`);
|
|
407
421
|
}
|
|
422
|
+
if (raw.loaders !== undefined) {
|
|
423
|
+
const named = raw.loaders;
|
|
424
|
+
if (!Array.isArray(named) ||
|
|
425
|
+
!named.length ||
|
|
426
|
+
named.length > MAX_PAGE_LOADERS ||
|
|
427
|
+
named.some((name) => typeof name !== 'string' || !LOADER.test(name))) {
|
|
428
|
+
throw new Error(`[page-loader] ${at} has "loaders" that are not up to ${MAX_PAGE_LOADERS} loader names, as the commands module's defineLoaders() registers them: loaders: ['board', 'dueFigure'].`);
|
|
429
|
+
}
|
|
430
|
+
if (new Set(named).size !== named.length || (raw.loader !== undefined && named.includes(raw.loader)))
|
|
431
|
+
throw new Error(`[page-loader] ${at} names a loader twice: "loader" and "loaders" together name each loader once.`);
|
|
432
|
+
}
|
|
408
433
|
return {
|
|
409
434
|
component,
|
|
410
435
|
reads: [...new Set(reads.map((name) => name.trim()))],
|
|
@@ -412,6 +437,7 @@ export function parsePage(raw, at) {
|
|
|
412
437
|
actions: [...new Set(actions.map((name) => name.trim()))],
|
|
413
438
|
params: [...new Set(params)],
|
|
414
439
|
...(raw.loader === undefined ? {} : { loader: raw.loader }),
|
|
440
|
+
...(raw.loaders === undefined ? {} : { loaders: [...raw.loaders] }),
|
|
415
441
|
props: componentPropValues(component, raw.props, at),
|
|
416
442
|
};
|
|
417
443
|
}
|
|
@@ -20,9 +20,10 @@ export declare function parseDocument(raw: unknown, at: string): PageDocument;
|
|
|
20
20
|
/**
|
|
21
21
|
* What a document's sections may be, refused section by section: paper has no
|
|
22
22
|
* aside, no tabs and nothing to operate, and a list on it is every line — a
|
|
23
|
-
* table whose header repeats on each sheet —
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* table whose header repeats on each sheet — or, over a file resource, its
|
|
24
|
+
* pictures (a gallery, drawn as a grid, with no lightbox to open), never
|
|
25
|
+
* cards or a page of rows. Its lists read every line, up to DOCUMENT_LINES
|
|
26
|
+
* (DOCUMENT_PICTURES for pictures), unless the author says fewer.
|
|
26
27
|
*/
|
|
27
28
|
export declare function documentSections(sections: readonly PageSection[], at: string): PageSection[];
|
|
28
29
|
/** The sheet a document is printed on: its own `size`, else the paper the App's (or tenant's) locale buys. */
|
|
@@ -30,6 +30,8 @@ const DOCUMENT_SIZES = ['a4', 'letter'];
|
|
|
30
30
|
const DOCUMENT_SECTION_KINDS = ['fields', 'list', 'note'];
|
|
31
31
|
/** Every line is on paper, up to the most a related list reads at once; a page that would be longer says so. */
|
|
32
32
|
const DOCUMENT_LINES = 500;
|
|
33
|
+
/** A list of pictures is read on the reader's lease one file at a time, and each takes a sheet's room: fewer by default. */
|
|
34
|
+
const DOCUMENT_PICTURES = 24;
|
|
33
35
|
/** A page's document, as one page body states it. */
|
|
34
36
|
export function parseDocument(raw, at) {
|
|
35
37
|
const where = `${at}, "document"`;
|
|
@@ -55,9 +57,10 @@ export function parseDocument(raw, at) {
|
|
|
55
57
|
/**
|
|
56
58
|
* What a document's sections may be, refused section by section: paper has no
|
|
57
59
|
* aside, no tabs and nothing to operate, and a list on it is every line — a
|
|
58
|
-
* table whose header repeats on each sheet —
|
|
59
|
-
*
|
|
60
|
-
*
|
|
60
|
+
* table whose header repeats on each sheet — or, over a file resource, its
|
|
61
|
+
* pictures (a gallery, drawn as a grid, with no lightbox to open), never
|
|
62
|
+
* cards or a page of rows. Its lists read every line, up to DOCUMENT_LINES
|
|
63
|
+
* (DOCUMENT_PICTURES for pictures), unless the author says fewer.
|
|
61
64
|
*/
|
|
62
65
|
export function documentSections(sections, at) {
|
|
63
66
|
return sections.map((section, i) => {
|
|
@@ -74,8 +77,10 @@ export function documentSections(sections, at) {
|
|
|
74
77
|
throw new Error(`${where} has "actions"; paper has nothing to press.`);
|
|
75
78
|
if (section.kind !== 'list')
|
|
76
79
|
return section;
|
|
77
|
-
if (section.presentation !== undefined || section.create || section.rowActions)
|
|
78
|
-
throw new Error(`${where} is a list of the record's lines on paper: no
|
|
80
|
+
if ((section.presentation !== undefined && section.presentation !== 'gallery') || section.create || section.rowActions)
|
|
81
|
+
throw new Error(`${where} is a list of the record's lines on paper: no cards, create or row actions.`);
|
|
82
|
+
if (section.presentation === 'gallery')
|
|
83
|
+
return section.limit === undefined ? { ...section, limit: DOCUMENT_PICTURES } : section;
|
|
79
84
|
return section.limit === undefined ? { ...section, limit: DOCUMENT_LINES } : section;
|
|
80
85
|
});
|
|
81
86
|
}
|
|
@@ -90,6 +90,11 @@ export declare function conditionResult(condition: CompiledCondition, row: Reado
|
|
|
90
90
|
export declare function evaluateFormCondition(condition: FormCondition, row: Readonly<Record<string, unknown>>, columns: readonly ColumnMeta[], paths?: boolean): boolean | 'unknown';
|
|
91
91
|
/** The word a form default fills in for its column — the constants `today`, `now`, `me` — or undefined for a literal. */
|
|
92
92
|
export declare function formDefaultWord(column: ColumnMeta, value: unknown): 'today' | 'now' | 'me' | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* A column DEFAULT that is a plain value — `'booked'`, `'booked'::text`, `0`, `(-1)::integer`, `true` — as the value
|
|
95
|
+
* a form would write; undefined for an expression (a clock, a sequence, a function), which is the database's to fill.
|
|
96
|
+
*/
|
|
97
|
+
export declare function literalDefault(sql: string | undefined): string | undefined;
|
|
93
98
|
/**
|
|
94
99
|
* A New form's starting values the schema already says: a vocabulary column's
|
|
95
100
|
* literal DEFAULT (`status … default 'booked'`) is the choice the form opens
|
|
@@ -313,6 +313,22 @@ export function formDefaultWord(column, value) {
|
|
|
313
313
|
return columnKind(column.type) === 'date' ? value : undefined;
|
|
314
314
|
return value === 'me' && (column.references || columnKind(column.type) === 'text') ? 'me' : undefined;
|
|
315
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* A column DEFAULT that is a plain value — `'booked'`, `'booked'::text`, `0`, `(-1)::integer`, `true` — as the value
|
|
318
|
+
* a form would write; undefined for an expression (a clock, a sequence, a function), which is the database's to fill.
|
|
319
|
+
*/
|
|
320
|
+
export function literalDefault(sql) {
|
|
321
|
+
const text = sql?.trim();
|
|
322
|
+
if (!text)
|
|
323
|
+
return undefined;
|
|
324
|
+
const quoted = /^'((?:[^']|'')*)'(?:::[\w\s."[\](),]+)?$/.exec(text);
|
|
325
|
+
if (quoted)
|
|
326
|
+
return quoted[1].replace(/''/g, "'");
|
|
327
|
+
const number = /^\(?(-?\d+(?:\.\d+)?)\)?(?:::[\w\s."[\](),]+)?$/.exec(text);
|
|
328
|
+
if (number)
|
|
329
|
+
return number[1];
|
|
330
|
+
return /^(?:true|false)$/i.test(text) ? text.toLowerCase() : undefined;
|
|
331
|
+
}
|
|
316
332
|
/**
|
|
317
333
|
* A New form's starting values the schema already says: a vocabulary column's
|
|
318
334
|
* literal DEFAULT (`status … default 'booked'`) is the choice the form opens
|
package/dist/shared/page.js
CHANGED
|
@@ -34,7 +34,7 @@ import { hopName, parseViewQuery, validateView } from './view.js';
|
|
|
34
34
|
import { DATE_UNITS } from './breakdown.js';
|
|
35
35
|
import { authoredSpelling } from './autoValues.js';
|
|
36
36
|
import { createSaysMore, relatedCreatePlan } from './relatedCreate.js';
|
|
37
|
-
import { groupsAsked } from './appComponents.js';
|
|
37
|
+
import { groupsAsked, totalMeasureText } from './appComponents.js';
|
|
38
38
|
import { DEFAULT_PAGE_LIST_LIMIT, timelineMarkColumns, timelineSide, sectionReading, } from './pageModel.js';
|
|
39
39
|
import { resolvePath, pageHop, resolveOf, listView, defaultColumns, similarProblem, groupProblem, groupFactPaths, relatedMatchProblem, customProblem, } from './pagePaths.js';
|
|
40
40
|
export { WIDTHS, OFFSETS, SECTION_REGIONS, FIELD_COLUMNS, timelineMarkColumns, DEFAULT_PAGE_LIST_LIMIT, MAX_PAGE_SECTIONS, } from './pageModel.js';
|
|
@@ -754,7 +754,13 @@ export function customTotalPlan(schema, page, name, total, key, index, now = new
|
|
|
754
754
|
def: {
|
|
755
755
|
base,
|
|
756
756
|
by,
|
|
757
|
-
measures: [
|
|
757
|
+
measures: [
|
|
758
|
+
total.distinct
|
|
759
|
+
? { fn: 'count', path: total.column, distinct: true, alias: 'value' }
|
|
760
|
+
: total.fn === 'count'
|
|
761
|
+
? { fn: 'count', alias: 'value' }
|
|
762
|
+
: { fn: total.fn, path: total.column, alias: 'value' },
|
|
763
|
+
],
|
|
758
764
|
...(filter ? { filter } : {}),
|
|
759
765
|
// Biggest first, like a breakdown on a page: "mostly what?".
|
|
760
766
|
...(by.length ? { orderBy: [{ name: 'value', direction: 'desc' }] } : {}),
|
|
@@ -1065,7 +1071,7 @@ export function sectionConfig(s) {
|
|
|
1065
1071
|
name,
|
|
1066
1072
|
{
|
|
1067
1073
|
from: total.from,
|
|
1068
|
-
measure: (total
|
|
1074
|
+
measure: totalMeasureText(total),
|
|
1069
1075
|
...(total.by ? { by: total.by } : {}),
|
|
1070
1076
|
...(total.path ? { whose: total.path } : {}),
|
|
1071
1077
|
...(total.filter ? { query: total.filter } : {}),
|
|
@@ -13,6 +13,7 @@ import { CARDS_MAX_LINES, HEADER_FACTS_SHOWN, HEADER_MAX_FACTS, parseCards, pars
|
|
|
13
13
|
import { parseIcon } from './appIcons.js';
|
|
14
14
|
import { slug } from './slug.js';
|
|
15
15
|
import { parsePageLayout } from './pageLayouts.js';
|
|
16
|
+
import { CONFIG_PAGE_RENAMED, CUSTOM_SECTION_RENAMED, LINK_INTENT_RENAMED, SECTION_RENAMED, refusedAsNow } from './renamedSectionWords.js';
|
|
16
17
|
import { parseSortText } from './sortText.js';
|
|
17
18
|
import { componentPropValues, parseComponentDecl, parsePageReads, parsePageTotals, parseRecordFields } from './appComponents.js';
|
|
18
19
|
import { parseAppLinkAction, parseAppTarget, parseLinkTo } from './appLinks.js';
|
|
@@ -61,13 +62,10 @@ export function parsePagesConfig(raw, where) {
|
|
|
61
62
|
return page;
|
|
62
63
|
});
|
|
63
64
|
}
|
|
64
|
-
/* Spellings renamed before 1.0, refused with the word that replaced them (allowKeys' `refused`). */
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
const INTENT_RENAMED = { kind: 'is now "intent", as a button says it: "primary" or "secondary"' };
|
|
70
|
-
const PAGE_RENAMED = { onlyOn: 'is now "connection", as the root of the config file says it' };
|
|
65
|
+
/* Spellings renamed before 1.0, refused with the word that replaced them (allowKeys' `refused`): renamedSectionWords.ts. */
|
|
66
|
+
const CUSTOM_RENAMED = refusedAsNow(CUSTOM_SECTION_RENAMED);
|
|
67
|
+
const INTENT_RENAMED = refusedAsNow(LINK_INTENT_RENAMED);
|
|
68
|
+
const PAGE_RENAMED = refusedAsNow(CONFIG_PAGE_RENAMED);
|
|
71
69
|
/** The keys a page takes. A tablewalk.json page also names its `id`; an App page is keyed by it. */
|
|
72
70
|
export const PAGE_KEYS = ['label', 'base', 'connection', 'listTabs', 'empty', 'sections', 'aside', 'layout'];
|
|
73
71
|
/** An App page has no `connection`: the App names its one connection, and a page scoped to another would never show. Nor a `label`: it is called its resource's `noun`. */
|
|
@@ -253,21 +251,10 @@ function parseFlag(raw, at, key) {
|
|
|
253
251
|
return raw || undefined;
|
|
254
252
|
}
|
|
255
253
|
/* The spellings a section may not use any more, each mapped to the word
|
|
256
|
-
that replaced it. Refused by name, in the parser's
|
|
257
|
-
written against the pre-rename format fails with its
|
|
258
|
-
half-working.
|
|
259
|
-
|
|
260
|
-
way `of` only implied, `show` and `sort` are the query
|
|
261
|
-
language's own words. */
|
|
262
|
-
const RENAMED = {
|
|
263
|
-
tint: '"tone", as a display rule says it: { kind: { internal: \'warn\' } } on the timeline, or one tone on a stream',
|
|
264
|
-
order: "\"newest\": 'first' (the default) or 'last', the way a conversation reads",
|
|
265
|
-
edit: '"editable", as a list view says it',
|
|
266
|
-
path: '"whose" — the column on the section\'s table that names this record, e.g. "customer_id" or "invoice_id.customer_id"',
|
|
267
|
-
of: '"about" — the record this section is about, named by a reference column of the base, e.g. "site_id"',
|
|
268
|
-
paths: '"show" — the fields to show, e.g. ["name", "account_id.name"]',
|
|
269
|
-
orderBy: '"sort" — written like the query bar, e.g. "due_on desc, name"',
|
|
270
|
-
};
|
|
254
|
+
that replaced it (renamedSectionWords.ts). Refused by name, in the parser's
|
|
255
|
+
usual voice, so a page written against the pre-rename format fails with its
|
|
256
|
+
fix rather than half-working. */
|
|
257
|
+
const RENAMED = Object.fromEntries(SECTION_RENAMED.map((row) => [row.from, row.now]));
|
|
271
258
|
function refuseRenamed(s, at, keys) {
|
|
272
259
|
for (const key of keys) {
|
|
273
260
|
if (s[key] !== undefined)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words an engine reader (a page's sections, a call to action, a config file's page) refuses as renamed before 1.0, as
|
|
3
|
+
* data in the shape of the App framework's own tables (packages/mistri/src/shared/renamedWords.ts): what each is now
|
|
4
|
+
* (`to`, absent when nothing takes its place under one key), and what follows "which is now" in the refusal. The
|
|
5
|
+
* framework files these under `RENAMED_TABLES`, so `mistri upgrade` answers each and test/upgrade.test.ts holds it.
|
|
6
|
+
*
|
|
7
|
+
* Kept free of imports so the browser and the CLI can both read it.
|
|
8
|
+
*/
|
|
9
|
+
/** A word renamed: what it is now (`to`, absent when it is gone or moved), and the sentence the loader says. */
|
|
10
|
+
export interface RenamedWord {
|
|
11
|
+
from: string;
|
|
12
|
+
to?: string;
|
|
13
|
+
/** What follows "which is now" in the loader's refusal. */
|
|
14
|
+
now: string;
|
|
15
|
+
}
|
|
16
|
+
/** The `{ old: sentence }` form `allowKeys` takes as its `refused`, which says "which <sentence>". */
|
|
17
|
+
export declare function refusedAsNow(rows: readonly RenamedWord[]): Readonly<Record<string, string>>;
|
|
18
|
+
export declare const SECTION_RENAMED: readonly RenamedWord[];
|
|
19
|
+
export declare const CUSTOM_SECTION_RENAMED: readonly RenamedWord[];
|
|
20
|
+
export declare const LINK_INTENT_RENAMED: readonly RenamedWord[];
|
|
21
|
+
export declare const CONFIG_PAGE_RENAMED: readonly RenamedWord[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words an engine reader (a page's sections, a call to action, a config file's page) refuses as renamed before 1.0, as
|
|
3
|
+
* data in the shape of the App framework's own tables (packages/mistri/src/shared/renamedWords.ts): what each is now
|
|
4
|
+
* (`to`, absent when nothing takes its place under one key), and what follows "which is now" in the refusal. The
|
|
5
|
+
* framework files these under `RENAMED_TABLES`, so `mistri upgrade` answers each and test/upgrade.test.ts holds it.
|
|
6
|
+
*
|
|
7
|
+
* Kept free of imports so the browser and the CLI can both read it.
|
|
8
|
+
*/
|
|
9
|
+
/** The `{ old: sentence }` form `allowKeys` takes as its `refused`, which says "which <sentence>". */
|
|
10
|
+
export function refusedAsNow(rows) {
|
|
11
|
+
return Object.fromEntries(rows.map((row) => [row.from, `is now ${row.now}`]));
|
|
12
|
+
}
|
|
13
|
+
/* A page section's keys (pageConfig's `refuseRenamed`). The renames (docs/apps.md, "The respelling"): `whose` says the
|
|
14
|
+
direction `path` hid, `about` moves the subject the way `of` only implied, `show` and `sort` are the query language's
|
|
15
|
+
own words. */
|
|
16
|
+
export const SECTION_RENAMED = [
|
|
17
|
+
{
|
|
18
|
+
from: 'tint',
|
|
19
|
+
to: 'tone',
|
|
20
|
+
now: '"tone", as a display rule says it: { kind: { internal: \'warn\' } } on the timeline, or one tone on a stream',
|
|
21
|
+
},
|
|
22
|
+
{ from: 'order', to: 'newest', now: "\"newest\": 'first' (the default) or 'last', the way a conversation reads" },
|
|
23
|
+
{ from: 'edit', to: 'editable', now: '"editable", as a list view says it' },
|
|
24
|
+
{
|
|
25
|
+
from: 'path',
|
|
26
|
+
to: 'whose',
|
|
27
|
+
now: '"whose" — the column on the section\'s table that names this record, e.g. "customer_id" or "invoice_id.customer_id"',
|
|
28
|
+
},
|
|
29
|
+
{ from: 'of', to: 'about', now: '"about" — the record this section is about, named by a reference column of the base, e.g. "site_id"' },
|
|
30
|
+
{ from: 'paths', to: 'show', now: '"show" — the fields to show, e.g. ["name", "account_id.name"]' },
|
|
31
|
+
{ from: 'orderBy', to: 'sort', now: '"sort" — written like the query bar, e.g. "due_on desc, name"' },
|
|
32
|
+
];
|
|
33
|
+
/* A custom section's reads, on a record page and on a dashboard alike. */
|
|
34
|
+
export const CUSTOM_SECTION_RENAMED = [
|
|
35
|
+
{
|
|
36
|
+
from: 'totals',
|
|
37
|
+
to: 'figures',
|
|
38
|
+
now: '"figures": the named aggregate reads its component receives as figures.<name> ("totals" is a list\'s footer of sums)',
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
/* A call to action's emphasis is its `intent`, as a button's is; `kind` names what a thing is. */
|
|
42
|
+
export const LINK_INTENT_RENAMED = [
|
|
43
|
+
{ from: 'kind', to: 'intent', now: '"intent", as a button says it: "primary" or "secondary"' },
|
|
44
|
+
];
|
|
45
|
+
/* A config file's page (tablewalk.json): an App's page has no connection to name, so this one never reaches App source. */
|
|
46
|
+
export const CONFIG_PAGE_RENAMED = [
|
|
47
|
+
{ from: 'onlyOn', to: 'connection', now: '"connection", as the root of the config file says it' },
|
|
48
|
+
];
|
|
@@ -690,6 +690,7 @@ export interface ServedApp<View extends object = ServedDashboardView | ServedFor
|
|
|
690
690
|
ui: ServedAppUi;
|
|
691
691
|
writableTables?: string[] | false;
|
|
692
692
|
exportableTables?: string[];
|
|
693
|
+
viewerRoles?: string[];
|
|
693
694
|
grantedCommands?: string[];
|
|
694
695
|
grantedActions?: Record<string, string[]>;
|
|
695
696
|
assistant?: {
|
|
@@ -19,10 +19,16 @@ export declare function families(stack: string): string[];
|
|
|
19
19
|
* would not draw a line in.
|
|
20
20
|
*/
|
|
21
21
|
export declare function headingFace(theme: ThemeDefinition): ThemeFaceDefinition | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* The face a theme's interface text is drawn in: the first served face of the family its `ui` stack leads with, at the
|
|
24
|
+
* regular weight where it ships one. Preloaded where a tenant picked it (clientSurface.ts appFaceHead), since every
|
|
25
|
+
* line of the page is set in it; a theme's headings are the App's author's call and preload on their own.
|
|
26
|
+
*/
|
|
27
|
+
export declare function uiFace(theme: ThemeDefinition): ThemeFaceDefinition | undefined;
|
|
22
28
|
/**
|
|
23
29
|
* The `@font-face` rules for a theme's served faces, each `url()` the
|
|
24
30
|
* browser's own form of its address (`shown`). `swap`, as Inter's is
|
|
25
|
-
* (
|
|
31
|
+
* (interFace.css): the text is drawn at once in the stack's next family and
|
|
26
32
|
* set again when the face lands, never held invisible. The family and the
|
|
27
33
|
* address are both checked to a character set that cannot close the rule
|
|
28
34
|
* (themeSpec.ts, appFonts.ts), so nothing a theme says becomes a stylesheet.
|
|
@@ -25,10 +25,25 @@ export function headingFace(theme) {
|
|
|
25
25
|
return weight >= low && weight <= high;
|
|
26
26
|
}) ?? faces[0]);
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* The face a theme's interface text is drawn in: the first served face of the family its `ui` stack leads with, at the
|
|
30
|
+
* regular weight where it ships one. Preloaded where a tenant picked it (clientSurface.ts appFaceHead), since every
|
|
31
|
+
* line of the page is set in it; a theme's headings are the App's author's call and preload on their own.
|
|
32
|
+
*/
|
|
33
|
+
export function uiFace(theme) {
|
|
34
|
+
const lead = families(theme.fonts?.ui ?? '')[0]?.toLowerCase();
|
|
35
|
+
if (!lead)
|
|
36
|
+
return undefined;
|
|
37
|
+
const faces = (theme.faces ?? []).filter((face) => face.family.toLowerCase() === lead && face.style === 'normal' && face.href);
|
|
38
|
+
return (faces.find((face) => {
|
|
39
|
+
const [low, high = low] = face.weight.split(' ').map(Number);
|
|
40
|
+
return 400 >= low && 400 <= high;
|
|
41
|
+
}) ?? faces[0]);
|
|
42
|
+
}
|
|
28
43
|
/**
|
|
29
44
|
* The `@font-face` rules for a theme's served faces, each `url()` the
|
|
30
45
|
* browser's own form of its address (`shown`). `swap`, as Inter's is
|
|
31
|
-
* (
|
|
46
|
+
* (interFace.css): the text is drawn at once in the stack's next family and
|
|
32
47
|
* set again when the face lands, never held invisible. The family and the
|
|
33
48
|
* address are both checked to a character set that cannot close the rule
|
|
34
49
|
* (themeSpec.ts, appFonts.ts), so nothing a theme says becomes a stylesheet.
|
|
@@ -6,4 +6,12 @@
|
|
|
6
6
|
* first paint that needs only the looks.
|
|
7
7
|
*/
|
|
8
8
|
import type { ThemeSpec } from '../../schema/theme.js';
|
|
9
|
+
/** Lumen's face: Inter, shipped as a sheet of its own (interFace.css) and so
|
|
10
|
+
fetched only by a page set in it, never in the first paint; then Arial
|
|
11
|
+
cut to Inter's measure while it arrives (docs/design.md, Faces). */
|
|
12
|
+
export declare const INTER = "Inter, \"Inter Fallback\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif";
|
|
13
|
+
/** Workshop's faces: Barlow for the interface and data, its semi-condensed bold for titles and labels, shipped with
|
|
14
|
+
a sheet of their own (barlowFace.css) and fetched only by a page set in them; each with Arial cut to its measure
|
|
15
|
+
while it arrives. */
|
|
16
|
+
export declare const BARLOW = "Barlow, \"Barlow Fallback\", \"Helvetica Neue\", Arial, sans-serif";
|
|
9
17
|
export declare const LOOKS: readonly ThemeSpec[];
|
|
@@ -3,14 +3,14 @@ import { LOOK_PALETTES, paletteColors } from './lookPalettes.js';
|
|
|
3
3
|
nothing is bundled. A look's identity is its type roles: size, weight and tracking. */
|
|
4
4
|
const SANS = 'ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif';
|
|
5
5
|
const HELVETICA = '"Helvetica Neue", Helvetica, Arial, ui-sans-serif, sans-serif';
|
|
6
|
-
/** Lumen's face: Inter, shipped
|
|
7
|
-
fetched only by a page
|
|
6
|
+
/** Lumen's face: Inter, shipped as a sheet of its own (interFace.css) and so
|
|
7
|
+
fetched only by a page set in it, never in the first paint; then Arial
|
|
8
8
|
cut to Inter's measure while it arrives (docs/design.md, Faces). */
|
|
9
|
-
const INTER = `Inter, "Inter Fallback", ${SANS}`;
|
|
9
|
+
export const INTER = `Inter, "Inter Fallback", ${SANS}`;
|
|
10
10
|
/** Workshop's faces: Barlow for the interface and data, its semi-condensed bold for titles and labels, shipped with
|
|
11
|
-
|
|
11
|
+
a sheet of their own (barlowFace.css) and fetched only by a page set in them; each with Arial cut to its measure
|
|
12
12
|
while it arrives. */
|
|
13
|
-
const BARLOW = `Barlow, "Barlow Fallback", "Helvetica Neue", Arial, sans-serif`;
|
|
13
|
+
export const BARLOW = `Barlow, "Barlow Fallback", "Helvetica Neue", Arial, sans-serif`;
|
|
14
14
|
const BARLOW_CONDENSED = `"Barlow Semi Condensed", "Barlow Semi Condensed Fallback", Barlow, "Arial Narrow", sans-serif`;
|
|
15
15
|
/** Ledger's figures and labels: IBM Plex Mono, shipped with Ledger's sheet (ledgerLook.css) and fetched only by a page
|
|
16
16
|
wearing it; the platform's monospace stands in until it arrives. */
|
|
@@ -58,6 +58,10 @@ export const lookAttribute = (part) => `data-look-${part.replace(/[A-Z]/g, (lett
|
|
|
58
58
|
export const RECIPE_PARTS = Object.keys(RECIPE_MENU);
|
|
59
59
|
/** Every part at its first value: the plain structure a theme that extends nothing starts from. */
|
|
60
60
|
export const DEFAULT_RECIPES = Object.fromEntries(RECIPE_PARTS.map((part) => [part, Object.keys(RECIPE_MENU[part])[0]]));
|
|
61
|
+
/** The sheet that declares each face the kit ships for an interface, by the family a stack begins with: a sheet of its
|
|
62
|
+
own (interFace.css, barlowFace.css), apart from the look it was made for, so a theme set in the face fetches its
|
|
63
|
+
declaration and not the whole of that look's rules. */
|
|
64
|
+
const KIT_FACE_SHEETS = { Inter: 'inter', Barlow: 'barlow', 'Barlow Semi Condensed': 'barlow' };
|
|
61
65
|
/** The attributes a worn theme sets on the root, and the look sheets they need. */
|
|
62
66
|
export function recipeAttributes(theme, lookNav) {
|
|
63
67
|
const recipes = { ...DEFAULT_RECIPES, ...theme.recipes };
|
|
@@ -82,6 +86,18 @@ export function recipeAttributes(theme, lookNav) {
|
|
|
82
86
|
const lifted = ELEVATIONS[elevation];
|
|
83
87
|
if (lifted)
|
|
84
88
|
sheets.add(lifted);
|
|
89
|
+
/* A face the kit ships is declared by a sheet of its own (interFace.css, barlowFace.css), brought by the stacks that
|
|
90
|
+
begin with it: Lumen's and Workshop's own are set in Inter and Barlow, so they bring theirs, and so does a theme
|
|
91
|
+
that sets its interface in one — a tenant's pick, or an App's stack that names it — which else would draw its
|
|
92
|
+
first line in the fallback and never receive the face. */
|
|
93
|
+
for (const stack of [theme.fonts?.ui, theme.fonts?.heading, theme.fonts?.data]) {
|
|
94
|
+
const face = KIT_FACE_SHEETS[stack
|
|
95
|
+
?.split(',')[0]
|
|
96
|
+
?.trim()
|
|
97
|
+
.replace(/^["']|["']$/g, '') ?? ''];
|
|
98
|
+
if (face)
|
|
99
|
+
sheets.add(face);
|
|
100
|
+
}
|
|
85
101
|
Object.assign(attributes, typeAttributes(theme.type));
|
|
86
102
|
const side = sideNavWords(theme.type, lookNav);
|
|
87
103
|
if (side.length)
|
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.44",
|
|
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": {
|
|
@@ -231,6 +231,7 @@
|
|
|
231
231
|
"./shared/referenceSubline.js": "./dist/shared/referenceSubline.js",
|
|
232
232
|
"./shared/refusal.js": "./dist/shared/refusal.js",
|
|
233
233
|
"./shared/relatedCreate.js": "./dist/shared/relatedCreate.js",
|
|
234
|
+
"./shared/renamedSectionWords.js": "./dist/shared/renamedSectionWords.js",
|
|
234
235
|
"./shared/resourceHttp.js": "./dist/shared/resourceHttp.js",
|
|
235
236
|
"./shared/richText.js": "./dist/shared/richText.js",
|
|
236
237
|
"./shared/rollups.js": "./dist/shared/rollups.js",
|
package/schema/model.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface RelatedCreate<Label extends string | AppMessageRef = string | A
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/** What an aggregate read of a custom section measures: "count", or an aggregate and a column of the resource. */
|
|
34
|
-
export type CustomMeasure = 'count' | `${'sum' | 'avg' | 'min' | 'max'} ${string}`;
|
|
34
|
+
export type CustomMeasure = 'count' | `count distinct ${string}` | `${'sum' | 'avg' | 'min' | 'max'} ${string}`;
|
|
35
35
|
|
|
36
36
|
/** A scalar key, or a field of the source record. Never a URL or authority. */
|
|
37
37
|
export type AppLinkValue = string | number | { column: string };
|
|
@@ -165,15 +165,15 @@ export interface AppCommandGroup {
|
|
|
165
165
|
required?: never;
|
|
166
166
|
}
|
|
167
167
|
export type AppCommandField = (CommandValueBase & (
|
|
168
|
-
| { type: 'text' | 'textarea'; minLength?: number; maxLength?: number; format?: CommandTextFormat; pattern?: string; message?: string; case?: 'upper' | 'lower';
|
|
168
|
+
| { type: 'text' | 'textarea'; placeholder?: string; minLength?: number; maxLength?: number; format?: CommandTextFormat; pattern?: string; message?: string; case?: 'upper' | 'lower';
|
|
169
169
|
/** A mask the value is typed through: `0` a digit, `a` a letter, `*` either, anything else drawn as written
|
|
170
170
|
(`'000-00-0000'`). The value is what the mask's places hold (`123456789`), and the mask is its pattern. */
|
|
171
171
|
mask?: string; sensitive?: CommandSensitive }
|
|
172
172
|
| { type: 'richText'; minLength?: number; maxLength?: number; mentions?: CommandRichTextMentions; images?: string }
|
|
173
173
|
/** `outOf`: with `as: 'rating'`, the stars of its scale; the field is then a whole number from 1 to it. */
|
|
174
|
-
| { type: 'number'; min?: number; max?: number; integer?: boolean; step?: number; below?: string; above?: string; live?: CommandLiveLines; outOf?: number }
|
|
174
|
+
| { type: 'number'; placeholder?: string; min?: number; max?: number; integer?: boolean; step?: number; below?: string; above?: string; live?: CommandLiveLines; outOf?: number }
|
|
175
175
|
/** An amount of money in the App's currency (`ui.currency`), from 0 unless `min` says less, on cents unless `step` says otherwise. */
|
|
176
|
-
| { type: 'money'; min?: number; max?: number; step?: number; minor?: boolean; currency?: string; below?: string; above?: string; live?: CommandLiveLines }
|
|
176
|
+
| { type: 'money'; placeholder?: string; min?: number; max?: number; step?: number; minor?: boolean; currency?: string; below?: string; above?: string; live?: CommandLiveLines }
|
|
177
177
|
/** `statement`: the long words a consent box stands beside (at most 2,000 characters), drawn as one paragraph. */
|
|
178
178
|
| { type: 'boolean'; accept?: true; statement?: string }
|
|
179
179
|
| { type: 'date'; min?: string; max?: string; below?: string; above?: string }
|