@rex0220/kintone-sql-tools 1.12.1 → 1.13.2

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
@@ -16,9 +16,13 @@ kintone アプリを SQL 風の構文で操作するツールセットです。
16
16
  - プラグイン: read-only バッチのみ(最終結果を表示)
17
17
  - **`ASSERT`(実行時ゲート。DML 前の件数ガード / CLI ヘルスチェック)**(v1.10.0)
18
18
  - サブテーブル仮想テーブル(`APP100$明細`)
19
- - CLI 拡張 `APP@profile`
20
- - 同一 SQL 内で同一 APP の profile 混在を許可
21
- - `INSERT/UPDATE/UPSERT` 対応、`DELETE` は未対応
19
+ - CLI 拡張 `APP@profile`
20
+ - 同一 SQL 内で同一 APP の profile 混在を許可
21
+ - `INSERT/UPDATE/UPSERT` 対応、`DELETE` は未対応
22
+ - CLI / MCP の論理アプリ参照 `LAPP_<NAME>`
23
+ - profile ごとの `logicalApps` で、同じ SQL を異なる物理アプリ ID へ安全に解決
24
+ - `APP100` は常に物理 ID 100 のまま(暗黙変換なし)
25
+ - `allowPhysicalAppRefs: false` で、その profile の物理 `APPxxx` 直接参照を禁止可能
22
26
  - `FROM` 省略 SELECT(例: `SELECT 'xxx' AS a`)
23
27
 
24
28
  ## インストール
@@ -46,10 +50,11 @@ npm run build:plugin
46
50
 
47
51
  ## 使い分け(CLI / Plugin)
48
52
 
49
- - CLI を使うケース:
53
+ - CLI を使うケース:
50
54
  - DML を含むバッチ実行・SQL ファイル実行(`-f`)
51
55
  - CI/CD 連携
52
- - `APP@profile` を使った環境切替
56
+ - `APP@profile` を使った環境切替
57
+ - `LAPP_<NAME>` を使った配置非依存 SQL
53
58
  - `--dry-run` / `EXPLAIN` による安全確認
54
59
 
55
60
  - Plugin を使うケース:
@@ -57,13 +62,14 @@ npm run build:plugin
57
62
  - 非エンジニア向けの運用
58
63
  - UI で結果確認したい場合
59
64
 
60
- - MCP を使うケース:
65
+ - MCP を使うケース:
61
66
  - Claude 等の AI クライアントから kintone を照会・更新
62
- - 一時テーブルで中間結果をサーバー内に保持し、AI のコンテキスト消費を抑えたい場合
67
+ - 一時テーブルで中間結果をサーバー内に保持し、AI のコンテキスト消費を抑えたい場合
68
+ - validation / EXPLAIN で論理名から最終的な物理アプリ ID への解決を確認したい場合
63
69
 
64
70
  注意:
65
71
 
66
- - `@profile` は CLI 拡張です。plugin 側では非対応です。
72
+ - `APP@profile` と `LAPP_<NAME>[@profile]` Node.js runtime(CLI / MCP)の拡張です。plugin 側では非対応です。
67
73
 
68
74
  ## 最短実行例(CLI)
69
75
 
@@ -98,11 +104,39 @@ node dist-cli/ksql.js --console --base-url https://example.cybozu.com --token xx
98
104
  - 既定: `./ksql.config.json`
99
105
  - profile 切替: `--profile <name>`
100
106
 
101
- 例:
107
+ 例:
102
108
 
103
109
  ```bash
104
- node dist-cli/ksql.js --config ./ksql.config.json --profile dev -e "SELECT * FROM APP100"
105
- ```
110
+ node dist-cli/ksql.js --config ./ksql.config.json --profile dev -e "SELECT * FROM APP100"
111
+ ```
112
+
113
+ 論理アプリ参照を使う場合、profile ごとに論理名と物理 ID を定義します。
114
+
115
+ ```json
116
+ {
117
+ "defaultProfile": "dev",
118
+ "profiles": {
119
+ "dev": {
120
+ "baseUrl": "https://dev.example.cybozu.com",
121
+ "logicalApps": { "ORDERS": 100 },
122
+ "tokenMap": { "APP100": "env:DEV_ORDERS_TOKEN" }
123
+ },
124
+ "prod": {
125
+ "baseUrl": "https://prod.example.cybozu.com",
126
+ "allowPhysicalAppRefs": false,
127
+ "logicalApps": { "ORDERS": 1200 },
128
+ "tokenMap": { "APP1200": "env:PROD_ORDERS_TOKEN" }
129
+ }
130
+ }
131
+ }
132
+ ```
133
+
134
+ ```bash
135
+ node dist-cli/ksql.js --config ./ksql.config.json --profile dev -e "SELECT * FROM LAPP_ORDERS"
136
+ node dist-cli/ksql.js --config ./ksql.config.json --profile prod -e "SELECT * FROM LAPP_ORDERS"
137
+ ```
138
+
139
+ どちらも同じ SQL ですが、前者は `APP100`、後者は `APP1200` に解決されます。`logicalApps` のキーは `LAPP_` を付けない ASCII 論理名です。`APP100`、`100`、`LAPP_ORDERS` は設定キーとして拒否されます。
106
140
 
107
141
  ## CLI オプション
108
142
 
@@ -202,7 +236,7 @@ Options:
202
236
  - [CLI / Console 仕様](docs/ksql_cli_console_spec.md)
203
237
  - [バッチ実行・一時テーブル仕様](docs/ksql_batch_temp_table_spec.md)
204
238
  - [MCP サーバー仕様](docs/ksql_mcp_server_spec.md) / [Claude Desktop への導入(MCPB)](docs/ksql_mcpb_claude_desktop_install.md)
205
- - [APP@profile 仕様](docs/cli_app_profile_spec.md)
239
+ - [APP@profile 仕様](docs/cli_app_profile_spec.md)
206
240
  - [公開前チェックリスト](docs/internal/public_release_checklist.md)
207
241
 
208
242
  ## ライセンス