@mistriwork/engine 1.0.0-rc.29 → 1.0.0-rc.31

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.
@@ -213,6 +213,17 @@ export function appEntries(app, given) {
213
213
  more.commands = { path: app.commands.file, from: 'convention' };
214
214
  return more;
215
215
  }
216
+ /**
217
+ * The commands module the App keeps beside its manifest, for a run that has not loaded the App (shot, dev, grade):
218
+ * the same file a load would find, so every command says one thing about it (`check` knows it from the loaded App).
219
+ */
220
+ function conventionEntries(context, more) {
221
+ if (more.commands || context.entries.commands || !context.app)
222
+ return more;
223
+ const home = resolve(context.app.path);
224
+ const file = ['commands.ts', 'commands.mjs', 'commands.js'].map((name) => join(home, name)).find((path) => existsSync(path));
225
+ return file ? { ...more, commands: { path: file, from: 'convention' } } : more;
226
+ }
216
227
  /**
217
228
  * The context as the run prints it, one line an entry: where it came from, and a flag that overrode the profile.
218
229
  * `convention` and `build` are the App's to say (the loaded App's commands.ts beside it, a build's own bundles).
@@ -220,6 +231,7 @@ export function appEntries(app, given) {
220
231
  export function contextLines(context, more = {}) {
221
232
  if (!context)
222
233
  return [];
234
+ more = conventionEntries(context, more);
223
235
  const where = context.config
224
236
  ? `${shown(context.config.path)} (${{ flag: '--config', app: 'beside the App', cwd: 'the working directory', user: "the person's own" }[context.config.from]})`
225
237
  : 'no config file';
@@ -245,8 +257,9 @@ function over(context, key, from) {
245
257
  }
246
258
  /** The context as `--json` carries it: `{ config, app, entries: { commands|jobs|policy|entry: { path, from } | null } }`. */
