@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.
Files changed (152) hide show
  1. package/README.md +127 -5
  2. package/dist/ai/index.d.ts +14 -0
  3. package/dist/ai/index.d.ts.map +1 -0
  4. package/dist/ai/index.js +29 -0
  5. package/dist/ai/model-registry.zod.d.ts +1389 -0
  6. package/dist/ai/model-registry.zod.d.ts.map +1 -0
  7. package/dist/ai/model-registry.zod.js +164 -0
  8. package/dist/ai/nlq.zod.d.ts +1126 -0
  9. package/dist/ai/nlq.zod.d.ts.map +1 -0
  10. package/dist/ai/nlq.zod.js +246 -0
  11. package/dist/ai/rag-pipeline.zod.d.ts +1034 -0
  12. package/dist/ai/rag-pipeline.zod.d.ts.map +1 -0
  13. package/dist/ai/rag-pipeline.zod.js +244 -0
  14. package/dist/api/index.d.ts +9 -0
  15. package/dist/api/index.d.ts.map +1 -0
  16. package/dist/api/index.js +24 -0
  17. package/dist/data/filter.zod.d.ts +295 -0
  18. package/dist/data/filter.zod.d.ts.map +1 -0
  19. package/dist/data/filter.zod.js +226 -0
  20. package/dist/data/index.d.ts +21 -0
  21. package/dist/data/index.d.ts.map +1 -0
  22. package/dist/data/index.js +36 -0
  23. package/dist/data/query.zod.d.ts +386 -3
  24. package/dist/data/query.zod.d.ts.map +1 -1
  25. package/dist/data/query.zod.js +386 -3
  26. package/dist/data/validation.zod.d.ts +349 -0
  27. package/dist/data/validation.zod.d.ts.map +1 -1
  28. package/dist/data/validation.zod.js +395 -0
  29. package/dist/index.d.ts +36 -39
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +64 -47
  32. package/dist/system/auth-protocol.d.ts +175 -0
  33. package/dist/system/auth-protocol.d.ts.map +1 -0
  34. package/dist/system/auth-protocol.js +60 -0
  35. package/dist/system/auth.zod.d.ts +3319 -0
  36. package/dist/system/auth.zod.d.ts.map +1 -0
  37. package/dist/system/auth.zod.js +499 -0
  38. package/dist/system/datasource.zod.d.ts +118 -38
  39. package/dist/system/datasource.zod.d.ts.map +1 -1
  40. package/dist/system/datasource.zod.js +25 -6
  41. package/dist/system/driver.zod.d.ts +106 -0
  42. package/dist/system/driver.zod.d.ts.map +1 -1
  43. package/dist/system/driver.zod.js +47 -0
  44. package/dist/system/identity.zod.d.ts +234 -180
  45. package/dist/system/identity.zod.d.ts.map +1 -1
  46. package/dist/system/identity.zod.js +168 -51
  47. package/dist/system/index.d.ts +28 -0
  48. package/dist/system/index.d.ts.map +1 -0
  49. package/dist/system/index.js +43 -0
  50. package/dist/system/manifest.zod.d.ts +10 -10
  51. package/dist/system/organization.zod.d.ts +179 -0
  52. package/dist/system/organization.zod.d.ts.map +1 -0
  53. package/dist/system/organization.zod.js +129 -0
  54. package/dist/system/policy.zod.d.ts +10 -10
  55. package/dist/ui/action.zod.d.ts +2 -2
  56. package/dist/ui/dashboard.zod.d.ts +10 -10
  57. package/dist/ui/dashboard.zod.d.ts.map +1 -1
  58. package/dist/ui/dashboard.zod.js +3 -2
  59. package/dist/ui/index.d.ts +17 -0
  60. package/dist/ui/index.d.ts.map +1 -0
  61. package/dist/ui/index.js +32 -0
  62. package/dist/ui/report.zod.d.ts +4 -32
  63. package/dist/ui/report.zod.d.ts.map +1 -1
  64. package/dist/ui/report.zod.js +3 -8
  65. package/dist/ui/theme.zod.d.ts +6 -6
  66. package/json-schema/Account.json +87 -0
  67. package/json-schema/AccountLinkingConfig.json +27 -0
  68. package/json-schema/AuthConfig.json +841 -0
  69. package/json-schema/AuthPluginConfig.json +28 -0
  70. package/json-schema/AuthStrategy.json +17 -0
  71. package/json-schema/AuthenticationConfig.json +601 -0
  72. package/json-schema/AuthenticationProvider.json +617 -0
  73. package/json-schema/CSRFConfig.json +31 -0
  74. package/json-schema/ChunkingStrategy.json +133 -0
  75. package/json-schema/ComparisonOperator.json +56 -0
  76. package/json-schema/Dashboard.json +20 -0
  77. package/json-schema/DashboardWidget.json +20 -0
  78. package/json-schema/DatabaseAdapter.json +38 -0
  79. package/json-schema/DatabaseMapping.json +48 -0
  80. package/json-schema/Datasource.json +25 -5
  81. package/json-schema/DatasourceCapabilities.json +25 -5
  82. package/json-schema/DocumentChunk.json +97 -0
  83. package/json-schema/DocumentLoaderConfig.json +69 -0
  84. package/json-schema/DocumentMetadata.json +61 -0
  85. package/json-schema/DriverCapabilities.json +30 -0
  86. package/json-schema/DriverDefinition.json +25 -5
  87. package/json-schema/DriverInterface.json +30 -0
  88. package/json-schema/EmailPasswordConfig.json +43 -0
  89. package/json-schema/EmbeddingModel.json +57 -0
  90. package/json-schema/EnterpriseAuthConfig.json +172 -0
  91. package/json-schema/Entity.json +55 -0
  92. package/json-schema/EqualityOperator.json +14 -0
  93. package/json-schema/FieldOperators.json +108 -0
  94. package/json-schema/FieldSynonymConfig.json +39 -0
  95. package/json-schema/FilterCondition.json +28 -0
  96. package/json-schema/Invitation.json +69 -0
  97. package/json-schema/InvitationStatus.json +15 -0
  98. package/json-schema/LDAPConfig.json +22 -5
  99. package/json-schema/MagicLinkConfig.json +21 -0
  100. package/json-schema/Member.json +46 -0
  101. package/json-schema/ModelCapability.json +47 -0
  102. package/json-schema/ModelConfig.json +181 -0
  103. package/json-schema/ModelLimits.json +45 -0
  104. package/json-schema/ModelPricing.json +28 -0
  105. package/json-schema/ModelProvider.json +19 -0
  106. package/json-schema/ModelRegistry.json +427 -0
  107. package/json-schema/ModelRegistryEntry.json +239 -0
  108. package/json-schema/ModelSelectionCriteria.json +50 -0
  109. package/json-schema/NLQAnalytics.json +106 -0
  110. package/json-schema/NLQFieldMapping.json +40 -0
  111. package/json-schema/NLQModelConfig.json +78 -0
  112. package/json-schema/NLQParseResult.json +252 -0
  113. package/json-schema/NLQRequest.json +110 -0
  114. package/json-schema/NLQResponse.json +288 -0
  115. package/json-schema/NLQTrainingExample.json +120 -0
  116. package/json-schema/NormalizedFilter.json +348 -0
  117. package/json-schema/OAuthProvider.json +66 -0
  118. package/json-schema/OIDCConfig.json +18 -3
  119. package/json-schema/Organization.json +52 -0
  120. package/json-schema/PasskeyConfig.json +54 -0
  121. package/json-schema/PromptTemplate.json +163 -0
  122. package/json-schema/PromptVariable.json +56 -0
  123. package/json-schema/QueryContext.json +72 -0
  124. package/json-schema/QueryFilter.json +34 -0
  125. package/json-schema/QueryIntent.json +21 -0
  126. package/json-schema/QueryTemplate.json +81 -0
  127. package/json-schema/RAGPipelineConfig.json +552 -0
  128. package/json-schema/RAGPipelineStatus.json +66 -0
  129. package/json-schema/RAGQueryRequest.json +64 -0
  130. package/json-schema/RAGQueryResponse.json +108 -0
  131. package/json-schema/RangeOperator.json +41 -0
  132. package/json-schema/RateLimitConfig.json +36 -0
  133. package/json-schema/Report.json +20 -26
  134. package/json-schema/RerankingConfig.json +34 -0
  135. package/json-schema/RetrievalStrategy.json +121 -0
  136. package/json-schema/SAMLConfig.json +17 -3
  137. package/json-schema/Session.json +63 -0
  138. package/json-schema/SessionConfig.json +56 -0
  139. package/json-schema/SetOperator.json +18 -0
  140. package/json-schema/SpecialOperator.json +18 -0
  141. package/json-schema/StandardAuthProvider.json +857 -0
  142. package/json-schema/StringOperator.json +21 -0
  143. package/json-schema/Timeframe.json +68 -0
  144. package/json-schema/TwoFactorConfig.json +40 -0
  145. package/json-schema/User.json +51 -0
  146. package/json-schema/UserFieldMapping.json +47 -0
  147. package/json-schema/VectorStoreConfig.json +82 -0
  148. package/json-schema/VectorStoreProvider.json +21 -0
  149. package/json-schema/VerificationToken.json +36 -0
  150. package/package.json +27 -1
  151. package/json-schema/AuthProtocol.json +0 -17
  152. 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;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
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
+ });