@refhub/cli 1.8.0 → 1.9.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/dist/client.d.ts +16 -0
- package/dist/client.js +104 -60
- package/dist/commands/audit.js +5 -6
- package/dist/commands/discover.js +19 -25
- package/dist/commands/enrich.js +35 -38
- package/dist/commands/export.js +6 -8
- package/dist/commands/import.js +16 -22
- package/dist/commands/inbox.js +43 -56
- package/dist/commands/items.js +48 -64
- package/dist/commands/pdf.js +6 -8
- package/dist/commands/relations.d.ts +1 -1
- package/dist/commands/relations.js +25 -25
- package/dist/commands/relationsScan.js +47 -51
- package/dist/commands/sections.js +17 -21
- package/dist/commands/tags.js +25 -31
- package/dist/commands/vaults.js +47 -60
- package/dist/format.js +15 -0
- package/dist/types.d.ts +8 -6
- package/dist/types.js +2 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UsageError, action } from '../client.js';
|
|
2
2
|
function normalizeDoi(doi) {
|
|
3
3
|
return doi.trim().toLowerCase().replace(/^https?:\/\/(dx\.)?doi\.org\//, '');
|
|
4
4
|
}
|
|
@@ -56,7 +56,7 @@ export async function scanItemRelations(item, client, vaultId, allItems, existin
|
|
|
56
56
|
if (!opts.dryRun) {
|
|
57
57
|
await client.createRelation(vaultId, { publication_id: item.id, related_publication_id: matched.id, relation_type: 'cites' });
|
|
58
58
|
}
|
|
59
|
-
existingRelations.push({ id: 'pending',
|
|
59
|
+
existingRelations.push({ id: 'pending', publication_id: item.id, related_publication_id: matched.id, relation_type: 'cites', created_at: '' });
|
|
60
60
|
created++;
|
|
61
61
|
}
|
|
62
62
|
// citations: the matched paper cites this item
|
|
@@ -72,7 +72,7 @@ export async function scanItemRelations(item, client, vaultId, allItems, existin
|
|
|
72
72
|
if (!opts.dryRun) {
|
|
73
73
|
await client.createRelation(vaultId, { publication_id: matched.id, related_publication_id: item.id, relation_type: 'cites' });
|
|
74
74
|
}
|
|
75
|
-
existingRelations.push({ id: 'pending',
|
|
75
|
+
existingRelations.push({ id: 'pending', publication_id: matched.id, related_publication_id: item.id, relation_type: 'cites', created_at: '' });
|
|
76
76
|
created++;
|
|
77
77
|
}
|
|
78
78
|
return { outcome: suggested === 0 ? 'no_matches' : 'scanned', suggested, created, skippedDuplicate };
|
|
@@ -85,53 +85,49 @@ export function registerRelationsScan(relations) {
|
|
|
85
85
|
.option('--item <itemId>', 'scan a single item instead of the whole vault')
|
|
86
86
|
.option('--dry-run', 'show what would be created without writing')
|
|
87
87
|
.option('--limit <n>', 'references/citations fetched per item from Semantic Scholar, 1-25', (v) => parseInt(v, 10))
|
|
88
|
-
.action(async (opts,
|
|
89
|
-
const
|
|
90
|
-
const client = resolveClient(g.apiKey);
|
|
88
|
+
.action(action(async ({ opts, g, getClient }) => {
|
|
89
|
+
const client = getClient();
|
|
91
90
|
const dryRun = opts.dryRun ?? false;
|
|
92
|
-
await
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}, null, 2) + '\n');
|
|
135
|
-
});
|
|
136
|
-
});
|
|
91
|
+
const vaultResult = await client.getVault(opts.vault);
|
|
92
|
+
const allItems = vaultResult.data.items;
|
|
93
|
+
const existingRelations = [...vaultResult.data.relations];
|
|
94
|
+
const targets = opts.item ? allItems.filter((i) => i.id === opts.item) : allItems;
|
|
95
|
+
if (opts.item && targets.length === 0) {
|
|
96
|
+
throw new UsageError('item_not_found', `Item ${opts.item} not found in vault ${opts.vault}.`);
|
|
97
|
+
}
|
|
98
|
+
const withDoi = targets.filter((i) => i.doi);
|
|
99
|
+
if (withDoi.length === 0) {
|
|
100
|
+
process.stdout.write(JSON.stringify({ data: { dry_run: dryRun, scanned: 0, suggested: 0, created: 0, skipped_duplicate: 0, no_doi: targets.length, message: 'No items with a DOI to scan.' } }, null, 2) + '\n');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
let suggested = 0;
|
|
104
|
+
let created = 0;
|
|
105
|
+
let skippedDuplicate = 0;
|
|
106
|
+
let noMatches = 0;
|
|
107
|
+
let lookupFailed = 0;
|
|
108
|
+
for (const item of withDoi) {
|
|
109
|
+
const result = await scanItemRelations(item, client, opts.vault, allItems, existingRelations, { dryRun, limit: opts.limit });
|
|
110
|
+
suggested += result.suggested;
|
|
111
|
+
created += result.created;
|
|
112
|
+
skippedDuplicate += result.skippedDuplicate;
|
|
113
|
+
if (result.outcome === 'no_matches')
|
|
114
|
+
noMatches++;
|
|
115
|
+
if (result.outcome === 'lookup_failed')
|
|
116
|
+
lookupFailed++;
|
|
117
|
+
// pace Semantic Scholar calls — each item makes a lookup + references + citations request
|
|
118
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
119
|
+
}
|
|
120
|
+
process.stdout.write(JSON.stringify({
|
|
121
|
+
data: {
|
|
122
|
+
dry_run: dryRun,
|
|
123
|
+
scanned: withDoi.length,
|
|
124
|
+
no_doi: targets.length - withDoi.length,
|
|
125
|
+
lookup_failed: lookupFailed,
|
|
126
|
+
no_matches: noMatches,
|
|
127
|
+
suggested,
|
|
128
|
+
created,
|
|
129
|
+
skipped_duplicate: skippedDuplicate,
|
|
130
|
+
},
|
|
131
|
+
}, null, 2) + '\n');
|
|
132
|
+
}));
|
|
137
133
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { action } from '../client.js';
|
|
2
2
|
import { format } from '../format.js';
|
|
3
3
|
export async function handleSectionsList(client, vaultId, tableMode) {
|
|
4
4
|
const result = await client.listSections(vaultId);
|
|
@@ -34,11 +34,10 @@ export function registerSections(program) {
|
|
|
34
34
|
.command('list')
|
|
35
35
|
.description('List sections in a vault')
|
|
36
36
|
.requiredOption('--vault <id>')
|
|
37
|
-
.action(async (opts,
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
37
|
+
.action(action(async ({ opts, g, getClient }) => {
|
|
38
|
+
const client = getClient();
|
|
39
|
+
await handleSectionsList(client, opts.vault, g.table ?? false);
|
|
40
|
+
}));
|
|
42
41
|
sections
|
|
43
42
|
.command('create')
|
|
44
43
|
.description('Create a section (owner-only)')
|
|
@@ -46,11 +45,10 @@ export function registerSections(program) {
|
|
|
46
45
|
.requiredOption('--name <name>')
|
|
47
46
|
.option('--description <text>')
|
|
48
47
|
.option('--position <n>', 'sort position, defaults to 0', (v) => parseInt(v, 10))
|
|
49
|
-
.action(async (opts,
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
48
|
+
.action(action(async ({ opts, g, getClient }) => {
|
|
49
|
+
const client = getClient();
|
|
50
|
+
await handleSectionCreate(client, opts.vault, { name: opts.name, description: opts.description, position: opts.position }, g.table ?? false);
|
|
51
|
+
}));
|
|
54
52
|
sections
|
|
55
53
|
.command('update')
|
|
56
54
|
.argument('<sectionId>')
|
|
@@ -59,19 +57,17 @@ export function registerSections(program) {
|
|
|
59
57
|
.option('--name <name>')
|
|
60
58
|
.option('--description <text>')
|
|
61
59
|
.option('--position <n>', '', (v) => parseInt(v, 10))
|
|
62
|
-
.action(async (sectionId, opts,
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
60
|
+
.action(action(async ({ args: [sectionId], opts, g, getClient }) => {
|
|
61
|
+
const client = getClient();
|
|
62
|
+
await handleSectionUpdate(client, opts.vault, sectionId, { name: opts.name, description: opts.description, position: opts.position }, g.table ?? false);
|
|
63
|
+
}));
|
|
67
64
|
sections
|
|
68
65
|
.command('delete')
|
|
69
66
|
.argument('<sectionId>')
|
|
70
67
|
.description('Delete a section (owner-only) — items in it are unfiled, not deleted')
|
|
71
68
|
.requiredOption('--vault <id>')
|
|
72
|
-
.action(async (sectionId, opts,
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
69
|
+
.action(action(async ({ args: [sectionId], opts, g, getClient }) => {
|
|
70
|
+
const client = getClient();
|
|
71
|
+
await handleSectionDelete(client, opts.vault, sectionId);
|
|
72
|
+
}));
|
|
77
73
|
}
|
package/dist/commands/tags.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { action } from '../client.js';
|
|
2
2
|
import { format } from '../format.js';
|
|
3
3
|
export async function handleTagsList(client, vaultId, tableMode) {
|
|
4
4
|
const result = await client.listTags(vaultId);
|
|
@@ -44,11 +44,10 @@ export function registerTags(program) {
|
|
|
44
44
|
.command('list')
|
|
45
45
|
.description('List tags in a vault')
|
|
46
46
|
.requiredOption('--vault <id>')
|
|
47
|
-
.action(async (opts,
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
47
|
+
.action(action(async ({ opts, g, getClient }) => {
|
|
48
|
+
const client = getClient();
|
|
49
|
+
await handleTagsList(client, opts.vault, g.table ?? false);
|
|
50
|
+
}));
|
|
52
51
|
tags
|
|
53
52
|
.command('create')
|
|
54
53
|
.description('Create a tag')
|
|
@@ -56,11 +55,10 @@ export function registerTags(program) {
|
|
|
56
55
|
.requiredOption('--name <name>')
|
|
57
56
|
.option('--color <color>')
|
|
58
57
|
.option('--parent <tagId>', 'parent tag ID')
|
|
59
|
-
.action(async (opts,
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
58
|
+
.action(action(async ({ opts, g, getClient }) => {
|
|
59
|
+
const client = getClient();
|
|
60
|
+
await handleTagCreate(client, opts.vault, { name: opts.name, color: opts.color, parent: opts.parent }, g.table ?? false);
|
|
61
|
+
}));
|
|
64
62
|
tags
|
|
65
63
|
.command('update')
|
|
66
64
|
.argument('<tagId>')
|
|
@@ -69,41 +67,37 @@ export function registerTags(program) {
|
|
|
69
67
|
.option('--name <name>')
|
|
70
68
|
.option('--color <color>')
|
|
71
69
|
.option('--parent <tagId>')
|
|
72
|
-
.action(async (tagId, opts,
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
70
|
+
.action(action(async ({ args: [tagId], opts, g, getClient }) => {
|
|
71
|
+
const client = getClient();
|
|
72
|
+
await handleTagUpdate(client, opts.vault, tagId, { name: opts.name, color: opts.color, parent: opts.parent }, g.table ?? false);
|
|
73
|
+
}));
|
|
77
74
|
tags
|
|
78
75
|
.command('delete')
|
|
79
76
|
.argument('<tagId>')
|
|
80
77
|
.description('Delete a tag')
|
|
81
78
|
.requiredOption('--vault <id>')
|
|
82
|
-
.action(async (tagId, opts,
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
79
|
+
.action(action(async ({ args: [tagId], opts, g, getClient }) => {
|
|
80
|
+
const client = getClient();
|
|
81
|
+
await handleTagDelete(client, opts.vault, tagId);
|
|
82
|
+
}));
|
|
87
83
|
tags
|
|
88
84
|
.command('attach')
|
|
89
85
|
.description('Attach tags to an item (idempotent)')
|
|
90
86
|
.requiredOption('--vault <id>')
|
|
91
87
|
.requiredOption('--item <itemId>')
|
|
92
88
|
.requiredOption('--tags <ids>', 'comma-separated tag IDs')
|
|
93
|
-
.action(async (opts,
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
89
|
+
.action(action(async ({ opts, g, getClient }) => {
|
|
90
|
+
const client = getClient();
|
|
91
|
+
await handleTagAttach(client, opts.vault, opts.item, opts.tags);
|
|
92
|
+
}));
|
|
98
93
|
tags
|
|
99
94
|
.command('detach')
|
|
100
95
|
.description('Detach tags from an item')
|
|
101
96
|
.requiredOption('--vault <id>')
|
|
102
97
|
.requiredOption('--item <itemId>')
|
|
103
98
|
.requiredOption('--tags <ids>', 'comma-separated tag IDs')
|
|
104
|
-
.action(async (opts,
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
99
|
+
.action(action(async ({ opts, g, getClient }) => {
|
|
100
|
+
const client = getClient();
|
|
101
|
+
await handleTagDetach(client, opts.vault, opts.item, opts.tags);
|
|
102
|
+
}));
|
|
109
103
|
}
|
package/dist/commands/vaults.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UsageError, action } 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();
|
|
@@ -40,16 +40,14 @@ export async function handleVaultUpdate(client, vaultId, opts, tableMode) {
|
|
|
40
40
|
}
|
|
41
41
|
export async function handleVaultDelete(client, vaultId, confirmed) {
|
|
42
42
|
if (!confirmed) {
|
|
43
|
-
|
|
44
|
-
process.exit(2);
|
|
43
|
+
throw new UsageError('confirm_required', 'Pass --confirm to acknowledge this is a hard delete with no undo.');
|
|
45
44
|
}
|
|
46
45
|
const result = await client.deleteVault(vaultId);
|
|
47
46
|
format(result, false);
|
|
48
47
|
}
|
|
49
48
|
export async function handleVaultArchive(client, vaultId, confirmed, tableMode) {
|
|
50
49
|
if (!confirmed) {
|
|
51
|
-
|
|
52
|
-
process.exit(2);
|
|
50
|
+
throw new UsageError('confirm_required', 'Pass --confirm to acknowledge this is permanent: archiving makes the vault read-only forever (items/tags/relations/shares) and cannot be undone (no unarchive).');
|
|
53
51
|
}
|
|
54
52
|
const result = await client.archiveVault(vaultId);
|
|
55
53
|
format(result, tableMode);
|
|
@@ -82,20 +80,18 @@ export function registerVaults(program) {
|
|
|
82
80
|
vaults
|
|
83
81
|
.command('list')
|
|
84
82
|
.description('List all accessible vaults')
|
|
85
|
-
.action(async (opts,
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
83
|
+
.action(action(async ({ opts, g, getClient }) => {
|
|
84
|
+
const client = getClient();
|
|
85
|
+
await handleVaultsList(client, g.table ?? false);
|
|
86
|
+
}));
|
|
90
87
|
vaults
|
|
91
88
|
.command('get')
|
|
92
89
|
.argument('<vaultId>')
|
|
93
90
|
.description('Read one vault with full contents')
|
|
94
|
-
.action(async (vaultId, opts,
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
});
|
|
91
|
+
.action(action(async ({ args: [vaultId], opts, g, getClient }) => {
|
|
92
|
+
const client = getClient();
|
|
93
|
+
await handleVaultGet(client, vaultId, g.table ?? false);
|
|
94
|
+
}));
|
|
99
95
|
vaults
|
|
100
96
|
.command('create')
|
|
101
97
|
.description('Create a vault')
|
|
@@ -105,11 +101,10 @@ export function registerVaults(program) {
|
|
|
105
101
|
.option('--visibility <visibility>', 'private|protected|public')
|
|
106
102
|
.option('--category <category>')
|
|
107
103
|
.option('--abstract <abstract>')
|
|
108
|
-
.action(async (opts,
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
104
|
+
.action(action(async ({ opts, g, getClient }) => {
|
|
105
|
+
const client = getClient();
|
|
106
|
+
await handleVaultCreate(client, opts, g.table ?? false);
|
|
107
|
+
}));
|
|
113
108
|
vaults
|
|
114
109
|
.command('update')
|
|
115
110
|
.argument('<vaultId>')
|
|
@@ -119,52 +114,47 @@ export function registerVaults(program) {
|
|
|
119
114
|
.option('--color <color>')
|
|
120
115
|
.option('--category <category>')
|
|
121
116
|
.option('--abstract <abstract>')
|
|
122
|
-
.action(async (vaultId, opts,
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
});
|
|
117
|
+
.action(action(async ({ args: [vaultId], opts, g, getClient }) => {
|
|
118
|
+
const client = getClient();
|
|
119
|
+
await handleVaultUpdate(client, vaultId, opts, g.table ?? false);
|
|
120
|
+
}));
|
|
127
121
|
vaults
|
|
128
122
|
.command('delete')
|
|
129
123
|
.argument('<vaultId>')
|
|
130
124
|
.description('Delete a vault (hard delete, no undo)')
|
|
131
125
|
.option('--confirm', 'required: acknowledge this is a permanent deletion')
|
|
132
|
-
.action(async (vaultId, opts,
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
126
|
+
.action(action(async ({ args: [vaultId], opts, g, getClient }) => {
|
|
127
|
+
const client = getClient();
|
|
128
|
+
await handleVaultDelete(client, vaultId, opts.confirm ?? false);
|
|
129
|
+
}));
|
|
137
130
|
vaults
|
|
138
131
|
.command('archive')
|
|
139
132
|
.argument('<vaultId>')
|
|
140
133
|
.description('Permanently archive a vault (read-only forever, no unarchive)')
|
|
141
134
|
.option('--confirm', 'required: acknowledge this cannot be undone')
|
|
142
|
-
.action(async (vaultId, opts,
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
});
|
|
135
|
+
.action(action(async ({ args: [vaultId], opts, g, getClient }) => {
|
|
136
|
+
const client = getClient();
|
|
137
|
+
await handleVaultArchive(client, vaultId, opts.confirm ?? false, g.table ?? false);
|
|
138
|
+
}));
|
|
147
139
|
vaults
|
|
148
140
|
.command('visibility')
|
|
149
141
|
.argument('<vaultId>')
|
|
150
142
|
.description('Set vault visibility')
|
|
151
143
|
.requiredOption('--visibility <visibility>', 'private|protected|public')
|
|
152
144
|
.option('--slug <slug>', 'public_slug for public vaults')
|
|
153
|
-
.action(async (vaultId, opts,
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
145
|
+
.action(action(async ({ args: [vaultId], opts, g, getClient }) => {
|
|
146
|
+
const client = getClient();
|
|
147
|
+
await handleVaultVisibility(client, vaultId, { visibility: opts.visibility, slug: opts.slug }, g.table ?? false);
|
|
148
|
+
}));
|
|
158
149
|
const shares = vaults.command('shares').description('Manage vault collaborators');
|
|
159
150
|
shares
|
|
160
151
|
.command('list')
|
|
161
152
|
.argument('<vaultId>')
|
|
162
153
|
.description('List vault collaborators')
|
|
163
|
-
.action(async (vaultId, opts,
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
154
|
+
.action(action(async ({ args: [vaultId], opts, g, getClient }) => {
|
|
155
|
+
const client = getClient();
|
|
156
|
+
await handleSharesList(client, vaultId, g.table ?? false);
|
|
157
|
+
}));
|
|
168
158
|
shares
|
|
169
159
|
.command('add')
|
|
170
160
|
.argument('<vaultId>')
|
|
@@ -172,30 +162,27 @@ export function registerVaults(program) {
|
|
|
172
162
|
.requiredOption('--email <email>')
|
|
173
163
|
.requiredOption('--role <role>', 'viewer|editor')
|
|
174
164
|
.option('--name <name>')
|
|
175
|
-
.action(async (vaultId, opts,
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
});
|
|
165
|
+
.action(action(async ({ args: [vaultId], opts, g, getClient }) => {
|
|
166
|
+
const client = getClient();
|
|
167
|
+
await handleShareAdd(client, vaultId, { email: opts.email, role: opts.role, name: opts.name }, g.table ?? false);
|
|
168
|
+
}));
|
|
180
169
|
shares
|
|
181
170
|
.command('update')
|
|
182
171
|
.argument('<vaultId>')
|
|
183
172
|
.argument('<shareId>')
|
|
184
173
|
.description('Update a collaborator role')
|
|
185
174
|
.requiredOption('--role <role>', 'viewer|editor')
|
|
186
|
-
.action(async (vaultId, shareId, opts,
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
});
|
|
175
|
+
.action(action(async ({ args: [vaultId, shareId], opts, g, getClient }) => {
|
|
176
|
+
const client = getClient();
|
|
177
|
+
await handleShareUpdate(client, vaultId, shareId, opts.role, g.table ?? false);
|
|
178
|
+
}));
|
|
191
179
|
shares
|
|
192
180
|
.command('remove')
|
|
193
181
|
.argument('<vaultId>')
|
|
194
182
|
.argument('<shareId>')
|
|
195
183
|
.description('Remove a collaborator')
|
|
196
|
-
.action(async (vaultId, shareId, opts,
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
});
|
|
184
|
+
.action(action(async ({ args: [vaultId, shareId], opts, g, getClient }) => {
|
|
185
|
+
const client = getClient();
|
|
186
|
+
await handleShareRemove(client, vaultId, shareId);
|
|
187
|
+
}));
|
|
201
188
|
}
|
package/dist/format.js
CHANGED
|
@@ -7,6 +7,15 @@ export function format(response, tableMode, columns) {
|
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
const data = response?.data;
|
|
10
|
+
// One record: a key/value table, one row per field.
|
|
11
|
+
if (data !== null && typeof data === 'object' && !Array.isArray(data)) {
|
|
12
|
+
const table = new Table();
|
|
13
|
+
for (const [key, value] of Object.entries(data)) {
|
|
14
|
+
table.push({ [chalk.cyan(key)]: cell(value) });
|
|
15
|
+
}
|
|
16
|
+
process.stdout.write(table.toString() + '\n');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
10
19
|
if (!Array.isArray(data) || data.length === 0) {
|
|
11
20
|
process.stdout.write(JSON.stringify(response, null, 2) + '\n');
|
|
12
21
|
return;
|
|
@@ -20,3 +29,9 @@ export function format(response, tableMode, columns) {
|
|
|
20
29
|
}
|
|
21
30
|
process.stdout.write(table.toString() + '\n');
|
|
22
31
|
}
|
|
32
|
+
/** A value as table text: empty for null, JSON for arrays and objects. */
|
|
33
|
+
function cell(value) {
|
|
34
|
+
if (value === null || value === undefined)
|
|
35
|
+
return '';
|
|
36
|
+
return typeof value === 'object' ? JSON.stringify(value) : String(value);
|
|
37
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/** The relation types the API accepts, in the order help text lists them (refhub-io/.netlify#48). */
|
|
2
|
+
export declare const RELATION_TYPES: readonly ["cites", "extends", "builds_on", "contradicts", "reviews", "related"];
|
|
3
|
+
export type RelationType = (typeof RELATION_TYPES)[number];
|
|
2
4
|
export interface Vault {
|
|
3
5
|
id: string;
|
|
4
6
|
name: string;
|
|
@@ -46,23 +48,23 @@ export interface Section {
|
|
|
46
48
|
created_at: string;
|
|
47
49
|
updated_at: string;
|
|
48
50
|
}
|
|
51
|
+
/** As the API returns it: tags carry no vault id or update time. */
|
|
49
52
|
export interface Tag {
|
|
50
53
|
id: string;
|
|
51
|
-
vault_id: string;
|
|
52
54
|
name: string;
|
|
53
55
|
color?: string;
|
|
54
|
-
parent_id?: string;
|
|
56
|
+
parent_id?: string | null;
|
|
57
|
+
depth?: number;
|
|
55
58
|
created_at: string;
|
|
56
|
-
updated_at: string;
|
|
57
59
|
}
|
|
60
|
+
/** As the API returns it: a relation belongs to its papers, not to a vault, and isn't updated in place. */
|
|
58
61
|
export interface Relation {
|
|
59
62
|
id: string;
|
|
60
|
-
vault_id: string;
|
|
61
63
|
publication_id: string;
|
|
62
64
|
related_publication_id: string;
|
|
63
65
|
relation_type: RelationType;
|
|
64
66
|
created_at: string;
|
|
65
|
-
|
|
67
|
+
created_by?: string | null;
|
|
66
68
|
}
|
|
67
69
|
export interface Share {
|
|
68
70
|
id: string;
|
package/dist/types.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/** The relation types the API accepts, in the order help text lists them (refhub-io/.netlify#48). */
|
|
2
|
+
export const RELATION_TYPES = ['cites', 'extends', 'builds_on', 'contradicts', 'reviews', 'related'];
|