@mistriwork/engine 1.0.0-rc.23 → 1.0.0-rc.28

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.
@@ -122,6 +122,11 @@ export interface QueryRequest {
122
122
  export interface ViewResult extends QueryResult {
123
123
  resolved: CompiledColumn[];
124
124
  joins: CompiledJoin[];
125
+ /** Stitched references whose target could not be read (an adapter or transport error): the rows are whole, those labels are the raw keys. */
126
+ partial?: Array<{
127
+ reference: string;
128
+ reason: string;
129
+ }>;
125
130
  }
126
131
  /**
127
132
  * What a breakdown returns.
@@ -3,8 +3,8 @@ export declare class CommandInputError extends Error {
3
3
  readonly field?: string;
4
4
  constructor(field?: string);
5
5
  }
6
- /** The bound on one command request, envelope included. */
7
- export declare const MAX_COMMAND_BYTES = 65536;
6
+ /** The bound on one command request, envelope included. A text input may be 65,536 characters (up to four bytes each, and escaped), so the envelope holds eight times that. */
7
+ export declare const MAX_COMMAND_BYTES = 524288;
8
8
  /** Names that belong to Object.prototype, never to data. */
9
9
  export declare const reservedKeys: ReadonlySet<string>;
10
10
  export type Json = null | boolean | number | string | readonly Json[] | {
@@ -26,8 +26,8 @@ export class CommandInputError extends Error {
26
26
  this.field = field;
27
27
  }
28
28
  }
29
- /** The bound on one command request, envelope included. */
30
- export const MAX_COMMAND_BYTES = 65_536;
29
+ /** The bound on one command request, envelope included. A text input may be 65,536 characters (up to four bytes each, and escaped), so the envelope holds eight times that. */
30
+ export const MAX_COMMAND_BYTES = 524_288;
31
31
  const MAX_DEPTH = 16;
32
32
  const MAX_NODES = 10_000;
33
33
  /** Names that belong to Object.prototype, never to data. */
@@ -52,6 +52,7 @@ export declare class HttpAdapter implements Adapter {
52
52
  operation(table: string, kind: 'list' | 'item', params: Record<string, string>): Promise<HttpOperationReply>;
53
53
  runView(view: ViewDef, offset?: number): Promise<ViewResult>;
54
54
  private lookUp;
55
+ private fanOut;
55
56
  query(request: QueryRequest): Promise<QueryResult>;
56
57
  private resource;
57
58
  private columns;
@@ -336,9 +336,43 @@ export class HttpAdapter {
336
336
  }
337
337
  return { rows: found, ...(values.length ? { read: `GET ${target.item} for ${values.length} ${target.name}` } : {}) };
338
338
  }
339
+ /* A list of keys the API cannot take as one list (`in` undeclared) is asked a key at a time, as a followed reference
340
+ is: each from its item path, in the same bounded batches. The stitched read of another source's reference
341
+ (appStitchedReads.ts) is the caller. */
342
+ async fanOut(request, resource) {
343
+ if (request.filter?.groups.length !== 1)
344
+ return undefined;
345
+ const [group] = request.filter.groups;
346
+ const many = group.find((condition) => condition.op === 'in' && Array.isArray(condition.value));
347
+ if (!many || resource.filters[many.column]?.ops.includes('in'))
348
+ return undefined;
349
+ /* Only the key: its rows are one each, so a request per value loses nothing. Another column's rows are many, and
350
+ a page of each would be cut short; that stays a refusal naming what the API can do. */
351
+ if (many.column !== resource.key)
352
+ return undefined;
353
+ const started = performance.now();
354
+ const values = [...new Set(many.value.map(String))];
355
+ if (values.length > MAX_LOOKUPS_PER_READ) {
356
+ throw new Refusal(`${resource.name} is asked for ${values.length} different ${many.column} at once, more than the ${MAX_LOOKUPS_PER_READ} an API is asked for ` +
357
+ `(it takes one ${many.column} per request). Show fewer rows.`, { columns: [many.column] });
358
+ }
359
+ const asked = new Map();
360
+ for (let start = 0; start < values.length; start += LOOKUP_BATCH) {
361
+ await Promise.all(values.slice(start, start + LOOKUP_BATCH).map(async (value) => {
362
+ const each = group.map((condition) => (condition === many ? { column: many.column, op: '=', value } : condition));
363
+ // Two rows at most per key: a key the API holds twice is seen as shared.
364
+ asked.set(value, await this.query({ ...request, filter: { groups: [each] }, limit: Math.min(request.limit, 2), offset: 0 }));
365
+ }));
366
+ }
367
+ const results = values.map((value) => asked.get(value));
368
+ return this.result(this.columns(resource, request.columns), results.flatMap((result) => result.rows).slice(request.offset, request.offset + request.limit), started, resource.list, new URLSearchParams());
369
+ }
339
370
  async query(request) {
340
371
  const started = performance.now();
341
372
  const resource = this.resource(request.table);
373
+ const fanned = await this.fanOut(request, resource);
374
+ if (fanned)
375
+ return fanned;
342
376
  const columns = this.columns(resource, request.columns);
343
377
  const conditions = this.conditions(resource, request.filter);
344
378
  const byKey = conditions.length === 1 && conditions[0].column === resource.key && conditions[0].op === '=' ? conditions[0] : undefined;
@@ -236,6 +236,9 @@ export function describedSchema(description, label, readAt = new Date()) {
236
236
  ...(resource.comment ? { comment: resource.comment } : {}),
237
237
  // What the API documents a filter for; the explorer offers boxes for these alone.
238
238
  filterable: Object.keys(resource.filters),
239
+ filterIn: Object.entries(resource.filters)
240
+ .filter(([, filter]) => filter.ops.includes('in'))
241
+ .map(([column]) => column),
239
242
  // The columns its documented sort values name ("-shipped_at" sorts by shipped_at), in the spellings the adapter reads.
240
243
  sortable: [
241
244
  ...new Set((resource.sort?.values ?? []).map((value) => value.replace(/^[-+]/, '').replace(/(?::| |_)(?:asc|desc)$/, ''))),
@@ -108,6 +108,8 @@ interface ShellTitle {
108
108
  manifest: string;
109
109
  register: string;
110
110
  };
111
+ /** The App declared `ui.microphone`: its pages may ask for the microphone, from this origin alone (`pagePermissions`). */
112
+ microphone?: true;
111
113
  /** The scheme that look says (clientSurface.ts lookSchemeFor), said in the page so it is dark from its first paint. */
112
114
  scheme?: 'dark' | 'dark-only';
113
115
  /** The page's colours in each mode (clientSurface.ts lookGroundsFor), written as `color-scheme` and `theme-color`. */
@@ -9,7 +9,7 @@ import { headingWeight, inheritThemePreset, lookNavRole } from '../shared/themeP
9
9
  import { typeTokens } from '../shared/themeType.js';
10
10
  import { fieldEdge } from '../shared/themeColor.js';
11
11
  import { recipeAttributes } from '../shared/themeRecipes.js';
12
- import { APP_PAGE_PERMISSIONS_POLICY } from './http/baselineHeaders.js';
12
+ import { APP_PAGE_MICROPHONE_PERMISSIONS_POLICY, APP_PAGE_PERMISSIONS_POLICY } from './http/baselineHeaders.js';
13
13
  const MIME = {
14
14
  '.html': 'text/html; charset=utf-8',
15
15
  '.js': 'text/javascript; charset=utf-8',
@@ -116,8 +116,11 @@ function withFrameAncestors(policy, origins) {
116
116
  /**
117
117
  * An App's page may use the camera (the scan input); the database browser's
118
118
  * has no such input and keeps the baseline's refusal (http/baselineHeaders.ts).
119
+ * The microphone is the App's to ask for (`ui.microphone`), never the default.
119
120
  */
120
- const pagePermissions = (shell) => shell?.workbench ? {} : { 'permissions-policy': APP_PAGE_PERMISSIONS_POLICY };
121
+ const pagePermissions = (shell) => shell?.workbench
122
+ ? {}
123
+ : { 'permissions-policy': shell?.microphone ? APP_PAGE_MICROPHONE_PERMISSIONS_POLICY : APP_PAGE_PERMISSIONS_POLICY };
121
124
  /** A page's whole policy: its own, the served Apps' egress, and who may frame it. */
122
125
  const pagePolicy = (policy, shell) => shell?.unframed
123
126
  ? withEgress(policy, shell.egress).replace("frame-ancestors 'self'", "frame-ancestors 'none'")
@@ -99,6 +99,7 @@ export function withoutHiddenColumns(schema, rules, name) {
99
99
  ...(cut ? { [CONNECTION_HIDDEN]: [...cut] } : {}),
100
100
  ...(original.deletable !== undefined ? { deletable: original.deletable } : {}),
101
101
  ...(table.filterable ? { filterable: keep(table.id, table.filterable) } : {}),
102
+ ...(table.filterIn ? { filterIn: keep(table.id, table.filterIn) } : {}),
102
103
  ...(table.sortable ? { sortable: keep(table.id, table.sortable) } : {}),
103
104
  };
104
105
  }),
@@ -12,7 +12,8 @@
12
12
  * own HTML (clientHttp.ts) replaces this with `APP_PAGE_PERMISSIONS_POLICY`,
13
13
  * which lets its own origin ask for the camera: the scan input
14
14
  * (`field.text({ as: 'scan' })`) reads a code through `getUserMedia`, and
15
- * a form with one can be a signed-in page or a public one.
15
+ * a form with one can be a signed-in page or a public one. An App that
16
+ * declares `ui.microphone` gets `APP_PAGE_MICROPHONE_PERMISSIONS_POLICY`.
16
17
  * - `Strict-Transport-Security`, only on an answer that arrived over https
17
18
  * (trust.ts `arrivedOverHttps`): the socket's own TLS, an https public
18
19
  * address, or a proxy this server trusts saying it forwarded https. A
@@ -31,6 +32,14 @@ export declare const PERMISSIONS_POLICY: string;
31
32
  * the baseline — and a frame from another origin is still not granted it.
32
33
  */
33
34
  export declare const APP_PAGE_PERMISSIONS_POLICY: string;
35
+ /**
36
+ * An App that declares `ui.microphone: true` (a voice note, a dictated field in
37
+ * its own component): the App page's policy with the microphone allowed for
38
+ * this origin alone too. Opt-in per App because a microphone is a prompt the
39
+ * reader never expected from a page that does not record, so no page asks it
40
+ * by default.
41
+ */
42
+ export declare const APP_PAGE_MICROPHONE_PERMISSIONS_POLICY: string;
34
43
  /** A year, and the names under this one: the time browsers ask of a name kept on https. */
35
44
  export declare const STRICT_TRANSPORT = "max-age=31536000; includeSubDomains";
36
45
  export declare function setBaselineHeaders(req: Pick<IncomingMessage, 'headers' | 'socket'>, res: ServerResponse, trustedProxies?: readonly ProxyRange[]): void;
@@ -10,6 +10,14 @@ export const PERMISSIONS_POLICY = 'camera=(), microphone=(), geolocation=(), pay
10
10
  * the baseline — and a frame from another origin is still not granted it.
11
11
  */
12
12
  export const APP_PAGE_PERMISSIONS_POLICY = PERMISSIONS_POLICY.replace('camera=()', 'camera=(self)');
13
+ /**
14
+ * An App that declares `ui.microphone: true` (a voice note, a dictated field in
15
+ * its own component): the App page's policy with the microphone allowed for
16
+ * this origin alone too. Opt-in per App because a microphone is a prompt the
17
+ * reader never expected from a page that does not record, so no page asks it
18
+ * by default.
19
+ */
20
+ export const APP_PAGE_MICROPHONE_PERMISSIONS_POLICY = APP_PAGE_PERMISSIONS_POLICY.replace('microphone=()', 'microphone=(self)');
13
21
  /** A year, and the names under this one: the time browsers ask of a name kept on https. */
14
22
  export const STRICT_TRANSPORT = 'max-age=31536000; includeSubDomains';
15
23
  export function setBaselineHeaders(req, res, trustedProxies = []) {
@@ -89,7 +89,7 @@ export async function atlasBinary(projectDir, say, fetcher = download, platform
89
89
  async function download(url) {
90
90
  const response = await fetch(url);
91
91
  if (!response.ok)
92
- throw new Error(`could not fetch Atlas from ${url}: HTTP ${response.status}.`);
92
+ 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
93
  return new Uint8Array(await response.arrayBuffer());
94
94
  }
95
95
  /**
@@ -525,6 +525,7 @@ export async function dispatchResourceReadHttp(path, body, adapter, schema, opti
525
525
  resolved: result.resolved,
526
526
  joins: result.joins,
527
527
  rows: result.rows,
528
+ ...(result.partial ? { partial: result.partial } : {}),
528
529
  ms: result.ms,
529
530
  sql: result.sql,
530
531
  explain: explainView(schema, { ...merged, limit }, styleFor(schema)),
@@ -589,6 +590,7 @@ async function runViewForBar(adapter, schema, view, body, app, countMode = 'exac
589
590
  resolved: dropped.size ? result.resolved?.filter((column) => !dropped.has(column.path)) : result.resolved,
590
591
  joins: result.joins,
591
592
  rows: settled?.rows ?? result.rows,
593
+ ...(result.partial ? { partial: result.partial } : {}),
592
594
  ...(settled?.bounds ? { bounds: settled.bounds } : {}),
593
595
  ...(paging?.continuation ? { keyset: true } : {}),
594
596
  ms: result.ms,
@@ -92,7 +92,8 @@ export const THEME_PRESETS = [
92
92
  "fonts": {
93
93
  "ui": "Barlow, \"Barlow Fallback\", \"Helvetica Neue\", Arial, sans-serif",
94
94
  "data": "Barlow, \"Barlow Fallback\", \"Helvetica Neue\", Arial, sans-serif",
95
- "heading": "\"Barlow Semi Condensed\", \"Barlow Semi Condensed Fallback\", Barlow, \"Arial Narrow\", sans-serif"
95
+ "heading": "\"Barlow Semi Condensed\", \"Barlow Semi Condensed Fallback\", Barlow, \"Arial Narrow\", sans-serif",
96
+ "figures": "'IBM Plex Mono', 'IBM Plex Mono Fallback', ui-monospace, Menlo, monospace"
96
97
  },
97
98
  "radius": {
98
99
  "control": "2px",
@@ -274,7 +275,8 @@ export const THEME_PRESETS = [
274
275
  "fonts": {
275
276
  "ui": "Inter, \"Inter Fallback\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif",
276
277
  "data": "Inter, \"Inter Fallback\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif",
277
- "heading": "Inter, \"Inter Fallback\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif"
278
+ "heading": "Inter, \"Inter Fallback\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif",
279
+ "figures": "'IBM Plex Mono', 'IBM Plex Mono Fallback', ui-monospace, Menlo, monospace"
278
280
  },
279
281
  "radius": {
280
282
  "control": "8px",
@@ -412,7 +414,8 @@ export const THEME_PRESETS = [
412
414
  "fonts": {
413
415
  "ui": "\"Helvetica Neue\", Helvetica, Arial, ui-sans-serif, sans-serif",
414
416
  "data": "\"Helvetica Neue\", Helvetica, Arial, ui-sans-serif, sans-serif",
415
- "heading": "\"Helvetica Neue\", Helvetica, Arial, ui-sans-serif, sans-serif"
417
+ "heading": "\"Helvetica Neue\", Helvetica, Arial, ui-sans-serif, sans-serif",
418
+ "figures": "'IBM Plex Mono', 'IBM Plex Mono Fallback', ui-monospace, Menlo, monospace"
416
419
  },
417
420
  "radius": {
418
421
  "control": "0px",
@@ -552,7 +555,8 @@ export const THEME_PRESETS = [
552
555
  "fonts": {
553
556
  "ui": "ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif",
554
557
  "data": "ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif",
555
- "heading": "ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif"
558
+ "heading": "ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif",
559
+ "figures": "'IBM Plex Mono', 'IBM Plex Mono Fallback', ui-monospace, Menlo, monospace"
556
560
  },
557
561
  "radius": {
558
562
  "control": "8px",
@@ -679,7 +683,8 @@ export const THEME_PRESETS = [
679
683
  "fonts": {
680
684
  "ui": "Inter, \"Inter Fallback\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif",
681
685
  "data": "'IBM Plex Mono', ui-monospace, Menlo, monospace",
682
- "heading": "Inter, \"Inter Fallback\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif"
686
+ "heading": "Inter, \"Inter Fallback\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif",
687
+ "figures": "'IBM Plex Mono', 'IBM Plex Mono Fallback', ui-monospace, Menlo, monospace"
683
688
  },
684
689
  "radius": {
685
690
  "control": "2px",
@@ -29,7 +29,7 @@
29
29
  * cannot disagree.
30
30
  */
31
31
  /** No Apps and no prefix: every address is its own. */
32
- export const NO_MOUNT = Object.freeze({ base: '', apps: Object.freeze({}) });
32
+ export const NO_MOUNT = /* @__PURE__ */ Object.freeze({ base: '', apps: /* @__PURE__ */ Object.freeze({}) });
33
33
  /**
34
34
  * First segments the server answers at its root whatever it serves: the API,
35
35
  * the built client's files, `_mistri` — the custom components' host
@@ -24,7 +24,24 @@ const NUMERAL = /^-?\d+(?:\.\d+)?$/;
24
24
  const ISO_DAY = /^\d{4}-\d{2}-\d{2}$/;
25
25
  /* The language's column token: a name outside it could not be read back as a column. */
26
26
  const COLUMN_NAME = /^[\w$]+$/;
27
- const plain = (value) => typeof value === 'object' && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
27
+ /* By shape, not by identity: an object made in another realm (a worker, a bundle's own copy of Object, a test
28
+ sandbox) has a different Object.prototype, and one from Object.create(null) has none; both are plain data. A Date,
29
+ a Map or a class instance says its own tag. */
30
+ const plain = (value) => {
31
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
32
+ return false;
33
+ const prototype = Object.getPrototypeOf(value);
34
+ return prototype === null || prototype === Object.prototype || Object.prototype.toString.call(value) === '[object Object]';
35
+ };
36
+ /* What a refused value actually was, so the sentence names it instead of saying "object" of an object. */
37
+ const described = (value) => {
38
+ if (Array.isArray(value))
39
+ return 'an array';
40
+ if (typeof value !== 'object' || value === null)
41
+ return `a ${typeof value}`;
42
+ const tag = Object.prototype.toString.call(value).slice(8, -1);
43
+ return /^[AEIOU]/.test(tag) ? `an ${tag}` : `a ${tag}`;
44
+ };
28
45
  const kindOf = (column) => (isFlagColumn(column) ? 'boolean' : columnKind(column.type));
29
46
  /* One value in the language, or the sentence that says why it cannot stand for this column. */
30
47
  function written(name, kind, value) {
@@ -143,7 +160,7 @@ export function compileWhere(where, table) {
143
160
  return { text: parts.join(' and ') };
144
161
  }
145
162
  if (!plain(where))
146
- return { error: `A where is an object of column names and values, not ${typeof where}.` };
163
+ return { error: `A where is an object of column names and values, not ${described(where)}.` };
147
164
  const parts = [];
148
165
  for (const [key, value] of Object.entries(where)) {
149
166
  if (value === undefined)
@@ -9,4 +9,15 @@ interface DateWindow {
9
9
  * assert on an exact timestamp instead of a range.
10
10
  */
11
11
  export declare function dateWindow(phrase: string, now: Date): DateWindow | undefined;
12
+ interface DateComparison {
13
+ op: '<' | '<=' | '>' | '>=';
14
+ phrase: string;
15
+ }
16
+ /** A tone key that is a date comparison — `<= today`, `< next 7 days` — or undefined where it is not one. */
17
+ export declare function dateComparison(key: string): DateComparison | undefined;
18
+ /**
19
+ * Whether a day satisfies a date comparison. `offset` is the day's distance from `today` in whole days (negative
20
+ * before it), `today` the App's today as a Date whose local fields read it (what `dateWindow` computes with).
21
+ */
22
+ export declare function dateComparisonHolds(cmp: DateComparison, offset: number, today: Date): boolean;
12
23
  export {};
@@ -99,3 +99,33 @@ export function dateWindow(phrase, now) {
99
99
  }
100
100
  return undefined;
101
101
  }
102
+ /** A tone key that is a date comparison — `<= today`, `< next 7 days` — or undefined where it is not one. */
103
+ export function dateComparison(key) {
104
+ const m = /^(>=|<=|>|<)\s*([a-z][a-z0-9 ]*)$/i.exec(key.trim());
105
+ if (!m)
106
+ return undefined;
107
+ const phrase = m[2].trim().replace(/\s+/g, ' ').toLowerCase();
108
+ if (/\b(?:hour|minute)s?$/.test(phrase) || !dateWindow(phrase, new Date()))
109
+ return undefined;
110
+ return { op: m[1], phrase };
111
+ }
112
+ /**
113
+ * Whether a day satisfies a date comparison. `offset` is the day's distance from `today` in whole days (negative
114
+ * before it), `today` the App's today as a Date whose local fields read it (what `dateWindow` computes with).
115
+ */
116
+ export function dateComparisonHolds(cmp, offset, today) {
117
+ const window = dateWindow(cmp.phrase, today);
118
+ if (!window)
119
+ return false;
120
+ const base = Date.UTC(today.getFullYear(), today.getMonth(), today.getDate());
121
+ const from = (d) => Math.round((Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) - base) / 86_400_000);
122
+ const start = from(window.start);
123
+ const end = from(window.end);
124
+ if (cmp.op === '<')
125
+ return offset < start;
126
+ if (cmp.op === '>=')
127
+ return offset >= start;
128
+ if (cmp.op === '>')
129
+ return offset >= end;
130
+ return offset < end;
131
+ }
@@ -175,6 +175,12 @@ export interface HttpReadFailure {
175
175
  columns?: never;
176
176
  }
177
177
  type HttpRows = Pick<QueryResult, 'columns' | 'rows' | 'ms'>;
178
+ /** A stitched reference whose target source could not be read: its labels are the raw keys. `reference` is the column
179
+ that holds the key; `reason` is a short word (`timeout`, `network`, `unavailable`), never the operator's message. */
180
+ type HttpPartial = Array<{
181
+ reference: string;
182
+ reason: string;
183
+ }>;
178
184
  export type HttpSql = QueryResult['sql'];
179
185
  interface HttpResolvedOrder {
180
186
  order: Order[];
@@ -213,6 +219,7 @@ type RunViewSuccess = HttpRows & HttpPageBounds & {
213
219
  total?: number;
214
220
  limit: number;
215
221
  offset: number;
222
+ partial?: HttpPartial;
216
223
  errors: [];
217
224
  };
218
225
  type ViewSuccess = HttpRows & {
@@ -222,6 +229,7 @@ type ViewSuccess = HttpRows & {
222
229
  more: boolean;
223
230
  limit: number;
224
231
  offset: number;
232
+ partial?: HttpPartial;
225
233
  errors: [];
226
234
  };
227
235
  type BreakdownSuccess = HttpRows & {
@@ -186,6 +186,8 @@ export interface TableMeta {
186
186
  * Absent means any column, as for every database.
187
187
  */
188
188
  filterable?: string[];
189
+ /** Of those, the columns an API also takes a list of values for (`in`): a stitched reference onto one of the others is read a key at a time. */
190
+ filterIn?: string[];
189
191
  /**
190
192
  * The columns the source can sort by, when it cannot sort by every one: an
191
193
  * API sorts by the values it documents (adapters/http). Absent means the
@@ -141,6 +141,7 @@ export function captureScopeCatalog(schema) {
141
141
  'insertable',
142
142
  'sourceDialect',
143
143
  'filterable',
144
+ 'filterIn',
144
145
  'sortable',
145
146
  'countable',
146
147
  ]);
@@ -214,7 +215,7 @@ export function captureScopeCatalog(schema) {
214
215
  return refuse();
215
216
  /* What an API can filter and sort by, and that it reports no totals (adapters/http): evidence for which boxes
216
217
  a list offers, never a grant, so it is carried and left out of the fingerprint. Only columns this table has. */
217
- for (const names of [table.filterable, table.sortable])
218
+ for (const names of [table.filterable, table.filterIn, table.sortable])
218
219
  if (names !== undefined &&
219
220
  (!Array.isArray(names) ||
220
221
  names.some((name) => typeof name !== 'string' || !table.columns.some((column) => column.name === name))))
@@ -25,6 +25,7 @@ export interface ServedMachine {
25
25
  value: string;
26
26
  label: string;
27
27
  final?: true;
28
+ /** Final and frozen: no write changes a record here (the form draws read-only). */ freeze?: true;
28
29
  }[];
29
30
  path: string[];
30
31
  /** Its named groups of states (`status is onBench`), which a menu count reads as it reads `is open`. */
@@ -28,6 +28,8 @@ export interface TextRule {
28
28
  /** What the form says when the rule is not met; a generic sentence otherwise. */
29
29
  message?: string;
30
30
  }
31
+ /** The most characters a rule may name, as a command's text input. */
32
+ export declare const TEXT_RULE_MOST = 65536;
31
33
  /** Which part of a rule a value breaks. */
32
34
  type TextRuleBreak = 'min' | 'max' | 'pattern';
33
35
  /**
@@ -19,7 +19,7 @@
19
19
  import { columnKind } from './schema.js';
20
20
  const TEXT_RULE_KEYS = ['min', 'max', 'pattern', 'message'];
21
21
  /** The most characters a rule may name, as a command's text input. */
22
- const TEXT_RULE_MOST = 16384;
22
+ export const TEXT_RULE_MOST = 65536;
23
23
  const MESSAGE_MOST = 200;
24
24
  const PATTERN_MOST = 500;
25
25
  const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
@@ -15,6 +15,10 @@ const BARLOW_CONDENSED = `"Barlow Semi Condensed", "Barlow Semi Condensed Fallba
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. */
17
17
  const PLEX_MONO = `'IBM Plex Mono', ui-monospace, Menlo, monospace`;
18
+ /** A data column's figures in every built-in look (`fonts.figures`, drawn as `--figures`, themeFamilies.css): Plex Mono, with
19
+ the fallback cut to its measure while it arrives. A theme that names a data face and no figures face draws its figures
20
+ in that face, so each built-in that names a data face says this one, and its figures stay as they were. */
21
+ const FIGURES = `'IBM Plex Mono', 'IBM Plex Mono Fallback', ui-monospace, Menlo, monospace`;
18
22
  /** Spec colors over spec colors: a group (`nav`, `status`, `rules`) role by role, a series whole. */
19
23
  function overColors(base, top) {
20
24
  return {
@@ -159,7 +163,7 @@ const HOUSE = [
159
163
  border: { panel: '1px', rule: '1px' },
160
164
  },
161
165
  type: {
162
- font: { ui: BARLOW, data: BARLOW, heading: BARLOW_CONDENSED },
166
+ font: { ui: BARLOW, data: BARLOW, heading: BARLOW_CONDENSED, figures: FIGURES },
163
167
  base: '14px',
164
168
  roles: {
165
169
  // A page still names itself in the workshop's voice, the condensed bold, in sentence case.
@@ -287,7 +291,7 @@ const HOUSE = [
287
291
  /* The page's name anchors it: 28px, tight; a list's name a step under, and a section's heading 16px, so the
288
292
  page reads title, section, row at a glance. On a flat page the type is the hierarchy the boxes used to be. */
289
293
  type: {
290
- font: { ui: INTER, data: INTER, heading: INTER },
294
+ font: { ui: INTER, data: INTER, heading: INTER, figures: FIGURES },
291
295
  roles: {
292
296
  title: { size: '28px', weight: 600, tracking: '-0.02em' },
293
297
  heading: { size: '24px', tracking: '-0.018em' },
@@ -380,7 +384,7 @@ const HOUSE = [
380
384
  /* Figures and the labels that make the look in the platform's monospace, the labels and the bar's entries in
381
385
  capitals: not data, which a reader who wants monospace picks in Preferences. */
382
386
  type: {
383
- font: { ui: HELVETICA, data: HELVETICA, heading: HELVETICA },
387
+ font: { ui: HELVETICA, data: HELVETICA, heading: HELVETICA, figures: FIGURES },
384
388
  roles: {
385
389
  title: { size: '30px', weight: 700 },
386
390
  label: { face: 'code', case: 'upper' },
@@ -461,7 +465,7 @@ const HOUSE = [
461
465
  },
462
466
  },
463
467
  shape: { radius: { control: '8px', field: '8px' }, elevation: 'soft' },
464
- type: { font: { ui: SANS, data: SANS, heading: SANS }, roles: { title: { weight: 600 } } },
468
+ type: { font: { ui: SANS, data: SANS, heading: SANS, figures: FIGURES }, roles: { title: { weight: 600 } } },
465
469
  // Compact, as Mono and Lumen: see Mono's density.
466
470
  density: 'compact',
467
471
  recipes: {
@@ -558,7 +562,7 @@ const HOUSE = [
558
562
  border: { panel: '1px', rule: '1px' },
559
563
  },
560
564
  type: {
561
- font: { ui: INTER, data: PLEX_MONO, heading: INTER },
565
+ font: { ui: INTER, data: PLEX_MONO, heading: INTER, figures: FIGURES },
562
566
  roles: {
563
567
  title: { size: '26px', weight: 600, tracking: '-0.01em' },
564
568
  heading: { size: '20px', weight: 600, tracking: '-0.018em' },
@@ -45,11 +45,14 @@ export declare const PALETTE_TOKENS: {
45
45
  readonly chart7: '--chart-7';
46
46
  readonly chart8: '--chart-8';
47
47
  };
48
+ /** `figures` is not `--figures` itself: an App's sheet sets that on `.app-mode`, under the root these are written on, from
49
+ `--figures-face` when a theme names one (themeFamilies.css). */
48
50
  export declare const FONT_TOKENS: {
49
51
  readonly ui: '--sans';
50
52
  readonly data: '--mono';
51
53
  readonly heading: '--heading-font';
52
54
  readonly code: '--code';
55
+ readonly figures: '--figures-face';
53
56
  };
54
57
  export declare const RADIUS_TOKENS: {
55
58
  readonly control: '--radius';
@@ -45,7 +45,15 @@ export const PALETTE_TOKENS = {
45
45
  chart7: '--chart-7',
46
46
  chart8: '--chart-8',
47
47
  };
48
- export const FONT_TOKENS = { ui: '--sans', data: '--mono', heading: '--heading-font', code: '--code' };
48
+ /** `figures` is not `--figures` itself: an App's sheet sets that on `.app-mode`, under the root these are written on, from
49
+ `--figures-face` when a theme names one (themeFamilies.css). */
50
+ export const FONT_TOKENS = {
51
+ ui: '--sans',
52
+ data: '--mono',
53
+ heading: '--heading-font',
54
+ code: '--code',
55
+ figures: '--figures-face',
56
+ };
49
57
  export const RADIUS_TOKENS = { control: '--radius', field: '--field-radius', pill: '--pill-radius', panel: '--panel-radius' };
50
58
  /** A panel's edge and the focus ring's width; a rule's and a control's ride in each mode's palette (`--rules-weight`). */
51
59
  const BORDER_TOKENS = { panel: '--panel-border-width', focus: '--focus-ring-width' };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/engine",
3
- "version": "1.0.0-rc.23",
3
+ "version": "1.0.0-rc.28",
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/theme.d.ts CHANGED
@@ -80,7 +80,7 @@ export interface ThemeDefinition {
80
80
  ones, and nothing turns it light. Omitted, it follows the reader and their machine. */
81
81
  scheme?: 'dark' | 'dark-only';
82
82
  /** CSS font-family stacks, each over the machine's faces or the theme's own (`faces`). */
83
- fonts?: { ui?: string; data?: string; heading?: string; code?: string };
83
+ fonts?: { ui?: string; data?: string; heading?: string; code?: string; figures?: string };
84
84
  /** The font files the theme ships, from the App's directory: each an `@font-face` the page declares. */
85
85
  faces?: readonly ThemeFaceDefinition[];
86
86
  /** Pixel lengths: a control's up to 16px, a field's and a pill's up to 12px, a panel's up to 20px; `999px` is a
@@ -538,8 +538,10 @@ interface ThemeSpecCommon {
538
538
  height?: { control?: ThemeControlHeight };
539
539
  };
540
540
  type?: {
541
- /** CSS font-family stacks: the machine's faces, or the families `faces` ships. */
542
- font?: string | { ui?: string; data?: string; heading?: string; code?: string };
541
+ /** CSS font-family stacks: the machine's faces, or the families `faces` ships. `figures` is the face of the ids,
542
+ codes, numbers and dates a table's cells and a record's fields set apart: omitted, it follows `data` when the
543
+ theme names one, and is the platform's Plex Mono when it names neither. */
544
+ font?: string | { ui?: string; data?: string; heading?: string; code?: string; figures?: string };
543
545
  /** Font files from the App's directory, each one `@font-face` (at most 12). The heading's face is preloaded. */
544
546
  faces?: readonly ThemeFace[];
545
547
  /** The size an App's text is drawn at, 13px to 16px; every size grows with it, the roles' too. Omitted, 13px. */