@fadhilp/stateql 0.16.0 → 0.18.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/dist/src/adapters.d.ts +17 -25
- package/dist/src/adapters.js +15 -95
- package/dist/src/agent-response.js +6 -1
- package/dist/src/catalog.d.ts +6 -0
- package/dist/src/catalog.js +52 -0
- package/dist/src/cli.js +76 -25
- package/dist/src/connect.d.ts +16 -0
- package/dist/src/connect.js +205 -0
- package/dist/src/core.d.ts +78 -0
- package/dist/src/core.js +477 -0
- package/dist/src/execution.d.ts +27 -0
- package/dist/src/execution.js +87 -0
- package/dist/src/filter.js +3 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/migrations.d.ts +1 -1
- package/dist/src/mongodb.d.ts +4 -2
- package/dist/src/mongodb.js +5 -56
- package/dist/src/panel.d.ts +64 -0
- package/dist/src/panel.js +316 -0
- package/dist/src/plans.d.ts +31 -0
- package/dist/src/plans.js +275 -0
- package/dist/src/reads.d.ts +35 -0
- package/dist/src/reads.js +184 -0
- package/dist/src/redis.d.ts +4 -2
- package/dist/src/redis.js +7 -33
- package/dist/src/response-data.d.ts +1 -0
- package/dist/src/response-data.js +13 -10
- package/dist/src/results.d.ts +10 -0
- package/dist/src/results.js +153 -0
- package/dist/src/sql.d.ts +7 -1
- package/dist/src/sql.js +88 -8
- package/dist/src/sqlite-process.js +16 -9
- package/dist/src/stateql.d.ts +9 -59
- package/dist/src/stateql.js +170 -2597
- package/dist/src/table-editor.js +2 -2
- package/dist/src/transactions.d.ts +8 -0
- package/dist/src/transactions.js +186 -0
- package/dist/src/types.d.ts +20 -18
- package/dist/src/util.d.ts +1 -0
- package/dist/src/util.js +1 -1
- package/dist/src/writes.d.ts +48 -0
- package/dist/src/writes.js +320 -0
- package/docs/batch.md +2 -1
- package/docs/cli.md +15 -9
- package/docs/databases.md +4 -3
- package/docs/library.md +3 -1
- package/docs/results.md +17 -0
- package/docs/writes.md +6 -0
- package/package.json +5 -3
- package/skills/stateql/SKILL.md +14 -6
- package/skills/stateql/reference/writes.md +4 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { writeFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { nonNegativeInteger, positiveInteger } from "./core.js";
|
|
4
|
+
import { StateQLError } from "./errors.js";
|
|
5
|
+
import { filterMaterializedRows, prepareFilterStatement, validateFilterParameters, } from "./filter.js";
|
|
6
|
+
import { rowsToCsv } from "./response-data.js";
|
|
7
|
+
import { compactRows, compactValue, hash } from "./util.js";
|
|
8
|
+
export function showResult(core, result) {
|
|
9
|
+
return storedResult(result, core.resultData(result, true));
|
|
10
|
+
}
|
|
11
|
+
export function filterResult(core, source, predicate, options) {
|
|
12
|
+
const columns = core.store.resultColumns(source);
|
|
13
|
+
const filter = prepareFilterStatement(columns, predicate);
|
|
14
|
+
const parameters = options.params ?? [];
|
|
15
|
+
validateFilterParameters(filter, parameters);
|
|
16
|
+
const fingerprint = hash({
|
|
17
|
+
command: "filter",
|
|
18
|
+
source: source.id,
|
|
19
|
+
predicate: filter.normalized,
|
|
20
|
+
parameters,
|
|
21
|
+
});
|
|
22
|
+
const cached = core.store.findResult(fingerprint);
|
|
23
|
+
const reusable = cached !== undefined &&
|
|
24
|
+
cached.session_id === source.session_id &&
|
|
25
|
+
cached.connection_id === source.connection_id &&
|
|
26
|
+
Date.parse(cached.expires_at) > core.now().getTime();
|
|
27
|
+
if (reusable)
|
|
28
|
+
return storedResult(cached, core.resultData(cached, true));
|
|
29
|
+
const saved = core.store.saveResult({
|
|
30
|
+
sessionId: source.session_id,
|
|
31
|
+
connectionId: source.connection_id,
|
|
32
|
+
fingerprint,
|
|
33
|
+
sql: `FILTER ${source.id} WHERE ${predicate.trim()}`,
|
|
34
|
+
parameters,
|
|
35
|
+
rows: filterMaterializedRows(core.store.resultRows(source), filter, parameters),
|
|
36
|
+
columns,
|
|
37
|
+
stateVersion: source.state_version,
|
|
38
|
+
stateSignature: source.state_signature,
|
|
39
|
+
stateConfidence: source.state_confidence,
|
|
40
|
+
expiresAt: source.expires_at,
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
data: core.resultData(saved, false),
|
|
44
|
+
handle: saved.id,
|
|
45
|
+
executed: true,
|
|
46
|
+
stateVersion: saved.state_version,
|
|
47
|
+
confidence: saved.state_confidence,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function resultRows(core, result, options) {
|
|
51
|
+
const offset = nonNegativeInteger(options.offset ?? 0, "offset");
|
|
52
|
+
const limit = positiveInteger(options.limit ?? 20, "limit");
|
|
53
|
+
if (limit > 1_000) {
|
|
54
|
+
throw new StateQLError("OUTPUT_LIMIT_EXCEEDED", "limit cannot exceed 1000 rows.", { suggestedAction: "Fetch another page or use export." });
|
|
55
|
+
}
|
|
56
|
+
const rows = selectColumns(core.store.resultRows(result).slice(offset, offset + limit), core.store.resultColumns(result), options.columns);
|
|
57
|
+
const next = offset + rows.length;
|
|
58
|
+
return storedResult(result, {
|
|
59
|
+
result_id: result.id,
|
|
60
|
+
offset,
|
|
61
|
+
limit,
|
|
62
|
+
rows: compactRows(rows, core.settings.maxCellCharacters),
|
|
63
|
+
returned: rows.length,
|
|
64
|
+
total: result.row_count,
|
|
65
|
+
truncated: next < result.row_count,
|
|
66
|
+
next_offset: next < result.row_count ? next : null,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
export function countResult(result) {
|
|
70
|
+
return storedResult(result, { result_id: result.id, rows: result.row_count });
|
|
71
|
+
}
|
|
72
|
+
export function resultColumns(core, result) {
|
|
73
|
+
return storedResult(result, { result_id: result.id, columns: core.store.resultColumns(result) });
|
|
74
|
+
}
|
|
75
|
+
export function summarizeResult(core, result) {
|
|
76
|
+
const rows = core.store.resultRows(result);
|
|
77
|
+
return storedResult(result, {
|
|
78
|
+
result_id: result.id,
|
|
79
|
+
total: result.row_count,
|
|
80
|
+
columns: core.store.resultColumns(result).map((column) => summarizeColumn(column.name, rows, core.settings.maxCellCharacters)),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
export function exportResult(core, result, output, format, columns) {
|
|
84
|
+
const resultColumns = core.store.resultColumns(result);
|
|
85
|
+
const rows = selectColumns(core.store.resultRows(result), resultColumns, columns);
|
|
86
|
+
const content = format === "json"
|
|
87
|
+
? `${JSON.stringify(rows, null, 2)}\n`
|
|
88
|
+
: format === "jsonl"
|
|
89
|
+
? `${rows.map((row) => JSON.stringify(row)).join("\n")}\n`
|
|
90
|
+
: rowsToCsv(rows, columns ?? resultColumns.map((column) => column.name));
|
|
91
|
+
const path = resolve(output);
|
|
92
|
+
writeFileSync(path, content, "utf8");
|
|
93
|
+
return {
|
|
94
|
+
data: { result_id: result.id, output: path, format, rows: rows.length },
|
|
95
|
+
handle: result.id,
|
|
96
|
+
executed: true,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function storedResult(result, data) {
|
|
100
|
+
return {
|
|
101
|
+
data,
|
|
102
|
+
handle: result.id,
|
|
103
|
+
cached: true,
|
|
104
|
+
stateVersion: result.state_version,
|
|
105
|
+
confidence: result.state_confidence,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function selectColumns(rows, available, selected) {
|
|
109
|
+
if (!selected)
|
|
110
|
+
return rows;
|
|
111
|
+
const names = available.map((column) => column.name);
|
|
112
|
+
const unknown = selected.filter((name) => !names.includes(name));
|
|
113
|
+
if (selected.length === 0 || unknown.length > 0) {
|
|
114
|
+
throw new StateQLError("INVALID_COMMAND", unknown.length > 0 ? `Unknown column: ${unknown.join(", ")}.` : "columns cannot be empty.", { suggestedAction: `Use one or more of: ${names.join(", ")}.` });
|
|
115
|
+
}
|
|
116
|
+
// Keep missing keys missing, so MongoDB documents still distinguish missing from null.
|
|
117
|
+
return rows.map((row) => Object.fromEntries(selected.filter((name) => name in row).map((name) => [name, row[name]])));
|
|
118
|
+
}
|
|
119
|
+
function summarizeColumn(name, rows, maxCellCharacters) {
|
|
120
|
+
const values = rows
|
|
121
|
+
.map((row) => row[name])
|
|
122
|
+
.filter((value) => value !== null && value !== undefined);
|
|
123
|
+
const [min, max] = valueRange(values);
|
|
124
|
+
return {
|
|
125
|
+
name,
|
|
126
|
+
nulls: rows.length - values.length,
|
|
127
|
+
distinct: new Set(values.map((value) => JSON.stringify(value))).size,
|
|
128
|
+
min: compactValue(min, maxCellCharacters),
|
|
129
|
+
max: compactValue(max, maxCellCharacters),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const NUMERIC_TEXT = /^-?\d+(?:\.\d+)?$/;
|
|
133
|
+
// Exact numerics (PostgreSQL numeric/bigint, MySQL DECIMAL) arrive as strings, so compare them as numbers.
|
|
134
|
+
function valueRange(values) {
|
|
135
|
+
const numeric = values.every((value) => typeof value === "number" || (typeof value === "string" && NUMERIC_TEXT.test(value)));
|
|
136
|
+
const text = values.every((value) => typeof value === "string");
|
|
137
|
+
if (values.length === 0)
|
|
138
|
+
return [null, null];
|
|
139
|
+
if (!numeric && !text)
|
|
140
|
+
return [null, null];
|
|
141
|
+
const compare = numeric
|
|
142
|
+
? (left, right) => Number(left) - Number(right)
|
|
143
|
+
: (left, right) => (String(left) < String(right) ? -1 : String(left) > String(right) ? 1 : 0);
|
|
144
|
+
let min = values[0];
|
|
145
|
+
let max = values[0];
|
|
146
|
+
for (const value of values) {
|
|
147
|
+
if (compare(value, min) < 0)
|
|
148
|
+
min = value;
|
|
149
|
+
if (compare(value, max) > 0)
|
|
150
|
+
max = value;
|
|
151
|
+
}
|
|
152
|
+
return [min, max];
|
|
153
|
+
}
|
package/dist/src/sql.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AST } from "node-sql-parser";
|
|
2
|
-
import type { Driver, SqlDriver } from "./types.js";
|
|
2
|
+
import type { Driver, SqlDriver, SqlParameters } from "./types.js";
|
|
3
3
|
export type StatementType = "select" | "insert" | "upsert" | "replace" | "update" | "delete" | "create" | "alter" | "drop" | "truncate" | "values" | "show" | "explain" | "vacuum" | "analyze" | "reindex" | "optimize" | "check" | "cluster";
|
|
4
4
|
export interface SqlAnalysis {
|
|
5
5
|
ast: AST;
|
|
@@ -18,3 +18,9 @@ export interface SqlAnalysis {
|
|
|
18
18
|
export declare function analyzeSql(sql: string, driver: SqlDriver): SqlAnalysis;
|
|
19
19
|
/** @internal Compatibility for existing connection records during Mongo rollout. */
|
|
20
20
|
export declare function analyzeSql(sql: string, driver: Driver): SqlAnalysis;
|
|
21
|
+
export interface CountStatement {
|
|
22
|
+
sql: string;
|
|
23
|
+
params: unknown[];
|
|
24
|
+
}
|
|
25
|
+
/** A COUNT(*) of the rows a single-table UPDATE or DELETE matches, or undefined when it cannot be derived safely. */
|
|
26
|
+
export declare function matchedRowsCount(analysis: SqlAnalysis, params: SqlParameters, driver: SqlDriver): CountStatement | undefined;
|
package/dist/src/sql.js
CHANGED
|
@@ -50,13 +50,93 @@ export function analyzeSql(sql, driver) {
|
|
|
50
50
|
throw new StateQLError("INVALID_SQL", message);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
function parserDatabase(driver) {
|
|
54
|
+
if (driver === "postgres")
|
|
55
|
+
return "Postgresql";
|
|
56
|
+
if (driver === "mysql")
|
|
57
|
+
return "MySQL";
|
|
58
|
+
return "Sqlite";
|
|
59
|
+
}
|
|
60
|
+
/** A COUNT(*) of the rows a single-table UPDATE or DELETE matches, or undefined when it cannot be derived safely. */
|
|
61
|
+
export function matchedRowsCount(analysis, params, driver) {
|
|
62
|
+
const ast = analysis.ast;
|
|
63
|
+
const isUpdate = analysis.statementType === "update";
|
|
64
|
+
const isDelete = analysis.statementType === "delete";
|
|
65
|
+
if (!isUpdate && !isDelete)
|
|
66
|
+
return undefined;
|
|
67
|
+
const tables = isUpdate ? ast.table : ast.from;
|
|
68
|
+
const singleTable = Array.isArray(tables) && tables.length === 1 && !record(tables[0])?.join;
|
|
69
|
+
const limit = record(ast.limit)?.value;
|
|
70
|
+
const hasLimit = Array.isArray(limit) && limit.length > 0;
|
|
71
|
+
if (!Array.isArray(params) || !singleTable)
|
|
72
|
+
return undefined;
|
|
73
|
+
if (ast.with || ast.orderby || hasLimit || (isUpdate && ast.from))
|
|
74
|
+
return undefined;
|
|
75
|
+
// The parser drops NULLS FIRST/LAST, which can change a subquery that also has a LIMIT.
|
|
76
|
+
if (/\bnulls\s+(?:first|last)\b/i.test(analysis.normalized))
|
|
77
|
+
return undefined;
|
|
78
|
+
const where = structuredClone(ast.where ?? null);
|
|
79
|
+
const setPlaceholders = placeholders(ast.set);
|
|
80
|
+
const wherePlaceholders = placeholders(where);
|
|
81
|
+
const placeholderCount = setPlaceholders.length + wherePlaceholders.length;
|
|
82
|
+
if (placeholders(ast).length !== placeholderCount)
|
|
83
|
+
return undefined;
|
|
84
|
+
let countParams;
|
|
85
|
+
if ([...setPlaceholders, ...wherePlaceholders].every(isQuestionMark)) {
|
|
86
|
+
if (params.length !== placeholderCount)
|
|
87
|
+
return undefined;
|
|
88
|
+
countParams = params.slice(setPlaceholders.length);
|
|
89
|
+
}
|
|
90
|
+
else if (driver === "postgres" && wherePlaceholders.every(isNumberedVar)) {
|
|
91
|
+
const renumbered = new Map();
|
|
92
|
+
for (const node of wherePlaceholders) {
|
|
93
|
+
const number = node.name;
|
|
94
|
+
if (!renumbered.has(number))
|
|
95
|
+
renumbered.set(number, renumbered.size + 1);
|
|
96
|
+
node.name = renumbered.get(number);
|
|
97
|
+
}
|
|
98
|
+
countParams = [...renumbered.keys()].map((number) => params[number - 1]);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
const select = {
|
|
104
|
+
type: "select",
|
|
105
|
+
columns: [{ expr: { type: "aggr_func", name: "COUNT", args: { expr: { type: "star", value: "*" } } }, as: null }],
|
|
106
|
+
from: tables,
|
|
107
|
+
where,
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
sql: sqlParser().sqlify(select, { database: parserDatabase(driver) }),
|
|
111
|
+
params: countParams,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function placeholders(node, found = []) {
|
|
115
|
+
if (Array.isArray(node)) {
|
|
116
|
+
for (const item of node)
|
|
117
|
+
placeholders(item, found);
|
|
118
|
+
return found;
|
|
119
|
+
}
|
|
120
|
+
const value = record(node);
|
|
121
|
+
if (!value)
|
|
122
|
+
return found;
|
|
123
|
+
if (value.type === "var" || isQuestionMark(value)) {
|
|
124
|
+
found.push(value);
|
|
125
|
+
return found;
|
|
126
|
+
}
|
|
127
|
+
for (const child of Object.values(value))
|
|
128
|
+
placeholders(child, found);
|
|
129
|
+
return found;
|
|
130
|
+
}
|
|
131
|
+
function isQuestionMark(node) {
|
|
132
|
+
return node.type === "origin" && node.value === "?";
|
|
133
|
+
}
|
|
134
|
+
function isNumberedVar(node) {
|
|
135
|
+
return node.type === "var" && node.prefix === "$" && Number.isInteger(node.name);
|
|
136
|
+
}
|
|
53
137
|
function parseSqlStatement(sql, driver) {
|
|
54
138
|
const parser = sqlParser();
|
|
55
|
-
const database = driver
|
|
56
|
-
? "Postgresql"
|
|
57
|
-
: driver === "mysql"
|
|
58
|
-
? "MySQL"
|
|
59
|
-
: "Sqlite";
|
|
139
|
+
const database = parserDatabase(driver);
|
|
60
140
|
const parserSql = driver === "postgres" ? postgresParserSql(sql) : sql;
|
|
61
141
|
let parsed;
|
|
62
142
|
try {
|
|
@@ -699,10 +779,10 @@ class UtilityParser {
|
|
|
699
779
|
if (this.done())
|
|
700
780
|
return;
|
|
701
781
|
while (true) {
|
|
702
|
-
|
|
703
|
-
this.consumeWord("ONLY");
|
|
782
|
+
const only = allowOnlyAndStar && this.consumeWord("ONLY");
|
|
704
783
|
this.qualifiedIdentifier();
|
|
705
|
-
|
|
784
|
+
// PostgreSQL accepts ONLY name or name *, never both.
|
|
785
|
+
if (allowOnlyAndStar && !only)
|
|
706
786
|
this.consumePunctuation("*");
|
|
707
787
|
if (this.consumePunctuation("(")) {
|
|
708
788
|
this.identifier();
|
|
@@ -44,15 +44,22 @@ function execute(request) {
|
|
|
44
44
|
switch (request.operation) {
|
|
45
45
|
case "read": {
|
|
46
46
|
const [sql, params] = request.args;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
// SQLite itself rejects writes here even if SQL analysis misclassifies a statement.
|
|
48
|
+
database.exec("PRAGMA query_only = ON");
|
|
49
|
+
try {
|
|
50
|
+
const statement = database.prepare(sql);
|
|
51
|
+
const rows = bindAll(statement, params);
|
|
52
|
+
return {
|
|
53
|
+
rows: toJsonSafe(rows),
|
|
54
|
+
columns: statement.columns().map((column) => ({
|
|
55
|
+
name: column.name,
|
|
56
|
+
type: column.type?.toLowerCase() ?? inferType(rows, column.name),
|
|
57
|
+
})),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
database.exec("PRAGMA query_only = OFF");
|
|
62
|
+
}
|
|
56
63
|
}
|
|
57
64
|
case "write": {
|
|
58
65
|
if (readOnly)
|
package/dist/src/stateql.d.ts
CHANGED
|
@@ -1,30 +1,16 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type {
|
|
1
|
+
import { type MaterializedPage, type TableRead } from "./panel.js";
|
|
2
|
+
import type { TableChange } from "./table-editor.js";
|
|
3
|
+
import type { ActorData, ActorLinkData, ActorResolutionData, ActorsData, ActorUnlinkData, AliasData, ApplyData, BatchCommand, BatchOptions, CapabilitiesData, CatalogObject, CloseSessionData, ColumnsData, CommandExecutionContext, CommandOrigin, CommitTransactionData, ConnectionData, ConnectOptions, CountData, DescribeObjectData, DisconnectData, DoctorData, ExecData, ExecOptions, ExecutionOptions, ExportData, FilterOptions, HistoryData, HistoryOptions, ListObjectsData, ListObjectsFilter, MongoExecOptions, MongoPlanOptions, MongoQueryOptions, MongoReadCommand, MongoWriteCommand, OperationData, PlanData, PlanOptions, ProfileData, ProfileOptions, ProfilesData, ProfileUpdateOptions, PurgeData, QueryOptions, RedisCommand, RedisExecOptions, RedisPlanOptions, RedisQueryOptions, RemovedProfileData, Response, ResultData, RollbackTransactionData, RowsData, RowsOptions, SessionData, SessionsData, SessionSummaryData, StateQLActorOptions, StateQLOptions, StateQLSnapshot, StateQLSnapshotOptions, StateQLWorkspaceOptions, StatusData, SummaryData, TransactionData } from "./types.js";
|
|
3
4
|
export declare class StateQL {
|
|
4
5
|
/** Runtime contract marker for passwordRef/password_ref support. */
|
|
5
6
|
static readonly passwordReferenceVersion: 1;
|
|
6
7
|
static forActor(options: StateQLActorOptions): StateQL;
|
|
7
8
|
/** Opens one actor in a named shared workspace for a trusted library host. */
|
|
8
9
|
static forWorkspace(options: StateQLWorkspaceOptions): StateQL;
|
|
10
|
+
private readonly core;
|
|
9
11
|
private readonly store;
|
|
10
|
-
private readonly
|
|
11
|
-
private readonly actorId;
|
|
12
|
-
private readonly previewRows;
|
|
13
|
-
private readonly cacheTtlSeconds;
|
|
14
|
-
private readonly resultTtlSeconds;
|
|
15
|
-
private readonly maxCellCharacters;
|
|
16
|
-
private readonly maxResultRows;
|
|
17
|
-
private readonly maxResultBytes;
|
|
18
|
-
private readonly timeoutMs;
|
|
19
|
-
private readonly credentialTimeoutMs;
|
|
20
|
-
private readonly signal?;
|
|
21
|
-
private readonly commandContexts;
|
|
22
|
-
private readonly credentialResolver?;
|
|
23
|
-
private readonly now;
|
|
12
|
+
private readonly panel;
|
|
24
13
|
private closed;
|
|
25
|
-
private readonly tableResults;
|
|
26
|
-
private readonly editTokens;
|
|
27
|
-
private panelRows?;
|
|
28
14
|
constructor(options?: StateQLOptions);
|
|
29
15
|
close(): void;
|
|
30
16
|
[Symbol.dispose](): void;
|
|
@@ -56,16 +42,12 @@ export declare class StateQL {
|
|
|
56
42
|
rows(idOrAlias: string, options?: RowsOptions): Promise<Response<RowsData>>;
|
|
57
43
|
count(idOrAlias: string): Promise<Response<CountData>>;
|
|
58
44
|
columns(idOrAlias: string): Promise<Response<ColumnsData>>;
|
|
45
|
+
summarize(idOrAlias: string): Promise<Response<SummaryData>>;
|
|
59
46
|
setAlias(name: string, id: string): Promise<Response<AliasData>>;
|
|
60
47
|
/** Owned, full-value pages for host UIs. Reading a page does not add a command to history. */
|
|
61
48
|
readMaterialized(id: string, options?: RowsOptions & {
|
|
62
49
|
signal?: AbortSignal;
|
|
63
|
-
}):
|
|
64
|
-
columns: Column[];
|
|
65
|
-
row_tokens: Array<string | null>;
|
|
66
|
-
writable_columns: string[];
|
|
67
|
-
editing_reason?: string;
|
|
68
|
-
};
|
|
50
|
+
}): MaterializedPage;
|
|
69
51
|
/** No caller-selected filesystem paths. The host delivers these bounded attachment bytes. */
|
|
70
52
|
serializeResult(id: string, format: "json" | "jsonl" | "csv", signal?: AbortSignal, origin?: CommandOrigin): Promise<Response<{
|
|
71
53
|
content: string;
|
|
@@ -77,14 +59,7 @@ export declare class StateQL {
|
|
|
77
59
|
name: string;
|
|
78
60
|
}, limit?: number, options?: QueryOptions & {
|
|
79
61
|
origin?: CommandOrigin;
|
|
80
|
-
}): Promise<Response<
|
|
81
|
-
table: {
|
|
82
|
-
schema?: string;
|
|
83
|
-
name: string;
|
|
84
|
-
};
|
|
85
|
-
sample_limit: number;
|
|
86
|
-
query: string;
|
|
87
|
-
}>>;
|
|
62
|
+
}): Promise<Response<TableRead>>;
|
|
88
63
|
planTableUpdate(token: string, changes: TableChange, options?: ExecutionOptions & {
|
|
89
64
|
origin?: CommandOrigin;
|
|
90
65
|
}): Promise<Response<PlanData>>;
|
|
@@ -94,10 +69,7 @@ export declare class StateQL {
|
|
|
94
69
|
}>, options?: ExecutionOptions & {
|
|
95
70
|
origin?: CommandOrigin;
|
|
96
71
|
}): Promise<Response<PlanData>>;
|
|
97
|
-
|
|
98
|
-
private panelResult;
|
|
99
|
-
private fullResultRows;
|
|
100
|
-
exportResult(idOrAlias: string, output: string, format?: "json" | "jsonl" | "csv"): Promise<Response<ExportData>>;
|
|
72
|
+
exportResult(idOrAlias: string, output: string, format?: "json" | "jsonl" | "csv", columns?: string[]): Promise<Response<ExportData>>;
|
|
101
73
|
exec(sql: string, options?: ExecOptions): Promise<Response<ExecData>>;
|
|
102
74
|
mongoExec(command: MongoWriteCommand, options?: MongoExecOptions): Promise<Response<ExecData>>;
|
|
103
75
|
redisExec(command: RedisCommand, options?: RedisExecOptions): Promise<Response<ExecData>>;
|
|
@@ -119,30 +91,8 @@ export declare class StateQL {
|
|
|
119
91
|
capabilities(): Promise<Response<CapabilitiesData>>;
|
|
120
92
|
executeCommand(command: BatchCommand, context?: CommandExecutionContext): Promise<Response<unknown>>;
|
|
121
93
|
batch(commands: Iterable<BatchCommand> | AsyncIterable<BatchCommand>, options?: BatchOptions): AsyncGenerator<Response<unknown>>;
|
|
122
|
-
private performExec;
|
|
123
|
-
private performMongoExec;
|
|
124
|
-
private performRedisExec;
|
|
125
|
-
private performTableBatch;
|
|
126
94
|
private batchFailure;
|
|
127
|
-
private withResult;
|
|
128
|
-
private rejectDuringStagedTransaction;
|
|
129
|
-
private requireResult;
|
|
130
|
-
private requireConnection;
|
|
131
|
-
private requireMongoConnection;
|
|
132
|
-
private requireRedisConnection;
|
|
133
|
-
private rejectMongoSql;
|
|
134
|
-
private requireActiveTransaction;
|
|
135
95
|
private requireSelectedSession;
|
|
136
96
|
private validateActorId;
|
|
137
97
|
private validateActorName;
|
|
138
|
-
private throwMembershipDenied;
|
|
139
|
-
private resolveConnectionSource;
|
|
140
|
-
private resolveCredential;
|
|
141
|
-
private openAdapter;
|
|
142
|
-
private openMongoAdapter;
|
|
143
|
-
private openRedisAdapter;
|
|
144
|
-
private executionContext;
|
|
145
|
-
private resultData;
|
|
146
|
-
private cacheValid;
|
|
147
|
-
private run;
|
|
148
98
|
}
|