@objectstack/spec 0.1.2 → 0.3.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 +127 -5
- package/dist/ai/index.d.ts +14 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +29 -0
- package/dist/ai/model-registry.zod.d.ts +1389 -0
- package/dist/ai/model-registry.zod.d.ts.map +1 -0
- package/dist/ai/model-registry.zod.js +164 -0
- package/dist/ai/nlq.zod.d.ts +1126 -0
- package/dist/ai/nlq.zod.d.ts.map +1 -0
- package/dist/ai/nlq.zod.js +246 -0
- package/dist/ai/rag-pipeline.zod.d.ts +1034 -0
- package/dist/ai/rag-pipeline.zod.d.ts.map +1 -0
- package/dist/ai/rag-pipeline.zod.js +244 -0
- package/dist/api/index.d.ts +9 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +24 -0
- package/dist/data/filter.zod.d.ts +295 -0
- package/dist/data/filter.zod.d.ts.map +1 -0
- package/dist/data/filter.zod.js +226 -0
- package/dist/data/index.d.ts +21 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +36 -0
- package/dist/data/query.zod.d.ts +386 -3
- package/dist/data/query.zod.d.ts.map +1 -1
- package/dist/data/query.zod.js +386 -3
- package/dist/data/validation.zod.d.ts +349 -0
- package/dist/data/validation.zod.d.ts.map +1 -1
- package/dist/data/validation.zod.js +395 -0
- package/dist/index.d.ts +36 -39
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -47
- package/dist/system/auth-protocol.d.ts +175 -0
- package/dist/system/auth-protocol.d.ts.map +1 -0
- package/dist/system/auth-protocol.js +60 -0
- package/dist/system/auth.zod.d.ts +3319 -0
- package/dist/system/auth.zod.d.ts.map +1 -0
- package/dist/system/auth.zod.js +499 -0
- package/dist/system/datasource.zod.d.ts +118 -38
- package/dist/system/datasource.zod.d.ts.map +1 -1
- package/dist/system/datasource.zod.js +25 -6
- package/dist/system/driver.zod.d.ts +106 -0
- package/dist/system/driver.zod.d.ts.map +1 -1
- package/dist/system/driver.zod.js +47 -0
- package/dist/system/identity.zod.d.ts +234 -180
- package/dist/system/identity.zod.d.ts.map +1 -1
- package/dist/system/identity.zod.js +168 -51
- package/dist/system/index.d.ts +28 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/system/index.js +43 -0
- package/dist/system/manifest.zod.d.ts +10 -10
- package/dist/system/organization.zod.d.ts +179 -0
- package/dist/system/organization.zod.d.ts.map +1 -0
- package/dist/system/organization.zod.js +129 -0
- package/dist/system/policy.zod.d.ts +10 -10
- package/dist/ui/action.zod.d.ts +2 -2
- package/dist/ui/dashboard.zod.d.ts +10 -10
- package/dist/ui/dashboard.zod.d.ts.map +1 -1
- package/dist/ui/dashboard.zod.js +3 -2
- package/dist/ui/index.d.ts +17 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +32 -0
- package/dist/ui/report.zod.d.ts +4 -32
- package/dist/ui/report.zod.d.ts.map +1 -1
- package/dist/ui/report.zod.js +3 -8
- package/dist/ui/theme.zod.d.ts +6 -6
- package/json-schema/Account.json +87 -0
- package/json-schema/AccountLinkingConfig.json +27 -0
- package/json-schema/AuthConfig.json +841 -0
- package/json-schema/AuthPluginConfig.json +28 -0
- package/json-schema/AuthStrategy.json +17 -0
- package/json-schema/AuthenticationConfig.json +601 -0
- package/json-schema/AuthenticationProvider.json +617 -0
- package/json-schema/CSRFConfig.json +31 -0
- package/json-schema/ChunkingStrategy.json +133 -0
- package/json-schema/ComparisonOperator.json +56 -0
- package/json-schema/Dashboard.json +20 -0
- package/json-schema/DashboardWidget.json +20 -0
- package/json-schema/DatabaseAdapter.json +38 -0
- package/json-schema/DatabaseMapping.json +48 -0
- package/json-schema/Datasource.json +25 -5
- package/json-schema/DatasourceCapabilities.json +25 -5
- package/json-schema/DocumentChunk.json +97 -0
- package/json-schema/DocumentLoaderConfig.json +69 -0
- package/json-schema/DocumentMetadata.json +61 -0
- package/json-schema/DriverCapabilities.json +30 -0
- package/json-schema/DriverDefinition.json +25 -5
- package/json-schema/DriverInterface.json +30 -0
- package/json-schema/EmailPasswordConfig.json +43 -0
- package/json-schema/EmbeddingModel.json +57 -0
- package/json-schema/EnterpriseAuthConfig.json +172 -0
- package/json-schema/Entity.json +55 -0
- package/json-schema/EqualityOperator.json +14 -0
- package/json-schema/FieldOperators.json +108 -0
- package/json-schema/FieldSynonymConfig.json +39 -0
- package/json-schema/FilterCondition.json +28 -0
- package/json-schema/Invitation.json +69 -0
- package/json-schema/InvitationStatus.json +15 -0
- package/json-schema/LDAPConfig.json +22 -5
- package/json-schema/MagicLinkConfig.json +21 -0
- package/json-schema/Member.json +46 -0
- package/json-schema/ModelCapability.json +47 -0
- package/json-schema/ModelConfig.json +181 -0
- package/json-schema/ModelLimits.json +45 -0
- package/json-schema/ModelPricing.json +28 -0
- package/json-schema/ModelProvider.json +19 -0
- package/json-schema/ModelRegistry.json +427 -0
- package/json-schema/ModelRegistryEntry.json +239 -0
- package/json-schema/ModelSelectionCriteria.json +50 -0
- package/json-schema/NLQAnalytics.json +106 -0
- package/json-schema/NLQFieldMapping.json +40 -0
- package/json-schema/NLQModelConfig.json +78 -0
- package/json-schema/NLQParseResult.json +252 -0
- package/json-schema/NLQRequest.json +110 -0
- package/json-schema/NLQResponse.json +288 -0
- package/json-schema/NLQTrainingExample.json +120 -0
- package/json-schema/NormalizedFilter.json +348 -0
- package/json-schema/OAuthProvider.json +66 -0
- package/json-schema/OIDCConfig.json +18 -3
- package/json-schema/Organization.json +52 -0
- package/json-schema/PasskeyConfig.json +54 -0
- package/json-schema/PromptTemplate.json +163 -0
- package/json-schema/PromptVariable.json +56 -0
- package/json-schema/QueryContext.json +72 -0
- package/json-schema/QueryFilter.json +34 -0
- package/json-schema/QueryIntent.json +21 -0
- package/json-schema/QueryTemplate.json +81 -0
- package/json-schema/RAGPipelineConfig.json +552 -0
- package/json-schema/RAGPipelineStatus.json +66 -0
- package/json-schema/RAGQueryRequest.json +64 -0
- package/json-schema/RAGQueryResponse.json +108 -0
- package/json-schema/RangeOperator.json +41 -0
- package/json-schema/RateLimitConfig.json +36 -0
- package/json-schema/Report.json +20 -26
- package/json-schema/RerankingConfig.json +34 -0
- package/json-schema/RetrievalStrategy.json +121 -0
- package/json-schema/SAMLConfig.json +17 -3
- package/json-schema/Session.json +63 -0
- package/json-schema/SessionConfig.json +56 -0
- package/json-schema/SetOperator.json +18 -0
- package/json-schema/SpecialOperator.json +18 -0
- package/json-schema/StandardAuthProvider.json +857 -0
- package/json-schema/StringOperator.json +21 -0
- package/json-schema/Timeframe.json +68 -0
- package/json-schema/TwoFactorConfig.json +40 -0
- package/json-schema/User.json +51 -0
- package/json-schema/UserFieldMapping.json +47 -0
- package/json-schema/VectorStoreConfig.json +82 -0
- package/json-schema/VectorStoreProvider.json +21 -0
- package/json-schema/VerificationToken.json +36 -0
- package/package.json +27 -1
- package/json-schema/AuthProtocol.json +0 -17
- package/json-schema/AuthProvider.json +0 -171
package/dist/data/query.zod.js
CHANGED
|
@@ -42,7 +42,43 @@ exports.SortNodeSchema = zod_1.z.object({
|
|
|
42
42
|
});
|
|
43
43
|
/**
|
|
44
44
|
* Aggregation Function Enum
|
|
45
|
-
* Standard aggregation functions.
|
|
45
|
+
* Standard aggregation functions for data analysis.
|
|
46
|
+
*
|
|
47
|
+
* Supported Functions:
|
|
48
|
+
* - **count**: Count rows (SQL: COUNT(*) or COUNT(field))
|
|
49
|
+
* - **sum**: Sum numeric values (SQL: SUM(field))
|
|
50
|
+
* - **avg**: Average numeric values (SQL: AVG(field))
|
|
51
|
+
* - **min**: Minimum value (SQL: MIN(field))
|
|
52
|
+
* - **max**: Maximum value (SQL: MAX(field))
|
|
53
|
+
* - **count_distinct**: Count unique values (SQL: COUNT(DISTINCT field))
|
|
54
|
+
* - **array_agg**: Aggregate values into array (SQL: ARRAY_AGG(field))
|
|
55
|
+
* - **string_agg**: Concatenate values (SQL: STRING_AGG(field, delimiter))
|
|
56
|
+
*
|
|
57
|
+
* Performance Considerations:
|
|
58
|
+
* - COUNT(*) is typically faster than COUNT(field) as it doesn't check for nulls
|
|
59
|
+
* - COUNT DISTINCT may require additional memory for tracking unique values
|
|
60
|
+
* - Window aggregates (with OVER clause) can be more efficient than subqueries
|
|
61
|
+
* - Large GROUP BY operations benefit from proper indexing on grouped fields
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* // SQL: SELECT region, SUM(amount) FROM sales GROUP BY region
|
|
65
|
+
* {
|
|
66
|
+
* object: 'sales',
|
|
67
|
+
* fields: ['region'],
|
|
68
|
+
* aggregations: [
|
|
69
|
+
* { function: 'sum', field: 'amount', alias: 'total_sales' }
|
|
70
|
+
* ],
|
|
71
|
+
* groupBy: ['region']
|
|
72
|
+
* }
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* // Salesforce SOQL: SELECT COUNT(Id) FROM Account
|
|
76
|
+
* {
|
|
77
|
+
* object: 'account',
|
|
78
|
+
* aggregations: [
|
|
79
|
+
* { function: 'count', alias: 'total_accounts' }
|
|
80
|
+
* ]
|
|
81
|
+
* }
|
|
46
82
|
*/
|
|
47
83
|
exports.AggregationFunction = zod_1.z.enum([
|
|
48
84
|
'count', 'sum', 'avg', 'min', 'max',
|
|
@@ -50,7 +86,33 @@ exports.AggregationFunction = zod_1.z.enum([
|
|
|
50
86
|
]);
|
|
51
87
|
/**
|
|
52
88
|
* Aggregation Node
|
|
53
|
-
* Represents aggregated field with function.
|
|
89
|
+
* Represents an aggregated field with function.
|
|
90
|
+
*
|
|
91
|
+
* Aggregations summarize data across groups of rows (GROUP BY).
|
|
92
|
+
* Used with `groupBy` to create analytical queries.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* // SQL: SELECT customer_id, COUNT(*), SUM(amount) FROM orders GROUP BY customer_id
|
|
96
|
+
* {
|
|
97
|
+
* object: 'order',
|
|
98
|
+
* fields: ['customer_id'],
|
|
99
|
+
* aggregations: [
|
|
100
|
+
* { function: 'count', alias: 'order_count' },
|
|
101
|
+
* { function: 'sum', field: 'amount', alias: 'total_amount' }
|
|
102
|
+
* ],
|
|
103
|
+
* groupBy: ['customer_id']
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* // Salesforce SOQL: SELECT LeadSource, COUNT(Id) FROM Lead GROUP BY LeadSource
|
|
108
|
+
* {
|
|
109
|
+
* object: 'lead',
|
|
110
|
+
* fields: ['lead_source'],
|
|
111
|
+
* aggregations: [
|
|
112
|
+
* { function: 'count', alias: 'lead_count' }
|
|
113
|
+
* ],
|
|
114
|
+
* groupBy: ['lead_source']
|
|
115
|
+
* }
|
|
54
116
|
*/
|
|
55
117
|
exports.AggregationNodeSchema = zod_1.z.object({
|
|
56
118
|
function: exports.AggregationFunction.describe('Aggregation function'),
|
|
@@ -60,11 +122,118 @@ exports.AggregationNodeSchema = zod_1.z.object({
|
|
|
60
122
|
});
|
|
61
123
|
/**
|
|
62
124
|
* Join Type Enum
|
|
125
|
+
* Standard SQL join types for combining tables.
|
|
126
|
+
*
|
|
127
|
+
* Join Types:
|
|
128
|
+
* - **inner**: Returns only matching rows from both tables (SQL: INNER JOIN)
|
|
129
|
+
* - **left**: Returns all rows from left table, matching rows from right (SQL: LEFT JOIN)
|
|
130
|
+
* - **right**: Returns all rows from right table, matching rows from left (SQL: RIGHT JOIN)
|
|
131
|
+
* - **full**: Returns all rows from both tables (SQL: FULL OUTER JOIN)
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* // SQL: SELECT * FROM orders INNER JOIN customers ON orders.customer_id = customers.id
|
|
135
|
+
* {
|
|
136
|
+
* object: 'order',
|
|
137
|
+
* joins: [
|
|
138
|
+
* {
|
|
139
|
+
* type: 'inner',
|
|
140
|
+
* object: 'customer',
|
|
141
|
+
* on: ['order.customer_id', '=', 'customer.id']
|
|
142
|
+
* }
|
|
143
|
+
* ]
|
|
144
|
+
* }
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* // Salesforce SOQL-style: Find all customers and their orders (if any)
|
|
148
|
+
* {
|
|
149
|
+
* object: 'customer',
|
|
150
|
+
* joins: [
|
|
151
|
+
* {
|
|
152
|
+
* type: 'left',
|
|
153
|
+
* object: 'order',
|
|
154
|
+
* on: ['customer.id', '=', 'order.customer_id']
|
|
155
|
+
* }
|
|
156
|
+
* ]
|
|
157
|
+
* }
|
|
63
158
|
*/
|
|
64
159
|
exports.JoinType = zod_1.z.enum(['inner', 'left', 'right', 'full']);
|
|
65
160
|
/**
|
|
66
161
|
* Join Node
|
|
67
|
-
* Represents table joins.
|
|
162
|
+
* Represents table joins for combining data from multiple objects.
|
|
163
|
+
*
|
|
164
|
+
* Joins connect related data across multiple tables using ON conditions.
|
|
165
|
+
* Supports both direct object joins and subquery joins.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* // SQL: SELECT o.*, c.name FROM orders o INNER JOIN customers c ON o.customer_id = c.id
|
|
169
|
+
* {
|
|
170
|
+
* object: 'order',
|
|
171
|
+
* fields: ['id', 'amount'],
|
|
172
|
+
* joins: [
|
|
173
|
+
* {
|
|
174
|
+
* type: 'inner',
|
|
175
|
+
* object: 'customer',
|
|
176
|
+
* alias: 'c',
|
|
177
|
+
* on: ['order.customer_id', '=', 'c.id']
|
|
178
|
+
* }
|
|
179
|
+
* ]
|
|
180
|
+
* }
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* // SQL: Multi-table join
|
|
184
|
+
* // SELECT * FROM orders o
|
|
185
|
+
* // INNER JOIN customers c ON o.customer_id = c.id
|
|
186
|
+
* // LEFT JOIN shipments s ON o.id = s.order_id
|
|
187
|
+
* {
|
|
188
|
+
* object: 'order',
|
|
189
|
+
* joins: [
|
|
190
|
+
* {
|
|
191
|
+
* type: 'inner',
|
|
192
|
+
* object: 'customer',
|
|
193
|
+
* alias: 'c',
|
|
194
|
+
* on: ['order.customer_id', '=', 'c.id']
|
|
195
|
+
* },
|
|
196
|
+
* {
|
|
197
|
+
* type: 'left',
|
|
198
|
+
* object: 'shipment',
|
|
199
|
+
* alias: 's',
|
|
200
|
+
* on: ['order.id', '=', 's.order_id']
|
|
201
|
+
* }
|
|
202
|
+
* ]
|
|
203
|
+
* }
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* // Salesforce SOQL: SELECT Name, (SELECT LastName FROM Contacts) FROM Account
|
|
207
|
+
* {
|
|
208
|
+
* object: 'account',
|
|
209
|
+
* fields: ['name'],
|
|
210
|
+
* joins: [
|
|
211
|
+
* {
|
|
212
|
+
* type: 'left',
|
|
213
|
+
* object: 'contact',
|
|
214
|
+
* on: ['account.id', '=', 'contact.account_id']
|
|
215
|
+
* }
|
|
216
|
+
* ]
|
|
217
|
+
* }
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* // Subquery Join: Join with a filtered/aggregated dataset
|
|
221
|
+
* {
|
|
222
|
+
* object: 'customer',
|
|
223
|
+
* joins: [
|
|
224
|
+
* {
|
|
225
|
+
* type: 'left',
|
|
226
|
+
* object: 'order',
|
|
227
|
+
* alias: 'high_value_orders',
|
|
228
|
+
* on: ['customer.id', '=', 'high_value_orders.customer_id'],
|
|
229
|
+
* subquery: {
|
|
230
|
+
* object: 'order',
|
|
231
|
+
* fields: ['customer_id', 'total'],
|
|
232
|
+
* filters: ['total', '>', 1000]
|
|
233
|
+
* }
|
|
234
|
+
* }
|
|
235
|
+
* ]
|
|
236
|
+
* }
|
|
68
237
|
*/
|
|
69
238
|
exports.JoinNodeSchema = zod_1.z.lazy(() => zod_1.z.object({
|
|
70
239
|
type: exports.JoinType.describe('Join type'),
|
|
@@ -75,6 +244,58 @@ exports.JoinNodeSchema = zod_1.z.lazy(() => zod_1.z.object({
|
|
|
75
244
|
}));
|
|
76
245
|
/**
|
|
77
246
|
* Window Function Enum
|
|
247
|
+
* Advanced analytical functions for row-based calculations.
|
|
248
|
+
*
|
|
249
|
+
* Window Functions:
|
|
250
|
+
* - **row_number**: Sequential number within partition (SQL: ROW_NUMBER() OVER (...))
|
|
251
|
+
* - **rank**: Rank with gaps for ties (SQL: RANK() OVER (...))
|
|
252
|
+
* - **dense_rank**: Rank without gaps (SQL: DENSE_RANK() OVER (...))
|
|
253
|
+
* - **percent_rank**: Relative rank as percentage (SQL: PERCENT_RANK() OVER (...))
|
|
254
|
+
* - **lag**: Access previous row value (SQL: LAG(field) OVER (...))
|
|
255
|
+
* - **lead**: Access next row value (SQL: LEAD(field) OVER (...))
|
|
256
|
+
* - **first_value**: First value in window (SQL: FIRST_VALUE(field) OVER (...))
|
|
257
|
+
* - **last_value**: Last value in window (SQL: LAST_VALUE(field) OVER (...))
|
|
258
|
+
* - **sum/avg/count/min/max**: Aggregates over window (SQL: SUM(field) OVER (...))
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* // SQL: SELECT *, ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY amount DESC) as rank
|
|
262
|
+
* // FROM orders
|
|
263
|
+
* {
|
|
264
|
+
* object: 'order',
|
|
265
|
+
* fields: ['id', 'customer_id', 'amount'],
|
|
266
|
+
* windowFunctions: [
|
|
267
|
+
* {
|
|
268
|
+
* function: 'row_number',
|
|
269
|
+
* alias: 'rank',
|
|
270
|
+
* over: {
|
|
271
|
+
* partitionBy: ['customer_id'],
|
|
272
|
+
* orderBy: [{ field: 'amount', order: 'desc' }]
|
|
273
|
+
* }
|
|
274
|
+
* }
|
|
275
|
+
* ]
|
|
276
|
+
* }
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* // SQL: Running total with SUM() OVER (...)
|
|
280
|
+
* {
|
|
281
|
+
* object: 'transaction',
|
|
282
|
+
* fields: ['date', 'amount'],
|
|
283
|
+
* windowFunctions: [
|
|
284
|
+
* {
|
|
285
|
+
* function: 'sum',
|
|
286
|
+
* field: 'amount',
|
|
287
|
+
* alias: 'running_total',
|
|
288
|
+
* over: {
|
|
289
|
+
* orderBy: [{ field: 'date', order: 'asc' }],
|
|
290
|
+
* frame: {
|
|
291
|
+
* type: 'rows',
|
|
292
|
+
* start: 'UNBOUNDED PRECEDING',
|
|
293
|
+
* end: 'CURRENT ROW'
|
|
294
|
+
* }
|
|
295
|
+
* }
|
|
296
|
+
* }
|
|
297
|
+
* ]
|
|
298
|
+
* }
|
|
78
299
|
*/
|
|
79
300
|
exports.WindowFunction = zod_1.z.enum([
|
|
80
301
|
'row_number', 'rank', 'dense_rank', 'percent_rank',
|
|
@@ -84,6 +305,29 @@ exports.WindowFunction = zod_1.z.enum([
|
|
|
84
305
|
/**
|
|
85
306
|
* Window Specification
|
|
86
307
|
* Defines PARTITION BY and ORDER BY for window functions.
|
|
308
|
+
*
|
|
309
|
+
* Window specifications control how window functions compute values:
|
|
310
|
+
* - **partitionBy**: Divide rows into groups (like GROUP BY but without collapsing rows)
|
|
311
|
+
* - **orderBy**: Define order for ranking and offset functions
|
|
312
|
+
* - **frame**: Specify which rows to include in aggregate calculations
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* // Partition by department, order by salary
|
|
316
|
+
* {
|
|
317
|
+
* partitionBy: ['department'],
|
|
318
|
+
* orderBy: [{ field: 'salary', order: 'desc' }]
|
|
319
|
+
* }
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* // Moving average with frame specification
|
|
323
|
+
* {
|
|
324
|
+
* orderBy: [{ field: 'date', order: 'asc' }],
|
|
325
|
+
* frame: {
|
|
326
|
+
* type: 'rows',
|
|
327
|
+
* start: '6 PRECEDING',
|
|
328
|
+
* end: 'CURRENT ROW'
|
|
329
|
+
* }
|
|
330
|
+
* }
|
|
87
331
|
*/
|
|
88
332
|
exports.WindowSpecSchema = zod_1.z.object({
|
|
89
333
|
partitionBy: zod_1.z.array(zod_1.z.string()).optional().describe('PARTITION BY fields'),
|
|
@@ -97,6 +341,45 @@ exports.WindowSpecSchema = zod_1.z.object({
|
|
|
97
341
|
/**
|
|
98
342
|
* Window Function Node
|
|
99
343
|
* Represents window function with OVER clause.
|
|
344
|
+
*
|
|
345
|
+
* Window functions perform calculations across a set of rows related to the current row,
|
|
346
|
+
* without collapsing the result set (unlike GROUP BY aggregations).
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* // SQL: Top 3 products per category
|
|
350
|
+
* // SELECT *, ROW_NUMBER() OVER (PARTITION BY category ORDER BY sales DESC) as rank
|
|
351
|
+
* // FROM products
|
|
352
|
+
* {
|
|
353
|
+
* object: 'product',
|
|
354
|
+
* fields: ['name', 'category', 'sales'],
|
|
355
|
+
* windowFunctions: [
|
|
356
|
+
* {
|
|
357
|
+
* function: 'row_number',
|
|
358
|
+
* alias: 'category_rank',
|
|
359
|
+
* over: {
|
|
360
|
+
* partitionBy: ['category'],
|
|
361
|
+
* orderBy: [{ field: 'sales', order: 'desc' }]
|
|
362
|
+
* }
|
|
363
|
+
* }
|
|
364
|
+
* ]
|
|
365
|
+
* }
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* // SQL: Year-over-year comparison with LAG
|
|
369
|
+
* {
|
|
370
|
+
* object: 'monthly_sales',
|
|
371
|
+
* fields: ['month', 'revenue'],
|
|
372
|
+
* windowFunctions: [
|
|
373
|
+
* {
|
|
374
|
+
* function: 'lag',
|
|
375
|
+
* field: 'revenue',
|
|
376
|
+
* alias: 'prev_year_revenue',
|
|
377
|
+
* over: {
|
|
378
|
+
* orderBy: [{ field: 'month', order: 'asc' }]
|
|
379
|
+
* }
|
|
380
|
+
* }
|
|
381
|
+
* ]
|
|
382
|
+
* }
|
|
100
383
|
*/
|
|
101
384
|
exports.WindowFunctionNodeSchema = zod_1.z.object({
|
|
102
385
|
function: exports.WindowFunction.describe('Window function name'),
|
|
@@ -119,6 +402,106 @@ exports.FieldNodeSchema = zod_1.z.lazy(() => zod_1.z.union([
|
|
|
119
402
|
/**
|
|
120
403
|
* Query AST Schema
|
|
121
404
|
* The universal data retrieval contract defined in `ast-structure.mdx`.
|
|
405
|
+
*
|
|
406
|
+
* This schema represents ObjectQL - a universal query language that abstracts
|
|
407
|
+
* SQL, NoSQL, and SaaS APIs into a single unified interface.
|
|
408
|
+
*
|
|
409
|
+
* Key Features:
|
|
410
|
+
* - **Filtering**: WHERE clauses with nested logic
|
|
411
|
+
* - **Aggregations**: GROUP BY with COUNT, SUM, AVG, MIN, MAX
|
|
412
|
+
* - **Joins**: INNER, LEFT, RIGHT, FULL OUTER joins
|
|
413
|
+
* - **Window Functions**: ROW_NUMBER, RANK, LAG, LEAD, running totals
|
|
414
|
+
* - **Subqueries**: Nested queries in joins and filters
|
|
415
|
+
* - **Sorting & Pagination**: ORDER BY, LIMIT, OFFSET
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* // Simple query: SELECT name, email FROM account WHERE status = 'active'
|
|
419
|
+
* {
|
|
420
|
+
* object: 'account',
|
|
421
|
+
* fields: ['name', 'email'],
|
|
422
|
+
* filters: ['status', '=', 'active']
|
|
423
|
+
* }
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* // Aggregation: SELECT region, SUM(amount) as total FROM sales GROUP BY region HAVING total > 10000
|
|
427
|
+
* {
|
|
428
|
+
* object: 'sales',
|
|
429
|
+
* fields: ['region'],
|
|
430
|
+
* aggregations: [
|
|
431
|
+
* { function: 'sum', field: 'amount', alias: 'total' }
|
|
432
|
+
* ],
|
|
433
|
+
* groupBy: ['region'],
|
|
434
|
+
* having: ['total', '>', 10000]
|
|
435
|
+
* }
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* // Join: SELECT o.*, c.name FROM orders o INNER JOIN customers c ON o.customer_id = c.id
|
|
439
|
+
* {
|
|
440
|
+
* object: 'order',
|
|
441
|
+
* fields: ['id', 'amount'],
|
|
442
|
+
* joins: [
|
|
443
|
+
* {
|
|
444
|
+
* type: 'inner',
|
|
445
|
+
* object: 'customer',
|
|
446
|
+
* alias: 'c',
|
|
447
|
+
* on: ['order.customer_id', '=', 'c.id']
|
|
448
|
+
* }
|
|
449
|
+
* ]
|
|
450
|
+
* }
|
|
451
|
+
*
|
|
452
|
+
* @example
|
|
453
|
+
* // Window Function: Top 5 orders per customer
|
|
454
|
+
* {
|
|
455
|
+
* object: 'order',
|
|
456
|
+
* fields: ['customer_id', 'amount', 'created_at'],
|
|
457
|
+
* windowFunctions: [
|
|
458
|
+
* {
|
|
459
|
+
* function: 'row_number',
|
|
460
|
+
* alias: 'customer_order_rank',
|
|
461
|
+
* over: {
|
|
462
|
+
* partitionBy: ['customer_id'],
|
|
463
|
+
* orderBy: [{ field: 'amount', order: 'desc' }]
|
|
464
|
+
* }
|
|
465
|
+
* }
|
|
466
|
+
* ]
|
|
467
|
+
* }
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* // Complex: Customer lifetime value with rankings
|
|
471
|
+
* {
|
|
472
|
+
* object: 'customer',
|
|
473
|
+
* fields: ['id', 'name'],
|
|
474
|
+
* joins: [
|
|
475
|
+
* {
|
|
476
|
+
* type: 'left',
|
|
477
|
+
* object: 'order',
|
|
478
|
+
* alias: 'o',
|
|
479
|
+
* on: ['customer.id', '=', 'o.customer_id']
|
|
480
|
+
* }
|
|
481
|
+
* ],
|
|
482
|
+
* aggregations: [
|
|
483
|
+
* { function: 'count', field: 'o.id', alias: 'order_count' },
|
|
484
|
+
* { function: 'sum', field: 'o.amount', alias: 'lifetime_value' }
|
|
485
|
+
* ],
|
|
486
|
+
* groupBy: ['customer.id', 'customer.name'],
|
|
487
|
+
* having: ['order_count', '>', 0],
|
|
488
|
+
* sort: [{ field: 'lifetime_value', order: 'desc' }],
|
|
489
|
+
* top: 100
|
|
490
|
+
* }
|
|
491
|
+
*
|
|
492
|
+
* @example
|
|
493
|
+
* // Salesforce SOQL: SELECT Name, (SELECT LastName FROM Contacts) FROM Account
|
|
494
|
+
* {
|
|
495
|
+
* object: 'account',
|
|
496
|
+
* fields: ['name'],
|
|
497
|
+
* joins: [
|
|
498
|
+
* {
|
|
499
|
+
* type: 'left',
|
|
500
|
+
* object: 'contact',
|
|
501
|
+
* on: ['account.id', '=', 'contact.account_id']
|
|
502
|
+
* }
|
|
503
|
+
* ]
|
|
504
|
+
* }
|
|
122
505
|
*/
|
|
123
506
|
exports.QuerySchema = zod_1.z.object({
|
|
124
507
|
/** Target Entity */
|