@rex0220/kintone-sql-tools 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/LICENSE +21 -0
- package/README.md +187 -0
- package/dist-cli/ksql.js +7402 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rex0220
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
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 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
|
+
## 機密情報の取り扱い
|
|
172
|
+
|
|
173
|
+
- token / password は直書きせず、環境変数または `env:` 参照を推奨します。
|
|
174
|
+
- `ksql.config.json` はローカル運用ファイルとして `.gitignore` 済みです。
|
|
175
|
+
- `private.ppk` / `pluginId.txt` は `.gitignore` 済みです。
|
|
176
|
+
|
|
177
|
+
## ドキュメント
|
|
178
|
+
|
|
179
|
+
- [Docs Index](docs/README.md)
|
|
180
|
+
- [言語リファレンス](docs/ksql_language_reference.md)
|
|
181
|
+
- [CLI / Console 仕様](docs/ksql_cli_console_spec.md)
|
|
182
|
+
- [APP@profile 仕様](docs/cli_app_profile_spec.md)
|
|
183
|
+
- [公開前チェックリスト](docs/internal/public_release_checklist.md)
|
|
184
|
+
|
|
185
|
+
## ライセンス
|
|
186
|
+
|
|
187
|
+
MIT License. See [LICENSE](LICENSE).
|