@verbatims/cli 0.1.17 → 1.0.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 +5 -1
- package/package.json +2 -2
- package/src/commands/quotes.ts +15 -15
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
CLI for the [Verbatims](https://verbatims.cc) quotes API.
|
|
4
4
|
|
|
5
|
+
Version 1 uses normalized provenance options for quote creation and updates.
|
|
6
|
+
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
@@ -30,7 +32,9 @@ verbatims quotes sources list 123
|
|
|
30
32
|
verbatims quotes sources create 123 --source-type book --source-url https://example.com/edition --status externally_verified
|
|
31
33
|
|
|
32
34
|
# Create a quote with a source
|
|
33
|
-
verbatims quotes create --source-type book --source-url https://example.com/edition
|
|
35
|
+
verbatims quotes create --provenance-source-type book --provenance-source-url https://example.com/edition
|
|
36
|
+
|
|
37
|
+
Use the `--provenance-*` options for primary provenance. The dedicated `quotes attributions` and `quotes sources` commands manage secondary provenance.
|
|
34
38
|
|
|
35
39
|
# Browse interactively
|
|
36
40
|
verbatims quotes browse
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbatims/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "CLI for the Verbatims quotes API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"typecheck": "tsc --noEmit"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@verbatims/sdk": "^
|
|
19
|
+
"@verbatims/sdk": "^2.0.0",
|
|
20
20
|
"@clack/prompts": "^0.10.1",
|
|
21
21
|
"chalk": "^5.4.1",
|
|
22
22
|
"commander": "^13.1.0",
|
package/src/commands/quotes.ts
CHANGED
|
@@ -66,10 +66,10 @@ export function registerQuotesCommand(program: Command) {
|
|
|
66
66
|
.description('Create a quote')
|
|
67
67
|
.option('--name <text>', 'Quote text')
|
|
68
68
|
.option('--language <lang>', 'Language')
|
|
69
|
-
.option('--author-id <id>', '
|
|
70
|
-
.option('--reference-id <id>', '
|
|
71
|
-
.option('--source-type <type>', '
|
|
72
|
-
.option('--source-url <url>', '
|
|
69
|
+
.option('--provenance-author-id <id>', 'Primary provenance author ID')
|
|
70
|
+
.option('--provenance-reference-id <id>', 'Primary provenance reference ID')
|
|
71
|
+
.option('--provenance-source-type <type>', 'Primary provenance source type')
|
|
72
|
+
.option('--provenance-source-url <url>', 'Primary provenance source URL')
|
|
73
73
|
.action(async (options: Record<string, string>) => {
|
|
74
74
|
const client = await getClient()
|
|
75
75
|
const format = getFormat(program)
|
|
@@ -80,8 +80,8 @@ export function registerQuotesCommand(program: Command) {
|
|
|
80
80
|
const language = options.language ?? await text({ message: 'Language', initialValue: 'fr' })
|
|
81
81
|
if (isCancel(language)) cancel('Cancelled')
|
|
82
82
|
|
|
83
|
-
const authorId = options.
|
|
84
|
-
const referenceId = options.
|
|
83
|
+
const authorId = options.provenanceAuthorId ? Number(options.provenanceAuthorId) : undefined
|
|
84
|
+
const referenceId = options.provenanceReferenceId ? Number(options.provenanceReferenceId) : undefined
|
|
85
85
|
|
|
86
86
|
const { data } = await withSpinner('Creating quote', () =>
|
|
87
87
|
client.quotes.create({
|
|
@@ -91,7 +91,7 @@ export function registerQuotesCommand(program: Command) {
|
|
|
91
91
|
provenance: {
|
|
92
92
|
author_id: authorId,
|
|
93
93
|
reference_id: referenceId,
|
|
94
|
-
source: options.
|
|
94
|
+
source: options.provenanceSourceType ? { source_type: options.provenanceSourceType, source_url: options.provenanceSourceUrl } : undefined,
|
|
95
95
|
},
|
|
96
96
|
}),
|
|
97
97
|
format,
|
|
@@ -105,10 +105,10 @@ export function registerQuotesCommand(program: Command) {
|
|
|
105
105
|
.description('Update a quote')
|
|
106
106
|
.option('--name <text>', 'Quote text')
|
|
107
107
|
.option('--language <lang>', 'Language')
|
|
108
|
-
.option('--author-id <id>', '
|
|
109
|
-
.option('--reference-id <id>', '
|
|
110
|
-
.option('--source-type <type>', '
|
|
111
|
-
.option('--source-url <url>', '
|
|
108
|
+
.option('--provenance-author-id <id>', 'Primary provenance author ID')
|
|
109
|
+
.option('--provenance-reference-id <id>', 'Primary provenance reference ID')
|
|
110
|
+
.option('--provenance-source-type <type>', 'Primary provenance source type')
|
|
111
|
+
.option('--provenance-source-url <url>', 'Primary provenance source URL')
|
|
112
112
|
.action(async (id: string, options: Record<string, string>) => {
|
|
113
113
|
const client = await getClient()
|
|
114
114
|
const format = getFormat(program)
|
|
@@ -116,12 +116,12 @@ export function registerQuotesCommand(program: Command) {
|
|
|
116
116
|
const data_: Record<string, unknown> = {}
|
|
117
117
|
if (options.name) { data_.name = options.name; data_.content = options.name }
|
|
118
118
|
if (options.language) data_.language = options.language
|
|
119
|
-
if (options.
|
|
120
|
-
if (options.
|
|
121
|
-
if (options.
|
|
119
|
+
if (options.provenanceAuthorId !== undefined) data_.provenance = { ...(data_.provenance as object), author_id: options.provenanceAuthorId === 'null' ? null : Number(options.provenanceAuthorId) }
|
|
120
|
+
if (options.provenanceReferenceId !== undefined) data_.provenance = { ...(data_.provenance as object), reference_id: options.provenanceReferenceId === 'null' ? null : Number(options.provenanceReferenceId) }
|
|
121
|
+
if (options.provenanceSourceType !== undefined || options.provenanceSourceUrl !== undefined) {
|
|
122
122
|
data_.provenance = {
|
|
123
123
|
...(data_.provenance as object),
|
|
124
|
-
source: { source_type: options.
|
|
124
|
+
source: { source_type: options.provenanceSourceType ?? 'manual', source_url: options.provenanceSourceUrl },
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|