-
Notifications
You must be signed in to change notification settings - Fork 10
Feat: use case of getFileVersionSummaries #299
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
Merged
ofahimIQSS
merged 9 commits into
develop
from
297-file-page-file-version-summary-use-case
May 15, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4850ee4
feat: use case of getFileVersionSummaries
ChengShi-1 3eab089
fix: update tests error (uncomment until api is ready)
ChengShi-1 409a28b
fix: update tests error (uncomment until api is ready)
ChengShi-1 526e1cc
merged with dev branch
ChengShi-1 4d5d58c
feat: add a transformer to better arrange the data model
ChengShi-1 1585568
fix: restrict file access
ChengShi-1 e1f6279
fix: testcase
ChengShi-1 68024d6
fix: nonexistentID is existed somehow
ChengShi-1 13091da
fix: naming of transformer
ChengShi-1 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 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,27 @@ | ||
| import { DatasetVersionState } from '../../../datasets/domain/models/Dataset' | ||
|
|
||
| export interface FileVersionSummaryInfo { | ||
| datasetVersion: string | ||
| contributors?: string | ||
| publishedDate?: string | ||
| fileDifferenceSummary?: FileDifferenceSummary | ||
| versionState?: DatasetVersionState | ||
| datafileId: number | ||
| persistentId?: string | ||
| versionNote?: string | ||
| } | ||
|
|
||
| export type FileDifferenceSummary = { | ||
| file?: FileChangeType | ||
| fileAccess?: 'Restricted' | 'Unrestricted' | ||
| fileMetadata?: FileMetadataChange[] | ||
| deaccessionedReason?: string | ||
| fileTags?: { [key in FileChangeType]?: number } | ||
| } | ||
|
|
||
| export type FileChangeType = 'Added' | 'Deleted' | 'Replaced' | 'Changed' | ||
|
|
||
| export interface FileMetadataChange { | ||
| name: string | ||
| action: FileChangeType | ||
| } |
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,21 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { FileVersionSummaryInfo } from '../models/FileVersionSummaryInfo' | ||
| import { IFilesRepository } from '../repositories/IFilesRepository' | ||
|
|
||
| export class GetFileVersionSummaries implements UseCase<FileVersionSummaryInfo[]> { | ||
| private filesRepository: IFilesRepository | ||
|
|
||
| constructor(filesRepository: IFilesRepository) { | ||
| this.filesRepository = filesRepository | ||
| } | ||
|
|
||
| /** | ||
| * Returns a list of versions for a given file including a summary of differences between consecutive versions | ||
| * | ||
| * @param {number | string} [fileId] - The file identifier, which can be a string (for persistent identifiers), or a number (for numeric identifiers). | ||
| * @returns {Promise<FileVersionSummaryInfo[]>} - An array of FileVersionSummaryInfo. | ||
| */ | ||
| async execute(fileId: number | string): Promise<FileVersionSummaryInfo[]> { | ||
| return await this.filesRepository.getFileVersionSummaries(fileId) | ||
| } | ||
| } |
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
57 changes: 57 additions & 0 deletions
57
src/files/infra/repositories/transformers/fileVersionSummaryInfoTransformers.ts
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,57 @@ | ||
| import { AxiosResponse } from 'axios' | ||
| import { | ||
| FileVersionSummaryInfo, | ||
| FileMetadataChange, | ||
| FileDifferenceSummary | ||
| } from '../../../domain/models/FileVersionSummaryInfo' | ||
| import { DatasetVersionState } from '../../../../datasets/domain/models/Dataset' | ||
|
|
||
| export interface FileVersionSummaryInfoPayload { | ||
| datasetVersion: string | ||
| contributors?: string | ||
| publishedDate?: string | ||
| fileDifferenceSummary?: { | ||
| file?: string | ||
| FileAccess?: string | ||
| FileMetadata?: FileMetadataChange[] | ||
| deaccessionedReason?: string | ||
| FileTags?: { | ||
| Added?: number | ||
| Deleted?: number | ||
| Changed?: number | ||
| } | ||
| } | ||
| versionState?: DatasetVersionState | ||
| datafileId: number | ||
| persistentId?: string | ||
| versionNote?: string | ||
| } | ||
|
|
||
| export const transformFileVersionSummaryInfoResponseToFileVersionSummaryInfo = ( | ||
| response: AxiosResponse | ||
| ): FileVersionSummaryInfo[] => { | ||
| const payload = response.data.data | ||
|
|
||
| return payload.map((item: FileVersionSummaryInfoPayload): FileVersionSummaryInfo => { | ||
| const summary = item.fileDifferenceSummary || {} | ||
|
|
||
| const fileDifferenceSummary: FileDifferenceSummary = { | ||
| ...(summary.file && { file: summary.file }), | ||
| ...(summary.FileAccess && { fileAccess: summary.FileAccess }), | ||
| ...(summary.FileMetadata && { fileMetadata: summary.FileMetadata }), | ||
| ...(summary.deaccessionedReason && { deaccessionedReason: summary.deaccessionedReason }), | ||
| ...(summary.FileTags && { fileTags: summary.FileTags }) | ||
| } as FileDifferenceSummary | ||
|
|
||
| return { | ||
| datasetVersion: item.datasetVersion, | ||
| contributors: item.contributors, | ||
| publishedDate: item.publishedDate, | ||
| fileDifferenceSummary: fileDifferenceSummary, | ||
| versionState: item.versionState, | ||
| datafileId: item.datafileId, | ||
| persistentId: item.persistentId, | ||
| versionNote: item.versionNote | ||
| } | ||
| }) | ||
| } |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.