-
Notifications
You must be signed in to change notification settings - Fork 3
New export option: Tolerate Missing References #36
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
New export option: Tolerate Missing References #36
Conversation
- Add optional tolerateMissingReferences parameter to ExportConfig - Update export transforms to conditionally handle missing items/assets - Missing references are filtered out when tolerateMissingReferences is true - Throw errors for missing references when tolerateMissingReferences is false (default) - Add comprehensive test coverage with 22 new test cases - Support for asset, modular_content, subpages, and rich_text elements - Backward compatible with default value of false
- Replace tolerateMissingReferences boolean field with exportOptions object in ExportContext - Update all references to use context.exportOptions.tolerateMissingReferences - Improves consistency and extensibility for future export options
|
Thanks for the PR! The idea behind this makes sense, so I'll look into this and test it a bit more. I'll likely push a few minor changes, but you can expect this feature to be included within next release ;) |
|
Any changes are very welcome. Let me know if you have any questions. The main issue this is solving is for us specifically is trying to copy items from a Prod env to a Dev env, but the Prod env often has deleted items and the references to the deleted items were never cleaned up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for a skipMissingReferences parameter that allows exports and migrations to continue when referenced items or assets are missing, instead of throwing errors and halting the process. The parameter defaults to false to maintain backward compatibility.
Key changes:
- Introduces new error classes (
MissingItemError,MissingAssetError) with structured error types - Updates export transforms to handle missing references by either throwing errors or filtering them out
- Adds discriminated union types for asset/item states with
exists,doesNotExists, andskipstates - Implements placeholder utility for missing references in rich text content
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/export-transforms.test.ts | Comprehensive test coverage for all export transform element types with missing reference scenarios |
| lib/export/export.models.ts | Added ExportContextOptions interface and skipMissingReferences configuration property |
| lib/export/context/export-context-fetcher.ts | Updated state handling to use discriminated unions with skip state support |
| lib/translation/transforms/export-transforms.ts | Modified transforms to handle missing references using pattern matching and filtering |
| lib/translation/helpers/export-placeholder.utils.ts | New utility for generating placeholder text for missing references |
| lib/toolkit/migrate.ts | Added skipMissingReferences option to migration source configuration |
| lib/node/cli/commands.ts | Added CLI argument definition for skipMissingReferences parameter |
| lib/node/cli/actions/export-action.ts | Integrated skipMissingReferences parameter in export action |
| lib/node/cli/actions/migrate-action.ts | Integrated skipMissingReferences parameter in migrate action |
| lib/core/models/error.models.ts | New error class hierarchy with typed error categories |
| lib/core/models/core.models.ts | Refactored state types to use discriminated unions with data property |
| scripts/test/test-export.ts | Test script updated to use new skipMissingReferences option |
| scripts/test/import-report.json | Test result showing successful import with no errors |
| README.md | Documentation updated with new configuration parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Motivation
Adds support for
tolerateMissingReferencesparameter to allow exports and migrations to continue when referenced items or assets are missing, instead of throwing errors and halting the process.This is useful in scenarios where:
The parameter defaults to
falseto maintain backward compatibility and existing error-throwing behavior.Checklist
How to test
Manual CLI Testing:
Build the project:
npm run buildTest export with the new parameter:
node dist/node/cli/app.js export --help node dist/node/cli/app.js migrate --helpProgrammatic API Testing: