viatris-exam-cli 1.4.1 → 1.5.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
@@ -72,6 +72,15 @@ viatris-exam describe --compact
72
72
 
73
73
  ## 命令
74
74
 
75
+ ### 产品主数据
76
+
77
+ ```bash
78
+ viatris-exam products list
79
+ viatris-exam products create --input product.json
80
+ ```
81
+
82
+ 创建产品时必须提供全局唯一的 `code`、中文名称 `name` 和英文名称 `nameEn`,并会同步初始化规范知识树根节点。创建请求不会自动重试;网络结果不确定时,应先按列表中的稳定编码确认是否已创建。
83
+
75
84
  ### 产品知识树
76
85
 
77
86
  ```bash
@@ -80,7 +89,7 @@ viatris-exam products update-knowledge-tree "$PRODUCT_ID" \
80
89
  --input knowledge-tree.json
81
90
  ```
82
91
 
83
- 产品是隐藏系统容器,不属于业务知识树层级。固定维度为 L1;知识树回写是完整替换操作,必须一次提交全部 15-500 个 L2/L3/L4 动态节点。先查询产品以获取固定 L1 维度的 `clientRef`。
92
+ 产品主数据不属于业务知识树层级;详情查询使用产品主数据 ID,并兼容历史知识树根节点 ID。固定维度为 L1;知识树回写是完整替换操作,必须一次提交全部 15-500 个 L2/L3/L4 动态节点。先查询产品以获取固定 L1 维度的 `clientRef`。
84
93
 
85
94
  ### 知识节点与文档
86
95
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viatris-exam-cli",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "Agent-friendly CLI for the Viatris exam OpenAPI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: viatris-exam-cli
3
3
  description: Operate the Viatris exam OpenAPI through its agent-friendly CLI. Use for products, knowledge nodes or documents, generation tasks, exam records, scoring, exams, questions, or medical search.
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  ---
6
6
 
7
7
  # Viatris Exam CLI
@@ -22,11 +22,12 @@ Use the repository-local CLI for every supported API operation. Do not call the
22
22
  - Prefer `--input <file>` for existing payloads and stdin for generated payloads.
23
23
  - Parse successful `stdout` as JSON.
24
24
  - Parse failed `stderr` as JSON and branch on both exit code and `error.type`.
25
+ - Use `products list` to resolve product master IDs and stable codes before product-specific workflows. `products create` also initializes the canonical knowledge-tree root.
25
26
  - Preserve `externalRef` when retrying question submission. It is the idempotency key.
26
27
  - For product-wide generation tasks, create one or more questions for every entry in `knowledgeContexts` and include its `knowledgeNodeId`.
27
28
  - Apply every returned generation rule. Product-scoped rules identify applicable product codes through `products`; global rules return an empty `products` array.
28
29
  - Prefer scoring rule V2 for generated questions and scoring results. Use stable point and deduction-rule IDs.
29
- - Treat product IDs as hidden containers, not knowledge-tree levels. Fixed dimensions are business L1; generated nodes are L2-L4.
30
+ - Treat product master records as outside business knowledge-tree levels. Fixed dimensions are business L1; generated nodes are L2-L4. Product detail lookup also accepts a historical knowledge-tree root ID.
30
31
  - Do not automatically retry POST, PUT, PATCH, or DELETE commands. Inspect the returned error and determine whether the server accepted the request.
31
32
  - Keep temporary payloads outside the repository unless they are requested deliverables.
32
33
 
@@ -42,13 +42,38 @@ node src/cli.js --version
42
42
 
43
43
  ## Commands
44
44
 
45
+ List product master data:
46
+
47
+ ```bash
48
+ node src/cli.js products list --compact
49
+ ```
50
+
51
+ The response is `{ "items": [...] }`, ordered by `sortOrder` and then name. Each record includes the stable `code`, Chinese and English names, optional generic name, indication, dosage form, `active` or `inactive` status, remark, and timestamps.
52
+
53
+ Create a product and initialize its canonical knowledge-tree root:
54
+
55
+ ```bash
56
+ node src/cli.js products create --json '{
57
+ "code": "norvasc",
58
+ "name": "络活喜",
59
+ "nameEn": "Norvasc",
60
+ "genericName": "苯磺酸氨氯地平片",
61
+ "indication": "高血压、冠心病",
62
+ "dosageForm": "片剂",
63
+ "sortOrder": 20,
64
+ "remark": "由外部系统创建"
65
+ }'
66
+ ```
67
+
68
+ `code`, `name`, and `nameEn` are required. The code must contain only lowercase letters, digits, and hyphens and must be globally unique. The Chinese name must also be unique. Omitted `sortOrder` defaults to 0. This POST is not automatically retried; after an uncertain network outcome, list products and resolve by code before attempting another create.
69
+
45
70
  Get a product and its fixed L1 dimensions:
46
71
 
47
72
  ```bash
48
73
  node src/cli.js products get "$PRODUCT_ID" --compact
49
74
  ```
50
75
 
51
- The product ID represents a hidden system container and is not part of 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`.
76
+ Use the product master `id`; historical knowledge-tree root IDs remain accepted for compatibility. 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`.
52
77
 
53
78
  Replace a product knowledge tree:
54
79
 
Binary file
@@ -9,6 +9,22 @@ export async function resolveProducts(positionals, options) {
9
9
  const [resource, action] = positionals;
10
10
  if (resource !== "products") return null;
11
11
 
12
+ if (action === "list") {
13
+ assertNoExtraPositionals(positionals, 2);
14
+ assertOptions(options);
15
+ return { method: "GET", path: "/openapi/products" };
16
+ }
17
+
18
+ if (action === "create") {
19
+ assertNoExtraPositionals(positionals, 2);
20
+ assertOptions(options, ["input", "json"]);
21
+ return {
22
+ method: "POST",
23
+ path: "/openapi/products",
24
+ body: await readJsonInput(options),
25
+ };
26
+ }
27
+
12
28
  if (action === "get") {
13
29
  assertNoExtraPositionals(positionals, 3);
14
30
  assertOptions(options);
package/src/help.js CHANGED
@@ -8,6 +8,8 @@ Usage:
8
8
  viatris-exam describe
9
9
 
10
10
  Commands:
11
+ products list
12
+ products create --input <file|->
11
13
  products get <product-id>
12
14
  products update-knowledge-tree <product-id> --input <file|->
13
15
  knowledge tree <product-code>
package/src/metadata.js CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = "1.4.1";
1
+ export const VERSION = "1.5.0";
2
2
  export const DEFAULT_TIMEOUT_MS = 30_000;
3
3
  export const DEFAULT_RETRIES = 2;
4
4
 
@@ -15,6 +15,19 @@ export const API_ENVIRONMENT_ALIASES = Object.freeze({
15
15
  });
16
16
 
17
17
  export const COMMANDS = Object.freeze([
18
+ {
19
+ command: "products list",
20
+ method: "GET",
21
+ path: "/openapi/products",
22
+ summary: "List all product master records in display order.",
23
+ },
24
+ {
25
+ command: "products create",
26
+ method: "POST",
27
+ path: "/openapi/products",
28
+ input: "{code, name, nameEn, genericName?, indication?, dosageForm?, sortOrder?, remark?}",
29
+ summary: "Create a product and initialize its canonical knowledge-tree root.",
30
+ },
18
31
  {
19
32
  command: "products get <product-id>",
20
33
  method: "GET",