i-repo 0.1.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.
Files changed (186) hide show
  1. package/README.md +382 -0
  2. package/dist/bin/irepo.d.ts +6 -0
  3. package/dist/bin/irepo.d.ts.map +1 -0
  4. package/dist/bin/irepo.js +55 -0
  5. package/dist/bin/irepo.js.map +1 -0
  6. package/dist/commands/auth.d.ts +8 -0
  7. package/dist/commands/auth.d.ts.map +1 -0
  8. package/dist/commands/auth.js +106 -0
  9. package/dist/commands/auth.js.map +1 -0
  10. package/dist/commands/config.d.ts +8 -0
  11. package/dist/commands/config.d.ts.map +1 -0
  12. package/dist/commands/config.js +98 -0
  13. package/dist/commands/config.js.map +1 -0
  14. package/dist/commands/definition-batches/index.d.ts +8 -0
  15. package/dist/commands/definition-batches/index.d.ts.map +1 -0
  16. package/dist/commands/definition-batches/index.js +96 -0
  17. package/dist/commands/definition-batches/index.js.map +1 -0
  18. package/dist/commands/definitions/get.d.ts +7 -0
  19. package/dist/commands/definitions/get.d.ts.map +1 -0
  20. package/dist/commands/definitions/get.js +28 -0
  21. package/dist/commands/definitions/get.js.map +1 -0
  22. package/dist/commands/definitions/index.d.ts +6 -0
  23. package/dist/commands/definitions/index.d.ts.map +1 -0
  24. package/dist/commands/definitions/index.js +27 -0
  25. package/dist/commands/definitions/index.js.map +1 -0
  26. package/dist/commands/definitions/labels.d.ts +4 -0
  27. package/dist/commands/definitions/labels.d.ts.map +1 -0
  28. package/dist/commands/definitions/labels.js +118 -0
  29. package/dist/commands/definitions/labels.js.map +1 -0
  30. package/dist/commands/definitions/list.d.ts +7 -0
  31. package/dist/commands/definitions/list.d.ts.map +1 -0
  32. package/dist/commands/definitions/list.js +76 -0
  33. package/dist/commands/definitions/list.js.map +1 -0
  34. package/dist/commands/definitions/lock.d.ts +7 -0
  35. package/dist/commands/definitions/lock.d.ts.map +1 -0
  36. package/dist/commands/definitions/lock.js +36 -0
  37. package/dist/commands/definitions/lock.js.map +1 -0
  38. package/dist/commands/definitions/roles.d.ts +4 -0
  39. package/dist/commands/definitions/roles.d.ts.map +1 -0
  40. package/dist/commands/definitions/roles.js +68 -0
  41. package/dist/commands/definitions/roles.js.map +1 -0
  42. package/dist/commands/index.d.ts +11 -0
  43. package/dist/commands/index.d.ts.map +1 -0
  44. package/dist/commands/index.js +11 -0
  45. package/dist/commands/index.js.map +1 -0
  46. package/dist/commands/report-batches/index.d.ts +9 -0
  47. package/dist/commands/report-batches/index.d.ts.map +1 -0
  48. package/dist/commands/report-batches/index.js +450 -0
  49. package/dist/commands/report-batches/index.js.map +1 -0
  50. package/dist/commands/reports/cluster-value.d.ts +7 -0
  51. package/dist/commands/reports/cluster-value.d.ts.map +1 -0
  52. package/dist/commands/reports/cluster-value.js +34 -0
  53. package/dist/commands/reports/cluster-value.js.map +1 -0
  54. package/dist/commands/reports/copy.d.ts +7 -0
  55. package/dist/commands/reports/copy.d.ts.map +1 -0
  56. package/dist/commands/reports/copy.js +31 -0
  57. package/dist/commands/reports/copy.js.map +1 -0
  58. package/dist/commands/reports/create-sorted.d.ts +7 -0
  59. package/dist/commands/reports/create-sorted.d.ts.map +1 -0
  60. package/dist/commands/reports/create-sorted.js +31 -0
  61. package/dist/commands/reports/create-sorted.js.map +1 -0
  62. package/dist/commands/reports/download.d.ts +7 -0
  63. package/dist/commands/reports/download.d.ts.map +1 -0
  64. package/dist/commands/reports/download.js +34 -0
  65. package/dist/commands/reports/download.js.map +1 -0
  66. package/dist/commands/reports/get.d.ts +7 -0
  67. package/dist/commands/reports/get.d.ts.map +1 -0
  68. package/dist/commands/reports/get.js +28 -0
  69. package/dist/commands/reports/get.js.map +1 -0
  70. package/dist/commands/reports/index.d.ts +6 -0
  71. package/dist/commands/reports/index.d.ts.map +1 -0
  72. package/dist/commands/reports/index.js +35 -0
  73. package/dist/commands/reports/index.js.map +1 -0
  74. package/dist/commands/reports/labels.d.ts +4 -0
  75. package/dist/commands/reports/labels.d.ts.map +1 -0
  76. package/dist/commands/reports/labels.js +64 -0
  77. package/dist/commands/reports/labels.js.map +1 -0
  78. package/dist/commands/reports/list.d.ts +7 -0
  79. package/dist/commands/reports/list.d.ts.map +1 -0
  80. package/dist/commands/reports/list.js +105 -0
  81. package/dist/commands/reports/list.js.map +1 -0
  82. package/dist/commands/reports/lock.d.ts +7 -0
  83. package/dist/commands/reports/lock.d.ts.map +1 -0
  84. package/dist/commands/reports/lock.js +36 -0
  85. package/dist/commands/reports/lock.js.map +1 -0
  86. package/dist/commands/reports/roles.d.ts +4 -0
  87. package/dist/commands/reports/roles.d.ts.map +1 -0
  88. package/dist/commands/reports/roles.js +64 -0
  89. package/dist/commands/reports/roles.js.map +1 -0
  90. package/dist/commands/systems/index.d.ts +8 -0
  91. package/dist/commands/systems/index.d.ts.map +1 -0
  92. package/dist/commands/systems/index.js +411 -0
  93. package/dist/commands/systems/index.js.map +1 -0
  94. package/dist/config/client.d.ts +24 -0
  95. package/dist/config/client.d.ts.map +1 -0
  96. package/dist/config/client.js +53 -0
  97. package/dist/config/client.js.map +1 -0
  98. package/dist/config/index.d.ts +10 -0
  99. package/dist/config/index.d.ts.map +1 -0
  100. package/dist/config/index.js +8 -0
  101. package/dist/config/index.js.map +1 -0
  102. package/dist/config/store.d.ts +20 -0
  103. package/dist/config/store.d.ts.map +1 -0
  104. package/dist/config/store.js +47 -0
  105. package/dist/config/store.js.map +1 -0
  106. package/dist/core/errors.d.ts +48 -0
  107. package/dist/core/errors.d.ts.map +1 -0
  108. package/dist/core/errors.js +187 -0
  109. package/dist/core/errors.js.map +1 -0
  110. package/dist/core/index.d.ts +8 -0
  111. package/dist/core/index.d.ts.map +1 -0
  112. package/dist/core/index.js +7 -0
  113. package/dist/core/index.js.map +1 -0
  114. package/dist/index.d.ts +2 -0
  115. package/dist/index.d.ts.map +1 -0
  116. package/dist/index.js +2 -0
  117. package/dist/index.js.map +1 -0
  118. package/dist/ui/banner.d.ts +13 -0
  119. package/dist/ui/banner.d.ts.map +1 -0
  120. package/dist/ui/banner.js +54 -0
  121. package/dist/ui/banner.js.map +1 -0
  122. package/dist/ui/error.d.ts +17 -0
  123. package/dist/ui/error.d.ts.map +1 -0
  124. package/dist/ui/error.js +109 -0
  125. package/dist/ui/error.js.map +1 -0
  126. package/dist/ui/formatters/csv.d.ts +15 -0
  127. package/dist/ui/formatters/csv.d.ts.map +1 -0
  128. package/dist/ui/formatters/csv.js +49 -0
  129. package/dist/ui/formatters/csv.js.map +1 -0
  130. package/dist/ui/formatters/index.d.ts +22 -0
  131. package/dist/ui/formatters/index.d.ts.map +1 -0
  132. package/dist/ui/formatters/index.js +49 -0
  133. package/dist/ui/formatters/index.js.map +1 -0
  134. package/dist/ui/formatters/json.d.ts +14 -0
  135. package/dist/ui/formatters/json.d.ts.map +1 -0
  136. package/dist/ui/formatters/json.js +16 -0
  137. package/dist/ui/formatters/json.js.map +1 -0
  138. package/dist/ui/formatters/quiet.d.ts +14 -0
  139. package/dist/ui/formatters/quiet.d.ts.map +1 -0
  140. package/dist/ui/formatters/quiet.js +35 -0
  141. package/dist/ui/formatters/quiet.js.map +1 -0
  142. package/dist/ui/formatters/table.d.ts +9 -0
  143. package/dist/ui/formatters/table.d.ts.map +1 -0
  144. package/dist/ui/formatters/table.js +61 -0
  145. package/dist/ui/formatters/table.js.map +1 -0
  146. package/dist/ui/index.d.ts +28 -0
  147. package/dist/ui/index.d.ts.map +1 -0
  148. package/dist/ui/index.js +31 -0
  149. package/dist/ui/index.js.map +1 -0
  150. package/dist/ui/progress.d.ts +33 -0
  151. package/dist/ui/progress.d.ts.map +1 -0
  152. package/dist/ui/progress.js +63 -0
  153. package/dist/ui/progress.js.map +1 -0
  154. package/dist/ui/prompt.d.ts +22 -0
  155. package/dist/ui/prompt.d.ts.map +1 -0
  156. package/dist/ui/prompt.js +36 -0
  157. package/dist/ui/prompt.js.map +1 -0
  158. package/dist/ui/spinner.d.ts +50 -0
  159. package/dist/ui/spinner.d.ts.map +1 -0
  160. package/dist/ui/spinner.js +74 -0
  161. package/dist/ui/spinner.js.map +1 -0
  162. package/dist/ui/table.d.ts +31 -0
  163. package/dist/ui/table.d.ts.map +1 -0
  164. package/dist/ui/table.js +99 -0
  165. package/dist/ui/table.js.map +1 -0
  166. package/dist/ui/theme.d.ts +79 -0
  167. package/dist/ui/theme.d.ts.map +1 -0
  168. package/dist/ui/theme.js +105 -0
  169. package/dist/ui/theme.js.map +1 -0
  170. package/dist/utils/constants.d.ts +13 -0
  171. package/dist/utils/constants.d.ts.map +1 -0
  172. package/dist/utils/constants.js +13 -0
  173. package/dist/utils/constants.js.map +1 -0
  174. package/dist/utils/file.d.ts +29 -0
  175. package/dist/utils/file.d.ts.map +1 -0
  176. package/dist/utils/file.js +70 -0
  177. package/dist/utils/file.js.map +1 -0
  178. package/dist/utils/index.d.ts +9 -0
  179. package/dist/utils/index.d.ts.map +1 -0
  180. package/dist/utils/index.js +7 -0
  181. package/dist/utils/index.js.map +1 -0
  182. package/dist/utils/output.d.ts +16 -0
  183. package/dist/utils/output.d.ts.map +1 -0
  184. package/dist/utils/output.js +107 -0
  185. package/dist/utils/output.js.map +1 -0
  186. package/package.json +56 -0
