yamlite 0.38.0 → 0.39.0

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/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { F as createHandler, L as isLoopback, R as loopbackHosts, a as query, c as exportSite, i as formatTable, n as formatCsv, o as generateConfig, r as formatJson, s as init, t as open, z as check } from "./src-DdRmp-vT.mjs";
3
- import { n as guide, r as envKeys, t as createWorkspace } from "./workspace-B4WnIeHR.mjs";
2
+ import { F as createHandler, L as isLoopback, R as loopbackHosts, a as query, c as exportSite, i as formatTable, n as formatCsv, o as generateConfig, r as formatJson, s as init, t as open, z as check } from "./src-BMrfSYwa.mjs";
3
+ import { n as guide, r as envKeys, t as createWorkspace } from "./workspace-gtZ3m7LH.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { relative, resolve } from "node:path";
6
6
  import { homedir } from "node:os";
package/dist/core.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { B as CONFIG_NAMES, C as describeChange, H as parseConfig, I as HttpError, T as worthShowing, U as readsFile, a as query, c as exportSite, f as ReviewRefused, h as templatePath, i as formatTable, n as formatCsv, o as generateConfig, r as formatJson, s as init, t as open, w as fieldChanges, z as check } from "./src-DdRmp-vT.mjs";
2
- import { t as createWorkspace } from "./workspace-B4WnIeHR.mjs";
1
+ import { B as CONFIG_NAMES, C as describeChange, H as parseConfig, I as HttpError, T as worthShowing, U as readsFile, a as query, c as exportSite, f as ReviewRefused, h as templatePath, i as formatTable, n as formatCsv, o as generateConfig, r as formatJson, s as init, t as open, w as fieldChanges, z as check } from "./src-BMrfSYwa.mjs";
2
+ import { t as createWorkspace } from "./workspace-gtZ3m7LH.mjs";
3
3
  export { CONFIG_NAMES, HttpError, ReviewRefused, check, createWorkspace, describeChange, exportSite, fieldChanges, formatCsv, formatJson, formatTable, generateConfig, init, open, parseConfig, query, readsFile, templatePath, worthShowing };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { z as check, c as exportSite, n as formatCsv, r as formatJson, i as formatTable, o as generateConfig, s as init, t as open, a as query } from "./src-DdRmp-vT.mjs";
1
+ export { z as check, c as exportSite, n as formatCsv, r as formatJson, i as formatTable, o as generateConfig, s as init, t as open, a as query } from "./src-BMrfSYwa.mjs";
@@ -7299,11 +7299,23 @@ const schemaRoutes = (router, ctx) => {
7299
7299
  };
7300
7300
  });
7301
7301
  };
7302
+ const SEPARATORS = [
7303
+ " ",
7304
+ " ",
7305
+ "\n",
7306
+ "\r",
7307
+ "-",
7308
+ "_",
7309
+ ".",
7310
+ "/"
7311
+ ];
7312
+ const isSeparator = (c) => SEPARATORS.includes(c);
7313
+ const squash = (s) => [...s].filter((c) => !isSeparator(c)).join("");
7302
7314
  const DEFAULT_PER = 20;
7303
7315
  const MAX_PER = 200;
7304
7316
  function parseSearchQuery(params) {
7305
7317
  const needle = params.get("q")?.trim() ?? "";
7306
- if ([...needle].length < 2) throw new HttpError(400, `q needs at least 2 characters`);
7318
+ if ([...squash(needle)].length < 2) throw new HttpError(400, `q needs at least 2 characters`);
7307
7319
  const raw = params.get("per");
7308
7320
  if (raw === null) return {
7309
7321
  needle,
@@ -7331,25 +7343,27 @@ function labelColumn(t) {
7331
7343
  }
7332
7344
  const literal = (s) => `'${s.replaceAll("'", "''")}'`;
7333
7345
  const text = (column) => `CAST(${q(column)} AS TEXT)`;
7334
- const contains = (column) => `instr(lower(${text(column)}), needle.v) > 0`;
7346
+ const char = (c) => c < " " ? `char(${c.charCodeAt(0)})` : literal(c);
7347
+ const squashed = (expr) => SEPARATORS.reduce((e, c) => `replace(${e}, ${char(c)}, '')`, `lower(${expr})`);
7348
+ const contains = (column) => `instr(${squashed(text(column))}, needle.v) > 0`;
7335
7349
  function tableHits(t) {
7336
7350
  const columns = [t.key, ...[...t.columns.keys()].filter((c) => c !== t.key)].filter((c) => t.columns.get(c) !== "BOOLEAN");
7337
7351
  if (columns.length === 0) return null;
7338
7352
  const pick = (then) => `CASE ${columns.map((c) => `WHEN ${contains(c)} THEN ${then(c)}`).join(" ")} END`;
7339
7353
  const label = labelColumn(t);
7340
- return `SELECT ${literal(t.name)} AS tbl, ${text(t.key)} AS k, ${label ? text(label) : "NULL"} AS lbl, ${pick(literal)} AS col, ${pick(text)} AS val FROM main.${q(t.name)}, needle WHERE ${columns.map(contains).join(" OR ")}`;
7354
+ return `SELECT ${literal(t.name)} AS tbl, ${text(t.key)} AS k, ${squashed(text(t.key))} AS sk, ${label ? text(label) : "NULL"} AS lbl, ${pick(literal)} AS col, ${pick(text)} AS val FROM main.${q(t.name)}, needle WHERE ${columns.map(contains).join(" OR ")}`;
7341
7355
  }
7342
7356
  function buildSearchSql(tables, needle, per) {
7343
7357
  const selects = tables.map(tableHits).filter((s) => s !== null);
7344
7358
  if (selects.length === 0) return null;
7345
7359
  return {
7346
- sql: `WITH needle(v) AS (SELECT lower(?)),
7360
+ sql: `WITH needle(v) AS (SELECT ${squashed("?")}),
7347
7361
  hits AS (${selects.join(" UNION ALL ")}),
7348
7362
  ranked AS (
7349
7363
  SELECT hits.*,
7350
- CASE WHEN lower(k) = needle.v THEN 0
7351
- WHEN substr(lower(k), 1, length(needle.v)) = needle.v THEN 1
7352
- WHEN instr(lower(k), needle.v) > 0 THEN 2
7364
+ CASE WHEN sk = needle.v THEN 0
7365
+ WHEN substr(sk, 1, length(needle.v)) = needle.v THEN 1
7366
+ WHEN instr(sk, needle.v) > 0 THEN 2
7353
7367
  ELSE 3 END AS grade,
7354
7368
  count(*) OVER (PARTITION BY tbl) AS total
7355
7369
  FROM hits, needle