diff --git a/examples/json-ast.ts b/examples/json-ast.ts index 2060ddb..6aed37a 100644 --- a/examples/json-ast.ts +++ b/examples/json-ast.ts @@ -1,4 +1,7 @@ import { jsonToAst } from '../src/utils/json-ast/index'; +import { JsonNode } from '../src/utils/json-ast/types'; +import Debug from 'debug'; +const debug = Debug('rz:json-ast'); // Example JSON data const exampleJson = { @@ -34,7 +37,7 @@ debug("Original JSON:", JSON.stringify(exampleJson, null, 2)); debug("\nAST:", JSON.stringify(ast, null, 2)); // Example of traversing the AST -function traverse(node: any, indent = 0) { +function traverse(node: JsonNode, indent = 0) { const padding = ' '.repeat(indent); const type = node.type.toUpperCase(); const value = node.value !== undefined ? `: ${JSON.stringify(node.value)}` : ''; @@ -43,7 +46,7 @@ function traverse(node: any, indent = 0) { debug(`${padding}${type}${value}${path}`); if (node.children) { - node.children.forEach((child: any) => traverse(child, indent + 2)); + node.children.forEach((child: JsonNode) => traverse(child, indent + 2)); } } diff --git a/merge-chore-major-cleanup.md b/merge-chore-major-cleanup.md new file mode 100644 index 0000000..a5b53bf --- /dev/null +++ b/merge-chore-major-cleanup.md @@ -0,0 +1,59 @@ +# Merge Request: Major Cleanup and Refactoring + +## Overview +This MR represents a significant cleanup and refactoring effort, focusing on improving code organization, test structure, and documentation. The changes touch multiple areas of the codebase with a particular emphasis on the custom resolvers system and test infrastructure. + +## Key Changes + +### 1. Code Organization & Structure +- Reorganized test files into logical directories (`unit/`, `integration/`, `e2e/`, `performance/`) +- Moved and refactored custom resolvers into a more modular plugin architecture +- Created dedicated directories for documentation and planning artifacts + +### 2. New Features & Enhancements +- Implemented JSON AST functionality for better delta analysis +- Enhanced plugin system with inter-plugin dependency support +- Added new built-in resolver plugins: + - Concatenation + - First Write Wins + - Last Write Wins + - Majority Vote + - Max/Min + - Running Average + +### 3. Refactoring & Improvements +- Replaced `NegationHelper.createNegation` with `DeltaBuilder.negate` +- Improved relationship graph implementation +- Optimized lossless view resolution +- Enhanced resolver dependency handling and logging +- Added comprehensive test coverage for new and refactored components + +### 4. Documentation +- Added extensive documentation for custom resolvers API +- Created documentation for delta patterns and schema validation +- Added test helper documentation +- Organized planning documents in `__plans__/` directory + +### 5. Build & Tooling +- Added module alias `@src` for better import paths +- Removed unused scripts and logs +- Updated package dependencies + +## Testing +- Added numerous unit tests for new functionality +- Reorganized test files for better maintainability +- Added performance test cases +- Ensured backward compatibility through comprehensive test coverage + +## Migration Notes +- Some test files have been moved to new locations +- Custom resolvers now use the new plugin architecture +- Dependencies between resolvers should now be handled through the new dependency system + +## Next Steps +- Review the new plugin architecture documentation +- Update any custom resolvers to use the new plugin system +- Test performance impact of the changes in production-like environments + +## Related Issues +- [Reference any related issues or tickets here] diff --git a/src/views/resolvers/aggregation-resolvers.ts b/src/views/resolvers/aggregation-resolvers.ts index d714e01..0b7b11c 100644 --- a/src/views/resolvers/aggregation-resolvers.ts +++ b/src/views/resolvers/aggregation-resolvers.ts @@ -3,8 +3,6 @@ import { Lossy } from '../lossy'; import { DomainEntityID, PropertyID, ViewMany } from "../../core/types"; import { valueFromDelta } from "../lossless"; import { EntityRecord, EntityRecordMany } from "@src/core/entity"; -import Debug from 'debug'; -const debug = Debug('rz:test:performance'); export type AggregationType = 'min' | 'max' | 'sum' | 'average' | 'count'; diff --git a/src/views/resolvers/custom-resolvers/targeted-plugin.ts b/src/views/resolvers/custom-resolvers/targeted-plugin.ts deleted file mode 100644 index e8ef059..0000000 --- a/src/views/resolvers/custom-resolvers/targeted-plugin.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ResolverPlugin } from "./plugin"; - -export abstract class TargetedPlugin extends ResolverPlugin { - constructor(target?: string) { - // If no target is provided, then we want to implicitly target the property - // to which this plugin is attached. That means that when we apply an update, - // we want to take the value of - super(target); - } -} - \ No newline at end of file