-
Notifications
You must be signed in to change notification settings - Fork 0
survey engine v2.0.0 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
phev8
wants to merge
94
commits into
master
Choose a base branch
from
develop-v2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…lized content and dynamic values
…sive documentation and tests. The new methods move translations and dynamic values between component-level and global survey level, ensuring a locale-first structure. Added tests to verify functionality and reversibility of the processes.
…update compileSurvey/decompileSurvey methods to avoid redundant operations. Enhance tests to cover new functionality and edge cases.
…or consistency and clarity. Modify legacy-types to remove unnecessary types in LegacyLocalizedString.
- Introduced `convertLegacyToNewSurvey` and `convertNewToLegacySurvey` functions to handle conversions between legacy and new survey formats. - Updated `index.ts` to export new conversion functions and added a new `legacy-conversion.ts` file containing the implementation. - Added comprehensive tests for conversion functions to ensure accuracy and reversibility of transformations.
- Updated `SurveyProps` interface to include a `translations` property for managing localized content. - Modified `convertLegacyLocalizedObjectToContent` and `convertSurveyPropsToLegacy` functions to handle translations during conversion processes. - Implemented logic to move survey props translations to a global level during compilation and restore them during decompilation. - Added tests to verify the correct handling of survey props translations in various scenarios, ensuring accurate compilation and decompilation.
- Introduced locale management in `SurveyEngineCore` by adding `selectedLocale` and `availableLocales` properties. - Implemented methods for locale selection and retrieval of date formats based on the selected locale. - Enhanced content resolution to support dynamic values and translations, ensuring accurate rendering of localized content. - Updated tests to validate the new localization features and dynamic value resolution in various contexts. - Refactored component resolution logic to accommodate new translation and dynamic value handling.
- Replaced Rollup with tsdown for the build process in `package.json`. - Removed `rollup.config.js` as it is no longer needed. - Added a new `tsdown.config.ts` file to configure the new build tool. - Updated `devDependencies` in `package.json` to reflect the changes, including upgrading TypeScript and Jest types. - Cleaned up unused Rollup plugins and dependencies to streamline the project.
…component resolution - Simplified survey compilation logic by directly assigning the compiled survey to `surveyDef`. - Enhanced locale selection method to always set `selectedLocale`, ensuring consistent re-rendering. - Updated component resolution to use `role` instead of `key` for group components, improving clarity. - Adjusted content resolution to return the original contents when none are provided, ensuring expected behavior. - Modified tests to reflect changes in component key handling and ensure accurate rendering of survey items.
- Introduced a new `parseCQM` function to parse text with various formatting options including bold, underline, primary, and italic. - Created a new interface `CQMPart` to define the structure of parsed text parts. - Added comprehensive tests for the `parseCQM` function to validate parsing of plain text, formatted text, mixed content, nested formatting, and edge cases. - Updated `utils.ts` to remove an unused import, streamlining the codebase.
…nts and tests - Updated content type in survey examples, legacy conversion, and tests to use 'plain' instead of 'simple' for consistency. - Modified the CQM parser to replace the 'primary' boolean with an optional 'textColor' property, allowing for 'primary' and 'accent' color handling. - Enhanced tests to validate the new content type and text color features, ensuring comprehensive coverage of formatting scenarios.
- Introduced CURRENT_SURVEY_SCHEMA constant for consistent schema reference across the codebase. - Updated survey JSON parsing tests to validate error handling for unsupported schemas and missing survey definitions. - Refactored Survey and JsonSurvey classes to improve schema validation and ensure required fields are checked during JSON parsing.
- Introduced SurveyItemKey and ItemComponentKey classes to manage hierarchical keys for survey items and components. - Implemented validation to prevent invalid keys containing dots and ensure proper parent-child relationships. - Added extensive unit tests covering various scenarios, including root and nested keys, error handling, and edge cases. - Refactored existing SurveyItemKey implementation for improved structure and functionality. - Updated imports in survey-item.ts to reflect the new key structure.
…ding tests - Introduced the SurveyEditorUndoRedo class to manage undo and redo operations for survey state changes. - Implemented memory management features to limit history size and track memory usage. - Added comprehensive tests for various scenarios including commit, undo, redo, and memory management. - Refactored utils.ts to include a structuredCloneMethod for deep cloning objects. - Commented out the pickRandomListItem function for future implementation.
- Introduced the SurveyEditor class to facilitate editing and managing survey items, including adding, removing, and updating items. - Implemented undo/redo functionality to track changes and allow reverting to previous states. - Enhanced survey item structure to support translations and dynamic values. - Added comprehensive tests for the SurveyEditor class to ensure functionality and reliability. - Removed the deprecated SurveyItemEditor class to streamline the codebase.
- Changed survey definition to a new structure using surveyItems for better organization and access. - Updated tests to validate the new surveyItems format and ensure proper error handling for missing fields. - Enhanced translation handling for display items within the survey structure.
- Introduced new methods for deleting components from survey items, including handling translations and display conditions. - Implemented the ComponentEditor class to streamline component deletion processes. - Added comprehensive tests for deleting single choice options, ensuring proper handling of translations and undo/redo functionality. - Refactored existing survey item classes to support component deletion and maintain data integrity. - Removed the deprecated engine.ts file to clean up the codebase.
- Introduced new JsonSurveyResponse and JsonSurveyItemResponse interfaces for improved JSON serialization. - Updated SurveyResponse and SurveyItemResponse classes to support new response structures and serialization methods. - Refactored ResponseItem and its subclasses to streamline response handling and JSON conversion. - Enhanced type definitions for better clarity and maintainability. - Removed deprecated response handling methods to clean up the codebase.
…s in root item handling - Modified expectations for isRoot and parentFullKey properties in tests to align with updated logic. - Ensured that root items are correctly identified and that parentFullKey is undefined for root items.
- Implemented methods for setting and getting display conditions, including support for root and component-specific conditions. - Enhanced the handling of template values and validations within the SurveyItemEditor. - Added unit tests to validate the functionality of display conditions, ensuring correct behavior for setting, retrieving, and removing conditions. - Improved the cloning mechanism for expressions to maintain integrity when conditions are set or retrieved.
- Updated validation and display condition logging to use space instead of a dot for better readability in warning messages. - Enhanced the cloning mechanism in the Expression class to throw an error if cloning fails, ensuring better error handling. - Adjusted the handling of item keys in survey item JSON parsing to use the full key instead of the parent key, improving data integrity. - Introduced new methods in the ComponentEditor for managing display and disable conditions, enhancing component functionality.
…improved clarity and maintainability. This cleanup enhances the overall readability of the engine's codebase.
- Introduced `in_range`, `sum`, `min`, and `max` functions to the expression evaluator, allowing for more complex calculations and range checks. - Implemented corresponding expression editors for these functions to facilitate their use in the expression editor. - Updated the `ExpressionEvaluator` class to handle the new functions, ensuring proper evaluation and error handling for argument counts and types. - Added comprehensive unit tests to validate the functionality of the new expressions, covering various scenarios including edge cases.
…ve argument validation - Updated the `eval` method to accept `undefined` expressions, returning `undefined` when encountered. - Improved argument handling in various evaluation functions to gracefully manage `undefined` values, ensuring robust evaluation and error handling. - Refactored code to eliminate forced non-null assertions, enhancing type safety and readability.
Expression editor concept
- Added support for a new template value type `Date2String` to convert date expressions into formatted strings. - Updated the evaluation logic in `SurveyEngineCore` to format dates according to specified patterns. - Introduced a new test case to validate the correct handling of the new date template value in response handling tests.
…nitions - Deleted the old `SurveyContext` and `SurveyContextDef` interfaces from `context.ts`. - Updated imports in various files to reference the new context definitions from `survey/utils/context.ts`. - Adjusted the `SurveyEngineCore` to initialize the context with a default locale and removed unused locale handling. - Cleaned up survey-related files by removing references to the deprecated context rules.
…nitions - Deleted the old `SurveyContext` and `SurveyContextDef` interfaces from `context.ts`. - Updated imports in various files to reference the new context definitions from `survey/utils/context.ts`. - Adjusted the `SurveyEngineCore` to initialize the context with a default locale and removed unused locale handling. - Cleaned up survey-related files by removing references to the deprecated context rules.
- Added `ContextVariableType` enum to define various context types. - Updated `JsonContextVariableExpression` and `ContextVariableExpression` to include `contextType`, `key`, `method`, and `arguments`. - Modified tests to accommodate the new context variable structure, ensuring proper parsing and evaluation of context variables. - Enhanced `ExpressionEvaluator` to utilize the new survey context structure for improved expression evaluation.
- Introduced context variable expressions, allowing for dynamic evaluation of locale, participant flags, custom values, and custom expressions. - Updated the ExpressionEvaluator to handle different return types for participant flags and custom values, including string, number, boolean, and date. - Added new expression editors for context variables, enhancing the expression editor's capabilities. - Refactored related classes and interfaces to accommodate the new context variable structure, ensuring robust evaluation and type safety. - Improved unit tests to validate the functionality of the new context variable expressions and their integration within the expression evaluation framework.
…ates - Added functionality to update the locale in SurveyEngineCore when the context is updated, ensuring that locale-dependent expressions are re-evaluated correctly. - This change enhances the dynamic handling of locale changes within the survey engine, improving user experience and expression accuracy.
Feat: Survey context and expressions for it
…emoval - Enhanced the `onItemDeleted` method to remove all translations for an item and its children. - Introduced a new test case to verify that deleting a group also deletes all associated child item translations while ensuring unrelated items remain intact.
- Introduced the `onItemKeyChanged` method in `SurveyTranslations` to rename item keys while preserving translations across multiple locales. - Added tests to verify the renaming process, ensuring that translations are correctly transferred to the new key and that unrelated items remain unaffected. - Included edge case handling for renaming non-existent keys and overwriting existing keys, enhancing the robustness of the translation management system.
- Implemented the `onComponentKeyChanged` method in `SurveyTranslations` to facilitate renaming component keys within items, ensuring that translations are preserved across all locales. - Added comprehensive test cases to validate the renaming process, including scenarios for handling non-existent keys, overwriting existing keys, and ensuring that unrelated items and components remain unaffected. - Enhanced the robustness of the translation management system by addressing edge cases and verifying the integrity of translations during key changes.
- Implemented `getReferenceUsages` method in the `Survey` class to retrieve all reference usages for survey items, with optional filtering by item key. - Added `findInvalidReferenceUsages` method to identify and return invalid references that do not exist in the response value references. - Enhanced `SurveyItem` class to include `getReferenceUsages` method, capturing usages from display conditions, template values, disabled conditions, and validations. - Introduced `ReferenceUsage` interface and `ReferenceUsageType` enum to standardize reference usage tracking across the survey. - Added comprehensive tests to validate the functionality of reference usage tracking and invalid reference detection.
- Introduced a new test suite for the `onItemKeyChanged` method in the `SurveyEditor`, covering various scenarios including simple item key changes, nested group key changes, and updates to component parent keys. - Implemented tests to ensure that translations, display conditions, template values, and validation references are correctly updated when item keys are changed. - Added error handling tests to verify that attempts to rename to existing keys or change non-existent items are properly managed. - Enhanced the overall test coverage for item key management, ensuring robust functionality and reliability in the survey editor.
…ng and tests - Enhanced the `moveItem` method in `SurveyEditor` to support moving items between different parents, including validation checks for non-existent items, target parent existence, and group type requirements. - Added tests to cover various scenarios for moving items, including error cases for moving to non-existent parents, circular references, and moving items to themselves. - Implemented functionality to update item keys when moved, ensuring that all references are correctly maintained. - Verified that moving items updates the parent items' arrays and handles nested children appropriately. - Improved overall robustness of item management within the survey editor.
- Implemented the `getSiblingKeys` method in the `SurveyItemEditor` class to retrieve sibling items based on the current item's parent key, excluding itself. - Added a comprehensive test suite for `getSiblingKeys`, covering scenarios with no siblings, multiple siblings, and sibling items across different parent groups. - Ensured that the method correctly handles nested survey structures and verifies the properties of returned sibling keys. - Enhanced overall test coverage for item management within the survey editor.
… tests - Added the `changeItemKey` method to the `SurveyItemEditor` class, allowing for the renaming of items while enforcing validation rules such as preventing keys with dots and ensuring no sibling items share the same key. - Updated the internal reference to the current item after a key change, ensuring consistency in item management. - Introduced a new test suite for the `changeItemKey` method, covering various scenarios including successful key changes, error handling for existing sibling keys, and validation against invalid key formats. - Enhanced overall test coverage for item key management within the survey editor, ensuring robust functionality and reliability.
- Introduced private methods for key validation and computation of full and parent keys, enhancing code clarity and maintainability. - Updated the `setParentFullKey` and `setKey` methods to utilize the new computation methods, ensuring consistent key management. - Added validation to prevent keys from containing dots, improving data integrity. - Enhanced the `ItemComponentKey` class with new methods for setting component and parent component keys, streamlining key assignment processes.
- Updated the response configuration in various components and tests to replace 'options' with 'items', enhancing consistency across the codebase. - Adjusted related tests to reflect the changes in property names, ensuring that all references to response items are correctly updated. - Improved overall clarity and maintainability of the code by standardizing terminology used for response options.
Reference handling
- Introduced new tests for enhanced undo/redo capabilities in the SurveyEditor, including methods for jumping to specific history indices and validating navigation with uncommitted changes. - Exposed the undo/redo instance directly in the SurveyEditor, allowing for easier access and manipulation of the undo/redo history. - Updated the SurveyEditor class to support jumping to specific indices in the history, improving user experience during item management. - Enhanced the SurveyEditorUndoRedo class with comprehensive history tracking, including metadata for each history entry and methods for jumping to indices with validation. - Improved overall test coverage for undo/redo functionality, ensuring robust handling of various scenarios and edge cases.
- Implemented `toJSON` and `fromJSON` methods in the SurveyEditorUndoRedo class to enable serialization and restoration of the undo/redo state. - Enhanced error handling for invalid JSON data during restoration, ensuring robust validation of history, current index, and configuration. - Added comprehensive tests for JSON serialization and deserialization, covering various scenarios including state restoration, memory usage, and error handling. - Improved overall test coverage for undo/redo functionality, ensuring reliable state management and integrity during serialization processes.
- Implemented `toJson` and `fromJson` methods in the SurveyEditor class to enable serialization and restoration of the editor state, including survey data and undo/redo history. - Enhanced error handling for invalid JSON data during restoration, ensuring robust validation of required fields and version compatibility. - Added comprehensive tests for serialization and deserialization, covering various scenarios including state preservation, uncommitted changes, and error handling. - Improved overall test coverage for the SurveyEditor, ensuring reliable state management and integrity during serialization processes.
- Introduced a new event system in the SurveyEditor to handle changes with a `survey-changed` event, allowing for better tracking of modifications and commits. - Added methods for registering, deregistering, and clearing event listeners, enhancing the flexibility of the editor's event management. - Updated the commit and modification methods to emit events with relevant data, including uncommitted changes and commit descriptions. - Enhanced tests to cover event listener functionality, ensuring correct event emission for various operations such as adding, removing, and renaming items. - Improved error handling for listener execution, ensuring robustness in the event system.
- Introduced the `updateItemMetadata` method in the `SurveyItemEditor` class to allow updating of item metadata with commit tracking. - Enhanced the `GenericSurveyItemEditor` class to extend the `SurveyItemEditor`, providing a base for type-specific editors. - Updated tests in `survey-editor.test.ts` to include handling of invalid JSON data and ensure robust error handling for metadata and undo/redo operations. - Improved overall test coverage for the SurveyEditor, focusing on metadata management and error scenarios.
- Introduced the `getRenderedSurveyItem` method to retrieve a specific rendered survey item by its key from the rendered survey tree. - Enhanced the functionality of the SurveyEngineCore class, improving item access within the survey structure. - No changes to tests were made in this commit.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rework survey types including new class based models also for editing surveys in more explicit and type safe way.