@rex0220/kintone-sql-tools 3.69.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 +1 -1
- package/dist-cli/ksql.js +12 -5
- package/dist-engine/index.cjs +14 -14
- package/dist-engine/index.mjs +14 -14
- package/dist-engine/ksql-engine.umd.js +14 -14
- package/dist-engine/meta/bundle-baseline.json +7 -7
- package/dist-engine/meta/cjs.json +3 -3
- package/dist-engine/meta/esm.json +3 -3
- package/dist-engine/meta/umd.json +3 -3
- package/dist-flow/flow-library/index.d.ts +2 -1
- package/dist-flow/flow-library/publicTypes.d.ts +46 -0
- package/dist-flow/index.cjs +13 -13
- package/dist-flow/index.mjs +13 -13
- package/dist-flow/meta/cjs.json +18 -5
- package/dist-flow/meta/esm.json +19 -5
- package/dist-mcp/ksql-mcp.js +14 -7
- package/dist-mcpb/ksql-mcp.mcpb +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -267,7 +267,7 @@ npm パッケージは 2 つのサブパスを **semver 対象の公開 API**
|
|
|
267
267
|
| サブパス | 用途 | 主な export |
|
|
268
268
|
|---|---|---|
|
|
269
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` / `createExecutionContext` / `executeStatement` / `disposeExecutionContext` / `createKintoneClient` / `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
271
|
|
|
272
272
|
`/flow` の典型的な使い方(1 文ずつ実行して結果で継続判断する):
|
|
273
273
|
|
package/dist-cli/ksql.js
CHANGED
|
@@ -18725,7 +18725,7 @@ async function executeParsedStatement(stmt, client, options, cacheContext) {
|
|
|
18725
18725
|
if (stmt.type !== "EXPLAIN") assertRelativeDatePushdownPlan(relativeDatePlan);
|
|
18726
18726
|
const unresolved = findVariableRef(stmt);
|
|
18727
18727
|
if (unresolved !== null && !isApplyParentKlikeStatement(stmt)) {
|
|
18728
|
-
throw new Error(
|
|
18728
|
+
throw new Error(undefinedBatchVariableMessage(unresolved, "in a batch"));
|
|
18729
18729
|
}
|
|
18730
18730
|
assertApplyScope("phase15b", stmt);
|
|
18731
18731
|
assertApplyExecutionScope("phase15b", stmt);
|
|
@@ -19597,6 +19597,9 @@ function evaluateScalarExpr(expr, evaluationContext = {}) {
|
|
|
19597
19597
|
function resolveBatchVariableReferences(node, variables) {
|
|
19598
19598
|
return resolveBatchVariableReferencesInternal(node, variables, false);
|
|
19599
19599
|
}
|
|
19600
|
+
function undefinedBatchVariableMessage(name, location2) {
|
|
19601
|
+
return asOfFunctionNameFromVariable(name) === null ? `ParseError: variable @${name} is not defined ${location2}.` : `ParseError: @NOW() \u306A\u3069\u306E as-of \u95A2\u6570\u306F\u57FA\u6E96\u6642\u523B\u304C\u521D\u671F\u5316\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002`;
|
|
19602
|
+
}
|
|
19600
19603
|
function resolveBatchVariableReferencesInternal(node, variables, numericArithmeticOperand) {
|
|
19601
19604
|
if (Array.isArray(node)) {
|
|
19602
19605
|
return node.map((v) => resolveBatchVariableReferencesInternal(v, variables, false));
|
|
@@ -19606,7 +19609,7 @@ function resolveBatchVariableReferencesInternal(node, variables, numericArithmet
|
|
|
19606
19609
|
if (obj["type"] === "VARIABLE" && typeof obj["name"] === "string") {
|
|
19607
19610
|
const value = variables.get(obj["name"]);
|
|
19608
19611
|
if (value === void 0) {
|
|
19609
|
-
throw new Error(
|
|
19612
|
+
throw new Error(undefinedBatchVariableMessage(obj["name"], "in this batch"));
|
|
19610
19613
|
}
|
|
19611
19614
|
if (value.type === "array") {
|
|
19612
19615
|
throw new Error(`ParseError: array variable @${obj["name"]} can only be used as IN @${obj["name"]}.`);
|
|
@@ -19629,7 +19632,7 @@ function resolveBatchVariableReferencesInternal(node, variables, numericArithmet
|
|
|
19629
19632
|
}
|
|
19630
19633
|
if (obj["type"] === "VARIABLE_COL" && typeof obj["name"] === "string" && (typeof obj["alias"] === "string" || obj["alias"] === null)) {
|
|
19631
19634
|
const value = variables.get(obj["name"]);
|
|
19632
|
-
if (value === void 0) throw new Error(
|
|
19635
|
+
if (value === void 0) throw new Error(undefinedBatchVariableMessage(obj["name"], "in this batch"));
|
|
19633
19636
|
if (value.type === "array") throw new Error(`ParseError: array variable @${obj["name"]} cannot be used as a SELECT column.`);
|
|
19634
19637
|
if (value.type === "relative-date") {
|
|
19635
19638
|
throw new Error(`InternalError: RELATIVE_DATE variable @${obj["name"]} reached a SELECT column.`);
|
|
@@ -19655,7 +19658,7 @@ function resolveBatchVariableReferencesInternal(node, variables, numericArithmet
|
|
|
19655
19658
|
const right = resolved["right"];
|
|
19656
19659
|
if (right?.["type"] === "VARIABLE_IN_LIST" && typeof right["name"] === "string") {
|
|
19657
19660
|
const value = variables.get(right["name"]);
|
|
19658
|
-
if (value === void 0) throw new Error(
|
|
19661
|
+
if (value === void 0) throw new Error(undefinedBatchVariableMessage(right["name"], "in this batch"));
|
|
19659
19662
|
if (value.type !== "array") {
|
|
19660
19663
|
throw new Error(`ParseError: scalar variable @${right["name"]} cannot be used as IN @${right["name"]}; use IN (@${right["name"]}) instead.`);
|
|
19661
19664
|
}
|
|
@@ -27101,7 +27104,8 @@ var EXPLAIN_FETCH_PLAN = /* @__PURE__ */ Symbol("ksql.explainFetchPlan");
|
|
|
27101
27104
|
function setExplainFetchPlan(result, plan) {
|
|
27102
27105
|
result[EXPLAIN_FETCH_PLAN] = plan;
|
|
27103
27106
|
}
|
|
27104
|
-
async function buildBatchExplainPlans(sql, client, injectedVariables, cacheContext = "batch-explain", maxRecords = 1e4, cursorMaxActive = 2, enableImport = false, dmlMaxRows = 100, dmlMaxSubtableRows = DEFAULT_APPLY_MAX_SUBTABLE_ROWS, resolveMetadata = true, recursiveCteMaxDepth, recursiveCteMaxRows, recursiveCteMaxExpansions) {
|
|
27107
|
+
async function buildBatchExplainPlans(sql, client, injectedVariables, cacheContext = "batch-explain", maxRecords = 1e4, cursorMaxActive = 2, enableImport = false, dmlMaxRows = 100, dmlMaxSubtableRows = DEFAULT_APPLY_MAX_SUBTABLE_ROWS, resolveMetadata = true, recursiveCteMaxDepth, recursiveCteMaxRows, recursiveCteMaxExpansions, asOf, timezone) {
|
|
27108
|
+
const asOfClock = createAsOfClock(asOf ?? /* @__PURE__ */ new Date(), timezone);
|
|
27105
27109
|
const recursiveLimits = resolveRecursiveCteLimits({
|
|
27106
27110
|
recursiveCteMaxDepth,
|
|
27107
27111
|
recursiveCteMaxRows,
|
|
@@ -27114,6 +27118,9 @@ async function buildBatchExplainPlans(sql, client, injectedVariables, cacheConte
|
|
|
27114
27118
|
const normalizedInjectedVariables = validateDeclaredBatchVariables(statements, injectedVariables);
|
|
27115
27119
|
const relativeDateVariables = prepareRelativeDateVariables(statements, normalizedInjectedVariables);
|
|
27116
27120
|
const variables = /* @__PURE__ */ new Map();
|
|
27121
|
+
for (const [name, value] of Object.entries(asOfClock.values)) {
|
|
27122
|
+
variables.set(asOfVariableName(name), { type: "string", value });
|
|
27123
|
+
}
|
|
27117
27124
|
const literalDeclareDefaults = /* @__PURE__ */ new Map();
|
|
27118
27125
|
const tempSchemaLedger = /* @__PURE__ */ new Map();
|
|
27119
27126
|
const plans = [];
|