yamlite 0.43.0 → 0.43.1
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.mjs +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{src-H6E5YDao.mjs → src-BM2e03Dm.mjs} +34 -7
- package/dist/ui/assets/{ErdView-C-Kg8blN.js → ErdView-CtbEjGp1.js} +1 -1
- package/dist/ui/assets/{MarkdownField-DbmIyR2F.js → MarkdownField-DVxx5u06.js} +1 -1
- package/dist/ui/assets/{PageView-BZ2TyXNJ.js → PageView-DAP-ED6d.js} +1 -1
- package/dist/ui/assets/index-DQMFVxfs.js +126 -0
- package/dist/ui/assets/{load-iZmRMple.js → load-CyEvGfpZ.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/ui-embed/{PageView-BtwLoyjq.js → PageView-CoMBCmD5.js} +1 -1
- package/dist/ui-embed/embed.js +2 -2
- package/dist/ui-embed/{pageFrame-_gi-jKkG.js → pageFrame-CNwogqiE.js} +563 -520
- package/dist/{workspace-BR6jiILy.mjs → workspace-BpOu_Vav.mjs} +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/index-Bfy1b8dm.js +0 -126
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
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-
|
|
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-BM2e03Dm.mjs";
|
|
3
|
+
import { n as guide, r as envKeys, t as createWorkspace } from "./workspace-BpOu_Vav.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 check, C as describeChange, K as DENIED_FILES, L as HttpError, T as worthShowing, U as parseConfig, V as CONFIG_NAMES, W as readsFile, X as fileGranted, Z as normalizeFilePath, a as query, c as exportSite, f as ReviewRefused, h as templatePath, i as formatTable, n as formatCsv, o as generateConfig, q as MAX_PAGE_FILE_BYTES, r as formatJson, s as init, t as open, w as fieldChanges } from "./src-
|
|
2
|
-
import { t as createWorkspace } from "./workspace-
|
|
1
|
+
import { B as check, C as describeChange, K as DENIED_FILES, L as HttpError, T as worthShowing, U as parseConfig, V as CONFIG_NAMES, W as readsFile, X as fileGranted, Z as normalizeFilePath, a as query, c as exportSite, f as ReviewRefused, h as templatePath, i as formatTable, n as formatCsv, o as generateConfig, q as MAX_PAGE_FILE_BYTES, r as formatJson, s as init, t as open, w as fieldChanges } from "./src-BM2e03Dm.mjs";
|
|
2
|
+
import { t as createWorkspace } from "./workspace-BpOu_Vav.mjs";
|
|
3
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-BM2e03Dm.mjs";
|
|
@@ -654,7 +654,7 @@ function logicalType(declared) {
|
|
|
654
654
|
function isStructured(value) {
|
|
655
655
|
return value !== null && typeof value === "object" && !(value instanceof Uint8Array);
|
|
656
656
|
}
|
|
657
|
-
function checkShapes(records, existing, overrides) {
|
|
657
|
+
function checkShapes$1(records, existing, overrides) {
|
|
658
658
|
const skip = /* @__PURE__ */ new Map();
|
|
659
659
|
const byField = /* @__PURE__ */ new Map();
|
|
660
660
|
for (const [key, record] of records) for (const [field, value] of Object.entries(record)) {
|
|
@@ -2661,7 +2661,7 @@ function planTable(store, spec, files, schema, opts) {
|
|
|
2661
2661
|
};
|
|
2662
2662
|
if (db.nullKeys > 0) warnings.push(`${db.nullKeys} rows with NULL "${spec.key}" are ignored`);
|
|
2663
2663
|
for (const key of db.skip) warnings.push(`duplicate "${spec.key}" = "${key}" in the table; skipped`);
|
|
2664
|
-
const shapes = checkShapes(files.records, existing, spec.columns);
|
|
2664
|
+
const shapes = checkShapes$1(files.records, existing, spec.columns);
|
|
2665
2665
|
if (shapes.error) return {
|
|
2666
2666
|
ok: false,
|
|
2667
2667
|
error: shapes.error,
|
|
@@ -2849,9 +2849,15 @@ var ListSource = class {
|
|
|
2849
2849
|
};
|
|
2850
2850
|
//#endregion
|
|
2851
2851
|
//#region src/engine.ts
|
|
2852
|
+
function mdExt(spec) {
|
|
2853
|
+
return markdownExt(spec.glob) ?? ".md";
|
|
2854
|
+
}
|
|
2855
|
+
function recordExt(spec) {
|
|
2856
|
+
return spec.codec === "markdown" ? mdExt(spec) : yamlCodec.ext;
|
|
2857
|
+
}
|
|
2852
2858
|
function makeSource(spec) {
|
|
2853
2859
|
if (spec.mode === "list") return new ListSource(spec.path, spec.key);
|
|
2854
|
-
const codec = spec.codec === "markdown" ? markdownCodec(spec.body ?? "body",
|
|
2860
|
+
const codec = spec.codec === "markdown" ? markdownCodec(spec.body ?? "body", mdExt(spec)) : yamlCodec;
|
|
2855
2861
|
return new FilesSource(spec.path, spec.glob ?? "**/*.{yaml,yml}", spec.key, spec.exclude, codec, spec.captures);
|
|
2856
2862
|
}
|
|
2857
2863
|
function emptyResult(table) {
|
|
@@ -4000,11 +4006,25 @@ function assertSynced(results, prefix, suffix = "") {
|
|
|
4000
4006
|
function checkKey(spec, key) {
|
|
4001
4007
|
if (typeof key !== "string" || key === "") throw new HttpError(400, "key is required", { field: "key" });
|
|
4002
4008
|
if (spec.mode === "files") {
|
|
4003
|
-
const reason = invalidKey(key);
|
|
4009
|
+
const reason = invalidKey(key) ?? unmatchedKey(spec, key);
|
|
4004
4010
|
if (reason) throw new HttpError(400, reason, { field: "key" });
|
|
4005
4011
|
}
|
|
4006
4012
|
return key;
|
|
4007
4013
|
}
|
|
4014
|
+
function unmatchedKey(spec, key) {
|
|
4015
|
+
const glob = spec.glob ?? "**/*.{yaml,yml}";
|
|
4016
|
+
if (matchesFiles(`${key}${recordExt(spec)}`, glob)) return null;
|
|
4017
|
+
if (spec.captures.length === 0) return `key does not match files "${glob}"`;
|
|
4018
|
+
const segments = glob.split("/");
|
|
4019
|
+
return `key must look like "${segments.map((s, i) => {
|
|
4020
|
+
if (i === segments.length - 1) return "<name>";
|
|
4021
|
+
const capture = spec.captures.find((c) => c.segment === i);
|
|
4022
|
+
return capture ? `<${capture.column}>` : s;
|
|
4023
|
+
}).join("/")}" to match files "${glob}"`;
|
|
4024
|
+
}
|
|
4025
|
+
function checkShapes(record, types) {
|
|
4026
|
+
for (const [column, value] of Object.entries(record)) if (types.get(column) === "JSON" && value !== null && !isStructured(value)) throw new HttpError(400, `"${column}" must be a JSON map or list`, { field: column });
|
|
4027
|
+
}
|
|
4008
4028
|
function noKeyIn(spec, values, hint) {
|
|
4009
4029
|
if (spec.key in values) throw new HttpError(400, `"${spec.key}" is the key; ${hint}`, { field: spec.key });
|
|
4010
4030
|
}
|
|
@@ -4016,7 +4036,9 @@ function readRecord(store, spec, key) {
|
|
|
4016
4036
|
function insertRecord(store, spec, key, values) {
|
|
4017
4037
|
checkKey(spec, key);
|
|
4018
4038
|
noKeyIn(spec, values, "send it as \"key\"");
|
|
4019
|
-
const
|
|
4039
|
+
const before = store.tableExists(spec.name) ? store.columns(spec.name) : /* @__PURE__ */ new Map();
|
|
4040
|
+
const record = fromWireRecord(values, before);
|
|
4041
|
+
checkShapes(record, declaredTypes(spec, before));
|
|
4020
4042
|
const keyValue = encode(fromWire(key, ensureColumns(store, spec, record).get(spec.key)));
|
|
4021
4043
|
if (store.readRow(spec.name, spec.key, keyValue)) throw new HttpError(409, `"${key}" already exists in ${spec.name}`, { field: "key" });
|
|
4022
4044
|
const row = {
|
|
@@ -4029,7 +4051,9 @@ function updateRecord(store, spec, key, values) {
|
|
|
4029
4051
|
noKeyIn(spec, values, "rename the record instead");
|
|
4030
4052
|
const row = store.tableExists(spec.name) ? store.readRow(spec.name, spec.key, key) : void 0;
|
|
4031
4053
|
if (!row) throw new HttpError(404, `no record "${key}" in ${spec.name}`);
|
|
4032
|
-
const
|
|
4054
|
+
const types = store.columns(spec.name);
|
|
4055
|
+
const record = fromWireRecord(values, types);
|
|
4056
|
+
checkShapes(record, declaredTypes(spec, types));
|
|
4033
4057
|
ensureColumns(store, spec, record);
|
|
4034
4058
|
const update = {
|
|
4035
4059
|
...recordToRow(record),
|
|
@@ -4037,6 +4061,9 @@ function updateRecord(store, spec, key, values) {
|
|
|
4037
4061
|
};
|
|
4038
4062
|
store.upsert(spec.name, spec.key, update, Object.keys(update));
|
|
4039
4063
|
}
|
|
4064
|
+
function declaredTypes(spec, existing) {
|
|
4065
|
+
return new Map([...Object.entries(spec.columns), ...existing]);
|
|
4066
|
+
}
|
|
4040
4067
|
function deleteRecord(store, spec, key) {
|
|
4041
4068
|
const row = store.tableExists(spec.name) ? store.readRow(spec.name, spec.key, key) : void 0;
|
|
4042
4069
|
if (!row) throw new HttpError(404, `no record "${key}" in ${spec.name}`);
|
|
@@ -8396,7 +8423,7 @@ function inferKey(spec) {
|
|
|
8396
8423
|
function columnsFor(spec, existing) {
|
|
8397
8424
|
const files = makeSource(spec).read();
|
|
8398
8425
|
if (files.tableError) throw new Error(`${spec.name}: ${files.tableError}`);
|
|
8399
|
-
const shapes = checkShapes(files.records, existing ?? /* @__PURE__ */ new Map(), spec.columns);
|
|
8426
|
+
const shapes = checkShapes$1(files.records, existing ?? /* @__PURE__ */ new Map(), spec.columns);
|
|
8400
8427
|
if (shapes.error) throw new Error(`${spec.name}: ${shapes.error}`);
|
|
8401
8428
|
const columns = new Map(existing ?? []);
|
|
8402
8429
|
for (const [column, type] of inferColumns(files.records.values())) if (!columns.has(column)) columns.set(column, spec.columns[column] ?? type);
|