@mistriwork/engine 1.0.0-rc.13 → 1.0.0-rc.14

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.
@@ -212,7 +212,7 @@ export class HttpAdapter {
212
212
  throw new Refusal(`${view.base} comes from an API, so a view over it ${why}`);
213
213
  };
214
214
  if (view.aggregates?.length || view.orderBy?.some((order) => order.alias))
215
- refuse('cannot summarise the records that point at it.');
215
+ refuse('cannot summarize the records that point at it.');
216
216
  if (view.filter?.groups.some((group) => group.some((condition) => condition.any)))
217
217
  refuse('cannot ask about the records that point at it.');
218
218
  const deep = compiled.columns.find((column) => column.hops > 1);
@@ -73,9 +73,11 @@ export function exposureLines(host, apps, authProxyHeader) {
73
73
  return [];
74
74
  if (authProxyHeader)
75
75
  return [];
76
- const remedy = 'Bind --host 127.0.0.1, put it behind a proxy that signs people in (--auth-proxy-header), or give the App sign-in.';
76
+ const way = 'Bind --host 127.0.0.1, put it behind a proxy that signs people in (--auth-proxy-header)';
77
+ /* No App is served (the database browser, or a Workbench): there is no App sign-in to give. */
77
78
  if (!apps.length)
78
- return [`Warning: bound to ${host}, beyond loopback, with no sign-in. Anyone who can reach this port can read the database. ${remedy}`];
79
+ return [`Warning: bound to ${host}, beyond loopback, with no sign-in. Anyone who can reach this port can read the database. ${way}.`];
80
+ const remedy = `${way}, or give the App sign-in.`;
79
81
  return apps.map((app) => !app.auth
80
82
  ? `Warning: bound to ${host}, beyond loopback, and "${app.name}" signs no one in: anyone who can reach this port reads what it shows. ${remedy}`
81
83
  : app.auth.public?.read.length
@@ -9,5 +9,8 @@ export declare function commandWordsOf(usage: string, bin: string): string[];
9
9
  export declare function flagWordsOf(usage: string): string[];
10
10
  /** What was probably meant, said the way a person would type it, or nothing when nothing is near. */
11
11
  export declare function didYouMean(said: string, among: readonly string[]): Promise<string>;
12
- /** What the package says it is, best effort. Every package of the workspace carries the one version. */
12
+ /**
13
+ * What this process says it is, best effort: the host product's own version when its main gave one (`setProduct`),
14
+ * else the package's. Every package of the workspace carries the one version.
15
+ */
13
16
  export declare function packageVersion(): Promise<string>;
@@ -3,6 +3,7 @@
3
3
  * is read for its command and flag words. Each binary keeps its own `USAGE` (packages/mistri/src/server/cli/usage.ts
4
4
  * here, the database browser's in its own repository), and each is held to its own README.
5
5
  */
6
+ import { productVersion } from '../product.js';
6
7
  /** The command words a usage names (`tablewalk migrate`, `mistri check`, …), for a near miss's suggestion. */
7
8
  export function commandWordsOf(usage, bin) {
8
9
  return [...new Set([...usage.matchAll(new RegExp(`^ {2}${bin} ([a-z][a-z-]*)(?=\\s|$)`, 'gm'))].map((match) => match[1]))];
@@ -19,8 +20,14 @@ export async function didYouMean(said, among) {
19
20
  ? ` Did you mean ${near}?`
20
21
  : '';
21
22
  }
22
- /** What the package says it is, best effort. Every package of the workspace carries the one version. */
23
+ /**
24
+ * What this process says it is, best effort: the host product's own version when its main gave one (`setProduct`),
25
+ * else the package's. Every package of the workspace carries the one version.
26
+ */
23
27
  export async function packageVersion() {
28
+ const host = productVersion();
29
+ if (host)
30
+ return host;
24
31
  try {
25
32
  const { runtimeVersion } = await import('../packageVersion.js');
26
33
  return runtimeVersion();
@@ -19,7 +19,7 @@
19
19
  */
20
20
  import { readFile, writeFile, mkdir } from 'node:fs/promises';
21
21
  import { dirname, resolve } from 'node:path';
22
- import { connect } from '../adapters/connect.js';
22
+ import { connect, MYSQL_REFUSAL } from '../adapters/connect.js';
23
23
  import { UNTRUSTED_NETWORK } from '../adapters/net/untrustedDatabase.js';
24
24
  import { configLocations } from './config/locations.js';
25
25
  import { redact, scrubSecrets } from './connectionRedaction.js';
@@ -445,6 +445,11 @@ export class Registry {
445
445
  adapter = opened.adapter;
446
446
  }
447
447
  else {
448
+ /* Before any secret is looked for: a mysql:// address has no password worth resolving, and "no password
449
+ found" said first hid the refusal that is the actual answer. connect() says it again for a reference
450
+ that only resolves to one. */
451
+ if (/^(mysql|mariadb):\/\//i.test(entry.config.url))
452
+ throw new Error(MYSQL_REFUSAL);
448
453
  resolved = await resolveConnection(entry.config.name, entry.config.url, {
449
454
  secrets: !entry.untrustedUrl,
450
455
  environment: this.environment,
@@ -8,8 +8,14 @@
8
8
  * Only the variables both binaries read go through here. A variable one product alone reads names itself.
9
9
  */
10
10
  type ProductName = 'tablewalk' | 'mistri';
11
- /** Say which product this process is. A main calls it first. */
12
- export declare function setProduct(name: ProductName): void;
11
+ /**
12
+ * Say which product this process is. A main calls it first. A host product that runs the engine from npm passes
13
+ * its own version too: `--version`, MCP's serverInfo and telemetry (`packageVersion`) then report it, where the
14
+ * engine's number is the framework's and moves on its own schedule. Left out, they report the engine's.
15
+ */
16
+ export declare function setProduct(name: ProductName, version?: string): void;
17
+ /** The version the host said it is, if it said one (`setProduct`). */
18
+ export declare const productVersion: () => string | undefined;
13
19
  export declare const product: () => ProductName;
14
20
  /** The config file a project keeps beside it: `mistri.json` for an App, `tablewalk.json` for the browser. */
15
21
  export declare const configFileName: () => string;
@@ -1,8 +1,16 @@
1
1
  let current = 'mistri';
2
- /** Say which product this process is. A main calls it first. */
3
- export function setProduct(name) {
2
+ let hostVersion;
3
+ /**
4
+ * Say which product this process is. A main calls it first. A host product that runs the engine from npm passes
5
+ * its own version too: `--version`, MCP's serverInfo and telemetry (`packageVersion`) then report it, where the
6
+ * engine's number is the framework's and moves on its own schedule. Left out, they report the engine's.
7
+ */
8
+ export function setProduct(name, version) {
4
9
  current = name;
10
+ hostVersion = version;
5
11
  }
12
+ /** The version the host said it is, if it said one (`setProduct`). */
13
+ export const productVersion = () => hostVersion;
6
14
  export const product = () => current;
7
15
  /** The config file a project keeps beside it: `mistri.json` for an App, `tablewalk.json` for the browser. */
8
16
  export const configFileName = () => `${current}.json`;
@@ -895,7 +895,7 @@ function parseAggregates(raw, at, name) {
895
895
  if (typeof a.via !== 'string' || !a.via.trim())
896
896
  throw new Error(`${where} has no "via".`);
897
897
  if (a.fn !== 'count' && (typeof a.column !== 'string' || !a.column.trim())) {
898
- throw new Error(`${where} is a ${a.fn} and needs a "column" to summarise.`);
898
+ throw new Error(`${where} is a ${a.fn} and needs a "column" to summarize.`);
899
899
  }
900
900
  if (a.on !== undefined && typeof a.on !== 'string') {
901
901
  throw new Error(`${where} has an "on" that is not a string.`);
@@ -255,7 +255,7 @@ export function resolveAggregate(schema, baseId, aggregate) {
255
255
  let column;
256
256
  if (aggregate.fn !== 'count') {
257
257
  if (!aggregate.column) {
258
- fail(`${aggregate.fn} needs a column on ${child.name} to summarise.`, aggregate.via);
258
+ fail(`${aggregate.fn} needs a column on ${child.name} to summarize.`, aggregate.via);
259
259
  }
260
260
  column = child.columns.find((c) => c.name === aggregate.column);
261
261
  if (!column) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/engine",
3
- "version": "1.0.0-rc.13",
3
+ "version": "1.0.0-rc.14",
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": {