yamlite 0.37.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/browser/sqlite.d.mts +1 -1
- package/dist/browser/sqlite.mjs +7 -3
- package/dist/cli.mjs +2 -2
- package/dist/core.mjs +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{src-DdRmp-vT.mjs → src-BMrfSYwa.mjs} +21 -7
- package/dist/ui/assets/{ErdView-DoSS_2hC.js → ErdView-D3Q6HCAZ.js} +1 -1
- package/dist/ui/assets/{MarkdownField-DGK9weUB.js → MarkdownField-Dh4Tn8_S.js} +1 -1
- package/dist/ui/assets/{PageView-BNleODcZ.js → PageView-9PohkcTy.js} +1 -1
- package/dist/ui/assets/index-BwkTtzmh.css +2 -0
- package/dist/ui/assets/index-nxlI4YiX.js +126 -0
- package/dist/ui/assets/{load-DvgVYICA.js → load-C3NfhY_i.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/ui-embed/{PageView-Cpq5JtTW.js → PageView-BzCYlXPg.js} +1 -1
- package/dist/ui-embed/embed.js +2990 -2997
- package/dist/ui-embed/{pageFrame-Dm62WvvT.js → pageFrame-CFoU6UjD.js} +850 -817
- package/dist/ui-embed/style.css +1 -1
- package/dist/{workspace-B4WnIeHR.mjs → workspace-gtZ3m7LH.mjs} +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/index-rdl0LZp6.css +0 -2
- package/dist/ui/assets/index-yVyR96tO.js +0 -125
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/browser/sqlite.d.ts
|
|
2
2
|
export declare const sqlite3: any;
|
|
3
|
-
export declare const opfs: any;
|
|
4
3
|
export declare function registerVfs(name: string): void;
|
|
4
|
+
export declare function installOpfs(name?: string): Promise<any>;
|
|
5
5
|
type Value = null | number | bigint | string | Uint8Array;
|
|
6
6
|
type Row = Record<string, Value>;
|
|
7
7
|
export declare const constants: Record<string, number>;
|
package/dist/browser/sqlite.mjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import sqlite3InitModule from "@sqlite.org/sqlite-wasm";
|
|
2
2
|
//#region src/browser/sqlite.ts
|
|
3
3
|
const sqlite3 = await sqlite3InitModule();
|
|
4
|
-
|
|
5
|
-
let VFS = opfs?.vfsName;
|
|
4
|
+
let VFS;
|
|
6
5
|
function registerVfs(name) {
|
|
7
6
|
VFS = name;
|
|
8
7
|
}
|
|
8
|
+
async function installOpfs(name = "yamlite") {
|
|
9
|
+
const pool = await sqlite3.installOpfsSAHPoolVfs({ name });
|
|
10
|
+
VFS = pool.vfsName;
|
|
11
|
+
return pool;
|
|
12
|
+
}
|
|
9
13
|
const { capi, oo1 } = sqlite3;
|
|
10
14
|
const constants = Object.fromEntries(Object.entries(capi).filter(([k, v]) => k.startsWith("SQLITE_") && typeof v === "number"));
|
|
11
15
|
var SqliteError = class extends Error {
|
|
@@ -216,4 +220,4 @@ var DatabaseSync = class {
|
|
|
216
220
|
}
|
|
217
221
|
};
|
|
218
222
|
//#endregion
|
|
219
|
-
export { DatabaseSync, StatementSync, constants,
|
|
223
|
+
export { DatabaseSync, StatementSync, constants, installOpfs, registerVfs, sqlite3 };
|
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-
|
|
3
|
-
import { n as guide, r as envKeys, t as createWorkspace } from "./workspace-
|
|
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-
|
|
2
|
-
import { t as createWorkspace } from "./workspace-
|
|
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-
|
|
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
|
|
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
|
|
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
|
|
7351
|
-
WHEN substr(
|
|
7352
|
-
WHEN instr(
|
|
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
|