@objectstack/spec 0.2.0 → 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/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 -41
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -49
- 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 +1097 -65
- package/dist/system/auth.zod.d.ts.map +1 -1
- package/dist/system/auth.zod.js +135 -1
- 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/ui/action.zod.d.ts +2 -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/theme.zod.d.ts +6 -6
- package/json-schema/Account.json +87 -0
- package/json-schema/AuthConfig.json +235 -0
- package/json-schema/ChunkingStrategy.json +133 -0
- package/json-schema/DatabaseMapping.json +48 -0
- package/json-schema/DocumentChunk.json +97 -0
- package/json-schema/DocumentLoaderConfig.json +69 -0
- package/json-schema/DocumentMetadata.json +61 -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/FieldSynonymConfig.json +39 -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/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/OIDCConfig.json +18 -3
- package/json-schema/Organization.json +52 -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/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/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/StandardAuthProvider.json +235 -0
- package/json-schema/Timeframe.json +68 -0
- package/json-schema/User.json +51 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nlq.zod.d.ts","sourceRoot":"","sources":["../../src/ai/nlq.zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB,mHAW5B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;EAMvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU1B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;EAMhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B,uBAAuB;;;IAIvB,sBAAsB;;;IAItB,2BAA2B;;;;;;;;;;;;;;IAO3B,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIlB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;IAC/B,qBAAqB;;IAGrB,uBAAuB;;;IAIvB,yBAAyB;;;;;;;;;;;;;;;;;;;;IAGzB,gCAAgC;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,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryTemplateSchema = exports.FieldSynonymConfigSchema = exports.NLQAnalyticsSchema = exports.NLQModelConfigSchema = exports.NLQTrainingExampleSchema = exports.NLQResponseSchema = exports.NLQRequestSchema = exports.NLQParseResultSchema = exports.QueryContextSchema = exports.NLQFieldMappingSchema = exports.TimeframeSchema = exports.EntitySchema = exports.QueryIntentSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Natural Language Query (NLQ) Protocol
|
|
7
|
+
*
|
|
8
|
+
* Transforms natural language queries into ObjectQL AST (Abstract Syntax Tree).
|
|
9
|
+
* Enables business users to query data using natural language instead of writing code.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Query Intent Type
|
|
13
|
+
*/
|
|
14
|
+
exports.QueryIntentSchema = zod_1.z.enum([
|
|
15
|
+
'select', // Retrieve data (e.g., "show me all accounts")
|
|
16
|
+
'aggregate', // Aggregation (e.g., "total revenue by region")
|
|
17
|
+
'filter', // Filter data (e.g., "accounts created last month")
|
|
18
|
+
'sort', // Sort data (e.g., "top 10 opportunities by value")
|
|
19
|
+
'compare', // Compare values (e.g., "compare this quarter vs last quarter")
|
|
20
|
+
'trend', // Analyze trends (e.g., "sales trend over time")
|
|
21
|
+
'insight', // Generate insights (e.g., "what's unusual about this data")
|
|
22
|
+
'create', // Create record (e.g., "create a new task")
|
|
23
|
+
'update', // Update record (e.g., "mark this as complete")
|
|
24
|
+
'delete', // Delete record (e.g., "remove this contact")
|
|
25
|
+
]);
|
|
26
|
+
/**
|
|
27
|
+
* Entity Recognition
|
|
28
|
+
*/
|
|
29
|
+
exports.EntitySchema = zod_1.z.object({
|
|
30
|
+
type: zod_1.z.enum(['object', 'field', 'value', 'operator', 'function', 'timeframe']),
|
|
31
|
+
text: zod_1.z.string().describe('Original text from query'),
|
|
32
|
+
value: zod_1.z.any().describe('Normalized value'),
|
|
33
|
+
confidence: zod_1.z.number().min(0).max(1).describe('Confidence score'),
|
|
34
|
+
span: zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()]).optional().describe('Character span in query'),
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Timeframe Detection
|
|
38
|
+
*/
|
|
39
|
+
exports.TimeframeSchema = zod_1.z.object({
|
|
40
|
+
type: zod_1.z.enum(['absolute', 'relative']),
|
|
41
|
+
start: zod_1.z.string().optional().describe('Start date (ISO format)'),
|
|
42
|
+
end: zod_1.z.string().optional().describe('End date (ISO format)'),
|
|
43
|
+
relative: zod_1.z.object({
|
|
44
|
+
unit: zod_1.z.enum(['hour', 'day', 'week', 'month', 'quarter', 'year']),
|
|
45
|
+
value: zod_1.z.number().int(),
|
|
46
|
+
direction: zod_1.z.enum(['past', 'future', 'current']).default('past'),
|
|
47
|
+
}).optional(),
|
|
48
|
+
text: zod_1.z.string().describe('Original timeframe text'),
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* NLQ Field Mapping
|
|
52
|
+
* Maps natural language field names to actual object fields
|
|
53
|
+
*/
|
|
54
|
+
exports.NLQFieldMappingSchema = zod_1.z.object({
|
|
55
|
+
naturalLanguage: zod_1.z.string().describe('NL field name (e.g., "customer name")'),
|
|
56
|
+
objectField: zod_1.z.string().describe('Actual field name (e.g., "account.name")'),
|
|
57
|
+
object: zod_1.z.string().describe('Object name'),
|
|
58
|
+
field: zod_1.z.string().describe('Field name'),
|
|
59
|
+
confidence: zod_1.z.number().min(0).max(1),
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Query Context
|
|
63
|
+
*/
|
|
64
|
+
exports.QueryContextSchema = zod_1.z.object({
|
|
65
|
+
/** User Information */
|
|
66
|
+
userId: zod_1.z.string().optional(),
|
|
67
|
+
userRole: zod_1.z.string().optional(),
|
|
68
|
+
/** Current Context */
|
|
69
|
+
currentObject: zod_1.z.string().optional().describe('Current object being viewed'),
|
|
70
|
+
currentRecordId: zod_1.z.string().optional().describe('Current record ID'),
|
|
71
|
+
/** Conversation History */
|
|
72
|
+
conversationHistory: zod_1.z.array(zod_1.z.object({
|
|
73
|
+
query: zod_1.z.string(),
|
|
74
|
+
timestamp: zod_1.z.string(),
|
|
75
|
+
intent: exports.QueryIntentSchema.optional(),
|
|
76
|
+
})).optional(),
|
|
77
|
+
/** Preferences */
|
|
78
|
+
defaultLimit: zod_1.z.number().int().default(100),
|
|
79
|
+
timezone: zod_1.z.string().default('UTC'),
|
|
80
|
+
locale: zod_1.z.string().default('en-US'),
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* NLQ Parse Result
|
|
84
|
+
*/
|
|
85
|
+
exports.NLQParseResultSchema = zod_1.z.object({
|
|
86
|
+
/** Original Query */
|
|
87
|
+
originalQuery: zod_1.z.string(),
|
|
88
|
+
/** Intent Detection */
|
|
89
|
+
intent: exports.QueryIntentSchema,
|
|
90
|
+
intentConfidence: zod_1.z.number().min(0).max(1),
|
|
91
|
+
/** Entity Recognition */
|
|
92
|
+
entities: zod_1.z.array(exports.EntitySchema),
|
|
93
|
+
/** Object & Field Resolution */
|
|
94
|
+
targetObject: zod_1.z.string().optional().describe('Primary object to query'),
|
|
95
|
+
fields: zod_1.z.array(exports.NLQFieldMappingSchema).optional(),
|
|
96
|
+
/** Temporal Information */
|
|
97
|
+
timeframe: exports.TimeframeSchema.optional(),
|
|
98
|
+
/** Query AST */
|
|
99
|
+
ast: zod_1.z.any().describe('Generated ObjectQL AST'),
|
|
100
|
+
/** Metadata */
|
|
101
|
+
confidence: zod_1.z.number().min(0).max(1).describe('Overall confidence'),
|
|
102
|
+
ambiguities: zod_1.z.array(zod_1.z.object({
|
|
103
|
+
type: zod_1.z.string(),
|
|
104
|
+
description: zod_1.z.string(),
|
|
105
|
+
suggestions: zod_1.z.array(zod_1.z.string()).optional(),
|
|
106
|
+
})).optional().describe('Detected ambiguities requiring clarification'),
|
|
107
|
+
/** Alternative Interpretations */
|
|
108
|
+
alternatives: zod_1.z.array(zod_1.z.object({
|
|
109
|
+
interpretation: zod_1.z.string(),
|
|
110
|
+
confidence: zod_1.z.number(),
|
|
111
|
+
ast: zod_1.z.any(),
|
|
112
|
+
})).optional(),
|
|
113
|
+
});
|
|
114
|
+
/**
|
|
115
|
+
* NLQ Request
|
|
116
|
+
*/
|
|
117
|
+
exports.NLQRequestSchema = zod_1.z.object({
|
|
118
|
+
/** Query */
|
|
119
|
+
query: zod_1.z.string().describe('Natural language query'),
|
|
120
|
+
/** Context */
|
|
121
|
+
context: exports.QueryContextSchema.optional(),
|
|
122
|
+
/** Options */
|
|
123
|
+
includeAlternatives: zod_1.z.boolean().default(false).describe('Include alternative interpretations'),
|
|
124
|
+
maxAlternatives: zod_1.z.number().int().default(3),
|
|
125
|
+
minConfidence: zod_1.z.number().min(0).max(1).default(0.5).describe('Minimum confidence threshold'),
|
|
126
|
+
/** Execution */
|
|
127
|
+
executeQuery: zod_1.z.boolean().default(false).describe('Execute query and return results'),
|
|
128
|
+
maxResults: zod_1.z.number().int().optional().describe('Maximum results to return'),
|
|
129
|
+
});
|
|
130
|
+
/**
|
|
131
|
+
* NLQ Response
|
|
132
|
+
*/
|
|
133
|
+
exports.NLQResponseSchema = zod_1.z.object({
|
|
134
|
+
/** Parse Result */
|
|
135
|
+
parseResult: exports.NLQParseResultSchema,
|
|
136
|
+
/** Query Results (if executeQuery = true) */
|
|
137
|
+
results: zod_1.z.array(zod_1.z.record(zod_1.z.any())).optional().describe('Query results'),
|
|
138
|
+
totalCount: zod_1.z.number().int().optional(),
|
|
139
|
+
/** Execution Metadata */
|
|
140
|
+
executionTime: zod_1.z.number().optional().describe('Execution time in milliseconds'),
|
|
141
|
+
needsClarification: zod_1.z.boolean().describe('Whether query needs clarification'),
|
|
142
|
+
/** Suggestions */
|
|
143
|
+
suggestions: zod_1.z.array(zod_1.z.string()).optional().describe('Query refinement suggestions'),
|
|
144
|
+
});
|
|
145
|
+
/**
|
|
146
|
+
* NLQ Training Example
|
|
147
|
+
*/
|
|
148
|
+
exports.NLQTrainingExampleSchema = zod_1.z.object({
|
|
149
|
+
/** Input */
|
|
150
|
+
query: zod_1.z.string().describe('Natural language query'),
|
|
151
|
+
context: exports.QueryContextSchema.optional(),
|
|
152
|
+
/** Expected Output */
|
|
153
|
+
expectedIntent: exports.QueryIntentSchema,
|
|
154
|
+
expectedObject: zod_1.z.string().optional(),
|
|
155
|
+
expectedAST: zod_1.z.any().describe('Expected ObjectQL AST'),
|
|
156
|
+
/** Metadata */
|
|
157
|
+
category: zod_1.z.string().optional().describe('Example category'),
|
|
158
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
159
|
+
notes: zod_1.z.string().optional(),
|
|
160
|
+
});
|
|
161
|
+
/**
|
|
162
|
+
* NLQ Model Configuration
|
|
163
|
+
*/
|
|
164
|
+
exports.NLQModelConfigSchema = zod_1.z.object({
|
|
165
|
+
/** Model */
|
|
166
|
+
modelId: zod_1.z.string().describe('Model from registry'),
|
|
167
|
+
/** Prompt Engineering */
|
|
168
|
+
systemPrompt: zod_1.z.string().optional().describe('System prompt override'),
|
|
169
|
+
includeSchema: zod_1.z.boolean().default(true).describe('Include object schema in prompt'),
|
|
170
|
+
includeExamples: zod_1.z.boolean().default(true).describe('Include examples in prompt'),
|
|
171
|
+
/** Intent Detection */
|
|
172
|
+
enableIntentDetection: zod_1.z.boolean().default(true),
|
|
173
|
+
intentThreshold: zod_1.z.number().min(0).max(1).default(0.7),
|
|
174
|
+
/** Entity Recognition */
|
|
175
|
+
enableEntityRecognition: zod_1.z.boolean().default(true),
|
|
176
|
+
entityRecognitionModel: zod_1.z.string().optional(),
|
|
177
|
+
/** Field Resolution */
|
|
178
|
+
enableFuzzyMatching: zod_1.z.boolean().default(true).describe('Fuzzy match field names'),
|
|
179
|
+
fuzzyMatchThreshold: zod_1.z.number().min(0).max(1).default(0.8),
|
|
180
|
+
/** Temporal Processing */
|
|
181
|
+
enableTimeframeDetection: zod_1.z.boolean().default(true),
|
|
182
|
+
defaultTimeframe: zod_1.z.string().optional().describe('Default timeframe if not specified'),
|
|
183
|
+
/** Performance */
|
|
184
|
+
enableCaching: zod_1.z.boolean().default(true),
|
|
185
|
+
cacheTTL: zod_1.z.number().int().default(3600).describe('Cache TTL in seconds'),
|
|
186
|
+
});
|
|
187
|
+
/**
|
|
188
|
+
* NLQ Analytics
|
|
189
|
+
*/
|
|
190
|
+
exports.NLQAnalyticsSchema = zod_1.z.object({
|
|
191
|
+
/** Query Metrics */
|
|
192
|
+
totalQueries: zod_1.z.number().int(),
|
|
193
|
+
successfulQueries: zod_1.z.number().int(),
|
|
194
|
+
failedQueries: zod_1.z.number().int(),
|
|
195
|
+
averageConfidence: zod_1.z.number().min(0).max(1),
|
|
196
|
+
/** Intent Distribution */
|
|
197
|
+
intentDistribution: zod_1.z.record(zod_1.z.number().int()).describe('Count by intent type'),
|
|
198
|
+
/** Common Patterns */
|
|
199
|
+
topQueries: zod_1.z.array(zod_1.z.object({
|
|
200
|
+
query: zod_1.z.string(),
|
|
201
|
+
count: zod_1.z.number().int(),
|
|
202
|
+
averageConfidence: zod_1.z.number(),
|
|
203
|
+
})),
|
|
204
|
+
/** Performance */
|
|
205
|
+
averageParseTime: zod_1.z.number().describe('Average parse time in milliseconds'),
|
|
206
|
+
averageExecutionTime: zod_1.z.number().optional(),
|
|
207
|
+
/** Issues */
|
|
208
|
+
lowConfidenceQueries: zod_1.z.array(zod_1.z.object({
|
|
209
|
+
query: zod_1.z.string(),
|
|
210
|
+
confidence: zod_1.z.number(),
|
|
211
|
+
timestamp: zod_1.z.string(),
|
|
212
|
+
})),
|
|
213
|
+
/** Timeframe */
|
|
214
|
+
startDate: zod_1.z.string().describe('ISO timestamp'),
|
|
215
|
+
endDate: zod_1.z.string().describe('ISO timestamp'),
|
|
216
|
+
});
|
|
217
|
+
/**
|
|
218
|
+
* Field Synonym Configuration
|
|
219
|
+
*/
|
|
220
|
+
exports.FieldSynonymConfigSchema = zod_1.z.object({
|
|
221
|
+
object: zod_1.z.string().describe('Object name'),
|
|
222
|
+
field: zod_1.z.string().describe('Field name'),
|
|
223
|
+
synonyms: zod_1.z.array(zod_1.z.string()).describe('Natural language synonyms'),
|
|
224
|
+
examples: zod_1.z.array(zod_1.z.string()).optional().describe('Example queries using synonyms'),
|
|
225
|
+
});
|
|
226
|
+
/**
|
|
227
|
+
* Query Template
|
|
228
|
+
*/
|
|
229
|
+
exports.QueryTemplateSchema = zod_1.z.object({
|
|
230
|
+
id: zod_1.z.string(),
|
|
231
|
+
name: zod_1.z.string().regex(/^[a-z_][a-z0-9_]*$/).describe('Template name (snake_case)'),
|
|
232
|
+
label: zod_1.z.string(),
|
|
233
|
+
/** Template */
|
|
234
|
+
pattern: zod_1.z.string().describe('Query pattern with placeholders'),
|
|
235
|
+
variables: zod_1.z.array(zod_1.z.object({
|
|
236
|
+
name: zod_1.z.string(),
|
|
237
|
+
type: zod_1.z.enum(['object', 'field', 'value', 'timeframe']),
|
|
238
|
+
required: zod_1.z.boolean().default(false),
|
|
239
|
+
})),
|
|
240
|
+
/** Generated AST */
|
|
241
|
+
astTemplate: zod_1.z.any().describe('AST template with variable placeholders'),
|
|
242
|
+
/** Metadata */
|
|
243
|
+
category: zod_1.z.string().optional(),
|
|
244
|
+
examples: zod_1.z.array(zod_1.z.string()).optional(),
|
|
245
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
246
|
+
});
|