viatris-exam-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/README.md
CHANGED
|
@@ -5,12 +5,19 @@
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm
|
|
8
|
+
npm install -g viatris-exam-cli
|
|
9
9
|
export VIATRIS_API_KEY="replace-with-real-key"
|
|
10
10
|
viatris-exam login
|
|
11
11
|
unset VIATRIS_API_KEY
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
开始任务前更新到最新版本:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g viatris-exam-cli@latest
|
|
18
|
+
viatris-exam --version
|
|
19
|
+
```
|
|
20
|
+
|
|
14
21
|
默认连接线上环境:
|
|
15
22
|
|
|
16
23
|
```text
|
package/package.json
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: viatris-exam-cli
|
|
3
3
|
description: Operate the Viatris exam OpenAPI through its agent-friendly CLI. Use for login, products, knowledge, generation tasks, exam records, scoring, exams, questions, or medical search.
|
|
4
|
-
version: 1.8.
|
|
4
|
+
version: 1.8.1
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Viatris Exam CLI
|
|
8
8
|
|
|
9
|
-
Use the
|
|
9
|
+
Use the installed CLI for every supported API operation. Do not call the HTTP endpoints directly when the CLI covers the task.
|
|
10
10
|
|
|
11
11
|
## Start
|
|
12
12
|
|
|
13
|
-
1.
|
|
14
|
-
2.
|
|
15
|
-
3.
|
|
16
|
-
4.
|
|
17
|
-
5.
|
|
13
|
+
1. Read the install and update sections in [references/cli-reference.md](references/cli-reference.md).
|
|
14
|
+
2. Install `viatris-exam-cli` from npm when unavailable.
|
|
15
|
+
3. Update to `viatris-exam-cli@latest` at the start of a task so capability instructions match the installed CLI.
|
|
16
|
+
4. Verify with `viatris-exam --version`.
|
|
17
|
+
5. Prefer the saved credential. To initialize or rotate it, set `VIATRIS_API_KEY` and run `viatris-exam login`; never place the key in command arguments, output, or logs.
|
|
18
|
+
6. Use production by default. Set `VIATRIS_API_ENV=development` only when the user requests development or testing.
|
|
19
|
+
7. Run `viatris-exam describe --compact` when capability discovery or exact machine-readable metadata is needed.
|
|
20
|
+
8. Read the relevant command section in the reference before constructing a write payload or handling a nonzero exit code.
|
|
18
21
|
|
|
19
22
|
## Execute
|
|
20
23
|
|
|
21
|
-
- Invoke the
|
|
24
|
+
- Invoke commands through the installed `viatris-exam` binary.
|
|
22
25
|
- Prefer `--input <file>` for existing payloads and stdin for generated payloads.
|
|
23
26
|
- Parse successful `stdout` as JSON.
|
|
24
27
|
- Parse failed `stderr` as JSON and branch on both exit code and `error.type`.
|
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
# CLI Reference
|
|
2
2
|
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
Install the CLI globally so every example below can use the `viatris-exam` command directly:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g viatris-exam-cli
|
|
9
|
+
viatris-exam --version
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Update
|
|
13
|
+
|
|
14
|
+
Update before starting a task so the installed capabilities and this Skill remain aligned:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g viatris-exam-cli@latest
|
|
18
|
+
viatris-exam --version
|
|
19
|
+
```
|
|
20
|
+
|
|
3
21
|
## Authentication And Environment
|
|
4
22
|
|
|
5
23
|
Login once:
|
|
6
24
|
|
|
7
25
|
```bash
|
|
8
26
|
export VIATRIS_API_KEY="..."
|
|
9
|
-
|
|
27
|
+
viatris-exam login
|
|
10
28
|
unset VIATRIS_API_KEY
|
|
11
29
|
```
|
|
12
30
|
|
|
@@ -42,9 +60,9 @@ export VIATRIS_API_KEY_PREFIX=""
|
|
|
42
60
|
## Capability Discovery
|
|
43
61
|
|
|
44
62
|
```bash
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
viatris-exam describe --compact
|
|
64
|
+
viatris-exam --help
|
|
65
|
+
viatris-exam --version
|
|
48
66
|
```
|
|
49
67
|
|
|
50
68
|
`describe` does not require credentials. It returns commands, paths, environment metadata, authentication metadata, and exit codes as JSON.
|
|
@@ -54,7 +72,7 @@ node src/cli.js --version
|
|
|
54
72
|
List product master data:
|
|
55
73
|
|
|
56
74
|
```bash
|
|
57
|
-
|
|
75
|
+
viatris-exam products list --compact
|
|
58
76
|
```
|
|
59
77
|
|
|
60
78
|
The response is `{ "items": [...] }`, ordered by `sortOrder` and then name. Each record includes the stable `code`, Chinese name, optional English name, generic name, indication, dosage form, `active` or `inactive` status, remark, and timestamps.
|
|
@@ -62,7 +80,7 @@ The response is `{ "items": [...] }`, ordered by `sortOrder` and then name. Each
|
|
|
62
80
|
Create a product and initialize its canonical knowledge-tree root:
|
|
63
81
|
|
|
64
82
|
```bash
|
|
65
|
-
|
|
83
|
+
viatris-exam products create --json '{
|
|
66
84
|
"name": "络活喜",
|
|
67
85
|
"genericName": "苯磺酸氨氯地平片",
|
|
68
86
|
"indication": "高血压、冠心病",
|
|
@@ -77,7 +95,7 @@ Only `name` is required and the Chinese name must be unique. `code` is optional;
|
|
|
77
95
|
Get a product and its fixed L1 dimensions:
|
|
78
96
|
|
|
79
97
|
```bash
|
|
80
|
-
|
|
98
|
+
viatris-exam products get "$PRODUCT_ID" --compact
|
|
81
99
|
```
|
|
82
100
|
|
|
83
101
|
Use the product master `id`; historical knowledge-tree root IDs remain accepted for compatibility. The response also contains nullable `nameEn`, `genericName`, `indication`, `dosageForm`, and `remark`. Product master data is outside business levels L1-L4. Use each returned `fixedDimensions[].clientRef` as the parent reference for an L2 node. Each fixed dimension also returns `level: 1` and a display `codePrefix`.
|
|
@@ -85,7 +103,7 @@ Use the product master `id`; historical knowledge-tree root IDs remain accepted
|
|
|
85
103
|
Update verified optional medical master data:
|
|
86
104
|
|
|
87
105
|
```bash
|
|
88
|
-
|
|
106
|
+
viatris-exam products update "$PRODUCT_ID" --json '{
|
|
89
107
|
"nameEn": "Lipitor",
|
|
90
108
|
"genericName": "阿托伐他汀钙片",
|
|
91
109
|
"indication": "高胆固醇血症、混合型血脂异常及心血管疾病预防",
|
|
@@ -99,7 +117,7 @@ Only supplied fields are updated. Each supplied value must be a nonempty string
|
|
|
99
117
|
Replace a product knowledge tree:
|
|
100
118
|
|
|
101
119
|
```bash
|
|
102
|
-
|
|
120
|
+
viatris-exam products update-knowledge-tree "$PRODUCT_ID" \
|
|
103
121
|
--input knowledge-tree.json \
|
|
104
122
|
--compact
|
|
105
123
|
```
|
|
@@ -148,7 +166,7 @@ Submit the complete L2/L3/L4 node set, between 15 and 500 nodes. Every `clientRe
|
|
|
148
166
|
Delete all dynamic knowledge-tree content:
|
|
149
167
|
|
|
150
168
|
```bash
|
|
151
|
-
|
|
169
|
+
viatris-exam products delete-knowledge-tree "$PRODUCT_ID"
|
|
152
170
|
```
|
|
153
171
|
|
|
154
172
|
This destructive operation preserves the product root and five fixed L1 dimensions, deletes all L2-L4 nodes and evidence documents, and unbinds affected questions. Inspect the product and tree first, and execute only when the user explicitly requests the full reset.
|
|
@@ -158,7 +176,7 @@ This destructive operation preserves the product root and five fixed L1 dimensio
|
|
|
158
176
|
Get the complete physical tree and all product documents:
|
|
159
177
|
|
|
160
178
|
```bash
|
|
161
|
-
|
|
179
|
+
viatris-exam knowledge tree lipitor --compact
|
|
162
180
|
```
|
|
163
181
|
|
|
164
182
|
The incremental `/knowledge` responses expose physical storage levels where the product root is 1 and fixed dimensions are 2. This differs from the product-generation business taxonomy, where the product is hidden, fixed dimensions are L1, and generated content is L2-L4.
|
|
@@ -166,7 +184,7 @@ The incremental `/knowledge` responses expose physical storage levels where the
|
|
|
166
184
|
Create or reuse a visible path:
|
|
167
185
|
|
|
168
186
|
```bash
|
|
169
|
-
|
|
187
|
+
viatris-exam knowledge nodes by-path --json \
|
|
170
188
|
'{"product":"lipitor","path":["疾病知识","血脂异常基础","ASCVD 风险评估"]}'
|
|
171
189
|
```
|
|
172
190
|
|
|
@@ -175,20 +193,20 @@ The path has one to three entries. The first entry must be a fixed dimension nam
|
|
|
175
193
|
Create or reuse one node under a known parent:
|
|
176
194
|
|
|
177
195
|
```bash
|
|
178
|
-
|
|
196
|
+
viatris-exam knowledge nodes create --json \
|
|
179
197
|
'{"parentId":"PARENT_ID","name":"ASCVD 风险评估","sortOrder":20}'
|
|
180
198
|
```
|
|
181
199
|
|
|
182
200
|
Read, update, move, or delete a node:
|
|
183
201
|
|
|
184
202
|
```bash
|
|
185
|
-
|
|
186
|
-
|
|
203
|
+
viatris-exam knowledge nodes get "$NODE_ID"
|
|
204
|
+
viatris-exam knowledge nodes update "$NODE_ID" \
|
|
187
205
|
--json '{"name":"血脂异常与他汀治疗","sortOrder":5}'
|
|
188
|
-
|
|
206
|
+
viatris-exam knowledge nodes move "$NODE_ID" \
|
|
189
207
|
--json '{"newParentId":"NEW_PARENT_ID","sortOrder":30}'
|
|
190
|
-
|
|
191
|
-
|
|
208
|
+
viatris-exam knowledge nodes delete "$NODE_ID"
|
|
209
|
+
viatris-exam knowledge nodes delete "$NODE_ID" --recursive
|
|
192
210
|
```
|
|
193
211
|
|
|
194
212
|
Product roots and fixed dimensions are protected from rename, move, and deletion. Moving cannot cross products, target the node itself or its descendants, or produce levels deeper than L4. Plain deletion is the safe default and returns HTTP 409 when children or question bindings exist. `--recursive` deletes the full subtree and documents and unbinds affected questions. Inspect the node first and use recursive deletion only when explicitly requested.
|
|
@@ -196,14 +214,14 @@ Product roots and fixed dimensions are protected from rename, move, and deletion
|
|
|
196
214
|
Manage documents:
|
|
197
215
|
|
|
198
216
|
```bash
|
|
199
|
-
|
|
200
|
-
|
|
217
|
+
viatris-exam knowledge documents list "$NODE_ID"
|
|
218
|
+
viatris-exam knowledge documents create "$NODE_ID" \
|
|
201
219
|
--json '{"title":"说明书","summary":"摘录"}'
|
|
202
|
-
|
|
220
|
+
viatris-exam knowledge documents upsert "$NODE_ID" \
|
|
203
221
|
--json '{"items":[{"title":"说明书","summary":"更新后的摘录"}]}'
|
|
204
|
-
|
|
222
|
+
viatris-exam knowledge documents update "$DOCUMENT_ID" \
|
|
205
223
|
--json '{"summary":"更新后的摘要"}'
|
|
206
|
-
|
|
224
|
+
viatris-exam knowledge documents delete "$DOCUMENT_ID"
|
|
207
225
|
```
|
|
208
226
|
|
|
209
227
|
Create reuses a document with the same title under the node. Batch upsert accepts 1-20 items and updates `summary` for existing titles. A single-document update changes only supplied fields; send `summary: null` to clear the summary. Current write contracts accept only `title` and `summary`; if input contains `url`, the CLI drops it before sending. Read responses may still contain historical URL data. Inspect a document before an explicitly requested delete.
|
|
@@ -223,7 +241,7 @@ Whitespace is normalized after removal, and leading or trailing title separators
|
|
|
223
241
|
List generation tasks:
|
|
224
242
|
|
|
225
243
|
```bash
|
|
226
|
-
|
|
244
|
+
viatris-exam gen-tasks list \
|
|
227
245
|
--status generating \
|
|
228
246
|
--limit 20 \
|
|
229
247
|
--compact
|
|
@@ -234,7 +252,7 @@ node src/cli.js gen-tasks list \
|
|
|
234
252
|
Get one generation task:
|
|
235
253
|
|
|
236
254
|
```bash
|
|
237
|
-
|
|
255
|
+
viatris-exam gen-tasks get "$TASK_ID" --compact
|
|
238
256
|
```
|
|
239
257
|
|
|
240
258
|
For a leaf-node task, `knowledgeContext` is the mandatory target context. For a product-wide task, `dimension` is `all`, `knowledgeContext` is null, and `knowledgeContexts` contains every leaf context. Generate `questionsPerNode` questions for every listed context and follow all returned `rules`.
|
|
@@ -244,7 +262,7 @@ Each rule has `scope` and `products`. For `scope: "product"`, `products` contain
|
|
|
244
262
|
Submit generated questions:
|
|
245
263
|
|
|
246
264
|
```bash
|
|
247
|
-
|
|
265
|
+
viatris-exam gen-tasks submit "$TASK_ID" --input payload.json --compact
|
|
248
266
|
```
|
|
249
267
|
|
|
250
268
|
Payload shape:
|
|
@@ -315,13 +333,13 @@ Omit `knowledgeNodeId` for ordinary tasks. For a product-wide task it is require
|
|
|
315
333
|
Get a submitted exam record and its frozen answers:
|
|
316
334
|
|
|
317
335
|
```bash
|
|
318
|
-
|
|
336
|
+
viatris-exam exam-records get "$RECORD_ID" --compact
|
|
319
337
|
```
|
|
320
338
|
|
|
321
339
|
Get the complete scoring rules bound to the record:
|
|
322
340
|
|
|
323
341
|
```bash
|
|
324
|
-
|
|
342
|
+
viatris-exam exam-records scoring-rules "$RECORD_ID" --compact
|
|
325
343
|
```
|
|
326
344
|
|
|
327
345
|
The response includes the scoring `taskId`, `schemaVersion`, frozen question versions, evidence, V2 deduction rules, score caps, and item IDs. Use its `taskId` for scoring submission.
|
|
@@ -329,13 +347,13 @@ The response includes the scoring `taskId`, `schemaVersion`, frozen question ver
|
|
|
329
347
|
Get a scoring task:
|
|
330
348
|
|
|
331
349
|
```bash
|
|
332
|
-
|
|
350
|
+
viatris-exam scoring get "$TASK_ID" --compact
|
|
333
351
|
```
|
|
334
352
|
|
|
335
353
|
Submit scoring results:
|
|
336
354
|
|
|
337
355
|
```bash
|
|
338
|
-
|
|
356
|
+
viatris-exam scoring submit "$TASK_ID" --input results.json --compact
|
|
339
357
|
```
|
|
340
358
|
|
|
341
359
|
Payload shape:
|
|
@@ -367,7 +385,7 @@ For V2, submit exactly one `pointJudgement` per scoring point. IDs must match th
|
|
|
367
385
|
Create an exam:
|
|
368
386
|
|
|
369
387
|
```bash
|
|
370
|
-
|
|
388
|
+
viatris-exam exams create --input exam.json --compact
|
|
371
389
|
```
|
|
372
390
|
|
|
373
391
|
Required top-level fields are `name`, `product`, `questionCount`, `startAt`, `endAt`, `resultPolicy`, and `assigneeIds`. `questionCount` is 1 through 150. Use either `questions` or legacy `questionIds`, never both. Each question score must be a positive integer and the complete exam must total exactly 100.
|
|
@@ -375,7 +393,7 @@ Required top-level fields are `name`, `product`, `questionCount`, `startAt`, `en
|
|
|
375
393
|
Create questions directly:
|
|
376
394
|
|
|
377
395
|
```bash
|
|
378
|
-
|
|
396
|
+
viatris-exam questions create --input questions.json --compact
|
|
379
397
|
```
|
|
380
398
|
|
|
381
399
|
Payload shape is `{ "items": [...] }`. Each item requires `product`, `dimension`, and `content`; provide `externalRef` for idempotency. Prefer `scoringRuleVersion: 2`, stable IDs on scoring points and deduction rules, and explicit `scoreCapRules`.
|
|
@@ -385,7 +403,7 @@ The API has partial-success semantics: inspect `accepted`, `duplicates`, and eve
|
|
|
385
403
|
Add a question version:
|
|
386
404
|
|
|
387
405
|
```bash
|
|
388
|
-
|
|
406
|
+
viatris-exam questions version "$QUESTION_ID" --input version.json --compact
|
|
389
407
|
```
|
|
390
408
|
|
|
391
409
|
Required fields are `stem`, `referenceAnswer`, nonempty `scoringPoints`, `evidence`, and `editReason`. V2 versions may also include `scoringRuleVersion: 2`, deduction rules, and `scoreCapRules`.
|
|
@@ -393,7 +411,7 @@ Required fields are `stem`, `referenceAnswer`, nonempty `scoringPoints`, `eviden
|
|
|
393
411
|
Search medical evidence:
|
|
394
412
|
|
|
395
413
|
```bash
|
|
396
|
-
|
|
414
|
+
viatris-exam medical-search search "阿托伐他汀 适应症" \
|
|
397
415
|
--file-type drug \
|
|
398
416
|
--limit 20 \
|
|
399
417
|
--max-length 1200 \
|
|
@@ -404,7 +422,7 @@ Or use JSON:
|
|
|
404
422
|
|
|
405
423
|
```bash
|
|
406
424
|
printf '%s' '{"query":"阿托伐他汀 适应症","limit":20}' |
|
|
407
|
-
|
|
425
|
+
viatris-exam medical-search search --compact
|
|
408
426
|
```
|
|
409
427
|
|
|
410
428
|
Do not combine query flags with JSON input. `limit` accepts 1-20 and defaults to 20 when omitted. `maxLength` defaults to 1200.
|
|
@@ -416,10 +434,10 @@ The response `rawJson` is already a structured object. Read `rawJson.documents`
|
|
|
416
434
|
Choose exactly one input form:
|
|
417
435
|
|
|
418
436
|
```bash
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
printf '%s' '{"items":[]}' |
|
|
437
|
+
viatris-exam questions create --input payload.json
|
|
438
|
+
viatris-exam questions create --input - < payload.json
|
|
439
|
+
viatris-exam questions create --json '{"items":[]}'
|
|
440
|
+
printf '%s' '{"items":[]}' | viatris-exam questions create
|
|
423
441
|
```
|
|
424
442
|
|
|
425
443
|
The top-level JSON value must be an object.
|
|
Binary file
|
package/src/cli.js
CHANGED
|
File without changes
|
package/src/metadata.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CREDENTIAL_FILE_DISPLAY } from "./credentials.js";
|
|
2
2
|
import { DOCUMENT_SANITIZATION_POLICY } from "./sanitizers/documents.js";
|
|
3
3
|
|
|
4
|
-
export const VERSION = "1.8.
|
|
4
|
+
export const VERSION = "1.8.1";
|
|
5
5
|
export const DEFAULT_TIMEOUT_MS = 30_000;
|
|
6
6
|
export const DEFAULT_RETRIES = 2;
|
|
7
7
|
|