@otea/cli 0.0.1 → 0.1.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 +661 -0
- package/README.es.md +151 -0
- package/README.md +251 -3
- package/THIRD_PARTY_NOTICES.md +114 -0
- package/bin/otea.mjs +28 -0
- package/dist/app/agent-detail.js +26 -0
- package/dist/app/agent-draft.js +429 -0
- package/dist/app/agent-prompts.js +52 -0
- package/dist/app/agents.js +77 -0
- package/dist/app/asking.js +43 -0
- package/dist/app/board-archive.js +243 -0
- package/dist/app/board-migration.js +272 -0
- package/dist/app/boards.js +870 -0
- package/dist/app/branch-owner.js +48 -0
- package/dist/app/brief.js +53 -0
- package/dist/app/choices.js +61 -0
- package/dist/app/collections.js +101 -0
- package/dist/app/context.js +1 -0
- package/dist/app/crop.js +56 -0
- package/dist/app/devices.js +62 -0
- package/dist/app/draft-request.js +82 -0
- package/dist/app/events.js +12 -0
- package/dist/app/evidence.js +287 -0
- package/dist/app/gates.js +610 -0
- package/dist/app/guide.js +37 -0
- package/dist/app/home.js +145 -0
- package/dist/app/init-boards.js +36 -0
- package/dist/app/intake.js +25 -0
- package/dist/app/item-search.js +141 -0
- package/dist/app/items.js +318 -0
- package/dist/app/keep-waiting.js +44 -0
- package/dist/app/land-order.js +107 -0
- package/dist/app/language.js +52 -0
- package/dist/app/launcher.js +56 -0
- package/dist/app/lease-take.js +54 -0
- package/dist/app/leases.js +86 -0
- package/dist/app/machine.js +39 -0
- package/dist/app/merged.js +89 -0
- package/dist/app/migrate.js +171 -0
- package/dist/app/next.js +1637 -0
- package/dist/app/notes.js +319 -0
- package/dist/app/notify-targets.js +113 -0
- package/dist/app/opened.js +25 -0
- package/dist/app/owner-only.js +34 -0
- package/dist/app/performance.js +28 -0
- package/dist/app/phone.js +97 -0
- package/dist/app/presence.js +596 -0
- package/dist/app/preset-views.js +25 -0
- package/dist/app/presets.js +129 -0
- package/dist/app/priority.js +156 -0
- package/dist/app/profile.js +86 -0
- package/dist/app/project.js +247 -0
- package/dist/app/proofs.js +179 -0
- package/dist/app/questions.js +215 -0
- package/dist/app/reader-filter.js +58 -0
- package/dist/app/relations.js +164 -0
- package/dist/app/relay.js +98 -0
- package/dist/app/repos.js +176 -0
- package/dist/app/restart.js +92 -0
- package/dist/app/set-aside.js +64 -0
- package/dist/app/system-locale.js +6 -0
- package/dist/app/tailscale-cli.js +77 -0
- package/dist/app/tailscale-testing.js +41 -0
- package/dist/app/tailscale.js +177 -0
- package/dist/app/tips.js +30 -0
- package/dist/app/topics-everywhere.js +53 -0
- package/dist/app/topics.js +453 -0
- package/dist/app/undo.js +52 -0
- package/dist/app/validate.js +131 -0
- package/dist/app/watch.js +48 -0
- package/dist/cli/command.js +44 -0
- package/dist/cli/commands.js +3303 -0
- package/dist/cli/exit-codes.js +70 -0
- package/dist/cli/forge.js +176 -0
- package/dist/cli/format.js +340 -0
- package/dist/cli/gh.js +17 -0
- package/dist/cli/gitrepo.js +489 -0
- package/dist/cli/help.js +101 -0
- package/dist/cli/hooks.js +232 -0
- package/dist/cli/main.js +37 -0
- package/dist/cli/merged-outside.js +58 -0
- package/dist/cli/names.js +154 -0
- package/dist/cli/opener.js +21 -0
- package/dist/cli/owner.js +154 -0
- package/dist/cli/phone.js +221 -0
- package/dist/cli/ports.js +24 -0
- package/dist/cli/probe.js +18 -0
- package/dist/cli/run.js +246 -0
- package/dist/cli/serve-file.js +21 -0
- package/dist/cli/stats.js +55 -0
- package/dist/cli/version.js +3 -0
- package/dist/core/agent-guide.js +31 -0
- package/dist/core/agent-prompts.js +139 -0
- package/dist/core/authority.js +94 -0
- package/dist/core/board/analysis.js +86 -0
- package/dist/core/board/choices.js +100 -0
- package/dist/core/board/compile.js +362 -0
- package/dist/core/board/engine.js +523 -0
- package/dist/core/board/hints.js +46 -0
- package/dist/core/board/history.js +146 -0
- package/dist/core/board/ids.js +87 -0
- package/dist/core/board/joins.js +30 -0
- package/dist/core/board/mentions.js +68 -0
- package/dist/core/board/merged.js +18 -0
- package/dist/core/board/model.js +135 -0
- package/dist/core/board/next.js +1116 -0
- package/dist/core/board/notes.js +298 -0
- package/dist/core/board/performance.js +218 -0
- package/dist/core/board/plan.js +299 -0
- package/dist/core/board/problems.js +232 -0
- package/dist/core/board/proofs.js +84 -0
- package/dist/core/board/questions.js +114 -0
- package/dist/core/board/reading.js +220 -0
- package/dist/core/board/readings.js +534 -0
- package/dist/core/board/schema.js +335 -0
- package/dist/core/board/shape-words.js +179 -0
- package/dist/core/board/template-words.js +23 -0
- package/dist/core/board/templates-catalogue.js +965 -0
- package/dist/core/board/templates-coverage.js +261 -0
- package/dist/core/board/templates-flows.js +779 -0
- package/dist/core/board/templates.js +586 -0
- package/dist/core/brief.js +93 -0
- package/dist/core/diagram.js +80 -0
- package/dist/core/errors.js +12 -0
- package/dist/core/evidence.js +33 -0
- package/dist/core/fields.js +129 -0
- package/dist/core/hierarchy.js +30 -0
- package/dist/core/icons.js +181 -0
- package/dist/core/image-crop.js +166 -0
- package/dist/core/item.js +49 -0
- package/dist/core/lease.js +31 -0
- package/dist/core/modules.js +318 -0
- package/dist/core/notify/planner.js +117 -0
- package/dist/core/notify/signals.js +66 -0
- package/dist/core/notify/text.js +60 -0
- package/dist/core/path-key.js +22 -0
- package/dist/core/placement.js +161 -0
- package/dist/core/preset-labels.js +66 -0
- package/dist/core/preset-notes.js +109 -0
- package/dist/core/preset.js +541 -0
- package/dist/core/profile.js +55 -0
- package/dist/core/project-id.js +20 -0
- package/dist/core/refusal.js +1 -0
- package/dist/core/relations.js +208 -0
- package/dist/core/repo.js +54 -0
- package/dist/core/samples.js +161 -0
- package/dist/core/search-words.js +68 -0
- package/dist/core/test-report.js +120 -0
- package/dist/core/time.js +8 -0
- package/dist/core/validation.js +60 -0
- package/dist/core/views.js +171 -0
- package/dist/core/workflow.js +51 -0
- package/dist/mcp/commands.js +101 -0
- package/dist/mcp/server.js +239 -0
- package/dist/mcp/words.js +95 -0
- package/dist/server/boards.js +232 -0
- package/dist/server/changes.js +42 -0
- package/dist/server/diff-tip.js +83 -0
- package/dist/server/drift.js +87 -0
- package/dist/server/errors.js +87 -0
- package/dist/server/evidence.js +82 -0
- package/dist/server/hosts.js +6 -0
- package/dist/server/hub.js +98 -0
- package/dist/server/lan-access.js +62 -0
- package/dist/server/lan.js +164 -0
- package/dist/server/listen.js +70 -0
- package/dist/server/notifier.js +156 -0
- package/dist/server/notify-api.js +151 -0
- package/dist/server/pairing.js +124 -0
- package/dist/server/projects.js +191 -0
- package/dist/server/push.js +199 -0
- package/dist/server/server.js +960 -0
- package/dist/server/session.js +43 -0
- package/dist/server/stream.js +36 -0
- package/dist/server/test-push.js +38 -0
- package/dist/server/token.js +37 -0
- package/dist/server/transports.js +54 -0
- package/dist/server/ui.js +44 -0
- package/dist/server/writes.js +361 -0
- package/dist/server/wrong-address.js +36 -0
- package/dist/store/boards.js +111 -0
- package/dist/store/database.js +45 -0
- package/dist/store/machine.js +77 -0
- package/dist/store/migrations.js +493 -0
- package/dist/store/queries.js +585 -0
- package/dist/store/registry.js +72 -0
- package/package.json +72 -4
- package/presets/architecture/playbook.md +69 -0
- package/presets/architecture/preset.yaml +80 -0
- package/presets/architecture/samples.yaml +23 -0
- package/presets/bug-triage/playbook.md +129 -0
- package/presets/bug-triage/preset.yaml +127 -0
- package/presets/bug-triage/samples/wall-slide-after.png +0 -0
- package/presets/bug-triage/samples/wall-slide-before.png +0 -0
- package/presets/bug-triage/samples.yaml +72 -0
- package/presets/change/playbook.md +115 -0
- package/presets/change/preset.yaml +141 -0
- package/presets/change/samples.yaml +62 -0
- package/presets/review/playbook.md +51 -0
- package/presets/review/preset.yaml +62 -0
- package/presets/review/samples.yaml +27 -0
- package/presets/tasks/playbook.md +78 -0
- package/presets/tasks/preset.yaml +61 -0
- package/presets/tasks/samples.yaml +46 -0
- package/schemas/board.schema.json +764 -0
- package/ui/dist/THIRD_PARTY_NOTICES.md +114 -0
- package/ui/dist/assets/dm-mono-latin-400-normal--0xN8mdc.woff +0 -0
- package/ui/dist/assets/dm-mono-latin-400-normal-4GdczIuU.woff2 +0 -0
- package/ui/dist/assets/dm-mono-latin-500-normal-CN8Miw6E.woff +0 -0
- package/ui/dist/assets/dm-mono-latin-500-normal-DRMDZjhP.woff2 +0 -0
- package/ui/dist/assets/dm-mono-latin-ext-400-normal-1aZr6b2b.woff +0 -0
- package/ui/dist/assets/dm-mono-latin-ext-400-normal-C2zvOubV.woff2 +0 -0
- package/ui/dist/assets/dm-mono-latin-ext-500-normal-BtRyHRi6.woff2 +0 -0
- package/ui/dist/assets/dm-mono-latin-ext-500-normal-Dw3M13d8.woff +0 -0
- package/ui/dist/assets/index-C3OzJope.js +103 -0
- package/ui/dist/assets/index-COdEjckQ.css +1 -0
- package/ui/dist/assets/newsreader-latin-ext-opsz-italic-CSPGnFdO.woff2 +0 -0
- package/ui/dist/assets/newsreader-latin-ext-opsz-normal-BQn1nviT.woff2 +0 -0
- package/ui/dist/assets/newsreader-latin-opsz-italic-kJKFiXvB.woff2 +0 -0
- package/ui/dist/assets/newsreader-latin-opsz-normal-s-izfB6B.woff2 +0 -0
- package/ui/dist/assets/newsreader-vietnamese-opsz-italic-DTr-ymY4.woff2 +0 -0
- package/ui/dist/assets/newsreader-vietnamese-opsz-normal-BjhtXyW2.woff2 +0 -0
- package/ui/dist/assets/pdf-YwugTw7Y.js +54 -0
- package/ui/dist/assets/pdf-engine-CkBopwck.js +1 -0
- package/ui/dist/assets/pdf-rELvHkft.js +56 -0
- package/ui/dist/assets/pdf.worker.min-B5Yc7dP4.mjs +27 -0
- package/ui/dist/assets/pdf.worker.min-B7U8ptvh.js +1 -0
- package/ui/dist/assets/pdf.worker.min-CIqJB0yW.mjs +28 -0
- package/ui/dist/assets/pdf.worker.min-UqOn5EDC.js +1 -0
- package/ui/dist/assets/schibsted-grotesk-latin-ext-wght-normal-hsMS0n0O.woff2 +0 -0
- package/ui/dist/assets/schibsted-grotesk-latin-wght-normal-Bb8VGrTG.woff2 +0 -0
- package/ui/dist/icons/apple-touch-icon.png +0 -0
- package/ui/dist/icons/otea-192.png +0 -0
- package/ui/dist/icons/otea-512.png +0 -0
- package/ui/dist/icons/otea-badge.png +0 -0
- package/ui/dist/icons/otea-maskable-512.png +0 -0
- package/ui/dist/index.html +25 -0
- package/ui/dist/manifest.webmanifest +24 -0
- package/ui/dist/otea-idle.svg +5 -0
- package/ui/dist/otea-working.svg +5 -0
- package/ui/dist/otea-yours-working.svg +5 -0
- package/ui/dist/otea-yours.svg +5 -0
- package/ui/dist/sw.js +1 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
function toBoard(row) {
|
|
2
|
+
return {
|
|
3
|
+
id: String(row.id),
|
|
4
|
+
collection: row.collection === null ? null : String(row.collection),
|
|
5
|
+
liveVersion: row.live_version === null ? null : Number(row.live_version),
|
|
6
|
+
builtin: Number(row.builtin) === 1,
|
|
7
|
+
createdAt: String(row.created_at),
|
|
8
|
+
archivedAt: row.archived_at == null ? null : String(row.archived_at),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function insertBoard(db, board) {
|
|
12
|
+
db.prepare('INSERT INTO boards (id, builtin, created_at) VALUES (?, ?, ?)').run(board.id, board.builtin ? 1 : 0, board.createdAt);
|
|
13
|
+
}
|
|
14
|
+
export function findBoard(db, id) {
|
|
15
|
+
const row = db.prepare('SELECT * FROM boards WHERE id = ?').get(id);
|
|
16
|
+
return row && toBoard(row);
|
|
17
|
+
}
|
|
18
|
+
export function findBoardOfCollection(db, collection) {
|
|
19
|
+
const row = db.prepare('SELECT * FROM boards WHERE collection = ?').get(collection);
|
|
20
|
+
return row && toBoard(row);
|
|
21
|
+
}
|
|
22
|
+
// The boards that stand; `archived` adds the archived ones (what reads their items needs).
|
|
23
|
+
export function listBoards(db, options = {}) {
|
|
24
|
+
const archived = options.archived ? '' : ' AND archived_at IS NULL';
|
|
25
|
+
return db
|
|
26
|
+
.prepare(`SELECT * FROM boards WHERE retired_at IS NULL${archived} ORDER BY created_at, rowid`)
|
|
27
|
+
.all()
|
|
28
|
+
.map(toBoard);
|
|
29
|
+
}
|
|
30
|
+
export function setArchived(db, id, at) {
|
|
31
|
+
db.prepare('UPDATE boards SET archived_at = ? WHERE id = ?').run(at, id);
|
|
32
|
+
}
|
|
33
|
+
// A board that was published once and undone keeps its versions (they are append-only): discarding
|
|
34
|
+
// it retires it from every listing instead of deleting it.
|
|
35
|
+
export function retireBoard(db, id, at) {
|
|
36
|
+
db.prepare('UPDATE boards SET retired_at = ? WHERE id = ?').run(at, id);
|
|
37
|
+
}
|
|
38
|
+
export function deleteBoard(db, id) {
|
|
39
|
+
db.prepare('DELETE FROM boards WHERE id = ?').run(id);
|
|
40
|
+
}
|
|
41
|
+
export function setLiveVersion(db, id, version) {
|
|
42
|
+
db.prepare('UPDATE boards SET live_version = ? WHERE id = ?').run(version, id);
|
|
43
|
+
}
|
|
44
|
+
export function setBoardCollection(db, id, collection) {
|
|
45
|
+
db.prepare('UPDATE boards SET collection = ? WHERE id = ?').run(collection, id);
|
|
46
|
+
}
|
|
47
|
+
export function insertVersion(db, version) {
|
|
48
|
+
db.prepare('INSERT INTO board_versions (board_id, version, definition, published_at, published_by) VALUES (?, ?, ?, ?, ?)').run(version.boardId, version.version, version.definition, version.publishedAt, version.publishedBy);
|
|
49
|
+
}
|
|
50
|
+
function toVersion(row) {
|
|
51
|
+
return {
|
|
52
|
+
version: Number(row.version),
|
|
53
|
+
definition: String(row.definition),
|
|
54
|
+
publishedAt: String(row.published_at),
|
|
55
|
+
publishedBy: String(row.published_by),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export function findVersion(db, id, version) {
|
|
59
|
+
const row = db
|
|
60
|
+
.prepare('SELECT * FROM board_versions WHERE board_id = ? AND version = ?')
|
|
61
|
+
.get(id, version);
|
|
62
|
+
return row && toVersion(row);
|
|
63
|
+
}
|
|
64
|
+
export function listVersions(db, id) {
|
|
65
|
+
return db
|
|
66
|
+
.prepare('SELECT * FROM board_versions WHERE board_id = ? ORDER BY version')
|
|
67
|
+
.all(id)
|
|
68
|
+
.map(toVersion);
|
|
69
|
+
}
|
|
70
|
+
export function maxVersion(db, id) {
|
|
71
|
+
const row = db.prepare('SELECT max(version) AS v FROM board_versions WHERE board_id = ?').get(id);
|
|
72
|
+
return Number(row?.v ?? 0);
|
|
73
|
+
}
|
|
74
|
+
export function upsertDraft(db, draft) {
|
|
75
|
+
db.prepare(`INSERT INTO board_drafts (board_id, definition, base_version, updated_at, request_item, agent_note)
|
|
76
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
77
|
+
ON CONFLICT (board_id) DO UPDATE SET definition = excluded.definition,
|
|
78
|
+
base_version = excluded.base_version, updated_at = excluded.updated_at,
|
|
79
|
+
request_item = excluded.request_item, agent_note = excluded.agent_note`).run(draft.boardId, draft.definition, draft.baseVersion, draft.updatedAt, draft.requestItem, draft.agentNote);
|
|
80
|
+
}
|
|
81
|
+
export function findDraft(db, id) {
|
|
82
|
+
const row = db.prepare('SELECT * FROM board_drafts WHERE board_id = ?').get(id);
|
|
83
|
+
if (!row)
|
|
84
|
+
return undefined;
|
|
85
|
+
return {
|
|
86
|
+
boardId: String(row.board_id),
|
|
87
|
+
definition: String(row.definition),
|
|
88
|
+
baseVersion: row.base_version === null ? null : Number(row.base_version),
|
|
89
|
+
updatedAt: String(row.updated_at),
|
|
90
|
+
requestItem: row.request_item === null ? null : String(row.request_item),
|
|
91
|
+
agentNote: row.agent_note === null ? null : String(row.agent_note),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function deleteDraft(db, id) {
|
|
95
|
+
db.prepare('DELETE FROM board_drafts WHERE board_id = ?').run(id);
|
|
96
|
+
}
|
|
97
|
+
// A board renamed renames its collection: the collection row, its items and its board row move to
|
|
98
|
+
// the new name together (boards follow by ON UPDATE CASCADE). Run inside a transaction.
|
|
99
|
+
export function renameCollection(db, from, to) {
|
|
100
|
+
db.exec('PRAGMA defer_foreign_keys = ON');
|
|
101
|
+
db.prepare('UPDATE collections SET name = ? WHERE name = ?').run(to, from);
|
|
102
|
+
db.prepare('UPDATE items SET collection = ? WHERE collection = ?').run(to, from);
|
|
103
|
+
}
|
|
104
|
+
// Changes whenever a board is published, restored, added, archived or deleted: a long-lived reader (the MCP server)
|
|
105
|
+
// compares it to know when to compile the boards again.
|
|
106
|
+
export function boardsStamp(db) {
|
|
107
|
+
const row = db
|
|
108
|
+
.prepare("SELECT count(*) AS n, coalesce(group_concat(id || ':' || coalesce(live_version, 0) || ':' || coalesce(collection, '') || ':' || coalesce(archived_at, ''), ','), '') AS s FROM (SELECT * FROM boards ORDER BY id)")
|
|
109
|
+
.get();
|
|
110
|
+
return `${row?.n ?? 0}|${row?.s ?? ''}`;
|
|
111
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
export function openDatabase(path) {
|
|
3
|
+
const db = new DatabaseSync(path);
|
|
4
|
+
// The timeout goes first: switching to WAL needs a lock, and another process may hold it.
|
|
5
|
+
db.exec('PRAGMA busy_timeout = 5000');
|
|
6
|
+
db.exec('PRAGMA journal_mode = WAL');
|
|
7
|
+
db.exec('PRAGMA foreign_keys = ON');
|
|
8
|
+
return db;
|
|
9
|
+
}
|
|
10
|
+
export function transaction(db, fn) {
|
|
11
|
+
db.exec('BEGIN IMMEDIATE');
|
|
12
|
+
try {
|
|
13
|
+
const result = fn();
|
|
14
|
+
db.exec('COMMIT');
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
db.exec('ROLLBACK');
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function dataVersion(db) {
|
|
23
|
+
return Number(db.prepare('PRAGMA data_version').get()?.data_version);
|
|
24
|
+
}
|
|
25
|
+
// A consistent copy of the whole database in a new file, taken without blocking other connections.
|
|
26
|
+
export function vacuumInto(db, path) {
|
|
27
|
+
db.prepare('VACUUM INTO ?').run(path);
|
|
28
|
+
}
|
|
29
|
+
export function integrityCheck(db) {
|
|
30
|
+
const rows = db.prepare('PRAGMA integrity_check').all();
|
|
31
|
+
return rows.map((row) => String(row.integrity_check)).join(' ');
|
|
32
|
+
}
|
|
33
|
+
// Per table, its row count and highest rowid: two copies that agree hold the same rows, unless a
|
|
34
|
+
// row was changed in place.
|
|
35
|
+
export function tableSummary(db) {
|
|
36
|
+
const sql = "SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%'";
|
|
37
|
+
const names = db
|
|
38
|
+
.prepare(sql)
|
|
39
|
+
.all()
|
|
40
|
+
.map((row) => String(row.name));
|
|
41
|
+
return Object.fromEntries(names.sort().map((name) => {
|
|
42
|
+
const row = db.prepare(`SELECT count(*) AS n, max(rowid) AS last FROM "${name}"`).get();
|
|
43
|
+
return [name, { rows: Number(row?.n ?? 0), lastRowid: Number(row?.last ?? 0) }];
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { applyMigrations } from './migrations.js';
|
|
2
|
+
// What belongs to this computer's one Otea server rather than to a project ($OTEA_HOME/machine.db):
|
|
3
|
+
// the paired devices, how a phone reaches the server, who is told when something becomes yours, the
|
|
4
|
+
// local projects the server was asked to serve and the person's preferences. The tables of devices,
|
|
5
|
+
// phone and notify_targets are laid out as a project's used to be, so the use cases in app/ read
|
|
6
|
+
// them the same way.
|
|
7
|
+
const MACHINE_MIGRATIONS = [
|
|
8
|
+
`
|
|
9
|
+
CREATE TABLE devices (
|
|
10
|
+
id TEXT PRIMARY KEY,
|
|
11
|
+
name TEXT NOT NULL,
|
|
12
|
+
token_hash TEXT NOT NULL UNIQUE,
|
|
13
|
+
paired_at TEXT NOT NULL,
|
|
14
|
+
last_seen_at TEXT
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE phone (
|
|
18
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
19
|
+
transport TEXT NOT NULL,
|
|
20
|
+
tailscale_host TEXT,
|
|
21
|
+
lan_open INTEGER NOT NULL DEFAULT 0
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
CREATE TABLE notify_targets (
|
|
25
|
+
id TEXT PRIMARY KEY,
|
|
26
|
+
device TEXT UNIQUE REFERENCES devices (id) ON DELETE CASCADE,
|
|
27
|
+
endpoint TEXT UNIQUE,
|
|
28
|
+
p256dh TEXT,
|
|
29
|
+
auth TEXT,
|
|
30
|
+
lang TEXT NOT NULL,
|
|
31
|
+
prefs TEXT NOT NULL,
|
|
32
|
+
created_at TEXT NOT NULL
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
CREATE TABLE local_projects (
|
|
36
|
+
id TEXT PRIMARY KEY,
|
|
37
|
+
root TEXT NOT NULL,
|
|
38
|
+
added_at TEXT NOT NULL
|
|
39
|
+
);
|
|
40
|
+
`,
|
|
41
|
+
// How each paired device last reached Otea: 'tailscale' (HTTPS through tailscale serve) or
|
|
42
|
+
// 'lan'; NULL until it is seen again. The Tailscale guide's last step reads it.
|
|
43
|
+
`
|
|
44
|
+
ALTER TABLE devices ADD COLUMN via TEXT;
|
|
45
|
+
`,
|
|
46
|
+
// What the person chose, not a device: today the language of the desk, which everything Otea
|
|
47
|
+
// makes without a desk to ask (otea init, otea board add) is written in.
|
|
48
|
+
`
|
|
49
|
+
CREATE TABLE preferences (
|
|
50
|
+
key TEXT PRIMARY KEY,
|
|
51
|
+
value TEXT NOT NULL
|
|
52
|
+
);
|
|
53
|
+
`,
|
|
54
|
+
];
|
|
55
|
+
export function migrateMachine(db) {
|
|
56
|
+
applyMigrations(db, MACHINE_MIGRATIONS);
|
|
57
|
+
}
|
|
58
|
+
export function selectPreference(db, key) {
|
|
59
|
+
const row = db.prepare('SELECT value FROM preferences WHERE key = ?').get(key);
|
|
60
|
+
return row?.value;
|
|
61
|
+
}
|
|
62
|
+
export function upsertPreference(db, key, value) {
|
|
63
|
+
db.prepare(`INSERT INTO preferences (key, value) VALUES (?, ?)
|
|
64
|
+
ON CONFLICT (key) DO UPDATE SET value = excluded.value`).run(key, value);
|
|
65
|
+
}
|
|
66
|
+
export function upsertLocalProject(db, project, at) {
|
|
67
|
+
db.prepare(`INSERT INTO local_projects (id, root, added_at) VALUES (?, ?, ?)
|
|
68
|
+
ON CONFLICT (id) DO UPDATE SET root = excluded.root`).run(project.id, project.root, at);
|
|
69
|
+
}
|
|
70
|
+
export function selectLocalProjects(db) {
|
|
71
|
+
return db
|
|
72
|
+
.prepare('SELECT id, root FROM local_projects ORDER BY added_at, rowid')
|
|
73
|
+
.all();
|
|
74
|
+
}
|
|
75
|
+
export function deleteLocalProject(db, id) {
|
|
76
|
+
db.prepare('DELETE FROM local_projects WHERE id = ?').run(id);
|
|
77
|
+
}
|