yamlite 0.45.0 → 0.46.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 +2 -2
- package/dist/core.d.mts +2 -2
- package/dist/core.mjs +3 -3
- package/dist/{index-CDeSOWZt.d.mts → index-azHF8sNP.d.mts} +6 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-EgLryo0T.mjs → src-DYEPD6E1.mjs} +170 -112
- package/dist/{workspace-Ba4Q66xr.mjs → workspace-DyUsuH40.mjs} +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { B as
|
|
3
|
-
import { n as guide, r as envKeys, t as createWorkspace } from "./workspace-
|
|
2
|
+
import { B as check, I as createHandler, R as isLoopback, 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 loopbackHosts } from "./src-DYEPD6E1.mjs";
|
|
3
|
+
import { n as guide, r as envKeys, t as createWorkspace } from "./workspace-DyUsuH40.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.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as ownerOf, B as DbValue, C as Decision, D as OpenOptions, E as DeclaredTable, F as Change, G as PageAccess, H as HistoryEntry, I as ChangeOp, J as SchemaChange, K as PageSpec, L as ColumnType, M as readsFile, N as resolveTables, O as TableInput, P as Capture, R as ConflictInfo, S as BaseHashes, T as Config, U as HistoryPage, V as FieldChange, W as IndexSpec, X as ViewRecord, Y as TableSpec, _ as check, a as formatCsv, b as Watcher, c as query, d as init, f as ExportOptions, g as CheckTable, h as CheckResult, i as QueryResult, j as parseConfig, k as TableLocation, l as InitOptions, m as exportSite, n as open, o as formatJson, p as ExportResult, q as Rec, r as QueryOptions, s as formatTable, t as Yamlite, u as generateConfig, v as WatchHandlers, w as CONFIG_NAMES, x as TableResult, y as WatchOptions, z as DbRow } from "./index-azHF8sNP.mjs";
|
|
2
2
|
import { DatabaseSync } from "node:sqlite";
|
|
3
3
|
import { LanguageModel, ModelMessage } from "ai";
|
|
4
4
|
//#region src/store.d.ts
|
|
@@ -562,4 +562,4 @@ export declare function createWorkspace(o: WorkspaceOptions): Promise<Workspace>
|
|
|
562
562
|
//#region src/git/pr.d.ts
|
|
563
563
|
export declare function templatePath(paths: readonly string[]): string | null;
|
|
564
564
|
//#endregion
|
|
565
|
-
export { type AiOptions, type ApiContext, CONFIG_NAMES, type Capture, type Change, type ChangeOp, type CheckResult, type CheckTable, type ColumnType, type Config, type ConflictInfo, type Credentials, type Decision, type DeclaredTable, type DefaultBranchFiles, type DiffResult, type ExportOptions, type ExportResult, type Extract, type Extracted, type GitStatus, type GitStep, type HistoryEntry, type HistoryPage, type HistoryTarget, type IndexSpec, type InitOptions, type OpenOptions, type PageFileResult, type PageSpec, type QueryOptions, type QueryResult, type Repo, type ReviewCapability, type ReviewOutcome, type ReviewRequest, type RunOptions, type SchemaChange, type StepResult, type StepRunner, type TableInput, type TableLocation, type TableResult, type TableSpec, type WatchHandlers, type WatchOptions, type Watcher, type Workspace, type WorkspaceDriver, type WorkspaceOptions, Yamlite, check, exportSite, formatCsv, formatJson, formatTable, generateConfig, init, open, parseConfig, query, readsFile };
|
|
565
|
+
export { type AiOptions, type ApiContext, CONFIG_NAMES, type Capture, type Change, type ChangeOp, type CheckResult, type CheckTable, type ColumnType, type Config, type ConflictInfo, type Credentials, type Decision, type DeclaredTable, type DefaultBranchFiles, type DiffResult, type ExportOptions, type ExportResult, type Extract, type Extracted, type GitStatus, type GitStep, type HistoryEntry, type HistoryPage, type HistoryTarget, type IndexSpec, type InitOptions, type OpenOptions, type PageFileResult, type PageSpec, type QueryOptions, type QueryResult, type Repo, type ReviewCapability, type ReviewOutcome, type ReviewRequest, type RunOptions, type SchemaChange, type StepResult, type StepRunner, type TableInput, type TableLocation, type TableResult, type TableSpec, type WatchHandlers, type WatchOptions, type Watcher, type Workspace, type WorkspaceDriver, type WorkspaceOptions, Yamlite, check, exportSite, formatCsv, formatJson, formatTable, generateConfig, init, open, ownerOf, parseConfig, query, readsFile, resolveTables };
|
package/dist/core.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as createWorkspace } from "./workspace-
|
|
3
|
-
export { CONFIG_NAMES, DENIED_FILES, HttpError, MAX_PAGE_FILE_BYTES, ReviewRefused, check, createWorkspace, describeChange, exportSite, fieldChanges, fileGranted, formatCsv, formatJson, formatTable, generateConfig, init, normalizeFilePath, open, parseConfig, query, readsFile, templatePath, worthShowing };
|
|
1
|
+
import { $ as normalizeFilePath, B as check, C as describeChange, G as readsFile, J as DENIED_FILES, L as HttpError, Q as fileGranted, T as worthShowing, U as ownerOf, V as CONFIG_NAMES, W as parseConfig, Y as MAX_PAGE_FILE_BYTES, a as query, c as exportSite, f as ReviewRefused, h as templatePath, i as formatTable, n as formatCsv, o as generateConfig, q as resolveTables, r as formatJson, s as init, t as open, w as fieldChanges } from "./src-DYEPD6E1.mjs";
|
|
2
|
+
import { t as createWorkspace } from "./workspace-DyUsuH40.mjs";
|
|
3
|
+
export { CONFIG_NAMES, DENIED_FILES, HttpError, MAX_PAGE_FILE_BYTES, ReviewRefused, check, createWorkspace, describeChange, exportSite, fieldChanges, fileGranted, formatCsv, formatJson, formatTable, generateConfig, init, normalizeFilePath, open, ownerOf, parseConfig, query, readsFile, resolveTables, templatePath, worthShowing };
|
|
@@ -182,6 +182,11 @@ interface Config {
|
|
|
182
182
|
}
|
|
183
183
|
declare function readsFile(l: TableLocation, file: string): boolean;
|
|
184
184
|
declare function parseConfig(text: string, name?: string): Config;
|
|
185
|
+
declare function resolveTables(root: string, configText: string, files: readonly string[], read?: (file: string) => string | null): TableSpec[];
|
|
186
|
+
declare function ownerOf(tables: readonly TableSpec[], file: string): {
|
|
187
|
+
spec: TableSpec;
|
|
188
|
+
key: string | null;
|
|
189
|
+
} | null;
|
|
185
190
|
//#endregion
|
|
186
191
|
//#region src/reconcile.d.ts
|
|
187
192
|
interface BaseHashes {
|
|
@@ -322,4 +327,4 @@ interface Yamlite {
|
|
|
322
327
|
}
|
|
323
328
|
declare function open(options: OpenOptions): Promise<Yamlite>;
|
|
324
329
|
//#endregion
|
|
325
|
-
export {
|
|
330
|
+
export { ownerOf as A, DbValue as B, Decision as C, OpenOptions as D, DeclaredTable as E, Change as F, PageAccess as G, HistoryEntry as H, ChangeOp as I, SchemaChange as J, PageSpec as K, ColumnType as L, readsFile as M, resolveTables as N, TableInput as O, Capture as P, ConflictInfo as R, BaseHashes as S, Config as T, HistoryPage as U, FieldChange as V, IndexSpec as W, ViewRecord as X, TableSpec as Y, check as _, formatCsv as a, Watcher as b, query as c, init as d, ExportOptions as f, CheckTable as g, CheckResult as h, QueryResult as i, parseConfig as j, TableLocation as k, InitOptions as l, exportSite as m, open as n, formatJson as o, ExportResult as p, Rec as q, QueryOptions as r, formatTable as s, Yamlite as t, generateConfig as u, WatchHandlers as v, CONFIG_NAMES as w, TableResult as x, WatchOptions as y, DbRow as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as Decision, D as OpenOptions, F as
|
|
1
|
+
import { C as Decision, D as OpenOptions, F as Change, I as ChangeOp, J as SchemaChange, K as PageSpec, L as ColumnType, O as TableInput, R as ConflictInfo, W as IndexSpec, Y as TableSpec, _ as check, a as formatCsv, b as Watcher, c as query, d as init, f as ExportOptions, g as CheckTable, h as CheckResult, i as QueryResult, l as InitOptions, m as exportSite, n as open, o as formatJson, p as ExportResult, r as QueryOptions, s as formatTable, t as Yamlite, u as generateConfig, v as WatchHandlers, x as TableResult, y as WatchOptions } from "./index-azHF8sNP.mjs";
|
|
2
2
|
export { type Change, type ChangeOp, type CheckResult, type CheckTable, type ColumnType, type ConflictInfo, type Decision, type ExportOptions, type ExportResult, type IndexSpec, type InitOptions, type OpenOptions, type PageSpec, type QueryOptions, type QueryResult, type SchemaChange, type TableInput, type TableResult, type TableSpec, type WatchHandlers, type WatchOptions, type Watcher, Yamlite, check, exportSite, formatCsv, formatJson, formatTable, generateConfig, init, open, query };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { B 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-DYEPD6E1.mjs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { basename, delimiter, dirname, extname, isAbsolute, join, matchesGlob, normalize, posix, relative, resolve, sep } from "node:path";
|
|
2
2
|
import { accessSync, chmodSync, constants, copyFileSync, cpSync, createReadStream, existsSync, linkSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, rmdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { homedir, tmpdir } from "node:os";
|
|
4
|
-
import { Document, Scalar, isMap, isNode, isScalar, isSeq, parse, parseDocument, stringify } from "yaml";
|
|
4
|
+
import { Document, Scalar, isMap, isNode, isScalar, isSeq, parse, parseAllDocuments, parseDocument, stringify } from "yaml";
|
|
5
5
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
6
6
|
import { DatabaseSync, constants as constants$1 } from "node:sqlite";
|
|
7
7
|
import { watch } from "chokidar";
|
|
@@ -1259,14 +1259,80 @@ function readsFile(l, file) {
|
|
|
1259
1259
|
tie: false
|
|
1260
1260
|
}, f);
|
|
1261
1261
|
}
|
|
1262
|
-
|
|
1262
|
+
const diskTree = {
|
|
1263
|
+
list(dir) {
|
|
1264
|
+
let entries;
|
|
1265
|
+
try {
|
|
1266
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
1267
|
+
} catch {
|
|
1268
|
+
return null;
|
|
1269
|
+
}
|
|
1270
|
+
const out = [];
|
|
1271
|
+
for (const e of entries) {
|
|
1272
|
+
if (!e.isSymbolicLink()) {
|
|
1273
|
+
if (e.isDirectory() || e.isFile()) out.push({
|
|
1274
|
+
name: e.name,
|
|
1275
|
+
folder: e.isDirectory()
|
|
1276
|
+
});
|
|
1277
|
+
continue;
|
|
1278
|
+
}
|
|
1279
|
+
try {
|
|
1280
|
+
const s = statSync(join(dir, e.name));
|
|
1281
|
+
if (s.isDirectory() || s.isFile()) out.push({
|
|
1282
|
+
name: e.name,
|
|
1283
|
+
folder: s.isDirectory()
|
|
1284
|
+
});
|
|
1285
|
+
} catch {}
|
|
1286
|
+
}
|
|
1287
|
+
return out;
|
|
1288
|
+
},
|
|
1289
|
+
read(path) {
|
|
1290
|
+
try {
|
|
1291
|
+
return readFileSync(path, "utf8");
|
|
1292
|
+
} catch {
|
|
1293
|
+
return null;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
function pathTree(root, files, read) {
|
|
1298
|
+
const folders = /* @__PURE__ */ new Map([[root, /* @__PURE__ */ new Map()]]);
|
|
1299
|
+
const texts = /* @__PURE__ */ new Map();
|
|
1300
|
+
for (const file of files) {
|
|
1301
|
+
const segments = file.split("/").filter((s) => s !== "" && s !== ".");
|
|
1302
|
+
if (segments.length === 0 || segments.includes("..")) continue;
|
|
1303
|
+
let dir = root;
|
|
1304
|
+
segments.forEach((name, i) => {
|
|
1305
|
+
const folder = i < segments.length - 1;
|
|
1306
|
+
folders.get(dir).set(name, folder || (folders.get(dir).get(name) ?? false));
|
|
1307
|
+
const path = join(dir, name);
|
|
1308
|
+
if (folder && !folders.has(path)) folders.set(path, /* @__PURE__ */ new Map());
|
|
1309
|
+
if (!folder) texts.set(path, segments.join("/"));
|
|
1310
|
+
dir = path;
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
return {
|
|
1314
|
+
list: (dir) => {
|
|
1315
|
+
const entries = folders.get(dir);
|
|
1316
|
+
return entries ? [...entries].map(([name, folder]) => ({
|
|
1317
|
+
name,
|
|
1318
|
+
folder
|
|
1319
|
+
})) : null;
|
|
1320
|
+
},
|
|
1321
|
+
read: (path) => {
|
|
1322
|
+
const file = texts.get(path);
|
|
1323
|
+
return file === void 0 ? null : read(file);
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
const isFileIn = (tree, path) => tree.list(dirname(path))?.some((e) => e.name === basename(path) && !e.folder) ?? false;
|
|
1328
|
+
function locate$2(where, l, base, conventional, tree = diskTree) {
|
|
1263
1329
|
if (l.kind === "files") return {
|
|
1264
1330
|
path: expandPath(l.base, base),
|
|
1265
1331
|
glob: l.glob,
|
|
1266
1332
|
captures: l.captures
|
|
1267
1333
|
};
|
|
1268
1334
|
const path = expandPath(l.path, base);
|
|
1269
|
-
if (
|
|
1335
|
+
if (tree.list(path) !== null || !YAML_EXT.test(path)) {
|
|
1270
1336
|
const dir = l.path.replace(/^\.\//, "").replace(/^\.$/, "").replace(/\/+$/, "");
|
|
1271
1337
|
const glob = dir === "" ? YAML_GLOB : `${dir}/${YAML_GLOB}`;
|
|
1272
1338
|
throw new FolderPathError(conventional !== void 0 && path === join(conventional.root, conventional.name) ? `${where}path must be a YAML file; remove the path: line (the folder ${conventional.name}/ is the default) or use files: "${glob}"` : `${where}path must be a YAML file; for one record per file use files: "${glob}"`);
|
|
@@ -1294,20 +1360,14 @@ function filesOf(root, spec) {
|
|
|
1294
1360
|
if (rel === "") return glob;
|
|
1295
1361
|
return `${rel.startsWith("..") || isAbsolute(rel) ? spec.path : rel.split(sep).join("/")}/${glob}`;
|
|
1296
1362
|
}
|
|
1297
|
-
function hasFilesButNoYaml(dir) {
|
|
1363
|
+
function hasFilesButNoYaml(tree, dir) {
|
|
1298
1364
|
let files = false;
|
|
1299
1365
|
let yaml = false;
|
|
1300
1366
|
const visit = (d) => {
|
|
1301
|
-
|
|
1302
|
-
try {
|
|
1303
|
-
entries = readdirSync(d, { withFileTypes: true });
|
|
1304
|
-
} catch {
|
|
1305
|
-
return;
|
|
1306
|
-
}
|
|
1307
|
-
for (const e of entries) {
|
|
1367
|
+
for (const e of tree.list(d) ?? []) {
|
|
1308
1368
|
if (yaml) return;
|
|
1309
1369
|
if (e.name.startsWith(".") || e.name === "node_modules") continue;
|
|
1310
|
-
if (e.
|
|
1370
|
+
if (e.folder) visit(join(d, e.name));
|
|
1311
1371
|
else {
|
|
1312
1372
|
files = true;
|
|
1313
1373
|
if (YAML_EXT.test(e.name)) yaml = true;
|
|
@@ -1317,38 +1377,30 @@ function hasFilesButNoYaml(dir) {
|
|
|
1317
1377
|
visit(dir);
|
|
1318
1378
|
return files && !yaml;
|
|
1319
1379
|
}
|
|
1320
|
-
function notAList(path) {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
return false;
|
|
1326
|
-
}
|
|
1380
|
+
function notAList(tree, path) {
|
|
1381
|
+
const text = tree.read(path);
|
|
1382
|
+
if (text === null) return false;
|
|
1383
|
+
const docs = parseAllDocuments(text);
|
|
1384
|
+
if (Array.isArray(docs) && docs.length > 1) return true;
|
|
1327
1385
|
const doc = parseDocument(text);
|
|
1328
1386
|
return doc.errors.length === 0 && doc.contents !== null && !isSeq(doc.contents);
|
|
1329
1387
|
}
|
|
1330
1388
|
const ignoredEntry = (name, ignore) => ignore.some((p) => matchesGlob(name, p) || matchesGlob(`${name}/`, p));
|
|
1331
|
-
function scanRoot(root, ignore) {
|
|
1389
|
+
function scanRoot(tree, root, ignore) {
|
|
1332
1390
|
const out = [];
|
|
1333
|
-
for (const entry of
|
|
1391
|
+
for (const entry of tree.list(root) ?? []) {
|
|
1334
1392
|
const name = entry.name;
|
|
1335
1393
|
if (name.startsWith(".") || name === "node_modules" || CONFIG_NAMES.includes(name)) continue;
|
|
1336
1394
|
if (ignoredEntry(name, ignore)) continue;
|
|
1337
1395
|
const path = join(root, name);
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
kind = statSync(path);
|
|
1341
|
-
} catch {
|
|
1342
|
-
continue;
|
|
1343
|
-
}
|
|
1344
|
-
if (kind.isDirectory()) {
|
|
1345
|
-
if (hasFilesButNoYaml(path)) continue;
|
|
1396
|
+
if (entry.folder) {
|
|
1397
|
+
if (hasFilesButNoYaml(tree, path)) continue;
|
|
1346
1398
|
out.push({
|
|
1347
1399
|
name,
|
|
1348
1400
|
path,
|
|
1349
1401
|
glob: YAML_GLOB
|
|
1350
1402
|
});
|
|
1351
|
-
} else if (
|
|
1403
|
+
} else if (YAML_EXT.test(name)) out.push({
|
|
1352
1404
|
name: name.replace(YAML_EXT, ""),
|
|
1353
1405
|
path,
|
|
1354
1406
|
glob: null
|
|
@@ -1367,10 +1419,10 @@ function configPath(root) {
|
|
|
1367
1419
|
}
|
|
1368
1420
|
return null;
|
|
1369
1421
|
}
|
|
1370
|
-
function defaultLocation(root, name) {
|
|
1422
|
+
function defaultLocation(tree, root, name) {
|
|
1371
1423
|
for (const ext of [".yaml", ".yml"]) {
|
|
1372
1424
|
const path = join(root, `${name}${ext}`);
|
|
1373
|
-
if (
|
|
1425
|
+
if (isFileIn(tree, path)) return {
|
|
1374
1426
|
path,
|
|
1375
1427
|
glob: null
|
|
1376
1428
|
};
|
|
@@ -1839,66 +1891,97 @@ function toIndex(table, raw, i) {
|
|
|
1839
1891
|
}
|
|
1840
1892
|
throw invalid();
|
|
1841
1893
|
}
|
|
1894
|
+
function tablesIn(tree, root, config, extra) {
|
|
1895
|
+
const scanned = scanRoot(tree, root, config.ignore);
|
|
1896
|
+
const declared = /* @__PURE__ */ new Map();
|
|
1897
|
+
const pathErrors = [];
|
|
1898
|
+
for (const t of config.tables) {
|
|
1899
|
+
const where = `table "${t.name}": `;
|
|
1900
|
+
const prev = scanned.find((s) => s.name === t.name);
|
|
1901
|
+
let loc;
|
|
1902
|
+
try {
|
|
1903
|
+
loc = t.location.kind !== "default" ? locate$2(where, t.location, root, {
|
|
1904
|
+
name: t.name,
|
|
1905
|
+
root
|
|
1906
|
+
}, tree) : {
|
|
1907
|
+
...prev ?? defaultLocation(tree, root, t.name),
|
|
1908
|
+
captures: []
|
|
1909
|
+
};
|
|
1910
|
+
} catch (e) {
|
|
1911
|
+
if (!(e instanceof FolderPathError)) throw e;
|
|
1912
|
+
pathErrors.push(e.message);
|
|
1913
|
+
continue;
|
|
1914
|
+
}
|
|
1915
|
+
const { location: _location, ...rest } = t;
|
|
1916
|
+
declared.set(t.name, {
|
|
1917
|
+
...rest,
|
|
1918
|
+
...loc,
|
|
1919
|
+
mode: loc.glob === null ? "list" : "files",
|
|
1920
|
+
persisted: true,
|
|
1921
|
+
exclude: []
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
if (pathErrors.length > 0) throw new Error(pathErrors.join("\n"));
|
|
1925
|
+
for (const t of extra) declared.set(t.name, toSpec(locateInput(t, root), false));
|
|
1926
|
+
const codecOf = (glob) => markdownExt(glob) !== null ? "markdown" : "yaml";
|
|
1927
|
+
const globs = [...declared.values()].filter((d) => d.glob !== null);
|
|
1928
|
+
const covered = (s) => s.glob !== null ? globs.some((d) => codecOf(d.glob) === codecOf(s.glob) && (s.path === d.path || s.path.startsWith(d.path + sep))) : globs.some((d) => claims({
|
|
1929
|
+
owner: "",
|
|
1930
|
+
path: d.path,
|
|
1931
|
+
glob: d.glob,
|
|
1932
|
+
tie: false
|
|
1933
|
+
}, s.path));
|
|
1934
|
+
const merged = /* @__PURE__ */ new Map();
|
|
1935
|
+
for (const s of scanned) {
|
|
1936
|
+
const d = declared.get(s.name);
|
|
1937
|
+
if (d) merged.set(s.name, d);
|
|
1938
|
+
else if (!covered(s) && !(s.glob === null && notAList(tree, s.path))) merged.set(s.name, s);
|
|
1939
|
+
}
|
|
1940
|
+
for (const [name, d] of declared) if (!merged.has(name)) merged.set(name, d);
|
|
1941
|
+
const configFiles = CONFIG_NAMES.map((name) => join(root, name));
|
|
1942
|
+
const ignored = config.ignore.flatMap((glob) => [glob, `${glob}/**`].map((g) => ({
|
|
1943
|
+
owner: `ignore entry "${glob}"`,
|
|
1944
|
+
path: root,
|
|
1945
|
+
glob: g,
|
|
1946
|
+
tie: false
|
|
1947
|
+
})));
|
|
1948
|
+
return checkViewNames(withClaims([...merged.values()].map((t) => "mode" in t ? t : toSpec(t, true)), configFiles, ignored));
|
|
1949
|
+
}
|
|
1950
|
+
function resolveTables(root, configText, files, read = () => null) {
|
|
1951
|
+
return tablesIn(pathTree(root, files, read), root, parseConfig(configText), []);
|
|
1952
|
+
}
|
|
1953
|
+
function ownerOf(tables, file) {
|
|
1954
|
+
for (const t of tables) {
|
|
1955
|
+
if (t.mode === "list") {
|
|
1956
|
+
if (t.path === file) return {
|
|
1957
|
+
spec: t,
|
|
1958
|
+
key: null
|
|
1959
|
+
};
|
|
1960
|
+
continue;
|
|
1961
|
+
}
|
|
1962
|
+
if (!claims({
|
|
1963
|
+
owner: t.name,
|
|
1964
|
+
path: t.path,
|
|
1965
|
+
glob: t.glob,
|
|
1966
|
+
tie: false
|
|
1967
|
+
}, file)) continue;
|
|
1968
|
+
if (t.exclude.some((c) => claims(c, file))) continue;
|
|
1969
|
+
const rel = relative(t.path, file);
|
|
1970
|
+
if (rel.startsWith("..") || isAbsolute(rel)) continue;
|
|
1971
|
+
return {
|
|
1972
|
+
spec: t,
|
|
1973
|
+
key: rel.split(sep).join("/").replace(/\.[^./]+$/, "")
|
|
1974
|
+
};
|
|
1975
|
+
}
|
|
1976
|
+
return null;
|
|
1977
|
+
}
|
|
1842
1978
|
function resolveConfig(opts, { requireConfig = true } = {}) {
|
|
1843
1979
|
if (opts.root !== void 0) {
|
|
1844
1980
|
const root = resolve(opts.root);
|
|
1845
1981
|
if (!existsSync(root) || !statSync(root).isDirectory()) throw new Error(`root is not a directory: ${root}`);
|
|
1846
1982
|
if (requireConfig && configPath(root) === null) throw new Error(`no yamlite.yaml in ${root}; run "yamlite init" to create it`);
|
|
1847
1983
|
const config = readRootConfig(root, opts.configText);
|
|
1848
|
-
const
|
|
1849
|
-
const declared = /* @__PURE__ */ new Map();
|
|
1850
|
-
const pathErrors = [];
|
|
1851
|
-
for (const t of config.tables) {
|
|
1852
|
-
const where = `table "${t.name}": `;
|
|
1853
|
-
const prev = scanned.find((s) => s.name === t.name);
|
|
1854
|
-
let loc;
|
|
1855
|
-
try {
|
|
1856
|
-
loc = t.location.kind !== "default" ? locate$2(where, t.location, root, {
|
|
1857
|
-
name: t.name,
|
|
1858
|
-
root
|
|
1859
|
-
}) : {
|
|
1860
|
-
...prev ?? defaultLocation(root, t.name),
|
|
1861
|
-
captures: []
|
|
1862
|
-
};
|
|
1863
|
-
} catch (e) {
|
|
1864
|
-
if (!(e instanceof FolderPathError)) throw e;
|
|
1865
|
-
pathErrors.push(e.message);
|
|
1866
|
-
continue;
|
|
1867
|
-
}
|
|
1868
|
-
const { location: _location, ...rest } = t;
|
|
1869
|
-
declared.set(t.name, {
|
|
1870
|
-
...rest,
|
|
1871
|
-
...loc,
|
|
1872
|
-
mode: loc.glob === null ? "list" : "files",
|
|
1873
|
-
persisted: true,
|
|
1874
|
-
exclude: []
|
|
1875
|
-
});
|
|
1876
|
-
}
|
|
1877
|
-
if (pathErrors.length > 0) throw new Error(pathErrors.join("\n"));
|
|
1878
|
-
for (const t of opts.tables ?? []) declared.set(t.name, toSpec(locateInput(t, root), false));
|
|
1879
|
-
const codecOf = (glob) => markdownExt(glob) !== null ? "markdown" : "yaml";
|
|
1880
|
-
const globs = [...declared.values()].filter((d) => d.glob !== null);
|
|
1881
|
-
const covered = (s) => s.glob !== null ? globs.some((d) => codecOf(d.glob) === codecOf(s.glob) && (s.path === d.path || s.path.startsWith(d.path + sep))) : globs.some((d) => claims({
|
|
1882
|
-
owner: "",
|
|
1883
|
-
path: d.path,
|
|
1884
|
-
glob: d.glob,
|
|
1885
|
-
tie: false
|
|
1886
|
-
}, s.path));
|
|
1887
|
-
const merged = /* @__PURE__ */ new Map();
|
|
1888
|
-
for (const s of scanned) {
|
|
1889
|
-
const d = declared.get(s.name);
|
|
1890
|
-
if (d) merged.set(s.name, d);
|
|
1891
|
-
else if (!covered(s) && !(s.glob === null && notAList(s.path))) merged.set(s.name, s);
|
|
1892
|
-
}
|
|
1893
|
-
for (const [name, d] of declared) if (!merged.has(name)) merged.set(name, d);
|
|
1894
|
-
const configFiles = CONFIG_NAMES.map((name) => join(root, name));
|
|
1895
|
-
const ignored = config.ignore.flatMap((glob) => [glob, `${glob}/**`].map((g) => ({
|
|
1896
|
-
owner: `ignore entry "${glob}"`,
|
|
1897
|
-
path: root,
|
|
1898
|
-
glob: g,
|
|
1899
|
-
tie: false
|
|
1900
|
-
})));
|
|
1901
|
-
const tables = checkViewNames(withClaims([...merged.values()].map((t) => "mode" in t ? t : toSpec(t, true)), configFiles, ignored));
|
|
1984
|
+
const tables = tablesIn(diskTree, root, config, opts.tables ?? []);
|
|
1902
1985
|
return {
|
|
1903
1986
|
db: opts.db ? expandPath(opts.db, process.cwd()) : join(root, ".yamlite", "db.sqlite"),
|
|
1904
1987
|
stateDir: opts.stateDir ? expandPath(opts.stateDir, process.cwd()) : join(root, ".yamlite"),
|
|
@@ -6579,31 +6662,6 @@ async function draftReview(model, input, signal) {
|
|
|
6579
6662
|
}
|
|
6580
6663
|
//#endregion
|
|
6581
6664
|
//#region src/serve/gitrecords.ts
|
|
6582
|
-
function ownerOf(tables, file) {
|
|
6583
|
-
for (const t of tables) {
|
|
6584
|
-
if (t.mode === "list") {
|
|
6585
|
-
if (t.path === file) return {
|
|
6586
|
-
spec: t,
|
|
6587
|
-
key: null
|
|
6588
|
-
};
|
|
6589
|
-
continue;
|
|
6590
|
-
}
|
|
6591
|
-
if (!claims({
|
|
6592
|
-
owner: t.name,
|
|
6593
|
-
path: t.path,
|
|
6594
|
-
glob: t.glob,
|
|
6595
|
-
tie: false
|
|
6596
|
-
}, file)) continue;
|
|
6597
|
-
if (t.exclude.some((c) => claims(c, file))) continue;
|
|
6598
|
-
const rel = relative(t.path, file);
|
|
6599
|
-
if (rel.startsWith("..") || isAbsolute(rel)) continue;
|
|
6600
|
-
return {
|
|
6601
|
-
spec: t,
|
|
6602
|
-
key: rel.split(sep).join("/").replace(/\.[^./]+$/, "")
|
|
6603
|
-
};
|
|
6604
|
-
}
|
|
6605
|
-
return null;
|
|
6606
|
-
}
|
|
6607
6665
|
const currentContent = (root, rootPath) => {
|
|
6608
6666
|
const abs = join(root, rootPath);
|
|
6609
6667
|
return existsSync(abs) ? readFileSync(abs, "utf8") : null;
|
|
@@ -8829,4 +8887,4 @@ async function open(options) {
|
|
|
8829
8887
|
};
|
|
8830
8888
|
}
|
|
8831
8889
|
//#endregion
|
|
8832
|
-
export {
|
|
8890
|
+
export { normalizeFilePath as $, deniedFiles as A, check as B, describeChange as C, isRead as D, PageSql as E, Router as F, readsFile as G, configPath as H, createHandler as I, DENIED_FILES as J, resolveConfig as K, HttpError as L, readRecord as M, assertSynced as N, statementCount as O, toWire as P, fileGranted as Q, isLoopback as R, which as S, worthShowing as T, ownerOf as U, CONFIG_NAMES as V, parseConfig as W, deniedFile as X, MAX_PAGE_FILE_BYTES as Y, entryCovers as Z, ghReady as _, query as a, gitLog as b, exportSite as c, validateNewTable as d, declaredViews as et, ReviewRefused as f, DIFF_LIMIT as g, templatePath as h, formatTable as i, ProposalStore as j, EventHub as k, ROUTES as l, STEP_KINDS as m, formatCsv as n, COLUMN_TYPES as nt, generateConfig as o, localDriver as p, resolveTables as q, formatJson as r, init as s, open as t, Store as tt, createTable as u, gitBranches as v, fieldChanges as w, gitStatus as x, gitDiff as y, loopbackHosts as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as deniedFiles, B as check, D as isRead, E as PageSql, F as Router, H as configPath, K as resolveConfig, L as HttpError, M as readRecord, N as assertSynced, O as statementCount, P as toWire, Q as fileGranted, S as which, U as ownerOf, X as deniedFile, Z as entryCovers, _ as ghReady, b as gitLog, d as validateNewTable, et as declaredViews, g as DIFF_LIMIT, j as ProposalStore, k as EventHub, l as ROUTES, m as STEP_KINDS, nt as COLUMN_TYPES, p as localDriver, t as open, tt as Store, u as createTable, v as gitBranches, x as gitStatus, y as gitDiff } from "./src-DYEPD6E1.mjs";
|
|
2
2
|
import { dirname, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { randomBytes } from "node:crypto";
|