-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add getVersionDiff to DatasetRepository interface
- Loading branch information
1 parent
19fe1c8
commit 91d3013
Showing
9 changed files
with
215 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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,48 @@ | ||
export interface DatasetVersionDiff { | ||
oldVersion: VersionSummary | ||
newVersion: VersionSummary | ||
metadataChanges?: MetadataBlockDiff[] | ||
filesAdded?: FileSummary[] | ||
filesRemoved?: FileSummary[] | ||
fileChanges?: FileDiff[] | ||
filesReplaced?: FileReplacement[] | ||
termsOfAccess?: FieldDiff[] | ||
} | ||
|
||
export interface FileSummary { | ||
fileName: string | ||
MD5: string | ||
type: string | ||
fileId: number | ||
filePath: string | ||
description: string | ||
isRestricted: boolean | ||
tags: string[] | ||
categories: string[] | ||
} | ||
|
||
export interface VersionSummary { | ||
versionNumber: string | ||
lastUpdatedDate: string | ||
} | ||
export interface MetadataBlockDiff { | ||
blockName: string | ||
changed: FieldDiff[] | ||
} | ||
|
||
export interface FileDiff { | ||
fileName: string | ||
md5: string | ||
fileId: number | ||
changed: FieldDiff[] | ||
} | ||
|
||
export interface FileReplacement { | ||
oldFile: FileSummary | ||
newFile: FileSummary | ||
} | ||
export interface FieldDiff { | ||
fieldName: string | ||
oldValue: string | ||
newValue: string | ||
} |
This file contains 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 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,15 @@ | ||
import { DatasetRepository } from '../repositories/DatasetRepository' | ||
import { DatasetVersionDiff } from '../models/DatasetVersionDiff' | ||
|
||
export async function getDatasetVersionDiff( | ||
datasetRepository: DatasetRepository, | ||
persistentId: string, | ||
oldVersion: string, | ||
newVersion: string | ||
): Promise<DatasetVersionDiff | undefined> { | ||
return datasetRepository | ||
.getVersionDiff(persistentId, oldVersion, newVersion) | ||
.catch((error: Error) => { | ||
throw new Error(error.message) | ||
}) | ||
} |
This file contains 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 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 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 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
32 changes: 32 additions & 0 deletions
32
tests/component/dataset/domain/models/DatasetVersionDiffMother.ts
This file contains 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,32 @@ | ||
import { faker } from '@faker-js/faker' | ||
import { DatasetVersionDiff } from '../../../../../src/dataset/domain/models/DatasetVersionDiff' | ||
|
||
export class DatasetVersionDiffMother { | ||
static create(props?: Partial<DatasetVersionDiff>): DatasetVersionDiff { | ||
const datasetVersionDiff = { | ||
persistentId: faker.datatype.uuid(), | ||
oldVersion: { | ||
versionNumber: '1.0', | ||
lastUpdatedDate: '2023-05-15T08:21:03Z' | ||
}, | ||
newVersion: { | ||
versionNumber: '1.1', | ||
lastUpdatedDate: '2023-05-20T08:21:03Z' | ||
}, | ||
metadataBlockDiffs: [ | ||
{ | ||
blockName: 'citation', | ||
changed: [ | ||
{ | ||
fieldName: 'title', | ||
oldValue: 'Old Title', | ||
newValue: 'New Title' | ||
} | ||
] | ||
} | ||
], | ||
...props | ||
} | ||
return datasetVersionDiff | ||
} | ||
} |
This file contains 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