@object-ui/types 0.3.0 → 0.5.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 +19 -11
- package/dist/api-types.d.ts +7 -0
- package/dist/api-types.d.ts.map +1 -1
- package/dist/api-types.js +4 -6
- package/dist/app.d.ts +17 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +4 -3
- package/dist/base.d.ts +7 -0
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +4 -6
- package/dist/blocks.d.ts +332 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +8 -0
- package/dist/complex.d.ts +68 -1
- package/dist/complex.d.ts.map +1 -1
- package/dist/complex.js +4 -5
- package/dist/crud.d.ts +181 -3
- package/dist/crud.d.ts.map +1 -1
- package/dist/crud.js +4 -6
- package/dist/data-display.d.ts +54 -2
- package/dist/data-display.d.ts.map +1 -1
- package/dist/data-display.js +4 -5
- package/dist/data-protocol.d.ts +1268 -0
- package/dist/data-protocol.d.ts.map +1 -0
- package/dist/data-protocol.js +8 -0
- package/dist/data.d.ts +22 -1
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +4 -6
- package/dist/disclosure.d.ts +70 -1
- package/dist/disclosure.d.ts.map +1 -1
- package/dist/disclosure.js +4 -5
- package/dist/feedback.d.ts +68 -1
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +4 -5
- package/dist/field-types.d.ts +728 -0
- package/dist/field-types.d.ts.map +1 -0
- package/dist/field-types.js +8 -0
- package/dist/form.d.ts +123 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +4 -5
- package/dist/index.d.ts +48 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -37
- package/dist/layout.d.ts +66 -16
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +4 -6
- package/dist/navigation.d.ts +102 -2
- package/dist/navigation.d.ts.map +1 -1
- package/dist/navigation.js +4 -5
- package/dist/objectql.d.ts +491 -54
- package/dist/objectql.d.ts.map +1 -1
- package/dist/objectql.js +4 -6
- package/dist/overlay.d.ts +31 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +4 -5
- package/dist/plugin-scope.d.ts +194 -0
- package/dist/plugin-scope.d.ts.map +1 -0
- package/dist/plugin-scope.js +8 -0
- package/dist/registry.d.ts +7 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +7 -0
- package/dist/reports.d.ts +336 -0
- package/dist/reports.d.ts.map +1 -0
- package/dist/reports.js +8 -0
- package/dist/theme.d.ts +289 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +8 -0
- package/dist/ui-action.d.ts +175 -0
- package/dist/ui-action.d.ts.map +1 -0
- package/dist/ui-action.js +8 -0
- package/dist/views.d.ts +417 -0
- package/dist/views.d.ts.map +1 -0
- package/dist/views.js +8 -0
- package/dist/zod/app.zod.d.ts +120 -0
- package/dist/zod/app.zod.d.ts.map +1 -0
- package/dist/zod/app.zod.js +60 -0
- package/dist/zod/base.zod.d.ts +202 -0
- package/dist/zod/base.zod.d.ts.map +1 -0
- package/dist/zod/base.zod.js +198 -0
- package/dist/zod/blocks.zod.d.ts +834 -0
- package/dist/zod/blocks.zod.d.ts.map +1 -0
- package/dist/zod/blocks.zod.js +145 -0
- package/dist/zod/complex.zod.d.ts +742 -0
- package/dist/zod/complex.zod.d.ts.map +1 -0
- package/dist/zod/complex.zod.js +233 -0
- package/dist/zod/crud.zod.d.ts +598 -0
- package/dist/zod/crud.zod.d.ts.map +1 -0
- package/dist/zod/crud.zod.js +230 -0
- package/dist/zod/data-display.zod.d.ts +996 -0
- package/dist/zod/data-display.zod.d.ts.map +1 -0
- package/dist/zod/data-display.zod.js +266 -0
- package/dist/zod/disclosure.zod.d.ts +267 -0
- package/dist/zod/disclosure.zod.d.ts.map +1 -0
- package/dist/zod/disclosure.zod.js +84 -0
- package/dist/zod/feedback.zod.d.ts +538 -0
- package/dist/zod/feedback.zod.d.ts.map +1 -0
- package/dist/zod/feedback.zod.js +127 -0
- package/dist/zod/form.zod.d.ts +1308 -0
- package/dist/zod/form.zod.d.ts.map +1 -0
- package/dist/zod/form.zod.js +406 -0
- package/dist/zod/index.zod.d.ts +4985 -0
- package/dist/zod/index.zod.d.ts.map +1 -0
- package/dist/zod/index.zod.js +183 -0
- package/dist/zod/layout.zod.d.ts +1048 -0
- package/dist/zod/layout.zod.d.ts.map +1 -0
- package/dist/zod/layout.zod.js +241 -0
- package/dist/zod/navigation.zod.d.ts +486 -0
- package/dist/zod/navigation.zod.d.ts.map +1 -0
- package/dist/zod/navigation.zod.js +142 -0
- package/dist/zod/objectql.zod.d.ts +1261 -0
- package/dist/zod/objectql.zod.d.ts.map +1 -0
- package/dist/zod/objectql.zod.js +248 -0
- package/dist/zod/overlay.zod.d.ts +691 -0
- package/dist/zod/overlay.zod.d.ts.map +1 -0
- package/dist/zod/overlay.zod.js +179 -0
- package/dist/zod/reports.zod.d.ts +1628 -0
- package/dist/zod/reports.zod.d.ts.map +1 -0
- package/dist/zod/reports.zod.js +152 -0
- package/dist/zod/theme.zod.d.ts +611 -0
- package/dist/zod/theme.zod.d.ts.map +1 -0
- package/dist/zod/theme.zod.js +130 -0
- package/dist/zod/views.zod.d.ts +675 -0
- package/dist/zod/views.zod.d.ts.map +1 -0
- package/dist/zod/views.zod.js +159 -0
- package/package.json +9 -1
- package/src/__tests__/namespace-exports.test.ts +80 -0
- package/src/__tests__/phase2-schemas.test.ts +639 -0
- package/src/api-types.ts +8 -0
- package/src/app.ts +20 -0
- package/src/base.ts +8 -0
- package/src/blocks.ts +405 -0
- package/src/complex.ts +69 -1
- package/src/crud.ts +185 -3
- package/src/data-display.ts +60 -2
- package/src/data-protocol.ts +1679 -0
- package/src/data.ts +21 -1
- package/src/disclosure.ts +74 -1
- package/src/feedback.ts +76 -2
- package/src/field-types.ts +846 -0
- package/src/form.ts +131 -1
- package/src/index.ts +305 -8
- package/src/layout.ts +70 -15
- package/src/navigation.ts +109 -2
- package/src/objectql.ts +563 -59
- package/src/overlay.ts +35 -1
- package/src/plugin-scope.ts +210 -0
- package/src/registry.ts +8 -0
- package/src/reports.ts +408 -0
- package/src/theme.ts +351 -0
- package/src/ui-action.ts +276 -0
- package/src/views.ts +429 -0
- package/src/zod/README.md +329 -0
- package/src/zod/app.zod.ts +72 -0
- package/src/zod/base.zod.ts +229 -0
- package/src/zod/blocks.zod.ts +170 -0
- package/src/zod/complex.zod.ts +258 -0
- package/src/zod/crud.zod.ts +259 -0
- package/src/zod/data-display.zod.ts +290 -0
- package/src/zod/disclosure.zod.ts +92 -0
- package/src/zod/feedback.zod.ts +138 -0
- package/src/zod/form.zod.ts +434 -0
- package/src/zod/index.zod.ts +425 -0
- package/src/zod/layout.zod.ts +262 -0
- package/src/zod/navigation.zod.ts +159 -0
- package/src/zod/objectql.zod.ts +268 -0
- package/src/zod/overlay.zod.ts +196 -0
- package/src/zod/reports.zod.ts +183 -0
- package/src/zod/theme.zod.ts +155 -0
- package/src/zod/views.zod.ts +182 -0
|
@@ -0,0 +1,1268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @object-ui/types - Data Protocol Advanced Types
|
|
10
|
+
*
|
|
11
|
+
* Phase 3: Complete implementation of QuerySchema, FilterSchema,
|
|
12
|
+
* ValidationSchema, DriverInterface, and DatasourceSchema.
|
|
13
|
+
*
|
|
14
|
+
* @module data-protocol
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
*/
|
|
17
|
+
import type { SortConfig as BaseSortConfig } from './objectql';
|
|
18
|
+
import type { FilterOperator as BaseFilterOperator } from './complex';
|
|
19
|
+
/**
|
|
20
|
+
* =============================================================================
|
|
21
|
+
* Phase 3.3: QuerySchema AST Implementation
|
|
22
|
+
* =============================================================================
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Query AST Node Types
|
|
26
|
+
*/
|
|
27
|
+
export type QueryASTNodeType = 'select' | 'from' | 'where' | 'join' | 'group_by' | 'order_by' | 'limit' | 'offset' | 'subquery' | 'aggregate' | 'window' | 'field' | 'literal' | 'operator' | 'function';
|
|
28
|
+
/**
|
|
29
|
+
* Base Query AST Node
|
|
30
|
+
*/
|
|
31
|
+
export interface QueryASTNode {
|
|
32
|
+
type: QueryASTNodeType;
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* SELECT clause node
|
|
37
|
+
*/
|
|
38
|
+
export interface SelectNode extends QueryASTNode {
|
|
39
|
+
type: 'select';
|
|
40
|
+
fields: (FieldNode | AggregateNode | WindowNode)[];
|
|
41
|
+
distinct?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* FROM clause node
|
|
45
|
+
*/
|
|
46
|
+
export interface FromNode extends QueryASTNode {
|
|
47
|
+
type: 'from';
|
|
48
|
+
table: string;
|
|
49
|
+
alias?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* WHERE clause node
|
|
53
|
+
*/
|
|
54
|
+
export interface WhereNode extends QueryASTNode {
|
|
55
|
+
type: 'where';
|
|
56
|
+
condition: OperatorNode;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Join execution strategy hint (ObjectStack Spec v0.7.1)
|
|
60
|
+
*/
|
|
61
|
+
export type JoinStrategy = 'auto' | 'database' | 'hash' | 'loop';
|
|
62
|
+
/**
|
|
63
|
+
* JOIN clause node (Phase 3.3.4)
|
|
64
|
+
*/
|
|
65
|
+
export interface JoinNode extends QueryASTNode {
|
|
66
|
+
type: 'join';
|
|
67
|
+
join_type: 'inner' | 'left' | 'right' | 'full' | 'cross';
|
|
68
|
+
table: string;
|
|
69
|
+
alias?: string;
|
|
70
|
+
on: OperatorNode;
|
|
71
|
+
strategy?: JoinStrategy;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* GROUP BY clause node
|
|
75
|
+
*/
|
|
76
|
+
export interface GroupByNode extends QueryASTNode {
|
|
77
|
+
type: 'group_by';
|
|
78
|
+
fields: FieldNode[];
|
|
79
|
+
having?: OperatorNode;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* ORDER BY clause node
|
|
83
|
+
*/
|
|
84
|
+
export interface OrderByNode extends QueryASTNode {
|
|
85
|
+
type: 'order_by';
|
|
86
|
+
fields: Array<{
|
|
87
|
+
field: FieldNode;
|
|
88
|
+
direction: 'asc' | 'desc';
|
|
89
|
+
}>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* LIMIT clause node
|
|
93
|
+
*/
|
|
94
|
+
export interface LimitNode extends QueryASTNode {
|
|
95
|
+
type: 'limit';
|
|
96
|
+
value: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* OFFSET clause node
|
|
100
|
+
*/
|
|
101
|
+
export interface OffsetNode extends QueryASTNode {
|
|
102
|
+
type: 'offset';
|
|
103
|
+
value: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Subquery node (Phase 3.3.3)
|
|
107
|
+
*/
|
|
108
|
+
export interface SubqueryNode extends QueryASTNode {
|
|
109
|
+
type: 'subquery';
|
|
110
|
+
query: QueryAST;
|
|
111
|
+
alias?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Aggregate function node (Phase 3.3.5)
|
|
115
|
+
*/
|
|
116
|
+
export interface AggregateNode extends QueryASTNode {
|
|
117
|
+
type: 'aggregate';
|
|
118
|
+
function: 'count' | 'sum' | 'avg' | 'min' | 'max' | 'first' | 'last' | 'count_distinct' | 'array_agg' | 'string_agg';
|
|
119
|
+
field?: FieldNode;
|
|
120
|
+
alias?: string;
|
|
121
|
+
distinct?: boolean;
|
|
122
|
+
separator?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Window function type (ObjectStack Spec v0.7.1)
|
|
126
|
+
*/
|
|
127
|
+
export type WindowFunction = 'row_number' | 'rank' | 'dense_rank' | 'percent_rank' | 'lag' | 'lead' | 'first_value' | 'last_value' | 'sum' | 'avg' | 'count' | 'min' | 'max';
|
|
128
|
+
/**
|
|
129
|
+
* Window frame unit (ObjectStack Spec v0.7.1)
|
|
130
|
+
*/
|
|
131
|
+
export type WindowFrameUnit = 'rows' | 'range';
|
|
132
|
+
/**
|
|
133
|
+
* Window frame boundary (ObjectStack Spec v0.7.1)
|
|
134
|
+
*/
|
|
135
|
+
export type WindowFrameBoundary = 'unbounded_preceding' | 'unbounded_following' | 'current_row' | {
|
|
136
|
+
type: 'preceding';
|
|
137
|
+
offset: number;
|
|
138
|
+
} | {
|
|
139
|
+
type: 'following';
|
|
140
|
+
offset: number;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Window frame specification (ObjectStack Spec v0.7.1)
|
|
144
|
+
*/
|
|
145
|
+
export interface WindowFrame {
|
|
146
|
+
unit: WindowFrameUnit;
|
|
147
|
+
start: WindowFrameBoundary;
|
|
148
|
+
end?: WindowFrameBoundary;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Window function node (ObjectStack Spec v0.7.1)
|
|
152
|
+
*/
|
|
153
|
+
export interface WindowNode extends QueryASTNode {
|
|
154
|
+
type: 'window';
|
|
155
|
+
function: WindowFunction;
|
|
156
|
+
field?: FieldNode;
|
|
157
|
+
alias: string;
|
|
158
|
+
partitionBy?: FieldNode[];
|
|
159
|
+
orderBy?: Array<{
|
|
160
|
+
field: FieldNode;
|
|
161
|
+
direction: 'asc' | 'desc';
|
|
162
|
+
}>;
|
|
163
|
+
frame?: WindowFrame;
|
|
164
|
+
offset?: number;
|
|
165
|
+
defaultValue?: LiteralNode;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Field reference node
|
|
169
|
+
*/
|
|
170
|
+
export interface FieldNode extends QueryASTNode {
|
|
171
|
+
type: 'field';
|
|
172
|
+
table?: string;
|
|
173
|
+
name: string;
|
|
174
|
+
alias?: string;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Literal value node
|
|
178
|
+
*/
|
|
179
|
+
export interface LiteralNode extends QueryASTNode {
|
|
180
|
+
type: 'literal';
|
|
181
|
+
value: any;
|
|
182
|
+
data_type?: 'string' | 'number' | 'boolean' | 'date' | 'null';
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Operator node
|
|
186
|
+
*/
|
|
187
|
+
export interface OperatorNode extends QueryASTNode {
|
|
188
|
+
type: 'operator';
|
|
189
|
+
operator: ComparisonOperator | LogicalOperator;
|
|
190
|
+
operands: (FieldNode | LiteralNode | OperatorNode | FunctionNode)[];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Function call node
|
|
194
|
+
*/
|
|
195
|
+
export interface FunctionNode extends QueryASTNode {
|
|
196
|
+
type: 'function';
|
|
197
|
+
name: string;
|
|
198
|
+
arguments: (FieldNode | LiteralNode | FunctionNode)[];
|
|
199
|
+
alias?: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Comparison operators
|
|
203
|
+
*/
|
|
204
|
+
export type ComparisonOperator = '=' | '!=' | '<>' | '>' | '>=' | '<' | '<=' | 'like' | 'ilike' | 'in' | 'not_in' | 'is_null' | 'is_not_null' | 'between' | 'contains' | 'starts_with' | 'ends_with';
|
|
205
|
+
/**
|
|
206
|
+
* Logical operators
|
|
207
|
+
*/
|
|
208
|
+
export type LogicalOperator = 'and' | 'or' | 'not';
|
|
209
|
+
/**
|
|
210
|
+
* Complete Query AST (Phase 3.3.1)
|
|
211
|
+
*/
|
|
212
|
+
export interface QueryAST {
|
|
213
|
+
select: SelectNode;
|
|
214
|
+
from: FromNode;
|
|
215
|
+
joins?: JoinNode[];
|
|
216
|
+
where?: WhereNode;
|
|
217
|
+
group_by?: GroupByNode;
|
|
218
|
+
order_by?: OrderByNode;
|
|
219
|
+
limit?: LimitNode;
|
|
220
|
+
offset?: OffsetNode;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Query Schema - High-level query configuration
|
|
224
|
+
*/
|
|
225
|
+
export interface QuerySchema {
|
|
226
|
+
/**
|
|
227
|
+
* Target object/table
|
|
228
|
+
*/
|
|
229
|
+
object: string;
|
|
230
|
+
/**
|
|
231
|
+
* Fields to select
|
|
232
|
+
*/
|
|
233
|
+
fields?: string[];
|
|
234
|
+
/**
|
|
235
|
+
* Filter conditions
|
|
236
|
+
*/
|
|
237
|
+
filter?: AdvancedFilterSchema;
|
|
238
|
+
/**
|
|
239
|
+
* Sort configuration
|
|
240
|
+
*/
|
|
241
|
+
sort?: QuerySortConfig[];
|
|
242
|
+
/**
|
|
243
|
+
* Pagination
|
|
244
|
+
*/
|
|
245
|
+
limit?: number;
|
|
246
|
+
offset?: number;
|
|
247
|
+
/**
|
|
248
|
+
* Joins (Phase 3.3.4)
|
|
249
|
+
*/
|
|
250
|
+
joins?: JoinConfig[];
|
|
251
|
+
/**
|
|
252
|
+
* Aggregations (Phase 3.3.5)
|
|
253
|
+
*/
|
|
254
|
+
aggregations?: AggregationConfig[];
|
|
255
|
+
/**
|
|
256
|
+
* Group by fields
|
|
257
|
+
*/
|
|
258
|
+
group_by?: string[];
|
|
259
|
+
/**
|
|
260
|
+
* Window functions (ObjectStack Spec v0.7.1)
|
|
261
|
+
*/
|
|
262
|
+
windows?: WindowConfig[];
|
|
263
|
+
/**
|
|
264
|
+
* Related objects to expand
|
|
265
|
+
*/
|
|
266
|
+
expand?: string[];
|
|
267
|
+
/**
|
|
268
|
+
* Full-text search
|
|
269
|
+
*/
|
|
270
|
+
search?: string;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Sort configuration (extends base SortConfig)
|
|
274
|
+
*/
|
|
275
|
+
export interface QuerySortConfig extends BaseSortConfig {
|
|
276
|
+
nulls?: 'first' | 'last';
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Join configuration
|
|
280
|
+
*/
|
|
281
|
+
export interface JoinConfig {
|
|
282
|
+
type: 'inner' | 'left' | 'right' | 'full';
|
|
283
|
+
object: string;
|
|
284
|
+
on: {
|
|
285
|
+
local_field: string;
|
|
286
|
+
foreign_field: string;
|
|
287
|
+
};
|
|
288
|
+
alias?: string;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Aggregation configuration
|
|
292
|
+
*/
|
|
293
|
+
export interface AggregationConfig {
|
|
294
|
+
function: 'count' | 'sum' | 'avg' | 'min' | 'max' | 'count_distinct' | 'array_agg' | 'string_agg';
|
|
295
|
+
field?: string;
|
|
296
|
+
alias?: string;
|
|
297
|
+
distinct?: boolean;
|
|
298
|
+
separator?: string;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Window function configuration (ObjectStack Spec v0.7.1)
|
|
302
|
+
*/
|
|
303
|
+
export interface WindowConfig {
|
|
304
|
+
/** Window function name */
|
|
305
|
+
function: WindowFunction;
|
|
306
|
+
/** Field to operate on (not required for row_number, rank, etc.) */
|
|
307
|
+
field?: string;
|
|
308
|
+
/** Result alias */
|
|
309
|
+
alias: string;
|
|
310
|
+
/** PARTITION BY fields */
|
|
311
|
+
partitionBy?: string[];
|
|
312
|
+
/** ORDER BY clause */
|
|
313
|
+
orderBy?: Array<{
|
|
314
|
+
field: string;
|
|
315
|
+
direction: 'asc' | 'desc';
|
|
316
|
+
}>;
|
|
317
|
+
/** Window frame specification */
|
|
318
|
+
frame?: WindowFrame;
|
|
319
|
+
/** Offset for lag/lead functions */
|
|
320
|
+
offset?: number;
|
|
321
|
+
/** Default value for lag/lead when no previous/next row */
|
|
322
|
+
defaultValue?: any;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* =============================================================================
|
|
326
|
+
* Phase 3.4: FilterSchema - Advanced Filtering
|
|
327
|
+
* =============================================================================
|
|
328
|
+
*/
|
|
329
|
+
/**
|
|
330
|
+
* Filter Schema - Complex filtering support (extends base)
|
|
331
|
+
*/
|
|
332
|
+
export interface AdvancedFilterSchema {
|
|
333
|
+
/**
|
|
334
|
+
* Logical operator for combining conditions
|
|
335
|
+
*/
|
|
336
|
+
operator?: 'and' | 'or' | 'not';
|
|
337
|
+
/**
|
|
338
|
+
* Filter conditions
|
|
339
|
+
*/
|
|
340
|
+
conditions?: AdvancedFilterCondition[];
|
|
341
|
+
/**
|
|
342
|
+
* Nested filter groups
|
|
343
|
+
*/
|
|
344
|
+
groups?: AdvancedFilterSchema[];
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Individual filter condition (extends base)
|
|
348
|
+
*/
|
|
349
|
+
export interface AdvancedFilterCondition {
|
|
350
|
+
/**
|
|
351
|
+
* Field to filter on
|
|
352
|
+
*/
|
|
353
|
+
field: string;
|
|
354
|
+
/**
|
|
355
|
+
* Comparison operator (extended)
|
|
356
|
+
*/
|
|
357
|
+
operator: AdvancedFilterOperator;
|
|
358
|
+
/**
|
|
359
|
+
* Value to compare against
|
|
360
|
+
*/
|
|
361
|
+
value?: any;
|
|
362
|
+
/**
|
|
363
|
+
* For BETWEEN and IN operators
|
|
364
|
+
*/
|
|
365
|
+
values?: any[];
|
|
366
|
+
/**
|
|
367
|
+
* Case sensitivity for string comparisons
|
|
368
|
+
*/
|
|
369
|
+
case_sensitive?: boolean;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Filter operators (Phase 3.4.1-3.4.4) - Extended from base
|
|
373
|
+
*/
|
|
374
|
+
export type AdvancedFilterOperator = BaseFilterOperator | 'like' | 'ilike' | 'is_null' | 'is_not_null' | 'between' | 'not_between' | 'date_equals' | 'date_after' | 'date_before' | 'date_in_range' | 'date_today' | 'date_yesterday' | 'date_tomorrow' | 'date_this_week' | 'date_last_week' | 'date_next_week' | 'date_this_month' | 'date_last_month' | 'date_next_month' | 'date_this_year' | 'date_last_year' | 'date_next_year' | 'lookup_equals' | 'lookup_contains' | 'lookup_starts_with' | 'search' | 'search_phrase' | 'search_proximity';
|
|
375
|
+
/**
|
|
376
|
+
* Date range filter (Phase 3.4.2)
|
|
377
|
+
*/
|
|
378
|
+
export interface DateRangeFilter {
|
|
379
|
+
start?: Date | string;
|
|
380
|
+
end?: Date | string;
|
|
381
|
+
preset?: DateRangePreset;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Date range presets
|
|
385
|
+
*/
|
|
386
|
+
export type DateRangePreset = 'today' | 'yesterday' | 'tomorrow' | 'this_week' | 'last_week' | 'next_week' | 'this_month' | 'last_month' | 'next_month' | 'this_quarter' | 'last_quarter' | 'next_quarter' | 'this_year' | 'last_year' | 'next_year' | 'last_7_days' | 'last_30_days' | 'last_90_days' | 'next_7_days' | 'next_30_days' | 'next_90_days';
|
|
387
|
+
/**
|
|
388
|
+
* Filter builder configuration (Phase 3.4.5)
|
|
389
|
+
*/
|
|
390
|
+
export interface FilterBuilderConfig {
|
|
391
|
+
/**
|
|
392
|
+
* Available fields for filtering
|
|
393
|
+
*/
|
|
394
|
+
fields: FilterFieldConfig[];
|
|
395
|
+
/**
|
|
396
|
+
* Default operator
|
|
397
|
+
*/
|
|
398
|
+
default_operator?: 'and' | 'or';
|
|
399
|
+
/**
|
|
400
|
+
* Allow nested groups
|
|
401
|
+
*/
|
|
402
|
+
allow_groups?: boolean;
|
|
403
|
+
/**
|
|
404
|
+
* Maximum nesting depth
|
|
405
|
+
*/
|
|
406
|
+
max_depth?: number;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Filter field configuration
|
|
410
|
+
*/
|
|
411
|
+
export interface FilterFieldConfig {
|
|
412
|
+
/**
|
|
413
|
+
* Field name
|
|
414
|
+
*/
|
|
415
|
+
name: string;
|
|
416
|
+
/**
|
|
417
|
+
* Display label
|
|
418
|
+
*/
|
|
419
|
+
label: string;
|
|
420
|
+
/**
|
|
421
|
+
* Field type
|
|
422
|
+
*/
|
|
423
|
+
type: string;
|
|
424
|
+
/**
|
|
425
|
+
* Available operators for this field
|
|
426
|
+
*/
|
|
427
|
+
operators?: AdvancedFilterOperator[];
|
|
428
|
+
/**
|
|
429
|
+
* Options for select fields
|
|
430
|
+
*/
|
|
431
|
+
options?: Array<{
|
|
432
|
+
label: string;
|
|
433
|
+
value: any;
|
|
434
|
+
}>;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* =============================================================================
|
|
438
|
+
* Phase 3.5: ValidationSchema - Complete Validation Engine
|
|
439
|
+
* =============================================================================
|
|
440
|
+
*/
|
|
441
|
+
/**
|
|
442
|
+
* Validation Schema (Phase 3.5)
|
|
443
|
+
*/
|
|
444
|
+
export interface AdvancedValidationSchema {
|
|
445
|
+
/**
|
|
446
|
+
* Field name to validate
|
|
447
|
+
*/
|
|
448
|
+
field?: string;
|
|
449
|
+
/**
|
|
450
|
+
* Validation rules
|
|
451
|
+
*/
|
|
452
|
+
rules: AdvancedValidationRule[];
|
|
453
|
+
/**
|
|
454
|
+
* Custom error messages
|
|
455
|
+
*/
|
|
456
|
+
messages?: Record<string, string>;
|
|
457
|
+
/**
|
|
458
|
+
* Validation triggers
|
|
459
|
+
*/
|
|
460
|
+
on?: ('blur' | 'change' | 'submit')[];
|
|
461
|
+
/**
|
|
462
|
+
* Whether validation is async
|
|
463
|
+
*/
|
|
464
|
+
async?: boolean;
|
|
465
|
+
/**
|
|
466
|
+
* Debounce time for async validation (ms)
|
|
467
|
+
*/
|
|
468
|
+
debounce?: number;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Validation rule (Phase 3.5.1-3.5.4) - Extended
|
|
472
|
+
*/
|
|
473
|
+
export interface AdvancedValidationRule {
|
|
474
|
+
/**
|
|
475
|
+
* Rule type
|
|
476
|
+
*/
|
|
477
|
+
type: ValidationRuleType;
|
|
478
|
+
/**
|
|
479
|
+
* Rule parameters
|
|
480
|
+
*/
|
|
481
|
+
params?: any;
|
|
482
|
+
/**
|
|
483
|
+
* Error message
|
|
484
|
+
*/
|
|
485
|
+
message?: string;
|
|
486
|
+
/**
|
|
487
|
+
* Custom validation function (Phase 3.5.2)
|
|
488
|
+
*/
|
|
489
|
+
validator?: ValidationFunction;
|
|
490
|
+
/**
|
|
491
|
+
* Async validation function (Phase 3.5.3)
|
|
492
|
+
*/
|
|
493
|
+
async_validator?: AsyncValidationFunction;
|
|
494
|
+
/**
|
|
495
|
+
* Cross-field dependencies (Phase 3.5.4)
|
|
496
|
+
*/
|
|
497
|
+
depends_on?: string[];
|
|
498
|
+
/**
|
|
499
|
+
* Validation severity
|
|
500
|
+
*/
|
|
501
|
+
severity?: 'error' | 'warning' | 'info';
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Validation rule types
|
|
505
|
+
*/
|
|
506
|
+
export type ValidationRuleType = 'required' | 'min_length' | 'max_length' | 'pattern' | 'email' | 'url' | 'phone' | 'min' | 'max' | 'integer' | 'positive' | 'negative' | 'date_min' | 'date_max' | 'date_range' | 'date_future' | 'date_past' | 'min_items' | 'max_items' | 'unique_items' | 'object_schema' | 'field_match' | 'field_compare' | 'conditional' | 'custom' | 'async_custom' | 'remote_validation' | 'unique_check' | 'exists_check';
|
|
507
|
+
/**
|
|
508
|
+
* Validation function signature used by AdvancedValidationRule in the data protocol.
|
|
509
|
+
*
|
|
510
|
+
* This type is defined in this module and may differ from similarly named
|
|
511
|
+
* validation function types in other packages (e.g., in `field-types`).
|
|
512
|
+
*
|
|
513
|
+
* @param value - The value to validate
|
|
514
|
+
* @param context - Optional validation context with access to other field values
|
|
515
|
+
* @returns true if valid, false or error message string if invalid
|
|
516
|
+
*/
|
|
517
|
+
export type ValidationFunction = (value: any, context?: ValidationContext) => boolean | string;
|
|
518
|
+
/**
|
|
519
|
+
* Async validation function (Phase 3.5.3)
|
|
520
|
+
*/
|
|
521
|
+
export type AsyncValidationFunction = (value: any, context?: ValidationContext) => Promise<boolean | string>;
|
|
522
|
+
/**
|
|
523
|
+
* Validation context (Phase 3.5.4)
|
|
524
|
+
*/
|
|
525
|
+
export interface ValidationContext {
|
|
526
|
+
/**
|
|
527
|
+
* All form values
|
|
528
|
+
*/
|
|
529
|
+
values?: Record<string, any>;
|
|
530
|
+
/**
|
|
531
|
+
* Field metadata
|
|
532
|
+
*/
|
|
533
|
+
field?: any;
|
|
534
|
+
/**
|
|
535
|
+
* Parent object data
|
|
536
|
+
*/
|
|
537
|
+
parent?: any;
|
|
538
|
+
/**
|
|
539
|
+
* Current user context
|
|
540
|
+
*/
|
|
541
|
+
user?: any;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Validation result
|
|
545
|
+
*/
|
|
546
|
+
export interface AdvancedValidationResult {
|
|
547
|
+
/**
|
|
548
|
+
* Whether validation passed
|
|
549
|
+
*/
|
|
550
|
+
valid: boolean;
|
|
551
|
+
/**
|
|
552
|
+
* Validation errors
|
|
553
|
+
*/
|
|
554
|
+
errors: AdvancedValidationError[];
|
|
555
|
+
/**
|
|
556
|
+
* Validation warnings
|
|
557
|
+
*/
|
|
558
|
+
warnings?: AdvancedValidationError[];
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Validation error (Phase 3.5.5: Improved error messages)
|
|
562
|
+
*/
|
|
563
|
+
export interface AdvancedValidationError {
|
|
564
|
+
/**
|
|
565
|
+
* Field path
|
|
566
|
+
*/
|
|
567
|
+
field: string;
|
|
568
|
+
/**
|
|
569
|
+
* Error message
|
|
570
|
+
*/
|
|
571
|
+
message: string;
|
|
572
|
+
/**
|
|
573
|
+
* Error code
|
|
574
|
+
*/
|
|
575
|
+
code?: string;
|
|
576
|
+
/**
|
|
577
|
+
* Rule type that failed
|
|
578
|
+
*/
|
|
579
|
+
rule?: ValidationRuleType;
|
|
580
|
+
/**
|
|
581
|
+
* Error severity
|
|
582
|
+
*/
|
|
583
|
+
severity?: 'error' | 'warning' | 'info';
|
|
584
|
+
/**
|
|
585
|
+
* Additional context
|
|
586
|
+
*/
|
|
587
|
+
context?: Record<string, any>;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* =============================================================================
|
|
591
|
+
* ObjectStack Spec v0.7.1: Object-Level Validation Framework
|
|
592
|
+
* =============================================================================
|
|
593
|
+
*/
|
|
594
|
+
/**
|
|
595
|
+
* Base validation interface (ObjectStack Spec v0.7.1)
|
|
596
|
+
*/
|
|
597
|
+
export interface BaseValidation {
|
|
598
|
+
/** Unique validation name (snake_case) */
|
|
599
|
+
name: string;
|
|
600
|
+
/** Display label for the validation */
|
|
601
|
+
label?: string;
|
|
602
|
+
/** Description of what this validation does */
|
|
603
|
+
description?: string;
|
|
604
|
+
/** Whether this validation is currently active */
|
|
605
|
+
active: boolean;
|
|
606
|
+
/** When this validation should run */
|
|
607
|
+
events: Array<'insert' | 'update' | 'delete'>;
|
|
608
|
+
/** Severity of validation failure */
|
|
609
|
+
severity: 'error' | 'warning' | 'info';
|
|
610
|
+
/** Error message to display on failure */
|
|
611
|
+
message: string;
|
|
612
|
+
/** Tags for categorization */
|
|
613
|
+
tags?: string[];
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Script-based validation (ObjectStack Spec v0.7.1)
|
|
617
|
+
* Uses expression language to define conditions
|
|
618
|
+
*/
|
|
619
|
+
export interface ScriptValidation extends BaseValidation {
|
|
620
|
+
type: 'script';
|
|
621
|
+
/** Expression that must evaluate to true */
|
|
622
|
+
condition: string;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Uniqueness validation (ObjectStack Spec v0.7.1)
|
|
626
|
+
* Ensures field combinations are unique
|
|
627
|
+
*/
|
|
628
|
+
export interface UniquenessValidation extends BaseValidation {
|
|
629
|
+
type: 'unique';
|
|
630
|
+
/** Fields that must be unique together */
|
|
631
|
+
fields: string[];
|
|
632
|
+
/** Optional scope expression (e.g., "tenant_id = ${current_tenant}") */
|
|
633
|
+
scope?: string;
|
|
634
|
+
/** Whether comparison is case-sensitive */
|
|
635
|
+
caseSensitive?: boolean;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* State machine validation (ObjectStack Spec v0.7.1)
|
|
639
|
+
* Enforces valid state transitions
|
|
640
|
+
*/
|
|
641
|
+
export interface StateMachineValidation extends BaseValidation {
|
|
642
|
+
type: 'state_machine';
|
|
643
|
+
/** Field containing the state */
|
|
644
|
+
stateField: string;
|
|
645
|
+
/** Allowed state transitions */
|
|
646
|
+
transitions: Array<{
|
|
647
|
+
/** Source state(s) */
|
|
648
|
+
from: string | string[];
|
|
649
|
+
/** Target state */
|
|
650
|
+
to: string;
|
|
651
|
+
/** Optional condition that must be true */
|
|
652
|
+
condition?: string;
|
|
653
|
+
}>;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Cross-field validation (ObjectStack Spec v0.7.1)
|
|
657
|
+
* Validates relationships between multiple fields
|
|
658
|
+
*/
|
|
659
|
+
export interface CrossFieldValidation extends BaseValidation {
|
|
660
|
+
type: 'cross_field';
|
|
661
|
+
/** Fields involved in the validation */
|
|
662
|
+
fields: string[];
|
|
663
|
+
/** Condition expression involving multiple fields */
|
|
664
|
+
condition: string;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Async/remote validation (ObjectStack Spec v0.7.1)
|
|
668
|
+
* Calls external endpoint for validation
|
|
669
|
+
*/
|
|
670
|
+
export interface AsyncValidation extends BaseValidation {
|
|
671
|
+
type: 'async';
|
|
672
|
+
/** API endpoint to call */
|
|
673
|
+
endpoint: string;
|
|
674
|
+
/** HTTP method */
|
|
675
|
+
method?: 'GET' | 'POST';
|
|
676
|
+
/** Debounce delay in milliseconds */
|
|
677
|
+
debounce?: number;
|
|
678
|
+
/** Cache configuration */
|
|
679
|
+
cache?: {
|
|
680
|
+
enabled: boolean;
|
|
681
|
+
ttl?: number;
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Conditional validation (ObjectStack Spec v0.7.1)
|
|
686
|
+
* Applies nested rules only when condition is met
|
|
687
|
+
*/
|
|
688
|
+
export interface ConditionalValidation extends BaseValidation {
|
|
689
|
+
type: 'conditional';
|
|
690
|
+
/** Condition that determines if rules should apply */
|
|
691
|
+
condition: string;
|
|
692
|
+
/** Nested validation rules to apply when condition is true */
|
|
693
|
+
rules: ObjectValidationRule[];
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Format validation (ObjectStack Spec v0.7.1)
|
|
697
|
+
* Validates field format using regex or predefined patterns
|
|
698
|
+
*/
|
|
699
|
+
export interface FormatValidation extends BaseValidation {
|
|
700
|
+
type: 'format';
|
|
701
|
+
/** Field to validate */
|
|
702
|
+
field: string;
|
|
703
|
+
/** Regex pattern or predefined format name */
|
|
704
|
+
pattern: string | RegExp;
|
|
705
|
+
/** Predefined format (email, url, phone, etc.) */
|
|
706
|
+
format?: 'email' | 'url' | 'phone' | 'ipv4' | 'ipv6' | 'uuid' | 'iso_date' | 'credit_card';
|
|
707
|
+
/** Validation flags for regex (i, g, m, etc.) */
|
|
708
|
+
flags?: string;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Range validation (ObjectStack Spec v0.7.1)
|
|
712
|
+
* Validates numeric or date ranges
|
|
713
|
+
*/
|
|
714
|
+
export interface RangeValidation extends BaseValidation {
|
|
715
|
+
type: 'range';
|
|
716
|
+
/** Field to validate */
|
|
717
|
+
field: string;
|
|
718
|
+
/** Minimum value (inclusive) */
|
|
719
|
+
min?: number | string | Date;
|
|
720
|
+
/** Maximum value (inclusive) */
|
|
721
|
+
max?: number | string | Date;
|
|
722
|
+
/** Whether min is exclusive */
|
|
723
|
+
minExclusive?: boolean;
|
|
724
|
+
/** Whether max is exclusive */
|
|
725
|
+
maxExclusive?: boolean;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Union type for all validation rules (ObjectStack Spec v0.7.1)
|
|
729
|
+
*/
|
|
730
|
+
export type ObjectValidationRule = ScriptValidation | UniquenessValidation | StateMachineValidation | CrossFieldValidation | AsyncValidation | ConditionalValidation | FormatValidation | RangeValidation;
|
|
731
|
+
/**
|
|
732
|
+
* =============================================================================
|
|
733
|
+
* Phase 3.6: DriverInterface - Database Driver Abstraction
|
|
734
|
+
* =============================================================================
|
|
735
|
+
*/
|
|
736
|
+
/**
|
|
737
|
+
* Database Driver Interface (Phase 3.6)
|
|
738
|
+
*/
|
|
739
|
+
export interface DriverInterface {
|
|
740
|
+
/**
|
|
741
|
+
* Driver name
|
|
742
|
+
*/
|
|
743
|
+
name: string;
|
|
744
|
+
/**
|
|
745
|
+
* Driver version
|
|
746
|
+
*/
|
|
747
|
+
version?: string;
|
|
748
|
+
/**
|
|
749
|
+
* Connect to database
|
|
750
|
+
*/
|
|
751
|
+
connect(config: ConnectionConfig): Promise<void>;
|
|
752
|
+
/**
|
|
753
|
+
* Disconnect from database
|
|
754
|
+
*/
|
|
755
|
+
disconnect(): Promise<void>;
|
|
756
|
+
/**
|
|
757
|
+
* Execute query
|
|
758
|
+
*/
|
|
759
|
+
query<T = any>(sql: string, params?: any[]): Promise<DriverQueryResult<T>>;
|
|
760
|
+
/**
|
|
761
|
+
* Execute query from AST
|
|
762
|
+
*/
|
|
763
|
+
executeAST<T = any>(ast: QueryAST): Promise<DriverQueryResult<T>>;
|
|
764
|
+
/**
|
|
765
|
+
* Find records
|
|
766
|
+
*/
|
|
767
|
+
find<T = any>(table: string, query: QuerySchema): Promise<DriverQueryResult<T>>;
|
|
768
|
+
/**
|
|
769
|
+
* Find one record
|
|
770
|
+
*/
|
|
771
|
+
findOne<T = any>(table: string, id: any): Promise<T | null>;
|
|
772
|
+
/**
|
|
773
|
+
* Insert record
|
|
774
|
+
*/
|
|
775
|
+
insert<T = any>(table: string, data: Partial<T>): Promise<T>;
|
|
776
|
+
/**
|
|
777
|
+
* Update record
|
|
778
|
+
*/
|
|
779
|
+
update<T = any>(table: string, id: any, data: Partial<T>): Promise<T>;
|
|
780
|
+
/**
|
|
781
|
+
* Delete record
|
|
782
|
+
*/
|
|
783
|
+
delete(table: string, id: any): Promise<boolean>;
|
|
784
|
+
/**
|
|
785
|
+
* Batch operations (Phase 3.6.2)
|
|
786
|
+
*/
|
|
787
|
+
batch<T = any>(operations: BatchOperation[]): Promise<BatchResult<T>>;
|
|
788
|
+
/**
|
|
789
|
+
* Transaction support (Phase 3.6.1)
|
|
790
|
+
*/
|
|
791
|
+
transaction<T = any>(callback: (trx: TransactionContext) => Promise<T>): Promise<T>;
|
|
792
|
+
/**
|
|
793
|
+
* Get object schema
|
|
794
|
+
*/
|
|
795
|
+
getSchema(objectName: string): Promise<any>;
|
|
796
|
+
/**
|
|
797
|
+
* Cache management (Phase 3.6.4)
|
|
798
|
+
*/
|
|
799
|
+
cache?: CacheManager;
|
|
800
|
+
/**
|
|
801
|
+
* Connection pool (Phase 3.6.3)
|
|
802
|
+
*/
|
|
803
|
+
pool?: ConnectionPool;
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Connection configuration
|
|
807
|
+
*/
|
|
808
|
+
export interface ConnectionConfig {
|
|
809
|
+
/**
|
|
810
|
+
* Database host
|
|
811
|
+
*/
|
|
812
|
+
host?: string;
|
|
813
|
+
/**
|
|
814
|
+
* Database port
|
|
815
|
+
*/
|
|
816
|
+
port?: number;
|
|
817
|
+
/**
|
|
818
|
+
* Database name
|
|
819
|
+
*/
|
|
820
|
+
database?: string;
|
|
821
|
+
/**
|
|
822
|
+
* Username
|
|
823
|
+
*/
|
|
824
|
+
username?: string;
|
|
825
|
+
/**
|
|
826
|
+
* Password
|
|
827
|
+
*/
|
|
828
|
+
password?: string;
|
|
829
|
+
/**
|
|
830
|
+
* Connection URL
|
|
831
|
+
*/
|
|
832
|
+
url?: string;
|
|
833
|
+
/**
|
|
834
|
+
* SSL configuration
|
|
835
|
+
*/
|
|
836
|
+
ssl?: boolean | object;
|
|
837
|
+
/**
|
|
838
|
+
* Pool configuration (Phase 3.6.3)
|
|
839
|
+
*/
|
|
840
|
+
pool?: {
|
|
841
|
+
min?: number;
|
|
842
|
+
max?: number;
|
|
843
|
+
idle_timeout?: number;
|
|
844
|
+
connection_timeout?: number;
|
|
845
|
+
};
|
|
846
|
+
/**
|
|
847
|
+
* Additional driver-specific options
|
|
848
|
+
*/
|
|
849
|
+
options?: Record<string, any>;
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Query result with metadata (extends base QueryResult from data.ts)
|
|
853
|
+
*/
|
|
854
|
+
export interface DriverQueryResult<T = any> {
|
|
855
|
+
/**
|
|
856
|
+
* Result data
|
|
857
|
+
*/
|
|
858
|
+
data: T[];
|
|
859
|
+
/**
|
|
860
|
+
* Total count
|
|
861
|
+
*/
|
|
862
|
+
total?: number;
|
|
863
|
+
/**
|
|
864
|
+
* Current page number (1-indexed)
|
|
865
|
+
*/
|
|
866
|
+
page?: number;
|
|
867
|
+
/**
|
|
868
|
+
* Page size
|
|
869
|
+
*/
|
|
870
|
+
pageSize?: number;
|
|
871
|
+
/**
|
|
872
|
+
* Whether there are more records
|
|
873
|
+
*/
|
|
874
|
+
hasMore?: boolean;
|
|
875
|
+
/**
|
|
876
|
+
* Cursor for cursor-based pagination
|
|
877
|
+
*/
|
|
878
|
+
cursor?: string;
|
|
879
|
+
/**
|
|
880
|
+
* Execution metadata
|
|
881
|
+
*/
|
|
882
|
+
metadata?: {
|
|
883
|
+
/**
|
|
884
|
+
* Execution time in ms
|
|
885
|
+
*/
|
|
886
|
+
execution_time?: number;
|
|
887
|
+
/**
|
|
888
|
+
* Whether result was cached
|
|
889
|
+
*/
|
|
890
|
+
from_cache?: boolean;
|
|
891
|
+
/**
|
|
892
|
+
* Number of rows affected
|
|
893
|
+
*/
|
|
894
|
+
rows_affected?: number;
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Batch operation (Phase 3.6.2)
|
|
899
|
+
*/
|
|
900
|
+
export interface BatchOperation {
|
|
901
|
+
/**
|
|
902
|
+
* Operation type
|
|
903
|
+
*/
|
|
904
|
+
type: 'insert' | 'update' | 'delete';
|
|
905
|
+
/**
|
|
906
|
+
* Target table
|
|
907
|
+
*/
|
|
908
|
+
table: string;
|
|
909
|
+
/**
|
|
910
|
+
* Operation data
|
|
911
|
+
*/
|
|
912
|
+
data?: any;
|
|
913
|
+
/**
|
|
914
|
+
* Record ID (for update/delete)
|
|
915
|
+
*/
|
|
916
|
+
id?: any;
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Batch operation result
|
|
920
|
+
*/
|
|
921
|
+
export interface BatchResult<T = any> {
|
|
922
|
+
/**
|
|
923
|
+
* Successful operations
|
|
924
|
+
*/
|
|
925
|
+
success: T[];
|
|
926
|
+
/**
|
|
927
|
+
* Failed operations
|
|
928
|
+
*/
|
|
929
|
+
failed: Array<{
|
|
930
|
+
operation: BatchOperation;
|
|
931
|
+
error: Error;
|
|
932
|
+
}>;
|
|
933
|
+
/**
|
|
934
|
+
* Total operations
|
|
935
|
+
*/
|
|
936
|
+
total: number;
|
|
937
|
+
/**
|
|
938
|
+
* Success count
|
|
939
|
+
*/
|
|
940
|
+
success_count: number;
|
|
941
|
+
/**
|
|
942
|
+
* Failure count
|
|
943
|
+
*/
|
|
944
|
+
failure_count: number;
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Transaction context (Phase 3.6.1)
|
|
948
|
+
*/
|
|
949
|
+
export interface TransactionContext {
|
|
950
|
+
/**
|
|
951
|
+
* Execute query within transaction
|
|
952
|
+
*/
|
|
953
|
+
query<T = any>(sql: string, params?: any[]): Promise<DriverQueryResult<T>>;
|
|
954
|
+
/**
|
|
955
|
+
* Insert within transaction
|
|
956
|
+
*/
|
|
957
|
+
insert<T = any>(table: string, data: Partial<T>): Promise<T>;
|
|
958
|
+
/**
|
|
959
|
+
* Update within transaction
|
|
960
|
+
*/
|
|
961
|
+
update<T = any>(table: string, id: any, data: Partial<T>): Promise<T>;
|
|
962
|
+
/**
|
|
963
|
+
* Delete within transaction
|
|
964
|
+
*/
|
|
965
|
+
delete(table: string, id: any): Promise<boolean>;
|
|
966
|
+
/**
|
|
967
|
+
* Commit transaction
|
|
968
|
+
*/
|
|
969
|
+
commit(): Promise<void>;
|
|
970
|
+
/**
|
|
971
|
+
* Rollback transaction
|
|
972
|
+
*/
|
|
973
|
+
rollback(): Promise<void>;
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Cache manager (Phase 3.6.4)
|
|
977
|
+
*/
|
|
978
|
+
export interface CacheManager {
|
|
979
|
+
/**
|
|
980
|
+
* Get cached value
|
|
981
|
+
*/
|
|
982
|
+
get<T = any>(key: string): Promise<T | null>;
|
|
983
|
+
/**
|
|
984
|
+
* Set cached value
|
|
985
|
+
*/
|
|
986
|
+
set<T = any>(key: string, value: T, ttl?: number): Promise<void>;
|
|
987
|
+
/**
|
|
988
|
+
* Delete cached value
|
|
989
|
+
*/
|
|
990
|
+
delete(key: string): Promise<void>;
|
|
991
|
+
/**
|
|
992
|
+
* Clear all cache
|
|
993
|
+
*/
|
|
994
|
+
clear(): Promise<void>;
|
|
995
|
+
/**
|
|
996
|
+
* Check if key exists
|
|
997
|
+
*/
|
|
998
|
+
has(key: string): Promise<boolean>;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Connection pool (Phase 3.6.3)
|
|
1002
|
+
*/
|
|
1003
|
+
export interface ConnectionPool {
|
|
1004
|
+
/**
|
|
1005
|
+
* Get connection from pool
|
|
1006
|
+
*/
|
|
1007
|
+
acquire(): Promise<any>;
|
|
1008
|
+
/**
|
|
1009
|
+
* Release connection back to pool
|
|
1010
|
+
*/
|
|
1011
|
+
release(connection: any): Promise<void>;
|
|
1012
|
+
/**
|
|
1013
|
+
* Pool statistics
|
|
1014
|
+
*/
|
|
1015
|
+
stats(): {
|
|
1016
|
+
total: number;
|
|
1017
|
+
idle: number;
|
|
1018
|
+
active: number;
|
|
1019
|
+
waiting: number;
|
|
1020
|
+
};
|
|
1021
|
+
/**
|
|
1022
|
+
* Close all connections
|
|
1023
|
+
*/
|
|
1024
|
+
close(): Promise<void>;
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* =============================================================================
|
|
1028
|
+
* Phase 3.7: DatasourceSchema - Multi-Datasource Management
|
|
1029
|
+
* =============================================================================
|
|
1030
|
+
*/
|
|
1031
|
+
/**
|
|
1032
|
+
* Datasource Schema (Phase 3.7)
|
|
1033
|
+
*/
|
|
1034
|
+
export interface DatasourceSchema {
|
|
1035
|
+
/**
|
|
1036
|
+
* Datasource name
|
|
1037
|
+
*/
|
|
1038
|
+
name: string;
|
|
1039
|
+
/**
|
|
1040
|
+
* Datasource type
|
|
1041
|
+
*/
|
|
1042
|
+
type: DatasourceType;
|
|
1043
|
+
/**
|
|
1044
|
+
* Display label
|
|
1045
|
+
*/
|
|
1046
|
+
label?: string;
|
|
1047
|
+
/**
|
|
1048
|
+
* Connection configuration
|
|
1049
|
+
*/
|
|
1050
|
+
connection: ConnectionConfig;
|
|
1051
|
+
/**
|
|
1052
|
+
* Driver interface
|
|
1053
|
+
*/
|
|
1054
|
+
driver?: DriverInterface;
|
|
1055
|
+
/**
|
|
1056
|
+
* Whether datasource is default
|
|
1057
|
+
*/
|
|
1058
|
+
is_default?: boolean;
|
|
1059
|
+
/**
|
|
1060
|
+
* Health check configuration (Phase 3.7.4)
|
|
1061
|
+
*/
|
|
1062
|
+
health_check?: {
|
|
1063
|
+
/**
|
|
1064
|
+
* Enable health checks
|
|
1065
|
+
*/
|
|
1066
|
+
enabled?: boolean;
|
|
1067
|
+
/**
|
|
1068
|
+
* Check interval in seconds
|
|
1069
|
+
*/
|
|
1070
|
+
interval?: number;
|
|
1071
|
+
/**
|
|
1072
|
+
* Timeout in milliseconds
|
|
1073
|
+
*/
|
|
1074
|
+
timeout?: number;
|
|
1075
|
+
/**
|
|
1076
|
+
* Health check query
|
|
1077
|
+
*/
|
|
1078
|
+
query?: string;
|
|
1079
|
+
};
|
|
1080
|
+
/**
|
|
1081
|
+
* Monitoring configuration (Phase 3.7.5)
|
|
1082
|
+
*/
|
|
1083
|
+
monitoring?: {
|
|
1084
|
+
/**
|
|
1085
|
+
* Enable monitoring
|
|
1086
|
+
*/
|
|
1087
|
+
enabled?: boolean;
|
|
1088
|
+
/**
|
|
1089
|
+
* Metrics to collect
|
|
1090
|
+
*/
|
|
1091
|
+
metrics?: DatasourceMetric[];
|
|
1092
|
+
/**
|
|
1093
|
+
* Alert thresholds
|
|
1094
|
+
*/
|
|
1095
|
+
alerts?: DatasourceAlert[];
|
|
1096
|
+
};
|
|
1097
|
+
/**
|
|
1098
|
+
* Retry configuration
|
|
1099
|
+
*/
|
|
1100
|
+
retry?: {
|
|
1101
|
+
/**
|
|
1102
|
+
* Max retry attempts
|
|
1103
|
+
*/
|
|
1104
|
+
max_attempts?: number;
|
|
1105
|
+
/**
|
|
1106
|
+
* Retry delay in milliseconds
|
|
1107
|
+
*/
|
|
1108
|
+
delay?: number;
|
|
1109
|
+
/**
|
|
1110
|
+
* Exponential backoff
|
|
1111
|
+
*/
|
|
1112
|
+
backoff?: boolean;
|
|
1113
|
+
};
|
|
1114
|
+
/**
|
|
1115
|
+
* Metadata
|
|
1116
|
+
*/
|
|
1117
|
+
metadata?: Record<string, any>;
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Datasource types
|
|
1121
|
+
*/
|
|
1122
|
+
export type DatasourceType = 'postgres' | 'mysql' | 'mongodb' | 'sqlite' | 'mssql' | 'oracle' | 'rest' | 'graphql' | 'objectql' | 'custom';
|
|
1123
|
+
/**
|
|
1124
|
+
* Datasource metric types (Phase 3.7.5)
|
|
1125
|
+
*/
|
|
1126
|
+
export type DatasourceMetric = 'query_count' | 'query_duration' | 'error_rate' | 'connection_count' | 'cache_hit_rate' | 'throughput';
|
|
1127
|
+
/**
|
|
1128
|
+
* Datasource alert configuration (Phase 3.7.5)
|
|
1129
|
+
*/
|
|
1130
|
+
export interface DatasourceAlert {
|
|
1131
|
+
/**
|
|
1132
|
+
* Alert name
|
|
1133
|
+
*/
|
|
1134
|
+
name: string;
|
|
1135
|
+
/**
|
|
1136
|
+
* Metric to monitor
|
|
1137
|
+
*/
|
|
1138
|
+
metric: DatasourceMetric;
|
|
1139
|
+
/**
|
|
1140
|
+
* Threshold value
|
|
1141
|
+
*/
|
|
1142
|
+
threshold: number;
|
|
1143
|
+
/**
|
|
1144
|
+
* Comparison operator
|
|
1145
|
+
*/
|
|
1146
|
+
operator: '>' | '<' | '>=' | '<=' | '=';
|
|
1147
|
+
/**
|
|
1148
|
+
* Alert severity
|
|
1149
|
+
*/
|
|
1150
|
+
severity: 'info' | 'warning' | 'error' | 'critical';
|
|
1151
|
+
/**
|
|
1152
|
+
* Alert actions
|
|
1153
|
+
*/
|
|
1154
|
+
actions?: Array<'log' | 'email' | 'slack' | 'webhook'>;
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Multi-datasource manager (Phase 3.7.2)
|
|
1158
|
+
*/
|
|
1159
|
+
export interface DatasourceManager {
|
|
1160
|
+
/**
|
|
1161
|
+
* Register a datasource
|
|
1162
|
+
*/
|
|
1163
|
+
register(datasource: DatasourceSchema): void;
|
|
1164
|
+
/**
|
|
1165
|
+
* Unregister a datasource
|
|
1166
|
+
*/
|
|
1167
|
+
unregister(name: string): void;
|
|
1168
|
+
/**
|
|
1169
|
+
* Get datasource by name
|
|
1170
|
+
*/
|
|
1171
|
+
get(name: string): DatasourceSchema | undefined;
|
|
1172
|
+
/**
|
|
1173
|
+
* Get default datasource
|
|
1174
|
+
*/
|
|
1175
|
+
getDefault(): DatasourceSchema | undefined;
|
|
1176
|
+
/**
|
|
1177
|
+
* Switch active datasource (Phase 3.7.3)
|
|
1178
|
+
*/
|
|
1179
|
+
switch(name: string): void;
|
|
1180
|
+
/**
|
|
1181
|
+
* Get active datasource
|
|
1182
|
+
*/
|
|
1183
|
+
getActive(): DatasourceSchema | undefined;
|
|
1184
|
+
/**
|
|
1185
|
+
* List all datasources
|
|
1186
|
+
*/
|
|
1187
|
+
list(): DatasourceSchema[];
|
|
1188
|
+
/**
|
|
1189
|
+
* Check datasource health (Phase 3.7.4)
|
|
1190
|
+
*/
|
|
1191
|
+
checkHealth(name: string): Promise<HealthCheckResult>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Get datasource metrics (Phase 3.7.5)
|
|
1194
|
+
*/
|
|
1195
|
+
getMetrics(name: string): Promise<DatasourceMetrics>;
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Health check result (Phase 3.7.4)
|
|
1199
|
+
*/
|
|
1200
|
+
export interface HealthCheckResult {
|
|
1201
|
+
/**
|
|
1202
|
+
* Datasource name
|
|
1203
|
+
*/
|
|
1204
|
+
datasource: string;
|
|
1205
|
+
/**
|
|
1206
|
+
* Health status
|
|
1207
|
+
*/
|
|
1208
|
+
status: 'healthy' | 'degraded' | 'unhealthy';
|
|
1209
|
+
/**
|
|
1210
|
+
* Response time in ms
|
|
1211
|
+
*/
|
|
1212
|
+
response_time?: number;
|
|
1213
|
+
/**
|
|
1214
|
+
* Error message if unhealthy
|
|
1215
|
+
*/
|
|
1216
|
+
error?: string;
|
|
1217
|
+
/**
|
|
1218
|
+
* Timestamp
|
|
1219
|
+
*/
|
|
1220
|
+
timestamp: Date;
|
|
1221
|
+
/**
|
|
1222
|
+
* Additional details
|
|
1223
|
+
*/
|
|
1224
|
+
details?: Record<string, any>;
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Datasource metrics (Phase 3.7.5)
|
|
1228
|
+
*/
|
|
1229
|
+
export interface DatasourceMetrics {
|
|
1230
|
+
/**
|
|
1231
|
+
* Datasource name
|
|
1232
|
+
*/
|
|
1233
|
+
datasource: string;
|
|
1234
|
+
/**
|
|
1235
|
+
* Query metrics
|
|
1236
|
+
*/
|
|
1237
|
+
queries: {
|
|
1238
|
+
total: number;
|
|
1239
|
+
success: number;
|
|
1240
|
+
failed: number;
|
|
1241
|
+
avg_duration: number;
|
|
1242
|
+
};
|
|
1243
|
+
/**
|
|
1244
|
+
* Connection metrics
|
|
1245
|
+
*/
|
|
1246
|
+
connections: {
|
|
1247
|
+
active: number;
|
|
1248
|
+
idle: number;
|
|
1249
|
+
total: number;
|
|
1250
|
+
};
|
|
1251
|
+
/**
|
|
1252
|
+
* Cache metrics
|
|
1253
|
+
*/
|
|
1254
|
+
cache?: {
|
|
1255
|
+
hits: number;
|
|
1256
|
+
misses: number;
|
|
1257
|
+
hit_rate: number;
|
|
1258
|
+
};
|
|
1259
|
+
/**
|
|
1260
|
+
* Error rate
|
|
1261
|
+
*/
|
|
1262
|
+
error_rate: number;
|
|
1263
|
+
/**
|
|
1264
|
+
* Timestamp
|
|
1265
|
+
*/
|
|
1266
|
+
timestamp: Date;
|
|
1267
|
+
}
|
|
1268
|
+
//# sourceMappingURL=data-protocol.d.ts.map
|