@mistriwork/engine 1.0.0-rc.15 → 1.0.0-rc.16
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/cli/startup.js +7 -2
- package/dist/server/cli/usage.d.ts +2 -0
- package/dist/server/cli/usage.js +12 -1
- package/dist/server/clientHttp.js +20 -3
- package/dist/server/config/profile.d.ts +10 -3
- package/dist/server/config/profile.js +28 -4
- package/dist/server/http/baselineHeaders.d.ts +13 -3
- package/dist/server/http/baselineHeaders.js +6 -0
- package/dist/server/http/frontDoor.d.ts +41 -0
- package/dist/server/http/frontDoor.js +36 -0
- package/dist/server/http/recordCompose.d.ts +3 -0
- package/dist/server/http/recordCompose.js +1 -0
- package/dist/server/http/serverCore.d.ts +2 -2
- package/dist/server/http/serverCore.js +16 -32
- package/dist/server/migrate/cli.js +8 -1
- package/dist/server/migrate/target.d.ts +8 -0
- package/dist/server/migrate/target.js +15 -0
- package/dist/server/seed/seed.js +46 -11
- package/dist/shared/appCards.d.ts +4 -0
- package/dist/shared/appCards.js +5 -0
- package/dist/shared/breakdown.js +8 -2
- package/dist/shared/computed.d.ts +16 -2
- package/dist/shared/computed.js +23 -4
- package/dist/shared/computedValue.js +23 -0
- package/dist/shared/mentionLookup.js +3 -1
- package/dist/shared/page.js +23 -5
- package/dist/shared/pageAnatomy.js +2 -0
- package/dist/shared/pageConfig.d.ts +1 -1
- package/dist/shared/pageConfig.js +68 -18
- package/dist/shared/pageModel.d.ts +42 -5
- package/dist/shared/pagePaths.js +4 -1
- package/dist/shared/pagePlans.d.ts +2 -2
- package/dist/shared/pagePlans.js +3 -3
- package/dist/shared/recordLabel.d.ts +12 -3
- package/dist/shared/recordLabel.js +39 -18
- package/dist/shared/recordReads.d.ts +6 -30
- package/dist/shared/recordReads.js +13 -1
- package/dist/shared/rollups.d.ts +4 -4
- package/dist/shared/rollups.js +1 -1
- package/dist/shared/schema.d.ts +7 -0
- package/dist/shared/schema.js +17 -0
- package/dist/shared/viewLabels.js +22 -17
- package/package.json +3 -2
package/dist/server/seed/seed.js
CHANGED
|
@@ -230,6 +230,9 @@ class Taken {
|
|
|
230
230
|
function textFor(dice, plan, column, person, n, personLike, companyLike) {
|
|
231
231
|
const name = column.name.toLowerCase();
|
|
232
232
|
const table = plan.table;
|
|
233
|
+
/* A uuid column holds a uuid whatever it is called: `code` and `key` are words for text. */
|
|
234
|
+
if (/uuid/i.test(column.type))
|
|
235
|
+
return uuid(dice);
|
|
233
236
|
if (/(^|_)e?mail(_address)?$/.test(name))
|
|
234
237
|
return companyLike && !personLike
|
|
235
238
|
? `hello@${slug(person.company)}.example.com`
|
|
@@ -534,7 +537,7 @@ export async function seedDatabase(adapter, schema, opts) {
|
|
|
534
537
|
if (column.nullable)
|
|
535
538
|
values[column.name] = null;
|
|
536
539
|
else
|
|
537
|
-
|
|
540
|
+
throw new SeedRefusal(`${table.name}.${column.name} references ${ref.table}.${ref.column}, which has no rows to point at, so no ${table.name} row can be made.`);
|
|
538
541
|
continue;
|
|
539
542
|
}
|
|
540
543
|
/* The first rows go one to each parent, so none is childless; the rest favor a few, as a busy doctor or a
|
|
@@ -548,8 +551,21 @@ export async function seedDatabase(adapter, schema, opts) {
|
|
|
548
551
|
let order = ordersOf.get(column.name);
|
|
549
552
|
if (!order)
|
|
550
553
|
ordersOf.set(column.name, (order = crowd(dice, options)));
|
|
551
|
-
|
|
552
|
-
|
|
554
|
+
/* A reference that is unique (a primary key that is also a foreign key: a profile is its customer's) draws
|
|
555
|
+
each parent once, whatever the reference is called or typed; it is never made distinct by editing the key. */
|
|
556
|
+
if ((table.unique ?? []).includes(column.name) || (column.primaryKey && primary.length === 1)) {
|
|
557
|
+
const free = order.rows.find((row) => !taken.has(`${table.id}.${column.name}`, row[ref.column]));
|
|
558
|
+
if (!free) {
|
|
559
|
+
if (made > 0) {
|
|
560
|
+
ok = false;
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
throw new SeedRefusal(`${table.name}.${column.name} is unique and references ${ref.table}.${ref.column}, which has ${options.length} ${options.length === 1 ? 'row' : 'rows'}` +
|
|
564
|
+
` and every one already has a ${table.name} row, so there is no key left to give it.` +
|
|
565
|
+
' Add rows to the parent, or leave this table out.');
|
|
566
|
+
}
|
|
567
|
+
parents.set(column.name, free);
|
|
568
|
+
values[column.name] = free[ref.column];
|
|
553
569
|
continue;
|
|
554
570
|
}
|
|
555
571
|
const parent = covering ? order.rows[made] : order.pick(dice);
|
|
@@ -690,30 +706,49 @@ export async function seedDatabase(adapter, schema, opts) {
|
|
|
690
706
|
}
|
|
691
707
|
}
|
|
692
708
|
}
|
|
693
|
-
/* Never repeat what must be unique: a second "Ada Lam" gets a number, a
|
|
709
|
+
/* Never repeat what must be unique, in the column's own terms: a second "Ada Lam" gets a number, a uuid a fresh
|
|
710
|
+
uuid, a date the next day, an integer the next integer; a second pair is skipped. A reference is drawn above. */
|
|
694
711
|
for (const column of table.unique ?? []) {
|
|
695
712
|
const key = `${table.id}.${column}`;
|
|
696
713
|
const value = values[column];
|
|
697
|
-
if (value === undefined || value === null)
|
|
714
|
+
if (value === undefined || value === null || plan.refs.has(column))
|
|
698
715
|
continue;
|
|
699
716
|
if (!taken.has(key, value))
|
|
700
717
|
continue;
|
|
718
|
+
const meta = table.columns.find((c) => c.name === column);
|
|
719
|
+
const kind = moment(meta, types);
|
|
701
720
|
let changed;
|
|
702
721
|
for (let k = 2; k < 1000 && changed === undefined; k++) {
|
|
703
|
-
const next =
|
|
704
|
-
?
|
|
705
|
-
:
|
|
706
|
-
?
|
|
707
|
-
|
|
722
|
+
const next = /uuid/i.test(meta.type)
|
|
723
|
+
? uuid(dice)
|
|
724
|
+
: kind
|
|
725
|
+
? (() => {
|
|
726
|
+
const at = new Date(String(value));
|
|
727
|
+
return Number.isNaN(at.getTime()) ? undefined : written(new Date(at.getTime() + (k - 1) * DAY), kind);
|
|
728
|
+
})()
|
|
729
|
+
: typeof value === 'number'
|
|
730
|
+
? value + (k - 1)
|
|
731
|
+
: /@/.test(String(value))
|
|
732
|
+
? String(value).replace('@', `${k}@`)
|
|
733
|
+
: `${value} ${k}`;
|
|
734
|
+
if (next === undefined)
|
|
735
|
+
break;
|
|
708
736
|
if (!taken.has(key, next))
|
|
709
737
|
changed = next;
|
|
710
738
|
}
|
|
739
|
+
if (changed === undefined && !meta.nullable)
|
|
740
|
+
throw new SeedRefusal(`${table.name}.${column} must be unique, and no new ${meta.type || 'value'} could be made that is not already taken.`);
|
|
711
741
|
values[column] = changed ?? null;
|
|
712
742
|
}
|
|
713
743
|
const pairKeys = pairs.map(([a, b]) => `${table.id}.${a}+${b}`);
|
|
714
744
|
if (pairs.some(([a, b], i) => values[a] != null && values[b] != null && taken.has(pairKeys[i], `${values[a]}\u0000${values[b]}`)))
|
|
715
745
|
continue;
|
|
716
|
-
const inserted = await tx.insert({ table: table.id, values })
|
|
746
|
+
const inserted = await tx.insert({ table: table.id, values }).catch((error) => {
|
|
747
|
+
if (error instanceof SeedRefusal)
|
|
748
|
+
throw error;
|
|
749
|
+
const column = error.column;
|
|
750
|
+
throw new SeedRefusal(`${table.name}${typeof column === 'string' && column ? `.${column}` : ''}: ${error instanceof Error ? error.message : String(error)}`);
|
|
751
|
+
});
|
|
717
752
|
const row = { ...values, ...(inserted.row ?? {}), ...inserted.key };
|
|
718
753
|
for (const column of table.unique ?? [])
|
|
719
754
|
if (row[column] != null)
|
|
@@ -69,6 +69,10 @@ export interface AppCardsList {
|
|
|
69
69
|
}
|
|
70
70
|
/** How many facts a card carries under its title. */
|
|
71
71
|
export declare const CARDS_MAX_LINES = 4;
|
|
72
|
+
/** How many facts a record header says before the rest wait in its More: the first of them stay in the line. */
|
|
73
|
+
export declare const HEADER_FACTS_SHOWN = 6;
|
|
74
|
+
/** How many a header may name at all; past the line they fold, so an author never moves one into a side block to fit. */
|
|
75
|
+
export declare const HEADER_MAX_FACTS = 12;
|
|
72
76
|
/** One sort key and its direction: "position", "added_at desc". */
|
|
73
77
|
export declare function cardsImageSort(sort: string): {
|
|
74
78
|
column: string;
|
package/dist/shared/appCards.js
CHANGED
|
@@ -27,6 +27,10 @@ import { singularOf } from './unitWord.js';
|
|
|
27
27
|
export const CARDS_MAX_LINES = 4;
|
|
28
28
|
/** How many values a card's facts line says. */
|
|
29
29
|
const CARDS_MAX_FACTS = 6;
|
|
30
|
+
/** How many facts a record header says before the rest wait in its More: the first of them stay in the line. */
|
|
31
|
+
export const HEADER_FACTS_SHOWN = 6;
|
|
32
|
+
/** How many a header may name at all; past the line they fold, so an author never moves one into a side block to fit. */
|
|
33
|
+
export const HEADER_MAX_FACTS = 12;
|
|
30
34
|
/** How many values stand along a card's foot. */
|
|
31
35
|
const CARDS_MAX_FOOTER = 4;
|
|
32
36
|
const CARDS_IMAGE_KEYS = ['about', 'from', 'whose', 'sort'];
|
|
@@ -88,6 +92,7 @@ export function parseFacts(raw, at, key = 'facts', max = CARDS_MAX_FACTS) {
|
|
|
88
92
|
allowKeys(entry, ['column', 'before', 'after'], `${at}, ${key}`, {
|
|
89
93
|
label: 'is now "after" (a word after the value) or "before" (a word before it)',
|
|
90
94
|
position: 'is gone: "before" is a word before the value, "after" a word after it',
|
|
95
|
+
subtitle: 'is the second line of a headline figure (headline(figure, { subtitle })); a fact is one line, so its words go in "before" or "after"',
|
|
91
96
|
});
|
|
92
97
|
const path = entry.column.trim();
|
|
93
98
|
const word = (value, which) => {
|
package/dist/shared/breakdown.js
CHANGED
|
@@ -434,8 +434,14 @@ function compileBreakdownFresh(schema, def, style, offset, scope) {
|
|
|
434
434
|
if (!names.has(o.name)) {
|
|
435
435
|
throw new PathError(`Nothing called "${o.name}" is in this breakdown. It shows: ${[...names].join(', ')}.`, o.name, o.name, 0);
|
|
436
436
|
}
|
|
437
|
-
|
|
438
|
-
|
|
437
|
+
/* An output name is only a name when it stands alone in ORDER BY: inside an expression PostgreSQL reads it as an
|
|
438
|
+
input column, and a key (`hold_id`) that the joined record also has (`holds.hold_id`) is ambiguous there. The
|
|
439
|
+
expression the SELECT list gives that name is what is tested. */
|
|
440
|
+
if (o.emptyLast) {
|
|
441
|
+
const shown = select[columns.findIndex((c) => c.name === o.name)] ?? style.quote(o.name);
|
|
442
|
+
const quoted = ` AS ${style.quote(o.name)}`;
|
|
443
|
+
return `(${shown.endsWith(quoted) ? shown.slice(0, -quoted.length) : shown} IS NULL) ASC`;
|
|
444
|
+
}
|
|
439
445
|
/* An exact sum is text; it sorts by the integer it says, never as text ("9.00" after "10.00"). */
|
|
440
446
|
return `${orderedBy.get(o.name) ?? style.quote(o.name)} ${o.direction === 'desc' ? 'DESC' : 'ASC'}`;
|
|
441
447
|
});
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
*/
|
|
35
35
|
import type { SqlStyle } from './filter.js';
|
|
36
36
|
import type { ColumnMeta, DatabaseSchema } from './schema.js';
|
|
37
|
-
export declare const COMPUTED_TYPES: readonly ['boolean', 'number', 'date'];
|
|
37
|
+
export declare const COMPUTED_TYPES: readonly ['boolean', 'number', 'date', 'text'];
|
|
38
38
|
export type ComputedType = (typeof COMPUTED_TYPES)[number];
|
|
39
39
|
/** A span a date moves by: `3 days`, `term months`. */
|
|
40
40
|
export type ComputedUnit = ComputedSpan['unit'];
|
|
@@ -78,12 +78,26 @@ export type ComputedNode = {
|
|
|
78
78
|
k: 'call';
|
|
79
79
|
fn: ComputedFunction;
|
|
80
80
|
args: ComputedNode[];
|
|
81
|
-
} | {
|
|
81
|
+
} | ComputedJson | {
|
|
82
82
|
k: 'op';
|
|
83
83
|
op: ComputedOp;
|
|
84
84
|
left: ComputedNode;
|
|
85
85
|
right: ComputedNode;
|
|
86
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* A member of a JSON column, read as text: `filters_json.make`, `payload.customer.city`. Authored as a path; the
|
|
89
|
+
* catalog that knows `filters_json` is a JSON column, and no reference, makes it this (appComputed.ts). Each key is
|
|
90
|
+
* an identifier (the tokenizer's word), so it is written into the statement's path literal as it stands. The
|
|
91
|
+
* database is never asked whether the member is there: one that is not has no value.
|
|
92
|
+
* @preview
|
|
93
|
+
*/
|
|
94
|
+
export interface ComputedJson {
|
|
95
|
+
k: 'json';
|
|
96
|
+
/** The table's own JSON column. */
|
|
97
|
+
column: string;
|
|
98
|
+
/** The members walked, outermost first. */
|
|
99
|
+
keys: string[];
|
|
100
|
+
}
|
|
87
101
|
/** The functions an expression may call (computedParse.ts COMPUTED_FUNCTIONS): each written alike on every engine and worked out alike in JavaScript. */
|
|
88
102
|
export type ComputedFunction = 'coalesce' | 'round' | 'min' | 'max' | 'abs';
|
|
89
103
|
interface ComputedSpan {
|
package/dist/shared/computed.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { noteRead } from './query.js';
|
|
2
|
-
export const COMPUTED_TYPES = ['boolean', 'number', 'date'];
|
|
2
|
+
export const COMPUTED_TYPES = ['boolean', 'number', 'date', 'text'];
|
|
3
3
|
/** What a computed column is to anything that reads columns: typed, never written, never a key. */
|
|
4
4
|
export function computedColumnMeta(name, computed) {
|
|
5
5
|
return {
|
|
@@ -43,9 +43,10 @@ export class ComputedError extends Error {
|
|
|
43
43
|
export function computedReads(node) {
|
|
44
44
|
const out = [];
|
|
45
45
|
const walk = (n) => {
|
|
46
|
-
if (n.k === 'path') {
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
if (n.k === 'path' || n.k === 'json') {
|
|
47
|
+
const path = n.k === 'path' ? n.path : n.column;
|
|
48
|
+
if (!out.includes(path))
|
|
49
|
+
out.push(path);
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
52
|
if (n.k === 'op') {
|
|
@@ -78,6 +79,10 @@ export function computedKind(node, kindOf) {
|
|
|
78
79
|
}
|
|
79
80
|
case 'number':
|
|
80
81
|
return 'number';
|
|
82
|
+
case 'json':
|
|
83
|
+
if (!kindOf(n.column))
|
|
84
|
+
throw new Error(`"${n.column}" is not a column here.`);
|
|
85
|
+
return 'text';
|
|
81
86
|
case 'text':
|
|
82
87
|
case 'me':
|
|
83
88
|
case 'nobody':
|
|
@@ -257,6 +262,8 @@ export function compileComputed(computed, style, column, kindOf) {
|
|
|
257
262
|
switch (n.k) {
|
|
258
263
|
case 'path':
|
|
259
264
|
return column(n.path);
|
|
265
|
+
case 'json':
|
|
266
|
+
return jsonMember(column(n.column), n.keys, dialect);
|
|
260
267
|
case 'number':
|
|
261
268
|
return String(n.value);
|
|
262
269
|
case 'text':
|
|
@@ -350,6 +357,18 @@ export function compileComputed(computed, style, column, kindOf) {
|
|
|
350
357
|
}
|
|
351
358
|
return sql(computed.expr);
|
|
352
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* A JSON member as text, alike on both engines: PostgreSQL's `#>>` gives text, and a yes-or-no as `true`/`false`;
|
|
362
|
+
* SQLite's `json_extract` gives a number as a number and a yes-or-no as 1 or 0, so it is said as PostgreSQL says it.
|
|
363
|
+
* An object or an array is its JSON text on both. The keys are identifiers (ComputedJson), never quoted text.
|
|
364
|
+
*/
|
|
365
|
+
function jsonMember(column, keys, dialect) {
|
|
366
|
+
if (dialect === 'postgres')
|
|
367
|
+
return `(${column} #>> '{${keys.join(',')}}')`;
|
|
368
|
+
const at = `'$${keys.map((key) => `."${key}"`).join('')}'`;
|
|
369
|
+
return (`(CASE json_type(${column}, ${at}) WHEN 'true' THEN 'true' WHEN 'false' THEN 'false' ` +
|
|
370
|
+
`ELSE CAST(json_extract(${column}, ${at}) AS TEXT) END)`);
|
|
371
|
+
}
|
|
353
372
|
/** Whether an expression says the instant (`now`), so it comes to a moment rather than a day. */
|
|
354
373
|
export function readsNow(node) {
|
|
355
374
|
if (node.k === 'now' || node.k === 'instant')
|
|
@@ -120,6 +120,8 @@ export function evaluateComputed(node, values, read = (path) => {
|
|
|
120
120
|
const v = read(n.path);
|
|
121
121
|
return v === undefined || v === '' ? null : v;
|
|
122
122
|
}
|
|
123
|
+
case 'json':
|
|
124
|
+
return jsonMember(read(n.column), n.keys);
|
|
123
125
|
case 'op': {
|
|
124
126
|
if (n.op === 'and' || n.op === 'or') {
|
|
125
127
|
const l = truth(value(n.left)), r = truth(value(n.right));
|
|
@@ -168,6 +170,27 @@ export function evaluateComputed(node, values, read = (path) => {
|
|
|
168
170
|
const result = value(node);
|
|
169
171
|
return result === null && isCondition(node) ? false : result;
|
|
170
172
|
}
|
|
173
|
+
/* A JSON member as the statement reads it (computed.ts jsonMember): text, a yes-or-no as `true`/`false`, an object
|
|
174
|
+
or an array as its JSON. The column arrives as its text (SQLite) or already read (PostgreSQL's driver). */
|
|
175
|
+
function jsonMember(stored, keys) {
|
|
176
|
+
let at = stored;
|
|
177
|
+
if (typeof at === 'string') {
|
|
178
|
+
try {
|
|
179
|
+
at = JSON.parse(at);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
for (const key of keys) {
|
|
186
|
+
if (at === null || typeof at !== 'object' || Array.isArray(at) || !Object.hasOwn(at, key))
|
|
187
|
+
return null;
|
|
188
|
+
at = at[key];
|
|
189
|
+
}
|
|
190
|
+
if (at === null || at === undefined)
|
|
191
|
+
return null;
|
|
192
|
+
return typeof at === 'object' ? JSON.stringify(at) : String(at);
|
|
193
|
+
}
|
|
171
194
|
/**
|
|
172
195
|
* A constant expression's value, worked out where a fixed action's `set`
|
|
173
196
|
* writes it (appStamps on the server): `today + 14 days`, `now + 1 week`,
|
|
@@ -24,7 +24,9 @@ export function mentionLabelText(source, row) {
|
|
|
24
24
|
if ('problem' in parsed)
|
|
25
25
|
return '';
|
|
26
26
|
return parsed.parts
|
|
27
|
-
.map((part) =>
|
|
27
|
+
.map((part) => 'text' in part
|
|
28
|
+
? part.text
|
|
29
|
+
: ([part.path, ...(part.or ?? []).map((other) => other.path)].map((path) => said(row[path])).find(Boolean) ?? ''))
|
|
28
30
|
.join('')
|
|
29
31
|
.replace(/\s+/g, ' ')
|
|
30
32
|
.trim();
|
package/dist/shared/page.js
CHANGED
|
@@ -187,6 +187,12 @@ function validated(schema, page) {
|
|
|
187
187
|
error: `${at}: "was" is a number or money column beside the figure; "${section.was}" is ${was.resolved.column.type || 'untyped'}.`,
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
|
+
/* The line under the figure is read from the record, so it must name something there. */
|
|
191
|
+
if (section.subtitle !== undefined) {
|
|
192
|
+
const line = tryResolvePath(schema, page.base, section.subtitle);
|
|
193
|
+
if (!line.resolved)
|
|
194
|
+
return { ...page, error: `${at}: "subtitle" names "${section.subtitle}", ${line.error?.message ?? 'which does not resolve'}` };
|
|
195
|
+
}
|
|
190
196
|
if (section.status !== undefined && !columnOrRollup(base, section.status)) {
|
|
191
197
|
return { ...page, error: `${at}: the header's status "${section.status}" is not a column on ${base.name}.` };
|
|
192
198
|
}
|
|
@@ -229,7 +235,7 @@ function validated(schema, page) {
|
|
|
229
235
|
error: `${here}: "${stream.at}" is ${atCol.type || 'untyped'} — a timeline orders by a date column. See \`mistri docs dates-and-types\`.`,
|
|
230
236
|
};
|
|
231
237
|
}
|
|
232
|
-
for (const path of [stream.
|
|
238
|
+
for (const path of [stream.text, stream.badge, stream.by].filter((p) => Boolean(p))) {
|
|
233
239
|
/* A bare name is a column of `from`; a dotted path walks references
|
|
234
240
|
to a column of the table it reaches, and is judged the way a
|
|
235
241
|
list column is — `author_id.name`, not a chain of references. */
|
|
@@ -334,6 +340,11 @@ function validated(schema, page) {
|
|
|
334
340
|
const problem = relatedMatchProblem(schema, page, section);
|
|
335
341
|
if (problem)
|
|
336
342
|
return { ...page, error: `${at}: ${problem}` };
|
|
343
|
+
if (section.opens) {
|
|
344
|
+
const reference = table.columns.find((column) => column.name === section.opens)?.references;
|
|
345
|
+
if (!reference || !findTable(schema, reference.table))
|
|
346
|
+
return { ...page, error: `${at}: "opens" names "${section.opens}", which is not a reference column of ${table.name}.` };
|
|
347
|
+
}
|
|
337
348
|
}
|
|
338
349
|
if (section.kind === 'metric' && section.fn !== 'count' && !section.column) {
|
|
339
350
|
return { ...page, error: `${at}: "${section.fn}" needs a column to ${section.fn}.` };
|
|
@@ -799,6 +810,7 @@ function createConfig(create) {
|
|
|
799
810
|
export function sectionConfig(s) {
|
|
800
811
|
const common = {
|
|
801
812
|
...(s.title !== undefined ? { title: s.title } : {}),
|
|
813
|
+
...(s.icon ? { icon: s.icon } : {}),
|
|
802
814
|
...(s.region !== undefined ? { region: s.region } : {}),
|
|
803
815
|
...(s.tab !== undefined ? { tab: s.tab } : {}),
|
|
804
816
|
...(s.width && s.width !== 'full' ? { width: s.width } : {}),
|
|
@@ -843,6 +855,7 @@ export function sectionConfig(s) {
|
|
|
843
855
|
show: s.paths ?? [],
|
|
844
856
|
...(s.actions ? { links: s.actions.map((a) => ('view' in a ? (({ view, ...rest }) => ({ ...rest, to: view }))(a) : a)) } : {}),
|
|
845
857
|
...(s.subfigure !== undefined ? { subfigure: s.subfigure } : {}),
|
|
858
|
+
...(s.subtitle !== undefined ? { subtitle: s.subtitle } : {}),
|
|
846
859
|
...(s.was !== undefined ? { was: s.was } : {}),
|
|
847
860
|
...(s.note !== undefined ? { note: s.note } : {}),
|
|
848
861
|
};
|
|
@@ -854,6 +867,7 @@ export function sectionConfig(s) {
|
|
|
854
867
|
...(s.names === false ? { names: false } : {}),
|
|
855
868
|
...(s.presentation ? { presentation: s.presentation } : {}),
|
|
856
869
|
...(s.edit ? { editable: true } : {}),
|
|
870
|
+
...(s.emptyMode ? { empty: s.emptyMode } : {}),
|
|
857
871
|
};
|
|
858
872
|
case 'timeline':
|
|
859
873
|
return {
|
|
@@ -864,8 +878,8 @@ export function sectionConfig(s) {
|
|
|
864
878
|
from: stream.from,
|
|
865
879
|
whose: stream.path,
|
|
866
880
|
at: stream.at,
|
|
867
|
-
|
|
868
|
-
|
|
881
|
+
text: stream.text,
|
|
882
|
+
badge: stream.badge,
|
|
869
883
|
author: stream.by,
|
|
870
884
|
query: stream.filter,
|
|
871
885
|
...(stream.of ? { about: stream.of } : {}),
|
|
@@ -925,7 +939,8 @@ export function sectionConfig(s) {
|
|
|
925
939
|
whose: s.path,
|
|
926
940
|
show: s.labels ? s.columns?.map((column) => (s.labels[column] ? { column, label: s.labels[column] } : column)) : s.columns,
|
|
927
941
|
query: s.filter,
|
|
928
|
-
...(s.empty ? { empty: listEmptyConfig(s.empty) } : {}),
|
|
942
|
+
...(s.emptyMode === 'hide' ? { empty: 'hide' } : s.empty ? { empty: listEmptyConfig(s.empty) } : {}),
|
|
943
|
+
...(s.opens ? { opens: s.opens } : {}),
|
|
929
944
|
sort: s.orderBy?.map((o) => (o.direction === 'desc' ? `${o.column} desc` : o.column)).join(', '),
|
|
930
945
|
};
|
|
931
946
|
return {
|
|
@@ -975,6 +990,7 @@ export function sectionConfig(s) {
|
|
|
975
990
|
: { measure: [s.fn, s.column].filter(Boolean).join(' ') }),
|
|
976
991
|
query: s.filter,
|
|
977
992
|
limit: s.limit,
|
|
993
|
+
...(s.emptyMode ? { empty: s.emptyMode } : {}),
|
|
978
994
|
...(s.format !== undefined ? { format: s.format } : {}),
|
|
979
995
|
...(s.unit !== undefined ? { unit: s.unit } : {}),
|
|
980
996
|
};
|
|
@@ -998,6 +1014,9 @@ export function sectionConfig(s) {
|
|
|
998
1014
|
limit: s.limit,
|
|
999
1015
|
...(s.height !== undefined ? { height: s.height } : {}),
|
|
1000
1016
|
...(s.target !== undefined ? { target: s.target } : {}),
|
|
1017
|
+
...(s.curve ? { curve: s.curve } : {}),
|
|
1018
|
+
...(s.total ? { total: s.total } : {}),
|
|
1019
|
+
...(s.emptyMode ? { empty: s.emptyMode } : {}),
|
|
1001
1020
|
...(s.format !== undefined ? { format: s.format } : {}),
|
|
1002
1021
|
...(s.unit !== undefined ? { unit: s.unit } : {}),
|
|
1003
1022
|
};
|
|
@@ -1007,7 +1026,6 @@ export function sectionConfig(s) {
|
|
|
1007
1026
|
kind: s.kind,
|
|
1008
1027
|
text: s.text,
|
|
1009
1028
|
...(s.variant ? { variant: s.variant } : {}),
|
|
1010
|
-
...(s.icon ? { icon: s.icon } : {}),
|
|
1011
1029
|
...(s.action ? { action: 'view' in s.action ? { label: s.action.label, to: s.action.view } : s.action } : {}),
|
|
1012
1030
|
};
|
|
1013
1031
|
case 'custom':
|
|
@@ -358,6 +358,8 @@ export function withDefaultAside(schema, page) {
|
|
|
358
358
|
shown.add(section.status);
|
|
359
359
|
if (section.was)
|
|
360
360
|
shown.add(section.was.split('.')[0]);
|
|
361
|
+
if (section.subtitle)
|
|
362
|
+
shown.add(section.subtitle.split('.')[0]);
|
|
361
363
|
}
|
|
362
364
|
const name = labelColumn(base);
|
|
363
365
|
const paths = railOf(base.columns.filter((column) => readable(base, column) && column.name !== name && !shown.has(column.name)));
|
|
@@ -15,7 +15,7 @@ export declare const APP_PAGE_KEYS: ("aside" | "base" | "empty" | "layout" | "li
|
|
|
15
15
|
/** The keys each page section kind takes. Anything else is refused by name. A `segment` is read before the
|
|
16
16
|
section is (appSegments.ts unfoldSegments), as its word in `query`. */
|
|
17
17
|
export declare const PAGE_SECTION_KEYS: Record<PageSection['kind'] | 'view' | 'header' | 'current' | 'card' | 'headline', readonly string[]>;
|
|
18
|
-
export declare const STREAM_KEYS: readonly ['from', 'whose', 'at', '
|
|
18
|
+
export declare const STREAM_KEYS: readonly ['from', 'whose', 'at', 'text', 'badge', 'author', 'query', 'about', 'side', 'tone', 'compact'];
|
|
19
19
|
/**
|
|
20
20
|
* One page body: a tablewalk.json page, whose `id` is its own or derives
|
|
21
21
|
* from the name, or an App page, whose id is its key. The body is the same
|