@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,107 +0,0 @@
1
- "use strict";
2
- /**
3
- * ObjectQL Formula Plugin
4
- * Copyright (c) 2026-present ObjectStack Inc.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.FormulaPlugin = void 0;
11
- const formula_engine_1 = require("./formula-engine");
12
- /**
13
- * Formula Plugin
14
- *
15
- * Wraps the ObjectQL Formula Engine as an ObjectStack plugin.
16
- * Registers formula evaluation capabilities into the kernel.
17
- */
18
- class FormulaPlugin {
19
- constructor(config = {}) {
20
- this.name = '@objectql/formulas';
21
- this.version = '4.0.0';
22
- this.config = {
23
- autoEvaluateOnQuery: true,
24
- ...config
25
- };
26
- // Initialize the formula engine with configuration
27
- this.engine = new formula_engine_1.FormulaEngine(config);
28
- }
29
- /**
30
- * Install the plugin into the kernel
31
- * Registers formula evaluation capabilities
32
- */
33
- async install(ctx) {
34
- const kernel = ctx.engine;
35
- console.log(`[${this.name}] Installing formula plugin...`);
36
- // Make formula engine accessible from the kernel for direct usage
37
- kernel.formulaEngine = this.engine;
38
- // Register formula provider if the kernel supports it
39
- this.registerFormulaProvider(kernel);
40
- // Register formula evaluation middleware if auto-evaluation is enabled
41
- if (this.config.autoEvaluateOnQuery !== false) {
42
- this.registerFormulaMiddleware(kernel);
43
- }
44
- console.log(`[${this.name}] Formula plugin installed`);
45
- }
46
- /**
47
- * Register the formula provider with the kernel
48
- * @private
49
- */
50
- registerFormulaProvider(kernel) {
51
- // Check if kernel supports formula provider registration
52
- if (typeof kernel.registerFormulaProvider === 'function') {
53
- kernel.registerFormulaProvider({
54
- evaluate: (formula, context) => {
55
- // Delegate to the formula engine
56
- // Note: In a real implementation, we would need to properly construct
57
- // the FormulaContext from the provided context
58
- return this.engine.evaluate(formula, context, 'text', // default data type
59
- {});
60
- },
61
- validate: (expression) => {
62
- return this.engine.validate(expression);
63
- },
64
- extractMetadata: (fieldName, expression, dataType) => {
65
- return this.engine.extractMetadata(fieldName, expression, dataType);
66
- }
67
- });
68
- }
69
- // Note: formulaEngine is already registered in install() method above
70
- }
71
- /**
72
- * Register formula evaluation middleware
73
- * @private
74
- */
75
- registerFormulaMiddleware(kernel) {
76
- // Check if kernel supports middleware hooks
77
- if (typeof kernel.use === 'function') {
78
- // Register middleware to evaluate formulas after queries
79
- kernel.use('afterQuery', async (context) => {
80
- var _a;
81
- // Formula evaluation logic would go here
82
- // This would automatically compute formula fields after data is retrieved
83
- if (context.results && ((_a = context.metadata) === null || _a === void 0 ? void 0 : _a.fields)) {
84
- // Iterate through fields and evaluate formulas
85
- // const formulaFields = Object.entries(context.metadata.fields)
86
- // .filter(([_, fieldConfig]) => (fieldConfig as any).formula);
87
- //
88
- // for (const record of context.results) {
89
- // for (const [fieldName, fieldConfig] of formulaFields) {
90
- // const formula = (fieldConfig as any).formula;
91
- // const result = this.engine.evaluate(formula, /* context */, /* dataType */);
92
- // record[fieldName] = result.value;
93
- // }
94
- // }
95
- }
96
- });
97
- }
98
- }
99
- /**
100
- * Get the formula engine instance for direct access
101
- */
102
- getEngine() {
103
- return this.engine;
104
- }
105
- }
106
- exports.FormulaPlugin = FormulaPlugin;
107
- //# sourceMappingURL=formula-plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formula-plugin.js","sourceRoot":"","sources":["../src/formula-plugin.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAGH,qDAAiD;AAqBjD;;;;;GAKG;AACH,MAAa,aAAa;IAOxB,YAAY,SAA8B,EAAE;QAN5C,SAAI,GAAG,oBAAoB,CAAC;QAC5B,YAAO,GAAG,OAAO,CAAC;QAMhB,IAAI,CAAC,MAAM,GAAG;YACZ,mBAAmB,EAAE,IAAI;YACzB,GAAG,MAAM;SACV,CAAC;QAEF,mDAAmD;QACnD,IAAI,CAAC,MAAM,GAAG,IAAI,8BAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,GAAmB;QAC/B,MAAM,MAAM,GAAG,GAAG,CAAC,MAA4B,CAAC;QAEhD,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,gCAAgC,CAAC,CAAC;QAE3D,kEAAkE;QAClE,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;QAEnC,sDAAsD;QACtD,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAErC,uEAAuE;QACvE,IAAI,IAAI,CAAC,MAAM,CAAC,mBAAmB,KAAK,KAAK,EAAE,CAAC;YAC9C,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,4BAA4B,CAAC,C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C;oBACxC,MAAM;oBACN,IAAI;gBACN,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAxGD,sCAwGC"}
@@ -1,56 +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
- import type { RuntimePlugin, RuntimeContext } from '@objectql/runtime';
9
- import { Validator, ValidatorOptions } from './validator';
10
- /**
11
- * Configuration for the Validator Plugin
12
- */
13
- export interface ValidatorPluginConfig extends ValidatorOptions {
14
- /**
15
- * Enable validation on queries
16
- * @default true
17
- */
18
- enableQueryValidation?: boolean;
19
- /**
20
- * Enable validation on mutations
21
- * @default true
22
- */
23
- enableMutationValidation?: boolean;
24
- }
25
- /**
26
- * Validator Plugin
27
- *
28
- * Wraps the ObjectQL Validator engine as an ObjectStack plugin.
29
- * Registers validation middleware hooks into the kernel lifecycle.
30
- */
31
- export declare class ValidatorPlugin implements RuntimePlugin {
32
- name: string;
33
- version: string;
34
- private validator;
35
- private config;
36
- constructor(config?: ValidatorPluginConfig);
37
- /**
38
- * Install the plugin into the kernel
39
- * Registers validation middleware for queries and mutations
40
- */
41
- install(ctx: RuntimeContext): Promise<void>;
42
- /**
43
- * Register query validation middleware
44
- * @private
45
- */
46
- private registerQueryValidation;
47
- /**
48
- * Register mutation validation middleware
49
- * @private
50
- */
51
- private registerMutationValidation;
52
- /**
53
- * Get the validator instance for direct access
54
- */
55
- getValidator(): Validator;
56
- }
@@ -1,106 +0,0 @@
1
- "use strict";
2
- /**
3
- * ObjectQL Validator Plugin
4
- * Copyright (c) 2026-present ObjectStack Inc.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ValidatorPlugin = void 0;
11
- const validator_1 = require("./validator");
12
- /**
13
- * Validator Plugin
14
- *
15
- * Wraps the ObjectQL Validator engine as an ObjectStack plugin.
16
- * Registers validation middleware hooks into the kernel lifecycle.
17
- */
18
- class ValidatorPlugin {
19
- constructor(config = {}) {
20
- this.name = '@objectql/validator';
21
- this.version = '4.0.0';
22
- this.config = {
23
- enableQueryValidation: true,
24
- enableMutationValidation: true,
25
- ...config
26
- };
27
- // Initialize the validator with language options
28
- this.validator = new validator_1.Validator({
29
- language: config.language,
30
- languageFallback: config.languageFallback,
31
- });
32
- }
33
- /**
34
- * Install the plugin into the kernel
35
- * Registers validation middleware for queries and mutations
36
- */
37
- async install(ctx) {
38
- const kernel = ctx.engine;
39
- console.log(`[${this.name}] Installing validator plugin...`);
40
- // Make validator accessible from the kernel for direct usage
41
- kernel.validator = this.validator;
42
- // Register validation middleware for queries (if enabled)
43
- if (this.config.enableQueryValidation !== false) {
44
- this.registerQueryValidation(kernel);
45
- }
46
- // Register validation middleware for mutations (if enabled)
47
- if (this.config.enableMutationValidation !== false) {
48
- this.registerMutationValidation(kernel);
49
- }
50
- console.log(`[${this.name}] Validator plugin installed`);
51
- }
52
- /**
53
- * Register query validation middleware
54
- * @private
55
- */
56
- registerQueryValidation(kernel) {
57
- // Check if kernel supports middleware hooks
58
- if (typeof kernel.use === 'function') {
59
- kernel.use('beforeQuery', async (context) => {
60
- var _a;
61
- // Query validation logic
62
- // In a real implementation, this would validate query parameters
63
- // For now, this is a placeholder that demonstrates the integration pattern
64
- if (context.query && ((_a = context.metadata) === null || _a === void 0 ? void 0 : _a.validation_rules)) {
65
- // Validation would happen here
66
- // const result = await this.validator.validate(
67
- // context.metadata.validation_rules,
68
- // { /* validation context */ }
69
- // );
70
- }
71
- });
72
- }
73
- }
74
- /**
75
- * Register mutation validation middleware
76
- * @private
77
- */
78
- registerMutationValidation(kernel) {
79
- // Check if kernel supports middleware hooks
80
- if (typeof kernel.use === 'function') {
81
- kernel.use('beforeMutation', async (context) => {
82
- var _a;
83
- // Mutation validation logic
84
- // This would validate data before create/update operations
85
- if (context.data && ((_a = context.metadata) === null || _a === void 0 ? void 0 : _a.validation_rules)) {
86
- // Validation would happen here
87
- // const result = await this.validator.validate(
88
- // context.metadata.validation_rules,
89
- // { /* validation context */ }
90
- // );
91
- // if (!result.valid) {
92
- // throw new Error('Validation failed: ' + result.errors.map(e => e.message).join(', '));
93
- // }
94
- }
95
- });
96
- }
97
- }
98
- /**
99
- * Get the validator instance for direct access
100
- */
101
- getValidator() {
102
- return this.validator;
103
- }
104
- }
105
- exports.ValidatorPlugin = ValidatorPlugin;
106
- //# sourceMappingURL=validator-plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validator-plugin.js","sourceRoot":"","sources":["../src/validator-plugin.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAGH,2CAA0D;AA0B1D;;;;;GAKG;AACH,MAAa,eAAe;IAO1B,YAAY,SAAgC,EAAE;QAN9C,SAAI,GAAG,qBAAqB,CAAC;QAC7B,YAAO,GAAG,OAAO,CAAC;QAMhB,IAAI,CAAC,MAAM,GAAG;YACZ,qBAAqB,EAAE,IAAI;YAC3B,wBAAwB,EAAE,IAAI;YAC9B,GAAG,MAAM;SACV,CAAC;QAEF,iDAAiD;QACjD,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAS,CAAC;YAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;SAC1C,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,GAAmB;QAC/B,MAAM,MAAM,GAAG,GAAG,CAAC,MAA6B,CAAC;QAEjD,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,kCAAkC,CAAC,CAAC;QAE7D,6DAA6D;QAC7D,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAElC,0DAA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jC,KAAK;oBACL,uBAAuB;oBACvB,2FAA2F;oBAC3F,IAAI;gBACN,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AAlGD,0CAkGC"}
@@ -1,80 +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
- * Validation engine for ObjectQL.
10
- * Executes validation rules based on metadata configuration.
11
- */
12
- import { AnyValidationRule, ValidationContext, ValidationResult, ValidationRuleResult, FieldConfig } from '@objectql/types';
13
- /**
14
- * Configuration options for the Validator.
15
- */
16
- export interface ValidatorOptions {
17
- /** Preferred language for validation messages (default: 'en') */
18
- language?: string;
19
- /** Fallback languages if preferred language is not available */
20
- languageFallback?: string[];
21
- }
22
- /**
23
- * Validator class that executes validation rules.
24
- */
25
- export declare class Validator {
26
- private options;
27
- constructor(options?: ValidatorOptions);
28
- /**
29
- * Validate a record against a set of rules.
30
- */
31
- validate(rules: AnyValidationRule[], context: ValidationContext): Promise<ValidationResult>;
32
- /**
33
- * Validate field-level rules.
34
- */
35
- validateField(fieldName: string, fieldConfig: FieldConfig, value: any, context: ValidationContext): Promise<ValidationRuleResult[]>;
36
- /**
37
- * Check if a rule should be applied based on triggers and conditions.
38
- */
39
- private shouldApplyRule;
40
- /**
41
- * Validate cross-field rule.
42
- */
43
- private validateCrossField;
44
- /**
45
- * Validate state machine transitions.
46
- */
47
- private validateStateMachine;
48
- /**
49
- * Validate uniqueness by checking database for existing values.
50
- */
51
- private validateUniqueness;
52
- /**
53
- * Extract field names from a validation condition.
54
- */
55
- private extractFieldsFromCondition;
56
- /**
57
- * Validate business rule by evaluating constraint conditions.
58
- */
59
- private validateBusinessRule;
60
- /**
61
- * Validate custom rule (stub - requires function execution).
62
- */
63
- private validateCustom;
64
- /**
65
- * Evaluate a validation condition.
66
- */
67
- private evaluateCondition;
68
- /**
69
- * Compare two values using an operator.
70
- */
71
- private compareValues;
72
- /**
73
- * Format validation message with template variables.
74
- */
75
- private formatMessage;
76
- /**
77
- * Get nested value from object by path.
78
- */
79
- private getNestedValue;
80
- }