@mistriwork/engine 1.0.0-rc.17 → 1.0.0-rc.18

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.
Files changed (63) hide show
  1. package/dist/adapters/adapter.d.ts +35 -2
  2. package/dist/adapters/adapter.js +32 -1
  3. package/dist/adapters/postgres.js +8 -4
  4. package/dist/adapters/scoped/scopedReads.js +23 -5
  5. package/dist/adapters/scoped/sqliteTriggers.js +65 -38
  6. package/dist/adapters/sqlite.js +8 -4
  7. package/dist/server/columnGrants.d.ts +5 -0
  8. package/dist/server/connections.d.ts +1 -0
  9. package/dist/server/connections.js +13 -3
  10. package/dist/server/http/firstPaint.d.ts +5 -1
  11. package/dist/server/http/firstPaint.js +4 -4
  12. package/dist/server/httpConnection.d.ts +4 -2
  13. package/dist/server/httpConnection.js +10 -3
  14. package/dist/server/journalStore.d.ts +2 -2
  15. package/dist/server/journalStore.js +33 -10
  16. package/dist/server/resourceReadHttp.d.ts +4 -2
  17. package/dist/server/resourceReadHttp.js +40 -4
  18. package/dist/server/resourceReadOperations.d.ts +4 -0
  19. package/dist/server/scaffoldMachine.js +12 -1
  20. package/dist/shared/boardLanes.d.ts +44 -0
  21. package/dist/shared/boardLanes.js +69 -0
  22. package/dist/shared/builtInThemes.js +26 -20
  23. package/dist/shared/dashboardAsks.d.ts +2 -0
  24. package/dist/shared/filter.d.ts +2 -0
  25. package/dist/shared/filter.js +3 -2
  26. package/dist/shared/form.d.ts +24 -1
  27. package/dist/shared/form.js +53 -0
  28. package/dist/shared/keysetPage.js +3 -0
  29. package/dist/shared/listInference.d.ts +91 -0
  30. package/dist/shared/listInference.js +323 -0
  31. package/dist/shared/listPresentations.d.ts +3 -0
  32. package/dist/shared/listQuestion.d.ts +2 -0
  33. package/dist/shared/listQuestion.js +1 -0
  34. package/dist/shared/pageAnatomy.d.ts +27 -3
  35. package/dist/shared/pageAnatomy.js +217 -36
  36. package/dist/shared/pageModel.d.ts +17 -1
  37. package/dist/shared/pageModel.js +8 -0
  38. package/dist/shared/query.d.ts +2 -0
  39. package/dist/shared/query.js +11 -3
  40. package/dist/shared/reads.d.ts +9 -0
  41. package/dist/shared/reads.js +9 -0
  42. package/dist/shared/recordLabel.d.ts +5 -0
  43. package/dist/shared/recordLabel.js +22 -2
  44. package/dist/shared/recordReads.d.ts +30 -0
  45. package/dist/shared/recordReads.js +72 -8
  46. package/dist/shared/referenceSubline.d.ts +18 -0
  47. package/dist/shared/referenceSubline.js +62 -0
  48. package/dist/shared/resourceHttp.d.ts +5 -0
  49. package/dist/shared/rowScope.js +52 -6
  50. package/dist/shared/schema.d.ts +2 -0
  51. package/dist/shared/servedApp.d.ts +18 -0
  52. package/dist/shared/servedApp.js +10 -0
  53. package/dist/shared/themeLooks.js +61 -35
  54. package/dist/shared/themeRecipeWords.d.ts +5 -0
  55. package/dist/shared/themeRecipeWords.js +6 -1
  56. package/dist/shared/themeRecipes.d.ts +5 -0
  57. package/dist/shared/themeRecipes.js +3 -0
  58. package/dist/shared/themeType.js +2 -1
  59. package/dist/shared/view.js +29 -2
  60. package/dist/shared/viewLabels.js +16 -0
  61. package/dist/shared/viewPaths.d.ts +9 -0
  62. package/package.json +4 -1
  63. package/schema/theme.d.ts +8 -4
@@ -134,6 +134,11 @@ export declare const RECIPE_MENU: {
134
134
  readonly band: null;
135
135
  readonly hero: null;
136
136
  };
