@refhub/cli 1.8.0 → 1.8.1
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.js
CHANGED
|
@@ -190,7 +190,7 @@ export class RefHubClient {
|
|
|
190
190
|
if (params.page !== undefined)
|
|
191
191
|
q.set('page', String(params.page));
|
|
192
192
|
if (params.limit !== undefined)
|
|
193
|
-
q.set('
|
|
193
|
+
q.set('per_page', String(params.limit));
|
|
194
194
|
const qs = q.toString() ? `?${q}` : '';
|
|
195
195
|
return this.req('GET', `/inbox${qs}`);
|
|
196
196
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Command } from 'commander';
|
|
2
2
|
import { RefHubClient } from '../client.js';
|
|
3
3
|
export declare function handleRelationsList(client: RefHubClient, vaultId: string, type: string | undefined, tableMode: boolean): Promise<void>;
|
|
4
4
|
export declare function handleRelationCreate(client: RefHubClient, vaultId: string, opts: {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
// src/commands/relations.ts
|
|
2
|
+
import { Option } from 'commander';
|
|
1
3
|
import { resolveClient, run } from '../client.js';
|
|
2
4
|
import { format } from '../format.js';
|
|
3
5
|
import { registerRelationsScan } from './relationsScan.js';
|
|
4
|
-
|
|
6
|
+
import { RELATION_TYPES } from '../types.js';
|
|
7
|
+
// commander refuses any other value, and lists these in its error and in --help.
|
|
8
|
+
const typeOption = () => new Option('--type <type>', 'relation type').choices(RELATION_TYPES);
|
|
5
9
|
export async function handleRelationsList(client, vaultId, type, tableMode) {
|
|
6
10
|
const result = await client.listRelations(vaultId, type);
|
|
7
11
|
format(result, tableMode, ['id', 'publication_id', 'related_publication_id', 'relation_type']);
|
|
@@ -28,7 +32,7 @@ export function registerRelations(program) {
|
|
|
28
32
|
.command('list')
|
|
29
33
|
.description('List relations in a vault')
|
|
30
34
|
.requiredOption('--vault <id>')
|
|
31
|
-
.
|
|
35
|
+
.addOption(typeOption())
|
|
32
36
|
.action(async (opts, cmd) => {
|
|
33
37
|
const g = cmd.optsWithGlobals();
|
|
34
38
|
const client = resolveClient(g.apiKey);
|
|
@@ -40,7 +44,7 @@ export function registerRelations(program) {
|
|
|
40
44
|
.requiredOption('--vault <id>')
|
|
41
45
|
.requiredOption('--pub <publicationId>')
|
|
42
46
|
.requiredOption('--related <publicationId>')
|
|
43
|
-
.
|
|
47
|
+
.addOption(typeOption())
|
|
44
48
|
.action(async (opts, cmd) => {
|
|
45
49
|
const g = cmd.optsWithGlobals();
|
|
46
50
|
const client = resolveClient(g.apiKey);
|
|
@@ -51,7 +55,7 @@ export function registerRelations(program) {
|
|
|
51
55
|
.argument('<relationId>')
|
|
52
56
|
.description('Update a relation type')
|
|
53
57
|
.requiredOption('--vault <id>')
|
|
54
|
-
.
|
|
58
|
+
.addOption(typeOption().makeOptionMandatory())
|
|
55
59
|
.action(async (relationId, opts, cmd) => {
|
|
56
60
|
const g = cmd.optsWithGlobals();
|
|
57
61
|
const client = resolveClient(g.apiKey);
|
|
@@ -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 };
|
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'];
|