-
Notifications
You must be signed in to change notification settings - Fork 1
Implement translations from old event types to new ones #99
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
Open
radovanjorgic
wants to merge
17
commits into
main
Choose a base branch
from
rado/event-renamings-poc
base: main
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.
Open
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a82bb0b
Event renamings with normalization functions
radovanjorgic 165c9fd
Removed redundant default workers and added default paths for workers…
gasperzgonec bc0ddc5
Updated deprecated adapter to ensure compatibility.
gasperzgonec 5c491c1
Apply suggestions from code review
gasperzgonec b1210f4
Deduplicated the strings used for keys
gasperzgonec a5d2244
Ran a linter and prettier
gasperzgonec c8a0354
Satisfied linter and fixed backward-compatibility tests.
gasperzgonec 630d0bf
Fixed nits.
gasperzgonec de2c3cd
Renamed remaining normalizations to translations.
gasperzgonec 50febc8
Removed default workers, added a TODO and renamed 'normalized' to 'tr…
gasperzgonec a8ceca9
Fixed the path overrides for getWorkerPath.
gasperzgonec ef82227
chore: release v1.12.3-beta.0
d307312
Removed 'node_modules' skipping.
gasperzgonec bf268cd
chore: release v1.12.3-beta.1
89312dc
Merge branch 'main' into rado/event-renamings-poc
gasperzgonec e1120ae
Removed the CallStack traversal and changed for user-provided path.
gasperzgonec 51a0f03
Fixed translations and changed `GetWorkerPathInterface`.
gasperzgonec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| import { EventType, ExtractorEventType } from '../types/extraction'; | ||
| import { LoaderEventType } from '../types/loading'; | ||
|
|
||
| /** | ||
| * Maps old incoming event type strings to new EventType enum values. | ||
| * This ensures backwards compatibility when the platform sends old event types. | ||
| * @param eventTypeString The raw event type string from the platform | ||
| * @returns The normalized EventType enum value | ||
| */ | ||
| export function translateIncomingEventType(eventTypeString: string): EventType { | ||
| // Create a reverse mapping from OLD string values to NEW enum member names | ||
| const eventTypeMap: Record<string, EventType> = { | ||
| // Old extraction event types from platform -> New enum members | ||
| [EventType.ExtractionExternalSyncUnitsStart]: | ||
| EventType.StartExtractingExternalSyncUnits, | ||
| [EventType.ExtractionMetadataStart]: EventType.StartExtractingMetadata, | ||
| [EventType.ExtractionDataStart]: EventType.StartExtractingData, | ||
| [EventType.ExtractionDataContinue]: EventType.ContinueExtractingData, | ||
| [EventType.ExtractionDataDelete]: EventType.StartDeletingExtractorState, | ||
| [EventType.ExtractionAttachmentsStart]: | ||
| EventType.StartExtractingAttachments, | ||
| [EventType.ExtractionAttachmentsContinue]: | ||
| EventType.ContinueExtractingAttachments, | ||
| [EventType.ExtractionAttachmentsDelete]: | ||
| EventType.StartDeletingExtractorAttachmentsState, | ||
|
|
||
| // New extraction event types (already correct, map to new enum members) | ||
| [EventType.StartExtractingExternalSyncUnits]: | ||
| EventType.StartExtractingExternalSyncUnits, | ||
| [EventType.StartExtractingMetadata]: EventType.StartExtractingMetadata, | ||
| [EventType.StartExtractingData]: EventType.StartExtractingData, | ||
| [EventType.ContinueExtractingData]: EventType.ContinueExtractingData, | ||
| [EventType.StartDeletingExtractorState]: | ||
| EventType.StartDeletingExtractorState, | ||
| [EventType.StartExtractingAttachments]: | ||
| EventType.StartExtractingAttachments, | ||
| [EventType.ContinueExtractingAttachments]: | ||
| EventType.ContinueExtractingAttachments, | ||
| [EventType.StartDeletingExtractorAttachmentsState]: | ||
| EventType.StartDeletingExtractorAttachmentsState, | ||
|
|
||
| // Loading events | ||
| [EventType.StartLoadingData]: EventType.StartLoadingData, | ||
| [EventType.ContinueLoadingData]: EventType.ContinueLoadingData, | ||
| [EventType.StartLoadingAttachments]: EventType.StartLoadingAttachments, | ||
| [EventType.ContinueLoadingAttachments]: | ||
| EventType.ContinueLoadingAttachments, | ||
| [EventType.StartDeletingLoaderState]: EventType.StartDeletingLoaderState, | ||
| [EventType.StartDeletingLoaderAttachmentState]: | ||
| EventType.StartDeletingLoaderAttachmentState, | ||
|
|
||
| // Unknown | ||
| [EventType.UnknownEventType]: EventType.UnknownEventType, | ||
| }; | ||
|
|
||
| const normalized = eventTypeMap[eventTypeString]; | ||
| if (!normalized) { | ||
| console.warn( | ||
| `Unknown event type received: ${eventTypeString}. This may indicate a new event type or a typo.` | ||
| ); | ||
| // Return the original string cast as EventType as a fallback | ||
| return eventTypeString as EventType; | ||
| } | ||
|
|
||
| return normalized; | ||
| } | ||
|
|
||
| /** | ||
| * Normalizes ExtractorEventType enum values by converting old enum members to new ones. | ||
| * Old enum members are deprecated and should be replaced with new ones. | ||
| */ | ||
| export function translateExtractorEventType( | ||
| eventType: ExtractorEventType | ||
| ): ExtractorEventType { | ||
| // Map old enum members to new enum members | ||
| const stringValue = eventType as string; | ||
|
|
||
| const mapping: Record<string, ExtractorEventType> = { | ||
| // Old string values -> New enum members | ||
| [ExtractorEventType.ExtractionExternalSyncUnitsDone]: | ||
| ExtractorEventType.ExternalSyncUnitExtractionDone, | ||
| [ExtractorEventType.ExtractionExternalSyncUnitsError]: | ||
| ExtractorEventType.ExternalSyncUnitExtractionError, | ||
| [ExtractorEventType.ExtractionMetadataDone]: | ||
| ExtractorEventType.MetadataExtractionDone, | ||
| [ExtractorEventType.ExtractionMetadataError]: | ||
| ExtractorEventType.MetadataExtractionError, | ||
| [ExtractorEventType.ExtractionDataProgress]: | ||
| ExtractorEventType.DataExtractionProgress, | ||
| [ExtractorEventType.ExtractionDataDelay]: | ||
| ExtractorEventType.DataExtractionDelayed, | ||
| [ExtractorEventType.ExtractionDataDone]: | ||
| ExtractorEventType.DataExtractionDone, | ||
| [ExtractorEventType.ExtractionDataError]: | ||
| ExtractorEventType.DataExtractionError, | ||
| [ExtractorEventType.ExtractionDataDeleteDone]: | ||
| ExtractorEventType.ExtractorStateDeletionDone, | ||
| [ExtractorEventType.ExtractionDataDeleteError]: | ||
| ExtractorEventType.ExtractorStateDeletionError, | ||
| [ExtractorEventType.ExtractionAttachmentsProgress]: | ||
| ExtractorEventType.AttachmentExtractionProgress, | ||
| [ExtractorEventType.ExtractionAttachmentsDelay]: | ||
| ExtractorEventType.AttachmentExtractionDelayed, | ||
| [ExtractorEventType.ExtractionAttachmentsDone]: | ||
| ExtractorEventType.AttachmentExtractionDone, | ||
| [ExtractorEventType.ExtractionAttachmentsError]: | ||
| ExtractorEventType.AttachmentExtractionError, | ||
| [ExtractorEventType.ExtractionAttachmentsDeleteDone]: | ||
| ExtractorEventType.ExtractorAttachmentsStateDeletionDone, | ||
| [ExtractorEventType.ExtractionAttachmentsDeleteError]: | ||
| ExtractorEventType.ExtractorAttachmentsStateDeletionError, | ||
| }; | ||
|
|
||
| // If there's a mapping, use it; otherwise return original (already new) | ||
| return mapping[stringValue] ?? eventType; | ||
| } | ||
|
|
||
| /** | ||
| * Normalizes LoaderEventType enum values by converting old enum members to new ones. | ||
| * Old enum members are deprecated and should be replaced with new ones. | ||
| */ | ||
| export function translateLoaderEventType( | ||
| eventType: LoaderEventType | ||
| ): LoaderEventType { | ||
| // Map old enum members to new enum members | ||
| const stringValue = eventType as string; | ||
|
|
||
| const mapping: Record<string, LoaderEventType> = { | ||
| // Old string values -> New enum members | ||
| [LoaderEventType.DataLoadingDelay]: LoaderEventType.DataLoadingDelayed, | ||
| [LoaderEventType.AttachmentLoadingProgress]: | ||
| LoaderEventType.AttachmentsLoadingProgress, | ||
| [LoaderEventType.AttachmentLoadingDelayed]: | ||
| LoaderEventType.AttachmentsLoadingDelayed, | ||
| [LoaderEventType.AttachmentLoadingDone]: | ||
| LoaderEventType.AttachmentsLoadingDone, | ||
| [LoaderEventType.AttachmentLoadingError]: | ||
| LoaderEventType.AttachmentsLoadingError, | ||
| }; | ||
|
|
||
| // If there's a mapping, use it; otherwise return original (already new) | ||
| return mapping[stringValue] ?? eventType; | ||
| } | ||
|
|
||
| /** | ||
| * Normalizes any outgoing event type (Extractor or Loader) to ensure new event types are used. | ||
| */ | ||
| export function translateOutgoingEventType( | ||
| eventType: ExtractorEventType | LoaderEventType | ||
| ): ExtractorEventType | LoaderEventType { | ||
| // Check if it's an ExtractorEventType by checking if the value exists in ExtractorEventType | ||
| if ( | ||
| Object.values(ExtractorEventType).includes(eventType as ExtractorEventType) | ||
| ) { | ||
| return translateExtractorEventType(eventType as ExtractorEventType); | ||
| } | ||
| // Otherwise treat as LoaderEventType | ||
| if (Object.values(LoaderEventType).includes(eventType as LoaderEventType)) { | ||
| return translateLoaderEventType(eventType as LoaderEventType); | ||
| } | ||
| // If neither, return as-is | ||
| return eventType; | ||
| } | ||
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
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
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
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
Oops, something went wrong.
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.
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.
Use translated instead normalized all over the code