247
259
  export function contextJson(context, more = {}) {
260
+ const beside = context ? conventionEntries(context, more) : more;
248
261
  const entry = (key) => {
249
- const own = context?.entries[key] ?? more[key];
262
+ const own = context?.entries[key] ?? beside[key];
250
263
  if (!own)
251
264
  return null;
252
265
  const said = context?.over[key];
@@ -20,6 +20,7 @@
20
20
  */
21
21
  import type { ServerResponse } from 'node:http';
22
22
  import { type PageDef } from '../../shared/page.js';
23
+ import { type ReadAsk } from '../../shared/recordReads.js';
23
24
  import type { RequestContext, ResolvedSource } from './context.js';
24
25
  export declare const COMPOSE_PATH = "/api/pages/compose";
25
26
  /** The resources of the App a page is drawn in, as far as composing its reads needs them. */
@@ -54,6 +55,10 @@ export interface ComposeHooks {
54
55
  resources(ctx: RequestContext, source: ResolvedSource): ComposeResources;
55
56
  /** A table's suggested page (`suggested:<table>`). */
56
57
  suggested(source: ResolvedSource, table: string): PageDef | null;
58
+ /** An error that refuses the whole page rather than leaving the part out (a read the audit could not record). */
59
+ fatal?(error: unknown): boolean;
60
+ /** Runs a part's read as the door its `kind` names (a related list's), for a read audit; where none is kept, as it is. */
61
+ asking?<T>(path: string, kind: ReadAsk['kind'], work: () => T): T;
57
62
  /** Which of the record's commands are available to this reader: the availability route's answer, or none. */
58
63
  availability?(ctx: RequestContext, checks: CommandCheck[]): Promise<{
59
64
  status: number;
@@ -36,14 +36,17 @@ export async function composeRecordPage({ ctx, source, body, post, hooks, }) {
36
36
  /* A part asked on the page's behalf: through the route its section's own
37
37
  request reaches, answered into memory. What that route would refuse, or
38
38
  throw, leaves the part out. */
39
- const ask = async (path, given) => {
39
+ const ask = async (path, given, kind) => {
40
40
  if (!hooks.mayAsk(ctx, path))
41
41
  return undefined;
42
42
  const reply = new CapturedReply();
43
43
  try {
44
- await post(reply.asResponse(), path, given);
44
+ const posting = () => post(reply.asResponse(), path, given);
45
+ await (hooks.asking ? hooks.asking(path, kind, posting) : posting());
45
46
  }
46
- catch {
47
+ catch (error) {
48
+ if (hooks.fatal?.(error))
49
+ throw error;
47
50
  return undefined;
48
51
  }
49
52
  return reply.answer();
@@ -67,7 +70,7 @@ export async function composeRecordPage({ ctx, source, body, post, hooks, }) {
67
70
  const answered = [];
68
71
  const keep = (asked, answer) => {
69
72
  if (!failed(answer))
70
- answered.push({ ...asked, status: answer.status, reply: answer.body });
73
+ answered.push({ path: asked.path, body: asked.body, status: answer.status, reply: answer.body });
71
74
  };
72
75
  const { row, parts, reads } = recordPageReads(names, page, base, plans, record, options);
73
76
  /* The record's fixed edits ask their `when` of the row, as a section does. */
@@ -100,7 +103,7 @@ export async function composeRecordPage({ ctx, source, body, post, hooks, }) {
100
103
  /* The page's own row first, its verbs last: they are advice, and wait behind what is shown. */
101
104
  const done = Promise.all([
102
105
  whole(),
103
- ...reads.map(async (asked) => keep(asked, await (begun.get(readKey(asked)) ?? ask(asked.path, asked.body)))),
106
+ ...reads.map(async (asked) => keep(asked, await (begun.get(readKey(asked)) ?? ask(asked.path, asked.body, asked.kind)))),
104
107
  availability(),
105
108
  ]);
106
109
  return { reads: new Set(reads.map((asked) => readKey(asked))), done: done.then(() => answered) };
@@ -113,10 +116,14 @@ export async function composeRecordPage({ ctx, source, body, post, hooks, }) {
113
116
  const history = expected && expectedBase
114
117
  ? recordPageReads(names, expected, expectedBase, [], record, options)
115
118
  .reads.filter((asked) => asked.path === '/api/record-history')
116
- .map((asked) => [asked, ask(asked.path, asked.body)])
119
+ .map((asked) => [asked, ask(asked.path, asked.body, asked.kind)])
117
120
  : [];
118
121
  const planning = ask('/api/pages/plan', { page: body.page, key });
119
122
  const early = expected && expectedBase ? reading(expected, expectedBase, [], history) : undefined;
123
+ /* A part that refuses the page ends it where it is awaited; what was started beside it settles unobserved otherwise. */
124
+ for (const [, started] of history)
125
+ started.catch(() => { });
126
+ early?.done.catch(() => { });
120
127
  const plan = await planning;
121
128
  const planned = failed(plan) ? undefined : plan.body;
122
129
  const base = planned && findTable(source.schema, planned.page.base);
@@ -136,10 +143,10 @@ export async function composeRecordPage({ ctx, source, body, post, hooks, }) {
136
143
  /* Only what the plan adds: its lists, figures, timelines and custom reads. */
137
144
  const { reads } = recordPageReads(names, planned.page, base, planned.plans, record, options);
138
145
  const later = reads.filter((asked) => !kept.reads.has(readKey(asked)));
139
- const more = await Promise.all(later.map(async (asked) => ({ asked, answer: await ask(asked.path, asked.body) })));
146
+ const more = await Promise.all(later.map(async (asked) => ({ asked, answer: await ask(asked.path, asked.body, asked.kind) })));
140
147
  answered = [
141
148
  ...(await kept.done),
142
- ...more.flatMap(({ asked, answer }) => (failed(answer) ? [] : [{ ...asked, status: answer.status, reply: answer.body }])),
149
+ ...more.flatMap(({ asked, answer }) => failed(answer) ? [] : [{ path: asked.path, body: asked.body, status: answer.status, reply: answer.body }]),
143
150
  ];
144
151
  }
145
152
  else
@@ -87,7 +87,11 @@ export async function atlasBinary(projectDir, say, fetcher = download, platform
87
87
  return path;
88
88
  }
89
89
  async function download(url) {
90
- const response = await fetch(url);
90
+ /* A closed network (a sandboxed agent, a build box) fails here as a bare "fetch failed": said with where it was
91
+ going and the way round it, since nothing else in the message names either. */
92
+ const response = await fetch(url).catch((error) => {
93
+ throw new Error(`could not fetch Atlas from ${url}: ${error instanceof Error ? error.message : String(error)}. The first diff needs no download; the next ones do. Where there is no network route, download that file elsewhere, make it executable, and set ${envName('ATLAS')} to its path.`, { cause: error });
94
+ });
91
95
  if (!response.ok)
92
96
  throw new Error(`could not fetch Atlas from ${url}: HTTP ${response.status}. To work offline, install Atlas ${ATLAS_VERSION} (community edition) and set ${envName('ATLAS')} to that binary.`);
93
97
  return new Uint8Array(await response.arrayBuffer());
@@ -20,7 +20,7 @@
20
20
  * tests keep this list, the JSON schema's `appIcon` enum, packages/mistri/schema/app.d.ts's
21
21
  * `AppIconName` and the generated glyphs the same.
22
22
  */
23
- export declare const APP_ICONS: readonly ['house', 'tray', 'list', 'list-checks', 'kanban', 'table', 'calendar', 'calendar-check', 'clock', 'chart-bar', 'chart-line', 'chart-pie', 'gauge', 'target', 'flag', 'user', 'users', 'user-circle', 'address-book', 'handshake', 'buildings', 'storefront', 'briefcase', 'package', 'truck', 'car', 'shopping-cart', 'receipt', 'currency-dollar', 'credit-card', 'wallet', 'bank', 'file', 'file-text', 'folder', 'clipboard-text', 'note', 'archive', 'tag', 'ticket', 'star', 'bookmark-simple', 'bell', 'envelope', 'chat-circle', 'phone', 'headset', 'megaphone', 'globe', 'map-pin', 'magnifying-glass', 'gear', 'sliders', 'wrench', 'bug', 'shield-check', 'lock', 'key', 'database', 'stack', 'lightning', 'check-circle', 'warning', 'info', 'cell-signal-low', 'cell-signal-medium', 'cell-signal-high', 'cell-signal-full', 'fire', 'hourglass', 'circle-dashed', 'x-circle', 'plus-circle', 'pencil-simple', 'paper-plane-tilt', 'arrows-left-right', 'arrow-circle-down', 'arrow-circle-up', 'laptop', 'monitor', 'device-mobile', 'printer', 'stethoscope', 'heartbeat', 'heart', 'pill', 'syringe', 'first-aid-kit', 'thermometer', 'flask', 'test-tube', 'microscope', 'bed', 'hospital', 'ambulance', 'tooth', 'eyeglasses', 'wheelchair', 'baby', 'dna', 'brain', 'bandaids', 'hand-heart', 'graduation-cap', 'book-open', 'student', 'chalkboard-teacher', 'factory', 'warehouse', 'house-line', 'plant', 'leaf', 'sun', 'cloud', 'drop', 'airplane', 'bicycle', 'bus', 'train', 'boat', 'hammer', 'toolbox', 'plug', 'lightbulb', 'cube', 'camera', 'image', 'trophy', 'gift', 'coffee', 'fork-knife', 'shopping-bag', 'basket', 'barcode', 'qr-code', 'scales', 'gavel', 'certificate', 'identification-card', 'fingerprint', 'eye', 'link', 'paperclip', 'scissors', 'palette', 'code', 'terminal', 'users-three', 'user-plus'];
23
+ export declare const APP_ICONS: readonly ['house', 'tray', 'list', 'list-checks', 'kanban', 'table', 'calendar', 'calendar-check', 'clock', 'chart-bar', 'chart-line', 'chart-pie', 'gauge', 'target', 'flag', 'user', 'users', 'user-circle', 'address-book', 'handshake', 'buildings', 'storefront', 'briefcase', 'package', 'truck', 'car', 'shopping-cart', 'receipt', 'currency-dollar', 'credit-card', 'wallet', 'bank', 'file', 'file-text', 'folder', 'clipboard-text', 'note', 'archive', 'tag', 'ticket', 'star', 'bookmark-simple', 'bell', 'envelope', 'chat-circle', 'phone', 'headset', 'megaphone', 'globe', 'map-pin', 'magnifying-glass', 'gear', 'sliders', 'wrench', 'bug', 'shield-check', 'lock', 'key', 'database', 'stack', 'lightning', 'check-circle', 'warning', 'info', 'cell-signal-low', 'cell-signal-medium', 'cell-signal-high', 'cell-signal-full', 'fire', 'hourglass', 'circle-dashed', 'x-circle', 'plus-circle', 'pencil-simple', 'paper-plane-tilt', 'arrows-left-right', 'arrow-circle-down', 'arrow-circle-up', 'laptop', 'monitor', 'device-mobile', 'printer', 'stethoscope', 'heartbeat', 'heart', 'pill', 'syringe', 'first-aid-kit', 'thermometer', 'flask', 'test-tube', 'microscope', 'bed', 'hospital', 'ambulance', 'tooth', 'eyeglasses', 'wheelchair', 'baby', 'dna', 'brain', 'bandaids', 'hand-heart', 'graduation-cap', 'book-open', 'student', 'chalkboard-teacher', 'factory', 'warehouse', 'house-line', 'plant', 'leaf', 'sun', 'cloud', 'drop', 'airplane', 'bicycle', 'bus', 'train', 'boat', 'hammer', 'toolbox', 'plug', 'lightbulb', 'cube', 'camera', 'image', 'trophy', 'gift', 'coffee', 'fork-knife', 'shopping-bag', 'basket', 'barcode', 'qr-code', 'scales', 'gavel', 'certificate', 'identification-card', 'fingerprint', 'eye', 'link', 'paperclip', 'scissors', 'palette', 'code', 'terminal', 'users-three', 'user-plus', 'caret-left', 'caret-right', 'caret-up', 'caret-down', 'arrow-left', 'arrow-right', 'x', 'plus', 'dots-three'];
24
24
  export type AppIconName = (typeof APP_ICONS)[number];
25
25
  export declare const isAppIcon: (value: unknown) => value is AppIconName;
26
26
  /** An authored `icon`: one of APP_ICONS, or refused with the closest names and where the rest are listed.
@@ -183,6 +183,16 @@ export const APP_ICONS = [
183
183
  'terminal',
184
184
  'users-three',
185
185
  'user-plus',
186
+ // Direction and dismissal: what a page's own previous, next, close, add and more are drawn with
187
+ 'caret-left',
188
+ 'caret-right',
189
+ 'caret-up',
190
+ 'caret-down',
191
+ 'arrow-left',
192
+ 'arrow-right',
193
+ 'x',
194
+ 'plus',
195
+ 'dots-three',
186
196
  ];
187
197
  const KNOWN = new Set(APP_ICONS);
188
198
  export const isAppIcon = (value) => typeof value === 'string' && KNOWN.has(value);
@@ -148,4 +148,13 @@ export const APP_ICON_GLYPHS = {
148
148
  'terminal': [["M117.31,134l-72,64a8,8,0,1,1-10.63-12L100,128,34.69,70A8,8,0,1,1,45.32,58l72,64a8,8,0,0,1,0,12ZM216,184H120a8,8,0,0,0,0,16h96a8,8,0,0,0,0-16Z"], ["M120,137,48,201A12,12,0,1,1,32,183l61.91-55L32,73A12,12,0,1,1,48,55l72,64A12,12,0,0,1,120,137Zm96,43H120a12,12,0,0,0,0,24h96a12,12,0,0,0,0-24Z"]],
149
149
  'users-three': [["M244.8,150.4a8,8,0,0,1-11.2-1.6A51.6,51.6,0,0,0,192,128a8,8,0,0,1-7.37-4.89,8,8,0,0,1,0-6.22A8,8,0,0,1,192,112a24,24,0,1,0-23.24-30,8,8,0,1,1-15.5-4A40,40,0,1,1,219,117.51a67.94,67.94,0,0,1,27.43,21.68A8,8,0,0,1,244.8,150.4ZM190.92,212a8,8,0,1,1-13.84,8,57,57,0,0,0-98.16,0,8,8,0,1,1-13.84-8,72.06,72.06,0,0,1,33.74-29.92,48,48,0,1,1,58.36,0A72.06,72.06,0,0,1,190.92,212ZM128,176a32,32,0,1,0-32-32A32,32,0,0,0,128,176ZM72,120a8,8,0,0,0-8-8A24,24,0,1,1,87.24,82a8,8,0,1,0,15.5-4A40,40,0,1,0,37,117.51,67.94,67.94,0,0,0,9.6,139.19a8,8,0,1,0,12.8,9.61A51.6,51.6,0,0,1,64,128,8,8,0,0,0,72,120Z"], ["M164.38,181.1a52,52,0,1,0-72.76,0,75.89,75.89,0,0,0-30,28.89,12,12,0,0,0,20.78,12,53,53,0,0,1,91.22,0,12,12,0,1,0,20.78-12A75.89,75.89,0,0,0,164.38,181.1ZM100,144a28,28,0,1,1,28,28A28,28,0,0,1,100,144Zm147.21,9.59a12,12,0,0,1-16.81-2.39c-8.33-11.09-19.85-19.59-29.33-21.64a12,12,0,0,1-1.82-22.91,20,20,0,1,0-24.78-28.3,12,12,0,1,1-21-11.6,44,44,0,1,1,73.28,48.35,92.18,92.18,0,0,1,22.85,21.69A12,12,0,0,1,247.21,153.59Zm-192.28-24c-9.48,2.05-21,10.55-29.33,21.65A12,12,0,0,1,6.41,136.79,92.37,92.37,0,0,1,29.26,115.1a44,44,0,1,1,73.28-48.35,12,12,0,1,1-21,11.6,20,20,0,1,0-24.78,28.3,12,12,0,0,1-1.82,22.91Z"]],
150
150
  'user-plus': [["M256,136a8,8,0,0,1-8,8H232v16a8,8,0,0,1-16,0V144H200a8,8,0,0,1,0-16h16V112a8,8,0,0,1,16,0v16h16A8,8,0,0,1,256,136Zm-57.87,58.85a8,8,0,0,1-12.26,10.3C165.75,181.19,138.09,168,108,168s-57.75,13.19-77.87,37.15a8,8,0,0,1-12.25-10.3c14.94-17.78,33.52-30.41,54.17-37.17a68,68,0,1,1,71.9,0C164.6,164.44,183.18,177.07,198.13,194.85ZM108,152a52,52,0,1,0-52-52A52.06,52.06,0,0,0,108,152Z"], ["M256,136a12,12,0,0,1-12,12h-8v8a12,12,0,0,1-24,0v-8h-8a12,12,0,0,1,0-24h8v-8a12,12,0,0,1,24,0v8h8A12,12,0,0,1,256,136Zm-54.81,56.28a12,12,0,1,1-18.38,15.44C169.12,191.42,145,172,108,172c-28.89,0-55.46,12.68-74.81,35.72a12,12,0,0,1-18.38-15.44A124.08,124.08,0,0,1,63.5,156.53a72,72,0,1,1,89,0A124,124,0,0,1,201.19,192.28ZM108,148a48,48,0,1,0-48-48A48.05,48.05,0,0,0,108,148Z"]],
151
+ 'caret-left': [["M165.66,202.34a8,8,0,0,1-11.32,11.32l-80-80a8,8,0,0,1,0-11.32l80-80a8,8,0,0,1,11.32,11.32L91.31,128Z"], ["M168.49,199.51a12,12,0,0,1-17,17l-80-80a12,12,0,0,1,0-17l80-80a12,12,0,0,1,17,17L97,128Z"]],
152
+ 'caret-right': [["M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"], ["M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z"]],
153
+ 'caret-up': [["M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z"], ["M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z"]],
154
+ 'caret-down': [["M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"], ["M216.49,104.49l-80,80a12,12,0,0,1-17,0l-80-80a12,12,0,0,1,17-17L128,159l71.51-71.52a12,12,0,0,1,17,17Z"]],
155
+ 'arrow-left': [["M224,128a8,8,0,0,1-8,8H59.31l58.35,58.34a8,8,0,0,1-11.32,11.32l-72-72a8,8,0,0,1,0-11.32l72-72a8,8,0,0,1,11.32,11.32L59.31,120H216A8,8,0,0,1,224,128Z"], ["M228,128a12,12,0,0,1-12,12H69l51.52,51.51a12,12,0,0,1-17,17l-72-72a12,12,0,0,1,0-17l72-72a12,12,0,0,1,17,17L69,116H216A12,12,0,0,1,228,128Z"]],
156
+ 'arrow-right': [["M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"], ["M224.49,136.49l-72,72a12,12,0,0,1-17-17L187,140H40a12,12,0,0,1,0-24H187L135.51,64.48a12,12,0,0,1,17-17l72,72A12,12,0,0,1,224.49,136.49Z"]],
157
+ 'x': [["M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"], ["M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"]],
158
+ 'plus': [["M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"], ["M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z"]],
159
+ 'dots-three': [["M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z"], ["M144,128a16,16,0,1,1-16-16A16,16,0,0,1,144,128ZM60,112a16,16,0,1,0,16,16A16,16,0,0,0,60,112Zm136,0a16,16,0,1,0,16,16A16,16,0,0,0,196,112Z"]],
151
160
  };
@@ -160,4 +160,9 @@ export const ICON_WEIGHT_GLYPHS = {
160
160
  'terminal': [["M116,132.48l-72,64a6,6,0,0,1-8-9L103,128,36,68.49a6,6,0,0,1,8-9l72,64a6,6,0,0,1,0,9ZM216,186H120a6,6,0,0,0,0,12h96a6,6,0,0,0,0-12Z"], ["M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM77.66,173.66a8,8,0,0,1-11.32-11.32L100.69,128,66.34,93.66A8,8,0,0,1,77.66,82.34l40,40a8,8,0,0,1,0,11.32ZM192,176H128a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Z"]],
161
161
  'users-three': [["M243.6,148.8a6,6,0,0,1-8.4-1.2A53.58,53.58,0,0,0,192,126a6,6,0,0,1,0-12,26,26,0,1,0-25.18-32.5,6,6,0,0,1-11.62-3,38,38,0,1,1,59.91,39.63A65.69,65.69,0,0,1,244.8,140.4,6,6,0,0,1,243.6,148.8ZM189.19,213a6,6,0,0,1-2.19,8.2,5.9,5.9,0,0,1-3,.81,6,6,0,0,1-5.2-3,59,59,0,0,0-101.62,0,6,6,0,1,1-10.38-6A70.1,70.1,0,0,1,103,182.55a46,46,0,1,1,50.1,0A70.1,70.1,0,0,1,189.19,213ZM128,178a34,34,0,1,0-34-34A34,34,0,0,0,128,178ZM70,120a6,6,0,0,0-6-6A26,26,0,1,1,89.18,81.49a6,6,0,1,0,11.62-3,38,38,0,1,0-59.91,39.63A65.69,65.69,0,0,0,11.2,140.4a6,6,0,1,0,9.6,7.2A53.58,53.58,0,0,1,64,126,6,6,0,0,0,70,120Z"], ["M64.12,147.8a4,4,0,0,1-4,4.2H16a8,8,0,0,1-7.8-6.17,8.35,8.35,0,0,1,1.62-6.93A67.79,67.79,0,0,1,37,117.51a40,40,0,1,1,66.46-35.8,3.94,3.94,0,0,1-2.27,4.18A64.08,64.08,0,0,0,64,144C64,145.28,64,146.54,64.12,147.8Zm182-8.91A67.76,67.76,0,0,0,219,117.51a40,40,0,1,0-66.46-35.8,3.94,3.94,0,0,0,2.27,4.18A64.08,64.08,0,0,1,192,144c0,1.28,0,2.54-.12,3.8a4,4,0,0,0,4,4.2H240a8,8,0,0,0,7.8-6.17A8.33,8.33,0,0,0,246.17,138.89Zm-89,43.18a48,48,0,1,0-58.37,0A72.13,72.13,0,0,0,65.07,212,8,8,0,0,0,72,224H184a8,8,0,0,0,6.93-12A72.15,72.15,0,0,0,157.19,182.07Z"]],
162
162
  'user-plus': [["M254,136a6,6,0,0,1-6,6H230v18a6,6,0,0,1-12,0V142H200a6,6,0,0,1,0-12h18V112a6,6,0,0,1,12,0v18h18A6,6,0,0,1,254,136Zm-57.41,60.14a6,6,0,1,1-9.18,7.72C166.9,179.45,138.69,166,108,166s-58.89,13.45-79.41,37.86a6,6,0,0,1-9.18-7.72C35.14,177.41,55,164.48,77,158.25a66,66,0,1,1,62,0C161,164.48,180.86,177.41,196.59,196.14ZM108,154a54,54,0,1,0-54-54A54.06,54.06,0,0,0,108,154Z"], ["M256,136a8,8,0,0,1-8,8H232v16a8,8,0,0,1-16,0V144H200a8,8,0,0,1,0-16h16V112a8,8,0,0,1,16,0v16h16A8,8,0,0,1,256,136ZM144,157.68a68,68,0,1,0-71.9,0c-20.65,6.76-39.23,19.39-54.17,37.17A8,8,0,0,0,24,208H192a8,8,0,0,0,6.13-13.15C183.18,177.07,164.6,164.44,144,157.68Z"]],
163
+ 'caret-up': [["M212.24,164.24a6,6,0,0,1-8.48,0L128,88.49,52.24,164.24a6,6,0,0,1-8.48-8.48l80-80a6,6,0,0,1,8.48,0l80,80A6,6,0,0,1,212.24,164.24Z"], ["M215.39,163.06A8,8,0,0,1,208,168H48a8,8,0,0,1-5.66-13.66l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,215.39,163.06Z"]],
164
+ 'arrow-right': [["M220.24,132.24l-72,72a6,6,0,0,1-8.48-8.48L201.51,134H40a6,6,0,0,1,0-12H201.51L139.76,60.24a6,6,0,0,1,8.48-8.48l72,72A6,6,0,0,1,220.24,132.24Z"], ["M221.66,133.66l-72,72A8,8,0,0,1,136,200V136H40a8,8,0,0,1,0-16h96V56a8,8,0,0,1,13.66-5.66l72,72A8,8,0,0,1,221.66,133.66Z"]],
165
+ 'x': [["M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z"], ["M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z"]],
166
+ 'plus': [["M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z"], ["M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z"]],
167
+ 'dots-three': [["M138,128a10,10,0,1,1-10-10A10,10,0,0,1,138,128ZM60,118a10,10,0,1,0,10,10A10,10,0,0,0,60,118Zm136,0a10,10,0,1,0,10,10A10,10,0,0,0,196,118Z"], ["M224,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V96A16,16,0,0,0,224,80ZM60,140a12,12,0,1,1,12-12A12,12,0,0,1,60,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,196,140Z"]],
163
168
  };
@@ -123,6 +123,8 @@ export declare function timelineReads<V extends ReadView>(names: {
123
123
  export interface ReadAsk {
124
124
  readonly path: string;
125
125
  readonly body: Record<string, unknown>;
126
+ /** What the read is where it is not a page's own: a related list's (the `x-mistri-read` a list asking alone would carry), so a read audit says so. */
127
+ readonly kind?: 'related';
126
128
  }
127
129
  /**
128
130
  * The fields a section shows when it names none. In the Workbench, every
@@ -368,11 +368,14 @@ export function recordPageReads(names, page, base, plans, key, options) {
368
368
  const parts = [{ part: 'root', columns: probeColumns(names, base) }];
369
369
  const reads = [];
370
370
  const planOf = (index) => plans.find((plan) => plan.index === index);
371
- const view = (body) => reads.push({ path: '/api/view/run', body });
372
- const breakdown = (def) => reads.push({ path: '/api/breakdown', body: { def } });
371
+ /* A list section is a related list: what it asks, it asks as one (a read audit names the door `related`). */
372
+ let kind;
373
+ const view = (body) => reads.push({ path: '/api/view/run', body, ...(kind && { kind }) });
374
+ const breakdown = (def) => reads.push({ path: '/api/breakdown', body: { def }, ...(kind && { kind }) });
373
375
  page.sections.forEach((section, index) => {
374
376
  if (section.hidden || !drawn.has(index))
375
377
  return;
378
+ kind = section.kind === 'list' ? 'related' : undefined;
376
379
  if (section.when)
377
380
  reads.push({ path: '/api/run', body: whenBody(base, key, section.when) });
378
381
  const plan = planOf(index);
@@ -435,7 +438,7 @@ export function recordPageReads(names, page, base, plans, key, options) {
435
438
  case 'list': {
436
439
  /* A grouped list asks its groups first; each group's rows are asked of the keys that come back. */
437
440
  if (section.group && plan.groups) {
438
- reads.push({ path: '/api/breakdown', body: groupsBody(plan.groups, 0) });
441
+ reads.push({ path: '/api/breakdown', body: groupsBody(plan.groups, 0), kind: 'related' });
439
442
  if (plan.totals)
440
443
  breakdown(plan.totals);
441
444
  return;
@@ -456,7 +459,7 @@ export function recordPageReads(names, page, base, plans, key, options) {
456
459
  for (const run of runs) {
457
460
  const body = relatedCountsBody(names.schema, run.map((index) => page.sections[index]), base, key);
458
461
  if (body)
459
- reads.push({ path: '/api/counts', body });
462
+ reads.push({ path: '/api/counts', body, kind: 'related' });
460
463
  }
461
464
  return { row: [...new Set(parts.flatMap((part) => part.columns))], parts, reads };
462
465
  }
@@ -50,7 +50,9 @@ export function unknownKey(key, takes, homes = []) {
50
50
  const near = found !== undefined && (d <= 1 || d < Math.min(key.length, found.length) / 2) ? found : undefined;
51
51
  const slip = near !== undefined && d <= 1;
52
52
  const where = homes.length > 1 ? `${homes.slice(0, -1).join(', ')} or ${homes[homes.length - 1]}` : homes[0];
53
- const hint = where && !slip ? ` "${key}" belongs ${where}.` : near ? ` Did you mean "${near}"?` : '';
53
+ /* `required` is the word reached for where the word is `optional`: a field is asked unless it says otherwise. */
54
+ const opposite = key === 'required' && takes.includes('optional') ? ' Did you mean "optional: true"? A field is required unless it says so.' : '';
55
+ const hint = opposite ? opposite : where && !slip ? ` "${key}" belongs ${where}.` : near ? ` Did you mean "${near}"?` : '';
54
56
  return `has no "${key}".${hint} It takes: ${takes.join(', ')}`;
55
57
  }
56
58
  /** A short list for an error message; long lists help nobody. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/engine",
3
- "version": "1.0.0-rc.29",
3
+ "version": "1.0.0-rc.31",
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
@@ -216,6 +216,8 @@ export interface AppFormCommandReference {
216
216
  /** Its signed-in form prepares its starting values as it opens: the command declares `initial`, or an input starts
217
217
  as the reader (`default: me`). */
218
218
  prepares?: true;
219
+ /** What its form and button are called (`defineCommand({ label })`); left out, the client says the command's name as words. */
220
+ label?: string;
219
221
  }
220
222
 
221
223
  export interface AppUpdateAction<Label extends string | AppMessageRef = string> {