-
Notifications
You must be signed in to change notification settings - Fork 8
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
Get collection metadata blocks #141
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e100f8e
Added: GetCollectionMetadataBlocks use case (Pending data access logic)
GPortas 23f9a4f
Changed: GetCollectionMetadataBlocks subdomain
GPortas db9fe30
Added: getCollectionMetadataBlocks API access logic
GPortas 23f0180
Changed: target dataverse image
GPortas 5955617
Added: getCollectionMetadataBlocks repository unit tests
GPortas 377e41f
Added: extended MetadataFieldInfo model
GPortas 0033085
Added: missing exports for new MetadataBlockInfo enums
GPortas 2d54907
Added: getCollectionMetadataBlocks functional tests and tweaks
GPortas e47a6ad
Merge branch 'develop' of github.com:IQSS/dataverse-client-javascript…
GPortas 153a56a
Changed: restored env vars
GPortas 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 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { Collection } from '../models/Collection' | ||
|
||
export interface ICollectionsRepository { | ||
getCollection(collectionIdOrAlias: number | string): Promise<Collection> | ||
} |
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
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
30 changes: 30 additions & 0 deletions
30
src/metadataBlocks/domain/useCases/GetCollectionMetadataBlocks.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,30 @@ | ||
import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
import { MetadataBlock } from '../..' | ||
import { ROOT_COLLECTION_ALIAS } from '../../../collections/domain/models/Collection' | ||
import { IMetadataBlocksRepository } from '../repositories/IMetadataBlocksRepository' | ||
|
||
export class GetCollectionMetadataBlocks implements UseCase<MetadataBlock[]> { | ||
private metadataBlocksRepository: IMetadataBlocksRepository | ||
|
||
constructor(metadataBlocksRepository: IMetadataBlocksRepository) { | ||
this.metadataBlocksRepository = metadataBlocksRepository | ||
} | ||
|
||
/** | ||
* Returns a MetadataBlock array containing the metadata blocks from the requested collection. | ||
* | ||
* @param {number | string} [collectionIdOrAlias = 'root'] - A generic collection identifier, which can be either a string (for queries by CollectionAlias), or a number (for queries by CollectionId) | ||
* If this parameter is not set, the default value is: 'root' | ||
* @param {boolean} [onlyDisplayedOnCreate=false] - Indicates whether or not to return only the metadata blocks that are displayed on dataset creation. The default value is false. | ||
* @returns {Promise<MetadataBlock[]>} | ||
*/ | ||
async execute( | ||
collectionIdOrAlias: number | string = ROOT_COLLECTION_ALIAS, | ||
onlyDisplayedOnCreate = false | ||
): Promise<MetadataBlock[]> { | ||
return await this.metadataBlocksRepository.getCollectionMetadataBlocks( | ||
collectionIdOrAlias, | ||
onlyDisplayedOnCreate | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import { GetMetadataBlockByName } from './domain/useCases/GetMetadataBlockByName' | ||
import { MetadataBlocksRepository } from './infra/repositories/MetadataBlocksRepository' | ||
import { GetCollectionMetadataBlocks } from './domain/useCases/GetCollectionMetadataBlocks' | ||
|
||
const metadataBlocksRepository = new MetadataBlocksRepository() | ||
|
||
const getMetadataBlockByName = new GetMetadataBlockByName(metadataBlocksRepository) | ||
const getCollectionMetadataBlocks = new GetCollectionMetadataBlocks(metadataBlocksRepository) | ||
|
||
export { getMetadataBlockByName } | ||
export { MetadataBlock, MetadataFieldInfo } from './domain/models/MetadataBlock' | ||
export { getMetadataBlockByName, getCollectionMetadataBlocks } | ||
export { | ||
MetadataBlock, | ||
MetadataFieldInfo, | ||
MetadataFieldType, | ||
MetadataFieldTypeClass | ||
} from './domain/models/MetadataBlock' |
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
7 changes: 7 additions & 0 deletions
7
src/metadataBlocks/infra/repositories/transformers/MetadataBlockPayload.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,7 @@ | ||
export interface MetadataBlockPayload { | ||
id: number | ||
name: string | ||
displayName: string | ||
displayOnCreate: boolean | ||
fields: Record<string, unknown> | ||
} |
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
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.
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.
To adhere to our naming conventions, should we consider renaming the method to
GetMetadataBlocksByCollection
? Given that we are in theMetadataBlocks
domain, this name explicitly reflects that we're retrieving metadata blocks.Additionally, this naming strategy enhances usability in IDEs. When developers start typing
getMetadataBlocks
, the IDE can autocomplete with all related fetching methods likebyName
,byCollection
, etc. This could streamline finding the right method compared to starting withgetCollection
, which might not immediately suggest that it pertains to metadata blocks.Alternatively, we could consider moving this use case to the collection domain. In that context, naming the method
getCollectionMetadataBlocks
would be more semantically appropriate, as it clearly indicates that the method retrieves metadata blocks specific to collections.QA police 🚨 😆
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.
I like the naming convention you describe, and makes sense to me.
In any case, the naming convention that we have mostly followed so far in the package is the one I have used. If you notice, it is used in almost all use cases that return a property "by a parameter".
For example, see: GetDatasetFiles, GetFileCitation, GetFileDataTables, etc.
To be consistent with the naming convention, we must rename all or none. We can create a separate issue for general renaming and make all use cases follow the same naming strategy (And mention this requirement in the dev guidelines). Let me know what you think. @MellyGray
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.
It's fine for me to create a separate issue.
However, based on the use cases you describe, I don't see the same problem with
GetFileCitation
andGetFileDataTables
. They are in the file domain, and as they are attributes of the file, they sound fine, I wouldn't change those.In the case of
GetDatasetFiles
, it might be more similar to the metadatablock case, because you are in the files domain and you want some files. However, you have to start typinggetDataset
, which might make more sense asgetFilesByDatasetId
or simplygetFiles
, as the necessary datasetId could be specified through the method parameters.In any case, I think it makes sense to choose a naming convention that aligns well with IDE autocomplete and to create a separate issue for that