package/README.md ADDED
@@ -0,0 +1,382 @@
1
+ ```
2
+ ██╗ ██████╗ ███████╗██████╗ ██████╗
3
+ ╚═╝ ██╔══██╗██╔════╝██╔══██╗██╔═══██╗
4
+ ██╗ ██████╔╝█████╗ ██████╔╝██║ ██║
5
+ ██║ ████╗ ██╔══██╗██╔══╝ ██╔═══╝ ██║ ██║
6
+ ██║ ╚═══╝ ██║ ██║███████╗██║ ╚██████╔╝
7
+ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═════╝
8
+ ```
9
+
10
+ # i-Repo CLI
11
+
12
+ ConMas i-Reporter をターミナルから操作する CLI ツール。
13
+ 人間にも AI にもやさしい。
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install -g i-repo
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```bash
24
+ # 1. 環境変数をセット(推奨)
25
+ export IREPO_ENDPOINT="https://example.com/ConMasAPI/Rests/APIExecute.aspx"
26
+ export IREPO_USER="admin"
27
+ export IREPO_PASSWORD="secret"
28
+
29
+ # 2. 帳票を一覧
30
+ i-repo reports list
31
+
32
+ # 3. PDF をダウンロード
33
+ i-repo reports download REP-001 --file-type pdf
34
+ ```
35
+
36
+ これだけ。
37
+
38
+ ---
39
+
40
+ ## Setup
41
+
42
+ 認証情報の解決順序(上が優先):
43
+
44
+ 1. **CLI フラグ**: `--endpoint`, `--user`, `-p`
45
+ 2. **環境変数**: `IREPO_ENDPOINT`, `IREPO_USER`, `IREPO_PASSWORD`
46
+ 3. **Config ファイル**: `i-repo config set ...`
47
+
48
+ > パスワードはセキュリティ上 **ディスクに保存しない**。環境変数か `-p` フラグで渡す。
49
+
50
+ ### 対話的セットアップ
51
+
52
+ ```bash
53
+ i-repo auth login
54
+ # ? API Endpoint URL: https://example.com/ConMasAPI/Rests/APIExecute.aspx
55
+ # ? Username: admin
56
+ # ? Password: ****
57
+ # ✔ Authenticated successfully
58
+ # ℹ Endpoint and user saved to config.
59
+ # ℹ Password is NOT stored. Set IREPO_PASSWORD env var, or pass -p each time.
60
+ ```
61
+
62
+ ### 環境変数(推奨)
63
+
64
+ ```bash
65
+ export IREPO_ENDPOINT="https://example.com/ConMasAPI/Rests/APIExecute.aspx"
66
+ export IREPO_USER="admin"
67
+ export IREPO_PASSWORD="secret"
68
+ ```
69
+
70
+ `.bashrc` / `.zshrc` に書いておけば毎回入力不要。
71
+
72
+ ### Config コマンド
73
+
74
+ ```bash
75
+ i-repo config set endpoint https://example.com/ConMasAPI/Rests/APIExecute.aspx
76
+ i-repo config set user admin
77
+ i-repo config list
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Commands
83
+
84
+ ```
85
+ i-repo auth ログイン・ログアウト
86
+ i-repo config 設定管理
87
+ i-repo definitions 帳票定義の操作 (alias: def)
88
+ i-repo reports レポートの操作 (alias: rep)
89
+ i-repo definition-batches 定義の一括操作 (alias: defb)
90
+ i-repo report-batches レポートの一括操作 (alias: repb)
91
+ i-repo systems ユーザー・グループ管理 (alias: sys)
92
+ ```
93
+
94
+ ### Definitions (帳票定義)
95
+
96
+ ```bash
97
+ i-repo def list # 定義一覧
98
+ i-repo def list -w "点検" # キーワード検索
99
+ i-repo def get DEF-001 # 詳細表示
100
+ i-repo def lock DEF-001 # 排他ロック
101
+ i-repo def unlock DEF-001 # ロック解除
102
+ i-repo def roles download -t csv # 権限ファイル取得
103
+ i-repo def labels download -t csv # ラベル情報取得
104
+ ```
105
+
106
+ ### Reports (レポート)
107
+
108
+ ```bash
109
+ i-repo rep list # レポート一覧
110
+ i-repo rep list -e completed # 完了済みのみ
111
+ i-repo rep list -d DEF-001 # 定義IDで絞り込み
112
+ i-repo rep get REP-001 # 詳細表示
113
+ i-repo rep download REP-001 --file-type pdf # PDF取得
114
+ i-repo rep download REP-001 --file-type excel # Excel取得
115
+ i-repo rep copy REP-001 # コピー
116
+ i-repo rep lock REP-001 # 排他ロック
117
+ ```
118
+
119
+ ### Report Batches (一括操作)
120
+
121
+ ```bash
122
+ i-repo repb generate data.csv -t csv # CSV から帳票自動作成
123
+ i-repo repb update data.xml -t xml # XML で帳票更新
124
+ i-repo repb download -d DEF-001 -o reports.zip # 一括ダウンロード
125
+ i-repo repb download-csv REP-001 # CSV エクスポート
126
+ i-repo repb download-merged-pdf --reports '[{"repTopId":"REP-001"},{"repTopId":"REP-002"}]'
127
+ i-repo repb delete -d DEF-001 -e completed # 完了済みを削除
128
+ ```
129
+
130
+ ### Systems (管理)
131
+
132
+ ```bash
133
+ i-repo sys users download -t csv # ユーザー一覧
134
+ i-repo sys users upload users.csv -t csv # ユーザー登録
135
+ i-repo sys groups download -t csv # グループ一覧
136
+ i-repo sys terminals download -t csv # 端末情報
137
+ i-repo sys url-scheme # URLスキーム取得
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Output Formats
143
+
144
+ 人間が読むとき。AI が読むとき。用途に応じて切り替える。
145
+
146
+ ```bash
147
+ # テーブル(デフォルト - 人間向け)
148
+ i-repo rep list
149
+
150
+ # JSON(プログラム・AI 向け)
151
+ i-repo rep list --format json
152
+
153
+ # CSV(Excel・スプレッドシート向け)
154
+ i-repo rep list --format csv
155
+
156
+ # Quiet(ID だけ - パイプ向け)
157
+ i-repo rep list --quiet
158
+ ```
159
+
160
+ ### パイプで繋ぐ
161
+
162
+ **bash / zsh (macOS, Linux)**
163
+
164
+ ```bash
165
+ # 完了済みレポートを全件 PDF ダウンロード
166
+ i-repo rep list -e completed --quiet | xargs -I{} i-repo rep download {} --file-type pdf
167
+
168
+ # JSON を jq で加工
169
+ i-repo rep list --format json | jq '.[].name'
170
+
171
+ # CSV をファイルに保存
172
+ i-repo rep list --format csv > reports.csv
173
+ ```
174
+
175
+ **PowerShell (Windows)**
176
+
177
+ ```powershell
178
+ # 完了済みレポートを全件 PDF ダウンロード
179
+ i-repo rep list -e completed --quiet | ForEach-Object { i-repo rep download $_ --file-type pdf }
180
+
181
+ # JSON を PowerShell オブジェクトとして扱う
182
+ i-repo rep list --format json | ConvertFrom-Json | Select-Object -ExpandProperty name
183
+
184
+ # CSV をファイルに保存
185
+ i-repo rep list --format csv | Out-File -Encoding utf8 reports.csv
186
+ ```
187
+
188
+ **コマンドプロンプト (Windows)**
189
+
190
+ ```cmd
191
+ REM CSV をファイルに保存
192
+ i-repo rep list --format csv > reports.csv
193
+
194
+ REM 完了済みレポートを全件 PDF ダウンロード
195
+ for /f %i in ('i-repo rep list -e completed --quiet') do i-repo rep download %i --file-type pdf
196
+ ```
197
+
198
+ ---
199
+
200
+ ## AI から使う
201
+
202
+ i-Repo CLI は `--format json` と `--quiet` で AI ツールとの連携に最適化されている。
203
+
204
+ ### Claude Code / Claude Desktop
205
+
206
+ `AGENTS.md` に以下を記載:
207
+
208
+ ```markdown
209
+ ## i-Reporter 操作
210
+
211
+ i-Reporter の操作には `i-repo` CLI を使用する。
212
+
213
+ ### 認証
214
+ 環境変数で設定済み:
215
+ - IREPO_ENDPOINT: APIエンドポイント
216
+ - IREPO_USER / IREPO_PASSWORD: 認証情報
217
+
218
+ ### 使い方
219
+ - 一覧取得: `i-repo rep list --format json`
220
+ - 詳細取得: `i-repo rep get <id> --format json`
221
+ - ダウンロード: `i-repo rep download <id> --file-type pdf -o <path>`
222
+ - 定義一覧: `i-repo def list --format json`
223
+ - 一括操作: `i-repo repb generate <file> -t csv`
224
+
225
+ ### ルール
226
+ - 必ず `--format json` を付けて構造化データで受け取ること
227
+ - 削除・更新前に `--format json` で対象を確認すること
228
+ - ファイル操作は `-o` で保存先を明示すること
229
+ ```
230
+
231
+ ### OpenAI (ChatGPT / Function Calling)
232
+
233
+ ```python
234
+ import subprocess, json
235
+
236
+ def i_repo(args: str) -> dict:
237
+ """i-Reporter CLI を実行して JSON で結果を返す"""
238
+ result = subprocess.run(
239
+ f"i-repo {args} --format json",
240
+ shell=True, capture_output=True, text=True
241
+ )
242
+ return json.loads(result.stdout) if result.returncode == 0 else {
243
+ "error": result.stderr, "exit_code": result.returncode
244
+ }
245
+
246
+ # Function Calling で tools に登録
247
+ tools = [{
248
+ "type": "function",
249
+ "function": {
250
+ "name": "i_repo",
251
+ "description": "ConMas i-Reporter を操作する",
252
+ "parameters": {
253
+ "type": "object",
254
+ "properties": {
255
+ "args": {
256
+ "type": "string",
257
+ "description": "i-repo コマンドの引数。例: 'rep list -e completed'"
258
+ }
259
+ },
260
+ "required": ["args"]
261
+ }
262
+ }
263
+ }]
264
+
265
+ # 使用例
266
+ reports = i_repo("rep list -d DEF-001")
267
+ detail = i_repo(f"rep get {reports[0]['topId']}")
268
+ ```
269
+
270
+ ### CLI からパイプで AI に渡す
271
+
272
+ ```bash
273
+ # Claude
274
+ i-repo rep list --format json | claude "このレポート一覧を分析して、未完了のものをリストアップして"
275
+
276
+ # Gemini
277
+ i-repo rep list --format json | gemini -p "このデータから今週更新されたレポートを教えて"
278
+
279
+ # ChatGPT (openai CLI)
280
+ i-repo rep list --format json | openai api chat.completions.create \
281
+ -m gpt-4o -g user "このレポート一覧を要約して"
282
+
283
+ # ワンライナーで分析 (bash)
284
+ claude "$(i-repo rep list --format json | head -50) このデータから未完了レポートを教えて"
285
+ ```
286
+
287
+ ### Dify / LangChain / その他エージェント
288
+
289
+ ```bash
290
+ # シェルツール として登録する場合
291
+ command: i-repo rep list --format json
292
+ command: i-repo rep get {{report_id}} --format json
293
+ command: i-repo repb download -d {{definition_id}} -o {{output_path}}
294
+ ```
295
+
296
+ ---
297
+
298
+ ## Batch / CI/CD
299
+
300
+ ### シェルスクリプト
301
+
302
+ ```bash
303
+ #!/bin/bash
304
+ # daily-export.sh - 日次レポートエクスポート
305
+
306
+ set -euo pipefail
307
+
308
+ DATE=$(date +%Y%m%d)
309
+ OUTDIR="./exports/${DATE}"
310
+ mkdir -p "${OUTDIR}"
311
+
312
+ # 今日更新されたレポートを PDF で取得
313
+ i-repo rep list \
314
+ --update-from "$(date +%Y/%m/%d) 00:00:00" \
315
+ --quiet \
316
+ | while read -r id; do
317
+ i-repo rep download "${id}" --file-type pdf -o "${OUTDIR}/${id}.pdf"
318
+ echo "Downloaded: ${id}"
319
+ done
320
+
321
+ echo "Exported to ${OUTDIR}"
322
+ ```
323
+
324
+ ### cron
325
+
326
+ ```bash
327
+ # 毎日 23:00 にレポートをバックアップ
328
+ 0 23 * * * IREPO_ENDPOINT=https://... IREPO_USER=admin IREPO_PASSWORD=secret /usr/local/bin/i-repo repb download -d DEF-001 -o /backup/reports-$(date +\%Y\%m\%d).zip
329
+ ```
330
+
331
+ ### GitHub Actions
332
+
333
+ ```yaml
334
+ - name: Export i-Reporter data
335
+ env:
336
+ IREPO_ENDPOINT: ${{ secrets.IREPO_ENDPOINT }}
337
+ IREPO_USER: ${{ secrets.IREPO_USER }}
338
+ IREPO_PASSWORD: ${{ secrets.IREPO_PASSWORD }}
339
+ run: |
340
+ npx i-repo rep list --format csv > reports.csv
341
+ npx i-repo sys users download -t csv -o users.csv
342
+ ```
343
+
344
+ ---
345
+
346
+ ## Exit Codes
347
+
348
+ | Code | 意味 |
349
+ |------|------|
350
+ | 0 | 成功 |
351
+ | 1 | 認証エラー |
352
+ | 2 | セッション切れ |
353
+ | 3 | API エラー |
354
+ | 4 | HTTP エラー |
355
+ | 5 | ネットワークエラー |
356
+ | 10 | 設定不備 |
357
+ | 11 | 引数エラー |
358
+
359
+ ```bash
360
+ i-repo rep list || echo "Failed with exit code: $?"
361
+ ```
362
+
363
+ ---
364
+
365
+ ## Global Options
366
+
367
+ | Option | Short | Description |
368
+ |--------|-------|-------------|
369
+ | `--format <format>` | `-f` | 出力形式: `table` / `json` / `csv` |
370
+ | `--quiet` | `-q` | ID のみ出力(パイプ向け) |
371
+ | `--verbose` | | 詳細出力 |
372
+ | `--endpoint <url>` | `-e` | API エンドポイント |
373
+ | `--user <user>` | `-u` | ユーザー名 |
374
+ | `--password <pw>` | `-p` | パスワード |
375
+ | `--version` | `-v` | バージョン表示 |
376
+ | `--help` | `-h` | ヘルプ表示 |
377
+
378
+ ---
379
+
380
+ ## License
381
+
382
+ MIT
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Run the CLI program.
4
+ */
5
+ export declare function run(argv?: string[]): Promise<void>;
6
+ //# sourceMappingURL=irepo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"irepo.d.ts","sourceRoot":"","sources":["../../src/bin/irepo.ts"],"names":[],"mappings":";AA8CA;;GAEG;AACH,wBAAsB,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAOxD"}
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * irepo - Modern CLI for ConMas i-Reporter
4
+ *
5
+ * Main entry point. Commander-based program with subcommands.
6
+ */
7
+ import { Command } from "commander";
8
+ import { printBanner, printError } from "../ui/index.js";
9
+ import { authCommand } from "../commands/auth.js";
10
+ import { configCommand } from "../commands/config.js";
11
+ import { definitionsCommand } from "../commands/definitions/index.js";
12
+ import { reportsCommand } from "../commands/reports/index.js";
13
+ import { definitionBatchesCommand } from "../commands/definition-batches/index.js";
14
+ import { reportBatchesCommand } from "../commands/report-batches/index.js";
15
+ import { systemsCommand } from "../commands/systems/index.js";
16
+ const VERSION = "0.1.0";
17
+ const program = new Command();
18
+ program
19
+ .name("i-repo")
20
+ .description("Modern CLI for ConMas i-Reporter")
21
+ .version(VERSION, "-v, --version")
22
+ .option("-f, --format <format>", "Output format (table|json|csv)", "table")
23
+ .option("-q, --quiet", "Minimal output for scripting / AI tools")
24
+ .option("--verbose", "Show detailed output including debug info")
25
+ .option("-e, --endpoint <url>", "API endpoint URL (overrides config)")
26
+ .option("-u, --user <user>", "Username (overrides config)")
27
+ .option("-p, --password <password>", "Password");
28
+ // Register subcommands
29
+ program.addCommand(authCommand);
30
+ program.addCommand(configCommand);
31
+ program.addCommand(definitionsCommand);
32
+ program.addCommand(reportsCommand);
33
+ program.addCommand(definitionBatchesCommand);
34
+ program.addCommand(reportBatchesCommand);
35
+ program.addCommand(systemsCommand);
36
+ // Show banner when run without arguments
37
+ program.action(() => {
38
+ printBanner(VERSION);
39
+ program.help();
40
+ });
41
+ /**
42
+ * Run the CLI program.
43
+ */
44
+ export async function run(argv) {
45
+ try {
46
+ await program.parseAsync(argv ?? process.argv);
47
+ }
48
+ catch (error) {
49
+ printError(error);
50
+ process.exitCode = 1;
51
+ }
52
+ }
53
+ // Direct execution
54
+ run();
55
+ //# sourceMappingURL=irepo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"irepo.js","sourceRoot":"","sources":["../../src/bin/irepo.ts"],"names":[],"mappings":";AACA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAq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,EAAE;IAClB,WAAW,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAe;IACvC,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,UAAU,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,mBAAmB;AACnB,GAAG,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * irepo auth - Authentication commands
3
+ *
4
+ * Login, logout, and connection status.
5
+ */
6
+ import { Command } from "commander";
7
+ export declare const authCommand: Command;
8
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC,eAAO,MAAM,WAAW,SACmB,CAAC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * irepo auth - Authentication commands
3
+ *
4
+ * Login, logout, and connection status.
5
+ */
6
+ import { Command } from "commander";
7
+ import { input, password as passwordPrompt } from "@inquirer/prompts";
8
+ import { IReporterClient } from "i-repo-sdk";
9
+ import { getConfig, setConfig, deleteConfig, } from "../config/store.js";
10
+ import { printSuccess, printError, printWarning, printInfo, printDetails, withSpinner, } from "../ui/index.js";
11
+ export const authCommand = new Command("auth")
12
+ .description("Authentication management");
13
+ // ── auth login ───────────────────────────────────────────────
14
+ authCommand
15
+ .command("login")
16
+ .description("Authenticate with i-Reporter server")
17
+ .option("-u, --user <user>", "Username")
18
+ .option("-p, --password <password>", "Password")
19
+ .option("-e, --endpoint <url>", "API endpoint URL")
20
+ .action(async (opts) => {
21
+ try {
22
+ let { user, password, endpoint } = opts;
23
+ // Use stored endpoint if not provided
24
+ endpoint = endpoint ?? getConfig("endpoint");
25
+ // Interactive prompts for missing values
26
+ if (!endpoint) {
27
+ endpoint = await input({
28
+ message: "API Endpoint URL:",
29
+ validate: (v) => v.startsWith("http") || "Please enter a valid URL",
30
+ });
31
+ }
32
+ if (!user) {
33
+ user = await input({
34
+ message: "Username:",
35
+ validate: (v) => v.length > 0 || "Username is required",
36
+ });
37
+ }
38
+ if (!password) {
39
+ password = await passwordPrompt({
40
+ message: "Password:",
41
+ mask: "*",
42
+ validate: (v) => v.length > 0 || "Password is required",
43
+ });
44
+ }
45
+ // Authenticate via login() and verify with a lightweight API call
46
+ await withSpinner("authenticating", async () => {
47
+ const client = new IReporterClient({
48
+ apiEndpoint: endpoint,
49
+ });
50
+ await client.login({ user, password });
51
+ // Verify the session works with a lightweight call
52
+ await client.systems.getUrlScheme();
53
+ }, {
54
+ successText: "Authenticated successfully",
55
+ failText: "Authentication failed",
56
+ });
57
+ // Save endpoint and user (password is NOT stored for security)
58
+ setConfig("endpoint", endpoint);
59
+ setConfig("user", user);
60
+ printSuccess(`Logged in as ${user}`);
61
+ printInfo("Endpoint and user saved to config.");
62
+ printInfo("Password is NOT stored. Set IREPO_PASSWORD env var, or pass -p each time.");
63
+ }
64
+ catch (error) {
65
+ printError(error);
66
+ process.exitCode = 1;
67
+ }
68
+ });
69
+ // ── auth logout ──────────────────────────────────────────────
70
+ authCommand
71
+ .command("logout")
72
+ .description("Clear stored credentials")
73
+ .action(() => {
74
+ try {
75
+ deleteConfig("user");
76
+ printSuccess("Logged out successfully. Stored user cleared.");
77
+ }
78
+ catch (error) {
79
+ printError(error);
80
+ process.exitCode = 1;
81
+ }
82
+ });
83
+ // ── auth status (alias: whoami) ──────────────────────────────
84
+ authCommand
85
+ .command("status")
86
+ .alias("whoami")
87
+ .description("Show current connection info")
88
+ .action(() => {
89
+ try {
90
+ const endpoint = getConfig("endpoint");
91
+ const user = getConfig("user");
92
+ if (!endpoint && !user) {
93
+ printWarning("Not configured. Run \"i-repo auth login\" to get started.");
94
+ return;
95
+ }
96
+ printDetails("Connection Info", {
97
+ "Endpoint": endpoint ?? "(not set)",
98
+ "User": user ?? "(not set)",
99
+ });
100
+ }
101
+ catch (error) {
102
+ printError(error);
103
+ process.exitCode = 1;
104
+ }
105
+ });
106
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EACL,SAAS,EACT,SAAS,EACT,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,2BAA2B,CAAC,CAAC;AAE5C,gEAAgE;AAChE,WAAW;KACR,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,qCAAqC,CAAC;KAClD,MAAM,CAAC,mBAAmB,EAAE,UAAU,CAAC;KACvC,MAAM,CAAC,2BAA2B,EAAE,UAAU,CAAC;KAC/C,MAAM,CAAC,sBAAsB,EAAE,kBAAkB,CAAC;KAClD,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACrB,IAAI,CAAC;QACH,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAExC,s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C,OAAO,KAAK,EAAE,CAAC;QACf,UAAU,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * irepo config - Configuration management commands
3
+ *
4
+ * Get, set, list, and reset CLI configuration.
5
+ */
6
+ import { Command } from "commander";
7
+ export declare const configCommand: Command;
8
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBpC,eAAO,MAAM,aAAa,SACoB,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * irepo config - Configuration management commands
3
+ *
4
+ * Get, set, list, and reset CLI configuration.
5
+ */
6
+ import { Command } from "commander";
7
+ import { getConfig, setConfig, resetConfig, getAllConfig, validKeys, isValidKey, } from "../config/store.js";
8
+ import { printSuccess, printError, printWarning, printDetails, printInfo, t, } from "../ui/index.js";
9
+ export const configCommand = new Command("config")
10
+ .description("CLI configuration management");
11
+ // ── config set ───────────────────────────────────────────────
12
+ configCommand
13
+ .command("set <key> <value>")
14
+ .description("Set a configuration value")
15
+ .action((key, value) => {
16
+ try {
17
+ if (!isValidKey(key)) {
18
+ printWarning(`Unknown key "${key}". Valid keys: ${validKeys.join(", ")}`);
19
+ process.exitCode = 1;
20
+ return;
21
+ }
22
+ // Validate format value
23
+ if (key === "defaultFormat" && !["table", "json", "csv"].includes(value)) {
24
+ printWarning('Invalid format. Must be one of: table, json, csv');
25
+ process.exitCode = 1;
26
+ return;
27
+ }
28
+ setConfig(key, value);
29
+ printSuccess(`${key} = ${value}`);
30
+ }
31
+ catch (error) {
32
+ printError(error);
33
+ process.exitCode = 1;
34
+ }
35
+ });
36
+ // ── config get ───────────────────────────────────────────────
37
+ configCommand
38
+ .command("get <key>")
39
+ .description("Get a configuration value")
40
+ .action((key) => {
41
+ try {
42
+ if (!isValidKey(key)) {
43
+ printWarning(`Unknown key "${key}". Valid keys: ${validKeys.join(", ")}`);
44
+ process.exitCode = 1;
45
+ return;
46
+ }
47
+ const value = getConfig(key);
48
+ if (value === undefined) {
49
+ printInfo(`${key} is not set`);
50
+ }
51
+ else {
52
+ console.log(` ${t.muted(key)} = ${t.text(String(value))}`);
53
+ }
54
+ }
55
+ catch (error) {
56
+ printError(error);
57
+ process.exitCode = 1;
58
+ }
59
+ });
60
+ // ── config list ──────────────────────────────────────────────
61
+ configCommand
62
+ .command("list")
63
+ .description("List all configuration values")
64
+ .action(() => {
65
+ try {
66
+ const all = getAllConfig();
67
+ const entries = Object.entries(all);
68
+ if (entries.length === 0) {
69
+ printInfo("No configuration values set");
70
+ return;
71
+ }
72
+ const display = {};
73
+ for (const key of validKeys) {
74
+ const value = all[key];
75
+ display[key] = value !== undefined ? String(value) : "(not set)";
76
+ }
77
+ printDetails("Configuration", display);
78
+ }
79
+ catch (error) {
80
+ printError(error);
81
+ process.exitCode = 1;
82
+ }
83
+ });
84
+ // ── config reset ─────────────────────────────────────────────
85
+ configCommand
86
+ .command("reset")
87
+ .description("Reset all configuration to defaults")
88
+ .action(() => {
89
+ try {
90
+ resetConfig();
91
+ printSuccess("Configuration reset to defaults");
92
+ }
93
+ catch (error) {
94
+ printError(error);
95
+ process.exitCode = 1;
96
+ }
97
+ });
98
+ //# sourceMappingURL=config.js.map