@rex0220/kintone-sql-tools 3.67.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.
- package/README.md +38 -0
- package/dist-cli/ksql.js +889 -75
- package/dist-engine/index.cjs +16 -12
- package/dist-engine/index.mjs +16 -12
- package/dist-engine/ksql-engine.umd.js +17 -13
- package/dist-engine/meta/bundle-baseline.json +10 -10
- package/dist-engine/meta/cjs.json +129 -45
- package/dist-engine/meta/esm.json +129 -45
- package/dist-engine/meta/umd.json +129 -45
- package/dist-flow/flow-library/errors.d.ts +6 -0
- package/dist-flow/flow-library/index.d.ts +12 -0
- package/dist-flow/flow-library/publicTypes.d.ts +225 -0
- package/dist-flow/flow-library/writableClient.d.ts +2 -0
- package/dist-flow/index.cjs +18 -0
- package/dist-flow/index.mjs +18 -0
- package/dist-flow/meta/cjs.json +2333 -0
- package/dist-flow/meta/esm.json +2343 -0
- package/dist-flow/types/ast.d.ts +881 -0
- package/dist-mcp/ksql-mcp.js +1255 -174
- package/dist-mcpb/ksql-mcp.mcpb +0 -0
- package/package.json +12 -3
|
@@ -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
|
+
}
|