@mistriwork/engine 1.0.0-rc.16 → 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.
- package/README.md +5 -0
- package/dist/adapters/adapter.d.ts +35 -2
- package/dist/adapters/adapter.js +32 -1
- package/dist/adapters/postgres.js +8 -4
- package/dist/adapters/scoped/scopedReads.js +23 -5
- package/dist/adapters/scoped/sqliteTriggers.js +65 -38
- package/dist/adapters/sqlite.js +8 -4
- package/dist/host.d.ts +46 -0
- package/dist/host.js +51 -0
- package/dist/server/columnGrants.d.ts +5 -0
- package/dist/server/connections.d.ts +1 -0
- package/dist/server/connections.js +20 -1
- package/dist/server/http/exportRoute.d.ts +74 -0
- package/dist/server/http/exportRoute.js +206 -169
- package/dist/server/http/firstPaint.d.ts +5 -1
- package/dist/server/http/firstPaint.js +4 -4
- package/dist/server/http/reply.js +6 -0
- package/dist/server/httpConnection.d.ts +4 -2
- package/dist/server/httpConnection.js +10 -3
- package/dist/server/journal.d.ts +35 -6
- package/dist/server/journal.js +79 -8
- package/dist/server/journalStore.d.ts +37 -0
- package/dist/server/journalStore.js +375 -0
- package/dist/server/resourceReadHttp.d.ts +4 -2
- package/dist/server/resourceReadHttp.js +40 -4
- package/dist/server/resourceReadOperations.d.ts +4 -0
- package/dist/server/scaffoldMachine.js +12 -1
- package/dist/shared/appListColumns.d.ts +7 -0
- package/dist/shared/appListColumns.js +13 -0
- package/dist/shared/boardLanes.d.ts +44 -0
- package/dist/shared/boardLanes.js +69 -0
- package/dist/shared/builtInThemes.js +26 -20
- package/dist/shared/dashboardAsks.d.ts +2 -0
- package/dist/shared/filter.d.ts +2 -0
- package/dist/shared/filter.js +3 -2
- package/dist/shared/form.d.ts +24 -1
- package/dist/shared/form.js +53 -0
- package/dist/shared/keysetPage.js +3 -0
- package/dist/shared/listInference.d.ts +91 -0
- package/dist/shared/listInference.js +323 -0
- package/dist/shared/listPresentations.d.ts +3 -0
- package/dist/shared/listQuestion.d.ts +2 -0
- package/dist/shared/listQuestion.js +3 -2
- package/dist/shared/pageAnatomy.d.ts +27 -3
- package/dist/shared/pageAnatomy.js +217 -36
- package/dist/shared/pageModel.d.ts +17 -1
- package/dist/shared/pageModel.js +8 -0
- package/dist/shared/query.d.ts +2 -0
- package/dist/shared/query.js +11 -3
- package/dist/shared/reads.d.ts +9 -0
- package/dist/shared/reads.js +9 -0
- package/dist/shared/recordLabel.d.ts +5 -0
- package/dist/shared/recordLabel.js +22 -2
- package/dist/shared/recordReads.d.ts +30 -0
- package/dist/shared/recordReads.js +101 -19
- package/dist/shared/referenceSubline.d.ts +18 -0
- package/dist/shared/referenceSubline.js +62 -0
- package/dist/shared/resourceHttp.d.ts +5 -0
- package/dist/shared/rowScope.js +52 -6
- package/dist/shared/schema.d.ts +2 -0
- package/dist/shared/servedApp.d.ts +19 -1
- package/dist/shared/servedApp.js +10 -0
- package/dist/shared/themeLooks.js +61 -35
- package/dist/shared/themeRecipeWords.d.ts +5 -0
- package/dist/shared/themeRecipeWords.js +6 -1
- package/dist/shared/themeRecipes.d.ts +5 -0
- package/dist/shared/themeRecipes.js +3 -0
- package/dist/shared/themeType.js +2 -1
- package/dist/shared/view.js +29 -2
- package/dist/shared/viewLabels.js +16 -0
- package/dist/shared/viewPaths.d.ts +9 -0
- package/package.json +6 -1
- package/schema/theme.d.ts +8 -4
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a board asks to draw its lanes, written once for the browser that asks
|
|
3
|
+
* it (mistri client BoardList.tsx, kit TableRoom.tsx) and the first page that
|
|
4
|
+
* asks it ahead of the browser (mistri server firstPaintRooms.ts): a carried
|
|
5
|
+
* answer is found by its question, so the two must ask in the same words.
|
|
6
|
+
*
|
|
7
|
+
* Two reads: every lane's count (and sum) in one breakdown by the lane
|
|
8
|
+
* column, and every lane's first cards in one read windowed by it
|
|
9
|
+
* (`lanes: { by, limit }`, adapter.ts lanesStatement). A lane's "Show more"
|
|
10
|
+
* reads that lane alone.
|
|
11
|
+
*/
|
|
12
|
+
import { currencyPath } from './money.js';
|
|
13
|
+
import { splitQuery } from './clauses.js';
|
|
14
|
+
/** A lane's cards are read this many at a time; "Show more" reads the next. */
|
|
15
|
+
export const LANE_PAGE = 20;
|
|
16
|
+
/** The window over every lane: a page of each of a board's eight lanes and its four final states, at most. */
|
|
17
|
+
const LANE_WINDOW = LANE_PAGE * 12;
|
|
18
|
+
/* The lane breakdown's two measures, and the currency each is summed apart by, by names no column is read by. */
|
|
19
|
+
export const LANE_COUNT = 'lane_cards';
|
|
20
|
+
export const LANE_SUM = 'lane_amount';
|
|
21
|
+
export const LANE_CURRENCY = 'lane_currency';
|
|
22
|
+
/** The lane breakdown's question: the list's conditions, without its show, sort or page, counted (and summed) by the lane column. */
|
|
23
|
+
export function laneCountsText(query, by, amount, currencyBy) {
|
|
24
|
+
const parts = query ? splitQuery(query) : undefined;
|
|
25
|
+
/* With an amount, the same breakdown sums it beside each count, named so neither is read for the other. */
|
|
26
|
+
const measures = amount ? `count as ${LANE_COUNT}, sum ${amount} as ${LANE_SUM}` : 'count';
|
|
27
|
+
const keys = amount && currencyBy ? `${by}, ${currencyBy} as ${LANE_CURRENCY}` : by;
|
|
28
|
+
return parts ? `${parts.table} ${parts.filter ?? ''} ${measures} by ${keys}`.replace(/\s+/g, ' ') : null;
|
|
29
|
+
}
|
|
30
|
+
/** What the list's read adds to read as a board's lanes: the first page of each lane, one statement, no total. */
|
|
31
|
+
export const laneWindow = (by) => ({ limit: LANE_WINDOW, count: 'none', lanes: { by, limit: LANE_PAGE } });
|
|
32
|
+
/**
|
|
33
|
+
* What a card is worth: the board's `sum`, else the first money its card shows (a line, a fact on its foot), and
|
|
34
|
+
* the column that says each card's currency where it says its own. `rule` is a column's display rule where it
|
|
35
|
+
* says money or a number, else null.
|
|
36
|
+
*/
|
|
37
|
+
export function boardAmount(spec, rule) {
|
|
38
|
+
const amount = spec.sum ?? [...(spec.lines ?? []), ...(spec.footer ?? []).map((fact) => fact.column)].find((name) => rule(name)?.format === 'money');
|
|
39
|
+
if (!amount)
|
|
40
|
+
return {};
|
|
41
|
+
const said = rule(amount) ?? { format: 'number' };
|
|
42
|
+
const currencyBy = said.format === 'money' ? currencyPath(said, amount) : undefined;
|
|
43
|
+
return { amount, said, ...(currencyBy ? { currencyBy } : {}) };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The lists this browser reads as boards (kit LayoutSwitch.tsx), said to the server too, so a page it opens on one
|
|
47
|
+
* carries the board's reads rather than the list's: the view ids, each encoded, joined by commas.
|
|
48
|
+
*/
|
|
49
|
+
export const BOARD_COOKIE = 'mistri_boards';
|
|
50
|
+
/** The views a request's Cookie header says are read as boards. */
|
|
51
|
+
export function boardsInCookie(header) {
|
|
52
|
+
const found = header
|
|
53
|
+
?.split(';')
|
|
54
|
+
.map((part) => part.trim())
|
|
55
|
+
.find((part) => part.startsWith(`${BOARD_COOKIE}=`));
|
|
56
|
+
if (!found)
|
|
57
|
+
return new Set();
|
|
58
|
+
return new Set(found
|
|
59
|
+
.slice(BOARD_COOKIE.length + 1)
|
|
60
|
+
.split(',')
|
|
61
|
+
.flatMap((each) => {
|
|
62
|
+
try {
|
|
63
|
+
return each ? [decodeURIComponent(each)] : [];
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
@@ -12,8 +12,8 @@ export const THEME_PRESETS = [
|
|
|
12
12
|
{
|
|
13
13
|
"id": "workshop",
|
|
14
14
|
"label": "Workshop",
|
|
15
|
-
"light": p("#
|
|
16
|
-
"dark": p("#
|
|
15
|
+
"light": p("#fbfaf7 #ffffff #f2ede3 #e6e1d8 #8b8274 #7d7466 #1b1813 #4f483d #5f574b #f26a1b #e7dfd0 #aa3600 #c9530b #1b1813 #1b1813 #106b38 #934a06 #c52a2a #2f5578 #f2ede3 #1b1813 #4f483d #d8cfbe #aa3600 #e3ded4 #1b1813 #e8691f #2b2620 #9a6cf7 #0e9a6c #0e8fb0 #e0428a #a3510b #94a3b8 #e6e1d8 #e6e1d8 1px - #f26a1b #1b1813 #3a3020"),
|
|
16
|
+
"dark": p("#121110 #1a1917 #24221f #2c2a26 #6d6555 #7a7262 #efe9de #c2b9aa #a59c8d #ff7a2e #2a2723 #ffb88f #e8742c #15130f #efe9de #4ade80 #fbbf24 #f87171 #91a8ff #0f0e0d #efe9de #b3aa9b #24221f #ffb88f #252422 #efe9de #f07a32 #d9d0c0 #9a78ec #12a678 #1597b9 #e0559b #c88317 #6b7694 #2c2a26 #2c2a26 1px - #ff7a2e #15130f"),
|
|
17
17
|
"palettes": [
|
|
18
18
|
{
|
|
19
19
|
"id": "crimson",
|
|
@@ -108,7 +108,7 @@ export const THEME_PRESETS = [
|
|
|
108
108
|
"bar": "ruled",
|
|
109
109
|
"tabs": "rule",
|
|
110
110
|
"windows": "segmented",
|
|
111
|
-
"stat": "
|
|
111
|
+
"stat": "divided",
|
|
112
112
|
"section": "open",
|
|
113
113
|
"fields": "open",
|
|
114
114
|
"table": "open",
|
|
@@ -117,13 +117,14 @@ export const THEME_PRESETS = [
|
|
|
117
117
|
"chart": "plain",
|
|
118
118
|
"buttons": "keyed",
|
|
119
119
|
"links": "plain",
|
|
120
|
-
"rules": "
|
|
120
|
+
"rules": "hairline",
|
|
121
121
|
"avatar": "plain",
|
|
122
122
|
"workflow": "markers",
|
|
123
123
|
"banner": "plain",
|
|
124
124
|
"steps": "strip",
|
|
125
125
|
"lanes": "tag",
|
|
126
|
-
"header": "
|
|
126
|
+
"header": "band",
|
|
127
|
+
"filters": "solid",
|
|
127
128
|
"required": "star",
|
|
128
129
|
"checkbox": "native",
|
|
129
130
|
"formStep": "plain",
|
|
@@ -135,31 +136,32 @@ export const THEME_PRESETS = [
|
|
|
135
136
|
"roles": {
|
|
136
137
|
"title": {
|
|
137
138
|
"face": "heading",
|
|
138
|
-
"size": "
|
|
139
|
+
"size": "28px",
|
|
139
140
|
"weight": 700,
|
|
140
|
-
"case": "
|
|
141
|
-
"tracking": "
|
|
142
|
-
"leading": 1.
|
|
141
|
+
"case": "none",
|
|
142
|
+
"tracking": "0em",
|
|
143
|
+
"leading": 1.15
|
|
143
144
|
},
|
|
144
145
|
"heading": {
|
|
145
146
|
"face": "heading",
|
|
146
|
-
"size": "
|
|
147
|
+
"size": "23px",
|
|
147
148
|
"weight": 700,
|
|
148
|
-
"case": "
|
|
149
|
-
"tracking": "
|
|
149
|
+
"case": "none",
|
|
150
|
+
"tracking": "0em"
|
|
150
151
|
},
|
|
151
152
|
"section": {
|
|
152
|
-
"face": "
|
|
153
|
+
"face": "ui",
|
|
153
154
|
"size": "15px",
|
|
154
|
-
"weight":
|
|
155
|
-
"case": "
|
|
156
|
-
"tracking": "
|
|
155
|
+
"weight": 600,
|
|
156
|
+
"case": "none",
|
|
157
|
+
"tracking": "0em"
|
|
157
158
|
},
|
|
158
159
|
"label": {
|
|
159
|
-
"face": "
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
"
|
|
160
|
+
"face": "ui",
|
|
161
|
+
"size": "12px",
|
|
162
|
+
"weight": 600,
|
|
163
|
+
"case": "none",
|
|
164
|
+
"tracking": "0em"
|
|
163
165
|
},
|
|
164
166
|
"data": {
|
|
165
167
|
"features": [
|
|
@@ -299,6 +301,7 @@ export const THEME_PRESETS = [
|
|
|
299
301
|
"steps": "strip",
|
|
300
302
|
"lanes": "tint",
|
|
301
303
|
"header": "plain",
|
|
304
|
+
"filters": "quiet",
|
|
302
305
|
"required": "star",
|
|
303
306
|
"checkbox": "native",
|
|
304
307
|
"formStep": "plain",
|
|
@@ -436,6 +439,7 @@ export const THEME_PRESETS = [
|
|
|
436
439
|
"steps": "flat",
|
|
437
440
|
"lanes": "tint",
|
|
438
441
|
"header": "plain",
|
|
442
|
+
"filters": "dashed",
|
|
439
443
|
"required": "star",
|
|
440
444
|
"checkbox": "native",
|
|
441
445
|
"formStep": "plain",
|
|
@@ -575,6 +579,7 @@ export const THEME_PRESETS = [
|
|
|
575
579
|
"steps": "flat",
|
|
576
580
|
"lanes": "tint",
|
|
577
581
|
"header": "band",
|
|
582
|
+
"filters": "dashed",
|
|
578
583
|
"required": "star",
|
|
579
584
|
"checkbox": "native",
|
|
580
585
|
"formStep": "plain",
|
|
@@ -706,6 +711,7 @@ export const THEME_PRESETS = [
|
|
|
706
711
|
"steps": "strip",
|
|
707
712
|
"lanes": "plain",
|
|
708
713
|
"header": "plain",
|
|
714
|
+
"filters": "dashed",
|
|
709
715
|
"required": "star",
|
|
710
716
|
"checkbox": "native",
|
|
711
717
|
"formStep": "plain",
|
|
@@ -47,6 +47,8 @@ export interface AskedSection {
|
|
|
47
47
|
};
|
|
48
48
|
/** The target is the whole this metric is a share of, not a goal (it follows the metric's window and picks). */
|
|
49
49
|
targetWhole?: true;
|
|
50
|
+
/** A rows section asked for its rows and no total (served only: an overview's, which says none). */
|
|
51
|
+
counted?: false;
|
|
50
52
|
error?: string;
|
|
51
53
|
}
|
|
52
54
|
/** A breakdown's goals, a row per group: the target table's measure by its own `by`, within its query. */
|
package/dist/shared/filter.d.ts
CHANGED
|
@@ -209,6 +209,8 @@ interface OrderTerm {
|
|
|
209
209
|
direction: 'asc' | 'desc';
|
|
210
210
|
/** The values in their declared order (schema.ts `declaredOrder`). */
|
|
211
211
|
declared?: readonly string[];
|
|
212
|
+
/** An empty value after every other, in either direction: said as `IS NULL` first, which every dialect reads (view.ts). */
|
|
213
|
+
nulls?: 'last';
|
|
212
214
|
}
|
|
213
215
|
/**
|
|
214
216
|
* An ORDER BY clause, or nothing. A term with a declared vocabulary sorts its
|
package/dist/shared/filter.js
CHANGED
|
@@ -162,15 +162,16 @@ export function orderClauseSql(terms, style, startIndex = 1) {
|
|
|
162
162
|
if (typeof term === 'string')
|
|
163
163
|
return term;
|
|
164
164
|
const dir = term.direction === 'desc' ? 'DESC' : 'ASC';
|
|
165
|
+
const last = term.nulls === 'last' ? `${term.expression} IS NULL ASC, ` : '';
|
|
165
166
|
if (!term.declared?.length)
|
|
166
|
-
return `${term.expression} ${dir}`;
|
|
167
|
+
return `${last}${term.expression} ${dir}`;
|
|
167
168
|
const rank = term.declared
|
|
168
169
|
.map((value, at) => {
|
|
169
170
|
params.push(value);
|
|
170
171
|
return `WHEN ${style.placeholder(startIndex + params.length - 1)} THEN ${at}`;
|
|
171
172
|
})
|
|
172
173
|
.join(' ');
|
|
173
|
-
return
|
|
174
|
+
return `${last}CASE ${term.expression} ${rank} ELSE ${term.declared.length} END ${dir}, ${term.expression} ${dir}`;
|
|
174
175
|
})
|
|
175
176
|
.join(', ');
|
|
176
177
|
return { text: ` ORDER BY ${text}`, params };
|
package/dist/shared/form.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ColumnMeta, type TableMeta } from './schema.js';
|
|
2
2
|
/** The explicit selection wins; otherwise steps declare the form's fields
|
|
3
3
|
* in order. Groups only arrange fields and do not narrow a schema-derived form. */
|
|
4
4
|
export declare function formShownFields(form: {
|
|
@@ -19,3 +19,26 @@ export declare function isRequired(column: ColumnMeta, assigned: string | null):
|
|
|
19
19
|
* cannot fill either.
|
|
20
20
|
*/
|
|
21
21
|
export declare function unformedColumns(table: TableMeta, writes: (column: string) => boolean): string[];
|
|
22
|
+
/** A machine as a New form reads it: its column and its states' stored values. */
|
|
23
|
+
interface FormMachine {
|
|
24
|
+
column: string;
|
|
25
|
+
since?: string;
|
|
26
|
+
states: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The columns a New form leaves to the database and the App's machine, where the App's form does not name them: a
|
|
30
|
+
* moment the database stamps (a timestamp with a default, or a creation or upkeep stamp with one), a number a
|
|
31
|
+
* sequence hands out, and a state's own stamp (`completed_at` beside a `completed` state), which the platform
|
|
32
|
+
* writes as the record enters the state (stateStampColumn) — a new record starts in its first one. None of these is
|
|
33
|
+
* the creator's to say, and a form that asked for them asked a person to invent a value the system keeps. Each stays
|
|
34
|
+
* on the record, editable there where it is writable. A day with a default (an invoice's date, today unless said)
|
|
35
|
+
* is the creator's, and stays asked.
|
|
36
|
+
*/
|
|
37
|
+
export declare function platformWritten(table: TableMeta, machine?: FormMachine): Set<string>;
|
|
38
|
+
/**
|
|
39
|
+
* The columns a New form starts at now where nothing else starts them: a required stamp of when the record was
|
|
40
|
+
* entered (`opened_at`, `created_at`) with no default of the database's or the form's. The form still asks it, so a
|
|
41
|
+
* record entered late can say when it really was; it no longer asks a person to type the moment they are in.
|
|
42
|
+
*/
|
|
43
|
+
export declare function enteredNow(columns: readonly ColumnMeta[], defaults: Readonly<Record<string, unknown>>): ColumnMeta[];
|
|
44
|
+
export {};
|
package/dist/shared/form.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { stateStampColumn } from './schema.js';
|
|
1
2
|
/** The explicit selection wins; otherwise steps declare the form's fields
|
|
2
3
|
* in order. Groups only arrange fields and do not narrow a schema-derived form. */
|
|
3
4
|
export function formShownFields(form) {
|
|
@@ -23,3 +24,55 @@ export function unformedColumns(table, writes) {
|
|
|
23
24
|
const assigned = autoKey(table);
|
|
24
25
|
return table.columns.filter((column) => isRequired(column, assigned) && !writes(column.name)).map((column) => column.name);
|
|
25
26
|
}
|
|
27
|
+
/* Stamps of a row's own life, by their names: when it was entered, when it was last touched. */
|
|
28
|
+
const STAMP = /^(sys_)?(created|inserted|added|entered|updated|modified|changed|last_updated)(_at|_on|_date|_time)?$/i;
|
|
29
|
+
/* A default that hands out the next number: a sequence's, an engine's own counter. */
|
|
30
|
+
const NUMBERED = /\bnextval\s*\(|\bauto_?increment\b/i;
|
|
31
|
+
/* When a record was entered, by the words people use for it: a ticket's `opened_at`, a note's `created_at`. */
|
|
32
|
+
const ENTERED = /^(created|opened|raised|logged|reported|entered|inserted|added)(_at|_on|_date)?$/i;
|
|
33
|
+
const dated = (column) => /date|time/i.test(column.type ?? '') || /_(at|on)$/.test(column.name);
|
|
34
|
+
const defaulted = (column) => column.default !== undefined || column.hasDefault === true;
|
|
35
|
+
/**
|
|
36
|
+
* The columns a New form leaves to the database and the App's machine, where the App's form does not name them: a
|
|
37
|
+
* moment the database stamps (a timestamp with a default, or a creation or upkeep stamp with one), a number a
|
|
38
|
+
* sequence hands out, and a state's own stamp (`completed_at` beside a `completed` state), which the platform
|
|
39
|
+
* writes as the record enters the state (stateStampColumn) — a new record starts in its first one. None of these is
|
|
40
|
+
* the creator's to say, and a form that asked for them asked a person to invent a value the system keeps. Each stays
|
|
41
|
+
* on the record, editable there where it is writable. A day with a default (an invoice's date, today unless said)
|
|
42
|
+
* is the creator's, and stays asked.
|
|
43
|
+
*/
|
|
44
|
+
export function platformWritten(table, machine) {
|
|
45
|
+
const written = new Set();
|
|
46
|
+
for (const column of table.columns) {
|
|
47
|
+
if (column.primaryKey || column.references)
|
|
48
|
+
continue;
|
|
49
|
+
if (defaulted(column) && dated(column) && (/time|datetime/i.test(column.type ?? '') || STAMP.test(column.name)))
|
|
50
|
+
written.add(column.name);
|
|
51
|
+
else if (column.default !== undefined && NUMBERED.test(column.default))
|
|
52
|
+
written.add(column.name);
|
|
53
|
+
}
|
|
54
|
+
if (machine) {
|
|
55
|
+
if (machine.since)
|
|
56
|
+
written.add(machine.since);
|
|
57
|
+
for (const state of machine.states) {
|
|
58
|
+
const stamp = stateStampColumn(state, table.columns, machine);
|
|
59
|
+
if (stamp)
|
|
60
|
+
written.add(stamp.name);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return written;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The columns a New form starts at now where nothing else starts them: a required stamp of when the record was
|
|
67
|
+
* entered (`opened_at`, `created_at`) with no default of the database's or the form's. The form still asks it, so a
|
|
68
|
+
* record entered late can say when it really was; it no longer asks a person to type the moment they are in.
|
|
69
|
+
*/
|
|
70
|
+
export function enteredNow(columns, defaults) {
|
|
71
|
+
return columns.filter((column) => !column.primaryKey &&
|
|
72
|
+
!column.references &&
|
|
73
|
+
column.nullable === false &&
|
|
74
|
+
!defaulted(column) &&
|
|
75
|
+
!Object.hasOwn(defaults, column.name) &&
|
|
76
|
+
ENTERED.test(column.name) &&
|
|
77
|
+
dated(column));
|
|
78
|
+
}
|
|
@@ -32,6 +32,9 @@ export function keysetOrder(table, order, dialect) {
|
|
|
32
32
|
const key = primaryKey(table);
|
|
33
33
|
if (!key.length || !key.every((column) => order.some((o) => o.column === column)))
|
|
34
34
|
return false;
|
|
35
|
+
/* A sort that moves its empty values says where they go on its own terms; a step is asked by offset there. */
|
|
36
|
+
if (order.some((o) => o.nulls))
|
|
37
|
+
return false;
|
|
35
38
|
return order.every((o) => {
|
|
36
39
|
const column = table.columns.find((c) => c.name === o.column);
|
|
37
40
|
if (!column || UNFAITHFUL.test(column.type))
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type DatabaseSchema, type TableMeta } from './schema.js';
|
|
2
|
+
import type { AppBoardList } from './listPresentations.js';
|
|
3
|
+
/** What the App says about the resource that the inference reads. */
|
|
4
|
+
export interface InferenceResource {
|
|
5
|
+
/** The App's record label (`recordLabel`): the column, path or template a record is named by; false withholds it. */
|
|
6
|
+
recordLabel?: string | false;
|
|
7
|
+
/** Each column's display rule as drawn (declared over the conventions, displayDefaults.ts effectiveDisplay). */
|
|
8
|
+
display?: Readonly<Record<string, {
|
|
9
|
+
subtitle?: string;
|
|
10
|
+
format?: string;
|
|
11
|
+
} | undefined>>;
|
|
12
|
+
/** The resource's machine: its column and its states in order. */
|
|
13
|
+
machine?: {
|
|
14
|
+
column: string;
|
|
15
|
+
states: readonly {
|
|
16
|
+
name: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
final?: boolean;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** One inferred tab: the label, the condition it adds (a sort clause after it where it reads its own order). */
|
|
23
|
+
interface InferredTab {
|
|
24
|
+
label: string;
|
|
25
|
+
query?: string;
|
|
26
|
+
}
|
|
27
|
+
/** The state a list's rows are in: the machine's column, else a vocabulary named like one. */
|
|
28
|
+
export declare function stateColumn(table: TableMeta, resource?: InferenceResource): string | undefined;
|
|
29
|
+
/** The one date a list shows and filters by: when it is due, else when it starts, else when it came to be. */
|
|
30
|
+
export declare function oneDate(table: TableMeta): string | undefined;
|
|
31
|
+
/** When a row came to be, for newest first. */
|
|
32
|
+
export declare const createdDate: (table: TableMeta) => string | undefined;
|
|
33
|
+
/** When a row is due, where the table says: what an overdue row is late against. */
|
|
34
|
+
export declare const dueDate: (table: TableMeta) => string | undefined;
|
|
35
|
+
/** The rows still under way, in the query language: the machine's open states, or the vocabulary's words that are not
|
|
36
|
+
final. Undefined where nothing says a row is ever over. */
|
|
37
|
+
export declare function openQuery(table: TableMeta, resource?: InferenceResource): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The column a list leads with: what the record is called, where it is one of its own required columns. A name a row
|
|
40
|
+
* may leave blank (a visit's nullable summary) names nothing on the rows that leave it, so the row leads with what it
|
|
41
|
+
* belongs to instead (`job_id`, said by the job's name), the first required reference with a name of its own.
|
|
42
|
+
*/
|
|
43
|
+
export declare function leadColumn(schema: DatabaseSchema, table: TableMeta, resource?: InferenceResource): string | undefined;
|
|
44
|
+
export declare const CODE: RegExp;
|
|
45
|
+
/**
|
|
46
|
+
* The second line under a list's name where its view names no columns and its display rule names none: a code the
|
|
47
|
+
* row is also quoted by (a job's number under its title), proven unique by the catalog. Only a list whose columns
|
|
48
|
+
* are inferred draws it, so a list an author arranged, and every record page, stays as written.
|
|
49
|
+
*/
|
|
50
|
+
export declare function inferListSubtitles(schema: DatabaseSchema, table: TableMeta, resource?: InferenceResource): Record<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* A list's columns where its view names none, in the order a row is read: its name (the display rule's second line
|
|
53
|
+
* under it, where one exists), its state, what it belongs to by name, one date, its money, then its other short
|
|
54
|
+
* words and figures. Left out: the key where the row has a name, a column pinned to one value, long text, a second
|
|
55
|
+
* copy of what the name's second line already says, every date but the one, a postal address past its first part,
|
|
56
|
+
* documents and bytes. The grid leaves out from the end what its room cannot hold.
|
|
57
|
+
*/
|
|
58
|
+
export declare function inferListColumns(schema: DatabaseSchema, table: TableMeta, resource?: InferenceResource): string[];
|
|
59
|
+
/**
|
|
60
|
+
* The order a list reads in where its view says none: work that has a date to be done by is read soonest first —
|
|
61
|
+
* the open tabs, by that date — and anything else newest first by when it came to be. A table with neither reads
|
|
62
|
+
* by its name, never by its key. Undefined leaves the platform's own order (schema.ts defaultOrder).
|
|
63
|
+
*/
|
|
64
|
+
export declare function inferListSort(schema: DatabaseSchema, table: TableMeta, resource?: InferenceResource): string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Tabs where the view names none, from the machine (or a status vocabulary): Open — every state that is not final —
|
|
67
|
+
* then each open state while there are two to five of them, Done — the final ones — and All. The open tabs read in
|
|
68
|
+
* the list's order; Done and All read newest first, where finished work is looked back on.
|
|
69
|
+
*/
|
|
70
|
+
export declare function inferListTabs(_schema: DatabaseSchema, table: TableMeta, resource?: InferenceResource): InferredTab[] | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Filters where the view names none: every vocabulary and yes-or-no among its own columns (the state too where no
|
|
73
|
+
* tab says it already), each reference to a table of at most fifty records, and the one date.
|
|
74
|
+
*/
|
|
75
|
+
export declare function inferListFilters(schema: DatabaseSchema, table: TableMeta, resource?: InferenceResource, tabbed?: boolean): string[];
|
|
76
|
+
/**
|
|
77
|
+
* A board to switch the list to, where its machine has three to seven open states: a lane per state in the
|
|
78
|
+
* machine's order, the final ones together in one folded Done lane, a card of the name, what it belongs to, the date and its
|
|
79
|
+
* urgency toned. A card dropped in another lane runs the one verb that leads there (BoardList.tsx).
|
|
80
|
+
*/
|
|
81
|
+
export declare function inferBoard(schema: DatabaseSchema, table: TableMeta, resource?: InferenceResource): AppBoardList | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* The table an App is about, for a home it did not declare: the one with a machine that the most of its other
|
|
84
|
+
* tables point at, else the most pointed at; between two pointed at as often, the one that points at more (a job
|
|
85
|
+
* before the technician it is filed under), then the App's own order.
|
|
86
|
+
*/
|
|
87
|
+
export declare function mainTable(schema: DatabaseSchema, tables: readonly {
|
|
88
|
+
table: TableMeta;
|
|
89
|
+
machine: boolean;
|
|
90
|
+
}[]): TableMeta | undefined;
|
|
91
|
+
export {};
|