@rex0220/kintone-sql-tools 3.68.0 → 3.69.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.
@@ -11,7 +11,7 @@
11
11
  "format": "esm"
12
12
  },
13
13
  "src/types/ast.ts": {
14
- "bytes": 38120,
14
+ "bytes": 38224,
15
15
  "imports": [
16
16
  {
17
17
  "path": "src/core/exactDecimal.ts",
@@ -420,8 +420,13 @@
420
420
  ],
421
421
  "format": "esm"
422
422
  },
423
+ "src/core/asOfClock.ts": {
424
+ "bytes": 2891,
425
+ "imports": [],
426
+ "format": "esm"
427
+ },
423
428
  "src/core/batch.ts": {
424
- "bytes": 21308,
429
+ "bytes": 21010,
425
430
  "imports": [
426
431
  {
427
432
  "path": "src/core/dmlGuard.ts",
@@ -452,6 +457,11 @@
452
457
  "path": "src/core/groupingValidation.ts",
453
458
  "kind": "import-statement",
454
459
  "original": "./groupingValidation"
460
+ },
461
+ {
462
+ "path": "src/core/asOfClock.ts",
463
+ "kind": "import-statement",
464
+ "original": "./asOfClock"
455
465
  }
456
466
  ],
457
467
  "format": "esm"
@@ -473,7 +483,7 @@
473
483
  "format": "esm"
474
484
  },
475
485
  "src/parser/parser.ts": {
476
- "bytes": 215744,
486
+ "bytes": 217567,
477
487
  "imports": [
478
488
  {
479
489
  "path": "src/lexer/tokens.ts",
@@ -490,6 +500,11 @@
490
500
  "kind": "import-statement",
491
501
  "original": "../core/grouping"
492
502
  },
503
+ {
504
+ "path": "src/core/asOfClock.ts",
505
+ "kind": "import-statement",
506
+ "original": "../core/asOfClock"
507
+ },
493
508
  {
494
509
  "path": "src/core/aggregateExpression.ts",
495
510
  "kind": "import-statement",
@@ -1144,7 +1159,7 @@
1144
1159
  "format": "esm"
1145
1160
  },
1146
1161
  "src/core/diagnostics.ts": {
1147
- "bytes": 1535,
1162
+ "bytes": 1804,
1148
1163
  "imports": [],
1149
1164
  "format": "esm"
1150
1165
  },
@@ -1159,6 +1174,53 @@
1159
1174
  ],
1160
1175
  "format": "esm"
1161
1176
  },
1177
+ "src/core/sql.ts": {
1178
+ "bytes": 1991,
1179
+ "imports": [
1180
+ {
1181
+ "path": "src/lexer/lexer.ts",
1182
+ "kind": "import-statement",
1183
+ "original": "../lexer/lexer"
1184
+ },
1185
+ {
1186
+ "path": "src/parser/parser.ts",
1187
+ "kind": "import-statement",
1188
+ "original": "../parser/parser"
1189
+ },
1190
+ {
1191
+ "path": "src/core/scriptHeader.ts",
1192
+ "kind": "import-statement",
1193
+ "original": "./scriptHeader"
1194
+ },
1195
+ {
1196
+ "path": "src/core/statementValidation.ts",
1197
+ "kind": "import-statement",
1198
+ "original": "./statementValidation"
1199
+ }
1200
+ ],
1201
+ "format": "esm"
1202
+ },
1203
+ "src/core/dialect1Validation.ts": {
1204
+ "bytes": 6720,
1205
+ "imports": [
1206
+ {
1207
+ "path": "src/core/relativeDateFunction.ts",
1208
+ "kind": "import-statement",
1209
+ "original": "./relativeDateFunction"
1210
+ },
1211
+ {
1212
+ "path": "src/core/optimization/relativeDateFullScanExactPlan.ts",
1213
+ "kind": "import-statement",
1214
+ "original": "./optimization/relativeDateFullScanExactPlan"
1215
+ },
1216
+ {
1217
+ "path": "src/core/diagnostics.ts",
1218
+ "kind": "import-statement",
1219
+ "original": "./diagnostics"
1220
+ }
1221
+ ],
1222
+ "format": "esm"
1223
+ },
1162
1224
  "src/core/dmlPrevalidation.ts": {
1163
1225
  "bytes": 3780,
1164
1226
  "imports": [],
@@ -1384,7 +1446,7 @@
1384
1446
  "format": "esm"
1385
1447
  },
1386
1448
  "src/execute.ts": {
1387
- "bytes": 576972,
1449
+ "bytes": 590529,
1388
1450
  "imports": [
1389
1451
  {
1390
1452
  "path": "src/lexer/lexer.ts",
@@ -1647,9 +1709,19 @@
1647
1709
  "original": "./engine/evalFunc"
1648
1710
  },
1649
1711
  {
1650
- "path": "src/core/scriptHeader.ts",
1712
+ "path": "src/core/sql.ts",
1651
1713
  "kind": "import-statement",
1652
- "original": "./core/scriptHeader"
1714
+ "original": "./core/sql"
1715
+ },
1716
+ {
1717
+ "path": "src/core/asOfClock.ts",
1718
+ "kind": "import-statement",
1719
+ "original": "./core/asOfClock"
1720
+ },
1721
+ {
1722
+ "path": "src/core/dialect1Validation.ts",
1723
+ "kind": "import-statement",
1724
+ "original": "./core/dialect1Validation"
1653
1725
  },
1654
1726
  {
1655
1727
  "path": "src/core/dmlValidationCandidates.ts",
@@ -1938,27 +2010,6 @@
1938
2010
  ],
1939
2011
  "format": "esm"
1940
2012
  },
1941
- "src/core/sql.ts": {
1942
- "bytes": 867,
1943
- "imports": [
1944
- {
1945
- "path": "src/lexer/lexer.ts",
1946
- "kind": "import-statement",
1947
- "original": "../lexer/lexer"
1948
- },
1949
- {
1950
- "path": "src/parser/parser.ts",
1951
- "kind": "import-statement",
1952
- "original": "../parser/parser"
1953
- },
1954
- {
1955
- "path": "src/core/statementValidation.ts",
1956
- "kind": "import-statement",
1957
- "original": "./statementValidation"
1958
- }
1959
- ],
1960
- "format": "esm"
1961
- },
1962
2013
  "src/core/applyGuard.ts": {
1963
2014
  "bytes": 638,
1964
2015
  "imports": [],
@@ -2151,10 +2202,10 @@
2151
2202
  "bytesInOutput": 303
2152
2203
  },
2153
2204
  "src/core/grouping.ts": {
2154
- "bytesInOutput": 1277
2205
+ "bytesInOutput": 1280
2155
2206
  },
2156
2207
  "src/core/dmlGuard.ts": {
2157
- "bytesInOutput": 3459
2208
+ "bytesInOutput": 3460
2158
2209
  },
2159
2210
  "src/core/relativeDateFunction.ts": {
2160
2211
  "bytesInOutput": 451
@@ -2184,13 +2235,13 @@
2184
2235
  "bytesInOutput": 3124
2185
2236
  },
2186
2237
  "src/core/aggregateDependencyValidation.ts": {
2187
- "bytesInOutput": 8225
2238
+ "bytesInOutput": 8228
2188
2239
  },
2189
2240
  "src/core/groupingValidation.ts": {
2190
- "bytesInOutput": 3809
2241
+ "bytesInOutput": 3811
2191
2242
  },
2192
2243
  "src/converter/selectToKintone.ts": {
2193
- "bytesInOutput": 10146
2244
+ "bytesInOutput": 10148
2194
2245
  },
2195
2246
  "src/core/cteInlining.ts": {
2196
2247
  "bytesInOutput": 1224
@@ -2234,8 +2285,11 @@
2234
2285
  "src/core/statementValidation.ts": {
2235
2286
  "bytesInOutput": 239
2236
2287
  },
2288
+ "src/core/asOfClock.ts": {
2289
+ "bytesInOutput": 1162
2290
+ },
2237
2291
  "src/core/batch.ts": {
2238
- "bytesInOutput": 6358
2292
+ "bytesInOutput": 6386
2239
2293
  },
2240
2294
  "src/lexer/tokens.ts": {
2241
2295
  "bytesInOutput": 2328
@@ -2244,7 +2298,7 @@
2244
2298
  "bytesInOutput": 5906
2245
2299
  },
2246
2300
  "src/parser/parser.ts": {
2247
- "bytesInOutput": 127422
2301
+ "bytesInOutput": 128344
2248
2302
  },
2249
2303
  "src/core/scalarCompare.ts": {
2250
2304
  "bytesInOutput": 2804
@@ -2322,7 +2376,7 @@
2322
2376
  "bytesInOutput": 122
2323
2377
  },
2324
2378
  "src/core/explainMetadata.ts": {
2325
- "bytesInOutput": 626
2379
+ "bytesInOutput": 627
2326
2380
  },
2327
2381
  "src/core/optimization/sharedPlanner.ts": {
2328
2382
  "bytesInOutput": 339
@@ -2352,17 +2406,23 @@
2352
2406
  "bytesInOutput": 1223
2353
2407
  },
2354
2408
  "src/engine/process.ts": {
2355
- "bytesInOutput": 27971
2409
+ "bytesInOutput": 27972
2356
2410
  },
2357
2411
  "src/converter/subtableAdapter.ts": {
2358
2412
  "bytesInOutput": 643
2359
2413
  },
2360
2414
  "src/core/diagnostics.ts": {
2361
- "bytesInOutput": 514
2415
+ "bytesInOutput": 755
2362
2416
  },
2363
2417
  "src/core/scriptHeader.ts": {
2364
2418
  "bytesInOutput": 1831
2365
2419
  },
2420
+ "src/core/sql.ts": {
2421
+ "bytesInOutput": 492
2422
+ },
2423
+ "src/core/dialect1Validation.ts": {
2424
+ "bytesInOutput": 3025
2425
+ },
2366
2426
  "src/core/dmlPrevalidation.ts": {
2367
2427
  "bytesInOutput": 1136
2368
2428
  },
@@ -2418,7 +2478,7 @@
2418
2478
  "bytesInOutput": 412
2419
2479
  },
2420
2480
  "src/execute.ts": {
2421
- "bytesInOutput": 232730
2481
+ "bytesInOutput": 235571
2422
2482
  },
2423
2483
  "src/engine-library/errors.ts": {
2424
2484
  "bytesInOutput": 1441
@@ -2462,9 +2522,6 @@
2462
2522
  "src/engine-library/resultMapping.ts": {
2463
2523
  "bytesInOutput": 903
2464
2524
  },
2465
- "src/core/sql.ts": {
2466
- "bytesInOutput": 186
2467
- },
2468
2525
  "src/core/applyGuard.ts": {
2469
2526
  "bytesInOutput": 236
2470
2527
  },
@@ -2487,7 +2544,7 @@
2487
2544
  "bytesInOutput": 127
2488
2545
  }
2489
2546
  },
2490
- "bytes": 671877
2547
+ "bytes": 680415
2491
2548
  }
