@jvelo/tapemark 0.7.0 → 0.7.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.
Files changed (2) hide show
  1. package/dist/index.js +235 -235
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var Ie = Object.defineProperty;
2
2
  var Ee = (t, e, n) => e in t ? Ie(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var D = (t, e, n) => Ee(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { jsxs as b, jsx as o, Fragment as te } from "hono/jsx/jsx-runtime";
3
+ var F = (t, e, n) => Ee(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { jsxs as b, jsx as o, Fragment as ae } from "hono/jsx/jsx-runtime";
5
5
  import { renderToString as Se } from "hono/jsx/dom/server";
6
6
  const Re = {
7
7
  hubot: {
@@ -44,17 +44,17 @@ const Re = {
44
44
  accentText: "#181818"
45
45
  }
46
46
  }, de = "hubot";
47
- class J extends Error {
47
+ class $ extends Error {
48
48
  constructor(e, n, a) {
49
49
  super(n), this.status = e, this.detail = a, this.name = "TapemarkError";
50
50
  }
51
51
  }
52
- class U extends J {
52
+ class U extends $ {
53
53
  constructor(e, n) {
54
54
  super(404, e, n), this.name = "NotFoundError";
55
55
  }
56
56
  }
57
- class M extends J {
57
+ class M extends $ {
58
58
  constructor(e, n) {
59
59
  super(400, e, n), this.name = "ValidationError";
60
60
  }
@@ -83,7 +83,7 @@ function Be(t) {
83
83
  function be(t, e, n) {
84
84
  return n && e.length === 1 && e[0] === t.name && t.affinity === "integer";
85
85
  }
86
- class F extends U {
86
+ class O extends U {
87
87
  constructor(e, n) {
88
88
  super(
89
89
  `${e} not found: ${n}`,
@@ -108,16 +108,16 @@ class X {
108
108
  /** Validate that a table or view name exists and is safe to use in SQL. */
109
109
  async assertTable(e) {
110
110
  if (!pe.test(e))
111
- throw new F("table", e);
111
+ throw new O("table", e);
112
112
  if (!(await this.getTableNames()).includes(e))
113
- throw new F("table", e);
113
+ throw new O("table", e);
114
114
  }
115
115
  /** Validate that a column belongs to the given table. */
116
116
  async assertColumn(e, n) {
117
117
  if (!pe.test(n))
118
- throw new F("column", n);
118
+ throw new O("column", n);
119
119
  if (!(await this.getTable(e)).columns.some((r) => r.name === n))
120
- throw new F("column", n);
120
+ throw new O("column", n);
121
121
  }
122
122
  /** Foreign keys for a table (views have none). */
123
123
  async getForeignKeys(e) {
@@ -128,7 +128,7 @@ class X {
128
128
  }
129
129
  const r = [];
130
130
  for (const s of a.values())
131
- s.sort((i, m) => i.seq - m.seq), r.push({
131
+ s.sort((i, c) => i.seq - c.seq), r.push({
132
132
  columns: s.map((i) => i.from),
133
133
  referencedTable: s[0].table,
134
134
  referencedColumns: s.map((i) => i.to),
@@ -147,7 +147,7 @@ class X {
147
147
  nullable: d.notnull === 0,
148
148
  defaultValue: d.dflt_value,
149
149
  primaryKeyPosition: d.pk > 0 ? d.pk : null
150
- })), m = r === "view" ? [] : i.filter((d) => d.primaryKeyPosition !== null).sort((d, c) => d.primaryKeyPosition - c.primaryKeyPosition).map((d) => d.name), p = r === "view" ? [] : await this.getForeignKeys(e);
150
+ })), c = r === "view" ? [] : i.filter((d) => d.primaryKeyPosition !== null).sort((d, m) => d.primaryKeyPosition - m.primaryKeyPosition).map((d) => d.name), p = r === "view" ? [] : await this.getForeignKeys(e);
151
151
  let f = r === "table";
152
152
  if (r === "table") {
153
153
  const d = await this.db.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name=?").bind(e).first();
@@ -159,7 +159,7 @@ class X {
159
159
  kind: r,
160
160
  hasRowid: f,
161
161
  columns: i,
162
- primaryKey: m,
162
+ primaryKey: c,
163
163
  foreignKeys: p,
164
164
  rowCount: (u == null ? void 0 : u.cnt) ?? 0
165
165
  };
@@ -181,16 +181,16 @@ class X {
181
181
  return { tables: e, hash: r };
182
182
  }
183
183
  }
184
- function se(t, e) {
184
+ function j(t, e) {
185
185
  return t.map((n) => encodeURIComponent(String(e[n] ?? ""))).join(",");
186
186
  }
187
- function j(t, e) {
187
+ function L(t, e) {
188
188
  const n = e.split(",").map(decodeURIComponent), a = {};
189
189
  for (let r = 0; r < t.length; r++)
190
190
  a[t[r]] = n[r] ?? "";
191
191
  return a;
192
192
  }
193
- function ae(t, e) {
193
+ function re(t, e) {
194
194
  if (t === "" && e.nullable) return null;
195
195
  if (e.affinity === "integer" || e.affinity === "real" || e.affinity === "numeric") {
196
196
  const n = Number(t);
@@ -200,16 +200,16 @@ function ae(t, e) {
200
200
  }
201
201
  class z {
202
202
  constructor(e) {
203
- D(this, "schema");
203
+ F(this, "schema");
204
204
  this.db = e, this.schema = new X(e);
205
205
  }
206
206
  /** Paginated row listing. */
207
207
  async getRows(e, n = 1, a = 50) {
208
- const r = await this.schema.getTable(e), s = (n - 1) * a, i = await this.db.prepare(`SELECT COUNT(*) as cnt FROM "${e}"`).first(), m = (i == null ? void 0 : i.cnt) ?? 0, p = await this.db.prepare(`SELECT * FROM "${e}" LIMIT ? OFFSET ?`).bind(a, s).all();
208
+ const r = await this.schema.getTable(e), s = (n - 1) * a, i = await this.db.prepare(`SELECT COUNT(*) as cnt FROM "${e}"`).first(), c = (i == null ? void 0 : i.cnt) ?? 0, p = await this.db.prepare(`SELECT * FROM "${e}" LIMIT ? OFFSET ?`).bind(a, s).all();
209
209
  return {
210
210
  columns: r.columns,
211
211
  rows: p,
212
- total: m,
212
+ total: c,
213
213
  page: n,
214
214
  pageSize: a
215
215
  };
@@ -221,7 +221,7 @@ class z {
221
221
  throw new M(
222
222
  `Table "${e}" has no primary key`
223
223
  );
224
- const r = O(a.primaryKey), s = a.primaryKey.map((m) => n[m]), i = await this.db.prepare(`SELECT * FROM "${e}" WHERE ${r}`).bind(...s).first();
224
+ const r = Y(a.primaryKey), s = a.primaryKey.map((c) => n[c]), i = await this.db.prepare(`SELECT * FROM "${e}" WHERE ${r}`).bind(...s).first();
225
225
  if (!i)
226
226
  throw new U(
227
227
  `Row not found in "${e}"`,
@@ -238,23 +238,23 @@ class z {
238
238
  );
239
239
  if (s.length === 0)
240
240
  throw new M("No valid columns to insert");
241
- const i = s.map(([u]) => `"${u}"`).join(", "), m = s.map(() => "?").join(", "), p = s.map(([u, d]) => ae(d, r.get(u)));
241
+ const i = s.map(([u]) => `"${u}"`).join(", "), c = s.map(() => "?").join(", "), p = s.map(([u, d]) => re(d, r.get(u)));
242
242
  return await this.db.prepare(
243
- `INSERT INTO "${e}" (${i}) VALUES (${m}) RETURNING *`
243
+ `INSERT INTO "${e}" (${i}) VALUES (${c}) RETURNING *`
244
244
  ).bind(...p).first() ?? n;
245
245
  }
246
246
  /** Update a row. PK columns in data are ignored. */
247
247
  async updateRow(e, n, a) {
248
- const r = await this.schema.getTable(e), s = new Set(r.primaryKey), i = new Map(r.columns.map((d) => [d.name, d])), m = Object.entries(a).filter(
248
+ const r = await this.schema.getTable(e), s = new Set(r.primaryKey), i = new Map(r.columns.map((d) => [d.name, d])), c = Object.entries(a).filter(
249
249
  ([d]) => i.has(d) && !s.has(d)
250
250
  );
251
- if (m.length === 0)
251
+ if (c.length === 0)
252
252
  throw new M("No valid columns to update");
253
- const p = m.map(([d]) => `"${d}" = ?`).join(", "), f = m.map(
254
- ([d, c]) => ae(c, i.get(d))
253
+ const p = c.map(([d]) => `"${d}" = ?`).join(", "), f = c.map(
254
+ ([d, m]) => re(m, i.get(d))
255
255
  ), u = r.primaryKey.map((d) => n[d]);
256
256
  await this.db.prepare(
257
- `UPDATE "${e}" SET ${p} WHERE ${O(r.primaryKey)}`
257
+ `UPDATE "${e}" SET ${p} WHERE ${Y(r.primaryKey)}`
258
258
  ).bind(...f, ...u).run();
259
259
  }
260
260
  /** Delete a single row by primary key. */
@@ -266,7 +266,7 @@ class z {
266
266
  );
267
267
  const r = a.primaryKey.map((s) => n[s]);
268
268
  await this.db.prepare(
269
- `DELETE FROM "${e}" WHERE ${O(a.primaryKey)}`
269
+ `DELETE FROM "${e}" WHERE ${Y(a.primaryKey)}`
270
270
  ).bind(...r).run();
271
271
  }
272
272
  /** Delete multiple rows by encoded PK strings. Each delete is a separate
@@ -280,24 +280,24 @@ class z {
280
280
  );
281
281
  let r = 0;
282
282
  for (const s of n) {
283
- const i = j(a.primaryKey, s);
283
+ const i = L(a.primaryKey, s);
284
284
  await this.db.prepare(
285
- `DELETE FROM "${e}" WHERE ${O(a.primaryKey)}`
286
- ).bind(...a.primaryKey.map((m) => i[m])).run(), r++;
285
+ `DELETE FROM "${e}" WHERE ${Y(a.primaryKey)}`
286
+ ).bind(...a.primaryKey.map((c) => i[c])).run(), r++;
287
287
  }
288
288
  return r;
289
289
  }
290
290
  }
291
- function O(t) {
291
+ function Y(t) {
292
292
  return t.map((e) => `"${e}" = ?`).join(" AND ");
293
293
  }
294
- function L(t, e) {
294
+ function G(t, e) {
295
295
  const n = e.order;
296
296
  if (!n || n.length === 0) return t;
297
297
  const a = new Map(t.map((i) => [i.name, i])), r = /* @__PURE__ */ new Set(), s = [];
298
298
  for (const i of n) {
299
- const m = a.get(i);
300
- !m || r.has(i) || (s.push(m), r.add(i));
299
+ const c = a.get(i);
300
+ !c || r.has(i) || (s.push(c), r.add(i));
301
301
  }
302
302
  for (const i of t)
303
303
  r.has(i.name) || s.push(i);
@@ -305,7 +305,7 @@ function L(t, e) {
305
305
  }
306
306
  class W {
307
307
  constructor(e) {
308
- D(this, "cache", /* @__PURE__ */ new Map());
308
+ F(this, "cache", /* @__PURE__ */ new Map());
309
309
  this.db = e;
310
310
  }
311
311
  async getTableConfig(e) {
@@ -337,10 +337,10 @@ class W {
337
337
  this.cache.clear();
338
338
  }
339
339
  }
340
- const ne = 1;
340
+ const te = 1;
341
341
  class Xe {
342
342
  constructor(e, n = !1, a = "enforce") {
343
- D(this, "initialized", !1);
343
+ F(this, "initialized", !1);
344
344
  this.db = e, this.readonlyMode = n, this.constraints = a;
345
345
  }
346
346
  /** Ensure tapemark tables exist and are up to date. Idempotent. */
@@ -354,7 +354,7 @@ class Xe {
354
354
  await this.createInitialSchema();
355
355
  else {
356
356
  const n = await this.getSchemaVersion();
357
- n < ne && await this.applyMigrations(n);
357
+ n < te && await this.applyMigrations(n);
358
358
  }
359
359
  await this.updateAppSchemaHash(), this.initialized = !0;
360
360
  }
@@ -383,7 +383,7 @@ class Xe {
383
383
  )`
384
384
  ).run(), await this.db.prepare(
385
385
  "INSERT OR REPLACE INTO _tapemark_meta (key, value) VALUES ('schema_version', ?)"
386
- ).bind(String(ne)).run();
386
+ ).bind(String(te)).run();
387
387
  }
388
388
  async getSchemaVersion() {
389
389
  const e = await this.db.prepare(
@@ -394,7 +394,7 @@ class Xe {
394
394
  async applyMigrations(e) {
395
395
  await this.db.prepare(
396
396
  "INSERT OR REPLACE INTO _tapemark_meta (key, value) VALUES ('schema_version', ?)"
397
- ).bind(String(ne)).run();
397
+ ).bind(String(te)).run();
398
398
  }
399
399
  async updateAppSchemaHash() {
400
400
  const n = (await this.db.prepare(
@@ -683,7 +683,7 @@ function he(t) {
683
683
  return ((a = n[0]) == null ? void 0 : a.name) ?? null;
684
684
  }
685
685
  async function Fe(t, e) {
686
- const n = t.params.table, a = t.query.q ?? "", r = t.query.value, s = parseInt(t.query.limit ?? String(Ge), 10), i = Math.min(Math.max(1, s), Ke), m = parseInt(t.query.offset ?? "0", 10), p = Math.max(0, m), f = t.query.label, u = new X(e.db), d = await u.getTable(n);
686
+ const n = t.params.table, a = t.query.q ?? "", r = t.query.value, s = parseInt(t.query.limit ?? String(Ge), 10), i = Math.min(Math.max(1, s), Ke), c = parseInt(t.query.offset ?? "0", 10), p = Math.max(0, c), f = t.query.label, u = new X(e.db), d = await u.getTable(n);
687
687
  if (d.primaryKey.length === 0)
688
688
  return {
689
689
  status: 400,
@@ -691,9 +691,9 @@ async function Fe(t, e) {
691
691
  html: JSON.stringify({ error: "table has no primary key" })
692
692
  };
693
693
  f !== void 0 && await u.assertColumn(n, f);
694
- const c = f ?? he(d), g = d.primaryKey[0], w = [`"${g}" as value`];
695
- if (c && c !== g && w.push(`"${c}" as label`), r) {
696
- const A = `SELECT ${w.join(", ")} FROM "${n}" WHERE "${g}" = ?`, P = (await e.db.prepare(A).bind(r).all()).map((E) => ({
694
+ const m = f ?? he(d), y = d.primaryKey[0], w = [`"${y}" as value`];
695
+ if (m && m !== y && w.push(`"${m}" as label`), r) {
696
+ const A = `SELECT ${w.join(", ")} FROM "${n}" WHERE "${y}" = ?`, P = (await e.db.prepare(A).bind(r).all()).map((E) => ({
697
697
  value: E.value,
698
698
  label: E.label !== void 0 ? String(E.label) : String(E.value)
699
699
  }));
@@ -704,8 +704,8 @@ async function Fe(t, e) {
704
704
  };
705
705
  }
706
706
  let C = "", R = [];
707
- a && c ? (C = `WHERE "${c}" LIKE ?`, R = [`%${a}%`]) : a && (C = `WHERE CAST("${g}" AS TEXT) LIKE ?`, R = [`%${a}%`]);
708
- const l = await e.db.prepare(`SELECT COUNT(*) as cnt FROM "${n}" ${C}`).bind(...R).first(), h = (l == null ? void 0 : l.cnt) ?? 0, y = `SELECT ${w.join(", ")} FROM "${n}" ${C} LIMIT ? OFFSET ?`, I = (await e.db.prepare(y).bind(...R, i, p).all()).map((A) => ({
707
+ a && m ? (C = `WHERE "${m}" LIKE ?`, R = [`%${a}%`]) : a && (C = `WHERE CAST("${y}" AS TEXT) LIKE ?`, R = [`%${a}%`]);
708
+ const l = await e.db.prepare(`SELECT COUNT(*) as cnt FROM "${n}" ${C}`).bind(...R).first(), h = (l == null ? void 0 : l.cnt) ?? 0, g = `SELECT ${w.join(", ")} FROM "${n}" ${C} LIMIT ? OFFSET ?`, I = (await e.db.prepare(g).bind(...R, i, p).all()).map((A) => ({
709
709
  value: A.value,
710
710
  label: A.label !== void 0 ? String(A.label) : String(A.value)
711
711
  }));
@@ -727,7 +727,7 @@ function Z({
727
727
  siteUrl: r,
728
728
  siteName: s = "site",
729
729
  crumbs: i = [],
730
- scripts: m = [],
730
+ scripts: c = [],
731
731
  children: p
732
732
  }) {
733
733
  const f = `${e}/_tapemark/styles.css`, u = `${e}/_tapemark/admin.js`, d = a ? `${a} ${t} — ${n}` : `${t} — ${n}`;
@@ -739,20 +739,20 @@ function Z({
739
739
  a && /* @__PURE__ */ o("link", { rel: "icon", href: Oe(a) }),
740
740
  /* @__PURE__ */ o("link", { rel: "stylesheet", href: f }),
741
741
  /* @__PURE__ */ o("script", { src: u, defer: !0 }),
742
- m.map((c) => /* @__PURE__ */ o("script", { src: c, defer: !0 }))
742
+ c.map((m) => /* @__PURE__ */ o("script", { src: m, defer: !0 }))
743
743
  ] }),
744
744
  /* @__PURE__ */ o("body", { children: /* @__PURE__ */ b("div", { class: "tm", children: [
745
745
  /* @__PURE__ */ b("div", { class: "tm-bar", children: [
746
746
  /* @__PURE__ */ o("span", { class: "tm-bar-title", children: /* @__PURE__ */ b("a", { href: e || "/", children: [
747
- a && /* @__PURE__ */ b(te, { children: [
747
+ a && /* @__PURE__ */ b(ae, { children: [
748
748
  /* @__PURE__ */ o("span", { class: "tm-symbol", "aria-hidden": "true", children: a }),
749
749
  " "
750
750
  ] }),
751
751
  n
752
752
  ] }) }),
753
- i.length > 0 && /* @__PURE__ */ o("div", { class: "tm-crumbs", children: i.map((c, g) => /* @__PURE__ */ b(te, { children: [
754
- g > 0 && /* @__PURE__ */ o("span", { children: "/" }),
755
- c.href ? /* @__PURE__ */ o("a", { href: c.href, children: c.label }) : /* @__PURE__ */ o("span", { children: c.label })
753
+ i.length > 0 && /* @__PURE__ */ o("div", { class: "tm-crumbs", children: i.map((m, y) => /* @__PURE__ */ b(ae, { children: [
754
+ y > 0 && /* @__PURE__ */ o("span", { children: "/" }),
755
+ m.href ? /* @__PURE__ */ o("a", { href: m.href, children: m.label }) : /* @__PURE__ */ o("span", { children: m.label })
756
756
  ] })) }),
757
757
  r && /* @__PURE__ */ b("a", { href: r, class: "tm-bar-site", children: [
758
758
  "← ",
@@ -777,7 +777,7 @@ function Je({
777
777
  symbol: r,
778
778
  siteUrl: s,
779
779
  siteName: i,
780
- scripts: m
780
+ scripts: c
781
781
  }) {
782
782
  const p = Ye[t] ?? `Error ${t}`, f = e !== p ? e : void 0;
783
783
  return /* @__PURE__ */ o(
@@ -789,7 +789,7 @@ function Je({
789
789
  symbol: r,
790
790
  siteUrl: s,
791
791
  siteName: i,
792
- scripts: m,
792
+ scripts: c,
793
793
  children: /* @__PURE__ */ b("div", { class: "tm-error", children: [
794
794
  /* @__PURE__ */ o("span", { class: "tm-error-status", children: t }),
795
795
  /* @__PURE__ */ o("span", { class: "tm-error-label", children: p }),
@@ -802,7 +802,7 @@ function Je({
802
802
  function N(t) {
803
803
  return "<!DOCTYPE html>" + Se(t);
804
804
  }
805
- function Y(t, e, n) {
805
+ function J(t, e, n) {
806
806
  const a = N(
807
807
  /* @__PURE__ */ o(
808
808
  Je,
@@ -845,11 +845,11 @@ async function $e(t, e) {
845
845
  var f;
846
846
  return !((f = e.tableOptions.get(p.name)) != null && f.hidden);
847
847
  }
848
- ), s = r.filter((p) => p.kind === "table"), i = r.filter((p) => p.kind === "view"), m = N(
848
+ ), s = r.filter((p) => p.kind === "table"), i = r.filter((p) => p.kind === "view"), c = N(
849
849
  /* @__PURE__ */ b(Z, { title: "tables", prefix: e.prefix, name: e.name, symbol: e.symbol, siteUrl: e.siteUrl, siteName: e.siteName, scripts: e.scripts, children: [
850
850
  /* @__PURE__ */ o("h2", { class: "tm-section-title", children: "tables" }),
851
851
  /* @__PURE__ */ o(ue, { items: s, prefix: e.prefix }),
852
- i.length > 0 && /* @__PURE__ */ b(te, { children: [
852
+ i.length > 0 && /* @__PURE__ */ b(ae, { children: [
853
853
  /* @__PURE__ */ o("h2", { class: "tm-section-title tm-section-views", children: "views" }),
854
854
  /* @__PURE__ */ o(ue, { items: i, prefix: e.prefix })
855
855
  ] })
@@ -858,10 +858,10 @@ async function $e(t, e) {
858
858
  return {
859
859
  status: 200,
860
860
  headers: { "content-type": "text/html; charset=utf-8" },
861
- html: m
861
+ html: c
862
862
  };
863
863
  }
864
- function $(t, e) {
864
+ function _(t, e) {
865
865
  const n = t.executionContext;
866
866
  return {
867
867
  db: t.db,
@@ -890,19 +890,19 @@ async function ie(t) {
890
890
  async function _e(t, e, n, a) {
891
891
  var s;
892
892
  const r = (s = oe(t, n)) == null ? void 0 : s.afterInsert;
893
- return r ? ie(() => r(e, $(n, a))) : null;
893
+ return r ? ie(() => r(e, _(n, a))) : null;
894
894
  }
895
895
  async function ge(t, e, n, a, r) {
896
896
  var i;
897
897
  const s = (i = oe(t, a)) == null ? void 0 : i.afterUpdate;
898
- return s ? ie(() => s(e, n, $(a, r))) : null;
898
+ return s ? ie(() => s(e, n, _(a, r))) : null;
899
899
  }
900
900
  async function ye(t, e, n, a) {
901
901
  var s;
902
902
  const r = (s = oe(t, n)) == null ? void 0 : s.afterDelete;
903
- return r ? ie(() => r(e, $(n, a))) : null;
903
+ return r ? ie(() => r(e, _(n, a))) : null;
904
904
  }
905
- function re(t, e) {
905
+ function se(t, e) {
906
906
  if (!t.visible) return !0;
907
907
  try {
908
908
  return t.visible(e);
@@ -911,17 +911,17 @@ function re(t, e) {
911
911
  }
912
912
  }
913
913
  async function en(t, e, n, a, r) {
914
- var i, m;
915
- const s = (m = (i = a.tableOptions.get(t)) == null ? void 0 : i.actions) == null ? void 0 : m[e];
914
+ var i, c;
915
+ const s = (c = (i = a.tableOptions.get(t)) == null ? void 0 : i.actions) == null ? void 0 : c[e];
916
916
  if (!s)
917
917
  return { success: !1, message: `Action "${e}" not found on "${t}"` };
918
918
  try {
919
- return await s.handler(n, $(a, r));
919
+ return await s.handler(n, _(a, r));
920
920
  } catch (p) {
921
921
  return { success: !1, message: p instanceof Error ? p.message : String(p) };
922
922
  }
923
923
  }
924
- function G(t, e) {
924
+ function K(t, e) {
925
925
  return e ? {
926
926
  flash: "warning",
927
927
  message: `${t} — hook failed: ${e}`
@@ -946,37 +946,37 @@ function tn({
946
946
  encodePk: r,
947
947
  tableConfig: s,
948
948
  displayTypes: i,
949
- page: m = 1,
949
+ page: c = 1,
950
950
  pageSize: p = 50,
951
951
  kind: f = "table",
952
952
  actions: u
953
953
  }) {
954
- const d = new Set(e), c = e.length > 0, g = f === "view", w = t.filter((l) => {
955
- var y;
956
- const h = (y = s.columns) == null ? void 0 : y[l.name];
954
+ const d = new Set(e), m = e.length > 0, y = f === "view", w = t.filter((l) => {
955
+ var g;
956
+ const h = (g = s.columns) == null ? void 0 : g[l.name];
957
957
  return !(h != null && h.hidden);
958
958
  }), C = Object.entries(u ?? {}).filter(([, l]) => {
959
959
  var h;
960
960
  return ((h = l.display) == null ? void 0 : h.list) === !0;
961
- }), R = c && !g && C.length > 0;
961
+ }), R = m && !y && C.length > 0;
962
962
  return n.length === 0 ? /* @__PURE__ */ o("p", { class: "tm-empty", children: "empty table" }) : /* @__PURE__ */ b("div", { class: "tm-table-scroll", children: [
963
963
  /* @__PURE__ */ b("form", { method: "post", action: `${a}/_bulk-delete`, id: "tm-bulk-form", children: [
964
- /* @__PURE__ */ o("input", { type: "hidden", name: "page", value: String(m) }),
964
+ /* @__PURE__ */ o("input", { type: "hidden", name: "page", value: String(c) }),
965
965
  /* @__PURE__ */ b("table", { children: [
966
966
  /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ b("tr", { children: [
967
967
  w.map((l) => {
968
- var y;
969
- const h = (y = s.columns) == null ? void 0 : y[l.name];
968
+ var g;
969
+ const h = (g = s.columns) == null ? void 0 : g[l.name];
970
970
  return /* @__PURE__ */ b("th", { class: d.has(l.name) ? "tm-pk-col" : "", children: [
971
971
  (h == null ? void 0 : h.label) || l.name,
972
972
  d.has(l.name) && " ●"
973
973
  ] });
974
974
  }),
975
975
  R && /* @__PURE__ */ o("th", { class: "tm-row-action-col", children: "actions" }),
976
- c && !g && /* @__PURE__ */ o("th", { class: "tm-select-col", children: /* @__PURE__ */ o("input", { type: "checkbox", class: "tm-row-select", id: "tm-select-all" }) })
976
+ m && !y && /* @__PURE__ */ o("th", { class: "tm-select-col", children: /* @__PURE__ */ o("input", { type: "checkbox", class: "tm-row-select", id: "tm-select-all" }) })
977
977
  ] }) }),
978
978
  /* @__PURE__ */ o("tbody", { children: n.map((l, h) => {
979
- const y = c && !g ? `${a}/${r(l)}` : `${a}/_row/${(m - 1) * p + h}`, v = c ? r(l) : "";
979
+ const g = m && !y ? `${a}/${r(l)}` : `${a}/_row/${(c - 1) * p + h}`, v = m ? r(l) : "";
980
980
  return /* @__PURE__ */ b("tr", { children: [
981
981
  w.map((I) => {
982
982
  var E;
@@ -984,12 +984,12 @@ function tn({
984
984
  return /* @__PURE__ */ o("td", { children: /* @__PURE__ */ o(
985
985
  "a",
986
986
  {
987
- href: y,
987
+ href: g,
988
988
  dangerouslySetInnerHTML: { __html: P }
989
989
  }
990
990
  ) });
991
991
  }),
992
- R && /* @__PURE__ */ o("td", { class: "tm-row-action-col", children: C.filter(([, I]) => re(I, l)).map(([I, A]) => /* @__PURE__ */ o(
992
+ R && /* @__PURE__ */ o("td", { class: "tm-row-action-col", children: C.filter(([, I]) => se(I, l)).map(([I, A]) => /* @__PURE__ */ o(
993
993
  "button",
994
994
  {
995
995
  type: "submit",
@@ -998,7 +998,7 @@ function tn({
998
998
  children: A.label
999
999
  }
1000
1000
  )) }),
1001
- c && !g && /* @__PURE__ */ o("td", { class: "tm-select-col", children: /* @__PURE__ */ o(
1001
+ m && !y && /* @__PURE__ */ o("td", { class: "tm-select-col", children: /* @__PURE__ */ o(
1002
1002
  "input",
1003
1003
  {
1004
1004
  type: "checkbox",
@@ -1013,12 +1013,12 @@ function tn({
1013
1013
  ] }),
1014
1014
  R && n.map((l) => {
1015
1015
  const h = r(l);
1016
- return C.filter(([, y]) => re(y, l)).map(([y]) => /* @__PURE__ */ o(
1016
+ return C.filter(([, g]) => se(g, l)).map(([g]) => /* @__PURE__ */ o(
1017
1017
  "form",
1018
1018
  {
1019
1019
  method: "post",
1020
- action: `${a}/${h}/_action/${y}`,
1021
- id: `tm-act-${h}-${y}`,
1020
+ action: `${a}/${h}/_action/${g}`,
1021
+ id: `tm-act-${h}-${g}`,
1022
1022
  class: "tm-table-action-form",
1023
1023
  children: /* @__PURE__ */ o("input", { type: "hidden", name: "_back", value: "table" })
1024
1024
  }
@@ -1029,20 +1029,20 @@ function tn({
1029
1029
  function an({ page: t, pageSize: e, total: n, baseUrl: a }) {
1030
1030
  const r = Math.ceil(n / e);
1031
1031
  if (r <= 1) return null;
1032
- const s = a.includes("?") ? "&" : "?", i = (t - 1) * e + 1, m = Math.min(t * e, n);
1032
+ const s = a.includes("?") ? "&" : "?", i = (t - 1) * e + 1, c = Math.min(t * e, n);
1033
1033
  return /* @__PURE__ */ b("div", { class: "tm-pager", children: [
1034
1034
  t > 1 && /* @__PURE__ */ o("a", { href: `${a}${s}page=${t - 1}`, children: "prev" }),
1035
1035
  /* @__PURE__ */ b("span", { class: "tm-pager-current", children: [
1036
1036
  i,
1037
1037
  "–",
1038
- m,
1038
+ c,
1039
1039
  " of ",
1040
1040
  n
1041
1041
  ] }),
1042
1042
  t < r && /* @__PURE__ */ o("a", { href: `${a}${s}page=${t + 1}`, children: "next" })
1043
1043
  ] });
1044
1044
  }
1045
- function _({ type: t, message: e }) {
1045
+ function ee({ type: t, message: e }) {
1046
1046
  if (!e) return null;
1047
1047
  let n, a;
1048
1048
  return t === "error" ? (n = "tm-flash tm-flash-error", a = "✗ ") : t === "warning" ? (n = "tm-flash tm-flash-warning", a = "⚠ ") : (n = "tm-flash tm-flash-success", a = "→ "), /* @__PURE__ */ b("div", { class: n, id: "tm-flash", children: [
@@ -1054,13 +1054,13 @@ async function rn(t, e, n, a, r) {
1054
1054
  var p, f;
1055
1055
  const s = e.filter((u) => u.columns.length === 1);
1056
1056
  if (s.length === 0) return a;
1057
- const i = new X(t), m = {
1057
+ const i = new X(t), c = {
1058
1058
  ...a,
1059
1059
  columns: { ...a.columns }
1060
1060
  };
1061
1061
  for (const u of s) {
1062
- const d = u.columns[0], c = (p = m.columns) == null ? void 0 : p[d], g = (c == null ? void 0 : c.display) === "reference", w = !(c != null && c.display);
1063
- if (!g && !w) continue;
1062
+ const d = u.columns[0], m = (p = c.columns) == null ? void 0 : p[d], y = (m == null ? void 0 : m.display) === "reference", w = !(m != null && m.display);
1063
+ if (!y && !w) continue;
1064
1064
  const C = /* @__PURE__ */ new Set();
1065
1065
  for (const E of n) {
1066
1066
  const x = E[d];
@@ -1073,30 +1073,30 @@ async function rn(t, e, n, a, r) {
1073
1073
  } catch {
1074
1074
  continue;
1075
1075
  }
1076
- const l = (f = c == null ? void 0 : c.options) == null ? void 0 : f.labelColumn;
1076
+ const l = (f = m == null ? void 0 : m.options) == null ? void 0 : f.labelColumn;
1077
1077
  if (l !== void 0)
1078
1078
  try {
1079
1079
  await i.assertColumn(u.referencedTable, l);
1080
1080
  } catch {
1081
1081
  continue;
1082
1082
  }
1083
- const h = l ?? he(R), y = u.referencedColumns[0], v = [...C].map(() => "?").join(", "), I = [`"${y}" as value`];
1084
- h && h !== y && I.push(`"${h}" as label`);
1085
- const A = `SELECT ${I.join(", ")} FROM "${u.referencedTable}" WHERE "${y}" IN (${v})`, k = await t.prepare(A).bind(...C).all(), P = {};
1083
+ const h = l ?? he(R), g = u.referencedColumns[0], v = [...C].map(() => "?").join(", "), I = [`"${g}" as value`];
1084
+ h && h !== g && I.push(`"${h}" as label`);
1085
+ const A = `SELECT ${I.join(", ")} FROM "${u.referencedTable}" WHERE "${g}" IN (${v})`, k = await t.prepare(A).bind(...C).all(), P = {};
1086
1086
  for (const E of k)
1087
1087
  P[String(E.value)] = E.label !== void 0 ? String(E.label) : String(E.value);
1088
- m.columns = m.columns ?? {}, m.columns[d] = {
1089
- ...c,
1090
- display: (c == null ? void 0 : c.display) ?? "reference",
1088
+ c.columns = c.columns ?? {}, c.columns[d] = {
1089
+ ...m,
1090
+ display: (m == null ? void 0 : m.display) ?? "reference",
1091
1091
  options: {
1092
- ...c == null ? void 0 : c.options,
1092
+ ...m == null ? void 0 : m.options,
1093
1093
  table: `${r}/${u.referencedTable}`,
1094
1094
  _refTable: u.referencedTable,
1095
1095
  _labels: P
1096
1096
  }
1097
1097
  };
1098
1098
  }
1099
- return m;
1099
+ return c;
1100
1100
  }
1101
1101
  async function sn(t, e) {
1102
1102
  var l, h;
@@ -1106,7 +1106,7 @@ async function sn(t, e) {
1106
1106
  p.rows,
1107
1107
  u,
1108
1108
  e.prefix
1109
- ), c = i.primaryKey.length > 0, w = i.kind === "view" || e.readonly || ((l = e.tableOptions.get(n)) == null ? void 0 : l.readonly), C = [
1109
+ ), m = i.primaryKey.length > 0, w = i.kind === "view" || e.readonly || ((l = e.tableOptions.get(n)) == null ? void 0 : l.readonly), C = [
1110
1110
  { label: "tables", href: e.prefix || "/" },
1111
1111
  { label: n }
1112
1112
  ], R = N(
@@ -1122,7 +1122,7 @@ async function sn(t, e) {
1122
1122
  crumbs: C,
1123
1123
  scripts: e.scripts,
1124
1124
  children: [
1125
- /* @__PURE__ */ o(_, { type: t.query.flash, message: t.query.msg }),
1125
+ /* @__PURE__ */ o(ee, { type: t.query.flash, message: t.query.msg }),
1126
1126
  /* @__PURE__ */ b("div", { class: "tm-toolbar", children: [
1127
1127
  /* @__PURE__ */ b("h2", { class: "tm-section-title", children: [
1128
1128
  n,
@@ -1135,7 +1135,7 @@ async function sn(t, e) {
1135
1135
  ] }),
1136
1136
  /* @__PURE__ */ b("div", { class: "tm-actions", children: [
1137
1137
  !e.readonly && /* @__PURE__ */ o("a", { href: `${e.prefix}/${n}/_config`, class: "tm-btn", children: "config" }),
1138
- c && !w && /* @__PURE__ */ o(
1138
+ m && !w && /* @__PURE__ */ o(
1139
1139
  "a",
1140
1140
  {
1141
1141
  href: `${e.prefix}/${n}/new`,
@@ -1148,11 +1148,11 @@ async function sn(t, e) {
1148
1148
  /* @__PURE__ */ o(
1149
1149
  tn,
1150
1150
  {
1151
- columns: L(i.columns, d),
1151
+ columns: G(i.columns, d),
1152
1152
  primaryKey: i.primaryKey,
1153
1153
  rows: p.rows,
1154
1154
  linkBase: `${e.prefix}/${n}`,
1155
- encodePk: (y) => se(i.primaryKey, y),
1155
+ encodePk: (g) => j(i.primaryKey, g),
1156
1156
  tableConfig: d,
1157
1157
  displayTypes: e.displayTypes,
1158
1158
  page: a,
@@ -1171,7 +1171,7 @@ async function sn(t, e) {
1171
1171
  baseUrl: `${e.prefix}/${n}`
1172
1172
  }
1173
1173
  ),
1174
- c && !w && /* @__PURE__ */ o("tm-confirm-button", { "data-message": "delete selected rows?", children: /* @__PURE__ */ o(
1174
+ m && !w && /* @__PURE__ */ o("tm-confirm-button", { "data-message": "delete selected rows?", children: /* @__PURE__ */ o(
1175
1175
  "button",
1176
1176
  {
1177
1177
  type: "submit",
@@ -1216,32 +1216,32 @@ function le({
1216
1216
  values: r,
1217
1217
  action: s,
1218
1218
  submitLabel: i,
1219
- formId: m,
1219
+ formId: c,
1220
1220
  tableConfig: p,
1221
1221
  displayTypes: f,
1222
1222
  prefix: u,
1223
1223
  constraints: d = "enforce",
1224
- formReadonly: c = !1
1224
+ formReadonly: m = !1
1225
1225
  }) {
1226
- const g = !!r, w = new Set(e), C = d === "enforce", R = /* @__PURE__ */ new Map();
1226
+ const y = !!r, w = new Set(e), C = d === "enforce", R = /* @__PURE__ */ new Map();
1227
1227
  for (const l of a ?? [])
1228
1228
  l.columns.length === 1 && R.set(l.columns[0], l);
1229
- return /* @__PURE__ */ b("form", { method: "post", action: s, class: "tm-form", id: m, children: [
1229
+ return /* @__PURE__ */ b("form", { method: "post", action: s, class: "tm-form", id: c, children: [
1230
1230
  u && /* @__PURE__ */ o("script", { dangerouslySetInnerHTML: { __html: `window.__tapemarkPrefix = ${JSON.stringify(u)};` } }),
1231
1231
  t.map((l) => {
1232
1232
  var me;
1233
- const h = r == null ? void 0 : r[l.name], y = h == null ? "" : String(h), v = w.has(l.name), I = v && g, A = (me = p == null ? void 0 : p.columns) == null ? void 0 : me[l.name];
1234
- if (!g && be(l, e, n) && !(A != null && A.showOnCreate))
1233
+ const h = r == null ? void 0 : r[l.name], g = h == null ? "" : String(h), v = w.has(l.name), I = v && y, A = (me = p == null ? void 0 : p.columns) == null ? void 0 : me[l.name];
1234
+ if (!y && be(l, e, n) && !(A != null && A.showOnCreate))
1235
1235
  return null;
1236
1236
  const k = C && !l.nullable && !v && l.defaultValue === null, P = A == null ? void 0 : A.display, E = P ? f == null ? void 0 : f.get(P) : void 0, x = R.get(l.name), B = !P && x, q = B ? f == null ? void 0 : f.get("reference") : void 0;
1237
1237
  if (!I && (E != null && E.renderInput)) {
1238
- const ee = E.renderInput(l, h, (A == null ? void 0 : A.options) ?? {});
1238
+ const ne = E.renderInput(l, h, (A == null ? void 0 : A.options) ?? {});
1239
1239
  return /* @__PURE__ */ b("div", { class: "tm-field", children: [
1240
1240
  /* @__PURE__ */ b("label", { for: `f-${l.name}`, children: [
1241
1241
  l.name,
1242
1242
  k ? " *" : ""
1243
1243
  ] }),
1244
- /* @__PURE__ */ o("div", { dangerouslySetInnerHTML: { __html: ee } }),
1244
+ /* @__PURE__ */ o("div", { dangerouslySetInnerHTML: { __html: ne } }),
1245
1245
  /* @__PURE__ */ b("span", { class: "tm-field-hint", children: [
1246
1246
  l.rawType || "TEXT",
1247
1247
  l.defaultValue ? ` · default: ${l.defaultValue}` : ""
@@ -1249,7 +1249,7 @@ function le({
1249
1249
  ] });
1250
1250
  }
1251
1251
  if (!I && B && (q != null && q.renderInput)) {
1252
- const ee = { table: x.referencedTable }, ve = q.renderInput(l, h, ee);
1252
+ const ne = { table: x.referencedTable }, ve = q.renderInput(l, h, ne);
1253
1253
  return /* @__PURE__ */ b("div", { class: "tm-field", children: [
1254
1254
  /* @__PURE__ */ b("label", { for: `f-${l.name}`, children: [
1255
1255
  l.name,
@@ -1263,7 +1263,7 @@ function le({
1263
1263
  ] })
1264
1264
  ] });
1265
1265
  }
1266
- const { type: K, useTextarea: Ae } = on(l, A), Ce = Ae || ln(h);
1266
+ const { type: D, useTextarea: Ae } = on(l, A), Ce = Ae || ln(h);
1267
1267
  return /* @__PURE__ */ b("div", { class: "tm-field", children: [
1268
1268
  /* @__PURE__ */ b("label", { for: `f-${l.name}`, children: [
1269
1269
  l.name,
@@ -1275,19 +1275,19 @@ function le({
1275
1275
  id: `f-${l.name}`,
1276
1276
  name: l.name,
1277
1277
  required: k,
1278
- children: y
1278
+ children: g
1279
1279
  }
1280
1280
  ) : /* @__PURE__ */ o(
1281
1281
  "input",
1282
1282
  {
1283
1283
  id: `f-${l.name}`,
1284
1284
  name: I ? void 0 : l.name,
1285
- type: K,
1286
- value: y,
1285
+ type: D,
1286
+ value: g,
1287
1287
  disabled: I,
1288
- required: k && !g,
1288
+ required: k && !y,
1289
1289
  placeholder: l.defaultValue ? `default: ${l.defaultValue}` : void 0,
1290
- step: K === "number" ? "any" : void 0
1290
+ step: D === "number" ? "any" : void 0
1291
1291
  }
1292
1292
  ),
1293
1293
  /* @__PURE__ */ b("span", { class: "tm-field-hint", children: [
@@ -1298,25 +1298,25 @@ function le({
1298
1298
  ] })
1299
1299
  ] });
1300
1300
  }),
1301
- !m && !c && /* @__PURE__ */ o("div", { class: "tm-actions", children: /* @__PURE__ */ o("button", { type: "submit", class: "tm-btn tm-btn-primary", children: i }) })
1301
+ !c && !m && /* @__PURE__ */ o("div", { class: "tm-actions", children: /* @__PURE__ */ o("button", { type: "submit", class: "tm-btn tm-btn-primary", children: i }) })
1302
1302
  ] });
1303
1303
  }
1304
1304
  function T(t, e, n = "table") {
1305
1305
  var a;
1306
1306
  if (n === "view" || e.readonly || (a = e.tableOptions.get(t)) != null && a.readonly)
1307
- throw new J(403, "This table is read-only");
1307
+ throw new $(403, "This table is read-only");
1308
1308
  }
1309
1309
  async function cn(t, e) {
1310
- const n = t.params.table, a = t.params.pk, s = await new X(e.db).getTable(n), i = new z(e.db), m = new W(e.db), p = j(s.primaryKey, a), f = await i.getRow(n, p), u = await m.getTableConfig(n), d = s.kind === "view", c = e.tableOptions.get(n), g = d || e.readonly || (c == null ? void 0 : c.readonly), w = Object.entries((c == null ? void 0 : c.actions) ?? {}).filter(
1311
- ([, l]) => {
1312
- var h;
1313
- return ((h = l.display) == null ? void 0 : h.detail) !== !1 && re(l, f);
1310
+ const n = t.params.table, a = t.params.pk, s = await new X(e.db).getTable(n), i = new z(e.db), c = new W(e.db), p = L(s.primaryKey, a), f = j(s.primaryKey, p), u = await i.getRow(n, p), d = await c.getTableConfig(n), m = s.kind === "view", y = e.tableOptions.get(n), w = m || e.readonly || (y == null ? void 0 : y.readonly), C = Object.entries((y == null ? void 0 : y.actions) ?? {}).filter(
1311
+ ([, h]) => {
1312
+ var g;
1313
+ return ((g = h.display) == null ? void 0 : g.detail) !== !1 && se(h, u);
1314
1314
  }
1315
- ), C = [
1315
+ ), R = [
1316
1316
  { label: "tables", href: e.prefix || "/" },
1317
1317
  { label: n, href: `${e.prefix}/${n}` },
1318
1318
  { label: a }
1319
- ], R = N(
1319
+ ], l = N(
1320
1320
  /* @__PURE__ */ b(
1321
1321
  Z,
1322
1322
  {
@@ -1326,46 +1326,46 @@ async function cn(t, e) {
1326
1326
  symbol: e.symbol,
1327
1327
  siteUrl: e.siteUrl,
1328
1328
  siteName: e.siteName,
1329
- crumbs: C,
1329
+ crumbs: R,
1330
1330
  scripts: e.scripts,
1331
1331
  children: [
1332
- /* @__PURE__ */ o(_, { type: t.query.flash, message: t.query.msg }),
1333
- /* @__PURE__ */ o("h2", { class: "tm-section-title", children: g ? "view row" : "edit row" }),
1332
+ /* @__PURE__ */ o(ee, { type: t.query.flash, message: t.query.msg }),
1333
+ /* @__PURE__ */ o("h2", { class: "tm-section-title", children: w ? "view row" : "edit row" }),
1334
1334
  /* @__PURE__ */ o(
1335
1335
  le,
1336
1336
  {
1337
- columns: L(s.columns, u),
1337
+ columns: G(s.columns, d),
1338
1338
  primaryKey: s.primaryKey,
1339
1339
  hasRowid: s.hasRowid,
1340
1340
  foreignKeys: s.foreignKeys,
1341
- values: f,
1342
- action: `${e.prefix}/${n}/${a}`,
1341
+ values: u,
1342
+ action: `${e.prefix}/${n}/${f}`,
1343
1343
  submitLabel: "save",
1344
- formId: g ? void 0 : "tm-edit-form",
1345
- formReadonly: g,
1346
- tableConfig: u,
1344
+ formId: w ? void 0 : "tm-edit-form",
1345
+ formReadonly: w,
1346
+ tableConfig: d,
1347
1347
  constraints: e.constraints,
1348
1348
  displayTypes: e.displayTypes,
1349
1349
  prefix: e.prefix
1350
1350
  }
1351
1351
  ),
1352
- !g && /* @__PURE__ */ b("div", { class: "tm-row-actions", children: [
1352
+ !w && /* @__PURE__ */ b("div", { class: "tm-row-actions", children: [
1353
1353
  /* @__PURE__ */ o("div", { class: "tm-row-actions-form", children: /* @__PURE__ */ o("button", { type: "submit", form: "tm-edit-form", class: "tm-btn tm-btn-primary", children: "save" }) }),
1354
1354
  /* @__PURE__ */ b("div", { class: "tm-row-actions-row", children: [
1355
- w.map(([l, h]) => /* @__PURE__ */ o(
1355
+ C.map(([h, g]) => /* @__PURE__ */ o(
1356
1356
  "form",
1357
1357
  {
1358
1358
  method: "post",
1359
- action: `${e.prefix}/${n}/${a}/_action/${l}`,
1359
+ action: `${e.prefix}/${n}/${f}/_action/${h}`,
1360
1360
  class: "tm-action-inline",
1361
- children: /* @__PURE__ */ o("button", { type: "submit", class: "tm-btn", children: h.label })
1361
+ children: /* @__PURE__ */ o("button", { type: "submit", class: "tm-btn", children: g.label })
1362
1362
  }
1363
1363
  )),
1364
1364
  /* @__PURE__ */ o(
1365
1365
  "form",
1366
1366
  {
1367
1367
  method: "post",
1368
- action: `${e.prefix}/${n}/${a}/delete`,
1368
+ action: `${e.prefix}/${n}/${f}/delete`,
1369
1369
  class: "tm-delete-inline",
1370
1370
  children: /* @__PURE__ */ o("tm-confirm-button", { "data-message": `delete row ${a}?`, children: /* @__PURE__ */ o("button", { type: "submit", class: "tm-btn tm-btn-danger", children: "delete row" }) })
1371
1371
  }
@@ -1379,34 +1379,34 @@ async function cn(t, e) {
1379
1379
  return {
1380
1380
  status: 200,
1381
1381
  headers: { "content-type": "text/html; charset=utf-8" },
1382
- html: R
1382
+ html: l
1383
1383
  };
1384
1384
  }
1385
1385
  async function mn(t, e) {
1386
1386
  const n = t.params.table, a = t.params.pk;
1387
1387
  T(n, e);
1388
- const s = await new X(e.db).getTable(n), i = new z(e.db), m = j(s.primaryKey, a), p = {};
1388
+ const s = await new X(e.db).getTable(n), i = new z(e.db), c = L(s.primaryKey, a), p = {};
1389
1389
  if (t.body)
1390
- for (const g of s.columns)
1391
- g.name in t.body && (p[g.name] = String(t.body[g.name]));
1392
- await i.updateRow(n, m, p);
1393
- const f = await ge(n, m, p, e, t), { flash: u, message: d } = G("row updated", f), c = se(s.primaryKey, { ...m, ...p });
1390
+ for (const y of s.columns)
1391
+ y.name in t.body && (p[y.name] = String(t.body[y.name]));
1392
+ await i.updateRow(n, c, p);
1393
+ const f = await ge(n, c, p, e, t), { flash: u, message: d } = K("row updated", f), m = j(s.primaryKey, { ...c, ...p });
1394
1394
  return V(
1395
- `${e.prefix}/${n}/${c}?flash=${u}&msg=${encodeURIComponent(d)}`
1395
+ `${e.prefix}/${n}/${m}?flash=${u}&msg=${encodeURIComponent(d)}`
1396
1396
  );
1397
1397
  }
1398
1398
  async function dn(t, e) {
1399
1399
  const n = t.params.table, a = t.params.pk;
1400
1400
  T(n, e);
1401
- const s = await new X(e.db).getTable(n), i = new z(e.db), m = j(s.primaryKey, a);
1402
- await i.deleteRow(n, m);
1403
- const p = await ye(n, m, e, t), { flash: f, message: u } = G("row deleted", p);
1401
+ const s = await new X(e.db).getTable(n), i = new z(e.db), c = L(s.primaryKey, a);
1402
+ await i.deleteRow(n, c);
1403
+ const p = await ye(n, c, e, t), { flash: f, message: u } = K("row deleted", p);
1404
1404
  return V(
1405
1405
  `${e.prefix}/${n}?flash=${f}&msg=${encodeURIComponent(u)}`
1406
1406
  );
1407
1407
  }
1408
1408
  async function pn(t, e) {
1409
- const n = t.params.table, r = await new X(e.db).getTable(n), i = await new W(e.db).getTableConfig(n), m = [
1409
+ const n = t.params.table, r = await new X(e.db).getTable(n), i = await new W(e.db).getTableConfig(n), c = [
1410
1410
  { label: "tables", href: e.prefix || "/" },
1411
1411
  { label: n, href: `${e.prefix}/${n}` },
1412
1412
  { label: "new" }
@@ -1420,14 +1420,14 @@ async function pn(t, e) {
1420
1420
  symbol: e.symbol,
1421
1421
  siteUrl: e.siteUrl,
1422
1422
  siteName: e.siteName,
1423
- crumbs: m,
1423
+ crumbs: c,
1424
1424
  scripts: e.scripts,
1425
1425
  children: [
1426
1426
  /* @__PURE__ */ o("h2", { class: "tm-section-title", children: "new row" }),
1427
1427
  /* @__PURE__ */ o(
1428
1428
  le,
1429
1429
  {
1430
- columns: L(r.columns, i),
1430
+ columns: G(r.columns, i),
1431
1431
  primaryKey: r.primaryKey,
1432
1432
  hasRowid: r.hasRowid,
1433
1433
  foreignKeys: r.foreignKeys,
@@ -1454,9 +1454,9 @@ async function un(t, e) {
1454
1454
  T(n, e);
1455
1455
  const r = await new X(e.db).getTable(n), s = new z(e.db), i = {};
1456
1456
  if (t.body)
1457
- for (const c of r.columns)
1458
- c.name in t.body && (i[c.name] = String(t.body[c.name]));
1459
- const m = await s.insertRow(n, i), p = await _e(n, m, e, t), { flash: f, message: u } = G("row created", p), d = se(r.primaryKey, m);
1457
+ for (const m of r.columns)
1458
+ m.name in t.body && (i[m.name] = String(t.body[m.name]));
1459
+ const c = await s.insertRow(n, i), p = await _e(n, c, e, t), { flash: f, message: u } = K("row created", p), d = j(r.primaryKey, c);
1460
1460
  return V(
1461
1461
  `${e.prefix}/${n}/${d}?flash=${f}&msg=${encodeURIComponent(u)}`
1462
1462
  );
@@ -1470,7 +1470,7 @@ function fn({
1470
1470
  config: s,
1471
1471
  displayTypes: i
1472
1472
  }) {
1473
- const m = Array.from(i.keys()), p = {};
1473
+ const c = Array.from(i.keys()), p = {};
1474
1474
  for (const [u, d] of i)
1475
1475
  p[u] = d.schema;
1476
1476
  const f = JSON.stringify(p);
@@ -1501,16 +1501,16 @@ function fn({
1501
1501
  ] }) }),
1502
1502
  /* @__PURE__ */ o("tbody", { children: n.map((u) => {
1503
1503
  var w;
1504
- const d = ((w = s.columns) == null ? void 0 : w[u.name]) ?? {}, c = JSON.stringify(d.options ?? {}), g = be(u, a, r);
1504
+ const d = ((w = s.columns) == null ? void 0 : w[u.name]) ?? {}, m = JSON.stringify(d.options ?? {}), y = be(u, a, r);
1505
1505
  return /* @__PURE__ */ b("tr", { children: [
1506
1506
  /* @__PURE__ */ o("td", { children: u.name }),
1507
1507
  /* @__PURE__ */ o("td", { class: "tm-muted", children: u.rawType || "TEXT" }),
1508
- /* @__PURE__ */ o("td", { children: /* @__PURE__ */ o("select", { name: `${u.name}__display`, children: m.map((C) => /* @__PURE__ */ o("option", { value: C, selected: d.display === C, children: C })) }) }),
1508
+ /* @__PURE__ */ o("td", { children: /* @__PURE__ */ o("select", { name: `${u.name}__display`, children: c.map((C) => /* @__PURE__ */ o("option", { value: C, selected: d.display === C, children: C })) }) }),
1509
1509
  /* @__PURE__ */ o("td", { children: /* @__PURE__ */ o(
1510
1510
  "tm-display-options",
1511
1511
  {
1512
1512
  "data-column": u.name,
1513
- "data-options": c
1513
+ "data-options": m
1514
1514
  }
1515
1515
  ) }),
1516
1516
  /* @__PURE__ */ o("td", { children: /* @__PURE__ */ o(
@@ -1530,7 +1530,7 @@ function fn({
1530
1530
  value: "1"
1531
1531
  }
1532
1532
  ) }),
1533
- /* @__PURE__ */ o("td", { class: "tm-center", children: g ? /* @__PURE__ */ o(
1533
+ /* @__PURE__ */ o("td", { class: "tm-center", children: y ? /* @__PURE__ */ o(
1534
1534
  "input",
1535
1535
  {
1536
1536
  name: `${u.name}__showOnCreate`,
@@ -1551,7 +1551,7 @@ function fn({
1551
1551
  );
1552
1552
  }
1553
1553
  async function bn(t, e) {
1554
- const n = t.params.table, r = await new X(e.db).getTable(n), i = await new W(e.db).getTableConfig(n), m = [
1554
+ const n = t.params.table, r = await new X(e.db).getTable(n), i = await new W(e.db).getTableConfig(n), c = [
1555
1555
  { label: "tables", href: e.prefix || "/" },
1556
1556
  { label: n, href: `${e.prefix}/${n}` },
1557
1557
  { label: "config" }
@@ -1565,10 +1565,10 @@ async function bn(t, e) {
1565
1565
  symbol: e.symbol,
1566
1566
  siteUrl: e.siteUrl,
1567
1567
  siteName: e.siteName,
1568
- crumbs: m,
1568
+ crumbs: c,
1569
1569
  scripts: e.scripts,
1570
1570
  children: [
1571
- /* @__PURE__ */ o(_, { type: t.query.flash, message: t.query.msg }),
1571
+ /* @__PURE__ */ o(ee, { type: t.query.flash, message: t.query.msg }),
1572
1572
  /* @__PURE__ */ b("h2", { class: "tm-section-title", children: [
1573
1573
  n,
1574
1574
  " — display config"
@@ -1578,7 +1578,7 @@ async function bn(t, e) {
1578
1578
  {
1579
1579
  table: n,
1580
1580
  prefix: e.prefix,
1581
- columns: L(r.columns, i),
1581
+ columns: G(r.columns, i),
1582
1582
  primaryKey: r.primaryKey,
1583
1583
  hasRowid: r.hasRowid,
1584
1584
  config: i,
@@ -1599,13 +1599,13 @@ async function hn(t, e) {
1599
1599
  var p, f, u, d;
1600
1600
  const n = t.params.table;
1601
1601
  T(n, e);
1602
- const r = await new X(e.db).getTable(n), s = new W(e.db), i = await s.getTableConfig(n), m = { columns: {} };
1603
- if (i.order && (m.order = i.order), t.body)
1604
- for (const c of r.columns) {
1605
- const g = t.body[`${c.name}__display`] || "text", w = t.body[`${c.name}__label`] || "", C = !!t.body[`${c.name}__hidden`], R = !!t.body[`${c.name}__showOnCreate`], l = (p = e.displayTypes.get(g)) == null ? void 0 : p.schema, h = {}, y = `${c.name}__opt__`;
1602
+ const r = await new X(e.db).getTable(n), s = new W(e.db), i = await s.getTableConfig(n), c = { columns: {} };
1603
+ if (i.order && (c.order = i.order), t.body)
1604
+ for (const m of r.columns) {
1605
+ const y = t.body[`${m.name}__display`] || "text", w = t.body[`${m.name}__label`] || "", C = !!t.body[`${m.name}__hidden`], R = !!t.body[`${m.name}__showOnCreate`], l = (p = e.displayTypes.get(y)) == null ? void 0 : p.schema, h = {}, g = `${m.name}__opt__`;
1606
1606
  for (const [A, k] of Object.entries(t.body))
1607
- if (A.startsWith(y)) {
1608
- const P = A.slice(y.length), E = String(k), x = (f = l == null ? void 0 : l.properties) == null ? void 0 : f[P];
1607
+ if (A.startsWith(g)) {
1608
+ const P = A.slice(g.length), E = String(k), x = (f = l == null ? void 0 : l.properties) == null ? void 0 : f[P];
1609
1609
  if ((x == null ? void 0 : x.type) === "number" && E !== "") {
1610
1610
  const B = Number(E);
1611
1611
  Number.isNaN(B) || (h[P] = B);
@@ -1613,20 +1613,20 @@ async function hn(t, e) {
1613
1613
  }
1614
1614
  if (l != null && l.properties)
1615
1615
  for (const [A, k] of Object.entries(l.properties))
1616
- k.type === "boolean" && !(`${c.name}__opt__${A}` in t.body) && (h[A] = !1);
1616
+ k.type === "boolean" && !(`${m.name}__opt__${A}` in t.body) && (h[A] = !1);
1617
1617
  const v = {};
1618
- g !== "text" && (v.display = g), w && (v.label = w), C && (v.hidden = !0), R && (v.showOnCreate = !0);
1618
+ y !== "text" && (v.display = y), w && (v.label = w), C && (v.hidden = !0), R && (v.showOnCreate = !0);
1619
1619
  const I = {};
1620
1620
  for (const [A, k] of Object.entries(h)) {
1621
1621
  const P = (d = (u = l == null ? void 0 : l.properties) == null ? void 0 : u[A]) == null ? void 0 : d.default;
1622
1622
  k !== P && (I[A] = k);
1623
1623
  }
1624
- Object.keys(I).length > 0 && (v.options = I), Object.keys(v).length > 0 && (m.columns[c.name] = v);
1624
+ Object.keys(I).length > 0 && (v.options = I), Object.keys(v).length > 0 && (c.columns[m.name] = v);
1625
1625
  }
1626
- return Object.keys(m.columns).length === 0 && delete m.columns, await s.setTableConfig(n, m), V(`${e.prefix}/${n}?flash=success&msg=${encodeURIComponent("config saved")}`);
1626
+ return Object.keys(c.columns).length === 0 && delete c.columns, await s.setTableConfig(n, c), V(`${e.prefix}/${n}?flash=success&msg=${encodeURIComponent("config saved")}`);
1627
1627
  }
1628
1628
  async function gn(t, e) {
1629
- var m;
1629
+ var c;
1630
1630
  const n = t.params.table;
1631
1631
  T(n, e);
1632
1632
  const a = new z(e.db);
@@ -1635,7 +1635,7 @@ async function gn(t, e) {
1635
1635
  const p = t.body.pk;
1636
1636
  r = Array.isArray(p) ? p : p ? [p] : [];
1637
1637
  }
1638
- const s = await a.bulkDelete(n, r), i = ((m = t.body) == null ? void 0 : m.page) || "1";
1638
+ const s = await a.bulkDelete(n, r), i = ((c = t.body) == null ? void 0 : c.page) || "1";
1639
1639
  return V(`${e.prefix}/${n}?page=${i}&flash=success&msg=${encodeURIComponent(`${s} row${s === 1 ? "" : "s"} deleted`)}`);
1640
1640
  }
1641
1641
  function we(t, e) {
@@ -1655,15 +1655,15 @@ async function ce(t, e, n, a) {
1655
1655
  return s[0];
1656
1656
  }
1657
1657
  async function yn(t, e) {
1658
- var g;
1658
+ var y;
1659
1659
  const n = t.params.table, a = parseInt(t.params.index, 10);
1660
1660
  if (Number.isNaN(a) || a < 0)
1661
1661
  throw new U("Invalid row index");
1662
- const s = await new X(e.db).getTable(n), m = await new W(e.db).getTableConfig(n), p = await ce(e, n, a, s.hasRowid), u = s.kind === "view" || e.readonly || ((g = e.tableOptions.get(n)) == null ? void 0 : g.readonly), d = [
1662
+ const s = await new X(e.db).getTable(n), c = await new W(e.db).getTableConfig(n), p = await ce(e, n, a, s.hasRowid), u = s.kind === "view" || e.readonly || ((y = e.tableOptions.get(n)) == null ? void 0 : y.readonly), d = [
1663
1663
  { label: "tables", href: e.prefix || "/" },
1664
1664
  { label: n, href: `${e.prefix}/${n}` },
1665
1665
  { label: `row ${a}` }
1666
- ], c = N(
1666
+ ], m = N(
1667
1667
  /* @__PURE__ */ b(
1668
1668
  Z,
1669
1669
  {
@@ -1676,12 +1676,12 @@ async function yn(t, e) {
1676
1676
  crumbs: d,
1677
1677
  scripts: e.scripts,
1678
1678
  children: [
1679
- /* @__PURE__ */ o(_, { type: t.query.flash, message: t.query.msg }),
1679
+ /* @__PURE__ */ o(ee, { type: t.query.flash, message: t.query.msg }),
1680
1680
  /* @__PURE__ */ o("h2", { class: "tm-section-title", children: u ? "view row" : "edit row" }),
1681
1681
  /* @__PURE__ */ o(
1682
1682
  le,
1683
1683
  {
1684
- columns: L(s.columns, m),
1684
+ columns: G(s.columns, c),
1685
1685
  primaryKey: s.primaryKey,
1686
1686
  hasRowid: s.hasRowid,
1687
1687
  foreignKeys: s.foreignKeys,
@@ -1690,7 +1690,7 @@ async function yn(t, e) {
1690
1690
  submitLabel: "save",
1691
1691
  formId: u ? void 0 : "tm-edit-form",
1692
1692
  formReadonly: u,
1693
- tableConfig: m,
1693
+ tableConfig: c,
1694
1694
  constraints: e.constraints,
1695
1695
  displayTypes: e.displayTypes,
1696
1696
  prefix: e.prefix
@@ -1715,26 +1715,26 @@ async function yn(t, e) {
1715
1715
  return {
1716
1716
  status: 200,
1717
1717
  headers: { "content-type": "text/html; charset=utf-8" },
1718
- html: c
1718
+ html: m
1719
1719
  };
1720
1720
  }
1721
1721
  async function wn(t, e) {
1722
1722
  const n = t.params.table, a = parseInt(t.params.index, 10);
1723
1723
  T(n, e);
1724
- const s = await new X(e.db).getTable(n), i = await ce(e, n, a, s.hasRowid), m = i._rowid, p = new Map(s.columns.map((l) => [l.name, l])), f = Object.entries(t.body ?? {}).filter(
1724
+ const s = await new X(e.db).getTable(n), i = await ce(e, n, a, s.hasRowid), c = i._rowid, p = new Map(s.columns.map((l) => [l.name, l])), f = Object.entries(t.body ?? {}).filter(
1725
1725
  ([l]) => p.has(l)
1726
1726
  ), u = f.map(([l]) => `"${l}" = ?`).join(", "), d = f.map(
1727
- ([l, h]) => ae(String(h), p.get(l))
1727
+ ([l, h]) => re(String(h), p.get(l))
1728
1728
  );
1729
- if (m != null)
1730
- await e.db.prepare(`UPDATE "${n}" SET ${u} WHERE rowid = ?`).bind(...d, m).run();
1729
+ if (c != null)
1730
+ await e.db.prepare(`UPDATE "${n}" SET ${u} WHERE rowid = ?`).bind(...d, c).run();
1731
1731
  else {
1732
- const l = s.columns.map((y) => `"${y.name}" IS ?`).join(" AND "), h = s.columns.map((y) => i[y.name] ?? null);
1732
+ const l = s.columns.map((g) => `"${g.name}" IS ?`).join(" AND "), h = s.columns.map((g) => i[g.name] ?? null);
1733
1733
  await e.db.prepare(`UPDATE "${n}" SET ${u} WHERE ${l}`).bind(...d, ...h).run();
1734
1734
  }
1735
- const c = we(s.primaryKey, i), g = {};
1736
- for (const [l, h] of f) g[l] = String(h ?? "");
1737
- const w = c ? await ge(n, c, g, e, t) : null, { flash: C, message: R } = G("row updated", w);
1735
+ const m = we(s.primaryKey, i), y = {};
1736
+ for (const [l, h] of f) y[l] = String(h ?? "");
1737
+ const w = m ? await ge(n, m, y, e, t) : null, { flash: C, message: R } = K("row updated", w);
1738
1738
  return V(
1739
1739
  `${e.prefix}/${n}/_row/${a}?flash=${C}&msg=${encodeURIComponent(R)}`
1740
1740
  );
@@ -1742,14 +1742,14 @@ async function wn(t, e) {
1742
1742
  async function An(t, e) {
1743
1743
  const n = t.params.table;
1744
1744
  T(n, e);
1745
- const a = parseInt(t.params.index, 10), s = await new X(e.db).getTable(n), i = await ce(e, n, a, s.hasRowid), m = i._rowid;
1746
- if (m != null)
1747
- await e.db.prepare(`DELETE FROM "${n}" WHERE rowid = ?`).bind(m).run();
1745
+ const a = parseInt(t.params.index, 10), s = await new X(e.db).getTable(n), i = await ce(e, n, a, s.hasRowid), c = i._rowid;
1746
+ if (c != null)
1747
+ await e.db.prepare(`DELETE FROM "${n}" WHERE rowid = ?`).bind(c).run();
1748
1748
  else {
1749
- const c = s.columns.map((w) => `"${w.name}" IS ?`).join(" AND "), g = s.columns.map((w) => i[w.name] ?? null);
1750
- await e.db.prepare(`DELETE FROM "${n}" WHERE ${c}`).bind(...g).run();
1749
+ const m = s.columns.map((w) => `"${w.name}" IS ?`).join(" AND "), y = s.columns.map((w) => i[w.name] ?? null);
1750
+ await e.db.prepare(`DELETE FROM "${n}" WHERE ${m}`).bind(...y).run();
1751
1751
  }
1752
- const p = we(s.primaryKey, i), f = p ? await ye(n, p, e, t) : null, { flash: u, message: d } = G("row deleted", f);
1752
+ const p = we(s.primaryKey, i), f = p ? await ye(n, p, e, t) : null, { flash: u, message: d } = K("row deleted", f);
1753
1753
  return V(
1754
1754
  `${e.prefix}/${n}?flash=${u}&msg=${encodeURIComponent(d)}`
1755
1755
  );
@@ -1761,8 +1761,8 @@ async function Cn(t, e) {
1761
1761
  throw new U(
1762
1762
  `Action "${r}" is not registered on "${n}"`
1763
1763
  );
1764
- const m = await new X(e.db).getTable(n), p = j(m.primaryKey, a), f = await en(n, r, p, e, t), u = f.success ? "success" : "error", d = f.message ?? (f.success ? "action completed" : "action failed"), g = ((R = t.body) == null ? void 0 : R._back) === "table" ? `${e.prefix}/${n}` : `${e.prefix}/${n}/${a}`;
1765
- return V(`${g}?flash=${u}&msg=${encodeURIComponent(d)}`);
1764
+ const c = await new X(e.db).getTable(n), p = L(c.primaryKey, a), f = await en(n, r, p, e, t), u = f.success ? "success" : "error", d = f.message ?? (f.success ? "action completed" : "action failed"), y = ((R = t.body) == null ? void 0 : R._back) === "table" ? `${e.prefix}/${n}` : `${e.prefix}/${n}/${j(c.primaryKey, p)}`;
1765
+ return V(`${y}?flash=${u}&msg=${encodeURIComponent(d)}`);
1766
1766
  }
1767
1767
  const vn = {
1768
1768
  "fonts-depart.css": `/* tapemark — admin panel styles */
@@ -3321,19 +3321,19 @@ function Rn(t, e, n) {
3321
3321
  if (r.method !== e) continue;
3322
3322
  const s = r.pattern.split("/"), i = a.split("/");
3323
3323
  if (s.length !== i.length) continue;
3324
- const m = {};
3324
+ const c = {};
3325
3325
  let p = !0;
3326
3326
  for (let f = 0; f < s.length; f++) {
3327
3327
  const u = s[f], d = i[f];
3328
3328
  if (u.startsWith(":"))
3329
- m[u.slice(1)] = decodeURIComponent(d);
3329
+ c[u.slice(1)] = decodeURIComponent(d);
3330
3330
  else if (u !== d) {
3331
3331
  p = !1;
3332
3332
  break;
3333
3333
  }
3334
3334
  }
3335
3335
  if (p)
3336
- return { handler: r.handler, params: m };
3336
+ return { handler: r.handler, params: c };
3337
3337
  }
3338
3338
  return null;
3339
3339
  }
@@ -3342,18 +3342,18 @@ function Xn(t) {
3342
3342
  Object.entries(t.tables ?? {})
3343
3343
  ), s = t.scripts ?? [];
3344
3344
  let i = null;
3345
- const m = t.symbol !== void 0 ? t.symbol : t.name === void 0 ? "🎞️" : !1;
3345
+ const c = t.symbol !== void 0 ? t.symbol : t.name === void 0 ? "🎞️" : !1;
3346
3346
  function p() {
3347
3347
  if (!t.db)
3348
3348
  throw new Error("No database configured — provide `db` in options or via per-request overrides");
3349
3349
  return typeof t.db == "function" ? t.db() : t.db;
3350
3350
  }
3351
- function f(y) {
3352
- return i || (i = new Xe(y, t.readonly, t.constraints ?? "enforce")), i;
3351
+ function f(g) {
3352
+ return i || (i = new Xe(g, t.readonly, t.constraints ?? "enforce")), i;
3353
3353
  }
3354
- function u(y, v) {
3354
+ function u(g, v) {
3355
3355
  return {
3356
- db: y,
3356
+ db: g,
3357
3357
  prefix: n,
3358
3358
  displayTypes: a,
3359
3359
  tableOptions: r,
@@ -3361,7 +3361,7 @@ function Xn(t) {
3361
3361
  siteUrl: t.siteUrl,
3362
3362
  siteName: t.siteName ?? "site",
3363
3363
  name: t.name ?? "tapemark",
3364
- symbol: m,
3364
+ symbol: c,
3365
3365
  readonly: t.readonly ?? !1,
3366
3366
  constraints: t.constraints ?? "enforce",
3367
3367
  theme: t.theme ?? de,
@@ -3370,46 +3370,46 @@ function Xn(t) {
3370
3370
  executionContext: v == null ? void 0 : v.executionContext
3371
3371
  };
3372
3372
  }
3373
- async function d(y, v) {
3373
+ async function d(g, v) {
3374
3374
  var x;
3375
3375
  const I = {
3376
3376
  prefix: n,
3377
3377
  name: t.name ?? "tapemark",
3378
- symbol: m,
3378
+ symbol: c,
3379
3379
  siteUrl: t.siteUrl,
3380
3380
  siteName: t.siteName ?? "site",
3381
3381
  scripts: t.scripts
3382
3382
  };
3383
3383
  if (t.authorize) {
3384
- const B = await t.authorize(y);
3384
+ const B = await t.authorize(g);
3385
3385
  if (typeof B != "boolean") return B;
3386
- if (!B) return Y(403, "Forbidden", I);
3386
+ if (!B) return J(403, "Forbidden", I);
3387
3387
  }
3388
3388
  const A = (v == null ? void 0 : v.db) ?? p();
3389
3389
  await f(A).ensureReady();
3390
- const k = Rn(e, y.method, y.path);
3390
+ const k = Rn(e, g.method, g.path);
3391
3391
  if (!k || k.params.table && ((x = r.get(k.params.table)) != null && x.hidden))
3392
- return Y(404, "Not Found", I);
3392
+ return J(404, "Not Found", I);
3393
3393
  const P = {
3394
- ...y,
3395
- params: { ...y.params, ...k.params }
3394
+ ...g,
3395
+ params: { ...g.params, ...k.params }
3396
3396
  }, E = u(A, v);
3397
3397
  try {
3398
3398
  return await k.handler(P, E);
3399
3399
  } catch (B) {
3400
- if (B instanceof J)
3401
- return Y(B.status, B.message, I);
3402
- if (y.method === "POST") {
3403
- const q = B instanceof Error ? B.message : "Unknown error", K = y.path.replace(/\/delete$/, "");
3404
- return V(`${n}${K}?flash=error&msg=${encodeURIComponent(q)}`);
3400
+ if (B instanceof $)
3401
+ return J(B.status, B.message, I);
3402
+ if (g.method === "POST") {
3403
+ const q = B instanceof Error ? B.message : "Unknown error", D = g.path.replace(/\/delete$/, "");
3404
+ return V(`${n}${D}?flash=error&msg=${encodeURIComponent(q)}`);
3405
3405
  }
3406
3406
  throw B;
3407
3407
  }
3408
3408
  }
3409
- function c(y, v, I) {
3410
- e.push({ method: y, pattern: v, handler: I });
3409
+ function m(g, v, I) {
3410
+ e.push({ method: g, pattern: v, handler: I });
3411
3411
  }
3412
- const g = t.theme ?? de, w = Re[g], R = t.bundleFonts !== !1 && In[g] || "", l = `:root {
3412
+ const y = t.theme ?? de, w = Re[y], R = t.bundleFonts !== !1 && In[y] || "", l = `:root {
3413
3413
  --tm-font: ${w.fontFamily};
3414
3414
  --tm-font-mono: ${w.fontFamilyMono};
3415
3415
  --tm-font-size-base: ${w.fontSizeBase};
@@ -3422,21 +3422,21 @@ function Xn(t) {
3422
3422
  `, h = R + `
3423
3423
  ` + En + `
3424
3424
  ` + l;
3425
- return c("GET", "/_tapemark/styles.css", async () => ({
3425
+ return m("GET", "/_tapemark/styles.css", async () => ({
3426
3426
  status: 200,
3427
3427
  headers: {
3428
3428
  "content-type": "text/css; charset=utf-8",
3429
3429
  "cache-control": "public, max-age=86400"
3430
3430
  },
3431
3431
  html: h
3432
- })), c("GET", "/_tapemark/admin.js", async () => ({
3432
+ })), m("GET", "/_tapemark/admin.js", async () => ({
3433
3433
  status: 200,
3434
3434
  headers: {
3435
3435
  "content-type": "application/javascript; charset=utf-8",
3436
3436
  "cache-control": "public, max-age=86400"
3437
3437
  },
3438
3438
  html: Sn
3439
- })), c("GET", "/", $e), c("GET", "/:table/new", pn), c("POST", "/:table/new", un), c("GET", "/:table/_config", bn), c("POST", "/:table/_config", hn), c("GET", "/:table/_lookup", Fe), c("POST", "/:table/_bulk-delete", gn), c("GET", "/:table/_row/:index", yn), c("POST", "/:table/_row/:index", wn), c("POST", "/:table/_row/:index/delete", An), c("GET", "/:table/:pk", cn), c("POST", "/:table/:pk", mn), c("POST", "/:table/:pk/delete", dn), c("POST", "/:table/:pk/_action/:actionName", Cn), c("GET", "/:table", sn), { handle: d, addRoute: c };
3439
+ })), m("GET", "/", $e), m("GET", "/:table/new", pn), m("POST", "/:table/new", un), m("GET", "/:table/_config", bn), m("POST", "/:table/_config", hn), m("GET", "/:table/_lookup", Fe), m("POST", "/:table/_bulk-delete", gn), m("GET", "/:table/_row/:index", yn), m("POST", "/:table/_row/:index", wn), m("POST", "/:table/_row/:index/delete", An), m("GET", "/:table/:pk", cn), m("POST", "/:table/:pk", mn), m("POST", "/:table/:pk/delete", dn), m("POST", "/:table/:pk/_action/:actionName", Cn), m("GET", "/:table", sn), { handle: d, addRoute: m };
3440
3440
  }
3441
3441
  function kn({ databases: t }) {
3442
3442
  return /* @__PURE__ */ b(
@@ -3467,21 +3467,21 @@ function Vn(t) {
3467
3467
  }
3468
3468
  export {
3469
3469
  W as ConfigStore,
3470
- F as NameValidationError,
3470
+ O as NameValidationError,
3471
3471
  U as NotFoundError,
3472
3472
  X as SchemaIntrospector,
3473
3473
  z as TableRepository,
3474
- J as TapemarkError,
3474
+ $ as TapemarkError,
3475
3475
  Z as TapemarkLayout,
3476
3476
  Xe as TapemarkMigrator,
3477
3477
  M as ValidationError,
3478
3478
  Ue as builtinDisplayTypes,
3479
- ae as castValue,
3479
+ re as castValue,
3480
3480
  je as createDisplayTypeRegistry,
3481
3481
  Xn as createTapemark,
3482
- j as decodePk,
3482
+ L as decodePk,
3483
3483
  de as defaultTheme,
3484
- se as encodePk,
3484
+ j as encodePk,
3485
3485
  be as isAutoGeneratedPk,
3486
3486
  Be as isInternalTable,
3487
3487
  xe as parseAffinity,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jvelo/tapemark",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "description": "Self-contained admin UI for SQLite — framework-agnostic core (router, schema introspection, CRUD, server-rendered Preact UI).",
6
6
  "keywords": [
@@ -45,7 +45,7 @@
45
45
  "vite-plugin-dts": "^4.0.0",
46
46
  "vitest": "^3.0.0",
47
47
  "typescript": "^5.7.0",
48
- "@jvelo/tapemark-better-sqlite3": "0.7.0"
48
+ "@jvelo/tapemark-better-sqlite3": "0.7.1"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "vite build",