137
+ readonly filters: {
138
+ readonly dashed: null;
139
+ readonly solid: 'workshop';
140
+ readonly quiet: 'lumen';
141
+ };
137
142
  readonly required: {
138
143
  readonly star: null;
139
144
  readonly 'optional-word': null;
@@ -30,6 +30,9 @@ export const RECIPE_MENU = {
30
30
  steps: { flat: null, tinted: 'lumen', strip: 'lumen' },
31
31
  lanes: { tint: null, tag: 'brand', plain: 'brand' },
32
32
  header: { plain: null, band: null, hero: null },
33
+ /* A list's filter not yet asked for: its own part, so a theme may keep its keyed or raised buttons and still pick the
34
+ adders' edge (Workshop keys them solid; Lumen's are quiet, as its raised buttons were). */
35
+ filters: { dashed: null, solid: 'workshop', quiet: 'lumen' },
33
36
  /* The four below are a form's: their rules are in @mistriwork/ui's forms.css, which arrives with the first control
34
37
  a page draws, so no first stylesheet carries them and the menu names no sheet of a look. */
35
38
  required: { star: null, 'optional-word': null },
@@ -26,7 +26,8 @@ export const TYPE_ROLES = {
26
26
  },
27
27
  section: { takes: ['face', 'size', 'tracking', 'weight', 'case', 'features'], size: [12, 20], weights: WEIGHTS },
28
28
  body: { takes: ['leading', 'features'], leading: [1.35, 1.8] },
29
- label: { takes: ['face', 'tracking', 'weight', 'case', 'features'], weights: [400, 500, 600, 700] },
29
+ /* A step either side of the base (text-xs to text-md): a label is filed-under words, never a heading's size. */
30
+ label: { takes: ['face', 'size', 'tracking', 'weight', 'case', 'features'], size: [11, 14], weights: [400, 500, 600, 700] },
30
31
  data: { takes: ['features', 'reach'] },
31
32
  figure: { takes: ['face', 'size', 'tracking', 'weight', 'features'], size: [18, 40], weights: WEIGHTS },
32
33
  nav: { takes: ['face', 'tracking', 'weight', 'case'], weights: [400, 500, 600] },
@@ -35,7 +35,7 @@
35
35
  * a second predicate builder existing to disagree with the first.
36
36
  */
37
37
  import { ANSI_STYLE, buildWhere, collate, orderClauseSql, } from './filter.js';
38
- import { clampLimit, clampOffset, countStatement } from './reads.js';
38
+ import { clampLimit, clampOffset, countStatement, LANE_ROW } from './reads.js';
39
39
  import { aggregateInput, declaredOrder, findTable, } from './schema.js';
40
40
  import { ANY_CONDITION, anyConditions, expandSegments, parseQuery, splitClauseTail } from './query.js';
41
41
  import { stitchedListProblem } from './stitchedPaths.js';
@@ -345,8 +345,33 @@ export function compileView(schema, view, style, offset = 0, scope) {
345
345
  }
346
346
  const limit = clampLimit(view.limit);
347
347
  const skip = clampOffset(offset);
348
+ /* A board's lanes: the partition's path is planned with the rest, before the joins are frozen. */
349
+ const lanes = view.lanes ? { by: qualify(view.lanes.by), most: clampLimit(view.lanes.limit) } : undefined;
348
350
  const joins = plan.clauses();
349
351
  const prefix = relations.finish();
352
+ if (lanes) {
353
+ /* The order is the window's, and so comes first in the statement: its parameters are numbered before the WHERE's. */
354
+ const within = orderClauseSql(order, style, prefix.params.length + 1);
355
+ const filtered = buildWhere(conditions, style, prefix.params.length + within.params.length + 1, qualify, qualify, membership, exists, false, typeOf);
356
+ const n = prefix.params.length + within.params.length + filtered.params.length;
357
+ const [outer, number] = [style.quote('lanes'), style.quote(LANE_ROW)];
358
+ const inner = [
359
+ `SELECT ${select.join(',\n ')},\n ROW_NUMBER() OVER (PARTITION BY ${lanes.by}${within.text}) AS ${number}`,
360
+ ` FROM ${baseRelation} ${style.quote(plan.baseAlias)}`,
361
+ ...joins,
362
+ ...(filtered.text ? [filtered.text] : []),
363
+ ];
364
+ return {
365
+ text: prefix.text +
366
+ `SELECT ${columns.map((column) => `${outer}.${style.quote(column.name)}`).join(', ')}\n FROM (\n${inner.join('\n')}\n) AS ${outer}` +
367
+ ` WHERE ${outer}.${number} <= ${style.placeholder(n + 1)} ORDER BY ${outer}.${number}` +
368
+ ` LIMIT ${style.placeholder(n + 2)} OFFSET ${style.placeholder(n + 3)}`,
369
+ params: [...prefix.params, ...within.params, ...filtered.params, lanes.most, limit, skip],
370
+ columns,
371
+ joins: plan.joins,
372
+ limit,
373
+ };
374
+ }
350
375
  /* The other side of a column comparison is a path like any other: resolved
351
376
  against this catalog, so a reader's pruned graph refuses one it may not
352
377
  read exactly as it refuses the left. */
@@ -582,7 +607,9 @@ export function parseViewQuery(schema, baseId, text, now, options = {}) {
582
607
  (c.other === undefined ? { path: c.column, op: c.op, value: c.value } : { path: c.column, op: c.op, other: c.other }))),
583
608
  },
