Refactor formula engine and validator into separate plugin packages#252
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Created @objectql/plugin-formula package with FormulaEngine and FormulaPlugin - Created @objectql/plugin-validator package with Validator and ValidatorPlugin - Updated @objectql/core to depend on and re-export from new plugins - Moved all source files and tests to appropriate plugin packages - Updated imports throughout the codebase - All packages build successfully Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
…ixes - Fixed test imports and added mock-driver to plugin test directories - Created comprehensive MIGRATION_GUIDE.md - Fixed code formatting issues identified in review - All 282 tests passing (109 formula, 52 validator, 121 core) - CodeQL security scan passed with no alerts - Backward compatibility maintained through core package re-exports Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
|
不需要Re-exports components for backward compatibility @copilot |
Per feedback, the @objectql/core package no longer re-exports components from
plugin-formula and plugin-validator. Users must now explicitly import from the
plugin packages they use, enforcing clean separation of concerns.
Breaking change: Applications must update imports:
- Before: import { FormulaEngine, Validator } from '@objectql/core';
- After: import { FormulaEngine } from '@objectql/plugin-formula';
import { Validator } from '@objectql/plugin-validator';
Updated MIGRATION_GUIDE.md and PLUGIN_REFACTORING_SUMMARY.md to reflect
this change and remove references to backward compatibility.
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Done. Removed backward compatibility re-exports from @objectql/core. Users must now explicitly import from @objectql/plugin-formula and @objectql/plugin-validator. This enforces clean separation of concerns. Updated documentation (MIGRATION_GUIDE.md and PLUGIN_REFACTORING_SUMMARY.md) to reflect this breaking change. All 282 tests still passing. Commit: 73822a4 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
- Add plugin-validator and plugin-formula to root tsconfig references - Update core package tsconfig to reference plugin packages - Fix CLI import to use plugin-validator directly - Add plugin-validator dependency to CLI package Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
- Revert core re-exports to avoid circular dependency - Update test to import from @objectql/plugin-validator - Add plugin-validator as devDependency to platform-node Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
- Remove validation.test.ts from platform-node (not its responsibility) - Remove plugin-validator devDependency from platform-node - Validation tests already exist in plugin-validator package (52 tests) Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
- Add comprehensive validation tests to plugin-validator (uniqueness, business rules, cross-field, state machine, triggers, severity) - Remove validation.test.ts from platform-node (tests now in correct package) - Platform-node tests pass (5 tests) - focused on platform responsibilities - Plugin-validator now has 71 tests total (some failing due to incomplete implementation - to be fixed separately) Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
| import { | ||
| ValidationContext, | ||
| CrossFieldValidationRule, | ||
| StateMachineValidationRule, | ||
| UniquenessValidationRule, | ||
| BusinessRuleValidationRule, | ||
| CustomValidationRule, | ||
| FieldConfig, | ||
| AnyValidationRule, | ||
| } from '@objectql/types'; |
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
There was a problem hiding this comment.
Pull request overview
Refactors ObjectQL by extracting the formula engine and validation engine from @objectql/core into two dedicated plugin packages, improving modularity and enabling explicit, opt-in dependencies.
Changes:
- Introduced
@objectql/plugin-formulaand@objectql/plugin-validatorpackages (engines + plugin wrappers + tests/docs). - Updated
@objectql/coreto depend on (but not re-export) the new plugins; updated internal imports accordingly. - Updated CLI and shared type definitions to reflect the new plugin-based architecture.
Reviewed changes
Copilot reviewed 30 out of 39 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Adds TS project references for the new plugin packages. |
| packages/tools/cli/tsconfig.json | Adds plugin-validator reference so CLI builds with the new dependency. |
| packages/tools/cli/src/commands/ai.ts | Switches Validator import from core to @objectql/plugin-validator. |
| packages/tools/cli/package.json | Adds @objectql/plugin-validator dependency. |
| packages/foundation/types/src/validation.ts | Extends validation schema types (business-rule shorthand + cross-field shorthand). |
| packages/foundation/plugin-validator/tsconfig.json | New TS config for validator plugin package. |
| packages/foundation/plugin-validator/test/validator.test.ts | New validator engine tests in plugin package. |
| packages/foundation/plugin-validator/test/validator-plugin.test.ts | New validator plugin wrapper tests. |
| packages/foundation/plugin-validator/test/validation-spec-compliance.test.ts | Spec compliance coverage for validator behavior. |
| packages/foundation/plugin-validator/src/validator.ts | Validator engine implementation moved into plugin package + enhancements. |
| packages/foundation/plugin-validator/src/validator-plugin.ts | Validator plugin wrapper (kernel integration hooks). |
| packages/foundation/plugin-validator/src/index.ts | Plugin package public exports. |
| packages/foundation/plugin-validator/package.json | New plugin package manifest. |
| packages/foundation/plugin-validator/jest.config.js | Jest config for plugin package tests. |
| packages/foundation/plugin-validator/README.md | Plugin documentation and usage examples. |
| packages/foundation/plugin-formula/tsconfig.json | New TS config for formula plugin package. |
| packages/foundation/plugin-formula/test/mock-driver.ts | Test helper driver for formula integration tests. |
| packages/foundation/plugin-formula/test/formula-spec-compliance.test.ts | Spec compliance tests for formula behavior. |
| packages/foundation/plugin-formula/test/formula-plugin.test.ts | New formula plugin wrapper tests. |
| packages/foundation/plugin-formula/test/formula-integration.test.ts | Updates integration test import to use @objectql/core. |
| packages/foundation/plugin-formula/test/formula-engine.test.ts | Formula engine unit tests moved into plugin package. |
| packages/foundation/plugin-formula/src/index.ts | Plugin package public exports. |
| packages/foundation/plugin-formula/src/formula-plugin.ts | Formula plugin wrapper (kernel provider + hook registration). |
| packages/foundation/plugin-formula/src/formula-engine.ts | Formula engine implementation moved into plugin package. |
| packages/foundation/plugin-formula/package.json | New plugin package manifest. |
| packages/foundation/plugin-formula/jest.config.js | Jest config for plugin package tests. |
| packages/foundation/plugin-formula/README.md | Plugin documentation and usage examples. |
| packages/foundation/platform-node/test/validation.test.ts | Removes platform-node validation tests migrated to plugin-validator. |
| packages/foundation/core/tsconfig.json | Adds TS project references to the new plugin packages. |
| packages/foundation/core/test/validator.test.ts | Removes core validator tests migrated to plugin-validator. |
| packages/foundation/core/test/plugin-integration.test.ts | Updates integration tests to import/mocks from new plugin packages. |
| packages/foundation/core/src/repository.ts | Switches internal imports to plugin-based Validator/FormulaEngine. |
| packages/foundation/core/src/plugin.ts | Switches internal imports to plugin-based ValidatorPlugin/FormulaPlugin. |
| packages/foundation/core/src/index.ts | Stops re-exporting validator/formula engines & plugins from core. |
| packages/foundation/core/src/ai-agent.ts | Switches Validator import from core-local to plugin package. |
| packages/foundation/core/package.json | Adds dependencies on @objectql/plugin-formula and @objectql/plugin-validator. |
| PLUGIN_REFACTORING_SUMMARY.md | Adds refactor summary/metrics and migration overview. |
| MIGRATION_GUIDE.md | Adds migration guide and new import paths/examples. |
Comments suppressed due to low confidence (8)
packages/foundation/core/src/ai-agent.ts:24
- Unused imports AnyValidationRule, ObjectConfig, ValidationContext, ValidationResult.
import {
ObjectConfig,
AnyValidationRule,
ValidationContext,
ValidationResult
} from '@objectql/types';
packages/foundation/core/src/repository.ts:9
- Unused import Filter.
import { ObjectQLContext, IObjectQL, ObjectConfig, Driver, UnifiedQuery, ActionContext, HookAPI, RetrievalHookContext, MutationHookContext, UpdateHookContext, ValidationContext, ValidationError, ValidationRuleResult, FormulaContext, Filter } from '@objectql/types';
packages/foundation/core/src/repository.ts:457
- Unused variable driver.
const driver = this.getDriver();
packages/tools/cli/src/commands/ai.ts:395
- Unused variable validator.
packages/foundation/core/src/ai-agent.ts:258 - The value assigned to parsedMetadata here is unused.
parsedMetadata = yaml.load(options.metadata);
packages/foundation/core/src/ai-agent.ts:271
- The value assigned to parsedMetadata here is unused.
parsedMetadata = options.metadata;
packages/foundation/core/src/plugin.ts:97
- This write to property 'config' is useless, since another property write always overrides it.
constructor(private config: ObjectQLPluginConfig = {}, ql?: any) {
packages/foundation/plugin-validator/src/validator.ts:637
- This use of variable 'valid' always evaluates to true.
| /** Shorthand: Field to check (alternative to using rule property) */ | ||
| field?: string; | ||
| /** Shorthand: Comparison operator (alternative to using rule property) */ | ||
| operator?: ValidationOperator; | ||
| /** Shorthand: Value to compare against (mutually exclusive with compare_to) */ |
There was a problem hiding this comment.
The new shorthand operator is typed as ValidationOperator, but the implementation now normalizes aliases like gte, lte, eq, etc. If those aliases are supported inputs (e.g., from YAML), the type should be widened to include them (or alias normalization removed) so TypeScript and runtime behavior stay consistent.
| 2. Review the [API Documentation](../../docs/api/) | ||
| 3. Open a new issue if needed | ||
|
|
||
| ## Additional Resources | ||
|
|
||
| - [Formula Plugin README](../packages/foundation/plugin-formula/README.md) | ||
| - [Validator Plugin README](../packages/foundation/plugin-validator/README.md) | ||
| - [API Documentation](../../docs/api/) | ||
| - [Examples](../../examples/) |
There was a problem hiding this comment.
These documentation links are broken as written. From the repository root, ../../docs/api/ points outside the repo, and the examples link ../../examples/ also points outside the repo. Update them to valid in-repo paths (or to the published docs site URLs if that’s the intent).
| 2. Review the [API Documentation](../../docs/api/) | |
| 3. Open a new issue if needed | |
| ## Additional Resources | |
| - [Formula Plugin README](../packages/foundation/plugin-formula/README.md) | |
| - [Validator Plugin README](../packages/foundation/plugin-validator/README.md) | |
| - [API Documentation](../../docs/api/) | |
| - [Examples](../../examples/) | |
| 2. Review the [API Documentation](./api/) | |
| 3. Open a new issue if needed | |
| ## Additional Resources | |
| - [Formula Plugin README](../packages/foundation/plugin-formula/README.md) | |
| - [Validator Plugin README](../packages/foundation/plugin-validator/README.md) | |
| - [API Documentation](./api/) | |
| - [Examples](../examples/) |
| 2. Review the [API Documentation](../../docs/api/) | ||
| 3. Open a new issue if needed | ||
|
|
||
| ## Additional Resources | ||
|
|
||
| - [Formula Plugin README](../packages/foundation/plugin-formula/README.md) | ||
| - [Validator Plugin README](../packages/foundation/plugin-validator/README.md) | ||
| - [API Documentation](../../docs/api/) | ||
| - [Examples](../../examples/) |
There was a problem hiding this comment.
The “Additional Resources” links use ../packages/... from the repo root, which resolves outside the repo and will 404 on GitHub. These should be ./packages/... (or another correct relative path).
| 2. Review the [API Documentation](../../docs/api/) | |
| 3. Open a new issue if needed | |
| ## Additional Resources | |
| - [Formula Plugin README](../packages/foundation/plugin-formula/README.md) | |
| - [Validator Plugin README](../packages/foundation/plugin-validator/README.md) | |
| - [API Documentation](../../docs/api/) | |
| - [Examples](../../examples/) | |
| 2. Review the [API Documentation](./docs/api/) | |
| 3. Open a new issue if needed | |
| ## Additional Resources | |
| - [Formula Plugin README](./packages/foundation/plugin-formula/README.md) | |
| - [Validator Plugin README](./packages/foundation/plugin-validator/README.md) | |
| - [API Documentation](./docs/api/) | |
| - [Examples](./examples/) |
| import { | ||
| ValidationContext, | ||
| CrossFieldValidationRule, | ||
| StateMachineValidationRule, | ||
| UniquenessValidationRule, | ||
| BusinessRuleValidationRule, | ||
| CustomValidationRule, | ||
| FieldConfig, | ||
| AnyValidationRule, | ||
| } from '@objectql/types'; |
There was a problem hiding this comment.
Unused import AnyValidationRule.
Extracted formula engine and validator from monolithic
@objectql/coreinto dedicated plugins, improving modularity and bundle size with clean separation of concerns.Changes
New Packages
Core Package Updates
Migration Path
Breaking Change: Applications must update imports to use dedicated packages:
Architecture
Before:
After:
Follows existing pattern from
@objectql/plugin-security. Enables tree-shaking and optional feature inclusion. Enforces clean architectural boundaries with explicit dependencies.Testing
Documentation
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.