@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.
- package/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +32 -0
- package/README.md +14 -12
- package/dist/app.d.ts +9 -6
- package/dist/app.js +151 -29
- package/dist/app.js.map +1 -1
- package/dist/index.d.ts +6 -9
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/dist/optimizations/CompiledHookManager.d.ts +55 -0
- package/dist/optimizations/CompiledHookManager.js +164 -0
- package/dist/optimizations/CompiledHookManager.js.map +1 -0
- package/dist/optimizations/DependencyGraph.d.ts +82 -0
- package/dist/optimizations/DependencyGraph.js +211 -0
- package/dist/optimizations/DependencyGraph.js.map +1 -0
- package/dist/optimizations/GlobalConnectionPool.d.ts +89 -0
- package/dist/optimizations/GlobalConnectionPool.js +193 -0
- package/dist/optimizations/GlobalConnectionPool.js.map +1 -0
- package/dist/optimizations/LazyMetadataLoader.d.ts +75 -0
- package/dist/optimizations/LazyMetadataLoader.js +149 -0
- package/dist/optimizations/LazyMetadataLoader.js.map +1 -0
- package/dist/optimizations/OptimizedMetadataRegistry.d.ts +26 -0
- package/dist/optimizations/OptimizedMetadataRegistry.js +117 -0
- package/dist/optimizations/OptimizedMetadataRegistry.js.map +1 -0
- package/dist/optimizations/OptimizedValidationEngine.d.ts +73 -0
- package/dist/optimizations/OptimizedValidationEngine.js +141 -0
- package/dist/optimizations/OptimizedValidationEngine.js.map +1 -0
- package/dist/optimizations/QueryCompiler.d.ts +51 -0
- package/dist/optimizations/QueryCompiler.js +216 -0
- package/dist/optimizations/QueryCompiler.js.map +1 -0
- package/dist/optimizations/SQLQueryOptimizer.d.ts +96 -0
- package/dist/optimizations/SQLQueryOptimizer.js +265 -0
- package/dist/optimizations/SQLQueryOptimizer.js.map +1 -0
- package/dist/optimizations/index.d.ts +32 -0
- package/dist/optimizations/index.js +44 -0
- package/dist/optimizations/index.js.map +1 -0
- package/dist/plugin.d.ts +6 -7
- package/dist/plugin.js +39 -22
- package/dist/plugin.js.map +1 -1
- package/dist/query/filter-translator.d.ts +6 -18
- package/dist/query/filter-translator.js +6 -103
- package/dist/query/filter-translator.js.map +1 -1
- package/dist/query/query-analyzer.js +24 -25
- package/dist/query/query-analyzer.js.map +1 -1
- package/dist/query/query-builder.d.ts +9 -3
- package/dist/query/query-builder.js +25 -35
- package/dist/query/query-builder.js.map +1 -1
- package/dist/query/query-service.d.ts +2 -2
- package/dist/query/query-service.js +5 -5
- package/dist/query/query-service.js.map +1 -1
- package/dist/repository.d.ts +2 -0
- package/dist/repository.js +24 -17
- package/dist/repository.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +8 -5
- package/src/app.ts +173 -47
- package/src/index.ts +7 -8
- package/src/optimizations/CompiledHookManager.ts +185 -0
- package/src/optimizations/DependencyGraph.ts +255 -0
- package/src/optimizations/GlobalConnectionPool.ts +251 -0
- package/src/optimizations/LazyMetadataLoader.ts +180 -0
- package/src/optimizations/OptimizedMetadataRegistry.ts +132 -0
- package/src/optimizations/OptimizedValidationEngine.ts +172 -0
- package/src/optimizations/QueryCompiler.ts +242 -0
- package/src/optimizations/SQLQueryOptimizer.ts +329 -0
- package/src/optimizations/index.ts +34 -0
- package/src/plugin.ts +51 -28
- package/src/query/filter-translator.ts +8 -115
- package/src/query/query-analyzer.ts +25 -29
- package/src/query/query-builder.ts +26 -43
- package/src/query/query-service.ts +6 -6
- package/src/repository.ts +35 -22
- package/test/__mocks__/@objectstack/runtime.ts +8 -8
- package/test/app.test.ts +11 -8
- package/test/optimizations.test.ts +440 -0
- package/test/plugin-integration.test.ts +30 -19
- package/tsconfig.json +4 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/ai-agent.d.ts +0 -176
- package/dist/ai-agent.js +0 -722
- package/dist/ai-agent.js.map +0 -1
- package/dist/formula-engine.d.ts +0 -102
- package/dist/formula-engine.js +0 -433
- package/dist/formula-engine.js.map +0 -1
- package/dist/formula-plugin.d.ts +0 -52
- package/dist/formula-plugin.js +0 -107
- package/dist/formula-plugin.js.map +0 -1
- package/dist/validator-plugin.d.ts +0 -56
- package/dist/validator-plugin.js +0 -106
- package/dist/validator-plugin.js.map +0 -1
- package/dist/validator.d.ts +0 -80
- package/dist/validator.js +0 -625
- package/dist/validator.js.map +0 -1
- package/src/ai-agent.ts +0 -868
- package/src/formula-engine.ts +0 -572
- package/src/formula-plugin.ts +0 -141
- package/src/validator-plugin.ts +0 -140
- package/src/validator.ts +0 -743
- package/test/formula-engine.test.ts +0 -725
- package/test/formula-integration.test.ts +0 -286
- package/test/formula-plugin.test.ts +0 -197
- package/test/validator-plugin.test.ts +0 -126
- package/test/validator.test.ts +0 -440
package/src/validator-plugin.ts
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ObjectQL Validator Plugin
|
|
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
|
-
import type { RuntimePlugin, RuntimeContext, ObjectStackKernel } from '@objectql/runtime';
|
|
10
|
-
import { Validator, ValidatorOptions } from './validator';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Extended ObjectStack Kernel with validator capability
|
|
14
|
-
*/
|
|
15
|
-
interface KernelWithValidator extends ObjectStackKernel {
|
|
16
|
-
validator?: Validator;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Configuration for the Validator Plugin
|
|
21
|
-
*/
|
|
22
|
-
export interface ValidatorPluginConfig extends ValidatorOptions {
|
|
23
|
-
/**
|
|
24
|
-
* Enable validation on queries
|
|
25
|
-
* @default true
|
|
26
|
-
*/
|
|
27
|
-
enableQueryValidation?: boolean;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Enable validation on mutations
|
|
31
|
-
* @default true
|
|
32
|
-
*/
|
|
33
|
-
enableMutationValidation?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Validator Plugin
|
|
38
|
-
*
|
|
39
|
-
* Wraps the ObjectQL Validator engine as an ObjectStack plugin.
|
|
40
|
-
* Registers validation middleware hooks into the kernel lifecycle.
|
|
41
|
-
*/
|
|
42
|
-
export class ValidatorPlugin implements RuntimePlugin {
|
|
43
|
-
name = '@objectql/validator';
|
|
44
|
-
version = '4.0.0';
|
|
45
|
-
|
|
46
|
-
private validator: Validator;
|
|
47
|
-
private config: ValidatorPluginConfig;
|
|
48
|
-
|
|
49
|
-
constructor(config: ValidatorPluginConfig = {}) {
|
|
50
|
-
this.config = {
|
|
51
|
-
enableQueryValidation: true,
|
|
52
|
-
enableMutationValidation: true,
|
|
53
|
-
...config
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// Initialize the validator with language options
|
|
57
|
-
this.validator = new Validator({
|
|
58
|
-
language: config.language,
|
|
59
|
-
languageFallback: config.languageFallback,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Install the plugin into the kernel
|
|
65
|
-
* Registers validation middleware for queries and mutations
|
|
66
|
-
*/
|
|
67
|
-
async install(ctx: RuntimeContext): Promise<void> {
|
|
68
|
-
const kernel = ctx.engine as KernelWithValidator;
|
|
69
|
-
|
|
70
|
-
console.log(`[${this.name}] Installing validator plugin...`);
|
|
71
|
-
|
|
72
|
-
// Make validator accessible from the kernel for direct usage
|
|
73
|
-
kernel.validator = this.validator;
|
|
74
|
-
|
|
75
|
-
// Register validation middleware for queries (if enabled)
|
|
76
|
-
if (this.config.enableQueryValidation !== false) {
|
|
77
|
-
this.registerQueryValidation(kernel);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Register validation middleware for mutations (if enabled)
|
|
81
|
-
if (this.config.enableMutationValidation !== false) {
|
|
82
|
-
this.registerMutationValidation(kernel);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
console.log(`[${this.name}] Validator plugin installed`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Register query validation middleware
|
|
90
|
-
* @private
|
|
91
|
-
*/
|
|
92
|
-
private registerQueryValidation(kernel: KernelWithValidator): void {
|
|
93
|
-
// Check if kernel supports middleware hooks
|
|
94
|
-
if (typeof (kernel as any).use === 'function') {
|
|
95
|
-
(kernel as any).use('beforeQuery', async (context: any) => {
|
|
96
|
-
// Query validation logic
|
|
97
|
-
// In a real implementation, this would validate query parameters
|
|
98
|
-
// For now, this is a placeholder that demonstrates the integration pattern
|
|
99
|
-
if (context.query && context.metadata?.validation_rules) {
|
|
100
|
-
// Validation would happen here
|
|
101
|
-
// const result = await this.validator.validate(
|
|
102
|
-
// context.metadata.validation_rules,
|
|
103
|
-
// { /* validation context */ }
|
|
104
|
-
// );
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Register mutation validation middleware
|
|
112
|
-
* @private
|
|
113
|
-
*/
|
|
114
|
-
private registerMutationValidation(kernel: KernelWithValidator): void {
|
|
115
|
-
// Check if kernel supports middleware hooks
|
|
116
|
-
if (typeof (kernel as any).use === 'function') {
|
|
117
|
-
(kernel as any).use('beforeMutation', async (context: any) => {
|
|
118
|
-
// Mutation validation logic
|
|
119
|
-
// This would validate data before create/update operations
|
|
120
|
-
if (context.data && context.metadata?.validation_rules) {
|
|
121
|
-
// Validation would happen here
|
|
122
|
-
// const result = await this.validator.validate(
|
|
123
|
-
// context.metadata.validation_rules,
|
|
124
|
-
// { /* validation context */ }
|
|
125
|
-
// );
|
|
126
|
-
// if (!result.valid) {
|
|
127
|
-
// throw new Error('Validation failed: ' + result.errors.map(e => e.message).join(', '));
|
|
128
|
-
// }
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Get the validator instance for direct access
|
|
136
|
-
*/
|
|
137
|
-
getValidator(): Validator {
|
|
138
|
-
return this.validator;
|
|
139
|
-
}
|
|
140
|
-
}
|