584
609
  columns: query.columns,
585
- orderBy: query.orderBy.map((o) => aliases.has(o.column) ? { path: o.column, direction: o.direction, alias: true } : { path: o.column, direction: o.direction }),
610
+ orderBy: query.orderBy.map((o) => aliases.has(o.column)
611
+ ? { path: o.column, direction: o.direction, alias: true }
612
+ : { path: o.column, direction: o.direction, ...(o.nulls ? { nulls: o.nulls } : {}) }),
586
613
  limit: query.limit,
587
614
  errors,
588
615
  };
@@ -372,6 +372,8 @@ export function viewPaths(schema, view, plan, style, relations) {
372
372
  .join(' ');
373
373
  return `CASE ${value} ${cases} ELSE COALESCE(${value}, '') END`;
374
374
  }
375
+ if (field.date)
376
+ return dayText(value, style, literal);
375
377
  return `COALESCE(${value}, '')`;
376
378
  };
377
379
  /* A fallback chain is its first alternative with a value: each said as it would alone, an empty text
@@ -387,6 +389,20 @@ export function viewPaths(schema, view, plan, style, relations) {
387
389
  : plainType(schema, view.base, path);
388
390
  return { resolve, qualify, membership, exists, typeOf };
389
391
  }
392
+ const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
393
+ /**
394
+ * A date or a timestamp, as text, said as a day a person reads ("Sep 13, 2026"): a name's `{starts_at|date}`
395
+ * (recordLabel.ts). Read off the text every engine writes a date as — `YYYY-MM-DD`, then any time — with SUBSTR and
396
+ * CASE alone, which all three say alike, so no engine's date functions or session settings enter a name. A value
397
+ * not written that way (an epoch, a typo in a text column) is said as it is stored. The year is always said: a
398
+ * name is read in lists of any age, and the day is the record's as stored, not moved into the reader's zone.
399
+ */
400
+ function dayText(value, style, literal) {
401
+ const month = `CASE SUBSTR(${value}, 6, 2) ${MONTHS.map((word, at) => `WHEN ${literal(String(at + 1).padStart(2, '0'))} THEN ${literal(`${word} `)}`).join(' ')} ELSE '' END`;
402
+ const day = `CASE WHEN SUBSTR(${value}, 9, 1) = '0' THEN SUBSTR(${value}, 10, 1) ELSE SUBSTR(${value}, 9, 2) END`;
403
+ const iso = `SUBSTR(${value}, 5, 1) = '-' AND SUBSTR(${value}, 8, 1) = '-'`;
404
+ return `CASE WHEN ${iso} THEN ${style.concat([month, day, literal(', '), `SUBSTR(${value}, 1, 4)`])} ELSE COALESCE(${value}, '') END`;
405
+ }
390
406
  /* What a stored column is to an expression that reads it: a yes-or-no column native or a 0/1 integer. */
