@jvelo/tapemark 0.7.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/LICENSE +373 -0
- package/README.md +33 -0
- package/dist/fonts-depart.css +9 -0
- package/dist/fonts-hubot.css +15 -0
- package/dist/fonts-plex.css +15 -0
- package/dist/index.d.ts +504 -0
- package/dist/index.js +3492 -0
- package/dist/tapemark.css +841 -0
- package/dist/tapemark.js +656 -0
- package/package.json +56 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
import { Child } from 'hono/jsx';
|
|
2
|
+
import { JSX } from 'hono/jsx/jsx-dev-runtime';
|
|
3
|
+
|
|
4
|
+
/** Result returned by an action handler. Surfaced as a flash message. */
|
|
5
|
+
export declare interface ActionResult {
|
|
6
|
+
success: boolean;
|
|
7
|
+
message?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export declare const builtinDisplayTypes: Record<string, DisplayType>;
|
|
11
|
+
|
|
12
|
+
export declare function castValue(value: string, column: Column): CellValue;
|
|
13
|
+
|
|
14
|
+
export declare type CellValue = string | number | null | Uint8Array;
|
|
15
|
+
|
|
16
|
+
export declare interface Column {
|
|
17
|
+
name: string;
|
|
18
|
+
/** Raw type string from SQLite (e.g. "VARCHAR(255)", "INTEGER"). */
|
|
19
|
+
rawType: string;
|
|
20
|
+
/** Parsed affinity. */
|
|
21
|
+
affinity: ColumnAffinity;
|
|
22
|
+
nullable: boolean;
|
|
23
|
+
defaultValue: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Position in the primary key (1-based), or `null` if the column is not
|
|
26
|
+
* part of the primary key.
|
|
27
|
+
*/
|
|
28
|
+
primaryKeyPosition: number | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** SQLite type affinity, parsed from the raw column type string. */
|
|
32
|
+
export declare type ColumnAffinity = "text" | "numeric" | "integer" | "real" | "blob";
|
|
33
|
+
|
|
34
|
+
export declare interface ColumnConfig {
|
|
35
|
+
display?: string;
|
|
36
|
+
options?: Record<string, unknown>;
|
|
37
|
+
label?: string;
|
|
38
|
+
hidden?: boolean;
|
|
39
|
+
/** Force-render on the create form even when Tapemark would hide it
|
|
40
|
+
* (e.g. auto-generated INTEGER primary keys). Default `false`. */
|
|
41
|
+
showOnCreate?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Reads and writes per-table display configuration from _tapemark_table_config.
|
|
46
|
+
* Caches in memory; invalidates on write.
|
|
47
|
+
*/
|
|
48
|
+
export declare class ConfigStore {
|
|
49
|
+
private db;
|
|
50
|
+
private cache;
|
|
51
|
+
constructor(db: Database);
|
|
52
|
+
getTableConfig(tableName: string): Promise<TableConfig>;
|
|
53
|
+
setTableConfig(tableName: string, config: TableConfig): Promise<void>;
|
|
54
|
+
/** Get config for a specific column, with defaults. */
|
|
55
|
+
getColumnConfig(tableConfig: TableConfig, columnName: string): ColumnConfig;
|
|
56
|
+
/** Clear the entire cache (e.g. after migration). */
|
|
57
|
+
invalidate(): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** "enforce" enables FK checks and HTML required attributes. "relaxed" disables both. */
|
|
61
|
+
export declare type ConstraintMode = "enforce" | "relaxed";
|
|
62
|
+
|
|
63
|
+
export declare function createDisplayTypeRegistry(custom?: Record<string, DisplayType>): Map<string, DisplayType>;
|
|
64
|
+
|
|
65
|
+
export declare function createTapemark(options: TapemarkOptions): TapemarkCore;
|
|
66
|
+
|
|
67
|
+
export declare function createTapemark(options: TapemarkBaseOptions): TapemarkCore;
|
|
68
|
+
|
|
69
|
+
export declare interface Crumb {
|
|
70
|
+
label: string;
|
|
71
|
+
href?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Minimal database interface that both D1 and native SQLite can implement.
|
|
76
|
+
* Adapters wrap the underlying driver to match this shape.
|
|
77
|
+
*/
|
|
78
|
+
export declare interface Database {
|
|
79
|
+
prepare(query: string): PreparedStatement;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export declare interface DatabaseListItem {
|
|
83
|
+
name: string;
|
|
84
|
+
path: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare function decodePk(primaryKey: string[], encoded: string): Record<string, string>;
|
|
88
|
+
|
|
89
|
+
export declare const defaultTheme: ThemeName;
|
|
90
|
+
|
|
91
|
+
export declare interface DisplayType {
|
|
92
|
+
name: string;
|
|
93
|
+
description: string;
|
|
94
|
+
/** JSON Schema describing the configurable options. */
|
|
95
|
+
schema: OptionSchema;
|
|
96
|
+
/** Server-side: render a cell value to an HTML string. */
|
|
97
|
+
render: (value: unknown, options: Record<string, unknown>) => string;
|
|
98
|
+
/** Server-side: render the form input for editing. */
|
|
99
|
+
renderInput?: (column: Column, value: unknown, options: Record<string, unknown>) => string;
|
|
100
|
+
/**
|
|
101
|
+
* Tag name of a web component that progressively enhances the input.
|
|
102
|
+
* The component receives the rendered input as its child.
|
|
103
|
+
*/
|
|
104
|
+
editorComponent?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export declare function encodePk(primaryKey: string[], row: Record<string, unknown>): string;
|
|
108
|
+
|
|
109
|
+
/** Capability host for fire-and-forget work: `waitUntil(promise)` keeps a
|
|
110
|
+
* Promise alive past the response. Available on edge runtimes that share
|
|
111
|
+
* this idiom — Cloudflare Workers (`c.executionCtx`), Vercel
|
|
112
|
+
* (`@vercel/functions`'s `waitUntil`), and others. Undefined on runtimes
|
|
113
|
+
* without the concept (Node, Bun standalone), where hooks just fall back
|
|
114
|
+
* to plain async invocations. */
|
|
115
|
+
export declare interface ExecutionContextLike {
|
|
116
|
+
waitUntil?: (promise: Promise<unknown>) => void;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export declare interface ForeignKey {
|
|
120
|
+
/** Local column names, ordered by position in the constraint. */
|
|
121
|
+
columns: string[];
|
|
122
|
+
referencedTable: string;
|
|
123
|
+
referencedColumns: string[];
|
|
124
|
+
onUpdate: string;
|
|
125
|
+
onDelete: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Context passed to user-defined hooks and action handlers. `env` is
|
|
129
|
+
* `unknown` because the adapter's binding shape isn't known to core —
|
|
130
|
+
* cast at the call site (`ctx.env as MyEnv`) for typed access. */
|
|
131
|
+
export declare interface HookContext {
|
|
132
|
+
db: Database;
|
|
133
|
+
/** Framework env (e.g. Hono's `c.env`); undefined when not adapter-bound. */
|
|
134
|
+
env?: unknown;
|
|
135
|
+
/** Run `work` in the background when the runtime supports it
|
|
136
|
+
* (Workers/Vercel/etc.); otherwise await it inline. Always `await` the
|
|
137
|
+
* return value — it resolves immediately in background mode and after
|
|
138
|
+
* `work` settles in sync mode. Errors are surfaced as flash warnings in
|
|
139
|
+
* sync mode but only logged by the runtime in background mode. */
|
|
140
|
+
background: (work: Promise<unknown>) => Promise<void>;
|
|
141
|
+
request: TapemarkRequest;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** True for sole-INTEGER-PK columns on rowid tables — SQLite aliases them
|
|
145
|
+
* to rowid and fills them in on INSERT, so admin UIs typically hide them
|
|
146
|
+
* on create. `WITHOUT ROWID` tables disable the aliasing, so the column
|
|
147
|
+
* is a regular integer PK that the user must supply. */
|
|
148
|
+
export declare function isAutoGeneratedPk(col: Column, primaryKey: string[], hasRowid: boolean): boolean;
|
|
149
|
+
|
|
150
|
+
export declare function isInternalTable(name: string): boolean;
|
|
151
|
+
|
|
152
|
+
export declare class NameValidationError extends NotFoundError {
|
|
153
|
+
readonly kind: "table" | "column";
|
|
154
|
+
readonly invalidName: string;
|
|
155
|
+
constructor(kind: "table" | "column", invalidName: string);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export declare class NotFoundError extends TapemarkError {
|
|
159
|
+
constructor(message: string, detail?: string);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** JSON Schema subset used for display type option definitions. */
|
|
163
|
+
export declare interface OptionSchema {
|
|
164
|
+
type: "object";
|
|
165
|
+
properties: Record<string, {
|
|
166
|
+
type: "string" | "number" | "boolean";
|
|
167
|
+
default?: unknown;
|
|
168
|
+
description?: string;
|
|
169
|
+
enum?: unknown[];
|
|
170
|
+
}>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export declare function parseAffinity(rawType: string): ColumnAffinity;
|
|
174
|
+
|
|
175
|
+
export declare function pickLabelColumn(table: Awaited<ReturnType<SchemaIntrospector["getTable"]>>): string | null;
|
|
176
|
+
|
|
177
|
+
export declare interface PreparedStatement {
|
|
178
|
+
bind(...values: unknown[]): PreparedStatement;
|
|
179
|
+
/** Return all rows from any row-returning statement — including
|
|
180
|
+
* `SELECT`, `INSERT … RETURNING`, `UPDATE … RETURNING`, `DELETE … RETURNING`. */
|
|
181
|
+
all<T = Record<string, unknown>>(): Promise<T[]>;
|
|
182
|
+
/** Return the first row from any row-returning statement (see `all`).
|
|
183
|
+
* Core uses this on `INSERT … RETURNING *` to recover auto-generated
|
|
184
|
+
* values, so adapters must support it on writes, not only on SELECTs. */
|
|
185
|
+
first<T = Record<string, unknown>>(): Promise<T | null>;
|
|
186
|
+
/** Execute a statement that returns no rows. */
|
|
187
|
+
run(): Promise<void>;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export declare function renderDatabaseListPage(databases: DatabaseListItem[]): string;
|
|
191
|
+
|
|
192
|
+
export declare function renderPage(node: Child): string;
|
|
193
|
+
|
|
194
|
+
export declare interface RequestOverrides {
|
|
195
|
+
/** Pre-resolved database for this request (bypasses options.db). */
|
|
196
|
+
db?: Database;
|
|
197
|
+
/** Framework env forwarded to hook/action handlers (e.g. Hono's `c.env`). */
|
|
198
|
+
env?: unknown;
|
|
199
|
+
/** Background-task host forwarded from the adapter (Workers' `executionCtx`,
|
|
200
|
+
* Vercel's `waitUntil`, etc.). Undefined on runtimes without the concept. */
|
|
201
|
+
executionContext?: ExecutionContextLike;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** A route handler is a pure async function. */
|
|
205
|
+
export declare type RouteHandler = (req: TapemarkRequest, ctx: TapemarkContext) => Promise<TapemarkResponse>;
|
|
206
|
+
|
|
207
|
+
/** A user-triggered named operation on a row, rendered as a button. */
|
|
208
|
+
export declare interface RowAction {
|
|
209
|
+
/** Label shown on the button. */
|
|
210
|
+
label: string;
|
|
211
|
+
/** Handler invoked when the button is clicked. */
|
|
212
|
+
handler: (pkValues: Record<string, string>, ctx: HookContext) => Promise<ActionResult> | ActionResult;
|
|
213
|
+
/** Where to render this action button. Defaults: `detail: true`, `list: false`.
|
|
214
|
+
* Invocations from the list view redirect back to the list. */
|
|
215
|
+
display?: {
|
|
216
|
+
detail?: boolean;
|
|
217
|
+
list?: boolean;
|
|
218
|
+
};
|
|
219
|
+
/** UI-only predicate hiding the button when it doesn't apply to this row.
|
|
220
|
+
* Not enforced server-side; thrown errors are treated as "not visible". */
|
|
221
|
+
visible?: (row: Record<string, CellValue>) => boolean;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export declare interface RowData {
|
|
225
|
+
values: Map<string, CellValue>;
|
|
226
|
+
primaryKey: Map<string, CellValue>;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export declare interface RowResult {
|
|
230
|
+
columns: Column[];
|
|
231
|
+
rows: Record<string, CellValue>[];
|
|
232
|
+
total: number;
|
|
233
|
+
page: number;
|
|
234
|
+
pageSize: number;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export declare interface Schema {
|
|
238
|
+
tables: Table[];
|
|
239
|
+
/** SHA-256 hash of the sorted CREATE TABLE statements. */
|
|
240
|
+
hash: string;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export declare class SchemaIntrospector {
|
|
244
|
+
private db;
|
|
245
|
+
constructor(db: Database);
|
|
246
|
+
/** All user-facing table and view names (excludes internal tables). */
|
|
247
|
+
getTableNames(): Promise<string[]>;
|
|
248
|
+
/** All user-facing tables and views with their kind. */
|
|
249
|
+
getTableEntries(): Promise<{
|
|
250
|
+
name: string;
|
|
251
|
+
kind: "table" | "view";
|
|
252
|
+
}[]>;
|
|
253
|
+
/** Validate that a table or view name exists and is safe to use in SQL. */
|
|
254
|
+
assertTable(name: string): Promise<void>;
|
|
255
|
+
/** Validate that a column belongs to the given table. */
|
|
256
|
+
assertColumn(table: string, column: string): Promise<void>;
|
|
257
|
+
/** Foreign keys for a table (views have none). */
|
|
258
|
+
getForeignKeys(name: string): Promise<ForeignKey[]>;
|
|
259
|
+
/** Full column and PK info for a single table or view. */
|
|
260
|
+
getTable(name: string): Promise<Table>;
|
|
261
|
+
/** All user-facing tables with column info and row counts. */
|
|
262
|
+
getTables(): Promise<Table[]>;
|
|
263
|
+
/**
|
|
264
|
+
* Full schema snapshot including a hash for sync compatibility.
|
|
265
|
+
* The hash is computed from the sorted CREATE TABLE statements.
|
|
266
|
+
*/
|
|
267
|
+
getSchema(): Promise<Schema>;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export declare interface Table {
|
|
271
|
+
name: string;
|
|
272
|
+
/** Whether this is a table or a view. */
|
|
273
|
+
kind: "table" | "view";
|
|
274
|
+
/** Whether the table has an implicit rowid column. False for views and WITHOUT ROWID tables. */
|
|
275
|
+
hasRowid: boolean;
|
|
276
|
+
columns: Column[];
|
|
277
|
+
/** Ordered list of primary key column names. */
|
|
278
|
+
primaryKey: string[];
|
|
279
|
+
foreignKeys: ForeignKey[];
|
|
280
|
+
rowCount: number;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export declare interface TableConfig {
|
|
284
|
+
columns?: Record<string, ColumnConfig>;
|
|
285
|
+
/** Render order for columns. Listed names render first in the given order;
|
|
286
|
+
* unlisted columns trail in schema order. Names that no longer match a
|
|
287
|
+
* column are silently ignored — Tapemark does not track schema renames. */
|
|
288
|
+
order?: string[];
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Row-level lifecycle hooks. Only fire on writes that go through Tapemark. */
|
|
292
|
+
export declare interface TableHooks {
|
|
293
|
+
/** After a row has been inserted. Receives the full inserted row. */
|
|
294
|
+
afterInsert?: (row: Record<string, CellValue>, ctx: HookContext) => Promise<void> | void;
|
|
295
|
+
/** After a row has been updated. Receives the PK and the submitted patch. */
|
|
296
|
+
afterUpdate?: (pkValues: Record<string, string>, patch: Record<string, string>, ctx: HookContext) => Promise<void> | void;
|
|
297
|
+
/** After a row has been deleted. Receives the PK of the deleted row. */
|
|
298
|
+
afterDelete?: (pkValues: Record<string, string>, ctx: HookContext) => Promise<void> | void;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export declare interface TableOptions {
|
|
302
|
+
readonly?: boolean;
|
|
303
|
+
hidden?: boolean;
|
|
304
|
+
hooks?: TableHooks;
|
|
305
|
+
actions?: Record<string, RowAction>;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export declare class TableRepository {
|
|
309
|
+
private db;
|
|
310
|
+
private schema;
|
|
311
|
+
constructor(db: Database);
|
|
312
|
+
/** Paginated row listing. */
|
|
313
|
+
getRows(tableName: string, page?: number, pageSize?: number): Promise<RowResult>;
|
|
314
|
+
/** Single row by primary key values. */
|
|
315
|
+
getRow(tableName: string, pkValues: Record<string, string>): Promise<Record<string, CellValue>>;
|
|
316
|
+
/** Insert a row. Returns it via `RETURNING *` so callers and `afterInsert`
|
|
317
|
+
* hooks see auto-generated values regardless of PK affinity. Empty-string
|
|
318
|
+
* values are skipped (lets columns fall through to their DEFAULT). */
|
|
319
|
+
insertRow(tableName: string, data: Record<string, string>): Promise<Record<string, CellValue>>;
|
|
320
|
+
/** Update a row. PK columns in data are ignored. */
|
|
321
|
+
updateRow(tableName: string, pkValues: Record<string, string>, data: Record<string, string>): Promise<void>;
|
|
322
|
+
/** Delete a single row by primary key. */
|
|
323
|
+
deleteRow(tableName: string, pkValues: Record<string, string>): Promise<void>;
|
|
324
|
+
/** Delete multiple rows by encoded PK strings. Each delete is a separate
|
|
325
|
+
* statement rather than one transaction, so on D1 this is N round-trips and
|
|
326
|
+
* a mid-way failure leaves the already-deleted rows committed. */
|
|
327
|
+
bulkDelete(tableName: string, encodedPks: string[]): Promise<number>;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Base configuration shared by direct users and adapters.
|
|
332
|
+
* Adapters extend this to add framework-specific fields (like a
|
|
333
|
+
* context-aware `db` accessor) while `createTapemark` accepts it
|
|
334
|
+
* directly when the database is provided per-request via overrides.
|
|
335
|
+
*/
|
|
336
|
+
export declare interface TapemarkBaseOptions {
|
|
337
|
+
/**
|
|
338
|
+
* Authorization callback. Return `true` to allow, `false` for the default
|
|
339
|
+
* 403, or a `TapemarkResponse` to override the denial (e.g. a redirect).
|
|
340
|
+
* If omitted, the panel is unprotected.
|
|
341
|
+
*/
|
|
342
|
+
authorize?: (req: TapemarkRequest) => Promise<boolean | TapemarkResponse>;
|
|
343
|
+
/** URL prefix for generating internal links (e.g. "/admin"). */
|
|
344
|
+
prefix?: string;
|
|
345
|
+
/** Custom display type definitions. */
|
|
346
|
+
displayTypes?: Record<string, DisplayType>;
|
|
347
|
+
/** Per-table overrides. */
|
|
348
|
+
tables?: Record<string, TableOptions>;
|
|
349
|
+
/** Additional client-side scripts to load. */
|
|
350
|
+
scripts?: string[];
|
|
351
|
+
/** URL to link back to the host site. */
|
|
352
|
+
siteUrl?: string;
|
|
353
|
+
/** Label for the site link (e.g. "jvelo.at"). Defaults to "site". */
|
|
354
|
+
siteName?: string;
|
|
355
|
+
/** Display name shown in the top-left of the bar. Defaults to "tapemark". */
|
|
356
|
+
name?: string;
|
|
357
|
+
/**
|
|
358
|
+
* Brand mark (emoji or short string) rendered before `name` and used as favicon.
|
|
359
|
+
* Defaults to "🎞️" when `name` is not set, and to `false` when `name` is customized —
|
|
360
|
+
* i.e. integrators who rebrand don't get tapemark's mark by accident. Pass a string
|
|
361
|
+
* to override, or `false` to hide explicitly.
|
|
362
|
+
*/
|
|
363
|
+
symbol?: string | false;
|
|
364
|
+
/** Global read-only mode — disables all writes and deletes. */
|
|
365
|
+
readonly?: boolean;
|
|
366
|
+
/** Set to false to skip bundled fonts (when the host app already serves them). Defaults to true. */
|
|
367
|
+
bundleFonts?: boolean;
|
|
368
|
+
/** Theme name. Defaults to "hubot". */
|
|
369
|
+
theme?: ThemeName;
|
|
370
|
+
/** Constraint enforcement mode. Defaults to "enforce". */
|
|
371
|
+
constraints?: ConstraintMode;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Context passed to route handlers. Built once per request from
|
|
376
|
+
* resolved options. Handlers never touch raw options.
|
|
377
|
+
*/
|
|
378
|
+
export declare interface TapemarkContext {
|
|
379
|
+
db: Database;
|
|
380
|
+
prefix: string;
|
|
381
|
+
siteUrl?: string;
|
|
382
|
+
siteName: string;
|
|
383
|
+
name: string;
|
|
384
|
+
symbol: string | false;
|
|
385
|
+
readonly: boolean;
|
|
386
|
+
constraints: ConstraintMode;
|
|
387
|
+
theme: ThemeName;
|
|
388
|
+
bundleFonts: boolean;
|
|
389
|
+
displayTypes: Map<string, DisplayType>;
|
|
390
|
+
tableOptions: Map<string, TableOptions>;
|
|
391
|
+
scripts: string[];
|
|
392
|
+
/** Framework env forwarded from the adapter; passed through to hook/action handlers. */
|
|
393
|
+
env?: unknown;
|
|
394
|
+
/** Framework execution context forwarded from the adapter. */
|
|
395
|
+
executionContext?: ExecutionContextLike;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export declare interface TapemarkCore {
|
|
399
|
+
/** Handle an incoming request. */
|
|
400
|
+
handle(req: TapemarkRequest, overrides?: RequestOverrides): Promise<TapemarkResponse>;
|
|
401
|
+
/** Register a route. Used internally and by adapters for asset routes. */
|
|
402
|
+
addRoute(method: "GET" | "POST", pattern: string, handler: RouteHandler): void;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Base error class for all tapemark errors.
|
|
407
|
+
* Carries an HTTP status code and optional detail for logging.
|
|
408
|
+
*/
|
|
409
|
+
export declare class TapemarkError extends Error {
|
|
410
|
+
readonly status: number;
|
|
411
|
+
readonly detail?: string | undefined;
|
|
412
|
+
constructor(status: number, message: string, detail?: string | undefined);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export declare function TapemarkLayout({ title, prefix, name, symbol, siteUrl, siteName, crumbs, scripts, children, }: TapemarkLayoutProps): JSX.Element;
|
|
416
|
+
|
|
417
|
+
declare interface TapemarkLayoutProps {
|
|
418
|
+
title: string;
|
|
419
|
+
prefix: string;
|
|
420
|
+
name: string;
|
|
421
|
+
symbol: string | false;
|
|
422
|
+
siteUrl?: string;
|
|
423
|
+
siteName?: string;
|
|
424
|
+
crumbs?: Crumb[];
|
|
425
|
+
scripts?: string[];
|
|
426
|
+
children?: Child;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Manages tapemark's own tables (_tapemark_meta, _tapemark_table_config).
|
|
431
|
+
* Auto-creates on first use, applies pending migrations on schema upgrades.
|
|
432
|
+
*/
|
|
433
|
+
export declare class TapemarkMigrator {
|
|
434
|
+
private db;
|
|
435
|
+
private readonly readonlyMode;
|
|
436
|
+
private readonly constraints;
|
|
437
|
+
private initialized;
|
|
438
|
+
constructor(db: Database, readonlyMode?: boolean, constraints?: ConstraintMode);
|
|
439
|
+
/** Ensure tapemark tables exist and are up to date. Idempotent. */
|
|
440
|
+
ensureReady(): Promise<void>;
|
|
441
|
+
/** Reset initialized flag (useful after config writes that may change state). */
|
|
442
|
+
resetInitialized(): void;
|
|
443
|
+
private tableExists;
|
|
444
|
+
private createInitialSchema;
|
|
445
|
+
private getSchemaVersion;
|
|
446
|
+
private applyMigrations;
|
|
447
|
+
private updateAppSchemaHash;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/** Full options for direct usage — `db` is required. */
|
|
451
|
+
export declare interface TapemarkOptions extends TapemarkBaseOptions {
|
|
452
|
+
/** Database instance or factory. */
|
|
453
|
+
db: Database | (() => Database);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export declare interface TapemarkRequest {
|
|
457
|
+
method: string;
|
|
458
|
+
/** Path relative to the mount point (e.g. "/users", "/users/42"). */
|
|
459
|
+
path: string;
|
|
460
|
+
/** Route parameters extracted from path patterns (e.g. { table: "users", pk: "42" }). */
|
|
461
|
+
params: Record<string, string>;
|
|
462
|
+
/** URL query string parameters. */
|
|
463
|
+
query: Record<string, string>;
|
|
464
|
+
body?: Record<string, string | string[]>;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export declare interface TapemarkResponse {
|
|
468
|
+
status: number;
|
|
469
|
+
headers: Record<string, string>;
|
|
470
|
+
html?: string;
|
|
471
|
+
redirect?: string;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export declare interface ThemeDefinition {
|
|
475
|
+
name: ThemeName;
|
|
476
|
+
label: string;
|
|
477
|
+
fontFamily: string;
|
|
478
|
+
/** Monospace companion — used for UUIDs, JSON, code, hashes. */
|
|
479
|
+
fontFamilyMono: string;
|
|
480
|
+
/** Key into the font CSS files (e.g. "depart" → fonts-depart.css). */
|
|
481
|
+
fontFile: string;
|
|
482
|
+
/** Base font size for the UI. Table cells scale from this via em units. */
|
|
483
|
+
fontSizeBase: string;
|
|
484
|
+
/** Background color. */
|
|
485
|
+
bg: string;
|
|
486
|
+
/** Primary text color. */
|
|
487
|
+
text: string;
|
|
488
|
+
/** Border / divider color. */
|
|
489
|
+
border: string;
|
|
490
|
+
/** Accent color for links, focus, primary actions. */
|
|
491
|
+
accent: string;
|
|
492
|
+
/** Text color that reads well on top of the accent color. */
|
|
493
|
+
accentText: string;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export declare type ThemeName = "hubot" | "plex" | "depart";
|
|
497
|
+
|
|
498
|
+
export declare const themes: Record<ThemeName, ThemeDefinition>;
|
|
499
|
+
|
|
500
|
+
export declare class ValidationError extends TapemarkError {
|
|
501
|
+
constructor(message: string, detail?: string);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export { }
|