@mistriwork/engine 1.0.0-rc.37 → 1.0.0-rc.38
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/server/clientHttp.js +10 -1
- package/dist/server/http/exportRoute.js +9 -1
- package/dist/shared/recordReads.js +26 -0
- package/dist/shared/themeRecipes.d.ts +1 -1
- package/dist/shared/themeRecipes.js +1 -0
- package/package.json +1 -1
- package/schema/model.d.ts +5 -1
- package/schema/theme.d.ts +2 -1
|
@@ -140,10 +140,19 @@ const writesHead = (head) => Boolean(head?.title ||
|
|
|
140
140
|
head?.social ||
|
|
141
141
|
head?.pane ||
|
|
142
142
|
head?.pwa);
|
|
143
|
+
/** What an App's own theme carries that a page's head never writes: its served files and where its menu sits. */
|
|
144
|
+
const HEAD_UNWRITTEN = new Set(['faces', 'stylesheet', 'shell']);
|
|
143
145
|
/** Generate only registered token names and validated theme values. Row text
|
|
144
146
|
* exists only in escaped JSON; it can never close a style/script element. */
|
|
145
147
|
function brandingHead(html, presentation, base) {
|
|
146
|
-
|
|
148
|
+
/* A tenant's theme starts from the App's own, which may ship font files, a stylesheet or a menu placement. The head
|
|
149
|
+
writes none of them (the shell serves the App's already), so the validator is not asked them: a field report's
|
|
150
|
+
App wore its own faces, and every public form of a tenant that had saved a name answered 403. */
|
|
151
|
+
const said = presentation.value.theme;
|
|
152
|
+
const tokens = said && typeof said === 'object' && !Array.isArray(said)
|
|
153
|
+
? Object.fromEntries(Object.entries(said).filter(([key]) => !HEAD_UNWRITTEN.has(key)))
|
|
154
|
+
: said;
|
|
155
|
+
const theme = parseThemes([tokens], 'Request branding', 'themes', { platform: true })[0];
|
|
147
156
|
const declarations = (mode) => {
|
|
148
157
|
const pairs = [];
|
|
149
158
|
for (const [key, token] of Object.entries(PALETTE_TOKENS)) {
|
|
@@ -127,8 +127,11 @@ export async function exportFile(asked) {
|
|
|
127
127
|
return stream(res, format, view.base, rowsWanted(view.limit), read, requested(body) ?? undefined, amountsOf(view.base), asked.headers, byOffset ? answer : undefined);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
+
/* Not a file, so not a 200: a client reads the status before the body. A table this reader is not served is not
|
|
131
|
+
found — the same answer whether it exists or not, so a refusal tells nothing — and any other question that cannot
|
|
132
|
+
be read is a bad request. Either way `errors` says why, as `/api/run`'s does. */
|
|
130
133
|
if (!parsed.query || parsed.errors.length) {
|
|
131
|
-
answer(
|
|
134
|
+
answer(servesTable(schema, text) ? 400 : 404, { errors: parsed.errors });
|
|
132
135
|
return undefined;
|
|
133
136
|
}
|
|
134
137
|
const query = parsed.query;
|
|
@@ -170,6 +173,11 @@ export async function exportFile(asked) {
|
|
|
170
173
|
};
|
|
171
174
|
return stream(res, format, table.id, rowsWanted(query.limit), read, wanted, amountsOf(table.id), asked.headers, byOffset ? answer : undefined);
|
|
172
175
|
}
|
|
176
|
+
/** Whether the question's first word is a table in this reader's schema, by id or by bare name (as parseQuery finds it); an empty question names none and is no missing table. */
|
|
177
|
+
function servesTable(schema, text) {
|
|
178
|
+
const first = text.trim().split(/\s+/)[0];
|
|
179
|
+
return !first || findTable(schema, first) !== undefined || schema.tables.some((table) => table.name === first);
|
|
180
|
+
}
|
|
173
181
|
function refuseTable(answer, tableId) {
|
|
174
182
|
answer(403, {
|
|
175
183
|
error: `Export of "${tableId}" is not available to this person.`,
|
|
@@ -454,6 +454,32 @@ export function recordPageReads(names, page, base, plans, key, options) {
|
|
|
454
454
|
assertNever(section.kind, 'page section kind');
|
|
455
455
|
}
|
|
456
456
|
});
|
|
457
|
+
/* A strip of related tabs decides which tabs it has before one is opened (kit ListTabs, useStandings): the condition of a
|
|
458
|
+
list that has one, and the first page of a list that hides while empty, which is the answer to "has it rows?". They
|
|
459
|
+
are the reads the list asks itself when its tab is opened, so they are asked here too, once, and the strip finds
|
|
460
|
+
them waiting (as for a list alone). A closed tab is asked what it must decide on and no more. */
|
|
461
|
+
for (const run of runs) {
|
|
462
|
+
if (run.length < 2)
|
|
463
|
+
continue;
|
|
464
|
+
for (const index of run) {
|
|
465
|
+
const section = page.sections[index];
|
|
466
|
+
if (section.hidden || drawn.has(index) || section.kind !== 'list')
|
|
467
|
+
continue;
|
|
468
|
+
kind = 'related';
|
|
469
|
+
if (section.when)
|
|
470
|
+
reads.push({ path: '/api/run', body: whenBody(base, key, section.when) });
|
|
471
|
+
const plan = planOf(index);
|
|
472
|
+
if (section.emptyMode !== 'hide' || !plan || plan.error || plan.empty)
|
|
473
|
+
continue;
|
|
474
|
+
if (section.group && plan.groups) {
|
|
475
|
+
reads.push({ path: '/api/breakdown', body: groupsBody(plan.groups, 0), kind });
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
const listed = listView(names, section, plan, options.rows).view;
|
|
479
|
+
if (listed)
|
|
480
|
+
view({ view: listed, offset: 0 });
|
|
481
|
+
}
|
|
482
|
+
}
|
|
457
483
|
/* An inferred page's tabs say how many rows each holds, all of them in one read; a list alone says it in its head. */
|
|
458
484
|
if (isInferredPage(page, names.app))
|
|
459
485
|
for (const run of runs) {
|
|
@@ -211,7 +211,7 @@ export declare function typeAttributes(type: ThemeTypeDefinition | undefined): R
|
|
|
211
211
|
* The published parts a theme may dress one by one (themeParts.ts says what each may take and how it is worn). Here,
|
|
212
212
|
* with the words the root wears for them, because the first paint sets `data-parts` as it sets the recipes'.
|
|
213
213
|
*/
|
|
214
|
-
export declare const THEME_PARTS: readonly ["ground", "bar", "bar.search", "nav", "nav.item", "nav.current", "nav.group", "logo", "page.title", "tabs", "tab.current", "section", "section.title", "stat", "stat.figure", "fields", "field.label", "table", "table.head", "table.row", "status", "tag", "button.primary", "button.secondary", "button.quiet", "link", "board.lane", "board.card", "workflow.step", "banner", "steps.step", "avatar", "identityMark", "menu", "dialog", "chart"];
|
|
214
|
+
export declare const THEME_PARTS: readonly ["ground", "bar", "bar.search", "nav", "nav.item", "nav.current", "nav.group", "logo", "page.title", "tabs", "tab.current", "section", "section.title", "stat", "stat.figure", "fields", "field.label", "table", "table.head", "table.row", "status", "tag", "button.primary", "button.secondary", "button.quiet", "link", "board.lane", "board.card", "workflow.step", "banner", "steps.step", "avatar", "identityMark", "menu", "dialog", "chart", "kicker"];
|
|
215
215
|
/** What a part style may say, in the order its words are written. */
|
|
216
216
|
export declare const PART_PROPERTIES: readonly ['ground', 'ink', 'edge', 'radius', 'lift', 'face', 'weight', 'case'];
|
|
217
217
|
/** The root's `data-parts`: one word per property a part says (`stat:ground button.primary:case`); undefined when none. */
|
|
@@ -220,6 +220,7 @@ export const THEME_PARTS = [
|
|
|
220
220
|
'menu',
|
|
221
221
|
'dialog',
|
|
222
222
|
'chart',
|
|
223
|
+
'kicker',
|
|
223
224
|
];
|
|
224
225
|
/** What a part style may say, in the order its words are written. */
|
|
225
226
|
export const PART_PROPERTIES = ['ground', 'ink', 'edge', 'radius', 'lift', 'face', 'weight', 'case'];
|
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.38",
|
|
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": {
|
package/schema/model.d.ts
CHANGED
|
@@ -283,8 +283,12 @@ export interface AppCommandAction<Target extends string = string, Label extends
|
|
|
283
283
|
/** Its key in `resources.<table>.actions`. */
|
|
284
284
|
id: string;
|
|
285
285
|
command: AppCommandReference<Target>;
|
|
286
|
-
/** Where the button is offered: the command's own `when
|
|
286
|
+
/** Where the button is offered: the command's own `when` and the action's together, or the states a machine's verb
|
|
287
|
+
leaves. Visibility only; the server judges the command's. */
|
|
287
288
|
when?: string;
|
|
289
|
+
/** The action's own `when` alone, when it has one: what a record's bar asks, since the server's availability answer
|
|
290
|
+
already holds the command's. */
|
|
291
|
+
offered?: string;
|
|
288
292
|
/** A machine's verb that says itself differently from different states (a per-edge `label`, or `{to}` in it):
|
|
289
293
|
each label with the states it is said from, as a condition. `label` is the first state's. */
|
|
290
294
|
labels?: Array<{ when: string; label: string }>;
|
package/schema/theme.d.ts
CHANGED
|
@@ -178,7 +178,8 @@ export type ThemePart =
|
|
|
178
178
|
| 'identityMark'
|
|
179
179
|
| 'menu'
|
|
180
180
|
| 'dialog'
|
|
181
|
-
| 'chart'
|
|
181
|
+
| 'chart'
|
|
182
|
+
| 'kicker';
|
|
182
183
|
|
|
183
184
|
/** A color role by its path in `colors`: `ink`, `nav.ground`, `status.good`, `chart[2]`. */
|
|
184
185
|
export type ThemeColorPath =
|