yamlite 0.43.0 → 0.44.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 { 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-H6E5YDao.mjs";
3
- import { n as guide, r as envKeys, t as createWorkspace } from "./workspace-BR6jiILy.mjs";
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-c2B3gqup.mjs";
3
+ import { n as guide, r as envKeys, t as createWorkspace } from "./workspace-Bi3ZH_Bi.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
@@ -277,16 +277,20 @@ interface GitStatus {
277
277
  status: "added" | "modified" | "deleted";
278
278
  }[];
279
279
  }
280
- interface GitDriver {
281
- hasRemote(): Promise<boolean>;
280
+ interface WorkspaceDriver {
282
281
  status(): Promise<GitStatus>;
283
- defaultBranch(): Promise<string | null>;
284
282
  baseContent(rootPath: string): Promise<string | null>;
285
283
  baseFile(rootPath: string): Promise<Uint8Array | null>;
286
- history(t: HistoryTarget, extract: Extract, o: {
284
+ history?(t: HistoryTarget, extract: Extract, o: {
287
285
  cursor?: string;
288
286
  }): Promise<HistoryPage>;
289
- fileDiff(t: HistoryTarget, rev: string): Promise<DiffResult>;
287
+ fileDiff?(t: HistoryTarget, rev: string): Promise<DiffResult>;
288
+ review?: ReviewCapability;
289
+ readonly steps?: StepRunner;
290
+ }
291
+ interface ReviewCapability {
292
+ available(): Promise<boolean>;
293
+ defaultBranch(): Promise<string | null>;
290
294
  review(req: ReviewRequest & {
291
295
  target: string | null;
292
296
  }, o: {
@@ -296,7 +300,6 @@ interface GitDriver {
296
300
  pullRequestTemplate?(): Promise<string | null>;
297
301
  readonly namesBranch?: boolean;
298
302
  readonly defaultBranchFiles?: DefaultBranchFiles;
299
- readonly steps?: StepRunner;
300
303
  }
301
304
  interface DefaultBranchFiles {
302
305
  changes(): Promise<GitStatus["changes"]>;
@@ -401,7 +404,7 @@ interface ApiContext {
401
404
  hub: EventHub;
402
405
  proposals: ProposalStore;
403
406
  agent: AgentHost | null;
404
- git: GitDriver | null;
407
+ git: WorkspaceDriver | null;
405
408
  reloadConfig: () => void;
406
409
  pageFiles: WorkspaceOptions["pageFiles"] | null;
407
410
  deniedFiles: string[];
@@ -544,7 +547,7 @@ interface WorkspaceOptions {
544
547
  db?: string;
545
548
  watch?: WatchOptions;
546
549
  ai?: AiOptions | null;
547
- git?: GitDriver | null;
550
+ git?: WorkspaceDriver | null;
548
551
  gh?: string | null;
549
552
  pageFiles?: (path: string, signal: AbortSignal) => Promise<PageFileResult>;
550
553
  }
@@ -558,4 +561,4 @@ export declare function createWorkspace(o: WorkspaceOptions): Promise<Workspace>
558
561
  //#region src/git/pr.d.ts
559
562
  export declare function templatePath(paths: readonly string[]): string | null;
560
563
  //#endregion
561
- 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 GitDriver, 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 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 WorkspaceOptions, Yamlite, check, exportSite, formatCsv, formatJson, formatTable, generateConfig, init, open, parseConfig, query, readsFile };
564
+ 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 };
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-H6E5YDao.mjs";
2
- import { t as createWorkspace } from "./workspace-BR6jiILy.mjs";
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-c2B3gqup.mjs";
2
+ import { t as createWorkspace } from "./workspace-Bi3ZH_Bi.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-H6E5YDao.mjs";
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-c2B3gqup.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", markdownExt(spec.glob) ?? ".md") : yamlCodec;
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 record = fromWireRecord(values, store.tableExists(spec.name) ? store.columns(spec.name) : /* @__PURE__ */ new Map());
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 record = fromWireRecord(values, store.columns(spec.name));
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}`);
@@ -5191,7 +5218,7 @@ const historyRoutes = (router, ctx) => {
5191
5218
  const { spec, key, t } = target(ctx, params);
5192
5219
  const cursor = query.get("cursor") ?? void 0;
5193
5220
  if (cursor !== void 0 && !CURSOR.test(cursor)) throw new HttpError(400, "invalid cursor");
5194
- if (!ctx.git) return { state: "nogit" };
5221
+ if (!ctx.git?.history) return { state: "nogit" };
5195
5222
  const page = await ctx.git.history(t, extractor(spec, key), { cursor });
5196
5223
  if (page.state !== "ok") return page;
5197
5224
  return {
@@ -5213,7 +5240,7 @@ const historyRoutes = (router, ctx) => {
5213
5240
  const rev = params.sha;
5214
5241
  if (!REV.test(rev)) throw new HttpError(400, "invalid commit");
5215
5242
  const { t } = target(ctx, params);
5216
- if (!ctx.git) throw new HttpError(404, "no git history (nogit)");
5243
+ if (!ctx.git?.fileDiff) throw new HttpError(404, "no git history (nogit)");
5217
5244
  const res = await ctx.git.fileDiff(t, rev);
5218
5245
  if (res.state === "ok") return { text: res.text };
5219
5246
  if (res.state === "error") throw new HttpError(500, res.message);
@@ -6309,24 +6336,9 @@ async function localDriver(root, gh) {
6309
6336
  };
6310
6337
  await lookup();
6311
6338
  return {
6312
- namesBranch: true,
6313
6339
  get steps() {
6314
6340
  return found?.steps;
6315
6341
  },
6316
- async hasRemote() {
6317
- const f = await lookup();
6318
- if (!f) return false;
6319
- try {
6320
- await runGit(f.repo.top, [
6321
- "remote",
6322
- "get-url",
6323
- "origin"
6324
- ]);
6325
- return true;
6326
- } catch {
6327
- return false;
6328
- }
6329
- },
6330
6342
  async status() {
6331
6343
  const f = await lookup();
6332
6344
  if (!f) return {
@@ -6345,7 +6357,6 @@ async function localDriver(root, gh) {
6345
6357
  changes
6346
6358
  };
6347
6359
  },
6348
- defaultBranch: defaultName,
6349
6360
  async baseContent(rootPath) {
6350
6361
  const { repo } = await need();
6351
6362
  const top = insideRoot$1(repo, rootPath);
@@ -6359,70 +6370,88 @@ async function localDriver(root, gh) {
6359
6370
  async baseFile(rootPath) {
6360
6371
  return blobAt((await need()).repo, "HEAD", rootPath);
6361
6372
  },
6362
- defaultBranchFiles: {
6363
- async changes() {
6373
+ history: (t, extract, o) => recordHistory(t, extract, o),
6374
+ fileDiff: (t, rev) => fileDiff(t, rev),
6375
+ review: {
6376
+ namesBranch: true,
6377
+ async available() {
6364
6378
  const f = await lookup();
6365
- if (!f) return [];
6366
- const [branch, name] = [await currentBranch(f.repo), await defaultName()];
6367
- if (branch === null || name === null || branch === name) return [];
6368
- const parts = (await runGit(f.repo.top, [
6369
- "diff",
6370
- "--name-status",
6371
- "--no-renames",
6372
- "-z",
6373
- `${await defaultRef(f.repo, name)}...HEAD`,
6374
- "--",
6375
- f.repo.prefix || "."
6376
- ])).split("\0");
6377
- const changes = [];
6378
- for (let i = 0; i + 1 < parts.length; i += 2) {
6379
- const path = toRoot(f.repo, parts[i + 1]);
6380
- if (path === null) continue;
6381
- const code = parts[i];
6382
- changes.push({
6383
- path,
6384
- status: code === "A" ? "added" : code === "D" ? "deleted" : "modified"
6385
- });
6379
+ if (!f) return false;
6380
+ try {
6381
+ await runGit(f.repo.top, [
6382
+ "remote",
6383
+ "get-url",
6384
+ "origin"
6385
+ ]);
6386
+ return true;
6387
+ } catch {
6388
+ return false;
6386
6389
  }
6387
- return changes;
6388
6390
  },
6389
- async file(rootPath) {
6390
- const { repo } = await need();
6391
- const name = await defaultName();
6392
- if (name === null) throw new GitError("the default branch is not known");
6393
- return blobAt(repo, await defaultRef(repo, name), rootPath);
6391
+ defaultBranch: defaultName,
6392
+ defaultBranchFiles: {
6393
+ async changes() {
6394
+ const f = await lookup();
6395
+ if (!f) return [];
6396
+ const [branch, name] = [await currentBranch(f.repo), await defaultName()];
6397
+ if (branch === null || name === null || branch === name) return [];
6398
+ const parts = (await runGit(f.repo.top, [
6399
+ "diff",
6400
+ "--name-status",
6401
+ "--no-renames",
6402
+ "-z",
6403
+ `${await defaultRef(f.repo, name)}...HEAD`,
6404
+ "--",
6405
+ f.repo.prefix || "."
6406
+ ])).split("\0");
6407
+ const changes = [];
6408
+ for (let i = 0; i + 1 < parts.length; i += 2) {
6409
+ const path = toRoot(f.repo, parts[i + 1]);
6410
+ if (path === null) continue;
6411
+ const code = parts[i];
6412
+ changes.push({
6413
+ path,
6414
+ status: code === "A" ? "added" : code === "D" ? "deleted" : "modified"
6415
+ });
6416
+ }
6417
+ return changes;
6418
+ },
6419
+ async file(rootPath) {
6420
+ const { repo } = await need();
6421
+ const name = await defaultName();
6422
+ if (name === null) throw new GitError("the default branch is not known");
6423
+ return blobAt(repo, await defaultRef(repo, name), rootPath);
6424
+ }
6425
+ },
6426
+ async openPr() {
6427
+ const f = await lookup();
6428
+ if (!f) return null;
6429
+ const branch = await currentBranch(f.repo);
6430
+ if (branch === null || branch === await defaultName()) return null;
6431
+ return findOpenPr(f.repo, branch, await gh());
6432
+ },
6433
+ async pullRequestTemplate() {
6434
+ const f = await lookup();
6435
+ if (!f) return null;
6436
+ const path = templatePath((await runGit(f.repo.top, [
6437
+ "ls-tree",
6438
+ "--name-only",
6439
+ "HEAD",
6440
+ "--",
6441
+ ".",
6442
+ ".github/",
6443
+ "docs/"
6444
+ ]).catch(() => "")).split("\n"));
6445
+ return path === null ? null : runGit(f.repo.top, ["show", `HEAD:${path}`]).catch(() => null);
6446
+ },
6447
+ async review(req, o) {
6448
+ if (req.target !== null) throw new ReviewRefused(400, "this server cannot add to an existing pull request");
6449
+ const { repo, steps } = await need();
6450
+ return localReview(steps, req, {
6451
+ ...o,
6452
+ findOpenPr: async (branch) => findOpenPr(repo, branch, await gh())
6453
+ });
6394
6454
  }
6395
- },
6396
- history: (t, extract, o) => recordHistory(t, extract, o),
6397
- fileDiff: (t, rev) => fileDiff(t, rev),
6398
- async openPr() {
6399
- const f = await lookup();
6400
- if (!f) return null;
6401
- const branch = await currentBranch(f.repo);
6402
- if (branch === null || branch === await defaultName()) return null;
6403
- return findOpenPr(f.repo, branch, await gh());
6404
- },
6405
- async pullRequestTemplate() {
6406
- const f = await lookup();
6407
- if (!f) return null;
6408
- const path = templatePath((await runGit(f.repo.top, [
6409
- "ls-tree",
6410
- "--name-only",
6411
- "HEAD",
6412
- "--",
6413
- ".",
6414
- ".github/",
6415
- "docs/"
6416
- ]).catch(() => "")).split("\n"));
6417
- return path === null ? null : runGit(f.repo.top, ["show", `HEAD:${path}`]).catch(() => null);
6418
- },
6419
- async review(req, o) {
6420
- if (req.target !== null) throw new ReviewRefused(400, "this server cannot add to an existing pull request");
6421
- const { repo, steps } = await need();
6422
- return localReview(steps, req, {
6423
- ...o,
6424
- findOpenPr: async (branch) => findOpenPr(repo, branch, await gh())
6425
- });
6426
6455
  }
6427
6456
  };
6428
6457
  }
@@ -7043,7 +7072,8 @@ function reviewBody(body) {
7043
7072
  const gitRoutes = (router, ctx) => {
7044
7073
  router.add("GET", "/api/git", async () => {
7045
7074
  const git = ctx.git;
7046
- if (!git || !await git.hasRemote()) return { git: null };
7075
+ const review = git?.review;
7076
+ if (!git || !review || !await review.available()) return { git: null };
7047
7077
  const status = await git.status();
7048
7078
  const changes = await Promise.all(status.changes.map(async (c) => ({
7049
7079
  path: c.path,
@@ -7051,18 +7081,18 @@ const gitRoutes = (router, ctx) => {
7051
7081
  ...summary(await recordChanges(git, ctx.root, ctx.y.tables, c.path))
7052
7082
  })));
7053
7083
  changes.sort((a, b) => a.path.localeCompare(b.path));
7054
- const defaultBranch = await git.defaultBranch();
7084
+ const defaultBranch = await review.defaultBranch();
7055
7085
  return { git: {
7056
7086
  branch: status.branch,
7057
7087
  defaultBranch,
7058
7088
  upstream: status.upstream,
7059
- namesBranch: git.namesBranch === true,
7060
- restoresDefault: git.defaultBranchFiles !== void 0 && status.branch !== null && defaultBranch !== null && status.branch !== defaultBranch,
7089
+ namesBranch: review.namesBranch === true,
7090
+ restoresDefault: review.defaultBranchFiles !== void 0 && status.branch !== null && defaultBranch !== null && status.branch !== defaultBranch,
7061
7091
  changes
7062
7092
  } };
7063
7093
  });
7064
7094
  router.add("GET", "/api/git/default", async () => {
7065
- const from = ctx.git?.defaultBranchFiles;
7095
+ const from = ctx.git?.review?.defaultBranchFiles;
7066
7096
  if (!from) throw new HttpError(404, "this host cannot read the default branch");
7067
7097
  const [changes, status] = await Promise.all([from.changes().catch(notFound), ctx.git.status()]);
7068
7098
  const unsent = new Set(status.changes.map((c) => c.path));
@@ -7074,7 +7104,7 @@ const gitRoutes = (router, ctx) => {
7074
7104
  })).sort((a, b) => a.path.localeCompare(b.path)) };
7075
7105
  });
7076
7106
  router.add("POST", "/api/git/restore-default", async ({ body }) => {
7077
- const from = ctx.git?.defaultBranchFiles;
7107
+ const from = ctx.git?.review?.defaultBranchFiles;
7078
7108
  if (!from) throw new HttpError(404, "this host cannot read the default branch");
7079
7109
  const paths = objectBody(body, "body").files;
7080
7110
  if (!Array.isArray(paths) || paths.length === 0 || paths.some((p) => typeof p !== "string")) throw new HttpError(400, "choose at least one file", { field: "files" });
@@ -7129,16 +7159,16 @@ const gitRoutes = (router, ctx) => {
7129
7159
  }) };
7130
7160
  });
7131
7161
  router.add("POST", "/api/git/review", async ({ body }) => {
7132
- const git = ctx.git;
7133
- if (!git || !await git.hasRemote()) throw new HttpError(404, "the data folder is not in a git repository with an origin");
7162
+ const review = ctx.git?.review;
7163
+ if (!review || !await review.available()) throw new HttpError(404, "the data folder is not in a git repository with an origin");
7134
7164
  const req = reviewBody(body);
7135
- if (req.branch !== void 0 && !git.namesBranch) throw new HttpError(400, "this host names the branch for a review itself", { field: "branch" });
7165
+ if (req.branch !== void 0 && !review.namesBranch) throw new HttpError(400, "this host names the branch for a review itself", { field: "branch" });
7136
7166
  const target = objectBody(body, "body").target;
7137
7167
  if (target !== void 0 && target !== null && typeof target !== "string") throw new HttpError(400, "target must be a branch name or null", { field: "target" });
7138
7168
  return ctx.proposals.exclusive(async () => {
7139
7169
  assertSynced(await ctx.y.sync(), "could not write the latest edits to files for", "; nothing was sent");
7140
7170
  try {
7141
- return await git.review({
7171
+ return await review.review({
7142
7172
  ...req,
7143
7173
  target: target ?? null
7144
7174
  }, { afterTreeChange: async () => assertSynced(await ctx.y.sync(), "the database could not follow the files for") });
@@ -7152,7 +7182,7 @@ const gitRoutes = (router, ctx) => {
7152
7182
  router.add("GET", "/api/git/pr", async () => {
7153
7183
  const git = ctx.git;
7154
7184
  if (!git) throw new HttpError(404, "the data folder is not in a git repository");
7155
- return { url: await git.openPr?.().catch(notFound) ?? null };
7185
+ return { url: await git.review?.openPr?.().catch(notFound) ?? null };
7156
7186
  });
7157
7187
  router.add("POST", "/api/git/review/draft", async ({ body, signal }) => {
7158
7188
  const git = ctx.git;
@@ -7187,7 +7217,7 @@ const gitRoutes = (router, ctx) => {
7187
7217
  after: shownFile(join(ctx.root, path))
7188
7218
  };
7189
7219
  }));
7190
- const template = b.mode === "pr" ? await git.pullRequestTemplate?.() ?? null : null;
7220
+ const template = b.mode === "pr" ? await git.review?.pullRequestTemplate?.() ?? null : null;
7191
7221
  const release = ctx.agent.pageSlot();
7192
7222
  try {
7193
7223
  return await draftReview(languageModel, {
@@ -8396,7 +8426,7 @@ function inferKey(spec) {
8396
8426
  function columnsFor(spec, existing) {
8397
8427
  const files = makeSource(spec).read();
8398
8428
  if (files.tableError) throw new Error(`${spec.name}: ${files.tableError}`);
8399
- const shapes = checkShapes(files.records, existing ?? /* @__PURE__ */ new Map(), spec.columns);
8429
+ const shapes = checkShapes$1(files.records, existing ?? /* @__PURE__ */ new Map(), spec.columns);
8400
8430
  if (shapes.error) throw new Error(`${spec.name}: ${shapes.error}`);
8401
8431
  const columns = new Map(existing ?? []);
8402
8432
  for (const [column, type] of inferColumns(files.records.values())) if (!columns.has(column)) columns.set(column, spec.columns[column] ?? type);