@mistriwork/engine 1.0.0-rc.58 → 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.
@@ -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, lookNavRole } from '../shared/themePresets.js';
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), lookNavRole(theme)).attributes)
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
  /**
@@ -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))