@mistriwork/engine 1.0.0-rc.65 → 1.0.0-rc.66

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.
@@ -207,7 +207,7 @@ export const THEME_PRESETS = [
207
207
  {
208
208
  "id": "safety",
209
209
  "label": "Safety orange",
210
- "light": p("- - - - - - - - - #b33d0b #fdeee4 #b33d0b #d4612a - - - - - #2d4fd6 - - - - #b33d0b - - #e8691f #2557e0 #9a6cf7 #0e9a6c #0e8fb0 #e0428a"),
210
+ "light": p("- - - - - - - - - #b33d0b #fdeee4 #aa3600 #d4612a - - - - - #2d4fd6 - - - - #aa3600 - - #e8691f #2557e0 #9a6cf7 #0e9a6c #0e8fb0 #e0428a"),
211
211
  "dark": p("- - - - - - - - - #ff9d66 #3b2112 #ffb88f #d8743a - - - - - #91a8ff - - - - #ffb88f - - #f07a32 #3559e6 - #12a678 #1597b9 #e0559b #c88317")
212
212
  },
213
213
  {
@@ -231,7 +231,7 @@ export const THEME_PRESETS = [
231
231
  {
232
232
  "id": "teal",
233
233
  "label": "Teal",
234
- "light": p("- - - - - - - - - #0b6f86 #e3f5f8 #0b6f86 #3c90a4 - - - - - #684fa2 - - - - #0b6f86 - - #0e8fb0 #2557e0 #9a6cf7 #0e9a6c #d97706 #e0428a"),
234
+ "light": p("- - - - - - - - - #0b6f86 #e3f5f8 #00687e #3c90a4 - - - - - #684fa2 - - - - #00687e - - #0e8fb0 #2557e0 #9a6cf7 #0e9a6c #d97706 #e0428a"),
235
235
  "dark": p("- - - - - - - - - #4cc6db #0f3540 #79d6e6 #2a8a9c - - - - - #91a8ff - - - - #79d6e6 - - #0c8ab0 #3559e6 - #12a678 #c88317 #e0559b")
236
236
  },
237
237
  {
@@ -9,6 +9,19 @@ export declare function formShownFields(form: {
9
9
  } | undefined): readonly string[] | undefined;
10
10
  /** A single key that can be omitted because the catalog promises a value. */
11
11
  export declare function autoKey(table: TableMeta): string | null;
12
+ /**
13
+ * A single text key with nothing in the catalog to fill it — no identity, no default, no reference to another row —
14
+ * which a tenant App's store fills with a fresh UUID when a new row is given none (app/appAccess.ts), as the database
15
+ * fills an identity's: only where the table says so (`fillsKey`, set for a tenant-owned table whose key is not the
16
+ * natural key its `address` names, appKeyFill.ts). A tenant's opaque text key (tenantWriteSource.ts) is the common one:
17
+ * its New form never asks for it, since no person should invent a key, and before the store filled it the insert met
18
+ * NOT NULL (a field report). Anywhere else a key nothing fills is the form's to ask, and `mistri check` says so.
19
+ */
20
+ export declare function filledKey(table: TableMeta): string | null;
21
+ /** The text key of a table nothing in the catalog fills: what `fillsKey` may be set on. */
22
+ export declare function fillableKey(table: TableMeta): string | null;
23
+ /** The key an App's New form leaves out: one the catalog promises (autoKey) or one its store fills (filledKey). */
24
+ export declare function appAssignedKey(table: TableMeta): string | null;
12
25
  /** Omitting this column cannot rely on a database default or assigned key. */
13
26
  export declare function isRequired(column: ColumnMeta, assigned: string | null): boolean;
14
27
  /**
@@ -9,6 +9,37 @@ export function autoKey(table) {
9
9
  const pk = table.columns.filter((c) => c.primaryKey);
10
10
  return pk.length === 1 && (pk[0].identity || pk[0].default !== undefined || pk[0].hasDefault === true) ? pk[0].name : null;
11
11
  }
12
+ /* Text a fresh UUID fits in: a bounded type only when it holds its 36 characters. */
13
+ const TEXT_KEY = /char|text|clob|string|uuid/i;
14
+ const fitsUuid = (type) => {
15
+ const bound = /\(\s*(\d+)\s*\)/.exec(type);
16
+ return !bound || Number(bound[1]) >= 36;
17
+ };
18
+ /**
19
+ * A single text key with nothing in the catalog to fill it — no identity, no default, no reference to another row —
20
+ * which a tenant App's store fills with a fresh UUID when a new row is given none (app/appAccess.ts), as the database
21
+ * fills an identity's: only where the table says so (`fillsKey`, set for a tenant-owned table whose key is not the
22
+ * natural key its `address` names, appKeyFill.ts). A tenant's opaque text key (tenantWriteSource.ts) is the common one:
23
+ * its New form never asks for it, since no person should invent a key, and before the store filled it the insert met
24
+ * NOT NULL (a field report). Anywhere else a key nothing fills is the form's to ask, and `mistri check` says so.
25
+ */
26
+ export function filledKey(table) {
27
+ return table.fillsKey === true ? fillableKey(table) : null;
28
+ }
29
+ /** The text key of a table nothing in the catalog fills: what `fillsKey` may be set on. */
30
+ export function fillableKey(table) {
31
+ const pk = table.columns.filter((c) => c.primaryKey);
32
+ if (pk.length !== 1)
33
+ return null;
34
+ const [key] = pk;
35
+ const type = key.type ?? '';
36
+ const filled = !key.identity && key.default === undefined && key.hasDefault !== true && !key.references;
37
+ return filled && TEXT_KEY.test(type) && fitsUuid(type) ? key.name : null;
38
+ }
39
+ /** The key an App's New form leaves out: one the catalog promises (autoKey) or one its store fills (filledKey). */
40
+ export function appAssignedKey(table) {
41
+ return autoKey(table) ?? filledKey(table);
42
+ }
12
43
  /** Omitting this column cannot rely on a database default or assigned key. */
13
44
  export function isRequired(column, assigned) {
14
45
  return !column.nullable && column.default === undefined && column.hasDefault !== true && !column.identity && column.name !== assigned;
@@ -21,7 +52,8 @@ export function isRequired(column, assigned) {
21
52
  * cannot fill either.
22
53
  */
23
54
  export function unformedColumns(table, writes) {
24
- const assigned = autoKey(table);
55
+ // Only an App's grants ask this, and an App's store fills a text key no grant writes (filledKey).
56
+ const assigned = appAssignedKey(table);
25
57
  return table.columns.filter((column) => isRequired(column, assigned) && !writes(column.name)).map((column) => column.name);
26
58
  }
27
59
  /* Stamps of a row's own life, by their names: when it was entered, when it was last touched. */
@@ -30,8 +30,12 @@ export const LOOK_PALETTES = [
30
30
  onSignal: '#15130f',
31
31
  chart: '#f07a32',
32
32
  },
33
- /* Workshop's ring is its own deeper orange (a field report's theme, where the look began). */
34
- looks: { workshop: { light: { accent: '#c9530b', link: '#aa3600' }, dark: { accent: '#e8742c' } } },
33
+ /* Workshop's ring is its own deeper orange (a field report's theme, where the look began). Lumen's pill menu
34
+ writes its current entry in the link on the hue's tint, 4.48:1 at the accent: its link is Workshop's. */
35
+ looks: {
36
+ workshop: { light: { accent: '#c9530b', link: '#aa3600' }, dark: { accent: '#e8742c' } },
37
+ lumen: { light: { link: '#aa3600' } },
38
+ },
35
39
  },
36
40
  {
37
41
  id: 'amber',
@@ -99,8 +103,13 @@ export const LOOK_PALETTES = [
99
103
  onSignal: '#15130f',
100
104
  chart: '#0c8ab0',
101
105
  },
102
- /* A step deeper on Workshop's paper and on Atelier's, whose menu's hover is the warm ground a shade down. */
103
- looks: { workshop: { light: { link: '#00687e' } }, atelier: { light: { link: '#00687e' } } },
106
+ /* A step deeper on Workshop's paper and on Atelier's, whose menu's hover is the warm ground a shade down, and on
107
+ Lumen's, whose pill menu writes its current entry in the link on the hue's tint (4.43:1 at the accent). */
108
+ looks: {
109
+ workshop: { light: { link: '#00687e' } },
110
+ atelier: { light: { link: '#00687e' } },
111
+ lumen: { light: { link: '#00687e' } },
112
+ },
104
113
  },
105
114
  {
106
115
  id: 'cobalt',
@@ -209,6 +209,12 @@ export interface TableMeta {
209
209
  * new one. Absent elsewhere, AUTOINCREMENT and every other engine included.
210
210
  */
211
211
  reusesKeys?: true;
212
+ /**
213
+ * Set on a tenant App's table (appKeyFill.ts) whose single text key the App's store fills with a fresh UUID when a new
214
+ * row is given none, as the database fills an identity's (filledKey in form.ts). Absent everywhere else: an App that
215
+ * is not tenant-owned, or a key a person types (its `address`), is never filled, and a form that leaves it off is refused.
216
+ */
217
+ fillsKey?: true;
212
218
  /** True for views — read-only, and worth saying so rather than surprising. */
213
219
  isView: boolean;
214
220
  /** An App's union (appUnions.ts): read by asking each branch it holds, never as a table. */
@@ -179,6 +179,7 @@ export function captureScopeCatalog(schema) {
179
179
  'sortable',
180
180
  'countable',
181
181
  'reusesKeys',
182
+ 'fillsKey',
182
183
  ]);
183
184
  if (!identifier(table.id) ||
184
185
  /* A catalog of several connections says which engine reads each table
@@ -259,6 +260,8 @@ export function captureScopeCatalog(schema) {
259
260
  return refuse();
260
261
  if (table.reusesKeys !== undefined && table.reusesKeys !== true)
261
262
  return refuse();
263
+ if (table.fillsKey !== undefined && table.fillsKey !== true)
264
+ return refuse();
262
265
  // Index advice, as `unique` is address evidence: only columns this table has.
263
266
  if (table.trigram !== undefined &&
264
267
  (!Array.isArray(table.trigram) ||
@@ -535,6 +535,7 @@ export type AppShellNew = ({
535
535
  label?: string;
536
536
  icon?: AppIconName;
537
537
  group?: string;
538
+ when?: string;
538
539
  };
539
540
  /** Optional presentation for a roomier side menu and its fixed workspace identity. */
540
541
  export interface AppSidebar {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/engine",
3
- "version": "1.0.0-rc.65",
3
+ "version": "1.0.0-rc.66",
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": {
package/schema/model.d.ts CHANGED
@@ -79,6 +79,10 @@ export interface AppCommandChoice {
79
79
  icon?: string;
80
80
  /** A line under the label, on a card. */
81
81
  help?: string;
82
+ /** Offered only where the tenant's profile holds this condition, as a field's `when` reads it:
83
+ `tenant.<column>` alone (`"tenant.country = 'IN'"`), shared through `auth.tenancy.shared`. Judged as the form
84
+ is prepared or a public form is served; a submitted withheld value is refused as no choice. */
85
+ when?: string;
82
86
  /** Set by the server on a table's row it served (`source.served`): the columns its `where` compares, so the page
83
87
  offers the rows the answers given match without a read of its own. Never written in an App. */
84
88
  row?: Readonly<Record<string, string | number | boolean | null>>;