@refhub/cli 1.3.0 → 1.6.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/README.md +9 -15
- package/bin/refhub.js +2 -0
- package/dist/client.d.ts +13 -5
- package/dist/client.js +11 -33
- package/dist/commands/items.d.ts +4 -0
- package/dist/commands/items.js +14 -2
- package/dist/commands/vaults.d.ts +1 -0
- package/dist/commands/vaults.js +19 -1
- package/dist/index.js +0 -1
- package/dist/types.d.ts +5 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -77,6 +77,7 @@ refhub vaults get <vaultId>
|
|
|
77
77
|
refhub vaults create --name <n> [--description] [--color] [--visibility] [--category]
|
|
78
78
|
refhub vaults update <vaultId> [--name] [--description] [--color] [--category]
|
|
79
79
|
refhub vaults delete <vaultId> --confirm
|
|
80
|
+
refhub vaults archive <vaultId> --confirm
|
|
80
81
|
refhub vaults visibility <vaultId> --visibility <private|protected|public> [--slug]
|
|
81
82
|
|
|
82
83
|
# shares
|
|
@@ -91,8 +92,8 @@ refhub vaults shares remove <vaultId> <shareId>
|
|
|
91
92
|
```bash
|
|
92
93
|
refhub items list --vault <id> [--page] [--limit]
|
|
93
94
|
refhub items get --vault <id> <itemId>
|
|
94
|
-
refhub items add --vault <id> --title <t> [--authors "Smith J,Doe A"] [--year] [--doi] [--tags <id,id>]
|
|
95
|
-
refhub items update --vault <id> <itemId> [--title] [--authors] [--year] [--doi] [--tags <id,id>]
|
|
95
|
+
refhub items add --vault <id> --title <t> [--authors "Smith J,Doe A"] [--year] [--doi] [--url] [--pdf-url] [--tags <id,id>] [--notes]
|
|
96
|
+
refhub items update --vault <id> <itemId> [--title] [--authors] [--year] [--doi] [--url] [--pdf-url] [--tags <id,id>] [--notes]
|
|
96
97
|
refhub items delete --vault <id> <itemId> --confirm
|
|
97
98
|
refhub items upsert --vault <id> --file <items.json> [--idempotency-key]
|
|
98
99
|
refhub items preview --vault <id> --file <items.json>
|
|
@@ -103,6 +104,8 @@ refhub items changes --vault <id> --since <ISO>
|
|
|
103
104
|
|
|
104
105
|
`--tags` on update is a **full replacement**, not an append. a warning is printed to stderr.
|
|
105
106
|
|
|
107
|
+
`--pdf-url` sets the frontend's `publisher_pdf` field (a link to a publisher-hosted PDF). it is distinct from the frontend's `drive_pdf` field (the Google Drive-hosted copy created by `refhub pdf upload`, see below) — the Drive copy is readable back afterward too, as `drive_pdf_url` on item reads (see the `pdf` command below).
|
|
108
|
+
|
|
106
109
|
### tags
|
|
107
110
|
|
|
108
111
|
```bash
|
|
@@ -181,10 +184,10 @@ Uploads a PDF file to the user's linked Google Drive and links it to a vault ite
|
|
|
181
184
|
refhub pdf upload --vault <vaultId> --item <itemId> --file <path/to/file.pdf>
|
|
182
185
|
```
|
|
183
186
|
|
|
184
|
-
-
|
|
185
|
-
- raw API uploads are capped by the backend at the smallest of `REFHUB_API_MAX_BODY_BYTES`, `GOOGLE_DRIVE_MAX_UPLOAD_BYTES`, and the Netlify synchronous Function ceiling (6 MiB); oversized raw requests return structured `413 pdf_upload_too_large_for_api`
|
|
186
|
-
- larger PDFs use the API-key resumable Drive flow: `POST /api/v1/vaults/:vaultId/items/:itemId/pdf/session`, direct `PUT` of the PDF bytes to the returned Google Drive `upload_url`, then `POST /api/v1/vaults/:vaultId/items/:itemId/pdf/complete`
|
|
187
|
+
- all PDF uploads use the resumable Drive flow, regardless of file size — there is no raw-body upload route anymore: `POST /api/v1/vaults/:vaultId/items/:itemId/pdf/session`, direct `PUT` of the PDF bytes to the returned Google Drive `upload_url`, then `POST /api/v1/vaults/:vaultId/items/:itemId/pdf/complete`
|
|
187
188
|
- max file size: 26 MB by default, matching the backend Google Drive upload limit
|
|
189
|
+
- on success the response body carries the resulting Google Drive URL directly: `{ data: { stored: true, provider: "google_drive", fileId, driveUrl, folderId, folderName } }`. Deliberately named differently from `pdf_url` (the publisher-hosted link set via `--pdf-url`, see above) since they are unrelated fields.
|
|
190
|
+
- the stored Drive link is also readable afterward as `drive_pdf_url` on `items get`/`items list`/vault reads, and in the refreshed row returned by `items update` — it's the same value the frontend calls `drive_pdf`.
|
|
188
191
|
|
|
189
192
|
---
|
|
190
193
|
|
|
@@ -220,6 +223,7 @@ rate-limited responses (429) include `retry_after_seconds`.
|
|
|
220
223
|
## // guardrails
|
|
221
224
|
|
|
222
225
|
- `vaults delete` and `items delete` require `--confirm` — hard deletes, no undo
|
|
226
|
+
- `vaults archive` requires `--confirm` — permanent read-only lockdown, no undo, no unarchive command exists
|
|
223
227
|
- `items upsert` without `--idempotency-key` emits a `partial_write_risk` warning before exiting 1 on failure
|
|
224
228
|
- `items update --tags` warns that the tags list is a full replacement
|
|
225
229
|
|
|
@@ -252,13 +256,3 @@ Releases are published from GitHub Actions via npm Trusted Publishing. See [RELE
|
|
|
252
256
|
| output | chalk • cli-table3 |
|
|
253
257
|
| tests | vitest |
|
|
254
258
|
| build | tsc + tsx |
|
|
255
|
-
|
|
256
|
-
---
|
|
257
|
-
|
|
258
|
-
## // out of scope (v1)
|
|
259
|
-
|
|
260
|
-
not exposed by the cli:
|
|
261
|
-
|
|
262
|
-
- api key management (jwt-only, no cli command)
|
|
263
|
-
- google drive link/unlink setup (browser/JWT-only, no cli command)
|
|
264
|
-
- global audit log (jwt-only, non-vault-scoped, no cli command)
|
package/bin/refhub.js
ADDED
package/dist/client.d.ts
CHANGED
|
@@ -7,12 +7,10 @@ export declare class RefHubError extends Error {
|
|
|
7
7
|
constructor(status: number, code: string, message: string, request_id: string, retry_after_seconds?: number);
|
|
8
8
|
}
|
|
9
9
|
export declare class RefHubClient {
|
|
10
|
-
static readonly RAW_PDF_UPLOAD_LIMIT_BYTES: number;
|
|
11
10
|
private readonly baseUrl;
|
|
12
11
|
private readonly headers;
|
|
13
12
|
constructor(apiKey: string);
|
|
14
13
|
private req;
|
|
15
|
-
private reqBinary;
|
|
16
14
|
private reqText;
|
|
17
15
|
listVaults(): Promise<ApiResponse<Vault[]>>;
|
|
18
16
|
getVault(vaultId: string): Promise<ApiResponse<VaultDetail>>;
|
|
@@ -34,6 +32,8 @@ export declare class RefHubClient {
|
|
|
34
32
|
deleteVault(vaultId: string): Promise<ApiResponse<{
|
|
35
33
|
id: string;
|
|
36
34
|
}>>;
|
|
35
|
+
/** Permanently archives the vault. There is no unarchive — this cannot be undone. */
|
|
36
|
+
archiveVault(vaultId: string): Promise<ApiResponse<Vault>>;
|
|
37
37
|
setVaultVisibility(vaultId: string, body: {
|
|
38
38
|
visibility: string;
|
|
39
39
|
public_slug?: string;
|
|
@@ -60,16 +60,20 @@ export declare class RefHubClient {
|
|
|
60
60
|
authors?: string[];
|
|
61
61
|
year?: number;
|
|
62
62
|
doi?: string;
|
|
63
|
+
url?: string;
|
|
63
64
|
tag_ids?: string[];
|
|
64
65
|
notes?: string;
|
|
66
|
+
pdf_url?: string;
|
|
65
67
|
}>): Promise<ApiResponse<Item[]>>;
|
|
66
68
|
updateItem(vaultId: string, itemId: string, body: {
|
|
67
69
|
title?: string;
|
|
68
70
|
authors?: string[];
|
|
69
71
|
year?: number;
|
|
70
72
|
doi?: string;
|
|
73
|
+
url?: string;
|
|
71
74
|
tag_ids?: string[];
|
|
72
75
|
notes?: string;
|
|
76
|
+
pdf_url?: string;
|
|
73
77
|
}): Promise<ApiResponse<Item>>;
|
|
74
78
|
deleteItem(vaultId: string, itemId: string): Promise<ApiResponse<{
|
|
75
79
|
id: string;
|
|
@@ -144,14 +148,17 @@ export declare class RefHubClient {
|
|
|
144
148
|
}>>;
|
|
145
149
|
semanticScholarSearch(query: string, limit?: number): Promise<ApiResponse<SemanticScholarPaper[]>>;
|
|
146
150
|
semanticScholarPaperList(kind: 'recommendations' | 'related' | 'references' | 'citations' | 'cited-by', paperId: string, limit?: number): Promise<ApiResponse<SemanticScholarPaper[]>>;
|
|
147
|
-
uploadItemPdfRaw(vaultId: string, itemId: string, pdfBuffer: Buffer): Promise<ApiResponse<PdfUploadResult>>;
|
|
148
151
|
createItemPdfUploadSession(vaultId: string, itemId: string): Promise<ApiResponse<PdfUploadSession>>;
|
|
149
152
|
completeItemPdfUpload(vaultId: string, itemId: string, body: {
|
|
150
153
|
file_id: string;
|
|
151
154
|
web_view_link?: string | null;
|
|
152
155
|
source_url?: string | null;
|
|
153
156
|
}): Promise<ApiResponse<PdfUploadResult>>;
|
|
154
|
-
|
|
157
|
+
/**
|
|
158
|
+
* The only PDF upload mechanism: create a resumable session, PUT the bytes
|
|
159
|
+
* directly to Google Drive, then record completion. Works at any file
|
|
160
|
+
* size — there is no raw-bytes upload path.
|
|
161
|
+
*/
|
|
155
162
|
uploadItemPdf(vaultId: string, itemId: string, pdfBuffer: Buffer): Promise<ApiResponse<PdfUploadResult>>;
|
|
156
163
|
}
|
|
157
164
|
export interface PdfUploadResult {
|
|
@@ -161,7 +168,8 @@ export interface PdfUploadResult {
|
|
|
161
168
|
fileId?: string;
|
|
162
169
|
folderId?: string;
|
|
163
170
|
folderName?: string;
|
|
164
|
-
|
|
171
|
+
/** URL of the stored copy at `provider` (e.g. Google Drive) — distinct from `pdf_url` (the publisher-hosted PDF link) on Item. */
|
|
172
|
+
driveUrl?: string;
|
|
165
173
|
sourceUrl?: string | null;
|
|
166
174
|
}
|
|
167
175
|
export interface PdfUploadSession {
|
package/dist/client.js
CHANGED
|
@@ -13,8 +13,7 @@ export class RefHubError extends Error {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
export class RefHubClient {
|
|
16
|
-
|
|
17
|
-
baseUrl = 'https://refhub-api.netlify.app/api/v1';
|
|
16
|
+
baseUrl = process.env['REFHUB_API_BASE_URL'] ?? 'https://refhub-api.netlify.app/api/v1';
|
|
18
17
|
headers;
|
|
19
18
|
constructor(apiKey) {
|
|
20
19
|
this.headers = {
|
|
@@ -37,19 +36,6 @@ export class RefHubClient {
|
|
|
37
36
|
}
|
|
38
37
|
return res.json();
|
|
39
38
|
}
|
|
40
|
-
async reqBinary(method, path, body, contentType = 'application/octet-stream') {
|
|
41
|
-
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
42
|
-
method,
|
|
43
|
-
headers: { ...this.headers, 'Content-Type': contentType },
|
|
44
|
-
body: body,
|
|
45
|
-
});
|
|
46
|
-
if (!res.ok) {
|
|
47
|
-
const payload = await res.json().catch(() => ({}));
|
|
48
|
-
const err = (payload['error'] ?? {});
|
|
49
|
-
throw new RefHubError(res.status, String(err['code'] ?? 'unknown_error'), String(err['message'] ?? `HTTP ${res.status}`), String(payload['meta']?.['request_id'] ?? err['request_id'] ?? ''));
|
|
50
|
-
}
|
|
51
|
-
return res.json();
|
|
52
|
-
}
|
|
53
39
|
async reqText(method, path) {
|
|
54
40
|
const res = await fetch(`${this.baseUrl}${path}`, { method, headers: this.headers });
|
|
55
41
|
if (!res.ok) {
|
|
@@ -75,6 +61,10 @@ export class RefHubClient {
|
|
|
75
61
|
deleteVault(vaultId) {
|
|
76
62
|
return this.req('DELETE', `/vaults/${vaultId}`);
|
|
77
63
|
}
|
|
64
|
+
/** Permanently archives the vault. There is no unarchive — this cannot be undone. */
|
|
65
|
+
archiveVault(vaultId) {
|
|
66
|
+
return this.req('POST', `/vaults/${vaultId}/archive`);
|
|
67
|
+
}
|
|
78
68
|
setVaultVisibility(vaultId, body) {
|
|
79
69
|
return this.req('PATCH', `/vaults/${vaultId}/visibility`, body);
|
|
80
70
|
}
|
|
@@ -220,16 +210,18 @@ export class RefHubClient {
|
|
|
220
210
|
semanticScholarPaperList(kind, paperId, limit) {
|
|
221
211
|
return this.req('POST', `/semantic-scholar/${kind}`, { paper_id: paperId, ...(limit !== undefined ? { limit } : {}) });
|
|
222
212
|
}
|
|
223
|
-
uploadItemPdfRaw(vaultId, itemId, pdfBuffer) {
|
|
224
|
-
return this.reqBinary('POST', `/vaults/${encodeURIComponent(vaultId)}/items/${encodeURIComponent(itemId)}/pdf`, pdfBuffer, 'application/pdf');
|
|
225
|
-
}
|
|
226
213
|
createItemPdfUploadSession(vaultId, itemId) {
|
|
227
214
|
return this.req('POST', `/vaults/${encodeURIComponent(vaultId)}/items/${encodeURIComponent(itemId)}/pdf/session`, {});
|
|
228
215
|
}
|
|
229
216
|
completeItemPdfUpload(vaultId, itemId, body) {
|
|
230
217
|
return this.req('POST', `/vaults/${encodeURIComponent(vaultId)}/items/${encodeURIComponent(itemId)}/pdf/complete`, body);
|
|
231
218
|
}
|
|
232
|
-
|
|
219
|
+
/**
|
|
220
|
+
* The only PDF upload mechanism: create a resumable session, PUT the bytes
|
|
221
|
+
* directly to Google Drive, then record completion. Works at any file
|
|
222
|
+
* size — there is no raw-bytes upload path.
|
|
223
|
+
*/
|
|
224
|
+
async uploadItemPdf(vaultId, itemId, pdfBuffer) {
|
|
233
225
|
const session = await this.createItemPdfUploadSession(vaultId, itemId);
|
|
234
226
|
const driveResponse = await fetch(session.data.upload_url, {
|
|
235
227
|
method: 'PUT',
|
|
@@ -252,20 +244,6 @@ export class RefHubClient {
|
|
|
252
244
|
web_view_link: driveUpload.webViewLink ?? null,
|
|
253
245
|
});
|
|
254
246
|
}
|
|
255
|
-
async uploadItemPdf(vaultId, itemId, pdfBuffer) {
|
|
256
|
-
if (pdfBuffer.length > RefHubClient.RAW_PDF_UPLOAD_LIMIT_BYTES) {
|
|
257
|
-
return this.uploadItemPdfResumable(vaultId, itemId, pdfBuffer);
|
|
258
|
-
}
|
|
259
|
-
try {
|
|
260
|
-
return await this.uploadItemPdfRaw(vaultId, itemId, pdfBuffer);
|
|
261
|
-
}
|
|
262
|
-
catch (err) {
|
|
263
|
-
if (err instanceof RefHubError && err.status === 413 && err.code === 'pdf_upload_too_large_for_api') {
|
|
264
|
-
return this.uploadItemPdfResumable(vaultId, itemId, pdfBuffer);
|
|
265
|
-
}
|
|
266
|
-
throw err;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
247
|
}
|
|
270
248
|
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
271
249
|
export function resolveClient(apiKey) {
|
package/dist/commands/items.d.ts
CHANGED
|
@@ -10,16 +10,20 @@ export declare function handleItemAdd(client: RefHubClient, vaultId: string, opt
|
|
|
10
10
|
authors?: string;
|
|
11
11
|
year?: number;
|
|
12
12
|
doi?: string;
|
|
13
|
+
url?: string;
|
|
13
14
|
tags?: string;
|
|
14
15
|
notes?: string;
|
|
16
|
+
pdfUrl?: string;
|
|
15
17
|
}, tableMode: boolean): Promise<void>;
|
|
16
18
|
export declare function handleItemUpdate(client: RefHubClient, vaultId: string, itemId: string, opts: {
|
|
17
19
|
title?: string;
|
|
18
20
|
authors?: string;
|
|
19
21
|
year?: number;
|
|
20
22
|
doi?: string;
|
|
23
|
+
url?: string;
|
|
21
24
|
tags?: string;
|
|
22
25
|
notes?: string;
|
|
26
|
+
pdfUrl?: string;
|
|
23
27
|
}, tableMode: boolean): Promise<void>;
|
|
24
28
|
export declare function handleItemDelete(client: RefHubClient, vaultId: string, itemId: string, confirmed: boolean): Promise<void>;
|
|
25
29
|
export declare function handleItemUpsert(client: RefHubClient, vaultId: string, filePath: string, idempotencyKey: string | undefined, tableMode: boolean): Promise<void>;
|
package/dist/commands/items.js
CHANGED
|
@@ -18,10 +18,14 @@ export async function handleItemAdd(client, vaultId, opts, tableMode) {
|
|
|
18
18
|
item['year'] = opts.year;
|
|
19
19
|
if (opts.doi)
|
|
20
20
|
item['doi'] = opts.doi;
|
|
21
|
+
if (opts.url !== undefined)
|
|
22
|
+
item['url'] = opts.url;
|
|
21
23
|
if (opts.tags)
|
|
22
24
|
item['tag_ids'] = opts.tags.split(',').map((t) => t.trim());
|
|
23
25
|
if (opts.notes !== undefined)
|
|
24
26
|
item['notes'] = opts.notes;
|
|
27
|
+
if (opts.pdfUrl !== undefined)
|
|
28
|
+
item['pdf_url'] = opts.pdfUrl;
|
|
25
29
|
const result = await client.addItems(vaultId, [item]);
|
|
26
30
|
format(result, tableMode, ['id', 'title', 'doi', 'year']);
|
|
27
31
|
}
|
|
@@ -35,8 +39,12 @@ export async function handleItemUpdate(client, vaultId, itemId, opts, tableMode)
|
|
|
35
39
|
body['year'] = opts.year;
|
|
36
40
|
if (opts.doi)
|
|
37
41
|
body['doi'] = opts.doi;
|
|
42
|
+
if (opts.url !== undefined)
|
|
43
|
+
body['url'] = opts.url;
|
|
38
44
|
if (opts.notes !== undefined)
|
|
39
45
|
body['notes'] = opts.notes;
|
|
46
|
+
if (opts.pdfUrl !== undefined)
|
|
47
|
+
body['pdf_url'] = opts.pdfUrl;
|
|
40
48
|
if (opts.tags) {
|
|
41
49
|
process.stderr.write(JSON.stringify({ warning: 'tag_replacement', message: '--tags replaces the full tag set, not an append. Existing tags will be removed.' }) + '\n');
|
|
42
50
|
body['tag_ids'] = opts.tags.split(',').map((t) => t.trim());
|
|
@@ -121,12 +129,14 @@ export function registerItems(program) {
|
|
|
121
129
|
.option('--authors <authors>', 'comma-separated, e.g. "Smith J,Doe A"')
|
|
122
130
|
.option('--year <year>', 'publication year', (v) => parseInt(v, 10))
|
|
123
131
|
.option('--doi <doi>')
|
|
132
|
+
.option('--url <url>', 'publication URL')
|
|
124
133
|
.option('--tags <ids>', 'comma-separated tag IDs')
|
|
125
134
|
.option('--notes <text>', 'free-text notes on the item')
|
|
135
|
+
.option('--pdf-url <url>', "publisher PDF link (the frontend's publisher_pdf field)")
|
|
126
136
|
.action(async (opts, cmd) => {
|
|
127
137
|
const g = cmd.optsWithGlobals();
|
|
128
138
|
const client = resolveClient(g.apiKey);
|
|
129
|
-
await run(() => handleItemAdd(client, opts.vault, { title: opts.title, authors: opts.authors, year: opts.year, doi: opts.doi, tags: opts.tags, notes: opts.notes }, g.table ?? false));
|
|
139
|
+
await run(() => handleItemAdd(client, opts.vault, { title: opts.title, authors: opts.authors, year: opts.year, doi: opts.doi, url: opts.url, tags: opts.tags, notes: opts.notes, pdfUrl: opts.pdfUrl }, g.table ?? false));
|
|
130
140
|
});
|
|
131
141
|
items
|
|
132
142
|
.command('update')
|
|
@@ -137,12 +147,14 @@ export function registerItems(program) {
|
|
|
137
147
|
.option('--authors <authors>')
|
|
138
148
|
.option('--year <year>', '', (v) => parseInt(v, 10))
|
|
139
149
|
.option('--doi <doi>')
|
|
150
|
+
.option('--url <url>', 'publication URL')
|
|
140
151
|
.option('--tags <ids>', 'comma-separated tag IDs — REPLACES the full tag set')
|
|
141
152
|
.option('--notes <text>', 'free-text notes on the item')
|
|
153
|
+
.option('--pdf-url <url>', "publisher PDF link (the frontend's publisher_pdf field)")
|
|
142
154
|
.action(async (itemId, opts, cmd) => {
|
|
143
155
|
const g = cmd.optsWithGlobals();
|
|
144
156
|
const client = resolveClient(g.apiKey);
|
|
145
|
-
await run(() => handleItemUpdate(client, opts.vault, itemId, { title: opts.title, authors: opts.authors, year: opts.year, doi: opts.doi, tags: opts.tags, notes: opts.notes }, g.table ?? false));
|
|
157
|
+
await run(() => handleItemUpdate(client, opts.vault, itemId, { title: opts.title, authors: opts.authors, year: opts.year, doi: opts.doi, url: opts.url, tags: opts.tags, notes: opts.notes, pdfUrl: opts.pdfUrl }, g.table ?? false));
|
|
146
158
|
});
|
|
147
159
|
items
|
|
148
160
|
.command('delete')
|
|
@@ -18,6 +18,7 @@ export declare function handleVaultUpdate(client: RefHubClient, vaultId: string,
|
|
|
18
18
|
abstract?: string;
|
|
19
19
|
}, tableMode: boolean): Promise<void>;
|
|
20
20
|
export declare function handleVaultDelete(client: RefHubClient, vaultId: string, confirmed: boolean): Promise<void>;
|
|
21
|
+
export declare function handleVaultArchive(client: RefHubClient, vaultId: string, confirmed: boolean, tableMode: boolean): Promise<void>;
|
|
21
22
|
export declare function handleVaultVisibility(client: RefHubClient, vaultId: string, opts: {
|
|
22
23
|
visibility: string;
|
|
23
24
|
slug?: string;
|
package/dist/commands/vaults.js
CHANGED
|
@@ -2,7 +2,7 @@ import { resolveClient, run } from '../client.js';
|
|
|
2
2
|
import { format } from '../format.js';
|
|
3
3
|
export async function handleVaultsList(client, tableMode) {
|
|
4
4
|
const result = await client.listVaults();
|
|
5
|
-
format(result, tableMode, ['id', 'name', 'visibility', 'item_count', 'updated_at']);
|
|
5
|
+
format(result, tableMode, ['id', 'name', 'visibility', 'archived_at', 'item_count', 'updated_at']);
|
|
6
6
|
}
|
|
7
7
|
export async function handleVaultGet(client, vaultId, tableMode) {
|
|
8
8
|
const result = await client.getVault(vaultId);
|
|
@@ -46,6 +46,14 @@ export async function handleVaultDelete(client, vaultId, confirmed) {
|
|
|
46
46
|
const result = await client.deleteVault(vaultId);
|
|
47
47
|
format(result, false);
|
|
48
48
|
}
|
|
49
|
+
export async function handleVaultArchive(client, vaultId, confirmed, tableMode) {
|
|
50
|
+
if (!confirmed) {
|
|
51
|
+
process.stderr.write(JSON.stringify({ error: { code: 'confirm_required', message: 'Pass --confirm to acknowledge this is permanent: archiving makes the vault read-only forever (items/tags/relations/shares) and cannot be undone (no unarchive).' } }) + '\n');
|
|
52
|
+
process.exit(2);
|
|
53
|
+
}
|
|
54
|
+
const result = await client.archiveVault(vaultId);
|
|
55
|
+
format(result, tableMode);
|
|
56
|
+
}
|
|
49
57
|
export async function handleVaultVisibility(client, vaultId, opts, tableMode) {
|
|
50
58
|
const body = { visibility: opts.visibility };
|
|
51
59
|
if (opts.slug)
|
|
@@ -126,6 +134,16 @@ export function registerVaults(program) {
|
|
|
126
134
|
const client = resolveClient(g.apiKey);
|
|
127
135
|
await run(() => handleVaultDelete(client, vaultId, opts.confirm ?? false));
|
|
128
136
|
});
|
|
137
|
+
vaults
|
|
138
|
+
.command('archive')
|
|
139
|
+
.argument('<vaultId>')
|
|
140
|
+
.description('Permanently archive a vault (read-only forever, no unarchive)')
|
|
141
|
+
.option('--confirm', 'required: acknowledge this cannot be undone')
|
|
142
|
+
.action(async (vaultId, opts, cmd) => {
|
|
143
|
+
const g = cmd.optsWithGlobals();
|
|
144
|
+
const client = resolveClient(g.apiKey);
|
|
145
|
+
await run(() => handleVaultArchive(client, vaultId, opts.confirm ?? false, g.table ?? false));
|
|
146
|
+
});
|
|
129
147
|
vaults
|
|
130
148
|
.command('visibility')
|
|
131
149
|
.argument('<vaultId>')
|
package/dist/index.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface Vault {
|
|
|
11
11
|
item_count: number;
|
|
12
12
|
created_at: string;
|
|
13
13
|
updated_at: string;
|
|
14
|
+
/** Set once, permanently, when the vault is archived. No unarchive path exists. */
|
|
15
|
+
archived_at: string | null;
|
|
14
16
|
}
|
|
15
17
|
export interface Item {
|
|
16
18
|
id: string;
|
|
@@ -20,9 +22,12 @@ export interface Item {
|
|
|
20
22
|
authors?: string[];
|
|
21
23
|
year?: number;
|
|
22
24
|
doi?: string;
|
|
25
|
+
url?: string;
|
|
23
26
|
bibtex_key?: string;
|
|
24
27
|
abstract?: string;
|
|
25
28
|
notes?: string;
|
|
29
|
+
pdf_url?: string;
|
|
30
|
+
drive_pdf_url?: string | null;
|
|
26
31
|
tag_ids: string[];
|
|
27
32
|
version: number;
|
|
28
33
|
created_at: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refhub/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "refhub CLI execution layer for agent skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
"url": "https://github.com/refhub-io/refhub-cli/issues"
|
|
13
13
|
},
|
|
14
14
|
"engines": { "node": ">=18" },
|
|
15
|
-
"bin": { "refhub": "
|
|
15
|
+
"bin": { "refhub": "bin/refhub.js" },
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "tsc
|
|
17
|
+
"build": "tsc",
|
|
18
18
|
"test": "vitest run",
|
|
19
19
|
"test:watch": "vitest",
|
|
20
20
|
"smoke": "tsx scripts/smoke.ts",
|
|
21
21
|
"dev": "tsx src/index.ts"
|
|
22
22
|
},
|
|
23
|
-
"files": ["dist"],
|
|
23
|
+
"files": ["dist", "bin"],
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|