stanford-openarch 0.0.0 → 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/cli/ui.js ADDED
@@ -0,0 +1,209 @@
1
+ // ui.js — how the openarch CLI looks. One place for colour, the mark, tables,
2
+ // the spinner and prompts, so every command speaks with one voice.
3
+ //
4
+ // The identity in a terminal: the name is one lowercase word; the only colour
5
+ // of the mark is arch blue on the centre arch; headings are bold, secondary text
6
+ // dim; verdicts use green / amber / red and nothing else does. No emoji. Colour
7
+ // goes away on a pipe, under NO_COLOR, or with --no-color, and every table
8
+ // degrades to plain aligned text.
9
+ import { stdout, stdin, env } from "node:process";
10
+ import readline from "node:readline";
11
+
12
+ // `openarch members | head` closes our stdout early: that is the reader's choice, not a failure
13
+ stdout.on("error", (e) => { if (e?.code === "EPIPE") process.exit(0); throw e; });
14
+
15
+ // ── colour ─────────────────────────────────────────────────────────────────
16
+
17
+ let colorOn = Boolean(stdout.isTTY) && !("NO_COLOR" in env) && env.TERM !== "dumb";
18
+ if (env.FORCE_COLOR && env.FORCE_COLOR !== "0") colorOn = true;
19
+ export function setColor(on) { colorOn = on; }
20
+ export const color = () => colorOn;
21
+ const truecolor = /^(truecolor|24bit)$/i.test(env.COLORTERM || "");
22
+
23
+ const wrap = (open, close = "\x1b[0m") => (s) => (colorOn ? `${open}${s}${close}` : String(s));
24
+ export const bold = wrap("\x1b[1m", "\x1b[22m");
25
+ export const dim = wrap("\x1b[2m", "\x1b[22m");
26
+ export const italic = wrap("\x1b[3m", "\x1b[23m");
27
+ export const underline = wrap("\x1b[4m", "\x1b[24m");
28
+ // arch blue #2F5D9E; navy for headings reads as the same family on light and dark
29
+ export const arch = wrap(truecolor ? "\x1b[38;2;47;93;158m" : "\x1b[38;5;25m", "\x1b[39m");
30
+ export const pale = wrap(truecolor ? "\x1b[38;2;123;160;204m" : "\x1b[38;5;110m", "\x1b[39m");
31
+ export const green = wrap("\x1b[32m", "\x1b[39m");
32
+ export const amber = wrap("\x1b[33m", "\x1b[39m");
33
+ export const red = wrap("\x1b[31m", "\x1b[39m");
34
+
35
+ export const glyph = { pass: green("✓"), fail: red("✗"), warn: amber("!"), skip: dim("–"), info: dim("·"), arrow: dim("→") };
36
+
37
+ // visible width (strip ANSI, count code points; the box-drawing we use is single width)
38
+ export const strip = (s) => String(s).replace(/\x1b\[[0-9;]*m/g, "");
39
+ /**
40
+ * One shell word for a suggested command line (ind-sec run-1,
41
+ * member-data-in-suggested-command): values that come from a member — a search
42
+ * cursor, a document id — are single-quoted unless they are plainly safe, so a
43
+ * hostile one cannot add a flag (--hub …) or a command to a line a partner pastes.
44
+ */
45
+ export const shq = (v) => { const s = String(v ?? ""); return /^[A-Za-z0-9_@%+=:,./-]+$/.test(s) && !s.startsWith("-") ? s : `'${s.replace(/'/g, "'\\''")}'`; };
46
+ export const width = (s) => [...strip(s)].length;
47
+ export const cols = () => (stdout.isTTY && stdout.columns) || Number(env.COLUMNS) || 100;
48
+
49
+ export function truncate(s, n) {
50
+ const raw = String(s ?? "");
51
+ if (width(raw) <= n) return raw;
52
+ const chars = [...strip(raw)];
53
+ return chars.slice(0, Math.max(0, n - 1)).join("") + "…";
54
+ }
55
+ export const pad = (s, n, right = false) => {
56
+ const w = width(s);
57
+ const fill = " ".repeat(Math.max(0, n - w));
58
+ return right ? fill + s : s + fill;
59
+ };
60
+
61
+ export const fmtInt = (n) => (typeof n === "number" && Number.isFinite(n) ? n.toLocaleString("en-US") : n == null ? dim("—") : String(n));
62
+ export const fmtBytes = (n) => {
63
+ if (typeof n !== "number") return dim("—");
64
+ if (n < 1024) return `${n} B`;
65
+ if (n < 1024 ** 2) return `${(n / 1024).toFixed(1)} KB`;
66
+ if (n < 1024 ** 3) return `${(n / 1024 ** 2).toFixed(1)} MB`;
67
+ return `${(n / 1024 ** 3).toFixed(2)} GB`;
68
+ };
69
+ export const fmtMs = (ms) => (ms < 1000 ? `${Math.round(ms)} ms` : `${(ms / 1000).toFixed(1)} s`);
70
+
71
+ // ── the mark ───────────────────────────────────────────────────────────────
72
+
73
+ /** The arcade: eaves, two side arches, the centre arch in blue, the baseline. */
74
+ export function mark() {
75
+ const a = arch;
76
+ return [
77
+ " ╱───────────────────╲",
78
+ ` ╭─╮ ${a("╭───────╮")} ╭─╮`,
79
+ ` │ │ ${a("│ │")} │ │`,
80
+ ` ───┴─┴────${a("┴───────┴")}────┴─┴───`,
81
+ ];
82
+ }
83
+
84
+ /** The mark with the wordmark and a line or two beside it. */
85
+ export function banner(lines = []) {
86
+ const m = mark();
87
+ const right = [bold("openarch"), ...lines.map((l) => dim(l))];
88
+ const out = [];
89
+ for (let i = 0; i < m.length; i++) {
90
+ const r = right[i - 1] ?? ""; // text starts on the second row, level with the arches
91
+ out.push(pad(m[i], 34) + (r ? ` ${r}` : ""));
92
+ }
93
+ return out.join("\n");
94
+ }
95
+
96
+ // ── headings and blocks ────────────────────────────────────────────────────
97
+
98
+ export const h1 = (s) => bold(s);
99
+ export const h2 = (s) => `${arch("§")} ${bold(s)}`;
100
+ export const label = (s) => dim(String(s).toUpperCase());
101
+ export const kv = (pairs, indent = " ") => {
102
+ const w = Math.max(...pairs.map(([k]) => width(k)));
103
+ // one line per pair: a value's line break or tab can never start a line of its own (P3 #25)
104
+ const flat = (s) => String(s).replace(/[\r\n\t]+/g, " ");
105
+ return pairs.map(([k, v]) => `${indent}${dim(pad(flat(k), w))} ${v == null ? dim("—") : flat(v)}`).join("\n");
106
+ };
107
+ export const rule = (n = Math.min(cols(), 100)) => dim("─".repeat(n));
108
+
109
+ /**
110
+ * A table: `columns` = [{ key, title, align: "left"|"right", max }], `rows` = objects.
111
+ * Header in small caps, a rule beneath, numbers right-aligned, long cells
112
+ * truncated so the whole table fits the terminal.
113
+ */
114
+ export function table(columns, rows, { indent = " ", gap = 3 } = {}) {
115
+ const avail = cols() - indent.length;
116
+ const raw = (v) => (typeof v === "string" ? cleanLine(v) : v);
117
+ const cells = rows.map((r) => columns.map((c) => (c.format ? c.format(raw(r[c.key]), r) : r[c.key] == null ? dim("—") : cleanLine(r[c.key]))));
118
+ const widths = columns.map((c, i) => Math.max(width(c.title), ...cells.map((row) => width(row[i]))));
119
+ // shrink the widest flexible column until the table fits
120
+ let total = widths.reduce((a, b) => a + b, 0) + gap * (columns.length - 1);
121
+ while (total > avail) {
122
+ const i = widths.indexOf(Math.max(...widths.map((w, j) => (columns[j].fixed ? 0 : w))));
123
+ if (widths[i] <= 8) break;
124
+ widths[i]--; total--;
125
+ }
126
+ const line = (row, isHead) => indent + row.map((v, i) => pad(truncate(v, widths[i]), widths[i], columns[i].align === "right")).join(" ".repeat(gap)).replace(/\s+$/, "");
127
+ const out = [line(columns.map((c) => label(c.title)), true), indent + dim("─".repeat(Math.min(total, avail)))];
128
+ for (const row of cells) out.push(line(row, false));
129
+ return out.join("\n");
130
+ }
131
+
132
+ // ── spinner ────────────────────────────────────────────────────────────────
133
+
134
+ const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
135
+ export function spinner(text) {
136
+ if (!stdout.isTTY || !colorOn) return { stop() {}, update() {} };
137
+ let i = 0, msg = text;
138
+ const draw = () => stdout.write(`\r\x1b[2K ${arch(FRAMES[i++ % FRAMES.length])} ${dim(msg)}`);
139
+ draw();
140
+ const t = setInterval(draw, 80);
141
+ return {
142
+ update(m) { msg = m; },
143
+ stop() { clearInterval(t); stdout.write("\r\x1b[2K"); },
144
+ };
145
+ }
146
+
147
+ // ── prompts ────────────────────────────────────────────────────────────────
148
+
149
+ // Whatever a hub, a member or a catalog sends can reach this terminal: in human output a control
150
+ // character prints as U+FFFD, never as a terminal escape (ind-sec run-1; moved here so every
151
+ // printer shares it, PR #3 review S13). Single-line fields also lose their line breaks.
152
+ export const CONTROL = /[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/g;
153
+ export const cleanForTerminal = (v) => typeof v === "string" ? v.replace(CONTROL, "\ufffd") : Array.isArray(v) ? v.map(cleanForTerminal) : v && typeof v === "object" ? Object.fromEntries(Object.entries(v).map(([k, x]) => [cleanForTerminal(k), cleanForTerminal(x)])) : v;
154
+ export const cleanLine = (s) => String(s ?? "").replace(/[\r\n\t]+/g, " ").replace(CONTROL, "\ufffd");
155
+
156
+ /** Is this a hub a key must never be sent to: plain http to anything but this machine? (S14) */
157
+ export const plainHttpRemote = (u) => { try { const x = new URL(u); return x.protocol !== "https:" && !(x.protocol === "http:" && /^(localhost|127(\.\d{1,3}){3}|\[::1\])$/i.test(x.hostname)); } catch { return true; } };
158
+
159
+ export class NotATerminal extends Error { constructor(q) { super(`"${q}" needs an answer and stdin is not a terminal`); this.question = q; } }
160
+ export class Interrupted extends Error { constructor() { super("Stopped."); } }
161
+
162
+ export function ask(question, { fallback = "", hidden = false } = {}) {
163
+ // on a pipe or in a script there is nobody to answer: take the fallback, or say what was missing
164
+ if (!stdin.isTTY) { if (fallback) return Promise.resolve(fallback); return Promise.reject(new NotATerminal(question)); }
165
+ return new Promise((resolve, reject) => {
166
+ const rl = readline.createInterface({ input: stdin, output: stdout, terminal: true });
167
+ // Ctrl-C: stop, and say so (a silent exit would lose what was answered so far)
168
+ rl.on("SIGINT", () => { rl.close(); stdout.write("\n"); reject(new Interrupted()); });
169
+ const q = ` ${question}${fallback ? dim(` (${cleanLine(fallback)})`) : ""}: `;
170
+ if (hidden) {
171
+ // echo nothing: a key pasted into a terminal should not sit in scrollback
172
+ const onData = (ch) => { const c = String(ch); if (c === "\n" || c === "\r" || c === "\u0004") stdin.removeListener("data", onData); };
173
+ rl._writeToOutput = (s) => { if (s.includes(q)) stdout.write(q); };
174
+ stdin.on("data", onData);
175
+ }
176
+ rl.question(q, (a) => { rl.close(); if (hidden) stdout.write("\n"); resolve((a || "").trim() || fallback); });
177
+ });
178
+ }
179
+
180
+ /** A numbered choice from a vocabulary list [{id,label,note}]; returns the id. */
181
+ export async function choose(question, list, { fallback } = {}) {
182
+ if (!stdin.isTTY) { if (fallback) return fallback; return Promise.reject(new NotATerminal(question)); }
183
+ out(`\n ${bold(question)}`);
184
+ list.forEach((x, i) => { out(` ${dim(String(i + 1).padStart(2))} ${bold(x.label)} ${dim(x.id)}`); out(` ${dim(x.note)}`); });
185
+ for (;;) {
186
+ const a = await ask(`choose 1–${list.length}`, { fallback: fallback ? String(list.findIndex((x) => x.id === fallback) + 1) : "" });
187
+ const n = Number.parseInt(a, 10);
188
+ if (n >= 1 && n <= list.length) return list[n - 1].id;
189
+ const byId = list.find((x) => x.id === a);
190
+ if (byId) return byId.id;
191
+ out(` ${amber("!")} ${dim(`a number from 1 to ${list.length}, or one of the words`)}`);
192
+ }
193
+ }
194
+
195
+ export async function confirm(question, def = false) {
196
+ const a = (await ask(`${question} ${dim(def ? "[Y/n]" : "[y/N]")}`)).toLowerCase();
197
+ if (!a) return def;
198
+ return a.startsWith("y");
199
+ }
200
+
201
+ // ── output ─────────────────────────────────────────────────────────────────
202
+
203
+ export const out = (s = "") => stdout.write(s + "\n");
204
+ export const blank = () => stdout.write("\n");
205
+ export function fail(message, hint) {
206
+ process.stderr.write(`\n ${red("✗")} ${message}\n${hint ? ` ${dim(hint)}\n` : ""}\n`);
207
+ process.exitCode = 1;
208
+ }
209
+ export const json = (v) => stdout.write(JSON.stringify(v, null, 2) + "\n");
@@ -0,0 +1,215 @@
1
+ # Connecting your archive to openarch
2
+
3
+ openarch is a network that lets researchers at partner universities search, read, cite and
4
+ check quotations in each member archive's documents, under each archive's own terms. This guide
5
+ connects yours. You need a terminal, Node.js 20.6 or newer, your catalog as a spreadsheet, and
6
+ the folder of files it describes. You write no code.
7
+
8
+ ## 1. Install
9
+
10
+ ```sh
11
+ npm install -g https://openarch.stanford.edu/cli/stanford-openarch-0.1.0.tgz
12
+ openarch --version
13
+ ```
14
+
15
+ `https://openarch.stanford.edu/cli/` lists the current version and its sha256. The package is
16
+ named `stanford-openarch`; the command it installs is `openarch`. Install from that address
17
+ only: the package named `openarch` on the public npm registry is someone else's, not this one
18
+ (`openarch mcp doctor` checks which `openarch` your terminal runs), and `stanford-openarch` is
19
+ not published there yet. **Until it is published by this network, never run `npm update -g`,
20
+ `npm outdated -g` or `npm audit fix --force` for it**: npm looks a package up on the registry by
21
+ its name, and could replace this one with whatever that name holds. If you installed openarch
22
+ before 2026-11-29, when the package was named `openarch`, remove that one first
23
+ (`npm rm -g openarch`), install this one, and wire your agents to it again
24
+ (`openarch mcp install <client>`; `openarch mcp doctor` names any still pointing at the old one).
25
+
26
+ `npm install` may report a high-severity advisory in zod. zod is used only by
27
+ `openarch mcp serve` (an agent's tools), never by your adapter, and a zod 4 upgrade is
28
+ planned. The command line talks to the hub you installed it from; `--hub <url>` or
29
+ `OPENARCH_HUB` points it elsewhere, and its banner (`openarch --help`) names the hub in use.
30
+
31
+ ## 2. The path
32
+
33
+ | Step | Command | What happens |
34
+ |---|---|---|
35
+ | Describe your archive | `openarch member init my-archive` | Asks about the archive, reads your catalog, writes a working adapter |
36
+ | Run it here | `cd my-archive && npm install && npm start` | Your archive answers on this machine, at http://127.0.0.1:3101 (`PORT` in `.env` changes it) |
37
+ | Check it | `openarch member check` | Walks every protocol call: "Conforms (local test)", or what to fix |
38
+ | Go live | see [Going live](#4-going-live) | The same adapter, at your public https address |
39
+ | Check it live | `openarch member check --public` | "Ready to apply", or what to fix |
40
+ | Apply | `openarch member apply` | Sends your application; the declarations come from your live adapter. Rehearsing first against a development hub, with the adapter on this machine: `openarch member apply --local --hub <that hub>` |
41
+ | Wait | `openarch member status` | Pending, then approved |
42
+ | Connect | `openarch member credential set` | Installs the hub's credential (sent to you at approval); restart the adapter |
43
+
44
+ Every command has its own help: `openarch member init --help`; `openarch member --help` shows
45
+ this path.
46
+
47
+ **If `init` stops part-way** (you decline the agreement, or press Ctrl-C), your answers are kept
48
+ in `my-archive.answers.json`; `openarch member init my-archive --answers my-archive.answers.json`
49
+ asks only what is missing. The public address is asked once and checked then: it is the https
50
+ address the hub will reach over the internet, not the one you test at.
51
+
52
+ ## 3. Your catalog
53
+
54
+ A CSV file (or TSV, or JSON Lines) with one row per document and one column per field.
55
+ Spreadsheet exports work as they are: quoted commas and line breaks, a byte-order mark,
56
+ CRLF line ends. `member init` reads the column names and guesses which is which; you
57
+ confirm each one against a preview.
58
+
59
+ | Field | Required | What it holds |
60
+ |---|---|---|
61
+ | id | yes | A unique identifier that never changes. Allowed: letters, digits, `.`, `_`, `~`, `-` (no spaces or slashes), at most 128 characters. It becomes `<your short name>/<id>` in the network. |
62
+ | title | yes | The document's title. |
63
+ | date | no | `YYYY`, `YYYY-MM` or `YYYY-MM-DD`. |
64
+ | authors | no | Who made it; several separated by `;`. |
65
+ | collection | no | Which collection a row belongs to. Each distinct value becomes a collection (up to 50). |
66
+ | type | no | Letter, report, minutes and so on. |
67
+ | file | no | The path of its file, relative to the catalog; several separated by `;`. The first is the primary file. |
68
+ | text | no | Its text: the path of a `.txt` file, or the text itself. |
69
+ | source_url | no | Where the original lives, if it is elsewhere. |
70
+ | pages | no | How many pages it has, when its text does not mark them. |
71
+
72
+ **When the page count disagrees.** If a text's form feeds give a different number of pages than
73
+ your catalog's `pages` column, the catalog wins: the text is served whole, without page markers,
74
+ and `init` and the adapter's log say which documents.
75
+
76
+ **Text and pages.** The kind of text is asked once: OCR (recognized by software from scans),
77
+ born-digital (text from the start), or a transcript of speech (what was said in a recording).
78
+ If your transcripts separate pages with form feeds (which `pdftotext`
79
+ writes: `pdftotext scan.pdf scan.txt`), the kit marks each page `[[page N]]`. Partners can
80
+ then read single pages, and pay only for those. Text without page breaks is served whole.
81
+ The kit serves the text you give it; it never generates text.
82
+
83
+ **Kinds and sharing.** A file's kind comes from its extension: pdf, image, video, audio,
84
+ spreadsheet, email, text or dataset. A row with no file is "text". During `init` you choose,
85
+ for each kind your catalog holds, how far to share it:
86
+ - metadata only;
87
+ - metadata and text;
88
+ - metadata, text and the files;
89
+ - or withhold it, with a reason.
90
+
91
+ Withheld kinds are never loaded, never searched and never counted.
92
+
93
+ **Problems.** When the catalog has a problem, the kit refuses it and lists every problem with
94
+ its line number: a repeated or unsafe id, a missing title, a file that is missing or outside
95
+ the archive's folder, a collection no one defined. Fix the spreadsheet and start again.
96
+
97
+ ## 4. Going live
98
+
99
+ The hub reaches your adapter over https at the public address you gave (`public_base` in
100
+ `openarch-member.json`). Any small server with Node.js 20.6 or newer will do. The adapter
101
+ keeps your catalog's text in memory, so plan for about twice the size of that text.
102
+
103
+ If your catalog lived outside the member's directory, `init` offered to copy it and its files
104
+ into `archive/` there, so the directory is everything the server needs. If you kept it where it
105
+ was, put it on the server at the same place relative to the directory (`catalog.path`); the
106
+ member's README.md names that place (for example `/srv/library-archive`), and the Dockerfile's
107
+ run line mounts it. If you change `PORT` in `.env`, change `deploy/Caddyfile` (and the
108
+ Dockerfile's `-p`) to match; `openarch member check` warns when they differ.
109
+
110
+ `member init` wrote three files in `deploy/` for this:
111
+ - `Caddyfile`. Caddy obtains and renews the https certificate and passes requests to the
112
+ adapter on the same machine. Point your name's DNS at the server, install Caddy, use this
113
+ file.
114
+ - `openarch-member.service`. A systemd unit that keeps the adapter running and restarts it if
115
+ it fails. `systemctl reload openarch-member` re-reads the catalog.
116
+ - `Dockerfile`, if you run containers instead.
117
+
118
+ Copy the directory to the server at `/srv/openarch-member` (the systemd unit's path; change
119
+ the unit if you put it elsewhere), including `.env`, which is mode 600 and must not go into
120
+ version control. Run `npm install --omit=dev` there and start the service:
121
+ `systemctl enable --now openarch-member`. Only port 443 needs to be open to the world. The
122
+ adapter itself listens on 127.0.0.1:3101, and logs one line per call (method, path, status,
123
+ time; never a search's words): `journalctl -u openarch-member -f`.
124
+
125
+ **Its public pages.** Each document has a page at `<public_base>/view/<id>`, the address its
126
+ citation names, open to anyone on the web: its record, its citation, the credit you require and
127
+ your statement. Its text appears there only when you declared automated access allowed, or set
128
+ `"view": { "text": true }` in `openarch-member.json`; researchers read it through openarch
129
+ either way. Unless automated access is allowed, search engines and scripts are asked not to
130
+ index the page (robots.txt and a noindex header).
131
+
132
+ Then, from your own machine, in the member's directory, run `openarch member check --public`.
133
+ It walks the live address. Once it says **Ready to apply**, run `openarch member apply`.
134
+
135
+ ## 5. After approval
136
+
137
+ The operator sends two things to the contact address on your application, each shown to them
138
+ only once:
139
+ - **The hub's credential** (`oa_hub_…`). The hub presents it on every call to your adapter, and
140
+ your adapter answers nothing without it. Run `openarch member credential set` (it asks for it) in the
141
+ member's directory, copy `.env` to the server, and restart. It replaces the provisional
142
+ credential `init` made for testing, which was never sent anywhere.
143
+ - **Your account key** (`oa_mem_…`). With it you sign in at `https://openarch.stanford.edu/account`
144
+ (your sharing board) and with `openarch login`, and you can use the network as a partner does.
145
+
146
+ `openarch member status` shows the hub's last call to your adapter. A 401 there means the
147
+ adapter does not hold the hub's credential yet.
148
+
149
+ ## 6. Keeping it current
150
+
151
+ - **The catalog changes.** Edit it, then reload: `systemctl reload openarch-member`, or
152
+ `kill -HUP <pid>`. The kit loads the new catalog and serves it only if it is sound;
153
+ otherwise it keeps serving the old one and logs why. The hub re-reads your manifest
154
+ (collections, counts, the sharing grid) within six hours.
155
+ - **What you share changes.** Edit `sharing` in `openarch-member.json` and reload, or change
156
+ it on your sharing board at /account. The hub enforces the board.
157
+ - **The credential needs replacing.** Ask the operator. They issue a new one; you run
158
+ `openarch member credential set`.
159
+ - **A new version of openarch.** Run `npm install -g <the new tarball>` on your machine, and
160
+ point the `stanford-openarch` dependency in `package.json` at it on the server (then
161
+ `npm install`). Your `openarch-member.json` and catalog stay as they are. Never take a new
162
+ version from `npm update`, `npm outdated` or `npm audit fix --force`: until
163
+ `stanford-openarch` is published by this network, the registry's answer is not this package.
164
+
165
+ **A member made before 2026-11-29** names the kit `openarch` in `package.json` and imports
166
+ `openarch/member-kit` in `index.js`. It still runs, but npm can resolve that name on the public
167
+ registry. Rename both, in the member's directory (and on the server), then reinstall:
168
+
169
+ ```sh
170
+ npm pkg delete dependencies.openarch
171
+ npm pkg set dependencies.stanford-openarch=https://openarch.stanford.edu/cli/stanford-openarch-0.1.0.tgz
172
+ sed -i.bak 's#"openarch/member-kit"#"stanford-openarch/member-kit"#' index.js && rm index.js.bak
173
+ rm -rf node_modules package-lock.json && npm install
174
+ ```
175
+
176
+ ## 7. openarch-member.json
177
+
178
+ | Key | What it is |
179
+ |---|---|
180
+ | `member` | Your short name: lowercase, digits, `-`. It prefixes every id. |
181
+ | `name`, `institution`, `contact`, `home` | How the network lists you. `contact` is an email address. |
182
+ | `public_base` | The https address the hub reaches you at. Permalinks and file URLs are built from it, never from the address a request arrived at. |
183
+ | `catalog.path`, `catalog.columns`, `catalog.files_root`, `catalog.authors_separator` | Your catalog, which column is which, the folder your files live under (default: the catalog's folder), and the author separator (default `;`). |
184
+ | `text.kind`, `text.from` | `ocr`, `born-digital`, `transcript` or `none`. `file` (the column holds paths) or `column` (it holds the text). |
185
+ | `default_kind` | The kind of a row with no file (default `text`). |
186
+ | `collections` | `{ id: "<member>/<name>", title, match, terms }`. `match` is the collection column's value. |
187
+ | `terms` | Reuse statements by id, e.g. `{ "research-and-education": { label, reuse, url } }`. Each collection names one. |
188
+ | `rights`, `permalinks`, `agreement`, `sharing` | Your declarations, as `init` asked them (protocol §4.1). `permalinks.pattern` defaults to `<public_base>/view/{id}`, a page the kit serves for each document. |
189
+ | `limits` | `search_results_max` (default 50); `document_bytes_max` (default 2 MB; longer texts are cut and say so). |
190
+ | `view` | `{ "text": true }` shows each document's text on its public page (otherwise only when automated access is allowed); `{ "text": false }` never. |
191
+
192
+ **Scripted setup.** `openarch member init <dir> --answers answers.json` takes the same answers
193
+ as JSON: `name`, `institution`, `contact`, `member`, `public_base`, `catalog`, `text`, and
194
+ `declarations` (containing `rights`, `accepted_by` and `sharing`).
195
+
196
+ ## 8. Larger archives, or a database
197
+
198
+ The kit holds its index in memory and suits tens of thousands of documents. For a larger
199
+ archive, or one that lives in a database, the simplest route is to export your catalog to CSV
200
+ or JSON Lines on a schedule and reload. Beyond that, the protocol (`openarch protocol`) is
201
+ five calls you can serve from your own system. `openarch member check` tells you when yours
202
+ conforms.
203
+
204
+ ## 9. When the check says no
205
+
206
+ | Check | What to do |
207
+ |---|---|
208
+ | `reachable: nothing answered` | Is the adapter running at that address? The base URL is the address before `/openarch/v1`. |
209
+ | `answers: the adapter refused this credential` | Pass the credential your adapter has, or run the check in the member's directory, which reads `.env`. |
210
+ | `public https address` | The hub only calls https at a public address. Test on your own machine with the plain `openarch member check`. |
211
+ | `gated by a credential: open to any caller` | Set `OPENARCH_HUB_CREDENTIAL` in `.env` (`init` wrote one). |
212
+ | `public https address: nothing answered there` | The name's DNS, the server, Caddy and the adapter: each must be up. `the name … does not resolve` means DNS. |
213
+ | `your own archive: still the example's` | Replace the demonstration archive's identity and documents with yours. |
214
+ | `permalinks follow the pattern` | Set `public_base` to the address you will serve at, not the one you are testing on. |
215
+ | `chicago: does not name the holding archive` | Your citations must carry your archive's name, as `name` gives it. |