@mistriwork/engine 1.0.0-rc.57 → 1.0.0-rc.59
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/clientHttp.js +2 -2
- package/dist/server/clientSurface.js +1 -0
- package/dist/server/columnGrants.js +13 -9
- package/dist/server/seed/seed.js +14 -0
- package/dist/shared/builtInThemes.js +473 -18
- package/dist/shared/lookPalettes.d.ts +13 -10
- package/dist/shared/lookPalettes.js +95 -1
- package/dist/shared/model.js +10 -0
- package/dist/shared/page.js +1 -0
- package/dist/shared/pageAnatomy.d.ts +12 -0
- package/dist/shared/pageAnatomy.js +47 -2
- package/dist/shared/pageConfig.js +29 -1
- package/dist/shared/pageModel.d.ts +7 -0
- package/dist/shared/recordReads.js +19 -4
- package/dist/shared/relatedCreate.js +5 -3
- package/dist/shared/servedApp.d.ts +5 -0
- package/dist/shared/servedApp.js +3 -0
- package/dist/shared/themeLooks.js +370 -55
- package/dist/shared/themePresets.d.ts +0 -2
- package/dist/shared/themePresets.js +0 -4
- package/dist/shared/themeRecipeFamilies.d.ts +92 -0
- package/dist/shared/themeRecipeFamilies.js +60 -0
- package/dist/shared/themeRecipeWords.d.ts +15 -13
- package/dist/shared/themeRecipeWords.js +16 -14
- package/dist/shared/themeRecipes.d.ts +19 -10
- package/dist/shared/themeRecipes.js +37 -27
- package/dist/shared/themeTokens.d.ts +1 -1
- package/dist/shared/themeTokens.js +1 -1
- package/package.json +2 -1
- package/schema/theme.d.ts +37 -12
|
@@ -5,7 +5,7 @@ import { extname, join, normalize, relative, sep } from 'node:path';
|
|
|
5
5
|
import { SOURCE_CLIENT, devClient } from './devclient.js';
|
|
6
6
|
import { localePreloads, lookPreloads, SURFACE_PAGES, surfaceFor, tenantPreloads } from './clientSurface.js';
|
|
7
7
|
import { FONT_TOKENS, PALETTE_TOKENS, parseThemes, shapeTokens } from '../shared/theme.js';
|
|
8
|
-
import { headingWeight, inheritThemePreset
|
|
8
|
+
import { headingWeight, inheritThemePreset } from '../shared/themePresets.js';
|
|
9
9
|
import { typeTokens } from '../shared/themeType.js';
|
|
10
10
|
import { fieldEdge } from '../shared/themeColor.js';
|
|
11
11
|
import { recipeAttributes } from '../shared/themeRecipes.js';
|
|
@@ -182,7 +182,7 @@ function brandingHead(html, presentation, base) {
|
|
|
182
182
|
const json = JSON.stringify(presentation).replace(/[<>&\u2028\u2029]/g, (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`);
|
|
183
183
|
const block = `<style id="mistri-branding-style">${css}</style><script type="application/json" id="mistri-branding">${json}</script>`;
|
|
184
184
|
/* The recipes are menu values (parseThemes refused anything else), written as attributes the sheets answer. */
|
|
185
|
-
const looks = Object.entries(recipeAttributes(inheritThemePreset(theme)
|
|
185
|
+
const looks = Object.entries(recipeAttributes(inheritThemePreset(theme)).attributes)
|
|
186
186
|
.map(([name, value]) => ` ${name}="${escapeHtml(value)}"`)
|
|
187
187
|
.join('');
|
|
188
188
|
let out = html.replace(/<html\b([^>]*)>/i, (_, attributes) => `<html${attributes} data-record-branding data-custom-theme data-visual-theme="${theme.id}" data-theme-style="${theme.base ?? ''}" data-theme-palette="default"${looks}>`);
|
|
@@ -73,6 +73,7 @@ function wornTheme(ui, audience = {}) {
|
|
|
73
73
|
const SHEET_FACES = {
|
|
74
74
|
barlow: { families: ['Barlow', 'Barlow Semi Condensed'], file: /^assets\/barlow-(?:400|semi-condensed-700)-[\w-]+\.woff2$/ },
|
|
75
75
|
inter: { families: ['Inter'], file: /^assets\/inter-latin-[\w-]+\.woff2$/ },
|
|
76
|
+
manrope: { families: ['Manrope'], file: /^assets\/manrope-latin-[\w-]+\.woff2$/ },
|
|
76
77
|
ledger: { families: ['IBM Plex Mono'], data: true, file: /^assets\/ibm-plex-mono-400-[\w-]+\.woff2$/ },
|
|
77
78
|
};
|
|
78
79
|
/**
|
|
@@ -665,6 +665,15 @@ export function expectedCovers(full, request) {
|
|
|
665
665
|
const columns = Object.keys(request.values).filter((column) => !json.has(column) || Object.hasOwn(expected, column));
|
|
666
666
|
return Object.keys(expected).length === columns.length && columns.every((column) => Object.hasOwn(expected, column));
|
|
667
667
|
}
|
|
668
|
+
/* The server adds values the caller never sent (fills, derived values, a machine's start, stamps), so a write's
|
|
669
|
+
reply is narrowed to the columns this principal reads, `applied` as much as `row`. No read set: unchanged. */
|
|
670
|
+
function readableResult(operation, table, result) {
|
|
671
|
+
const readable = operation.fields?.get(table)?.read;
|
|
672
|
+
if (!readable)
|
|
673
|
+
return result;
|
|
674
|
+
const narrow = (values) => Object.fromEntries(Object.entries(values).filter(([column]) => readable.has(column)));
|
|
675
|
+
return { ...result, ...(result.row ? { row: narrow(result.row) } : {}), applied: narrow(result.applied) };
|
|
676
|
+
}
|
|
668
677
|
/** Apply the same graph-aware checks to an already-owned transaction handle. */
|
|
669
678
|
export function authorizeColumnWrites(full, grant, writer, rules) {
|
|
670
679
|
// An arbitrary transaction handle has no proof of row enforcement. Only
|
|
@@ -685,12 +694,7 @@ export function authorizeColumnWrites(full, grant, writer, rules) {
|
|
|
685
694
|
throw new AppAccessDenied();
|
|
686
695
|
recordFields(request.table, request.values, 'write', server);
|
|
687
696
|
const written = product?.insert ? product.insert(request, operation, server, write) : (async () => write(request))();
|
|
688
|
-
return written.then((result) =>
|
|
689
|
-
const readable = operation.fields?.get(request.table)?.read;
|
|
690
|
-
if (!readable || !result.row)
|
|
691
|
-
return result;
|
|
692
|
-
return { ...result, row: Object.fromEntries(Object.entries(result.row).filter(([column]) => readable.has(column))) };
|
|
693
|
-
});
|
|
697
|
+
return written.then((result) => readableResult(operation, request.table, result));
|
|
694
698
|
};
|
|
695
699
|
const updateVia = (input, write) => {
|
|
696
700
|
const request = jsonWritten(full, requestData(input));
|
|
@@ -700,13 +704,13 @@ export function authorizeColumnWrites(full, grant, writer, rules) {
|
|
|
700
704
|
if (operation.appendOnly?.has(request.table)) {
|
|
701
705
|
const answered = product?.unwritable?.(request, operation, write);
|
|
702
706
|
if (answered)
|
|
703
|
-
return answered;
|
|
707
|
+
return answered.then((result) => readableResult(operation, request.table, result));
|
|
704
708
|
throw new AppAccessDenied();
|
|
705
709
|
}
|
|
706
710
|
if (!operation.writable.has(request.table)) {
|
|
707
711
|
const answered = product?.unwritable?.(request, operation, write);
|
|
708
712
|
if (answered)
|
|
709
|
-
return answered;
|
|
713
|
+
return answered.then((result) => readableResult(operation, request.table, result));
|
|
710
714
|
}
|
|
711
715
|
assertWrite(request.table);
|
|
712
716
|
recordFields(request.table, request.values, 'write', isServerRequest(input));
|
|
@@ -717,7 +721,7 @@ export function authorizeColumnWrites(full, grant, writer, rules) {
|
|
|
717
721
|
throw new AppAccessDenied();
|
|
718
722
|
}
|
|
719
723
|
assertRelatedWrites(request.table, Object.keys(request.values));
|
|
720
|
-
return product?.update ? product.update(request, operation, write) : (async () => write(request))();
|
|
724
|
+
return (product?.update ? product.update(request, operation, write) : (async () => write(request))()).then((result) => readableResult(operation, request.table, result));
|
|
721
725
|
};
|
|
722
726
|
return {
|
|
723
727
|
...(writer.lockRecord
|
package/dist/server/seed/seed.js
CHANGED
|
@@ -54,6 +54,10 @@ const COMPANY = /^(companies|company|accounts?|organi[sz]ations?|orgs?|vendors?|
|
|
|
54
54
|
const BORN = [/created/i, /opened/i, /received|registered|reported|requested|raised|booked|logged/i, /ordered|placed|submitted/i, /date$/i];
|
|
55
55
|
/* Columns that hold when something is to happen, not when it did: a schedule's dashboards read "today" and "next". */
|
|
56
56
|
const SCHEDULE = /(^|_)(appointment|appt|scheduled|starts?|begins?|follow_?up|planned|booked_for|check_?in|session|visit)(_|$)|^start_(at|on|date|time)$/i;
|
|
57
|
+
/* Tables whose rows are things that happen at a time: their plain dates are when, not when the row was written. */
|
|
58
|
+
/* When a row was written, as against a plain `date` or `at` that may say when the thing it holds happens. */
|
|
59
|
+
const WRITTEN = BORN.slice(0, 4);
|
|
60
|
+
const SCHEDULE_TABLE = /^(appointments?|bookings?|visits?|sessions?|events?|reservations?|shifts?|lessons?|classes|meetings?|rentals?|viewings?)$/i;
|
|
57
61
|
/* Optional by nature: a note may well be blank; every other text column is filled nearly always. */
|
|
58
62
|
const OPTIONAL_TEXT = /(^|_)(notes?|comments?|remarks?|cancel(l?ation)?|middle_name|nickname|suffix|address_?line_?2|line_?2|fax|alt|secondary)(_|$)/i;
|
|
59
63
|
/* Roles in the building that a title is a job title for. */
|
|
@@ -472,6 +476,7 @@ export async function seedDatabase(adapter, schema, opts) {
|
|
|
472
476
|
const dated = table.columns.filter((c) => moment(c, types) &&
|
|
473
477
|
!DUE.test(c.name) &&
|
|
474
478
|
!SCHEDULE.test(c.name) &&
|
|
479
|
+
!(SCHEDULE_TABLE.test(local(table.name)) && !WRITTEN.some((born) => born.test(c.name))) &&
|
|
475
480
|
!(plan.life && [...plan.life.stamps.values()].flat().includes(c.name)) &&
|
|
476
481
|
c.name !== plan.life?.since);
|
|
477
482
|
for (const want of BORN) {
|
|
@@ -599,6 +604,15 @@ export async function seedDatabase(adapter, schema, opts) {
|
|
|
599
604
|
? new Date(today.getTime() - dice.int(1, 6) * DAY)
|
|
600
605
|
: new Date(today.getTime() + dice.int(1, 14) * DAY);
|
|
601
606
|
}
|
|
607
|
+
/* A table of things that happen at a time (appointments, bookings, visits) has its plain date that time:
|
|
608
|
+
some behind, some today, most ahead, so its "upcoming" list and its calendar have rows to show. */
|
|
609
|
+
if (SCHEDULE_TABLE.test(local(table.name)) &&
|
|
610
|
+
!WRITTEN.some((born) => born.test(column.name)) &&
|
|
611
|
+
!/(^|_)(updated|modified|deleted|archived|ended|completed|cancel(l?ed)?|closed)(_|$)/i.test(column.name)) {
|
|
612
|
+
if (plan.life && !life.open)
|
|
613
|
+
return new Date(Math.min(life.born.getTime() + dice.int(0, 3) * DAY, today.getTime() - 60_000));
|
|
614
|
+
return scheduledFor(dice, today);
|
|
615
|
+
}
|
|
602
616
|
if (/birth|dob/i.test(column.name))
|
|
603
617
|
return new Date(Date.UTC(dice.int(1955, 2004), dice.int(0, 11), dice.int(1, 28)));
|
|
604
618
|
if (/expir|valid_until|renew|ends?_(at|on)/i.test(column.name))
|