2492
2549
  }
2493
2550
  }
@@ -0,0 +1,6 @@
1
+ export declare class KsqlFlowError extends Error {
2
+ readonly code: string;
3
+ readonly cause?: unknown;
4
+ constructor(code: string, message: string, cause?: unknown);
5
+ }
6
+ export declare function normalizeFlowError(error: unknown): KsqlFlowError;
@@ -0,0 +1,12 @@
1
+ import { createKintoneClient } from "./writableClient";
2
+ import { KsqlFlowError } from "./errors";
3
+ import type { CreateExecutionContextOptions, Diagnostic, ExecutionContext, ExplainScriptOptions, ExplainScriptResult, ParseScriptOptions, ParseScriptResult, Statement, StatementResult, ValidateScriptOptions } from "./publicTypes";
4
+ export declare const version: string;
5
+ export declare function parseScript(source: string, opts?: ParseScriptOptions): ParseScriptResult;
6
+ export declare function validateScript(source: string, opts?: ValidateScriptOptions): Promise<Diagnostic[]>;
7
+ export declare function explainScript(source: string, opts: ExplainScriptOptions): Promise<ExplainScriptResult>;
8
+ export declare function createExecutionContext(opts: CreateExecutionContextOptions): ExecutionContext;
9
+ export declare function executeStatement(statement: Statement, context: ExecutionContext): Promise<StatementResult>;
10
+ export declare function disposeExecutionContext(context: ExecutionContext): Promise<void>;
11
+ export { createKintoneClient, KsqlFlowError };
12
+ export type { CreateExecutionContextOptions, CreateKintoneClientConfig, Diagnostic, DiagnosticCode, ExecutionContext, ExplainScriptOptions, ExplainScriptResult, FieldInfo, FlowKintoneClient, ParseScriptOptions, ParseScriptResult, SchemaResolver, ScriptHeaderMeta, Statement, StatementResult, StatementResultKind, ValidateScriptOptions, } from "./publicTypes";
@@ -0,0 +1,225 @@
1
+ import type { Statement } from "../types/ast";
2
+ export type { Statement };
3
+ export type DiagnosticCode = "KSQL1001" | "KSQL1002" | "KSQL1003" | "KSQL1004" | "KSQL1005" | "KSQL1006" | "KSQL1101" | "KSQL1201" | "KSQL1202" | "KSQL1203" | "KSQL1301" | "KSQL1302" | "KSQL1303" | "KSQL1304" | "KSQL1305" | "KSQL1306";
4
+ export interface Diagnostic {
5
+ severity: "error" | "warning";
6
+ code: DiagnosticCode;
7
+ message: string;
8
+ line: number;
9
+ column: number;
10
+ statementIndex?: number;
11
+ }
12
+ export interface ScriptHeaderMeta {
13
+ name: string | null;
14
+ dependsOn: string[];
15
+ timeout: number | null;
16
+ dialect: 0 | 1;
17
+ }
18
+ export interface FieldInfo {
19
+ code: string;
20
+ label: string;
21
+ fieldType: string;
22
+ optionOrder?: Record<string, number>;
23
+ sortKind?: "number" | "string";
24
+ required?: boolean;
25
+ minValue?: string;
26
+ maxValue?: string;
27
+ minLength?: string;
28
+ maxLength?: string;
29
+ defaultValue?: unknown;
30
+ hasLookup?: boolean;
31
+ isLookupCopyTarget?: boolean;
32
+ isUnique?: boolean;
33
+ isCalculated?: boolean;
34
+ inSubtable?: boolean;
35
+ writable?: boolean;
36
+ subtableCode?: string;
37
+ }
38
+ export interface KintoneRecordValue {
39
+ value: string | string[] | Array<{
40
+ code: string;
41
+ }>;
42
+ }
43
+ export type KintoneRecord = Record<string, KintoneRecordValue>;
44
+ export interface FlowKintoneClient {
45
+ getRecords(params: {
46
+ app: number;
47
+ query: string;
48
+ fields: string[];
49
+ totalCount?: boolean;
50
+ }): Promise<{
51
+ records: KintoneRecord[];
52
+ totalCount?: string;
53
+ searchAborted?: boolean;
54
+ }>;
55
+ openCursor(params: {
56
+ app: number;
57
+ fields?: string[];
58
+ query: string;
59
+ size: 500;
60
+ }): Promise<{
61
+ readonly totalCount: number;
62
+ nextPage(): Promise<{
63
+ records: KintoneRecord[];
64
+ next: boolean;
65
+ }>;
66
+ close(): Promise<void>;
67
+ }>;
68
+ postRecords(params: {
69
+ app: number;
70
+ records: KintoneRecord[];
71
+ }): Promise<{
72
+ ids: string[];
73
+ }>;
74
+ putRecords(params: {
75
+ app: number;
76
+ records: Array<{
77
+ id: number;
78
+ revision?: number;
79
+ record: KintoneRecord;
80
+ }>;
81
+ }): Promise<void>;
82
+ deleteRecords(params: {
83
+ app: number;
84
+ ids: number[];
85
+ }): Promise<void>;
86
+ getApps(): Promise<Array<{
87
+ appId: number;
88
+ name: string;
89
+ description: string;
90
+ }>>;
91
+ getFields(appId: number): Promise<FieldInfo[]>;
92
+ getNumberPrecision(appId: number): Promise<{
93
+ digits: number;
94
+ decimalPlaces: number;
95
+ roundingMode: "HALF_EVEN" | "UP" | "DOWN";
96
+ }>;
97
+ getProcessStatuses(appId: number): Promise<{
98
+ enable: boolean;
99
+ states: Array<{
100
+ name: string;
101
+ index: number;
102
+ }> | null;
103
+ }>;
104
+ }
105
+ export type SchemaResolver = (appId: number) => readonly FieldInfo[] | Promise<readonly FieldInfo[]>;
106
+ export interface ParseScriptOptions {
107
+ apps?: Readonly<Record<string, number>>;
108
+ }
109
+ export interface ParseScriptResult {
110
+ meta: ScriptHeaderMeta;
111
+ statements: Statement[];
112
+ statementRanges: Array<{
113
+ start: number;
114
+ end: number;
115
+ }>;
116
+ diagnostics: Diagnostic[];
117
+ }
118
+ export interface ValidateScriptOptions extends ParseScriptOptions {
119
+ strict?: boolean;
120
+ schema?: SchemaResolver;
121
+ client?: Pick<FlowKintoneClient, "getFields">;
122
+ }
123
+ export interface ExplainScriptOptions extends ParseScriptOptions {
124
+ client: FlowKintoneClient;
125
+ variables?: Readonly<Record<string, string>>;
126
+ maxRecords?: number;
127
+ cursorMaxActive?: number;
128
+ dmlMaxRows?: number;
129
+ dmlMaxSubtableRows?: number;
130
+ resolveMetadata?: boolean;
131
+ recursiveCteMaxDepth?: number;
132
+ recursiveCteMaxRows?: number;
133
+ recursiveCteMaxExpansions?: number;
134
+ }
135
+ export interface ExplainScriptResult {
136
+ statementCount: number;
137
+ statements: Array<{
138
+ index: number;
139
+ type: string;
140
+ plan: string[];
141
+ }>;
142
+ }
143
+ export interface CreateExecutionContextOptions extends ParseScriptOptions {
144
+ client: FlowKintoneClient;
145
+ script?: string;
146
+ statements?: readonly Statement[];
147
+ meta?: ScriptHeaderMeta;
148
+ variables?: Readonly<Record<string, string>>;
149
+ maxRecords?: number;
150
+ recursiveCteMaxDepth?: number;
151
+ recursiveCteMaxRows?: number;
152
+ recursiveCteMaxExpansions?: number;
153
+ onLimitReached?: "error" | "truncate";
154
+ fetchParallel?: number;
155
+ cacheContext?: string;
156
+ cursorMaxActive?: number;
157
+ dmlMaxRows?: number;
158
+ dmlMaxSubtableRows?: number;
159
+ tempTableMaxRows?: number;
160
+ timeoutMs?: number;
161
+ asOf?: Date;
162
+ timezone?: string;
163
+ continueOnError?: boolean;
164
+ }
165
+ declare const executionContextBrand: unique symbol;
166
+ /** Opaque, sequential-only statement execution handle. */
167
+ export interface ExecutionContext {
168
+ readonly [executionContextBrand]: true;
169
+ }
170
+ export interface StatementError {
171
+ code: string;
172
+ message: string;
173
+ readonly cause?: unknown;
174
+ }
175
+ export interface ExecutionMetrics {
176
+ getCalls: number;
177
+ postCalls: number;
178
+ putCalls: number;
179
+ deleteCalls: number;
180
+ fieldCalls: number;
181
+ numberPrecisionCalls: number;
182
+ appsCalls: number;
183
+ processStatusCalls: number;
184
+ cursorCreateCalls: number;
185
+ cursorGetCalls: number;
186
+ cursorDeleteCalls: number;
187
+ cursorRecordsScanned: number;
188
+ cursorActiveCurrent: number;
189
+ cursorActivePeak: number;
190
+ cursorCleanupFailures: number;
191
+ cursorCreateOutcomeUnknown: number;
192
+ cursorQuarantinedCurrent: number;
193
+ fetchedRows: number;
194
+ limitReached: boolean;
195
+ limitReachedApps: number[];
196
+ elapsedMs: number;
197
+ }
198
+ export type StatementResultKind = "STATEMENT" | "ASSERT_PASSED" | "ASSERT_WARNING" | "ASSERT_VIOLATION" | "EXIT_NO_DATA";
199
+ export interface StatementResult {
200
+ index: number;
201
+ type: string;
202
+ status: "success" | "error" | "skipped";
203
+ kind: StatementResultKind;
204
+ result?: unknown;
205
+ tempTable?: string;
206
+ rowCount?: number;
207
+ error?: StatementError;
208
+ skippedReason?: string;
209
+ metrics: ExecutionMetrics;
210
+ }
211
+ export interface CreateKintoneClientConfig {
212
+ baseUrl: string;
213
+ guestSpaceId?: number;
214
+ auth: {
215
+ type: "apiToken";
216
+ apiToken: string | ((appId: number) => string);
217
+ } | {
218
+ type: "password";
219
+ username: string;
220
+ password: string;
221
+ };
222
+ fetch?: typeof globalThis.fetch;
223
+ timeoutMs?: number;
224
+ cursorMaxActive?: number;
225
+ }
@@ -0,0 +1,2 @@
1
+ import type { CreateKintoneClientConfig, FlowKintoneClient } from "./publicTypes";
2
+ export declare function createKintoneClient(config: CreateKintoneClientConfig): FlowKintoneClient;