Skip to content

Commit 1918a84

Browse files
committed
docs: update README and add usage documentation; remove installation guide
1 parent fc62010 commit 1918a84

File tree

4 files changed

+109
-132
lines changed

4 files changed

+109
-132
lines changed

README.md

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,49 @@
1-
# js-dataverse
1+
## Dataverse JavaScript Client
22

3-
[![npm](https://img.shields.io/npm/v/js-dataverse.svg)](https://www.npmjs.com/package/js-dataverse)
3+
![NPM Version](https://img.shields.io/npm/v/%40iqss%2Fdataverse-client-javascript)
44

5-
A JavaScript/TypeScript API wrapper for [Dataverse](http://guides.dataverse.org/en/latest/api/).
5+
The Dataverse JavaScript Client is an open-source package that provides a set of use-case-driven functions to interact with the [Dataverse API](http://guides.dataverse.org/en/latest/api/). Designed around Domain-Driven Design (DDD) principles, this package offers a structured, high-level interface to perform actions like retrieving datasets, managing collections, uploading files, and more.
66

7-
- [Installation](./docs/installation.md)
8-
- [Use Cases](./docs/useCases.md)
9-
- [Local Development](./docs/localDevelopment.md)
10-
- [Contributing](./CONTRIBUTING.md)
11-
- [License](./LICENSE)
7+
This package is part of the Dataverse Frontend ecosystem and is intended to be used by applications or services that integrate with the Dataverse platform.
8+
9+
## Features
10+
11+
- **Use case-centric API functions** – Organized around domain-specific actions like `getDataset`, `createCollection`, or `restrictFile`.
12+
- **TypeScript-first** – All use cases include strong typings for inputs and outputs, improving developer experience.
13+
14+
## Installation
15+
16+
Install the package via npm:
17+
18+
```bash
19+
npm install @iqss/dataverse-client-javascript
20+
```
21+
22+
## Usage
23+
24+
```typescript
25+
import { getDataset } from '@iqss/dataverse-client-javascript'
26+
27+
/* ... */
28+
29+
const datasetIdentifier = 'doi:10.77777/FK2/AAAAAA'
30+
const datasetVersion = '1.0'
31+
32+
getDataset.execute(datasetIdentifier, datasetVersion).then((dataset: Dataset) => {
33+
/* ... */
34+
})
35+
36+
/* ... */
37+
```
38+
39+
For detailed information about available use cases see [Use Cases Docs](https://github.com/IQSS/dataverse-client-javascript/blob/develop/docs/useCases.md).
40+
41+
For detailed information about usage see [Usage Docs](https://github.com/IQSS/dataverse-client-javascript/blob/develop/docs/usage.md).
42+
43+
## Contributing
44+
45+
Want to add a new use case or improve an existing one? Please check the [Contributing](https://github.com/IQSS/dataverse-client-javascript/blob/develop/CONTRIBUTING.md) section.
46+
47+
## License
48+
49+
This project is open source and available under the [MIT License](https://github.com/IQSS/dataverse-client-javascript/blob/develop/LICENSE).

docs/installation.md

Lines changed: 0 additions & 124 deletions
This file was deleted.

docs/localDevelopment.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,21 @@ Fix linting checks on the code:
117117
```bash
118118
npm run lint:fix
119119
```
120+
121+
## Development Versions of this package
122+
123+
Two different versions are being pushed to the GitHub Packages registry:
124+
125+
1. **PR-Generated Versions**:
126+
127+
- These versions are generated from pull request commits.
128+
- They follow the structure `2.1.0-pr<pr_number>.<commit_hash>`, where `pr_number` is the number of the pull request, and `commit_hash` is the specific commit hash from the PR branch.
129+
- These versions are unstable and correspond to the state of the package during the pull request.
130+
131+
2. **Develop Alpha Versions**:
132+
- These versions are generated on every commit made to the `develop` branch, ideally after each pull request is merged.
133+
- They follow the structure `2.1.0-alpha.<number>`, where `number` is an incremental value that starts at 1 and increases with each build.
134+
- These versions are also unstable and represent the latest work in progress on the `develop` branch.
135+
136+
These versions are great for developing a new SPA frontend feature integration.
137+
For instance, if you create a new use case in this repository and want to integrate the UI in the [dataverse-frontend repository](https://github.com/IQSS/dataverse-frontend), you can use the PR-Generated Version. If the changes have already been merged, the Alpha Version will contain the new use case.

docs/usage.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Initialization
2+
3+
In order for the package to connect to the Dataverse API, there is an `APIConfig` object that should be initialized to set the preferred authentication mechanism with the associated credentials for connecting to the Dataverse API.
4+
5+
Currently, the supported authentication mechanisms are:
6+
7+
- **API Key**: The recommended authentication mechanism. The API Key should correspond to a particular Dataverse user account.
8+
9+
- **Bearer Token**: This mechanism is currently under development and testing. We've selected it for the upcoming Dataverse SPA and will provide more information in a future release once it becomes a standard.
10+
11+
- **Session Cookie**: This is an experimental feature primarily designed for Dataverse SPA development. To use this mechanism, you must enable the corresponding feature flag in the Dataverse installation (See https://guides.dataverse.org/en/latest/installation/config.html?#feature-flags). It is recommended not to use this mechanism and instead use API Key authentication.
12+
13+
It is recommended to globally initialize the `ApiConfig` object from the consuming application, as the configuration will be read on every API call made by the package's use cases.
14+
15+
For example, in a React application, we can globally initialize the `ApiConfig` object in the `App` file, like this:
16+
17+
```typescript
18+
ApiConfig.init(<DATAVERSE_API_BASE_URL>, DataverseApiAuthMechanism.API_KEY, <DATAVERSE_API_KEY>)
19+
20+
function App() {
21+
/* Yor App code */
22+
}
23+
24+
export default App
25+
```
26+
27+
The same example but with example values set:
28+
29+
```typescript
30+
ApiConfig.init(
31+
'http://localhost:8000/api/v1',
32+
DataverseApiAuthMechanism.API_KEY,
33+
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
34+
)
35+
36+
function App() {
37+
/* Yor App code */
38+
}
39+
40+
export default App
41+
```
42+
43+
We can initialize the `ApiConfig` object as an unauthenticated user, by setting `undefined` as the API Key value.
44+
45+
This will allow use cases that do not require authentication to be successfully executed, but those that do require authentication will fail.

0 commit comments

Comments
 (0)