@verbatims/cli 0.1.18 → 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 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,9 +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
34
36
 
35
- The quote-level `--author-id`, `--reference-id`, `--source-type`, and `--source-url` options are deprecated compatibility options. New integrations should use the SDK `provenance` payload; the dedicated `quotes attributions` and `quotes sources` commands manage secondary provenance.
37
+ Use the `--provenance-*` options for primary provenance. The dedicated `quotes attributions` and `quotes sources` commands manage secondary provenance.
36
38
 
37
39
  # Browse interactively
38
40
  verbatims quotes browse
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbatims/cli",
3
- "version": "0.1.18",
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": "^1.0.0",
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",
@@ -10,13 +10,6 @@ function getFormat(program: Command): Format {
10
10
  return (program.opts().format ?? 'table') as Format
11
11
  }
12
12
 
13
- function warnLegacyQuoteOptions(options: Record<string, unknown>): void {
14
- const fields = ['authorId', 'referenceId', 'sourceType', 'sourceUrl']
15
- if (fields.some(field => options[field] !== undefined)) {
16
- console.error(chalk.yellow('Warning: quote provenance options are deprecated; use the provenance API fields instead.'))
17
- }
18
- }
19
-
20
13
  export function registerQuotesCommand(program: Command) {
21
14
  const quotes = program.command('quotes').description('Manage quotes')
22
15
 
@@ -73,14 +66,13 @@ export function registerQuotesCommand(program: Command) {
73
66
  .description('Create a quote')
74
67
  .option('--name <text>', 'Quote text')
75
68
  .option('--language <lang>', 'Language')
76
- .option('--author-id <id>', 'Author ID (deprecated)')
77
- .option('--reference-id <id>', 'Reference ID (deprecated)')
78
- .option('--source-type <type>', 'Source type (deprecated)')
79
- .option('--source-url <url>', 'Source URL (deprecated)')
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')
80
73
  .action(async (options: Record<string, string>) => {
81
74
  const client = await getClient()
82
75
  const format = getFormat(program)
83
- warnLegacyQuoteOptions(options)
84
76
 
85
77
  const name = options.name ?? await text({ message: 'Quote text', validate: (v) => !v ? 'Required' : undefined })
86
78
  if (isCancel(name)) cancel('Cancelled')
@@ -88,8 +80,8 @@ export function registerQuotesCommand(program: Command) {
88
80
  const language = options.language ?? await text({ message: 'Language', initialValue: 'fr' })
89
81
  if (isCancel(language)) cancel('Cancelled')
90
82
 
91
- const authorId = options.authorId ? Number(options.authorId) : undefined
92
- const referenceId = options.referenceId ? Number(options.referenceId) : undefined
83
+ const authorId = options.provenanceAuthorId ? Number(options.provenanceAuthorId) : undefined
84
+ const referenceId = options.provenanceReferenceId ? Number(options.provenanceReferenceId) : undefined
93
85
 
94
86
  const { data } = await withSpinner('Creating quote', () =>
95
87
  client.quotes.create({
@@ -99,7 +91,7 @@ export function registerQuotesCommand(program: Command) {
99
91
  provenance: {
100
92
  author_id: authorId,
101
93
  reference_id: referenceId,
102
- source: options.sourceType ? { source_type: options.sourceType, source_url: options.sourceUrl } : undefined,
94
+ source: options.provenanceSourceType ? { source_type: options.provenanceSourceType, source_url: options.provenanceSourceUrl } : undefined,
103
95
  },
104
96
  }),
105
97
  format,
@@ -113,24 +105,23 @@ export function registerQuotesCommand(program: Command) {
113
105
  .description('Update a quote')
114
106
  .option('--name <text>', 'Quote text')
115
107
  .option('--language <lang>', 'Language')
116
- .option('--author-id <id>', 'Author ID (deprecated)')
117
- .option('--reference-id <id>', 'Reference ID (deprecated)')
118
- .option('--source-type <type>', 'Source type (deprecated)')
119
- .option('--source-url <url>', 'Source URL (deprecated)')
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')
120
112
  .action(async (id: string, options: Record<string, string>) => {
121
113
  const client = await getClient()
122
114
  const format = getFormat(program)
123
- warnLegacyQuoteOptions(options)
124
115
 
125
116
  const data_: Record<string, unknown> = {}
126
117
  if (options.name) { data_.name = options.name; data_.content = options.name }
127
118
  if (options.language) data_.language = options.language
128
- if (options.authorId !== undefined) data_.provenance = { ...(data_.provenance as object), author_id: options.authorId === 'null' ? null : Number(options.authorId) }
129
- if (options.referenceId !== undefined) data_.provenance = { ...(data_.provenance as object), reference_id: options.referenceId === 'null' ? null : Number(options.referenceId) }
130
- if (options.sourceType !== undefined || options.sourceUrl !== undefined) {
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) {
131
122
  data_.provenance = {
132
123
  ...(data_.provenance as object),
133
- source: { source_type: options.sourceType ?? 'manual', source_url: options.sourceUrl },
124
+ source: { source_type: options.provenanceSourceType ?? 'manual', source_url: options.provenanceSourceUrl },
134
125
  }
135
126
  }
136
127