@objectql/core 4.0.1 → 4.0.3

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 (103) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/CHANGELOG.md +32 -0
  3. package/README.md +14 -12
  4. package/dist/app.d.ts +9 -6
  5. package/dist/app.js +151 -29
  6. package/dist/app.js.map +1 -1
  7. package/dist/index.d.ts +6 -9
  8. package/dist/index.js +2 -5
  9. package/dist/index.js.map +1 -1
  10. package/dist/optimizations/CompiledHookManager.d.ts +55 -0
  11. package/dist/optimizations/CompiledHookManager.js +164 -0
  12. package/dist/optimizations/CompiledHookManager.js.map +1 -0
  13. package/dist/optimizations/DependencyGraph.d.ts +82 -0
  14. package/dist/optimizations/DependencyGraph.js +211 -0
  15. package/dist/optimizations/DependencyGraph.js.map +1 -0
  16. package/dist/optimizations/GlobalConnectionPool.d.ts +89 -0
  17. package/dist/optimizations/GlobalConnectionPool.js +193 -0
  18. package/dist/optimizations/GlobalConnectionPool.js.map +1 -0
  19. package/dist/optimizations/LazyMetadataLoader.d.ts +75 -0
  20. package/dist/optimizations/LazyMetadataLoader.js +149 -0
  21. package/dist/optimizations/LazyMetadataLoader.js.map +1 -0
  22. package/dist/optimizations/OptimizedMetadataRegistry.d.ts +26 -0
  23. package/dist/optimizations/OptimizedMetadataRegistry.js +117 -0
  24. package/dist/optimizations/OptimizedMetadataRegistry.js.map +1 -0
  25. package/dist/optimizations/OptimizedValidationEngine.d.ts +73 -0
  26. package/dist/optimizations/OptimizedValidationEngine.js +141 -0
  27. package/dist/optimizations/OptimizedValidationEngine.js.map +1 -0
  28. package/dist/optimizations/QueryCompiler.d.ts +51 -0
  29. package/dist/optimizations/QueryCompiler.js +216 -0
  30. package/dist/optimizations/QueryCompiler.js.map +1 -0
  31. package/dist/optimizations/SQLQueryOptimizer.d.ts +96 -0
  32. package/dist/optimizations/SQLQueryOptimizer.js +265 -0
  33. package/dist/optimizations/SQLQueryOptimizer.js.map +1 -0
  34. package/dist/optimizations/index.d.ts +32 -0
  35. package/dist/optimizations/index.js +44 -0
  36. package/dist/optimizations/index.js.map +1 -0
  37. package/dist/plugin.d.ts +6 -7
  38. package/dist/plugin.js +39 -22
  39. package/dist/plugin.js.map +1 -1
  40. package/dist/query/filter-translator.d.ts +6 -18
  41. package/dist/query/filter-translator.js +6 -103
  42. package/dist/query/filter-translator.js.map +1 -1
  43. package/dist/query/query-analyzer.js +24 -25
  44. package/dist/query/query-analyzer.js.map +1 -1
  45. package/dist/query/query-builder.d.ts +9 -3
  46. package/dist/query/query-builder.js +25 -35
  47. package/dist/query/query-builder.js.map +1 -1
  48. package/dist/query/query-service.d.ts +2 -2
  49. package/dist/query/query-service.js +5 -5
  50. package/dist/query/query-service.js.map +1 -1
  51. package/dist/repository.d.ts +2 -0
  52. package/dist/repository.js +24 -17
  53. package/dist/repository.js.map +1 -1
  54. package/jest.config.js +3 -3
  55. package/package.json +8 -5
  56. package/src/app.ts +173 -47
  57. package/src/index.ts +7 -8
  58. package/src/optimizations/CompiledHookManager.ts +185 -0
  59. package/src/optimizations/DependencyGraph.ts +255 -0
  60. package/src/optimizations/GlobalConnectionPool.ts +251 -0
  61. package/src/optimizations/LazyMetadataLoader.ts +180 -0
  62. package/src/optimizations/OptimizedMetadataRegistry.ts +132 -0
  63. package/src/optimizations/OptimizedValidationEngine.ts +172 -0
  64. package/src/optimizations/QueryCompiler.ts +242 -0
  65. package/src/optimizations/SQLQueryOptimizer.ts +329 -0
  66. package/src/optimizations/index.ts +34 -0
  67. package/src/plugin.ts +51 -28
  68. package/src/query/filter-translator.ts +8 -115
  69. package/src/query/query-analyzer.ts +25 -29
  70. package/src/query/query-builder.ts +26 -43
  71. package/src/query/query-service.ts +6 -6
  72. package/src/repository.ts +35 -22
  73. package/test/__mocks__/@objectstack/runtime.ts +8 -8
  74. package/test/app.test.ts +11 -8
  75. package/test/optimizations.test.ts +440 -0
  76. package/test/plugin-integration.test.ts +30 -19
  77. package/tsconfig.json +4 -6
  78. package/tsconfig.tsbuildinfo +1 -1
  79. package/dist/ai-agent.d.ts +0 -176
  80. package/dist/ai-agent.js +0 -722
  81. package/dist/ai-agent.js.map +0 -1
  82. package/dist/formula-engine.d.ts +0 -102
  83. package/dist/formula-engine.js +0 -433
  84. package/dist/formula-engine.js.map +0 -1
  85. package/dist/formula-plugin.d.ts +0 -52
  86. package/dist/formula-plugin.js +0 -107
  87. package/dist/formula-plugin.js.map +0 -1
  88. package/dist/validator-plugin.d.ts +0 -56
  89. package/dist/validator-plugin.js +0 -106
  90. package/dist/validator-plugin.js.map +0 -1
  91. package/dist/validator.d.ts +0 -80
  92. package/dist/validator.js +0 -625
  93. package/dist/validator.js.map +0 -1
  94. package/src/ai-agent.ts +0 -868
  95. package/src/formula-engine.ts +0 -572
  96. package/src/formula-plugin.ts +0 -141
  97. package/src/validator-plugin.ts +0 -140
  98. package/src/validator.ts +0 -743
  99. package/test/formula-engine.test.ts +0 -725
  100. package/test/formula-integration.test.ts +0 -286
  101. package/test/formula-plugin.test.ts +0 -197
  102. package/test/validator-plugin.test.ts +0 -126
  103. package/test/validator.test.ts +0 -440
