-
Notifications
You must be signed in to change notification settings - Fork 10
Use Cases of Guestbooks #429
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
ChengShi-1
wants to merge
9
commits into
develop
Choose a base branch
from
424-use-cases-to-support-download-terms-of-use-and-guestbook
base: develop
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.
+1,835
−4
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c023fd5
feat: Add Guestbook and Access Repository, and their use cases accord…
ChengShi-1 1f61ab1
use other image tag for test
ChengShi-1 812dd22
fix: test failing
ChengShi-1 c3f76f8
fix: copilot reviews
ChengShi-1 bba1993
fix: update collectionId to Uppercase
ChengShi-1 4dd5c4c
feat: update use cases of guestbook and access
ChengShi-1 88fb521
chore: update usecases.md
ChengShi-1 1aa3e31
feat: add guestId to dataset
ChengShi-1 f4e6bd4
chore: changelog
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 |
|---|---|---|
|
|
@@ -123,6 +123,26 @@ The different use cases currently available in the package are classified below, | |
| - [Get External Tools](#get-external-tools) | ||
| - [Get Dataset External Tool Resolved](#get-dataset-external-tool-resolved) | ||
| - [Get File External Tool Resolved](#get-file-external-tool-resolved) | ||
| - [Guestbooks](#Guestbooks) | ||
| - [Guestbooks read use cases](#guestbooks-read-use-cases) | ||
| - [Get a Guestbook](#get-a-guestbook) | ||
| - [Get Guestbooks By Collection Id](#get-guestbooks-by-collection-id) | ||
| - [Guestbooks write use cases](#guestbooks-write-use-cases) | ||
| - [Create a Guestbook](#create-a-guestbook) | ||
| - [Set Guestbook Enabled](#set-guestbook-enabled) | ||
| - [Assign Dataset Guestbook](#assign-dataset-guestbook) | ||
| - [Remove Dataset Guestbook](#remove-dataset-guestbook) | ||
| - [Access](#Access) | ||
| - [Access read use cases](#access-read-use-cases) | ||
| - [Get Signed Datafile Download URL](#get-signed-datafile-download-url) | ||
| - [Get Signed Datafiles Download URL](#get-signed-datafiles-download-url) | ||
| - [Get Signed Dataset Download URL](#get-signed-dataset-download-url) | ||
| - [Get Signed Dataset Version Download URL](#get-signed-dataset-version-download-url) | ||
| - [Access write use cases](#access-write-use-cases) | ||
| - [Submit Guestbook For Datafile Download](#submit-guestbook-for-datafile-download) | ||
| - [Submit Guestbook For Datafiles Download](#submit-guestbook-for-datafiles-download) | ||
| - [Submit Guestbook For Dataset Download](#submit-guestbook-for-dataset-download) | ||
| - [Submit Guestbook For Dataset Version Download](#submit-guestbook-for-dataset-version-download) | ||
|
|
||
| ## Collections | ||
|
|
||
|
|
@@ -2767,3 +2787,312 @@ getFileExternalToolResolved | |
| ``` | ||
|
|
||
| _See [use case](../src/externalTools/domain/useCases/GetfileExternalToolResolved.ts) implementation_. | ||
|
|
||
| ## Guestbooks | ||
|
|
||
| ### Guestbooks Read Use Cases | ||
|
|
||
| #### Get a Guestbook | ||
|
|
||
| Returns a [Guestbook](../src/guestbooks/domain/models/Guestbook.ts) by its id. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { getGuestbook } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| const guestbookId = 123 | ||
|
|
||
| getGuestbook.execute(guestbookId).then((guestbook: Guestbook) => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/guestbooks/domain/useCases/GetGuestbook.ts) implementation_. | ||
|
|
||
| #### Get Guestbooks By Collection Id | ||
|
|
||
| Returns all [Guestbook](../src/guestbooks/domain/models/Guestbook.ts) entries available for a collection. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { getGuestbooksByCollectionId } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| const collectionIdOrAlias = 'root' | ||
|
|
||
| getGuestbooksByCollectionId.execute(collectionIdOrAlias).then((guestbooks: Guestbook[]) => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/guestbooks/domain/useCases/GetGuestbooksByCollectionId.ts) implementation_. | ||
|
|
||
| ### Guestbooks Write Use Cases | ||
|
|
||
| #### Create a Guestbook | ||
|
|
||
| Creates a guestbook on a collection using [CreateGuestbookDTO](../src/guestbooks/domain/dtos/CreateGuestbookDTO.ts). | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { createGuestbook } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| const collectionIdOrAlias = 'root' | ||
| const guestbook: CreateGuestbookDTO = { | ||
| name: 'my test guestbook', | ||
| enabled: true, | ||
| emailRequired: true, | ||
| nameRequired: true, | ||
| institutionRequired: false, | ||
| positionRequired: false, | ||
| email: 'test@gmail.com', | ||
| institution: 'Harvard University', | ||
| position: 'Researcher', | ||
| customQuestions: [ | ||
| { | ||
| question: 'Describe yourself', | ||
| required: false, | ||
| displayOrder: 1, | ||
| type: 'textarea', | ||
| hidden: false | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| createGuestbook.execute(guestbook, collectionIdOrAlias).then(() => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/guestbooks/domain/useCases/CreateGuestbook.ts) implementation_. | ||
|
|
||
| #### Set Guestbook Enabled | ||
|
|
||
| Enables or disables a guestbook in a collection. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { setGuestbookEnabled } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| const collectionIdOrAlias = 'root' | ||
| const guestbookId = 123 | ||
|
|
||
| setGuestbookEnabled.execute(collectionIdOrAlias, guestbookId, false).then(() => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/guestbooks/domain/useCases/SetGuestbookEnabled.ts) implementation_. | ||
|
|
||
| #### Assign Dataset Guestbook | ||
|
|
||
| Assigns a guestbook to a dataset using `PUT /api/datasets/{identifier}/guestbook`. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { assignDatasetGuestbook } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| const datasetIdOrPersistentId = 123 | ||
| const guestbookId = 456 | ||
|
|
||
| assignDatasetGuestbook.execute(datasetIdOrPersistentId, guestbookId).then(() => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/guestbooks/domain/useCases/AssignDatasetGuestbook.ts) implementation_. | ||
|
|
||
| #### Remove Dataset Guestbook | ||
|
|
||
| Removes the guestbook assignment for a dataset using `DELETE /api/datasets/{identifier}/guestbook`. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { removeDatasetGuestbook } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| const datasetIdOrPersistentId = 123 | ||
|
|
||
| removeDatasetGuestbook.execute(datasetIdOrPersistentId).then(() => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/guestbooks/domain/useCases/RemoveDatasetGuestbook.ts) implementation_. | ||
|
|
||
| ## Access | ||
|
|
||
| ### Access Read Use Cases | ||
|
|
||
| #### Get Signed Datafile Download URL | ||
|
|
||
| Returns a signed URL for downloading a single datafile. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { getSignedDatafileDownloadUrl } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| getSignedDatafileDownloadUrl.execute(10).then((signedUrl: string) => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/access/domain/useCases/GetSignedDatafileDownloadUrl.ts) implementation_. | ||
|
|
||
| #### Get Signed Datafiles Download URL | ||
|
|
||
| Returns a signed URL for downloading multiple datafiles. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { getSignedDatafilesDownloadUrl } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| getSignedDatafilesDownloadUrl.execute([10, 11]).then((signedUrl: string) => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/access/domain/useCases/GetSignedDatafilesDownloadUrl.ts) implementation_. | ||
|
|
||
| #### Get Signed Dataset Download URL | ||
|
|
||
| Returns a signed URL for downloading a dataset. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { getSignedDatasetDownloadUrl } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| getSignedDatasetDownloadUrl.execute(10).then((signedUrl: string) => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/access/domain/useCases/GetSignedDatasetDownloadUrl.ts) implementation_. | ||
|
|
||
| #### Get Signed Dataset Version Download URL | ||
|
|
||
| Returns a signed URL for downloading a dataset version. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { getSignedDatasetVersionDownloadUrl } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| getSignedDatasetVersionDownloadUrl.execute(10, '1.0').then((signedUrl: string) => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/access/domain/useCases/GetSignedDatasetVersionDownloadUrl.ts) implementation_. | ||
|
|
||
| ### Access Write Use Cases | ||
|
|
||
| #### Submit Guestbook For Datafile Download | ||
|
|
||
| Submits guestbook answers for a datafile and returns a signed URL. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { submitGuestbookForDatafileDownload } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| submitGuestbookForDatafileDownload | ||
| .execute(10, { | ||
| guestbookResponse: { | ||
| answers: [ | ||
| { id: 123, value: 'Good' }, | ||
| { id: 124, value: ['Multi', 'Line'] } | ||
| ] | ||
| } | ||
| }) | ||
| .then((signedUrl: string) => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/access/domain/useCases/SubmitGuestbookForDatafileDownload.ts) implementation_. | ||
|
|
||
| #### Submit Guestbook For Datafiles Download | ||
|
|
||
| Submits guestbook answers for multiple files and returns a signed URL. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { submitGuestbookForDatafilesDownload } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| submitGuestbookForDatafilesDownload | ||
| .execute([10, 11], { | ||
| guestbookResponse: { | ||
| answers: [ | ||
| { id: 123, value: 'Good' }, | ||
| { id: 124, value: ['Multi', 'Line'] }, | ||
| { id: 125, value: 'Yellow' } | ||
| ] | ||
| } | ||
| }) | ||
| .then((signedUrl: string) => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/access/domain/useCases/SubmitGuestbookForDatafilesDownload.ts) implementation_. | ||
|
|
||
| #### Submit Guestbook For Dataset Download | ||
|
|
||
| Submits guestbook answers for dataset download and returns a signed URL. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { submitGuestbookForDatasetDownload } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| submitGuestbookForDatasetDownload | ||
| .execute('doi:10.5072/FK2/XXXXXX', { | ||
| guestbookResponse: { | ||
| answers: [ | ||
| { id: 123, value: 'Good' }, | ||
| { id: 124, value: ['Multi', 'Line'] }, | ||
| { id: 125, value: 'Yellow' } | ||
| ] | ||
| } | ||
| }) | ||
| .then((signedUrl: string) => { | ||
ChengShi-1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/access/domain/useCases/SubmitGuestbookForDatasetDownload.ts) implementation_. | ||
|
|
||
| #### Submit Guestbook For Dataset Version Download | ||
|
|
||
| Submits guestbook answers for a specific dataset version and returns a signed URL. | ||
|
|
||
| ##### Example call: | ||
|
|
||
| ```typescript | ||
| import { submitGuestbookForDatasetVersionDownload } from '@iqss/dataverse-client-javascript' | ||
|
|
||
| submitGuestbookForDatasetVersionDownload | ||
| .execute(10, ':latest', { | ||
| guestbookResponse: { | ||
| answers: [ | ||
| { id: 123, value: 'Good' }, | ||
| { id: 124, value: ['Multi', 'Line'] }, | ||
| { id: 125, value: 'Yellow' } | ||
| ] | ||
| } | ||
| }) | ||
|
Comment on lines
3083
to
3092
|
||
| .then((signedUrl: string) => { | ||
| /* ... */ | ||
| }) | ||
| ``` | ||
|
|
||
| _See [use case](../src/access/domain/useCases/SubmitGuestbookForDatasetVersionDownload.ts) implementation_. | ||
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,10 @@ | ||
| export interface GuestbookAnswerDTO { | ||
| id: number | string | ||
| value: string | string[] | ||
| } | ||
|
|
||
| export interface GuestbookResponseDTO { | ||
| guestbookResponse: { | ||
| answers: GuestbookAnswerDTO[] | ||
| } | ||
| } |
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,32 @@ | ||
| import { GuestbookResponseDTO } from '../dtos/GuestbookResponseDTO' | ||
|
|
||
| export interface IAccessRepository { | ||
| getSignedDatafileDownloadUrl(fileId: number | string): Promise<string> | ||
|
|
||
| getSignedDatafilesDownloadUrl(fileIds: string | Array<number | string>): Promise<string> | ||
|
|
||
| getSignedDatasetDownloadUrl(datasetId: number | string): Promise<string> | ||
|
|
||
| getSignedDatasetVersionDownloadUrl(datasetId: number | string, versionId: string): Promise<string> | ||
|
|
||
| submitGuestbookForDatafileDownload( | ||
| fileId: number | string, | ||
| guestbookResponse: GuestbookResponseDTO | ||
| ): Promise<string> | ||
|
|
||
| submitGuestbookForDatafilesDownload( | ||
| fileIds: string | Array<number | string>, | ||
| guestbookResponse: GuestbookResponseDTO | ||
| ): Promise<string> | ||
|
|
||
| submitGuestbookForDatasetDownload( | ||
| datasetId: number | string, | ||
| guestbookResponse: GuestbookResponseDTO | ||
| ): Promise<string> | ||
|
|
||
| submitGuestbookForDatasetVersionDownload( | ||
| datasetId: number | string, | ||
| versionId: string, | ||
| guestbookResponse: GuestbookResponseDTO | ||
| ): Promise<string> | ||
| } |
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.