391
407
  function columnRead(column) {
392
408
  if (!column)
@@ -86,6 +86,15 @@ export interface ViewDef {
86
86
  filter?: ViewFilter;
87
87
  orderBy?: ViewOrder[];
88
88
  limit?: number;
89
+ /**
90
+ * Each value of `by` (a path) its first `limit` rows in the view's order, as one statement: a board's lanes
91
+ * (adapter.ts lanesStatement, boardLanes.ts). The page then cuts across the lanes, the first of each before any
92
+ * second. Set by the run route for a board, never by a request's view.
93
+ */
94
+ lanes?: {
95
+ by: string;
96
+ limit: number;
97
+ };
89
98
  /**
90
99
  * The view written down, in the same language.
91
100
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/engine",
3
- "version": "1.0.0-rc.17",
3
+ "version": "1.0.0-rc.18",
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": {
@@ -160,6 +160,7 @@
160
160
  "./shared/appNoun.js": "./dist/shared/appNoun.js",
161
161
  "./shared/autoBucket.js": "./dist/shared/autoBucket.js",
162
162
  "./shared/autoValues.js": "./dist/shared/autoValues.js",
163
+ "./shared/boardLanes.js": "./dist/shared/boardLanes.js",
163
164
  "./shared/breakdown.js": "./dist/shared/breakdown.js",
164
165
  "./shared/breakdowntext.js": "./dist/shared/breakdowntext.js",
165
166
  "./shared/decimals.js": "./dist/shared/decimals.js",
@@ -194,6 +195,7 @@
194
195
  "./shared/keysetPage.js": "./dist/shared/keysetPage.js",
195
196
  "./shared/listEmpty.js": "./dist/shared/listEmpty.js",
196
197
  "./shared/listFilters.js": "./dist/shared/listFilters.js",
198
+ "./shared/listInference.js": "./dist/shared/listInference.js",
197
199
  "./shared/listPresentations.js": "./dist/shared/listPresentations.js",
198
200
  "./shared/listQuestion.js": "./dist/shared/listQuestion.js",
199
201
  "./shared/maskQuoted.js": "./dist/shared/maskQuoted.js",
@@ -223,6 +225,7 @@
223
225
  "./shared/recordReads.js": "./dist/shared/recordReads.js",
224
226
  "./shared/recordview.js": "./dist/shared/recordview.js",
225
227
  "./shared/referenceModel.js": "./dist/shared/referenceModel.js",
228
+ "./shared/referenceSubline.js": "./dist/shared/referenceSubline.js",
226
229
  "./shared/refusal.js": "./dist/shared/refusal.js",
227
230
  "./shared/relatedCreate.js": "./dist/shared/relatedCreate.js",
228
231
  "./shared/resourceHttp.js": "./dist/shared/resourceHttp.js",
package/schema/theme.d.ts CHANGED
@@ -332,6 +332,9 @@ export interface ThemeRecipes {
332
332
  page's ground, on a band of the raised ground from edge to edge, or a band with the record's avatar large beside
333
333
  its title. It paints the box the page placed: it never moves a region, adds to the head or reorders it. */
334
334
  header?: 'plain' | 'band' | 'hero';
335
+ /** A list's filter not yet asked for ("+ Status"): on a dashed hairline, on a solid edge, or with no edge until a
336
+ pointer is over it. Its own part, so a theme picks it apart from its buttons. */
337
+ filters?: 'dashed' | 'solid' | 'quiet';
335
338
  /** A required field's mark: a red star after its label, or the word "(optional)" after the labels of the fields that
336
339
  may be left empty (`aria-required` stays either way). The words are the form's, in the reader's language. */
337
340
  required?: 'star' | 'optional-word';
@@ -455,8 +458,8 @@ type TypeWeight = 400 | 500 | 600 | 700 | 800 | 900;
455
458
 
456
459
  /**
457
460
  * Each kind of text, by what it is for. A role says only what differs from the look; its size is the size at the
458
- * 13px base, and grows with `base`. Body, data, label and navigation text has no size of its own: it follows the
459
- * base. A weight past 700 is for a face the theme ships at that weight (`type.faces`); `check` warns of one it does
461
+ * 13px base, and grows with `base`. Body, data and navigation text has no size of its own: it follows the base. A
462
+ * label's may be set a step either side of it. A weight past 700 is for a face the theme ships at that weight (`type.faces`); `check` warns of one it does
460
463
  * not (theme-type).
461
464
  */
462
465
  export interface ThemeTypeRoles {
@@ -471,8 +474,9 @@ export interface ThemeTypeRoles {
471
474
  section?: { face?: ThemeTypeFace; size?: TypePx; tracking?: TypeEm; weight?: TypeWeight; case?: ThemeTypeCase; features?: readonly ThemeTypeFeature[] };
472
475
  /** Prose, fields and the interface: its leading, 1.35 to 1.8. */
473
476
  body?: { leading?: number; features?: readonly ThemeTypeFeature[] };
474
- /** The short names things are filed under: a column's head, a stat's label, a record's tabs. */
475
- label?: { face?: ThemeTypeFace; tracking?: TypeEm; weight?: 400 | 500 | 600 | 700; case?: ThemeTypeCase; features?: readonly ThemeTypeFeature[] };
477
+ /** The short names things are filed under: a column's head, a stat's label, a record's tabs. 11px to 14px, a step
478
+ either side of the base; omitted, the base (a step under it in capitals). */
479
+ label?: { face?: ThemeTypeFace; size?: TypePx; tracking?: TypeEm; weight?: 400 | 500 | 600 | 700; case?: ThemeTypeCase; features?: readonly ThemeTypeFeature[] };
476
480
  /** A table's cells and a record's values, in the data face; tabular figures stay. `reach: 'figures'` sets only
477
481
  the figures, keys and dates in it (a table's, a field's and a record header's facts), and leaves names and words
478
482
  in the interface face; omitted, every value is in it, and a header's figures too. */