@@ -1,176 +0,0 @@
1
- /**
2
- * ObjectQL
3
- * Copyright (c) 2026-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
- * Configuration for the ObjectQL AI Agent
10
- */
11
- export interface AgentConfig {
12
- /** OpenAI API key */
13
- apiKey: string;
14
- /** OpenAI model to use (default: gpt-4) */
15
- model?: string;
16
- /** Temperature for generation (0-1, default: 0.7) */
17
- temperature?: number;
18
- /** Preferred language for messages (default: en) */
19
- language?: string;
20
- }
21
- /**
22
- * Options for generating application metadata
23
- */
24
- export interface GenerateAppOptions {
25
- /** Natural language description of the application */
26
- description: string;
27
- /** Type of generation: basic (minimal), complete (comprehensive), or custom */
28
- type?: 'basic' | 'complete' | 'custom';
29
- /** Maximum tokens for generation */
30
- maxTokens?: number;
31
- }
32
- /**
33
- * Result of application generation
34
- */
35
- export interface GenerateAppResult {
36
- /** Whether generation was successful */
37
- success: boolean;
38
- /** Generated metadata files */
39
- files: Array<{
40
- filename: string;
41
- content: string;
42
- type: 'object' | 'validation' | 'action' | 'hook' | 'permission' | 'workflow' | 'data' | 'application' | 'typescript' | 'test' | 'other';
43
- }>;
44
- /** Any errors encountered */
45
- errors?: string[];
46
- /** AI model response (raw) */
47
- rawResponse?: string;
48
- }
49
- /**
50
- * Conversation message for step-by-step generation
51
- */
52
- export interface ConversationMessage {
53
- role: 'system' | 'user' | 'assistant';
54
- content: string;
55
- }
56
- /**
57
- * Options for conversational generation
58
- */
59
- export interface ConversationalGenerateOptions {
60
- /** Initial description or follow-up request */
61
- message: string;
62
- /** Previous conversation history */
63
- conversationHistory?: ConversationMessage[];
64
- /** Current application state (already generated files) */
65
- currentApp?: GenerateAppResult;
66
- }
67
- /**
68
- * Result of conversational generation
69
- */
70
- export interface ConversationalGenerateResult extends GenerateAppResult {
71
- /** Updated conversation history */
72
- conversationHistory: ConversationMessage[];
73
- /** Suggested next steps or questions */
74
- suggestions?: string[];
75
- }
76
- /**
77
- * Options for validating metadata
78
- */
79
- export interface ValidateMetadataOptions {
80
- /** Metadata content (YAML string or parsed object) */
81
- metadata: string | any;
82
- /** Filename (for context) */
83
- filename?: string;
84
- /** Whether to check business logic consistency */
85
- checkBusinessLogic?: boolean;
86
- /** Whether to check performance considerations */
87
- checkPerformance?: boolean;
88
- /** Whether to check security issues */
89
- checkSecurity?: boolean;
90
- }
91
- /**
92
- * Result of metadata validation
93
- */
94
- export interface ValidateMetadataResult {
95
- /** Whether validation passed (no errors) */
96
- valid: boolean;
97
- /** Errors found */
98
- errors: Array<{
99
- message: string;
100
- location?: string;
101
- code?: string;
102
- }>;
103
- /** Warnings found */
104
- warnings: Array<{
105
- message: string;
106
- location?: string;
107
- suggestion?: string;
108
- }>;
109
- /** Informational messages */
110
- info: Array<{
111
- message: string;
112
- location?: string;
113
- }>;
114
- }
115
- /**
116
- * ObjectQL AI Agent for programmatic application generation and validation
117
- */
118
- export declare class ObjectQLAgent {
119
- private openai;
120
- private validator;
121
- private config;
122
- constructor(config: AgentConfig);
123
- /**
124
- * Generate application metadata from natural language description
125
- */
126
- generateApp(options: GenerateAppOptions): Promise<GenerateAppResult>;
127
- /**
128
- * Validate metadata using AI
129
- */
130
- validateMetadata(options: ValidateMetadataOptions): Promise<ValidateMetadataResult>;
131
- /**
132
- * Refine existing metadata based on feedback
133
- */
134
- refineMetadata(metadata: string, feedback: string, iterations?: number): Promise<GenerateAppResult>;
135
- /**
136
- * Conversational generation with step-by-step refinement
137
- * This allows users to iteratively improve the application through dialogue
138
- */
139
- generateConversational(options: ConversationalGenerateOptions): Promise<ConversationalGenerateResult>;
140
- /**
141
- * Generate suggestions for next steps based on current application state
142
- */
143
- private generateSuggestions;
144
- /**
145
- * Get system prompt for metadata generation
146
- */
147
- private getSystemPrompt;
148
- /**
149
- * Get system prompt for validation
150
- */
151
- private getValidationSystemPrompt;
152
- /**
153
- * Build generation prompt based on options
154
- */
155
- private buildGenerationPrompt;
156
- /**
157
- * Build validation prompt
158
- */
159
- private buildValidationPrompt;
160
- /**
161
- * Parse generation response and extract files
162
- */
163
- private parseGenerationResponse;
164
- /**
165
- * Parse validation feedback into structured result
166
- */
167
- private parseFeedback;
168
- /**
169
- * Infer file type from filename
170
- */
171
- private inferFileType;
172
- }
173
- /**
174
- * Convenience function to create an agent instance
175
- */
176
- export declare function createAgent(apiKey: string, options?: Partial<AgentConfig>): ObjectQLAgent;