@rex0220/kintone-sql-tools 1.1.2 → 1.3.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
@@ -1,190 +1,191 @@
1
- # kintone-sql-tools
2
-
3
- kintone アプリを SQL 風の構文で操作するツールセットです。
4
-
5
- - kintone プラグイン(UI)
6
- - CLI(`ksql`)
7
-
8
- ## 機能概要
9
-
10
- - `SELECT`(JOIN/GROUP BY/HAVING/CTE/UNION)
11
- - `INSERT` / `UPDATE` / `UPSERT` / `DELETE`(`--allow-dml` 必須)
12
- - `EXPLAIN`
13
- - サブテーブル仮想テーブル(`APP100$明細`)
14
- - CLI 拡張 `APP@profile`
15
- - 同一 SQL 内で同一 APP の profile 混在を許可
16
- - `INSERT/UPDATE/UPSERT` 対応、`DELETE` は未対応
17
- - `FROM` 省略 SELECT(例: `SELECT 'xxx' AS a`)
18
-
19
- ## インストール
20
-
21
- ## npm(グローバル)
22
-
23
- ```bash
24
- npm install -g @rex0220/kintone-sql-tools
25
- ksql --help
26
- ```
27
-
28
- ## ローカル開発
29
-
30
- ```bash
31
- npm install
32
- npm run build:cli
33
- node dist-cli/ksql.js --help
34
- ```
35
-
36
- プラグインをビルドする場合:
37
-
38
- ```bash
39
- npm run build:plugin
40
- ```
41
-
42
- ## 使い分け(CLI / Plugin)
43
-
44
- - CLI を使うケース:
45
- - バッチ実行
46
- - CI/CD 連携
47
- - `APP@profile` を使った環境切替
48
- - `--dry-run` / `EXPLAIN` による安全確認
49
-
50
- - Plugin を使うケース:
51
- - kintone 画面内での対話操作
52
- - 非エンジニア向けの運用
53
- - UI で結果確認したい場合
54
-
55
- 注意:
56
-
57
- - `@profile` は CLI 拡張です。plugin 側では非対応です。
58
-
59
- ## 最短実行例(CLI)
60
-
61
- ```bash
62
- node dist-cli/ksql.js --base-url https://example.cybozu.com --token xxx -e "SELECT * FROM APP100 LIMIT 5"
63
- ```
64
-
65
- `FROM` 省略 SELECT:
66
-
67
- ```bash
68
- node dist-cli/ksql.js -e "SELECT 'xxx' AS a"
69
- ```
70
-
71
- DML(確認付き):
72
-
73
- ```bash
74
- node dist-cli/ksql.js \
75
- --base-url https://example.cybozu.com \
76
- --token xxx \
77
- --allow-dml \
78
- -e "UPDATE APP100 SET 状態 = '完了' WHERE ステータス = '未着手'"
79
- ```
80
-
81
- コンソール:
82
-
83
- ```bash
84
- node dist-cli/ksql.js --console --base-url https://example.cybozu.com --token xxx
85
- ```
86
-
87
- ## 設定ファイル
88
-
89
- - 既定: `./ksql.config.json`
90
- - profile 切替: `--profile <name>`
91
-
92
- 例:
93
-
94
- ```bash
95
- node dist-cli/ksql.js --config ./ksql.config.json --profile dev -e "SELECT * FROM APP100"
96
- ```
97
-
98
- ## CLI オプション
99
-
100
- <!-- BEGIN_HELP_SYNC -->
101
- ```text
102
- ksql - Execute SQL against kintone apps
103
-
104
- Usage:
105
- ksql [options]
106
- ksql -e "<SQL>"
107
- ksql -f <file.sql>
108
-
109
- Options:
110
- -e, --execute <sql> Execute SQL string
111
- -f, --file <path> Execute SQL file
112
- --console Start interactive console mode
113
- --dry-run Parse and show execution plan only
114
- --format <type> Output format: table | json | jsonl | csv | markdown | md
115
- --max-records <n> Max records to fetch (default: 500)
116
- --on-limit <mode> On record limit: error | truncate
117
- --timeout <ms> Request timeout in milliseconds (default: 30000)
118
- --config <path> Config file path (default: ./ksql.config.json)
119
- --profile <name> Profile name in config
120
- --base-url <url> kintone base URL
121
- --guest-space-id <id> Guest space ID (uses /k/guest/<id>/v1 APIs)
122
- --auth <type> Auth type: token | userpass | auto
123
- --username <name> Login username (for userpass auth)
124
- --password <pass> Login password (for userpass auth)
125
- --token <token> Single-app token
126
- --token-map <mapping> App token map (APP100=...,APP101=...)
127
- --token-file <path> JSON file for app token map
128
- --app <id> Default app id context
129
- --diag-record-id <id> Diagnostic: GET record.json by app+id
130
- --no-header Hide table header
131
- --pretty Pretty-print JSON output
132
- --user-format <mode> User field format: full | name | code
133
- --array-format <mode> Array field format: full | join
134
- --table-format <mode> Subtable format: full | count
135
- --date-format <mode> Date format: full | local
136
- --attachment-format <mode> Attachment format: full | name | fileKey
137
- --output <path> Write output to file
138
- --no-color Disable ANSI colors
139
- --quiet Suppress non-result logs
140
- --debug Show request/response debug logs
141
- --debug-url Show only HTTP request URL debug logs
142
- --debug-headers Show request headers in debug logs (masked)
143
- --exit-on-empty Return exit code 1 when rowCount is 0
144
- --allow-dml Enable UPDATE/DELETE/INSERT/UPSERT execution
145
- --yes Skip DML confirmation prompt
146
- --allow-without-where Allow UPDATE/DELETE without WHERE
147
- --dml-max-rows <n> Max affected rows for DML guard (default: 100)
148
- -h, --help Show help
149
- -v, --version Show version
150
- ```
151
- <!-- END_HELP_SYNC -->
152
-
153
- ## 最低限のトラブルシュート
154
-
155
- 1. `ArgumentError: no APPxxx found...`
156
- - `FROM` ありクエリでは `APPxxx` 指定が必要です。
157
- - `SELECT 'xxx' AS a` のような式 SELECT は実行可能です。
158
-
159
- 2. `AuthError: token is missing...`
160
- - `--token-map` / `--token-file` / config の `tokenMap` を確認してください。
161
-
162
- 3. `ArgumentError: unknown field code(s)...`
163
- - フィールドコード名を確認してください(ラベル名ではなくコード)。
164
-
165
- 4. `DML is disabled`
166
- - `--allow-dml` を付けて再実行してください。
167
-
168
- 5. `@profile` を使った DELETE が失敗する
169
- - 現在 `DELETE` の `@profile` は未対応です。
170
-
171
- 6. Windows で `ksql --help` 実行時にエディタが開いてしまう
172
- - `.js` 関連付けの影響の可能性があります。`ksql.cmd --help` または `node dist-cli/ksql.js --help` で確認してください。
173
-
174
- ## 機密情報の取り扱い
175
-
176
- - token / password は直書きせず、環境変数または `env:` 参照を推奨します。
177
- - `ksql.config.json` はローカル運用ファイルとして `.gitignore` 済みです。
178
- - `private.ppk` / `pluginId.txt` `.gitignore` 済みです。
179
-
180
- ## ドキュメント
181
-
182
- - [Docs Index](docs/README.md)
183
- - [言語リファレンス](docs/ksql_language_reference.md)
184
- - [CLI / Console 仕様](docs/ksql_cli_console_spec.md)
185
- - [APP@profile 仕様](docs/cli_app_profile_spec.md)
186
- - [公開前チェックリスト](docs/internal/public_release_checklist.md)
187
-
188
- ## ライセンス
189
-
190
- MIT License. See [LICENSE](LICENSE).
1
+ # kintone-sql-tools
2
+
3
+ kintone アプリを SQL 風の構文で操作するツールセットです。
4
+
5
+ - kintone プラグイン(UI)
6
+ - CLI(`ksql`)
7
+
8
+ ## 機能概要
9
+
10
+ - `SELECT`(JOIN/GROUP BY/HAVING/CTE/UNION)
11
+ - `INSERT` / `UPDATE` / `UPSERT` / `DELETE` / `REORDER`(`--allow-dml` 必須)
12
+ - `EXPLAIN`
13
+ - サブテーブル仮想テーブル(`APP100$明細`)
14
+ - CLI 拡張 `APP@profile`
15
+ - 同一 SQL 内で同一 APP の profile 混在を許可
16
+ - `INSERT/UPDATE/UPSERT` 対応、`DELETE` は未対応
17
+ - `FROM` 省略 SELECT(例: `SELECT 'xxx' AS a`)
18
+
19
+ ## インストール
20
+
21
+ ## npm(グローバル)
22
+
23
+ ```bash
24
+ npm install -g @rex0220/kintone-sql-tools
25
+ ksql --help
26
+ ```
27
+
28
+ ## ローカル開発
29
+
30
+ ```bash
31
+ npm install
32
+ npm run build:cli
33
+ node dist-cli/ksql.js --help
34
+ ```
35
+
36
+ プラグインをビルドする場合:
37
+
38
+ ```bash
39
+ npm run build:plugin
40
+ ```
41
+
42
+ ## 使い分け(CLI / Plugin)
43
+
44
+ - CLI を使うケース:
45
+ - バッチ実行
46
+ - CI/CD 連携
47
+ - `APP@profile` を使った環境切替
48
+ - `--dry-run` / `EXPLAIN` による安全確認
49
+
50
+ - Plugin を使うケース:
51
+ - kintone 画面内での対話操作
52
+ - 非エンジニア向けの運用
53
+ - UI で結果確認したい場合
54
+
55
+ 注意:
56
+
57
+ - `@profile` は CLI 拡張です。plugin 側では非対応です。
58
+
59
+ ## 最短実行例(CLI)
60
+
61
+ ```bash
62
+ node dist-cli/ksql.js --base-url https://example.cybozu.com --token xxx -e "SELECT * FROM APP100 LIMIT 5"
63
+ ```
64
+
65
+ `FROM` 省略 SELECT:
66
+
67
+ ```bash
68
+ node dist-cli/ksql.js -e "SELECT 'xxx' AS a"
69
+ ```
70
+
71
+ DML(確認付き):
72
+
73
+ ```bash
74
+ node dist-cli/ksql.js \
75
+ --base-url https://example.cybozu.com \
76
+ --token xxx \
77
+ --allow-dml \
78
+ -e "UPDATE APP100 SET 状態 = '完了' WHERE ステータス = '未着手'"
79
+ ```
80
+
81
+ コンソール:
82
+
83
+ ```bash
84
+ node dist-cli/ksql.js --console --base-url https://example.cybozu.com --token xxx
85
+ ```
86
+
87
+ ## 設定ファイル
88
+
89
+ - 既定: `./ksql.config.json`
90
+ - profile 切替: `--profile <name>`
91
+
92
+ 例:
93
+
94
+ ```bash
95
+ node dist-cli/ksql.js --config ./ksql.config.json --profile dev -e "SELECT * FROM APP100"
96
+ ```
97
+
98
+ ## CLI オプション
99
+
100
+ <!-- BEGIN_HELP_SYNC -->
101
+ ```text
102
+ ksql - Execute SQL against kintone apps
103
+
104
+ Usage:
105
+ ksql [options]
106
+ ksql -e "<SQL>"
107
+ ksql -f <file.sql>
108
+
109
+ Options:
110
+ -e, --execute <sql> Execute SQL string
111
+ -f, --file <path> Execute SQL file
112
+ --console Start interactive console mode
113
+ --dry-run Parse and show execution plan only
114
+ --format <type> Output format: table | json | jsonl | csv | markdown | md
115
+ --max-records <n> Max records to fetch (default: 500)
116
+ --fetch-parallel <n> Parallel page fetches per query: 1-10 (default: 3)
117
+ --on-limit <mode> On record limit: error | truncate
118
+ --timeout <ms> Request timeout in milliseconds (default: 30000)
119
+ --config <path> Config file path (default: ./ksql.config.json)
120
+ --profile <name> Profile name in config
121
+ --base-url <url> kintone base URL
122
+ --guest-space-id <id> Guest space ID (uses /k/guest/<id>/v1 APIs)
123
+ --auth <type> Auth type: token | userpass | auto
124
+ --username <name> Login username (for userpass auth)
125
+ --password <pass> Login password (for userpass auth)
126
+ --token <token> Single-app token
127
+ --token-map <mapping> App token map (APP100=...,APP101=...)
128
+ --token-file <path> JSON file for app token map
129
+ --app <id> Default app id context
130
+ --diag-record-id <id> Diagnostic: GET record.json by app+id
131
+ --no-header Hide table header
132
+ --pretty Pretty-print JSON output
133
+ --user-format <mode> User field format: full | name | code
134
+ --array-format <mode> Array field format: full | join
135
+ --table-format <mode> Subtable format: full | count
136
+ --date-format <mode> Date format: full | local
137
+ --attachment-format <mode> Attachment format: full | name | fileKey
138
+ --output <path> Write output to file
139
+ --no-color Disable ANSI colors
140
+ --quiet Suppress non-result logs
141
+ --debug Show request/response debug logs
142
+ --debug-url Show only HTTP request URL debug logs
143
+ --debug-headers Show request headers in debug logs (masked)
144
+ --exit-on-empty Return exit code 1 when rowCount is 0
145
+ --allow-dml Enable UPDATE/DELETE/INSERT/UPSERT/REORDER execution
146
+ --yes Skip DML confirmation prompt
147
+ --allow-without-where Allow UPDATE/DELETE without WHERE
148
+ --dml-max-rows <n> Max affected rows for DML guard (default: 100)
149
+ -h, --help Show help
150
+ -v, --version Show version
151
+ ```
152
+ <!-- END_HELP_SYNC -->
153
+
154
+ ## 最低限のトラブルシュート
155
+
156
+ 1. `ArgumentError: no APPxxx found...`
157
+ - `FROM` ありクエリでは `APPxxx` 指定が必要です。
158
+ - `SELECT 'xxx' AS a` のような式 SELECT は実行可能です。
159
+
160
+ 2. `AuthError: token is missing...`
161
+ - `--token-map` / `--token-file` / config の `tokenMap` を確認してください。
162
+
163
+ 3. `ArgumentError: unknown field code(s)...`
164
+ - フィールドコード名を確認してください(ラベル名ではなくコード)。
165
+
166
+ 4. `DML is disabled`
167
+ - `--allow-dml` を付けて再実行してください。
168
+
169
+ 5. `@profile` を使った DELETE が失敗する
170
+ - 現在 `DELETE` の `@profile` は未対応です。
171
+
172
+ 6. Windows `ksql --help` 実行時にエディタが開いてしまう
173
+ - `.js` 関連付けの影響の可能性があります。`ksql.cmd --help` または `node dist-cli/ksql.js --help` で確認してください。
174
+
175
+ ## 機密情報の取り扱い
176
+
177
+ - token / password は直書きせず、環境変数または `env:` 参照を推奨します。
178
+ - `ksql.config.json` はローカル運用ファイルとして `.gitignore` 済みです。
179
+ - `private.ppk` / `pluginId.txt` は `.gitignore` 済みです。
180
+
181
+ ## ドキュメント
182
+
183
+ - [Docs Index](docs/README.md)
184
+ - [言語リファレンス](docs/ksql_language_reference.md)
185
+ - [CLI / Console 仕様](docs/ksql_cli_console_spec.md)
186
+ - [APP@profile 仕様](docs/cli_app_profile_spec.md)
187
+ - [公開前チェックリスト](docs/internal/public_release_checklist.md)
188
+
189
+ ## ライセンス
190
+
191
+ MIT License. See [LICENSE](LICENSE).