@mistriwork/engine 1.0.0-rc.43 → 1.0.0-rc.45
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/adapters/sqlite.js +2 -0
- package/dist/shared/appComponents.d.ts +3 -1
- package/dist/shared/appComponents.js +14 -1
- package/dist/shared/appDocuments.d.ts +4 -3
- package/dist/shared/appDocuments.js +10 -5
- package/dist/shared/schema.d.ts +6 -0
- package/dist/shared/scopeCatalog.js +3 -0
- package/package.json +1 -1
package/dist/adapters/sqlite.js
CHANGED
|
@@ -356,6 +356,8 @@ export class SqliteAdapter {
|
|
|
356
356
|
columns,
|
|
357
357
|
approxRows: approxRowsOf(t.name, t.type),
|
|
358
358
|
isView: t.type === 'view',
|
|
359
|
+
/* AUTOINCREMENT is only in the statement: the catalog says nothing else about it. */
|
|
360
|
+
...(identity && !/\bAUTOINCREMENT\b/i.test(t.sql ?? '') ? { reusesKeys: true } : {}),
|
|
359
361
|
indexed: t.type === 'view' ? [] : this.leadingIndexColumns(columns, indexes),
|
|
360
362
|
...(() => {
|
|
361
363
|
const unique = t.type === 'view' ? [] : this.uniqueColumns(indexes);
|
|
@@ -153,8 +153,10 @@ interface PageDecl {
|
|
|
153
153
|
actions: string[];
|
|
154
154
|
/** The address parameters the page keeps its place in: `/{app}/pick-walk?list=12`. */
|
|
155
155
|
params: string[];
|
|
156
|
-
/** The loader that reads for it on the server, by its name in the commands module (`defineLoaders`)
|
|
156
|
+
/** The loader that reads for it on the server, by its name in the commands module (`defineLoaders`); its result is the page's `data`. */
|
|
157
157
|
loader?: string;
|
|
158
|
+
/** More loaders the page runs by name (`useLoader`), each with a cache entry and a loading state of its own. */
|
|
159
|
+
loaders?: string[];
|
|
158
160
|
props: Record<string, unknown>;
|
|
159
161
|
}
|
|
160
162
|
/**
|
|
@@ -361,8 +361,9 @@ export function parseCustomList(raw, at) {
|
|
|
361
361
|
throw new Error(`${at} names one column twice in "show".`);
|
|
362
362
|
return { kind: 'custom', component, show: columns, props: componentPropValues(component, raw.props, at) };
|
|
363
363
|
}
|
|
364
|
-
/** The most address parameters one page keeps. */
|
|
364
|
+
/** The most address parameters one page keeps, and the most loaders it names. */
|
|
365
365
|
const MAX_PAGE_PARAMS = 8;
|
|
366
|
+
const MAX_PAGE_LOADERS = 8;
|
|
366
367
|
const PARAM = /^[a-z][a-z0-9_]{0,31}$/;
|
|
367
368
|
const LOADER = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
368
369
|
/* A parameter's kind is how the page reads its text back (sdk/page.tsx): the address always holds text. */
|
|
@@ -418,6 +419,17 @@ export function parsePage(raw, at) {
|
|
|
418
419
|
if (raw.loader !== undefined && (typeof raw.loader !== 'string' || !LOADER.test(raw.loader))) {
|
|
419
420
|
throw new Error(`[page-loader] ${at} has a "loader" that is not a loader's name, as the commands module's defineLoaders() registers it.`);
|
|
420
421
|
}
|
|
422
|
+
if (raw.loaders !== undefined) {
|
|
423
|
+
const named = raw.loaders;
|
|
424
|
+
if (!Array.isArray(named) ||
|
|
425
|
+
!named.length ||
|
|
426
|
+
named.length > MAX_PAGE_LOADERS ||
|
|
427
|
+
named.some((name) => typeof name !== 'string' || !LOADER.test(name))) {
|
|
428
|
+
throw new Error(`[page-loader] ${at} has "loaders" that are not up to ${MAX_PAGE_LOADERS} loader names, as the commands module's defineLoaders() registers them: loaders: ['board', 'dueFigure'].`);
|
|
429
|
+
}
|
|
430
|
+
if (new Set(named).size !== named.length || (raw.loader !== undefined && named.includes(raw.loader)))
|
|
431
|
+
throw new Error(`[page-loader] ${at} names a loader twice: "loader" and "loaders" together name each loader once.`);
|
|
432
|
+
}
|
|
421
433
|
return {
|
|
422
434
|
component,
|
|
423
435
|
reads: [...new Set(reads.map((name) => name.trim()))],
|
|
@@ -425,6 +437,7 @@ export function parsePage(raw, at) {
|
|
|
425
437
|
actions: [...new Set(actions.map((name) => name.trim()))],
|
|
426
438
|
params: [...new Set(params)],
|
|
427
439
|
...(raw.loader === undefined ? {} : { loader: raw.loader }),
|
|
440
|
+
...(raw.loaders === undefined ? {} : { loaders: [...raw.loaders] }),
|
|
428
441
|
props: componentPropValues(component, raw.props, at),
|
|
429
442
|
};
|
|
430
443
|
}
|
|
@@ -20,9 +20,10 @@ export declare function parseDocument(raw: unknown, at: string): PageDocument;
|
|
|
20
20
|
/**
|
|
21
21
|
* What a document's sections may be, refused section by section: paper has no
|
|
22
22
|
* aside, no tabs and nothing to operate, and a list on it is every line — a
|
|
23
|
-
* table whose header repeats on each sheet —
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* table whose header repeats on each sheet — or, over a file resource, its
|
|
24
|
+
* pictures (a gallery, drawn as a grid, with no lightbox to open), never
|
|
25
|
+
* cards or a page of rows. Its lists read every line, up to DOCUMENT_LINES
|
|
26
|
+
* (DOCUMENT_PICTURES for pictures), unless the author says fewer.
|
|
26
27
|
*/
|
|
27
28
|
export declare function documentSections(sections: readonly PageSection[], at: string): PageSection[];
|
|
28
29
|
/** The sheet a document is printed on: its own `size`, else the paper the App's (or tenant's) locale buys. */
|
|
@@ -30,6 +30,8 @@ const DOCUMENT_SIZES = ['a4', 'letter'];
|
|
|
30
30
|
const DOCUMENT_SECTION_KINDS = ['fields', 'list', 'note'];
|
|
31
31
|
/** Every line is on paper, up to the most a related list reads at once; a page that would be longer says so. */
|
|
32
32
|
const DOCUMENT_LINES = 500;
|
|
33
|
+
/** A list of pictures is read on the reader's lease one file at a time, and each takes a sheet's room: fewer by default. */
|
|
34
|
+
const DOCUMENT_PICTURES = 24;
|
|
33
35
|
/** A page's document, as one page body states it. */
|
|
34
36
|
export function parseDocument(raw, at) {
|
|
35
37
|
const where = `${at}, "document"`;
|
|
@@ -55,9 +57,10 @@ export function parseDocument(raw, at) {
|
|
|
55
57
|
/**
|
|
56
58
|
* What a document's sections may be, refused section by section: paper has no
|
|
57
59
|
* aside, no tabs and nothing to operate, and a list on it is every line — a
|
|
58
|
-
* table whose header repeats on each sheet —
|
|
59
|
-
*
|
|
60
|
-
*
|
|
60
|
+
* table whose header repeats on each sheet — or, over a file resource, its
|
|
61
|
+
* pictures (a gallery, drawn as a grid, with no lightbox to open), never
|
|
62
|
+
* cards or a page of rows. Its lists read every line, up to DOCUMENT_LINES
|
|
63
|
+
* (DOCUMENT_PICTURES for pictures), unless the author says fewer.
|
|
61
64
|
*/
|
|
62
65
|
export function documentSections(sections, at) {
|
|
63
66
|
return sections.map((section, i) => {
|
|
@@ -74,8 +77,10 @@ export function documentSections(sections, at) {
|
|
|
74
77
|
throw new Error(`${where} has "actions"; paper has nothing to press.`);
|
|
75
78
|
if (section.kind !== 'list')
|
|
76
79
|
return section;
|
|
77
|
-
if (section.presentation !== undefined || section.create || section.rowActions)
|
|
78
|
-
throw new Error(`${where} is a list of the record's lines on paper: no
|
|
80
|
+
if ((section.presentation !== undefined && section.presentation !== 'gallery') || section.create || section.rowActions)
|
|
81
|
+
throw new Error(`${where} is a list of the record's lines on paper: no cards, create or row actions.`);
|
|
82
|
+
if (section.presentation === 'gallery')
|
|
83
|
+
return section.limit === undefined ? { ...section, limit: DOCUMENT_PICTURES } : section;
|
|
79
84
|
return section.limit === undefined ? { ...section, limit: DOCUMENT_LINES } : section;
|
|
80
85
|
});
|
|
81
86
|
}
|
package/dist/shared/schema.d.ts
CHANGED
|
@@ -198,6 +198,12 @@ export interface TableMeta {
|
|
|
198
198
|
sortable?: string[];
|
|
199
199
|
/** `false` when the source reports no totals (an API): lists page without one, and nothing asks for a count. */
|
|
200
200
|
countable?: false;
|
|
201
|
+
/**
|
|
202
|
+
* Set on a SQLite table whose key is a rowid alias declared without AUTOINCREMENT: SQLite may hand a deleted row's
|
|
203
|
+
* key to the next insert, so whatever outlives the row and names it by key (a capability link) may come to name a
|
|
204
|
+
* new one. Absent elsewhere, AUTOINCREMENT and every other engine included.
|
|
205
|
+
*/
|
|
206
|
+
reusesKeys?: true;
|
|
201
207
|
/** True for views — read-only, and worth saying so rather than surprising. */
|
|
202
208
|
isView: boolean;
|
|
203
209
|
/** An App's union (appUnions.ts): read by asking each branch it holds, never as a table. */
|
|
@@ -178,6 +178,7 @@ export function captureScopeCatalog(schema) {
|
|
|
178
178
|
'filterIn',
|
|
179
179
|
'sortable',
|
|
180
180
|
'countable',
|
|
181
|
+
'reusesKeys',
|
|
181
182
|
]);
|
|
182
183
|
if (!identifier(table.id) ||
|
|
183
184
|
/* A catalog of several connections says which engine reads each table
|
|
@@ -256,6 +257,8 @@ export function captureScopeCatalog(schema) {
|
|
|
256
257
|
return refuse();
|
|
257
258
|
if (table.countable !== undefined && table.countable !== false)
|
|
258
259
|
return refuse();
|
|
260
|
+
if (table.reusesKeys !== undefined && table.reusesKeys !== true)
|
|
261
|
+
return refuse();
|
|
259
262
|
// Index advice, as `unique` is address evidence: only columns this table has.
|
|
260
263
|
if (table.trigram !== undefined &&
|
|
261
264
|
(!Array.isArray(table.trigram) ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mistriwork/engine",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.45",
|
|
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": {
|