@rex0220/kintone-sql-tools 3.68.0 → 3.70.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
@@ -259,6 +259,44 @@ Options:
259
259
  6. Windows で `ksql --help` 実行時にエディタが開いてしまう
260
260
  - `.js` 関連付けの影響の可能性があります。`ksql.cmd --help` または `node dist-cli/ksql.js --help` で確認してください。
261
261
 
262
+ ## 公式 API(プログラムから使う)
263
+
264
+ npm パッケージは 2 つのサブパスを **semver 対象の公開 API** として提供します。
265
+ ここに載る export のシグネチャ・挙動の互換性は semver(破壊的変更=メジャー、追加=マイナー)で管理します。
266
+
267
+ | サブパス | 用途 | 主な export |
268
+ |---|---|---|
269
+ | `@rex0220/kintone-sql-tools/engine` | **read-only** のクエリ実行(ダッシュボード等)。書込 API は構造的に遮断 | `runQuery` / `runBatch` / `explainQuery` / `createReadonlyKintoneClient` / `KsqlEngineError` / `version` |
270
+ | `@rex0220/kintone-sql-tools/flow` | **Flow dialect 1**(→ [言語リファレンス §27](docs/ksql_language_reference.md))のスクリプト解析・検証・**文単位実行**(バッチランナー向け・書込可能) | `parseScript` / `validateScript` / `explainScript`(`asOf`/`timezone` 注入可) / `createExecutionContext`(`onChunkWritten` 書込チャンク通知) / `executeStatement` / `disposeExecutionContext` / `createKintoneClient` / `isDmlResult`(`FlowDmlResult` 型ガード) / `version` |
271
+
272
+ `/flow` の典型的な使い方(1 文ずつ実行して結果で継続判断する):
273
+
274
+ ```ts
275
+ import { parseScript, createExecutionContext, executeStatement, disposeExecutionContext, createKintoneClient } from "@rex0220/kintone-sql-tools/flow";
276
+
277
+ const client = createKintoneClient({ baseUrl, auth: { type: "apiToken", apiToken } });
278
+ const { statements, meta, diagnostics } = parseScript(source, { apps: { 受注: 100 } });
279
+ const ctx = createExecutionContext({ client, script: source, apps: { 受注: 100, 顧客マスタ: 200 }, asOf: new Date("2026-08-01T00:00:00+09:00"), timezone: "Asia/Tokyo" });
280
+ try {
281
+ for (const stmt of statements) {
282
+ const result = await executeStatement(stmt, ctx);
283
+ // result で ASSERT 違反 / EXIT 成立 / skipped を判別して継続を判断する
284
+ }
285
+ } finally {
286
+ await disposeExecutionContext(ctx);
287
+ }
288
+ ```
289
+
290
+ ### エンジンバージョン × dialect 対応表
291
+
292
+ | エンジン | dialect 0(既定・宣言なし) | dialect 1(`-- @ksql dialect: 1`) |
293
+ |---|---|---|
294
+ | 〜 v3.67.0 | ✅ | —(未実装) |
295
+ | v3.68.0 | ✅ | 解析のみ(エンジン内部 API。実行できる出荷面なし・実験的) |
296
+ | v3.69.0 〜 | ✅ | ✅ CLI / MCP / プラグイン / `/flow` で実行可 |
297
+
298
+ dialect は後方互換で管理します: dialect 0 のスクリプトはどのエンジン版でも挙動不変・破壊的変更は dialect 番号の繰り上げでのみ導入します。変更履歴は [CHANGELOG.md](CHANGELOG.md) を参照してください。
299
+
262
300
  ## 機密情報の取り扱い
263
301
 
264
302
  - token / password は直書きせず、環境変数または `env:` 参照を推奨します。