@axiom-lattice/gateway 2.1.39 → 2.1.41

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.
@@ -0,0 +1,252 @@
1
+ /**
2
+ * Data Query SDK TypeScript 类型定义
3
+ *
4
+ * 用于在 TypeScript 项目中提供类型支持
5
+ */
6
+
7
+ export interface SDKConfig {
8
+ /** Gateway 基础 URL,如 'http://localhost:4001' */
9
+ baseURL: string;
10
+ /** 租户 ID,可选 */
11
+ tenantId?: string;
12
+ /** 额外的请求头,可选 */
13
+ headers?: Record<string, string>;
14
+ /** 请求超时时间(毫秒),默认 30 秒 */
15
+ timeout?: number;
16
+ }
17
+
18
+ export interface Filter {
19
+ /** 维度/字段名 */
20
+ dimension: string;
21
+ /** 操作符,如 'BETWEEN', 'EQ', 'GT', 'LT', 'IN' */
22
+ operator: string;
23
+ /** 过滤值数组 */
24
+ values: (string | number | boolean)[];
25
+ }
26
+
27
+ export interface QueryParams {
28
+ /** 指标服务器 key */
29
+ serverKey: string;
30
+ /** 数据源 ID */
31
+ datasourceId: string;
32
+ /** 语义查询:指标名称数组 */
33
+ metrics?: string[];
34
+ /** 语义查询:分组维度数组 */
35
+ groupBy?: string[];
36
+ /** 语义查询:过滤器数组 */
37
+ filters?: Filter[];
38
+ /** SQL 查询:SQL 语句 */
39
+ customSql?: string;
40
+ /** SQL 查询:SQL 参数 */
41
+ params?: Record<string, string | number | boolean>;
42
+ /** 最大返回行数,默认 1000 */
43
+ limit?: number;
44
+ /** 返回格式:'echarts' 或 'raw',默认 'echarts' */
45
+ format?: 'echarts' | 'raw';
46
+ }
47
+
48
+ export interface SemanticQueryParams extends Omit<QueryParams, 'customSql' | 'params'> {
49
+ /** 指标名称数组(必填) */
50
+ metrics: string[];
51
+ }
52
+
53
+ export interface SQLQueryParams extends Omit<QueryParams, 'metrics' | 'groupBy' | 'filters'> {
54
+ /** SQL 语句(必填) */
55
+ sql: string;
56
+ /** SQL 参数 */
57
+ params?: Record<string, string | number | boolean>;
58
+ }
59
+
60
+ export interface SeriesConfig {
61
+ /** 系列名称 */
62
+ name: string;
63
+ /** 图表类型:'line', 'bar', 'pie' */
64
+ type: 'line' | 'bar' | 'pie';
65
+ /** 编码配置 */
66
+ encode?: {
67
+ x?: string;
68
+ y?: string;
69
+ };
70
+ }
71
+
72
+ export interface QueryResultData {
73
+ /** 维度数组 */
74
+ dimensions: string[];
75
+ /** 数据源数组(ECharts dataset.source 格式) */
76
+ source: Record<string, any>[];
77
+ /** 系列配置 */
78
+ series: SeriesConfig[];
79
+ /** 分页信息 */
80
+ pagination?: {
81
+ total: number;
82
+ limit: number;
83
+ offset: number;
84
+ };
85
+ /** 元数据 */
86
+ metadata: {
87
+ queryTimeMs: number;
88
+ rowCount: number;
89
+ };
90
+ }
91
+
92
+ export interface QueryResult {
93
+ /** 是否成功 */
94
+ success: boolean;
95
+ /** 消息 */
96
+ message: string;
97
+ /** 数据 */
98
+ data: QueryResultData;
99
+ }
100
+
101
+ export interface EChartsOption {
102
+ title?: { text: string };
103
+ tooltip?: { trigger: string };
104
+ legend?: { data: string[] };
105
+ dataset?: {
106
+ dimensions: string[];
107
+ source: Record<string, any>[];
108
+ };
109
+ xAxis?: { type: string };
110
+ yAxis?: { type: string };
111
+ series: any[];
112
+ }
113
+
114
+ export interface EChartsOptionConfig {
115
+ /** 图表标题 */
116
+ title?: string;
117
+ /** 图表类型:'line', 'bar', 'pie',默认 'line' */
118
+ type?: 'line' | 'bar' | 'pie';
119
+ }
120
+
121
+ /**
122
+ * Data Query SDK 类
123
+ */
124
+ export declare class DataQuerySDK {
125
+ /**
126
+ * 创建 SDK 实例
127
+ * @param config - 配置对象
128
+ */
129
+ constructor(config: SDKConfig);
130
+
131
+ /**
132
+ * 执行数据查询
133
+ * @param params - 查询参数
134
+ * @returns 查询结果
135
+ */
136
+ query(params: QueryParams): Promise<QueryResult>;
137
+
138
+ /**
139
+ * 语义查询快捷方法
140
+ * @param params - 语义查询参数
141
+ * @returns 查询结果
142
+ */
143
+ semanticQuery(params: SemanticQueryParams): Promise<QueryResult>;
144
+
145
+ /**
146
+ * SQL 查询快捷方法
147
+ * @param params - SQL 查询参数
148
+ * @returns 查询结果
149
+ */
150
+ sqlQuery(params: SQLQueryParams): Promise<QueryResult>;
151
+
152
+ /**
153
+ * 获取 ECharts 配置
154
+ * @param result - query 方法返回的结果
155
+ * @param options - 图表配置选项
156
+ * @returns ECharts 配置对象
157
+ */
158
+ toEChartsOption(result: QueryResult, options?: EChartsOptionConfig): EChartsOption;
159
+ }
160
+
161
+ // DashboardEngine Types
162
+
163
+ export interface SeriesMapping {
164
+ y: string;
165
+ type: 'bar' | 'line';
166
+ name: string;
167
+ yAxisIndex?: number;
168
+ area?: boolean;
169
+ }
170
+
171
+ export interface WidgetMapping {
172
+ x?: string;
173
+ xName?: string;
174
+ yAxisNames?: string[];
175
+ series?: SeriesMapping[];
176
+ y?: string;
177
+ yName?: string;
178
+ name?: string;
179
+ value?: string;
180
+ size?: string;
181
+ color?: string;
182
+ dimensions?: string[];
183
+ nameField?: string;
184
+ max?: number;
185
+ }
186
+
187
+ export interface WidgetQuery {
188
+ metrics: string[];
189
+ groupBy?: string[];
190
+ serverKey: string;
191
+ datasourceId: string;
192
+ filters?: Filter[];
193
+ }
194
+
195
+ export interface WidgetConfig {
196
+ id: string;
197
+ title: string;
198
+ type: 'bar' | 'line' | 'pie' | 'kpi' | 'scatter' | 'radar' | 'funnel' | 'gauge' | 'heatmap' | 'treemap' | 'custom';
199
+ gridClass?: string;
200
+ query: WidgetQuery;
201
+ mapping: WidgetMapping;
202
+ optionOverride?: Record<string, any>;
203
+ getOption?: (rows: any[], config: WidgetConfig) => Record<string, any>;
204
+ }
205
+
206
+ export interface FilterOption {
207
+ value: string;
208
+ text: string;
209
+ }
210
+
211
+ export interface FilterConfig {
212
+ id: string;
213
+ label: string;
214
+ dimension: string;
215
+ operator: string;
216
+ defaultValue: string;
217
+ options: FilterOption[];
218
+ }
219
+
220
+ export interface DashboardConfig {
221
+ widgets: WidgetConfig[];
222
+ filters: FilterConfig[];
223
+ }
224
+
225
+ export interface ChartTypeHandler {
226
+ validate: (config: WidgetConfig) => boolean;
227
+ generateOption: (rows: any[], mapping: WidgetMapping, baseOption: Record<string, any>) => Record<string, any>;
228
+ }
229
+
230
+ /**
231
+ * DashboardEngine - 声明式看板渲染引擎
232
+ */
233
+ export declare class DashboardEngine {
234
+ constructor(sdk: DataQuerySDK, config: DashboardConfig);
235
+
236
+ /** 初始化看板 */
237
+ init(): Promise<void>;
238
+
239
+ /** 刷新所有图表 */
240
+ refreshAll(): Promise<void>;
241
+
242
+ /** 刷新单个图表 */
243
+ refreshWidget(config: WidgetConfig): Promise<void>;
244
+
245
+ /** 销毁看板,清理资源 */
246
+ destroy(): void;
247
+
248
+ /** 注册自定义图表类型 */
249
+ static registerChartType(type: string, handler: ChartTypeHandler): void;
250
+ }
251
+
252
+ export default DataQuerySDK;